UNPKG

@blocknote/core

Version:

A "Notion-style" block-based extensible text editor built on top of Prosemirror and Tiptap.

3,514 lines 115 kB
import { n as e, o as t, t as n } from "./BlockNoteExtension-CbvDA0F7.js";
import { DOMParser as r, Fragment as i, Slice as a } from "prosemirror-model";
import { ReplaceStep as o } from "prosemirror-transform";
import { Extension as s, InputRule as c, Mark as l, Node as u, callOrReturn as d, combineTransactionSteps as f, findChildrenInRange as p, findParentNode as m, getChangedRanges as h, getExtensionField as g, markInputRule as _, mergeAttributes as v } from "@tiptap/core";
import { uuidv4 as ee } from "lib0/random";
import { Plugin as te, PluginKey as ne, TextSelection as re } from "prosemirror-state";
import { DOMParser as ie, DOMSerializer as ae, Fragment as oe } from "@tiptap/pm/model";
import { CellSelection as se, TableMap as ce, TableView as le, columnResizing as ue, goToNextCell as de, isInTable as fe, moveCellForward as pe, nextCell as me, selectionCell as he, tableEditing as ge } from "prosemirror-tables";
import { Plugin as _e, PluginKey as ve } from "@tiptap/pm/state";
import { Decoration as ye, DecorationSet as be } from "@tiptap/pm/view";
import { Decoration as xe, DecorationSet as Se } from "prosemirror-view";
import Ce from "@tiptap/extension-bold";
import we from "@tiptap/extension-code";
import Te from "@tiptap/extension-italic";
import Ee from "@tiptap/extension-strike";
import De from "@tiptap/extension-underline";
//#region src/api/getBlockInfoFromPos.ts
function Oe(e) {
	return e.marks.some((e) => ["y-attributed-delete"].includes(e.type.name));
}
function ke(e, t) {
	let n = e.attrs.id;
	if (!n) throw Error(`Node ${e.type.name} does not have an ID`);
	if (Oe(e)) {
		let r = 0, i = !1;
		if (t.descendants((t) => {
			if (i) return !1;
			if (t.attrs.id === n) {
				if (t === e) return i = !0, !1;
				r++;
			}
			return !0;
		}), !i) throw Error(`Node ${e.type.name} with ID ${n} not found in document`);
		return `${n}-${r}`;
	}
	return n;
}
function Ae(e, t) {
	let n = e.resolve(t);
	if (n.nodeAfter && n.nodeAfter.type.isInGroup("bnBlock")) return {
		posBeforeNode: n.pos,
		node: n.nodeAfter
	};
	let r = n.depth, i = n.node(r);
	for (; r > 0;) {
		if (i.type.isInGroup("bnBlock")) return {
			posBeforeNode: n.before(r),
			node: i
		};
		r--, i = n.node(r);
	}
	let a = [];
	e.descendants((e, t) => {
		e.type.isInGroup("bnBlock") && a.push(t);
	}), console.warn(`Position ${t} is not within a blockContainer node.`);
	let o = e.resolve(a.find((e) => e >= t) || a[a.length - 1]);
	return {
		posBeforeNode: o.pos,
		node: o.nodeAfter
	};
}
function y(e, t) {
	if (!e.type.isInGroup("bnBlock")) throw Error(`Attempted to get bnBlock node at position but found node of different type ${e.type.name}`);
	let n = e, r = t, i = {
		node: n,
		beforePos: r,
		afterPos: r + n.nodeSize
	};
	if (n.type.name === "blockContainer") {
		let e, t;
		if (n.forEach((n, i) => {
			if (n.type.spec.group === "blockContent") {
				let t = n, a = r + i + 1;
				e = {
					node: t,
					beforePos: a,
					afterPos: a + n.nodeSize
				};
			} else if (n.type.name === "blockGroup") {
				let e = n, a = r + i + 1;
				t = {
					node: e,
					beforePos: a,
					afterPos: a + n.nodeSize
				};
			}
		}), !e) throw Error(`blockContainer node does not contain a blockContent node in its children: ${n}`);
		return {
			isBlockContainer: !0,
			bnBlock: i,
			blockContent: e,
			childContainer: t,
			blockNoteType: e.node.type.name
		};
	}
	if (!i.node.type.isInGroup("childContainer")) throw Error(`bnBlock node is not in the childContainer group: ${i.node}`);
	return {
		isBlockContainer: !1,
		bnBlock: i,
		childContainer: i,
		blockNoteType: i.node.type.name
	};
}
function b(e) {
	return y(e.node, e.posBeforeNode);
}
function je(e) {
	if (!e.nodeAfter) throw Error(`Attempted to get blockContainer node at position ${e.pos} but a node at this position does not exist`);
	return y(e.nodeAfter, e.pos);
}
function Me(e) {
	return Ne(e, e.selection.anchor);
}
function Ne(e, t) {
	return b(Ae(e.doc, t));
}
//#endregion
//#region src/extensions/tiptap-extensions/UniqueID/UniqueID.ts
function Pe(e, t = JSON.stringify) {
	let n = {};
	return e.filter((e) => {
		let r = t(e);
		return Object.prototype.hasOwnProperty.call(n, r) ? !1 : n[r] = !0;
	});
}
function Fe(e) {
	return Pe(e.filter((t, n) => e.indexOf(t) !== n));
}
function Ie(e) {
	return e.marks.some((e) => e.type.name === "y-attributed-delete");
}
var Le = s.create({
	name: "uniqueID",
	priority: 1e4,
	addOptions() {
		return {
			types: [],
			setIdAttribute: !1,
			isWithinEditor: void 0,
			generateID: () => {
				if (typeof window < "u" && window.__TEST_OPTIONS) {
					let e = window.__TEST_OPTIONS;
					return e.mockID === void 0 ? e.mockID = 0 : e.mockID++, e.mockID.toString();
				}
				return ee();
			}
		};
	},
	addGlobalAttributes() {
		return [{
			types: this.options.types,
			attributes: { id: {
				default: null,
				parseHTML: (e) => e.getAttribute("data-id"),
				renderHTML: (e) => {
					let t = { "data-id": e.id };
					return this.options.setIdAttribute ? {
						...t,
						id: e.id
					} : t;
				}
			} }
		}];
	},
	addProseMirrorPlugins() {
		let { isWithinEditor: e } = this.options, t = null, n = !1;
		return [new te({
			key: new ne("uniqueID"),
			appendTransaction: (e, t, n) => {
				if (!(e.some((e) => e.docChanged) && !t.doc.eq(n.doc))) return;
				let { tr: r } = n, { types: i, generateID: a } = this.options, o = f(t.doc, e), { mapping: s } = o;
				if (h(o).forEach(({ newRange: e }) => {
					let o = p(n.doc, e, (e) => i.includes(e.type.name)), c = Fe(o.map(({ node: e }) => e.attrs.id).filter((e) => e !== null));
					o.forEach(({ node: e, pos: i }) => {
						if (Ie(e)) return;
						let o = r.doc.nodeAt(i)?.attrs.id;
						if (o === null) {
							let o = t.doc.type.createAndFill().content;
							if (t.doc.content.findDiffStart(o) === null) {
								let t = JSON.parse(JSON.stringify(n.doc.toJSON()));
								if (t.content[0].content[0].attrs.id = "initialBlockId", JSON.stringify(t.content) === JSON.stringify(o.toJSON())) {
									r.setNodeMarkup(i, void 0, {
										...e.attrs,
										id: "initialBlockId"
									});
									return;
								}
							}
							r.setNodeMarkup(i, void 0, {
								...e.attrs,
								id: a()
							});
							return;
						}
						let { deleted: l } = s.invert().mapResult(i);
						l && c.includes(o) && !Oe(e) && r.setNodeMarkup(i, void 0, {
							...e.attrs,
							id: a()
						});
					});
				}), r.steps.length) return r.setMeta("uniqueID", !0), r;
			},
			view(n) {
				let r = (r) => {
					let i = n.dom.parentElement;
					t = i?.contains(r.target) || e?.(r.target) ? i : null;
				};
				return window.addEventListener("dragstart", r), { destroy() {
					window.removeEventListener("dragstart", r);
				} };
			},
			props: {
				handleDOMEvents: {
					drop: (e, r) => (n = t !== e.dom.parentElement || r.dataTransfer?.effectAllowed === "copy", t = null, !1),
					paste: () => (n = !0, !1)
				},
				transformPasted: (e) => {
					if (!n) return e;
					let { types: t } = this.options, r = (e) => {
						let n = [];
						return e.forEach((e) => {
							if (e.isText) {
								n.push(e);
								return;
							}
							if (!t.includes(e.type.name)) {
								n.push(e.copy(r(e.content)));
								return;
							}
							let i = e.type.create({
								...e.attrs,
								id: null
							}, r(e.content), e.marks);
							n.push(i);
						}), i.from(n);
					};
					return n = !1, new a(r(e.content), e.openStart, e.openEnd);
				}
			}
		})];
	}
});
//#endregion
//#region src/schema/inlineContent/types.ts
function Re(e) {
	return e.type === "link";
}
function ze(e) {
	return typeof e != "string" && e.type === "link";
}
function x(e) {
	return typeof e != "string" && e.type === "text";
}
//#endregion
//#region src/util/table.ts
function Be(e) {
	return C(e) ? { ...e } : S(e) ? {
		type: "tableCell",
		content: [].concat(e.content),
		props: {
			backgroundColor: e.props?.backgroundColor ?? "default",
			textColor: e.props?.textColor ?? "default",
			textAlignment: e.props?.textAlignment ?? "left",
			colspan: e.props?.colspan ?? 1,
			rowspan: e.props?.rowspan ?? 1
		}
	} : {
		type: "tableCell",
		content: [].concat(e),
		props: {
			backgroundColor: "default",
			textColor: "default",
			textAlignment: "left",
			colspan: 1,
			rowspan: 1
		}
	};
}
function S(e) {
	return e != null && typeof e != "string" && !Array.isArray(e) && e.type === "tableCell";
}
function C(e) {
	return S(e) && e.props !== void 0 && e.content !== void 0;
}
function w(e) {
	return C(e) ? e.props.colspan ?? 1 : 1;
}
function T(e) {
	return C(e) ? e.props.rowspan ?? 1 : 1;
}
//#endregion
//#region src/util/typescript.ts
var E = class extends Error {
	constructor(e) {
		super(`Unreachable case: ${e}`);
	}
};
function Ve(e, t = !0) {
	let { "data-test": n, ...r } = e;
	if (Object.keys(r).length > 0 && t) throw Error("Object must be empty " + JSON.stringify(e));
}
//#endregion
//#region src/util/browser.ts
var He = () => typeof navigator < "u" && (/Mac/.test(navigator.platform) || /AppleWebKit/.test(navigator.userAgent) && /Mobile\/\w+/.test(navigator.userAgent));
function D(e, t = "Ctrl") {
	return He() ? e.replace("Mod", "⌘") : e.replace("Mod", t);
}
function O(...e) {
	return [...new Set(e.filter((e) => e).join(" ").split(" "))].join(" ");
}
var Ue = () => /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
//#endregion
//#region src/blocks/defaultBlockHelpers.ts
function We(e, t, n, r) {
	let i = document.createElement("div");
	i.className = O("bn-block-content", n.class), i.setAttribute("data-content-type", e);
	for (let [e, t] of Object.entries(n)) e !== "class" && i.setAttribute(e, t);
	let a = document.createElement(t);
	a.className = O("bn-inline-content", r.class);
	for (let [e, t] of Object.entries(r)) e !== "class" && a.setAttribute(e, t);
	return i.appendChild(a), {
		dom: i,
		contentDOM: a
	};
}
var Ge = (e, t) => {
	let n = H(e, t.pmSchema);
	n.type.name === "blockContainer" && (n = n.firstChild);
	let r = t.pmSchema.nodes[n.type.name].spec.toDOM;
	if (r === void 0) throw Error("This block has no default HTML serialization as its corresponding TipTap node doesn't implement `renderHTML`.");
	let i = r(n);
	if (typeof i != "object" || !("dom" in i)) throw Error("Cannot use this block's default HTML serialization as its corresponding TipTap node's `renderHTML` function does not return an object with the `dom` property.");
	return i;
};
function Ke(e, t = "<br>") {
	let n = e.querySelectorAll("p");
	if (n.length > 1) {
		let e = n[0];
		for (let r = 1; r < n.length; r++) {
			let i = n[r];
			e.innerHTML += t + i.innerHTML, i.remove();
		}
	}
}
//#endregion
//#region src/schema/nodeViewMutations.ts
function qe(e, t) {
	return e.type === "selection" ? !1 : !t || e.type === "attributes" || !t.contains(e.target);
}
function Je(e) {
	let t = e.ignoreMutation?.bind(e), n = e.contentDOM;
	e.ignoreMutation = (e) => qe(e, n) ? !0 : t ? t(e) : !1;
}
//#endregion
//#region src/api/pmUtil.ts
function k(e) {
	return "doc" in e ? e.doc.type.schema : e.type.schema;
}
function Ye(e) {
	return e.cached.blockNoteEditor;
}
function Xe(e) {
	return Ye(e).schema;
}
function Ze(e) {
	return Xe(e).blockSchema;
}
function Qe(e) {
	return Xe(e).inlineContentSchema;
}
function A(e) {
	return Xe(e).styleSchema;
}
function $e(e) {
	return Ye(e).blockCache;
}
function et(e, t) {
	if (Ze(e)[t.name]?.content === "plain") return !0;
	let n = Qe(e)[t.name];
	return typeof n == "object" && n.content === "plain";
}
//#endregion
//#region src/api/nodeConversions/nodeToBlock.ts
function tt(e, t, n) {
	let r = {
		type: "tableContent",
		columnWidths: [],
		headerRows: void 0,
		headerCols: void 0,
		rows: []
	}, i = [];
	e.content.forEach((e, a, o) => {
		let s = { cells: [] };
		o === 0 && e.content.forEach((e) => {
			let t = e.attrs.colwidth;
			t ??= Array(e.attrs.colspan ?? 1).fill(void 0), r.columnWidths.push(...t);
		}), s.cells = e.content.content.map((e, r) => (i[o] || (i[o] = []), i[o][r] = e.type.name === "tableHeader", {
			type: "tableCell",
			content: e.content.content.map((e) => nt(e, t, n)).reduce((e, t) => {
				if (!e.length) return t;
				let n = e[e.length - 1], r = t[0];
				return r && x(n) && x(r) && JSON.stringify(n.styles) === JSON.stringify(r.styles) ? (n.text += "\n" + r.text, e.push(...t.slice(1)), e) : (e.push(...t), e);
			}, []),
			props: {
				colspan: e.attrs.colspan,
				rowspan: e.attrs.rowspan,
				backgroundColor: e.attrs.backgroundColor,
				textColor: e.attrs.textColor,
				textAlignment: e.attrs.textAlignment
			}
		})), r.rows.push(s);
	});
	for (let e = 0; e < i.length; e++) i[e]?.every((e) => e) && (r.headerRows = (r.headerRows ?? 0) + 1);
	for (let e = 0; e < i[0]?.length; e++) i?.every((t) => t[e]) && (r.headerCols = (r.headerCols ?? 0) + 1);
	return r;
}
function nt(e, t, n) {
	let r = [], i;
	return e.content.forEach((e) => {
		if (e.type.name === "hardBreak") {
			if (i) {
				if (x(i)) i.text += "\n";
				else if (Re(i)) i.content[i.content.length - 1].text += "\n";
				else throw Error("unexpected");
			} else i = {
				type: "text",
				text: "\n",
				styles: {}
			};
			return;
		}
		if (e.type.name !== "link" && e.type.name !== "text") {
			if (!t[e.type.name]) {
				console.warn("unrecognized inline content type", e.type.name);
				return;
			}
			i &&= (r.push(i), void 0), r.push(rt(e, t, n));
			return;
		}
		let a = {}, o;
		for (let t of e.marks) if (t.type.name === "link") o = t;
		else {
			let e = n[t.type.name];
			if (!e) {
				if (t.type.spec.blocknoteIgnore) continue;
				throw Error(`style ${t.type.name} not found in styleSchema`);
			}
			if (e.propSchema === "boolean") a[e.type] = !0;
			else if (e.propSchema === "string") a[e.type] = t.attrs.stringValue;
			else throw new E(e.propSchema);
		}
		i ? x(i) ? o ? (r.push(i), i = {
			type: "link",
			href: o.attrs.href,
			content: [{
				type: "text",
				text: e.textContent,
				styles: a
			}]
		}) : JSON.stringify(i.styles) === JSON.stringify(a) ? i.text += e.textContent : (r.push(i), i = {
			type: "text",
			text: e.textContent,
			styles: a
		}) : Re(i) && (o ? i.href === o.attrs.href ? JSON.stringify(i.content[i.content.length - 1].styles) === JSON.stringify(a) ? i.content[i.content.length - 1].text += e.textContent : i.content.push({
			type: "text",
			text: e.textContent,
			styles: a
		}) : (r.push(i), i = {
			type: "link",
			href: o.attrs.href,
			content: [{
				type: "text",
				text: e.textContent,
				styles: a
			}]
		}) : (r.push(i), i = {
			type: "text",
			text: e.textContent,
			styles: a
		})) : i = o ? {
			type: "link",
			href: o.attrs.href,
			content: [{
				type: "text",
				text: e.textContent,
				styles: a
			}]
		} : {
			type: "text",
			text: e.textContent,
			styles: a
		};
	}), i && r.push(i), r;
}
function rt(e, t, n) {
	if (e.type.name === "text" || e.type.name === "link") throw Error("unexpected");
	let r = {}, i = t[e.type.name];
	for (let [t, n] of Object.entries(e.attrs)) {
		if (!i) throw Error("ic node is of an unrecognized type: " + e.type.name);
		t in i.propSchema && (r[t] = n);
	}
	let a;
	return a = i.content === "styled" ? nt(e, t, n) : i.content === "plain" ? e.textContent : void 0, {
		type: e.type.name,
		props: r,
		content: a
	};
}
function j(e, t) {
	let n = e.type.schema, r = Ze(n), i = Qe(n), a = A(n), o = $e(n);
	if (!e.type.isInGroup("bnBlock")) throw Error("Node should be a bnBlock, but is instead: " + e.type.name);
	let s = o?.get(e);
	if (s) return s;
	let c = y(e, 0), l;
	try {
		l = ke(c.bnBlock.node, t);
	} catch {
		l = Le.options.generateID();
	}
	let u = r[c.blockNoteType];
	if (!u) throw Error("Block is of an unrecognized type: " + c.blockNoteType);
	let d = {};
	for (let [t, n] of Object.entries({
		...e.attrs,
		...c.isBlockContainer ? c.blockContent.node.attrs : {}
	})) {
		let e = u.propSchema;
		t in e && (e[t].default !== void 0 || n !== void 0) && (d[t] = n);
	}
	let f = r[c.blockNoteType], p = [];
	c.childContainer?.node.forEach((e) => {
		p.push(j(e, t));
	});
	let m;
	if (f.content === "inline") {
		if (!c.isBlockContainer) throw Error("impossible");
		m = nt(c.blockContent.node, i, a);
	} else if (f.content === "table") {
		if (!c.isBlockContainer) throw Error("impossible");
		m = tt(c.blockContent.node, i, a);
	} else if (f.content === "plain") {
		if (!c.isBlockContainer) throw Error("impossible");
		let e = c.blockContent.node.textContent;
		m = e.length > 0 ? [{
			type: "text",
			text: e,
			styles: {}
		}] : [];
	} else if (f.content === "none") m = void 0;
	else throw new E(f.content);
	let h = {
		id: l,
		type: f.type,
		props: d,
		content: m,
		children: p
	};
	return o?.set(e, h), h;
}
function it(e) {
	let t = [];
	return e.firstChild && e.firstChild.descendants((n) => (t.push(j(n, e)), !1)), t;
}
function at(e) {
	function t(n, r, i) {
		if (n.type.name !== "blockGroup") throw Error("unexpected");
		let a = [], o, s;
		return n.forEach((c, l, u) => {
			if (c.type.name !== "blockContainer") throw Error("unexpected");
			if (c.childCount === 0) return;
			if (c.childCount === 0 || c.childCount > 2) throw Error("unexpected, blockContainer.childCount: " + c.childCount);
			let d = u === 0, f = u === n.childCount - 1;
			if (c.firstChild.type.name === "blockGroup") {
				if (!d) throw Error("unexpected");
				let e = t(c.firstChild, Math.max(0, r - 1), f ? Math.max(0, i - 1) : 0);
				o = e.blockCutAtStart, f && (s = e.blockCutAtEnd), a.push(...e.blocks);
				return;
			}
			let p = j(c, e.content.firstChild), m = c.childCount > 1 ? c.child(1) : void 0, h = [];
			if (m) {
				let e = t(m, 0, f ? Math.max(0, i - 1) : 0);
				h = e.blocks, f && (s = e.blockCutAtEnd);
			}
			f && !m && i > 1 && (s = p.id), d && r > 1 && (o = p.id), a.push({
				...p,
				children: h
			});
		}), {
			blocks: a,
			blockCutAtStart: o,
			blockCutAtEnd: s
		};
	}
	if (e.content.childCount === 0) return {
		blocks: [],
		blockCutAtStart: void 0,
		blockCutAtEnd: void 0
	};
	if (e.content.childCount !== 1) throw Error("slice must be a single block, did you forget includeParents=true?");
	return t(e.content.firstChild, Math.max(e.openStart - 1, 0), Math.max(e.openEnd - 1, 0));
}
//#endregion
//#region src/util/string.ts
function M(e) {
	return "data-" + e.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
}
function ot(e) {
	let t = e.split("/");
	return !t.length || t[t.length - 1] === "" ? e : t[t.length - 1];
}
function st(e) {
	let t = [
		"mp4",
		"webm",
		"ogg",
		"mov",
		"mkv",
		"flv",
		"avi",
		"wmv",
		"m4v"
	];
	try {
		let n = new URL(e).pathname.split(".").pop()?.toLowerCase() || "";
		return t.includes(n);
	} catch {
		return !1;
	}
}
//#endregion
//#region src/schema/blocks/internal.ts
function ct(e) {
	let t = {};
	return Object.entries(e).forEach(([e, n]) => {
		t[e] = {
			default: n.default,
			keepOnSplit: !0,
			parseHTML: (t) => {
				let r = t.getAttribute(M(e));
				if (r === null) return null;
				if (n.default === void 0 && n.type === "boolean" || n.default !== void 0 && typeof n.default == "boolean") return r === "true" || r !== "false" && null;
				if (n.default === void 0 && n.type === "number" || n.default !== void 0 && typeof n.default == "number") {
					let e = parseFloat(r);
					return !Number.isNaN(e) && Number.isFinite(e) ? e : null;
				}
				return r;
			},
			renderHTML: (t) => t[e] === n.default ? {} : { [M(e)]: t[e] }
		};
	}), t;
}
function lt(e, t) {
	let n = e();
	if (n === void 0) throw Error("Cannot find node position");
	let r = t.resolve(n).node();
	if (!r) throw Error("Cannot find block container");
	return j(r, t);
}
function ut(e, t, n) {
	try {
		return lt(e, n);
	} catch (e) {
		let r = n.type.schema.nodes.blockContainer?.createAndFill(null, t);
		if (r) return j(r, n);
		throw e;
	}
}
function N(e, t, n, r, i = !1, a) {
	let o = document.createElement("div");
	if (a !== void 0) for (let [e, t] of Object.entries(a)) e !== "class" && o.setAttribute(e, t);
	o.className = O("bn-block-content", a?.class || ""), o.setAttribute("data-content-type", t);
	for (let [e, t] of Object.entries(n)) t !== r[e]?.default && o.setAttribute(M(e), t);
	return i && o.setAttribute("data-file-block", ""), o.appendChild(e.dom), e.contentDOM && (e.contentDOM.className = O("bn-inline-content", e.contentDOM.className)), {
		...e,
		dom: o
	};
}
function dt(e, t, n) {
	return {
		config: {
			type: e.type,
			content: e.content,
			propSchema: t
		},
		implementation: {
			node: e.node,
			render: Ge,
			toExternalHTML: Ge
		},
		extensions: n
	};
}
//#endregion
//#region src/schema/blocks/createSpec.ts
function ft(e, t) {
	e.stopEvent = (e) => (e.type === "mousedown" && setTimeout(() => {
		t.view.dom.blur();
	}, 10), !0);
}
function pt(e, t) {
	let n = [{
		tag: "[data-content-type=" + e.type + "]",
		contentElement: ".bn-inline-content"
	}];
	return t.parse && n.push({
		tag: "*",
		getAttrs(e) {
			if (typeof e == "string") return !1;
			let n = t.parse?.(e);
			return n !== void 0 && n;
		},
		preserveWhitespace: !0,
		getContent: e.content === "inline" || e.content === "none" || e.content === "plain" ? (n, r) => {
			if (t.parseContent) {
				let e = t.parseContent({
					el: n,
					schema: r
				});
				if (e !== void 0) return e;
			}
			if (e.content === "inline" || e.content === "plain") {
				let i = n.cloneNode(!0);
				Ke(i, e.content === "plain" || t.meta?.code ? "\n" : "<br>");
				let a = ie.fromSchema(r).parse(i, {
					topNode: r.nodes.paragraph.create(),
					preserveWhitespace: !0
				});
				if (e.content === "plain") {
					let e = [];
					return a.content.forEach((t) => {
						if (t.isText) e.push(t);
						else {
							let n = t.type === r.linebreakReplacement ? "\n" : t.textContent;
							n && e.push(r.text(n, t.marks));
						}
					}), oe.fromArray(e);
				}
				return a.content;
			}
			return oe.empty;
		} : void 0
	}), n;
}
function mt(e, n, r, i) {
	let a = n.node || u.create({
		name: e.type,
		content: e.content === "inline" ? "inline*" : e.content === "plain" ? "text*" : e.content === "none" ? "" : e.content,
		marks() {
			return e.content === "plain" ? t(this.editor) : void 0;
		},
		group: "blockContent",
		selectable: n.meta?.selectable ?? !0,
		isolating: n.meta?.isolating ?? !0,
		code: n.meta?.code ?? !1,
		defining: n.meta?.defining ?? !0,
		priority: i,
		addAttributes() {
			return ct(e.propSchema);
		},
		parseHTML() {
			return pt(e, n);
		},
		renderHTML({ HTMLAttributes: t }) {
			let r = document.createElement("div");
			return N({
				dom: r,
				contentDOM: e.content === "inline" || e.content === "plain" ? r : void 0
			}, e.type, {}, e.propSchema, n.meta?.fileBlockAccept !== void 0, t);
		},
		addNodeView() {
			return (t) => {
				let r = this.options.editor, i = ut(t.getPos, t.node, t.view.state.doc), a = this.options.domAttributes?.blockContent || {}, o = n.render.call({
					blockContentDOMAttributes: a,
					props: t,
					renderType: "nodeView",
					propSchema: e.propSchema
				}, i, r);
				return n.meta?.selectable === !1 && ft(o, this.editor), Je(o), o;
			};
		}
	});
	if (a.name !== e.type) throw Error("Node name does not match block type. This is a bug in BlockNote.");
	return {
		config: e,
		implementation: {
			...n,
			node: a,
			render(t, r) {
				let i = a.options.domAttributes?.blockContent || {};
				return n.render.call({
					blockContentDOMAttributes: i,
					props: void 0,
					renderType: "dom",
					propSchema: e.propSchema
				}, t, r);
			},
			toExternalHTML: (t, r, i) => {
				let o = a.options.domAttributes?.blockContent || {};
				return n.toExternalHTML?.call({
					blockContentDOMAttributes: o,
					propSchema: e.propSchema
				}, t, r, i) ?? n.render.call({
					blockContentDOMAttributes: o,
					renderType: "dom",
					props: void 0,
					propSchema: e.propSchema
				}, t, r);
			}
		},
		extensions: r
	};
}
function P(e) {
	return e;
}
function F(e, t, n) {
	return (r = {}) => {
		let i = typeof e == "function" ? e(r) : e, a = typeof t == "function" ? t(r) : t, o = n ? typeof n == "function" ? n(r) : n : void 0;
		return {
			config: i,
			implementation: {
				...a,
				toExternalHTML(e, t, n) {
					let r = a.toExternalHTML?.call({ blockContentDOMAttributes: this.blockContentDOMAttributes }, e, t, n);
					if (r !== void 0) return N(r, e.type, e.props, this.propSchema ?? i.propSchema, a.meta?.fileBlockAccept !== void 0);
				},
				render(e, t) {
					return N(a.render.call({
						blockContentDOMAttributes: this.blockContentDOMAttributes,
						renderType: this.renderType,
						props: this.props
					}, e, t), e.type, e.props, this.propSchema ?? i.propSchema, a.meta?.fileBlockAccept !== void 0, this.blockContentDOMAttributes);
				}
			},
			extensions: o
		};
	};
}
//#endregion
//#region src/schema/inlineContent/internal.ts
function ht(e, t, n, r) {
	return e.dom.setAttribute("data-inline-content-type", t), Object.entries(n).filter(([e, t]) => t !== r[e]?.default).map(([e, t]) => [M(e), t]).forEach(([t, n]) => e.dom.setAttribute(t, n)), e.contentDOM && e.contentDOM.setAttribute("data-editable", ""), e;
}
function gt(e) {
	return { Backspace: ({ editor: t }) => {
		let n = t.state.selection.$from;
		return t.state.selection.empty && n.node().type.name === e.type && n.parentOffset === 0;
	} };
}
function _t(e, t, n) {
	return {
		config: e,
		implementation: t,
		extensions: n
	};
}
function vt(e, t, n) {
	return _t({
		type: e.name,
		propSchema: t,
		content: e.config.content === "inline*" ? "styled" : e.config.content === "text*" ? "plain" : "none"
	}, {
		...n,
		node: e
	});
}
function yt(e) {
	return Object.fromEntries(Object.entries(e).map(([e, t]) => [e, t.config]));
}
//#endregion
//#region src/schema/styles/internal.ts
function bt(e) {
	return e === "boolean" ? {} : { stringValue: {
		default: void 0,
		keepOnSplit: !0,
		parseHTML: (e) => e.getAttribute("data-value"),
		renderHTML: (e) => e.stringValue === void 0 ? {} : { "data-value": e.stringValue }
	} };
}
function I(e, t, n, r) {
	return e.dom.setAttribute("data-style-type", t), r === "string" && e.dom.setAttribute("data-value", n), e.contentDOM && e.contentDOM.setAttribute("data-editable", ""), e;
}
function xt(e, t) {
	return {
		config: e,
		implementation: t
	};
}
function L(e, t) {
	return xt({
		type: e.name,
		propSchema: t
	}, {
		mark: e,
		render(t, n) {
			let r = n.pmSchema.marks[e.name].spec.toDOM;
			if (r === void 0) throw Error("This block has no default HTML serialization as its corresponding TipTap node doesn't implement `renderHTML`.");
			let i = n.pmSchema.mark(e.name, { stringValue: t }), a = ae.renderSpec(document, r(i, !0));
			if (typeof a != "object" || !("dom" in a)) throw Error("Cannot use this block's default HTML serialization as its corresponding TipTap mark's `renderHTML` function does not return an object with the `dom` property.");
			return a;
		},
		toExternalHTML(t, n) {
			let r = n.pmSchema.marks[e.name].spec.toDOM;
			if (r === void 0) throw Error("This block has no default HTML serialization as its corresponding TipTap node doesn't implement `renderHTML`.");
			let i = n.pmSchema.mark(e.name, { stringValue: t }), a = ae.renderSpec(document, r(i, !0));
			if (typeof a != "object" || !("dom" in a)) throw Error("Cannot use this block's default HTML serialization as its corresponding TipTap mark's `renderHTML` function does not return an object with the `dom` property.");
			return a;
		}
	});
}
function St(e) {
	return Object.fromEntries(Object.entries(e).map(([e, t]) => [e, t.config]));
}
//#endregion
//#region src/schema/styles/createSpec.ts
function Ct(e, t) {
	let n = [{
		tag: `[data-style-type="${e.type}"]`,
		contentElement: (e) => {
			let t = e;
			return t.matches("[data-editable]") ? t : t.querySelector("[data-editable]") || t;
		}
	}];
	return t && n.push({
		tag: "*",
		consuming: !1,
		getAttrs(e) {
			if (typeof e == "string") return !1;
			let n = t?.(e);
			return n !== void 0 && { stringValue: n };
		}
	}), n;
}
function wt(e, t) {
	let n = l.create({
		name: e.type,
		addAttributes() {
			return bt(e.propSchema);
		},
		parseHTML() {
			return Ct(e, t.parse);
		},
		renderHTML({ mark: n }) {
			return I((t.toExternalHTML || t.render)(n.attrs.stringValue), e.type, n.attrs.stringValue, e.propSchema);
		},
		addMarkView() {
			return ({ mark: n }) => I(t.render(n.attrs.stringValue), e.type, n.attrs.stringValue, e.propSchema);
		}
	});
	return xt(e, {
		...t,
		mark: n,
		render: (n) => I(t.render(n), e.type, n, e.propSchema),
		toExternalHTML: (n) => I((t.toExternalHTML || t.render)(n), e.type, n, e.propSchema)
	});
}
//#endregion
//#region src/util/topo-sort.ts
function Tt(e) {
	let t = Dt(e), { roots: n, nonRoots: r } = Ot(t), i = [];
	for (; n.size;) {
		i.push(n);
		let r = /* @__PURE__ */ new Set();
		for (let i of n) {
			let n = e.get(i);
			if (n) for (let e of n) {
				let n = t.get(e);
				if (n === void 0) continue;
				let i = n - 1;
				t.set(e, i), i === 0 && r.add(e);
			}
		}
		n = r;
	}
	if (r = Ot(t).nonRoots, r.size) throw Error(`Cycle(s) detected; toposort only works on acyclic graphs. Cyclic nodes: ${Array.from(r).join(", ")}`);
	return i;
}
function Et(e) {
	return Tt(kt(e));
}
function Dt(e) {
	let t = /* @__PURE__ */ new Map();
	for (let [n, r] of e.entries()) {
		t.has(n) || t.set(n, 0);
		for (let e of r) {
			let n = t.get(e) ?? 0;
			t.set(e, n + 1);
		}
	}
	return t;
}
function Ot(e) {
	let t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
	for (let [r, i] of e.entries()) i === 0 ? t.add(r) : n.add(r);
	return {
		roots: t,
		nonRoots: n
	};
}
function kt(e) {
	let t = /* @__PURE__ */ new Map();
	for (let [n, r] of e.entries()) {
		t.has(n) || t.set(n, /* @__PURE__ */ new Set());
		for (let e of r) t.has(e) || t.set(e, /* @__PURE__ */ new Set()), t.get(e).add(n);
	}
	return t;
}
function At() {
	return /* @__PURE__ */ new Map();
}
function jt(e, t, n) {
	return e.has(t) || e.set(t, /* @__PURE__ */ new Set()), e.get(t).add(n), e;
}
function Mt(e) {
	let t = At();
	for (let n of e) Array.isArray(n.runsBefore) && n.runsBefore.length > 0 ? n.runsBefore.forEach((e) => {
		jt(t, n.key, e);
	}) : jt(t, "default", n.key);
	let n = Et(t), r = n.findIndex((e) => e.has("default"));
	return (e) => 91 + (n.findIndex((t) => t.has(e)) + r) * 10;
}
//#endregion
//#region src/schema/schema.ts
function Nt(e) {
	return e && Object.fromEntries(Object.entries(e).filter(([, e]) => e !== void 0));
}
var Pt = class {
	opts;
	BlockNoteEditor = "only for types";
	Block = "only for types";
	PartialBlock = "only for types";
	inlineContentSpecs;
	styleSpecs;
	blockSpecs;
	blockSchema;
	inlineContentSchema;
	styleSchema;
	constructor(e) {
		this.opts = e;
		let { blockSpecs: t, inlineContentSpecs: n, styleSpecs: r, blockSchema: i, inlineContentSchema: a, styleSchema: o } = this.init();
		this.blockSpecs = t, this.styleSpecs = r, this.styleSchema = o, this.inlineContentSpecs = n, this.blockSchema = i, this.inlineContentSchema = a;
	}
	init() {
		let e = Mt(Object.entries({
			...this.opts.blockSpecs,
			...this.opts.inlineContentSpecs,
			...this.opts.styleSpecs
		}).map(([e, t]) => ({
			key: e,
			runsBefore: t.implementation?.runsBefore ?? []
		}))), t = Object.fromEntries(Object.entries(this.opts.blockSpecs).map(([t, n]) => [t, mt(n.config, n.implementation, n.extensions, e(t))])), n = Object.fromEntries(Object.entries(this.opts.inlineContentSpecs).map(([t, n]) => typeof n.config == "object" ? [t, {
			...n,
			implementation: {
				...n.implementation,
				node: n.implementation?.node.extend({ priority: e(t) })
			}
		}] : [t, n])), r = Object.fromEntries(Object.entries(this.opts.styleSpecs).map(([t, n]) => [t, {
			...n,
			implementation: {
				...n.implementation,
				mark: n.implementation?.mark.extend({ priority: e(t) })
			}
		}]));
		return {
			blockSpecs: t,
			blockSchema: Object.fromEntries(Object.entries(t).map(([e, t]) => [e, t.config])),
			inlineContentSpecs: Nt(n),
			styleSpecs: Nt(r),
			inlineContentSchema: yt(n),
			styleSchema: St(r)
		};
	}
	extend(e) {
		Object.assign(this.opts.blockSpecs, e.blockSpecs), Object.assign(this.opts.inlineContentSpecs, e.inlineContentSpecs), Object.assign(this.opts.styleSpecs, e.styleSpecs);
		let { blockSpecs: t, inlineContentSpecs: n, styleSpecs: r, blockSchema: i, inlineContentSchema: a, styleSchema: o } = this.init();
		return this.blockSpecs = t, this.styleSpecs = r, this.styleSchema = o, this.inlineContentSpecs = n, this.blockSchema = i, this.inlineContentSchema = a, this;
	}
};
//#endregion
//#region src/api/blockManipulation/tables/tables.ts
function R(e) {
	let { height: t, width: n } = Ft(e), r = Array(t).fill(!1).map(() => Array(n).fill(null)), i = (e, i) => {
		for (let a = e; a < t; a++) for (let e = i; e < n; e++) if (!r[a][e]) return {
			row: a,
			col: e
		};
		throw Error("Unable to create occupancy grid for table, no more available cells");
	};
	for (let t = 0; t < e.content.rows.length; t++) for (let n = 0; n < e.content.rows[t].cells.length; n++) {
		let a = Be(e.content.rows[t].cells[n]), o = T(a), s = w(a), { row: c, col: l } = i(t, n);
		for (let e = c; e < c + o; e++) for (let i = l; i < l + s; i++) {
			if (r[e][i]) throw Error(`Unable to create occupancy grid for table, cell at ${e},${i} is already occupied`);
			r[e][i] = {
				row: t,
				col: n,
				rowspan: o,
				colspan: s,
				cell: a
			};
		}
	}
	return r;
}
function z(e) {
	let t = /* @__PURE__ */ new Set();
	return e.map((e) => ({ cells: e.map((e) => !t.has(e.row + ":" + e.col) && (t.add(e.row + ":" + e.col), e.cell)).filter((e) => e !== !1) }));
}
function B(e, t, n = R(t)) {
	for (let t = 0; t < n.length; t++) for (let r = 0; r < n[t].length; r++) {
		let i = n[t][r];
		if (i && i.row === e.row && i.col === e.col) return {
			row: t,
			col: r,
			cell: i.cell
		};
	}
	throw Error(`Unable to resolve relative table cell indices for table, cell at ${e.row},${e.col} is not occupied`);
}
function Ft(e) {
	let t = e.content.rows.length, n = 0;
	return e.content.rows.forEach((e) => {
		let t = 0;
		e.cells.forEach((e) => {
			t += w(e);
		}), n = Math.max(n, t);
	}), {
		height: t,
		width: n
	};
}
function It(e, t, n = R(t)) {
	let r = n[e.row]?.[e.col];
	if (r) return {
		row: r.row,
		col: r.col,
		cell: r.cell
	};
}
function Lt(e, t) {
	let n = R(e);
	if (t < 0 || t >= n.length) return [];
	let r = 0;
	for (let e = 0; e < t; e++) {
		let e = n[r]?.[0];
		if (!e) return [];
		r += e.rowspan;
	}
	let i = Array(n[0].length).fill(!1).map((t, i) => It({
		row: r,
		col: i
	}, e, n)).filter((e) => e !== void 0);
	return i.filter((e, t) => i.findIndex((t) => t.row === e.row && t.col === e.col) === t);
}
function Rt(e, t) {
	let n = R(e);
	if (t < 0 || t >= n[0].length) return [];
	let r = 0;
	for (let e = 0; e < t; e++) {
		let e = n[0]?.[r];
		if (!e) return [];
		r += e.colspan;
	}
	let i = Array(n.length).fill(!1).map((t, i) => It({
		row: i,
		col: r
	}, e, n)).filter((e) => e !== void 0);
	return i.filter((e, t) => i.findIndex((t) => t.row === e.row && t.col === e.col) === t);
}
function zt(e, t, n, r = R(e)) {
	let { col: i } = B({
		row: 0,
		col: t
	}, e, r), { col: a } = B({
		row: 0,
		col: n
	}, e, r);
	return r.forEach((e) => {
		let [t] = e.splice(i, 1);
		e.splice(a, 0, t);
	}), z(r);
}
function Bt(e, t, n, r = R(e)) {
	let { row: i } = B({
		row: t,
		col: 0
	}, e, r), { row: a } = B({
		row: n,
		col: 0
	}, e, r), [o] = r.splice(i, 1);
	return r.splice(a, 0, o), z(r);
}
function Vt(e) {
	return e ? S(e) ? Vt(e.content) : typeof e == "string" ? e.length === 0 : Array.isArray(e) ? e.every((e) => typeof e == "string" ? e.length === 0 : x(e) ? e.text.length === 0 : ze(e) ? typeof e.content == "string" ? e.content.length === 0 : e.content.every((e) => e.text.length === 0) : !1) : !1 : !0;
}
function Ht(e, t, n = R(e)) {
	if (t === "columns") {
		let e = 0;
		for (let t = n[0].length - 1; t >= 0 && n.every((e) => Vt(e[t].cell) && e[t].colspan === 1); t--) e++;
		for (let t = n.length - 1; t >= 0; t--) {
			let r = Math.max(n[t].length - e, 1);
			n[t] = n[t].slice(0, r);
		}
		return z(n);
	}
	let r = 0;
	for (let e = n.length - 1; e >= 0 && n[e].every((e) => Vt(e.cell) && e.rowspan === 1); e--) r++;
	let i = Math.min(r, n.length - 1);
	return n.splice(n.length - i, i), z(n);
}
function Ut(e, t, n, r = R(e)) {
	let { width: i, height: a } = Ft(e);
	if (t === "columns") r.forEach((e, t) => {
		if (n >= 0) for (let r = 0; r < n; r++) e.push({
			row: t,
			col: Math.max(...e.map((e) => e.col)) + 1,
			rowspan: 1,
			colspan: 1,
			cell: Be("")
		});
		else e.splice(i + n, -1 * n);
	});
	else if (n > 0) for (let e = 0; e < n; e++) {
		let t = Array(i).fill(null).map((t, n) => ({
			row: a + e,
			col: n,
			rowspan: 1,
			colspan: 1,
			cell: Be("")
		}));
		r.push(t);
	}
	else n < 0 && r.splice(a + n, -1 * n);
	return z(r);
}
function Wt(e, t, n) {
	let r = Lt(e, n);
	if (!r.some((e) => T(e.cell) > 1)) return !0;
	let i = n, a = n;
	return r.forEach((e) => {
		let t = T(e.cell);
		i = Math.max(i, e.row + t - 1), a = Math.min(a, e.row);
	}), t < n ? n === i : n === a;
}
function Gt(e, t, n) {
	let r = Rt(e, n);
	if (!r.some((e) => w(e.cell) > 1)) return !0;
	let i = n, a = n;
	return r.forEach((e) => {
		let t = w(e.cell);
		i = Math.max(i, e.col + t - 1), a = Math.min(a, e.col);
	}), t < n ? n === i : n === a;
}
function Kt(e, t, n) {
	let r = B(e, n), i = B(t, n);
	return r.col === i.col;
}
//#endregion
//#region src/api/nodeConversions/blockToNode.ts
function qt(e, t, n, r) {
	let i = [];
	for (let [r, a] of Object.entries(e.styles || {})) {
		let e = n[r];
		if (!e) throw Error(`style ${r} not found in styleSchema`);
		if (e.propSchema === "boolean") a && i.push(t.mark(r));
		else if (e.propSchema === "string") a && i.push(t.mark(r, { stringValue: a }));
		else throw new E(e.propSchema);
	}
	let a = r && t.nodes[r] && et(t, t.nodes[r]) ? [...t.nodes[r].allowedMarks(i)] : i;
	return !r || !et(t, t.nodes[r]) ? e.text.split(/(\n)/g).filter((e) => e.length > 0).map((e) => e === "\n" ? t.nodes.hardBreak.createChecked() : t.text(e, a)) : e.text.length > 0 ? [t.text(e.text, a)] : [];
}
function Jt(e, t, n) {
	let r = t.marks.link.create({ href: e.href });
	return Yt(e.content, t, n).map((e) => {
		if (e.type.name === "text") return e.mark([...e.marks, r]);
		if (e.type.name === "hardBreak") return e;
		throw Error("unexpected node type");
	});
}
function Yt(e, t, n, r) {
	let i = [];
	if (typeof e == "string") return i.push(...qt({
		type: "text",
		text: e,
		styles: {}
	}, t, n, r)), i;
	for (let a of e) i.push(...qt(a, t, n, r));
	return i;
}
function V(e, t, n, r = A(t)) {
	let i = [];
	for (let a of e) typeof a == "string" ? i.push(...Yt(a, t, r, n)) : ze(a) ? i.push(...Jt(a, t, r)) : x(a) ? i.push(...Yt([a], t, r, n)) : i.push(Zt(a, t, r));
	return i;
}
function Xt(e, t, n = A(t)) {
	let r = [], i = Array(e.headerRows ?? 0).fill(!0), a = Array(e.headerCols ?? 0).fill(!0), o = e.columnWidths ?? [];
	for (let s = 0; s < e.rows.length; s++) {
		let c = e.rows[s], l = [], u = i[s];
		for (let r = 0; r < c.cells.length; r++) {
			let i = c.cells[r], d = a[r], f = null, p = B({
				row: s,
				col: r
			}, {
				type: "table",
				content: e
			}), m = o[p.col] ? [o[p.col]] : null;
			if (i) {
				if (typeof i == "string") f = t.text(i);
				else if (S(i)) {
					i.content && (f = V(i.content, t, "tableParagraph", n));
					let e = w(i);
					e > 1 && (m = Array(e).fill(!1).map((e, t) => o[p.col + t] ?? void 0));
				} else f = V(i, t, "tableParagraph", n);
			}
			let h = t.nodes[d || u ? "tableHeader" : "tableCell"].createChecked({
				...S(i) ? i.props : {},
				colwidth: m
			}, t.nodes.tableParagraph.createChecked(void 0, f));
			l.push(h);
		}
		let d = t.nodes.tableRow.createChecked({}, l);
		r.push(d);
	}
	return r;
}
function Zt(e, t, n) {
	let r, i = e.type;
	if (i === void 0 && (i = "paragraph"), !t.nodes[i]) throw Error(`node type ${i} not found in schema`);
	if (!e.content) r = t.nodes[i].createChecked(e.props);
	else if (typeof e.content == "string") {
		let a = V([e.content], t, i, n);
		r = t.nodes[i].createChecked(e.props, a);
	} else if (Array.isArray(e.content)) {
		let a = V(e.content, t, i, n);
		r = t.nodes[i].createChecked(e.props, a);
	} else if (e.content.type === "tableContent") {
		let a = Xt(e.content, t, n);
		r = t.nodes[i].createChecked(e.props, a);
	} else throw new E(e.content.type);
	return r;
}
function H(e, t, n = A(t)) {
	let r = e.id;
	r === void 0 && (r = Le.options.generateID());
	let i = [];
	if (e.children) for (let r of e.children) i.push(H(r, t, n));
	if (!e.type || t.nodes[e.type].isInGroup("blockContent")) {
		let a = Zt(e, t, n), o = i.length > 0 ? t.nodes.blockGroup.createChecked({}, i) : void 0;
		return t.nodes.blockContainer.createChecked({
			id: r,
			...e.props
		}, o ? [a, o] : a);
	}
	if (t.nodes[e.type].isInGroup("bnBlock")) return t.nodes[e.type].create({
		id: r,
		...e.props
	}, i);
	throw Error(`block type ${e.type} doesn't match blockContent or bnBlock group`);
}
//#endregion
//#region src/api/nodeUtil.ts
function Qt(e, t) {
	let n, r;
	if (t.firstChild.descendants((i, a) => n ? !1 : !$t(i) || !i.attrs.id || ke(i, t) !== e || (n = i, r = a + 1, !1)), n !== void 0 && r !== void 0) return {
		node: n,
		posBeforeNode: r
	};
}
function $t(e) {
	return e.type.isInGroup("bnBlock");
}
//#endregion
//#region src/api/blockManipulation/commands/updateBlock/updateBlock.ts
var en = (e, t) => ({ tr: n, dispatch: r }) => (r && U(n, e, t), !0);
function U(e, t, n, r, i) {
	let a = je(e.doc.resolve(t)), o = null;
	a.blockNoteType === "table" && (o = cn(e));
	let s = k(e);
	if (r !== void 0 && i !== void 0 && r > i) throw Error("Invalid replaceFromPos or replaceToPos");
	let c = s.nodes[a.blockNoteType], l = s.nodes[n.type || a.blockNoteType], u = l.isInGroup("bnBlock") ? l : s.nodes.blockContainer;
	if (a.isBlockContainer && l.isInGroup("blockContent")) {
		let t = r !== void 0 && r > a.blockContent.beforePos && r < a.blockContent.afterPos ? r - a.blockContent.beforePos - 1 : void 0, o = i !== void 0 && i > a.blockContent.beforePos && i < a.blockContent.afterPos ? i - a.blockContent.beforePos - 1 : void 0;
		on(n, e, a), tn(n, e, c, l, a, t, o);
	} else if (!a.isBlockContainer && l.isInGroup("bnBlock")) on(n, e, a);
	else {
		let t = H({
			children: j(a.bnBlock.node, e.doc).children,
			...n
		}, s);
		t.check(), e.replaceWith(a.bnBlock.beforePos, a.bnBlock.afterPos, t);
		return;
	}
	rn(e, a.bnBlock.beforePos, u, { ...n.props }), o && ln(e, a, o);
}
function tn(e, t, n, r, o, s, c) {
	let l = k(t), u = "keep";
	if (e.content) {
		if (typeof e.content == "string") u = V([e.content], l, r.name);
		else if (Array.isArray(e.content)) u = V(e.content, l, r.name);
		else if (e.content.type === "tableContent") u = Xt(e.content, l);
		else throw new E(e.content.type);
	} else {
		let e = o.blockContent.node.content;
		if (n.spec.content !== "" && r.spec.content !== n.spec.content && !r.validContent(e)) {
			if (r.inlineContent && n.inlineContent) {
				let e = o.blockContent.node.textContent;
				u = e.length > 0 ? [l.text(e)] : [];
			} else u = [];
		}
	}
	if (u === "keep") rn(t, o.blockContent.beforePos, r, { ...e.props });
	else if (s !== void 0 || c !== void 0) {
		let n = an(t, o.blockContent.beforePos, r, { ...e.props }), l = n + 1 + (s ?? 0), d = n + 1 + (c ?? o.blockContent.node.content.size), f = t.doc.resolve(n).depth, p = t.doc.resolve(l).depth, m = t.doc.resolve(d).depth;
		t.replace(l, d, new a(i.from(u), p - f - 1, m - f - 1));
	} else r === n || r.validContent(o.blockContent.node.content) ? nn(t, an(t, o.blockContent.beforePos, r, { ...e.props }), i.from(u)) : t.replaceWith(o.blockContent.beforePos, o.blockContent.afterPos, r.createChecked({
		...o.blockContent.node.attrs,
		...e.props
	}, u));
}
function nn(e, t, n) {
	let r = e.doc.nodeAt(t);
	if (!r) throw RangeError("No node at given position");
	let s = r.content, c = t + 1;
	if (r.isTextblock) {
		let t = s.findDiffStart(n);
		if (t === null) return;
		let { a: r, b: i } = s.findDiffEnd(n), o = Math.max(0, t - r, t - i);
		o > 0 && (r += o, i += o), e.replace(c + t, c + r, new a(n.cut(t, i), 0, 0));
		return;
	}
	let l = s.childCount, u = n.childCount, d = 0;
	for (; d < l && d < u && s.child(d).eq(n.child(d));) d++;
	let f = l, p = u;
	for (; f > d && p > d && s.child(f - 1).eq(n.child(p - 1));) f--, p--;
	if (d === f && d === p) return;
	let m = c;
	for (let e = 0; e < d; e++) m += s.child(e).nodeSize;
	let h = m;
	for (let e = d; e < f; e++) h += s.child(e).nodeSize;
	let g = [];
	for (let e = d; e < p; e++) g.push(n.child(e));
	e.step(new o(m, h, new a(i.from(g), 0, 0)));
}
function rn(e, t, n, r) {
	let i = e.doc.nodeAt(t);
	if (!i) throw RangeError("No node at given position");
	let a = n.spec.attrs ?? {}, o = {};
	for (let e of Object.keys(r)) e in a && (o[e] = r[e]);
	let s = {
		...i.attrs,
		...o
	};
	if (i.type === n) {
		for (let n of Object.keys(s)) s[n] !== i.attrs[n] && e.setNodeAttribute(t, n, s[n]);
		return;
	}
	e.setNodeMarkup(t, n, s);
}
function an(e, t, n, r) {
	let i = e.mapping.maps.length;
	return rn(e, t, n, r), e.mapping.slice(i).map(t, -1);
}
function on(e, t, n) {
	let r = k(t);
	if (e.children !== void 0 && e.children.length > 0) {
		let a = e.children.map((e) => {
			let t = H(e, r);
			return t.check(), t;
		});
		if (n.childContainer) nn(t, n.childContainer.beforePos, i.from(a));
		else {
			if (!n.isBlockContainer) throw Error("impossible");
			t.insert(n.blockContent.afterPos, r.nodes.blockGroup.createChecked({}, a));
		}
	}
}
function sn(e, t, n, r, i) {
	let a = typeof t == "string" ? t : t.id, o = Qt(a, e.doc);
	if (!o) throw Error(`Block with ID ${a} not found`);
	return U(e, o.posBeforeNode, n, r, i), j(e.doc.resolve(o.posBeforeNode + 1).node(), e.doc);
}
function cn(e) {
	let t = "selection" in e ? e.selection : null;
	if (!(t instanceof re)) return null;
	let n = e.doc.resolve(t.head), r = -1, i = -1;
	for (let e = n.depth; e >= 0; e--) {
		let t = n.node(e).type.name;
		if (r < 0 && (t === "tableCell" || t === "tableHeader") && (r = e), t === "table") {
			i = e;
			break;
		}
	}
	if (r < 0 || i < 0) return null;
	let a = n.before(r), o = n.before(i), s = e.doc.nodeAt(o);
	if (!s || s.type.name !== "table") return null;
	let c = ce.get(s), l = a - (o + 1), u = c.map.indexOf(l);
	if (u < 0) return null;
	let d = Math.floor(u / c.width), f = u % c.width, p = a + 1 + 1;
	return {
		row: d,
		col: f,
		offset: Math.max(0, t.head - p)
	};
}
function ln(e, t, n) {
	if (t.blockNoteType !== "table") return !1;
	let r = -1;
	if (t.isBlockContainer) r = e.mapping.map(t.blockContent.beforePos);
	else {
		let n = e.mapping.map(t.bnBlock.beforePos), i = n + (e.doc.nodeAt(n)?.nodeSize || 0);
		e.doc.nodesBetween(n, i, (e, t) => e.type.name !== "table" || (r = t, !1));
	}
	let i = r >= 0 ? e.doc.nodeAt(r) : null;
	if (!i || i.type.name !== "table") return !1;
	let a = ce.get(i), o = Math.max(0, Math.min(n.row, a.height - 1)), s = Math.max(0, Math.min(n.col, a.width - 1)), c = o * a.width + s, l = a.map[c];
	if (l == null) return !1;
	let u = r + 1 + l + 1, d = e.doc.nodeAt(u), f = u + 1, p = d ? d.content.size : 0, m = f + Math.max(0, Math.min(n.offset, p));
	return "selection" in e && e.setSelection(re.create(e.doc, m)), !0;
}
//#endregion
//#region src/editor/defaultColors.ts
var W = {
	gray: {
		text: "#9b9a97",
		background: "#ebeced"
	},
	brown: {
		text: "#64473a",
		background: "#e9e5e3"
	},
	red: {
		text: "#e03e3e",
		background: "#fbe4e4"
	},
	orange: {
		text: "#d9730d",
		background: "#f6e9d9"
	},
	yellow: {
		text: "#dfab01",
		background: "#fbf3db"
	},
	green: {
		text: "#4d6461",
		background: "#ddedea"
	},
	blue: {
		text: "#0b6e99",
		background: "#ddebf1"
	},
	purple: {
		text: "#6940a5",
		background: "#eae4f2"
	},
	pink: {
		text: "#ad1a72",
		background: "#f4dfeb"
	}
}, un = {
	gray: {
		text: "#bebdb8",
		background: "#9b9a97"
	},
	brown: {
		text: "#8e6552",
		background: "#64473a"
	},
	red: {
		text: "#ec4040",
		background: "#be3434"
	},
	orange: {
		text: "#e3790d",
		background: "#b7600a"
	},
	yellow: {
		text: "#dfab01",
		background: "#b58b00"
	},
	green: {
		text: "#6b8b87",
		background: "#4d6461"
	},
	blue: {
		text: "#0e87bc",
		background: "#0b6e99"
	},
	purple: {
		text: "#8552d7",
		background: "#6940a5"
	},
	pink: {
		text: "#da208f",
		background: "#ad1a72"
	}
}, G = {
	backgroundColor: { default: "default" },
	textColor: { default: "default" },
	textAlignment: {
		default: "left",
		values: [
			"left",
			"center",
			"right",
			"justify"
		]
	}
}, K = (e) => {
	let t = {};
	return e.hasAttribute("data-background-color") ? t.backgroundColor = e.getAttribute("data-background-color") : e.style.backgroundColor && (t.backgroundColor = e.style.backgroundColor), e.hasAttribute("data-text-color") ? t.textColor = e.getAttribute("data-text-color") : e.style.color && (t.textColor = e.style.color), t.textAlignment = G.textAlignment.values.includes(e.style.textAlign) ? e.style.textAlign : void 0, t;
}, q = (e, t) => {
	e.backgroundColor && e.backgroundColor !== G.backgroundColor.default && (t.style.backgroundColor = e.backgroundColor in W ? W[e.backgroundColor].background : e.backgroundColor), e.textColor && e.textColor !== G.textColor.default && (t.style.color = e.textColor in W ? W[e.textColor].text : e.textColor), e.textAlignment && e.textAlignment !== G.textAlignment.default && (t.style.textAlign = e.textAlignment);
}, dn = (e = "backgroundColor") => ({
	default: G.backgroundColor.default,
	parseHTML: (e) => e.hasAttribute("data-background-color") ? e.getAttribute("data-background-color") : e.style.backgroundColor ? e.style.backgroundColor : G.backgroundColor.default,
	renderHTML: (t) => t[e] === G.backgroundColor.default ? {} : { "data-background-color": t[e] }
}), fn = (e = "textColor") => ({
	default: G.textColor.default,
	parseHTML: (e) => e.hasAttribute("data-text-color") ? e.getAttribute("data-text-color") : e.style.color ? e.style.color : G.textColor.default,
	renderHTML: (t) => t[e] === G.textColor.default ? {} : { "data-text-color": t[e] }
}), pn = (e = "textAlignment") => ({
	default: G.textAlignment.default,
	parseHTML: (e) => e.hasAttribute("data-text-alignment") ? e.getAttribute("data-text-alignment") : e.style.textAlign ? e.style.textAlign : G.textAlignment.default,
	renderHTML: (t) => t[e] === G.textAlignment.default ? {} : { "data-text-alignment": t[e] }
}), mn = (e, t) => {
	let n = e.querySelector(t);
	if (n) return {
		targetElement: n,
		caption: e.querySelector("figcaption")?.textContent ?? void 0
	};
}, J = n(({ editor: t }) => {
	let n = e(void 0);
	function r() {
		n.setState(void 0);
	}
	return {
		key: "filePanel",
		store: n,
		mount({ signal: e }) {
			let n = t.onChange(r, !1), i = t.onSelectionChange(r, !1);
			e.addEventListener("abort", () => {
				n(), i();
			});
		},
		closeMenu: r,
		showMenu(e) {
			n.setState(e);
		}
	};
}), hn = (e, t, n) => {
	let r = document.createElement("div");
	r.className = "bn-add-file-button";
	let i = document.createElement("div");
	i.className = "bn-add-file-button-icon", n ? i.appendChild(n) : i.innerHTML = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M3 8L9.00319 2H19.9978C20.5513 2 21 2.45531 21 2.9918V21.0082C21 21.556 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5501 3 20.9932V8ZM10 4V9H5V20H19V4H10Z\"></path></svg>", r.appendChild(i);
	let a = document.createElement("p");
	a.className = "bn-add-file-button-text", a.innerHTML = e.type in t.dictionary.file_blocks.add_button_text ? t.dictionary.file_blocks.add_button_text[e.type] : t.dictionary.file_blocks.add_button_text.file, r.appendChild(a);
	let o = (e) => {
		e.preventDefault(), e.stopPropagation();
	}, s = () => {
		t.isEditable && t.getExtension(J)?.showMenu(e.id);
	};
	return r.addEventListener("mousedown", o, !0), r.addEventListener("click", s, !0), {
		dom: r,
		destroy: () => {
			r.removeEventListener("mousedown", o, !0), r.removeEventListener("click", s, !0);
		}
	};
}, gn = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M3 8L9.00319 2H19.9978C20.5513 2 21 2.45531 21 2.9918V21.0082C21 21.556 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5501 3 20.9932V8ZM10 4V9H5V20H19V4H10Z\"></path></svg>", _n = (e) => {
	let t = document.createElement("div");
	t.className = "bn-file-name-with-icon";
	let n = document.createElement("div");
	n.className = "bn-file-icon", n.innerHTML = gn, t.appendChild(n);
	let r = document.createElement("p");
	return r.className = "bn-file-name", r.textContent = e.props.name, t.appendChild(r), { dom: t };
}, vn = (e, t, n, r) => {
	let i = e.props.url !== "" && !!e.props.caption, a = document.createElement(i ? "figure" : "div");
	if (a.className = "bn-file-block-content-wrapper", e.props.url === "") {
		let n = hn(e, t, r);
		a.appendChild(n.dom);
		let i = t.onUploadStart((t) => {
			if (t === e.id) {
				a.removeChild(n.dom);
				let e = document.createElement("div");
				e.className = "bn-file-loading-preview", e.textContent = "Loading...", a.appendChild(e);
			}
		});
		return {
			dom: a,
			destroy: () => {
				i(), n.destroy();
			}
		};
	}
	let o = { dom: a };
	if (e.props.showPreview === !1 || !n) {
		let t = _n(e);
		a.appendChild(t.dom), o.destroy = () => {
			t.destroy?.();
		};
	} else a.appendChild(n.dom);
	if (e.props.caption) {
		let t = document.createElement("figcaption");
		t.className = "bn-file-caption", t.textContent = e.props.caption, a.appendChild(t);
	}
	return o;
}, yn = (e, t) => {
	let n = document.createElement("figure"), r = document.createElement("figcaption");
	return r.textContent = t, n.appendChild(e), n.appendChild(r), { dom: n };
}, bn = (e, t) => {
	let n = document.createElement("div"), r = document.createElement("p");
	return r.textContent = t, n.appendChild(e), n.appendChild(r), { dom: n };
}, xn = (e) => ({ url: e.src || void 0 }), Sn = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M2 16.0001H5.88889L11.1834 20.3319C11.2727 20.405 11.3846 20.4449 11.5 20.4449C11.7761 20.4449 12 20.2211 12 19.9449V4.05519C12 3.93977 11.9601 3.8279 11.887 3.73857C11.7121 3.52485 11.3971 3.49335 11.1834 3.66821L5.88889 8.00007H2C1.44772 8.00007 1 8.44778 1 9.00007V15.0001C1 15.5524 1.44772 16.0001 2 16.0001ZM23 12C23 15.292 21.5539 18.2463 19.2622 20.2622L17.8445 18.8444C19.7758 17.1937 21 14.7398 21 12C21 9.26016 19.7758 6.80629 17.8445 5.15557L19.2622 3.73779C21.5539 5.75368 23 8.70795 23 12ZM18 12C18 10.0883 17.106 8.38548 15.7133 7.28673L14.2842 8.71584C15.3213 9.43855 16 10.64 16 12C16 13.36 15.3213 14.5614 14.2842 15.2841L15.7133 16.7132C17.106 15.6145 18 13.9116 18 12Z\"></path></svg>", Cn = P((e) => ({
	type: "audio",
	propSchema: {
		backgroundColor: G.backgroundColor,
		name: { default: "" },
		url: { default: "" },
		caption: { default: "" },
		showPreview: { default: !0 }
	},
	content: "none"
})), wn = (e = {}) => (e) => {
	if (e.tagName === "AUDIO") {
		if (e.closest("figure")) return;
		let { backgroundColor: t } = K(e);
		return {
			...xn(e),
			backgroundColor: t
		};
	}
	if (e.tagName === "FIGURE") {
		let t = mn(e, "audio");
		if (!t) return;
		let { targetElement: n, caption: r } = t, { backgroundColor: i } = K(e);
		return {
			...xn(n),
			backgroundColor: i,
			caption: r
		};
	}
}, Tn = (e = {}) => (t, n) => {
	let r = document.createElement("div");
	r.innerHTML = e.icon ?? "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M2 16.0001H5.88889L11.1834 20.3319C11.2727 20.405 11.3846 20.4449 11.5 20.4449C11.7761 20.4449 12 20.2211 12 19.9449V4.05519C12 3.93977 11.9601 3.8279 11.887 3.73857C11.7121 3.52485 11.3971 3.49335 11.1834 3.66821L5.88889 8.00007H2C1.44772 8.00007 1 8.44778 1 9.00007V15.0001C1 15.5524 1.44772 16.0001 2 16.0001ZM23 12C23 15.292 21.5539 18.2463 19.2622 20.2622L17.8445 18.8444C19.7758 17.1937 21 14.7398 21 12C21 9.26016 19.7758 6.80629 17.8445 5.15557L19.2622 3.73779C21.5539 5.75368 23 8.70795 23 12ZM18 12C18 10.0883 17.106 8.38548 15.7133 7.28673L14.2842 8.71584C15.3213 9.43855 16 10.64 16 12C16 13.36 15.3213 14.5614 14.2842 15.2841L15.7133 16.7132C17.106 15.6145 18 13.9116 18 12Z\"></path></svg>";
	let i = document.createElement("audio");
	return i.className = "bn-audio", n.resolveFileUrl ? n.resolveFileUrl(t.props.url).then((e) => {
		i.src = e;
	}) : i.src = t.props.url, i.controls = !0, i.contentEditable = "false", i.draggable = !1, vn(t, n, { dom: i }, r.firstElementChild);
}, En = (e = {}) => (e, t) => {
	if (!e.props.url) return { dom: document.createElement("audio") };
	let n;
	return e.props.showPreview ? (n = document.createElement("audio"), n.src = e.props.url) : (n = document.createElement("a"), n.href = e.props.url, n.textContent = e.props.name || e.props.url), e.props.caption ? e.props.showPreview ? yn(n, e.props.caption) : bn(n, e.props.caption) : { dom: n };
}, Dn = F(Cn, (e) => ({
	meta: { fileBlockAccept: ["audio/*"] },
	parse: wn(e),
	render: Tn(e),
	toExternalHTML: En(e),
	runsBefore: ["file"]
})), On = (e) => {
	{
		if (e.tagName !== "PRE" || e.childElementCount !== 1 || e.firstElementChild?.tagName !== "CODE") return;
		let t = e.firstElementChild;
		return { language: t.getAttribute("data-language") || t.className.split(" ").find((e) => e.startsWith("language-"))?.replace("language-", "") };
	}
}, kn = ({ el: e, schema: t }, n) => {
	let r = ie.fromSchema(t), i = e.firstElementChild;
	return r.parse(i, {
		preserveWhitespace: "full",
		topNode: t.nodes[n].create()
	}).content;
}, An = (e) => {
	let t = document.createElement("pre"), n = document.createElement("code");
	return n.className = `language-${e.props.language}`, n.dataset.language = e.props.language, t.appendChild(n), {
		dom: t,
		contentDOM: n
	};
};
//#endregion
//#region src/blocks/Code/CodeBlockOptions.ts
function jn(e, t) {
	let n = t.trim().toLowerCase();
	return Object.entries(e.supportedLanguages ?? {}).find(([e, { aliases: t }]) => e.toLowerCase() === n || t?.some((e) => e.toLowerCase() === n))?.[0];
}
//#endregion
//#region src/blocks/Code/helpers/extensions/CodeKeyboardShortcutsExtension.ts
var Mn = (e) => (t, r) => n({
	key: t,
	keyboardShortcuts: {
		Delete: ({ editor: e }) => e.transact((t) => {
			let { block: n } = e.getTextCursorPosition();
			if (n.type !== r) return !1;
			let { $from: i } = t.selection;
			return !i.parent.textContent && (e.removeBlocks([n]), !0);
		}),
		Tab: ({ editor: t }) => e.indentLineWithTab !== !1 && t.transact((e) => {
			let { block: n } = t.getTextCursorPosition();
			return n.type === r && (e.insertText("  "), !0);
		}),
		Enter: ({ editor: e }) => e.transact((t) => {
			let { block: n, nextBlock: i } = e.getTextCursorPosition();
			if (n.type !== r) return !1;
			let { $from: a } = t.selection, o = a.parentOffset === a.parent.nodeSize - 2, s = a.parent.textContent.endsWith("\n\n");
			if (o && s) {
				if (t.delete(a.pos - 2, a.pos), i) return e.setTextCursorPosition(i, "start"), !0;
				let [r] = e.insertBlocks([{ type: "paragraph" }], n, "after");
				return e.setTextCursorPosition(r, "start"), !0;
			}
			return t.insertText("\n"), !0;
		}),
		"Shift-Enter": ({ editor: e }) => e.transact(() => {
			let { block: t } = e.getTextCursorPosition();
			if (t.type !== r) return !1;
			let [n] = e.insertBlocks([{ type: "paragraph" }], t, "after");
			return e.setTextCursorPosition(n, "start"), !0;
		})
	},
	inputRules: [{
		find: /^```(.*?)\s$/,
		replace: ({ match: t }) => {
			let n = t[1].trim();
			return {
				type: r,
				props: { language: { language: jn(e, n) ?? n }.language },
				content: []
			};
		}
	}]
}), Nn = (e, t, n, r) => {
	if (!(n in r)) throw Error(`Language ${n} is not supported.`);
	let i = document.createElement("select");
	Object.entries(r).forEach(([e, { name: t }]) => {
		let n = document.createElement("option");
		n.value = e, n.text = t, i.appendChild(n);
	}), i.value = n;
	let a = (n) => {
		t.isEditable && t.updateBlock(e.id, { props: { language: n.target.value } });
	};
	t.isEditable ? i.addEventListener("change", a) : i.disabled = !0;
	let o = document.createElement("div");
	return o.contentEditable = "false", o.appendChild(i), {
		dom: o,
		destroy: () => i.removeEventListener("change", a)
	};
}, Pn = (e, t, n) => {
	let r = document.createElement("pre"), i = document.createElement("code");
	r.appendChild(i);
	let a = document.createDocumentFragment(), o;
	return n && Object.keys(n.supportedLanguages).length > 1 && (o = Nn(e, t, n.selectedLanguage, n.supportedLanguages), a.appendChild(o.dom)), a.appendChild(r), {
		dom: a,
		contentDOM: i,
		destroy: () => {
			o?.destroy();
		}
	};
}, Fn = "code-block-keyboard-shortcuts", In = P(({ defaultLanguage: e = "text" }) => ({
	type: "codeBlock",
	propSchema: { language: { default: e } },
	content: "plain"
})), Ln = F(In, (e) => ({
	meta: {
		code: !0,
		defining: !0,
		isolating: !1,
		highlight: (e) => e.props.language
	},
	parse: (e) => On(e),
	parseContent: (e) => kn(e, "codeBlock"),
	render: (t, n) => Pn(t, n, e.supportedLanguages && {
		selectedLanguage: t.props.language,
		supportedLanguages: e.supportedLanguages
	}),
	toExternalHTML: (e) => An(e)
}), (e) => [Mn(e)(Fn, "codeBlock")]), Rn = P(() => ({
	type: "divider",
	propSchema: {},
	content: "none"
})), zn = F(Rn, {
	meta: { isolating: !1 },
	parse(e) {
		if (e.tagName === "HR") return {};
	},
	render() {
		return { dom: document.createElement("hr") };
	}
}, [n({
	key: "divider-block-shortcuts",
	inputRules: [{
		find: /* @__PURE__ */ RegExp("^---$"),
		replace() {
			return {
				type: "divider",
				props: {},
				content: []
			};
		}
	}]
})]), Bn = (e) => ({ url: e.src || void 0 }), Vn = P(() => ({
	type: "file",
	propSchema: {
		backgroundColor: G.backgroundColor,
		name: { default: "" },
		url: { default: "" },
		caption: { default: "" }
	},
	content: "none"
})), Hn = () => (e) => {
	if (e.tagName === "EMBED") {
		if (e.closest("figure")) return;
		let { backgroundColor: t } = K(e);
		return {
			...Bn(e),
			backgroundColor: t
		};
	}
	if (e.tagName === "FIGURE") {
		let t = mn(e, "embed");
		if (!t) return;
		let { targetElement: n, caption: r } = t, { backgroundColor: i } = K(e);
		return {
			...Bn(n),
			backgroundColor: i,
			caption: r
		};
	}
}, Un = F(Vn, {
	meta: { fileBlockAccept: ["*/*"] },
	parse: Hn(),
	render(e, t) {
		return vn(e, t);
	},
	toExternalHTML(e) {
		if (!e.props.url) return { dom: document.createElement("embed") };
		let t = document.createElement("a");
		return t.href = e.props.url, t.textContent = e.props.name || e.props.url, e.props.caption ? bn(t, e.props.caption) : { dom: t };
	}
});
//#endregion
//#region src/blocks/getDetailsContent.ts
function Wn(e, t, n) {
	let a = r.fromSchema(t), o = e.querySelector(":scope > summary"), s;
	if (o) {
		let e = o.cloneNode(!0);
		Ke(e), s = a.parse(e, {
			topNode: t.nodes.paragraph.create(),
			preserveWhitespace: !0
		}).content;
	} else s = i.empty;
	let c = document.createElement("div");
	c.setAttribute("data-node-type", "blockGroup");
	let l = !1;
	for (let t of Array.from(e.childNodes)) t.tagName !== "SUMMARY" && (t.nodeType === 3 && !t.textContent?.trim() || (l = !0, c.appendChild(t.cloneNode(!0))));
	let u = t.nodes[n].create({}, s);
	if (!l) return u.content;
	let d = a.parse(c, { topNode: t.nodes.blockGroup.create() });
	return d.content.size > 0 ? u.content.addToEnd(d) : u.content;
}
//#endregion
//#region src/blocks/ToggleWrapper/createToggleWrapper.ts
var Gn = {
	set: (e, t) => window.localStorage.setItem(`toggle-${e.id}`, t ? "true" : "false"),
	get: (e) => window.localStorage.getItem(`toggle-${e.id}`) === "true"
}, Kn = (e, t, n, r = Gn) => {
	if ("isToggleable" in e.props && !e.props.isToggleable) return { dom: n };
	let i = document.createElement("div"), a = document.createElement("div");
	a.className = "bn-toggle-wrapper";
	let o = document.createElement("button");
	o.className = "bn-toggle-button", o.type = "button", o.innerHTML = "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\" width=\"24px\" fill=\"CURRENTCOLOR\"><path d=\"M320-200v-560l440 280-440 280Z\"/></svg>";
	let s = (e) => e.preventDefault();
	o.addEventListener("mousedown", s);
	let c = () => {
		let n = t.getBlock(e);
		n && (a.getAttribute("data-show-children") === "true" ? (a.setAttribute("data-show-children", "false"), r.set(n, !1), i.contains(l) && i.removeChild(l)) : (a.setAttribute("data-show-children", "true"), r.set(n, !0), t.isEditable && n.children.length === 0 && !i.contains(l) && i.appendChild(l)));
	};
	o.addEventListener("click", c), a.appendChild(o), a.appendChild(n);
	let l = document.createElement("button");
	l.className = "bn-toggle-add-block-button", l.type = "button", l.textContent = t.dictionary.toggle_blocks.add_block_button;
	let u = (e) => e.preventDefault();
	l.addEventListener("mousedown", u);
	let d = () => {
		t.transact(() => {
			let n = t.updateBlock(e, { children: [{}] });
			t.setTextCursorPosition(n.children[0].id, "end"), t.focus();
		});
	};
	l.addEventListener("click", d), i.appendChild(a);
	let f = e.children.length, p = t.onChange(() => {
		let n = t.getBlock(e)?.children.length ?? 0;
		if (n > f) {
			if (a.getAttribute("data-show-children") === "false") {
				a.setAttribute("data-show-children", "true");
				let n = t.getBlock(e);
				n && r.set(n, !0);
			}
			i.contains(l) && i.removeChild(l);
		} else if (n === 0 && n < f) {
			if (a.getAttribute("data-show-children") === "true") {
				a.setAttribute("data-show-children", "false");
				let n = t.getBlock(e);
				n && r.set(n, !1);
			}
			i.contains(l) && i.removeChild(l);
		}
		f = n;
	});
	return r.get(e) ? (a.setAttribute("data-show-children", "true"), t.isEditable && e.children.length === 0 && i.appendChild(l)) : a.setAttribute("data-show-children", "false"), {
		dom: i,
		ignoreMutation: (e) => e instanceof MutationRecord && (e.type === "attributes" && e.target === a && e.attributeName === "data-show-children" || e.type === "childList" && (e.addedNodes[0] === l || e.removedNodes[0] === l)),
		destroy: () => {
			o.removeEventListener("mousedown", s), o.removeEventListener("click", c), l.removeEventListener("mousedown", u), l.removeEventListener("click", d), p?.();
		}
	};
}, qn = [
	1,
	2,
	3,
	4,
	5,
	6
], Jn = (e) => ({ editor: t }) => {
	let n = t.getTextCursorPosition();
	return t.schema.blockSchema[n.block.type].content === "inline" && (t.updateBlock(n.block, {
		type: "heading",
		props: { level: e }
	}), !0);
}, Yn = P(({ defaultLevel: e = 1, levels: t = qn, allowToggleHeadings: n = !0 } = {}) => ({
	type: "heading",
	propSchema: {
		...G,
		level: {
			default: e,
			values: t
		},
		...n ? { isToggleable: {
			default: !1,
			optional: !0
		} } : {}
	},
	content: "inline"
})), Xn = F(Yn, ({ allowToggleHeadings: e = !0 } = {}) => ({
	meta: { isolating: !1 },
	parse(t) {
		if (e && t.tagName === "DETAILS") {
			let e = t.querySelector(":scope > summary");
			if (!e) return;
			let n = e.querySelector("h1, h2, h3, h4, h5, h6");
			return n ? {
				...K(n),
				level: parseInt(n.tagName[1]),
				isToggleable: !0
			} : void 0;
		}
		let n;
		switch (t.tagName) {
			case "H1":
				n = 1;
				break;
			case "H2":
				n = 2;
				break;
			case "H3":
				n = 3;
				break;
			case "H4":
				n = 4;
				break;
			case "H5":
				n = 5;
				break;
			case "H6":
				n = 6;
				break;
			default: return;
		}
		return {
			...K(t),
			level: n
		};
	},
	...e ? { parseContent: ({ el: e, schema: t }) => {
		if (e.tagName === "DETAILS") return Wn(e, t, "heading");
	} } : {},
	runsBefore: ["toggleListItem"],
	render(t, n) {
		let r = document.createElement(`h${t.props.level}`);
		return e ? {
			...Kn(t, n, r),
			contentDOM: r
		} : {
			dom: r,
			contentDOM: r
		};
	},
	toExternalHTML(t) {
		let n = document.createElement(`h${t.props.level}`);
		if (q(t.props, n), e && t.props.isToggleable) {
			let e = document.createElement("details");
			e.setAttribute("open", "");
			let t = document.createElement("summary");
			return t.appendChild(n), e.appendChild(t), {
				dom: e,
				contentDOM: n,
				childrenDOM: e
			};
		}
		return {
			dom: n,
			contentDOM: n
		};
	}
}), ({ levels: e = qn } = {}) => [n({
	key: "heading-shortcuts",
	keyboardShortcuts: Object.fromEntries(e.map((e) => [`Mod-Alt-${e}`, Jn(e)]) ?? []),
	inputRules: e.map((e) => ({
		find: RegExp(`^(#{${e}})\\s$`),
		replace({ match: e }) {
			return {
				type: "heading",
				props: { level: e[1].length }
			};
		}
	}))
})]), Zn = (e, t, n, r, i) => {
	let { dom: a, destroy: o } = vn(e, t, n, i), s = a;
	s.style.position = "relative", e.props.url && e.props.showPreview && (e.props.previewWidth ? s.style.width = `${e.props.previewWidth}px` : s.style.width = "fit-content");
	let c = document.createElement("div");
	c.className = "bn-resize-handle", c.style.left = "4px", c.style.display = "none", r.appendChild(c);
	let l = document.createElement("div");
	l.className = "bn-resize-handle", l.style.right = "4px", l.style.display = "none", r.appendChild(l);
	let u = document.createElement("div");
	u.style.position = "absolute", u.style.height = "100%", u.style.width = "100%";
	let d, f = e.props.previewWidth, p = (n) => {
		if (!d) {
			t.isEditable || (c.style.display = "none", l.style.display = "none");
			return;
		}
		let r, i = "touches" in n ? n.touches[0].clientX : n.clientX;
		r = e.props.textAlignment === "center" ? d.handleUsed === "left" ? d.initialWidth + (d.initialClientX - i) * 2 : d.initialWidth + (i - d.initialClientX) * 2 : d.handleUsed === "left" ? d.initialWidth + d.initialClientX - i : d.initialWidth + i - d.initialClientX, f = Math.min(Math.max(r, 64), t.domElement?.firstElementChild?.clientWidth || Number.MAX_VALUE), s.style.width = `${f}px`;
	}, m = (n) => {
		(!n.target || !s.contains(n.target) || !t.isEditable) && (c.style.display = "none", l.style.display = "none"), d && (d = void 0, s.contains(u) && s.removeChild(u), t.updateBlock(e, { props: { previewWidth: f } }));
	}, h = () => {
		t.isEditable && (c.style.display = "", l.style.display = "");
	}, g = (e) => {
		e.relatedTarget !== c && e.relatedTarget !== l && (d || t.isEditable && (c.style.display = "none", l.style.display = "none"));
	}, _ = (e) => {
		e.preventDefault(), s.contains(u) || s.appendChild(u);
		let t = "touches" in e ? e.touches[0].clientX : e.clientX;
		d = {
			handleUsed: "left",
			initialWidth: s.clientWidth,
			initialClientX: t
		};
	}, v = (e) => {
		e.preventDefault(), s.contains(u) || s.appendChild(u);
		let t = "touches" in e ? e.touches[0].clientX : e.clientX;
		d = {
			handleUsed: "right",
			initialWidth: s.clientWidth,
			initialClientX: t
		};
	};
	return window.addEventListener("mousemove", p), window.addEventListener("touchmove", p), window.addEventListener("mouseup", m), window.addEventListener("touchend", m), s.addEventListener("mouseenter", h), s.addEventListener("mouseleave", g), c.addEventListener("mousedown", _), c.addEventListener("touchstart", _), l.addEventListener("mousedown", v), l.addEventListener("touchstart", v), {
		dom: s,
		destroy: () => {
			o?.(), window.removeEventListener("mousemove", p), window.removeEventListener("touchmove", p), window.removeEventListener("mouseup", m), window.removeEventListener("touchend", m), s.removeEventListener("mouseenter", h), s.removeEventListener("mouseleave", g), c.removeEventListener("mousedown", _), c.removeEventListener("touchstart", _), l.removeEventListener("mousedown", v), l.removeEventListener("touchstart", v);
		}
	};
}, Qn = (e) => ({
	url: e.src || void 0,
	previewWidth: e.width || void 0,
	name: e.alt || void 0
}), $n = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M5 11.1005L7 9.1005L12.5 14.6005L16 11.1005L19 14.1005V5H5V11.1005ZM4 3H20C20.5523 3 21 3.44772 21 4V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3ZM15.5 10C14.6716 10 14 9.32843 14 8.5C14 7.67157 14.6716 7 15.5 7C16.3284 7 17 7.67157 17 8.5C17 9.32843 16.3284 10 15.5 10Z\"></path></svg>", er = P((e = {}) => ({
	type: "image",
	propSchema: {
		textAlignment: G.textAlignment,
		backgroundColor: G.backgroundColor,
		name: { default: "" },
		url: { default: "" },
		caption: { default: "" },
		showPreview: { default: !0 },
		previewWidth: {
			default: void 0,
			type: "number"
		}
	},
	content: "none"
})), tr = (e = {}) => (e) => {
	if (e.tagName === "IMG") {
		if (e.closest("figure")) return;
		let { backgroundColor: t } = K(e);
		return {
			...Qn(e),
			backgroundColor: t
		};
	}
	if (e.tagName === "FIGURE") {
		let t = mn(e, "img");
		if (!t) return;
		let { targetElement: n, caption: r } = t, { backgroundColor: i } = K(e);
		return {
			...Qn(n),
			backgroundColor: i,
			caption: r
		};
	}
}, nr = (e = {}) => (t, n) => {
	let r = document.createElement("div");
	r.innerHTML = e.icon ?? "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M5 11.1005L7 9.1005L12.5 14.6005L16 11.1005L19 14.1005V5H5V11.1005ZM4 3H20C20.5523 3 21 3.44772 21 4V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3ZM15.5 10C14.6716 10 14 9.32843 14 8.5C14 7.67157 14.6716 7 15.5 7C16.3284 7 17 7.67157 17 8.5C17 9.32843 16.3284 10 15.5 10Z\"></path></svg>";
	let i = document.createElement("div");
	i.className = "bn-visual-media-wrapper";
	let a = document.createElement("img");
	return a.className = "bn-visual-media", n.resolveFileUrl ? n.resolveFileUrl(t.props.url).then((e) => {
		a.src = e;
	}) : a.src = t.props.url, a.alt = t.props.name || "", a.contentEditable = "false", a.draggable = !1, t.props.previewWidth && (a.width = t.props.previewWidth), i.appendChild(a), Zn(t, n, { dom: i }, i, r.firstElementChild);
}, rr = (e = {}) => (e, t) => {
	if (!e.props.url) return { dom: document.createElement("img") };
	let n;
	return e.props.showPreview ? (n = document.createElement("img"), n.src = e.props.url, n.alt = e.props.name || "", e.props.previewWidth && (n.width = e.props.previewWidth)) : (n = document.createElement("a"), n.href = e.props.url, n.textContent = e.props.name || e.props.url), e.props.caption ? e.props.showPreview ? yn(n, e.props.caption) : bn(n, e.props.caption) : { dom: n };
}, ir = F(er, (e) => ({
	meta: { fileBlockAccept: ["image/*"] },
	parse: tr(e),
	render: nr(e),
	toExternalHTML: rr(e),
	runsBefore: ["file"]
})), ar = (e, t, n) => ({ state: r, dispatch: i }) => !i || or(r.tr, e, t, n), or = (e, t, n, r) => {
	let i = b(Ae(e.doc, t));
	if (!i.isBlockContainer) return !1;
	let a = k(e), o = [{
		type: i.bnBlock.node.type,
		attrs: r ? {
			...i.bnBlock.node.attrs,
			id: void 0
		} : {}
	}, {
		type: n ? i.blockContent.node.type : a.nodes.paragraph,
		attrs: r ? { ...i.blockContent.node.attrs } : {}
	}];
	return e.split(t, 2, o), !0;
}, sr = (e, t) => {
	let { blockInfo: n, selectionEmpty: r } = e.transact((e) => ({
		blockInfo: Me(e),
		selectionEmpty: e.selection.anchor === e.selection.head
	}));
	if (!n.isBlockContainer) return !1;
	let { bnBlock: i, blockContent: a } = n;
	return a.node.type.name !== t || !r ? !1 : a.node.childCount === 0 ? (e.transact((e) => {
		U(e, i.beforePos, {
			type: "paragraph",
			props: {}
		});
	}), !0) : a.node.childCount > 0 && e.transact((e) => (e.deleteSelection(), e.scrollIntoView(), or(e, e.selection.from, !0)));
};
//#endregion
//#region src/blocks/ListItem/getListItemContent.ts
function cr(e, t, n) {
	let a = r.fromSchema(t), o = e, s = document.createElement("div");
	s.setAttribute("data-node-type", "blockGroup");
	for (let e of Array.from(o.childNodes)) s.appendChild(e.cloneNode(!0));
	let c = a.parse(s, { topNode: t.nodes.blockGroup.create() });
	c.firstChild?.firstChild?.type.name === "checkListItem" && (c = c.copy(c.content.cut(c.firstChild.firstChild.nodeSize + 2)));
	let l = c.firstChild?.firstChild;
	if (!l?.isTextblock) return i.from(c);
	let u = t.nodes[n].create({}, l.content), d = c.content.cut(l.nodeSize + 2);
	if (d.size > 0) {
		let e = c.copy(d);
		return u.content.addToEnd(e);
	}
	return u.content;
}
//#endregion
//#region src/blocks/ListItem/BulletListItem/block.ts
var lr = P(() => ({
	type: "bulletListItem",
	propSchema: { ...G },
	content: "inline"
})), ur = F(lr, {
	meta: { isolating: !1 },
	parse(e) {
		if (e.tagName !== "LI") return;
		let t = e.parentElement;
		if (t === null || t.tagName === "UL" || t.tagName === "DIV" && t.parentElement?.tagName === "UL" || !e.closest("ul, ol")) return K(e);
	},
	parseContent: ({ el: e, schema: t }) => cr(e, t, "bulletListItem"),
	render() {
		let e = document.createElement("p");
		return {
			dom: e,
			contentDOM: e
		};
	},
	toExternalHTML(e) {
		let t = document.createElement("li"), n = document.createElement("p");
		return q(e.props, t), t.appendChild(n), {
			dom: t,
			contentDOM: n
		};
	}
}, [n({
	key: "bullet-list-item-shortcuts",
	keyboardShortcuts: {
		Enter: ({ editor: e }) => sr(e, "bulletListItem"),
		"Mod-Shift-8": ({ editor: e }) => {
			let t = e.getTextCursorPosition();
			return e.schema.blockSchema[t.block.type].content === "inline" && (e.updateBlock(t.block, {
				type: "bulletListItem",
				props: {}
			}), !0);
		}
	},
	inputRules: [{
		find: /^\s?[-+*]\s$/,
		replace({ editor: e }) {
			if (Me(e.prosemirrorState).blockNoteType !== "heading") return {
				type: "bulletListItem",
				props: {}
			};
		}
	}]
})]), dr = P(() => ({
	type: "checkListItem",
	propSchema: {
		...G,
		checked: {
			default: !1,
			type: "boolean"
		}
	},
	content: "inline"
})), fr = F(dr, {
	meta: { isolating: !1 },
	parse(e) {
		if (e.tagName === "input") return e.closest("[data-content-type]") || e.closest("li") ? void 0 : e.type === "checkbox" ? { checked: e.checked } : void 0;
		if (e.tagName !== "LI") return;
		let t = e.parentElement;
		if (t !== null && (t.tagName === "UL" || t.tagName === "DIV" && t.parentElement?.tagName === "UL")) {
			let t = e.querySelector("input[type=checkbox]") || null;
			return t === null ? void 0 : {
				...K(e),
				checked: t.checked
			};
		}
	},
	parseContent: ({ el: e, schema: t }) => cr(e, t, "checkListItem"),
	render(e, t) {
		let n = document.createDocumentFragment(), r = document.createElement("input");
		r.type = "checkbox", r.checked = e.props.checked, e.props.checked && r.setAttribute("checked", ""), r.disabled = !t.isEditable, r.addEventListener("change", () => {
			t.isEditable && t.updateBlock(e, { props: { checked: !e.props.checked } });
		});
		let i = document.createElement("p"), a = document.createElement("div");
		return a.contentEditable = "false", a.appendChild(r), n.appendChild(a), n.appendChild(i), {
			dom: n,
			contentDOM: i
		};
	},
	toExternalHTML(e) {
		let t = document.createElement("li"), n = document.createElement("input");
		n.type = "checkbox", n.checked = e.props.checked, e.props.checked && n.setAttribute("checked", "");
		let r = document.createElement("p");
		return q(e.props, t), t.appendChild(n), t.appendChild(r), {
			dom: t,
			contentDOM: r
		};
	},
	runsBefore: ["bulletListItem"]
}, [n({
	key: "check-list-item-shortcuts",
	keyboardShortcuts: {
		Enter: ({ editor: e }) => sr(e, "checkListItem"),
		"Mod-Shift-9": ({ editor: e }) => {
			let t = e.getTextCursorPosition();
			return e.schema.blockSchema[t.block.type].content === "inline" && (e.updateBlock(t.block, {
				type: "checkListItem",
				props: {}
			}), !0);
		}
	},
	inputRules: [{
		find: /^\s?\[\s*\]\s$/,
		replace() {
			return {
				type: "checkListItem",
				props: { checked: !1 }
			};
		}
	}, {
		find: /^\s?\[[Xx]\]\s$/,
		replace() {
			return {
				type: "checkListItem",
				props: { checked: !0 }
			};
		}
	}]
})]);
//#endregion
//#region src/blocks/ListItem/NumberedListItem/IndexingPlugin.ts
function pr(e, t, n, r) {
	let i = !!e.firstChild.attrs.start, a = b({
		posBeforeNode: t,
		node: e
	});
	if (!a.isBlockContainer) throw Error("impossible");
	let o = n.doc.resolve(a.bnBlock.beforePos).nodeBefore, s = o ? r.get(o) : void 0;
	if (s !== void 0) {
		let t = s + 1;
		return r.set(e, t), {
			index: t,
			isFirst: !1,
			hasStart: i
		};
	}
	let c = [{
		node: e,
		pos: t
	}], l = o, u = a.bnBlock.beforePos;
	for (; l && r.get(l) === void 0;) {
		let e = b({
			posBeforeNode: u - l.nodeSize,
			node: l
		});
		if (e.blockNoteType !== "numberedListItem") break;
		c.push({
			node: l,
			pos: u - l.nodeSize
		});
		let t = n.doc.resolve(e.bnBlock.beforePos).nodeBefore;
		u = e.bnBlock.beforePos, l = t;
	}
	let d, f, p = c[c.length - 1], m = b({
		posBeforeNode: p.pos,
		node: p.node
	});
	if (!m.isBlockContainer) throw Error("impossible");
	let h = n.doc.resolve(m.bnBlock.beforePos).nodeBefore, g = h ? r.get(h) : void 0;
	g === void 0 ? (d = (p.node.firstChild.attrs.start || 1) - 1, f = !0) : (d = g, f = !1);
	for (let e = c.length - 1; e >= 0; e--) {
		let t = c[e];
		f && e < c.length - 1 && (f = !1), d++, r.set(t.node, d);
	}
	return {
		index: d,
		isFirst: c.length === 1 ? f || g === void 0 : !1,
		hasStart: i
	};
}
function mr(e, t) {
	let n = /* @__PURE__ */ new Map(), r = t.decorations.map(e.mapping, e.doc), i = e.changedRange() ?? {
		from: 0,
		to: e.doc.nodeSize - 2
	}, a = [], o = /* @__PURE__ */ new Set();
	e.doc.nodesBetween(i.from, e.doc.nodeSize - 2, (t, s, c) => {
		if (c && o.has(c)) return !1;
		if (t.type.name === "blockContainer" && t.firstChild.type.name === "numberedListItem") {
			let { index: l, isFirst: u, hasStart: d } = pr(t, s, e, n), f = e.doc.nodeAt(s + 1);
			if (r.find(s + 1, s + 1 + f.nodeSize, (e) => e.index === l && e.isFirst === u && e.hasStart === d).length === 0) a.push(ye.node(s + 1, s + 1 + f.nodeSize, { "data-index": l.toString() }, {
				index: l,
				isFirst: u,
				hasStart: d
			}));
			else if (s >= i.to && c) return o.add(c), !1;
		}
	});
	let s = a.flatMap((e) => r.find(e.from, e.to));
	return { decorations: r.remove(s).add(e.doc, a) };
}
var hr = () => new _e({
	key: new ve("numbered-list-indexing-decorations"),
	state: {
		init(e, t) {
			return mr(t.tr, { decorations: be.empty });
		},
		apply(e, t) {
			return !e.docChanged && t.decorations ? t : mr(e, t);
		}
	},
	props: { decorations(e) {
		return this.getState(e)?.decorations ?? be.empty;
	} }
}), gr = P(() => ({
	type: "numberedListItem",
	propSchema: {
		...G,
		start: {
			default: void 0,
			type: "number"
		}
	},
	content: "inline"
})), _r = F(gr, {
	meta: { isolating: !1 },
	parse(e) {
		if (e.tagName !== "LI") return;
		let t = e.parentElement;
		if (t !== null && (t.tagName === "OL" || t.tagName === "DIV" && t.parentElement?.tagName === "OL")) {
			let n = parseInt(t.getAttribute("start") || "1"), r = K(e);
			return e.previousElementSibling || n === 1 ? r : {
				...r,
				start: n
			};
		}
	},
	parseContent: ({ el: e, schema: t }) => cr(e, t, "numberedListItem"),
	render() {
		let e = document.createElement("p");
		return {
			dom: e,
			contentDOM: e
		};
	},
	toExternalHTML(e) {
		let t = document.createElement("li"), n = document.createElement("p");
		return q(e.props, t), t.appendChild(n), {
			dom: t,
			contentDOM: n
		};
	}
}, [n({
	key: "numbered-list-item-shortcuts",
	inputRules: [{
		find: /^\s?(\d+)\.\s$/,
		replace({ match: e, editor: t }) {
			if (Me(t.prosemirrorState).blockNoteType === "heading") return;
			let n = parseInt(e[1]);
			return {
				type: "numberedListItem",
				props: { start: n === 1 ? void 0 : n }
			};
		}
	}],
	keyboardShortcuts: {
		Enter: ({ editor: e }) => sr(e, "numberedListItem"),
		"Mod-Shift-7": ({ editor: e }) => {
			let t = e.getTextCursorPosition();
			return e.schema.blockSchema[t.block.type].content === "inline" && (e.updateBlock(t.block, {
				type: "numberedListItem",
				props: {}
			}), !0);
		}
	},
	prosemirrorPlugins: [hr()]
})]), vr = P(() => ({
	type: "toggleListItem",
	propSchema: { ...G },
	content: "inline"
})), yr = F(vr, {
	meta: { isolating: !1 },
	parse(e) {
		if (e.tagName === "DETAILS") return K(e);
		if (e.tagName === "LI") {
			let t = e.parentElement;
			if (t && (t.tagName === "UL" || t.tagName === "DIV" && t.parentElement?.tagName === "UL") && e.querySelector(":scope > details")) return K(e);
		}
	},
	parseContent: ({ el: e, schema: t }) => {
		let n = e.tagName === "DETAILS" ? e : e.querySelector(":scope > details");
		if (!n) throw Error("No details found in toggleListItem parseContent");
		return Wn(n, t, "toggleListItem");
	},
	runsBefore: ["bulletListItem"],
	render(e, t) {
		let n = document.createElement("p");
		return {
			...Kn(e, t, n),
			contentDOM: n
		};
	},
	toExternalHTML(e) {
		let t = document.createElement("li"), n = document.createElement("details");
		n.setAttribute("open", "");
		let r = document.createElement("summary"), i = document.createElement("p");
		return r.appendChild(i), n.appendChild(r), q(e.props, t), t.appendChild(n), {
			dom: t,
			contentDOM: i,
			childrenDOM: n
		};
	}
}, [n({
	key: "toggle-list-item-shortcuts",
	keyboardShortcuts: {
		Enter: ({ editor: e }) => sr(e, "toggleListItem"),
		"Mod-Shift-6": ({ editor: e }) => {
			let t = e.getTextCursorPosition();
			return e.schema.blockSchema[t.block.type].content === "inline" && (e.updateBlock(t.block, {
				type: "toggleListItem",
				props: {}
			}), !0);
		}
	}
})]), br = P(() => ({
	type: "pageBreak",
	propSchema: {},
	content: "none"
})), xr = F(br, {
	parse(e) {
		if (e.tagName === "DIV" && e.hasAttribute("data-page-break")) return {};
	},
	render() {
		let e = document.createElement("div");
		return e.setAttribute("data-page-break", ""), { dom: e };
	},
	toExternalHTML() {
		let e = document.createElement("div");
		return e.setAttribute("data-page-break", ""), { dom: e };
	}
}), Sr = (e) => e.extend({ blockSpecs: { pageBreak: xr() } }), Cr = P(() => ({
	type: "paragraph",
	propSchema: G,
	content: "inline"
})), wr = F(Cr, {
	meta: { isolating: !1 },
	parse: (e) => {
		if (e.tagName === "P" && e.textContent?.trim()) return K(e);
	},
	render: () => {
		let e = document.createElement("p");
		return {
			dom: e,
			contentDOM: e
		};
	},
	toExternalHTML: (e) => {
		let t = document.createElement("p");
		return q(e.props, t), {
			dom: t,
			contentDOM: t
		};
	},
	runsBefore: ["default", "heading"]
}, [n({
	key: "paragraph-shortcuts",
	keyboardShortcuts: { "Mod-Alt-0": ({ editor: e }) => {
		let t = e.getTextCursorPosition();
		return e.schema.blockSchema[t.block.type].content === "inline" && (e.updateBlock(t.block, {
			type: "paragraph",
			props: {}
		}), !0);
	} }
})]), Tr = P(() => ({
	type: "quote",
	propSchema: {
		backgroundColor: G.backgroundColor,
		textColor: G.textColor
	},
	content: "inline"
})), Er = F(Tr, {
	meta: { isolating: !1 },
	parse(e) {
		if (e.tagName === "BLOCKQUOTE") {
			let { backgroundColor: t, textColor: n } = K(e);
			return {
				backgroundColor: t,
				textColor: n
			};
		}
	},
	render() {
		let e = document.createElement("blockquote");
		return {
			dom: e,
			contentDOM: e
		};
	},
	toExternalHTML(e) {
		let t = document.createElement("blockquote");
		return q(e.props, t), {
			dom: t,
			contentDOM: t
		};
	}
}, [n({
	key: "quote-block-shortcuts",
	keyboardShortcuts: { "Mod-Alt-q": ({ editor: e }) => {
		let t = e.getTextCursorPosition();
		return e.schema.blockSchema[t.block.type].content === "inline" && (e.updateBlock(t.block, {
			type: "quote",
			props: {}
		}), !0);
	} },
	inputRules: [{
		find: /* @__PURE__ */ RegExp("^>\\s$"),
		replace() {
			return {
				type: "quote",
				props: {}
			};
		}
	}, {
		find: /* @__PURE__ */ RegExp("^\\p{Quotation_Mark}\\s$", "u"),
		replace() {
			return {
				type: "quote",
				props: {}
			};
		}
	}]
})]), Dr = "blockLevelSuggestion";
function Y(e) {
	return e && e.options.extensions.some((e) => {
		if (e.type !== "mark") return !1;
		let t = g(e, "group");
		return typeof t == "string" && t.split(" ").includes("blockLevelSuggestion");
	}) ? Dr : "";
}
var Or = 120, kr = 31, Ar = s.create({
	name: "BlockNoteTableExtension",
	addProseMirrorPlugins: () => [ue({
		cellMinWidth: 35,
		defaultCellMinWidth: 120,
		View: null
	}), ge()],
	addKeyboardShortcuts() {
		return {
			Enter: () => fe(this.editor.state) ? this.editor.commands.command(({ state: e, dispatch: t }) => {
				let n = he(e), r = n ? me(n, "vert", 1) : null;
				return r && t && t(e.tr.setSelection(re.between(r, pe(r))).scrollIntoView()), !0;
			}) : !1,
			Backspace: () => {
				let e = this.editor.state.selection, t = e.empty, n = e.$head.parentOffset === 0, r = e.$head.node().type.name === "tableParagraph";
				return t && n && r;
			},
			Tab: () => this.editor.commands.command(({ state: e, dispatch: t, view: n }) => fe(e) ? (de(1)(e, t, n), !0) : !1),
			"Shift-Tab": () => this.editor.commands.command(({ state: e, dispatch: t, view: n }) => fe(e) ? (de(-1)(e, t, n), !0) : !1)
		};
	},
	extendNodeSchema(e) {
		let t = {
			name: e.name,
			options: e.options,
			storage: e.storage
		};
		return { tableRole: d(g(e, "tableRole", t)) };
	}
}), jr = { textColor: G.textColor }, Mr = u.create({
	name: "tableHeader",
	addOptions() {
		return { HTMLAttributes: {} };
	},
	content: "tableContent+",
	marks() {
		return Y(this.editor);
	},
	addAttributes() {
		return {
			colspan: { default: 1 },
			rowspan: { default: 1 },
			colwidth: {
				default: null,
				parseHTML: (e) => {
					let t = e.getAttribute("colwidth");
					return t ? t.split(",").map((e) => parseInt(e, 10)) : null;
				}
			}
		};
	},
	tableRole: "header_cell",
	isolating: !0,
	parseHTML() {
		return [{
			tag: "th",
			getContent: (e, t) => Lr(e, t)
		}];
	},
	renderHTML({ HTMLAttributes: e }) {
		return [
			"th",
			v(this.options.HTMLAttributes, e),
			0
		];
	}
}), Nr = u.create({
	name: "tableCell",
	addOptions() {
		return { HTMLAttributes: {} };
	},
	content: "tableContent+",
	marks() {
		return Y(this.editor);
	},
	addAttributes() {
		return {
			colspan: { default: 1 },
			rowspan: { default: 1 },
			colwidth: {
				default: null,
				parseHTML: (e) => {
					let t = e.getAttribute("colwidth");
					return t ? t.split(",").map((e) => parseInt(e, 10)) : null;
				}
			}
		};
	},
	tableRole: "cell",
	isolating: !0,
	parseHTML() {
		return [{
			tag: "td",
			getContent: (e, t) => Lr(e, t)
		}];
	},
	renderHTML({ HTMLAttributes: e }) {
		return [
			"td",
			v(this.options.HTMLAttributes, e),
			0
		];
	}
}), Pr = u.create({
	name: "table",
	content: "tableRow+",
	group: "blockContent",
	tableRole: "table",
	marks() {
		return Y(this.editor);
	},
	isolating: !0,
	parseHTML() {
		return [{ tag: "table" }];
	},
	renderHTML({ node: e, HTMLAttributes: t }) {
		let n = We(this.name, "table", {
			...this.options.domAttributes?.blockContent || {},
			...t
		}, this.options.domAttributes?.inlineContent || {}), r = document.createElement("colgroup");
		for (let t of e.children[0].children) if (t.attrs.colwidth) for (let e of t.attrs.colwidth) {
			let t = document.createElement("col");
			e && (t.style = `width: ${e}px`), r.appendChild(t);
		}
		else r.appendChild(document.createElement("col"));
		return n.dom.firstChild?.appendChild(r), n;
	},
	addNodeView() {
		return ({ node: e, HTMLAttributes: t }) => {
			class n extends le {
				node;
				cellMinWidth;
				blockContentHTMLAttributes;
				constructor(e, t, n) {
					super(e, t), this.node = e, this.cellMinWidth = t, this.blockContentHTMLAttributes = n;
					let r = document.createElement("div");
					r.className = O("bn-block-content", n.class), r.setAttribute("data-content-type", "table");
					for (let [e, t] of Object.entries(n)) e !== "class" && r.setAttribute(e, t);
					let i = this.dom, a = document.createElement("div");
					a.className = "tableWrapper-inner", a.appendChild(i.firstChild), i.appendChild(a), r.appendChild(i);
					let o = document.createElement("div");
					o.className = "table-widgets-container", o.style.position = "relative", i.appendChild(o), this.dom = r;
				}
				ignoreMutation(e) {
					return !e.target.closest(".tableWrapper-inner") || super.ignoreMutation(e);
				}
				update(e) {
					if (!super.update(e)) return !1;
					for (let [t, n] of Object.entries(jr)) {
						let r = M(t), i = e.attrs[t];
						i === n.default ? this.dom.removeAttribute(r) : this.dom.setAttribute(r, String(i));
					}
					return !0;
				}
			}
			return new n(e, 120, {
				...this.options.domAttributes?.blockContent || {},
				...t
			});
		};
	}
}), Fr = u.create({
	name: "tableParagraph",
	group: "tableContent",
	content: "inline*",
	parseHTML() {
		return [{
			tag: "p",
			getAttrs: (e) => {
				if (typeof e == "string" || !e.textContent || !e.closest("[data-content-type]")) return !1;
				let t = e.parentElement;
				return t === null ? !1 : t.tagName === "TD" || t.tagName === "TH" ? {} : !1;
			},
			node: "tableParagraph"
		}];
	},
	renderHTML({ HTMLAttributes: e }) {
		return [
			"p",
			e,
			0
		];
	}
}), Ir = u.create({
	name: "tableRow",
	addOptions() {
		return { HTMLAttributes: {} };
	},
	content: "(tableCell | tableHeader)+",
	tableRole: "row",
	marks() {
		return Y(this.editor);
	},
	parseHTML() {
		return [{ tag: "tr" }];
	},
	renderHTML({ HTMLAttributes: e }) {
		return [
			"tr",
			v(this.options.HTMLAttributes, e),
			0
		];
	}
});
function Lr(e, t) {
	let n = r.fromSchema(t).parse(e, { topNode: t.nodes.blockGroup.create() }), a = [];
	return n.content.descendants((e) => {
		if (e.isInline) return a.push(e), !1;
	}), i.fromArray(a);
}
var Rr = () => dt({
	node: Pr,
	type: "table",
	content: "table"
}, jr, [n({
	key: "table-extensions",
	tiptapExtensions: [
		Ar,
		Fr,
		Mr,
		Nr,
		Ir
	]
}), n({
	key: "table-keyboard-delete",
	keyboardShortcuts: { Backspace: ({ editor: e }) => {
		if (!(e.prosemirrorState.selection instanceof se)) return !1;
		let t = e.getTextCursorPosition().block, n = t.content, r = 0;
		for (let e of n.rows) for (let t of e.cells) {
			if ("type" in t && t.content.length > 0 || !("type" in t) && t.length > 0) return !1;
			r++;
		}
		let i = 0;
		return e.prosemirrorState.selection.forEachCell(() => {
			i++;
		}), i < r ? !1 : (e.transact(() => {
			(e.getPrevBlock(t) || e.getNextBlock(t)) && e.setTextCursorPosition(t), e.removeBlocks([t]);
		}), !0);
	} }
})]), zr = (e) => ({
	url: e.src || void 0,
	previewWidth: e.width || void 0,
	name: e.getAttribute("data-name") || void 0
}), Br = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M2 3.9934C2 3.44476 2.45531 3 2.9918 3H21.0082C21.556 3 22 3.44495 22 3.9934V20.0066C22 20.5552 21.5447 21 21.0082 21H2.9918C2.44405 21 2 20.5551 2 20.0066V3.9934ZM8 5V19H16V5H8ZM4 5V7H6V5H4ZM18 5V7H20V5H18ZM4 9V11H6V9H4ZM18 9V11H20V9H18ZM4 13V15H6V13H4ZM18 13V15H20V13H18ZM4 17V19H6V17H4ZM18 17V19H20V17H18Z\"></path></svg>", Vr = P((e) => ({
	type: "video",
	propSchema: {
		textAlignment: G.textAlignment,
		backgroundColor: G.backgroundColor,
		name: { default: "" },
		url: { default: "" },
		caption: { default: "" },
		showPreview: { default: !0 },
		previewWidth: {
			default: void 0,
			type: "number"
		}
	},
	content: "none"
})), Hr = (e) => (e) => {
	if (e.tagName === "VIDEO") {
		if (e.closest("figure")) return;
		let { backgroundColor: t } = K(e);
		return {
			...zr(e),
			backgroundColor: t
		};
	}
	if (e.tagName === "FIGURE") {
		let t = mn(e, "video");
		if (!t) return;
		let { targetElement: n, caption: r } = t, { backgroundColor: i } = K(e);
		return {
			...zr(n),
			backgroundColor: i,
			caption: r
		};
	}
}, Ur = F(Vr, (e) => ({
	meta: { fileBlockAccept: ["video/*"] },
	parse: Hr(e),
	render(t, n) {
		let r = document.createElement("div");
		r.innerHTML = e.icon ?? "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M2 3.9934C2 3.44476 2.45531 3 2.9918 3H21.0082C21.556 3 22 3.44495 22 3.9934V20.0066C22 20.5552 21.5447 21 21.0082 21H2.9918C2.44405 21 2 20.5551 2 20.0066V3.9934ZM8 5V19H16V5H8ZM4 5V7H6V5H4ZM18 5V7H20V5H18ZM4 9V11H6V9H4ZM18 9V11H20V9H18ZM4 13V15H6V13H4ZM18 13V15H20V13H18ZM4 17V19H6V17H4ZM18 17V19H20V17H18Z\"></path></svg>";
		let i = document.createElement("div");
		i.className = "bn-visual-media-wrapper";
		let a = document.createElement("video");
		return a.className = "bn-visual-media", n.resolveFileUrl ? n.resolveFileUrl(t.props.url).then((e) => {
			a.src = e;
		}) : a.src = t.props.url, a.controls = !0, a.contentEditable = "false", a.draggable = !1, t.props.previewWidth && (a.width = t.props.previewWidth), i.appendChild(a), Zn(t, n, { dom: i }, i, r.firstElementChild);
	},
	toExternalHTML(e) {
		if (!e.props.url) return { dom: document.createElement("video") };
		let t;
		return e.props.showPreview ? (t = document.createElement("video"), t.src = e.props.url, e.props.previewWidth && (t.width = e.props.previewWidth)) : (t = document.createElement("a"), t.href = e.props.url, t.textContent = e.props.name || e.props.url), e.props.caption ? e.props.showPreview ? yn(t, e.props.caption) : bn(t, e.props.caption) : { dom: t };
	},
	runsBefore: ["file"]
})), Wr = async (e) => {
	let t = new FormData();
	return t.append("file", e), (await (await fetch("https://tmpfiles.org/api/v1/upload", {
		method: "POST",
		body: t
	})).json()).data.url.replace("tmpfiles.org/", "tmpfiles.org/dl/");
};
//#endregion
//#region src/blocks/defaultBlockTypeGuards.ts
function X(e, t, n) {
	if (!(t in e.schema.blockSpecs)) return !1;
	if (!n) return !0;
	for (let [r, i] of Object.entries(n)) {
		if (!(r in e.schema.blockSpecs[t].config.propSchema)) return !1;
		if (typeof i == "string") {
			if (e.schema.blockSpecs[t].config.propSchema[r].default !== void 0 && typeof e.schema.blockSpecs[t].config.propSchema[r].default !== i || e.schema.blockSpecs[t].config.propSchema[r].type !== void 0 && e.schema.blockSpecs[t].config.propSchema[r].type !== i) return !1;
		} else {
			if (e.schema.blockSpecs[t].config.propSchema[r].default !== i.default || e.schema.blockSpecs[t].config.propSchema[r].default === void 0 && i.default === void 0 && e.schema.blockSpecs[t].config.propSchema[r].type !== i.type || typeof e.schema.blockSpecs[t].config.propSchema[r].values != typeof i.values) return !1;
			if (typeof e.schema.blockSpecs[t].config.propSchema[r].values == "object" && typeof i.values == "object") {
				for (let n of i.values) if (!e.schema.blockSpecs[t].config.propSchema[r].values.includes(n)) return !1;
			}
		}
	}
	return !0;
}
function Gr(e, t, n, r) {
	return X(t, n, r) && e.type === n;
}
function Kr(e) {
	return e instanceof se;
}
function qr(e) {
	let t = e.type.spec.tableRole;
	return t === "cell" || t === "header_cell";
}
//#endregion
//#region src/extensions/FormattingToolbar/FormattingToolbar.ts
var Z = n(({ editor: t }) => {
	let n = e(!1), r = () => t.transact((e) => {
		if (e.selection.empty || e.selection instanceof re && e.doc.textBetween(e.selection.from, e.selection.to).length === 0) return !1;
		let t = !1;
		return e.selection.content().content.descendants((e) => (e.type.spec.content === "text*" && (t = !0), !t)), !t;
	});
	return {
		key: "formattingToolbar",
		store: n,
		mount({ dom: e, signal: i }) {
			let a = !1, o = !1, s = t.onChange(() => {
				a || o || n.setState(r());
			}), c = t.onSelectionChange(() => {
				a || o || n.setState(r());
			});
			e.addEventListener("pointerdown", () => {
				a = !0, n.setState(!1);
			}, { signal: i }), t.prosemirrorView.root.addEventListener("pointerup", () => {
				a = !1, t.isFocused() && n.setState(r());
			}, {
				signal: i,
				capture: !0
			}), e.addEventListener("pointercancel", () => {
				a = !0;
			}, {
				signal: i,
				capture: !0
			}), t.prosemirrorView.root.addEventListener("dragstart", () => {
				o = !0, n.setState(!1);
			}, { signal: i }), t.prosemirrorView.root.addEventListener("dragend", () => {
				o = !1;
			}, { signal: i }), i.addEventListener("abort", () => {
				s(), c();
			});
		}
	};
});
//#endregion
//#region src/api/positionMapping.ts
function Jr(e, t, n = "left") {
	let r = e.getExtension("yPositionMapping");
	if (r) return r.mapPosition(t, n);
	let i = e.getExtension("positionMapping");
	if (i) return i.mapPosition(t, n);
	throw Error("No position mapping extension found");
}
//#endregion
//#region src/extensions/SuggestionMenu/SuggestionMenu.ts
var Yr = m((e) => e.type.name === "blockContainer"), Xr = class {
	editor;
	state;
	emitUpdate;
	rootEl;
	pluginState;
	constructor(e, t, n) {
		this.editor = e, this.pluginState = void 0, this.emitUpdate = (e) => {
			if (!this.state) throw Error("Attempting to update uninitialized suggestions menu");
			t(e, {
				...this.state,
				ignoreQueryLength: this.pluginState?.ignoreQueryLength
			});
		}, this.rootEl = n.root, this.rootEl?.addEventListener("scroll", this.handleScroll, !0);
	}
	handleScroll = () => {
		if (this.state?.show) {
			let e = this.rootEl?.querySelector(`[data-decoration-id="${this.pluginState.decorationId}"]`);
			if (!e) return;
			this.state.referencePos = e.getBoundingClientRect().toJSON(), this.emitUpdate(this.pluginState.triggerCharacter);
		}
	};
	update(e, t) {
		let n = Q.getState(t), r = Q.getState(e.state), i = n === void 0 && r !== void 0, a = n !== void 0 && r === void 0;
		if (!i && (n === void 0 || r === void 0) && !a) return;
		if (this.pluginState = a ? n : r, a || !this.editor.isEditable) {
			this.state && (this.state.show = !1), this.emitUpdate(this.pluginState.triggerCharacter);
			return;
		}
		let o = this.rootEl?.querySelector(`[data-decoration-id="${this.pluginState.decorationId}"]`);
		this.editor.isEditable && o && (this.state = {
			show: !0,
			referencePos: o.getBoundingClientRect().toJSON(),
			query: this.pluginState.query
		}, this.emitUpdate(this.pluginState.triggerCharacter));
	}
	destroy() {
		this.rootEl?.removeEventListener("scroll", this.handleScroll, !0);
	}
	closeMenu = () => {
		this.editor.transact((e) => e.setMeta(Q, null));
	};
	clearQuery = () => {
		this.pluginState !== void 0 && this.editor._tiptapEditor.chain().focus().deleteRange({
			from: this.pluginState.queryStartPos() - (this.pluginState.deleteTriggerCharacter ? this.pluginState.triggerCharacter.length : 0),
			to: this.editor.transact((e) => e.selection.from)
		}).run();
	};
}, Q = new ne("SuggestionMenuPlugin"), Zr = n(({ editor: t }) => {
	let n = /* @__PURE__ */ new Map(), r, i = e(void 0);
	return {
		key: "suggestionMenu",
		store: i,
		addSuggestionMenu: (e) => {
			n.set(e.triggerCharacter, e);
		},
		removeSuggestionMenu: (e) => {
			n.delete(e);
		},
		closeMenu: () => {
			r?.closeMenu();
		},
		clearQuery: () => {
			r?.clearQuery();
		},
		shown: () => r?.state?.show || !1,
		openSuggestionMenu: (e, n) => {
			t.headless || (t.focus(), t.transact((t) => {
				n?.deleteTriggerCharacter && t.insertText(e), t.scrollIntoView().setMeta(Q, {
					triggerCharacter: e,
					deleteTriggerCharacter: n?.deleteTriggerCharacter || !1,
					ignoreQueryLength: n?.ignoreQueryLength || !1
				});
			}));
		},
		prosemirrorPlugins: [new te({
			key: Q,
			view: (e) => (r = new Xr(t, (e, t) => {
				i.setState({
					...t,
					triggerCharacter: e
				});
			}, e), r),
			state: {
				init() {},
				apply: (e, n, i, a) => {
					if (e.selection.$from.parent.type.spec.code) return n;
					let o = e.getMeta(Q);
					if (typeof o == "object" && o) {
						n && r?.closeMenu();
						let e = Jr(t, a.selection.from - o.triggerCharacter.length);
						return {
							triggerCharacter: o.triggerCharacter,
							deleteTriggerCharacter: o.deleteTriggerCharacter !== !1,
							queryStartPos: () => e() + o.triggerCharacter.length,
							query: "",
							decorationId: `id_${Math.floor(Math.random() * 4294967295)}`,
							ignoreQueryLength: o?.ignoreQueryLength
						};
					}
					if (n === void 0) return n;
					if (a.selection.from !== a.selection.to || o === null || e.getMeta("focus") || e.getMeta("blur") || e.getMeta("pointer") || n.triggerCharacter !== void 0 && a.selection.from < n.queryStartPos() || !a.selection.$from.sameParent(a.doc.resolve(n.queryStartPos()))) return;
					let s = { ...n };
					return s.query = a.doc.textBetween(n.queryStartPos(), a.selection.from), s;
				}
			},
			props: {
				handleTextInput(e, t, r, i) {
					let a = e.state.doc, o = [...n.entries()].sort(([e], [t]) => t.length - e.length);
					for (let [n, r] of o) {
						let o = a.textBetween(Math.max(0, t - (n.length - i.length)), t) + i;
						if (n === o) {
							if (r.shouldOpen && !r.shouldOpen(e.state.tr)) continue;
							return e.dispatch(e.state.tr.insertText(i)), e.dispatch(e.state.tr.setMeta(Q, { triggerCharacter: o }).scrollIntoView()), !0;
						}
					}
					return !1;
				},
				decorations(e) {
					let t = this.getState(e);
					if (t === void 0) return null;
					if (!t.deleteTriggerCharacter) {
						let n = Yr(e.selection);
						if (n) return Se.create(e.doc, [xe.node(n.pos, n.pos + n.node.nodeSize, {
							nodeName: "span",
							class: "bn-suggestion-decorator",
							"data-decoration-id": t.decorationId
						})]);
					}
					return Se.create(e.doc, [xe.inline(t.queryStartPos() - t.triggerCharacter.length, t.queryStartPos(), {
						nodeName: "span",
						class: "bn-suggestion-decorator",
						"data-decoration-id": t.decorationId
					})]);
				}
			}
		})]
	};
});
//#endregion
//#region src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts
function Qr(e) {
	let t = e.getTextCursorPosition().block, n = e.schema.blockSchema[t.type].content;
	for (; n === "none";) {
		if (t = e.getTextCursorPosition().nextBlock, t === void 0) {
			let t = e.document[e.document.length - 1], n = e.insertBlocks([{ type: "paragraph" }], t, "after")[0];
			e.setTextCursorPosition(n, "end");
			return;
		}
		n = e.schema.blockSchema[t.type].content, e.setTextCursorPosition(t, "end");
	}
}
function $(e, t) {
	let n = e.getTextCursorPosition().block;
	if (n.content === void 0) throw Error("Slash Menu open in a block that doesn't contain content.");
	let r;
	return Array.isArray(n.content) && (n.content.length === 1 && x(n.content[0]) && n.content[0].type === "text" && n.content[0].text === "/" || n.content.length === 0) ? (r = e.updateBlock(n, t), e.setTextCursorPosition(r)) : (r = e.insertBlocks([t], n, "after")[0], e.setTextCursorPosition(e.getTextCursorPosition().nextBlock)), Qr(e), r;
}
function $r(e) {
	let t = [];
	return X(e, "heading", { level: "number" }) && (e.schema.blockSchema.heading.propSchema.level.values || []).filter((e) => e <= 3).forEach((n) => {
		t.push({
			onItemClick: () => {
				$(e, {
					type: "heading",
					props: { level: n }
				});
			},
			badge: D(`Mod-Alt-${n}`),
			key: n === 1 ? "heading" : `heading_${n}`,
			...e.dictionary.slash_menu[n === 1 ? "heading" : `heading_${n}`]
		});
	}), X(e, "quote") && t.push({
		onItemClick: () => {
			$(e, { type: "quote" });
		},
		key: "quote",
		...e.dictionary.slash_menu.quote
	}), X(e, "toggleListItem") && t.push({
		onItemClick: () => {
			$(e, { type: "toggleListItem" });
		},
		badge: D("Mod-Shift-6"),
		key: "toggle_list",
		...e.dictionary.slash_menu.toggle_list
	}), X(e, "numberedListItem") && t.push({
		onItemClick: () => {
			$(e, { type: "numberedListItem" });
		},
		badge: D("Mod-Shift-7"),
		key: "numbered_list",
		...e.dictionary.slash_menu.numbered_list
	}), X(e, "bulletListItem") && t.push({
		onItemClick: () => {
			$(e, { type: "bulletListItem" });
		},
		badge: D("Mod-Shift-8"),
		key: "bullet_list",
		...e.dictionary.slash_menu.bullet_list
	}), X(e, "checkListItem") && t.push({
		onItemClick: () => {
			$(e, { type: "checkListItem" });
		},
		badge: D("Mod-Shift-9"),
		key: "check_list",
		...e.dictionary.slash_menu.check_list
	}), X(e, "paragraph") && t.push({
		onItemClick: () => {
			$(e, { type: "paragraph" });
		},
		badge: D("Mod-Alt-0"),
		key: "paragraph",
		...e.dictionary.slash_menu.paragraph
	}), X(e, "codeBlock") && t.push({
		onItemClick: () => {
			$(e, { type: "codeBlock" });
		},
		badge: D("Mod-Alt-c"),
		key: "code_block",
		...e.dictionary.slash_menu.code_block
	}), X(e, "divider") && t.push({
		onItemClick: () => {
			$(e, { type: "divider" });
		},
		key: "divider",
		...e.dictionary.slash_menu.divider
	}), X(e, "table") && t.push({
		onItemClick: () => {
			$(e, {
				type: "table",
				content: {
					type: "tableContent",
					rows: [{ cells: [
						"",
						"",
						""
					] }, { cells: [
						"",
						"",
						""
					] }]
				}
			});
		},
		badge: void 0,
		key: "table",
		...e.dictionary.slash_menu.table
	}), X(e, "image", { url: "string" }) && t.push({
		onItemClick: () => {
			let t = $(e, { type: "image" });
			e.getExtension(J)?.showMenu(t.id), e.getExtension(Z)?.store.setState(!1);
		},
		key: "image",
		...e.dictionary.slash_menu.image
	}), X(e, "video", { url: "string" }) && t.push({
		onItemClick: () => {
			let t = $(e, { type: "video" });
			e.getExtension(J)?.showMenu(t.id), e.getExtension(Z)?.store.setState(!1);
		},
		key: "video",
		...e.dictionary.slash_menu.video
	}), X(e, "audio", { url: "string" }) && t.push({
		onItemClick: () => {
			let t = $(e, { type: "audio" });
			e.getExtension(J)?.showMenu(t.id), e.getExtension(Z)?.store.setState(!1);
		},
		key: "audio",
		...e.dictionary.slash_menu.audio
	}), X(e, "file", { url: "string" }) && t.push({
		onItemClick: () => {
			let t = $(e, { type: "file" });
			e.getExtension(J)?.showMenu(t.id), e.getExtension(Z)?.store.setState(!1);
		},
		key: "file",
		...e.dictionary.slash_menu.file
	}), X(e, "heading", {
		level: "number",
		isToggleable: "boolean"
	}) && (e.schema.blockSchema.heading.propSchema.level.values || []).filter((e) => e <= 3).forEach((n) => {
		t.push({
			onItemClick: () => {
				$(e, {
					type: "heading",
					props: {
						level: n,
						isToggleable: !0
					}
				});
			},
			key: n === 1 ? "toggle_heading" : `toggle_heading_${n}`,
			...e.dictionary.slash_menu[n === 1 ? "toggle_heading" : `toggle_heading_${n}`]
		});
	}), X(e, "heading", { level: "number" }) && (e.schema.blockSchema.heading.propSchema.level.values || []).filter((e) => e > 3).forEach((n) => {
		t.push({
			onItemClick: () => {
				$(e, {
					type: "heading",
					props: { level: n }
				});
			},
			badge: D(`Mod-Alt-${n}`),
			key: `heading_${n}`,
			...e.dictionary.slash_menu[`heading_${n}`]
		});
	}), t.push({
		onItemClick: () => {
			e.getExtension(Zr)?.openSuggestionMenu(":", {
				deleteTriggerCharacter: !0,
				ignoreQueryLength: !0
			});
		},
		key: "emoji",
		...e.dictionary.slash_menu.emoji
	}), t;
}
function ei(e, t) {
	return e.filter(({ title: e, aliases: n }) => e.toLowerCase().includes(t.toLowerCase()) || n && n.filter((e) => e.toLowerCase().includes(t.toLowerCase())).length !== 0);
}
//#endregion
//#region src/blocks/PageBreak/getPageBreakSlashMenuItems.ts
function ti(e) {
	return "pageBreak" in e.schema.blockSchema;
}
function ni(e) {
	let t = [];
	return ti(e) && t.push({
		...e.dictionary.slash_menu.page_break,
		onItemClick: () => {
			$(e, { type: "pageBreak" });
		},
		key: "page_break"
	}), t;
}
//#endregion
//#region src/blocks/defaultBlocks.ts
var ri = {
	audio: Dn(),
	bulletListItem: ur(),
	checkListItem: fr(),
	codeBlock: Ln(),
	divider: zn(),
	file: Un(),
	heading: Xn(),
	image: ir(),
	numberedListItem: _r(),
	paragraph: wr(),
	quote: Er(),
	table: Rr(),
	toggleListItem: yr(),
	video: Ur()
}, ii = wt({
	type: "textColor",
	propSchema: "string"
}, {
	render: () => {
		let e = document.createElement("span");
		return {
			dom: e,
			contentDOM: e
		};
	},
	toExternalHTML: (e) => {
		let t = document.createElement("span");
		return e !== G.textColor.default && (t.style.color = e in W ? W[e].text : e), {
			dom: t,
			contentDOM: t
		};
	},
	parse: (e) => {
		if (e.tagName === "SPAN" && e.style.color) return e.style.color;
	}
}), ai = wt({
	type: "backgroundColor",
	propSchema: "string"
}, {
	render: () => {
		let e = document.createElement("span");
		return {
			dom: e,
			contentDOM: e
		};
	},
	toExternalHTML: (e) => {
		let t = document.createElement("span");
		return e !== G.backgroundColor.default && (t.style.backgroundColor = e in W ? W[e].background : e), {
			dom: t,
			contentDOM: t
		};
	},
	parse: (e) => {
		if (e.tagName === "SPAN" && e.style.backgroundColor) return e.style.backgroundColor;
	}
}), oi = {
	bold: L(Ce, "boolean"),
	italic: L(Te, "boolean"),
	underline: L(De, "boolean"),
	strike: L(Ee, "boolean"),
	code: L(we.extend({ addInputRules() {
		return [_({
			find: /(^|[^`])`([^`]+)`(?!`)$/,
			type: this.type
		}), new c({
			find: /(^|[^`])`([^`]+)`(?!`) $/,
			handler: ({ state: e, range: t, match: n }) => {
				let { tr: r, schema: i } = e, a = n[1], o = n[2];
				r.replaceWith(t.from + a.length, t.to, [i.text(o, [this.type.create()]), i.text(" ")]);
			}
		})];
	} }), "boolean"),
	textColor: ii,
	backgroundColor: ai
}, si = St(oi), ci = {
	text: {
		config: "text",
		implementation: {}
	},
	link: {
		config: "link",
		implementation: {}
	}
}, li = yt(ci), ui = class e extends Pt {
	static create(t) {
		return new e({
			blockSpecs: t?.blockSpecs ?? ri,
			inlineContentSpecs: t?.inlineContentSpecs ?? ci,
			styleSpecs: t?.styleSpecs ?? oi
		});
	}
};
//#endregion
export { Xn as $, Le as $n, I as $t, Tr as A, Ze as An, cn as At, _r as B, He as Bn, Kt as Bt, Hr as C, tt as Cn, G as Ct, Or as D, at as Dn, K as Dt, kr as E, rt as En, fn as Et, xr as F, Je as Fn, $t as Ft, ar as G, w as Gn, Lt as Gt, dr as H, O as Hn, Wt as Ht, Sr as I, We as In, H as It, ir as J, C as Jn, Bt as Jt, $n as K, T as Kn, Ft as Kt, vr as L, Ge as Ln, V as Lt, Cr as M, k as Mn, en as Mt, wr as N, A as Nn, U as Nt, Dr as O, $e as On, un as Ot, br as P, et as Pn, Qt as Pt, Yn as Q, x as Qn, Ct as Qt, yr as R, Ke as Rn, Xt as Rt, Ur as S, nt as Sn, q as St, jr as T, j as Tn, pn as Tt, lr as U, E as Un, Ht as Ut, fr as V, Ue as Vn, Gt as Vt, ur as W, Ve as Wn, Rt as Wt, nr as X, Re as Xn, Mt as Xt, tr as Y, Be as Yn, Pt as Yt, rr as Z, ze as Zn, wt as Zt, qr as _, ct as _n, En as _t, si as a, gt as an, Ae as ar, Rn as at, Br as b, ot as bn, xn as bt, ni as c, yt as cn, Ln as ct, $ as d, P as dn, An as dt, xt as en, b as er, Kn as et, Zr as f, F as fn, On as ft, X as g, lt as gn, Tn as gt, Gr as h, ut as hn, wn as ht, ci as i, ht as in, y as ir, Hn as it, Er as j, Qe as jn, sn as jt, Y as k, Xe as kn, W as kt, ei as l, mt as ln, Pn as lt, Z as m, dt as mn, Sn as mt, ri as n, St as nn, je as nr, Vn as nt, oi as o, vt as on, ke as or, zn as ot, Jr as p, pt as pn, kn as pt, er as q, S as qn, zt as qt, li as r, bt as rn, Me as rr, Un as rt, ti as s, _t as sn, Oe as sr, In as st, ui as t, L as tn, Ne as tr, Gn as tt, $r as u, ft as un, Nn as ut, Kr as v, N as vn, Cn as vt, Rr as w, it as wn, dn as wt, Vr as x, st as xn, J as xt, Wr as y, M as yn, Dn as yt, gr as z, D as zn, Ut as zt };

//# sourceMappingURL=blocks-CzQLehlc.js.map