@limetech/lime-elements 37.27.0 → 37.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/cjs/lime-elements.cjs.js +1 -1
- package/dist/cjs/limel-markdown.cjs.entry.js +6 -43714
- package/dist/cjs/limel-markdown.cjs.entry.js.map +1 -1
- package/dist/cjs/limel-prosemirror-adapter.cjs.entry.js +8711 -43
- package/dist/cjs/limel-prosemirror-adapter.cjs.entry.js.map +1 -1
- package/dist/cjs/limel-text-editor.cjs.entry.js +2 -1
- package/dist/cjs/limel-text-editor.cjs.entry.js.map +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/markdown-parser-1686b0d7.js +44158 -0
- package/dist/cjs/markdown-parser-1686b0d7.js.map +1 -0
- package/dist/collection/components/text-editor/prosemirror-adapter/prosemirror-adapter.js +61 -35
- package/dist/collection/components/text-editor/prosemirror-adapter/prosemirror-adapter.js.map +1 -1
- package/dist/collection/components/text-editor/text-editor.js +23 -2
- package/dist/collection/components/text-editor/text-editor.js.map +1 -1
- package/dist/collection/components/text-editor/utils/content-type-converter.js +2 -0
- package/dist/collection/components/text-editor/utils/content-type-converter.js.map +1 -0
- package/dist/collection/components/text-editor/utils/html-converter.js +21 -0
- package/dist/collection/components/text-editor/utils/html-converter.js.map +1 -0
- package/dist/collection/components/text-editor/utils/markdown-converter.js +21 -0
- package/dist/collection/components/text-editor/utils/markdown-converter.js.map +1 -0
- package/dist/esm/lime-elements.js +1 -1
- package/dist/esm/limel-markdown.entry.js +4 -43712
- package/dist/esm/limel-markdown.entry.js.map +1 -1
- package/dist/esm/limel-prosemirror-adapter.entry.js +8711 -43
- package/dist/esm/limel-prosemirror-adapter.entry.js.map +1 -1
- package/dist/esm/limel-text-editor.entry.js +2 -1
- package/dist/esm/limel-text-editor.entry.js.map +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/markdown-parser-2ab3dab9.js +44155 -0
- package/dist/esm/markdown-parser-2ab3dab9.js.map +1 -0
- package/dist/lime-elements/lime-elements.esm.js +1 -1
- package/dist/lime-elements/lime-elements.esm.js.map +1 -1
- package/dist/lime-elements/p-3619d8ca.entry.js +2 -0
- package/dist/lime-elements/p-3619d8ca.entry.js.map +1 -0
- package/dist/lime-elements/p-50a9c9b4.entry.js +2 -0
- package/dist/lime-elements/p-50a9c9b4.entry.js.map +1 -0
- package/dist/lime-elements/p-714d3ef8.js +8 -0
- package/dist/lime-elements/p-714d3ef8.js.map +1 -0
- package/dist/lime-elements/{p-48d4564a.entry.js → p-e9d2525d.entry.js} +2 -2
- package/dist/lime-elements/p-e9d2525d.entry.js.map +1 -0
- package/dist/types/components/text-editor/prosemirror-adapter/prosemirror-adapter.d.ts +10 -3
- package/dist/types/components/text-editor/text-editor.d.ts +8 -1
- package/dist/types/components/text-editor/utils/content-type-converter.d.ts +15 -0
- package/dist/types/components/text-editor/utils/html-converter.d.ts +10 -0
- package/dist/types/components/text-editor/utils/markdown-converter.d.ts +10 -0
- package/dist/types/components.d.ts +28 -4
- package/package.json +2 -1
- package/dist/lime-elements/p-48d4564a.entry.js.map +0 -1
- package/dist/lime-elements/p-91f40d46.entry.js +0 -2
- package/dist/lime-elements/p-91f40d46.entry.js.map +0 -1
- package/dist/lime-elements/p-b6e238b6.entry.js +0 -8
- package/dist/lime-elements/p-b6e238b6.entry.js.map +0 -1
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{r as t,c as e,h as i,g as r}from"./p-443111b3.js";function n(t){this.content=t}n.prototype={constructor:n,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?undefined:this.content[e+1]},update:function(t,e,i){var r=i&&i!=t?this.remove(i):this;var s=r.find(t),l=r.content.slice();if(s==-1){l.push(i||t,e)}else{l[s+1]=e;if(i)l[s]=i}return new n(l)},remove:function(t){var e=this.find(t);if(e==-1)return this;var i=this.content.slice();i.splice(e,2);return new n(i)},addToStart:function(t,e){return new n([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var i=this.remove(t).content.slice();i.push(t,e);return new n(i)},addBefore:function(t,e,i){var r=this.remove(e),s=r.content.slice();var l=r.find(t);s.splice(l==-1?s.length:l,0,e,i);return new n(s)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){t=n.from(t);if(!t.size)return this;return new n(t.content.concat(this.subtract(t).content))},append:function(t){t=n.from(t);if(!t.size)return this;return new n(this.subtract(t).content.concat(t.content))},subtract:function(t){var e=this;t=n.from(t);for(var i=0;i<t.content.length;i+=2)e=e.remove(t.content[i]);return e},toObject:function(){var t={};this.forEach((function(e,i){t[e]=i}));return t},get size(){return this.content.length>>1}};n.from=function(t){if(t instanceof n)return t;var e=[];if(t)for(var i in t)e.push(i,t[i]);return new n(e)};function s(t,e,i){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:i;let n=t.child(r),l=e.child(r);if(n==l){i+=n.nodeSize;continue}if(!n.sameMarkup(l))return i;if(n.isText&&n.text!=l.text){for(let t=0;n.text[t]==l.text[t];t++)i++;return i}if(n.content.size||l.content.size){let t=s(n.content,l.content,i+1);if(t!=null)return t}i+=n.nodeSize}}function l(t,e,i,r){for(let n=t.childCount,s=e.childCount;;){if(n==0||s==0)return n==s?null:{a:i,b:r};let f=t.child(--n),o=e.child(--s),u=f.nodeSize;if(f==o){i-=u;r-=u;continue}if(!f.sameMarkup(o))return{a:i,b:r};if(f.isText&&f.text!=o.text){let t=0,e=Math.min(f.text.length,o.text.length);while(t<e&&f.text[f.text.length-t-1]==o.text[o.text.length-t-1]){t++;i--;r--}return{a:i,b:r}}if(f.content.size||o.content.size){let t=l(f.content,o.content,i-1,r-1);if(t)return t}i-=u;r-=u}}class f{constructor(t,e){this.content=t;this.size=e||0;if(e==null)for(let e=0;e<t.length;e++)this.size+=t[e].nodeSize}nodesBetween(t,e,i,r=0,n){for(let s=0,l=0;l<e;s++){let f=this.content[s],o=l+f.nodeSize;if(o>t&&i(f,r+l,n||null,s)!==false&&f.content.size){let n=l+1;f.nodesBetween(Math.max(0,t-n),Math.min(f.content.size,e-n),i,r+n)}l=o}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,e,i,r){let n="",s=true;this.nodesBetween(t,e,((l,f)=>{let o=l.isText?l.text.slice(Math.max(t,f)-f,e-f):!l.isLeaf?"":r?typeof r==="function"?r(l):r:l.type.spec.leafText?l.type.spec.leafText(l):"";if(l.isBlock&&(l.isLeaf&&o||l.isTextblock)&&i){if(s)s=false;else n+=i}n+=o}),0);return n}append(t){if(!t.size)return this;if(!this.size)return t;let e=this.lastChild,i=t.firstChild,r=this.content.slice(),n=0;if(e.isText&&e.sameMarkup(i)){r[r.length-1]=e.withText(e.text+i.text);n=1}for(;n<t.content.length;n++)r.push(t.content[n]);return new f(r,this.size+t.size)}cut(t,e=this.size){if(t==0&&e==this.size)return this;let i=[],r=0;if(e>t)for(let n=0,s=0;s<e;n++){let l=this.content[n],f=s+l.nodeSize;if(f>t){if(s<t||f>e){if(l.isText)l=l.cut(Math.max(0,t-s),Math.min(l.text.length,e-s));else l=l.cut(Math.max(0,t-s-1),Math.min(l.content.size,e-s-1))}i.push(l);r+=l.nodeSize}s=f}return new f(i,r)}cutByIndex(t,e){if(t==e)return f.empty;if(t==0&&e==this.content.length)return this;return new f(this.content.slice(t,e))}replaceChild(t,e){let i=this.content[t];if(i==e)return this;let r=this.content.slice();let n=this.size+e.nodeSize-i.nodeSize;r[t]=e;return new f(r,n)}addToStart(t){return new f([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new f(this.content.concat(t),this.size+t.nodeSize)}eq(t){if(this.content.length!=t.content.length)return false;for(let e=0;e<this.content.length;e++)if(!this.content[e].eq(t.content[e]))return false;return true}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(t){let e=this.content[t];if(!e)throw new RangeError("Index "+t+" out of range for "+this);return e}maybeChild(t){return this.content[t]||null}forEach(t){for(let e=0,i=0;e<this.content.length;e++){let r=this.content[e];t(r,i,e);i+=r.nodeSize}}findDiffStart(t,e=0){return s(this,t,e)}findDiffEnd(t,e=this.size,i=t.size){return l(this,t,e,i)}findIndex(t,e=-1){if(t==0)return u(0,t);if(t==this.size)return u(this.content.length,t);if(t>this.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let i=0,r=0;;i++){let n=this.child(i),s=r+n.nodeSize;if(s>=t){if(s==t||e>0)return u(i+1,s);return u(i,r)}r=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map((t=>t.toJSON())):null}static fromJSON(t,e){if(!e)return f.empty;if(!Array.isArray(e))throw new RangeError("Invalid input for Fragment.fromJSON");return new f(e.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return f.empty;let e,i=0;for(let r=0;r<t.length;r++){let n=t[r];i+=n.nodeSize;if(r&&n.isText&&t[r-1].sameMarkup(n)){if(!e)e=t.slice(0,r);e[e.length-1]=n.withText(e[e.length-1].text+n.text)}else if(e){e.push(n)}}return new f(e||t,i)}static from(t){if(!t)return f.empty;if(t instanceof f)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new f([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}f.empty=new f([],0);const o={index:0,offset:0};function u(t,e){o.index=t;o.offset=e;return o}function h(t,e){if(t===e)return true;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return false;let i=Array.isArray(t);if(Array.isArray(e)!=i)return false;if(i){if(t.length!=e.length)return false;for(let i=0;i<t.length;i++)if(!h(t[i],e[i]))return false}else{for(let i in t)if(!(i in e)||!h(t[i],e[i]))return false;for(let i in e)if(!(i in t))return false}return true}class a{constructor(t,e){this.type=t;this.attrs=e}addToSet(t){let e,i=false;for(let r=0;r<t.length;r++){let n=t[r];if(this.eq(n))return t;if(this.type.excludes(n.type)){if(!e)e=t.slice(0,r)}else if(n.type.excludes(this.type)){return t}else{if(!i&&n.type.rank>this.type.rank){if(!e)e=t.slice(0,r);e.push(this);i=true}if(e)e.push(n)}}if(!e)e=t.slice();if(!i)e.push(this);return e}removeFromSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return t.slice(0,e).concat(t.slice(e+1));return t}isInSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return true;return false}eq(t){return this==t||this.type==t.type&&h(this.attrs,t.attrs)}toJSON(){let t={type:this.type.name};for(let e in this.attrs){t.attrs=this.attrs;break}return t}static fromJSON(t,e){if(!e)throw new RangeError("Invalid input for Mark.fromJSON");let i=t.marks[e.type];if(!i)throw new RangeError(`There is no mark type ${e.type} in this schema`);return i.create(e.attrs)}static sameSet(t,e){if(t==e)return true;if(t.length!=e.length)return false;for(let i=0;i<t.length;i++)if(!t[i].eq(e[i]))return false;return true}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return a.none;if(t instanceof a)return[t];let e=t.slice();e.sort(((t,e)=>t.type.rank-e.type.rank));return e}}a.none=[];class c extends Error{}class d{constructor(t,e,i){this.content=t;this.openStart=e;this.openEnd=i}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,e){let i=m(this.content,t+this.openStart,e);return i&&new d(i,this.openStart,this.openEnd)}removeBetween(t,e){return new d(p(this.content,t+this.openStart,e+this.openStart),this.openStart,this.openEnd)}eq(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let t={content:this.content.toJSON()};if(this.openStart>0)t.openStart=this.openStart;if(this.openEnd>0)t.openEnd=this.openEnd;return t}static fromJSON(t,e){if(!e)return d.empty;let i=e.openStart||0,r=e.openEnd||0;if(typeof i!="number"||typeof r!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new d(f.fromJSON(t,e.content),i,r)}static maxOpen(t,e=true){let i=0,r=0;for(let r=t.firstChild;r&&!r.isLeaf&&(e||!r.type.spec.isolating);r=r.firstChild)i++;for(let i=t.lastChild;i&&!i.isLeaf&&(e||!i.type.spec.isolating);i=i.lastChild)r++;return new d(t,i,r)}}d.empty=new d(f.empty,0,0);function p(t,e,i){let{index:r,offset:n}=t.findIndex(e),s=t.maybeChild(r);let{index:l,offset:f}=t.findIndex(i);if(n==e||s.isText){if(f!=i&&!t.child(l).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(i))}if(r!=l)throw new RangeError("Removing non-flat range");return t.replaceChild(r,s.copy(p(s.content,e-n-1,i-n-1)))}function m(t,e,i,r){let{index:n,offset:s}=t.findIndex(e),l=t.maybeChild(n);if(s==e||l.isText){if(r&&!r.canReplace(n,n,i))return null;return t.cut(0,e).append(i).append(t.cut(e))}let f=m(l.content,e-s-1,i);return f&&t.replaceChild(n,l.copy(f))}function w(t,e,i){if(i.openStart>t.depth)throw new c("Inserted content deeper than insertion position");if(t.depth-i.openStart!=e.depth-i.openEnd)throw new c("Inconsistent open depths");return g(t,e,i,0)}function g(t,e,i,r){let n=t.index(r),s=t.node(r);if(n==e.index(r)&&r<t.depth-i.openStart){let l=g(t,e,i,r+1);return s.copy(s.content.replaceChild(n,l))}else if(!i.content.size){return M(s,S(t,e,r))}else if(!i.openStart&&!i.openEnd&&t.depth==r&&e.depth==r){let r=t.parent,n=r.content;return M(r,n.cut(0,t.parentOffset).append(i.content).append(n.cut(e.parentOffset)))}else{let{start:n,end:l}=O(i,t);return M(s,x(t,n,l,e,r))}}function b(t,e){if(!e.type.compatibleContent(t.type))throw new c("Cannot join "+e.type.name+" onto "+t.type.name)}function v(t,e,i){let r=t.node(i);b(r,e.node(i));return r}function y(t,e){let i=e.length-1;if(i>=0&&t.isText&&t.sameMarkup(e[i]))e[i]=t.withText(e[i].text+t.text);else e.push(t)}function k(t,e,i,r){let n=(e||t).node(i);let s=0,l=e?e.index(i):n.childCount;if(t){s=t.index(i);if(t.depth>i){s++}else if(t.textOffset){y(t.nodeAfter,r);s++}}for(let t=s;t<l;t++)y(n.child(t),r);if(e&&e.depth==i&&e.textOffset)y(e.nodeBefore,r)}function M(t,e){t.type.checkContent(e);return t.copy(e)}function x(t,e,i,r,n){let s=t.depth>n&&v(t,e,n+1);let l=r.depth>n&&v(i,r,n+1);let o=[];k(null,t,n,o);if(s&&l&&e.index(n)==i.index(n)){b(s,l);y(M(s,x(t,e,i,r,n+1)),o)}else{if(s)y(M(s,S(t,e,n+1)),o);k(e,i,n,o);if(l)y(M(l,S(i,r,n+1)),o)}k(r,null,n,o);return new f(o)}function S(t,e,i){let r=[];k(null,t,i,r);if(t.depth>i){let n=v(t,e,i+1);y(M(n,S(t,e,i+1)),r)}k(e,null,i,r);return new f(r)}function O(t,e){let i=e.depth-t.openStart,r=e.node(i);let n=r.copy(t.content);for(let t=i-1;t>=0;t--)n=e.node(t).copy(f.from(n));return{start:n.resolveNoCache(t.openStart+i),end:n.resolveNoCache(n.content.size-t.openEnd-i)}}class E{constructor(t,e,i){this.pos=t;this.path=e;this.parentOffset=i;this.depth=e.length/3-1}resolveDepth(t){if(t==null)return this.depth;if(t<0)return this.depth+t;return t}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(t){return this.path[this.resolveDepth(t)*3]}index(t){return this.path[this.resolveDepth(t)*3+1]}indexAfter(t){t=this.resolveDepth(t);return this.index(t)+(t==this.depth&&!this.textOffset?0:1)}start(t){t=this.resolveDepth(t);return t==0?0:this.path[t*3-1]+1}end(t){t=this.resolveDepth(t);return this.start(t)+this.node(t).content.size}before(t){t=this.resolveDepth(t);if(!t)throw new RangeError("There is no position before the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]}after(t){t=this.resolveDepth(t);if(!t)throw new RangeError("There is no position after the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]+this.path[t*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let t=this.parent,e=this.index(this.depth);if(e==t.childCount)return null;let i=this.pos-this.path[this.path.length-1],r=t.child(e);return i?t.child(e).cut(i):r}get nodeBefore(){let t=this.index(this.depth);let e=this.pos-this.path[this.path.length-1];if(e)return this.parent.child(t).cut(0,e);return t==0?null:this.parent.child(t-1)}posAtIndex(t,e){e=this.resolveDepth(e);let i=this.path[e*3],r=e==0?0:this.path[e*3-1]+1;for(let e=0;e<t;e++)r+=i.child(e).nodeSize;return r}marks(){let t=this.parent,e=this.index();if(t.content.size==0)return a.none;if(this.textOffset)return t.child(e).marks;let i=t.maybeChild(e-1),r=t.maybeChild(e);if(!i){let t=i;i=r;r=t}let n=i.marks;for(var s=0;s<n.length;s++)if(n[s].type.spec.inclusive===false&&(!r||!n[s].isInSet(r.marks)))n=n[s--].removeFromSet(n);return n}marksAcross(t){let e=this.parent.maybeChild(this.index());if(!e||!e.isInline)return null;let i=e.marks,r=t.parent.maybeChild(t.index());for(var n=0;n<i.length;n++)if(i[n].type.spec.inclusive===false&&(!r||!i[n].isInSet(r.marks)))i=i[n--].removeFromSet(i);return i}sharedDepth(t){for(let e=this.depth;e>0;e--)if(this.start(e)<=t&&this.end(e)>=t)return e;return 0}blockRange(t=this,e){if(t.pos<this.pos)return t.blockRange(this);for(let i=this.depth-(this.parent.inlineContent||this.pos==t.pos?1:0);i>=0;i--)if(t.pos<=this.end(i)&&(!e||e(this.node(i))))return new R(this,t,i);return null}sameParent(t){return this.pos-this.parentOffset==t.pos-t.parentOffset}max(t){return t.pos>this.pos?t:this}min(t){return t.pos<this.pos?t:this}toString(){let t="";for(let e=1;e<=this.depth;e++)t+=(t?"/":"")+this.node(e).type.name+"_"+this.index(e-1);return t+":"+this.parentOffset}static resolve(t,e){if(!(e>=0&&e<=t.content.size))throw new RangeError("Position "+e+" out of range");let i=[];let r=0,n=e;for(let e=t;;){let{index:t,offset:s}=e.content.findIndex(n);let l=n-s;i.push(e,t,r+s);if(!l)break;e=e.child(t);if(e.isText)break;n=l-1;r+=s+1}return new E(e,i,n)}static resolveCached(t,e){for(let i=0;i<D.length;i++){let r=D[i];if(r.pos==e&&r.doc==t)return r}let i=D[N]=E.resolve(t,e);N=(N+1)%$;return i}}let D=[],N=0,$=12;class R{constructor(t,e,i){this.$from=t;this.$to=e;this.depth=i}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)}}const q=Object.create(null);class C{constructor(t,e,i,r=a.none){this.type=t;this.attrs=e;this.marks=r;this.content=i||f.empty}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(t){return this.content.child(t)}maybeChild(t){return this.content.maybeChild(t)}forEach(t){this.content.forEach(t)}nodesBetween(t,e,i,r=0){this.content.nodesBetween(t,e,i,r,this)}descendants(t){this.nodesBetween(0,this.content.size,t)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(t,e,i,r){return this.content.textBetween(t,e,i,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(t){return this==t||this.sameMarkup(t)&&this.content.eq(t.content)}sameMarkup(t){return this.hasMarkup(t.type,t.attrs,t.marks)}hasMarkup(t,e,i){return this.type==t&&h(this.attrs,e||t.defaultAttrs||q)&&a.sameSet(this.marks,i||a.none)}copy(t=null){if(t==this.content)return this;return new C(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new C(this.type,this.attrs,this.content,t)}cut(t,e=this.content.size){if(t==0&&e==this.content.size)return this;return this.copy(this.content.cut(t,e))}slice(t,e=this.content.size,i=false){if(t==e)return d.empty;let r=this.resolve(t),n=this.resolve(e);let s=i?0:r.sharedDepth(e);let l=r.start(s),f=r.node(s);let o=f.content.cut(r.pos-l,n.pos-l);return new d(o,r.depth-s,n.depth-s)}replace(t,e,i){return w(this.resolve(t),this.resolve(e),i)}nodeAt(t){for(let e=this;;){let{index:i,offset:r}=e.content.findIndex(t);e=e.maybeChild(i);if(!e)return null;if(r==t||e.isText)return e;t-=r+1}}childAfter(t){let{index:e,offset:i}=this.content.findIndex(t);return{node:this.content.maybeChild(e),index:e,offset:i}}childBefore(t){if(t==0)return{node:null,index:0,offset:0};let{index:e,offset:i}=this.content.findIndex(t);if(i<t)return{node:this.content.child(e),index:e,offset:i};let r=this.content.child(e-1);return{node:r,index:e-1,offset:i-r.nodeSize}}resolve(t){return E.resolveCached(this,t)}resolveNoCache(t){return E.resolve(this,t)}rangeHasMark(t,e,i){let r=false;if(e>t)this.nodesBetween(t,e,(t=>{if(i.isInSet(t.marks))r=true;return!r}));return 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 t=this.type.name;if(this.content.size)t+="("+this.content.toStringInner()+")";return A(this.marks,t)}contentMatchAt(t){let e=this.type.contentMatch.matchFragment(this.content,0,t);if(!e)throw new Error("Called contentMatchAt on a node with invalid content");return e}canReplace(t,e,i=f.empty,r=0,n=i.childCount){let s=this.contentMatchAt(t).matchFragment(i,r,n);let l=s&&s.matchFragment(this.content,e);if(!l||!l.validEnd)return false;for(let t=r;t<n;t++)if(!this.type.allowsMarks(i.child(t).marks))return false;return true}canReplaceWith(t,e,i,r){if(r&&!this.type.allowsMarks(r))return false;let n=this.contentMatchAt(t).matchType(i);let s=n&&n.matchFragment(this.content,e);return s?s.validEnd:false}canAppend(t){if(t.content.size)return this.canReplace(this.childCount,this.childCount,t.content);else return this.type.compatibleContent(t.type)}check(){this.type.checkContent(this.content);let t=a.none;for(let e=0;e<this.marks.length;e++)t=this.marks[e].addToSet(t);if(!a.sameSet(t,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map((t=>t.type.name))}`);this.content.forEach((t=>t.check()))}toJSON(){let t={type:this.type.name};for(let e in this.attrs){t.attrs=this.attrs;break}if(this.content.size)t.content=this.content.toJSON();if(this.marks.length)t.marks=this.marks.map((t=>t.toJSON()));return t}static fromJSON(t,e){if(!e)throw new RangeError("Invalid input for Node.fromJSON");let i=null;if(e.marks){if(!Array.isArray(e.marks))throw new RangeError("Invalid mark data for Node.fromJSON");i=e.marks.map(t.markFromJSON)}if(e.type=="text"){if(typeof e.text!="string")throw new RangeError("Invalid text node in JSON");return t.text(e.text,i)}let r=f.fromJSON(t,e.content);return t.nodeType(e.type).create(e.attrs,r,i)}}C.prototype.text=undefined;class T extends C{constructor(t,e,i,r){super(t,e,null,r);if(!i)throw new RangeError("Empty text nodes are not allowed");this.text=i}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);return A(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(t,e){return this.text.slice(t,e)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new T(this.type,this.attrs,this.text,t)}withText(t){if(t==this.text)return this;return new T(this.type,this.attrs,t,this.marks)}cut(t=0,e=this.text.length){if(t==0&&e==this.text.length)return this;return this.withText(this.text.slice(t,e))}eq(t){return this.sameMarkup(t)&&this.text==t.text}toJSON(){let t=super.toJSON();t.text=this.text;return t}}function A(t,e){for(let i=t.length-1;i>=0;i--)e=t[i].type.name+"("+e+")";return e}class I{constructor(t){this.validEnd=t;this.next=[];this.wrapCache=[]}static parse(t,e){let i=new P(t,e);if(i.next==null)return I.empty;let r=z(i);if(i.next)i.err("Unexpected trailing text");let n=H(_(r));G(n,i);return n}matchType(t){for(let e=0;e<this.next.length;e++)if(this.next[e].type==t)return this.next[e].next;return null}matchFragment(t,e=0,i=t.childCount){let r=this;for(let n=e;r&&n<i;n++)r=r.matchType(t.child(n).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let t=0;t<this.next.length;t++){let{type:e}=this.next[t];if(!(e.isText||e.hasRequiredAttrs()))return e}return null}compatible(t){for(let e=0;e<this.next.length;e++)for(let i=0;i<t.next.length;i++)if(this.next[e].type==t.next[i].type)return true;return false}fillBefore(t,e=false,i=0){let r=[this];function n(s,l){let o=s.matchFragment(t,i);if(o&&(!e||o.validEnd))return f.from(l.map((t=>t.createAndFill())));for(let t=0;t<s.next.length;t++){let{type:e,next:i}=s.next[t];if(!(e.isText||e.hasRequiredAttrs())&&r.indexOf(i)==-1){r.push(i);let t=n(i,l.concat(e));if(t)return t}}return null}return n(this,[])}findWrapping(t){for(let e=0;e<this.wrapCache.length;e+=2)if(this.wrapCache[e]==t)return this.wrapCache[e+1];let e=this.computeWrapping(t);this.wrapCache.push(t,e);return e}computeWrapping(t){let e=Object.create(null),i=[{match:this,type:null,via:null}];while(i.length){let r=i.shift(),n=r.match;if(n.matchType(t)){let t=[];for(let e=r;e.type;e=e.via)t.push(e.type);return t.reverse()}for(let t=0;t<n.next.length;t++){let{type:s,next:l}=n.next[t];if(!s.isLeaf&&!s.hasRequiredAttrs()&&!(s.name in e)&&(!r.type||l.validEnd)){i.push({match:s.contentMatch,type:s,via:r});e[s.name]=true}}}return null}get edgeCount(){return this.next.length}edge(t){if(t>=this.next.length)throw new RangeError(`There's no ${t}th edge in this content match`);return this.next[t]}toString(){let t=[];function e(i){t.push(i);for(let r=0;r<i.next.length;r++)if(t.indexOf(i.next[r].next)==-1)e(i.next[r].next)}e(this);return t.map(((e,i)=>{let r=i+(e.validEnd?"*":" ")+" ";for(let i=0;i<e.next.length;i++)r+=(i?", ":"")+e.next[i].type.name+"->"+t.indexOf(e.next[i].next);return r})).join("\n")}}I.empty=new I(true);class P{constructor(t,e){this.string=t;this.nodeTypes=e;this.inline=null;this.pos=0;this.tokens=t.split(/\s*(?=\b|\W|$)/);if(this.tokens[this.tokens.length-1]=="")this.tokens.pop();if(this.tokens[0]=="")this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(t){return this.next==t&&(this.pos++||true)}err(t){throw new SyntaxError(t+" (in content expression '"+this.string+"')")}}function z(t){let e=[];do{e.push(J(t))}while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function J(t){let e=[];do{e.push(B(t))}while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function B(t){let e=W(t);for(;;){if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=F(t,e);else break}return e}function j(t){if(/\D/.test(t.next))t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);t.pos++;return e}function F(t,e){let i=j(t),r=i;if(t.eat(",")){if(t.next!="}")r=j(t);else r=-1}if(!t.eat("}"))t.err("Unclosed braced range");return{type:"range",min:i,max:r,expr:e}}function L(t,e){let i=t.nodeTypes,r=i[e];if(r)return[r];let n=[];for(let t in i){let r=i[t];if(r.groups.indexOf(e)>-1)n.push(r)}if(n.length==0)t.err("No node type or group '"+e+"' found");return n}function W(t){if(t.eat("(")){let e=z(t);if(!t.eat(")"))t.err("Missing closing paren");return e}else if(!/\W/.test(t.next)){let e=L(t,t.next).map((e=>{if(t.inline==null)t.inline=e.isInline;else if(t.inline!=e.isInline)t.err("Mixing inline and block content");return{type:"name",value:e}}));t.pos++;return e.length==1?e[0]:{type:"choice",exprs:e}}else{t.err("Unexpected token '"+t.next+"'")}}function _(t){let e=[[]];n(s(t,0),i());return e;function i(){return e.push([])-1}function r(t,i,r){let n={term:r,to:i};e[t].push(n);return n}function n(t,e){t.forEach((t=>t.to=e))}function s(t,e){if(t.type=="choice"){return t.exprs.reduce(((t,i)=>t.concat(s(i,e))),[])}else if(t.type=="seq"){for(let r=0;;r++){let l=s(t.exprs[r],e);if(r==t.exprs.length-1)return l;n(l,e=i())}}else if(t.type=="star"){let l=i();r(e,l);n(s(t.expr,l),l);return[r(l)]}else if(t.type=="plus"){let l=i();n(s(t.expr,e),l);n(s(t.expr,l),l);return[r(l)]}else if(t.type=="opt"){return[r(e)].concat(s(t.expr,e))}else if(t.type=="range"){let l=e;for(let e=0;e<t.min;e++){let e=i();n(s(t.expr,l),e);l=e}if(t.max==-1){n(s(t.expr,l),l)}else{for(let e=t.min;e<t.max;e++){let e=i();r(l,e);n(s(t.expr,l),e);l=e}}return[r(l)]}else if(t.type=="name"){return[r(e,undefined,t.value)]}else{throw new Error("Unknown expr type")}}}function U(t,e){return e-t}function K(t,e){let i=[];r(e);return i.sort(U);function r(e){let n=t[e];if(n.length==1&&!n[0].term)return r(n[0].to);i.push(e);for(let t=0;t<n.length;t++){let{term:e,to:s}=n[t];if(!e&&i.indexOf(s)==-1)r(s)}}}function H(t){let e=Object.create(null);return i(K(t,0));function i(r){let n=[];r.forEach((e=>{t[e].forEach((({term:e,to:i})=>{if(!e)return;let r;for(let t=0;t<n.length;t++)if(n[t][0]==e)r=n[t][1];K(t,i).forEach((t=>{if(!r)n.push([e,r=[]]);if(r.indexOf(t)==-1)r.push(t)}))}))}));let s=e[r.join(",")]=new I(r.indexOf(t.length-1)>-1);for(let t=0;t<n.length;t++){let r=n[t][1].sort(U);s.next.push({type:n[t][0],next:e[r.join(",")]||i(r)})}return s}}function G(t,e){for(let i=0,r=[t];i<r.length;i++){let t=r[i],n=!t.validEnd,s=[];for(let e=0;e<t.next.length;e++){let{type:i,next:l}=t.next[e];s.push(i.name);if(n&&!(i.isText||i.hasRequiredAttrs()))n=false;if(r.indexOf(l)==-1)r.push(l)}if(n)e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function V(t){let e=Object.create(null);for(let i in t){let r=t[i];if(!r.hasDefault)return null;e[i]=r.default}return e}function X(t,e){let i=Object.create(null);for(let r in t){let n=e&&e[r];if(n===undefined){let e=t[r];if(e.hasDefault)n=e.default;else throw new RangeError("No value supplied for attribute "+r)}i[r]=n}return i}function Y(t){let e=Object.create(null);if(t)for(let i in t)e[i]=new Z(t[i]);return e}class Q{constructor(t,e,i){this.name=t;this.schema=e;this.spec=i;this.markSet=null;this.groups=i.group?i.group.split(" "):[];this.attrs=Y(i.attrs);this.defaultAttrs=V(this.attrs);this.contentMatch=null;this.inlineContent=null;this.isBlock=!(i.inline||t=="text");this.isText=t=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==I.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let t in this.attrs)if(this.attrs[t].isRequired)return true;return false}compatibleContent(t){return this==t||this.contentMatch.compatible(t.contentMatch)}computeAttrs(t){if(!t&&this.defaultAttrs)return this.defaultAttrs;else return X(this.attrs,t)}create(t=null,e,i){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new C(this,this.computeAttrs(t),f.from(e),a.setFrom(i))}createChecked(t=null,e,i){e=f.from(e);this.checkContent(e);return new C(this,this.computeAttrs(t),e,a.setFrom(i))}createAndFill(t=null,e,i){t=this.computeAttrs(t);e=f.from(e);if(e.size){let t=this.contentMatch.fillBefore(e);if(!t)return null;e=t.append(e)}let r=this.contentMatch.matchFragment(e);let n=r&&r.fillBefore(f.empty,true);if(!n)return null;return new C(this,t,e.append(n),a.setFrom(i))}validContent(t){let e=this.contentMatch.matchFragment(t);if(!e||!e.validEnd)return false;for(let e=0;e<t.childCount;e++)if(!this.allowsMarks(t.child(e).marks))return false;return true}checkContent(t){if(!this.validContent(t))throw new RangeError(`Invalid content for node ${this.name}: ${t.toString().slice(0,50)}`)}allowsMarkType(t){return this.markSet==null||this.markSet.indexOf(t)>-1}allowsMarks(t){if(this.markSet==null)return true;for(let e=0;e<t.length;e++)if(!this.allowsMarkType(t[e].type))return false;return true}allowedMarks(t){if(this.markSet==null)return t;let e;for(let i=0;i<t.length;i++){if(!this.allowsMarkType(t[i].type)){if(!e)e=t.slice(0,i)}else if(e){e.push(t[i])}}return!e?t:e.length?e:a.none}static compile(t,e){let i=Object.create(null);t.forEach(((t,r)=>i[t]=new Q(t,e,r)));let r=e.spec.topNode||"doc";if(!i[r])throw new RangeError("Schema is missing its top node type ('"+r+"')");if(!i.text)throw new RangeError("Every schema needs a 'text' type");for(let t in i.text.attrs)throw new RangeError("The text node type should not have attributes");return i}}class Z{constructor(t){this.hasDefault=Object.prototype.hasOwnProperty.call(t,"default");this.default=t.default}get isRequired(){return!this.hasDefault}}class tt{constructor(t,e,i,r){this.name=t;this.rank=e;this.schema=i;this.spec=r;this.attrs=Y(r.attrs);this.excluded=null;let n=V(this.attrs);this.instance=n?new a(this,n):null}create(t=null){if(!t&&this.instance)return this.instance;return new a(this,X(this.attrs,t))}static compile(t,e){let i=Object.create(null),r=0;t.forEach(((t,n)=>i[t]=new tt(t,r++,e,n)));return i}removeFromSet(t){for(var e=0;e<t.length;e++)if(t[e].type==this){t=t.slice(0,e).concat(t.slice(e+1));e--}return t}isInSet(t){for(let e=0;e<t.length;e++)if(t[e].type==this)return t[e]}excludes(t){return this.excluded.indexOf(t)>-1}}class et{constructor(t){this.cached=Object.create(null);let e=this.spec={};for(let i in t)e[i]=t[i];e.nodes=n.from(t.nodes),e.marks=n.from(t.marks||{}),this.nodes=Q.compile(this.spec.nodes,this);this.marks=tt.compile(this.spec.marks,this);let i=Object.create(null);for(let t in this.nodes){if(t in this.marks)throw new RangeError(t+" can not be both a node and a mark");let e=this.nodes[t],r=e.spec.content||"",n=e.spec.marks;e.contentMatch=i[r]||(i[r]=I.parse(r,this.nodes));e.inlineContent=e.contentMatch.inlineContent;e.markSet=n=="_"?null:n?it(this,n.split(" ")):n==""||!e.inlineContent?[]:null}for(let t in this.marks){let e=this.marks[t],i=e.spec.excludes;e.excluded=i==null?[e]:i==""?[]:it(this,i.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this);this.markFromJSON=this.markFromJSON.bind(this);this.topNodeType=this.nodes[this.spec.topNode||"doc"];this.cached.wrappings=Object.create(null)}node(t,e=null,i,r){if(typeof t=="string")t=this.nodeType(t);else if(!(t instanceof Q))throw new RangeError("Invalid node type: "+t);else if(t.schema!=this)throw new RangeError("Node type from different schema used ("+t.name+")");return t.createChecked(e,i,r)}text(t,e){let i=this.nodes.text;return new T(i,i.defaultAttrs,t,a.setFrom(e))}mark(t,e){if(typeof t=="string")t=this.marks[t];return t.create(e)}nodeFromJSON(t){return C.fromJSON(this,t)}markFromJSON(t){return a.fromJSON(this,t)}nodeType(t){let e=this.nodes[t];if(!e)throw new RangeError("Unknown node type: "+t);return e}}function it(t,e){let i=[];for(let r=0;r<e.length;r++){let n=e[r],s=t.marks[n],l=s;if(s){i.push(s)}else{for(let e in t.marks){let r=t.marks[e];if(n=="_"||r.spec.group&&r.spec.group.split(" ").indexOf(n)>-1)i.push(l=r)}}if(!l)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return i}class rt{constructor(t,e){this.schema=t;this.rules=e;this.tags=[];this.styles=[];e.forEach((t=>{if(t.tag)this.tags.push(t);else if(t.style)this.styles.push(t)}));this.normalizeLists=!this.tags.some((e=>{if(!/^(ul|ol)\b/.test(e.tag)||!e.node)return false;let i=t.nodes[e.node];return i.contentMatch.matchType(i)}))}parse(t,e={}){let i=new ct(this,e,false);i.addAll(t,e.from,e.to);return i.finish()}parseSlice(t,e={}){let i=new ct(this,e,true);i.addAll(t,e.from,e.to);return d.maxOpen(i.finish())}matchTag(t,e,i){for(let r=i?this.tags.indexOf(i)+1:0;r<this.tags.length;r++){let i=this.tags[r];if(pt(t,i.tag)&&(i.namespace===undefined||t.namespaceURI==i.namespace)&&(!i.context||e.matchesContext(i.context))){if(i.getAttrs){let e=i.getAttrs(t);if(e===false)continue;i.attrs=e||undefined}return i}}}matchStyle(t,e,i,r){for(let n=r?this.styles.indexOf(r)+1:0;n<this.styles.length;n++){let r=this.styles[n],s=r.style;if(s.indexOf(t)!=0||r.context&&!i.matchesContext(r.context)||s.length>t.length&&(s.charCodeAt(t.length)!=61||s.slice(t.length+1)!=e))continue;if(r.getAttrs){let t=r.getAttrs(e);if(t===false)continue;r.attrs=t||undefined}return r}}static schemaRules(t){let e=[];function i(t){let i=t.priority==null?50:t.priority,r=0;for(;r<e.length;r++){let t=e[r],n=t.priority==null?50:t.priority;if(n<i)break}e.splice(r,0,t)}for(let e in t.marks){let r=t.marks[e].spec.parseDOM;if(r)r.forEach((t=>{i(t=wt(t));if(!(t.mark||t.ignore||t.clearMark))t.mark=e}))}for(let e in t.nodes){let r=t.nodes[e].spec.parseDOM;if(r)r.forEach((t=>{i(t=wt(t));if(!(t.node||t.ignore||t.mark))t.node=e}))}return e}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new rt(t,rt.schemaRules(t)))}}const nt={address:true,article:true,aside:true,blockquote:true,canvas:true,dd:true,div:true,dl:true,fieldset:true,figcaption:true,figure:true,footer:true,form:true,h1:true,h2:true,h3:true,h4:true,h5:true,h6:true,header:true,hgroup:true,hr:true,li:true,noscript:true,ol:true,output:true,p:true,pre:true,section:true,table:true,tfoot:true,ul:true};const st={head:true,noscript:true,object:true,script:true,style:true,title:true};const lt={ol:true,ul:true};const ft=1,ot=2,ut=4;function ht(t,e,i){if(e!=null)return(e?ft:0)|(e==="full"?ot:0);return t&&t.whitespace=="pre"?ft|ot:i&~ut}class at{constructor(t,e,i,r,n,s,l){this.type=t;this.attrs=e;this.marks=i;this.pendingMarks=r;this.solid=n;this.options=l;this.content=[];this.activeMarks=a.none;this.stashMarks=[];this.match=s||(l&ut?null:t.contentMatch)}findWrapping(t){if(!this.match){if(!this.type)return[];let e=this.type.contentMatch.fillBefore(f.from(t));if(e){this.match=this.type.contentMatch.matchFragment(e)}else{let e=this.type.contentMatch,i;if(i=e.findWrapping(t.type)){this.match=e;return i}else{return null}}}return this.match.findWrapping(t.type)}finish(t){if(!(this.options&ft)){let t=this.content[this.content.length-1],e;if(t&&t.isText&&(e=/[ \t\r\n\u000c]+$/.exec(t.text))){let i=t;if(t.text.length==e[0].length)this.content.pop();else this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-e[0].length))}}let e=f.from(this.content);if(!t&&this.match)e=e.append(this.match.fillBefore(f.empty,true));return this.type?this.type.create(this.attrs,e,this.marks):e}popFromStashMark(t){for(let e=this.stashMarks.length-1;e>=0;e--)if(t.eq(this.stashMarks[e]))return this.stashMarks.splice(e,1)[0]}applyPending(t){for(let e=0,i=this.pendingMarks;e<i.length;e++){let r=i[e];if((this.type?this.type.allowsMarkType(r.type):gt(r.type,t))&&!r.isInSet(this.activeMarks)){this.activeMarks=r.addToSet(this.activeMarks);this.pendingMarks=r.removeFromSet(this.pendingMarks)}}}inlineContext(t){if(this.type)return this.type.inlineContent;if(this.content.length)return this.content[0].isInline;return t.parentNode&&!nt.hasOwnProperty(t.parentNode.nodeName.toLowerCase())}}class ct{constructor(t,e,i){this.parser=t;this.options=e;this.isOpen=i;this.open=0;let r=e.topNode,n;let s=ht(null,e.preserveWhitespace,0)|(i?ut:0);if(r)n=new at(r.type,r.attrs,a.none,a.none,true,e.topMatch||r.type.contentMatch,s);else if(i)n=new at(null,null,a.none,a.none,true,null,s);else n=new at(t.schema.topNodeType,null,a.none,a.none,true,null,s);this.nodes=[n];this.find=e.findPositions;this.needsBlock=false}get top(){return this.nodes[this.open]}addDOM(t){if(t.nodeType==3)this.addTextNode(t);else if(t.nodeType==1)this.addElement(t)}withStyleRules(t,e){let i=t.getAttribute("style");if(!i)return e();let r=this.readStyles(mt(i));if(!r)return;let[n,s]=r,l=this.top;for(let t=0;t<s.length;t++)this.removePendingMark(s[t],l);for(let t=0;t<n.length;t++)this.addPendingMark(n[t]);e();for(let t=0;t<n.length;t++)this.removePendingMark(n[t],l);for(let t=0;t<s.length;t++)this.addPendingMark(s[t])}addTextNode(t){let e=t.nodeValue;let i=this.top;if(i.options&ot||i.inlineContext(t)||/[^ \t\r\n\u000c]/.test(e)){if(!(i.options&ft)){e=e.replace(/[ \t\r\n\u000c]+/g," ");if(/^[ \t\r\n\u000c]/.test(e)&&this.open==this.nodes.length-1){let r=i.content[i.content.length-1];let n=t.previousSibling;if(!r||n&&n.nodeName=="BR"||r.isText&&/[ \t\r\n\u000c]$/.test(r.text))e=e.slice(1)}}else if(!(i.options&ot)){e=e.replace(/\r?\n|\r/g," ")}else{e=e.replace(/\r\n?/g,"\n")}if(e)this.insertNode(this.parser.schema.text(e));this.findInText(t)}else{this.findInside(t)}}addElement(t,e){let i=t.nodeName.toLowerCase(),r;if(lt.hasOwnProperty(i)&&this.parser.normalizeLists)dt(t);let n=this.options.ruleFromNode&&this.options.ruleFromNode(t)||(r=this.parser.matchTag(t,this,e));if(n?n.ignore:st.hasOwnProperty(i)){this.findInside(t);this.ignoreFallback(t)}else if(!n||n.skip||n.closeParent){if(n&&n.closeParent)this.open=Math.max(0,this.open-1);else if(n&&n.skip.nodeType)t=n.skip;let e,r=this.top,s=this.needsBlock;if(nt.hasOwnProperty(i)){if(r.content.length&&r.content[0].isInline&&this.open){this.open--;r=this.top}e=true;if(!r.type)this.needsBlock=true}else if(!t.firstChild){this.leafFallback(t);return}if(n&&n.skip)this.addAll(t);else this.withStyleRules(t,(()=>this.addAll(t)));if(e)this.sync(r);this.needsBlock=s}else{this.withStyleRules(t,(()=>{this.addElementByRule(t,n,n.consuming===false?r:undefined)}))}}leafFallback(t){if(t.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent)this.addTextNode(t.ownerDocument.createTextNode("\n"))}ignoreFallback(t){if(t.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent))this.findPlace(this.parser.schema.text("-"))}readStyles(t){let e=a.none,i=a.none;for(let r=0;r<t.length;r+=2){for(let n=undefined;;){let s=this.parser.matchStyle(t[r],t[r+1],this,n);if(!s)break;if(s.ignore)return null;if(s.clearMark){this.top.pendingMarks.concat(this.top.activeMarks).forEach((t=>{if(s.clearMark(t))i=t.addToSet(i)}))}else{e=this.parser.schema.marks[s.mark].create(s.attrs).addToSet(e)}if(s.consuming===false)n=s;else break}}return[e,i]}addElementByRule(t,e,i){let r,n,s;if(e.node){n=this.parser.schema.nodes[e.node];if(!n.isLeaf){r=this.enter(n,e.attrs||null,e.preserveWhitespace)}else if(!this.insertNode(n.create(e.attrs))){this.leafFallback(t)}}else{let t=this.parser.schema.marks[e.mark];s=t.create(e.attrs);this.addPendingMark(s)}let l=this.top;if(n&&n.isLeaf){this.findInside(t)}else if(i){this.addElement(t,i)}else if(e.getContent){this.findInside(t);e.getContent(t,this.parser.schema).forEach((t=>this.insertNode(t)))}else{let i=t;if(typeof e.contentElement=="string")i=t.querySelector(e.contentElement);else if(typeof e.contentElement=="function")i=e.contentElement(t);else if(e.contentElement)i=e.contentElement;this.findAround(t,i,true);this.addAll(i)}if(r&&this.sync(l))this.open--;if(s)this.removePendingMark(s,l)}addAll(t,e,i){let r=e||0;for(let n=e?t.childNodes[e]:t.firstChild,s=i==null?null:t.childNodes[i];n!=s;n=n.nextSibling,++r){this.findAtPoint(t,r);this.addDOM(n)}this.findAtPoint(t,r)}findPlace(t){let e,i;for(let r=this.open;r>=0;r--){let n=this.nodes[r];let s=n.findWrapping(t);if(s&&(!e||e.length>s.length)){e=s;i=n;if(!s.length)break}if(n.solid)break}if(!e)return false;this.sync(i);for(let t=0;t<e.length;t++)this.enterInner(e[t],null,false);return true}insertNode(t){if(t.isInline&&this.needsBlock&&!this.top.type){let t=this.textblockFromContext();if(t)this.enterInner(t)}if(this.findPlace(t)){this.closeExtra();let e=this.top;e.applyPending(t.type);if(e.match)e.match=e.match.matchType(t.type);let i=e.activeMarks;for(let r=0;r<t.marks.length;r++)if(!e.type||e.type.allowsMarkType(t.marks[r].type))i=t.marks[r].addToSet(i);e.content.push(t.mark(i));return true}return false}enter(t,e,i){let r=this.findPlace(t.create(e));if(r)this.enterInner(t,e,true,i);return r}enterInner(t,e=null,i=false,r){this.closeExtra();let n=this.top;n.applyPending(t);n.match=n.match&&n.match.matchType(t);let s=ht(t,r,n.options);if(n.options&ut&&n.content.length==0)s|=ut;this.nodes.push(new at(t,e,n.activeMarks,n.pendingMarks,i,null,s));this.open++}closeExtra(t=false){let e=this.nodes.length-1;if(e>this.open){for(;e>this.open;e--)this.nodes[e-1].content.push(this.nodes[e].finish(t));this.nodes.length=this.open+1}}finish(){this.open=0;this.closeExtra(this.isOpen);return this.nodes[0].finish(this.isOpen||this.options.topOpen)}sync(t){for(let e=this.open;e>=0;e--)if(this.nodes[e]==t){this.open=e;return true}return false}get currentPos(){this.closeExtra();let t=0;for(let e=this.open;e>=0;e--){let i=this.nodes[e].content;for(let e=i.length-1;e>=0;e--)t+=i[e].nodeSize;if(e)t++}return t}findAtPoint(t,e){if(this.find)for(let i=0;i<this.find.length;i++){if(this.find[i].node==t&&this.find[i].offset==e)this.find[i].pos=this.currentPos}}findInside(t){if(this.find)for(let e=0;e<this.find.length;e++){if(this.find[e].pos==null&&t.nodeType==1&&t.contains(this.find[e].node))this.find[e].pos=this.currentPos}}findAround(t,e,i){if(t!=e&&this.find)for(let r=0;r<this.find.length;r++){if(this.find[r].pos==null&&t.nodeType==1&&t.contains(this.find[r].node)){let t=e.compareDocumentPosition(this.find[r].node);if(t&(i?2:4))this.find[r].pos=this.currentPos}}}findInText(t){if(this.find)for(let e=0;e<this.find.length;e++){if(this.find[e].node==t)this.find[e].pos=this.currentPos-(t.nodeValue.length-this.find[e].offset)}}matchesContext(t){if(t.indexOf("|")>-1)return t.split(/\s*\|\s*/).some(this.matchesContext,this);let e=t.split("/");let i=this.options.context;let r=!this.isOpen&&(!i||i.parent.type==this.nodes[0].type);let n=-(i?i.depth+1:0)+(r?0:1);let s=(t,l)=>{for(;t>=0;t--){let f=e[t];if(f==""){if(t==e.length-1||t==0)continue;for(;l>=n;l--)if(s(t-1,l))return true;return false}else{let t=l>0||l==0&&r?this.nodes[l].type:i&&l>=n?i.node(l-n).type:null;if(!t||t.name!=f&&t.groups.indexOf(f)==-1)return false;l--}}return true};return s(e.length-1,this.open)}textblockFromContext(){let t=this.options.context;if(t)for(let e=t.depth;e>=0;e--){let i=t.node(e).contentMatchAt(t.indexAfter(e)).defaultType;if(i&&i.isTextblock&&i.defaultAttrs)return i}for(let t in this.parser.schema.nodes){let e=this.parser.schema.nodes[t];if(e.isTextblock&&e.defaultAttrs)return e}}addPendingMark(t){let e=bt(t,this.top.pendingMarks);if(e)this.top.stashMarks.push(e);this.top.pendingMarks=t.addToSet(this.top.pendingMarks)}removePendingMark(t,e){for(let i=this.open;i>=0;i--){let r=this.nodes[i];let n=r.pendingMarks.lastIndexOf(t);if(n>-1){r.pendingMarks=t.removeFromSet(r.pendingMarks)}else{r.activeMarks=t.removeFromSet(r.activeMarks);let e=r.popFromStashMark(t);if(e&&r.type&&r.type.allowsMarkType(e.type))r.activeMarks=e.addToSet(r.activeMarks)}if(r==e)break}}}function dt(t){for(let e=t.firstChild,i=null;e;e=e.nextSibling){let t=e.nodeType==1?e.nodeName.toLowerCase():null;if(t&<.hasOwnProperty(t)&&i){i.appendChild(e);e=i}else if(t=="li"){i=e}else if(t){i=null}}}function pt(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function mt(t){let e=/\s*([\w-]+)\s*:\s*([^;]+)/g,i,r=[];while(i=e.exec(t))r.push(i[1],i[2].trim());return r}function wt(t){let e={};for(let i in t)e[i]=t[i];return e}function gt(t,e){let i=e.schema.nodes;for(let r in i){let n=i[r];if(!n.allowsMarkType(t))continue;let s=[],l=t=>{s.push(t);for(let i=0;i<t.edgeCount;i++){let{type:r,next:n}=t.edge(i);if(r==e)return true;if(s.indexOf(n)<0&&l(n))return true}};if(l(n.contentMatch))return true}}function bt(t,e){for(let i=0;i<e.length;i++){if(t.eq(e[i]))return e[i]}}class vt{constructor(t,e){this.nodes=t;this.marks=e}serializeFragment(t,e={},i){if(!i)i=kt(e).createDocumentFragment();let r=i,n=[];t.forEach((t=>{if(n.length||t.marks.length){let i=0,s=0;while(i<n.length&&s<t.marks.length){let e=t.marks[s];if(!this.marks[e.type.name]){s++;continue}if(!e.eq(n[i][0])||e.type.spec.spanning===false)break;i++;s++}while(i<n.length)r=n.pop()[1];while(s<t.marks.length){let i=t.marks[s++];let l=this.serializeMark(i,t.isInline,e);if(l){n.push([i,r]);r.appendChild(l.dom);r=l.contentDOM||l.dom}}}r.appendChild(this.serializeNodeInner(t,e))}));return i}serializeNodeInner(t,e){let{dom:i,contentDOM:r}=vt.renderSpec(kt(e),this.nodes[t.type.name](t));if(r){if(t.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(t.content,e,r)}return i}serializeNode(t,e={}){let i=this.serializeNodeInner(t,e);for(let r=t.marks.length-1;r>=0;r--){let n=this.serializeMark(t.marks[r],t.isInline,e);if(n){(n.contentDOM||n.dom).appendChild(i);i=n.dom}}return i}serializeMark(t,e,i={}){let r=this.marks[t.type.name];return r&&vt.renderSpec(kt(i),r(t,e))}static renderSpec(t,e,i=null){if(typeof e=="string")return{dom:t.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let r=e[0],n=r.indexOf(" ");if(n>0){i=r.slice(0,n);r=r.slice(n+1)}let s;let l=i?t.createElementNS(i,r):t.createElement(r);let f=e[1],o=1;if(f&&typeof f=="object"&&f.nodeType==null&&!Array.isArray(f)){o=2;for(let t in f)if(f[t]!=null){let e=t.indexOf(" ");if(e>0)l.setAttributeNS(t.slice(0,e),t.slice(e+1),f[t]);else l.setAttribute(t,f[t])}}for(let r=o;r<e.length;r++){let n=e[r];if(n===0){if(r<e.length-1||r>o)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:e,contentDOM:r}=vt.renderSpec(t,n,i);l.appendChild(e);if(r){if(s)throw new RangeError("Multiple content holes");s=r}}}return{dom:l,contentDOM:s}}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new vt(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(t){let e=yt(t.nodes);if(!e.text)e.text=t=>t.text;return e}static marksFromSchema(t){return yt(t.marks)}}function yt(t){let e={};for(let i in t){let r=t[i].spec.toDOM;if(r)e[i]=r}return e}function kt(t){return t.document||window.document}const Mt=65535;const xt=Math.pow(2,16);function St(t,e){return t+e*xt}function Ot(t){return t&Mt}function Et(t){return(t-(t&Mt))/xt}const Dt=1,Nt=2,$t=4,Rt=8;class qt{constructor(t,e,i){this.pos=t;this.delInfo=e;this.recover=i}get deleted(){return(this.delInfo&Rt)>0}get deletedBefore(){return(this.delInfo&(Dt|$t))>0}get deletedAfter(){return(this.delInfo&(Nt|$t))>0}get deletedAcross(){return(this.delInfo&$t)>0}}class Ct{constructor(t,e=false){this.ranges=t;this.inverted=e;if(!t.length&&Ct.empty)return Ct.empty}recover(t){let e=0,i=Ot(t);if(!this.inverted)for(let t=0;t<i;t++)e+=this.ranges[t*3+2]-this.ranges[t*3+1];return this.ranges[i*3]+e+Et(t)}mapResult(t,e=1){return this._map(t,e,false)}map(t,e=1){return this._map(t,e,true)}_map(t,e,i){let r=0,n=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let f=this.ranges[l]-(this.inverted?r:0);if(f>t)break;let o=this.ranges[l+n],u=this.ranges[l+s],h=f+o;if(t<=h){let n=!o?e:t==f?-1:t==h?1:e;let s=f+r+(n<0?0:u);if(i)return s;let a=t==(e<0?f:h)?null:St(l/3,t-f);let c=t==f?Nt:t==h?Dt:$t;if(e<0?t!=f:t!=h)c|=Rt;return new qt(s,c,a)}r+=u-o}return i?t+r:new qt(t+r,0,null)}touches(t,e){let i=0,r=Ot(e);let n=this.inverted?2:1,s=this.inverted?1:2;for(let e=0;e<this.ranges.length;e+=3){let l=this.ranges[e]-(this.inverted?i:0);if(l>t)break;let f=this.ranges[e+n],o=l+f;if(t<=o&&e==r*3)return true;i+=this.ranges[e+s]-f}return false}forEach(t){let e=this.inverted?2:1,i=this.inverted?1:2;for(let r=0,n=0;r<this.ranges.length;r+=3){let s=this.ranges[r],l=s-(this.inverted?n:0),f=s+(this.inverted?0:n);let o=this.ranges[r+e],u=this.ranges[r+i];t(l,l+o,f,f+u);n+=u-o}}invert(){return new Ct(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(t){return t==0?Ct.empty:new Ct(t<0?[0,-t,0]:[0,0,t])}}Ct.empty=new Ct([]);class Tt{constructor(t=[],e,i=0,r=t.length){this.maps=t;this.mirror=e;this.from=i;this.to=r}slice(t=0,e=this.maps.length){return new Tt(this.maps,this.mirror,t,e)}copy(){return new Tt(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)}appendMap(t,e){this.to=this.maps.push(t);if(e!=null)this.setMirror(this.maps.length-1,e)}appendMapping(t){for(let e=0,i=this.maps.length;e<t.maps.length;e++){let r=t.getMirror(e);this.appendMap(t.maps[e],r!=null&&r<e?i+r:undefined)}}getMirror(t){if(this.mirror)for(let e=0;e<this.mirror.length;e++)if(this.mirror[e]==t)return this.mirror[e+(e%2?-1:1)]}setMirror(t,e){if(!this.mirror)this.mirror=[];this.mirror.push(t,e)}appendMappingInverted(t){for(let e=t.maps.length-1,i=this.maps.length+t.maps.length;e>=0;e--){let r=t.getMirror(e);this.appendMap(t.maps[e].invert(),r!=null&&r>e?i-r-1:undefined)}}invert(){let t=new Tt;t.appendMappingInverted(this);return t}map(t,e=1){if(this.mirror)return this._map(t,e,true);for(let i=this.from;i<this.to;i++)t=this.maps[i].map(t,e);return t}mapResult(t,e=1){return this._map(t,e,false)}_map(t,e,i){let r=0;for(let i=this.from;i<this.to;i++){let n=this.maps[i],s=n.mapResult(t,e);if(s.recover!=null){let e=this.getMirror(i);if(e!=null&&e>i&&e<this.to){i=e;t=this.maps[e].recover(s.recover);continue}}r|=s.delInfo;t=s.pos}return i?t:new qt(t,r,null)}}const At=Object.create(null);class It{getMap(){return Ct.empty}merge(t){return null}static fromJSON(t,e){if(!e||!e.stepType)throw new RangeError("Invalid input for Step.fromJSON");let i=At[e.stepType];if(!i)throw new RangeError(`No step type ${e.stepType} defined`);return i.fromJSON(t,e)}static jsonID(t,e){if(t in At)throw new RangeError("Duplicate use of step JSON ID "+t);At[t]=e;e.prototype.jsonID=t;return e}}class Pt{constructor(t,e){this.doc=t;this.failed=e}static ok(t){return new Pt(t,null)}static fail(t){return new Pt(null,t)}static fromReplace(t,e,i,r){try{return Pt.ok(t.replace(e,i,r))}catch(t){if(t instanceof c)return Pt.fail(t.message);throw t}}}function zt(t,e,i){let r=[];for(let n=0;n<t.childCount;n++){let s=t.child(n);if(s.content.size)s=s.copy(zt(s.content,e,s));if(s.isInline)s=e(s,i,n);r.push(s)}return f.fromArray(r)}class Jt extends It{constructor(t,e,i){super();this.from=t;this.to=e;this.mark=i}apply(t){let e=t.slice(this.from,this.to),i=t.resolve(this.from);let r=i.node(i.sharedDepth(this.to));let n=new d(zt(e.content,((t,e)=>{if(!t.isAtom||!e.type.allowsMarkType(this.mark.type))return t;return t.mark(this.mark.addToSet(t.marks))}),r),e.openStart,e.openEnd);return Pt.fromReplace(t,this.from,this.to,n)}invert(){return new Bt(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),i=t.mapResult(this.to,-1);if(e.deleted&&i.deleted||e.pos>=i.pos)return null;return new Jt(e.pos,i.pos,this.mark)}merge(t){if(t instanceof Jt&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from)return new Jt(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark);return null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,e){if(typeof e.from!="number"||typeof e.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Jt(e.from,e.to,t.markFromJSON(e.mark))}}It.jsonID("addMark",Jt);class Bt extends It{constructor(t,e,i){super();this.from=t;this.to=e;this.mark=i}apply(t){let e=t.slice(this.from,this.to);let i=new d(zt(e.content,(t=>t.mark(this.mark.removeFromSet(t.marks))),t),e.openStart,e.openEnd);return Pt.fromReplace(t,this.from,this.to,i)}invert(){return new Jt(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),i=t.mapResult(this.to,-1);if(e.deleted&&i.deleted||e.pos>=i.pos)return null;return new Bt(e.pos,i.pos,this.mark)}merge(t){if(t instanceof Bt&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from)return new Bt(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark);return null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,e){if(typeof e.from!="number"||typeof e.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Bt(e.from,e.to,t.markFromJSON(e.mark))}}It.jsonID("removeMark",Bt);class jt extends It{constructor(t,e){super();this.pos=t;this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return Pt.fail("No node at mark step's position");let i=e.type.create(e.attrs,null,this.mark.addToSet(e.marks));return Pt.fromReplace(t,this.pos,this.pos+1,new d(f.from(i),0,e.isLeaf?0:1))}invert(t){let e=t.nodeAt(this.pos);if(e){let t=this.mark.addToSet(e.marks);if(t.length==e.marks.length){for(let i=0;i<e.marks.length;i++)if(!e.marks[i].isInSet(t))return new jt(this.pos,e.marks[i]);return new jt(this.pos,this.mark)}}return new Ft(this.pos,this.mark)}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new jt(e.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,e){if(typeof e.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new jt(e.pos,t.markFromJSON(e.mark))}}It.jsonID("addNodeMark",jt);class Ft extends It{constructor(t,e){super();this.pos=t;this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return Pt.fail("No node at mark step's position");let i=e.type.create(e.attrs,null,this.mark.removeFromSet(e.marks));return Pt.fromReplace(t,this.pos,this.pos+1,new d(f.from(i),0,e.isLeaf?0:1))}invert(t){let e=t.nodeAt(this.pos);if(!e||!this.mark.isInSet(e.marks))return this;return new jt(this.pos,this.mark)}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new Ft(e.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,e){if(typeof e.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Ft(e.pos,t.markFromJSON(e.mark))}}It.jsonID("removeNodeMark",Ft);class Lt extends It{constructor(t,e,i,r=false){super();this.from=t;this.to=e;this.slice=i;this.structure=r}apply(t){if(this.structure&&_t(t,this.from,this.to))return Pt.fail("Structure replace would overwrite content");return Pt.fromReplace(t,this.from,this.to,this.slice)}getMap(){return new Ct([this.from,this.to-this.from,this.slice.size])}invert(t){return new Lt(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let e=t.mapResult(this.from,1),i=t.mapResult(this.to,-1);if(e.deletedAcross&&i.deletedAcross)return null;return new Lt(e.pos,Math.max(e.pos,i.pos),this.slice)}merge(t){if(!(t instanceof Lt)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let e=this.slice.size+t.slice.size==0?d.empty:new d(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new Lt(this.from,this.to+(t.to-t.from),e,this.structure)}else if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let e=this.slice.size+t.slice.size==0?d.empty:new d(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new Lt(t.from,this.to,e,this.structure)}else{return null}}toJSON(){let t={stepType:"replace",from:this.from,to:this.to};if(this.slice.size)t.slice=this.slice.toJSON();if(this.structure)t.structure=true;return t}static fromJSON(t,e){if(typeof e.from!="number"||typeof e.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Lt(e.from,e.to,d.fromJSON(t,e.slice),!!e.structure)}}It.jsonID("replace",Lt);class Wt extends It{constructor(t,e,i,r,n,s,l=false){super();this.from=t;this.to=e;this.gapFrom=i;this.gapTo=r;this.slice=n;this.insert=s;this.structure=l}apply(t){if(this.structure&&(_t(t,this.from,this.gapFrom)||_t(t,this.gapTo,this.to)))return Pt.fail("Structure gap-replace would overwrite content");let e=t.slice(this.gapFrom,this.gapTo);if(e.openStart||e.openEnd)return Pt.fail("Gap is not a flat range");let i=this.slice.insertAt(this.insert,e.content);if(!i)return Pt.fail("Content does not fit in gap");return Pt.fromReplace(t,this.from,this.to,i)}getMap(){return new Ct([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let e=this.gapTo-this.gapFrom;return new Wt(this.from,this.from+this.slice.size+e,this.from+this.insert,this.from+this.insert+e,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let e=t.mapResult(this.from,1),i=t.mapResult(this.to,-1);let r=t.map(this.gapFrom,-1),n=t.map(this.gapTo,1);if(e.deletedAcross&&i.deletedAcross||r<e.pos||n>i.pos)return null;return new Wt(e.pos,i.pos,r,n,this.slice,this.insert,this.structure)}toJSON(){let t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};if(this.slice.size)t.slice=this.slice.toJSON();if(this.structure)t.structure=true;return t}static fromJSON(t,e){if(typeof e.from!="number"||typeof e.to!="number"||typeof e.gapFrom!="number"||typeof e.gapTo!="number"||typeof e.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Wt(e.from,e.to,e.gapFrom,e.gapTo,d.fromJSON(t,e.slice),e.insert,!!e.structure)}}It.jsonID("replaceAround",Wt);function _t(t,e,i){let r=t.resolve(e),n=i-e,s=r.depth;while(n>0&&s>0&&r.indexAfter(s)==r.node(s).childCount){s--;n--}if(n>0){let t=r.node(s).maybeChild(r.indexAfter(s));while(n>0){if(!t||t.isLeaf)return true;t=t.firstChild;n--}}return false}function Ut(t,e,i,r){let n=[],s=[];let l,f;t.doc.nodesBetween(e,i,((t,o,u)=>{if(!t.isInline)return;let h=t.marks;if(!r.isInSet(h)&&u.type.allowsMarkType(r.type)){let u=Math.max(o,e),a=Math.min(o+t.nodeSize,i);let c=r.addToSet(h);for(let t=0;t<h.length;t++){if(!h[t].isInSet(c)){if(l&&l.to==u&&l.mark.eq(h[t]))l.to=a;else n.push(l=new Bt(u,a,h[t]))}}if(f&&f.to==u)f.to=a;else s.push(f=new Jt(u,a,r))}}));n.forEach((e=>t.step(e)));s.forEach((e=>t.step(e)))}function Kt(t,e,i,r){let n=[],s=0;t.doc.nodesBetween(e,i,((t,l)=>{if(!t.isInline)return;s++;let f=null;if(r instanceof tt){let e=t.marks,i;while(i=r.isInSet(e)){(f||(f=[])).push(i);e=i.removeFromSet(e)}}else if(r){if(r.isInSet(t.marks))f=[r]}else{f=t.marks}if(f&&f.length){let r=Math.min(l+t.nodeSize,i);for(let t=0;t<f.length;t++){let i=f[t],o;for(let t=0;t<n.length;t++){let e=n[t];if(e.step==s-1&&i.eq(n[t].style))o=e}if(o){o.to=r;o.step=s}else{n.push({style:i,from:Math.max(l,e),to:r,step:s})}}}}));n.forEach((e=>t.step(new Bt(e.from,e.to,e.style))))}function Ht(t,e,i,r=i.contentMatch){let n=t.doc.nodeAt(e);let s=[],l=e+1;for(let e=0;e<n.childCount;e++){let o=n.child(e),u=l+o.nodeSize;let h=r.matchType(o.type);if(!h){s.push(new Lt(l,u,d.empty))}else{r=h;for(let e=0;e<o.marks.length;e++)if(!i.allowsMarkType(o.marks[e].type))t.step(new Bt(l,u,o.marks[e]));if(o.isText&&!i.spec.code){let t,e=/\r?\n|\r/g,r;while(t=e.exec(o.text)){if(!r)r=new d(f.from(i.schema.text(" ",i.allowedMarks(o.marks))),0,0);s.push(new Lt(l+t.index,l+t.index+t[0].length,r))}}}l=u}if(!r.validEnd){let e=r.fillBefore(f.empty,true);t.replace(l,l,new d(e,0,0))}for(let e=s.length-1;e>=0;e--)t.step(s[e])}function Gt(t,e,i){return(e==0||t.canReplace(e,t.childCount))&&(i==t.childCount||t.canReplace(0,i))}function Vt(t){let e=t.parent;let i=e.content.cutByIndex(t.startIndex,t.endIndex);for(let e=t.depth;;--e){let r=t.$from.node(e);let n=t.$from.index(e),s=t.$to.indexAfter(e);if(e<t.depth&&r.canReplace(n,s,i))return e;if(e==0||r.type.spec.isolating||!Gt(r,n,s))break}return null}function Xt(t,e,i){let{$from:r,$to:n,depth:s}=e;let l=r.before(s+1),o=n.after(s+1);let u=l,h=o;let a=f.empty,c=0;for(let t=s,e=false;t>i;t--)if(e||r.index(t)>0){e=true;a=f.from(r.node(t).copy(a));c++}else{u--}let p=f.empty,m=0;for(let t=s,e=false;t>i;t--)if(e||n.after(t+1)<n.end(t)){e=true;p=f.from(n.node(t).copy(p));m++}else{h++}t.step(new Wt(u,h,l,o,new d(a.append(p),c,m),a.size-c,true))}function Yt(t,e,i=null,r=t){let n=Zt(t,e);let s=n&&te(r,e);if(!s)return null;return n.map(Qt).concat({type:e,attrs:i}).concat(s.map(Qt))}function Qt(t){return{type:t,attrs:null}}function Zt(t,e){let{parent:i,startIndex:r,endIndex:n}=t;let s=i.contentMatchAt(r).findWrapping(e);if(!s)return null;let l=s.length?s[0]:e;return i.canReplaceWith(r,n,l)?s:null}function te(t,e){let{parent:i,startIndex:r,endIndex:n}=t;let s=i.child(r);let l=e.contentMatch.findWrapping(s.type);if(!l)return null;let f=l.length?l[l.length-1]:e;let o=f.contentMatch;for(let t=r;o&&t<n;t++)o=o.matchType(i.child(t).type);if(!o||!o.validEnd)return null;return l}function ee(t,e,i){let r=f.empty;for(let t=i.length-1;t>=0;t--){if(r.size){let e=i[t].type.contentMatch.matchFragment(r);if(!e||!e.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=f.from(i[t].type.create(i[t].attrs,r))}let n=e.start,s=e.end;t.step(new Wt(n,s,n,s,new d(r,0,0),i.length,true))}function ie(t,e,i,r,n){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=t.steps.length;t.doc.nodesBetween(e,i,((e,i)=>{if(e.isTextblock&&!e.hasMarkup(r,n)&&re(t.doc,t.mapping.slice(s).map(i),r)){t.clearIncompatible(t.mapping.slice(s).map(i,1),r);let l=t.mapping.slice(s);let o=l.map(i,1),u=l.map(i+e.nodeSize,1);t.step(new Wt(o,u,o+1,u-1,new d(f.from(r.create(n,null,e.marks)),0,0),1,true));return false}}))}function re(t,e,i){let r=t.resolve(e),n=r.index();return r.parent.canReplaceWith(n,n+1,i)}function ne(t,e,i,r,n){let s=t.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");if(!i)i=s.type;let l=i.create(r,null,n||s.marks);if(s.isLeaf)return t.replaceWith(e,e+s.nodeSize,l);if(!i.validContent(s.content))throw new RangeError("Invalid content for node type "+i.name);t.step(new Wt(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new d(f.from(l),0,0),1,true))}function se(t,e,i=1,r){let n=t.resolve(e),s=n.depth-i;let l=r&&r[r.length-1]||n.parent;if(s<0||n.parent.type.spec.isolating||!n.parent.canReplace(n.index(),n.parent.childCount)||!l.type.validContent(n.parent.content.cutByIndex(n.index(),n.parent.childCount)))return false;for(let t=n.depth-1,e=i-2;t>s;t--,e--){let i=n.node(t),s=n.index(t);if(i.type.spec.isolating)return false;let l=i.content.cutByIndex(s,i.childCount);let f=r&&r[e+1];if(f)l=l.replaceChild(0,f.type.create(f.attrs));let o=r&&r[e]||i;if(!i.canReplace(s+1,i.childCount)||!o.type.validContent(l))return false}let f=n.indexAfter(s);let o=r&&r[0];return n.node(s).canReplaceWith(f,f,o?o.type:n.node(s+1).type)}function le(t,e,i=1,r){let n=t.doc.resolve(e),s=f.empty,l=f.empty;for(let t=n.depth,e=n.depth-i,o=i-1;t>e;t--,o--){s=f.from(n.node(t).copy(s));let e=r&&r[o];l=f.from(e?e.type.create(e.attrs,l):n.node(t).copy(l))}t.step(new Lt(e,e,new d(s.append(l),i,i),true))}function fe(t,e){let i=t.resolve(e),r=i.index();return oe(i.nodeBefore,i.nodeAfter)&&i.parent.canReplace(r,r+1)}function oe(t,e){return!!(t&&e&&!t.isLeaf&&t.canAppend(e))}function ue(t,e,i=-1){let r=t.resolve(e);for(let t=r.depth;;t--){let n,s,l=r.index(t);if(t==r.depth){n=r.nodeBefore;s=r.nodeAfter}else if(i>0){n=r.node(t+1);l++;s=r.node(t).maybeChild(l)}else{n=r.node(t).maybeChild(l-1);s=r.node(t+1)}if(n&&!n.isTextblock&&oe(n,s)&&r.node(t).canReplace(l,l+1))return e;if(t==0)break;e=i<0?r.before(t):r.after(t)}}function he(t,e,i){let r=new Lt(e-i,e+i,d.empty,true);t.step(r)}function ae(t,e,i){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),i))return e;if(r.parentOffset==0)for(let t=r.depth-1;t>=0;t--){let e=r.index(t);if(r.node(t).canReplaceWith(e,e,i))return r.before(t+1);if(e>0)return null}if(r.parentOffset==r.parent.content.size)for(let t=r.depth-1;t>=0;t--){let e=r.indexAfter(t);if(r.node(t).canReplaceWith(e,e,i))return r.after(t+1);if(e<r.node(t).childCount)return null}return null}function ce(t,e,i){let r=t.resolve(e);if(!i.content.size)return e;let n=i.content;for(let t=0;t<i.openStart;t++)n=n.firstChild.content;for(let t=1;t<=(i.openStart==0&&i.size?2:1);t++){for(let e=r.depth;e>=0;e--){let i=e==r.depth?0:r.pos<=(r.start(e+1)+r.end(e+1))/2?-1:1;let s=r.index(e)+(i>0?1:0);let l=r.node(e),f=false;if(t==1){f=l.canReplace(s,s,n)}else{let t=l.contentMatchAt(s).findWrapping(n.firstChild.type);f=t&&l.canReplaceWith(s,s,t[0])}if(f)return i==0?r.pos:i<0?r.before(e+1):r.after(e+1)}}return null}function de(t,e,i=e,r=d.empty){if(e==i&&!r.size)return null;let n=t.resolve(e),s=t.resolve(i);if(pe(n,s,r))return new Lt(e,i,r);return new me(n,s,r).fit()}function pe(t,e,i){return!i.openStart&&!i.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),i.content)}class me{constructor(t,e,i){this.$from=t;this.$to=e;this.unplaced=i;this.frontier=[];this.placed=f.empty;for(let e=0;e<=t.depth;e++){let i=t.node(e);this.frontier.push({type:i.type,match:i.contentMatchAt(t.indexAfter(e))})}for(let e=t.depth;e>0;e--)this.placed=f.from(t.node(e).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){while(this.unplaced.size){let t=this.findFittable();if(t)this.placeNodes(t);else this.openMore()||this.dropNode()}let t=this.mustMoveInline(),e=this.placed.size-this.depth-this.$from.depth;let i=this.$from,r=this.close(t<0?this.$to:i.doc.resolve(t));if(!r)return null;let n=this.placed,s=i.depth,l=r.depth;while(s&&l&&n.childCount==1){n=n.firstChild.content;s--;l--}let f=new d(n,s,l);if(t>-1)return new Wt(i.pos,t,this.$to.pos,this.$to.end(),f,e);if(f.size||i.pos!=this.$to.pos)return new Lt(i.pos,r.pos,f);return null}findFittable(){let t=this.unplaced.openStart;for(let e=this.unplaced.content,i=0,r=this.unplaced.openEnd;i<t;i++){let n=e.firstChild;if(e.childCount>1)r=0;if(n.type.spec.isolating&&r<=i){t=i;break}e=n.content}for(let e=1;e<=2;e++){for(let i=e==1?t:this.unplaced.openStart;i>=0;i--){let t,r=null;if(i){r=be(this.unplaced.content,i-1).firstChild;t=r.content}else{t=this.unplaced.content}let n=t.firstChild;for(let t=this.depth;t>=0;t--){let{type:s,match:l}=this.frontier[t],o,u=null;if(e==1&&(n?l.matchType(n.type)||(u=l.fillBefore(f.from(n),false)):r&&s.compatibleContent(r.type)))return{sliceDepth:i,frontierDepth:t,parent:r,inject:u};else if(e==2&&n&&(o=l.findWrapping(n.type)))return{sliceDepth:i,frontierDepth:t,parent:r,wrap:o};if(r&&l.matchType(r.type))break}}}}openMore(){let{content:t,openStart:e,openEnd:i}=this.unplaced;let r=be(t,e);if(!r.childCount||r.firstChild.isLeaf)return false;this.unplaced=new d(t,e+1,Math.max(i,r.size+e>=t.size-i?e+1:0));return true}dropNode(){let{content:t,openStart:e,openEnd:i}=this.unplaced;let r=be(t,e);if(r.childCount<=1&&e>0){let n=t.size-e<=e+r.size;this.unplaced=new d(we(t,e-1,1),e-1,n?e-1:i)}else{this.unplaced=new d(we(t,e,1),e,i)}}placeNodes({sliceDepth:t,frontierDepth:e,parent:i,inject:r,wrap:n}){while(this.depth>e)this.closeFrontierNode();if(n)for(let t=0;t<n.length;t++)this.openFrontierNode(n[t]);let s=this.unplaced,l=i?i.content:s.content;let o=s.openStart-t;let u=0,h=[];let{match:a,type:c}=this.frontier[e];if(r){for(let t=0;t<r.childCount;t++)h.push(r.child(t));a=a.matchFragment(r)}let p=l.size+t-(s.content.size-s.openEnd);while(u<l.childCount){let t=l.child(u),e=a.matchType(t.type);if(!e)break;u++;if(u>1||o==0||t.content.size){a=e;h.push(ve(t.mark(c.allowedMarks(t.marks)),u==1?o:0,u==l.childCount?p:-1))}}let m=u==l.childCount;if(!m)p=-1;this.placed=ge(this.placed,e,f.from(h));this.frontier[e].match=a;if(m&&p<0&&i&&i.type==this.frontier[this.depth].type&&this.frontier.length>1)this.closeFrontierNode();for(let t=0,e=l;t<p;t++){let t=e.lastChild;this.frontier.push({type:t.type,match:t.contentMatchAt(t.childCount)});e=t.content}this.unplaced=!m?new d(we(s.content,t,u),s.openStart,s.openEnd):t==0?d.empty:new d(we(s.content,t-1,1),t-1,p<0?s.openEnd:t-1)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let t=this.frontier[this.depth],e;if(!t.type.isTextblock||!ye(this.$to,this.$to.depth,t.type,t.match,false)||this.$to.depth==this.depth&&(e=this.findCloseLevel(this.$to))&&e.depth==this.depth)return-1;let{depth:i}=this.$to,r=this.$to.after(i);while(i>1&&r==this.$to.end(--i))++r;return r}findCloseLevel(t){t:for(let e=Math.min(this.depth,t.depth);e>=0;e--){let{match:i,type:r}=this.frontier[e];let n=e<t.depth&&t.end(e+1)==t.pos+(t.depth-(e+1));let s=ye(t,e,r,i,n);if(!s)continue;for(let i=e-1;i>=0;i--){let{match:e,type:r}=this.frontier[i];let n=ye(t,i,r,e,true);if(!n||n.childCount)continue t}return{depth:e,fit:s,move:n?t.doc.resolve(t.after(e+1)):t}}}close(t){let e=this.findCloseLevel(t);if(!e)return null;while(this.depth>e.depth)this.closeFrontierNode();if(e.fit.childCount)this.placed=ge(this.placed,e.depth,e.fit);t=e.move;for(let i=e.depth+1;i<=t.depth;i++){let e=t.node(i),r=e.type.contentMatch.fillBefore(e.content,true,t.index(i));this.openFrontierNode(e.type,e.attrs,r)}return t}openFrontierNode(t,e=null,i){let r=this.frontier[this.depth];r.match=r.match.matchType(t);this.placed=ge(this.placed,this.depth,f.from(t.create(e,i)));this.frontier.push({type:t,match:t.contentMatch})}closeFrontierNode(){let t=this.frontier.pop();let e=t.match.fillBefore(f.empty,true);if(e.childCount)this.placed=ge(this.placed,this.frontier.length,e)}}function we(t,e,i){if(e==0)return t.cutByIndex(i,t.childCount);return t.replaceChild(0,t.firstChild.copy(we(t.firstChild.content,e-1,i)))}function ge(t,e,i){if(e==0)return t.append(i);return t.replaceChild(t.childCount-1,t.lastChild.copy(ge(t.lastChild.content,e-1,i)))}function be(t,e){for(let i=0;i<e;i++)t=t.firstChild.content;return t}function ve(t,e,i){if(e<=0)return t;let r=t.content;if(e>1)r=r.replaceChild(0,ve(r.firstChild,e-1,r.childCount==1?i-1:0));if(e>0){r=t.type.contentMatch.fillBefore(r).append(r);if(i<=0)r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(f.empty,true))}return t.copy(r)}function ye(t,e,i,r,n){let s=t.node(e),l=n?t.indexAfter(e):t.index(e);if(l==s.childCount&&!i.compatibleContent(s.type))return null;let f=r.fillBefore(s.content,true,l);return f&&!ke(i,s.content,l)?f:null}function ke(t,e,i){for(let r=i;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return true;return false}function Me(t){return t.spec.defining||t.spec.definingForContent}function xe(t,e,i,r){if(!r.size)return t.deleteRange(e,i);let n=t.doc.resolve(e),s=t.doc.resolve(i);if(pe(n,s,r))return t.step(new Lt(e,i,r));let l=De(n,t.doc.resolve(i));if(l[l.length-1]==0)l.pop();let f=-(n.depth+1);l.unshift(f);for(let t=n.depth,e=n.pos-1;t>0;t--,e--){let i=n.node(t).type.spec;if(i.defining||i.definingAsContext||i.isolating)break;if(l.indexOf(t)>-1)f=t;else if(n.before(t)==e)l.splice(1,0,-t)}let o=l.indexOf(f);let u=[],h=r.openStart;for(let t=r.content,e=0;;e++){let i=t.firstChild;u.push(i);if(e==r.openStart)break;t=i.content}for(let t=h-1;t>=0;t--){let e=u[t],i=Me(e.type);if(i&&!e.sameMarkup(n.node(Math.abs(f)-1)))h=t;else if(i||!e.type.isTextblock)break}for(let e=r.openStart;e>=0;e--){let f=(e+h+1)%(r.openStart+1);let a=u[f];if(!a)continue;for(let e=0;e<l.length;e++){let u=l[(e+o)%l.length],h=true;if(u<0){h=false;u=-u}let c=n.node(u-1),p=n.index(u-1);if(c.canReplaceWith(p,p,a.type,a.marks))return t.replace(n.before(u),h?s.after(u):i,new d(Se(r.content,0,r.openStart,f),f,r.openEnd))}}let a=t.steps.length;for(let f=l.length-1;f>=0;f--){t.replace(e,i,r);if(t.steps.length>a)break;let o=l[f];if(o<0)continue;e=n.before(o);i=s.after(o)}}function Se(t,e,i,r,n){if(e<i){let n=t.firstChild;t=t.replaceChild(0,n.copy(Se(n.content,e+1,i,r,n)))}if(e>r){let e=n.contentMatchAt(0);let i=e.fillBefore(t).append(t);t=i.append(e.matchFragment(i).fillBefore(f.empty,true))}return t}function Oe(t,e,i,r){if(!r.isInline&&e==i&&t.doc.resolve(e).parent.content.size){let n=ae(t.doc,e,r.type);if(n!=null)e=i=n}t.replaceRange(e,i,new d(f.from(r),0,0))}function Ee(t,e,i){let r=t.doc.resolve(e),n=t.doc.resolve(i);let s=De(r,n);for(let e=0;e<s.length;e++){let i=s[e],l=e==s.length-1;if(l&&i==0||r.node(i).type.contentMatch.validEnd)return t.delete(r.start(i),n.end(i));if(i>0&&(l||r.node(i-1).canReplace(r.index(i-1),n.indexAfter(i-1))))return t.delete(r.before(i),n.after(i))}for(let s=1;s<=r.depth&&s<=n.depth;s++){if(e-r.start(s)==r.depth-s&&i>r.end(s)&&n.end(s)-i!=n.depth-s)return t.delete(r.before(s),i)}t.delete(e,i)}function De(t,e){let i=[],r=Math.min(t.depth,e.depth);for(let n=r;n>=0;n--){let r=t.start(n);if(r<t.pos-(t.depth-n)||e.end(n)>e.pos+(e.depth-n)||t.node(n).type.spec.isolating||e.node(n).type.spec.isolating)break;if(r==e.start(n)||n==t.depth&&n==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&n&&e.start(n-1)==r-1)i.push(n)}return i}class Ne extends It{constructor(t,e,i){super();this.pos=t;this.attr=e;this.value=i}apply(t){let e=t.nodeAt(this.pos);if(!e)return Pt.fail("No node at attribute step's position");let i=Object.create(null);for(let t in e.attrs)i[t]=e.attrs[t];i[this.attr]=this.value;let r=e.type.create(i,null,e.marks);return Pt.fromReplace(t,this.pos,this.pos+1,new d(f.from(r),0,e.isLeaf?0:1))}getMap(){return Ct.empty}invert(t){return new Ne(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new Ne(e.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,e){if(typeof e.pos!="number"||typeof e.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Ne(e.pos,e.attr,e.value)}}It.jsonID("attr",Ne);class $e extends It{constructor(t,e){super();this.attr=t;this.value=e}apply(t){let e=Object.create(null);for(let i in t.attrs)e[i]=t.attrs[i];e[this.attr]=this.value;let i=t.type.create(e,t.content,t.marks);return Pt.ok(i)}getMap(){return Ct.empty}invert(t){return new $e(this.attr,t.attrs[this.attr])}map(t){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(t,e){if(typeof e.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new $e(e.attr,e.value)}}It.jsonID("docAttr",$e);let Re=class extends Error{};Re=function t(e){let i=Error.call(this,e);i.__proto__=t.prototype;return i};Re.prototype=Object.create(Error.prototype);Re.prototype.constructor=Re;Re.prototype.name="TransformError";class qe{constructor(t){this.doc=t;this.steps=[];this.docs=[];this.mapping=new Tt}get before(){return this.docs.length?this.docs[0]:this.doc}step(t){let e=this.maybeStep(t);if(e.failed)throw new Re(e.failed);return this}maybeStep(t){let e=t.apply(this.doc);if(!e.failed)this.addStep(t,e.doc);return e}get docChanged(){return this.steps.length>0}addStep(t,e){this.docs.push(this.doc);this.steps.push(t);this.mapping.appendMap(t.getMap());this.doc=e}replace(t,e=t,i=d.empty){let r=de(this.doc,t,e,i);if(r)this.step(r);return this}replaceWith(t,e,i){return this.replace(t,e,new d(f.from(i),0,0))}delete(t,e){return this.replace(t,e,d.empty)}insert(t,e){return this.replaceWith(t,t,e)}replaceRange(t,e,i){xe(this,t,e,i);return this}replaceRangeWith(t,e,i){Oe(this,t,e,i);return this}deleteRange(t,e){Ee(this,t,e);return this}lift(t,e){Xt(this,t,e);return this}join(t,e=1){he(this,t,e);return this}wrap(t,e){ee(this,t,e);return this}setBlockType(t,e=t,i,r=null){ie(this,t,e,i,r);return this}setNodeMarkup(t,e,i=null,r){ne(this,t,e,i,r);return this}setNodeAttribute(t,e,i){this.step(new Ne(t,e,i));return this}setDocAttribute(t,e){this.step(new $e(t,e));return this}addNodeMark(t,e){this.step(new jt(t,e));return this}removeNodeMark(t,e){if(!(e instanceof a)){let i=this.doc.nodeAt(t);if(!i)throw new RangeError("No node at position "+t);e=e.isInSet(i.marks);if(!e)return this}this.step(new Ft(t,e));return this}split(t,e=1,i){le(this,t,e,i);return this}addMark(t,e,i){Ut(this,t,e,i);return this}removeMark(t,e,i){Kt(this,t,e,i);return this}clearIncompatible(t,e,i){Ht(this,t,e,i);return this}}const Ce=Object.create(null);class Te{constructor(t,e,i){this.$anchor=t;this.$head=e;this.ranges=i||[new Ae(t.min(e),t.max(e))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let t=this.ranges;for(let e=0;e<t.length;e++)if(t[e].$from.pos!=t[e].$to.pos)return false;return true}content(){return this.$from.doc.slice(this.from,this.to,true)}replace(t,e=d.empty){let i=e.content.lastChild,r=null;for(let t=0;t<e.openEnd;t++){r=i;i=i.lastChild}let n=t.steps.length,s=this.ranges;for(let l=0;l<s.length;l++){let{$from:f,$to:o}=s[l],u=t.mapping.slice(n);t.replaceRange(u.map(f.pos),u.map(o.pos),l?d.empty:e);if(l==0)_e(t,n,(i?i.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(t,e){let i=t.steps.length,r=this.ranges;for(let n=0;n<r.length;n++){let{$from:s,$to:l}=r[n],f=t.mapping.slice(i);let o=f.map(s.pos),u=f.map(l.pos);if(n){t.deleteRange(o,u)}else{t.replaceRangeWith(o,u,e);_e(t,i,e.isInline?-1:1)}}}static findFrom(t,e,i=false){let r=t.parent.inlineContent?new ze(t):We(t.node(0),t.parent,t.pos,t.index(),e,i);if(r)return r;for(let r=t.depth-1;r>=0;r--){let n=e<0?We(t.node(0),t.node(r),t.before(r+1),t.index(r),e,i):We(t.node(0),t.node(r),t.after(r+1),t.index(r)+1,e,i);if(n)return n}return null}static near(t,e=1){return this.findFrom(t,e)||this.findFrom(t,-e)||new Fe(t.node(0))}static atStart(t){return We(t,t,0,0,1)||new Fe(t)}static atEnd(t){return We(t,t,t.content.size,t.childCount,-1)||new Fe(t)}static fromJSON(t,e){if(!e||!e.type)throw new RangeError("Invalid input for Selection.fromJSON");let i=Ce[e.type];if(!i)throw new RangeError(`No selection type ${e.type} defined`);return i.fromJSON(t,e)}static jsonID(t,e){if(t in Ce)throw new RangeError("Duplicate use of selection JSON ID "+t);Ce[t]=e;e.prototype.jsonID=t;return e}getBookmark(){return ze.between(this.$anchor,this.$head).getBookmark()}}Te.prototype.visible=true;class Ae{constructor(t,e){this.$from=t;this.$to=e}}let Ie=false;function Pe(t){if(!Ie&&!t.parent.inlineContent){Ie=true;console["warn"]("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")")}}class ze extends Te{constructor(t,e=t){Pe(t);Pe(e);super(t,e)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,e){let i=t.resolve(e.map(this.head));if(!i.parent.inlineContent)return Te.near(i);let r=t.resolve(e.map(this.anchor));return new ze(r.parent.inlineContent?r:i,i)}replace(t,e=d.empty){super.replace(t,e);if(e==d.empty){let e=this.$from.marksAcross(this.$to);if(e)t.ensureMarks(e)}}eq(t){return t instanceof ze&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new Je(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(t,e){if(typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new ze(t.resolve(e.anchor),t.resolve(e.head))}static create(t,e,i=e){let r=t.resolve(e);return new this(r,i==e?r:t.resolve(i))}static between(t,e,i){let r=t.pos-e.pos;if(!i||r)i=r>=0?1:-1;if(!e.parent.inlineContent){let t=Te.findFrom(e,i,true)||Te.findFrom(e,-i,true);if(t)e=t.$head;else return Te.near(e,i)}if(!t.parent.inlineContent){if(r==0){t=e}else{t=(Te.findFrom(t,-i,true)||Te.findFrom(t,i,true)).$anchor;if(t.pos<e.pos!=r<0)t=e}}return new ze(t,e)}}Te.jsonID("text",ze);class Je{constructor(t,e){this.anchor=t;this.head=e}map(t){return new Je(t.map(this.anchor),t.map(this.head))}resolve(t){return ze.between(t.resolve(this.anchor),t.resolve(this.head))}}class Be extends Te{constructor(t){let e=t.nodeAfter;let i=t.node(0).resolve(t.pos+e.nodeSize);super(t,i);this.node=e}map(t,e){let{deleted:i,pos:r}=e.mapResult(this.anchor);let n=t.resolve(r);if(i)return Te.near(n);return new Be(n)}content(){return new d(f.from(this.node),0,0)}eq(t){return t instanceof Be&&t.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new je(this.anchor)}static fromJSON(t,e){if(typeof e.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Be(t.resolve(e.anchor))}static create(t,e){return new Be(t.resolve(e))}static isSelectable(t){return!t.isText&&t.type.spec.selectable!==false}}Be.prototype.visible=false;Te.jsonID("node",Be);class je{constructor(t){this.anchor=t}map(t){let{deleted:e,pos:i}=t.mapResult(this.anchor);return e?new Je(i,i):new je(i)}resolve(t){let e=t.resolve(this.anchor),i=e.nodeAfter;if(i&&Be.isSelectable(i))return new Be(e);return Te.near(e)}}class Fe extends Te{constructor(t){super(t.resolve(0),t.resolve(t.content.size))}replace(t,e=d.empty){if(e==d.empty){t.delete(0,t.doc.content.size);let e=Te.atStart(t.doc);if(!e.eq(t.selection))t.setSelection(e)}else{super.replace(t,e)}}toJSON(){return{type:"all"}}static fromJSON(t){return new Fe(t)}map(t){return new Fe(t)}eq(t){return t instanceof Fe}getBookmark(){return Le}}Te.jsonID("all",Fe);const Le={map(){return this},resolve(t){return new Fe(t)}};function We(t,e,i,r,n,s=false){if(e.inlineContent)return ze.create(t,i);for(let l=r-(n>0?0:1);n>0?l<e.childCount:l>=0;l+=n){let r=e.child(l);if(!r.isAtom){let e=We(t,r,i+n,n<0?r.childCount:0,n,s);if(e)return e}else if(!s&&Be.isSelectable(r)){return Be.create(t,i-(n<0?r.nodeSize:0))}i+=r.nodeSize*n}return null}function _e(t,e,i){let r=t.steps.length-1;if(r<e)return;let n=t.steps[r];if(!(n instanceof Lt||n instanceof Wt))return;let s=t.mapping.maps[r],l;s.forEach(((t,e,i,r)=>{if(l==null)l=r}));t.setSelection(Te.near(t.doc.resolve(l),i))}const Ue=1,Ke=2,He=4;class Ge extends qe{constructor(t){super(t.doc);this.curSelectionFor=0;this.updated=0;this.meta=Object.create(null);this.time=Date.now();this.curSelection=t.selection;this.storedMarks=t.storedMarks}get selection(){if(this.curSelectionFor<this.steps.length){this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor));this.curSelectionFor=this.steps.length}return this.curSelection}setSelection(t){if(t.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");this.curSelection=t;this.curSelectionFor=this.steps.length;this.updated=(this.updated|Ue)&~Ke;this.storedMarks=null;return this}get selectionSet(){return(this.updated&Ue)>0}setStoredMarks(t){this.storedMarks=t;this.updated|=Ke;return this}ensureMarks(t){if(!a.sameSet(this.storedMarks||this.selection.$from.marks(),t))this.setStoredMarks(t);return this}addStoredMark(t){return this.ensureMarks(t.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(t){return this.ensureMarks(t.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&Ke)>0}addStep(t,e){super.addStep(t,e);this.updated=this.updated&~Ke;this.storedMarks=null}setTime(t){this.time=t;return this}replaceSelection(t){this.selection.replace(this,t);return this}replaceSelectionWith(t,e=true){let i=this.selection;if(e)t=t.mark(this.storedMarks||(i.empty?i.$from.marks():i.$from.marksAcross(i.$to)||a.none));i.replaceWith(this,t);return this}deleteSelection(){this.selection.replace(this);return this}insertText(t,e,i){let r=this.doc.type.schema;if(e==null){if(!t)return this.deleteSelection();return this.replaceSelectionWith(r.text(t),true)}else{if(i==null)i=e;i=i==null?e:i;if(!t)return this.deleteRange(e,i);let n=this.storedMarks;if(!n){let t=this.doc.resolve(e);n=i==e?t.marks():t.marksAcross(this.doc.resolve(i))}this.replaceRangeWith(e,i,r.text(t,n));if(!this.selection.empty)this.setSelection(Te.near(this.selection.$to));return this}}setMeta(t,e){this.meta[typeof t=="string"?t:t.key]=e;return this}getMeta(t){return this.meta[typeof t=="string"?t:t.key]}get isGeneric(){for(let t in this.meta)return false;return true}scrollIntoView(){this.updated|=He;return this}get scrolledIntoView(){return(this.updated&He)>0}}function Ve(t,e){return!e||!t?t:t.bind(e)}class Xe{constructor(t,e,i){this.name=t;this.init=Ve(e.init,i);this.apply=Ve(e.apply,i)}}const Ye=[new Xe("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Xe("selection",{init(t,e){return t.selection||Te.atStart(e.doc)},apply(t){return t.selection}}),new Xe("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,i,r){return r.selection.$cursor?t.storedMarks:null}}),new Xe("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class Qe{constructor(t,e){this.schema=t;this.plugins=[];this.pluginsByKey=Object.create(null);this.fields=Ye.slice();if(e)e.forEach((t=>{if(this.pluginsByKey[t.key])throw new RangeError("Adding different instances of a keyed plugin ("+t.key+")");this.plugins.push(t);this.pluginsByKey[t.key]=t;if(t.spec.state)this.fields.push(new Xe(t.key,t.spec.state,t))}))}}class Ze{constructor(t){this.config=t}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(t){return this.applyTransaction(t).state}filterTransaction(t,e=-1){for(let i=0;i<this.config.plugins.length;i++)if(i!=e){let e=this.config.plugins[i];if(e.spec.filterTransaction&&!e.spec.filterTransaction.call(e,t,this))return false}return true}applyTransaction(t){if(!this.filterTransaction(t))return{state:this,transactions:[]};let e=[t],i=this.applyInner(t),r=null;for(;;){let n=false;for(let s=0;s<this.config.plugins.length;s++){let l=this.config.plugins[s];if(l.spec.appendTransaction){let f=r?r[s].n:0,o=r?r[s].state:this;let u=f<e.length&&l.spec.appendTransaction.call(l,f?e.slice(f):e,o,i);if(u&&i.filterTransaction(u,s)){u.setMeta("appendedTransaction",t);if(!r){r=[];for(let t=0;t<this.config.plugins.length;t++)r.push(t<s?{state:i,n:e.length}:{state:this,n:0})}e.push(u);i=i.applyInner(u);n=true}if(r)r[s]={state:i,n:e.length}}}if(!n)return{state:i,transactions:e}}}applyInner(t){if(!t.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let e=new Ze(this.config),i=this.config.fields;for(let r=0;r<i.length;r++){let n=i[r];e[n.name]=n.apply(t,this[n.name],this,e)}return e}get tr(){return new Ge(this)}static create(t){let e=new Qe(t.doc?t.doc.type.schema:t.schema,t.plugins);let i=new Ze(e);for(let r=0;r<e.fields.length;r++)i[e.fields[r].name]=e.fields[r].init(t,i);return i}reconfigure(t){let e=new Qe(this.schema,t.plugins);let i=e.fields,r=new Ze(e);for(let e=0;e<i.length;e++){let n=i[e].name;r[n]=this.hasOwnProperty(n)?this[n]:i[e].init(t,r)}return r}toJSON(t){let e={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks)e.storedMarks=this.storedMarks.map((t=>t.toJSON()));if(t&&typeof t=="object")for(let i in t){if(i=="doc"||i=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let r=t[i],n=r.spec.state;if(n&&n.toJSON)e[i]=n.toJSON.call(r,this[r.key])}return e}static fromJSON(t,e,i){if(!e)throw new RangeError("Invalid input for EditorState.fromJSON");if(!t.schema)throw new RangeError("Required config field 'schema' missing");let r=new Qe(t.schema,t.plugins);let n=new Ze(r);r.fields.forEach((r=>{if(r.name=="doc"){n.doc=C.fromJSON(t.schema,e.doc)}else if(r.name=="selection"){n.selection=Te.fromJSON(n.doc,e.selection)}else if(r.name=="storedMarks"){if(e.storedMarks)n.storedMarks=e.storedMarks.map(t.schema.markFromJSON)}else{if(i)for(let s in i){let l=i[s],f=l.spec.state;if(l.key==r.name&&f&&f.fromJSON&&Object.prototype.hasOwnProperty.call(e,s)){n[r.name]=f.fromJSON.call(l,t,e[s],n);return}}n[r.name]=r.init(t,n)}}));return n}}function ti(t,e,i){for(let r in t){let n=t[r];if(n instanceof Function)n=n.bind(e);else if(r=="handleDOMEvents")n=ti(n,e,{});i[r]=n}return i}class ei{constructor(t){this.spec=t;this.props={};if(t.props)ti(t.props,this,this.props);this.key=t.key?t.key.key:ri("plugin")}getState(t){return t[this.key]}}const ii=Object.create(null);function ri(t){if(t in ii)return t+"$"+ ++ii[t];ii[t]=0;return t+"$"}class ni{constructor(t="key"){this.key=ri(t)}get(t){return t.config.pluginsByKey[this.key]}getState(t){return t[this.key]}}const si=function(t){for(var e=0;;e++){t=t.previousSibling;if(!t)return e}};const li=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let fi=null;const oi=function(t,e,i){let r=fi||(fi=document.createRange());r.setEnd(t,i==null?t.nodeValue.length:i);r.setStart(t,e||0);return r};const ui=function(t,e,i,r){return i&&(ai(t,e,i,r,-1)||ai(t,e,i,r,1))};const hi=/^(img|br|input|textarea|hr)$/i;function ai(t,e,i,r,n){for(;;){if(t==i&&e==r)return true;if(e==(n<0?0:ci(t))){let i=t.parentNode;if(!i||i.nodeType!=1||pi(t)||hi.test(t.nodeName)||t.contentEditable=="false")return false;e=si(t)+(n<0?0:1);t=i}else if(t.nodeType==1){t=t.childNodes[e+(n<0?-1:0)];if(t.contentEditable=="false")return false;e=n<0?ci(t):0}else{return false}}}function ci(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function di(t,e,i){for(let r=e==0,n=e==ci(t);r||n;){if(t==i)return true;let e=si(t);t=t.parentNode;if(!t)return false;r=r&&e==0;n=n&&e==ci(t)}}function pi(t){let e;for(let i=t;i;i=i.parentNode)if(e=i.pmViewDesc)break;return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const mi=function(t){return t.focusNode&&ui(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function wi(t,e){let i=document.createEvent("Event");i.initEvent("keydown",true,true);i.keyCode=t;i.key=i.code=e;return i}function gi(t){let e=t.activeElement;while(e&&e.shadowRoot)e=e.shadowRoot.activeElement;return e}function bi(t,e,i){if(t.caretPositionFromPoint){try{let r=t.caretPositionFromPoint(e,i);if(r)return{node:r.offsetNode,offset:r.offset}}catch(t){}}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,i);if(r)return{node:r.startContainer,offset:r.startOffset}}}const vi=typeof navigator!="undefined"?navigator:null;const yi=typeof document!="undefined"?document:null;const ki=vi&&vi.userAgent||"";const Mi=/Edge\/(\d+)/.exec(ki);const xi=/MSIE \d/.exec(ki);const Si=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ki);const Oi=!!(xi||Si||Mi);const Ei=xi?document.documentMode:Si?+Si[1]:Mi?+Mi[1]:0;const Di=!Oi&&/gecko\/(\d+)/i.test(ki);Di&&+(/Firefox\/(\d+)/.exec(ki)||[0,0])[1];const Ni=!Oi&&/Chrome\/(\d+)/.exec(ki);const $i=!!Ni;const Ri=Ni?+Ni[1]:0;const qi=!Oi&&!!vi&&/Apple Computer/.test(vi.vendor);const Ci=qi&&(/Mobile\/\w+/.test(ki)||!!vi&&vi.maxTouchPoints>2);const Ti=Ci||(vi?/Mac/.test(vi.platform):false);const Ai=vi?/Win/.test(vi.platform):false;const Ii=/Android \d/.test(ki);const Pi=!!yi&&"webkitFontSmoothing"in yi.documentElement.style;const zi=Pi?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Ji(t){return{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function Bi(t,e){return typeof t=="number"?t:t[e]}function ji(t){let e=t.getBoundingClientRect();let i=e.width/t.offsetWidth||1;let r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*i,top:e.top,bottom:e.top+t.clientHeight*r}}function Fi(t,e,i){let r=t.someProp("scrollThreshold")||0,n=t.someProp("scrollMargin")||5;let s=t.dom.ownerDocument;for(let l=i||t.dom;;l=li(l)){if(!l)break;if(l.nodeType!=1)continue;let t=l;let i=t==s.body;let f=i?Ji(s):ji(t);let o=0,u=0;if(e.top<f.top+Bi(r,"top"))u=-(f.top-e.top+Bi(n,"top"));else if(e.bottom>f.bottom-Bi(r,"bottom"))u=e.bottom-e.top>f.bottom-f.top?e.top+Bi(n,"top")-f.top:e.bottom-f.bottom+Bi(n,"bottom");if(e.left<f.left+Bi(r,"left"))o=-(f.left-e.left+Bi(n,"left"));else if(e.right>f.right-Bi(r,"right"))o=e.right-f.right+Bi(n,"right");if(o||u){if(i){s.defaultView.scrollBy(o,u)}else{let i=t.scrollLeft,r=t.scrollTop;if(u)t.scrollTop+=u;if(o)t.scrollLeft+=o;let n=t.scrollLeft-i,s=t.scrollTop-r;e={left:e.left-n,top:e.top-s,right:e.right-n,bottom:e.bottom-s}}}if(i||/^(fixed|sticky)$/.test(getComputedStyle(l).position))break}}function Li(t){let e=t.dom.getBoundingClientRect(),i=Math.max(0,e.top);let r,n;for(let s=(e.left+e.right)/2,l=i+1;l<Math.min(innerHeight,e.bottom);l+=5){let e=t.root.elementFromPoint(s,l);if(!e||e==t.dom||!t.dom.contains(e))continue;let f=e.getBoundingClientRect();if(f.top>=i-20){r=e;n=f.top;break}}return{refDOM:r,refTop:n,stack:Wi(t.dom)}}function Wi(t){let e=[],i=t.ownerDocument;for(let r=t;r;r=li(r)){e.push({dom:r,top:r.scrollTop,left:r.scrollLeft});if(t==i)break}return e}function _i({refDOM:t,refTop:e,stack:i}){let r=t?t.getBoundingClientRect().top:0;Ui(i,r==0?0:r-e)}function Ui(t,e){for(let i=0;i<t.length;i++){let{dom:r,top:n,left:s}=t[i];if(r.scrollTop!=n+e)r.scrollTop=n+e;if(r.scrollLeft!=s)r.scrollLeft=s}}let Ki=null;function Hi(t){if(t.setActive)return t.setActive();if(Ki)return t.focus(Ki);let e=Wi(t);t.focus(Ki==null?{get preventScroll(){Ki={preventScroll:true};return true}}:undefined);if(!Ki){Ki=false;Ui(e,0)}}function Gi(t,e){let i,r=2e8,n,s=0;let l=e.top,f=e.top;let o,u;for(let h=t.firstChild,a=0;h;h=h.nextSibling,a++){let t;if(h.nodeType==1)t=h.getClientRects();else if(h.nodeType==3)t=oi(h).getClientRects();else continue;for(let c=0;c<t.length;c++){let d=t[c];if(d.top<=l&&d.bottom>=f){l=Math.max(d.bottom,l);f=Math.min(d.top,f);let t=d.left>e.left?d.left-e.left:d.right<e.left?e.left-d.right:0;if(t<r){i=h;r=t;n=t&&i.nodeType==3?{left:d.right<e.left?d.right:d.left,top:e.top}:e;if(h.nodeType==1&&t)s=a+(e.left>=(d.left+d.right)/2?1:0);continue}}else if(d.top>e.top&&!o&&d.left<=e.left&&d.right>=e.left){o=h;u={left:Math.max(d.left,Math.min(d.right,e.left)),top:d.top}}if(!i&&(e.left>=d.right&&e.top>=d.top||e.left>=d.left&&e.top>=d.bottom))s=a+1}}if(!i&&o){i=o;n=u;r=0}if(i&&i.nodeType==3)return Vi(i,n);if(!i||r&&i.nodeType==1)return{node:t,offset:s};return Gi(i,n)}function Vi(t,e){let i=t.nodeValue.length;let r=document.createRange();for(let n=0;n<i;n++){r.setEnd(t,n+1);r.setStart(t,n);let i=rr(r,1);if(i.top==i.bottom)continue;if(Xi(e,i))return{node:t,offset:n+(e.left>=(i.left+i.right)/2?1:0)}}return{node:t,offset:0}}function Xi(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function Yi(t,e){let i=t.parentNode;if(i&&/^li$/i.test(i.nodeName)&&e.left<t.getBoundingClientRect().left)return i;return t}function Qi(t,e,i){let{node:r,offset:n}=Gi(e,i),s=-1;if(r.nodeType==1&&!r.firstChild){let t=r.getBoundingClientRect();s=t.left!=t.right&&i.left>(t.left+t.right)/2?1:-1}return t.docView.posFromDOM(r,n,s)}function Zi(t,e,i,r){let n=-1;for(let i=e,s=false;;){if(i==t.dom)break;let e=t.docView.nearestDesc(i,true);if(!e)return null;if(e.dom.nodeType==1&&(e.node.isBlock&&e.parent&&!s||!e.contentDOM)){let t=e.dom.getBoundingClientRect();if(e.node.isBlock&&e.parent&&!s){s=true;if(t.left>r.left||t.top>r.top)n=e.posBefore;else if(t.right<r.left||t.bottom<r.top)n=e.posAfter}if(!e.contentDOM&&n<0&&!e.node.isText){let i=e.node.isBlock?r.top<(t.top+t.bottom)/2:r.left<(t.left+t.right)/2;return i?e.posBefore:e.posAfter}}i=e.dom.parentNode}return n>-1?n:t.docView.posFromDOM(e,i,-1)}function tr(t,e,i){let r=t.childNodes.length;if(r&&i.top<i.bottom){for(let n=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-i.top)/(i.bottom-i.top))-2)),s=n;;){let i=t.childNodes[s];if(i.nodeType==1){let t=i.getClientRects();for(let r=0;r<t.length;r++){let n=t[r];if(Xi(e,n))return tr(i,e,n)}}if((s=(s+1)%r)==n)break}}return t}function er(t,e){let i=t.dom.ownerDocument,r,n=0;let s=bi(i,e.left,e.top);if(s)({node:r,offset:n}=s);let l=(t.root.elementFromPoint?t.root:i).elementFromPoint(e.left,e.top);let f;if(!l||!t.dom.contains(l.nodeType!=1?l.parentNode:l)){let i=t.dom.getBoundingClientRect();if(!Xi(e,i))return null;l=tr(t.dom,e,i);if(!l)return null}if(qi){for(let t=l;r&&t;t=li(t))if(t.draggable)r=undefined}l=Yi(l,e);if(r){if(Di&&r.nodeType==1){n=Math.min(n,r.childNodes.length);if(n<r.childNodes.length){let t=r.childNodes[n],i;if(t.nodeName=="IMG"&&(i=t.getBoundingClientRect()).right<=e.left&&i.bottom>e.top)n++}}let i;if(Pi&&n&&r.nodeType==1&&(i=r.childNodes[n-1]).nodeType==1&&i.contentEditable=="false"&&i.getBoundingClientRect().top>=e.top)n--;if(r==t.dom&&n==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom)f=t.state.doc.content.size;else if(n==0||r.nodeType!=1||r.childNodes[n-1].nodeName!="BR")f=Zi(t,r,n,e)}if(f==null)f=Qi(t,l,e);let o=t.docView.nearestDesc(l,true);return{pos:f,inside:o?o.posAtStart-o.border:-1}}function ir(t){return t.top<t.bottom||t.left<t.right}function rr(t,e){let i=t.getClientRects();if(i.length){let t=i[e<0?0:i.length-1];if(ir(t))return t}return Array.prototype.find.call(i,ir)||t.getBoundingClientRect()}const nr=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function sr(t,e,i){let{node:r,offset:n,atom:s}=t.docView.domFromPos(e,i<0?-1:1);let l=Pi||Di;if(r.nodeType==3){if(l&&(nr.test(r.nodeValue)||(i<0?!n:n==r.nodeValue.length))){let t=rr(oi(r,n,n),i);if(Di&&n&&/\s/.test(r.nodeValue[n-1])&&n<r.nodeValue.length){let e=rr(oi(r,n-1,n-1),-1);if(e.top==t.top){let i=rr(oi(r,n,n+1),-1);if(i.top!=t.top)return lr(i,i.left<e.left)}}return t}else{let t=n,e=n,s=i<0?1:-1;if(i<0&&!n){e++;s=-1}else if(i>=0&&n==r.nodeValue.length){t--;s=1}else if(i<0){t--}else{e++}return lr(rr(oi(r,t,e),s),s<0)}}let f=t.state.doc.resolve(e-(s||0));if(!f.parent.inlineContent){if(s==null&&n&&(i<0||n==ci(r))){let t=r.childNodes[n-1];if(t.nodeType==1)return fr(t.getBoundingClientRect(),false)}if(s==null&&n<ci(r)){let t=r.childNodes[n];if(t.nodeType==1)return fr(t.getBoundingClientRect(),true)}return fr(r.getBoundingClientRect(),i>=0)}if(s==null&&n&&(i<0||n==ci(r))){let t=r.childNodes[n-1];let e=t.nodeType==3?oi(t,ci(t)-(l?0:1)):t.nodeType==1&&(t.nodeName!="BR"||!t.nextSibling)?t:null;if(e)return lr(rr(e,1),false)}if(s==null&&n<ci(r)){let t=r.childNodes[n];while(t.pmViewDesc&&t.pmViewDesc.ignoreForCoords)t=t.nextSibling;let e=!t?null:t.nodeType==3?oi(t,0,l?0:1):t.nodeType==1?t:null;if(e)return lr(rr(e,-1),true)}return lr(rr(r.nodeType==3?oi(r):r,-i),i>=0)}function lr(t,e){if(t.width==0)return t;let i=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:i,right:i}}function fr(t,e){if(t.height==0)return t;let i=e?t.top:t.bottom;return{top:i,bottom:i,left:t.left,right:t.right}}function or(t,e,i){let r=t.state,n=t.root.activeElement;if(r!=e)t.updateState(e);if(n!=t.dom)t.focus();try{return i()}finally{if(r!=e)t.updateState(r);if(n!=t.dom&&n)n.focus()}}function ur(t,e,i){let r=e.selection;let n=i=="up"?r.$from:r.$to;return or(t,e,(()=>{let{node:e}=t.docView.domFromPos(n.pos,i=="up"?-1:1);for(;;){let i=t.docView.nearestDesc(e,true);if(!i)break;if(i.node.isBlock){e=i.contentDOM||i.dom;break}e=i.dom.parentNode}let r=sr(t,n.pos,1);for(let t=e.firstChild;t;t=t.nextSibling){let e;if(t.nodeType==1)e=t.getClientRects();else if(t.nodeType==3)e=oi(t,0,t.nodeValue.length).getClientRects();else continue;for(let t=0;t<e.length;t++){let n=e[t];if(n.bottom>n.top+1&&(i=="up"?r.top-n.top>(n.bottom-r.top)*2:n.bottom-r.bottom>(r.bottom-n.top)*2))return false}}return true}))}const hr=/[\u0590-\u08ac]/;function ar(t,e,i){let{$head:r}=e.selection;if(!r.parent.isTextblock)return false;let n=r.parentOffset,s=!n,l=n==r.parent.content.size;let f=t.domSelection();if(!hr.test(r.parent.textContent)||!f.modify)return i=="left"||i=="backward"?s:l;return or(t,e,(()=>{let{focusNode:e,focusOffset:n,anchorNode:s,anchorOffset:l}=t.domSelectionRange();let o=f.caretBidiLevel;f.modify("move",i,"character");let u=r.depth?t.docView.domAfterPos(r.before()):t.dom;let{focusNode:h,focusOffset:a}=t.domSelectionRange();let c=h&&!u.contains(h.nodeType==1?h:h.parentNode)||e==h&&n==a;try{f.collapse(s,l);if(e&&(e!=s||n!=l)&&f.extend)f.extend(e,n)}catch(t){}if(o!=null)f.caretBidiLevel=o;return c}))}let cr=null;let dr=null;let pr=false;function mr(t,e,i){if(cr==e&&dr==i)return pr;cr=e;dr=i;return pr=i=="up"||i=="down"?ur(t,e,i):ar(t,e,i)}const wr=0,gr=1,br=2,vr=3;class yr{constructor(t,e,i,r){this.parent=t;this.children=e;this.dom=i;this.contentDOM=r;this.dirty=wr;i.pmViewDesc=this}matchesWidget(t){return false}matchesMark(t){return false}matchesNode(t,e,i){return false}matchesHack(t){return false}parseRule(){return null}stopEvent(t){return false}get size(){let t=0;for(let e=0;e<this.children.length;e++)t+=this.children[e].size;return t}get border(){return 0}destroy(){this.parent=undefined;if(this.dom.pmViewDesc==this)this.dom.pmViewDesc=undefined;for(let t=0;t<this.children.length;t++)this.children[t].destroy()}posBeforeChild(t){for(let e=0,i=this.posAtStart;;e++){let r=this.children[e];if(r==t)return i;i+=r.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(t,e,i){if(this.contentDOM&&this.contentDOM.contains(t.nodeType==1?t:t.parentNode)){if(i<0){let i,r;if(t==this.contentDOM){i=t.childNodes[e-1]}else{while(t.parentNode!=this.contentDOM)t=t.parentNode;i=t.previousSibling}while(i&&!((r=i.pmViewDesc)&&r.parent==this))i=i.previousSibling;return i?this.posBeforeChild(r)+r.size:this.posAtStart}else{let i,r;if(t==this.contentDOM){i=t.childNodes[e]}else{while(t.parentNode!=this.contentDOM)t=t.parentNode;i=t.nextSibling}while(i&&!((r=i.pmViewDesc)&&r.parent==this))i=i.nextSibling;return i?this.posBeforeChild(r):this.posAtEnd}}let r;if(t==this.dom&&this.contentDOM){r=e>si(this.contentDOM)}else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM)){r=t.compareDocumentPosition(this.contentDOM)&2}else if(this.dom.firstChild){if(e==0)for(let e=t;;e=e.parentNode){if(e==this.dom){r=false;break}if(e.previousSibling)break}if(r==null&&e==t.childNodes.length)for(let e=t;;e=e.parentNode){if(e==this.dom){r=true;break}if(e.nextSibling)break}}return(r==null?i>0:r)?this.posAtEnd:this.posAtStart}nearestDesc(t,e=false){for(let i=true,r=t;r;r=r.parentNode){let n=this.getDesc(r),s;if(n&&(!e||n.node)){if(i&&(s=n.nodeDOM)&&!(s.nodeType==1?s.contains(t.nodeType==1?t:t.parentNode):s==t))i=false;else return n}}}getDesc(t){let e=t.pmViewDesc;for(let t=e;t;t=t.parent)if(t==this)return e}posFromDOM(t,e,i){for(let r=t;r;r=r.parentNode){let n=this.getDesc(r);if(n)return n.localPosFromDOM(t,e,i)}return-1}descAt(t){for(let e=0,i=0;e<this.children.length;e++){let r=this.children[e],n=i+r.size;if(i==t&&n!=i){while(!r.border&&r.children.length)r=r.children[0];return r}if(t<n)return r.descAt(t-i-r.border);i=n}}domFromPos(t,e){if(!this.contentDOM)return{node:this.dom,offset:0,atom:t+1};let i=0,r=0;for(let e=0;i<this.children.length;i++){let n=this.children[i],s=e+n.size;if(s>t||n instanceof Dr){r=t-e;break}e=s}if(r)return this.children[i].domFromPos(r-this.children[i].border,e);for(let t;i&&!(t=this.children[i-1]).size&&t instanceof kr&&t.side>=0;i--){}if(e<=0){let t,r=true;for(;;i--,r=false){t=i?this.children[i-1]:null;if(!t||t.dom.parentNode==this.contentDOM)break}if(t&&e&&r&&!t.border&&!t.domAtom)return t.domFromPos(t.size,e);return{node:this.contentDOM,offset:t?si(t.dom)+1:0}}else{let t,r=true;for(;;i++,r=false){t=i<this.children.length?this.children[i]:null;if(!t||t.dom.parentNode==this.contentDOM)break}if(t&&r&&!t.border&&!t.domAtom)return t.domFromPos(0,e);return{node:this.contentDOM,offset:t?si(t.dom):this.contentDOM.childNodes.length}}}parseRange(t,e,i=0){if(this.children.length==0)return{node:this.contentDOM,from:t,to:e,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,n=-1;for(let s=i,l=0;;l++){let i=this.children[l],f=s+i.size;if(r==-1&&t<=f){let n=s+i.border;if(t>=n&&e<=f-i.border&&i.node&&i.contentDOM&&this.contentDOM.contains(i.contentDOM))return i.parseRange(t,e,n);t=s;for(let e=l;e>0;e--){let i=this.children[e-1];if(i.size&&i.dom.parentNode==this.contentDOM&&!i.emptyChildAt(1)){r=si(i.dom)+1;break}t-=i.size}if(r==-1)r=0}if(r>-1&&(f>e||l==this.children.length-1)){e=f;for(let t=l+1;t<this.children.length;t++){let i=this.children[t];if(i.size&&i.dom.parentNode==this.contentDOM&&!i.emptyChildAt(-1)){n=si(i.dom);break}e+=i.size}if(n==-1)n=this.contentDOM.childNodes.length;break}s=f}return{node:this.contentDOM,from:t,to:e,fromOffset:r,toOffset:n}}emptyChildAt(t){if(this.border||!this.contentDOM||!this.children.length)return false;let e=this.children[t<0?0:this.children.length-1];return e.size==0||e.emptyChildAt(t)}domAfterPos(t){let{node:e,offset:i}=this.domFromPos(t,0);if(e.nodeType!=1||i==e.childNodes.length)throw new RangeError("No node after pos "+t);return e.childNodes[i]}setSelection(t,e,i,r=false){let n=Math.min(t,e),s=Math.max(t,e);for(let l=0,f=0;l<this.children.length;l++){let o=this.children[l],u=f+o.size;if(n>f&&s<u)return o.setSelection(t-f-o.border,e-f-o.border,i,r);f=u}let l=this.domFromPos(t,t?-1:1);let f=e==t?l:this.domFromPos(e,e?-1:1);let o=i.getSelection();let u=false;if((Di||qi)&&t==e){let{node:t,offset:e}=l;if(t.nodeType==3){u=!!(e&&t.nodeValue[e-1]=="\n");if(u&&e==t.nodeValue.length){for(let e=t,i;e;e=e.parentNode){if(i=e.nextSibling){if(i.nodeName=="BR")l=f={node:i.parentNode,offset:si(i)+1};break}let t=e.pmViewDesc;if(t&&t.node&&t.node.isBlock)break}}}else{let i=t.childNodes[e-1];u=i&&(i.nodeName=="BR"||i.contentEditable=="false")}}if(Di&&o.focusNode&&o.focusNode!=f.node&&o.focusNode.nodeType==1){let t=o.focusNode.childNodes[o.focusOffset];if(t&&t.contentEditable=="false")r=true}if(!(r||u&&qi)&&ui(l.node,l.offset,o.anchorNode,o.anchorOffset)&&ui(f.node,f.offset,o.focusNode,o.focusOffset))return;let h=false;if((o.extend||t==e)&&!u){o.collapse(l.node,l.offset);try{if(t!=e)o.extend(f.node,f.offset);h=true}catch(t){}}if(!h){if(t>e){let t=l;l=f;f=t}let i=document.createRange();i.setEnd(f.node,f.offset);i.setStart(l.node,l.offset);o.removeAllRanges();o.addRange(i)}}ignoreMutation(t){return!this.contentDOM&&t.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(t,e){for(let i=0,r=0;r<this.children.length;r++){let n=this.children[r],s=i+n.size;if(i==s?t<=s&&e>=i:t<s&&e>i){let r=i+n.border,l=s-n.border;if(t>=r&&e<=l){this.dirty=t==i||e==s?br:gr;if(t==r&&e==l&&(n.contentLost||n.dom.parentNode!=this.contentDOM))n.dirty=vr;else n.markDirty(t-r,e-r);return}else{n.dirty=n.dom==n.contentDOM&&n.dom.parentNode==this.contentDOM&&!n.children.length?br:vr}}i=s}this.dirty=br}markParentsDirty(){let t=1;for(let e=this.parent;e;e=e.parent,t++){let i=t==1?br:gr;if(e.dirty<i)e.dirty=i}}get domAtom(){return false}get ignoreForCoords(){return false}}class kr extends yr{constructor(t,e,i,r){let n,s=e.type.toDOM;if(typeof s=="function")s=s(i,(()=>{if(!n)return r;if(n.parent)return n.parent.posBeforeChild(n)}));if(!e.type.spec.raw){if(s.nodeType!=1){let t=document.createElement("span");t.appendChild(s);s=t}s.contentEditable="false";s.classList.add("ProseMirror-widget")}super(t,[],s,null);this.widget=e;this.widget=e;n=this}matchesWidget(t){return this.dirty==wr&&t.type.eq(this.widget.type)}parseRule(){return{ignore:true}}stopEvent(t){let e=this.widget.spec.stopEvent;return e?e(t):false}ignoreMutation(t){return t.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom);super.destroy()}get domAtom(){return true}get side(){return this.widget.type.side}}class Mr extends yr{constructor(t,e,i,r){super(t,[],e,null);this.textDOM=i;this.text=r}get size(){return this.text.length}localPosFromDOM(t,e){if(t!=this.textDOM)return this.posAtStart+(e?this.size:0);return this.posAtStart+e}domFromPos(t){return{node:this.textDOM,offset:t}}ignoreMutation(t){return t.type==="characterData"&&t.target.nodeValue==t.oldValue}}class xr extends yr{constructor(t,e,i,r){super(t,[],i,r);this.mark=e}static create(t,e,i,r){let n=r.nodeViews[e.type.name];let s=n&&n(e,r,i);if(!s||!s.dom)s=vt.renderSpec(document,e.type.spec.toDOM(e,i));return new xr(t,e,s.dom,s.contentDOM||s.dom)}parseRule(){if(this.dirty&vr||this.mark.type.spec.reparseInView)return null;return{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(t){return this.dirty!=vr&&this.mark.eq(t)}markDirty(t,e){super.markDirty(t,e);if(this.dirty!=wr){let t=this.parent;while(!t.node)t=t.parent;if(t.dirty<this.dirty)t.dirty=this.dirty;this.dirty=wr}}slice(t,e,i){let r=xr.create(this.parent,this.mark,true,i);let n=this.children,s=this.size;if(e<s)n=Ur(n,e,s,i);if(t>0)n=Ur(n,0,t,i);for(let t=0;t<n.length;t++)n[t].parent=r;r.children=n;return r}}class Sr extends yr{constructor(t,e,i,r,n,s,l,f,o){super(t,[],n,s);this.node=e;this.outerDeco=i;this.innerDeco=r;this.nodeDOM=l}static create(t,e,i,r,n,s){let l=n.nodeViews[e.type.name],f;let o=l&&l(e,n,(()=>{if(!f)return s;if(f.parent)return f.parent.posBeforeChild(f)}),i,r);let u=o&&o.dom,h=o&&o.contentDOM;if(e.isText){if(!u)u=document.createTextNode(e.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else if(!u){({dom:u,contentDOM:h}=vt.renderSpec(document,e.type.spec.toDOM(e)))}if(!h&&!e.isText&&u.nodeName!="BR"){if(!u.hasAttribute("contenteditable"))u.contentEditable="false";if(e.type.spec.draggable)u.draggable=true}let a=u;u=Ir(u,i,e);if(o)return f=new Nr(t,e,i,r,u,h||null,a,o,n,s+1);else if(e.isText)return new Er(t,e,i,r,u,a,n);else return new Sr(t,e,i,r,u,h||null,a,n,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre")t.preserveWhitespace="full";if(!this.contentDOM){t.getContent=()=>this.node.content}else if(!this.contentLost){t.contentElement=this.contentDOM}else{for(let e=this.children.length-1;e>=0;e--){let i=this.children[e];if(this.dom.contains(i.dom.parentNode)){t.contentElement=i.dom.parentNode;break}}if(!t.contentElement)t.getContent=()=>f.empty}return t}matchesNode(t,e,i){return this.dirty==wr&&t.eq(this.node)&&Pr(e,this.outerDeco)&&i.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(t,e){let i=this.node.inlineContent,r=e;let n=t.composing?this.localCompositionInfo(t,e):null;let s=n&&n.pos>-1?n:null;let l=n&&n.pos<0;let f=new Jr(this,s&&s.node,t);Fr(this.node,this.innerDeco,((e,n,s)=>{if(e.spec.marks)f.syncToMarks(e.spec.marks,i,t);else if(e.type.side>=0&&!s)f.syncToMarks(n==this.node.childCount?a.none:this.node.child(n).marks,i,t);f.placeWidget(e,t,r)}),((e,s,o,u)=>{f.syncToMarks(e.marks,i,t);let h;if(f.findNodeMatch(e,s,o,u));else if(l&&t.state.selection.from>r&&t.state.selection.to<r+e.nodeSize&&(h=f.findIndexWithChild(n.node))>-1&&f.updateNodeAt(e,s,o,h,t));else if(f.updateNextNode(e,s,o,t,u,r));else{f.addNode(e,s,o,t,r)}r+=e.nodeSize}));f.syncToMarks([],i,t);if(this.node.isTextblock)f.addTextblockHacks();f.destroyRest();if(f.changed||this.dirty==br){if(s)this.protectLocalComposition(t,s);$r(this.contentDOM,this.children,t);if(Ci)Lr(this.dom)}}localCompositionInfo(t,e){let{from:i,to:r}=t.state.selection;if(!(t.state.selection instanceof ze)||i<e||r>e+this.node.content.size)return null;let n=t.domSelectionRange();let s=Wr(n.focusNode,n.focusOffset);if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let t=s.nodeValue;let n=_r(this.node.content,t,i-e,r-e);return n<0?null:{node:s,pos:n,text:t}}else{return{node:s,pos:-1,text:""}}}protectLocalComposition(t,{node:e,pos:i,text:r}){if(this.getDesc(e))return;let n=e;for(;;n=n.parentNode){if(n.parentNode==this.contentDOM)break;while(n.previousSibling)n.parentNode.removeChild(n.previousSibling);while(n.nextSibling)n.parentNode.removeChild(n.nextSibling);if(n.pmViewDesc)n.pmViewDesc=undefined}let s=new Mr(this,n,e,r);t.input.compositionNodes.push(s);this.children=Ur(this.children,i,i+r.length,t,s)}update(t,e,i,r){if(this.dirty==vr||!t.sameMarkup(this.node))return false;this.updateInner(t,e,i,r);return true}updateInner(t,e,i,r){this.updateOuterDeco(e);this.node=t;this.innerDeco=i;if(this.contentDOM)this.updateChildren(r,this.posAtStart);this.dirty=wr}updateOuterDeco(t){if(Pr(t,this.outerDeco))return;let e=this.nodeDOM.nodeType!=1;let i=this.dom;this.dom=Tr(this.dom,this.nodeDOM,Cr(this.outerDeco,this.node,e),Cr(t,this.node,e));if(this.dom!=i){i.pmViewDesc=undefined;this.dom.pmViewDesc=this}this.outerDeco=t}selectNode(){if(this.nodeDOM.nodeType==1)this.nodeDOM.classList.add("ProseMirror-selectednode");if(this.contentDOM||!this.node.type.spec.draggable)this.dom.draggable=true}deselectNode(){if(this.nodeDOM.nodeType==1)this.nodeDOM.classList.remove("ProseMirror-selectednode");if(this.contentDOM||!this.node.type.spec.draggable)this.dom.removeAttribute("draggable")}get domAtom(){return this.node.isAtom}}function Or(t,e,i,r,n){Ir(r,e,t);let s=new Sr(undefined,t,e,i,r,r,r,n,0);if(s.contentDOM)s.updateChildren(n,0);return s}class Er extends Sr{constructor(t,e,i,r,n,s,l){super(t,e,i,r,n,null,s,l,0)}parseRule(){let t=this.nodeDOM.parentNode;while(t&&t!=this.dom&&!t.pmIsDeco)t=t.parentNode;return{skip:t||true}}update(t,e,i,r){if(this.dirty==vr||this.dirty!=wr&&!this.inParent()||!t.sameMarkup(this.node))return false;this.updateOuterDeco(e);if((this.dirty!=wr||t.text!=this.node.text)&&t.text!=this.nodeDOM.nodeValue){this.nodeDOM.nodeValue=t.text;if(r.trackWrites==this.nodeDOM)r.trackWrites=null}this.node=t;this.dirty=wr;return true}inParent(){let t=this.parent.contentDOM;for(let e=this.nodeDOM;e;e=e.parentNode)if(e==t)return true;return false}domFromPos(t){return{node:this.nodeDOM,offset:t}}localPosFromDOM(t,e,i){if(t==this.nodeDOM)return this.posAtStart+Math.min(e,this.node.text.length);return super.localPosFromDOM(t,e,i)}ignoreMutation(t){return t.type!="characterData"&&t.type!="selection"}slice(t,e,i){let r=this.node.cut(t,e),n=document.createTextNode(r.text);return new Er(this.parent,r,this.outerDeco,this.innerDeco,n,n,i)}markDirty(t,e){super.markDirty(t,e);if(this.dom!=this.nodeDOM&&(t==0||e==this.nodeDOM.nodeValue.length))this.dirty=vr}get domAtom(){return false}}class Dr extends yr{parseRule(){return{ignore:true}}matchesHack(t){return this.dirty==wr&&this.dom.nodeName==t}get domAtom(){return true}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Nr extends Sr{constructor(t,e,i,r,n,s,l,f,o,u){super(t,e,i,r,n,s,l,o,u);this.spec=f}update(t,e,i,r){if(this.dirty==vr)return false;if(this.spec.update){let n=this.spec.update(t,e,i);if(n)this.updateInner(t,e,i,r);return n}else if(!this.contentDOM&&!t.isLeaf){return false}else{return super.update(t,e,i,r)}}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(t,e,i,r){this.spec.setSelection?this.spec.setSelection(t,e,i):super.setSelection(t,e,i,r)}destroy(){if(this.spec.destroy)this.spec.destroy();super.destroy()}stopEvent(t){return this.spec.stopEvent?this.spec.stopEvent(t):false}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}}function $r(t,e,i){let r=t.firstChild,n=false;for(let s=0;s<e.length;s++){let l=e[s],f=l.dom;if(f.parentNode==t){while(f!=r){r=zr(r);n=true}r=r.nextSibling}else{n=true;t.insertBefore(f,r)}if(l instanceof xr){let e=r?r.previousSibling:t.lastChild;$r(l.contentDOM,l.children,i);r=e?e.nextSibling:t.firstChild}}while(r){r=zr(r);n=true}if(n&&i.trackWrites==t)i.trackWrites=null}const Rr=function(t){if(t)this.nodeName=t};Rr.prototype=Object.create(null);const qr=[new Rr];function Cr(t,e,i){if(t.length==0)return qr;let r=i?qr[0]:new Rr,n=[r];for(let s=0;s<t.length;s++){let l=t[s].type.attrs;if(!l)continue;if(l.nodeName)n.push(r=new Rr(l.nodeName));for(let t in l){let s=l[t];if(s==null)continue;if(i&&n.length==1)n.push(r=new Rr(e.isInline?"span":"div"));if(t=="class")r.class=(r.class?r.class+" ":"")+s;else if(t=="style")r.style=(r.style?r.style+";":"")+s;else if(t!="nodeName")r[t]=s}}return n}function Tr(t,e,i,r){if(i==qr&&r==qr)return e;let n=e;for(let e=0;e<r.length;e++){let s=r[e],l=i[e];if(e){let e;if(l&&l.nodeName==s.nodeName&&n!=t&&(e=n.parentNode)&&e.nodeName.toLowerCase()==s.nodeName){n=e}else{e=document.createElement(s.nodeName);e.pmIsDeco=true;e.appendChild(n);l=qr[0];n=e}}Ar(n,l||qr[0],s)}return n}function Ar(t,e,i){for(let r in e)if(r!="class"&&r!="style"&&r!="nodeName"&&!(r in i))t.removeAttribute(r);for(let r in i)if(r!="class"&&r!="style"&&r!="nodeName"&&i[r]!=e[r])t.setAttribute(r,i[r]);if(e.class!=i.class){let r=e.class?e.class.split(" ").filter(Boolean):[];let n=i.class?i.class.split(" ").filter(Boolean):[];for(let e=0;e<r.length;e++)if(n.indexOf(r[e])==-1)t.classList.remove(r[e]);for(let e=0;e<n.length;e++)if(r.indexOf(n[e])==-1)t.classList.add(n[e]);if(t.classList.length==0)t.removeAttribute("class")}if(e.style!=i.style){if(e.style){let i=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,r;while(r=i.exec(e.style))t.style.removeProperty(r[1])}if(i.style)t.style.cssText+=i.style}}function Ir(t,e,i){return Tr(t,t,qr,Cr(e,i,t.nodeType!=1))}function Pr(t,e){if(t.length!=e.length)return false;for(let i=0;i<t.length;i++)if(!t[i].type.eq(e[i].type))return false;return true}function zr(t){let e=t.nextSibling;t.parentNode.removeChild(t);return e}class Jr{constructor(t,e,i){this.lock=e;this.view=i;this.index=0;this.stack=[];this.changed=false;this.top=t;this.preMatch=Br(t.node.content,t)}destroyBetween(t,e){if(t==e)return;for(let i=t;i<e;i++)this.top.children[i].destroy();this.top.children.splice(t,e-t);this.changed=true}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(t,e,i){let r=0,n=this.stack.length>>1;let s=Math.min(n,t.length);while(r<s&&(r==n-1?this.top:this.stack[r+1<<1]).matchesMark(t[r])&&t[r].type.spec.spanning!==false)r++;while(r<n){this.destroyRest();this.top.dirty=wr;this.index=this.stack.pop();this.top=this.stack.pop();n--}while(n<t.length){this.stack.push(this.top,this.index+1);let r=-1;for(let e=this.index;e<Math.min(this.index+3,this.top.children.length);e++){let i=this.top.children[e];if(i.matchesMark(t[n])&&!this.isLocked(i.dom)){r=e;break}}if(r>-1){if(r>this.index){this.changed=true;this.destroyBetween(this.index,r)}this.top=this.top.children[this.index]}else{let r=xr.create(this.top,t[n],e,i);this.top.children.splice(this.index,0,r);this.top=r;this.changed=true}this.index=0;n++}}findNodeMatch(t,e,i,r){let n=-1,s;if(r>=this.preMatch.index&&(s=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&s.matchesNode(t,e,i)){n=this.top.children.indexOf(s,this.index)}else{for(let r=this.index,s=Math.min(this.top.children.length,r+5);r<s;r++){let s=this.top.children[r];if(s.matchesNode(t,e,i)&&!this.preMatch.matched.has(s)){n=r;break}}}if(n<0)return false;this.destroyBetween(this.index,n);this.index++;return true}updateNodeAt(t,e,i,r,n){let s=this.top.children[r];if(s.dirty==vr&&s.dom==s.contentDOM)s.dirty=br;if(!s.update(t,e,i,n))return false;this.destroyBetween(this.index,r);this.index++;return true}findIndexWithChild(t){for(;;){let e=t.parentNode;if(!e)return-1;if(e==this.top.contentDOM){let e=t.pmViewDesc;if(e)for(let t=this.index;t<this.top.children.length;t++){if(this.top.children[t]==e)return t}return-1}t=e}}updateNextNode(t,e,i,r,n,s){for(let l=this.index;l<this.top.children.length;l++){let f=this.top.children[l];if(f instanceof Sr){let o=this.preMatch.matched.get(f);if(o!=null&&o!=n)return false;let u=f.dom,h;let a=this.isLocked(u)&&!(t.isText&&f.node&&f.node.isText&&f.nodeDOM.nodeValue==t.text&&f.dirty!=vr&&Pr(e,f.outerDeco));if(!a&&f.update(t,e,i,r)){this.destroyBetween(this.index,l);if(f.dom!=u)this.changed=true;this.index++;return true}else if(!a&&(h=this.recreateWrapper(f,t,e,i,r,s))){this.top.children[this.index]=h;if(h.contentDOM){h.dirty=br;h.updateChildren(r,s+1);h.dirty=wr}this.changed=true;this.index++;return true}break}}return false}recreateWrapper(t,e,i,r,n,s){if(t.dirty||e.isAtom||!t.children.length||!t.node.content.eq(e.content))return null;let l=Sr.create(this.top,e,i,r,n,s);if(l.contentDOM){l.children=t.children;t.children=[];for(let t of l.children)t.parent=l}t.destroy();return l}addNode(t,e,i,r,n){let s=Sr.create(this.top,t,e,i,r,n);if(s.contentDOM)s.updateChildren(r,n+1);this.top.children.splice(this.index++,0,s);this.changed=true}placeWidget(t,e,i){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(r&&r.matchesWidget(t)&&(t==r.widget||!r.widget.type.toDOM.parentNode)){this.index++}else{let r=new kr(this.top,t,e,i);this.top.children.splice(this.index++,0,r);this.changed=true}}addTextblockHacks(){let t=this.top.children[this.index-1],e=this.top;while(t instanceof xr){e=t;t=e.children[e.children.length-1]}if(!t||!(t instanceof Er)||/\n$/.test(t.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(t.node.text)){if((qi||$i)&&t&&t.dom.contentEditable=="false")this.addHackNode("IMG",e);this.addHackNode("BR",this.top)}}addHackNode(t,e){if(e==this.top&&this.index<e.children.length&&e.children[this.index].matchesHack(t)){this.index++}else{let i=document.createElement(t);if(t=="IMG"){i.className="ProseMirror-separator";i.alt=""}if(t=="BR")i.className="ProseMirror-trailingBreak";let r=new Dr(this.top,[],i,null);if(e!=this.top)e.children.push(r);else e.children.splice(this.index++,0,r);this.changed=true}}isLocked(t){return this.lock&&(t==this.lock||t.nodeType==1&&t.contains(this.lock.parentNode))}}function Br(t,e){let i=e,r=i.children.length;let n=t.childCount,s=new Map,l=[];t:while(n>0){let f;for(;;){if(r){let t=i.children[r-1];if(t instanceof xr){i=t;r=t.children.length}else{f=t;r--;break}}else if(i==e){break t}else{r=i.parent.children.indexOf(i);i=i.parent}}let o=f.node;if(!o)continue;if(o!=t.child(n-1))break;--n;s.set(f,n);l.push(f)}return{index:n,matched:s,matches:l.reverse()}}function jr(t,e){return t.type.side-e.type.side}function Fr(t,e,i,r){let n=e.locals(t),s=0;if(n.length==0){for(let i=0;i<t.childCount;i++){let l=t.child(i);r(l,n,e.forChild(s,l),i);s+=l.nodeSize}return}let l=0,f=[],o=null;for(let u=0;;){let h,a;while(l<n.length&&n[l].to==s){let t=n[l++];if(t.widget){if(!h)h=t;else(a||(a=[h])).push(t)}}if(h){if(a){a.sort(jr);for(let t=0;t<a.length;t++)i(a[t],u,!!o)}else{i(h,u,!!o)}}let c,d;if(o){d=-1;c=o;o=null}else if(u<t.childCount){d=u;c=t.child(u++)}else{break}for(let t=0;t<f.length;t++)if(f[t].to<=s)f.splice(t--,1);while(l<n.length&&n[l].from<=s&&n[l].to>s)f.push(n[l++]);let p=s+c.nodeSize;if(c.isText){let t=p;if(l<n.length&&n[l].from<t)t=n[l].from;for(let e=0;e<f.length;e++)if(f[e].to<t)t=f[e].to;if(t<p){o=c.cut(t-s);c=c.cut(0,t-s);p=t;d=-1}}else{while(l<n.length&&n[l].to<p)l++}let m=c.isInline&&!c.isLeaf?f.filter((t=>!t.inline)):f.slice();r(c,m,e.forChild(s,c),d);s=p}}function Lr(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important";window.getComputedStyle(t).listStyle;t.style.cssText=e}}function Wr(t,e){for(;;){if(t.nodeType==3)return t;if(t.nodeType==1&&e>0){if(t.childNodes.length>e&&t.childNodes[e].nodeType==3)return t.childNodes[e];t=t.childNodes[e-1];e=ci(t)}else if(t.nodeType==1&&e<t.childNodes.length){t=t.childNodes[e];e=0}else{return null}}}function _r(t,e,i,r){for(let n=0,s=0;n<t.childCount&&s<=r;){let l=t.child(n++),f=s;s+=l.nodeSize;if(!l.isText)continue;let o=l.text;while(n<t.childCount){let e=t.child(n++);s+=e.nodeSize;if(!e.isText)break;o+=e.text}if(s>=i){if(s>=r&&o.slice(r-e.length-f,r-f)==e)return r-e.length;let t=f<r?o.lastIndexOf(e,r-f-1):-1;if(t>=0&&t+e.length+f>=i)return f+t;if(i==r&&o.length>=r+e.length-f&&o.slice(r-f,r-f+e.length)==e)return r}}return-1}function Ur(t,e,i,r,n){let s=[];for(let l=0,f=0;l<t.length;l++){let o=t[l],u=f,h=f+=o.size;if(u>=i||h<=e){s.push(o)}else{if(u<e)s.push(o.slice(0,e-u,r));if(n){s.push(n);n=undefined}if(h>i)s.push(o.slice(i-u,o.size,r))}}return s}function Kr(t,e=null){let i=t.domSelectionRange(),r=t.state.doc;if(!i.focusNode)return null;let n=t.docView.nearestDesc(i.focusNode),s=n&&n.size==0;let l=t.docView.posFromDOM(i.focusNode,i.focusOffset,1);if(l<0)return null;let f=r.resolve(l),o,u;if(mi(i)){o=f;while(n&&!n.node)n=n.parent;let t=n.node;if(n&&t.isAtom&&Be.isSelectable(t)&&n.parent&&!(t.isInline&&di(i.focusNode,i.focusOffset,n.dom))){let t=n.posBefore;u=new Be(l==t?f:r.resolve(t))}}else{let e=t.docView.posFromDOM(i.anchorNode,i.anchorOffset,1);if(e<0)return null;o=r.resolve(e)}if(!u){let i=e=="pointer"||t.state.selection.head<f.pos&&!s?1:-1;u=nn(t,o,f,i)}return u}function Hr(t){return t.editable?t.hasFocus():ln(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Gr(t,e=false){let i=t.state.selection;en(t,i);if(!Hr(t))return;if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&$i){let e=t.domSelectionRange(),i=t.domObserver.currentSelection;if(e.anchorNode&&i.anchorNode&&ui(e.anchorNode,e.anchorOffset,i.anchorNode,i.anchorOffset)){t.input.mouseDown.delayedSelectionSync=true;t.domObserver.setCurSelection();return}}t.domObserver.disconnectSelection();if(t.cursorWrapper){tn(t)}else{let{anchor:r,head:n}=i,s,l;if(Vr&&!(i instanceof ze)){if(!i.$from.parent.inlineContent)s=Xr(t,i.from);if(!i.empty&&!i.$from.parent.inlineContent)l=Xr(t,i.to)}t.docView.setSelection(r,n,t.root,e);if(Vr){if(s)Qr(s);if(l)Qr(l)}if(i.visible){t.dom.classList.remove("ProseMirror-hideselection")}else{t.dom.classList.add("ProseMirror-hideselection");if("onselectionchange"in document)Zr(t)}}t.domObserver.setCurSelection();t.domObserver.connectSelection()}const Vr=qi||$i&&Ri<63;function Xr(t,e){let{node:i,offset:r}=t.docView.domFromPos(e,0);let n=r<i.childNodes.length?i.childNodes[r]:null;let s=r?i.childNodes[r-1]:null;if(qi&&n&&n.contentEditable=="false")return Yr(n);if((!n||n.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(n)return Yr(n);else if(s)return Yr(s)}}function Yr(t){t.contentEditable="true";if(qi&&t.draggable){t.draggable=false;t.wasDraggable=true}return t}function Qr(t){t.contentEditable="false";if(t.wasDraggable){t.draggable=true;t.wasDraggable=null}}function Zr(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let i=t.domSelectionRange();let r=i.anchorNode,n=i.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{if(i.anchorNode!=r||i.anchorOffset!=n){e.removeEventListener("selectionchange",t.input.hideSelectionGuard);setTimeout((()=>{if(!Hr(t)||t.state.selection.visible)t.dom.classList.remove("ProseMirror-hideselection")}),20)}})}function tn(t){let e=t.domSelection(),i=document.createRange();let r=t.cursorWrapper.dom,n=r.nodeName=="IMG";if(n)i.setEnd(r.parentNode,si(r)+1);else i.setEnd(r,0);i.collapse(false);e.removeAllRanges();e.addRange(i);if(!n&&!t.state.selection.visible&&Oi&&Ei<=11){r.disabled=true;r.disabled=false}}function en(t,e){if(e instanceof Be){let i=t.docView.descAt(e.from);if(i!=t.lastSelectedViewDesc){rn(t);if(i)i.selectNode();t.lastSelectedViewDesc=i}}else{rn(t)}}function rn(t){if(t.lastSelectedViewDesc){if(t.lastSelectedViewDesc.parent)t.lastSelectedViewDesc.deselectNode();t.lastSelectedViewDesc=undefined}}function nn(t,e,i,r){return t.someProp("createSelectionBetween",(r=>r(t,e,i)))||ze.between(e,i,r)}function sn(t){if(t.editable&&!t.hasFocus())return false;return ln(t)}function ln(t){let e=t.domSelectionRange();if(!e.anchorNode)return false;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch(t){return false}}function fn(t){let e=t.docView.domFromPos(t.state.selection.anchor,0);let i=t.domSelectionRange();return ui(e.node,e.offset,i.anchorNode,i.anchorOffset)}function on(t,e){let{$anchor:i,$head:r}=t.selection;let n=e>0?i.max(r):i.min(r);let s=!n.parent.inlineContent?n:n.depth?t.doc.resolve(e>0?n.after():n.before()):null;return s&&Te.findFrom(s,e)}function un(t,e){t.dispatch(t.state.tr.setSelection(e).scrollIntoView());return true}function hn(t,e,i){let r=t.state.selection;if(r instanceof ze){if(i.indexOf("s")>-1){let{$head:i}=r,n=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!n||n.isText||!n.isLeaf)return false;let s=t.state.doc.resolve(i.pos+n.nodeSize*(e<0?-1:1));return un(t,new ze(r.$anchor,s))}else if(!r.empty){return false}else if(t.endOfTextblock(e>0?"forward":"backward")){let i=on(t.state,e);if(i&&i instanceof Be)return un(t,i);return false}else if(!(Ti&&i.indexOf("m")>-1)){let i=r.$head,n=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,s;if(!n||n.isText)return false;let l=e<0?i.pos-n.nodeSize:i.pos;if(!(n.isAtom||(s=t.docView.descAt(l))&&!s.contentDOM))return false;if(Be.isSelectable(n)){return un(t,new Be(e<0?t.state.doc.resolve(i.pos-n.nodeSize):i))}else if(Pi){return un(t,new ze(t.state.doc.resolve(e<0?l:l+n.nodeSize)))}else{return false}}}else if(r instanceof Be&&r.node.isInline){return un(t,new ze(e>0?r.$to:r.$from))}else{let i=on(t.state,e);if(i)return un(t,i);return false}}function an(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function cn(t,e){let i=t.pmViewDesc;return i&&i.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function dn(t,e){return e<0?pn(t):mn(t)}function pn(t){let e=t.domSelectionRange();let i=e.focusNode,r=e.focusOffset;if(!i)return;let n,s,l=false;if(Di&&i.nodeType==1&&r<an(i)&&cn(i.childNodes[r],-1))l=true;for(;;){if(r>0){if(i.nodeType!=1){break}else{let t=i.childNodes[r-1];if(cn(t,-1)){n=i;s=--r}else if(t.nodeType==3){i=t;r=i.nodeValue.length}else break}}else if(wn(i)){break}else{let e=i.previousSibling;while(e&&cn(e,-1)){n=i.parentNode;s=si(e);e=e.previousSibling}if(!e){i=i.parentNode;if(i==t.dom)break;r=0}else{i=e;r=an(i)}}}if(l)vn(t,i,r);else if(n)vn(t,n,s)}function mn(t){let e=t.domSelectionRange();let i=e.focusNode,r=e.focusOffset;if(!i)return;let n=an(i);let s,l;for(;;){if(r<n){if(i.nodeType!=1)break;let t=i.childNodes[r];if(cn(t,1)){s=i;l=++r}else break}else if(wn(i)){break}else{let e=i.nextSibling;while(e&&cn(e,1)){s=e.parentNode;l=si(e)+1;e=e.nextSibling}if(!e){i=i.parentNode;if(i==t.dom)break;r=n=0}else{i=e;r=0;n=an(i)}}}if(s)vn(t,s,l)}function wn(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function gn(t,e){while(t&&e==t.childNodes.length&&!pi(t)){e=si(t)+1;t=t.parentNode}while(t&&e<t.childNodes.length){let i=t.childNodes[e];if(i.nodeType==3)return i;if(i.nodeType==1&&i.contentEditable=="false")break;t=i;e=0}}function bn(t,e){while(t&&!e&&!pi(t)){e=si(t);t=t.parentNode}while(t&&e){let i=t.childNodes[e-1];if(i.nodeType==3)return i;if(i.nodeType==1&&i.contentEditable=="false")break;t=i;e=t.childNodes.length}}function vn(t,e,i){if(e.nodeType!=3){let t,r;if(r=gn(e,i)){e=r;i=0}else if(t=bn(e,i)){e=t;i=t.nodeValue.length}}let r=t.domSelection();if(mi(r)){let t=document.createRange();t.setEnd(e,i);t.setStart(e,i);r.removeAllRanges();r.addRange(t)}else if(r.extend){r.extend(e,i)}t.domObserver.setCurSelection();let{state:n}=t;setTimeout((()=>{if(t.state==n)Gr(t)}),50)}function yn(t,e){let i=t.state.doc.resolve(e);if(!($i||Ai)&&i.parent.inlineContent){let r=t.coordsAtPos(e);if(e>i.start()){let i=t.coordsAtPos(e-1);let n=(i.top+i.bottom)/2;if(n>r.top&&n<r.bottom&&Math.abs(i.left-r.left)>1)return i.left<r.left?"ltr":"rtl"}if(e<i.end()){let i=t.coordsAtPos(e+1);let n=(i.top+i.bottom)/2;if(n>r.top&&n<r.bottom&&Math.abs(i.left-r.left)>1)return i.left>r.left?"ltr":"rtl"}}let r=getComputedStyle(t.dom).direction;return r=="rtl"?"rtl":"ltr"}function kn(t,e,i){let r=t.state.selection;if(r instanceof ze&&!r.empty||i.indexOf("s")>-1)return false;if(Ti&&i.indexOf("m")>-1)return false;let{$from:n,$to:s}=r;if(!n.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let i=on(t.state,e);if(i&&i instanceof Be)return un(t,i)}if(!n.parent.inlineContent){let i=e<0?n:s;let l=r instanceof Fe?Te.near(i,e):Te.findFrom(i,e);return l?un(t,l):false}return false}function Mn(t,e){if(!(t.state.selection instanceof ze))return true;let{$head:i,$anchor:r,empty:n}=t.state.selection;if(!i.sameParent(r))return true;if(!n)return false;if(t.endOfTextblock(e>0?"forward":"backward"))return true;let s=!i.textOffset&&(e<0?i.nodeBefore:i.nodeAfter);if(s&&!s.isText){let r=t.state.tr;if(e<0)r.delete(i.pos-s.nodeSize,i.pos);else r.delete(i.pos,i.pos+s.nodeSize);t.dispatch(r);return true}return false}function xn(t,e,i){t.domObserver.stop();e.contentEditable=i;t.domObserver.start()}function Sn(t){if(!qi||t.state.selection.$head.parentOffset>0)return false;let{focusNode:e,focusOffset:i}=t.domSelectionRange();if(e&&e.nodeType==1&&i==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let i=e.firstChild;xn(t,i,"true");setTimeout((()=>xn(t,i,"false")),20)}return false}function On(t){let e="";if(t.ctrlKey)e+="c";if(t.metaKey)e+="m";if(t.altKey)e+="a";if(t.shiftKey)e+="s";return e}function En(t,e){let i=e.keyCode,r=On(e);if(i==8||Ti&&i==72&&r=="c"){return Mn(t,-1)||dn(t,-1)}else if(i==46&&!e.shiftKey||Ti&&i==68&&r=="c"){return Mn(t,1)||dn(t,1)}else if(i==13||i==27){return true}else if(i==37||Ti&&i==66&&r=="c"){let e=i==37?yn(t,t.state.selection.from)=="ltr"?-1:1:-1;return hn(t,e,r)||dn(t,e)}else if(i==39||Ti&&i==70&&r=="c"){let e=i==39?yn(t,t.state.selection.from)=="ltr"?1:-1:1;return hn(t,e,r)||dn(t,e)}else if(i==38||Ti&&i==80&&r=="c"){return kn(t,-1,r)||dn(t,-1)}else if(i==40||Ti&&i==78&&r=="c"){return Sn(t)||kn(t,1,r)||dn(t,1)}else if(r==(Ti?"m":"c")&&(i==66||i==73||i==89||i==90)){return true}return false}function Dn(t,e){t.someProp("transformCopied",(i=>{e=i(e,t)}));let i=[],{content:r,openStart:n,openEnd:s}=e;while(n>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1){n--;s--;let t=r.firstChild;i.push(t.type.name,t.attrs!=t.type.defaultAttrs?t.attrs:null);r=t.content}let l=t.someProp("clipboardSerializer")||vt.fromSchema(t.state.schema);let f=Jn(),o=f.createElement("div");o.appendChild(l.serializeFragment(r,{document:f}));let u=o.firstChild,h,a=0;while(u&&u.nodeType==1&&(h=Pn[u.nodeName.toLowerCase()])){for(let t=h.length-1;t>=0;t--){let e=f.createElement(h[t]);while(o.firstChild)e.appendChild(o.firstChild);o.appendChild(e);a++}u=o.firstChild}if(u&&u.nodeType==1)u.setAttribute("data-pm-slice",`${n} ${s}${a?` -${a}`:""} ${JSON.stringify(i)}`);let c=t.someProp("clipboardTextSerializer",(i=>i(e,t)))||e.content.textBetween(0,e.content.size,"\n\n");return{dom:o,text:c}}function Nn(t,e,i,r,n){let s=n.parent.type.spec.code;let l,o;if(!i&&!e)return null;let u=e&&(r||s||!i);if(u){t.someProp("transformPastedText",(i=>{e=i(e,s||r,t)}));if(s)return e?new d(f.from(t.state.schema.text(e.replace(/\r\n?/g,"\n"))),0,0):d.empty;let i=t.someProp("clipboardTextParser",(i=>i(e,n,r,t)));if(i){o=i}else{let i=n.marks();let{schema:r}=t.state,s=vt.fromSchema(r);l=document.createElement("div");e.split(/(?:\r\n?|\n)+/).forEach((t=>{let e=l.appendChild(document.createElement("p"));if(t)e.appendChild(s.serializeNode(r.text(t,i)))}))}}else{t.someProp("transformPastedHTML",(e=>{i=e(i,t)}));l=Bn(i);if(Pi)jn(l)}let h=l&&l.querySelector("[data-pm-slice]");let a=h&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(h.getAttribute("data-pm-slice")||"");if(a&&a[3])for(let t=+a[3];t>0;t--){let t=l.firstChild;while(t&&t.nodeType!=1)t=t.nextSibling;if(!t)break;l=t}if(!o){let e=t.someProp("clipboardParser")||t.someProp("domParser")||rt.fromSchema(t.state.schema);o=e.parseSlice(l,{preserveWhitespace:!!(u||a),context:n,ruleFromNode(t){if(t.nodeName=="BR"&&!t.nextSibling&&t.parentNode&&!$n.test(t.parentNode.nodeName))return{ignore:true};return null}})}if(a){o=Fn(In(o,+a[1],+a[2]),a[4])}else{o=d.maxOpen(Rn(o.content,n),true);if(o.openStart||o.openEnd){let t=0,e=0;for(let e=o.content.firstChild;t<o.openStart&&!e.type.spec.isolating;t++,e=e.firstChild){}for(let t=o.content.lastChild;e<o.openEnd&&!t.type.spec.isolating;e++,t=t.lastChild){}o=In(o,t,e)}}t.someProp("transformPasted",(e=>{o=e(o,t)}));return o}const $n=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function Rn(t,e){if(t.childCount<2)return t;for(let i=e.depth;i>=0;i--){let r=e.node(i);let n=r.contentMatchAt(e.index(i));let s,l=[];t.forEach((t=>{if(!l)return;let e=n.findWrapping(t.type),i;if(!e)return l=null;if(i=l.length&&s.length&&Cn(e,s,t,l[l.length-1],0)){l[l.length-1]=i}else{if(l.length)l[l.length-1]=Tn(l[l.length-1],s.length);let i=qn(t,e);l.push(i);n=n.matchType(i.type);s=e}}));if(l)return f.from(l)}return t}function qn(t,e,i=0){for(let r=e.length-1;r>=i;r--)t=e[r].create(null,f.from(t));return t}function Cn(t,e,i,r,n){if(n<t.length&&n<e.length&&t[n]==e[n]){let s=Cn(t,e,i,r.lastChild,n+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));let l=r.contentMatchAt(r.childCount);if(l.matchType(n==t.length-1?i.type:t[n+1]))return r.copy(r.content.append(f.from(qn(i,t,n+1))))}}function Tn(t,e){if(e==0)return t;let i=t.content.replaceChild(t.childCount-1,Tn(t.lastChild,e-1));let r=t.contentMatchAt(t.childCount).fillBefore(f.empty,true);return t.copy(i.append(r))}function An(t,e,i,r,n,s){let l=e<0?t.firstChild:t.lastChild,o=l.content;if(t.childCount>1)s=0;if(n<r-1)o=An(o,e,i,r,n+1,s);if(n>=i)o=e<0?l.contentMatchAt(0).fillBefore(o,s<=n).append(o):o.append(l.contentMatchAt(l.childCount).fillBefore(f.empty,true));return t.replaceChild(e<0?0:t.childCount-1,l.copy(o))}function In(t,e,i){if(e<t.openStart)t=new d(An(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd);if(i<t.openEnd)t=new d(An(t.content,1,i,t.openEnd,0,0),t.openStart,i);return t}const Pn={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let zn=null;function Jn(){return zn||(zn=document.implementation.createHTMLDocument("title"))}function Bn(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);if(e)t=t.slice(e[0].length);let i=Jn().createElement("div");let r=/<([a-z][^>\s]+)/i.exec(t),n;if(n=r&&Pn[r[1].toLowerCase()])t=n.map((t=>"<"+t+">")).join("")+t+n.map((t=>"</"+t+">")).reverse().join("");i.innerHTML=t;if(n)for(let t=0;t<n.length;t++)i=i.querySelector(n[t])||i;return i}function jn(t){let e=t.querySelectorAll($i?"span:not([class]):not([style])":"span.Apple-converted-space");for(let i=0;i<e.length;i++){let r=e[i];if(r.childNodes.length==1&&r.textContent==" "&&r.parentNode)r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}function Fn(t,e){if(!t.size)return t;let i=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch(e){return t}let{content:n,openStart:s,openEnd:l}=t;for(let t=r.length-2;t>=0;t-=2){let e=i.nodes[r[t]];if(!e||e.hasRequiredAttrs())break;n=f.from(e.create(r[t+1],n));s++;l++}return new d(n,s,l)}const Ln={};const Wn={};const _n={touchstart:true,touchmove:true};class Un{constructor(){this.shiftKey=false;this.mouseDown=null;this.lastKeyCode=null;this.lastKeyCodeTime=0;this.lastClick={time:0,x:0,y:0,type:""};this.lastSelectionOrigin=null;this.lastSelectionTime=0;this.lastIOSEnter=0;this.lastIOSEnterFallbackTimeout=-1;this.lastFocus=0;this.lastTouch=0;this.lastAndroidDelete=0;this.composing=false;this.composingTimeout=-1;this.compositionNodes=[];this.compositionEndedAt=-2e8;this.compositionID=1;this.compositionPendingChanges=0;this.domChangeCount=0;this.eventHandlers=Object.create(null);this.hideSelectionGuard=null}}function Kn(t){for(let e in Ln){let i=Ln[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=e=>{if(Yn(t,e)&&!Xn(t,e)&&(t.editable||!(e.type in Wn)))i(t,e)},_n[e]?{passive:true}:undefined)}if(qi)t.dom.addEventListener("input",(()=>null));Vn(t)}function Hn(t,e){t.input.lastSelectionOrigin=e;t.input.lastSelectionTime=Date.now()}function Gn(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout);clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function Vn(t){t.someProp("handleDOMEvents",(e=>{for(let i in e)if(!t.input.eventHandlers[i])t.dom.addEventListener(i,t.input.eventHandlers[i]=e=>Xn(t,e))}))}function Xn(t,e){return t.someProp("handleDOMEvents",(i=>{let r=i[e.type];return r?r(t,e)||e.defaultPrevented:false}))}function Yn(t,e){if(!e.bubbles)return true;if(e.defaultPrevented)return false;for(let i=e.target;i!=t.dom;i=i.parentNode)if(!i||i.nodeType==11||i.pmViewDesc&&i.pmViewDesc.stopEvent(e))return false;return true}function Qn(t,e){if(!Xn(t,e)&&Ln[e.type]&&(t.editable||!(e.type in Wn)))Ln[e.type](t,e)}Wn.keydown=(t,e)=>{let i=e;t.input.shiftKey=i.keyCode==16||i.shiftKey;if(ds(t,i))return;t.input.lastKeyCode=i.keyCode;t.input.lastKeyCodeTime=Date.now();if(Ii&&$i&&i.keyCode==13)return;if(i.keyCode!=229)t.domObserver.forceFlush();if(Ci&&i.keyCode==13&&!i.ctrlKey&&!i.altKey&&!i.metaKey){let e=Date.now();t.input.lastIOSEnter=e;t.input.lastIOSEnterFallbackTimeout=setTimeout((()=>{if(t.input.lastIOSEnter==e){t.someProp("handleKeyDown",(e=>e(t,wi(13,"Enter"))));t.input.lastIOSEnter=0}}),200)}else if(t.someProp("handleKeyDown",(e=>e(t,i)))||En(t,i)){i.preventDefault()}else{Hn(t,"key")}};Wn.keyup=(t,e)=>{if(e.keyCode==16)t.input.shiftKey=false};Wn.keypress=(t,e)=>{let i=e;if(ds(t,i)||!i.charCode||i.ctrlKey&&!i.altKey||Ti&&i.metaKey)return;if(t.someProp("handleKeyPress",(e=>e(t,i)))){i.preventDefault();return}let r=t.state.selection;if(!(r instanceof ze)||!r.$from.sameParent(r.$to)){let e=String.fromCharCode(i.charCode);if(!/[\r\n]/.test(e)&&!t.someProp("handleTextInput",(i=>i(t,r.$from.pos,r.$to.pos,e))))t.dispatch(t.state.tr.insertText(e).scrollIntoView());i.preventDefault()}};function Zn(t){return{left:t.clientX,top:t.clientY}}function ts(t,e){let i=e.x-t.clientX,r=e.y-t.clientY;return i*i+r*r<100}function es(t,e,i,r,n){if(r==-1)return false;let s=t.state.doc.resolve(r);for(let r=s.depth+1;r>0;r--){if(t.someProp(e,(e=>r>s.depth?e(t,i,s.nodeAfter,s.before(r),n,true):e(t,i,s.node(r),s.before(r),n,false))))return true}return false}function is(t,e,i){if(!t.focused)t.focus();let r=t.state.tr.setSelection(e);if(i=="pointer")r.setMeta("pointer",true);t.dispatch(r)}function rs(t,e){if(e==-1)return false;let i=t.state.doc.resolve(e),r=i.nodeAfter;if(r&&r.isAtom&&Be.isSelectable(r)){is(t,new Be(i),"pointer");return true}return false}function ns(t,e){if(e==-1)return false;let i=t.state.selection,r,n;if(i instanceof Be)r=i.node;let s=t.state.doc.resolve(e);for(let t=s.depth+1;t>0;t--){let e=t>s.depth?s.nodeAfter:s.node(t);if(Be.isSelectable(e)){if(r&&i.$from.depth>0&&t>=i.$from.depth&&s.before(i.$from.depth+1)==i.$from.pos)n=s.before(i.$from.depth);else n=s.before(t);break}}if(n!=null){is(t,Be.create(t.state.doc,n),"pointer");return true}else{return false}}function ss(t,e,i,r,n){return es(t,"handleClickOn",e,i,r)||t.someProp("handleClick",(i=>i(t,e,r)))||(n?ns(t,i):rs(t,i))}function ls(t,e,i,r){return es(t,"handleDoubleClickOn",e,i,r)||t.someProp("handleDoubleClick",(i=>i(t,e,r)))}function fs(t,e,i,r){return es(t,"handleTripleClickOn",e,i,r)||t.someProp("handleTripleClick",(i=>i(t,e,r)))||us(t,i,r)}function us(t,e,i){if(i.button!=0)return false;let r=t.state.doc;if(e==-1){if(r.inlineContent){is(t,ze.create(r,0,r.content.size),"pointer");return true}return false}let n=r.resolve(e);for(let e=n.depth+1;e>0;e--){let i=e>n.depth?n.nodeAfter:n.node(e);let s=n.before(e);if(i.inlineContent)is(t,ze.create(r,s+1,s+1+i.content.size),"pointer");else if(Be.isSelectable(i))is(t,Be.create(r,s),"pointer");else continue;return true}}function hs(t){return bs(t)}const as=Ti?"metaKey":"ctrlKey";Ln.mousedown=(t,e)=>{let i=e;t.input.shiftKey=i.shiftKey;let r=hs(t);let n=Date.now(),s="singleClick";if(n-t.input.lastClick.time<500&&ts(i,t.input.lastClick)&&!i[as]){if(t.input.lastClick.type=="singleClick")s="doubleClick";else if(t.input.lastClick.type=="doubleClick")s="tripleClick"}t.input.lastClick={time:n,x:i.clientX,y:i.clientY,type:s};let l=t.posAtCoords(Zn(i));if(!l)return;if(s=="singleClick"){if(t.input.mouseDown)t.input.mouseDown.done();t.input.mouseDown=new cs(t,l,i,!!r)}else if((s=="doubleClick"?ls:fs)(t,l.pos,l.inside,i)){i.preventDefault()}else{Hn(t,"pointer")}};class cs{constructor(t,e,i,r){this.view=t;this.pos=e;this.event=i;this.flushed=r;this.delayedSelectionSync=false;this.mightDrag=null;this.startDoc=t.state.doc;this.selectNode=!!i[as];this.allowDefault=i.shiftKey;let n,s;if(e.inside>-1){n=t.state.doc.nodeAt(e.inside);s=e.inside}else{let i=t.state.doc.resolve(e.pos);n=i.parent;s=i.depth?i.before():0}const l=r?null:i.target;const f=l?t.docView.nearestDesc(l,true):null;this.target=f?f.dom:null;let{selection:o}=t.state;if(i.button==0&&n.type.spec.draggable&&n.type.spec.selectable!==false||o instanceof Be&&o.from<=s&&o.to>s)this.mightDrag={node:n,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Di&&!this.target.hasAttribute("contentEditable"))};if(this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)){this.view.domObserver.stop();if(this.mightDrag.addAttr)this.target.draggable=true;if(this.mightDrag.setUneditable)setTimeout((()=>{if(this.view.input.mouseDown==this)this.target.setAttribute("contentEditable","false")}),20);this.view.domObserver.start()}t.root.addEventListener("mouseup",this.up=this.up.bind(this));t.root.addEventListener("mousemove",this.move=this.move.bind(this));Hn(t,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up);this.view.root.removeEventListener("mousemove",this.move);if(this.mightDrag&&this.target){this.view.domObserver.stop();if(this.mightDrag.addAttr)this.target.removeAttribute("draggable");if(this.mightDrag.setUneditable)this.target.removeAttribute("contentEditable");this.view.domObserver.start()}if(this.delayedSelectionSync)setTimeout((()=>Gr(this.view)));this.view.input.mouseDown=null}up(t){this.done();if(!this.view.dom.contains(t.target))return;let e=this.pos;if(this.view.state.doc!=this.startDoc)e=this.view.posAtCoords(Zn(t));this.updateAllowDefault(t);if(this.allowDefault||!e){Hn(this.view,"pointer")}else if(ss(this.view,e.pos,e.inside,t,this.selectNode)){t.preventDefault()}else if(t.button==0&&(this.flushed||qi&&this.mightDrag&&!this.mightDrag.node.isAtom||$i&&!this.view.state.selection.visible&&Math.min(Math.abs(e.pos-this.view.state.selection.from),Math.abs(e.pos-this.view.state.selection.to))<=2)){is(this.view,Te.near(this.view.state.doc.resolve(e.pos)),"pointer");t.preventDefault()}else{Hn(this.view,"pointer")}}move(t){this.updateAllowDefault(t);Hn(this.view,"pointer");if(t.buttons==0)this.done()}updateAllowDefault(t){if(!this.allowDefault&&(Math.abs(this.event.x-t.clientX)>4||Math.abs(this.event.y-t.clientY)>4))this.allowDefault=true}}Ln.touchstart=t=>{t.input.lastTouch=Date.now();hs(t);Hn(t,"pointer")};Ln.touchmove=t=>{t.input.lastTouch=Date.now();Hn(t,"pointer")};Ln.contextmenu=t=>hs(t);function ds(t,e){if(t.composing)return true;if(qi&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500){t.input.compositionEndedAt=-2e8;return true}return false}const ps=Ii?5e3:-1;Wn.compositionstart=Wn.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,i=e.selection.$from;if(e.selection.empty&&(e.storedMarks||!i.textOffset&&i.parentOffset&&i.nodeBefore.marks.some((t=>t.type.spec.inclusive===false)))){t.markCursor=t.state.storedMarks||i.marks();bs(t,true);t.markCursor=null}else{bs(t);if(Di&&e.selection.empty&&i.parentOffset&&!i.textOffset&&i.nodeBefore.marks.length){let e=t.domSelectionRange();for(let i=e.focusNode,r=e.focusOffset;i&&i.nodeType==1&&r!=0;){let e=r<0?i.lastChild:i.childNodes[r-1];if(!e)break;if(e.nodeType==3){t.domSelection().collapse(e,e.nodeValue.length);break}else{i=e;r=-1}}}}t.input.composing=true}ms(t,ps)};Wn.compositionend=(t,e)=>{if(t.composing){t.input.composing=false;t.input.compositionEndedAt=e.timeStamp;t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0;if(t.input.compositionPendingChanges)Promise.resolve().then((()=>t.domObserver.flush()));t.input.compositionID++;ms(t,20)}};function ms(t,e){clearTimeout(t.input.composingTimeout);if(e>-1)t.input.composingTimeout=setTimeout((()=>bs(t)),e)}function ws(t){if(t.composing){t.input.composing=false;t.input.compositionEndedAt=gs()}while(t.input.compositionNodes.length>0)t.input.compositionNodes.pop().markParentsDirty()}function gs(){let t=document.createEvent("Event");t.initEvent("event",true,true);return t.timeStamp}function bs(t,e=false){if(Ii&&t.domObserver.flushingSoon>=0)return;t.domObserver.forceFlush();ws(t);if(e||t.docView&&t.docView.dirty){let e=Kr(t);if(e&&!e.eq(t.state.selection))t.dispatch(t.state.tr.setSelection(e));else t.updateState(t.state);return true}return false}function vs(t,e){if(!t.dom.parentNode)return;let i=t.dom.parentNode.appendChild(document.createElement("div"));i.appendChild(e);i.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),n=document.createRange();n.selectNodeContents(e);t.dom.blur();r.removeAllRanges();r.addRange(n);setTimeout((()=>{if(i.parentNode)i.parentNode.removeChild(i);t.focus()}),50)}const ys=Oi&&Ei<15||Ci&&zi<604;Ln.copy=Wn.cut=(t,e)=>{let i=e;let r=t.state.selection,n=i.type=="cut";if(r.empty)return;let s=ys?null:i.clipboardData;let l=r.content(),{dom:f,text:o}=Dn(t,l);if(s){i.preventDefault();s.clearData();s.setData("text/html",f.innerHTML);s.setData("text/plain",o)}else{vs(t,f)}if(n)t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function ks(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function Ms(t,e){if(!t.dom.parentNode)return;let i=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code;let r=t.dom.parentNode.appendChild(document.createElement(i?"textarea":"div"));if(!i)r.contentEditable="true";r.style.cssText="position: fixed; left: -10000px; top: 10px";r.focus();let n=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout((()=>{t.focus();if(r.parentNode)r.parentNode.removeChild(r);if(i)xs(t,r.value,null,n,e);else xs(t,r.textContent,r.innerHTML,n,e)}),50)}function xs(t,e,i,r,n){let s=Nn(t,e,i,r,t.state.selection.$from);if(t.someProp("handlePaste",(e=>e(t,n,s||d.empty))))return true;if(!s)return false;let l=ks(s);let f=l?t.state.tr.replaceSelectionWith(l,r):t.state.tr.replaceSelection(s);t.dispatch(f.scrollIntoView().setMeta("paste",true).setMeta("uiEvent","paste"));return true}function Ss(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let i=t.getData("text/uri-list");return i?i.replace(/\r?\n/g," "):""}Wn.paste=(t,e)=>{let i=e;if(t.composing&&!Ii)return;let r=ys?null:i.clipboardData;let n=t.input.shiftKey&&t.input.lastKeyCode!=45;if(r&&xs(t,Ss(r),r.getData("text/html"),n,i))i.preventDefault();else Ms(t,i)};class Os{constructor(t,e,i){this.slice=t;this.move=e;this.node=i}}const Es=Ti?"altKey":"ctrlKey";Ln.dragstart=(t,e)=>{let i=e;let r=t.input.mouseDown;if(r)r.done();if(!i.dataTransfer)return;let n=t.state.selection;let s=n.empty?null:t.posAtCoords(Zn(i));let l;if(s&&s.pos>=n.from&&s.pos<=(n instanceof Be?n.to-1:n.to));else if(r&&r.mightDrag){l=Be.create(t.state.doc,r.mightDrag.pos)}else if(i.target&&i.target.nodeType==1){let e=t.docView.nearestDesc(i.target,true);if(e&&e.node.type.spec.draggable&&e!=t.docView)l=Be.create(t.state.doc,e.posBefore)}let f=(l||t.state.selection).content(),{dom:o,text:u}=Dn(t,f);i.dataTransfer.clearData();i.dataTransfer.setData(ys?"Text":"text/html",o.innerHTML);i.dataTransfer.effectAllowed="copyMove";if(!ys)i.dataTransfer.setData("text/plain",u);t.dragging=new Os(f,!i[Es],l)};Ln.dragend=t=>{let e=t.dragging;window.setTimeout((()=>{if(t.dragging==e)t.dragging=null}),50)};Wn.dragover=Wn.dragenter=(t,e)=>e.preventDefault();Wn.drop=(t,e)=>{let i=e;let r=t.dragging;t.dragging=null;if(!i.dataTransfer)return;let n=t.posAtCoords(Zn(i));if(!n)return;let s=t.state.doc.resolve(n.pos);let l=r&&r.slice;if(l){t.someProp("transformPasted",(e=>{l=e(l,t)}))}else{l=Nn(t,Ss(i.dataTransfer),ys?null:i.dataTransfer.getData("text/html"),false,s)}let f=!!(r&&!i[Es]);if(t.someProp("handleDrop",(e=>e(t,i,l||d.empty,f)))){i.preventDefault();return}if(!l)return;i.preventDefault();let o=l?ce(t.state.doc,s.pos,l):s.pos;if(o==null)o=s.pos;let u=t.state.tr;if(f){let{node:t}=r;if(t)t.replace(u);else u.deleteSelection()}let h=u.mapping.map(o);let a=l.openStart==0&&l.openEnd==0&&l.content.childCount==1;let c=u.doc;if(a)u.replaceRangeWith(h,h,l.content.firstChild);else u.replaceRange(h,h,l);if(u.doc.eq(c))return;let p=u.doc.resolve(h);if(a&&Be.isSelectable(l.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(l.content.firstChild)){u.setSelection(new Be(p))}else{let e=u.mapping.map(o);u.mapping.maps[u.mapping.maps.length-1].forEach(((t,i,r,n)=>e=n));u.setSelection(nn(t,p,u.doc.resolve(e)))}t.focus();t.dispatch(u.setMeta("uiEvent","drop"))};Ln.focus=t=>{t.input.lastFocus=Date.now();if(!t.focused){t.domObserver.stop();t.dom.classList.add("ProseMirror-focused");t.domObserver.start();t.focused=true;setTimeout((()=>{if(t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange()))Gr(t)}),20)}};Ln.blur=(t,e)=>{let i=e;if(t.focused){t.domObserver.stop();t.dom.classList.remove("ProseMirror-focused");t.domObserver.start();if(i.relatedTarget&&t.dom.contains(i.relatedTarget))t.domObserver.currentSelection.clear();t.focused=false}};Ln.beforeinput=(t,e)=>{let i=e;if($i&&Ii&&i.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:e}=t.input;setTimeout((()=>{if(t.input.domChangeCount!=e)return;t.dom.blur();t.focus();if(t.someProp("handleKeyDown",(e=>e(t,wi(8,"Backspace")))))return;let{$cursor:i}=t.state.selection;if(i&&i.pos>0)t.dispatch(t.state.tr.delete(i.pos-1,i.pos).scrollIntoView())}),50)}};for(let t in Wn)Ln[t]=Wn[t];function Ds(t,e){if(t==e)return true;for(let i in t)if(t[i]!==e[i])return false;for(let i in e)if(!(i in t))return false;return true}class Ns{constructor(t,e){this.toDOM=t;this.spec=e||Ts;this.side=this.spec.side||0}map(t,e,i,r){let{pos:n,deleted:s}=t.mapResult(e.from+r,this.side<0?-1:1);return s?null:new qs(n-i,n-i,this)}valid(){return true}eq(t){return this==t||t instanceof Ns&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&Ds(this.spec,t.spec))}destroy(t){if(this.spec.destroy)this.spec.destroy(t)}}class $s{constructor(t,e){this.attrs=t;this.spec=e||Ts}map(t,e,i,r){let n=t.map(e.from+r,this.spec.inclusiveStart?-1:1)-i;let s=t.map(e.to+r,this.spec.inclusiveEnd?1:-1)-i;return n>=s?null:new qs(n,s,this)}valid(t,e){return e.from<e.to}eq(t){return this==t||t instanceof $s&&Ds(this.attrs,t.attrs)&&Ds(this.spec,t.spec)}static is(t){return t.type instanceof $s}destroy(){}}class Rs{constructor(t,e){this.attrs=t;this.spec=e||Ts}map(t,e,i,r){let n=t.mapResult(e.from+r,1);if(n.deleted)return null;let s=t.mapResult(e.to+r,-1);if(s.deleted||s.pos<=n.pos)return null;return new qs(n.pos-i,s.pos-i,this)}valid(t,e){let{index:i,offset:r}=t.content.findIndex(e.from),n;return r==e.from&&!(n=t.child(i)).isText&&r+n.nodeSize==e.to}eq(t){return this==t||t instanceof Rs&&Ds(this.attrs,t.attrs)&&Ds(this.spec,t.spec)}destroy(){}}class qs{constructor(t,e,i){this.from=t;this.to=e;this.type=i}copy(t,e){return new qs(t,e,this.type)}eq(t,e=0){return this.type.eq(t.type)&&this.from+e==t.from&&this.to+e==t.to}map(t,e,i){return this.type.map(t,this,e,i)}static widget(t,e,i){return new qs(t,t,new Ns(e,i))}static inline(t,e,i,r){return new qs(t,e,new $s(i,r))}static node(t,e,i,r){return new qs(t,e,new Rs(i,r))}get spec(){return this.type.spec}get inline(){return this.type instanceof $s}get widget(){return this.type instanceof Ns}}const Cs=[],Ts={};class As{constructor(t,e){this.local=t.length?t:Cs;this.children=e.length?e:Cs}static create(t,e){return e.length?Ls(e,t,0,Ts):Is}find(t,e,i){let r=[];this.findInner(t==null?0:t,e==null?1e9:e,r,0,i);return r}findInner(t,e,i,r,n){for(let s=0;s<this.local.length;s++){let l=this.local[s];if(l.from<=e&&l.to>=t&&(!n||n(l.spec)))i.push(l.copy(l.from+r,l.to+r))}for(let s=0;s<this.children.length;s+=3){if(this.children[s]<e&&this.children[s+1]>t){let l=this.children[s]+1;this.children[s+2].findInner(t-l,e-l,i,r+l,n)}}}map(t,e,i){if(this==Is||t.maps.length==0)return this;return this.mapInner(t,e,0,0,i||Ts)}mapInner(t,e,i,r,n){let s;for(let l=0;l<this.local.length;l++){let f=this.local[l].map(t,i,r);if(f&&f.type.valid(e,f))(s||(s=[])).push(f);else if(n.onRemove)n.onRemove(this.local[l].spec)}if(this.children.length)return zs(this.children,s||[],t,e,i,r,n);else return s?new As(s.sort(Ws),Cs):Is}add(t,e){if(!e.length)return this;if(this==Is)return As.create(t,e);return this.addInner(t,e,0)}addInner(t,e,i){let r,n=0;t.forEach(((t,s)=>{let l=s+i,f;if(!(f=js(e,t,l)))return;if(!r)r=this.children.slice();while(n<r.length&&r[n]<s)n+=3;if(r[n]==s)r[n+2]=r[n+2].addInner(t,f,l+1);else r.splice(n,0,s,s+t.nodeSize,Ls(f,t,l+1,Ts));n+=3}));let s=Js(n?Fs(e):e,-i);for(let e=0;e<s.length;e++)if(!s[e].type.valid(t,s[e]))s.splice(e--,1);return new As(s.length?this.local.concat(s).sort(Ws):this.local,r||this.children)}remove(t){if(t.length==0||this==Is)return this;return this.removeInner(t,0)}removeInner(t,e){let i=this.children,r=this.local;for(let r=0;r<i.length;r+=3){let n;let s=i[r]+e,l=i[r+1]+e;for(let e=0,i;e<t.length;e++)if(i=t[e]){if(i.from>s&&i.to<l){t[e]=null;(n||(n=[])).push(i)}}if(!n)continue;if(i==this.children)i=this.children.slice();let f=i[r+2].removeInner(n,s+1);if(f!=Is){i[r+2]=f}else{i.splice(r,3);r-=3}}if(r.length)for(let i=0,n;i<t.length;i++)if(n=t[i]){for(let t=0;t<r.length;t++)if(r[t].eq(n,e)){if(r==this.local)r=this.local.slice();r.splice(t--,1)}}if(i==this.children&&r==this.local)return this;return r.length||i.length?new As(r,i):Is}forChild(t,e){if(this==Is)return this;if(e.isLeaf)return As.empty;let i,r;for(let e=0;e<this.children.length;e+=3)if(this.children[e]>=t){if(this.children[e]==t)i=this.children[e+2];break}let n=t+1,s=n+e.content.size;for(let t=0;t<this.local.length;t++){let e=this.local[t];if(e.from<s&&e.to>n&&e.type instanceof $s){let t=Math.max(n,e.from)-n,i=Math.min(s,e.to)-n;if(t<i)(r||(r=[])).push(e.copy(t,i))}}if(r){let t=new As(r.sort(Ws),Cs);return i?new Ps([t,i]):t}return i||Is}eq(t){if(this==t)return true;if(!(t instanceof As)||this.local.length!=t.local.length||this.children.length!=t.children.length)return false;for(let e=0;e<this.local.length;e++)if(!this.local[e].eq(t.local[e]))return false;for(let e=0;e<this.children.length;e+=3)if(this.children[e]!=t.children[e]||this.children[e+1]!=t.children[e+1]||!this.children[e+2].eq(t.children[e+2]))return false;return true}locals(t){return _s(this.localsInner(t))}localsInner(t){if(this==Is)return Cs;if(t.inlineContent||!this.local.some($s.is))return this.local;let e=[];for(let t=0;t<this.local.length;t++){if(!(this.local[t].type instanceof $s))e.push(this.local[t])}return e}}As.empty=new As([],[]);As.removeOverlap=_s;const Is=As.empty;class Ps{constructor(t){this.members=t}map(t,e){const i=this.members.map((i=>i.map(t,e,Ts)));return Ps.from(i)}forChild(t,e){if(e.isLeaf)return As.empty;let i=[];for(let r=0;r<this.members.length;r++){let n=this.members[r].forChild(t,e);if(n==Is)continue;if(n instanceof Ps)i=i.concat(n.members);else i.push(n)}return Ps.from(i)}eq(t){if(!(t instanceof Ps)||t.members.length!=this.members.length)return false;for(let e=0;e<this.members.length;e++)if(!this.members[e].eq(t.members[e]))return false;return true}locals(t){let e,i=true;for(let r=0;r<this.members.length;r++){let n=this.members[r].localsInner(t);if(!n.length)continue;if(!e){e=n}else{if(i){e=e.slice();i=false}for(let t=0;t<n.length;t++)e.push(n[t])}}return e?_s(i?e:e.sort(Ws)):Cs}static from(t){switch(t.length){case 0:return Is;case 1:return t[0];default:return new Ps(t.every((t=>t instanceof As))?t:t.reduce(((t,e)=>t.concat(e instanceof As?e:e.members)),[]))}}}function zs(t,e,i,r,n,s,l){let f=t.slice();for(let t=0,e=s;t<i.maps.length;t++){let r=0;i.maps[t].forEach(((t,i,n,s)=>{let l=s-n-(i-t);for(let n=0;n<f.length;n+=3){let s=f[n+1];if(s<0||t>s+e-r)continue;let o=f[n]+e-r;if(i>=o){f[n+1]=t<=o?-2:-1}else if(t>=e&&l){f[n]+=l;f[n+1]+=l}}r+=l}));e=i.maps[t].map(e,-1)}let o=false;for(let e=0;e<f.length;e+=3)if(f[e+1]<0){if(f[e+1]==-2){o=true;f[e+1]=-1;continue}let u=i.map(t[e]+s),h=u-n;if(h<0||h>=r.content.size){o=true;continue}let a=i.map(t[e+1]+s,-1),c=a-n;let{index:d,offset:p}=r.content.findIndex(h);let m=r.maybeChild(d);if(m&&p==h&&p+m.nodeSize==c){let r=f[e+2].mapInner(i,m,u+1,t[e]+s+1,l);if(r!=Is){f[e]=h;f[e+1]=c;f[e+2]=r}else{f[e+1]=-2;o=true}}else{o=true}}if(o){let o=Bs(f,t,e,i,n,s,l);let u=Ls(o,r,0,l);e=u.local;for(let t=0;t<f.length;t+=3)if(f[t+1]<0){f.splice(t,3);t-=3}for(let t=0,e=0;t<u.children.length;t+=3){let i=u.children[t];while(e<f.length&&f[e]<i)e+=3;f.splice(e,0,u.children[t],u.children[t+1],u.children[t+2])}}return new As(e.sort(Ws),f)}function Js(t,e){if(!e||!t.length)return t;let i=[];for(let r=0;r<t.length;r++){let n=t[r];i.push(new qs(n.from+e,n.to+e,n.type))}return i}function Bs(t,e,i,r,n,s,l){function f(t,e){for(let s=0;s<t.local.length;s++){let f=t.local[s].map(r,n,e);if(f)i.push(f);else if(l.onRemove)l.onRemove(t.local[s].spec)}for(let i=0;i<t.children.length;i+=3)f(t.children[i+2],t.children[i]+e+1)}for(let i=0;i<t.length;i+=3)if(t[i+1]==-1)f(t[i+2],e[i]+s+1);return i}function js(t,e,i){if(e.isLeaf)return null;let r=i+e.nodeSize,n=null;for(let e=0,s;e<t.length;e++){if((s=t[e])&&s.from>i&&s.to<r){(n||(n=[])).push(s);t[e]=null}}return n}function Fs(t){let e=[];for(let i=0;i<t.length;i++)if(t[i]!=null)e.push(t[i]);return e}function Ls(t,e,i,r){let n=[],s=false;e.forEach(((e,l)=>{let f=js(t,e,l+i);if(f){s=true;let t=Ls(f,e,i+l+1,r);if(t!=Is)n.push(l,l+e.nodeSize,t)}}));let l=Js(s?Fs(t):t,-i).sort(Ws);for(let t=0;t<l.length;t++)if(!l[t].type.valid(e,l[t])){if(r.onRemove)r.onRemove(l[t].spec);l.splice(t--,1)}return l.length||n.length?new As(l,n):Is}function Ws(t,e){return t.from-e.from||t.to-e.to}function _s(t){let e=t;for(let i=0;i<e.length-1;i++){let r=e[i];if(r.from!=r.to)for(let n=i+1;n<e.length;n++){let s=e[n];if(s.from==r.from){if(s.to!=r.to){if(e==t)e=t.slice();e[n]=s.copy(s.from,r.to);Us(e,n+1,s.copy(r.to,s.to))}continue}else{if(s.from<r.to){if(e==t)e=t.slice();e[i]=r.copy(r.from,s.from);Us(e,n,r.copy(s.from,r.to))}break}}}return e}function Us(t,e,i){while(e<t.length&&Ws(i,t[e])>0)e++;t.splice(e,0,i)}function Ks(t){let e=[];t.someProp("decorations",(i=>{let r=i(t.state);if(r&&r!=Is)e.push(r)}));if(t.cursorWrapper)e.push(As.create(t.state.doc,[t.cursorWrapper.deco]));return Ps.from(e)}const Hs={childList:true,characterData:true,characterDataOldValue:true,attributes:true,attributeOldValue:true,subtree:true};const Gs=Oi&&Ei<=11;class Vs{constructor(){this.anchorNode=null;this.anchorOffset=0;this.focusNode=null;this.focusOffset=0}set(t){this.anchorNode=t.anchorNode;this.anchorOffset=t.anchorOffset;this.focusNode=t.focusNode;this.focusOffset=t.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(t){return t.anchorNode==this.anchorNode&&t.anchorOffset==this.anchorOffset&&t.focusNode==this.focusNode&&t.focusOffset==this.focusOffset}}class Xs{constructor(t,e){this.view=t;this.handleDOMChange=e;this.queue=[];this.flushingSoon=-1;this.observer=null;this.currentSelection=new Vs;this.onCharData=null;this.suppressingSelectionUpdates=false;this.observer=window.MutationObserver&&new window.MutationObserver((t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);if(Oi&&Ei<=11&&t.some((t=>t.type=="childList"&&t.removedNodes.length||t.type=="characterData"&&t.oldValue.length>t.target.nodeValue.length)))this.flushSoon();else this.flush()}));if(Gs){this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue});this.flushSoon()}}this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){if(this.flushingSoon<0)this.flushingSoon=window.setTimeout((()=>{this.flushingSoon=-1;this.flush()}),20)}forceFlush(){if(this.flushingSoon>-1){window.clearTimeout(this.flushingSoon);this.flushingSoon=-1;this.flush()}}start(){if(this.observer){this.observer.takeRecords();this.observer.observe(this.view.dom,Hs)}if(this.onCharData)this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData);this.connectSelection()}stop(){if(this.observer){let t=this.observer.takeRecords();if(t.length){for(let e=0;e<t.length;e++)this.queue.push(t[e]);window.setTimeout((()=>this.flush()),20)}this.observer.disconnect()}if(this.onCharData)this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData);this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=true;setTimeout((()=>this.suppressingSelectionUpdates=false),50)}onSelectionChange(){if(!sn(this.view))return;if(this.suppressingSelectionUpdates)return Gr(this.view);if(Oi&&Ei<=11&&!this.view.state.selection.empty){let t=this.view.domSelectionRange();if(t.focusNode&&ui(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset))return this.flushSoon()}this.flush()}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(t){if(!t.focusNode)return true;let e=new Set,i;for(let i=t.focusNode;i;i=li(i))e.add(i);for(let r=t.anchorNode;r;r=li(r))if(e.has(r)){i=r;break}let r=i&&this.view.docView.nearestDesc(i);if(r&&r.ignoreMutation({type:"selection",target:i.nodeType==3?i.parentNode:i})){this.setCurSelection();return true}}pendingRecords(){if(this.observer)for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}flush(){let{view:t}=this;if(!t.docView||this.flushingSoon>-1)return;let e=this.pendingRecords();if(e.length)this.queue=[];let i=t.domSelectionRange();let r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(i)&&sn(t)&&!this.ignoreSelectionChange(i);let n=-1,s=-1,l=false,f=[];if(t.editable){for(let t=0;t<e.length;t++){let i=this.registerMutation(e[t],f);if(i){n=n<0?i.from:Math.min(i.from,n);s=s<0?i.to:Math.max(i.to,s);if(i.typeOver)l=true}}}if(Di&&f.length>1){let t=f.filter((t=>t.nodeName=="BR"));if(t.length==2){let e=t[0],i=t[1];if(e.parentNode&&e.parentNode.parentNode==i.parentNode)i.remove();else e.remove()}}let o=null;if(n<0&&r&&t.input.lastFocus>Date.now()-200&&Math.max(t.input.lastTouch,t.input.lastClick.time)<Date.now()-300&&mi(i)&&(o=Kr(t))&&o.eq(Te.near(t.state.doc.resolve(0),1))){t.input.lastFocus=0;Gr(t);this.currentSelection.set(i);t.scrollToSelection()}else if(n>-1||r){if(n>-1){t.docView.markDirty(n,s);Zs(t)}this.handleDOMChange(n,s,l,f);if(t.docView&&t.docView.dirty)t.updateState(t.state);else if(!this.currentSelection.eq(i))Gr(t);this.currentSelection.set(i)}}registerMutation(t,e){if(e.indexOf(t.target)>-1)return null;let i=this.view.docView.nearestDesc(t.target);if(t.type=="attributes"&&(i==this.view.docView||t.attributeName=="contenteditable"||t.attributeName=="style"&&!t.oldValue&&!t.target.getAttribute("style")))return null;if(!i||i.ignoreMutation(t))return null;if(t.type=="childList"){for(let i=0;i<t.addedNodes.length;i++)e.push(t.addedNodes[i]);if(i.contentDOM&&i.contentDOM!=i.dom&&!i.contentDOM.contains(t.target))return{from:i.posBefore,to:i.posAfter};let r=t.previousSibling,n=t.nextSibling;if(Oi&&Ei<=11&&t.addedNodes.length){for(let e=0;e<t.addedNodes.length;e++){let{previousSibling:i,nextSibling:s}=t.addedNodes[e];if(!i||Array.prototype.indexOf.call(t.addedNodes,i)<0)r=i;if(!s||Array.prototype.indexOf.call(t.addedNodes,s)<0)n=s}}let s=r&&r.parentNode==t.target?si(r)+1:0;let l=i.localPosFromDOM(t.target,s,-1);let f=n&&n.parentNode==t.target?si(n):t.target.childNodes.length;let o=i.localPosFromDOM(t.target,f,1);return{from:l,to:o}}else if(t.type=="attributes"){return{from:i.posAtStart-i.border,to:i.posAtEnd+i.border}}else{return{from:i.posAtStart,to:i.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}}}}let Ys=new WeakMap;let Qs=false;function Zs(t){if(Ys.has(t))return;Ys.set(t,null);if(["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1){t.requiresGeckoHackNode=Di;if(Qs)return;console["warn"]("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package.");Qs=true}}function tl(t){let e;function i(t){t.preventDefault();t.stopImmediatePropagation();e=t.getTargetRanges()[0]}t.dom.addEventListener("beforeinput",i,true);document.execCommand("indent");t.dom.removeEventListener("beforeinput",i,true);let r=e.startContainer,n=e.startOffset;let s=e.endContainer,l=e.endOffset;let f=t.domAtPos(t.state.selection.anchor);if(ui(f.node,f.offset,s,l))[r,n,s,l]=[s,l,r,n];return{anchorNode:r,anchorOffset:n,focusNode:s,focusOffset:l}}function el(t,e,i){let{node:r,fromOffset:n,toOffset:s,from:l,to:f}=t.docView.parseRange(e,i);let o=t.domSelectionRange();let u;let h=o.anchorNode;if(h&&t.dom.contains(h.nodeType==1?h:h.parentNode)){u=[{node:h,offset:o.anchorOffset}];if(!mi(o))u.push({node:o.focusNode,offset:o.focusOffset})}if($i&&t.input.lastKeyCode===8){for(let t=s;t>n;t--){let e=r.childNodes[t-1],i=e.pmViewDesc;if(e.nodeName=="BR"&&!i){s=t;break}if(!i||i.size)break}}let a=t.state.doc;let c=t.someProp("domParser")||rt.fromSchema(t.state.schema);let d=a.resolve(l);let p=null,m=c.parse(r,{topNode:d.parent,topMatch:d.parent.contentMatchAt(d.index()),topOpen:true,from:n,to:s,preserveWhitespace:d.parent.type.whitespace=="pre"?"full":true,findPositions:u,ruleFromNode:il,context:d});if(u&&u[0].pos!=null){let t=u[0].pos,e=u[1]&&u[1].pos;if(e==null)e=t;p={anchor:t+l,head:e+l}}return{doc:m,sel:p,from:l,to:f}}function il(t){let e=t.pmViewDesc;if(e){return e.parseRule()}else if(t.nodeName=="BR"&&t.parentNode){if(qi&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let t=document.createElement("div");t.appendChild(document.createElement("li"));return{skip:t}}else if(t.parentNode.lastChild==t||qi&&/^(tr|table)$/i.test(t.parentNode.nodeName)){return{ignore:true}}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder")){return{ignore:true}}return null}const rl=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function nl(t,e,i,r,n){let s=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);t.input.compositionPendingChanges=0;if(e<0){let e=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null;let i=Kr(t,e);if(i&&!t.state.selection.eq(i)){if($i&&Ii&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",(e=>e(t,wi(13,"Enter")))))return;let r=t.state.tr.setSelection(i);if(e=="pointer")r.setMeta("pointer",true);else if(e=="key")r.scrollIntoView();if(s)r.setMeta("composition",s);t.dispatch(r)}return}let l=t.state.doc.resolve(e);let f=l.sharedDepth(i);e=l.before(f+1);i=t.state.doc.resolve(i).after(f+1);let o=t.state.selection;let u=el(t,e,i);let h=t.state.doc,a=h.slice(u.from,u.to);let c,d;if(t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime){c=t.state.selection.to;d="end"}else{c=t.state.selection.from;d="start"}t.input.lastKeyCode=null;let p=ul(a.content,u.doc.content,u.from,c,d);if((Ci&&t.input.lastIOSEnter>Date.now()-225||Ii)&&n.some((t=>t.nodeType==1&&!rl.test(t.nodeName)))&&(!p||p.endA>=p.endB)&&t.someProp("handleKeyDown",(e=>e(t,wi(13,"Enter"))))){t.input.lastIOSEnter=0;return}if(!p){if(r&&o instanceof ze&&!o.empty&&o.$head.sameParent(o.$anchor)&&!t.composing&&!(u.sel&&u.sel.anchor!=u.sel.head)){p={start:o.from,endA:o.to,endB:o.to}}else{if(u.sel){let e=sl(t,t.state.doc,u.sel);if(e&&!e.eq(t.state.selection)){let i=t.state.tr.setSelection(e);if(s)i.setMeta("composition",s);t.dispatch(i)}}return}}if($i&&t.cursorWrapper&&u.sel&&u.sel.anchor==t.cursorWrapper.deco.from&&u.sel.head==u.sel.anchor){let t=p.endB-p.start;u.sel={anchor:u.sel.anchor+t,head:u.sel.anchor+t}}t.input.domChangeCount++;if(t.state.selection.from<t.state.selection.to&&p.start==p.endB&&t.state.selection instanceof ze){if(p.start>t.state.selection.from&&p.start<=t.state.selection.from+2&&t.state.selection.from>=u.from){p.start=t.state.selection.from}else if(p.endA<t.state.selection.to&&p.endA>=t.state.selection.to-2&&t.state.selection.to<=u.to){p.endB+=t.state.selection.to-p.endA;p.endA=t.state.selection.to}}if(Oi&&Ei<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>u.from&&u.doc.textBetween(p.start-u.from-1,p.start-u.from+1)==" "){p.start--;p.endA--;p.endB--}let m=u.doc.resolveNoCache(p.start-u.from);let w=u.doc.resolveNoCache(p.endB-u.from);let g=h.resolve(p.start);let b=m.sameParent(w)&&m.parent.inlineContent&&g.end()>=p.endA;let v;if((Ci&&t.input.lastIOSEnter>Date.now()-225&&(!b||n.some((t=>t.nodeName=="DIV"||t.nodeName=="P")))||!b&&m.pos<u.doc.content.size&&!m.sameParent(w)&&(v=Te.findFrom(u.doc.resolve(m.pos+1),1,true))&&v.head==w.pos)&&t.someProp("handleKeyDown",(e=>e(t,wi(13,"Enter"))))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>p.start&&fl(h,p.start,p.endA,m,w)&&t.someProp("handleKeyDown",(e=>e(t,wi(8,"Backspace"))))){if(Ii&&$i)t.domObserver.suppressSelectionUpdates();return}if($i&&Ii&&p.endB==p.start)t.input.lastAndroidDelete=Date.now();if(Ii&&!b&&m.start()!=w.start()&&w.parentOffset==0&&m.depth==w.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==p.endA){p.endB-=2;w=u.doc.resolveNoCache(p.endB-u.from);setTimeout((()=>{t.someProp("handleKeyDown",(function(e){return e(t,wi(13,"Enter"))}))}),20)}let y=p.start,k=p.endA;let M,x,S;if(b){if(m.pos==w.pos){if(Oi&&Ei<=11&&m.parentOffset==0){t.domObserver.suppressSelectionUpdates();setTimeout((()=>Gr(t)),20)}M=t.state.tr.delete(y,k);x=h.resolve(p.start).marksAcross(h.resolve(p.endA))}else if(p.endA==p.endB&&(S=ll(m.parent.content.cut(m.parentOffset,w.parentOffset),g.parent.content.cut(g.parentOffset,p.endA-g.start())))){M=t.state.tr;if(S.type=="add")M.addMark(y,k,S.mark);else M.removeMark(y,k,S.mark)}else if(m.parent.child(m.index()).isText&&m.index()==w.index()-(w.textOffset?0:1)){let e=m.parent.textBetween(m.parentOffset,w.parentOffset);if(t.someProp("handleTextInput",(i=>i(t,y,k,e))))return;M=t.state.tr.insertText(e,y,k)}}if(!M)M=t.state.tr.replace(y,k,u.doc.slice(p.start-u.from,p.endB-u.from));if(u.sel){let e=sl(t,M.doc,u.sel);if(e&&!($i&&Ii&&t.composing&&e.empty&&(p.start!=p.endB||t.input.lastAndroidDelete<Date.now()-100)&&(e.head==y||e.head==M.mapping.map(k)-1)||Oi&&e.empty&&e.head==y))M.setSelection(e)}if(x)M.ensureMarks(x);if(s)M.setMeta("composition",s);t.dispatch(M.scrollIntoView())}function sl(t,e,i){if(Math.max(i.anchor,i.head)>e.content.size)return null;return nn(t,e.resolve(i.anchor),e.resolve(i.head))}function ll(t,e){let i=t.firstChild.marks,r=e.firstChild.marks;let n=i,s=r,l,o,u;for(let t=0;t<r.length;t++)n=r[t].removeFromSet(n);for(let t=0;t<i.length;t++)s=i[t].removeFromSet(s);if(n.length==1&&s.length==0){o=n[0];l="add";u=t=>t.mark(o.addToSet(t.marks))}else if(n.length==0&&s.length==1){o=s[0];l="remove";u=t=>t.mark(o.removeFromSet(t.marks))}else{return null}let h=[];for(let t=0;t<e.childCount;t++)h.push(u(e.child(t)));if(f.from(h).eq(t))return{mark:o,type:l}}function fl(t,e,i,r,n){if(!r.parent.isTextblock||i-e<=n.pos-r.pos||ol(r,true,false)<n.pos)return false;let s=t.resolve(e);if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return false;let l=t.resolve(ol(s,true,true));if(!l.parent.isTextblock||l.pos>i||ol(l,true,false)<i)return false;return r.parent.content.cut(r.parentOffset).eq(l.parent.content)}function ol(t,e,i){let r=t.depth,n=e?t.end():t.pos;while(r>0&&(e||t.indexAfter(r)==t.node(r).childCount)){r--;n++;e=false}if(i){let e=t.node(r).maybeChild(t.indexAfter(r));while(e&&!e.isLeaf){e=e.firstChild;n++}}return n}function ul(t,e,i,r,n){let s=t.findDiffStart(e,i);if(s==null)return null;let{a:l,b:f}=t.findDiffEnd(e,i+t.size,i+e.size);if(n=="end"){let t=Math.max(0,s-Math.min(l,f));r-=l+t-s}if(l<s&&t.size<e.size){let t=r<=s&&r>=l?s-r:0;s-=t;if(s&&s<e.size&&hl(e.textBetween(s-1,s+1)))s+=t?1:-1;f=s+(f-l);l=s}else if(f<s){let e=r<=s&&r>=f?s-r:0;s-=e;if(s&&s<t.size&&hl(t.textBetween(s-1,s+1)))s+=e?1:-1;l=s+(l-f);f=s}return{start:s,endA:l,endB:f}}function hl(t){if(t.length!=2)return false;let e=t.charCodeAt(0),i=t.charCodeAt(1);return e>=56320&&e<=57343&&i>=55296&&i<=56319}class al{constructor(t,e){this._root=null;this.focused=false;this.trackWrites=null;this.mounted=false;this.markCursor=null;this.cursorWrapper=null;this.lastSelectedViewDesc=undefined;this.input=new Un;this.prevDirectPlugins=[];this.pluginViews=[];this.requiresGeckoHackNode=false;this.dragging=null;this._props=e;this.state=e.state;this.directPlugins=e.plugins||[];this.directPlugins.forEach(bl);this.dispatch=this.dispatch.bind(this);this.dom=t&&t.mount||document.createElement("div");if(t){if(t.appendChild)t.appendChild(this.dom);else if(typeof t=="function")t(this.dom);else if(t.mount)this.mounted=true}this.editable=pl(this);dl(this);this.nodeViews=wl(this);this.docView=Or(this.state.doc,cl(this),Ks(this),this.dom,this);this.domObserver=new Xs(this,((t,e,i,r)=>nl(this,t,e,i,r)));this.domObserver.start();Kn(this);this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let t=this._props;this._props={};for(let e in t)this._props[e]=t[e];this._props.state=this.state}return this._props}update(t){if(t.handleDOMEvents!=this._props.handleDOMEvents)Vn(this);let e=this._props;this._props=t;if(t.plugins){t.plugins.forEach(bl);this.directPlugins=t.plugins}this.updateStateInner(t.state,e)}setProps(t){let e={};for(let t in this._props)e[t]=this._props[t];e.state=this.state;for(let i in t)e[i]=t[i];this.update(e)}updateState(t){this.updateStateInner(t,this._props)}updateStateInner(t,e){var i;let r=this.state,n=false,s=false;if(t.storedMarks&&this.composing){ws(this);s=true}this.state=t;let l=r.plugins!=t.plugins||this._props.plugins!=e.plugins;if(l||this._props.plugins!=e.plugins||this._props.nodeViews!=e.nodeViews){let t=wl(this);if(gl(t,this.nodeViews)){this.nodeViews=t;n=true}}if(l||e.handleDOMEvents!=this._props.handleDOMEvents){Vn(this)}this.editable=pl(this);dl(this);let f=Ks(this),o=cl(this);let u=r.plugins!=t.plugins&&!r.doc.eq(t.doc)?"reset":t.scrollToSelection>r.scrollToSelection?"to selection":"preserve";let h=n||!this.docView.matchesNode(t.doc,o,f);if(h||!t.selection.eq(r.selection))s=true;let a=u=="preserve"&&s&&this.dom.style.overflowAnchor==null&&Li(this);if(s){this.domObserver.stop();let e=h&&(Oi||$i)&&!this.composing&&!r.selection.empty&&!t.selection.empty&&ml(r.selection,t.selection);if(h){let i=$i?this.trackWrites=this.domSelectionRange().focusNode:null;if(n||!this.docView.update(t.doc,o,f,this)){this.docView.updateOuterDeco([]);this.docView.destroy();this.docView=Or(t.doc,o,f,this.dom,this)}if(i&&!this.trackWrites)e=true}if(e||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&fn(this))){Gr(this,e)}else{en(this,t.selection);this.domObserver.setCurSelection()}this.domObserver.start()}this.updatePluginViews(r);if(((i=this.dragging)===null||i===void 0?void 0:i.node)&&!r.doc.eq(t.doc))this.updateDraggedNode(this.dragging,r);if(u=="reset"){this.dom.scrollTop=0}else if(u=="to selection"){this.scrollToSelection()}else if(a){_i(a)}}scrollToSelection(){let t=this.domSelectionRange().focusNode;if(this.someProp("handleScrollToSelection",(t=>t(this))));else if(this.state.selection instanceof Be){let e=this.docView.domAfterPos(this.state.selection.from);if(e.nodeType==1)Fi(this,e.getBoundingClientRect(),t)}else{Fi(this,this.coordsAtPos(this.state.selection.head,1),t)}}destroyPluginViews(){let t;while(t=this.pluginViews.pop())if(t.destroy)t.destroy()}updatePluginViews(t){if(!t||t.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins;this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let e=this.directPlugins[t];if(e.spec.view)this.pluginViews.push(e.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let e=this.state.plugins[t];if(e.spec.view)this.pluginViews.push(e.spec.view(this))}}else{for(let e=0;e<this.pluginViews.length;e++){let i=this.pluginViews[e];if(i.update)i.update(this,t)}}}updateDraggedNode(t,e){let i=t.node,r=-1;if(this.state.doc.nodeAt(i.from)==i.node){r=i.from}else{let t=i.from+(this.state.doc.content.size-e.doc.content.size);let n=t>0&&this.state.doc.nodeAt(t);if(n==i.node)r=t}this.dragging=new Os(t.slice,t.move,r<0?undefined:Be.create(this.state.doc,r))}someProp(t,e){let i=this._props&&this._props[t],r;if(i!=null&&(r=e?e(i):i))return r;for(let i=0;i<this.directPlugins.length;i++){let n=this.directPlugins[i].props[t];if(n!=null&&(r=e?e(n):n))return r}let n=this.state.plugins;if(n)for(let i=0;i<n.length;i++){let s=n[i].props[t];if(s!=null&&(r=e?e(s):s))return r}}hasFocus(){if(Oi){let t=this.root.activeElement;if(t==this.dom)return true;if(!t||!this.dom.contains(t))return false;while(t&&this.dom!=t&&this.dom.contains(t)){if(t.contentEditable=="false")return false;t=t.parentElement}return true}return this.root.activeElement==this.dom}focus(){this.domObserver.stop();if(this.editable)Hi(this.dom);Gr(this);this.domObserver.start()}get root(){let t=this._root;if(t==null)for(let t=this.dom.parentNode;t;t=t.parentNode){if(t.nodeType==9||t.nodeType==11&&t.host){if(!t.getSelection)Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection();return this._root=t}}return t||document}updateRoot(){this._root=null}posAtCoords(t){return er(this,t)}coordsAtPos(t,e=1){return sr(this,t,e)}domAtPos(t,e=0){return this.docView.domFromPos(t,e)}nodeDOM(t){let e=this.docView.descAt(t);return e?e.nodeDOM:null}posAtDOM(t,e,i=-1){let r=this.docView.posFromDOM(t,e,i);if(r==null)throw new RangeError("DOM position not inside the editor");return r}endOfTextblock(t,e){return mr(this,e||this.state,t)}pasteHTML(t,e){return xs(this,"",t,false,e||new ClipboardEvent("paste"))}pasteText(t,e){return xs(this,t,null,true,e||new ClipboardEvent("paste"))}destroy(){if(!this.docView)return;Gn(this);this.destroyPluginViews();if(this.mounted){this.docView.update(this.state.doc,[],Ks(this),this);this.dom.textContent=""}else if(this.dom.parentNode){this.dom.parentNode.removeChild(this.dom)}this.docView.destroy();this.docView=null}get isDestroyed(){return this.docView==null}dispatchEvent(t){return Qn(this,t)}dispatch(t){let e=this._props.dispatchTransaction;if(e)e.call(this,t);else this.updateState(this.state.apply(t))}domSelectionRange(){return qi&&this.root.nodeType===11&&gi(this.dom.ownerDocument)==this.dom?tl(this):this.domSelection()}domSelection(){return this.root.getSelection()}}function cl(t){let e=Object.create(null);e.class="ProseMirror";e.contenteditable=String(t.editable);t.someProp("attributes",(i=>{if(typeof i=="function")i=i(t.state);if(i)for(let t in i){if(t=="class")e.class+=" "+i[t];else if(t=="style")e.style=(e.style?e.style+";":"")+i[t];else if(!e[t]&&t!="contenteditable"&&t!="nodeName")e[t]=String(i[t])}}));if(!e.translate)e.translate="no";return[qs.node(0,t.state.doc.content.size,e)]}function dl(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator";e.setAttribute("mark-placeholder","true");e.setAttribute("alt","");t.cursorWrapper={dom:e,deco:qs.widget(t.state.selection.head,e,{raw:true,marks:t.markCursor})}}else{t.cursorWrapper=null}}function pl(t){return!t.someProp("editable",(e=>e(t.state)===false))}function ml(t,e){let i=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(i)!=e.$anchor.start(i)}function wl(t){let e=Object.create(null);function i(t){for(let i in t)if(!Object.prototype.hasOwnProperty.call(e,i))e[i]=t[i]}t.someProp("nodeViews",i);t.someProp("markViews",i);return e}function gl(t,e){let i=0,r=0;for(let r in t){if(t[r]!=e[r])return true;i++}for(let t in e)r++;return i!=r}function bl(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}const vl=["p",0],yl=["blockquote",0],kl=["hr"],Ml=["pre",["code",0]],xl=["br"];const Sl={doc:{content:"block+"},paragraph:{content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM(){return vl}},blockquote:{content:"block+",group:"block",defining:true,parseDOM:[{tag:"blockquote"}],toDOM(){return yl}},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM(){return kl}},heading:{attrs:{level:{default:1}},content:"inline*",group:"block",defining:true,parseDOM:[{tag:"h1",attrs:{level:1}},{tag:"h2",attrs:{level:2}},{tag:"h3",attrs:{level:3}},{tag:"h4",attrs:{level:4}},{tag:"h5",attrs:{level:5}},{tag:"h6",attrs:{level:6}}],toDOM(t){return["h"+t.attrs.level,0]}},code_block:{content:"text*",marks:"",group:"block",code:true,defining:true,parseDOM:[{tag:"pre",preserveWhitespace:"full"}],toDOM(){return Ml}},text:{group:"inline"},image:{inline:true,attrs:{src:{},alt:{default:null},title:{default:null}},group:"inline",draggable:true,parseDOM:[{tag:"img[src]",getAttrs(t){return{src:t.getAttribute("src"),title:t.getAttribute("title"),alt:t.getAttribute("alt")}}}],toDOM(t){let{src:e,alt:i,title:r}=t.attrs;return["img",{src:e,alt:i,title:r}]}},hard_break:{inline:true,group:"inline",selectable:false,parseDOM:[{tag:"br"}],toDOM(){return xl}}};const Ol=["em",0],El=["strong",0],Dl=["code",0];const Nl={link:{attrs:{href:{},title:{default:null}},inclusive:false,parseDOM:[{tag:"a[href]",getAttrs(t){return{href:t.getAttribute("href"),title:t.getAttribute("title")}}}],toDOM(t){let{href:e,title:i}=t.attrs;return["a",{href:e,title:i},0]}},em:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style=italic"},{style:"font-style=normal",clearMark:t=>t.type.name=="em"}],toDOM(){return Ol}},strong:{parseDOM:[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name=="strong"},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}],toDOM(){return El}},code:{parseDOM:[{tag:"code"}],toDOM(){return Dl}}};const $l=new et({nodes:Sl,marks:Nl});const Rl=["ol",0],ql=["ul",0],Cl=["li",0];const Tl={attrs:{order:{default:1}},parseDOM:[{tag:"ol",getAttrs(t){return{order:t.hasAttribute("start")?+t.getAttribute("start"):1}}}],toDOM(t){return t.attrs.order==1?Rl:["ol",{start:t.attrs.order},0]}};const Al={parseDOM:[{tag:"ul"}],toDOM(){return ql}};const Il={parseDOM:[{tag:"li"}],toDOM(){return Cl},defining:true};function Pl(t,e){let i={};for(let e in t)i[e]=t[e];for(let t in e)i[t]=e[t];return i}function zl(t,e,i){return t.append({ordered_list:Pl(Tl,{content:"list_item+",group:i}),bullet_list:Pl(Al,{content:"list_item+",group:i}),list_item:Pl(Il,{content:e})})}function Jl(t,e=null){return function(i,r){let{$from:n,$to:s}=i.selection;let l=n.blockRange(s),f=false,o=l;if(!l)return false;if(l.depth>=2&&n.node(l.depth-1).type.compatibleContent(t)&&l.startIndex==0){if(n.index(l.depth-1)==0)return false;let t=i.doc.resolve(l.start-2);o=new R(t,t,l.depth);if(l.endIndex<l.parent.childCount)l=new R(n,i.doc.resolve(s.end(l.depth)),l.depth);f=true}let u=Yt(o,t,e,l);if(!u)return false;if(r)r(Bl(i.tr,l,u,f,t).scrollIntoView());return true}}function Bl(t,e,i,r,n){let s=f.empty;for(let t=i.length-1;t>=0;t--)s=f.from(i[t].type.create(i[t].attrs,s));t.step(new Wt(e.start-(r?2:0),e.end,e.start,e.end,new d(s,0,0),i.length,true));let l=0;for(let t=0;t<i.length;t++)if(i[t].type==n)l=t+1;let o=i.length-l;let u=e.start+i.length-(r?2:0),h=e.parent;for(let i=e.startIndex,r=e.endIndex,n=true;i<r;i++,n=false){if(!n&&se(t.doc,u,o)){t.split(u,o);u+=2*o}u+=h.child(i).nodeSize}return t}function jl(t,e){return function(i,r){let{$from:n,$to:s,node:l}=i.selection;if(l&&l.isBlock||n.depth<2||!n.sameParent(s))return false;let o=n.node(-1);if(o.type!=t)return false;if(n.parent.content.size==0&&n.node(-1).childCount==n.indexAfter(-1)){if(n.depth==3||n.node(-3).type!=t||n.index(-2)!=n.node(-2).childCount-1)return false;if(r){let e=f.empty;let s=n.index(-1)?1:n.index(-2)?2:3;for(let t=n.depth-s;t>=n.depth-3;t--)e=f.from(n.node(t).copy(e));let l=n.indexAfter(-1)<n.node(-2).childCount?1:n.indexAfter(-2)<n.node(-3).childCount?2:3;e=e.append(f.from(t.createAndFill()));let o=n.before(n.depth-(s-1));let u=i.tr.replace(o,n.after(-l),new d(e,4-s,0));let h=-1;u.doc.nodesBetween(o,u.doc.content.size,((t,e)=>{if(h>-1)return false;if(t.isTextblock&&t.content.size==0)h=e+1}));if(h>-1)u.setSelection(Te.near(u.doc.resolve(h)));r(u.scrollIntoView())}return true}let u=s.pos==n.end()?o.contentMatchAt(0).defaultType:null;let h=i.tr.delete(n.pos,s.pos);let a=u?[e?{type:t,attrs:e}:null,{type:u}]:undefined;if(!se(h.doc,n.pos,2,a))return false;if(r)r(h.split(n.pos,2,a).scrollIntoView());return true}}function Fl(t){return function(e,i){let{$from:r,$to:n}=e.selection;let s=r.blockRange(n,(e=>e.childCount>0&&e.firstChild.type==t));if(!s)return false;if(!i)return true;if(r.node(s.depth-1).type==t)return Ll(e,i,t,s);else return Wl(e,i,s)}}function Ll(t,e,i,r){let n=t.tr,s=r.end,l=r.$to.end(r.depth);if(s<l){n.step(new Wt(s-1,l,s,l,new d(f.from(i.create(null,r.parent.copy())),1,0),1,true));r=new R(n.doc.resolve(r.$from.pos),n.doc.resolve(l),r.depth)}const o=Vt(r);if(o==null)return false;n.lift(r,o);let u=n.mapping.map(s,-1)-1;if(fe(n.doc,u))n.join(u);e(n.scrollIntoView());return true}function Wl(t,e,i){let r=t.tr,n=i.parent;for(let t=i.end,e=i.endIndex-1,s=i.startIndex;e>s;e--){t-=n.child(e).nodeSize;r.delete(t-1,t+1)}let s=r.doc.resolve(i.start),l=s.nodeAfter;if(r.mapping.map(i.end)!=i.start+s.nodeAfter.nodeSize)return false;let o=i.startIndex==0,u=i.endIndex==n.childCount;let h=s.node(-1),a=s.index(-1);if(!h.canReplace(a+(o?0:1),a+1,l.content.append(u?f.empty:f.from(n))))return false;let c=s.pos,p=c+l.nodeSize;r.step(new Wt(c-(o?1:0),p+(u?1:0),c+1,p-1,new d((o?f.empty:f.from(n.copy(f.empty))).append(u?f.empty:f.from(n.copy(f.empty))),o?0:1,u?0:1),o?0:1));e(r.scrollIntoView());return true}function _l(t){return function(e,i){let{$from:r,$to:n}=e.selection;let s=r.blockRange(n,(e=>e.childCount>0&&e.firstChild.type==t));if(!s)return false;let l=s.startIndex;if(l==0)return false;let o=s.parent,u=o.child(l-1);if(u.type!=t)return false;if(i){let r=u.lastChild&&u.lastChild.type==o.type;let n=f.from(r?t.create():null);let l=new d(f.from(t.create(null,f.from(o.type.create(null,n)))),r?3:1,0);let h=s.start,a=s.end;i(e.tr.step(new Wt(h-(r?3:1),a,h,a,l,1,true)).scrollIntoView())}return true}}var Ul={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"};var Kl={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'};var Hl=typeof navigator!="undefined"&&/Mac/.test(navigator.platform);var Gl=typeof navigator!="undefined"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Vl=0;Vl<10;Vl++)Ul[48+Vl]=Ul[96+Vl]=String(Vl);for(var Vl=1;Vl<=24;Vl++)Ul[Vl+111]="F"+Vl;for(var Vl=65;Vl<=90;Vl++){Ul[Vl]=String.fromCharCode(Vl+32);Kl[Vl]=String.fromCharCode(Vl)}for(var Xl in Ul)if(!Kl.hasOwnProperty(Xl))Kl[Xl]=Ul[Xl];function Yl(t){var e=Hl&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||Gl&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified";var i=!e&&t.key||(t.shiftKey?Kl:Ul)[t.keyCode]||t.key||"Unidentified";if(i=="Esc")i="Escape";if(i=="Del")i="Delete";if(i=="Left")i="ArrowLeft";if(i=="Up")i="ArrowUp";if(i=="Right")i="ArrowRight";if(i=="Down")i="ArrowDown";return i}const Ql=typeof navigator!="undefined"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):false;function Zl(t){let e=t.split(/-(?!$)/),i=e[e.length-1];if(i=="Space")i=" ";let r,n,s,l;for(let t=0;t<e.length-1;t++){let i=e[t];if(/^(cmd|meta|m)$/i.test(i))l=true;else if(/^a(lt)?$/i.test(i))r=true;else if(/^(c|ctrl|control)$/i.test(i))n=true;else if(/^s(hift)?$/i.test(i))s=true;else if(/^mod$/i.test(i)){if(Ql)l=true;else n=true}else throw new Error("Unrecognized modifier name: "+i)}if(r)i="Alt-"+i;if(n)i="Ctrl-"+i;if(l)i="Meta-"+i;if(s)i="Shift-"+i;return i}function tf(t){let e=Object.create(null);for(let i in t)e[Zl(i)]=t[i];return e}function ef(t,e,i=true){if(e.altKey)t="Alt-"+t;if(e.ctrlKey)t="Ctrl-"+t;if(e.metaKey)t="Meta-"+t;if(i&&e.shiftKey)t="Shift-"+t;return t}function rf(t){return new ei({props:{handleKeyDown:nf(t)}})}function nf(t){let e=tf(t);return function(t,i){let r=Yl(i),n,s=e[ef(r,i)];if(s&&s(t.state,t.dispatch,t))return true;if(r.length==1&&r!=" "){if(i.shiftKey){let n=e[ef(r,i,false)];if(n&&n(t.state,t.dispatch,t))return true}if((i.shiftKey||i.altKey||i.metaKey||r.charCodeAt(0)>127)&&(n=Ul[i.keyCode])&&n!=r){let r=e[ef(n,i)];if(r&&r(t.state,t.dispatch,t))return true}}return false}}var sf=200;var lf=function t(){};lf.prototype.append=function t(e){if(!e.length){return this}e=lf.from(e);return!this.length&&e||e.length<sf&&this.leafAppend(e)||this.length<sf&&e.leafPrepend(this)||this.appendInner(e)};lf.prototype.prepend=function t(e){if(!e.length){return this}return lf.from(e).append(this)};lf.prototype.appendInner=function t(e){return new of(this,e)};lf.prototype.slice=function t(e,i){if(e===void 0)e=0;if(i===void 0)i=this.length;if(e>=i){return lf.empty}return this.sliceInner(Math.max(0,e),Math.min(this.length,i))};lf.prototype.get=function t(e){if(e<0||e>=this.length){return undefined}return this.getInner(e)};lf.prototype.forEach=function t(e,i,r){if(i===void 0)i=0;if(r===void 0)r=this.length;if(i<=r){this.forEachInner(e,i,r,0)}else{this.forEachInvertedInner(e,i,r,0)}};lf.prototype.map=function t(e,i,r){if(i===void 0)i=0;if(r===void 0)r=this.length;var n=[];this.forEach((function(t,i){return n.push(e(t,i))}),i,r);return n};lf.from=function t(e){if(e instanceof lf){return e}return e&&e.length?new ff(e):lf.empty};var ff=function(t){function e(e){t.call(this);this.values=e}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;var i={length:{configurable:true},depth:{configurable:true}};e.prototype.flatten=function t(){return this.values};e.prototype.sliceInner=function t(i,r){if(i==0&&r==this.length){return this}return new e(this.values.slice(i,r))};e.prototype.getInner=function t(e){return this.values[e]};e.prototype.forEachInner=function t(e,i,r,n){for(var s=i;s<r;s++){if(e(this.values[s],n+s)===false){return false}}};e.prototype.forEachInvertedInner=function t(e,i,r,n){for(var s=i-1;s>=r;s--){if(e(this.values[s],n+s)===false){return false}}};e.prototype.leafAppend=function t(i){if(this.length+i.length<=sf){return new e(this.values.concat(i.flatten()))}};e.prototype.leafPrepend=function t(i){if(this.length+i.length<=sf){return new e(i.flatten().concat(this.values))}};i.length.get=function(){return this.values.length};i.depth.get=function(){return 0};Object.defineProperties(e.prototype,i);return e}(lf);lf.empty=new ff([]);var of=function(t){function e(e,i){t.call(this);this.left=e;this.right=i;this.length=e.length+i.length;this.depth=Math.max(e.depth,i.depth)+1}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.flatten=function t(){return this.left.flatten().concat(this.right.flatten())};e.prototype.getInner=function t(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)};e.prototype.forEachInner=function t(e,i,r,n){var s=this.left.length;if(i<s&&this.left.forEachInner(e,i,Math.min(r,s),n)===false){return false}if(r>s&&this.right.forEachInner(e,Math.max(i-s,0),Math.min(this.length,r)-s,n+s)===false){return false}};e.prototype.forEachInvertedInner=function t(e,i,r,n){var s=this.left.length;if(i>s&&this.right.forEachInvertedInner(e,i-s,Math.max(r,s)-s,n+s)===false){return false}if(r<s&&this.left.forEachInvertedInner(e,Math.min(i,s),r,n)===false){return false}};e.prototype.sliceInner=function t(e,i){if(e==0&&i==this.length){return this}var r=this.left.length;if(i<=r){return this.left.slice(e,i)}if(e>=r){return this.right.slice(e-r,i-r)}return this.left.slice(e,r).append(this.right.slice(0,i-r))};e.prototype.leafAppend=function t(i){var r=this.right.leafAppend(i);if(r){return new e(this.left,r)}};e.prototype.leafPrepend=function t(i){var r=this.left.leafPrepend(i);if(r){return new e(r,this.right)}};e.prototype.appendInner=function t(i){if(this.left.depth>=Math.max(this.right.depth,i.depth)+1){return new e(this.left,new e(this.right,i))}return new e(this,i)};return e}(lf);const uf=500;class hf{constructor(t,e){this.items=t;this.eventCount=e}popEvent(t,e){if(this.eventCount==0)return null;let i=this.items.length;for(;;i--){let t=this.items.get(i-1);if(t.selection){--i;break}}let r,n;if(e){r=this.remapping(i,this.items.length);n=r.maps.length}let s=t.tr;let l,f;let o=[],u=[];this.items.forEach(((t,e)=>{if(!t.step){if(!r){r=this.remapping(i,e+1);n=r.maps.length}n--;u.push(t);return}if(r){u.push(new cf(t.map));let e=t.step.map(r.slice(n)),i;if(e&&s.maybeStep(e).doc){i=s.mapping.maps[s.mapping.maps.length-1];o.push(new cf(i,undefined,undefined,o.length+u.length))}n--;if(i)r.appendMap(i,n)}else{s.maybeStep(t.step)}if(t.selection){l=r?t.selection.map(r.slice(n)):t.selection;f=new hf(this.items.slice(0,i).append(u.reverse().concat(o)),this.eventCount-1);return false}}),this.items.length,0);return{remaining:f,transform:s,selection:l}}addTransform(t,e,i,r){let n=[],s=this.eventCount;let l=this.items,f=!r&&l.length?l.get(l.length-1):null;for(let i=0;i<t.steps.length;i++){let o=t.steps[i].invert(t.docs[i]);let u=new cf(t.mapping.maps[i],o,e),h;if(h=f&&f.merge(u)){u=h;if(i)n.pop();else l=l.slice(0,l.length-1)}n.push(u);if(e){s++;e=undefined}if(!r)f=u}let o=s-i.depth;if(o>pf){l=af(l,o);s-=o}return new hf(l.append(n),s)}remapping(t,e){let i=new Tt;this.items.forEach(((e,r)=>{let n=e.mirrorOffset!=null&&r-e.mirrorOffset>=t?i.maps.length-e.mirrorOffset:undefined;i.appendMap(e.map,n)}),t,e);return i}addMaps(t){if(this.eventCount==0)return this;return new hf(this.items.append(t.map((t=>new cf(t)))),this.eventCount)}rebased(t,e){if(!this.eventCount)return this;let i=[],r=Math.max(0,this.items.length-e);let n=t.mapping;let s=t.steps.length;let l=this.eventCount;this.items.forEach((t=>{if(t.selection)l--}),r);let f=e;this.items.forEach((e=>{let r=n.getMirror(--f);if(r==null)return;s=Math.min(s,r);let o=n.maps[r];if(e.step){let s=t.steps[r].invert(t.docs[r]);let u=e.selection&&e.selection.map(n.slice(f+1,r));if(u)l++;i.push(new cf(o,s,u))}else{i.push(new cf(o))}}),r);let o=[];for(let t=e;t<s;t++)o.push(new cf(n.maps[t]));let u=this.items.slice(0,r).append(o).append(i);let h=new hf(u,l);if(h.emptyItemCount()>uf)h=h.compress(this.items.length-i.length);return h}emptyItemCount(){let t=0;this.items.forEach((e=>{if(!e.step)t++}));return t}compress(t=this.items.length){let e=this.remapping(0,t),i=e.maps.length;let r=[],n=0;this.items.forEach(((s,l)=>{if(l>=t){r.push(s);if(s.selection)n++}else if(s.step){let t=s.step.map(e.slice(i)),l=t&&t.getMap();i--;if(l)e.appendMap(l,i);if(t){let f=s.selection&&s.selection.map(e.slice(i));if(f)n++;let o=new cf(l.invert(),t,f),u,h=r.length-1;if(u=r.length&&r[h].merge(o))r[h]=u;else r.push(o)}}else if(s.map){i--}}),this.items.length,0);return new hf(lf.from(r.reverse()),n)}}hf.empty=new hf(lf.empty,0);function af(t,e){let i;t.forEach(((t,r)=>{if(t.selection&&e--==0){i=r;return false}}));return t.slice(i)}class cf{constructor(t,e,i,r){this.map=t;this.step=e;this.selection=i;this.mirrorOffset=r}merge(t){if(this.step&&t.step&&!t.selection){let e=t.step.merge(this.step);if(e)return new cf(e.getMap().invert(),e,this.selection)}}}class df{constructor(t,e,i,r,n){this.done=t;this.undone=e;this.prevRanges=i;this.prevTime=r;this.prevComposition=n}}const pf=20;function mf(t,e,i,r){let n=i.getMeta(xf),s;if(n)return n.historyState;if(i.getMeta(Sf))t=new df(t.done,t.undone,null,0,-1);let l=i.getMeta("appendedTransaction");if(i.steps.length==0){return t}else if(l&&l.getMeta(xf)){if(l.getMeta(xf).redo)return new df(t.done.addTransform(i,undefined,r,Mf(e)),t.undone,gf(i.mapping.maps[i.steps.length-1]),t.prevTime,t.prevComposition);else return new df(t.done,t.undone.addTransform(i,undefined,r,Mf(e)),null,t.prevTime,t.prevComposition)}else if(i.getMeta("addToHistory")!==false&&!(l&&l.getMeta("addToHistory")===false)){let n=i.getMeta("composition");let s=t.prevTime==0||!l&&t.prevComposition!=n&&(t.prevTime<(i.time||0)-r.newGroupDelay||!wf(i,t.prevRanges));let f=l?bf(t.prevRanges,i.mapping):gf(i.mapping.maps[i.steps.length-1]);return new df(t.done.addTransform(i,s?e.selection.getBookmark():undefined,r,Mf(e)),hf.empty,f,i.time,n==null?t.prevComposition:n)}else if(s=i.getMeta("rebased")){return new df(t.done.rebased(i,s),t.undone.rebased(i,s),bf(t.prevRanges,i.mapping),t.prevTime,t.prevComposition)}else{return new df(t.done.addMaps(i.mapping.maps),t.undone.addMaps(i.mapping.maps),bf(t.prevRanges,i.mapping),t.prevTime,t.prevComposition)}}function wf(t,e){if(!e)return false;if(!t.docChanged)return true;let i=false;t.mapping.maps[0].forEach(((t,r)=>{for(let n=0;n<e.length;n+=2)if(t<=e[n+1]&&r>=e[n])i=true}));return i}function gf(t){let e=[];t.forEach(((t,i,r,n)=>e.push(r,n)));return e}function bf(t,e){if(!t)return null;let i=[];for(let r=0;r<t.length;r+=2){let n=e.map(t[r],1),s=e.map(t[r+1],-1);if(n<=s)i.push(n,s)}return i}function vf(t,e,i,r){let n=Mf(e);let s=xf.get(e).spec.config;let l=(r?t.undone:t.done).popEvent(e,n);if(!l)return;let f=l.selection.resolve(l.transform.doc);let o=(r?t.done:t.undone).addTransform(l.transform,e.selection.getBookmark(),s,n);let u=new df(r?o:l.remaining,r?l.remaining:o,null,0,-1);i(l.transform.setSelection(f).setMeta(xf,{redo:r,historyState:u}).scrollIntoView())}let yf=false,kf=null;function Mf(t){let e=t.plugins;if(kf!=e){yf=false;kf=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){yf=true;break}}return yf}const xf=new ni("history");const Sf=new ni("closeHistory");function Of(t={}){t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500};return new ei({key:xf,state:{init(){return new df(hf.empty,hf.empty,null,0,-1)},apply(e,i,r){return mf(i,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(t,e){let i=e.inputType;let r=i=="historyUndo"?Ef:i=="historyRedo"?Df:null;if(!r)return false;e.preventDefault();return r(t.state,t.dispatch)}}}})}const Ef=(t,e)=>{let i=xf.getState(t);if(!i||i.done.eventCount==0)return false;if(e)vf(i,t,e,false);return true};const Df=(t,e)=>{let i=xf.getState(t);if(!i||i.undone.eventCount==0)return false;if(e)vf(i,t,e,true);return true};const Nf=(t,e)=>{if(t.selection.empty)return false;if(e)e(t.tr.deleteSelection().scrollIntoView());return true};function $f(t,e){let{$cursor:i}=t.selection;if(!i||(e?!e.endOfTextblock("backward",t):i.parentOffset>0))return null;return i}const Rf=(t,e,i)=>{let r=$f(t,i);if(!r)return false;let n=Tf(r);if(!n){let i=r.blockRange(),n=i&&Vt(i);if(n==null)return false;if(e)e(t.tr.lift(i,n).scrollIntoView());return true}let s=n.nodeBefore;if(!s.type.spec.isolating&&Yf(t,n,e))return true;if(r.parent.content.size==0&&(qf(s,"end")||Be.isSelectable(s))){let i=de(t.doc,r.before(),r.after(),d.empty);if(i&&i.slice.size<i.to-i.from){if(e){let r=t.tr.step(i);r.setSelection(qf(s,"end")?Te.findFrom(r.doc.resolve(r.mapping.map(n.pos,-1)),-1):Be.create(r.doc,n.pos-s.nodeSize));e(r.scrollIntoView())}return true}}if(s.isAtom&&n.depth==r.depth-1){if(e)e(t.tr.delete(n.pos-s.nodeSize,n.pos).scrollIntoView());return true}return false};function qf(t,e,i=false){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return true;if(i&&r.childCount!=1)return false}return false}const Cf=(t,e,i)=>{let{$head:r,empty:n}=t.selection,s=r;if(!n)return false;if(r.parent.isTextblock){if(i?!i.endOfTextblock("backward",t):r.parentOffset>0)return false;s=Tf(r)}let l=s&&s.nodeBefore;if(!l||!Be.isSelectable(l))return false;if(e)e(t.tr.setSelection(Be.create(t.doc,s.pos-l.nodeSize)).scrollIntoView());return true};function Tf(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function Af(t,e){let{$cursor:i}=t.selection;if(!i||(e?!e.endOfTextblock("forward",t):i.parentOffset<i.parent.content.size))return null;return i}const If=(t,e,i)=>{let r=Af(t,i);if(!r)return false;let n=zf(r);if(!n)return false;let s=n.nodeAfter;if(Yf(t,n,e))return true;if(r.parent.content.size==0&&(qf(s,"start")||Be.isSelectable(s))){let i=de(t.doc,r.before(),r.after(),d.empty);if(i&&i.slice.size<i.to-i.from){if(e){let r=t.tr.step(i);r.setSelection(qf(s,"start")?Te.findFrom(r.doc.resolve(r.mapping.map(n.pos)),1):Be.create(r.doc,r.mapping.map(n.pos)));e(r.scrollIntoView())}return true}}if(s.isAtom&&n.depth==r.depth-1){if(e)e(t.tr.delete(n.pos,n.pos+s.nodeSize).scrollIntoView());return true}return false};const Pf=(t,e,i)=>{let{$head:r,empty:n}=t.selection,s=r;if(!n)return false;if(r.parent.isTextblock){if(i?!i.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return false;s=zf(r)}let l=s&&s.nodeAfter;if(!l||!Be.isSelectable(l))return false;if(e)e(t.tr.setSelection(Be.create(t.doc,s.pos)).scrollIntoView());return true};function zf(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let i=t.node(e);if(t.index(e)+1<i.childCount)return t.doc.resolve(t.after(e+1));if(i.type.spec.isolating)break}return null}const Jf=(t,e)=>{let i=t.selection,r=i instanceof Be,n;if(r){if(i.node.isTextblock||!fe(t.doc,i.from))return false;n=i.from}else{n=ue(t.doc,i.from,-1);if(n==null)return false}if(e){let i=t.tr.join(n);if(r)i.setSelection(Be.create(i.doc,n-t.doc.resolve(n).nodeBefore.nodeSize));e(i.scrollIntoView())}return true};const Bf=(t,e)=>{let i=t.selection,r;if(i instanceof Be){if(i.node.isTextblock||!fe(t.doc,i.to))return false;r=i.to}else{r=ue(t.doc,i.to,1);if(r==null)return false}if(e)e(t.tr.join(r).scrollIntoView());return true};const jf=(t,e)=>{let{$from:i,$to:r}=t.selection;let n=i.blockRange(r),s=n&&Vt(n);if(s==null)return false;if(e)e(t.tr.lift(n,s).scrollIntoView());return true};const Ff=(t,e)=>{let{$head:i,$anchor:r}=t.selection;if(!i.parent.type.spec.code||!i.sameParent(r))return false;if(e)e(t.tr.insertText("\n").scrollIntoView());return true};function Lf(t){for(let e=0;e<t.edgeCount;e++){let{type:i}=t.edge(e);if(i.isTextblock&&!i.hasRequiredAttrs())return i}return null}const Wf=(t,e)=>{let{$head:i,$anchor:r}=t.selection;if(!i.parent.type.spec.code||!i.sameParent(r))return false;let n=i.node(-1),s=i.indexAfter(-1),l=Lf(n.contentMatchAt(s));if(!l||!n.canReplaceWith(s,s,l))return false;if(e){let r=i.after(),n=t.tr.replaceWith(r,r,l.createAndFill());n.setSelection(Te.near(n.doc.resolve(r),1));e(n.scrollIntoView())}return true};const _f=(t,e)=>{let i=t.selection,{$from:r,$to:n}=i;if(i instanceof Fe||r.parent.inlineContent||n.parent.inlineContent)return false;let s=Lf(n.parent.contentMatchAt(n.indexAfter()));if(!s||!s.isTextblock)return false;if(e){let i=(!r.parentOffset&&n.index()<n.parent.childCount?r:n).pos;let l=t.tr.insert(i,s.createAndFill());l.setSelection(ze.create(l.doc,i+1));e(l.scrollIntoView())}return true};const Uf=(t,e)=>{let{$cursor:i}=t.selection;if(!i||i.parent.content.size)return false;if(i.depth>1&&i.after()!=i.end(-1)){let r=i.before();if(se(t.doc,r)){if(e)e(t.tr.split(r).scrollIntoView());return true}}let r=i.blockRange(),n=r&&Vt(r);if(n==null)return false;if(e)e(t.tr.lift(r,n).scrollIntoView());return true};function Kf(t){return(e,i)=>{let{$from:r,$to:n}=e.selection;if(e.selection instanceof Be&&e.selection.node.isBlock){if(!r.parentOffset||!se(e.doc,r.pos))return false;if(i)i(e.tr.split(r.pos).scrollIntoView());return true}if(!r.parent.isBlock)return false;if(i){let s=n.parentOffset==n.parent.content.size;let l=e.tr;if(e.selection instanceof ze||e.selection instanceof Fe)l.deleteSelection();let f=r.depth==0?null:Lf(r.node(-1).contentMatchAt(r.indexAfter(-1)));let o=t&&t(n.parent,s);let u=o?[o]:s&&f?[{type:f}]:undefined;let h=se(l.doc,l.mapping.map(r.pos),1,u);if(!u&&!h&&se(l.doc,l.mapping.map(r.pos),1,f?[{type:f}]:undefined)){if(f)u=[{type:f}];h=true}if(h){l.split(l.mapping.map(r.pos),1,u);if(!s&&!r.parentOffset&&r.parent.type!=f){let t=l.mapping.map(r.before()),e=l.doc.resolve(t);if(f&&r.node(-1).canReplaceWith(e.index(),e.index()+1,f))l.setNodeMarkup(l.mapping.map(r.before()),f)}}i(l.scrollIntoView())}return true}}const Hf=Kf();const Gf=(t,e)=>{let{$from:i,to:r}=t.selection,n;let s=i.sharedDepth(r);if(s==0)return false;n=i.before(s);if(e)e(t.tr.setSelection(Be.create(t.doc,n)));return true};const Vf=(t,e)=>{if(e)e(t.tr.setSelection(new Fe(t.doc)));return true};function Xf(t,e,i){let r=e.nodeBefore,n=e.nodeAfter,s=e.index();if(!r||!n||!r.type.compatibleContent(n.type))return false;if(!r.content.size&&e.parent.canReplace(s-1,s)){if(i)i(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView());return true}if(!e.parent.canReplace(s,s+1)||!(n.isTextblock||fe(t.doc,e.pos)))return false;if(i)i(t.tr.clearIncompatible(e.pos,r.type,r.contentMatchAt(r.childCount)).join(e.pos).scrollIntoView());return true}function Yf(t,e,i){let r=e.nodeBefore,n=e.nodeAfter,s,l;if(r.type.spec.isolating||n.type.spec.isolating)return false;if(Xf(t,e,i))return true;let o=e.parent.canReplace(e.index(),e.index()+1);if(o&&(s=(l=r.contentMatchAt(r.childCount)).findWrapping(n.type))&&l.matchType(s[0]||n.type).validEnd){if(i){let l=e.pos+n.nodeSize,o=f.empty;for(let t=s.length-1;t>=0;t--)o=f.from(s[t].create(null,o));o=f.from(r.copy(o));let u=t.tr.step(new Wt(e.pos-1,l,e.pos,l,new d(o,1,0),s.length,true));let h=l+2*s.length;if(fe(u.doc,h))u.join(h);i(u.scrollIntoView())}return true}let u=Te.findFrom(e,1);let h=u&&u.$from.blockRange(u.$to),a=h&&Vt(h);if(a!=null&&a>=e.depth){if(i)i(t.tr.lift(h,a).scrollIntoView());return true}if(o&&qf(n,"start",true)&&qf(r,"end")){let s=r,l=[];for(;;){l.push(s);if(s.isTextblock)break;s=s.lastChild}let o=n,u=1;for(;!o.isTextblock;o=o.firstChild)u++;if(s.canReplace(s.childCount,s.childCount,o.content)){if(i){let r=f.empty;for(let t=l.length-1;t>=0;t--)r=f.from(l[t].copy(r));let s=t.tr.step(new Wt(e.pos-l.length,e.pos+n.nodeSize,e.pos+u,e.pos+n.nodeSize-u,new d(r,l.length,0),0,true));i(s.scrollIntoView())}return true}}return false}function Qf(t){return function(e,i){let r=e.selection,n=t<0?r.$from:r.$to;let s=n.depth;while(n.node(s).isInline){if(!s)return false;s--}if(!n.node(s).isTextblock)return false;if(i)i(e.tr.setSelection(ze.create(e.doc,t<0?n.start(s):n.end(s))));return true}}const Zf=Qf(-1);const to=Qf(1);function eo(t,e=null){return function(i,r){let{$from:n,$to:s}=i.selection;let l=n.blockRange(s),f=l&&Yt(l,t,e);if(!f)return false;if(r)r(i.tr.wrap(l,f).scrollIntoView());return true}}function io(t,e=null){return function(i,r){let n=false;for(let r=0;r<i.selection.ranges.length&&!n;r++){let{$from:{pos:s},$to:{pos:l}}=i.selection.ranges[r];i.doc.nodesBetween(s,l,((r,s)=>{if(n)return false;if(!r.isTextblock||r.hasMarkup(t,e))return;if(r.type==t){n=true}else{let e=i.doc.resolve(s),r=e.index();n=e.parent.canReplaceWith(r,r+1,t)}}))}if(!n)return false;if(r){let n=i.tr;for(let r=0;r<i.selection.ranges.length;r++){let{$from:{pos:s},$to:{pos:l}}=i.selection.ranges[r];n.setBlockType(s,l,t,e)}r(n.scrollIntoView())}return true}}function ro(t,e,i){for(let r=0;r<e.length;r++){let{$from:n,$to:s}=e[r];let l=n.depth==0?t.inlineContent&&t.type.allowsMarkType(i):false;t.nodesBetween(n.pos,s.pos,(t=>{if(l)return false;l=t.inlineContent&&t.type.allowsMarkType(i)}));if(l)return true}return false}function no(t,e=null){return function(i,r){let{empty:n,$cursor:s,ranges:l}=i.selection;if(n&&!s||!ro(i.doc,l,t))return false;if(r){if(s){if(t.isInSet(i.storedMarks||s.marks()))r(i.tr.removeStoredMark(t));else r(i.tr.addStoredMark(t.create(e)))}else{let n=false,s=i.tr;for(let e=0;!n&&e<l.length;e++){let{$from:r,$to:s}=l[e];n=i.doc.rangeHasMark(r.pos,s.pos,t)}for(let i=0;i<l.length;i++){let{$from:r,$to:f}=l[i];if(n){s.removeMark(r.pos,f.pos,t)}else{let i=r.pos,n=f.pos,l=r.nodeAfter,o=f.nodeBefore;let u=l&&l.isText?/^\s*/.exec(l.text)[0].length:0;let h=o&&o.isText?/\s*$/.exec(o.text)[0].length:0;if(i+u<n){i+=u;n-=h}s.addMark(i,n,t.create(e))}}r(s.scrollIntoView())}}return true}}function so(...t){return function(e,i,r){for(let n=0;n<t.length;n++)if(t[n](e,i,r))return true;return false}}let lo=so(Nf,Rf,Cf);let fo=so(Nf,If,Pf);const oo={Enter:so(Ff,_f,Uf,Hf),"Mod-Enter":Wf,Backspace:lo,"Mod-Backspace":lo,"Shift-Backspace":lo,Delete:fo,"Mod-Delete":fo,"Mod-a":Vf};const uo={"Ctrl-h":oo["Backspace"],"Alt-Backspace":oo["Mod-Backspace"],"Ctrl-d":oo["Delete"],"Ctrl-Alt-Backspace":oo["Mod-Delete"],"Alt-Delete":oo["Mod-Delete"],"Alt-d":oo["Mod-Delete"],"Ctrl-a":Zf,"Ctrl-e":to};for(let t in oo)uo[t]=oo[t];const ho=typeof navigator!="undefined"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os!="undefined"&&os.platform?os.platform()=="darwin":false;const ao=ho?uo:oo;function co(t={}){return new ei({view(e){return new po(e,t)}})}class po{constructor(t,e){var i;this.editorView=t;this.cursorPos=null;this.element=null;this.timeout=-1;this.width=(i=e.width)!==null&&i!==void 0?i:1;this.color=e.color===false?undefined:e.color||"black";this.class=e.class;this.handlers=["dragover","dragend","drop","dragleave"].map((e=>{let i=t=>{this[e](t)};t.dom.addEventListener(e,i);return{name:e,handler:i}}))}destroy(){this.handlers.forEach((({name:t,handler:e})=>this.editorView.dom.removeEventListener(t,e)))}update(t,e){if(this.cursorPos!=null&&e.doc!=t.state.doc){if(this.cursorPos>t.state.doc.content.size)this.setCursor(null);else this.updateOverlay()}}setCursor(t){if(t==this.cursorPos)return;this.cursorPos=t;if(t==null){this.element.parentNode.removeChild(this.element);this.element=null}else{this.updateOverlay()}}updateOverlay(){let t=this.editorView.state.doc.resolve(this.cursorPos);let e=!t.parent.inlineContent,i;if(e){let e=t.nodeBefore,r=t.nodeAfter;if(e||r){let t=this.editorView.nodeDOM(this.cursorPos-(e?e.nodeSize:0));if(t){let n=t.getBoundingClientRect();let s=e?n.bottom:n.top;if(e&&r)s=(s+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2;i={left:n.left,right:n.right,top:s-this.width/2,bottom:s+this.width/2}}}}if(!i){let t=this.editorView.coordsAtPos(this.cursorPos);i={left:t.left-this.width/2,right:t.left+this.width/2,top:t.top,bottom:t.bottom}}let r=this.editorView.dom.offsetParent;if(!this.element){this.element=r.appendChild(document.createElement("div"));if(this.class)this.element.className=this.class;this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;";if(this.color){this.element.style.backgroundColor=this.color}}this.element.classList.toggle("prosemirror-dropcursor-block",e);this.element.classList.toggle("prosemirror-dropcursor-inline",!e);let n,s;if(!r||r==document.body&&getComputedStyle(r).position=="static"){n=-pageXOffset;s=-pageYOffset}else{let t=r.getBoundingClientRect();n=t.left-r.scrollLeft;s=t.top-r.scrollTop}this.element.style.left=i.left-n+"px";this.element.style.top=i.top-s+"px";this.element.style.width=i.right-i.left+"px";this.element.style.height=i.bottom-i.top+"px"}scheduleRemoval(t){clearTimeout(this.timeout);this.timeout=setTimeout((()=>this.setCursor(null)),t)}dragover(t){if(!this.editorView.editable)return;let e=this.editorView.posAtCoords({left:t.clientX,top:t.clientY});let i=e&&e.inside>=0&&this.editorView.state.doc.nodeAt(e.inside);let r=i&&i.type.spec.disableDropCursor;let n=typeof r=="function"?r(this.editorView,e,t):r;if(e&&!n){let t=e.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let e=ce(this.editorView.state.doc,t,this.editorView.dragging.slice);if(e!=null)t=e}this.setCursor(t);this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(t){if(t.target==this.editorView.dom||!this.editorView.dom.contains(t.relatedTarget))this.setCursor(null)}}class mo extends Te{constructor(t){super(t,t)}map(t,e){let i=t.resolve(e.map(this.head));return mo.valid(i)?new mo(i):Te.near(i)}content(){return d.empty}eq(t){return t instanceof mo&&t.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(t,e){if(typeof e.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new mo(t.resolve(e.pos))}getBookmark(){return new wo(this.anchor)}static valid(t){let e=t.parent;if(e.isTextblock||!go(t)||!bo(t))return false;let i=e.type.spec.allowGapCursor;if(i!=null)return i;let r=e.contentMatchAt(t.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(t,e,i=false){t:for(;;){if(!i&&mo.valid(t))return t;let r=t.pos,n=null;for(let i=t.depth;;i--){let s=t.node(i);if(e>0?t.indexAfter(i)<s.childCount:t.index(i)>0){n=s.child(e>0?t.indexAfter(i):t.index(i)-1);break}else if(i==0){return null}r+=e;let l=t.doc.resolve(r);if(mo.valid(l))return l}for(;;){let s=e>0?n.firstChild:n.lastChild;if(!s){if(n.isAtom&&!n.isText&&!Be.isSelectable(n)){t=t.doc.resolve(r+n.nodeSize*e);i=false;continue t}break}n=s;r+=e;let l=t.doc.resolve(r);if(mo.valid(l))return l}return null}}}mo.prototype.visible=false;mo.findFrom=mo.findGapCursorFrom;Te.jsonID("gapcursor",mo);class wo{constructor(t){this.pos=t}map(t){return new wo(t.map(this.pos))}resolve(t){let e=t.resolve(this.pos);return mo.valid(e)?new mo(e):Te.near(e)}}function go(t){for(let e=t.depth;e>=0;e--){let i=t.index(e),r=t.node(e);if(i==0){if(r.type.spec.isolating)return true;continue}for(let t=r.child(i-1);;t=t.lastChild){if(t.childCount==0&&!t.inlineContent||t.isAtom||t.type.spec.isolating)return true;if(t.inlineContent)return false}}return true}function bo(t){for(let e=t.depth;e>=0;e--){let i=t.indexAfter(e),r=t.node(e);if(i==r.childCount){if(r.type.spec.isolating)return true;continue}for(let t=r.child(i);;t=t.firstChild){if(t.childCount==0&&!t.inlineContent||t.isAtom||t.type.spec.isolating)return true;if(t.inlineContent)return false}}return true}function vo(){return new ei({props:{decorations:So,createSelectionBetween(t,e,i){return e.pos==i.pos&&mo.valid(i)?new mo(i):null},handleClick:Mo,handleKeyDown:yo,handleDOMEvents:{beforeinput:xo}}})}const yo=nf({ArrowLeft:ko("horiz",-1),ArrowRight:ko("horiz",1),ArrowUp:ko("vert",-1),ArrowDown:ko("vert",1)});function ko(t,e){const i=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(t,r,n){let s=t.selection;let l=e>0?s.$to:s.$from,f=s.empty;if(s instanceof ze){if(!n.endOfTextblock(i)||l.depth==0)return false;f=false;l=t.doc.resolve(e>0?l.after():l.before())}let o=mo.findGapCursorFrom(l,e,f);if(!o)return false;if(r)r(t.tr.setSelection(new mo(o)));return true}}function Mo(t,e,i){if(!t||!t.editable)return false;let r=t.state.doc.resolve(e);if(!mo.valid(r))return false;let n=t.posAtCoords({left:i.clientX,top:i.clientY});if(n&&n.inside>-1&&Be.isSelectable(t.state.doc.nodeAt(n.inside)))return false;t.dispatch(t.state.tr.setSelection(new mo(r)));return true}function xo(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof mo))return false;let{$from:i}=t.state.selection;let r=i.parent.contentMatchAt(i.index()).findWrapping(t.state.schema.nodes.text);if(!r)return false;let n=f.empty;for(let t=r.length-1;t>=0;t--)n=f.from(r[t].createAndFill(null,n));let s=t.state.tr.replace(i.pos,i.pos,new d(n,0,0));s.setSelection(ze.near(s.doc.resolve(i.pos+1)));t.dispatch(s);return false}function So(t){if(!(t.selection instanceof mo))return null;let e=document.createElement("div");e.className="ProseMirror-gapcursor";return As.create(t.doc,[qs.widget(t.selection.head,e,{key:"gapcursor"})])}function Oo(){var t=arguments[0];if(typeof t=="string")t=document.createElement(t);var e=1,i=arguments[1];if(i&&typeof i=="object"&&i.nodeType==null&&!Array.isArray(i)){for(var r in i)if(Object.prototype.hasOwnProperty.call(i,r)){var n=i[r];if(typeof n=="string")t.setAttribute(r,n);else if(n!=null)t[r]=n}e++}for(;e<arguments.length;e++)Eo(t,arguments[e]);return t}function Eo(t,e){if(typeof e=="string"){t.appendChild(document.createTextNode(e))}else if(e==null);else if(e.nodeType!=null){t.appendChild(e)}else if(Array.isArray(e)){for(var i=0;i<e.length;i++)Eo(t,e[i])}else{throw new RangeError("Unsupported child node: "+e)}}const Do="http://www.w3.org/2000/svg";const No="http://www.w3.org/1999/xlink";const $o="ProseMirror-icon";function Ro(t){let e=0;for(let i=0;i<t.length;i++)e=(e<<5)-e+t.charCodeAt(i)|0;return e}function qo(t,e){let i=(t.nodeType==9?t:t.ownerDocument)||document;let r=i.createElement("div");r.className=$o;if(e.path){let{path:n,width:s,height:l}=e;let f="pm-icon-"+Ro(n).toString(16);if(!i.getElementById(f))Co(t,f,e);let o=r.appendChild(i.createElementNS(Do,"svg"));o.style.width=s/l+"em";let u=o.appendChild(i.createElementNS(Do,"use"));u.setAttributeNS(No,"href",/([^#]*)/.exec(i.location.toString())[1]+"#"+f)}else if(e.dom){r.appendChild(e.dom.cloneNode(true))}else{let{text:t,css:n}=e;r.appendChild(i.createElement("span")).textContent=t||"";if(n)r.firstChild.style.cssText=n}return r}function Co(t,e,i){let[r,n]=t.nodeType==9?[t,t.body]:[t.ownerDocument||document,t];let s=r.getElementById($o+"-collection");if(!s){s=r.createElementNS(Do,"svg");s.id=$o+"-collection";s.style.display="none";n.insertBefore(s,n.firstChild)}let l=r.createElementNS(Do,"symbol");l.id=e;l.setAttribute("viewBox","0 0 "+i.width+" "+i.height);let f=l.appendChild(r.createElementNS(Do,"path"));f.setAttribute("d",i.path);s.appendChild(l)}const To="ProseMirror-menu";class Ao{constructor(t){this.spec=t}render(t){let e=this.spec;let i=e.render?e.render(t):e.icon?qo(t.root,e.icon):e.label?Oo("div",null,Io(t,e.label)):null;if(!i)throw new RangeError("MenuItem without icon or label property");if(e.title){const r=typeof e.title==="function"?e.title(t.state):e.title;i.setAttribute("title",Io(t,r))}if(e.class)i.classList.add(e.class);if(e.css)i.style.cssText+=e.css;i.addEventListener("mousedown",(r=>{r.preventDefault();if(!i.classList.contains(To+"-disabled"))e.run(t.state,t.dispatch,t,r)}));function r(t){if(e.select){let r=e.select(t);i.style.display=r?"":"none";if(!r)return false}let r=true;if(e.enable){r=e.enable(t)||false;Zo(i,To+"-disabled",!r)}if(e.active){let n=r&&e.active(t)||false;Zo(i,To+"-active",n)}return true}return{dom:i,update:r}}}function Io(t,e){return t._props.translate?t._props.translate(e):e}let Po={time:0,node:null};function zo(t){Po.time=Date.now();Po.node=t.target}function Jo(t){return Date.now()-100<Po.time&&Po.node&&t.contains(Po.node)}class Bo{constructor(t,e={}){this.options=e;this.options=e||{};this.content=Array.isArray(t)?t:[t]}render(t){let e=jo(this.content,t);let i=t.dom.ownerDocument.defaultView||window;let r=Oo("div",{class:To+"-dropdown "+(this.options.class||""),style:this.options.css},Io(t,this.options.label||""));if(this.options.title)r.setAttribute("title",Io(t,this.options.title));let n=Oo("div",{class:To+"-dropdown-wrap"},r);let s=null;let l=null;let f=()=>{if(s&&s.close()){s=null;i.removeEventListener("mousedown",l)}};r.addEventListener("mousedown",(t=>{t.preventDefault();zo(t);if(s){f()}else{s=this.expand(n,e.dom);i.addEventListener("mousedown",l=()=>{if(!Jo(n))f()})}}));function o(t){let i=e.update(t);n.style.display=i?"":"none";return i}return{dom:n,update:o}}expand(t,e){let i=Oo("div",{class:To+"-dropdown-menu "+(this.options.class||"")},e);let r=false;function n(){if(r)return false;r=true;t.removeChild(i);return true}t.appendChild(i);return{close:n,node:i}}}function jo(t,e){let i=[],r=[];for(let n=0;n<t.length;n++){let{dom:s,update:l}=t[n].render(e);i.push(Oo("div",{class:To+"-dropdown-item"},s));r.push(l)}return{dom:i,update:Fo(r,i)}}function Fo(t,e){return i=>{let r=false;for(let n=0;n<t.length;n++){let s=t[n](i);e[n].style.display=s?"":"none";if(s)r=true}return r}}class Lo{constructor(t,e={}){this.options=e;this.content=Array.isArray(t)?t:[t]}render(t){let e=jo(this.content,t);let i=t.dom.ownerDocument.defaultView||window;let r=Oo("div",{class:To+"-submenu-label"},Io(t,this.options.label||""));let n=Oo("div",{class:To+"-submenu-wrap"},r,Oo("div",{class:To+"-submenu"},e.dom));let s=null;r.addEventListener("mousedown",(t=>{t.preventDefault();zo(t);Zo(n,To+"-submenu-wrap-active",false);if(!s)i.addEventListener("mousedown",s=()=>{if(!Jo(n)){n.classList.remove(To+"-submenu-wrap-active");i.removeEventListener("mousedown",s);s=null}})}));function l(t){let i=e.update(t);n.style.display=i?"":"none";return i}return{dom:n,update:l}}}function Wo(t,e){let i=document.createDocumentFragment();let r=[],n=[];for(let s=0;s<e.length;s++){let l=e[s],f=[],o=[];for(let e=0;e<l.length;e++){let{dom:r,update:n}=l[e].render(t);let s=Oo("span",{class:To+"item"},r);i.appendChild(s);o.push(s);f.push(n)}if(f.length){r.push(Fo(f,o));if(s<e.length-1)n.push(i.appendChild(_o()))}}function s(t){let e=false,i=false;for(let s=0;s<r.length;s++){let l=r[s](t);if(s)n[s-1].style.display=i&&l?"":"none";i=l;if(l)e=true}return e}return{dom:i,update:s}}function _o(){return Oo("span",{class:To+"separator"})}const Uo={join:{width:800,height:900,path:"M0 75h800v125h-800z M0 825h800v-125h-800z M250 400h100v-100h100v100h100v100h-100v100h-100v-100h-100z"},lift:{width:1024,height:1024,path:"M219 310v329q0 7-5 12t-12 5q-8 0-13-5l-164-164q-5-5-5-13t5-13l164-164q5-5 13-5 7 0 12 5t5 12zM1024 749v109q0 7-5 12t-12 5h-987q-7 0-12-5t-5-12v-109q0-7 5-12t12-5h987q7 0 12 5t5 12zM1024 530v109q0 7-5 12t-12 5h-621q-7 0-12-5t-5-12v-109q0-7 5-12t12-5h621q7 0 12 5t5 12zM1024 310v109q0 7-5 12t-12 5h-621q-7 0-12-5t-5-12v-109q0-7 5-12t12-5h621q7 0 12 5t5 12zM1024 91v109q0 7-5 12t-12 5h-987q-7 0-12-5t-5-12v-109q0-7 5-12t12-5h987q7 0 12 5t5 12z"},selectParentNode:{text:"⬚",css:"font-weight: bold"},undo:{width:1024,height:1024,path:"M761 1024c113-206 132-520-313-509v253l-384-384 384-384v248c534-13 594 472 313 775z"},redo:{width:1024,height:1024,path:"M576 248v-248l384 384-384 384v-253c-446-10-427 303-313 509-280-303-221-789 313-775z"},strong:{width:805,height:1024,path:"M317 869q42 18 80 18 214 0 214-191 0-65-23-102-15-25-35-42t-38-26-46-14-48-6-54-1q-41 0-57 5 0 30-0 90t-0 90q0 4-0 38t-0 55 2 47 6 38zM309 442q24 4 62 4 46 0 81-7t62-25 42-51 14-81q0-40-16-70t-45-46-61-24-70-8q-28 0-74 7 0 28 2 86t2 86q0 15-0 45t-0 45q0 26 0 39zM0 950l1-53q8-2 48-9t60-15q4-6 7-15t4-19 3-18 1-21 0-19v-37q0-561-12-585-2-4-12-8t-25-6-28-4-27-2-17-1l-2-47q56-1 194-6t213-5q13 0 39 0t38 0q40 0 78 7t73 24 61 40 42 59 16 78q0 29-9 54t-22 41-36 32-41 25-48 22q88 20 146 76t58 141q0 57-20 102t-53 74-78 48-93 27-100 8q-25 0-75-1t-75-1q-60 0-175 6t-132 6z"},em:{width:585,height:1024,path:"M0 949l9-48q3-1 46-12t63-21q16-20 23-57 0-4 35-165t65-310 29-169v-14q-13-7-31-10t-39-4-33-3l10-58q18 1 68 3t85 4 68 1q27 0 56-1t69-4 56-3q-2 22-10 50-17 5-58 16t-62 19q-4 10-8 24t-5 22-4 26-3 24q-15 84-50 239t-44 203q-1 5-7 33t-11 51-9 47-3 32l0 10q9 2 105 17-1 25-9 56-6 0-18 0t-18 0q-16 0-49-5t-49-5q-78-1-117-1-29 0-81 5t-69 6z"},code:{width:896,height:1024,path:"M608 192l-96 96 224 224-224 224 96 96 288-320-288-320zM288 192l-288 320 288 320 96-96-224-224 224-224-96-96z"},link:{width:951,height:1024,path:"M832 694q0-22-16-38l-118-118q-16-16-38-16-24 0-41 18 1 1 10 10t12 12 8 10 7 14 2 15q0 22-16 38t-38 16q-8 0-15-2t-14-7-10-8-12-12-10-10q-18 17-18 41 0 22 16 38l117 118q15 15 38 15 22 0 38-14l84-83q16-16 16-38zM430 292q0-22-16-38l-117-118q-16-16-38-16-22 0-38 15l-84 83q-16 16-16 38 0 22 16 38l118 118q15 15 38 15 24 0 41-17-1-1-10-10t-12-12-8-10-7-14-2-15q0-22 16-38t38-16q8 0 15 2t14 7 10 8 12 12 10 10q18-17 18-41zM941 694q0 68-48 116l-84 83q-47 47-116 47-69 0-116-48l-117-118q-47-47-47-116 0-70 50-119l-50-50q-49 50-118 50-68 0-116-48l-118-118q-48-48-48-116t48-116l84-83q47-47 116-47 69 0 116 48l117 118q47 47 47 116 0 70-50 119l50 50q49-50 118-50 68 0 116 48l118 118q48 48 48 116z"},bulletList:{width:768,height:896,path:"M0 512h128v-128h-128v128zM0 256h128v-128h-128v128zM0 768h128v-128h-128v128zM256 512h512v-128h-512v128zM256 256h512v-128h-512v128zM256 768h512v-128h-512v128z"},orderedList:{width:768,height:896,path:"M320 512h448v-128h-448v128zM320 768h448v-128h-448v128zM320 128v128h448v-128h-448zM79 384h78v-256h-36l-85 23v50l43-2v185zM189 590c0-36-12-78-96-78-33 0-64 6-83 16l1 66c21-10 42-15 67-15s32 11 32 28c0 26-30 58-110 112v50h192v-67l-91 2c49-30 87-66 87-113l1-1z"},blockquote:{width:640,height:896,path:"M0 448v256h256v-256h-128c0 0 0-128 128-128v-128c0 0-256 0-256 256zM640 320v-128c0 0-256 0-256 256v256h256v-256h-128c0 0 0-128 128-128z"}};const Ko=new Ao({title:"Join with above block",run:Jf,select:t=>Jf(t),icon:Uo.join});const Ho=new Ao({title:"Lift out of enclosing block",run:jf,select:t=>jf(t),icon:Uo.lift});const Go=new Ao({title:"Select parent node",run:Gf,select:t=>Gf(t),icon:Uo.selectParentNode});let Vo=new Ao({title:"Undo last change",run:Ef,enable:t=>Ef(t),icon:Uo.undo});let Xo=new Ao({title:"Redo last undone change",run:Df,enable:t=>Df(t),icon:Uo.redo});function Yo(t,e){let i={run(i,r){return eo(t,e.attrs)(i,r)},select(i){return eo(t,e.attrs)(i)}};for(let t in e)i[t]=e[t];return new Ao(i)}function Qo(t,e){let i=io(t,e.attrs);let r={run:i,enable(t){return i(t)},active(i){let{$from:r,to:n,node:s}=i.selection;if(s)return s.hasMarkup(t,e.attrs);return n<=r.end()&&r.parent.hasMarkup(t,e.attrs)}};for(let t in e)r[t]=e[t];return new Ao(r)}function Zo(t,e,i){if(i)t.classList.add(e);else t.classList.remove(e)}const tu="ProseMirror-menubar";function eu(){if(typeof navigator=="undefined")return false;let t=navigator.userAgent;return!/Edge\/\d/.test(t)&&/AppleWebKit/.test(t)&&/Mobile\/\w+/.test(t)}function iu(t){return new ei({view(e){return new ru(e,t)}})}class ru{constructor(t,e){this.editorView=t;this.options=e;this.spacer=null;this.maxHeight=0;this.widthForMaxHeight=0;this.floating=false;this.scrollHandler=null;this.wrapper=Oo("div",{class:tu+"-wrapper"});this.menu=this.wrapper.appendChild(Oo("div",{class:tu}));this.menu.className=tu;if(t.dom.parentNode)t.dom.parentNode.replaceChild(this.wrapper,t.dom);this.wrapper.appendChild(t.dom);let{dom:i,update:r}=Wo(this.editorView,this.options.content);this.contentUpdate=r;this.menu.appendChild(i);this.update();if(e.floating&&!eu()){this.updateFloat();let t=lu(this.wrapper);this.scrollHandler=e=>{let i=this.editorView.root;if(!(i.body||i).contains(this.wrapper))t.forEach((t=>t.removeEventListener("scroll",this.scrollHandler)));else this.updateFloat(e.target.getBoundingClientRect?e.target:undefined)};t.forEach((t=>t.addEventListener("scroll",this.scrollHandler)))}}update(){this.contentUpdate(this.editorView.state);if(this.floating){this.updateScrollCursor()}else{if(this.menu.offsetWidth!=this.widthForMaxHeight){this.widthForMaxHeight=this.menu.offsetWidth;this.maxHeight=0}if(this.menu.offsetHeight>this.maxHeight){this.maxHeight=this.menu.offsetHeight;this.menu.style.minHeight=this.maxHeight+"px"}}}updateScrollCursor(){let t=this.editorView.root.getSelection();if(!t.focusNode)return;let e=t.getRangeAt(0).getClientRects();let i=e[nu(t)?0:e.length-1];if(!i)return;let r=this.menu.getBoundingClientRect();if(i.top<r.bottom&&i.bottom>r.top){let t=su(this.wrapper);if(t)t.scrollTop-=r.bottom-i.top}}updateFloat(t){let e=this.wrapper,i=e.getBoundingClientRect(),r=t?Math.max(0,t.getBoundingClientRect().top):0;if(this.floating){if(i.top>=r||i.bottom<this.menu.offsetHeight+10){this.floating=false;this.menu.style.position=this.menu.style.left=this.menu.style.top=this.menu.style.width="";this.menu.style.display="";this.spacer.parentNode.removeChild(this.spacer);this.spacer=null}else{let n=(e.offsetWidth-e.clientWidth)/2;this.menu.style.left=i.left+n+"px";this.menu.style.display=i.top>(this.editorView.dom.ownerDocument.defaultView||window).innerHeight?"none":"";if(t)this.menu.style.top=r+"px"}}else{if(i.top<r&&i.bottom>=this.menu.offsetHeight+10){this.floating=true;let i=this.menu.getBoundingClientRect();this.menu.style.left=i.left+"px";this.menu.style.width=i.width+"px";if(t)this.menu.style.top=r+"px";this.menu.style.position="fixed";this.spacer=Oo("div",{class:tu+"-spacer",style:`height: ${i.height}px`});e.insertBefore(this.spacer,this.menu)}}}destroy(){if(this.wrapper.parentNode)this.wrapper.parentNode.replaceChild(this.editorView.dom,this.wrapper)}}function nu(t){if(t.anchorNode==t.focusNode)return t.anchorOffset>t.focusOffset;return t.anchorNode.compareDocumentPosition(t.focusNode)==Node.DOCUMENT_POSITION_FOLLOWING}function su(t){for(let e=t.parentNode;e;e=e.parentNode)if(e.scrollHeight>e.clientHeight)return e}function lu(t){let e=[t.ownerDocument.defaultView||window];for(let i=t.parentNode;i;i=i.parentNode)e.push(i);return e}class fu{constructor(t,e,i={}){this.match=t;this.match=t;this.handler=typeof e=="string"?ou(e):e;this.undoable=i.undoable!==false;this.inCode=i.inCode||false}}function ou(t){return function(e,i,r,n){let s=t;if(i[1]){let t=i[0].lastIndexOf(i[1]);s+=i[0].slice(t+i[1].length);r+=t;let e=r-n;if(e>0){s=i[0].slice(t-e,t)+s;r=n}}return e.tr.insertText(s,r,n)}}const uu=500;function hu({rules:t}){let e=new ei({state:{init(){return null},apply(t,e){let i=t.getMeta(this);if(i)return i;return t.selectionSet||t.docChanged?null:e}},props:{handleTextInput(i,r,n,s){return au(i,r,n,s,t,e)},handleDOMEvents:{compositionend:i=>{setTimeout((()=>{let{$cursor:r}=i.state.selection;if(r)au(i,r.pos,r.pos,"",t,e)}))}}},isInputRules:true});return e}function au(t,e,i,r,n,s){if(t.composing)return false;let l=t.state,f=l.doc.resolve(e);let o=f.parent.textBetween(Math.max(0,f.parentOffset-uu),f.parentOffset,null,"")+r;for(let u=0;u<n.length;u++){let h=n[u];if(f.parent.type.spec.code){if(!h.inCode)continue}else if(h.inCode==="only"){continue}let a=h.match.exec(o);let c=a&&h.handler(l,a,e-(a[0].length-r.length),i);if(!c)continue;if(h.undoable)c.setMeta(s,{transform:c,from:e,to:i,text:r});t.dispatch(c);return true}return false}const cu=(t,e)=>{let i=t.plugins;for(let r=0;r<i.length;r++){let n=i[r],s;if(n.spec.isInputRules&&(s=n.getState(t))){if(e){let i=t.tr,r=s.transform;for(let t=r.steps.length-1;t>=0;t--)i.step(r.steps[t].invert(r.docs[t]));if(s.text){let e=i.doc.resolve(s.from).marks();i.replaceWith(s.from,s.to,t.schema.text(s.text,e))}else{i.delete(s.from,s.to)}e(i)}return true}}return false};const du=new fu(/--$/,"—");const pu=new fu(/\.\.\.$/,"…");const mu=new fu(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“");const wu=new fu(/"$/,"”");const gu=new fu(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘");const bu=new fu(/'$/,"’");const vu=[mu,wu,gu,bu];function yu(t,e,i=null,r){return new fu(t,((t,n,s,l)=>{let f=i instanceof Function?i(n):i;let o=t.tr.delete(s,l);let u=o.doc.resolve(s),h=u.blockRange(),a=h&&Yt(h,e,f);if(!a)return null;o.wrap(h,a);let c=o.doc.resolve(s-1).nodeBefore;if(c&&c.type==e&&fe(o.doc,s-1)&&(!r||r(n,c)))o.join(s-1);return o}))}function ku(t,e,i=null){return new fu(t,((t,r,n,s)=>{let l=t.doc.resolve(n);let f=i instanceof Function?i(r):i;if(!l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),e))return null;return t.tr.delete(n,s).setBlockType(n,n,e,f)}))}const Mu="ProseMirror-prompt";function xu(t){let e=document.body.appendChild(document.createElement("div"));e.className=Mu;let i=t=>{if(!e.contains(t.target))r()};setTimeout((()=>window.addEventListener("mousedown",i)),50);let r=()=>{window.removeEventListener("mousedown",i);if(e.parentNode)e.parentNode.removeChild(e)};let n=[];for(let e in t.fields)n.push(t.fields[e].render());let s=document.createElement("button");s.type="submit";s.className=Mu+"-submit";s.textContent="OK";let l=document.createElement("button");l.type="button";l.className=Mu+"-cancel";l.textContent="Cancel";l.addEventListener("click",r);let f=e.appendChild(document.createElement("form"));if(t.title)f.appendChild(document.createElement("h5")).textContent=t.title;n.forEach((t=>{f.appendChild(document.createElement("div")).appendChild(t)}));let o=f.appendChild(document.createElement("div"));o.className=Mu+"-buttons";o.appendChild(s);o.appendChild(document.createTextNode(" "));o.appendChild(l);let u=e.getBoundingClientRect();e.style.top=(window.innerHeight-u.height)/2+"px";e.style.left=(window.innerWidth-u.width)/2+"px";let h=()=>{let e=Su(t.fields,n);if(e){r();t.callback(e)}};f.addEventListener("submit",(t=>{t.preventDefault();h()}));f.addEventListener("keydown",(t=>{if(t.keyCode==27){t.preventDefault();r()}else if(t.keyCode==13&&!(t.ctrlKey||t.metaKey||t.shiftKey)){t.preventDefault();h()}else if(t.keyCode==9){window.setTimeout((()=>{if(!e.contains(document.activeElement))r()}),500)}}));let a=f.elements[0];if(a)a.focus()}function Su(t,e){let i=Object.create(null),r=0;for(let n in t){let s=t[n],l=e[r++];let f=s.read(l),o=s.validate(f);if(o){Ou(l,o);return null}i[n]=s.clean(f)}return i}function Ou(t,e){let i=t.parentNode;let r=i.appendChild(document.createElement("div"));r.style.left=t.offsetLeft+t.offsetWidth+2+"px";r.style.top=t.offsetTop-5+"px";r.className="ProseMirror-invalid";r.textContent=e;setTimeout((()=>i.removeChild(r)),1500)}class Eu{constructor(t){this.options=t}read(t){return t.value}validateType(t){return null}validate(t){if(!t&&this.options.required)return"Required field";return this.validateType(t)||(this.options.validate?this.options.validate(t):null)}clean(t){return this.options.clean?this.options.clean(t):t}}class Du extends Eu{render(){let t=document.createElement("input");t.type="text";t.placeholder=this.options.label;t.value=this.options.value||"";t.autocomplete="off";return t}}function Nu(t,e){let i=t.selection.$from;for(let t=i.depth;t>=0;t--){let r=i.index(t);if(i.node(t).canReplaceWith(r,r,e))return true}return false}function $u(t){return new Ao({title:"Insert image",label:"Image",enable(e){return Nu(e,t)},run(e,i,r){let{from:n,to:s}=e.selection,l=null;if(e.selection instanceof Be&&e.selection.node.type==t)l=e.selection.node.attrs;xu({title:"Insert image",fields:{src:new Du({label:"Location",required:true,value:l&&l.src}),title:new Du({label:"Title",value:l&&l.title}),alt:new Du({label:"Description",value:l?l.alt:e.doc.textBetween(n,s," ")})},callback(e){r.dispatch(r.state.tr.replaceSelectionWith(t.createAndFill(e)));r.focus()}})}})}function Ru(t,e){let i={label:e.title,run:t};for(let t in e)i[t]=e[t];if(!e.enable&&!e.select)i[e.enable?"enable":"select"]=e=>t(e);return new Ao(i)}function qu(t,e){let{from:i,$from:r,to:n,empty:s}=t.selection;if(s)return!!e.isInSet(t.storedMarks||r.marks());else return t.doc.rangeHasMark(i,n,e)}function Cu(t,e){let i={active(e){return qu(e,t)}};for(let t in e)i[t]=e[t];return Ru(no(t),i)}function Tu(t){return new Ao({title:"Add or remove link",icon:Uo.link,active(e){return qu(e,t)},enable(t){return!t.selection.empty},run(e,i,r){if(qu(e,t)){no(t)(e,i);return true}xu({title:"Create a link",fields:{href:new Du({label:"Link target",required:true}),title:new Du({label:"Title"})},callback(e){no(t,e)(r.state,r.dispatch);r.focus()}})}})}function Au(t,e){return Ru(Jl(t,e.attrs),e)}function Iu(t){let e={};let i;if(i=t.marks.strong)e.toggleStrong=Cu(i,{title:"Toggle strong style",icon:Uo.strong});if(i=t.marks.em)e.toggleEm=Cu(i,{title:"Toggle emphasis",icon:Uo.em});if(i=t.marks.code)e.toggleCode=Cu(i,{title:"Toggle code font",icon:Uo.code});if(i=t.marks.link)e.toggleLink=Tu(i);let r;if(r=t.nodes.image)e.insertImage=$u(r);if(r=t.nodes.bullet_list)e.wrapBulletList=Au(r,{title:"Wrap in bullet list",icon:Uo.bulletList});if(r=t.nodes.ordered_list)e.wrapOrderedList=Au(r,{title:"Wrap in ordered list",icon:Uo.orderedList});if(r=t.nodes.blockquote)e.wrapBlockQuote=Yo(r,{title:"Wrap in block quote",icon:Uo.blockquote});if(r=t.nodes.paragraph)e.makeParagraph=Qo(r,{title:"Change to paragraph",label:"Plain"});if(r=t.nodes.code_block)e.makeCodeBlock=Qo(r,{title:"Change to code block",label:"Code"});if(r=t.nodes.heading)for(let t=1;t<=10;t++)e["makeHead"+t]=Qo(r,{title:"Change to heading "+t,label:"Level "+t,attrs:{level:t}});if(r=t.nodes.horizontal_rule){let t=r;e.insertHorizontalRule=new Ao({title:"Insert horizontal rule",label:"Horizontal rule",enable(e){return Nu(e,t)},run(e,i){i(e.tr.replaceSelectionWith(t.create()))}})}let n=t=>t.filter((t=>t));e.insertMenu=new Bo(n([e.insertImage,e.insertHorizontalRule]),{label:"Insert"});e.typeMenu=new Bo(n([e.makeParagraph,e.makeCodeBlock,e.makeHead1&&new Lo(n([e.makeHead1,e.makeHead2,e.makeHead3,e.makeHead4,e.makeHead5,e.makeHead6]),{label:"Heading"})]),{label:"Type..."});e.inlineMenu=[n([e.toggleStrong,e.toggleEm,e.toggleCode,e.toggleLink])];e.blockMenu=[n([e.wrapBulletList,e.wrapOrderedList,e.wrapBlockQuote,Ko,Ho,Go])];e.fullMenu=e.inlineMenu.concat([[e.insertMenu,e.typeMenu]],[[Vo,Xo]],e.blockMenu);return e}const Pu=typeof navigator!="undefined"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):false;function zu(t,e){let i={},r;function n(t,r){if(e){let i=e[t];if(i===false)return;if(i)t=i}i[t]=r}n("Mod-z",Ef);n("Shift-Mod-z",Df);n("Backspace",cu);if(!Pu)n("Mod-y",Df);n("Alt-ArrowUp",Jf);n("Alt-ArrowDown",Bf);n("Mod-BracketLeft",jf);n("Escape",Gf);if(r=t.marks.strong){n("Mod-b",no(r));n("Mod-B",no(r))}if(r=t.marks.em){n("Mod-i",no(r));n("Mod-I",no(r))}if(r=t.marks.code)n("Mod-`",no(r));if(r=t.nodes.bullet_list)n("Shift-Ctrl-8",Jl(r));if(r=t.nodes.ordered_list)n("Shift-Ctrl-9",Jl(r));if(r=t.nodes.blockquote)n("Ctrl->",eo(r));if(r=t.nodes.hard_break){let t=r,e=so(Wf,((e,i)=>{if(i)i(e.tr.replaceSelectionWith(t.create()).scrollIntoView());return true}));n("Mod-Enter",e);n("Shift-Enter",e);if(Pu)n("Ctrl-Enter",e)}if(r=t.nodes.list_item){n("Enter",jl(r));n("Mod-[",Fl(r));n("Mod-]",_l(r))}if(r=t.nodes.paragraph)n("Shift-Ctrl-0",io(r));if(r=t.nodes.code_block)n("Shift-Ctrl-\\",io(r));if(r=t.nodes.heading)for(let t=1;t<=6;t++)n("Shift-Ctrl-"+t,io(r,{level:t}));if(r=t.nodes.horizontal_rule){let t=r;n("Mod-_",((e,i)=>{if(i)i(e.tr.replaceSelectionWith(t.create()).scrollIntoView());return true}))}return i}function Ju(t){return yu(/^\s*>\s$/,t)}function Bu(t){return yu(/^(\d+)\.\s$/,t,(t=>({order:+t[1]})),((t,e)=>e.childCount+e.attrs.order==+t[1]))}function ju(t){return yu(/^\s*([-+*])\s$/,t)}function Fu(t){return ku(/^```$/,t)}function Lu(t,e){return ku(new RegExp("^(#{1,"+e+"})\\s$"),t,(t=>({level:t[1].length})))}function Wu(t){let e=vu.concat(pu,du),i;if(i=t.nodes.blockquote)e.push(Ju(i));if(i=t.nodes.ordered_list)e.push(Bu(i));if(i=t.nodes.bullet_list)e.push(ju(i));if(i=t.nodes.code_block)e.push(Fu(i));if(i=t.nodes.heading)e.push(Lu(i,6));return hu({rules:e})}function _u(t){let e=[Wu(t.schema),rf(zu(t.schema,t.mapKeys)),rf(ao),co(),vo()];if(t.menuBar!==false)e.push(iu({floating:t.floatingMenu!==false,content:t.menuContent||Iu(t.schema).fullMenu}));if(t.history!==false)e.push(Of());return e.concat(new ei({props:{attributes:{class:"ProseMirror-example-setup-style"}}}))}class Uu{constructor(t){this.markNames={bold:"strong",italic:"em",underline:"underline",blockquote:"blockquote",headerlevel1:"headerlevel1",headerlevel2:"headerlevel2",headerlevel3:"headerlevel3",addorremovelink:"link",numberedlist:"ordered_list",list:"bullet_list"};this.schema=t}createCommand(t){if(this.markNames[t]){t=this.markNames[t]}switch(t){case"strong":case"em":case"underline":return this.createToggleMarkCommand(t);case"paragraph":return this.createSetNodeTypeCommand(t);case"headerlevel1":case"headerlevel2":case"headerlevel3":return this.createSetNodeTypeCommand("heading",parseInt(t[t.length-1],10));case"blockquote":return this.createWrapInCommand(t);case"ordered_list":case"bullet_list":return this.createListCommand(t);default:throw new Error(`The Mark "${t}" is not supported`)}}createToggleMarkCommand(t){const e=this.schema.marks[t];if(!e){throw new Error(`Mark "${t}" not found in schema`)}return no(e)}createSetNodeTypeCommand(t,e){const i=this.schema.nodes[t];if(!i){throw new Error(`Node type "${t}" not found in schema`)}if(t==="heading"&&e){return io(i,{level:e})}else{return io(i)}}createWrapInCommand(t){const e=this.schema.nodes[t];if(!e){throw new Error(`Node type "${t}" not found in schema`)}return eo(e)}createListCommand(t){const e=this.schema.nodes[t];if(!e){throw new Error(`List type "${t}" not found in schema`)}return Jl(e)}}const Ku=()=>{const t=/Macintosh|MacIntel|MacPPC|Mac68K/;if(navigator.userAgent.match(t)){return{mod:"⌘",option:"⌥",shift:"⇧"}}return{mod:"Ctrl",option:"Alt",shift:"Shift"}};const{mod:Hu,shift:Gu}=Ku();const Vu=[{value:"strong",text:"Bold",commandText:`${Hu} B`,icon:"-lime-text-bold",iconOnly:true},{value:"em",text:"Italic",commandText:`${Hu} I`,icon:"-lime-text-italic",iconOnly:true},{separator:true},{value:"headerlevel1",text:"Header Level 1",commandText:`${Hu} ${Gu} 1`,icon:"-lime-text-h-heading-1",iconOnly:true},{value:"headerlevel2",text:"Header Level 2",commandText:`${Hu} ${Gu} 2`,icon:"-lime-text-h-heading-2",iconOnly:true},{value:"headerlevel3",text:"Header Level 3",commandText:`${Hu} ${Gu} 3`,icon:"-lime-text-h-heading-3",iconOnly:true},{separator:true},{value:"bullet_list",text:"Bullet list",icon:"-lime-text-bulleted-list",iconOnly:true},{value:"ordered_list",text:"Numbered list",icon:"-lime-text-ordered-list",iconOnly:true},{value:"blockquote",text:"Blockquote",icon:"-lime-text-blockquote",iconOnly:true}];const Xu='@charset "UTF-8";:host{--mdc-theme-primary:var(\n --lime-primary-color,\n rgb(var(--color-teal-default))\n );--mdc-theme-secondary:var(\n --lime-secondary-color,\n rgb(var(--contrast-1100))\n );--mdc-theme-on-primary:var(\n --lime-on-primary-color,\n rgb(var(--contrast-100))\n );--mdc-theme-on-secondary:var(\n --lime-on-secondary-color,\n rgb(var(--contrast-100))\n );--mdc-theme-text-disabled-on-background:var(\n --lime-text-disabled-on-background-color,\n rgba(var(--contrast-1700), 0.38)\n );--mdc-theme-text-primary-on-background:var(\n --lime-text-primary-on-background-color,\n rgba(var(--contrast-1700), 0.87)\n );--mdc-theme-text-secondary-on-background:var(\n --lime-text-secondary-on-background-color,\n rgba(var(--contrast-1700), 0.54)\n );--mdc-theme-error:var(\n --lime-error-background-color,\n rgb(var(--color-red-dark))\n );--lime-error-text-color:rgb(var(--color-red-darker));--mdc-theme-surface:var(\n --lime-surface-background-color,\n rgb(var(--contrast-100))\n );--mdc-theme-on-surface:var(\n --lime-on-surface-color,\n rgb(var(--contrast-1500))\n )}:host(limel-prosemirror-adapter){display:block}*{box-sizing:border-box}.ProseMirror-menubar-wrapper{display:grid;grid-template-rows:auto 1fr}.ProseMirror-textblock-dropdown{min-width:3em}.ProseMirror-tooltip .ProseMirror-menu{width:-webkit-fit-content;width:fit-content;white-space:pre}limel-action-bar{--action-bar-border-radius:0.25rem;position:sticky;z-index:1;top:1px;background-color:rgba(var(--contrast-200), 0.5);backdrop-filter:blur(0.5rem);-webkit-backdrop-filter:blur(0.5rem);margin:0 1px;width:calc(100% - 2px)}.ProseMirror{position:relative;word-wrap:break-word;white-space:pre-wrap;white-space:break-spaces;-webkit-font-variant-ligatures:none;font-variant-ligatures:none;font-feature-settings:"liga" 0;padding:var(--limel-text-editor-padding)}.ProseMirror [draggable][contenteditable=false]{user-select:text}.ProseMirror:focus-visible{outline:none}.ProseMirror-hideselection{caret-color:transparent}.ProseMirror-hideselection *::selection{background:transparent}.ProseMirror-hideselection *::-moz-selection{background:transparent}.ProseMirror-selectednode{outline:0.125rem solid rgb(var(--color-sky-light))}li.ProseMirror-selectednode{outline:none}li.ProseMirror-selectednode:after{content:"";position:absolute;left:-2rem;right:-0.125rem;top:-0.125rem;bottom:-0.125rem;border:0.125rem solid rgb(var(--color-sky-light));pointer-events:none}img.ProseMirror-separator{display:inline !important;border:none !important;margin:0 !important}blockquote{position:relative;font-weight:100;font-size:0.875rem;max-width:100%;line-height:1.4;margin:0;padding:0.5rem 1.25rem;border-radius:0.05rem 0.75rem;background-color:rgb(var(--contrast-300))}blockquote:before,blockquote:after{position:absolute;font-size:2.75rem;opacity:0.4}blockquote:before{content:"“";left:0;top:-0.75rem}blockquote:after{content:"”";right:0;bottom:-2rem}:host(limel-markdown.truncate-paragraphs) p{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}p,li{font-size:0.875rem;word-break:break-word;hyphens:auto;-webkit-hyphens:auto}a{word-break:break-all}p{margin-top:0;margin-bottom:0.5rem}p:only-child{margin-bottom:0}a{transition:color 0.2s ease;color:var(--markdown-hyperlink-color, rgb(var(--color-blue-dark)));text-decoration:none}a:hover{color:var(--markdown-hyperlink-color--hovered, rgb(var(--color-blue-default)))}hr{margin:1.75rem 0 2rem 0;border-width:0;border-top:1px solid rgb(var(--contrast-500))}dl{display:grid;grid-template-columns:1fr 2fr;grid-template-rows:1fr;margin-bottom:2rem;border:1px solid rgb(var(--contrast-400));border-radius:0.375rem;background-color:rgb(var(--contrast-200))}dl dt,dl dd{padding:0.375rem 0.5rem;font-size:0.875rem;margin:0}dl dt:nth-of-type(even),dl dd:nth-of-type(even){background-color:rgb(var(--contrast-300))}dl dt:first-child{border-top-left-radius:0.375rem}dl dt:last-child{border-bottom-left-radius:0.375rem}dl dd:first-child{border-top-right-radius:0.375rem}dl dd:last-child{border-bottom-right-radius:0.375rem}h1{font-size:1.5rem}h2{font-size:1.25rem}h3{font-size:1.125rem}h4{font-size:1rem}h5{font-size:0.875rem}h6{font-size:0.75rem}h1,h2{margin-top:0.5rem;margin-bottom:0.5rem;letter-spacing:-0.03125rem;font-weight:500}h3,h4{margin-top:0.75rem;margin-bottom:0.25rem;font-weight:600}h5,h6{margin-top:0.5rem;margin-bottom:0.125rem;font-weight:600}h1,h2,h3,h4,h5,h6{word-break:break-word;hyphens:auto;-webkit-hyphens:auto}:not([contenteditable=true]) h1,:not([contenteditable=true]) h2,:not([contenteditable=true]) h3,:not([contenteditable=true]) h4,:not([contenteditable=true]) h5,:not([contenteditable=true]) h6{text-wrap:balance}[contenteditable=true] h1,[contenteditable=true] h2,[contenteditable=true] h3,[contenteditable=true] h4,[contenteditable=true] h5,[contenteditable=true] h6{text-wrap:initial}ul{list-style:none}ul li{position:relative;margin-left:0.75rem}ul li:before{content:"";position:absolute;left:-0.5rem;top:0.5rem;width:0.25rem;height:0.25rem;border-radius:50%;background-color:rgb(var(--contrast-700));display:block}ol{margin-top:0.25rem;padding-left:1rem}ul{margin-top:0.25rem;padding-left:0}ul ul,ul ol,ol ol,ol ul{margin-left:0}li{margin-bottom:0.25rem}code{font-family:ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas, "DejaVu Sans Mono", monospace;font-size:0.8125rem;letter-spacing:-0.0125rem;color:rgb(var(--contrast-1300));-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none;display:inline-block;border-radius:0.25rem;padding:0.03125rem 0.25rem;background-color:rgb(var(--contrast-600))}pre>code{display:block;margin:0.5rem 0;padding:0.5rem 0.75rem;overflow:auto;white-space:pre-wrap}:host(limel-markdown:not(.no-table-styles)) table{table-layout:auto;min-width:100%;border-collapse:collapse;border-spacing:0;background:transparent;margin:0.75rem 0;border:1px solid rgb(var(--contrast-400))}:host(limel-markdown:not(.no-table-styles)) th,:host(limel-markdown:not(.no-table-styles)) td{text-align:left;vertical-align:top;transition:background-color 0.2s ease;font-size:0.875rem}:host(limel-markdown:not(.no-table-styles)) td{padding:0.5rem 0.375rem 0.75rem 0.375rem}:host(limel-markdown:not(.no-table-styles)) tr th{background-color:rgb(var(--contrast-400));padding:0.25rem 0.375rem;font-weight:normal}:host(limel-markdown:not(.no-table-styles)) tr th:only-child{text-align:center}:host(limel-markdown:not(.no-table-styles)) tbody tr:nth-child(odd) td{background-color:rgb(var(--contrast-200))}:host(limel-markdown:not(.no-table-styles)) tbody tr:hover td{background-color:rgb(var(--contrast-300))}';const Yu=class{constructor(i){t(this,i);this.change=e(this,"change",7);this.initializeEditor=()=>{this.actionBarItems=Vu;const t=new et({nodes:zl($l.spec.nodes,"paragraph block*","block"),marks:$l.spec.marks});this.view=new al(this.host.shadowRoot.querySelector("#editor"),{state:Ze.create({doc:rt.fromSchema(t).parse(this.host.shadowRoot.querySelector("#editor")),plugins:_u({schema:t,menuBar:false})}),dispatchTransaction:t=>{const e=this.view.state.apply(t);this.view.updateState(e);this.change.emit(this.getHTML())}});this.menuCommandFactory=new Uu(t);if(this.value){this.view.dom.innerHTML=this.value}};this.getHTML=()=>{if(this.view.dom.textContent===""){return""}else{return this.view.dom.innerHTML}};this.handleActionBarItem=t=>{t.preventDefault();const{text:e}=t.detail;const i=e.replace(/\s/g,"").toLowerCase();try{const t=this.menuCommandFactory.createCommand(i);this.executeCommand(t)}catch(t){throw new Error(`Error executing command: ${t}`)}};this.value=undefined;this.view=undefined;this.actionBarItems=[]}componentDidLoad(){setTimeout(this.initializeEditor,0)}render(){return[i("limel-action-bar",{accessibleLabel:"Toolbar",actions:this.actionBarItems,onItemSelected:this.handleActionBarItem}),i("div",{id:"editor"})]}executeCommand(t){const{state:e}=this.view;const i=e.selection;let r=e.tr;if(!i.empty){r.setSelection(i)}t(e,(t=>{r=t}));this.view.dispatch(r);this.view.focus()}get host(){return r(this)}};Yu.style=Xu;export{Yu as limel_prosemirror_adapter};
|
|
2
|
-
//# sourceMappingURL=p-91f40d46.entry.js.map
|