@uiw/react-codemirror 4.13.2 → 4.14.0
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.
- package/README.md +2 -0
- package/dist/mdeditor.js +84 -41
- package/dist/mdeditor.min.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -65,6 +65,8 @@ npm install @uiw/react-codemirror --save
|
|
|
65
65
|
| `@uiw/codemirror-theme-gruvbox-dark` | [](https://www.npmjs.com/package/@uiw/codemirror-theme-gruvbox-dark) [](https://www.npmjs.com/package/@uiw/codemirror-theme-gruvbox-dark) | [`#preview`](https://uiwjs.github.io/react-codemirror/#/theme/data/gruvbox/dark) |
|
|
66
66
|
| `@uiw/codemirror-theme-okaidia` | [](https://www.npmjs.com/package/@uiw/codemirror-theme-okaidia) [](https://www.npmjs.com/package/@uiw/codemirror-theme-okaidia) | [`#preview`](https://uiwjs.github.io/react-codemirror/#/theme/data/okaidia) |
|
|
67
67
|
| `@uiw/codemirror-theme-sublime` | [](https://www.npmjs.com/package/@uiw/codemirror-theme-sublime) [](https://www.npmjs.com/package/@uiw/codemirror-theme-sublime) | [`#preview`](https://uiwjs.github.io/react-codemirror/#/theme/data/sublime) |
|
|
68
|
+
| `@uiw/codemirror-theme-vscode` | [](https://www.npmjs.com/package/@uiw/codemirror-theme-vscode) [](https://www.npmjs.com/package/@uiw/codemirror-theme-vscode) | [`#preview`](https://uiwjs.github.io/react-codemirror/#/theme/data/vscode) |
|
|
69
|
+
| `@uiw/codemirror-theme-xcode` | [](https://www.npmjs.com/package/@uiw/codemirror-theme-xcode) [](https://www.npmjs.com/package/@uiw/codemirror-theme-xcode) | [`#preview`](https://uiwjs.github.io/react-codemirror/#/theme/data/xcode) |
|
|
68
70
|
|
|
69
71
|
<!--rehype:style=width: 100%; display: inline-table;-->
|
|
70
72
|
|
package/dist/mdeditor.js
CHANGED
|
@@ -3678,8 +3678,10 @@ class LanguageDescription {
|
|
|
3678
3678
|
Facet that defines a way to provide a function that computes the
|
|
3679
3679
|
appropriate indentation depth, as a column number (see
|
|
3680
3680
|
[`indentString`](https://codemirror.net/6/docs/ref/#language.indentString)), at the start of a given
|
|
3681
|
-
line
|
|
3682
|
-
determined
|
|
3681
|
+
line. A return value of `null` indicates no indentation can be
|
|
3682
|
+
determined, and the line should inherit the indentation of the one
|
|
3683
|
+
above it. A return value of `undefined` defers to the next indent
|
|
3684
|
+
service.
|
|
3683
3685
|
*/
|
|
3684
3686
|
const indentService = /*@__PURE__*/state_.Facet.define();
|
|
3685
3687
|
/**
|
|
@@ -3737,7 +3739,7 @@ function getIndentation(context, pos) {
|
|
|
3737
3739
|
context = new IndentContext(context);
|
|
3738
3740
|
for (let service of context.state.facet(indentService)) {
|
|
3739
3741
|
let result = service(context, pos);
|
|
3740
|
-
if (result
|
|
3742
|
+
if (result !== undefined)
|
|
3741
3743
|
return result;
|
|
3742
3744
|
}
|
|
3743
3745
|
let tree = dist_syntaxTree(context.state);
|
|
@@ -4098,7 +4100,7 @@ function syntaxFolding(state, start, end) {
|
|
|
4098
4100
|
let tree = dist_syntaxTree(state);
|
|
4099
4101
|
if (tree.length < end)
|
|
4100
4102
|
return null;
|
|
4101
|
-
let inner = tree.resolveInner(end);
|
|
4103
|
+
let inner = tree.resolveInner(end, 1);
|
|
4102
4104
|
let found = null;
|
|
4103
4105
|
for (let cur = inner; cur; cur = cur.parent) {
|
|
4104
4106
|
if (cur.to <= end || cur.from > end)
|
|
@@ -7988,14 +7990,14 @@ class SearchPanel {
|
|
|
7988
7990
|
crelt("br"),
|
|
7989
7991
|
this.replaceField,
|
|
7990
7992
|
button("replace", () => replaceNext(view), [phrase(view, "replace")]),
|
|
7991
|
-
button("replaceAll", () => replaceAll(view), [phrase(view, "replace all")])
|
|
7992
|
-
|
|
7993
|
-
|
|
7994
|
-
|
|
7995
|
-
|
|
7996
|
-
|
|
7997
|
-
|
|
7998
|
-
]
|
|
7993
|
+
button("replaceAll", () => replaceAll(view), [phrase(view, "replace all")])
|
|
7994
|
+
],
|
|
7995
|
+
crelt("button", {
|
|
7996
|
+
name: "close",
|
|
7997
|
+
onclick: () => closeSearchPanel(view),
|
|
7998
|
+
"aria-label": phrase(view, "close"),
|
|
7999
|
+
type: "button"
|
|
8000
|
+
}, ["×"])
|
|
7999
8001
|
]);
|
|
8000
8002
|
}
|
|
8001
8003
|
commit() {
|
|
@@ -8257,7 +8259,7 @@ function ensureAnchor(expr, start) {
|
|
|
8257
8259
|
This annotation is added to transactions that are produced by
|
|
8258
8260
|
picking a completion.
|
|
8259
8261
|
*/
|
|
8260
|
-
const pickedCompletion = /*@__PURE__*/
|
|
8262
|
+
const pickedCompletion = /*@__PURE__*/state_.Annotation.define();
|
|
8261
8263
|
/**
|
|
8262
8264
|
Helper function that returns a transaction spec which inserts a
|
|
8263
8265
|
completion's text in the main selection range, and any other
|
|
@@ -8284,7 +8286,7 @@ function applyCompletion(view, option) {
|
|
|
8284
8286
|
const apply = option.completion.apply || option.completion.label;
|
|
8285
8287
|
let result = option.source;
|
|
8286
8288
|
if (typeof apply == "string")
|
|
8287
|
-
view.dispatch(insertCompletionText(view.state, apply, result.from, result.to));
|
|
8289
|
+
view.dispatch(Object.assign(Object.assign({}, insertCompletionText(view.state, apply, result.from, result.to)), { annotations: pickedCompletion.of(option.completion) }));
|
|
8288
8290
|
else
|
|
8289
8291
|
apply(view, option.completion, result.from, result.to);
|
|
8290
8292
|
}
|
|
@@ -8519,6 +8521,7 @@ class CompletionTooltip {
|
|
|
8519
8521
|
write: (pos) => this.positionInfo(pos),
|
|
8520
8522
|
key: this
|
|
8521
8523
|
};
|
|
8524
|
+
this.space = null;
|
|
8522
8525
|
let cState = view.state.field(stateField);
|
|
8523
8526
|
let { options, selected } = cState.open;
|
|
8524
8527
|
let config = view.state.facet(completionConfig);
|
|
@@ -8544,10 +8547,17 @@ class CompletionTooltip {
|
|
|
8544
8547
|
}
|
|
8545
8548
|
mount() { this.updateSel(); }
|
|
8546
8549
|
update(update) {
|
|
8547
|
-
|
|
8550
|
+
var _a, _b, _c;
|
|
8551
|
+
let cState = update.state.field(this.stateField);
|
|
8552
|
+
let prevState = update.startState.field(this.stateField);
|
|
8553
|
+
if (cState != prevState) {
|
|
8548
8554
|
this.updateSel();
|
|
8555
|
+
if (((_a = cState.open) === null || _a === void 0 ? void 0 : _a.disabled) != ((_b = prevState.open) === null || _b === void 0 ? void 0 : _b.disabled))
|
|
8556
|
+
this.dom.classList.toggle("cm-tooltip-autocomplete-disabled", !!((_c = cState.open) === null || _c === void 0 ? void 0 : _c.disabled));
|
|
8557
|
+
}
|
|
8549
8558
|
}
|
|
8550
|
-
positioned() {
|
|
8559
|
+
positioned(space) {
|
|
8560
|
+
this.space = space;
|
|
8551
8561
|
if (this.info)
|
|
8552
8562
|
this.view.requestMeasure(this.placeInfo);
|
|
8553
8563
|
}
|
|
@@ -8614,27 +8624,32 @@ class CompletionTooltip {
|
|
|
8614
8624
|
let sel = this.dom.querySelector("[aria-selected]");
|
|
8615
8625
|
if (!sel || !this.info)
|
|
8616
8626
|
return null;
|
|
8617
|
-
let win = this.dom.ownerDocument.defaultView || window;
|
|
8618
8627
|
let listRect = this.dom.getBoundingClientRect();
|
|
8619
8628
|
let infoRect = this.info.getBoundingClientRect();
|
|
8620
8629
|
let selRect = sel.getBoundingClientRect();
|
|
8621
|
-
|
|
8630
|
+
let space = this.space;
|
|
8631
|
+
if (!space) {
|
|
8632
|
+
let win = this.dom.ownerDocument.defaultView || window;
|
|
8633
|
+
space = { left: 0, top: 0, right: win.innerWidth, bottom: win.innerHeight };
|
|
8634
|
+
}
|
|
8635
|
+
if (selRect.top > Math.min(space.bottom, listRect.bottom) - 10 ||
|
|
8636
|
+
selRect.bottom < Math.max(space.top, listRect.top) + 10)
|
|
8622
8637
|
return null;
|
|
8623
8638
|
let rtl = this.view.textDirection == view_.Direction.RTL, left = rtl, narrow = false, maxWidth;
|
|
8624
8639
|
let top = "", bottom = "";
|
|
8625
|
-
let spaceLeft = listRect.left, spaceRight =
|
|
8640
|
+
let spaceLeft = listRect.left - space.left, spaceRight = space.right - listRect.right;
|
|
8626
8641
|
if (left && spaceLeft < Math.min(infoRect.width, spaceRight))
|
|
8627
8642
|
left = false;
|
|
8628
8643
|
else if (!left && spaceRight < Math.min(infoRect.width, spaceLeft))
|
|
8629
8644
|
left = true;
|
|
8630
8645
|
if (infoRect.width <= (left ? spaceLeft : spaceRight)) {
|
|
8631
|
-
top = (Math.max(
|
|
8646
|
+
top = (Math.max(space.top, Math.min(selRect.top, space.bottom - infoRect.height)) - listRect.top) + "px";
|
|
8632
8647
|
maxWidth = Math.min(400 /* Info.Width */, left ? spaceLeft : spaceRight) + "px";
|
|
8633
8648
|
}
|
|
8634
8649
|
else {
|
|
8635
8650
|
narrow = true;
|
|
8636
|
-
maxWidth = Math.min(400 /* Info.Width */, (rtl ? listRect.right :
|
|
8637
|
-
let spaceBelow =
|
|
8651
|
+
maxWidth = Math.min(400 /* Info.Width */, (rtl ? listRect.right : space.right - listRect.left) - 30 /* Info.Margin */) + "px";
|
|
8652
|
+
let spaceBelow = space.bottom - listRect.bottom;
|
|
8638
8653
|
if (spaceBelow >= infoRect.height || spaceBelow > listRect.top) // Below the completion
|
|
8639
8654
|
top = (selRect.bottom - listRect.top) + "px";
|
|
8640
8655
|
else // Above it
|
|
@@ -8743,21 +8758,24 @@ function sortOptions(active, state) {
|
|
|
8743
8758
|
return result;
|
|
8744
8759
|
}
|
|
8745
8760
|
class CompletionDialog {
|
|
8746
|
-
constructor(options, attrs, tooltip, timestamp, selected) {
|
|
8761
|
+
constructor(options, attrs, tooltip, timestamp, selected, disabled) {
|
|
8747
8762
|
this.options = options;
|
|
8748
8763
|
this.attrs = attrs;
|
|
8749
8764
|
this.tooltip = tooltip;
|
|
8750
8765
|
this.timestamp = timestamp;
|
|
8751
8766
|
this.selected = selected;
|
|
8767
|
+
this.disabled = disabled;
|
|
8752
8768
|
}
|
|
8753
8769
|
setSelected(selected, id) {
|
|
8754
8770
|
return selected == this.selected || selected >= this.options.length ? this
|
|
8755
|
-
: new CompletionDialog(this.options, makeAttrs(id, selected), this.tooltip, this.timestamp, selected);
|
|
8771
|
+
: new CompletionDialog(this.options, makeAttrs(id, selected), this.tooltip, this.timestamp, selected, this.disabled);
|
|
8756
8772
|
}
|
|
8757
8773
|
static build(active, state, id, prev, conf) {
|
|
8758
8774
|
let options = sortOptions(active, state);
|
|
8759
|
-
if (!options.length)
|
|
8760
|
-
return
|
|
8775
|
+
if (!options.length) {
|
|
8776
|
+
return prev && active.some(a => a.state == 1 /* State.Pending */) ?
|
|
8777
|
+
new CompletionDialog(prev.options, prev.attrs, prev.tooltip, prev.timestamp, prev.selected, true) : null;
|
|
8778
|
+
}
|
|
8761
8779
|
let selected = state.facet(completionConfig).selectOnOpen ? 0 : -1;
|
|
8762
8780
|
if (prev && prev.selected != selected && prev.selected != -1) {
|
|
8763
8781
|
let selectedValue = prev.options[prev.selected].completion;
|
|
@@ -8771,10 +8789,10 @@ class CompletionDialog {
|
|
|
8771
8789
|
pos: active.reduce((a, b) => b.hasResult() ? Math.min(a, b.from) : a, 1e8),
|
|
8772
8790
|
create: completionTooltip(completionState),
|
|
8773
8791
|
above: conf.aboveCursor,
|
|
8774
|
-
}, prev ? prev.timestamp : Date.now(), selected);
|
|
8792
|
+
}, prev ? prev.timestamp : Date.now(), selected, false);
|
|
8775
8793
|
}
|
|
8776
8794
|
map(changes) {
|
|
8777
|
-
return new CompletionDialog(this.options, this.attrs, Object.assign(Object.assign({}, this.tooltip), { pos: changes.mapPos(this.tooltip.pos) }), this.timestamp, this.selected);
|
|
8795
|
+
return new CompletionDialog(this.options, this.attrs, Object.assign(Object.assign({}, this.tooltip), { pos: changes.mapPos(this.tooltip.pos) }), this.timestamp, this.selected, this.disabled);
|
|
8778
8796
|
}
|
|
8779
8797
|
}
|
|
8780
8798
|
class CompletionState {
|
|
@@ -8797,9 +8815,14 @@ class CompletionState {
|
|
|
8797
8815
|
});
|
|
8798
8816
|
if (active.length == this.active.length && active.every((a, i) => a == this.active[i]))
|
|
8799
8817
|
active = this.active;
|
|
8800
|
-
let open =
|
|
8801
|
-
|
|
8802
|
-
|
|
8818
|
+
let open = this.open;
|
|
8819
|
+
if (tr.selection || active.some(a => a.hasResult() && tr.changes.touchesRange(a.from, a.to)) ||
|
|
8820
|
+
!sameResults(active, this.active))
|
|
8821
|
+
open = CompletionDialog.build(active, state, this.id, this.open, conf);
|
|
8822
|
+
else if (open && open.disabled && !active.some(a => a.state == 1 /* State.Pending */))
|
|
8823
|
+
open = null;
|
|
8824
|
+
else if (open && tr.docChanged)
|
|
8825
|
+
open = open.map(tr.changes);
|
|
8803
8826
|
if (!open && active.every(a => a.state != 1 /* State.Pending */) && active.some(a => a.hasResult()))
|
|
8804
8827
|
active = active.map(a => a.hasResult() ? new ActiveSource(a.source, 0 /* State.Inactive */) : a);
|
|
8805
8828
|
for (let effect of tr.effects)
|
|
@@ -8939,7 +8962,7 @@ backward by the given amount.
|
|
|
8939
8962
|
function moveCompletionSelection(forward, by = "option") {
|
|
8940
8963
|
return (view) => {
|
|
8941
8964
|
let cState = view.state.field(completionState, false);
|
|
8942
|
-
if (!cState || !cState.open ||
|
|
8965
|
+
if (!cState || !cState.open || cState.open.disabled ||
|
|
8943
8966
|
Date.now() - cState.open.timestamp < view.state.facet(completionConfig).interactionDelay)
|
|
8944
8967
|
return false;
|
|
8945
8968
|
let step = 1, tooltip;
|
|
@@ -8964,7 +8987,8 @@ const acceptCompletion = (view) => {
|
|
|
8964
8987
|
if (view.state.readOnly || !cState || !cState.open || cState.open.selected < 0 ||
|
|
8965
8988
|
Date.now() - cState.open.timestamp < view.state.facet(completionConfig).interactionDelay)
|
|
8966
8989
|
return false;
|
|
8967
|
-
|
|
8990
|
+
if (!cState.open.disabled)
|
|
8991
|
+
applyCompletion(view, cState.open.options[cState.open.selected]);
|
|
8968
8992
|
return true;
|
|
8969
8993
|
};
|
|
8970
8994
|
/**
|
|
@@ -9169,10 +9193,16 @@ const autocomplete_dist_baseTheme = /*@__PURE__*/view_.EditorView.baseTheme({
|
|
|
9169
9193
|
background: "#17c",
|
|
9170
9194
|
color: "white",
|
|
9171
9195
|
},
|
|
9196
|
+
"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]": {
|
|
9197
|
+
background: "#777",
|
|
9198
|
+
},
|
|
9172
9199
|
"&dark .cm-tooltip-autocomplete ul li[aria-selected]": {
|
|
9173
9200
|
background: "#347",
|
|
9174
9201
|
color: "white",
|
|
9175
9202
|
},
|
|
9203
|
+
"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]": {
|
|
9204
|
+
background: "#444",
|
|
9205
|
+
},
|
|
9176
9206
|
".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after": {
|
|
9177
9207
|
content: '"···"',
|
|
9178
9208
|
opacity: 0.5,
|
|
@@ -9881,7 +9911,7 @@ Returns the available completions as an array.
|
|
|
9881
9911
|
function currentCompletions(state) {
|
|
9882
9912
|
var _a;
|
|
9883
9913
|
let open = (_a = state.field(completionState, false)) === null || _a === void 0 ? void 0 : _a.open;
|
|
9884
|
-
if (!open)
|
|
9914
|
+
if (!open || open.disabled)
|
|
9885
9915
|
return [];
|
|
9886
9916
|
let completions = completionArrayCache.get(open.options);
|
|
9887
9917
|
if (!completions)
|
|
@@ -9894,7 +9924,7 @@ Return the currently selected completion, if any.
|
|
|
9894
9924
|
function selectedCompletion(state) {
|
|
9895
9925
|
var _a;
|
|
9896
9926
|
let open = (_a = state.field(completionState, false)) === null || _a === void 0 ? void 0 : _a.open;
|
|
9897
|
-
return open && open.selected >= 0 ? open.options[open.selected].completion : null;
|
|
9927
|
+
return open && !open.disabled && open.selected >= 0 ? open.options[open.selected].completion : null;
|
|
9898
9928
|
}
|
|
9899
9929
|
/**
|
|
9900
9930
|
Returns the currently selected position in the active completion
|
|
@@ -9903,7 +9933,7 @@ list, or null if no completions are active.
|
|
|
9903
9933
|
function selectedCompletionIndex(state) {
|
|
9904
9934
|
var _a;
|
|
9905
9935
|
let open = (_a = state.field(completionState, false)) === null || _a === void 0 ? void 0 : _a.open;
|
|
9906
|
-
return open && open.selected >= 0 ? open.selected : null;
|
|
9936
|
+
return open && !open.disabled && open.selected >= 0 ? open.selected : null;
|
|
9907
9937
|
}
|
|
9908
9938
|
/**
|
|
9909
9939
|
Create an effect that can be attached to a transaction to change
|
|
@@ -10107,7 +10137,7 @@ A set of default key bindings for the lint functionality.
|
|
|
10107
10137
|
- F8: [`nextDiagnostic`](https://codemirror.net/6/docs/ref/#lint.nextDiagnostic)
|
|
10108
10138
|
*/
|
|
10109
10139
|
const lintKeymap = [
|
|
10110
|
-
{ key: "Mod-Shift-m", run: openLintPanel },
|
|
10140
|
+
{ key: "Mod-Shift-m", run: openLintPanel, preventDefault: true },
|
|
10111
10141
|
{ key: "F8", run: nextDiagnostic }
|
|
10112
10142
|
];
|
|
10113
10143
|
const lintPlugin = /*@__PURE__*/view_.ViewPlugin.fromClass(class {
|
|
@@ -10521,8 +10551,8 @@ class LintGutterMarker extends view_.GutterMarker {
|
|
|
10521
10551
|
function trackHoverOn(view, marker) {
|
|
10522
10552
|
let mousemove = (event) => {
|
|
10523
10553
|
let rect = marker.getBoundingClientRect();
|
|
10524
|
-
if (event.clientX > rect.left - 10 /* Margin */ && event.clientX < rect.right + 10 /* Margin */ &&
|
|
10525
|
-
event.clientY > rect.top - 10 /* Margin */ && event.clientY < rect.bottom + 10 /* Margin */)
|
|
10554
|
+
if (event.clientX > rect.left - 10 /* Hover.Margin */ && event.clientX < rect.right + 10 /* Hover.Margin */ &&
|
|
10555
|
+
event.clientY > rect.top - 10 /* Hover.Margin */ && event.clientY < rect.bottom + 10 /* Hover.Margin */)
|
|
10526
10556
|
return;
|
|
10527
10557
|
for (let target = event.target; target; target = target.parentNode) {
|
|
10528
10558
|
if (target.nodeType == 1 && target.classList.contains("cm-tooltip-lint"))
|
|
@@ -10625,14 +10655,14 @@ const lintGutterTheme = /*@__PURE__*/view_.EditorView.baseTheme({
|
|
|
10625
10655
|
".cm-lint-marker-warning": {
|
|
10626
10656
|
content: /*@__PURE__*/svg(`<path fill="#fe8" stroke="#fd7" stroke-width="6" stroke-linejoin="round" d="M20 6L37 35L3 35Z"/>`),
|
|
10627
10657
|
},
|
|
10628
|
-
".cm-lint-marker-error
|
|
10658
|
+
".cm-lint-marker-error": {
|
|
10629
10659
|
content: /*@__PURE__*/svg(`<circle cx="20" cy="20" r="15" fill="#f87" stroke="#f43" stroke-width="6"/>`)
|
|
10630
10660
|
},
|
|
10631
10661
|
});
|
|
10632
10662
|
const lintGutterConfig = /*@__PURE__*/state_.Facet.define({
|
|
10633
10663
|
combine(configs) {
|
|
10634
10664
|
return (0,state_.combineConfig)(configs, {
|
|
10635
|
-
hoverTime: 300 /* Time */,
|
|
10665
|
+
hoverTime: 300 /* Hover.Time */,
|
|
10636
10666
|
markerFilter: null,
|
|
10637
10667
|
tooltipFilter: null
|
|
10638
10668
|
});
|
|
@@ -10646,6 +10676,19 @@ the diagnostics.
|
|
|
10646
10676
|
function lintGutter(config = {}) {
|
|
10647
10677
|
return [lintGutterConfig.of(config), lintGutterMarkers, lintGutterExtension, lintGutterTheme, lintGutterTooltip];
|
|
10648
10678
|
}
|
|
10679
|
+
/**
|
|
10680
|
+
Iterate over the marked diagnostics for the given editor state,
|
|
10681
|
+
calling `f` for each of them. Note that, if the document changed
|
|
10682
|
+
since the diagnostics werecreated, the `Diagnostic` object will
|
|
10683
|
+
hold the original outdated position, whereas the `to` and `from`
|
|
10684
|
+
arguments hold the diagnostic's current position.
|
|
10685
|
+
*/
|
|
10686
|
+
function forEachDiagnostic(state, f) {
|
|
10687
|
+
let lState = state.field(lintState, false);
|
|
10688
|
+
if (lState && lState.diagnostics.size)
|
|
10689
|
+
for (let iter = RangeSet.iter([lState.diagnostics]); iter.value; iter.next())
|
|
10690
|
+
f(iter.value.spec.diagnostic, iter.from, iter.to);
|
|
10691
|
+
}
|
|
10649
10692
|
|
|
10650
10693
|
|
|
10651
10694
|
|
package/dist/mdeditor.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see mdeditor.min.js.LICENSE.txt */
|
|
2
|
-
!function(e,t){"object"===typeof exports&&"object"===typeof module?module.exports=t(require("react"),require("@codemirror/state"),require("@codemirror/theme-one-dark"),require("@codemirror/view")):"function"===typeof define&&define.amd?define(["react",,,],t):"object"===typeof exports?exports["@uiw/codemirror"]=t(require("react"),require("@codemirror/state"),require("@codemirror/theme-one-dark"),require("@codemirror/view")):e["@uiw/codemirror"]=t(e.React,e.CM["@codemirror/state"],e.CM["@codemirror/theme-one-dark"],e.CM["@codemirror/view"])}(self,((e,t,n,i)=>(()=>{"use strict";var r={298:(e,t,n)=>{var i=n(787),r=Symbol.for("react.element"),o=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,l=i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,n){var i,o={},c=null,h=null;for(i in void 0!==n&&(c=""+n),void 0!==t.key&&(c=""+t.key),void 0!==t.ref&&(h=t.ref),t)s.call(t,i)&&!a.hasOwnProperty(i)&&(o[i]=t[i]);if(e&&e.defaultProps)for(i in t=e.defaultProps)void 0===o[i]&&(o[i]=t[i]);return{$$typeof:r,type:e,key:c,ref:h,props:o,_owner:l.current}}t.jsx=c},605:(e,t,n)=>{e.exports=n(298)},787:t=>{t.exports=e},242:e=>{e.exports=t},362:e=>{e.exports=n},105:e=>{e.exports=i}},o={};function s(e){var t=o[e];if(void 0!==t)return t.exports;var n=o[e]={exports:{}};return r[e](n,n.exports,s),n.exports}s.d=(e,t)=>{for(var n in t)s.o(t,n)&&!s.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),s.r=e=>{"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var l={};return(()=>{function e(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function t(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function n(e,t){if(null==e)return{};var n,i,r=function(e,t){if(null==e)return{};var n,i,r={},o=Object.keys(e);for(i=0;i<o.length;i++)n=o[i],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(i=0;i<o.length;i++)n=o[i],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}s.r(l),s.d(l,{basicSetup:()=>No,default:()=>jo,getStatistics:()=>_o,minimalSetup:()=>Ro,useCodeMirror:()=>Fo});var i=s(787);function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function o(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!==typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var i,r,o=[],s=!0,l=!1;try{for(n=n.call(e);!(s=(i=n.next()).done)&&(o.push(i.value),!t||o.length!==t);s=!0);}catch(a){l=!0,r=a}finally{try{s||null==n.return||n.return()}finally{if(l)throw r}}return o}}(e,t)||function(e,t){if(e){if("string"===typeof e)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var a=s(242),c=s(105);const h=1024;let u=0;class f{constructor(e,t){this.from=e,this.to=t}}class d{constructor(e={}){this.id=u++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof e&&(e=m.match(e)),t=>{let n=e(t);return void 0===n?null:[this,n]}}}d.closedBy=new d({deserialize:e=>e.split(" ")}),d.openedBy=new d({deserialize:e=>e.split(" ")}),d.group=new d({deserialize:e=>e.split(" ")}),d.contextHash=new d({perNode:!0}),d.lookAhead=new d({perNode:!0}),d.mounted=new d({perNode:!0});const p=Object.create(null);class m{constructor(e,t,n,i=0){this.name=e,this.props=t,this.id=n,this.flags=i}static define(e){let t=e.props&&e.props.length?Object.create(null):p,n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(null==e.name?8:0),i=new m(e.name||"",t,e.id,n);if(e.props)for(let r of e.props)if(Array.isArray(r)||(r=r(i)),r){if(r[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[r[0].id]=r[1]}return i}prop(e){return this.props[e.id]}get isTop(){return(1&this.flags)>0}get isSkipped(){return(2&this.flags)>0}get isError(){return(4&this.flags)>0}get isAnonymous(){return(8&this.flags)>0}is(e){if("string"==typeof e){if(this.name==e)return!0;let t=this.prop(d.group);return!!t&&t.indexOf(e)>-1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let i of n.split(" "))t[i]=e[n];return e=>{for(let n=e.prop(d.group),i=-1;i<(n?n.length:0);i++){let r=t[i<0?e.name:n[i]];if(r)return r}}}}m.none=new m("",Object.create(null),0,8);const g=new WeakMap,y=new WeakMap;var v;!function(e){e[e.ExcludeBuffers=1]="ExcludeBuffers",e[e.IncludeAnonymous=2]="IncludeAnonymous",e[e.IgnoreMounts=4]="IgnoreMounts",e[e.IgnoreOverlays=8]="IgnoreOverlays"}(v||(v={}));class b{constructor(e,t,n,i,r){if(this.type=e,this.children=t,this.positions=n,this.length=i,this.props=null,r&&r.length){this.props=Object.create(null);for(let[e,t]of r)this.props["number"==typeof e?e:e.id]=t}}toString(){let e=this.prop(d.mounted);if(e&&!e.overlay)return e.tree.toString();let t="";for(let n of this.children){let e=n.toString();e&&(t&&(t+=","),t+=e)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new P(this.topNode,e)}cursorAt(e,t=0,n=0){let i=g.get(this)||this.topNode,r=new P(i);return r.moveTo(e,t),g.set(this,r._tree),r}get topNode(){return new A(this,0,0,null)}resolve(e,t=0){let n=C(g.get(this)||this.topNode,e,t,!1);return g.set(this,n),n}resolveInner(e,t=0){let n=C(y.get(this)||this.topNode,e,t,!0);return y.set(this,n),n}iterate(e){let{enter:t,leave:n,from:i=0,to:r=this.length}=e;for(let o=this.cursor((e.mode||0)|v.IncludeAnonymous);;){let e=!1;if(o.from<=r&&o.to>=i&&(o.type.isAnonymous||!1!==t(o))){if(o.firstChild())continue;e=!0}for(;e&&n&&!o.type.isAnonymous&&n(o),!o.nextSibling();){if(!o.parent())return;e=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:N(m.none,this.children,this.positions,0,this.children.length,0,this.length,((e,t,n)=>new b(this.type,e,t,n,this.propValues)),e.makeTree||((e,t,n)=>new b(m.none,e,t,n)))}static build(e){return function(e){var t;let{buffer:n,nodeSet:i,maxBufferLength:r=h,reused:o=[],minRepeatType:s=i.types.length}=e,l=Array.isArray(n)?new w(n,n.length):n,a=i.types,c=0,u=0;function f(e,t,n,h,d){let{id:b,start:w,end:k,size:S}=l,C=u;for(;S<0;){if(l.next(),-1==S){let t=o[b];return n.push(t),void h.push(w-e)}if(-3==S)return void(c=b);if(-4==S)return void(u=b);throw new RangeError(`Unrecognized record size: ${S}`)}let A,E,M=a[b],O=w-e;if(k-w<=r&&(E=y(l.pos-t,d))){let t=new Uint16Array(E.size-E.skip),n=l.pos-E.size,r=t.length;for(;l.pos>n;)r=v(E.start,t,r);A=new x(t,k-E.start,i),O=E.start-e}else{let e=l.pos-S;l.next();let t=[],n=[],i=b>=s?b:-1,o=0,a=k;for(;l.pos>e;)i>=0&&l.id==i&&l.size>=0?(l.end<=a-r&&(m(t,n,w,o,l.end,a,i,C),o=t.length,a=l.end),l.next()):f(w,e,t,n,i);if(i>=0&&o>0&&o<t.length&&m(t,n,w,o,w,a,i,C),t.reverse(),n.reverse(),i>-1&&o>0){let e=p(M);A=N(M,t,n,0,t.length,0,k-w,e,e)}else A=g(M,t,n,k-w,C-k)}n.push(A),h.push(O)}function p(e){return(t,n,i)=>{let r,o,s=0,l=t.length-1;if(l>=0&&(r=t[l])instanceof b){if(!l&&r.type==e&&r.length==i)return r;(o=r.prop(d.lookAhead))&&(s=n[l]+r.length+o)}return g(e,t,n,i,s)}}function m(e,t,n,r,o,s,l,a){let c=[],h=[];for(;e.length>r;)c.push(e.pop()),h.push(t.pop()+n-o);e.push(g(i.types[l],c,h,s-o,a-s)),t.push(o-n)}function g(e,t,n,i,r=0,o){if(c){let e=[d.contextHash,c];o=o?[e].concat(o):[e]}if(r>25){let e=[d.lookAhead,r];o=o?[e].concat(o):[e]}return new b(e,t,n,i,o)}function y(e,t){let n=l.fork(),i=0,o=0,a=0,c=n.end-r,h={size:0,start:0,skip:0};e:for(let r=n.pos-e;n.pos>r;){let e=n.size;if(n.id==t&&e>=0){h.size=i,h.start=o,h.skip=a,a+=4,i+=4,n.next();continue}let l=n.pos-e;if(e<0||l<r||n.start<c)break;let u=n.id>=s?4:0,f=n.start;for(n.next();n.pos>l;){if(n.size<0){if(-3!=n.size)break e;u+=4}else n.id>=s&&(u+=4);n.next()}o=f,i+=e,a+=u}return(t<0||i==e)&&(h.size=i,h.start=o,h.skip=a),h.size>4?h:void 0}function v(e,t,n){let{id:i,start:r,end:o,size:a}=l;if(l.next(),a>=0&&i<s){let s=n;if(a>4){let i=l.pos-(a-4);for(;l.pos>i;)n=v(e,t,n)}t[--n]=s,t[--n]=o-e,t[--n]=r-e,t[--n]=i}else-3==a?c=i:-4==a&&(u=i);return n}let k=[],S=[];for(;l.pos>0;)f(e.start||0,e.bufferStart||0,k,S,-1);let C=null!==(t=e.length)&&void 0!==t?t:k.length?S[0]+k[0].length:0;return new b(a[e.topID],k.reverse(),S.reverse(),C)}(e)}}b.empty=new b(m.none,[],[],0);class w{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new w(this.buffer,this.index)}}class x{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return m.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],n=this.buffer[e+3],i=this.set.types[t],r=i.name;if(/\W/.test(r)&&!i.isError&&(r=JSON.stringify(r)),n==(e+=4))return r;let o=[];for(;e<n;)o.push(this.childString(e)),e=this.buffer[e+3];return r+"("+o.join(",")+")"}findChild(e,t,n,i,r){let{buffer:o}=this,s=-1;for(let l=e;l!=t&&!(k(r,i,o[l+1],o[l+2])&&(s=l,n>0));l=o[l+3]);return s}slice(e,t,n,i){let r=this.buffer,o=new Uint16Array(t-e);for(let s=e,l=0;s<t;)o[l++]=r[s++],o[l++]=r[s++]-n,o[l++]=r[s++]-n,o[l++]=r[s++]-e;return new x(o,i-n,this.set)}}function k(e,t,n,i){switch(e){case-2:return n<t;case-1:return i>=t&&n<t;case 0:return n<t&&i>t;case 1:return n<=t&&i>t;case 2:return i>t;case 4:return!0}}function S(e,t){let n=e.childBefore(t);for(;n;){let t=n.lastChild;if(!t||t.to!=n.to)break;t.type.isError&&t.from==t.to?(e=n,n=t.prevSibling):n=t}return e}function C(e,t,n,i){for(var r;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to<t);){let t=!i&&e instanceof A&&e.index<0?null:e.parent;if(!t)return e;e=t}let o=i?0:v.IgnoreOverlays;if(i)for(let s=e,l=s.parent;l;s=l,l=s.parent)s instanceof A&&s.index<0&&(null===(r=l.enter(t,n,o))||void 0===r?void 0:r.from)!=s.from&&(e=l);for(;;){let i=e.enter(t,n,o);if(!i)return e;e=i}}class A{constructor(e,t,n,i){this._tree=e,this.from=t,this.index=n,this._parent=i}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,n,i,r=0){for(let o=this;;){for(let{children:s,positions:l}=o._tree,a=t>0?s.length:-1;e!=a;e+=t){let a=s[e],c=l[e]+o.from;if(k(i,n,c,c+a.length))if(a instanceof x){if(r&v.ExcludeBuffers)continue;let s=a.findChild(0,a.buffer.length,t,n-c,i);if(s>-1)return new D(new O(o,a,e,c),null,s)}else if(r&v.IncludeAnonymous||!a.type.isAnonymous||I(a)){let s;if(!(r&v.IgnoreMounts)&&a.props&&(s=a.prop(d.mounted))&&!s.overlay)return new A(s.tree,c,e,o);let l=new A(a,c,e,o);return r&v.IncludeAnonymous||!l.type.isAnonymous?l:l.nextChild(t<0?a.children.length-1:0,t,n,i)}}if(r&v.IncludeAnonymous||!o.type.isAnonymous)return null;if(e=o.index>=0?o.index+t:t<0?-1:o._parent._tree.children.length,o=o._parent,!o)return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}enter(e,t,n=0){let i;if(!(n&v.IgnoreOverlays)&&(i=this._tree.prop(d.mounted))&&i.overlay){let n=e-this.from;for(let{from:e,to:r}of i.overlay)if((t>0?e<=n:e<n)&&(t<0?r>=n:r>n))return new A(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,n)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}cursor(e=0){return new P(this,e)}get tree(){return this._tree}toTree(){return this._tree}resolve(e,t=0){return C(this,e,t,!1)}resolveInner(e,t=0){return C(this,e,t,!0)}enterUnfinishedNodesBefore(e){return S(this,e)}getChild(e,t=null,n=null){let i=E(this,e,t,n);return i.length?i[0]:null}getChildren(e,t=null,n=null){return E(this,e,t,n)}toString(){return this._tree.toString()}get node(){return this}matchContext(e){return M(this,e)}}function E(e,t,n,i){let r=e.cursor(),o=[];if(!r.firstChild())return o;if(null!=n)for(;!r.type.is(n);)if(!r.nextSibling())return o;for(;;){if(null!=i&&r.type.is(i))return o;if(r.type.is(t)&&o.push(r.node),!r.nextSibling())return null==i?o:[]}}function M(e,t,n=t.length-1){for(let i=e.parent;n>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(t[n]&&t[n]!=i.name)return!1;n--}}return!0}class O{constructor(e,t,n,i){this.parent=e,this.buffer=t,this.index=n,this.start=i}}class D{constructor(e,t,n){this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}child(e,t,n){let{buffer:i}=this.context,r=i.findChild(this.index+4,i.buffer[this.index+3],e,t-this.context.start,n);return r<0?null:new D(this.context,this,r)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}enter(e,t,n=0){if(n&v.ExcludeBuffers)return null;let{buffer:i}=this.context,r=i.findChild(this.index+4,i.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return r<0?null:new D(this.context,this,r)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new D(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new D(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}cursor(e=0){return new P(this,e)}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,i=this.index+4,r=n.buffer[this.index+3];if(r>i){let o=n.buffer[this.index+1],s=n.buffer[this.index+2];e.push(n.slice(i,r,o,s)),t.push(0)}return new b(this.type,e,t,this.to-this.from)}resolve(e,t=0){return C(this,e,t,!1)}resolveInner(e,t=0){return C(this,e,t,!0)}enterUnfinishedNodesBefore(e){return S(this,e)}toString(){return this.context.buffer.childString(this.index)}getChild(e,t=null,n=null){let i=E(this,e,t,n);return i.length?i[0]:null}getChildren(e,t=null,n=null){return E(this,e,t,n)}get node(){return this}matchContext(e){return M(this,e)}}class P{constructor(e,t=0){if(this.mode=t,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof A)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.index);this.bufferNode=e,this.yieldBuf(e.index)}}get name(){return this.type.name}yieldNode(e){return!!e&&(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0)}yieldBuf(e,t){this.index=e;let{start:n,buffer:i}=this.buffer;return this.type=t||i.set.types[i.buffer[e]],this.from=n+i.buffer[e+1],this.to=n+i.buffer[e+2],!0}yield(e){return!!e&&(e instanceof A?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)))}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:i}=this.buffer,r=i.findChild(this.index+4,i.buffer[this.index+3],e,t-this.buffer.start,n);return!(r<0)&&(this.stack.push(this.index),this.yieldBuf(r))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,n=this.mode){return this.buffer?!(n&v.ExcludeBuffers)&&this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&v.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&v.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return!!this._tree._parent&&this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode));let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let e=n<0?0:this.stack[n]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(e)}return n<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:i}=this;if(i){if(e>0){if(this.index<i.buffer.buffer.length)return!1}else for(let e=0;e<this.index;e++)if(i.buffer.buffer[e+3]<this.index)return!1;({index:t,parent:n}=i)}else({index:t,_parent:n}=this._tree);for(;n;({index:t,_parent:n}=n))if(t>-1)for(let i=t+e,r=e<0?-1:n._tree.children.length;i!=r;i+=e){let e=n._tree.children[i];if(this.mode&v.IncludeAnonymous||e instanceof x||!e.type.isAnonymous||I(e))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,n=0;if(e&&e.context==this.buffer)e:for(let i=this.index,r=this.stack.length;r>=0;){for(let o=e;o;o=o._parent)if(o.index==i){if(i==this.index)return o;t=o,n=r+1;break e}i=this.stack[--r]}for(let i=n;i<this.stack.length;i++)t=new D(this.buffer,t,this.stack[i]);return this.bufferNode=new D(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let i=!1;if(this.type.isAnonymous||!1!==e(this)){if(this.firstChild()){n++;continue}this.type.isAnonymous||(i=!0)}for(;i&&t&&t(this),i=this.type.isAnonymous,!this.nextSibling();){if(!n)return;this.parent(),n--,i=!0}}}matchContext(e){if(!this.buffer)return M(this.node,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let i=e.length-1,r=this.stack.length-1;i>=0;r--){if(r<0)return M(this.node,e,i);let o=n[t.buffer[this.stack[r]]];if(!o.isAnonymous){if(e[i]&&e[i]!=o.name)return!1;i--}}return!0}}function I(e){return e.children.some((e=>e instanceof x||!e.type.isAnonymous||I(e)))}const B=new WeakMap;function T(e,t){if(!e.isAnonymous||t instanceof x||t.type!=e)return 1;let n=B.get(t);if(null==n){n=1;for(let i of t.children){if(i.type!=e||!(i instanceof b)){n=1;break}n+=T(e,i)}B.set(t,n)}return n}function N(e,t,n,i,r,o,s,l,a){let c=0;for(let d=i;d<r;d++)c+=T(e,t[d]);let h=Math.ceil(1.5*c/8),u=[],f=[];return function t(n,i,r,s,l){for(let c=r;c<s;){let r=c,d=i[c],p=T(e,n[c]);for(c++;c<s;c++){let t=T(e,n[c]);if(p+t>=h)break;p+=t}if(c==r+1){if(p>h){let e=n[r];t(e.children,e.positions,0,e.children.length,i[r]+l);continue}u.push(n[r])}else{let t=i[c-1]+n[c-1].length-d;u.push(N(e,n,i,r,c,d,t,null,a))}f.push(d+l-o)}}(t,n,i,r,0),(l||a)(u,f,s)}class R{constructor(e,t,n,i,r=!1,o=!1){this.from=e,this.to=t,this.tree=n,this.offset=i,this.open=(r?1:0)|(o?2:0)}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(e,t=[],n=!1){let i=[new R(0,e.length,e,0,!1,n)];for(let r of t)r.to>e.length&&i.push(r);return i}static applyChanges(e,t,n=128){if(!t.length)return e;let i=[],r=1,o=e.length?e[0]:null;for(let s=0,l=0,a=0;;s++){let c=s<t.length?t[s]:null,h=c?c.fromA:1e9;if(h-l>=n)for(;o&&o.from<h;){let t=o;if(l>=t.from||h<=t.to||a){let e=Math.max(t.from,l)-a,n=Math.min(t.to,h)-a;t=e>=n?null:new R(e,n,t.tree,t.offset+a,s>0,!!c)}if(t&&i.push(t),o.to>h)break;o=r<e.length?e[r++]:null}if(!c)break;l=c.toA,a=c.toA-c.toB}return i}}class L{startParse(e,t,n){return"string"==typeof e&&(e=new _(e)),n=n?n.length?n.map((e=>new f(e.from,e.to))):[new f(0,0)]:[new f(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let i=this.startParse(e,t,n);for(;;){let e=i.advance();if(e)return e}}}class _{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}new d({perNode:!0});let F=0;class W{constructor(e,t,n){this.set=e,this.base=t,this.modified=n,this.id=F++}static define(e){if(null===e||void 0===e?void 0:e.base)throw new Error("Can not derive from a modified tag");let t=new W([],null,[]);if(t.set.push(t),e)for(let n of e.set)t.set.push(n);return t}static defineModifier(){let e=new q;return t=>t.modified.indexOf(e)>-1?t:q.get(t.base||t,t.modified.concat(e).sort(((e,t)=>e.id-t.id)))}}let V=0;class q{constructor(){this.instances=[],this.id=V++}static get(e,t){if(!t.length)return e;let n=t[0].instances.find((n=>{return n.base==e&&(i=t,r=n.modified,i.length==r.length&&i.every(((e,t)=>e==r[t])));var i,r}));if(n)return n;let i=[],r=new W(i,e,t);for(let s of t)s.instances.push(r);let o=function(e){let t=[[]];for(let n=0;n<e.length;n++)for(let i=0,r=t.length;i<r;i++)t.push(t[i].concat(e[n]));return t.sort(((e,t)=>t.length-e.length))}(t);for(let s of e.set)if(!s.modified.length)for(let e of o)i.push(q.get(s,e));return r}}function j(e){let t=Object.create(null);for(let n in e){let i=e[n];Array.isArray(i)||(i=[i]);for(let e of n.split(" "))if(e){let n=[],r=2,o=e;for(let t=0;;){if("..."==o&&t>0&&t+3==e.length){r=1;break}let i=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(o);if(!i)throw new RangeError("Invalid path: "+e);if(n.push("*"==i[0]?"":'"'==i[0][0]?JSON.parse(i[0]):i[0]),t+=i[0].length,t==e.length)break;let s=e[t++];if(t==e.length&&"!"==s){r=0;break}if("/"!=s)throw new RangeError("Invalid path: "+e);o=e.slice(t)}let s=n.length-1,l=n[s];if(!l)throw new RangeError("Invalid path: "+e);let a=new U(i,r,s>0?n.slice(0,s):null);t[l]=a.sort(t[l])}}return z.add(t)}const z=new d;class U{constructor(e,t,n,i){this.tags=e,this.mode=t,this.context=n,this.next=i}get opaque(){return 0==this.mode}get inherit(){return 1==this.mode}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}function $(e,t){let n=Object.create(null);for(let o of e)if(Array.isArray(o.tag))for(let e of o.tag)n[e.id]=o.class;else n[o.tag.id]=o.class;let{scope:i,all:r=null}=t||{};return{style:e=>{let t=r;for(let i of e)for(let e of i.set){let i=n[e.id];if(i){t=t?t+" "+i:i;break}}return t},scope:i}}function H(e,t,n,i=0,r=e.length){let o=new J(i,Array.isArray(t)?t:[t],n);o.highlightRange(e.cursor(),i,r,"",o.highlighters),o.flush(r)}U.empty=new U([],2,null);class J{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,n,i,r){let{type:o,from:s,to:l}=e;if(s>=n||l<=t)return;o.isTop&&(r=this.highlighters.filter((e=>!e.scope||e.scope(o))));let a=i,c=function(e){let t=e.type.prop(z);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}(e)||U.empty,h=function(e,t){let n=null;for(let i of e){let e=i.style(t);e&&(n=n?n+" "+e:e)}return n}(r,c.tags);if(h&&(a&&(a+=" "),a+=h,1==c.mode&&(i+=(i?" ":"")+h)),this.startSpan(e.from,a),c.opaque)return;let u=e.tree&&e.tree.prop(d.mounted);if(u&&u.overlay){let o=e.node.enter(u.overlay[0].from+s,1),c=this.highlighters.filter((e=>!e.scope||e.scope(u.tree.type))),h=e.firstChild();for(let f=0,d=s;;f++){let p=f<u.overlay.length?u.overlay[f]:null,m=p?p.from+s:l,g=Math.max(t,d),y=Math.min(n,m);if(g<y&&h)for(;e.from<y&&(this.highlightRange(e,g,y,i,r),this.startSpan(Math.min(n,e.to),a),!(e.to>=m)&&e.nextSibling()););if(!p||m>n)break;d=p.to+s,d>t&&(this.highlightRange(o.cursor(),Math.max(t,p.from+s),Math.min(n,d),i,c),this.startSpan(d,a))}h&&e.parent()}else if(e.firstChild()){do{if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,i,r),this.startSpan(Math.min(n,e.to),a)}}while(e.nextSibling());e.parent()}}}const G=W.define,K=G(),Q=G(),Y=G(Q),X=G(Q),Z=G(),ee=G(Z),te=G(Z),ne=G(),ie=G(ne),re=G(),oe=G(),se=G(),le=G(se),ae=G(),ce={comment:K,lineComment:G(K),blockComment:G(K),docComment:G(K),name:Q,variableName:G(Q),typeName:Y,tagName:G(Y),propertyName:X,attributeName:G(X),className:G(Q),labelName:G(Q),namespace:G(Q),macroName:G(Q),literal:Z,string:ee,docString:G(ee),character:G(ee),attributeValue:G(ee),number:te,integer:G(te),float:G(te),bool:G(Z),regexp:G(Z),escape:G(Z),color:G(Z),url:G(Z),keyword:re,self:G(re),null:G(re),atom:G(re),unit:G(re),modifier:G(re),operatorKeyword:G(re),controlKeyword:G(re),definitionKeyword:G(re),moduleKeyword:G(re),operator:oe,derefOperator:G(oe),arithmeticOperator:G(oe),logicOperator:G(oe),bitwiseOperator:G(oe),compareOperator:G(oe),updateOperator:G(oe),definitionOperator:G(oe),typeOperator:G(oe),controlOperator:G(oe),punctuation:se,separator:G(se),bracket:le,angleBracket:G(le),squareBracket:G(le),paren:G(le),brace:G(le),content:ne,heading:ie,heading1:G(ie),heading2:G(ie),heading3:G(ie),heading4:G(ie),heading5:G(ie),heading6:G(ie),contentSeparator:G(ne),list:G(ne),quote:G(ne),emphasis:G(ne),strong:G(ne),link:G(ne),monospace:G(ne),strikethrough:G(ne),inserted:G(),deleted:G(),changed:G(),invalid:G(),meta:ae,documentMeta:G(ae),annotation:G(ae),processingInstruction:G(ae),definition:W.defineModifier(),constant:W.defineModifier(),function:W.defineModifier(),standard:W.defineModifier(),local:W.defineModifier(),special:W.defineModifier()},he=($([{tag:ce.link,class:"tok-link"},{tag:ce.heading,class:"tok-heading"},{tag:ce.emphasis,class:"tok-emphasis"},{tag:ce.strong,class:"tok-strong"},{tag:ce.keyword,class:"tok-keyword"},{tag:ce.atom,class:"tok-atom"},{tag:ce.bool,class:"tok-bool"},{tag:ce.url,class:"tok-url"},{tag:ce.labelName,class:"tok-labelName"},{tag:ce.inserted,class:"tok-inserted"},{tag:ce.deleted,class:"tok-deleted"},{tag:ce.literal,class:"tok-literal"},{tag:ce.string,class:"tok-string"},{tag:ce.number,class:"tok-number"},{tag:[ce.regexp,ce.escape,ce.special(ce.string)],class:"tok-string2"},{tag:ce.variableName,class:"tok-variableName"},{tag:ce.local(ce.variableName),class:"tok-variableName tok-local"},{tag:ce.definition(ce.variableName),class:"tok-variableName tok-definition"},{tag:ce.special(ce.variableName),class:"tok-variableName2"},{tag:ce.definition(ce.propertyName),class:"tok-propertyName tok-definition"},{tag:ce.typeName,class:"tok-typeName"},{tag:ce.namespace,class:"tok-namespace"},{tag:ce.className,class:"tok-className"},{tag:ce.macroName,class:"tok-macroName"},{tag:ce.propertyName,class:"tok-propertyName"},{tag:ce.operator,class:"tok-operator"},{tag:ce.comment,class:"tok-comment"},{tag:ce.meta,class:"tok-meta"},{tag:ce.invalid,class:"tok-invalid"},{tag:ce.punctuation,class:"tok-punctuation"}]),"undefined"==typeof Symbol?"__\u037c":Symbol.for("\u037c")),ue="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),fe="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class de{constructor(e,t){this.rules=[];let{finish:n}=t||{};function i(e){return/^@/.test(e)?[e]:e.split(/,\s*/)}function r(e,t,o,s){let l=[],a=/^@(\w+)\b/.exec(e[0]),c=a&&"keyframes"==a[1];if(a&&null==t)return o.push(e[0]+";");for(let n in t){let s=t[n];if(/&/.test(n))r(n.split(/,\s*/).map((t=>e.map((e=>t.replace(/&/,e))))).reduce(((e,t)=>e.concat(t))),s,o);else if(s&&"object"==typeof s){if(!a)throw new RangeError("The value of a property ("+n+") should be a primitive value.");r(i(n),s,l,c)}else null!=s&&l.push(n.replace(/_.*/,"").replace(/[A-Z]/g,(e=>"-"+e.toLowerCase()))+": "+s+";")}(l.length||c)&&o.push((!n||a||s?e:e.map(n)).join(", ")+" {"+l.join(" ")+"}")}for(let o in e)r(i(o),e[o],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let e=fe[he]||1;return fe[he]=e+1,"\u037c"+e.toString(36)}static mount(e,t){(e[ue]||new me(e)).mount(Array.isArray(t)?t:[t])}}let pe=null;class me{constructor(e){if(!e.head&&e.adoptedStyleSheets&&"undefined"!=typeof CSSStyleSheet){if(pe)return e.adoptedStyleSheets=[pe.sheet].concat(e.adoptedStyleSheets),e[ue]=pe;this.sheet=new CSSStyleSheet,e.adoptedStyleSheets=[this.sheet].concat(e.adoptedStyleSheets),pe=this}else{this.styleTag=(e.ownerDocument||e).createElement("style");let t=e.head||e;t.insertBefore(this.styleTag,t.firstChild)}this.modules=[],e[ue]=this}mount(e){let t=this.sheet,n=0,i=0;for(let r=0;r<e.length;r++){let o=e[r],s=this.modules.indexOf(o);if(s<i&&s>-1&&(this.modules.splice(s,1),i--,s=-1),-1==s){if(this.modules.splice(i++,0,o),t)for(let e=0;e<o.rules.length;e++)t.insertRule(o.rules[e],n++)}else{for(;i<s;)n+=this.modules[i++].rules.length;n+=o.rules.length,i++}}if(!t){let e="";for(let t=0;t<this.modules.length;t++)e+=this.modules[t].getRules()+"\n";this.styleTag.textContent=e}}}var ge;const ye=new d;class ve{constructor(e,t,n=[],i=""){this.data=e,this.name=i,a.EditorState.prototype.hasOwnProperty("tree")||Object.defineProperty(a.EditorState.prototype,"tree",{get(){return we(this)}}),this.parser=t,this.extension=[De.of(this),a.EditorState.languageData.of(((e,t,n)=>e.facet(be(e,t,n))))].concat(n)}isActiveAt(e,t,n=-1){return be(e,t,n)==this.data}findRegions(e){let t=e.facet(De);if((null===t||void 0===t?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],i=(e,t)=>{if(e.prop(ye)==this.data)return void n.push({from:t,to:t+e.length});let r=e.prop(d.mounted);if(r){if(r.tree.prop(ye)==this.data){if(r.overlay)for(let e of r.overlay)n.push({from:e.from+t,to:e.to+t});else n.push({from:t,to:t+e.length});return}if(r.overlay){let e=n.length;if(i(r.tree,r.overlay[0].from+t),n.length>e)return}}for(let n=0;n<e.children.length;n++){let r=e.children[n];r instanceof b&&i(r,e.positions[n]+t)}};return i(we(e),0),n}get allowsNesting(){return!0}}function be(e,t,n){let i=e.facet(De);if(!i)return null;let r=i.data;if(i.allowsNesting)for(let o=we(e).topNode;o;o=o.enter(t,n,v.ExcludeBuffers))r=o.type.prop(ye)||r;return r}ve.setState=a.StateEffect.define();function we(e){let t=e.field(ve.state,!1);return t?t.tree:b.empty}class xe{constructor(e,t=e.length){this.doc=e,this.length=t,this.cursorPos=0,this.string="",this.cursor=e.iter()}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let n=this.cursorPos-this.string.length;return e<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}}let ke=null;class Se{constructor(e,t,n=[],i,r,o,s,l){this.parser=e,this.state=t,this.fragments=n,this.tree=i,this.treeLen=r,this.viewport=o,this.skipped=s,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(e,t,n){return new Se(e,t,[],b.empty,0,n,[],null)}startParse(){return this.parser.startParse(new xe(this.state.doc),this.fragments)}work(e,t){return null!=t&&t>=this.state.doc.length&&(t=void 0),this.tree!=b.empty&&this.isDone(null!==t&&void 0!==t?t:this.state.doc.length)?(this.takeTree(),!0):this.withContext((()=>{var n;if("number"==typeof e){let t=Date.now()+e;e=()=>Date.now()>t}for(this.parse||(this.parse=this.startParse()),null!=t&&(null==this.parse.stoppedAt||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let i=this.parse.advance();if(i){if(this.fragments=this.withoutTempSkipped(R.addTree(i,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!==(n=this.parse.stoppedAt)&&void 0!==n?n:this.state.doc.length,this.tree=i,this.parse=null,!(this.treeLen<(null!==t&&void 0!==t?t:this.state.doc.length)))return!0;this.parse=this.startParse()}if(e())return!1}}))}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((null==this.parse.stoppedAt||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext((()=>{for(;!(t=this.parse.advance()););})),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(R.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=ke;ke=this;try{return e()}finally{ke=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=Ce(e,t.from,t.to);return e}changes(e,t){let{fragments:n,tree:i,treeLen:r,viewport:o,skipped:s}=this;if(this.takeTree(),!e.empty){let t=[];if(e.iterChangedRanges(((e,n,i,r)=>t.push({fromA:e,toA:n,fromB:i,toB:r}))),n=R.applyChanges(n,t),i=b.empty,r=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){s=[];for(let t of this.skipped){let n=e.mapPos(t.from,1),i=e.mapPos(t.to,-1);n<i&&s.push({from:n,to:i})}}}return new Se(this.parser,t,n,i,r,o,s,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let n=0;n<this.skipped.length;n++){let{from:t,to:i}=this.skipped[n];t<e.to&&i>e.from&&(this.fragments=Ce(this.fragments,t,i),this.skipped.splice(n--,1))}return!(this.skipped.length>=t)&&(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends L{createParse(t,n,i){let r=i[0].from,o=i[i.length-1].to;return{parsedPos:r,advance(){let t=ke;if(t){for(let e of i)t.tempSkipped.push(e);e&&(t.scheduleOn=t.scheduleOn?Promise.all([t.scheduleOn,e]):e)}return this.parsedPos=o,new b(m.none,[],[],o-r)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&0==t[0].from&&t[0].to>=e}static get(){return ke}}function Ce(e,t,n){return R.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}class Ae{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),n=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,n)||t.takeTree(),new Ae(t)}static init(e){let t=Math.min(3e3,e.doc.length),n=Se.create(e.facet(De).parser,e,{from:0,to:t});return n.work(20,t)||n.takeTree(),new Ae(n)}}ve.state=a.StateField.define({create:Ae.init,update(e,t){for(let n of t.effects)if(n.is(ve.setState))return n.value;return t.startState.facet(De)!=t.state.facet(De)?Ae.init(t.state):e.apply(t)}});let Ee=e=>{let t=setTimeout((()=>e()),500);return()=>clearTimeout(t)};"undefined"!=typeof requestIdleCallback&&(Ee=e=>{let t=-1,n=setTimeout((()=>{t=requestIdleCallback(e,{timeout:400})}),100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});const Me="undefined"!=typeof navigator&&(null===(ge=navigator.scheduling)||void 0===ge?void 0:ge.isInputPending)?()=>navigator.scheduling.isInputPending():null,Oe=c.ViewPlugin.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(ve.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),e.docChanged&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(ve.state);t.tree==t.context.tree&&t.context.isDone(e.doc.length)||(this.working=Ee(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:i}}=this.view,r=n.field(ve.state);if(r.tree==r.context.tree&&r.context.isDone(i+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!Me?Math.max(25,e.timeRemaining()-5):1e9),s=r.context.treeLen<i&&n.doc.length>i+1e3,l=r.context.work((()=>Me&&Me()||Date.now()>o),i+(s?0:1e5));this.chunkBudget-=Date.now()-t,(l||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:ve.setState.of(new Ae(r.context))})),this.chunkBudget>0&&(!l||s)&&this.scheduleWork(),this.checkAsyncSchedule(r.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then((()=>this.scheduleWork())).catch((e=>(0,c.logException)(this.view.state,e))).then((()=>this.workScheduled--)),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),De=a.Facet.define({combine:e=>e.length?e[0]:null,enables:e=>[ve.state,Oe,c.EditorView.contentAttributes.compute([e],(t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}}))]});const Pe=a.Facet.define(),Ie=a.Facet.define({combine:e=>{if(!e.length)return" ";if(!/^(?: +|\t+)$/.test(e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(e[0]));return e[0]}});function Be(e){let t=e.facet(Ie);return 9==t.charCodeAt(0)?e.tabSize*t.length:t.length}function Te(e,t){let n="",i=e.tabSize;if(9==e.facet(Ie).charCodeAt(0))for(;t>=i;)n+="\t",t-=i;for(let r=0;r<t;r++)n+=" ";return n}function Ne(e,t){e instanceof a.EditorState&&(e=new Re(e));for(let i of e.state.facet(Pe)){let n=i(e,t);if(null!=n)return n}let n=we(e.state);return n?function(e,t,n){return Fe(t.resolveInner(n).enterUnfinishedNodesBefore(n),n,e)}(e,n,t):null}class Re{constructor(e,t={}){this.state=e,this.options=t,this.unit=Be(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:i,simulateDoubleBreak:r}=this.options;return null!=i&&i>=n.from&&i<=n.to?r&&i==e?{text:"",from:e}:(t<0?i<e:i<=e)?{text:n.text.slice(i-n.from),from:i}:{text:n.text.slice(0,i-n.from),from:n.from}:n}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:n,from:i}=this.lineAt(e,t);return n.slice(e-i,Math.min(n.length,e+100-i))}column(e,t=1){let{text:n,from:i}=this.lineAt(e,t),r=this.countColumn(n,e-i),o=this.options.overrideIndentation?this.options.overrideIndentation(i):-1;return o>-1&&(r+=o-this.countColumn(n,n.search(/\S|$/))),r}countColumn(e,t=e.length){return(0,a.countColumn)(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:i}=this.lineAt(e,t),r=this.options.overrideIndentation;if(r){let e=r(i);if(e>-1)return e}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const Le=new d;function _e(e){let t=e.type.prop(Le);if(t)return t;let n,i=e.firstChild;if(i&&(n=i.type.prop(d.closedBy))){let t=e.lastChild,i=t&&n.indexOf(t.name)>-1;return e=>je(e,!0,1,void 0,i&&!function(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}(e)?t.from:void 0)}return null==e.parent?We:null}function Fe(e,t,n){for(;e;e=e.parent){let i=_e(e);if(i)return i(Ve.create(n,t,e))}return null}function We(){return 0}class Ve extends Re{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.node=n}static create(e,t,n){return new Ve(e,t,n)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){let e=this.state.doc.lineAt(this.node.from);for(;;){let t=this.node.resolve(e.from);for(;t.parent&&t.parent.from==t.from;)t=t.parent;if(qe(t,this.node))break;e=this.state.doc.lineAt(t.from)}return this.lineIndent(e.from)}continue(){let e=this.node.parent;return e?Fe(e,this.pos,this.base):0}}function qe(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function je(e,t,n,i,r){let o=e.textAfter,s=o.match(/^\s*/)[0].length,l=i&&o.slice(s,s+i.length)==i||r==e.pos+s,a=t?function(e){let t=e.node,n=t.childAfter(t.from),i=t.lastChild;if(!n)return null;let r=e.options.simulateBreak,o=e.state.doc.lineAt(n.from),s=null==r||r<=o.from?o.to:Math.min(o.to,r);for(let l=n.to;;){let e=t.childAfter(l);if(!e||e==i)return null;if(!e.type.isSkipped)return e.from<s?n:null;l=e.to}}(e):null;return a?l?e.column(a.from):e.column(a.to):e.baseIndent+(l?0:e.unit*n)}const ze=a.Facet.define(),Ue=new d;function $e(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function He(e,t,n){for(let i of e.facet(ze)){let r=i(e,t,n);if(r)return r}return function(e,t,n){let i=we(e);if(i.length<n)return null;let r=null;for(let o=i.resolveInner(n);o;o=o.parent){if(o.to<=n||o.from>n)continue;if(r&&o.from<t)break;let s=o.type.prop(Ue);if(s&&(o.to<i.length-50||i.length==e.doc.length||!$e(o))){let i=s(o,e);i&&i.from<=n&&i.from>=t&&i.to>n&&(r=i)}}return r}(e,t,n)}function Je(e,t){let n=t.mapPos(e.from,1),i=t.mapPos(e.to,-1);return n>=i?void 0:{from:n,to:i}}const Ge=a.StateEffect.define({map:Je}),Ke=a.StateEffect.define({map:Je});function Qe(e){let t=[];for(let{head:n}of e.state.selection.ranges)t.some((e=>e.from<=n&&e.to>=n))||t.push(e.lineBlockAt(n));return t}const Ye=a.StateField.define({create:()=>c.Decoration.none,update(e,t){e=e.map(t.changes);for(let n of t.effects)n.is(Ge)&&!Ze(e,n.value.from,n.value.to)?e=e.update({add:[st.range(n.value.from,n.value.to)]}):n.is(Ke)&&(e=e.update({filter:(e,t)=>n.value.from!=e||n.value.to!=t,filterFrom:n.value.from,filterTo:n.value.to}));if(t.selection){let n=!1,{head:i}=t.selection.main;e.between(i,i,((e,t)=>{e<i&&t>i&&(n=!0)})),n&&(e=e.update({filterFrom:i,filterTo:i,filter:(e,t)=>t<=i||e>=i}))}return e},provide:e=>c.EditorView.decorations.from(e),toJSON(e,t){let n=[];return e.between(0,t.doc.length,((e,t)=>{n.push(e,t)})),n},fromJSON(e){if(!Array.isArray(e)||e.length%2)throw new RangeError("Invalid JSON for fold state");let t=[];for(let n=0;n<e.length;){let i=e[n++],r=e[n++];if("number"!=typeof i||"number"!=typeof r)throw new RangeError("Invalid JSON for fold state");t.push(st.range(i,r))}return c.Decoration.set(t,!0)}});function Xe(e,t,n){var i;let r=null;return null===(i=e.field(Ye,!1))||void 0===i||i.between(t,n,((e,t)=>{(!r||r.from>e)&&(r={from:e,to:t})})),r}function Ze(e,t,n){let i=!1;return e.between(t,t,((e,r)=>{e==t&&r==n&&(i=!0)})),i}function et(e,t){return e.field(Ye,!1)?t:t.concat(a.StateEffect.appendConfig.of(ot()))}function tt(e,t,n=!0){let i=e.state.doc.lineAt(t.from).number,r=e.state.doc.lineAt(t.to).number;return c.EditorView.announce.of(`${e.state.phrase(n?"Folded lines":"Unfolded lines")} ${i} ${e.state.phrase("to")} ${r}.`)}const nt=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:e=>{for(let t of Qe(e)){let n=He(e.state,t.from,t.to);if(n)return e.dispatch({effects:et(e.state,[Ge.of(n),tt(e,n)])}),!0}return!1}},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:e=>{if(!e.state.field(Ye,!1))return!1;let t=[];for(let n of Qe(e)){let i=Xe(e.state,n.from,n.to);i&&t.push(Ke.of(i),tt(e,i,!1))}return t.length&&e.dispatch({effects:t}),t.length>0}},{key:"Ctrl-Alt-[",run:e=>{let{state:t}=e,n=[];for(let i=0;i<t.doc.length;){let r=e.lineBlockAt(i),o=He(t,r.from,r.to);o&&n.push(Ge.of(o)),i=(o?e.lineBlockAt(o.to):r).to+1}return n.length&&e.dispatch({effects:et(e.state,n)}),!!n.length}},{key:"Ctrl-Alt-]",run:e=>{let t=e.state.field(Ye,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,((e,t)=>{n.push(Ke.of({from:e,to:t}))})),e.dispatch({effects:n}),!0}}],it={placeholderDOM:null,placeholderText:"\u2026"},rt=a.Facet.define({combine:e=>(0,a.combineConfig)(e,it)});function ot(e){let t=[Ye,ct];return e&&t.push(rt.of(e)),t}const st=c.Decoration.replace({widget:new class extends c.WidgetType{toDOM(e){let{state:t}=e,n=t.facet(rt),i=t=>{let n=e.lineBlockAt(e.posAtDOM(t.target)),i=Xe(e.state,n.from,n.to);i&&e.dispatch({effects:Ke.of(i)}),t.preventDefault()};if(n.placeholderDOM)return n.placeholderDOM(e,i);let r=document.createElement("span");return r.textContent=n.placeholderText,r.setAttribute("aria-label",t.phrase("folded code")),r.title=t.phrase("unfold"),r.className="cm-foldPlaceholder",r.onclick=i,r}}}),lt={openText:"\u2304",closedText:"\u203a",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class at extends c.GutterMarker{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}}const ct=c.EditorView.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class ht{constructor(e,t){let n;function i(e){let t=de.newName();return(n||(n=Object.create(null)))["."+t]=e,t}this.specs=e;const r="string"==typeof t.all?t.all:t.all?i(t.all):void 0,o=t.scope;this.scope=o instanceof ve?e=>e.prop(ye)==o.data:o?e=>e==o:void 0,this.style=$(e.map((e=>({tag:e.tag,class:e.class||i(Object.assign({},e,{tag:null}))}))),{all:r}).style,this.module=n?new de(n):null,this.themeType=t.themeType}static define(e,t){return new ht(e,t||{})}}const ut=a.Facet.define(),ft=a.Facet.define({combine:e=>e.length?[e[0]]:null});function dt(e){let t=e.facet(ut);return t.length?t:e.facet(ft)}function pt(e,t){let n,i=[gt];return e instanceof ht&&(e.module&&i.push(c.EditorView.styleModule.of(e.module)),n=e.themeType),(null===t||void 0===t?void 0:t.fallback)?i.push(ft.of(e)):n?i.push(ut.computeN([c.EditorView.darkTheme],(t=>t.facet(c.EditorView.darkTheme)==("dark"==n)?[e]:[]))):i.push(ut.of(e)),i}class mt{constructor(e){this.markCache=Object.create(null),this.tree=we(e.state),this.decorations=this.buildDeco(e,dt(e.state))}update(e){let t=we(e.state),n=dt(e.state),i=n!=dt(e.startState);t.length<e.view.viewport.to&&!i&&t.type==this.tree.type?this.decorations=this.decorations.map(e.changes):(t!=this.tree||e.viewportChanged||i)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n))}buildDeco(e,t){if(!t||!this.tree.length)return c.Decoration.none;let n=new a.RangeSetBuilder;for(let{from:i,to:r}of e.visibleRanges)H(this.tree,t,((e,t,i)=>{n.add(e,t,this.markCache[i]||(this.markCache[i]=c.Decoration.mark({class:i})))}),i,r);return n.finish()}}const gt=a.Prec.high(c.ViewPlugin.fromClass(mt,{decorations:e=>e.decorations})),yt=ht.define([{tag:ce.meta,color:"#7a757a"},{tag:ce.link,textDecoration:"underline"},{tag:ce.heading,textDecoration:"underline",fontWeight:"bold"},{tag:ce.emphasis,fontStyle:"italic"},{tag:ce.strong,fontWeight:"bold"},{tag:ce.strikethrough,textDecoration:"line-through"},{tag:ce.keyword,color:"#708"},{tag:[ce.atom,ce.bool,ce.url,ce.contentSeparator,ce.labelName],color:"#219"},{tag:[ce.literal,ce.inserted],color:"#164"},{tag:[ce.string,ce.deleted],color:"#a11"},{tag:[ce.regexp,ce.escape,ce.special(ce.string)],color:"#e40"},{tag:ce.definition(ce.variableName),color:"#00f"},{tag:ce.local(ce.variableName),color:"#30a"},{tag:[ce.typeName,ce.namespace],color:"#085"},{tag:ce.className,color:"#167"},{tag:[ce.special(ce.variableName),ce.macroName],color:"#256"},{tag:ce.definition(ce.propertyName),color:"#00c"},{tag:ce.comment,color:"#940"},{tag:ce.invalid,color:"#f00"}]),vt=c.EditorView.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),bt="()[]{}",wt=a.Facet.define({combine:e=>(0,a.combineConfig)(e,{afterCursor:!0,brackets:bt,maxScanDistance:1e4,renderMatch:St})}),xt=c.Decoration.mark({class:"cm-matchingBracket"}),kt=c.Decoration.mark({class:"cm-nonmatchingBracket"});function St(e){let t=[],n=e.matched?xt:kt;return t.push(n.range(e.start.from,e.start.to)),e.end&&t.push(n.range(e.end.from,e.end.to)),t}const Ct=a.StateField.define({create:()=>c.Decoration.none,update(e,t){if(!t.docChanged&&!t.selection)return e;let n=[],i=t.state.facet(wt);for(let r of t.state.selection.ranges){if(!r.empty)continue;let e=Mt(t.state,r.head,-1,i)||r.head>0&&Mt(t.state,r.head-1,1,i)||i.afterCursor&&(Mt(t.state,r.head,1,i)||r.head<t.state.doc.length&&Mt(t.state,r.head+1,-1,i));e&&(n=n.concat(i.renderMatch(e,t.state)))}return c.Decoration.set(n,!0)},provide:e=>c.EditorView.decorations.from(e)}),At=[Ct,vt];function Et(e,t,n){let i=e.prop(t<0?d.openedBy:d.closedBy);if(i)return i;if(1==e.name.length){let i=n.indexOf(e.name);if(i>-1&&i%2==(t<0?1:0))return[n[i+t]]}return null}function Mt(e,t,n,i={}){let r=i.maxScanDistance||1e4,o=i.brackets||bt,s=we(e),l=s.resolveInner(t,n);for(let a=l;a;a=a.parent){let i=Et(a.type,n,o);if(i&&a.from<a.to)return Ot(e,t,n,a,i,o)}return function(e,t,n,i,r,o,s){let l=n<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),a=s.indexOf(l);if(a<0||a%2==0!=n>0)return null;let c={from:n<0?t-1:t,to:n>0?t+1:t},h=e.doc.iterRange(t,n>0?e.doc.length:0),u=0;for(let f=0;!h.next().done&&f<=o;){let e=h.value;n<0&&(f+=e.length);let o=t+f*n;for(let t=n>0?0:e.length-1,l=n>0?e.length:-1;t!=l;t+=n){let l=s.indexOf(e[t]);if(!(l<0||i.resolveInner(o+t,1).type!=r))if(l%2==0==n>0)u++;else{if(1==u)return{start:c,end:{from:o+t,to:o+t+1},matched:l>>1==a>>1};u--}}n>0&&(f+=e.length)}return h.done?{start:c,matched:!1}:null}(e,t,n,s,l.type,r,o)}function Ot(e,t,n,i,r,o){let s=i.parent,l={from:i.from,to:i.to},a=0,c=null===s||void 0===s?void 0:s.cursor();if(c&&(n<0?c.childBefore(i.from):c.childAfter(i.to)))do{if(n<0?c.to<=i.from:c.from>=i.to){if(0==a&&r.indexOf(c.type.name)>-1&&c.from<c.to)return{start:l,end:{from:c.from,to:c.to},matched:!0};if(Et(c.type,n,o))a++;else if(Et(c.type,-n,o)){if(0==a)return{start:l,end:c.from==c.to?void 0:{from:c.from,to:c.to},matched:!1};a--}}}while(n<0?c.prevSibling():c.nextSibling());return{start:l,matched:!1}}const Dt=Object.create(null),Pt=[m.none],It=[],Bt=Object.create(null);for(let[s,l]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])Bt[s]=Nt(Dt,l);function Tt(e,t){It.indexOf(e)>-1||(It.push(e),console.warn(t))}function Nt(e,t){let n=null;for(let o of t.split(".")){let t=e[o]||ce[o];t?"function"==typeof t?n?n=t(n):Tt(o,`Modifier ${o} used at start of tag`):n?Tt(o,`Tag ${o} used as modifier`):n=t:Tt(o,`Unknown highlighting tag ${o}`)}if(!n)return 0;let i=t.replace(/ /g,"_"),r=m.define({id:Pt.length,name:i,props:[j({[i]:n})]});return Pt.push(r),r.id}function Rt(e,t){return({state:n,dispatch:i})=>{if(n.readOnly)return!1;let r=e(t,n);return!!r&&(i(n.update(r)),!0)}}const Lt=Rt(qt,0),_t=Rt(Vt,0),Ft=Rt(((e,t)=>Vt(e,t,function(e){let t=[];for(let n of e.selection.ranges){let i=e.doc.lineAt(n.from),r=n.to<=i.to?i:e.doc.lineAt(n.to),o=t.length-1;o>=0&&t[o].to>i.from?t[o].to=r.to:t.push({from:i.from,to:r.to})}return t}(t))),0);function Wt(e,t=e.selection.main.head){let n=e.languageDataAt("commentTokens",t);return n.length?n[0]:{}}function Vt(e,t,n=t.selection.ranges){let i=n.map((e=>Wt(t,e.from).block));if(!i.every((e=>e)))return null;let r=n.map(((e,n)=>function(e,{open:t,close:n},i,r){let o,s,l=e.sliceDoc(i-50,i),a=e.sliceDoc(r,r+50),c=/\s*$/.exec(l)[0].length,h=/^\s*/.exec(a)[0].length,u=l.length-c;if(l.slice(u-t.length,u)==t&&a.slice(h,h+n.length)==n)return{open:{pos:i-c,margin:c&&1},close:{pos:r+h,margin:h&&1}};r-i<=100?o=s=e.sliceDoc(i,r):(o=e.sliceDoc(i,i+50),s=e.sliceDoc(r-50,r));let f=/^\s*/.exec(o)[0].length,d=/\s*$/.exec(s)[0].length,p=s.length-d-n.length;return o.slice(f,f+t.length)==t&&s.slice(p,p+n.length)==n?{open:{pos:i+f+t.length,margin:/\s/.test(o.charAt(f+t.length))?1:0},close:{pos:r-d-n.length,margin:/\s/.test(s.charAt(p-1))?1:0}}:null}(t,i[n],e.from,e.to)));if(2!=e&&!r.every((e=>e)))return{changes:t.changes(n.map(((e,t)=>r[t]?[]:[{from:e.from,insert:i[t].open+" "},{from:e.to,insert:" "+i[t].close}])))};if(1!=e&&r.some((e=>e))){let e=[];for(let t,n=0;n<r.length;n++)if(t=r[n]){let r=i[n],{open:o,close:s}=t;e.push({from:o.pos-r.open.length,to:o.pos+o.margin},{from:s.pos-s.margin,to:s.pos+r.close.length})}return{changes:e}}return null}function qt(e,t,n=t.selection.ranges){let i=[],r=-1;for(let{from:o,to:s}of n){let e=i.length,n=1e9;for(let l=o;l<=s;){let e=t.doc.lineAt(l);if(e.from>r&&(o==s||s>e.from)){r=e.from;let o=Wt(t,l).line;if(!o)continue;let s=/^\s*/.exec(e.text)[0].length,a=s==e.length,c=e.text.slice(s,s+o.length)==o?s:-1;s<e.text.length&&s<n&&(n=s),i.push({line:e,comment:c,token:o,indent:s,empty:a,single:!1})}l=e.to+1}if(n<1e9)for(let t=e;t<i.length;t++)i[t].indent<i[t].line.text.length&&(i[t].indent=n);i.length==e+1&&(i[e].single=!0)}if(2!=e&&i.some((e=>e.comment<0&&(!e.empty||e.single)))){let e=[];for(let{line:t,token:r,indent:o,empty:s,single:l}of i)!l&&s||e.push({from:t.from+o,insert:r+" "});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}if(1!=e&&i.some((e=>e.comment>=0))){let e=[];for(let{line:t,comment:n,token:r}of i)if(n>=0){let i=t.from+n,o=i+r.length;" "==t.text[o-t.from]&&o++,e.push({from:i,to:o})}return{changes:e}}return null}const jt=a.Annotation.define(),zt=a.Annotation.define(),Ut=a.Facet.define(),$t=a.Facet.define({combine:e=>(0,a.combineConfig)(e,{minDepth:100,newGroupDelay:500},{minDepth:Math.max,newGroupDelay:Math.min})});const Ht=a.StateField.define({create:()=>cn.empty,update(e,t){let n=t.state.facet($t),i=t.annotation(jt);if(i){let r=t.docChanged?a.EditorSelection.single(function(e){let t=0;return e.iterChangedRanges(((e,n)=>t=n)),t}(t.changes)):void 0,o=Zt.fromTransaction(t,r),s=i.side,l=0==s?e.undone:e.done;return l=o?en(l,l.length,n.minDepth,o):rn(l,t.startState.selection),new cn(0==s?i.rest:l,0==s?l:i.rest)}let r=t.annotation(zt);if("full"!=r&&"before"!=r||(e=e.isolate()),!1===t.annotation(a.Transaction.addToHistory))return t.changes.empty?e:e.addMapping(t.changes.desc);let o=Zt.fromTransaction(t),s=t.annotation(a.Transaction.time),l=t.annotation(a.Transaction.userEvent);return o?e=e.addChanges(o,s,l,n.newGroupDelay,n.minDepth):t.selection&&(e=e.addSelection(t.startState.selection,s,l,n.newGroupDelay)),"full"!=r&&"after"!=r||(e=e.isolate()),e},toJSON:e=>({done:e.done.map((e=>e.toJSON())),undone:e.undone.map((e=>e.toJSON()))}),fromJSON:e=>new cn(e.done.map(Zt.fromJSON),e.undone.map(Zt.fromJSON))});function Jt(e={}){return[Ht,$t.of(e),c.EditorView.domEventHandlers({beforeinput(e,t){let n="historyUndo"==e.inputType?Kt:"historyRedo"==e.inputType?Qt:null;return!!n&&(e.preventDefault(),n(t))}})]}function Gt(e,t){return function({state:n,dispatch:i}){if(!t&&n.readOnly)return!1;let r=n.field(Ht,!1);if(!r)return!1;let o=r.pop(e,n,t);return!!o&&(i(o),!0)}}const Kt=Gt(0,!1),Qt=Gt(1,!1),Yt=Gt(0,!0),Xt=Gt(1,!0);class Zt{constructor(e,t,n,i,r){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=i,this.selectionsAfter=r}setSelAfter(e){return new Zt(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,n;return{changes:null===(e=this.changes)||void 0===e?void 0:e.toJSON(),mapped:null===(t=this.mapped)||void 0===t?void 0:t.toJSON(),startSelection:null===(n=this.startSelection)||void 0===n?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map((e=>e.toJSON()))}}static fromJSON(e){return new Zt(e.changes&&a.ChangeSet.fromJSON(e.changes),[],e.mapped&&a.ChangeDesc.fromJSON(e.mapped),e.startSelection&&a.EditorSelection.fromJSON(e.startSelection),e.selectionsAfter.map(a.EditorSelection.fromJSON))}static fromTransaction(e,t){let n=nn;for(let i of e.startState.facet(Ut)){let t=i(e);t.length&&(n=n.concat(t))}return!n.length&&e.changes.empty?null:new Zt(e.changes.invert(e.startState.doc),n,void 0,t||e.startState.selection,nn)}static selection(e){return new Zt(void 0,nn,void 0,void 0,e)}}function en(e,t,n,i){let r=t+1>n+20?t-n-1:0,o=e.slice(r,t);return o.push(i),o}function tn(e,t){return e.length?t.length?e.concat(t):e:t}const nn=[];function rn(e,t){if(e.length){let n=e[e.length-1],i=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-200));return i.length&&i[i.length-1].eq(t)?e:(i.push(t),en(e,e.length-1,1e9,n.setSelAfter(i)))}return[Zt.selection([t])]}function on(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function sn(e,t){if(!e.length)return e;let n=e.length,i=nn;for(;n;){let r=ln(e[n-1],t,i);if(r.changes&&!r.changes.empty||r.effects.length){let t=e.slice(0,n);return t[n-1]=r,t}t=r.mapped,n--,i=r.selectionsAfter}return i.length?[Zt.selection(i)]:nn}function ln(e,t,n){let i=tn(e.selectionsAfter.length?e.selectionsAfter.map((e=>e.map(t))):nn,n);if(!e.changes)return Zt.selection(i);let r=e.changes.map(t),o=t.mapDesc(e.changes,!0),s=e.mapped?e.mapped.composeDesc(o):o;return new Zt(r,a.StateEffect.mapEffects(e.effects,t),s,e.startSelection.map(o),i)}const an=/^(input\.type|delete)($|\.)/;class cn{constructor(e,t,n=0,i){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=i}isolate(){return this.prevTime?new cn(this.done,this.undone):this}addChanges(e,t,n,i,r){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&e.changes&&(!n||an.test(n))&&(!s.selectionsAfter.length&&t-this.prevTime<i&&function(e,t){let n=[],i=!1;return e.iterChangedRanges(((e,t)=>n.push(e,t))),t.iterChangedRanges(((e,t,r,o)=>{for(let s=0;s<n.length;){let e=n[s++],t=n[s++];o>=e&&r<=t&&(i=!0)}})),i}(s.changes,e.changes)||"input.type.compose"==n)?en(o,o.length-1,r,new Zt(e.changes.compose(s.changes),tn(e.effects,s.effects),s.mapped,s.startSelection,nn)):en(o,o.length,r,e),new cn(o,nn,t,n)}addSelection(e,t,n,i){let r=this.done.length?this.done[this.done.length-1].selectionsAfter:nn;return r.length>0&&t-this.prevTime<i&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&(o=r[r.length-1],s=e,o.ranges.length==s.ranges.length&&0===o.ranges.filter(((e,t)=>e.empty!=s.ranges[t].empty)).length)?this:new cn(rn(this.done,e),this.undone,t,n);var o,s}addMapping(e){return new cn(sn(this.done,e),sn(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,n){let i=0==e?this.done:this.undone;if(0==i.length)return null;let r=i[i.length-1];if(n&&r.selectionsAfter.length)return t.update({selection:r.selectionsAfter[r.selectionsAfter.length-1],annotations:jt.of({side:e,rest:on(i)}),userEvent:0==e?"select.undo":"select.redo",scrollIntoView:!0});if(r.changes){let n=1==i.length?nn:i.slice(0,i.length-1);return r.mapped&&(n=sn(n,r.mapped)),t.update({changes:r.changes,selection:r.startSelection,effects:r.effects,annotations:jt.of({side:e,rest:n}),filter:!1,userEvent:0==e?"undo":"redo",scrollIntoView:!0})}return null}}cn.empty=new cn(nn,nn);const hn=[{key:"Mod-z",run:Kt,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Qt,preventDefault:!0},{linux:"Ctrl-Shift-z",run:Qt,preventDefault:!0},{key:"Mod-u",run:Yt,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:Xt,preventDefault:!0}];function un(e,t){return a.EditorSelection.create(e.ranges.map(t),e.mainIndex)}function fn(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function dn({state:e,dispatch:t},n){let i=un(e.selection,n);return!i.eq(e.selection)&&(t(fn(e,i)),!0)}function pn(e,t){return a.EditorSelection.cursor(t?e.to:e.from)}function mn(e,t){return dn(e,(n=>n.empty?e.moveByChar(n,t):pn(n,t)))}function gn(e){return e.textDirectionAt(e.state.selection.main.head)==c.Direction.LTR}const yn=e=>mn(e,!gn(e)),vn=e=>mn(e,gn(e));function bn(e,t){return dn(e,(n=>n.empty?e.moveByGroup(n,t):pn(n,t)))}function wn(e,t,n){if(t.type.prop(n))return!0;let i=t.to-t.from;return i&&(i>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function xn(e,t,n){let i,r,o=we(e).resolveInner(t.head),s=n?d.closedBy:d.openedBy;for(let l=t.head;;){let t=n?o.childAfter(l):o.childBefore(l);if(!t)break;wn(e,t,s)?o=t:l=n?t.to:t.from}return r=o.type.prop(s)&&(i=n?Mt(e,o.from,1):Mt(e,o.to,-1))&&i.matched?n?i.end.to:i.end.from:n?o.to:o.from,a.EditorSelection.cursor(r,n?-1:1)}function kn(e,t){return dn(e,(n=>{if(!n.empty)return pn(n,t);let i=e.moveVertically(n,t);return i.head!=n.head?i:e.moveToLineBoundary(n,t)}))}const Sn=e=>kn(e,!1),Cn=e=>kn(e,!0);function An(e){return Math.max(e.defaultLineHeight,Math.min(e.dom.clientHeight,innerHeight)-5)}function En(e,t){let{state:n}=e,i=un(n.selection,(n=>n.empty?e.moveVertically(n,t,An(e)):pn(n,t)));if(i.eq(n.selection))return!1;let r,o=e.coordsAtPos(n.selection.main.head),s=e.scrollDOM.getBoundingClientRect();return o&&o.top>s.top&&o.bottom<s.bottom&&o.top-s.top<=e.scrollDOM.scrollHeight-e.scrollDOM.scrollTop-e.scrollDOM.clientHeight&&(r=c.EditorView.scrollIntoView(i.main.head,{y:"start",yMargin:o.top-s.top})),e.dispatch(fn(n,i),{effects:r}),!0}const Mn=e=>En(e,!1),On=e=>En(e,!0);function Dn(e,t,n){let i=e.lineBlockAt(t.head),r=e.moveToLineBoundary(t,n);if(r.head==t.head&&r.head!=(n?i.to:i.from)&&(r=e.moveToLineBoundary(t,n,!1)),!n&&r.head==i.from&&i.length){let n=/^\s*/.exec(e.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;n&&t.head!=i.from+n&&(r=a.EditorSelection.cursor(i.from+n))}return r}function Pn(e,t,n){let i=!1,r=un(e.selection,(t=>{let r=Mt(e,t.head,-1)||Mt(e,t.head,1)||t.head>0&&Mt(e,t.head-1,1)||t.head<e.doc.length&&Mt(e,t.head+1,-1);if(!r||!r.end)return t;i=!0;let o=r.start.from==t.head?r.end.to:r.end.from;return n?a.EditorSelection.range(t.anchor,o):a.EditorSelection.cursor(o)}));return!!i&&(t(fn(e,r)),!0)}function In(e,t){let n=un(e.state.selection,(e=>{let n=t(e);return a.EditorSelection.range(e.anchor,n.head,n.goalColumn)}));return!n.eq(e.state.selection)&&(e.dispatch(fn(e.state,n)),!0)}function Bn(e,t){return In(e,(n=>e.moveByChar(n,t)))}const Tn=e=>Bn(e,!gn(e)),Nn=e=>Bn(e,gn(e));function Rn(e,t){return In(e,(n=>e.moveByGroup(n,t)))}function Ln(e,t){return In(e,(n=>e.moveVertically(n,t)))}const _n=e=>Ln(e,!1),Fn=e=>Ln(e,!0);function Wn(e,t){return In(e,(n=>e.moveVertically(n,t,An(e))))}const Vn=e=>Wn(e,!1),qn=e=>Wn(e,!0),jn=({state:e,dispatch:t})=>(t(fn(e,{anchor:0})),!0),zn=({state:e,dispatch:t})=>(t(fn(e,{anchor:e.doc.length})),!0),Un=({state:e,dispatch:t})=>(t(fn(e,{anchor:e.selection.main.anchor,head:0})),!0),$n=({state:e,dispatch:t})=>(t(fn(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0);function Hn(e,t){if(e.state.readOnly)return!1;let n="delete.selection",{state:i}=e,r=i.changeByRange((i=>{let{from:r,to:o}=i;if(r==o){let i=t(r);i<r?(n="delete.backward",i=Jn(e,i,!1)):i>r&&(n="delete.forward",i=Jn(e,i,!0)),r=Math.min(r,i),o=Math.max(o,i)}else r=Jn(e,r,!1),o=Jn(e,o,!0);return r==o?{range:i}:{changes:{from:r,to:o},range:a.EditorSelection.cursor(r)}}));return!r.changes.empty&&(e.dispatch(i.update(r,{scrollIntoView:!0,userEvent:n,effects:"delete.selection"==n?c.EditorView.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function Jn(e,t,n){if(e instanceof c.EditorView)for(let i of e.state.facet(c.EditorView.atomicRanges).map((t=>t(e))))i.between(t,t,((e,i)=>{e<t&&i>t&&(t=n?i:e)}));return t}const Gn=(e,t)=>Hn(e,(n=>{let i,r,{state:o}=e,s=o.doc.lineAt(n);if(!t&&n>s.from&&n<s.from+200&&!/[^ \t]/.test(i=s.text.slice(0,n-s.from))){if("\t"==i[i.length-1])return n-1;let e=(0,a.countColumn)(i,o.tabSize)%Be(o)||Be(o);for(let t=0;t<e&&" "==i[i.length-1-t];t++)n--;r=n}else r=(0,a.findClusterBreak)(s.text,n-s.from,t,t)+s.from,r==n&&s.number!=(t?o.doc.lines:1)&&(r+=t?1:-1);return r})),Kn=e=>Gn(e,!1),Qn=e=>Gn(e,!0),Yn=(e,t)=>Hn(e,(n=>{let i=n,{state:r}=e,o=r.doc.lineAt(i),s=r.charCategorizer(i);for(let e=null;;){if(i==(t?o.to:o.from)){i==n&&o.number!=(t?r.doc.lines:1)&&(i+=t?1:-1);break}let l=(0,a.findClusterBreak)(o.text,i-o.from,t)+o.from,c=o.text.slice(Math.min(i,l)-o.from,Math.max(i,l)-o.from),h=s(c);if(null!=e&&h!=e)break;" "==c&&i==n||(e=h),i=l}return i})),Xn=e=>Yn(e,!1),Zn=e=>Hn(e,(t=>{let n=e.lineBlockAt(t).to;return t<n?n:Math.min(e.state.doc.length,t+1)}));function ei(e){let t=[],n=-1;for(let i of e.selection.ranges){let r=e.doc.lineAt(i.from),o=e.doc.lineAt(i.to);if(i.empty||i.to!=o.from||(o=e.doc.lineAt(i.to-1)),n>=r.number){let e=t[t.length-1];e.to=o.to,e.ranges.push(i)}else t.push({from:r.from,to:o.to,ranges:[i]});n=o.number+1}return t}function ti(e,t,n){if(e.readOnly)return!1;let i=[],r=[];for(let o of ei(e)){if(n?o.to==e.doc.length:0==o.from)continue;let t=e.doc.lineAt(n?o.to+1:o.from-1),s=t.length+1;if(n){i.push({from:o.to,to:t.to},{from:o.from,insert:t.text+e.lineBreak});for(let t of o.ranges)r.push(a.EditorSelection.range(Math.min(e.doc.length,t.anchor+s),Math.min(e.doc.length,t.head+s)))}else{i.push({from:t.from,to:o.from},{from:o.to,insert:e.lineBreak+t.text});for(let e of o.ranges)r.push(a.EditorSelection.range(e.anchor-s,e.head-s))}}return!!i.length&&(t(e.update({changes:i,scrollIntoView:!0,selection:a.EditorSelection.create(r,e.selection.mainIndex),userEvent:"move.line"})),!0)}function ni(e,t,n){if(e.readOnly)return!1;let i=[];for(let r of ei(e))n?i.push({from:r.from,insert:e.doc.slice(r.from,r.to)+e.lineBreak}):i.push({from:r.to,insert:e.lineBreak+e.doc.slice(r.from,r.to)});return t(e.update({changes:i,scrollIntoView:!0,userEvent:"input.copyline"})),!0}const ii=ri(!1);function ri(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let i=t.changeByRange((n=>{let{from:i,to:r}=n,o=t.doc.lineAt(i),s=!e&&i==r&&function(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n,i=we(e).resolveInner(t),r=i.childBefore(t),o=i.childAfter(t);return r&&o&&r.to<=t&&o.from>=t&&(n=r.type.prop(d.closedBy))&&n.indexOf(o.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(o.from).from?{from:r.to,to:o.from}:null}(t,i);e&&(i=r=(r<=o.to?o:t.doc.lineAt(r)).to);let l=new Re(t,{simulateBreak:i,simulateDoubleBreak:!!s}),c=Ne(l,i);for(null==c&&(c=/^\s*/.exec(t.doc.lineAt(i).text)[0].length);r<o.to&&/\s/.test(o.text[r-o.from]);)r++;s?({from:i,to:r}=s):i>o.from&&i<o.from+100&&!/\S/.test(o.text.slice(0,i))&&(i=o.from);let h=["",Te(t,c)];return s&&h.push(Te(t,l.lineIndent(o.from,-1))),{changes:{from:i,to:r,insert:a.Text.of(h)},range:a.EditorSelection.cursor(i+1+h[1].length)}}));return n(t.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function oi(e,t){let n=-1;return e.changeByRange((i=>{let r=[];for(let s=i.from;s<=i.to;){let o=e.doc.lineAt(s);o.number>n&&(i.empty||i.to>o.from)&&(t(o,r,i),n=o.number),s=o.to+1}let o=e.changes(r);return{changes:r,range:a.EditorSelection.range(o.mapPos(i.anchor,1),o.mapPos(i.head,1))}}))}const si=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(oi(e,((t,n)=>{n.push({from:t.from,insert:e.facet(Ie)})})),{userEvent:"input.indent"})),!0),li=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(oi(e,((t,n)=>{let i=/^\s*/.exec(t.text)[0];if(!i)return;let r=(0,a.countColumn)(i,e.tabSize),o=0,s=Te(e,Math.max(0,r-Be(e)));for(;o<i.length&&o<s.length&&i.charCodeAt(o)==s.charCodeAt(o);)o++;n.push({from:t.from+o,to:t.from+i.length,insert:s.slice(o)})})),{userEvent:"delete.dedent"})),!0),ai=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:e=>dn(e,(t=>xn(e.state,t,!gn(e)))),shift:e=>In(e,(t=>xn(e.state,t,!gn(e))))},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:e=>dn(e,(t=>xn(e.state,t,gn(e)))),shift:e=>In(e,(t=>xn(e.state,t,gn(e))))},{key:"Alt-ArrowUp",run:({state:e,dispatch:t})=>ti(e,t,!1)},{key:"Shift-Alt-ArrowUp",run:({state:e,dispatch:t})=>ni(e,t,!1)},{key:"Alt-ArrowDown",run:({state:e,dispatch:t})=>ti(e,t,!0)},{key:"Shift-Alt-ArrowDown",run:({state:e,dispatch:t})=>ni(e,t,!0)},{key:"Escape",run:({state:e,dispatch:t})=>{let n=e.selection,i=null;return n.ranges.length>1?i=a.EditorSelection.create([n.main]):n.main.empty||(i=a.EditorSelection.create([a.EditorSelection.cursor(n.main.head)])),!!i&&(t(fn(e,i)),!0)}},{key:"Mod-Enter",run:ri(!0)},{key:"Alt-l",mac:"Ctrl-l",run:({state:e,dispatch:t})=>{let n=ei(e).map((({from:t,to:n})=>a.EditorSelection.range(t,Math.min(n+1,e.doc.length))));return t(e.update({selection:a.EditorSelection.create(n),userEvent:"select"})),!0}},{key:"Mod-i",run:({state:e,dispatch:t})=>{let n=un(e.selection,(t=>{var n;let i=we(e).resolveInner(t.head,1);for(;!(i.from<t.from&&i.to>=t.to||i.to>t.to&&i.from<=t.from)&&(null===(n=i.parent)||void 0===n?void 0:n.parent);)i=i.parent;return a.EditorSelection.range(i.to,i.from)}));return t(fn(e,n)),!0},preventDefault:!0},{key:"Mod-[",run:li},{key:"Mod-]",run:si},{key:"Mod-Alt-\\",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),i=new Re(e,{overrideIndentation:e=>{let t=n[e];return null==t?-1:t}}),r=oi(e,((t,r,o)=>{let s=Ne(i,t.from);if(null==s)return;/\S/.test(t.text)||(s=0);let l=/^\s*/.exec(t.text)[0],a=Te(e,s);(l!=a||o.from<t.from+l.length)&&(n[t.from]=s,r.push({from:t.from,to:t.from+l.length,insert:a}))}));return r.changes.empty||t(e.update(r,{userEvent:"indent"})),!0}},{key:"Shift-Mod-k",run:e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(ei(t).map((({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n})))),i=un(t.selection,(t=>e.moveVertically(t,!0))).map(n);return e.dispatch({changes:n,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0}},{key:"Shift-Mod-\\",run:({state:e,dispatch:t})=>Pn(e,t,!1)},{key:"Mod-/",run:e=>{let t=Wt(e.state);return t.line?Lt(e):!!t.block&&Ft(e)}},{key:"Alt-A",run:_t}].concat([{key:"ArrowLeft",run:yn,shift:Tn,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:e=>bn(e,!gn(e)),shift:e=>Rn(e,!gn(e)),preventDefault:!0},{mac:"Cmd-ArrowLeft",run:e=>dn(e,(t=>Dn(e,t,!gn(e)))),shift:e=>In(e,(t=>Dn(e,t,!gn(e)))),preventDefault:!0},{key:"ArrowRight",run:vn,shift:Nn,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:e=>bn(e,gn(e)),shift:e=>Rn(e,gn(e)),preventDefault:!0},{mac:"Cmd-ArrowRight",run:e=>dn(e,(t=>Dn(e,t,gn(e)))),shift:e=>In(e,(t=>Dn(e,t,gn(e)))),preventDefault:!0},{key:"ArrowUp",run:Sn,shift:_n,preventDefault:!0},{mac:"Cmd-ArrowUp",run:jn,shift:Un},{mac:"Ctrl-ArrowUp",run:Mn,shift:Vn},{key:"ArrowDown",run:Cn,shift:Fn,preventDefault:!0},{mac:"Cmd-ArrowDown",run:zn,shift:$n},{mac:"Ctrl-ArrowDown",run:On,shift:qn},{key:"PageUp",run:Mn,shift:Vn},{key:"PageDown",run:On,shift:qn},{key:"Home",run:e=>dn(e,(t=>Dn(e,t,!1))),shift:e=>In(e,(t=>Dn(e,t,!1))),preventDefault:!0},{key:"Mod-Home",run:jn,shift:Un},{key:"End",run:e=>dn(e,(t=>Dn(e,t,!0))),shift:e=>In(e,(t=>Dn(e,t,!0))),preventDefault:!0},{key:"Mod-End",run:zn,shift:$n},{key:"Enter",run:ii},{key:"Mod-a",run:({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0)},{key:"Backspace",run:Kn,shift:Kn},{key:"Delete",run:Qn},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Xn},{key:"Mod-Delete",mac:"Alt-Delete",run:e=>Yn(e,!0)},{mac:"Mod-Backspace",run:e=>Hn(e,(t=>{let n=e.lineBlockAt(t).from;return t>n?n:Math.max(0,t-1)}))},{mac:"Mod-Delete",run:Zn}].concat([{key:"Ctrl-b",run:yn,shift:Tn,preventDefault:!0},{key:"Ctrl-f",run:vn,shift:Nn},{key:"Ctrl-p",run:Sn,shift:_n},{key:"Ctrl-n",run:Cn,shift:Fn},{key:"Ctrl-a",run:e=>dn(e,(t=>a.EditorSelection.cursor(e.lineBlockAt(t.head).from,1))),shift:e=>In(e,(t=>a.EditorSelection.cursor(e.lineBlockAt(t.head).from)))},{key:"Ctrl-e",run:e=>dn(e,(t=>a.EditorSelection.cursor(e.lineBlockAt(t.head).to,-1))),shift:e=>In(e,(t=>a.EditorSelection.cursor(e.lineBlockAt(t.head).to)))},{key:"Ctrl-d",run:Qn},{key:"Ctrl-h",run:Kn},{key:"Ctrl-k",run:Zn},{key:"Ctrl-Alt-h",run:Xn},{key:"Ctrl-o",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange((e=>({changes:{from:e.from,to:e.to,insert:a.Text.of(["",""])},range:a.EditorSelection.cursor(e.from)})));return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}},{key:"Ctrl-t",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange((t=>{if(!t.empty||0==t.from||t.from==e.doc.length)return{range:t};let n=t.from,i=e.doc.lineAt(n),r=n==i.from?n-1:(0,a.findClusterBreak)(i.text,n-i.from,!1)+i.from,o=n==i.to?n+1:(0,a.findClusterBreak)(i.text,n-i.from,!0)+i.from;return{changes:{from:r,to:o,insert:e.doc.slice(n,o).append(e.doc.slice(r,n))},range:a.EditorSelection.cursor(o)}}));return!n.changes.empty&&(t(e.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)}},{key:"Ctrl-v",run:On}].map((e=>({mac:e.key,run:e.run,shift:e.shift}))))),ci={key:"Tab",run:si,shift:li};function hi(){var e=arguments[0];"string"==typeof e&&(e=document.createElement(e));var t=1,n=arguments[1];if(n&&"object"==typeof n&&null==n.nodeType&&!Array.isArray(n)){for(var i in n)if(Object.prototype.hasOwnProperty.call(n,i)){var r=n[i];"string"==typeof r?e.setAttribute(i,r):null!=r&&(e[i]=r)}t++}for(;t<arguments.length;t++)ui(e,arguments[t]);return e}function ui(e,t){if("string"==typeof t)e.appendChild(document.createTextNode(t));else if(null==t);else if(null!=t.nodeType)e.appendChild(t);else{if(!Array.isArray(t))throw new RangeError("Unsupported child node: "+t);for(var n=0;n<t.length;n++)ui(e,t[n])}}const fi="function"==typeof String.prototype.normalize?e=>e.normalize("NFKD"):e=>e;class di{constructor(e,t,n=0,i=e.length,r,o){this.test=o,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(n,i),this.bufferStart=n,this.normalize=r?e=>r(fi(e)):fi,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return(0,a.codePointAt)(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=(0,a.fromCodePoint)(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=(0,a.codePointSize)(e);let i=this.normalize(t);for(let r=0,o=n;;r++){let e=i.charCodeAt(r),s=this.match(e,o);if(s)return this.value=s,this;if(r==i.length-1)break;o==n&&r<t.length&&t.charCodeAt(r)==e&&o++}}}match(e,t){let n=null;for(let i=0;i<this.matches.length;i+=2){let r=this.matches[i],o=!1;this.query.charCodeAt(r)==e&&(r==this.query.length-1?n={from:this.matches[i+1],to:t+1}:(this.matches[i]++,o=!0)),o||(this.matches.splice(i,2),i-=2)}return this.query.charCodeAt(0)==e&&(1==this.query.length?n={from:t,to:t+1}:this.matches.push(1,t)),n&&this.test&&!this.test(n.from,n.to,this.buffer,this.bufferPos)&&(n=null),n}}"undefined"!=typeof Symbol&&(di.prototype[Symbol.iterator]=function(){return this});const pi={from:-1,to:-1,match:/.*/.exec("")},mi="gm"+(null==/x/.unicode?"":"u");class gi{constructor(e,t,n,i=0,r=e.length){if(this.text=e,this.to=r,this.curLine="",this.done=!1,this.value=pi,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new bi(e,t,n,i,r);this.re=new RegExp(t,mi+((null===n||void 0===n?void 0:n.ignoreCase)?"i":"")),this.test=null===n||void 0===n?void 0:n.test,this.iter=e.iter();let o=e.lineAt(i);this.curLineStart=o.from,this.matchPos=wi(e,i),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,i=n+t[0].length;if(this.matchPos=wi(this.text,i+(n==i?1:0)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<i||n>this.value.to)&&(!this.test||this.test(n,i,t)))return this.value={from:n,to:i,match:t},this;e=this.matchPos-this.curLineStart}else{if(!(this.curLineStart+this.curLine.length<this.to))return this.done=!0,this;this.nextLine(),e=0}}}}const yi=new WeakMap;class vi{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,n){let i=yi.get(e);if(!i||i.from>=n||i.to<=t){let i=new vi(t,e.sliceString(t,n));return yi.set(e,i),i}if(i.from==t&&i.to==n)return i;let{text:r,from:o}=i;return o>t&&(r=e.sliceString(t,o)+r,o=t),i.to<n&&(r+=e.sliceString(i.to,n)),yi.set(e,new vi(o,r)),new vi(t,r.slice(t-o,n-o))}}class bi{constructor(e,t,n,i,r){this.text=e,this.to=r,this.done=!1,this.value=pi,this.matchPos=wi(e,i),this.re=new RegExp(t,mi+((null===n||void 0===n?void 0:n.ignoreCase)?"i":"")),this.test=null===n||void 0===n?void 0:n.test,this.flat=vi.get(e,i,this.chunkEnd(i+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,match:t},this.matchPos=wi(this.text,n+(e==n?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=vi.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+2*this.flat.text.length))}}}function wi(e,t){if(t>=e.length)return t;let n,i=e.lineAt(t);for(;t<i.to&&(n=i.text.charCodeAt(t-i.from))>=56320&&n<57344;)t++;return t}function xi(e){let t=hi("input",{class:"cm-textfield",name:"line"});function n(){let n=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(t.value);if(!n)return;let{state:i}=e,r=i.doc.lineAt(i.selection.main.head),[,o,s,l,c]=n,h=l?+l.slice(1):0,u=s?+s:r.number;if(s&&c){let e=u/100;o&&(e=e*("-"==o?-1:1)+r.number/i.doc.lines),u=Math.round(i.doc.lines*e)}else s&&o&&(u=u*("-"==o?-1:1)+r.number);let f=i.doc.line(Math.max(1,Math.min(i.doc.lines,u)));e.dispatch({effects:ki.of(!1),selection:a.EditorSelection.cursor(f.from+Math.max(0,Math.min(h,f.length))),scrollIntoView:!0}),e.focus()}return{dom:hi("form",{class:"cm-gotoLine",onkeydown:t=>{27==t.keyCode?(t.preventDefault(),e.dispatch({effects:ki.of(!1)}),e.focus()):13==t.keyCode&&(t.preventDefault(),n())},onsubmit:e=>{e.preventDefault(),n()}},hi("label",e.state.phrase("Go to line"),": ",t)," ",hi("button",{class:"cm-button",type:"submit"},e.state.phrase("go")))}}"undefined"!=typeof Symbol&&(gi.prototype[Symbol.iterator]=bi.prototype[Symbol.iterator]=function(){return this});const ki=a.StateEffect.define(),Si=a.StateField.define({create:()=>!0,update(e,t){for(let n of t.effects)n.is(ki)&&(e=n.value);return e},provide:e=>c.showPanel.from(e,(e=>e?xi:null))}),Ci=c.EditorView.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px","& label":{fontSize:"80%"}}}),Ai={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},Ei=a.Facet.define({combine:e=>(0,a.combineConfig)(e,Ai,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})});const Mi=c.Decoration.mark({class:"cm-selectionMatch"}),Oi=c.Decoration.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function Di(e,t,n,i){return(0==n||e(t.sliceDoc(n-1,n))!=a.CharCategory.Word)&&(i==t.doc.length||e(t.sliceDoc(i,i+1))!=a.CharCategory.Word)}const Pi=c.ViewPlugin.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(Ei),{state:n}=e,i=n.selection;if(i.ranges.length>1)return c.Decoration.none;let r,o=i.main,s=null;if(o.empty){if(!t.highlightWordAroundCursor)return c.Decoration.none;let e=n.wordAt(o.head);if(!e)return c.Decoration.none;s=n.charCategorizer(o.head),r=n.sliceDoc(e.from,e.to)}else{let e=o.to-o.from;if(e<t.minSelectionLength||e>200)return c.Decoration.none;if(t.wholeWords){if(r=n.sliceDoc(o.from,o.to),s=n.charCategorizer(o.head),!Di(s,n,o.from,o.to)||!function(e,t,n,i){return e(t.sliceDoc(n,n+1))==a.CharCategory.Word&&e(t.sliceDoc(i-1,i))==a.CharCategory.Word}(s,n,o.from,o.to))return c.Decoration.none}else if(r=n.sliceDoc(o.from,o.to).trim(),!r)return c.Decoration.none}let l=[];for(let a of e.visibleRanges){let e=new di(n.doc,r,a.from,a.to);for(;!e.next().done;){let{from:i,to:r}=e.value;if((!s||Di(s,n,i,r))&&(o.empty&&i<=o.from&&r>=o.to?l.push(Oi.range(i,r)):(i>=o.to||r<=o.from)&&l.push(Mi.range(i,r)),l.length>t.maxMatches))return c.Decoration.none}}return c.Decoration.set(l)}},{decorations:e=>e.decorations}),Ii=c.EditorView.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}});const Bi=a.Facet.define({combine:e=>(0,a.combineConfig)(e,{top:!1,caseSensitive:!1,literal:!1,wholeWord:!1,createPanel:e=>new or(e)})});class Ti{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||function(e){try{return new RegExp(e,mi),!0}catch(ge){return!1}}(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,((e,t)=>"n"==t?"\n":"r"==t?"\r":"t"==t?"\t":"\\"))}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord}create(){return this.regexp?new Vi(this):new Li(this)}getCursor(e,t=0,n){let i=e.doc?e:a.EditorState.create({doc:e});return null==n&&(n=i.doc.length),this.regexp?_i(this,i,t,n):Ri(this,i,t,n)}}class Ni{constructor(e){this.spec=e}}function Ri(e,t,n,i){return new di(t.doc,e.unquoted,n,i,e.caseSensitive?void 0:e=>e.toLowerCase(),e.wholeWord?(r=t.doc,o=t.charCategorizer(t.selection.main.head),(e,t,n,i)=>((i>e||i+n.length<t)&&(i=Math.max(0,e-2),n=r.sliceString(i,Math.min(r.length,t+2))),(o(Fi(n,e-i))!=a.CharCategory.Word||o(Wi(n,e-i))!=a.CharCategory.Word)&&(o(Wi(n,t-i))!=a.CharCategory.Word||o(Fi(n,t-i))!=a.CharCategory.Word))):void 0);var r,o}class Li extends Ni{constructor(e){super(e)}nextMatch(e,t,n){let i=Ri(this.spec,e,n,e.doc.length).nextOverlapping();return i.done&&(i=Ri(this.spec,e,0,t).nextOverlapping()),i.done?null:i.value}prevMatchInRange(e,t,n){for(let i=n;;){let n=Math.max(t,i-1e4-this.spec.unquoted.length),r=Ri(this.spec,e,n,i),o=null;for(;!r.nextOverlapping().done;)o=r.value;if(o)return o;if(n==t)return null;i-=1e4}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=Ri(this.spec,e,0,e.doc.length),i=[];for(;!n.next().done;){if(i.length>=t)return null;i.push(n.value)}return i}highlight(e,t,n,i){let r=Ri(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!r.next().done;)i(r.value.from,r.value.to)}}function _i(e,t,n,i){return new gi(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:e.wholeWord?(r=t.charCategorizer(t.selection.main.head),(e,t,n)=>!n[0].length||(r(Fi(n.input,n.index))!=a.CharCategory.Word||r(Wi(n.input,n.index))!=a.CharCategory.Word)&&(r(Wi(n.input,n.index+n[0].length))!=a.CharCategory.Word||r(Fi(n.input,n.index+n[0].length))!=a.CharCategory.Word)):void 0},n,i);var r}function Fi(e,t){return e.slice((0,a.findClusterBreak)(e,t,!1),t)}function Wi(e,t){return e.slice(t,(0,a.findClusterBreak)(e,t))}class Vi extends Ni{nextMatch(e,t,n){let i=_i(this.spec,e,n,e.doc.length).next();return i.done&&(i=_i(this.spec,e,0,t).next()),i.done?null:i.value}prevMatchInRange(e,t,n){for(let i=1;;i++){let r=Math.max(t,n-1e4*i),o=_i(this.spec,e,r,n),s=null;for(;!o.next().done;)s=o.value;if(s&&(r==t||s.from>r+10))return s;if(r==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace.replace(/\$([$&\d+])/g,((t,n)=>"$"==n?"$":"&"==n?e.match[0]:"0"!=n&&+n<e.match.length?e.match[n]:t)))}matchAll(e,t){let n=_i(this.spec,e,0,e.doc.length),i=[];for(;!n.next().done;){if(i.length>=t)return null;i.push(n.value)}return i}highlight(e,t,n,i){let r=_i(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!r.next().done;)i(r.value.from,r.value.to)}}const qi=a.StateEffect.define(),ji=a.StateEffect.define(),zi=a.StateField.define({create:e=>new Ui(tr(e).create(),null),update(e,t){for(let n of t.effects)n.is(qi)?e=new Ui(n.value.create(),e.panel):n.is(ji)&&(e=new Ui(e.query,n.value?er:null));return e},provide:e=>c.showPanel.from(e,(e=>e.panel))});class Ui{constructor(e,t){this.query=e,this.panel=t}}const $i=c.Decoration.mark({class:"cm-searchMatch"}),Hi=c.Decoration.mark({class:"cm-searchMatch cm-searchMatch-selected"}),Ji=c.ViewPlugin.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(zi))}update(e){let t=e.state.field(zi);(t!=e.startState.field(zi)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return c.Decoration.none;let{view:n}=this,i=new a.RangeSetBuilder;for(let r=0,o=n.visibleRanges,s=o.length;r<s;r++){let{from:t,to:l}=o[r];for(;r<s-1&&l>o[r+1].from-500;)l=o[++r].to;e.highlight(n.state,t,l,((e,t)=>{let r=n.state.selection.ranges.some((n=>n.from==e&&n.to==t));i.add(e,t,r?Hi:$i)}))}return i.finish()}},{decorations:e=>e.decorations});function Gi(e){return t=>{let n=t.state.field(zi,!1);return n&&n.query.spec.valid?e(t,n):nr(t)}}const Ki=Gi(((e,{query:t})=>{let{to:n}=e.state.selection.main,i=t.nextMatch(e.state,n,n);return!!i&&(e.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:ar(e,i),userEvent:"select.search"}),!0)})),Qi=Gi(((e,{query:t})=>{let{state:n}=e,{from:i}=n.selection.main,r=t.prevMatch(n,i,i);return!!r&&(e.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0,effects:ar(e,r),userEvent:"select.search"}),!0)})),Yi=Gi(((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!(!n||!n.length)&&(e.dispatch({selection:a.EditorSelection.create(n.map((e=>a.EditorSelection.range(e.from,e.to)))),userEvent:"select.search.matches"}),!0)})),Xi=Gi(((e,{query:t})=>{let{state:n}=e,{from:i,to:r}=n.selection.main;if(n.readOnly)return!1;let o=t.nextMatch(n,i,i);if(!o)return!1;let s,l,a=[],h=[];if(o.from==i&&o.to==r&&(l=n.toText(t.getReplacement(o)),a.push({from:o.from,to:o.to,insert:l}),o=t.nextMatch(n,o.from,o.to),h.push(c.EditorView.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(i).number)+"."))),o){let t=0==a.length||a[0].from>=o.to?0:o.to-o.from-l.length;s={anchor:o.from-t,head:o.to-t},h.push(ar(e,o))}return e.dispatch({changes:a,selection:s,scrollIntoView:!!s,effects:h,userEvent:"input.replace"}),!0})),Zi=Gi(((e,{query:t})=>{if(e.state.readOnly)return!1;let n=t.matchAll(e.state,1e9).map((e=>{let{from:n,to:i}=e;return{from:n,to:i,insert:t.getReplacement(e)}}));if(!n.length)return!1;let i=e.state.phrase("replaced $ matches",n.length)+".";return e.dispatch({changes:n,effects:c.EditorView.announce.of(i),userEvent:"input.replace.all"}),!0}));function er(e){return e.state.facet(Bi).createPanel(e)}function tr(e,t){var n,i,r,o;let s=e.selection.main,l=s.empty||s.to>s.from+100?"":e.sliceDoc(s.from,s.to);if(t&&!l)return t;let a=e.facet(Bi);return new Ti({search:(null!==(n=null===t||void 0===t?void 0:t.literal)&&void 0!==n?n:a.literal)?l:l.replace(/\n/g,"\\n"),caseSensitive:null!==(i=null===t||void 0===t?void 0:t.caseSensitive)&&void 0!==i?i:a.caseSensitive,literal:null!==(r=null===t||void 0===t?void 0:t.literal)&&void 0!==r?r:a.literal,wholeWord:null!==(o=null===t||void 0===t?void 0:t.wholeWord)&&void 0!==o?o:a.wholeWord})}const nr=e=>{let t=e.state.field(zi,!1);if(t&&t.panel){let n=(0,c.getPanel)(e,er);if(!n)return!1;let i=n.dom.querySelector("[main-field]");if(i&&i!=e.root.activeElement){let n=tr(e.state,t.query.spec);n.valid&&e.dispatch({effects:qi.of(n)}),i.focus(),i.select()}}else e.dispatch({effects:[ji.of(!0),t?qi.of(tr(e.state,t.query.spec)):a.StateEffect.appendConfig.of(hr)]});return!0},ir=e=>{let t=e.state.field(zi,!1);if(!t||!t.panel)return!1;let n=(0,c.getPanel)(e,er);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:ji.of(!1)}),!0},rr=[{key:"Mod-f",run:nr,scope:"editor search-panel"},{key:"F3",run:Ki,shift:Qi,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:Ki,shift:Qi,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:ir,scope:"editor search-panel"},{key:"Mod-Shift-l",run:({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:i,to:r}=n.main,o=[],s=0;for(let l=new di(e.doc,e.sliceDoc(i,r));!l.next().done;){if(o.length>1e3)return!1;l.value.from==i&&(s=o.length),o.push(a.EditorSelection.range(l.value.from,l.value.to))}return t(e.update({selection:a.EditorSelection.create(o,s),userEvent:"select.search.matches"})),!0}},{key:"Alt-g",run:e=>{let t=(0,c.getPanel)(e,xi);if(!t){let n=[ki.of(!0)];null==e.state.field(Si,!1)&&n.push(a.StateEffect.appendConfig.of([Si,Ci])),e.dispatch({effects:n}),t=(0,c.getPanel)(e,xi)}return t&&t.dom.querySelector("input").focus(),!0}},{key:"Mod-d",run:({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some((e=>e.from===e.to)))return(({state:e,dispatch:t})=>{let{selection:n}=e,i=a.EditorSelection.create(n.ranges.map((t=>e.wordAt(t.head)||a.EditorSelection.cursor(t.head))),n.mainIndex);return!i.eq(n)&&(t(e.update({selection:i})),!0)})({state:e,dispatch:t});let i=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some((t=>e.sliceDoc(t.from,t.to)!=i)))return!1;let r=function(e,t){let{main:n,ranges:i}=e.selection,r=e.wordAt(n.head),o=r&&r.from==n.from&&r.to==n.to;for(let s=!1,l=new di(e.doc,t,i[i.length-1].to);;){if(l.next(),!l.done){if(s&&i.some((e=>e.from==l.value.from)))continue;if(o){let t=e.wordAt(l.value.from);if(!t||t.from!=l.value.from||t.to!=l.value.to)continue}return l.value}if(s)return null;l=new di(e.doc,t,0,Math.max(0,i[i.length-1].from-1)),s=!0}}(e,i);return!!r&&(t(e.update({selection:e.selection.addRange(a.EditorSelection.range(r.from,r.to),!1),effects:c.EditorView.scrollIntoView(r.to)})),!0)},preventDefault:!0}];class or{constructor(e){this.view=e;let t=this.query=e.state.field(zi).query.spec;function n(e,t,n){return hi("button",{class:"cm-button",name:e,onclick:t,type:"button"},n)}this.commit=this.commit.bind(this),this.searchField=hi("input",{value:t.search,placeholder:sr(e,"Find"),"aria-label":sr(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=hi("input",{value:t.replace,placeholder:sr(e,"Replace"),"aria-label":sr(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=hi("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=hi("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=hi("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit}),this.dom=hi("div",{onkeydown:e=>this.keydown(e),class:"cm-search"},[this.searchField,n("next",(()=>Ki(e)),[sr(e,"next")]),n("prev",(()=>Qi(e)),[sr(e,"previous")]),n("select",(()=>Yi(e)),[sr(e,"all")]),hi("label",null,[this.caseField,sr(e,"match case")]),hi("label",null,[this.reField,sr(e,"regexp")]),hi("label",null,[this.wordField,sr(e,"by word")]),...e.state.readOnly?[]:[hi("br"),this.replaceField,n("replace",(()=>Xi(e)),[sr(e,"replace")]),n("replaceAll",(()=>Zi(e)),[sr(e,"replace all")]),hi("button",{name:"close",onclick:()=>ir(e),"aria-label":sr(e,"close"),type:"button"},["\xd7"])]])}commit(){let e=new Ti({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:qi.of(e)}))}keydown(e){(0,c.runScopeHandlers)(this.view,e,"search-panel")?e.preventDefault():13==e.keyCode&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?Qi:Ki)(this.view)):13==e.keyCode&&e.target==this.replaceField&&(e.preventDefault(),Xi(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(qi)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(Bi).top}}function sr(e,t){return e.state.phrase(t)}const lr=/[\s\.,:;?!]/;function ar(e,{from:t,to:n}){let i=e.state.doc.lineAt(t),r=e.state.doc.lineAt(n).to,o=Math.max(i.from,t-30),s=Math.min(r,n+30),l=e.state.sliceDoc(o,s);if(o!=i.from)for(let a=0;a<30;a++)if(!lr.test(l[a+1])&&lr.test(l[a])){l=l.slice(a);break}if(s!=r)for(let a=l.length-1;a>l.length-30;a--)if(!lr.test(l[a-1])&&lr.test(l[a])){l=l.slice(0,a);break}return c.EditorView.announce.of(`${e.state.phrase("current match")}. ${l} ${e.state.phrase("on line")} ${i.number}.`)}const cr=c.EditorView.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),hr=[zi,a.Prec.lowest(Ji),cr];class ur{constructor(e,t,n){this.state=e,this.pos=t,this.explicit=n,this.abortListeners=[]}tokenBefore(e){let t=we(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),i=t.text.slice(n-t.from,this.pos-t.from),r=i.search(gr(e,!1));return r<0?null:{from:n+r,to:this.pos,text:i.slice(r)}}get aborted(){return null==this.abortListeners}addEventListener(e,t){"abort"==e&&this.abortListeners&&this.abortListeners.push(t)}}function fr(e){let t=Object.keys(e).join(""),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,"")),`[${n?"\\w":""}${t.replace(/[^\w\s]/g,"\\$&")}]`}function dr(e){let t=e.map((e=>"string"==typeof e?{label:e}:e)),[n,i]=t.every((e=>/^\w+$/.test(e.label)))?[/\w*$/,/\w+$/]:function(e){let t=Object.create(null),n=Object.create(null);for(let{label:r}of e){t[r[0]]=!0;for(let e=1;e<r.length;e++)n[r[e]]=!0}let i=fr(t)+fr(n)+"*$";return[new RegExp("^"+i),new RegExp(i)]}(t);return e=>{let r=e.matchBefore(i);return r||e.explicit?{from:r?r.from:e.pos,options:t,validFor:n}:null}}class pr{constructor(e,t,n){this.completion=e,this.source=t,this.match=n}}function mr(e){return e.selection.main.head}function gr(e,t){var n;let{source:i}=e,r=t&&"^"!=i[0],o="$"!=i[i.length-1];return r||o?new RegExp(`${r?"^":""}(?:${i})${o?"$":""}`,null!==(n=e.flags)&&void 0!==n?n:e.ignoreCase?"i":""):e}function yr(e,t){const n=t.completion.apply||t.completion.label;let i=t.source;var r,o,s,l;"string"==typeof n?e.dispatch((r=e.state,o=n,s=i.from,l=i.to,Object.assign(Object.assign({},r.changeByRange((e=>{if(e==r.selection.main)return{changes:{from:s,to:l,insert:o},range:a.EditorSelection.cursor(s+o.length)};let t=l-s;return!e.empty||t&&r.sliceDoc(e.from-t,e.from)!=r.sliceDoc(s,l)?{range:e}:{changes:{from:e.from-t,to:e.from,insert:o},range:a.EditorSelection.cursor(e.from-t+o.length)}}))),{userEvent:"input.complete"}))):n(e,t.completion,i.from,i.to)}const vr=new WeakMap;function br(e){if(!Array.isArray(e))return e;let t=vr.get(e);return t||vr.set(e,t=dr(e)),t}class wr{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[];for(let t=0;t<e.length;){let n=(0,a.codePointAt)(e,t),i=(0,a.codePointSize)(n);this.chars.push(n);let r=e.slice(t,t+i),o=r.toUpperCase();this.folded.push((0,a.codePointAt)(o==r?r.toLowerCase():o,0)),t+=i}this.astral=e.length!=this.chars.length}match(e){if(0==this.pattern.length)return[0];if(e.length<this.pattern.length)return null;let{chars:t,folded:n,any:i,precise:r,byWord:o}=this;if(1==t.length){let i=(0,a.codePointAt)(e,0);return i==t[0]?[0,0,(0,a.codePointSize)(i)]:i==n[0]?[-200,0,(0,a.codePointSize)(i)]:null}let s=e.indexOf(this.pattern);if(0==s)return[0,0,this.pattern.length];let l=t.length,c=0;if(s<0){for(let r=0,o=Math.min(e.length,200);r<o&&c<l;){let o=(0,a.codePointAt)(e,r);o!=t[c]&&o!=n[c]||(i[c++]=r),r+=(0,a.codePointSize)(o)}if(c<l)return null}let h=0,u=0,f=!1,d=0,p=-1,m=-1,g=/[a-z]/.test(e),y=!0;for(let v=0,b=Math.min(e.length,200),w=0;v<b&&u<l;){let i=(0,a.codePointAt)(e,v);s<0&&(h<l&&i==t[h]&&(r[h++]=v),d<l&&(i==t[d]||i==n[d]?(0==d&&(p=v),m=v+1,d++):d=0));let c,b=i<255?i>=48&&i<=57||i>=97&&i<=122?2:i>=65&&i<=90?1:0:(c=(0,a.fromCodePoint)(i))!=c.toLowerCase()?1:c!=c.toUpperCase()?2:0;(!v||1==b&&g||0==w&&0!=b)&&(t[u]==i||n[u]==i&&(f=!0)?o[u++]=v:o.length&&(y=!1)),w=b,v+=(0,a.codePointSize)(i)}return u==l&&0==o[0]&&y?this.result((f?-200:0)-100,o,e):d==l&&0==p?[-200-e.length,0,m]:s>-1?[-700-e.length,s,s+this.pattern.length]:d==l?[-900-e.length,p,m]:u==l?this.result((f?-200:0)-100-700+(y?0:-1100),o,e):2==t.length?null:this.result((i[0]?-700:0)-200-1100,i,e)}result(e,t,n){let i=[e-n.length],r=1;for(let o of t){let e=o+(this.astral?(0,a.codePointSize)((0,a.codePointAt)(n,o)):1);r>1&&i[r-1]==o?i[r-1]=e:(i[r++]=o,i[r++]=e)}return i}}const xr=a.Facet.define({combine:e=>(0,a.combineConfig)(e,{activateOnTyping:!0,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],compareCompletions:(e,t)=>e.label.localeCompare(t.label),interactionDelay:75},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,optionClass:(e,t)=>n=>function(e,t){return e?t?e+" "+t:e:t}(e(n),t(n)),addToOptions:(e,t)=>e.concat(t)})});function kr(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let e=Math.floor(t/n);return{from:e*n,to:(e+1)*n}}let i=Math.floor((e-t)/n);return{from:e-(i+1)*n,to:e-i*n}}class Sr{constructor(e,t){this.view=e,this.stateField=t,this.info=null,this.placeInfo={read:()=>this.measureInfo(),write:e=>this.positionInfo(e),key:this};let n=e.state.field(t),{options:i,selected:r}=n.open,o=e.state.facet(xr);this.optionContent=function(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(e){let t=document.createElement("div");return t.classList.add("cm-completionIcon"),e.type&&t.classList.add(...e.type.split(/\s+/g).map((e=>"cm-completionIcon-"+e))),t.setAttribute("aria-hidden","true"),t},position:20}),t.push({render(e,t,n){let i=document.createElement("span");i.className="cm-completionLabel";let{label:r}=e,o=0;for(let s=1;s<n.length;){let e=n[s++],t=n[s++];e>o&&i.appendChild(document.createTextNode(r.slice(o,e)));let l=i.appendChild(document.createElement("span"));l.appendChild(document.createTextNode(r.slice(e,t))),l.className="cm-completionMatchedText",o=t}return o<r.length&&i.appendChild(document.createTextNode(r.slice(o))),i},position:50},{render(e){if(!e.detail)return null;let t=document.createElement("span");return t.className="cm-completionDetail",t.textContent=e.detail,t},position:80}),t.sort(((e,t)=>e.position-t.position)).map((e=>e.render))}(o),this.optionClass=o.optionClass,this.range=kr(i.length,r,o.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.dom.addEventListener("mousedown",(t=>{for(let n,r=t.target;r&&r!=this.dom;r=r.parentNode)if("LI"==r.nodeName&&(n=/-(\d+)$/.exec(r.id))&&+n[1]<i.length)return yr(e,i[+n[1]]),void t.preventDefault()})),this.list=this.dom.appendChild(this.createListBox(i,n.id,this.range)),this.list.addEventListener("scroll",(()=>{this.info&&this.view.requestMeasure(this.placeInfo)}))}mount(){this.updateSel()}update(e){e.state.field(this.stateField)!=e.startState.field(this.stateField)&&this.updateSel()}positioned(){this.info&&this.view.requestMeasure(this.placeInfo)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;if((t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=kr(t.options.length,t.selected,this.view.state.facet(xr).maxRenderedOptions),this.list.remove(),this.list=this.dom.appendChild(this.createListBox(t.options,e.id,this.range)),this.list.addEventListener("scroll",(()=>{this.info&&this.view.requestMeasure(this.placeInfo)}))),this.updateSelectedOption(t.selected)){this.info&&(this.info.remove(),this.info=null);let{completion:n}=t.options[t.selected],{info:i}=n;if(!i)return;let r="string"===typeof i?document.createTextNode(i):i(n);if(!r)return;"then"in r?r.then((t=>{t&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(t)})).catch((e=>(0,c.logException)(this.view.state,e,"completion info"))):this.addInfoPane(r)}}addInfoPane(e){let t=this.info=document.createElement("div");t.className="cm-tooltip cm-completionInfo",t.appendChild(e),this.dom.appendChild(t),this.view.requestMeasure(this.placeInfo)}updateSelectedOption(e){let t=null;for(let n=this.list.firstChild,i=this.range.from;n;n=n.nextSibling,i++)i==e?n.hasAttribute("aria-selected")||(n.setAttribute("aria-selected","true"),t=n):n.hasAttribute("aria-selected")&&n.removeAttribute("aria-selected");return t&&function(e,t){let n=e.getBoundingClientRect(),i=t.getBoundingClientRect();i.top<n.top?e.scrollTop-=n.top-i.top:i.bottom>n.bottom&&(e.scrollTop+=i.bottom-n.bottom)}(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.ownerDocument.defaultView||window,n=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),r=e.getBoundingClientRect();if(r.top>Math.min(t.innerHeight,n.bottom)-10||r.bottom<Math.max(0,n.top)+10)return null;let o,s=this.view.textDirection==c.Direction.RTL,l=s,a=!1,h="",u="",f=n.left,d=t.innerWidth-n.right;if(l&&f<Math.min(i.width,d)?l=!1:!l&&d<Math.min(i.width,f)&&(l=!0),i.width<=(l?f:d))h=Math.max(0,Math.min(r.top,t.innerHeight-i.height))-n.top+"px",o=Math.min(400,l?f:d)+"px";else{a=!0,o=Math.min(400,(s?n.right:t.innerWidth-n.left)-30)+"px";let e=t.innerHeight-n.bottom;e>=i.height||e>n.top?h=r.bottom-n.top+"px":u=n.bottom-r.top+"px"}return{top:h,bottom:u,maxWidth:o,class:a?s?"left-narrow":"right-narrow":l?"left":"right"}}positionInfo(e){this.info&&(e?(this.info.style.top=e.top,this.info.style.bottom=e.bottom,this.info.style.maxWidth=e.maxWidth,this.info.className="cm-tooltip cm-completionInfo cm-completionInfo-"+e.class):this.info.style.top="-1e6px")}createListBox(e,t,n){const i=document.createElement("ul");i.id=t,i.setAttribute("role","listbox"),i.setAttribute("aria-expanded","true"),i.setAttribute("aria-label",this.view.state.phrase("Completions"));for(let r=n.from;r<n.to;r++){let{completion:n,match:o}=e[r];const s=i.appendChild(document.createElement("li"));s.id=t+"-"+r,s.setAttribute("role","option");let l=this.optionClass(n);l&&(s.className=l);for(let e of this.optionContent){let t=e(n,this.view.state,o);t&&s.appendChild(t)}}return n.from&&i.classList.add("cm-completionListIncompleteTop"),n.to<e.length&&i.classList.add("cm-completionListIncompleteBottom"),i}}function Cr(e){return 100*(e.boost||0)+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}class Ar{constructor(e,t,n,i,r){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=i,this.selected=r}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new Ar(this.options,Or(t,e),this.tooltip,this.timestamp,e)}static build(e,t,n,i,r){let o=function(e,t){let n=[],i=0;for(let l of e)if(l.hasResult())if(!1===l.result.filter){let e=l.result.getMatch;for(let t of l.result.options){let r=[1e9-i++];if(e)for(let n of e(t))r.push(n);n.push(new pr(t,l,r))}}else{let e,i=new wr(t.sliceDoc(l.from,l.to));for(let t of l.result.options)(e=i.match(t.label))&&(null!=t.boost&&(e[0]+=t.boost),n.push(new pr(t,l,e)))}let r=[],o=null,s=t.facet(xr).compareCompletions;for(let l of n.sort(((e,t)=>t.match[0]-e.match[0]||s(e.completion,t.completion))))!o||o.label!=l.completion.label||o.detail!=l.completion.detail||null!=o.type&&null!=l.completion.type&&o.type!=l.completion.type||o.apply!=l.completion.apply?r.push(l):Cr(l.completion)>Cr(o)&&(r[r.length-1]=l),o=l.completion;return r}(e,t);if(!o.length)return null;let s=t.facet(xr).selectOnOpen?0:-1;if(i&&i.selected!=s&&-1!=i.selected){let e=i.options[i.selected].completion;for(let t=0;t<o.length;t++)if(o[t].completion==e){s=t;break}}return new Ar(o,Or(n,s),{pos:e.reduce(((e,t)=>t.hasResult()?Math.min(e,t.from):e),1e8),create:(l=_r,e=>new Sr(e,l)),above:r.aboveCursor},i?i.timestamp:Date.now(),s);var l}map(e){return new Ar(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:e.mapPos(this.tooltip.pos)}),this.timestamp,this.selected)}}class Er{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new Er(Dr,"cm-ac-"+Math.floor(2e6*Math.random()).toString(36),null)}update(e){let{state:t}=e,n=t.facet(xr),i=(n.override||t.languageDataAt("autocomplete",mr(t)).map(br)).map((t=>(this.active.find((e=>e.source==t))||new Ir(t,this.active.some((e=>0!=e.state))?1:0)).update(e,n)));i.length==this.active.length&&i.every(((e,t)=>e==this.active[t]))&&(i=this.active);let r=e.selection||i.some((t=>t.hasResult()&&e.changes.touchesRange(t.from,t.to)))||!function(e,t){if(e==t)return!0;for(let n=0,i=0;;){for(;n<e.length&&!e[n].hasResult;)n++;for(;i<t.length&&!t[i].hasResult;)i++;let r=n==e.length,o=i==t.length;if(r||o)return r==o;if(e[n++].result!=t[i++].result)return!1}}(i,this.active)?Ar.build(i,t,this.id,this.open,n):this.open&&e.docChanged?this.open.map(e.changes):this.open;!r&&i.every((e=>1!=e.state))&&i.some((e=>e.hasResult()))&&(i=i.map((e=>e.hasResult()?new Ir(e.source,0):e)));for(let o of e.effects)o.is(Lr)&&(r=r&&r.setSelected(o.value,this.id));return i==this.active&&r==this.open?this:new Er(i,this.id,r)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:Mr}}const Mr={"aria-autocomplete":"list"};function Or(e,t){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}const Dr=[];function Pr(e){return e.isUserEvent("input.type")?"input":e.isUserEvent("delete.backward")?"delete":null}class Ir{constructor(e,t,n=-1){this.source=e,this.state=t,this.explicitPos=n}hasResult(){return!1}update(e,t){let n=Pr(e),i=this;n?i=i.handleUserEvent(e,n,t):e.docChanged?i=i.handleChange(e):e.selection&&0!=i.state&&(i=new Ir(i.source,0));for(let r of e.effects)if(r.is(Tr))i=new Ir(i.source,1,r.value?mr(e.state):-1);else if(r.is(Nr))i=new Ir(i.source,0);else if(r.is(Rr))for(let e of r.value)e.source==i.source&&(i=e);return i}handleUserEvent(e,t,n){return"delete"!=t&&n.activateOnTyping?new Ir(this.source,1):this.map(e.changes)}handleChange(e){return e.changes.touchesRange(mr(e.startState))?new Ir(this.source,0):this.map(e.changes)}map(e){return e.empty||this.explicitPos<0?this:new Ir(this.source,this.state,e.mapPos(this.explicitPos))}}class Br extends Ir{constructor(e,t,n,i,r){super(e,2,t),this.result=n,this.from=i,this.to=r}hasResult(){return!0}handleUserEvent(e,t,n){var i;let r=e.changes.mapPos(this.from),o=e.changes.mapPos(this.to,1),s=mr(e.state);if((this.explicitPos<0?s<=r:s<this.from)||s>o||"delete"==t&&mr(e.startState)==this.from)return new Ir(this.source,"input"==t&&n.activateOnTyping?1:0);let l,a=this.explicitPos<0?-1:e.changes.mapPos(this.explicitPos);return function(e,t,n,i){if(!e)return!1;let r=t.sliceDoc(n,i);return"function"==typeof e?e(r,n,i,t):gr(e,!0).test(r)}(this.result.validFor,e.state,r,o)?new Br(this.source,a,this.result,r,o):this.result.update&&(l=this.result.update(this.result,r,o,new ur(e.state,s,a>=0)))?new Br(this.source,a,l,l.from,null!==(i=l.to)&&void 0!==i?i:mr(e.state)):new Ir(this.source,1,a)}handleChange(e){return e.changes.touchesRange(this.from,this.to)?new Ir(this.source,0):this.map(e.changes)}map(e){return e.empty?this:new Br(this.source,this.explicitPos<0?-1:e.mapPos(this.explicitPos),this.result,e.mapPos(this.from),e.mapPos(this.to,1))}}const Tr=a.StateEffect.define(),Nr=a.StateEffect.define(),Rr=a.StateEffect.define({map:(e,t)=>e.map((e=>e.map(t)))}),Lr=a.StateEffect.define(),_r=a.StateField.define({create:()=>Er.start(),update:(e,t)=>e.update(t),provide:e=>[c.showTooltip.from(e,(e=>e.tooltip)),c.EditorView.contentAttributes.from(e,(e=>e.attrs))]});function Fr(e,t="option"){return n=>{let i=n.state.field(_r,!1);if(!i||!i.open||Date.now()-i.open.timestamp<n.state.facet(xr).interactionDelay)return!1;let r,o=1;"page"==t&&(r=(0,c.getTooltip)(n,i.open.tooltip))&&(o=Math.max(2,Math.floor(r.dom.offsetHeight/r.dom.querySelector("li").offsetHeight)-1));let{length:s}=i.open.options,l=i.open.selected>-1?i.open.selected+o*(e?1:-1):e?0:s-1;return l<0?l="page"==t?0:s-1:l>=s&&(l="page"==t?s-1:0),n.dispatch({effects:Lr.of(l)}),!0}}class Wr{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const Vr=c.ViewPlugin.fromClass(class{constructor(e){this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.composing=0;for(let t of e.state.field(_r).active)1==t.state&&this.startQuery(t)}update(e){let t=e.state.field(_r);if(!e.selectionSet&&!e.docChanged&&e.startState.field(_r)==t)return;let n=e.transactions.some((e=>(e.selection||e.docChanged)&&!Pr(e)));for(let r=0;r<this.running.length;r++){let t=this.running[r];if(n||t.updates.length+e.transactions.length>50&&Date.now()-t.time>1e3){for(let e of t.context.abortListeners)try{e()}catch(i){(0,c.logException)(this.view.state,i)}t.context.abortListeners=null,this.running.splice(r--,1)}else t.updates.push(...e.transactions)}if(this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),this.debounceUpdate=t.active.some((e=>1==e.state&&!this.running.some((t=>t.active.source==e.source))))?setTimeout((()=>this.startUpdate()),50):-1,0!=this.composing)for(let r of e.transactions)"input"==Pr(r)?this.composing=2:2==this.composing&&r.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1;let{state:e}=this.view,t=e.field(_r);for(let n of t.active)1!=n.state||this.running.some((e=>e.active.source==n.source))||this.startQuery(n)}startQuery(e){let{state:t}=this.view,n=mr(t),i=new ur(t,n,e.explicitPos==n),r=new Wr(e,i);this.running.push(r),Promise.resolve(e.source(i)).then((e=>{r.context.aborted||(r.done=e||null,this.scheduleAccept())}),(e=>{this.view.dispatch({effects:Nr.of(null)}),(0,c.logException)(this.view.state,e)}))}scheduleAccept(){this.running.every((e=>void 0!==e.done))?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout((()=>this.accept()),50))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],n=this.view.state.facet(xr);for(let i=0;i<this.running.length;i++){let r=this.running[i];if(void 0===r.done)continue;if(this.running.splice(i--,1),r.done){let i=new Br(r.active.source,r.active.explicitPos,r.done,r.done.from,null!==(e=r.done.to)&&void 0!==e?e:mr(r.updates.length?r.updates[0].startState:this.view.state));for(let e of r.updates)i=i.update(e,n);if(i.hasResult()){t.push(i);continue}}let o=this.view.state.field(_r).active.find((e=>e.source==r.active.source));if(o&&1==o.state)if(null==r.done){let e=new Ir(r.active.source,0);for(let t of r.updates)e=e.update(t,n);1!=e.state&&t.push(e)}else this.startQuery(o)}t.length&&this.view.dispatch({effects:Rr.of(t)})}},{eventHandlers:{blur(){let e=this.view.state.field(_r,!1);e&&e.tooltip&&this.view.state.facet(xr).closeOnBlur&&this.view.dispatch({effects:Nr.of(null)})},compositionstart(){this.composing=1},compositionend(){3==this.composing&&setTimeout((()=>this.view.dispatch({effects:Tr.of(!1)})),20),this.composing=0}}}),qr=c.EditorView.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",listStyle:"none",margin:0,padding:0,"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer",padding:"1px 3px",lineHeight:1.2}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"\xb7\xb7\xb7"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'\u0192'"}},".cm-completionIcon-class":{"&:after":{content:"'\u25cb'"}},".cm-completionIcon-interface":{"&:after":{content:"'\u25cc'"}},".cm-completionIcon-variable":{"&:after":{content:"'\ud835\udc65'"}},".cm-completionIcon-constant":{"&:after":{content:"'\ud835\udc36'"}},".cm-completionIcon-type":{"&:after":{content:"'\ud835\udc61'"}},".cm-completionIcon-enum":{"&:after":{content:"'\u222a'"}},".cm-completionIcon-property":{"&:after":{content:"'\u25a1'"}},".cm-completionIcon-keyword":{"&:after":{content:"'\ud83d\udd11\ufe0e'"}},".cm-completionIcon-namespace":{"&:after":{content:"'\u25a2'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});const jr={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},zr=a.StateEffect.define({map(e,t){let n=t.mapPos(e,-1,a.MapMode.TrackAfter);return null==n?void 0:n}}),Ur=a.StateEffect.define({map:(e,t)=>t.mapPos(e)}),$r=new class extends a.RangeValue{};$r.startSide=1,$r.endSide=-1;const Hr=a.StateField.define({create:()=>a.RangeSet.empty,update(e,t){if(t.selection){let n=t.state.doc.lineAt(t.selection.main.head).from,i=t.startState.doc.lineAt(t.startState.selection.main.head).from;n!=t.changes.mapPos(i,-1)&&(e=a.RangeSet.empty)}e=e.map(t.changes);for(let n of t.effects)n.is(zr)?e=e.update({add:[$r.range(n.value,n.value+1)]}):n.is(Ur)&&(e=e.update({filter:e=>e!=n.value}));return e}});const Jr="()[]{}<>";function Gr(e){for(let t=0;t<Jr.length;t+=2)if(Jr.charCodeAt(t)==e)return Jr.charAt(t+1);return(0,a.fromCodePoint)(e<128?e:e+1)}function Kr(e,t){return e.languageDataAt("closeBrackets",t)[0]||jr}const Qr="object"==typeof navigator&&/Android\b/.test(navigator.userAgent),Yr=c.EditorView.inputHandler.of(((e,t,n,i)=>{if((Qr?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let r=e.state.selection.main;if(i.length>2||2==i.length&&1==(0,a.codePointSize)((0,a.codePointAt)(i,0))||t!=r.from||n!=r.to)return!1;let o=function(e,t){let n=Kr(e,e.selection.main.head),i=n.brackets||jr.brackets;for(let r of i){let o=Gr((0,a.codePointAt)(r,0));if(t==r)return o==r?io(e,r,i.indexOf(r+r+r)>-1,n):to(e,r,o,n.before||jr.before);if(t==o&&Zr(e,e.selection.main.from))return no(e,r,o)}return null}(e.state,i);return!!o&&(e.dispatch(o),!0)})),Xr=[{key:"Backspace",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Kr(e,e.selection.main.head).brackets||jr.brackets,i=null,r=e.changeByRange((t=>{if(t.empty){let i=function(e,t){let n=e.sliceString(t-2,t);return(0,a.codePointSize)((0,a.codePointAt)(n,0))==n.length?n:n.slice(1)}(e.doc,t.head);for(let r of n)if(r==i&&eo(e.doc,t.head)==Gr((0,a.codePointAt)(r,0)))return{changes:{from:t.head-r.length,to:t.head+r.length},range:a.EditorSelection.cursor(t.head-r.length)}}return{range:i=t}}));return i||t(e.update(r,{scrollIntoView:!0,userEvent:"delete.backward"})),!i}}];function Zr(e,t){let n=!1;return e.field(Hr).between(0,e.doc.length,(e=>{e==t&&(n=!0)})),n}function eo(e,t){let n=e.sliceString(t,t+2);return n.slice(0,(0,a.codePointSize)((0,a.codePointAt)(n,0)))}function to(e,t,n,i){let r=null,o=e.changeByRange((o=>{if(!o.empty)return{changes:[{insert:t,from:o.from},{insert:n,from:o.to}],effects:zr.of(o.to+t.length),range:a.EditorSelection.range(o.anchor+t.length,o.head+t.length)};let s=eo(e.doc,o.head);return!s||/\s/.test(s)||i.indexOf(s)>-1?{changes:{insert:t+n,from:o.head},effects:zr.of(o.head+t.length),range:a.EditorSelection.cursor(o.head+t.length)}:{range:r=o}}));return r?null:e.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function no(e,t,n){let i=null,r=e.selection.ranges.map((t=>t.empty&&eo(e.doc,t.head)==n?a.EditorSelection.cursor(t.head+n.length):i=t));return i?null:e.update({selection:a.EditorSelection.create(r,e.selection.mainIndex),scrollIntoView:!0,effects:e.selection.ranges.map((({from:e})=>Ur.of(e)))})}function io(e,t,n,i){let r=i.stringPrefixes||jr.stringPrefixes,o=null,s=e.changeByRange((i=>{if(!i.empty)return{changes:[{insert:t,from:i.from},{insert:t,from:i.to}],effects:zr.of(i.to+t.length),range:a.EditorSelection.range(i.anchor+t.length,i.head+t.length)};let s,l=i.head,c=eo(e.doc,l);if(c==t){if(ro(e,l))return{changes:{insert:t+t,from:l},effects:zr.of(l+t.length),range:a.EditorSelection.cursor(l+t.length)};if(Zr(e,l)){let i=n&&e.sliceDoc(l,l+3*t.length)==t+t+t;return{range:a.EditorSelection.cursor(l+t.length*(i?3:1)),effects:Ur.of(l)}}}else{if(n&&e.sliceDoc(l-2*t.length,l)==t+t&&(s=oo(e,l-2*t.length,r))>-1&&ro(e,s))return{changes:{insert:t+t+t+t,from:l},effects:zr.of(l+t.length),range:a.EditorSelection.cursor(l+t.length)};if(e.charCategorizer(l)(c)!=a.CharCategory.Word&&oo(e,l,r)>-1&&!function(e,t,n,i){let r=we(e).resolveInner(t,-1),o=i.reduce(((e,t)=>Math.max(e,t.length)),0);for(let s=0;s<5;s++){let s=e.sliceDoc(r.from,Math.min(r.to,r.from+n.length+o)),l=s.indexOf(n);if(!l||l>-1&&i.indexOf(s.slice(0,l))>-1){let t=r.firstChild;for(;t&&t.from==r.from&&t.to-t.from>n.length+l;){if(e.sliceDoc(t.to-n.length,t.to)==n)return!1;t=t.firstChild}return!0}let a=r.to==t&&r.parent;if(!a)break;r=a}return!1}(e,l,t,r))return{changes:{insert:t+t,from:l},effects:zr.of(l+t.length),range:a.EditorSelection.cursor(l+t.length)}}return{range:o=i}}));return o?null:e.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function ro(e,t){let n=we(e).resolveInner(t+1);return n.parent&&n.from==t}function oo(e,t,n){let i=e.charCategorizer(t);if(i(e.sliceDoc(t-1,t))!=a.CharCategory.Word)return t;for(let r of n){let n=t-r.length;if(e.sliceDoc(n,t)==r&&i(e.sliceDoc(n-1,n))!=a.CharCategory.Word)return n}return-1}const so=[{key:"Ctrl-Space",run:e=>!!e.state.field(_r,!1)&&(e.dispatch({effects:Tr.of(!0)}),!0)},{key:"Escape",run:e=>{let t=e.state.field(_r,!1);return!(!t||!t.active.some((e=>0!=e.state)))&&(e.dispatch({effects:Nr.of(null)}),!0)}},{key:"ArrowDown",run:Fr(!0)},{key:"ArrowUp",run:Fr(!1)},{key:"PageDown",run:Fr(!0,"page")},{key:"PageUp",run:Fr(!1,"page")},{key:"Enter",run:e=>{let t=e.state.field(_r,!1);return!(e.state.readOnly||!t||!t.open||t.open.selected<0||Date.now()-t.open.timestamp<e.state.facet(xr).interactionDelay)&&(yr(e,t.open.options[t.open.selected]),!0)}}],lo=a.Prec.highest(c.keymap.computeN([xr],(e=>e.facet(xr).defaultKeymap?[so]:[])));class ao{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}}class co{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(e,t,n){let i=e,r=n.facet(Co).markerFilter;r&&(i=r(i));let o=c.Decoration.set(i.map((e=>e.from==e.to||e.from==e.to-1&&n.doc.lineAt(e.from).to==e.from?c.Decoration.widget({widget:new Mo(e),diagnostic:e}).range(e.from):c.Decoration.mark({attributes:{class:"cm-lintRange cm-lintRange-"+e.severity},diagnostic:e}).range(e.from,e.to))),!0);return new co(o,t,ho(o))}}function ho(e,t=null,n=0){let i=null;return e.between(n,1e9,((e,n,{spec:r})=>{if(!t||r.diagnostic==t)return i=new ao(e,n,r.diagnostic),!1})),i}function uo(e,t){return!(!e.effects.some((e=>e.is(po)))&&!e.changes.touchesRange(t.pos))}function fo(e,t){return e.field(yo,!1)?t:t.concat(a.StateEffect.appendConfig.of([yo,c.EditorView.decorations.compute([yo],(e=>{let{selected:t,panel:n}=e.field(yo);return t&&n&&t.from!=t.to?c.Decoration.set([vo.range(t.from,t.to)]):c.Decoration.none})),(0,c.hoverTooltip)(bo,{hideOn:uo}),Bo]))}const po=a.StateEffect.define(),mo=a.StateEffect.define(),go=a.StateEffect.define(),yo=a.StateField.define({create:()=>new co(c.Decoration.none,null,null),update(e,t){if(t.docChanged){let n=e.diagnostics.map(t.changes),i=null;if(e.selected){let r=t.changes.mapPos(e.selected.from,1);i=ho(n,e.selected.diagnostic,r)||ho(n,null,r)}e=new co(n,e.panel,i)}for(let n of t.effects)n.is(po)?e=co.init(n.value,e.panel,t.state):n.is(mo)?e=new co(e.diagnostics,n.value?Do.open:null,e.selected):n.is(go)&&(e=new co(e.diagnostics,e.panel,n.value));return e},provide:e=>[c.showPanel.from(e,(e=>e.panel)),c.EditorView.decorations.from(e,(e=>e.diagnostics))]});const vo=c.Decoration.mark({class:"cm-lintRange cm-lintRange-active"});function bo(e,t,n){let{diagnostics:i}=e.state.field(yo),r=[],o=2e8,s=0;i.between(t-(n<0?1:0),t+(n>0?1:0),((e,i,{spec:l})=>{t>=e&&t<=i&&(e==i||(t>e||n>0)&&(t<i||n<0))&&(r.push(l.diagnostic),o=Math.min(e,o),s=Math.max(i,s))}));let l=e.state.facet(Co).tooltipFilter;return l&&(r=l(r)),r.length?{pos:o,end:s,above:e.state.doc.lineAt(o).to<s,create:()=>({dom:wo(e,r)})}:null}function wo(e,t){return hi("ul",{class:"cm-tooltip-lint"},t.map((t=>Eo(e,t,!1))))}const xo=e=>{let t=e.state.field(yo,!1);return!(!t||!t.panel)&&(e.dispatch({effects:mo.of(!1)}),!0)},ko=[{key:"Mod-Shift-m",run:e=>{let t=e.state.field(yo,!1);t&&t.panel||e.dispatch({effects:fo(e.state,[mo.of(!0)])});let n=(0,c.getPanel)(e,Do.open);return n&&n.dom.querySelector(".cm-panel-lint ul").focus(),!0}},{key:"F8",run:e=>{let t=e.state.field(yo,!1);if(!t)return!1;let n=e.state.selection.main,i=t.diagnostics.iter(n.to+1);return!(!i.value&&(i=t.diagnostics.iter(0),!i.value||i.from==n.from&&i.to==n.to))&&(e.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0}),!0)}}],So=c.ViewPlugin.fromClass(class{constructor(e){this.view=e,this.timeout=-1,this.set=!0;let{delay:t}=e.state.facet(Co);this.lintTime=Date.now()+t,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,t)}run(){let e=Date.now();if(e<this.lintTime-10)setTimeout(this.run,this.lintTime-e);else{this.set=!1;let{state:e}=this.view,{sources:t}=e.facet(Co);Promise.all(t.map((e=>Promise.resolve(e(this.view))))).then((t=>{let n=t.reduce(((e,t)=>e.concat(t)));this.view.state.doc==e.doc&&this.view.dispatch(function(e,t){return{effects:fo(e,[po.of(t)])}}(this.view.state,n))}),(e=>{(0,c.logException)(this.view.state,e)}))}}update(e){let t=e.state.facet(Co);(e.docChanged||t!=e.startState.facet(Co))&&(this.lintTime=Date.now()+t.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,t.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}}),Co=a.Facet.define({combine:e=>Object.assign({sources:e.map((e=>e.source))},(0,a.combineConfig)(e.map((e=>e.config)),{delay:750,markerFilter:null,tooltipFilter:null})),enables:So});function Ao(e){let t=[];if(e)e:for(let{name:n}of e){for(let e=0;e<n.length;e++){let i=n[e];if(/[a-zA-Z]/.test(i)&&!t.some((e=>e.toLowerCase()==i.toLowerCase()))){t.push(i);continue e}}t.push("")}return t}function Eo(e,t,n){var i;let r=n?Ao(t.actions):[];return hi("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},hi("span",{class:"cm-diagnosticText"},t.renderMessage?t.renderMessage():t.message),null===(i=t.actions)||void 0===i?void 0:i.map(((n,i)=>{let o=i=>{i.preventDefault();let r=ho(e.state.field(yo).diagnostics,t);r&&n.apply(e,r.from,r.to)},{name:s}=n,l=r[i]?s.indexOf(r[i]):-1,a=l<0?s:[s.slice(0,l),hi("u",s.slice(l,l+1)),s.slice(l+1)];return hi("button",{type:"button",class:"cm-diagnosticAction",onclick:o,onmousedown:o,"aria-label":` Action: ${s}${l<0?"":` (access key "${r[i]})"`}.`},a)})),t.source&&hi("div",{class:"cm-diagnosticSource"},t.source))}class Mo extends c.WidgetType{constructor(e){super(),this.diagnostic=e}eq(e){return e.diagnostic==this.diagnostic}toDOM(){return hi("span",{class:"cm-lintPoint cm-lintPoint-"+this.diagnostic.severity})}}class Oo{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(4294967295*Math.random()).toString(16),this.dom=Eo(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class Do{constructor(e){this.view=e,this.items=[];this.list=hi("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t=>{if(27==t.keyCode)xo(this.view),this.view.focus();else if(38==t.keyCode||33==t.keyCode)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(40==t.keyCode||34==t.keyCode)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(36==t.keyCode)this.moveSelection(0);else if(35==t.keyCode)this.moveSelection(this.items.length-1);else if(13==t.keyCode)this.view.focus();else{if(!(t.keyCode>=65&&t.keyCode<=90&&this.selectedIndex>=0))return;{let{diagnostic:n}=this.items[this.selectedIndex],i=Ao(n.actions);for(let r=0;r<i.length;r++)if(i[r].toUpperCase().charCodeAt(0)==t.keyCode){let t=ho(this.view.state.field(yo).diagnostics,n);t&&n.actions[r].apply(e,t.from,t.to)}}}t.preventDefault()},onclick:e=>{for(let t=0;t<this.items.length;t++)this.items[t].dom.contains(e.target)&&this.moveSelection(t)}}),this.dom=hi("div",{class:"cm-panel-lint"},this.list,hi("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>xo(this.view)},"\xd7")),this.update()}get selectedIndex(){let e=this.view.state.field(yo).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(yo),n=0,i=!1,r=null;for(e.between(0,this.view.state.doc.length,((e,o,{spec:s})=>{let l,a=-1;for(let t=n;t<this.items.length;t++)if(this.items[t].diagnostic==s.diagnostic){a=t;break}a<0?(l=new Oo(this.view,s.diagnostic),this.items.splice(n,0,l),i=!0):(l=this.items[a],a>n&&(this.items.splice(n,a-n),i=!0)),t&&l.diagnostic==t.diagnostic?l.dom.hasAttribute("aria-selected")||(l.dom.setAttribute("aria-selected","true"),r=l):l.dom.hasAttribute("aria-selected")&&l.dom.removeAttribute("aria-selected"),n++}));n<this.items.length&&!(1==this.items.length&&this.items[0].diagnostic.from<0);)i=!0,this.items.pop();0==this.items.length&&(this.items.push(new Oo(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),i=!0),r?(this.list.setAttribute("aria-activedescendant",r.id),this.view.requestMeasure({key:this,read:()=>({sel:r.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{e.top<t.top?this.list.scrollTop-=t.top-e.top:e.bottom>t.bottom&&(this.list.scrollTop+=e.bottom-t.bottom)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),i&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=ho(this.view.state.field(yo).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:go.of(t)})}static open(e){return new Do(e)}}function Po(e,t='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}function Io(e){return Po(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const Bo=c.EditorView.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:Io("#d11")},".cm-lintRange-warning":{backgroundImage:Io("orange")},".cm-lintRange-info":{backgroundImage:Io("#999")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}});class To extends c.GutterMarker{constructor(e){super(),this.diagnostics=e,this.severity=e.reduce(((e,t)=>{let n=t.severity;return"error"==n||"warning"==n&&"info"==e?n:e}),"info")}toDOM(e){let t=document.createElement("div");t.className="cm-lint-marker cm-lint-marker-"+this.severity;let n=this.diagnostics,i=e.state.facet(lintGutterConfig).tooltipFilter;return i&&i(n),n.length&&(t.onmouseover=()=>function(e,t,n){function i(){let i=e.elementAtHeight(t.getBoundingClientRect().top+5-e.documentTop);e.coordsAtPos(i.from)&&e.dispatch({effects:setLintGutterTooltip.of({pos:i.from,above:!1,create:()=>({dom:wo(e,n),getCoords:()=>t.getBoundingClientRect()})})}),t.onmouseout=t.onmousemove=null,function(e,t){let n=i=>{let r=t.getBoundingClientRect();if(!(i.clientX>r.left-10&&i.clientX<r.right+10&&i.clientY>r.top-10&&i.clientY<r.bottom+10)){for(let e=i.target;e;e.parentNode)if(1==e.nodeType&&e.classList.contains("cm-tooltip-lint"))return;window.removeEventListener("mousemove",n),e.state.field(lintGutterTooltip)&&e.dispatch({effects:setLintGutterTooltip.of(null)})}};window.addEventListener("mousemove",n)}(e,t)}let{hoverTime:r}=e.state.facet(lintGutterConfig),o=setTimeout(i,r);t.onmouseout=()=>{clearTimeout(o),t.onmouseout=t.onmousemove=null},t.onmousemove=()=>{clearTimeout(o),setTimeout(i,r)}}(e,t,n)),t}}var No=function(e){void 0===e&&(e={});var t=[];!1!==e.closeBracketsKeymap&&(t=t.concat(Xr)),!1!==e.defaultKeymap&&(t=t.concat(ai)),!1!==e.searchKeymap&&(t=t.concat(rr)),!1!==e.historyKeymap&&(t=t.concat(hn)),!1!==e.foldKeymap&&(t=t.concat(nt)),!1!==e.completionKeymap&&(t=t.concat(so)),!1!==e.lintKeymap&&(t=t.concat(ko));var n=[];return!1!==e.lineNumbers&&n.push((0,c.lineNumbers)()),!1!==e.highlightActiveLineGutter&&n.push((0,c.highlightActiveLineGutter)()),!1!==e.highlightSpecialChars&&n.push((0,c.highlightSpecialChars)()),!1!==e.history&&n.push(Jt()),!1!==e.foldGutter&&n.push(function(e={}){let t=Object.assign(Object.assign({},lt),e),n=new at(t,!0),i=new at(t,!1),r=c.ViewPlugin.fromClass(class{constructor(e){this.from=e.viewport.from,this.markers=this.buildMarkers(e)}update(e){(e.docChanged||e.viewportChanged||e.startState.facet(De)!=e.state.facet(De)||e.startState.field(Ye,!1)!=e.state.field(Ye,!1)||we(e.startState)!=we(e.state)||t.foldingChanged(e))&&(this.markers=this.buildMarkers(e.view))}buildMarkers(e){let t=new a.RangeSetBuilder;for(let r of e.viewportLineBlocks){let o=Xe(e.state,r.from,r.to)?i:He(e.state,r.from,r.to)?n:null;o&&t.add(r.from,r.from,o)}return t.finish()}}),{domEventHandlers:o}=t;return[r,(0,c.gutter)({class:"cm-foldGutter",markers(e){var t;return(null===(t=e.plugin(r))||void 0===t?void 0:t.markers)||a.RangeSet.empty},initialSpacer:()=>new at(t,!1),domEventHandlers:Object.assign(Object.assign({},o),{click:(e,t,n)=>{if(o.click&&o.click(e,t,n))return!0;let i=Xe(e.state,t.from,t.to);if(i)return e.dispatch({effects:Ke.of(i)}),!0;let r=He(e.state,t.from,t.to);return!!r&&(e.dispatch({effects:Ge.of(r)}),!0)}})}),ot()]}()),!1!==e.drawSelection&&n.push((0,c.drawSelection)()),!1!==e.dropCursor&&n.push((0,c.dropCursor)()),!1!==e.allowMultipleSelections&&n.push(a.EditorState.allowMultipleSelections.of(!0)),!1!==e.indentOnInput&&n.push(a.EditorState.transactionFilter.of((e=>{if(!e.docChanged||!e.isUserEvent("input.type")&&!e.isUserEvent("input.complete"))return e;let t=e.startState.languageDataAt("indentOnInput",e.startState.selection.main.head);if(!t.length)return e;let n=e.newDoc,{head:i}=e.newSelection.main,r=n.lineAt(i);if(i>r.from+200)return e;let o=n.sliceString(r.from,i);if(!t.some((e=>e.test(o))))return e;let{state:s}=e,l=-1,a=[];for(let{head:c}of s.selection.ranges){let e=s.doc.lineAt(c);if(e.from==l)continue;l=e.from;let t=Ne(s,e.from);if(null==t)continue;let n=/^\s*/.exec(e.text)[0],i=Te(s,t);n!=i&&a.push({from:e.from,to:e.from+n.length,insert:i})}return a.length?[e,{changes:a,sequential:!0}]:e}))),!1!==e.syntaxHighlighting&&n.push(pt(yt,{fallback:!0})),!1!==e.bracketMatching&&n.push(function(e={}){return[wt.of(e),At]}()),!1!==e.closeBrackets&&n.push([Yr,Hr]),!1!==e.autocompletion&&n.push(function(e={}){return[_r,xr.of(e),Vr,lo,qr]}()),!1!==e.rectangularSelection&&n.push((0,c.rectangularSelection)()),!1!==e.crosshairCursor&&n.push((0,c.crosshairCursor)()),!1!==e.highlightActiveLine&&n.push((0,c.highlightActiveLine)()),!1!==e.highlightSelectionMatches&&n.push(function(e){let t=[Ii,Pi];return e&&t.push(Ei.of(e)),t}()),e.tabSize&&"number"===typeof e.tabSize&&n.push(Ie.of(" ".repeat(e.tabSize))),n.concat([c.keymap.of(t.flat())]).filter(Boolean)},Ro=function(e){void 0===e&&(e={});var t=[];!1!==e.defaultKeymap&&(t=t.concat(ai)),!1!==e.historyKeymap&&(t=t.concat(hn));var n=[];return!1!==e.highlightSpecialChars&&n.push((0,c.highlightSpecialChars)()),!1!==e.history&&n.push(Jt()),!1!==e.drawSelection&&n.push((0,c.drawSelection)()),!1!==e.syntaxHighlighting&&n.push(pt(yt,{fallback:!0})),n.concat([c.keymap.of(t.flat())]).filter(Boolean)},Lo=s(362),_o=function(e){return{line:e.state.doc.lineAt(e.state.selection.main.from),lineCount:e.state.doc.lines,lineBreak:e.state.lineBreak,length:e.state.doc.length,readOnly:e.state.readOnly,tabSize:e.state.tabSize,selection:e.state.selection,selectionAsSingle:e.state.selection.asSingle().main,ranges:e.state.selection.ranges,selectionCode:e.state.sliceDoc(e.state.selection.main.from,e.state.selection.main.to),selections:e.state.selection.ranges.map((function(t){return e.state.sliceDoc(t.from,t.to)})),selectedText:e.state.selection.ranges.some((function(e){return!e.empty}))}};function Fo(e){var t=e.value,n=e.selection,r=e.onChange,s=e.onStatistics,l=e.onCreateEditor,h=e.onUpdate,u=e.extensions,f=void 0===u?[]:u,d=e.autoFocus,p=e.theme,m=void 0===p?"light":p,g=e.height,y=void 0===g?"":g,v=e.minHeight,b=void 0===v?"":v,w=e.maxHeight,x=void 0===w?"":w,k=e.placeholder,S=void 0===k?"":k,C=e.width,A=void 0===C?"":C,E=e.minWidth,M=void 0===E?"":E,O=e.maxWidth,D=void 0===O?"":O,P=e.editable,I=void 0===P||P,B=e.readOnly,T=void 0!==B&&B,N=e.indentWithTab,R=void 0===N||N,L=e.basicSetup,_=void 0===L||L,F=e.root,W=e.initialState,V=o((0,i.useState)(),2),q=V[0],j=V[1],z=o((0,i.useState)(),2),U=z[0],$=z[1],H=o((0,i.useState)(),2),J=H[0],G=H[1],K=c.EditorView.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),Q=c.EditorView.theme({"&":{height:y,minHeight:b,maxHeight:x,width:A,minWidth:M,maxWidth:D}}),Y=[c.EditorView.updateListener.of((function(e){if(e.docChanged&&"function"===typeof r){var t=e.state.doc.toString();r(t,e)}s&&s(_o(e))})),Q];switch(R&&Y.unshift(c.keymap.of([ci])),_&&("boolean"===typeof _?Y.unshift(No()):Y.unshift(No(_))),S&&Y.unshift((0,c.placeholder)(S)),m){case"light":Y.push(K);break;case"dark":Y.push(Lo.oneDark);break;default:Y.push(m)}return!1===I&&Y.push(c.EditorView.editable.of(!1)),T&&Y.push(a.EditorState.readOnly.of(!0)),h&&"function"===typeof h&&Y.push(c.EditorView.updateListener.of(h)),Y=Y.concat(f),(0,i.useEffect)((function(){if(q&&!J){var e={doc:t,selection:n,extensions:Y},i=W?a.EditorState.fromJSON(W.json,e,W.fields):a.EditorState.create(e);if(G(i),!U){var r=new c.EditorView({state:i,parent:q,root:F});$(r),l&&l(r,i)}}return function(){U&&(G(void 0),$(void 0))}}),[q,J]),(0,i.useEffect)((function(){return j(e.container)}),[e.container]),(0,i.useEffect)((function(){return function(){U&&(U.destroy(),$(void 0))}}),[U]),(0,i.useEffect)((function(){d&&U&&U.focus()}),[d,U]),(0,i.useEffect)((function(){U&&U.dispatch({effects:a.StateEffect.reconfigure.of(Y)})}),[m,f,y,b,x,A,M,D,S,I,T,R,_,r,h]),(0,i.useEffect)((function(){var e=U?U.state.doc.toString():"";U&&t!==e&&U.dispatch({changes:{from:0,to:e.length,insert:t||""}})}),[t,U]),{state:J,setState:G,view:U,setView:$,container:q,setContainer:j}}var Wo=s(605),Vo=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],qo=(0,i.forwardRef)((function(r,o){var s=r.className,l=r.value,a=void 0===l?"":l,c=r.selection,h=r.extensions,u=void 0===h?[]:h,f=r.onChange,d=r.onStatistics,p=r.onCreateEditor,m=r.onUpdate,g=r.autoFocus,y=r.theme,v=void 0===y?"light":y,b=r.height,w=r.minHeight,x=r.maxHeight,k=r.width,S=r.minWidth,C=r.maxWidth,A=r.basicSetup,E=r.placeholder,M=r.indentWithTab,O=r.editable,D=r.readOnly,P=r.root,I=r.initialState,B=n(r,Vo),T=(0,i.useRef)(null),N=Fo({container:T.current,root:P,value:a,autoFocus:g,theme:v,height:b,minHeight:w,maxHeight:x,width:k,minWidth:S,maxWidth:C,basicSetup:A,placeholder:E,indentWithTab:M,editable:O,readOnly:D,selection:c,onChange:f,onStatistics:d,onCreateEditor:p,onUpdate:m,extensions:u,initialState:I}),R=N.state,L=N.view,_=N.container;N.setContainer;if((0,i.useImperativeHandle)(o,(function(){return{editor:T.current,state:R,view:L}}),[T,_,R,L]),"string"!==typeof a)throw new Error("value must be typeof string but got ".concat(typeof a));var F="string"===typeof v?"cm-theme-".concat(v):"cm-theme";return(0,Wo.jsx)("div",function(n){for(var i=1;i<arguments.length;i++){var r=null!=arguments[i]?arguments[i]:{};i%2?t(Object(r),!0).forEach((function(t){e(n,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(r)):t(Object(r)).forEach((function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(r,e))}))}return n}({ref:T,className:"".concat(F).concat(s?" ".concat(s):"")},B))}));qo.displayName="CodeMirror";const jo=qo})(),l})()));
|
|
2
|
+
!function(e,t){"object"===typeof exports&&"object"===typeof module?module.exports=t(require("react"),require("@codemirror/state"),require("@codemirror/theme-one-dark"),require("@codemirror/view")):"function"===typeof define&&define.amd?define(["react",,,],t):"object"===typeof exports?exports["@uiw/codemirror"]=t(require("react"),require("@codemirror/state"),require("@codemirror/theme-one-dark"),require("@codemirror/view")):e["@uiw/codemirror"]=t(e.React,e.CM["@codemirror/state"],e.CM["@codemirror/theme-one-dark"],e.CM["@codemirror/view"])}(self,((e,t,n,i)=>(()=>{"use strict";var r={298:(e,t,n)=>{var i=n(787),r=Symbol.for("react.element"),o=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,l=i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,n){var i,o={},c=null,h=null;for(i in void 0!==n&&(c=""+n),void 0!==t.key&&(c=""+t.key),void 0!==t.ref&&(h=t.ref),t)s.call(t,i)&&!a.hasOwnProperty(i)&&(o[i]=t[i]);if(e&&e.defaultProps)for(i in t=e.defaultProps)void 0===o[i]&&(o[i]=t[i]);return{$$typeof:r,type:e,key:c,ref:h,props:o,_owner:l.current}}t.jsx=c},605:(e,t,n)=>{e.exports=n(298)},787:t=>{t.exports=e},242:e=>{e.exports=t},362:e=>{e.exports=n},105:e=>{e.exports=i}},o={};function s(e){var t=o[e];if(void 0!==t)return t.exports;var n=o[e]={exports:{}};return r[e](n,n.exports,s),n.exports}s.d=(e,t)=>{for(var n in t)s.o(t,n)&&!s.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),s.r=e=>{"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var l={};return(()=>{function e(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function t(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function n(e,t){if(null==e)return{};var n,i,r=function(e,t){if(null==e)return{};var n,i,r={},o=Object.keys(e);for(i=0;i<o.length;i++)n=o[i],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(i=0;i<o.length;i++)n=o[i],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}s.r(l),s.d(l,{basicSetup:()=>Ro,default:()=>zo,getStatistics:()=>Fo,minimalSetup:()=>Lo,useCodeMirror:()=>Wo});var i=s(787);function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function o(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!==typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var i,r,o=[],s=!0,l=!1;try{for(n=n.call(e);!(s=(i=n.next()).done)&&(o.push(i.value),!t||o.length!==t);s=!0);}catch(a){l=!0,r=a}finally{try{s||null==n.return||n.return()}finally{if(l)throw r}}return o}}(e,t)||function(e,t){if(e){if("string"===typeof e)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var a=s(242),c=s(105);const h=1024;let u=0;class f{constructor(e,t){this.from=e,this.to=t}}class d{constructor(e={}){this.id=u++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof e&&(e=m.match(e)),t=>{let n=e(t);return void 0===n?null:[this,n]}}}d.closedBy=new d({deserialize:e=>e.split(" ")}),d.openedBy=new d({deserialize:e=>e.split(" ")}),d.group=new d({deserialize:e=>e.split(" ")}),d.contextHash=new d({perNode:!0}),d.lookAhead=new d({perNode:!0}),d.mounted=new d({perNode:!0});const p=Object.create(null);class m{constructor(e,t,n,i=0){this.name=e,this.props=t,this.id=n,this.flags=i}static define(e){let t=e.props&&e.props.length?Object.create(null):p,n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(null==e.name?8:0),i=new m(e.name||"",t,e.id,n);if(e.props)for(let r of e.props)if(Array.isArray(r)||(r=r(i)),r){if(r[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[r[0].id]=r[1]}return i}prop(e){return this.props[e.id]}get isTop(){return(1&this.flags)>0}get isSkipped(){return(2&this.flags)>0}get isError(){return(4&this.flags)>0}get isAnonymous(){return(8&this.flags)>0}is(e){if("string"==typeof e){if(this.name==e)return!0;let t=this.prop(d.group);return!!t&&t.indexOf(e)>-1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let i of n.split(" "))t[i]=e[n];return e=>{for(let n=e.prop(d.group),i=-1;i<(n?n.length:0);i++){let r=t[i<0?e.name:n[i]];if(r)return r}}}}m.none=new m("",Object.create(null),0,8);const g=new WeakMap,y=new WeakMap;var v;!function(e){e[e.ExcludeBuffers=1]="ExcludeBuffers",e[e.IncludeAnonymous=2]="IncludeAnonymous",e[e.IgnoreMounts=4]="IgnoreMounts",e[e.IgnoreOverlays=8]="IgnoreOverlays"}(v||(v={}));class b{constructor(e,t,n,i,r){if(this.type=e,this.children=t,this.positions=n,this.length=i,this.props=null,r&&r.length){this.props=Object.create(null);for(let[e,t]of r)this.props["number"==typeof e?e:e.id]=t}}toString(){let e=this.prop(d.mounted);if(e&&!e.overlay)return e.tree.toString();let t="";for(let n of this.children){let e=n.toString();e&&(t&&(t+=","),t+=e)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new P(this.topNode,e)}cursorAt(e,t=0,n=0){let i=g.get(this)||this.topNode,r=new P(i);return r.moveTo(e,t),g.set(this,r._tree),r}get topNode(){return new A(this,0,0,null)}resolve(e,t=0){let n=C(g.get(this)||this.topNode,e,t,!1);return g.set(this,n),n}resolveInner(e,t=0){let n=C(y.get(this)||this.topNode,e,t,!0);return y.set(this,n),n}iterate(e){let{enter:t,leave:n,from:i=0,to:r=this.length}=e;for(let o=this.cursor((e.mode||0)|v.IncludeAnonymous);;){let e=!1;if(o.from<=r&&o.to>=i&&(o.type.isAnonymous||!1!==t(o))){if(o.firstChild())continue;e=!0}for(;e&&n&&!o.type.isAnonymous&&n(o),!o.nextSibling();){if(!o.parent())return;e=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:N(m.none,this.children,this.positions,0,this.children.length,0,this.length,((e,t,n)=>new b(this.type,e,t,n,this.propValues)),e.makeTree||((e,t,n)=>new b(m.none,e,t,n)))}static build(e){return function(e){var t;let{buffer:n,nodeSet:i,maxBufferLength:r=h,reused:o=[],minRepeatType:s=i.types.length}=e,l=Array.isArray(n)?new w(n,n.length):n,a=i.types,c=0,u=0;function f(e,t,n,h,d){let{id:b,start:w,end:k,size:S}=l,C=u;for(;S<0;){if(l.next(),-1==S){let t=o[b];return n.push(t),void h.push(w-e)}if(-3==S)return void(c=b);if(-4==S)return void(u=b);throw new RangeError(`Unrecognized record size: ${S}`)}let A,E,O=a[b],D=w-e;if(k-w<=r&&(E=y(l.pos-t,d))){let t=new Uint16Array(E.size-E.skip),n=l.pos-E.size,r=t.length;for(;l.pos>n;)r=v(E.start,t,r);A=new x(t,k-E.start,i),D=E.start-e}else{let e=l.pos-S;l.next();let t=[],n=[],i=b>=s?b:-1,o=0,a=k;for(;l.pos>e;)i>=0&&l.id==i&&l.size>=0?(l.end<=a-r&&(m(t,n,w,o,l.end,a,i,C),o=t.length,a=l.end),l.next()):f(w,e,t,n,i);if(i>=0&&o>0&&o<t.length&&m(t,n,w,o,w,a,i,C),t.reverse(),n.reverse(),i>-1&&o>0){let e=p(O);A=N(O,t,n,0,t.length,0,k-w,e,e)}else A=g(O,t,n,k-w,C-k)}n.push(A),h.push(D)}function p(e){return(t,n,i)=>{let r,o,s=0,l=t.length-1;if(l>=0&&(r=t[l])instanceof b){if(!l&&r.type==e&&r.length==i)return r;(o=r.prop(d.lookAhead))&&(s=n[l]+r.length+o)}return g(e,t,n,i,s)}}function m(e,t,n,r,o,s,l,a){let c=[],h=[];for(;e.length>r;)c.push(e.pop()),h.push(t.pop()+n-o);e.push(g(i.types[l],c,h,s-o,a-s)),t.push(o-n)}function g(e,t,n,i,r=0,o){if(c){let e=[d.contextHash,c];o=o?[e].concat(o):[e]}if(r>25){let e=[d.lookAhead,r];o=o?[e].concat(o):[e]}return new b(e,t,n,i,o)}function y(e,t){let n=l.fork(),i=0,o=0,a=0,c=n.end-r,h={size:0,start:0,skip:0};e:for(let r=n.pos-e;n.pos>r;){let e=n.size;if(n.id==t&&e>=0){h.size=i,h.start=o,h.skip=a,a+=4,i+=4,n.next();continue}let l=n.pos-e;if(e<0||l<r||n.start<c)break;let u=n.id>=s?4:0,f=n.start;for(n.next();n.pos>l;){if(n.size<0){if(-3!=n.size)break e;u+=4}else n.id>=s&&(u+=4);n.next()}o=f,i+=e,a+=u}return(t<0||i==e)&&(h.size=i,h.start=o,h.skip=a),h.size>4?h:void 0}function v(e,t,n){let{id:i,start:r,end:o,size:a}=l;if(l.next(),a>=0&&i<s){let s=n;if(a>4){let i=l.pos-(a-4);for(;l.pos>i;)n=v(e,t,n)}t[--n]=s,t[--n]=o-e,t[--n]=r-e,t[--n]=i}else-3==a?c=i:-4==a&&(u=i);return n}let k=[],S=[];for(;l.pos>0;)f(e.start||0,e.bufferStart||0,k,S,-1);let C=null!==(t=e.length)&&void 0!==t?t:k.length?S[0]+k[0].length:0;return new b(a[e.topID],k.reverse(),S.reverse(),C)}(e)}}b.empty=new b(m.none,[],[],0);class w{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new w(this.buffer,this.index)}}class x{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return m.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],n=this.buffer[e+3],i=this.set.types[t],r=i.name;if(/\W/.test(r)&&!i.isError&&(r=JSON.stringify(r)),n==(e+=4))return r;let o=[];for(;e<n;)o.push(this.childString(e)),e=this.buffer[e+3];return r+"("+o.join(",")+")"}findChild(e,t,n,i,r){let{buffer:o}=this,s=-1;for(let l=e;l!=t&&!(k(r,i,o[l+1],o[l+2])&&(s=l,n>0));l=o[l+3]);return s}slice(e,t,n,i){let r=this.buffer,o=new Uint16Array(t-e);for(let s=e,l=0;s<t;)o[l++]=r[s++],o[l++]=r[s++]-n,o[l++]=r[s++]-n,o[l++]=r[s++]-e;return new x(o,i-n,this.set)}}function k(e,t,n,i){switch(e){case-2:return n<t;case-1:return i>=t&&n<t;case 0:return n<t&&i>t;case 1:return n<=t&&i>t;case 2:return i>t;case 4:return!0}}function S(e,t){let n=e.childBefore(t);for(;n;){let t=n.lastChild;if(!t||t.to!=n.to)break;t.type.isError&&t.from==t.to?(e=n,n=t.prevSibling):n=t}return e}function C(e,t,n,i){for(var r;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to<t);){let t=!i&&e instanceof A&&e.index<0?null:e.parent;if(!t)return e;e=t}let o=i?0:v.IgnoreOverlays;if(i)for(let s=e,l=s.parent;l;s=l,l=s.parent)s instanceof A&&s.index<0&&(null===(r=l.enter(t,n,o))||void 0===r?void 0:r.from)!=s.from&&(e=l);for(;;){let i=e.enter(t,n,o);if(!i)return e;e=i}}class A{constructor(e,t,n,i){this._tree=e,this.from=t,this.index=n,this._parent=i}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,n,i,r=0){for(let o=this;;){for(let{children:s,positions:l}=o._tree,a=t>0?s.length:-1;e!=a;e+=t){let a=s[e],c=l[e]+o.from;if(k(i,n,c,c+a.length))if(a instanceof x){if(r&v.ExcludeBuffers)continue;let s=a.findChild(0,a.buffer.length,t,n-c,i);if(s>-1)return new M(new D(o,a,e,c),null,s)}else if(r&v.IncludeAnonymous||!a.type.isAnonymous||I(a)){let s;if(!(r&v.IgnoreMounts)&&a.props&&(s=a.prop(d.mounted))&&!s.overlay)return new A(s.tree,c,e,o);let l=new A(a,c,e,o);return r&v.IncludeAnonymous||!l.type.isAnonymous?l:l.nextChild(t<0?a.children.length-1:0,t,n,i)}}if(r&v.IncludeAnonymous||!o.type.isAnonymous)return null;if(e=o.index>=0?o.index+t:t<0?-1:o._parent._tree.children.length,o=o._parent,!o)return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}enter(e,t,n=0){let i;if(!(n&v.IgnoreOverlays)&&(i=this._tree.prop(d.mounted))&&i.overlay){let n=e-this.from;for(let{from:e,to:r}of i.overlay)if((t>0?e<=n:e<n)&&(t<0?r>=n:r>n))return new A(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,n)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}cursor(e=0){return new P(this,e)}get tree(){return this._tree}toTree(){return this._tree}resolve(e,t=0){return C(this,e,t,!1)}resolveInner(e,t=0){return C(this,e,t,!0)}enterUnfinishedNodesBefore(e){return S(this,e)}getChild(e,t=null,n=null){let i=E(this,e,t,n);return i.length?i[0]:null}getChildren(e,t=null,n=null){return E(this,e,t,n)}toString(){return this._tree.toString()}get node(){return this}matchContext(e){return O(this,e)}}function E(e,t,n,i){let r=e.cursor(),o=[];if(!r.firstChild())return o;if(null!=n)for(;!r.type.is(n);)if(!r.nextSibling())return o;for(;;){if(null!=i&&r.type.is(i))return o;if(r.type.is(t)&&o.push(r.node),!r.nextSibling())return null==i?o:[]}}function O(e,t,n=t.length-1){for(let i=e.parent;n>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(t[n]&&t[n]!=i.name)return!1;n--}}return!0}class D{constructor(e,t,n,i){this.parent=e,this.buffer=t,this.index=n,this.start=i}}class M{constructor(e,t,n){this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}child(e,t,n){let{buffer:i}=this.context,r=i.findChild(this.index+4,i.buffer[this.index+3],e,t-this.context.start,n);return r<0?null:new M(this.context,this,r)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}enter(e,t,n=0){if(n&v.ExcludeBuffers)return null;let{buffer:i}=this.context,r=i.findChild(this.index+4,i.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return r<0?null:new M(this.context,this,r)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new M(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new M(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}cursor(e=0){return new P(this,e)}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,i=this.index+4,r=n.buffer[this.index+3];if(r>i){let o=n.buffer[this.index+1],s=n.buffer[this.index+2];e.push(n.slice(i,r,o,s)),t.push(0)}return new b(this.type,e,t,this.to-this.from)}resolve(e,t=0){return C(this,e,t,!1)}resolveInner(e,t=0){return C(this,e,t,!0)}enterUnfinishedNodesBefore(e){return S(this,e)}toString(){return this.context.buffer.childString(this.index)}getChild(e,t=null,n=null){let i=E(this,e,t,n);return i.length?i[0]:null}getChildren(e,t=null,n=null){return E(this,e,t,n)}get node(){return this}matchContext(e){return O(this,e)}}class P{constructor(e,t=0){if(this.mode=t,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof A)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.index);this.bufferNode=e,this.yieldBuf(e.index)}}get name(){return this.type.name}yieldNode(e){return!!e&&(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0)}yieldBuf(e,t){this.index=e;let{start:n,buffer:i}=this.buffer;return this.type=t||i.set.types[i.buffer[e]],this.from=n+i.buffer[e+1],this.to=n+i.buffer[e+2],!0}yield(e){return!!e&&(e instanceof A?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)))}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:i}=this.buffer,r=i.findChild(this.index+4,i.buffer[this.index+3],e,t-this.buffer.start,n);return!(r<0)&&(this.stack.push(this.index),this.yieldBuf(r))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,n=this.mode){return this.buffer?!(n&v.ExcludeBuffers)&&this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&v.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&v.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return!!this._tree._parent&&this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode));let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let e=n<0?0:this.stack[n]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(e)}return n<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:i}=this;if(i){if(e>0){if(this.index<i.buffer.buffer.length)return!1}else for(let e=0;e<this.index;e++)if(i.buffer.buffer[e+3]<this.index)return!1;({index:t,parent:n}=i)}else({index:t,_parent:n}=this._tree);for(;n;({index:t,_parent:n}=n))if(t>-1)for(let i=t+e,r=e<0?-1:n._tree.children.length;i!=r;i+=e){let e=n._tree.children[i];if(this.mode&v.IncludeAnonymous||e instanceof x||!e.type.isAnonymous||I(e))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,n=0;if(e&&e.context==this.buffer)e:for(let i=this.index,r=this.stack.length;r>=0;){for(let o=e;o;o=o._parent)if(o.index==i){if(i==this.index)return o;t=o,n=r+1;break e}i=this.stack[--r]}for(let i=n;i<this.stack.length;i++)t=new M(this.buffer,t,this.stack[i]);return this.bufferNode=new M(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let i=!1;if(this.type.isAnonymous||!1!==e(this)){if(this.firstChild()){n++;continue}this.type.isAnonymous||(i=!0)}for(;i&&t&&t(this),i=this.type.isAnonymous,!this.nextSibling();){if(!n)return;this.parent(),n--,i=!0}}}matchContext(e){if(!this.buffer)return O(this.node,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let i=e.length-1,r=this.stack.length-1;i>=0;r--){if(r<0)return O(this.node,e,i);let o=n[t.buffer[this.stack[r]]];if(!o.isAnonymous){if(e[i]&&e[i]!=o.name)return!1;i--}}return!0}}function I(e){return e.children.some((e=>e instanceof x||!e.type.isAnonymous||I(e)))}const B=new WeakMap;function T(e,t){if(!e.isAnonymous||t instanceof x||t.type!=e)return 1;let n=B.get(t);if(null==n){n=1;for(let i of t.children){if(i.type!=e||!(i instanceof b)){n=1;break}n+=T(e,i)}B.set(t,n)}return n}function N(e,t,n,i,r,o,s,l,a){let c=0;for(let d=i;d<r;d++)c+=T(e,t[d]);let h=Math.ceil(1.5*c/8),u=[],f=[];return function t(n,i,r,s,l){for(let c=r;c<s;){let r=c,d=i[c],p=T(e,n[c]);for(c++;c<s;c++){let t=T(e,n[c]);if(p+t>=h)break;p+=t}if(c==r+1){if(p>h){let e=n[r];t(e.children,e.positions,0,e.children.length,i[r]+l);continue}u.push(n[r])}else{let t=i[c-1]+n[c-1].length-d;u.push(N(e,n,i,r,c,d,t,null,a))}f.push(d+l-o)}}(t,n,i,r,0),(l||a)(u,f,s)}class R{constructor(e,t,n,i,r=!1,o=!1){this.from=e,this.to=t,this.tree=n,this.offset=i,this.open=(r?1:0)|(o?2:0)}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(e,t=[],n=!1){let i=[new R(0,e.length,e,0,!1,n)];for(let r of t)r.to>e.length&&i.push(r);return i}static applyChanges(e,t,n=128){if(!t.length)return e;let i=[],r=1,o=e.length?e[0]:null;for(let s=0,l=0,a=0;;s++){let c=s<t.length?t[s]:null,h=c?c.fromA:1e9;if(h-l>=n)for(;o&&o.from<h;){let t=o;if(l>=t.from||h<=t.to||a){let e=Math.max(t.from,l)-a,n=Math.min(t.to,h)-a;t=e>=n?null:new R(e,n,t.tree,t.offset+a,s>0,!!c)}if(t&&i.push(t),o.to>h)break;o=r<e.length?e[r++]:null}if(!c)break;l=c.toA,a=c.toA-c.toB}return i}}class L{startParse(e,t,n){return"string"==typeof e&&(e=new _(e)),n=n?n.length?n.map((e=>new f(e.from,e.to))):[new f(0,0)]:[new f(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let i=this.startParse(e,t,n);for(;;){let e=i.advance();if(e)return e}}}class _{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}new d({perNode:!0});let F=0;class W{constructor(e,t,n){this.set=e,this.base=t,this.modified=n,this.id=F++}static define(e){if(null===e||void 0===e?void 0:e.base)throw new Error("Can not derive from a modified tag");let t=new W([],null,[]);if(t.set.push(t),e)for(let n of e.set)t.set.push(n);return t}static defineModifier(){let e=new j;return t=>t.modified.indexOf(e)>-1?t:j.get(t.base||t,t.modified.concat(e).sort(((e,t)=>e.id-t.id)))}}let V=0;class j{constructor(){this.instances=[],this.id=V++}static get(e,t){if(!t.length)return e;let n=t[0].instances.find((n=>{return n.base==e&&(i=t,r=n.modified,i.length==r.length&&i.every(((e,t)=>e==r[t])));var i,r}));if(n)return n;let i=[],r=new W(i,e,t);for(let s of t)s.instances.push(r);let o=function(e){let t=[[]];for(let n=0;n<e.length;n++)for(let i=0,r=t.length;i<r;i++)t.push(t[i].concat(e[n]));return t.sort(((e,t)=>t.length-e.length))}(t);for(let s of e.set)if(!s.modified.length)for(let e of o)i.push(j.get(s,e));return r}}function q(e){let t=Object.create(null);for(let n in e){let i=e[n];Array.isArray(i)||(i=[i]);for(let e of n.split(" "))if(e){let n=[],r=2,o=e;for(let t=0;;){if("..."==o&&t>0&&t+3==e.length){r=1;break}let i=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(o);if(!i)throw new RangeError("Invalid path: "+e);if(n.push("*"==i[0]?"":'"'==i[0][0]?JSON.parse(i[0]):i[0]),t+=i[0].length,t==e.length)break;let s=e[t++];if(t==e.length&&"!"==s){r=0;break}if("/"!=s)throw new RangeError("Invalid path: "+e);o=e.slice(t)}let s=n.length-1,l=n[s];if(!l)throw new RangeError("Invalid path: "+e);let a=new U(i,r,s>0?n.slice(0,s):null);t[l]=a.sort(t[l])}}return z.add(t)}const z=new d;class U{constructor(e,t,n,i){this.tags=e,this.mode=t,this.context=n,this.next=i}get opaque(){return 0==this.mode}get inherit(){return 1==this.mode}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}function $(e,t){let n=Object.create(null);for(let o of e)if(Array.isArray(o.tag))for(let e of o.tag)n[e.id]=o.class;else n[o.tag.id]=o.class;let{scope:i,all:r=null}=t||{};return{style:e=>{let t=r;for(let i of e)for(let e of i.set){let i=n[e.id];if(i){t=t?t+" "+i:i;break}}return t},scope:i}}function H(e,t,n,i=0,r=e.length){let o=new J(i,Array.isArray(t)?t:[t],n);o.highlightRange(e.cursor(),i,r,"",o.highlighters),o.flush(r)}U.empty=new U([],2,null);class J{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,n,i,r){let{type:o,from:s,to:l}=e;if(s>=n||l<=t)return;o.isTop&&(r=this.highlighters.filter((e=>!e.scope||e.scope(o))));let a=i,c=function(e){let t=e.type.prop(z);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}(e)||U.empty,h=function(e,t){let n=null;for(let i of e){let e=i.style(t);e&&(n=n?n+" "+e:e)}return n}(r,c.tags);if(h&&(a&&(a+=" "),a+=h,1==c.mode&&(i+=(i?" ":"")+h)),this.startSpan(e.from,a),c.opaque)return;let u=e.tree&&e.tree.prop(d.mounted);if(u&&u.overlay){let o=e.node.enter(u.overlay[0].from+s,1),c=this.highlighters.filter((e=>!e.scope||e.scope(u.tree.type))),h=e.firstChild();for(let f=0,d=s;;f++){let p=f<u.overlay.length?u.overlay[f]:null,m=p?p.from+s:l,g=Math.max(t,d),y=Math.min(n,m);if(g<y&&h)for(;e.from<y&&(this.highlightRange(e,g,y,i,r),this.startSpan(Math.min(n,e.to),a),!(e.to>=m)&&e.nextSibling()););if(!p||m>n)break;d=p.to+s,d>t&&(this.highlightRange(o.cursor(),Math.max(t,p.from+s),Math.min(n,d),i,c),this.startSpan(d,a))}h&&e.parent()}else if(e.firstChild()){do{if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,i,r),this.startSpan(Math.min(n,e.to),a)}}while(e.nextSibling());e.parent()}}}const G=W.define,K=G(),Q=G(),Y=G(Q),X=G(Q),Z=G(),ee=G(Z),te=G(Z),ne=G(),ie=G(ne),re=G(),oe=G(),se=G(),le=G(se),ae=G(),ce={comment:K,lineComment:G(K),blockComment:G(K),docComment:G(K),name:Q,variableName:G(Q),typeName:Y,tagName:G(Y),propertyName:X,attributeName:G(X),className:G(Q),labelName:G(Q),namespace:G(Q),macroName:G(Q),literal:Z,string:ee,docString:G(ee),character:G(ee),attributeValue:G(ee),number:te,integer:G(te),float:G(te),bool:G(Z),regexp:G(Z),escape:G(Z),color:G(Z),url:G(Z),keyword:re,self:G(re),null:G(re),atom:G(re),unit:G(re),modifier:G(re),operatorKeyword:G(re),controlKeyword:G(re),definitionKeyword:G(re),moduleKeyword:G(re),operator:oe,derefOperator:G(oe),arithmeticOperator:G(oe),logicOperator:G(oe),bitwiseOperator:G(oe),compareOperator:G(oe),updateOperator:G(oe),definitionOperator:G(oe),typeOperator:G(oe),controlOperator:G(oe),punctuation:se,separator:G(se),bracket:le,angleBracket:G(le),squareBracket:G(le),paren:G(le),brace:G(le),content:ne,heading:ie,heading1:G(ie),heading2:G(ie),heading3:G(ie),heading4:G(ie),heading5:G(ie),heading6:G(ie),contentSeparator:G(ne),list:G(ne),quote:G(ne),emphasis:G(ne),strong:G(ne),link:G(ne),monospace:G(ne),strikethrough:G(ne),inserted:G(),deleted:G(),changed:G(),invalid:G(),meta:ae,documentMeta:G(ae),annotation:G(ae),processingInstruction:G(ae),definition:W.defineModifier(),constant:W.defineModifier(),function:W.defineModifier(),standard:W.defineModifier(),local:W.defineModifier(),special:W.defineModifier()},he=($([{tag:ce.link,class:"tok-link"},{tag:ce.heading,class:"tok-heading"},{tag:ce.emphasis,class:"tok-emphasis"},{tag:ce.strong,class:"tok-strong"},{tag:ce.keyword,class:"tok-keyword"},{tag:ce.atom,class:"tok-atom"},{tag:ce.bool,class:"tok-bool"},{tag:ce.url,class:"tok-url"},{tag:ce.labelName,class:"tok-labelName"},{tag:ce.inserted,class:"tok-inserted"},{tag:ce.deleted,class:"tok-deleted"},{tag:ce.literal,class:"tok-literal"},{tag:ce.string,class:"tok-string"},{tag:ce.number,class:"tok-number"},{tag:[ce.regexp,ce.escape,ce.special(ce.string)],class:"tok-string2"},{tag:ce.variableName,class:"tok-variableName"},{tag:ce.local(ce.variableName),class:"tok-variableName tok-local"},{tag:ce.definition(ce.variableName),class:"tok-variableName tok-definition"},{tag:ce.special(ce.variableName),class:"tok-variableName2"},{tag:ce.definition(ce.propertyName),class:"tok-propertyName tok-definition"},{tag:ce.typeName,class:"tok-typeName"},{tag:ce.namespace,class:"tok-namespace"},{tag:ce.className,class:"tok-className"},{tag:ce.macroName,class:"tok-macroName"},{tag:ce.propertyName,class:"tok-propertyName"},{tag:ce.operator,class:"tok-operator"},{tag:ce.comment,class:"tok-comment"},{tag:ce.meta,class:"tok-meta"},{tag:ce.invalid,class:"tok-invalid"},{tag:ce.punctuation,class:"tok-punctuation"}]),"undefined"==typeof Symbol?"__\u037c":Symbol.for("\u037c")),ue="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),fe="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class de{constructor(e,t){this.rules=[];let{finish:n}=t||{};function i(e){return/^@/.test(e)?[e]:e.split(/,\s*/)}function r(e,t,o,s){let l=[],a=/^@(\w+)\b/.exec(e[0]),c=a&&"keyframes"==a[1];if(a&&null==t)return o.push(e[0]+";");for(let n in t){let s=t[n];if(/&/.test(n))r(n.split(/,\s*/).map((t=>e.map((e=>t.replace(/&/,e))))).reduce(((e,t)=>e.concat(t))),s,o);else if(s&&"object"==typeof s){if(!a)throw new RangeError("The value of a property ("+n+") should be a primitive value.");r(i(n),s,l,c)}else null!=s&&l.push(n.replace(/_.*/,"").replace(/[A-Z]/g,(e=>"-"+e.toLowerCase()))+": "+s+";")}(l.length||c)&&o.push((!n||a||s?e:e.map(n)).join(", ")+" {"+l.join(" ")+"}")}for(let o in e)r(i(o),e[o],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let e=fe[he]||1;return fe[he]=e+1,"\u037c"+e.toString(36)}static mount(e,t){(e[ue]||new me(e)).mount(Array.isArray(t)?t:[t])}}let pe=null;class me{constructor(e){if(!e.head&&e.adoptedStyleSheets&&"undefined"!=typeof CSSStyleSheet){if(pe)return e.adoptedStyleSheets=[pe.sheet].concat(e.adoptedStyleSheets),e[ue]=pe;this.sheet=new CSSStyleSheet,e.adoptedStyleSheets=[this.sheet].concat(e.adoptedStyleSheets),pe=this}else{this.styleTag=(e.ownerDocument||e).createElement("style");let t=e.head||e;t.insertBefore(this.styleTag,t.firstChild)}this.modules=[],e[ue]=this}mount(e){let t=this.sheet,n=0,i=0;for(let r=0;r<e.length;r++){let o=e[r],s=this.modules.indexOf(o);if(s<i&&s>-1&&(this.modules.splice(s,1),i--,s=-1),-1==s){if(this.modules.splice(i++,0,o),t)for(let e=0;e<o.rules.length;e++)t.insertRule(o.rules[e],n++)}else{for(;i<s;)n+=this.modules[i++].rules.length;n+=o.rules.length,i++}}if(!t){let e="";for(let t=0;t<this.modules.length;t++)e+=this.modules[t].getRules()+"\n";this.styleTag.textContent=e}}}var ge;const ye=new d;class ve{constructor(e,t,n=[],i=""){this.data=e,this.name=i,a.EditorState.prototype.hasOwnProperty("tree")||Object.defineProperty(a.EditorState.prototype,"tree",{get(){return we(this)}}),this.parser=t,this.extension=[Me.of(this),a.EditorState.languageData.of(((e,t,n)=>e.facet(be(e,t,n))))].concat(n)}isActiveAt(e,t,n=-1){return be(e,t,n)==this.data}findRegions(e){let t=e.facet(Me);if((null===t||void 0===t?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],i=(e,t)=>{if(e.prop(ye)==this.data)return void n.push({from:t,to:t+e.length});let r=e.prop(d.mounted);if(r){if(r.tree.prop(ye)==this.data){if(r.overlay)for(let e of r.overlay)n.push({from:e.from+t,to:e.to+t});else n.push({from:t,to:t+e.length});return}if(r.overlay){let e=n.length;if(i(r.tree,r.overlay[0].from+t),n.length>e)return}}for(let n=0;n<e.children.length;n++){let r=e.children[n];r instanceof b&&i(r,e.positions[n]+t)}};return i(we(e),0),n}get allowsNesting(){return!0}}function be(e,t,n){let i=e.facet(Me);if(!i)return null;let r=i.data;if(i.allowsNesting)for(let o=we(e).topNode;o;o=o.enter(t,n,v.ExcludeBuffers))r=o.type.prop(ye)||r;return r}ve.setState=a.StateEffect.define();function we(e){let t=e.field(ve.state,!1);return t?t.tree:b.empty}class xe{constructor(e,t=e.length){this.doc=e,this.length=t,this.cursorPos=0,this.string="",this.cursor=e.iter()}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let n=this.cursorPos-this.string.length;return e<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}}let ke=null;class Se{constructor(e,t,n=[],i,r,o,s,l){this.parser=e,this.state=t,this.fragments=n,this.tree=i,this.treeLen=r,this.viewport=o,this.skipped=s,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(e,t,n){return new Se(e,t,[],b.empty,0,n,[],null)}startParse(){return this.parser.startParse(new xe(this.state.doc),this.fragments)}work(e,t){return null!=t&&t>=this.state.doc.length&&(t=void 0),this.tree!=b.empty&&this.isDone(null!==t&&void 0!==t?t:this.state.doc.length)?(this.takeTree(),!0):this.withContext((()=>{var n;if("number"==typeof e){let t=Date.now()+e;e=()=>Date.now()>t}for(this.parse||(this.parse=this.startParse()),null!=t&&(null==this.parse.stoppedAt||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let i=this.parse.advance();if(i){if(this.fragments=this.withoutTempSkipped(R.addTree(i,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!==(n=this.parse.stoppedAt)&&void 0!==n?n:this.state.doc.length,this.tree=i,this.parse=null,!(this.treeLen<(null!==t&&void 0!==t?t:this.state.doc.length)))return!0;this.parse=this.startParse()}if(e())return!1}}))}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((null==this.parse.stoppedAt||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext((()=>{for(;!(t=this.parse.advance()););})),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(R.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=ke;ke=this;try{return e()}finally{ke=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=Ce(e,t.from,t.to);return e}changes(e,t){let{fragments:n,tree:i,treeLen:r,viewport:o,skipped:s}=this;if(this.takeTree(),!e.empty){let t=[];if(e.iterChangedRanges(((e,n,i,r)=>t.push({fromA:e,toA:n,fromB:i,toB:r}))),n=R.applyChanges(n,t),i=b.empty,r=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){s=[];for(let t of this.skipped){let n=e.mapPos(t.from,1),i=e.mapPos(t.to,-1);n<i&&s.push({from:n,to:i})}}}return new Se(this.parser,t,n,i,r,o,s,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let n=0;n<this.skipped.length;n++){let{from:t,to:i}=this.skipped[n];t<e.to&&i>e.from&&(this.fragments=Ce(this.fragments,t,i),this.skipped.splice(n--,1))}return!(this.skipped.length>=t)&&(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends L{createParse(t,n,i){let r=i[0].from,o=i[i.length-1].to;return{parsedPos:r,advance(){let t=ke;if(t){for(let e of i)t.tempSkipped.push(e);e&&(t.scheduleOn=t.scheduleOn?Promise.all([t.scheduleOn,e]):e)}return this.parsedPos=o,new b(m.none,[],[],o-r)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&0==t[0].from&&t[0].to>=e}static get(){return ke}}function Ce(e,t,n){return R.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}class Ae{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),n=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,n)||t.takeTree(),new Ae(t)}static init(e){let t=Math.min(3e3,e.doc.length),n=Se.create(e.facet(Me).parser,e,{from:0,to:t});return n.work(20,t)||n.takeTree(),new Ae(n)}}ve.state=a.StateField.define({create:Ae.init,update(e,t){for(let n of t.effects)if(n.is(ve.setState))return n.value;return t.startState.facet(Me)!=t.state.facet(Me)?Ae.init(t.state):e.apply(t)}});let Ee=e=>{let t=setTimeout((()=>e()),500);return()=>clearTimeout(t)};"undefined"!=typeof requestIdleCallback&&(Ee=e=>{let t=-1,n=setTimeout((()=>{t=requestIdleCallback(e,{timeout:400})}),100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});const Oe="undefined"!=typeof navigator&&(null===(ge=navigator.scheduling)||void 0===ge?void 0:ge.isInputPending)?()=>navigator.scheduling.isInputPending():null,De=c.ViewPlugin.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(ve.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),e.docChanged&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(ve.state);t.tree==t.context.tree&&t.context.isDone(e.doc.length)||(this.working=Ee(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:i}}=this.view,r=n.field(ve.state);if(r.tree==r.context.tree&&r.context.isDone(i+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!Oe?Math.max(25,e.timeRemaining()-5):1e9),s=r.context.treeLen<i&&n.doc.length>i+1e3,l=r.context.work((()=>Oe&&Oe()||Date.now()>o),i+(s?0:1e5));this.chunkBudget-=Date.now()-t,(l||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:ve.setState.of(new Ae(r.context))})),this.chunkBudget>0&&(!l||s)&&this.scheduleWork(),this.checkAsyncSchedule(r.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then((()=>this.scheduleWork())).catch((e=>(0,c.logException)(this.view.state,e))).then((()=>this.workScheduled--)),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Me=a.Facet.define({combine:e=>e.length?e[0]:null,enables:e=>[ve.state,De,c.EditorView.contentAttributes.compute([e],(t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}}))]});const Pe=a.Facet.define(),Ie=a.Facet.define({combine:e=>{if(!e.length)return" ";if(!/^(?: +|\t+)$/.test(e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(e[0]));return e[0]}});function Be(e){let t=e.facet(Ie);return 9==t.charCodeAt(0)?e.tabSize*t.length:t.length}function Te(e,t){let n="",i=e.tabSize;if(9==e.facet(Ie).charCodeAt(0))for(;t>=i;)n+="\t",t-=i;for(let r=0;r<t;r++)n+=" ";return n}function Ne(e,t){e instanceof a.EditorState&&(e=new Re(e));for(let i of e.state.facet(Pe)){let n=i(e,t);if(void 0!==n)return n}let n=we(e.state);return n?function(e,t,n){return Fe(t.resolveInner(n).enterUnfinishedNodesBefore(n),n,e)}(e,n,t):null}class Re{constructor(e,t={}){this.state=e,this.options=t,this.unit=Be(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:i,simulateDoubleBreak:r}=this.options;return null!=i&&i>=n.from&&i<=n.to?r&&i==e?{text:"",from:e}:(t<0?i<e:i<=e)?{text:n.text.slice(i-n.from),from:i}:{text:n.text.slice(0,i-n.from),from:n.from}:n}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:n,from:i}=this.lineAt(e,t);return n.slice(e-i,Math.min(n.length,e+100-i))}column(e,t=1){let{text:n,from:i}=this.lineAt(e,t),r=this.countColumn(n,e-i),o=this.options.overrideIndentation?this.options.overrideIndentation(i):-1;return o>-1&&(r+=o-this.countColumn(n,n.search(/\S|$/))),r}countColumn(e,t=e.length){return(0,a.countColumn)(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:i}=this.lineAt(e,t),r=this.options.overrideIndentation;if(r){let e=r(i);if(e>-1)return e}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const Le=new d;function _e(e){let t=e.type.prop(Le);if(t)return t;let n,i=e.firstChild;if(i&&(n=i.type.prop(d.closedBy))){let t=e.lastChild,i=t&&n.indexOf(t.name)>-1;return e=>qe(e,!0,1,void 0,i&&!function(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}(e)?t.from:void 0)}return null==e.parent?We:null}function Fe(e,t,n){for(;e;e=e.parent){let i=_e(e);if(i)return i(Ve.create(n,t,e))}return null}function We(){return 0}class Ve extends Re{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.node=n}static create(e,t,n){return new Ve(e,t,n)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){let e=this.state.doc.lineAt(this.node.from);for(;;){let t=this.node.resolve(e.from);for(;t.parent&&t.parent.from==t.from;)t=t.parent;if(je(t,this.node))break;e=this.state.doc.lineAt(t.from)}return this.lineIndent(e.from)}continue(){let e=this.node.parent;return e?Fe(e,this.pos,this.base):0}}function je(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function qe(e,t,n,i,r){let o=e.textAfter,s=o.match(/^\s*/)[0].length,l=i&&o.slice(s,s+i.length)==i||r==e.pos+s,a=t?function(e){let t=e.node,n=t.childAfter(t.from),i=t.lastChild;if(!n)return null;let r=e.options.simulateBreak,o=e.state.doc.lineAt(n.from),s=null==r||r<=o.from?o.to:Math.min(o.to,r);for(let l=n.to;;){let e=t.childAfter(l);if(!e||e==i)return null;if(!e.type.isSkipped)return e.from<s?n:null;l=e.to}}(e):null;return a?l?e.column(a.from):e.column(a.to):e.baseIndent+(l?0:e.unit*n)}const ze=a.Facet.define(),Ue=new d;function $e(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function He(e,t,n){for(let i of e.facet(ze)){let r=i(e,t,n);if(r)return r}return function(e,t,n){let i=we(e);if(i.length<n)return null;let r=null;for(let o=i.resolveInner(n,1);o;o=o.parent){if(o.to<=n||o.from>n)continue;if(r&&o.from<t)break;let s=o.type.prop(Ue);if(s&&(o.to<i.length-50||i.length==e.doc.length||!$e(o))){let i=s(o,e);i&&i.from<=n&&i.from>=t&&i.to>n&&(r=i)}}return r}(e,t,n)}function Je(e,t){let n=t.mapPos(e.from,1),i=t.mapPos(e.to,-1);return n>=i?void 0:{from:n,to:i}}const Ge=a.StateEffect.define({map:Je}),Ke=a.StateEffect.define({map:Je});function Qe(e){let t=[];for(let{head:n}of e.state.selection.ranges)t.some((e=>e.from<=n&&e.to>=n))||t.push(e.lineBlockAt(n));return t}const Ye=a.StateField.define({create:()=>c.Decoration.none,update(e,t){e=e.map(t.changes);for(let n of t.effects)n.is(Ge)&&!Ze(e,n.value.from,n.value.to)?e=e.update({add:[st.range(n.value.from,n.value.to)]}):n.is(Ke)&&(e=e.update({filter:(e,t)=>n.value.from!=e||n.value.to!=t,filterFrom:n.value.from,filterTo:n.value.to}));if(t.selection){let n=!1,{head:i}=t.selection.main;e.between(i,i,((e,t)=>{e<i&&t>i&&(n=!0)})),n&&(e=e.update({filterFrom:i,filterTo:i,filter:(e,t)=>t<=i||e>=i}))}return e},provide:e=>c.EditorView.decorations.from(e),toJSON(e,t){let n=[];return e.between(0,t.doc.length,((e,t)=>{n.push(e,t)})),n},fromJSON(e){if(!Array.isArray(e)||e.length%2)throw new RangeError("Invalid JSON for fold state");let t=[];for(let n=0;n<e.length;){let i=e[n++],r=e[n++];if("number"!=typeof i||"number"!=typeof r)throw new RangeError("Invalid JSON for fold state");t.push(st.range(i,r))}return c.Decoration.set(t,!0)}});function Xe(e,t,n){var i;let r=null;return null===(i=e.field(Ye,!1))||void 0===i||i.between(t,n,((e,t)=>{(!r||r.from>e)&&(r={from:e,to:t})})),r}function Ze(e,t,n){let i=!1;return e.between(t,t,((e,r)=>{e==t&&r==n&&(i=!0)})),i}function et(e,t){return e.field(Ye,!1)?t:t.concat(a.StateEffect.appendConfig.of(ot()))}function tt(e,t,n=!0){let i=e.state.doc.lineAt(t.from).number,r=e.state.doc.lineAt(t.to).number;return c.EditorView.announce.of(`${e.state.phrase(n?"Folded lines":"Unfolded lines")} ${i} ${e.state.phrase("to")} ${r}.`)}const nt=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:e=>{for(let t of Qe(e)){let n=He(e.state,t.from,t.to);if(n)return e.dispatch({effects:et(e.state,[Ge.of(n),tt(e,n)])}),!0}return!1}},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:e=>{if(!e.state.field(Ye,!1))return!1;let t=[];for(let n of Qe(e)){let i=Xe(e.state,n.from,n.to);i&&t.push(Ke.of(i),tt(e,i,!1))}return t.length&&e.dispatch({effects:t}),t.length>0}},{key:"Ctrl-Alt-[",run:e=>{let{state:t}=e,n=[];for(let i=0;i<t.doc.length;){let r=e.lineBlockAt(i),o=He(t,r.from,r.to);o&&n.push(Ge.of(o)),i=(o?e.lineBlockAt(o.to):r).to+1}return n.length&&e.dispatch({effects:et(e.state,n)}),!!n.length}},{key:"Ctrl-Alt-]",run:e=>{let t=e.state.field(Ye,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,((e,t)=>{n.push(Ke.of({from:e,to:t}))})),e.dispatch({effects:n}),!0}}],it={placeholderDOM:null,placeholderText:"\u2026"},rt=a.Facet.define({combine:e=>(0,a.combineConfig)(e,it)});function ot(e){let t=[Ye,ct];return e&&t.push(rt.of(e)),t}const st=c.Decoration.replace({widget:new class extends c.WidgetType{toDOM(e){let{state:t}=e,n=t.facet(rt),i=t=>{let n=e.lineBlockAt(e.posAtDOM(t.target)),i=Xe(e.state,n.from,n.to);i&&e.dispatch({effects:Ke.of(i)}),t.preventDefault()};if(n.placeholderDOM)return n.placeholderDOM(e,i);let r=document.createElement("span");return r.textContent=n.placeholderText,r.setAttribute("aria-label",t.phrase("folded code")),r.title=t.phrase("unfold"),r.className="cm-foldPlaceholder",r.onclick=i,r}}}),lt={openText:"\u2304",closedText:"\u203a",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class at extends c.GutterMarker{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}}const ct=c.EditorView.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class ht{constructor(e,t){let n;function i(e){let t=de.newName();return(n||(n=Object.create(null)))["."+t]=e,t}this.specs=e;const r="string"==typeof t.all?t.all:t.all?i(t.all):void 0,o=t.scope;this.scope=o instanceof ve?e=>e.prop(ye)==o.data:o?e=>e==o:void 0,this.style=$(e.map((e=>({tag:e.tag,class:e.class||i(Object.assign({},e,{tag:null}))}))),{all:r}).style,this.module=n?new de(n):null,this.themeType=t.themeType}static define(e,t){return new ht(e,t||{})}}const ut=a.Facet.define(),ft=a.Facet.define({combine:e=>e.length?[e[0]]:null});function dt(e){let t=e.facet(ut);return t.length?t:e.facet(ft)}function pt(e,t){let n,i=[gt];return e instanceof ht&&(e.module&&i.push(c.EditorView.styleModule.of(e.module)),n=e.themeType),(null===t||void 0===t?void 0:t.fallback)?i.push(ft.of(e)):n?i.push(ut.computeN([c.EditorView.darkTheme],(t=>t.facet(c.EditorView.darkTheme)==("dark"==n)?[e]:[]))):i.push(ut.of(e)),i}class mt{constructor(e){this.markCache=Object.create(null),this.tree=we(e.state),this.decorations=this.buildDeco(e,dt(e.state))}update(e){let t=we(e.state),n=dt(e.state),i=n!=dt(e.startState);t.length<e.view.viewport.to&&!i&&t.type==this.tree.type?this.decorations=this.decorations.map(e.changes):(t!=this.tree||e.viewportChanged||i)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n))}buildDeco(e,t){if(!t||!this.tree.length)return c.Decoration.none;let n=new a.RangeSetBuilder;for(let{from:i,to:r}of e.visibleRanges)H(this.tree,t,((e,t,i)=>{n.add(e,t,this.markCache[i]||(this.markCache[i]=c.Decoration.mark({class:i})))}),i,r);return n.finish()}}const gt=a.Prec.high(c.ViewPlugin.fromClass(mt,{decorations:e=>e.decorations})),yt=ht.define([{tag:ce.meta,color:"#7a757a"},{tag:ce.link,textDecoration:"underline"},{tag:ce.heading,textDecoration:"underline",fontWeight:"bold"},{tag:ce.emphasis,fontStyle:"italic"},{tag:ce.strong,fontWeight:"bold"},{tag:ce.strikethrough,textDecoration:"line-through"},{tag:ce.keyword,color:"#708"},{tag:[ce.atom,ce.bool,ce.url,ce.contentSeparator,ce.labelName],color:"#219"},{tag:[ce.literal,ce.inserted],color:"#164"},{tag:[ce.string,ce.deleted],color:"#a11"},{tag:[ce.regexp,ce.escape,ce.special(ce.string)],color:"#e40"},{tag:ce.definition(ce.variableName),color:"#00f"},{tag:ce.local(ce.variableName),color:"#30a"},{tag:[ce.typeName,ce.namespace],color:"#085"},{tag:ce.className,color:"#167"},{tag:[ce.special(ce.variableName),ce.macroName],color:"#256"},{tag:ce.definition(ce.propertyName),color:"#00c"},{tag:ce.comment,color:"#940"},{tag:ce.invalid,color:"#f00"}]),vt=c.EditorView.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),bt="()[]{}",wt=a.Facet.define({combine:e=>(0,a.combineConfig)(e,{afterCursor:!0,brackets:bt,maxScanDistance:1e4,renderMatch:St})}),xt=c.Decoration.mark({class:"cm-matchingBracket"}),kt=c.Decoration.mark({class:"cm-nonmatchingBracket"});function St(e){let t=[],n=e.matched?xt:kt;return t.push(n.range(e.start.from,e.start.to)),e.end&&t.push(n.range(e.end.from,e.end.to)),t}const Ct=a.StateField.define({create:()=>c.Decoration.none,update(e,t){if(!t.docChanged&&!t.selection)return e;let n=[],i=t.state.facet(wt);for(let r of t.state.selection.ranges){if(!r.empty)continue;let e=Ot(t.state,r.head,-1,i)||r.head>0&&Ot(t.state,r.head-1,1,i)||i.afterCursor&&(Ot(t.state,r.head,1,i)||r.head<t.state.doc.length&&Ot(t.state,r.head+1,-1,i));e&&(n=n.concat(i.renderMatch(e,t.state)))}return c.Decoration.set(n,!0)},provide:e=>c.EditorView.decorations.from(e)}),At=[Ct,vt];function Et(e,t,n){let i=e.prop(t<0?d.openedBy:d.closedBy);if(i)return i;if(1==e.name.length){let i=n.indexOf(e.name);if(i>-1&&i%2==(t<0?1:0))return[n[i+t]]}return null}function Ot(e,t,n,i={}){let r=i.maxScanDistance||1e4,o=i.brackets||bt,s=we(e),l=s.resolveInner(t,n);for(let a=l;a;a=a.parent){let i=Et(a.type,n,o);if(i&&a.from<a.to)return Dt(e,t,n,a,i,o)}return function(e,t,n,i,r,o,s){let l=n<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),a=s.indexOf(l);if(a<0||a%2==0!=n>0)return null;let c={from:n<0?t-1:t,to:n>0?t+1:t},h=e.doc.iterRange(t,n>0?e.doc.length:0),u=0;for(let f=0;!h.next().done&&f<=o;){let e=h.value;n<0&&(f+=e.length);let o=t+f*n;for(let t=n>0?0:e.length-1,l=n>0?e.length:-1;t!=l;t+=n){let l=s.indexOf(e[t]);if(!(l<0||i.resolveInner(o+t,1).type!=r))if(l%2==0==n>0)u++;else{if(1==u)return{start:c,end:{from:o+t,to:o+t+1},matched:l>>1==a>>1};u--}}n>0&&(f+=e.length)}return h.done?{start:c,matched:!1}:null}(e,t,n,s,l.type,r,o)}function Dt(e,t,n,i,r,o){let s=i.parent,l={from:i.from,to:i.to},a=0,c=null===s||void 0===s?void 0:s.cursor();if(c&&(n<0?c.childBefore(i.from):c.childAfter(i.to)))do{if(n<0?c.to<=i.from:c.from>=i.to){if(0==a&&r.indexOf(c.type.name)>-1&&c.from<c.to)return{start:l,end:{from:c.from,to:c.to},matched:!0};if(Et(c.type,n,o))a++;else if(Et(c.type,-n,o)){if(0==a)return{start:l,end:c.from==c.to?void 0:{from:c.from,to:c.to},matched:!1};a--}}}while(n<0?c.prevSibling():c.nextSibling());return{start:l,matched:!1}}const Mt=Object.create(null),Pt=[m.none],It=[],Bt=Object.create(null);for(let[s,l]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])Bt[s]=Nt(Mt,l);function Tt(e,t){It.indexOf(e)>-1||(It.push(e),console.warn(t))}function Nt(e,t){let n=null;for(let o of t.split(".")){let t=e[o]||ce[o];t?"function"==typeof t?n?n=t(n):Tt(o,`Modifier ${o} used at start of tag`):n?Tt(o,`Tag ${o} used as modifier`):n=t:Tt(o,`Unknown highlighting tag ${o}`)}if(!n)return 0;let i=t.replace(/ /g,"_"),r=m.define({id:Pt.length,name:i,props:[q({[i]:n})]});return Pt.push(r),r.id}function Rt(e,t){return({state:n,dispatch:i})=>{if(n.readOnly)return!1;let r=e(t,n);return!!r&&(i(n.update(r)),!0)}}const Lt=Rt(jt,0),_t=Rt(Vt,0),Ft=Rt(((e,t)=>Vt(e,t,function(e){let t=[];for(let n of e.selection.ranges){let i=e.doc.lineAt(n.from),r=n.to<=i.to?i:e.doc.lineAt(n.to),o=t.length-1;o>=0&&t[o].to>i.from?t[o].to=r.to:t.push({from:i.from,to:r.to})}return t}(t))),0);function Wt(e,t=e.selection.main.head){let n=e.languageDataAt("commentTokens",t);return n.length?n[0]:{}}function Vt(e,t,n=t.selection.ranges){let i=n.map((e=>Wt(t,e.from).block));if(!i.every((e=>e)))return null;let r=n.map(((e,n)=>function(e,{open:t,close:n},i,r){let o,s,l=e.sliceDoc(i-50,i),a=e.sliceDoc(r,r+50),c=/\s*$/.exec(l)[0].length,h=/^\s*/.exec(a)[0].length,u=l.length-c;if(l.slice(u-t.length,u)==t&&a.slice(h,h+n.length)==n)return{open:{pos:i-c,margin:c&&1},close:{pos:r+h,margin:h&&1}};r-i<=100?o=s=e.sliceDoc(i,r):(o=e.sliceDoc(i,i+50),s=e.sliceDoc(r-50,r));let f=/^\s*/.exec(o)[0].length,d=/\s*$/.exec(s)[0].length,p=s.length-d-n.length;return o.slice(f,f+t.length)==t&&s.slice(p,p+n.length)==n?{open:{pos:i+f+t.length,margin:/\s/.test(o.charAt(f+t.length))?1:0},close:{pos:r-d-n.length,margin:/\s/.test(s.charAt(p-1))?1:0}}:null}(t,i[n],e.from,e.to)));if(2!=e&&!r.every((e=>e)))return{changes:t.changes(n.map(((e,t)=>r[t]?[]:[{from:e.from,insert:i[t].open+" "},{from:e.to,insert:" "+i[t].close}])))};if(1!=e&&r.some((e=>e))){let e=[];for(let t,n=0;n<r.length;n++)if(t=r[n]){let r=i[n],{open:o,close:s}=t;e.push({from:o.pos-r.open.length,to:o.pos+o.margin},{from:s.pos-s.margin,to:s.pos+r.close.length})}return{changes:e}}return null}function jt(e,t,n=t.selection.ranges){let i=[],r=-1;for(let{from:o,to:s}of n){let e=i.length,n=1e9;for(let l=o;l<=s;){let e=t.doc.lineAt(l);if(e.from>r&&(o==s||s>e.from)){r=e.from;let o=Wt(t,l).line;if(!o)continue;let s=/^\s*/.exec(e.text)[0].length,a=s==e.length,c=e.text.slice(s,s+o.length)==o?s:-1;s<e.text.length&&s<n&&(n=s),i.push({line:e,comment:c,token:o,indent:s,empty:a,single:!1})}l=e.to+1}if(n<1e9)for(let t=e;t<i.length;t++)i[t].indent<i[t].line.text.length&&(i[t].indent=n);i.length==e+1&&(i[e].single=!0)}if(2!=e&&i.some((e=>e.comment<0&&(!e.empty||e.single)))){let e=[];for(let{line:t,token:r,indent:o,empty:s,single:l}of i)!l&&s||e.push({from:t.from+o,insert:r+" "});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}if(1!=e&&i.some((e=>e.comment>=0))){let e=[];for(let{line:t,comment:n,token:r}of i)if(n>=0){let i=t.from+n,o=i+r.length;" "==t.text[o-t.from]&&o++,e.push({from:i,to:o})}return{changes:e}}return null}const qt=a.Annotation.define(),zt=a.Annotation.define(),Ut=a.Facet.define(),$t=a.Facet.define({combine:e=>(0,a.combineConfig)(e,{minDepth:100,newGroupDelay:500},{minDepth:Math.max,newGroupDelay:Math.min})});const Ht=a.StateField.define({create:()=>cn.empty,update(e,t){let n=t.state.facet($t),i=t.annotation(qt);if(i){let r=t.docChanged?a.EditorSelection.single(function(e){let t=0;return e.iterChangedRanges(((e,n)=>t=n)),t}(t.changes)):void 0,o=Zt.fromTransaction(t,r),s=i.side,l=0==s?e.undone:e.done;return l=o?en(l,l.length,n.minDepth,o):rn(l,t.startState.selection),new cn(0==s?i.rest:l,0==s?l:i.rest)}let r=t.annotation(zt);if("full"!=r&&"before"!=r||(e=e.isolate()),!1===t.annotation(a.Transaction.addToHistory))return t.changes.empty?e:e.addMapping(t.changes.desc);let o=Zt.fromTransaction(t),s=t.annotation(a.Transaction.time),l=t.annotation(a.Transaction.userEvent);return o?e=e.addChanges(o,s,l,n.newGroupDelay,n.minDepth):t.selection&&(e=e.addSelection(t.startState.selection,s,l,n.newGroupDelay)),"full"!=r&&"after"!=r||(e=e.isolate()),e},toJSON:e=>({done:e.done.map((e=>e.toJSON())),undone:e.undone.map((e=>e.toJSON()))}),fromJSON:e=>new cn(e.done.map(Zt.fromJSON),e.undone.map(Zt.fromJSON))});function Jt(e={}){return[Ht,$t.of(e),c.EditorView.domEventHandlers({beforeinput(e,t){let n="historyUndo"==e.inputType?Kt:"historyRedo"==e.inputType?Qt:null;return!!n&&(e.preventDefault(),n(t))}})]}function Gt(e,t){return function({state:n,dispatch:i}){if(!t&&n.readOnly)return!1;let r=n.field(Ht,!1);if(!r)return!1;let o=r.pop(e,n,t);return!!o&&(i(o),!0)}}const Kt=Gt(0,!1),Qt=Gt(1,!1),Yt=Gt(0,!0),Xt=Gt(1,!0);class Zt{constructor(e,t,n,i,r){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=i,this.selectionsAfter=r}setSelAfter(e){return new Zt(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,n;return{changes:null===(e=this.changes)||void 0===e?void 0:e.toJSON(),mapped:null===(t=this.mapped)||void 0===t?void 0:t.toJSON(),startSelection:null===(n=this.startSelection)||void 0===n?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map((e=>e.toJSON()))}}static fromJSON(e){return new Zt(e.changes&&a.ChangeSet.fromJSON(e.changes),[],e.mapped&&a.ChangeDesc.fromJSON(e.mapped),e.startSelection&&a.EditorSelection.fromJSON(e.startSelection),e.selectionsAfter.map(a.EditorSelection.fromJSON))}static fromTransaction(e,t){let n=nn;for(let i of e.startState.facet(Ut)){let t=i(e);t.length&&(n=n.concat(t))}return!n.length&&e.changes.empty?null:new Zt(e.changes.invert(e.startState.doc),n,void 0,t||e.startState.selection,nn)}static selection(e){return new Zt(void 0,nn,void 0,void 0,e)}}function en(e,t,n,i){let r=t+1>n+20?t-n-1:0,o=e.slice(r,t);return o.push(i),o}function tn(e,t){return e.length?t.length?e.concat(t):e:t}const nn=[];function rn(e,t){if(e.length){let n=e[e.length-1],i=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-200));return i.length&&i[i.length-1].eq(t)?e:(i.push(t),en(e,e.length-1,1e9,n.setSelAfter(i)))}return[Zt.selection([t])]}function on(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function sn(e,t){if(!e.length)return e;let n=e.length,i=nn;for(;n;){let r=ln(e[n-1],t,i);if(r.changes&&!r.changes.empty||r.effects.length){let t=e.slice(0,n);return t[n-1]=r,t}t=r.mapped,n--,i=r.selectionsAfter}return i.length?[Zt.selection(i)]:nn}function ln(e,t,n){let i=tn(e.selectionsAfter.length?e.selectionsAfter.map((e=>e.map(t))):nn,n);if(!e.changes)return Zt.selection(i);let r=e.changes.map(t),o=t.mapDesc(e.changes,!0),s=e.mapped?e.mapped.composeDesc(o):o;return new Zt(r,a.StateEffect.mapEffects(e.effects,t),s,e.startSelection.map(o),i)}const an=/^(input\.type|delete)($|\.)/;class cn{constructor(e,t,n=0,i){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=i}isolate(){return this.prevTime?new cn(this.done,this.undone):this}addChanges(e,t,n,i,r){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&e.changes&&(!n||an.test(n))&&(!s.selectionsAfter.length&&t-this.prevTime<i&&function(e,t){let n=[],i=!1;return e.iterChangedRanges(((e,t)=>n.push(e,t))),t.iterChangedRanges(((e,t,r,o)=>{for(let s=0;s<n.length;){let e=n[s++],t=n[s++];o>=e&&r<=t&&(i=!0)}})),i}(s.changes,e.changes)||"input.type.compose"==n)?en(o,o.length-1,r,new Zt(e.changes.compose(s.changes),tn(e.effects,s.effects),s.mapped,s.startSelection,nn)):en(o,o.length,r,e),new cn(o,nn,t,n)}addSelection(e,t,n,i){let r=this.done.length?this.done[this.done.length-1].selectionsAfter:nn;return r.length>0&&t-this.prevTime<i&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&(o=r[r.length-1],s=e,o.ranges.length==s.ranges.length&&0===o.ranges.filter(((e,t)=>e.empty!=s.ranges[t].empty)).length)?this:new cn(rn(this.done,e),this.undone,t,n);var o,s}addMapping(e){return new cn(sn(this.done,e),sn(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,n){let i=0==e?this.done:this.undone;if(0==i.length)return null;let r=i[i.length-1];if(n&&r.selectionsAfter.length)return t.update({selection:r.selectionsAfter[r.selectionsAfter.length-1],annotations:qt.of({side:e,rest:on(i)}),userEvent:0==e?"select.undo":"select.redo",scrollIntoView:!0});if(r.changes){let n=1==i.length?nn:i.slice(0,i.length-1);return r.mapped&&(n=sn(n,r.mapped)),t.update({changes:r.changes,selection:r.startSelection,effects:r.effects,annotations:qt.of({side:e,rest:n}),filter:!1,userEvent:0==e?"undo":"redo",scrollIntoView:!0})}return null}}cn.empty=new cn(nn,nn);const hn=[{key:"Mod-z",run:Kt,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Qt,preventDefault:!0},{linux:"Ctrl-Shift-z",run:Qt,preventDefault:!0},{key:"Mod-u",run:Yt,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:Xt,preventDefault:!0}];function un(e,t){return a.EditorSelection.create(e.ranges.map(t),e.mainIndex)}function fn(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function dn({state:e,dispatch:t},n){let i=un(e.selection,n);return!i.eq(e.selection)&&(t(fn(e,i)),!0)}function pn(e,t){return a.EditorSelection.cursor(t?e.to:e.from)}function mn(e,t){return dn(e,(n=>n.empty?e.moveByChar(n,t):pn(n,t)))}function gn(e){return e.textDirectionAt(e.state.selection.main.head)==c.Direction.LTR}const yn=e=>mn(e,!gn(e)),vn=e=>mn(e,gn(e));function bn(e,t){return dn(e,(n=>n.empty?e.moveByGroup(n,t):pn(n,t)))}function wn(e,t,n){if(t.type.prop(n))return!0;let i=t.to-t.from;return i&&(i>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function xn(e,t,n){let i,r,o=we(e).resolveInner(t.head),s=n?d.closedBy:d.openedBy;for(let l=t.head;;){let t=n?o.childAfter(l):o.childBefore(l);if(!t)break;wn(e,t,s)?o=t:l=n?t.to:t.from}return r=o.type.prop(s)&&(i=n?Ot(e,o.from,1):Ot(e,o.to,-1))&&i.matched?n?i.end.to:i.end.from:n?o.to:o.from,a.EditorSelection.cursor(r,n?-1:1)}function kn(e,t){return dn(e,(n=>{if(!n.empty)return pn(n,t);let i=e.moveVertically(n,t);return i.head!=n.head?i:e.moveToLineBoundary(n,t)}))}const Sn=e=>kn(e,!1),Cn=e=>kn(e,!0);function An(e){return Math.max(e.defaultLineHeight,Math.min(e.dom.clientHeight,innerHeight)-5)}function En(e,t){let{state:n}=e,i=un(n.selection,(n=>n.empty?e.moveVertically(n,t,An(e)):pn(n,t)));if(i.eq(n.selection))return!1;let r,o=e.coordsAtPos(n.selection.main.head),s=e.scrollDOM.getBoundingClientRect();return o&&o.top>s.top&&o.bottom<s.bottom&&o.top-s.top<=e.scrollDOM.scrollHeight-e.scrollDOM.scrollTop-e.scrollDOM.clientHeight&&(r=c.EditorView.scrollIntoView(i.main.head,{y:"start",yMargin:o.top-s.top})),e.dispatch(fn(n,i),{effects:r}),!0}const On=e=>En(e,!1),Dn=e=>En(e,!0);function Mn(e,t,n){let i=e.lineBlockAt(t.head),r=e.moveToLineBoundary(t,n);if(r.head==t.head&&r.head!=(n?i.to:i.from)&&(r=e.moveToLineBoundary(t,n,!1)),!n&&r.head==i.from&&i.length){let n=/^\s*/.exec(e.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;n&&t.head!=i.from+n&&(r=a.EditorSelection.cursor(i.from+n))}return r}function Pn(e,t,n){let i=!1,r=un(e.selection,(t=>{let r=Ot(e,t.head,-1)||Ot(e,t.head,1)||t.head>0&&Ot(e,t.head-1,1)||t.head<e.doc.length&&Ot(e,t.head+1,-1);if(!r||!r.end)return t;i=!0;let o=r.start.from==t.head?r.end.to:r.end.from;return n?a.EditorSelection.range(t.anchor,o):a.EditorSelection.cursor(o)}));return!!i&&(t(fn(e,r)),!0)}function In(e,t){let n=un(e.state.selection,(e=>{let n=t(e);return a.EditorSelection.range(e.anchor,n.head,n.goalColumn)}));return!n.eq(e.state.selection)&&(e.dispatch(fn(e.state,n)),!0)}function Bn(e,t){return In(e,(n=>e.moveByChar(n,t)))}const Tn=e=>Bn(e,!gn(e)),Nn=e=>Bn(e,gn(e));function Rn(e,t){return In(e,(n=>e.moveByGroup(n,t)))}function Ln(e,t){return In(e,(n=>e.moveVertically(n,t)))}const _n=e=>Ln(e,!1),Fn=e=>Ln(e,!0);function Wn(e,t){return In(e,(n=>e.moveVertically(n,t,An(e))))}const Vn=e=>Wn(e,!1),jn=e=>Wn(e,!0),qn=({state:e,dispatch:t})=>(t(fn(e,{anchor:0})),!0),zn=({state:e,dispatch:t})=>(t(fn(e,{anchor:e.doc.length})),!0),Un=({state:e,dispatch:t})=>(t(fn(e,{anchor:e.selection.main.anchor,head:0})),!0),$n=({state:e,dispatch:t})=>(t(fn(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0);function Hn(e,t){if(e.state.readOnly)return!1;let n="delete.selection",{state:i}=e,r=i.changeByRange((i=>{let{from:r,to:o}=i;if(r==o){let i=t(r);i<r?(n="delete.backward",i=Jn(e,i,!1)):i>r&&(n="delete.forward",i=Jn(e,i,!0)),r=Math.min(r,i),o=Math.max(o,i)}else r=Jn(e,r,!1),o=Jn(e,o,!0);return r==o?{range:i}:{changes:{from:r,to:o},range:a.EditorSelection.cursor(r)}}));return!r.changes.empty&&(e.dispatch(i.update(r,{scrollIntoView:!0,userEvent:n,effects:"delete.selection"==n?c.EditorView.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function Jn(e,t,n){if(e instanceof c.EditorView)for(let i of e.state.facet(c.EditorView.atomicRanges).map((t=>t(e))))i.between(t,t,((e,i)=>{e<t&&i>t&&(t=n?i:e)}));return t}const Gn=(e,t)=>Hn(e,(n=>{let i,r,{state:o}=e,s=o.doc.lineAt(n);if(!t&&n>s.from&&n<s.from+200&&!/[^ \t]/.test(i=s.text.slice(0,n-s.from))){if("\t"==i[i.length-1])return n-1;let e=(0,a.countColumn)(i,o.tabSize)%Be(o)||Be(o);for(let t=0;t<e&&" "==i[i.length-1-t];t++)n--;r=n}else r=(0,a.findClusterBreak)(s.text,n-s.from,t,t)+s.from,r==n&&s.number!=(t?o.doc.lines:1)&&(r+=t?1:-1);return r})),Kn=e=>Gn(e,!1),Qn=e=>Gn(e,!0),Yn=(e,t)=>Hn(e,(n=>{let i=n,{state:r}=e,o=r.doc.lineAt(i),s=r.charCategorizer(i);for(let e=null;;){if(i==(t?o.to:o.from)){i==n&&o.number!=(t?r.doc.lines:1)&&(i+=t?1:-1);break}let l=(0,a.findClusterBreak)(o.text,i-o.from,t)+o.from,c=o.text.slice(Math.min(i,l)-o.from,Math.max(i,l)-o.from),h=s(c);if(null!=e&&h!=e)break;" "==c&&i==n||(e=h),i=l}return i})),Xn=e=>Yn(e,!1),Zn=e=>Hn(e,(t=>{let n=e.lineBlockAt(t).to;return t<n?n:Math.min(e.state.doc.length,t+1)}));function ei(e){let t=[],n=-1;for(let i of e.selection.ranges){let r=e.doc.lineAt(i.from),o=e.doc.lineAt(i.to);if(i.empty||i.to!=o.from||(o=e.doc.lineAt(i.to-1)),n>=r.number){let e=t[t.length-1];e.to=o.to,e.ranges.push(i)}else t.push({from:r.from,to:o.to,ranges:[i]});n=o.number+1}return t}function ti(e,t,n){if(e.readOnly)return!1;let i=[],r=[];for(let o of ei(e)){if(n?o.to==e.doc.length:0==o.from)continue;let t=e.doc.lineAt(n?o.to+1:o.from-1),s=t.length+1;if(n){i.push({from:o.to,to:t.to},{from:o.from,insert:t.text+e.lineBreak});for(let t of o.ranges)r.push(a.EditorSelection.range(Math.min(e.doc.length,t.anchor+s),Math.min(e.doc.length,t.head+s)))}else{i.push({from:t.from,to:o.from},{from:o.to,insert:e.lineBreak+t.text});for(let e of o.ranges)r.push(a.EditorSelection.range(e.anchor-s,e.head-s))}}return!!i.length&&(t(e.update({changes:i,scrollIntoView:!0,selection:a.EditorSelection.create(r,e.selection.mainIndex),userEvent:"move.line"})),!0)}function ni(e,t,n){if(e.readOnly)return!1;let i=[];for(let r of ei(e))n?i.push({from:r.from,insert:e.doc.slice(r.from,r.to)+e.lineBreak}):i.push({from:r.to,insert:e.lineBreak+e.doc.slice(r.from,r.to)});return t(e.update({changes:i,scrollIntoView:!0,userEvent:"input.copyline"})),!0}const ii=ri(!1);function ri(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let i=t.changeByRange((n=>{let{from:i,to:r}=n,o=t.doc.lineAt(i),s=!e&&i==r&&function(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n,i=we(e).resolveInner(t),r=i.childBefore(t),o=i.childAfter(t);return r&&o&&r.to<=t&&o.from>=t&&(n=r.type.prop(d.closedBy))&&n.indexOf(o.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(o.from).from?{from:r.to,to:o.from}:null}(t,i);e&&(i=r=(r<=o.to?o:t.doc.lineAt(r)).to);let l=new Re(t,{simulateBreak:i,simulateDoubleBreak:!!s}),c=Ne(l,i);for(null==c&&(c=/^\s*/.exec(t.doc.lineAt(i).text)[0].length);r<o.to&&/\s/.test(o.text[r-o.from]);)r++;s?({from:i,to:r}=s):i>o.from&&i<o.from+100&&!/\S/.test(o.text.slice(0,i))&&(i=o.from);let h=["",Te(t,c)];return s&&h.push(Te(t,l.lineIndent(o.from,-1))),{changes:{from:i,to:r,insert:a.Text.of(h)},range:a.EditorSelection.cursor(i+1+h[1].length)}}));return n(t.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function oi(e,t){let n=-1;return e.changeByRange((i=>{let r=[];for(let s=i.from;s<=i.to;){let o=e.doc.lineAt(s);o.number>n&&(i.empty||i.to>o.from)&&(t(o,r,i),n=o.number),s=o.to+1}let o=e.changes(r);return{changes:r,range:a.EditorSelection.range(o.mapPos(i.anchor,1),o.mapPos(i.head,1))}}))}const si=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(oi(e,((t,n)=>{n.push({from:t.from,insert:e.facet(Ie)})})),{userEvent:"input.indent"})),!0),li=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(oi(e,((t,n)=>{let i=/^\s*/.exec(t.text)[0];if(!i)return;let r=(0,a.countColumn)(i,e.tabSize),o=0,s=Te(e,Math.max(0,r-Be(e)));for(;o<i.length&&o<s.length&&i.charCodeAt(o)==s.charCodeAt(o);)o++;n.push({from:t.from+o,to:t.from+i.length,insert:s.slice(o)})})),{userEvent:"delete.dedent"})),!0),ai=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:e=>dn(e,(t=>xn(e.state,t,!gn(e)))),shift:e=>In(e,(t=>xn(e.state,t,!gn(e))))},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:e=>dn(e,(t=>xn(e.state,t,gn(e)))),shift:e=>In(e,(t=>xn(e.state,t,gn(e))))},{key:"Alt-ArrowUp",run:({state:e,dispatch:t})=>ti(e,t,!1)},{key:"Shift-Alt-ArrowUp",run:({state:e,dispatch:t})=>ni(e,t,!1)},{key:"Alt-ArrowDown",run:({state:e,dispatch:t})=>ti(e,t,!0)},{key:"Shift-Alt-ArrowDown",run:({state:e,dispatch:t})=>ni(e,t,!0)},{key:"Escape",run:({state:e,dispatch:t})=>{let n=e.selection,i=null;return n.ranges.length>1?i=a.EditorSelection.create([n.main]):n.main.empty||(i=a.EditorSelection.create([a.EditorSelection.cursor(n.main.head)])),!!i&&(t(fn(e,i)),!0)}},{key:"Mod-Enter",run:ri(!0)},{key:"Alt-l",mac:"Ctrl-l",run:({state:e,dispatch:t})=>{let n=ei(e).map((({from:t,to:n})=>a.EditorSelection.range(t,Math.min(n+1,e.doc.length))));return t(e.update({selection:a.EditorSelection.create(n),userEvent:"select"})),!0}},{key:"Mod-i",run:({state:e,dispatch:t})=>{let n=un(e.selection,(t=>{var n;let i=we(e).resolveInner(t.head,1);for(;!(i.from<t.from&&i.to>=t.to||i.to>t.to&&i.from<=t.from)&&(null===(n=i.parent)||void 0===n?void 0:n.parent);)i=i.parent;return a.EditorSelection.range(i.to,i.from)}));return t(fn(e,n)),!0},preventDefault:!0},{key:"Mod-[",run:li},{key:"Mod-]",run:si},{key:"Mod-Alt-\\",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),i=new Re(e,{overrideIndentation:e=>{let t=n[e];return null==t?-1:t}}),r=oi(e,((t,r,o)=>{let s=Ne(i,t.from);if(null==s)return;/\S/.test(t.text)||(s=0);let l=/^\s*/.exec(t.text)[0],a=Te(e,s);(l!=a||o.from<t.from+l.length)&&(n[t.from]=s,r.push({from:t.from,to:t.from+l.length,insert:a}))}));return r.changes.empty||t(e.update(r,{userEvent:"indent"})),!0}},{key:"Shift-Mod-k",run:e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(ei(t).map((({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n})))),i=un(t.selection,(t=>e.moveVertically(t,!0))).map(n);return e.dispatch({changes:n,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0}},{key:"Shift-Mod-\\",run:({state:e,dispatch:t})=>Pn(e,t,!1)},{key:"Mod-/",run:e=>{let t=Wt(e.state);return t.line?Lt(e):!!t.block&&Ft(e)}},{key:"Alt-A",run:_t}].concat([{key:"ArrowLeft",run:yn,shift:Tn,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:e=>bn(e,!gn(e)),shift:e=>Rn(e,!gn(e)),preventDefault:!0},{mac:"Cmd-ArrowLeft",run:e=>dn(e,(t=>Mn(e,t,!gn(e)))),shift:e=>In(e,(t=>Mn(e,t,!gn(e)))),preventDefault:!0},{key:"ArrowRight",run:vn,shift:Nn,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:e=>bn(e,gn(e)),shift:e=>Rn(e,gn(e)),preventDefault:!0},{mac:"Cmd-ArrowRight",run:e=>dn(e,(t=>Mn(e,t,gn(e)))),shift:e=>In(e,(t=>Mn(e,t,gn(e)))),preventDefault:!0},{key:"ArrowUp",run:Sn,shift:_n,preventDefault:!0},{mac:"Cmd-ArrowUp",run:qn,shift:Un},{mac:"Ctrl-ArrowUp",run:On,shift:Vn},{key:"ArrowDown",run:Cn,shift:Fn,preventDefault:!0},{mac:"Cmd-ArrowDown",run:zn,shift:$n},{mac:"Ctrl-ArrowDown",run:Dn,shift:jn},{key:"PageUp",run:On,shift:Vn},{key:"PageDown",run:Dn,shift:jn},{key:"Home",run:e=>dn(e,(t=>Mn(e,t,!1))),shift:e=>In(e,(t=>Mn(e,t,!1))),preventDefault:!0},{key:"Mod-Home",run:qn,shift:Un},{key:"End",run:e=>dn(e,(t=>Mn(e,t,!0))),shift:e=>In(e,(t=>Mn(e,t,!0))),preventDefault:!0},{key:"Mod-End",run:zn,shift:$n},{key:"Enter",run:ii},{key:"Mod-a",run:({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0)},{key:"Backspace",run:Kn,shift:Kn},{key:"Delete",run:Qn},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Xn},{key:"Mod-Delete",mac:"Alt-Delete",run:e=>Yn(e,!0)},{mac:"Mod-Backspace",run:e=>Hn(e,(t=>{let n=e.lineBlockAt(t).from;return t>n?n:Math.max(0,t-1)}))},{mac:"Mod-Delete",run:Zn}].concat([{key:"Ctrl-b",run:yn,shift:Tn,preventDefault:!0},{key:"Ctrl-f",run:vn,shift:Nn},{key:"Ctrl-p",run:Sn,shift:_n},{key:"Ctrl-n",run:Cn,shift:Fn},{key:"Ctrl-a",run:e=>dn(e,(t=>a.EditorSelection.cursor(e.lineBlockAt(t.head).from,1))),shift:e=>In(e,(t=>a.EditorSelection.cursor(e.lineBlockAt(t.head).from)))},{key:"Ctrl-e",run:e=>dn(e,(t=>a.EditorSelection.cursor(e.lineBlockAt(t.head).to,-1))),shift:e=>In(e,(t=>a.EditorSelection.cursor(e.lineBlockAt(t.head).to)))},{key:"Ctrl-d",run:Qn},{key:"Ctrl-h",run:Kn},{key:"Ctrl-k",run:Zn},{key:"Ctrl-Alt-h",run:Xn},{key:"Ctrl-o",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange((e=>({changes:{from:e.from,to:e.to,insert:a.Text.of(["",""])},range:a.EditorSelection.cursor(e.from)})));return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}},{key:"Ctrl-t",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange((t=>{if(!t.empty||0==t.from||t.from==e.doc.length)return{range:t};let n=t.from,i=e.doc.lineAt(n),r=n==i.from?n-1:(0,a.findClusterBreak)(i.text,n-i.from,!1)+i.from,o=n==i.to?n+1:(0,a.findClusterBreak)(i.text,n-i.from,!0)+i.from;return{changes:{from:r,to:o,insert:e.doc.slice(n,o).append(e.doc.slice(r,n))},range:a.EditorSelection.cursor(o)}}));return!n.changes.empty&&(t(e.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)}},{key:"Ctrl-v",run:Dn}].map((e=>({mac:e.key,run:e.run,shift:e.shift}))))),ci={key:"Tab",run:si,shift:li};function hi(){var e=arguments[0];"string"==typeof e&&(e=document.createElement(e));var t=1,n=arguments[1];if(n&&"object"==typeof n&&null==n.nodeType&&!Array.isArray(n)){for(var i in n)if(Object.prototype.hasOwnProperty.call(n,i)){var r=n[i];"string"==typeof r?e.setAttribute(i,r):null!=r&&(e[i]=r)}t++}for(;t<arguments.length;t++)ui(e,arguments[t]);return e}function ui(e,t){if("string"==typeof t)e.appendChild(document.createTextNode(t));else if(null==t);else if(null!=t.nodeType)e.appendChild(t);else{if(!Array.isArray(t))throw new RangeError("Unsupported child node: "+t);for(var n=0;n<t.length;n++)ui(e,t[n])}}const fi="function"==typeof String.prototype.normalize?e=>e.normalize("NFKD"):e=>e;class di{constructor(e,t,n=0,i=e.length,r,o){this.test=o,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(n,i),this.bufferStart=n,this.normalize=r?e=>r(fi(e)):fi,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return(0,a.codePointAt)(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=(0,a.fromCodePoint)(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=(0,a.codePointSize)(e);let i=this.normalize(t);for(let r=0,o=n;;r++){let e=i.charCodeAt(r),s=this.match(e,o);if(s)return this.value=s,this;if(r==i.length-1)break;o==n&&r<t.length&&t.charCodeAt(r)==e&&o++}}}match(e,t){let n=null;for(let i=0;i<this.matches.length;i+=2){let r=this.matches[i],o=!1;this.query.charCodeAt(r)==e&&(r==this.query.length-1?n={from:this.matches[i+1],to:t+1}:(this.matches[i]++,o=!0)),o||(this.matches.splice(i,2),i-=2)}return this.query.charCodeAt(0)==e&&(1==this.query.length?n={from:t,to:t+1}:this.matches.push(1,t)),n&&this.test&&!this.test(n.from,n.to,this.buffer,this.bufferPos)&&(n=null),n}}"undefined"!=typeof Symbol&&(di.prototype[Symbol.iterator]=function(){return this});const pi={from:-1,to:-1,match:/.*/.exec("")},mi="gm"+(null==/x/.unicode?"":"u");class gi{constructor(e,t,n,i=0,r=e.length){if(this.text=e,this.to=r,this.curLine="",this.done=!1,this.value=pi,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new bi(e,t,n,i,r);this.re=new RegExp(t,mi+((null===n||void 0===n?void 0:n.ignoreCase)?"i":"")),this.test=null===n||void 0===n?void 0:n.test,this.iter=e.iter();let o=e.lineAt(i);this.curLineStart=o.from,this.matchPos=wi(e,i),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,i=n+t[0].length;if(this.matchPos=wi(this.text,i+(n==i?1:0)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<i||n>this.value.to)&&(!this.test||this.test(n,i,t)))return this.value={from:n,to:i,match:t},this;e=this.matchPos-this.curLineStart}else{if(!(this.curLineStart+this.curLine.length<this.to))return this.done=!0,this;this.nextLine(),e=0}}}}const yi=new WeakMap;class vi{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,n){let i=yi.get(e);if(!i||i.from>=n||i.to<=t){let i=new vi(t,e.sliceString(t,n));return yi.set(e,i),i}if(i.from==t&&i.to==n)return i;let{text:r,from:o}=i;return o>t&&(r=e.sliceString(t,o)+r,o=t),i.to<n&&(r+=e.sliceString(i.to,n)),yi.set(e,new vi(o,r)),new vi(t,r.slice(t-o,n-o))}}class bi{constructor(e,t,n,i,r){this.text=e,this.to=r,this.done=!1,this.value=pi,this.matchPos=wi(e,i),this.re=new RegExp(t,mi+((null===n||void 0===n?void 0:n.ignoreCase)?"i":"")),this.test=null===n||void 0===n?void 0:n.test,this.flat=vi.get(e,i,this.chunkEnd(i+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,match:t},this.matchPos=wi(this.text,n+(e==n?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=vi.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+2*this.flat.text.length))}}}function wi(e,t){if(t>=e.length)return t;let n,i=e.lineAt(t);for(;t<i.to&&(n=i.text.charCodeAt(t-i.from))>=56320&&n<57344;)t++;return t}function xi(e){let t=hi("input",{class:"cm-textfield",name:"line"});function n(){let n=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(t.value);if(!n)return;let{state:i}=e,r=i.doc.lineAt(i.selection.main.head),[,o,s,l,c]=n,h=l?+l.slice(1):0,u=s?+s:r.number;if(s&&c){let e=u/100;o&&(e=e*("-"==o?-1:1)+r.number/i.doc.lines),u=Math.round(i.doc.lines*e)}else s&&o&&(u=u*("-"==o?-1:1)+r.number);let f=i.doc.line(Math.max(1,Math.min(i.doc.lines,u)));e.dispatch({effects:ki.of(!1),selection:a.EditorSelection.cursor(f.from+Math.max(0,Math.min(h,f.length))),scrollIntoView:!0}),e.focus()}return{dom:hi("form",{class:"cm-gotoLine",onkeydown:t=>{27==t.keyCode?(t.preventDefault(),e.dispatch({effects:ki.of(!1)}),e.focus()):13==t.keyCode&&(t.preventDefault(),n())},onsubmit:e=>{e.preventDefault(),n()}},hi("label",e.state.phrase("Go to line"),": ",t)," ",hi("button",{class:"cm-button",type:"submit"},e.state.phrase("go")))}}"undefined"!=typeof Symbol&&(gi.prototype[Symbol.iterator]=bi.prototype[Symbol.iterator]=function(){return this});const ki=a.StateEffect.define(),Si=a.StateField.define({create:()=>!0,update(e,t){for(let n of t.effects)n.is(ki)&&(e=n.value);return e},provide:e=>c.showPanel.from(e,(e=>e?xi:null))}),Ci=c.EditorView.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px","& label":{fontSize:"80%"}}}),Ai={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},Ei=a.Facet.define({combine:e=>(0,a.combineConfig)(e,Ai,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})});const Oi=c.Decoration.mark({class:"cm-selectionMatch"}),Di=c.Decoration.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function Mi(e,t,n,i){return(0==n||e(t.sliceDoc(n-1,n))!=a.CharCategory.Word)&&(i==t.doc.length||e(t.sliceDoc(i,i+1))!=a.CharCategory.Word)}const Pi=c.ViewPlugin.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(Ei),{state:n}=e,i=n.selection;if(i.ranges.length>1)return c.Decoration.none;let r,o=i.main,s=null;if(o.empty){if(!t.highlightWordAroundCursor)return c.Decoration.none;let e=n.wordAt(o.head);if(!e)return c.Decoration.none;s=n.charCategorizer(o.head),r=n.sliceDoc(e.from,e.to)}else{let e=o.to-o.from;if(e<t.minSelectionLength||e>200)return c.Decoration.none;if(t.wholeWords){if(r=n.sliceDoc(o.from,o.to),s=n.charCategorizer(o.head),!Mi(s,n,o.from,o.to)||!function(e,t,n,i){return e(t.sliceDoc(n,n+1))==a.CharCategory.Word&&e(t.sliceDoc(i-1,i))==a.CharCategory.Word}(s,n,o.from,o.to))return c.Decoration.none}else if(r=n.sliceDoc(o.from,o.to).trim(),!r)return c.Decoration.none}let l=[];for(let a of e.visibleRanges){let e=new di(n.doc,r,a.from,a.to);for(;!e.next().done;){let{from:i,to:r}=e.value;if((!s||Mi(s,n,i,r))&&(o.empty&&i<=o.from&&r>=o.to?l.push(Di.range(i,r)):(i>=o.to||r<=o.from)&&l.push(Oi.range(i,r)),l.length>t.maxMatches))return c.Decoration.none}}return c.Decoration.set(l)}},{decorations:e=>e.decorations}),Ii=c.EditorView.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}});const Bi=a.Facet.define({combine:e=>(0,a.combineConfig)(e,{top:!1,caseSensitive:!1,literal:!1,wholeWord:!1,createPanel:e=>new or(e)})});class Ti{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||function(e){try{return new RegExp(e,mi),!0}catch(ge){return!1}}(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,((e,t)=>"n"==t?"\n":"r"==t?"\r":"t"==t?"\t":"\\"))}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord}create(){return this.regexp?new Vi(this):new Li(this)}getCursor(e,t=0,n){let i=e.doc?e:a.EditorState.create({doc:e});return null==n&&(n=i.doc.length),this.regexp?_i(this,i,t,n):Ri(this,i,t,n)}}class Ni{constructor(e){this.spec=e}}function Ri(e,t,n,i){return new di(t.doc,e.unquoted,n,i,e.caseSensitive?void 0:e=>e.toLowerCase(),e.wholeWord?(r=t.doc,o=t.charCategorizer(t.selection.main.head),(e,t,n,i)=>((i>e||i+n.length<t)&&(i=Math.max(0,e-2),n=r.sliceString(i,Math.min(r.length,t+2))),(o(Fi(n,e-i))!=a.CharCategory.Word||o(Wi(n,e-i))!=a.CharCategory.Word)&&(o(Wi(n,t-i))!=a.CharCategory.Word||o(Fi(n,t-i))!=a.CharCategory.Word))):void 0);var r,o}class Li extends Ni{constructor(e){super(e)}nextMatch(e,t,n){let i=Ri(this.spec,e,n,e.doc.length).nextOverlapping();return i.done&&(i=Ri(this.spec,e,0,t).nextOverlapping()),i.done?null:i.value}prevMatchInRange(e,t,n){for(let i=n;;){let n=Math.max(t,i-1e4-this.spec.unquoted.length),r=Ri(this.spec,e,n,i),o=null;for(;!r.nextOverlapping().done;)o=r.value;if(o)return o;if(n==t)return null;i-=1e4}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=Ri(this.spec,e,0,e.doc.length),i=[];for(;!n.next().done;){if(i.length>=t)return null;i.push(n.value)}return i}highlight(e,t,n,i){let r=Ri(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!r.next().done;)i(r.value.from,r.value.to)}}function _i(e,t,n,i){return new gi(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:e.wholeWord?(r=t.charCategorizer(t.selection.main.head),(e,t,n)=>!n[0].length||(r(Fi(n.input,n.index))!=a.CharCategory.Word||r(Wi(n.input,n.index))!=a.CharCategory.Word)&&(r(Wi(n.input,n.index+n[0].length))!=a.CharCategory.Word||r(Fi(n.input,n.index+n[0].length))!=a.CharCategory.Word)):void 0},n,i);var r}function Fi(e,t){return e.slice((0,a.findClusterBreak)(e,t,!1),t)}function Wi(e,t){return e.slice(t,(0,a.findClusterBreak)(e,t))}class Vi extends Ni{nextMatch(e,t,n){let i=_i(this.spec,e,n,e.doc.length).next();return i.done&&(i=_i(this.spec,e,0,t).next()),i.done?null:i.value}prevMatchInRange(e,t,n){for(let i=1;;i++){let r=Math.max(t,n-1e4*i),o=_i(this.spec,e,r,n),s=null;for(;!o.next().done;)s=o.value;if(s&&(r==t||s.from>r+10))return s;if(r==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace.replace(/\$([$&\d+])/g,((t,n)=>"$"==n?"$":"&"==n?e.match[0]:"0"!=n&&+n<e.match.length?e.match[n]:t)))}matchAll(e,t){let n=_i(this.spec,e,0,e.doc.length),i=[];for(;!n.next().done;){if(i.length>=t)return null;i.push(n.value)}return i}highlight(e,t,n,i){let r=_i(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!r.next().done;)i(r.value.from,r.value.to)}}const ji=a.StateEffect.define(),qi=a.StateEffect.define(),zi=a.StateField.define({create:e=>new Ui(tr(e).create(),null),update(e,t){for(let n of t.effects)n.is(ji)?e=new Ui(n.value.create(),e.panel):n.is(qi)&&(e=new Ui(e.query,n.value?er:null));return e},provide:e=>c.showPanel.from(e,(e=>e.panel))});class Ui{constructor(e,t){this.query=e,this.panel=t}}const $i=c.Decoration.mark({class:"cm-searchMatch"}),Hi=c.Decoration.mark({class:"cm-searchMatch cm-searchMatch-selected"}),Ji=c.ViewPlugin.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(zi))}update(e){let t=e.state.field(zi);(t!=e.startState.field(zi)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return c.Decoration.none;let{view:n}=this,i=new a.RangeSetBuilder;for(let r=0,o=n.visibleRanges,s=o.length;r<s;r++){let{from:t,to:l}=o[r];for(;r<s-1&&l>o[r+1].from-500;)l=o[++r].to;e.highlight(n.state,t,l,((e,t)=>{let r=n.state.selection.ranges.some((n=>n.from==e&&n.to==t));i.add(e,t,r?Hi:$i)}))}return i.finish()}},{decorations:e=>e.decorations});function Gi(e){return t=>{let n=t.state.field(zi,!1);return n&&n.query.spec.valid?e(t,n):nr(t)}}const Ki=Gi(((e,{query:t})=>{let{to:n}=e.state.selection.main,i=t.nextMatch(e.state,n,n);return!!i&&(e.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:ar(e,i),userEvent:"select.search"}),!0)})),Qi=Gi(((e,{query:t})=>{let{state:n}=e,{from:i}=n.selection.main,r=t.prevMatch(n,i,i);return!!r&&(e.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0,effects:ar(e,r),userEvent:"select.search"}),!0)})),Yi=Gi(((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!(!n||!n.length)&&(e.dispatch({selection:a.EditorSelection.create(n.map((e=>a.EditorSelection.range(e.from,e.to)))),userEvent:"select.search.matches"}),!0)})),Xi=Gi(((e,{query:t})=>{let{state:n}=e,{from:i,to:r}=n.selection.main;if(n.readOnly)return!1;let o=t.nextMatch(n,i,i);if(!o)return!1;let s,l,a=[],h=[];if(o.from==i&&o.to==r&&(l=n.toText(t.getReplacement(o)),a.push({from:o.from,to:o.to,insert:l}),o=t.nextMatch(n,o.from,o.to),h.push(c.EditorView.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(i).number)+"."))),o){let t=0==a.length||a[0].from>=o.to?0:o.to-o.from-l.length;s={anchor:o.from-t,head:o.to-t},h.push(ar(e,o))}return e.dispatch({changes:a,selection:s,scrollIntoView:!!s,effects:h,userEvent:"input.replace"}),!0})),Zi=Gi(((e,{query:t})=>{if(e.state.readOnly)return!1;let n=t.matchAll(e.state,1e9).map((e=>{let{from:n,to:i}=e;return{from:n,to:i,insert:t.getReplacement(e)}}));if(!n.length)return!1;let i=e.state.phrase("replaced $ matches",n.length)+".";return e.dispatch({changes:n,effects:c.EditorView.announce.of(i),userEvent:"input.replace.all"}),!0}));function er(e){return e.state.facet(Bi).createPanel(e)}function tr(e,t){var n,i,r,o;let s=e.selection.main,l=s.empty||s.to>s.from+100?"":e.sliceDoc(s.from,s.to);if(t&&!l)return t;let a=e.facet(Bi);return new Ti({search:(null!==(n=null===t||void 0===t?void 0:t.literal)&&void 0!==n?n:a.literal)?l:l.replace(/\n/g,"\\n"),caseSensitive:null!==(i=null===t||void 0===t?void 0:t.caseSensitive)&&void 0!==i?i:a.caseSensitive,literal:null!==(r=null===t||void 0===t?void 0:t.literal)&&void 0!==r?r:a.literal,wholeWord:null!==(o=null===t||void 0===t?void 0:t.wholeWord)&&void 0!==o?o:a.wholeWord})}const nr=e=>{let t=e.state.field(zi,!1);if(t&&t.panel){let n=(0,c.getPanel)(e,er);if(!n)return!1;let i=n.dom.querySelector("[main-field]");if(i&&i!=e.root.activeElement){let n=tr(e.state,t.query.spec);n.valid&&e.dispatch({effects:ji.of(n)}),i.focus(),i.select()}}else e.dispatch({effects:[qi.of(!0),t?ji.of(tr(e.state,t.query.spec)):a.StateEffect.appendConfig.of(hr)]});return!0},ir=e=>{let t=e.state.field(zi,!1);if(!t||!t.panel)return!1;let n=(0,c.getPanel)(e,er);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:qi.of(!1)}),!0},rr=[{key:"Mod-f",run:nr,scope:"editor search-panel"},{key:"F3",run:Ki,shift:Qi,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:Ki,shift:Qi,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:ir,scope:"editor search-panel"},{key:"Mod-Shift-l",run:({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:i,to:r}=n.main,o=[],s=0;for(let l=new di(e.doc,e.sliceDoc(i,r));!l.next().done;){if(o.length>1e3)return!1;l.value.from==i&&(s=o.length),o.push(a.EditorSelection.range(l.value.from,l.value.to))}return t(e.update({selection:a.EditorSelection.create(o,s),userEvent:"select.search.matches"})),!0}},{key:"Alt-g",run:e=>{let t=(0,c.getPanel)(e,xi);if(!t){let n=[ki.of(!0)];null==e.state.field(Si,!1)&&n.push(a.StateEffect.appendConfig.of([Si,Ci])),e.dispatch({effects:n}),t=(0,c.getPanel)(e,xi)}return t&&t.dom.querySelector("input").focus(),!0}},{key:"Mod-d",run:({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some((e=>e.from===e.to)))return(({state:e,dispatch:t})=>{let{selection:n}=e,i=a.EditorSelection.create(n.ranges.map((t=>e.wordAt(t.head)||a.EditorSelection.cursor(t.head))),n.mainIndex);return!i.eq(n)&&(t(e.update({selection:i})),!0)})({state:e,dispatch:t});let i=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some((t=>e.sliceDoc(t.from,t.to)!=i)))return!1;let r=function(e,t){let{main:n,ranges:i}=e.selection,r=e.wordAt(n.head),o=r&&r.from==n.from&&r.to==n.to;for(let s=!1,l=new di(e.doc,t,i[i.length-1].to);;){if(l.next(),!l.done){if(s&&i.some((e=>e.from==l.value.from)))continue;if(o){let t=e.wordAt(l.value.from);if(!t||t.from!=l.value.from||t.to!=l.value.to)continue}return l.value}if(s)return null;l=new di(e.doc,t,0,Math.max(0,i[i.length-1].from-1)),s=!0}}(e,i);return!!r&&(t(e.update({selection:e.selection.addRange(a.EditorSelection.range(r.from,r.to),!1),effects:c.EditorView.scrollIntoView(r.to)})),!0)},preventDefault:!0}];class or{constructor(e){this.view=e;let t=this.query=e.state.field(zi).query.spec;function n(e,t,n){return hi("button",{class:"cm-button",name:e,onclick:t,type:"button"},n)}this.commit=this.commit.bind(this),this.searchField=hi("input",{value:t.search,placeholder:sr(e,"Find"),"aria-label":sr(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=hi("input",{value:t.replace,placeholder:sr(e,"Replace"),"aria-label":sr(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=hi("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=hi("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=hi("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit}),this.dom=hi("div",{onkeydown:e=>this.keydown(e),class:"cm-search"},[this.searchField,n("next",(()=>Ki(e)),[sr(e,"next")]),n("prev",(()=>Qi(e)),[sr(e,"previous")]),n("select",(()=>Yi(e)),[sr(e,"all")]),hi("label",null,[this.caseField,sr(e,"match case")]),hi("label",null,[this.reField,sr(e,"regexp")]),hi("label",null,[this.wordField,sr(e,"by word")]),...e.state.readOnly?[]:[hi("br"),this.replaceField,n("replace",(()=>Xi(e)),[sr(e,"replace")]),n("replaceAll",(()=>Zi(e)),[sr(e,"replace all")])],hi("button",{name:"close",onclick:()=>ir(e),"aria-label":sr(e,"close"),type:"button"},["\xd7"])])}commit(){let e=new Ti({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:ji.of(e)}))}keydown(e){(0,c.runScopeHandlers)(this.view,e,"search-panel")?e.preventDefault():13==e.keyCode&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?Qi:Ki)(this.view)):13==e.keyCode&&e.target==this.replaceField&&(e.preventDefault(),Xi(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(ji)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(Bi).top}}function sr(e,t){return e.state.phrase(t)}const lr=/[\s\.,:;?!]/;function ar(e,{from:t,to:n}){let i=e.state.doc.lineAt(t),r=e.state.doc.lineAt(n).to,o=Math.max(i.from,t-30),s=Math.min(r,n+30),l=e.state.sliceDoc(o,s);if(o!=i.from)for(let a=0;a<30;a++)if(!lr.test(l[a+1])&&lr.test(l[a])){l=l.slice(a);break}if(s!=r)for(let a=l.length-1;a>l.length-30;a--)if(!lr.test(l[a-1])&&lr.test(l[a])){l=l.slice(0,a);break}return c.EditorView.announce.of(`${e.state.phrase("current match")}. ${l} ${e.state.phrase("on line")} ${i.number}.`)}const cr=c.EditorView.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),hr=[zi,a.Prec.lowest(Ji),cr];class ur{constructor(e,t,n){this.state=e,this.pos=t,this.explicit=n,this.abortListeners=[]}tokenBefore(e){let t=we(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),i=t.text.slice(n-t.from,this.pos-t.from),r=i.search(gr(e,!1));return r<0?null:{from:n+r,to:this.pos,text:i.slice(r)}}get aborted(){return null==this.abortListeners}addEventListener(e,t){"abort"==e&&this.abortListeners&&this.abortListeners.push(t)}}function fr(e){let t=Object.keys(e).join(""),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,"")),`[${n?"\\w":""}${t.replace(/[^\w\s]/g,"\\$&")}]`}function dr(e){let t=e.map((e=>"string"==typeof e?{label:e}:e)),[n,i]=t.every((e=>/^\w+$/.test(e.label)))?[/\w*$/,/\w+$/]:function(e){let t=Object.create(null),n=Object.create(null);for(let{label:r}of e){t[r[0]]=!0;for(let e=1;e<r.length;e++)n[r[e]]=!0}let i=fr(t)+fr(n)+"*$";return[new RegExp("^"+i),new RegExp(i)]}(t);return e=>{let r=e.matchBefore(i);return r||e.explicit?{from:r?r.from:e.pos,options:t,validFor:n}:null}}class pr{constructor(e,t,n){this.completion=e,this.source=t,this.match=n}}function mr(e){return e.selection.main.head}function gr(e,t){var n;let{source:i}=e,r=t&&"^"!=i[0],o="$"!=i[i.length-1];return r||o?new RegExp(`${r?"^":""}(?:${i})${o?"$":""}`,null!==(n=e.flags)&&void 0!==n?n:e.ignoreCase?"i":""):e}const yr=a.Annotation.define();function vr(e,t){const n=t.completion.apply||t.completion.label;let i=t.source;var r,o,s,l;"string"==typeof n?e.dispatch(Object.assign(Object.assign({},(r=e.state,o=n,s=i.from,l=i.to,Object.assign(Object.assign({},r.changeByRange((e=>{if(e==r.selection.main)return{changes:{from:s,to:l,insert:o},range:a.EditorSelection.cursor(s+o.length)};let t=l-s;return!e.empty||t&&r.sliceDoc(e.from-t,e.from)!=r.sliceDoc(s,l)?{range:e}:{changes:{from:e.from-t,to:e.from,insert:o},range:a.EditorSelection.cursor(e.from-t+o.length)}}))),{userEvent:"input.complete"}))),{annotations:yr.of(t.completion)})):n(e,t.completion,i.from,i.to)}const br=new WeakMap;function wr(e){if(!Array.isArray(e))return e;let t=br.get(e);return t||br.set(e,t=dr(e)),t}class xr{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[];for(let t=0;t<e.length;){let n=(0,a.codePointAt)(e,t),i=(0,a.codePointSize)(n);this.chars.push(n);let r=e.slice(t,t+i),o=r.toUpperCase();this.folded.push((0,a.codePointAt)(o==r?r.toLowerCase():o,0)),t+=i}this.astral=e.length!=this.chars.length}match(e){if(0==this.pattern.length)return[0];if(e.length<this.pattern.length)return null;let{chars:t,folded:n,any:i,precise:r,byWord:o}=this;if(1==t.length){let i=(0,a.codePointAt)(e,0);return i==t[0]?[0,0,(0,a.codePointSize)(i)]:i==n[0]?[-200,0,(0,a.codePointSize)(i)]:null}let s=e.indexOf(this.pattern);if(0==s)return[0,0,this.pattern.length];let l=t.length,c=0;if(s<0){for(let r=0,o=Math.min(e.length,200);r<o&&c<l;){let o=(0,a.codePointAt)(e,r);o!=t[c]&&o!=n[c]||(i[c++]=r),r+=(0,a.codePointSize)(o)}if(c<l)return null}let h=0,u=0,f=!1,d=0,p=-1,m=-1,g=/[a-z]/.test(e),y=!0;for(let v=0,b=Math.min(e.length,200),w=0;v<b&&u<l;){let i=(0,a.codePointAt)(e,v);s<0&&(h<l&&i==t[h]&&(r[h++]=v),d<l&&(i==t[d]||i==n[d]?(0==d&&(p=v),m=v+1,d++):d=0));let c,b=i<255?i>=48&&i<=57||i>=97&&i<=122?2:i>=65&&i<=90?1:0:(c=(0,a.fromCodePoint)(i))!=c.toLowerCase()?1:c!=c.toUpperCase()?2:0;(!v||1==b&&g||0==w&&0!=b)&&(t[u]==i||n[u]==i&&(f=!0)?o[u++]=v:o.length&&(y=!1)),w=b,v+=(0,a.codePointSize)(i)}return u==l&&0==o[0]&&y?this.result((f?-200:0)-100,o,e):d==l&&0==p?[-200-e.length,0,m]:s>-1?[-700-e.length,s,s+this.pattern.length]:d==l?[-900-e.length,p,m]:u==l?this.result((f?-200:0)-100-700+(y?0:-1100),o,e):2==t.length?null:this.result((i[0]?-700:0)-200-1100,i,e)}result(e,t,n){let i=[e-n.length],r=1;for(let o of t){let e=o+(this.astral?(0,a.codePointSize)((0,a.codePointAt)(n,o)):1);r>1&&i[r-1]==o?i[r-1]=e:(i[r++]=o,i[r++]=e)}return i}}const kr=a.Facet.define({combine:e=>(0,a.combineConfig)(e,{activateOnTyping:!0,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],compareCompletions:(e,t)=>e.label.localeCompare(t.label),interactionDelay:75},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,optionClass:(e,t)=>n=>function(e,t){return e?t?e+" "+t:e:t}(e(n),t(n)),addToOptions:(e,t)=>e.concat(t)})});function Sr(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let e=Math.floor(t/n);return{from:e*n,to:(e+1)*n}}let i=Math.floor((e-t)/n);return{from:e-(i+1)*n,to:e-i*n}}class Cr{constructor(e,t){this.view=e,this.stateField=t,this.info=null,this.placeInfo={read:()=>this.measureInfo(),write:e=>this.positionInfo(e),key:this},this.space=null;let n=e.state.field(t),{options:i,selected:r}=n.open,o=e.state.facet(kr);this.optionContent=function(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(e){let t=document.createElement("div");return t.classList.add("cm-completionIcon"),e.type&&t.classList.add(...e.type.split(/\s+/g).map((e=>"cm-completionIcon-"+e))),t.setAttribute("aria-hidden","true"),t},position:20}),t.push({render(e,t,n){let i=document.createElement("span");i.className="cm-completionLabel";let{label:r}=e,o=0;for(let s=1;s<n.length;){let e=n[s++],t=n[s++];e>o&&i.appendChild(document.createTextNode(r.slice(o,e)));let l=i.appendChild(document.createElement("span"));l.appendChild(document.createTextNode(r.slice(e,t))),l.className="cm-completionMatchedText",o=t}return o<r.length&&i.appendChild(document.createTextNode(r.slice(o))),i},position:50},{render(e){if(!e.detail)return null;let t=document.createElement("span");return t.className="cm-completionDetail",t.textContent=e.detail,t},position:80}),t.sort(((e,t)=>e.position-t.position)).map((e=>e.render))}(o),this.optionClass=o.optionClass,this.range=Sr(i.length,r,o.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.dom.addEventListener("mousedown",(t=>{for(let n,r=t.target;r&&r!=this.dom;r=r.parentNode)if("LI"==r.nodeName&&(n=/-(\d+)$/.exec(r.id))&&+n[1]<i.length)return vr(e,i[+n[1]]),void t.preventDefault()})),this.list=this.dom.appendChild(this.createListBox(i,n.id,this.range)),this.list.addEventListener("scroll",(()=>{this.info&&this.view.requestMeasure(this.placeInfo)}))}mount(){this.updateSel()}update(e){var t,n,i;let r=e.state.field(this.stateField),o=e.startState.field(this.stateField);r!=o&&(this.updateSel(),(null===(t=r.open)||void 0===t?void 0:t.disabled)!=(null===(n=o.open)||void 0===n?void 0:n.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!(null===(i=r.open)||void 0===i?void 0:i.disabled)))}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfo)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;if((t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=Sr(t.options.length,t.selected,this.view.state.facet(kr).maxRenderedOptions),this.list.remove(),this.list=this.dom.appendChild(this.createListBox(t.options,e.id,this.range)),this.list.addEventListener("scroll",(()=>{this.info&&this.view.requestMeasure(this.placeInfo)}))),this.updateSelectedOption(t.selected)){this.info&&(this.info.remove(),this.info=null);let{completion:n}=t.options[t.selected],{info:i}=n;if(!i)return;let r="string"===typeof i?document.createTextNode(i):i(n);if(!r)return;"then"in r?r.then((t=>{t&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(t)})).catch((e=>(0,c.logException)(this.view.state,e,"completion info"))):this.addInfoPane(r)}}addInfoPane(e){let t=this.info=document.createElement("div");t.className="cm-tooltip cm-completionInfo",t.appendChild(e),this.dom.appendChild(t),this.view.requestMeasure(this.placeInfo)}updateSelectedOption(e){let t=null;for(let n=this.list.firstChild,i=this.range.from;n;n=n.nextSibling,i++)i==e?n.hasAttribute("aria-selected")||(n.setAttribute("aria-selected","true"),t=n):n.hasAttribute("aria-selected")&&n.removeAttribute("aria-selected");return t&&function(e,t){let n=e.getBoundingClientRect(),i=t.getBoundingClientRect();i.top<n.top?e.scrollTop-=n.top-i.top:i.bottom>n.bottom&&(e.scrollTop+=i.bottom-n.bottom)}(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),i=e.getBoundingClientRect(),r=this.space;if(!r){let e=this.dom.ownerDocument.defaultView||window;r={left:0,top:0,right:e.innerWidth,bottom:e.innerHeight}}if(i.top>Math.min(r.bottom,t.bottom)-10||i.bottom<Math.max(r.top,t.top)+10)return null;let o,s=this.view.textDirection==c.Direction.RTL,l=s,a=!1,h="",u="",f=t.left-r.left,d=r.right-t.right;if(l&&f<Math.min(n.width,d)?l=!1:!l&&d<Math.min(n.width,f)&&(l=!0),n.width<=(l?f:d))h=Math.max(r.top,Math.min(i.top,r.bottom-n.height))-t.top+"px",o=Math.min(400,l?f:d)+"px";else{a=!0,o=Math.min(400,(s?t.right:r.right-t.left)-30)+"px";let e=r.bottom-t.bottom;e>=n.height||e>t.top?h=i.bottom-t.top+"px":u=t.bottom-i.top+"px"}return{top:h,bottom:u,maxWidth:o,class:a?s?"left-narrow":"right-narrow":l?"left":"right"}}positionInfo(e){this.info&&(e?(this.info.style.top=e.top,this.info.style.bottom=e.bottom,this.info.style.maxWidth=e.maxWidth,this.info.className="cm-tooltip cm-completionInfo cm-completionInfo-"+e.class):this.info.style.top="-1e6px")}createListBox(e,t,n){const i=document.createElement("ul");i.id=t,i.setAttribute("role","listbox"),i.setAttribute("aria-expanded","true"),i.setAttribute("aria-label",this.view.state.phrase("Completions"));for(let r=n.from;r<n.to;r++){let{completion:n,match:o}=e[r];const s=i.appendChild(document.createElement("li"));s.id=t+"-"+r,s.setAttribute("role","option");let l=this.optionClass(n);l&&(s.className=l);for(let e of this.optionContent){let t=e(n,this.view.state,o);t&&s.appendChild(t)}}return n.from&&i.classList.add("cm-completionListIncompleteTop"),n.to<e.length&&i.classList.add("cm-completionListIncompleteBottom"),i}}function Ar(e){return 100*(e.boost||0)+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}class Er{constructor(e,t,n,i,r,o){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=i,this.selected=r,this.disabled=o}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new Er(this.options,Mr(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,n,i,r){let o=function(e,t){let n=[],i=0;for(let l of e)if(l.hasResult())if(!1===l.result.filter){let e=l.result.getMatch;for(let t of l.result.options){let r=[1e9-i++];if(e)for(let n of e(t))r.push(n);n.push(new pr(t,l,r))}}else{let e,i=new xr(t.sliceDoc(l.from,l.to));for(let t of l.result.options)(e=i.match(t.label))&&(null!=t.boost&&(e[0]+=t.boost),n.push(new pr(t,l,e)))}let r=[],o=null,s=t.facet(kr).compareCompletions;for(let l of n.sort(((e,t)=>t.match[0]-e.match[0]||s(e.completion,t.completion))))!o||o.label!=l.completion.label||o.detail!=l.completion.detail||null!=o.type&&null!=l.completion.type&&o.type!=l.completion.type||o.apply!=l.completion.apply?r.push(l):Ar(l.completion)>Ar(o)&&(r[r.length-1]=l),o=l.completion;return r}(e,t);if(!o.length)return i&&e.some((e=>1==e.state))?new Er(i.options,i.attrs,i.tooltip,i.timestamp,i.selected,!0):null;let s=t.facet(kr).selectOnOpen?0:-1;if(i&&i.selected!=s&&-1!=i.selected){let e=i.options[i.selected].completion;for(let t=0;t<o.length;t++)if(o[t].completion==e){s=t;break}}return new Er(o,Mr(n,s),{pos:e.reduce(((e,t)=>t.hasResult()?Math.min(e,t.from):e),1e8),create:(l=Fr,e=>new Cr(e,l)),above:r.aboveCursor},i?i.timestamp:Date.now(),s,!1);var l}map(e){return new Er(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:e.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}}class Or{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new Or(Pr,"cm-ac-"+Math.floor(2e6*Math.random()).toString(36),null)}update(e){let{state:t}=e,n=t.facet(kr),i=(n.override||t.languageDataAt("autocomplete",mr(t)).map(wr)).map((t=>(this.active.find((e=>e.source==t))||new Br(t,this.active.some((e=>0!=e.state))?1:0)).update(e,n)));i.length==this.active.length&&i.every(((e,t)=>e==this.active[t]))&&(i=this.active);let r=this.open;e.selection||i.some((t=>t.hasResult()&&e.changes.touchesRange(t.from,t.to)))||!function(e,t){if(e==t)return!0;for(let n=0,i=0;;){for(;n<e.length&&!e[n].hasResult;)n++;for(;i<t.length&&!t[i].hasResult;)i++;let r=n==e.length,o=i==t.length;if(r||o)return r==o;if(e[n++].result!=t[i++].result)return!1}}(i,this.active)?r=Er.build(i,t,this.id,this.open,n):r&&r.disabled&&!i.some((e=>1==e.state))?r=null:r&&e.docChanged&&(r=r.map(e.changes)),!r&&i.every((e=>1!=e.state))&&i.some((e=>e.hasResult()))&&(i=i.map((e=>e.hasResult()?new Br(e.source,0):e)));for(let o of e.effects)o.is(_r)&&(r=r&&r.setSelected(o.value,this.id));return i==this.active&&r==this.open?this:new Or(i,this.id,r)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:Dr}}const Dr={"aria-autocomplete":"list"};function Mr(e,t){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}const Pr=[];function Ir(e){return e.isUserEvent("input.type")?"input":e.isUserEvent("delete.backward")?"delete":null}class Br{constructor(e,t,n=-1){this.source=e,this.state=t,this.explicitPos=n}hasResult(){return!1}update(e,t){let n=Ir(e),i=this;n?i=i.handleUserEvent(e,n,t):e.docChanged?i=i.handleChange(e):e.selection&&0!=i.state&&(i=new Br(i.source,0));for(let r of e.effects)if(r.is(Nr))i=new Br(i.source,1,r.value?mr(e.state):-1);else if(r.is(Rr))i=new Br(i.source,0);else if(r.is(Lr))for(let e of r.value)e.source==i.source&&(i=e);return i}handleUserEvent(e,t,n){return"delete"!=t&&n.activateOnTyping?new Br(this.source,1):this.map(e.changes)}handleChange(e){return e.changes.touchesRange(mr(e.startState))?new Br(this.source,0):this.map(e.changes)}map(e){return e.empty||this.explicitPos<0?this:new Br(this.source,this.state,e.mapPos(this.explicitPos))}}class Tr extends Br{constructor(e,t,n,i,r){super(e,2,t),this.result=n,this.from=i,this.to=r}hasResult(){return!0}handleUserEvent(e,t,n){var i;let r=e.changes.mapPos(this.from),o=e.changes.mapPos(this.to,1),s=mr(e.state);if((this.explicitPos<0?s<=r:s<this.from)||s>o||"delete"==t&&mr(e.startState)==this.from)return new Br(this.source,"input"==t&&n.activateOnTyping?1:0);let l,a=this.explicitPos<0?-1:e.changes.mapPos(this.explicitPos);return function(e,t,n,i){if(!e)return!1;let r=t.sliceDoc(n,i);return"function"==typeof e?e(r,n,i,t):gr(e,!0).test(r)}(this.result.validFor,e.state,r,o)?new Tr(this.source,a,this.result,r,o):this.result.update&&(l=this.result.update(this.result,r,o,new ur(e.state,s,a>=0)))?new Tr(this.source,a,l,l.from,null!==(i=l.to)&&void 0!==i?i:mr(e.state)):new Br(this.source,1,a)}handleChange(e){return e.changes.touchesRange(this.from,this.to)?new Br(this.source,0):this.map(e.changes)}map(e){return e.empty?this:new Tr(this.source,this.explicitPos<0?-1:e.mapPos(this.explicitPos),this.result,e.mapPos(this.from),e.mapPos(this.to,1))}}const Nr=a.StateEffect.define(),Rr=a.StateEffect.define(),Lr=a.StateEffect.define({map:(e,t)=>e.map((e=>e.map(t)))}),_r=a.StateEffect.define(),Fr=a.StateField.define({create:()=>Or.start(),update:(e,t)=>e.update(t),provide:e=>[c.showTooltip.from(e,(e=>e.tooltip)),c.EditorView.contentAttributes.from(e,(e=>e.attrs))]});function Wr(e,t="option"){return n=>{let i=n.state.field(Fr,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp<n.state.facet(kr).interactionDelay)return!1;let r,o=1;"page"==t&&(r=(0,c.getTooltip)(n,i.open.tooltip))&&(o=Math.max(2,Math.floor(r.dom.offsetHeight/r.dom.querySelector("li").offsetHeight)-1));let{length:s}=i.open.options,l=i.open.selected>-1?i.open.selected+o*(e?1:-1):e?0:s-1;return l<0?l="page"==t?0:s-1:l>=s&&(l="page"==t?s-1:0),n.dispatch({effects:_r.of(l)}),!0}}class Vr{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const jr=c.ViewPlugin.fromClass(class{constructor(e){this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.composing=0;for(let t of e.state.field(Fr).active)1==t.state&&this.startQuery(t)}update(e){let t=e.state.field(Fr);if(!e.selectionSet&&!e.docChanged&&e.startState.field(Fr)==t)return;let n=e.transactions.some((e=>(e.selection||e.docChanged)&&!Ir(e)));for(let r=0;r<this.running.length;r++){let t=this.running[r];if(n||t.updates.length+e.transactions.length>50&&Date.now()-t.time>1e3){for(let e of t.context.abortListeners)try{e()}catch(i){(0,c.logException)(this.view.state,i)}t.context.abortListeners=null,this.running.splice(r--,1)}else t.updates.push(...e.transactions)}if(this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),this.debounceUpdate=t.active.some((e=>1==e.state&&!this.running.some((t=>t.active.source==e.source))))?setTimeout((()=>this.startUpdate()),50):-1,0!=this.composing)for(let r of e.transactions)"input"==Ir(r)?this.composing=2:2==this.composing&&r.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1;let{state:e}=this.view,t=e.field(Fr);for(let n of t.active)1!=n.state||this.running.some((e=>e.active.source==n.source))||this.startQuery(n)}startQuery(e){let{state:t}=this.view,n=mr(t),i=new ur(t,n,e.explicitPos==n),r=new Vr(e,i);this.running.push(r),Promise.resolve(e.source(i)).then((e=>{r.context.aborted||(r.done=e||null,this.scheduleAccept())}),(e=>{this.view.dispatch({effects:Rr.of(null)}),(0,c.logException)(this.view.state,e)}))}scheduleAccept(){this.running.every((e=>void 0!==e.done))?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout((()=>this.accept()),50))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],n=this.view.state.facet(kr);for(let i=0;i<this.running.length;i++){let r=this.running[i];if(void 0===r.done)continue;if(this.running.splice(i--,1),r.done){let i=new Tr(r.active.source,r.active.explicitPos,r.done,r.done.from,null!==(e=r.done.to)&&void 0!==e?e:mr(r.updates.length?r.updates[0].startState:this.view.state));for(let e of r.updates)i=i.update(e,n);if(i.hasResult()){t.push(i);continue}}let o=this.view.state.field(Fr).active.find((e=>e.source==r.active.source));if(o&&1==o.state)if(null==r.done){let e=new Br(r.active.source,0);for(let t of r.updates)e=e.update(t,n);1!=e.state&&t.push(e)}else this.startQuery(o)}t.length&&this.view.dispatch({effects:Lr.of(t)})}},{eventHandlers:{blur(){let e=this.view.state.field(Fr,!1);e&&e.tooltip&&this.view.state.facet(kr).closeOnBlur&&this.view.dispatch({effects:Rr.of(null)})},compositionstart(){this.composing=1},compositionend(){3==this.composing&&setTimeout((()=>this.view.dispatch({effects:Nr.of(!1)})),20),this.composing=0}}}),qr=c.EditorView.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",listStyle:"none",margin:0,padding:0,"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer",padding:"1px 3px",lineHeight:1.2}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"\xb7\xb7\xb7"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'\u0192'"}},".cm-completionIcon-class":{"&:after":{content:"'\u25cb'"}},".cm-completionIcon-interface":{"&:after":{content:"'\u25cc'"}},".cm-completionIcon-variable":{"&:after":{content:"'\ud835\udc65'"}},".cm-completionIcon-constant":{"&:after":{content:"'\ud835\udc36'"}},".cm-completionIcon-type":{"&:after":{content:"'\ud835\udc61'"}},".cm-completionIcon-enum":{"&:after":{content:"'\u222a'"}},".cm-completionIcon-property":{"&:after":{content:"'\u25a1'"}},".cm-completionIcon-keyword":{"&:after":{content:"'\ud83d\udd11\ufe0e'"}},".cm-completionIcon-namespace":{"&:after":{content:"'\u25a2'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});const zr={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Ur=a.StateEffect.define({map(e,t){let n=t.mapPos(e,-1,a.MapMode.TrackAfter);return null==n?void 0:n}}),$r=a.StateEffect.define({map:(e,t)=>t.mapPos(e)}),Hr=new class extends a.RangeValue{};Hr.startSide=1,Hr.endSide=-1;const Jr=a.StateField.define({create:()=>a.RangeSet.empty,update(e,t){if(t.selection){let n=t.state.doc.lineAt(t.selection.main.head).from,i=t.startState.doc.lineAt(t.startState.selection.main.head).from;n!=t.changes.mapPos(i,-1)&&(e=a.RangeSet.empty)}e=e.map(t.changes);for(let n of t.effects)n.is(Ur)?e=e.update({add:[Hr.range(n.value,n.value+1)]}):n.is($r)&&(e=e.update({filter:e=>e!=n.value}));return e}});const Gr="()[]{}<>";function Kr(e){for(let t=0;t<Gr.length;t+=2)if(Gr.charCodeAt(t)==e)return Gr.charAt(t+1);return(0,a.fromCodePoint)(e<128?e:e+1)}function Qr(e,t){return e.languageDataAt("closeBrackets",t)[0]||zr}const Yr="object"==typeof navigator&&/Android\b/.test(navigator.userAgent),Xr=c.EditorView.inputHandler.of(((e,t,n,i)=>{if((Yr?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let r=e.state.selection.main;if(i.length>2||2==i.length&&1==(0,a.codePointSize)((0,a.codePointAt)(i,0))||t!=r.from||n!=r.to)return!1;let o=function(e,t){let n=Qr(e,e.selection.main.head),i=n.brackets||zr.brackets;for(let r of i){let o=Kr((0,a.codePointAt)(r,0));if(t==r)return o==r?ro(e,r,i.indexOf(r+r+r)>-1,n):no(e,r,o,n.before||zr.before);if(t==o&&eo(e,e.selection.main.from))return io(e,r,o)}return null}(e.state,i);return!!o&&(e.dispatch(o),!0)})),Zr=[{key:"Backspace",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Qr(e,e.selection.main.head).brackets||zr.brackets,i=null,r=e.changeByRange((t=>{if(t.empty){let i=function(e,t){let n=e.sliceString(t-2,t);return(0,a.codePointSize)((0,a.codePointAt)(n,0))==n.length?n:n.slice(1)}(e.doc,t.head);for(let r of n)if(r==i&&to(e.doc,t.head)==Kr((0,a.codePointAt)(r,0)))return{changes:{from:t.head-r.length,to:t.head+r.length},range:a.EditorSelection.cursor(t.head-r.length)}}return{range:i=t}}));return i||t(e.update(r,{scrollIntoView:!0,userEvent:"delete.backward"})),!i}}];function eo(e,t){let n=!1;return e.field(Jr).between(0,e.doc.length,(e=>{e==t&&(n=!0)})),n}function to(e,t){let n=e.sliceString(t,t+2);return n.slice(0,(0,a.codePointSize)((0,a.codePointAt)(n,0)))}function no(e,t,n,i){let r=null,o=e.changeByRange((o=>{if(!o.empty)return{changes:[{insert:t,from:o.from},{insert:n,from:o.to}],effects:Ur.of(o.to+t.length),range:a.EditorSelection.range(o.anchor+t.length,o.head+t.length)};let s=to(e.doc,o.head);return!s||/\s/.test(s)||i.indexOf(s)>-1?{changes:{insert:t+n,from:o.head},effects:Ur.of(o.head+t.length),range:a.EditorSelection.cursor(o.head+t.length)}:{range:r=o}}));return r?null:e.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function io(e,t,n){let i=null,r=e.selection.ranges.map((t=>t.empty&&to(e.doc,t.head)==n?a.EditorSelection.cursor(t.head+n.length):i=t));return i?null:e.update({selection:a.EditorSelection.create(r,e.selection.mainIndex),scrollIntoView:!0,effects:e.selection.ranges.map((({from:e})=>$r.of(e)))})}function ro(e,t,n,i){let r=i.stringPrefixes||zr.stringPrefixes,o=null,s=e.changeByRange((i=>{if(!i.empty)return{changes:[{insert:t,from:i.from},{insert:t,from:i.to}],effects:Ur.of(i.to+t.length),range:a.EditorSelection.range(i.anchor+t.length,i.head+t.length)};let s,l=i.head,c=to(e.doc,l);if(c==t){if(oo(e,l))return{changes:{insert:t+t,from:l},effects:Ur.of(l+t.length),range:a.EditorSelection.cursor(l+t.length)};if(eo(e,l)){let i=n&&e.sliceDoc(l,l+3*t.length)==t+t+t;return{range:a.EditorSelection.cursor(l+t.length*(i?3:1)),effects:$r.of(l)}}}else{if(n&&e.sliceDoc(l-2*t.length,l)==t+t&&(s=so(e,l-2*t.length,r))>-1&&oo(e,s))return{changes:{insert:t+t+t+t,from:l},effects:Ur.of(l+t.length),range:a.EditorSelection.cursor(l+t.length)};if(e.charCategorizer(l)(c)!=a.CharCategory.Word&&so(e,l,r)>-1&&!function(e,t,n,i){let r=we(e).resolveInner(t,-1),o=i.reduce(((e,t)=>Math.max(e,t.length)),0);for(let s=0;s<5;s++){let s=e.sliceDoc(r.from,Math.min(r.to,r.from+n.length+o)),l=s.indexOf(n);if(!l||l>-1&&i.indexOf(s.slice(0,l))>-1){let t=r.firstChild;for(;t&&t.from==r.from&&t.to-t.from>n.length+l;){if(e.sliceDoc(t.to-n.length,t.to)==n)return!1;t=t.firstChild}return!0}let a=r.to==t&&r.parent;if(!a)break;r=a}return!1}(e,l,t,r))return{changes:{insert:t+t,from:l},effects:Ur.of(l+t.length),range:a.EditorSelection.cursor(l+t.length)}}return{range:o=i}}));return o?null:e.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function oo(e,t){let n=we(e).resolveInner(t+1);return n.parent&&n.from==t}function so(e,t,n){let i=e.charCategorizer(t);if(i(e.sliceDoc(t-1,t))!=a.CharCategory.Word)return t;for(let r of n){let n=t-r.length;if(e.sliceDoc(n,t)==r&&i(e.sliceDoc(n-1,n))!=a.CharCategory.Word)return n}return-1}const lo=[{key:"Ctrl-Space",run:e=>!!e.state.field(Fr,!1)&&(e.dispatch({effects:Nr.of(!0)}),!0)},{key:"Escape",run:e=>{let t=e.state.field(Fr,!1);return!(!t||!t.active.some((e=>0!=e.state)))&&(e.dispatch({effects:Rr.of(null)}),!0)}},{key:"ArrowDown",run:Wr(!0)},{key:"ArrowUp",run:Wr(!1)},{key:"PageDown",run:Wr(!0,"page")},{key:"PageUp",run:Wr(!1,"page")},{key:"Enter",run:e=>{let t=e.state.field(Fr,!1);return!(e.state.readOnly||!t||!t.open||t.open.selected<0||Date.now()-t.open.timestamp<e.state.facet(kr).interactionDelay)&&(t.open.disabled||vr(e,t.open.options[t.open.selected]),!0)}}],ao=a.Prec.highest(c.keymap.computeN([kr],(e=>e.facet(kr).defaultKeymap?[lo]:[])));class co{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}}class ho{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(e,t,n){let i=e,r=n.facet(Ao).markerFilter;r&&(i=r(i));let o=c.Decoration.set(i.map((e=>e.from==e.to||e.from==e.to-1&&n.doc.lineAt(e.from).to==e.from?c.Decoration.widget({widget:new Do(e),diagnostic:e}).range(e.from):c.Decoration.mark({attributes:{class:"cm-lintRange cm-lintRange-"+e.severity},diagnostic:e}).range(e.from,e.to))),!0);return new ho(o,t,uo(o))}}function uo(e,t=null,n=0){let i=null;return e.between(n,1e9,((e,n,{spec:r})=>{if(!t||r.diagnostic==t)return i=new co(e,n,r.diagnostic),!1})),i}function fo(e,t){return!(!e.effects.some((e=>e.is(mo)))&&!e.changes.touchesRange(t.pos))}function po(e,t){return e.field(vo,!1)?t:t.concat(a.StateEffect.appendConfig.of([vo,c.EditorView.decorations.compute([vo],(e=>{let{selected:t,panel:n}=e.field(vo);return t&&n&&t.from!=t.to?c.Decoration.set([bo.range(t.from,t.to)]):c.Decoration.none})),(0,c.hoverTooltip)(wo,{hideOn:fo}),To]))}const mo=a.StateEffect.define(),go=a.StateEffect.define(),yo=a.StateEffect.define(),vo=a.StateField.define({create:()=>new ho(c.Decoration.none,null,null),update(e,t){if(t.docChanged){let n=e.diagnostics.map(t.changes),i=null;if(e.selected){let r=t.changes.mapPos(e.selected.from,1);i=uo(n,e.selected.diagnostic,r)||uo(n,null,r)}e=new ho(n,e.panel,i)}for(let n of t.effects)n.is(mo)?e=ho.init(n.value,e.panel,t.state):n.is(go)?e=new ho(e.diagnostics,n.value?Po.open:null,e.selected):n.is(yo)&&(e=new ho(e.diagnostics,e.panel,n.value));return e},provide:e=>[c.showPanel.from(e,(e=>e.panel)),c.EditorView.decorations.from(e,(e=>e.diagnostics))]});const bo=c.Decoration.mark({class:"cm-lintRange cm-lintRange-active"});function wo(e,t,n){let{diagnostics:i}=e.state.field(vo),r=[],o=2e8,s=0;i.between(t-(n<0?1:0),t+(n>0?1:0),((e,i,{spec:l})=>{t>=e&&t<=i&&(e==i||(t>e||n>0)&&(t<i||n<0))&&(r.push(l.diagnostic),o=Math.min(e,o),s=Math.max(i,s))}));let l=e.state.facet(Ao).tooltipFilter;return l&&(r=l(r)),r.length?{pos:o,end:s,above:e.state.doc.lineAt(o).to<s,create:()=>({dom:xo(e,r)})}:null}function xo(e,t){return hi("ul",{class:"cm-tooltip-lint"},t.map((t=>Oo(e,t,!1))))}const ko=e=>{let t=e.state.field(vo,!1);return!(!t||!t.panel)&&(e.dispatch({effects:go.of(!1)}),!0)},So=[{key:"Mod-Shift-m",run:e=>{let t=e.state.field(vo,!1);t&&t.panel||e.dispatch({effects:po(e.state,[go.of(!0)])});let n=(0,c.getPanel)(e,Po.open);return n&&n.dom.querySelector(".cm-panel-lint ul").focus(),!0},preventDefault:!0},{key:"F8",run:e=>{let t=e.state.field(vo,!1);if(!t)return!1;let n=e.state.selection.main,i=t.diagnostics.iter(n.to+1);return!(!i.value&&(i=t.diagnostics.iter(0),!i.value||i.from==n.from&&i.to==n.to))&&(e.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0}),!0)}}],Co=c.ViewPlugin.fromClass(class{constructor(e){this.view=e,this.timeout=-1,this.set=!0;let{delay:t}=e.state.facet(Ao);this.lintTime=Date.now()+t,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,t)}run(){let e=Date.now();if(e<this.lintTime-10)setTimeout(this.run,this.lintTime-e);else{this.set=!1;let{state:e}=this.view,{sources:t}=e.facet(Ao);Promise.all(t.map((e=>Promise.resolve(e(this.view))))).then((t=>{let n=t.reduce(((e,t)=>e.concat(t)));this.view.state.doc==e.doc&&this.view.dispatch(function(e,t){return{effects:po(e,[mo.of(t)])}}(this.view.state,n))}),(e=>{(0,c.logException)(this.view.state,e)}))}}update(e){let t=e.state.facet(Ao);(e.docChanged||t!=e.startState.facet(Ao))&&(this.lintTime=Date.now()+t.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,t.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}}),Ao=a.Facet.define({combine:e=>Object.assign({sources:e.map((e=>e.source))},(0,a.combineConfig)(e.map((e=>e.config)),{delay:750,markerFilter:null,tooltipFilter:null})),enables:Co});function Eo(e){let t=[];if(e)e:for(let{name:n}of e){for(let e=0;e<n.length;e++){let i=n[e];if(/[a-zA-Z]/.test(i)&&!t.some((e=>e.toLowerCase()==i.toLowerCase()))){t.push(i);continue e}}t.push("")}return t}function Oo(e,t,n){var i;let r=n?Eo(t.actions):[];return hi("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},hi("span",{class:"cm-diagnosticText"},t.renderMessage?t.renderMessage():t.message),null===(i=t.actions)||void 0===i?void 0:i.map(((n,i)=>{let o=i=>{i.preventDefault();let r=uo(e.state.field(vo).diagnostics,t);r&&n.apply(e,r.from,r.to)},{name:s}=n,l=r[i]?s.indexOf(r[i]):-1,a=l<0?s:[s.slice(0,l),hi("u",s.slice(l,l+1)),s.slice(l+1)];return hi("button",{type:"button",class:"cm-diagnosticAction",onclick:o,onmousedown:o,"aria-label":` Action: ${s}${l<0?"":` (access key "${r[i]})"`}.`},a)})),t.source&&hi("div",{class:"cm-diagnosticSource"},t.source))}class Do extends c.WidgetType{constructor(e){super(),this.diagnostic=e}eq(e){return e.diagnostic==this.diagnostic}toDOM(){return hi("span",{class:"cm-lintPoint cm-lintPoint-"+this.diagnostic.severity})}}class Mo{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(4294967295*Math.random()).toString(16),this.dom=Oo(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class Po{constructor(e){this.view=e,this.items=[];this.list=hi("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t=>{if(27==t.keyCode)ko(this.view),this.view.focus();else if(38==t.keyCode||33==t.keyCode)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(40==t.keyCode||34==t.keyCode)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(36==t.keyCode)this.moveSelection(0);else if(35==t.keyCode)this.moveSelection(this.items.length-1);else if(13==t.keyCode)this.view.focus();else{if(!(t.keyCode>=65&&t.keyCode<=90&&this.selectedIndex>=0))return;{let{diagnostic:n}=this.items[this.selectedIndex],i=Eo(n.actions);for(let r=0;r<i.length;r++)if(i[r].toUpperCase().charCodeAt(0)==t.keyCode){let t=uo(this.view.state.field(vo).diagnostics,n);t&&n.actions[r].apply(e,t.from,t.to)}}}t.preventDefault()},onclick:e=>{for(let t=0;t<this.items.length;t++)this.items[t].dom.contains(e.target)&&this.moveSelection(t)}}),this.dom=hi("div",{class:"cm-panel-lint"},this.list,hi("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>ko(this.view)},"\xd7")),this.update()}get selectedIndex(){let e=this.view.state.field(vo).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(vo),n=0,i=!1,r=null;for(e.between(0,this.view.state.doc.length,((e,o,{spec:s})=>{let l,a=-1;for(let t=n;t<this.items.length;t++)if(this.items[t].diagnostic==s.diagnostic){a=t;break}a<0?(l=new Mo(this.view,s.diagnostic),this.items.splice(n,0,l),i=!0):(l=this.items[a],a>n&&(this.items.splice(n,a-n),i=!0)),t&&l.diagnostic==t.diagnostic?l.dom.hasAttribute("aria-selected")||(l.dom.setAttribute("aria-selected","true"),r=l):l.dom.hasAttribute("aria-selected")&&l.dom.removeAttribute("aria-selected"),n++}));n<this.items.length&&!(1==this.items.length&&this.items[0].diagnostic.from<0);)i=!0,this.items.pop();0==this.items.length&&(this.items.push(new Mo(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),i=!0),r?(this.list.setAttribute("aria-activedescendant",r.id),this.view.requestMeasure({key:this,read:()=>({sel:r.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{e.top<t.top?this.list.scrollTop-=t.top-e.top:e.bottom>t.bottom&&(this.list.scrollTop+=e.bottom-t.bottom)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),i&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=uo(this.view.state.field(vo).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:yo.of(t)})}static open(e){return new Po(e)}}function Io(e,t='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}function Bo(e){return Io(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const To=c.EditorView.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:Bo("#d11")},".cm-lintRange-warning":{backgroundImage:Bo("orange")},".cm-lintRange-info":{backgroundImage:Bo("#999")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}});class No extends c.GutterMarker{constructor(e){super(),this.diagnostics=e,this.severity=e.reduce(((e,t)=>{let n=t.severity;return"error"==n||"warning"==n&&"info"==e?n:e}),"info")}toDOM(e){let t=document.createElement("div");t.className="cm-lint-marker cm-lint-marker-"+this.severity;let n=this.diagnostics,i=e.state.facet(lintGutterConfig).tooltipFilter;return i&&i(n),n.length&&(t.onmouseover=()=>function(e,t,n){function i(){let i=e.elementAtHeight(t.getBoundingClientRect().top+5-e.documentTop);e.coordsAtPos(i.from)&&e.dispatch({effects:setLintGutterTooltip.of({pos:i.from,above:!1,create:()=>({dom:xo(e,n),getCoords:()=>t.getBoundingClientRect()})})}),t.onmouseout=t.onmousemove=null,function(e,t){let n=i=>{let r=t.getBoundingClientRect();if(!(i.clientX>r.left-10&&i.clientX<r.right+10&&i.clientY>r.top-10&&i.clientY<r.bottom+10)){for(let e=i.target;e;e.parentNode)if(1==e.nodeType&&e.classList.contains("cm-tooltip-lint"))return;window.removeEventListener("mousemove",n),e.state.field(lintGutterTooltip)&&e.dispatch({effects:setLintGutterTooltip.of(null)})}};window.addEventListener("mousemove",n)}(e,t)}let{hoverTime:r}=e.state.facet(lintGutterConfig),o=setTimeout(i,r);t.onmouseout=()=>{clearTimeout(o),t.onmouseout=t.onmousemove=null},t.onmousemove=()=>{clearTimeout(o),setTimeout(i,r)}}(e,t,n)),t}}var Ro=function(e){void 0===e&&(e={});var t=[];!1!==e.closeBracketsKeymap&&(t=t.concat(Zr)),!1!==e.defaultKeymap&&(t=t.concat(ai)),!1!==e.searchKeymap&&(t=t.concat(rr)),!1!==e.historyKeymap&&(t=t.concat(hn)),!1!==e.foldKeymap&&(t=t.concat(nt)),!1!==e.completionKeymap&&(t=t.concat(lo)),!1!==e.lintKeymap&&(t=t.concat(So));var n=[];return!1!==e.lineNumbers&&n.push((0,c.lineNumbers)()),!1!==e.highlightActiveLineGutter&&n.push((0,c.highlightActiveLineGutter)()),!1!==e.highlightSpecialChars&&n.push((0,c.highlightSpecialChars)()),!1!==e.history&&n.push(Jt()),!1!==e.foldGutter&&n.push(function(e={}){let t=Object.assign(Object.assign({},lt),e),n=new at(t,!0),i=new at(t,!1),r=c.ViewPlugin.fromClass(class{constructor(e){this.from=e.viewport.from,this.markers=this.buildMarkers(e)}update(e){(e.docChanged||e.viewportChanged||e.startState.facet(Me)!=e.state.facet(Me)||e.startState.field(Ye,!1)!=e.state.field(Ye,!1)||we(e.startState)!=we(e.state)||t.foldingChanged(e))&&(this.markers=this.buildMarkers(e.view))}buildMarkers(e){let t=new a.RangeSetBuilder;for(let r of e.viewportLineBlocks){let o=Xe(e.state,r.from,r.to)?i:He(e.state,r.from,r.to)?n:null;o&&t.add(r.from,r.from,o)}return t.finish()}}),{domEventHandlers:o}=t;return[r,(0,c.gutter)({class:"cm-foldGutter",markers(e){var t;return(null===(t=e.plugin(r))||void 0===t?void 0:t.markers)||a.RangeSet.empty},initialSpacer:()=>new at(t,!1),domEventHandlers:Object.assign(Object.assign({},o),{click:(e,t,n)=>{if(o.click&&o.click(e,t,n))return!0;let i=Xe(e.state,t.from,t.to);if(i)return e.dispatch({effects:Ke.of(i)}),!0;let r=He(e.state,t.from,t.to);return!!r&&(e.dispatch({effects:Ge.of(r)}),!0)}})}),ot()]}()),!1!==e.drawSelection&&n.push((0,c.drawSelection)()),!1!==e.dropCursor&&n.push((0,c.dropCursor)()),!1!==e.allowMultipleSelections&&n.push(a.EditorState.allowMultipleSelections.of(!0)),!1!==e.indentOnInput&&n.push(a.EditorState.transactionFilter.of((e=>{if(!e.docChanged||!e.isUserEvent("input.type")&&!e.isUserEvent("input.complete"))return e;let t=e.startState.languageDataAt("indentOnInput",e.startState.selection.main.head);if(!t.length)return e;let n=e.newDoc,{head:i}=e.newSelection.main,r=n.lineAt(i);if(i>r.from+200)return e;let o=n.sliceString(r.from,i);if(!t.some((e=>e.test(o))))return e;let{state:s}=e,l=-1,a=[];for(let{head:c}of s.selection.ranges){let e=s.doc.lineAt(c);if(e.from==l)continue;l=e.from;let t=Ne(s,e.from);if(null==t)continue;let n=/^\s*/.exec(e.text)[0],i=Te(s,t);n!=i&&a.push({from:e.from,to:e.from+n.length,insert:i})}return a.length?[e,{changes:a,sequential:!0}]:e}))),!1!==e.syntaxHighlighting&&n.push(pt(yt,{fallback:!0})),!1!==e.bracketMatching&&n.push(function(e={}){return[wt.of(e),At]}()),!1!==e.closeBrackets&&n.push([Xr,Jr]),!1!==e.autocompletion&&n.push(function(e={}){return[Fr,kr.of(e),jr,ao,qr]}()),!1!==e.rectangularSelection&&n.push((0,c.rectangularSelection)()),!1!==e.crosshairCursor&&n.push((0,c.crosshairCursor)()),!1!==e.highlightActiveLine&&n.push((0,c.highlightActiveLine)()),!1!==e.highlightSelectionMatches&&n.push(function(e){let t=[Ii,Pi];return e&&t.push(Ei.of(e)),t}()),e.tabSize&&"number"===typeof e.tabSize&&n.push(Ie.of(" ".repeat(e.tabSize))),n.concat([c.keymap.of(t.flat())]).filter(Boolean)},Lo=function(e){void 0===e&&(e={});var t=[];!1!==e.defaultKeymap&&(t=t.concat(ai)),!1!==e.historyKeymap&&(t=t.concat(hn));var n=[];return!1!==e.highlightSpecialChars&&n.push((0,c.highlightSpecialChars)()),!1!==e.history&&n.push(Jt()),!1!==e.drawSelection&&n.push((0,c.drawSelection)()),!1!==e.syntaxHighlighting&&n.push(pt(yt,{fallback:!0})),n.concat([c.keymap.of(t.flat())]).filter(Boolean)},_o=s(362),Fo=function(e){return{line:e.state.doc.lineAt(e.state.selection.main.from),lineCount:e.state.doc.lines,lineBreak:e.state.lineBreak,length:e.state.doc.length,readOnly:e.state.readOnly,tabSize:e.state.tabSize,selection:e.state.selection,selectionAsSingle:e.state.selection.asSingle().main,ranges:e.state.selection.ranges,selectionCode:e.state.sliceDoc(e.state.selection.main.from,e.state.selection.main.to),selections:e.state.selection.ranges.map((function(t){return e.state.sliceDoc(t.from,t.to)})),selectedText:e.state.selection.ranges.some((function(e){return!e.empty}))}};function Wo(e){var t=e.value,n=e.selection,r=e.onChange,s=e.onStatistics,l=e.onCreateEditor,h=e.onUpdate,u=e.extensions,f=void 0===u?[]:u,d=e.autoFocus,p=e.theme,m=void 0===p?"light":p,g=e.height,y=void 0===g?"":g,v=e.minHeight,b=void 0===v?"":v,w=e.maxHeight,x=void 0===w?"":w,k=e.placeholder,S=void 0===k?"":k,C=e.width,A=void 0===C?"":C,E=e.minWidth,O=void 0===E?"":E,D=e.maxWidth,M=void 0===D?"":D,P=e.editable,I=void 0===P||P,B=e.readOnly,T=void 0!==B&&B,N=e.indentWithTab,R=void 0===N||N,L=e.basicSetup,_=void 0===L||L,F=e.root,W=e.initialState,V=o((0,i.useState)(),2),j=V[0],q=V[1],z=o((0,i.useState)(),2),U=z[0],$=z[1],H=o((0,i.useState)(),2),J=H[0],G=H[1],K=c.EditorView.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),Q=c.EditorView.theme({"&":{height:y,minHeight:b,maxHeight:x,width:A,minWidth:O,maxWidth:M}}),Y=[c.EditorView.updateListener.of((function(e){if(e.docChanged&&"function"===typeof r){var t=e.state.doc.toString();r(t,e)}s&&s(Fo(e))})),Q];switch(R&&Y.unshift(c.keymap.of([ci])),_&&("boolean"===typeof _?Y.unshift(Ro()):Y.unshift(Ro(_))),S&&Y.unshift((0,c.placeholder)(S)),m){case"light":Y.push(K);break;case"dark":Y.push(_o.oneDark);break;default:Y.push(m)}return!1===I&&Y.push(c.EditorView.editable.of(!1)),T&&Y.push(a.EditorState.readOnly.of(!0)),h&&"function"===typeof h&&Y.push(c.EditorView.updateListener.of(h)),Y=Y.concat(f),(0,i.useEffect)((function(){if(j&&!J){var e={doc:t,selection:n,extensions:Y},i=W?a.EditorState.fromJSON(W.json,e,W.fields):a.EditorState.create(e);if(G(i),!U){var r=new c.EditorView({state:i,parent:j,root:F});$(r),l&&l(r,i)}}return function(){U&&(G(void 0),$(void 0))}}),[j,J]),(0,i.useEffect)((function(){return q(e.container)}),[e.container]),(0,i.useEffect)((function(){return function(){U&&(U.destroy(),$(void 0))}}),[U]),(0,i.useEffect)((function(){d&&U&&U.focus()}),[d,U]),(0,i.useEffect)((function(){U&&U.dispatch({effects:a.StateEffect.reconfigure.of(Y)})}),[m,f,y,b,x,A,O,M,S,I,T,R,_,r,h]),(0,i.useEffect)((function(){var e=U?U.state.doc.toString():"";U&&t!==e&&U.dispatch({changes:{from:0,to:e.length,insert:t||""}})}),[t,U]),{state:J,setState:G,view:U,setView:$,container:j,setContainer:q}}var Vo=s(605),jo=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],qo=(0,i.forwardRef)((function(r,o){var s=r.className,l=r.value,a=void 0===l?"":l,c=r.selection,h=r.extensions,u=void 0===h?[]:h,f=r.onChange,d=r.onStatistics,p=r.onCreateEditor,m=r.onUpdate,g=r.autoFocus,y=r.theme,v=void 0===y?"light":y,b=r.height,w=r.minHeight,x=r.maxHeight,k=r.width,S=r.minWidth,C=r.maxWidth,A=r.basicSetup,E=r.placeholder,O=r.indentWithTab,D=r.editable,M=r.readOnly,P=r.root,I=r.initialState,B=n(r,jo),T=(0,i.useRef)(null),N=Wo({container:T.current,root:P,value:a,autoFocus:g,theme:v,height:b,minHeight:w,maxHeight:x,width:k,minWidth:S,maxWidth:C,basicSetup:A,placeholder:E,indentWithTab:O,editable:D,readOnly:M,selection:c,onChange:f,onStatistics:d,onCreateEditor:p,onUpdate:m,extensions:u,initialState:I}),R=N.state,L=N.view,_=N.container;N.setContainer;if((0,i.useImperativeHandle)(o,(function(){return{editor:T.current,state:R,view:L}}),[T,_,R,L]),"string"!==typeof a)throw new Error("value must be typeof string but got ".concat(typeof a));var F="string"===typeof v?"cm-theme-".concat(v):"cm-theme";return(0,Vo.jsx)("div",function(n){for(var i=1;i<arguments.length;i++){var r=null!=arguments[i]?arguments[i]:{};i%2?t(Object(r),!0).forEach((function(t){e(n,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(r)):t(Object(r)).forEach((function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(r,e))}))}return n}({ref:T,className:"".concat(F).concat(s?" ".concat(s):"")},B))}));qo.displayName="CodeMirror";const zo=qo})(),l})()));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uiw/react-codemirror",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.14.0",
|
|
4
4
|
"description": "CodeMirror component for React.",
|
|
5
5
|
"homepage": "https://uiwjs.github.io/react-codemirror",
|
|
6
6
|
"author": "kenny wong <wowohoo@qq.com>",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@codemirror/commands": "^6.1.0",
|
|
41
41
|
"@codemirror/state": "^6.1.1",
|
|
42
42
|
"@codemirror/theme-one-dark": "^6.0.0",
|
|
43
|
-
"@uiw/codemirror-extensions-basic-setup": "4.
|
|
43
|
+
"@uiw/codemirror-extensions-basic-setup": "4.14.0",
|
|
44
44
|
"codemirror": "^6.0.0"
|
|
45
45
|
},
|
|
46
46
|
"keywords": [
|