@progress/kendo-editor-common 1.8.2-dev.202204011319 → 1.8.2-dev.202204011418
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.KendoEditorCommon=e():t.KendoEditorCommon=e()}(window,(function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=23)}([function(t,e,n){"use strict";function r(t){this.content=t}n.r(e),n.d(e,"ContentMatch",(function(){return _})),n.d(e,"DOMParser",(function(){return tt})),n.d(e,"DOMSerializer",(function(){return pt})),n.d(e,"Fragment",(function(){return i})),n.d(e,"Mark",(function(){return u})),n.d(e,"MarkType",(function(){return Y})),n.d(e,"Node",(function(){return A})),n.d(e,"NodeRange",(function(){return O})),n.d(e,"NodeType",(function(){return J})),n.d(e,"ReplaceError",(function(){return p})),n.d(e,"ResolvedPos",(function(){return S})),n.d(e,"Schema",(function(){return Q})),n.d(e,"Slice",(function(){return f})),r.prototype={constructor:r,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return-1==e?void 0:this.content[e+1]},update:function(t,e,n){var o=n&&n!=t?this.remove(n):this,i=o.find(t),s=o.content.slice();return-1==i?s.push(n||t,e):(s[i+1]=e,n&&(s[i]=n)),new r(s)},remove:function(t){var e=this.find(t);if(-1==e)return this;var n=this.content.slice();return n.splice(e,2),new r(n)},addToStart:function(t,e){return new r([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new r(n)},addBefore:function(t,e,n){var o=this.remove(e),i=o.content.slice(),s=o.find(t);return i.splice(-1==s?i.length:s,0,e,n),new r(i)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return(t=r.from(t)).size?new r(t.content.concat(this.subtract(t).content)):this},append:function(t){return(t=r.from(t)).size?new r(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=r.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},get size(){return this.content.length>>1}},r.from=function(t){if(t instanceof r)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new r(e)};var o=r;var i=function(t,e){if(this.content=t,this.size=e||0,null==e)for(var n=0;n<t.length;n++)this.size+=t[n].nodeSize},s={firstChild:{configurable:!0},lastChild:{configurable:!0},childCount:{configurable:!0}};i.prototype.nodesBetween=function(t,e,n,r,o){void 0===r&&(r=0);for(var i=0,s=0;s<e;i++){var a=this.content[i],c=s+a.nodeSize;if(c>t&&!1!==n(a,r+s,o,i)&&a.content.size){var l=s+1;a.nodesBetween(Math.max(0,t-l),Math.min(a.content.size,e-l),n,r+l)}s=c}},i.prototype.descendants=function(t){this.nodesBetween(0,this.size,t)},i.prototype.textBetween=function(t,e,n,r){var o="",i=!0;return this.nodesBetween(t,e,(function(s,a){s.isText?(o+=s.text.slice(Math.max(t,a)-a,e-a),i=!n):s.isLeaf&&r?(o+="function"==typeof r?r(s):r,i=!n):!i&&s.isBlock&&(o+=n,i=!0)}),0),o},i.prototype.append=function(t){if(!t.size)return this;if(!this.size)return t;var e=this.lastChild,n=t.firstChild,r=this.content.slice(),o=0;for(e.isText&&e.sameMarkup(n)&&(r[r.length-1]=e.withText(e.text+n.text),o=1);o<t.content.length;o++)r.push(t.content[o]);return new i(r,this.size+t.size)},i.prototype.cut=function(t,e){if(null==e&&(e=this.size),0==t&&e==this.size)return this;var n=[],r=0;if(e>t)for(var o=0,s=0;s<e;o++){var a=this.content[o],c=s+a.nodeSize;c>t&&((s<t||c>e)&&(a=a.isText?a.cut(Math.max(0,t-s),Math.min(a.text.length,e-s)):a.cut(Math.max(0,t-s-1),Math.min(a.content.size,e-s-1))),n.push(a),r+=a.nodeSize),s=c}return new i(n,r)},i.prototype.cutByIndex=function(t,e){return t==e?i.empty:0==t&&e==this.content.length?this:new i(this.content.slice(t,e))},i.prototype.replaceChild=function(t,e){var n=this.content[t];if(n==e)return this;var r=this.content.slice(),o=this.size+e.nodeSize-n.nodeSize;return r[t]=e,new i(r,o)},i.prototype.addToStart=function(t){return new i([t].concat(this.content),this.size+t.nodeSize)},i.prototype.addToEnd=function(t){return new i(this.content.concat(t),this.size+t.nodeSize)},i.prototype.eq=function(t){if(this.content.length!=t.content.length)return!1;for(var e=0;e<this.content.length;e++)if(!this.content[e].eq(t.content[e]))return!1;return!0},s.firstChild.get=function(){return this.content.length?this.content[0]:null},s.lastChild.get=function(){return this.content.length?this.content[this.content.length-1]:null},s.childCount.get=function(){return this.content.length},i.prototype.child=function(t){var e=this.content[t];if(!e)throw new RangeError("Index "+t+" out of range for "+this);return e},i.prototype.maybeChild=function(t){return this.content[t]},i.prototype.forEach=function(t){for(var e=0,n=0;e<this.content.length;e++){var r=this.content[e];t(r,n,e),n+=r.nodeSize}},i.prototype.findDiffStart=function(t,e){return void 0===e&&(e=0),function t(e,n,r){for(var o=0;;o++){if(o==e.childCount||o==n.childCount)return e.childCount==n.childCount?null:r;var i=e.child(o),s=n.child(o);if(i!=s){if(!i.sameMarkup(s))return r;if(i.isText&&i.text!=s.text){for(var a=0;i.text[a]==s.text[a];a++)r++;return r}if(i.content.size||s.content.size){var c=t(i.content,s.content,r+1);if(null!=c)return c}r+=i.nodeSize}else r+=i.nodeSize}}(this,t,e)},i.prototype.findDiffEnd=function(t,e,n){return void 0===e&&(e=this.size),void 0===n&&(n=t.size),function t(e,n,r,o){for(var i=e.childCount,s=n.childCount;;){if(0==i||0==s)return i==s?null:{a:r,b:o};var a=e.child(--i),c=n.child(--s),l=a.nodeSize;if(a!=c){if(!a.sameMarkup(c))return{a:r,b:o};if(a.isText&&a.text!=c.text){for(var u=0,p=Math.min(a.text.length,c.text.length);u<p&&a.text[a.text.length-u-1]==c.text[c.text.length-u-1];)u++,r--,o--;return{a:r,b:o}}if(a.content.size||c.content.size){var f=t(a.content,c.content,r-1,o-1);if(f)return f}r-=l,o-=l}else r-=l,o-=l}}(this,t,e,n)},i.prototype.findIndex=function(t,e){if(void 0===e&&(e=-1),0==t)return c(0,t);if(t==this.size)return c(this.content.length,t);if(t>this.size||t<0)throw new RangeError("Position "+t+" outside of fragment ("+this+")");for(var n=0,r=0;;n++){var o=r+this.child(n).nodeSize;if(o>=t)return o==t||e>0?c(n+1,o):c(n,r);r=o}},i.prototype.toString=function(){return"<"+this.toStringInner()+">"},i.prototype.toStringInner=function(){return this.content.join(", ")},i.prototype.toJSON=function(){return this.content.length?this.content.map((function(t){return t.toJSON()})):null},i.fromJSON=function(t,e){if(!e)return i.empty;if(!Array.isArray(e))throw new RangeError("Invalid input for Fragment.fromJSON");return new i(e.map(t.nodeFromJSON))},i.fromArray=function(t){if(!t.length)return i.empty;for(var e,n=0,r=0;r<t.length;r++){var o=t[r];n+=o.nodeSize,r&&o.isText&&t[r-1].sameMarkup(o)?(e||(e=t.slice(0,r)),e[e.length-1]=o.withText(e[e.length-1].text+o.text)):e&&e.push(o)}return new i(e||t,n)},i.from=function(t){if(!t)return i.empty;if(t instanceof i)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new i([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))},Object.defineProperties(i.prototype,s);var a={index:0,offset:0};function c(t,e){return a.index=t,a.offset=e,a}function l(t,e){if(t===e)return!0;if(!t||"object"!=typeof t||!e||"object"!=typeof e)return!1;var n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(var r=0;r<t.length;r++)if(!l(t[r],e[r]))return!1}else{for(var o in t)if(!(o in e)||!l(t[o],e[o]))return!1;for(var i in e)if(!(i in t))return!1}return!0}i.empty=new i([],0);var u=function(t,e){this.type=t,this.attrs=e};function p(t){var e=Error.call(this,t);return e.__proto__=p.prototype,e}u.prototype.addToSet=function(t){for(var e,n=!1,r=0;r<t.length;r++){var o=t[r];if(this.eq(o))return t;if(this.type.excludes(o.type))e||(e=t.slice(0,r));else{if(o.type.excludes(this.type))return t;!n&&o.type.rank>this.type.rank&&(e||(e=t.slice(0,r)),e.push(this),n=!0),e&&e.push(o)}}return e||(e=t.slice()),n||e.push(this),e},u.prototype.removeFromSet=function(t){for(var e=0;e<t.length;e++)if(this.eq(t[e]))return t.slice(0,e).concat(t.slice(e+1));return t},u.prototype.isInSet=function(t){for(var e=0;e<t.length;e++)if(this.eq(t[e]))return!0;return!1},u.prototype.eq=function(t){return this==t||this.type==t.type&&l(this.attrs,t.attrs)},u.prototype.toJSON=function(){var t={type:this.type.name};for(var e in this.attrs){t.attrs=this.attrs;break}return t},u.fromJSON=function(t,e){if(!e)throw new RangeError("Invalid input for Mark.fromJSON");var n=t.marks[e.type];if(!n)throw new RangeError("There is no mark type "+e.type+" in this schema");return n.create(e.attrs)},u.sameSet=function(t,e){if(t==e)return!0;if(t.length!=e.length)return!1;for(var n=0;n<t.length;n++)if(!t[n].eq(e[n]))return!1;return!0},u.setFrom=function(t){if(!t||0==t.length)return u.none;if(t instanceof u)return[t];var e=t.slice();return e.sort((function(t,e){return t.type.rank-e.type.rank})),e},u.none=[],p.prototype=Object.create(Error.prototype),p.prototype.constructor=p,p.prototype.name="ReplaceError";var f=function(t,e,n){this.content=t,this.openStart=e,this.openEnd=n},d={size:{configurable:!0}};function h(t,e,n){if(n.openStart>t.depth)throw new p("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new p("Inconsistent open depths");return function t(e,n,r,o){var s=e.index(o),a=e.node(o);if(s==n.index(o)&&o<e.depth-r.openStart){var c=t(e,n,r,o+1);return a.copy(a.content.replaceChild(s,c))}if(r.content.size){if(r.openStart||r.openEnd||e.depth!=o||n.depth!=o){var l=function(t,e){for(var n=e.depth-t.openStart,r=e.node(n).copy(t.content),o=n-1;o>=0;o--)r=e.node(o).copy(i.from(r));return{start:r.resolveNoCache(t.openStart+n),end:r.resolveNoCache(r.content.size-t.openEnd-n)}}(r,e),u=l.start,p=l.end;return w(a,function t(e,n,r,o,s){var a=e.depth>s&&v(e,n,s+1),c=o.depth>s&&v(r,o,s+1),l=[];y(null,e,s,l),a&&c&&n.index(s)==r.index(s)?(m(a,c),g(w(a,t(e,n,r,o,s+1)),l)):(a&&g(w(a,b(e,n,s+1)),l),y(n,r,s,l),c&&g(w(c,b(r,o,s+1)),l));return y(o,null,s,l),new i(l)}(e,u,p,n,o))}var f=e.parent,d=f.content;return w(f,d.cut(0,e.parentOffset).append(r.content).append(d.cut(n.parentOffset)))}return w(a,b(e,n,o))}(t,e,n,0)}function m(t,e){if(!e.type.compatibleContent(t.type))throw new p("Cannot join "+e.type.name+" onto "+t.type.name)}function v(t,e,n){var r=t.node(n);return m(r,e.node(n)),r}function g(t,e){var n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function y(t,e,n,r){var o=(e||t).node(n),i=0,s=e?e.index(n):o.childCount;t&&(i=t.index(n),t.depth>n?i++:t.textOffset&&(g(t.nodeAfter,r),i++));for(var a=i;a<s;a++)g(o.child(a),r);e&&e.depth==n&&e.textOffset&&g(e.nodeBefore,r)}function w(t,e){if(!t.type.validContent(e))throw new p("Invalid content for node "+t.type.name);return t.copy(e)}function b(t,e,n){var r=[];(y(null,t,n,r),t.depth>n)&&g(w(v(t,e,n+1),b(t,e,n+1)),r);return y(e,null,n,r),new i(r)}d.size.get=function(){return this.content.size-this.openStart-this.openEnd},f.prototype.insertAt=function(t,e){var n=function t(e,n,r,o){var i=e.findIndex(n),s=i.index,a=i.offset,c=e.maybeChild(s);if(a==n||c.isText)return o&&!o.canReplace(s,s,r)?null:e.cut(0,n).append(r).append(e.cut(n));var l=t(c.content,n-a-1,r);return l&&e.replaceChild(s,c.copy(l))}(this.content,t+this.openStart,e,null);return n&&new f(n,this.openStart,this.openEnd)},f.prototype.removeBetween=function(t,e){return new f(function t(e,n,r){var o=e.findIndex(n),i=o.index,s=o.offset,a=e.maybeChild(i),c=e.findIndex(r),l=c.index,u=c.offset;if(s==n||a.isText){if(u!=r&&!e.child(l).isText)throw new RangeError("Removing non-flat range");return e.cut(0,n).append(e.cut(r))}if(i!=l)throw new RangeError("Removing non-flat range");return e.replaceChild(i,a.copy(t(a.content,n-s-1,r-s-1)))}(this.content,t+this.openStart,e+this.openStart),this.openStart,this.openEnd)},f.prototype.eq=function(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd},f.prototype.toString=function(){return this.content+"("+this.openStart+","+this.openEnd+")"},f.prototype.toJSON=function(){if(!this.content.size)return null;var t={content:this.content.toJSON()};return this.openStart>0&&(t.openStart=this.openStart),this.openEnd>0&&(t.openEnd=this.openEnd),t},f.fromJSON=function(t,e){if(!e)return f.empty;var n=e.openStart||0,r=e.openEnd||0;if("number"!=typeof n||"number"!=typeof r)throw new RangeError("Invalid input for Slice.fromJSON");return new f(i.fromJSON(t,e.content),n,r)},f.maxOpen=function(t,e){void 0===e&&(e=!0);for(var n=0,r=0,o=t.firstChild;o&&!o.isLeaf&&(e||!o.type.spec.isolating);o=o.firstChild)n++;for(var i=t.lastChild;i&&!i.isLeaf&&(e||!i.type.spec.isolating);i=i.lastChild)r++;return new f(t,n,r)},Object.defineProperties(f.prototype,d),f.empty=new f(i.empty,0,0);var S=function(t,e,n){this.pos=t,this.path=e,this.depth=e.length/3-1,this.parentOffset=n},k={parent:{configurable:!0},doc:{configurable:!0},textOffset:{configurable:!0},nodeAfter:{configurable:!0},nodeBefore:{configurable:!0}};S.prototype.resolveDepth=function(t){return null==t?this.depth:t<0?this.depth+t:t},k.parent.get=function(){return this.node(this.depth)},k.doc.get=function(){return this.node(0)},S.prototype.node=function(t){return this.path[3*this.resolveDepth(t)]},S.prototype.index=function(t){return this.path[3*this.resolveDepth(t)+1]},S.prototype.indexAfter=function(t){return t=this.resolveDepth(t),this.index(t)+(t!=this.depth||this.textOffset?1:0)},S.prototype.start=function(t){return 0==(t=this.resolveDepth(t))?0:this.path[3*t-1]+1},S.prototype.end=function(t){return t=this.resolveDepth(t),this.start(t)+this.node(t).content.size},S.prototype.before=function(t){if(!(t=this.resolveDepth(t)))throw new RangeError("There is no position before the top-level node");return t==this.depth+1?this.pos:this.path[3*t-1]},S.prototype.after=function(t){if(!(t=this.resolveDepth(t)))throw new RangeError("There is no position after the top-level node");return t==this.depth+1?this.pos:this.path[3*t-1]+this.path[3*t].nodeSize},k.textOffset.get=function(){return this.pos-this.path[this.path.length-1]},k.nodeAfter.get=function(){var t=this.parent,e=this.index(this.depth);if(e==t.childCount)return null;var n=this.pos-this.path[this.path.length-1],r=t.child(e);return n?t.child(e).cut(n):r},k.nodeBefore.get=function(){var t=this.index(this.depth),e=this.pos-this.path[this.path.length-1];return e?this.parent.child(t).cut(0,e):0==t?null:this.parent.child(t-1)},S.prototype.posAtIndex=function(t,e){e=this.resolveDepth(e);for(var n=this.path[3*e],r=0==e?0:this.path[3*e-1]+1,o=0;o<t;o++)r+=n.child(o).nodeSize;return r},S.prototype.marks=function(){var t=this.parent,e=this.index();if(0==t.content.size)return u.none;if(this.textOffset)return t.child(e).marks;var n=t.maybeChild(e-1),r=t.maybeChild(e);if(!n){var o=n;n=r,r=o}for(var i=n.marks,s=0;s<i.length;s++)!1!==i[s].type.spec.inclusive||r&&i[s].isInSet(r.marks)||(i=i[s--].removeFromSet(i));return i},S.prototype.marksAcross=function(t){var e=this.parent.maybeChild(this.index());if(!e||!e.isInline)return null;for(var n=e.marks,r=t.parent.maybeChild(t.index()),o=0;o<n.length;o++)!1!==n[o].type.spec.inclusive||r&&n[o].isInSet(r.marks)||(n=n[o--].removeFromSet(n));return n},S.prototype.sharedDepth=function(t){for(var e=this.depth;e>0;e--)if(this.start(e)<=t&&this.end(e)>=t)return e;return 0},S.prototype.blockRange=function(t,e){if(void 0===t&&(t=this),t.pos<this.pos)return t.blockRange(this);for(var n=this.depth-(this.parent.inlineContent||this.pos==t.pos?1:0);n>=0;n--)if(t.pos<=this.end(n)&&(!e||e(this.node(n))))return new O(this,t,n)},S.prototype.sameParent=function(t){return this.pos-this.parentOffset==t.pos-t.parentOffset},S.prototype.max=function(t){return t.pos>this.pos?t:this},S.prototype.min=function(t){return t.pos<this.pos?t:this},S.prototype.toString=function(){for(var t="",e=1;e<=this.depth;e++)t+=(t?"/":"")+this.node(e).type.name+"_"+this.index(e-1);return t+":"+this.parentOffset},S.resolve=function(t,e){if(!(e>=0&&e<=t.content.size))throw new RangeError("Position "+e+" out of range");for(var n=[],r=0,o=e,i=t;;){var s=i.content.findIndex(o),a=s.index,c=s.offset,l=o-c;if(n.push(i,a,r+c),!l)break;if((i=i.child(a)).isText)break;o=l-1,r+=c+1}return new S(e,n,o)},S.resolveCached=function(t,e){for(var n=0;n<x.length;n++){var r=x[n];if(r.pos==e&&r.doc==t)return r}var o=x[C]=S.resolve(t,e);return C=(C+1)%M,o},Object.defineProperties(S.prototype,k);var x=[],C=0,M=12,O=function(t,e,n){this.$from=t,this.$to=e,this.depth=n},T={start:{configurable:!0},end:{configurable:!0},parent:{configurable:!0},startIndex:{configurable:!0},endIndex:{configurable:!0}};T.start.get=function(){return this.$from.before(this.depth+1)},T.end.get=function(){return this.$to.after(this.depth+1)},T.parent.get=function(){return this.$from.node(this.depth)},T.startIndex.get=function(){return this.$from.index(this.depth)},T.endIndex.get=function(){return this.$to.indexAfter(this.depth)},Object.defineProperties(O.prototype,T);var N=Object.create(null),A=function(t,e,n,r){this.type=t,this.attrs=e,this.content=n||i.empty,this.marks=r||u.none},D={nodeSize:{configurable:!0},childCount:{configurable:!0},textContent:{configurable:!0},firstChild:{configurable:!0},lastChild:{configurable:!0},isBlock:{configurable:!0},isTextblock:{configurable:!0},inlineContent:{configurable:!0},isInline:{configurable:!0},isText:{configurable:!0},isLeaf:{configurable:!0},isAtom:{configurable:!0}};D.nodeSize.get=function(){return this.isLeaf?1:2+this.content.size},D.childCount.get=function(){return this.content.childCount},A.prototype.child=function(t){return this.content.child(t)},A.prototype.maybeChild=function(t){return this.content.maybeChild(t)},A.prototype.forEach=function(t){this.content.forEach(t)},A.prototype.nodesBetween=function(t,e,n,r){void 0===r&&(r=0),this.content.nodesBetween(t,e,n,r,this)},A.prototype.descendants=function(t){this.nodesBetween(0,this.content.size,t)},D.textContent.get=function(){return this.textBetween(0,this.content.size,"")},A.prototype.textBetween=function(t,e,n,r){return this.content.textBetween(t,e,n,r)},D.firstChild.get=function(){return this.content.firstChild},D.lastChild.get=function(){return this.content.lastChild},A.prototype.eq=function(t){return this==t||this.sameMarkup(t)&&this.content.eq(t.content)},A.prototype.sameMarkup=function(t){return this.hasMarkup(t.type,t.attrs,t.marks)},A.prototype.hasMarkup=function(t,e,n){return this.type==t&&l(this.attrs,e||t.defaultAttrs||N)&&u.sameSet(this.marks,n||u.none)},A.prototype.copy=function(t){return void 0===t&&(t=null),t==this.content?this:new this.constructor(this.type,this.attrs,t,this.marks)},A.prototype.mark=function(t){return t==this.marks?this:new this.constructor(this.type,this.attrs,this.content,t)},A.prototype.cut=function(t,e){return 0==t&&e==this.content.size?this:this.copy(this.content.cut(t,e))},A.prototype.slice=function(t,e,n){if(void 0===e&&(e=this.content.size),void 0===n&&(n=!1),t==e)return f.empty;var r=this.resolve(t),o=this.resolve(e),i=n?0:r.sharedDepth(e),s=r.start(i),a=r.node(i).content.cut(r.pos-s,o.pos-s);return new f(a,r.depth-i,o.depth-i)},A.prototype.replace=function(t,e,n){return h(this.resolve(t),this.resolve(e),n)},A.prototype.nodeAt=function(t){for(var e=this;;){var n=e.content.findIndex(t),r=n.index,o=n.offset;if(!(e=e.maybeChild(r)))return null;if(o==t||e.isText)return e;t-=o+1}},A.prototype.childAfter=function(t){var e=this.content.findIndex(t),n=e.index,r=e.offset;return{node:this.content.maybeChild(n),index:n,offset:r}},A.prototype.childBefore=function(t){if(0==t)return{node:null,index:0,offset:0};var e=this.content.findIndex(t),n=e.index,r=e.offset;if(r<t)return{node:this.content.child(n),index:n,offset:r};var o=this.content.child(n-1);return{node:o,index:n-1,offset:r-o.nodeSize}},A.prototype.resolve=function(t){return S.resolveCached(this,t)},A.prototype.resolveNoCache=function(t){return S.resolve(this,t)},A.prototype.rangeHasMark=function(t,e,n){var r=!1;return e>t&&this.nodesBetween(t,e,(function(t){return n.isInSet(t.marks)&&(r=!0),!r})),r},D.isBlock.get=function(){return this.type.isBlock},D.isTextblock.get=function(){return this.type.isTextblock},D.inlineContent.get=function(){return this.type.inlineContent},D.isInline.get=function(){return this.type.isInline},D.isText.get=function(){return this.type.isText},D.isLeaf.get=function(){return this.type.isLeaf},D.isAtom.get=function(){return this.type.isAtom},A.prototype.toString=function(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);var t=this.type.name;return this.content.size&&(t+="("+this.content.toStringInner()+")"),R(this.marks,t)},A.prototype.contentMatchAt=function(t){var e=this.type.contentMatch.matchFragment(this.content,0,t);if(!e)throw new Error("Called contentMatchAt on a node with invalid content");return e},A.prototype.canReplace=function(t,e,n,r,o){void 0===n&&(n=i.empty),void 0===r&&(r=0),void 0===o&&(o=n.childCount);var s=this.contentMatchAt(t).matchFragment(n,r,o),a=s&&s.matchFragment(this.content,e);if(!a||!a.validEnd)return!1;for(var c=r;c<o;c++)if(!this.type.allowsMarks(n.child(c).marks))return!1;return!0},A.prototype.canReplaceWith=function(t,e,n,r){if(r&&!this.type.allowsMarks(r))return!1;var o=this.contentMatchAt(t).matchType(n),i=o&&o.matchFragment(this.content,e);return!!i&&i.validEnd},A.prototype.canAppend=function(t){return t.content.size?this.canReplace(this.childCount,this.childCount,t.content):this.type.compatibleContent(t.type)},A.prototype.check=function(){if(!this.type.validContent(this.content))throw new RangeError("Invalid content for node "+this.type.name+": "+this.content.toString().slice(0,50));for(var t=u.none,e=0;e<this.marks.length;e++)t=this.marks[e].addToSet(t);if(!u.sameSet(t,this.marks))throw new RangeError("Invalid collection of marks for node "+this.type.name+": "+this.marks.map((function(t){return t.type.name})));this.content.forEach((function(t){return t.check()}))},A.prototype.toJSON=function(){var t={type:this.type.name};for(var e in this.attrs){t.attrs=this.attrs;break}return this.content.size&&(t.content=this.content.toJSON()),this.marks.length&&(t.marks=this.marks.map((function(t){return t.toJSON()}))),t},A.fromJSON=function(t,e){if(!e)throw new RangeError("Invalid input for Node.fromJSON");var n=null;if(e.marks){if(!Array.isArray(e.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=e.marks.map(t.markFromJSON)}if("text"==e.type){if("string"!=typeof e.text)throw new RangeError("Invalid text node in JSON");return t.text(e.text,n)}var r=i.fromJSON(t,e.content);return t.nodeType(e.type).create(e.attrs,r,n)},Object.defineProperties(A.prototype,D);var E=function(t){function e(e,n,r,o){if(t.call(this,e,n,null,o),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={textContent:{configurable:!0},nodeSize:{configurable:!0}};return e.prototype.toString=function(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):R(this.marks,JSON.stringify(this.text))},n.textContent.get=function(){return this.text},e.prototype.textBetween=function(t,e){return this.text.slice(t,e)},n.nodeSize.get=function(){return this.text.length},e.prototype.mark=function(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)},e.prototype.withText=function(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)},e.prototype.cut=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=this.text.length),0==t&&e==this.text.length?this:this.withText(this.text.slice(t,e))},e.prototype.eq=function(t){return this.sameMarkup(t)&&this.text==t.text},e.prototype.toJSON=function(){var e=t.prototype.toJSON.call(this);return e.text=this.text,e},Object.defineProperties(e.prototype,n),e}(A);function R(t,e){for(var n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}var _=function(t){this.validEnd=t,this.next=[],this.wrapCache=[]},I={inlineContent:{configurable:!0},defaultType:{configurable:!0},edgeCount:{configurable:!0}};_.parse=function(t,e){var n=new z(t,e);if(null==n.next)return _.empty;var r=$(n);n.next&&n.err("Unexpected trailing text");var o=function(t){var e=Object.create(null);return function n(r){var o=[];r.forEach((function(e){t[e].forEach((function(e){var n=e.term,r=e.to;if(n){var i=o.indexOf(n),s=i>-1&&o[i+1];W(t,r).forEach((function(t){s||o.push(n,s=[]),-1==s.indexOf(t)&&s.push(t)}))}}))}));for(var i=e[r.join(",")]=new _(r.indexOf(t.length-1)>-1),s=0;s<o.length;s+=2){var a=o[s+1].sort(j);i.next.push(o[s],e[a.join(",")]||n(a))}return i}(W(t,0))}(function(t){var e=[[]];return o(function t(e,i){if("choice"==e.type)return e.exprs.reduce((function(e,n){return e.concat(t(n,i))}),[]);if("seq"==e.type)for(var s=0;;s++){var a=t(e.exprs[s],i);if(s==e.exprs.length-1)return a;o(a,i=n())}else{if("star"==e.type){var c=n();return r(i,c),o(t(e.expr,c),c),[r(c)]}if("plus"==e.type){var l=n();return o(t(e.expr,i),l),o(t(e.expr,l),l),[r(l)]}if("opt"==e.type)return[r(i)].concat(t(e.expr,i));if("range"==e.type){for(var u=i,p=0;p<e.min;p++){var f=n();o(t(e.expr,u),f),u=f}if(-1==e.max)o(t(e.expr,u),u);else for(var d=e.min;d<e.max;d++){var h=n();r(u,h),o(t(e.expr,u),h),u=h}return[r(u)]}if("name"==e.type)return[r(i,null,e.value)]}}(t,0),n()),e;function n(){return e.push([])-1}function r(t,n,r){var o={term:r,to:n};return e[t].push(o),o}function o(t,e){t.forEach((function(t){return t.to=e}))}}(r));return function(t,e){for(var n=0,r=[t];n<r.length;n++){for(var o=r[n],i=!o.validEnd,s=[],a=0;a<o.next.length;a+=2){var c=o.next[a],l=o.next[a+1];s.push(c.name),!i||c.isText||c.hasRequiredAttrs()||(i=!1),-1==r.indexOf(l)&&r.push(l)}i&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(o,n),o},_.prototype.matchType=function(t){for(var e=0;e<this.next.length;e+=2)if(this.next[e]==t)return this.next[e+1];return null},_.prototype.matchFragment=function(t,e,n){void 0===e&&(e=0),void 0===n&&(n=t.childCount);for(var r=this,o=e;r&&o<n;o++)r=r.matchType(t.child(o).type);return r},I.inlineContent.get=function(){var t=this.next[0];return!!t&&t.isInline},I.defaultType.get=function(){for(var t=0;t<this.next.length;t+=2){var e=this.next[t];if(!e.isText&&!e.hasRequiredAttrs())return e}},_.prototype.compatible=function(t){for(var e=0;e<this.next.length;e+=2)for(var n=0;n<t.next.length;n+=2)if(this.next[e]==t.next[n])return!0;return!1},_.prototype.fillBefore=function(t,e,n){void 0===e&&(e=!1),void 0===n&&(n=0);var r=[this];return function o(s,a){var c=s.matchFragment(t,n);if(c&&(!e||c.validEnd))return i.from(a.map((function(t){return t.createAndFill()})));for(var l=0;l<s.next.length;l+=2){var u=s.next[l],p=s.next[l+1];if(!u.isText&&!u.hasRequiredAttrs()&&-1==r.indexOf(p)){r.push(p);var f=o(p,a.concat(u));if(f)return f}}}(this,[])},_.prototype.findWrapping=function(t){for(var e=0;e<this.wrapCache.length;e+=2)if(this.wrapCache[e]==t)return this.wrapCache[e+1];var n=this.computeWrapping(t);return this.wrapCache.push(t,n),n},_.prototype.computeWrapping=function(t){for(var e=Object.create(null),n=[{match:this,type:null,via:null}];n.length;){var r=n.shift(),o=r.match;if(o.matchType(t)){for(var i=[],s=r;s.type;s=s.via)i.push(s.type);return i.reverse()}for(var a=0;a<o.next.length;a+=2){var c=o.next[a];c.isLeaf||c.hasRequiredAttrs()||c.name in e||r.type&&!o.next[a+1].validEnd||(n.push({match:c.contentMatch,type:c,via:r}),e[c.name]=!0)}}},I.edgeCount.get=function(){return this.next.length>>1},_.prototype.edge=function(t){var e=t<<1;if(e>=this.next.length)throw new RangeError("There's no "+t+"th edge in this content match");return{type:this.next[e],next:this.next[e+1]}},_.prototype.toString=function(){var t=[];return function e(n){t.push(n);for(var r=1;r<n.next.length;r+=2)-1==t.indexOf(n.next[r])&&e(n.next[r])}(this),t.map((function(e,n){for(var r=n+(e.validEnd?"*":" ")+" ",o=0;o<e.next.length;o+=2)r+=(o?", ":"")+e.next[o].name+"->"+t.indexOf(e.next[o+1]);return r})).join("\n")},Object.defineProperties(_.prototype,I),_.empty=new _(!0);var z=function(t,e){this.string=t,this.nodeTypes=e,this.inline=null,this.pos=0,this.tokens=t.split(/\s*(?=\b|\W|$)/),""==this.tokens[this.tokens.length-1]&&this.tokens.pop(),""==this.tokens[0]&&this.tokens.shift()},P={next:{configurable:!0}};function $(t){var e=[];do{e.push(F(t))}while(t.eat("|"));return 1==e.length?e[0]:{type:"choice",exprs:e}}function F(t){var e=[];do{e.push(B(t))}while(t.next&&")"!=t.next&&"|"!=t.next);return 1==e.length?e[0]:{type:"seq",exprs:e}}function B(t){for(var e=function(t){if(t.eat("(")){var e=$(t);return t.eat(")")||t.err("Missing closing paren"),e}if(!/\W/.test(t.next)){var n=function(t,e){var n=t.nodeTypes,r=n[e];if(r)return[r];var o=[];for(var i in n){var s=n[i];s.groups.indexOf(e)>-1&&o.push(s)}0==o.length&&t.err("No node type or group '"+e+"' found");return o}(t,t.next).map((function(e){return null==t.inline?t.inline=e.isInline:t.inline!=e.isInline&&t.err("Mixing inline and block content"),{type:"name",value:e}}));return t.pos++,1==n.length?n[0]:{type:"choice",exprs:n}}t.err("Unexpected token '"+t.next+"'")}(t);;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else{if(!t.eat("{"))break;e=V(t,e)}return e}function L(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");var e=Number(t.next);return t.pos++,e}function V(t,e){var n=L(t),r=n;return t.eat(",")&&(r="}"!=t.next?L(t):-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function j(t,e){return e-t}function W(t,e){var n=[];return function e(r){var o=t[r];if(1==o.length&&!o[0].term)return e(o[0].to);n.push(r);for(var i=0;i<o.length;i++){var s=o[i],a=s.term,c=s.to;a||-1!=n.indexOf(c)||e(c)}}(e),n.sort(j)}function K(t){var e=Object.create(null);for(var n in t){var r=t[n];if(!r.hasDefault)return null;e[n]=r.default}return e}function q(t,e){var n=Object.create(null);for(var r in t){var o=e&&e[r];if(void 0===o){var i=t[r];if(!i.hasDefault)throw new RangeError("No value supplied for attribute "+r);o=i.default}n[r]=o}return n}function H(t){var e=Object.create(null);if(t)for(var n in t)e[n]=new G(t[n]);return e}P.next.get=function(){return this.tokens[this.pos]},z.prototype.eat=function(t){return this.next==t&&(this.pos++||!0)},z.prototype.err=function(t){throw new SyntaxError(t+" (in content expression '"+this.string+"')")},Object.defineProperties(z.prototype,P);var J=function(t,e,n){this.name=t,this.schema=e,this.spec=n,this.groups=n.group?n.group.split(" "):[],this.attrs=H(n.attrs),this.defaultAttrs=K(this.attrs),this.contentMatch=null,this.markSet=null,this.inlineContent=null,this.isBlock=!(n.inline||"text"==t),this.isText="text"==t},U={isInline:{configurable:!0},isTextblock:{configurable:!0},isLeaf:{configurable:!0},isAtom:{configurable:!0},whitespace:{configurable:!0}};U.isInline.get=function(){return!this.isBlock},U.isTextblock.get=function(){return this.isBlock&&this.inlineContent},U.isLeaf.get=function(){return this.contentMatch==_.empty},U.isAtom.get=function(){return this.isLeaf||this.spec.atom},U.whitespace.get=function(){return this.spec.whitespace||(this.spec.code?"pre":"normal")},J.prototype.hasRequiredAttrs=function(){for(var t in this.attrs)if(this.attrs[t].isRequired)return!0;return!1},J.prototype.compatibleContent=function(t){return this==t||this.contentMatch.compatible(t.contentMatch)},J.prototype.computeAttrs=function(t){return!t&&this.defaultAttrs?this.defaultAttrs:q(this.attrs,t)},J.prototype.create=function(t,e,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new A(this,this.computeAttrs(t),i.from(e),u.setFrom(n))},J.prototype.createChecked=function(t,e,n){if(e=i.from(e),!this.validContent(e))throw new RangeError("Invalid content for node "+this.name);return new A(this,this.computeAttrs(t),e,u.setFrom(n))},J.prototype.createAndFill=function(t,e,n){if(t=this.computeAttrs(t),(e=i.from(e)).size){var r=this.contentMatch.fillBefore(e);if(!r)return null;e=r.append(e)}var o=this.contentMatch.matchFragment(e).fillBefore(i.empty,!0);return o?new A(this,t,e.append(o),u.setFrom(n)):null},J.prototype.validContent=function(t){var e=this.contentMatch.matchFragment(t);if(!e||!e.validEnd)return!1;for(var n=0;n<t.childCount;n++)if(!this.allowsMarks(t.child(n).marks))return!1;return!0},J.prototype.allowsMarkType=function(t){return null==this.markSet||this.markSet.indexOf(t)>-1},J.prototype.allowsMarks=function(t){if(null==this.markSet)return!0;for(var e=0;e<t.length;e++)if(!this.allowsMarkType(t[e].type))return!1;return!0},J.prototype.allowedMarks=function(t){if(null==this.markSet)return t;for(var e,n=0;n<t.length;n++)this.allowsMarkType(t[n].type)?e&&e.push(t[n]):e||(e=t.slice(0,n));return e?e.length?e:u.empty:t},J.compile=function(t,e){var n=Object.create(null);t.forEach((function(t,r){return n[t]=new J(t,e,r)}));var r=e.spec.topNode||"doc";if(!n[r])throw new RangeError("Schema is missing its top node type ('"+r+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(var o in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n},Object.defineProperties(J.prototype,U);var G=function(t){this.hasDefault=Object.prototype.hasOwnProperty.call(t,"default"),this.default=t.default},X={isRequired:{configurable:!0}};X.isRequired.get=function(){return!this.hasDefault},Object.defineProperties(G.prototype,X);var Y=function(t,e,n,r){this.name=t,this.schema=n,this.spec=r,this.attrs=H(r.attrs),this.rank=e,this.excluded=null;var o=K(this.attrs);this.instance=o&&new u(this,o)};Y.prototype.create=function(t){return!t&&this.instance?this.instance:new u(this,q(this.attrs,t))},Y.compile=function(t,e){var n=Object.create(null),r=0;return t.forEach((function(t,o){return n[t]=new Y(t,r++,e,o)})),n},Y.prototype.removeFromSet=function(t){for(var e=0;e<t.length;e++)t[e].type==this&&(t=t.slice(0,e).concat(t.slice(e+1)),e--);return t},Y.prototype.isInSet=function(t){for(var e=0;e<t.length;e++)if(t[e].type==this)return t[e]},Y.prototype.excludes=function(t){return this.excluded.indexOf(t)>-1};var Q=function(t){for(var e in this.spec={},t)this.spec[e]=t[e];this.spec.nodes=o.from(t.nodes),this.spec.marks=o.from(t.marks),this.nodes=J.compile(this.spec.nodes,this),this.marks=Y.compile(this.spec.marks,this);var n=Object.create(null);for(var r in this.nodes){if(r in this.marks)throw new RangeError(r+" can not be both a node and a mark");var i=this.nodes[r],s=i.spec.content||"",a=i.spec.marks;i.contentMatch=n[s]||(n[s]=_.parse(s,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.markSet="_"==a?null:a?Z(this,a.split(" ")):""!=a&&i.inlineContent?null:[]}for(var c in this.marks){var l=this.marks[c],u=l.spec.excludes;l.excluded=null==u?[l]:""==u?[]:Z(this,u.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached=Object.create(null),this.cached.wrappings=Object.create(null)};function Z(t,e){for(var n=[],r=0;r<e.length;r++){var o=e[r],i=t.marks[o],s=i;if(i)n.push(i);else for(var a in t.marks){var c=t.marks[a];("_"==o||c.spec.group&&c.spec.group.split(" ").indexOf(o)>-1)&&n.push(s=c)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}Q.prototype.node=function(t,e,n,r){if("string"==typeof t)t=this.nodeType(t);else{if(!(t instanceof J))throw new RangeError("Invalid node type: "+t);if(t.schema!=this)throw new RangeError("Node type from different schema used ("+t.name+")")}return t.createChecked(e,n,r)},Q.prototype.text=function(t,e){var n=this.nodes.text;return new E(n,n.defaultAttrs,t,u.setFrom(e))},Q.prototype.mark=function(t,e){return"string"==typeof t&&(t=this.marks[t]),t.create(e)},Q.prototype.nodeFromJSON=function(t){return A.fromJSON(this,t)},Q.prototype.markFromJSON=function(t){return u.fromJSON(this,t)},Q.prototype.nodeType=function(t){var e=this.nodes[t];if(!e)throw new RangeError("Unknown node type: "+t);return e};var tt=function(t,e){var n=this;this.schema=t,this.rules=e,this.tags=[],this.styles=[],e.forEach((function(t){t.tag?n.tags.push(t):t.style&&n.styles.push(t)})),this.normalizeLists=!this.tags.some((function(e){if(!/^(ul|ol)\b/.test(e.tag)||!e.node)return!1;var n=t.nodes[e.node];return n.contentMatch.matchType(n)}))};tt.prototype.parse=function(t,e){void 0===e&&(e={});var n=new st(this,e,!1);return n.addAll(t,null,e.from,e.to),n.finish()},tt.prototype.parseSlice=function(t,e){void 0===e&&(e={});var n=new st(this,e,!0);return n.addAll(t,null,e.from,e.to),f.maxOpen(n.finish())},tt.prototype.matchTag=function(t,e,n){for(var r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){var o=this.tags[r];if(ct(t,o.tag)&&(void 0===o.namespace||t.namespaceURI==o.namespace)&&(!o.context||e.matchesContext(o.context))){if(o.getAttrs){var i=o.getAttrs(t);if(!1===i)continue;o.attrs=i}return o}}},tt.prototype.matchStyle=function(t,e,n,r){for(var o=r?this.styles.indexOf(r)+1:0;o<this.styles.length;o++){var i=this.styles[o];if(!(0!=i.style.indexOf(t)||i.context&&!n.matchesContext(i.context)||i.style.length>t.length&&(61!=i.style.charCodeAt(t.length)||i.style.slice(t.length+1)!=e))){if(i.getAttrs){var s=i.getAttrs(e);if(!1===s)continue;i.attrs=s}return i}}},tt.schemaRules=function(t){var e=[];function n(t){for(var n=null==t.priority?50:t.priority,r=0;r<e.length;r++){var o=e[r];if((null==o.priority?50:o.priority)<n)break}e.splice(r,0,t)}var r=function(e){var r=t.marks[e].spec.parseDOM;r&&r.forEach((function(t){n(t=lt(t)),t.mark=e}))};for(var o in t.marks)r(o);var i;for(var s in t.nodes)i=void 0,(i=t.nodes[s].spec.parseDOM)&&i.forEach((function(t){n(t=lt(t)),t.node=s}));return e},tt.fromSchema=function(t){return t.cached.domParser||(t.cached.domParser=new tt(t,tt.schemaRules(t)))};var et={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},nt={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},rt={ol:!0,ul:!0};function ot(t,e,n){return null!=e?(e?1:0)|("full"===e?2:0):t&&"pre"==t.whitespace?3:-5&n}var it=function(t,e,n,r,o,i,s){this.type=t,this.attrs=e,this.solid=o,this.match=i||(4&s?null:t.contentMatch),this.options=s,this.content=[],this.marks=n,this.activeMarks=u.none,this.pendingMarks=r,this.stashMarks=[]};it.prototype.findWrapping=function(t){if(!this.match){if(!this.type)return[];var e=this.type.contentMatch.fillBefore(i.from(t));if(!e){var n,r=this.type.contentMatch;return(n=r.findWrapping(t.type))?(this.match=r,n):null}this.match=this.type.contentMatch.matchFragment(e)}return this.match.findWrapping(t.type)},it.prototype.finish=function(t){if(!(1&this.options)){var e,n=this.content[this.content.length-1];n&&n.isText&&(e=/[ \t\r\n\u000c]+$/.exec(n.text))&&(n.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)))}var r=i.from(this.content);return!t&&this.match&&(r=r.append(this.match.fillBefore(i.empty,!0))),this.type?this.type.create(this.attrs,r,this.marks):r},it.prototype.popFromStashMark=function(t){for(var e=this.stashMarks.length-1;e>=0;e--)if(t.eq(this.stashMarks[e]))return this.stashMarks.splice(e,1)[0]},it.prototype.applyPending=function(t){for(var e=0,n=this.pendingMarks;e<n.length;e++){var r=n[e];(this.type?this.type.allowsMarkType(r.type):ut(r.type,t))&&!r.isInSet(this.activeMarks)&&(this.activeMarks=r.addToSet(this.activeMarks),this.pendingMarks=r.removeFromSet(this.pendingMarks))}},it.prototype.inlineContext=function(t){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:t.parentNode&&!et.hasOwnProperty(t.parentNode.nodeName.toLowerCase())};var st=function(t,e,n){this.parser=t,this.options=e,this.isOpen=n;var r,o=e.topNode,i=ot(null,e.preserveWhitespace,0)|(n?4:0);r=o?new it(o.type,o.attrs,u.none,u.none,!0,e.topMatch||o.type.contentMatch,i):new it(n?null:t.schema.topNodeType,null,u.none,u.none,!0,null,i),this.nodes=[r],this.open=0,this.find=e.findPositions,this.needsBlock=!1},at={top:{configurable:!0},currentPos:{configurable:!0}};function ct(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function lt(t){var e={};for(var n in t)e[n]=t[n];return e}function ut(t,e){var n=e.schema.nodes,r=function(r){var o=n[r];if(o.allowsMarkType(t)){var i=[],s=function(t){i.push(t);for(var n=0;n<t.edgeCount;n++){var r=t.edge(n),o=r.type,a=r.next;if(o==e)return!0;if(i.indexOf(a)<0&&s(a))return!0}};return s(o.contentMatch)?{v:!0}:void 0}};for(var o in n){var i=r(o);if(i)return i.v}}at.top.get=function(){return this.nodes[this.open]},st.prototype.addDOM=function(t){if(3==t.nodeType)this.addTextNode(t);else if(1==t.nodeType){var e=t.getAttribute("style"),n=e?this.readStyles(function(t){var e,n=/\s*([\w-]+)\s*:\s*([^;]+)/g,r=[];for(;e=n.exec(t);)r.push(e[1],e[2].trim());return r}(e)):null,r=this.top;if(null!=n)for(var o=0;o<n.length;o++)this.addPendingMark(n[o]);if(this.addElement(t),null!=n)for(var i=0;i<n.length;i++)this.removePendingMark(n[i],r)}},st.prototype.addTextNode=function(t){var e=t.nodeValue,n=this.top;if(2&n.options||n.inlineContext(t)||/[^ \t\r\n\u000c]/.test(e)){if(1&n.options)e=2&n.options?e.replace(/\r\n?/g,"\n"):e.replace(/\r?\n|\r/g," ");else if(e=e.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(e)&&this.open==this.nodes.length-1){var r=n.content[n.content.length-1],o=t.previousSibling;(!r||o&&"BR"==o.nodeName||r.isText&&/[ \t\r\n\u000c]$/.test(r.text))&&(e=e.slice(1))}e&&this.insertNode(this.parser.schema.text(e)),this.findInText(t)}else this.findInside(t)},st.prototype.addElement=function(t,e){var n,r=t.nodeName.toLowerCase();rt.hasOwnProperty(r)&&this.parser.normalizeLists&&function(t){for(var e=t.firstChild,n=null;e;e=e.nextSibling){var r=1==e.nodeType?e.nodeName.toLowerCase():null;r&&rt.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):"li"==r?n=e:r&&(n=null)}}(t);var o=this.options.ruleFromNode&&this.options.ruleFromNode(t)||(n=this.parser.matchTag(t,this,e));if(o?o.ignore:nt.hasOwnProperty(r))this.findInside(t),this.ignoreFallback(t);else if(!o||o.skip||o.closeParent){o&&o.closeParent?this.open=Math.max(0,this.open-1):o&&o.skip.nodeType&&(t=o.skip);var i,s=this.top,a=this.needsBlock;if(et.hasOwnProperty(r))i=!0,s.type||(this.needsBlock=!0);else if(!t.firstChild)return void this.leafFallback(t);this.addAll(t),i&&this.sync(s),this.needsBlock=a}else this.addElementByRule(t,o,!1===o.consuming?n:null)},st.prototype.leafFallback=function(t){"BR"==t.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(t.ownerDocument.createTextNode("\n"))},st.prototype.ignoreFallback=function(t){"BR"!=t.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"))},st.prototype.readStyles=function(t){var e=u.none;t:for(var n=0;n<t.length;n+=2)for(var r=null;;){var o=this.parser.matchStyle(t[n],t[n+1],this,r);if(!o)continue t;if(o.ignore)return null;if(e=this.parser.schema.marks[o.mark].create(o.attrs).addToSet(e),!1!==o.consuming)break;r=o}return e},st.prototype.addElementByRule=function(t,e,n){var r,o,i,s=this;e.node?(o=this.parser.schema.nodes[e.node]).isLeaf?this.insertNode(o.create(e.attrs))||this.leafFallback(t):r=this.enter(o,e.attrs,e.preserveWhitespace):(i=this.parser.schema.marks[e.mark].create(e.attrs),this.addPendingMark(i));var a=this.top;if(o&&o.isLeaf)this.findInside(t);else if(n)this.addElement(t,n);else if(e.getContent)this.findInside(t),e.getContent(t,this.parser.schema).forEach((function(t){return s.insertNode(t)}));else{var c=e.contentElement;"string"==typeof c?c=t.querySelector(c):"function"==typeof c&&(c=c(t)),c||(c=t),this.findAround(t,c,!0),this.addAll(c,r)}r&&(this.sync(a),this.open--),i&&this.removePendingMark(i,a)},st.prototype.addAll=function(t,e,n,r){for(var o=n||0,i=n?t.childNodes[n]:t.firstChild,s=null==r?null:t.childNodes[r];i!=s;i=i.nextSibling,++o)this.findAtPoint(t,o),this.addDOM(i),e&&et.hasOwnProperty(i.nodeName.toLowerCase())&&this.sync(e);this.findAtPoint(t,o)},st.prototype.findPlace=function(t){for(var e,n,r=this.open;r>=0;r--){var o=this.nodes[r],i=o.findWrapping(t);if(i&&(!e||e.length>i.length)&&(e=i,n=o,!i.length))break;if(o.solid)break}if(!e)return!1;this.sync(n);for(var s=0;s<e.length;s++)this.enterInner(e[s],null,!1);return!0},st.prototype.insertNode=function(t){if(t.isInline&&this.needsBlock&&!this.top.type){var e=this.textblockFromContext();e&&this.enterInner(e)}if(this.findPlace(t)){this.closeExtra();var n=this.top;n.applyPending(t.type),n.match&&(n.match=n.match.matchType(t.type));for(var r=n.activeMarks,o=0;o<t.marks.length;o++)n.type&&!n.type.allowsMarkType(t.marks[o].type)||(r=t.marks[o].addToSet(r));return n.content.push(t.mark(r)),!0}return!1},st.prototype.enter=function(t,e,n){var r=this.findPlace(t.create(e));return r&&this.enterInner(t,e,!0,n),r},st.prototype.enterInner=function(t,e,n,r){this.closeExtra();var o=this.top;o.applyPending(t),o.match=o.match&&o.match.matchType(t,e);var i=ot(t,r,o.options);4&o.options&&0==o.content.length&&(i|=4),this.nodes.push(new it(t,e,o.activeMarks,o.pendingMarks,n,null,i)),this.open++},st.prototype.closeExtra=function(t){var e=this.nodes.length-1;if(e>this.open){for(;e>this.open;e--)this.nodes[e-1].content.push(this.nodes[e].finish(t));this.nodes.length=this.open+1}},st.prototype.finish=function(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)},st.prototype.sync=function(t){for(var e=this.open;e>=0;e--)if(this.nodes[e]==t)return void(this.open=e)},at.currentPos.get=function(){this.closeExtra();for(var t=0,e=this.open;e>=0;e--){for(var n=this.nodes[e].content,r=n.length-1;r>=0;r--)t+=n[r].nodeSize;e&&t++}return t},st.prototype.findAtPoint=function(t,e){if(this.find)for(var n=0;n<this.find.length;n++)this.find[n].node==t&&this.find[n].offset==e&&(this.find[n].pos=this.currentPos)},st.prototype.findInside=function(t){if(this.find)for(var e=0;e<this.find.length;e++)null==this.find[e].pos&&1==t.nodeType&&t.contains(this.find[e].node)&&(this.find[e].pos=this.currentPos)},st.prototype.findAround=function(t,e,n){if(t!=e&&this.find)for(var r=0;r<this.find.length;r++){if(null==this.find[r].pos&&1==t.nodeType&&t.contains(this.find[r].node))e.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}},st.prototype.findInText=function(t){if(this.find)for(var e=0;e<this.find.length;e++)this.find[e].node==t&&(this.find[e].pos=this.currentPos-(t.nodeValue.length-this.find[e].offset))},st.prototype.matchesContext=function(t){var e=this;if(t.indexOf("|")>-1)return t.split(/\s*\|\s*/).some(this.matchesContext,this);var n=t.split("/"),r=this.options.context,o=!(this.isOpen||r&&r.parent.type!=this.nodes[0].type),i=-(r?r.depth+1:0)+(o?0:1),s=function(t,a){for(;t>=0;t--){var c=n[t];if(""==c){if(t==n.length-1||0==t)continue;for(;a>=i;a--)if(s(t-1,a))return!0;return!1}var l=a>0||0==a&&o?e.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!l||l.name!=c&&-1==l.groups.indexOf(c))return!1;a--}return!0};return s(n.length-1,this.open)},st.prototype.textblockFromContext=function(){var t=this.options.context;if(t)for(var e=t.depth;e>=0;e--){var n=t.node(e).contentMatchAt(t.indexAfter(e)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(var r in this.parser.schema.nodes){var o=this.parser.schema.nodes[r];if(o.isTextblock&&o.defaultAttrs)return o}},st.prototype.addPendingMark=function(t){var e=function(t,e){for(var n=0;n<e.length;n++)if(t.eq(e[n]))return e[n]}(t,this.top.pendingMarks);e&&this.top.stashMarks.push(e),this.top.pendingMarks=t.addToSet(this.top.pendingMarks)},st.prototype.removePendingMark=function(t,e){for(var n=this.open;n>=0;n--){var r=this.nodes[n];if(r.pendingMarks.lastIndexOf(t)>-1)r.pendingMarks=t.removeFromSet(r.pendingMarks);else{r.activeMarks=t.removeFromSet(r.activeMarks);var o=r.popFromStashMark(t);o&&r.type&&r.type.allowsMarkType(o.type)&&(r.activeMarks=o.addToSet(r.activeMarks))}if(r==e)break}},Object.defineProperties(st.prototype,at);var pt=function(t,e){this.nodes=t||{},this.marks=e||{}};function ft(t){var e={};for(var n in t){var r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function dt(t){return t.document||window.document}pt.prototype.serializeFragment=function(t,e,n){var r=this;void 0===e&&(e={}),n||(n=dt(e).createDocumentFragment());var o=n,i=null;return t.forEach((function(t){if(i||t.marks.length){i||(i=[]);for(var n=0,s=0;n<i.length&&s<t.marks.length;){var a=t.marks[s];if(r.marks[a.type.name]){if(!a.eq(i[n])||!1===a.type.spec.spanning)break;n+=2,s++}else s++}for(;n<i.length;)o=i.pop(),i.pop();for(;s<t.marks.length;){var c=t.marks[s++],l=r.serializeMark(c,t.isInline,e);l&&(i.push(c,o),o.appendChild(l.dom),o=l.contentDOM||l.dom)}}o.appendChild(r.serializeNodeInner(t,e))})),n},pt.prototype.serializeNodeInner=function(t,e){void 0===e&&(e={});var n=pt.renderSpec(dt(e),this.nodes[t.type.name](t)),r=n.dom,o=n.contentDOM;if(o){if(t.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");e.onContent?e.onContent(t,o,e):this.serializeFragment(t.content,e,o)}return r},pt.prototype.serializeNode=function(t,e){void 0===e&&(e={});for(var n=this.serializeNodeInner(t,e),r=t.marks.length-1;r>=0;r--){var o=this.serializeMark(t.marks[r],t.isInline,e);o&&((o.contentDOM||o.dom).appendChild(n),n=o.dom)}return n},pt.prototype.serializeMark=function(t,e,n){void 0===n&&(n={});var r=this.marks[t.type.name];return r&&pt.renderSpec(dt(n),r(t,e))},pt.renderSpec=function(t,e,n){if(void 0===n&&(n=null),"string"==typeof e)return{dom:t.createTextNode(e)};if(null!=e.nodeType)return{dom:e};if(e.dom&&null!=e.dom.nodeType)return e;var r=e[0],o=r.indexOf(" ");o>0&&(n=r.slice(0,o),r=r.slice(o+1));var i=null,s=n?t.createElementNS(n,r):t.createElement(r),a=e[1],c=1;if(a&&"object"==typeof a&&null==a.nodeType&&!Array.isArray(a))for(var l in c=2,a)if(null!=a[l]){var u=l.indexOf(" ");u>0?s.setAttributeNS(l.slice(0,u),l.slice(u+1),a[l]):s.setAttribute(l,a[l])}for(var p=c;p<e.length;p++){var f=e[p];if(0===f){if(p<e.length-1||p>c)throw new RangeError("Content hole must be the only child of its parent node");return{dom:s,contentDOM:s}}var d=pt.renderSpec(t,f,n),h=d.dom,m=d.contentDOM;if(s.appendChild(h),m){if(i)throw new RangeError("Multiple content holes");i=m}}return{dom:s,contentDOM:i}},pt.fromSchema=function(t){return t.cached.domSerializer||(t.cached.domSerializer=new pt(this.nodesFromSchema(t),this.marksFromSchema(t)))},pt.nodesFromSchema=function(t){var e=ft(t.nodes);return e.text||(e.text=function(t){return t.text}),e},pt.marksFromSchema=function(t){return ft(t.marks)}},function(t,e,n){"use strict";n.r(e),n.d(e,"AllSelection",(function(){return d})),n.d(e,"EditorState",(function(){return k})),n.d(e,"NodeSelection",(function(){return p})),n.d(e,"Plugin",(function(){return M})),n.d(e,"PluginKey",(function(){return N})),n.d(e,"Selection",(function(){return s})),n.d(e,"SelectionRange",(function(){return c})),n.d(e,"TextSelection",(function(){return l})),n.d(e,"Transaction",(function(){return g}));var r=n(0),o=n(2),i=Object.create(null),s=function(t,e,n){this.ranges=n||[new c(t.min(e),t.max(e))],this.$anchor=t,this.$head=e},a={anchor:{configurable:!0},head:{configurable:!0},from:{configurable:!0},to:{configurable:!0},$from:{configurable:!0},$to:{configurable:!0},empty:{configurable:!0}};a.anchor.get=function(){return this.$anchor.pos},a.head.get=function(){return this.$head.pos},a.from.get=function(){return this.$from.pos},a.to.get=function(){return this.$to.pos},a.$from.get=function(){return this.ranges[0].$from},a.$to.get=function(){return this.ranges[0].$to},a.empty.get=function(){for(var t=this.ranges,e=0;e<t.length;e++)if(t[e].$from.pos!=t[e].$to.pos)return!1;return!0},s.prototype.content=function(){return this.$from.node(0).slice(this.from,this.to,!0)},s.prototype.replace=function(t,e){void 0===e&&(e=r.Slice.empty);for(var n=e.content.lastChild,o=null,i=0;i<e.openEnd;i++)o=n,n=n.lastChild;for(var s=t.steps.length,a=this.ranges,c=0;c<a.length;c++){var l=a[c],u=l.$from,p=l.$to,f=t.mapping.slice(s);t.replaceRange(f.map(u.pos),f.map(p.pos),c?r.Slice.empty:e),0==c&&v(t,s,(n?n.isInline:o&&o.isTextblock)?-1:1)}},s.prototype.replaceWith=function(t,e){for(var n=t.steps.length,r=this.ranges,o=0;o<r.length;o++){var i=r[o],s=i.$from,a=i.$to,c=t.mapping.slice(n),l=c.map(s.pos),u=c.map(a.pos);o?t.deleteRange(l,u):(t.replaceRangeWith(l,u,e),v(t,n,e.isInline?-1:1))}},s.findFrom=function(t,e,n){var r=t.parent.inlineContent?new l(t):m(t.node(0),t.parent,t.pos,t.index(),e,n);if(r)return r;for(var o=t.depth-1;o>=0;o--){var i=e<0?m(t.node(0),t.node(o),t.before(o+1),t.index(o),e,n):m(t.node(0),t.node(o),t.after(o+1),t.index(o)+1,e,n);if(i)return i}},s.near=function(t,e){return void 0===e&&(e=1),this.findFrom(t,e)||this.findFrom(t,-e)||new d(t.node(0))},s.atStart=function(t){return m(t,t,0,0,1)||new d(t)},s.atEnd=function(t){return m(t,t,t.content.size,t.childCount,-1)||new d(t)},s.fromJSON=function(t,e){if(!e||!e.type)throw new RangeError("Invalid input for Selection.fromJSON");var n=i[e.type];if(!n)throw new RangeError("No selection type "+e.type+" defined");return n.fromJSON(t,e)},s.jsonID=function(t,e){if(t in i)throw new RangeError("Duplicate use of selection JSON ID "+t);return i[t]=e,e.prototype.jsonID=t,e},s.prototype.getBookmark=function(){return l.between(this.$anchor,this.$head).getBookmark()},Object.defineProperties(s.prototype,a),s.prototype.visible=!0;var c=function(t,e){this.$from=t,this.$to=e},l=function(t){function e(e,n){void 0===n&&(n=e),t.call(this,e,n)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={$cursor:{configurable:!0}};return n.$cursor.get=function(){return this.$anchor.pos==this.$head.pos?this.$head:null},e.prototype.map=function(n,r){var o=n.resolve(r.map(this.head));if(!o.parent.inlineContent)return t.near(o);var i=n.resolve(r.map(this.anchor));return new e(i.parent.inlineContent?i:o,o)},e.prototype.replace=function(e,n){if(void 0===n&&(n=r.Slice.empty),t.prototype.replace.call(this,e,n),n==r.Slice.empty){var o=this.$from.marksAcross(this.$to);o&&e.ensureMarks(o)}},e.prototype.eq=function(t){return t instanceof e&&t.anchor==this.anchor&&t.head==this.head},e.prototype.getBookmark=function(){return new u(this.anchor,this.head)},e.prototype.toJSON=function(){return{type:"text",anchor:this.anchor,head:this.head}},e.fromJSON=function(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))},e.create=function(t,e,n){void 0===n&&(n=e);var r=t.resolve(e);return new this(r,n==e?r:t.resolve(n))},e.between=function(n,r,o){var i=n.pos-r.pos;if(o&&!i||(o=i>=0?1:-1),!r.parent.inlineContent){var s=t.findFrom(r,o,!0)||t.findFrom(r,-o,!0);if(!s)return t.near(r,o);r=s.$head}return n.parent.inlineContent||(0==i||(n=(t.findFrom(n,-o,!0)||t.findFrom(n,o,!0)).$anchor).pos<r.pos!=i<0)&&(n=r),new e(n,r)},Object.defineProperties(e.prototype,n),e}(s);s.jsonID("text",l);var u=function(t,e){this.anchor=t,this.head=e};u.prototype.map=function(t){return new u(t.map(this.anchor),t.map(this.head))},u.prototype.resolve=function(t){return l.between(t.resolve(this.anchor),t.resolve(this.head))};var p=function(t){function e(e){var n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);t.call(this,e,r),this.node=n}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.map=function(n,r){var o=r.mapResult(this.anchor),i=o.deleted,s=o.pos,a=n.resolve(s);return i?t.near(a):new e(a)},e.prototype.content=function(){return new r.Slice(r.Fragment.from(this.node),0,0)},e.prototype.eq=function(t){return t instanceof e&&t.anchor==this.anchor},e.prototype.toJSON=function(){return{type:"node",anchor:this.anchor}},e.prototype.getBookmark=function(){return new f(this.anchor)},e.fromJSON=function(t,n){if("number"!=typeof n.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new e(t.resolve(n.anchor))},e.create=function(t,e){return new this(t.resolve(e))},e.isSelectable=function(t){return!t.isText&&!1!==t.type.spec.selectable},e}(s);p.prototype.visible=!1,s.jsonID("node",p);var f=function(t){this.anchor=t};f.prototype.map=function(t){var e=t.mapResult(this.anchor),n=e.deleted,r=e.pos;return n?new u(r,r):new f(r)},f.prototype.resolve=function(t){var e=t.resolve(this.anchor),n=e.nodeAfter;return n&&p.isSelectable(n)?new p(e):s.near(e)};var d=function(t){function e(e){t.call(this,e.resolve(0),e.resolve(e.content.size))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.replace=function(e,n){if(void 0===n&&(n=r.Slice.empty),n==r.Slice.empty){e.delete(0,e.doc.content.size);var o=t.atStart(e.doc);o.eq(e.selection)||e.setSelection(o)}else t.prototype.replace.call(this,e,n)},e.prototype.toJSON=function(){return{type:"all"}},e.fromJSON=function(t){return new e(t)},e.prototype.map=function(t){return new e(t)},e.prototype.eq=function(t){return t instanceof e},e.prototype.getBookmark=function(){return h},e}(s);s.jsonID("all",d);var h={map:function(){return this},resolve:function(t){return new d(t)}};function m(t,e,n,r,o,i){if(e.inlineContent)return l.create(t,n);for(var s=r-(o>0?0:1);o>0?s<e.childCount:s>=0;s+=o){var a=e.child(s);if(a.isAtom){if(!i&&p.isSelectable(a))return p.create(t,n-(o<0?a.nodeSize:0))}else{var c=m(t,a,n+o,o<0?a.childCount:0,o,i);if(c)return c}n+=a.nodeSize*o}}function v(t,e,n){var r=t.steps.length-1;if(!(r<e)){var i,a=t.steps[r];if(a instanceof o.ReplaceStep||a instanceof o.ReplaceAroundStep)t.mapping.maps[r].forEach((function(t,e,n,r){null==i&&(i=r)})),t.setSelection(s.near(t.doc.resolve(i),n))}}var g=function(t){function e(e){t.call(this,e.doc),this.time=Date.now(),this.curSelection=e.selection,this.curSelectionFor=0,this.storedMarks=e.storedMarks,this.updated=0,this.meta=Object.create(null)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={selection:{configurable:!0},selectionSet:{configurable:!0},storedMarksSet:{configurable:!0},isGeneric:{configurable:!0},scrolledIntoView:{configurable:!0}};return n.selection.get=function(){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},e.prototype.setSelection=function(t){if(t.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=t,this.curSelectionFor=this.steps.length,this.updated=-3&(1|this.updated),this.storedMarks=null,this},n.selectionSet.get=function(){return(1&this.updated)>0},e.prototype.setStoredMarks=function(t){return this.storedMarks=t,this.updated|=2,this},e.prototype.ensureMarks=function(t){return r.Mark.sameSet(this.storedMarks||this.selection.$from.marks(),t)||this.setStoredMarks(t),this},e.prototype.addStoredMark=function(t){return this.ensureMarks(t.addToSet(this.storedMarks||this.selection.$head.marks()))},e.prototype.removeStoredMark=function(t){return this.ensureMarks(t.removeFromSet(this.storedMarks||this.selection.$head.marks()))},n.storedMarksSet.get=function(){return(2&this.updated)>0},e.prototype.addStep=function(e,n){t.prototype.addStep.call(this,e,n),this.updated=-3&this.updated,this.storedMarks=null},e.prototype.setTime=function(t){return this.time=t,this},e.prototype.replaceSelection=function(t){return this.selection.replace(this,t),this},e.prototype.replaceSelectionWith=function(t,e){var n=this.selection;return!1!==e&&(t=t.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||r.Mark.none))),n.replaceWith(this,t),this},e.prototype.deleteSelection=function(){return this.selection.replace(this),this},e.prototype.insertText=function(t,e,n){void 0===n&&(n=e);var r=this.doc.type.schema;if(null==e)return t?this.replaceSelectionWith(r.text(t),!0):this.deleteSelection();if(!t)return this.deleteRange(e,n);var o=this.storedMarks;if(!o){var i=this.doc.resolve(e);o=n==e?i.marks():i.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(e,n,r.text(t,o)),this.selection.empty||this.setSelection(s.near(this.selection.$to)),this},e.prototype.setMeta=function(t,e){return this.meta["string"==typeof t?t:t.key]=e,this},e.prototype.getMeta=function(t){return this.meta["string"==typeof t?t:t.key]},n.isGeneric.get=function(){for(var t in this.meta)return!1;return!0},e.prototype.scrollIntoView=function(){return this.updated|=4,this},n.scrolledIntoView.get=function(){return(4&this.updated)>0},Object.defineProperties(e.prototype,n),e}(o.Transform);function y(t,e){return e&&t?t.bind(e):t}var w=function(t,e,n){this.name=t,this.init=y(e.init,n),this.apply=y(e.apply,n)},b=[new w("doc",{init:function(t){return t.doc||t.schema.topNodeType.createAndFill()},apply:function(t){return t.doc}}),new w("selection",{init:function(t,e){return t.selection||s.atStart(e.doc)},apply:function(t){return t.selection}}),new w("storedMarks",{init:function(t){return t.storedMarks||null},apply:function(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new w("scrollToSelection",{init:function(){return 0},apply:function(t,e){return t.scrolledIntoView?e+1:e}})],S=function(t,e){var n=this;this.schema=t,this.fields=b.concat(),this.plugins=[],this.pluginsByKey=Object.create(null),e&&e.forEach((function(t){if(n.pluginsByKey[t.key])throw new RangeError("Adding different instances of a keyed plugin ("+t.key+")");n.plugins.push(t),n.pluginsByKey[t.key]=t,t.spec.state&&n.fields.push(new w(t.key,t.spec.state,t))}))},k=function(t){this.config=t},x={schema:{configurable:!0},plugins:{configurable:!0},tr:{configurable:!0}};x.schema.get=function(){return this.config.schema},x.plugins.get=function(){return this.config.plugins},k.prototype.apply=function(t){return this.applyTransaction(t).state},k.prototype.filterTransaction=function(t,e){void 0===e&&(e=-1);for(var n=0;n<this.config.plugins.length;n++)if(n!=e){var r=this.config.plugins[n];if(r.spec.filterTransaction&&!r.spec.filterTransaction.call(r,t,this))return!1}return!0},k.prototype.applyTransaction=function(t){if(!this.filterTransaction(t))return{state:this,transactions:[]};for(var e=[t],n=this.applyInner(t),r=null;;){for(var o=!1,i=0;i<this.config.plugins.length;i++){var s=this.config.plugins[i];if(s.spec.appendTransaction){var a=r?r[i].n:0,c=r?r[i].state:this,l=a<e.length&&s.spec.appendTransaction.call(s,a?e.slice(a):e,c,n);if(l&&n.filterTransaction(l,i)){if(l.setMeta("appendedTransaction",t),!r){r=[];for(var u=0;u<this.config.plugins.length;u++)r.push(u<i?{state:n,n:e.length}:{state:this,n:0})}e.push(l),n=n.applyInner(l),o=!0}r&&(r[i]={state:n,n:e.length})}}if(!o)return{state:n,transactions:e}}},k.prototype.applyInner=function(t){if(!t.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");for(var e=new k(this.config),n=this.config.fields,r=0;r<n.length;r++){var o=n[r];e[o.name]=o.apply(t,this[o.name],this,e)}for(var i=0;i<C.length;i++)C[i](this,t,e);return e},x.tr.get=function(){return new g(this)},k.create=function(t){for(var e=new S(t.doc?t.doc.type.schema:t.schema,t.plugins),n=new k(e),r=0;r<e.fields.length;r++)n[e.fields[r].name]=e.fields[r].init(t,n);return n},k.prototype.reconfigure=function(t){for(var e=new S(this.schema,t.plugins),n=e.fields,r=new k(e),o=0;o<n.length;o++){var i=n[o].name;r[i]=this.hasOwnProperty(i)?this[i]:n[o].init(t,r)}return r},k.prototype.toJSON=function(t){var e={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(e.storedMarks=this.storedMarks.map((function(t){return t.toJSON()}))),t&&"object"==typeof t)for(var n in t){if("doc"==n||"selection"==n)throw new RangeError("The JSON fields `doc` and `selection` are reserved");var r=t[n],o=r.spec.state;o&&o.toJSON&&(e[n]=o.toJSON.call(r,this[r.key]))}return e},k.fromJSON=function(t,e,n){if(!e)throw new RangeError("Invalid input for EditorState.fromJSON");if(!t.schema)throw new RangeError("Required config field 'schema' missing");var o=new S(t.schema,t.plugins),i=new k(o);return o.fields.forEach((function(o){if("doc"==o.name)i.doc=r.Node.fromJSON(t.schema,e.doc);else if("selection"==o.name)i.selection=s.fromJSON(i.doc,e.selection);else if("storedMarks"==o.name)e.storedMarks&&(i.storedMarks=e.storedMarks.map(t.schema.markFromJSON));else{if(n)for(var a in n){var c=n[a],l=c.spec.state;if(c.key==o.name&&l&&l.fromJSON&&Object.prototype.hasOwnProperty.call(e,a))return void(i[o.name]=l.fromJSON.call(c,t,e[a],i))}i[o.name]=o.init(t,i)}})),i},k.addApplyListener=function(t){C.push(t)},k.removeApplyListener=function(t){var e=C.indexOf(t);e>-1&&C.splice(e,1)},Object.defineProperties(k.prototype,x);var C=[];var M=function(t){this.props={},t.props&&function t(e,n,r){for(var o in e){var i=e[o];i instanceof Function?i=i.bind(n):"handleDOMEvents"==o&&(i=t(i,n,{})),r[o]=i}return r}(t.props,this,this.props),this.spec=t,this.key=t.key?t.key.key:T("plugin")};M.prototype.getState=function(t){return t[this.key]};var O=Object.create(null);function T(t){return t in O?t+"$"+ ++O[t]:(O[t]=0,t+"$")}var N=function(t){void 0===t&&(t="key"),this.key=T(t)};N.prototype.get=function(t){return t.config.pluginsByKey[this.key]},N.prototype.getState=function(t){return t[this.key]}},function(t,e,n){"use strict";n.r(e),n.d(e,"AddMarkStep",(function(){return D})),n.d(e,"MapResult",(function(){return s})),n.d(e,"Mapping",(function(){return c})),n.d(e,"RemoveMarkStep",(function(){return E})),n.d(e,"ReplaceAroundStep",(function(){return g})),n.d(e,"ReplaceStep",(function(){return v})),n.d(e,"Step",(function(){return h})),n.d(e,"StepMap",(function(){return a})),n.d(e,"StepResult",(function(){return m})),n.d(e,"Transform",(function(){return u})),n.d(e,"TransformError",(function(){return l})),n.d(e,"canJoin",(function(){return C})),n.d(e,"canSplit",(function(){return x})),n.d(e,"dropPoint",(function(){return N})),n.d(e,"findWrapping",(function(){return S})),n.d(e,"insertPoint",(function(){return T})),n.d(e,"joinPoint",(function(){return O})),n.d(e,"liftTarget",(function(){return b})),n.d(e,"replaceStep",(function(){return R}));var r=n(0),o=Math.pow(2,16);function i(t){return 65535&t}var s=function(t,e,n){void 0===e&&(e=!1),void 0===n&&(n=null),this.pos=t,this.deleted=e,this.recover=n},a=function t(e,n){if(void 0===n&&(n=!1),!e.length&&t.empty)return t.empty;this.ranges=e,this.inverted=n};a.prototype.recover=function(t){var e=0,n=i(t);if(!this.inverted)for(var r=0;r<n;r++)e+=this.ranges[3*r+2]-this.ranges[3*r+1];return this.ranges[3*n]+e+function(t){return(t-(65535&t))/o}(t)},a.prototype.mapResult=function(t,e){return void 0===e&&(e=1),this._map(t,e,!1)},a.prototype.map=function(t,e){return void 0===e&&(e=1),this._map(t,e,!0)},a.prototype._map=function(t,e,n){for(var r=0,i=this.inverted?2:1,a=this.inverted?1:2,c=0;c<this.ranges.length;c+=3){var l=this.ranges[c]-(this.inverted?r:0);if(l>t)break;var u=this.ranges[c+i],p=this.ranges[c+a],f=l+u;if(t<=f){var d=l+r+((u?t==l?-1:t==f?1:e:e)<0?0:p);if(n)return d;var h=t==(e<0?l:f)?null:c/3+(t-l)*o;return new s(d,e<0?t!=l:t!=f,h)}r+=p-u}return n?t+r:new s(t+r)},a.prototype.touches=function(t,e){for(var n=0,r=i(e),o=this.inverted?2:1,s=this.inverted?1:2,a=0;a<this.ranges.length;a+=3){var c=this.ranges[a]-(this.inverted?n:0);if(c>t)break;var l=this.ranges[a+o];if(t<=c+l&&a==3*r)return!0;n+=this.ranges[a+s]-l}return!1},a.prototype.forEach=function(t){for(var e=this.inverted?2:1,n=this.inverted?1:2,r=0,o=0;r<this.ranges.length;r+=3){var i=this.ranges[r],s=i-(this.inverted?o:0),a=i+(this.inverted?0:o),c=this.ranges[r+e],l=this.ranges[r+n];t(s,s+c,a,a+l),o+=l-c}},a.prototype.invert=function(){return new a(this.ranges,!this.inverted)},a.prototype.toString=function(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)},a.offset=function(t){return 0==t?a.empty:new a(t<0?[0,-t,0]:[0,0,t])},a.empty=new a([]);var c=function(t,e,n,r){this.maps=t||[],this.from=n||0,this.to=null==r?this.maps.length:r,this.mirror=e};function l(t){var e=Error.call(this,t);return e.__proto__=l.prototype,e}c.prototype.slice=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=this.maps.length),new c(this.maps,this.mirror,t,e)},c.prototype.copy=function(){return new c(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)},c.prototype.appendMap=function(t,e){this.to=this.maps.push(t),null!=e&&this.setMirror(this.maps.length-1,e)},c.prototype.appendMapping=function(t){for(var e=0,n=this.maps.length;e<t.maps.length;e++){var r=t.getMirror(e);this.appendMap(t.maps[e],null!=r&&r<e?n+r:null)}},c.prototype.getMirror=function(t){if(this.mirror)for(var e=0;e<this.mirror.length;e++)if(this.mirror[e]==t)return this.mirror[e+(e%2?-1:1)]},c.prototype.setMirror=function(t,e){this.mirror||(this.mirror=[]),this.mirror.push(t,e)},c.prototype.appendMappingInverted=function(t){for(var e=t.maps.length-1,n=this.maps.length+t.maps.length;e>=0;e--){var r=t.getMirror(e);this.appendMap(t.maps[e].invert(),null!=r&&r>e?n-r-1:null)}},c.prototype.invert=function(){var t=new c;return t.appendMappingInverted(this),t},c.prototype.map=function(t,e){if(void 0===e&&(e=1),this.mirror)return this._map(t,e,!0);for(var n=this.from;n<this.to;n++)t=this.maps[n].map(t,e);return t},c.prototype.mapResult=function(t,e){return void 0===e&&(e=1),this._map(t,e,!1)},c.prototype._map=function(t,e,n){for(var r=!1,o=this.from;o<this.to;o++){var i=this.maps[o].mapResult(t,e);if(null!=i.recover){var a=this.getMirror(o);if(null!=a&&a>o&&a<this.to){o=a,t=this.maps[a].recover(i.recover);continue}}i.deleted&&(r=!0),t=i.pos}return n?t:new s(t,r)},l.prototype=Object.create(Error.prototype),l.prototype.constructor=l,l.prototype.name="TransformError";var u=function(t){this.doc=t,this.steps=[],this.docs=[],this.mapping=new c},p={before:{configurable:!0},docChanged:{configurable:!0}};function f(){throw new Error("Override me")}p.before.get=function(){return this.docs.length?this.docs[0]:this.doc},u.prototype.step=function(t){var e=this.maybeStep(t);if(e.failed)throw new l(e.failed);return this},u.prototype.maybeStep=function(t){var e=t.apply(this.doc);return e.failed||this.addStep(t,e.doc),e},p.docChanged.get=function(){return this.steps.length>0},u.prototype.addStep=function(t,e){this.docs.push(this.doc),this.steps.push(t),this.mapping.appendMap(t.getMap()),this.doc=e},Object.defineProperties(u.prototype,p);var d=Object.create(null),h=function(){};h.prototype.apply=function(t){return f()},h.prototype.getMap=function(){return a.empty},h.prototype.invert=function(t){return f()},h.prototype.map=function(t){return f()},h.prototype.merge=function(t){return null},h.prototype.toJSON=function(){return f()},h.fromJSON=function(t,e){if(!e||!e.stepType)throw new RangeError("Invalid input for Step.fromJSON");var n=d[e.stepType];if(!n)throw new RangeError("No step type "+e.stepType+" defined");return n.fromJSON(t,e)},h.jsonID=function(t,e){if(t in d)throw new RangeError("Duplicate use of step JSON ID "+t);return d[t]=e,e.prototype.jsonID=t,e};var m=function(t,e){this.doc=t,this.failed=e};m.ok=function(t){return new m(t,null)},m.fail=function(t){return new m(null,t)},m.fromReplace=function(t,e,n,o){try{return m.ok(t.replace(e,n,o))}catch(t){if(t instanceof r.ReplaceError)return m.fail(t.message);throw t}};var v=function(t){function e(e,n,r,o){t.call(this),this.from=e,this.to=n,this.slice=r,this.structure=!!o}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.apply=function(t){return this.structure&&y(t,this.from,this.to)?m.fail("Structure replace would overwrite content"):m.fromReplace(t,this.from,this.to,this.slice)},e.prototype.getMap=function(){return new a([this.from,this.to-this.from,this.slice.size])},e.prototype.invert=function(t){return new e(this.from,this.from+this.slice.size,t.slice(this.from,this.to))},e.prototype.map=function(t){var n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted?null:new e(n.pos,Math.max(n.pos,r.pos),this.slice)},e.prototype.merge=function(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;var n=this.slice.size+t.slice.size==0?r.Slice.empty:new r.Slice(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new e(t.from,this.to,n,this.structure)}var o=this.slice.size+t.slice.size==0?r.Slice.empty:new r.Slice(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new e(this.from,this.to+(t.to-t.from),o,this.structure)},e.prototype.toJSON=function(){var t={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t},e.fromJSON=function(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,r.Slice.fromJSON(t,n.slice),!!n.structure)},e}(h);h.jsonID("replace",v);var g=function(t){function e(e,n,r,o,i,s,a){t.call(this),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=o,this.slice=i,this.insert=s,this.structure=!!a}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.apply=function(t){if(this.structure&&(y(t,this.from,this.gapFrom)||y(t,this.gapTo,this.to)))return m.fail("Structure gap-replace would overwrite content");var e=t.slice(this.gapFrom,this.gapTo);if(e.openStart||e.openEnd)return m.fail("Gap is not a flat range");var n=this.slice.insertAt(this.insert,e.content);return n?m.fromReplace(t,this.from,this.to,n):m.fail("Content does not fit in gap")},e.prototype.getMap=function(){return new a([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])},e.prototype.invert=function(t){var 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)},e.prototype.map=function(t){var n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1),o=t.map(this.gapFrom,-1),i=t.map(this.gapTo,1);return n.deleted&&r.deleted||o<n.pos||i>r.pos?null:new e(n.pos,r.pos,o,i,this.slice,this.insert,this.structure)},e.prototype.toJSON=function(){var t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t},e.fromJSON=function(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,r.Slice.fromJSON(t,n.slice),n.insert,!!n.structure)},e}(h);function y(t,e,n){for(var r=t.resolve(e),o=n-e,i=r.depth;o>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,o--;if(o>0)for(var s=r.node(i).maybeChild(r.indexAfter(i));o>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,o--}return!1}function w(t,e,n){return(0==e||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function b(t){for(var e=t.parent.content.cutByIndex(t.startIndex,t.endIndex),n=t.depth;;--n){var r=t.$from.node(n),o=t.$from.index(n),i=t.$to.indexAfter(n);if(n<t.depth&&r.canReplace(o,i,e))return n;if(0==n||r.type.spec.isolating||!w(r,o,i))break}}function S(t,e,n,r){void 0===r&&(r=t);var o=function(t,e){var n=t.parent,r=t.startIndex,o=t.endIndex,i=n.contentMatchAt(r).findWrapping(e);if(!i)return null;var s=i.length?i[0]:e;return n.canReplaceWith(r,o,s)?i:null}(t,e),i=o&&function(t,e){var n=t.parent,r=t.startIndex,o=t.endIndex,i=n.child(r),s=e.contentMatch.findWrapping(i.type);if(!s)return null;for(var a=(s.length?s[s.length-1]:e).contentMatch,c=r;a&&c<o;c++)a=a.matchType(n.child(c).type);if(!a||!a.validEnd)return null;return s}(r,e);return i?o.map(k).concat({type:e,attrs:n}).concat(i.map(k)):null}function k(t){return{type:t,attrs:null}}function x(t,e,n,r){void 0===n&&(n=1);var o=t.resolve(e),i=o.depth-n,s=r&&r[r.length-1]||o.parent;if(i<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!s.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(var a=o.depth-1,c=n-2;a>i;a--,c--){var l=o.node(a),u=o.index(a);if(l.type.spec.isolating)return!1;var p=l.content.cutByIndex(u,l.childCount),f=r&&r[c]||l;if(f!=l&&(p=p.replaceChild(0,f.type.create(f.attrs))),!l.canReplace(u+1,l.childCount)||!f.type.validContent(p))return!1}var d=o.indexAfter(i),h=r&&r[0];return o.node(i).canReplaceWith(d,d,h?h.type:o.node(i+1).type)}function C(t,e){var n=t.resolve(e),r=n.index();return M(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function M(t,e){return t&&e&&!t.isLeaf&&t.canAppend(e)}function O(t,e,n){void 0===n&&(n=-1);for(var r=t.resolve(e),o=r.depth;;o--){var i=void 0,s=void 0,a=r.index(o);if(o==r.depth?(i=r.nodeBefore,s=r.nodeAfter):n>0?(i=r.node(o+1),a++,s=r.node(o).maybeChild(a)):(i=r.node(o).maybeChild(a-1),s=r.node(o+1)),i&&!i.isTextblock&&M(i,s)&&r.node(o).canReplace(a,a+1))return e;if(0==o)break;e=n<0?r.before(o):r.after(o)}}function T(t,e,n){var r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(0==r.parentOffset)for(var o=r.depth-1;o>=0;o--){var i=r.index(o);if(r.node(o).canReplaceWith(i,i,n))return r.before(o+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(var s=r.depth-1;s>=0;s--){var a=r.indexAfter(s);if(r.node(s).canReplaceWith(a,a,n))return r.after(s+1);if(a<r.node(s).childCount)return null}}function N(t,e,n){var r=t.resolve(e);if(!n.content.size)return e;for(var o=n.content,i=0;i<n.openStart;i++)o=o.firstChild.content;for(var s=1;s<=(0==n.openStart&&n.size?2:1);s++)for(var a=r.depth;a>=0;a--){var c=a==r.depth?0:r.pos<=(r.start(a+1)+r.end(a+1))/2?-1:1,l=r.index(a)+(c>0?1:0),u=r.node(a),p=!1;if(1==s)p=u.canReplace(l,l,o);else{var f=u.contentMatchAt(l).findWrapping(o.firstChild.type);p=f&&u.canReplaceWith(l,l,f[0])}if(p)return 0==c?r.pos:c<0?r.before(a+1):r.after(a+1)}return null}function A(t,e,n){for(var o=[],i=0;i<t.childCount;i++){var s=t.child(i);s.content.size&&(s=s.copy(A(s.content,e,s))),s.isInline&&(s=e(s,n,i)),o.push(s)}return r.Fragment.fromArray(o)}h.jsonID("replaceAround",g),u.prototype.lift=function(t,e){for(var n=t.$from,o=t.$to,i=t.depth,s=n.before(i+1),a=o.after(i+1),c=s,l=a,u=r.Fragment.empty,p=0,f=i,d=!1;f>e;f--)d||n.index(f)>0?(d=!0,u=r.Fragment.from(n.node(f).copy(u)),p++):c--;for(var h=r.Fragment.empty,m=0,v=i,y=!1;v>e;v--)y||o.after(v+1)<o.end(v)?(y=!0,h=r.Fragment.from(o.node(v).copy(h)),m++):l++;return this.step(new g(c,l,s,a,new r.Slice(u.append(h),p,m),u.size-p,!0))},u.prototype.wrap=function(t,e){for(var n=r.Fragment.empty,o=e.length-1;o>=0;o--){if(n.size){var i=e[o].type.contentMatch.matchFragment(n);if(!i||!i.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}n=r.Fragment.from(e[o].type.create(e[o].attrs,n))}var s=t.start,a=t.end;return this.step(new g(s,a,s,a,new r.Slice(n,0,0),e.length,!0))},u.prototype.setBlockType=function(t,e,n,o){var i=this;if(void 0===e&&(e=t),!n.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");var s=this.steps.length;return this.doc.nodesBetween(t,e,(function(t,e){if(t.isTextblock&&!t.hasMarkup(n,o)&&function(t,e,n){var r=t.resolve(e),o=r.index();return r.parent.canReplaceWith(o,o+1,n)}(i.doc,i.mapping.slice(s).map(e),n)){i.clearIncompatible(i.mapping.slice(s).map(e,1),n);var a=i.mapping.slice(s),c=a.map(e,1),l=a.map(e+t.nodeSize,1);return i.step(new g(c,l,c+1,l-1,new r.Slice(r.Fragment.from(n.create(o,null,t.marks)),0,0),1,!0)),!1}})),this},u.prototype.setNodeMarkup=function(t,e,n,o){var i=this.doc.nodeAt(t);if(!i)throw new RangeError("No node at given position");e||(e=i.type);var s=e.create(n,null,o||i.marks);if(i.isLeaf)return this.replaceWith(t,t+i.nodeSize,s);if(!e.validContent(i.content))throw new RangeError("Invalid content for node type "+e.name);return this.step(new g(t,t+i.nodeSize,t+1,t+i.nodeSize-1,new r.Slice(r.Fragment.from(s),0,0),1,!0))},u.prototype.split=function(t,e,n){void 0===e&&(e=1);for(var o=this.doc.resolve(t),i=r.Fragment.empty,s=r.Fragment.empty,a=o.depth,c=o.depth-e,l=e-1;a>c;a--,l--){i=r.Fragment.from(o.node(a).copy(i));var u=n&&n[l];s=r.Fragment.from(u?u.type.create(u.attrs,s):o.node(a).copy(s))}return this.step(new v(t,t,new r.Slice(i.append(s),e,e),!0))},u.prototype.join=function(t,e){void 0===e&&(e=1);var n=new v(t-e,t+e,r.Slice.empty,!0);return this.step(n)};var D=function(t){function e(e,n,r){t.call(this),this.from=e,this.to=n,this.mark=r}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.apply=function(t){var e=this,n=t.slice(this.from,this.to),o=t.resolve(this.from),i=o.node(o.sharedDepth(this.to)),s=new r.Slice(A(n.content,(function(t,n){return t.isAtom&&n.type.allowsMarkType(e.mark.type)?t.mark(e.mark.addToSet(t.marks)):t}),i),n.openStart,n.openEnd);return m.fromReplace(t,this.from,this.to,s)},e.prototype.invert=function(){return new E(this.from,this.to,this.mark)},e.prototype.map=function(t){var 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)},e.prototype.merge=function(t){if(t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from)return new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark)},e.prototype.toJSON=function(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}},e.fromJSON=function(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))},e}(h);h.jsonID("addMark",D);var E=function(t){function e(e,n,r){t.call(this),this.from=e,this.to=n,this.mark=r}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.apply=function(t){var e=this,n=t.slice(this.from,this.to),o=new r.Slice(A(n.content,(function(t){return t.mark(e.mark.removeFromSet(t.marks))})),n.openStart,n.openEnd);return m.fromReplace(t,this.from,this.to,o)},e.prototype.invert=function(){return new D(this.from,this.to,this.mark)},e.prototype.map=function(t){var 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)},e.prototype.merge=function(t){if(t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from)return new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark)},e.prototype.toJSON=function(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}},e.fromJSON=function(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))},e}(h);function R(t,e,n,o){if(void 0===n&&(n=e),void 0===o&&(o=r.Slice.empty),e==n&&!o.size)return null;var i=t.resolve(e),s=t.resolve(n);return _(i,s,o)?new v(e,n,o):new I(i,s,o).fit()}function _(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}h.jsonID("removeMark",E),u.prototype.addMark=function(t,e,n){var r=this,o=[],i=[],s=null,a=null;return this.doc.nodesBetween(t,e,(function(r,c,l){if(r.isInline){var u=r.marks;if(!n.isInSet(u)&&l.type.allowsMarkType(n.type)){for(var p=Math.max(c,t),f=Math.min(c+r.nodeSize,e),d=n.addToSet(u),h=0;h<u.length;h++)u[h].isInSet(d)||(s&&s.to==p&&s.mark.eq(u[h])?s.to=f:o.push(s=new E(p,f,u[h])));a&&a.to==p?a.to=f:i.push(a=new D(p,f,n))}}})),o.forEach((function(t){return r.step(t)})),i.forEach((function(t){return r.step(t)})),this},u.prototype.removeMark=function(t,e,n){var o=this;void 0===n&&(n=null);var i=[],s=0;return this.doc.nodesBetween(t,e,(function(o,a){if(o.isInline){s++;var c=null;if(n instanceof r.MarkType)for(var l,u=o.marks;l=n.isInSet(u);)(c||(c=[])).push(l),u=l.removeFromSet(u);else n?n.isInSet(o.marks)&&(c=[n]):c=o.marks;if(c&&c.length)for(var p=Math.min(a+o.nodeSize,e),f=0;f<c.length;f++){for(var d=c[f],h=void 0,m=0;m<i.length;m++){var v=i[m];v.step==s-1&&d.eq(i[m].style)&&(h=v)}h?(h.to=p,h.step=s):i.push({style:d,from:Math.max(a,t),to:p,step:s})}}})),i.forEach((function(t){return o.step(new E(t.from,t.to,t.style))})),this},u.prototype.clearIncompatible=function(t,e,n){void 0===n&&(n=e.contentMatch);for(var o=this.doc.nodeAt(t),i=[],s=t+1,a=0;a<o.childCount;a++){var c=o.child(a),l=s+c.nodeSize,u=n.matchType(c.type,c.attrs);if(u){n=u;for(var p=0;p<c.marks.length;p++)e.allowsMarkType(c.marks[p].type)||this.step(new E(s,l,c.marks[p]))}else i.push(new v(s,l,r.Slice.empty));s=l}if(!n.validEnd){var f=n.fillBefore(r.Fragment.empty,!0);this.replace(s,s,new r.Slice(f,0,0))}for(var d=i.length-1;d>=0;d--)this.step(i[d]);return this},u.prototype.replace=function(t,e,n){void 0===e&&(e=t),void 0===n&&(n=r.Slice.empty);var o=R(this.doc,t,e,n);return o&&this.step(o),this},u.prototype.replaceWith=function(t,e,n){return this.replace(t,e,new r.Slice(r.Fragment.from(n),0,0))},u.prototype.delete=function(t,e){return this.replace(t,e,r.Slice.empty)},u.prototype.insert=function(t,e){return this.replaceWith(t,t,e)};var I=function(t,e,n){this.$to=e,this.$from=t,this.unplaced=n,this.frontier=[];for(var o=0;o<=t.depth;o++){var i=t.node(o);this.frontier.push({type:i.type,match:i.contentMatchAt(t.indexAfter(o))})}this.placed=r.Fragment.empty;for(var s=t.depth;s>0;s--)this.placed=r.Fragment.from(t.node(s).copy(this.placed))},z={depth:{configurable:!0}};function P(t,e,n){return 0==e?t.cutByIndex(n):t.replaceChild(0,t.firstChild.copy(P(t.firstChild.content,e-1,n)))}function $(t,e,n){return 0==e?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy($(t.lastChild.content,e-1,n)))}function F(t,e){for(var n=0;n<e;n++)t=t.firstChild.content;return t}function B(t,e,n){if(e<=0)return t;var o=t.content;return e>1&&(o=o.replaceChild(0,B(o.firstChild,e-1,1==o.childCount?n-1:0))),e>0&&(o=t.type.contentMatch.fillBefore(o).append(o),n<=0&&(o=o.append(t.type.contentMatch.matchFragment(o).fillBefore(r.Fragment.empty,!0)))),t.copy(o)}function L(t,e,n,r,o){var i=t.node(e),s=o?t.indexAfter(e):t.index(e);if(s==i.childCount&&!n.compatibleContent(i.type))return null;var a=r.fillBefore(i.content,!0,s);return a&&!function(t,e,n){for(var r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}(n,i.content,s)?a:null}function V(t){return t.spec.defining||t.spec.definingForContent}function j(t,e,n,o,i){if(e<n){var s=t.firstChild;t=t.replaceChild(0,s.copy(j(s.content,e+1,n,o,s)))}if(e>o){var a=i.contentMatchAt(0),c=a.fillBefore(t).append(t);t=c.append(a.matchFragment(c).fillBefore(r.Fragment.empty,!0))}return t}function W(t,e){for(var n=[],r=Math.min(t.depth,e.depth);r>=0;r--){var o=t.start(r);if(o<t.pos-(t.depth-r)||e.end(r)>e.pos+(e.depth-r)||t.node(r).type.spec.isolating||e.node(r).type.spec.isolating)break;(o==e.start(r)||r==t.depth&&r==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&r&&e.start(r-1)==o-1)&&n.push(r)}return n}z.depth.get=function(){return this.frontier.length-1},I.prototype.fit=function(){for(;this.unplaced.size;){var t=this.findFittable();t?this.placeNodes(t):this.openMore()||this.dropNode()}var e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,o=this.$from,i=this.close(e<0?this.$to:o.doc.resolve(e));if(!i)return null;for(var s=this.placed,a=o.depth,c=i.depth;a&&c&&1==s.childCount;)s=s.firstChild.content,a--,c--;var l=new r.Slice(s,a,c);return e>-1?new g(o.pos,e,this.$to.pos,this.$to.end(),l,n):l.size||o.pos!=this.$to.pos?new v(o.pos,i.pos,l):void 0},I.prototype.findFittable=function(){for(var t=1;t<=2;t++)for(var e=this.unplaced.openStart;e>=0;e--)for(var n=void 0,o=(e?(n=F(this.unplaced.content,e-1).firstChild).content:this.unplaced.content).firstChild,i=this.depth;i>=0;i--){var s=this.frontier[i],a=s.type,c=s.match,l=void 0,u=void 0;if(1==t&&(o?c.matchType(o.type)||(u=c.fillBefore(r.Fragment.from(o),!1)):a.compatibleContent(n.type)))return{sliceDepth:e,frontierDepth:i,parent:n,inject:u};if(2==t&&o&&(l=c.findWrapping(o.type)))return{sliceDepth:e,frontierDepth:i,parent:n,wrap:l};if(n&&c.matchType(n.type))break}},I.prototype.openMore=function(){var t=this.unplaced,e=t.content,n=t.openStart,o=t.openEnd,i=F(e,n);return!(!i.childCount||i.firstChild.isLeaf)&&(this.unplaced=new r.Slice(e,n+1,Math.max(o,i.size+n>=e.size-o?n+1:0)),!0)},I.prototype.dropNode=function(){var t=this.unplaced,e=t.content,n=t.openStart,o=t.openEnd,i=F(e,n);if(i.childCount<=1&&n>0){var s=e.size-n<=n+i.size;this.unplaced=new r.Slice(P(e,n-1,1),n-1,s?n-1:o)}else this.unplaced=new r.Slice(P(e,n,1),n,o)},I.prototype.placeNodes=function(t){for(var e=t.sliceDepth,n=t.frontierDepth,o=t.parent,i=t.inject,s=t.wrap;this.depth>n;)this.closeFrontierNode();if(s)for(var a=0;a<s.length;a++)this.openFrontierNode(s[a]);var c=this.unplaced,l=o?o.content:c.content,u=c.openStart-e,p=0,f=[],d=this.frontier[n],h=d.match,m=d.type;if(i){for(var v=0;v<i.childCount;v++)f.push(i.child(v));h=h.matchFragment(i)}for(var g=l.size+e-(c.content.size-c.openEnd);p<l.childCount;){var y=l.child(p),w=h.matchType(y.type);if(!w)break;(++p>1||0==u||y.content.size)&&(h=w,f.push(B(y.mark(m.allowedMarks(y.marks)),1==p?u:0,p==l.childCount?g:-1)))}var b=p==l.childCount;b||(g=-1),this.placed=$(this.placed,n,r.Fragment.from(f)),this.frontier[n].match=h,b&&g<0&&o&&o.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(var S=0,k=l;S<g;S++){var x=k.lastChild;this.frontier.push({type:x.type,match:x.contentMatchAt(x.childCount)}),k=x.content}this.unplaced=b?0==e?r.Slice.empty:new r.Slice(P(c.content,e-1,1),e-1,g<0?c.openEnd:e-1):new r.Slice(P(c.content,e,p),c.openStart,c.openEnd)},I.prototype.mustMoveInline=function(){if(!this.$to.parent.isTextblock||this.$to.end()==this.$to.pos)return-1;var t,e=this.frontier[this.depth];if(!e.type.isTextblock||!L(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;for(var n=this.$to.depth,r=this.$to.after(n);n>1&&r==this.$to.end(--n);)++r;return r},I.prototype.findCloseLevel=function(t){t:for(var e=Math.min(this.depth,t.depth);e>=0;e--){var n=this.frontier[e],r=n.match,o=n.type,i=e<t.depth&&t.end(e+1)==t.pos+(t.depth-(e+1)),s=L(t,e,o,r,i);if(s){for(var a=e-1;a>=0;a--){var c=this.frontier[a],l=c.match,u=L(t,a,c.type,l,!0);if(!u||u.childCount)continue t}return{depth:e,fit:s,move:i?t.doc.resolve(t.after(e+1)):t}}}},I.prototype.close=function(t){var e=this.findCloseLevel(t);if(!e)return null;for(;this.depth>e.depth;)this.closeFrontierNode();e.fit.childCount&&(this.placed=$(this.placed,e.depth,e.fit)),t=e.move;for(var n=e.depth+1;n<=t.depth;n++){var r=t.node(n),o=r.type.contentMatch.fillBefore(r.content,!0,t.index(n));this.openFrontierNode(r.type,r.attrs,o)}return t},I.prototype.openFrontierNode=function(t,e,n){var o=this.frontier[this.depth];o.match=o.match.matchType(t),this.placed=$(this.placed,this.depth,r.Fragment.from(t.create(e,n))),this.frontier.push({type:t,match:t.contentMatch})},I.prototype.closeFrontierNode=function(){var t=this.frontier.pop().match.fillBefore(r.Fragment.empty,!0);t.childCount&&(this.placed=$(this.placed,this.frontier.length,t))},Object.defineProperties(I.prototype,z),u.prototype.replaceRange=function(t,e,n){if(!n.size)return this.deleteRange(t,e);var o=this.doc.resolve(t),i=this.doc.resolve(e);if(_(o,i,n))return this.step(new v(t,e,n));var s=W(o,this.doc.resolve(e));0==s[s.length-1]&&s.pop();var a=-(o.depth+1);s.unshift(a);for(var c=o.depth,l=o.pos-1;c>0;c--,l--){var u=o.node(c).type.spec;if(u.defining||u.definingAsContext||u.isolating)break;s.indexOf(c)>-1?a=c:o.before(c)==l&&s.splice(1,0,-c)}for(var p=s.indexOf(a),f=[],d=n.openStart,h=n.content,m=0;;m++){var g=h.firstChild;if(f.push(g),m==n.openStart)break;h=g.content}d>0&&V(f[d-1].type)&&o.node(p).type!=f[d-1].type?d-=1:d>=2&&f[d-1].isTextblock&&V(f[d-2].type)&&o.node(p).type!=f[d-2].type&&(d-=2);for(var y=n.openStart;y>=0;y--){var w=(y+d+1)%(n.openStart+1),b=f[w];if(b)for(var S=0;S<s.length;S++){var k=s[(S+p)%s.length],x=!0;k<0&&(x=!1,k=-k);var C=o.node(k-1),M=o.index(k-1);if(C.canReplaceWith(M,M,b.type,b.marks))return this.replace(o.before(k),x?i.after(k):e,new r.Slice(j(n.content,0,n.openStart,w),w,n.openEnd))}}for(var O=this.steps.length,T=s.length-1;T>=0&&(this.replace(t,e,n),!(this.steps.length>O));T--){var N=s[T];N<0||(t=o.before(N),e=i.after(N))}return this},u.prototype.replaceRangeWith=function(t,e,n){if(!n.isInline&&t==e&&this.doc.resolve(t).parent.content.size){var o=T(this.doc,t,n.type);null!=o&&(t=e=o)}return this.replaceRange(t,e,new r.Slice(r.Fragment.from(n),0,0))},u.prototype.deleteRange=function(t,e){for(var n=this.doc.resolve(t),r=this.doc.resolve(e),o=W(n,r),i=0;i<o.length;i++){var s=o[i],a=i==o.length-1;if(a&&0==s||n.node(s).type.contentMatch.validEnd)return this.delete(n.start(s),r.end(s));if(s>0&&(a||n.node(s-1).canReplace(n.index(s-1),r.indexAfter(s-1))))return this.delete(n.before(s),r.after(s))}for(var c=1;c<=n.depth&&c<=r.depth;c++)if(t-n.start(c)==n.depth-c&&e>n.end(c)&&r.end(c)-e!=r.depth-c)return this.delete(n.before(c),e);return this.delete(t,e)}},function(t,e,n){"use strict";n.r(e),n.d(e,"Decoration",(function(){return Ne})),n.d(e,"DecorationSet",(function(){return Re})),n.d(e,"EditorView",(function(){return We})),n.d(e,"__endComposition",(function(){return ye})),n.d(e,"__parseFromClipboard",(function(){return Vt})),n.d(e,"__serializeForClipboard",(function(){return Lt}));var r=n(1),o=n(0),i=n(2),s={};if("undefined"!=typeof navigator&&"undefined"!=typeof document){var a=/Edge\/(\d+)/.exec(navigator.userAgent),c=/MSIE \d/.test(navigator.userAgent),l=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),u=s.ie=!!(c||l||a);s.ie_version=c?document.documentMode||6:l?+l[1]:a?+a[1]:null,s.gecko=!u&&/gecko\/(\d+)/i.test(navigator.userAgent),s.gecko_version=s.gecko&&+(/Firefox\/(\d+)/.exec(navigator.userAgent)||[0,0])[1];var p=!u&&/Chrome\/(\d+)/.exec(navigator.userAgent);s.chrome=!!p,s.chrome_version=p&&+p[1],s.safari=!u&&/Apple Computer/.test(navigator.vendor),s.ios=s.safari&&(/Mobile\/\w+/.test(navigator.userAgent)||navigator.maxTouchPoints>2),s.mac=s.ios||/Mac/.test(navigator.platform),s.android=/Android \d/.test(navigator.userAgent),s.webkit="webkitFontSmoothing"in document.documentElement.style,s.webkit_version=s.webkit&&+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]}var f=function(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e},d=function(t){var e=t.assignedSlot||t.parentNode;return e&&11==e.nodeType?e.host:e},h=null,m=function(t,e,n){var r=h||(h=document.createRange());return r.setEnd(t,null==n?t.nodeValue.length:n),r.setStart(t,e||0),r},v=function(t,e,n,r){return n&&(y(t,e,n,r,-1)||y(t,e,n,r,1))},g=/^(img|br|input|textarea|hr)$/i;function y(t,e,n,r,o){for(;;){if(t==n&&e==r)return!0;if(e==(o<0?0:w(t))){var i=t.parentNode;if(!i||1!=i.nodeType||b(t)||g.test(t.nodeName)||"false"==t.contentEditable)return!1;e=f(t)+(o<0?0:1),t=i}else{if(1!=t.nodeType)return!1;if("false"==(t=t.childNodes[e+(o<0?-1:0)]).contentEditable)return!1;e=o<0?w(t):0}}}function w(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function b(t){for(var e,n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}var S=function(t){var e=t.isCollapsed;return e&&s.chrome&&t.rangeCount&&!t.getRangeAt(0).collapsed&&(e=!1),e};function k(t,e){var n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function x(t){return{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function C(t,e){return"number"==typeof t?t:t[e]}function M(t){var e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function O(t,e,n){for(var r=t.someProp("scrollThreshold")||0,o=t.someProp("scrollMargin")||5,i=t.dom.ownerDocument,s=n||t.dom;s;s=d(s))if(1==s.nodeType){var a=s==i.body||1!=s.nodeType,c=a?x(i):M(s),l=0,u=0;if(e.top<c.top+C(r,"top")?u=-(c.top-e.top+C(o,"top")):e.bottom>c.bottom-C(r,"bottom")&&(u=e.bottom-c.bottom+C(o,"bottom")),e.left<c.left+C(r,"left")?l=-(c.left-e.left+C(o,"left")):e.right>c.right-C(r,"right")&&(l=e.right-c.right+C(o,"right")),l||u)if(a)i.defaultView.scrollBy(l,u);else{var p=s.scrollLeft,f=s.scrollTop;u&&(s.scrollTop+=u),l&&(s.scrollLeft+=l);var h=s.scrollLeft-p,m=s.scrollTop-f;e={left:e.left-h,top:e.top-m,right:e.right-h,bottom:e.bottom-m}}if(a)break}}function T(t){for(var e=[],n=t.ownerDocument;t&&(e.push({dom:t,top:t.scrollTop,left:t.scrollLeft}),t!=n);t=d(t));return e}function N(t,e){for(var n=0;n<t.length;n++){var r=t[n],o=r.dom,i=r.top,s=r.left;o.scrollTop!=i+e&&(o.scrollTop=i+e),o.scrollLeft!=s&&(o.scrollLeft=s)}}var A=null;function D(t,e){for(var n,r,o=2e8,i=0,s=e.top,a=e.top,c=t.firstChild,l=0;c;c=c.nextSibling,l++){var u=void 0;if(1==c.nodeType)u=c.getClientRects();else{if(3!=c.nodeType)continue;u=m(c).getClientRects()}for(var p=0;p<u.length;p++){var f=u[p];if(f.top<=s&&f.bottom>=a){s=Math.max(f.bottom,s),a=Math.min(f.top,a);var d=f.left>e.left?f.left-e.left:f.right<e.left?e.left-f.right:0;if(d<o){n=c,o=d,r=d&&3==n.nodeType?{left:f.right<e.left?f.right:f.left,top:e.top}:e,1==c.nodeType&&d&&(i=l+(e.left>=(f.left+f.right)/2?1:0));continue}}!n&&(e.left>=f.right&&e.top>=f.top||e.left>=f.left&&e.top>=f.bottom)&&(i=l+1)}}return n&&3==n.nodeType?function(t,e){for(var n=t.nodeValue.length,r=document.createRange(),o=0;o<n;o++){r.setEnd(t,o+1),r.setStart(t,o);var i=_(r,1);if(i.top!=i.bottom&&E(e,i))return{node:t,offset:o+(e.left>=(i.left+i.right)/2?1:0)}}return{node:t,offset:0}}(n,r):!n||o&&1==n.nodeType?{node:t,offset:i}:D(n,r)}function E(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function R(t,e){var n,r,o,i,a=t.dom.ownerDocument;if(a.caretPositionFromPoint)try{var c=a.caretPositionFromPoint(e.left,e.top);c&&(o=(n=c).offsetNode,i=n.offset)}catch(t){}if(!o&&a.caretRangeFromPoint){var l=a.caretRangeFromPoint(e.left,e.top);l&&(o=(r=l).startContainer,i=r.startOffset)}var u,p=(t.root.elementFromPoint?t.root:a).elementFromPoint(e.left,e.top+1);if(!p||!t.dom.contains(1!=p.nodeType?p.parentNode:p)){var f=t.dom.getBoundingClientRect();if(!E(e,f))return null;if(!(p=function t(e,n,r){var o=e.childNodes.length;if(o&&r.top<r.bottom)for(var i=Math.max(0,Math.min(o-1,Math.floor(o*(n.top-r.top)/(r.bottom-r.top))-2)),s=i;;){var a=e.childNodes[s];if(1==a.nodeType)for(var c=a.getClientRects(),l=0;l<c.length;l++){var u=c[l];if(E(n,u))return t(a,n,u)}if((s=(s+1)%o)==i)break}return e}(t.dom,e,f)))return null}if(s.safari)for(var h=p;o&&h;h=d(h))h.draggable&&(o=i=null);if(p=function(t,e){var n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}(p,e),o){if(s.gecko&&1==o.nodeType&&(i=Math.min(i,o.childNodes.length))<o.childNodes.length){var m,v=o.childNodes[i];"IMG"==v.nodeName&&(m=v.getBoundingClientRect()).right<=e.left&&m.bottom>e.top&&i++}o==t.dom&&i==o.childNodes.length-1&&1==o.lastChild.nodeType&&e.top>o.lastChild.getBoundingClientRect().bottom?u=t.state.doc.content.size:0!=i&&1==o.nodeType&&"BR"==o.childNodes[i-1].nodeName||(u=function(t,e,n,r){for(var o=-1,i=e;i!=t.dom;){var s=t.docView.nearestDesc(i,!0);if(!s)return null;if(s.node.isBlock&&s.parent){var a=s.dom.getBoundingClientRect();if(a.left>r.left||a.top>r.top)o=s.posBefore;else{if(!(a.right<r.left||a.bottom<r.top))break;o=s.posAfter}}i=s.dom.parentNode}return o>-1?o:t.docView.posFromDOM(e,n)}(t,o,i,e))}null==u&&(u=function(t,e,n){var r=D(e,n),o=r.node,i=r.offset,s=-1;if(1==o.nodeType&&!o.firstChild){var a=o.getBoundingClientRect();s=a.left!=a.right&&n.left>(a.left+a.right)/2?1:-1}return t.docView.posFromDOM(o,i,s)}(t,p,e));var g=t.docView.nearestDesc(p,!0);return{pos:u,inside:g?g.posAtStart-g.border:-1}}function _(t,e){var n=t.getClientRects();return n.length?n[e<0?0:n.length-1]:t.getBoundingClientRect()}var I=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function z(t,e,n){var r=t.docView.domFromPos(e,n<0?-1:1),o=r.node,i=r.offset,a=s.webkit||s.gecko;if(3==o.nodeType){if(!a||!I.test(o.nodeValue)&&(n<0?i:i!=o.nodeValue.length)){var c=i,l=i,u=n<0?1:-1;return n<0&&!i?(l++,u=-1):n>=0&&i==o.nodeValue.length?(c--,u=1):n<0?c--:l++,P(_(m(o,c,l),u),u<0)}var p=_(m(o,i,i),n);if(s.gecko&&i&&/\s/.test(o.nodeValue[i-1])&&i<o.nodeValue.length){var f=_(m(o,i-1,i-1),-1);if(f.top==p.top){var d=_(m(o,i,i+1),-1);if(d.top!=p.top)return P(d,d.left<f.left)}}return p}if(!t.state.doc.resolve(e).parent.inlineContent){if(i&&(n<0||i==w(o))){var h=o.childNodes[i-1];if(1==h.nodeType)return $(h.getBoundingClientRect(),!1)}if(i<w(o)){var v=o.childNodes[i];if(1==v.nodeType)return $(v.getBoundingClientRect(),!0)}return $(o.getBoundingClientRect(),n>=0)}if(i&&(n<0||i==w(o))){var g=o.childNodes[i-1],y=3==g.nodeType?m(g,w(g)-(a?0:1)):1!=g.nodeType||"BR"==g.nodeName&&g.nextSibling?null:g;if(y)return P(_(y,1),!1)}if(i<w(o)){for(var b=o.childNodes[i];b.pmViewDesc&&b.pmViewDesc.ignoreForCoords;)b=b.nextSibling;var S=b?3==b.nodeType?m(b,0,a?0:1):1==b.nodeType?b:null:null;if(S)return P(_(S,-1),!0)}return P(_(3==o.nodeType?m(o):o,-n),n>=0)}function P(t,e){if(0==t.width)return t;var n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function $(t,e){if(0==t.height)return t;var n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function F(t,e,n){var r=t.state,o=t.root.activeElement;r!=e&&t.updateState(e),o!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),o!=t.dom&&o&&o.focus()}}var B=/[\u0590-\u08ac]/;var L=null,V=null,j=!1;function W(t,e,n){return L==e&&V==n?j:(L=e,V=n,j="up"==n||"down"==n?function(t,e,n){var r=e.selection,o="up"==n?r.$from:r.$to;return F(t,e,(function(){for(var e=t.docView.domFromPos(o.pos,"up"==n?-1:1).node;;){var r=t.docView.nearestDesc(e,!0);if(!r)break;if(r.node.isBlock){e=r.dom;break}e=r.dom.parentNode}for(var i=z(t,o.pos,1),s=e.firstChild;s;s=s.nextSibling){var a=void 0;if(1==s.nodeType)a=s.getClientRects();else{if(3!=s.nodeType)continue;a=m(s,0,s.nodeValue.length).getClientRects()}for(var c=0;c<a.length;c++){var l=a[c];if(l.bottom>l.top+1&&("up"==n?i.top-l.top>2*(l.bottom-i.top):l.bottom-i.bottom>2*(i.bottom-l.top)))return!1}}return!0}))}(t,e,n):function(t,e,n){var r=e.selection.$head;if(!r.parent.isTextblock)return!1;var o=r.parentOffset,i=!o,s=o==r.parent.content.size,a=t.root.getSelection();return B.test(r.parent.textContent)&&a.modify?F(t,e,(function(){var e=a.getRangeAt(0),o=a.focusNode,i=a.focusOffset,s=a.caretBidiLevel;a.modify("move",n,"character");var c=!(r.depth?t.docView.domAfterPos(r.before()):t.dom).contains(1==a.focusNode.nodeType?a.focusNode:a.focusNode.parentNode)||o==a.focusNode&&i==a.focusOffset;return a.removeAllRanges(),a.addRange(e),null!=s&&(a.caretBidiLevel=s),c})):"left"==n||"backward"==n?i:s}(t,e,n))}var K=function(t,e,n,r){this.parent=t,this.children=e,this.dom=n,n.pmViewDesc=this,this.contentDOM=r,this.dirty=0},q={size:{configurable:!0},border:{configurable:!0},posBefore:{configurable:!0},posAtStart:{configurable:!0},posAfter:{configurable:!0},posAtEnd:{configurable:!0},contentLost:{configurable:!0},domAtom:{configurable:!0},ignoreForCoords:{configurable:!0}};K.prototype.matchesWidget=function(){return!1},K.prototype.matchesMark=function(){return!1},K.prototype.matchesNode=function(){return!1},K.prototype.matchesHack=function(t){return!1},K.prototype.parseRule=function(){return null},K.prototype.stopEvent=function(){return!1},q.size.get=function(){for(var t=0,e=0;e<this.children.length;e++)t+=this.children[e].size;return t},q.border.get=function(){return 0},K.prototype.destroy=function(){this.parent=null,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=null);for(var t=0;t<this.children.length;t++)this.children[t].destroy()},K.prototype.posBeforeChild=function(t){for(var e=0,n=this.posAtStart;e<this.children.length;e++){var r=this.children[e];if(r==t)return n;n+=r.size}},q.posBefore.get=function(){return this.parent.posBeforeChild(this)},q.posAtStart.get=function(){return this.parent?this.parent.posBeforeChild(this)+this.border:0},q.posAfter.get=function(){return this.posBefore+this.size},q.posAtEnd.get=function(){return this.posAtStart+this.size-2*this.border},K.prototype.localPosFromDOM=function(t,e,n){if(this.contentDOM&&this.contentDOM.contains(1==t.nodeType?t:t.parentNode)){if(n<0){var r,o;if(t==this.contentDOM)r=t.childNodes[e-1];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;r=t.previousSibling}for(;r&&(!(o=r.pmViewDesc)||o.parent!=this);)r=r.previousSibling;return r?this.posBeforeChild(o)+o.size:this.posAtStart}var i,s;if(t==this.contentDOM)i=t.childNodes[e];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;i=t.nextSibling}for(;i&&(!(s=i.pmViewDesc)||s.parent!=this);)i=i.nextSibling;return i?this.posBeforeChild(s):this.posAtEnd}var a;if(t==this.dom&&this.contentDOM)a=e>f(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))a=2&t.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==e)for(var c=t;;c=c.parentNode){if(c==this.dom){a=!1;break}if(c.parentNode.firstChild!=c)break}if(null==a&&e==t.childNodes.length)for(var l=t;;l=l.parentNode){if(l==this.dom){a=!0;break}if(l.parentNode.lastChild!=l)break}}return(null==a?n>0:a)?this.posAtEnd:this.posAtStart},K.prototype.nearestDesc=function(t,e){for(var n=!0,r=t;r;r=r.parentNode){var o=this.getDesc(r);if(o&&(!e||o.node)){if(!n||!o.nodeDOM||(1==o.nodeDOM.nodeType?o.nodeDOM.contains(1==t.nodeType?t:t.parentNode):o.nodeDOM==t))return o;n=!1}}},K.prototype.getDesc=function(t){for(var e=t.pmViewDesc,n=e;n;n=n.parent)if(n==this)return e},K.prototype.posFromDOM=function(t,e,n){for(var r=t;r;r=r.parentNode){var o=this.getDesc(r);if(o)return o.localPosFromDOM(t,e,n)}return-1},K.prototype.descAt=function(t){for(var e=0,n=0;e<this.children.length;e++){var r=this.children[e],o=n+r.size;if(n==t&&o!=n){for(;!r.border&&r.children.length;)r=r.children[0];return r}if(t<o)return r.descAt(t-n-r.border);n=o}},K.prototype.domFromPos=function(t,e){if(!this.contentDOM)return{node:this.dom,offset:0};for(var n=0,r=0,o=0;n<this.children.length;n++){var i=this.children[n],s=o+i.size;if(s>t||i instanceof Z){r=t-o;break}o=s}if(r)return this.children[n].domFromPos(r-this.children[n].border,e);for(var a=void 0;n&&!(a=this.children[n-1]).size&&a instanceof J&&a.widget.type.side>=0;n--);if(e<=0){for(var c,l=!0;(c=n?this.children[n-1]:null)&&c.dom.parentNode!=this.contentDOM;n--,l=!1);return c&&e&&l&&!c.border&&!c.domAtom?c.domFromPos(c.size,e):{node:this.contentDOM,offset:c?f(c.dom)+1:0}}for(var u,p=!0;(u=n<this.children.length?this.children[n]:null)&&u.dom.parentNode!=this.contentDOM;n++,p=!1);return u&&p&&!u.border&&!u.domAtom?u.domFromPos(0,e):{node:this.contentDOM,offset:u?f(u.dom):this.contentDOM.childNodes.length}},K.prototype.parseRange=function(t,e,n){if(void 0===n&&(n=0),0==this.children.length)return{node:this.contentDOM,from:t,to:e,fromOffset:0,toOffset:this.contentDOM.childNodes.length};for(var r=-1,o=-1,i=n,s=0;;s++){var a=this.children[s],c=i+a.size;if(-1==r&&t<=c){var l=i+a.border;if(t>=l&&e<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(t,e,l);t=i;for(var u=s;u>0;u--){var p=this.children[u-1];if(p.size&&p.dom.parentNode==this.contentDOM&&!p.emptyChildAt(1)){r=f(p.dom)+1;break}t-=p.size}-1==r&&(r=0)}if(r>-1&&(c>e||s==this.children.length-1)){e=c;for(var d=s+1;d<this.children.length;d++){var h=this.children[d];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(-1)){o=f(h.dom);break}e+=h.size}-1==o&&(o=this.contentDOM.childNodes.length);break}i=c}return{node:this.contentDOM,from:t,to:e,fromOffset:r,toOffset:o}},K.prototype.emptyChildAt=function(t){if(this.border||!this.contentDOM||!this.children.length)return!1;var e=this.children[t<0?0:this.children.length-1];return 0==e.size||e.emptyChildAt(t)},K.prototype.domAfterPos=function(t){var e=this.domFromPos(t,0),n=e.node,r=e.offset;if(1!=n.nodeType||r==n.childNodes.length)throw new RangeError("No node after pos "+t);return n.childNodes[r]},K.prototype.setSelection=function(t,e,n,r){for(var o=Math.min(t,e),i=Math.max(t,e),a=0,c=0;a<this.children.length;a++){var l=this.children[a],u=c+l.size;if(o>c&&i<u)return l.setSelection(t-c-l.border,e-c-l.border,n,r);c=u}var p=this.domFromPos(t,t?-1:1),d=e==t?p:this.domFromPos(e,e?-1:1),h=n.getSelection(),m=!1;if((s.gecko||s.safari)&&t==e){var g=p.node,y=p.offset;if(3==g.nodeType){if((m=y&&"\n"==g.nodeValue[y-1])&&y==g.nodeValue.length)for(var w=g,b=void 0;w;w=w.parentNode){if(b=w.nextSibling){"BR"==b.nodeName&&(p=d={node:b.parentNode,offset:f(b)+1});break}var S=w.pmViewDesc;if(S&&S.node&&S.node.isBlock)break}}else{var k=g.childNodes[y-1];m=k&&("BR"==k.nodeName||"false"==k.contentEditable)}}if(s.gecko&&h.focusNode&&h.focusNode!=d.node&&1==h.focusNode.nodeType){var x=h.focusNode.childNodes[h.focusOffset];x&&"false"==x.contentEditable&&(r=!0)}if(r||m&&s.safari||!v(p.node,p.offset,h.anchorNode,h.anchorOffset)||!v(d.node,d.offset,h.focusNode,h.focusOffset)){var C=!1;if((h.extend||t==e)&&!m){h.collapse(p.node,p.offset);try{t!=e&&h.extend(d.node,d.offset),C=!0}catch(t){if(!(t instanceof DOMException))throw t}}if(!C){if(t>e){var M=p;p=d,d=M}var O=document.createRange();O.setEnd(d.node,d.offset),O.setStart(p.node,p.offset),h.removeAllRanges(),h.addRange(O)}}},K.prototype.ignoreMutation=function(t){return!this.contentDOM&&"selection"!=t.type},q.contentLost.get=function(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)},K.prototype.markDirty=function(t,e){for(var n=0,r=0;r<this.children.length;r++){var o=this.children[r],i=n+o.size;if(n==i?t<=i&&e>=n:t<i&&e>n){var s=n+o.border,a=i-o.border;if(t>=s&&e<=a)return this.dirty=t==n||e==i?2:1,void(t!=s||e!=a||!o.contentLost&&o.dom.parentNode==this.contentDOM?o.markDirty(t-s,e-s):o.dirty=3);o.dirty=o.dom!=o.contentDOM||o.dom.parentNode!=this.contentDOM||o.children.length?3:2}n=i}this.dirty=2},K.prototype.markParentsDirty=function(){for(var t=1,e=this.parent;e;e=e.parent,t++){var n=1==t?2:1;e.dirty<n&&(e.dirty=n)}},q.domAtom.get=function(){return!1},q.ignoreForCoords.get=function(){return!1},Object.defineProperties(K.prototype,q);var H=[],J=function(t){function e(e,n,r,o){var i,s=n.type.toDOM;if("function"==typeof s&&(s=s(r,(function(){return i?i.parent?i.parent.posBeforeChild(i):void 0:o}))),!n.type.spec.raw){if(1!=s.nodeType){var a=document.createElement("span");a.appendChild(s),s=a}s.contentEditable=!1,s.classList.add("ProseMirror-widget")}t.call(this,e,H,s,null),this.widget=n,i=this}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={domAtom:{configurable:!0}};return e.prototype.matchesWidget=function(t){return 0==this.dirty&&t.type.eq(this.widget.type)},e.prototype.parseRule=function(){return{ignore:!0}},e.prototype.stopEvent=function(t){var e=this.widget.spec.stopEvent;return!!e&&e(t)},e.prototype.ignoreMutation=function(t){return"selection"!=t.type||this.widget.spec.ignoreSelection},e.prototype.destroy=function(){this.widget.type.destroy(this.dom),t.prototype.destroy.call(this)},n.domAtom.get=function(){return!0},Object.defineProperties(e.prototype,n),e}(K),U=function(t){function e(e,n,r,o){t.call(this,e,H,n,null),this.textDOM=r,this.text=o}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={size:{configurable:!0}};return n.size.get=function(){return this.text.length},e.prototype.localPosFromDOM=function(t,e){return t!=this.textDOM?this.posAtStart+(e?this.size:0):this.posAtStart+e},e.prototype.domFromPos=function(t){return{node:this.textDOM,offset:t}},e.prototype.ignoreMutation=function(t){return"characterData"===t.type&&t.target.nodeValue==t.oldValue},Object.defineProperties(e.prototype,n),e}(K),G=function(t){function e(e,n,r,o){t.call(this,e,[],r,o),this.mark=n}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.create=function(t,n,r,i){var s=i.nodeViews[n.type.name],a=s&&s(n,i,r);return a&&a.dom||(a=o.DOMSerializer.renderSpec(document,n.type.spec.toDOM(n,r))),new e(t,n,a.dom,a.contentDOM||a.dom)},e.prototype.parseRule=function(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}},e.prototype.matchesMark=function(t){return 3!=this.dirty&&this.mark.eq(t)},e.prototype.markDirty=function(e,n){if(t.prototype.markDirty.call(this,e,n),0!=this.dirty){for(var r=this.parent;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=0}},e.prototype.slice=function(t,n,r){var o=e.create(this.parent,this.mark,!0,r),i=this.children,s=this.size;n<s&&(i=pt(i,n,s,r)),t>0&&(i=pt(i,0,t,r));for(var a=0;a<i.length;a++)i[a].parent=o;return o.children=i,o},e}(K),X=function(t){function e(e,n,r,o,i,s,a,c,l){t.call(this,e,n.isLeaf?H:[],i,s),this.nodeDOM=a,this.node=n,this.outerDeco=r,this.innerDeco=o,s&&this.updateChildren(c,l)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={size:{configurable:!0},border:{configurable:!0},domAtom:{configurable:!0}};return e.create=function(t,n,r,i,s,a){var c,l,u=s.nodeViews[n.type.name],p=u&&u(n,s,(function(){return l?l.parent?l.parent.posBeforeChild(l):void 0:a}),r,i),f=p&&p.dom,d=p&&p.contentDOM;if(n.isText)if(f){if(3!=f.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else f=document.createTextNode(n.text);else f||(f=(c=o.DOMSerializer.renderSpec(document,n.type.spec.toDOM(n))).dom,d=c.contentDOM);d||n.isText||"BR"==f.nodeName||(f.hasAttribute("contenteditable")||(f.contentEditable=!1),n.type.spec.draggable&&(f.draggable=!0));var h=f;return f=st(f,r,n),p?l=new tt(t,n,r,i,f,d,h,p,s,a+1):n.isText?new Q(t,n,r,i,f,h,s):new e(t,n,r,i,f,d,h,s,a+1)},e.prototype.parseRule=function(){var t=this;if(this.node.type.spec.reparseInView)return null;var 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(var n=this.children.length-1;n>=0;n--){var r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=function(){return o.Fragment.empty})}else e.contentElement=this.contentDOM;else e.getContent=function(){return t.node.content};return e},e.prototype.matchesNode=function(t,e,n){return 0==this.dirty&&t.eq(this.node)&&at(e,this.outerDeco)&&n.eq(this.innerDeco)},n.size.get=function(){return this.node.nodeSize},n.border.get=function(){return this.node.isLeaf?0:1},e.prototype.updateChildren=function(t,e){var n=this,r=this.node.inlineContent,i=e,a=t.composing&&this.localCompositionInfo(t,e),c=a&&a.pos>-1?a:null,l=a&&a.pos<0,u=new lt(this,c&&c.node);!function(t,e,n,r){var o=e.locals(t),i=0;if(0==o.length){for(var s=0;s<t.childCount;s++){var a=t.child(s);r(a,o,e.forChild(i,a),s),i+=a.nodeSize}return}for(var c=0,l=[],u=null,p=0;;){if(c<o.length&&o[c].to==i){for(var f=o[c++],d=void 0;c<o.length&&o[c].to==i;)(d||(d=[f])).push(o[c++]);if(d){d.sort(ut);for(var h=0;h<d.length;h++)n(d[h],p,!!u)}else n(f,p,!!u)}var m=void 0,v=void 0;if(u)v=-1,m=u,u=null;else{if(!(p<t.childCount))break;v=p,m=t.child(p++)}for(var g=0;g<l.length;g++)l[g].to<=i&&l.splice(g--,1);for(;c<o.length&&o[c].from<=i&&o[c].to>i;)l.push(o[c++]);var y=i+m.nodeSize;if(m.isText){var w=y;c<o.length&&o[c].from<w&&(w=o[c].from);for(var b=0;b<l.length;b++)l[b].to<w&&(w=l[b].to);w<y&&(u=m.cut(w-i),m=m.cut(0,w-i),y=w,v=-1)}var S=l.length?m.isInline&&!m.isLeaf?l.filter((function(t){return!t.inline})):l.slice():H;r(m,S,e.forChild(i,m),v),i=y}}(this.node,this.innerDeco,(function(e,s,a){e.spec.marks?u.syncToMarks(e.spec.marks,r,t):e.type.side>=0&&!a&&u.syncToMarks(s==n.node.childCount?o.Mark.none:n.node.child(s).marks,r,t),u.placeWidget(e,t,i)}),(function(e,n,o,s){var c;u.syncToMarks(e.marks,r,t),u.findNodeMatch(e,n,o,s)||l&&t.state.selection.from>i&&t.state.selection.to<i+e.nodeSize&&(c=u.findIndexWithChild(a.node))>-1&&u.updateNodeAt(e,n,o,c,t)||u.updateNextNode(e,n,o,t,s)||u.addNode(e,n,o,t,i),i+=e.nodeSize})),u.syncToMarks(H,r,t),this.node.isTextblock&&u.addTextblockHacks(),u.destroyRest(),(u.changed||2==this.dirty)&&(c&&this.protectLocalComposition(t,c),function t(e,n,r){for(var o=e.firstChild,i=!1,s=0;s<n.length;s++){var a=n[s],c=a.dom;if(c.parentNode==e){for(;c!=o;)o=ct(o),i=!0;o=o.nextSibling}else i=!0,e.insertBefore(c,o);if(a instanceof G){var l=o?o.previousSibling:e.lastChild;t(a.contentDOM,a.children,r),o=l?l.nextSibling:e.firstChild}}for(;o;)o=ct(o),i=!0;i&&r.trackWrites==e&&(r.trackWrites=null)}(this.contentDOM,this.children,t),s.ios&&function(t){if("UL"==t.nodeName||"OL"==t.nodeName){var e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}(this.dom))},e.prototype.localCompositionInfo=function(t,e){var n=t.state.selection,o=n.from,i=n.to;if(!(!(t.state.selection instanceof r.TextSelection)||o<e||i>e+this.node.content.size)){var s=t.root.getSelection(),a=function(t,e){for(;;){if(3==t.nodeType)return t;if(1==t.nodeType&&e>0){if(t.childNodes.length>e&&3==t.childNodes[e].nodeType)return t.childNodes[e];t=t.childNodes[e-1],e=w(t)}else{if(!(1==t.nodeType&&e<t.childNodes.length))return null;t=t.childNodes[e],e=0}}}(s.focusNode,s.focusOffset);if(a&&this.dom.contains(a.parentNode)){if(this.node.inlineContent){var c=a.nodeValue,l=function(t,e,n,r){for(var o=0,i=0;o<t.childCount&&i<=r;){var s=t.child(o++),a=i;if(i+=s.nodeSize,s.isText){for(var c=s.text;o<t.childCount;){var l=t.child(o++);if(i+=l.nodeSize,!l.isText)break;c+=l.text}if(i>=n){var u=a<r?c.lastIndexOf(e,r-a-1):-1;if(u>=0&&u+e.length+a>=n)return a+u;if(n==r&&c.length>=r+e.length-a&&c.slice(r-a,r-a+e.length)==e)return r}}}return-1}(this.node.content,c,o-e,i-e);return l<0?null:{node:a,pos:l,text:c}}return{node:a,pos:-1}}}},e.prototype.protectLocalComposition=function(t,e){var n=e.node,r=e.pos,o=e.text;if(!this.getDesc(n)){for(var i=n;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=null)}var s=new U(this,i,n,o);t.compositionNodes.push(s),this.children=pt(this.children,r,r+o.length,t,s)}},e.prototype.update=function(t,e,n,r){return!(3==this.dirty||!t.sameMarkup(this.node))&&(this.updateInner(t,e,n,r),!0)},e.prototype.updateInner=function(t,e,n,r){this.updateOuterDeco(e),this.node=t,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=0},e.prototype.updateOuterDeco=function(t){if(!at(t,this.outerDeco)){var e=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=ot(this.dom,this.nodeDOM,rt(this.outerDeco,this.node,e),rt(t,this.node,e)),this.dom!=n&&(n.pmViewDesc=null,this.dom.pmViewDesc=this),this.outerDeco=t}},e.prototype.selectNode=function(){this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.dom.draggable=!0)},e.prototype.deselectNode=function(){this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||this.dom.removeAttribute("draggable")},n.domAtom.get=function(){return this.node.isAtom},Object.defineProperties(e.prototype,n),e}(K);function Y(t,e,n,r,o){return st(r,e,t),new X(null,t,e,n,r,r,r,o,0)}var Q=function(t){function e(e,n,r,o,i,s,a){t.call(this,e,n,r,o,i,null,s,a)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={domAtom:{configurable:!0}};return e.prototype.parseRule=function(){for(var t=this.nodeDOM.parentNode;t&&t!=this.dom&&!t.pmIsDeco;)t=t.parentNode;return{skip:t||!0}},e.prototype.update=function(t,e,n,r){return!(3==this.dirty||0!=this.dirty&&!this.inParent()||!t.sameMarkup(this.node))&&(this.updateOuterDeco(e),0==this.dirty&&t.text==this.node.text||t.text==this.nodeDOM.nodeValue||(this.nodeDOM.nodeValue=t.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=t,this.dirty=0,!0)},e.prototype.inParent=function(){for(var t=this.parent.contentDOM,e=this.nodeDOM;e;e=e.parentNode)if(e==t)return!0;return!1},e.prototype.domFromPos=function(t){return{node:this.nodeDOM,offset:t}},e.prototype.localPosFromDOM=function(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):t.prototype.localPosFromDOM.call(this,e,n,r)},e.prototype.ignoreMutation=function(t){return"characterData"!=t.type&&"selection"!=t.type},e.prototype.slice=function(t,n,r){var o=this.node.cut(t,n),i=document.createTextNode(o.text);return new e(this.parent,o,this.outerDeco,this.innerDeco,i,i,r)},e.prototype.markDirty=function(e,n){t.prototype.markDirty.call(this,e,n),this.dom==this.nodeDOM||0!=e&&n!=this.nodeDOM.nodeValue.length||(this.dirty=3)},n.domAtom.get=function(){return!1},Object.defineProperties(e.prototype,n),e}(X),Z=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={domAtom:{configurable:!0},ignoreForCoords:{configurable:!0}};return e.prototype.parseRule=function(){return{ignore:!0}},e.prototype.matchesHack=function(t){return 0==this.dirty&&this.dom.nodeName==t},n.domAtom.get=function(){return!0},n.ignoreForCoords.get=function(){return"IMG"==this.dom.nodeName},Object.defineProperties(e.prototype,n),e}(K),tt=function(t){function e(e,n,r,o,i,s,a,c,l,u){t.call(this,e,n,r,o,i,s,a,l,u),this.spec=c}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.update=function(e,n,r,o){if(3==this.dirty)return!1;if(this.spec.update){var i=this.spec.update(e,n,r);return i&&this.updateInner(e,n,r,o),i}return!(!this.contentDOM&&!e.isLeaf)&&t.prototype.update.call(this,e,n,r,o)},e.prototype.selectNode=function(){this.spec.selectNode?this.spec.selectNode():t.prototype.selectNode.call(this)},e.prototype.deselectNode=function(){this.spec.deselectNode?this.spec.deselectNode():t.prototype.deselectNode.call(this)},e.prototype.setSelection=function(e,n,r,o){this.spec.setSelection?this.spec.setSelection(e,n,r):t.prototype.setSelection.call(this,e,n,r,o)},e.prototype.destroy=function(){this.spec.destroy&&this.spec.destroy(),t.prototype.destroy.call(this)},e.prototype.stopEvent=function(t){return!!this.spec.stopEvent&&this.spec.stopEvent(t)},e.prototype.ignoreMutation=function(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):t.prototype.ignoreMutation.call(this,e)},e}(X);function et(t){t&&(this.nodeName=t)}et.prototype=Object.create(null);var nt=[new et];function rt(t,e,n){if(0==t.length)return nt;for(var r=n?nt[0]:new et,o=[r],i=0;i<t.length;i++){var s=t[i].type.attrs;if(s)for(var a in s.nodeName&&o.push(r=new et(s.nodeName)),s){var c=s[a];null!=c&&(n&&1==o.length&&o.push(r=new et(e.isInline?"span":"div")),"class"==a?r.class=(r.class?r.class+" ":"")+c:"style"==a?r.style=(r.style?r.style+";":"")+c:"nodeName"!=a&&(r[a]=c))}}return o}function ot(t,e,n,r){if(n==nt&&r==nt)return e;for(var o=e,i=0;i<r.length;i++){var s=r[i],a=n[i];if(i){var c=void 0;a&&a.nodeName==s.nodeName&&o!=t&&(c=o.parentNode)&&c.tagName.toLowerCase()==s.nodeName||((c=document.createElement(s.nodeName)).pmIsDeco=!0,c.appendChild(o),a=nt[0]),o=c}it(o,a||nt[0],s)}return o}function it(t,e,n){for(var r in e)"class"==r||"style"==r||"nodeName"==r||r in n||t.removeAttribute(r);for(var o in n)"class"!=o&&"style"!=o&&"nodeName"!=o&&n[o]!=e[o]&&t.setAttribute(o,n[o]);if(e.class!=n.class){for(var i=e.class?e.class.split(" ").filter(Boolean):H,s=n.class?n.class.split(" ").filter(Boolean):H,a=0;a<i.length;a++)-1==s.indexOf(i[a])&&t.classList.remove(i[a]);for(var c=0;c<s.length;c++)-1==i.indexOf(s[c])&&t.classList.add(s[c]);0==t.classList.length&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style)for(var l,u=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;l=u.exec(e.style);)t.style.removeProperty(l[1]);n.style&&(t.style.cssText+=n.style)}}function st(t,e,n){return ot(t,t,nt,rt(e,n,1!=t.nodeType))}function at(t,e){if(t.length!=e.length)return!1;for(var n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return!1;return!0}function ct(t){var e=t.nextSibling;return t.parentNode.removeChild(t),e}var lt=function(t,e){this.top=t,this.lock=e,this.index=0,this.stack=[],this.changed=!1,this.preMatch=function(t,e){var n=e,r=n.children.length,o=t.childCount,i=new Map,s=[];t:for(;o>0;){for(var a=void 0;;)if(r){var c=n.children[r-1];if(!(c instanceof G)){a=c,r--;break}n=c,r=c.children.length}else{if(n==e)break t;r=n.parent.children.indexOf(n),n=n.parent}var l=a.node;if(l){if(l!=t.child(o-1))break;--o,i.set(a,o),s.push(a)}}return{index:o,matched:i,matches:s.reverse()}}(t.node.content,t)};function ut(t,e){return t.type.side-e.type.side}function pt(t,e,n,r,o){for(var i=[],s=0,a=0;s<t.length;s++){var c=t[s],l=a,u=a+=c.size;l>=n||u<=e?i.push(c):(l<e&&i.push(c.slice(0,e-l,r)),o&&(i.push(o),o=null),u>n&&i.push(c.slice(n-l,c.size,r)))}return i}function ft(t,e){var n=t.root.getSelection(),o=t.state.doc;if(!n.focusNode)return null;var i=t.docView.nearestDesc(n.focusNode),s=i&&0==i.size,a=t.docView.posFromDOM(n.focusNode,n.focusOffset);if(a<0)return null;var c,l,u=o.resolve(a);if(S(n)){for(c=u;i&&!i.node;)i=i.parent;if(i&&i.node.isAtom&&r.NodeSelection.isSelectable(i.node)&&i.parent&&(!i.node.isInline||!function(t,e,n){for(var r=0==e,o=e==w(t);r||o;){if(t==n)return!0;var i=f(t);if(!(t=t.parentNode))return!1;r=r&&0==i,o=o&&i==w(t)}}(n.focusNode,n.focusOffset,i.dom))){var p=i.posBefore;l=new r.NodeSelection(a==p?u:o.resolve(p))}}else{var d=t.docView.posFromDOM(n.anchorNode,n.anchorOffset);if(d<0)return null;c=o.resolve(d)}l||(l=St(t,c,u,"pointer"==e||t.state.selection.head<u.pos&&!s?1:-1));return l}function dt(t){return t.editable?t.hasFocus():kt(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function ht(t,e){var n=t.state.selection;if(wt(t,n),dt(t)){if(!e&&t.mouseDown&&t.mouseDown.allowDefault&&s.chrome){var o=t.root.getSelection(),i=t.domObserver.currentSelection;if(o.anchorNode&&v(o.anchorNode,o.anchorOffset,i.anchorNode,i.anchorOffset))return t.mouseDown.delayedSelectionSync=!0,void t.domObserver.setCurSelection()}if(t.domObserver.disconnectSelection(),t.cursorWrapper)!function(t){var e=t.root.getSelection(),n=document.createRange(),r=t.cursorWrapper.dom,o="IMG"==r.nodeName;o?n.setEnd(r.parentNode,f(r)+1):n.setEnd(r,0);n.collapse(!1),e.removeAllRanges(),e.addRange(n),!o&&!t.state.selection.visible&&s.ie&&s.ie_version<=11&&(r.disabled=!0,r.disabled=!1)}(t);else{var a,c,l=n.anchor,u=n.head;!mt||n instanceof r.TextSelection||(n.$from.parent.inlineContent||(a=vt(t,n.from)),n.empty||n.$from.parent.inlineContent||(c=vt(t,n.to))),t.docView.setSelection(l,u,t.root,e),mt&&(a&&yt(a),c&&yt(c)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(t){var e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.hideSelectionGuard);var n=t.root.getSelection(),r=n.anchorNode,o=n.anchorOffset;e.addEventListener("selectionchange",t.hideSelectionGuard=function(){n.anchorNode==r&&n.anchorOffset==o||(e.removeEventListener("selectionchange",t.hideSelectionGuard),setTimeout((function(){dt(t)&&!t.state.selection.visible||t.dom.classList.remove("ProseMirror-hideselection")}),20))})}(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}lt.prototype.destroyBetween=function(t,e){if(t!=e){for(var n=t;n<e;n++)this.top.children[n].destroy();this.top.children.splice(t,e-t),this.changed=!0}},lt.prototype.destroyRest=function(){this.destroyBetween(this.index,this.top.children.length)},lt.prototype.syncToMarks=function(t,e,n){for(var r=0,o=this.stack.length>>1,i=Math.min(o,t.length);r<i&&(r==o-1?this.top:this.stack[r+1<<1]).matchesMark(t[r])&&!1!==t[r].type.spec.spanning;)r++;for(;r<o;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<t.length;){this.stack.push(this.top,this.index+1);for(var s=-1,a=this.index;a<Math.min(this.index+3,this.top.children.length);a++)if(this.top.children[a].matchesMark(t[o])){s=a;break}if(s>-1)s>this.index&&(this.changed=!0,this.destroyBetween(this.index,s)),this.top=this.top.children[this.index];else{var c=G.create(this.top,t[o],e,n);this.top.children.splice(this.index,0,c),this.top=c,this.changed=!0}this.index=0,o++}},lt.prototype.findNodeMatch=function(t,e,n,r){var o,i=-1;if(r>=this.preMatch.index&&(o=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&o.matchesNode(t,e,n))i=this.top.children.indexOf(o,this.index);else for(var s=this.index,a=Math.min(this.top.children.length,s+5);s<a;s++){var c=this.top.children[s];if(c.matchesNode(t,e,n)&&!this.preMatch.matched.has(c)){i=s;break}}return!(i<0)&&(this.destroyBetween(this.index,i),this.index++,!0)},lt.prototype.updateNodeAt=function(t,e,n,r,o){return!!this.top.children[r].update(t,e,n,o)&&(this.destroyBetween(this.index,r),this.index=r+1,!0)},lt.prototype.findIndexWithChild=function(t){for(;;){var e=t.parentNode;if(!e)return-1;if(e==this.top.contentDOM){var n=t.pmViewDesc;if(n)for(var r=this.index;r<this.top.children.length;r++)if(this.top.children[r]==n)return r;return-1}t=e}},lt.prototype.updateNextNode=function(t,e,n,r,o){for(var i=this.index;i<this.top.children.length;i++){var s=this.top.children[i];if(s instanceof X){var a=this.preMatch.matched.get(s);if(null!=a&&a!=o)return!1;var c=s.dom;if(!(this.lock&&(c==this.lock||1==c.nodeType&&c.contains(this.lock.parentNode))&&!(t.isText&&s.node&&s.node.isText&&s.nodeDOM.nodeValue==t.text&&3!=s.dirty&&at(e,s.outerDeco)))&&s.update(t,e,n,r))return this.destroyBetween(this.index,i),s.dom!=c&&(this.changed=!0),this.index++,!0;break}}return!1},lt.prototype.addNode=function(t,e,n,r,o){this.top.children.splice(this.index++,0,X.create(this.top,t,e,n,r,o)),this.changed=!0},lt.prototype.placeWidget=function(t,e,n){var r=this.index<this.top.children.length?this.top.children[this.index]:null;if(!r||!r.matchesWidget(t)||t!=r.widget&&r.widget.type.toDOM.parentNode){var o=new J(this.top,t,e,n);this.top.children.splice(this.index++,0,o),this.changed=!0}else this.index++},lt.prototype.addTextblockHacks=function(){for(var t=this.top.children[this.index-1];t instanceof G;)t=t.children[t.children.length-1];t&&t instanceof Q&&!/\n$/.test(t.node.text)||((s.safari||s.chrome)&&t&&"false"==t.dom.contentEditable&&this.addHackNode("IMG"),this.addHackNode("BR"))},lt.prototype.addHackNode=function(t){if(this.index<this.top.children.length&&this.top.children[this.index].matchesHack(t))this.index++;else{var e=document.createElement(t);"IMG"==t&&(e.className="ProseMirror-separator",e.alt=""),"BR"==t&&(e.className="ProseMirror-trailingBreak"),this.top.children.splice(this.index++,0,new Z(this.top,H,e,null)),this.changed=!0}};var mt=s.safari||s.chrome&&s.chrome_version<63;function vt(t,e){var n=t.docView.domFromPos(e,0),r=n.node,o=n.offset,i=o<r.childNodes.length?r.childNodes[o]:null,a=o?r.childNodes[o-1]:null;if(s.safari&&i&&"false"==i.contentEditable)return gt(i);if(!(i&&"false"!=i.contentEditable||a&&"false"!=a.contentEditable)){if(i)return gt(i);if(a)return gt(a)}}function gt(t){return t.contentEditable="true",s.safari&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function yt(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function wt(t,e){if(e instanceof r.NodeSelection){var n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(bt(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else bt(t)}function bt(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=null)}function St(t,e,n,o){return t.someProp("createSelectionBetween",(function(r){return r(t,e,n)}))||r.TextSelection.between(e,n,o)}function kt(t){var e=t.root.getSelection();if(!e.anchorNode)return!1;try{return t.dom.contains(3==e.anchorNode.nodeType?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(3==e.focusNode.nodeType?e.focusNode.parentNode:e.focusNode))}catch(t){return!1}}function xt(t,e){var n=t.selection,o=n.$anchor,i=n.$head,s=e>0?o.max(i):o.min(i),a=s.parent.inlineContent?s.depth?t.doc.resolve(e>0?s.after():s.before()):null:s;return a&&r.Selection.findFrom(a,e)}function Ct(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function Mt(t,e,n){var o=t.state.selection;if(!(o instanceof r.TextSelection)){if(o instanceof r.NodeSelection&&o.node.isInline)return Ct(t,new r.TextSelection(e>0?o.$to:o.$from));var i=xt(t.state,e);return!!i&&Ct(t,i)}if(!o.empty||n.indexOf("s")>-1)return!1;if(t.endOfTextblock(e>0?"right":"left")){var a=xt(t.state,e);return!!(a&&a instanceof r.NodeSelection)&&Ct(t,a)}if(!(s.mac&&n.indexOf("m")>-1)){var c,l=o.$head,u=l.textOffset?null:e<0?l.nodeBefore:l.nodeAfter;if(!u||u.isText)return!1;var p=e<0?l.pos-u.nodeSize:l.pos;return!!(u.isAtom||(c=t.docView.descAt(p))&&!c.contentDOM)&&(r.NodeSelection.isSelectable(u)?Ct(t,new r.NodeSelection(e<0?t.state.doc.resolve(l.pos-u.nodeSize):l)):!!s.webkit&&Ct(t,new r.TextSelection(t.state.doc.resolve(e<0?p:p+u.nodeSize))))}}function Ot(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function Tt(t){var e=t.pmViewDesc;return e&&0==e.size&&(t.nextSibling||"BR"!=t.nodeName)}function Nt(t){var e=t.root.getSelection(),n=e.focusNode,r=e.focusOffset;if(n){var o,i,a=!1;for(s.gecko&&1==n.nodeType&&r<Ot(n)&&Tt(n.childNodes[r])&&(a=!0);;)if(r>0){if(1!=n.nodeType)break;var c=n.childNodes[r-1];if(Tt(c))o=n,i=--r;else{if(3!=c.nodeType)break;r=(n=c).nodeValue.length}}else{if(Dt(n))break;for(var l=n.previousSibling;l&&Tt(l);)o=n.parentNode,i=f(l),l=l.previousSibling;if(l)r=Ot(n=l);else{if((n=n.parentNode)==t.dom)break;r=0}}a?Et(t,e,n,r):o&&Et(t,e,o,i)}}function At(t){var e=t.root.getSelection(),n=e.focusNode,r=e.focusOffset;if(n){for(var o,i,s=Ot(n);;)if(r<s){if(1!=n.nodeType)break;if(!Tt(n.childNodes[r]))break;o=n,i=++r}else{if(Dt(n))break;for(var a=n.nextSibling;a&&Tt(a);)o=a.parentNode,i=f(a)+1,a=a.nextSibling;if(a)r=0,s=Ot(n=a);else{if((n=n.parentNode)==t.dom)break;r=s=0}}o&&Et(t,e,o,i)}}function Dt(t){var e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function Et(t,e,n,r){if(S(e)){var o=document.createRange();o.setEnd(n,r),o.setStart(n,r),e.removeAllRanges(),e.addRange(o)}else e.extend&&e.extend(n,r);t.domObserver.setCurSelection();var i=t.state;setTimeout((function(){t.state==i&&ht(t)}),50)}function Rt(t,e,n){var o=t.state.selection;if(o instanceof r.TextSelection&&!o.empty||n.indexOf("s")>-1)return!1;if(s.mac&&n.indexOf("m")>-1)return!1;var i=o.$from,a=o.$to;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){var c=xt(t.state,e);if(c&&c instanceof r.NodeSelection)return Ct(t,c)}if(!i.parent.inlineContent){var l=e<0?i:a,u=o instanceof r.AllSelection?r.Selection.near(l,e):r.Selection.findFrom(l,e);return!!u&&Ct(t,u)}return!1}function _t(t,e){if(!(t.state.selection instanceof r.TextSelection))return!0;var n=t.state.selection,o=n.$head,i=n.$anchor,s=n.empty;if(!o.sameParent(i))return!0;if(!s)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;var a=!o.textOffset&&(e<0?o.nodeBefore:o.nodeAfter);if(a&&!a.isText){var c=t.state.tr;return e<0?c.delete(o.pos-a.nodeSize,o.pos):c.delete(o.pos,o.pos+a.nodeSize),t.dispatch(c),!0}return!1}function It(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function zt(t,e){var n=e.keyCode,r=function(t){var e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}(e);return 8==n||s.mac&&72==n&&"c"==r?_t(t,-1)||Nt(t):46==n||s.mac&&68==n&&"c"==r?_t(t,1)||At(t):13==n||27==n||(37==n?Mt(t,-1,r)||Nt(t):39==n?Mt(t,1,r)||At(t):38==n?Rt(t,-1,r)||Nt(t):40==n?function(t){if(s.safari&&!(t.state.selection.$head.parentOffset>0)){var e=t.root.getSelection(),n=e.focusNode,r=e.focusOffset;if(n&&1==n.nodeType&&0==r&&n.firstChild&&"false"==n.firstChild.contentEditable){var o=n.firstChild;It(t,o,!0),setTimeout((function(){return It(t,o,!1)}),20)}}}(t)||Rt(t,1,r)||At(t):r==(s.mac?"m":"c")&&(66==n||73==n||89==n||90==n))}function Pt(t){var e=t.pmViewDesc;if(e)return e.parseRule();if("BR"==t.nodeName&&t.parentNode){if(s.safari&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){var n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}if(t.parentNode.lastChild==t||s.safari&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if("IMG"==t.nodeName&&t.getAttribute("mark-placeholder"))return{ignore:!0}}function $t(t,e,n,i,a){if(e<0){var c=t.lastSelectionTime>Date.now()-50?t.lastSelectionOrigin:null,l=ft(t,c);if(l&&!t.state.selection.eq(l)){var u=t.state.tr.setSelection(l);"pointer"==c?u.setMeta("pointer",!0):"key"==c&&u.scrollIntoView(),t.dispatch(u)}}else{var p=t.state.doc.resolve(e),f=p.sharedDepth(n);e=p.before(f+1),n=t.state.doc.resolve(n).after(f+1);var d=t.state.selection,h=function(t,e,n){var r=t.docView.parseRange(e,n),i=r.node,a=r.fromOffset,c=r.toOffset,l=r.from,u=r.to,p=t.root.getSelection(),f=null,d=p.anchorNode;if(d&&t.dom.contains(1==d.nodeType?d:d.parentNode)&&(f=[{node:d,offset:p.anchorOffset}],S(p)||f.push({node:p.focusNode,offset:p.focusOffset})),s.chrome&&8===t.lastKeyCode)for(var h=c;h>a;h--){var m=i.childNodes[h-1],v=m.pmViewDesc;if("BR"==m.nodeName&&!v){c=h;break}if(!v||v.size)break}var g=t.state.doc,y=t.someProp("domParser")||o.DOMParser.fromSchema(t.state.schema),w=g.resolve(l),b=null,k=y.parse(i,{topNode:w.parent,topMatch:w.parent.contentMatchAt(w.index()),topOpen:!0,from:a,to:c,preserveWhitespace:"pre"!=w.parent.type.whitespace||"full",editableContent:!0,findPositions:f,ruleFromNode:Pt,context:w});if(f&&null!=f[0].pos){var x=f[0].pos,C=f[1]&&f[1].pos;null==C&&(C=x),b={anchor:x+l,head:C+l}}return{doc:k,sel:b,from:l,to:u}}(t,e,n);if(s.chrome&&t.cursorWrapper&&h.sel&&h.sel.anchor==t.cursorWrapper.deco.from){var m=t.cursorWrapper.deco.type.toDOM.nextSibling,v=m&&m.nodeValue?m.nodeValue.length:1;h.sel={anchor:h.sel.anchor+v,head:h.sel.anchor+v}}var g,y,w=t.state.doc,b=w.slice(h.from,h.to);8===t.lastKeyCode&&Date.now()-100<t.lastKeyCodeTime?(g=t.state.selection.to,y="end"):(g=t.state.selection.from,y="start"),t.lastKeyCode=null;var x=function(t,e,n,r,o){var i=t.findDiffStart(e,n);if(null==i)return null;var s=t.findDiffEnd(e,n+t.size,n+e.size),a=s.a,c=s.b;if("end"==o){var l=Math.max(0,i-Math.min(a,c));r-=a+l-i}if(a<i&&t.size<e.size){c=(i-=r<=i&&r>=a?i-r:0)+(c-a),a=i}else if(c<i){a=(i-=r<=i&&r>=c?i-r:0)+(a-c),c=i}return{start:i,endA:a,endB:c}}(b.content,h.doc.content,h.from,g,y);if(!x){if(!(i&&d instanceof r.TextSelection&&!d.empty&&d.$head.sameParent(d.$anchor))||t.composing||h.sel&&h.sel.anchor!=h.sel.head){if((s.ios&&t.lastIOSEnter>Date.now()-225||s.android)&&a.some((function(t){return"DIV"==t.nodeName||"P"==t.nodeName}))&&t.someProp("handleKeyDown",(function(e){return e(t,k(13,"Enter"))})))return void(t.lastIOSEnter=0);if(h.sel){var C=Ft(t,t.state.doc,h.sel);C&&!C.eq(t.state.selection)&&t.dispatch(t.state.tr.setSelection(C))}return}x={start:d.from,endA:d.to,endB:d.to}}t.domChangeCount++,t.state.selection.from<t.state.selection.to&&x.start==x.endB&&t.state.selection instanceof r.TextSelection&&(x.start>t.state.selection.from&&x.start<=t.state.selection.from+2&&t.state.selection.from>=h.from?x.start=t.state.selection.from:x.endA<t.state.selection.to&&x.endA>=t.state.selection.to-2&&t.state.selection.to<=h.to&&(x.endB+=t.state.selection.to-x.endA,x.endA=t.state.selection.to)),s.ie&&s.ie_version<=11&&x.endB==x.start+1&&x.endA==x.start&&x.start>h.from&&" "==h.doc.textBetween(x.start-h.from-1,x.start-h.from+1)&&(x.start--,x.endA--,x.endB--);var M,O=h.doc.resolveNoCache(x.start-h.from),T=h.doc.resolveNoCache(x.endB-h.from),N=O.sameParent(T)&&O.parent.inlineContent;if((s.ios&&t.lastIOSEnter>Date.now()-225&&(!N||a.some((function(t){return"DIV"==t.nodeName||"P"==t.nodeName})))||!N&&O.pos<h.doc.content.size&&(M=r.Selection.findFrom(h.doc.resolve(O.pos+1),1,!0))&&M.head==T.pos)&&t.someProp("handleKeyDown",(function(e){return e(t,k(13,"Enter"))})))t.lastIOSEnter=0;else if(t.state.selection.anchor>x.start&&function(t,e,n,r,o){if(!r.parent.isTextblock||n-e<=o.pos-r.pos||Bt(r,!0,!1)<o.pos)return!1;var i=t.resolve(e);if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;var s=t.resolve(Bt(i,!0,!0));if(!s.parent.isTextblock||s.pos>n||Bt(s,!0,!1)<n)return!1;return r.parent.content.cut(r.parentOffset).eq(s.parent.content)}(w,x.start,x.endA,O,T)&&t.someProp("handleKeyDown",(function(e){return e(t,k(8,"Backspace"))})))s.android&&s.chrome&&t.domObserver.suppressSelectionUpdates();else{s.chrome&&s.android&&x.toB==x.from&&(t.lastAndroidDelete=Date.now()),s.android&&!N&&O.start()!=T.start()&&0==T.parentOffset&&O.depth==T.depth&&h.sel&&h.sel.anchor==h.sel.head&&h.sel.head==x.endA&&(x.endB-=2,T=h.doc.resolveNoCache(x.endB-h.from),setTimeout((function(){t.someProp("handleKeyDown",(function(e){return e(t,k(13,"Enter"))}))}),20));var A,D,E,R,_=x.start,I=x.endA;if(N)if(O.pos==T.pos)s.ie&&s.ie_version<=11&&0==O.parentOffset&&(t.domObserver.suppressSelectionUpdates(),setTimeout((function(){return ht(t)}),20)),A=t.state.tr.delete(_,I),D=w.resolve(x.start).marksAcross(w.resolve(x.endA));else if(x.endA==x.endB&&(R=w.resolve(x.start))&&(E=function(t,e){for(var n,r,i,s=t.firstChild.marks,a=e.firstChild.marks,c=s,l=a,u=0;u<a.length;u++)c=a[u].removeFromSet(c);for(var p=0;p<s.length;p++)l=s[p].removeFromSet(l);if(1==c.length&&0==l.length)r=c[0],n="add",i=function(t){return t.mark(r.addToSet(t.marks))};else{if(0!=c.length||1!=l.length)return null;r=l[0],n="remove",i=function(t){return t.mark(r.removeFromSet(t.marks))}}for(var f=[],d=0;d<e.childCount;d++)f.push(i(e.child(d)));if(o.Fragment.from(f).eq(t))return{mark:r,type:n}}(O.parent.content.cut(O.parentOffset,T.parentOffset),R.parent.content.cut(R.parentOffset,x.endA-R.start()))))A=t.state.tr,"add"==E.type?A.addMark(_,I,E.mark):A.removeMark(_,I,E.mark);else if(O.parent.child(O.index()).isText&&O.index()==T.index()-(T.textOffset?0:1)){var z=O.parent.textBetween(O.parentOffset,T.parentOffset);if(t.someProp("handleTextInput",(function(e){return e(t,_,I,z)})))return;A=t.state.tr.insertText(z,_,I)}if(A||(A=t.state.tr.replace(_,I,h.doc.slice(x.start-h.from,x.endB-h.from))),h.sel){var P=Ft(t,A.doc,h.sel);P&&!(s.chrome&&s.android&&t.composing&&P.empty&&(x.start!=x.endB||t.lastAndroidDelete<Date.now()-100)&&(P.head==_||P.head==A.mapping.map(I)-1)||s.ie&&P.empty&&P.head==_)&&A.setSelection(P)}D&&A.ensureMarks(D),t.dispatch(A.scrollIntoView())}}}function Ft(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:St(t,e.resolve(n.anchor),e.resolve(n.head))}function Bt(t,e,n){for(var r=t.depth,o=e?t.end():t.pos;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,o++,e=!1;if(n)for(var i=t.node(r).maybeChild(t.indexAfter(r));i&&!i.isLeaf;)i=i.firstChild,o++;return o}function Lt(t,e){for(var n=[],r=e.content,i=e.openStart,s=e.openEnd;i>1&&s>1&&1==r.childCount&&1==r.firstChild.childCount;){i--,s--;var a=r.firstChild;n.push(a.type.name,a.attrs!=a.type.defaultAttrs?a.attrs:null),r=a.content}var c=t.someProp("clipboardSerializer")||o.DOMSerializer.fromSchema(t.state.schema),l=Ut(),u=l.createElement("div");u.appendChild(c.serializeFragment(r,{document:l}));for(var p,f=u.firstChild;f&&1==f.nodeType&&(p=Ht[f.nodeName.toLowerCase()]);){for(var d=p.length-1;d>=0;d--){for(var h=l.createElement(p[d]);u.firstChild;)h.appendChild(u.firstChild);u.appendChild(h),"tbody"!=p[d]&&(i++,s++)}f=u.firstChild}return f&&1==f.nodeType&&f.setAttribute("data-pm-slice",i+" "+s+" "+JSON.stringify(n)),{dom:u,text:t.someProp("clipboardTextSerializer",(function(t){return t(e)}))||e.content.textBetween(0,e.content.size,"\n\n")}}function Vt(t,e,n,r,i){var a,c,l=i.parent.type.spec.code;if(!n&&!e)return null;var u=e&&(r||l||!n);if(u){if(t.someProp("transformPastedText",(function(t){e=t(e,l||r)})),l)return e?new o.Slice(o.Fragment.from(t.state.schema.text(e.replace(/\r\n?/g,"\n"))),0,0):o.Slice.empty;var p=t.someProp("clipboardTextParser",(function(t){return t(e,i,r)}));if(p)c=p;else{var f=i.marks(),d=t.state.schema,h=o.DOMSerializer.fromSchema(d);a=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach((function(t){var e=a.appendChild(document.createElement("p"));t&&e.appendChild(h.serializeNode(d.text(t,f)))}))}}else t.someProp("transformPastedHTML",(function(t){n=t(n)})),a=function(t){var e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));var n,r=Ut().createElement("div"),o=/<([a-z][^>\s]+)/i.exec(t);(n=o&&Ht[o[1].toLowerCase()])&&(t=n.map((function(t){return"<"+t+">"})).join("")+t+n.map((function(t){return"</"+t+">"})).reverse().join(""));if(r.innerHTML=t,n)for(var i=0;i<n.length;i++)r=r.querySelector(n[i])||r;return r}(n),s.webkit&&function(t){for(var e=t.querySelectorAll(s.chrome?"span:not([class]):not([style])":"span.Apple-converted-space"),n=0;n<e.length;n++){var r=e[n];1==r.childNodes.length&&" "==r.textContent&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}(a);var m=a&&a.querySelector("[data-pm-slice]"),v=m&&/^(\d+) (\d+) (.*)/.exec(m.getAttribute("data-pm-slice"));if(!c){var g=t.someProp("clipboardParser")||t.someProp("domParser")||o.DOMParser.fromSchema(t.state.schema);c=g.parseSlice(a,{preserveWhitespace:!(!u&&!v),context:i,ruleFromNode:function(t){if("BR"==t.nodeName&&!t.nextSibling&&t.parentNode&&!jt.test(t.parentNode.nodeName))return{ignore:!0}}})}if(v)c=function(t,e){if(!t.size)return t;var n,r=t.content.firstChild.type.schema;try{n=JSON.parse(e)}catch(e){return t}for(var i=t.content,s=t.openStart,a=t.openEnd,c=n.length-2;c>=0;c-=2){var l=r.nodes[n[c]];if(!l||l.hasRequiredAttrs())break;i=o.Fragment.from(l.create(n[c+1],i)),s++,a++}return new o.Slice(i,s,a)}(qt(c,+v[1],+v[2]),v[3]);else if((c=o.Slice.maxOpen(function(t,e){if(t.childCount<2)return t;for(var n=function(n){var r=e.node(n).contentMatchAt(e.index(n)),i=void 0,s=[];if(t.forEach((function(t){if(s){var e,n=r.findWrapping(t.type);if(!n)return s=null;if(e=s.length&&i.length&&function t(e,n,r,i,s){if(s<e.length&&s<n.length&&e[s]==n[s]){var a=t(e,n,r,i.lastChild,s+1);if(a)return i.copy(i.content.replaceChild(i.childCount-1,a));if(i.contentMatchAt(i.childCount).matchType(s==e.length-1?r.type:e[s+1]))return i.copy(i.content.append(o.Fragment.from(Wt(r,e,s+1))))}}(n,i,t,s[s.length-1],0))s[s.length-1]=e;else{s.length&&(s[s.length-1]=function t(e,n){if(0==n)return e;var r=e.content.replaceChild(e.childCount-1,t(e.lastChild,n-1)),i=e.contentMatchAt(e.childCount).fillBefore(o.Fragment.empty,!0);return e.copy(r.append(i))}(s[s.length-1],i.length));var a=Wt(t,n);s.push(a),r=r.matchType(a.type,a.attrs),i=n}}})),s)return{v:o.Fragment.from(s)}},r=e.depth;r>=0;r--){var i=n(r);if(i)return i.v}return t}(c.content,i),!0)).openStart||c.openEnd){for(var y=0,w=0,b=c.content.firstChild;y<c.openStart&&!b.type.spec.isolating;y++,b=b.firstChild);for(var S=c.content.lastChild;w<c.openEnd&&!S.type.spec.isolating;w++,S=S.lastChild);c=qt(c,y,w)}return t.someProp("transformPasted",(function(t){c=t(c)})),c}var jt=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function Wt(t,e,n){void 0===n&&(n=0);for(var r=e.length-1;r>=n;r--)t=e[r].create(null,o.Fragment.from(t));return t}function Kt(t,e,n,r,i,s){var a=e<0?t.firstChild:t.lastChild,c=a.content;return i<r-1&&(c=Kt(c,e,n,r,i+1,s)),i>=n&&(c=e<0?a.contentMatchAt(0).fillBefore(c,t.childCount>1||s<=i).append(c):c.append(a.contentMatchAt(a.childCount).fillBefore(o.Fragment.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,a.copy(c))}function qt(t,e,n){return e<t.openStart&&(t=new o.Slice(Kt(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new o.Slice(Kt(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}var Ht={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]},Jt=null;function Ut(){return Jt||(Jt=document.implementation.createHTMLDocument("title"))}var Gt={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Xt=s.ie&&s.ie_version<=11,Yt=function(){this.anchorNode=this.anchorOffset=this.focusNode=this.focusOffset=null};Yt.prototype.set=function(t){this.anchorNode=t.anchorNode,this.anchorOffset=t.anchorOffset,this.focusNode=t.focusNode,this.focusOffset=t.focusOffset},Yt.prototype.eq=function(t){return t.anchorNode==this.anchorNode&&t.anchorOffset==this.anchorOffset&&t.focusNode==this.focusNode&&t.focusOffset==this.focusOffset};var Qt=function(t,e){var n=this;this.view=t,this.handleDOMChange=e,this.queue=[],this.flushingSoon=-1,this.observer=window.MutationObserver&&new window.MutationObserver((function(t){for(var e=0;e<t.length;e++)n.queue.push(t[e]);s.ie&&s.ie_version<=11&&t.some((function(t){return"childList"==t.type&&t.removedNodes.length||"characterData"==t.type&&t.oldValue.length>t.target.nodeValue.length}))?n.flushSoon():n.flush()})),this.currentSelection=new Yt,Xt&&(this.onCharData=function(t){n.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),n.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.suppressingSelectionUpdates=!1};Qt.prototype.flushSoon=function(){var t=this;this.flushingSoon<0&&(this.flushingSoon=window.setTimeout((function(){t.flushingSoon=-1,t.flush()}),20))},Qt.prototype.forceFlush=function(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())},Qt.prototype.start=function(){this.observer&&this.observer.observe(this.view.dom,Gt),Xt&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()},Qt.prototype.stop=function(){var t=this;if(this.observer){var e=this.observer.takeRecords();if(e.length){for(var n=0;n<e.length;n++)this.queue.push(e[n]);window.setTimeout((function(){return t.flush()}),20)}this.observer.disconnect()}Xt&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()},Qt.prototype.connectSelection=function(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)},Qt.prototype.disconnectSelection=function(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)},Qt.prototype.suppressSelectionUpdates=function(){var t=this;this.suppressingSelectionUpdates=!0,setTimeout((function(){return t.suppressingSelectionUpdates=!1}),50)},Qt.prototype.onSelectionChange=function(){if((!(t=this.view).editable||t.root.activeElement==t.dom)&&kt(t)){var t;if(this.suppressingSelectionUpdates)return ht(this.view);if(s.ie&&s.ie_version<=11&&!this.view.state.selection.empty){var e=this.view.root.getSelection();if(e.focusNode&&v(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}},Qt.prototype.setCurSelection=function(){this.currentSelection.set(this.view.root.getSelection())},Qt.prototype.ignoreSelectionChange=function(t){if(0==t.rangeCount)return!0;var e=t.getRangeAt(0).commonAncestorContainer,n=this.view.docView.nearestDesc(e);return n&&n.ignoreMutation({type:"selection",target:3==e.nodeType?e.parentNode:e})?(this.setCurSelection(),!0):void 0},Qt.prototype.flush=function(){if(this.view.docView&&!(this.flushingSoon>-1)){var t=this.observer?this.observer.takeRecords():[];this.queue.length&&(t=this.queue.concat(t),this.queue.length=0);var e=this.view.root.getSelection(),n=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(e)&&kt(this.view)&&!this.ignoreSelectionChange(e),r=-1,o=-1,i=!1,a=[];if(this.view.editable)for(var c=0;c<t.length;c++){var l=this.registerMutation(t[c],a);l&&(r=r<0?l.from:Math.min(l.from,r),o=o<0?l.to:Math.max(l.to,o),l.typeOver&&(i=!0))}if(s.gecko&&a.length>1){var u=a.filter((function(t){return"BR"==t.nodeName}));if(2==u.length){var p=u[0],f=u[1];p.parentNode&&p.parentNode.parentNode==f.parentNode?f.remove():p.remove()}}(r>-1||n)&&(r>-1&&(this.view.docView.markDirty(r,o),function(t){if(Zt)return;Zt=!0,"normal"==getComputedStyle(t.dom).whiteSpace&&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.")}(this.view)),this.handleDOMChange(r,o,i,a),this.view.docView&&this.view.docView.dirty?this.view.updateState(this.view.state):this.currentSelection.eq(e)||ht(this.view),this.currentSelection.set(e))}},Qt.prototype.registerMutation=function(t,e){if(e.indexOf(t.target)>-1)return null;var n=this.view.docView.nearestDesc(t.target);if("attributes"==t.type&&(n==this.view.docView||"contenteditable"==t.attributeName||"style"==t.attributeName&&!t.oldValue&&!t.target.getAttribute("style")))return null;if(!n||n.ignoreMutation(t))return null;if("childList"==t.type){for(var r=0;r<t.addedNodes.length;r++)e.push(t.addedNodes[r]);if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(t.target))return{from:n.posBefore,to:n.posAfter};var o=t.previousSibling,i=t.nextSibling;if(s.ie&&s.ie_version<=11&&t.addedNodes.length)for(var a=0;a<t.addedNodes.length;a++){var c=t.addedNodes[a],l=c.previousSibling,u=c.nextSibling;(!l||Array.prototype.indexOf.call(t.addedNodes,l)<0)&&(o=l),(!u||Array.prototype.indexOf.call(t.addedNodes,u)<0)&&(i=u)}var p=o&&o.parentNode==t.target?f(o)+1:0,d=n.localPosFromDOM(t.target,p,-1),h=i&&i.parentNode==t.target?f(i):t.target.childNodes.length;return{from:d,to:n.localPosFromDOM(t.target,h,1)}}return"attributes"==t.type?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:{from:n.posAtStart,to:n.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}};var Zt=!1;var te={},ee={};function ne(t,e){t.lastSelectionOrigin=e,t.lastSelectionTime=Date.now()}function re(t){t.someProp("handleDOMEvents",(function(e){for(var n in e)t.eventHandlers[n]||t.dom.addEventListener(n,t.eventHandlers[n]=function(e){return oe(t,e)})}))}function oe(t,e){return t.someProp("handleDOMEvents",(function(n){var r=n[e.type];return!!r&&(r(t,e)||e.defaultPrevented)}))}function ie(t){return{left:t.clientX,top:t.clientY}}function se(t,e,n,r,o){if(-1==r)return!1;for(var i=t.state.doc.resolve(r),s=function(r){if(t.someProp(e,(function(e){return r>i.depth?e(t,n,i.nodeAfter,i.before(r),o,!0):e(t,n,i.node(r),i.before(r),o,!1)})))return{v:!0}},a=i.depth+1;a>0;a--){var c=s(a);if(c)return c.v}return!1}function ae(t,e,n){t.focused||t.focus();var r=t.state.tr.setSelection(e);"pointer"==n&&r.setMeta("pointer",!0),t.dispatch(r)}function ce(t,e,n,o,i){return se(t,"handleClickOn",e,n,o)||t.someProp("handleClick",(function(n){return n(t,e,o)}))||(i?function(t,e){if(-1==e)return!1;var n,o,i=t.state.selection;i instanceof r.NodeSelection&&(n=i.node);for(var s=t.state.doc.resolve(e),a=s.depth+1;a>0;a--){var c=a>s.depth?s.nodeAfter:s.node(a);if(r.NodeSelection.isSelectable(c)){o=n&&i.$from.depth>0&&a>=i.$from.depth&&s.before(i.$from.depth+1)==i.$from.pos?s.before(i.$from.depth):s.before(a);break}}return null!=o&&(ae(t,r.NodeSelection.create(t.state.doc,o),"pointer"),!0)}(t,n):function(t,e){if(-1==e)return!1;var n=t.state.doc.resolve(e),o=n.nodeAfter;return!!(o&&o.isAtom&&r.NodeSelection.isSelectable(o))&&(ae(t,new r.NodeSelection(n),"pointer"),!0)}(t,n))}function le(t,e,n,r){return se(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",(function(n){return n(t,e,r)}))}function ue(t,e,n,o){return se(t,"handleTripleClickOn",e,n,o)||t.someProp("handleTripleClick",(function(n){return n(t,e,o)}))||function(t,e,n){if(0!=n.button)return!1;var o=t.state.doc;if(-1==e)return!!o.inlineContent&&(ae(t,r.TextSelection.create(o,0,o.content.size),"pointer"),!0);for(var i=o.resolve(e),s=i.depth+1;s>0;s--){var a=s>i.depth?i.nodeAfter:i.node(s),c=i.before(s);if(a.inlineContent)ae(t,r.TextSelection.create(o,c+1,c+1+a.content.size),"pointer");else{if(!r.NodeSelection.isSelectable(a))continue;ae(t,r.NodeSelection.create(o,c),"pointer")}return!0}}(t,n,o)}function pe(t){return ye(t)}ee.keydown=function(t,e){if(t.shiftKey=16==e.keyCode||e.shiftKey,!he(t,e)&&(t.lastKeyCode=e.keyCode,t.lastKeyCodeTime=Date.now(),!s.android||!s.chrome||13!=e.keyCode))if(229!=e.keyCode&&t.domObserver.forceFlush(),!s.ios||13!=e.keyCode||e.ctrlKey||e.altKey||e.metaKey)t.someProp("handleKeyDown",(function(n){return n(t,e)}))||zt(t,e)?e.preventDefault():ne(t,"key");else{var n=Date.now();t.lastIOSEnter=n,t.lastIOSEnterFallbackTimeout=setTimeout((function(){t.lastIOSEnter==n&&(t.someProp("handleKeyDown",(function(e){return e(t,k(13,"Enter"))})),t.lastIOSEnter=0)}),200)}},ee.keyup=function(t,e){16==e.keyCode&&(t.shiftKey=!1)},ee.keypress=function(t,e){if(!(he(t,e)||!e.charCode||e.ctrlKey&&!e.altKey||s.mac&&e.metaKey))if(t.someProp("handleKeyPress",(function(n){return n(t,e)})))e.preventDefault();else{var n=t.state.selection;if(!(n instanceof r.TextSelection&&n.$from.sameParent(n.$to))){var o=String.fromCharCode(e.charCode);t.someProp("handleTextInput",(function(e){return e(t,n.$from.pos,n.$to.pos,o)}))||t.dispatch(t.state.tr.insertText(o).scrollIntoView()),e.preventDefault()}}};var fe=s.mac?"metaKey":"ctrlKey";te.mousedown=function(t,e){t.shiftKey=e.shiftKey;var n=pe(t),r=Date.now(),o="singleClick";r-t.lastClick.time<500&&function(t,e){var n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}(e,t.lastClick)&&!e[fe]&&("singleClick"==t.lastClick.type?o="doubleClick":"doubleClick"==t.lastClick.type&&(o="tripleClick")),t.lastClick={time:r,x:e.clientX,y:e.clientY,type:o};var i=t.posAtCoords(ie(e));i&&("singleClick"==o?(t.mouseDown&&t.mouseDown.done(),t.mouseDown=new de(t,i,e,n)):("doubleClick"==o?le:ue)(t,i.pos,i.inside,e)?e.preventDefault():ne(t,"pointer"))};var de=function(t,e,n,o){var i,a,c=this;if(this.view=t,this.startDoc=t.state.doc,this.pos=e,this.event=n,this.flushed=o,this.selectNode=n[fe],this.allowDefault=n.shiftKey,this.delayedSelectionSync=!1,e.inside>-1)i=t.state.doc.nodeAt(e.inside),a=e.inside;else{var l=t.state.doc.resolve(e.pos);i=l.parent,a=l.depth?l.before():0}this.mightDrag=null;var u=o?null:n.target,p=u?t.docView.nearestDesc(u,!0):null;this.target=p?p.dom:null;var f=t.state.selection;(0==n.button&&i.type.spec.draggable&&!1!==i.type.spec.selectable||f instanceof r.NodeSelection&&f.from<=a&&f.to>a)&&(this.mightDrag={node:i,pos:a,addAttr:this.target&&!this.target.draggable,setUneditable:this.target&&s.gecko&&!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((function(){c.view.mouseDown==c&&c.target.setAttribute("contentEditable","false")}),20),this.view.domObserver.start()),t.root.addEventListener("mouseup",this.up=this.up.bind(this)),t.root.addEventListener("mousemove",this.move=this.move.bind(this)),ne(t,"pointer")};function he(t,e){return!!t.composing||!!(s.safari&&Math.abs(e.timeStamp-t.compositionEndedAt)<500)&&(t.compositionEndedAt=-2e8,!0)}de.prototype.done=function(){var t=this;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((function(){return ht(t.view)})),this.view.mouseDown=null},de.prototype.up=function(t){if(this.done(),this.view.dom.contains(3==t.target.nodeType?t.target.parentNode:t.target)){var e=this.pos;this.view.state.doc!=this.startDoc&&(e=this.view.posAtCoords(ie(t))),this.allowDefault||!e?ne(this.view,"pointer"):ce(this.view,e.pos,e.inside,t,this.selectNode)?t.preventDefault():0==t.button&&(this.flushed||s.safari&&this.mightDrag&&!this.mightDrag.node.isAtom||s.chrome&&!(this.view.state.selection instanceof r.TextSelection)&&Math.min(Math.abs(e.pos-this.view.state.selection.from),Math.abs(e.pos-this.view.state.selection.to))<=2)?(ae(this.view,r.Selection.near(this.view.state.doc.resolve(e.pos)),"pointer"),t.preventDefault()):ne(this.view,"pointer")}},de.prototype.move=function(t){!this.allowDefault&&(Math.abs(this.event.x-t.clientX)>4||Math.abs(this.event.y-t.clientY)>4)&&(this.allowDefault=!0),ne(this.view,"pointer"),0==t.buttons&&this.done()},te.touchdown=function(t){pe(t),ne(t,"pointer")},te.contextmenu=function(t){return pe(t)};var me=s.android?5e3:-1;function ve(t,e){clearTimeout(t.composingTimeout),e>-1&&(t.composingTimeout=setTimeout((function(){return ye(t)}),e))}function ge(t){var e;for(t.composing&&(t.composing=!1,t.compositionEndedAt=((e=document.createEvent("Event")).initEvent("event",!0,!0),e.timeStamp));t.compositionNodes.length>0;)t.compositionNodes.pop().markParentsDirty()}function ye(t,e){if(!(s.android&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),ge(t),e||t.docView&&t.docView.dirty){var n=ft(t);return n&&!n.eq(t.state.selection)?t.dispatch(t.state.tr.setSelection(n)):t.updateState(t.state),!0}return!1}}ee.compositionstart=ee.compositionupdate=function(t){if(!t.composing){t.domObserver.flush();var e=t.state,n=e.selection.$from;if(e.selection.empty&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some((function(t){return!1===t.type.spec.inclusive}))))t.markCursor=t.state.storedMarks||n.marks(),ye(t,!0),t.markCursor=null;else if(ye(t),s.gecko&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length)for(var r=t.root.getSelection(),o=r.focusNode,i=r.focusOffset;o&&1==o.nodeType&&0!=i;){var a=i<0?o.lastChild:o.childNodes[i-1];if(!a)break;if(3==a.nodeType){r.collapse(a,a.nodeValue.length);break}o=a,i=-1}t.composing=!0}ve(t,me)},ee.compositionend=function(t,e){t.composing&&(t.composing=!1,t.compositionEndedAt=e.timeStamp,ve(t,20))};var we=s.ie&&s.ie_version<15||s.ios&&s.webkit_version<604;function be(t,e,n,r){var i=Vt(t,e,n,t.shiftKey,t.state.selection.$from);if(t.someProp("handlePaste",(function(e){return e(t,r,i||o.Slice.empty)})))return!0;if(!i)return!1;var s=function(t){return 0==t.openStart&&0==t.openEnd&&1==t.content.childCount?t.content.firstChild:null}(i),a=s?t.state.tr.replaceSelectionWith(s,t.shiftKey):t.state.tr.replaceSelection(i);return t.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}te.copy=ee.cut=function(t,e){var n=t.state.selection,r="cut"==e.type;if(!n.empty){var o=we?null:e.clipboardData,i=Lt(t,n.content()),s=i.dom,a=i.text;o?(e.preventDefault(),o.clearData(),o.setData("text/html",s.innerHTML),o.setData("text/plain",a)):function(t,e){if(t.dom.parentNode){var n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";var r=getSelection(),o=document.createRange();o.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout((function(){n.parentNode&&n.parentNode.removeChild(n),t.focus()}),50)}}(t,s),r&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))}},ee.paste=function(t,e){if(!t.composing||s.android){var n=we?null:e.clipboardData;n&&be(t,n.getData("text/plain"),n.getData("text/html"),e)?e.preventDefault():function(t,e){if(t.dom.parentNode){var n=t.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus(),setTimeout((function(){t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?be(t,r.value,null,e):be(t,r.textContent,r.innerHTML,e)}),50)}}(t,e)}};var Se=function(t,e){this.slice=t,this.move=e},ke=s.mac?"altKey":"ctrlKey";for(var xe in te.dragstart=function(t,e){var n=t.mouseDown;if(n&&n.done(),e.dataTransfer){var o=t.state.selection,i=o.empty?null:t.posAtCoords(ie(e));if(i&&i.pos>=o.from&&i.pos<=(o instanceof r.NodeSelection?o.to-1:o.to));else if(n&&n.mightDrag)t.dispatch(t.state.tr.setSelection(r.NodeSelection.create(t.state.doc,n.mightDrag.pos)));else if(e.target&&1==e.target.nodeType){var s=t.docView.nearestDesc(e.target,!0);s&&s.node.type.spec.draggable&&s!=t.docView&&t.dispatch(t.state.tr.setSelection(r.NodeSelection.create(t.state.doc,s.posBefore)))}var a=t.state.selection.content(),c=Lt(t,a),l=c.dom,u=c.text;e.dataTransfer.clearData(),e.dataTransfer.setData(we?"Text":"text/html",l.innerHTML),e.dataTransfer.effectAllowed="copyMove",we||e.dataTransfer.setData("text/plain",u),t.dragging=new Se(a,!e[ke])}},te.dragend=function(t){var e=t.dragging;window.setTimeout((function(){t.dragging==e&&(t.dragging=null)}),50)},ee.dragover=ee.dragenter=function(t,e){return e.preventDefault()},ee.drop=function(t,e){var n=t.dragging;if(t.dragging=null,e.dataTransfer){var s=t.posAtCoords(ie(e));if(s){var a=t.state.doc.resolve(s.pos);if(a){var c=n&&n.slice;c?t.someProp("transformPasted",(function(t){c=t(c)})):c=Vt(t,e.dataTransfer.getData(we?"Text":"text/plain"),we?null:e.dataTransfer.getData("text/html"),!1,a);var l=n&&!e[ke];if(t.someProp("handleDrop",(function(n){return n(t,e,c||o.Slice.empty,l)})))e.preventDefault();else if(c){e.preventDefault();var u=c?Object(i.dropPoint)(t.state.doc,a.pos,c):a.pos;null==u&&(u=a.pos);var p=t.state.tr;l&&p.deleteSelection();var f=p.mapping.map(u),d=0==c.openStart&&0==c.openEnd&&1==c.content.childCount,h=p.doc;if(d?p.replaceRangeWith(f,f,c.content.firstChild):p.replaceRange(f,f,c),!p.doc.eq(h)){var m=p.doc.resolve(f);if(d&&r.NodeSelection.isSelectable(c.content.firstChild)&&m.nodeAfter&&m.nodeAfter.sameMarkup(c.content.firstChild))p.setSelection(new r.NodeSelection(m));else{var v=p.mapping.map(u);p.mapping.maps[p.mapping.maps.length-1].forEach((function(t,e,n,r){return v=r})),p.setSelection(St(t,m,p.doc.resolve(v)))}t.focus(),t.dispatch(p.setMeta("uiEvent","drop"))}}}}}},te.focus=function(t){t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout((function(){t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.root.getSelection())&&ht(t)}),20))},te.blur=function(t,e){t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),e.relatedTarget&&t.dom.contains(e.relatedTarget)&&t.domObserver.currentSelection.set({}),t.focused=!1)},te.beforeinput=function(t,e){if(s.chrome&&s.android&&"deleteContentBackward"==e.inputType){t.domObserver.flushSoon();var n=t.domChangeCount;setTimeout((function(){if(t.domChangeCount==n&&(t.dom.blur(),t.focus(),!t.someProp("handleKeyDown",(function(e){return e(t,k(8,"Backspace"))})))){var e=t.state.selection.$cursor;e&&e.pos>0&&t.dispatch(t.state.tr.delete(e.pos-1,e.pos).scrollIntoView())}}),50)}},ee)te[xe]=ee[xe];function Ce(t,e){if(t==e)return!0;for(var n in t)if(t[n]!==e[n])return!1;for(var r in e)if(!(r in t))return!1;return!0}var Me=function(t,e){this.spec=e||Ee,this.side=this.spec.side||0,this.toDOM=t};Me.prototype.map=function(t,e,n,r){var o=t.mapResult(e.from+r,this.side<0?-1:1),i=o.pos;return o.deleted?null:new Ne(i-n,i-n,this)},Me.prototype.valid=function(){return!0},Me.prototype.eq=function(t){return this==t||t instanceof Me&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&Ce(this.spec,t.spec))},Me.prototype.destroy=function(t){this.spec.destroy&&this.spec.destroy(t)};var Oe=function(t,e){this.spec=e||Ee,this.attrs=t};Oe.prototype.map=function(t,e,n,r){var o=t.map(e.from+r,this.spec.inclusiveStart?-1:1)-n,i=t.map(e.to+r,this.spec.inclusiveEnd?1:-1)-n;return o>=i?null:new Ne(o,i,this)},Oe.prototype.valid=function(t,e){return e.from<e.to},Oe.prototype.eq=function(t){return this==t||t instanceof Oe&&Ce(this.attrs,t.attrs)&&Ce(this.spec,t.spec)},Oe.is=function(t){return t.type instanceof Oe};var Te=function(t,e){this.spec=e||Ee,this.attrs=t};Te.prototype.map=function(t,e,n,r){var o=t.mapResult(e.from+r,1);if(o.deleted)return null;var i=t.mapResult(e.to+r,-1);return i.deleted||i.pos<=o.pos?null:new Ne(o.pos-n,i.pos-n,this)},Te.prototype.valid=function(t,e){var n,r=t.content.findIndex(e.from),o=r.index,i=r.offset;return i==e.from&&!(n=t.child(o)).isText&&i+n.nodeSize==e.to},Te.prototype.eq=function(t){return this==t||t instanceof Te&&Ce(this.attrs,t.attrs)&&Ce(this.spec,t.spec)};var Ne=function(t,e,n){this.from=t,this.to=e,this.type=n},Ae={spec:{configurable:!0},inline:{configurable:!0}};Ne.prototype.copy=function(t,e){return new Ne(t,e,this.type)},Ne.prototype.eq=function(t,e){return void 0===e&&(e=0),this.type.eq(t.type)&&this.from+e==t.from&&this.to+e==t.to},Ne.prototype.map=function(t,e,n){return this.type.map(t,this,e,n)},Ne.widget=function(t,e,n){return new Ne(t,t,new Me(e,n))},Ne.inline=function(t,e,n,r){return new Ne(t,e,new Oe(n,r))},Ne.node=function(t,e,n,r){return new Ne(t,e,new Te(n,r))},Ae.spec.get=function(){return this.type.spec},Ae.inline.get=function(){return this.type instanceof Oe},Object.defineProperties(Ne.prototype,Ae);var De=[],Ee={},Re=function(t,e){this.local=t&&t.length?t:De,this.children=e&&e.length?e:De};Re.create=function(t,e){return e.length?Fe(e,t,0,Ee):_e},Re.prototype.find=function(t,e,n){var r=[];return this.findInner(null==t?0:t,null==e?1e9:e,r,0,n),r},Re.prototype.findInner=function(t,e,n,r,o){for(var i=0;i<this.local.length;i++){var s=this.local[i];s.from<=e&&s.to>=t&&(!o||o(s.spec))&&n.push(s.copy(s.from+r,s.to+r))}for(var a=0;a<this.children.length;a+=3)if(this.children[a]<e&&this.children[a+1]>t){var c=this.children[a]+1;this.children[a+2].findInner(t-c,e-c,n,r+c,o)}},Re.prototype.map=function(t,e,n){return this==_e||0==t.maps.length?this:this.mapInner(t,e,0,0,n||Ee)},Re.prototype.mapInner=function(t,e,n,r,o){for(var i,s=0;s<this.local.length;s++){var a=this.local[s].map(t,n,r);a&&a.type.valid(e,a)?(i||(i=[])).push(a):o.onRemove&&o.onRemove(this.local[s].spec)}return this.children.length?function(t,e,n,r,o,i,s){for(var a=t.slice(),c=function(t,e,n,r){for(var s=0;s<a.length;s+=3){var c=a[s+1],l=void 0;if(!(c<0||t>c+i)){var u=a[s]+i;e>=u?a[s+1]=t<=u?-2:-1:n>=o&&(l=r-n-(e-t))&&(a[s]+=l,a[s+1]+=l)}}},l=0;l<n.maps.length;l++)n.maps[l].forEach(c);for(var u=!1,p=0;p<a.length;p+=3)if(a[p+1]<0){if(-2==a[p+1]){u=!0,a[p+1]=-1;continue}var f=n.map(t[p]+i),d=f-o;if(d<0||d>=r.content.size){u=!0;continue}var h=n.map(t[p+1]+i,-1)-o,m=r.content.findIndex(d),v=m.index,g=m.offset,y=r.maybeChild(v);if(y&&g==d&&g+y.nodeSize==h){var w=a[p+2].mapInner(n,y,f+1,t[p]+i+1,s);w!=_e?(a[p]=d,a[p+1]=h,a[p+2]=w):(a[p+1]=-2,u=!0)}else u=!0}if(u){var b=Fe(function(t,e,n,r,o,i,s){function a(t,e){for(var i=0;i<t.local.length;i++){var c=t.local[i].map(r,o,e);c?n.push(c):s.onRemove&&s.onRemove(t.local[i].spec)}for(var l=0;l<t.children.length;l+=3)a(t.children[l+2],t.children[l]+e+1)}for(var c=0;c<t.length;c+=3)-1==t[c+1]&&a(t[c+2],e[c]+i+1);return n}(a,t,e||[],n,o,i,s),r,0,s);e=b.local;for(var S=0;S<a.length;S+=3)a[S+1]<0&&(a.splice(S,3),S-=3);for(var k=0,x=0;k<b.children.length;k+=3){for(var C=b.children[k];x<a.length&&a[x]<C;)x+=3;a.splice(x,0,b.children[k],b.children[k+1],b.children[k+2])}}return new Re(e&&e.sort(Be),a)}(this.children,i,t,e,n,r,o):i?new Re(i.sort(Be)):_e},Re.prototype.add=function(t,e){return e.length?this==_e?Re.create(t,e):this.addInner(t,e,0):this},Re.prototype.addInner=function(t,e,n){var r,o=this,i=0;t.forEach((function(t,s){var a,c=s+n;if(a=Pe(e,t,c)){for(r||(r=o.children.slice());i<r.length&&r[i]<s;)i+=3;r[i]==s?r[i+2]=r[i+2].addInner(t,a,c+1):r.splice(i,0,s,s+t.nodeSize,Fe(a,t,c+1,Ee)),i+=3}}));for(var s=ze(i?$e(e):e,-n),a=0;a<s.length;a++)s[a].type.valid(t,s[a])||s.splice(a--,1);return new Re(s.length?this.local.concat(s).sort(Be):this.local,r||this.children)},Re.prototype.remove=function(t){return 0==t.length||this==_e?this:this.removeInner(t,0)},Re.prototype.removeInner=function(t,e){for(var n=this.children,r=this.local,o=0;o<n.length;o+=3){for(var i=void 0,s=n[o]+e,a=n[o+1]+e,c=0,l=void 0;c<t.length;c++)(l=t[c])&&l.from>s&&l.to<a&&(t[c]=null,(i||(i=[])).push(l));if(i){n==this.children&&(n=this.children.slice());var u=n[o+2].removeInner(i,s+1);u!=_e?n[o+2]=u:(n.splice(o,3),o-=3)}}if(r.length)for(var p=0,f=void 0;p<t.length;p++)if(f=t[p])for(var d=0;d<r.length;d++)r[d].eq(f,e)&&(r==this.local&&(r=this.local.slice()),r.splice(d--,1));return n==this.children&&r==this.local?this:r.length||n.length?new Re(r,n):_e},Re.prototype.forChild=function(t,e){if(this==_e)return this;if(e.isLeaf)return Re.empty;for(var n,r,o=0;o<this.children.length;o+=3)if(this.children[o]>=t){this.children[o]==t&&(n=this.children[o+2]);break}for(var i=t+1,s=i+e.content.size,a=0;a<this.local.length;a++){var c=this.local[a];if(c.from<s&&c.to>i&&c.type instanceof Oe){var l=Math.max(i,c.from)-i,u=Math.min(s,c.to)-i;l<u&&(r||(r=[])).push(c.copy(l,u))}}if(r){var p=new Re(r.sort(Be));return n?new Ie([p,n]):p}return n||_e},Re.prototype.eq=function(t){if(this==t)return!0;if(!(t instanceof Re)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(var e=0;e<this.local.length;e++)if(!this.local[e].eq(t.local[e]))return!1;for(var n=0;n<this.children.length;n+=3)if(this.children[n]!=t.children[n]||this.children[n+1]!=t.children[n+1]||!this.children[n+2].eq(t.children[n+2]))return!1;return!0},Re.prototype.locals=function(t){return Le(this.localsInner(t))},Re.prototype.localsInner=function(t){if(this==_e)return De;if(t.inlineContent||!this.local.some(Oe.is))return this.local;for(var e=[],n=0;n<this.local.length;n++)this.local[n].type instanceof Oe||e.push(this.local[n]);return e};var _e=new Re;Re.empty=_e,Re.removeOverlap=Le;var Ie=function(t){this.members=t};function ze(t,e){if(!e||!t.length)return t;for(var n=[],r=0;r<t.length;r++){var o=t[r];n.push(new Ne(o.from+e,o.to+e,o.type))}return n}function Pe(t,e,n){if(e.isLeaf)return null;for(var r=n+e.nodeSize,o=null,i=0,s=void 0;i<t.length;i++)(s=t[i])&&s.from>n&&s.to<r&&((o||(o=[])).push(s),t[i]=null);return o}function $e(t){for(var e=[],n=0;n<t.length;n++)null!=t[n]&&e.push(t[n]);return e}function Fe(t,e,n,r){var o=[],i=!1;e.forEach((function(e,s){var a=Pe(t,e,s+n);if(a){i=!0;var c=Fe(a,e,n+s+1,r);c!=_e&&o.push(s,s+e.nodeSize,c)}}));for(var s=ze(i?$e(t):t,-n).sort(Be),a=0;a<s.length;a++)s[a].type.valid(e,s[a])||(r.onRemove&&r.onRemove(s[a].spec),s.splice(a--,1));return s.length||o.length?new Re(s,o):_e}function Be(t,e){return t.from-e.from||t.to-e.to}function Le(t){for(var e=t,n=0;n<e.length-1;n++){var r=e[n];if(r.from!=r.to)for(var o=n+1;o<e.length;o++){var i=e[o];if(i.from!=r.from){i.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,i.from),Ve(e,o,r.copy(i.from,r.to)));break}i.to!=r.to&&(e==t&&(e=t.slice()),e[o]=i.copy(i.from,r.to),Ve(e,o+1,i.copy(r.to,i.to)))}}return e}function Ve(t,e,n){for(;e<t.length&&Be(n,t[e])>0;)e++;t.splice(e,0,n)}function je(t){var e=[];return t.someProp("decorations",(function(n){var r=n(t.state);r&&r!=_e&&e.push(r)})),t.cursorWrapper&&e.push(Re.create(t.state.doc,[t.cursorWrapper.deco])),Ie.from(e)}Ie.prototype.map=function(t,e){var n=this.members.map((function(n){return n.map(t,e,Ee)}));return Ie.from(n)},Ie.prototype.forChild=function(t,e){if(e.isLeaf)return Re.empty;for(var n=[],r=0;r<this.members.length;r++){var o=this.members[r].forChild(t,e);o!=_e&&(o instanceof Ie?n=n.concat(o.members):n.push(o))}return Ie.from(n)},Ie.prototype.eq=function(t){if(!(t instanceof Ie)||t.members.length!=this.members.length)return!1;for(var e=0;e<this.members.length;e++)if(!this.members[e].eq(t.members[e]))return!1;return!0},Ie.prototype.locals=function(t){for(var e,n=!0,r=0;r<this.members.length;r++){var o=this.members[r].localsInner(t);if(o.length)if(e){n&&(e=e.slice(),n=!1);for(var i=0;i<o.length;i++)e.push(o[i])}else e=o}return e?Le(n?e:e.sort(Be)):De},Ie.from=function(t){switch(t.length){case 0:return _e;case 1:return t[0];default:return new Ie(t)}};var We=function(t,e){this._props=e,this.state=e.state,this.directPlugins=e.plugins||[],this.directPlugins.forEach(Ge),this.dispatch=this.dispatch.bind(this),this._root=null,this.focused=!1,this.trackWrites=null,this.dom=t&&t.mount||document.createElement("div"),t&&(t.appendChild?t.appendChild(this.dom):t.apply?t(this.dom):t.mount&&(this.mounted=!0)),this.editable=Je(this),this.markCursor=null,this.cursorWrapper=null,He(this),this.nodeViews=Ue(this),this.docView=Y(this.state.doc,qe(this),je(this),this.dom,this),this.lastSelectedViewDesc=null,this.dragging=null,function(t){t.shiftKey=!1,t.mouseDown=null,t.lastKeyCode=null,t.lastKeyCodeTime=0,t.lastClick={time:0,x:0,y:0,type:""},t.lastSelectionOrigin=null,t.lastSelectionTime=0,t.lastIOSEnter=0,t.lastIOSEnterFallbackTimeout=null,t.lastAndroidDelete=0,t.composing=!1,t.composingTimeout=null,t.compositionNodes=[],t.compositionEndedAt=-2e8,t.domObserver=new Qt(t,(function(e,n,r,o){return $t(t,e,n,r,o)})),t.domObserver.start(),t.domChangeCount=0,t.eventHandlers=Object.create(null);var e=function(e){var n=te[e];t.dom.addEventListener(e,t.eventHandlers[e]=function(e){!function(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(var n=e.target;n!=t.dom;n=n.parentNode)if(!n||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}(t,e)||oe(t,e)||!t.editable&&e.type in ee||n(t,e)})};for(var n in te)e(n);s.safari&&t.dom.addEventListener("input",(function(){return null})),re(t)}(this),this.prevDirectPlugins=[],this.pluginViews=[],this.updatePluginViews()},Ke={props:{configurable:!0},root:{configurable:!0},isDestroyed:{configurable:!0}};function qe(t){var e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),e.translate="no",t.someProp("attributes",(function(n){if("function"==typeof n&&(n=n(t.state)),n)for(var r in n)"class"==r&&(e.class+=" "+n[r]),"style"==r?e.style=(e.style?e.style+";":"")+n[r]:e[r]||"contenteditable"==r||"nodeName"==r||(e[r]=String(n[r]))})),[Ne.node(0,t.state.doc.content.size,e)]}function He(t){if(t.markCursor){var e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:Ne.widget(t.state.selection.head,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function Je(t){return!t.someProp("editable",(function(e){return!1===e(t.state)}))}function Ue(t){var e={};return t.someProp("nodeViews",(function(t){for(var n in t)Object.prototype.hasOwnProperty.call(e,n)||(e[n]=t[n])})),e}function Ge(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}Ke.props.get=function(){if(this._props.state!=this.state){var t=this._props;for(var e in this._props={},t)this._props[e]=t[e];this._props.state=this.state}return this._props},We.prototype.update=function(t){t.handleDOMEvents!=this._props.handleDOMEvents&&re(this),this._props=t,t.plugins&&(t.plugins.forEach(Ge),this.directPlugins=t.plugins),this.updateStateInner(t.state,!0)},We.prototype.setProps=function(t){var e={};for(var n in this._props)e[n]=this._props[n];for(var r in e.state=this.state,t)e[r]=t[r];this.update(e)},We.prototype.updateState=function(t){this.updateStateInner(t,this.state.plugins!=t.plugins)},We.prototype.updateStateInner=function(t,e){var n=this,o=this.state,i=!1,a=!1;if(t.storedMarks&&this.composing&&(ge(this),a=!0),this.state=t,e){var c=Ue(this);(function(t,e){var n=0,r=0;for(var o in t){if(t[o]!=e[o])return!0;n++}for(var i in e)r++;return n!=r})(c,this.nodeViews)&&(this.nodeViews=c,i=!0),re(this)}this.editable=Je(this),He(this);var l=je(this),u=qe(this),p=e?"reset":t.scrollToSelection>o.scrollToSelection?"to selection":"preserve",f=i||!this.docView.matchesNode(t.doc,u,l);!f&&t.selection.eq(o.selection)||(a=!0);var d,h,m,g,y,w,b,S,k,x,C,M="preserve"==p&&a&&null==this.dom.style.overflowAnchor&&function(t){for(var e,n,r=t.dom.getBoundingClientRect(),o=Math.max(0,r.top),i=(r.left+r.right)/2,s=o+1;s<Math.min(innerHeight,r.bottom);s+=5){var a=t.root.elementFromPoint(i,s);if(a!=t.dom&&t.dom.contains(a)){var c=a.getBoundingClientRect();if(c.top>=o-20){e=a,n=c.top;break}}}return{refDOM:e,refTop:n,stack:T(t.dom)}}(this);if(a){this.domObserver.stop();var A=f&&(s.ie||s.chrome)&&!this.composing&&!o.selection.empty&&!t.selection.empty&&(g=o.selection,y=t.selection,w=Math.min(g.$anchor.sharedDepth(g.head),y.$anchor.sharedDepth(y.head)),g.$anchor.start(w)!=y.$anchor.start(w));if(f){var D=s.chrome?this.trackWrites=this.root.getSelection().focusNode:null;!i&&this.docView.update(t.doc,u,l,this)||(this.docView.updateOuterDeco([]),this.docView.destroy(),this.docView=Y(t.doc,u,l,this.dom,this)),D&&!this.trackWrites&&(A=!0)}A||!(this.mouseDown&&this.domObserver.currentSelection.eq(this.root.getSelection())&&(d=this,h=d.docView.domFromPos(d.state.selection.anchor,0),m=d.root.getSelection(),v(h.node,h.offset,m.anchorNode,m.anchorOffset)))?ht(this,A):(wt(this,t.selection),this.domObserver.setCurSelection()),this.domObserver.start()}if(this.updatePluginViews(o),"reset"==p)this.dom.scrollTop=0;else if("to selection"==p){var E=this.root.getSelection().focusNode;this.someProp("handleScrollToSelection",(function(t){return t(n)}))||(t.selection instanceof r.NodeSelection?O(this,this.docView.domAfterPos(t.selection.from).getBoundingClientRect(),E):O(this,this.coordsAtPos(t.selection.head,1),E))}else M&&(S=(b=M).refDOM,k=b.refTop,x=b.stack,C=S?S.getBoundingClientRect().top:0,N(x,0==C?0:C-k))},We.prototype.destroyPluginViews=function(){for(var t;t=this.pluginViews.pop();)t.destroy&&t.destroy()},We.prototype.updatePluginViews=function(t){if(t&&t.plugins==this.state.plugins&&this.directPlugins==this.prevDirectPlugins)for(var e=0;e<this.pluginViews.length;e++){var n=this.pluginViews[e];n.update&&n.update(this,t)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(var r=0;r<this.directPlugins.length;r++){var o=this.directPlugins[r];o.spec.view&&this.pluginViews.push(o.spec.view(this))}for(var i=0;i<this.state.plugins.length;i++){var s=this.state.plugins[i];s.spec.view&&this.pluginViews.push(s.spec.view(this))}}},We.prototype.someProp=function(t,e){var n,r=this._props&&this._props[t];if(null!=r&&(n=e?e(r):r))return n;for(var o=0;o<this.directPlugins.length;o++){var i=this.directPlugins[o].props[t];if(null!=i&&(n=e?e(i):i))return n}var s=this.state.plugins;if(s)for(var a=0;a<s.length;a++){var c=s[a].props[t];if(null!=c&&(n=e?e(c):c))return n}},We.prototype.hasFocus=function(){return this.root.activeElement==this.dom},We.prototype.focus=function(){this.domObserver.stop(),this.editable&&function(t){if(t.setActive)return t.setActive();if(A)return t.focus(A);var e=T(t);t.focus(null==A?{get preventScroll(){return A={preventScroll:!0},!0}}:void 0),A||(A=!1,N(e,0))}(this.dom),ht(this),this.domObserver.start()},Ke.root.get=function(){var t=this._root;if(null==t)for(var e=this.dom.parentNode;e;e=e.parentNode)if(9==e.nodeType||11==e.nodeType&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=function(){return document.getSelection()}),this._root=e;return t||document},We.prototype.posAtCoords=function(t){return R(this,t)},We.prototype.coordsAtPos=function(t,e){return void 0===e&&(e=1),z(this,t,e)},We.prototype.domAtPos=function(t,e){return void 0===e&&(e=0),this.docView.domFromPos(t,e)},We.prototype.nodeDOM=function(t){var e=this.docView.descAt(t);return e?e.nodeDOM:null},We.prototype.posAtDOM=function(t,e,n){void 0===n&&(n=-1);var r=this.docView.posFromDOM(t,e,n);if(null==r)throw new RangeError("DOM position not inside the editor");return r},We.prototype.endOfTextblock=function(t,e){return W(this,e||this.state,t)},We.prototype.destroy=function(){this.docView&&(!function(t){for(var e in t.domObserver.stop(),t.eventHandlers)t.dom.removeEventListener(e,t.eventHandlers[e]);clearTimeout(t.composingTimeout),clearTimeout(t.lastIOSEnterFallbackTimeout)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],je(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null)},Ke.isDestroyed.get=function(){return null==this.docView},We.prototype.dispatchEvent=function(t){return function(t,e){oe(t,e)||!te[e.type]||!t.editable&&e.type in ee||te[e.type](t,e)}(this,t)},We.prototype.dispatch=function(t){var e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))},Object.defineProperties(We.prototype,Ke)},function(t,e,n){"use strict";n.r(e),n.d(e,"__extends",(function(){return o})),n.d(e,"__assign",(function(){return i})),n.d(e,"__rest",(function(){return s})),n.d(e,"__decorate",(function(){return a})),n.d(e,"__param",(function(){return c})),n.d(e,"__metadata",(function(){return l})),n.d(e,"__awaiter",(function(){return u})),n.d(e,"__generator",(function(){return p})),n.d(e,"__createBinding",(function(){return f})),n.d(e,"__exportStar",(function(){return d})),n.d(e,"__values",(function(){return h})),n.d(e,"__read",(function(){return m})),n.d(e,"__spread",(function(){return v})),n.d(e,"__spreadArrays",(function(){return g})),n.d(e,"__await",(function(){return y})),n.d(e,"__asyncGenerator",(function(){return w})),n.d(e,"__asyncDelegator",(function(){return b})),n.d(e,"__asyncValues",(function(){return S})),n.d(e,"__makeTemplateObject",(function(){return k})),n.d(e,"__importStar",(function(){return x})),n.d(e,"__importDefault",(function(){return C})),n.d(e,"__classPrivateFieldGet",(function(){return M})),n.d(e,"__classPrivateFieldSet",(function(){return O}));
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.KendoEditorCommon=e():t.KendoEditorCommon=e()}(window,(function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=23)}([function(t,e,n){"use strict";function r(t){this.content=t}n.r(e),n.d(e,"ContentMatch",(function(){return _})),n.d(e,"DOMParser",(function(){return tt})),n.d(e,"DOMSerializer",(function(){return pt})),n.d(e,"Fragment",(function(){return i})),n.d(e,"Mark",(function(){return u})),n.d(e,"MarkType",(function(){return Y})),n.d(e,"Node",(function(){return A})),n.d(e,"NodeRange",(function(){return O})),n.d(e,"NodeType",(function(){return J})),n.d(e,"ReplaceError",(function(){return p})),n.d(e,"ResolvedPos",(function(){return S})),n.d(e,"Schema",(function(){return Q})),n.d(e,"Slice",(function(){return f})),r.prototype={constructor:r,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return-1==e?void 0:this.content[e+1]},update:function(t,e,n){var o=n&&n!=t?this.remove(n):this,i=o.find(t),s=o.content.slice();return-1==i?s.push(n||t,e):(s[i+1]=e,n&&(s[i]=n)),new r(s)},remove:function(t){var e=this.find(t);if(-1==e)return this;var n=this.content.slice();return n.splice(e,2),new r(n)},addToStart:function(t,e){return new r([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new r(n)},addBefore:function(t,e,n){var o=this.remove(e),i=o.content.slice(),s=o.find(t);return i.splice(-1==s?i.length:s,0,e,n),new r(i)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return(t=r.from(t)).size?new r(t.content.concat(this.subtract(t).content)):this},append:function(t){return(t=r.from(t)).size?new r(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=r.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},get size(){return this.content.length>>1}},r.from=function(t){if(t instanceof r)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new r(e)};var o=r;var i=function(t,e){if(this.content=t,this.size=e||0,null==e)for(var n=0;n<t.length;n++)this.size+=t[n].nodeSize},s={firstChild:{configurable:!0},lastChild:{configurable:!0},childCount:{configurable:!0}};i.prototype.nodesBetween=function(t,e,n,r,o){void 0===r&&(r=0);for(var i=0,s=0;s<e;i++){var a=this.content[i],c=s+a.nodeSize;if(c>t&&!1!==n(a,r+s,o,i)&&a.content.size){var l=s+1;a.nodesBetween(Math.max(0,t-l),Math.min(a.content.size,e-l),n,r+l)}s=c}},i.prototype.descendants=function(t){this.nodesBetween(0,this.size,t)},i.prototype.textBetween=function(t,e,n,r){var o="",i=!0;return this.nodesBetween(t,e,(function(s,a){s.isText?(o+=s.text.slice(Math.max(t,a)-a,e-a),i=!n):s.isLeaf&&r?(o+="function"==typeof r?r(s):r,i=!n):!i&&s.isBlock&&(o+=n,i=!0)}),0),o},i.prototype.append=function(t){if(!t.size)return this;if(!this.size)return t;var e=this.lastChild,n=t.firstChild,r=this.content.slice(),o=0;for(e.isText&&e.sameMarkup(n)&&(r[r.length-1]=e.withText(e.text+n.text),o=1);o<t.content.length;o++)r.push(t.content[o]);return new i(r,this.size+t.size)},i.prototype.cut=function(t,e){if(null==e&&(e=this.size),0==t&&e==this.size)return this;var n=[],r=0;if(e>t)for(var o=0,s=0;s<e;o++){var a=this.content[o],c=s+a.nodeSize;c>t&&((s<t||c>e)&&(a=a.isText?a.cut(Math.max(0,t-s),Math.min(a.text.length,e-s)):a.cut(Math.max(0,t-s-1),Math.min(a.content.size,e-s-1))),n.push(a),r+=a.nodeSize),s=c}return new i(n,r)},i.prototype.cutByIndex=function(t,e){return t==e?i.empty:0==t&&e==this.content.length?this:new i(this.content.slice(t,e))},i.prototype.replaceChild=function(t,e){var n=this.content[t];if(n==e)return this;var r=this.content.slice(),o=this.size+e.nodeSize-n.nodeSize;return r[t]=e,new i(r,o)},i.prototype.addToStart=function(t){return new i([t].concat(this.content),this.size+t.nodeSize)},i.prototype.addToEnd=function(t){return new i(this.content.concat(t),this.size+t.nodeSize)},i.prototype.eq=function(t){if(this.content.length!=t.content.length)return!1;for(var e=0;e<this.content.length;e++)if(!this.content[e].eq(t.content[e]))return!1;return!0},s.firstChild.get=function(){return this.content.length?this.content[0]:null},s.lastChild.get=function(){return this.content.length?this.content[this.content.length-1]:null},s.childCount.get=function(){return this.content.length},i.prototype.child=function(t){var e=this.content[t];if(!e)throw new RangeError("Index "+t+" out of range for "+this);return e},i.prototype.maybeChild=function(t){return this.content[t]},i.prototype.forEach=function(t){for(var e=0,n=0;e<this.content.length;e++){var r=this.content[e];t(r,n,e),n+=r.nodeSize}},i.prototype.findDiffStart=function(t,e){return void 0===e&&(e=0),function t(e,n,r){for(var o=0;;o++){if(o==e.childCount||o==n.childCount)return e.childCount==n.childCount?null:r;var i=e.child(o),s=n.child(o);if(i!=s){if(!i.sameMarkup(s))return r;if(i.isText&&i.text!=s.text){for(var a=0;i.text[a]==s.text[a];a++)r++;return r}if(i.content.size||s.content.size){var c=t(i.content,s.content,r+1);if(null!=c)return c}r+=i.nodeSize}else r+=i.nodeSize}}(this,t,e)},i.prototype.findDiffEnd=function(t,e,n){return void 0===e&&(e=this.size),void 0===n&&(n=t.size),function t(e,n,r,o){for(var i=e.childCount,s=n.childCount;;){if(0==i||0==s)return i==s?null:{a:r,b:o};var a=e.child(--i),c=n.child(--s),l=a.nodeSize;if(a!=c){if(!a.sameMarkup(c))return{a:r,b:o};if(a.isText&&a.text!=c.text){for(var u=0,p=Math.min(a.text.length,c.text.length);u<p&&a.text[a.text.length-u-1]==c.text[c.text.length-u-1];)u++,r--,o--;return{a:r,b:o}}if(a.content.size||c.content.size){var f=t(a.content,c.content,r-1,o-1);if(f)return f}r-=l,o-=l}else r-=l,o-=l}}(this,t,e,n)},i.prototype.findIndex=function(t,e){if(void 0===e&&(e=-1),0==t)return c(0,t);if(t==this.size)return c(this.content.length,t);if(t>this.size||t<0)throw new RangeError("Position "+t+" outside of fragment ("+this+")");for(var n=0,r=0;;n++){var o=r+this.child(n).nodeSize;if(o>=t)return o==t||e>0?c(n+1,o):c(n,r);r=o}},i.prototype.toString=function(){return"<"+this.toStringInner()+">"},i.prototype.toStringInner=function(){return this.content.join(", ")},i.prototype.toJSON=function(){return this.content.length?this.content.map((function(t){return t.toJSON()})):null},i.fromJSON=function(t,e){if(!e)return i.empty;if(!Array.isArray(e))throw new RangeError("Invalid input for Fragment.fromJSON");return new i(e.map(t.nodeFromJSON))},i.fromArray=function(t){if(!t.length)return i.empty;for(var e,n=0,r=0;r<t.length;r++){var o=t[r];n+=o.nodeSize,r&&o.isText&&t[r-1].sameMarkup(o)?(e||(e=t.slice(0,r)),e[e.length-1]=o.withText(e[e.length-1].text+o.text)):e&&e.push(o)}return new i(e||t,n)},i.from=function(t){if(!t)return i.empty;if(t instanceof i)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new i([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))},Object.defineProperties(i.prototype,s);var a={index:0,offset:0};function c(t,e){return a.index=t,a.offset=e,a}function l(t,e){if(t===e)return!0;if(!t||"object"!=typeof t||!e||"object"!=typeof e)return!1;var n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(var r=0;r<t.length;r++)if(!l(t[r],e[r]))return!1}else{for(var o in t)if(!(o in e)||!l(t[o],e[o]))return!1;for(var i in e)if(!(i in t))return!1}return!0}i.empty=new i([],0);var u=function(t,e){this.type=t,this.attrs=e};function p(t){var e=Error.call(this,t);return e.__proto__=p.prototype,e}u.prototype.addToSet=function(t){for(var e,n=!1,r=0;r<t.length;r++){var o=t[r];if(this.eq(o))return t;if(this.type.excludes(o.type))e||(e=t.slice(0,r));else{if(o.type.excludes(this.type))return t;!n&&o.type.rank>this.type.rank&&(e||(e=t.slice(0,r)),e.push(this),n=!0),e&&e.push(o)}}return e||(e=t.slice()),n||e.push(this),e},u.prototype.removeFromSet=function(t){for(var e=0;e<t.length;e++)if(this.eq(t[e]))return t.slice(0,e).concat(t.slice(e+1));return t},u.prototype.isInSet=function(t){for(var e=0;e<t.length;e++)if(this.eq(t[e]))return!0;return!1},u.prototype.eq=function(t){return this==t||this.type==t.type&&l(this.attrs,t.attrs)},u.prototype.toJSON=function(){var t={type:this.type.name};for(var e in this.attrs){t.attrs=this.attrs;break}return t},u.fromJSON=function(t,e){if(!e)throw new RangeError("Invalid input for Mark.fromJSON");var n=t.marks[e.type];if(!n)throw new RangeError("There is no mark type "+e.type+" in this schema");return n.create(e.attrs)},u.sameSet=function(t,e){if(t==e)return!0;if(t.length!=e.length)return!1;for(var n=0;n<t.length;n++)if(!t[n].eq(e[n]))return!1;return!0},u.setFrom=function(t){if(!t||0==t.length)return u.none;if(t instanceof u)return[t];var e=t.slice();return e.sort((function(t,e){return t.type.rank-e.type.rank})),e},u.none=[],p.prototype=Object.create(Error.prototype),p.prototype.constructor=p,p.prototype.name="ReplaceError";var f=function(t,e,n){this.content=t,this.openStart=e,this.openEnd=n},d={size:{configurable:!0}};function h(t,e,n){if(n.openStart>t.depth)throw new p("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new p("Inconsistent open depths");return function t(e,n,r,o){var s=e.index(o),a=e.node(o);if(s==n.index(o)&&o<e.depth-r.openStart){var c=t(e,n,r,o+1);return a.copy(a.content.replaceChild(s,c))}if(r.content.size){if(r.openStart||r.openEnd||e.depth!=o||n.depth!=o){var l=function(t,e){for(var n=e.depth-t.openStart,r=e.node(n).copy(t.content),o=n-1;o>=0;o--)r=e.node(o).copy(i.from(r));return{start:r.resolveNoCache(t.openStart+n),end:r.resolveNoCache(r.content.size-t.openEnd-n)}}(r,e),u=l.start,p=l.end;return w(a,function t(e,n,r,o,s){var a=e.depth>s&&v(e,n,s+1),c=o.depth>s&&v(r,o,s+1),l=[];y(null,e,s,l),a&&c&&n.index(s)==r.index(s)?(m(a,c),g(w(a,t(e,n,r,o,s+1)),l)):(a&&g(w(a,b(e,n,s+1)),l),y(n,r,s,l),c&&g(w(c,b(r,o,s+1)),l));return y(o,null,s,l),new i(l)}(e,u,p,n,o))}var f=e.parent,d=f.content;return w(f,d.cut(0,e.parentOffset).append(r.content).append(d.cut(n.parentOffset)))}return w(a,b(e,n,o))}(t,e,n,0)}function m(t,e){if(!e.type.compatibleContent(t.type))throw new p("Cannot join "+e.type.name+" onto "+t.type.name)}function v(t,e,n){var r=t.node(n);return m(r,e.node(n)),r}function g(t,e){var n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function y(t,e,n,r){var o=(e||t).node(n),i=0,s=e?e.index(n):o.childCount;t&&(i=t.index(n),t.depth>n?i++:t.textOffset&&(g(t.nodeAfter,r),i++));for(var a=i;a<s;a++)g(o.child(a),r);e&&e.depth==n&&e.textOffset&&g(e.nodeBefore,r)}function w(t,e){if(!t.type.validContent(e))throw new p("Invalid content for node "+t.type.name);return t.copy(e)}function b(t,e,n){var r=[];(y(null,t,n,r),t.depth>n)&&g(w(v(t,e,n+1),b(t,e,n+1)),r);return y(e,null,n,r),new i(r)}d.size.get=function(){return this.content.size-this.openStart-this.openEnd},f.prototype.insertAt=function(t,e){var n=function t(e,n,r,o){var i=e.findIndex(n),s=i.index,a=i.offset,c=e.maybeChild(s);if(a==n||c.isText)return o&&!o.canReplace(s,s,r)?null:e.cut(0,n).append(r).append(e.cut(n));var l=t(c.content,n-a-1,r);return l&&e.replaceChild(s,c.copy(l))}(this.content,t+this.openStart,e,null);return n&&new f(n,this.openStart,this.openEnd)},f.prototype.removeBetween=function(t,e){return new f(function t(e,n,r){var o=e.findIndex(n),i=o.index,s=o.offset,a=e.maybeChild(i),c=e.findIndex(r),l=c.index,u=c.offset;if(s==n||a.isText){if(u!=r&&!e.child(l).isText)throw new RangeError("Removing non-flat range");return e.cut(0,n).append(e.cut(r))}if(i!=l)throw new RangeError("Removing non-flat range");return e.replaceChild(i,a.copy(t(a.content,n-s-1,r-s-1)))}(this.content,t+this.openStart,e+this.openStart),this.openStart,this.openEnd)},f.prototype.eq=function(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd},f.prototype.toString=function(){return this.content+"("+this.openStart+","+this.openEnd+")"},f.prototype.toJSON=function(){if(!this.content.size)return null;var t={content:this.content.toJSON()};return this.openStart>0&&(t.openStart=this.openStart),this.openEnd>0&&(t.openEnd=this.openEnd),t},f.fromJSON=function(t,e){if(!e)return f.empty;var n=e.openStart||0,r=e.openEnd||0;if("number"!=typeof n||"number"!=typeof r)throw new RangeError("Invalid input for Slice.fromJSON");return new f(i.fromJSON(t,e.content),n,r)},f.maxOpen=function(t,e){void 0===e&&(e=!0);for(var n=0,r=0,o=t.firstChild;o&&!o.isLeaf&&(e||!o.type.spec.isolating);o=o.firstChild)n++;for(var i=t.lastChild;i&&!i.isLeaf&&(e||!i.type.spec.isolating);i=i.lastChild)r++;return new f(t,n,r)},Object.defineProperties(f.prototype,d),f.empty=new f(i.empty,0,0);var S=function(t,e,n){this.pos=t,this.path=e,this.depth=e.length/3-1,this.parentOffset=n},k={parent:{configurable:!0},doc:{configurable:!0},textOffset:{configurable:!0},nodeAfter:{configurable:!0},nodeBefore:{configurable:!0}};S.prototype.resolveDepth=function(t){return null==t?this.depth:t<0?this.depth+t:t},k.parent.get=function(){return this.node(this.depth)},k.doc.get=function(){return this.node(0)},S.prototype.node=function(t){return this.path[3*this.resolveDepth(t)]},S.prototype.index=function(t){return this.path[3*this.resolveDepth(t)+1]},S.prototype.indexAfter=function(t){return t=this.resolveDepth(t),this.index(t)+(t!=this.depth||this.textOffset?1:0)},S.prototype.start=function(t){return 0==(t=this.resolveDepth(t))?0:this.path[3*t-1]+1},S.prototype.end=function(t){return t=this.resolveDepth(t),this.start(t)+this.node(t).content.size},S.prototype.before=function(t){if(!(t=this.resolveDepth(t)))throw new RangeError("There is no position before the top-level node");return t==this.depth+1?this.pos:this.path[3*t-1]},S.prototype.after=function(t){if(!(t=this.resolveDepth(t)))throw new RangeError("There is no position after the top-level node");return t==this.depth+1?this.pos:this.path[3*t-1]+this.path[3*t].nodeSize},k.textOffset.get=function(){return this.pos-this.path[this.path.length-1]},k.nodeAfter.get=function(){var t=this.parent,e=this.index(this.depth);if(e==t.childCount)return null;var n=this.pos-this.path[this.path.length-1],r=t.child(e);return n?t.child(e).cut(n):r},k.nodeBefore.get=function(){var t=this.index(this.depth),e=this.pos-this.path[this.path.length-1];return e?this.parent.child(t).cut(0,e):0==t?null:this.parent.child(t-1)},S.prototype.posAtIndex=function(t,e){e=this.resolveDepth(e);for(var n=this.path[3*e],r=0==e?0:this.path[3*e-1]+1,o=0;o<t;o++)r+=n.child(o).nodeSize;return r},S.prototype.marks=function(){var t=this.parent,e=this.index();if(0==t.content.size)return u.none;if(this.textOffset)return t.child(e).marks;var n=t.maybeChild(e-1),r=t.maybeChild(e);if(!n){var o=n;n=r,r=o}for(var i=n.marks,s=0;s<i.length;s++)!1!==i[s].type.spec.inclusive||r&&i[s].isInSet(r.marks)||(i=i[s--].removeFromSet(i));return i},S.prototype.marksAcross=function(t){var e=this.parent.maybeChild(this.index());if(!e||!e.isInline)return null;for(var n=e.marks,r=t.parent.maybeChild(t.index()),o=0;o<n.length;o++)!1!==n[o].type.spec.inclusive||r&&n[o].isInSet(r.marks)||(n=n[o--].removeFromSet(n));return n},S.prototype.sharedDepth=function(t){for(var e=this.depth;e>0;e--)if(this.start(e)<=t&&this.end(e)>=t)return e;return 0},S.prototype.blockRange=function(t,e){if(void 0===t&&(t=this),t.pos<this.pos)return t.blockRange(this);for(var n=this.depth-(this.parent.inlineContent||this.pos==t.pos?1:0);n>=0;n--)if(t.pos<=this.end(n)&&(!e||e(this.node(n))))return new O(this,t,n)},S.prototype.sameParent=function(t){return this.pos-this.parentOffset==t.pos-t.parentOffset},S.prototype.max=function(t){return t.pos>this.pos?t:this},S.prototype.min=function(t){return t.pos<this.pos?t:this},S.prototype.toString=function(){for(var t="",e=1;e<=this.depth;e++)t+=(t?"/":"")+this.node(e).type.name+"_"+this.index(e-1);return t+":"+this.parentOffset},S.resolve=function(t,e){if(!(e>=0&&e<=t.content.size))throw new RangeError("Position "+e+" out of range");for(var n=[],r=0,o=e,i=t;;){var s=i.content.findIndex(o),a=s.index,c=s.offset,l=o-c;if(n.push(i,a,r+c),!l)break;if((i=i.child(a)).isText)break;o=l-1,r+=c+1}return new S(e,n,o)},S.resolveCached=function(t,e){for(var n=0;n<x.length;n++){var r=x[n];if(r.pos==e&&r.doc==t)return r}var o=x[C]=S.resolve(t,e);return C=(C+1)%M,o},Object.defineProperties(S.prototype,k);var x=[],C=0,M=12,O=function(t,e,n){this.$from=t,this.$to=e,this.depth=n},T={start:{configurable:!0},end:{configurable:!0},parent:{configurable:!0},startIndex:{configurable:!0},endIndex:{configurable:!0}};T.start.get=function(){return this.$from.before(this.depth+1)},T.end.get=function(){return this.$to.after(this.depth+1)},T.parent.get=function(){return this.$from.node(this.depth)},T.startIndex.get=function(){return this.$from.index(this.depth)},T.endIndex.get=function(){return this.$to.indexAfter(this.depth)},Object.defineProperties(O.prototype,T);var N=Object.create(null),A=function(t,e,n,r){this.type=t,this.attrs=e,this.content=n||i.empty,this.marks=r||u.none},D={nodeSize:{configurable:!0},childCount:{configurable:!0},textContent:{configurable:!0},firstChild:{configurable:!0},lastChild:{configurable:!0},isBlock:{configurable:!0},isTextblock:{configurable:!0},inlineContent:{configurable:!0},isInline:{configurable:!0},isText:{configurable:!0},isLeaf:{configurable:!0},isAtom:{configurable:!0}};D.nodeSize.get=function(){return this.isLeaf?1:2+this.content.size},D.childCount.get=function(){return this.content.childCount},A.prototype.child=function(t){return this.content.child(t)},A.prototype.maybeChild=function(t){return this.content.maybeChild(t)},A.prototype.forEach=function(t){this.content.forEach(t)},A.prototype.nodesBetween=function(t,e,n,r){void 0===r&&(r=0),this.content.nodesBetween(t,e,n,r,this)},A.prototype.descendants=function(t){this.nodesBetween(0,this.content.size,t)},D.textContent.get=function(){return this.textBetween(0,this.content.size,"")},A.prototype.textBetween=function(t,e,n,r){return this.content.textBetween(t,e,n,r)},D.firstChild.get=function(){return this.content.firstChild},D.lastChild.get=function(){return this.content.lastChild},A.prototype.eq=function(t){return this==t||this.sameMarkup(t)&&this.content.eq(t.content)},A.prototype.sameMarkup=function(t){return this.hasMarkup(t.type,t.attrs,t.marks)},A.prototype.hasMarkup=function(t,e,n){return this.type==t&&l(this.attrs,e||t.defaultAttrs||N)&&u.sameSet(this.marks,n||u.none)},A.prototype.copy=function(t){return void 0===t&&(t=null),t==this.content?this:new this.constructor(this.type,this.attrs,t,this.marks)},A.prototype.mark=function(t){return t==this.marks?this:new this.constructor(this.type,this.attrs,this.content,t)},A.prototype.cut=function(t,e){return 0==t&&e==this.content.size?this:this.copy(this.content.cut(t,e))},A.prototype.slice=function(t,e,n){if(void 0===e&&(e=this.content.size),void 0===n&&(n=!1),t==e)return f.empty;var r=this.resolve(t),o=this.resolve(e),i=n?0:r.sharedDepth(e),s=r.start(i),a=r.node(i).content.cut(r.pos-s,o.pos-s);return new f(a,r.depth-i,o.depth-i)},A.prototype.replace=function(t,e,n){return h(this.resolve(t),this.resolve(e),n)},A.prototype.nodeAt=function(t){for(var e=this;;){var n=e.content.findIndex(t),r=n.index,o=n.offset;if(!(e=e.maybeChild(r)))return null;if(o==t||e.isText)return e;t-=o+1}},A.prototype.childAfter=function(t){var e=this.content.findIndex(t),n=e.index,r=e.offset;return{node:this.content.maybeChild(n),index:n,offset:r}},A.prototype.childBefore=function(t){if(0==t)return{node:null,index:0,offset:0};var e=this.content.findIndex(t),n=e.index,r=e.offset;if(r<t)return{node:this.content.child(n),index:n,offset:r};var o=this.content.child(n-1);return{node:o,index:n-1,offset:r-o.nodeSize}},A.prototype.resolve=function(t){return S.resolveCached(this,t)},A.prototype.resolveNoCache=function(t){return S.resolve(this,t)},A.prototype.rangeHasMark=function(t,e,n){var r=!1;return e>t&&this.nodesBetween(t,e,(function(t){return n.isInSet(t.marks)&&(r=!0),!r})),r},D.isBlock.get=function(){return this.type.isBlock},D.isTextblock.get=function(){return this.type.isTextblock},D.inlineContent.get=function(){return this.type.inlineContent},D.isInline.get=function(){return this.type.isInline},D.isText.get=function(){return this.type.isText},D.isLeaf.get=function(){return this.type.isLeaf},D.isAtom.get=function(){return this.type.isAtom},A.prototype.toString=function(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);var t=this.type.name;return this.content.size&&(t+="("+this.content.toStringInner()+")"),R(this.marks,t)},A.prototype.contentMatchAt=function(t){var e=this.type.contentMatch.matchFragment(this.content,0,t);if(!e)throw new Error("Called contentMatchAt on a node with invalid content");return e},A.prototype.canReplace=function(t,e,n,r,o){void 0===n&&(n=i.empty),void 0===r&&(r=0),void 0===o&&(o=n.childCount);var s=this.contentMatchAt(t).matchFragment(n,r,o),a=s&&s.matchFragment(this.content,e);if(!a||!a.validEnd)return!1;for(var c=r;c<o;c++)if(!this.type.allowsMarks(n.child(c).marks))return!1;return!0},A.prototype.canReplaceWith=function(t,e,n,r){if(r&&!this.type.allowsMarks(r))return!1;var o=this.contentMatchAt(t).matchType(n),i=o&&o.matchFragment(this.content,e);return!!i&&i.validEnd},A.prototype.canAppend=function(t){return t.content.size?this.canReplace(this.childCount,this.childCount,t.content):this.type.compatibleContent(t.type)},A.prototype.check=function(){if(!this.type.validContent(this.content))throw new RangeError("Invalid content for node "+this.type.name+": "+this.content.toString().slice(0,50));for(var t=u.none,e=0;e<this.marks.length;e++)t=this.marks[e].addToSet(t);if(!u.sameSet(t,this.marks))throw new RangeError("Invalid collection of marks for node "+this.type.name+": "+this.marks.map((function(t){return t.type.name})));this.content.forEach((function(t){return t.check()}))},A.prototype.toJSON=function(){var t={type:this.type.name};for(var e in this.attrs){t.attrs=this.attrs;break}return this.content.size&&(t.content=this.content.toJSON()),this.marks.length&&(t.marks=this.marks.map((function(t){return t.toJSON()}))),t},A.fromJSON=function(t,e){if(!e)throw new RangeError("Invalid input for Node.fromJSON");var n=null;if(e.marks){if(!Array.isArray(e.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=e.marks.map(t.markFromJSON)}if("text"==e.type){if("string"!=typeof e.text)throw new RangeError("Invalid text node in JSON");return t.text(e.text,n)}var r=i.fromJSON(t,e.content);return t.nodeType(e.type).create(e.attrs,r,n)},Object.defineProperties(A.prototype,D);var E=function(t){function e(e,n,r,o){if(t.call(this,e,n,null,o),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={textContent:{configurable:!0},nodeSize:{configurable:!0}};return e.prototype.toString=function(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):R(this.marks,JSON.stringify(this.text))},n.textContent.get=function(){return this.text},e.prototype.textBetween=function(t,e){return this.text.slice(t,e)},n.nodeSize.get=function(){return this.text.length},e.prototype.mark=function(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)},e.prototype.withText=function(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)},e.prototype.cut=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=this.text.length),0==t&&e==this.text.length?this:this.withText(this.text.slice(t,e))},e.prototype.eq=function(t){return this.sameMarkup(t)&&this.text==t.text},e.prototype.toJSON=function(){var e=t.prototype.toJSON.call(this);return e.text=this.text,e},Object.defineProperties(e.prototype,n),e}(A);function R(t,e){for(var n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}var _=function(t){this.validEnd=t,this.next=[],this.wrapCache=[]},I={inlineContent:{configurable:!0},defaultType:{configurable:!0},edgeCount:{configurable:!0}};_.parse=function(t,e){var n=new z(t,e);if(null==n.next)return _.empty;var r=$(n);n.next&&n.err("Unexpected trailing text");var o=function(t){var e=Object.create(null);return function n(r){var o=[];r.forEach((function(e){t[e].forEach((function(e){var n=e.term,r=e.to;if(n){var i=o.indexOf(n),s=i>-1&&o[i+1];W(t,r).forEach((function(t){s||o.push(n,s=[]),-1==s.indexOf(t)&&s.push(t)}))}}))}));for(var i=e[r.join(",")]=new _(r.indexOf(t.length-1)>-1),s=0;s<o.length;s+=2){var a=o[s+1].sort(j);i.next.push(o[s],e[a.join(",")]||n(a))}return i}(W(t,0))}(function(t){var e=[[]];return o(function t(e,i){if("choice"==e.type)return e.exprs.reduce((function(e,n){return e.concat(t(n,i))}),[]);if("seq"==e.type)for(var s=0;;s++){var a=t(e.exprs[s],i);if(s==e.exprs.length-1)return a;o(a,i=n())}else{if("star"==e.type){var c=n();return r(i,c),o(t(e.expr,c),c),[r(c)]}if("plus"==e.type){var l=n();return o(t(e.expr,i),l),o(t(e.expr,l),l),[r(l)]}if("opt"==e.type)return[r(i)].concat(t(e.expr,i));if("range"==e.type){for(var u=i,p=0;p<e.min;p++){var f=n();o(t(e.expr,u),f),u=f}if(-1==e.max)o(t(e.expr,u),u);else for(var d=e.min;d<e.max;d++){var h=n();r(u,h),o(t(e.expr,u),h),u=h}return[r(u)]}if("name"==e.type)return[r(i,null,e.value)]}}(t,0),n()),e;function n(){return e.push([])-1}function r(t,n,r){var o={term:r,to:n};return e[t].push(o),o}function o(t,e){t.forEach((function(t){return t.to=e}))}}(r));return function(t,e){for(var n=0,r=[t];n<r.length;n++){for(var o=r[n],i=!o.validEnd,s=[],a=0;a<o.next.length;a+=2){var c=o.next[a],l=o.next[a+1];s.push(c.name),!i||c.isText||c.hasRequiredAttrs()||(i=!1),-1==r.indexOf(l)&&r.push(l)}i&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(o,n),o},_.prototype.matchType=function(t){for(var e=0;e<this.next.length;e+=2)if(this.next[e]==t)return this.next[e+1];return null},_.prototype.matchFragment=function(t,e,n){void 0===e&&(e=0),void 0===n&&(n=t.childCount);for(var r=this,o=e;r&&o<n;o++)r=r.matchType(t.child(o).type);return r},I.inlineContent.get=function(){var t=this.next[0];return!!t&&t.isInline},I.defaultType.get=function(){for(var t=0;t<this.next.length;t+=2){var e=this.next[t];if(!e.isText&&!e.hasRequiredAttrs())return e}},_.prototype.compatible=function(t){for(var e=0;e<this.next.length;e+=2)for(var n=0;n<t.next.length;n+=2)if(this.next[e]==t.next[n])return!0;return!1},_.prototype.fillBefore=function(t,e,n){void 0===e&&(e=!1),void 0===n&&(n=0);var r=[this];return function o(s,a){var c=s.matchFragment(t,n);if(c&&(!e||c.validEnd))return i.from(a.map((function(t){return t.createAndFill()})));for(var l=0;l<s.next.length;l+=2){var u=s.next[l],p=s.next[l+1];if(!u.isText&&!u.hasRequiredAttrs()&&-1==r.indexOf(p)){r.push(p);var f=o(p,a.concat(u));if(f)return f}}}(this,[])},_.prototype.findWrapping=function(t){for(var e=0;e<this.wrapCache.length;e+=2)if(this.wrapCache[e]==t)return this.wrapCache[e+1];var n=this.computeWrapping(t);return this.wrapCache.push(t,n),n},_.prototype.computeWrapping=function(t){for(var e=Object.create(null),n=[{match:this,type:null,via:null}];n.length;){var r=n.shift(),o=r.match;if(o.matchType(t)){for(var i=[],s=r;s.type;s=s.via)i.push(s.type);return i.reverse()}for(var a=0;a<o.next.length;a+=2){var c=o.next[a];c.isLeaf||c.hasRequiredAttrs()||c.name in e||r.type&&!o.next[a+1].validEnd||(n.push({match:c.contentMatch,type:c,via:r}),e[c.name]=!0)}}},I.edgeCount.get=function(){return this.next.length>>1},_.prototype.edge=function(t){var e=t<<1;if(e>=this.next.length)throw new RangeError("There's no "+t+"th edge in this content match");return{type:this.next[e],next:this.next[e+1]}},_.prototype.toString=function(){var t=[];return function e(n){t.push(n);for(var r=1;r<n.next.length;r+=2)-1==t.indexOf(n.next[r])&&e(n.next[r])}(this),t.map((function(e,n){for(var r=n+(e.validEnd?"*":" ")+" ",o=0;o<e.next.length;o+=2)r+=(o?", ":"")+e.next[o].name+"->"+t.indexOf(e.next[o+1]);return r})).join("\n")},Object.defineProperties(_.prototype,I),_.empty=new _(!0);var z=function(t,e){this.string=t,this.nodeTypes=e,this.inline=null,this.pos=0,this.tokens=t.split(/\s*(?=\b|\W|$)/),""==this.tokens[this.tokens.length-1]&&this.tokens.pop(),""==this.tokens[0]&&this.tokens.shift()},P={next:{configurable:!0}};function $(t){var e=[];do{e.push(F(t))}while(t.eat("|"));return 1==e.length?e[0]:{type:"choice",exprs:e}}function F(t){var e=[];do{e.push(B(t))}while(t.next&&")"!=t.next&&"|"!=t.next);return 1==e.length?e[0]:{type:"seq",exprs:e}}function B(t){for(var e=function(t){if(t.eat("(")){var e=$(t);return t.eat(")")||t.err("Missing closing paren"),e}if(!/\W/.test(t.next)){var n=function(t,e){var n=t.nodeTypes,r=n[e];if(r)return[r];var o=[];for(var i in n){var s=n[i];s.groups.indexOf(e)>-1&&o.push(s)}0==o.length&&t.err("No node type or group '"+e+"' found");return o}(t,t.next).map((function(e){return null==t.inline?t.inline=e.isInline:t.inline!=e.isInline&&t.err("Mixing inline and block content"),{type:"name",value:e}}));return t.pos++,1==n.length?n[0]:{type:"choice",exprs:n}}t.err("Unexpected token '"+t.next+"'")}(t);;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else{if(!t.eat("{"))break;e=V(t,e)}return e}function L(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");var e=Number(t.next);return t.pos++,e}function V(t,e){var n=L(t),r=n;return t.eat(",")&&(r="}"!=t.next?L(t):-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function j(t,e){return e-t}function W(t,e){var n=[];return function e(r){var o=t[r];if(1==o.length&&!o[0].term)return e(o[0].to);n.push(r);for(var i=0;i<o.length;i++){var s=o[i],a=s.term,c=s.to;a||-1!=n.indexOf(c)||e(c)}}(e),n.sort(j)}function K(t){var e=Object.create(null);for(var n in t){var r=t[n];if(!r.hasDefault)return null;e[n]=r.default}return e}function q(t,e){var n=Object.create(null);for(var r in t){var o=e&&e[r];if(void 0===o){var i=t[r];if(!i.hasDefault)throw new RangeError("No value supplied for attribute "+r);o=i.default}n[r]=o}return n}function H(t){var e=Object.create(null);if(t)for(var n in t)e[n]=new G(t[n]);return e}P.next.get=function(){return this.tokens[this.pos]},z.prototype.eat=function(t){return this.next==t&&(this.pos++||!0)},z.prototype.err=function(t){throw new SyntaxError(t+" (in content expression '"+this.string+"')")},Object.defineProperties(z.prototype,P);var J=function(t,e,n){this.name=t,this.schema=e,this.spec=n,this.groups=n.group?n.group.split(" "):[],this.attrs=H(n.attrs),this.defaultAttrs=K(this.attrs),this.contentMatch=null,this.markSet=null,this.inlineContent=null,this.isBlock=!(n.inline||"text"==t),this.isText="text"==t},U={isInline:{configurable:!0},isTextblock:{configurable:!0},isLeaf:{configurable:!0},isAtom:{configurable:!0},whitespace:{configurable:!0}};U.isInline.get=function(){return!this.isBlock},U.isTextblock.get=function(){return this.isBlock&&this.inlineContent},U.isLeaf.get=function(){return this.contentMatch==_.empty},U.isAtom.get=function(){return this.isLeaf||this.spec.atom},U.whitespace.get=function(){return this.spec.whitespace||(this.spec.code?"pre":"normal")},J.prototype.hasRequiredAttrs=function(){for(var t in this.attrs)if(this.attrs[t].isRequired)return!0;return!1},J.prototype.compatibleContent=function(t){return this==t||this.contentMatch.compatible(t.contentMatch)},J.prototype.computeAttrs=function(t){return!t&&this.defaultAttrs?this.defaultAttrs:q(this.attrs,t)},J.prototype.create=function(t,e,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new A(this,this.computeAttrs(t),i.from(e),u.setFrom(n))},J.prototype.createChecked=function(t,e,n){if(e=i.from(e),!this.validContent(e))throw new RangeError("Invalid content for node "+this.name);return new A(this,this.computeAttrs(t),e,u.setFrom(n))},J.prototype.createAndFill=function(t,e,n){if(t=this.computeAttrs(t),(e=i.from(e)).size){var r=this.contentMatch.fillBefore(e);if(!r)return null;e=r.append(e)}var o=this.contentMatch.matchFragment(e).fillBefore(i.empty,!0);return o?new A(this,t,e.append(o),u.setFrom(n)):null},J.prototype.validContent=function(t){var e=this.contentMatch.matchFragment(t);if(!e||!e.validEnd)return!1;for(var n=0;n<t.childCount;n++)if(!this.allowsMarks(t.child(n).marks))return!1;return!0},J.prototype.allowsMarkType=function(t){return null==this.markSet||this.markSet.indexOf(t)>-1},J.prototype.allowsMarks=function(t){if(null==this.markSet)return!0;for(var e=0;e<t.length;e++)if(!this.allowsMarkType(t[e].type))return!1;return!0},J.prototype.allowedMarks=function(t){if(null==this.markSet)return t;for(var e,n=0;n<t.length;n++)this.allowsMarkType(t[n].type)?e&&e.push(t[n]):e||(e=t.slice(0,n));return e?e.length?e:u.empty:t},J.compile=function(t,e){var n=Object.create(null);t.forEach((function(t,r){return n[t]=new J(t,e,r)}));var r=e.spec.topNode||"doc";if(!n[r])throw new RangeError("Schema is missing its top node type ('"+r+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(var o in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n},Object.defineProperties(J.prototype,U);var G=function(t){this.hasDefault=Object.prototype.hasOwnProperty.call(t,"default"),this.default=t.default},X={isRequired:{configurable:!0}};X.isRequired.get=function(){return!this.hasDefault},Object.defineProperties(G.prototype,X);var Y=function(t,e,n,r){this.name=t,this.schema=n,this.spec=r,this.attrs=H(r.attrs),this.rank=e,this.excluded=null;var o=K(this.attrs);this.instance=o&&new u(this,o)};Y.prototype.create=function(t){return!t&&this.instance?this.instance:new u(this,q(this.attrs,t))},Y.compile=function(t,e){var n=Object.create(null),r=0;return t.forEach((function(t,o){return n[t]=new Y(t,r++,e,o)})),n},Y.prototype.removeFromSet=function(t){for(var e=0;e<t.length;e++)t[e].type==this&&(t=t.slice(0,e).concat(t.slice(e+1)),e--);return t},Y.prototype.isInSet=function(t){for(var e=0;e<t.length;e++)if(t[e].type==this)return t[e]},Y.prototype.excludes=function(t){return this.excluded.indexOf(t)>-1};var Q=function(t){for(var e in this.spec={},t)this.spec[e]=t[e];this.spec.nodes=o.from(t.nodes),this.spec.marks=o.from(t.marks),this.nodes=J.compile(this.spec.nodes,this),this.marks=Y.compile(this.spec.marks,this);var n=Object.create(null);for(var r in this.nodes){if(r in this.marks)throw new RangeError(r+" can not be both a node and a mark");var i=this.nodes[r],s=i.spec.content||"",a=i.spec.marks;i.contentMatch=n[s]||(n[s]=_.parse(s,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.markSet="_"==a?null:a?Z(this,a.split(" ")):""!=a&&i.inlineContent?null:[]}for(var c in this.marks){var l=this.marks[c],u=l.spec.excludes;l.excluded=null==u?[l]:""==u?[]:Z(this,u.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached=Object.create(null),this.cached.wrappings=Object.create(null)};function Z(t,e){for(var n=[],r=0;r<e.length;r++){var o=e[r],i=t.marks[o],s=i;if(i)n.push(i);else for(var a in t.marks){var c=t.marks[a];("_"==o||c.spec.group&&c.spec.group.split(" ").indexOf(o)>-1)&&n.push(s=c)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}Q.prototype.node=function(t,e,n,r){if("string"==typeof t)t=this.nodeType(t);else{if(!(t instanceof J))throw new RangeError("Invalid node type: "+t);if(t.schema!=this)throw new RangeError("Node type from different schema used ("+t.name+")")}return t.createChecked(e,n,r)},Q.prototype.text=function(t,e){var n=this.nodes.text;return new E(n,n.defaultAttrs,t,u.setFrom(e))},Q.prototype.mark=function(t,e){return"string"==typeof t&&(t=this.marks[t]),t.create(e)},Q.prototype.nodeFromJSON=function(t){return A.fromJSON(this,t)},Q.prototype.markFromJSON=function(t){return u.fromJSON(this,t)},Q.prototype.nodeType=function(t){var e=this.nodes[t];if(!e)throw new RangeError("Unknown node type: "+t);return e};var tt=function(t,e){var n=this;this.schema=t,this.rules=e,this.tags=[],this.styles=[],e.forEach((function(t){t.tag?n.tags.push(t):t.style&&n.styles.push(t)})),this.normalizeLists=!this.tags.some((function(e){if(!/^(ul|ol)\b/.test(e.tag)||!e.node)return!1;var n=t.nodes[e.node];return n.contentMatch.matchType(n)}))};tt.prototype.parse=function(t,e){void 0===e&&(e={});var n=new st(this,e,!1);return n.addAll(t,null,e.from,e.to),n.finish()},tt.prototype.parseSlice=function(t,e){void 0===e&&(e={});var n=new st(this,e,!0);return n.addAll(t,null,e.from,e.to),f.maxOpen(n.finish())},tt.prototype.matchTag=function(t,e,n){for(var r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){var o=this.tags[r];if(ct(t,o.tag)&&(void 0===o.namespace||t.namespaceURI==o.namespace)&&(!o.context||e.matchesContext(o.context))){if(o.getAttrs){var i=o.getAttrs(t);if(!1===i)continue;o.attrs=i}return o}}},tt.prototype.matchStyle=function(t,e,n,r){for(var o=r?this.styles.indexOf(r)+1:0;o<this.styles.length;o++){var i=this.styles[o];if(!(0!=i.style.indexOf(t)||i.context&&!n.matchesContext(i.context)||i.style.length>t.length&&(61!=i.style.charCodeAt(t.length)||i.style.slice(t.length+1)!=e))){if(i.getAttrs){var s=i.getAttrs(e);if(!1===s)continue;i.attrs=s}return i}}},tt.schemaRules=function(t){var e=[];function n(t){for(var n=null==t.priority?50:t.priority,r=0;r<e.length;r++){var o=e[r];if((null==o.priority?50:o.priority)<n)break}e.splice(r,0,t)}var r=function(e){var r=t.marks[e].spec.parseDOM;r&&r.forEach((function(t){n(t=lt(t)),t.mark=e}))};for(var o in t.marks)r(o);var i;for(var s in t.nodes)i=void 0,(i=t.nodes[s].spec.parseDOM)&&i.forEach((function(t){n(t=lt(t)),t.node=s}));return e},tt.fromSchema=function(t){return t.cached.domParser||(t.cached.domParser=new tt(t,tt.schemaRules(t)))};var et={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},nt={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},rt={ol:!0,ul:!0};function ot(t,e,n){return null!=e?(e?1:0)|("full"===e?2:0):t&&"pre"==t.whitespace?3:-5&n}var it=function(t,e,n,r,o,i,s){this.type=t,this.attrs=e,this.solid=o,this.match=i||(4&s?null:t.contentMatch),this.options=s,this.content=[],this.marks=n,this.activeMarks=u.none,this.pendingMarks=r,this.stashMarks=[]};it.prototype.findWrapping=function(t){if(!this.match){if(!this.type)return[];var e=this.type.contentMatch.fillBefore(i.from(t));if(!e){var n,r=this.type.contentMatch;return(n=r.findWrapping(t.type))?(this.match=r,n):null}this.match=this.type.contentMatch.matchFragment(e)}return this.match.findWrapping(t.type)},it.prototype.finish=function(t){if(!(1&this.options)){var e,n=this.content[this.content.length-1];n&&n.isText&&(e=/[ \t\r\n\u000c]+$/.exec(n.text))&&(n.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)))}var r=i.from(this.content);return!t&&this.match&&(r=r.append(this.match.fillBefore(i.empty,!0))),this.type?this.type.create(this.attrs,r,this.marks):r},it.prototype.popFromStashMark=function(t){for(var e=this.stashMarks.length-1;e>=0;e--)if(t.eq(this.stashMarks[e]))return this.stashMarks.splice(e,1)[0]},it.prototype.applyPending=function(t){for(var e=0,n=this.pendingMarks;e<n.length;e++){var r=n[e];(this.type?this.type.allowsMarkType(r.type):ut(r.type,t))&&!r.isInSet(this.activeMarks)&&(this.activeMarks=r.addToSet(this.activeMarks),this.pendingMarks=r.removeFromSet(this.pendingMarks))}},it.prototype.inlineContext=function(t){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:t.parentNode&&!et.hasOwnProperty(t.parentNode.nodeName.toLowerCase())};var st=function(t,e,n){this.parser=t,this.options=e,this.isOpen=n;var r,o=e.topNode,i=ot(null,e.preserveWhitespace,0)|(n?4:0);r=o?new it(o.type,o.attrs,u.none,u.none,!0,e.topMatch||o.type.contentMatch,i):new it(n?null:t.schema.topNodeType,null,u.none,u.none,!0,null,i),this.nodes=[r],this.open=0,this.find=e.findPositions,this.needsBlock=!1},at={top:{configurable:!0},currentPos:{configurable:!0}};function ct(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function lt(t){var e={};for(var n in t)e[n]=t[n];return e}function ut(t,e){var n=e.schema.nodes,r=function(r){var o=n[r];if(o.allowsMarkType(t)){var i=[],s=function(t){i.push(t);for(var n=0;n<t.edgeCount;n++){var r=t.edge(n),o=r.type,a=r.next;if(o==e)return!0;if(i.indexOf(a)<0&&s(a))return!0}};return s(o.contentMatch)?{v:!0}:void 0}};for(var o in n){var i=r(o);if(i)return i.v}}at.top.get=function(){return this.nodes[this.open]},st.prototype.addDOM=function(t){if(3==t.nodeType)this.addTextNode(t);else if(1==t.nodeType){var e=t.getAttribute("style"),n=e?this.readStyles(function(t){var e,n=/\s*([\w-]+)\s*:\s*([^;]+)/g,r=[];for(;e=n.exec(t);)r.push(e[1],e[2].trim());return r}(e)):null,r=this.top;if(null!=n)for(var o=0;o<n.length;o++)this.addPendingMark(n[o]);if(this.addElement(t),null!=n)for(var i=0;i<n.length;i++)this.removePendingMark(n[i],r)}},st.prototype.addTextNode=function(t){var e=t.nodeValue,n=this.top;if(2&n.options||n.inlineContext(t)||/[^ \t\r\n\u000c]/.test(e)){if(1&n.options)e=2&n.options?e.replace(/\r\n?/g,"\n"):e.replace(/\r?\n|\r/g," ");else if(e=e.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(e)&&this.open==this.nodes.length-1){var r=n.content[n.content.length-1],o=t.previousSibling;(!r||o&&"BR"==o.nodeName||r.isText&&/[ \t\r\n\u000c]$/.test(r.text))&&(e=e.slice(1))}e&&this.insertNode(this.parser.schema.text(e)),this.findInText(t)}else this.findInside(t)},st.prototype.addElement=function(t,e){var n,r=t.nodeName.toLowerCase();rt.hasOwnProperty(r)&&this.parser.normalizeLists&&function(t){for(var e=t.firstChild,n=null;e;e=e.nextSibling){var r=1==e.nodeType?e.nodeName.toLowerCase():null;r&&rt.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):"li"==r?n=e:r&&(n=null)}}(t);var o=this.options.ruleFromNode&&this.options.ruleFromNode(t)||(n=this.parser.matchTag(t,this,e));if(o?o.ignore:nt.hasOwnProperty(r))this.findInside(t),this.ignoreFallback(t);else if(!o||o.skip||o.closeParent){o&&o.closeParent?this.open=Math.max(0,this.open-1):o&&o.skip.nodeType&&(t=o.skip);var i,s=this.top,a=this.needsBlock;if(et.hasOwnProperty(r))i=!0,s.type||(this.needsBlock=!0);else if(!t.firstChild)return void this.leafFallback(t);this.addAll(t),i&&this.sync(s),this.needsBlock=a}else this.addElementByRule(t,o,!1===o.consuming?n:null)},st.prototype.leafFallback=function(t){"BR"==t.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(t.ownerDocument.createTextNode("\n"))},st.prototype.ignoreFallback=function(t){"BR"!=t.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"))},st.prototype.readStyles=function(t){var e=u.none;t:for(var n=0;n<t.length;n+=2)for(var r=null;;){var o=this.parser.matchStyle(t[n],t[n+1],this,r);if(!o)continue t;if(o.ignore)return null;if(e=this.parser.schema.marks[o.mark].create(o.attrs).addToSet(e),!1!==o.consuming)break;r=o}return e},st.prototype.addElementByRule=function(t,e,n){var r,o,i,s=this;e.node?(o=this.parser.schema.nodes[e.node]).isLeaf?this.insertNode(o.create(e.attrs))||this.leafFallback(t):r=this.enter(o,e.attrs,e.preserveWhitespace):(i=this.parser.schema.marks[e.mark].create(e.attrs),this.addPendingMark(i));var a=this.top;if(o&&o.isLeaf)this.findInside(t);else if(n)this.addElement(t,n);else if(e.getContent)this.findInside(t),e.getContent(t,this.parser.schema).forEach((function(t){return s.insertNode(t)}));else{var c=e.contentElement;"string"==typeof c?c=t.querySelector(c):"function"==typeof c&&(c=c(t)),c||(c=t),this.findAround(t,c,!0),this.addAll(c,r)}r&&(this.sync(a),this.open--),i&&this.removePendingMark(i,a)},st.prototype.addAll=function(t,e,n,r){for(var o=n||0,i=n?t.childNodes[n]:t.firstChild,s=null==r?null:t.childNodes[r];i!=s;i=i.nextSibling,++o)this.findAtPoint(t,o),this.addDOM(i),e&&et.hasOwnProperty(i.nodeName.toLowerCase())&&this.sync(e);this.findAtPoint(t,o)},st.prototype.findPlace=function(t){for(var e,n,r=this.open;r>=0;r--){var o=this.nodes[r],i=o.findWrapping(t);if(i&&(!e||e.length>i.length)&&(e=i,n=o,!i.length))break;if(o.solid)break}if(!e)return!1;this.sync(n);for(var s=0;s<e.length;s++)this.enterInner(e[s],null,!1);return!0},st.prototype.insertNode=function(t){if(t.isInline&&this.needsBlock&&!this.top.type){var e=this.textblockFromContext();e&&this.enterInner(e)}if(this.findPlace(t)){this.closeExtra();var n=this.top;n.applyPending(t.type),n.match&&(n.match=n.match.matchType(t.type));for(var r=n.activeMarks,o=0;o<t.marks.length;o++)n.type&&!n.type.allowsMarkType(t.marks[o].type)||(r=t.marks[o].addToSet(r));return n.content.push(t.mark(r)),!0}return!1},st.prototype.enter=function(t,e,n){var r=this.findPlace(t.create(e));return r&&this.enterInner(t,e,!0,n),r},st.prototype.enterInner=function(t,e,n,r){this.closeExtra();var o=this.top;o.applyPending(t),o.match=o.match&&o.match.matchType(t,e);var i=ot(t,r,o.options);4&o.options&&0==o.content.length&&(i|=4),this.nodes.push(new it(t,e,o.activeMarks,o.pendingMarks,n,null,i)),this.open++},st.prototype.closeExtra=function(t){var e=this.nodes.length-1;if(e>this.open){for(;e>this.open;e--)this.nodes[e-1].content.push(this.nodes[e].finish(t));this.nodes.length=this.open+1}},st.prototype.finish=function(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)},st.prototype.sync=function(t){for(var e=this.open;e>=0;e--)if(this.nodes[e]==t)return void(this.open=e)},at.currentPos.get=function(){this.closeExtra();for(var t=0,e=this.open;e>=0;e--){for(var n=this.nodes[e].content,r=n.length-1;r>=0;r--)t+=n[r].nodeSize;e&&t++}return t},st.prototype.findAtPoint=function(t,e){if(this.find)for(var n=0;n<this.find.length;n++)this.find[n].node==t&&this.find[n].offset==e&&(this.find[n].pos=this.currentPos)},st.prototype.findInside=function(t){if(this.find)for(var e=0;e<this.find.length;e++)null==this.find[e].pos&&1==t.nodeType&&t.contains(this.find[e].node)&&(this.find[e].pos=this.currentPos)},st.prototype.findAround=function(t,e,n){if(t!=e&&this.find)for(var r=0;r<this.find.length;r++){if(null==this.find[r].pos&&1==t.nodeType&&t.contains(this.find[r].node))e.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}},st.prototype.findInText=function(t){if(this.find)for(var e=0;e<this.find.length;e++)this.find[e].node==t&&(this.find[e].pos=this.currentPos-(t.nodeValue.length-this.find[e].offset))},st.prototype.matchesContext=function(t){var e=this;if(t.indexOf("|")>-1)return t.split(/\s*\|\s*/).some(this.matchesContext,this);var n=t.split("/"),r=this.options.context,o=!(this.isOpen||r&&r.parent.type!=this.nodes[0].type),i=-(r?r.depth+1:0)+(o?0:1),s=function(t,a){for(;t>=0;t--){var c=n[t];if(""==c){if(t==n.length-1||0==t)continue;for(;a>=i;a--)if(s(t-1,a))return!0;return!1}var l=a>0||0==a&&o?e.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!l||l.name!=c&&-1==l.groups.indexOf(c))return!1;a--}return!0};return s(n.length-1,this.open)},st.prototype.textblockFromContext=function(){var t=this.options.context;if(t)for(var e=t.depth;e>=0;e--){var n=t.node(e).contentMatchAt(t.indexAfter(e)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(var r in this.parser.schema.nodes){var o=this.parser.schema.nodes[r];if(o.isTextblock&&o.defaultAttrs)return o}},st.prototype.addPendingMark=function(t){var e=function(t,e){for(var n=0;n<e.length;n++)if(t.eq(e[n]))return e[n]}(t,this.top.pendingMarks);e&&this.top.stashMarks.push(e),this.top.pendingMarks=t.addToSet(this.top.pendingMarks)},st.prototype.removePendingMark=function(t,e){for(var n=this.open;n>=0;n--){var r=this.nodes[n];if(r.pendingMarks.lastIndexOf(t)>-1)r.pendingMarks=t.removeFromSet(r.pendingMarks);else{r.activeMarks=t.removeFromSet(r.activeMarks);var o=r.popFromStashMark(t);o&&r.type&&r.type.allowsMarkType(o.type)&&(r.activeMarks=o.addToSet(r.activeMarks))}if(r==e)break}},Object.defineProperties(st.prototype,at);var pt=function(t,e){this.nodes=t||{},this.marks=e||{}};function ft(t){var e={};for(var n in t){var r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function dt(t){return t.document||window.document}pt.prototype.serializeFragment=function(t,e,n){var r=this;void 0===e&&(e={}),n||(n=dt(e).createDocumentFragment());var o=n,i=null;return t.forEach((function(t){if(i||t.marks.length){i||(i=[]);for(var n=0,s=0;n<i.length&&s<t.marks.length;){var a=t.marks[s];if(r.marks[a.type.name]){if(!a.eq(i[n])||!1===a.type.spec.spanning)break;n+=2,s++}else s++}for(;n<i.length;)o=i.pop(),i.pop();for(;s<t.marks.length;){var c=t.marks[s++],l=r.serializeMark(c,t.isInline,e);l&&(i.push(c,o),o.appendChild(l.dom),o=l.contentDOM||l.dom)}}o.appendChild(r.serializeNodeInner(t,e))})),n},pt.prototype.serializeNodeInner=function(t,e){void 0===e&&(e={});var n=pt.renderSpec(dt(e),this.nodes[t.type.name](t)),r=n.dom,o=n.contentDOM;if(o){if(t.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");e.onContent?e.onContent(t,o,e):this.serializeFragment(t.content,e,o)}return r},pt.prototype.serializeNode=function(t,e){void 0===e&&(e={});for(var n=this.serializeNodeInner(t,e),r=t.marks.length-1;r>=0;r--){var o=this.serializeMark(t.marks[r],t.isInline,e);o&&((o.contentDOM||o.dom).appendChild(n),n=o.dom)}return n},pt.prototype.serializeMark=function(t,e,n){void 0===n&&(n={});var r=this.marks[t.type.name];return r&&pt.renderSpec(dt(n),r(t,e))},pt.renderSpec=function(t,e,n){if(void 0===n&&(n=null),"string"==typeof e)return{dom:t.createTextNode(e)};if(null!=e.nodeType)return{dom:e};if(e.dom&&null!=e.dom.nodeType)return e;var r=e[0],o=r.indexOf(" ");o>0&&(n=r.slice(0,o),r=r.slice(o+1));var i=null,s=n?t.createElementNS(n,r):t.createElement(r),a=e[1],c=1;if(a&&"object"==typeof a&&null==a.nodeType&&!Array.isArray(a))for(var l in c=2,a)if(null!=a[l]){var u=l.indexOf(" ");u>0?s.setAttributeNS(l.slice(0,u),l.slice(u+1),a[l]):s.setAttribute(l,a[l])}for(var p=c;p<e.length;p++){var f=e[p];if(0===f){if(p<e.length-1||p>c)throw new RangeError("Content hole must be the only child of its parent node");return{dom:s,contentDOM:s}}var d=pt.renderSpec(t,f,n),h=d.dom,m=d.contentDOM;if(s.appendChild(h),m){if(i)throw new RangeError("Multiple content holes");i=m}}return{dom:s,contentDOM:i}},pt.fromSchema=function(t){return t.cached.domSerializer||(t.cached.domSerializer=new pt(this.nodesFromSchema(t),this.marksFromSchema(t)))},pt.nodesFromSchema=function(t){var e=ft(t.nodes);return e.text||(e.text=function(t){return t.text}),e},pt.marksFromSchema=function(t){return ft(t.marks)}},function(t,e,n){"use strict";n.r(e),n.d(e,"AllSelection",(function(){return d})),n.d(e,"EditorState",(function(){return k})),n.d(e,"NodeSelection",(function(){return p})),n.d(e,"Plugin",(function(){return M})),n.d(e,"PluginKey",(function(){return N})),n.d(e,"Selection",(function(){return s})),n.d(e,"SelectionRange",(function(){return c})),n.d(e,"TextSelection",(function(){return l})),n.d(e,"Transaction",(function(){return g}));var r=n(0),o=n(2),i=Object.create(null),s=function(t,e,n){this.ranges=n||[new c(t.min(e),t.max(e))],this.$anchor=t,this.$head=e},a={anchor:{configurable:!0},head:{configurable:!0},from:{configurable:!0},to:{configurable:!0},$from:{configurable:!0},$to:{configurable:!0},empty:{configurable:!0}};a.anchor.get=function(){return this.$anchor.pos},a.head.get=function(){return this.$head.pos},a.from.get=function(){return this.$from.pos},a.to.get=function(){return this.$to.pos},a.$from.get=function(){return this.ranges[0].$from},a.$to.get=function(){return this.ranges[0].$to},a.empty.get=function(){for(var t=this.ranges,e=0;e<t.length;e++)if(t[e].$from.pos!=t[e].$to.pos)return!1;return!0},s.prototype.content=function(){return this.$from.node(0).slice(this.from,this.to,!0)},s.prototype.replace=function(t,e){void 0===e&&(e=r.Slice.empty);for(var n=e.content.lastChild,o=null,i=0;i<e.openEnd;i++)o=n,n=n.lastChild;for(var s=t.steps.length,a=this.ranges,c=0;c<a.length;c++){var l=a[c],u=l.$from,p=l.$to,f=t.mapping.slice(s);t.replaceRange(f.map(u.pos),f.map(p.pos),c?r.Slice.empty:e),0==c&&v(t,s,(n?n.isInline:o&&o.isTextblock)?-1:1)}},s.prototype.replaceWith=function(t,e){for(var n=t.steps.length,r=this.ranges,o=0;o<r.length;o++){var i=r[o],s=i.$from,a=i.$to,c=t.mapping.slice(n),l=c.map(s.pos),u=c.map(a.pos);o?t.deleteRange(l,u):(t.replaceRangeWith(l,u,e),v(t,n,e.isInline?-1:1))}},s.findFrom=function(t,e,n){var r=t.parent.inlineContent?new l(t):m(t.node(0),t.parent,t.pos,t.index(),e,n);if(r)return r;for(var o=t.depth-1;o>=0;o--){var i=e<0?m(t.node(0),t.node(o),t.before(o+1),t.index(o),e,n):m(t.node(0),t.node(o),t.after(o+1),t.index(o)+1,e,n);if(i)return i}},s.near=function(t,e){return void 0===e&&(e=1),this.findFrom(t,e)||this.findFrom(t,-e)||new d(t.node(0))},s.atStart=function(t){return m(t,t,0,0,1)||new d(t)},s.atEnd=function(t){return m(t,t,t.content.size,t.childCount,-1)||new d(t)},s.fromJSON=function(t,e){if(!e||!e.type)throw new RangeError("Invalid input for Selection.fromJSON");var n=i[e.type];if(!n)throw new RangeError("No selection type "+e.type+" defined");return n.fromJSON(t,e)},s.jsonID=function(t,e){if(t in i)throw new RangeError("Duplicate use of selection JSON ID "+t);return i[t]=e,e.prototype.jsonID=t,e},s.prototype.getBookmark=function(){return l.between(this.$anchor,this.$head).getBookmark()},Object.defineProperties(s.prototype,a),s.prototype.visible=!0;var c=function(t,e){this.$from=t,this.$to=e},l=function(t){function e(e,n){void 0===n&&(n=e),t.call(this,e,n)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={$cursor:{configurable:!0}};return n.$cursor.get=function(){return this.$anchor.pos==this.$head.pos?this.$head:null},e.prototype.map=function(n,r){var o=n.resolve(r.map(this.head));if(!o.parent.inlineContent)return t.near(o);var i=n.resolve(r.map(this.anchor));return new e(i.parent.inlineContent?i:o,o)},e.prototype.replace=function(e,n){if(void 0===n&&(n=r.Slice.empty),t.prototype.replace.call(this,e,n),n==r.Slice.empty){var o=this.$from.marksAcross(this.$to);o&&e.ensureMarks(o)}},e.prototype.eq=function(t){return t instanceof e&&t.anchor==this.anchor&&t.head==this.head},e.prototype.getBookmark=function(){return new u(this.anchor,this.head)},e.prototype.toJSON=function(){return{type:"text",anchor:this.anchor,head:this.head}},e.fromJSON=function(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))},e.create=function(t,e,n){void 0===n&&(n=e);var r=t.resolve(e);return new this(r,n==e?r:t.resolve(n))},e.between=function(n,r,o){var i=n.pos-r.pos;if(o&&!i||(o=i>=0?1:-1),!r.parent.inlineContent){var s=t.findFrom(r,o,!0)||t.findFrom(r,-o,!0);if(!s)return t.near(r,o);r=s.$head}return n.parent.inlineContent||(0==i||(n=(t.findFrom(n,-o,!0)||t.findFrom(n,o,!0)).$anchor).pos<r.pos!=i<0)&&(n=r),new e(n,r)},Object.defineProperties(e.prototype,n),e}(s);s.jsonID("text",l);var u=function(t,e){this.anchor=t,this.head=e};u.prototype.map=function(t){return new u(t.map(this.anchor),t.map(this.head))},u.prototype.resolve=function(t){return l.between(t.resolve(this.anchor),t.resolve(this.head))};var p=function(t){function e(e){var n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);t.call(this,e,r),this.node=n}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.map=function(n,r){var o=r.mapResult(this.anchor),i=o.deleted,s=o.pos,a=n.resolve(s);return i?t.near(a):new e(a)},e.prototype.content=function(){return new r.Slice(r.Fragment.from(this.node),0,0)},e.prototype.eq=function(t){return t instanceof e&&t.anchor==this.anchor},e.prototype.toJSON=function(){return{type:"node",anchor:this.anchor}},e.prototype.getBookmark=function(){return new f(this.anchor)},e.fromJSON=function(t,n){if("number"!=typeof n.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new e(t.resolve(n.anchor))},e.create=function(t,e){return new this(t.resolve(e))},e.isSelectable=function(t){return!t.isText&&!1!==t.type.spec.selectable},e}(s);p.prototype.visible=!1,s.jsonID("node",p);var f=function(t){this.anchor=t};f.prototype.map=function(t){var e=t.mapResult(this.anchor),n=e.deleted,r=e.pos;return n?new u(r,r):new f(r)},f.prototype.resolve=function(t){var e=t.resolve(this.anchor),n=e.nodeAfter;return n&&p.isSelectable(n)?new p(e):s.near(e)};var d=function(t){function e(e){t.call(this,e.resolve(0),e.resolve(e.content.size))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.replace=function(e,n){if(void 0===n&&(n=r.Slice.empty),n==r.Slice.empty){e.delete(0,e.doc.content.size);var o=t.atStart(e.doc);o.eq(e.selection)||e.setSelection(o)}else t.prototype.replace.call(this,e,n)},e.prototype.toJSON=function(){return{type:"all"}},e.fromJSON=function(t){return new e(t)},e.prototype.map=function(t){return new e(t)},e.prototype.eq=function(t){return t instanceof e},e.prototype.getBookmark=function(){return h},e}(s);s.jsonID("all",d);var h={map:function(){return this},resolve:function(t){return new d(t)}};function m(t,e,n,r,o,i){if(e.inlineContent)return l.create(t,n);for(var s=r-(o>0?0:1);o>0?s<e.childCount:s>=0;s+=o){var a=e.child(s);if(a.isAtom){if(!i&&p.isSelectable(a))return p.create(t,n-(o<0?a.nodeSize:0))}else{var c=m(t,a,n+o,o<0?a.childCount:0,o,i);if(c)return c}n+=a.nodeSize*o}}function v(t,e,n){var r=t.steps.length-1;if(!(r<e)){var i,a=t.steps[r];if(a instanceof o.ReplaceStep||a instanceof o.ReplaceAroundStep)t.mapping.maps[r].forEach((function(t,e,n,r){null==i&&(i=r)})),t.setSelection(s.near(t.doc.resolve(i),n))}}var g=function(t){function e(e){t.call(this,e.doc),this.time=Date.now(),this.curSelection=e.selection,this.curSelectionFor=0,this.storedMarks=e.storedMarks,this.updated=0,this.meta=Object.create(null)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={selection:{configurable:!0},selectionSet:{configurable:!0},storedMarksSet:{configurable:!0},isGeneric:{configurable:!0},scrolledIntoView:{configurable:!0}};return n.selection.get=function(){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},e.prototype.setSelection=function(t){if(t.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=t,this.curSelectionFor=this.steps.length,this.updated=-3&(1|this.updated),this.storedMarks=null,this},n.selectionSet.get=function(){return(1&this.updated)>0},e.prototype.setStoredMarks=function(t){return this.storedMarks=t,this.updated|=2,this},e.prototype.ensureMarks=function(t){return r.Mark.sameSet(this.storedMarks||this.selection.$from.marks(),t)||this.setStoredMarks(t),this},e.prototype.addStoredMark=function(t){return this.ensureMarks(t.addToSet(this.storedMarks||this.selection.$head.marks()))},e.prototype.removeStoredMark=function(t){return this.ensureMarks(t.removeFromSet(this.storedMarks||this.selection.$head.marks()))},n.storedMarksSet.get=function(){return(2&this.updated)>0},e.prototype.addStep=function(e,n){t.prototype.addStep.call(this,e,n),this.updated=-3&this.updated,this.storedMarks=null},e.prototype.setTime=function(t){return this.time=t,this},e.prototype.replaceSelection=function(t){return this.selection.replace(this,t),this},e.prototype.replaceSelectionWith=function(t,e){var n=this.selection;return!1!==e&&(t=t.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||r.Mark.none))),n.replaceWith(this,t),this},e.prototype.deleteSelection=function(){return this.selection.replace(this),this},e.prototype.insertText=function(t,e,n){void 0===n&&(n=e);var r=this.doc.type.schema;if(null==e)return t?this.replaceSelectionWith(r.text(t),!0):this.deleteSelection();if(!t)return this.deleteRange(e,n);var o=this.storedMarks;if(!o){var i=this.doc.resolve(e);o=n==e?i.marks():i.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(e,n,r.text(t,o)),this.selection.empty||this.setSelection(s.near(this.selection.$to)),this},e.prototype.setMeta=function(t,e){return this.meta["string"==typeof t?t:t.key]=e,this},e.prototype.getMeta=function(t){return this.meta["string"==typeof t?t:t.key]},n.isGeneric.get=function(){for(var t in this.meta)return!1;return!0},e.prototype.scrollIntoView=function(){return this.updated|=4,this},n.scrolledIntoView.get=function(){return(4&this.updated)>0},Object.defineProperties(e.prototype,n),e}(o.Transform);function y(t,e){return e&&t?t.bind(e):t}var w=function(t,e,n){this.name=t,this.init=y(e.init,n),this.apply=y(e.apply,n)},b=[new w("doc",{init:function(t){return t.doc||t.schema.topNodeType.createAndFill()},apply:function(t){return t.doc}}),new w("selection",{init:function(t,e){return t.selection||s.atStart(e.doc)},apply:function(t){return t.selection}}),new w("storedMarks",{init:function(t){return t.storedMarks||null},apply:function(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new w("scrollToSelection",{init:function(){return 0},apply:function(t,e){return t.scrolledIntoView?e+1:e}})],S=function(t,e){var n=this;this.schema=t,this.fields=b.concat(),this.plugins=[],this.pluginsByKey=Object.create(null),e&&e.forEach((function(t){if(n.pluginsByKey[t.key])throw new RangeError("Adding different instances of a keyed plugin ("+t.key+")");n.plugins.push(t),n.pluginsByKey[t.key]=t,t.spec.state&&n.fields.push(new w(t.key,t.spec.state,t))}))},k=function(t){this.config=t},x={schema:{configurable:!0},plugins:{configurable:!0},tr:{configurable:!0}};x.schema.get=function(){return this.config.schema},x.plugins.get=function(){return this.config.plugins},k.prototype.apply=function(t){return this.applyTransaction(t).state},k.prototype.filterTransaction=function(t,e){void 0===e&&(e=-1);for(var n=0;n<this.config.plugins.length;n++)if(n!=e){var r=this.config.plugins[n];if(r.spec.filterTransaction&&!r.spec.filterTransaction.call(r,t,this))return!1}return!0},k.prototype.applyTransaction=function(t){if(!this.filterTransaction(t))return{state:this,transactions:[]};for(var e=[t],n=this.applyInner(t),r=null;;){for(var o=!1,i=0;i<this.config.plugins.length;i++){var s=this.config.plugins[i];if(s.spec.appendTransaction){var a=r?r[i].n:0,c=r?r[i].state:this,l=a<e.length&&s.spec.appendTransaction.call(s,a?e.slice(a):e,c,n);if(l&&n.filterTransaction(l,i)){if(l.setMeta("appendedTransaction",t),!r){r=[];for(var u=0;u<this.config.plugins.length;u++)r.push(u<i?{state:n,n:e.length}:{state:this,n:0})}e.push(l),n=n.applyInner(l),o=!0}r&&(r[i]={state:n,n:e.length})}}if(!o)return{state:n,transactions:e}}},k.prototype.applyInner=function(t){if(!t.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");for(var e=new k(this.config),n=this.config.fields,r=0;r<n.length;r++){var o=n[r];e[o.name]=o.apply(t,this[o.name],this,e)}for(var i=0;i<C.length;i++)C[i](this,t,e);return e},x.tr.get=function(){return new g(this)},k.create=function(t){for(var e=new S(t.doc?t.doc.type.schema:t.schema,t.plugins),n=new k(e),r=0;r<e.fields.length;r++)n[e.fields[r].name]=e.fields[r].init(t,n);return n},k.prototype.reconfigure=function(t){for(var e=new S(this.schema,t.plugins),n=e.fields,r=new k(e),o=0;o<n.length;o++){var i=n[o].name;r[i]=this.hasOwnProperty(i)?this[i]:n[o].init(t,r)}return r},k.prototype.toJSON=function(t){var e={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(e.storedMarks=this.storedMarks.map((function(t){return t.toJSON()}))),t&&"object"==typeof t)for(var n in t){if("doc"==n||"selection"==n)throw new RangeError("The JSON fields `doc` and `selection` are reserved");var r=t[n],o=r.spec.state;o&&o.toJSON&&(e[n]=o.toJSON.call(r,this[r.key]))}return e},k.fromJSON=function(t,e,n){if(!e)throw new RangeError("Invalid input for EditorState.fromJSON");if(!t.schema)throw new RangeError("Required config field 'schema' missing");var o=new S(t.schema,t.plugins),i=new k(o);return o.fields.forEach((function(o){if("doc"==o.name)i.doc=r.Node.fromJSON(t.schema,e.doc);else if("selection"==o.name)i.selection=s.fromJSON(i.doc,e.selection);else if("storedMarks"==o.name)e.storedMarks&&(i.storedMarks=e.storedMarks.map(t.schema.markFromJSON));else{if(n)for(var a in n){var c=n[a],l=c.spec.state;if(c.key==o.name&&l&&l.fromJSON&&Object.prototype.hasOwnProperty.call(e,a))return void(i[o.name]=l.fromJSON.call(c,t,e[a],i))}i[o.name]=o.init(t,i)}})),i},k.addApplyListener=function(t){C.push(t)},k.removeApplyListener=function(t){var e=C.indexOf(t);e>-1&&C.splice(e,1)},Object.defineProperties(k.prototype,x);var C=[];var M=function(t){this.props={},t.props&&function t(e,n,r){for(var o in e){var i=e[o];i instanceof Function?i=i.bind(n):"handleDOMEvents"==o&&(i=t(i,n,{})),r[o]=i}return r}(t.props,this,this.props),this.spec=t,this.key=t.key?t.key.key:T("plugin")};M.prototype.getState=function(t){return t[this.key]};var O=Object.create(null);function T(t){return t in O?t+"$"+ ++O[t]:(O[t]=0,t+"$")}var N=function(t){void 0===t&&(t="key"),this.key=T(t)};N.prototype.get=function(t){return t.config.pluginsByKey[this.key]},N.prototype.getState=function(t){return t[this.key]}},function(t,e,n){"use strict";n.r(e),n.d(e,"AddMarkStep",(function(){return D})),n.d(e,"MapResult",(function(){return s})),n.d(e,"Mapping",(function(){return c})),n.d(e,"RemoveMarkStep",(function(){return E})),n.d(e,"ReplaceAroundStep",(function(){return g})),n.d(e,"ReplaceStep",(function(){return v})),n.d(e,"Step",(function(){return h})),n.d(e,"StepMap",(function(){return a})),n.d(e,"StepResult",(function(){return m})),n.d(e,"Transform",(function(){return u})),n.d(e,"TransformError",(function(){return l})),n.d(e,"canJoin",(function(){return C})),n.d(e,"canSplit",(function(){return x})),n.d(e,"dropPoint",(function(){return N})),n.d(e,"findWrapping",(function(){return S})),n.d(e,"insertPoint",(function(){return T})),n.d(e,"joinPoint",(function(){return O})),n.d(e,"liftTarget",(function(){return b})),n.d(e,"replaceStep",(function(){return R}));var r=n(0),o=Math.pow(2,16);function i(t){return 65535&t}var s=function(t,e,n){void 0===e&&(e=!1),void 0===n&&(n=null),this.pos=t,this.deleted=e,this.recover=n},a=function t(e,n){if(void 0===n&&(n=!1),!e.length&&t.empty)return t.empty;this.ranges=e,this.inverted=n};a.prototype.recover=function(t){var e=0,n=i(t);if(!this.inverted)for(var r=0;r<n;r++)e+=this.ranges[3*r+2]-this.ranges[3*r+1];return this.ranges[3*n]+e+function(t){return(t-(65535&t))/o}(t)},a.prototype.mapResult=function(t,e){return void 0===e&&(e=1),this._map(t,e,!1)},a.prototype.map=function(t,e){return void 0===e&&(e=1),this._map(t,e,!0)},a.prototype._map=function(t,e,n){for(var r=0,i=this.inverted?2:1,a=this.inverted?1:2,c=0;c<this.ranges.length;c+=3){var l=this.ranges[c]-(this.inverted?r:0);if(l>t)break;var u=this.ranges[c+i],p=this.ranges[c+a],f=l+u;if(t<=f){var d=l+r+((u?t==l?-1:t==f?1:e:e)<0?0:p);if(n)return d;var h=t==(e<0?l:f)?null:c/3+(t-l)*o;return new s(d,e<0?t!=l:t!=f,h)}r+=p-u}return n?t+r:new s(t+r)},a.prototype.touches=function(t,e){for(var n=0,r=i(e),o=this.inverted?2:1,s=this.inverted?1:2,a=0;a<this.ranges.length;a+=3){var c=this.ranges[a]-(this.inverted?n:0);if(c>t)break;var l=this.ranges[a+o];if(t<=c+l&&a==3*r)return!0;n+=this.ranges[a+s]-l}return!1},a.prototype.forEach=function(t){for(var e=this.inverted?2:1,n=this.inverted?1:2,r=0,o=0;r<this.ranges.length;r+=3){var i=this.ranges[r],s=i-(this.inverted?o:0),a=i+(this.inverted?0:o),c=this.ranges[r+e],l=this.ranges[r+n];t(s,s+c,a,a+l),o+=l-c}},a.prototype.invert=function(){return new a(this.ranges,!this.inverted)},a.prototype.toString=function(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)},a.offset=function(t){return 0==t?a.empty:new a(t<0?[0,-t,0]:[0,0,t])},a.empty=new a([]);var c=function(t,e,n,r){this.maps=t||[],this.from=n||0,this.to=null==r?this.maps.length:r,this.mirror=e};function l(t){var e=Error.call(this,t);return e.__proto__=l.prototype,e}c.prototype.slice=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=this.maps.length),new c(this.maps,this.mirror,t,e)},c.prototype.copy=function(){return new c(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)},c.prototype.appendMap=function(t,e){this.to=this.maps.push(t),null!=e&&this.setMirror(this.maps.length-1,e)},c.prototype.appendMapping=function(t){for(var e=0,n=this.maps.length;e<t.maps.length;e++){var r=t.getMirror(e);this.appendMap(t.maps[e],null!=r&&r<e?n+r:null)}},c.prototype.getMirror=function(t){if(this.mirror)for(var e=0;e<this.mirror.length;e++)if(this.mirror[e]==t)return this.mirror[e+(e%2?-1:1)]},c.prototype.setMirror=function(t,e){this.mirror||(this.mirror=[]),this.mirror.push(t,e)},c.prototype.appendMappingInverted=function(t){for(var e=t.maps.length-1,n=this.maps.length+t.maps.length;e>=0;e--){var r=t.getMirror(e);this.appendMap(t.maps[e].invert(),null!=r&&r>e?n-r-1:null)}},c.prototype.invert=function(){var t=new c;return t.appendMappingInverted(this),t},c.prototype.map=function(t,e){if(void 0===e&&(e=1),this.mirror)return this._map(t,e,!0);for(var n=this.from;n<this.to;n++)t=this.maps[n].map(t,e);return t},c.prototype.mapResult=function(t,e){return void 0===e&&(e=1),this._map(t,e,!1)},c.prototype._map=function(t,e,n){for(var r=!1,o=this.from;o<this.to;o++){var i=this.maps[o].mapResult(t,e);if(null!=i.recover){var a=this.getMirror(o);if(null!=a&&a>o&&a<this.to){o=a,t=this.maps[a].recover(i.recover);continue}}i.deleted&&(r=!0),t=i.pos}return n?t:new s(t,r)},l.prototype=Object.create(Error.prototype),l.prototype.constructor=l,l.prototype.name="TransformError";var u=function(t){this.doc=t,this.steps=[],this.docs=[],this.mapping=new c},p={before:{configurable:!0},docChanged:{configurable:!0}};function f(){throw new Error("Override me")}p.before.get=function(){return this.docs.length?this.docs[0]:this.doc},u.prototype.step=function(t){var e=this.maybeStep(t);if(e.failed)throw new l(e.failed);return this},u.prototype.maybeStep=function(t){var e=t.apply(this.doc);return e.failed||this.addStep(t,e.doc),e},p.docChanged.get=function(){return this.steps.length>0},u.prototype.addStep=function(t,e){this.docs.push(this.doc),this.steps.push(t),this.mapping.appendMap(t.getMap()),this.doc=e},Object.defineProperties(u.prototype,p);var d=Object.create(null),h=function(){};h.prototype.apply=function(t){return f()},h.prototype.getMap=function(){return a.empty},h.prototype.invert=function(t){return f()},h.prototype.map=function(t){return f()},h.prototype.merge=function(t){return null},h.prototype.toJSON=function(){return f()},h.fromJSON=function(t,e){if(!e||!e.stepType)throw new RangeError("Invalid input for Step.fromJSON");var n=d[e.stepType];if(!n)throw new RangeError("No step type "+e.stepType+" defined");return n.fromJSON(t,e)},h.jsonID=function(t,e){if(t in d)throw new RangeError("Duplicate use of step JSON ID "+t);return d[t]=e,e.prototype.jsonID=t,e};var m=function(t,e){this.doc=t,this.failed=e};m.ok=function(t){return new m(t,null)},m.fail=function(t){return new m(null,t)},m.fromReplace=function(t,e,n,o){try{return m.ok(t.replace(e,n,o))}catch(t){if(t instanceof r.ReplaceError)return m.fail(t.message);throw t}};var v=function(t){function e(e,n,r,o){t.call(this),this.from=e,this.to=n,this.slice=r,this.structure=!!o}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.apply=function(t){return this.structure&&y(t,this.from,this.to)?m.fail("Structure replace would overwrite content"):m.fromReplace(t,this.from,this.to,this.slice)},e.prototype.getMap=function(){return new a([this.from,this.to-this.from,this.slice.size])},e.prototype.invert=function(t){return new e(this.from,this.from+this.slice.size,t.slice(this.from,this.to))},e.prototype.map=function(t){var n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted?null:new e(n.pos,Math.max(n.pos,r.pos),this.slice)},e.prototype.merge=function(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;var n=this.slice.size+t.slice.size==0?r.Slice.empty:new r.Slice(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new e(t.from,this.to,n,this.structure)}var o=this.slice.size+t.slice.size==0?r.Slice.empty:new r.Slice(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new e(this.from,this.to+(t.to-t.from),o,this.structure)},e.prototype.toJSON=function(){var t={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t},e.fromJSON=function(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,r.Slice.fromJSON(t,n.slice),!!n.structure)},e}(h);h.jsonID("replace",v);var g=function(t){function e(e,n,r,o,i,s,a){t.call(this),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=o,this.slice=i,this.insert=s,this.structure=!!a}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.apply=function(t){if(this.structure&&(y(t,this.from,this.gapFrom)||y(t,this.gapTo,this.to)))return m.fail("Structure gap-replace would overwrite content");var e=t.slice(this.gapFrom,this.gapTo);if(e.openStart||e.openEnd)return m.fail("Gap is not a flat range");var n=this.slice.insertAt(this.insert,e.content);return n?m.fromReplace(t,this.from,this.to,n):m.fail("Content does not fit in gap")},e.prototype.getMap=function(){return new a([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])},e.prototype.invert=function(t){var 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)},e.prototype.map=function(t){var n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1),o=t.map(this.gapFrom,-1),i=t.map(this.gapTo,1);return n.deleted&&r.deleted||o<n.pos||i>r.pos?null:new e(n.pos,r.pos,o,i,this.slice,this.insert,this.structure)},e.prototype.toJSON=function(){var t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t},e.fromJSON=function(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,r.Slice.fromJSON(t,n.slice),n.insert,!!n.structure)},e}(h);function y(t,e,n){for(var r=t.resolve(e),o=n-e,i=r.depth;o>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,o--;if(o>0)for(var s=r.node(i).maybeChild(r.indexAfter(i));o>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,o--}return!1}function w(t,e,n){return(0==e||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function b(t){for(var e=t.parent.content.cutByIndex(t.startIndex,t.endIndex),n=t.depth;;--n){var r=t.$from.node(n),o=t.$from.index(n),i=t.$to.indexAfter(n);if(n<t.depth&&r.canReplace(o,i,e))return n;if(0==n||r.type.spec.isolating||!w(r,o,i))break}}function S(t,e,n,r){void 0===r&&(r=t);var o=function(t,e){var n=t.parent,r=t.startIndex,o=t.endIndex,i=n.contentMatchAt(r).findWrapping(e);if(!i)return null;var s=i.length?i[0]:e;return n.canReplaceWith(r,o,s)?i:null}(t,e),i=o&&function(t,e){var n=t.parent,r=t.startIndex,o=t.endIndex,i=n.child(r),s=e.contentMatch.findWrapping(i.type);if(!s)return null;for(var a=(s.length?s[s.length-1]:e).contentMatch,c=r;a&&c<o;c++)a=a.matchType(n.child(c).type);if(!a||!a.validEnd)return null;return s}(r,e);return i?o.map(k).concat({type:e,attrs:n}).concat(i.map(k)):null}function k(t){return{type:t,attrs:null}}function x(t,e,n,r){void 0===n&&(n=1);var o=t.resolve(e),i=o.depth-n,s=r&&r[r.length-1]||o.parent;if(i<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!s.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(var a=o.depth-1,c=n-2;a>i;a--,c--){var l=o.node(a),u=o.index(a);if(l.type.spec.isolating)return!1;var p=l.content.cutByIndex(u,l.childCount),f=r&&r[c]||l;if(f!=l&&(p=p.replaceChild(0,f.type.create(f.attrs))),!l.canReplace(u+1,l.childCount)||!f.type.validContent(p))return!1}var d=o.indexAfter(i),h=r&&r[0];return o.node(i).canReplaceWith(d,d,h?h.type:o.node(i+1).type)}function C(t,e){var n=t.resolve(e),r=n.index();return M(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function M(t,e){return t&&e&&!t.isLeaf&&t.canAppend(e)}function O(t,e,n){void 0===n&&(n=-1);for(var r=t.resolve(e),o=r.depth;;o--){var i=void 0,s=void 0,a=r.index(o);if(o==r.depth?(i=r.nodeBefore,s=r.nodeAfter):n>0?(i=r.node(o+1),a++,s=r.node(o).maybeChild(a)):(i=r.node(o).maybeChild(a-1),s=r.node(o+1)),i&&!i.isTextblock&&M(i,s)&&r.node(o).canReplace(a,a+1))return e;if(0==o)break;e=n<0?r.before(o):r.after(o)}}function T(t,e,n){var r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(0==r.parentOffset)for(var o=r.depth-1;o>=0;o--){var i=r.index(o);if(r.node(o).canReplaceWith(i,i,n))return r.before(o+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(var s=r.depth-1;s>=0;s--){var a=r.indexAfter(s);if(r.node(s).canReplaceWith(a,a,n))return r.after(s+1);if(a<r.node(s).childCount)return null}}function N(t,e,n){var r=t.resolve(e);if(!n.content.size)return e;for(var o=n.content,i=0;i<n.openStart;i++)o=o.firstChild.content;for(var s=1;s<=(0==n.openStart&&n.size?2:1);s++)for(var a=r.depth;a>=0;a--){var c=a==r.depth?0:r.pos<=(r.start(a+1)+r.end(a+1))/2?-1:1,l=r.index(a)+(c>0?1:0),u=r.node(a),p=!1;if(1==s)p=u.canReplace(l,l,o);else{var f=u.contentMatchAt(l).findWrapping(o.firstChild.type);p=f&&u.canReplaceWith(l,l,f[0])}if(p)return 0==c?r.pos:c<0?r.before(a+1):r.after(a+1)}return null}function A(t,e,n){for(var o=[],i=0;i<t.childCount;i++){var s=t.child(i);s.content.size&&(s=s.copy(A(s.content,e,s))),s.isInline&&(s=e(s,n,i)),o.push(s)}return r.Fragment.fromArray(o)}h.jsonID("replaceAround",g),u.prototype.lift=function(t,e){for(var n=t.$from,o=t.$to,i=t.depth,s=n.before(i+1),a=o.after(i+1),c=s,l=a,u=r.Fragment.empty,p=0,f=i,d=!1;f>e;f--)d||n.index(f)>0?(d=!0,u=r.Fragment.from(n.node(f).copy(u)),p++):c--;for(var h=r.Fragment.empty,m=0,v=i,y=!1;v>e;v--)y||o.after(v+1)<o.end(v)?(y=!0,h=r.Fragment.from(o.node(v).copy(h)),m++):l++;return this.step(new g(c,l,s,a,new r.Slice(u.append(h),p,m),u.size-p,!0))},u.prototype.wrap=function(t,e){for(var n=r.Fragment.empty,o=e.length-1;o>=0;o--){if(n.size){var i=e[o].type.contentMatch.matchFragment(n);if(!i||!i.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}n=r.Fragment.from(e[o].type.create(e[o].attrs,n))}var s=t.start,a=t.end;return this.step(new g(s,a,s,a,new r.Slice(n,0,0),e.length,!0))},u.prototype.setBlockType=function(t,e,n,o){var i=this;if(void 0===e&&(e=t),!n.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");var s=this.steps.length;return this.doc.nodesBetween(t,e,(function(t,e){if(t.isTextblock&&!t.hasMarkup(n,o)&&function(t,e,n){var r=t.resolve(e),o=r.index();return r.parent.canReplaceWith(o,o+1,n)}(i.doc,i.mapping.slice(s).map(e),n)){i.clearIncompatible(i.mapping.slice(s).map(e,1),n);var a=i.mapping.slice(s),c=a.map(e,1),l=a.map(e+t.nodeSize,1);return i.step(new g(c,l,c+1,l-1,new r.Slice(r.Fragment.from(n.create(o,null,t.marks)),0,0),1,!0)),!1}})),this},u.prototype.setNodeMarkup=function(t,e,n,o){var i=this.doc.nodeAt(t);if(!i)throw new RangeError("No node at given position");e||(e=i.type);var s=e.create(n,null,o||i.marks);if(i.isLeaf)return this.replaceWith(t,t+i.nodeSize,s);if(!e.validContent(i.content))throw new RangeError("Invalid content for node type "+e.name);return this.step(new g(t,t+i.nodeSize,t+1,t+i.nodeSize-1,new r.Slice(r.Fragment.from(s),0,0),1,!0))},u.prototype.split=function(t,e,n){void 0===e&&(e=1);for(var o=this.doc.resolve(t),i=r.Fragment.empty,s=r.Fragment.empty,a=o.depth,c=o.depth-e,l=e-1;a>c;a--,l--){i=r.Fragment.from(o.node(a).copy(i));var u=n&&n[l];s=r.Fragment.from(u?u.type.create(u.attrs,s):o.node(a).copy(s))}return this.step(new v(t,t,new r.Slice(i.append(s),e,e),!0))},u.prototype.join=function(t,e){void 0===e&&(e=1);var n=new v(t-e,t+e,r.Slice.empty,!0);return this.step(n)};var D=function(t){function e(e,n,r){t.call(this),this.from=e,this.to=n,this.mark=r}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.apply=function(t){var e=this,n=t.slice(this.from,this.to),o=t.resolve(this.from),i=o.node(o.sharedDepth(this.to)),s=new r.Slice(A(n.content,(function(t,n){return t.isAtom&&n.type.allowsMarkType(e.mark.type)?t.mark(e.mark.addToSet(t.marks)):t}),i),n.openStart,n.openEnd);return m.fromReplace(t,this.from,this.to,s)},e.prototype.invert=function(){return new E(this.from,this.to,this.mark)},e.prototype.map=function(t){var 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)},e.prototype.merge=function(t){if(t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from)return new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark)},e.prototype.toJSON=function(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}},e.fromJSON=function(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))},e}(h);h.jsonID("addMark",D);var E=function(t){function e(e,n,r){t.call(this),this.from=e,this.to=n,this.mark=r}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.apply=function(t){var e=this,n=t.slice(this.from,this.to),o=new r.Slice(A(n.content,(function(t){return t.mark(e.mark.removeFromSet(t.marks))})),n.openStart,n.openEnd);return m.fromReplace(t,this.from,this.to,o)},e.prototype.invert=function(){return new D(this.from,this.to,this.mark)},e.prototype.map=function(t){var 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)},e.prototype.merge=function(t){if(t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from)return new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark)},e.prototype.toJSON=function(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}},e.fromJSON=function(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))},e}(h);function R(t,e,n,o){if(void 0===n&&(n=e),void 0===o&&(o=r.Slice.empty),e==n&&!o.size)return null;var i=t.resolve(e),s=t.resolve(n);return _(i,s,o)?new v(e,n,o):new I(i,s,o).fit()}function _(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}h.jsonID("removeMark",E),u.prototype.addMark=function(t,e,n){var r=this,o=[],i=[],s=null,a=null;return this.doc.nodesBetween(t,e,(function(r,c,l){if(r.isInline){var u=r.marks;if(!n.isInSet(u)&&l.type.allowsMarkType(n.type)){for(var p=Math.max(c,t),f=Math.min(c+r.nodeSize,e),d=n.addToSet(u),h=0;h<u.length;h++)u[h].isInSet(d)||(s&&s.to==p&&s.mark.eq(u[h])?s.to=f:o.push(s=new E(p,f,u[h])));a&&a.to==p?a.to=f:i.push(a=new D(p,f,n))}}})),o.forEach((function(t){return r.step(t)})),i.forEach((function(t){return r.step(t)})),this},u.prototype.removeMark=function(t,e,n){var o=this;void 0===n&&(n=null);var i=[],s=0;return this.doc.nodesBetween(t,e,(function(o,a){if(o.isInline){s++;var c=null;if(n instanceof r.MarkType)for(var l,u=o.marks;l=n.isInSet(u);)(c||(c=[])).push(l),u=l.removeFromSet(u);else n?n.isInSet(o.marks)&&(c=[n]):c=o.marks;if(c&&c.length)for(var p=Math.min(a+o.nodeSize,e),f=0;f<c.length;f++){for(var d=c[f],h=void 0,m=0;m<i.length;m++){var v=i[m];v.step==s-1&&d.eq(i[m].style)&&(h=v)}h?(h.to=p,h.step=s):i.push({style:d,from:Math.max(a,t),to:p,step:s})}}})),i.forEach((function(t){return o.step(new E(t.from,t.to,t.style))})),this},u.prototype.clearIncompatible=function(t,e,n){void 0===n&&(n=e.contentMatch);for(var o=this.doc.nodeAt(t),i=[],s=t+1,a=0;a<o.childCount;a++){var c=o.child(a),l=s+c.nodeSize,u=n.matchType(c.type,c.attrs);if(u){n=u;for(var p=0;p<c.marks.length;p++)e.allowsMarkType(c.marks[p].type)||this.step(new E(s,l,c.marks[p]))}else i.push(new v(s,l,r.Slice.empty));s=l}if(!n.validEnd){var f=n.fillBefore(r.Fragment.empty,!0);this.replace(s,s,new r.Slice(f,0,0))}for(var d=i.length-1;d>=0;d--)this.step(i[d]);return this},u.prototype.replace=function(t,e,n){void 0===e&&(e=t),void 0===n&&(n=r.Slice.empty);var o=R(this.doc,t,e,n);return o&&this.step(o),this},u.prototype.replaceWith=function(t,e,n){return this.replace(t,e,new r.Slice(r.Fragment.from(n),0,0))},u.prototype.delete=function(t,e){return this.replace(t,e,r.Slice.empty)},u.prototype.insert=function(t,e){return this.replaceWith(t,t,e)};var I=function(t,e,n){this.$to=e,this.$from=t,this.unplaced=n,this.frontier=[];for(var o=0;o<=t.depth;o++){var i=t.node(o);this.frontier.push({type:i.type,match:i.contentMatchAt(t.indexAfter(o))})}this.placed=r.Fragment.empty;for(var s=t.depth;s>0;s--)this.placed=r.Fragment.from(t.node(s).copy(this.placed))},z={depth:{configurable:!0}};function P(t,e,n){return 0==e?t.cutByIndex(n):t.replaceChild(0,t.firstChild.copy(P(t.firstChild.content,e-1,n)))}function $(t,e,n){return 0==e?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy($(t.lastChild.content,e-1,n)))}function F(t,e){for(var n=0;n<e;n++)t=t.firstChild.content;return t}function B(t,e,n){if(e<=0)return t;var o=t.content;return e>1&&(o=o.replaceChild(0,B(o.firstChild,e-1,1==o.childCount?n-1:0))),e>0&&(o=t.type.contentMatch.fillBefore(o).append(o),n<=0&&(o=o.append(t.type.contentMatch.matchFragment(o).fillBefore(r.Fragment.empty,!0)))),t.copy(o)}function L(t,e,n,r,o){var i=t.node(e),s=o?t.indexAfter(e):t.index(e);if(s==i.childCount&&!n.compatibleContent(i.type))return null;var a=r.fillBefore(i.content,!0,s);return a&&!function(t,e,n){for(var r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}(n,i.content,s)?a:null}function V(t){return t.spec.defining||t.spec.definingForContent}function j(t,e,n,o,i){if(e<n){var s=t.firstChild;t=t.replaceChild(0,s.copy(j(s.content,e+1,n,o,s)))}if(e>o){var a=i.contentMatchAt(0),c=a.fillBefore(t).append(t);t=c.append(a.matchFragment(c).fillBefore(r.Fragment.empty,!0))}return t}function W(t,e){for(var n=[],r=Math.min(t.depth,e.depth);r>=0;r--){var o=t.start(r);if(o<t.pos-(t.depth-r)||e.end(r)>e.pos+(e.depth-r)||t.node(r).type.spec.isolating||e.node(r).type.spec.isolating)break;(o==e.start(r)||r==t.depth&&r==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&r&&e.start(r-1)==o-1)&&n.push(r)}return n}z.depth.get=function(){return this.frontier.length-1},I.prototype.fit=function(){for(;this.unplaced.size;){var t=this.findFittable();t?this.placeNodes(t):this.openMore()||this.dropNode()}var e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,o=this.$from,i=this.close(e<0?this.$to:o.doc.resolve(e));if(!i)return null;for(var s=this.placed,a=o.depth,c=i.depth;a&&c&&1==s.childCount;)s=s.firstChild.content,a--,c--;var l=new r.Slice(s,a,c);return e>-1?new g(o.pos,e,this.$to.pos,this.$to.end(),l,n):l.size||o.pos!=this.$to.pos?new v(o.pos,i.pos,l):void 0},I.prototype.findFittable=function(){for(var t=1;t<=2;t++)for(var e=this.unplaced.openStart;e>=0;e--)for(var n=void 0,o=(e?(n=F(this.unplaced.content,e-1).firstChild).content:this.unplaced.content).firstChild,i=this.depth;i>=0;i--){var s=this.frontier[i],a=s.type,c=s.match,l=void 0,u=void 0;if(1==t&&(o?c.matchType(o.type)||(u=c.fillBefore(r.Fragment.from(o),!1)):a.compatibleContent(n.type)))return{sliceDepth:e,frontierDepth:i,parent:n,inject:u};if(2==t&&o&&(l=c.findWrapping(o.type)))return{sliceDepth:e,frontierDepth:i,parent:n,wrap:l};if(n&&c.matchType(n.type))break}},I.prototype.openMore=function(){var t=this.unplaced,e=t.content,n=t.openStart,o=t.openEnd,i=F(e,n);return!(!i.childCount||i.firstChild.isLeaf)&&(this.unplaced=new r.Slice(e,n+1,Math.max(o,i.size+n>=e.size-o?n+1:0)),!0)},I.prototype.dropNode=function(){var t=this.unplaced,e=t.content,n=t.openStart,o=t.openEnd,i=F(e,n);if(i.childCount<=1&&n>0){var s=e.size-n<=n+i.size;this.unplaced=new r.Slice(P(e,n-1,1),n-1,s?n-1:o)}else this.unplaced=new r.Slice(P(e,n,1),n,o)},I.prototype.placeNodes=function(t){for(var e=t.sliceDepth,n=t.frontierDepth,o=t.parent,i=t.inject,s=t.wrap;this.depth>n;)this.closeFrontierNode();if(s)for(var a=0;a<s.length;a++)this.openFrontierNode(s[a]);var c=this.unplaced,l=o?o.content:c.content,u=c.openStart-e,p=0,f=[],d=this.frontier[n],h=d.match,m=d.type;if(i){for(var v=0;v<i.childCount;v++)f.push(i.child(v));h=h.matchFragment(i)}for(var g=l.size+e-(c.content.size-c.openEnd);p<l.childCount;){var y=l.child(p),w=h.matchType(y.type);if(!w)break;(++p>1||0==u||y.content.size)&&(h=w,f.push(B(y.mark(m.allowedMarks(y.marks)),1==p?u:0,p==l.childCount?g:-1)))}var b=p==l.childCount;b||(g=-1),this.placed=$(this.placed,n,r.Fragment.from(f)),this.frontier[n].match=h,b&&g<0&&o&&o.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(var S=0,k=l;S<g;S++){var x=k.lastChild;this.frontier.push({type:x.type,match:x.contentMatchAt(x.childCount)}),k=x.content}this.unplaced=b?0==e?r.Slice.empty:new r.Slice(P(c.content,e-1,1),e-1,g<0?c.openEnd:e-1):new r.Slice(P(c.content,e,p),c.openStart,c.openEnd)},I.prototype.mustMoveInline=function(){if(!this.$to.parent.isTextblock||this.$to.end()==this.$to.pos)return-1;var t,e=this.frontier[this.depth];if(!e.type.isTextblock||!L(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;for(var n=this.$to.depth,r=this.$to.after(n);n>1&&r==this.$to.end(--n);)++r;return r},I.prototype.findCloseLevel=function(t){t:for(var e=Math.min(this.depth,t.depth);e>=0;e--){var n=this.frontier[e],r=n.match,o=n.type,i=e<t.depth&&t.end(e+1)==t.pos+(t.depth-(e+1)),s=L(t,e,o,r,i);if(s){for(var a=e-1;a>=0;a--){var c=this.frontier[a],l=c.match,u=L(t,a,c.type,l,!0);if(!u||u.childCount)continue t}return{depth:e,fit:s,move:i?t.doc.resolve(t.after(e+1)):t}}}},I.prototype.close=function(t){var e=this.findCloseLevel(t);if(!e)return null;for(;this.depth>e.depth;)this.closeFrontierNode();e.fit.childCount&&(this.placed=$(this.placed,e.depth,e.fit)),t=e.move;for(var n=e.depth+1;n<=t.depth;n++){var r=t.node(n),o=r.type.contentMatch.fillBefore(r.content,!0,t.index(n));this.openFrontierNode(r.type,r.attrs,o)}return t},I.prototype.openFrontierNode=function(t,e,n){var o=this.frontier[this.depth];o.match=o.match.matchType(t),this.placed=$(this.placed,this.depth,r.Fragment.from(t.create(e,n))),this.frontier.push({type:t,match:t.contentMatch})},I.prototype.closeFrontierNode=function(){var t=this.frontier.pop().match.fillBefore(r.Fragment.empty,!0);t.childCount&&(this.placed=$(this.placed,this.frontier.length,t))},Object.defineProperties(I.prototype,z),u.prototype.replaceRange=function(t,e,n){if(!n.size)return this.deleteRange(t,e);var o=this.doc.resolve(t),i=this.doc.resolve(e);if(_(o,i,n))return this.step(new v(t,e,n));var s=W(o,this.doc.resolve(e));0==s[s.length-1]&&s.pop();var a=-(o.depth+1);s.unshift(a);for(var c=o.depth,l=o.pos-1;c>0;c--,l--){var u=o.node(c).type.spec;if(u.defining||u.definingAsContext||u.isolating)break;s.indexOf(c)>-1?a=c:o.before(c)==l&&s.splice(1,0,-c)}for(var p=s.indexOf(a),f=[],d=n.openStart,h=n.content,m=0;;m++){var g=h.firstChild;if(f.push(g),m==n.openStart)break;h=g.content}for(var y=d-1;y>=0;y--){var w=f[y].type,b=V(w);if(b&&o.node(p).type!=w)d=y;else if(b||!w.isTextblock)break}for(var S=n.openStart;S>=0;S--){var k=(S+d+1)%(n.openStart+1),x=f[k];if(x)for(var C=0;C<s.length;C++){var M=s[(C+p)%s.length],O=!0;M<0&&(O=!1,M=-M);var T=o.node(M-1),N=o.index(M-1);if(T.canReplaceWith(N,N,x.type,x.marks))return this.replace(o.before(M),O?i.after(M):e,new r.Slice(j(n.content,0,n.openStart,k),k,n.openEnd))}}for(var A=this.steps.length,D=s.length-1;D>=0&&(this.replace(t,e,n),!(this.steps.length>A));D--){var E=s[D];E<0||(t=o.before(E),e=i.after(E))}return this},u.prototype.replaceRangeWith=function(t,e,n){if(!n.isInline&&t==e&&this.doc.resolve(t).parent.content.size){var o=T(this.doc,t,n.type);null!=o&&(t=e=o)}return this.replaceRange(t,e,new r.Slice(r.Fragment.from(n),0,0))},u.prototype.deleteRange=function(t,e){for(var n=this.doc.resolve(t),r=this.doc.resolve(e),o=W(n,r),i=0;i<o.length;i++){var s=o[i],a=i==o.length-1;if(a&&0==s||n.node(s).type.contentMatch.validEnd)return this.delete(n.start(s),r.end(s));if(s>0&&(a||n.node(s-1).canReplace(n.index(s-1),r.indexAfter(s-1))))return this.delete(n.before(s),r.after(s))}for(var c=1;c<=n.depth&&c<=r.depth;c++)if(t-n.start(c)==n.depth-c&&e>n.end(c)&&r.end(c)-e!=r.depth-c)return this.delete(n.before(c),e);return this.delete(t,e)}},function(t,e,n){"use strict";n.r(e),n.d(e,"Decoration",(function(){return Ne})),n.d(e,"DecorationSet",(function(){return Re})),n.d(e,"EditorView",(function(){return We})),n.d(e,"__endComposition",(function(){return ye})),n.d(e,"__parseFromClipboard",(function(){return Vt})),n.d(e,"__serializeForClipboard",(function(){return Lt}));var r=n(1),o=n(0),i=n(2),s={};if("undefined"!=typeof navigator&&"undefined"!=typeof document){var a=/Edge\/(\d+)/.exec(navigator.userAgent),c=/MSIE \d/.test(navigator.userAgent),l=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),u=s.ie=!!(c||l||a);s.ie_version=c?document.documentMode||6:l?+l[1]:a?+a[1]:null,s.gecko=!u&&/gecko\/(\d+)/i.test(navigator.userAgent),s.gecko_version=s.gecko&&+(/Firefox\/(\d+)/.exec(navigator.userAgent)||[0,0])[1];var p=!u&&/Chrome\/(\d+)/.exec(navigator.userAgent);s.chrome=!!p,s.chrome_version=p&&+p[1],s.safari=!u&&/Apple Computer/.test(navigator.vendor),s.ios=s.safari&&(/Mobile\/\w+/.test(navigator.userAgent)||navigator.maxTouchPoints>2),s.mac=s.ios||/Mac/.test(navigator.platform),s.android=/Android \d/.test(navigator.userAgent),s.webkit="webkitFontSmoothing"in document.documentElement.style,s.webkit_version=s.webkit&&+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]}var f=function(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e},d=function(t){var e=t.assignedSlot||t.parentNode;return e&&11==e.nodeType?e.host:e},h=null,m=function(t,e,n){var r=h||(h=document.createRange());return r.setEnd(t,null==n?t.nodeValue.length:n),r.setStart(t,e||0),r},v=function(t,e,n,r){return n&&(y(t,e,n,r,-1)||y(t,e,n,r,1))},g=/^(img|br|input|textarea|hr)$/i;function y(t,e,n,r,o){for(;;){if(t==n&&e==r)return!0;if(e==(o<0?0:w(t))){var i=t.parentNode;if(!i||1!=i.nodeType||b(t)||g.test(t.nodeName)||"false"==t.contentEditable)return!1;e=f(t)+(o<0?0:1),t=i}else{if(1!=t.nodeType)return!1;if("false"==(t=t.childNodes[e+(o<0?-1:0)]).contentEditable)return!1;e=o<0?w(t):0}}}function w(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function b(t){for(var e,n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}var S=function(t){var e=t.isCollapsed;return e&&s.chrome&&t.rangeCount&&!t.getRangeAt(0).collapsed&&(e=!1),e};function k(t,e){var n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function x(t){return{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function C(t,e){return"number"==typeof t?t:t[e]}function M(t){var e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function O(t,e,n){for(var r=t.someProp("scrollThreshold")||0,o=t.someProp("scrollMargin")||5,i=t.dom.ownerDocument,s=n||t.dom;s;s=d(s))if(1==s.nodeType){var a=s==i.body||1!=s.nodeType,c=a?x(i):M(s),l=0,u=0;if(e.top<c.top+C(r,"top")?u=-(c.top-e.top+C(o,"top")):e.bottom>c.bottom-C(r,"bottom")&&(u=e.bottom-c.bottom+C(o,"bottom")),e.left<c.left+C(r,"left")?l=-(c.left-e.left+C(o,"left")):e.right>c.right-C(r,"right")&&(l=e.right-c.right+C(o,"right")),l||u)if(a)i.defaultView.scrollBy(l,u);else{var p=s.scrollLeft,f=s.scrollTop;u&&(s.scrollTop+=u),l&&(s.scrollLeft+=l);var h=s.scrollLeft-p,m=s.scrollTop-f;e={left:e.left-h,top:e.top-m,right:e.right-h,bottom:e.bottom-m}}if(a)break}}function T(t){for(var e=[],n=t.ownerDocument;t&&(e.push({dom:t,top:t.scrollTop,left:t.scrollLeft}),t!=n);t=d(t));return e}function N(t,e){for(var n=0;n<t.length;n++){var r=t[n],o=r.dom,i=r.top,s=r.left;o.scrollTop!=i+e&&(o.scrollTop=i+e),o.scrollLeft!=s&&(o.scrollLeft=s)}}var A=null;function D(t,e){for(var n,r,o=2e8,i=0,s=e.top,a=e.top,c=t.firstChild,l=0;c;c=c.nextSibling,l++){var u=void 0;if(1==c.nodeType)u=c.getClientRects();else{if(3!=c.nodeType)continue;u=m(c).getClientRects()}for(var p=0;p<u.length;p++){var f=u[p];if(f.top<=s&&f.bottom>=a){s=Math.max(f.bottom,s),a=Math.min(f.top,a);var d=f.left>e.left?f.left-e.left:f.right<e.left?e.left-f.right:0;if(d<o){n=c,o=d,r=d&&3==n.nodeType?{left:f.right<e.left?f.right:f.left,top:e.top}:e,1==c.nodeType&&d&&(i=l+(e.left>=(f.left+f.right)/2?1:0));continue}}!n&&(e.left>=f.right&&e.top>=f.top||e.left>=f.left&&e.top>=f.bottom)&&(i=l+1)}}return n&&3==n.nodeType?function(t,e){for(var n=t.nodeValue.length,r=document.createRange(),o=0;o<n;o++){r.setEnd(t,o+1),r.setStart(t,o);var i=_(r,1);if(i.top!=i.bottom&&E(e,i))return{node:t,offset:o+(e.left>=(i.left+i.right)/2?1:0)}}return{node:t,offset:0}}(n,r):!n||o&&1==n.nodeType?{node:t,offset:i}:D(n,r)}function E(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function R(t,e){var n,r,o,i,a=t.dom.ownerDocument;if(a.caretPositionFromPoint)try{var c=a.caretPositionFromPoint(e.left,e.top);c&&(o=(n=c).offsetNode,i=n.offset)}catch(t){}if(!o&&a.caretRangeFromPoint){var l=a.caretRangeFromPoint(e.left,e.top);l&&(o=(r=l).startContainer,i=r.startOffset)}var u,p=(t.root.elementFromPoint?t.root:a).elementFromPoint(e.left,e.top+1);if(!p||!t.dom.contains(1!=p.nodeType?p.parentNode:p)){var f=t.dom.getBoundingClientRect();if(!E(e,f))return null;if(!(p=function t(e,n,r){var o=e.childNodes.length;if(o&&r.top<r.bottom)for(var i=Math.max(0,Math.min(o-1,Math.floor(o*(n.top-r.top)/(r.bottom-r.top))-2)),s=i;;){var a=e.childNodes[s];if(1==a.nodeType)for(var c=a.getClientRects(),l=0;l<c.length;l++){var u=c[l];if(E(n,u))return t(a,n,u)}if((s=(s+1)%o)==i)break}return e}(t.dom,e,f)))return null}if(s.safari)for(var h=p;o&&h;h=d(h))h.draggable&&(o=i=null);if(p=function(t,e){var n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}(p,e),o){if(s.gecko&&1==o.nodeType&&(i=Math.min(i,o.childNodes.length))<o.childNodes.length){var m,v=o.childNodes[i];"IMG"==v.nodeName&&(m=v.getBoundingClientRect()).right<=e.left&&m.bottom>e.top&&i++}o==t.dom&&i==o.childNodes.length-1&&1==o.lastChild.nodeType&&e.top>o.lastChild.getBoundingClientRect().bottom?u=t.state.doc.content.size:0!=i&&1==o.nodeType&&"BR"==o.childNodes[i-1].nodeName||(u=function(t,e,n,r){for(var o=-1,i=e;i!=t.dom;){var s=t.docView.nearestDesc(i,!0);if(!s)return null;if(s.node.isBlock&&s.parent){var a=s.dom.getBoundingClientRect();if(a.left>r.left||a.top>r.top)o=s.posBefore;else{if(!(a.right<r.left||a.bottom<r.top))break;o=s.posAfter}}i=s.dom.parentNode}return o>-1?o:t.docView.posFromDOM(e,n)}(t,o,i,e))}null==u&&(u=function(t,e,n){var r=D(e,n),o=r.node,i=r.offset,s=-1;if(1==o.nodeType&&!o.firstChild){var a=o.getBoundingClientRect();s=a.left!=a.right&&n.left>(a.left+a.right)/2?1:-1}return t.docView.posFromDOM(o,i,s)}(t,p,e));var g=t.docView.nearestDesc(p,!0);return{pos:u,inside:g?g.posAtStart-g.border:-1}}function _(t,e){var n=t.getClientRects();return n.length?n[e<0?0:n.length-1]:t.getBoundingClientRect()}var I=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function z(t,e,n){var r=t.docView.domFromPos(e,n<0?-1:1),o=r.node,i=r.offset,a=s.webkit||s.gecko;if(3==o.nodeType){if(!a||!I.test(o.nodeValue)&&(n<0?i:i!=o.nodeValue.length)){var c=i,l=i,u=n<0?1:-1;return n<0&&!i?(l++,u=-1):n>=0&&i==o.nodeValue.length?(c--,u=1):n<0?c--:l++,P(_(m(o,c,l),u),u<0)}var p=_(m(o,i,i),n);if(s.gecko&&i&&/\s/.test(o.nodeValue[i-1])&&i<o.nodeValue.length){var f=_(m(o,i-1,i-1),-1);if(f.top==p.top){var d=_(m(o,i,i+1),-1);if(d.top!=p.top)return P(d,d.left<f.left)}}return p}if(!t.state.doc.resolve(e).parent.inlineContent){if(i&&(n<0||i==w(o))){var h=o.childNodes[i-1];if(1==h.nodeType)return $(h.getBoundingClientRect(),!1)}if(i<w(o)){var v=o.childNodes[i];if(1==v.nodeType)return $(v.getBoundingClientRect(),!0)}return $(o.getBoundingClientRect(),n>=0)}if(i&&(n<0||i==w(o))){var g=o.childNodes[i-1],y=3==g.nodeType?m(g,w(g)-(a?0:1)):1!=g.nodeType||"BR"==g.nodeName&&g.nextSibling?null:g;if(y)return P(_(y,1),!1)}if(i<w(o)){for(var b=o.childNodes[i];b.pmViewDesc&&b.pmViewDesc.ignoreForCoords;)b=b.nextSibling;var S=b?3==b.nodeType?m(b,0,a?0:1):1==b.nodeType?b:null:null;if(S)return P(_(S,-1),!0)}return P(_(3==o.nodeType?m(o):o,-n),n>=0)}function P(t,e){if(0==t.width)return t;var n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function $(t,e){if(0==t.height)return t;var n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function F(t,e,n){var r=t.state,o=t.root.activeElement;r!=e&&t.updateState(e),o!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),o!=t.dom&&o&&o.focus()}}var B=/[\u0590-\u08ac]/;var L=null,V=null,j=!1;function W(t,e,n){return L==e&&V==n?j:(L=e,V=n,j="up"==n||"down"==n?function(t,e,n){var r=e.selection,o="up"==n?r.$from:r.$to;return F(t,e,(function(){for(var e=t.docView.domFromPos(o.pos,"up"==n?-1:1).node;;){var r=t.docView.nearestDesc(e,!0);if(!r)break;if(r.node.isBlock){e=r.dom;break}e=r.dom.parentNode}for(var i=z(t,o.pos,1),s=e.firstChild;s;s=s.nextSibling){var a=void 0;if(1==s.nodeType)a=s.getClientRects();else{if(3!=s.nodeType)continue;a=m(s,0,s.nodeValue.length).getClientRects()}for(var c=0;c<a.length;c++){var l=a[c];if(l.bottom>l.top+1&&("up"==n?i.top-l.top>2*(l.bottom-i.top):l.bottom-i.bottom>2*(i.bottom-l.top)))return!1}}return!0}))}(t,e,n):function(t,e,n){var r=e.selection.$head;if(!r.parent.isTextblock)return!1;var o=r.parentOffset,i=!o,s=o==r.parent.content.size,a=t.root.getSelection();return B.test(r.parent.textContent)&&a.modify?F(t,e,(function(){var e=a.getRangeAt(0),o=a.focusNode,i=a.focusOffset,s=a.caretBidiLevel;a.modify("move",n,"character");var c=!(r.depth?t.docView.domAfterPos(r.before()):t.dom).contains(1==a.focusNode.nodeType?a.focusNode:a.focusNode.parentNode)||o==a.focusNode&&i==a.focusOffset;return a.removeAllRanges(),a.addRange(e),null!=s&&(a.caretBidiLevel=s),c})):"left"==n||"backward"==n?i:s}(t,e,n))}var K=function(t,e,n,r){this.parent=t,this.children=e,this.dom=n,n.pmViewDesc=this,this.contentDOM=r,this.dirty=0},q={size:{configurable:!0},border:{configurable:!0},posBefore:{configurable:!0},posAtStart:{configurable:!0},posAfter:{configurable:!0},posAtEnd:{configurable:!0},contentLost:{configurable:!0},domAtom:{configurable:!0},ignoreForCoords:{configurable:!0}};K.prototype.matchesWidget=function(){return!1},K.prototype.matchesMark=function(){return!1},K.prototype.matchesNode=function(){return!1},K.prototype.matchesHack=function(t){return!1},K.prototype.parseRule=function(){return null},K.prototype.stopEvent=function(){return!1},q.size.get=function(){for(var t=0,e=0;e<this.children.length;e++)t+=this.children[e].size;return t},q.border.get=function(){return 0},K.prototype.destroy=function(){this.parent=null,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=null);for(var t=0;t<this.children.length;t++)this.children[t].destroy()},K.prototype.posBeforeChild=function(t){for(var e=0,n=this.posAtStart;e<this.children.length;e++){var r=this.children[e];if(r==t)return n;n+=r.size}},q.posBefore.get=function(){return this.parent.posBeforeChild(this)},q.posAtStart.get=function(){return this.parent?this.parent.posBeforeChild(this)+this.border:0},q.posAfter.get=function(){return this.posBefore+this.size},q.posAtEnd.get=function(){return this.posAtStart+this.size-2*this.border},K.prototype.localPosFromDOM=function(t,e,n){if(this.contentDOM&&this.contentDOM.contains(1==t.nodeType?t:t.parentNode)){if(n<0){var r,o;if(t==this.contentDOM)r=t.childNodes[e-1];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;r=t.previousSibling}for(;r&&(!(o=r.pmViewDesc)||o.parent!=this);)r=r.previousSibling;return r?this.posBeforeChild(o)+o.size:this.posAtStart}var i,s;if(t==this.contentDOM)i=t.childNodes[e];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;i=t.nextSibling}for(;i&&(!(s=i.pmViewDesc)||s.parent!=this);)i=i.nextSibling;return i?this.posBeforeChild(s):this.posAtEnd}var a;if(t==this.dom&&this.contentDOM)a=e>f(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))a=2&t.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==e)for(var c=t;;c=c.parentNode){if(c==this.dom){a=!1;break}if(c.parentNode.firstChild!=c)break}if(null==a&&e==t.childNodes.length)for(var l=t;;l=l.parentNode){if(l==this.dom){a=!0;break}if(l.parentNode.lastChild!=l)break}}return(null==a?n>0:a)?this.posAtEnd:this.posAtStart},K.prototype.nearestDesc=function(t,e){for(var n=!0,r=t;r;r=r.parentNode){var o=this.getDesc(r);if(o&&(!e||o.node)){if(!n||!o.nodeDOM||(1==o.nodeDOM.nodeType?o.nodeDOM.contains(1==t.nodeType?t:t.parentNode):o.nodeDOM==t))return o;n=!1}}},K.prototype.getDesc=function(t){for(var e=t.pmViewDesc,n=e;n;n=n.parent)if(n==this)return e},K.prototype.posFromDOM=function(t,e,n){for(var r=t;r;r=r.parentNode){var o=this.getDesc(r);if(o)return o.localPosFromDOM(t,e,n)}return-1},K.prototype.descAt=function(t){for(var e=0,n=0;e<this.children.length;e++){var r=this.children[e],o=n+r.size;if(n==t&&o!=n){for(;!r.border&&r.children.length;)r=r.children[0];return r}if(t<o)return r.descAt(t-n-r.border);n=o}},K.prototype.domFromPos=function(t,e){if(!this.contentDOM)return{node:this.dom,offset:0};for(var n=0,r=0,o=0;n<this.children.length;n++){var i=this.children[n],s=o+i.size;if(s>t||i instanceof Z){r=t-o;break}o=s}if(r)return this.children[n].domFromPos(r-this.children[n].border,e);for(var a=void 0;n&&!(a=this.children[n-1]).size&&a instanceof J&&a.widget.type.side>=0;n--);if(e<=0){for(var c,l=!0;(c=n?this.children[n-1]:null)&&c.dom.parentNode!=this.contentDOM;n--,l=!1);return c&&e&&l&&!c.border&&!c.domAtom?c.domFromPos(c.size,e):{node:this.contentDOM,offset:c?f(c.dom)+1:0}}for(var u,p=!0;(u=n<this.children.length?this.children[n]:null)&&u.dom.parentNode!=this.contentDOM;n++,p=!1);return u&&p&&!u.border&&!u.domAtom?u.domFromPos(0,e):{node:this.contentDOM,offset:u?f(u.dom):this.contentDOM.childNodes.length}},K.prototype.parseRange=function(t,e,n){if(void 0===n&&(n=0),0==this.children.length)return{node:this.contentDOM,from:t,to:e,fromOffset:0,toOffset:this.contentDOM.childNodes.length};for(var r=-1,o=-1,i=n,s=0;;s++){var a=this.children[s],c=i+a.size;if(-1==r&&t<=c){var l=i+a.border;if(t>=l&&e<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(t,e,l);t=i;for(var u=s;u>0;u--){var p=this.children[u-1];if(p.size&&p.dom.parentNode==this.contentDOM&&!p.emptyChildAt(1)){r=f(p.dom)+1;break}t-=p.size}-1==r&&(r=0)}if(r>-1&&(c>e||s==this.children.length-1)){e=c;for(var d=s+1;d<this.children.length;d++){var h=this.children[d];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(-1)){o=f(h.dom);break}e+=h.size}-1==o&&(o=this.contentDOM.childNodes.length);break}i=c}return{node:this.contentDOM,from:t,to:e,fromOffset:r,toOffset:o}},K.prototype.emptyChildAt=function(t){if(this.border||!this.contentDOM||!this.children.length)return!1;var e=this.children[t<0?0:this.children.length-1];return 0==e.size||e.emptyChildAt(t)},K.prototype.domAfterPos=function(t){var e=this.domFromPos(t,0),n=e.node,r=e.offset;if(1!=n.nodeType||r==n.childNodes.length)throw new RangeError("No node after pos "+t);return n.childNodes[r]},K.prototype.setSelection=function(t,e,n,r){for(var o=Math.min(t,e),i=Math.max(t,e),a=0,c=0;a<this.children.length;a++){var l=this.children[a],u=c+l.size;if(o>c&&i<u)return l.setSelection(t-c-l.border,e-c-l.border,n,r);c=u}var p=this.domFromPos(t,t?-1:1),d=e==t?p:this.domFromPos(e,e?-1:1),h=n.getSelection(),m=!1;if((s.gecko||s.safari)&&t==e){var g=p.node,y=p.offset;if(3==g.nodeType){if((m=y&&"\n"==g.nodeValue[y-1])&&y==g.nodeValue.length)for(var w=g,b=void 0;w;w=w.parentNode){if(b=w.nextSibling){"BR"==b.nodeName&&(p=d={node:b.parentNode,offset:f(b)+1});break}var S=w.pmViewDesc;if(S&&S.node&&S.node.isBlock)break}}else{var k=g.childNodes[y-1];m=k&&("BR"==k.nodeName||"false"==k.contentEditable)}}if(s.gecko&&h.focusNode&&h.focusNode!=d.node&&1==h.focusNode.nodeType){var x=h.focusNode.childNodes[h.focusOffset];x&&"false"==x.contentEditable&&(r=!0)}if(r||m&&s.safari||!v(p.node,p.offset,h.anchorNode,h.anchorOffset)||!v(d.node,d.offset,h.focusNode,h.focusOffset)){var C=!1;if((h.extend||t==e)&&!m){h.collapse(p.node,p.offset);try{t!=e&&h.extend(d.node,d.offset),C=!0}catch(t){if(!(t instanceof DOMException))throw t}}if(!C){if(t>e){var M=p;p=d,d=M}var O=document.createRange();O.setEnd(d.node,d.offset),O.setStart(p.node,p.offset),h.removeAllRanges(),h.addRange(O)}}},K.prototype.ignoreMutation=function(t){return!this.contentDOM&&"selection"!=t.type},q.contentLost.get=function(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)},K.prototype.markDirty=function(t,e){for(var n=0,r=0;r<this.children.length;r++){var o=this.children[r],i=n+o.size;if(n==i?t<=i&&e>=n:t<i&&e>n){var s=n+o.border,a=i-o.border;if(t>=s&&e<=a)return this.dirty=t==n||e==i?2:1,void(t!=s||e!=a||!o.contentLost&&o.dom.parentNode==this.contentDOM?o.markDirty(t-s,e-s):o.dirty=3);o.dirty=o.dom!=o.contentDOM||o.dom.parentNode!=this.contentDOM||o.children.length?3:2}n=i}this.dirty=2},K.prototype.markParentsDirty=function(){for(var t=1,e=this.parent;e;e=e.parent,t++){var n=1==t?2:1;e.dirty<n&&(e.dirty=n)}},q.domAtom.get=function(){return!1},q.ignoreForCoords.get=function(){return!1},Object.defineProperties(K.prototype,q);var H=[],J=function(t){function e(e,n,r,o){var i,s=n.type.toDOM;if("function"==typeof s&&(s=s(r,(function(){return i?i.parent?i.parent.posBeforeChild(i):void 0:o}))),!n.type.spec.raw){if(1!=s.nodeType){var a=document.createElement("span");a.appendChild(s),s=a}s.contentEditable=!1,s.classList.add("ProseMirror-widget")}t.call(this,e,H,s,null),this.widget=n,i=this}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={domAtom:{configurable:!0}};return e.prototype.matchesWidget=function(t){return 0==this.dirty&&t.type.eq(this.widget.type)},e.prototype.parseRule=function(){return{ignore:!0}},e.prototype.stopEvent=function(t){var e=this.widget.spec.stopEvent;return!!e&&e(t)},e.prototype.ignoreMutation=function(t){return"selection"!=t.type||this.widget.spec.ignoreSelection},e.prototype.destroy=function(){this.widget.type.destroy(this.dom),t.prototype.destroy.call(this)},n.domAtom.get=function(){return!0},Object.defineProperties(e.prototype,n),e}(K),U=function(t){function e(e,n,r,o){t.call(this,e,H,n,null),this.textDOM=r,this.text=o}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={size:{configurable:!0}};return n.size.get=function(){return this.text.length},e.prototype.localPosFromDOM=function(t,e){return t!=this.textDOM?this.posAtStart+(e?this.size:0):this.posAtStart+e},e.prototype.domFromPos=function(t){return{node:this.textDOM,offset:t}},e.prototype.ignoreMutation=function(t){return"characterData"===t.type&&t.target.nodeValue==t.oldValue},Object.defineProperties(e.prototype,n),e}(K),G=function(t){function e(e,n,r,o){t.call(this,e,[],r,o),this.mark=n}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.create=function(t,n,r,i){var s=i.nodeViews[n.type.name],a=s&&s(n,i,r);return a&&a.dom||(a=o.DOMSerializer.renderSpec(document,n.type.spec.toDOM(n,r))),new e(t,n,a.dom,a.contentDOM||a.dom)},e.prototype.parseRule=function(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}},e.prototype.matchesMark=function(t){return 3!=this.dirty&&this.mark.eq(t)},e.prototype.markDirty=function(e,n){if(t.prototype.markDirty.call(this,e,n),0!=this.dirty){for(var r=this.parent;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=0}},e.prototype.slice=function(t,n,r){var o=e.create(this.parent,this.mark,!0,r),i=this.children,s=this.size;n<s&&(i=pt(i,n,s,r)),t>0&&(i=pt(i,0,t,r));for(var a=0;a<i.length;a++)i[a].parent=o;return o.children=i,o},e}(K),X=function(t){function e(e,n,r,o,i,s,a,c,l){t.call(this,e,n.isLeaf?H:[],i,s),this.nodeDOM=a,this.node=n,this.outerDeco=r,this.innerDeco=o,s&&this.updateChildren(c,l)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={size:{configurable:!0},border:{configurable:!0},domAtom:{configurable:!0}};return e.create=function(t,n,r,i,s,a){var c,l,u=s.nodeViews[n.type.name],p=u&&u(n,s,(function(){return l?l.parent?l.parent.posBeforeChild(l):void 0:a}),r,i),f=p&&p.dom,d=p&&p.contentDOM;if(n.isText)if(f){if(3!=f.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else f=document.createTextNode(n.text);else f||(f=(c=o.DOMSerializer.renderSpec(document,n.type.spec.toDOM(n))).dom,d=c.contentDOM);d||n.isText||"BR"==f.nodeName||(f.hasAttribute("contenteditable")||(f.contentEditable=!1),n.type.spec.draggable&&(f.draggable=!0));var h=f;return f=st(f,r,n),p?l=new tt(t,n,r,i,f,d,h,p,s,a+1):n.isText?new Q(t,n,r,i,f,h,s):new e(t,n,r,i,f,d,h,s,a+1)},e.prototype.parseRule=function(){var t=this;if(this.node.type.spec.reparseInView)return null;var 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(var n=this.children.length-1;n>=0;n--){var r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=function(){return o.Fragment.empty})}else e.contentElement=this.contentDOM;else e.getContent=function(){return t.node.content};return e},e.prototype.matchesNode=function(t,e,n){return 0==this.dirty&&t.eq(this.node)&&at(e,this.outerDeco)&&n.eq(this.innerDeco)},n.size.get=function(){return this.node.nodeSize},n.border.get=function(){return this.node.isLeaf?0:1},e.prototype.updateChildren=function(t,e){var n=this,r=this.node.inlineContent,i=e,a=t.composing&&this.localCompositionInfo(t,e),c=a&&a.pos>-1?a:null,l=a&&a.pos<0,u=new lt(this,c&&c.node);!function(t,e,n,r){var o=e.locals(t),i=0;if(0==o.length){for(var s=0;s<t.childCount;s++){var a=t.child(s);r(a,o,e.forChild(i,a),s),i+=a.nodeSize}return}for(var c=0,l=[],u=null,p=0;;){if(c<o.length&&o[c].to==i){for(var f=o[c++],d=void 0;c<o.length&&o[c].to==i;)(d||(d=[f])).push(o[c++]);if(d){d.sort(ut);for(var h=0;h<d.length;h++)n(d[h],p,!!u)}else n(f,p,!!u)}var m=void 0,v=void 0;if(u)v=-1,m=u,u=null;else{if(!(p<t.childCount))break;v=p,m=t.child(p++)}for(var g=0;g<l.length;g++)l[g].to<=i&&l.splice(g--,1);for(;c<o.length&&o[c].from<=i&&o[c].to>i;)l.push(o[c++]);var y=i+m.nodeSize;if(m.isText){var w=y;c<o.length&&o[c].from<w&&(w=o[c].from);for(var b=0;b<l.length;b++)l[b].to<w&&(w=l[b].to);w<y&&(u=m.cut(w-i),m=m.cut(0,w-i),y=w,v=-1)}var S=l.length?m.isInline&&!m.isLeaf?l.filter((function(t){return!t.inline})):l.slice():H;r(m,S,e.forChild(i,m),v),i=y}}(this.node,this.innerDeco,(function(e,s,a){e.spec.marks?u.syncToMarks(e.spec.marks,r,t):e.type.side>=0&&!a&&u.syncToMarks(s==n.node.childCount?o.Mark.none:n.node.child(s).marks,r,t),u.placeWidget(e,t,i)}),(function(e,n,o,s){var c;u.syncToMarks(e.marks,r,t),u.findNodeMatch(e,n,o,s)||l&&t.state.selection.from>i&&t.state.selection.to<i+e.nodeSize&&(c=u.findIndexWithChild(a.node))>-1&&u.updateNodeAt(e,n,o,c,t)||u.updateNextNode(e,n,o,t,s)||u.addNode(e,n,o,t,i),i+=e.nodeSize})),u.syncToMarks(H,r,t),this.node.isTextblock&&u.addTextblockHacks(),u.destroyRest(),(u.changed||2==this.dirty)&&(c&&this.protectLocalComposition(t,c),function t(e,n,r){for(var o=e.firstChild,i=!1,s=0;s<n.length;s++){var a=n[s],c=a.dom;if(c.parentNode==e){for(;c!=o;)o=ct(o),i=!0;o=o.nextSibling}else i=!0,e.insertBefore(c,o);if(a instanceof G){var l=o?o.previousSibling:e.lastChild;t(a.contentDOM,a.children,r),o=l?l.nextSibling:e.firstChild}}for(;o;)o=ct(o),i=!0;i&&r.trackWrites==e&&(r.trackWrites=null)}(this.contentDOM,this.children,t),s.ios&&function(t){if("UL"==t.nodeName||"OL"==t.nodeName){var e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}(this.dom))},e.prototype.localCompositionInfo=function(t,e){var n=t.state.selection,o=n.from,i=n.to;if(!(!(t.state.selection instanceof r.TextSelection)||o<e||i>e+this.node.content.size)){var s=t.root.getSelection(),a=function(t,e){for(;;){if(3==t.nodeType)return t;if(1==t.nodeType&&e>0){if(t.childNodes.length>e&&3==t.childNodes[e].nodeType)return t.childNodes[e];t=t.childNodes[e-1],e=w(t)}else{if(!(1==t.nodeType&&e<t.childNodes.length))return null;t=t.childNodes[e],e=0}}}(s.focusNode,s.focusOffset);if(a&&this.dom.contains(a.parentNode)){if(this.node.inlineContent){var c=a.nodeValue,l=function(t,e,n,r){for(var o=0,i=0;o<t.childCount&&i<=r;){var s=t.child(o++),a=i;if(i+=s.nodeSize,s.isText){for(var c=s.text;o<t.childCount;){var l=t.child(o++);if(i+=l.nodeSize,!l.isText)break;c+=l.text}if(i>=n){var u=a<r?c.lastIndexOf(e,r-a-1):-1;if(u>=0&&u+e.length+a>=n)return a+u;if(n==r&&c.length>=r+e.length-a&&c.slice(r-a,r-a+e.length)==e)return r}}}return-1}(this.node.content,c,o-e,i-e);return l<0?null:{node:a,pos:l,text:c}}return{node:a,pos:-1}}}},e.prototype.protectLocalComposition=function(t,e){var n=e.node,r=e.pos,o=e.text;if(!this.getDesc(n)){for(var i=n;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=null)}var s=new U(this,i,n,o);t.compositionNodes.push(s),this.children=pt(this.children,r,r+o.length,t,s)}},e.prototype.update=function(t,e,n,r){return!(3==this.dirty||!t.sameMarkup(this.node))&&(this.updateInner(t,e,n,r),!0)},e.prototype.updateInner=function(t,e,n,r){this.updateOuterDeco(e),this.node=t,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=0},e.prototype.updateOuterDeco=function(t){if(!at(t,this.outerDeco)){var e=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=ot(this.dom,this.nodeDOM,rt(this.outerDeco,this.node,e),rt(t,this.node,e)),this.dom!=n&&(n.pmViewDesc=null,this.dom.pmViewDesc=this),this.outerDeco=t}},e.prototype.selectNode=function(){this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.dom.draggable=!0)},e.prototype.deselectNode=function(){this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||this.dom.removeAttribute("draggable")},n.domAtom.get=function(){return this.node.isAtom},Object.defineProperties(e.prototype,n),e}(K);function Y(t,e,n,r,o){return st(r,e,t),new X(null,t,e,n,r,r,r,o,0)}var Q=function(t){function e(e,n,r,o,i,s,a){t.call(this,e,n,r,o,i,null,s,a)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={domAtom:{configurable:!0}};return e.prototype.parseRule=function(){for(var t=this.nodeDOM.parentNode;t&&t!=this.dom&&!t.pmIsDeco;)t=t.parentNode;return{skip:t||!0}},e.prototype.update=function(t,e,n,r){return!(3==this.dirty||0!=this.dirty&&!this.inParent()||!t.sameMarkup(this.node))&&(this.updateOuterDeco(e),0==this.dirty&&t.text==this.node.text||t.text==this.nodeDOM.nodeValue||(this.nodeDOM.nodeValue=t.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=t,this.dirty=0,!0)},e.prototype.inParent=function(){for(var t=this.parent.contentDOM,e=this.nodeDOM;e;e=e.parentNode)if(e==t)return!0;return!1},e.prototype.domFromPos=function(t){return{node:this.nodeDOM,offset:t}},e.prototype.localPosFromDOM=function(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):t.prototype.localPosFromDOM.call(this,e,n,r)},e.prototype.ignoreMutation=function(t){return"characterData"!=t.type&&"selection"!=t.type},e.prototype.slice=function(t,n,r){var o=this.node.cut(t,n),i=document.createTextNode(o.text);return new e(this.parent,o,this.outerDeco,this.innerDeco,i,i,r)},e.prototype.markDirty=function(e,n){t.prototype.markDirty.call(this,e,n),this.dom==this.nodeDOM||0!=e&&n!=this.nodeDOM.nodeValue.length||(this.dirty=3)},n.domAtom.get=function(){return!1},Object.defineProperties(e.prototype,n),e}(X),Z=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={domAtom:{configurable:!0},ignoreForCoords:{configurable:!0}};return e.prototype.parseRule=function(){return{ignore:!0}},e.prototype.matchesHack=function(t){return 0==this.dirty&&this.dom.nodeName==t},n.domAtom.get=function(){return!0},n.ignoreForCoords.get=function(){return"IMG"==this.dom.nodeName},Object.defineProperties(e.prototype,n),e}(K),tt=function(t){function e(e,n,r,o,i,s,a,c,l,u){t.call(this,e,n,r,o,i,s,a,l,u),this.spec=c}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.update=function(e,n,r,o){if(3==this.dirty)return!1;if(this.spec.update){var i=this.spec.update(e,n,r);return i&&this.updateInner(e,n,r,o),i}return!(!this.contentDOM&&!e.isLeaf)&&t.prototype.update.call(this,e,n,r,o)},e.prototype.selectNode=function(){this.spec.selectNode?this.spec.selectNode():t.prototype.selectNode.call(this)},e.prototype.deselectNode=function(){this.spec.deselectNode?this.spec.deselectNode():t.prototype.deselectNode.call(this)},e.prototype.setSelection=function(e,n,r,o){this.spec.setSelection?this.spec.setSelection(e,n,r):t.prototype.setSelection.call(this,e,n,r,o)},e.prototype.destroy=function(){this.spec.destroy&&this.spec.destroy(),t.prototype.destroy.call(this)},e.prototype.stopEvent=function(t){return!!this.spec.stopEvent&&this.spec.stopEvent(t)},e.prototype.ignoreMutation=function(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):t.prototype.ignoreMutation.call(this,e)},e}(X);function et(t){t&&(this.nodeName=t)}et.prototype=Object.create(null);var nt=[new et];function rt(t,e,n){if(0==t.length)return nt;for(var r=n?nt[0]:new et,o=[r],i=0;i<t.length;i++){var s=t[i].type.attrs;if(s)for(var a in s.nodeName&&o.push(r=new et(s.nodeName)),s){var c=s[a];null!=c&&(n&&1==o.length&&o.push(r=new et(e.isInline?"span":"div")),"class"==a?r.class=(r.class?r.class+" ":"")+c:"style"==a?r.style=(r.style?r.style+";":"")+c:"nodeName"!=a&&(r[a]=c))}}return o}function ot(t,e,n,r){if(n==nt&&r==nt)return e;for(var o=e,i=0;i<r.length;i++){var s=r[i],a=n[i];if(i){var c=void 0;a&&a.nodeName==s.nodeName&&o!=t&&(c=o.parentNode)&&c.tagName.toLowerCase()==s.nodeName||((c=document.createElement(s.nodeName)).pmIsDeco=!0,c.appendChild(o),a=nt[0]),o=c}it(o,a||nt[0],s)}return o}function it(t,e,n){for(var r in e)"class"==r||"style"==r||"nodeName"==r||r in n||t.removeAttribute(r);for(var o in n)"class"!=o&&"style"!=o&&"nodeName"!=o&&n[o]!=e[o]&&t.setAttribute(o,n[o]);if(e.class!=n.class){for(var i=e.class?e.class.split(" ").filter(Boolean):H,s=n.class?n.class.split(" ").filter(Boolean):H,a=0;a<i.length;a++)-1==s.indexOf(i[a])&&t.classList.remove(i[a]);for(var c=0;c<s.length;c++)-1==i.indexOf(s[c])&&t.classList.add(s[c]);0==t.classList.length&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style)for(var l,u=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;l=u.exec(e.style);)t.style.removeProperty(l[1]);n.style&&(t.style.cssText+=n.style)}}function st(t,e,n){return ot(t,t,nt,rt(e,n,1!=t.nodeType))}function at(t,e){if(t.length!=e.length)return!1;for(var n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return!1;return!0}function ct(t){var e=t.nextSibling;return t.parentNode.removeChild(t),e}var lt=function(t,e){this.top=t,this.lock=e,this.index=0,this.stack=[],this.changed=!1,this.preMatch=function(t,e){var n=e,r=n.children.length,o=t.childCount,i=new Map,s=[];t:for(;o>0;){for(var a=void 0;;)if(r){var c=n.children[r-1];if(!(c instanceof G)){a=c,r--;break}n=c,r=c.children.length}else{if(n==e)break t;r=n.parent.children.indexOf(n),n=n.parent}var l=a.node;if(l){if(l!=t.child(o-1))break;--o,i.set(a,o),s.push(a)}}return{index:o,matched:i,matches:s.reverse()}}(t.node.content,t)};function ut(t,e){return t.type.side-e.type.side}function pt(t,e,n,r,o){for(var i=[],s=0,a=0;s<t.length;s++){var c=t[s],l=a,u=a+=c.size;l>=n||u<=e?i.push(c):(l<e&&i.push(c.slice(0,e-l,r)),o&&(i.push(o),o=null),u>n&&i.push(c.slice(n-l,c.size,r)))}return i}function ft(t,e){var n=t.root.getSelection(),o=t.state.doc;if(!n.focusNode)return null;var i=t.docView.nearestDesc(n.focusNode),s=i&&0==i.size,a=t.docView.posFromDOM(n.focusNode,n.focusOffset);if(a<0)return null;var c,l,u=o.resolve(a);if(S(n)){for(c=u;i&&!i.node;)i=i.parent;if(i&&i.node.isAtom&&r.NodeSelection.isSelectable(i.node)&&i.parent&&(!i.node.isInline||!function(t,e,n){for(var r=0==e,o=e==w(t);r||o;){if(t==n)return!0;var i=f(t);if(!(t=t.parentNode))return!1;r=r&&0==i,o=o&&i==w(t)}}(n.focusNode,n.focusOffset,i.dom))){var p=i.posBefore;l=new r.NodeSelection(a==p?u:o.resolve(p))}}else{var d=t.docView.posFromDOM(n.anchorNode,n.anchorOffset);if(d<0)return null;c=o.resolve(d)}l||(l=St(t,c,u,"pointer"==e||t.state.selection.head<u.pos&&!s?1:-1));return l}function dt(t){return t.editable?t.hasFocus():kt(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function ht(t,e){var n=t.state.selection;if(wt(t,n),dt(t)){if(!e&&t.mouseDown&&t.mouseDown.allowDefault&&s.chrome){var o=t.root.getSelection(),i=t.domObserver.currentSelection;if(o.anchorNode&&v(o.anchorNode,o.anchorOffset,i.anchorNode,i.anchorOffset))return t.mouseDown.delayedSelectionSync=!0,void t.domObserver.setCurSelection()}if(t.domObserver.disconnectSelection(),t.cursorWrapper)!function(t){var e=t.root.getSelection(),n=document.createRange(),r=t.cursorWrapper.dom,o="IMG"==r.nodeName;o?n.setEnd(r.parentNode,f(r)+1):n.setEnd(r,0);n.collapse(!1),e.removeAllRanges(),e.addRange(n),!o&&!t.state.selection.visible&&s.ie&&s.ie_version<=11&&(r.disabled=!0,r.disabled=!1)}(t);else{var a,c,l=n.anchor,u=n.head;!mt||n instanceof r.TextSelection||(n.$from.parent.inlineContent||(a=vt(t,n.from)),n.empty||n.$from.parent.inlineContent||(c=vt(t,n.to))),t.docView.setSelection(l,u,t.root,e),mt&&(a&&yt(a),c&&yt(c)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(t){var e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.hideSelectionGuard);var n=t.root.getSelection(),r=n.anchorNode,o=n.anchorOffset;e.addEventListener("selectionchange",t.hideSelectionGuard=function(){n.anchorNode==r&&n.anchorOffset==o||(e.removeEventListener("selectionchange",t.hideSelectionGuard),setTimeout((function(){dt(t)&&!t.state.selection.visible||t.dom.classList.remove("ProseMirror-hideselection")}),20))})}(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}lt.prototype.destroyBetween=function(t,e){if(t!=e){for(var n=t;n<e;n++)this.top.children[n].destroy();this.top.children.splice(t,e-t),this.changed=!0}},lt.prototype.destroyRest=function(){this.destroyBetween(this.index,this.top.children.length)},lt.prototype.syncToMarks=function(t,e,n){for(var r=0,o=this.stack.length>>1,i=Math.min(o,t.length);r<i&&(r==o-1?this.top:this.stack[r+1<<1]).matchesMark(t[r])&&!1!==t[r].type.spec.spanning;)r++;for(;r<o;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<t.length;){this.stack.push(this.top,this.index+1);for(var s=-1,a=this.index;a<Math.min(this.index+3,this.top.children.length);a++)if(this.top.children[a].matchesMark(t[o])){s=a;break}if(s>-1)s>this.index&&(this.changed=!0,this.destroyBetween(this.index,s)),this.top=this.top.children[this.index];else{var c=G.create(this.top,t[o],e,n);this.top.children.splice(this.index,0,c),this.top=c,this.changed=!0}this.index=0,o++}},lt.prototype.findNodeMatch=function(t,e,n,r){var o,i=-1;if(r>=this.preMatch.index&&(o=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&o.matchesNode(t,e,n))i=this.top.children.indexOf(o,this.index);else for(var s=this.index,a=Math.min(this.top.children.length,s+5);s<a;s++){var c=this.top.children[s];if(c.matchesNode(t,e,n)&&!this.preMatch.matched.has(c)){i=s;break}}return!(i<0)&&(this.destroyBetween(this.index,i),this.index++,!0)},lt.prototype.updateNodeAt=function(t,e,n,r,o){return!!this.top.children[r].update(t,e,n,o)&&(this.destroyBetween(this.index,r),this.index=r+1,!0)},lt.prototype.findIndexWithChild=function(t){for(;;){var e=t.parentNode;if(!e)return-1;if(e==this.top.contentDOM){var n=t.pmViewDesc;if(n)for(var r=this.index;r<this.top.children.length;r++)if(this.top.children[r]==n)return r;return-1}t=e}},lt.prototype.updateNextNode=function(t,e,n,r,o){for(var i=this.index;i<this.top.children.length;i++){var s=this.top.children[i];if(s instanceof X){var a=this.preMatch.matched.get(s);if(null!=a&&a!=o)return!1;var c=s.dom;if(!(this.lock&&(c==this.lock||1==c.nodeType&&c.contains(this.lock.parentNode))&&!(t.isText&&s.node&&s.node.isText&&s.nodeDOM.nodeValue==t.text&&3!=s.dirty&&at(e,s.outerDeco)))&&s.update(t,e,n,r))return this.destroyBetween(this.index,i),s.dom!=c&&(this.changed=!0),this.index++,!0;break}}return!1},lt.prototype.addNode=function(t,e,n,r,o){this.top.children.splice(this.index++,0,X.create(this.top,t,e,n,r,o)),this.changed=!0},lt.prototype.placeWidget=function(t,e,n){var r=this.index<this.top.children.length?this.top.children[this.index]:null;if(!r||!r.matchesWidget(t)||t!=r.widget&&r.widget.type.toDOM.parentNode){var o=new J(this.top,t,e,n);this.top.children.splice(this.index++,0,o),this.changed=!0}else this.index++},lt.prototype.addTextblockHacks=function(){for(var t=this.top.children[this.index-1];t instanceof G;)t=t.children[t.children.length-1];t&&t instanceof Q&&!/\n$/.test(t.node.text)||((s.safari||s.chrome)&&t&&"false"==t.dom.contentEditable&&this.addHackNode("IMG"),this.addHackNode("BR"))},lt.prototype.addHackNode=function(t){if(this.index<this.top.children.length&&this.top.children[this.index].matchesHack(t))this.index++;else{var e=document.createElement(t);"IMG"==t&&(e.className="ProseMirror-separator",e.alt=""),"BR"==t&&(e.className="ProseMirror-trailingBreak"),this.top.children.splice(this.index++,0,new Z(this.top,H,e,null)),this.changed=!0}};var mt=s.safari||s.chrome&&s.chrome_version<63;function vt(t,e){var n=t.docView.domFromPos(e,0),r=n.node,o=n.offset,i=o<r.childNodes.length?r.childNodes[o]:null,a=o?r.childNodes[o-1]:null;if(s.safari&&i&&"false"==i.contentEditable)return gt(i);if(!(i&&"false"!=i.contentEditable||a&&"false"!=a.contentEditable)){if(i)return gt(i);if(a)return gt(a)}}function gt(t){return t.contentEditable="true",s.safari&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function yt(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function wt(t,e){if(e instanceof r.NodeSelection){var n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(bt(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else bt(t)}function bt(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=null)}function St(t,e,n,o){return t.someProp("createSelectionBetween",(function(r){return r(t,e,n)}))||r.TextSelection.between(e,n,o)}function kt(t){var e=t.root.getSelection();if(!e.anchorNode)return!1;try{return t.dom.contains(3==e.anchorNode.nodeType?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(3==e.focusNode.nodeType?e.focusNode.parentNode:e.focusNode))}catch(t){return!1}}function xt(t,e){var n=t.selection,o=n.$anchor,i=n.$head,s=e>0?o.max(i):o.min(i),a=s.parent.inlineContent?s.depth?t.doc.resolve(e>0?s.after():s.before()):null:s;return a&&r.Selection.findFrom(a,e)}function Ct(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function Mt(t,e,n){var o=t.state.selection;if(!(o instanceof r.TextSelection)){if(o instanceof r.NodeSelection&&o.node.isInline)return Ct(t,new r.TextSelection(e>0?o.$to:o.$from));var i=xt(t.state,e);return!!i&&Ct(t,i)}if(!o.empty||n.indexOf("s")>-1)return!1;if(t.endOfTextblock(e>0?"right":"left")){var a=xt(t.state,e);return!!(a&&a instanceof r.NodeSelection)&&Ct(t,a)}if(!(s.mac&&n.indexOf("m")>-1)){var c,l=o.$head,u=l.textOffset?null:e<0?l.nodeBefore:l.nodeAfter;if(!u||u.isText)return!1;var p=e<0?l.pos-u.nodeSize:l.pos;return!!(u.isAtom||(c=t.docView.descAt(p))&&!c.contentDOM)&&(r.NodeSelection.isSelectable(u)?Ct(t,new r.NodeSelection(e<0?t.state.doc.resolve(l.pos-u.nodeSize):l)):!!s.webkit&&Ct(t,new r.TextSelection(t.state.doc.resolve(e<0?p:p+u.nodeSize))))}}function Ot(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function Tt(t){var e=t.pmViewDesc;return e&&0==e.size&&(t.nextSibling||"BR"!=t.nodeName)}function Nt(t){var e=t.root.getSelection(),n=e.focusNode,r=e.focusOffset;if(n){var o,i,a=!1;for(s.gecko&&1==n.nodeType&&r<Ot(n)&&Tt(n.childNodes[r])&&(a=!0);;)if(r>0){if(1!=n.nodeType)break;var c=n.childNodes[r-1];if(Tt(c))o=n,i=--r;else{if(3!=c.nodeType)break;r=(n=c).nodeValue.length}}else{if(Dt(n))break;for(var l=n.previousSibling;l&&Tt(l);)o=n.parentNode,i=f(l),l=l.previousSibling;if(l)r=Ot(n=l);else{if((n=n.parentNode)==t.dom)break;r=0}}a?Et(t,e,n,r):o&&Et(t,e,o,i)}}function At(t){var e=t.root.getSelection(),n=e.focusNode,r=e.focusOffset;if(n){for(var o,i,s=Ot(n);;)if(r<s){if(1!=n.nodeType)break;if(!Tt(n.childNodes[r]))break;o=n,i=++r}else{if(Dt(n))break;for(var a=n.nextSibling;a&&Tt(a);)o=a.parentNode,i=f(a)+1,a=a.nextSibling;if(a)r=0,s=Ot(n=a);else{if((n=n.parentNode)==t.dom)break;r=s=0}}o&&Et(t,e,o,i)}}function Dt(t){var e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function Et(t,e,n,r){if(S(e)){var o=document.createRange();o.setEnd(n,r),o.setStart(n,r),e.removeAllRanges(),e.addRange(o)}else e.extend&&e.extend(n,r);t.domObserver.setCurSelection();var i=t.state;setTimeout((function(){t.state==i&&ht(t)}),50)}function Rt(t,e,n){var o=t.state.selection;if(o instanceof r.TextSelection&&!o.empty||n.indexOf("s")>-1)return!1;if(s.mac&&n.indexOf("m")>-1)return!1;var i=o.$from,a=o.$to;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){var c=xt(t.state,e);if(c&&c instanceof r.NodeSelection)return Ct(t,c)}if(!i.parent.inlineContent){var l=e<0?i:a,u=o instanceof r.AllSelection?r.Selection.near(l,e):r.Selection.findFrom(l,e);return!!u&&Ct(t,u)}return!1}function _t(t,e){if(!(t.state.selection instanceof r.TextSelection))return!0;var n=t.state.selection,o=n.$head,i=n.$anchor,s=n.empty;if(!o.sameParent(i))return!0;if(!s)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;var a=!o.textOffset&&(e<0?o.nodeBefore:o.nodeAfter);if(a&&!a.isText){var c=t.state.tr;return e<0?c.delete(o.pos-a.nodeSize,o.pos):c.delete(o.pos,o.pos+a.nodeSize),t.dispatch(c),!0}return!1}function It(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function zt(t,e){var n=e.keyCode,r=function(t){var e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}(e);return 8==n||s.mac&&72==n&&"c"==r?_t(t,-1)||Nt(t):46==n||s.mac&&68==n&&"c"==r?_t(t,1)||At(t):13==n||27==n||(37==n?Mt(t,-1,r)||Nt(t):39==n?Mt(t,1,r)||At(t):38==n?Rt(t,-1,r)||Nt(t):40==n?function(t){if(s.safari&&!(t.state.selection.$head.parentOffset>0)){var e=t.root.getSelection(),n=e.focusNode,r=e.focusOffset;if(n&&1==n.nodeType&&0==r&&n.firstChild&&"false"==n.firstChild.contentEditable){var o=n.firstChild;It(t,o,!0),setTimeout((function(){return It(t,o,!1)}),20)}}}(t)||Rt(t,1,r)||At(t):r==(s.mac?"m":"c")&&(66==n||73==n||89==n||90==n))}function Pt(t){var e=t.pmViewDesc;if(e)return e.parseRule();if("BR"==t.nodeName&&t.parentNode){if(s.safari&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){var n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}if(t.parentNode.lastChild==t||s.safari&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if("IMG"==t.nodeName&&t.getAttribute("mark-placeholder"))return{ignore:!0}}function $t(t,e,n,i,a){if(e<0){var c=t.lastSelectionTime>Date.now()-50?t.lastSelectionOrigin:null,l=ft(t,c);if(l&&!t.state.selection.eq(l)){var u=t.state.tr.setSelection(l);"pointer"==c?u.setMeta("pointer",!0):"key"==c&&u.scrollIntoView(),t.dispatch(u)}}else{var p=t.state.doc.resolve(e),f=p.sharedDepth(n);e=p.before(f+1),n=t.state.doc.resolve(n).after(f+1);var d=t.state.selection,h=function(t,e,n){var r=t.docView.parseRange(e,n),i=r.node,a=r.fromOffset,c=r.toOffset,l=r.from,u=r.to,p=t.root.getSelection(),f=null,d=p.anchorNode;if(d&&t.dom.contains(1==d.nodeType?d:d.parentNode)&&(f=[{node:d,offset:p.anchorOffset}],S(p)||f.push({node:p.focusNode,offset:p.focusOffset})),s.chrome&&8===t.lastKeyCode)for(var h=c;h>a;h--){var m=i.childNodes[h-1],v=m.pmViewDesc;if("BR"==m.nodeName&&!v){c=h;break}if(!v||v.size)break}var g=t.state.doc,y=t.someProp("domParser")||o.DOMParser.fromSchema(t.state.schema),w=g.resolve(l),b=null,k=y.parse(i,{topNode:w.parent,topMatch:w.parent.contentMatchAt(w.index()),topOpen:!0,from:a,to:c,preserveWhitespace:"pre"!=w.parent.type.whitespace||"full",editableContent:!0,findPositions:f,ruleFromNode:Pt,context:w});if(f&&null!=f[0].pos){var x=f[0].pos,C=f[1]&&f[1].pos;null==C&&(C=x),b={anchor:x+l,head:C+l}}return{doc:k,sel:b,from:l,to:u}}(t,e,n);if(s.chrome&&t.cursorWrapper&&h.sel&&h.sel.anchor==t.cursorWrapper.deco.from){var m=t.cursorWrapper.deco.type.toDOM.nextSibling,v=m&&m.nodeValue?m.nodeValue.length:1;h.sel={anchor:h.sel.anchor+v,head:h.sel.anchor+v}}var g,y,w=t.state.doc,b=w.slice(h.from,h.to);8===t.lastKeyCode&&Date.now()-100<t.lastKeyCodeTime?(g=t.state.selection.to,y="end"):(g=t.state.selection.from,y="start"),t.lastKeyCode=null;var x=function(t,e,n,r,o){var i=t.findDiffStart(e,n);if(null==i)return null;var s=t.findDiffEnd(e,n+t.size,n+e.size),a=s.a,c=s.b;if("end"==o){var l=Math.max(0,i-Math.min(a,c));r-=a+l-i}if(a<i&&t.size<e.size){c=(i-=r<=i&&r>=a?i-r:0)+(c-a),a=i}else if(c<i){a=(i-=r<=i&&r>=c?i-r:0)+(a-c),c=i}return{start:i,endA:a,endB:c}}(b.content,h.doc.content,h.from,g,y);if(!x){if(!(i&&d instanceof r.TextSelection&&!d.empty&&d.$head.sameParent(d.$anchor))||t.composing||h.sel&&h.sel.anchor!=h.sel.head){if((s.ios&&t.lastIOSEnter>Date.now()-225||s.android)&&a.some((function(t){return"DIV"==t.nodeName||"P"==t.nodeName}))&&t.someProp("handleKeyDown",(function(e){return e(t,k(13,"Enter"))})))return void(t.lastIOSEnter=0);if(h.sel){var C=Ft(t,t.state.doc,h.sel);C&&!C.eq(t.state.selection)&&t.dispatch(t.state.tr.setSelection(C))}return}x={start:d.from,endA:d.to,endB:d.to}}t.domChangeCount++,t.state.selection.from<t.state.selection.to&&x.start==x.endB&&t.state.selection instanceof r.TextSelection&&(x.start>t.state.selection.from&&x.start<=t.state.selection.from+2&&t.state.selection.from>=h.from?x.start=t.state.selection.from:x.endA<t.state.selection.to&&x.endA>=t.state.selection.to-2&&t.state.selection.to<=h.to&&(x.endB+=t.state.selection.to-x.endA,x.endA=t.state.selection.to)),s.ie&&s.ie_version<=11&&x.endB==x.start+1&&x.endA==x.start&&x.start>h.from&&" "==h.doc.textBetween(x.start-h.from-1,x.start-h.from+1)&&(x.start--,x.endA--,x.endB--);var M,O=h.doc.resolveNoCache(x.start-h.from),T=h.doc.resolveNoCache(x.endB-h.from),N=O.sameParent(T)&&O.parent.inlineContent;if((s.ios&&t.lastIOSEnter>Date.now()-225&&(!N||a.some((function(t){return"DIV"==t.nodeName||"P"==t.nodeName})))||!N&&O.pos<h.doc.content.size&&(M=r.Selection.findFrom(h.doc.resolve(O.pos+1),1,!0))&&M.head==T.pos)&&t.someProp("handleKeyDown",(function(e){return e(t,k(13,"Enter"))})))t.lastIOSEnter=0;else if(t.state.selection.anchor>x.start&&function(t,e,n,r,o){if(!r.parent.isTextblock||n-e<=o.pos-r.pos||Bt(r,!0,!1)<o.pos)return!1;var i=t.resolve(e);if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;var s=t.resolve(Bt(i,!0,!0));if(!s.parent.isTextblock||s.pos>n||Bt(s,!0,!1)<n)return!1;return r.parent.content.cut(r.parentOffset).eq(s.parent.content)}(w,x.start,x.endA,O,T)&&t.someProp("handleKeyDown",(function(e){return e(t,k(8,"Backspace"))})))s.android&&s.chrome&&t.domObserver.suppressSelectionUpdates();else{s.chrome&&s.android&&x.toB==x.from&&(t.lastAndroidDelete=Date.now()),s.android&&!N&&O.start()!=T.start()&&0==T.parentOffset&&O.depth==T.depth&&h.sel&&h.sel.anchor==h.sel.head&&h.sel.head==x.endA&&(x.endB-=2,T=h.doc.resolveNoCache(x.endB-h.from),setTimeout((function(){t.someProp("handleKeyDown",(function(e){return e(t,k(13,"Enter"))}))}),20));var A,D,E,R,_=x.start,I=x.endA;if(N)if(O.pos==T.pos)s.ie&&s.ie_version<=11&&0==O.parentOffset&&(t.domObserver.suppressSelectionUpdates(),setTimeout((function(){return ht(t)}),20)),A=t.state.tr.delete(_,I),D=w.resolve(x.start).marksAcross(w.resolve(x.endA));else if(x.endA==x.endB&&(R=w.resolve(x.start))&&(E=function(t,e){for(var n,r,i,s=t.firstChild.marks,a=e.firstChild.marks,c=s,l=a,u=0;u<a.length;u++)c=a[u].removeFromSet(c);for(var p=0;p<s.length;p++)l=s[p].removeFromSet(l);if(1==c.length&&0==l.length)r=c[0],n="add",i=function(t){return t.mark(r.addToSet(t.marks))};else{if(0!=c.length||1!=l.length)return null;r=l[0],n="remove",i=function(t){return t.mark(r.removeFromSet(t.marks))}}for(var f=[],d=0;d<e.childCount;d++)f.push(i(e.child(d)));if(o.Fragment.from(f).eq(t))return{mark:r,type:n}}(O.parent.content.cut(O.parentOffset,T.parentOffset),R.parent.content.cut(R.parentOffset,x.endA-R.start()))))A=t.state.tr,"add"==E.type?A.addMark(_,I,E.mark):A.removeMark(_,I,E.mark);else if(O.parent.child(O.index()).isText&&O.index()==T.index()-(T.textOffset?0:1)){var z=O.parent.textBetween(O.parentOffset,T.parentOffset);if(t.someProp("handleTextInput",(function(e){return e(t,_,I,z)})))return;A=t.state.tr.insertText(z,_,I)}if(A||(A=t.state.tr.replace(_,I,h.doc.slice(x.start-h.from,x.endB-h.from))),h.sel){var P=Ft(t,A.doc,h.sel);P&&!(s.chrome&&s.android&&t.composing&&P.empty&&(x.start!=x.endB||t.lastAndroidDelete<Date.now()-100)&&(P.head==_||P.head==A.mapping.map(I)-1)||s.ie&&P.empty&&P.head==_)&&A.setSelection(P)}D&&A.ensureMarks(D),t.dispatch(A.scrollIntoView())}}}function Ft(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:St(t,e.resolve(n.anchor),e.resolve(n.head))}function Bt(t,e,n){for(var r=t.depth,o=e?t.end():t.pos;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,o++,e=!1;if(n)for(var i=t.node(r).maybeChild(t.indexAfter(r));i&&!i.isLeaf;)i=i.firstChild,o++;return o}function Lt(t,e){for(var n=[],r=e.content,i=e.openStart,s=e.openEnd;i>1&&s>1&&1==r.childCount&&1==r.firstChild.childCount;){i--,s--;var a=r.firstChild;n.push(a.type.name,a.attrs!=a.type.defaultAttrs?a.attrs:null),r=a.content}var c=t.someProp("clipboardSerializer")||o.DOMSerializer.fromSchema(t.state.schema),l=Ut(),u=l.createElement("div");u.appendChild(c.serializeFragment(r,{document:l}));for(var p,f=u.firstChild;f&&1==f.nodeType&&(p=Ht[f.nodeName.toLowerCase()]);){for(var d=p.length-1;d>=0;d--){for(var h=l.createElement(p[d]);u.firstChild;)h.appendChild(u.firstChild);u.appendChild(h),"tbody"!=p[d]&&(i++,s++)}f=u.firstChild}return f&&1==f.nodeType&&f.setAttribute("data-pm-slice",i+" "+s+" "+JSON.stringify(n)),{dom:u,text:t.someProp("clipboardTextSerializer",(function(t){return t(e)}))||e.content.textBetween(0,e.content.size,"\n\n")}}function Vt(t,e,n,r,i){var a,c,l=i.parent.type.spec.code;if(!n&&!e)return null;var u=e&&(r||l||!n);if(u){if(t.someProp("transformPastedText",(function(t){e=t(e,l||r)})),l)return e?new o.Slice(o.Fragment.from(t.state.schema.text(e.replace(/\r\n?/g,"\n"))),0,0):o.Slice.empty;var p=t.someProp("clipboardTextParser",(function(t){return t(e,i,r)}));if(p)c=p;else{var f=i.marks(),d=t.state.schema,h=o.DOMSerializer.fromSchema(d);a=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach((function(t){var e=a.appendChild(document.createElement("p"));t&&e.appendChild(h.serializeNode(d.text(t,f)))}))}}else t.someProp("transformPastedHTML",(function(t){n=t(n)})),a=function(t){var e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));var n,r=Ut().createElement("div"),o=/<([a-z][^>\s]+)/i.exec(t);(n=o&&Ht[o[1].toLowerCase()])&&(t=n.map((function(t){return"<"+t+">"})).join("")+t+n.map((function(t){return"</"+t+">"})).reverse().join(""));if(r.innerHTML=t,n)for(var i=0;i<n.length;i++)r=r.querySelector(n[i])||r;return r}(n),s.webkit&&function(t){for(var e=t.querySelectorAll(s.chrome?"span:not([class]):not([style])":"span.Apple-converted-space"),n=0;n<e.length;n++){var r=e[n];1==r.childNodes.length&&" "==r.textContent&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}(a);var m=a&&a.querySelector("[data-pm-slice]"),v=m&&/^(\d+) (\d+) (.*)/.exec(m.getAttribute("data-pm-slice"));if(!c){var g=t.someProp("clipboardParser")||t.someProp("domParser")||o.DOMParser.fromSchema(t.state.schema);c=g.parseSlice(a,{preserveWhitespace:!(!u&&!v),context:i,ruleFromNode:function(t){if("BR"==t.nodeName&&!t.nextSibling&&t.parentNode&&!jt.test(t.parentNode.nodeName))return{ignore:!0}}})}if(v)c=function(t,e){if(!t.size)return t;var n,r=t.content.firstChild.type.schema;try{n=JSON.parse(e)}catch(e){return t}for(var i=t.content,s=t.openStart,a=t.openEnd,c=n.length-2;c>=0;c-=2){var l=r.nodes[n[c]];if(!l||l.hasRequiredAttrs())break;i=o.Fragment.from(l.create(n[c+1],i)),s++,a++}return new o.Slice(i,s,a)}(qt(c,+v[1],+v[2]),v[3]);else if((c=o.Slice.maxOpen(function(t,e){if(t.childCount<2)return t;for(var n=function(n){var r=e.node(n).contentMatchAt(e.index(n)),i=void 0,s=[];if(t.forEach((function(t){if(s){var e,n=r.findWrapping(t.type);if(!n)return s=null;if(e=s.length&&i.length&&function t(e,n,r,i,s){if(s<e.length&&s<n.length&&e[s]==n[s]){var a=t(e,n,r,i.lastChild,s+1);if(a)return i.copy(i.content.replaceChild(i.childCount-1,a));if(i.contentMatchAt(i.childCount).matchType(s==e.length-1?r.type:e[s+1]))return i.copy(i.content.append(o.Fragment.from(Wt(r,e,s+1))))}}(n,i,t,s[s.length-1],0))s[s.length-1]=e;else{s.length&&(s[s.length-1]=function t(e,n){if(0==n)return e;var r=e.content.replaceChild(e.childCount-1,t(e.lastChild,n-1)),i=e.contentMatchAt(e.childCount).fillBefore(o.Fragment.empty,!0);return e.copy(r.append(i))}(s[s.length-1],i.length));var a=Wt(t,n);s.push(a),r=r.matchType(a.type,a.attrs),i=n}}})),s)return{v:o.Fragment.from(s)}},r=e.depth;r>=0;r--){var i=n(r);if(i)return i.v}return t}(c.content,i),!0)).openStart||c.openEnd){for(var y=0,w=0,b=c.content.firstChild;y<c.openStart&&!b.type.spec.isolating;y++,b=b.firstChild);for(var S=c.content.lastChild;w<c.openEnd&&!S.type.spec.isolating;w++,S=S.lastChild);c=qt(c,y,w)}return t.someProp("transformPasted",(function(t){c=t(c)})),c}var jt=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function Wt(t,e,n){void 0===n&&(n=0);for(var r=e.length-1;r>=n;r--)t=e[r].create(null,o.Fragment.from(t));return t}function Kt(t,e,n,r,i,s){var a=e<0?t.firstChild:t.lastChild,c=a.content;return i<r-1&&(c=Kt(c,e,n,r,i+1,s)),i>=n&&(c=e<0?a.contentMatchAt(0).fillBefore(c,t.childCount>1||s<=i).append(c):c.append(a.contentMatchAt(a.childCount).fillBefore(o.Fragment.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,a.copy(c))}function qt(t,e,n){return e<t.openStart&&(t=new o.Slice(Kt(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new o.Slice(Kt(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}var Ht={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]},Jt=null;function Ut(){return Jt||(Jt=document.implementation.createHTMLDocument("title"))}var Gt={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Xt=s.ie&&s.ie_version<=11,Yt=function(){this.anchorNode=this.anchorOffset=this.focusNode=this.focusOffset=null};Yt.prototype.set=function(t){this.anchorNode=t.anchorNode,this.anchorOffset=t.anchorOffset,this.focusNode=t.focusNode,this.focusOffset=t.focusOffset},Yt.prototype.eq=function(t){return t.anchorNode==this.anchorNode&&t.anchorOffset==this.anchorOffset&&t.focusNode==this.focusNode&&t.focusOffset==this.focusOffset};var Qt=function(t,e){var n=this;this.view=t,this.handleDOMChange=e,this.queue=[],this.flushingSoon=-1,this.observer=window.MutationObserver&&new window.MutationObserver((function(t){for(var e=0;e<t.length;e++)n.queue.push(t[e]);s.ie&&s.ie_version<=11&&t.some((function(t){return"childList"==t.type&&t.removedNodes.length||"characterData"==t.type&&t.oldValue.length>t.target.nodeValue.length}))?n.flushSoon():n.flush()})),this.currentSelection=new Yt,Xt&&(this.onCharData=function(t){n.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),n.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.suppressingSelectionUpdates=!1};Qt.prototype.flushSoon=function(){var t=this;this.flushingSoon<0&&(this.flushingSoon=window.setTimeout((function(){t.flushingSoon=-1,t.flush()}),20))},Qt.prototype.forceFlush=function(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())},Qt.prototype.start=function(){this.observer&&this.observer.observe(this.view.dom,Gt),Xt&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()},Qt.prototype.stop=function(){var t=this;if(this.observer){var e=this.observer.takeRecords();if(e.length){for(var n=0;n<e.length;n++)this.queue.push(e[n]);window.setTimeout((function(){return t.flush()}),20)}this.observer.disconnect()}Xt&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()},Qt.prototype.connectSelection=function(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)},Qt.prototype.disconnectSelection=function(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)},Qt.prototype.suppressSelectionUpdates=function(){var t=this;this.suppressingSelectionUpdates=!0,setTimeout((function(){return t.suppressingSelectionUpdates=!1}),50)},Qt.prototype.onSelectionChange=function(){if((!(t=this.view).editable||t.root.activeElement==t.dom)&&kt(t)){var t;if(this.suppressingSelectionUpdates)return ht(this.view);if(s.ie&&s.ie_version<=11&&!this.view.state.selection.empty){var e=this.view.root.getSelection();if(e.focusNode&&v(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}},Qt.prototype.setCurSelection=function(){this.currentSelection.set(this.view.root.getSelection())},Qt.prototype.ignoreSelectionChange=function(t){if(0==t.rangeCount)return!0;var e=t.getRangeAt(0).commonAncestorContainer,n=this.view.docView.nearestDesc(e);return n&&n.ignoreMutation({type:"selection",target:3==e.nodeType?e.parentNode:e})?(this.setCurSelection(),!0):void 0},Qt.prototype.flush=function(){if(this.view.docView&&!(this.flushingSoon>-1)){var t=this.observer?this.observer.takeRecords():[];this.queue.length&&(t=this.queue.concat(t),this.queue.length=0);var e=this.view.root.getSelection(),n=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(e)&&kt(this.view)&&!this.ignoreSelectionChange(e),r=-1,o=-1,i=!1,a=[];if(this.view.editable)for(var c=0;c<t.length;c++){var l=this.registerMutation(t[c],a);l&&(r=r<0?l.from:Math.min(l.from,r),o=o<0?l.to:Math.max(l.to,o),l.typeOver&&(i=!0))}if(s.gecko&&a.length>1){var u=a.filter((function(t){return"BR"==t.nodeName}));if(2==u.length){var p=u[0],f=u[1];p.parentNode&&p.parentNode.parentNode==f.parentNode?f.remove():p.remove()}}(r>-1||n)&&(r>-1&&(this.view.docView.markDirty(r,o),function(t){if(Zt)return;Zt=!0,"normal"==getComputedStyle(t.dom).whiteSpace&&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.")}(this.view)),this.handleDOMChange(r,o,i,a),this.view.docView&&this.view.docView.dirty?this.view.updateState(this.view.state):this.currentSelection.eq(e)||ht(this.view),this.currentSelection.set(e))}},Qt.prototype.registerMutation=function(t,e){if(e.indexOf(t.target)>-1)return null;var n=this.view.docView.nearestDesc(t.target);if("attributes"==t.type&&(n==this.view.docView||"contenteditable"==t.attributeName||"style"==t.attributeName&&!t.oldValue&&!t.target.getAttribute("style")))return null;if(!n||n.ignoreMutation(t))return null;if("childList"==t.type){for(var r=0;r<t.addedNodes.length;r++)e.push(t.addedNodes[r]);if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(t.target))return{from:n.posBefore,to:n.posAfter};var o=t.previousSibling,i=t.nextSibling;if(s.ie&&s.ie_version<=11&&t.addedNodes.length)for(var a=0;a<t.addedNodes.length;a++){var c=t.addedNodes[a],l=c.previousSibling,u=c.nextSibling;(!l||Array.prototype.indexOf.call(t.addedNodes,l)<0)&&(o=l),(!u||Array.prototype.indexOf.call(t.addedNodes,u)<0)&&(i=u)}var p=o&&o.parentNode==t.target?f(o)+1:0,d=n.localPosFromDOM(t.target,p,-1),h=i&&i.parentNode==t.target?f(i):t.target.childNodes.length;return{from:d,to:n.localPosFromDOM(t.target,h,1)}}return"attributes"==t.type?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:{from:n.posAtStart,to:n.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}};var Zt=!1;var te={},ee={};function ne(t,e){t.lastSelectionOrigin=e,t.lastSelectionTime=Date.now()}function re(t){t.someProp("handleDOMEvents",(function(e){for(var n in e)t.eventHandlers[n]||t.dom.addEventListener(n,t.eventHandlers[n]=function(e){return oe(t,e)})}))}function oe(t,e){return t.someProp("handleDOMEvents",(function(n){var r=n[e.type];return!!r&&(r(t,e)||e.defaultPrevented)}))}function ie(t){return{left:t.clientX,top:t.clientY}}function se(t,e,n,r,o){if(-1==r)return!1;for(var i=t.state.doc.resolve(r),s=function(r){if(t.someProp(e,(function(e){return r>i.depth?e(t,n,i.nodeAfter,i.before(r),o,!0):e(t,n,i.node(r),i.before(r),o,!1)})))return{v:!0}},a=i.depth+1;a>0;a--){var c=s(a);if(c)return c.v}return!1}function ae(t,e,n){t.focused||t.focus();var r=t.state.tr.setSelection(e);"pointer"==n&&r.setMeta("pointer",!0),t.dispatch(r)}function ce(t,e,n,o,i){return se(t,"handleClickOn",e,n,o)||t.someProp("handleClick",(function(n){return n(t,e,o)}))||(i?function(t,e){if(-1==e)return!1;var n,o,i=t.state.selection;i instanceof r.NodeSelection&&(n=i.node);for(var s=t.state.doc.resolve(e),a=s.depth+1;a>0;a--){var c=a>s.depth?s.nodeAfter:s.node(a);if(r.NodeSelection.isSelectable(c)){o=n&&i.$from.depth>0&&a>=i.$from.depth&&s.before(i.$from.depth+1)==i.$from.pos?s.before(i.$from.depth):s.before(a);break}}return null!=o&&(ae(t,r.NodeSelection.create(t.state.doc,o),"pointer"),!0)}(t,n):function(t,e){if(-1==e)return!1;var n=t.state.doc.resolve(e),o=n.nodeAfter;return!!(o&&o.isAtom&&r.NodeSelection.isSelectable(o))&&(ae(t,new r.NodeSelection(n),"pointer"),!0)}(t,n))}function le(t,e,n,r){return se(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",(function(n){return n(t,e,r)}))}function ue(t,e,n,o){return se(t,"handleTripleClickOn",e,n,o)||t.someProp("handleTripleClick",(function(n){return n(t,e,o)}))||function(t,e,n){if(0!=n.button)return!1;var o=t.state.doc;if(-1==e)return!!o.inlineContent&&(ae(t,r.TextSelection.create(o,0,o.content.size),"pointer"),!0);for(var i=o.resolve(e),s=i.depth+1;s>0;s--){var a=s>i.depth?i.nodeAfter:i.node(s),c=i.before(s);if(a.inlineContent)ae(t,r.TextSelection.create(o,c+1,c+1+a.content.size),"pointer");else{if(!r.NodeSelection.isSelectable(a))continue;ae(t,r.NodeSelection.create(o,c),"pointer")}return!0}}(t,n,o)}function pe(t){return ye(t)}ee.keydown=function(t,e){if(t.shiftKey=16==e.keyCode||e.shiftKey,!he(t,e)&&(t.lastKeyCode=e.keyCode,t.lastKeyCodeTime=Date.now(),!s.android||!s.chrome||13!=e.keyCode))if(229!=e.keyCode&&t.domObserver.forceFlush(),!s.ios||13!=e.keyCode||e.ctrlKey||e.altKey||e.metaKey)t.someProp("handleKeyDown",(function(n){return n(t,e)}))||zt(t,e)?e.preventDefault():ne(t,"key");else{var n=Date.now();t.lastIOSEnter=n,t.lastIOSEnterFallbackTimeout=setTimeout((function(){t.lastIOSEnter==n&&(t.someProp("handleKeyDown",(function(e){return e(t,k(13,"Enter"))})),t.lastIOSEnter=0)}),200)}},ee.keyup=function(t,e){16==e.keyCode&&(t.shiftKey=!1)},ee.keypress=function(t,e){if(!(he(t,e)||!e.charCode||e.ctrlKey&&!e.altKey||s.mac&&e.metaKey))if(t.someProp("handleKeyPress",(function(n){return n(t,e)})))e.preventDefault();else{var n=t.state.selection;if(!(n instanceof r.TextSelection&&n.$from.sameParent(n.$to))){var o=String.fromCharCode(e.charCode);t.someProp("handleTextInput",(function(e){return e(t,n.$from.pos,n.$to.pos,o)}))||t.dispatch(t.state.tr.insertText(o).scrollIntoView()),e.preventDefault()}}};var fe=s.mac?"metaKey":"ctrlKey";te.mousedown=function(t,e){t.shiftKey=e.shiftKey;var n=pe(t),r=Date.now(),o="singleClick";r-t.lastClick.time<500&&function(t,e){var n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}(e,t.lastClick)&&!e[fe]&&("singleClick"==t.lastClick.type?o="doubleClick":"doubleClick"==t.lastClick.type&&(o="tripleClick")),t.lastClick={time:r,x:e.clientX,y:e.clientY,type:o};var i=t.posAtCoords(ie(e));i&&("singleClick"==o?(t.mouseDown&&t.mouseDown.done(),t.mouseDown=new de(t,i,e,n)):("doubleClick"==o?le:ue)(t,i.pos,i.inside,e)?e.preventDefault():ne(t,"pointer"))};var de=function(t,e,n,o){var i,a,c=this;if(this.view=t,this.startDoc=t.state.doc,this.pos=e,this.event=n,this.flushed=o,this.selectNode=n[fe],this.allowDefault=n.shiftKey,this.delayedSelectionSync=!1,e.inside>-1)i=t.state.doc.nodeAt(e.inside),a=e.inside;else{var l=t.state.doc.resolve(e.pos);i=l.parent,a=l.depth?l.before():0}this.mightDrag=null;var u=o?null:n.target,p=u?t.docView.nearestDesc(u,!0):null;this.target=p?p.dom:null;var f=t.state.selection;(0==n.button&&i.type.spec.draggable&&!1!==i.type.spec.selectable||f instanceof r.NodeSelection&&f.from<=a&&f.to>a)&&(this.mightDrag={node:i,pos:a,addAttr:this.target&&!this.target.draggable,setUneditable:this.target&&s.gecko&&!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((function(){c.view.mouseDown==c&&c.target.setAttribute("contentEditable","false")}),20),this.view.domObserver.start()),t.root.addEventListener("mouseup",this.up=this.up.bind(this)),t.root.addEventListener("mousemove",this.move=this.move.bind(this)),ne(t,"pointer")};function he(t,e){return!!t.composing||!!(s.safari&&Math.abs(e.timeStamp-t.compositionEndedAt)<500)&&(t.compositionEndedAt=-2e8,!0)}de.prototype.done=function(){var t=this;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((function(){return ht(t.view)})),this.view.mouseDown=null},de.prototype.up=function(t){if(this.done(),this.view.dom.contains(3==t.target.nodeType?t.target.parentNode:t.target)){var e=this.pos;this.view.state.doc!=this.startDoc&&(e=this.view.posAtCoords(ie(t))),this.allowDefault||!e?ne(this.view,"pointer"):ce(this.view,e.pos,e.inside,t,this.selectNode)?t.preventDefault():0==t.button&&(this.flushed||s.safari&&this.mightDrag&&!this.mightDrag.node.isAtom||s.chrome&&!(this.view.state.selection instanceof r.TextSelection)&&Math.min(Math.abs(e.pos-this.view.state.selection.from),Math.abs(e.pos-this.view.state.selection.to))<=2)?(ae(this.view,r.Selection.near(this.view.state.doc.resolve(e.pos)),"pointer"),t.preventDefault()):ne(this.view,"pointer")}},de.prototype.move=function(t){!this.allowDefault&&(Math.abs(this.event.x-t.clientX)>4||Math.abs(this.event.y-t.clientY)>4)&&(this.allowDefault=!0),ne(this.view,"pointer"),0==t.buttons&&this.done()},te.touchdown=function(t){pe(t),ne(t,"pointer")},te.contextmenu=function(t){return pe(t)};var me=s.android?5e3:-1;function ve(t,e){clearTimeout(t.composingTimeout),e>-1&&(t.composingTimeout=setTimeout((function(){return ye(t)}),e))}function ge(t){var e;for(t.composing&&(t.composing=!1,t.compositionEndedAt=((e=document.createEvent("Event")).initEvent("event",!0,!0),e.timeStamp));t.compositionNodes.length>0;)t.compositionNodes.pop().markParentsDirty()}function ye(t,e){if(!(s.android&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),ge(t),e||t.docView&&t.docView.dirty){var n=ft(t);return n&&!n.eq(t.state.selection)?t.dispatch(t.state.tr.setSelection(n)):t.updateState(t.state),!0}return!1}}ee.compositionstart=ee.compositionupdate=function(t){if(!t.composing){t.domObserver.flush();var e=t.state,n=e.selection.$from;if(e.selection.empty&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some((function(t){return!1===t.type.spec.inclusive}))))t.markCursor=t.state.storedMarks||n.marks(),ye(t,!0),t.markCursor=null;else if(ye(t),s.gecko&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length)for(var r=t.root.getSelection(),o=r.focusNode,i=r.focusOffset;o&&1==o.nodeType&&0!=i;){var a=i<0?o.lastChild:o.childNodes[i-1];if(!a)break;if(3==a.nodeType){r.collapse(a,a.nodeValue.length);break}o=a,i=-1}t.composing=!0}ve(t,me)},ee.compositionend=function(t,e){t.composing&&(t.composing=!1,t.compositionEndedAt=e.timeStamp,ve(t,20))};var we=s.ie&&s.ie_version<15||s.ios&&s.webkit_version<604;function be(t,e,n,r){var i=Vt(t,e,n,t.shiftKey,t.state.selection.$from);if(t.someProp("handlePaste",(function(e){return e(t,r,i||o.Slice.empty)})))return!0;if(!i)return!1;var s=function(t){return 0==t.openStart&&0==t.openEnd&&1==t.content.childCount?t.content.firstChild:null}(i),a=s?t.state.tr.replaceSelectionWith(s,t.shiftKey):t.state.tr.replaceSelection(i);return t.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}te.copy=ee.cut=function(t,e){var n=t.state.selection,r="cut"==e.type;if(!n.empty){var o=we?null:e.clipboardData,i=Lt(t,n.content()),s=i.dom,a=i.text;o?(e.preventDefault(),o.clearData(),o.setData("text/html",s.innerHTML),o.setData("text/plain",a)):function(t,e){if(t.dom.parentNode){var n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";var r=getSelection(),o=document.createRange();o.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout((function(){n.parentNode&&n.parentNode.removeChild(n),t.focus()}),50)}}(t,s),r&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))}},ee.paste=function(t,e){if(!t.composing||s.android){var n=we?null:e.clipboardData;n&&be(t,n.getData("text/plain"),n.getData("text/html"),e)?e.preventDefault():function(t,e){if(t.dom.parentNode){var n=t.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus(),setTimeout((function(){t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?be(t,r.value,null,e):be(t,r.textContent,r.innerHTML,e)}),50)}}(t,e)}};var Se=function(t,e){this.slice=t,this.move=e},ke=s.mac?"altKey":"ctrlKey";for(var xe in te.dragstart=function(t,e){var n=t.mouseDown;if(n&&n.done(),e.dataTransfer){var o=t.state.selection,i=o.empty?null:t.posAtCoords(ie(e));if(i&&i.pos>=o.from&&i.pos<=(o instanceof r.NodeSelection?o.to-1:o.to));else if(n&&n.mightDrag)t.dispatch(t.state.tr.setSelection(r.NodeSelection.create(t.state.doc,n.mightDrag.pos)));else if(e.target&&1==e.target.nodeType){var s=t.docView.nearestDesc(e.target,!0);s&&s.node.type.spec.draggable&&s!=t.docView&&t.dispatch(t.state.tr.setSelection(r.NodeSelection.create(t.state.doc,s.posBefore)))}var a=t.state.selection.content(),c=Lt(t,a),l=c.dom,u=c.text;e.dataTransfer.clearData(),e.dataTransfer.setData(we?"Text":"text/html",l.innerHTML),e.dataTransfer.effectAllowed="copyMove",we||e.dataTransfer.setData("text/plain",u),t.dragging=new Se(a,!e[ke])}},te.dragend=function(t){var e=t.dragging;window.setTimeout((function(){t.dragging==e&&(t.dragging=null)}),50)},ee.dragover=ee.dragenter=function(t,e){return e.preventDefault()},ee.drop=function(t,e){var n=t.dragging;if(t.dragging=null,e.dataTransfer){var s=t.posAtCoords(ie(e));if(s){var a=t.state.doc.resolve(s.pos);if(a){var c=n&&n.slice;c?t.someProp("transformPasted",(function(t){c=t(c)})):c=Vt(t,e.dataTransfer.getData(we?"Text":"text/plain"),we?null:e.dataTransfer.getData("text/html"),!1,a);var l=n&&!e[ke];if(t.someProp("handleDrop",(function(n){return n(t,e,c||o.Slice.empty,l)})))e.preventDefault();else if(c){e.preventDefault();var u=c?Object(i.dropPoint)(t.state.doc,a.pos,c):a.pos;null==u&&(u=a.pos);var p=t.state.tr;l&&p.deleteSelection();var f=p.mapping.map(u),d=0==c.openStart&&0==c.openEnd&&1==c.content.childCount,h=p.doc;if(d?p.replaceRangeWith(f,f,c.content.firstChild):p.replaceRange(f,f,c),!p.doc.eq(h)){var m=p.doc.resolve(f);if(d&&r.NodeSelection.isSelectable(c.content.firstChild)&&m.nodeAfter&&m.nodeAfter.sameMarkup(c.content.firstChild))p.setSelection(new r.NodeSelection(m));else{var v=p.mapping.map(u);p.mapping.maps[p.mapping.maps.length-1].forEach((function(t,e,n,r){return v=r})),p.setSelection(St(t,m,p.doc.resolve(v)))}t.focus(),t.dispatch(p.setMeta("uiEvent","drop"))}}}}}},te.focus=function(t){t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout((function(){t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.root.getSelection())&&ht(t)}),20))},te.blur=function(t,e){t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),e.relatedTarget&&t.dom.contains(e.relatedTarget)&&t.domObserver.currentSelection.set({}),t.focused=!1)},te.beforeinput=function(t,e){if(s.chrome&&s.android&&"deleteContentBackward"==e.inputType){t.domObserver.flushSoon();var n=t.domChangeCount;setTimeout((function(){if(t.domChangeCount==n&&(t.dom.blur(),t.focus(),!t.someProp("handleKeyDown",(function(e){return e(t,k(8,"Backspace"))})))){var e=t.state.selection.$cursor;e&&e.pos>0&&t.dispatch(t.state.tr.delete(e.pos-1,e.pos).scrollIntoView())}}),50)}},ee)te[xe]=ee[xe];function Ce(t,e){if(t==e)return!0;for(var n in t)if(t[n]!==e[n])return!1;for(var r in e)if(!(r in t))return!1;return!0}var Me=function(t,e){this.spec=e||Ee,this.side=this.spec.side||0,this.toDOM=t};Me.prototype.map=function(t,e,n,r){var o=t.mapResult(e.from+r,this.side<0?-1:1),i=o.pos;return o.deleted?null:new Ne(i-n,i-n,this)},Me.prototype.valid=function(){return!0},Me.prototype.eq=function(t){return this==t||t instanceof Me&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&Ce(this.spec,t.spec))},Me.prototype.destroy=function(t){this.spec.destroy&&this.spec.destroy(t)};var Oe=function(t,e){this.spec=e||Ee,this.attrs=t};Oe.prototype.map=function(t,e,n,r){var o=t.map(e.from+r,this.spec.inclusiveStart?-1:1)-n,i=t.map(e.to+r,this.spec.inclusiveEnd?1:-1)-n;return o>=i?null:new Ne(o,i,this)},Oe.prototype.valid=function(t,e){return e.from<e.to},Oe.prototype.eq=function(t){return this==t||t instanceof Oe&&Ce(this.attrs,t.attrs)&&Ce(this.spec,t.spec)},Oe.is=function(t){return t.type instanceof Oe};var Te=function(t,e){this.spec=e||Ee,this.attrs=t};Te.prototype.map=function(t,e,n,r){var o=t.mapResult(e.from+r,1);if(o.deleted)return null;var i=t.mapResult(e.to+r,-1);return i.deleted||i.pos<=o.pos?null:new Ne(o.pos-n,i.pos-n,this)},Te.prototype.valid=function(t,e){var n,r=t.content.findIndex(e.from),o=r.index,i=r.offset;return i==e.from&&!(n=t.child(o)).isText&&i+n.nodeSize==e.to},Te.prototype.eq=function(t){return this==t||t instanceof Te&&Ce(this.attrs,t.attrs)&&Ce(this.spec,t.spec)};var Ne=function(t,e,n){this.from=t,this.to=e,this.type=n},Ae={spec:{configurable:!0},inline:{configurable:!0}};Ne.prototype.copy=function(t,e){return new Ne(t,e,this.type)},Ne.prototype.eq=function(t,e){return void 0===e&&(e=0),this.type.eq(t.type)&&this.from+e==t.from&&this.to+e==t.to},Ne.prototype.map=function(t,e,n){return this.type.map(t,this,e,n)},Ne.widget=function(t,e,n){return new Ne(t,t,new Me(e,n))},Ne.inline=function(t,e,n,r){return new Ne(t,e,new Oe(n,r))},Ne.node=function(t,e,n,r){return new Ne(t,e,new Te(n,r))},Ae.spec.get=function(){return this.type.spec},Ae.inline.get=function(){return this.type instanceof Oe},Object.defineProperties(Ne.prototype,Ae);var De=[],Ee={},Re=function(t,e){this.local=t&&t.length?t:De,this.children=e&&e.length?e:De};Re.create=function(t,e){return e.length?Fe(e,t,0,Ee):_e},Re.prototype.find=function(t,e,n){var r=[];return this.findInner(null==t?0:t,null==e?1e9:e,r,0,n),r},Re.prototype.findInner=function(t,e,n,r,o){for(var i=0;i<this.local.length;i++){var s=this.local[i];s.from<=e&&s.to>=t&&(!o||o(s.spec))&&n.push(s.copy(s.from+r,s.to+r))}for(var a=0;a<this.children.length;a+=3)if(this.children[a]<e&&this.children[a+1]>t){var c=this.children[a]+1;this.children[a+2].findInner(t-c,e-c,n,r+c,o)}},Re.prototype.map=function(t,e,n){return this==_e||0==t.maps.length?this:this.mapInner(t,e,0,0,n||Ee)},Re.prototype.mapInner=function(t,e,n,r,o){for(var i,s=0;s<this.local.length;s++){var a=this.local[s].map(t,n,r);a&&a.type.valid(e,a)?(i||(i=[])).push(a):o.onRemove&&o.onRemove(this.local[s].spec)}return this.children.length?function(t,e,n,r,o,i,s){for(var a=t.slice(),c=function(t,e,n,r){for(var s=0;s<a.length;s+=3){var c=a[s+1],l=void 0;if(!(c<0||t>c+i)){var u=a[s]+i;e>=u?a[s+1]=t<=u?-2:-1:n>=o&&(l=r-n-(e-t))&&(a[s]+=l,a[s+1]+=l)}}},l=0;l<n.maps.length;l++)n.maps[l].forEach(c);for(var u=!1,p=0;p<a.length;p+=3)if(a[p+1]<0){if(-2==a[p+1]){u=!0,a[p+1]=-1;continue}var f=n.map(t[p]+i),d=f-o;if(d<0||d>=r.content.size){u=!0;continue}var h=n.map(t[p+1]+i,-1)-o,m=r.content.findIndex(d),v=m.index,g=m.offset,y=r.maybeChild(v);if(y&&g==d&&g+y.nodeSize==h){var w=a[p+2].mapInner(n,y,f+1,t[p]+i+1,s);w!=_e?(a[p]=d,a[p+1]=h,a[p+2]=w):(a[p+1]=-2,u=!0)}else u=!0}if(u){var b=Fe(function(t,e,n,r,o,i,s){function a(t,e){for(var i=0;i<t.local.length;i++){var c=t.local[i].map(r,o,e);c?n.push(c):s.onRemove&&s.onRemove(t.local[i].spec)}for(var l=0;l<t.children.length;l+=3)a(t.children[l+2],t.children[l]+e+1)}for(var c=0;c<t.length;c+=3)-1==t[c+1]&&a(t[c+2],e[c]+i+1);return n}(a,t,e||[],n,o,i,s),r,0,s);e=b.local;for(var S=0;S<a.length;S+=3)a[S+1]<0&&(a.splice(S,3),S-=3);for(var k=0,x=0;k<b.children.length;k+=3){for(var C=b.children[k];x<a.length&&a[x]<C;)x+=3;a.splice(x,0,b.children[k],b.children[k+1],b.children[k+2])}}return new Re(e&&e.sort(Be),a)}(this.children,i,t,e,n,r,o):i?new Re(i.sort(Be)):_e},Re.prototype.add=function(t,e){return e.length?this==_e?Re.create(t,e):this.addInner(t,e,0):this},Re.prototype.addInner=function(t,e,n){var r,o=this,i=0;t.forEach((function(t,s){var a,c=s+n;if(a=Pe(e,t,c)){for(r||(r=o.children.slice());i<r.length&&r[i]<s;)i+=3;r[i]==s?r[i+2]=r[i+2].addInner(t,a,c+1):r.splice(i,0,s,s+t.nodeSize,Fe(a,t,c+1,Ee)),i+=3}}));for(var s=ze(i?$e(e):e,-n),a=0;a<s.length;a++)s[a].type.valid(t,s[a])||s.splice(a--,1);return new Re(s.length?this.local.concat(s).sort(Be):this.local,r||this.children)},Re.prototype.remove=function(t){return 0==t.length||this==_e?this:this.removeInner(t,0)},Re.prototype.removeInner=function(t,e){for(var n=this.children,r=this.local,o=0;o<n.length;o+=3){for(var i=void 0,s=n[o]+e,a=n[o+1]+e,c=0,l=void 0;c<t.length;c++)(l=t[c])&&l.from>s&&l.to<a&&(t[c]=null,(i||(i=[])).push(l));if(i){n==this.children&&(n=this.children.slice());var u=n[o+2].removeInner(i,s+1);u!=_e?n[o+2]=u:(n.splice(o,3),o-=3)}}if(r.length)for(var p=0,f=void 0;p<t.length;p++)if(f=t[p])for(var d=0;d<r.length;d++)r[d].eq(f,e)&&(r==this.local&&(r=this.local.slice()),r.splice(d--,1));return n==this.children&&r==this.local?this:r.length||n.length?new Re(r,n):_e},Re.prototype.forChild=function(t,e){if(this==_e)return this;if(e.isLeaf)return Re.empty;for(var n,r,o=0;o<this.children.length;o+=3)if(this.children[o]>=t){this.children[o]==t&&(n=this.children[o+2]);break}for(var i=t+1,s=i+e.content.size,a=0;a<this.local.length;a++){var c=this.local[a];if(c.from<s&&c.to>i&&c.type instanceof Oe){var l=Math.max(i,c.from)-i,u=Math.min(s,c.to)-i;l<u&&(r||(r=[])).push(c.copy(l,u))}}if(r){var p=new Re(r.sort(Be));return n?new Ie([p,n]):p}return n||_e},Re.prototype.eq=function(t){if(this==t)return!0;if(!(t instanceof Re)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(var e=0;e<this.local.length;e++)if(!this.local[e].eq(t.local[e]))return!1;for(var n=0;n<this.children.length;n+=3)if(this.children[n]!=t.children[n]||this.children[n+1]!=t.children[n+1]||!this.children[n+2].eq(t.children[n+2]))return!1;return!0},Re.prototype.locals=function(t){return Le(this.localsInner(t))},Re.prototype.localsInner=function(t){if(this==_e)return De;if(t.inlineContent||!this.local.some(Oe.is))return this.local;for(var e=[],n=0;n<this.local.length;n++)this.local[n].type instanceof Oe||e.push(this.local[n]);return e};var _e=new Re;Re.empty=_e,Re.removeOverlap=Le;var Ie=function(t){this.members=t};function ze(t,e){if(!e||!t.length)return t;for(var n=[],r=0;r<t.length;r++){var o=t[r];n.push(new Ne(o.from+e,o.to+e,o.type))}return n}function Pe(t,e,n){if(e.isLeaf)return null;for(var r=n+e.nodeSize,o=null,i=0,s=void 0;i<t.length;i++)(s=t[i])&&s.from>n&&s.to<r&&((o||(o=[])).push(s),t[i]=null);return o}function $e(t){for(var e=[],n=0;n<t.length;n++)null!=t[n]&&e.push(t[n]);return e}function Fe(t,e,n,r){var o=[],i=!1;e.forEach((function(e,s){var a=Pe(t,e,s+n);if(a){i=!0;var c=Fe(a,e,n+s+1,r);c!=_e&&o.push(s,s+e.nodeSize,c)}}));for(var s=ze(i?$e(t):t,-n).sort(Be),a=0;a<s.length;a++)s[a].type.valid(e,s[a])||(r.onRemove&&r.onRemove(s[a].spec),s.splice(a--,1));return s.length||o.length?new Re(s,o):_e}function Be(t,e){return t.from-e.from||t.to-e.to}function Le(t){for(var e=t,n=0;n<e.length-1;n++){var r=e[n];if(r.from!=r.to)for(var o=n+1;o<e.length;o++){var i=e[o];if(i.from!=r.from){i.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,i.from),Ve(e,o,r.copy(i.from,r.to)));break}i.to!=r.to&&(e==t&&(e=t.slice()),e[o]=i.copy(i.from,r.to),Ve(e,o+1,i.copy(r.to,i.to)))}}return e}function Ve(t,e,n){for(;e<t.length&&Be(n,t[e])>0;)e++;t.splice(e,0,n)}function je(t){var e=[];return t.someProp("decorations",(function(n){var r=n(t.state);r&&r!=_e&&e.push(r)})),t.cursorWrapper&&e.push(Re.create(t.state.doc,[t.cursorWrapper.deco])),Ie.from(e)}Ie.prototype.map=function(t,e){var n=this.members.map((function(n){return n.map(t,e,Ee)}));return Ie.from(n)},Ie.prototype.forChild=function(t,e){if(e.isLeaf)return Re.empty;for(var n=[],r=0;r<this.members.length;r++){var o=this.members[r].forChild(t,e);o!=_e&&(o instanceof Ie?n=n.concat(o.members):n.push(o))}return Ie.from(n)},Ie.prototype.eq=function(t){if(!(t instanceof Ie)||t.members.length!=this.members.length)return!1;for(var e=0;e<this.members.length;e++)if(!this.members[e].eq(t.members[e]))return!1;return!0},Ie.prototype.locals=function(t){for(var e,n=!0,r=0;r<this.members.length;r++){var o=this.members[r].localsInner(t);if(o.length)if(e){n&&(e=e.slice(),n=!1);for(var i=0;i<o.length;i++)e.push(o[i])}else e=o}return e?Le(n?e:e.sort(Be)):De},Ie.from=function(t){switch(t.length){case 0:return _e;case 1:return t[0];default:return new Ie(t)}};var We=function(t,e){this._props=e,this.state=e.state,this.directPlugins=e.plugins||[],this.directPlugins.forEach(Ge),this.dispatch=this.dispatch.bind(this),this._root=null,this.focused=!1,this.trackWrites=null,this.dom=t&&t.mount||document.createElement("div"),t&&(t.appendChild?t.appendChild(this.dom):t.apply?t(this.dom):t.mount&&(this.mounted=!0)),this.editable=Je(this),this.markCursor=null,this.cursorWrapper=null,He(this),this.nodeViews=Ue(this),this.docView=Y(this.state.doc,qe(this),je(this),this.dom,this),this.lastSelectedViewDesc=null,this.dragging=null,function(t){t.shiftKey=!1,t.mouseDown=null,t.lastKeyCode=null,t.lastKeyCodeTime=0,t.lastClick={time:0,x:0,y:0,type:""},t.lastSelectionOrigin=null,t.lastSelectionTime=0,t.lastIOSEnter=0,t.lastIOSEnterFallbackTimeout=null,t.lastAndroidDelete=0,t.composing=!1,t.composingTimeout=null,t.compositionNodes=[],t.compositionEndedAt=-2e8,t.domObserver=new Qt(t,(function(e,n,r,o){return $t(t,e,n,r,o)})),t.domObserver.start(),t.domChangeCount=0,t.eventHandlers=Object.create(null);var e=function(e){var n=te[e];t.dom.addEventListener(e,t.eventHandlers[e]=function(e){!function(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(var n=e.target;n!=t.dom;n=n.parentNode)if(!n||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}(t,e)||oe(t,e)||!t.editable&&e.type in ee||n(t,e)})};for(var n in te)e(n);s.safari&&t.dom.addEventListener("input",(function(){return null})),re(t)}(this),this.prevDirectPlugins=[],this.pluginViews=[],this.updatePluginViews()},Ke={props:{configurable:!0},root:{configurable:!0},isDestroyed:{configurable:!0}};function qe(t){var e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),e.translate="no",t.someProp("attributes",(function(n){if("function"==typeof n&&(n=n(t.state)),n)for(var r in n)"class"==r&&(e.class+=" "+n[r]),"style"==r?e.style=(e.style?e.style+";":"")+n[r]:e[r]||"contenteditable"==r||"nodeName"==r||(e[r]=String(n[r]))})),[Ne.node(0,t.state.doc.content.size,e)]}function He(t){if(t.markCursor){var e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:Ne.widget(t.state.selection.head,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function Je(t){return!t.someProp("editable",(function(e){return!1===e(t.state)}))}function Ue(t){var e={};return t.someProp("nodeViews",(function(t){for(var n in t)Object.prototype.hasOwnProperty.call(e,n)||(e[n]=t[n])})),e}function Ge(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}Ke.props.get=function(){if(this._props.state!=this.state){var t=this._props;for(var e in this._props={},t)this._props[e]=t[e];this._props.state=this.state}return this._props},We.prototype.update=function(t){t.handleDOMEvents!=this._props.handleDOMEvents&&re(this),this._props=t,t.plugins&&(t.plugins.forEach(Ge),this.directPlugins=t.plugins),this.updateStateInner(t.state,!0)},We.prototype.setProps=function(t){var e={};for(var n in this._props)e[n]=this._props[n];for(var r in e.state=this.state,t)e[r]=t[r];this.update(e)},We.prototype.updateState=function(t){this.updateStateInner(t,this.state.plugins!=t.plugins)},We.prototype.updateStateInner=function(t,e){var n=this,o=this.state,i=!1,a=!1;if(t.storedMarks&&this.composing&&(ge(this),a=!0),this.state=t,e){var c=Ue(this);(function(t,e){var n=0,r=0;for(var o in t){if(t[o]!=e[o])return!0;n++}for(var i in e)r++;return n!=r})(c,this.nodeViews)&&(this.nodeViews=c,i=!0),re(this)}this.editable=Je(this),He(this);var l=je(this),u=qe(this),p=e?"reset":t.scrollToSelection>o.scrollToSelection?"to selection":"preserve",f=i||!this.docView.matchesNode(t.doc,u,l);!f&&t.selection.eq(o.selection)||(a=!0);var d,h,m,g,y,w,b,S,k,x,C,M="preserve"==p&&a&&null==this.dom.style.overflowAnchor&&function(t){for(var e,n,r=t.dom.getBoundingClientRect(),o=Math.max(0,r.top),i=(r.left+r.right)/2,s=o+1;s<Math.min(innerHeight,r.bottom);s+=5){var a=t.root.elementFromPoint(i,s);if(a!=t.dom&&t.dom.contains(a)){var c=a.getBoundingClientRect();if(c.top>=o-20){e=a,n=c.top;break}}}return{refDOM:e,refTop:n,stack:T(t.dom)}}(this);if(a){this.domObserver.stop();var A=f&&(s.ie||s.chrome)&&!this.composing&&!o.selection.empty&&!t.selection.empty&&(g=o.selection,y=t.selection,w=Math.min(g.$anchor.sharedDepth(g.head),y.$anchor.sharedDepth(y.head)),g.$anchor.start(w)!=y.$anchor.start(w));if(f){var D=s.chrome?this.trackWrites=this.root.getSelection().focusNode:null;!i&&this.docView.update(t.doc,u,l,this)||(this.docView.updateOuterDeco([]),this.docView.destroy(),this.docView=Y(t.doc,u,l,this.dom,this)),D&&!this.trackWrites&&(A=!0)}A||!(this.mouseDown&&this.domObserver.currentSelection.eq(this.root.getSelection())&&(d=this,h=d.docView.domFromPos(d.state.selection.anchor,0),m=d.root.getSelection(),v(h.node,h.offset,m.anchorNode,m.anchorOffset)))?ht(this,A):(wt(this,t.selection),this.domObserver.setCurSelection()),this.domObserver.start()}if(this.updatePluginViews(o),"reset"==p)this.dom.scrollTop=0;else if("to selection"==p){var E=this.root.getSelection().focusNode;this.someProp("handleScrollToSelection",(function(t){return t(n)}))||(t.selection instanceof r.NodeSelection?O(this,this.docView.domAfterPos(t.selection.from).getBoundingClientRect(),E):O(this,this.coordsAtPos(t.selection.head,1),E))}else M&&(S=(b=M).refDOM,k=b.refTop,x=b.stack,C=S?S.getBoundingClientRect().top:0,N(x,0==C?0:C-k))},We.prototype.destroyPluginViews=function(){for(var t;t=this.pluginViews.pop();)t.destroy&&t.destroy()},We.prototype.updatePluginViews=function(t){if(t&&t.plugins==this.state.plugins&&this.directPlugins==this.prevDirectPlugins)for(var e=0;e<this.pluginViews.length;e++){var n=this.pluginViews[e];n.update&&n.update(this,t)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(var r=0;r<this.directPlugins.length;r++){var o=this.directPlugins[r];o.spec.view&&this.pluginViews.push(o.spec.view(this))}for(var i=0;i<this.state.plugins.length;i++){var s=this.state.plugins[i];s.spec.view&&this.pluginViews.push(s.spec.view(this))}}},We.prototype.someProp=function(t,e){var n,r=this._props&&this._props[t];if(null!=r&&(n=e?e(r):r))return n;for(var o=0;o<this.directPlugins.length;o++){var i=this.directPlugins[o].props[t];if(null!=i&&(n=e?e(i):i))return n}var s=this.state.plugins;if(s)for(var a=0;a<s.length;a++){var c=s[a].props[t];if(null!=c&&(n=e?e(c):c))return n}},We.prototype.hasFocus=function(){return this.root.activeElement==this.dom},We.prototype.focus=function(){this.domObserver.stop(),this.editable&&function(t){if(t.setActive)return t.setActive();if(A)return t.focus(A);var e=T(t);t.focus(null==A?{get preventScroll(){return A={preventScroll:!0},!0}}:void 0),A||(A=!1,N(e,0))}(this.dom),ht(this),this.domObserver.start()},Ke.root.get=function(){var t=this._root;if(null==t)for(var e=this.dom.parentNode;e;e=e.parentNode)if(9==e.nodeType||11==e.nodeType&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=function(){return document.getSelection()}),this._root=e;return t||document},We.prototype.posAtCoords=function(t){return R(this,t)},We.prototype.coordsAtPos=function(t,e){return void 0===e&&(e=1),z(this,t,e)},We.prototype.domAtPos=function(t,e){return void 0===e&&(e=0),this.docView.domFromPos(t,e)},We.prototype.nodeDOM=function(t){var e=this.docView.descAt(t);return e?e.nodeDOM:null},We.prototype.posAtDOM=function(t,e,n){void 0===n&&(n=-1);var r=this.docView.posFromDOM(t,e,n);if(null==r)throw new RangeError("DOM position not inside the editor");return r},We.prototype.endOfTextblock=function(t,e){return W(this,e||this.state,t)},We.prototype.destroy=function(){this.docView&&(!function(t){for(var e in t.domObserver.stop(),t.eventHandlers)t.dom.removeEventListener(e,t.eventHandlers[e]);clearTimeout(t.composingTimeout),clearTimeout(t.lastIOSEnterFallbackTimeout)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],je(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null)},Ke.isDestroyed.get=function(){return null==this.docView},We.prototype.dispatchEvent=function(t){return function(t,e){oe(t,e)||!te[e.type]||!t.editable&&e.type in ee||te[e.type](t,e)}(this,t)},We.prototype.dispatch=function(t){var e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))},Object.defineProperties(We.prototype,Ke)},function(t,e,n){"use strict";n.r(e),n.d(e,"__extends",(function(){return o})),n.d(e,"__assign",(function(){return i})),n.d(e,"__rest",(function(){return s})),n.d(e,"__decorate",(function(){return a})),n.d(e,"__param",(function(){return c})),n.d(e,"__metadata",(function(){return l})),n.d(e,"__awaiter",(function(){return u})),n.d(e,"__generator",(function(){return p})),n.d(e,"__createBinding",(function(){return f})),n.d(e,"__exportStar",(function(){return d})),n.d(e,"__values",(function(){return h})),n.d(e,"__read",(function(){return m})),n.d(e,"__spread",(function(){return v})),n.d(e,"__spreadArrays",(function(){return g})),n.d(e,"__await",(function(){return y})),n.d(e,"__asyncGenerator",(function(){return w})),n.d(e,"__asyncDelegator",(function(){return b})),n.d(e,"__asyncValues",(function(){return S})),n.d(e,"__makeTemplateObject",(function(){return k})),n.d(e,"__importStar",(function(){return x})),n.d(e,"__importDefault",(function(){return C})),n.d(e,"__classPrivateFieldGet",(function(){return M})),n.d(e,"__classPrivateFieldSet",(function(){return O}));
|
|
2
2
|
/*! *****************************************************************************
|
|
3
3
|
Copyright (c) Microsoft Corporation.
|
|
4
4
|
|