/* * Extracted from browser-delivered Turbopack chunk: 2a4e4dccbc3fdacb.bc4b655d5c.js * Module id: 47091 * For reading/searching only; this factory depends on the original Turbopack runtime. */ const moduleFactory = (e) => { "use strict"; function t(e) { this.content = e; } (t.prototype = { constructor: t, find: function (e) { for (var t = 0; t < this.content.length; t += 2) if (this.content[t] === e) return t; return -1; }, get: function (e) { var t = this.find(e); return -1 == t ? void 0 : this.content[t + 1]; }, update: function (e, n, r) { var i = r && r != e ? this.remove(r) : this, o = i.find(e), s = i.content.slice(); return ( -1 == o ? s.push(r || e, n) : ((s[o + 1] = n), r && (s[o] = r)), new t(s) ); }, remove: function (e) { var n = this.find(e); if (-1 == n) return this; var r = this.content.slice(); return r.splice(n, 2), new t(r); }, addToStart: function (e, n) { return new t([e, n].concat(this.remove(e).content)); }, addToEnd: function (e, n) { var r = this.remove(e).content.slice(); return r.push(e, n), new t(r); }, addBefore: function (e, n, r) { var i = this.remove(n), o = i.content.slice(), s = i.find(e); return o.splice(-1 == s ? o.length : s, 0, n, r), new t(o); }, forEach: function (e) { for (var t = 0; t < this.content.length; t += 2) e(this.content[t], this.content[t + 1]); }, prepend: function (e) { return (e = t.from(e)).size ? new t(e.content.concat(this.subtract(e).content)) : this; }, append: function (e) { return (e = t.from(e)).size ? new t(this.subtract(e).content.concat(e.content)) : this; }, subtract: function (e) { var n = this; e = t.from(e); for (var r = 0; r < e.content.length; r += 2) n = n.remove(e.content[r]); return n; }, toObject: function () { var e = {}; return ( this.forEach(function (t, n) { e[t] = n; }), e ); }, get size() { return this.content.length >> 1; }, }), (t.from = function (e) { if (e instanceof t) return e; var n = []; if (e) for (var r in e) n.push(r, e[r]); return new t(n); }); class n { constructor(e, t) { if (((this.content = e), (this.size = t || 0), null == t)) for (let t = 0; t < e.length; t++) this.size += e[t].nodeSize; } nodesBetween(e, t, n, r = 0, i) { for (let o = 0, s = 0; s < t; o++) { let l = this.content[o], a = s + l.nodeSize; if (a > e && !1 !== n(l, r + s, i || null, o) && l.content.size) { let i = s + 1; l.nodesBetween( Math.max(0, e - i), Math.min(l.content.size, t - i), n, r + i, ); } s = a; } } descendants(e) { this.nodesBetween(0, this.size, e); } textBetween(e, t, n, r) { let i = "", o = !0; return ( this.nodesBetween( e, t, (s, l) => { let a = s.isText ? s.text.slice(Math.max(e, l) - l, t - l) : s.isLeaf ? r ? "function" == typeof r ? r(s) : r : s.type.spec.leafText ? s.type.spec.leafText(s) : "" : ""; s.isBlock && ((s.isLeaf && a) || s.isTextblock) && n && (o ? (o = !1) : (i += n)), (i += a); }, 0, ), i ); } append(e) { if (!e.size) return this; if (!this.size) return e; let t = this.lastChild, r = e.firstChild, i = this.content.slice(), o = 0; for ( t.isText && t.sameMarkup(r) && ((i[i.length - 1] = t.withText(t.text + r.text)), (o = 1)); o < e.content.length; o++ ) i.push(e.content[o]); return new n(i, this.size + e.size); } cut(e, t = this.size) { if (0 == e && t == this.size) return this; let r = [], i = 0; if (t > e) for (let n = 0, o = 0; o < t; n++) { let s = this.content[n], l = o + s.nodeSize; l > e && ((o < e || l > t) && (s = s.isText ? s.cut(Math.max(0, e - o), Math.min(s.text.length, t - o)) : s.cut( Math.max(0, e - o - 1), Math.min(s.content.size, t - o - 1), )), r.push(s), (i += s.nodeSize)), (o = l); } return new n(r, i); } cutByIndex(e, t) { return e == t ? n.empty : 0 == e && t == this.content.length ? this : new n(this.content.slice(e, t)); } replaceChild(e, t) { let r = this.content[e]; if (r == t) return this; let i = this.content.slice(), o = this.size + t.nodeSize - r.nodeSize; return (i[e] = t), new n(i, o); } addToStart(e) { return new n([e].concat(this.content), this.size + e.nodeSize); } addToEnd(e) { return new n(this.content.concat(e), this.size + e.nodeSize); } eq(e) { if (this.content.length != e.content.length) return !1; for (let t = 0; t < this.content.length; t++) if (!this.content[t].eq(e.content[t])) return !1; return !0; } get firstChild() { return this.content.length ? this.content[0] : null; } get lastChild() { return this.content.length ? this.content[this.content.length - 1] : null; } get childCount() { return this.content.length; } child(e) { let t = this.content[e]; if (!t) throw RangeError("Index " + e + " out of range for " + this); return t; } maybeChild(e) { return this.content[e] || null; } forEach(e) { for (let t = 0, n = 0; t < this.content.length; t++) { let r = this.content[t]; e(r, n, t), (n += r.nodeSize); } } findDiffStart(e, t = 0) { return (function e(t, n, r) { for (let i = 0; ; i++) { if (i == t.childCount || i == n.childCount) return t.childCount == n.childCount ? null : r; let o = t.child(i), s = n.child(i); if (o == s) { r += o.nodeSize; continue; } if (!o.sameMarkup(s)) return r; if (o.isText && o.text != s.text) { for (let e = 0; o.text[e] == s.text[e]; e++) r++; return r; } if (o.content.size || s.content.size) { let t = e(o.content, s.content, r + 1); if (null != t) return t; } r += o.nodeSize; } })(this, e, t); } findDiffEnd(e, t = this.size, n = e.size) { return (function e(t, n, r, i) { for (let o = t.childCount, s = n.childCount; ; ) { if (0 == o || 0 == s) return o == s ? null : { a: r, b: i }; let l = t.child(--o), a = n.child(--s), d = l.nodeSize; if (l == a) { (r -= d), (i -= d); continue; } if (!l.sameMarkup(a)) return { a: r, b: i }; if (l.isText && l.text != a.text) { let e = 0, t = Math.min(l.text.length, a.text.length); for ( ; e < t && l.text[l.text.length - e - 1] == a.text[a.text.length - e - 1]; ) e++, r--, i--; return { a: r, b: i }; } if (l.content.size || a.content.size) { let t = e(l.content, a.content, r - 1, i - 1); if (t) return t; } (r -= d), (i -= d); } })(this, e, t, n); } findIndex(e) { if (0 == e) return i(0, e); if (e == this.size) return i(this.content.length, e); if (e > this.size || e < 0) throw RangeError(`Position ${e} outside of fragment (${this})`); for (let t = 0, n = 0; ; t++) { let r = n + this.child(t).nodeSize; if (r >= e) { if (r == e) return i(t + 1, r); return i(t, n); } n = r; } } toString() { return "<" + this.toStringInner() + ">"; } toStringInner() { return this.content.join(", "); } toJSON() { return this.content.length ? this.content.map((e) => e.toJSON()) : null; } static fromJSON(e, t) { if (!t) return n.empty; if (!Array.isArray(t)) throw RangeError("Invalid input for Fragment.fromJSON"); return new n(t.map(e.nodeFromJSON)); } static fromArray(e) { if (!e.length) return n.empty; let t, r = 0; for (let n = 0; n < e.length; n++) { let i = e[n]; (r += i.nodeSize), n && i.isText && e[n - 1].sameMarkup(i) ? (t || (t = e.slice(0, n)), (t[t.length - 1] = i.withText(t[t.length - 1].text + i.text))) : t && t.push(i); } return new n(t || e, r); } static from(e) { if (!e) return n.empty; if (e instanceof n) return e; if (Array.isArray(e)) return this.fromArray(e); if (e.attrs) return new n([e], e.nodeSize); throw RangeError( "Can not convert " + e + " to a Fragment" + (e.nodesBetween ? " (looks like multiple versions of prosemirror-model were loaded)" : ""), ); } } n.empty = new n([], 0); let r = { index: 0, offset: 0 }; function i(e, t) { return (r.index = e), (r.offset = t), r; } function o(e, t) { if (e === t) return !0; if (!(e && "object" == typeof e) || !(t && "object" == typeof t)) return !1; let n = Array.isArray(e); if (Array.isArray(t) != n) return !1; if (n) { if (e.length != t.length) return !1; for (let n = 0; n < e.length; n++) if (!o(e[n], t[n])) return !1; } else { for (let n in e) if (!(n in t) || !o(e[n], t[n])) return !1; for (let n in t) if (!(n in e)) return !1; } return !0; } class s { constructor(e, t) { (this.type = e), (this.attrs = t); } addToSet(e) { let t, n = !1; for (let r = 0; r < e.length; r++) { let i = e[r]; if (this.eq(i)) return e; if (this.type.excludes(i.type)) t || (t = e.slice(0, r)); else { if (i.type.excludes(this.type)) return e; !n && i.type.rank > this.type.rank && (t || (t = e.slice(0, r)), t.push(this), (n = !0)), t && t.push(i); } } return t || (t = e.slice()), n || t.push(this), t; } removeFromSet(e) { for (let t = 0; t < e.length; t++) if (this.eq(e[t])) return e.slice(0, t).concat(e.slice(t + 1)); return e; } isInSet(e) { for (let t = 0; t < e.length; t++) if (this.eq(e[t])) return !0; return !1; } eq(e) { return this == e || (this.type == e.type && o(this.attrs, e.attrs)); } toJSON() { let e = { type: this.type.name }; for (let t in this.attrs) { e.attrs = this.attrs; break; } return e; } static fromJSON(e, t) { if (!t) throw RangeError("Invalid input for Mark.fromJSON"); let n = e.marks[t.type]; if (!n) throw RangeError(`There is no mark type ${t.type} in this schema`); let r = n.create(t.attrs); return n.checkAttrs(r.attrs), r; } static sameSet(e, t) { if (e == t) return !0; if (e.length != t.length) return !1; for (let n = 0; n < e.length; n++) if (!e[n].eq(t[n])) return !1; return !0; } static setFrom(e) { if (!e || (Array.isArray(e) && 0 == e.length)) return s.none; if (e instanceof s) return [e]; let t = e.slice(); return t.sort((e, t) => e.type.rank - t.type.rank), t; } } s.none = []; class l extends Error {} class a { constructor(e, t, n) { (this.content = e), (this.openStart = t), (this.openEnd = n); } get size() { return this.content.size - this.openStart - this.openEnd; } insertAt(e, t) { let n = (function e(t, n, r, i) { let { index: o, offset: s } = t.findIndex(n), l = t.maybeChild(o); if (s == n || l.isText) return i && !i.canReplace(o, o, r) ? null : t.cut(0, n).append(r).append(t.cut(n)); let a = e(l.content, n - s - 1, r, l); return a && t.replaceChild(o, l.copy(a)); })(this.content, e + this.openStart, t); return n && new a(n, this.openStart, this.openEnd); } removeBetween(e, t) { return new a( (function e(t, n, r) { let { index: i, offset: o } = t.findIndex(n), s = t.maybeChild(i), { index: l, offset: a } = t.findIndex(r); if (o == n || s.isText) { if (a != r && !t.child(l).isText) throw RangeError("Removing non-flat range"); return t.cut(0, n).append(t.cut(r)); } if (i != l) throw RangeError("Removing non-flat range"); return t.replaceChild( i, s.copy(e(s.content, n - o - 1, r - o - 1)), ); })(this.content, e + this.openStart, t + this.openStart), this.openStart, this.openEnd, ); } eq(e) { return ( this.content.eq(e.content) && this.openStart == e.openStart && this.openEnd == e.openEnd ); } toString() { return this.content + "(" + this.openStart + "," + this.openEnd + ")"; } toJSON() { if (!this.content.size) return null; let e = { content: this.content.toJSON() }; return ( this.openStart > 0 && (e.openStart = this.openStart), this.openEnd > 0 && (e.openEnd = this.openEnd), e ); } static fromJSON(e, t) { if (!t) return a.empty; let r = t.openStart || 0, i = t.openEnd || 0; if ("number" != typeof r || "number" != typeof i) throw RangeError("Invalid input for Slice.fromJSON"); return new a(n.fromJSON(e, t.content), r, i); } static maxOpen(e, t = !0) { let n = 0, r = 0; for ( let r = e.firstChild; r && !r.isLeaf && (t || !r.type.spec.isolating); r = r.firstChild ) n++; for ( let n = e.lastChild; n && !n.isLeaf && (t || !n.type.spec.isolating); n = n.lastChild ) r++; return new a(e, n, r); } } function d(e, t) { if (!t.type.compatibleContent(e.type)) throw new l("Cannot join " + t.type.name + " onto " + e.type.name); } function c(e, t, n) { let r = e.node(n); return d(r, t.node(n)), r; } function h(e, t) { let n = t.length - 1; n >= 0 && e.isText && e.sameMarkup(t[n]) ? (t[n] = e.withText(t[n].text + e.text)) : t.push(e); } function p(e, t, n, r) { let i = (t || e).node(n), o = 0, s = t ? t.index(n) : i.childCount; e && ((o = e.index(n)), e.depth > n ? o++ : e.textOffset && (h(e.nodeAfter, r), o++)); for (let e = o; e < s; e++) h(i.child(e), r); t && t.depth == n && t.textOffset && h(t.nodeBefore, r); } function u(e, t) { return e.type.checkContent(t), e.copy(t); } function f(e, t, r) { let i = []; return ( p(null, e, r, i), e.depth > r && h(u(c(e, t, r + 1), f(e, t, r + 1)), i), p(t, null, r, i), new n(i) ); } a.empty = new a(n.empty, 0, 0); class m { constructor(e, t, n) { (this.pos = e), (this.path = t), (this.parentOffset = n), (this.depth = t.length / 3 - 1); } resolveDepth(e) { return null == e ? this.depth : e < 0 ? this.depth + e : e; } get parent() { return this.node(this.depth); } get doc() { return this.node(0); } node(e) { return this.path[3 * this.resolveDepth(e)]; } index(e) { return this.path[3 * this.resolveDepth(e) + 1]; } indexAfter(e) { return ( (e = this.resolveDepth(e)), this.index(e) + (e != this.depth || this.textOffset ? 1 : 0) ); } start(e) { return 0 == (e = this.resolveDepth(e)) ? 0 : this.path[3 * e - 1] + 1; } end(e) { return ( (e = this.resolveDepth(e)), this.start(e) + this.node(e).content.size ); } before(e) { if (!(e = this.resolveDepth(e))) throw RangeError("There is no position before the top-level node"); return e == this.depth + 1 ? this.pos : this.path[3 * e - 1]; } after(e) { if (!(e = this.resolveDepth(e))) throw RangeError("There is no position after the top-level node"); return e == this.depth + 1 ? this.pos : this.path[3 * e - 1] + this.path[3 * e].nodeSize; } get textOffset() { return this.pos - this.path[this.path.length - 1]; } get nodeAfter() { let e = this.parent, t = this.index(this.depth); if (t == e.childCount) return null; let n = this.pos - this.path[this.path.length - 1], r = e.child(t); return n ? e.child(t).cut(n) : r; } get nodeBefore() { let e = this.index(this.depth), t = this.pos - this.path[this.path.length - 1]; return t ? this.parent.child(e).cut(0, t) : 0 == e ? null : this.parent.child(e - 1); } posAtIndex(e, t) { t = this.resolveDepth(t); let n = this.path[3 * t], r = 0 == t ? 0 : this.path[3 * t - 1] + 1; for (let t = 0; t < e; t++) r += n.child(t).nodeSize; return r; } marks() { let e = this.parent, t = this.index(); if (0 == e.content.size) return s.none; if (this.textOffset) return e.child(t).marks; let n = e.maybeChild(t - 1), r = e.maybeChild(t); if (!n) { let e = n; (n = r), (r = e); } let i = n.marks; for (var o = 0; o < i.length; o++) !1 !== i[o].type.spec.inclusive || (r && i[o].isInSet(r.marks)) || (i = i[o--].removeFromSet(i)); return i; } marksAcross(e) { let t = this.parent.maybeChild(this.index()); if (!t || !t.isInline) return null; let n = t.marks, r = e.parent.maybeChild(e.index()); for (var i = 0; i < n.length; i++) !1 !== n[i].type.spec.inclusive || (r && n[i].isInSet(r.marks)) || (n = n[i--].removeFromSet(n)); return n; } sharedDepth(e) { for (let t = this.depth; t > 0; t--) if (this.start(t) <= e && this.end(t) >= e) return t; return 0; } blockRange(e = this, t) { if (e.pos < this.pos) return e.blockRange(this); for ( let n = this.depth - (this.parent.inlineContent || this.pos == e.pos ? 1 : 0); n >= 0; n-- ) if (e.pos <= this.end(n) && (!t || t(this.node(n)))) return new k(this, e, n); return null; } sameParent(e) { return this.pos - this.parentOffset == e.pos - e.parentOffset; } max(e) { return e.pos > this.pos ? e : this; } min(e) { return e.pos < this.pos ? e : this; } toString() { let e = ""; for (let t = 1; t <= this.depth; t++) e += (e ? "/" : "") + this.node(t).type.name + "_" + this.index(t - 1); return e + ":" + this.parentOffset; } static resolve(e, t) { if (!(t >= 0 && t <= e.content.size)) throw RangeError("Position " + t + " out of range"); let n = [], r = 0, i = t; for (let t = e; ; ) { let { index: e, offset: o } = t.content.findIndex(i), s = i - o; if ((n.push(t, e, r + o), !s || (t = t.child(e)).isText)) break; (i = s - 1), (r += o + 1); } return new m(t, n, i); } static resolveCached(e, t) { let n = b.get(e); if (n) for (let e = 0; e < n.elts.length; e++) { let r = n.elts[e]; if (r.pos == t) return r; } else b.set(e, (n = new g())); let r = (n.elts[n.i] = m.resolve(e, t)); return (n.i = (n.i + 1) % y), r; } } class g { constructor() { (this.elts = []), (this.i = 0); } } let y = 12, b = new WeakMap(); class k { constructor(e, t, n) { (this.$from = e), (this.$to = t), (this.depth = n); } get start() { return this.$from.before(this.depth + 1); } get end() { return this.$to.after(this.depth + 1); } get parent() { return this.$from.node(this.depth); } get startIndex() { return this.$from.index(this.depth); } get endIndex() { return this.$to.indexAfter(this.depth); } } let v = Object.create(null); class w { constructor(e, t, r, i = s.none) { (this.type = e), (this.attrs = t), (this.marks = i), (this.content = r || n.empty); } get children() { return this.content.content; } get nodeSize() { return this.isLeaf ? 1 : 2 + this.content.size; } get childCount() { return this.content.childCount; } child(e) { return this.content.child(e); } maybeChild(e) { return this.content.maybeChild(e); } forEach(e) { this.content.forEach(e); } nodesBetween(e, t, n, r = 0) { this.content.nodesBetween(e, t, n, r, this); } descendants(e) { this.nodesBetween(0, this.content.size, e); } get textContent() { return this.isLeaf && this.type.spec.leafText ? this.type.spec.leafText(this) : this.textBetween(0, this.content.size, ""); } textBetween(e, t, n, r) { return this.content.textBetween(e, t, n, r); } get firstChild() { return this.content.firstChild; } get lastChild() { return this.content.lastChild; } eq(e) { return this == e || (this.sameMarkup(e) && this.content.eq(e.content)); } sameMarkup(e) { return this.hasMarkup(e.type, e.attrs, e.marks); } hasMarkup(e, t, n) { return ( this.type == e && o(this.attrs, t || e.defaultAttrs || v) && s.sameSet(this.marks, n || s.none) ); } copy(e = null) { return e == this.content ? this : new w(this.type, this.attrs, e, this.marks); } mark(e) { return e == this.marks ? this : new w(this.type, this.attrs, this.content, e); } cut(e, t = this.content.size) { return 0 == e && t == this.content.size ? this : this.copy(this.content.cut(e, t)); } slice(e, t = this.content.size, n = !1) { if (e == t) return a.empty; let r = this.resolve(e), i = this.resolve(t), o = n ? 0 : r.sharedDepth(t), s = r.start(o); return new a( r.node(o).content.cut(r.pos - s, i.pos - s), r.depth - o, i.depth - o, ); } replace(e, t, r) { var i = this.resolve(e), o = this.resolve(t); if (r.openStart > i.depth) throw new l("Inserted content deeper than insertion position"); if (i.depth - r.openStart != o.depth - r.openEnd) throw new l("Inconsistent open depths"); return (function e(t, r, i, o) { let s = t.index(o), l = t.node(o); if (s == r.index(o) && o < t.depth - i.openStart) { let n = e(t, r, i, o + 1); return l.copy(l.content.replaceChild(s, n)); } if (!i.content.size) return u(l, f(t, r, o)); if (i.openStart || i.openEnd || t.depth != o || r.depth != o) { let { start: e, end: s } = (function (e, t) { let r = t.depth - e.openStart, i = t.node(r).copy(e.content); for (let e = r - 1; e >= 0; e--) i = t.node(e).copy(n.from(i)); return { start: i.resolveNoCache(e.openStart + r), end: i.resolveNoCache(i.content.size - e.openEnd - r), }; })(i, t); return u( l, (function e(t, r, i, o, s) { let l = t.depth > s && c(t, r, s + 1), a = o.depth > s && c(i, o, s + 1), m = []; return ( p(null, t, s, m), l && a && r.index(s) == i.index(s) ? (d(l, a), h(u(l, e(t, r, i, o, s + 1)), m)) : (l && h(u(l, f(t, r, s + 1)), m), p(r, i, s, m), a && h(u(a, f(i, o, s + 1)), m)), p(o, null, s, m), new n(m) ); })(t, e, s, r, o), ); } { let e = t.parent, n = e.content; return u( e, n .cut(0, t.parentOffset) .append(i.content) .append(n.cut(r.parentOffset)), ); } })(i, o, r, 0); } nodeAt(e) { for (let t = this; ; ) { let { index: n, offset: r } = t.content.findIndex(e); if (!(t = t.maybeChild(n))) return null; if (r == e || t.isText) return t; e -= r + 1; } } childAfter(e) { let { index: t, offset: n } = this.content.findIndex(e); return { node: this.content.maybeChild(t), index: t, offset: n }; } childBefore(e) { if (0 == e) return { node: null, index: 0, offset: 0 }; let { index: t, offset: n } = this.content.findIndex(e); if (n < e) return { node: this.content.child(t), index: t, offset: n }; let r = this.content.child(t - 1); return { node: r, index: t - 1, offset: n - r.nodeSize }; } resolve(e) { return m.resolveCached(this, e); } resolveNoCache(e) { return m.resolve(this, e); } rangeHasMark(e, t, n) { let r = !1; return ( t > e && this.nodesBetween( e, t, (e) => (n.isInSet(e.marks) && (r = !0), !r), ), r ); } get isBlock() { return this.type.isBlock; } get isTextblock() { return this.type.isTextblock; } get inlineContent() { return this.type.inlineContent; } get isInline() { return this.type.isInline; } get isText() { return this.type.isText; } get isLeaf() { return this.type.isLeaf; } get isAtom() { return this.type.isAtom; } toString() { if (this.type.spec.toDebugString) return this.type.spec.toDebugString(this); let e = this.type.name; return ( this.content.size && (e += "(" + this.content.toStringInner() + ")"), x(this.marks, e) ); } contentMatchAt(e) { let t = this.type.contentMatch.matchFragment(this.content, 0, e); if (!t) throw Error("Called contentMatchAt on a node with invalid content"); return t; } canReplace(e, t, r = n.empty, i = 0, o = r.childCount) { let s = this.contentMatchAt(e).matchFragment(r, i, o), l = s && s.matchFragment(this.content, t); if (!l || !l.validEnd) return !1; for (let e = i; e < o; e++) if (!this.type.allowsMarks(r.child(e).marks)) return !1; return !0; } canReplaceWith(e, t, n, r) { if (r && !this.type.allowsMarks(r)) return !1; let i = this.contentMatchAt(e).matchType(n), o = i && i.matchFragment(this.content, t); return !!o && o.validEnd; } canAppend(e) { return e.content.size ? this.canReplace(this.childCount, this.childCount, e.content) : this.type.compatibleContent(e.type); } check() { this.type.checkContent(this.content), this.type.checkAttrs(this.attrs); let e = s.none; for (let t = 0; t < this.marks.length; t++) { let n = this.marks[t]; n.type.checkAttrs(n.attrs), (e = n.addToSet(e)); } if (!s.sameSet(e, this.marks)) throw RangeError( `Invalid collection of marks for node ${this.type.name}: ${this.marks.map((e) => e.type.name)}`, ); this.content.forEach((e) => e.check()); } toJSON() { let e = { type: this.type.name }; for (let t in this.attrs) { e.attrs = this.attrs; break; } return ( this.content.size && (e.content = this.content.toJSON()), this.marks.length && (e.marks = this.marks.map((e) => e.toJSON())), e ); } static fromJSON(e, t) { let r; if (!t) throw RangeError("Invalid input for Node.fromJSON"); if (t.marks) { if (!Array.isArray(t.marks)) throw RangeError("Invalid mark data for Node.fromJSON"); r = t.marks.map(e.markFromJSON); } if ("text" == t.type) { if ("string" != typeof t.text) throw RangeError("Invalid text node in JSON"); return e.text(t.text, r); } let i = n.fromJSON(e, t.content), o = e.nodeType(t.type).create(t.attrs, i, r); return o.type.checkAttrs(o.attrs), o; } } w.prototype.text = void 0; class S extends w { constructor(e, t, n, r) { if ((super(e, t, null, r), !n)) throw RangeError("Empty text nodes are not allowed"); this.text = n; } toString() { return this.type.spec.toDebugString ? this.type.spec.toDebugString(this) : x(this.marks, JSON.stringify(this.text)); } get textContent() { return this.text; } textBetween(e, t) { return this.text.slice(e, t); } get nodeSize() { return this.text.length; } mark(e) { return e == this.marks ? this : new S(this.type, this.attrs, this.text, e); } withText(e) { return e == this.text ? this : new S(this.type, this.attrs, e, this.marks); } cut(e = 0, t = this.text.length) { return 0 == e && t == this.text.length ? this : this.withText(this.text.slice(e, t)); } eq(e) { return this.sameMarkup(e) && this.text == e.text; } toJSON() { let e = super.toJSON(); return (e.text = this.text), e; } } function x(e, t) { for (let n = e.length - 1; n >= 0; n--) t = e[n].type.name + "(" + t + ")"; return t; } class M { constructor(e) { (this.validEnd = e), (this.next = []), (this.wrapCache = []); } static parse(e, t) { var n; let r, i = new C(e, t); if (null == i.next) return M.empty; let o = (function e(t) { let n = []; do n.push( (function (t) { let n = []; do n.push( (function (t) { let n = (function (t) { if (t.eat("(")) { let n = e(t); return ( t.eat(")") || t.err("Missing closing paren"), n ); } if (/\W/.test(t.next)) t.err("Unexpected token '" + t.next + "'"); else { let e = (function (e, t) { let n = e.nodeTypes, r = n[t]; if (r) return [r]; let i = []; for (let e in n) { let r = n[e]; r.isInGroup(t) && i.push(r); } return ( 0 == i.length && e.err( "No node type or group '" + t + "' found", ), i ); })(t, t.next).map( (e) => ( null == t.inline ? (t.inline = e.isInline) : t.inline != e.isInline && t.err("Mixing inline and block content"), { type: "name", value: e } ), ); return ( t.pos++, 1 == e.length ? e[0] : { type: "choice", exprs: e } ); } })(t); for (;;) if (t.eat("+")) n = { type: "plus", expr: n }; else if (t.eat("*")) n = { type: "star", expr: n }; else if (t.eat("?")) n = { type: "opt", expr: n }; else if (t.eat("{")) n = (function (e, t) { let n = T(e), r = n; return ( e.eat(",") && (r = "}" != e.next ? T(e) : -1), e.eat("}") || e.err("Unclosed braced range"), { type: "range", min: n, max: r, expr: t } ); })(t, n); else break; return n; })(t), ); while (t.next && ")" != t.next && "|" != t.next); return 1 == n.length ? n[0] : { type: "seq", exprs: n }; })(t), ); while (t.eat("|")); return 1 == n.length ? n[0] : { type: "choice", exprs: n }; })(i); i.next && i.err("Unexpected trailing text"); let s = ((n = (function (e) { let t = [[]]; return ( i( (function e(t, o) { if ("choice" == t.type) return t.exprs.reduce((t, n) => t.concat(e(n, o)), []); if ("seq" == t.type) for (let r = 0; ; r++) { let s = e(t.exprs[r], o); if (r == t.exprs.length - 1) return s; i(s, (o = n())); } else if ("star" == t.type) { let s = n(); return r(o, s), i(e(t.expr, s), s), [r(s)]; } else if ("plus" == t.type) { let s = n(); return i(e(t.expr, o), s), i(e(t.expr, s), s), [r(s)]; } else if ("opt" == t.type) return [r(o)].concat(e(t.expr, o)); else if ("range" == t.type) { let s = o; for (let r = 0; r < t.min; r++) { let r = n(); i(e(t.expr, s), r), (s = r); } if (-1 == t.max) i(e(t.expr, s), s); else for (let o = t.min; o < t.max; o++) { let o = n(); r(s, o), i(e(t.expr, s), o), (s = o); } return [r(s)]; } else if ("name" == t.type) return [r(o, void 0, t.value)]; else throw Error("Unknown expr type"); })(e, 0), n(), ), t ); function n() { return t.push([]) - 1; } function r(e, n, r) { let i = { term: r, to: n }; return t[e].push(i), i; } function i(e, t) { e.forEach((e) => (e.to = t)); } })(o)), (r = Object.create(null)), (function e(t) { let i = []; t.forEach((e) => { n[e].forEach(({ term: e, to: t }) => { let r; if (e) { for (let t = 0; t < i.length; t++) i[t][0] == e && (r = i[t][1]); E(n, t).forEach((t) => { r || i.push([e, (r = [])]), -1 == r.indexOf(t) && r.push(t); }); } }); }); let o = (r[t.join(",")] = new M(t.indexOf(n.length - 1) > -1)); for (let t = 0; t < i.length; t++) { let n = i[t][1].sort(N); o.next.push({ type: i[t][0], next: r[n.join(",")] || e(n) }); } return o; })(E(n, 0))); return ( (function (e, t) { for (let n = 0, r = [e]; n < r.length; n++) { let e = r[n], i = !e.validEnd, o = []; for (let t = 0; t < e.next.length; t++) { let { type: n, next: s } = e.next[t]; o.push(n.name), i && !(n.isText || n.hasRequiredAttrs()) && (i = !1), -1 == r.indexOf(s) && r.push(s); } i && t.err( "Only non-generatable nodes (" + o.join(", ") + ") in a required position (see https://prosemirror.net/docs/guide/#generatable)", ); } })(s, i), s ); } matchType(e) { for (let t = 0; t < this.next.length; t++) if (this.next[t].type == e) return this.next[t].next; return null; } matchFragment(e, t = 0, n = e.childCount) { let r = this; for (let i = t; r && i < n; i++) r = r.matchType(e.child(i).type); return r; } get inlineContent() { return 0 != this.next.length && this.next[0].type.isInline; } get defaultType() { for (let e = 0; e < this.next.length; e++) { let { type: t } = this.next[e]; if (!(t.isText || t.hasRequiredAttrs())) return t; } return null; } compatible(e) { for (let t = 0; t < this.next.length; t++) for (let n = 0; n < e.next.length; n++) if (this.next[t].type == e.next[n].type) return !0; return !1; } fillBefore(e, t = !1, r = 0) { let i = [this]; return (function o(s, l) { let a = s.matchFragment(e, r); if (a && (!t || a.validEnd)) return n.from(l.map((e) => e.createAndFill())); for (let e = 0; e < s.next.length; e++) { let { type: t, next: n } = s.next[e]; if (!(t.isText || t.hasRequiredAttrs()) && -1 == i.indexOf(n)) { i.push(n); let e = o(n, l.concat(t)); if (e) return e; } } return null; })(this, []); } findWrapping(e) { for (let t = 0; t < this.wrapCache.length; t += 2) if (this.wrapCache[t] == e) return this.wrapCache[t + 1]; let t = this.computeWrapping(e); return this.wrapCache.push(e, t), t; } computeWrapping(e) { let t = Object.create(null), n = [{ match: this, type: null, via: null }]; for (; n.length; ) { let r = n.shift(), i = r.match; if (i.matchType(e)) { let e = []; for (let t = r; t.type; t = t.via) e.push(t.type); return e.reverse(); } for (let e = 0; e < i.next.length; e++) { let { type: o, next: s } = i.next[e]; o.isLeaf || o.hasRequiredAttrs() || o.name in t || (r.type && !s.validEnd) || (n.push({ match: o.contentMatch, type: o, via: r }), (t[o.name] = !0)); } } return null; } get edgeCount() { return this.next.length; } edge(e) { if (e >= this.next.length) throw RangeError(`There's no ${e}th edge in this content match`); return this.next[e]; } toString() { let e = []; return ( !(function t(n) { e.push(n); for (let r = 0; r < n.next.length; r++) -1 == e.indexOf(n.next[r].next) && t(n.next[r].next); })(this), e .map((t, n) => { let r = n + (t.validEnd ? "*" : " ") + " "; for (let n = 0; n < t.next.length; n++) r += (n ? ", " : "") + t.next[n].type.name + "->" + e.indexOf(t.next[n].next); return r; }) .join("\n") ); } } M.empty = new M(!0); class C { constructor(e, t) { (this.string = e), (this.nodeTypes = t), (this.inline = null), (this.pos = 0), (this.tokens = e.split(/\s*(?=\b|\W|$)/)), "" == this.tokens[this.tokens.length - 1] && this.tokens.pop(), "" == this.tokens[0] && this.tokens.shift(); } get next() { return this.tokens[this.pos]; } eat(e) { return this.next == e && (this.pos++ || !0); } err(e) { throw SyntaxError(e + " (in content expression '" + this.string + "')"); } } function T(e) { /\D/.test(e.next) && e.err("Expected number, got '" + e.next + "'"); let t = Number(e.next); return e.pos++, t; } function N(e, t) { return t - e; } function E(e, t) { let n = []; return ( (function t(r) { let i = e[r]; if (1 == i.length && !i[0].term) return t(i[0].to); n.push(r); for (let e = 0; e < i.length; e++) { let { term: r, to: o } = i[e]; r || -1 != n.indexOf(o) || t(o); } })(t), n.sort(N) ); } function O(e) { let t = Object.create(null); for (let n in e) { let r = e[n]; if (!r.hasDefault) return null; t[n] = r.default; } return t; } function A(e, t) { let n = Object.create(null); for (let r in e) { let i = t && t[r]; if (void 0 === i) { let t = e[r]; if (t.hasDefault) i = t.default; else throw RangeError("No value supplied for attribute " + r); } n[r] = i; } return n; } function D(e, t, n, r) { for (let r in t) if (!(r in e)) throw RangeError(`Unsupported attribute ${r} for ${n} of type ${r}`); for (let n in e) { let r = e[n]; r.validate && r.validate(t[n]); } } function R(e, t) { let n = Object.create(null); if (t) for (let r in t) n[r] = new P(e, r, t[r]); return n; } class I { constructor(e, t, n) { (this.name = e), (this.schema = t), (this.spec = n), (this.markSet = null), (this.groups = n.group ? n.group.split(" ") : []), (this.attrs = R(e, n.attrs)), (this.defaultAttrs = O(this.attrs)), (this.contentMatch = null), (this.inlineContent = null), (this.isBlock = !(n.inline || "text" == e)), (this.isText = "text" == e); } get isInline() { return !this.isBlock; } get isTextblock() { return this.isBlock && this.inlineContent; } get isLeaf() { return this.contentMatch == M.empty; } get isAtom() { return this.isLeaf || !!this.spec.atom; } isInGroup(e) { return this.groups.indexOf(e) > -1; } get whitespace() { return this.spec.whitespace || (this.spec.code ? "pre" : "normal"); } hasRequiredAttrs() { for (let e in this.attrs) if (this.attrs[e].isRequired) return !0; return !1; } compatibleContent(e) { return this == e || this.contentMatch.compatible(e.contentMatch); } computeAttrs(e) { return !e && this.defaultAttrs ? this.defaultAttrs : A(this.attrs, e); } create(e = null, t, r) { if (this.isText) throw Error("NodeType.create can't construct text nodes"); return new w(this, this.computeAttrs(e), n.from(t), s.setFrom(r)); } createChecked(e = null, t, r) { return ( (t = n.from(t)), this.checkContent(t), new w(this, this.computeAttrs(e), t, s.setFrom(r)) ); } createAndFill(e = null, t, r) { if (((e = this.computeAttrs(e)), (t = n.from(t)).size)) { let e = this.contentMatch.fillBefore(t); if (!e) return null; t = e.append(t); } let i = this.contentMatch.matchFragment(t), o = i && i.fillBefore(n.empty, !0); return o ? new w(this, e, t.append(o), s.setFrom(r)) : null; } validContent(e) { let t = this.contentMatch.matchFragment(e); if (!t || !t.validEnd) return !1; for (let t = 0; t < e.childCount; t++) if (!this.allowsMarks(e.child(t).marks)) return !1; return !0; } checkContent(e) { if (!this.validContent(e)) throw RangeError( `Invalid content for node ${this.name}: ${e.toString().slice(0, 50)}`, ); } checkAttrs(e) { D(this.attrs, e, "node", this.name); } allowsMarkType(e) { return null == this.markSet || this.markSet.indexOf(e) > -1; } allowsMarks(e) { if (null == this.markSet) return !0; for (let t = 0; t < e.length; t++) if (!this.allowsMarkType(e[t].type)) return !1; return !0; } allowedMarks(e) { let t; if (null == this.markSet) return e; for (let n = 0; n < e.length; n++) this.allowsMarkType(e[n].type) ? t && t.push(e[n]) : t || (t = e.slice(0, n)); return t ? (t.length ? t : s.none) : e; } static compile(e, t) { let n = Object.create(null); e.forEach((e, r) => (n[e] = new I(e, t, r))); let r = t.spec.topNode || "doc"; if (!n[r]) throw RangeError("Schema is missing its top node type ('" + r + "')"); if (!n.text) throw RangeError("Every schema needs a 'text' type"); for (let e in n.text.attrs) throw RangeError("The text node type should not have attributes"); return n; } } class P { constructor(e, t, n) { (this.hasDefault = Object.prototype.hasOwnProperty.call(n, "default")), (this.default = n.default), (this.validate = "string" == typeof n.validate ? (function (e, t, n) { let r = n.split("|"); return (n) => { let i = null === n ? "null" : typeof n; if (0 > r.indexOf(i)) throw RangeError( `Expected value of type ${r} for attribute ${t} on type ${e}, got ${i}`, ); }; })(e, t, n.validate) : n.validate); } get isRequired() { return !this.hasDefault; } } class L { constructor(e, t, n, r) { (this.name = e), (this.rank = t), (this.schema = n), (this.spec = r), (this.attrs = R(e, r.attrs)), (this.excluded = null); let i = O(this.attrs); this.instance = i ? new s(this, i) : null; } create(e = null) { return !e && this.instance ? this.instance : new s(this, A(this.attrs, e)); } static compile(e, t) { let n = Object.create(null), r = 0; return e.forEach((e, i) => (n[e] = new L(e, r++, t, i))), n; } removeFromSet(e) { for (var t = 0; t < e.length; t++) e[t].type == this && ((e = e.slice(0, t).concat(e.slice(t + 1))), t--); return e; } isInSet(e) { for (let t = 0; t < e.length; t++) if (e[t].type == this) return e[t]; } checkAttrs(e) { D(this.attrs, e, "mark", this.name); } excludes(e) { return this.excluded.indexOf(e) > -1; } } class z { constructor(e) { (this.linebreakReplacement = null), (this.cached = Object.create(null)); let n = (this.spec = {}); for (let t in e) n[t] = e[t]; (n.nodes = t.from(e.nodes)), (n.marks = t.from(e.marks || {})), (this.nodes = I.compile(this.spec.nodes, this)), (this.marks = L.compile(this.spec.marks, this)); let r = Object.create(null); for (let e in this.nodes) { if (e in this.marks) throw RangeError(e + " can not be both a node and a mark"); let t = this.nodes[e], n = t.spec.content || "", i = t.spec.marks; if ( ((t.contentMatch = r[n] || (r[n] = M.parse(n, this.nodes))), (t.inlineContent = t.contentMatch.inlineContent), t.spec.linebreakReplacement) ) { if (this.linebreakReplacement) throw RangeError("Multiple linebreak nodes defined"); if (!t.isInline || !t.isLeaf) throw RangeError( "Linebreak replacement nodes must be inline leaf nodes", ); this.linebreakReplacement = t; } t.markSet = "_" == i ? null : i ? B(this, i.split(" ")) : "" != i && t.inlineContent ? null : []; } for (let e in this.marks) { let t = this.marks[e], n = t.spec.excludes; t.excluded = null == n ? [t] : "" == n ? [] : B(this, n.split(" ")); } (this.nodeFromJSON = (e) => w.fromJSON(this, e)), (this.markFromJSON = (e) => s.fromJSON(this, e)), (this.topNodeType = this.nodes[this.spec.topNode || "doc"]), (this.cached.wrappings = Object.create(null)); } node(e, t = null, n, r) { if ("string" == typeof e) e = this.nodeType(e); else if (e instanceof I) { if (e.schema != this) throw RangeError( "Node type from different schema used (" + e.name + ")", ); } else throw RangeError("Invalid node type: " + e); return e.createChecked(t, n, r); } text(e, t) { let n = this.nodes.text; return new S(n, n.defaultAttrs, e, s.setFrom(t)); } mark(e, t) { return "string" == typeof e && (e = this.marks[e]), e.create(t); } nodeType(e) { let t = this.nodes[e]; if (!t) throw RangeError("Unknown node type: " + e); return t; } } function B(e, t) { let n = []; for (let r = 0; r < t.length; r++) { let i = t[r], o = e.marks[i], s = o; if (o) n.push(o); else for (let t in e.marks) { let r = e.marks[t]; ("_" == i || (r.spec.group && r.spec.group.split(" ").indexOf(i) > -1)) && n.push((s = r)); } if (!s) throw SyntaxError("Unknown mark type: '" + t[r] + "'"); } return n; } class $ { constructor(e, t) { (this.schema = e), (this.rules = t), (this.tags = []), (this.styles = []); let n = (this.matchedStyles = []); t.forEach((e) => { if (null != e.tag) this.tags.push(e); else if (null != e.style) { let t = /[^=]*/.exec(e.style)[0]; 0 > n.indexOf(t) && n.push(t), this.styles.push(e); } }), (this.normalizeLists = !this.tags.some((t) => { if (!/^(ul|ol)\b/.test(t.tag) || !t.node) return !1; let n = e.nodes[t.node]; return n.contentMatch.matchType(n); })); } parse(e, t = {}) { let n = new _(this, t, !1); return n.addAll(e, s.none, t.from, t.to), n.finish(); } parseSlice(e, t = {}) { let n = new _(this, t, !0); return n.addAll(e, s.none, t.from, t.to), a.maxOpen(n.finish()); } matchTag(e, t, n) { for ( let o = n ? this.tags.indexOf(n) + 1 : 0; o < this.tags.length; o++ ) { var r, i; let n = this.tags[o]; if ( ((r = e), (i = n.tag), ( r.matches || r.msMatchesSelector || r.webkitMatchesSelector || r.mozMatchesSelector ).call(r, i) && (void 0 === n.namespace || e.namespaceURI == n.namespace) && (!n.context || t.matchesContext(n.context))) ) { if (n.getAttrs) { let t = n.getAttrs(e); if (!1 === t) continue; n.attrs = t || void 0; } return n; } } } matchStyle(e, t, n, r) { for ( let i = r ? this.styles.indexOf(r) + 1 : 0; i < this.styles.length; i++ ) { let r = this.styles[i], o = r.style; if ( 0 == o.indexOf(e) && (!r.context || n.matchesContext(r.context)) && (!(o.length > e.length) || (61 == o.charCodeAt(e.length) && o.slice(e.length + 1) == t)) ) { if (r.getAttrs) { let e = r.getAttrs(t); if (!1 === e) continue; r.attrs = e || void 0; } return r; } } } static schemaRules(e) { let t = []; function n(e) { let n = null == e.priority ? 50 : e.priority, r = 0; for (; r < t.length; r++) { let e = t[r]; if ((null == e.priority ? 50 : e.priority) < n) break; } t.splice(r, 0, e); } for (let t in e.marks) { let r = e.marks[t].spec.parseDOM; r && r.forEach((e) => { n((e = q(e))), e.mark || e.ignore || e.clearMark || (e.mark = t); }); } for (let t in e.nodes) { let r = e.nodes[t].spec.parseDOM; r && r.forEach((e) => { n((e = q(e))), e.node || e.ignore || e.mark || (e.node = t); }); } return t; } static fromSchema(e) { return ( e.cached.domParser || (e.cached.domParser = new $(e, $.schemaRules(e))) ); } } let j = { address: !0, article: !0, aside: !0, blockquote: !0, canvas: !0, dd: !0, div: !0, dl: !0, fieldset: !0, figcaption: !0, figure: !0, footer: !0, form: !0, h1: !0, h2: !0, h3: !0, h4: !0, h5: !0, h6: !0, header: !0, hgroup: !0, hr: !0, li: !0, noscript: !0, ol: !0, output: !0, p: !0, pre: !0, section: !0, table: !0, tfoot: !0, ul: !0, }, F = { head: !0, noscript: !0, object: !0, script: !0, style: !0, title: !0, }, V = { ol: !0, ul: !0 }; function H(e, t, n) { return null != t ? !!t | (2 * ("full" === t)) : e && "pre" == e.whitespace ? 3 : -5 & n; } class W { constructor(e, t, n, r, i, o) { (this.type = e), (this.attrs = t), (this.marks = n), (this.solid = r), (this.options = o), (this.content = []), (this.activeMarks = s.none), (this.match = i || (4 & o ? null : e.contentMatch)); } findWrapping(e) { if (!this.match) { if (!this.type) return []; let t = this.type.contentMatch.fillBefore(n.from(e)); if (t) this.match = this.type.contentMatch.matchFragment(t); else { let t = this.type.contentMatch, n; return (n = t.findWrapping(e.type)) ? ((this.match = t), n) : null; } } return this.match.findWrapping(e.type); } finish(e) { if (!(1 & this.options)) { let e = this.content[this.content.length - 1], t; e && e.isText && (t = /[ \t\r\n\u000c]+$/.exec(e.text)) && (e.text.length == t[0].length ? this.content.pop() : (this.content[this.content.length - 1] = e.withText( e.text.slice(0, e.text.length - t[0].length), ))); } let t = n.from(this.content); return ( !e && this.match && (t = t.append(this.match.fillBefore(n.empty, !0))), this.type ? this.type.create(this.attrs, t, this.marks) : t ); } inlineContext(e) { return this.type ? this.type.inlineContent : this.content.length ? this.content[0].isInline : e.parentNode && !j.hasOwnProperty(e.parentNode.nodeName.toLowerCase()); } } class _ { constructor(e, t, n) { (this.parser = e), (this.options = t), (this.isOpen = n), (this.open = 0), (this.localPreserveWS = !1); let r = t.topNode, i, o = H(null, t.preserveWhitespace, 0) | (4 * !!n); (i = r ? new W( r.type, r.attrs, s.none, !0, t.topMatch || r.type.contentMatch, o, ) : n ? new W(null, null, s.none, !0, null, o) : new W(e.schema.topNodeType, null, s.none, !0, null, o)), (this.nodes = [i]), (this.find = t.findPositions), (this.needsBlock = !1); } get top() { return this.nodes[this.open]; } addDOM(e, t) { 3 == e.nodeType ? this.addTextNode(e, t) : 1 == e.nodeType && this.addElement(e, t); } addTextNode(e, t) { let n = e.nodeValue, r = this.top, i = 2 & r.options ? "full" : this.localPreserveWS || (1 & r.options) > 0, { schema: o } = this.parser; if ("full" === i || r.inlineContext(e) || /[^ \t\r\n\u000c]/.test(n)) { if (i) if ("full" === i) n = n.replace(/\r\n?/g, "\n"); else if ( o.linebreakReplacement && /[\r\n]/.test(n) && this.top.findWrapping(o.linebreakReplacement.create()) ) { let e = n.split(/\r?\n|\r/); for (let n = 0; n < e.length; n++) n && this.insertNode(o.linebreakReplacement.create(), t, !0), e[n] && this.insertNode(o.text(e[n]), t, !/\S/.test(e[n])); n = ""; } else n = n.replace(/\r?\n|\r/g, " "); else if ( ((n = n.replace(/[ \t\r\n\u000c]+/g, " ")), /^[ \t\r\n\u000c]/.test(n) && this.open == this.nodes.length - 1) ) { let t = r.content[r.content.length - 1], i = e.previousSibling; (!t || (i && "BR" == i.nodeName) || (t.isText && /[ \t\r\n\u000c]$/.test(t.text))) && (n = n.slice(1)); } n && this.insertNode(o.text(n), t, !/\S/.test(n)), this.findInText(e); } else this.findInside(e); } addElement(e, t, n) { let r = this.localPreserveWS, i = this.top; ("PRE" == e.tagName || /pre/.test(e.style && e.style.whiteSpace)) && (this.localPreserveWS = !0); let o = e.nodeName.toLowerCase(), s; V.hasOwnProperty(o) && this.parser.normalizeLists && (function (e) { for (let t = e.firstChild, n = null; t; t = t.nextSibling) { let e = 1 == t.nodeType ? t.nodeName.toLowerCase() : null; e && V.hasOwnProperty(e) && n ? (n.appendChild(t), (t = n)) : "li" == e ? (n = t) : e && (n = null); } })(e); let l = (this.options.ruleFromNode && this.options.ruleFromNode(e)) || (s = this.parser.matchTag(e, this, n)); e: if (l ? l.ignore : F.hasOwnProperty(o)) this.findInside(e), this.ignoreFallback(e, t); else if (!l || l.skip || l.closeParent) { l && l.closeParent ? (this.open = Math.max(0, this.open - 1)) : l && l.skip.nodeType && (e = l.skip); let n, r = this.needsBlock; if (j.hasOwnProperty(o)) i.content.length && i.content[0].isInline && this.open && (this.open--, (i = this.top)), (n = !0), i.type || (this.needsBlock = !0); else if (!e.firstChild) { this.leafFallback(e, t); break e; } let s = l && l.skip ? t : this.readStyles(e, t); s && this.addAll(e, s), n && this.sync(i), (this.needsBlock = r); } else { let n = this.readStyles(e, t); n && this.addElementByRule(e, l, n, !1 === l.consuming ? s : void 0); } this.localPreserveWS = r; } leafFallback(e, t) { "BR" == e.nodeName && this.top.type && this.top.type.inlineContent && this.addTextNode(e.ownerDocument.createTextNode("\n"), t); } ignoreFallback(e, t) { "BR" != e.nodeName || (this.top.type && this.top.type.inlineContent) || this.findPlace(this.parser.schema.text("-"), t, !0); } readStyles(e, t) { let n = e.style; if (n && n.length) for (let e = 0; e < this.parser.matchedStyles.length; e++) { let r = this.parser.matchedStyles[e], i = n.getPropertyValue(r); if (i) for (let e; ; ) { let n = this.parser.matchStyle(r, i, this, e); if (!n) break; if (n.ignore) return null; if ( ((t = n.clearMark ? t.filter((e) => !n.clearMark(e)) : t.concat( this.parser.schema.marks[n.mark].create(n.attrs), )), !1 === n.consuming) ) e = n; else break; } } return t; } addElementByRule(e, t, n, r) { let i, o; if (t.node) if ((o = this.parser.schema.nodes[t.node]).isLeaf) this.insertNode(o.create(t.attrs), n, "BR" == e.nodeName) || this.leafFallback(e, n); else { let e = this.enter(o, t.attrs || null, n, t.preserveWhitespace); e && ((i = !0), (n = e)); } else { let e = this.parser.schema.marks[t.mark]; n = n.concat(e.create(t.attrs)); } let s = this.top; if (o && o.isLeaf) this.findInside(e); else if (r) this.addElement(e, n, r); else if (t.getContent) this.findInside(e), t .getContent(e, this.parser.schema) .forEach((e) => this.insertNode(e, n, !1)); else { let r = e; "string" == typeof t.contentElement ? (r = e.querySelector(t.contentElement)) : "function" == typeof t.contentElement ? (r = t.contentElement(e)) : t.contentElement && (r = t.contentElement), this.findAround(e, r, !0), this.addAll(r, n), this.findAround(e, r, !1); } i && this.sync(s) && this.open--; } addAll(e, t, n, r) { let i = n || 0; for ( let o = n ? e.childNodes[n] : e.firstChild, s = null == r ? null : e.childNodes[r]; o != s; o = o.nextSibling, ++i ) this.findAtPoint(e, i), this.addDOM(o, t); this.findAtPoint(e, i); } findPlace(e, t, n) { let r, i; for (let t = this.open, o = 0; t >= 0; t--) { let s = this.nodes[t], l = s.findWrapping(e); if ( l && (!r || r.length > l.length + o) && ((r = l), (i = s), !l.length) ) break; if (s.solid) { if (n) break; o += 2; } } if (!r) return null; this.sync(i); for (let e = 0; e < r.length; e++) t = this.enterInner(r[e], null, t, !1); return t; } insertNode(e, t, n) { if (e.isInline && this.needsBlock && !this.top.type) { let e = this.textblockFromContext(); e && (t = this.enterInner(e, null, t)); } let r = this.findPlace(e, t, n); if (r) { this.closeExtra(); let t = this.top; t.match && (t.match = t.match.matchType(e.type)); let n = s.none; for (let i of r.concat(e.marks)) (t.type ? t.type.allowsMarkType(i.type) : K(i.type, e.type)) && (n = i.addToSet(n)); return t.content.push(e.mark(n)), !0; } return !1; } enter(e, t, n, r) { let i = this.findPlace(e.create(t), n, !1); return i && (i = this.enterInner(e, t, n, !0, r)), i; } enterInner(e, t, n, r = !1, i) { this.closeExtra(); let o = this.top; o.match = o.match && o.match.matchType(e); let l = H(e, i, o.options); 4 & o.options && 0 == o.content.length && (l |= 4); let a = s.none; return ( (n = n.filter( (t) => (o.type ? !o.type.allowsMarkType(t.type) : !K(t.type, e)) || ((a = t.addToSet(a)), !1), )), this.nodes.push(new W(e, t, a, r, null, l)), this.open++, n ); } closeExtra(e = !1) { let t = this.nodes.length - 1; if (t > this.open) { for (; t > this.open; t--) this.nodes[t - 1].content.push(this.nodes[t].finish(e)); this.nodes.length = this.open + 1; } } finish() { return ( (this.open = 0), this.closeExtra(this.isOpen), this.nodes[0].finish(!!(this.isOpen || this.options.topOpen)) ); } sync(e) { for (let t = this.open; t >= 0; t--) if (this.nodes[t] == e) return (this.open = t), !0; else this.localPreserveWS && (this.nodes[t].options |= 1); return !1; } get currentPos() { this.closeExtra(); let e = 0; for (let t = this.open; t >= 0; t--) { let n = this.nodes[t].content; for (let t = n.length - 1; t >= 0; t--) e += n[t].nodeSize; t && e++; } return e; } findAtPoint(e, t) { if (this.find) for (let n = 0; n < this.find.length; n++) this.find[n].node == e && this.find[n].offset == t && (this.find[n].pos = this.currentPos); } findInside(e) { if (this.find) for (let t = 0; t < this.find.length; t++) null == this.find[t].pos && 1 == e.nodeType && e.contains(this.find[t].node) && (this.find[t].pos = this.currentPos); } findAround(e, t, n) { if (e != t && this.find) for (let r = 0; r < this.find.length; r++) null == this.find[r].pos && 1 == e.nodeType && e.contains(this.find[r].node) && t.compareDocumentPosition(this.find[r].node) & (n ? 2 : 4) && (this.find[r].pos = this.currentPos); } findInText(e) { if (this.find) for (let t = 0; t < this.find.length; t++) this.find[t].node == e && (this.find[t].pos = this.currentPos - (e.nodeValue.length - this.find[t].offset)); } matchesContext(e) { if (e.indexOf("|") > -1) return e.split(/\s*\|\s*/).some(this.matchesContext, this); let t = e.split("/"), n = this.options.context, r = !this.isOpen && (!n || n.parent.type == this.nodes[0].type), i = -(n ? n.depth + 1 : 0) + +!r, o = (e, s) => { for (; e >= 0; e--) { let l = t[e]; if ("" == l) { if (e == t.length - 1 || 0 == e) continue; for (; s >= i; s--) if (o(e - 1, s)) return !0; return !1; } { let e = s > 0 || (0 == s && r) ? this.nodes[s].type : n && s >= i ? n.node(s - i).type : null; if (!e || (e.name != l && !e.isInGroup(l))) return !1; s--; } } return !0; }; return o(t.length - 1, this.open); } textblockFromContext() { let e = this.options.context; if (e) for (let t = e.depth; t >= 0; t--) { let n = e.node(t).contentMatchAt(e.indexAfter(t)).defaultType; if (n && n.isTextblock && n.defaultAttrs) return n; } for (let e in this.parser.schema.nodes) { let t = this.parser.schema.nodes[e]; if (t.isTextblock && t.defaultAttrs) return t; } } } function q(e) { let t = {}; for (let n in e) t[n] = e[n]; return t; } function K(e, t) { let n = t.schema.nodes; for (let r in n) { let i = n[r]; if (!i.allowsMarkType(e)) continue; let o = [], s = (e) => { o.push(e); for (let n = 0; n < e.edgeCount; n++) { let { type: r, next: i } = e.edge(n); if (r == t || (0 > o.indexOf(i) && s(i))) return !0; } }; if (s(i.contentMatch)) return !0; } } class U { constructor(e, t) { (this.nodes = e), (this.marks = t); } serializeFragment(e, t = {}, n) { n || (n = G(t).createDocumentFragment()); let r = n, i = []; return ( e.forEach((e) => { if (i.length || e.marks.length) { let n = 0, o = 0; for (; n < i.length && o < e.marks.length; ) { let t = e.marks[o]; if (!this.marks[t.type.name]) { o++; continue; } if (!t.eq(i[n][0]) || !1 === t.type.spec.spanning) break; n++, o++; } for (; n < i.length; ) r = i.pop()[1]; for (; o < e.marks.length; ) { let n = e.marks[o++], s = this.serializeMark(n, e.isInline, t); s && (i.push([n, r]), r.appendChild(s.dom), (r = s.contentDOM || s.dom)); } } r.appendChild(this.serializeNodeInner(e, t)); }), n ); } serializeNodeInner(e, t) { let { dom: n, contentDOM: r } = Q( G(t), this.nodes[e.type.name](e), null, e.attrs, ); if (r) { if (e.isLeaf) throw RangeError("Content hole not allowed in a leaf node spec"); this.serializeFragment(e.content, t, r); } return n; } serializeNode(e, t = {}) { let n = this.serializeNodeInner(e, t); for (let r = e.marks.length - 1; r >= 0; r--) { let i = this.serializeMark(e.marks[r], e.isInline, t); i && ((i.contentDOM || i.dom).appendChild(n), (n = i.dom)); } return n; } serializeMark(e, t, n = {}) { let r = this.marks[e.type.name]; return r && Q(G(n), r(e, t), null, e.attrs); } static renderSpec(e, t, n = null, r) { return Q(e, t, n, r); } static fromSchema(e) { return ( e.cached.domSerializer || (e.cached.domSerializer = new U( this.nodesFromSchema(e), this.marksFromSchema(e), )) ); } static nodesFromSchema(e) { let t = J(e.nodes); return t.text || (t.text = (e) => e.text), t; } static marksFromSchema(e) { return J(e.marks); } } function J(e) { let t = {}; for (let n in e) { let r = e[n].spec.toDOM; r && (t[n] = r); } return t; } function G(e) { return e.document || window.document; } let Y = new WeakMap(); function Q(e, t, n, r) { let i, o, s; if ("string" == typeof t) return { dom: e.createTextNode(t) }; if (null != t.nodeType) return { dom: t }; if (t.dom && null != t.dom.nodeType) return t; let l = t[0], a; if ("string" != typeof l) throw RangeError("Invalid array passed to renderSpec"); if ( r && (void 0 === (o = Y.get(r)) && Y.set( r, ((s = null), !(function e(t) { if (t && "object" == typeof t) if (Array.isArray(t)) if ("string" == typeof t[0]) s || (s = []), s.push(t); else for (let n = 0; n < t.length; n++) e(t[n]); else for (let n in t) e(t[n]); })(r), (o = s)), ), (a = o)) && a.indexOf(t) > -1 ) throw RangeError( "Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.", ); let d = l.indexOf(" "); d > 0 && ((n = l.slice(0, d)), (l = l.slice(d + 1))); let c = n ? e.createElementNS(n, l) : e.createElement(l), h = t[1], p = 1; if ( h && "object" == typeof h && null == h.nodeType && !Array.isArray(h) ) { for (let e in ((p = 2), h)) if (null != h[e]) { let t = e.indexOf(" "); t > 0 ? c.setAttributeNS(e.slice(0, t), e.slice(t + 1), h[e]) : "style" == e && c.style ? (c.style.cssText = h[e]) : c.setAttribute(e, h[e]); } } for (let o = p; o < t.length; o++) { let s = t[o]; if (0 === s) { if (o < t.length - 1 || o > p) throw RangeError( "Content hole must be the only child of its parent node", ); return { dom: c, contentDOM: c }; } { let { dom: t, contentDOM: o } = Q(e, s, n, r); if ((c.appendChild(t), o)) { if (i) throw RangeError("Multiple content holes"); i = o; } } } return { dom: c, contentDOM: i }; } e.s( [ "DOMParser", () => $, "DOMSerializer", () => U, "Fragment", () => n, "Mark", () => s, "MarkType", () => L, "Node", () => w, "NodeRange", () => k, "ReplaceError", () => l, "Schema", () => z, "Slice", () => a, ], 47091, ); class X { constructor(e, t, n) { (this.pos = e), (this.delInfo = t), (this.recover = n); } get deleted() { return (8 & this.delInfo) > 0; } get deletedBefore() { return (5 & this.delInfo) > 0; } get deletedAfter() { return (6 & this.delInfo) > 0; } get deletedAcross() { return (4 & this.delInfo) > 0; } } class Z { constructor(e, t = !1) { if (((this.ranges = e), (this.inverted = t), !e.length && Z.empty)) return Z.empty; } recover(e) { let t = 0, n = 65535 & e; if (!this.inverted) for (let e = 0; e < n; e++) t += this.ranges[3 * e + 2] - this.ranges[3 * e + 1]; return this.ranges[3 * n] + t + (e - (65535 & e)) / 65536; } mapResult(e, t = 1) { return this._map(e, t, !1); } map(e, t = 1) { return this._map(e, t, !0); } _map(e, t, n) { let r = 0, i = this.inverted ? 2 : 1, o = this.inverted ? 1 : 2; for (let s = 0; s < this.ranges.length; s += 3) { let l = this.ranges[s] - (this.inverted ? r : 0); if (l > e) break; let a = this.ranges[s + i], d = this.ranges[s + o], c = l + a; if (e <= c) { let i = a ? (e == l ? -1 : e == c ? 1 : t) : t, o = l + r + (i < 0 ? 0 : d); if (n) return o; let h = e == (t < 0 ? l : c) ? null : s / 3 + (e - l) * 65536, p = e == l ? 2 : e == c ? 1 : 4; return (t < 0 ? e != l : e != c) && (p |= 8), new X(o, p, h); } r += d - a; } return n ? e + r : new X(e + r, 0, null); } touches(e, t) { let n = 0, r = 65535 & t, i = this.inverted ? 2 : 1, o = this.inverted ? 1 : 2; for (let t = 0; t < this.ranges.length; t += 3) { let s = this.ranges[t] - (this.inverted ? n : 0); if (s > e) break; let l = this.ranges[t + i]; if (e <= s + l && t == 3 * r) return !0; n += this.ranges[t + o] - l; } return !1; } forEach(e) { let t = this.inverted ? 2 : 1, n = this.inverted ? 1 : 2; for (let r = 0, i = 0; r < this.ranges.length; r += 3) { let o = this.ranges[r], s = o - (this.inverted ? i : 0), l = o + (this.inverted ? 0 : i), a = this.ranges[r + t], d = this.ranges[r + n]; e(s, s + a, l, l + d), (i += d - a); } } invert() { return new Z(this.ranges, !this.inverted); } toString() { return (this.inverted ? "-" : "") + JSON.stringify(this.ranges); } static offset(e) { return 0 == e ? Z.empty : new Z(e < 0 ? [0, -e, 0] : [0, 0, e]); } } Z.empty = new Z([]); class ee { constructor(e, t, n = 0, r = e ? e.length : 0) { (this.mirror = t), (this.from = n), (this.to = r), (this._maps = e || []), (this.ownData = !(e || t)); } get maps() { return this._maps; } slice(e = 0, t = this.maps.length) { return new ee(this._maps, this.mirror, e, t); } appendMap(e, t) { this.ownData || ((this._maps = this._maps.slice()), (this.mirror = this.mirror && this.mirror.slice()), (this.ownData = !0)), (this.to = this._maps.push(e)), null != t && this.setMirror(this._maps.length - 1, t); } appendMapping(e) { for (let t = 0, n = this._maps.length; t < e._maps.length; t++) { let r = e.getMirror(t); this.appendMap(e._maps[t], null != r && r < t ? n + r : void 0); } } getMirror(e) { if (this.mirror) { for (let t = 0; t < this.mirror.length; t++) if (this.mirror[t] == e) return this.mirror[t + (t % 2 ? -1 : 1)]; } } setMirror(e, t) { this.mirror || (this.mirror = []), this.mirror.push(e, t); } appendMappingInverted(e) { for ( let t = e.maps.length - 1, n = this._maps.length + e._maps.length; t >= 0; t-- ) { let r = e.getMirror(t); this.appendMap( e._maps[t].invert(), null != r && r > t ? n - r - 1 : void 0, ); } } invert() { let e = new ee(); return e.appendMappingInverted(this), e; } map(e, t = 1) { if (this.mirror) return this._map(e, t, !0); for (let n = this.from; n < this.to; n++) e = this._maps[n].map(e, t); return e; } mapResult(e, t = 1) { return this._map(e, t, !1); } _map(e, t, n) { let r = 0; for (let n = this.from; n < this.to; n++) { let i = this._maps[n].mapResult(e, t); if (null != i.recover) { let t = this.getMirror(n); if (null != t && t > n && t < this.to) { (n = t), (e = this._maps[t].recover(i.recover)); continue; } } (r |= i.delInfo), (e = i.pos); } return n ? e : new X(e, r, null); } } let et = Object.create(null); class en { getMap() { return Z.empty; } merge(e) { return null; } static fromJSON(e, t) { if (!t || !t.stepType) throw RangeError("Invalid input for Step.fromJSON"); let n = et[t.stepType]; if (!n) throw RangeError(`No step type ${t.stepType} defined`); return n.fromJSON(e, t); } static jsonID(e, t) { if (e in et) throw RangeError("Duplicate use of step JSON ID " + e); return (et[e] = t), (t.prototype.jsonID = e), t; } } class er { constructor(e, t) { (this.doc = e), (this.failed = t); } static ok(e) { return new er(e, null); } static fail(e) { return new er(null, e); } static fromReplace(e, t, n, r) { try { return er.ok(e.replace(t, n, r)); } catch (e) { if (e instanceof l) return er.fail(e.message); throw e; } } } function ei(e, t, r) { let i = []; for (let n = 0; n < e.childCount; n++) { let o = e.child(n); o.content.size && (o = o.copy(ei(o.content, t, o))), o.isInline && (o = t(o, r, n)), i.push(o); } return n.fromArray(i); } class eo extends en { constructor(e, t, n) { super(), (this.from = e), (this.to = t), (this.mark = n); } apply(e) { let t = e.slice(this.from, this.to), n = e.resolve(this.from), r = n.node(n.sharedDepth(this.to)), i = new a( ei( t.content, (e, t) => e.isAtom && t.type.allowsMarkType(this.mark.type) ? e.mark(this.mark.addToSet(e.marks)) : e, r, ), t.openStart, t.openEnd, ); return er.fromReplace(e, this.from, this.to, i); } invert() { return new es(this.from, this.to, this.mark); } map(e) { let t = e.mapResult(this.from, 1), n = e.mapResult(this.to, -1); return (t.deleted && n.deleted) || t.pos >= n.pos ? null : new eo(t.pos, n.pos, this.mark); } merge(e) { return e instanceof eo && e.mark.eq(this.mark) && this.from <= e.to && this.to >= e.from ? new eo( Math.min(this.from, e.from), Math.max(this.to, e.to), this.mark, ) : null; } toJSON() { return { stepType: "addMark", mark: this.mark.toJSON(), from: this.from, to: this.to, }; } static fromJSON(e, t) { if ("number" != typeof t.from || "number" != typeof t.to) throw RangeError("Invalid input for AddMarkStep.fromJSON"); return new eo(t.from, t.to, e.markFromJSON(t.mark)); } } en.jsonID("addMark", eo); class es extends en { constructor(e, t, n) { super(), (this.from = e), (this.to = t), (this.mark = n); } apply(e) { let t = e.slice(this.from, this.to), n = new a( ei(t.content, (e) => e.mark(this.mark.removeFromSet(e.marks)), e), t.openStart, t.openEnd, ); return er.fromReplace(e, this.from, this.to, n); } invert() { return new eo(this.from, this.to, this.mark); } map(e) { let t = e.mapResult(this.from, 1), n = e.mapResult(this.to, -1); return (t.deleted && n.deleted) || t.pos >= n.pos ? null : new es(t.pos, n.pos, this.mark); } merge(e) { return e instanceof es && e.mark.eq(this.mark) && this.from <= e.to && this.to >= e.from ? new es( Math.min(this.from, e.from), Math.max(this.to, e.to), this.mark, ) : null; } toJSON() { return { stepType: "removeMark", mark: this.mark.toJSON(), from: this.from, to: this.to, }; } static fromJSON(e, t) { if ("number" != typeof t.from || "number" != typeof t.to) throw RangeError("Invalid input for RemoveMarkStep.fromJSON"); return new es(t.from, t.to, e.markFromJSON(t.mark)); } } en.jsonID("removeMark", es); class el extends en { constructor(e, t) { super(), (this.pos = e), (this.mark = t); } apply(e) { let t = e.nodeAt(this.pos); if (!t) return er.fail("No node at mark step's position"); let r = t.type.create(t.attrs, null, this.mark.addToSet(t.marks)); return er.fromReplace( e, this.pos, this.pos + 1, new a(n.from(r), 0, +!t.isLeaf), ); } invert(e) { let t = e.nodeAt(this.pos); if (t) { let e = this.mark.addToSet(t.marks); if (e.length == t.marks.length) { for (let n = 0; n < t.marks.length; n++) if (!t.marks[n].isInSet(e)) return new el(this.pos, t.marks[n]); return new el(this.pos, this.mark); } } return new ea(this.pos, this.mark); } map(e) { let t = e.mapResult(this.pos, 1); return t.deletedAfter ? null : new el(t.pos, this.mark); } toJSON() { return { stepType: "addNodeMark", pos: this.pos, mark: this.mark.toJSON(), }; } static fromJSON(e, t) { if ("number" != typeof t.pos) throw RangeError("Invalid input for AddNodeMarkStep.fromJSON"); return new el(t.pos, e.markFromJSON(t.mark)); } } en.jsonID("addNodeMark", el); class ea extends en { constructor(e, t) { super(), (this.pos = e), (this.mark = t); } apply(e) { let t = e.nodeAt(this.pos); if (!t) return er.fail("No node at mark step's position"); let r = t.type.create(t.attrs, null, this.mark.removeFromSet(t.marks)); return er.fromReplace( e, this.pos, this.pos + 1, new a(n.from(r), 0, +!t.isLeaf), ); } invert(e) { let t = e.nodeAt(this.pos); return t && this.mark.isInSet(t.marks) ? new el(this.pos, this.mark) : this; } map(e) { let t = e.mapResult(this.pos, 1); return t.deletedAfter ? null : new ea(t.pos, this.mark); } toJSON() { return { stepType: "removeNodeMark", pos: this.pos, mark: this.mark.toJSON(), }; } static fromJSON(e, t) { if ("number" != typeof t.pos) throw RangeError("Invalid input for RemoveNodeMarkStep.fromJSON"); return new ea(t.pos, e.markFromJSON(t.mark)); } } en.jsonID("removeNodeMark", ea); class ed extends en { constructor(e, t, n, r = !1) { super(), (this.from = e), (this.to = t), (this.slice = n), (this.structure = r); } apply(e) { return this.structure && eh(e, this.from, this.to) ? er.fail("Structure replace would overwrite content") : er.fromReplace(e, this.from, this.to, this.slice); } getMap() { return new Z([this.from, this.to - this.from, this.slice.size]); } invert(e) { return new ed( this.from, this.from + this.slice.size, e.slice(this.from, this.to), ); } map(e) { let t = e.mapResult(this.from, 1), n = e.mapResult(this.to, -1); return t.deletedAcross && n.deletedAcross ? null : new ed(t.pos, Math.max(t.pos, n.pos), this.slice, this.structure); } merge(e) { if (!(e instanceof ed) || e.structure || this.structure) return null; if ( this.from + this.slice.size != e.from || this.slice.openEnd || e.slice.openStart ) if (e.to != this.from || this.slice.openStart || e.slice.openEnd) return null; else { let t = this.slice.size + e.slice.size == 0 ? a.empty : new a( e.slice.content.append(this.slice.content), e.slice.openStart, this.slice.openEnd, ); return new ed(e.from, this.to, t, this.structure); } { let t = this.slice.size + e.slice.size == 0 ? a.empty : new a( this.slice.content.append(e.slice.content), this.slice.openStart, e.slice.openEnd, ); return new ed( this.from, this.to + (e.to - e.from), t, this.structure, ); } } toJSON() { let e = { stepType: "replace", from: this.from, to: this.to }; return ( this.slice.size && (e.slice = this.slice.toJSON()), this.structure && (e.structure = !0), e ); } static fromJSON(e, t) { if ("number" != typeof t.from || "number" != typeof t.to) throw RangeError("Invalid input for ReplaceStep.fromJSON"); return new ed(t.from, t.to, a.fromJSON(e, t.slice), !!t.structure); } } en.jsonID("replace", ed); class ec extends en { constructor(e, t, n, r, i, o, s = !1) { super(), (this.from = e), (this.to = t), (this.gapFrom = n), (this.gapTo = r), (this.slice = i), (this.insert = o), (this.structure = s); } apply(e) { if ( this.structure && (eh(e, this.from, this.gapFrom) || eh(e, this.gapTo, this.to)) ) return er.fail("Structure gap-replace would overwrite content"); let t = e.slice(this.gapFrom, this.gapTo); if (t.openStart || t.openEnd) return er.fail("Gap is not a flat range"); let n = this.slice.insertAt(this.insert, t.content); return n ? er.fromReplace(e, this.from, this.to, n) : er.fail("Content does not fit in gap"); } getMap() { return new Z([ this.from, this.gapFrom - this.from, this.insert, this.gapTo, this.to - this.gapTo, this.slice.size - this.insert, ]); } invert(e) { let t = this.gapTo - this.gapFrom; return new ec( this.from, this.from + this.slice.size + t, this.from + this.insert, this.from + this.insert + t, e .slice(this.from, this.to) .removeBetween(this.gapFrom - this.from, this.gapTo - this.from), this.gapFrom - this.from, this.structure, ); } map(e) { let t = e.mapResult(this.from, 1), n = e.mapResult(this.to, -1), r = this.from == this.gapFrom ? t.pos : e.map(this.gapFrom, -1), i = this.to == this.gapTo ? n.pos : e.map(this.gapTo, 1); return (t.deletedAcross && n.deletedAcross) || r < t.pos || i > n.pos ? null : new ec(t.pos, n.pos, r, i, this.slice, this.insert, this.structure); } toJSON() { let e = { stepType: "replaceAround", from: this.from, to: this.to, gapFrom: this.gapFrom, gapTo: this.gapTo, insert: this.insert, }; return ( this.slice.size && (e.slice = this.slice.toJSON()), this.structure && (e.structure = !0), e ); } static fromJSON(e, t) { if ( "number" != typeof t.from || "number" != typeof t.to || "number" != typeof t.gapFrom || "number" != typeof t.gapTo || "number" != typeof t.insert ) throw RangeError("Invalid input for ReplaceAroundStep.fromJSON"); return new ec( t.from, t.to, t.gapFrom, t.gapTo, a.fromJSON(e, t.slice), t.insert, !!t.structure, ); } } function eh(e, t, n) { let r = e.resolve(t), i = n - t, o = r.depth; for (; i > 0 && o > 0 && r.indexAfter(o) == r.node(o).childCount; ) o--, i--; if (i > 0) { let e = r.node(o).maybeChild(r.indexAfter(o)); for (; i > 0; ) { if (!e || e.isLeaf) return !0; (e = e.firstChild), i--; } } return !1; } function ep(e, t, r, i = r.contentMatch, o = !0) { let s = e.doc.nodeAt(t), l = [], d = t + 1; for (let t = 0; t < s.childCount; t++) { let c = s.child(t), h = d + c.nodeSize, p = i.matchType(c.type); if (p) { i = p; for (let t = 0; t < c.marks.length; t++) r.allowsMarkType(c.marks[t].type) || e.step(new es(d, h, c.marks[t])); if (o && c.isText && "pre" != r.whitespace) { let e, t = /\r?\n|\r/g, i; for (; (e = t.exec(c.text)); ) i || (i = new a( n.from(r.schema.text(" ", r.allowedMarks(c.marks))), 0, 0, )), l.push(new ed(d + e.index, d + e.index + e[0].length, i)); } } else l.push(new ed(d, h, a.empty)); d = h; } if (!i.validEnd) { let t = i.fillBefore(n.empty, !0); e.replace(d, d, new a(t, 0, 0)); } for (let t = l.length - 1; t >= 0; t--) e.step(l[t]); } function eu(e) { let t = e.parent.content.cutByIndex(e.startIndex, e.endIndex); for (let n = e.depth, r = 0, i = 0; ; --n) { let o = e.$from.node(n), s = e.$from.index(n) + r, l = e.$to.indexAfter(n) - i; if (n < e.depth && o.canReplace(s, l, t)) return n; if ( 0 == n || o.type.spec.isolating || !( (0 == s || o.canReplace(s, o.childCount)) && (l == o.childCount || o.canReplace(0, l)) ) ) break; s && (r = 1), l < o.childCount && (i = 1); } return null; } function ef(e, t, n = null, r = e) { let i = (function (e, t) { let { parent: n, startIndex: r, endIndex: i } = e, o = n.contentMatchAt(r).findWrapping(t); if (!o) return null; let s = o.length ? o[0] : t; return n.canReplaceWith(r, i, s) ? o : null; })(e, t), o = i && (function (e, t) { let { parent: n, startIndex: r, endIndex: i } = e, o = n.child(r), s = t.contentMatch.findWrapping(o.type); if (!s) return null; let l = (s.length ? s[s.length - 1] : t).contentMatch; for (let e = r; l && e < i; e++) l = l.matchType(n.child(e).type); return l && l.validEnd ? s : null; })(r, t); return o ? i.map(em).concat({ type: t, attrs: n }).concat(o.map(em)) : null; } function em(e) { return { type: e, attrs: null }; } function eg(e, t, n, r) { t.forEach((i, o) => { if (i.isText) { let s, l = /\r?\n|\r/g; for (; (s = l.exec(i.text)); ) { let i = e.mapping.slice(r).map(n + 1 + o + s.index); e.replaceWith( i, i + 1, t.type.schema.linebreakReplacement.create(), ); } } }); } function ey(e, t, n, r) { t.forEach((i, o) => { if (i.type == i.type.schema.linebreakReplacement) { let i = e.mapping.slice(r).map(n + 1 + o); e.replaceWith(i, i + 1, t.type.schema.text("\n")); } }); } function eb(e, t, n = 1, r) { let i = e.resolve(t), o = i.depth - n, s = (r && r[r.length - 1]) || i.parent; if ( o < 0 || i.parent.type.spec.isolating || !i.parent.canReplace(i.index(), i.parent.childCount) || !s.type.validContent( i.parent.content.cutByIndex(i.index(), i.parent.childCount), ) ) return !1; for (let e = i.depth - 1, t = n - 2; e > o; e--, t--) { let n = i.node(e), o = i.index(e); if (n.type.spec.isolating) return !1; let s = n.content.cutByIndex(o, n.childCount), l = r && r[t + 1]; l && (s = s.replaceChild(0, l.type.create(l.attrs))); let a = (r && r[t]) || n; if (!n.canReplace(o + 1, n.childCount) || !a.type.validContent(s)) return !1; } let l = i.indexAfter(o), a = r && r[0]; return i.node(o).canReplaceWith(l, l, a ? a.type : i.node(o + 1).type); } function ek(e, t) { let n = e.resolve(t), r = n.index(); return ev(n.nodeBefore, n.nodeAfter) && n.parent.canReplace(r, r + 1); } function ev(e, t) { return !!( e && t && !e.isLeaf && (function (e, t) { t.content.size || e.type.compatibleContent(t.type); let n = e.contentMatchAt(e.childCount), { linebreakReplacement: r } = e.type.schema; for (let i = 0; i < t.childCount; i++) { let o = t.child(i), s = o.type == r ? e.type.schema.nodes.text : o.type; if (!(n = n.matchType(s)) || !e.type.allowsMarks(o.marks)) return !1; } return n.validEnd; })(e, t) ); } function ew(e, t, n = -1) { let r = e.resolve(t); for (let e = r.depth; ; e--) { let i, o, s = r.index(e); if ( (e == r.depth ? ((i = r.nodeBefore), (o = r.nodeAfter)) : n > 0 ? ((i = r.node(e + 1)), s++, (o = r.node(e).maybeChild(s))) : ((i = r.node(e).maybeChild(s - 1)), (o = r.node(e + 1))), i && !i.isTextblock && ev(i, o) && r.node(e).canReplace(s, s + 1)) ) return t; if (0 == e) break; t = n < 0 ? r.before(e) : r.after(e); } } function eS(e, t, n) { let r = e.resolve(t); if (!n.content.size) return t; let i = n.content; for (let e = 0; e < n.openStart; e++) i = i.firstChild.content; for (let e = 1; e <= (0 == n.openStart && n.size ? 2 : 1); e++) for (let t = r.depth; t >= 0; t--) { let n = t == r.depth ? 0 : r.pos <= (r.start(t + 1) + r.end(t + 1)) / 2 ? -1 : 1, o = r.index(t) + +(n > 0), s = r.node(t), l = !1; if (1 == e) l = s.canReplace(o, o, i); else { let e = s.contentMatchAt(o).findWrapping(i.firstChild.type); l = e && s.canReplaceWith(o, o, e[0]); } if (l) return 0 == n ? r.pos : n < 0 ? r.before(t + 1) : r.after(t + 1); } return null; } function ex(e, t, n = t, r = a.empty) { if (t == n && !r.size) return null; let i = e.resolve(t), o = e.resolve(n); return eM(i, o, r) ? new ed(t, n, r) : new eC(i, o, r).fit(); } function eM(e, t, n) { return ( !n.openStart && !n.openEnd && e.start() == t.start() && e.parent.canReplace(e.index(), t.index(), n.content) ); } en.jsonID("replaceAround", ec); class eC { constructor(e, t, r) { (this.$from = e), (this.$to = t), (this.unplaced = r), (this.frontier = []), (this.placed = n.empty); for (let t = 0; t <= e.depth; t++) { let n = e.node(t); this.frontier.push({ type: n.type, match: n.contentMatchAt(e.indexAfter(t)), }); } for (let t = e.depth; t > 0; t--) this.placed = n.from(e.node(t).copy(this.placed)); } get depth() { return this.frontier.length - 1; } fit() { for (; this.unplaced.size; ) { let e = this.findFittable(); e ? this.placeNodes(e) : this.openMore() || this.dropNode(); } let e = this.mustMoveInline(), t = this.placed.size - this.depth - this.$from.depth, n = this.$from, r = this.close(e < 0 ? this.$to : n.doc.resolve(e)); if (!r) return null; let i = this.placed, o = n.depth, s = r.depth; for (; o && s && 1 == i.childCount; ) (i = i.firstChild.content), o--, s--; let l = new a(i, o, s); return e > -1 ? new ec(n.pos, e, this.$to.pos, this.$to.end(), l, t) : l.size || n.pos != this.$to.pos ? new ed(n.pos, r.pos, l) : null; } findFittable() { let e = this.unplaced.openStart; for ( let t = this.unplaced.content, n = 0, r = this.unplaced.openEnd; n < e; n++ ) { let i = t.firstChild; if ((t.childCount > 1 && (r = 0), i.type.spec.isolating && r <= n)) { e = n; break; } t = i.content; } for (let t = 1; t <= 2; t++) for (let r = 1 == t ? e : this.unplaced.openStart; r >= 0; r--) { let e = null, i = ( r ? (e = eE(this.unplaced.content, r - 1).firstChild).content : this.unplaced.content ).firstChild; for (let o = this.depth; o >= 0; o--) { let { type: s, match: l } = this.frontier[o], a, d = null; if ( 1 == t && (i ? l.matchType(i.type) || (d = l.fillBefore(n.from(i), !1)) : e && s.compatibleContent(e.type)) ) return { sliceDepth: r, frontierDepth: o, parent: e, inject: d, }; if (2 == t && i && (a = l.findWrapping(i.type))) return { sliceDepth: r, frontierDepth: o, parent: e, wrap: a }; if (e && l.matchType(e.type)) break; } } } openMore() { let { content: e, openStart: t, openEnd: n } = this.unplaced, r = eE(e, t); return ( !!r.childCount && !r.firstChild.isLeaf && ((this.unplaced = new a( e, t + 1, Math.max(n, r.size + t >= e.size - n ? t + 1 : 0), )), !0) ); } dropNode() { let { content: e, openStart: t, openEnd: n } = this.unplaced, r = eE(e, t); if (r.childCount <= 1 && t > 0) { let i = e.size - t <= t + r.size; this.unplaced = new a(eT(e, t - 1, 1), t - 1, i ? t - 1 : n); } else this.unplaced = new a(eT(e, t, 1), t, n); } placeNodes({ sliceDepth: e, frontierDepth: t, parent: r, inject: i, wrap: o, }) { for (; this.depth > t; ) this.closeFrontierNode(); if (o) for (let e = 0; e < o.length; e++) this.openFrontierNode(o[e]); let s = this.unplaced, l = r ? r.content : s.content, d = s.openStart - e, c = 0, h = [], { match: p, type: u } = this.frontier[t]; if (i) { for (let e = 0; e < i.childCount; e++) h.push(i.child(e)); p = p.matchFragment(i); } let f = l.size + e - (s.content.size - s.openEnd); for (; c < l.childCount; ) { let e = l.child(c), t = p.matchType(e.type); if (!t) break; (++c > 1 || 0 == d || e.content.size) && ((p = t), h.push( (function e(t, r, i) { if (r <= 0) return t; let o = t.content; return ( r > 1 && (o = o.replaceChild( 0, e(o.firstChild, r - 1, 1 == o.childCount ? i - 1 : 0), )), r > 0 && ((o = t.type.contentMatch.fillBefore(o).append(o)), i <= 0 && (o = o.append( t.type.contentMatch .matchFragment(o) .fillBefore(n.empty, !0), ))), t.copy(o) ); })( e.mark(u.allowedMarks(e.marks)), 1 == c ? d : 0, c == l.childCount ? f : -1, ), )); } let m = c == l.childCount; m || (f = -1), (this.placed = eN(this.placed, t, n.from(h))), (this.frontier[t].match = p), m && f < 0 && r && r.type == this.frontier[this.depth].type && this.frontier.length > 1 && this.closeFrontierNode(); for (let e = 0, t = l; e < f; e++) { let e = t.lastChild; this.frontier.push({ type: e.type, match: e.contentMatchAt(e.childCount), }), (t = e.content); } this.unplaced = m ? 0 == e ? a.empty : new a(eT(s.content, e - 1, 1), e - 1, f < 0 ? s.openEnd : e - 1) : new a(eT(s.content, e, c), s.openStart, s.openEnd); } mustMoveInline() { if (!this.$to.parent.isTextblock) return -1; let e = this.frontier[this.depth], t; if ( !e.type.isTextblock || !eO(this.$to, this.$to.depth, e.type, e.match, !1) || (this.$to.depth == this.depth && (t = this.findCloseLevel(this.$to)) && t.depth == this.depth) ) return -1; let { depth: n } = this.$to, r = this.$to.after(n); for (; n > 1 && r == this.$to.end(--n); ) ++r; return r; } findCloseLevel(e) { t: for (let t = Math.min(this.depth, e.depth); t >= 0; t--) { let { match: n, type: r } = this.frontier[t], i = t < e.depth && e.end(t + 1) == e.pos + (e.depth - (t + 1)), o = eO(e, t, r, n, i); if (o) { for (let n = t - 1; n >= 0; n--) { let { match: t, type: r } = this.frontier[n], i = eO(e, n, r, t, !0); if (!i || i.childCount) continue t; } return { depth: t, fit: o, move: i ? e.doc.resolve(e.after(t + 1)) : e, }; } } } close(e) { let t = this.findCloseLevel(e); if (!t) return null; for (; this.depth > t.depth; ) this.closeFrontierNode(); t.fit.childCount && (this.placed = eN(this.placed, t.depth, t.fit)), (e = t.move); for (let n = t.depth + 1; n <= e.depth; n++) { let t = e.node(n), r = t.type.contentMatch.fillBefore(t.content, !0, e.index(n)); this.openFrontierNode(t.type, t.attrs, r); } return e; } openFrontierNode(e, t = null, r) { let i = this.frontier[this.depth]; (i.match = i.match.matchType(e)), (this.placed = eN(this.placed, this.depth, n.from(e.create(t, r)))), this.frontier.push({ type: e, match: e.contentMatch }); } closeFrontierNode() { let e = this.frontier.pop().match.fillBefore(n.empty, !0); e.childCount && (this.placed = eN(this.placed, this.frontier.length, e)); } } function eT(e, t, n) { return 0 == t ? e.cutByIndex(n, e.childCount) : e.replaceChild( 0, e.firstChild.copy(eT(e.firstChild.content, t - 1, n)), ); } function eN(e, t, n) { return 0 == t ? e.append(n) : e.replaceChild( e.childCount - 1, e.lastChild.copy(eN(e.lastChild.content, t - 1, n)), ); } function eE(e, t) { for (let n = 0; n < t; n++) e = e.firstChild.content; return e; } function eO(e, t, n, r, i) { let o = e.node(t), s = i ? e.indexAfter(t) : e.index(t); if (s == o.childCount && !n.compatibleContent(o.type)) return null; let l = r.fillBefore(o.content, !0, s); return l && !(function (e, t, n) { for (let r = n; r < t.childCount; r++) if (!e.allowsMarks(t.child(r).marks)) return !0; return !1; })(n, o.content, s) ? l : null; } function eA(e, t) { let n = [], r = Math.min(e.depth, t.depth); for (let i = r; i >= 0; i--) { let r = e.start(i); if ( r < e.pos - (e.depth - i) || t.end(i) > t.pos + (t.depth - i) || e.node(i).type.spec.isolating || t.node(i).type.spec.isolating ) break; (r == t.start(i) || (i == e.depth && i == t.depth && e.parent.inlineContent && t.parent.inlineContent && i && t.start(i - 1) == r - 1)) && n.push(i); } return n; } class eD extends en { constructor(e, t, n) { super(), (this.pos = e), (this.attr = t), (this.value = n); } apply(e) { let t = e.nodeAt(this.pos); if (!t) return er.fail("No node at attribute step's position"); let r = Object.create(null); for (let e in t.attrs) r[e] = t.attrs[e]; r[this.attr] = this.value; let i = t.type.create(r, null, t.marks); return er.fromReplace( e, this.pos, this.pos + 1, new a(n.from(i), 0, +!t.isLeaf), ); } getMap() { return Z.empty; } invert(e) { return new eD(this.pos, this.attr, e.nodeAt(this.pos).attrs[this.attr]); } map(e) { let t = e.mapResult(this.pos, 1); return t.deletedAfter ? null : new eD(t.pos, this.attr, this.value); } toJSON() { return { stepType: "attr", pos: this.pos, attr: this.attr, value: this.value, }; } static fromJSON(e, t) { if ("number" != typeof t.pos || "string" != typeof t.attr) throw RangeError("Invalid input for AttrStep.fromJSON"); return new eD(t.pos, t.attr, t.value); } } en.jsonID("attr", eD); class eR extends en { constructor(e, t) { super(), (this.attr = e), (this.value = t); } apply(e) { let t = Object.create(null); for (let n in e.attrs) t[n] = e.attrs[n]; t[this.attr] = this.value; let n = e.type.create(t, e.content, e.marks); return er.ok(n); } getMap() { return Z.empty; } invert(e) { return new eR(this.attr, e.attrs[this.attr]); } map(e) { return this; } toJSON() { return { stepType: "docAttr", attr: this.attr, value: this.value }; } static fromJSON(e, t) { if ("string" != typeof t.attr) throw RangeError("Invalid input for DocAttrStep.fromJSON"); return new eR(t.attr, t.value); } } en.jsonID("docAttr", eR); let eI = class extends Error {}; ((eI = function e(t) { let n = Error.call(this, t); return (n.__proto__ = e.prototype), n; }).prototype = Object.create(Error.prototype)), (eI.prototype.constructor = eI), (eI.prototype.name = "TransformError"); class eP { constructor(e) { (this.doc = e), (this.steps = []), (this.docs = []), (this.mapping = new ee()); } get before() { return this.docs.length ? this.docs[0] : this.doc; } step(e) { let t = this.maybeStep(e); if (t.failed) throw new eI(t.failed); return this; } maybeStep(e) { let t = e.apply(this.doc); return t.failed || this.addStep(e, t.doc), t; } get docChanged() { return this.steps.length > 0; } changedRange() { let e = 1e9, t = -1e9; for (let n = 0; n < this.mapping.maps.length; n++) { let r = this.mapping.maps[n]; n && ((e = r.map(e, 1)), (t = r.map(t, -1))), r.forEach((n, r, i, o) => { (e = Math.min(e, i)), (t = Math.max(t, o)); }); } return 1e9 == e ? null : { from: e, to: t }; } addStep(e, t) { this.docs.push(this.doc), this.steps.push(e), this.mapping.appendMap(e.getMap()), (this.doc = t); } replace(e, t = e, n = a.empty) { let r = ex(this.doc, e, t, n); return r && this.step(r), this; } replaceWith(e, t, r) { return this.replace(e, t, new a(n.from(r), 0, 0)); } delete(e, t) { return this.replace(e, t, a.empty); } insert(e, t) { return this.replaceWith(e, e, t); } replaceRange(e, t, r) { return ( !(function (e, t, r, i) { if (!i.size) return e.deleteRange(t, r); let o = e.doc.resolve(t), s = e.doc.resolve(r); if (eM(o, s, i)) return e.step(new ed(t, r, i)); let l = eA(o, s); 0 == l[l.length - 1] && l.pop(); let d = -(o.depth + 1); l.unshift(d); for (let e = o.depth, t = o.pos - 1; e > 0; e--, t--) { let n = o.node(e).type.spec; if (n.defining || n.definingAsContext || n.isolating) break; l.indexOf(e) > -1 ? (d = e) : o.before(e) == t && l.splice(1, 0, -e); } let c = l.indexOf(d), h = [], p = i.openStart; for (let e = i.content, t = 0; ; t++) { let n = e.firstChild; if ((h.push(n), t == i.openStart)) break; e = n.content; } for (let e = p - 1; e >= 0; e--) { var u; let t = h[e], n = (u = t.type).spec.defining || u.spec.definingForContent; if (n && !t.sameMarkup(o.node(Math.abs(d) - 1))) p = e; else if (n || !t.type.isTextblock) break; } for (let t = i.openStart; t >= 0; t--) { let d = (t + p + 1) % (i.openStart + 1), u = h[d]; if (u) for (let t = 0; t < l.length; t++) { let h = l[(t + c) % l.length], p = !0; h < 0 && ((p = !1), (h = -h)); let f = o.node(h - 1), m = o.index(h - 1); if (f.canReplaceWith(m, m, u.type, u.marks)) return e.replace( o.before(h), p ? s.after(h) : r, new a( (function e(t, r, i, o, s) { if (r < i) { let n = t.firstChild; t = t.replaceChild( 0, n.copy(e(n.content, r + 1, i, o, n)), ); } if (r > o) { let e = s.contentMatchAt(0), r = e.fillBefore(t).append(t); t = r.append( e.matchFragment(r).fillBefore(n.empty, !0), ); } return t; })(i.content, 0, i.openStart, d), d, i.openEnd, ), ); } } let f = e.steps.length; for ( let n = l.length - 1; n >= 0 && (e.replace(t, r, i), !(e.steps.length > f)); n-- ) { let e = l[n]; e < 0 || ((t = o.before(e)), (r = s.after(e))); } })(this, e, t, r), this ); } replaceRangeWith(e, t, r) { var i = e, o = t; if (!r.isInline && i == o && this.doc.resolve(i).parent.content.size) { let e = (function (e, t, n) { let r = e.resolve(t); if (r.parent.canReplaceWith(r.index(), r.index(), n)) return t; if (0 == r.parentOffset) for (let e = r.depth - 1; e >= 0; e--) { let t = r.index(e); if (r.node(e).canReplaceWith(t, t, n)) return r.before(e + 1); if (t > 0) return null; } if (r.parentOffset == r.parent.content.size) for (let e = r.depth - 1; e >= 0; e--) { let t = r.indexAfter(e); if (r.node(e).canReplaceWith(t, t, n)) return r.after(e + 1); if (t < r.node(e).childCount) break; } return null; })(this.doc, i, r.type); null != e && (i = o = e); } return this.replaceRange(i, o, new a(n.from(r), 0, 0)), this; } deleteRange(e, t) { return ( !(function (e, t, n) { let r = e.doc.resolve(t), i = e.doc.resolve(n), o = eA(r, i); for (let t = 0; t < o.length; t++) { let n = o[t], s = t == o.length - 1; if ((s && 0 == n) || r.node(n).type.contentMatch.validEnd) return e.delete(r.start(n), i.end(n)); if ( n > 0 && (s || r.node(n - 1).canReplace(r.index(n - 1), i.indexAfter(n - 1))) ) return e.delete(r.before(n), i.after(n)); } for (let o = 1; o <= r.depth && o <= i.depth; o++) if ( t - r.start(o) == r.depth - o && n > r.end(o) && i.end(o) - n != i.depth - o && r.start(o - 1) == i.start(o - 1) && r.node(o - 1).canReplace(r.index(o - 1), i.index(o - 1)) ) return e.delete(r.before(o), n); e.delete(t, n); })(this, e, t), this ); } lift(e, t) { return ( !(function (e, t, r) { let { $from: i, $to: o, depth: s } = t, l = i.before(s + 1), d = o.after(s + 1), c = l, h = d, p = n.empty, u = 0; for (let e = s, t = !1; e > r; e--) t || i.index(e) > 0 ? ((t = !0), (p = n.from(i.node(e).copy(p))), u++) : c--; let f = n.empty, m = 0; for (let e = s, t = !1; e > r; e--) t || o.after(e + 1) < o.end(e) ? ((t = !0), (f = n.from(o.node(e).copy(f))), m++) : h++; e.step( new ec(c, h, l, d, new a(p.append(f), u, m), p.size - u, !0), ); })(this, e, t), this ); } join(e, t = 1) { return ( !(function (e, t, n) { let r = null, { linebreakReplacement: i } = e.doc.type.schema, o = e.doc.resolve(t - n), s = o.node().type; if (i && s.inlineContent) { let e = "pre" == s.whitespace, t = !!s.contentMatch.matchType(i); e && !t ? (r = !1) : !e && t && (r = !0); } let l = e.steps.length; if (!1 === r) { let r = e.doc.resolve(t + n); ey(e, r.node(), r.before(), l); } s.inlineContent && ep( e, t + n - 1, s, o.node().contentMatchAt(o.index()), null == r, ); let d = e.mapping.slice(l), c = d.map(t - n); if ((e.step(new ed(c, d.map(t + n, -1), a.empty, !0)), !0 === r)) { let t = e.doc.resolve(c); eg(e, t.node(), t.before(), e.steps.length); } })(this, e, t), this ); } wrap(e, t) { return ( !(function (e, t, r) { let i = n.empty; for (let e = r.length - 1; e >= 0; e--) { if (i.size) { let t = r[e].type.contentMatch.matchFragment(i); if (!t || !t.validEnd) throw RangeError( "Wrapper type given to Transform.wrap does not form valid content of its parent wrapper", ); } i = n.from(r[e].type.create(r[e].attrs, i)); } let o = t.start, s = t.end; e.step(new ec(o, s, o, s, new a(i, 0, 0), r.length, !0)); })(this, e, t), this ); } setBlockType(e, t = e, r, i = null) { var o = this; if (!r.isTextblock) throw RangeError("Type given to setBlockType should be a textblock"); let s = o.steps.length; return ( o.doc.nodesBetween(e, t, (e, t) => { var l, d, c; let h, p, u = "function" == typeof i ? i(e) : i; if ( e.isTextblock && !e.hasMarkup(r, u) && ((l = o.doc), (d = o.mapping.slice(s).map(t)), (c = r), (p = (h = l.resolve(d)).index()), h.parent.canReplaceWith(p, p + 1, c)) ) { let i = null; if (r.schema.linebreakReplacement) { let e = "pre" == r.whitespace, t = !!r.contentMatch.matchType(r.schema.linebreakReplacement); e && !t ? (i = !1) : !e && t && (i = !0); } !1 === i && ey(o, e, t, s), ep(o, o.mapping.slice(s).map(t, 1), r, void 0, null === i); let l = o.mapping.slice(s), d = l.map(t, 1), c = l.map(t + e.nodeSize, 1); return ( o.step( new ec( d, c, d + 1, c - 1, new a(n.from(r.create(u, null, e.marks)), 0, 0), 1, !0, ), ), !0 === i && eg(o, e, t, s), !1 ); } }), this ); } setNodeMarkup(e, t, r = null, i) { return ( !(function (e, t, r, i, o) { let s = e.doc.nodeAt(t); if (!s) throw RangeError("No node at given position"); r || (r = s.type); let l = r.create(i, null, o || s.marks); if (s.isLeaf) return e.replaceWith(t, t + s.nodeSize, l); if (!r.validContent(s.content)) throw RangeError("Invalid content for node type " + r.name); e.step( new ec( t, t + s.nodeSize, t + 1, t + s.nodeSize - 1, new a(n.from(l), 0, 0), 1, !0, ), ); })(this, e, t, r, i), this ); } setNodeAttribute(e, t, n) { return this.step(new eD(e, t, n)), this; } setDocAttribute(e, t) { return this.step(new eR(e, t)), this; } addNodeMark(e, t) { return this.step(new el(e, t)), this; } removeNodeMark(e, t) { let n = this.doc.nodeAt(e); if (!n) throw RangeError("No node at position " + e); if (t instanceof s) t.isInSet(n.marks) && this.step(new ea(e, t)); else { let r = n.marks, i, o = []; for (; (i = t.isInSet(r)); ) o.push(new ea(e, i)), (r = i.removeFromSet(r)); for (let e = o.length - 1; e >= 0; e--) this.step(o[e]); } return this; } split(e, t = 1, r) { return ( !(function (e, t, r = 1, i) { let o = e.doc.resolve(t), s = n.empty, l = n.empty; for (let e = o.depth, t = o.depth - r, a = r - 1; e > t; e--, a--) { s = n.from(o.node(e).copy(s)); let t = i && i[a]; l = n.from(t ? t.type.create(t.attrs, l) : o.node(e).copy(l)); } e.step(new ed(t, t, new a(s.append(l), r, r), !0)); })(this, e, t, r), this ); } addMark(e, t, n) { var r; let i, o, s, l; return ( (r = this), (s = []), (l = []), r.doc.nodesBetween(e, t, (r, a, d) => { if (!r.isInline) return; let c = r.marks; if (!n.isInSet(c) && d.type.allowsMarkType(n.type)) { let d = Math.max(a, e), h = Math.min(a + r.nodeSize, t), p = n.addToSet(c); for (let e = 0; e < c.length; e++) c[e].isInSet(p) || (i && i.to == d && i.mark.eq(c[e]) ? (i.to = h) : s.push((i = new es(d, h, c[e])))); o && o.to == d ? (o.to = h) : l.push((o = new eo(d, h, n))); } }), s.forEach((e) => r.step(e)), l.forEach((e) => r.step(e)), this ); } removeMark(e, t, n) { var r; let i, o; return ( (r = this), (i = []), (o = 0), r.doc.nodesBetween(e, t, (r, s) => { if (!r.isInline) return; o++; let l = null; if (n instanceof L) { let e = r.marks, t; for (; (t = n.isInSet(e)); ) (l || (l = [])).push(t), (e = t.removeFromSet(e)); } else n ? n.isInSet(r.marks) && (l = [n]) : (l = r.marks); if (l && l.length) { let n = Math.min(s + r.nodeSize, t); for (let t = 0; t < l.length; t++) { let r = l[t], a; for (let e = 0; e < i.length; e++) { let t = i[e]; t.step == o - 1 && r.eq(i[e].style) && (a = t); } a ? ((a.to = n), (a.step = o)) : i.push({ style: r, from: Math.max(s, e), to: n, step: o }); } } }), i.forEach((e) => r.step(new es(e.from, e.to, e.style))), this ); } clearIncompatible(e, t, n) { return ep(this, e, t, n), this; } } e.s( [ "Mapping", () => ee, "RemoveMarkStep", () => es, "ReplaceAroundStep", () => ec, "ReplaceStep", () => ed, "Transform", () => eP, "canJoin", () => ek, "canSplit", () => eb, "dropPoint", () => eS, "findWrapping", () => ef, "joinPoint", () => ew, "liftTarget", () => eu, "replaceStep", () => ex, ], 545773, ); }; export default moduleFactory;