1 line
206 KiB
JavaScript
1 line
206 KiB
JavaScript
System.register([],function(e,t){var n,r,i,o,s,l,a,h,c,d,p,f,u,m,g,y,w,v,x,k,b,S,C,M,O,N,T,D,E,A,R,I,z,P,$,B,V,F,L,J,W,q,K,j,_,H,U,G,Y,X,Q,Z,ee,te,ne,re,ie,oe,se,le,ae,he,ce,de,pe,fe,ue,me,ge,ye,we,ve,xe,ke,be,Se,Ce,Me,Oe,Ne,Te,De,Ee,Ae,Re,Ie,ze,Pe,$e,Be,Ve,Fe,Le,Je,We,qe,Ke,je,_e,He,Ue,Ge,Ye,Xe,Qe,Ze,et,tt,nt,rt,it,ot,st,lt,at,ht,ct,dt,pt,ft,ut,mt,gt,yt,wt,vt,xt,kt,bt,St,Ct,Mt,Ot,Nt,Tt,Dt,Et,At,Rt,It,zt,Pt,$t,Bt,Vt,Ft,Lt,Jt,Wt,qt,Kt,jt,_t,Ht,Ut,Gt,Yt,Xt,Qt,Zt,en,tn,nn,rn,on,sn,ln,an,hn,cn,dn,pn,fn,un,mn,gn,yn,wn,vn,xn,kn,bn,Sn,Cn,Mn;function On(e){this.content=e}function Nn(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),o=t.child(r);if(i!=o){if(!i.sameMarkup(o))return n;if(i.isText&&i.text!=o.text){for(let e=0;i.text[e]==o.text[e];e++)n++;return n}if(i.content.size||o.content.size){let e=Nn(i.content,o.content,n+1);if(null!=e)return e}n+=i.nodeSize}else n+=i.nodeSize}}function Tn(e,t,n,r){for(let i=e.childCount,o=t.childCount;;){if(0==i||0==o)return i==o?null:{a:n,b:r};let s=e.child(--i),l=t.child(--o),a=s.nodeSize;if(s!=l){if(!s.sameMarkup(l))return{a:n,b:r};if(s.isText&&s.text!=l.text){let e=0,t=Math.min(s.text.length,l.text.length);for(;e<t&&s.text[s.text.length-e-1]==l.text[l.text.length-e-1];)e++,n--,r--;return{a:n,b:r}}if(s.content.size||l.content.size){let e=Tn(s.content,l.content,n-1,r-1);if(e)return e}n-=a,r-=a}else n-=a,r-=a}}function Dn(e,t){return r.index=e,r.offset=t,r}function En(e,t){if(e===t)return!0;if(!e||"object"!=typeof e||!t||"object"!=typeof t)return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!En(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!En(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}function An(e,t,n){let{index:r,offset:i}=e.findIndex(t),o=e.maybeChild(r),{index:s,offset:l}=e.findIndex(n);if(i==t||o.isText){if(l!=n&&!e.child(s).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(n))}if(r!=s)throw new RangeError("Removing non-flat range");return e.replaceChild(r,o.copy(An(o.content,t-i-1,n-i-1)))}function Rn(e,t,n,r){let{index:i,offset:o}=e.findIndex(t),s=e.maybeChild(i);if(o==t||s.isText)return r&&!r.canReplace(i,i,n)?null:e.cut(0,t).append(n).append(e.cut(t));let l=Rn(s.content,t-o-1,n,s);return l&&e.replaceChild(i,s.copy(l))}function In(e,t,n){if(n.openStart>e.depth)throw new o("Inserted content deeper than insertion position");if(e.depth-n.openStart!=t.depth-n.openEnd)throw new o("Inconsistent open depths");return zn(e,t,n,0)}function zn(e,t,r,i){let o=e.index(i),s=e.node(i);if(o==t.index(i)&&i<e.depth-r.openStart){let n=zn(e,t,r,i+1);return s.copy(s.content.replaceChild(o,n))}if(r.content.size){if(r.openStart||r.openEnd||e.depth!=i||t.depth!=i){let{start:o,end:l}=function(e,t){let r=t.depth-e.openStart,i=t.node(r).copy(e.content);for(let o=r-1;o>=0;o--)i=t.node(o).copy(n.from(i));return{start:i.resolveNoCache(e.openStart+r),end:i.resolveNoCache(i.content.size-e.openEnd-r)}}(r,e);return Fn(s,Ln(e,o,l,t,i))}{let n=e.parent,i=n.content;return Fn(n,i.cut(0,e.parentOffset).append(r.content).append(i.cut(t.parentOffset)))}}return Fn(s,Jn(e,t,i))}function Pn(e,t){if(!t.type.compatibleContent(e.type))throw new o("Cannot join "+t.type.name+" onto "+e.type.name)}function $n(e,t,n){let r=e.node(n);return Pn(r,t.node(n)),r}function Bn(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function Vn(e,t,n,r){let i=(t||e).node(n),o=0,s=t?t.index(n):i.childCount;e&&(o=e.index(n),e.depth>n?o++:e.textOffset&&(Bn(e.nodeAfter,r),o++));for(let l=o;l<s;l++)Bn(i.child(l),r);t&&t.depth==n&&t.textOffset&&Bn(t.nodeBefore,r)}function Fn(e,t){return e.type.checkContent(t),e.copy(t)}function Ln(e,t,r,i,o){let s=e.depth>o&&$n(e,t,o+1),l=i.depth>o&&$n(r,i,o+1),a=[];return Vn(null,e,o,a),s&&l&&t.index(o)==r.index(o)?(Pn(s,l),Bn(Fn(s,Ln(e,t,r,i,o+1)),a)):(s&&Bn(Fn(s,Jn(e,t,o+1)),a),Vn(t,r,o,a),l&&Bn(Fn(l,Jn(r,i,o+1)),a)),Vn(i,null,o,a),new n(a)}function Jn(e,t,r){let i=[];return Vn(null,e,r,i),e.depth>r&&Bn(Fn($n(e,t,r+1),Jn(e,t,r+1)),i),Vn(t,null,r,i),new n(i)}function Wn(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}function qn(e){let t=[];do{t.push(Kn(e))}while(e.eat("|"));return 1==t.length?t[0]:{type:"choice",exprs:t}}function Kn(e){let t=[];do{t.push(jn(e))}while(e.next&&")"!=e.next&&"|"!=e.next);return 1==t.length?t[0]:{type:"seq",exprs:t}}function jn(e){let t=function(e){if(e.eat("(")){let t=qn(e);return e.eat(")")||e.err("Missing closing paren"),t}if(!/\W/.test(e.next)){let t=function(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let i=[];for(let o in n){let e=n[o];e.isInGroup(t)&&i.push(e)}return 0==i.length&&e.err("No node type or group '"+t+"' found"),i}(e,e.next).map(t=>(null==e.inline?e.inline=t.isInline:e.inline!=t.isInline&&e.err("Mixing inline and block content"),{type:"name",value:t}));return e.pos++,1==t.length?t[0]:{type:"choice",exprs:t}}e.err("Unexpected token '"+e.next+"'")}(e);for(;;)if(e.eat("+"))t={type:"plus",expr:t};else if(e.eat("*"))t={type:"star",expr:t};else if(e.eat("?"))t={type:"opt",expr:t};else{if(!e.eat("{"))break;t=Hn(e,t)}return t}function _n(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");let t=Number(e.next);return e.pos++,t}function Hn(e,t){let n=_n(e),r=n;return e.eat(",")&&(r="}"!=e.next?_n(e):-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:t}}function Un(e,t){return t-e}function Gn(e,t){let n=[];return function t(r){let i=e[r];if(1==i.length&&!i[0].term)return t(i[0].to);n.push(r);for(let e=0;e<i.length;e++){let{term:r,to:o}=i[e];r||-1!=n.indexOf(o)||t(o)}}(t),n.sort(Un)}function Yn(e){let t=Object.create(null);return function n(r){let i=[];r.forEach(t=>{e[t].forEach(({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e<i.length;e++)i[e][0]==t&&(r=i[e][1]);Gn(e,n).forEach(e=>{r||i.push([t,r=[]]),-1==r.indexOf(e)&&r.push(e)})})});let o=t[r.join(",")]=new m(r.indexOf(e.length-1)>-1);for(let e=0;e<i.length;e++){let r=i[e][1].sort(Un);o.next.push({type:i[e][0],next:t[r.join(",")]||n(r)})}return o}(Gn(e,0))}function Xn(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function Qn(e,t){let n=Object.create(null);for(let r in e){let i=t&&t[r];if(void 0===i){let t=e[r];if(!t.hasDefault)throw new RangeError("No value supplied for attribute "+r);i=t.default}n[r]=i}return n}function Zn(e,t,n,r){for(let i in t)if(!(i in e))throw new RangeError(`Unsupported attribute ${i} for ${n} of type ${i}`);for(let i in e){let n=e[i];n.validate&&n.validate(t[i])}}function er(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new w(e,r,t[r]);return n}function tr(e,t){let n=[];for(let r=0;r<t.length;r++){let i=t[r],o=e.marks[i],s=o;if(o)n.push(o);else for(let t in e.marks){let r=e.marks[t];("_"==i||r.spec.group&&r.spec.group.split(" ").indexOf(i)>-1)&&n.push(s=r)}if(!s)throw new SyntaxError("Unknown mark type: '"+t[r]+"'")}return n}function nr(e,t,n){return null!=t?(t?C:0)|("full"===t?M:0):e&&"pre"==e.whitespace?C|M:n&~O}function rr(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function ir(e){let t={};for(let n in e)t[n]=e[n];return t}function or(e,t){let n=t.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(e))continue;let o=[],s=e=>{o.push(e);for(let n=0;n<e.edgeCount;n++){let{type:r,next:i}=e.edge(n);if(r==t)return!0;if(o.indexOf(i)<0&&s(i))return!0}};if(s(i.contentMatch))return!0}}function sr(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function lr(e){return e.document||window.document}function ar(e){let t=E.get(e);return void 0===t&&E.set(e,t=function(e){let t=null;function n(e){if(e&&"object"==typeof e)if(Array.isArray(e))if("string"==typeof e[0])t||(t=[]),t.push(e);else for(let t=0;t<e.length;t++)n(e[t]);else for(let t in e)n(e[t])}return n(e),t}(e)),t}function hr(e,t,n,r){if("string"==typeof t)return{dom:e.createTextNode(t)};if(null!=t.nodeType)return{dom:t};if(t.dom&&null!=t.dom.nodeType)return t;let i,o=t[0];if("string"!=typeof o)throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=ar(r))&&i.indexOf(t)>-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 s,l=o.indexOf(" ");l>0&&(n=o.slice(0,l),o=o.slice(l+1));let a=n?e.createElementNS(n,o):e.createElement(o),h=t[1],c=1;if(h&&"object"==typeof h&&null==h.nodeType&&!Array.isArray(h)){c=2;for(let e in h)if(null!=h[e]){let t=e.indexOf(" ");t>0?a.setAttributeNS(e.slice(0,t),e.slice(t+1),h[e]):"style"==e&&a.style?a.style.cssText=h[e]:a.setAttribute(e,h[e])}}for(let d=c;d<t.length;d++){let i=t[d];if(0===i){if(d<t.length-1||d>c)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}{let{dom:t,contentDOM:o}=hr(e,i,n,r);if(a.appendChild(t),o){if(s)throw new RangeError("Multiple content holes");s=o}}}return{dom:a,contentDOM:s}}function cr(e,t){return e+t*R}function dr(e){return e&A}function pr(e,t,r){let i=[];for(let n=0;n<e.childCount;n++){let o=e.child(n);o.content.size&&(o=o.copy(pr(o.content,t,o))),o.isInline&&(o=t(o,r,n)),i.push(o)}return n.fromArray(i)}function fr(e,t,n){let r=e.resolve(t),i=n-t,o=r.depth;for(;i>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,i--;if(i>0){let e=r.node(o).maybeChild(r.indexAfter(o));for(;i>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,i--}}return!1}function ur(e,t,r,i=r.contentMatch,o=!0){let l=e.doc.nodeAt(t),a=[],h=t+1;for(let c=0;c<l.childCount;c++){let t=l.child(c),d=h+t.nodeSize,p=i.matchType(t.type);if(p){i=p;for(let n=0;n<t.marks.length;n++)r.allowsMarkType(t.marks[n].type)||e.step(new L(h,d,t.marks[n]));if(o&&t.isText&&"pre"!=r.whitespace){let e,i,o=/\r?\n|\r/g;for(;e=o.exec(t.text);)i||(i=new s(n.from(r.schema.text(" ",r.allowedMarks(t.marks))),0,0)),a.push(new q(h+e.index,h+e.index+e[0].length,i))}}else a.push(new q(h,d,s.empty));h=d}if(!i.validEnd){let t=i.fillBefore(n.empty,!0);e.replace(h,h,new s(t,0,0))}for(let n=a.length-1;n>=0;n--)e.step(a[n])}function mr(e,t,n){return(0==t||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function gr(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,i=0;;--n){let o=e.$from.node(n),s=e.$from.index(n)+r,l=e.$to.indexAfter(n)-i;if(n<e.depth&&o.canReplace(s,l,t))return n;if(0==n||o.type.spec.isolating||!mr(o,s,l))break;s&&(r=1),l<o.childCount&&(i=1)}return null}function yr(e,t,n=null,r=e){let i=function(e,t){let{parent:n,startIndex:r,endIndex:i}=e,o=n.contentMatchAt(r).findWrapping(t);if(!o)return null;let s=o.length?o[0]:t;return n.canReplaceWith(r,i,s)?o:null}(e,t),o=i&&function(e,t){let{parent:n,startIndex:r,endIndex:i}=e,o=n.child(r),s=t.contentMatch.findWrapping(o.type);if(!s)return null;let l=(s.length?s[s.length-1]:t).contentMatch;for(let a=r;l&&a<i;a++)l=l.matchType(n.child(a).type);return l&&l.validEnd?s:null}(r,t);return o?i.map(wr).concat({type:t,attrs:n}).concat(o.map(wr)):null}function wr(e){return{type:e,attrs:null}}function vr(e,t,n,r){t.forEach((i,o)=>{if(i.isText){let s,l=/\r?\n|\r/g;for(;s=l.exec(i.text);){let i=e.mapping.slice(r).map(n+1+o+s.index);e.replaceWith(i,i+1,t.type.schema.linebreakReplacement.create())}}})}function xr(e,t,n,r){t.forEach((i,o)=>{if(i.type==i.type.schema.linebreakReplacement){let i=e.mapping.slice(r).map(n+1+o);e.replaceWith(i,i+1,t.type.schema.text("\n"))}})}function kr(e,t,n=1,r){let i=e.resolve(t),o=i.depth-n,s=r&&r[r.length-1]||i.parent;if(o<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!s.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let h=i.depth-1,c=n-2;h>o;h--,c--){let e=i.node(h),t=i.index(h);if(e.type.spec.isolating)return!1;let n=e.content.cutByIndex(t,e.childCount),o=r&&r[c+1];o&&(n=n.replaceChild(0,o.type.create(o.attrs)));let s=r&&r[c]||e;if(!e.canReplace(t+1,e.childCount)||!s.type.validContent(n))return!1}let l=i.indexAfter(o),a=r&&r[0];return i.node(o).canReplaceWith(l,l,a?a.type:i.node(o+1).type)}function br(e,t){let n=e.resolve(t),r=n.index();return i=n.nodeBefore,o=n.nodeAfter,!(!i||!o||i.isLeaf||!function(e,t){t.content.size||e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:r}=e.type.schema;for(let i=0;i<t.childCount;i++){let o=t.child(i),s=o.type==r?e.type.schema.nodes.text:o.type;if(n=n.matchType(s),!n)return!1;if(!e.type.allowsMarks(o.marks))return!1}return n.validEnd}(i,o))&&n.parent.canReplace(r,r+1);var i,o}function Sr(e,t,n=t,r=s.empty){if(t==n&&!r.size)return null;let i=e.resolve(t),o=e.resolve(n);return Cr(i,o,r)?new q(t,n,r):new j(i,o,r).fit()}function Cr(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}function Mr(e,t,n){return 0==t?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(Mr(e.firstChild.content,t-1,n)))}function Or(e,t,n){return 0==t?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(Or(e.lastChild.content,t-1,n)))}function Nr(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function Tr(e,t,r){if(t<=0)return e;let i=e.content;return t>1&&(i=i.replaceChild(0,Tr(i.firstChild,t-1,1==i.childCount?r-1:0))),t>0&&(i=e.type.contentMatch.fillBefore(i).append(i),r<=0&&(i=i.append(e.type.contentMatch.matchFragment(i).fillBefore(n.empty,!0)))),e.copy(i)}function Dr(e,t,n,r,i){let o=e.node(t),s=i?e.indexAfter(t):e.index(t);if(s==o.childCount&&!n.compatibleContent(o.type))return null;let l=r.fillBefore(o.content,!0,s);return l&&!function(e,t,n){for(let r=n;r<t.childCount;r++)if(!e.allowsMarks(t.child(r).marks))return!0;return!1}(n,o.content,s)?l:null}function Er(e){return e.spec.defining||e.spec.definingForContent}function Ar(e,t,r,i,o){if(t<r){let n=e.firstChild;e=e.replaceChild(0,n.copy(Ar(n.content,t+1,r,i,n)))}if(t>i){let t=o.contentMatchAt(0),r=t.fillBefore(e).append(e);e=r.append(t.matchFragment(r).fillBefore(n.empty,!0))}return e}function Rr(e,t){let n=[];for(let r=Math.min(e.depth,t.depth);r>=0;r--){let i=e.start(r);if(i<e.pos-(e.depth-r)||t.end(r)>t.pos+(t.depth-r)||e.node(r).type.spec.isolating||t.node(r).type.spec.isolating)break;(i==t.start(r)||r==e.depth&&r==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&r&&t.start(r-1)==i-1)&&n.push(r)}return n}function Ir(e){Z||e.parent.inlineContent||(Z=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}function zr(e,t,n,r,i,o=!1){if(t.inlineContent)return ee.create(e,n);for(let s=r-(i>0?0:1);i>0?s<t.childCount:s>=0;s+=i){let r=t.child(s);if(r.isAtom){if(!o&&ne.isSelectable(r))return ne.create(e,n-(i<0?r.nodeSize:0))}else{let t=zr(e,r,n+i,i<0?r.childCount:0,i,o);if(t)return t}n+=r.nodeSize*i}return null}function Pr(e,t,n){let r=e.steps.length-1;if(r<t)return;let i,o=e.steps[r];(o instanceof q||o instanceof K)&&(e.mapping.maps[r].forEach((e,t,n,r)=>{null==i&&(i=r)}),e.setSelection(X.near(e.doc.resolve(i),n)))}function $r(e,t){return t&&e?e.bind(t):e}function Br(e,t,n){for(let r in e){let i=e[r];i instanceof Function?i=i.bind(t):"handleDOMEvents"==r&&(i=Br(i,t,{})),n[r]=i}return n}function Vr(e){return e in de?e+"$"+ ++de[e]:(de[e]=0,e+"$")}function Fr(e,t,n,r,i){for(var o;;){if(e==n&&t==r)return!0;if(t==(i<0?0:Lr(e))){let n=e.parentNode;if(!n||1!=n.nodeType||Jr(e)||ve.test(e.nodeName)||"false"==e.contentEditable)return!1;t=fe(e)+(i<0?0:1),e=n}else{if(1!=e.nodeType)return!1;{let n=e.childNodes[t+(i<0?-1:0)];if(1==n.nodeType&&"false"==n.contentEditable){if(!(null===(o=n.pmViewDesc)||void 0===o?void 0:o.ignoreForSelection))return!1;t+=i}else e=n,t=i<0?Lr(e):0}}}}function Lr(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function Jr(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}function Wr(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}function qr(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function Kr(e,t){return"number"==typeof e?e:e[t]}function jr(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function _r(e,t,n){let r=e.someProp("scrollThreshold")||0,i=e.someProp("scrollMargin")||5,o=e.dom.ownerDocument;for(let s=n||e.dom;s;){if(1!=s.nodeType){s=ue(s);continue}let e=s,n=e==o.body,l=n?qr(o):jr(e),a=0,h=0;if(t.top<l.top+Kr(r,"top")?h=-(l.top-t.top+Kr(i,"top")):t.bottom>l.bottom-Kr(r,"bottom")&&(h=t.bottom-t.top>l.bottom-l.top?t.top+Kr(i,"top")-l.top:t.bottom-l.bottom+Kr(i,"bottom")),t.left<l.left+Kr(r,"left")?a=-(l.left-t.left+Kr(i,"left")):t.right>l.right-Kr(r,"right")&&(a=t.right-l.right+Kr(i,"right")),a||h)if(n)o.defaultView.scrollBy(a,h);else{let n=e.scrollLeft,r=e.scrollTop;h&&(e.scrollTop+=h),a&&(e.scrollLeft+=a);let i=e.scrollLeft-n,o=e.scrollTop-r;t={left:t.left-i,top:t.top-o,right:t.right-i,bottom:t.bottom-o}}let c=n?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(c))break;s="absolute"==c?s.offsetParent:ue(s)}}function Hr(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=ue(r));return t}function Ur(e,t){for(let n=0;n<e.length;n++){let{dom:r,top:i,left:o}=e[n];r.scrollTop!=i+t&&(r.scrollTop=i+t),r.scrollLeft!=o&&(r.scrollLeft=o)}}function Gr(e,t){let n,r,i,o,s=2e8,l=0,a=t.top,h=t.top;for(let c=e.firstChild,d=0;c;c=c.nextSibling,d++){let e;if(1==c.nodeType)e=c.getClientRects();else{if(3!=c.nodeType)continue;e=ge(c).getClientRects()}for(let p=0;p<e.length;p++){let f=e[p];if(f.top<=a&&f.bottom>=h){a=Math.max(f.bottom,a),h=Math.min(f.top,h);let e=f.left>t.left?f.left-t.left:f.right<t.left?t.left-f.right:0;if(e<s){n=c,s=e,r=e&&3==n.nodeType?{left:f.right<t.left?f.right:f.left,top:t.top}:t,1==c.nodeType&&e&&(l=d+(t.left>=(f.left+f.right)/2?1:0));continue}}else f.top>t.top&&!i&&f.left<=t.left&&f.right>=t.left&&(i=c,o={left:Math.max(f.left,Math.min(f.right,t.left)),top:f.top});!n&&(t.left>=f.right&&t.top>=f.top||t.left>=f.left&&t.top>=f.bottom)&&(l=d+1)}}return!n&&i&&(n=i,r=o,s=0),n&&3==n.nodeType?function(e,t){let n,r=e.nodeValue.length,i=document.createRange();for(let o=0;o<r;o++){i.setEnd(e,o+1),i.setStart(e,o);let r=ei(i,1);if(r.top!=r.bottom&&Yr(t,r)){n={node:e,offset:o+(t.left>=(r.left+r.right)/2?1:0)};break}}return i.detach(),n||{node:e,offset:0}}(n,r):!n||s&&1==n.nodeType?{node:e,offset:l}:Gr(n,r)}function Yr(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function Xr(e,t,n){let r=e.childNodes.length;if(r&&n.top<n.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(t.top-n.top)/(n.bottom-n.top))-2)),o=i;;){let n=e.childNodes[o];if(1==n.nodeType){let e=n.getClientRects();for(let r=0;r<e.length;r++){let i=e[r];if(Yr(t,i))return Xr(n,t,i)}}if((o=(o+1)%r)==i)break}return e}function Qr(e,t){let n,r=e.dom.ownerDocument,i=0,o=function(e,t,n){if(e.caretPositionFromPoint)try{let r=e.caretPositionFromPoint(t,n);if(r)return{node:r.offsetNode,offset:Math.min(Lr(r.offsetNode),r.offset)}}catch(r){}if(e.caretRangeFromPoint){let r=e.caretRangeFromPoint(t,n);if(r)return{node:r.startContainer,offset:Math.min(Lr(r.startContainer),r.startOffset)}}}(r,t.left,t.top);o&&({node:n,offset:i}=o);let s,l=(e.root.elementFromPoint?e.root:r).elementFromPoint(t.left,t.top);if(!l||!e.dom.contains(1!=l.nodeType?l.parentNode:l)){let n=e.dom.getBoundingClientRect();if(!Yr(t,n))return null;if(l=Xr(e.dom,t,n),!l)return null}if(Ie)for(let h=l;n&&h;h=ue(h))h.draggable&&(n=void 0);if(l=function(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}(l,t),n){if(De&&1==n.nodeType&&(i=Math.min(i,n.childNodes.length),i<n.childNodes.length)){let e,r=n.childNodes[i];"IMG"==r.nodeName&&(e=r.getBoundingClientRect()).right<=t.left&&e.bottom>t.top&&i++}let r;Ve&&i&&1==n.nodeType&&1==(r=n.childNodes[i-1]).nodeType&&"false"==r.contentEditable&&r.getBoundingClientRect().top>=t.top&&i--,n==e.dom&&i==n.childNodes.length-1&&1==n.lastChild.nodeType&&t.top>n.lastChild.getBoundingClientRect().bottom?s=e.state.doc.content.size:0!=i&&1==n.nodeType&&"BR"==n.childNodes[i-1].nodeName||(s=function(e,t,n,r){let i=-1;for(let o=t,s=!1;o!=e.dom;){let t,n=e.docView.nearestDesc(o,!0);if(!n)return null;if(1==n.dom.nodeType&&(n.node.isBlock&&n.parent||!n.contentDOM)&&((t=n.dom.getBoundingClientRect()).width||t.height)&&(n.node.isBlock&&n.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(n.dom.nodeName)&&(!s&&t.left>r.left||t.top>r.top?i=n.posBefore:(!s&&t.right<r.left||t.bottom<r.top)&&(i=n.posAfter),s=!0),!n.contentDOM&&i<0&&!n.node.isText))return(n.node.isBlock?r.top<(t.top+t.bottom)/2:r.left<(t.left+t.right)/2)?n.posBefore:n.posAfter;o=n.dom.parentNode}return i>-1?i:e.docView.posFromDOM(t,n,-1)}(e,n,i,t))}null==s&&(s=function(e,t,n){let{node:r,offset:i}=Gr(t,n),o=-1;if(1==r.nodeType&&!r.firstChild){let e=r.getBoundingClientRect();o=e.left!=e.right&&n.left>(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(r,i,o)}(e,l,t));let a=e.docView.nearestDesc(l,!0);return{pos:s,inside:a?a.posAtStart-a.border:-1}}function Zr(e){return e.top<e.bottom||e.left<e.right}function ei(e,t){let n=e.getClientRects();if(n.length){let e=n[t<0?0:n.length-1];if(Zr(e))return e}return Array.prototype.find.call(n,Zr)||e.getBoundingClientRect()}function ti(e,t,n){let{node:r,offset:i,atom:o}=e.docView.domFromPos(t,n<0?-1:1),s=Ve||De;if(3==r.nodeType){if(!s||!Je.test(r.nodeValue)&&(n<0?i:i!=r.nodeValue.length)){let e=i,t=i,o=n<0?1:-1;return n<0&&!i?(t++,o=-1):n>=0&&i==r.nodeValue.length?(e--,o=1):n<0?e--:t++,ni(ei(ge(r,e,t),o),o<0)}{let e=ei(ge(r,i,i),n);if(De&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let t=ei(ge(r,i-1,i-1),-1);if(t.top==e.top){let n=ei(ge(r,i,i+1),-1);if(n.top!=e.top)return ni(n,n.left<t.left)}}return e}}if(!e.state.doc.resolve(t-(o||0)).parent.inlineContent){if(null==o&&i&&(n<0||i==Lr(r))){let e=r.childNodes[i-1];if(1==e.nodeType)return ri(e.getBoundingClientRect(),!1)}if(null==o&&i<Lr(r)){let e=r.childNodes[i];if(1==e.nodeType)return ri(e.getBoundingClientRect(),!0)}return ri(r.getBoundingClientRect(),n>=0)}if(null==o&&i&&(n<0||i==Lr(r))){let e=r.childNodes[i-1],t=3==e.nodeType?ge(e,Lr(e)-(s?0:1)):1!=e.nodeType||"BR"==e.nodeName&&e.nextSibling?null:e;if(t)return ni(ei(t,1),!1)}if(null==o&&i<Lr(r)){let e=r.childNodes[i];for(;e.pmViewDesc&&e.pmViewDesc.ignoreForCoords;)e=e.nextSibling;let t=e?3==e.nodeType?ge(e,0,s?0:1):1==e.nodeType?e:null:null;if(t)return ni(ei(t,-1),!0)}return ni(ei(3==r.nodeType?ge(r):r,-n),n>=0)}function ni(e,t){if(0==e.width)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function ri(e,t){if(0==e.height)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function ii(e,t,n){let r=e.state,i=e.root.activeElement;r!=t&&e.updateState(t),i!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),i!=e.dom&&i&&i.focus()}}function oi(e,t,n){return qe==t&&Ke==n?je:(qe=t,Ke=n,je="up"==n||"down"==n?function(e,t,n){let r=t.selection,i="up"==n?r.$from:r.$to;return ii(e,t,()=>{let{node:t}=e.docView.domFromPos(i.pos,"up"==n?-1:1);for(;;){let n=e.docView.nearestDesc(t,!0);if(!n)break;if(n.node.isBlock){t=n.contentDOM||n.dom;break}t=n.dom.parentNode}let r=ti(e,i.pos,1);for(let e=t.firstChild;e;e=e.nextSibling){let t;if(1==e.nodeType)t=e.getClientRects();else{if(3!=e.nodeType)continue;t=ge(e,0,e.nodeValue.length).getClientRects()}for(let e=0;e<t.length;e++){let i=t[e];if(i.bottom>i.top+1&&("up"==n?r.top-i.top>2*(i.bottom-r.top):i.bottom-r.bottom>2*(r.bottom-i.top)))return!1}}return!0})}(e,t,n):function(e,t,n){let{$head:r}=t.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,o=!i,s=i==r.parent.content.size,l=e.domSelection();return l?We.test(r.parent.textContent)&&l.modify?ii(e,t,()=>{let{focusNode:t,focusOffset:i,anchorNode:o,anchorOffset:s}=e.domSelectionRange(),a=l.caretBidiLevel;l.modify("move",n,"character");let h=r.depth?e.docView.domAfterPos(r.before()):e.dom,{focusNode:c,focusOffset:d}=e.domSelectionRange(),p=c&&!h.contains(1==c.nodeType?c:c.parentNode)||t==c&&i==d;try{l.collapse(o,s),t&&(t!=o||i!=s)&&l.extend&&l.extend(t,i)}catch(f){}return null!=a&&(l.caretBidiLevel=a),p}):"left"==n||"backward"==n?o:s:r.pos==r.start()||r.pos==r.end()}(e,t,n))}function si(e,t,n,r,i){di(r,t,e);let o=new Ye(void 0,e,t,n,r,r,r,i,0);return o.contentDOM&&o.updateChildren(i,0),o}function li(e,t,n){let r=e.firstChild,i=!1;for(let o=0;o<t.length;o++){let s=t[o],l=s.dom;if(l.parentNode==e){for(;l!=r;)r=fi(r),i=!0;r=r.nextSibling}else i=!0,e.insertBefore(l,r);if(s instanceof Ge){let t=r?r.previousSibling:e.lastChild;li(s.contentDOM,s.children,n),r=t?t.nextSibling:e.firstChild}}for(;r;)r=fi(r),i=!0;i&&n.trackWrites==e&&(n.trackWrites=null)}function ai(e,t,n){if(0==e.length)return tt;let r=n?tt[0]:new et,i=[r];for(let o=0;o<e.length;o++){let s=e[o].type.attrs;if(s){s.nodeName&&i.push(r=new et(s.nodeName));for(let e in s){let o=s[e];null!=o&&(n&&1==i.length&&i.push(r=new et(t.isInline?"span":"div")),"class"==e?r.class=(r.class?r.class+" ":"")+o:"style"==e?r.style=(r.style?r.style+";":"")+o:"nodeName"!=e&&(r[e]=o))}}}return i}function hi(e,t,n,r){if(n==tt&&r==tt)return t;let i=t;for(let o=0;o<r.length;o++){let t=r[o],s=n[o];if(o){let n;s&&s.nodeName==t.nodeName&&i!=e&&(n=i.parentNode)&&n.nodeName.toLowerCase()==t.nodeName||(n=document.createElement(t.nodeName),n.pmIsDeco=!0,n.appendChild(i),s=tt[0]),i=n}ci(i,s||tt[0],t)}return i}function ci(e,t,n){for(let r in t)"class"==r||"style"==r||"nodeName"==r||r in n||e.removeAttribute(r);for(let r in n)"class"!=r&&"style"!=r&&"nodeName"!=r&&n[r]!=t[r]&&e.setAttribute(r,n[r]);if(t.class!=n.class){let r=t.class?t.class.split(" ").filter(Boolean):[],i=n.class?n.class.split(" ").filter(Boolean):[];for(let t=0;t<r.length;t++)-1==i.indexOf(r[t])&&e.classList.remove(r[t]);for(let t=0;t<i.length;t++)-1==r.indexOf(i[t])&&e.classList.add(i[t]);0==e.classList.length&&e.removeAttribute("class")}if(t.style!=n.style){if(t.style){let n,r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;for(;n=r.exec(t.style);)e.style.removeProperty(n[1])}n.style&&(e.style.cssText+=n.style)}}function di(e,t,n){return hi(e,e,tt,ai(t,n,1!=e.nodeType))}function pi(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function fi(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}function ui(e,t){return e.type.side-t.type.side}function mi(e,t,n,r,i){let o=[];for(let s=0,l=0;s<e.length;s++){let a=e[s],h=l,c=l+=a.size;h>=n||c<=t?o.push(a):(h<t&&o.push(a.slice(0,t-h,r)),i&&(o.push(i),i=void 0),c>n&&o.push(a.slice(n-h,a.size,r)))}return o}function gi(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let i=e.docView.nearestDesc(n.focusNode),o=i&&0==i.size,s=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let l,a,h=r.resolve(s);if(xe(n)){for(l=s;i&&!i.node;)i=i.parent;let e=i.node;if(i&&e.isAtom&&ne.isSelectable(e)&&i.parent&&(!e.isInline||!function(e,t,n){for(let r=0==t,i=t==Lr(e);r||i;){if(e==n)return!0;let t=fe(e);if(!(e=e.parentNode))return!1;r=r&&0==t,i=i&&t==Lr(e)}}(n.focusNode,n.focusOffset,i.dom))){let e=i.posBefore;a=new ne(s==e?h:r.resolve(e))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let t=s,i=s;for(let r=0;r<n.rangeCount;r++){let o=n.getRangeAt(r);t=Math.min(t,e.docView.posFromDOM(o.startContainer,o.startOffset,1)),i=Math.max(i,e.docView.posFromDOM(o.endContainer,o.endOffset,-1))}if(t<0)return null;[l,s]=i==e.state.selection.anchor?[i,t]:[t,i],h=r.resolve(s)}else l=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(l<0)return null}let c=r.resolve(l);return a||(a=Ci(e,c,h,"pointer"==t||e.state.selection.head<h.pos&&!o?1:-1)),a}function yi(e){return e.editable?e.hasFocus():Oi(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function wi(e,t=!1){let n=e.state.selection;if(bi(e,n),yi(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&Ae){let t=e.domSelectionRange(),n=e.domObserver.currentSelection;if(t.anchorNode&&n.anchorNode&&we(t.anchorNode,t.anchorOffset,n.anchorNode,n.anchorOffset))return e.input.mouseDown.delayedSelectionSync=!0,void e.domObserver.setCurSelection()}if(e.domObserver.disconnectSelection(),e.cursorWrapper)!function(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,r="IMG"==n.nodeName;r?t.collapse(n.parentNode,fe(n)+1):t.collapse(n,0),!r&&!e.state.selection.visible&&Ne&&Te<=11&&(n.disabled=!0,n.disabled=!1)}(e);else{let r,i,{anchor:o,head:s}=n;!rt||n instanceof ee||(n.$from.parent.inlineContent||(r=vi(e,n.from)),n.empty||n.$from.parent.inlineContent||(i=vi(e,n.to))),e.docView.setSelection(o,s,e,t),rt&&(r&&ki(r),i&&ki(i)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(e){let t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);let n=e.domSelectionRange(),r=n.anchorNode,i=n.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{n.anchorNode==r&&n.anchorOffset==i||(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(()=>{yi(e)&&!e.state.selection.visible||e.dom.classList.remove("ProseMirror-hideselection")},20))})}(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}function vi(e,t){let{node:n,offset:r}=e.docView.domFromPos(t,0),i=r<n.childNodes.length?n.childNodes[r]:null,o=r?n.childNodes[r-1]:null;if(Ie&&i&&"false"==i.contentEditable)return xi(i);if(!(i&&"false"!=i.contentEditable||o&&"false"!=o.contentEditable)){if(i)return xi(i);if(o)return xi(o)}}function xi(e){return e.contentEditable="true",Ie&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function ki(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function bi(e,t){if(t instanceof ne){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(Si(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else Si(e)}function Si(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function Ci(e,t,n,r){return e.someProp("createSelectionBetween",r=>r(e,t,n))||ee.between(t,n,r)}function Mi(e){return!(e.editable&&!e.hasFocus())&&Oi(e)}function Oi(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(3==t.anchorNode.nodeType?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(3==t.focusNode.nodeType?t.focusNode.parentNode:t.focusNode))}catch(n){return!1}}function Ni(e,t){let{$anchor:n,$head:r}=e.selection,i=t>0?n.max(r):n.min(r),o=i.parent.inlineContent?i.depth?e.doc.resolve(t>0?i.after():i.before()):null:i;return o&&X.findFrom(o,t)}function Ti(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function Di(e,t,n){let r=e.state.selection;if(!(r instanceof ee)){if(r instanceof ne&&r.node.isInline)return Ti(e,new ee(t>0?r.$to:r.$from));{let n=Ni(e.state,t);return!!n&&Ti(e,n)}}if(n.indexOf("s")>-1){let{$head:n}=r,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let o=e.state.doc.resolve(n.pos+i.nodeSize*(t<0?-1:1));return Ti(e,new ee(r.$anchor,o))}if(!r.empty)return!1;if(e.endOfTextblock(t>0?"forward":"backward")){let n=Ni(e.state,t);return!!(n&&n instanceof ne)&&Ti(e,n)}if(!(Pe&&n.indexOf("m")>-1)){let n,i=r.$head,o=i.textOffset?null:t<0?i.nodeBefore:i.nodeAfter;if(!o||o.isText)return!1;let s=t<0?i.pos-o.nodeSize:i.pos;return!!(o.isAtom||(n=e.docView.descAt(s))&&!n.contentDOM)&&(ne.isSelectable(o)?Ti(e,new ne(t<0?e.state.doc.resolve(i.pos-o.nodeSize):i)):!!Ve&&Ti(e,new ee(e.state.doc.resolve(t<0?s:s+o.nodeSize))))}}function Ei(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function Ai(e,t){let n=e.pmViewDesc;return n&&0==n.size&&(t<0||e.nextSibling||"BR"!=e.nodeName)}function Ri(e,t){return t<0?function(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i,o,s=!1;for(De&&1==n.nodeType&&r<Ei(n)&&Ai(n.childNodes[r],-1)&&(s=!0);;)if(r>0){if(1!=n.nodeType)break;{let e=n.childNodes[r-1];if(Ai(e,-1))i=n,o=--r;else{if(3!=e.nodeType)break;n=e,r=n.nodeValue.length}}}else{if(Ii(n))break;{let t=n.previousSibling;for(;t&&Ai(t,-1);)i=n.parentNode,o=fe(t),t=t.previousSibling;if(t)n=t,r=Ei(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}}s?zi(e,n,r):i&&zi(e,i,o)}(e):function(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i,o,s=Ei(n);for(;;)if(r<s){if(1!=n.nodeType)break;if(!Ai(n.childNodes[r],1))break;i=n,o=++r}else{if(Ii(n))break;{let t=n.nextSibling;for(;t&&Ai(t,1);)i=t.parentNode,o=fe(t)+1,t=t.nextSibling;if(t)n=t,r=0,s=Ei(n);else{if(n=n.parentNode,n==e.dom)break;r=s=0}}}i&&zi(e,i,o)}(e)}function Ii(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function zi(e,t,n){if(3!=t.nodeType){let e,r;(r=function(e,t){for(;e&&t==e.childNodes.length&&!Jr(e);)t=fe(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;e=n,t=0}}(t,n))?(t=r,n=0):(e=function(e,t){for(;e&&!t&&!Jr(e);)t=fe(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;t=(e=n).childNodes.length}}(t,n))&&(t=e,n=e.nodeValue.length)}let r=e.domSelection();if(!r)return;if(xe(r)){let e=document.createRange();e.setEnd(t,n),e.setStart(t,n),r.removeAllRanges(),r.addRange(e)}else r.extend&&r.extend(t,n);e.domObserver.setCurSelection();let{state:i}=e;setTimeout(()=>{e.state==i&&wi(e)},50)}function Pi(e,t){let n=e.state.doc.resolve(t);if(!Ae&&!$e&&n.parent.inlineContent){let r=e.coordsAtPos(t);if(t>n.start()){let n=e.coordsAtPos(t-1),i=(n.top+n.bottom)/2;if(i>r.top&&i<r.bottom&&Math.abs(n.left-r.left)>1)return n.left<r.left?"ltr":"rtl"}if(t<n.end()){let n=e.coordsAtPos(t+1),i=(n.top+n.bottom)/2;if(i>r.top&&i<r.bottom&&Math.abs(n.left-r.left)>1)return n.left>r.left?"ltr":"rtl"}}return"rtl"==getComputedStyle(e.dom).direction?"rtl":"ltr"}function $i(e,t,n){let r=e.state.selection;if(r instanceof ee&&!r.empty||n.indexOf("s")>-1)return!1;if(Pe&&n.indexOf("m")>-1)return!1;let{$from:i,$to:o}=r;if(!i.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let n=Ni(e.state,t);if(n&&n instanceof ne)return Ti(e,n)}if(!i.parent.inlineContent){let n=t<0?i:o,s=r instanceof ie?X.near(n,t):X.findFrom(n,t);return!!s&&Ti(e,s)}return!1}function Bi(e,t){if(!(e.state.selection instanceof ee))return!0;let{$head:n,$anchor:r,empty:i}=e.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let o=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(o&&!o.isText){let r=e.state.tr;return t<0?r.delete(n.pos-o.nodeSize,n.pos):r.delete(n.pos,n.pos+o.nodeSize),e.dispatch(r),!0}return!1}function Vi(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function Fi(e,t){let n=t.keyCode,r=function(e){let t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}(t);if(8==n||Pe&&72==n&&"c"==r)return Bi(e,-1)||Ri(e,-1);if(46==n&&!t.shiftKey||Pe&&68==n&&"c"==r)return Bi(e,1)||Ri(e,1);if(13==n||27==n)return!0;if(37==n||Pe&&66==n&&"c"==r){let t=37==n?"ltr"==Pi(e,e.state.selection.from)?-1:1:-1;return Di(e,t,r)||Ri(e,t)}if(39==n||Pe&&70==n&&"c"==r){let t=39==n?"ltr"==Pi(e,e.state.selection.from)?1:-1:1;return Di(e,t,r)||Ri(e,t)}return 38==n||Pe&&80==n&&"c"==r?$i(e,-1,r)||Ri(e,-1):40==n||Pe&&78==n&&"c"==r?function(e){if(!Ie||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&1==t.nodeType&&0==n&&t.firstChild&&"false"==t.firstChild.contentEditable){let n=t.firstChild;Vi(e,n,"true"),setTimeout(()=>Vi(e,n,"false"),20)}return!1}(e)||$i(e,1,r)||Ri(e,1):r==(Pe?"m":"c")&&(66==n||73==n||89==n||90==n)}function Li(e,t){e.someProp("transformCopied",n=>{t=n(t,e)});let n=[],{content:r,openStart:i,openEnd:o}=t;for(;i>1&&o>1&&1==r.childCount&&1==r.firstChild.childCount;){i--,o--;let e=r.firstChild;n.push(e.type.name,e.attrs!=e.type.defaultAttrs?e.attrs:null),r=e.content}let s=e.someProp("clipboardSerializer")||D.fromSchema(e.state.schema),l=Hi(),a=l.createElement("div");a.appendChild(s.serializeFragment(r,{document:l}));let h,c=a.firstChild,d=0;for(;c&&1==c.nodeType&&(h=ot[c.nodeName.toLowerCase()]);){for(let e=h.length-1;e>=0;e--){let t=l.createElement(h[e]);for(;a.firstChild;)t.appendChild(a.firstChild);a.appendChild(t),d++}c=a.firstChild}return c&&1==c.nodeType&&c.setAttribute("data-pm-slice",`${i} ${o}${d?` -${d}`:""} ${JSON.stringify(n)}`),{dom:a,text:e.someProp("clipboardTextSerializer",n=>n(t,e))||t.content.textBetween(0,t.content.size,"\n\n"),slice:t}}function Ji(e,t,r,i,o){let l,a,h=o.parent.type.spec.code;if(!r&&!t)return null;let c=!!t&&(i||h||!r);if(c){if(e.someProp("transformPastedText",n=>{t=n(t,h||i,e)}),h)return a=new s(n.from(e.state.schema.text(t.replace(/\r\n?/g,"\n"))),0,0),e.someProp("transformPasted",t=>{a=t(a,e,!0)}),a;let r=e.someProp("clipboardTextParser",n=>n(t,o,i,e));if(r)a=r;else{let n=o.marks(),{schema:r}=e.state,i=D.fromSchema(r);l=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach(e=>{let t=l.appendChild(document.createElement("p"));e&&t.appendChild(i.serializeNode(r.text(e,n)))})}}else e.someProp("transformPastedHTML",t=>{r=t(r,e)}),l=function(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n,r=Hi().createElement("div"),i=/<([a-z][^>\s]+)/i.exec(e);if((n=i&&ot[i[1].toLowerCase()])&&(e=n.map(e=>"<"+e+">").join("")+e+n.map(e=>"</"+e+">").reverse().join("")),r.innerHTML=function(e){let t=window.trustedTypes;return t?(lt||(lt=t.defaultPolicy||t.createPolicy("ProseMirrorClipboard",{createHTML:e=>e})),lt.createHTML(e)):e}(e),n)for(let o=0;o<n.length;o++)r=r.querySelector(n[o])||r;return r}(r),Ve&&function(e){let t=e.querySelectorAll(Ae?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<t.length;n++){let r=t[n];1==r.childNodes.length&&" "==r.textContent&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),r)}}(l);let d=l&&l.querySelector("[data-pm-slice]"),p=d&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(d.getAttribute("data-pm-slice")||"");if(p&&p[3])for(let n=+p[3];n>0;n--){let e=l.firstChild;for(;e&&1!=e.nodeType;)e=e.nextSibling;if(!e)break;l=e}if(a||(a=(e.someProp("clipboardParser")||e.someProp("domParser")||x.fromSchema(e.state.schema)).parseSlice(l,{preserveWhitespace:!(!c&&!p),context:o,ruleFromNode:e=>"BR"!=e.nodeName||e.nextSibling||!e.parentNode||it.test(e.parentNode.nodeName)?null:{ignore:!0}})),p)a=function(e,t){if(!e.size)return e;let r,i=e.content.firstChild.type.schema;try{r=JSON.parse(t)}catch(h){return e}let{content:o,openStart:l,openEnd:a}=e;for(let s=r.length-2;s>=0;s-=2){let e=i.nodes[r[s]];if(!e||e.hasRequiredAttrs())break;o=n.from(e.create(r[s+1],o)),l++,a++}return new s(o,l,a)}(_i(a,+p[1],+p[2]),p[4]);else if(a=s.maxOpen(function(e,t){if(e.childCount<2)return e;for(let r=t.depth;r>=0;r--){let i,o=t.node(r).contentMatchAt(t.index(r)),s=[];if(e.forEach(e=>{if(!s)return;let t,n=o.findWrapping(e.type);if(!n)return s=null;if(t=s.length&&i.length&&qi(n,i,e,s[s.length-1],0))s[s.length-1]=t;else{s.length&&(s[s.length-1]=Ki(s[s.length-1],i.length));let t=Wi(e,n);s.push(t),o=o.matchType(t.type),i=n}}),s)return n.from(s)}return e}(a.content,o),!0),a.openStart||a.openEnd){let e=0,t=0;for(let n=a.content.firstChild;e<a.openStart&&!n.type.spec.isolating;e++,n=n.firstChild);for(let n=a.content.lastChild;t<a.openEnd&&!n.type.spec.isolating;t++,n=n.lastChild);a=_i(a,e,t)}return e.someProp("transformPasted",t=>{a=t(a,e,c)}),a}function Wi(e,t,r=0){for(let i=t.length-1;i>=r;i--)e=t[i].create(null,n.from(e));return e}function qi(e,t,r,i,o){if(o<e.length&&o<t.length&&e[o]==t[o]){let s=qi(e,t,r,i.lastChild,o+1);if(s)return i.copy(i.content.replaceChild(i.childCount-1,s));if(i.contentMatchAt(i.childCount).matchType(o==e.length-1?r.type:e[o+1]))return i.copy(i.content.append(n.from(Wi(r,e,o+1))))}}function Ki(e,t){if(0==t)return e;let r=e.content.replaceChild(e.childCount-1,Ki(e.lastChild,t-1)),i=e.contentMatchAt(e.childCount).fillBefore(n.empty,!0);return e.copy(r.append(i))}function ji(e,t,r,i,o,s){let l=t<0?e.firstChild:e.lastChild,a=l.content;return e.childCount>1&&(s=0),o<i-1&&(a=ji(a,t,r,i,o+1,s)),o>=r&&(a=t<0?l.contentMatchAt(0).fillBefore(a,s<=o).append(a):a.append(l.contentMatchAt(l.childCount).fillBefore(n.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,l.copy(a))}function _i(e,t,n){return t<e.openStart&&(e=new s(ji(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new s(ji(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}function Hi(){return st||(st=document.implementation.createHTMLDocument("title"))}function Ui(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function Gi(e){e.someProp("handleDOMEvents",t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>Yi(e,t))})}function Yi(e,t){return e.someProp("handleDOMEvents",n=>{let r=n[t.type];return!!r&&(r(e,t)||t.defaultPrevented)})}function Xi(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function Qi(e){return{left:e.clientX,top:e.clientY}}function Zi(e,t,n,r,i){if(-1==r)return!1;let o=e.state.doc.resolve(r);for(let s=o.depth+1;s>0;s--)if(e.someProp(t,t=>s>o.depth?t(e,n,o.nodeAfter,o.before(s),i,!0):t(e,n,o.node(s),o.before(s),i,!1)))return!0;return!1}function eo(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);"pointer"==n&&r.setMeta("pointer",!0),e.dispatch(r)}function to(e,t,n,r,i){return Zi(e,"handleClickOn",t,n,r)||e.someProp("handleClick",n=>n(e,t,r))||(i?function(e,t){if(-1==t)return!1;let n,r,i=e.state.selection;i instanceof ne&&(n=i.node);let o=e.state.doc.resolve(t);for(let s=o.depth+1;s>0;s--){let e=s>o.depth?o.nodeAfter:o.node(s);if(ne.isSelectable(e)){r=n&&i.$from.depth>0&&s>=i.$from.depth&&o.before(i.$from.depth+1)==i.$from.pos?o.before(i.$from.depth):o.before(s);break}}return null!=r&&(eo(e,ne.create(e.state.doc,r),"pointer"),!0)}(e,n):function(e,t){if(-1==t)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return!!(r&&r.isAtom&&ne.isSelectable(r))&&(eo(e,new ne(n),"pointer"),!0)}(e,n))}function no(e,t,n,r){return Zi(e,"handleDoubleClickOn",t,n,r)||e.someProp("handleDoubleClick",n=>n(e,t,r))}function ro(e,t,n,r){return Zi(e,"handleTripleClickOn",t,n,r)||e.someProp("handleTripleClick",n=>n(e,t,r))||function(e,t,n){if(0!=n.button)return!1;let r=e.state.doc;if(-1==t)return!!r.inlineContent&&(eo(e,ee.create(r,0,r.content.size),"pointer"),!0);let i=r.resolve(t);for(let o=i.depth+1;o>0;o--){let t=o>i.depth?i.nodeAfter:i.node(o),n=i.before(o);if(t.inlineContent)eo(e,ee.create(r,n+1,n+1+t.content.size),"pointer");else{if(!ne.isSelectable(t))continue;eo(e,ne.create(r,n),"pointer")}return!0}}(e,n,r)}function io(e){return ho(e)}function oo(e,t){return!!e.composing||!!(Ie&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500)&&(e.input.compositionEndedAt=-2e8,!0)}function so(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>ho(e),t))}function lo(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=function(){let e=document.createEvent("Event");return e.initEvent("event",!0,!0),e.timeStamp}());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function ao(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=function(e,t){for(;;){if(3==e.nodeType&&t)return e;if(1==e.nodeType&&t>0){if("false"==e.contentEditable)return null;t=Lr(e=e.childNodes[t-1])}else{if(!e.parentNode||Jr(e))return null;t=fe(e),e=e.parentNode}}}(t.focusNode,t.focusOffset),r=function(e,t){for(;;){if(3==e.nodeType&&t<e.nodeValue.length)return e;if(1==e.nodeType&&t<e.childNodes.length){if("false"==e.contentEditable)return null;e=e.childNodes[t],t=0}else{if(!e.parentNode||Jr(e))return null;t=fe(e)+1,e=e.parentNode}}}(t.focusNode,t.focusOffset);if(n&&r&&n!=r){let t=r.pmViewDesc,i=e.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!t||!t.isText(r.nodeValue))return r;if(e.input.compositionNode==r){let e=n.pmViewDesc;if(e&&e.isText(n.nodeValue))return r}}return n||r}function ho(e,t=!1){if(!(Be&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),lo(e),t||e.docView&&e.docView.dirty){let n=gi(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):!e.markCursor&&!t||r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.updateState(e.state):e.dispatch(e.state.tr.deleteSelection()),!0}return!1}}function co(e,t,n,r,i){let o=Ji(e,t,n,r,e.state.selection.$from);if(e.someProp("handlePaste",t=>t(e,i,o||s.empty)))return!0;if(!o)return!1;let l=function(e){return 0==e.openStart&&0==e.openEnd&&1==e.content.childCount?e.content.firstChild:null}(o),a=l?e.state.tr.replaceSelectionWith(l,r):e.state.tr.replaceSelection(o);return e.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function po(e){let t=e.getData("text/plain")||e.getData("Text");if(t)return t;let n=e.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}function fo(e,t){let n;return e.someProp("dragCopies",e=>{n=n||e(t)}),null!=n?!n:!t[yt]}function uo(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}function mo(e,t,n,r,i,o,s){let l=e.slice();for(let h=0,c=o;h<n.maps.length;h++){let e=0;n.maps[h].forEach((t,n,r,i)=>{let o=i-r-(n-t);for(let s=0;s<l.length;s+=3){let r=l[s+1];if(r<0||t>r+c-e)continue;let i=l[s]+c-e;n>=i?l[s+1]=t<=i?-2:-1:t>=c&&o&&(l[s]+=o,l[s+1]+=o)}e+=o}),c=n.maps[h].map(c,-1)}let a=!1;for(let h=0;h<l.length;h+=3)if(l[h+1]<0){if(-2==l[h+1]){a=!0,l[h+1]=-1;continue}let t=n.map(e[h]+o),c=t-i;if(c<0||c>=r.content.size){a=!0;continue}let d=n.map(e[h+1]+o,-1)-i,{index:p,offset:f}=r.content.findIndex(c),u=r.maybeChild(p);if(u&&f==c&&f+u.nodeSize==d){let r=l[h+2].mapInner(n,u,t+1,e[h]+o+1,s);r!=Mt?(l[h]=c,l[h+1]=d,l[h+2]=r):(l[h+1]=-2,a=!0)}else a=!0}if(a){let a=vo(function(e,t,n,r,i,o,s){function l(e,t){for(let o=0;o<e.local.length;o++){let l=e.local[o].map(r,i,t);l?n.push(l):s.onRemove&&s.onRemove(e.local[o].spec)}for(let n=0;n<e.children.length;n+=3)l(e.children[n+2],e.children[n]+t+1)}for(let a=0;a<e.length;a+=3)-1==e[a+1]&&l(e[a+2],t[a]+o+1);return n}(l,e,t,n,i,o,s),r,0,s);t=a.local;for(let e=0;e<l.length;e+=3)l[e+1]<0&&(l.splice(e,3),e-=3);for(let e=0,t=0;e<a.children.length;e+=3){let n=a.children[e];for(;t<l.length&&l[t]<n;)t+=3;l.splice(t,0,a.children[e],a.children[e+1],a.children[e+2])}}return new Ct(t.sort(xo),l)}function go(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let i=e[r];n.push(new kt(i.from+t,i.to+t,i.type))}return n}function yo(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,i=null;for(let o,s=0;s<e.length;s++)(o=e[s])&&o.from>n&&o.to<r&&((i||(i=[])).push(o),e[s]=null);return i}function wo(e){let t=[];for(let n=0;n<e.length;n++)null!=e[n]&&t.push(e[n]);return t}function vo(e,t,n,r){let i=[],o=!1;t.forEach((t,s)=>{let l=yo(e,t,s+n);if(l){o=!0;let e=vo(l,t,n+s+1,r);e!=Mt&&i.push(s,s+t.nodeSize,e)}});let s=go(o?wo(e):e,-n).sort(xo);for(let l=0;l<s.length;l++)s[l].type.valid(t,s[l])||(r.onRemove&&r.onRemove(s[l].spec),s.splice(l--,1));return s.length||i.length?new Ct(s,i):Mt}function xo(e,t){return e.from-t.from||e.to-t.to}function ko(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let i=n+1;i<t.length;i++){let o=t[i];if(o.from!=r.from){o.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,o.from),bo(t,i,r.copy(o.from,r.to)));break}o.to!=r.to&&(t==e&&(t=e.slice()),t[i]=o.copy(o.from,r.to),bo(t,i+1,o.copy(r.to,o.to)))}}return t}function bo(e,t,n){for(;t<e.length&&xo(n,e[t])>0;)t++;e.splice(t,0,n)}function So(e){let t=[];return e.someProp("decorations",n=>{let r=n(e.state);r&&r!=Mt&&t.push(r)}),e.cursorWrapper&&t.push(Ct.create(e.state.doc,[e.cursorWrapper.deco])),Ot.from(t)}function Co(e,t){let n=t.startContainer,r=t.startOffset,i=t.endContainer,o=t.endOffset,s=e.domAtPos(e.state.selection.anchor);return we(s.node,s.offset,i,o)&&([n,r,i,o]=[i,o,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:o}}function Mo(e,t){for(let n=t.parentNode;n&&n!=e.dom;n=n.parentNode){let t=e.docView.nearestDesc(n,!0);if(t&&t.node.isBlock)return n}return null}function Oo(e){let t=e.pmViewDesc;if(t)return t.parseRule();if("BR"==e.nodeName&&e.parentNode){if(Ie&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let e=document.createElement("div");return e.appendChild(document.createElement("li")),{skip:e}}if(e.parentNode.lastChild==e||Ie&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if("IMG"==e.nodeName&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null}function No(e,t,r,i,o){let s=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=gi(e,t);if(n&&!e.state.selection.eq(n)){if(Ae&&Be&&13===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp("handleKeyDown",t=>t(e,Wr(13,"Enter"))))return;let r=e.state.tr.setSelection(n);"pointer"==t?r.setMeta("pointer",!0):"key"==t&&r.scrollIntoView(),s&&r.setMeta("composition",s),e.dispatch(r)}return}let l=e.state.doc.resolve(t),a=l.sharedDepth(r);t=l.before(a+1),r=e.state.doc.resolve(r).after(a+1);let h,c,d=e.state.selection,p=function(e,t,n){let r,{node:i,fromOffset:o,toOffset:s,from:l,to:a}=e.docView.parseRange(t,n),h=e.domSelectionRange(),c=h.anchorNode;if(c&&e.dom.contains(1==c.nodeType?c:c.parentNode)&&(r=[{node:c,offset:h.anchorOffset}],xe(h)||r.push({node:h.focusNode,offset:h.focusOffset})),Ae&&8===e.input.lastKeyCode)for(let g=s;g>o;g--){let e=i.childNodes[g-1],t=e.pmViewDesc;if("BR"==e.nodeName&&!t){s=g;break}if(!t||t.size)break}let d=e.state.doc,p=e.someProp("domParser")||x.fromSchema(e.state.schema),f=d.resolve(l),u=null,m=p.parse(i,{topNode:f.parent,topMatch:f.parent.contentMatchAt(f.index()),topOpen:!0,from:o,to:s,preserveWhitespace:"pre"!=f.parent.type.whitespace||"full",findPositions:r,ruleFromNode:Oo,context:f});if(r&&null!=r[0].pos){let e=r[0].pos,t=r[1]&&r[1].pos;null==t&&(t=e),u={anchor:e+l,head:t+l}}return{doc:m,sel:u,from:l,to:a}}(e,t,r),f=e.state.doc,u=f.slice(p.from,p.to);8===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime?(h=e.state.selection.to,c="end"):(h=e.state.selection.from,c="start"),e.input.lastKeyCode=null;let m=function(e,t,n,r,i){let o=e.findDiffStart(t,n);if(null==o)return null;let{a:s,b:l}=e.findDiffEnd(t,n+e.size,n+t.size);if("end"==i&&(r-=s+Math.max(0,o-Math.min(s,l))-o),s<o&&e.size<t.size){let e=r<=o&&r>=s?o-r:0;o-=e,o&&o<t.size&&Eo(t.textBetween(o-1,o+1))&&(o+=e?1:-1),l=o+(l-s),s=o}else if(l<o){let t=r<=o&&r>=l?o-r:0;o-=t,o&&o<e.size&&Eo(e.textBetween(o-1,o+1))&&(o+=t?1:-1),s=o+(s-l),l=o}return{start:o,endA:s,endB:l}}(u.content,p.doc.content,p.from,h,c);if(m&&e.input.domChangeCount++,(ze&&e.input.lastIOSEnter>Date.now()-225||Be)&&o.some(e=>1==e.nodeType&&!It.test(e.nodeName))&&(!m||m.endA>=m.endB)&&e.someProp("handleKeyDown",t=>t(e,Wr(13,"Enter"))))return void(e.input.lastIOSEnter=0);if(!m){if(!(i&&d instanceof ee&&!d.empty&&d.$head.sameParent(d.$anchor))||e.composing||p.sel&&p.sel.anchor!=p.sel.head){if(p.sel){let t=To(e,e.state.doc,p.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);s&&n.setMeta("composition",s),e.dispatch(n)}}return}m={start:d.from,endA:d.to,endB:d.to}}e.state.selection.from<e.state.selection.to&&m.start==m.endB&&e.state.selection instanceof ee&&(m.start>e.state.selection.from&&m.start<=e.state.selection.from+2&&e.state.selection.from>=p.from?m.start=e.state.selection.from:m.endA<e.state.selection.to&&m.endA>=e.state.selection.to-2&&e.state.selection.to<=p.to&&(m.endB+=e.state.selection.to-m.endA,m.endA=e.state.selection.to)),Ne&&Te<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>p.from&&" "==p.doc.textBetween(m.start-p.from-1,m.start-p.from+1)&&(m.start--,m.endA--,m.endB--);let g=p.doc.resolveNoCache(m.start-p.from),y=p.doc.resolveNoCache(m.endB-p.from),w=f.resolve(m.start),v=g.sameParent(y)&&g.parent.inlineContent&&w.end()>=m.endA;if((ze&&e.input.lastIOSEnter>Date.now()-225&&(!v||o.some(e=>"DIV"==e.nodeName||"P"==e.nodeName))||!v&&g.pos<p.doc.content.size&&(!g.sameParent(y)||!g.parent.inlineContent)&&g.pos<y.pos&&!/\S/.test(p.doc.textBetween(g.pos,y.pos,"","")))&&e.someProp("handleKeyDown",t=>t(e,Wr(13,"Enter"))))return void(e.input.lastIOSEnter=0);if(e.state.selection.anchor>m.start&&function(e,t,n,r,i){if(n-t<=i.pos-r.pos||Do(r,!0,!1)<i.pos)return!1;let o=e.resolve(t);if(!r.parent.isTextblock){let e=o.nodeAfter;return null!=e&&n==t+e.nodeSize}if(o.parentOffset<o.parent.content.size||!o.parent.isTextblock)return!1;let s=e.resolve(Do(o,!0,!0));return!(!s.parent.isTextblock||s.pos>n||Do(s,!0,!1)<n)&&r.parent.content.cut(r.parentOffset).eq(s.parent.content)}(f,m.start,m.endA,g,y)&&e.someProp("handleKeyDown",t=>t(e,Wr(8,"Backspace"))))return void(Be&&Ae&&e.domObserver.suppressSelectionUpdates());Ae&&m.endB==m.start&&(e.input.lastChromeDelete=Date.now()),Be&&!v&&g.start()!=y.start()&&0==y.parentOffset&&g.depth==y.depth&&p.sel&&p.sel.anchor==p.sel.head&&p.sel.head==m.endA&&(m.endB-=2,y=p.doc.resolveNoCache(m.endB-p.from),setTimeout(()=>{e.someProp("handleKeyDown",function(t){return t(e,Wr(13,"Enter"))})},20));let k,b=m.start,S=m.endA,C=t=>{let n=t||e.state.tr.replace(b,S,p.doc.slice(m.start-p.from,m.endB-p.from));if(p.sel){let t=To(e,n.doc,p.sel);t&&!(Ae&&e.composing&&t.empty&&(m.start!=m.endB||e.input.lastChromeDelete<Date.now()-100)&&(t.head==b||t.head==n.mapping.map(S)-1)||Ne&&t.empty&&t.head==b)&&n.setSelection(t)}return s&&n.setMeta("composition",s),n.scrollIntoView()};if(v)if(g.pos==y.pos){Ne&&Te<=11&&0==g.parentOffset&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>wi(e),20));let t=C(e.state.tr.delete(b,S)),n=f.resolve(m.start).marksAcross(f.resolve(m.endA));n&&t.ensureMarks(n),e.dispatch(t)}else if(m.endA==m.endB&&(k=function(e,t){let r,i,o,s=e.firstChild.marks,l=t.firstChild.marks,a=s,h=l;for(let n=0;n<l.length;n++)a=l[n].removeFromSet(a);for(let n=0;n<s.length;n++)h=s[n].removeFromSet(h);if(1==a.length&&0==h.length)i=a[0],r="add",o=e=>e.mark(i.addToSet(e.marks));else{if(0!=a.length||1!=h.length)return null;i=h[0],r="remove",o=e=>e.mark(i.removeFromSet(e.marks))}let c=[];for(let n=0;n<t.childCount;n++)c.push(o(t.child(n)));if(n.from(c).eq(e))return{mark:i,type:r}}(g.parent.content.cut(g.parentOffset,y.parentOffset),w.parent.content.cut(w.parentOffset,m.endA-w.start())))){let t=C(e.state.tr);"add"==k.type?t.addMark(b,S,k.mark):t.removeMark(b,S,k.mark),e.dispatch(t)}else if(g.parent.child(g.index()).isText&&g.index()==y.index()-(y.textOffset?0:1)){let t=g.parent.textBetween(g.parentOffset,y.parentOffset),n=()=>C(e.state.tr.insertText(t,b,S));e.someProp("handleTextInput",r=>r(e,b,S,t,n))||e.dispatch(n())}else e.dispatch(C());else e.dispatch(C())}function To(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:Ci(e,t.resolve(n.anchor),t.resolve(n.head))}function Do(e,t,n){let r=e.depth,i=t?e.end():e.pos;for(;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,i++,t=!1;if(n){let t=e.node(r).maybeChild(e.indexAfter(r));for(;t&&!t.isLeaf;)t=t.firstChild,i++}return i}function Eo(e){if(2!=e.length)return!1;let t=e.charCodeAt(0),n=e.charCodeAt(1);return t>=56320&&t<=57343&&n>=55296&&n<=56319}function Ao(e){let t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(e.editable),e.someProp("attributes",n=>{if("function"==typeof n&&(n=n(e.state)),n)for(let e in n)"class"==e?t.class+=" "+n[e]:"style"==e?t.style=(t.style?t.style+";":"")+n[e]:t[e]||"contenteditable"==e||"nodeName"==e||(t[e]=String(n[e]))}),t.translate||(t.translate="no"),[kt.node(0,e.state.doc.content.size,t)]}function Ro(e){if(e.markCursor){let t=document.createElement("img");t.className="ProseMirror-separator",t.setAttribute("mark-placeholder","true"),t.setAttribute("alt",""),e.cursorWrapper={dom:t,deco:kt.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function Io(e){return!e.someProp("editable",t=>!1===t(e.state))}function zo(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp("nodeViews",n),e.someProp("markViews",n),t}function Po(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}function $o(e){let t,n,r,i,o=e.split(/-(?!$)/),s=o[o.length-1];"Space"==s&&(s=" ");for(let l=0;l<o.length-1;l++){let e=o[l];if(/^(cmd|meta|m)$/i.test(e))i=!0;else if(/^a(lt)?$/i.test(e))t=!0;else if(/^(c|ctrl|control)$/i.test(e))n=!0;else if(/^s(hift)?$/i.test(e))r=!0;else{if(!/^mod$/i.test(e))throw new Error("Unrecognized modifier name: "+e);Lt?i=!0:n=!0}}return t&&(s="Alt-"+s),n&&(s="Ctrl-"+s),i&&(s="Meta-"+s),r&&(s="Shift-"+s),s}function Bo(e,t,n=!0){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),n&&t.shiftKey&&(e="Shift-"+e),e}function Vo(e){let t=function(e){let t=Object.create(null);for(let n in e)t[$o(n)]=e[n];return t}(e);return function(e,n){let r,i=function(e){var t=!(Bt&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||Vt&&e.shiftKey&&e.key&&1==e.key.length||"Unidentified"==e.key)&&e.key||(e.shiftKey?$t:Pt)[e.keyCode]||e.key||"Unidentified";return"Esc"==t&&(t="Escape"),"Del"==t&&(t="Delete"),"Left"==t&&(t="ArrowLeft"),"Up"==t&&(t="ArrowUp"),"Right"==t&&(t="ArrowRight"),"Down"==t&&(t="ArrowDown"),t}(n),o=t[Bo(i,n)];if(o&&o(e.state,e.dispatch,e))return!0;if(1==i.length&&" "!=i){if(n.shiftKey){let r=t[Bo(i,n,!1)];if(r&&r(e.state,e.dispatch,e))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(Jt&&n.ctrlKey&&n.altKey)&&(r=Pt[n.keyCode])&&r!=i){let i=t[Bo(r,n)];if(i&&i(e.state,e.dispatch,e))return!0}}return!1}}function Fo(e,t,n=!1){for(let r=e;r;r="start"==t?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&1!=r.childCount)return!1}return!1}function Lo(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function Jo(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){let n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}function Wo(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function qo(e,t,r,i){let o,l,a=t.nodeBefore,h=t.nodeAfter,c=a.type.spec.isolating||h.type.spec.isolating;if(!c&&function(e,t,n){let r=t.nodeBefore,i=t.nodeAfter,o=t.index();return!(!(r&&i&&r.type.compatibleContent(i.type))||(!r.content.size&&t.parent.canReplace(o-1,o)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),0):!t.parent.canReplace(o,o+1)||!i.isTextblock&&!br(e.doc,t.pos)||(n&&n(e.tr.join(t.pos).scrollIntoView()),0)))}(e,t,r))return!0;let d=!c&&t.parent.canReplace(t.index(),t.index()+1);if(d&&(o=(l=a.contentMatchAt(a.childCount)).findWrapping(h.type))&&l.matchType(o[0]||h.type).validEnd){if(r){let i=t.pos+h.nodeSize,l=n.empty;for(let e=o.length-1;e>=0;e--)l=n.from(o[e].create(null,l));l=n.from(a.copy(l));let c=e.tr.step(new K(t.pos-1,i,t.pos,i,new s(l,1,0),o.length,!0)),d=c.doc.resolve(i+2*o.length);d.nodeAfter&&d.nodeAfter.type==a.type&&br(c.doc,d.pos)&&c.join(d.pos),r(c.scrollIntoView())}return!0}let p=h.type.spec.isolating||i>0&&c?null:X.findFrom(t,1),f=p&&p.$from.blockRange(p.$to),u=f&&gr(f);if(null!=u&&u>=t.depth)return r&&r(e.tr.lift(f,u).scrollIntoView()),!0;if(d&&Fo(h,"start",!0)&&Fo(a,"end")){let i=a,o=[];for(;o.push(i),!i.isTextblock;)i=i.lastChild;let l=h,c=1;for(;!l.isTextblock;l=l.firstChild)c++;if(i.canReplace(i.childCount,i.childCount,l.content)){if(r){let i=n.empty;for(let e=o.length-1;e>=0;e--)i=n.from(o[e].copy(i));r(e.tr.step(new K(t.pos-o.length,t.pos+h.nodeSize,t.pos+c,t.pos+h.nodeSize-c,new s(i,o.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function Ko(e){return function(t,n){let r=t.selection,i=e<0?r.$from:r.$to,o=i.depth;for(;i.node(o).isInline;){if(!o)return!1;o--}return!!i.node(o).isTextblock&&(n&&n(t.tr.setSelection(ee.create(t.doc,e<0?i.start(o):i.end(o)))),!0)}}function jo(...e){return function(t,n,r){for(let i=0;i<e.length;i++)if(e[i](t,n,r))return!0;return!1}}function _o(e){let t=[];for(let n=e.length-1;n>=0&&0==t.length;n--)e[n].forEach((e,n,r,i)=>t.push(r,i));return t}function Ho(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let i=t.map(e[r],1),o=t.map(e[r+1],-1);i<=o&&n.push(i,o)}return n}function Uo(e){let t=e.plugins;if(mn!=t){un=!1,mn=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){un=!0;break}}return un}function Go(e,t){return(n,r)=>{let i=gn.getState(n);if(!i||0==(e?i.undone:i.done).eventCount)return!1;if(r){let o=function(e,t,n){let r=Uo(t),i=gn.get(t).spec.config,o=(n?e.undone:e.done).popEvent(t,r);if(!o)return null;let s=o.selection.resolve(o.transform.doc),l=(n?e.done:e.undone).addTransform(o.transform,t.selection.getBookmark(),i,r),a=new pn(n?l:o.remaining,n?o.remaining:l,null,0,-1);return o.transform.setSelection(s).setMeta(gn,{redo:n,historyState:a})}(i,n,e);o&&r(t?o.scrollIntoView():o)}return!0}}function Yo(e,t,n,r,i,o){if(e.composing)return!1;let s=e.state,l=s.doc.resolve(t),a=l.parent.textBetween(Math.max(0,l.parentOffset-kn),l.parentOffset,null,"")+r;for(let h=0;h<i.length;h++){let c=i[h];if(!c.inCodeMark&&l.marks().some(e=>e.type.spec.code))continue;if(l.parent.type.spec.code){if(!c.inCode)continue}else if("only"===c.inCode)continue;let d=c.match.exec(a);if(!d||d[0].length<r.length)continue;let p=t-(d[0].length-r.length);if(!c.inCodeMark){let e=!1;if(s.doc.nodesBetween(p,l.pos,t=>{t.isInline&&t.marks.some(e=>e.type.spec.code)&&(e=!0)}),e)continue}let f=c.handler(s,d,p,n);if(f)return c.undoable&&f.setMeta(o,{transform:f,from:t,to:n,text:r}),e.dispatch(f),!0}return!1}return e({_:function(e){return new ce({props:{handleKeyDown:Vo(e)}})},d:function(e){return function(t,r){let{$from:i,$to:o}=t.selection,l=i.blockRange(o,t=>t.childCount>0&&t.firstChild.type==e);if(!l)return!1;let a=l.startIndex;if(0==a)return!1;let h=l.parent,c=h.child(a-1);if(c.type!=e)return!1;if(r){let i=c.lastChild&&c.lastChild.type==h.type,o=n.from(i?e.create():null),a=new s(n.from(e.create(null,n.from(h.type.create(null,o)))),i?3:1,0),d=l.start,p=l.end;r(t.tr.step(new K(d-(i?3:1),p,d,p,a,1,!0)).scrollIntoView())}return!0}},f:function(e,t){return function(r,i){let{$from:o,$to:l,node:a}=r.selection;if(a&&a.isBlock||o.depth<2||!o.sameParent(l))return!1;let h=o.node(-1);if(h.type!=e)return!1;if(0==o.parent.content.size&&o.node(-1).childCount==o.indexAfter(-1)){if(3==o.depth||o.node(-3).type!=e||o.index(-2)!=o.node(-2).childCount-1)return!1;if(i){let t=n.empty,l=o.index(-1)?1:o.index(-2)?2:3;for(let e=o.depth-l;e>=o.depth-3;e--)t=n.from(o.node(e).copy(t));let a=o.indexAfter(-1)<o.node(-2).childCount?1:o.indexAfter(-2)<o.node(-3).childCount?2:3;t=t.append(n.from(e.createAndFill()));let h=o.before(o.depth-(l-1)),c=r.tr.replace(h,o.after(-a),new s(t,4-l,0)),d=-1;c.doc.nodesBetween(h,c.doc.content.size,(e,t)=>{if(d>-1)return!1;e.isTextblock&&0==e.content.size&&(d=t+1)}),d>-1&&c.setSelection(X.near(c.doc.resolve(d))),i(c.scrollIntoView())}return!0}let c=l.pos==o.end()?h.contentMatchAt(0).defaultType:null,d=r.tr.delete(o.pos,l.pos),p=c?[t?{type:e,attrs:t}:null,{type:c}]:void 0;return!!kr(d.doc,o.pos,2,p)&&(i&&i(d.split(o.pos,2,p).scrollIntoView()),!0)}},g:function(e,t=null,n){let r=!1!==(n&&n.removeWhenPresent),i=!1!==(n&&n.enterInlineAtoms),o=!(n&&n.includeWhitespace);return function(n,s){let{empty:l,$cursor:a,ranges:h}=n.selection;if(l&&!a||!function(e,t,n,r){for(let i=0;i<t.length;i++){let{$from:o,$to:s}=t[i],l=0==o.depth&&e.inlineContent&&e.type.allowsMarkType(n);if(e.nodesBetween(o.pos,s.pos,(e,t)=>{if(l||!r&&e.isAtom&&e.isInline&&t>=o.pos&&t+e.nodeSize<=s.pos)return!1;l=e.inlineContent&&e.type.allowsMarkType(n)}),l)return!0}return!1}(n.doc,h,e,i))return!1;if(s)if(a)e.isInSet(n.storedMarks||a.marks())?s(n.tr.removeStoredMark(e)):s(n.tr.addStoredMark(e.create(t)));else{let l,a=n.tr;i||(h=function(e){let t=[];for(let n=0;n<e.length;n++){let{$from:r,$to:i}=e[n];r.doc.nodesBetween(r.pos,i.pos,(e,n)=>{if(e.isAtom&&e.content.size&&e.isInline&&n>=r.pos&&n+e.nodeSize<=i.pos)return n+1>r.pos&&t.push(new Q(r,r.doc.resolve(n+1))),r=r.doc.resolve(n+1+e.content.size),!1}),r.pos<i.pos&&t.push(new Q(r,i))}return t}(h)),l=r?!h.some(t=>n.doc.rangeHasMark(t.$from.pos,t.$to.pos,e)):!h.every(t=>{let n=!1;return a.doc.nodesBetween(t.$from.pos,t.$to.pos,(r,i,o)=>{if(n)return!1;n=!e.isInSet(r.marks)&&!!o&&o.type.allowsMarkType(e)&&!(r.isText&&/^\s*$/.test(r.textBetween(Math.max(0,t.$from.pos-i),Math.min(r.nodeSize,t.$to.pos-i))))}),!n});for(let n=0;n<h.length;n++){let{$from:r,$to:i}=h[n];if(l){let n=r.pos,s=i.pos,l=r.nodeAfter,h=i.nodeBefore,c=o&&l&&l.isText?/^\s*/.exec(l.text)[0].length:0,d=o&&h&&h.isText?/\s*$/.exec(h.text)[0].length:0;n+c<s&&(n+=c,s-=d),a.addMark(n,s,e.create(t))}else a.removeMark(r.pos,i.pos,e)}s(a.scrollIntoView())}return!0}},h:jo,i:function({rules:e}){let t=new ce({state:{init:()=>null,apply(e,t){let n=e.getMeta(this);return n||(e.selectionSet||e.docChanged?null:t)}},props:{handleTextInput:(n,r,i,o)=>Yo(n,r,i,o,e,t),handleDOMEvents:{compositionend:n=>{setTimeout(()=>{let{$cursor:r}=n.state.selection;r&&Yo(n,r.pos,r.pos,"",e,t)})}}},isInputRules:!0});return t},o:function(e,t,n=null,r){return new xn(e,(e,i,o,s)=>{let l=n instanceof Function?n(i):n,a=e.tr.delete(o,s),h=a.doc.resolve(o).blockRange(),c=h&&yr(h,t,l);if(!c)return null;a.wrap(h,c);let d=a.doc.resolve(o-1).nodeBefore;return d&&d.type==t&&br(a.doc,o-1)&&(!r||r(i,d))&&a.join(o-1),a})},p:function(e,t=null){return function(r,i){let{$from:o,$to:l}=r.selection,a=o.blockRange(l);if(!a)return!1;let h=i?r.tr:null;return!!function(e,t,r,i=null){let o=!1,l=t,a=t.$from.doc;if(t.depth>=2&&t.$from.node(t.depth-1).type.compatibleContent(r)&&0==t.startIndex){if(0==t.$from.index(t.depth-1))return!1;let e=a.resolve(t.start-2);l=new d(e,e,t.depth),t.endIndex<t.parent.childCount&&(t=new d(t.$from,a.resolve(t.$to.end(t.depth)),t.depth)),o=!0}let h=yr(l,r,i,t);return!!h&&(e&&function(e,t,r,i,o){let l=n.empty;for(let s=r.length-1;s>=0;s--)l=n.from(r[s].type.create(r[s].attrs,l));e.step(new K(t.start-(i?2:0),t.end,t.start,t.end,new s(l,0,0),r.length,!0));let a=0;for(let n=0;n<r.length;n++)r[n].type==o&&(a=n+1);let h=r.length-a,c=t.start+r.length-(i?2:0),d=t.parent;for(let n=t.startIndex,s=t.endIndex,p=!0;n<s;n++,p=!1)!p&&kr(e.doc,c,h)&&(e.split(c,h),c+=2*h),c+=d.child(n).nodeSize}(e,t,h,o,r),!0)}(h,a,e,t)&&(i&&i(h.scrollIntoView()),!0)}},s:function(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new ce({key:gn,state:{init:()=>new pn(cn.empty,cn.empty,null,0,-1),apply:(t,n,r)=>function(e,t,n,r){let i,o=n.getMeta(gn);if(o)return o.historyState;n.getMeta(yn)&&(e=new pn(e.done,e.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(0==n.steps.length)return e;if(s&&s.getMeta(gn))return s.getMeta(gn).redo?new pn(e.done.addTransform(n,void 0,r,Uo(t)),e.undone,_o(n.mapping.maps),e.prevTime,e.prevComposition):new pn(e.done,e.undone.addTransform(n,void 0,r,Uo(t)),null,e.prevTime,e.prevComposition);if(!1===n.getMeta("addToHistory")||s&&!1===s.getMeta("addToHistory"))return(i=n.getMeta("rebased"))?new pn(e.done.rebased(n,i),e.undone.rebased(n,i),Ho(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new pn(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),Ho(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);{let i=n.getMeta("composition"),o=0==e.prevTime||!s&&e.prevComposition!=i&&(e.prevTime<(n.time||0)-r.newGroupDelay||!function(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let i=0;i<t.length;i+=2)e<=t[i+1]&&r>=t[i]&&(n=!0)}),n}(n,e.prevRanges)),l=s?Ho(e.prevRanges,n.mapping):_o(n.mapping.maps);return new pn(e.done.addTransform(n,o?t.selection.getBookmark():void 0,r,Uo(t)),cn.empty,l,n.time,null==i?e.prevComposition:i)}}(n,r,t,e)},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r="historyUndo"==n?wn:"historyRedo"==n?vn:null;return!(!r||!e.editable)&&(t.preventDefault(),r(e.state,e.dispatch))}}}})},u:function(e){return function(t,r){let{$from:i,$to:o}=t.selection,l=i.blockRange(o,t=>t.childCount>0&&t.firstChild.type==e);return!!l&&(!r||(i.node(l.depth-1).type==e?function(e,t,r,i){let o=e.tr,l=i.end,a=i.$to.end(i.depth);l<a&&(o.step(new K(l-1,a,l,a,new s(n.from(r.create(null,i.parent.copy())),1,0),1,!0)),i=new d(o.doc.resolve(i.$from.pos),o.doc.resolve(a),i.depth));const h=gr(i);if(null==h)return!1;o.lift(i,h);let c=o.doc.resolve(o.mapping.map(l,-1)-1);return br(o.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&o.join(c.pos),t(o.scrollIntoView()),!0}(t,r,e,l):function(e,t,r){let i=e.tr,o=r.parent;for(let n=r.end,s=r.endIndex-1,m=r.startIndex;s>m;s--)n-=o.child(s).nodeSize,i.delete(n-1,n+1);let l=i.doc.resolve(r.start),a=l.nodeAfter;if(i.mapping.map(r.end)!=r.start+l.nodeAfter.nodeSize)return!1;let h=0==r.startIndex,c=r.endIndex==o.childCount,d=l.node(-1),p=l.index(-1);if(!d.canReplace(p+(h?0:1),p+1,a.content.append(c?n.empty:n.from(o))))return!1;let f=l.pos,u=f+a.nodeSize;return i.step(new K(f-(h?1:0),u+(c?1:0),f+1,u-1,new s((h?n.empty:n.from(o.copy(n.empty))).append(c?n.empty:n.from(o.copy(n.empty))),h?0:1,c?0:1),h?0:1)),t(i.scrollIntoView()),!0}(t,r,l)))}}}),{setters:[],execute:function(){On.prototype={constructor:On,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return-1==t?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),o=r.content.slice();return-1==i?o.push(n||e,t):(o[i+1]=t,n&&(o[i]=n)),new On(o)},remove:function(e){var t=this.find(e);if(-1==t)return this;var n=this.content.slice();return n.splice(t,2),new On(n)},addToStart:function(e,t){return new On([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new On(n)},addBefore:function(e,t,n){var r=this.remove(t),i=r.content.slice(),o=r.find(e);return i.splice(-1==o?i.length:o,0,t,n),new On(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return(e=On.from(e)).size?new On(e.content.concat(this.subtract(e).content)):this},append:function(e){return(e=On.from(e)).size?new On(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=On.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},On.from=function(e){if(e instanceof On)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new On(t)},n=class e{constructor(e,t){if(this.content=e,this.size=t||0,null==t)for(let n=0;n<e.length;n++)this.size+=e[n].nodeSize}nodesBetween(e,t,n,r=0,i){for(let o=0,s=0;s<t;o++){let l=this.content[o],a=s+l.nodeSize;if(a>e&&!1!==n(l,r+s,i||null,o)&&l.content.size){let i=s+1;l.nodesBetween(Math.max(0,e-i),Math.min(l.content.size,t-i),n,r+i)}s=a}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i="",o=!0;return this.nodesBetween(e,t,(s,l)=>{let a=s.isText?s.text.slice(Math.max(e,l)-l,t-l):s.isLeaf?r?"function"==typeof r?r(s):r:s.type.spec.leafText?s.type.spec.leafText(s):"":"";s.isBlock&&(s.isLeaf&&a||s.isTextblock)&&n&&(o?o=!1:i+=n),i+=a},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),o=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),o=1);o<t.content.length;o++)i.push(t.content[o]);return new e(i,this.size+t.size)}cut(t,n=this.size){if(0==t&&n==this.size)return this;let r=[],i=0;if(n>t)for(let e=0,o=0;o<n;e++){let s=this.content[e],l=o+s.nodeSize;l>t&&((o<t||l>n)&&(s=s.isText?s.cut(Math.max(0,t-o),Math.min(s.text.length,n-o)):s.cut(Math.max(0,t-o-1),Math.min(s.content.size,n-o-1))),r.push(s),i+=s.nodeSize),o=l}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:0==t&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),o=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,o)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.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 r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return Nn(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return Tn(this,e,t,n)}findIndex(e){if(0==e)return Dn(0,e);if(e==this.size)return Dn(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 r=n+this.child(t).nodeSize;if(r>=e)return r==e?Dn(t+1,r):Dn(t,n);n=r}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new e(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;e<t.length;e++){let i=t[e];r+=i.nodeSize,e&&i.isText&&t[e-1].sameMarkup(i)?(n||(n=t.slice(0,e)),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new e(n||t,r)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}},n.empty=new n([],0),r={index:0,offset:0},i=class e{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||(t=e.slice(0,r));else{if(i.type.excludes(this.type))return e;!n&&i.type.rank>this.type.rank&&(t||(t=e.slice(0,r)),t.push(this),n=!0),t&&t.push(i)}}return t||(t=e.slice()),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&En(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`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&0==t.length)return e.none;if(t instanceof e)return[t];let n=t.slice();return n.sort((e,t)=>e.type.rank-t.type.rank),n}},i.none=[],o=class extends Error{},(s=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=Rn(this.content,t+this.openStart,n);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(An(this.content,t+this.openStart,n+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(t,r){if(!r)return e.empty;let i=r.openStart||0,o=r.openEnd||0;if("number"!=typeof i||"number"!=typeof o)throw new RangeError("Invalid input for Slice.fromJSON");return new e(n.fromJSON(t,r.content),i,o)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}}).empty=new s(n.empty,0,0),l=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return null==e?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[3*this.resolveDepth(e)]}index(e){return this.path[3*this.resolveDepth(e)+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e!=this.depth||this.textOffset?1:0)}start(e){return 0==(e=this.resolveDepth(e))?0:this.path[3*e-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]}after(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]+this.path[3*e].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):0==e?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[3*t],r=0==t?0:this.path[3*t-1]+1;for(let i=0;i<e;i++)r+=n.child(i).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(0==e.content.size)return i.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let o=n.marks;for(var s=0;s<o.length;s++)!1!==o[s].type.spec.inclusive||r&&o[s].isInSet(r.marks)||(o=o[s--].removeFromSet(o));return o}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)!1!==n[i].type.spec.inclusive||r&&n[i].isInSet(r.marks)||(n=n[i--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new d(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(t,n){if(!(n>=0&&n<=t.content.size))throw new RangeError("Position "+n+" out of range");let r=[],i=0,o=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(o),s=o-n;if(r.push(e,t,i+n),!s)break;if(e=e.child(t),e.isText)break;o=s-1,i+=n+1}return new e(n,r,o)}static resolveCached(t,n){let r=c.get(t);if(r)for(let e=0;e<r.elts.length;e++){let t=r.elts[e];if(t.pos==n)return t}else c.set(t,r=new a);let i=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%h,i}},a=class{constructor(){this.elts=[],this.i=0}},h=12,c=new WeakMap,d=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)}},p=Object.create(null),f=class e{constructor(e,t,r,o=i.none){this.type=e,this.attrs=t,this.marks=o,this.content=r||n.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&En(this.attrs,t||e.defaultAttrs||p)&&i.sameSet(this.marks,n||i.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}cut(e,t=this.content.size){return 0==e&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return s.empty;let r=this.resolve(e),i=this.resolve(t),o=n?0:r.sharedDepth(t),l=r.start(o);return new s(r.node(o).content.cut(r.pos-l,i.pos-l),r.depth-o,i.depth-o)}replace(e,t,n){return In(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(0==e)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return l.resolveCached(this,e)}resolveNoCache(e){return l.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Wn(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,r=n.empty,i=0,o=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,i,o),l=s&&s.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let n=i;n<o;n++)if(!this.type.allowsMarks(r.child(n).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),o=i&&i.matchFragment(this.content,t);return!!o&&o.validEnd}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=i.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!i.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if("text"==t.type){if("string"!=typeof t.text)throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let i=n.fromJSON(e,t.content),o=e.nodeType(t.type).create(t.attrs,i,r);return o.type.checkAttrs(o.attrs),o}},f.prototype.text=void 0,u=class e extends f{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Wn(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(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return 0==e&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}},m=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new g(t,n);if(null==r.next)return e.empty;let i=qn(r);r.next&&r.err("Unexpected trailing text");let o=Yn(function(e){let t=[[]];return i(function e(t,o){if("choice"==t.type)return t.exprs.reduce((t,n)=>t.concat(e(n,o)),[]);if("seq"!=t.type){if("star"==t.type){let s=n();return r(o,s),i(e(t.expr,s),s),[r(s)]}if("plus"==t.type){let s=n();return i(e(t.expr,o),s),i(e(t.expr,s),s),[r(s)]}if("opt"==t.type)return[r(o)].concat(e(t.expr,o));if("range"==t.type){let s=o;for(let r=0;r<t.min;r++){let r=n();i(e(t.expr,s),r),s=r}if(-1==t.max)i(e(t.expr,s),s);else for(let o=t.min;o<t.max;o++){let o=n();r(s,o),i(e(t.expr,s),o),s=o}return[r(s)]}if("name"==t.type)return[r(o,void 0,t.value)];throw new Error("Unknown expr type")}for(let r=0;;r++){let s=e(t.exprs[r],o);if(r==t.exprs.length-1)return s;i(s,o=n())}}(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let i={term:r,to:n};return t[e].push(i),i}function i(e,t){e.forEach(e=>e.to=t)}}(i));return function(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],i=!e.validEnd,o=[];for(let t=0;t<e.next.length;t++){let{type:n,next:s}=e.next[t];o.push(n.name),!i||n.isText||n.hasRequiredAttrs()||(i=!1),-1==r.indexOf(s)&&r.push(s)}i&&t.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(o,r),o}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}get inlineContent(){return 0!=this.next.length&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!t.isText&&!t.hasRequiredAttrs())return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,r=0){let i=[this];return function o(s,l){let a=s.matchFragment(e,r);if(a&&(!t||a.validEnd))return n.from(l.map(e=>e.createAndFill()));for(let e=0;e<s.next.length;e++){let{type:t,next:n}=s.next[e];if(!t.isText&&!t.hasRequiredAttrs()&&-1==i.indexOf(n)){i.push(n);let e=o(n,l.concat(t));if(e)return e}}return null}(this,[])}findWrapping(e){for(let 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 r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:o,next:s}=i.next[e];o.isLeaf||o.hasRequiredAttrs()||o.name in t||r.type&&!s.validEnd||(n.push({match:o.contentMatch,type:o,via:r}),t[o.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];return function t(n){e.push(n);for(let r=0;r<n.next.length;r++)-1==e.indexOf(n.next[r].next)&&t(n.next[r].next)}(this),e.map((t,n)=>{let r=n+(t.validEnd?"*":" ")+" ";for(let i=0;i<t.next.length;i++)r+=(i?", ":"")+t.next[i].type.name+"->"+e.indexOf(t.next[i].next);return r}).join("\n")}},m.empty=new m(!0),g=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+"')")}},y=class e{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=er(e,n.attrs),this.defaultAttrs=Xn(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||"text"==e),this.isText="text"==e}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==m.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:Qn(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new f(this,this.computeAttrs(e),n.from(t),i.setFrom(r))}createChecked(e=null,t,r){return t=n.from(t),this.checkContent(t),new f(this,this.computeAttrs(e),t,i.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),(t=n.from(t)).size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let o=this.contentMatch.matchFragment(t),s=o&&o.fillBefore(n.empty,!0);return s?new f(this,e,t.append(s),i.setFrom(r)):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){Zn(this.attrs,e,"node",this.name)}allowsMarkType(e){return null==this.markSet||this.markSet.indexOf(e)>-1}allowsMarks(e){if(null==this.markSet)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(null==this.markSet)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:i.none:e}static compile(t,n){let r=Object.create(null);t.forEach((t,i)=>r[t]=new e(t,n,i));let i=n.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let e in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}},w=class{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate="string"==typeof n.validate?function(e,t,n){let r=n.split("|");return n=>{let i=null===n?"null":typeof n;if(r.indexOf(i)<0)throw new RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${i}`)}}(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}},v=class e{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=er(e,r.attrs),this.excluded=null;let o=Xn(this.attrs);this.instance=o?new i(this,o):null}create(e=null){return!e&&this.instance?this.instance:new i(this,Qn(this.attrs,e))}static compile(t,n){let r=Object.create(null),i=0;return t.forEach((t,o)=>r[t]=new e(t,i++,n,o)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){Zn(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}},e("E",class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let r in e)t[r]=e[r];t.nodes=On.from(e.nodes),t.marks=On.from(e.marks||{}),this.nodes=y.compile(this.spec.nodes,this),this.marks=v.compile(this.spec.marks,this);let n=Object.create(null);for(let r in this.nodes){if(r in this.marks)throw new RangeError(r+" can not be both a node and a mark");let e=this.nodes[r],t=e.spec.content||"",i=e.spec.marks;if(e.contentMatch=n[t]||(n[t]=m.parse(t,this.nodes)),e.inlineContent=e.contentMatch.inlineContent,e.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!e.isInline||!e.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=e}e.markSet="_"==i?null:i?tr(this,i.split(" ")):""!=i&&e.inlineContent?null:[]}for(let r in this.marks){let e=this.marks[r],t=e.spec.excludes;e.excluded=null==t?[e]:""==t?[]:tr(this,t.split(" "))}this.nodeFromJSON=e=>f.fromJSON(this,e),this.markFromJSON=e=>i.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if("string"==typeof e)e=this.nodeType(e);else{if(!(e instanceof y))throw new RangeError("Invalid node type: "+e);if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new u(n,n.defaultAttrs,e,i.setFrom(t))}mark(e,t){return"string"==typeof e&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}),e("w",x=class e{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(function(e){return null!=e.tag}(e))this.tags.push(e);else if(function(e){return null!=e.style}(e)){let t=/[^=]*/.exec(e.style)[0];n.indexOf(t)<0&&n.push(t),this.styles.push(e)}}),this.normalizeLists=!this.tags.some(t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)})}parse(e,t={}){let n=new T(this,t,!1);return n.addAll(e,i.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new T(this,t,!0);return n.addAll(e,i.none,t.from,t.to),s.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let n=this.tags[r];if(rr(e,n.tag)&&(void 0===n.namespace||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(!1===t)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,r){for(let i=r?this.styles.indexOf(r)+1:0;i<this.styles.length;i++){let r=this.styles[i],o=r.style;if(!(0!=o.indexOf(e)||r.context&&!n.matchesContext(r.context)||o.length>e.length&&(61!=o.charCodeAt(e.length)||o.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(!1===e)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=null==e.priority?50:e.priority,r=0;for(;r<t.length;r++){let e=t[r];if((null==e.priority?50:e.priority)<n)break}t.splice(r,0,e)}for(let r in e.marks){let t=e.marks[r].spec.parseDOM;t&&t.forEach(e=>{n(e=ir(e)),e.mark||e.ignore||e.clearMark||(e.mark=r)})}for(let r in e.nodes){let t=e.nodes[r].spec.parseDOM;t&&t.forEach(e=>{n(e=ir(e)),e.node||e.ignore||e.mark||(e.node=r)})}return t}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new e(t,e.schemaRules(t)))}}),k={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},b={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},S={ol:!0,ul:!0},C=1,M=2,O=4,N=class{constructor(e,t,n,r,o,s){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=s,this.content=[],this.activeMarks=i.none,this.match=o||(s&O?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(n.from(e));if(!t){let t,n=this.type.contentMatch;return(t=n.findWrapping(e.type))?(this.match=n,t):null}this.match=this.type.contentMatch.matchFragment(t)}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&C)){let e,t=this.content[this.content.length-1];if(t&&t.isText&&(e=/[ \t\r\n\u000c]+$/.exec(t.text))){let n=t;t.text.length==e[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-e[0].length))}}let t=n.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(n.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!k.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},T=class{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r,o=t.topNode,s=nr(null,t.preserveWhitespace,0)|(n?O:0);r=o?new N(o.type,o.attrs,i.none,!0,t.topMatch||o.type.contentMatch,s):new N(n?null:e.schema.topNodeType,null,i.none,!0,null,s),this.nodes=[r],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){3==e.nodeType?this.addTextNode(e,t):1==e.nodeType&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,r=this.top,i=r.options&M?"full":this.localPreserveWS||(r.options&C)>0,{schema:o}=this.parser;if("full"===i||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(i)if("full"===i)n=n.replace(/\r\n?/g,"\n");else if(o.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(o.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n<e.length;n++)n&&this.insertNode(o.linebreakReplacement.create(),t,!0),e[n]&&this.insertNode(o.text(e[n]),t,!/\S/.test(e[n]));n=""}else n=n.replace(/\r?\n|\r/g," ");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=r.content[r.content.length-1],i=e.previousSibling;(!t||i&&"BR"==i.nodeName||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}n&&this.insertNode(o.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let r=this.localPreserveWS,i=this.top;("PRE"==e.tagName||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o,s=e.nodeName.toLowerCase();S.hasOwnProperty(s)&&this.parser.normalizeLists&&function(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=1==t.nodeType?t.nodeName.toLowerCase():null;e&&S.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):"li"==e?n=t:e&&(n=null)}}(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,n));e:if(l?l.ignore:b.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,t);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(e=l.skip);let n,r=this.needsBlock;if(k.hasOwnProperty(s))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),n=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let o=l&&l.skip?t:this.readStyles(e,t);o&&this.addAll(e,o),n&&this.sync(i),this.needsBlock=r}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,l,n,!1===l.consuming?o:void 0)}this.localPreserveWS=r}leafFallback(e,t){"BR"==e.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode("\n"),t)}ignoreFallback(e,t){"BR"!=e.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let r=0;r<this.parser.matchedStyles.length;r++){let e=this.parser.matchedStyles[r],i=n.getPropertyValue(e);if(i)for(let n;;){let r=this.parser.matchStyle(e,i,this,n);if(!r)break;if(r.ignore)return null;if(t=r.clearMark?t.filter(e=>!r.clearMark(e)):t.concat(this.parser.schema.marks[r.mark].create(r.attrs)),!1!==r.consuming)break;n=r}}return t}addElementByRule(e,t,n,r){let i,o;if(t.node)if(o=this.parser.schema.nodes[t.node],o.isLeaf)this.insertNode(o.create(t.attrs),n,"BR"==e.nodeName)||this.leafFallback(e,n);else{let e=this.enter(o,t.attrs||null,n,t.preserveWhitespace);e&&(i=!0,n=e)}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let s=this.top;if(o&&o.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let r=e;"string"==typeof t.contentElement?r=e.querySelector(t.contentElement):"function"==typeof t.contentElement?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}i&&this.sync(s)&&this.open--}addAll(e,t,n,r){let i=n||0;for(let o=n?e.childNodes[n]:e.firstChild,s=null==r?null:e.childNodes[r];o!=s;o=o.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(o,t);this.findAtPoint(e,i)}findPlace(e,t,n){let r,i;for(let o=this.open,s=0;o>=0;o--){let t=this.nodes[o],l=t.findWrapping(e);if(l&&(!r||r.length>l.length+s)&&(r=l,i=t,!l.length))break;if(t.solid){if(n)break;s+=2}}if(!r)return null;this.sync(i);for(let o=0;o<r.length;o++)t=this.enterInner(r[o],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(t=this.enterInner(e,null,t))}let r=this.findPlace(e,t,n);if(r){this.closeExtra();let t=this.top;t.match&&(t.match=t.match.matchType(e.type));let n=i.none;for(let i of r.concat(e.marks))(t.type?t.type.allowsMarkType(i.type):or(i.type,e.type))&&(n=i.addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n,r){let i=this.findPlace(e.create(t),n,!1);return i&&(i=this.enterInner(e,t,n,!0,r)),i}enterInner(e,t,n,r=!1,o){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(e);let l=nr(e,o,s.options);s.options&O&&0==s.content.length&&(l|=O);let a=i.none;return n=n.filter(t=>!(s.type?s.type.allowsMarkType(t.type):or(t.type,e))||(a=t.addToSet(a),!1)),this.nodes.push(new N(e,t,a,r,null,l)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!(!this.isOpen&&!this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=C)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)null==this.find[t].pos&&1==e.nodeType&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)null==this.find[r].pos&&1==e.nodeType&&e.contains(this.find[r].node)&&t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),n=this.options.context,r=!(this.isOpen||n&&n.parent.type!=this.nodes[0].type),i=-(n?n.depth+1:0)+(r?0:1),o=(e,s)=>{for(;e>=0;e--){let l=t[e];if(""==l){if(e==t.length-1||0==e)continue;for(;s>=i;s--)if(o(e-1,s))return!0;return!1}{let e=s>0||0==s&&r?this.nodes[s].type:n&&s>=i?n.node(s-i).type:null;if(!e||e.name!=l&&!e.isInGroup(l))return!1;s--}}return!0};return o(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let t in this.parser.schema.nodes){let e=this.parser.schema.nodes[t];if(e.isTextblock&&e.defaultAttrs)return e}}},e("T",D=class e{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=lr(t).createDocumentFragment());let r=n,i=[];return e.forEach(e=>{if(i.length||e.marks.length){let n=0,o=0;for(;n<i.length&&o<e.marks.length;){let t=e.marks[o];if(this.marks[t.type.name]){if(!t.eq(i[n][0])||!1===t.type.spec.spanning)break;n++,o++}else o++}for(;n<i.length;)r=i.pop()[1];for(;o<e.marks.length;){let n=e.marks[o++],s=this.serializeMark(n,e.isInline,t);s&&(i.push([n,r]),r.appendChild(s.dom),r=s.contentDOM||s.dom)}}r.appendChild(this.serializeNodeInner(e,t))}),n}serializeNodeInner(e,t){let{dom:n,contentDOM:r}=hr(lr(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,r)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let i=this.serializeMark(e.marks[r],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&hr(lr(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return hr(e,t,n,r)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new e(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(e){let t=sr(e.nodes);return t.text||(t.text=e=>e.text),t}static marksFromSchema(e){return sr(e.marks)}}),E=new WeakMap,A=65535,R=Math.pow(2,16),I=class{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(8&this.delInfo)>0}get deletedBefore(){return(5&this.delInfo)>0}get deletedAfter(){return(6&this.delInfo)>0}get deletedAcross(){return(4&this.delInfo)>0}},z=class e{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&e.empty)return e.empty}recover(e){let t=0,n=dr(e);if(!this.inverted)for(let r=0;r<n;r++)t+=this.ranges[3*r+2]-this.ranges[3*r+1];return this.ranges[3*n]+t+function(e){return(e-(e&A))/R}(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 r=0,i=this.inverted?2:1,o=this.inverted?1:2;for(let s=0;s<this.ranges.length;s+=3){let l=this.ranges[s]-(this.inverted?r:0);if(l>e)break;let a=this.ranges[s+i],h=this.ranges[s+o],c=l+a;if(e<=c){let i=l+r+((a?e==l?-1:e==c?1:t:t)<0?0:h);if(n)return i;let o=e==(t<0?l:c)?null:cr(s/3,e-l),d=e==l?2:e==c?1:4;return(t<0?e!=l:e!=c)&&(d|=8),new I(i,d,o)}r+=h-a}return n?e+r:new I(e+r,0,null)}touches(e,t){let n=0,r=dr(t),i=this.inverted?2:1,o=this.inverted?1:2;for(let s=0;s<this.ranges.length;s+=3){let t=this.ranges[s]-(this.inverted?n:0);if(t>e)break;let l=this.ranges[s+i];if(e<=t+l&&s==3*r)return!0;n+=this.ranges[s+o]-l}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r<this.ranges.length;r+=3){let o=this.ranges[r],s=o-(this.inverted?i:0),l=o+(this.inverted?0:i),a=this.ranges[r+t],h=this.ranges[r+n];e(s,s+a,l,l+h),i+=h-a}}invert(){return new e(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(t){return 0==t?e.empty:new e(t<0?[0,-t,0]:[0,0,t])}},z.empty=new z([]),P=class e{constructor(e,t,n=0,r=(e?e.length:0)){this.mirror=t,this.from=n,this.to=r,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(t=0,n=this.maps.length){return new e(this._maps,this.mirror,t,n)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),null!=t&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let r=e.getMirror(t);this.appendMap(e._maps[t],null!=r&&r<t?n+r:void 0)}}getMirror(e){if(this.mirror)for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),null!=r&&r>t?n-r-1:void 0)}}invert(){let t=new e;return t.appendMappingInverted(this),t}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let r=0;for(let i=this.from;i<this.to;i++){let n=this._maps[i].mapResult(e,t);if(null!=n.recover){let t=this.getMirror(i);if(null!=t&&t>i&&t<this.to){i=t,e=this._maps[t].recover(n.recover);continue}}r|=n.delInfo,e=n.pos}return n?e:new I(e,r,null)}},$=Object.create(null),B=class{getMap(){return z.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=$[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 $)throw new RangeError("Duplicate use of step JSON ID "+e);return $[e]=t,t.prototype.jsonID=e,t}},V=class e{constructor(e,t){this.doc=e,this.failed=t}static ok(t){return new e(t,null)}static fail(t){return new e(null,t)}static fromReplace(t,n,r,i){try{return e.ok(t.replace(n,r,i))}catch(s){if(s instanceof o)return e.fail(s.message);throw s}}},F=class e extends B{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),r=n.node(n.sharedDepth(this.to)),i=new s(pr(t.content,(e,t)=>e.isAtom&&t.type.allowsMarkType(this.mark.type)?e.mark(this.mark.addToSet(e.marks)):e,r),t.openStart,t.openEnd);return V.fromReplace(e,this.from,this.to,i)}invert(){return new L(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if("number"!=typeof n.from||"number"!=typeof n.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new e(n.from,n.to,t.markFromJSON(n.mark))}},B.jsonID("addMark",F),L=class e extends B{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 s(pr(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return V.fromReplace(e,this.from,this.to,n)}invert(){return new F(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if("number"!=typeof n.from||"number"!=typeof n.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new e(n.from,n.to,t.markFromJSON(n.mark))}},B.jsonID("removeMark",L),J=class e extends B{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return V.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return V.fromReplace(e,this.pos,this.pos+1,new s(n.from(r),0,t.isLeaf?0:1))}invert(t){let n=t.nodeAt(this.pos);if(n){let t=this.mark.addToSet(n.marks);if(t.length==n.marks.length){for(let r=0;r<n.marks.length;r++)if(!n.marks[r].isInSet(t))return new e(this.pos,n.marks[r]);return new e(this.pos,this.mark)}}return new W(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if("number"!=typeof n.pos)throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new e(n.pos,t.markFromJSON(n.mark))}},B.jsonID("addNodeMark",J),W=class e extends B{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return V.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return V.fromReplace(e,this.pos,this.pos+1,new s(n.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return t&&this.mark.isInSet(t.marks)?new J(this.pos,this.mark):this}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if("number"!=typeof n.pos)throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new e(n.pos,t.markFromJSON(n.mark))}},B.jsonID("removeNodeMark",W),q=class e extends B{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&fr(e,this.from,this.to)?V.fail("Structure replace would overwrite content"):V.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new z([this.from,this.to-this.from,this.slice.size])}invert(t){return new e(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let n=t.mapResult(this.to,-1),r=this.from==this.to&&e.MAP_BIAS<0?n:t.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new e(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(t){if(!(t instanceof e)||t.structure||this.structure)return null;if(this.from+this.slice.size!=t.from||this.slice.openEnd||t.slice.openStart){if(t.to!=this.from||this.slice.openStart||t.slice.openEnd)return null;{let n=this.slice.size+t.slice.size==0?s.empty:new s(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new e(t.from,this.to,n,this.structure)}}{let n=this.slice.size+t.slice.size==0?s.empty:new s(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new e(this.from,this.to+(t.to-t.from),n,this.structure)}}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if("number"!=typeof n.from||"number"!=typeof n.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new e(n.from,n.to,s.fromJSON(t,n.slice),!!n.structure)}},q.MAP_BIAS=1,B.jsonID("replace",q),K=class e extends B{constructor(e,t,n,r,i,o,s=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=i,this.insert=o,this.structure=s}apply(e){if(this.structure&&(fr(e,this.from,this.gapFrom)||fr(e,this.gapTo,this.to)))return V.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return V.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?V.fromReplace(e,this.from,this.to,n):V.fail("Content does not fit in gap")}getMap(){return new z([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let n=this.gapTo-this.gapFrom;return new e(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:t.map(this.gapFrom,-1),o=this.to==this.gapTo?r.pos:t.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||o>r.pos?null:new e(n.pos,r.pos,i,o,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(t,n){if("number"!=typeof n.from||"number"!=typeof n.to||"number"!=typeof n.gapFrom||"number"!=typeof n.gapTo||"number"!=typeof n.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new e(n.from,n.to,n.gapFrom,n.gapTo,s.fromJSON(t,n.slice),n.insert,!!n.structure)}},B.jsonID("replaceAround",K),j=class{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=n.empty;for(let n=0;n<=e.depth;n++){let t=e.node(n);this.frontier.push({type:t.type,match:t.contentMatchAt(e.indexAfter(n))})}for(let i=e.depth;i>0;i--)this.placed=n.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,r=this.close(e<0?this.$to:n.doc.resolve(e));if(!r)return null;let i=this.placed,o=n.depth,l=r.depth;for(;o&&l&&1==i.childCount;)i=i.firstChild.content,o--,l--;let a=new s(i,o,l);return e>-1?new K(n.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||n.pos!=this.$to.pos?new q(n.pos,r.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,r=this.unplaced.openEnd;n<e;n++){let i=t.firstChild;if(t.childCount>1&&(r=0),i.type.spec.isolating&&r<=n){e=n;break}t=i.content}for(let t=1;t<=2;t++)for(let r=1==t?e:this.unplaced.openStart;r>=0;r--){let e,i=null;r?(i=Nr(this.unplaced.content,r-1).firstChild,e=i.content):e=this.unplaced.content;let o=e.firstChild;for(let s=this.depth;s>=0;s--){let e,{type:l,match:a}=this.frontier[s],h=null;if(1==t&&(o?a.matchType(o.type)||(h=a.fillBefore(n.from(o),!1)):i&&l.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:s,parent:i,inject:h};if(2==t&&o&&(e=a.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:s,parent:i,wrap:e};if(i&&a.matchType(i.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=Nr(e,t);return!(!r.childCount||r.firstChild.isLeaf||(this.unplaced=new s(e,t+1,Math.max(n,r.size+t>=e.size-n?t+1:0)),0))}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=Nr(e,t);if(r.childCount<=1&&t>0){let i=e.size-t<=t+r.size;this.unplaced=new s(Mr(e,t-1,1),t-1,i?t-1:n)}else this.unplaced=new s(Mr(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:i,wrap:o}){for(;this.depth>t;)this.closeFrontierNode();if(o)for(let n=0;n<o.length;n++)this.openFrontierNode(o[n]);let l=this.unplaced,a=r?r.content:l.content,h=l.openStart-e,c=0,d=[],{match:p,type:f}=this.frontier[t];if(i){for(let e=0;e<i.childCount;e++)d.push(i.child(e));p=p.matchFragment(i)}let u=a.size+e-(l.content.size-l.openEnd);for(;c<a.childCount;){let e=a.child(c),t=p.matchType(e.type);if(!t)break;c++,(c>1||0==h||e.content.size)&&(p=t,d.push(Tr(e.mark(f.allowedMarks(e.marks)),1==c?h:0,c==a.childCount?u:-1)))}let m=c==a.childCount;m||(u=-1),this.placed=Or(this.placed,t,n.from(d)),this.frontier[t].match=p,m&&u<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let n=0,s=a;n<u;n++){let e=s.lastChild;this.frontier.push({type:e.type,match:e.contentMatchAt(e.childCount)}),s=e.content}this.unplaced=m?0==e?s.empty:new s(Mr(l.content,e-1,1),e-1,u<0?l.openEnd:e-1):new s(Mr(l.content,e,c),l.openStart,l.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e,t=this.frontier[this.depth];if(!t.type.isTextblock||!Dr(this.$to,this.$to.depth,t.type,t.match,!1)||this.$to.depth==this.depth&&(e=this.findCloseLevel(this.$to))&&e.depth==this.depth)return-1;let{depth:n}=this.$to,r=this.$to.after(n);for(;n>1&&r==this.$to.end(--n);)++r;return r}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:r}=this.frontier[t],i=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),o=Dr(e,t,r,n,i);if(o){for(let n=t-1;n>=0;n--){let{match:t,type:r}=this.frontier[n],i=Dr(e,n,r,t,!0);if(!i||i.childCount)continue e}return{depth:t,fit:o,move:i?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Or(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),r=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,r)}return e}openFrontierNode(e,t=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Or(this.placed,this.depth,n.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(n.empty,!0);e.childCount&&(this.placed=Or(this.placed,this.frontier.length,e))}},_=class e extends B{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 V.fail("No node at attribute step's position");let r=Object.create(null);for(let n in t.attrs)r[n]=t.attrs[n];r[this.attr]=this.value;let i=t.type.create(r,null,t.marks);return V.fromReplace(e,this.pos,this.pos+1,new s(n.from(i),0,t.isLeaf?0:1))}getMap(){return z.empty}invert(t){return new e(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,n){if("number"!=typeof n.pos||"string"!=typeof n.attr)throw new RangeError("Invalid input for AttrStep.fromJSON");return new e(n.pos,n.attr,n.value)}},B.jsonID("attr",_),H=class e extends B{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let r in e.attrs)t[r]=e.attrs[r];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return V.ok(n)}getMap(){return z.empty}invert(t){return new e(this.attr,t.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(t,n){if("string"!=typeof n.attr)throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new e(n.attr,n.value)}},B.jsonID("docAttr",H),Error,((U=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n}).prototype=Object.create(Error.prototype)).constructor=U,U.prototype.name="TransformError",G=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new P}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new U(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let n=0;n<this.mapping.maps.length;n++){let r=this.mapping.maps[n];n&&(e=r.map(e,1),t=r.map(t,-1)),r.forEach((n,r,i,o)=>{e=Math.min(e,i),t=Math.max(t,o)})}return 1e9==e?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=s.empty){let r=Sr(this.doc,e,t,n);return r&&this.step(r),this}replaceWith(e,t,r){return this.replace(e,t,new s(n.from(r),0,0))}delete(e,t){return this.replace(e,t,s.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return function(e,t,n,r){if(!r.size)return e.deleteRange(t,n);let i=e.doc.resolve(t),o=e.doc.resolve(n);if(Cr(i,o,r))return e.step(new q(t,n,r));let l=Rr(i,o);0==l[l.length-1]&&l.pop();let a=-(i.depth+1);l.unshift(a);for(let s=i.depth,f=i.pos-1;s>0;s--,f--){let e=i.node(s).type.spec;if(e.defining||e.definingAsContext||e.isolating)break;l.indexOf(s)>-1?a=s:i.before(s)==f&&l.splice(1,0,-s)}let h=l.indexOf(a),c=[],d=r.openStart;for(let s=r.content,f=0;;f++){let e=s.firstChild;if(c.push(e),f==r.openStart)break;s=e.content}for(let s=d-1;s>=0;s--){let e=c[s],t=Er(e.type);if(t&&!e.sameMarkup(i.node(Math.abs(a)-1)))d=s;else if(t||!e.type.isTextblock)break}for(let f=r.openStart;f>=0;f--){let t=(f+d+1)%(r.openStart+1),a=c[t];if(a)for(let c=0;c<l.length;c++){let d=l[(c+h)%l.length],p=!0;d<0&&(p=!1,d=-d);let f=i.node(d-1),u=i.index(d-1);if(f.canReplaceWith(u,u,a.type,a.marks))return e.replace(i.before(d),p?o.after(d):n,new s(Ar(r.content,0,r.openStart,t),t,r.openEnd))}}let p=e.steps.length;for(let s=l.length-1;s>=0&&(e.replace(t,n,r),!(e.steps.length>p));s--){let e=l[s];e<0||(t=i.before(e),n=o.after(e))}}(this,e,t,n),this}replaceRangeWith(e,t,r){return function(e,t,r,i){if(!i.isInline&&t==r&&e.doc.resolve(t).parent.content.size){let n=function(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(0==r.parentOffset)for(let i=r.depth-1;i>=0;i--){let e=r.index(i);if(r.node(i).canReplaceWith(e,e,n))return r.before(i+1);if(e>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let e=r.indexAfter(i);if(r.node(i).canReplaceWith(e,e,n))return r.after(i+1);if(e<r.node(i).childCount)return null}return null}(e.doc,t,i.type);null!=n&&(t=r=n)}e.replaceRange(t,r,new s(n.from(i),0,0))}(this,e,t,r),this}deleteRange(e,t){return function(e,t,n){let r=e.doc.resolve(t),i=e.doc.resolve(n);if(r.parent.isTextblock&&i.parent.isTextblock&&r.start()!=i.start()&&0==r.parentOffset&&0==i.parentOffset){let o=r.sharedDepth(n),s=!1;for(let e=r.depth;e>o;e--)r.node(e).type.spec.isolating&&(s=!0);for(let e=i.depth;e>o;e--)i.node(e).type.spec.isolating&&(s=!0);if(!s){for(let e=r.depth;e>0&&t==r.start(e);e--)t=r.before(e);for(let e=i.depth;e>0&&n==i.start(e);e--)n=i.before(e);r=e.doc.resolve(t),i=e.doc.resolve(n)}}let o=Rr(r,i);for(let s=0;s<o.length;s++){let t=o[s],n=s==o.length-1;if(n&&0==t||r.node(t).type.contentMatch.validEnd)return e.delete(r.start(t),i.end(t));if(t>0&&(n||r.node(t-1).canReplace(r.index(t-1),i.indexAfter(t-1))))return e.delete(r.before(t),i.after(t))}for(let s=1;s<=r.depth&&s<=i.depth;s++)if(t-r.start(s)==r.depth-s&&n>r.end(s)&&i.end(s)-n!=i.depth-s&&r.start(s-1)==i.start(s-1)&&r.node(s-1).canReplace(r.index(s-1),i.index(s-1)))return e.delete(r.before(s),n);e.delete(t,n)}(this,e,t),this}lift(e,t){return function(e,t,r){let{$from:i,$to:o,depth:l}=t,a=i.before(l+1),h=o.after(l+1),c=a,d=h,p=n.empty,f=0;for(let s=l,g=!1;s>r;s--)g||i.index(s)>0?(g=!0,p=n.from(i.node(s).copy(p)),f++):c--;let u=n.empty,m=0;for(let s=l,g=!1;s>r;s--)g||o.after(s+1)<o.end(s)?(g=!0,u=n.from(o.node(s).copy(u)),m++):d++;e.step(new K(c,d,a,h,new s(p.append(u),f,m),p.size-f,!0))}(this,e,t),this}join(e,t=1){return function(e,t,n){let r=null,{linebreakReplacement:i}=e.doc.type.schema,o=e.doc.resolve(t-n),l=o.node().type;if(i&&l.inlineContent){let e="pre"==l.whitespace,t=!!l.contentMatch.matchType(i);e&&!t?r=!1:!e&&t&&(r=!0)}let a=e.steps.length;if(!1===r){let r=e.doc.resolve(t+n);xr(e,r.node(),r.before(),a)}l.inlineContent&&ur(e,t+n-1,l,o.node().contentMatchAt(o.index()),null==r);let h=e.mapping.slice(a),c=h.map(t-n);if(e.step(new q(c,h.map(t+n,-1),s.empty,!0)),!0===r){let t=e.doc.resolve(c);vr(e,t.node(),t.before(),e.steps.length)}}(this,e,t),this}wrap(e,t){return function(e,t,r){let i=n.empty;for(let s=r.length-1;s>=0;s--){if(i.size){let e=r[s].type.contentMatch.matchFragment(i);if(!e||!e.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}i=n.from(r[s].type.create(r[s].attrs,i))}let o=t.start,l=t.end;e.step(new K(o,l,o,l,new s(i,0,0),r.length,!0))}(this,e,t),this}setBlockType(e,t=e,r,i=null){return function(e,t,r,i,o){if(!i.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let l=e.steps.length;e.doc.nodesBetween(t,r,(t,r)=>{let a="function"==typeof o?o(t):o;if(t.isTextblock&&!t.hasMarkup(i,a)&&function(e,t,n){let r=e.resolve(t),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}(e.doc,e.mapping.slice(l).map(r),i)){let o=null;if(i.schema.linebreakReplacement){let e="pre"==i.whitespace,t=!!i.contentMatch.matchType(i.schema.linebreakReplacement);e&&!t?o=!1:!e&&t&&(o=!0)}!1===o&&xr(e,t,r,l),ur(e,e.mapping.slice(l).map(r,1),i,void 0,null===o);let h=e.mapping.slice(l),c=h.map(r,1),d=h.map(r+t.nodeSize,1);return e.step(new K(c,d,c+1,d-1,new s(n.from(i.create(a,null,t.marks)),0,0),1,!0)),!0===o&&vr(e,t,r,l),!1}})}(this,e,t,r,i),this}setNodeMarkup(e,t,r=null,i){return function(e,t,r,i,o){let l=e.doc.nodeAt(t);if(!l)throw new RangeError("No node at given position");r||(r=l.type);let a=r.create(i,null,o||l.marks);if(l.isLeaf)return e.replaceWith(t,t+l.nodeSize,a);if(!r.validContent(l.content))throw new RangeError("Invalid content for node type "+r.name);e.step(new K(t,t+l.nodeSize,t+1,t+l.nodeSize-1,new s(n.from(a),0,0),1,!0))}(this,e,t,r,i),this}setNodeAttribute(e,t,n){return this.step(new _(e,t,n)),this}setDocAttribute(e,t){return this.step(new H(e,t)),this}addNodeMark(e,t){return this.step(new J(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 i)t.isInSet(n.marks)&&this.step(new W(e,t));else{let r,i=n.marks,o=[];for(;r=t.isInSet(i);)o.push(new W(e,r)),i=r.removeFromSet(i);for(let e=o.length-1;e>=0;e--)this.step(o[e])}return this}split(e,t=1,r){return function(e,t,r=1,i){let o=e.doc.resolve(t),l=n.empty,a=n.empty;for(let s=o.depth,h=o.depth-r,c=r-1;s>h;s--,c--){l=n.from(o.node(s).copy(l));let e=i&&i[c];a=n.from(e?e.type.create(e.attrs,a):o.node(s).copy(a))}e.step(new q(t,t,new s(l.append(a),r,r),!0))}(this,e,t,r),this}addMark(e,t,n){return function(e,t,n,r){let i,o,s=[],l=[];e.doc.nodesBetween(t,n,(e,a,h)=>{if(!e.isInline)return;let c=e.marks;if(!r.isInSet(c)&&h.type.allowsMarkType(r.type)){let h=Math.max(a,t),d=Math.min(a+e.nodeSize,n),p=r.addToSet(c);for(let e=0;e<c.length;e++)c[e].isInSet(p)||(i&&i.to==h&&i.mark.eq(c[e])?i.to=d:s.push(i=new L(h,d,c[e])));o&&o.to==h?o.to=d:l.push(o=new F(h,d,r))}}),s.forEach(t=>e.step(t)),l.forEach(t=>e.step(t))}(this,e,t,n),this}removeMark(e,t,n){return function(e,t,n,r){let i=[],o=0;e.doc.nodesBetween(t,n,(e,s)=>{if(!e.isInline)return;o++;let l=null;if(r instanceof v){let t,n=e.marks;for(;t=r.isInSet(n);)(l||(l=[])).push(t),n=t.removeFromSet(n)}else r?r.isInSet(e.marks)&&(l=[r]):l=e.marks;if(l&&l.length){let r=Math.min(s+e.nodeSize,n);for(let e=0;e<l.length;e++){let n,a=l[e];for(let e=0;e<i.length;e++){let t=i[e];t.step==o-1&&a.eq(i[e].style)&&(n=t)}n?(n.to=r,n.step=o):i.push({style:a,from:Math.max(s,t),to:r,step:o})}}}),i.forEach(t=>e.step(new L(t.from,t.to,t.style)))}(this,e,t,n),this}clearIncompatible(e,t,n){return ur(this,e,t,n),this}},Y=Object.create(null),X=class{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new Q(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=s.empty){let n=t.content.lastChild,r=null;for(let s=0;s<t.openEnd;s++)r=n,n=n.lastChild;let i=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:a,$to:h}=o[l],c=e.mapping.slice(i);e.replaceRange(c.map(a.pos),c.map(h.pos),l?s.empty:t),0==l&&Pr(e,i,(n?n.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,r=this.ranges;for(let i=0;i<r.length;i++){let{$from:o,$to:s}=r[i],l=e.mapping.slice(n),a=l.map(o.pos),h=l.map(s.pos);i?e.deleteRange(a,h):(e.replaceRangeWith(a,h,t),Pr(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let r=e.parent.inlineContent?new ee(e):zr(e.node(0),e.parent,e.pos,e.index(),t,n);if(r)return r;for(let i=e.depth-1;i>=0;i--){let r=t<0?zr(e.node(0),e.node(i),e.before(i+1),e.index(i),t,n):zr(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,t,n);if(r)return r}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new ie(e.node(0))}static atStart(e){return zr(e,e,0,0,1)||new ie(e)}static atEnd(e){return zr(e,e,e.content.size,e.childCount,-1)||new ie(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=Y[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 Y)throw new RangeError("Duplicate use of selection JSON ID "+e);return Y[e]=t,t.prototype.jsonID=e,t}getBookmark(){return ee.between(this.$anchor,this.$head).getBookmark()}},X.prototype.visible=!0,Q=class{constructor(e,t){this.$from=e,this.$to=t}},Z=!1,e("C",ee=class e extends X{constructor(e,t=e){Ir(e),Ir(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,n){let r=t.resolve(n.map(this.head));if(!r.parent.inlineContent)return X.near(r);let i=t.resolve(n.map(this.anchor));return new e(i.parent.inlineContent?i:r,r)}replace(e,t=s.empty){if(super.replace(e,t),t==s.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(t){return t instanceof e&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new te(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(t,n){if("number"!=typeof n.anchor||"number"!=typeof n.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(e,t,n=t){let r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))}static between(t,n,r){let i=t.pos-n.pos;if(r&&!i||(r=i>=0?1:-1),!n.parent.inlineContent){let e=X.findFrom(n,r,!0)||X.findFrom(n,-r,!0);if(!e)return X.near(n,r);n=e.$head}return t.parent.inlineContent||(0==i||(t=(X.findFrom(t,-r,!0)||X.findFrom(t,r,!0)).$anchor).pos<n.pos!=i<0)&&(t=n),new e(t,n)}}),X.jsonID("text",ee),te=class e{constructor(e,t){this.anchor=e,this.head=t}map(t){return new e(t.map(this.anchor),t.map(this.head))}resolve(e){return ee.between(e.resolve(this.anchor),e.resolve(this.head))}},ne=class e extends X{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(t,n){let{deleted:r,pos:i}=n.mapResult(this.anchor),o=t.resolve(i);return r?X.near(o):new e(o)}content(){return new s(n.from(this.node),0,0)}eq(t){return t instanceof e&&t.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new re(this.anchor)}static fromJSON(t,n){if("number"!=typeof n.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new e(t.resolve(n.anchor))}static create(t,n){return new e(t.resolve(n))}static isSelectable(e){return!e.isText&&!1!==e.type.spec.selectable}},ne.prototype.visible=!1,X.jsonID("node",ne),re=class e{constructor(e){this.anchor=e}map(t){let{deleted:n,pos:r}=t.mapResult(this.anchor);return n?new te(r,r):new e(r)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&ne.isSelectable(n)?new ne(t):X.near(t)}},ie=class e extends X{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=s.empty){if(t==s.empty){e.delete(0,e.doc.content.size);let t=X.atStart(e.doc);t.eq(e.selection)||e.setSelection(t)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(t){return new e(t)}map(t){return new e(t)}eq(t){return t instanceof e}getBookmark(){return oe}},X.jsonID("all",ie),oe={map(){return this},resolve:e=>new ie(e)},se=class extends G{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=-3&this.updated|1,this.storedMarks=null,this}get selectionSet(){return(1&this.updated)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=2,this}ensureMarks(e){return i.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(2&this.updated)>0}addStep(e,t){super.addStep(e,t),this.updated=-3&this.updated,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)||i.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let r=this.doc.type.schema;if(null==t)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(null==n&&(n=t),!e)return this.deleteRange(t,n);let i=this.storedMarks;if(!i){let e=this.doc.resolve(t);i=n==t?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,i)),this.selection.empty||this.selection.to!=t+e.length||this.setSelection(X.near(this.selection.$to)),this}}setMeta(e,t){return this.meta["string"==typeof e?e:e.key]=t,this}getMeta(e){return this.meta["string"==typeof e?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=4,this}get scrolledIntoView(){return(4&this.updated)>0}},ae=[new(le=class{constructor(e,t,n){this.name=e,this.init=$r(t.init,n),this.apply=$r(t.apply,n)}})("doc",{init:e=>e.doc||e.schema.topNodeType.createAndFill(),apply:e=>e.doc}),new le("selection",{init:(e,t)=>e.selection||X.atStart(t.doc),apply:e=>e.selection}),new le("storedMarks",{init:e=>e.storedMarks||null,apply:(e,t,n,r)=>r.selection.$cursor?e.storedMarks:null}),new le("scrollToSelection",{init:()=>0,apply:(e,t)=>e.scrolledIntoView?t+1:t})],he=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=ae.slice(),t&&t.forEach(e=>{if(this.pluginsByKey[e.key])throw new RangeError("Adding different instances of a keyed plugin ("+e.key+")");this.plugins.push(e),this.pluginsByKey[e.key]=e,e.spec.state&&this.fields.push(new le(e.key,e.spec.state,e))})}},e("x",class e{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 t=this.config.plugins[n];if(t.spec.filterTransaction&&!t.spec.filterTransaction.call(t,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),r=null;for(;;){let i=!1;for(let o=0;o<this.config.plugins.length;o++){let s=this.config.plugins[o];if(s.spec.appendTransaction){let l=r?r[o].n:0,a=r?r[o].state:this,h=l<t.length&&s.spec.appendTransaction.call(s,l?t.slice(l):t,a,n);if(h&&n.filterTransaction(h,o)){if(h.setMeta("appendedTransaction",e),!r){r=[];for(let e=0;e<this.config.plugins.length;e++)r.push(e<o?{state:n,n:t.length}:{state:this,n:0})}t.push(h),n=n.applyInner(h),i=!0}r&&(r[o]={state:n,n:t.length})}}if(!i)return{state:n,transactions:t}}}applyInner(t){if(!t.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new e(this.config),r=this.config.fields;for(let e=0;e<r.length;e++){let i=r[e];n[i.name]=i.apply(t,this[i.name],this,n)}return n}get tr(){return new se(this)}static create(t){let n=new he(t.doc?t.doc.type.schema:t.schema,t.plugins),r=new e(n);for(let e=0;e<n.fields.length;e++)r[n.fields[e].name]=n.fields[e].init(t,r);return r}reconfigure(t){let n=new he(this.schema,t.plugins),r=n.fields,i=new e(n);for(let e=0;e<r.length;e++){let n=r[e].name;i[n]=this.hasOwnProperty(n)?this[n]:r[e].init(t,i)}return i}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(e=>e.toJSON())),e&&"object"==typeof e)for(let n in e){if("doc"==n||"selection"==n)throw new RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[n],i=r.spec.state;i&&i.toJSON&&(t[n]=i.toJSON.call(r,this[r.key]))}return t}static fromJSON(t,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!t.schema)throw new RangeError("Required config field 'schema' missing");let i=new he(t.schema,t.plugins),o=new e(i);return i.fields.forEach(e=>{if("doc"==e.name)o.doc=f.fromJSON(t.schema,n.doc);else if("selection"==e.name)o.selection=X.fromJSON(o.doc,n.selection);else if("storedMarks"==e.name)n.storedMarks&&(o.storedMarks=n.storedMarks.map(t.schema.markFromJSON));else{if(r)for(let i in r){let s=r[i],l=s.spec.state;if(s.key==e.name&&l&&l.fromJSON&&Object.prototype.hasOwnProperty.call(n,i))return void(o[e.name]=l.fromJSON.call(s,t,n[i],o))}o[e.name]=e.init(t,o)}}),o}}),e("S",ce=class{constructor(e){this.spec=e,this.props={},e.props&&Br(e.props,this,this.props),this.key=e.key?e.key.key:Vr("plugin")}getState(e){return e[this.key]}}),de=Object.create(null),pe=class{constructor(e="key"){this.key=Vr(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}},fe=function(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t},ue=function(e){let t=e.assignedSlot||e.parentNode;return t&&11==t.nodeType?t.host:t},me=null,ge=function(e,t,n){let r=me||(me=document.createRange());return r.setEnd(e,null==n?e.nodeValue.length:n),r.setStart(e,t||0),r},ye=function(){me=null},we=function(e,t,n,r){return n&&(Fr(e,t,n,r,-1)||Fr(e,t,n,r,1))},ve=/^(img|br|input|textarea|hr)$/i,xe=function(e){return e.focusNode&&we(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)},ke="undefined"!=typeof navigator?navigator:null,be="undefined"!=typeof document?document:null,Se=ke&&ke.userAgent||"",Ce=/Edge\/(\d+)/.exec(Se),Me=/MSIE \d/.exec(Se),Oe=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Se),Ne=!!(Me||Oe||Ce),Te=Me?document.documentMode:Oe?+Oe[1]:Ce?+Ce[1]:0,(De=!Ne&&/gecko\/(\d+)/i.test(Se))&&(/Firefox\/(\d+)/.exec(Se)||[0,0])[1],Ee=!Ne&&/Chrome\/(\d+)/.exec(Se),Ae=!!Ee,Re=Ee?+Ee[1]:0,Ie=!Ne&&!!ke&&/Apple Computer/.test(ke.vendor),ze=Ie&&(/Mobile\/\w+/.test(Se)||!!ke&&ke.maxTouchPoints>2),Pe=ze||!!ke&&/Mac/.test(ke.platform),$e=!!ke&&/Win/.test(ke.platform),Be=/Android \d/.test(Se),Ve=!!be&&"webkitFontSmoothing"in be.documentElement.style,Fe=Ve?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,Le=null,Je=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,We=/[\u0590-\u08ac]/,qe=null,Ke=null,je=!1,_e=class{constructor(e,t,n,r){this.parent=e,this.children=t,this.dom=n,this.contentDOM=r,this.dirty=0,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(){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 r=this.children[t];if(r==e)return n;n+=r.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,n){if(this.contentDOM&&this.contentDOM.contains(1==e.nodeType?e:e.parentNode)){if(n<0){let n,r;if(e==this.contentDOM)n=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.previousSibling}for(;n&&(!(r=n.pmViewDesc)||r.parent!=this);)n=n.previousSibling;return n?this.posBeforeChild(r)+r.size:this.posAtStart}{let n,r;if(e==this.contentDOM)n=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.nextSibling}for(;n&&(!(r=n.pmViewDesc)||r.parent!=this);)n=n.nextSibling;return n?this.posBeforeChild(r):this.posAtEnd}}let r;if(e==this.dom&&this.contentDOM)r=t>fe(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=2&e.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==t)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!1;break}if(t.previousSibling)break}if(null==r&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!0;break}if(t.nextSibling)break}}return(null==r?n>0:r)?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,r=e;r;r=r.parentNode){let i,o=this.getDesc(r);if(o&&(!t||o.node)){if(!n||!(i=o.nodeDOM)||(1==i.nodeType?i.contains(1==e.nodeType?e:e.parentNode):i==e))return o;n=!1}}}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 r=e;r;r=r.parentNode){let i=this.getDesc(r);if(i)return i.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let r=this.children[t],i=n+r.size;if(n==e&&i!=n){for(;!r.border&&r.children.length;)for(let e=0;e<r.children.length;e++){let t=r.children[e];if(t.size){r=t;break}}return r}if(e<i)return r.descAt(e-n-r.border);n=i}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,r=0;for(let i=0;n<this.children.length;n++){let t=this.children[n],o=i+t.size;if(o>e||t instanceof Qe){r=e-i;break}i=o}if(r)return this.children[n].domFromPos(r-this.children[n].border,t);for(let i;n&&!(i=this.children[n-1]).size&&i instanceof He&&i.side>=0;n--);if(t<=0){let e,r=!0;for(;e=n?this.children[n-1]:null,e&&e.dom.parentNode!=this.contentDOM;n--,r=!1);return e&&t&&r&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?fe(e.dom)+1:0}}{let e,r=!0;for(;e=n<this.children.length?this.children[n]:null,e&&e.dom.parentNode!=this.contentDOM;n++,r=!1);return e&&r&&!e.border&&!e.domAtom?e.domFromPos(0,t):{node:this.contentDOM,offset:e?fe(e.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(0==this.children.length)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,i=-1;for(let o=n,s=0;;s++){let n=this.children[s],l=o+n.size;if(-1==r&&e<=l){let i=o+n.border;if(e>=i&&t<=l-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,i);e=o;for(let t=s;t>0;t--){let n=this.children[t-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){r=fe(n.dom)+1;break}e-=n.size}-1==r&&(r=0)}if(r>-1&&(l>t||s==this.children.length-1)){t=l;for(let e=s+1;e<this.children.length;e++){let n=this.children[e];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(-1)){i=fe(n.dom);break}t+=n.size}-1==i&&(i=this.contentDOM.childNodes.length);break}o=l}return{node:this.contentDOM,from:e,to:t,fromOffset:r,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return 0==t.size||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:n}=this.domFromPos(e,0);if(1!=t.nodeType||n==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[n]}setSelection(e,t,n,r=!1){let i=Math.min(e,t),o=Math.max(e,t);for(let f=0,u=0;f<this.children.length;f++){let s=this.children[f],l=u+s.size;if(i>u&&o<l)return s.setSelection(e-u-s.border,t-u-s.border,n,r);u=l}let s=this.domFromPos(e,e?-1:1),l=t==e?s:this.domFromPos(t,t?-1:1),a=n.root.getSelection(),h=n.domSelectionRange(),c=!1;if((De||Ie)&&e==t){let{node:e,offset:t}=s;if(3==e.nodeType){if(c=!(!t||"\n"!=e.nodeValue[t-1]),c&&t==e.nodeValue.length)for(let n,r=e;r;r=r.parentNode){if(n=r.nextSibling){"BR"==n.nodeName&&(s=l={node:n.parentNode,offset:fe(n)+1});break}let e=r.pmViewDesc;if(e&&e.node&&e.node.isBlock)break}}else{let n=e.childNodes[t-1];c=n&&("BR"==n.nodeName||"false"==n.contentEditable)}}if(De&&h.focusNode&&h.focusNode!=l.node&&1==h.focusNode.nodeType){let e=h.focusNode.childNodes[h.focusOffset];e&&"false"==e.contentEditable&&(r=!0)}if(!(r||c&&Ie)&&we(s.node,s.offset,h.anchorNode,h.anchorOffset)&&we(l.node,l.offset,h.focusNode,h.focusOffset))return;let d=!1;if((a.extend||e==t)&&(!c||!De)){a.collapse(s.node,s.offset);try{e!=t&&a.extend(l.node,l.offset),d=!0}catch(p){}}if(!d){if(e>t){let e=s;s=l,l=e}let n=document.createRange();n.setEnd(l.node,l.offset),n.setStart(s.node,s.offset),a.removeAllRanges(),a.addRange(n)}}ignoreMutation(e){return!this.contentDOM&&"selection"!=e.type}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,r=0;r<this.children.length;r++){let i=this.children[r],o=n+i.size;if(n==o?e<=o&&t>=n:e<o&&t>n){let r=n+i.border,s=o-i.border;if(e>=r&&t<=s)return this.dirty=e==n||t==o?2:1,void(e!=r||t!=s||!i.contentLost&&i.dom.parentNode==this.contentDOM?i.markDirty(e-r,t-r):i.dirty=3);i.dirty=i.dom!=i.contentDOM||i.dom.parentNode!=this.contentDOM||i.children.length?3:2}n=o}this.dirty=2}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=1==e?2:1;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},He=class extends _e{constructor(e,t,n,r){let i,o=t.type.toDOM;if("function"==typeof o&&(o=o(n,()=>i?i.parent?i.parent.posBeforeChild(i):void 0:r)),!t.type.spec.raw){if(1!=o.nodeType){let e=document.createElement("span");e.appendChild(o),o=e}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return 0==this.dirty&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return!!t&&t(e)}ignoreMutation(e){return"selection"!=e.type||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}},Ue=class extends _e{constructor(e,t,n,r){super(e,[],t,null),this.textDOM=n,this.text=r}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"characterData"===e.type&&e.target.nodeValue==e.oldValue}},Ge=class e extends _e{constructor(e,t,n,r,i){super(e,[],n,r),this.mark=t,this.spec=i}static create(t,n,r,i){let o=i.nodeViews[n.type.name],s=o&&o(n,i,r);return s&&s.dom||(s=D.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new e(t,n,s.dom,s.contentDOM||s.dom,s)}parseRule(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return 3!=this.dirty&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),0!=this.dirty){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty<this.dirty&&(e.dirty=this.dirty),this.dirty=0}}slice(t,n,r){let i=e.create(this.parent,this.mark,!0,r),o=this.children,s=this.size;n<s&&(o=mi(o,n,s,r)),t>0&&(o=mi(o,0,t,r));for(let e=0;e<o.length;e++)o[e].parent=i;return i.children=o,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},Ye=class e extends _e{constructor(e,t,n,r,i,o,s,l,a){super(e,[],i,o),this.node=t,this.outerDeco=n,this.innerDeco=r,this.nodeDOM=s}static create(t,n,r,i,o,s){let l,a=o.nodeViews[n.type.name],h=a&&a(n,o,()=>l?l.parent?l.parent.posBeforeChild(l):void 0:s,r,i),c=h&&h.dom,d=h&&h.contentDOM;if(n.isText)if(c){if(3!=c.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else c=document.createTextNode(n.text);else if(!c){let e=D.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs);({dom:c,contentDOM:d}=e)}d||n.isText||"BR"==c.nodeName||(c.hasAttribute("contenteditable")||(c.contentEditable="false"),n.type.spec.draggable&&(c.draggable=!0));let p=c;return c=di(c,r,n),h?l=new Ze(t,n,r,i,c,d||null,p,h,o,s+1):n.isText?new Xe(t,n,r,i,c,p,o):new e(t,n,r,i,c,d||null,p,o,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(e.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(let t=this.children.length-1;t>=0;t--){let n=this.children[t];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}e.contentElement||(e.getContent=()=>n.empty)}else e.contentElement=this.contentDOM;else e.getContent=()=>this.node.content;return e}matchesNode(e,t,n){return 0==this.dirty&&e.eq(this.node)&&pi(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,r=t,o=e.composing?this.localCompositionInfo(e,t):null,s=o&&o.pos>-1?o:null,l=o&&o.pos<0,a=new nt(this,s&&s.node,e);!function(e,t,n,r){let i=t.locals(e),o=0;if(0==i.length){for(let n=0;n<e.childCount;n++){let s=e.child(n);r(s,i,t.forChild(o,s),n),o+=s.nodeSize}return}let s=0,l=[],a=null;for(let h=0;;){let c,d,p,f;for(;s<i.length&&i[s].to==o;){let e=i[s++];e.widget&&(c?(d||(d=[c])).push(e):c=e)}if(c)if(d){d.sort(ui);for(let e=0;e<d.length;e++)n(d[e],h,!!a)}else n(c,h,!!a);if(a)f=-1,p=a,a=null;else{if(!(h<e.childCount))break;f=h,p=e.child(h++)}for(let e=0;e<l.length;e++)l[e].to<=o&&l.splice(e--,1);for(;s<i.length&&i[s].from<=o&&i[s].to>o;)l.push(i[s++]);let u=o+p.nodeSize;if(p.isText){let e=u;s<i.length&&i[s].from<e&&(e=i[s].from);for(let t=0;t<l.length;t++)l[t].to<e&&(e=l[t].to);e<u&&(a=p.cut(e-o),p=p.cut(0,e-o),u=e,f=-1)}else for(;s<i.length&&i[s].to<u;)s++;r(p,p.isInline&&!p.isLeaf?l.filter(e=>!e.inline):l.slice(),t.forChild(o,p),f),o=u}}(this.node,this.innerDeco,(t,o,s)=>{t.spec.marks?a.syncToMarks(t.spec.marks,n,e,o):t.type.side>=0&&!s&&a.syncToMarks(o==this.node.childCount?i.none:this.node.child(o).marks,n,e,o),a.placeWidget(t,e,r)},(t,i,s,h)=>{let c;a.syncToMarks(t.marks,n,e,h),a.findNodeMatch(t,i,s,h)||l&&e.state.selection.from>r&&e.state.selection.to<r+t.nodeSize&&(c=a.findIndexWithChild(o.node))>-1&&a.updateNodeAt(t,i,s,c,e)||a.updateNextNode(t,i,s,e,h,r)||a.addNode(t,i,s,e,r),r+=t.nodeSize}),a.syncToMarks([],n,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||2==this.dirty)&&(s&&this.protectLocalComposition(e,s),li(this.contentDOM,this.children,e),ze&&function(e){if("UL"==e.nodeName||"OL"==e.nodeName){let t=e.style.cssText;e.style.cssText=t+"; list-style: square !important",window.getComputedStyle(e).listStyle,e.style.cssText=t}}(this.dom))}localCompositionInfo(e,t){let{from:n,to:r}=e.state.selection;if(!(e.state.selection instanceof ee)||n<t||r>t+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let e=i.nodeValue,o=function(e,t,n,r){for(let i=0,o=0;i<e.childCount&&o<=r;){let s=e.child(i++),l=o;if(o+=s.nodeSize,!s.isText)continue;let a=s.text;for(;i<e.childCount;){let t=e.child(i++);if(o+=t.nodeSize,!t.isText)break;a+=t.text}if(o>=n){if(o>=r&&a.slice(r-t.length-l,r-l)==t)return r-t.length;let e=l<r?a.lastIndexOf(t,r-l-1):-1;if(e>=0&&e+t.length+l>=n)return l+e;if(n==r&&a.length>=r+t.length-l&&a.slice(r-l,r-l+t.length)==t)return r}}return-1}(this.node.content,e,n-t,r-t);return o<0?null:{node:i,pos:o,text:e}}return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:n,text:r}){if(this.getDesc(t))return;let i=t;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let o=new Ue(this,i,t,r);e.input.compositionNodes.push(o),this.children=mi(this.children,n,n+r.length,e,o)}update(e,t,n,r){return!(3==this.dirty||!e.sameMarkup(this.node)||(this.updateInner(e,t,n,r),0))}updateInner(e,t,n,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=0}updateOuterDeco(e){if(pi(e,this.outerDeco))return;let t=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=hi(this.dom,this.nodeDOM,ai(this.outerDeco,this.node,t),ai(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.nodeDOM.draggable=!0))}deselectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}},Xe=class e extends Ye{constructor(e,t,n,r,i,o,s){super(e,t,n,r,i,null,o,s,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,r){return!(3==this.dirty||0!=this.dirty&&!this.inParent()||!e.sameMarkup(this.node)||(this.updateOuterDeco(t),0==this.dirty&&e.text==this.node.text||e.text==this.nodeDOM.nodeValue||(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=0,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"characterData"!=e.type&&"selection"!=e.type}slice(t,n,r){let i=this.node.cut(t,n),o=document.createTextNode(i.text);return new e(this.parent,i,this.outerDeco,this.innerDeco,o,o,r)}markDirty(e,t){super.markDirty(e,t),this.dom==this.nodeDOM||0!=e&&t!=this.nodeDOM.nodeValue.length||(this.dirty=3)}get domAtom(){return!1}isText(e){return this.node.text==e}},Qe=class extends _e{parseRule(){return{ignore:!0}}matchesHack(e){return 0==this.dirty&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return"IMG"==this.dom.nodeName}},Ze=class extends Ye{constructor(e,t,n,r,i,o,s,l,a,h){super(e,t,n,r,i,o,s,a,h),this.spec=l}update(e,t,n,r){if(3==this.dirty)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,t,n);return i&&this.updateInner(e,t,n,r),i}return!(!this.contentDOM&&!e.isLeaf)&&super.update(e,t,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,r){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,r)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return!!this.spec.stopEvent&&this.spec.stopEvent(e)}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}},(et=function(e){e&&(this.nodeName=e)}).prototype=Object.create(null),tt=[new et],nt=class{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=function(e,t){let n=t,r=n.children.length,i=e.childCount,o=new Map,s=[];e:for(;i>0;){let l;for(;;)if(r){let e=n.children[r-1];if(!(e instanceof Ge)){l=e,r--;break}n=e,r=e.children.length}else{if(n==t)break e;r=n.parent.children.indexOf(n),n=n.parent}let a=l.node;if(a){if(a!=e.child(i-1))break;--i,o.set(l,i),s.push(l)}}return{index:i,matched:o,matches:s.reverse()}}(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,r){let i=0,o=this.stack.length>>1,s=Math.min(o,e.length);for(;i<s&&(i==o-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&!1!==e[i].type.spec.spanning;)i++;for(;i<o;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<e.length;){this.stack.push(this.top,this.index+1);let i=-1,s=this.top.children.length;r<this.preMatch.index&&(s=Math.min(this.index+3,s));for(let t=this.index;t<s;t++){let n=this.top.children[t];if(n.matchesMark(e[o])&&!this.isLocked(n.dom)){i=t;break}}if(i>-1)i>this.index&&(this.changed=!0,this.destroyBetween(this.index,i)),this.top=this.top.children[this.index];else{let r=Ge.create(this.top,e[o],t,n);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,o++}}findNodeMatch(e,t,n,r){let i,o=-1;if(r>=this.preMatch.index&&(i=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&i.matchesNode(e,t,n))o=this.top.children.indexOf(i,this.index);else for(let s=this.index,l=Math.min(this.top.children.length,s+5);s<l;s++){let r=this.top.children[s];if(r.matchesNode(e,t,n)&&!this.preMatch.matched.has(r)){o=s;break}}return!(o<0||(this.destroyBetween(this.index,o),this.index++,0))}updateNodeAt(e,t,n,r,i){let o=this.top.children[r];return 3==o.dirty&&o.dom==o.contentDOM&&(o.dirty=2),!!o.update(e,t,n,i)&&(this.destroyBetween(this.index,r),this.index++,!0)}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let t=e.pmViewDesc;if(t)for(let e=this.index;e<this.top.children.length;e++)if(this.top.children[e]==t)return e;return-1}e=t}}updateNextNode(e,t,n,r,i,o){for(let s=this.index;s<this.top.children.length;s++){let l=this.top.children[s];if(l instanceof Ye){let a=this.preMatch.matched.get(l);if(null!=a&&a!=i)return!1;let h,c=l.dom,d=this.isLocked(c)&&!(e.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==e.text&&3!=l.dirty&&pi(t,l.outerDeco));if(!d&&l.update(e,t,n,r))return this.destroyBetween(this.index,s),l.dom!=c&&(this.changed=!0),this.index++,!0;if(!d&&(h=this.recreateWrapper(l,e,t,n,r,o)))return this.destroyBetween(this.index,s),this.top.children[this.index]=h,h.contentDOM&&(h.dirty=2,h.updateChildren(r,o+1),h.dirty=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,r,i,o){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!pi(n,e.outerDeco)||!r.eq(e.innerDeco))return null;let s=Ye.create(this.top,t,n,r,i,o);if(s.contentDOM){s.children=e.children,e.children=[];for(let e of s.children)e.parent=s}return e.destroy(),s}addNode(e,t,n,r,i){let o=Ye.create(this.top,e,t,n,r,i);o.contentDOM&&o.updateChildren(r,i+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,t,n){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(!r||!r.matchesWidget(e)||e!=r.widget&&r.widget.type.toDOM.parentNode){let r=new He(this.top,e,t,n);this.top.children.splice(this.index++,0,r),this.changed=!0}else this.index++}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Ge;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Xe)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Ie||Ae)&&e&&"false"==e.dom.contentEditable&&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);"IMG"==e&&(n.className="ProseMirror-separator",n.alt=""),"BR"==e&&(n.className="ProseMirror-trailingBreak");let r=new Qe(this.top,[],n,null);t!=this.top?t.children.push(r):t.children.splice(this.index++,0,r),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||1==e.nodeType&&e.contains(this.lock.parentNode))}},rt=Ie||Ae&&Re<63,it=/^(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,ot={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]},st=null,lt=null,at={},ht={},ct={touchstart:!0,touchmove:!0},dt=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}},ht.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=16==n.keyCode||n.shiftKey,!oo(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!Be||!Ae||13!=n.keyCode))if(229!=n.keyCode&&e.domObserver.forceFlush(),!ze||13!=n.keyCode||n.ctrlKey||n.altKey||n.metaKey)e.someProp("handleKeyDown",t=>t(e,n))||Fi(e,n)?n.preventDefault():Ui(e,"key");else{let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==t&&(e.someProp("handleKeyDown",t=>t(e,Wr(13,"Enter"))),e.input.lastIOSEnter=0)},200)}},ht.keyup=(e,t)=>{16==t.keyCode&&(e.input.shiftKey=!1)},ht.keypress=(e,t)=>{let n=t;if(oo(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||Pe&&n.metaKey)return;if(e.someProp("handleKeyPress",t=>t(e,n)))return void n.preventDefault();let r=e.state.selection;if(!(r instanceof ee&&r.$from.sameParent(r.$to))){let t=String.fromCharCode(n.charCode),i=()=>e.state.tr.insertText(t).scrollIntoView();/[\r\n]/.test(t)||e.someProp("handleTextInput",n=>n(e,r.$from.pos,r.$to.pos,t,i))||e.dispatch(i()),n.preventDefault()}},pt=Pe?"metaKey":"ctrlKey",at.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=io(e),i=Date.now(),o="singleClick";i-e.input.lastClick.time<500&&function(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}(n,e.input.lastClick)&&!n[pt]&&e.input.lastClick.button==n.button&&("singleClick"==e.input.lastClick.type?o="doubleClick":"doubleClick"==e.input.lastClick.type&&(o="tripleClick")),e.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:o,button:n.button};let s=e.posAtCoords(Qi(n));s&&("singleClick"==o?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new ft(e,s,n,!!r)):("doubleClick"==o?no:ro)(e,s.pos,s.inside,n)?n.preventDefault():Ui(e,"pointer"))},ft=class{constructor(e,t,n,r){let i,o;if(this.view=e,this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[pt],this.allowDefault=n.shiftKey,t.inside>-1)i=e.state.doc.nodeAt(t.inside),o=t.inside;else{let n=e.state.doc.resolve(t.pos);i=n.parent,o=n.depth?n.before():0}const s=r?null:n.target,l=s?e.docView.nearestDesc(s,!0):null;this.target=l&&1==l.nodeDOM.nodeType?l.nodeDOM:null;let{selection:a}=e.state;0==n.button&&(i.type.spec.draggable&&!1!==i.type.spec.selectable||a instanceof ne&&a.from<=o&&a.to>o)&&(this.mightDrag={node:i,pos:o,addAttr:!(!this.target||this.target.draggable),setUneditable:!(!this.target||!De||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()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),Ui(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),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(()=>wi(this.view)),this.view.input.mouseDown=null}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(Qi(e))),this.updateAllowDefault(e),this.allowDefault||!t?Ui(this.view,"pointer"):to(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():0==e.button&&(this.flushed||Ie&&this.mightDrag&&!this.mightDrag.node.isAtom||Ae&&!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)?(eo(this.view,X.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):Ui(this.view,"pointer")}move(e){this.updateAllowDefault(e),Ui(this.view,"pointer"),0==e.buttons&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}},at.touchstart=e=>{e.input.lastTouch=Date.now(),io(e),Ui(e,"pointer")},at.touchmove=e=>{e.input.lastTouch=Date.now(),Ui(e,"pointer")},at.contextmenu=e=>io(e),ut=Be?5e3:-1,ht.compositionstart=ht.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof ee&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>!1===e.type.spec.inclusive)||Ae&&$e&&function(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||1!=t.nodeType||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return 1==r.nodeType&&"false"==r.contentEditable}(e)))e.markCursor=e.state.storedMarks||n.marks(),ho(e,!0),e.markCursor=null;else if(ho(e,!t.selection.empty),De&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,r=t.focusOffset;n&&1==n.nodeType&&0!=r;){let t=r<0?n.lastChild:n.childNodes[r-1];if(!t)break;if(3==t.nodeType){let n=e.domSelection();n&&n.collapse(t,t.nodeValue.length);break}n=t,r=-1}}e.input.composing=!0}so(e,ut)},ht.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,so(e,20))},mt=Ne&&Te<15||ze&&Fe<604,at.copy=ht.cut=(e,t)=>{let n=t,r=e.state.selection,i="cut"==n.type;if(r.empty)return;let o=mt?null:n.clipboardData,{dom:s,text:l}=Li(e,r.content());o?(n.preventDefault(),o.clearData(),o.setData("text/html",s.innerHTML),o.setData("text/plain",l)):function(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(t),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}(e,s),i&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},ht.paste=(e,t)=>{let n=t;if(e.composing&&!Be)return;let r=mt?null:n.clipboardData,i=e.input.shiftKey&&45!=e.input.lastKeyCode;r&&co(e,po(r),r.getData("text/html"),i,n)?n.preventDefault():function(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=e.input.shiftKey&&45!=e.input.lastKeyCode;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?co(e,r.value,null,i,t):co(e,r.textContent,r.innerHTML,i,t)},50)}(e,n)},gt=class{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}},yt=Pe?"altKey":"ctrlKey",at.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i,o=e.state.selection,s=o.empty?null:e.posAtCoords(Qi(n));if(s&&s.pos>=o.from&&s.pos<=(o instanceof ne?o.to-1:o.to));else if(r&&r.mightDrag)i=ne.create(e.state.doc,r.mightDrag.pos);else if(n.target&&1==n.target.nodeType){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&(i=ne.create(e.state.doc,t.posBefore))}let{dom:l,text:a,slice:h}=Li(e,(i||e.state.selection).content());(!n.dataTransfer.files.length||!Ae||Re>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(mt?"Text":"text/html",l.innerHTML),n.dataTransfer.effectAllowed="copyMove",mt||n.dataTransfer.setData("text/plain",a),e.dragging=new gt(h,fo(e,n),i)},at.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},ht.dragover=ht.dragenter=(e,t)=>t.preventDefault(),ht.drop=(e,t)=>{try{!function(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(Qi(t));if(!r)return;let i=e.state.doc.resolve(r.pos),o=n&&n.slice;o?e.someProp("transformPasted",t=>{o=t(o,e,!1)}):o=Ji(e,po(t.dataTransfer),mt?null:t.dataTransfer.getData("text/html"),!1,i);let l=!(!n||!fo(e,t));if(e.someProp("handleDrop",n=>n(e,t,o||s.empty,l)))return void t.preventDefault();if(!o)return;t.preventDefault();let a=o?function(e,t,n){let r=e.resolve(t);if(!n.content.size)return t;let i=n.content;for(let o=0;o<n.openStart;o++)i=i.firstChild.content;for(let o=1;o<=(0==n.openStart&&n.size?2:1);o++)for(let e=r.depth;e>=0;e--){let t=e==r.depth?0:r.pos<=(r.start(e+1)+r.end(e+1))/2?-1:1,n=r.index(e)+(t>0?1:0),s=r.node(e),l=!1;if(1==o)l=s.canReplace(n,n,i);else{let e=s.contentMatchAt(n).findWrapping(i.firstChild.type);l=e&&s.canReplaceWith(n,n,e[0])}if(l)return 0==t?r.pos:t<0?r.before(e+1):r.after(e+1)}return null}(e.state.doc,i.pos,o):i.pos;null==a&&(a=i.pos);let h=e.state.tr;if(l){let{node:e}=n;e?e.replace(h):h.deleteSelection()}let c=h.mapping.map(a),d=0==o.openStart&&0==o.openEnd&&1==o.content.childCount,p=h.doc;if(d?h.replaceRangeWith(c,c,o.content.firstChild):h.replaceRange(c,c,o),h.doc.eq(p))return;let f=h.doc.resolve(c);if(d&&ne.isSelectable(o.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(o.content.firstChild))h.setSelection(new ne(f));else{let t=h.mapping.map(a);h.mapping.maps[h.mapping.maps.length-1].forEach((e,n,r,i)=>t=i),h.setSelection(Ci(e,f,h.doc.resolve(t)))}e.focus(),e.dispatch(h.setMeta("uiEvent","drop"))}(e,t,e.dragging)}finally{e.dragging=null}},at.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&wi(e)},20))},at.blur=(e,t)=>{let n=t;e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)},at.beforeinput=(e,t)=>{if(Ae&&Be&&"deleteContentBackward"==t.inputType){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=t)return;if(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",t=>t(e,Wr(8,"Backspace"))))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())},50)}};for(let e in ht)at[e]=ht[e];for(wt=class e{constructor(e,t){this.toDOM=e,this.spec=t||St,this.side=this.spec.side||0}map(e,t,n,r){let{pos:i,deleted:o}=e.mapResult(t.from+r,this.side<0?-1:1);return o?null:new kt(i-n,i-n,this)}valid(){return!0}eq(t){return this==t||t instanceof e&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&uo(this.spec,t.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},vt=class e{constructor(e,t){this.attrs=e,this.spec=t||St}map(e,t,n,r){let i=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,o=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return i>=o?null:new kt(i,o,this)}valid(e,t){return t.from<t.to}eq(t){return this==t||t instanceof e&&uo(this.attrs,t.attrs)&&uo(this.spec,t.spec)}static is(t){return t.type instanceof e}destroy(){}},xt=class e{constructor(e,t){this.attrs=e,this.spec=t||St}map(e,t,n,r){let i=e.mapResult(t.from+r,1);if(i.deleted)return null;let o=e.mapResult(t.to+r,-1);return o.deleted||o.pos<=i.pos?null:new kt(i.pos-n,o.pos-n,this)}valid(e,t){let n,{index:r,offset:i}=e.content.findIndex(t.from);return i==t.from&&!(n=e.child(r)).isText&&i+n.nodeSize==t.to}eq(t){return this==t||t instanceof e&&uo(this.attrs,t.attrs)&&uo(this.spec,t.spec)}destroy(){}},e("v",kt=class e{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(t,n){return new e(t,n,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(t,n,r){return new e(t,t,new wt(n,r))}static inline(t,n,r,i){return new e(t,n,new vt(r,i))}static node(t,n,r,i){return new e(t,n,new xt(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof vt}get widget(){return this.type instanceof wt}}),bt=[],St={},e("y",Ct=class e{constructor(e,t){this.local=e.length?e:bt,this.children=t.length?t:bt}static create(e,t){return t.length?vo(t,e,0,St):Mt}find(e,t,n){let r=[];return this.findInner(null==e?0:e,null==t?1e9:t,r,0,n),r}findInner(e,t,n,r,i){for(let o=0;o<this.local.length;o++){let s=this.local[o];s.from<=t&&s.to>=e&&(!i||i(s.spec))&&n.push(s.copy(s.from+r,s.to+r))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<t&&this.children[o+1]>e){let s=this.children[o]+1;this.children[o+2].findInner(e-s,t-s,n,r+s,i)}}map(e,t,n){return this==Mt||0==e.maps.length?this:this.mapInner(e,t,0,0,n||St)}mapInner(t,n,r,i,o){let s;for(let e=0;e<this.local.length;e++){let l=this.local[e].map(t,r,i);l&&l.type.valid(n,l)?(s||(s=[])).push(l):o.onRemove&&o.onRemove(this.local[e].spec)}return this.children.length?mo(this.children,s||[],t,n,r,i,o):s?new e(s.sort(xo),bt):Mt}add(t,n){return n.length?this==Mt?e.create(t,n):this.addInner(t,n,0):this}addInner(t,n,r){let i,o=0;t.forEach((e,t)=>{let s,l=t+r;if(s=yo(n,e,l)){for(i||(i=this.children.slice());o<i.length&&i[o]<t;)o+=3;i[o]==t?i[o+2]=i[o+2].addInner(e,s,l+1):i.splice(o,0,t,t+e.nodeSize,vo(s,e,l+1,St)),o+=3}});let s=go(o?wo(n):n,-r);for(let e=0;e<s.length;e++)s[e].type.valid(t,s[e])||s.splice(e--,1);return new e(s.length?this.local.concat(s).sort(xo):this.local,i||this.children)}remove(e){return 0==e.length||this==Mt?this:this.removeInner(e,0)}removeInner(t,n){let r=this.children,i=this.local;for(let e=0;e<r.length;e+=3){let i,o=r[e]+n,s=r[e+1]+n;for(let e,n=0;n<t.length;n++)(e=t[n])&&e.from>o&&e.to<s&&(t[n]=null,(i||(i=[])).push(e));if(!i)continue;r==this.children&&(r=this.children.slice());let l=r[e+2].removeInner(i,o+1);l!=Mt?r[e+2]=l:(r.splice(e,3),e-=3)}if(i.length)for(let e,o=0;o<t.length;o++)if(e=t[o])for(let t=0;t<i.length;t++)i[t].eq(e,n)&&(i==this.local&&(i=this.local.slice()),i.splice(t--,1));return r==this.children&&i==this.local?this:i.length||r.length?new e(i,r):Mt}forChild(t,n){if(this==Mt)return this;if(n.isLeaf)return e.empty;let r,i;for(let e=0;e<this.children.length;e+=3)if(this.children[e]>=t){this.children[e]==t&&(r=this.children[e+2]);break}let o=t+1,s=o+n.content.size;for(let e=0;e<this.local.length;e++){let t=this.local[e];if(t.from<s&&t.to>o&&t.type instanceof vt){let e=Math.max(o,t.from)-o,n=Math.min(s,t.to)-o;e<n&&(i||(i=[])).push(t.copy(e,n))}}if(i){let t=new e(i.sort(xo),bt);return r?new Ot([t,r]):t}return r||Mt}eq(t){if(this==t)return!0;if(!(t instanceof e)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(let e=0;e<this.local.length;e++)if(!this.local[e].eq(t.local[e]))return!1;for(let e=0;e<this.children.length;e+=3)if(this.children[e]!=t.children[e]||this.children[e+1]!=t.children[e+1]||!this.children[e+2].eq(t.children[e+2]))return!1;return!0}locals(e){return ko(this.localsInner(e))}localsInner(e){if(this==Mt)return bt;if(e.inlineContent||!this.local.some(vt.is))return this.local;let t=[];for(let n=0;n<this.local.length;n++)this.local[n].type instanceof vt||t.push(this.local[n]);return t}forEachSet(e){e(this)}}),Ct.empty=new Ct([],[]),Ct.removeOverlap=ko,Mt=Ct.empty,Ot=class e{constructor(e){this.members=e}map(t,n){const r=this.members.map(e=>e.map(t,n,St));return e.from(r)}forChild(t,n){if(n.isLeaf)return Ct.empty;let r=[];for(let i=0;i<this.members.length;i++){let o=this.members[i].forChild(t,n);o!=Mt&&(o instanceof e?r=r.concat(o.members):r.push(o))}return e.from(r)}eq(t){if(!(t instanceof e)||t.members.length!=this.members.length)return!1;for(let e=0;e<this.members.length;e++)if(!this.members[e].eq(t.members[e]))return!1;return!0}locals(e){let t,n=!0;for(let r=0;r<this.members.length;r++){let i=this.members[r].localsInner(e);if(i.length)if(t){n&&(t=t.slice(),n=!1);for(let e=0;e<i.length;e++)t.push(i[e])}else t=i}return t?ko(n?t:t.sort(xo)):bt}static from(t){switch(t.length){case 0:return Mt;case 1:return t[0];default:return new e(t.every(e=>e instanceof Ct)?t:t.reduce((e,t)=>e.concat(t instanceof Ct?t:t.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}},Nt={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Tt=Ne&&Te<=11,Dt=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}},Et=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Dt,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);Ne&&Te<=11&&t.some(e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():Ie&&e.composing&&t.some(e=>"childList"==e.type&&"TR"==e.target.nodeName)?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),Tt&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.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,Nt)),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(Mi(this.view)){if(this.suppressingSelectionUpdates)return wi(this.view);if(Ne&&Te<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&we(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,n=new Set;for(let i=e.focusNode;i;i=ue(i))n.add(i);for(let i=e.anchorNode;i;i=ue(i))if(n.has(i)){t=i;break}let r=t&&this.view.docView.nearestDesc(t);return r&&r.ignoreMutation({type:"selection",target:3==t.nodeType?t.parentNode:t})?(this.setCurSelection(),!0):void 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(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&Mi(e)&&!this.ignoreSelectionChange(n),i=-1,o=-1,s=!1,l=[];if(e.editable)for(let h=0;h<t.length;h++){let e=this.registerMutation(t[h],l);e&&(i=i<0?e.from:Math.min(e.from,i),o=o<0?e.to:Math.max(e.to,o),e.typeOver&&(s=!0))}if(!l.some(e=>"BR"==e.nodeName)||8!=e.input.lastKeyCode&&46!=e.input.lastKeyCode){if(De&&l.length){let t=l.filter(e=>"BR"==e.nodeName);if(2==t.length){let[e,n]=t;e.parentNode&&e.parentNode.parentNode==n.parentNode?n.remove():e.remove()}else{let{focusNode:n}=this.currentSelection;for(let r of t){let t=r.parentNode;!t||"LI"!=t.nodeName||n&&Mo(e,n)==t||r.remove()}}}}else for(let h of l)if("BR"==h.nodeName&&h.parentNode){let e=h.nextSibling;for(;e&&1==e.nodeType;){if("false"==e.contentEditable){h.parentNode.removeChild(h);break}e=e.firstChild}}let a=null;i<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&xe(n)&&(a=gi(e))&&a.eq(X.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,wi(e),this.currentSelection.set(n),e.scrollToSelection()):(i>-1||r)&&(i>-1&&(e.docView.markDirty(i,o),function(e){if(!At.has(e)&&(At.set(e,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace))){if(e.requiresGeckoHackNode=De,Rt)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."),Rt=!0}}(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,function(e,t){var n;let{focusNode:r,focusOffset:i}=e.domSelectionRange();for(let o of t)if("TR"==(null===(n=o.parentNode)||void 0===n?void 0:n.nodeName)){let t=o.nextSibling;for(;t&&"TD"!=t.nodeName&&"TH"!=t.nodeName;)t=t.nextSibling;if(t){let n=t;for(;;){let e=n.firstChild;if(!e||1!=e.nodeType||"false"==e.contentEditable||/^(BR|IMG)$/.test(e.nodeName))break;n=e}n.insertBefore(o,n.firstChild),r==o&&e.domSelection().collapse(o,i)}else o.parentNode.removeChild(o)}}(e,l)),this.handleDOMChange(i,o,s,l),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||wi(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("attributes"==e.type&&(n==this.view.docView||"contenteditable"==e.attributeName||"style"==e.attributeName&&!e.oldValue&&!e.target.getAttribute("style")))return null;if(!n||n.ignoreMutation(e))return null;if("childList"==e.type){for(let n=0;n<e.addedNodes.length;n++){let r=e.addedNodes[n];t.push(r),3==r.nodeType&&(this.lastChangedTextNode=r)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let r=e.previousSibling,i=e.nextSibling;if(Ne&&Te<=11&&e.addedNodes.length)for(let t=0;t<e.addedNodes.length;t++){let{previousSibling:n,nextSibling:o}=e.addedNodes[t];(!n||Array.prototype.indexOf.call(e.addedNodes,n)<0)&&(r=n),(!o||Array.prototype.indexOf.call(e.addedNodes,o)<0)&&(i=o)}let o=r&&r.parentNode==e.target?fe(r)+1:0,s=n.localPosFromDOM(e.target,o,-1),l=i&&i.parentNode==e.target?fe(i):e.target.childNodes.length;return{from:s,to:n.localPosFromDOM(e.target,l,1)}}return"attributes"==e.type?{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})}},At=new WeakMap,Rt=!1,It=/^(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,e("b",zt=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 dt,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Po),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):"function"==typeof e?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Io(this),Ro(this),this.nodeViews=zo(this),this.docView=si(this.state.doc,Ao(this),So(this),this.dom,this),this.domObserver=new Et(this,(e,t,n,r)=>No(this,e,t,n,r)),this.domObserver.start(),function(e){for(let t in at){let n=at[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{!Xi(e,t)||Yi(e,t)||!e.editable&&t.type in ht||n(e,t)},ct[t]?{passive:!0}:void 0)}Ie&&e.dom.addEventListener("input",()=>null),Gi(e)}(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&&Gi(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Po),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 r=this.state,i=!1,o=!1;e.storedMarks&&this.composing&&(lo(this),o=!0),this.state=e;let s=r.plugins!=e.plugins||this._props.plugins!=t.plugins;if(s||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=zo(this);(function(e,t){let n=0,r=0;for(let i in e){if(e[i]!=t[i])return!0;n++}for(let i in t)r++;return n!=r})(e,this.nodeViews)&&(this.nodeViews=e,i=!0)}(s||t.handleDOMEvents!=this._props.handleDOMEvents)&&Gi(this),this.editable=Io(this),Ro(this);let l=So(this),a=Ao(this),h=r.plugins==e.plugins||r.doc.eq(e.doc)?e.scrollToSelection>r.scrollToSelection?"to selection":"preserve":"reset",c=i||!this.docView.matchesNode(e.doc,a,l);!c&&e.selection.eq(r.selection)||(o=!0);let d="preserve"==h&&o&&null==this.dom.style.overflowAnchor&&function(e){let t,n,r=e.dom.getBoundingClientRect(),i=Math.max(0,r.top);for(let o=(r.left+r.right)/2,s=i+1;s<Math.min(innerHeight,r.bottom);s+=5){let r=e.root.elementFromPoint(o,s);if(!r||r==e.dom||!e.dom.contains(r))continue;let l=r.getBoundingClientRect();if(l.top>=i-20){t=r,n=l.top;break}}return{refDOM:t,refTop:n,stack:Hr(e.dom)}}(this);if(o){this.domObserver.stop();let t=c&&(Ne||Ae)&&!this.composing&&!r.selection.empty&&!e.selection.empty&&function(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}(r.selection,e.selection);if(c){let n=Ae?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=ao(this)),!i&&this.docView.update(e.doc,a,l,this)||(this.docView.updateOuterDeco(a),this.docView.destroy(),this.docView=si(e.doc,a,l,this.dom,this)),!n||this.trackWrites&&this.dom.contains(this.trackWrites)||(t=!0)}t||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&function(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return we(t.node,t.offset,n.anchorNode,n.anchorOffset)}(this))?wi(this,t):(bi(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(r),(null===(n=this.dragging)||void 0===n?void 0:n.node)&&!r.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,r),"reset"==h?this.dom.scrollTop=0:"to selection"==h?this.scrollToSelection():d&&function({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;Ur(n,0==r?0:r-t)}(d)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(e&&this.dom.contains(1==e.nodeType?e:e.parentNode))if(this.someProp("handleScrollToSelection",e=>e(this)));else if(this.state.selection instanceof ne){let t=this.docView.domAfterPos(this.state.selection.from);1==t.nodeType&&_r(this,t.getBoundingClientRect(),e)}else _r(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)for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e<this.directPlugins.length;e++){let t=this.directPlugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let t=this.state.plugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}}}updateDraggedNode(e,t){let n=e.node,r=-1;if(n.from<this.state.doc.content.size&&this.state.doc.nodeAt(n.from)==n.node)r=n.from;else{let e=n.from+(this.state.doc.content.size-t.doc.content.size);(e>0&&e<this.state.doc.content.size&&this.state.doc.nodeAt(e))==n.node&&(r=e)}this.dragging=new gt(e.slice,e.move,r<0?void 0:ne.create(this.state.doc,r))}someProp(e,t){let n,r=this._props&&this._props[e];if(null!=r&&(n=t?t(r):r))return n;for(let o=0;o<this.directPlugins.length;o++){let r=this.directPlugins[o].props[e];if(null!=r&&(n=t?t(r):r))return n}let i=this.state.plugins;if(i)for(let o=0;o<i.length;o++){let r=i[o].props[e];if(null!=r&&(n=t?t(r):r))return n}}hasFocus(){if(Ne){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("false"==e.contentEditable)return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&function(e){if(e.setActive)return e.setActive();if(Le)return e.focus(Le);let t=Hr(e);e.focus(null==Le?{get preventScroll(){return Le={preventScroll:!0},!0}}:void 0),Le||(Le=!1,Ur(t,0))}(this.dom),wi(this),this.domObserver.start()}get root(){let e=this._root;if(null==e)for(let t=this.dom.parentNode;t;t=t.parentNode)if(9==t.nodeType||11==t.nodeType&&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 Qr(this,e)}coordsAtPos(e,t=1){return ti(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 r=this.docView.posFromDOM(e,t,n);if(null==r)throw new RangeError("DOM position not inside the editor");return r}endOfTextblock(e,t){return oi(this,t||this.state,e)}pasteHTML(e,t){return co(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return co(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return Li(this,e)}destroy(){this.docView&&(function(e){e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],So(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,ye())}get isDestroyed(){return null==this.docView}dispatchEvent(e){return function(e,t){Yi(e,t)||!at[t.type]||!e.editable&&t.type in ht||at[t.type](e,t)}(this,e)}domSelectionRange(){let e=this.domSelection();return e?Ie&&11===this.root.nodeType&&function(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}(this.dom.ownerDocument)==this.dom&&function(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return Co(e,n)}let n;function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),e.dom.removeEventListener("beforeinput",r,!0),n?Co(e,n):null}(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}),zt.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))},Pt={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:"'"},$t={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Bt="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),Vt="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),t=0;t<10;t++)Pt[48+t]=Pt[96+t]=String(t);for(var t=1;t<=24;t++)Pt[t+111]="F"+t;for(t=65;t<=90;t++)Pt[t]=String.fromCharCode(t+32),$t[t]=String.fromCharCode(t);for(Ft in Pt)$t.hasOwnProperty(Ft)||($t[Ft]=Pt[Ft]);var zn;Lt="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Jt="undefined"!=typeof navigator&&/Win/.test(navigator.platform),Wt=(e,t)=>!e.selection.empty&&(t&&t(e.tr.deleteSelection().scrollIntoView()),!0),qt=(e,t,n)=>{let r=function(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("backward",e):n.parentOffset>0)?null:n}(e,n);if(!r)return!1;let i=Lo(r);if(!i){let n=r.blockRange(),i=n&&gr(n);return null!=i&&(t&&t(e.tr.lift(n,i).scrollIntoView()),!0)}let o=i.nodeBefore;if(qo(e,i,t,-1))return!0;if(0==r.parent.content.size&&(Fo(o,"end")||ne.isSelectable(o)))for(let l=r.depth;;l--){let n=Sr(e.doc,r.before(l),r.after(l),s.empty);if(n&&n.slice.size<n.to-n.from){if(t){let r=e.tr.step(n);r.setSelection(Fo(o,"end")?X.findFrom(r.doc.resolve(r.mapping.map(i.pos,-1)),-1):ne.create(r.doc,i.pos-o.nodeSize)),t(r.scrollIntoView())}return!0}if(1==l||r.node(l-1).childCount>1)break}return!(!o.isAtom||i.depth!=r.depth-1||(t&&t(e.tr.delete(i.pos-o.nodeSize,i.pos).scrollIntoView()),0))},Kt=(e,t,n)=>{let{$head:r,empty:i}=e.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",e):r.parentOffset>0)return!1;o=Lo(r)}let s=o&&o.nodeBefore;return!(!s||!ne.isSelectable(s)||(t&&t(e.tr.setSelection(ne.create(e.doc,o.pos-s.nodeSize)).scrollIntoView()),0))},jt=(e,t,n)=>{let r=function(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("forward",e):n.parentOffset<n.parent.content.size)?null:n}(e,n);if(!r)return!1;let i=Jo(r);if(!i)return!1;let o=i.nodeAfter;if(qo(e,i,t,1))return!0;if(0==r.parent.content.size&&(Fo(o,"start")||ne.isSelectable(o))){let n=Sr(e.doc,r.before(),r.after(),s.empty);if(n&&n.slice.size<n.to-n.from){if(t){let r=e.tr.step(n);r.setSelection(Fo(o,"start")?X.findFrom(r.doc.resolve(r.mapping.map(i.pos)),1):ne.create(r.doc,r.mapping.map(i.pos))),t(r.scrollIntoView())}return!0}}return!(!o.isAtom||i.depth!=r.depth-1||(t&&t(e.tr.delete(i.pos,i.pos+o.nodeSize).scrollIntoView()),0))},_t=(e,t,n)=>{let{$head:r,empty:i}=e.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",e):r.parentOffset<r.parent.content.size)return!1;o=Jo(r)}let s=o&&o.nodeAfter;return!(!s||!ne.isSelectable(s)||(t&&t(e.tr.setSelection(ne.create(e.doc,o.pos)).scrollIntoView()),0))},Ht=(e,t)=>{let{$head:n,$anchor:r}=e.selection;return!(!n.parent.type.spec.code||!n.sameParent(r)||(t&&t(e.tr.insertText("\n").scrollIntoView()),0))},Ut=(e,t)=>{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),o=n.indexAfter(-1),s=Wo(i.contentMatchAt(o));if(!s||!i.canReplaceWith(o,o,s))return!1;if(t){let r=n.after(),i=e.tr.replaceWith(r,r,s.createAndFill());i.setSelection(X.near(i.doc.resolve(r),1)),t(i.scrollIntoView())}return!0},Gt=(e,t)=>{let n=e.selection,{$from:r,$to:i}=n;if(n instanceof ie||r.parent.inlineContent||i.parent.inlineContent)return!1;let o=Wo(i.parent.contentMatchAt(i.indexAfter()));if(!o||!o.isTextblock)return!1;if(t){let n=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,s=e.tr.insert(n,o.createAndFill());s.setSelection(ee.create(s.doc,n+1)),t(s.scrollIntoView())}return!0},Yt=(e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let r=n.before();if(kr(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),i=r&&gr(r);return null!=i&&(t&&t(e.tr.lift(r,i).scrollIntoView()),!0)},Xt=(e,t)=>{let{$from:n,$to:r}=e.selection;if(e.selection instanceof ne&&e.selection.node.isBlock)return!(!n.parentOffset||!kr(e.doc,n.pos)||(t&&t(e.tr.split(n.pos).scrollIntoView()),0));if(!n.depth)return!1;let i,o,s=[],l=!1,a=!1;for(let p=n.depth;;p--){if(n.node(p).isBlock){l=n.end(p)==n.pos+(n.depth-p),a=n.start(p)==n.pos-(n.depth-p),o=Wo(n.node(p-1).contentMatchAt(n.indexAfter(p-1)));let e=zn&&zn(r.parent,l,n);s.unshift(e||(l&&o?{type:o}:null)),i=p;break}if(1==p)return!1;s.unshift(null)}let h=e.tr;(e.selection instanceof ee||e.selection instanceof ie)&&h.deleteSelection();let c=h.mapping.map(n.pos),d=kr(h.doc,c,s.length,s);if(d||(s[0]=o?{type:o}:null,d=kr(h.doc,c,s.length,s)),!d)return!1;if(h.split(c,s.length,s),!l&&a&&n.node(i).type!=o){let e=h.mapping.map(n.before(i)),t=h.doc.resolve(e);o&&n.node(i-1).canReplaceWith(t.index(),t.index()+1,o)&&h.setNodeMarkup(h.mapping.map(n.before(i)),o)}return t&&t(h.scrollIntoView()),!0},Qt=(e,t)=>(t&&t(e.tr.setSelection(new ie(e.doc))),!0),Zt=Ko(-1),en=Ko(1),tn=jo(Wt,qt,Kt),nn=jo(Wt,jt,_t),rn={Enter:jo(Ht,Gt,Yt,Xt),"Mod-Enter":Ut,Backspace:tn,"Mod-Backspace":tn,"Shift-Backspace":tn,Delete:nn,"Mod-Delete":nn,"Mod-a":Qt},on={"Ctrl-h":rn.Backspace,"Alt-Backspace":rn["Mod-Backspace"],"Ctrl-d":rn.Delete,"Ctrl-Alt-Backspace":rn["Mod-Delete"],"Alt-Delete":rn["Mod-Delete"],"Alt-d":rn["Mod-Delete"],"Ctrl-a":Zt,"Ctrl-e":en};for(let e in rn)on[e]=rn[e];e("m",("undefined"!=typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):"undefined"!=typeof os&&os.platform&&"darwin"==os.platform())?on:rn),sn=200,(ln=function(){}).prototype.append=function(e){return e.length?(e=ln.from(e),!this.length&&e||e.length<sn&&this.leafAppend(e)||this.length<sn&&e.leafPrepend(this)||this.appendInner(e)):this},ln.prototype.prepend=function(e){return e.length?ln.from(e).append(this):this},ln.prototype.appendInner=function(e){return new hn(this,e)},ln.prototype.slice=function(e,t){return void 0===e&&(e=0),void 0===t&&(t=this.length),e>=t?ln.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},ln.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},ln.prototype.forEach=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},ln.prototype.map=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},ln.from=function(e){return e instanceof ln?e:e&&e.length?new an(e):ln.empty},an=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return 0==e&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var i=t;i<n;i++)if(!1===e(this.values[i],r+i))return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var i=t-1;i>=n;i--)if(!1===e(this.values[i],r+i))return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=sn)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=sn)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(ln),ln.empty=new an([]),hn=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,r){var i=this.left.length;return!(t<i&&!1===this.left.forEachInner(e,t,Math.min(n,i),r))&&!(n>i&&!1===this.right.forEachInner(e,Math.max(t-i,0),Math.min(this.length,n)-i,r+i))&&void 0},t.prototype.forEachInvertedInner=function(e,t,n,r){var i=this.left.length;return!(t>i&&!1===this.right.forEachInvertedInner(e,t-i,Math.max(n,i)-i,r+i))&&!(n<i&&!1===this.left.forEachInvertedInner(e,Math.min(t,i),n,r))&&void 0},t.prototype.sliceInner=function(e,t){if(0==e&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(ln),cn=class e{constructor(e,t){this.items=e,this.eventCount=t}popEvent(t,n){if(0==this.eventCount)return null;let r,i,o=this.items.length;for(;;o--)if(this.items.get(o-1).selection){--o;break}n&&(r=this.remapping(o,this.items.length),i=r.maps.length);let s,l,a=t.tr,h=[],c=[];return this.items.forEach((t,n)=>{if(!t.step)return r||(r=this.remapping(o,n+1),i=r.maps.length),i--,void c.push(t);if(r){c.push(new dn(t.map));let e,n=t.step.map(r.slice(i));n&&a.maybeStep(n).doc&&(e=a.mapping.maps[a.mapping.maps.length-1],h.push(new dn(e,void 0,void 0,h.length+c.length))),i--,e&&r.appendMap(e,i)}else a.maybeStep(t.step);return t.selection?(s=r?t.selection.map(r.slice(i)):t.selection,l=new e(this.items.slice(0,o).append(c.reverse().concat(h)),this.eventCount-1),!1):void 0},this.items.length,0),{remaining:l,transform:a,selection:s}}addTransform(t,n,r,i){let o=[],s=this.eventCount,l=this.items,a=!i&&l.length?l.get(l.length-1):null;for(let e=0;e<t.steps.length;e++){let r,h=t.steps[e].invert(t.docs[e]),c=new dn(t.mapping.maps[e],h,n);(r=a&&a.merge(c))&&(c=r,e?o.pop():l=l.slice(0,l.length-1)),o.push(c),n&&(s++,n=void 0),i||(a=c)}let h=s-r.depth;return h>fn&&(l=function(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&0==t--)return n=r,!1}),e.slice(n)}(l,h),s-=h),new e(l.append(o),s)}remapping(e,t){let n=new P;return this.items.forEach((t,r)=>{let i=null!=t.mirrorOffset&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,i)},e,t),n}addMaps(t){return 0==this.eventCount?this:new e(this.items.append(t.map(e=>new dn(e))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),o=t.mapping,s=t.steps.length,l=this.eventCount;this.items.forEach(e=>{e.selection&&l--},i);let a=n;this.items.forEach(e=>{let n=o.getMirror(--a);if(null==n)return;s=Math.min(s,n);let i=o.maps[n];if(e.step){let s=t.steps[n].invert(t.docs[n]),h=e.selection&&e.selection.map(o.slice(a+1,n));h&&l++,r.push(new dn(i,s,h))}else r.push(new dn(i))},i);let h=[];for(let e=n;e<s;e++)h.push(new dn(o.maps[e]));let c=new e(this.items.slice(0,i).append(h).append(r),l);return c.emptyItemCount()>500&&(c=c.compress(this.items.length-r.length)),c}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,i=[],o=0;return this.items.forEach((e,s)=>{if(s>=t)i.push(e),e.selection&&o++;else if(e.step){let t=e.step.map(n.slice(r)),s=t&&t.getMap();if(r--,s&&n.appendMap(s,r),t){let l=e.selection&&e.selection.map(n.slice(r));l&&o++;let a,h=new dn(s.invert(),t,l),c=i.length-1;(a=i.length&&i[c].merge(h))?i[c]=a:i.push(h)}}else e.map&&r--},this.items.length,0),new e(ln.from(i.reverse()),o)}},cn.empty=new cn(ln.empty,0),dn=class e{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}},pn=class{constructor(e,t,n,r,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}},fn=20,un=!1,mn=null,gn=new pe("history"),yn=new pe("closeHistory"),e("l",wn=Go(!1,!0)),e("c",vn=Go(!0,!0)),Go(!1,!1),Go(!0,!1),e("t",xn=class{constructor(e,t,n={}){var r;this.match=e,this.match=e,this.handler="string"==typeof t?(r=t,function(e,t,n,i){let o=r;if(t[1]){let e=t[0].lastIndexOf(t[1]);o+=t[0].slice(e+t[1].length);let r=(n+=e)-i;r>0&&(o=t[0].slice(e-r,e)+o,n=i)}return e.tr.insertText(o,n,i)}):t,this.undoable=!1!==n.undoable,this.inCode=n.inCode||!1,this.inCodeMark=!1!==n.inCodeMark}}),kn=500,e("r",new xn(/--$/,"—",{inCodeMark:!1})),e("n",new xn(/\.\.\.$/,"…",{inCodeMark:!1})),bn=new xn(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“",{inCodeMark:!1}),Sn=new xn(/"$/,"”",{inCodeMark:!1}),Cn=new xn(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘",{inCodeMark:!1}),Mn=new xn(/'$/,"’",{inCodeMark:!1}),e("a",[bn,Sn,Cn,Mn])}}}); |