@panphora/clayjs 1.12.0 → 1.12.2

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.
@@ -0,0 +1,12 @@
1
+ /* ProseMirror (MIT), bundled for clayjs: model 1.25.12, state 1.4.4, view 1.42.6, transform 1.12.2, history 1.5.1, keymap 1.2.3, commands 1.7.2, inputrules 1.5.1, dropcursor 1.8.4, gapcursor 1.4.1.
2
+ https://prosemirror.net — regenerate with node scripts/build-prosemirror-vendor.mjs */
3
+ var bo=Object.defineProperty;var ie=(r,e)=>{for(var t in e)bo(r,t,{get:e[t],enumerable:!0})};var Qr={};ie(Qr,{ContentMatch:()=>be,DOMParser:()=>je,DOMSerializer:()=>Se,Fragment:()=>y,Mark:()=>w,MarkType:()=>Ue,Node:()=>Z,NodeRange:()=>Lt,NodeType:()=>ut,ReplaceError:()=>he,ResolvedPos:()=>ht,Schema:()=>Sn,Slice:()=>x});function v(r){this.content=r}v.prototype={constructor:v,find:function(r){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===r)return e;return-1},get:function(r){var e=this.find(r);return e==-1?void 0:this.content[e+1]},update:function(r,e,t){var n=t&&t!=r?this.remove(t):this,i=n.find(r),s=n.content.slice();return i==-1?s.push(t||r,e):(s[i+1]=e,t&&(s[i]=t)),new v(s)},remove:function(r){var e=this.find(r);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new v(t)},addToStart:function(r,e){return new v([r,e].concat(this.remove(r).content))},addToEnd:function(r,e){var t=this.remove(r).content.slice();return t.push(r,e),new v(t)},addBefore:function(r,e,t){var n=this.remove(e),i=n.content.slice(),s=n.find(r);return i.splice(s==-1?i.length:s,0,e,t),new v(i)},forEach:function(r){for(var e=0;e<this.content.length;e+=2)r(this.content[e],this.content[e+1])},prepend:function(r){return r=v.from(r),r.size?new v(r.content.concat(this.subtract(r).content)):this},append:function(r){return r=v.from(r),r.size?new v(this.subtract(r).content.concat(r.content)):this},subtract:function(r){var e=this;r=v.from(r);for(var t=0;t<r.content.length;t+=2)e=e.remove(r.content[t]);return e},toObject:function(){var r={};return this.forEach(function(e,t){r[e]=t}),r},get size(){return this.content.length>>1}};v.from=function(r){if(r instanceof v)return r;var e=[];if(r)for(var t in r)e.push(t,r[t]);return new v(e)};var dn=v;function Br(r,e,t){for(let n=0;;n++){if(n==r.childCount||n==e.childCount)return r.childCount==e.childCount?null:t;let i=r.child(n),s=e.child(n);if(i==s){t+=i.nodeSize;continue}if(!i.sameMarkup(s))return t;if(i.isText&&i.text!=s.text){let o=i.text,l=s.text,a=0;for(;o[a]==l[a];a++)t++;return a&&a<o.length&&a<l.length&&vr(o.charCodeAt(a-1))&&Fr(o.charCodeAt(a))&&t--,t}if(i.content.size||s.content.size){let o=Br(i.content,s.content,t+1);if(o!=null)return o}t+=i.nodeSize}}function zr(r,e,t,n){for(let i=r.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:t,b:n};let o=r.child(--i),l=e.child(--s),a=o.nodeSize;if(o==l){t-=a,n-=a;continue}if(!o.sameMarkup(l))return{a:t,b:n};if(o.isText&&o.text!=l.text){let f=o.text,c=l.text,h=f.length,u=c.length;for(;h>0&&u>0&&f[h-1]==c[u-1];)h--,u--,t--,n--;return h&&u&&h<f.length&&vr(f.charCodeAt(h-1))&&Fr(f.charCodeAt(h))&&(t++,n++),{a:t,b:n}}if(o.content.size||l.content.size){let f=zr(o.content,l.content,t-1,n-1);if(f)return f}t-=a,n-=a}}function Fr(r){return r>=56320&&r<57344}function vr(r){return r>=55296&&r<56320}var y=class r{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let n=0;n<e.length;n++)this.size+=e[n].nodeSize}nodesBetween(e,t,n,i=0,s){for(let o=0,l=0;l<t;o++){let a=this.content[o],f=l+a.nodeSize;if(f>e&&n(a,i+l,s||null,o)!==!1&&a.content.size){let c=l+1;a.nodesBetween(Math.max(0,e-c),Math.min(a.content.size,t-c),n,i+c)}l=f}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,i){let s="",o=!0;return this.nodesBetween(e,t,(l,a)=>{let f=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&f||l.isTextblock)&&n&&(o?o=!1:s+=n),s+=f},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,n=e.firstChild,i=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(n)&&(i[i.length-1]=t.withText(t.text+n.text),s=1);s<e.content.length;s++)i.push(e.content[s]);return new r(i,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let n=[],i=0;if(t>e)for(let s=0,o=0;o<t;s++){let l=this.content[s],a=o+l.nodeSize;a>e&&((o<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,t-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,t-o-1))),n.push(l),i+=l.nodeSize),o=a}return new r(n,i)}cutByIndex(e,t){return e==t?r.empty:e==0&&t==this.content.length?this:new r(this.content.slice(e,t))}replaceChild(e,t){let n=this.content[e];if(n==t)return this;let i=this.content.slice(),s=this.size+t.nodeSize-n.nodeSize;return i[e]=t,new r(i,s)}addToStart(e){return new r([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new r(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let i=this.content[t];e(i,n,t),n+=i.nodeSize}}findDiffStart(e,t=0){return Br(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return zr(this,e,t,n)}findIndex(e){if(e==0)return Bt(0,e);if(e==this.size)return Bt(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let i=this.child(t),s=n+i.nodeSize;if(s>=e)return s==e?Bt(t+1,s):Bt(t,n);n=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return r.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return r.fromArray(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return r.empty;let t,n=0;for(let i=0;i<e.length;i++){let s=e[i];n+=s.nodeSize,i&&s.isText&&e[i-1].sameMarkup(s)?(t||(t=e.slice(0,i)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new r(t||e,n)}static from(e){if(!e)return r.empty;if(e instanceof r)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new r([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}};y.empty=new y([],0);var pn={index:0,offset:0};function Bt(r,e){return pn.index=r,pn.offset=e,pn}function vt(r,e){if(r===e)return!0;if(!(r&&typeof r=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(r);if(Array.isArray(e)!=t)return!1;if(t){if(r.length!=e.length)return!1;for(let n=0;n<r.length;n++)if(!vt(r[n],e[n]))return!1}else{for(let n in r)if(!(n in e)||!vt(r[n],e[n]))return!1;for(let n in e)if(!(n in r))return!1}return!0}var w=class r{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let i=0;i<e.length;i++){let s=e[i];if(this.eq(s))return e;if(this.type.excludes(s.type))t||(t=e.slice(0,i));else{if(s.type.excludes(this.type))return e;!n&&s.type.rank>this.type.rank&&(t||(t=e.slice(0,i)),t.push(this),n=!0),t&&t.push(s)}}return t||(t=e.slice()),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&vt(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let n=e.marks[t.type];if(!n)throw new RangeError(`There is no mark type ${t.type} in this schema`);return n.create(t.attrs)}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return r.none;if(e instanceof r)return[e];let t=e.slice();return t.sort((n,i)=>n.type.rank-i.type.rank),t}};w.none=[];var he=class extends Error{},x=class r{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let n=Lr(this.content,e+this.openStart,t,this.openStart+1,this.openEnd+1);return n&&new r(n,this.openStart,this.openEnd)}removeBetween(e,t){return new r(Vr(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return r.empty;let n=t.openStart||0,i=t.openEnd||0;if(typeof n!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new r(y.fromJSON(e,t.content),n,i)}static maxOpen(e,t=!0){let n=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)n++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)i++;return new r(e,n,i)}};x.empty=new x(y.empty,0,0);function Vr(r,e,t){let{index:n,offset:i}=r.findIndex(e),s=r.maybeChild(n),{index:o,offset:l}=r.findIndex(t);if(i==e||s.isText){if(l!=t&&!r.child(o).isText)throw new RangeError("Removing non-flat range");return r.cut(0,e).append(r.cut(t))}if(n!=o)throw new RangeError("Removing non-flat range");return r.replaceChild(n,s.copy(Vr(s.content,e-i-1,t-i-1)))}function Lr(r,e,t,n,i,s){let{index:o,offset:l}=r.findIndex(e),a=r.maybeChild(o);if(l==e||a.isText)return s&&n<=0&&i<=0&&!s.canReplace(o,o,t)?null:r.cut(0,e).append(t).append(r.cut(e));let f=Lr(a.content,e-l-1,t,o==0?n-1:0,o==r.childCount-1?i-1:0,a);return f&&r.replaceChild(o,a.copy(f))}function So(r,e,t){if(t.openStart>r.depth)throw new he("Inserted content deeper than insertion position");if(r.depth-t.openStart!=e.depth-t.openEnd)throw new he("Inconsistent open depths");return Wr(r,e,t,0)}function Wr(r,e,t,n){let i=r.index(n),s=r.node(n);if(i==e.index(n)&&n<r.depth-t.openStart){let o=Wr(r,e,t,n+1);return s.copy(s.content.replaceChild(i,o))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&r.depth==n&&e.depth==n){let o=r.parent,l=o.content;return Ee(o,l.cut(0,r.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=ko(t,r);return Ee(s,qr(r,o,l,e,n))}else return Ee(s,Vt(r,e,n))}function Jr(r,e){if(!e.type.compatibleContent(r.type))throw new he("Cannot join "+e.type.name+" onto "+r.type.name)}function mn(r,e,t){let n=r.node(t);return Jr(n,e.node(t)),n}function Te(r,e){let t=e.length-1;t>=0&&r.isText&&r.sameMarkup(e[t])?e[t]=r.withText(e[t].text+r.text):e.push(r)}function ft(r,e,t,n){let i=(e||r).node(t),s=0,o=e?e.index(t):i.childCount;r&&(s=r.index(t),r.depth>t?s++:r.textOffset&&(Te(r.nodeAfter,n),s++));for(let l=s;l<o;l++)Te(i.child(l),n);e&&e.depth==t&&e.textOffset&&Te(e.nodeBefore,n)}function Ee(r,e){if(!r.type.validContent(e))throw new he("Invalid content for node "+r.type.name);return r.copy(e)}function qr(r,e,t,n,i){let s=r.depth>i&&mn(r,e,i+1),o=n.depth>i&&mn(t,n,i+1),l=[];return ft(null,r,i,l),s&&o&&e.index(i)==t.index(i)?(Jr(s,o),Te(Ee(s,qr(r,e,t,n,i+1)),l)):(s&&Te(Ee(s,Vt(r,e,i+1)),l),ft(e,t,i,l),o&&Te(Ee(o,Vt(t,n,i+1)),l)),ft(n,null,i,l),new y(l)}function Vt(r,e,t){let n=[];if(ft(null,r,t,n),r.depth>t){let i=mn(r,e,t+1);Te(Ee(i,Vt(r,e,t+1)),n)}return ft(e,null,t,n),new y(n)}function ko(r,e){let t=e.depth-r.openStart,i=e.node(t).copy(r.content);for(let s=t-1;s>=0;s--)i=e.node(s).copy(y.from(i));return{start:i.resolveNoCache(r.openStart+t),end:i.resolveNoCache(i.content.size-r.openEnd-t)}}var ht=class r{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],i=e.child(t);return n?e.child(t).cut(n):i}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],i=t==0?0:this.path[t*3-1]+1;for(let s=0;s<e;s++)i+=n.child(s).nodeSize;return i}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return w.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),i=e.maybeChild(t);if(!n){let l=n;n=i,i=l}let s=n.marks;for(var o=0;o<s.length;o++)s[o].type.spec.inclusive===!1&&(!i||!s[o].isInSet(i.marks))&&(s=s[o--].removeFromSet(s));return s}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,i=e.parent.maybeChild(e.index());for(var s=0;s<n.length;s++)n[s].type.spec.inclusive===!1&&(!i||!n[s].isInSet(i.marks))&&(n=n[s--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new Lt(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let n=[],i=0,s=t;for(let o=e;;){let{index:l,offset:a}=o.content.findIndex(s),f=s-a;if(n.push(o,l,i+a),!f||(o=o.child(l),o.isText))break;s=f-1,i+=a+1}return new r(t,n,s)}static resolveCached(e,t){let n=Or.get(e);if(n)for(let s=0;s<n.elts.length;s++){let o=n.elts[s];if(o.pos==t)return o}else Or.set(e,n=new gn);let i=n.elts[n.i]=r.resolve(e,t);return n.i=(n.i+1)%Co,i}},gn=class{constructor(){this.elts=[],this.i=0}},Co=12,Or=new WeakMap,Lt=class{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},Mo=Object.create(null),Z=class r{constructor(e,t,n,i=w.none){this.type=e,this.attrs=t,this.marks=i,this.content=n||y.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,i=0){this.content.nodesBetween(e,t,n,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,n,i){return this.content.textBetween(e,t,n,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&vt(this.attrs,t||e.defaultAttrs||Mo)&&w.sameSet(this.marks,n||w.none)}copy(e=null){return e==this.content?this:new r(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new r(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return x.empty;let i=this.resolve(e),s=this.resolve(t),o=n?0:i.sharedDepth(t),l=i.start(o),f=i.node(o).content.cut(i.pos-l,s.pos-l);return new x(f,i.depth-o,s.depth-o)}replace(e,t,n){return So(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:i}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(i==e||t.isText)return t;e-=i+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let i=this.content.child(t-1);return{node:i,index:t-1,offset:n-i.nodeSize}}resolve(e){return ht.resolveCached(this,e)}resolveNoCache(e){return ht.resolve(this,e)}rangeHasMark(e,t,n){let i=!1;return t>e&&this.nodesBetween(e,t,s=>(n.isInSet(s.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Kr(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,n=y.empty,i=0,s=n.childCount){let o=this.contentMatchAt(e).matchFragment(n,i,s),l=o&&o.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=i;a<s;a++)if(!this.type.allowsMarks(n.child(a).marks))return!1;return!0}canReplaceWith(e,t,n,i){if(i&&!this.type.allowsMarks(i))return!1;let s=this.contentMatchAt(e).matchType(n),o=s&&s.matchFragment(this.content,t);return o?o.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),wr(this.type.attrs,this.attrs,"node",this.type.name);let e=w.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];wr(n.type.attrs,n.attrs,"mark",n.type.name),e=n.addToSet(e)}if(!w.sameSet(e,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 e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let n;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,n)}let i=y.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,i,n)}};Z.prototype.text=void 0;var yn=class r extends Z{constructor(e,t,n,i){if(super(e,t,null,i),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Kr(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new r(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new r(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function Kr(r,e){for(let t=r.length-1;t>=0;t--)e=r[t].type.name+"("+e+")";return e}function wr(r,e,t,n){for(let i in e)if(!(i in r))throw new RangeError(`Unsupported attribute ${i} for ${t} of type ${n}`);for(let i in r)r[i].validate&&r[i].validate(e[i])}var be=class r{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let n=new xn(e,t);if(n.next==null)return r.empty;let i=$r(n);n.next&&n.err("Unexpected trailing text");let s=Ao(Eo(i));return Io(s,n),s}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let i=this;for(let s=t;i&&s<n;s++)i=i.matchType(e.child(s).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let i=[this];function s(o,l){let a=o.matchFragment(e,n);if(a&&(!t||a.validEnd))return y.from(l.map(f=>f.createAndFill()));for(let f=0;f<o.next.length;f++){let{type:c,next:h}=o.next[f];if(!(c.isText||c.hasRequiredAttrs())&&i.indexOf(h)==-1){i.push(h);let u=s(h,l.concat(c));if(u)return u}}return null}return s(this,[])}findWrapping(e){for(let n=0;n<this.wrapCache.length;n+=2)if(this.wrapCache[n]==e)return this.wrapCache[n+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let i=n.shift(),s=i.match;if(s.matchType(e)){let o=[];for(let l=i;l.type;l=l.via)o.push(l.type);return o.reverse()}for(let o=0;o<s.next.length;o++){let{type:l,next:a}=s.next[o];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!i.type||a.validEnd)&&(n.push({match:l.contentMatch,type:l,via:i}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let i=0;i<n.next.length;i++)e.indexOf(n.next[i].next)==-1&&t(n.next[i].next)}return t(this),e.map((n,i)=>{let s=i+(n.validEnd?"*":" ")+" ";for(let o=0;o<n.next.length;o++)s+=(o?", ":"")+n.next[o].type.name+"->"+e.indexOf(n.next[o].next);return s}).join(`
4
+ `)}};be.empty=new be(!0);var xn=class{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}};function $r(r){let e=[];do e.push(Oo(r));while(r.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Oo(r){let e=[];do e.push(wo(r));while(r.next&&r.next!=")"&&r.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function wo(r){let e=To(r);for(;;)if(r.eat("+"))e={type:"plus",expr:e};else if(r.eat("*"))e={type:"star",expr:e};else if(r.eat("?"))e={type:"opt",expr:e};else if(r.eat("{"))e=No(r,e);else break;return e}function Nr(r){/\D/.test(r.next)&&r.err("Expected number, got '"+r.next+"'");let e=Number(r.next);return r.pos++,e}function No(r,e){let t=Nr(r),n=t;return r.eat(",")&&(r.next!="}"?n=Nr(r):n=-1),r.eat("}")||r.err("Unclosed braced range"),{type:"range",min:t,max:n,expr:e}}function Do(r,e){let t=r.nodeTypes,n=t[e];if(n)return[n];let i=[];for(let s in t){let o=t[s];o.isInGroup(e)&&i.push(o)}return i.length==0&&r.err("No node type or group '"+e+"' found"),i}function To(r){if(r.eat("(")){let e=$r(r);return r.eat(")")||r.err("Missing closing paren"),e}else if(/\W/.test(r.next))r.err("Unexpected token '"+r.next+"'");else{let e=Do(r,r.next).map(t=>(r.inline==null?r.inline=t.isInline:r.inline!=t.isInline&&r.err("Mixing inline and block content"),{type:"name",value:t}));return r.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function Eo(r){let e=[[]];return i(s(r,0),t()),e;function t(){return e.push([])-1}function n(o,l,a){let f={term:a,to:l};return e[o].push(f),f}function i(o,l){o.forEach(a=>a.to=l)}function s(o,l){if(o.type=="choice")return o.exprs.reduce((a,f)=>a.concat(s(f,l)),[]);if(o.type=="seq")for(let a=0;;a++){let f=s(o.exprs[a],l);if(a==o.exprs.length-1)return f;i(f,l=t())}else if(o.type=="star"){let a=t();return n(l,a),i(s(o.expr,a),a),[n(a)]}else if(o.type=="plus"){let a=t();return i(s(o.expr,l),a),i(s(o.expr,a),a),[n(a)]}else{if(o.type=="opt")return[n(l)].concat(s(o.expr,l));if(o.type=="range"){let a=l;for(let f=0;f<o.min;f++){let c=t();i(s(o.expr,a),c),a=c}if(o.max==-1)i(s(o.expr,a),a);else for(let f=o.min;f<o.max;f++){let c=t();n(a,c),i(s(o.expr,a),c),a=c}return[n(a)]}else{if(o.type=="name")return[n(l,void 0,o.value)];throw new Error("Unknown expr type")}}}}function Hr(r,e){return e-r}function Dr(r,e){let t=[];return n(e),t.sort(Hr);function n(i){let s=r[i];if(s.length==1&&!s[0].term)return n(s[0].to);t.push(i);for(let o=0;o<s.length;o++){let{term:l,to:a}=s[o];!l&&t.indexOf(a)==-1&&n(a)}}}function Ao(r){let e=Object.create(null);return t(Dr(r,0));function t(n){let i=[];n.forEach(o=>{r[o].forEach(({term:l,to:a})=>{if(!l)return;let f;for(let c=0;c<i.length;c++)i[c][0]==l&&(f=i[c][1]);Dr(r,a).forEach(c=>{f||i.push([l,f=[]]),f.indexOf(c)==-1&&f.push(c)})})});let s=e[n.join(",")]=new be(n.indexOf(r.length-1)>-1);for(let o=0;o<i.length;o++){let l=i[o][1].sort(Hr);s.next.push({type:i[o][0],next:e[l.join(",")]||t(l)})}return s}}function Io(r,e){for(let t=0,n=[r];t<n.length;t++){let i=n[t],s=!i.validEnd,o=[];for(let l=0;l<i.next.length;l++){let{type:a,next:f}=i.next[l];o.push(a.name),s&&!(a.isText||a.hasRequiredAttrs())&&(s=!1),n.indexOf(f)==-1&&n.push(f)}s&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Ur(r){let e=Object.create(null);for(let t in r){let n=r[t];if(!n.hasDefault)return null;e[t]=n.default}return e}function jr(r,e){let t=Object.create(null);for(let n in r){let i=r[n],s=e&&e[n];if(s===void 0)if(i.hasDefault)s=i.default;else throw new RangeError("No value supplied for attribute "+n);else i.validate&&i.validate(s);t[n]=s}return t}function Gr(r,e){let t=Object.create(null);if(e)for(let n in e)t[n]=new bn(r,n,e[n]);return t}var ut=class r{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(" "):[],this.attrs=Gr(e,n.attrs),this.defaultAttrs=Ur(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==be.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:jr(this.attrs,e)}create(e=null,t,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Z(this,this.computeAttrs(e),y.from(t),w.setFrom(n))}createChecked(e=null,t,n){return t=y.from(t),this.checkContent(t),new Z(this,this.computeAttrs(e),t,w.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),t=y.from(t),t.size){let o=this.contentMatch.fillBefore(t);if(!o)return null;t=o.append(t)}let i=this.contentMatch.matchFragment(t),s=i&&i.fillBefore(y.empty,!0);return s?new Z(this,e,t.append(s),w.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let n=0;n<e.childCount;n++)if(!this.allowsMarks(e.child(n).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||(t=e.slice(0,n));return t?t.length?t:w.none:e}static compile(e,t){let n=Object.create(null);e.forEach((s,o)=>n[s]=new r(s,t,o));let i=t.spec.topNode||"doc";if(!n[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(let s in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n}};function Ro(r,e,t){let n=t.split("|");return i=>{let s=i===null?"null":typeof i;if(n.indexOf(s)<0)throw new RangeError(`Expected value of type ${n} for attribute ${e} on type ${r}, got ${s}`)}}var bn=class{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate=typeof n.validate=="string"?Ro(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}},Ue=class r{constructor(e,t,n,i){this.name=e,this.rank=t,this.schema=n,this.spec=i,this.attrs=Gr(e,i.attrs),this.excluded=null;let s=Ur(this.attrs);this.instance=s?new w(this,s):null}create(e=null){return!e&&this.instance?this.instance:new w(this,jr(this.attrs,e))}static compile(e,t){let n=Object.create(null),i=0;return e.forEach((s,o)=>n[s]=new r(s,i++,t,o)),n}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}excludes(e){return this.excluded.indexOf(e)>-1}},Sn=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let i in e)t[i]=e[i];t.nodes=dn.from(e.nodes),t.marks=dn.from(e.marks||{}),this.nodes=ut.compile(this.spec.nodes,this),this.marks=Ue.compile(this.spec.marks,this);let n=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let s=this.nodes[i],o=s.spec.content||"",l=s.spec.marks;if(s.contentMatch=n[o]||(n[o]=be.parse(o,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=l=="_"?null:l?Tr(this,l.split(" ")):l==""||!s.inlineContent?[]:null}for(let i in this.marks){let s=this.marks[i],o=s.spec.excludes;s.excluded=o==null?[s]:o==""?[]:Tr(this,o.split(" "))}this.nodeFromJSON=i=>Z.fromJSON(this,i),this.markFromJSON=i=>w.fromJSON(this,i),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,n,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof ut){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,n,i)}text(e,t){let n=this.nodes.text;return new yn(n,n.defaultAttrs,e,w.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}};function Tr(r,e){let t=[];for(let n=0;n<e.length;n++){let i=e[n],s=r.marks[i],o=s;if(s)t.push(s);else for(let l in r.marks){let a=r.marks[l];(i=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(i)>-1)&&t.push(o=a)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[n]+"'")}return t}function Po(r){return r.tag!=null}function Bo(r){return r.style!=null}var je=class r{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(i=>{if(Po(i))this.tags.push(i);else if(Bo(i)){let s=/[^=]*/.exec(i.style)[0];n.indexOf(s)<0&&n.push(s),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let s=e.nodes[i.node];return s.contentMatch.matchType(s)})}parse(e,t={}){let n=new Wt(this,t,!1);return n.addAll(e,w.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new Wt(this,t,!0);return n.addAll(e,w.none,t.from,t.to),x.maxOpen(n.finish())}matchTag(e,t,n){for(let i=n?this.tags.indexOf(n)+1:0;i<this.tags.length;i++){let s=this.tags[i];if(vo(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||t.matchesContext(s.context))){if(s.getAttrs){let o=s.getAttrs(e);if(o===!1)continue;s.attrs=o||void 0}return s}}}matchStyle(e,t,n,i){for(let s=i?this.styles.indexOf(i)+1:0;s<this.styles.length;s++){let o=this.styles[s],l=o.style;if(!(l.indexOf(e)!=0||o.context&&!n.matchesContext(o.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(o.getAttrs){let a=o.getAttrs(t);if(a===!1)continue;o.attrs=a||void 0}return o}}}static schemaRules(e){let t=[];function n(i){let s=i.priority==null?50:i.priority,o=0;for(;o<t.length;o++){let l=t[o];if((l.priority==null?50:l.priority)<s)break}t.splice(o,0,i)}for(let i in e.marks){let s=e.marks[i].spec.parseDOM;s&&s.forEach(o=>{n(o=Ar(o)),o.mark||o.ignore||o.clearMark||(o.mark=i)})}for(let i in e.nodes){let s=e.nodes[i].spec.parseDOM;s&&s.forEach(o=>{n(o=Ar(o)),o.node||o.ignore||o.mark||(o.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new r(e,r.schemaRules(e)))}},Yr={address:!0,article:!0,aside:!0,blockquote:!0,body:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},zo={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Xr={ol:!0,ul:!0},dt=1,kn=2,ct=4;function Er(r,e,t){return e!=null?(e?dt:0)|(e==="full"?kn:0):r&&r.whitespace=="pre"?dt|kn:t&~ct}var He=class{constructor(e,t,n,i,s,o){this.type=e,this.attrs=t,this.marks=n,this.solid=i,this.options=o,this.content=[],this.activeMarks=w.none,this.match=s||(o&ct?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(y.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let n=this.type.contentMatch,i;return(i=n.findWrapping(e.type))?(this.match=n,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&dt)){let n=this.content[this.content.length-1],i;if(n&&n.isText&&(i=/[ \t\r\n\u000c]+$/.exec(n.text))){let s=n;n.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-i[0].length))}}let t=y.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(y.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Yr.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},Wt=class{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let i=t.topNode,s,o=Er(null,t.preserveWhitespace,0)|(n?ct:0);i?s=new He(i.type,i.attrs,w.none,!0,t.topMatch||i.type.contentMatch,o):n?s=new He(null,null,w.none,!0,null,o):s=new He(e.schema.topNodeType,null,w.none,!0,null,o),this.nodes=[s],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,i=this.top,s=i.options&kn?"full":this.localPreserveWS||(i.options&dt)>0,{schema:o}=this.parser;if(s==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(s)if(s==="full")n=n.replace(/\r\n?/g,`
5
+ `);else if(o.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(o.linebreakReplacement.create())){let l=n.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(o.linebreakReplacement.create(),t,!0),l[a]&&this.insertNode(o.text(l[a]),t,!/\S/.test(l[a]));n=""}else n=n.replace(/\r?\n|\r/g," ");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let l=i.content[i.content.length-1],a=e.previousSibling;(!l||a&&a.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(n=n.slice(1))}n&&this.insertNode(o.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let i=this.localPreserveWS,s=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),l;Xr.hasOwnProperty(o)&&this.parser.normalizeLists&&Fo(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,n));e:if(a?a.ignore:zo.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let f,c=this.needsBlock;if(Yr.hasOwnProperty(o))s.content.length&&s.content[0].isInline&&this.open&&(this.open--,s=this.top),f=!0,s.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let h=a&&a.skip?t:this.readStyles(e,t);h&&this.addAll(e,h),f&&this.sync(s),this.needsBlock=c}else{let f=this.readStyles(e,t);f&&this.addElementByRule(e,a,f,a.consuming===!1?l:void 0)}this.localPreserveWS=i}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
6
+ `),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let s=this.parser.matchedStyles[i],o=n.getPropertyValue(s);if(o)for(let l=void 0;;){let a=this.parser.matchStyle(s,o,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(f=>!a.clearMark(f)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,n,i){let s,o;if(t.node)if(o=this.parser.schema.nodes[t.node],o.isLeaf)this.insertNode(o.create(t.attrs),n,e.nodeName=="BR")||this.leafFallback(e,n);else{let a=this.enter(o,t.attrs||null,n,t.preserveWhitespace);a&&(s=!0,n=a)}else{let a=this.parser.schema.marks[t.mark];n=n.concat(a.create(t.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(i)this.addElement(e,n,i);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,n,!1));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,n),this.findAround(e,a,!1)}s&&this.sync(l)&&this.open--}addAll(e,t,n,i){let s=n||0;for(let o=n?e.childNodes[n]:e.firstChild,l=i==null?null:e.childNodes[i];o!=l;o=o.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(o,t);this.findAtPoint(e,s)}findPlace(e,t,n){let i,s;for(let o=this.open,l=0;o>=0;o--){let a=this.nodes[o],f=a.findWrapping(e);if(f&&(!i||i.length>f.length+l)&&(i=f,s=a,!f.length))break;if(a.solid){if(n)break;l+=2}}if(!i)return null;this.sync(s);for(let o=0;o<i.length;o++)t=this.enterInner(i[o],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let s=this.textblockFromContext();s&&(t=this.enterInner(s,null,t))}let i=this.findPlace(e,t,n);if(i){this.closeExtra();let s=this.top;s.match&&(s.match=s.match.matchType(e.type));let o=w.none;for(let l of i.concat(e.marks))(s.type?s.type.allowsMarkType(l.type):Ir(l.type,e.type))&&(o=l.addToSet(o));return s.content.push(e.mark(o)),!0}return!1}enter(e,t,n,i){let s=this.findPlace(e.create(t),n,!1);return s&&(s=this.enterInner(e,t,n,!0,i)),s}enterInner(e,t,n,i=!1,s){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=Er(e,s,o.options);o.options&ct&&o.content.length==0&&(l|=ct);let a=w.none;return n=n.filter(f=>(o.type?o.type.allowsMarkType(f.type):Ir(f.type,e))?(a=f.addToSet(a),!1):!0),this.nodes.push(new He(e,t,a,i,null,l)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=dt)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let i=n.length-1;i>=0;i--)e+=n[i].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&t.compareDocumentPosition(this.find[i].node)&(n?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),n=this.options.context,i=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),s=-(n?n.depth+1:0)+(i?0:1),o=(l,a)=>{for(;l>=0;l--){let f=t[l];if(f==""){if(l==t.length-1||l==0)continue;for(;a>=s;a--)if(o(l-1,a))return!0;return!1}else{let c=a>0||a==0&&i?this.nodes[a].type:n&&a>=s?n.node(a-s).type:null;if(!c||c.name!=f&&!c.isInGroup(f))return!1;a--}}return!0};return o(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let t in this.parser.schema.nodes){let n=this.parser.schema.nodes[t];if(n.isTextblock&&n.defaultAttrs)return n}}};function Fo(r){for(let e=r.firstChild,t=null;e;e=e.nextSibling){let n=e.nodeType==1?e.nodeName.toLowerCase():null;n&&Xr.hasOwnProperty(n)&&t?(t.appendChild(e),e=t):n=="li"?t=e:n&&(t=null)}}function vo(r,e){return(r.matches||r.msMatchesSelector||r.webkitMatchesSelector||r.mozMatchesSelector).call(r,e)}function Ar(r){let e={};for(let t in r)e[t]=r[t];return e}function Ir(r,e){let t=e.schema.nodes;for(let n in t){let i=t[n];if(!i.allowsMarkType(r))continue;let s=[],o=l=>{s.push(l);for(let a=0;a<l.edgeCount;a++){let{type:f,next:c}=l.edge(a);if(f==e||s.indexOf(c)<0&&o(c))return!0}};if(o(i.contentMatch))return!0}}var Se=class r{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=zt(t).createDocumentFragment());let i=n,s=[];return e.forEach(o=>{if(s.length||o.marks.length){let l=0,a=0;for(;l<s.length&&a<o.marks.length;){let f=o.marks[a];if(!this.marks[f.type.name]){a++;continue}if(!f.eq(s[l][0])||f.type.spec.spanning===!1)break;l++,a++}for(;l<s.length;)i=s.pop()[1];for(;a<o.marks.length;){let f=o.marks[a++],c=this.serializeMark(f,o.isInline,t);c&&(s.push([f,i]),i.appendChild(c.dom),i=c.contentDOM||c.dom)}}i.appendChild(this.serializeNodeInner(o,t))}),n}serializeNodeInner(e,t){if(e.isText)return zt(t).createTextNode(e.text);let{dom:n,contentDOM:i}=Ft(zt(t),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,i)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let i=e.marks.length-1;i>=0;i--){let s=this.serializeMark(e.marks[i],e.isInline,t);s&&((s.contentDOM||s.dom).appendChild(n),n=s.dom)}return n}serializeMark(e,t,n={}){let i=this.marks[e.type.name];return i&&Ft(zt(n),i(e,t),null,e.attrs)}static renderSpec(e,t,n=null,i){return typeof t=="string"?{dom:e.createTextNode(t)}:Ft(e,t,n,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new r(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Rr(e.nodes);return t.text||(t.text=n=>n.text),t}static marksFromSchema(e){return Rr(e.marks)}};function Rr(r){let e={};for(let t in r){let n=r[t].spec.toDOM;n&&(e[t]=n)}return e}function zt(r){return r.document||window.document}var Pr=new WeakMap;function Vo(r){let e=Pr.get(r);return e===void 0&&Pr.set(r,e=Lo(r)),e}function Lo(r){let e=null;function t(n){if(n&&typeof n=="object")if(Array.isArray(n))if(typeof n[0]=="string")e||(e=[]),e.push(n);else for(let i=0;i<n.length;i++)t(n[i]);else for(let i in n)t(n[i])}return t(r),e}function Ft(r,e,t,n){if(e.nodeType==1)return{dom:e};if(e.dom&&e.dom.nodeType==1)return e;let i=e[0],s;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(n&&(s=Vo(n))&&s.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=i.indexOf(" ");o>0&&(t=i.slice(0,o),i=i.slice(o+1));let l,a=t?r.createElementNS(t,i):r.createElement(i),f=e[1],c=1;if(f&&typeof f=="object"&&f.nodeType==null&&!Array.isArray(f)){c=2;for(let h in f)if(f[h]!=null){let u=h.indexOf(" ");u>0?a.setAttributeNS(h.slice(0,u),h.slice(u+1),f[h]):h=="style"&&a.style?a.style.cssText=f[h]:a.setAttribute(h,f[h])}}for(let h=c;h<e.length;h++){let u=e[h];if(u===0){if(h<e.length-1||h>c)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else if(typeof u=="string")a.appendChild(r.createTextNode(u));else{let{dom:d,contentDOM:p}=Ft(r,u,t,n);if(a.appendChild(d),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}var Oi={};ie(Oi,{AllSelection:()=>j,EditorState:()=>In,NodeSelection:()=>k,Plugin:()=>Y,PluginKey:()=>nt,Selection:()=>C,SelectionRange:()=>Pe,TextSelection:()=>M,Transaction:()=>Ht});var mi={};ie(mi,{AddMarkStep:()=>Xe,AddNodeMarkStep:()=>Qe,AttrStep:()=>gt,DocAttrStep:()=>yt,MapResult:()=>Ge,Mapping:()=>Ye,RemoveMarkStep:()=>ke,RemoveNodeMarkStep:()=>Ae,ReplaceAroundStep:()=>U,ReplaceStep:()=>V,Step:()=>E,StepMap:()=>se,StepResult:()=>R,Transform:()=>xt,TransformError:()=>Ie,canJoin:()=>ue,canSplit:()=>Ze,dropPoint:()=>St,findWrapping:()=>bt,insertPoint:()=>ci,joinPoint:()=>qt,liftTarget:()=>_e,replaceStep:()=>et});var ni=65535,ri=Math.pow(2,16);function Wo(r,e){return r+e*ri}function _r(r){return r&ni}function Jo(r){return(r-(r&ni))/ri}var ii=1,si=2,Jt=4,oi=8,Ge=class{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&oi)>0}get deletedBefore(){return(this.delInfo&(ii|Jt))>0}get deletedAfter(){return(this.delInfo&(si|Jt))>0}get deletedAcross(){return(this.delInfo&Jt)>0}},se=class r{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&r.empty)return r.empty}recover(e){let t=0,n=_r(e);if(!this.inverted)for(let i=0;i<n;i++)t+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[n*3]+t+Jo(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let i=0,s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?i:0);if(a>e)break;let f=this.ranges[l+s],c=this.ranges[l+o],h=a+f;if(e<=h){let u=f?e==a?-1:e==h?1:t:t,d=a+i+(u<0?0:c);if(n)return d;let p=e==(t<0?a:h)?null:Wo(l/3,e-a),m=0;return f&&(m|=e==a?si:e==h?ii:Jt,(t<0?e!=a:e!=h)&&(m|=oi)),new Ge(d,m,p)}i+=c-f}return n?e+i:new Ge(e+i,0,null)}touches(e,t){let n=0,i=_r(t),s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?n:0);if(a>e)break;let f=this.ranges[l+s],c=a+f;if(e<=c&&l==i*3)return!0;n+=this.ranges[l+o]-f}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let i=0,s=0;i<this.ranges.length;i+=3){let o=this.ranges[i],l=o-(this.inverted?s:0),a=o+(this.inverted?0:s),f=this.ranges[i+t],c=this.ranges[i+n];e(l,l+f,a,a+c),s+=c-f}}invert(){return new r(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?r.empty:new r(e<0?[0,-e,0]:[0,0,e])}};se.empty=new se([]);var Ye=class r{constructor(e,t,n=0,i=e?e.length:0){this.mirror=t,this.from=n,this.to=i,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new r(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let i=e.getMirror(t);this.appendMap(e._maps[t],i!=null&&i<t?n+i:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let i=e.getMirror(t);this.appendMap(e._maps[t].invert(),i!=null&&i>t?n-i-1:void 0)}}invert(){let e=new r;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let i=0;for(let s=this.from;s<this.to;s++){let o=this._maps[s],l=o.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(s);if(a!=null&&a>s&&a<this.to){s=a,e=this._maps[a].recover(l.recover);continue}}i|=l.delInfo,e=l.pos}return n?e:new Ge(e,i,null)}},Cn=Object.create(null),E=class{getMap(){return se.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=Cn[t.stepType];if(!n)throw new RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in Cn)throw new RangeError("Duplicate use of step JSON ID "+e);return Cn[e]=t,t.prototype.jsonID=e,t}},R=class r{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new r(e,null)}static fail(e){return new r(null,e)}static fromReplace(e,t,n,i){try{return r.ok(e.replace(t,n,i))}catch(s){if(s instanceof he)return r.fail(s.message);throw s}}};function Nn(r,e,t){let n=[];for(let i=0;i<r.childCount;i++){let s=r.child(i);s.content.size&&(s=s.copy(Nn(s.content,e,s))),s.isInline&&(s=e(s,t,i)),n.push(s)}return y.fromArray(n)}var Xe=class r extends E{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),i=n.node(n.sharedDepth(this.to)),s=new x(Nn(t.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),i),t.openStart,t.openEnd);return R.fromReplace(e,this.from,this.to,s)}invert(){return new ke(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new r(t.pos,n.pos,this.mark)}merge(e){return e instanceof r&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new r(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new r(t.from,t.to,e.markFromJSON(t.mark))}};E.jsonID("addMark",Xe);var ke=class r extends E{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new x(Nn(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return R.fromReplace(e,this.from,this.to,n)}invert(){return new Xe(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new r(t.pos,n.pos,this.mark)}merge(e){return e instanceof r&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new r(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new r(t.from,t.to,e.markFromJSON(t.mark))}};E.jsonID("removeMark",ke);var Qe=class r extends E{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return R.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return R.fromReplace(e,this.pos,this.pos+1,new x(y.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let n=this.mark.addToSet(t.marks);if(n.length==t.marks.length){for(let i=0;i<t.marks.length;i++)if(!t.marks[i].isInSet(n))return new r(this.pos,t.marks[i]);return new r(this.pos,this.mark)}}return new Ae(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new r(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new r(t.pos,e.markFromJSON(t.mark))}};E.jsonID("addNodeMark",Qe);var Ae=class r extends E{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return R.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return R.fromReplace(e,this.pos,this.pos+1,new x(y.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Qe(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new r(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new r(t.pos,e.markFromJSON(t.mark))}};E.jsonID("removeNodeMark",Ae);var V=class r extends E{constructor(e,t,n,i=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=i}apply(e){return this.structure&&On(e,this.from,this.to)?R.fail("Structure replace would overwrite content"):R.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new se([this.from,this.to-this.from,this.slice.size])}invert(e){return new r(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.to,-1),n=this.from==this.to&&r.MAP_BIAS<0?t:e.mapResult(this.from,1);return n.deletedAcross&&t.deletedAcross?null:new r(n.pos,Math.max(n.pos,t.pos),this.slice,this.structure)}merge(e){if(!(e instanceof r)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?x.empty:new x(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new r(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?x.empty:new x(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new r(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new r(t.from,t.to,x.fromJSON(e,t.slice),!!t.structure)}};V.MAP_BIAS=1;E.jsonID("replace",V);var U=class r extends E{constructor(e,t,n,i,s,o,l=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=i,this.slice=s,this.insert=o,this.structure=l}apply(e){if(this.structure&&(On(e,this.from,this.gapFrom)||On(e,this.gapTo,this.to)))return R.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return R.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?R.fromReplace(e,this.from,this.to,n):R.fail("Content does not fit in gap")}getMap(){return new se([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new r(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1),i=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?n.pos:e.map(this.gapTo,1);return t.deletedAcross&&n.deletedAcross||i<t.pos||s>n.pos?null:new r(t.pos,n.pos,i,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new r(t.from,t.to,t.gapFrom,t.gapTo,x.fromJSON(e,t.slice),t.insert,!!t.structure)}};E.jsonID("replaceAround",U);function On(r,e,t){let n=r.resolve(e),i=t-e,s=n.depth;for(;i>0&&s>0&&n.indexAfter(s)==n.node(s).childCount;)s--,i--;if(i>0){let o=n.node(s).maybeChild(n.indexAfter(s));for(;i>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,i--}}return!1}function qo(r,e,t,n){let i=[],s=[],o,l;r.doc.nodesBetween(e,t,(a,f,c)=>{if(!a.isInline)return;let h=a.marks;if(!n.isInSet(h)&&c.type.allowsMarkType(n.type)){let u=Math.max(f,e),d=Math.min(f+a.nodeSize,t),p=n.addToSet(h);for(let m=0;m<h.length;m++)h[m].isInSet(p)||(o&&o.to==u&&o.mark.eq(h[m])?o.to=d:i.push(o=new ke(u,d,h[m])));l&&l.to==u?l.to=d:s.push(l=new Xe(u,d,n))}}),i.forEach(a=>r.step(a)),s.forEach(a=>r.step(a))}function Ko(r,e,t,n){let i=[],s=0;r.doc.nodesBetween(e,t,(o,l)=>{if(!o.isInline)return;s++;let a=null;if(n instanceof Ue){let f=o.marks,c;for(;c=n.isInSet(f);)(a||(a=[])).push(c),f=c.removeFromSet(f)}else n?n.isInSet(o.marks)&&(a=[n]):a=o.marks;if(a&&a.length){let f=Math.min(l+o.nodeSize,t);for(let c=0;c<a.length;c++){let h=a[c],u;for(let d=0;d<i.length;d++){let p=i[d];p.step==s-1&&h.eq(i[d].style)&&(u=p)}u?(u.to=f,u.step=s):i.push({style:h,from:Math.max(l,e),to:f,step:s})}}}),i.forEach(o=>r.step(new ke(o.from,o.to,o.style)))}function Dn(r,e,t,n=t.contentMatch,i=!0){let s=r.doc.nodeAt(e),o=[],l=e+1;for(let a=0;a<s.childCount;a++){let f=s.child(a),c=l+f.nodeSize,h=n.matchType(f.type);if(!h)o.push(new V(l,c,x.empty));else{n=h;for(let u=0;u<f.marks.length;u++)t.allowsMarkType(f.marks[u].type)||r.step(new ke(l,c,f.marks[u]));if(i&&f.isText&&t.whitespace!="pre"){let u,d=/\r?\n|\r/g,p;for(;u=d.exec(f.text);)p||(p=new x(y.from(t.schema.text(" ",t.allowedMarks(f.marks))),0,0)),o.push(new V(l+u.index,l+u.index+u[0].length,p))}}l=c}if(!n.validEnd){let a=n.fillBefore(y.empty,!0);r.replace(l,l,new x(a,0,0))}for(let a=o.length-1;a>=0;a--)r.step(o[a])}function $o(r,e,t){return(e==0||r.canReplace(e,r.childCount))&&(t==r.childCount||r.canReplace(0,t))}function _e(r){let t=r.parent.content.cutByIndex(r.startIndex,r.endIndex);for(let n=r.depth,i=0,s=0;;--n){let o=r.$from.node(n),l=r.$from.index(n)+i,a=r.$to.indexAfter(n)-s;if(n<r.depth&&o.canReplace(l,a,t))return n;if(n==0||o.type.spec.isolating||!$o(o,l,a))break;l&&(i=1),a<o.childCount&&(s=1)}return null}function Ho(r,e,t){let{$from:n,$to:i,depth:s}=e,o=n.before(s+1),l=i.after(s+1),a=o,f=l,c=y.empty,h=0;for(let p=s,m=!1;p>t;p--)m||n.index(p)>0?(m=!0,c=y.from(n.node(p).copy(c)),h++):a--;let u=y.empty,d=0;for(let p=s,m=!1;p>t;p--)m||i.after(p+1)<i.end(p)?(m=!0,u=y.from(i.node(p).copy(u)),d++):f++;r.step(new U(a,f,o,l,new x(c.append(u),h,d),c.size-h,!0))}function bt(r,e,t=null,n=r){let i=Uo(r,e),s=i&&jo(n,e);return s?i.map(Zr).concat({type:e,attrs:t}).concat(s.map(Zr)):null}function Zr(r){return{type:r,attrs:null}}function Uo(r,e){let{parent:t,startIndex:n,endIndex:i}=r,s=t.contentMatchAt(n).findWrapping(e);if(!s)return null;let o=s.length?s[0]:e;return t.canReplaceWith(n,i,o)?s:null}function jo(r,e){let{parent:t,startIndex:n,endIndex:i}=r,s=t.child(n),o=e.contentMatch.findWrapping(s.type);if(!o)return null;let a=(o.length?o[o.length-1]:e).contentMatch;for(let f=n;a&&f<i;f++)a=a.matchType(t.child(f).type);return!a||!a.validEnd?null:o}function Go(r,e,t){let n=y.empty;for(let o=t.length-1;o>=0;o--){if(n.size){let l=t[o].type.contentMatch.matchFragment(n);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}n=y.from(t[o].type.create(t[o].attrs,n))}let i=e.start,s=e.end;r.step(new U(i,s,i,s,new x(n,0,0),t.length,!0))}function Yo(r,e,t,n,i){if(!n.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=r.steps.length;r.doc.nodesBetween(e,t,(o,l)=>{let a=typeof i=="function"?i(o):i;if(o.isTextblock&&!o.hasMarkup(n,a)&&Xo(r.doc,r.mapping.slice(s).map(l),n)){let f=null;if(n.schema.linebreakReplacement){let d=n.whitespace=="pre",p=!!n.contentMatch.matchType(n.schema.linebreakReplacement);d&&!p?f=!1:!d&&p&&(f=!0)}f===!1&&ai(r,o,l,s),Dn(r,r.mapping.slice(s).map(l,1),n,void 0,f===null);let c=r.mapping.slice(s),h=c.map(l,1),u=c.map(l+o.nodeSize,1);return r.step(new U(h,u,h+1,u-1,new x(y.from(n.create(a,null,o.marks)),0,0),1,!0)),f===!0&&li(r,o,l,s),!1}})}function li(r,e,t,n){e.forEach((i,s)=>{if(i.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(i.text);){let a=r.mapping.slice(n).map(t+1+s+o.index);r.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function ai(r,e,t,n){e.forEach((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let o=r.mapping.slice(n).map(t+1+s);r.replaceWith(o,o+1,e.type.schema.text(`
7
+ `))}})}function Xo(r,e,t){let n=r.resolve(e),i=n.index();return n.parent.canReplaceWith(i,i+1,t)}function Qo(r,e,t,n,i){let s=r.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");t||(t=s.type);let o=t.create(n,null,i||s.marks);if(s.isLeaf)return r.replaceWith(e,e+s.nodeSize,o);if(!t.validContent(s.content))throw new RangeError("Invalid content for node type "+t.name);r.step(new U(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new x(y.from(o),0,0),1,!0))}function Ze(r,e,t=1,n){let i=r.resolve(e),s=i.depth-t,o=n&&n[n.length-1]||i.parent;if(s<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let f=i.depth-1,c=t-2;f>s;f--,c--){let h=i.node(f),u=i.index(f);if(h.type.spec.isolating)return!1;let d=h.content.cutByIndex(u,h.childCount),p=n&&n[c+1];p&&(d=d.replaceChild(0,p.type.create(p.attrs)));let m=n&&n[c]||h;if(!h.canReplace(u+1,h.childCount)||!m.type.validContent(d))return!1}let l=i.indexAfter(s),a=n&&n[0];return i.node(s).canReplaceWith(l,l,a?a.type:i.node(s+1).type)}function _o(r,e,t=1,n){let i=r.doc.resolve(e),s=y.empty,o=y.empty;for(let l=i.depth,a=i.depth-t,f=t-1;l>a;l--,f--){s=y.from(i.node(l).copy(s));let c=n&&n[f];o=y.from(c?c.type.create(c.attrs,o):i.node(l).copy(o))}r.step(new V(e,e,new x(s.append(o),t,t),!0))}function ue(r,e){let t=r.resolve(e),n=t.index();return fi(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(n,n+1)}function Zo(r,e){e.content.size||r.type.compatibleContent(e.type);let t=r.contentMatchAt(r.childCount),{linebreakReplacement:n}=r.type.schema;for(let i=0;i<e.childCount;i++){let s=e.child(i),o=s.type==n?r.type.schema.nodes.text:s.type;if(t=t.matchType(o),!t||!r.type.allowsMarks(s.marks))return!1}return t.validEnd}function fi(r,e){return!!(r&&e&&!r.isLeaf&&Zo(r,e))}function qt(r,e,t=-1){let n=r.resolve(e);for(let i=n.depth;;i--){let s,o,l=n.index(i);if(i==n.depth?(s=n.nodeBefore,o=n.nodeAfter):t>0?(s=n.node(i+1),l++,o=n.node(i).maybeChild(l)):(s=n.node(i).maybeChild(l-1),o=n.node(i+1)),s&&!s.isTextblock&&fi(s,o)&&n.node(i).canReplace(l,l+1))return e;if(i==0)break;e=t<0?n.before(i):n.after(i)}}function el(r,e,t){let n=null,{linebreakReplacement:i}=r.doc.type.schema,s=r.doc.resolve(e-t),o=s.node().type;if(i&&o.inlineContent){let c=o.whitespace=="pre",h=!!o.contentMatch.matchType(i);c&&!h?n=!1:!c&&h&&(n=!0)}let l=r.steps.length;if(n===!1){let c=r.doc.resolve(e+t);ai(r,c.node(),c.before(),l)}o.inlineContent&&Dn(r,e+t-1,o,s.node().contentMatchAt(s.index()),n==null);let a=r.mapping.slice(l),f=a.map(e-t);if(r.step(new V(f,a.map(e+t,-1),x.empty,!0)),n===!0){let c=r.doc.resolve(f);li(r,c.node(),c.before(),r.steps.length)}return r}function ci(r,e,t){let n=r.resolve(e);if(n.parent.canReplaceWith(n.index(),n.index(),t))return e;if(n.parentOffset==0)for(let i=n.depth-1;i>=0;i--){let s=n.index(i);if(n.node(i).canReplaceWith(s,s,t))return n.before(i+1);if(s>0)return null}if(n.parentOffset==n.parent.content.size)for(let i=n.depth-1;i>=0;i--){let s=n.indexAfter(i);if(n.node(i).canReplaceWith(s,s,t))return n.after(i+1);if(s<n.node(i).childCount)return null}return null}function St(r,e,t){let n=r.resolve(e);if(!t.content.size)return e;let i=t.content;for(let s=0;s<t.openStart;s++)i=i.firstChild.content;for(let s=1;s<=(t.openStart==0&&t.size?2:1);s++)for(let o=n.depth;o>=0;o--){let l=o==n.depth?0:n.pos<=(n.start(o+1)+n.end(o+1))/2?-1:1,a=n.index(o)+(l>0?1:0),f=n.node(o),c=!1;if(s==1)c=f.canReplace(a,a,i);else{let h=f.contentMatchAt(a).findWrapping(i.firstChild.type);c=h&&f.canReplaceWith(a,a,h[0])}if(c)return l==0?n.pos:l<0?n.before(o+1):n.after(o+1)}return null}function et(r,e,t=e,n=x.empty){if(e==t&&!n.size)return null;let i=r.resolve(e),s=r.resolve(t);return hi(i,s,n)?new V(e,t,n):new wn(i,s,n).fit()}function hi(r,e,t){return!t.openStart&&!t.openEnd&&r.start()==e.start()&&r.parent.canReplace(r.index(),e.index(),t.content)}var wn=class{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=y.empty;for(let i=0;i<=e.depth;i++){let s=e.node(i);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=y.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let f=this.findFittable();f?this.placeNodes(f):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,i=this.close(e<0?this.$to:n.doc.resolve(e));if(!i)return null;let s=this.placed,o=n.depth,l=i.depth;for(;o&&l&&s.childCount==1;)s=s.firstChild.content,o--,l--;let a=new x(s,o,l);return e>-1?new U(n.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||n.pos!=this.$to.pos?new V(n.pos,i.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,i=this.unplaced.openEnd;n<e;n++){let s=t.firstChild;if(t.childCount>1&&(i=0),s.type.spec.isolating&&i<=n){e=n;break}t=s.content}for(let t=1;t<=2;t++)for(let n=t==1?e:this.unplaced.openStart;n>=0;n--){let i,s=null;n?(s=ei(this.unplaced.content,n-1).firstChild,i=s.content):i=this.unplaced.content;let o=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:f}=this.frontier[l],c,h=null;if(t==1&&(o?f.matchType(o.type)||(h=f.fillBefore(y.from(o),!1)):s&&a.compatibleContent(s.type)))return{sliceDepth:n,frontierDepth:l,parent:s,inject:h};if(t==2&&o&&(c=f.findWrapping(o.type)))return{sliceDepth:n,frontierDepth:l,parent:s,wrap:c};if(s&&f.matchType(s.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced;return ti(e,-1)<=t?!1:(this.unplaced.size>1&&ti(e,1)>n&&n++,this.unplaced=new x(e,t+1,n),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,i=ei(e,t);if(i.childCount<=1&&t>0){let s=e.size-t<=t+i.size;this.unplaced=new x(pt(e,t-1,1),t-1,s?t-1:n)}else this.unplaced=new x(pt(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:i,wrap:s}){for(;this.depth>t;)this.closeFrontierNode();if(s)for(let m=0;m<s.length;m++)this.openFrontierNode(s[m]);let o=this.unplaced,l=n?n.content:o.content,a=o.openStart-e,f=0,c=[],{match:h,type:u}=this.frontier[t];if(i){for(let m=0;m<i.childCount;m++)c.push(i.child(m));h=h.matchFragment(i)}let d=l.size+e-(o.content.size-o.openEnd);for(;f<l.childCount;){let m=l.child(f),g=h.matchType(m.type);if(!g)break;f++,(f>1||a==0||m.content.size)&&(h=g,c.push(ui(m.mark(u.allowedMarks(m.marks)),f==1?a:0,f==l.childCount?d:-1)))}let p=f==l.childCount;p||(d=-1),this.placed=mt(this.placed,t,y.from(c)),this.frontier[t].match=h,p&&d<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=l;m<d;m++){let b=g.lastChild;this.frontier.push({type:b.type,match:b.contentMatchAt(b.childCount)}),g=b.content}this.unplaced=p?e==0?x.empty:new x(pt(o.content,e-1,1),e-1,d<0?o.openEnd:e-1):new x(pt(o.content,e,f),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!Mn(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:n}=this.$to,i=this.$to.after(n);for(;n>1&&i==this.$to.end(--n);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:i}=this.frontier[t],s=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),o=Mn(e,t,i,n,s);if(o){for(let l=t-1;l>=0;l--){let{match:a,type:f}=this.frontier[l],c=Mn(e,l,f,a,!0);if(!c||c.childCount)continue e}return{depth:t,fit:o,move:s?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=mt(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let i=e.node(n),s=i.type.contentMatch.fillBefore(i.content,!0,e.index(n));this.openFrontierNode(i.type,i.attrs,s)}return e}openFrontierNode(e,t=null,n){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=mt(this.placed,this.depth,y.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(y.empty,!0);t.childCount&&(this.placed=mt(this.placed,this.frontier.length,t))}};function pt(r,e,t){return e==0?r.cutByIndex(t,r.childCount):r.replaceChild(0,r.firstChild.copy(pt(r.firstChild.content,e-1,t)))}function mt(r,e,t){return e==0?r.append(t):r.replaceChild(r.childCount-1,r.lastChild.copy(mt(r.lastChild.content,e-1,t)))}function ei(r,e){for(let t=0;t<e;t++)r=r.firstChild.content;return r}function ui(r,e,t){if(e<=0)return r;let n=r.content;return e>1&&(n=n.replaceChild(0,ui(n.firstChild,e-1,n.childCount==1?t-1:0))),e>0&&(n=r.type.contentMatch.fillBefore(n).append(n),t<=0&&(n=n.append(r.type.contentMatch.matchFragment(n).fillBefore(y.empty,!0)))),r.copy(n)}function Mn(r,e,t,n,i){let s=r.node(e),o=i?r.indexAfter(e):r.index(e);if(o==s.childCount&&!t.compatibleContent(s.type))return null;let l=n.fillBefore(s.content,!0,o);return l&&!tl(t,s.content,o)?l:null}function tl(r,e,t){for(let n=t;n<e.childCount;n++)if(!r.allowsMarks(e.child(n).marks))return!0;return!1}function nl(r){return r.spec.defining||r.spec.definingForContent}function ti(r,e){for(let t=0;;t++){let n=e<0?r.firstChild:r.lastChild;if(!n||n.isAtom)return t;r=n.content}}function rl(r,e,t,n){if(!n.size)return r.deleteRange(e,t);let i=r.doc.resolve(e),s=r.doc.resolve(t);if(hi(i,s,n))return r.step(new V(e,t,n));let o=pi(i,s);o[o.length-1]==0&&o.pop();let l=-(i.depth+1);o.unshift(l);for(let u=i.depth,d=i.pos-1;u>0;u--,d--){let p=i.node(u).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;o.indexOf(u)>-1?l=u:i.before(u)==d&&o.splice(1,0,-u)}let a=o.indexOf(l),f=[],c=n.openStart;for(let u=n.content,d=0;;d++){let p=u.firstChild;if(f.push(p),d==n.openStart)break;u=p.content}for(let u=c-1;u>=0;u--){let d=f[u],p=nl(d.type);if(p&&!d.sameMarkup(i.node(Math.abs(l)-1)))c=u;else if(p||!d.type.isTextblock)break}for(let u=n.openStart;u>=0;u--){let d=(u+c+1)%(n.openStart+1),p=f[d];if(p)for(let m=0;m<o.length;m++){let g=o[(m+a)%o.length],b=!0;g<0&&(b=!1,g=-g);let D=i.node(g-1),N=i.index(g-1);if(D.canReplaceWith(N,N,p.type,p.marks))return r.replace(i.before(g),b?s.after(g):t,new x(di(n.content,0,n.openStart,d),d,n.openEnd))}}let h=r.steps.length;for(let u=o.length-1;u>=0&&(r.replace(e,t,n),!(r.steps.length>h));u--){let d=o[u];d<0||(e=i.before(d),t=s.after(d))}}function di(r,e,t,n,i){if(e<t){let s=r.firstChild;r=r.replaceChild(0,s.copy(di(s.content,e+1,t,n,s)))}if(e>n){let s=i.contentMatchAt(0),o=s.fillBefore(r).append(r);r=o.append(s.matchFragment(o).fillBefore(y.empty,!0))}return r}function il(r,e,t,n){if(!n.isInline&&e==t&&r.doc.resolve(e).parent.content.size){let i=ci(r.doc,e,n.type);i!=null&&(e=t=i)}r.replaceRange(e,t,new x(y.from(n),0,0))}function sl(r,e,t){let n=r.doc.resolve(e),i=r.doc.resolve(t);if(n.parent.isTextblock&&i.parent.isTextblock&&n.start()!=i.start()&&n.parentOffset==0&&i.parentOffset==0){let o=n.sharedDepth(t),l=!1;for(let a=n.depth;a>o;a--)n.node(a).type.spec.isolating&&(l=!0);for(let a=i.depth;a>o;a--)i.node(a).type.spec.isolating&&(l=!0);if(!l){for(let a=n.depth;a>0&&e==n.start(a);a--)e=n.before(a);for(let a=i.depth;a>0&&t==i.start(a);a--)t=i.before(a);n=r.doc.resolve(e),i=r.doc.resolve(t)}}let s=pi(n,i);for(let o=0;o<s.length;o++){let l=s[o],a=o==s.length-1;if(a&&l==0||n.node(l).type.contentMatch.validEnd)return r.delete(n.start(l),i.end(l));if(l>0&&(a||n.node(l-1).canReplace(n.index(l-1),i.indexAfter(l-1))))return r.delete(n.before(l),i.after(l))}for(let o=1;o<=n.depth&&o<=i.depth;o++)if(e-n.start(o)==n.depth-o&&t>n.end(o)&&i.end(o)-t!=i.depth-o&&n.start(o-1)==i.start(o-1)&&n.node(o-1).canReplace(n.index(o-1),i.index(o-1)))return r.delete(n.before(o),t);r.delete(e,t)}function pi(r,e){let t=[],n=Math.min(r.depth,e.depth);for(let i=n;i>=0;i--){let s=r.start(i);if(s<r.pos-(r.depth-i)||e.end(i)>e.pos+(e.depth-i)||r.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(s==e.start(i)||i==r.depth&&i==e.depth&&r.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==s-1)&&t.push(i)}return t}var gt=class r extends E{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return R.fail("No node at attribute step's position");let n=Object.create(null);for(let s in t.attrs)n[s]=t.attrs[s];n[this.attr]=this.value;let i=t.type.create(n,null,t.marks);return R.fromReplace(e,this.pos,this.pos+1,new x(y.from(i),0,t.isLeaf?0:1))}getMap(){return se.empty}invert(e){return new r(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new r(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new r(t.pos,t.attr,t.value)}};E.jsonID("attr",gt);var yt=class r extends E{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return R.ok(n)}getMap(){return se.empty}invert(e){return new r(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new r(t.attr,t.value)}};E.jsonID("docAttr",yt);var Ie=class extends Error{};Ie=function r(e){let t=Error.call(this,e);return t.__proto__=r.prototype,t};Ie.prototype=Object.create(Error.prototype);Ie.prototype.constructor=Ie;Ie.prototype.name="TransformError";var xt=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Ye}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Ie(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let n=0;n<this.mapping.maps.length;n++){let i=this.mapping.maps[n];n&&(e=i.map(e,1),t=i.map(t,-1)),i.forEach((s,o,l,a)=>{e=Math.min(e,l),t=Math.max(t,a)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=x.empty){let i=et(this.doc,e,t,n);return i&&this.step(i),this}replaceWith(e,t,n){return this.replace(e,t,new x(y.from(n),0,0))}delete(e,t){return this.replace(e,t,x.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return rl(this,e,t,n),this}replaceRangeWith(e,t,n){return il(this,e,t,n),this}deleteRange(e,t){return sl(this,e,t),this}lift(e,t){return Ho(this,e,t),this}join(e,t=1){return el(this,e,t),this}wrap(e,t){return Go(this,e,t),this}setBlockType(e,t=e,n,i=null){return Yo(this,e,t,n,i),this}setNodeMarkup(e,t,n=null,i){return Qo(this,e,t,n,i),this}setNodeAttribute(e,t,n){return this.step(new gt(e,t,n)),this}setDocAttribute(e,t){return this.step(new yt(e,t)),this}addNodeMark(e,t){return this.step(new Qe(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw new RangeError("No node at position "+e);if(t instanceof w)t.isInSet(n.marks)&&this.step(new Ae(e,t));else{let i=n.marks,s,o=[];for(;s=t.isInSet(i);)o.push(new Ae(e,s)),i=s.removeFromSet(i);for(let l=o.length-1;l>=0;l--)this.step(o[l])}return this}split(e,t=1,n){return _o(this,e,t,n),this}addMark(e,t,n){return qo(this,e,t,n),this}removeMark(e,t,n){return Ko(this,e,t,n),this}clearIncompatible(e,t,n){return Dn(this,e,t,n),this}};var Tn=Object.create(null),C=class{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new Pe(e.min(t),e.max(t))]}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 e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=x.empty){let n=t.content.lastChild,i=null;for(let l=0;l<t.openEnd;l++)i=n,n=n.lastChild;let s=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:a,$to:f}=o[l],c=e.mapping.slice(s);e.replaceRange(c.map(a.pos),c.map(f.pos),l?x.empty:t),l==0&&xi(e,s,(n?n.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:o,$to:l}=i[s],a=e.mapping.slice(n),f=a.map(o.pos),c=a.map(l.pos);s?e.deleteRange(f,c):(e.replaceRangeWith(f,c,t),xi(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let i=e.parent.inlineContent?new M(e):tt(e.node(0),e.parent,e.pos,e.index(),t,n);if(i)return i;for(let s=e.depth-1;s>=0;s--){let o=t<0?tt(e.node(0),e.node(s),e.before(s+1),e.index(s),t,n):tt(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,n);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new j(e.node(0))}static atStart(e){return tt(e,e,0,0,1)||new j(e)}static atEnd(e){return tt(e,e,e.content.size,e.childCount,-1)||new j(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=Tn[t.type];if(!n)throw new RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in Tn)throw new RangeError("Duplicate use of selection JSON ID "+e);return Tn[e]=t,t.prototype.jsonID=e,t}getBookmark(){return M.between(this.$anchor,this.$head).getBookmark()}};C.prototype.visible=!0;var Pe=class{constructor(e,t){this.$from=e,this.$to=t}},gi=!1;function yi(r){!gi&&!r.parent.inlineContent&&(gi=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+r.parent.type.name+")"))}var M=class r extends C{constructor(e,t=e){yi(e),yi(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let n=e.resolve(t.map(this.head));if(!n.parent.inlineContent)return C.near(n);let i=e.resolve(t.map(this.anchor));return new r(i.parent.inlineContent?i:n,n)}replace(e,t=x.empty){if(super.replace(e,t),t==x.empty){let n=this.$from.marksAcross(this.$to);n&&e.ensureMarks(n)}}eq(e){return e instanceof r&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new $t(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new r(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){let i=e.resolve(t);return new this(i,n==t?i:e.resolve(n))}static between(e,t,n){let i=e.pos-t.pos;if((!n||i)&&(n=i>=0?1:-1),!t.parent.inlineContent){let s=C.findFrom(t,n,!0)||C.findFrom(t,-n,!0);if(s)t=s.$head;else return C.near(t,n)}return e.parent.inlineContent||(i==0?e=t:(e=(C.findFrom(e,-n,!0)||C.findFrom(e,n,!0)).$anchor,e.pos<t.pos!=i<0&&(e=t))),new r(e,t)}};C.jsonID("text",M);var $t=class r{constructor(e,t){this.anchor=e,this.head=t}map(e){return new r(e.map(this.anchor),e.map(this.head))}resolve(e){return M.between(e.resolve(this.anchor),e.resolve(this.head))}},k=class r extends C{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(e,t){let{deleted:n,pos:i}=t.mapResult(this.anchor),s=e.resolve(i);return n?C.near(s):new r(s)}content(){return new x(y.from(this.node),0,0)}eq(e){return e instanceof r&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new An(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new r(e.resolve(t.anchor))}static create(e,t){return new r(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}};k.prototype.visible=!1;C.jsonID("node",k);var An=class r{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new $t(n,n):new r(n)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&k.isSelectable(n)?new k(t):C.near(t)}},j=class r extends C{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=x.empty){if(t==x.empty){e.delete(0,e.doc.content.size);let n=C.atStart(e.doc);n.eq(e.selection)||e.setSelection(n)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new r(e)}map(e){return new r(e)}eq(e){return e instanceof r}getBookmark(){return ol}};C.jsonID("all",j);var ol={map(){return this},resolve(r){return new j(r)}};function tt(r,e,t,n,i,s=!1){if(e.inlineContent)return M.create(r,t);for(let o=n-(i>0?0:1);i>0?o<e.childCount:o>=0;o+=i){let l=e.child(o);if(l.isAtom){if(!s&&k.isSelectable(l))return k.create(r,t-(i<0?l.nodeSize:0))}else{let a=tt(r,l,t+i,i<0?l.childCount:0,i,s);if(a)return a}t+=l.nodeSize*i}return null}function xi(r,e,t){let n=r.steps.length-1;if(n<e)return;let i=r.steps[n];if(!(i instanceof V||i instanceof U))return;let s=r.mapping.maps[n],o;s.forEach((l,a,f,c)=>{o==null&&(o=c)}),r.setSelection(C.near(r.doc.resolve(o),t))}var bi=1,Kt=2,Si=4,Ht=class extends xt{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|bi)&~Kt,this.storedMarks=null,this}get selectionSet(){return(this.updated&bi)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Kt,this}ensureMarks(e){return w.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&Kt)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~Kt,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||w.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let i=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(n==null&&(n=t),!e)return this.deleteRange(t,n);let s=this.storedMarks;if(!s){let o=this.doc.resolve(t);s=n==t?o.marks():o.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,i.text(e,s)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(C.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=Si,this}get scrolledIntoView(){return(this.updated&Si)>0}};function ki(r,e){return!e||!r?r:r.bind(e)}var Re=class{constructor(e,t,n){this.name=e,this.init=ki(t.init,n),this.apply=ki(t.apply,n)}},ll=[new Re("doc",{init(r){return r.doc||r.schema.topNodeType.createAndFill()},apply(r){return r.doc}}),new Re("selection",{init(r,e){return r.selection||C.atStart(e.doc)},apply(r){return r.selection}}),new Re("storedMarks",{init(r){return r.storedMarks||null},apply(r,e,t,n){return n.selection.$cursor?r.storedMarks:null}}),new Re("scrollToSelection",{init(){return 0},apply(r,e){return r.scrolledIntoView?e+1:e}})],kt=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=ll.slice(),t&&t.forEach(n=>{if(this.pluginsByKey[n.key])throw new RangeError("Adding different instances of a keyed plugin ("+n.key+")");this.plugins.push(n),this.pluginsByKey[n.key]=n,n.spec.state&&this.fields.push(new Re(n.key,n.spec.state,n))})}},In=class r{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=t){let i=this.config.plugins[n];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),i=null;for(;;){let s=!1;for(let o=0;o<this.config.plugins.length;o++){let l=this.config.plugins[o];if(l.spec.appendTransaction){let a=i?i[o].n:0,f=i?i[o].state:this,c=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,f,n);if(c&&n.filterTransaction(c,o)){if(c.setMeta("appendedTransaction",e),!i){i=[];for(let h=0;h<this.config.plugins.length;h++)i.push(h<o?{state:n,n:t.length}:{state:this,n:0})}t.push(c),n=n.applyInner(c),s=!0}i&&(i[o]={state:n,n:t.length})}}if(!s)return{state:n,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new r(this.config),n=this.config.fields;for(let i=0;i<n.length;i++){let s=n[i];t[s.name]=s.apply(e,this[s.name],this,t)}return t}get tr(){return new Ht(this)}static create(e){let t=new kt(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new r(t);for(let i=0;i<t.fields.length;i++)n[t.fields[i].name]=t.fields[i].init(e,n);return n}reconfigure(e){let t=new kt(this.schema,e.plugins),n=t.fields,i=new r(t);for(let s=0;s<n.length;s++){let o=n[s].name;i[o]=this.hasOwnProperty(o)?this[o]:n[s].init(e,i)}return i}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(n=>n.toJSON())),e&&typeof e=="object")for(let n in e){if(n=="doc"||n=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[n],s=i.spec.state;s&&s.toJSON&&(t[n]=s.toJSON.call(i,this[i.key]))}return t}static fromJSON(e,t,n){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new kt(e.schema,e.plugins),s=new r(i);return i.fields.forEach(o=>{if(o.name=="doc")s.doc=Z.fromJSON(e.schema,t.doc);else if(o.name=="selection")s.selection=C.fromJSON(s.doc,t.selection);else if(o.name=="storedMarks")t.storedMarks&&(s.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(n)for(let l in n){let a=n[l],f=a.spec.state;if(a.key==o.name&&f&&f.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){s[o.name]=f.fromJSON.call(a,e,t[l],s);return}}s[o.name]=o.init(e,s)}}),s}};function Ci(r,e,t){for(let n in r){let i=r[n];i instanceof Function?i=i.bind(e):n=="handleDOMEvents"&&(i=Ci(i,e,{})),t[n]=i}return t}var Y=class{constructor(e){this.spec=e,this.props={},e.props&&Ci(e.props,this,this.props),this.key=e.key?e.key.key:Mi("plugin")}getState(e){return e[this.key]}},En=Object.create(null);function Mi(r){return r in En?r+"$"+ ++En[r]:(En[r]=0,r+"$")}var nt=class{constructor(e="key"){this.key=Mi(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}};var Ps={};ie(Ps,{Decoration:()=>te,DecorationSet:()=>q,EditorView:()=>tn,__endComposition:()=>Fa,__parseFromClipboard:()=>za});var P=function(r){for(var e=0;;e++)if(r=r.previousSibling,!r)return e},ot=function(r){let e=r.assignedSlot||r.parentNode;return e&&e.nodeType==11?e.host:e},Fn=null,pe=function(r,e,t){let n=Fn||(Fn=document.createRange());return n.setEnd(r,t??r.nodeValue.length),n.setStart(r,e||0),n},al=function(){Fn=null},Je=function(r,e,t,n){return t&&(wi(r,e,t,n,-1)||wi(r,e,t,n,1))},fl=/^(img|br|input|textarea|hr)$/i;function wi(r,e,t,n,i){for(var s;;){if(r==t&&e==n)return!0;if(e==(i<0?0:W(r))){let o=r.parentNode;if(!o||!S(o)||At(r)||fl.test(r.nodeName)||r.contentEditable=="false")return!1;e=P(r)+(i<0?0:1),r=o}else if(S(r)){let o=r.childNodes[e+(i<0?-1:0)];if(S(o)&&o.contentEditable=="false")if(!((s=o.pmViewDesc)===null||s===void 0)&&s.ignoreForSelection)e+=i;else return!1;else r=o,e=i<0?W(r):0}else return!1}}function W(r){return r.nodeType==3?r.nodeValue.length:r.childNodes.length}function S(r){return r.nodeType==1}function A(r){return r.nodeType==3}function qe(r,e){return e?r.contains(S(e)?e:e.parentNode):!1}function cl(r,e){for(;;){if(A(r)&&e)return r;if(S(r)&&e>0){if(r.contentEditable=="false")return null;r=r.childNodes[e-1],e=W(r)}else if(r.parentNode&&!At(r))e=P(r),r=r.parentNode;else return null}}function hl(r,e){for(;;){if(A(r)&&e<r.nodeValue.length)return r;if(S(r)&&e<r.childNodes.length){if(r.contentEditable=="false")return null;r=r.childNodes[e],e=0}else if(r.parentNode&&!At(r))e=P(r)+1,r=r.parentNode;else return null}}function ul(r,e,t){for(let n=e==0,i=e==W(r);n||i;){if(r==t)return!0;let s=P(r);if(r=r.parentNode,!r)return!1;n=n&&s==0,i=i&&s==W(r)}}function At(r){let e;for(let t=r;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==r||e.contentDOM==r)}var nn=function(r){return r.focusNode&&Je(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)};function Be(r,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=r,t.key=t.code=e,t}function dl(r){let e=r.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function pl(r,e,t){if(r.caretPositionFromPoint)try{let n=r.caretPositionFromPoint(e,t);if(n)return{node:n.offsetNode,offset:Math.min(W(n.offsetNode),n.offset)}}catch{}if(r.caretRangeFromPoint){let n=r.caretRangeFromPoint(e,t);if(n)return{node:n.startContainer,offset:Math.min(W(n.startContainer),n.startOffset)}}}var oe=typeof navigator<"u"?navigator:null,Ni=typeof document<"u"?document:null,Ne=oe&&oe.userAgent||"",vn=/Edge\/(\d+)/.exec(Ne),ts=/MSIE \d/.exec(Ne),Vn=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ne),G=!!(ts||Vn||vn),Oe=ts?document.documentMode:Vn?+Vn[1]:vn?+vn[1]:0,X=!G&&/gecko\/(\d+)/i.test(Ne);X&&+(/Firefox\/(\d+)/.exec(Ne)||[0,0])[1];var Ln=!G&&/Chrome\/(\d+)/.exec(Ne),B=!!Ln,ns=Ln?+Ln[1]:0,J=!G&&!!oe&&/Apple Computer/.test(oe.vendor),lt=J&&(/Mobile\/\w+/.test(Ne)||!!oe&&oe.maxTouchPoints>2),Q=lt||(oe?/Mac/.test(oe.platform):!1),rs=oe?/Win/.test(oe.platform):!1,me=/Android \d/.test(Ne),rn=!!Ni&&"webkitFontSmoothing"in Ni.documentElement.style,ml=rn?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function gl(r){let e=r.defaultView&&r.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:r.documentElement.clientWidth,top:0,bottom:r.documentElement.clientHeight}}function de(r,e){return typeof r=="number"?r:r[e]}function yl(r){let e=r.getBoundingClientRect(),t=e.width/r.offsetWidth||1,n=e.height/r.offsetHeight||1;return{left:e.left,right:e.left+r.clientWidth*t,top:e.top,bottom:e.top+r.clientHeight*n}}function Di(r,e,t){if(!Wn(e)&&e.left==0)return;let n=r.someProp("scrollThreshold")||0,i=r.someProp("scrollMargin")||5,s=r.dom.ownerDocument;for(let o=t||r.dom;o;){if(!S(o)){o=ot(o);continue}let l=o==s.body,a=l?gl(s):yl(o),f=0,c=0;if(e.top<a.top+de(n,"top")?c=-(a.top-e.top+de(i,"top")):e.bottom>a.bottom-de(n,"bottom")&&(c=e.bottom-e.top>a.bottom-a.top?e.top+de(i,"top")-a.top:e.bottom-a.bottom+de(i,"bottom")),e.left<a.left+de(n,"left")?f=-(a.left-e.left+de(i,"left")):e.right>a.right-de(n,"right")&&(f=e.right-a.right+de(i,"right")),f||c)if(l)s.defaultView.scrollBy(f,c);else{let u=o.scrollLeft,d=o.scrollTop;c&&(o.scrollTop+=c),f&&(o.scrollLeft+=f);let p=o.scrollLeft-u,m=o.scrollTop-d;e={left:e.left-p,top:e.top-m,right:e.right-p,bottom:e.bottom-m}}let h=l?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(h))break;o=h=="absolute"?o.offsetParent:ot(o)}}function xl(r){let e=r.dom.getBoundingClientRect(),t=Math.max(0,e.top),n,i;for(let s=(e.left+e.right)/2,o=t+1;o<Math.min(innerHeight,e.bottom);o+=5){let l=r.root.elementFromPoint(s,o);if(!l||l==r.dom||!r.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){n=l,i=a.top;break}}return{refDOM:n,refTop:i,stack:is(r.dom)}}function is(r){let e=[],t=r.ownerDocument;for(let n=r;n&&(e.push({dom:n,top:n.scrollTop,left:n.scrollLeft}),r!=t);n=ot(n));return e}function bl({refDOM:r,refTop:e,stack:t}){let n=r?r.getBoundingClientRect().top:0;ss(t,n==0?0:n-e)}function ss(r,e){for(let t=0;t<r.length;t++){let{dom:n,top:i,left:s}=r[t];n.scrollTop!=i+e&&(n.scrollTop=i+e),n.scrollLeft!=s&&(n.scrollLeft=s)}}var rt=null;function Sl(r){if(r.setActive)return r.setActive();if(rt)return r.focus(rt);let e=is(r);r.focus(rt==null?{get preventScroll(){return rt={preventScroll:!0},!0}}:void 0),rt||(rt=!1,ss(e,0))}function ls(r,e){let t,n=2e8,i,s=0,o=e.top,l=e.top,a,f;for(let c=r.firstChild,h=0;c;c=c.nextSibling,h++){let u;if(S(c))u=c.getClientRects();else if(A(c))u=pe(c).getClientRects();else continue;for(let d=0;d<u.length;d++){let p=u[d];if(p.top<=o&&p.bottom>=l){o=Math.max(p.bottom,o),l=Math.min(p.top,l);let m=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(m<n){t=c,n=m,i=m&&A(t)?{left:p.right<e.left?p.right:p.left,top:e.top}:e,S(c)&&m&&(s=h+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=c,f={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!t&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(s=h+1)}}return!t&&a&&(t=a,i=f,n=0),t&&A(t)?kl(t,i):!t||n?{node:r,offset:s}:ls(t,i)}function kl(r,e){let t=r.nodeValue.length,n=document.createRange(),i;for(let s=0;s<t;s++){n.setEnd(r,s+1),n.setStart(r,s);let o=Ce(n,1);if(o.top!=o.bottom&&nr(e,o)){i={node:r,offset:s+(e.left>=(o.left+o.right)/2?1:0)};break}}return n.detach(),i||{node:r,offset:0}}function nr(r,e){return r.left>=e.left-1&&r.left<=e.right+1&&r.top>=e.top-1&&r.top<=e.bottom+1}function Cl(r,e){let t=r.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<r.getBoundingClientRect().left?t:r}function Ml(r,e,t){let{node:n,offset:i}=ls(e,t),s=-1;if(S(n)&&!n.firstChild){let o=n.getBoundingClientRect();s=o.left!=o.right&&t.left>(o.left+o.right)/2?1:-1}return r.docView.posFromDOM(n,i,s)}function Ol(r,e,t,n){let i=-1;for(let s=e,o=!1;s!=r.dom;){let l=r.docView.nearestDesc(s,!0),a;if(!l)return null;if(S(l.dom)&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!o&&a.left>n.left||a.top>n.top?i=l.posBefore:(!o&&a.right<n.left||a.bottom<n.top)&&(i=l.posAfter),o=!0),!l.contentDOM&&i<0&&!l.node.isText))return(l.node.isBlock?n.top<(a.top+a.bottom)/2:n.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;s=l.dom.parentNode}return i>-1?i:r.docView.posFromDOM(e,t,-1)}function as(r,e,t){let n=r.childNodes.length;if(n&&t.top<t.bottom)for(let i=Math.max(0,Math.min(n-1,Math.floor(n*(e.top-t.top)/(t.bottom-t.top))-2)),s=i;;){let o=r.childNodes[s];if(S(o)){let l=o.getClientRects();for(let a=0;a<l.length;a++){let f=l[a];if(nr(e,f))return as(o,e,f)}}if((s=(s+1)%n)==i)break}return r}function wl(r,e){let t=r.dom.ownerDocument,n,i=0,s=pl(t,e.left,e.top);s&&({node:n,offset:i}=s);let o=(r.root.elementFromPoint?r.root:t).elementFromPoint(e.left,e.top),l;if(!o||!r.dom.contains(o)){let f=r.dom.getBoundingClientRect();if(!nr(e,f)||(o=as(r.dom,e,f),!o))return null}if(J)for(let f=o;n&&f;f=ot(f))f.draggable&&(n=void 0);if(o=Cl(o,e),n){if(X&&S(n)&&(i=Math.min(i,n.childNodes.length),i<n.childNodes.length)){let c=n.childNodes[i],h;c.nodeName=="IMG"&&(h=c.getBoundingClientRect()).right<=e.left&&h.bottom>e.top&&i++}let f;rn&&i&&S(n)&&S(f=n.childNodes[i-1])&&f.contentEditable=="false"&&f.getBoundingClientRect().top>=e.top&&i--,n==r.dom&&i==n.childNodes.length-1&&S(n.lastChild)&&e.top>n.lastChild.getBoundingClientRect().bottom?l=r.state.doc.content.size:(i==0||!S(n)||n.childNodes[i-1].nodeName!="BR")&&(l=Ol(r,n,i,e))}l==null&&(l=Ml(r,o,e));let a=r.docView.nearestDesc(o,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Wn(r){return r.top<r.bottom||r.left<r.right}function Ce(r,e){let t=r.getClientRects();if(t.length){let n=t[e<0?0:t.length-1];if(Wn(n))return n}return Array.prototype.find.call(t,Wn)||r.getBoundingClientRect()}var Nl=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function fs(r,e,t){let{node:n,offset:i,atom:s}=r.docView.domFromPos(e,t<0?-1:1),o=rn||X;if(A(n))if(o&&(Nl.test(n.nodeValue)||(t<0?!i:i==n.nodeValue.length))){let a=Ce(pe(n,i,i),t);if(X&&i&&/\s/.test(n.nodeValue[i-1])&&i<n.nodeValue.length){let f=Ce(pe(n,i-1,i-1),-1);if(f.top==a.top){let c=Ce(pe(n,i,i+1),-1);if(c.top!=a.top)return Ct(c,c.left<f.left)}}return a}else{let a=i,f=i,c=t<0?1:-1;return t<0&&!i?(f++,c=-1):t>=0&&i==n.nodeValue.length?(a--,c=1):t<0?a--:f++,Ct(Ce(pe(n,a,f),c),c<0)}if(!r.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&i&&(t<0||i==W(n))){let a=n.childNodes[i-1];if(S(a))return Rn(a.getBoundingClientRect(),!1)}if(s==null&&i<W(n)){let a=n.childNodes[i];if(S(a))return Rn(a.getBoundingClientRect(),!0)}return Rn(n.getBoundingClientRect(),t>=0)}if(s==null&&i&&(t<0||i==W(n))){let a=n.childNodes[i-1],f=A(a)?pe(a,W(a)-(o?0:1)):S(a)&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(f)return Ct(Ce(f,1),!1)}if(s==null&&i<W(n)){let a=n.childNodes[i];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let f=a?A(a)?pe(a,0,o?0:1):S(a)?a:null:null;if(f)return Ct(Ce(f,-1),!0)}return Ct(Ce(A(n)?pe(n):n,-t),t>=0)}function Ct(r,e){if(r.width==0)return r;let t=e?r.left:r.right;return{top:r.top,bottom:r.bottom,left:t,right:t}}function Rn(r,e){if(r.height==0)return r;let t=e?r.top:r.bottom;return{top:t,bottom:t,left:r.left,right:r.right}}function cs(r,e,t){let n=r.state,i=r.root.activeElement;n!=e&&r.updateState(e),i!=r.dom&&r.focus();try{return t()}finally{n!=e&&r.updateState(n),i!=r.dom&&i&&i.focus()}}function Dl(r,e,t){let n=e.selection,i=t=="up"?n.$from:n.$to;return cs(r,e,()=>{let{node:s}=r.docView.domFromPos(i.pos,t=="up"?-1:1);for(;;){let l=r.docView.nearestDesc(s,!0);if(!l)break;if(l.node.isBlock){s=l.contentDOM||l.dom;break}s=l.dom.parentNode}let o=fs(r,i.pos,1);for(let l=s.firstChild;l;l=l.nextSibling){let a;if(S(l))a=l.getClientRects();else if(A(l))a=pe(l,0,l.nodeValue.length).getClientRects();else continue;for(let f=0;f<a.length;f++){let c=a[f];if(c.bottom>c.top+1&&(t=="up"?o.top-c.top>(c.bottom-o.top)*2:c.bottom-o.bottom>(o.bottom-c.top)*2))return!1}}return!0})}var Tl=/[\u0590-\u08ac]/;function El(r,e,t){let{$head:n}=e.selection;if(!n.parent.isTextblock)return!1;let i=n.parentOffset,s=!i,o=i==n.parent.content.size,l=r.domSelection();return l?!Tl.test(n.parent.textContent)||!l.modify?t=="left"||t=="backward"?s:o:cs(r,e,()=>{let{focusNode:a,focusOffset:f,anchorNode:c,anchorOffset:h}=r.domSelectionRange(),u=l.caretBidiLevel;l.modify("move",t,"character");let d=n.depth?r.docView.domAfterPos(n.before()):r.dom,{focusNode:p,focusOffset:m}=r.domSelectionRange(),g=p&&!qe(d,p)||a==p&&f==m;try{l.collapse(c,h),a&&(a!=c||f!=h)&&l.extend&&l.extend(a,f)}catch{}return u!=null&&(l.caretBidiLevel=u),g}):n.pos==n.start()||n.pos==n.end()}var Ti=null,Ei=null,Ai=!1;function Al(r,e,t){return Ti==e&&Ei==t?Ai:(Ti=e,Ei=t,Ai=t=="up"||t=="down"?Dl(r,e,t):El(r,e,t))}var _=0,Ii=1,ze=2,ee=3,Ke=class{constructor(e,t,n,i){this.parent=e,this.children=t,this.dom=n,this.contentDOM=i,this.dirty=_,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(e){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,n=this.posAtStart;;t++){let i=this.children[t];if(i==e)return n;n+=i.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(e,t,n){if(this.contentDOM&&qe(this.contentDOM,e))if(n<0){let s,o;if(e==this.contentDOM)s=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.previousSibling}for(;s&&!((o=s.pmViewDesc)&&o.parent==this);)s=s.previousSibling;return s?this.posBeforeChild(o)+o.size:this.posAtStart}else{let s,o;if(e==this.contentDOM)s=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.nextSibling}for(;s&&!((o=s.pmViewDesc)&&o.parent==this);)s=s.nextSibling;return s?this.posBeforeChild(o):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=t>P(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=!!(e.compareDocumentPosition(this.contentDOM)&4);else if(this.dom.firstChild){if(t==0)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!1;break}if(s.previousSibling)break}if(i==null&&t==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!0;break}if(s.nextSibling)break}}return i??n>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,i=e;i;i=i.parentNode){let s=this.getDesc(i),o;if(s&&(!t||s.node))if(n&&(o=s.nodeDOM)&&!(S(o)?qe(o,e):o==e))n=!1;else return s}}getDesc(e){let t=e.pmViewDesc;for(let n=t;n;n=n.parent)if(n==this)return t}posFromDOM(e,t,n){for(let i=e;i;i=i.parentNode){let s=this.getDesc(i);if(s)return s.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let i=this.children[t],s=n+i.size;if(n==e&&s!=n){for(;!i.border&&i.children.length;)for(let o=0;o<i.children.length;o++){let l=i.children[o];if(l.size){i=l;break}}return i}if(e<s)return i.descAt(e-n-i.border);n=s}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,i=0;for(let s=0;n<this.children.length;n++){let o=this.children[n],l=s+o.size;if(l>e){i=e-s;break}s=l}if(i)return this.children[n].domFromPos(i-this.children[n].border,t);for(;n>0;n--){let s=this.children[n-1];if(s.size||!(s instanceof Gt||s instanceof Ut&&s.side>=0))break}if(t<=0){let s,o=!0;for(;s=n?this.children[n-1]:null,!(!s||s.dom.parentNode==this.contentDOM);n--,o=!1);return s&&t&&o&&!s.border&&!s.domAtom?s.domFromPos(s.size,t):{node:this.contentDOM,offset:s?P(s.dom)+1:0}}else{let s,o=!0;for(;s=n<this.children.length?this.children[n]:null,!(!s||s.dom.parentNode==this.contentDOM);n++,o=!1);return s&&o&&!s.border&&!s.domAtom?s.domFromPos(0,t):{node:this.contentDOM,offset:s?P(s.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,s=-1;for(let o=n,l=0;;l++){let a=this.children[l],f=o+a.size;if(i==-1&&e<=f){let c=o+a.border;if(e>=c&&t<=f-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,c);e=o;for(let h=l;h>0;h--){let u=this.children[h-1];if(u.size&&u.dom.parentNode==this.contentDOM&&!u.emptyChildAt(1)){i=P(u.dom)+1;break}e-=u.size}i==-1&&(i=0)}if(i>-1&&(f>t||l==this.children.length-1)){t=f;for(let c=l+1;c<this.children.length;c++){let h=this.children[c];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(-1)){s=P(h.dom);break}t+=h.size}s==-1&&(s=this.contentDOM.childNodes.length);break}o=f}return{node:this.contentDOM,from:e,to:t,fromOffset:i,toOffset:s}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:n}=this.domFromPos(e,0);if(!S(t)||n==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[n]}setSelection(e,t,n,i=!1){let s=Math.min(e,t),o=Math.max(e,t);for(let d=0,p=0;d<this.children.length;d++){let m=this.children[d],g=p+m.size;if(s>p&&o<g)return m.setSelection(e-p-m.border,t-p-m.border,n,i);p=g}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),f=n.root.getSelection(),c=n.domSelectionRange(),h=!1;if((X||J)&&e==t){let{node:d,offset:p}=l;if(A(d)){if(h=!!(p&&d.nodeValue[p-1]==`
8
+ `),h&&p==d.nodeValue.length)for(let m=d,g;m;m=m.parentNode){if(g=m.nextSibling){g.nodeName=="BR"&&(l=a={node:g.parentNode,offset:P(g)+1});break}let b=m.pmViewDesc;if(b&&b.node&&b.node.isBlock)break}}else{let m=d.childNodes[p-1];h=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(X&&c.focusNode&&c.focusNode!=a.node&&S(c.focusNode)){let d=c.focusNode.childNodes[c.focusOffset];d&&d.contentEditable=="false"&&(i=!0)}if(!(i||h&&J)&&Je(l.node,l.offset,c.anchorNode,c.anchorOffset)&&Je(a.node,a.offset,c.focusNode,c.focusOffset))return;let u=!1;if((f.extend||e==t)&&!(h&&X)){f.collapse(l.node,l.offset);try{e!=t&&f.extend(a.node,a.offset),u=!0}catch{}}if(!u){if(e>t){let p=l;l=a,a=p}let d=document.createRange();d.setEnd(a.node,a.offset),d.setStart(l.node,l.offset),f.removeAllRanges(),f.addRange(d)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,i=0;i<this.children.length;i++){let s=this.children[i],o=n+s.size;if(n==o?e<=o&&t>=n:e<o&&t>n){let l=n+s.border,a=o-s.border;if(e>=l&&t<=a){this.dirty=e==n||t==o?ze:Ii,e==l&&t==a&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=ee:s.markDirty(e-l,t-l);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?ze:ee}n=o}this.dirty=ze}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=e==1?ze:Ii;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},Ut=class extends Ke{constructor(e,t,n,i){let s,o=t.type.toDOM;if(typeof o=="function"&&(o=o(n,()=>{if(!s)return i;if(s.parent)return s.parent.posBeforeChild(s)})),!t.type.spec.raw){let l=S(o)?o:document.createElement("span");l!=o&&l.appendChild(o),l.hasAttribute("contenteditable")||(l.contentEditable="false"),l.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=t,this.widget=t,s=this}matchesWidget(e){return this.dirty==_&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}},Jn=class extends Ke{constructor(e,t,n,i){super(e,[],t,null),this.textDOM=n,this.text=i}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}},ve=class r extends Ke{constructor(e,t,n,i,s){super(e,[],n,i),this.mark=t,this.spec=s}static create(e,t,n,i){let s=i.nodeViews[t.type.name],o=s&&s(t,i,n);return(!o||!o.dom)&&(o=Se.renderSpec(document,t.type.spec.toDOM(t,n),null,t.attrs)),new r(e,t,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&ee||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=ee&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=_){let n=this.parent;for(;!n.node;)n=n.parent;n.dirty<this.dirty&&(n.dirty=this.dirty),this.dirty=_}}slice(e,t,n){let i=r.create(this.parent,this.mark,!0,n),s=this.children,o=this.size;t<o&&(s=Hn(s,t,o,n)),e>0&&(s=Hn(s,0,e,n));for(let l=0;l<s.length;l++)s[l].parent=i;return i.children=s,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},we=class r extends Ke{constructor(e,t,n,i,s,o,l){super(e,[],s,o),this.node=t,this.outerDeco=n,this.innerDeco=i,this.nodeDOM=l}static create(e,t,n,i,s,o){let l=s.nodeViews[t.type.name],a,f=l&&l(t,s,()=>{if(!a)return o;if(a.parent)return a.parent.posBeforeChild(a)},n,i),c=f&&f.dom,h=f&&f.contentDOM;if(t.isText){if(!c)c=document.createTextNode(t.text);else if(!A(c))throw new RangeError("Text must be rendered as a DOM text node")}else c||({dom:c,contentDOM:h}=Se.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!h&&!t.isText&&c.nodeName!="BR"&&(c.hasAttribute("contenteditable")||(c.contentEditable="false"),t.type.spec.draggable&&(c.draggable=!0));let u=c;return c=ds(c,n,t),f?a=new qn(e,t,n,i,c,h||null,u,f):t.isText?new jt(e,t,n,i,c,u):new r(e,t,n,i,c,h||null,u)}parseRule(e){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"),!this.contentDOM)t.getContent=()=>this.node.content;else if(!this.contentLost)t.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let i=this.children[n];if(this.dom.contains(i.dom.parentNode)){t.contentElement=i.dom.parentNode;break}}if(!t.contentElement){let n=e&&e.find(i=>S(i)&&e.indexOf(i.parentNode)<0&&this.dom.contains(i));n?t.contentElement=n:t.getContent=()=>y.empty}}return t}matchesNode(e,t,n){return this.dirty==_&&e.eq(this.node)&&Yt(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let n=this.node.inlineContent,i=t,s=e.composing?this.localCompositionInfo(e,t):null,o=s&&s.pos>-1?s:null,l=s&&s.pos<0,a=new $n(this,o&&o.node,e),f=this.node.inlineContent,c=f&&this.node.isBlock;Bl(this.node,this.innerDeco,(h,u,d)=>{h.spec.marks?a.syncToMarks(h.spec.marks,n,e,u):h.type.side>=0&&!d&&a.syncToMarks(u==this.node.childCount?w.none:this.node.child(u).marks,n,e,u),a.placeWidget(h,e,i)},(h,u,d,p)=>{a.syncToMarks(h.marks,n,e,p),c&&h.isAtom&&!h.isText&&a.addHackNode("IMG",a.top);let m;a.findNodeMatch(h,u,d,p)||l&&e.state.selection.from>i&&e.state.selection.to<i+h.nodeSize&&(m=a.findIndexWithChild(s.node))>-1&&a.updateNodeAt(h,u,d,m,e)||a.updateNextNode(h,u,d,e,p,i)||a.addNode(h,u,d,e,i),i+=h.nodeSize,f&&(c=h.isAtom&&!h.isText)}),a.syncToMarks([],n,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==ze)&&(o&&this.protectLocalComposition(e,o),hs(this.contentDOM,this.children,e),lt&&zl(this.dom))}localCompositionInfo(e,t){let{from:n,to:i}=e.state.selection;if(!(e.state.selection instanceof M)||n<t||i>t+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let o=s.nodeValue,l=Fl(this.node.content,o,n-t,i-t);return l<0?null:{node:s,pos:l,text:o}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:n,text:i}){if(this.getDesc(t))return;let s=t;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let o=new Jn(this,s,t,i);e.input.compositionNodes.push(o),this.children=Hn(this.children,n,n+i.length,e,o)}update(e,t,n,i){return this.dirty==ee||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,n,i),!0)}updateInner(e,t,n,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=_}updateOuterDeco(e){if(Yt(e,this.outerDeco))return;let t=!S(this.nodeDOM),n=this.dom;this.dom=us(this.dom,this.nodeDOM,Kn(this.outerDeco,this.node,t),Kn(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){S(this.nodeDOM)&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){S(this.nodeDOM)&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}};function Ri(r,e,t,n,i){ds(n,e,r);let s=new we(void 0,r,e,t,n,n,n);return s.contentDOM&&s.updateChildren(i,0),s}var jt=class r extends we{constructor(e,t,n,i,s,o){super(e,t,n,i,s,null,o)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,i){return this.dirty==ee||this.dirty!=_&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=_||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=_,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,n){let i=this.node.cut(e,t),s=document.createTextNode(i.text);return new r(this.parent,i,this.outerDeco,this.innerDeco,s,s)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=ee)}get domAtom(){return!1}isText(e){return this.node.text==e}},Gt=class extends Ke{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==_&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},qn=class extends we{constructor(e,t,n,i,s,o,l,a){super(e,t,n,i,s,o,l),this.spec=a}update(e,t,n,i){if(this.dirty==ee)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,t,n);return s&&this.updateInner(e,t,n,i),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,n,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,i){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}};function hs(r,e,t){let n=r.firstChild,i=!1;for(let s=0;s<e.length;s++){let o=e[s],l=o.dom;if(l.parentNode==r){for(;l!=n;)n=Pi(n),i=!0;n=n.nextSibling}else i=!0,r.insertBefore(l,n);if(o instanceof ve){let a=n?n.previousSibling:r.lastChild;hs(o.contentDOM,o.children,t),n=a?a.nextSibling:r.firstChild}}for(;n;)n=Pi(n),i=!0;i&&t.trackWrites==r&&(t.trackWrites=null)}var Ot=function(r){r&&(this.nodeName=r)};Ot.prototype=Object.create(null);var Fe=[new Ot];function Kn(r,e,t){if(r.length==0)return Fe;let n=t?Fe[0]:new Ot,i=[n];for(let s=0;s<r.length;s++){let o=r[s].type.attrs;if(o){o.nodeName&&i.push(n=new Ot(o.nodeName));for(let l in o){let a=o[l];a!=null&&(t&&i.length==1&&i.push(n=new Ot(e.isInline?"span":"div")),l=="class"?n.class=(n.class?n.class+" ":"")+a:l=="style"?n.style=(n.style?n.style+";":"")+a:l!="nodeName"&&(n[l]=a))}}}return i}function us(r,e,t,n){if(t==Fe&&n==Fe)return e;let i=e;for(let s=0;s<n.length;s++){let o=n[s],l=t[s];if(s){let a;l&&l.nodeName==o.nodeName&&i!=r&&(a=i.parentNode)&&a.nodeName.toLowerCase()==o.nodeName||(a=document.createElement(o.nodeName),a.pmIsDeco=!0,a.appendChild(i),l=Fe[0]),i=a}Il(i,l||Fe[0],o)}return i}function Il(r,e,t){for(let n in e)n!="class"&&n!="style"&&n!="nodeName"&&!(n in t)&&r.removeAttribute(n);for(let n in t)n!="class"&&n!="style"&&n!="nodeName"&&t[n]!=e[n]&&r.setAttribute(n,t[n]);if(e.class!=t.class){let n=e.class?e.class.split(" ").filter(Boolean):[],i=t.class?t.class.split(" ").filter(Boolean):[];for(let s=0;s<n.length;s++)i.indexOf(n[s])==-1&&r.classList.remove(n[s]);for(let s=0;s<i.length;s++)n.indexOf(i[s])==-1&&r.classList.add(i[s]);r.classList.length==0&&r.removeAttribute("class")}if(e.style!=t.style){if(e.style){let n=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=n.exec(e.style);)r.style.removeProperty(i[1])}t.style&&(r.style.cssText+=t.style)}}function ds(r,e,t){return us(r,r,Fe,Kn(e,t,!S(r)))}function Yt(r,e){if(r.length!=e.length)return!1;for(let t=0;t<r.length;t++)if(!r[t].type.eq(e[t].type))return!1;return!0}function Pi(r){let e=r.nextSibling;return r.parentNode.removeChild(r),e}var $n=class{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Rl(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n,i){let s=0,o=this.stack.length>>1,l=Math.min(o,e.length);for(;s<l&&(s==o-1?this.top:this.stack[s+1<<1]).matchesMark(e[s])&&e[s].type.spec.spanning!==!1;)s++;for(;s<o;)this.destroyRest(),this.top.dirty=_,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<e.length;){this.stack.push(this.top,this.index+1);let a=-1,f=this.top.children.length;i<this.preMatch.index&&(f=Math.min(this.index+3,f));for(let c=this.index;c<f;c++){let h=this.top.children[c];if(h.matchesMark(e[o])&&!this.isLocked(h.dom)){a=c;break}}if(a<0&&this.index<this.top.children.length){let c=this.top.children[this.index];c instanceof ve&&c.dirty!=ee&&c.mark.type==e[o].type&&c.spec.update&&!this.isLocked(c.dom)&&c.spec.update(e[o])&&(c.mark=e[o],a=this.index,this.changed=!0)}if(a>-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let c=ve.create(this.top,e[o],t,n);this.top.children.splice(this.index,0,c),this.top=c,this.changed=!0}this.index=0,o++}}findNodeMatch(e,t,n,i){let s=-1,o;if(i>=this.preMatch.index&&(o=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,n))s=this.top.children.indexOf(o,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let f=this.top.children[l];if(f.matchesNode(e,t,n)&&!this.preMatch.matched.has(f)){s=l;break}}return s<0?!1:(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,t,n,i,s){let o=this.top.children[i];return o.dirty==ee&&o.dom==o.contentDOM&&(o.dirty=ze),o.update(e,t,n,s)?(this.destroyBetween(this.index,i),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let n=e.pmViewDesc;if(n){for(let i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==n)return i}return-1}e=t}}updateNextNode(e,t,n,i,s,o){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof we){let f=this.preMatch.matched.get(a);if(f!=null&&f!=s)return!1;let c=a.dom,h,u=this.isLocked(c)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=ee&&Yt(t,a.outerDeco));if(!u&&a.update(e,t,n,i))return this.destroyBetween(this.index,l),a.dom!=c&&(this.changed=!0),this.index++,!0;if(!u&&(h=this.recreateWrapper(a,e,t,n,i,o)))return this.destroyBetween(this.index,l),this.top.children[this.index]=h,h.contentDOM&&(h.dirty=ze,h.updateChildren(i,o+1),h.dirty=_),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,i,s,o){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Yt(n,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=we.create(this.top,t,n,i,s,o);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,t,n,i,s){let o=we.create(this.top,e,t,n,i,s);o.contentDOM&&o.updateChildren(i,s+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,t,n){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(e)&&(e==i.widget||!i.widget.type.toDOM.parentNode))this.index++;else{let s=new Ut(this.top,e,t,n);this.top.children.splice(this.index++,0,s),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof ve;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof jt)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((J||B)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let n=document.createElement(e);e=="IMG"&&(n.className="ProseMirror-separator",n.alt=""),e=="BR"&&(n.className="ProseMirror-trailingBreak");let i=new Gt(this.top,[],n,null);t!=this.top?t.children.push(i):t.children.splice(this.index++,0,i),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||S(e)&&e.contains(this.lock.parentNode))}};function Rl(r,e){let t=e,n=t.children.length,i=r.childCount,s=new Map,o=[];e:for(;i>0;){let l;for(;;)if(n){let f=t.children[n-1];if(f instanceof ve)t=f,n=f.children.length;else{l=f,n--;break}}else{if(t==e)break e;n=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=r.child(i-1))break;--i,s.set(l,i),o.push(l)}}return{index:i,matched:s,matches:o.reverse()}}function Pl(r,e){return r.type.side-e.type.side}function Bl(r,e,t,n){let i=e.locals(r),s=0;if(i.length==0){for(let f=0;f<r.childCount;f++){let c=r.child(f);n(c,i,e.forChild(s,c),f),s+=c.nodeSize}return}let o=0,l=[],a=null;for(let f=0;;){let c,h;for(;o<i.length&&i[o].to==s;){let g=i[o++];g.widget&&(c?(h||(h=[c])).push(g):c=g)}if(c)if(h){h.sort(Pl);for(let g=0;g<h.length;g++)t(h[g],f,!!a)}else t(c,f,!!a);let u,d;if(a)d=-1,u=a,a=null;else if(f<r.childCount)d=f,u=r.child(f++);else break;for(let g=0;g<l.length;g++)l[g].to<=s&&l.splice(g--,1);for(;o<i.length&&i[o].from<=s&&i[o].to>s;)l.push(i[o++]);let p=s+u.nodeSize;if(u.isText){let g=p;o<i.length&&i[o].from<g&&(g=i[o].from);for(let b=0;b<l.length;b++)l[b].to<g&&(g=l[b].to);g<p&&(a=u.cut(g-s),u=u.cut(0,g-s),p=g,d=-1)}else for(;o<i.length&&i[o].to<p;)o++;let m=u.isInline&&!u.isLeaf?l.filter(g=>!g.inline):l.slice();n(u,m,e.forChild(s,u),d),s=p}}function zl(r){if(r.nodeName=="UL"||r.nodeName=="OL"){let e=r.style.cssText;r.style.cssText=e+"; list-style: square !important",window.getComputedStyle(r).listStyle,r.style.cssText=e}}function Fl(r,e,t,n){for(let i=0,s=0;i<r.childCount&&s<=n;){let o=r.child(i++),l=s;if(s+=o.nodeSize,!o.isText)continue;let a=o.text;for(;i<r.childCount;){let f=r.child(i++);if(s+=f.nodeSize,!f.isText)break;a+=f.text}if(s>=t){if(s>=n&&a.slice(n-e.length-l,n-l)==e)return n-e.length;let f=l<n?a.lastIndexOf(e,n-l-1):-1;if(f>=0&&f+e.length+l>=t)return l+f;if(t==n&&a.length>=n+e.length-l&&a.slice(n-l,n-l+e.length)==e)return n}}return-1}function Hn(r,e,t,n,i){let s=[];for(let o=0,l=0;o<r.length;o++){let a=r[o],f=l,c=l+=a.size;f>=t||c<=e?s.push(a):(f<e&&s.push(a.slice(0,e-f,n)),i&&(s.push(i),i=void 0),c>t&&s.push(a.slice(t-f,a.size,n)))}return s}function rr(r,e=null){let t=r.domSelectionRange(),n=r.state.doc;if(!t.focusNode)return null;let i=r.docView.nearestDesc(t.focusNode),s=i&&i.size==0,o=r.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(o<0)return null;let l=n.resolve(o),a,f;if(nn(t)){for(a=o;i&&!i.node;)i=i.parent;if(i&&i.node.isAtom&&k.isSelectable(i.node)&&i.parent&&!(i.node.isInline&&ul(t.focusNode,t.focusOffset,i.dom))){let h=i.posBefore;f=new k(o==h?l:n.resolve(h))}else if(X&&e=="key"&&o>r.state.selection.to&&S(t.focusNode)&&t.focusOffset==t.focusNode.childNodes.length&&i&&i.posAtStart>r.state.selection.to)for(let h=t.focusNode;;h=h.parentNode){if(getComputedStyle(h).overflow!="visible"){f=C.findFrom(n.resolve(i.posAtStart),1);break}if(h==i.dom||h.nextSibling||!h.parentNode||!S(h.parentNode))break}}else{if(t instanceof r.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let h=o,u=o;for(let d=0;d<t.rangeCount;d++){let p=t.getRangeAt(d);h=Math.min(h,r.docView.posFromDOM(p.startContainer,p.startOffset,1)),u=Math.max(u,r.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(h<0)return null;[a,o]=u==r.state.selection.anchor?[u,h]:[h,u],l=n.resolve(o)}else a=r.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let c=n.resolve(a);if(!f){let h=e=="pointer"||r.state.selection.head<l.pos&&!s?1:-1;f=ir(r,c,l,h)}return f}function ps(r){return r.editable?r.hasFocus():gs(r)&&document.activeElement&&document.activeElement.contains(r.dom)}function ye(r,e=!1){let t=r.state.selection;if(ms(r,t),!ps(r))return;let n=r.input.mouseDown;if(!e&&B&&n){let i=r.domSelectionRange(),s=r.domObserver.currentSelection;if(i.anchorNode&&s.anchorNode&&Je(i.anchorNode,i.anchorOffset,s.anchorNode,s.anchorOffset)&&n.delaySelUpdate()){r.domObserver.setCurSelection();return}}if(r.domObserver.disconnectSelection(),r.cursorWrapper)Vl(r);else{let{anchor:i,head:s}=t,o,l;Bi&&!(t instanceof M)&&(t.$from.parent.inlineContent||(o=zi(r,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(l=zi(r,t.to))),r.docView.setSelection(i,s,r,e),Bi&&(o&&Fi(o),l&&Fi(l)),t.visible?r.dom.classList.remove("ProseMirror-hideselection"):(r.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&vl(r))}r.domObserver.setCurSelection(),r.domObserver.connectSelection()}var Bi=J||B&&ns<63;function zi(r,e){let{node:t,offset:n}=r.docView.domFromPos(e,0),i=n<t.childNodes.length?t.childNodes[n]:null,s=n?t.childNodes[n-1]:null;if(J&&i&&i.contentEditable=="false")return Pn(i);if((!i||i.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(i)return Pn(i);if(s)return Pn(s)}}function Pn(r){return r.contentEditable="true",J&&r.draggable&&(r.draggable=!1,r.wasDraggable=!0),r}function Fi(r){r.contentEditable="false",r.wasDraggable&&(r.draggable=!0,r.wasDraggable=null)}function vl(r){let e=r.dom.ownerDocument;e.removeEventListener("selectionchange",r.input.hideSelectionGuard);let t=r.domSelectionRange(),n=t.anchorNode,i=t.anchorOffset;e.addEventListener("selectionchange",r.input.hideSelectionGuard=()=>{(t.anchorNode!=n||t.anchorOffset!=i)&&(e.removeEventListener("selectionchange",r.input.hideSelectionGuard),setTimeout(()=>{(!ps(r)||r.state.selection.visible)&&r.dom.classList.remove("ProseMirror-hideselection")},20))})}function Vl(r){let e=r.domSelection();if(!e)return;let t=r.cursorWrapper.dom,n=t.nodeName=="IMG";n?e.collapse(t.parentNode,P(t)+1):e.collapse(t,0),!n&&!r.state.selection.visible&&G&&Oe<=11&&(t.disabled=!0,t.disabled=!1)}function ms(r,e){if(e instanceof k){let t=r.docView.descAt(e.from);t!=r.lastSelectedViewDesc&&(vi(r),t&&t.selectNode(),r.lastSelectedViewDesc=t)}else vi(r)}function vi(r){r.lastSelectedViewDesc&&(r.lastSelectedViewDesc.parent&&r.lastSelectedViewDesc.deselectNode(),r.lastSelectedViewDesc=void 0)}function ir(r,e,t,n){return r.someProp("createSelectionBetween",i=>i(r,e,t))||M.between(e,t,n)}function Vi(r){return r.editable&&!r.hasFocus()?!1:gs(r)}function gs(r){let e=r.domSelectionRange();if(!e.anchorNode)return!1;try{return qe(r.dom,e.anchorNode)&&(r.editable||qe(r.dom,e.focusNode))}catch{return!1}}function Ll(r){let e=r.docView.domFromPos(r.state.selection.anchor,0),t=r.domSelectionRange();return Je(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Un(r,e){let{$anchor:t,$head:n}=r.selection,i=e>0?t.max(n):t.min(n),s=i.parent.inlineContent?i.depth?r.doc.resolve(e>0?i.after():i.before()):null:i;return s&&C.findFrom(s,e)}function Me(r,e){return r.dispatch(r.state.tr.setSelection(e).scrollIntoView()),!0}function Li(r,e,t){let n=r.state.selection;if(n instanceof M)if(t.indexOf("s")>-1){let{$head:i}=n,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let o=r.state.doc.resolve(i.pos+s.nodeSize*(e<0?-1:1));return Me(r,new M(n.$anchor,o))}else if(n.empty){if(r.endOfTextblock(e>0?"forward":"backward")){let i=Un(r.state,e);return i&&i instanceof k?Me(r,i):!1}else if(!(Q&&t.indexOf("m")>-1)){let i=n.$head,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,o;if(!s||s.isText)return!1;let l=e<0?i.pos-s.nodeSize:i.pos;return s.isAtom||(o=r.docView.descAt(l))&&!o.contentDOM?k.isSelectable(s)?Me(r,new k(e<0?r.state.doc.resolve(i.pos-s.nodeSize):i)):Me(r,new M(r.state.doc.resolve(e<0?l:l+s.nodeSize))):!1}}else return!1;else{if(n instanceof k&&n.node.isInline)return Me(r,new M(e>0?n.$to:n.$from));{let i=Un(r.state,e);return i?Me(r,i):!1}}}function wt(r,e){let t=r.pmViewDesc;return t?t.size==0&&(e<0||r.nextSibling||r.nodeName!="BR"):S(r)&&r.contentEditable=="false"}function it(r,e){return e<0?Wl(r):Jl(r)}function Wl(r){let e=r.domSelectionRange(),t=e.focusNode,n=e.focusOffset;if(!t)return;let i,s,o=!1;for(X&&S(t)&&n<W(t)&&wt(t.childNodes[n],-1)&&(o=!0);;)if(n>0){if(!S(t))break;let l=t.childNodes[n-1];if(wt(l,-1))i=t,s=--n;else if(A(l))t=l,n=t.nodeValue.length;else break}else{if(ys(t))break;{let l=t.previousSibling;for(;l&&wt(l,-1);)i=t.parentNode,s=P(l),l=l.previousSibling;if(l)t=l,n=W(t);else{if(t=t.parentNode,t==r.dom)break;n=0}}}o?jn(r,t,n):i&&jn(r,i,s)}function Jl(r){let e=r.domSelectionRange(),t=e.focusNode,n=e.focusOffset;if(!t)return;let i=W(t),s,o;for(;;)if(n<i){if(!S(t))break;let l=t.childNodes[n];if(wt(l,1))s=t,o=++n;else break}else{if(ys(t))break;{let l=t.nextSibling;for(;l&&wt(l,1);)s=l.parentNode,o=P(l)+1,l=l.nextSibling;if(l)t=l,n=0,i=W(t);else{if(t=t.parentNode,t==r.dom)break;n=i=0}}}s&&jn(r,s,o)}function ys(r){let e=r.pmViewDesc;return e&&e.node&&e.node.isBlock}function ql(r,e){for(;r&&e==r.childNodes.length&&!At(r);)e=P(r)+1,r=r.parentNode;for(;r&&e<r.childNodes.length;){let t=r.childNodes[e];if(A(t))return t;if(S(t)&&t.contentEditable=="false")break;r=t,e=0}}function Kl(r,e){for(;r&&!e&&!At(r);)e=P(r),r=r.parentNode;for(;r&&e;){let t=r.childNodes[e-1];if(A(t))return t;if(S(t)&&t.contentEditable=="false")break;r=t,e=r.childNodes.length}}function jn(r,e,t){if(!A(e)){let s,o;(o=ql(e,t))?(e=o,t=0):(s=Kl(e,t))&&(e=s,t=s.nodeValue.length)}let n=r.domSelection();if(!n)return;if(nn(n)){let s=document.createRange();s.setEnd(e,t),s.setStart(e,t),n.removeAllRanges(),n.addRange(s)}else n.extend&&n.extend(e,t);r.domObserver.setCurSelection();let{state:i}=r;setTimeout(()=>{r.state==i&&ye(r)},50)}function Wi(r,e){let t=r.state.doc.resolve(e);if(!(B||rs)&&t.parent.inlineContent){let i=r.coordsAtPos(e);if(e>t.start()){let s=r.coordsAtPos(e-1),o=(s.top+s.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(s.left-i.left)>1)return s.left<i.left?"ltr":"rtl"}if(e<t.end()){let s=r.coordsAtPos(e+1),o=(s.top+s.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(s.left-i.left)>1)return s.left>i.left?"ltr":"rtl"}}return getComputedStyle(r.dom).direction=="rtl"?"rtl":"ltr"}function Ji(r,e,t){let n=r.state.selection;if(n instanceof M&&!n.empty||t.indexOf("s")>-1||Q&&t.indexOf("m")>-1)return!1;let{$from:i,$to:s}=n;if(!i.parent.inlineContent||r.endOfTextblock(e<0?"up":"down")){let o=Un(r.state,e);if(o&&o instanceof k)return Me(r,o)}if(!i.parent.inlineContent){let o=e<0?i:s,l=n instanceof j?C.near(o,e):C.findFrom(o,e);return l?Me(r,l):!1}return!1}function qi(r,e){if(!(r.state.selection instanceof M))return!0;let{$head:t,$anchor:n,empty:i}=r.state.selection;if(!t.sameParent(n))return!0;if(!i)return!1;if(r.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(s&&!s.isText){let o=r.state.tr;return e<0?o.delete(t.pos-s.nodeSize,t.pos):o.delete(t.pos,t.pos+s.nodeSize),r.dispatch(o),!0}return!1}function Ki(r,e,t){r.domObserver.stop(),e.contentEditable=t,r.domObserver.start()}function $l(r){if(!J||r.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=r.domSelectionRange();if(e&&S(e)&&t==0&&e.firstChild&&S(e.firstChild)&&e.firstChild.contentEditable=="false"){let n=e.firstChild;Ki(r,n,"true"),setTimeout(()=>Ki(r,n,"false"),20)}return!1}function Hl(r){let e="";return r.ctrlKey&&(e+="c"),r.metaKey&&(e+="m"),r.altKey&&(e+="a"),r.shiftKey&&(e+="s"),e}function Ul(r,e){let t=e.keyCode,n=Hl(e);if(t==8||Q&&t==72&&n=="c")return qi(r,-1)||it(r,-1);if(t==46&&!e.shiftKey||Q&&t==68&&n=="c")return qi(r,1)||it(r,1);if(t==13||t==27)return!0;if(t==37||Q&&t==66&&n=="c"){let i=t==37?Wi(r,r.state.selection.from)=="ltr"?-1:1:-1;return Li(r,i,n)||it(r,i)}else if(t==39||Q&&t==70&&n=="c"){let i=t==39?Wi(r,r.state.selection.from)=="ltr"?1:-1:1;return Li(r,i,n)||it(r,i)}else{if(t==38||Q&&t==80&&n=="c")return Ji(r,-1,n)||it(r,-1);if(t==40||Q&&t==78&&n=="c")return $l(r)||Ji(r,1,n)||it(r,1);if(n==(Q?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function sr(r,e){r.someProp("transformCopied",d=>{e=d(e,r)});let t=[],{content:n,openStart:i,openEnd:s}=e;for(;i>1&&s>1&&n.childCount==1&&n.firstChild.childCount==1;){i--,s--;let d=n.firstChild;t.push(d.type.name,d.attrs!=d.type.defaultAttrs?d.attrs:null),n=d.content}let o=r.someProp("clipboardSerializer")||Se.fromSchema(r.state.schema),l=Cs(),a=l.createElement("div");a.appendChild(o.serializeFragment(n,{document:l}));let f=a.firstChild,c,h=0;for(;f&&S(f)&&(c=ks[f.nodeName.toLowerCase()]);){for(let d=c.length-1;d>=0;d--){let p=l.createElement(c[d]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),h++}f=a.firstChild}f&&S(f)&&f.setAttribute("data-pm-slice",`${i} ${s}${h?` -${h}`:""} ${JSON.stringify(t)}`);let u=r.someProp("clipboardTextSerializer",d=>d(e,r))||e.content.textBetween(0,e.content.size,`
9
+
10
+ `);return{dom:a,text:u,slice:e}}function or(r,e,t,n,i){let s=i.parent.type.spec.code,o,l;if(!t&&!e)return null;let a=!!e&&(n||s||!t);if(a){if(r.someProp("transformPastedText",u=>{e=u(e,s||n,r)}),s)return l=new x(y.from(r.state.schema.text(e.replace(/\r\n?/g,`
11
+ `))),0,0),r.someProp("transformPasted",u=>{l=u(l,r,!0)}),l;let h=r.someProp("clipboardTextParser",u=>u(e,i,n,r));if(h)l=h;else{let u=i.marks(),{schema:d}=r.state,p=Se.fromSchema(d);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=o.appendChild(document.createElement("p"));m&&g.appendChild(p.serializeNode(d.text(m,u)))})}}else r.someProp("transformPastedHTML",h=>{t=h(t,r)}),o=Xl(t),rn&&Ql(o);let f=o&&o.querySelector("[data-pm-slice]"),c=f&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(f.getAttribute("data-pm-slice")||"");if(c&&c[3])for(let h=+c[3];h>0;h--){let u=o.firstChild;for(;u&&!S(u);)u=u.nextSibling;if(!u)break;o=u}if(l||(l=(r.someProp("clipboardParser")||r.someProp("domParser")||je.fromSchema(r.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||c),context:i,ruleFromNode(u){return u.nodeName=="BR"&&!u.nextSibling&&u.parentNode&&!jl.test(u.parentNode.nodeName)?{ignore:!0}:null}})),c)l=_l($i(l,+c[1],+c[2]),c[4]);else if(l=x.maxOpen(Gl(l.content,i),!0),l.openStart||l.openEnd){let h=0,u=0;for(let d=l.content.firstChild;h<l.openStart&&!d.type.spec.isolating;h++,d=d.firstChild);for(let d=l.content.lastChild;u<l.openEnd&&!d.type.spec.isolating;u++,d=d.lastChild);l=$i(l,h,u)}return r.someProp("transformPasted",h=>{l=h(l,r,a)}),l}var jl=/^(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 Gl(r,e){if(r.childCount<2)return r;for(let t=e.depth;t>=0;t--){let i=e.node(t).contentMatchAt(e.index(t)),s,o=[];if(r.forEach(l=>{if(!o)return;let a=i.findWrapping(l.type),f;if(!a)return o=null;if(f=o.length&&s.length&&bs(a,s,l,o[o.length-1],0))o[o.length-1]=f;else{o.length&&(o[o.length-1]=Ss(o[o.length-1],s.length));let c=xs(l,a);o.push(c),i=i.matchType(c.type),s=a}}),o)return y.from(o)}return r}function xs(r,e,t=0){for(let n=e.length-1;n>=t;n--)r=e[n].create(null,y.from(r));return r}function bs(r,e,t,n,i){if(i<r.length&&i<e.length&&r[i]==e[i]){let s=bs(r,e,t,n.lastChild,i+1);if(s)return n.copy(n.content.replaceChild(n.childCount-1,s));if(n.contentMatchAt(n.childCount).matchType(i==r.length-1?t.type:r[i+1]))return n.copy(n.content.append(y.from(xs(t,r,i+1))))}}function Ss(r,e){if(e==0)return r;let t=r.content.replaceChild(r.childCount-1,Ss(r.lastChild,e-1)),n=r.contentMatchAt(r.childCount).fillBefore(y.empty,!0);return r.copy(t.append(n))}function Gn(r,e,t,n,i,s){let o=e<0?r.firstChild:r.lastChild,l=o.content;return r.childCount>1&&(s=0),i<n-1&&(l=Gn(l,e,t,n,i+1,s)),i>=t&&(l=e<0?o.contentMatchAt(0).fillBefore(l,s<=i).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(y.empty,!0))),r.replaceChild(e<0?0:r.childCount-1,o.copy(l))}function $i(r,e,t){return e<r.openStart&&(r=new x(Gn(r.content,-1,e,r.openStart,0,r.openEnd),e,r.openEnd)),t<r.openEnd&&(r=new x(Gn(r.content,1,t,r.openEnd,0,0),r.openStart,t)),r}var ks={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};function Cs(){return document.implementation.createHTMLDocument("title")}var Mt=null;function Yl(r){let e=window.trustedTypes;if(!e)return r;if(!Mt){if(Mt=e.defaultPolicy)try{return Mt.createHTML(r)}catch{}Mt=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})}return Mt.createHTML(r)}function Xl(r){let e=/^(\s*<meta [^>]*>)*/.exec(r);e&&(r=r.slice(e[0].length));let t=Cs(),n=t.body,i=/<([a-z][^>\s]+)/i.exec(r),s;if((s=i&&ks[i[1].toLowerCase()])&&(r=s.map(o=>"<"+o+">").join("")+r+s.map(o=>"</"+o+">").reverse().join("")),n.innerHTML=Yl(r),s)for(let o=0;o<s.length;o++)n=n.querySelector(s[o])||n;for(let o=0;o<t.styleSheets.length;o++){let l=t.styleSheets[o];for(let a=0;a<l.rules.length;a++){let f=l.rules[a];if(f instanceof CSSStyleRule){let c=n.querySelectorAll(f.selectorText);for(let h=0;h<c.length;h++)c[h].style.cssText+=f.style.cssText}}}return n}function Ql(r){let e=r.querySelectorAll(B?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let n=e[t];n.childNodes.length==1&&n.textContent=="\xA0"&&n.parentNode&&n.parentNode.replaceChild(r.ownerDocument.createTextNode(" "),n)}}function _l(r,e){if(!r.size)return r;let t=r.content.firstChild.type.schema,n;try{n=JSON.parse(e)}catch{return r}let{content:i,openStart:s,openEnd:o}=r;for(let l=n.length-2;l>=0;l-=2){let a=t.nodes[n[l]];if(!a||a.hasRequiredAttrs())break;try{i=y.from(a.create(n[l+1],i))}catch{break}s++,o++}return new x(i,s,o)}var K={},$={},Zl={touchstart:!0,touchmove:!0},Yn=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function ea(r){for(let e in K){let t=K[e];r.dom.addEventListener(e,r.input.eventHandlers[e]=n=>{na(r,n)&&!lr(r,n)&&(r.editable||!(n.type in $))&&t(r,n)},Zl[e]?{passive:!0}:void 0)}J&&r.dom.addEventListener("input",()=>null),Xn(r)}function ge(r,e){r.input.lastSelectionOrigin=e,r.input.lastSelectionTime=Date.now()}function ta(r){r.input.mouseDown&&r.input.mouseDown.done(),r.domObserver.stop();for(let e in r.input.eventHandlers)r.dom.removeEventListener(e,r.input.eventHandlers[e]);clearTimeout(r.input.composingTimeout),clearTimeout(r.input.lastIOSEnterFallbackTimeout)}function Xn(r){r.someProp("handleDOMEvents",e=>{for(let t in e)r.input.eventHandlers[t]||r.dom.addEventListener(t,r.input.eventHandlers[t]=n=>lr(r,n))})}function lr(r,e){return r.someProp("handleDOMEvents",t=>{let n=t[e.type];return n?n(r,e)||e.defaultPrevented:!1})}function na(r,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=r.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function ra(r,e){!lr(r,e)&&K[e.type]&&(r.editable||!(e.type in $))&&K[e.type](r,e)}$.keydown=(r,e)=>{let t=e;if(r.input.shiftKey=t.keyCode==16||t.shiftKey,!ws(r)&&(r.input.lastKeyCode=t.keyCode,r.input.lastKeyCodeTime=Date.now(),!(me&&B&&t.keyCode==13)))if(t.keyCode!=229&&r.domObserver.forceFlush(),lt&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let n=Date.now();r.input.lastIOSEnter=n,r.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{r.input.lastIOSEnter==n&&(r.someProp("handleKeyDown",i=>i(r,Be(13,"Enter"))),r.input.lastIOSEnter=0)},200)}else r.someProp("handleKeyDown",n=>n(r,t))||Ul(r,t)?t.preventDefault():ge(r,"key")};$.keyup=(r,e)=>{e.keyCode==16&&(r.input.shiftKey=!1)};$.keypress=(r,e)=>{let t=e;if(ws(r)||!t.charCode||t.ctrlKey&&!t.altKey||Q&&t.metaKey)return;if(r.someProp("handleKeyPress",i=>i(r,t))){t.preventDefault();return}let n=r.state.selection;if(!(n instanceof M)||!n.$from.sameParent(n.$to)){let i=String.fromCharCode(t.charCode),s=()=>r.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!r.someProp("handleTextInput",o=>o(r,n.$from.pos,n.$to.pos,i,s))&&r.dispatch(s()),t.preventDefault()}};function It(r){return{left:r.clientX,top:r.clientY}}function ia(r,e){let t=e.x-r.clientX,n=e.y-r.clientY;return t*t+n*n<100}function ar(r,e,t,n,i){if(n==-1)return!1;let s=r.state.doc.resolve(n);for(let o=s.depth+1;o>0;o--)if(r.someProp(e,l=>o>s.depth?l(r,t,s.nodeAfter,s.before(o),i,!0):l(r,t,s.node(o),s.before(o),i,!1)))return!0;return!1}function Rt(r,e,t){if(r.focused||r.focus(),r.state.selection.eq(e))return;let n=r.state.tr.setSelection(e);n.setMeta("pointer",!0),r.dispatch(n)}function sa(r,e){if(e==-1)return!1;let t=r.state.doc.resolve(e),n=t.nodeAfter;return n&&n.isAtom&&k.isSelectable(n)?(Rt(r,new k(t)),!0):!1}function oa(r,e){if(e==-1)return!1;let t=r.state.selection,n,i;t instanceof k&&(n=t.node);let s=r.state.doc.resolve(e);for(let o=s.depth+1;o>0;o--){let l=o>s.depth?s.nodeAfter:s.node(o);if(k.isSelectable(l)){n&&t.$from.depth>0&&o>=t.$from.depth&&s.before(t.$from.depth+1)==t.$from.pos?i=s.before(t.$from.depth):i=s.before(o);break}}return i!=null?(Rt(r,k.create(r.state.doc,i)),!0):!1}function la(r,e,t,n,i){return ar(r,"handleClickOn",e,t,n)||r.someProp("handleClick",s=>s(r,e,n))||(i?oa(r,t):sa(r,t))}function aa(r,e,t,n){return ar(r,"handleDoubleClickOn",e,t,n)||r.someProp("handleDoubleClick",i=>i(r,e,n))}function fa(r,e,t,n){return ar(r,"handleTripleClickOn",e,t,n)||r.someProp("handleTripleClick",i=>i(r,e,n))||ca(r,t,n)}function ca(r,e,t){if(t.button!=0)return!1;let n=Ms(r,e,!0),i=r.state.doc;return n?(Rt(r,n),n instanceof M&&i.eq(r.state.doc)&&(r.input.mouseDown=new _n(r,n)),!0):!1}function Ms(r,e,t){let n=r.state.doc;if(e==-1)return n.inlineContent?M.create(n,0,n.content.size):null;let i=n.resolve(e);for(let s=i.depth+1;s>0;s--){let o=s>i.depth?i.nodeAfter:i.node(s),l=i.before(s);if(o.inlineContent)return M.create(n,l+1,l+1+o.content.size);if(t&&k.isSelectable(o))return k.create(n,l)}return null}function fr(r){return Nt(r)}var Os=Q?"metaKey":"ctrlKey";K.mousedown=(r,e)=>{let t=e;r.input.shiftKey=t.shiftKey;let n=fr(r),i=Date.now(),s="singleClick";i-r.input.lastClick.time<500&&ia(t,r.input.lastClick)&&!t[Os]&&r.input.lastClick.button==t.button&&(r.input.lastClick.type=="singleClick"?s="doubleClick":r.input.lastClick.type=="doubleClick"&&(s="tripleClick")),r.input.lastClick={time:i,x:t.clientX,y:t.clientY,type:s,button:t.button},r.input.mouseDown&&r.input.mouseDown.done();let o=r.posAtCoords(It(t));o&&(s=="singleClick"?r.input.mouseDown=new Qn(r,o,t,!!n):(s=="doubleClick"?aa:fa)(r,o.pos,o.inside,t)?t.preventDefault():ge(r,"pointer"))};var Xt=class{constructor(e){this.view=e,this.mightDrag=null,e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this))}up(e){this.done()}move(e){e.buttons==0&&this.done()}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null)}delaySelUpdate(){return!1}},Qn=class extends Xt{constructor(e,t,n,i){super(e),this.pos=t,this.event=n,this.flushed=i,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!n[Os],this.allowDefault=n.shiftKey;let s,o;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),o=t.inside;else{let c=e.state.doc.resolve(t.pos);s=c.parent,o=c.depth?c.before():0}let l=i?null:n.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&S(a.nodeDOM)?a.nodeDOM:null;let{selection:f}=e.state;n.button==0&&(s.type.spec.draggable&&s.type.spec.selectable!==!1||f instanceof k&&f.from<=o&&f.to>o)&&(this.mightDrag={node:s,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&X&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),ge(e,"pointer")}done(){super.done(),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>{this.view.isDestroyed||ye(this.view)})}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(It(e))),this.updateAllowDefault(e),this.allowDefault||!t?ge(this.view,"pointer"):la(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||J&&this.mightDrag&&!this.mightDrag.node.isAtom||B&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(Rt(this.view,C.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):ge(this.view,"pointer")}move(e){this.updateAllowDefault(e),ge(this.view,"pointer"),super.move(e)}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return this.allowDefault?(this.delayedSelectionSync=!0,!0):!1}},_n=class extends Xt{constructor(e,t){super(e),this.startSelection=t,this.startDoc=e.state.doc}move(e){if(e.buttons==0||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc)){this.done();return}e.preventDefault(),ge(this.view,"pointer");let t=this.view.posAtCoords(It(e)),n=t&&Ms(this.view,t.inside,!1);if(!n)return;let{doc:i}=this.view.state,s=this.startSelection,[o,l]=n.from<s.from?[s.to,n.from]:[s.from,n.to];Rt(this.view,M.create(i,o,l))}};K.touchstart=r=>{r.input.lastTouch=Date.now(),fr(r),ge(r,"pointer")};K.touchmove=r=>{r.input.lastTouch=Date.now(),ge(r,"pointer")};K.contextmenu=r=>fr(r);function ws(r,e){return r.composing?!0:J&&Math.abs(Date.now()-r.input.compositionEndedAt)<500?(r.input.compositionEndedAt=-2e8,!0):!1}var ha=me?5e3:-1;$.compositionstart=$.compositionupdate=r=>{if(!r.composing){r.domObserver.flush();let{state:e}=r,t=e.selection.$to;if(e.selection instanceof M&&e.selection.empty&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(n=>n.type.spec.inclusive===!1)||B&&rs&&ua(r)))r.markCursor=r.state.storedMarks||t.marks(),Nt(r,!0),r.markCursor=null;else if(Nt(r,!e.selection.empty),X&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let n=r.domSelectionRange();for(let i=n.focusNode,s=n.focusOffset;i&&S(i)&&s!=0;){let o=s<0?i.lastChild:i.childNodes[s-1];if(!o)break;if(A(o)){let l=r.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else i=o,s=-1}}r.input.composing=!0}Ns(r,ha)};function ua(r){let{focusNode:e,focusOffset:t}=r.domSelectionRange();if(!e||!S(e)||t>=e.childNodes.length)return!1;let n=e.childNodes[t];return S(n)&&n.contentEditable=="false"}$.compositionend=(r,e)=>{r.composing&&(r.input.composing=!1,r.input.compositionEndedAt=Date.now(),r.input.compositionPendingChanges=r.domObserver.pendingRecords().length?r.input.compositionID:0,r.input.compositionNode=null,r.input.badSafariComposition?r.domObserver.forceFlush():r.input.compositionPendingChanges&&Promise.resolve().then(()=>r.domObserver.flush()),r.input.compositionID++,Ns(r,20))};function Ns(r,e){clearTimeout(r.input.composingTimeout),e>-1&&(r.input.composingTimeout=setTimeout(()=>Nt(r),e))}function Ds(r){for(r.composing&&(r.input.composing=!1,r.input.compositionEndedAt=Date.now());r.input.compositionNodes.length>0;)r.input.compositionNodes.pop().markParentsDirty()}function da(r){let e=r.domSelectionRange();if(!e.focusNode)return null;let t=cl(e.focusNode,e.focusOffset),n=hl(e.focusNode,e.focusOffset);if(t&&n&&t!=n){let i=n.pmViewDesc,s=r.domObserver.lastChangedTextNode;if(t==s||n==s)return s;if(!i||!i.isText(n.nodeValue))return n;if(r.input.compositionNode==n){let o=t.pmViewDesc;if(!(!o||!o.isText(t.nodeValue)))return n}}return t||n}function Nt(r,e=!1){if(!(me&&r.domObserver.flushingSoon>=0)){if(r.domObserver.forceFlush(),Ds(r),e||r.docView&&r.docView.dirty){let t=rr(r),n=r.state.selection;return t&&!t.eq(n)?r.dispatch(r.state.tr.setSelection(t)):(r.markCursor||e)&&!n.$from.node(n.$from.sharedDepth(n.to)).inlineContent?r.dispatch(r.state.tr.deleteSelection()):r.updateState(r.state),!0}return!1}}function pa(r,e){if(!r.dom.parentNode)return;let t=r.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let n=getSelection(),i=document.createRange();i.selectNodeContents(e),r.dom.blur(),n.removeAllRanges(),n.addRange(i),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),r.focus()},50)}var Dt=G&&Oe<15||lt&&ml<604;K.copy=$.cut=(r,e)=>{let t=e,n=r.state.selection,i=t.type=="cut";if(n.empty)return;let s=Dt?null:t.clipboardData,o=n.content(),{dom:l,text:a}=sr(r,o);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):pa(r,l),i&&r.dispatch(r.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function ma(r){return r.openStart==0&&r.openEnd==0&&r.content.childCount==1?r.content.firstChild:null}function ga(r,e){if(!r.dom.parentNode)return;let t=r.input.shiftKey||r.state.selection.$from.parent.type.spec.code,n=r.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(n.contentEditable="true"),n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus();let i=r.input.shiftKey&&r.input.lastKeyCode!=45;setTimeout(()=>{r.focus(),n.parentNode&&n.parentNode.removeChild(n),t?Tt(r,n.value,null,i,e):Tt(r,n.textContent,n.innerHTML,i,e)},50)}function Tt(r,e,t,n,i){let s=or(r,e,t,n,r.state.selection.$from);if(r.someProp("handlePaste",a=>a(r,i,s||x.empty)))return!0;if(!s)return!1;let o=ma(s),l=o?r.state.tr.replaceSelectionWith(o,n):r.state.tr.replaceSelection(s);return r.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Ts(r){let e=r.getData("text/plain")||r.getData("Text");if(e)return e;let t=r.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}$.paste=(r,e)=>{let t=e;if(r.composing&&!me)return;let n=Dt?null:t.clipboardData,i=r.input.shiftKey&&r.input.lastKeyCode!=45;n&&Tt(r,Ts(n),n.getData("text/html"),i,t)?t.preventDefault():ga(r,t)};var Qt=class{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}},ya=Q?"altKey":"ctrlKey";function Es(r,e){let t;return r.someProp("dragCopies",n=>{t=t||n(e)}),t!=null?!t:!e[ya]}K.dragstart=(r,e)=>{let t=e,n=r.input.mouseDown;if(n&&n.done(),!t.dataTransfer)return;let i=r.state.selection,s=i.empty?null:r.posAtCoords(It(t)),o;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof k?i.to-1:i.to))){if(n&&n.mightDrag)o=k.create(r.state.doc,n.mightDrag.pos);else if(t.target&&S(t.target)){let h=r.docView.nearestDesc(t.target,!0);h&&h.node.type.spec.draggable&&h!=r.docView&&(o=k.create(r.state.doc,h.posBefore))}}let l=(o||r.state.selection).content(),{dom:a,text:f,slice:c}=sr(r,l);(!t.dataTransfer.files.length||!B||ns>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Dt?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",Dt||t.dataTransfer.setData("text/plain",f),r.dragging=new Qt(c,Es(r,t),o)};K.dragend=r=>{let e=r.dragging;window.setTimeout(()=>{r.dragging==e&&(r.dragging=null)},50)};$.dragover=$.dragenter=(r,e)=>e.preventDefault();$.drop=(r,e)=>{try{xa(r,e,r.dragging)}finally{r.dragging=null}};function xa(r,e,t){if(!e.dataTransfer)return;let n=r.posAtCoords(It(e));if(!n)return;let i=r.state.doc.resolve(n.pos),s=t&&t.slice;s?r.someProp("transformPasted",d=>{s=d(s,r,!1)}):s=or(r,Ts(e.dataTransfer),Dt?null:e.dataTransfer.getData("text/html"),!1,i);let o=!!(t&&Es(r,e));if(r.someProp("handleDrop",d=>d(r,e,s||x.empty,o))){e.preventDefault();return}if(!s)return;e.preventDefault();let l=s?St(r.state.doc,i.pos,s):i.pos;l==null&&(l=i.pos);let a=r.state.tr;if(o){let{node:d}=t;d?d.replace(a):a.deleteSelection()}let f=a.mapping.map(l),c=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,h=a.doc;if(c?a.replaceRangeWith(f,f,s.content.firstChild):a.replaceRange(f,f,s),a.doc.eq(h))return;let u=a.doc.resolve(f);if(c&&k.isSelectable(s.content.firstChild)&&u.nodeAfter&&u.nodeAfter.sameMarkup(s.content.firstChild))a.setSelection(new k(u));else{let d=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((p,m,g,b)=>d=b),a.setSelection(ir(r,u,a.doc.resolve(d)))}r.focus(),r.dispatch(a.setMeta("uiEvent","drop"))}K.focus=r=>{r.input.lastFocus=Date.now(),r.focused||(r.domObserver.stop(),r.dom.classList.add("ProseMirror-focused"),r.domObserver.start(),r.focused=!0,setTimeout(()=>{r.docView&&r.hasFocus()&&!r.domObserver.currentSelection.eq(r.domSelectionRange())&&ye(r)},20))};K.blur=(r,e)=>{let t=e;r.focused&&(r.domObserver.stop(),r.dom.classList.remove("ProseMirror-focused"),r.domObserver.start(),t.relatedTarget&&r.dom.contains(t.relatedTarget)&&r.domObserver.currentSelection.clear(),r.focused=!1)};K.beforeinput=(r,e)=>{if(me&&e.inputType=="deleteContentBackward"){r.domObserver.flushSoon();let{domChangeCount:n}=r.input;setTimeout(()=>{if(r.input.domChangeCount!=n||(r.dom.blur(),r.focus(),r.someProp("handleKeyDown",s=>s(r,Be(8,"Backspace")))))return;let{$cursor:i}=r.state.selection;i&&i.pos>0&&r.dispatch(r.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let r in $)K[r]=$[r];function Et(r,e){if(r==e)return!0;for(let t in r)if(r[t]!==e[t])return!1;for(let t in e)if(!(t in r))return!1;return!0}var _t=class r{constructor(e,t){this.toDOM=e,this.spec=t||Le,this.side=this.spec.side||0}map(e,t,n,i){let{pos:s,deleted:o}=e.mapResult(t.from+i,this.side<0?-1:1);return o?null:new te(s-n,s-n,this)}valid(){return!0}eq(e){return this==e||e instanceof r&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Et(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},Ve=class r{constructor(e,t){this.attrs=e,this.spec=t||Le}map(e,t,n,i){let s=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-n,o=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-n;return s>=o?null:new te(s,o,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof r&&Et(this.attrs,e.attrs)&&Et(this.spec,e.spec)}static is(e){return e.type instanceof r}destroy(){}},Zn=class r{constructor(e,t){this.attrs=e,this.spec=t||Le}map(e,t,n,i){let s=e.mapResult(t.from+i,1);if(s.deleted)return null;let o=e.mapResult(t.to+i,-1);return o.deleted||o.pos<=s.pos?null:new te(s.pos-n,o.pos-n,this)}valid(e,t){let{index:n,offset:i}=e.content.findIndex(t.from),s;return i==t.from&&!(s=e.child(n)).isText&&i+s.nodeSize==t.to}eq(e){return this==e||e instanceof r&&Et(this.attrs,e.attrs)&&Et(this.spec,e.spec)}destroy(){}},te=class r{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(e,t){return new r(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(e,t,n){return new r(e,e,new _t(t,n))}static inline(e,t,n,i){return new r(e,t,new Ve(n,i))}static node(e,t,n,i){return new r(e,t,new Zn(n,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Ve}get widget(){return this.type instanceof _t}},st=[],Le={},q=class r{constructor(e,t){this.local=e.length?e:st,this.children=t.length?t:st}static create(e,t){return t.length?en(t,e,0,Le):L}find(e,t,n){let i=[];return this.findInner(e??0,t??1e9,i,0,n),i}findInner(e,t,n,i,s){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=t&&l.to>=e&&(!s||s(l.spec))&&n.push(l.copy(l.from+i,l.to+i))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<t&&this.children[o+1]>e){let l=this.children[o]+1;this.children[o+2].findInner(e-l,t-l,n,i+l,s)}}map(e,t,n){return this==L||e.maps.length==0?this:this.mapInner(e,t,0,0,n||Le)}mapInner(e,t,n,i,s){let o;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,n,i);a&&a.type.valid(t,a)?(o||(o=[])).push(a):s.onRemove&&s.onRemove(this.local[l].spec)}return this.children.length?ba(this.children,o||[],e,t,n,i,s):o?new r(o.sort(We),st):L}add(e,t){return t.length?this==L?r.create(e,t):this.addInner(e,t,0):this}addInner(e,t,n){let i,s=0;e.forEach((l,a)=>{let f=a+n,c;if(c=Is(t,l,f)){for(i||(i=this.children.slice());s<i.length&&i[s]<a;)s+=3;i[s]==a?i[s+2]=i[s+2].addInner(l,c,f+1):i.splice(s,0,a,a+l.nodeSize,en(c,l,f+1,Le)),s+=3}});let o=As(s?Rs(t):t,-n);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new r(o.length?this.local.concat(o).sort(We):this.local,i||this.children)}remove(e){return e.length==0||this==L?this:this.removeInner(e,0)}removeInner(e,t){let n=this.children,i=this.local;for(let s=0;s<n.length;s+=3){let o,l=n[s]+t,a=n[s+1]+t;for(let c=0,h;c<e.length;c++)(h=e[c])&&h.from>l&&h.to<a&&(e[c]=null,(o||(o=[])).push(h));if(!o)continue;n==this.children&&(n=this.children.slice());let f=n[s+2].removeInner(o,l+1);f!=L?n[s+2]=f:(n.splice(s,3),s-=3)}if(i.length){for(let s=0,o;s<e.length;s++)if(o=e[s])for(let l=0;l<i.length;l++)i[l].eq(o,t)&&(i==this.local&&(i=this.local.slice()),i.splice(l--,1))}return n==this.children&&i==this.local?this:i.length||n.length?new r(i,n):L}forChild(e,t){if(this==L)return this;if(t.isLeaf)return r.empty;let n,i;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(n=this.children[l+2]);break}let s=e+1,o=s+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<o&&a.to>s&&a.type instanceof Ve){let f=Math.max(s,a.from)-s,c=Math.min(o,a.to)-s;f<c&&(i||(i=[])).push(a.copy(f,c))}}if(i){let l=new r(i.sort(We),st);return n?new Zt([l,n]):l}return n||L}eq(e){if(this==e)return!0;if(!(e instanceof r)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return cr(this.localsInner(e))}localsInner(e){if(this==L)return st;if(e.inlineContent||!this.local.some(Ve.is))return this.local;let t=[];for(let n=0;n<this.local.length;n++)this.local[n].type instanceof Ve||t.push(this.local[n]);return t}forEachSet(e){e(this)}};q.empty=new q([],[]);q.removeOverlap=cr;var L=q.empty,Zt=class r{constructor(e){this.members=e}map(e,t){let n=this.members.map(i=>i.map(e,t,Le));return r.from(n)}forChild(e,t){if(t.isLeaf)return q.empty;let n=[];for(let i=0;i<this.members.length;i++){let s=this.members[i].forChild(e,t);s!=L&&(s instanceof r?n=n.concat(s.members):n.push(s))}return r.from(n)}eq(e){if(!(e instanceof r)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,n=!0;for(let i=0;i<this.members.length;i++){let s=this.members[i].localsInner(e);if(s.length)if(!t)t=s;else{n&&(t=t.slice(),n=!1);for(let o=0;o<s.length;o++)t.push(s[o])}}return t?cr(n?t:t.sort(We)):st}static from(e){switch(e.length){case 0:return L;case 1:return e[0];default:return new r(e.every(t=>t instanceof q)?e:e.reduce((t,n)=>t.concat(n instanceof q?n:n.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function ba(r,e,t,n,i,s,o){let l=r.slice();for(let f=0,c=s;f<t.maps.length;f++){let h=0;t.maps[f].forEach((u,d,p,m)=>{let g=m-p-(d-u);for(let b=0;b<l.length;b+=3){let D=l[b+1];if(D<0||u>D+c-h)continue;let N=l[b]+c-h;d>=N?l[b+1]=u<=N?-2:-1:u>=c&&g&&(l[b]+=g,l[b+1]+=g)}h+=g}),c=t.maps[f].map(c,-1)}let a=!1;for(let f=0;f<l.length;f+=3)if(l[f+1]<0){if(l[f+1]==-2){a=!0,l[f+1]=-1;continue}let c=t.map(r[f]+s),h=c-i;if(h<0||h>=n.content.size){a=!0;continue}let u=t.map(r[f+1]+s,-1),d=u-i,{index:p,offset:m}=n.content.findIndex(h),g=n.maybeChild(p);if(g&&m==h&&m+g.nodeSize==d){let b=l[f+2].mapInner(t,g,c+1,r[f]+s+1,o);b!=L?(l[f]=h,l[f+1]=d,l[f+2]=b):(l[f+1]=-2,a=!0)}else a=!0}if(a){let f=Sa(l,r,e,t,i,s,o),c=en(f,n,0,o);e=c.local;for(let h=0;h<l.length;h+=3)l[h+1]<0&&(l.splice(h,3),h-=3);for(let h=0,u=0;h<c.children.length;h+=3){let d=c.children[h];for(;u<l.length&&l[u]<d;)u+=3;l.splice(u,0,c.children[h],c.children[h+1],c.children[h+2])}}return new q(e.sort(We),l)}function As(r,e){if(!e||!r.length)return r;let t=[];for(let n=0;n<r.length;n++){let i=r[n];t.push(new te(i.from+e,i.to+e,i.type))}return t}function Sa(r,e,t,n,i,s,o){function l(a,f){for(let c=0;c<a.local.length;c++){let h=a.local[c].map(n,i,f);h?t.push(h):o.onRemove&&o.onRemove(a.local[c].spec)}for(let c=0;c<a.children.length;c+=3)l(a.children[c+2],a.children[c]+f+1)}for(let a=0;a<r.length;a+=3)r[a+1]==-1&&l(r[a+2],e[a]+s+1);return t}function Is(r,e,t){if(e.isLeaf)return null;let n=t+e.nodeSize,i=null;for(let s=0,o;s<r.length;s++)(o=r[s])&&o.from>t&&o.to<n&&((i||(i=[])).push(o),r[s]=null);return i}function Rs(r){let e=[];for(let t=0;t<r.length;t++)r[t]!=null&&e.push(r[t]);return e}function en(r,e,t,n){let i=[],s=!1;e.forEach((l,a)=>{let f=Is(r,l,a+t);if(f){s=!0;let c=en(f,l,t+a+1,n);c!=L&&i.push(a,a+l.nodeSize,c)}});let o=As(s?Rs(r):r,-t).sort(We);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||(n.onRemove&&n.onRemove(o[l].spec),o.splice(l--,1));return o.length||i.length?new q(o,i):L}function We(r,e){return r.from-e.from||r.to-e.to}function cr(r){let e=r;for(let t=0;t<e.length-1;t++){let n=e[t];if(n.from!=n.to)for(let i=t+1;i<e.length;i++){let s=e[i];if(s.from==n.from){s.to!=n.to&&(e==r&&(e=r.slice()),e[i]=s.copy(s.from,n.to),Hi(e,i+1,s.copy(n.to,s.to)));continue}else{s.from<n.to&&(e==r&&(e=r.slice()),e[t]=n.copy(n.from,s.from),Hi(e,i,n.copy(s.from,n.to)));break}}}return e}function Hi(r,e,t){for(;e<r.length&&We(t,r[e])>0;)e++;r.splice(e,0,t)}function Bn(r){let e=[];return r.someProp("decorations",t=>{let n=t(r.state);n&&n!=L&&e.push(n)}),r.cursorWrapper&&e.push(q.create(r.state.doc,[r.cursorWrapper.deco])),Zt.from(e)}var ka={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Ca=G&&Oe<=11,er=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}},tr=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new er,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(n=>{for(let i=0;i<n.length;i++)this.queue.push(n[i]);G&&Oe<=11&&n.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():J&&e.composing&&n.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),Ca&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,ka)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}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=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(Vi(this.view)){if(this.suppressingSelectionUpdates)return ye(this.view);if(G&&Oe<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Je(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,n;for(let s=e.focusNode;s;s=ot(s))t.add(s);for(let s=e.anchorNode;s;s=ot(s))if(t.has(s)){n=s;break}let i=n&&this.view.docView.nearestDesc(n);if(i&&i.ignoreMutation({type:"selection",target:A(n)?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&Vi(e)&&!this.ignoreSelectionChange(n),s=-1,o=-1,l=!1,a=[];if(e.editable)for(let c=0;c<t.length;c++){let h=this.registerMutation(t[c],a);h&&(s=s<0?h.from:Math.min(h.from,s),o=o<0?h.to:Math.max(h.to,o),h.typeOver&&(l=!0))}if(a.some(c=>c.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46||B&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&t.some(c=>c.type=="childList"&&c.removedNodes.length))){for(let c of a)if(c.nodeName=="BR"&&c.parentNode){let h=c.nextSibling;for(;h&&S(h);){if(h.contentEditable=="false"){c.parentNode.removeChild(c);break}h=h.firstChild}}}else if(X&&a.length){let c=a.filter(h=>h.nodeName=="BR");if(c.length==2){let[h,u]=c;h.parentNode&&h.parentNode.parentNode==u.parentNode?u.remove():h.remove()}else{let{focusNode:h}=this.currentSelection;for(let u of c){let d=u.parentNode;d&&d.nodeName=="LI"&&(!h||wa(e,h)!=d)&&u.remove()}}}let f=null;s<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&nn(n)&&(f=rr(e))&&f.eq(C.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,ye(e),this.currentSelection.set(n),e.scrollToSelection()):(s>-1||i)&&(s>-1&&(e.docView.markDirty(s,o),Ma(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,Na(e,a)),this.handleDOMChange(s,o,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||ye(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(n==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!n||n.ignoreMutation(e))return null;if(e.type=="childList"){for(let c=0;c<e.addedNodes.length;c++){let h=e.addedNodes[c];t.push(h),A(h)&&(this.lastChangedTextNode=h)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let i=e.previousSibling,s=e.nextSibling;if(G&&Oe<=11&&e.addedNodes.length)for(let c=0;c<e.addedNodes.length;c++){let{previousSibling:h,nextSibling:u}=e.addedNodes[c];(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(i=h),(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(s=u)}let o=i&&i.parentNode==e.target?P(i)+1:0,l=n.localPosFromDOM(e.target,o,-1),a=s&&s.parentNode==e.target?P(s):e.target.childNodes.length,f=n.localPosFromDOM(e.target,a,1);return{from:l,to:f}}else return e.type=="attributes"?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:(this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}},Ui=new WeakMap,ji=!1;function Ma(r){if(!Ui.has(r)&&(Ui.set(r,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(r.dom).whiteSpace)!==-1)){if(r.requiresGeckoHackNode=X,ji)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."),ji=!0}}function Gi(r,e){let t=e.startContainer,n=e.startOffset,i=e.endContainer,s=e.endOffset,o=r.domAtPos(r.state.selection.anchor);return Je(o.node,o.offset,i,s)&&([t,n,i,s]=[i,s,t,n]),{anchorNode:t,anchorOffset:n,focusNode:i,focusOffset:s}}function Oa(r,e){if(e.getComposedRanges){let i=e.getComposedRanges(r.root)[0];if(i)return Gi(r,i)}let t;function n(i){i.preventDefault(),i.stopImmediatePropagation(),t=i.getTargetRanges()[0]}return r.dom.addEventListener("beforeinput",n,!0),document.execCommand("indent"),r.dom.removeEventListener("beforeinput",n,!0),t?Gi(r,t):null}function wa(r,e){for(let t=e.parentNode;t&&t!=r.dom;t=t.parentNode){let n=r.docView.nearestDesc(t,!0);if(n&&n.node.isBlock)return t}return null}function Na(r,e){var t;let{focusNode:n,focusOffset:i}=r.domSelectionRange();for(let s of e)if(((t=s.parentNode)===null||t===void 0?void 0:t.nodeName)=="TR"){let o=s.nextSibling;for(;o&&o.nodeName!="TD"&&o.nodeName!="TH";)o=o.nextSibling;if(o){let l=o;for(;;){let a=l.firstChild;if(!a||!S(a)||a.contentEditable=="false"||/^(BR|IMG)$/.test(a.nodeName))break;l=a}l.insertBefore(s,l.firstChild),n==s&&r.domSelection().collapse(s,i)}else s.parentNode.removeChild(s)}}function Da(r,e,t,n){let{node:i,fromOffset:s,toOffset:o,from:l,to:a}=r.docView.parseRange(e,t),f=r.domSelectionRange(),c,h=f.anchorNode;if(h&&qe(r.dom,h)&&(c=[{node:h,offset:f.anchorOffset}],nn(f)||c.push({node:f.focusNode,offset:f.focusOffset})),B&&r.input.lastKeyCode===8)for(let b=o;b>s;b--){let D=i.childNodes[b-1],N=D.pmViewDesc;if(D.nodeName=="BR"&&!N){o=b;break}if(!N||N.size)break}let u=r.state.doc,d=r.someProp("domParser")||je.fromSchema(r.state.schema),p=u.resolve(l),m=null,g=d.parse(i,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:s,to:o,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:Ta(n),context:p});if(c&&c[0].pos!=null){let b=c[0].pos,D=c[1]&&c[1].pos;D==null&&(D=b),m={anchor:b+l,head:D+l}}return{doc:g,sel:m,from:l,to:a}}var Ta=r=>e=>{let t=e.pmViewDesc;if(t)return t.parseRule(r);if(e.nodeName=="BR"&&e.parentNode){if(J&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}else if(e.parentNode.lastChild==e||J&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName=="IMG"&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null},Ea=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Aa(r,e,t,n,i){let s=r.input.compositionPendingChanges||(r.composing?r.input.compositionID:0);if(r.input.compositionPendingChanges=0,e<0){let O=r.input.lastSelectionTime>Date.now()-50?r.input.lastSelectionOrigin:null,I=rr(r,O);if(I&&!r.state.selection.eq(I)){if(B&&me&&r.input.lastKeyCode===13&&Date.now()-100<r.input.lastKeyCodeTime&&r.someProp("handleKeyDown",xo=>xo(r,Be(13,"Enter"))))return;let H=r.state.tr.setSelection(I);O=="pointer"?H.setMeta("pointer",!0):O=="key"&&H.scrollIntoView(),s&&H.setMeta("composition",s),r.dispatch(H)}return}let o=r.state.doc.resolve(e),l=o.sharedDepth(t);e=o.before(l+1),t=r.state.doc.resolve(t).after(l+1);let a=r.state.selection,f=Da(r,e,t,i),c=r.state.doc,h=c.slice(f.from,f.to),u,d;r.input.lastKeyCode===8&&Date.now()-100<r.input.lastKeyCodeTime?(u=r.state.selection.to,d="end"):(u=r.state.selection.from,d="start"),r.input.lastKeyCode=null;let p=Ba(h.content,f.doc.content,f.from,u,d);if(p&&r.input.domChangeCount++,(lt&&r.input.lastIOSEnter>Date.now()-225||me)&&i.some(O=>S(O)&&!Ea.test(O.nodeName))&&(!p||p.endA>=p.endB)&&r.someProp("handleKeyDown",O=>O(r,Be(13,"Enter")))){r.input.lastIOSEnter=0;return}if(!p)if(n&&a instanceof M&&!a.empty&&a.$head.sameParent(a.$anchor)&&!r.composing&&!(f.sel&&f.sel.anchor!=f.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(f.sel){let O=Yi(r,r.state.doc,f.sel);if(O&&!O.eq(r.state.selection)){let I=r.state.tr.setSelection(O);s&&I.setMeta("composition",s),r.dispatch(I)}}return}r.state.selection.from<r.state.selection.to&&p.start==p.endB&&r.state.selection instanceof M&&(p.start>r.state.selection.from&&p.start<=r.state.selection.from+2&&r.state.selection.from>=f.from?p.start=r.state.selection.from:p.endA<r.state.selection.to&&p.endA>=r.state.selection.to-2&&r.state.selection.to<=f.to&&(p.endB+=r.state.selection.to-p.endA,p.endA=r.state.selection.to)),G&&Oe<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>f.from&&f.doc.textBetween(p.start-f.from-1,p.start-f.from+1)==" \xA0"&&(p.start--,p.endA--,p.endB--);let m=f.doc.resolveNoCache(p.start-f.from),g=f.doc.resolveNoCache(p.endB-f.from),b=c.resolve(p.start),D=m.sameParent(g)&&m.parent.inlineContent&&b.end()>=p.endA;if((lt&&r.input.lastIOSEnter>Date.now()-225&&(!D||i.some(O=>O.nodeName=="DIV"||O.nodeName=="P"))||!D&&Pa(f.doc,m.pos,g.pos))&&r.someProp("handleKeyDown",O=>O(r,Be(13,"Enter")))){r.input.lastIOSEnter=0;return}if(r.state.selection.anchor>p.start&&Ra(c,p.start,p.endA,m,g)&&r.someProp("handleKeyDown",O=>O(r,Be(8,"Backspace")))){me&&B&&r.domObserver.suppressSelectionUpdates();return}B&&p.endB==p.start&&(r.input.lastChromeDelete=Date.now()),me&&!D&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&f.sel&&f.sel.anchor==f.sel.head&&f.sel.head==p.endA&&(p.endB-=2,g=f.doc.resolveNoCache(p.endB-f.from),setTimeout(()=>{r.someProp("handleKeyDown",function(O){return O(r,Be(13,"Enter"))})},20));let N=p.start,re=p.endA,De=O=>{let I=O||r.state.tr.replace(N,re,f.doc.slice(p.start-f.from,p.endB-f.from));if(f.sel){let H=Yi(r,I.doc,f.sel);H&&!(B&&r.composing&&H.empty&&(p.start!=p.endB||r.input.lastChromeDelete<Date.now()-100)&&(H.head==N||H.head==I.mapping.map(re)-1)||G&&H.empty&&H.head==N)&&I.setSelection(H)}return s&&I.setMeta("composition",s),I.scrollIntoView()},Pt;if(D)if(m.pos==g.pos){G&&Oe<=11&&m.parentOffset==0&&(r.domObserver.suppressSelectionUpdates(),setTimeout(()=>ye(r),20));let O=De(r.state.tr.delete(N,re)),I=c.resolve(p.start).marksAcross(c.resolve(p.endA));I&&O.ensureMarks(I),r.dispatch(O)}else if(p.endA==p.endB&&(Pt=Ia(m.parent.content.cut(m.parentOffset,g.parentOffset),b.parent.content.cut(b.parentOffset,p.endA-b.start())))){let O=De(r.state.tr);Pt.type=="add"?O.addMark(N,re,Pt.mark):O.removeMark(N,re,Pt.mark),r.dispatch(O)}else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let O=m.parent.textBetween(m.parentOffset,g.parentOffset),I=()=>De(r.state.tr.insertText(O,N,re));r.someProp("handleTextInput",H=>H(r,N,re,O,I))||r.dispatch(I())}else r.dispatch(De());else r.dispatch(De())}function Yi(r,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:ir(r,e.resolve(t.anchor),e.resolve(t.head))}function Ia(r,e){let t=r.firstChild.marks,n=e.firstChild.marks,i=t,s=n,o,l,a;for(let c=0;c<n.length;c++)i=n[c].removeFromSet(i);for(let c=0;c<t.length;c++)s=t[c].removeFromSet(s);if(i.length==1&&s.length==0)l=i[0],o="add",a=c=>c.mark(l.addToSet(c.marks));else if(i.length==0&&s.length==1)l=s[0],o="remove",a=c=>c.mark(l.removeFromSet(c.marks));else return null;let f=[];for(let c=0;c<e.childCount;c++)f.push(a(e.child(c)));if(y.from(f).eq(r))return{mark:l,type:o}}function Ra(r,e,t,n,i){if(t-e<=i.pos-n.pos||zn(n,!0,!1)<i.pos)return!1;let s=r.resolve(e);if(!n.parent.isTextblock){let l=s.nodeAfter;return l!=null&&t==e+l.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let o=r.resolve(zn(s,!0,!0));return!o.parent.isTextblock||o.pos>t||zn(o,!0,!1)<t?!1:n.parent.content.cut(n.parentOffset).eq(o.parent.content)}function Pa(r,e,t){let n=0,i=0;return r.nodesBetween(e,t,(s,o)=>{s.isTextblock&&o>=e&&o<t?n++:(s.isText?/\S/.test(s.text.slice(Math.max(0,e-o),Math.min(s.nodeSize,t-o))):s.isLeaf)&&i++}),i==0&&n==1}function zn(r,e,t){let n=r.depth,i=e?r.end():r.pos;for(;n>0&&(e||r.indexAfter(n)==r.node(n).childCount);)n--,i++,e=!1;if(t){let s=r.node(n).maybeChild(r.indexAfter(n));for(;s&&!s.isLeaf;)s=s.firstChild,i++}return i}function Ba(r,e,t,n,i){let s=r.findDiffStart(e,t),o=t+r.size,l=t+e.size;if(s==null)return null;let{a,b:f}=r.findDiffEnd(e,o,l);if(i=="end"){let c=Math.max(0,s-Math.min(a,f));n-=a+c-s}if(a<s&&o<l){let c=n<=s&&n>=a?s-n:0;s-=c,f=s+(f-a),a=s}else if(f<s){let c=n<=s&&n>=f?s-n:0;s-=c,a=s+(a-f),f=s}return{start:s,endA:a,endB:f}}var za=or,Fa=Nt,tn=class{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new Yn,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(es),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=_i(this),Qi(this),this.nodeViews=Zi(this),this.docView=Ri(this.state.doc,Xi(this),Bn(this),this.dom,this),this.domObserver=new tr(this,(n,i,s,o)=>Aa(this,n,i,s,o)),this.domObserver.start(),ea(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Xn(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(es),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let n in this._props)t[n]=this._props[n];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var n;let i=this.state,s=!1,o=!1;e.storedMarks&&this.composing&&(Ds(this),o=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let d=Zi(this);Va(d,this.nodeViews)&&(this.nodeViews=d,s=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&Xn(this),this.editable=_i(this),Qi(this);let a=Bn(this),f=Xi(this),c=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",h=s||!this.docView.matchesNode(e.doc,f,a);(h||!e.selection.eq(i.selection))&&(o=!0);let u=c=="preserve"&&o&&this.dom.style.overflowAnchor==null&&xl(this);if(o){this.domObserver.stop();let d=h&&(G||B)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&va(i.selection,e.selection);if(h){let m=B?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=da(this)),(s||!this.docView.update(e.doc,f,a,this))&&(this.docView.updateOuterDeco(f),this.docView.destroy(),this.docView=Ri(e.doc,f,a,this.dom,this)),m&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(d=!0)}let p=this.input.mouseDown;d||!(p&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Ll(this)&&p.delaySelUpdate())?ye(this,d):(ms(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((n=this.dragging)===null||n===void 0)&&n.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),c=="reset"?this.dom.scrollTop=0:c=="to selection"?this.scrollToSelection():u&&bl(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!qe(this.dom,e))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof k){let t=this.docView.domAfterPos(this.state.selection.from);S(t)&&Di(this,t.getBoundingClientRect(),e)}else Di(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let n=this.directPlugins[t];n.spec.view&&this.pluginViews.push(n.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let n=this.state.plugins[t];n.spec.view&&this.pluginViews.push(n.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}}updateDraggedNode(e,t){let n=e.node,i=-1;if(n.from<this.state.doc.content.size&&this.state.doc.nodeAt(n.from)==n.node)i=n.from;else{let s=n.from+(this.state.doc.content.size-t.doc.content.size);(s>0&&s<this.state.doc.content.size&&this.state.doc.nodeAt(s))==n.node&&(i=s)}this.dragging=new Qt(e.slice,e.move,i<0?void 0:k.create(this.state.doc,i))}someProp(e,t){let n=this._props&&this._props[e],i;if(n!=null&&(i=t?t(n):n))return i;for(let o=0;o<this.directPlugins.length;o++){let l=this.directPlugins[o].props[e];if(l!=null&&(i=t?t(l):l))return i}let s=this.state.plugins;if(s)for(let o=0;o<s.length;o++){let l=s[o].props[e];if(l!=null&&(i=t?t(l):l))return i}}hasFocus(){if(G){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&Sl(this.dom),ye(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return wl(this,e)}coordsAtPos(e,t=1){return fs(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let i=this.docView.posFromDOM(e,t,n);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,t){return Al(this,t||this.state,e)}pasteHTML(e,t){return Tt(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Tt(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return sr(this,e)}destroy(){this.docView&&(ta(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Bn(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,al())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return ra(this,e)}domSelectionRange(){let e=this.dom.isConnected!==!1&&this.domSelection();return e?J&&this.root.nodeType===11&&dl(this.dom.ownerDocument)==this.dom&&Oa(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};tn.prototype.dispatch=function(r){let e=this._props.dispatchTransaction;e?e.call(this,r):this.updateState(this.state.apply(r))};function Xi(r){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(r.editable),r.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(r.state)),t)for(let n in t)n=="class"?e.class+=" "+t[n]:n=="style"?e.style=(e.style?e.style+";":"")+t[n]:!e[n]&&n!="contenteditable"&&n!="nodeName"&&(e[n]=String(t[n]))}),e.translate||(e.translate="no"),[te.node(0,r.state.doc.content.size,e)]}function Qi(r){if(r.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),r.cursorWrapper={dom:e,deco:te.widget(r.state.selection.from,e,{raw:!0,marks:r.markCursor})}}else r.cursorWrapper=null}function _i(r){return!r.someProp("editable",e=>e(r.state)===!1)}function va(r,e){let t=Math.min(r.$anchor.sharedDepth(r.head),e.$anchor.sharedDepth(e.head));return r.$anchor.start(t)!=e.$anchor.start(t)}function Zi(r){let e=Object.create(null);function t(n){for(let i in n)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=n[i])}return r.someProp("nodeViews",t),r.someProp("markViews",t),e}function Va(r,e){let t=0,n=0;for(let i in r){if(r[i]!=e[i])return!0;t++}for(let i in e)n++;return t!=n}function es(r){if(r.spec.state||r.spec.filterTransaction||r.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Ws={};ie(Ws,{closeHistory:()=>Ua,history:()=>ja,isHistoryTransaction:()=>_a,redo:()=>Ls,redoDepth:()=>Qa,redoNoScroll:()=>Ya,undo:()=>Vs,undoDepth:()=>Xa,undoNoScroll:()=>Ga});var sn=200,z=function(){};z.prototype.append=function(e){return e.length?(e=z.from(e),!this.length&&e||e.length<sn&&this.leafAppend(e)||this.length<sn&&e.leafPrepend(this)||this.appendInner(e)):this};z.prototype.prepend=function(e){return e.length?z.from(e).append(this):this};z.prototype.appendInner=function(e){return new La(this,e)};z.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?z.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};z.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};z.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)};z.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var i=[];return this.forEach(function(s,o){return i.push(e(s,o))},t,n),i};z.from=function(e){return e instanceof z?e:e&&e.length?new Bs(e):z.empty};var Bs=(function(r){function e(n){r.call(this),this.values=n}r&&(e.__proto__=r),e.prototype=Object.create(r&&r.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,s){return i==0&&s==this.length?this:new e(this.values.slice(i,s))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,s,o,l){for(var a=s;a<o;a++)if(i(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(i,s,o,l){for(var a=s-1;a>=o;a--)if(i(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=sn)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=sn)return new e(i.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e})(z);z.empty=new Bs([]);var La=(function(r){function e(t,n){r.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return r&&(e.__proto__=r),e.prototype=Object.create(r&&r.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(n){return n<this.left.length?this.left.get(n):this.right.get(n-this.left.length)},e.prototype.forEachInner=function(n,i,s,o){var l=this.left.length;if(i<l&&this.left.forEachInner(n,i,Math.min(s,l),o)===!1||s>l&&this.right.forEachInner(n,Math.max(i-l,0),Math.min(this.length,s)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(n,i,s,o){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(n,i-l,Math.max(s,l)-l,o+l)===!1||s<l&&this.left.forEachInvertedInner(n,Math.min(i,l),s,o)===!1)return!1},e.prototype.sliceInner=function(n,i){if(n==0&&i==this.length)return this;var s=this.left.length;return i<=s?this.left.slice(n,i):n>=s?this.right.slice(n-s,i-s):this.left.slice(n,s).append(this.right.slice(0,i-s))},e.prototype.leafAppend=function(n){var i=this.right.leafAppend(n);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(n){var i=this.left.leafPrepend(n);if(i)return new e(i,this.right)},e.prototype.appendInner=function(n){return this.left.depth>=Math.max(this.right.depth,n.depth)+1?new e(this.left,new e(this.right,n)):new e(this,n)},e})(z),hr=z;var Wa=500,$e=class r{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let n=this.items.length;for(;;n--)if(this.items.get(n-1).selection){--n;break}let i,s;t&&(i=this.remapping(n,this.items.length),s=i.maps.length);let o=e.tr,l,a,f=[],c=[];return this.items.forEach((h,u)=>{if(!h.step){i||(i=this.remapping(n,u+1),s=i.maps.length),s--,c.push(h);return}if(i){c.push(new le(h.map));let d=h.step.map(i.slice(s)),p;d&&o.maybeStep(d).doc&&(p=o.mapping.maps[o.mapping.maps.length-1],f.push(new le(p,void 0,void 0,f.length+c.length))),s--,p&&i.appendMap(p,s)}else o.maybeStep(h.step);if(h.selection)return l=i?h.selection.map(i.slice(s)):h.selection,a=new r(this.items.slice(0,n).append(c.reverse().concat(f)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:o,selection:l}}addTransform(e,t,n,i){let s=[],o=this.eventCount,l=this.items,a=!i&&l.length?l.get(l.length-1):null;for(let c=0;c<e.steps.length;c++){let h=e.steps[c].invert(e.docs[c]),u=new le(e.mapping.maps[c],h,t),d;(d=a&&a.merge(u))&&(u=d,c?s.pop():l=l.slice(0,l.length-1)),s.push(u),t&&(o++,t=void 0),i||(a=u)}let f=o-n.depth;return f>qa&&(l=Ja(l,f),o-=f),new r(l.append(s),o)}remapping(e,t){let n=new Ye;return this.items.forEach((i,s)=>{let o=i.mirrorOffset!=null&&s-i.mirrorOffset>=e?n.maps.length-i.mirrorOffset:void 0;n.appendMap(i.map,o)},e,t),n}addMaps(e){return this.eventCount==0?this:new r(this.items.append(e.map(t=>new le(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;t=Math.min(this.items.length,t);let n=[],i=this.items.length-t,s=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(u=>{u.selection&&l--},i);let a=t;this.items.forEach(u=>{let d=s.getMirror(--a);if(d==null)return;o=Math.min(o,d);let p=s.maps[d];if(u.step){let m=e.steps[d].invert(e.docs[d]),g=u.selection&&u.selection.map(s.slice(a+1,d));g&&l++,n.push(new le(p,m,g))}else n.push(new le(p))},i);let f=[];for(let u=t;u<o;u++)f.push(new le(s.maps[u]));let c=this.items.slice(0,i).append(f).append(n),h=new r(c,l);return h.emptyItemCount()>Wa&&(h=h.compress(this.items.length-n.length)),h}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),n=t.maps.length,i=[],s=0;return this.items.forEach((o,l)=>{if(l>=e)i.push(o),o.selection&&s++;else if(o.step){let a=o.step.map(t.slice(n)),f=a&&a.getMap();if(n--,f&&t.appendMap(f,n),a){let c=o.selection&&o.selection.map(t.slice(n));c&&s++;let h=new le(f.invert(),a,c),u,d=i.length-1;(u=i.length&&i[d].merge(h))?i[d]=u:i.push(h)}}else o.map&&n--},this.items.length,0),new r(hr.from(i.reverse()),s)}};$e.empty=new $e(hr.empty,0);function Ja(r,e){let t;return r.forEach((n,i)=>{if(n.selection&&e--==0)return t=i,!1}),r.slice(t)}var le=class r{constructor(e,t,n,i){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new r(t.getMap().invert(),t,this.selection)}}},ae=class{constructor(e,t,n,i,s){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=i,this.prevComposition=s}},qa=20;function Ka(r,e,t,n){let i=t.getMeta(fe),s;if(i)return i.historyState;t.getMeta(vs)&&(r=new ae(r.done,r.undone,null,0,-1));let o=t.getMeta("appendedTransaction");if(t.steps.length==0)return r;if(o&&o.getMeta(fe))return o.getMeta(fe).redo?new ae(r.done.addTransform(t,void 0,n,on(e)),r.undone,zs(t.mapping.maps),r.prevTime,r.prevComposition):new ae(r.done,r.undone.addTransform(t,void 0,n,on(e)),null,r.prevTime,r.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=r.prevTime==0||!o&&r.prevComposition!=l&&(r.prevTime<(t.time||0)-n.newGroupDelay||!$a(t,r.prevRanges)),f=o?ur(r.prevRanges,t.mapping):zs(t.mapping.maps);return new ae(r.done.addTransform(t,a?e.selection.getBookmark():void 0,n,on(e)),$e.empty,f,t.time,l??r.prevComposition)}else return(s=t.getMeta("rebased"))?new ae(r.done.rebased(t,s),r.undone.rebased(t,s),ur(r.prevRanges,t.mapping),r.prevTime,r.prevComposition):new ae(r.done.addMaps(t.mapping.maps),r.undone.addMaps(t.mapping.maps),ur(r.prevRanges,t.mapping),r.prevTime,r.prevComposition)}function $a(r,e){if(!e)return!1;if(!r.docChanged)return!0;let t=!1;return r.mapping.maps[0].forEach((n,i)=>{for(let s=0;s<e.length;s+=2)n<=e[s+1]&&i>=e[s]&&(t=!0)}),t}function zs(r){let e=[];for(let t=r.length-1;t>=0&&e.length==0;t--)r[t].forEach((n,i,s,o)=>e.push(s,o));return e}function ur(r,e){if(!r)return null;let t=[];for(let n=0;n<r.length;n+=2){let i=e.map(r[n],1),s=e.map(r[n+1],-1);i<=s&&t.push(i,s)}return t}function Ha(r,e,t){let n=on(e),i=fe.get(e).spec.config,s=(t?r.undone:r.done).popEvent(e,n);if(!s)return null;let o=s.selection.resolve(s.transform.doc),l=(t?r.done:r.undone).addTransform(s.transform,e.selection.getBookmark(),i,n),a=new ae(t?l:s.remaining,t?s.remaining:l,null,0,-1);return s.transform.setSelection(o).setMeta(fe,{redo:t,historyState:a})}var dr=!1,Fs=null;function on(r){let e=r.plugins;if(Fs!=e){dr=!1,Fs=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){dr=!0;break}}return dr}function Ua(r){return r.setMeta(vs,!0)}var fe=new nt("history"),vs=new nt("closeHistory");function ja(r={}){return r={depth:r.depth||100,newGroupDelay:r.newGroupDelay||500},new Y({key:fe,state:{init(){return new ae($e.empty,$e.empty,null,0,-1)},apply(e,t,n){return Ka(t,n,e,r)}},config:r,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,i=n=="historyUndo"?Vs:n=="historyRedo"?Ls:null;return!i||!e.editable?!1:(t.preventDefault(),i(e.state,e.dispatch))}}}})}function ln(r,e){return(t,n)=>{let i=fe.getState(t);if(!i||(r?i.undone:i.done).eventCount==0)return!1;if(n){let s=Ha(i,t,r);s&&n(e?s.scrollIntoView():s)}return!0}}var Vs=ln(!1,!0),Ls=ln(!0,!0),Ga=ln(!1,!1),Ya=ln(!0,!1);function Xa(r){let e=fe.getState(r);return e?e.done.eventCount:0}function Qa(r){let e=fe.getState(r);return e?e.undone.eventCount:0}function _a(r){return r.getMeta(fe)!=null}var qs={};ie(qs,{keydownHandler:()=>cn,keymap:()=>of});var xe={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:"'"},fn={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Za=typeof navigator<"u"&&/Mac/.test(navigator.platform),ef=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(T=0;T<10;T++)xe[48+T]=xe[96+T]=String(T);var T;for(T=1;T<=24;T++)xe[T+111]="F"+T;var T;for(T=65;T<=90;T++)xe[T]=String.fromCharCode(T+32),fn[T]=String.fromCharCode(T);var T;for(an in xe)fn.hasOwnProperty(an)||(fn[an]=xe[an]);var an;function Js(r){var e=Za&&r.metaKey&&r.shiftKey&&!r.ctrlKey&&!r.altKey||ef&&r.shiftKey&&r.key&&r.key.length==1||r.key=="Unidentified",t=!e&&r.key||(r.shiftKey?fn:xe)[r.keyCode]||r.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}var tf=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),nf=typeof navigator<"u"&&/Win/.test(navigator.platform);function rf(r){let e=r.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let n,i,s,o;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))n=!0;else if(/^(c|ctrl|control)$/i.test(a))i=!0;else if(/^s(hift)?$/i.test(a))s=!0;else if(/^mod$/i.test(a))tf?o=!0:i=!0;else throw new Error("Unrecognized modifier name: "+a)}return n&&(t="Alt-"+t),i&&(t="Ctrl-"+t),o&&(t="Meta-"+t),s&&(t="Shift-"+t),t}function sf(r){let e=Object.create(null);for(let t in r)e[rf(t)]=r[t];return e}function pr(r,e,t=!0){return e.altKey&&(r="Alt-"+r),e.ctrlKey&&(r="Ctrl-"+r),e.metaKey&&(r="Meta-"+r),t&&e.shiftKey&&(r="Shift-"+r),r}function of(r){return new Y({props:{handleKeyDown:cn(r)}})}function cn(r){let e=sf(r);return function(t,n){let i=Js(n),s,o=e[pr(i,n)];if(o&&o(t.state,t.dispatch,t))return!0;if(i.length==1&&i!=" "){if(n.shiftKey){let l=e[pr(i,n,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(nf&&n.ctrlKey&&n.altKey)&&(s=xe[n.keyCode])&&s!=i){let l=e[pr(s,n)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}var lo={};ie(lo,{autoJoin:()=>kf,baseKeymap:()=>Mf,chainCommands:()=>hn,createParagraphNear:()=>Zs,deleteSelection:()=>gr,exitCode:()=>_s,joinBackward:()=>Hs,joinDown:()=>cf,joinForward:()=>Ys,joinTextblockBackward:()=>lf,joinTextblockForward:()=>af,joinUp:()=>ff,lift:()=>hf,liftEmptyBlock:()=>eo,macBaseKeymap:()=>kr,newlineInCode:()=>Qs,pcBaseKeymap:()=>ce,selectAll:()=>no,selectNodeBackward:()=>js,selectNodeForward:()=>Xs,selectParentNode:()=>df,selectTextblockEnd:()=>oo,selectTextblockStart:()=>so,setBlockType:()=>gf,splitBlock:()=>Sr,splitBlockAs:()=>to,splitBlockKeepMarks:()=>uf,toggleMark:()=>bf,wrapIn:()=>mf});var gr=(r,e)=>r.selection.empty?!1:(e&&e(r.tr.deleteSelection().scrollIntoView()),!0);function $s(r,e){let{$cursor:t}=r.selection;return!t||(e?!e.endOfTextblock("backward",r):t.parentOffset>0)?null:t}var Hs=(r,e,t)=>{let n=$s(r,t);if(!n)return!1;let i=yr(n);if(!i){let o=n.blockRange(),l=o&&_e(o);return l==null?!1:(e&&e(r.tr.lift(o,l).scrollIntoView()),!0)}let s=i.nodeBefore;if(ro(r,i,e,-1))return!0;if(n.parent.content.size==0&&(at(s,"end")||k.isSelectable(s)))for(let o=n.depth;;o--){let l=et(r.doc,n.before(o),n.after(o),x.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=r.tr.step(l);a.setSelection(at(s,"end")?C.findFrom(a.doc.resolve(a.mapping.map(i.pos,-1)),-1):k.create(a.doc,i.pos-s.nodeSize)),e(a.scrollIntoView())}return!0}if(o==1||n.node(o-1).childCount>1)break}return s.isAtom&&i.depth==n.depth-1?(e&&e(r.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),!0):!1},lf=(r,e,t)=>{let n=$s(r,t);if(!n)return!1;let i=yr(n);return i?Us(r,i,e):!1},af=(r,e,t)=>{let n=Gs(r,t);if(!n)return!1;let i=xr(n);return i?Us(r,i,e):!1};function Us(r,e,t){let n=e.nodeBefore,i=n,s=e.pos-1;for(;!i.isTextblock;s--){if(i.type.spec.isolating)return!1;let c=i.lastChild;if(!c)return!1;i=c}let o=e.nodeAfter,l=o,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let c=l.firstChild;if(!c)return!1;l=c}let f=et(r.doc,s,a,x.empty);if(!f||f.from!=s||f instanceof V&&f.slice.size>=a-s)return!1;if(t){let c=r.tr.step(f);c.setSelection(M.create(c.doc,s)),t(c.scrollIntoView())}return!0}function at(r,e,t=!1){for(let n=r;n;n=e=="start"?n.firstChild:n.lastChild){if(n.isTextblock)return!0;if(t&&n.childCount!=1)return!1}return!1}var js=(r,e,t)=>{let{$head:n,empty:i}=r.selection,s=n;if(!i)return!1;if(n.parent.isTextblock){if(t?!t.endOfTextblock("backward",r):n.parentOffset>0)return!1;s=yr(n)}let o=s&&s.nodeBefore;return!o||!k.isSelectable(o)?!1:(e&&e(r.tr.setSelection(k.create(r.doc,s.pos-o.nodeSize)).scrollIntoView()),!0)};function yr(r){if(!r.parent.type.spec.isolating)for(let e=r.depth-1;e>=0;e--){if(r.index(e)>0)return r.doc.resolve(r.before(e+1));if(r.node(e).type.spec.isolating)break}return null}function Gs(r,e){let{$cursor:t}=r.selection;return!t||(e?!e.endOfTextblock("forward",r):t.parentOffset<t.parent.content.size)?null:t}var Ys=(r,e,t)=>{let n=Gs(r,t);if(!n)return!1;let i=xr(n);if(!i)return!1;let s=i.nodeAfter;if(ro(r,i,e,1))return!0;if(n.parent.content.size==0&&(at(s,"start")||k.isSelectable(s))){let o=et(r.doc,n.before(),n.after(),x.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=r.tr.step(o);l.setSelection(at(s,"start")?C.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):k.create(l.doc,l.mapping.map(i.pos))),e(l.scrollIntoView())}return!0}}return s.isAtom&&i.depth==n.depth-1?(e&&e(r.tr.delete(i.pos,i.pos+s.nodeSize).scrollIntoView()),!0):!1},Xs=(r,e,t)=>{let{$head:n,empty:i}=r.selection,s=n;if(!i)return!1;if(n.parent.isTextblock){if(t?!t.endOfTextblock("forward",r):n.parentOffset<n.parent.content.size)return!1;s=xr(n)}let o=s&&s.nodeAfter;return!o||!k.isSelectable(o)?!1:(e&&e(r.tr.setSelection(k.create(r.doc,s.pos)).scrollIntoView()),!0)};function xr(r){if(!r.parent.type.spec.isolating)for(let e=r.depth-1;e>=0;e--){let t=r.node(e);if(r.index(e)+1<t.childCount)return r.doc.resolve(r.after(e+1));if(t.type.spec.isolating)break}return null}var ff=(r,e)=>{let t=r.selection,n=t instanceof k,i;if(n){if(t.node.isTextblock||!ue(r.doc,t.from))return!1;i=t.from}else if(i=qt(r.doc,t.from,-1),i==null)return!1;if(e){let s=r.tr.join(i);n&&s.setSelection(k.create(s.doc,i-r.doc.resolve(i).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},cf=(r,e)=>{let t=r.selection,n;if(t instanceof k){if(t.node.isTextblock||!ue(r.doc,t.to))return!1;n=t.to}else if(n=qt(r.doc,t.to,1),n==null)return!1;return e&&e(r.tr.join(n).scrollIntoView()),!0},hf=(r,e)=>{let{$from:t,$to:n}=r.selection,i=t.blockRange(n),s=i&&_e(i);return s==null?!1:(e&&e(r.tr.lift(i,s).scrollIntoView()),!0)},Qs=(r,e)=>{let{$head:t,$anchor:n}=r.selection;return!t.parent.type.spec.code||!t.sameParent(n)?!1:(e&&e(r.tr.insertText(`
12
+ `).scrollIntoView()),!0)};function br(r){for(let e=0;e<r.edgeCount;e++){let{type:t}=r.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}var _s=(r,e)=>{let{$head:t,$anchor:n}=r.selection;if(!t.parent.type.spec.code||!t.sameParent(n))return!1;let i=t.node(-1),s=t.indexAfter(-1),o=br(i.contentMatchAt(s));if(!o||!i.canReplaceWith(s,s,o))return!1;if(e){let l=t.after(),a=r.tr.replaceWith(l,l,o.createAndFill());a.setSelection(C.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Zs=(r,e)=>{let t=r.selection,{$from:n,$to:i}=t;if(t instanceof j||n.parent.inlineContent||i.parent.inlineContent)return!1;let s=br(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let o=(!n.parentOffset&&i.index()<i.parent.childCount?n:i).pos,l=r.tr.insert(o,s.createAndFill());l.setSelection(M.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},eo=(r,e)=>{let{$cursor:t}=r.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let s=t.before();if(Ze(r.doc,s))return e&&e(r.tr.split(s).scrollIntoView()),!0}let n=t.blockRange(),i=n&&_e(n);return i==null?!1:(e&&e(r.tr.lift(n,i).scrollIntoView()),!0)};function to(r){return(e,t)=>{if(e.selection instanceof k&&e.selection.node.isBlock){let{$from:d}=e.selection;return!d.parentOffset||!Ze(e.doc,d.pos)?!1:(t&&t(e.tr.split(d.pos).scrollIntoView()),!0)}if(!e.selection.$from.depth)return!1;let n=e.tr;!e.selection.empty&&(e.selection instanceof M||e.selection instanceof j)&&n.deleteSelection();let{$from:i}=n.selection,s=n.steps.length,o=[],l,a,f=!1,c=!1;for(let d=i.depth;;d--)if(i.node(d).isBlock){f=i.end(d)==i.pos+(i.depth-d),c=i.start(d)==i.pos-(i.depth-d),a=br(i.node(d-1).contentMatchAt(i.indexAfter(d-1)));let m=r&&r(i.parent,f,i);o.unshift(m||(f&&a?{type:a}:null)),l=d;break}else{if(d==1)return!1;o.unshift(null)}let h=i.pos,u=Ze(n.doc,h,o.length,o);if(u||(o[0]=a?{type:a}:null,u=Ze(n.doc,h,o.length,o)),!u)return!1;if(n.split(h,o.length,o),!f&&c&&i.node(l).type!=a){let d=n.mapping.slice(s),p=d.map(i.before(l)),m=n.doc.resolve(p);a&&i.node(l-1).canReplaceWith(m.index(),m.index()+1,a)&&n.setNodeMarkup(d.map(i.before(l)),a)}return t&&t(n.scrollIntoView()),!0}}var Sr=to(),uf=(r,e)=>Sr(r,e&&(t=>{let n=r.storedMarks||r.selection.$to.parentOffset&&r.selection.$from.marks();n&&t.ensureMarks(n),e(t)})),df=(r,e)=>{let{$from:t,to:n}=r.selection,i,s=t.sharedDepth(n);return s==0?!1:(i=t.before(s),e&&e(r.tr.setSelection(k.create(r.doc,i))),!0)},no=(r,e)=>(e&&e(r.tr.setSelection(new j(r.doc))),!0);function pf(r,e,t){let n=e.nodeBefore,i=e.nodeAfter,s=e.index();return!n||!i||!n.type.compatibleContent(i.type)?!1:!n.content.size&&e.parent.canReplace(s-1,s)?(t&&t(r.tr.delete(e.pos-n.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(i.isTextblock||ue(r.doc,e.pos))?!1:(t&&t(r.tr.join(e.pos).scrollIntoView()),!0)}function ro(r,e,t,n){let i=e.nodeBefore,s=e.nodeAfter,o,l,a=i.type.spec.isolating||s.type.spec.isolating;if(!a&&pf(r,e,t))return!0;let f=!a&&e.parent.canReplace(e.index(),e.index()+1);if(f&&(o=(l=i.contentMatchAt(i.childCount)).findWrapping(s.type))&&l.matchType(o[0]||s.type).validEnd){if(t){let d=e.pos+s.nodeSize,p=y.empty;for(let b=o.length-1;b>=0;b--)p=y.from(o[b].create(null,p));p=y.from(i.copy(p));let m=r.tr.step(new U(e.pos-1,d,e.pos,d,new x(p,1,0),o.length,!0)),g=m.doc.resolve(d+2*o.length);g.nodeAfter&&g.nodeAfter.type==i.type&&ue(m.doc,g.pos)&&m.join(g.pos),t(m.scrollIntoView())}return!0}let c=s.type.spec.isolating||n>0&&a?null:C.findFrom(e,1),h=c&&c.$from.blockRange(c.$to),u=h&&_e(h);if(u!=null&&u>=e.depth)return t&&t(r.tr.lift(h,u).scrollIntoView()),!0;if(f&&at(s,"start",!0)&&at(i,"end")){let d=i,p=[];for(;p.push(d),!d.isTextblock;)d=d.lastChild;let m=s,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(d.canReplace(d.childCount,d.childCount,m.content)){if(t){let b=y.empty;for(let N=p.length-1;N>=0;N--)b=y.from(p[N].copy(b));let D=r.tr.step(new U(e.pos-p.length,e.pos+s.nodeSize,e.pos+g,e.pos+s.nodeSize-g,new x(b,p.length,0),0,!0));t(D.scrollIntoView())}return!0}}return!1}function io(r){return function(e,t){let n=e.selection,i=r<0?n.$from:n.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return i.node(s).isTextblock?(t&&t(e.tr.setSelection(M.create(e.doc,r<0?i.start(s):i.end(s)))),!0):!1}}var so=io(-1),oo=io(1);function mf(r,e=null){return function(t,n){let{$from:i,$to:s}=t.selection,o=i.blockRange(s),l=o&&bt(o,r,e);return l?(n&&n(t.tr.wrap(o,l).scrollIntoView()),!0):!1}}function gf(r,e=null){return function(t,n){let i=!1;for(let s=0;s<t.selection.ranges.length&&!i;s++){let{$from:{pos:o},$to:{pos:l}}=t.selection.ranges[s];t.doc.nodesBetween(o,l,(a,f)=>{if(i)return!1;if(!(!a.isTextblock||a.hasMarkup(r,e)))if(a.type==r)i=!0;else{let c=t.doc.resolve(f),h=c.index();i=c.parent.canReplaceWith(h,h+1,r)}})}if(!i)return!1;if(n){let s=t.tr;for(let o=0;o<t.selection.ranges.length;o++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[o];s.setBlockType(l,a,r,e)}n(s.scrollIntoView())}return!0}}function yf(r,e,t,n){for(let i=0;i<e.length;i++){let{$from:s,$to:o}=e[i],l=s.depth==0?r.inlineContent&&r.type.allowsMarkType(t):!1;if(r.nodesBetween(s.pos,o.pos,(a,f)=>{if(l||!n&&a.isAtom&&a.isInline&&f>=s.pos&&f+a.nodeSize<=o.pos)return!1;l=a.inlineContent&&a.type.allowsMarkType(t)}),l)return!0}return!1}function xf(r){let e=[];for(let t=0;t<r.length;t++){let{$from:n,$to:i}=r[t];n.doc.nodesBetween(n.pos,i.pos,(s,o)=>{if(s.isAtom&&s.content.size&&s.isInline&&o>=n.pos&&o+s.nodeSize<=i.pos)return o+1>n.pos&&e.push(new Pe(n,n.doc.resolve(o+1))),n=n.doc.resolve(o+1+s.content.size),!1}),n.pos<i.pos&&e.push(new Pe(n,i))}return e}function bf(r,e=null,t){let n=(t&&t.removeWhenPresent)!==!1,i=(t&&t.enterInlineAtoms)!==!1,s=!(t&&t.includeWhitespace);return function(o,l){let{empty:a,$cursor:f,ranges:c}=o.selection;if(a&&!f||!yf(o.doc,c,r,i))return!1;if(l)if(f)r.isInSet(o.storedMarks||f.marks())?l(o.tr.removeStoredMark(r)):l(o.tr.addStoredMark(r.create(e)));else{let h,u=o.tr;i||(c=xf(c)),n?h=!c.some(d=>o.doc.rangeHasMark(d.$from.pos,d.$to.pos,r)):h=!c.every(d=>{let p=!1;return u.doc.nodesBetween(d.$from.pos,d.$to.pos,(m,g,b)=>{if(p)return!1;p=!r.isInSet(m.marks)&&!!b&&b.type.allowsMarkType(r)&&!(m.isText&&/^\s*$/.test(m.textBetween(Math.max(0,d.$from.pos-g),Math.min(m.nodeSize,d.$to.pos-g))))}),!p});for(let d=0;d<c.length;d++){let{$from:p,$to:m}=c[d];if(!h)u.removeMark(p.pos,m.pos,r);else{let g=p.pos,b=m.pos,D=p.nodeAfter,N=m.nodeBefore,re=s&&D&&D.isText?/^\s*/.exec(D.text)[0].length:0,De=s&&N&&N.isText?/\s*$/.exec(N.text)[0].length:0;g+re<b&&(g+=re,b-=De),u.addMark(g,b,r.create(e))}}l(u.scrollIntoView())}return!0}}function Sf(r,e){return t=>{if(!t.isGeneric)return r(t);let n=[];for(let s=0;s<t.mapping.maps.length;s++){let o=t.mapping.maps[s];for(let l=0;l<n.length;l++)n[l]=o.map(n[l]);o.forEach((l,a,f,c)=>n.push(f,c))}let i=[];for(let s=0;s<n.length;s+=2){let o=n[s],l=n[s+1],a=t.doc.resolve(o),f=a.sharedDepth(l),c=a.node(f);for(let h=a.indexAfter(f),u=a.after(f+1);u<=l;++h){let d=c.maybeChild(h);if(!d)break;if(h&&i.indexOf(u)==-1){let p=c.child(h-1);p.type==d.type&&e(p,d)&&i.push(u)}u+=d.nodeSize}}i.sort((s,o)=>s-o);for(let s=i.length-1;s>=0;s--)ue(t.doc,i[s])&&t.join(i[s]);r(t)}}function kf(r,e){let t=Array.isArray(e)?n=>e.indexOf(n.type.name)>-1:e;return(n,i,s)=>r(n,i&&Sf(i,t),s)}function hn(...r){return function(e,t,n){for(let i=0;i<r.length;i++)if(r[i](e,t,n))return!0;return!1}}var mr=hn(gr,Hs,js),Ks=hn(gr,Ys,Xs),ce={Enter:hn(Qs,Zs,eo,Sr),"Mod-Enter":_s,Backspace:mr,"Mod-Backspace":mr,"Shift-Backspace":mr,Delete:Ks,"Mod-Delete":Ks,"Mod-a":no},kr={"Ctrl-h":ce.Backspace,"Alt-Backspace":ce["Mod-Backspace"],"Ctrl-d":ce.Delete,"Ctrl-Alt-Backspace":ce["Mod-Delete"],"Alt-Delete":ce["Mod-Delete"],"Alt-d":ce["Mod-Delete"],"Ctrl-a":so,"Ctrl-e":oo};for(let r in ce)kr[r]=ce[r];var Cf=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,Mf=Cf?kr:ce;var po={};ie(po,{InputRule:()=>ne,closeDoubleQuote:()=>co,closeSingleQuote:()=>uo,ellipsis:()=>Ef,emDash:()=>Tf,inputRules:()=>Nf,openDoubleQuote:()=>fo,openSingleQuote:()=>ho,smartQuotes:()=>Af,textblockTypeInputRule:()=>Rf,undoInputRule:()=>Df,wrappingInputRule:()=>If});var ne=class{constructor(e,t,n={}){this.match=e,this.match=e,this.handler=typeof t=="string"?Of(t):t,this.undoable=n.undoable!==!1,this.inCode=n.inCode||!1,this.inCodeMark=n.inCodeMark!==!1}};function Of(r){return function(e,t,n,i){let s=r;if(t[1]){let o=t[0].lastIndexOf(t[1]);s+=t[0].slice(o+t[1].length),n+=o;let l=n-i;l>0&&(s=t[0].slice(o-l,o)+s,n=i)}return e.tr.insertText(s,n,i)}}var wf=500;function Nf({rules:r}){let e=new Y({state:{init(){return null},apply(t,n){let i=t.getMeta(this);return i||(t.selectionSet||t.docChanged?null:n)}},props:{handleTextInput(t,n,i,s){return ao(t,n,i,s,r,e)},handleDOMEvents:{compositionend:t=>{setTimeout(()=>{let{$cursor:n}=t.state.selection;n&&ao(t,n.pos,n.pos,"",r,e)})}}},isInputRules:!0});return e}function ao(r,e,t,n,i,s){if(r.composing)return!1;let o=r.state,l=o.doc.resolve(e),a=l.parent.textBetween(Math.max(0,l.parentOffset-wf),l.parentOffset,null,"\uFFFC")+n;for(let f=0;f<i.length;f++){let c=i[f];if(!c.inCodeMark&&l.marks().some(p=>p.type.spec.code))continue;if(l.parent.type.spec.code){if(!c.inCode)continue}else if(c.inCode==="only")continue;let h=c.match.exec(a);if(!h||h[0].length<n.length)continue;let u=e-(h[0].length-n.length);if(!c.inCodeMark){let p=!1;if(o.doc.nodesBetween(u,l.pos,m=>{m.isInline&&m.marks.some(g=>g.type.spec.code)&&(p=!0)}),p)continue}let d=c.handler(o,h,u,t);if(d)return c.undoable&&d.setMeta(s,{transform:d,from:e,to:t,text:n}),r.dispatch(d),!0}return!1}var Df=(r,e)=>{let t=r.plugins;for(let n=0;n<t.length;n++){let i=t[n],s;if(i.spec.isInputRules&&(s=i.getState(r))){if(e){let o=r.tr,l=s.transform;for(let a=l.steps.length-1;a>=0;a--)o.step(l.steps[a].invert(l.docs[a]));if(s.text){let a=o.doc.resolve(s.from).marks();o.replaceWith(s.from,s.to,r.schema.text(s.text,a))}else o.delete(s.from,s.to);e(o)}return!0}}return!1},Tf=new ne(/--$/,"\u2014",{inCodeMark:!1}),Ef=new ne(/\.\.\.$/,"\u2026",{inCodeMark:!1}),fo=new ne(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"\u201C",{inCodeMark:!1}),co=new ne(/"$/,"\u201D",{inCodeMark:!1}),ho=new ne(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"\u2018",{inCodeMark:!1}),uo=new ne(/'$/,"\u2019",{inCodeMark:!1}),Af=[fo,co,ho,uo];function If(r,e,t=null,n){return new ne(r,(i,s,o,l)=>{let a=t instanceof Function?t(s):t,f=i.tr.delete(o,l),c=f.doc.resolve(o),h=c.blockRange(),u=h&&bt(h,e,a);if(!u)return null;f.wrap(h,u);let d=f.doc.resolve(o-1).nodeBefore;return d&&d.type==e&&ue(f.doc,o-1)&&(!n||n(s,d))&&f.join(o-1),f})}function Rf(r,e,t=null){return new ne(r,(n,i,s,o)=>{let l=n.doc.resolve(s),a=t instanceof Function?t(i):t;return l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),e)?n.tr.delete(s,o).setBlockType(s,s,e,a):null})}var mo={};ie(mo,{dropCursor:()=>Pf});function Pf(r={}){return new Y({view(e){return new Cr(e,r)}})}var Cr=class{constructor(e,t){var n;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=(n=t.width)!==null&&n!==void 0?n:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let s=o=>{this[i](o)};return e.dom.addEventListener(i,s),{name:i,handler:s}})}destroy(){this.setCursor(null),this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){if(this.cursorPos!=null&&t.doc!=e.state.doc)if(this.lastDragEvent){let n=this.computeTarget(this.lastDragEvent);n==this.cursorPos?this.updateOverlay():this.setCursor(n)}else this.updateOverlay()}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,n,i=this.editorView.dom,s=i.getBoundingClientRect(),o=s.width/i.offsetWidth,l=s.height/i.offsetHeight;if(t){let h=e.nodeBefore,u=e.nodeAfter;if(h||u){let d=this.editorView.nodeDOM(this.cursorPos-(h?h.nodeSize:0));if(d){let p=d.getBoundingClientRect(),m=h?p.bottom:p.top;h&&u&&(m=(m+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let g=this.width/2*l;n={left:p.left,right:p.right,top:m-g,bottom:m+g}}}}if(!n){let h=this.editorView.coordsAtPos(this.cursorPos),u=this.width/2*o;n={left:h.left-u,right:h.left+u,top:h.top,bottom:h.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let f,c;if(!a||a==document.body&&getComputedStyle(a).position=="static")f=-pageXOffset,c=-pageYOffset;else{let h=a.getBoundingClientRect(),u=h.width/a.offsetWidth,d=h.height/a.offsetHeight;f=h.left-a.scrollLeft*u,c=h.top-a.scrollTop*d}this.element.style.left=(n.left-f)/o+"px",this.element.style.top=(n.top-c)/l+"px",this.element.style.width=(n.right-n.left)/o+"px",this.element.style.height=(n.bottom-n.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}computeTarget(e){let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),i=n&&n.type.spec.disableDropCursor,s=typeof i=="function"?i(this.editorView,t,e):i;if(!t||s)return null;let o=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=St(this.editorView.state.doc,o,this.editorView.dragging.slice);l!=null&&(o=l)}return o}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let t=this.computeTarget(e);t!=null&&(this.setCursor(t),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}};var yo={};ie(yo,{GapCursor:()=>F,gapCursor:()=>Ff});var F=class r extends C{constructor(e){super(e,e)}map(e,t){let n=e.resolve(t.map(this.head));return r.valid(n)?new r(n):C.near(n)}content(){return x.empty}eq(e){return e instanceof r&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new r(e.resolve(t.pos))}getBookmark(){return new Mr(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!Bf(e)||!zf(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let i=t.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,t,n=!1){e:for(;;){if(!n&&r.valid(e))return e;let i=e.pos,s=null;for(let o=e.depth;;o--){let l=e.node(o);if(t>0?e.indexAfter(o)<l.childCount:e.index(o)>0){s=l.child(t>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;i+=t;let a=e.doc.resolve(i);if(r.valid(a))return a}for(;;){let o=t>0?s.firstChild:s.lastChild;if(!o){if(s.isAtom&&!s.isText&&!k.isSelectable(s)){e=e.doc.resolve(i+s.nodeSize*t),n=!1;continue e}break}s=o,i+=t;let l=e.doc.resolve(i);if(r.valid(l))return l}return null}}};F.prototype.visible=!1;F.findFrom=F.findGapCursorFrom;C.jsonID("gapcursor",F);var Mr=class r{constructor(e){this.pos=e}map(e){return new r(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return F.valid(t)?new F(t):C.near(t)}};function go(r){return r.isAtom||r.spec.isolating||r.spec.createGapCursor}function Bf(r){for(let e=r.depth;e>=0;e--){let t=r.index(e),n=r.node(e);if(t==0){if(n.type.spec.isolating)return!0;continue}for(let i=n.child(t-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||go(i.type))return!0;if(i.inlineContent)return!1}}return!0}function zf(r){for(let e=r.depth;e>=0;e--){let t=r.indexAfter(e),n=r.node(e);if(t==n.childCount){if(n.type.spec.isolating)return!0;continue}for(let i=n.child(t);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||go(i.type))return!0;if(i.inlineContent)return!1}}return!0}function Ff(){return new Y({props:{decorations:Wf,createSelectionBetween(r,e,t){return e.pos==t.pos&&F.valid(t)?new F(t):null},handleClick:Vf,handleKeyDown:vf,handleDOMEvents:{beforeinput:Lf}}})}var vf=cn({ArrowLeft:un("horiz",-1),ArrowRight:un("horiz",1),ArrowUp:un("vert",-1),ArrowDown:un("vert",1)});function un(r,e){let t=r=="vert"?e>0?"down":"up":e>0?"right":"left";return function(n,i,s){let o=n.selection,l=e>0?o.$to:o.$from,a=o.empty;if(o instanceof M){if(!s.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=n.doc.resolve(e>0?l.after():l.before())}let f=F.findGapCursorFrom(l,e,a);return f?(i&&i(n.tr.setSelection(new F(f))),!0):!1}}function Vf(r,e,t){if(!r||!r.editable)return!1;let n=r.state.doc.resolve(e);if(!F.valid(n))return!1;let i=r.posAtCoords({left:t.clientX,top:t.clientY});return i&&i.inside>-1&&k.isSelectable(r.state.doc.nodeAt(i.inside))?!1:(r.dispatch(r.state.tr.setSelection(new F(n))),!0)}function Lf(r,e){if(e.inputType!="insertCompositionText"||!(r.state.selection instanceof F))return!1;let{$from:t}=r.state.selection,n=t.parent.contentMatchAt(t.index()).findWrapping(r.state.schema.nodes.text);if(!n)return!1;let i=y.empty;for(let o=n.length-1;o>=0;o--)i=y.from(n[o].createAndFill(null,i));let s=r.state.tr.replace(t.pos,t.pos,new x(i,0,0));return s.setSelection(M.near(s.doc.resolve(t.pos+1))),r.dispatch(s),!1}function Wf(r){if(!(r.selection instanceof F))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",q.create(r.doc,[te.widget(r.selection.head,e,{key:"gapcursor"})])}export{lo as commands,mo as dropcursor,yo as gapcursor,Ws as history,po as inputrules,qs as keymap,Qr as model,Oi as state,mi as transform,Ps as view};