import { A as e, At as t, Ct as n, Dt as r, E as i, Ft as a, G as o, It as s, J as c, K as l, L as u, Mt as d, Nt as f, O as p, Ot as m, P as h, Pt as ee, Q as te, S as ne, T as g, Tt as re, W as _, X as ie, Z as ae, _t as v, at as oe, bt as y, ct as se, dt as ce, f as le, gt as ue, ht as de, j as fe, jt as pe, kt as me, l as he, lt as ge, mt as _e, n as ve, nt as ye, ot as be, pt as b, rt as xe, t as Se, tt as Ce, ut as we, vt as Te, w as Ee, x as De, xt as x, yt as S } from "./dist-DgSmYkuV.js";
import { i as Oe, r as ke } from "./dist-CC_emMZy.js";
//#region node_modules/@codemirror/commands/dist/index.js
var Ae = (e) => {
	let { state: t } = e, n = t.doc.lineAt(t.selection.main.from), r = Fe(e.state, n.from);
	return r.line ? Me(e) : r.block ? Pe(e) : !1;
};
function je(e, t) {
	return ({ state: n, dispatch: r }) => {
		if (n.readOnly) return !1;
		let i = e(t, n);
		return i ? (r(n.update(i)), !0) : !1;
	};
}
var Me = /* @__PURE__ */ je(ze, 0), Ne = /* @__PURE__ */ je(Re, 0), Pe = /* @__PURE__ */ je((e, t) => Re(e, t, Le(t)), 0);
function Fe(e, t) {
	let n = e.languageDataAt("commentTokens", t, 1);
	return n.length ? n[0] : {};
}
var C = 50;
function Ie(e, { open: t, close: n }, r, i) {
	let a = e.sliceDoc(r - C, r), o = e.sliceDoc(i, i + C), s = /\s*$/.exec(a)[0].length, c = /^\s*/.exec(o)[0].length, l = a.length - s;
	if (a.slice(l - t.length, l) == t && o.slice(c, c + n.length) == n) return {
		open: {
			pos: r - s,
			margin: s && 1
		},
		close: {
			pos: i + c,
			margin: c && 1
		}
	};
	let u, d;
	i - r <= 2 * C ? u = d = e.sliceDoc(r, i) : (u = e.sliceDoc(r, r + C), d = e.sliceDoc(i - C, i));
	let f = /^\s*/.exec(u)[0].length, p = /\s*$/.exec(d)[0].length, m = d.length - p - n.length;
	return u.slice(f, f + t.length) == t && d.slice(m, m + n.length) == n ? {
		open: {
			pos: r + f + t.length,
			margin: /\s/.test(u.charAt(f + t.length)) ? 1 : 0
		},
		close: {
			pos: i - p - n.length,
			margin: /\s/.test(d.charAt(m - 1)) ? 1 : 0
		}
	} : null;
}
function Le(e) {
	let t = [];
	for (let n of e.selection.ranges) {
		let r = e.doc.lineAt(n.from), i = n.to <= r.to ? r : e.doc.lineAt(n.to);
		i.from > r.from && i.from == n.to && (i = n.to == r.to + 1 ? r : e.doc.lineAt(n.to - 1));
		let a = t.length - 1;
		a >= 0 && t[a].to > r.from ? t[a].to = i.to : t.push({
			from: r.from + /^\s*/.exec(r.text)[0].length,
			to: i.to
		});
	}
	return t;
}
function Re(e, t, n = t.selection.ranges) {
	let r = n.map((e) => Fe(t, e.from).block);
	if (!r.every((e) => e)) return null;
	let i = n.map((e, n) => Ie(t, r[n], e.from, e.to));
	if (e != 2 && !i.every((e) => e)) return { changes: t.changes(n.map((e, t) => i[t] ? [] : [{
		from: e.from,
		insert: r[t].open + " "
	}, {
		from: e.to,
		insert: " " + r[t].close
	}])) };
	if (e != 1 && i.some((e) => e)) {
		let e = [];
		for (let t = 0, n; t < i.length; t++) if (n = i[t]) {
			let i = r[t], { open: a, close: o } = n;
			e.push({
				from: a.pos - i.open.length,
				to: a.pos + a.margin
			}, {
				from: o.pos - o.margin,
				to: o.pos + i.close.length
			});
		}
		return { changes: e };
	}
	return null;
}
function ze(e, t, n = t.selection.ranges) {
	let r = [], i = -1;
	ranges: for (let { from: e, to: a } of n) {
		let n = r.length, o = 1e9, s;
		for (let n = e; n <= a;) {
			let c = t.doc.lineAt(n);
			if (s == null && (s = Fe(t, c.from).line, !s)) continue ranges;
			if (c.from > i && (e == a || a > c.from)) {
				i = c.from;
				let e = /^\s*/.exec(c.text)[0].length, t = e == c.length, n = c.text.slice(e, e + s.length) == s ? e : -1;
				e < c.text.length && e < o && (o = e), r.push({
					line: c,
					comment: n,
					token: s,
					indent: e,
					empty: t,
					single: !1
				});
			}
			n = c.to + 1;
		}
		if (o < 1e9) for (let e = n; e < r.length; e++) r[e].indent < r[e].line.text.length && (r[e].indent = o);
		r.length == n + 1 && (r[n].single = !0);
	}
	if (e != 2 && r.some((e) => e.comment < 0 && (!e.empty || e.single))) {
		let e = [];
		for (let { line: t, token: n, indent: i, empty: a, single: o } of r) (o || !a) && e.push({
			from: t.from + i,
			insert: n + " "
		});
		let n = t.changes(e);
		return {
			changes: n,
			selection: t.selection.map(n, 1)
		};
	} else if (e != 1 && r.some((e) => e.comment >= 0)) {
		let e = [];
		for (let { line: t, comment: n, token: i } of r) if (n >= 0) {
			let r = t.from + n, a = r + i.length;
			t.text[a - t.from] == " " && a++, e.push({
				from: r,
				to: a
			});
		}
		return { changes: e };
	}
	return null;
}
var Be = /* @__PURE__ */ _e.define(), Ve = /* @__PURE__ */ _e.define(), He = /* @__PURE__ */ x.define(), Ue = /* @__PURE__ */ x.define({ combine(e) {
	return f(e, {
		minDepth: 100,
		newGroupDelay: 500,
		joinToEvent: (e, t) => t
	}, {
		minDepth: Math.max,
		newGroupDelay: Math.min,
		joinToEvent: (e, t) => (n, r) => e(n, r) || t(n, r)
	});
} }), We = /* @__PURE__ */ m.define({
	create() {
		return O.empty;
	},
	update(e, n) {
		let r = n.state.facet(Ue), i = n.annotation(Be);
		if (i) {
			let t = T.fromTransaction(n, i.selection), a = i.side, o = a == 0 ? e.undone : e.done;
			return o = t ? E(o, o.length, r.minDepth, t) : et(o, n.startState.selection), new O(a == 0 ? i.rest : o, a == 0 ? o : i.rest);
		}
		let a = n.annotation(Ve);
		if ((a == "full" || a == "before") && (e = e.isolate()), n.annotation(t.addToHistory) === !1) return n.changes.empty ? e : e.addMapping(n.changes.desc);
		let o = T.fromTransaction(n), s = n.annotation(t.time), c = n.annotation(t.userEvent);
		return o ? e = e.addChanges(o, s, c, r, n) : n.selection && (e = e.addSelection(n.startState.selection, s, c, r.newGroupDelay)), (a == "full" || a == "after") && (e = e.isolate()), e;
	},
	toJSON(e) {
		return {
			done: e.done.map((e) => e.toJSON()),
			undone: e.undone.map((e) => e.toJSON())
		};
	},
	fromJSON(e) {
		return new O(e.done.map(T.fromJSON), e.undone.map(T.fromJSON));
	}
});
function Ge(e = {}) {
	return [
		We,
		Ue.of(e),
		l.domEventHandlers({ beforeinput(e, t) {
			let n = e.inputType == "historyUndo" ? Ke : e.inputType == "historyRedo" ? qe : null;
			return n ? (e.preventDefault(), n(t)) : !1;
		} })
	];
}
function w(e, t) {
	return function({ state: n, dispatch: r }) {
		if (!t && n.readOnly) return !1;
		let i = n.field(We, !1);
		if (!i) return !1;
		let a = i.pop(e, n, t);
		return a ? (r(a), !0) : !1;
	};
}
var Ke = /* @__PURE__ */ w(0, !1), qe = /* @__PURE__ */ w(1, !1), Je = /* @__PURE__ */ w(0, !0), Ye = /* @__PURE__ */ w(1, !0), T = class e {
	constructor(e, t, n, r, i) {
		this.changes = e, this.effects = t, this.mapped = n, this.startSelection = r, this.selectionsAfter = i;
	}
	setSelAfter(t) {
		return new e(this.changes, this.effects, this.mapped, this.startSelection, t);
	}
	toJSON() {
		return {
			changes: this.changes?.toJSON(),
			mapped: this.mapped?.toJSON(),
			startSelection: this.startSelection?.toJSON(),
			selectionsAfter: this.selectionsAfter.map((e) => e.toJSON())
		};
	}
	static fromJSON(t) {
		return new e(t.changes && ue.fromJSON(t.changes), [], t.mapped && de.fromJSON(t.mapped), t.startSelection && S.fromJSON(t.startSelection), t.selectionsAfter.map(S.fromJSON));
	}
	static fromTransaction(t, n) {
		let r = D;
		for (let e of t.startState.facet(He)) {
			let n = e(t);
			n.length && (r = r.concat(n));
		}
		return !r.length && t.changes.empty ? null : new e(t.changes.invert(t.startState.doc), r, void 0, n || t.startState.selection, D);
	}
	static selection(t) {
		return new e(void 0, D, void 0, void 0, t);
	}
};
function E(e, t, n, r) {
	let i = t + 1 > n + 20 ? t - n - 1 : 0, a = e.slice(i, t);
	return a.push(r), a;
}
function Xe(e, t) {
	let n = [], r = !1;
	return e.iterChangedRanges((e, t) => n.push(e, t)), t.iterChangedRanges((e, t, i, a) => {
		for (let e = 0; e < n.length;) {
			let t = n[e++], o = n[e++];
			a >= t && i <= o && (r = !0);
		}
	}), r;
}
function Ze(e, t) {
	return e.ranges.length == t.ranges.length && e.ranges.filter((e, n) => e.empty != t.ranges[n].empty).length === 0;
}
function Qe(e, t) {
	return e.length ? t.length ? e.concat(t) : e : t;
}
var D = [], $e = 200;
function et(e, t) {
	if (e.length) {
		let n = e[e.length - 1], r = n.selectionsAfter.slice(Math.max(0, n.selectionsAfter.length - $e));
		return r.length && r[r.length - 1].eq(t) ? e : (r.push(t), E(e, e.length - 1, 1e9, n.setSelAfter(r)));
	} else return [T.selection([t])];
}
function tt(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 nt(e, t) {
	if (!e.length) return e;
	let n = e.length, r = D;
	for (; n;) {
		let i = rt(e[n - 1], t, r);
		if (i.changes && !i.changes.empty || i.effects.length) {
			let t = e.slice(0, n);
			return t[n - 1] = i, t;
		} else t = i.mapped, n--, r = i.selectionsAfter;
	}
	return r.length ? [T.selection(r)] : D;
}
function rt(e, t, n) {
	let i = Qe(e.selectionsAfter.length ? e.selectionsAfter.map((e) => e.map(t)) : D, n);
	if (!e.changes) return T.selection(i);
	let a = e.changes.map(t), o = t.mapDesc(e.changes, !0), s = e.mapped ? e.mapped.composeDesc(o) : o;
	return new T(a, r.mapEffects(e.effects, t), s, e.startSelection.map(o), i);
}
var it = /^(input\.type|delete)($|\.)/, O = class e {
	constructor(e, t, n = 0, r = void 0) {
		this.done = e, this.undone = t, this.prevTime = n, this.prevUserEvent = r;
	}
	isolate() {
		return this.prevTime ? new e(this.done, this.undone) : this;
	}
	addChanges(t, n, i, a, o) {
		let s = this.done, c = s[s.length - 1];
		return s = c && c.changes && !c.changes.empty && t.changes && (!i || it.test(i)) && (!c.selectionsAfter.length && n - this.prevTime < a.newGroupDelay && a.joinToEvent(o, Xe(c.changes, t.changes)) || i == "input.type.compose") ? E(s, s.length - 1, a.minDepth, new T(t.changes.compose(c.changes), Qe(r.mapEffects(t.effects, c.changes), c.effects), c.mapped, c.startSelection, D)) : E(s, s.length, a.minDepth, t), new e(s, D, n, i);
	}
	addSelection(t, n, r, i) {
		let a = this.done.length ? this.done[this.done.length - 1].selectionsAfter : D;
		return a.length > 0 && n - this.prevTime < i && r == this.prevUserEvent && r && /^select($|\.)/.test(r) && Ze(a[a.length - 1], t) ? this : new e(et(this.done, t), this.undone, n, r);
	}
	addMapping(t) {
		return new e(nt(this.done, t), nt(this.undone, t), this.prevTime, this.prevUserEvent);
	}
	pop(e, t, n) {
		let r = e == 0 ? this.done : this.undone;
		if (r.length == 0) return null;
		let i = r[r.length - 1], a = i.selectionsAfter[0] || (i.startSelection ? i.startSelection.map(i.changes.invertedDesc, 1) : t.selection);
		if (n && i.selectionsAfter.length) return t.update({
			selection: i.selectionsAfter[i.selectionsAfter.length - 1],
			annotations: Be.of({
				side: e,
				rest: tt(r),
				selection: a
			}),
			userEvent: e == 0 ? "select.undo" : "select.redo",
			scrollIntoView: !0
		});
		if (i.changes) {
			let n = r.length == 1 ? D : r.slice(0, r.length - 1);
			return i.mapped && (n = nt(n, i.mapped)), t.update({
				changes: i.changes,
				selection: i.startSelection,
				effects: i.effects,
				annotations: Be.of({
					side: e,
					rest: n,
					selection: a
				}),
				filter: !1,
				userEvent: e == 0 ? "undo" : "redo",
				scrollIntoView: !0
			});
		} else return null;
	}
};
O.empty = /* @__PURE__ */ new O(D, D);
var at = [
	{
		key: "Mod-z",
		run: Ke,
		preventDefault: !0
	},
	{
		key: "Mod-y",
		mac: "Mod-Shift-z",
		run: qe,
		preventDefault: !0
	},
	{
		linux: "Ctrl-Shift-z",
		run: qe,
		preventDefault: !0
	},
	{
		key: "Mod-u",
		run: Je,
		preventDefault: !0
	},
	{
		key: "Alt-u",
		mac: "Mod-Shift-u",
		run: Ye,
		preventDefault: !0
	}
];
function k(e, t) {
	return S.create(e.ranges.map(t), e.mainIndex);
}
function A(e, t) {
	return e.update({
		selection: t,
		scrollIntoView: !0,
		userEvent: "select"
	});
}
function j({ state: e, dispatch: t }, n) {
	let r = k(e.selection, n);
	return r.eq(e.selection, !0) ? !1 : (t(A(e, r)), !0);
}
function M(e, t) {
	return S.cursor(t ? e.to : e.from);
}
function ot(e, t) {
	return j(e, (n) => n.empty ? e.moveByChar(n, t) : M(n, t));
}
function N(e) {
	return e.textDirectionAt(e.state.selection.main.head) == o.LTR;
}
var st = (e) => ot(e, !N(e)), ct = (e) => ot(e, N(e));
function lt(e, t) {
	return j(e, (n) => n.empty ? e.moveByGroup(n, t) : M(n, t));
}
var ut = (e) => lt(e, !N(e)), dt = (e) => lt(e, N(e));
typeof Intl < "u" && Intl.Segmenter;
function ft(e, t, n) {
	if (t.type.prop(n)) return !0;
	let r = t.to - t.from;
	return r && (r > 2 || /[^\s,.;:]/.test(e.sliceDoc(t.from, t.to))) || t.firstChild;
}
function P(e, t, n) {
	let r = fe(e).resolveInner(t.head), i = n ? u.closedBy : u.openedBy;
	for (let a = t.head;;) {
		let t = n ? r.childAfter(a) : r.childBefore(a);
		if (!t) break;
		ft(e, t, i) ? r = t : a = n ? t.to : t.from;
	}
	let a = r.type.prop(i), o, s;
	return s = a && (o = n ? p(e, r.from, 1) : p(e, r.to, -1)) && o.matched ? n ? o.end.to : o.end.from : n ? r.to : r.from, S.cursor(s, n ? -1 : 1);
}
var pt = (e) => j(e, (t) => P(e.state, t, !N(e))), mt = (e) => j(e, (t) => P(e.state, t, N(e)));
function ht(e, t) {
	return j(e, (n) => {
		if (!n.empty) return M(n, t);
		let r = e.moveVertically(n, t);
		return r.head == n.head ? e.moveToLineBoundary(n, t) : r;
	});
}
var gt = (e) => ht(e, !1), _t = (e) => ht(e, !0);
function vt(e) {
	let t = e.scrollDOM.clientHeight < e.scrollDOM.scrollHeight - 2, n = 0, r = 0, i;
	if (t) {
		for (let t of e.state.facet(l.scrollMargins)) {
			let i = t(e);
			i?.top && (n = Math.max(i?.top, n)), i?.bottom && (r = Math.max(i?.bottom, r));
		}
		i = e.scrollDOM.clientHeight - n - r;
	} else i = (e.dom.ownerDocument.defaultView || window).innerHeight;
	return {
		marginTop: n,
		marginBottom: r,
		selfScroll: t,
		height: Math.max(e.defaultLineHeight, i - 5)
	};
}
function yt(e, t) {
	let n = vt(e), { state: r } = e, i = k(r.selection, (r) => r.empty ? e.moveVertically(r, t, n.height) : M(r, t));
	if (i.eq(r.selection)) return !1;
	let a;
	if (n.selfScroll) {
		let t = e.coordsAtPos(r.selection.main.head), o = e.scrollDOM.getBoundingClientRect(), s = o.top + n.marginTop, c = o.bottom - n.marginBottom;
		t && t.top > s && t.bottom < c && (a = l.scrollIntoView(i.main.head, {
			y: "start",
			yMargin: t.top - s
		}));
	}
	return e.dispatch(A(r, i), { effects: a }), !0;
}
var bt = (e) => yt(e, !1), xt = (e) => yt(e, !0);
function F(e, t, n) {
	let r = e.lineBlockAt(t.head), i = e.moveToLineBoundary(t, n);
	if (i.head == t.head && i.head != (n ? r.to : r.from) && (i = e.moveToLineBoundary(t, n, !1)), !n && i.head == r.from && r.length) {
		let n = /^\s*/.exec(e.state.sliceDoc(r.from, Math.min(r.from + 100, r.to)))[0].length;
		n && t.head != r.from + n && (i = S.cursor(r.from + n));
	}
	return i;
}
var St = (e) => j(e, (t) => F(e, t, !0)), Ct = (e) => j(e, (t) => F(e, t, !1)), wt = (e) => j(e, (t) => F(e, t, !N(e))), Tt = (e) => j(e, (t) => F(e, t, N(e))), Et = (e) => j(e, (t) => S.cursor(e.lineBlockAt(t.head).from, 1)), Dt = (e) => j(e, (t) => S.cursor(e.lineBlockAt(t.head).to, -1));
function Ot(e, t, n) {
	let r = !1, i = k(e.selection, (t) => {
		let i = p(e, t.head, -1) || p(e, t.head, 1) || t.head > 0 && p(e, t.head - 1, 1) || t.head < e.doc.length && p(e, t.head + 1, -1);
		if (!i || !i.end) return t;
		r = !0;
		let a = i.start.from == t.head ? i.end.to : i.end.from;
		return n ? S.range(t.anchor, a) : S.cursor(a);
	});
	return r ? (t(A(e, i)), !0) : !1;
}
var kt = ({ state: e, dispatch: t }) => Ot(e, t, !1);
function I(e, t) {
	let n = k(e.state.selection, (e) => {
		let n = t(e);
		return S.range(e.anchor, n.head, n.goalColumn, n.bidiLevel || void 0, n.assoc);
	});
	return n.eq(e.state.selection) ? !1 : (e.dispatch(A(e.state, n)), !0);
}
function At(e, t) {
	return I(e, (n) => e.moveByChar(n, t));
}
var jt = (e) => At(e, !N(e)), Mt = (e) => At(e, N(e));
function Nt(e, t) {
	return I(e, (n) => e.moveByGroup(n, t));
}
var Pt = (e) => Nt(e, !N(e)), Ft = (e) => Nt(e, N(e)), It = (e) => I(e, (t) => P(e.state, t, !N(e))), Lt = (e) => I(e, (t) => P(e.state, t, N(e)));
function Rt(e, t) {
	return I(e, (n) => e.moveVertically(n, t));
}
var zt = (e) => Rt(e, !1), Bt = (e) => Rt(e, !0);
function Vt(e, t) {
	return I(e, (n) => e.moveVertically(n, t, vt(e).height));
}
var Ht = (e) => Vt(e, !1), Ut = (e) => Vt(e, !0), Wt = (e) => I(e, (t) => F(e, t, !0)), Gt = (e) => I(e, (t) => F(e, t, !1)), Kt = (e) => I(e, (t) => F(e, t, !N(e))), qt = (e) => I(e, (t) => F(e, t, N(e))), Jt = (e) => I(e, (t) => S.cursor(e.lineBlockAt(t.head).from)), Yt = (e) => I(e, (t) => S.cursor(e.lineBlockAt(t.head).to)), Xt = ({ state: e, dispatch: t }) => (t(A(e, { anchor: 0 })), !0), Zt = ({ state: e, dispatch: t }) => (t(A(e, { anchor: e.doc.length })), !0), Qt = ({ state: e, dispatch: t }) => (t(A(e, {
	anchor: e.selection.main.anchor,
	head: 0
})), !0), $t = ({ state: e, dispatch: t }) => (t(A(e, {
	anchor: e.selection.main.anchor,
	head: e.doc.length
})), !0), en = ({ state: e, dispatch: t }) => (t(e.update({
	selection: {
		anchor: 0,
		head: e.doc.length
	},
	userEvent: "select"
})), !0), tn = ({ state: e, dispatch: t }) => {
	let n = z(e).map(({ from: t, to: n }) => S.range(t, Math.min(n + 1, e.doc.length)));
	return t(e.update({
		selection: S.create(n),
		userEvent: "select"
	})), !0;
}, nn = ({ state: e, dispatch: t }) => {
	let n = k(e.selection, (t) => {
		let n = fe(e), r = n.resolveStack(t.from, 1);
		if (t.empty) {
			let e = n.resolveStack(t.from, -1);
			e.node.from >= r.node.from && e.node.to <= r.node.to && (r = e);
		}
		for (let e = r; e; e = e.next) {
			let { node: n } = e;
			if ((n.from < t.from && n.to >= t.to || n.to > t.to && n.from <= t.from) && e.next) return S.range(n.to, n.from);
		}
		return t;
	});
	return n.eq(e.selection) ? !1 : (t(A(e, n)), !0);
};
function rn(e, t) {
	let { state: n } = e, r = n.selection, i = n.selection.ranges.slice();
	for (let r of n.selection.ranges) {
		let a = n.doc.lineAt(r.head);
		if (t ? a.to < e.state.doc.length : a.from > 0) for (let n = r;;) {
			let r = e.moveVertically(n, t);
			if (r.head < a.from || r.head > a.to) {
				i.some((e) => e.head == r.head) || i.push(r);
				break;
			} else if (r.head == n.head) break;
			else n = r;
		}
	}
	return i.length == r.ranges.length ? !1 : (e.dispatch(A(n, S.create(i, i.length - 1))), !0);
}
var an = (e) => rn(e, !1), on = (e) => rn(e, !0), sn = ({ state: e, dispatch: t }) => {
	let n = e.selection, r = null;
	return n.ranges.length > 1 ? r = S.create([n.main]) : n.main.empty || (r = S.create([S.cursor(n.main.head)])), r ? (t(A(e, r)), !0) : !1;
};
function L(e, t) {
	if (e.state.readOnly) return !1;
	let n = "delete.selection", { state: r } = e, i = r.changeByRange((r) => {
		let { from: i, to: a } = r;
		if (i == a) {
			let o = t(r);
			o < i ? (n = "delete.backward", o = R(e, o, !1)) : o > i && (n = "delete.forward", o = R(e, o, !0)), i = Math.min(i, o), a = Math.max(a, o);
		} else i = R(e, i, !1), a = R(e, a, !0);
		return i == a ? { range: r } : {
			changes: {
				from: i,
				to: a
			},
			range: S.cursor(i, i < r.head ? -1 : 1)
		};
	});
	return i.changes.empty ? !1 : (e.dispatch(r.update(i, {
		scrollIntoView: !0,
		userEvent: n,
		effects: n == "delete.selection" ? l.announce.of(r.phrase("Selection deleted")) : void 0
	})), !0);
}
function R(e, t, n) {
	if (e instanceof l) for (let r of e.state.facet(l.atomicRanges).map((t) => t(e))) r.between(t, t, (e, r) => {
		e < t && r > t && (t = n ? r : e);
	});
	return t;
}
var cn = (e, t, n) => L(e, (r) => {
	let i = r.from, { state: o } = e, s = o.doc.lineAt(i), c, l;
	if (n && !t && i > s.from && i < s.from + 200 && !/[^ \t]/.test(c = s.text.slice(0, i - s.from))) {
		if (c[c.length - 1] == "	") return i - 1;
		let e = ee(c, o.tabSize) % De(o) || De(o);
		for (let t = 0; t < e && c[c.length - 1 - t] == " "; t++) i--;
		l = i;
	} else l = a(s.text, i - s.from, t, t) + s.from, l == i && s.number != (t ? o.doc.lines : 1) ? l += t ? 1 : -1 : !t && /[\ufe00-\ufe0f]/.test(s.text.slice(l - s.from, i - s.from)) && (l = a(s.text, l - s.from, !1, !1) + s.from);
	return l;
}), ln = (e) => cn(e, !1, !0), un = (e) => cn(e, !0, !1), dn = (e, t) => L(e, (n) => {
	let r = n.head, { state: i } = e, o = i.doc.lineAt(r), s = i.charCategorizer(r);
	for (let e = null;;) {
		if (r == (t ? o.to : o.from)) {
			r == n.head && o.number != (t ? i.doc.lines : 1) && (r += t ? 1 : -1);
			break;
		}
		let c = a(o.text, r - o.from, t) + o.from, l = o.text.slice(Math.min(r, c) - o.from, Math.max(r, c) - o.from), u = s(l);
		if (e != null && u != e) break;
		(l != " " || r != n.head) && (e = u), r = c;
	}
	return r;
}), fn = (e) => dn(e, !1), pn = (e) => dn(e, !0), mn = (e) => L(e, (t) => {
	let n = e.lineBlockAt(t.head).to;
	return t.head < n ? n : Math.min(e.state.doc.length, t.head + 1);
}), hn = (e) => L(e, (t) => {
	let n = e.moveToLineBoundary(t, !1).head;
	return t.head > n ? n : Math.max(0, t.head - 1);
}), gn = (e) => L(e, (t) => {
	let n = e.moveToLineBoundary(t, !0).head;
	return t.head < n ? n : Math.min(e.state.doc.length, t.head + 1);
}), _n = ({ state: e, dispatch: t }) => {
	if (e.readOnly) return !1;
	let n = e.changeByRange((e) => ({
		changes: {
			from: e.from,
			to: e.to,
			insert: me.of(["", ""])
		},
		range: S.cursor(e.from)
	}));
	return t(e.update(n, {
		scrollIntoView: !0,
		userEvent: "input"
	})), !0;
}, vn = ({ state: e, dispatch: t }) => {
	if (e.readOnly) return !1;
	let n = e.changeByRange((t) => {
		if (!t.empty || t.from == 0 || t.from == e.doc.length) return { range: t };
		let n = t.from, r = e.doc.lineAt(n), i = n == r.from ? n - 1 : a(r.text, n - r.from, !1) + r.from, o = n == r.to ? n + 1 : a(r.text, n - r.from, !0) + r.from;
		return {
			changes: {
				from: i,
				to: o,
				insert: e.doc.slice(n, o).append(e.doc.slice(i, n))
			},
			range: S.cursor(o)
		};
	});
	return n.changes.empty ? !1 : (t(e.update(n, {
		scrollIntoView: !0,
		userEvent: "move.character"
	})), !0);
};
function z(e) {
	let t = [], n = -1;
	for (let r of e.selection.ranges) {
		let i = e.doc.lineAt(r.from), a = e.doc.lineAt(r.to);
		if (!r.empty && r.to == a.from && (a = e.doc.lineAt(r.to - 1)), n >= i.number) {
			let e = t[t.length - 1];
			e.to = a.to, e.ranges.push(r);
		} else t.push({
			from: i.from,
			to: a.to,
			ranges: [r]
		});
		n = a.number + 1;
	}
	return t;
}
function yn(e, t, n) {
	if (e.readOnly) return !1;
	let r = [], i = [];
	for (let t of z(e)) {
		if (n ? t.to == e.doc.length : t.from == 0) continue;
		let a = e.doc.lineAt(n ? t.to + 1 : t.from - 1), o = a.length + 1;
		if (n) {
			r.push({
				from: t.to,
				to: a.to
			}, {
				from: t.from,
				insert: a.text + e.lineBreak
			});
			for (let n of t.ranges) i.push(S.range(Math.min(e.doc.length, n.anchor + o), Math.min(e.doc.length, n.head + o)));
		} else {
			r.push({
				from: a.from,
				to: t.from
			}, {
				from: t.to,
				insert: e.lineBreak + a.text
			});
			for (let e of t.ranges) i.push(S.range(e.anchor - o, e.head - o));
		}
	}
	return r.length ? (t(e.update({
		changes: r,
		scrollIntoView: !0,
		selection: S.create(i, e.selection.mainIndex),
		userEvent: "move.line"
	})), !0) : !1;
}
var bn = ({ state: e, dispatch: t }) => yn(e, t, !1), xn = ({ state: e, dispatch: t }) => yn(e, t, !0);
function Sn(e, t, n) {
	if (e.readOnly) return !1;
	let r = [];
	for (let t of z(e)) n ? r.push({
		from: t.from,
		insert: e.doc.slice(t.from, t.to) + e.lineBreak
	}) : r.push({
		from: t.to,
		insert: e.lineBreak + e.doc.slice(t.from, t.to)
	});
	let i = e.changes(r);
	return t(e.update({
		changes: i,
		selection: e.selection.map(i, n ? 1 : -1),
		scrollIntoView: !0,
		userEvent: "input.copyline"
	})), !0;
}
var Cn = ({ state: e, dispatch: t }) => Sn(e, t, !1), wn = ({ state: e, dispatch: t }) => Sn(e, t, !0), Tn = (e) => {
	if (e.state.readOnly) return !1;
	let { state: t } = e, n = t.changes(z(t).map(({ from: e, to: n }) => (e > 0 ? e-- : n < t.doc.length && n++, {
		from: e,
		to: n
	}))), r = k(t.selection, (t) => {
		let n;
		if (e.lineWrapping) {
			let r = e.lineBlockAt(t.head), i = e.coordsAtPos(t.head, t.assoc || 1);
			i && (n = r.bottom + e.documentTop - i.bottom + e.defaultLineHeight / 2);
		}
		return e.moveVertically(t, !0, n);
	}).map(n);
	return e.dispatch({
		changes: n,
		selection: r,
		scrollIntoView: !0,
		userEvent: "delete.line"
	}), !0;
};
function En(e, t) {
	if (/\(\)|\[\]|\{\}/.test(e.sliceDoc(t - 1, t + 1))) return {
		from: t,
		to: t
	};
	let n = fe(e).resolveInner(t), r = n.childBefore(t), i = n.childAfter(t), a;
	return r && i && r.to <= t && i.from >= t && (a = r.type.prop(u.closedBy)) && a.indexOf(i.name) > -1 && e.doc.lineAt(r.to).from == e.doc.lineAt(i.from).from && !/\S/.test(e.sliceDoc(r.to, i.from)) ? {
		from: r.to,
		to: i.from
	} : null;
}
var Dn = /* @__PURE__ */ kn(!1), On = /* @__PURE__ */ kn(!0);
function kn(e) {
	return ({ state: t, dispatch: n }) => {
		if (t.readOnly) return !1;
		let r = t.changeByRange((n) => {
			let { from: r, to: i } = n, a = t.doc.lineAt(r), o = !e && r == i && En(t, r);
			e && (r = i = (i <= a.to ? a : t.doc.lineAt(i)).to);
			let s = new ve(t, {
				simulateBreak: r,
				simulateDoubleBreak: !!o
			}), c = ne(s, r);
			for (c ??= ee(/^\s*/.exec(t.doc.lineAt(r).text)[0], t.tabSize); i < a.to && /\s/.test(a.text[i - a.from]);) i++;
			o ? {from: r, to: i} = o : r > a.from && r < a.from + 100 && !/\S/.test(a.text.slice(0, r)) && (r = a.from);
			let l = ["", g(t, c)];
			return o && l.push(g(t, s.lineIndent(a.from, -1))), {
				changes: {
					from: r,
					to: i,
					insert: me.of(l)
				},
				range: S.cursor(r + 1 + l[1].length)
			};
		});
		return n(t.update(r, {
			scrollIntoView: !0,
			userEvent: "input"
		})), !0;
	};
}
function An(e, t) {
	let n = -1;
	return e.changeByRange((r) => {
		let i = [];
		for (let a = r.from; a <= r.to;) {
			let o = e.doc.lineAt(a);
			o.number > n && (r.empty || r.to > o.from) && (t(o, i, r), n = o.number), a = o.to + 1;
		}
		let a = e.changes(i);
		return {
			changes: i,
			range: S.range(a.mapPos(r.anchor, 1), a.mapPos(r.head, 1))
		};
	});
}
var jn = ({ state: e, dispatch: t }) => {
	if (e.readOnly) return !1;
	let n = Object.create(null), r = new ve(e, { overrideIndentation: (e) => n[e] ?? -1 }), i = An(e, (t, i, a) => {
		let o = ne(r, t.from);
		if (o == null) return;
		/\S/.test(t.text) || (o = 0);
		let s = /^\s*/.exec(t.text)[0], c = g(e, o);
		(s != c || a.from < t.from + s.length) && (n[t.from] = o, i.push({
			from: t.from,
			to: t.from + s.length,
			insert: c
		}));
	});
	return i.changes.empty || t(e.update(i, { userEvent: "indent" })), !0;
}, Mn = ({ state: e, dispatch: t }) => e.readOnly ? !1 : (t(e.update(An(e, (t, n) => {
	n.push({
		from: t.from,
		insert: e.facet(i)
	});
}), { userEvent: "input.indent" })), !0), Nn = ({ state: e, dispatch: t }) => e.readOnly ? !1 : (t(e.update(An(e, (t, n) => {
	let r = /^\s*/.exec(t.text)[0];
	if (!r) return;
	let i = ee(r, e.tabSize), a = 0, o = g(e, Math.max(0, i - De(e)));
	for (; a < r.length && a < o.length && r.charCodeAt(a) == o.charCodeAt(a);) a++;
	n.push({
		from: t.from + a,
		to: t.from + r.length,
		insert: o.slice(a)
	});
}), { userEvent: "delete.dedent" })), !0), Pn = (e) => (e.setTabFocusMode(), !0), Fn = [
	{
		key: "Ctrl-b",
		run: st,
		shift: jt,
		preventDefault: !0
	},
	{
		key: "Ctrl-f",
		run: ct,
		shift: Mt
	},
	{
		key: "Ctrl-p",
		run: gt,
		shift: zt
	},
	{
		key: "Ctrl-n",
		run: _t,
		shift: Bt
	},
	{
		key: "Ctrl-a",
		run: Et,
		shift: Jt
	},
	{
		key: "Ctrl-e",
		run: Dt,
		shift: Yt
	},
	{
		key: "Ctrl-d",
		run: un
	},
	{
		key: "Ctrl-h",
		run: ln
	},
	{
		key: "Ctrl-k",
		run: mn
	},
	{
		key: "Ctrl-Alt-h",
		run: fn
	},
	{
		key: "Ctrl-o",
		run: _n
	},
	{
		key: "Ctrl-t",
		run: vn
	},
	{
		key: "Ctrl-v",
		run: xt
	}
], In = /* @__PURE__ */ [
	{
		key: "ArrowLeft",
		run: st,
		shift: jt,
		preventDefault: !0
	},
	{
		key: "Mod-ArrowLeft",
		mac: "Alt-ArrowLeft",
		run: ut,
		shift: Pt,
		preventDefault: !0
	},
	{
		mac: "Cmd-ArrowLeft",
		run: wt,
		shift: Kt,
		preventDefault: !0
	},
	{
		key: "ArrowRight",
		run: ct,
		shift: Mt,
		preventDefault: !0
	},
	{
		key: "Mod-ArrowRight",
		mac: "Alt-ArrowRight",
		run: dt,
		shift: Ft,
		preventDefault: !0
	},
	{
		mac: "Cmd-ArrowRight",
		run: Tt,
		shift: qt,
		preventDefault: !0
	},
	{
		key: "ArrowUp",
		run: gt,
		shift: zt,
		preventDefault: !0
	},
	{
		mac: "Cmd-ArrowUp",
		run: Xt,
		shift: Qt
	},
	{
		mac: "Ctrl-ArrowUp",
		run: bt,
		shift: Ht
	},
	{
		key: "ArrowDown",
		run: _t,
		shift: Bt,
		preventDefault: !0
	},
	{
		mac: "Cmd-ArrowDown",
		run: Zt,
		shift: $t
	},
	{
		mac: "Ctrl-ArrowDown",
		run: xt,
		shift: Ut
	},
	{
		key: "PageUp",
		run: bt,
		shift: Ht
	},
	{
		key: "PageDown",
		run: xt,
		shift: Ut
	},
	{
		key: "Home",
		run: Ct,
		shift: Gt,
		preventDefault: !0
	},
	{
		key: "Mod-Home",
		run: Xt,
		shift: Qt
	},
	{
		key: "End",
		run: St,
		shift: Wt,
		preventDefault: !0
	},
	{
		key: "Mod-End",
		run: Zt,
		shift: $t
	},
	{
		key: "Enter",
		run: Dn,
		shift: Dn
	},
	{
		key: "Mod-a",
		run: en
	},
	{
		key: "Backspace",
		run: ln,
		shift: ln,
		preventDefault: !0
	},
	{
		key: "Delete",
		run: un,
		preventDefault: !0
	},
	{
		key: "Mod-Backspace",
		mac: "Alt-Backspace",
		run: fn,
		preventDefault: !0
	},
	{
		key: "Mod-Delete",
		mac: "Alt-Delete",
		run: pn,
		preventDefault: !0
	},
	{
		mac: "Mod-Backspace",
		run: hn,
		preventDefault: !0
	},
	{
		mac: "Mod-Delete",
		run: gn,
		preventDefault: !0
	}
].concat(/* @__PURE__ */ Fn.map((e) => ({
	mac: e.key,
	run: e.run,
	shift: e.shift
}))), Ln = /* @__PURE__ */ [
	{
		key: "Alt-ArrowLeft",
		mac: "Ctrl-ArrowLeft",
		run: pt,
		shift: It
	},
	{
		key: "Alt-ArrowRight",
		mac: "Ctrl-ArrowRight",
		run: mt,
		shift: Lt
	},
	{
		key: "Alt-ArrowUp",
		run: bn
	},
	{
		key: "Shift-Alt-ArrowUp",
		run: Cn
	},
	{
		key: "Alt-ArrowDown",
		run: xn
	},
	{
		key: "Shift-Alt-ArrowDown",
		run: wn
	},
	{
		key: "Mod-Alt-ArrowUp",
		run: an
	},
	{
		key: "Mod-Alt-ArrowDown",
		run: on
	},
	{
		key: "Escape",
		run: sn
	},
	{
		key: "Mod-Enter",
		run: On
	},
	{
		key: "Alt-l",
		mac: "Ctrl-l",
		run: tn
	},
	{
		key: "Mod-i",
		run: nn,
		preventDefault: !0
	},
	{
		key: "Mod-[",
		run: Nn
	},
	{
		key: "Mod-]",
		run: Mn
	},
	{
		key: "Mod-Alt-\\",
		run: jn
	},
	{
		key: "Shift-Mod-k",
		run: Tn
	},
	{
		key: "Shift-Mod-\\",
		run: kt
	},
	{
		key: "Mod-/",
		run: Ae
	},
	{
		key: "Alt-A",
		run: Ne
	},
	{
		key: "Ctrl-m",
		mac: "Shift-Alt-m",
		run: Pn
	}
].concat(In), Rn = {
	key: "Tab",
	run: Mn,
	shift: Nn
}, zn = typeof String.prototype.normalize == "function" ? (e) => e.normalize("NFKD") : (e) => e, B = class {
	constructor(e, t, n = 0, r = e.length, i, a) {
		this.test = a, this.value = {
			from: 0,
			to: 0
		}, this.done = !1, this.matches = [], this.buffer = "", this.bufferPos = 0, this.iter = e.iterRange(n, r), this.bufferStart = n, this.normalize = i ? (e) => i(zn(e)) : zn, 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 pe(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 = s(e), n = this.bufferStart + this.bufferPos;
			this.bufferPos += d(e);
			let r = this.normalize(t);
			if (r.length) for (let e = 0, i = n;; e++) {
				let a = r.charCodeAt(e), o = this.match(a, i, this.bufferPos + this.bufferStart);
				if (e == r.length - 1) {
					if (o) return this.value = o, this;
					break;
				}
				i == n && e < t.length && t.charCodeAt(e) == a && i++;
			}
		}
	}
	match(e, t, n) {
		let r = null;
		for (let t = 0; t < this.matches.length; t += 2) {
			let i = this.matches[t], a = !1;
			this.query.charCodeAt(i) == e && (i == this.query.length - 1 ? r = {
				from: this.matches[t + 1],
				to: n
			} : (this.matches[t]++, a = !0)), a || (this.matches.splice(t, 2), t -= 2);
		}
		return this.query.charCodeAt(0) == e && (this.query.length == 1 ? r = {
			from: t,
			to: n
		} : this.matches.push(1, t)), r && this.test && !this.test(r.from, r.to, this.buffer, this.bufferStart) && (r = null), r;
	}
};
typeof Symbol < "u" && (B.prototype[Symbol.iterator] = function() {
	return this;
});
var Bn = {
	from: -1,
	to: -1,
	match: /* @__PURE__ */ /.*/.exec("")
}, Vn = "gm" + (/x/.unicode == null ? "" : "u"), Hn = class {
	constructor(e, t, n, r = 0, i = e.length) {
		if (this.text = e, this.to = i, this.curLine = "", this.done = !1, this.value = Bn, /\\[sWDnr]|\n|\r|\[\^/.test(t)) return new Gn(e, t, n, r, i);
		this.re = new RegExp(t, Vn + (n?.ignoreCase ? "i" : "")), this.test = n?.test, this.iter = e.iter(), this.curLineStart = e.lineAt(r).from, this.matchPos = V(e, r), 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, r = n + t[0].length;
				if (this.matchPos = V(this.text, r + (n == r ? 1 : 0)), n == this.curLineStart + this.curLine.length && this.nextLine(), (n < r || n > this.value.to) && (!this.test || this.test(n, r, t))) return this.value = {
					from: n,
					to: r,
					match: t
				}, this;
				e = this.matchPos - this.curLineStart;
			} else if (this.curLineStart + this.curLine.length < this.to) this.nextLine(), e = 0;
			else return this.done = !0, this;
		}
	}
}, Un = /* @__PURE__ */ new WeakMap(), Wn = class e {
	constructor(e, t) {
		this.from = e, this.text = t;
	}
	get to() {
		return this.from + this.text.length;
	}
	static get(t, n, r) {
		let i = Un.get(t);
		if (!i || i.from >= r || i.to <= n) {
			let i = new e(n, t.sliceString(n, r));
			return Un.set(t, i), i;
		}
		if (i.from == n && i.to == r) return i;
		let { text: a, from: o } = i;
		return o > n && (a = t.sliceString(n, o) + a, o = n), i.to < r && (a += t.sliceString(i.to, r)), Un.set(t, new e(o, a)), new e(n, a.slice(n - o, r - o));
	}
}, Gn = class {
	constructor(e, t, n, r, i) {
		this.text = e, this.to = i, this.done = !1, this.value = Bn, this.matchPos = V(e, r), this.re = new RegExp(t, Vn + (n?.ignoreCase ? "i" : "")), this.test = n?.test, this.flat = Wn.get(e, r, this.chunkEnd(r + 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 = V(this.text, n + (e == n ? 1 : 0)), this;
			}
			if (this.flat.to == this.to) return this.done = !0, this;
			this.flat = Wn.get(this.text, this.flat.from, this.chunkEnd(this.flat.from + this.flat.text.length * 2));
		}
	}
};
typeof Symbol < "u" && (Hn.prototype[Symbol.iterator] = Gn.prototype[Symbol.iterator] = function() {
	return this;
});
function Kn(e) {
	try {
		return new RegExp(e, Vn), !0;
	} catch {
		return !1;
	}
}
function V(e, t) {
	if (t >= e.length) return t;
	let n = e.lineAt(t), r;
	for (; t < n.to && (r = n.text.charCodeAt(t - n.from)) >= 56320 && r < 57344;) t++;
	return t;
}
var qn = (e) => {
	let { state: t } = e, n = String(t.doc.lineAt(e.state.selection.main.head).number), { close: r, result: i } = we(e, {
		label: t.phrase("Go to line"),
		input: {
			type: "text",
			name: "line",
			value: n
		},
		focus: !0,
		submitLabel: t.phrase("go")
	});
	return i.then((n) => {
		let i = n && /^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.elements.line.value);
		if (!i) {
			e.dispatch({ effects: r });
			return;
		}
		let a = t.doc.lineAt(t.selection.main.head), [, o, s, c, u] = i, d = c ? +c.slice(1) : 0, f = s ? +s : a.number;
		if (s && u) {
			let e = f / 100;
			o && (e = e * (o == "-" ? -1 : 1) + a.number / t.doc.lines), f = Math.round(t.doc.lines * e);
		} else s && o && (f = f * (o == "-" ? -1 : 1) + a.number);
		let p = t.doc.line(Math.max(1, Math.min(t.doc.lines, f))), m = S.cursor(p.from + Math.max(0, Math.min(d, p.length)));
		e.dispatch({
			effects: [r, l.scrollIntoView(m.from, { y: "center" })],
			selection: m
		});
	}), !0;
}, Jn = {
	highlightWordAroundCursor: !1,
	minSelectionLength: 1,
	maxMatches: 100,
	wholeWords: !1
}, Yn = /* @__PURE__ */ x.define({ combine(e) {
	return f(e, Jn, {
		highlightWordAroundCursor: (e, t) => e || t,
		minSelectionLength: Math.min,
		maxMatches: Math.min
	});
} });
function Xn(e) {
	let t = [nr, tr];
	return e && t.push(Yn.of(e)), t;
}
var Zn = /* @__PURE__ */ _.mark({ class: "cm-selectionMatch" }), Qn = /* @__PURE__ */ _.mark({ class: "cm-selectionMatch cm-selectionMatch-main" });
function $n(e, t, n, r) {
	return (n == 0 || e(t.sliceDoc(n - 1, n)) != v.Word) && (r == t.doc.length || e(t.sliceDoc(r, r + 1)) != v.Word);
}
function er(e, t, n, r) {
	return e(t.sliceDoc(n, n + 1)) == v.Word && e(t.sliceDoc(r - 1, r)) == v.Word;
}
var tr = /* @__PURE__ */ c.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(Yn), { state: n } = e, r = n.selection;
		if (r.ranges.length > 1) return _.none;
		let i = r.main, a, o = null;
		if (i.empty) {
			if (!t.highlightWordAroundCursor) return _.none;
			let e = n.wordAt(i.head);
			if (!e) return _.none;
			o = n.charCategorizer(i.head), a = n.sliceDoc(e.from, e.to);
		} else {
			let e = i.to - i.from;
			if (e < t.minSelectionLength || e > 200) return _.none;
			if (t.wholeWords) {
				if (a = n.sliceDoc(i.from, i.to), o = n.charCategorizer(i.head), !($n(o, n, i.from, i.to) && er(o, n, i.from, i.to))) return _.none;
			} else if (a = n.sliceDoc(i.from, i.to), !a) return _.none;
		}
		let s = [];
		for (let r of e.visibleRanges) {
			let e = new B(n.doc, a, r.from, r.to);
			for (; !e.next().done;) {
				let { from: r, to: a } = e.value;
				if ((!o || $n(o, n, r, a)) && (i.empty && r <= i.from && a >= i.to ? s.push(Qn.range(r, a)) : (r >= i.to || a <= i.from) && s.push(Zn.range(r, a)), s.length > t.maxMatches)) return _.none;
			}
		}
		return _.set(s);
	}
}, { decorations: (e) => e.decorations }), nr = /* @__PURE__ */ l.baseTheme({
	".cm-selectionMatch": { backgroundColor: "#99ff7780" },
	".cm-searchMatch .cm-selectionMatch": { backgroundColor: "transparent" }
}), rr = ({ state: e, dispatch: t }) => {
	let { selection: n } = e, r = S.create(n.ranges.map((t) => e.wordAt(t.head) || S.cursor(t.head)), n.mainIndex);
	return r.eq(n) ? !1 : (t(e.update({ selection: r })), !0);
};
function ir(e, t) {
	let { main: n, ranges: r } = e.selection, i = e.wordAt(n.head), a = i && i.from == n.from && i.to == n.to;
	for (let n = !1, i = new B(e.doc, t, r[r.length - 1].to);;) if (i.next(), i.done) {
		if (n) return null;
		i = new B(e.doc, t, 0, Math.max(0, r[r.length - 1].from - 1)), n = !0;
	} else {
		if (n && r.some((e) => e.from == i.value.from)) continue;
		if (a) {
			let t = e.wordAt(i.value.from);
			if (!t || t.from != i.value.from || t.to != i.value.to) continue;
		}
		return i.value;
	}
}
var ar = ({ state: e, dispatch: t }) => {
	let { ranges: n } = e.selection;
	if (n.some((e) => e.from === e.to)) return rr({
		state: e,
		dispatch: t
	});
	let r = e.sliceDoc(n[0].from, n[0].to);
	if (e.selection.ranges.some((t) => e.sliceDoc(t.from, t.to) != r)) return !1;
	let i = ir(e, r);
	return i ? (t(e.update({
		selection: e.selection.addRange(S.range(i.from, i.to), !1),
		effects: l.scrollIntoView(i.to)
	})), !0) : !1;
}, H = /* @__PURE__ */ x.define({ combine(e) {
	return f(e, {
		top: !1,
		caseSensitive: !1,
		literal: !1,
		regexp: !1,
		wholeWord: !1,
		createPanel: (e) => new jr(e),
		scrollToMatch: (e) => l.scrollIntoView(e)
	});
} });
function or(e) {
	return e ? [H.of(e), Fr] : Fr;
}
var sr = class {
	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 || Kn(this.search)), this.unquoted = this.unquote(this.search), this.wholeWord = !!e.wholeWord, this.test = e.test;
	}
	unquote(e) {
		return this.literal ? e : e.replace(/\\([nrt\\])/g, (e, t) => t == "n" ? "\n" : t == "r" ? "\r" : 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 && this.test == e.test;
	}
	create() {
		return this.regexp ? new mr(this) : new dr(this);
	}
	getCursor(e, t = 0, n) {
		let r = e.doc ? e : y.create({ doc: e });
		return n ??= r.doc.length, this.regexp ? W(this, r, t, n) : U(this, r, t, n);
	}
}, cr = class {
	constructor(e) {
		this.spec = e;
	}
};
function lr(e, t, n) {
	return (r, i, a, o) => n && !n(r, i, a, o) ? !1 : e(r >= o && i <= o + a.length ? a.slice(r - o, i - o) : t.doc.sliceString(r, i), t, r, i);
}
function U(e, t, n, r) {
	let i;
	return e.wholeWord && (i = ur(t.doc, t.charCategorizer(t.selection.main.head))), e.test && (i = lr(e.test, t, i)), new B(t.doc, e.unquoted, n, r, e.caseSensitive ? void 0 : (e) => e.toLowerCase(), i);
}
function ur(e, t) {
	return (n, r, i, a) => ((a > n || a + i.length < r) && (a = Math.max(0, n - 2), i = e.sliceString(a, Math.min(e.length, r + 2))), (t(G(i, n - a)) != v.Word || t(K(i, n - a)) != v.Word) && (t(K(i, r - a)) != v.Word || t(G(i, r - a)) != v.Word));
}
var dr = class extends cr {
	constructor(e) {
		super(e);
	}
	nextMatch(e, t, n) {
		let r = U(this.spec, e, n, e.doc.length).nextOverlapping();
		if (r.done) {
			let n = Math.min(e.doc.length, t + this.spec.unquoted.length);
			r = U(this.spec, e, 0, n).nextOverlapping();
		}
		return r.done || r.value.from == t && r.value.to == n ? null : r.value;
	}
	prevMatchInRange(e, t, n) {
		for (let r = n;;) {
			let n = Math.max(t, r - 1e4 - this.spec.unquoted.length), i = U(this.spec, e, n, r), a = null;
			for (; !i.nextOverlapping().done;) a = i.value;
			if (a) return a;
			if (n == t) return null;
			r -= 1e4;
		}
	}
	prevMatch(e, t, n) {
		let r = this.prevMatchInRange(e, 0, t);
		return r ||= this.prevMatchInRange(e, Math.max(0, n - this.spec.unquoted.length), e.doc.length), r && (r.from != t || r.to != n) ? r : null;
	}
	getReplacement(e) {
		return this.spec.unquote(this.spec.replace);
	}
	matchAll(e, t) {
		let n = U(this.spec, e, 0, e.doc.length), r = [];
		for (; !n.next().done;) {
			if (r.length >= t) return null;
			r.push(n.value);
		}
		return r;
	}
	highlight(e, t, n, r) {
		let i = U(this.spec, e, Math.max(0, t - this.spec.unquoted.length), Math.min(n + this.spec.unquoted.length, e.doc.length));
		for (; !i.next().done;) r(i.value.from, i.value.to);
	}
};
function fr(e, t, n) {
	return (r, i, a) => (!n || n(r, i, a)) && e(a[0], t, r, i);
}
function W(e, t, n, r) {
	let i;
	return e.wholeWord && (i = pr(t.charCategorizer(t.selection.main.head))), e.test && (i = fr(e.test, t, i)), new Hn(t.doc, e.search, {
		ignoreCase: !e.caseSensitive,
		test: i
	}, n, r);
}
function G(e, t) {
	return e.slice(a(e, t, !1), t);
}
function K(e, t) {
	return e.slice(t, a(e, t));
}
function pr(e) {
	return (t, n, r) => !r[0].length || (e(G(r.input, r.index)) != v.Word || e(K(r.input, r.index)) != v.Word) && (e(K(r.input, r.index + r[0].length)) != v.Word || e(G(r.input, r.index + r[0].length)) != v.Word);
}
var mr = class extends cr {
	nextMatch(e, t, n) {
		let r = W(this.spec, e, n, e.doc.length).next();
		return r.done && (r = W(this.spec, e, 0, t).next()), r.done ? null : r.value;
	}
	prevMatchInRange(e, t, n) {
		for (let r = 1;; r++) {
			let i = Math.max(t, n - r * 1e4), a = W(this.spec, e, i, n), o = null;
			for (; !a.next().done;) o = a.value;
			if (o && (i == t || o.from > i + 10)) return o;
			if (i == 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) => {
			if (n == "&") return e.match[0];
			if (n == "$") return "$";
			for (let t = n.length; t > 0; t--) {
				let r = +n.slice(0, t);
				if (r > 0 && r < e.match.length) return e.match[r] + n.slice(t);
			}
			return t;
		});
	}
	matchAll(e, t) {
		let n = W(this.spec, e, 0, e.doc.length), r = [];
		for (; !n.next().done;) {
			if (r.length >= t) return null;
			r.push(n.value);
		}
		return r;
	}
	highlight(e, t, n, r) {
		let i = W(this.spec, e, Math.max(0, t - 250), Math.min(n + 250, e.doc.length));
		for (; !i.next().done;) r(i.value.from, i.value.to);
	}
}, q = /* @__PURE__ */ r.define(), hr = /* @__PURE__ */ r.define(), J = /* @__PURE__ */ m.define({
	create(e) {
		return new gr(Tr(e).create(), null);
	},
	update(e, t) {
		for (let n of t.effects) n.is(q) ? e = new gr(n.value.create(), e.panel) : n.is(hr) && (e = new gr(e.query, n.value ? wr : null));
		return e;
	},
	provide: (e) => ce.from(e, (e) => e.panel)
}), gr = class {
	constructor(e, t) {
		this.query = e, this.panel = t;
	}
}, _r = /* @__PURE__ */ _.mark({ class: "cm-searchMatch" }), vr = /* @__PURE__ */ _.mark({ class: "cm-searchMatch cm-searchMatch-selected" }), yr = /* @__PURE__ */ c.fromClass(class {
	constructor(e) {
		this.view = e, this.decorations = this.highlight(e.state.field(J));
	}
	update(e) {
		let t = e.state.field(J);
		(t != e.startState.field(J) || e.docChanged || e.selectionSet || e.viewportChanged) && (this.decorations = this.highlight(t));
	}
	highlight({ query: e, panel: t }) {
		if (!t || !e.spec.valid) return _.none;
		let { view: n } = this, r = new re();
		for (let t = 0, i = n.visibleRanges, a = i.length; t < a; t++) {
			let { from: o, to: s } = i[t];
			for (; t < a - 1 && s > i[t + 1].from - 500;) s = i[++t].to;
			e.highlight(n.state, o, s, (e, t) => {
				let i = n.state.selection.ranges.some((n) => n.from == e && n.to == t);
				r.add(e, t, i ? vr : _r);
			});
		}
		return r.finish();
	}
}, { decorations: (e) => e.decorations });
function Y(e) {
	return (t) => {
		let n = t.state.field(J, !1);
		return n && n.query.spec.valid ? e(t, n) : Or(t);
	};
}
var X = /* @__PURE__ */ Y((e, { query: t }) => {
	let { to: n } = e.state.selection.main, r = t.nextMatch(e.state, n, n);
	if (!r) return !1;
	let i = S.single(r.from, r.to), a = e.state.facet(H);
	return e.dispatch({
		selection: i,
		effects: [Nr(e, r), a.scrollToMatch(i.main, e)],
		userEvent: "select.search"
	}), Dr(e), !0;
}), Z = /* @__PURE__ */ Y((e, { query: t }) => {
	let { state: n } = e, { from: r } = n.selection.main, i = t.prevMatch(n, r, r);
	if (!i) return !1;
	let a = S.single(i.from, i.to), o = e.state.facet(H);
	return e.dispatch({
		selection: a,
		effects: [Nr(e, i), o.scrollToMatch(a.main, e)],
		userEvent: "select.search"
	}), Dr(e), !0;
}), br = /* @__PURE__ */ Y((e, { query: t }) => {
	let n = t.matchAll(e.state, 1e3);
	return !n || !n.length ? !1 : (e.dispatch({
		selection: S.create(n.map((e) => S.range(e.from, e.to))),
		userEvent: "select.search.matches"
	}), !0);
}), xr = ({ state: e, dispatch: t }) => {
	let n = e.selection;
	if (n.ranges.length > 1 || n.main.empty) return !1;
	let { from: r, to: i } = n.main, a = [], o = 0;
	for (let t = new B(e.doc, e.sliceDoc(r, i)); !t.next().done;) {
		if (a.length > 1e3) return !1;
		t.value.from == r && (o = a.length), a.push(S.range(t.value.from, t.value.to));
	}
	return t(e.update({
		selection: S.create(a, o),
		userEvent: "select.search.matches"
	})), !0;
}, Sr = /* @__PURE__ */ Y((e, { query: t }) => {
	let { state: n } = e, { from: r, to: i } = n.selection.main;
	if (n.readOnly) return !1;
	let a = t.nextMatch(n, r, r);
	if (!a) return !1;
	let o = a, s = [], c, u, d = [];
	o.from == r && o.to == i && (u = n.toText(t.getReplacement(o)), s.push({
		from: o.from,
		to: o.to,
		insert: u
	}), o = t.nextMatch(n, o.from, o.to), d.push(l.announce.of(n.phrase("replaced match on line $", n.doc.lineAt(r).number) + ".")));
	let f = e.state.changes(s);
	return o && (c = S.single(o.from, o.to).map(f), d.push(Nr(e, o)), d.push(n.facet(H).scrollToMatch(c.main, e))), e.dispatch({
		changes: f,
		selection: c,
		effects: d,
		userEvent: "input.replace"
	}), !0;
}), Cr = /* @__PURE__ */ Y((e, { query: t }) => {
	if (e.state.readOnly) return !1;
	let n = t.matchAll(e.state, 1e9).map((e) => {
		let { from: n, to: r } = e;
		return {
			from: n,
			to: r,
			insert: t.getReplacement(e)
		};
	});
	if (!n.length) return !1;
	let r = e.state.phrase("replaced $ matches", n.length) + ".";
	return e.dispatch({
		changes: n,
		effects: l.announce.of(r),
		userEvent: "input.replace.all"
	}), !0;
});
function wr(e) {
	return e.state.facet(H).createPanel(e);
}
function Tr(e, t) {
	let n = e.selection.main, r = n.empty || n.to > n.from + 100 ? "" : e.sliceDoc(n.from, n.to);
	if (t && !r) return t;
	let i = e.facet(H);
	return new sr({
		search: t?.literal ?? i.literal ? r : r.replace(/\n/g, "\\n"),
		caseSensitive: t?.caseSensitive ?? i.caseSensitive,
		literal: t?.literal ?? i.literal,
		regexp: t?.regexp ?? i.regexp,
		wholeWord: t?.wholeWord ?? i.wholeWord
	});
}
function Er(e) {
	let t = te(e, wr);
	return t && t.dom.querySelector("[main-field]");
}
function Dr(e) {
	let t = Er(e);
	t && t == e.root.activeElement && t.select();
}
var Or = (e) => {
	let t = e.state.field(J, !1);
	if (t && t.panel) {
		let n = Er(e);
		if (n && n != e.root.activeElement) {
			let r = Tr(e.state, t.query.spec);
			r.valid && e.dispatch({ effects: q.of(r) }), n.focus(), n.select();
		}
	} else e.dispatch({ effects: [hr.of(!0), t ? q.of(Tr(e.state, t.query.spec)) : r.appendConfig.of(Fr)] });
	return !0;
}, kr = (e) => {
	let t = e.state.field(J, !1);
	if (!t || !t.panel) return !1;
	let n = te(e, wr);
	return n && n.dom.contains(e.root.activeElement) && e.focus(), e.dispatch({ effects: hr.of(!1) }), !0;
}, Ar = [
	{
		key: "Mod-f",
		run: Or,
		scope: "editor search-panel"
	},
	{
		key: "F3",
		run: X,
		shift: Z,
		scope: "editor search-panel",
		preventDefault: !0
	},
	{
		key: "Mod-g",
		run: X,
		shift: Z,
		scope: "editor search-panel",
		preventDefault: !0
	},
	{
		key: "Escape",
		run: kr,
		scope: "editor search-panel"
	},
	{
		key: "Mod-Shift-l",
		run: xr
	},
	{
		key: "Mod-Alt-g",
		run: qn
	},
	{
		key: "Mod-d",
		run: ar,
		preventDefault: !0
	}
], jr = class {
	constructor(e) {
		this.view = e;
		let t = this.query = e.state.field(J).query.spec;
		this.commit = this.commit.bind(this), this.searchField = b("input", {
			value: t.search,
			placeholder: Q(e, "Find"),
			"aria-label": Q(e, "Find"),
			class: "cm-textfield",
			name: "search",
			form: "",
			"main-field": "true",
			onchange: this.commit,
			onkeyup: this.commit
		}), this.replaceField = b("input", {
			value: t.replace,
			placeholder: Q(e, "Replace"),
			"aria-label": Q(e, "Replace"),
			class: "cm-textfield",
			name: "replace",
			form: "",
			onchange: this.commit,
			onkeyup: this.commit
		}), this.caseField = b("input", {
			type: "checkbox",
			name: "case",
			form: "",
			checked: t.caseSensitive,
			onchange: this.commit
		}), this.reField = b("input", {
			type: "checkbox",
			name: "re",
			form: "",
			checked: t.regexp,
			onchange: this.commit
		}), this.wordField = b("input", {
			type: "checkbox",
			name: "word",
			form: "",
			checked: t.wholeWord,
			onchange: this.commit
		});
		function n(e, t, n) {
			return b("button", {
				class: "cm-button",
				name: e,
				onclick: t,
				type: "button"
			}, n);
		}
		this.dom = b("div", {
			onkeydown: (e) => this.keydown(e),
			class: "cm-search"
		}, [
			this.searchField,
			n("next", () => X(e), [Q(e, "next")]),
			n("prev", () => Z(e), [Q(e, "previous")]),
			n("select", () => br(e), [Q(e, "all")]),
			b("label", null, [this.caseField, Q(e, "match case")]),
			b("label", null, [this.reField, Q(e, "regexp")]),
			b("label", null, [this.wordField, Q(e, "by word")]),
			...e.state.readOnly ? [] : [
				b("br"),
				this.replaceField,
				n("replace", () => Sr(e), [Q(e, "replace")]),
				n("replaceAll", () => Cr(e), [Q(e, "replace all")])
			],
			b("button", {
				name: "close",
				onclick: () => kr(e),
				"aria-label": Q(e, "close"),
				type: "button"
			}, ["×"])
		]);
	}
	commit() {
		let e = new sr({
			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: q.of(e) }));
	}
	keydown(e) {
		ge(this.view, e, "search-panel") ? e.preventDefault() : e.keyCode == 13 && e.target == this.searchField ? (e.preventDefault(), (e.shiftKey ? Z : X)(this.view)) : e.keyCode == 13 && e.target == this.replaceField && (e.preventDefault(), Sr(this.view));
	}
	update(e) {
		for (let t of e.transactions) for (let e of t.effects) e.is(q) && !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(H).top;
	}
};
function Q(e, t) {
	return e.state.phrase(t);
}
var Mr = 30, $ = /[\s\.,:;?!]/;
function Nr(e, { from: t, to: n }) {
	let r = e.state.doc.lineAt(t), i = e.state.doc.lineAt(n).to, a = Math.max(r.from, t - Mr), o = Math.min(i, n + Mr), s = e.state.sliceDoc(a, o);
	if (a != r.from) {
		for (let e = 0; e < Mr; e++) if (!$.test(s[e + 1]) && $.test(s[e])) {
			s = s.slice(e);
			break;
		}
	}
	if (o != i) {
		for (let e = s.length - 1; e > s.length - Mr; e--) if (!$.test(s[e - 1]) && $.test(s[e])) {
			s = s.slice(0, e);
			break;
		}
	}
	return l.announce.of(`${e.state.phrase("current match")}. ${s} ${e.state.phrase("on line")} ${r.number}.`);
}
var Pr = /* @__PURE__ */ l.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" }
}), Fr = [
	J,
	/* @__PURE__ */ n.low(yr),
	Pr
];
//#endregion
//#region src/editors/base.ts
function Ir(e) {
	if (typeof e == "string") {
		let t = document.querySelector(e);
		if (!t) throw Error(`Editor container not found: ${e}`);
		return t;
	}
	return e;
}
var Lr = Se.define([
	{
		tag: h.keyword,
		color: "var(--cmm-editor-keyword, #7c3aed)"
	},
	{
		tag: h.operator,
		color: "var(--cmm-editor-operator, #0891b2)"
	},
	{
		tag: [h.string, h.special(h.string)],
		color: "var(--cmm-editor-string, #059669)"
	},
	{
		tag: h.number,
		color: "var(--cmm-editor-number, #d97706)"
	},
	{
		tag: h.comment,
		color: "var(--cmm-editor-comment, #6b7280)",
		fontStyle: "italic"
	},
	{
		tag: h.variableName,
		color: "var(--cmm-editor-variable, #1e40af)"
	},
	{
		tag: [h.function(h.variableName)],
		color: "var(--cmm-editor-function, #2563eb)"
	},
	{
		tag: h.typeName,
		color: "var(--cmm-editor-type, #0891b2)"
	},
	{
		tag: h.propertyName,
		color: "var(--cmm-editor-property, #7c3aed)"
	},
	{
		tag: h.bool,
		color: "var(--cmm-editor-atom, #d97706)"
	},
	{
		tag: h.null,
		color: "var(--cmm-editor-atom, #d97706)"
	},
	{
		tag: h.atom,
		color: "var(--cmm-editor-atom, #d97706)"
	},
	{
		tag: h.meta,
		color: "var(--cmm-editor-meta, #6b7280)"
	},
	{
		tag: h.labelName,
		color: "var(--cmm-editor-label, #2563eb)"
	},
	{
		tag: h.namespace,
		color: "var(--cmm-editor-namespace, #0891b2)"
	},
	{
		tag: h.regexp,
		color: "var(--cmm-editor-regexp, #dc2626)"
	},
	{
		tag: h.bracket,
		color: "var(--cmm-editor-bracket, #6b7280)"
	},
	{
		tag: h.punctuation,
		color: "var(--cmm-editor-punctuation, #6b7280)"
	},
	{
		tag: h.tagName,
		color: "var(--cmm-editor-tag, #dc2626)"
	},
	{
		tag: h.attributeName,
		color: "var(--cmm-editor-attribute, #d97706)"
	}
]), Rr = l.theme({
	"&": {
		fontSize: "14px",
		backgroundColor: "var(--cmm-bg-primary, #ffffff)",
		color: "var(--cmm-text-primary, #0f172a)",
		borderRadius: "var(--radius-sm, 0.25rem)"
	},
	"&.cm-focused": {
		outline: "2px solid var(--cmm-accent, #2563eb)",
		outlineOffset: "-2px"
	},
	".cm-content": {
		padding: "8px 0",
		caretColor: "var(--cmm-text-primary, #0f172a)",
		fontFamily: "'JetBrains Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace"
	},
	".cm-cursor, .cm-dropCursor": {
		borderLeftColor: "var(--cmm-text-primary, #0f172a)",
		borderLeftWidth: "2px"
	},
	".cm-gutters": {
		backgroundColor: "var(--cmm-bg-secondary, #f8fafc)",
		color: "var(--cmm-text-muted, #64748b)",
		borderRight: "1px solid var(--cmm-border, #e2e8f0)",
		fontFamily: "'JetBrains Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace",
		fontSize: "13px"
	},
	".cm-activeLineGutter": {
		backgroundColor: "transparent",
		color: "var(--cmm-text-secondary, #334155)"
	},
	"&.cm-focused .cm-selectionBackground, .cm-selectionBackground": { backgroundColor: "var(--cmm-editor-selection, rgba(59, 130, 246, 0.2))" },
	".cm-activeLine": { backgroundColor: "var(--cmm-editor-active-line, rgba(0, 0, 0, 0.04))" },
	".cm-matchingBracket": {
		backgroundColor: "var(--cmm-editor-bracket-match, rgba(59, 130, 246, 0.3))",
		outline: "1px solid var(--cmm-accent, #2563eb)"
	},
	".cm-selectionMatch": { backgroundColor: "var(--cmm-editor-selection-match, rgba(34, 197, 94, 0.15))" },
	".cm-foldPlaceholder": {
		backgroundColor: "var(--cmm-bg-tertiary, #f1f5f9)",
		border: "1px solid var(--cmm-border, #e2e8f0)",
		color: "var(--cmm-text-muted, #64748b)"
	},
	".cm-tooltip": {
		backgroundColor: "var(--cmm-bg-secondary, #f8fafc)",
		border: "1px solid var(--cmm-border, #e2e8f0)",
		color: "var(--cmm-text-primary, #0f172a)",
		borderRadius: "6px",
		boxShadow: "var(--shadow-md, 0 4px 6px -1px rgb(0 0 0 / 0.1))"
	},
	".cm-tooltip-autocomplete > ul > li[aria-selected]": {
		backgroundColor: "var(--cmm-accent, #2563eb)",
		color: "white"
	},
	".cm-panels": {
		backgroundColor: "var(--cmm-bg-secondary, #f8fafc)",
		color: "var(--cmm-text-primary, #0f172a)"
	},
	".cm-panels.cm-panels-top": { borderBottom: "1px solid var(--cmm-border, #e2e8f0)" },
	".cm-panels.cm-panels-bottom": { borderTop: "1px solid var(--cmm-border, #e2e8f0)" },
	".cm-textfield": {
		backgroundColor: "var(--cmm-bg-primary, #ffffff)",
		border: "1px solid var(--cmm-border, #e2e8f0)",
		borderRadius: "4px",
		padding: "2px 6px",
		fontSize: "13px",
		color: "var(--cmm-text-primary, #0f172a)"
	},
	".cm-button": {
		backgroundColor: "var(--cmm-bg-tertiary, #f1f5f9)",
		border: "1px solid var(--cmm-border, #e2e8f0)",
		borderRadius: "4px",
		padding: "2px 8px",
		fontSize: "13px",
		cursor: "pointer",
		color: "var(--cmm-text-primary, #0f172a)"
	}
}), zr = class {
	view;
	container;
	readOnlyCompartment = new Te();
	lineNumbersCompartment = new Te();
	wordWrapCompartment = new Te();
	onChangeCallback;
	constructor(t, n = []) {
		this.container = Ir(t.container), this.onChangeCallback = t.onChange ?? null;
		let r = t.lineNumbers !== !1, i = t.wordWrap === !0, a = t.readOnly === !0, o = t.tabSize ?? 2, s = [
			xe(),
			Ge(),
			ie(),
			ae(),
			y.allowMultipleSelections.of(!0),
			Ee(),
			he(),
			ke(),
			Ce(),
			Xn(),
			e(Lr),
			e(le, { fallback: !0 }),
			Rr,
			oe.of([
				...Oe,
				...Ln,
				...Ar,
				...at,
				Rn
			]),
			y.tabSize.of(o),
			this.lineNumbersCompartment.of(r ? [be(), ye()] : []),
			this.wordWrapCompartment.of(i ? l.lineWrapping : []),
			this.readOnlyCompartment.of(a ? y.readOnly.of(!0) : []),
			...t.placeholder ? [se(t.placeholder)] : [],
			l.updateListener.of((e) => {
				e.docChanged && this.onChangeCallback && this.onChangeCallback(e.state.doc.toString());
			}),
			...n
		];
		this.view = new l({
			state: y.create({
				doc: t.value ?? "",
				extensions: s
			}),
			parent: this.container
		});
	}
	getValue() {
		return this.view.state.doc.toString();
	}
	setValue(e) {
		this.view.dispatch({ changes: {
			from: 0,
			to: this.view.state.doc.length,
			insert: e
		} });
	}
	setReadOnly(e) {
		this.view.dispatch({ effects: this.readOnlyCompartment.reconfigure(e ? y.readOnly.of(!0) : []) });
	}
	setLineNumbers(e) {
		this.view.dispatch({ effects: this.lineNumbersCompartment.reconfigure(e ? [be(), ye()] : []) });
	}
	setWordWrap(e) {
		this.view.dispatch({ effects: this.wordWrapCompartment.reconfigure(e ? l.lineWrapping : []) });
	}
	focus() {
		this.view.focus();
	}
	blur() {
		this.view.contentDOM.blur();
	}
	getLineCount() {
		return this.view.state.doc.lines;
	}
	scrollToLine(e) {
		let t = Math.min(Math.max(1, e), this.view.state.doc.lines), n = this.view.state.doc.line(t);
		this.view.dispatch({ effects: l.scrollIntoView(n.from, { y: "center" }) });
	}
	getView() {
		return this.view;
	}
	setOnChange(e) {
		this.onChangeCallback = e;
	}
	destroy() {
		this.view.destroy();
	}
};
//#endregion
export { or as a, Lr as i, Rr as n, Ar as o, Ir as r, zr as t };

//# sourceMappingURL=base-B7MLNUXu.js.map