@progress/kendo-editor-common 1.9.0 → 1.9.1-dev.202205130755
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(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.KendoEditorCommon=t():e.KendoEditorCommon=t()}(window,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=26)}([function(e,t,n){"use strict";function r(e){this.content=e}n.r(t),n.d(t,"ContentMatch",(function(){return z})),n.d(t,"DOMParser",(function(){return ee})),n.d(t,"DOMSerializer",(function(){return de})),n.d(t,"Fragment",(function(){return i})),n.d(t,"Mark",(function(){return u})),n.d(t,"MarkType",(function(){return G})),n.d(t,"Node",(function(){return N})),n.d(t,"NodeRange",(function(){return O})),n.d(t,"NodeType",(function(){return J})),n.d(t,"ReplaceError",(function(){return d})),n.d(t,"ResolvedPos",(function(){return S})),n.d(t,"Schema",(function(){return Q})),n.d(t,"Slice",(function(){return p})),r.prototype={constructor:r,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return-1==t?void 0:this.content[t+1]},update:function(e,t,n){var o=n&&n!=e?this.remove(n):this,i=o.find(e),s=o.content.slice();return-1==i?s.push(n||e,t):(s[i+1]=t,n&&(s[i]=n)),new r(s)},remove:function(e){var t=this.find(e);if(-1==t)return this;var n=this.content.slice();return n.splice(t,2),new r(n)},addToStart:function(e,t){return new r([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new r(n)},addBefore:function(e,t,n){var o=this.remove(t),i=o.content.slice(),s=o.find(e);return i.splice(-1==s?i.length:s,0,t,n),new r(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return(e=r.from(e)).size?new r(e.content.concat(this.subtract(e).content)):this},append:function(e){return(e=r.from(e)).size?new r(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=r.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},get size(){return this.content.length>>1}},r.from=function(e){if(e instanceof r)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new r(t)};var o=r;var i=function(e,t){if(this.content=e,this.size=t||0,null==t)for(var n=0;n<e.length;n++)this.size+=e[n].nodeSize},s={firstChild:{configurable:!0},lastChild:{configurable:!0},childCount:{configurable:!0}};i.prototype.nodesBetween=function(e,t,n,r,o){void 0===r&&(r=0);for(var i=0,s=0;s<t;i++){var a=this.content[i],l=s+a.nodeSize;if(l>e&&!1!==n(a,r+s,o,i)&&a.content.size){var c=s+1;a.nodesBetween(Math.max(0,e-c),Math.min(a.content.size,t-c),n,r+c)}s=l}},i.prototype.descendants=function(e){this.nodesBetween(0,this.size,e)},i.prototype.textBetween=function(e,t,n,r){var o="",i=!0;return this.nodesBetween(e,t,(function(s,a){s.isText?(o+=s.text.slice(Math.max(e,a)-a,t-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(e){if(!e.size)return this;if(!this.size)return e;var t=this.lastChild,n=e.firstChild,r=this.content.slice(),o=0;for(t.isText&&t.sameMarkup(n)&&(r[r.length-1]=t.withText(t.text+n.text),o=1);o<e.content.length;o++)r.push(e.content[o]);return new i(r,this.size+e.size)},i.prototype.cut=function(e,t){if(null==t&&(t=this.size),0==e&&t==this.size)return this;var n=[],r=0;if(t>e)for(var o=0,s=0;s<t;o++){var a=this.content[o],l=s+a.nodeSize;l>e&&((s<e||l>t)&&(a=a.isText?a.cut(Math.max(0,e-s),Math.min(a.text.length,t-s)):a.cut(Math.max(0,e-s-1),Math.min(a.content.size,t-s-1))),n.push(a),r+=a.nodeSize),s=l}return new i(n,r)},i.prototype.cutByIndex=function(e,t){return e==t?i.empty:0==e&&t==this.content.length?this:new i(this.content.slice(e,t))},i.prototype.replaceChild=function(e,t){var n=this.content[e];if(n==t)return this;var r=this.content.slice(),o=this.size+t.nodeSize-n.nodeSize;return r[e]=t,new i(r,o)},i.prototype.addToStart=function(e){return new i([e].concat(this.content),this.size+e.nodeSize)},i.prototype.addToEnd=function(e){return new i(this.content.concat(e),this.size+e.nodeSize)},i.prototype.eq=function(e){if(this.content.length!=e.content.length)return!1;for(var t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))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(e){var t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t},i.prototype.maybeChild=function(e){return this.content[e]},i.prototype.forEach=function(e){for(var t=0,n=0;t<this.content.length;t++){var r=this.content[t];e(r,n,t),n+=r.nodeSize}},i.prototype.findDiffStart=function(e,t){return void 0===t&&(t=0),function e(t,n,r){for(var o=0;;o++){if(o==t.childCount||o==n.childCount)return t.childCount==n.childCount?null:r;var i=t.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 l=e(i.content,s.content,r+1);if(null!=l)return l}r+=i.nodeSize}else r+=i.nodeSize}}(this,e,t)},i.prototype.findDiffEnd=function(e,t,n){return void 0===t&&(t=this.size),void 0===n&&(n=e.size),function e(t,n,r,o){for(var i=t.childCount,s=n.childCount;;){if(0==i||0==s)return i==s?null:{a:r,b:o};var a=t.child(--i),l=n.child(--s),c=a.nodeSize;if(a!=l){if(!a.sameMarkup(l))return{a:r,b:o};if(a.isText&&a.text!=l.text){for(var u=0,d=Math.min(a.text.length,l.text.length);u<d&&a.text[a.text.length-u-1]==l.text[l.text.length-u-1];)u++,r--,o--;return{a:r,b:o}}if(a.content.size||l.content.size){var p=e(a.content,l.content,r-1,o-1);if(p)return p}r-=c,o-=c}else r-=c,o-=c}}(this,e,t,n)},i.prototype.findIndex=function(e,t){if(void 0===t&&(t=-1),0==e)return l(0,e);if(e==this.size)return l(this.content.length,e);if(e>this.size||e<0)throw new RangeError("Position "+e+" outside of fragment ("+this+")");for(var n=0,r=0;;n++){var o=r+this.child(n).nodeSize;if(o>=e)return o==e||t>0?l(n+1,o):l(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(e){return e.toJSON()})):null},i.fromJSON=function(e,t){if(!t)return i.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new i(t.map(e.nodeFromJSON))},i.fromArray=function(e){if(!e.length)return i.empty;for(var t,n=0,r=0;r<e.length;r++){var o=e[r];n+=o.nodeSize,r&&o.isText&&e[r-1].sameMarkup(o)?(t||(t=e.slice(0,r)),t[t.length-1]=o.withText(t[t.length-1].text+o.text)):t&&t.push(o)}return new i(t||e,n)},i.from=function(e){if(!e)return i.empty;if(e instanceof i)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new i([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))},Object.defineProperties(i.prototype,s);var a={index:0,offset:0};function l(e,t){return a.index=e,a.offset=t,a}function c(e,t){if(e===t)return!0;if(!e||"object"!=typeof e||!t||"object"!=typeof t)return!1;var n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(var r=0;r<e.length;r++)if(!c(e[r],t[r]))return!1}else{for(var o in e)if(!(o in t)||!c(e[o],t[o]))return!1;for(var i in t)if(!(i in e))return!1}return!0}i.empty=new i([],0);var u=function(e,t){this.type=e,this.attrs=t};function d(e){var t=Error.call(this,e);return t.__proto__=d.prototype,t}u.prototype.addToSet=function(e){for(var t,n=!1,r=0;r<e.length;r++){var o=e[r];if(this.eq(o))return e;if(this.type.excludes(o.type))t||(t=e.slice(0,r));else{if(o.type.excludes(this.type))return e;!n&&o.type.rank>this.type.rank&&(t||(t=e.slice(0,r)),t.push(this),n=!0),t&&t.push(o)}}return t||(t=e.slice()),n||t.push(this),t},u.prototype.removeFromSet=function(e){for(var t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e},u.prototype.isInSet=function(e){for(var t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1},u.prototype.eq=function(e){return this==e||this.type==e.type&&c(this.attrs,e.attrs)},u.prototype.toJSON=function(){var e={type:this.type.name};for(var t in this.attrs){e.attrs=this.attrs;break}return e},u.fromJSON=function(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");var n=e.marks[t.type];if(!n)throw new RangeError("There is no mark type "+t.type+" in this schema");return n.create(t.attrs)},u.sameSet=function(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(var n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0},u.setFrom=function(e){if(!e||0==e.length)return u.none;if(e instanceof u)return[e];var t=e.slice();return t.sort((function(e,t){return e.type.rank-t.type.rank})),t},u.none=[],d.prototype=Object.create(Error.prototype),d.prototype.constructor=d,d.prototype.name="ReplaceError";var p=function(e,t,n){this.content=e,this.openStart=t,this.openEnd=n},f={size:{configurable:!0}};function h(e,t,n){if(n.openStart>e.depth)throw new d("Inserted content deeper than insertion position");if(e.depth-n.openStart!=t.depth-n.openEnd)throw new d("Inconsistent open depths");return function e(t,n,r,o){var s=t.index(o),a=t.node(o);if(s==n.index(o)&&o<t.depth-r.openStart){var l=e(t,n,r,o+1);return a.copy(a.content.replaceChild(s,l))}if(r.content.size){if(r.openStart||r.openEnd||t.depth!=o||n.depth!=o){var c=function(e,t){for(var n=t.depth-e.openStart,r=t.node(n).copy(e.content),o=n-1;o>=0;o--)r=t.node(o).copy(i.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}(r,t),u=c.start,d=c.end;return w(a,function e(t,n,r,o,s){var a=t.depth>s&&v(t,n,s+1),l=o.depth>s&&v(r,o,s+1),c=[];y(null,t,s,c),a&&l&&n.index(s)==r.index(s)?(m(a,l),g(w(a,e(t,n,r,o,s+1)),c)):(a&&g(w(a,b(t,n,s+1)),c),y(n,r,s,c),l&&g(w(l,b(r,o,s+1)),c));return y(o,null,s,c),new i(c)}(t,u,d,n,o))}var p=t.parent,f=p.content;return w(p,f.cut(0,t.parentOffset).append(r.content).append(f.cut(n.parentOffset)))}return w(a,b(t,n,o))}(e,t,n,0)}function m(e,t){if(!t.type.compatibleContent(e.type))throw new d("Cannot join "+t.type.name+" onto "+e.type.name)}function v(e,t,n){var r=e.node(n);return m(r,t.node(n)),r}function g(e,t){var n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function y(e,t,n,r){var o=(t||e).node(n),i=0,s=t?t.index(n):o.childCount;e&&(i=e.index(n),e.depth>n?i++:e.textOffset&&(g(e.nodeAfter,r),i++));for(var a=i;a<s;a++)g(o.child(a),r);t&&t.depth==n&&t.textOffset&&g(t.nodeBefore,r)}function w(e,t){if(!e.type.validContent(t))throw new d("Invalid content for node "+e.type.name);return e.copy(t)}function b(e,t,n){var r=[];(y(null,e,n,r),e.depth>n)&&g(w(v(e,t,n+1),b(e,t,n+1)),r);return y(t,null,n,r),new i(r)}f.size.get=function(){return this.content.size-this.openStart-this.openEnd},p.prototype.insertAt=function(e,t){var n=function e(t,n,r,o){var i=t.findIndex(n),s=i.index,a=i.offset,l=t.maybeChild(s);if(a==n||l.isText)return o&&!o.canReplace(s,s,r)?null:t.cut(0,n).append(r).append(t.cut(n));var c=e(l.content,n-a-1,r);return c&&t.replaceChild(s,l.copy(c))}(this.content,e+this.openStart,t,null);return n&&new p(n,this.openStart,this.openEnd)},p.prototype.removeBetween=function(e,t){return new p(function e(t,n,r){var o=t.findIndex(n),i=o.index,s=o.offset,a=t.maybeChild(i),l=t.findIndex(r),c=l.index,u=l.offset;if(s==n||a.isText){if(u!=r&&!t.child(c).isText)throw new RangeError("Removing non-flat range");return t.cut(0,n).append(t.cut(r))}if(i!=c)throw new RangeError("Removing non-flat range");return t.replaceChild(i,a.copy(e(a.content,n-s-1,r-s-1)))}(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)},p.prototype.eq=function(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd},p.prototype.toString=function(){return this.content+"("+this.openStart+","+this.openEnd+")"},p.prototype.toJSON=function(){if(!this.content.size)return null;var e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e},p.fromJSON=function(e,t){if(!t)return p.empty;var n=t.openStart||0,r=t.openEnd||0;if("number"!=typeof n||"number"!=typeof r)throw new RangeError("Invalid input for Slice.fromJSON");return new p(i.fromJSON(e,t.content),n,r)},p.maxOpen=function(e,t){void 0===t&&(t=!0);for(var n=0,r=0,o=e.firstChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.firstChild)n++;for(var i=e.lastChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.lastChild)r++;return new p(e,n,r)},Object.defineProperties(p.prototype,f),p.empty=new p(i.empty,0,0);var S=function(e,t,n){this.pos=e,this.path=t,this.depth=t.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(e){return null==e?this.depth:e<0?this.depth+e:e},k.parent.get=function(){return this.node(this.depth)},k.doc.get=function(){return this.node(0)},S.prototype.node=function(e){return this.path[3*this.resolveDepth(e)]},S.prototype.index=function(e){return this.path[3*this.resolveDepth(e)+1]},S.prototype.indexAfter=function(e){return e=this.resolveDepth(e),this.index(e)+(e!=this.depth||this.textOffset?1:0)},S.prototype.start=function(e){return 0==(e=this.resolveDepth(e))?0:this.path[3*e-1]+1},S.prototype.end=function(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size},S.prototype.before=function(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]},S.prototype.after=function(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]+this.path[3*e].nodeSize},k.textOffset.get=function(){return this.pos-this.path[this.path.length-1]},k.nodeAfter.get=function(){var e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;var n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r},k.nodeBefore.get=function(){var e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):0==e?null:this.parent.child(e-1)},S.prototype.posAtIndex=function(e,t){t=this.resolveDepth(t);for(var n=this.path[3*t],r=0==t?0:this.path[3*t-1]+1,o=0;o<e;o++)r+=n.child(o).nodeSize;return r},S.prototype.marks=function(){var e=this.parent,t=this.index();if(0==e.content.size)return u.none;if(this.textOffset)return e.child(t).marks;var n=e.maybeChild(t-1),r=e.maybeChild(t);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(e){var t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;for(var n=t.marks,r=e.parent.maybeChild(e.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(e){for(var t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0},S.prototype.blockRange=function(e,t){if(void 0===e&&(e=this),e.pos<this.pos)return e.blockRange(this);for(var n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new O(this,e,n)},S.prototype.sameParent=function(e){return this.pos-this.parentOffset==e.pos-e.parentOffset},S.prototype.max=function(e){return e.pos>this.pos?e:this},S.prototype.min=function(e){return e.pos<this.pos?e:this},S.prototype.toString=function(){for(var e="",t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset},S.resolve=function(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");for(var n=[],r=0,o=t,i=e;;){var s=i.content.findIndex(o),a=s.index,l=s.offset,c=o-l;if(n.push(i,a,r+l),!c)break;if((i=i.child(a)).isText)break;o=c-1,r+=l+1}return new S(t,n,o)},S.resolveCached=function(e,t){for(var n=0;n<x.length;n++){var r=x[n];if(r.pos==t&&r.doc==e)return r}var o=x[C]=S.resolve(e,t);return C=(C+1)%M,o},Object.defineProperties(S.prototype,k);var x=[],C=0,M=12,O=function(e,t,n){this.$from=e,this.$to=t,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 A=Object.create(null),N=function(e,t,n,r){this.type=e,this.attrs=t,this.content=n||i.empty,this.marks=r||u.none},R={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}};R.nodeSize.get=function(){return this.isLeaf?1:2+this.content.size},R.childCount.get=function(){return this.content.childCount},N.prototype.child=function(e){return this.content.child(e)},N.prototype.maybeChild=function(e){return this.content.maybeChild(e)},N.prototype.forEach=function(e){this.content.forEach(e)},N.prototype.nodesBetween=function(e,t,n,r){void 0===r&&(r=0),this.content.nodesBetween(e,t,n,r,this)},N.prototype.descendants=function(e){this.nodesBetween(0,this.content.size,e)},R.textContent.get=function(){return this.textBetween(0,this.content.size,"")},N.prototype.textBetween=function(e,t,n,r){return this.content.textBetween(e,t,n,r)},R.firstChild.get=function(){return this.content.firstChild},R.lastChild.get=function(){return this.content.lastChild},N.prototype.eq=function(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)},N.prototype.sameMarkup=function(e){return this.hasMarkup(e.type,e.attrs,e.marks)},N.prototype.hasMarkup=function(e,t,n){return this.type==e&&c(this.attrs,t||e.defaultAttrs||A)&&u.sameSet(this.marks,n||u.none)},N.prototype.copy=function(e){return void 0===e&&(e=null),e==this.content?this:new this.constructor(this.type,this.attrs,e,this.marks)},N.prototype.mark=function(e){return e==this.marks?this:new this.constructor(this.type,this.attrs,this.content,e)},N.prototype.cut=function(e,t){return 0==e&&t==this.content.size?this:this.copy(this.content.cut(e,t))},N.prototype.slice=function(e,t,n){if(void 0===t&&(t=this.content.size),void 0===n&&(n=!1),e==t)return p.empty;var r=this.resolve(e),o=this.resolve(t),i=n?0:r.sharedDepth(t),s=r.start(i),a=r.node(i).content.cut(r.pos-s,o.pos-s);return new p(a,r.depth-i,o.depth-i)},N.prototype.replace=function(e,t,n){return h(this.resolve(e),this.resolve(t),n)},N.prototype.nodeAt=function(e){for(var t=this;;){var n=t.content.findIndex(e),r=n.index,o=n.offset;if(!(t=t.maybeChild(r)))return null;if(o==e||t.isText)return t;e-=o+1}},N.prototype.childAfter=function(e){var t=this.content.findIndex(e),n=t.index,r=t.offset;return{node:this.content.maybeChild(n),index:n,offset:r}},N.prototype.childBefore=function(e){if(0==e)return{node:null,index:0,offset:0};var t=this.content.findIndex(e),n=t.index,r=t.offset;if(r<e)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}},N.prototype.resolve=function(e){return S.resolveCached(this,e)},N.prototype.resolveNoCache=function(e){return S.resolve(this,e)},N.prototype.rangeHasMark=function(e,t,n){var r=!1;return t>e&&this.nodesBetween(e,t,(function(e){return n.isInSet(e.marks)&&(r=!0),!r})),r},R.isBlock.get=function(){return this.type.isBlock},R.isTextblock.get=function(){return this.type.isTextblock},R.inlineContent.get=function(){return this.type.inlineContent},R.isInline.get=function(){return this.type.isInline},R.isText.get=function(){return this.type.isText},R.isLeaf.get=function(){return this.type.isLeaf},R.isAtom.get=function(){return this.type.isAtom},N.prototype.toString=function(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);var e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),E(this.marks,e)},N.prototype.contentMatchAt=function(e){var t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t},N.prototype.canReplace=function(e,t,n,r,o){void 0===n&&(n=i.empty),void 0===r&&(r=0),void 0===o&&(o=n.childCount);var s=this.contentMatchAt(e).matchFragment(n,r,o),a=s&&s.matchFragment(this.content,t);if(!a||!a.validEnd)return!1;for(var l=r;l<o;l++)if(!this.type.allowsMarks(n.child(l).marks))return!1;return!0},N.prototype.canReplaceWith=function(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;var o=this.contentMatchAt(e).matchType(n),i=o&&o.matchFragment(this.content,t);return!!i&&i.validEnd},N.prototype.canAppend=function(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)},N.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 e=u.none,t=0;t<this.marks.length;t++)e=this.marks[t].addToSet(e);if(!u.sameSet(e,this.marks))throw new RangeError("Invalid collection of marks for node "+this.type.name+": "+this.marks.map((function(e){return e.type.name})));this.content.forEach((function(e){return e.check()}))},N.prototype.toJSON=function(){var e={type:this.type.name};for(var t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map((function(e){return e.toJSON()}))),e},N.fromJSON=function(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");var n=null;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=t.marks.map(e.markFromJSON)}if("text"==t.type){if("string"!=typeof t.text)throw new RangeError("Invalid text node in JSON");return e.text(t.text,n)}var r=i.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,r,n)},Object.defineProperties(N.prototype,R);var D=function(e){function t(t,n,r,o){if(e.call(this,t,n,null,o),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={textContent:{configurable:!0},nodeSize:{configurable:!0}};return t.prototype.toString=function(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):E(this.marks,JSON.stringify(this.text))},n.textContent.get=function(){return this.text},t.prototype.textBetween=function(e,t){return this.text.slice(e,t)},n.nodeSize.get=function(){return this.text.length},t.prototype.mark=function(e){return e==this.marks?this:new t(this.type,this.attrs,this.text,e)},t.prototype.withText=function(e){return e==this.text?this:new t(this.type,this.attrs,e,this.marks)},t.prototype.cut=function(e,t){return void 0===e&&(e=0),void 0===t&&(t=this.text.length),0==e&&t==this.text.length?this:this.withText(this.text.slice(e,t))},t.prototype.eq=function(e){return this.sameMarkup(e)&&this.text==e.text},t.prototype.toJSON=function(){var t=e.prototype.toJSON.call(this);return t.text=this.text,t},Object.defineProperties(t.prototype,n),t}(N);function E(e,t){for(var n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}var z=function(e){this.validEnd=e,this.next=[],this.wrapCache=[]},_={inlineContent:{configurable:!0},defaultType:{configurable:!0},edgeCount:{configurable:!0}};z.parse=function(e,t){var n=new I(e,t);if(null==n.next)return z.empty;var r=$(n);n.next&&n.err("Unexpected trailing text");var o=function(e){var t=Object.create(null);return function n(r){var o=[];r.forEach((function(t){e[t].forEach((function(t){var n=t.term,r=t.to;if(n){var i=o.indexOf(n),s=i>-1&&o[i+1];K(e,r).forEach((function(e){s||o.push(n,s=[]),-1==s.indexOf(e)&&s.push(e)}))}}))}));for(var i=t[r.join(",")]=new z(r.indexOf(e.length-1)>-1),s=0;s<o.length;s+=2){var a=o[s+1].sort(j);i.next.push(o[s],t[a.join(",")]||n(a))}return i}(K(e,0))}(function(e){var t=[[]];return o(function e(t,i){if("choice"==t.type)return t.exprs.reduce((function(t,n){return t.concat(e(n,i))}),[]);if("seq"==t.type)for(var s=0;;s++){var a=e(t.exprs[s],i);if(s==t.exprs.length-1)return a;o(a,i=n())}else{if("star"==t.type){var l=n();return r(i,l),o(e(t.expr,l),l),[r(l)]}if("plus"==t.type){var c=n();return o(e(t.expr,i),c),o(e(t.expr,c),c),[r(c)]}if("opt"==t.type)return[r(i)].concat(e(t.expr,i));if("range"==t.type){for(var u=i,d=0;d<t.min;d++){var p=n();o(e(t.expr,u),p),u=p}if(-1==t.max)o(e(t.expr,u),u);else for(var f=t.min;f<t.max;f++){var h=n();r(u,h),o(e(t.expr,u),h),u=h}return[r(u)]}if("name"==t.type)return[r(i,null,t.value)]}}(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){var o={term:r,to:n};return t[e].push(o),o}function o(e,t){e.forEach((function(e){return e.to=t}))}}(r));return function(e,t){for(var n=0,r=[e];n<r.length;n++){for(var o=r[n],i=!o.validEnd,s=[],a=0;a<o.next.length;a+=2){var l=o.next[a],c=o.next[a+1];s.push(l.name),!i||l.isText||l.hasRequiredAttrs()||(i=!1),-1==r.indexOf(c)&&r.push(c)}i&&t.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(o,n),o},z.prototype.matchType=function(e){for(var t=0;t<this.next.length;t+=2)if(this.next[t]==e)return this.next[t+1];return null},z.prototype.matchFragment=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=e.childCount);for(var r=this,o=t;r&&o<n;o++)r=r.matchType(e.child(o).type);return r},_.inlineContent.get=function(){var e=this.next[0];return!!e&&e.isInline},_.defaultType.get=function(){for(var e=0;e<this.next.length;e+=2){var t=this.next[e];if(!t.isText&&!t.hasRequiredAttrs())return t}},z.prototype.compatible=function(e){for(var t=0;t<this.next.length;t+=2)for(var n=0;n<e.next.length;n+=2)if(this.next[t]==e.next[n])return!0;return!1},z.prototype.fillBefore=function(e,t,n){void 0===t&&(t=!1),void 0===n&&(n=0);var r=[this];return function o(s,a){var l=s.matchFragment(e,n);if(l&&(!t||l.validEnd))return i.from(a.map((function(e){return e.createAndFill()})));for(var c=0;c<s.next.length;c+=2){var u=s.next[c],d=s.next[c+1];if(!u.isText&&!u.hasRequiredAttrs()&&-1==r.indexOf(d)){r.push(d);var p=o(d,a.concat(u));if(p)return p}}}(this,[])},z.prototype.findWrapping=function(e){for(var t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];var n=this.computeWrapping(e);return this.wrapCache.push(e,n),n},z.prototype.computeWrapping=function(e){for(var t=Object.create(null),n=[{match:this,type:null,via:null}];n.length;){var r=n.shift(),o=r.match;if(o.matchType(e)){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 l=o.next[a];l.isLeaf||l.hasRequiredAttrs()||l.name in t||r.type&&!o.next[a+1].validEnd||(n.push({match:l.contentMatch,type:l,via:r}),t[l.name]=!0)}}},_.edgeCount.get=function(){return this.next.length>>1},z.prototype.edge=function(e){var t=e<<1;if(t>=this.next.length)throw new RangeError("There's no "+e+"th edge in this content match");return{type:this.next[t],next:this.next[t+1]}},z.prototype.toString=function(){var e=[];return function t(n){e.push(n);for(var r=1;r<n.next.length;r+=2)-1==e.indexOf(n.next[r])&&t(n.next[r])}(this),e.map((function(t,n){for(var r=n+(t.validEnd?"*":" ")+" ",o=0;o<t.next.length;o+=2)r+=(o?", ":"")+t.next[o].name+"->"+e.indexOf(t.next[o+1]);return r})).join("\n")},Object.defineProperties(z.prototype,_),z.empty=new z(!0);var I=function(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),""==this.tokens[this.tokens.length-1]&&this.tokens.pop(),""==this.tokens[0]&&this.tokens.shift()},P={next:{configurable:!0}};function $(e){var t=[];do{t.push(F(e))}while(e.eat("|"));return 1==t.length?t[0]:{type:"choice",exprs:t}}function F(e){var t=[];do{t.push(B(e))}while(e.next&&")"!=e.next&&"|"!=e.next);return 1==t.length?t[0]:{type:"seq",exprs:t}}function B(e){for(var t=function(e){if(e.eat("(")){var t=$(e);return e.eat(")")||e.err("Missing closing paren"),t}if(!/\W/.test(e.next)){var n=function(e,t){var n=e.nodeTypes,r=n[t];if(r)return[r];var o=[];for(var i in n){var s=n[i];s.groups.indexOf(t)>-1&&o.push(s)}0==o.length&&e.err("No node type or group '"+t+"' found");return o}(e,e.next).map((function(t){return null==e.inline?e.inline=t.isInline:e.inline!=t.isInline&&e.err("Mixing inline and block content"),{type:"name",value:t}}));return e.pos++,1==n.length?n[0]:{type:"choice",exprs:n}}e.err("Unexpected token '"+e.next+"'")}(e);;)if(e.eat("+"))t={type:"plus",expr:t};else if(e.eat("*"))t={type:"star",expr:t};else if(e.eat("?"))t={type:"opt",expr:t};else{if(!e.eat("{"))break;t=V(e,t)}return t}function L(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");var t=Number(e.next);return e.pos++,t}function V(e,t){var n=L(e),r=n;return e.eat(",")&&(r="}"!=e.next?L(e):-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:t}}function j(e,t){return t-e}function K(e,t){var n=[];return function t(r){var o=e[r];if(1==o.length&&!o[0].term)return t(o[0].to);n.push(r);for(var i=0;i<o.length;i++){var s=o[i],a=s.term,l=s.to;a||-1!=n.indexOf(l)||t(l)}}(t),n.sort(j)}function H(e){var t=Object.create(null);for(var n in e){var r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function W(e,t){var n=Object.create(null);for(var r in e){var o=t&&t[r];if(void 0===o){var i=e[r];if(!i.hasDefault)throw new RangeError("No value supplied for attribute "+r);o=i.default}n[r]=o}return n}function q(e){var t=Object.create(null);if(e)for(var n in e)t[n]=new U(e[n]);return t}P.next.get=function(){return this.tokens[this.pos]},I.prototype.eat=function(e){return this.next==e&&(this.pos++||!0)},I.prototype.err=function(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")},Object.defineProperties(I.prototype,P);var J=function(e,t,n){this.name=e,this.schema=t,this.spec=n,this.groups=n.group?n.group.split(" "):[],this.attrs=q(n.attrs),this.defaultAttrs=H(this.attrs),this.contentMatch=null,this.markSet=null,this.inlineContent=null,this.isBlock=!(n.inline||"text"==e),this.isText="text"==e},X={isInline:{configurable:!0},isTextblock:{configurable:!0},isLeaf:{configurable:!0},isAtom:{configurable:!0},whitespace:{configurable:!0}};X.isInline.get=function(){return!this.isBlock},X.isTextblock.get=function(){return this.isBlock&&this.inlineContent},X.isLeaf.get=function(){return this.contentMatch==z.empty},X.isAtom.get=function(){return this.isLeaf||this.spec.atom},X.whitespace.get=function(){return this.spec.whitespace||(this.spec.code?"pre":"normal")},J.prototype.hasRequiredAttrs=function(){for(var e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1},J.prototype.compatibleContent=function(e){return this==e||this.contentMatch.compatible(e.contentMatch)},J.prototype.computeAttrs=function(e){return!e&&this.defaultAttrs?this.defaultAttrs:W(this.attrs,e)},J.prototype.create=function(e,t,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new N(this,this.computeAttrs(e),i.from(t),u.setFrom(n))},J.prototype.createChecked=function(e,t,n){if(t=i.from(t),!this.validContent(t))throw new RangeError("Invalid content for node "+this.name);return new N(this,this.computeAttrs(e),t,u.setFrom(n))},J.prototype.createAndFill=function(e,t,n){if(e=this.computeAttrs(e),(t=i.from(t)).size){var r=this.contentMatch.fillBefore(t);if(!r)return null;t=r.append(t)}var o=this.contentMatch.matchFragment(t).fillBefore(i.empty,!0);return o?new N(this,e,t.append(o),u.setFrom(n)):null},J.prototype.validContent=function(e){var t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(var n=0;n<e.childCount;n++)if(!this.allowsMarks(e.child(n).marks))return!1;return!0},J.prototype.allowsMarkType=function(e){return null==this.markSet||this.markSet.indexOf(e)>-1},J.prototype.allowsMarks=function(e){if(null==this.markSet)return!0;for(var t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0},J.prototype.allowedMarks=function(e){if(null==this.markSet)return e;for(var t,n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||(t=e.slice(0,n));return t?t.length?t:u.empty:e},J.compile=function(e,t){var n=Object.create(null);e.forEach((function(e,r){return n[e]=new J(e,t,r)}));var r=t.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,X);var U=function(e){this.hasDefault=Object.prototype.hasOwnProperty.call(e,"default"),this.default=e.default},Y={isRequired:{configurable:!0}};Y.isRequired.get=function(){return!this.hasDefault},Object.defineProperties(U.prototype,Y);var G=function(e,t,n,r){this.name=e,this.schema=n,this.spec=r,this.attrs=q(r.attrs),this.rank=t,this.excluded=null;var o=H(this.attrs);this.instance=o&&new u(this,o)};G.prototype.create=function(e){return!e&&this.instance?this.instance:new u(this,W(this.attrs,e))},G.compile=function(e,t){var n=Object.create(null),r=0;return e.forEach((function(e,o){return n[e]=new G(e,r++,t,o)})),n},G.prototype.removeFromSet=function(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e},G.prototype.isInSet=function(e){for(var t=0;t<e.length;t++)if(e[t].type==this)return e[t]},G.prototype.excludes=function(e){return this.excluded.indexOf(e)>-1};var Q=function(e){for(var t in this.spec={},e)this.spec[t]=e[t];this.spec.nodes=o.from(e.nodes),this.spec.marks=o.from(e.marks),this.nodes=J.compile(this.spec.nodes,this),this.marks=G.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]=z.parse(s,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.markSet="_"==a?null:a?Z(this,a.split(" ")):""!=a&&i.inlineContent?null:[]}for(var l in this.marks){var c=this.marks[l],u=c.spec.excludes;c.excluded=null==u?[c]:""==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(e,t){for(var n=[],r=0;r<t.length;r++){var o=t[r],i=e.marks[o],s=i;if(i)n.push(i);else for(var a in e.marks){var l=e.marks[a];("_"==o||l.spec.group&&l.spec.group.split(" ").indexOf(o)>-1)&&n.push(s=l)}if(!s)throw new SyntaxError("Unknown mark type: '"+t[r]+"'")}return n}Q.prototype.node=function(e,t,n,r){if("string"==typeof e)e=this.nodeType(e);else{if(!(e instanceof J))throw new RangeError("Invalid node type: "+e);if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}return e.createChecked(t,n,r)},Q.prototype.text=function(e,t){var n=this.nodes.text;return new D(n,n.defaultAttrs,e,u.setFrom(t))},Q.prototype.mark=function(e,t){return"string"==typeof e&&(e=this.marks[e]),e.create(t)},Q.prototype.nodeFromJSON=function(e){return N.fromJSON(this,e)},Q.prototype.markFromJSON=function(e){return u.fromJSON(this,e)},Q.prototype.nodeType=function(e){var t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t};var ee=function(e,t){var n=this;this.schema=e,this.rules=t,this.tags=[],this.styles=[],t.forEach((function(e){e.tag?n.tags.push(e):e.style&&n.styles.push(e)})),this.normalizeLists=!this.tags.some((function(t){if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;var n=e.nodes[t.node];return n.contentMatch.matchType(n)}))};ee.prototype.parse=function(e,t){void 0===t&&(t={});var n=new se(this,t,!1);return n.addAll(e,null,t.from,t.to),n.finish()},ee.prototype.parseSlice=function(e,t){void 0===t&&(t={});var n=new se(this,t,!0);return n.addAll(e,null,t.from,t.to),p.maxOpen(n.finish())},ee.prototype.matchTag=function(e,t,n){for(var r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){var o=this.tags[r];if(le(e,o.tag)&&(void 0===o.namespace||e.namespaceURI==o.namespace)&&(!o.context||t.matchesContext(o.context))){if(o.getAttrs){var i=o.getAttrs(e);if(!1===i)continue;o.attrs=i}return o}}},ee.prototype.matchStyle=function(e,t,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(e)||i.context&&!n.matchesContext(i.context)||i.style.length>e.length&&(61!=i.style.charCodeAt(e.length)||i.style.slice(e.length+1)!=t))){if(i.getAttrs){var s=i.getAttrs(t);if(!1===s)continue;i.attrs=s}return i}}},ee.schemaRules=function(e){var t=[];function n(e){for(var n=null==e.priority?50:e.priority,r=0;r<t.length;r++){var o=t[r];if((null==o.priority?50:o.priority)<n)break}t.splice(r,0,e)}var r=function(t){var r=e.marks[t].spec.parseDOM;r&&r.forEach((function(e){n(e=ce(e)),e.mark=t}))};for(var o in e.marks)r(o);var i;for(var s in e.nodes)i=void 0,(i=e.nodes[s].spec.parseDOM)&&i.forEach((function(e){n(e=ce(e)),e.node=s}));return t},ee.fromSchema=function(e){return e.cached.domParser||(e.cached.domParser=new ee(e,ee.schemaRules(e)))};var te={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},ne={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},re={ol:!0,ul:!0};function oe(e,t,n){return null!=t?(t?1:0)|("full"===t?2:0):e&&"pre"==e.whitespace?3:-5&n}var ie=function(e,t,n,r,o,i,s){this.type=e,this.attrs=t,this.solid=o,this.match=i||(4&s?null:e.contentMatch),this.options=s,this.content=[],this.marks=n,this.activeMarks=u.none,this.pendingMarks=r,this.stashMarks=[]};ie.prototype.findWrapping=function(e){if(!this.match){if(!this.type)return[];var t=this.type.contentMatch.fillBefore(i.from(e));if(!t){var n,r=this.type.contentMatch;return(n=r.findWrapping(e.type))?(this.match=r,n):null}this.match=this.type.contentMatch.matchFragment(t)}return this.match.findWrapping(e.type)},ie.prototype.finish=function(e){if(!(1&this.options)){var t,n=this.content[this.content.length-1];n&&n.isText&&(t=/[ \t\r\n\u000c]+$/.exec(n.text))&&(n.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-t[0].length)))}var r=i.from(this.content);return!e&&this.match&&(r=r.append(this.match.fillBefore(i.empty,!0))),this.type?this.type.create(this.attrs,r,this.marks):r},ie.prototype.popFromStashMark=function(e){for(var t=this.stashMarks.length-1;t>=0;t--)if(e.eq(this.stashMarks[t]))return this.stashMarks.splice(t,1)[0]},ie.prototype.applyPending=function(e){for(var t=0,n=this.pendingMarks;t<n.length;t++){var r=n[t];(this.type?this.type.allowsMarkType(r.type):ue(r.type,e))&&!r.isInSet(this.activeMarks)&&(this.activeMarks=r.addToSet(this.activeMarks),this.pendingMarks=r.removeFromSet(this.pendingMarks))}},ie.prototype.inlineContext=function(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!te.hasOwnProperty(e.parentNode.nodeName.toLowerCase())};var se=function(e,t,n){this.parser=e,this.options=t,this.isOpen=n;var r,o=t.topNode,i=oe(null,t.preserveWhitespace,0)|(n?4:0);r=o?new ie(o.type,o.attrs,u.none,u.none,!0,t.topMatch||o.type.contentMatch,i):new ie(n?null:e.schema.topNodeType,null,u.none,u.none,!0,null,i),this.nodes=[r],this.open=0,this.find=t.findPositions,this.needsBlock=!1},ae={top:{configurable:!0},currentPos:{configurable:!0}};function le(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function ce(e){var t={};for(var n in e)t[n]=e[n];return t}function ue(e,t){var n=t.schema.nodes,r=function(r){var o=n[r];if(o.allowsMarkType(e)){var i=[],s=function(e){i.push(e);for(var n=0;n<e.edgeCount;n++){var r=e.edge(n),o=r.type,a=r.next;if(o==t)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}}ae.top.get=function(){return this.nodes[this.open]},se.prototype.addDOM=function(e){if(3==e.nodeType)this.addTextNode(e);else if(1==e.nodeType){var t=e.getAttribute("style"),n=t?this.readStyles(function(e){var t,n=/\s*([\w-]+)\s*:\s*([^;]+)/g,r=[];for(;t=n.exec(e);)r.push(t[1],t[2].trim());return r}(t)):null,r=this.top;if(null!=n)for(var o=0;o<n.length;o++)this.addPendingMark(n[o]);if(this.addElement(e),null!=n)for(var i=0;i<n.length;i++)this.removePendingMark(n[i],r)}},se.prototype.addTextNode=function(e){var t=e.nodeValue,n=this.top;if(2&n.options||n.inlineContext(e)||/[^ \t\r\n\u000c]/.test(t)){if(1&n.options)t=2&n.options?t.replace(/\r\n?/g,"\n"):t.replace(/\r?\n|\r/g," ");else if(t=t.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(t)&&this.open==this.nodes.length-1){var r=n.content[n.content.length-1],o=e.previousSibling;(!r||o&&"BR"==o.nodeName||r.isText&&/[ \t\r\n\u000c]$/.test(r.text))&&(t=t.slice(1))}t&&this.insertNode(this.parser.schema.text(t)),this.findInText(e)}else this.findInside(e)},se.prototype.addElement=function(e,t){var n,r=e.nodeName.toLowerCase();re.hasOwnProperty(r)&&this.parser.normalizeLists&&function(e){for(var t=e.firstChild,n=null;t;t=t.nextSibling){var r=1==t.nodeType?t.nodeName.toLowerCase():null;r&&re.hasOwnProperty(r)&&n?(n.appendChild(t),t=n):"li"==r?n=t:r&&(n=null)}}(e);var o=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(n=this.parser.matchTag(e,this,t));if(o?o.ignore:ne.hasOwnProperty(r))this.findInside(e),this.ignoreFallback(e);else if(!o||o.skip||o.closeParent){o&&o.closeParent?this.open=Math.max(0,this.open-1):o&&o.skip.nodeType&&(e=o.skip);var i,s=this.top,a=this.needsBlock;if(te.hasOwnProperty(r))i=!0,s.type||(this.needsBlock=!0);else if(!e.firstChild)return void this.leafFallback(e);this.addAll(e),i&&this.sync(s),this.needsBlock=a}else this.addElementByRule(e,o,!1===o.consuming?n:null)},se.prototype.leafFallback=function(e){"BR"==e.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode("\n"))},se.prototype.ignoreFallback=function(e){"BR"!=e.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"))},se.prototype.readStyles=function(e){var t=u.none;e:for(var n=0;n<e.length;n+=2)for(var r=null;;){var o=this.parser.matchStyle(e[n],e[n+1],this,r);if(!o)continue e;if(o.ignore)return null;if(t=this.parser.schema.marks[o.mark].create(o.attrs).addToSet(t),!1!==o.consuming)break;r=o}return t},se.prototype.addElementByRule=function(e,t,n){var r,o,i,s=this;t.node?(o=this.parser.schema.nodes[t.node]).isLeaf?this.insertNode(o.create(t.attrs))||this.leafFallback(e):r=this.enter(o,t.attrs,t.preserveWhitespace):(i=this.parser.schema.marks[t.mark].create(t.attrs),this.addPendingMark(i));var a=this.top;if(o&&o.isLeaf)this.findInside(e);else if(n)this.addElement(e,n);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach((function(e){return s.insertNode(e)}));else{var l=t.contentElement;"string"==typeof l?l=e.querySelector(l):"function"==typeof l&&(l=l(e)),l||(l=e),this.findAround(e,l,!0),this.addAll(l,r)}r&&(this.sync(a),this.open--),i&&this.removePendingMark(i,a)},se.prototype.addAll=function(e,t,n,r){for(var o=n||0,i=n?e.childNodes[n]:e.firstChild,s=null==r?null:e.childNodes[r];i!=s;i=i.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(i),t&&te.hasOwnProperty(i.nodeName.toLowerCase())&&this.sync(t);this.findAtPoint(e,o)},se.prototype.findPlace=function(e){for(var t,n,r=this.open;r>=0;r--){var o=this.nodes[r],i=o.findWrapping(e);if(i&&(!t||t.length>i.length)&&(t=i,n=o,!i.length))break;if(o.solid)break}if(!t)return!1;this.sync(n);for(var s=0;s<t.length;s++)this.enterInner(t[s],null,!1);return!0},se.prototype.insertNode=function(e){if(e.isInline&&this.needsBlock&&!this.top.type){var t=this.textblockFromContext();t&&this.enterInner(t)}if(this.findPlace(e)){this.closeExtra();var n=this.top;n.applyPending(e.type),n.match&&(n.match=n.match.matchType(e.type));for(var r=n.activeMarks,o=0;o<e.marks.length;o++)n.type&&!n.type.allowsMarkType(e.marks[o].type)||(r=e.marks[o].addToSet(r));return n.content.push(e.mark(r)),!0}return!1},se.prototype.enter=function(e,t,n){var r=this.findPlace(e.create(t));return r&&this.enterInner(e,t,!0,n),r},se.prototype.enterInner=function(e,t,n,r){this.closeExtra();var o=this.top;o.applyPending(e),o.match=o.match&&o.match.matchType(e,t);var i=oe(e,r,o.options);4&o.options&&0==o.content.length&&(i|=4),this.nodes.push(new ie(e,t,o.activeMarks,o.pendingMarks,n,null,i)),this.open++},se.prototype.closeExtra=function(e){var t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}},se.prototype.finish=function(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)},se.prototype.sync=function(e){for(var t=this.open;t>=0;t--)if(this.nodes[t]==e)return void(this.open=t)},ae.currentPos.get=function(){this.closeExtra();for(var e=0,t=this.open;t>=0;t--){for(var n=this.nodes[t].content,r=n.length-1;r>=0;r--)e+=n[r].nodeSize;t&&e++}return e},se.prototype.findAtPoint=function(e,t){if(this.find)for(var n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)},se.prototype.findInside=function(e){if(this.find)for(var t=0;t<this.find.length;t++)null==this.find[t].pos&&1==e.nodeType&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)},se.prototype.findAround=function(e,t,n){if(e!=t&&this.find)for(var r=0;r<this.find.length;r++){if(null==this.find[r].pos&&1==e.nodeType&&e.contains(this.find[r].node))t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}},se.prototype.findInText=function(e){if(this.find)for(var t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))},se.prototype.matchesContext=function(e){var t=this;if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);var n=e.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(e,a){for(;e>=0;e--){var l=n[e];if(""==l){if(e==n.length-1||0==e)continue;for(;a>=i;a--)if(s(e-1,a))return!0;return!1}var c=a>0||0==a&&o?t.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!c||c.name!=l&&-1==c.groups.indexOf(l))return!1;a--}return!0};return s(n.length-1,this.open)},se.prototype.textblockFromContext=function(){var e=this.options.context;if(e)for(var t=e.depth;t>=0;t--){var n=e.node(t).contentMatchAt(e.indexAfter(t)).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}},se.prototype.addPendingMark=function(e){var t=function(e,t){for(var n=0;n<t.length;n++)if(e.eq(t[n]))return t[n]}(e,this.top.pendingMarks);t&&this.top.stashMarks.push(t),this.top.pendingMarks=e.addToSet(this.top.pendingMarks)},se.prototype.removePendingMark=function(e,t){for(var n=this.open;n>=0;n--){var r=this.nodes[n];if(r.pendingMarks.lastIndexOf(e)>-1)r.pendingMarks=e.removeFromSet(r.pendingMarks);else{r.activeMarks=e.removeFromSet(r.activeMarks);var o=r.popFromStashMark(e);o&&r.type&&r.type.allowsMarkType(o.type)&&(r.activeMarks=o.addToSet(r.activeMarks))}if(r==t)break}},Object.defineProperties(se.prototype,ae);var de=function(e,t){this.nodes=e||{},this.marks=t||{}};function pe(e){var t={};for(var n in e){var r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function fe(e){return e.document||window.document}de.prototype.serializeFragment=function(e,t,n){var r=this;void 0===t&&(t={}),n||(n=fe(t).createDocumentFragment());var o=n,i=null;return e.forEach((function(e){if(i||e.marks.length){i||(i=[]);for(var n=0,s=0;n<i.length&&s<e.marks.length;){var a=e.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<e.marks.length;){var l=e.marks[s++],c=r.serializeMark(l,e.isInline,t);c&&(i.push(l,o),o.appendChild(c.dom),o=c.contentDOM||c.dom)}}o.appendChild(r.serializeNodeInner(e,t))})),n},de.prototype.serializeNodeInner=function(e,t){void 0===t&&(t={});var n=de.renderSpec(fe(t),this.nodes[e.type.name](e)),r=n.dom,o=n.contentDOM;if(o){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");t.onContent?t.onContent(e,o,t):this.serializeFragment(e.content,t,o)}return r},de.prototype.serializeNode=function(e,t){void 0===t&&(t={});for(var n=this.serializeNodeInner(e,t),r=e.marks.length-1;r>=0;r--){var o=this.serializeMark(e.marks[r],e.isInline,t);o&&((o.contentDOM||o.dom).appendChild(n),n=o.dom)}return n},de.prototype.serializeMark=function(e,t,n){void 0===n&&(n={});var r=this.marks[e.type.name];return r&&de.renderSpec(fe(n),r(e,t))},de.renderSpec=function(e,t,n){if(void 0===n&&(n=null),"string"==typeof t)return{dom:e.createTextNode(t)};if(null!=t.nodeType)return{dom:t};if(t.dom&&null!=t.dom.nodeType)return t;var r=t[0],o=r.indexOf(" ");o>0&&(n=r.slice(0,o),r=r.slice(o+1));var i=null,s=n?e.createElementNS(n,r):e.createElement(r),a=t[1],l=1;if(a&&"object"==typeof a&&null==a.nodeType&&!Array.isArray(a))for(var c in l=2,a)if(null!=a[c]){var u=c.indexOf(" ");u>0?s.setAttributeNS(c.slice(0,u),c.slice(u+1),a[c]):s.setAttribute(c,a[c])}for(var d=l;d<t.length;d++){var p=t[d];if(0===p){if(d<t.length-1||d>l)throw new RangeError("Content hole must be the only child of its parent node");return{dom:s,contentDOM:s}}var f=de.renderSpec(e,p,n),h=f.dom,m=f.contentDOM;if(s.appendChild(h),m){if(i)throw new RangeError("Multiple content holes");i=m}}return{dom:s,contentDOM:i}},de.fromSchema=function(e){return e.cached.domSerializer||(e.cached.domSerializer=new de(this.nodesFromSchema(e),this.marksFromSchema(e)))},de.nodesFromSchema=function(e){var t=pe(e.nodes);return t.text||(t.text=function(e){return e.text}),t},de.marksFromSchema=function(e){return pe(e.marks)}},function(e,t,n){"use strict";n.r(t),n.d(t,"AllSelection",(function(){return f})),n.d(t,"EditorState",(function(){return k})),n.d(t,"NodeSelection",(function(){return d})),n.d(t,"Plugin",(function(){return M})),n.d(t,"PluginKey",(function(){return A})),n.d(t,"Selection",(function(){return s})),n.d(t,"SelectionRange",(function(){return l})),n.d(t,"TextSelection",(function(){return c})),n.d(t,"Transaction",(function(){return g}));var r=n(0),o=n(2),i=Object.create(null),s=function(e,t,n){this.ranges=n||[new l(e.min(t),e.max(t))],this.$anchor=e,this.$head=t},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 e=this.ranges,t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$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(e,t){void 0===t&&(t=r.Slice.empty);for(var n=t.content.lastChild,o=null,i=0;i<t.openEnd;i++)o=n,n=n.lastChild;for(var s=e.steps.length,a=this.ranges,l=0;l<a.length;l++){var c=a[l],u=c.$from,d=c.$to,p=e.mapping.slice(s);e.replaceRange(p.map(u.pos),p.map(d.pos),l?r.Slice.empty:t),0==l&&v(e,s,(n?n.isInline:o&&o.isTextblock)?-1:1)}},s.prototype.replaceWith=function(e,t){for(var n=e.steps.length,r=this.ranges,o=0;o<r.length;o++){var i=r[o],s=i.$from,a=i.$to,l=e.mapping.slice(n),c=l.map(s.pos),u=l.map(a.pos);o?e.deleteRange(c,u):(e.replaceRangeWith(c,u,t),v(e,n,t.isInline?-1:1))}},s.findFrom=function(e,t,n){var r=e.parent.inlineContent?new c(e):m(e.node(0),e.parent,e.pos,e.index(),t,n);if(r)return r;for(var o=e.depth-1;o>=0;o--){var i=t<0?m(e.node(0),e.node(o),e.before(o+1),e.index(o),t,n):m(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,t,n);if(i)return i}},s.near=function(e,t){return void 0===t&&(t=1),this.findFrom(e,t)||this.findFrom(e,-t)||new f(e.node(0))},s.atStart=function(e){return m(e,e,0,0,1)||new f(e)},s.atEnd=function(e){return m(e,e,e.content.size,e.childCount,-1)||new f(e)},s.fromJSON=function(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");var n=i[t.type];if(!n)throw new RangeError("No selection type "+t.type+" defined");return n.fromJSON(e,t)},s.jsonID=function(e,t){if(e in i)throw new RangeError("Duplicate use of selection JSON ID "+e);return i[e]=t,t.prototype.jsonID=e,t},s.prototype.getBookmark=function(){return c.between(this.$anchor,this.$head).getBookmark()},Object.defineProperties(s.prototype,a),s.prototype.visible=!0;var l=function(e,t){this.$from=e,this.$to=t},c=function(e){function t(t,n){void 0===n&&(n=t),e.call(this,t,n)}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={$cursor:{configurable:!0}};return n.$cursor.get=function(){return this.$anchor.pos==this.$head.pos?this.$head:null},t.prototype.map=function(n,r){var o=n.resolve(r.map(this.head));if(!o.parent.inlineContent)return e.near(o);var i=n.resolve(r.map(this.anchor));return new t(i.parent.inlineContent?i:o,o)},t.prototype.replace=function(t,n){if(void 0===n&&(n=r.Slice.empty),e.prototype.replace.call(this,t,n),n==r.Slice.empty){var o=this.$from.marksAcross(this.$to);o&&t.ensureMarks(o)}},t.prototype.eq=function(e){return e instanceof t&&e.anchor==this.anchor&&e.head==this.head},t.prototype.getBookmark=function(){return new u(this.anchor,this.head)},t.prototype.toJSON=function(){return{type:"text",anchor:this.anchor,head:this.head}},t.fromJSON=function(e,n){if("number"!=typeof n.anchor||"number"!=typeof n.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new t(e.resolve(n.anchor),e.resolve(n.head))},t.create=function(e,t,n){void 0===n&&(n=t);var r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))},t.between=function(n,r,o){var i=n.pos-r.pos;if(o&&!i||(o=i>=0?1:-1),!r.parent.inlineContent){var s=e.findFrom(r,o,!0)||e.findFrom(r,-o,!0);if(!s)return e.near(r,o);r=s.$head}return n.parent.inlineContent||(0==i||(n=(e.findFrom(n,-o,!0)||e.findFrom(n,o,!0)).$anchor).pos<r.pos!=i<0)&&(n=r),new t(n,r)},Object.defineProperties(t.prototype,n),t}(s);s.jsonID("text",c);var u=function(e,t){this.anchor=e,this.head=t};u.prototype.map=function(e){return new u(e.map(this.anchor),e.map(this.head))},u.prototype.resolve=function(e){return c.between(e.resolve(this.anchor),e.resolve(this.head))};var d=function(e){function t(t){var n=t.nodeAfter,r=t.node(0).resolve(t.pos+n.nodeSize);e.call(this,t,r),this.node=n}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.map=function(n,r){var o=r.mapResult(this.anchor),i=o.deleted,s=o.pos,a=n.resolve(s);return i?e.near(a):new t(a)},t.prototype.content=function(){return new r.Slice(r.Fragment.from(this.node),0,0)},t.prototype.eq=function(e){return e instanceof t&&e.anchor==this.anchor},t.prototype.toJSON=function(){return{type:"node",anchor:this.anchor}},t.prototype.getBookmark=function(){return new p(this.anchor)},t.fromJSON=function(e,n){if("number"!=typeof n.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new t(e.resolve(n.anchor))},t.create=function(e,t){return new this(e.resolve(t))},t.isSelectable=function(e){return!e.isText&&!1!==e.type.spec.selectable},t}(s);d.prototype.visible=!1,s.jsonID("node",d);var p=function(e){this.anchor=e};p.prototype.map=function(e){var t=e.mapResult(this.anchor),n=t.deleted,r=t.pos;return n?new u(r,r):new p(r)},p.prototype.resolve=function(e){var t=e.resolve(this.anchor),n=t.nodeAfter;return n&&d.isSelectable(n)?new d(t):s.near(t)};var f=function(e){function t(t){e.call(this,t.resolve(0),t.resolve(t.content.size))}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.replace=function(t,n){if(void 0===n&&(n=r.Slice.empty),n==r.Slice.empty){t.delete(0,t.doc.content.size);var o=e.atStart(t.doc);o.eq(t.selection)||t.setSelection(o)}else e.prototype.replace.call(this,t,n)},t.prototype.toJSON=function(){return{type:"all"}},t.fromJSON=function(e){return new t(e)},t.prototype.map=function(e){return new t(e)},t.prototype.eq=function(e){return e instanceof t},t.prototype.getBookmark=function(){return h},t}(s);s.jsonID("all",f);var h={map:function(){return this},resolve:function(e){return new f(e)}};function m(e,t,n,r,o,i){if(t.inlineContent)return c.create(e,n);for(var s=r-(o>0?0:1);o>0?s<t.childCount:s>=0;s+=o){var a=t.child(s);if(a.isAtom){if(!i&&d.isSelectable(a))return d.create(e,n-(o<0?a.nodeSize:0))}else{var l=m(e,a,n+o,o<0?a.childCount:0,o,i);if(l)return l}n+=a.nodeSize*o}}function v(e,t,n){var r=e.steps.length-1;if(!(r<t)){var i,a=e.steps[r];if(a instanceof o.ReplaceStep||a instanceof o.ReplaceAroundStep)e.mapping.maps[r].forEach((function(e,t,n,r){null==i&&(i=r)})),e.setSelection(s.near(e.doc.resolve(i),n))}}var g=function(e){function t(t){e.call(this,t.doc),this.time=Date.now(),this.curSelection=t.selection,this.curSelectionFor=0,this.storedMarks=t.storedMarks,this.updated=0,this.meta=Object.create(null)}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;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},t.prototype.setSelection=function(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=-3&(1|this.updated),this.storedMarks=null,this},n.selectionSet.get=function(){return(1&this.updated)>0},t.prototype.setStoredMarks=function(e){return this.storedMarks=e,this.updated|=2,this},t.prototype.ensureMarks=function(e){return r.Mark.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this},t.prototype.addStoredMark=function(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))},t.prototype.removeStoredMark=function(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))},n.storedMarksSet.get=function(){return(2&this.updated)>0},t.prototype.addStep=function(t,n){e.prototype.addStep.call(this,t,n),this.updated=-3&this.updated,this.storedMarks=null},t.prototype.setTime=function(e){return this.time=e,this},t.prototype.replaceSelection=function(e){return this.selection.replace(this,e),this},t.prototype.replaceSelectionWith=function(e,t){var n=this.selection;return!1!==t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||r.Mark.none))),n.replaceWith(this,e),this},t.prototype.deleteSelection=function(){return this.selection.replace(this),this},t.prototype.insertText=function(e,t,n){void 0===n&&(n=t);var r=this.doc.type.schema;if(null==t)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();if(!e)return this.deleteRange(t,n);var o=this.storedMarks;if(!o){var i=this.doc.resolve(t);o=n==t?i.marks():i.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,o)),this.selection.empty||this.setSelection(s.near(this.selection.$to)),this},t.prototype.setMeta=function(e,t){return this.meta["string"==typeof e?e:e.key]=t,this},t.prototype.getMeta=function(e){return this.meta["string"==typeof e?e:e.key]},n.isGeneric.get=function(){for(var e in this.meta)return!1;return!0},t.prototype.scrollIntoView=function(){return this.updated|=4,this},n.scrolledIntoView.get=function(){return(4&this.updated)>0},Object.defineProperties(t.prototype,n),t}(o.Transform);function y(e,t){return t&&e?e.bind(t):e}var w=function(e,t,n){this.name=e,this.init=y(t.init,n),this.apply=y(t.apply,n)},b=[new w("doc",{init:function(e){return e.doc||e.schema.topNodeType.createAndFill()},apply:function(e){return e.doc}}),new w("selection",{init:function(e,t){return e.selection||s.atStart(t.doc)},apply:function(e){return e.selection}}),new w("storedMarks",{init:function(e){return e.storedMarks||null},apply:function(e,t,n,r){return r.selection.$cursor?e.storedMarks:null}}),new w("scrollToSelection",{init:function(){return 0},apply:function(e,t){return e.scrolledIntoView?t+1:t}})],S=function(e,t){var n=this;this.schema=e,this.fields=b.concat(),this.plugins=[],this.pluginsByKey=Object.create(null),t&&t.forEach((function(e){if(n.pluginsByKey[e.key])throw new RangeError("Adding different instances of a keyed plugin ("+e.key+")");n.plugins.push(e),n.pluginsByKey[e.key]=e,e.spec.state&&n.fields.push(new w(e.key,e.spec.state,e))}))},k=function(e){this.config=e},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(e){return this.applyTransaction(e).state},k.prototype.filterTransaction=function(e,t){void 0===t&&(t=-1);for(var n=0;n<this.config.plugins.length;n++)if(n!=t){var r=this.config.plugins[n];if(r.spec.filterTransaction&&!r.spec.filterTransaction.call(r,e,this))return!1}return!0},k.prototype.applyTransaction=function(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};for(var t=[e],n=this.applyInner(e),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,l=r?r[i].state:this,c=a<t.length&&s.spec.appendTransaction.call(s,a?t.slice(a):t,l,n);if(c&&n.filterTransaction(c,i)){if(c.setMeta("appendedTransaction",e),!r){r=[];for(var u=0;u<this.config.plugins.length;u++)r.push(u<i?{state:n,n:t.length}:{state:this,n:0})}t.push(c),n=n.applyInner(c),o=!0}r&&(r[i]={state:n,n:t.length})}}if(!o)return{state:n,transactions:t}}},k.prototype.applyInner=function(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");for(var t=new k(this.config),n=this.config.fields,r=0;r<n.length;r++){var o=n[r];t[o.name]=o.apply(e,this[o.name],this,t)}for(var i=0;i<C.length;i++)C[i](this,e,t);return t},x.tr.get=function(){return new g(this)},k.create=function(e){for(var t=new S(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new k(t),r=0;r<t.fields.length;r++)n[t.fields[r].name]=t.fields[r].init(e,n);return n},k.prototype.reconfigure=function(e){for(var t=new S(this.schema,e.plugins),n=t.fields,r=new k(t),o=0;o<n.length;o++){var i=n[o].name;r[i]=this.hasOwnProperty(i)?this[i]:n[o].init(e,r)}return r},k.prototype.toJSON=function(e){var t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map((function(e){return e.toJSON()}))),e&&"object"==typeof e)for(var n in e){if("doc"==n||"selection"==n)throw new RangeError("The JSON fields `doc` and `selection` are reserved");var r=e[n],o=r.spec.state;o&&o.toJSON&&(t[n]=o.toJSON.call(r,this[r.key]))}return t},k.fromJSON=function(e,t,n){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");var o=new S(e.schema,e.plugins),i=new k(o);return o.fields.forEach((function(o){if("doc"==o.name)i.doc=r.Node.fromJSON(e.schema,t.doc);else if("selection"==o.name)i.selection=s.fromJSON(i.doc,t.selection);else if("storedMarks"==o.name)t.storedMarks&&(i.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(n)for(var a in n){var l=n[a],c=l.spec.state;if(l.key==o.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,a))return void(i[o.name]=c.fromJSON.call(l,e,t[a],i))}i[o.name]=o.init(e,i)}})),i},k.addApplyListener=function(e){C.push(e)},k.removeApplyListener=function(e){var t=C.indexOf(e);t>-1&&C.splice(t,1)},Object.defineProperties(k.prototype,x);var C=[];var M=function(e){this.props={},e.props&&function e(t,n,r){for(var o in t){var i=t[o];i instanceof Function?i=i.bind(n):"handleDOMEvents"==o&&(i=e(i,n,{})),r[o]=i}return r}(e.props,this,this.props),this.spec=e,this.key=e.key?e.key.key:T("plugin")};M.prototype.getState=function(e){return e[this.key]};var O=Object.create(null);function T(e){return e in O?e+"$"+ ++O[e]:(O[e]=0,e+"$")}var A=function(e){void 0===e&&(e="key"),this.key=T(e)};A.prototype.get=function(e){return e.config.pluginsByKey[this.key]},A.prototype.getState=function(e){return e[this.key]}},function(e,t,n){"use strict";n.r(t),n.d(t,"AddMarkStep",(function(){return R})),n.d(t,"MapResult",(function(){return s})),n.d(t,"Mapping",(function(){return l})),n.d(t,"RemoveMarkStep",(function(){return D})),n.d(t,"ReplaceAroundStep",(function(){return g})),n.d(t,"ReplaceStep",(function(){return v})),n.d(t,"Step",(function(){return h})),n.d(t,"StepMap",(function(){return a})),n.d(t,"StepResult",(function(){return m})),n.d(t,"Transform",(function(){return u})),n.d(t,"TransformError",(function(){return c})),n.d(t,"canJoin",(function(){return C})),n.d(t,"canSplit",(function(){return x})),n.d(t,"dropPoint",(function(){return A})),n.d(t,"findWrapping",(function(){return S})),n.d(t,"insertPoint",(function(){return T})),n.d(t,"joinPoint",(function(){return O})),n.d(t,"liftTarget",(function(){return b})),n.d(t,"replaceStep",(function(){return E}));var r=n(0),o=Math.pow(2,16);function i(e){return 65535&e}var s=function(e,t,n){void 0===t&&(t=!1),void 0===n&&(n=null),this.pos=e,this.deleted=t,this.recover=n},a=function e(t,n){if(void 0===n&&(n=!1),!t.length&&e.empty)return e.empty;this.ranges=t,this.inverted=n};a.prototype.recover=function(e){var t=0,n=i(e);if(!this.inverted)for(var r=0;r<n;r++)t+=this.ranges[3*r+2]-this.ranges[3*r+1];return this.ranges[3*n]+t+function(e){return(e-(65535&e))/o}(e)},a.prototype.mapResult=function(e,t){return void 0===t&&(t=1),this._map(e,t,!1)},a.prototype.map=function(e,t){return void 0===t&&(t=1),this._map(e,t,!0)},a.prototype._map=function(e,t,n){for(var r=0,i=this.inverted?2:1,a=this.inverted?1:2,l=0;l<this.ranges.length;l+=3){var c=this.ranges[l]-(this.inverted?r:0);if(c>e)break;var u=this.ranges[l+i],d=this.ranges[l+a],p=c+u;if(e<=p){var f=c+r+((u?e==c?-1:e==p?1:t:t)<0?0:d);if(n)return f;var h=e==(t<0?c:p)?null:l/3+(e-c)*o;return new s(f,t<0?e!=c:e!=p,h)}r+=d-u}return n?e+r:new s(e+r)},a.prototype.touches=function(e,t){for(var n=0,r=i(t),o=this.inverted?2:1,s=this.inverted?1:2,a=0;a<this.ranges.length;a+=3){var l=this.ranges[a]-(this.inverted?n:0);if(l>e)break;var c=this.ranges[a+o];if(e<=l+c&&a==3*r)return!0;n+=this.ranges[a+s]-c}return!1},a.prototype.forEach=function(e){for(var t=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),l=this.ranges[r+t],c=this.ranges[r+n];e(s,s+l,a,a+c),o+=c-l}},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(e){return 0==e?a.empty:new a(e<0?[0,-e,0]:[0,0,e])},a.empty=new a([]);var l=function(e,t,n,r){this.maps=e||[],this.from=n||0,this.to=null==r?this.maps.length:r,this.mirror=t};function c(e){var t=Error.call(this,e);return t.__proto__=c.prototype,t}l.prototype.slice=function(e,t){return void 0===e&&(e=0),void 0===t&&(t=this.maps.length),new l(this.maps,this.mirror,e,t)},l.prototype.copy=function(){return new l(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)},l.prototype.appendMap=function(e,t){this.to=this.maps.push(e),null!=t&&this.setMirror(this.maps.length-1,t)},l.prototype.appendMapping=function(e){for(var t=0,n=this.maps.length;t<e.maps.length;t++){var r=e.getMirror(t);this.appendMap(e.maps[t],null!=r&&r<t?n+r:null)}},l.prototype.getMirror=function(e){if(this.mirror)for(var t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]},l.prototype.setMirror=function(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)},l.prototype.appendMappingInverted=function(e){for(var t=e.maps.length-1,n=this.maps.length+e.maps.length;t>=0;t--){var r=e.getMirror(t);this.appendMap(e.maps[t].invert(),null!=r&&r>t?n-r-1:null)}},l.prototype.invert=function(){var e=new l;return e.appendMappingInverted(this),e},l.prototype.map=function(e,t){if(void 0===t&&(t=1),this.mirror)return this._map(e,t,!0);for(var n=this.from;n<this.to;n++)e=this.maps[n].map(e,t);return e},l.prototype.mapResult=function(e,t){return void 0===t&&(t=1),this._map(e,t,!1)},l.prototype._map=function(e,t,n){for(var r=!1,o=this.from;o<this.to;o++){var i=this.maps[o].mapResult(e,t);if(null!=i.recover){var a=this.getMirror(o);if(null!=a&&a>o&&a<this.to){o=a,e=this.maps[a].recover(i.recover);continue}}i.deleted&&(r=!0),e=i.pos}return n?e:new s(e,r)},c.prototype=Object.create(Error.prototype),c.prototype.constructor=c,c.prototype.name="TransformError";var u=function(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new l},d={before:{configurable:!0},docChanged:{configurable:!0}};function p(){throw new Error("Override me")}d.before.get=function(){return this.docs.length?this.docs[0]:this.doc},u.prototype.step=function(e){var t=this.maybeStep(e);if(t.failed)throw new c(t.failed);return this},u.prototype.maybeStep=function(e){var t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t},d.docChanged.get=function(){return this.steps.length>0},u.prototype.addStep=function(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t},Object.defineProperties(u.prototype,d);var f=Object.create(null),h=function(){};h.prototype.apply=function(e){return p()},h.prototype.getMap=function(){return a.empty},h.prototype.invert=function(e){return p()},h.prototype.map=function(e){return p()},h.prototype.merge=function(e){return null},h.prototype.toJSON=function(){return p()},h.fromJSON=function(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");var n=f[t.stepType];if(!n)throw new RangeError("No step type "+t.stepType+" defined");return n.fromJSON(e,t)},h.jsonID=function(e,t){if(e in f)throw new RangeError("Duplicate use of step JSON ID "+e);return f[e]=t,t.prototype.jsonID=e,t};var m=function(e,t){this.doc=e,this.failed=t};m.ok=function(e){return new m(e,null)},m.fail=function(e){return new m(null,e)},m.fromReplace=function(e,t,n,o){try{return m.ok(e.replace(t,n,o))}catch(e){if(e instanceof r.ReplaceError)return m.fail(e.message);throw e}};var v=function(e){function t(t,n,r,o){e.call(this),this.from=t,this.to=n,this.slice=r,this.structure=!!o}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.apply=function(e){return this.structure&&y(e,this.from,this.to)?m.fail("Structure replace would overwrite content"):m.fromReplace(e,this.from,this.to,this.slice)},t.prototype.getMap=function(){return new a([this.from,this.to-this.from,this.slice.size])},t.prototype.invert=function(e){return new t(this.from,this.from+this.slice.size,e.slice(this.from,this.to))},t.prototype.map=function(e){var n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted?null:new t(n.pos,Math.max(n.pos,r.pos),this.slice)},t.prototype.merge=function(e){if(!(e instanceof t)||e.structure||this.structure)return null;if(this.from+this.slice.size!=e.from||this.slice.openEnd||e.slice.openStart){if(e.to!=this.from||this.slice.openStart||e.slice.openEnd)return null;var n=this.slice.size+e.slice.size==0?r.Slice.empty:new r.Slice(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new t(e.from,this.to,n,this.structure)}var o=this.slice.size+e.slice.size==0?r.Slice.empty:new r.Slice(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new t(this.from,this.to+(e.to-e.from),o,this.structure)},t.prototype.toJSON=function(){var e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e},t.fromJSON=function(e,n){if("number"!=typeof n.from||"number"!=typeof n.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new t(n.from,n.to,r.Slice.fromJSON(e,n.slice),!!n.structure)},t}(h);h.jsonID("replace",v);var g=function(e){function t(t,n,r,o,i,s,a){e.call(this),this.from=t,this.to=n,this.gapFrom=r,this.gapTo=o,this.slice=i,this.insert=s,this.structure=!!a}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.apply=function(e){if(this.structure&&(y(e,this.from,this.gapFrom)||y(e,this.gapTo,this.to)))return m.fail("Structure gap-replace would overwrite content");var t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return m.fail("Gap is not a flat range");var n=this.slice.insertAt(this.insert,t.content);return n?m.fromReplace(e,this.from,this.to,n):m.fail("Content does not fit in gap")},t.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])},t.prototype.invert=function(e){var n=this.gapTo-this.gapFrom;return new t(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)},t.prototype.map=function(e){var n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),o=e.map(this.gapFrom,-1),i=e.map(this.gapTo,1);return n.deleted&&r.deleted||o<n.pos||i>r.pos?null:new t(n.pos,r.pos,o,i,this.slice,this.insert,this.structure)},t.prototype.toJSON=function(){var e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e},t.fromJSON=function(e,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 t(n.from,n.to,n.gapFrom,n.gapTo,r.Slice.fromJSON(e,n.slice),n.insert,!!n.structure)},t}(h);function y(e,t,n){for(var r=e.resolve(t),o=n-t,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(e,t,n){return(0==t||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function b(e){for(var t=e.parent.content.cutByIndex(e.startIndex,e.endIndex),n=e.depth;;--n){var r=e.$from.node(n),o=e.$from.index(n),i=e.$to.indexAfter(n);if(n<e.depth&&r.canReplace(o,i,t))return n;if(0==n||r.type.spec.isolating||!w(r,o,i))break}}function S(e,t,n,r){void 0===r&&(r=e);var o=function(e,t){var n=e.parent,r=e.startIndex,o=e.endIndex,i=n.contentMatchAt(r).findWrapping(t);if(!i)return null;var s=i.length?i[0]:t;return n.canReplaceWith(r,o,s)?i:null}(e,t),i=o&&function(e,t){var n=e.parent,r=e.startIndex,o=e.endIndex,i=n.child(r),s=t.contentMatch.findWrapping(i.type);if(!s)return null;for(var a=(s.length?s[s.length-1]:t).contentMatch,l=r;a&&l<o;l++)a=a.matchType(n.child(l).type);if(!a||!a.validEnd)return null;return s}(r,t);return i?o.map(k).concat({type:t,attrs:n}).concat(i.map(k)):null}function k(e){return{type:e,attrs:null}}function x(e,t,n,r){void 0===n&&(n=1);var o=e.resolve(t),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,l=n-2;a>i;a--,l--){var c=o.node(a),u=o.index(a);if(c.type.spec.isolating)return!1;var d=c.content.cutByIndex(u,c.childCount),p=r&&r[l]||c;if(p!=c&&(d=d.replaceChild(0,p.type.create(p.attrs))),!c.canReplace(u+1,c.childCount)||!p.type.validContent(d))return!1}var f=o.indexAfter(i),h=r&&r[0];return o.node(i).canReplaceWith(f,f,h?h.type:o.node(i+1).type)}function C(e,t){var n=e.resolve(t),r=n.index();return M(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function M(e,t){return e&&t&&!e.isLeaf&&e.canAppend(t)}function O(e,t,n){void 0===n&&(n=-1);for(var r=e.resolve(t),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 t;if(0==o)break;t=n<0?r.before(o):r.after(o)}}function T(e,t,n){var r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;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 A(e,t,n){var r=e.resolve(t);if(!n.content.size)return t;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 l=a==r.depth?0:r.pos<=(r.start(a+1)+r.end(a+1))/2?-1:1,c=r.index(a)+(l>0?1:0),u=r.node(a),d=!1;if(1==s)d=u.canReplace(c,c,o);else{var p=u.contentMatchAt(c).findWrapping(o.firstChild.type);d=p&&u.canReplaceWith(c,c,p[0])}if(d)return 0==l?r.pos:l<0?r.before(a+1):r.after(a+1)}return null}function N(e,t,n){for(var o=[],i=0;i<e.childCount;i++){var s=e.child(i);s.content.size&&(s=s.copy(N(s.content,t,s))),s.isInline&&(s=t(s,n,i)),o.push(s)}return r.Fragment.fromArray(o)}h.jsonID("replaceAround",g),u.prototype.lift=function(e,t){for(var n=e.$from,o=e.$to,i=e.depth,s=n.before(i+1),a=o.after(i+1),l=s,c=a,u=r.Fragment.empty,d=0,p=i,f=!1;p>t;p--)f||n.index(p)>0?(f=!0,u=r.Fragment.from(n.node(p).copy(u)),d++):l--;for(var h=r.Fragment.empty,m=0,v=i,y=!1;v>t;v--)y||o.after(v+1)<o.end(v)?(y=!0,h=r.Fragment.from(o.node(v).copy(h)),m++):c++;return this.step(new g(l,c,s,a,new r.Slice(u.append(h),d,m),u.size-d,!0))},u.prototype.wrap=function(e,t){for(var n=r.Fragment.empty,o=t.length-1;o>=0;o--){if(n.size){var i=t[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(t[o].type.create(t[o].attrs,n))}var s=e.start,a=e.end;return this.step(new g(s,a,s,a,new r.Slice(n,0,0),t.length,!0))},u.prototype.setBlockType=function(e,t,n,o){var i=this;if(void 0===t&&(t=e),!n.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");var s=this.steps.length;return this.doc.nodesBetween(e,t,(function(e,t){if(e.isTextblock&&!e.hasMarkup(n,o)&&function(e,t,n){var r=e.resolve(t),o=r.index();return r.parent.canReplaceWith(o,o+1,n)}(i.doc,i.mapping.slice(s).map(t),n)){i.clearIncompatible(i.mapping.slice(s).map(t,1),n);var a=i.mapping.slice(s),l=a.map(t,1),c=a.map(t+e.nodeSize,1);return i.step(new g(l,c,l+1,c-1,new r.Slice(r.Fragment.from(n.create(o,null,e.marks)),0,0),1,!0)),!1}})),this},u.prototype.setNodeMarkup=function(e,t,n,o){var i=this.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");t||(t=i.type);var s=t.create(n,null,o||i.marks);if(i.isLeaf)return this.replaceWith(e,e+i.nodeSize,s);if(!t.validContent(i.content))throw new RangeError("Invalid content for node type "+t.name);return this.step(new g(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new r.Slice(r.Fragment.from(s),0,0),1,!0))},u.prototype.split=function(e,t,n){void 0===t&&(t=1);for(var o=this.doc.resolve(e),i=r.Fragment.empty,s=r.Fragment.empty,a=o.depth,l=o.depth-t,c=t-1;a>l;a--,c--){i=r.Fragment.from(o.node(a).copy(i));var u=n&&n[c];s=r.Fragment.from(u?u.type.create(u.attrs,s):o.node(a).copy(s))}return this.step(new v(e,e,new r.Slice(i.append(s),t,t),!0))},u.prototype.join=function(e,t){void 0===t&&(t=1);var n=new v(e-t,e+t,r.Slice.empty,!0);return this.step(n)};var R=function(e){function t(t,n,r){e.call(this),this.from=t,this.to=n,this.mark=r}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.apply=function(e){var t=this,n=e.slice(this.from,this.to),o=e.resolve(this.from),i=o.node(o.sharedDepth(this.to)),s=new r.Slice(N(n.content,(function(e,n){return e.isAtom&&n.type.allowsMarkType(t.mark.type)?e.mark(t.mark.addToSet(e.marks)):e}),i),n.openStart,n.openEnd);return m.fromReplace(e,this.from,this.to,s)},t.prototype.invert=function(){return new D(this.from,this.to,this.mark)},t.prototype.map=function(e){var n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new t(n.pos,r.pos,this.mark)},t.prototype.merge=function(e){if(e instanceof t&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from)return new t(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark)},t.prototype.toJSON=function(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}},t.fromJSON=function(e,n){if("number"!=typeof n.from||"number"!=typeof n.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new t(n.from,n.to,e.markFromJSON(n.mark))},t}(h);h.jsonID("addMark",R);var D=function(e){function t(t,n,r){e.call(this),this.from=t,this.to=n,this.mark=r}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.apply=function(e){var t=this,n=e.slice(this.from,this.to),o=new r.Slice(N(n.content,(function(e){return e.mark(t.mark.removeFromSet(e.marks))})),n.openStart,n.openEnd);return m.fromReplace(e,this.from,this.to,o)},t.prototype.invert=function(){return new R(this.from,this.to,this.mark)},t.prototype.map=function(e){var n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new t(n.pos,r.pos,this.mark)},t.prototype.merge=function(e){if(e instanceof t&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from)return new t(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark)},t.prototype.toJSON=function(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}},t.fromJSON=function(e,n){if("number"!=typeof n.from||"number"!=typeof n.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new t(n.from,n.to,e.markFromJSON(n.mark))},t}(h);function E(e,t,n,o){if(void 0===n&&(n=t),void 0===o&&(o=r.Slice.empty),t==n&&!o.size)return null;var i=e.resolve(t),s=e.resolve(n);return z(i,s,o)?new v(t,n,o):new _(i,s,o).fit()}function z(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}h.jsonID("removeMark",D),u.prototype.addMark=function(e,t,n){var r=this,o=[],i=[],s=null,a=null;return this.doc.nodesBetween(e,t,(function(r,l,c){if(r.isInline){var u=r.marks;if(!n.isInSet(u)&&c.type.allowsMarkType(n.type)){for(var d=Math.max(l,e),p=Math.min(l+r.nodeSize,t),f=n.addToSet(u),h=0;h<u.length;h++)u[h].isInSet(f)||(s&&s.to==d&&s.mark.eq(u[h])?s.to=p:o.push(s=new D(d,p,u[h])));a&&a.to==d?a.to=p:i.push(a=new R(d,p,n))}}})),o.forEach((function(e){return r.step(e)})),i.forEach((function(e){return r.step(e)})),this},u.prototype.removeMark=function(e,t,n){var o=this;void 0===n&&(n=null);var i=[],s=0;return this.doc.nodesBetween(e,t,(function(o,a){if(o.isInline){s++;var l=null;if(n instanceof r.MarkType)for(var c,u=o.marks;c=n.isInSet(u);)(l||(l=[])).push(c),u=c.removeFromSet(u);else n?n.isInSet(o.marks)&&(l=[n]):l=o.marks;if(l&&l.length)for(var d=Math.min(a+o.nodeSize,t),p=0;p<l.length;p++){for(var f=l[p],h=void 0,m=0;m<i.length;m++){var v=i[m];v.step==s-1&&f.eq(i[m].style)&&(h=v)}h?(h.to=d,h.step=s):i.push({style:f,from:Math.max(a,e),to:d,step:s})}}})),i.forEach((function(e){return o.step(new D(e.from,e.to,e.style))})),this},u.prototype.clearIncompatible=function(e,t,n){void 0===n&&(n=t.contentMatch);for(var o=this.doc.nodeAt(e),i=[],s=e+1,a=0;a<o.childCount;a++){var l=o.child(a),c=s+l.nodeSize,u=n.matchType(l.type,l.attrs);if(u){n=u;for(var d=0;d<l.marks.length;d++)t.allowsMarkType(l.marks[d].type)||this.step(new D(s,c,l.marks[d]))}else i.push(new v(s,c,r.Slice.empty));s=c}if(!n.validEnd){var p=n.fillBefore(r.Fragment.empty,!0);this.replace(s,s,new r.Slice(p,0,0))}for(var f=i.length-1;f>=0;f--)this.step(i[f]);return this},u.prototype.replace=function(e,t,n){void 0===t&&(t=e),void 0===n&&(n=r.Slice.empty);var o=E(this.doc,e,t,n);return o&&this.step(o),this},u.prototype.replaceWith=function(e,t,n){return this.replace(e,t,new r.Slice(r.Fragment.from(n),0,0))},u.prototype.delete=function(e,t){return this.replace(e,t,r.Slice.empty)},u.prototype.insert=function(e,t){return this.replaceWith(e,e,t)};var _=function(e,t,n){this.$to=t,this.$from=e,this.unplaced=n,this.frontier=[];for(var o=0;o<=e.depth;o++){var i=e.node(o);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(o))})}this.placed=r.Fragment.empty;for(var s=e.depth;s>0;s--)this.placed=r.Fragment.from(e.node(s).copy(this.placed))},I={depth:{configurable:!0}};function P(e,t,n){return 0==t?e.cutByIndex(n):e.replaceChild(0,e.firstChild.copy(P(e.firstChild.content,t-1,n)))}function $(e,t,n){return 0==t?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy($(e.lastChild.content,t-1,n)))}function F(e,t){for(var n=0;n<t;n++)e=e.firstChild.content;return e}function B(e,t,n){if(t<=0)return e;var o=e.content;return t>1&&(o=o.replaceChild(0,B(o.firstChild,t-1,1==o.childCount?n-1:0))),t>0&&(o=e.type.contentMatch.fillBefore(o).append(o),n<=0&&(o=o.append(e.type.contentMatch.matchFragment(o).fillBefore(r.Fragment.empty,!0)))),e.copy(o)}function L(e,t,n,r,o){var i=e.node(t),s=o?e.indexAfter(t):e.index(t);if(s==i.childCount&&!n.compatibleContent(i.type))return null;var a=r.fillBefore(i.content,!0,s);return a&&!function(e,t,n){for(var r=n;r<t.childCount;r++)if(!e.allowsMarks(t.child(r).marks))return!0;return!1}(n,i.content,s)?a:null}function V(e){return e.spec.defining||e.spec.definingForContent}function j(e,t,n,o,i){if(t<n){var s=e.firstChild;e=e.replaceChild(0,s.copy(j(s.content,t+1,n,o,s)))}if(t>o){var a=i.contentMatchAt(0),l=a.fillBefore(e).append(e);e=l.append(a.matchFragment(l).fillBefore(r.Fragment.empty,!0))}return e}function K(e,t){for(var n=[],r=Math.min(e.depth,t.depth);r>=0;r--){var o=e.start(r);if(o<e.pos-(e.depth-r)||t.end(r)>t.pos+(t.depth-r)||e.node(r).type.spec.isolating||t.node(r).type.spec.isolating)break;(o==t.start(r)||r==e.depth&&r==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&r&&t.start(r-1)==o-1)&&n.push(r)}return n}I.depth.get=function(){return this.frontier.length-1},_.prototype.fit=function(){for(;this.unplaced.size;){var e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}var t=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,o=this.$from,i=this.close(t<0?this.$to:o.doc.resolve(t));if(!i)return null;for(var s=this.placed,a=o.depth,l=i.depth;a&&l&&1==s.childCount;)s=s.firstChild.content,a--,l--;var c=new r.Slice(s,a,l);return t>-1?new g(o.pos,t,this.$to.pos,this.$to.end(),c,n):c.size||o.pos!=this.$to.pos?new v(o.pos,i.pos,c):void 0},_.prototype.findFittable=function(){for(var e=1;e<=2;e++)for(var t=this.unplaced.openStart;t>=0;t--)for(var n=void 0,o=(t?(n=F(this.unplaced.content,t-1).firstChild).content:this.unplaced.content).firstChild,i=this.depth;i>=0;i--){var s=this.frontier[i],a=s.type,l=s.match,c=void 0,u=void 0;if(1==e&&(o?l.matchType(o.type)||(u=l.fillBefore(r.Fragment.from(o),!1)):a.compatibleContent(n.type)))return{sliceDepth:t,frontierDepth:i,parent:n,inject:u};if(2==e&&o&&(c=l.findWrapping(o.type)))return{sliceDepth:t,frontierDepth:i,parent:n,wrap:c};if(n&&l.matchType(n.type))break}},_.prototype.openMore=function(){var e=this.unplaced,t=e.content,n=e.openStart,o=e.openEnd,i=F(t,n);return!(!i.childCount||i.firstChild.isLeaf)&&(this.unplaced=new r.Slice(t,n+1,Math.max(o,i.size+n>=t.size-o?n+1:0)),!0)},_.prototype.dropNode=function(){var e=this.unplaced,t=e.content,n=e.openStart,o=e.openEnd,i=F(t,n);if(i.childCount<=1&&n>0){var s=t.size-n<=n+i.size;this.unplaced=new r.Slice(P(t,n-1,1),n-1,s?n-1:o)}else this.unplaced=new r.Slice(P(t,n,1),n,o)},_.prototype.placeNodes=function(e){for(var t=e.sliceDepth,n=e.frontierDepth,o=e.parent,i=e.inject,s=e.wrap;this.depth>n;)this.closeFrontierNode();if(s)for(var a=0;a<s.length;a++)this.openFrontierNode(s[a]);var l=this.unplaced,c=o?o.content:l.content,u=l.openStart-t,d=0,p=[],f=this.frontier[n],h=f.match,m=f.type;if(i){for(var v=0;v<i.childCount;v++)p.push(i.child(v));h=h.matchFragment(i)}for(var g=c.size+t-(l.content.size-l.openEnd);d<c.childCount;){var y=c.child(d),w=h.matchType(y.type);if(!w)break;(++d>1||0==u||y.content.size)&&(h=w,p.push(B(y.mark(m.allowedMarks(y.marks)),1==d?u:0,d==c.childCount?g:-1)))}var b=d==c.childCount;b||(g=-1),this.placed=$(this.placed,n,r.Fragment.from(p)),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=c;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==t?r.Slice.empty:new r.Slice(P(l.content,t-1,1),t-1,g<0?l.openEnd:t-1):new r.Slice(P(l.content,t,d),l.openStart,l.openEnd)},_.prototype.mustMoveInline=function(){if(!this.$to.parent.isTextblock)return-1;var e,t=this.frontier[this.depth];if(!t.type.isTextblock||!L(this.$to,this.$to.depth,t.type,t.match,!1)||this.$to.depth==this.depth&&(e=this.findCloseLevel(this.$to))&&e.depth==this.depth)return-1;for(var n=this.$to.depth,r=this.$to.after(n);n>1&&r==this.$to.end(--n);)++r;return r},_.prototype.findCloseLevel=function(e){e:for(var t=Math.min(this.depth,e.depth);t>=0;t--){var n=this.frontier[t],r=n.match,o=n.type,i=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),s=L(e,t,o,r,i);if(s){for(var a=t-1;a>=0;a--){var l=this.frontier[a],c=l.match,u=L(e,a,l.type,c,!0);if(!u||u.childCount)continue e}return{depth:t,fit:s,move:i?e.doc.resolve(e.after(t+1)):e}}}},_.prototype.close=function(e){var t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=$(this.placed,t.depth,t.fit)),e=t.move;for(var n=t.depth+1;n<=e.depth;n++){var r=e.node(n),o=r.type.contentMatch.fillBefore(r.content,!0,e.index(n));this.openFrontierNode(r.type,r.attrs,o)}return e},_.prototype.openFrontierNode=function(e,t,n){var o=this.frontier[this.depth];o.match=o.match.matchType(e),this.placed=$(this.placed,this.depth,r.Fragment.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})},_.prototype.closeFrontierNode=function(){var e=this.frontier.pop().match.fillBefore(r.Fragment.empty,!0);e.childCount&&(this.placed=$(this.placed,this.frontier.length,e))},Object.defineProperties(_.prototype,I),u.prototype.replaceRange=function(e,t,n){if(!n.size)return this.deleteRange(e,t);var o=this.doc.resolve(e),i=this.doc.resolve(t);if(z(o,i,n))return this.step(new v(e,t,n));var s=K(o,this.doc.resolve(t));0==s[s.length-1]&&s.pop();var a=-(o.depth+1);s.unshift(a);for(var l=o.depth,c=o.pos-1;l>0;l--,c--){var u=o.node(l).type.spec;if(u.defining||u.definingAsContext||u.isolating)break;s.indexOf(l)>-1?a=l:o.before(l)==c&&s.splice(1,0,-l)}for(var d=s.indexOf(a),p=[],f=n.openStart,h=n.content,m=0;;m++){var g=h.firstChild;if(p.push(g),m==n.openStart)break;h=g.content}for(var y=f-1;y>=0;y--){var w=p[y].type,b=V(w);if(b&&o.node(d).type!=w)f=y;else if(b||!w.isTextblock)break}for(var S=n.openStart;S>=0;S--){var k=(S+f+1)%(n.openStart+1),x=p[k];if(x)for(var C=0;C<s.length;C++){var M=s[(C+d)%s.length],O=!0;M<0&&(O=!1,M=-M);var T=o.node(M-1),A=o.index(M-1);if(T.canReplaceWith(A,A,x.type,x.marks))return this.replace(o.before(M),O?i.after(M):t,new r.Slice(j(n.content,0,n.openStart,k),k,n.openEnd))}}for(var N=this.steps.length,R=s.length-1;R>=0&&(this.replace(e,t,n),!(this.steps.length>N));R--){var D=s[R];D<0||(e=o.before(D),t=i.after(D))}return this},u.prototype.replaceRangeWith=function(e,t,n){if(!n.isInline&&e==t&&this.doc.resolve(e).parent.content.size){var o=T(this.doc,e,n.type);null!=o&&(e=t=o)}return this.replaceRange(e,t,new r.Slice(r.Fragment.from(n),0,0))},u.prototype.deleteRange=function(e,t){for(var n=this.doc.resolve(e),r=this.doc.resolve(t),o=K(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 l=1;l<=n.depth&&l<=r.depth;l++)if(e-n.start(l)==n.depth-l&&t>n.end(l)&&r.end(l)-t!=r.depth-l)return this.delete(n.before(l),t);return this.delete(e,t)}},function(e,t,n){"use strict";n.r(t),n.d(t,"Decoration",(function(){return At})),n.d(t,"DecorationSet",(function(){return Et})),n.d(t,"EditorView",(function(){return Kt})),n.d(t,"__endComposition",(function(){return yt})),n.d(t,"__parseFromClipboard",(function(){return Ve})),n.d(t,"__serializeForClipboard",(function(){return Le}));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),l=/MSIE \d/.test(navigator.userAgent),c=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),u=s.ie=!!(l||c||a);s.ie_version=l?document.documentMode||6:c?+c[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 d=!u&&/Chrome\/(\d+)/.exec(navigator.userAgent);s.chrome=!!d,s.chrome_version=d&&+d[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 p=function(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t},f=function(e){var t=e.assignedSlot||e.parentNode;return t&&11==t.nodeType?t.host:t},h=null,m=function(e,t,n){var r=h||(h=document.createRange());return r.setEnd(e,null==n?e.nodeValue.length:n),r.setStart(e,t||0),r},v=function(e,t,n,r){return n&&(y(e,t,n,r,-1)||y(e,t,n,r,1))},g=/^(img|br|input|textarea|hr)$/i;function y(e,t,n,r,o){for(;;){if(e==n&&t==r)return!0;if(t==(o<0?0:w(e))){var i=e.parentNode;if(!i||1!=i.nodeType||b(e)||g.test(e.nodeName)||"false"==e.contentEditable)return!1;t=p(e)+(o<0?0:1),e=i}else{if(1!=e.nodeType)return!1;if("false"==(e=e.childNodes[t+(o<0?-1:0)]).contentEditable)return!1;t=o<0?w(e):0}}}function w(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function b(e){for(var t,n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}var S=function(e){var t=e.isCollapsed;return t&&s.chrome&&e.rangeCount&&!e.getRangeAt(0).collapsed&&(t=!1),t};function k(e,t){var n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}function x(e){return{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function C(e,t){return"number"==typeof e?e:e[t]}function M(e){var t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function O(e,t,n){for(var r=e.someProp("scrollThreshold")||0,o=e.someProp("scrollMargin")||5,i=e.dom.ownerDocument,s=n||e.dom;s;s=f(s))if(1==s.nodeType){var a=s==i.body||1!=s.nodeType,l=a?x(i):M(s),c=0,u=0;if(t.top<l.top+C(r,"top")?u=-(l.top-t.top+C(o,"top")):t.bottom>l.bottom-C(r,"bottom")&&(u=t.bottom-l.bottom+C(o,"bottom")),t.left<l.left+C(r,"left")?c=-(l.left-t.left+C(o,"left")):t.right>l.right-C(r,"right")&&(c=t.right-l.right+C(o,"right")),c||u)if(a)i.defaultView.scrollBy(c,u);else{var d=s.scrollLeft,p=s.scrollTop;u&&(s.scrollTop+=u),c&&(s.scrollLeft+=c);var h=s.scrollLeft-d,m=s.scrollTop-p;t={left:t.left-h,top:t.top-m,right:t.right-h,bottom:t.bottom-m}}if(a)break}}function T(e){for(var t=[],n=e.ownerDocument;e&&(t.push({dom:e,top:e.scrollTop,left:e.scrollLeft}),e!=n);e=f(e));return t}function A(e,t){for(var n=0;n<e.length;n++){var r=e[n],o=r.dom,i=r.top,s=r.left;o.scrollTop!=i+t&&(o.scrollTop=i+t),o.scrollLeft!=s&&(o.scrollLeft=s)}}var N=null;function R(e,t){for(var n,r,o=2e8,i=0,s=t.top,a=t.top,l=e.firstChild,c=0;l;l=l.nextSibling,c++){var u=void 0;if(1==l.nodeType)u=l.getClientRects();else{if(3!=l.nodeType)continue;u=m(l).getClientRects()}for(var d=0;d<u.length;d++){var p=u[d];if(p.top<=s&&p.bottom>=a){s=Math.max(p.bottom,s),a=Math.min(p.top,a);var f=p.left>t.left?p.left-t.left:p.right<t.left?t.left-p.right:0;if(f<o){n=l,o=f,r=f&&3==n.nodeType?{left:p.right<t.left?p.right:p.left,top:t.top}:t,1==l.nodeType&&f&&(i=c+(t.left>=(p.left+p.right)/2?1:0));continue}}!n&&(t.left>=p.right&&t.top>=p.top||t.left>=p.left&&t.top>=p.bottom)&&(i=c+1)}}return n&&3==n.nodeType?function(e,t){for(var n=e.nodeValue.length,r=document.createRange(),o=0;o<n;o++){r.setEnd(e,o+1),r.setStart(e,o);var i=z(r,1);if(i.top!=i.bottom&&D(t,i))return{node:e,offset:o+(t.left>=(i.left+i.right)/2?1:0)}}return{node:e,offset:0}}(n,r):!n||o&&1==n.nodeType?{node:e,offset:i}:R(n,r)}function D(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function E(e,t){var n,r,o,i,a=e.dom.ownerDocument;if(a.caretPositionFromPoint)try{var l=a.caretPositionFromPoint(t.left,t.top);l&&(o=(n=l).offsetNode,i=n.offset)}catch(e){}if(!o&&a.caretRangeFromPoint){var c=a.caretRangeFromPoint(t.left,t.top);c&&(o=(r=c).startContainer,i=r.startOffset)}var u,d=(e.root.elementFromPoint?e.root:a).elementFromPoint(t.left,t.top+1);if(!d||!e.dom.contains(1!=d.nodeType?d.parentNode:d)){var p=e.dom.getBoundingClientRect();if(!D(t,p))return null;if(!(d=function e(t,n,r){var o=t.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=t.childNodes[s];if(1==a.nodeType)for(var l=a.getClientRects(),c=0;c<l.length;c++){var u=l[c];if(D(n,u))return e(a,n,u)}if((s=(s+1)%o)==i)break}return t}(e.dom,t,p)))return null}if(s.safari)for(var h=d;o&&h;h=f(h))h.draggable&&(o=i=null);if(d=function(e,t){var n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}(d,t),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<=t.left&&m.bottom>t.top&&i++}o==e.dom&&i==o.childNodes.length-1&&1==o.lastChild.nodeType&&t.top>o.lastChild.getBoundingClientRect().bottom?u=e.state.doc.content.size:0!=i&&1==o.nodeType&&"BR"==o.childNodes[i-1].nodeName||(u=function(e,t,n,r){for(var o=-1,i=t;i!=e.dom;){var s=e.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:e.docView.posFromDOM(t,n)}(e,o,i,t))}null==u&&(u=function(e,t,n){var r=R(t,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 e.docView.posFromDOM(o,i,s)}(e,d,t));var g=e.docView.nearestDesc(d,!0);return{pos:u,inside:g?g.posAtStart-g.border:-1}}function z(e,t){var n=e.getClientRects();return n.length?n[t<0?0:n.length-1]:e.getBoundingClientRect()}var _=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function I(e,t,n){var r=e.docView.domFromPos(t,n<0?-1:1),o=r.node,i=r.offset,a=s.webkit||s.gecko;if(3==o.nodeType){if(!a||!_.test(o.nodeValue)&&(n<0?i:i!=o.nodeValue.length)){var l=i,c=i,u=n<0?1:-1;return n<0&&!i?(c++,u=-1):n>=0&&i==o.nodeValue.length?(l--,u=1):n<0?l--:c++,P(z(m(o,l,c),u),u<0)}var d=z(m(o,i,i),n);if(s.gecko&&i&&/\s/.test(o.nodeValue[i-1])&&i<o.nodeValue.length){var p=z(m(o,i-1,i-1),-1);if(p.top==d.top){var f=z(m(o,i,i+1),-1);if(f.top!=d.top)return P(f,f.left<p.left)}}return d}if(!e.state.doc.resolve(t).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(z(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(z(S,-1),!0)}return P(z(3==o.nodeType?m(o):o,-n),n>=0)}function P(e,t){if(0==e.width)return e;var n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function $(e,t){if(0==e.height)return e;var n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function F(e,t,n){var r=e.state,o=e.root.activeElement;r!=t&&e.updateState(t),o!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),o!=e.dom&&o&&o.focus()}}var B=/[\u0590-\u08ac]/;var L=null,V=null,j=!1;function K(e,t,n){return L==t&&V==n?j:(L=t,V=n,j="up"==n||"down"==n?function(e,t,n){var r=t.selection,o="up"==n?r.$from:r.$to;return F(e,t,(function(){for(var t=e.docView.domFromPos(o.pos,"up"==n?-1:1).node;;){var r=e.docView.nearestDesc(t,!0);if(!r)break;if(r.node.isBlock){t=r.dom;break}t=r.dom.parentNode}for(var i=I(e,o.pos,1),s=t.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 l=0;l<a.length;l++){var c=a[l];if(c.bottom>c.top+1&&("up"==n?i.top-c.top>2*(c.bottom-i.top):c.bottom-i.bottom>2*(i.bottom-c.top)))return!1}}return!0}))}(e,t,n):function(e,t,n){var r=t.selection.$head;if(!r.parent.isTextblock)return!1;var o=r.parentOffset,i=!o,s=o==r.parent.content.size,a=e.root.getSelection();return B.test(r.parent.textContent)&&a.modify?F(e,t,(function(){var t=a.getRangeAt(0),o=a.focusNode,i=a.focusOffset,s=a.caretBidiLevel;a.modify("move",n,"character");var l=!(r.depth?e.docView.domAfterPos(r.before()):e.dom).contains(1==a.focusNode.nodeType?a.focusNode:a.focusNode.parentNode)||o==a.focusNode&&i==a.focusOffset;return a.removeAllRanges(),a.addRange(t),null!=s&&(a.caretBidiLevel=s),l})):"left"==n||"backward"==n?i:s}(e,t,n))}var H=function(e,t,n,r){this.parent=e,this.children=t,this.dom=n,n.pmViewDesc=this,this.contentDOM=r,this.dirty=0},W={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}};H.prototype.matchesWidget=function(){return!1},H.prototype.matchesMark=function(){return!1},H.prototype.matchesNode=function(){return!1},H.prototype.matchesHack=function(e){return!1},H.prototype.parseRule=function(){return null},H.prototype.stopEvent=function(){return!1},W.size.get=function(){for(var e=0,t=0;t<this.children.length;t++)e+=this.children[t].size;return e},W.border.get=function(){return 0},H.prototype.destroy=function(){this.parent=null,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=null);for(var e=0;e<this.children.length;e++)this.children[e].destroy()},H.prototype.posBeforeChild=function(e){for(var t=0,n=this.posAtStart;t<this.children.length;t++){var r=this.children[t];if(r==e)return n;n+=r.size}},W.posBefore.get=function(){return this.parent.posBeforeChild(this)},W.posAtStart.get=function(){return this.parent?this.parent.posBeforeChild(this)+this.border:0},W.posAfter.get=function(){return this.posBefore+this.size},W.posAtEnd.get=function(){return this.posAtStart+this.size-2*this.border},H.prototype.localPosFromDOM=function(e,t,n){if(this.contentDOM&&this.contentDOM.contains(1==e.nodeType?e:e.parentNode)){if(n<0){var r,o;if(e==this.contentDOM)r=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;r=e.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(e==this.contentDOM)i=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&(!(s=i.pmViewDesc)||s.parent!=this);)i=i.nextSibling;return i?this.posBeforeChild(s):this.posAtEnd}var a;if(e==this.dom&&this.contentDOM)a=t>p(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))a=2&e.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==t)for(var l=e;;l=l.parentNode){if(l==this.dom){a=!1;break}if(l.parentNode.firstChild!=l)break}if(null==a&&t==e.childNodes.length)for(var c=e;;c=c.parentNode){if(c==this.dom){a=!0;break}if(c.parentNode.lastChild!=c)break}}return(null==a?n>0:a)?this.posAtEnd:this.posAtStart},H.prototype.nearestDesc=function(e,t){for(var n=!0,r=e;r;r=r.parentNode){var o=this.getDesc(r);if(o&&(!t||o.node)){if(!n||!o.nodeDOM||(1==o.nodeDOM.nodeType?o.nodeDOM.contains(1==e.nodeType?e:e.parentNode):o.nodeDOM==e))return o;n=!1}}},H.prototype.getDesc=function(e){for(var t=e.pmViewDesc,n=t;n;n=n.parent)if(n==this)return t},H.prototype.posFromDOM=function(e,t,n){for(var r=e;r;r=r.parentNode){var o=this.getDesc(r);if(o)return o.localPosFromDOM(e,t,n)}return-1},H.prototype.descAt=function(e){for(var t=0,n=0;t<this.children.length;t++){var r=this.children[t],o=n+r.size;if(n==e&&o!=n){for(;!r.border&&r.children.length;)r=r.children[0];return r}if(e<o)return r.descAt(e-n-r.border);n=o}},H.prototype.domFromPos=function(e,t){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>e||i instanceof Z){r=e-o;break}o=s}if(r)return this.children[n].domFromPos(r-this.children[n].border,t);for(var a=void 0;n&&!(a=this.children[n-1]).size&&a instanceof J&&a.widget.type.side>=0;n--);if(t<=0){for(var l,c=!0;(l=n?this.children[n-1]:null)&&l.dom.parentNode!=this.contentDOM;n--,c=!1);return l&&t&&c&&!l.border&&!l.domAtom?l.domFromPos(l.size,t):{node:this.contentDOM,offset:l?p(l.dom)+1:0}}for(var u,d=!0;(u=n<this.children.length?this.children[n]:null)&&u.dom.parentNode!=this.contentDOM;n++,d=!1);return u&&d&&!u.border&&!u.domAtom?u.domFromPos(0,t):{node:this.contentDOM,offset:u?p(u.dom):this.contentDOM.childNodes.length}},H.prototype.parseRange=function(e,t,n){if(void 0===n&&(n=0),0==this.children.length)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};for(var r=-1,o=-1,i=n,s=0;;s++){var a=this.children[s],l=i+a.size;if(-1==r&&e<=l){var c=i+a.border;if(e>=c&&t<=l-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,c);e=i;for(var u=s;u>0;u--){var d=this.children[u-1];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(1)){r=p(d.dom)+1;break}e-=d.size}-1==r&&(r=0)}if(r>-1&&(l>t||s==this.children.length-1)){t=l;for(var f=s+1;f<this.children.length;f++){var h=this.children[f];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(-1)){o=p(h.dom);break}t+=h.size}-1==o&&(o=this.contentDOM.childNodes.length);break}i=l}return{node:this.contentDOM,from:e,to:t,fromOffset:r,toOffset:o}},H.prototype.emptyChildAt=function(e){if(this.border||!this.contentDOM||!this.children.length)return!1;var t=this.children[e<0?0:this.children.length-1];return 0==t.size||t.emptyChildAt(e)},H.prototype.domAfterPos=function(e){var t=this.domFromPos(e,0),n=t.node,r=t.offset;if(1!=n.nodeType||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]},H.prototype.setSelection=function(e,t,n,r){for(var o=Math.min(e,t),i=Math.max(e,t),a=0,l=0;a<this.children.length;a++){var c=this.children[a],u=l+c.size;if(o>l&&i<u)return c.setSelection(e-l-c.border,t-l-c.border,n,r);l=u}var d=this.domFromPos(e,e?-1:1),f=t==e?d:this.domFromPos(t,t?-1:1),h=n.getSelection(),m=!1;if((s.gecko||s.safari)&&e==t){var g=d.node,y=d.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&&(d=f={node:b.parentNode,offset:p(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!=f.node&&1==h.focusNode.nodeType){var x=h.focusNode.childNodes[h.focusOffset];x&&"false"==x.contentEditable&&(r=!0)}if(r||m&&s.safari||!v(d.node,d.offset,h.anchorNode,h.anchorOffset)||!v(f.node,f.offset,h.focusNode,h.focusOffset)){var C=!1;if((h.extend||e==t)&&!m){h.collapse(d.node,d.offset);try{e!=t&&h.extend(f.node,f.offset),C=!0}catch(e){if(!(e instanceof DOMException))throw e}}if(!C){if(e>t){var M=d;d=f,f=M}var O=document.createRange();O.setEnd(f.node,f.offset),O.setStart(d.node,d.offset),h.removeAllRanges(),h.addRange(O)}}},H.prototype.ignoreMutation=function(e){return!this.contentDOM&&"selection"!=e.type},W.contentLost.get=function(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)},H.prototype.markDirty=function(e,t){for(var n=0,r=0;r<this.children.length;r++){var o=this.children[r],i=n+o.size;if(n==i?e<=i&&t>=n:e<i&&t>n){var s=n+o.border,a=i-o.border;if(e>=s&&t<=a)return this.dirty=e==n||t==i?2:1,void(e!=s||t!=a||!o.contentLost&&o.dom.parentNode==this.contentDOM?o.markDirty(e-s,t-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},H.prototype.markParentsDirty=function(){for(var e=1,t=this.parent;t;t=t.parent,e++){var n=1==e?2:1;t.dirty<n&&(t.dirty=n)}},W.domAtom.get=function(){return!1},W.ignoreForCoords.get=function(){return!1},Object.defineProperties(H.prototype,W);var q=[],J=function(e){function t(t,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")}e.call(this,t,q,s,null),this.widget=n,i=this}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={domAtom:{configurable:!0}};return t.prototype.matchesWidget=function(e){return 0==this.dirty&&e.type.eq(this.widget.type)},t.prototype.parseRule=function(){return{ignore:!0}},t.prototype.stopEvent=function(e){var t=this.widget.spec.stopEvent;return!!t&&t(e)},t.prototype.ignoreMutation=function(e){return"selection"!=e.type||this.widget.spec.ignoreSelection},t.prototype.destroy=function(){this.widget.type.destroy(this.dom),e.prototype.destroy.call(this)},n.domAtom.get=function(){return!0},Object.defineProperties(t.prototype,n),t}(H),X=function(e){function t(t,n,r,o){e.call(this,t,q,n,null),this.textDOM=r,this.text=o}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={size:{configurable:!0}};return n.size.get=function(){return this.text.length},t.prototype.localPosFromDOM=function(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t},t.prototype.domFromPos=function(e){return{node:this.textDOM,offset:e}},t.prototype.ignoreMutation=function(e){return"characterData"===e.type&&e.target.nodeValue==e.oldValue},Object.defineProperties(t.prototype,n),t}(H),U=function(e){function t(t,n,r,o){e.call(this,t,[],r,o),this.mark=n}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.create=function(e,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 t(e,n,a.dom,a.contentDOM||a.dom)},t.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}},t.prototype.matchesMark=function(e){return 3!=this.dirty&&this.mark.eq(e)},t.prototype.markDirty=function(t,n){if(e.prototype.markDirty.call(this,t,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}},t.prototype.slice=function(e,n,r){var o=t.create(this.parent,this.mark,!0,r),i=this.children,s=this.size;n<s&&(i=de(i,n,s,r)),e>0&&(i=de(i,0,e,r));for(var a=0;a<i.length;a++)i[a].parent=o;return o.children=i,o},t}(H),Y=function(e){function t(t,n,r,o,i,s,a,l,c){e.call(this,t,n.isLeaf?q:[],i,s),this.nodeDOM=a,this.node=n,this.outerDeco=r,this.innerDeco=o,s&&this.updateChildren(l,c)}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={size:{configurable:!0},border:{configurable:!0},domAtom:{configurable:!0}};return t.create=function(e,n,r,i,s,a){var l,c,u=s.nodeViews[n.type.name],d=u&&u(n,s,(function(){return c?c.parent?c.parent.posBeforeChild(c):void 0:a}),r,i),p=d&&d.dom,f=d&&d.contentDOM;if(n.isText)if(p){if(3!=p.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else p=document.createTextNode(n.text);else p||(p=(l=o.DOMSerializer.renderSpec(document,n.type.spec.toDOM(n))).dom,f=l.contentDOM);f||n.isText||"BR"==p.nodeName||(p.hasAttribute("contenteditable")||(p.contentEditable=!1),n.type.spec.draggable&&(p.draggable=!0));var h=p;return p=se(p,r,n),d?c=new ee(e,n,r,i,p,f,h,d,s,a+1):n.isText?new Q(e,n,r,i,p,h,s):new t(e,n,r,i,p,f,h,s,a+1)},t.prototype.parseRule=function(){var e=this;if(this.node.type.spec.reparseInView)return null;var t={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(t.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)){t.contentElement=r.dom.parentNode;break}}t.contentElement||(t.getContent=function(){return o.Fragment.empty})}else t.contentElement=this.contentDOM;else t.getContent=function(){return e.node.content};return t},t.prototype.matchesNode=function(e,t,n){return 0==this.dirty&&e.eq(this.node)&&ae(t,this.outerDeco)&&n.eq(this.innerDeco)},n.size.get=function(){return this.node.nodeSize},n.border.get=function(){return this.node.isLeaf?0:1},t.prototype.updateChildren=function(e,t){var n=this,r=this.node.inlineContent,i=t,a=e.composing&&this.localCompositionInfo(e,t),l=a&&a.pos>-1?a:null,c=a&&a.pos<0,u=new ce(this,l&&l.node);!function(e,t,n,r){var o=t.locals(e),i=0;if(0==o.length){for(var s=0;s<e.childCount;s++){var a=e.child(s);r(a,o,t.forChild(i,a),s),i+=a.nodeSize}return}for(var l=0,c=[],u=null,d=0;;){if(l<o.length&&o[l].to==i){for(var p=o[l++],f=void 0;l<o.length&&o[l].to==i;)(f||(f=[p])).push(o[l++]);if(f){f.sort(ue);for(var h=0;h<f.length;h++)n(f[h],d,!!u)}else n(p,d,!!u)}var m=void 0,v=void 0;if(u)v=-1,m=u,u=null;else{if(!(d<e.childCount))break;v=d,m=e.child(d++)}for(var g=0;g<c.length;g++)c[g].to<=i&&c.splice(g--,1);for(;l<o.length&&o[l].from<=i&&o[l].to>i;)c.push(o[l++]);var y=i+m.nodeSize;if(m.isText){var w=y;l<o.length&&o[l].from<w&&(w=o[l].from);for(var b=0;b<c.length;b++)c[b].to<w&&(w=c[b].to);w<y&&(u=m.cut(w-i),m=m.cut(0,w-i),y=w,v=-1)}var S=c.length?m.isInline&&!m.isLeaf?c.filter((function(e){return!e.inline})):c.slice():q;r(m,S,t.forChild(i,m),v),i=y}}(this.node,this.innerDeco,(function(t,s,a){t.spec.marks?u.syncToMarks(t.spec.marks,r,e):t.type.side>=0&&!a&&u.syncToMarks(s==n.node.childCount?o.Mark.none:n.node.child(s).marks,r,e),u.placeWidget(t,e,i)}),(function(t,n,o,s){var l;u.syncToMarks(t.marks,r,e),u.findNodeMatch(t,n,o,s)||c&&e.state.selection.from>i&&e.state.selection.to<i+t.nodeSize&&(l=u.findIndexWithChild(a.node))>-1&&u.updateNodeAt(t,n,o,l,e)||u.updateNextNode(t,n,o,e,s)||u.addNode(t,n,o,e,i),i+=t.nodeSize})),u.syncToMarks(q,r,e),this.node.isTextblock&&u.addTextblockHacks(),u.destroyRest(),(u.changed||2==this.dirty)&&(l&&this.protectLocalComposition(e,l),function e(t,n,r){for(var o=t.firstChild,i=!1,s=0;s<n.length;s++){var a=n[s],l=a.dom;if(l.parentNode==t){for(;l!=o;)o=le(o),i=!0;o=o.nextSibling}else i=!0,t.insertBefore(l,o);if(a instanceof U){var c=o?o.previousSibling:t.lastChild;e(a.contentDOM,a.children,r),o=c?c.nextSibling:t.firstChild}}for(;o;)o=le(o),i=!0;i&&r.trackWrites==t&&(r.trackWrites=null)}(this.contentDOM,this.children,e),s.ios&&function(e){if("UL"==e.nodeName||"OL"==e.nodeName){var t=e.style.cssText;e.style.cssText=t+"; list-style: square !important",window.getComputedStyle(e).listStyle,e.style.cssText=t}}(this.dom))},t.prototype.localCompositionInfo=function(e,t){var n=e.state.selection,o=n.from,i=n.to;if(!(!(e.state.selection instanceof r.TextSelection)||o<t||i>t+this.node.content.size)){var s=e.root.getSelection(),a=function(e,t){for(;;){if(3==e.nodeType)return e;if(1==e.nodeType&&t>0){if(e.childNodes.length>t&&3==e.childNodes[t].nodeType)return e.childNodes[t];e=e.childNodes[t-1],t=w(e)}else{if(!(1==e.nodeType&&t<e.childNodes.length))return null;e=e.childNodes[t],t=0}}}(s.focusNode,s.focusOffset);if(a&&this.dom.contains(a.parentNode)){if(this.node.inlineContent){var l=a.nodeValue,c=function(e,t,n,r){for(var o=0,i=0;o<e.childCount&&i<=r;){var s=e.child(o++),a=i;if(i+=s.nodeSize,s.isText){for(var l=s.text;o<e.childCount;){var c=e.child(o++);if(i+=c.nodeSize,!c.isText)break;l+=c.text}if(i>=n){var u=a<r?l.lastIndexOf(t,r-a-1):-1;if(u>=0&&u+t.length+a>=n)return a+u;if(n==r&&l.length>=r+t.length-a&&l.slice(r-a,r-a+t.length)==t)return r}}}return-1}(this.node.content,l,o-t,i-t);return c<0?null:{node:a,pos:c,text:l}}return{node:a,pos:-1}}}},t.prototype.protectLocalComposition=function(e,t){var n=t.node,r=t.pos,o=t.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 X(this,i,n,o);e.compositionNodes.push(s),this.children=de(this.children,r,r+o.length,e,s)}},t.prototype.update=function(e,t,n,r){return!(3==this.dirty||!e.sameMarkup(this.node))&&(this.updateInner(e,t,n,r),!0)},t.prototype.updateInner=function(e,t,n,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=0},t.prototype.updateOuterDeco=function(e){if(!ae(e,this.outerDeco)){var t=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=oe(this.dom,this.nodeDOM,re(this.outerDeco,this.node,t),re(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=null,this.dom.pmViewDesc=this),this.outerDeco=e}},t.prototype.selectNode=function(){this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.dom.draggable=!0)},t.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(t.prototype,n),t}(H);function G(e,t,n,r,o){return se(r,t,e),new Y(null,e,t,n,r,r,r,o,0)}var Q=function(e){function t(t,n,r,o,i,s,a){e.call(this,t,n,r,o,i,null,s,a)}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={domAtom:{configurable:!0}};return t.prototype.parseRule=function(){for(var e=this.nodeDOM.parentNode;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}},t.prototype.update=function(e,t,n,r){return!(3==this.dirty||0!=this.dirty&&!this.inParent()||!e.sameMarkup(this.node))&&(this.updateOuterDeco(t),0==this.dirty&&e.text==this.node.text||e.text==this.nodeDOM.nodeValue||(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=0,!0)},t.prototype.inParent=function(){for(var e=this.parent.contentDOM,t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1},t.prototype.domFromPos=function(e){return{node:this.nodeDOM,offset:e}},t.prototype.localPosFromDOM=function(t,n,r){return t==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):e.prototype.localPosFromDOM.call(this,t,n,r)},t.prototype.ignoreMutation=function(e){return"characterData"!=e.type&&"selection"!=e.type},t.prototype.slice=function(e,n,r){var o=this.node.cut(e,n),i=document.createTextNode(o.text);return new t(this.parent,o,this.outerDeco,this.innerDeco,i,i,r)},t.prototype.markDirty=function(t,n){e.prototype.markDirty.call(this,t,n),this.dom==this.nodeDOM||0!=t&&n!=this.nodeDOM.nodeValue.length||(this.dirty=3)},n.domAtom.get=function(){return!1},Object.defineProperties(t.prototype,n),t}(Y),Z=function(e){function t(){e.apply(this,arguments)}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={domAtom:{configurable:!0},ignoreForCoords:{configurable:!0}};return t.prototype.parseRule=function(){return{ignore:!0}},t.prototype.matchesHack=function(e){return 0==this.dirty&&this.dom.nodeName==e},n.domAtom.get=function(){return!0},n.ignoreForCoords.get=function(){return"IMG"==this.dom.nodeName},Object.defineProperties(t.prototype,n),t}(H),ee=function(e){function t(t,n,r,o,i,s,a,l,c,u){e.call(this,t,n,r,o,i,s,a,c,u),this.spec=l}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.update=function(t,n,r,o){if(3==this.dirty)return!1;if(this.spec.update){var i=this.spec.update(t,n,r);return i&&this.updateInner(t,n,r,o),i}return!(!this.contentDOM&&!t.isLeaf)&&e.prototype.update.call(this,t,n,r,o)},t.prototype.selectNode=function(){this.spec.selectNode?this.spec.selectNode():e.prototype.selectNode.call(this)},t.prototype.deselectNode=function(){this.spec.deselectNode?this.spec.deselectNode():e.prototype.deselectNode.call(this)},t.prototype.setSelection=function(t,n,r,o){this.spec.setSelection?this.spec.setSelection(t,n,r):e.prototype.setSelection.call(this,t,n,r,o)},t.prototype.destroy=function(){this.spec.destroy&&this.spec.destroy(),e.prototype.destroy.call(this)},t.prototype.stopEvent=function(e){return!!this.spec.stopEvent&&this.spec.stopEvent(e)},t.prototype.ignoreMutation=function(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):e.prototype.ignoreMutation.call(this,t)},t}(Y);function te(e){e&&(this.nodeName=e)}te.prototype=Object.create(null);var ne=[new te];function re(e,t,n){if(0==e.length)return ne;for(var r=n?ne[0]:new te,o=[r],i=0;i<e.length;i++){var s=e[i].type.attrs;if(s)for(var a in s.nodeName&&o.push(r=new te(s.nodeName)),s){var l=s[a];null!=l&&(n&&1==o.length&&o.push(r=new te(t.isInline?"span":"div")),"class"==a?r.class=(r.class?r.class+" ":"")+l:"style"==a?r.style=(r.style?r.style+";":"")+l:"nodeName"!=a&&(r[a]=l))}}return o}function oe(e,t,n,r){if(n==ne&&r==ne)return t;for(var o=t,i=0;i<r.length;i++){var s=r[i],a=n[i];if(i){var l=void 0;a&&a.nodeName==s.nodeName&&o!=e&&(l=o.parentNode)&&l.tagName.toLowerCase()==s.nodeName||((l=document.createElement(s.nodeName)).pmIsDeco=!0,l.appendChild(o),a=ne[0]),o=l}ie(o,a||ne[0],s)}return o}function ie(e,t,n){for(var r in t)"class"==r||"style"==r||"nodeName"==r||r in n||e.removeAttribute(r);for(var o in n)"class"!=o&&"style"!=o&&"nodeName"!=o&&n[o]!=t[o]&&e.setAttribute(o,n[o]);if(t.class!=n.class){for(var i=t.class?t.class.split(" ").filter(Boolean):q,s=n.class?n.class.split(" ").filter(Boolean):q,a=0;a<i.length;a++)-1==s.indexOf(i[a])&&e.classList.remove(i[a]);for(var l=0;l<s.length;l++)-1==i.indexOf(s[l])&&e.classList.add(s[l]);0==e.classList.length&&e.removeAttribute("class")}if(t.style!=n.style){if(t.style)for(var c,u=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;c=u.exec(t.style);)e.style.removeProperty(c[1]);n.style&&(e.style.cssText+=n.style)}}function se(e,t,n){return oe(e,e,ne,re(t,n,1!=e.nodeType))}function ae(e,t){if(e.length!=t.length)return!1;for(var n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function le(e){var t=e.nextSibling;return e.parentNode.removeChild(e),t}var ce=function(e,t){this.top=e,this.lock=t,this.index=0,this.stack=[],this.changed=!1,this.preMatch=function(e,t){var n=t,r=n.children.length,o=e.childCount,i=new Map,s=[];e:for(;o>0;){for(var a=void 0;;)if(r){var l=n.children[r-1];if(!(l instanceof U)){a=l,r--;break}n=l,r=l.children.length}else{if(n==t)break e;r=n.parent.children.indexOf(n),n=n.parent}var c=a.node;if(c){if(c!=e.child(o-1))break;--o,i.set(a,o),s.push(a)}}return{index:o,matched:i,matches:s.reverse()}}(e.node.content,e)};function ue(e,t){return e.type.side-t.type.side}function de(e,t,n,r,o){for(var i=[],s=0,a=0;s<e.length;s++){var l=e[s],c=a,u=a+=l.size;c>=n||u<=t?i.push(l):(c<t&&i.push(l.slice(0,t-c,r)),o&&(i.push(o),o=null),u>n&&i.push(l.slice(n-c,l.size,r)))}return i}function pe(e,t){var n=e.root.getSelection(),o=e.state.doc;if(!n.focusNode)return null;var i=e.docView.nearestDesc(n.focusNode),s=i&&0==i.size,a=e.docView.posFromDOM(n.focusNode,n.focusOffset);if(a<0)return null;var l,c,u=o.resolve(a);if(S(n)){for(l=u;i&&!i.node;)i=i.parent;if(i&&i.node.isAtom&&r.NodeSelection.isSelectable(i.node)&&i.parent&&(!i.node.isInline||!function(e,t,n){for(var r=0==t,o=t==w(e);r||o;){if(e==n)return!0;var i=p(e);if(!(e=e.parentNode))return!1;r=r&&0==i,o=o&&i==w(e)}}(n.focusNode,n.focusOffset,i.dom))){var d=i.posBefore;c=new r.NodeSelection(a==d?u:o.resolve(d))}}else{var f=e.docView.posFromDOM(n.anchorNode,n.anchorOffset);if(f<0)return null;l=o.resolve(f)}c||(c=Se(e,l,u,"pointer"==t||e.state.selection.head<u.pos&&!s?1:-1));return c}function fe(e){return e.editable?e.hasFocus():ke(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function he(e,t){var n=e.state.selection;if(we(e,n),fe(e)){if(!t&&e.mouseDown&&e.mouseDown.allowDefault&&s.chrome){var o=e.root.getSelection(),i=e.domObserver.currentSelection;if(o.anchorNode&&v(o.anchorNode,o.anchorOffset,i.anchorNode,i.anchorOffset))return e.mouseDown.delayedSelectionSync=!0,void e.domObserver.setCurSelection()}if(e.domObserver.disconnectSelection(),e.cursorWrapper)!function(e){var t=e.root.getSelection(),n=document.createRange(),r=e.cursorWrapper.dom,o="IMG"==r.nodeName;o?n.setEnd(r.parentNode,p(r)+1):n.setEnd(r,0);n.collapse(!1),t.removeAllRanges(),t.addRange(n),!o&&!e.state.selection.visible&&s.ie&&s.ie_version<=11&&(r.disabled=!0,r.disabled=!1)}(e);else{var a,l,c=n.anchor,u=n.head;!me||n instanceof r.TextSelection||(n.$from.parent.inlineContent||(a=ve(e,n.from)),n.empty||n.$from.parent.inlineContent||(l=ve(e,n.to))),e.docView.setSelection(c,u,e.root,t),me&&(a&&ye(a),l&&ye(l)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(e){var t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.hideSelectionGuard);var n=e.root.getSelection(),r=n.anchorNode,o=n.anchorOffset;t.addEventListener("selectionchange",e.hideSelectionGuard=function(){n.anchorNode==r&&n.anchorOffset==o||(t.removeEventListener("selectionchange",e.hideSelectionGuard),setTimeout((function(){fe(e)&&!e.state.selection.visible||e.dom.classList.remove("ProseMirror-hideselection")}),20))})}(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}ce.prototype.destroyBetween=function(e,t){if(e!=t){for(var n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}},ce.prototype.destroyRest=function(){this.destroyBetween(this.index,this.top.children.length)},ce.prototype.syncToMarks=function(e,t,n){for(var r=0,o=this.stack.length>>1,i=Math.min(o,e.length);r<i&&(r==o-1?this.top:this.stack[r+1<<1]).matchesMark(e[r])&&!1!==e[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<e.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(e[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 l=U.create(this.top,e[o],t,n);this.top.children.splice(this.index,0,l),this.top=l,this.changed=!0}this.index=0,o++}},ce.prototype.findNodeMatch=function(e,t,n,r){var o,i=-1;if(r>=this.preMatch.index&&(o=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,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 l=this.top.children[s];if(l.matchesNode(e,t,n)&&!this.preMatch.matched.has(l)){i=s;break}}return!(i<0)&&(this.destroyBetween(this.index,i),this.index++,!0)},ce.prototype.updateNodeAt=function(e,t,n,r,o){return!!this.top.children[r].update(e,t,n,o)&&(this.destroyBetween(this.index,r),this.index=r+1,!0)},ce.prototype.findIndexWithChild=function(e){for(;;){var t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){var n=e.pmViewDesc;if(n)for(var r=this.index;r<this.top.children.length;r++)if(this.top.children[r]==n)return r;return-1}e=t}},ce.prototype.updateNextNode=function(e,t,n,r,o){for(var i=this.index;i<this.top.children.length;i++){var s=this.top.children[i];if(s instanceof Y){var a=this.preMatch.matched.get(s);if(null!=a&&a!=o)return!1;var l=s.dom;if(!(this.lock&&(l==this.lock||1==l.nodeType&&l.contains(this.lock.parentNode))&&!(e.isText&&s.node&&s.node.isText&&s.nodeDOM.nodeValue==e.text&&3!=s.dirty&&ae(t,s.outerDeco)))&&s.update(e,t,n,r))return this.destroyBetween(this.index,i),s.dom!=l&&(this.changed=!0),this.index++,!0;break}}return!1},ce.prototype.addNode=function(e,t,n,r,o){this.top.children.splice(this.index++,0,Y.create(this.top,e,t,n,r,o)),this.changed=!0},ce.prototype.placeWidget=function(e,t,n){var r=this.index<this.top.children.length?this.top.children[this.index]:null;if(!r||!r.matchesWidget(e)||e!=r.widget&&r.widget.type.toDOM.parentNode){var o=new J(this.top,e,t,n);this.top.children.splice(this.index++,0,o),this.changed=!0}else this.index++},ce.prototype.addTextblockHacks=function(){for(var e=this.top.children[this.index-1];e instanceof U;)e=e.children[e.children.length-1];e&&e instanceof Q&&!/\n$/.test(e.node.text)||((s.safari||s.chrome)&&e&&"false"==e.dom.contentEditable&&this.addHackNode("IMG"),this.addHackNode("BR"))},ce.prototype.addHackNode=function(e){if(this.index<this.top.children.length&&this.top.children[this.index].matchesHack(e))this.index++;else{var t=document.createElement(e);"IMG"==e&&(t.className="ProseMirror-separator",t.alt=""),"BR"==e&&(t.className="ProseMirror-trailingBreak"),this.top.children.splice(this.index++,0,new Z(this.top,q,t,null)),this.changed=!0}};var me=s.safari||s.chrome&&s.chrome_version<63;function ve(e,t){var n=e.docView.domFromPos(t,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 ge(i);if(!(i&&"false"!=i.contentEditable||a&&"false"!=a.contentEditable)){if(i)return ge(i);if(a)return ge(a)}}function ge(e){return e.contentEditable="true",s.safari&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function ye(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function we(e,t){if(t instanceof r.NodeSelection){var n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(be(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else be(e)}function be(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=null)}function Se(e,t,n,o){return e.someProp("createSelectionBetween",(function(r){return r(e,t,n)}))||r.TextSelection.between(t,n,o)}function ke(e){var t=e.root.getSelection();if(!t.anchorNode)return!1;try{return e.dom.contains(3==t.anchorNode.nodeType?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(3==t.focusNode.nodeType?t.focusNode.parentNode:t.focusNode))}catch(e){return!1}}function xe(e,t){var n=e.selection,o=n.$anchor,i=n.$head,s=t>0?o.max(i):o.min(i),a=s.parent.inlineContent?s.depth?e.doc.resolve(t>0?s.after():s.before()):null:s;return a&&r.Selection.findFrom(a,t)}function Ce(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function Me(e,t,n){var o=e.state.selection;if(!(o instanceof r.TextSelection)){if(o instanceof r.NodeSelection&&o.node.isInline)return Ce(e,new r.TextSelection(t>0?o.$to:o.$from));var i=xe(e.state,t);return!!i&&Ce(e,i)}if(!o.empty||n.indexOf("s")>-1)return!1;if(e.endOfTextblock(t>0?"right":"left")){var a=xe(e.state,t);return!!(a&&a instanceof r.NodeSelection)&&Ce(e,a)}if(!(s.mac&&n.indexOf("m")>-1)){var l,c=o.$head,u=c.textOffset?null:t<0?c.nodeBefore:c.nodeAfter;if(!u||u.isText)return!1;var d=t<0?c.pos-u.nodeSize:c.pos;return!!(u.isAtom||(l=e.docView.descAt(d))&&!l.contentDOM)&&(r.NodeSelection.isSelectable(u)?Ce(e,new r.NodeSelection(t<0?e.state.doc.resolve(c.pos-u.nodeSize):c)):!!s.webkit&&Ce(e,new r.TextSelection(e.state.doc.resolve(t<0?d:d+u.nodeSize))))}}function Oe(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function Te(e){var t=e.pmViewDesc;return t&&0==t.size&&(e.nextSibling||"BR"!=e.nodeName)}function Ae(e){var t=e.root.getSelection(),n=t.focusNode,r=t.focusOffset;if(n){var o,i,a=!1;for(s.gecko&&1==n.nodeType&&r<Oe(n)&&Te(n.childNodes[r])&&(a=!0);;)if(r>0){if(1!=n.nodeType)break;var l=n.childNodes[r-1];if(Te(l))o=n,i=--r;else{if(3!=l.nodeType)break;r=(n=l).nodeValue.length}}else{if(Re(n))break;for(var c=n.previousSibling;c&&Te(c);)o=n.parentNode,i=p(c),c=c.previousSibling;if(c)r=Oe(n=c);else{if((n=n.parentNode)==e.dom)break;r=0}}a?De(e,t,n,r):o&&De(e,t,o,i)}}function Ne(e){var t=e.root.getSelection(),n=t.focusNode,r=t.focusOffset;if(n){for(var o,i,s=Oe(n);;)if(r<s){if(1!=n.nodeType)break;if(!Te(n.childNodes[r]))break;o=n,i=++r}else{if(Re(n))break;for(var a=n.nextSibling;a&&Te(a);)o=a.parentNode,i=p(a)+1,a=a.nextSibling;if(a)r=0,s=Oe(n=a);else{if((n=n.parentNode)==e.dom)break;r=s=0}}o&&De(e,t,o,i)}}function Re(e){var t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function De(e,t,n,r){if(S(t)){var o=document.createRange();o.setEnd(n,r),o.setStart(n,r),t.removeAllRanges(),t.addRange(o)}else t.extend&&t.extend(n,r);e.domObserver.setCurSelection();var i=e.state;setTimeout((function(){e.state==i&&he(e)}),50)}function Ee(e,t,n){var o=e.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||e.endOfTextblock(t<0?"up":"down")){var l=xe(e.state,t);if(l&&l instanceof r.NodeSelection)return Ce(e,l)}if(!i.parent.inlineContent){var c=t<0?i:a,u=o instanceof r.AllSelection?r.Selection.near(c,t):r.Selection.findFrom(c,t);return!!u&&Ce(e,u)}return!1}function ze(e,t){if(!(e.state.selection instanceof r.TextSelection))return!0;var n=e.state.selection,o=n.$head,i=n.$anchor,s=n.empty;if(!o.sameParent(i))return!0;if(!s)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;var a=!o.textOffset&&(t<0?o.nodeBefore:o.nodeAfter);if(a&&!a.isText){var l=e.state.tr;return t<0?l.delete(o.pos-a.nodeSize,o.pos):l.delete(o.pos,o.pos+a.nodeSize),e.dispatch(l),!0}return!1}function _e(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function Ie(e,t){var n=t.keyCode,r=function(e){var t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}(t);return 8==n||s.mac&&72==n&&"c"==r?ze(e,-1)||Ae(e):46==n||s.mac&&68==n&&"c"==r?ze(e,1)||Ne(e):13==n||27==n||(37==n?Me(e,-1,r)||Ae(e):39==n?Me(e,1,r)||Ne(e):38==n?Ee(e,-1,r)||Ae(e):40==n?function(e){if(s.safari&&!(e.state.selection.$head.parentOffset>0)){var t=e.root.getSelection(),n=t.focusNode,r=t.focusOffset;if(n&&1==n.nodeType&&0==r&&n.firstChild&&"false"==n.firstChild.contentEditable){var o=n.firstChild;_e(e,o,!0),setTimeout((function(){return _e(e,o,!1)}),20)}}}(e)||Ee(e,1,r)||Ne(e):r==(s.mac?"m":"c")&&(66==n||73==n||89==n||90==n))}function Pe(e){var t=e.pmViewDesc;if(t)return t.parseRule();if("BR"==e.nodeName&&e.parentNode){if(s.safari&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){var n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}if(e.parentNode.lastChild==e||s.safari&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if("IMG"==e.nodeName&&e.getAttribute("mark-placeholder"))return{ignore:!0}}function $e(e,t,n,i,a){if(t<0){var l=e.lastSelectionTime>Date.now()-50?e.lastSelectionOrigin:null,c=pe(e,l);if(c&&!e.state.selection.eq(c)){var u=e.state.tr.setSelection(c);"pointer"==l?u.setMeta("pointer",!0):"key"==l&&u.scrollIntoView(),e.dispatch(u)}}else{var d=e.state.doc.resolve(t),p=d.sharedDepth(n);t=d.before(p+1),n=e.state.doc.resolve(n).after(p+1);var f=e.state.selection,h=function(e,t,n){var r=e.docView.parseRange(t,n),i=r.node,a=r.fromOffset,l=r.toOffset,c=r.from,u=r.to,d=e.root.getSelection(),p=null,f=d.anchorNode;if(f&&e.dom.contains(1==f.nodeType?f:f.parentNode)&&(p=[{node:f,offset:d.anchorOffset}],S(d)||p.push({node:d.focusNode,offset:d.focusOffset})),s.chrome&&8===e.lastKeyCode)for(var h=l;h>a;h--){var m=i.childNodes[h-1],v=m.pmViewDesc;if("BR"==m.nodeName&&!v){l=h;break}if(!v||v.size)break}var g=e.state.doc,y=e.someProp("domParser")||o.DOMParser.fromSchema(e.state.schema),w=g.resolve(c),b=null,k=y.parse(i,{topNode:w.parent,topMatch:w.parent.contentMatchAt(w.index()),topOpen:!0,from:a,to:l,preserveWhitespace:"pre"!=w.parent.type.whitespace||"full",editableContent:!0,findPositions:p,ruleFromNode:Pe,context:w});if(p&&null!=p[0].pos){var x=p[0].pos,C=p[1]&&p[1].pos;null==C&&(C=x),b={anchor:x+c,head:C+c}}return{doc:k,sel:b,from:c,to:u}}(e,t,n);if(s.chrome&&e.cursorWrapper&&h.sel&&h.sel.anchor==e.cursorWrapper.deco.from){var m=e.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=e.state.doc,b=w.slice(h.from,h.to);8===e.lastKeyCode&&Date.now()-100<e.lastKeyCodeTime?(g=e.state.selection.to,y="end"):(g=e.state.selection.from,y="start"),e.lastKeyCode=null;var x=function(e,t,n,r,o){var i=e.findDiffStart(t,n);if(null==i)return null;var s=e.findDiffEnd(t,n+e.size,n+t.size),a=s.a,l=s.b;if("end"==o){var c=Math.max(0,i-Math.min(a,l));r-=a+c-i}if(a<i&&e.size<t.size){l=(i-=r<=i&&r>=a?i-r:0)+(l-a),a=i}else if(l<i){a=(i-=r<=i&&r>=l?i-r:0)+(a-l),l=i}return{start:i,endA:a,endB:l}}(b.content,h.doc.content,h.from,g,y);if((s.ios&&e.lastIOSEnter>Date.now()-225||s.android)&&a.some((function(e){return"DIV"==e.nodeName||"P"==e.nodeName}))&&(!x||x.endA>=x.endB)&&e.someProp("handleKeyDown",(function(t){return t(e,k(13,"Enter"))})))e.lastIOSEnter=0;else{if(!x){if(!(i&&f instanceof r.TextSelection&&!f.empty&&f.$head.sameParent(f.$anchor))||e.composing||h.sel&&h.sel.anchor!=h.sel.head){if(h.sel){var C=Fe(e,e.state.doc,h.sel);C&&!C.eq(e.state.selection)&&e.dispatch(e.state.tr.setSelection(C))}return}x={start:f.from,endA:f.to,endB:f.to}}e.domChangeCount++,e.state.selection.from<e.state.selection.to&&x.start==x.endB&&e.state.selection instanceof r.TextSelection&&(x.start>e.state.selection.from&&x.start<=e.state.selection.from+2&&e.state.selection.from>=h.from?x.start=e.state.selection.from:x.endA<e.state.selection.to&&x.endA>=e.state.selection.to-2&&e.state.selection.to<=h.to&&(x.endB+=e.state.selection.to-x.endA,x.endA=e.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),A=O.sameParent(T)&&O.parent.inlineContent;if((s.ios&&e.lastIOSEnter>Date.now()-225&&(!A||a.some((function(e){return"DIV"==e.nodeName||"P"==e.nodeName})))||!A&&O.pos<h.doc.content.size&&(M=r.Selection.findFrom(h.doc.resolve(O.pos+1),1,!0))&&M.head==T.pos)&&e.someProp("handleKeyDown",(function(t){return t(e,k(13,"Enter"))})))e.lastIOSEnter=0;else if(e.state.selection.anchor>x.start&&function(e,t,n,r,o){if(!r.parent.isTextblock||n-t<=o.pos-r.pos||Be(r,!0,!1)<o.pos)return!1;var i=e.resolve(t);if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;var s=e.resolve(Be(i,!0,!0));if(!s.parent.isTextblock||s.pos>n||Be(s,!0,!1)<n)return!1;return r.parent.content.cut(r.parentOffset).eq(s.parent.content)}(w,x.start,x.endA,O,T)&&e.someProp("handleKeyDown",(function(t){return t(e,k(8,"Backspace"))})))s.android&&s.chrome&&e.domObserver.suppressSelectionUpdates();else{s.chrome&&s.android&&x.toB==x.from&&(e.lastAndroidDelete=Date.now()),s.android&&!A&&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(){e.someProp("handleKeyDown",(function(t){return t(e,k(13,"Enter"))}))}),20));var N,R,D,E,z=x.start,_=x.endA;if(A)if(O.pos==T.pos)s.ie&&s.ie_version<=11&&0==O.parentOffset&&(e.domObserver.suppressSelectionUpdates(),setTimeout((function(){return he(e)}),20)),N=e.state.tr.delete(z,_),R=w.resolve(x.start).marksAcross(w.resolve(x.endA));else if(x.endA==x.endB&&(E=w.resolve(x.start))&&(D=function(e,t){for(var n,r,i,s=e.firstChild.marks,a=t.firstChild.marks,l=s,c=a,u=0;u<a.length;u++)l=a[u].removeFromSet(l);for(var d=0;d<s.length;d++)c=s[d].removeFromSet(c);if(1==l.length&&0==c.length)r=l[0],n="add",i=function(e){return e.mark(r.addToSet(e.marks))};else{if(0!=l.length||1!=c.length)return null;r=c[0],n="remove",i=function(e){return e.mark(r.removeFromSet(e.marks))}}for(var p=[],f=0;f<t.childCount;f++)p.push(i(t.child(f)));if(o.Fragment.from(p).eq(e))return{mark:r,type:n}}(O.parent.content.cut(O.parentOffset,T.parentOffset),E.parent.content.cut(E.parentOffset,x.endA-E.start()))))N=e.state.tr,"add"==D.type?N.addMark(z,_,D.mark):N.removeMark(z,_,D.mark);else if(O.parent.child(O.index()).isText&&O.index()==T.index()-(T.textOffset?0:1)){var I=O.parent.textBetween(O.parentOffset,T.parentOffset);if(e.someProp("handleTextInput",(function(t){return t(e,z,_,I)})))return;N=e.state.tr.insertText(I,z,_)}if(N||(N=e.state.tr.replace(z,_,h.doc.slice(x.start-h.from,x.endB-h.from))),h.sel){var P=Fe(e,N.doc,h.sel);P&&!(s.chrome&&s.android&&e.composing&&P.empty&&(x.start!=x.endB||e.lastAndroidDelete<Date.now()-100)&&(P.head==z||P.head==N.mapping.map(_)-1)||s.ie&&P.empty&&P.head==z)&&N.setSelection(P)}R&&N.ensureMarks(R),e.dispatch(N.scrollIntoView())}}}}function Fe(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:Se(e,t.resolve(n.anchor),t.resolve(n.head))}function Be(e,t,n){for(var r=e.depth,o=t?e.end():e.pos;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,o++,t=!1;if(n)for(var i=e.node(r).maybeChild(e.indexAfter(r));i&&!i.isLeaf;)i=i.firstChild,o++;return o}function Le(e,t){for(var n=[],r=t.content,i=t.openStart,s=t.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 l=e.someProp("clipboardSerializer")||o.DOMSerializer.fromSchema(e.state.schema),c=Xe(),u=c.createElement("div");u.appendChild(l.serializeFragment(r,{document:c}));for(var d,p=u.firstChild;p&&1==p.nodeType&&(d=qe[p.nodeName.toLowerCase()]);){for(var f=d.length-1;f>=0;f--){for(var h=c.createElement(d[f]);u.firstChild;)h.appendChild(u.firstChild);u.appendChild(h),"tbody"!=d[f]&&(i++,s++)}p=u.firstChild}return p&&1==p.nodeType&&p.setAttribute("data-pm-slice",i+" "+s+" "+JSON.stringify(n)),{dom:u,text:e.someProp("clipboardTextSerializer",(function(e){return e(t)}))||t.content.textBetween(0,t.content.size,"\n\n")}}function Ve(e,t,n,r,i){var a,l,c=i.parent.type.spec.code;if(!n&&!t)return null;var u=t&&(r||c||!n);if(u){if(e.someProp("transformPastedText",(function(e){t=e(t,c||r)})),c)return t?new o.Slice(o.Fragment.from(e.state.schema.text(t.replace(/\r\n?/g,"\n"))),0,0):o.Slice.empty;var d=e.someProp("clipboardTextParser",(function(e){return e(t,i,r)}));if(d)l=d;else{var p=i.marks(),f=e.state.schema,h=o.DOMSerializer.fromSchema(f);a=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach((function(e){var t=a.appendChild(document.createElement("p"));e&&t.appendChild(h.serializeNode(f.text(e,p)))}))}}else e.someProp("transformPastedHTML",(function(e){n=e(n)})),a=function(e){var t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));var n,r=Xe().createElement("div"),o=/<([a-z][^>\s]+)/i.exec(e);(n=o&&qe[o[1].toLowerCase()])&&(e=n.map((function(e){return"<"+e+">"})).join("")+e+n.map((function(e){return"</"+e+">"})).reverse().join(""));if(r.innerHTML=e,n)for(var i=0;i<n.length;i++)r=r.querySelector(n[i])||r;return r}(n),s.webkit&&function(e){for(var t=e.querySelectorAll(s.chrome?"span:not([class]):not([style])":"span.Apple-converted-space"),n=0;n<t.length;n++){var r=t[n];1==r.childNodes.length&&" "==r.textContent&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),r)}}(a);var m=a&&a.querySelector("[data-pm-slice]"),v=m&&/^(\d+) (\d+) (.*)/.exec(m.getAttribute("data-pm-slice"));if(!l){var g=e.someProp("clipboardParser")||e.someProp("domParser")||o.DOMParser.fromSchema(e.state.schema);l=g.parseSlice(a,{preserveWhitespace:!(!u&&!v),context:i,ruleFromNode:function(e){if("BR"==e.nodeName&&!e.nextSibling&&e.parentNode&&!je.test(e.parentNode.nodeName))return{ignore:!0}}})}if(v)l=function(e,t){if(!e.size)return e;var n,r=e.content.firstChild.type.schema;try{n=JSON.parse(t)}catch(t){return e}for(var i=e.content,s=e.openStart,a=e.openEnd,l=n.length-2;l>=0;l-=2){var c=r.nodes[n[l]];if(!c||c.hasRequiredAttrs())break;i=o.Fragment.from(c.create(n[l+1],i)),s++,a++}return new o.Slice(i,s,a)}(We(l,+v[1],+v[2]),v[3]);else if((l=o.Slice.maxOpen(function(e,t){if(e.childCount<2)return e;for(var n=function(n){var r=t.node(n).contentMatchAt(t.index(n)),i=void 0,s=[];if(e.forEach((function(e){if(s){var t,n=r.findWrapping(e.type);if(!n)return s=null;if(t=s.length&&i.length&&function e(t,n,r,i,s){if(s<t.length&&s<n.length&&t[s]==n[s]){var a=e(t,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==t.length-1?r.type:t[s+1]))return i.copy(i.content.append(o.Fragment.from(Ke(r,t,s+1))))}}(n,i,e,s[s.length-1],0))s[s.length-1]=t;else{s.length&&(s[s.length-1]=function e(t,n){if(0==n)return t;var r=t.content.replaceChild(t.childCount-1,e(t.lastChild,n-1)),i=t.contentMatchAt(t.childCount).fillBefore(o.Fragment.empty,!0);return t.copy(r.append(i))}(s[s.length-1],i.length));var a=Ke(e,n);s.push(a),r=r.matchType(a.type,a.attrs),i=n}}})),s)return{v:o.Fragment.from(s)}},r=t.depth;r>=0;r--){var i=n(r);if(i)return i.v}return e}(l.content,i),!0)).openStart||l.openEnd){for(var y=0,w=0,b=l.content.firstChild;y<l.openStart&&!b.type.spec.isolating;y++,b=b.firstChild);for(var S=l.content.lastChild;w<l.openEnd&&!S.type.spec.isolating;w++,S=S.lastChild);l=We(l,y,w)}return e.someProp("transformPasted",(function(e){l=e(l)})),l}var je=/^(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 Ke(e,t,n){void 0===n&&(n=0);for(var r=t.length-1;r>=n;r--)e=t[r].create(null,o.Fragment.from(e));return e}function He(e,t,n,r,i,s){var a=t<0?e.firstChild:e.lastChild,l=a.content;return i<r-1&&(l=He(l,t,n,r,i+1,s)),i>=n&&(l=t<0?a.contentMatchAt(0).fillBefore(l,e.childCount>1||s<=i).append(l):l.append(a.contentMatchAt(a.childCount).fillBefore(o.Fragment.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,a.copy(l))}function We(e,t,n){return t<e.openStart&&(e=new o.Slice(He(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new o.Slice(He(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}var qe={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]},Je=null;function Xe(){return Je||(Je=document.implementation.createHTMLDocument("title"))}var Ue={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Ye=s.ie&&s.ie_version<=11,Ge=function(){this.anchorNode=this.anchorOffset=this.focusNode=this.focusOffset=null};Ge.prototype.set=function(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset},Ge.prototype.eq=function(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset};var Qe=function(e,t){var n=this;this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=window.MutationObserver&&new window.MutationObserver((function(e){for(var t=0;t<e.length;t++)n.queue.push(e[t]);s.ie&&s.ie_version<=11&&e.some((function(e){return"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length}))?n.flushSoon():n.flush()})),this.currentSelection=new Ge,Ye&&(this.onCharData=function(e){n.queue.push({target:e.target,type:"characterData",oldValue:e.prevValue}),n.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.suppressingSelectionUpdates=!1};Qe.prototype.flushSoon=function(){var e=this;this.flushingSoon<0&&(this.flushingSoon=window.setTimeout((function(){e.flushingSoon=-1,e.flush()}),20))},Qe.prototype.forceFlush=function(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())},Qe.prototype.start=function(){this.observer&&this.observer.observe(this.view.dom,Ue),Ye&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()},Qe.prototype.stop=function(){var e=this;if(this.observer){var t=this.observer.takeRecords();if(t.length){for(var n=0;n<t.length;n++)this.queue.push(t[n]);window.setTimeout((function(){return e.flush()}),20)}this.observer.disconnect()}Ye&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()},Qe.prototype.connectSelection=function(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)},Qe.prototype.disconnectSelection=function(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)},Qe.prototype.suppressSelectionUpdates=function(){var e=this;this.suppressingSelectionUpdates=!0,setTimeout((function(){return e.suppressingSelectionUpdates=!1}),50)},Qe.prototype.onSelectionChange=function(){if((!(e=this.view).editable||e.root.activeElement==e.dom)&&ke(e)){var e;if(this.suppressingSelectionUpdates)return he(this.view);if(s.ie&&s.ie_version<=11&&!this.view.state.selection.empty){var t=this.view.root.getSelection();if(t.focusNode&&v(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset))return this.flushSoon()}this.flush()}},Qe.prototype.setCurSelection=function(){this.currentSelection.set(this.view.root.getSelection())},Qe.prototype.ignoreSelectionChange=function(e){if(0==e.rangeCount)return!0;var t=e.getRangeAt(0).commonAncestorContainer,n=this.view.docView.nearestDesc(t);return n&&n.ignoreMutation({type:"selection",target:3==t.nodeType?t.parentNode:t})?(this.setCurSelection(),!0):void 0},Qe.prototype.flush=function(){if(this.view.docView&&!(this.flushingSoon>-1)){var e=this.observer?this.observer.takeRecords():[];this.queue.length&&(e=this.queue.concat(e),this.queue.length=0);var t=this.view.root.getSelection(),n=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(t)&&ke(this.view)&&!this.ignoreSelectionChange(t),r=-1,o=-1,i=!1,a=[];if(this.view.editable)for(var l=0;l<e.length;l++){var c=this.registerMutation(e[l],a);c&&(r=r<0?c.from:Math.min(c.from,r),o=o<0?c.to:Math.max(c.to,o),c.typeOver&&(i=!0))}if(s.gecko&&a.length>1){var u=a.filter((function(e){return"BR"==e.nodeName}));if(2==u.length){var d=u[0],p=u[1];d.parentNode&&d.parentNode.parentNode==p.parentNode?p.remove():d.remove()}}(r>-1||n)&&(r>-1&&(this.view.docView.markDirty(r,o),function(e){if(Ze)return;Ze=!0,"normal"==getComputedStyle(e.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(t)||he(this.view),this.currentSelection.set(t))}},Qe.prototype.registerMutation=function(e,t){if(t.indexOf(e.target)>-1)return null;var n=this.view.docView.nearestDesc(e.target);if("attributes"==e.type&&(n==this.view.docView||"contenteditable"==e.attributeName||"style"==e.attributeName&&!e.oldValue&&!e.target.getAttribute("style")))return null;if(!n||n.ignoreMutation(e))return null;if("childList"==e.type){for(var r=0;r<e.addedNodes.length;r++)t.push(e.addedNodes[r]);if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};var o=e.previousSibling,i=e.nextSibling;if(s.ie&&s.ie_version<=11&&e.addedNodes.length)for(var a=0;a<e.addedNodes.length;a++){var l=e.addedNodes[a],c=l.previousSibling,u=l.nextSibling;(!c||Array.prototype.indexOf.call(e.addedNodes,c)<0)&&(o=c),(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(i=u)}var d=o&&o.parentNode==e.target?p(o)+1:0,f=n.localPosFromDOM(e.target,d,-1),h=i&&i.parentNode==e.target?p(i):e.target.childNodes.length;return{from:f,to:n.localPosFromDOM(e.target,h,1)}}return"attributes"==e.type?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}};var Ze=!1;var et={},tt={};function nt(e,t){e.lastSelectionOrigin=t,e.lastSelectionTime=Date.now()}function rt(e){e.someProp("handleDOMEvents",(function(t){for(var n in t)e.eventHandlers[n]||e.dom.addEventListener(n,e.eventHandlers[n]=function(t){return ot(e,t)})}))}function ot(e,t){return e.someProp("handleDOMEvents",(function(n){var r=n[t.type];return!!r&&(r(e,t)||t.defaultPrevented)}))}function it(e){return{left:e.clientX,top:e.clientY}}function st(e,t,n,r,o){if(-1==r)return!1;for(var i=e.state.doc.resolve(r),s=function(r){if(e.someProp(t,(function(t){return r>i.depth?t(e,n,i.nodeAfter,i.before(r),o,!0):t(e,n,i.node(r),i.before(r),o,!1)})))return{v:!0}},a=i.depth+1;a>0;a--){var l=s(a);if(l)return l.v}return!1}function at(e,t,n){e.focused||e.focus();var r=e.state.tr.setSelection(t);"pointer"==n&&r.setMeta("pointer",!0),e.dispatch(r)}function lt(e,t,n,o,i){return st(e,"handleClickOn",t,n,o)||e.someProp("handleClick",(function(n){return n(e,t,o)}))||(i?function(e,t){if(-1==t)return!1;var n,o,i=e.state.selection;i instanceof r.NodeSelection&&(n=i.node);for(var s=e.state.doc.resolve(t),a=s.depth+1;a>0;a--){var l=a>s.depth?s.nodeAfter:s.node(a);if(r.NodeSelection.isSelectable(l)){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&&(at(e,r.NodeSelection.create(e.state.doc,o),"pointer"),!0)}(e,n):function(e,t){if(-1==t)return!1;var n=e.state.doc.resolve(t),o=n.nodeAfter;return!!(o&&o.isAtom&&r.NodeSelection.isSelectable(o))&&(at(e,new r.NodeSelection(n),"pointer"),!0)}(e,n))}function ct(e,t,n,r){return st(e,"handleDoubleClickOn",t,n,r)||e.someProp("handleDoubleClick",(function(n){return n(e,t,r)}))}function ut(e,t,n,o){return st(e,"handleTripleClickOn",t,n,o)||e.someProp("handleTripleClick",(function(n){return n(e,t,o)}))||function(e,t,n){if(0!=n.button)return!1;var o=e.state.doc;if(-1==t)return!!o.inlineContent&&(at(e,r.TextSelection.create(o,0,o.content.size),"pointer"),!0);for(var i=o.resolve(t),s=i.depth+1;s>0;s--){var a=s>i.depth?i.nodeAfter:i.node(s),l=i.before(s);if(a.inlineContent)at(e,r.TextSelection.create(o,l+1,l+1+a.content.size),"pointer");else{if(!r.NodeSelection.isSelectable(a))continue;at(e,r.NodeSelection.create(o,l),"pointer")}return!0}}(e,n,o)}function dt(e){return yt(e)}tt.keydown=function(e,t){if(e.shiftKey=16==t.keyCode||t.shiftKey,!ht(e,t)&&(e.lastKeyCode=t.keyCode,e.lastKeyCodeTime=Date.now(),!s.android||!s.chrome||13!=t.keyCode))if(229!=t.keyCode&&e.domObserver.forceFlush(),!s.ios||13!=t.keyCode||t.ctrlKey||t.altKey||t.metaKey)e.someProp("handleKeyDown",(function(n){return n(e,t)}))||Ie(e,t)?t.preventDefault():nt(e,"key");else{var n=Date.now();e.lastIOSEnter=n,e.lastIOSEnterFallbackTimeout=setTimeout((function(){e.lastIOSEnter==n&&(e.someProp("handleKeyDown",(function(t){return t(e,k(13,"Enter"))})),e.lastIOSEnter=0)}),200)}},tt.keyup=function(e,t){16==t.keyCode&&(e.shiftKey=!1)},tt.keypress=function(e,t){if(!(ht(e,t)||!t.charCode||t.ctrlKey&&!t.altKey||s.mac&&t.metaKey))if(e.someProp("handleKeyPress",(function(n){return n(e,t)})))t.preventDefault();else{var n=e.state.selection;if(!(n instanceof r.TextSelection&&n.$from.sameParent(n.$to))){var o=String.fromCharCode(t.charCode);e.someProp("handleTextInput",(function(t){return t(e,n.$from.pos,n.$to.pos,o)}))||e.dispatch(e.state.tr.insertText(o).scrollIntoView()),t.preventDefault()}}};var pt=s.mac?"metaKey":"ctrlKey";et.mousedown=function(e,t){e.shiftKey=t.shiftKey;var n=dt(e),r=Date.now(),o="singleClick";r-e.lastClick.time<500&&function(e,t){var n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}(t,e.lastClick)&&!t[pt]&&("singleClick"==e.lastClick.type?o="doubleClick":"doubleClick"==e.lastClick.type&&(o="tripleClick")),e.lastClick={time:r,x:t.clientX,y:t.clientY,type:o};var i=e.posAtCoords(it(t));i&&("singleClick"==o?(e.mouseDown&&e.mouseDown.done(),e.mouseDown=new ft(e,i,t,n)):("doubleClick"==o?ct:ut)(e,i.pos,i.inside,t)?t.preventDefault():nt(e,"pointer"))};var ft=function(e,t,n,o){var i,a,l=this;if(this.view=e,this.startDoc=e.state.doc,this.pos=t,this.event=n,this.flushed=o,this.selectNode=n[pt],this.allowDefault=n.shiftKey,this.delayedSelectionSync=!1,t.inside>-1)i=e.state.doc.nodeAt(t.inside),a=t.inside;else{var c=e.state.doc.resolve(t.pos);i=c.parent,a=c.depth?c.before():0}this.mightDrag=null;var u=o?null:n.target,d=u?e.docView.nearestDesc(u,!0):null;this.target=d?d.dom:null;var p=e.state.selection;(0==n.button&&i.type.spec.draggable&&!1!==i.type.spec.selectable||p instanceof r.NodeSelection&&p.from<=a&&p.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(){l.view.mouseDown==l&&l.target.setAttribute("contentEditable","false")}),20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),nt(e,"pointer")};function ht(e,t){return!!e.composing||!!(s.safari&&Math.abs(t.timeStamp-e.compositionEndedAt)<500)&&(e.compositionEndedAt=-2e8,!0)}ft.prototype.done=function(){var e=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 he(e.view)})),this.view.mouseDown=null},ft.prototype.up=function(e){if(this.done(),this.view.dom.contains(3==e.target.nodeType?e.target.parentNode:e.target)){var t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(it(e))),this.allowDefault||!t?nt(this.view,"pointer"):lt(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():0==e.button&&(this.flushed||s.safari&&this.mightDrag&&!this.mightDrag.node.isAtom||s.chrome&&!(this.view.state.selection instanceof r.TextSelection)&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(at(this.view,r.Selection.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):nt(this.view,"pointer")}},ft.prototype.move=function(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0),nt(this.view,"pointer"),0==e.buttons&&this.done()},et.touchdown=function(e){dt(e),nt(e,"pointer")},et.contextmenu=function(e){return dt(e)};var mt=s.android?5e3:-1;function vt(e,t){clearTimeout(e.composingTimeout),t>-1&&(e.composingTimeout=setTimeout((function(){return yt(e)}),t))}function gt(e){var t;for(e.composing&&(e.composing=!1,e.compositionEndedAt=((t=document.createEvent("Event")).initEvent("event",!0,!0),t.timeStamp));e.compositionNodes.length>0;)e.compositionNodes.pop().markParentsDirty()}function yt(e,t){if(!(s.android&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),gt(e),t||e.docView&&e.docView.dirty){var n=pe(e);return n&&!n.eq(e.state.selection)?e.dispatch(e.state.tr.setSelection(n)):e.updateState(e.state),!0}return!1}}tt.compositionstart=tt.compositionupdate=function(e){if(!e.composing){e.domObserver.flush();var t=e.state,n=t.selection.$from;if(t.selection.empty&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some((function(e){return!1===e.type.spec.inclusive}))))e.markCursor=e.state.storedMarks||n.marks(),yt(e,!0),e.markCursor=null;else if(yt(e),s.gecko&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length)for(var r=e.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}e.composing=!0}vt(e,mt)},tt.compositionend=function(e,t){e.composing&&(e.composing=!1,e.compositionEndedAt=t.timeStamp,vt(e,20))};var wt=s.ie&&s.ie_version<15||s.ios&&s.webkit_version<604;function bt(e,t,n,r){var i=Ve(e,t,n,e.shiftKey,e.state.selection.$from);if(e.someProp("handlePaste",(function(t){return t(e,r,i||o.Slice.empty)})))return!0;if(!i)return!1;var s=function(e){return 0==e.openStart&&0==e.openEnd&&1==e.content.childCount?e.content.firstChild:null}(i),a=s?e.state.tr.replaceSelectionWith(s,e.shiftKey):e.state.tr.replaceSelection(i);return e.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}et.copy=tt.cut=function(e,t){var n=e.state.selection,r="cut"==t.type;if(!n.empty){var o=wt?null:t.clipboardData,i=Le(e,n.content()),s=i.dom,a=i.text;o?(t.preventDefault(),o.clearData(),o.setData("text/html",s.innerHTML),o.setData("text/plain",a)):function(e,t){if(e.dom.parentNode){var n=e.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(t),n.style.cssText="position: fixed; left: -10000px; top: 10px";var r=getSelection(),o=document.createRange();o.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout((function(){n.parentNode&&n.parentNode.removeChild(n),e.focus()}),50)}}(e,s),r&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))}},tt.paste=function(e,t){if(!e.composing||s.android){var n=wt?null:t.clipboardData;n&&bt(e,n.getData("text/plain"),n.getData("text/html"),t)?t.preventDefault():function(e,t){if(e.dom.parentNode){var n=e.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus(),setTimeout((function(){e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?bt(e,r.value,null,t):bt(e,r.textContent,r.innerHTML,t)}),50)}}(e,t)}};var St=function(e,t){this.slice=e,this.move=t},kt=s.mac?"altKey":"ctrlKey";for(var xt in et.dragstart=function(e,t){var n=e.mouseDown;if(n&&n.done(),t.dataTransfer){var o=e.state.selection,i=o.empty?null:e.posAtCoords(it(t));if(i&&i.pos>=o.from&&i.pos<=(o instanceof r.NodeSelection?o.to-1:o.to));else if(n&&n.mightDrag)e.dispatch(e.state.tr.setSelection(r.NodeSelection.create(e.state.doc,n.mightDrag.pos)));else if(t.target&&1==t.target.nodeType){var s=e.docView.nearestDesc(t.target,!0);s&&s.node.type.spec.draggable&&s!=e.docView&&e.dispatch(e.state.tr.setSelection(r.NodeSelection.create(e.state.doc,s.posBefore)))}var a=e.state.selection.content(),l=Le(e,a),c=l.dom,u=l.text;t.dataTransfer.clearData(),t.dataTransfer.setData(wt?"Text":"text/html",c.innerHTML),t.dataTransfer.effectAllowed="copyMove",wt||t.dataTransfer.setData("text/plain",u),e.dragging=new St(a,!t[kt])}},et.dragend=function(e){var t=e.dragging;window.setTimeout((function(){e.dragging==t&&(e.dragging=null)}),50)},tt.dragover=tt.dragenter=function(e,t){return t.preventDefault()},tt.drop=function(e,t){var n=e.dragging;if(e.dragging=null,t.dataTransfer){var s=e.posAtCoords(it(t));if(s){var a=e.state.doc.resolve(s.pos);if(a){var l=n&&n.slice;l?e.someProp("transformPasted",(function(e){l=e(l)})):l=Ve(e,t.dataTransfer.getData(wt?"Text":"text/plain"),wt?null:t.dataTransfer.getData("text/html"),!1,a);var c=n&&!t[kt];if(e.someProp("handleDrop",(function(n){return n(e,t,l||o.Slice.empty,c)})))t.preventDefault();else if(l){t.preventDefault();var u=l?Object(i.dropPoint)(e.state.doc,a.pos,l):a.pos;null==u&&(u=a.pos);var d=e.state.tr;c&&d.deleteSelection();var p=d.mapping.map(u),f=0==l.openStart&&0==l.openEnd&&1==l.content.childCount,h=d.doc;if(f?d.replaceRangeWith(p,p,l.content.firstChild):d.replaceRange(p,p,l),!d.doc.eq(h)){var m=d.doc.resolve(p);if(f&&r.NodeSelection.isSelectable(l.content.firstChild)&&m.nodeAfter&&m.nodeAfter.sameMarkup(l.content.firstChild))d.setSelection(new r.NodeSelection(m));else{var v=d.mapping.map(u);d.mapping.maps[d.mapping.maps.length-1].forEach((function(e,t,n,r){return v=r})),d.setSelection(Se(e,m,d.doc.resolve(v)))}e.focus(),e.dispatch(d.setMeta("uiEvent","drop"))}}}}}},et.focus=function(e){e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout((function(){e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.root.getSelection())&&he(e)}),20))},et.blur=function(e,t){e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),t.relatedTarget&&e.dom.contains(t.relatedTarget)&&e.domObserver.currentSelection.set({}),e.focused=!1)},et.beforeinput=function(e,t){if(s.chrome&&s.android&&"deleteContentBackward"==t.inputType){e.domObserver.flushSoon();var n=e.domChangeCount;setTimeout((function(){if(e.domChangeCount==n&&(e.dom.blur(),e.focus(),!e.someProp("handleKeyDown",(function(t){return t(e,k(8,"Backspace"))})))){var t=e.state.selection.$cursor;t&&t.pos>0&&e.dispatch(e.state.tr.delete(t.pos-1,t.pos).scrollIntoView())}}),50)}},tt)et[xt]=tt[xt];function Ct(e,t){if(e==t)return!0;for(var n in e)if(e[n]!==t[n])return!1;for(var r in t)if(!(r in e))return!1;return!0}var Mt=function(e,t){this.spec=t||Dt,this.side=this.spec.side||0,this.toDOM=e};Mt.prototype.map=function(e,t,n,r){var o=e.mapResult(t.from+r,this.side<0?-1:1),i=o.pos;return o.deleted?null:new At(i-n,i-n,this)},Mt.prototype.valid=function(){return!0},Mt.prototype.eq=function(e){return this==e||e instanceof Mt&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Ct(this.spec,e.spec))},Mt.prototype.destroy=function(e){this.spec.destroy&&this.spec.destroy(e)};var Ot=function(e,t){this.spec=t||Dt,this.attrs=e};Ot.prototype.map=function(e,t,n,r){var o=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,i=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return o>=i?null:new At(o,i,this)},Ot.prototype.valid=function(e,t){return t.from<t.to},Ot.prototype.eq=function(e){return this==e||e instanceof Ot&&Ct(this.attrs,e.attrs)&&Ct(this.spec,e.spec)},Ot.is=function(e){return e.type instanceof Ot};var Tt=function(e,t){this.spec=t||Dt,this.attrs=e};Tt.prototype.map=function(e,t,n,r){var o=e.mapResult(t.from+r,1);if(o.deleted)return null;var i=e.mapResult(t.to+r,-1);return i.deleted||i.pos<=o.pos?null:new At(o.pos-n,i.pos-n,this)},Tt.prototype.valid=function(e,t){var n,r=e.content.findIndex(t.from),o=r.index,i=r.offset;return i==t.from&&!(n=e.child(o)).isText&&i+n.nodeSize==t.to},Tt.prototype.eq=function(e){return this==e||e instanceof Tt&&Ct(this.attrs,e.attrs)&&Ct(this.spec,e.spec)};var At=function(e,t,n){this.from=e,this.to=t,this.type=n},Nt={spec:{configurable:!0},inline:{configurable:!0}};At.prototype.copy=function(e,t){return new At(e,t,this.type)},At.prototype.eq=function(e,t){return void 0===t&&(t=0),this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to},At.prototype.map=function(e,t,n){return this.type.map(e,this,t,n)},At.widget=function(e,t,n){return new At(e,e,new Mt(t,n))},At.inline=function(e,t,n,r){return new At(e,t,new Ot(n,r))},At.node=function(e,t,n,r){return new At(e,t,new Tt(n,r))},Nt.spec.get=function(){return this.type.spec},Nt.inline.get=function(){return this.type instanceof Ot},Object.defineProperties(At.prototype,Nt);var Rt=[],Dt={},Et=function(e,t){this.local=e&&e.length?e:Rt,this.children=t&&t.length?t:Rt};Et.create=function(e,t){return t.length?Ft(t,e,0,Dt):zt},Et.prototype.find=function(e,t,n){var r=[];return this.findInner(null==e?0:e,null==t?1e9:t,r,0,n),r},Et.prototype.findInner=function(e,t,n,r,o){for(var i=0;i<this.local.length;i++){var s=this.local[i];s.from<=t&&s.to>=e&&(!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]<t&&this.children[a+1]>e){var l=this.children[a]+1;this.children[a+2].findInner(e-l,t-l,n,r+l,o)}},Et.prototype.map=function(e,t,n){return this==zt||0==e.maps.length?this:this.mapInner(e,t,0,0,n||Dt)},Et.prototype.mapInner=function(e,t,n,r,o){for(var i,s=0;s<this.local.length;s++){var a=this.local[s].map(e,n,r);a&&a.type.valid(t,a)?(i||(i=[])).push(a):o.onRemove&&o.onRemove(this.local[s].spec)}return this.children.length?function(e,t,n,r,o,i,s){for(var a=e.slice(),l=function(e,t,n,r){for(var s=0;s<a.length;s+=3){var l=a[s+1],c=void 0;if(!(l<0||e>l+i)){var u=a[s]+i;t>=u?a[s+1]=e<=u?-2:-1:n>=o&&(c=r-n-(t-e))&&(a[s]+=c,a[s+1]+=c)}}},c=0;c<n.maps.length;c++)n.maps[c].forEach(l);for(var u=!1,d=0;d<a.length;d+=3)if(a[d+1]<0){if(-2==a[d+1]){u=!0,a[d+1]=-1;continue}var p=n.map(e[d]+i),f=p-o;if(f<0||f>=r.content.size){u=!0;continue}var h=n.map(e[d+1]+i,-1)-o,m=r.content.findIndex(f),v=m.index,g=m.offset,y=r.maybeChild(v);if(y&&g==f&&g+y.nodeSize==h){var w=a[d+2].mapInner(n,y,p+1,e[d]+i+1,s);w!=zt?(a[d]=f,a[d+1]=h,a[d+2]=w):(a[d+1]=-2,u=!0)}else u=!0}if(u){var b=Ft(function(e,t,n,r,o,i,s){function a(e,t){for(var i=0;i<e.local.length;i++){var l=e.local[i].map(r,o,t);l?n.push(l):s.onRemove&&s.onRemove(e.local[i].spec)}for(var c=0;c<e.children.length;c+=3)a(e.children[c+2],e.children[c]+t+1)}for(var l=0;l<e.length;l+=3)-1==e[l+1]&&a(e[l+2],t[l]+i+1);return n}(a,e,t||[],n,o,i,s),r,0,s);t=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 Et(t&&t.sort(Bt),a)}(this.children,i,e,t,n,r,o):i?new Et(i.sort(Bt)):zt},Et.prototype.add=function(e,t){return t.length?this==zt?Et.create(e,t):this.addInner(e,t,0):this},Et.prototype.addInner=function(e,t,n){var r,o=this,i=0;e.forEach((function(e,s){var a,l=s+n;if(a=Pt(t,e,l)){for(r||(r=o.children.slice());i<r.length&&r[i]<s;)i+=3;r[i]==s?r[i+2]=r[i+2].addInner(e,a,l+1):r.splice(i,0,s,s+e.nodeSize,Ft(a,e,l+1,Dt)),i+=3}}));for(var s=It(i?$t(t):t,-n),a=0;a<s.length;a++)s[a].type.valid(e,s[a])||s.splice(a--,1);return new Et(s.length?this.local.concat(s).sort(Bt):this.local,r||this.children)},Et.prototype.remove=function(e){return 0==e.length||this==zt?this:this.removeInner(e,0)},Et.prototype.removeInner=function(e,t){for(var n=this.children,r=this.local,o=0;o<n.length;o+=3){for(var i=void 0,s=n[o]+t,a=n[o+1]+t,l=0,c=void 0;l<e.length;l++)(c=e[l])&&c.from>s&&c.to<a&&(e[l]=null,(i||(i=[])).push(c));if(i){n==this.children&&(n=this.children.slice());var u=n[o+2].removeInner(i,s+1);u!=zt?n[o+2]=u:(n.splice(o,3),o-=3)}}if(r.length)for(var d=0,p=void 0;d<e.length;d++)if(p=e[d])for(var f=0;f<r.length;f++)r[f].eq(p,t)&&(r==this.local&&(r=this.local.slice()),r.splice(f--,1));return n==this.children&&r==this.local?this:r.length||n.length?new Et(r,n):zt},Et.prototype.forChild=function(e,t){if(this==zt)return this;if(t.isLeaf)return Et.empty;for(var n,r,o=0;o<this.children.length;o+=3)if(this.children[o]>=e){this.children[o]==e&&(n=this.children[o+2]);break}for(var i=e+1,s=i+t.content.size,a=0;a<this.local.length;a++){var l=this.local[a];if(l.from<s&&l.to>i&&l.type instanceof Ot){var c=Math.max(i,l.from)-i,u=Math.min(s,l.to)-i;c<u&&(r||(r=[])).push(l.copy(c,u))}}if(r){var d=new Et(r.sort(Bt));return n?new _t([d,n]):d}return n||zt},Et.prototype.eq=function(e){if(this==e)return!0;if(!(e instanceof Et)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(var t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(var n=0;n<this.children.length;n+=3)if(this.children[n]!=e.children[n]||this.children[n+1]!=e.children[n+1]||!this.children[n+2].eq(e.children[n+2]))return!1;return!0},Et.prototype.locals=function(e){return Lt(this.localsInner(e))},Et.prototype.localsInner=function(e){if(this==zt)return Rt;if(e.inlineContent||!this.local.some(Ot.is))return this.local;for(var t=[],n=0;n<this.local.length;n++)this.local[n].type instanceof Ot||t.push(this.local[n]);return t};var zt=new Et;Et.empty=zt,Et.removeOverlap=Lt;var _t=function(e){this.members=e};function It(e,t){if(!t||!e.length)return e;for(var n=[],r=0;r<e.length;r++){var o=e[r];n.push(new At(o.from+t,o.to+t,o.type))}return n}function Pt(e,t,n){if(t.isLeaf)return null;for(var r=n+t.nodeSize,o=null,i=0,s=void 0;i<e.length;i++)(s=e[i])&&s.from>n&&s.to<r&&((o||(o=[])).push(s),e[i]=null);return o}function $t(e){for(var t=[],n=0;n<e.length;n++)null!=e[n]&&t.push(e[n]);return t}function Ft(e,t,n,r){var o=[],i=!1;t.forEach((function(t,s){var a=Pt(e,t,s+n);if(a){i=!0;var l=Ft(a,t,n+s+1,r);l!=zt&&o.push(s,s+t.nodeSize,l)}}));for(var s=It(i?$t(e):e,-n).sort(Bt),a=0;a<s.length;a++)s[a].type.valid(t,s[a])||(r.onRemove&&r.onRemove(s[a].spec),s.splice(a--,1));return s.length||o.length?new Et(s,o):zt}function Bt(e,t){return e.from-t.from||e.to-t.to}function Lt(e){for(var t=e,n=0;n<t.length-1;n++){var r=t[n];if(r.from!=r.to)for(var o=n+1;o<t.length;o++){var i=t[o];if(i.from!=r.from){i.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,i.from),Vt(t,o,r.copy(i.from,r.to)));break}i.to!=r.to&&(t==e&&(t=e.slice()),t[o]=i.copy(i.from,r.to),Vt(t,o+1,i.copy(r.to,i.to)))}}return t}function Vt(e,t,n){for(;t<e.length&&Bt(n,e[t])>0;)t++;e.splice(t,0,n)}function jt(e){var t=[];return e.someProp("decorations",(function(n){var r=n(e.state);r&&r!=zt&&t.push(r)})),e.cursorWrapper&&t.push(Et.create(e.state.doc,[e.cursorWrapper.deco])),_t.from(t)}_t.prototype.map=function(e,t){var n=this.members.map((function(n){return n.map(e,t,Dt)}));return _t.from(n)},_t.prototype.forChild=function(e,t){if(t.isLeaf)return Et.empty;for(var n=[],r=0;r<this.members.length;r++){var o=this.members[r].forChild(e,t);o!=zt&&(o instanceof _t?n=n.concat(o.members):n.push(o))}return _t.from(n)},_t.prototype.eq=function(e){if(!(e instanceof _t)||e.members.length!=this.members.length)return!1;for(var t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0},_t.prototype.locals=function(e){for(var t,n=!0,r=0;r<this.members.length;r++){var o=this.members[r].localsInner(e);if(o.length)if(t){n&&(t=t.slice(),n=!1);for(var i=0;i<o.length;i++)t.push(o[i])}else t=o}return t?Lt(n?t:t.sort(Bt)):Rt},_t.from=function(e){switch(e.length){case 0:return zt;case 1:return e[0];default:return new _t(e)}};var Kt=function(e,t){this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Ut),this.dispatch=this.dispatch.bind(this),this._root=null,this.focused=!1,this.trackWrites=null,this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):e.apply?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Jt(this),this.markCursor=null,this.cursorWrapper=null,qt(this),this.nodeViews=Xt(this),this.docView=G(this.state.doc,Wt(this),jt(this),this.dom,this),this.lastSelectedViewDesc=null,this.dragging=null,function(e){e.shiftKey=!1,e.mouseDown=null,e.lastKeyCode=null,e.lastKeyCodeTime=0,e.lastClick={time:0,x:0,y:0,type:""},e.lastSelectionOrigin=null,e.lastSelectionTime=0,e.lastIOSEnter=0,e.lastIOSEnterFallbackTimeout=null,e.lastAndroidDelete=0,e.composing=!1,e.composingTimeout=null,e.compositionNodes=[],e.compositionEndedAt=-2e8,e.domObserver=new Qe(e,(function(t,n,r,o){return $e(e,t,n,r,o)})),e.domObserver.start(),e.domChangeCount=0,e.eventHandlers=Object.create(null);var t=function(t){var n=et[t];e.dom.addEventListener(t,e.eventHandlers[t]=function(t){!function(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(var n=t.target;n!=e.dom;n=n.parentNode)if(!n||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}(e,t)||ot(e,t)||!e.editable&&t.type in tt||n(e,t)})};for(var n in et)t(n);s.safari&&e.dom.addEventListener("input",(function(){return null})),rt(e)}(this),this.prevDirectPlugins=[],this.pluginViews=[],this.updatePluginViews()},Ht={props:{configurable:!0},root:{configurable:!0},isDestroyed:{configurable:!0}};function Wt(e){var t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(e.editable),t.translate="no",e.someProp("attributes",(function(n){if("function"==typeof n&&(n=n(e.state)),n)for(var r in n)"class"==r&&(t.class+=" "+n[r]),"style"==r?t.style=(t.style?t.style+";":"")+n[r]:t[r]||"contenteditable"==r||"nodeName"==r||(t[r]=String(n[r]))})),[At.node(0,e.state.doc.content.size,t)]}function qt(e){if(e.markCursor){var t=document.createElement("img");t.className="ProseMirror-separator",t.setAttribute("mark-placeholder","true"),t.setAttribute("alt",""),e.cursorWrapper={dom:t,deco:At.widget(e.state.selection.head,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function Jt(e){return!e.someProp("editable",(function(t){return!1===t(e.state)}))}function Xt(e){var t={};return e.someProp("nodeViews",(function(e){for(var n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])})),t}function Ut(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}Ht.props.get=function(){if(this._props.state!=this.state){var e=this._props;for(var t in this._props={},e)this._props[t]=e[t];this._props.state=this.state}return this._props},Kt.prototype.update=function(e){e.handleDOMEvents!=this._props.handleDOMEvents&&rt(this),this._props=e,e.plugins&&(e.plugins.forEach(Ut),this.directPlugins=e.plugins),this.updateStateInner(e.state,!0)},Kt.prototype.setProps=function(e){var t={};for(var n in this._props)t[n]=this._props[n];for(var r in t.state=this.state,e)t[r]=e[r];this.update(t)},Kt.prototype.updateState=function(e){this.updateStateInner(e,this.state.plugins!=e.plugins)},Kt.prototype.updateStateInner=function(e,t){var n=this,o=this.state,i=!1,a=!1;if(e.storedMarks&&this.composing&&(gt(this),a=!0),this.state=e,t){var l=Xt(this);(function(e,t){var n=0,r=0;for(var o in e){if(e[o]!=t[o])return!0;n++}for(var i in t)r++;return n!=r})(l,this.nodeViews)&&(this.nodeViews=l,i=!0),rt(this)}this.editable=Jt(this),qt(this);var c=jt(this),u=Wt(this),d=t?"reset":e.scrollToSelection>o.scrollToSelection?"to selection":"preserve",p=i||!this.docView.matchesNode(e.doc,u,c);!p&&e.selection.eq(o.selection)||(a=!0);var f,h,m,g,y,w,b,S,k,x,C,M="preserve"==d&&a&&null==this.dom.style.overflowAnchor&&function(e){for(var t,n,r=e.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=e.root.elementFromPoint(i,s);if(a!=e.dom&&e.dom.contains(a)){var l=a.getBoundingClientRect();if(l.top>=o-20){t=a,n=l.top;break}}}return{refDOM:t,refTop:n,stack:T(e.dom)}}(this);if(a){this.domObserver.stop();var N=p&&(s.ie||s.chrome)&&!this.composing&&!o.selection.empty&&!e.selection.empty&&(g=o.selection,y=e.selection,w=Math.min(g.$anchor.sharedDepth(g.head),y.$anchor.sharedDepth(y.head)),g.$anchor.start(w)!=y.$anchor.start(w));if(p){var R=s.chrome?this.trackWrites=this.root.getSelection().focusNode:null;!i&&this.docView.update(e.doc,u,c,this)||(this.docView.updateOuterDeco([]),this.docView.destroy(),this.docView=G(e.doc,u,c,this.dom,this)),R&&!this.trackWrites&&(N=!0)}N||!(this.mouseDown&&this.domObserver.currentSelection.eq(this.root.getSelection())&&(f=this,h=f.docView.domFromPos(f.state.selection.anchor,0),m=f.root.getSelection(),v(h.node,h.offset,m.anchorNode,m.anchorOffset)))?he(this,N):(we(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}if(this.updatePluginViews(o),"reset"==d)this.dom.scrollTop=0;else if("to selection"==d){var D=this.root.getSelection().focusNode;this.someProp("handleScrollToSelection",(function(e){return e(n)}))||(e.selection instanceof r.NodeSelection?O(this,this.docView.domAfterPos(e.selection.from).getBoundingClientRect(),D):O(this,this.coordsAtPos(e.selection.head,1),D))}else M&&(S=(b=M).refDOM,k=b.refTop,x=b.stack,C=S?S.getBoundingClientRect().top:0,A(x,0==C?0:C-k))},Kt.prototype.destroyPluginViews=function(){for(var e;e=this.pluginViews.pop();)e.destroy&&e.destroy()},Kt.prototype.updatePluginViews=function(e){if(e&&e.plugins==this.state.plugins&&this.directPlugins==this.prevDirectPlugins)for(var t=0;t<this.pluginViews.length;t++){var n=this.pluginViews[t];n.update&&n.update(this,e)}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))}}},Kt.prototype.someProp=function(e,t){var n,r=this._props&&this._props[e];if(null!=r&&(n=t?t(r):r))return n;for(var o=0;o<this.directPlugins.length;o++){var i=this.directPlugins[o].props[e];if(null!=i&&(n=t?t(i):i))return n}var s=this.state.plugins;if(s)for(var a=0;a<s.length;a++){var l=s[a].props[e];if(null!=l&&(n=t?t(l):l))return n}},Kt.prototype.hasFocus=function(){return this.root.activeElement==this.dom},Kt.prototype.focus=function(){this.domObserver.stop(),this.editable&&function(e){if(e.setActive)return e.setActive();if(N)return e.focus(N);var t=T(e);e.focus(null==N?{get preventScroll(){return N={preventScroll:!0},!0}}:void 0),N||(N=!1,A(t,0))}(this.dom),he(this),this.domObserver.start()},Ht.root.get=function(){var e=this._root;if(null==e)for(var t=this.dom.parentNode;t;t=t.parentNode)if(9==t.nodeType||11==t.nodeType&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=function(){return document.getSelection()}),this._root=t;return e||document},Kt.prototype.posAtCoords=function(e){return E(this,e)},Kt.prototype.coordsAtPos=function(e,t){return void 0===t&&(t=1),I(this,e,t)},Kt.prototype.domAtPos=function(e,t){return void 0===t&&(t=0),this.docView.domFromPos(e,t)},Kt.prototype.nodeDOM=function(e){var t=this.docView.descAt(e);return t?t.nodeDOM:null},Kt.prototype.posAtDOM=function(e,t,n){void 0===n&&(n=-1);var r=this.docView.posFromDOM(e,t,n);if(null==r)throw new RangeError("DOM position not inside the editor");return r},Kt.prototype.endOfTextblock=function(e,t){return K(this,t||this.state,e)},Kt.prototype.destroy=function(){this.docView&&(!function(e){for(var t in e.domObserver.stop(),e.eventHandlers)e.dom.removeEventListener(t,e.eventHandlers[t]);clearTimeout(e.composingTimeout),clearTimeout(e.lastIOSEnterFallbackTimeout)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],jt(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null)},Ht.isDestroyed.get=function(){return null==this.docView},Kt.prototype.dispatchEvent=function(e){return function(e,t){ot(e,t)||!et[t.type]||!e.editable&&t.type in tt||et[t.type](e,t)}(this,e)},Kt.prototype.dispatch=function(e){var t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))},Object.defineProperties(Kt.prototype,Ht)},function(e,t,n){"use strict";n.r(t),n.d(t,"__extends",(function(){return o})),n.d(t,"__assign",(function(){return i})),n.d(t,"__rest",(function(){return s})),n.d(t,"__decorate",(function(){return a})),n.d(t,"__param",(function(){return l})),n.d(t,"__metadata",(function(){return c})),n.d(t,"__awaiter",(function(){return u})),n.d(t,"__generator",(function(){return d})),n.d(t,"__createBinding",(function(){return p})),n.d(t,"__exportStar",(function(){return f})),n.d(t,"__values",(function(){return h})),n.d(t,"__read",(function(){return m})),n.d(t,"__spread",(function(){return v})),n.d(t,"__spreadArrays",(function(){return g})),n.d(t,"__await",(function(){return y})),n.d(t,"__asyncGenerator",(function(){return w})),n.d(t,"__asyncDelegator",(function(){return b})),n.d(t,"__asyncValues",(function(){return S})),n.d(t,"__makeTemplateObject",(function(){return k})),n.d(t,"__importStar",(function(){return x})),n.d(t,"__importDefault",(function(){return C})),n.d(t,"__classPrivateFieldGet",(function(){return M})),n.d(t,"__classPrivateFieldSet",(function(){return O}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.KendoEditorCommon=t():e.KendoEditorCommon=t()}(window,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=26)}([function(e,t,n){"use strict";function r(e){this.content=e}n.r(t),n.d(t,"ContentMatch",(function(){return z})),n.d(t,"DOMParser",(function(){return ee})),n.d(t,"DOMSerializer",(function(){return de})),n.d(t,"Fragment",(function(){return i})),n.d(t,"Mark",(function(){return u})),n.d(t,"MarkType",(function(){return G})),n.d(t,"Node",(function(){return N})),n.d(t,"NodeRange",(function(){return O})),n.d(t,"NodeType",(function(){return J})),n.d(t,"ReplaceError",(function(){return d})),n.d(t,"ResolvedPos",(function(){return S})),n.d(t,"Schema",(function(){return Q})),n.d(t,"Slice",(function(){return p})),r.prototype={constructor:r,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return-1==t?void 0:this.content[t+1]},update:function(e,t,n){var o=n&&n!=e?this.remove(n):this,i=o.find(e),s=o.content.slice();return-1==i?s.push(n||e,t):(s[i+1]=t,n&&(s[i]=n)),new r(s)},remove:function(e){var t=this.find(e);if(-1==t)return this;var n=this.content.slice();return n.splice(t,2),new r(n)},addToStart:function(e,t){return new r([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new r(n)},addBefore:function(e,t,n){var o=this.remove(t),i=o.content.slice(),s=o.find(e);return i.splice(-1==s?i.length:s,0,t,n),new r(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return(e=r.from(e)).size?new r(e.content.concat(this.subtract(e).content)):this},append:function(e){return(e=r.from(e)).size?new r(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=r.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},get size(){return this.content.length>>1}},r.from=function(e){if(e instanceof r)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new r(t)};var o=r;var i=function(e,t){if(this.content=e,this.size=t||0,null==t)for(var n=0;n<e.length;n++)this.size+=e[n].nodeSize},s={firstChild:{configurable:!0},lastChild:{configurable:!0},childCount:{configurable:!0}};i.prototype.nodesBetween=function(e,t,n,r,o){void 0===r&&(r=0);for(var i=0,s=0;s<t;i++){var a=this.content[i],l=s+a.nodeSize;if(l>e&&!1!==n(a,r+s,o,i)&&a.content.size){var c=s+1;a.nodesBetween(Math.max(0,e-c),Math.min(a.content.size,t-c),n,r+c)}s=l}},i.prototype.descendants=function(e){this.nodesBetween(0,this.size,e)},i.prototype.textBetween=function(e,t,n,r){var o="",i=!0;return this.nodesBetween(e,t,(function(s,a){s.isText?(o+=s.text.slice(Math.max(e,a)-a,t-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(e){if(!e.size)return this;if(!this.size)return e;var t=this.lastChild,n=e.firstChild,r=this.content.slice(),o=0;for(t.isText&&t.sameMarkup(n)&&(r[r.length-1]=t.withText(t.text+n.text),o=1);o<e.content.length;o++)r.push(e.content[o]);return new i(r,this.size+e.size)},i.prototype.cut=function(e,t){if(null==t&&(t=this.size),0==e&&t==this.size)return this;var n=[],r=0;if(t>e)for(var o=0,s=0;s<t;o++){var a=this.content[o],l=s+a.nodeSize;l>e&&((s<e||l>t)&&(a=a.isText?a.cut(Math.max(0,e-s),Math.min(a.text.length,t-s)):a.cut(Math.max(0,e-s-1),Math.min(a.content.size,t-s-1))),n.push(a),r+=a.nodeSize),s=l}return new i(n,r)},i.prototype.cutByIndex=function(e,t){return e==t?i.empty:0==e&&t==this.content.length?this:new i(this.content.slice(e,t))},i.prototype.replaceChild=function(e,t){var n=this.content[e];if(n==t)return this;var r=this.content.slice(),o=this.size+t.nodeSize-n.nodeSize;return r[e]=t,new i(r,o)},i.prototype.addToStart=function(e){return new i([e].concat(this.content),this.size+e.nodeSize)},i.prototype.addToEnd=function(e){return new i(this.content.concat(e),this.size+e.nodeSize)},i.prototype.eq=function(e){if(this.content.length!=e.content.length)return!1;for(var t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))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(e){var t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t},i.prototype.maybeChild=function(e){return this.content[e]},i.prototype.forEach=function(e){for(var t=0,n=0;t<this.content.length;t++){var r=this.content[t];e(r,n,t),n+=r.nodeSize}},i.prototype.findDiffStart=function(e,t){return void 0===t&&(t=0),function e(t,n,r){for(var o=0;;o++){if(o==t.childCount||o==n.childCount)return t.childCount==n.childCount?null:r;var i=t.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 l=e(i.content,s.content,r+1);if(null!=l)return l}r+=i.nodeSize}else r+=i.nodeSize}}(this,e,t)},i.prototype.findDiffEnd=function(e,t,n){return void 0===t&&(t=this.size),void 0===n&&(n=e.size),function e(t,n,r,o){for(var i=t.childCount,s=n.childCount;;){if(0==i||0==s)return i==s?null:{a:r,b:o};var a=t.child(--i),l=n.child(--s),c=a.nodeSize;if(a!=l){if(!a.sameMarkup(l))return{a:r,b:o};if(a.isText&&a.text!=l.text){for(var u=0,d=Math.min(a.text.length,l.text.length);u<d&&a.text[a.text.length-u-1]==l.text[l.text.length-u-1];)u++,r--,o--;return{a:r,b:o}}if(a.content.size||l.content.size){var p=e(a.content,l.content,r-1,o-1);if(p)return p}r-=c,o-=c}else r-=c,o-=c}}(this,e,t,n)},i.prototype.findIndex=function(e,t){if(void 0===t&&(t=-1),0==e)return l(0,e);if(e==this.size)return l(this.content.length,e);if(e>this.size||e<0)throw new RangeError("Position "+e+" outside of fragment ("+this+")");for(var n=0,r=0;;n++){var o=r+this.child(n).nodeSize;if(o>=e)return o==e||t>0?l(n+1,o):l(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(e){return e.toJSON()})):null},i.fromJSON=function(e,t){if(!t)return i.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new i(t.map(e.nodeFromJSON))},i.fromArray=function(e){if(!e.length)return i.empty;for(var t,n=0,r=0;r<e.length;r++){var o=e[r];n+=o.nodeSize,r&&o.isText&&e[r-1].sameMarkup(o)?(t||(t=e.slice(0,r)),t[t.length-1]=o.withText(t[t.length-1].text+o.text)):t&&t.push(o)}return new i(t||e,n)},i.from=function(e){if(!e)return i.empty;if(e instanceof i)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new i([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))},Object.defineProperties(i.prototype,s);var a={index:0,offset:0};function l(e,t){return a.index=e,a.offset=t,a}function c(e,t){if(e===t)return!0;if(!e||"object"!=typeof e||!t||"object"!=typeof t)return!1;var n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(var r=0;r<e.length;r++)if(!c(e[r],t[r]))return!1}else{for(var o in e)if(!(o in t)||!c(e[o],t[o]))return!1;for(var i in t)if(!(i in e))return!1}return!0}i.empty=new i([],0);var u=function(e,t){this.type=e,this.attrs=t};function d(e){var t=Error.call(this,e);return t.__proto__=d.prototype,t}u.prototype.addToSet=function(e){for(var t,n=!1,r=0;r<e.length;r++){var o=e[r];if(this.eq(o))return e;if(this.type.excludes(o.type))t||(t=e.slice(0,r));else{if(o.type.excludes(this.type))return e;!n&&o.type.rank>this.type.rank&&(t||(t=e.slice(0,r)),t.push(this),n=!0),t&&t.push(o)}}return t||(t=e.slice()),n||t.push(this),t},u.prototype.removeFromSet=function(e){for(var t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e},u.prototype.isInSet=function(e){for(var t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1},u.prototype.eq=function(e){return this==e||this.type==e.type&&c(this.attrs,e.attrs)},u.prototype.toJSON=function(){var e={type:this.type.name};for(var t in this.attrs){e.attrs=this.attrs;break}return e},u.fromJSON=function(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");var n=e.marks[t.type];if(!n)throw new RangeError("There is no mark type "+t.type+" in this schema");return n.create(t.attrs)},u.sameSet=function(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(var n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0},u.setFrom=function(e){if(!e||0==e.length)return u.none;if(e instanceof u)return[e];var t=e.slice();return t.sort((function(e,t){return e.type.rank-t.type.rank})),t},u.none=[],d.prototype=Object.create(Error.prototype),d.prototype.constructor=d,d.prototype.name="ReplaceError";var p=function(e,t,n){this.content=e,this.openStart=t,this.openEnd=n},f={size:{configurable:!0}};function h(e,t,n){if(n.openStart>e.depth)throw new d("Inserted content deeper than insertion position");if(e.depth-n.openStart!=t.depth-n.openEnd)throw new d("Inconsistent open depths");return function e(t,n,r,o){var s=t.index(o),a=t.node(o);if(s==n.index(o)&&o<t.depth-r.openStart){var l=e(t,n,r,o+1);return a.copy(a.content.replaceChild(s,l))}if(r.content.size){if(r.openStart||r.openEnd||t.depth!=o||n.depth!=o){var c=function(e,t){for(var n=t.depth-e.openStart,r=t.node(n).copy(e.content),o=n-1;o>=0;o--)r=t.node(o).copy(i.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}(r,t),u=c.start,d=c.end;return w(a,function e(t,n,r,o,s){var a=t.depth>s&&v(t,n,s+1),l=o.depth>s&&v(r,o,s+1),c=[];y(null,t,s,c),a&&l&&n.index(s)==r.index(s)?(m(a,l),g(w(a,e(t,n,r,o,s+1)),c)):(a&&g(w(a,b(t,n,s+1)),c),y(n,r,s,c),l&&g(w(l,b(r,o,s+1)),c));return y(o,null,s,c),new i(c)}(t,u,d,n,o))}var p=t.parent,f=p.content;return w(p,f.cut(0,t.parentOffset).append(r.content).append(f.cut(n.parentOffset)))}return w(a,b(t,n,o))}(e,t,n,0)}function m(e,t){if(!t.type.compatibleContent(e.type))throw new d("Cannot join "+t.type.name+" onto "+e.type.name)}function v(e,t,n){var r=e.node(n);return m(r,t.node(n)),r}function g(e,t){var n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function y(e,t,n,r){var o=(t||e).node(n),i=0,s=t?t.index(n):o.childCount;e&&(i=e.index(n),e.depth>n?i++:e.textOffset&&(g(e.nodeAfter,r),i++));for(var a=i;a<s;a++)g(o.child(a),r);t&&t.depth==n&&t.textOffset&&g(t.nodeBefore,r)}function w(e,t){if(!e.type.validContent(t))throw new d("Invalid content for node "+e.type.name);return e.copy(t)}function b(e,t,n){var r=[];(y(null,e,n,r),e.depth>n)&&g(w(v(e,t,n+1),b(e,t,n+1)),r);return y(t,null,n,r),new i(r)}f.size.get=function(){return this.content.size-this.openStart-this.openEnd},p.prototype.insertAt=function(e,t){var n=function e(t,n,r,o){var i=t.findIndex(n),s=i.index,a=i.offset,l=t.maybeChild(s);if(a==n||l.isText)return o&&!o.canReplace(s,s,r)?null:t.cut(0,n).append(r).append(t.cut(n));var c=e(l.content,n-a-1,r);return c&&t.replaceChild(s,l.copy(c))}(this.content,e+this.openStart,t,null);return n&&new p(n,this.openStart,this.openEnd)},p.prototype.removeBetween=function(e,t){return new p(function e(t,n,r){var o=t.findIndex(n),i=o.index,s=o.offset,a=t.maybeChild(i),l=t.findIndex(r),c=l.index,u=l.offset;if(s==n||a.isText){if(u!=r&&!t.child(c).isText)throw new RangeError("Removing non-flat range");return t.cut(0,n).append(t.cut(r))}if(i!=c)throw new RangeError("Removing non-flat range");return t.replaceChild(i,a.copy(e(a.content,n-s-1,r-s-1)))}(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)},p.prototype.eq=function(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd},p.prototype.toString=function(){return this.content+"("+this.openStart+","+this.openEnd+")"},p.prototype.toJSON=function(){if(!this.content.size)return null;var e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e},p.fromJSON=function(e,t){if(!t)return p.empty;var n=t.openStart||0,r=t.openEnd||0;if("number"!=typeof n||"number"!=typeof r)throw new RangeError("Invalid input for Slice.fromJSON");return new p(i.fromJSON(e,t.content),n,r)},p.maxOpen=function(e,t){void 0===t&&(t=!0);for(var n=0,r=0,o=e.firstChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.firstChild)n++;for(var i=e.lastChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.lastChild)r++;return new p(e,n,r)},Object.defineProperties(p.prototype,f),p.empty=new p(i.empty,0,0);var S=function(e,t,n){this.pos=e,this.path=t,this.depth=t.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(e){return null==e?this.depth:e<0?this.depth+e:e},k.parent.get=function(){return this.node(this.depth)},k.doc.get=function(){return this.node(0)},S.prototype.node=function(e){return this.path[3*this.resolveDepth(e)]},S.prototype.index=function(e){return this.path[3*this.resolveDepth(e)+1]},S.prototype.indexAfter=function(e){return e=this.resolveDepth(e),this.index(e)+(e!=this.depth||this.textOffset?1:0)},S.prototype.start=function(e){return 0==(e=this.resolveDepth(e))?0:this.path[3*e-1]+1},S.prototype.end=function(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size},S.prototype.before=function(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]},S.prototype.after=function(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]+this.path[3*e].nodeSize},k.textOffset.get=function(){return this.pos-this.path[this.path.length-1]},k.nodeAfter.get=function(){var e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;var n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r},k.nodeBefore.get=function(){var e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):0==e?null:this.parent.child(e-1)},S.prototype.posAtIndex=function(e,t){t=this.resolveDepth(t);for(var n=this.path[3*t],r=0==t?0:this.path[3*t-1]+1,o=0;o<e;o++)r+=n.child(o).nodeSize;return r},S.prototype.marks=function(){var e=this.parent,t=this.index();if(0==e.content.size)return u.none;if(this.textOffset)return e.child(t).marks;var n=e.maybeChild(t-1),r=e.maybeChild(t);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(e){var t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;for(var n=t.marks,r=e.parent.maybeChild(e.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(e){for(var t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0},S.prototype.blockRange=function(e,t){if(void 0===e&&(e=this),e.pos<this.pos)return e.blockRange(this);for(var n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new O(this,e,n)},S.prototype.sameParent=function(e){return this.pos-this.parentOffset==e.pos-e.parentOffset},S.prototype.max=function(e){return e.pos>this.pos?e:this},S.prototype.min=function(e){return e.pos<this.pos?e:this},S.prototype.toString=function(){for(var e="",t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset},S.resolve=function(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");for(var n=[],r=0,o=t,i=e;;){var s=i.content.findIndex(o),a=s.index,l=s.offset,c=o-l;if(n.push(i,a,r+l),!c)break;if((i=i.child(a)).isText)break;o=c-1,r+=l+1}return new S(t,n,o)},S.resolveCached=function(e,t){for(var n=0;n<x.length;n++){var r=x[n];if(r.pos==t&&r.doc==e)return r}var o=x[C]=S.resolve(e,t);return C=(C+1)%M,o},Object.defineProperties(S.prototype,k);var x=[],C=0,M=12,O=function(e,t,n){this.$from=e,this.$to=t,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 A=Object.create(null),N=function(e,t,n,r){this.type=e,this.attrs=t,this.content=n||i.empty,this.marks=r||u.none},R={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}};R.nodeSize.get=function(){return this.isLeaf?1:2+this.content.size},R.childCount.get=function(){return this.content.childCount},N.prototype.child=function(e){return this.content.child(e)},N.prototype.maybeChild=function(e){return this.content.maybeChild(e)},N.prototype.forEach=function(e){this.content.forEach(e)},N.prototype.nodesBetween=function(e,t,n,r){void 0===r&&(r=0),this.content.nodesBetween(e,t,n,r,this)},N.prototype.descendants=function(e){this.nodesBetween(0,this.content.size,e)},R.textContent.get=function(){return this.textBetween(0,this.content.size,"")},N.prototype.textBetween=function(e,t,n,r){return this.content.textBetween(e,t,n,r)},R.firstChild.get=function(){return this.content.firstChild},R.lastChild.get=function(){return this.content.lastChild},N.prototype.eq=function(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)},N.prototype.sameMarkup=function(e){return this.hasMarkup(e.type,e.attrs,e.marks)},N.prototype.hasMarkup=function(e,t,n){return this.type==e&&c(this.attrs,t||e.defaultAttrs||A)&&u.sameSet(this.marks,n||u.none)},N.prototype.copy=function(e){return void 0===e&&(e=null),e==this.content?this:new this.constructor(this.type,this.attrs,e,this.marks)},N.prototype.mark=function(e){return e==this.marks?this:new this.constructor(this.type,this.attrs,this.content,e)},N.prototype.cut=function(e,t){return 0==e&&t==this.content.size?this:this.copy(this.content.cut(e,t))},N.prototype.slice=function(e,t,n){if(void 0===t&&(t=this.content.size),void 0===n&&(n=!1),e==t)return p.empty;var r=this.resolve(e),o=this.resolve(t),i=n?0:r.sharedDepth(t),s=r.start(i),a=r.node(i).content.cut(r.pos-s,o.pos-s);return new p(a,r.depth-i,o.depth-i)},N.prototype.replace=function(e,t,n){return h(this.resolve(e),this.resolve(t),n)},N.prototype.nodeAt=function(e){for(var t=this;;){var n=t.content.findIndex(e),r=n.index,o=n.offset;if(!(t=t.maybeChild(r)))return null;if(o==e||t.isText)return t;e-=o+1}},N.prototype.childAfter=function(e){var t=this.content.findIndex(e),n=t.index,r=t.offset;return{node:this.content.maybeChild(n),index:n,offset:r}},N.prototype.childBefore=function(e){if(0==e)return{node:null,index:0,offset:0};var t=this.content.findIndex(e),n=t.index,r=t.offset;if(r<e)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}},N.prototype.resolve=function(e){return S.resolveCached(this,e)},N.prototype.resolveNoCache=function(e){return S.resolve(this,e)},N.prototype.rangeHasMark=function(e,t,n){var r=!1;return t>e&&this.nodesBetween(e,t,(function(e){return n.isInSet(e.marks)&&(r=!0),!r})),r},R.isBlock.get=function(){return this.type.isBlock},R.isTextblock.get=function(){return this.type.isTextblock},R.inlineContent.get=function(){return this.type.inlineContent},R.isInline.get=function(){return this.type.isInline},R.isText.get=function(){return this.type.isText},R.isLeaf.get=function(){return this.type.isLeaf},R.isAtom.get=function(){return this.type.isAtom},N.prototype.toString=function(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);var e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),E(this.marks,e)},N.prototype.contentMatchAt=function(e){var t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t},N.prototype.canReplace=function(e,t,n,r,o){void 0===n&&(n=i.empty),void 0===r&&(r=0),void 0===o&&(o=n.childCount);var s=this.contentMatchAt(e).matchFragment(n,r,o),a=s&&s.matchFragment(this.content,t);if(!a||!a.validEnd)return!1;for(var l=r;l<o;l++)if(!this.type.allowsMarks(n.child(l).marks))return!1;return!0},N.prototype.canReplaceWith=function(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;var o=this.contentMatchAt(e).matchType(n),i=o&&o.matchFragment(this.content,t);return!!i&&i.validEnd},N.prototype.canAppend=function(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)},N.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 e=u.none,t=0;t<this.marks.length;t++)e=this.marks[t].addToSet(e);if(!u.sameSet(e,this.marks))throw new RangeError("Invalid collection of marks for node "+this.type.name+": "+this.marks.map((function(e){return e.type.name})));this.content.forEach((function(e){return e.check()}))},N.prototype.toJSON=function(){var e={type:this.type.name};for(var t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map((function(e){return e.toJSON()}))),e},N.fromJSON=function(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");var n=null;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=t.marks.map(e.markFromJSON)}if("text"==t.type){if("string"!=typeof t.text)throw new RangeError("Invalid text node in JSON");return e.text(t.text,n)}var r=i.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,r,n)},Object.defineProperties(N.prototype,R);var D=function(e){function t(t,n,r,o){if(e.call(this,t,n,null,o),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={textContent:{configurable:!0},nodeSize:{configurable:!0}};return t.prototype.toString=function(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):E(this.marks,JSON.stringify(this.text))},n.textContent.get=function(){return this.text},t.prototype.textBetween=function(e,t){return this.text.slice(e,t)},n.nodeSize.get=function(){return this.text.length},t.prototype.mark=function(e){return e==this.marks?this:new t(this.type,this.attrs,this.text,e)},t.prototype.withText=function(e){return e==this.text?this:new t(this.type,this.attrs,e,this.marks)},t.prototype.cut=function(e,t){return void 0===e&&(e=0),void 0===t&&(t=this.text.length),0==e&&t==this.text.length?this:this.withText(this.text.slice(e,t))},t.prototype.eq=function(e){return this.sameMarkup(e)&&this.text==e.text},t.prototype.toJSON=function(){var t=e.prototype.toJSON.call(this);return t.text=this.text,t},Object.defineProperties(t.prototype,n),t}(N);function E(e,t){for(var n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}var z=function(e){this.validEnd=e,this.next=[],this.wrapCache=[]},_={inlineContent:{configurable:!0},defaultType:{configurable:!0},edgeCount:{configurable:!0}};z.parse=function(e,t){var n=new I(e,t);if(null==n.next)return z.empty;var r=$(n);n.next&&n.err("Unexpected trailing text");var o=function(e){var t=Object.create(null);return function n(r){var o=[];r.forEach((function(t){e[t].forEach((function(t){var n=t.term,r=t.to;if(n){var i=o.indexOf(n),s=i>-1&&o[i+1];K(e,r).forEach((function(e){s||o.push(n,s=[]),-1==s.indexOf(e)&&s.push(e)}))}}))}));for(var i=t[r.join(",")]=new z(r.indexOf(e.length-1)>-1),s=0;s<o.length;s+=2){var a=o[s+1].sort(j);i.next.push(o[s],t[a.join(",")]||n(a))}return i}(K(e,0))}(function(e){var t=[[]];return o(function e(t,i){if("choice"==t.type)return t.exprs.reduce((function(t,n){return t.concat(e(n,i))}),[]);if("seq"==t.type)for(var s=0;;s++){var a=e(t.exprs[s],i);if(s==t.exprs.length-1)return a;o(a,i=n())}else{if("star"==t.type){var l=n();return r(i,l),o(e(t.expr,l),l),[r(l)]}if("plus"==t.type){var c=n();return o(e(t.expr,i),c),o(e(t.expr,c),c),[r(c)]}if("opt"==t.type)return[r(i)].concat(e(t.expr,i));if("range"==t.type){for(var u=i,d=0;d<t.min;d++){var p=n();o(e(t.expr,u),p),u=p}if(-1==t.max)o(e(t.expr,u),u);else for(var f=t.min;f<t.max;f++){var h=n();r(u,h),o(e(t.expr,u),h),u=h}return[r(u)]}if("name"==t.type)return[r(i,null,t.value)]}}(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){var o={term:r,to:n};return t[e].push(o),o}function o(e,t){e.forEach((function(e){return e.to=t}))}}(r));return function(e,t){for(var n=0,r=[e];n<r.length;n++){for(var o=r[n],i=!o.validEnd,s=[],a=0;a<o.next.length;a+=2){var l=o.next[a],c=o.next[a+1];s.push(l.name),!i||l.isText||l.hasRequiredAttrs()||(i=!1),-1==r.indexOf(c)&&r.push(c)}i&&t.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(o,n),o},z.prototype.matchType=function(e){for(var t=0;t<this.next.length;t+=2)if(this.next[t]==e)return this.next[t+1];return null},z.prototype.matchFragment=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=e.childCount);for(var r=this,o=t;r&&o<n;o++)r=r.matchType(e.child(o).type);return r},_.inlineContent.get=function(){var e=this.next[0];return!!e&&e.isInline},_.defaultType.get=function(){for(var e=0;e<this.next.length;e+=2){var t=this.next[e];if(!t.isText&&!t.hasRequiredAttrs())return t}},z.prototype.compatible=function(e){for(var t=0;t<this.next.length;t+=2)for(var n=0;n<e.next.length;n+=2)if(this.next[t]==e.next[n])return!0;return!1},z.prototype.fillBefore=function(e,t,n){void 0===t&&(t=!1),void 0===n&&(n=0);var r=[this];return function o(s,a){var l=s.matchFragment(e,n);if(l&&(!t||l.validEnd))return i.from(a.map((function(e){return e.createAndFill()})));for(var c=0;c<s.next.length;c+=2){var u=s.next[c],d=s.next[c+1];if(!u.isText&&!u.hasRequiredAttrs()&&-1==r.indexOf(d)){r.push(d);var p=o(d,a.concat(u));if(p)return p}}}(this,[])},z.prototype.findWrapping=function(e){for(var t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];var n=this.computeWrapping(e);return this.wrapCache.push(e,n),n},z.prototype.computeWrapping=function(e){for(var t=Object.create(null),n=[{match:this,type:null,via:null}];n.length;){var r=n.shift(),o=r.match;if(o.matchType(e)){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 l=o.next[a];l.isLeaf||l.hasRequiredAttrs()||l.name in t||r.type&&!o.next[a+1].validEnd||(n.push({match:l.contentMatch,type:l,via:r}),t[l.name]=!0)}}},_.edgeCount.get=function(){return this.next.length>>1},z.prototype.edge=function(e){var t=e<<1;if(t>=this.next.length)throw new RangeError("There's no "+e+"th edge in this content match");return{type:this.next[t],next:this.next[t+1]}},z.prototype.toString=function(){var e=[];return function t(n){e.push(n);for(var r=1;r<n.next.length;r+=2)-1==e.indexOf(n.next[r])&&t(n.next[r])}(this),e.map((function(t,n){for(var r=n+(t.validEnd?"*":" ")+" ",o=0;o<t.next.length;o+=2)r+=(o?", ":"")+t.next[o].name+"->"+e.indexOf(t.next[o+1]);return r})).join("\n")},Object.defineProperties(z.prototype,_),z.empty=new z(!0);var I=function(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),""==this.tokens[this.tokens.length-1]&&this.tokens.pop(),""==this.tokens[0]&&this.tokens.shift()},P={next:{configurable:!0}};function $(e){var t=[];do{t.push(F(e))}while(e.eat("|"));return 1==t.length?t[0]:{type:"choice",exprs:t}}function F(e){var t=[];do{t.push(B(e))}while(e.next&&")"!=e.next&&"|"!=e.next);return 1==t.length?t[0]:{type:"seq",exprs:t}}function B(e){for(var t=function(e){if(e.eat("(")){var t=$(e);return e.eat(")")||e.err("Missing closing paren"),t}if(!/\W/.test(e.next)){var n=function(e,t){var n=e.nodeTypes,r=n[t];if(r)return[r];var o=[];for(var i in n){var s=n[i];s.groups.indexOf(t)>-1&&o.push(s)}0==o.length&&e.err("No node type or group '"+t+"' found");return o}(e,e.next).map((function(t){return null==e.inline?e.inline=t.isInline:e.inline!=t.isInline&&e.err("Mixing inline and block content"),{type:"name",value:t}}));return e.pos++,1==n.length?n[0]:{type:"choice",exprs:n}}e.err("Unexpected token '"+e.next+"'")}(e);;)if(e.eat("+"))t={type:"plus",expr:t};else if(e.eat("*"))t={type:"star",expr:t};else if(e.eat("?"))t={type:"opt",expr:t};else{if(!e.eat("{"))break;t=V(e,t)}return t}function L(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");var t=Number(e.next);return e.pos++,t}function V(e,t){var n=L(e),r=n;return e.eat(",")&&(r="}"!=e.next?L(e):-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:t}}function j(e,t){return t-e}function K(e,t){var n=[];return function t(r){var o=e[r];if(1==o.length&&!o[0].term)return t(o[0].to);n.push(r);for(var i=0;i<o.length;i++){var s=o[i],a=s.term,l=s.to;a||-1!=n.indexOf(l)||t(l)}}(t),n.sort(j)}function H(e){var t=Object.create(null);for(var n in e){var r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function W(e,t){var n=Object.create(null);for(var r in e){var o=t&&t[r];if(void 0===o){var i=e[r];if(!i.hasDefault)throw new RangeError("No value supplied for attribute "+r);o=i.default}n[r]=o}return n}function q(e){var t=Object.create(null);if(e)for(var n in e)t[n]=new U(e[n]);return t}P.next.get=function(){return this.tokens[this.pos]},I.prototype.eat=function(e){return this.next==e&&(this.pos++||!0)},I.prototype.err=function(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")},Object.defineProperties(I.prototype,P);var J=function(e,t,n){this.name=e,this.schema=t,this.spec=n,this.groups=n.group?n.group.split(" "):[],this.attrs=q(n.attrs),this.defaultAttrs=H(this.attrs),this.contentMatch=null,this.markSet=null,this.inlineContent=null,this.isBlock=!(n.inline||"text"==e),this.isText="text"==e},X={isInline:{configurable:!0},isTextblock:{configurable:!0},isLeaf:{configurable:!0},isAtom:{configurable:!0},whitespace:{configurable:!0}};X.isInline.get=function(){return!this.isBlock},X.isTextblock.get=function(){return this.isBlock&&this.inlineContent},X.isLeaf.get=function(){return this.contentMatch==z.empty},X.isAtom.get=function(){return this.isLeaf||this.spec.atom},X.whitespace.get=function(){return this.spec.whitespace||(this.spec.code?"pre":"normal")},J.prototype.hasRequiredAttrs=function(){for(var e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1},J.prototype.compatibleContent=function(e){return this==e||this.contentMatch.compatible(e.contentMatch)},J.prototype.computeAttrs=function(e){return!e&&this.defaultAttrs?this.defaultAttrs:W(this.attrs,e)},J.prototype.create=function(e,t,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new N(this,this.computeAttrs(e),i.from(t),u.setFrom(n))},J.prototype.createChecked=function(e,t,n){if(t=i.from(t),!this.validContent(t))throw new RangeError("Invalid content for node "+this.name);return new N(this,this.computeAttrs(e),t,u.setFrom(n))},J.prototype.createAndFill=function(e,t,n){if(e=this.computeAttrs(e),(t=i.from(t)).size){var r=this.contentMatch.fillBefore(t);if(!r)return null;t=r.append(t)}var o=this.contentMatch.matchFragment(t).fillBefore(i.empty,!0);return o?new N(this,e,t.append(o),u.setFrom(n)):null},J.prototype.validContent=function(e){var t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(var n=0;n<e.childCount;n++)if(!this.allowsMarks(e.child(n).marks))return!1;return!0},J.prototype.allowsMarkType=function(e){return null==this.markSet||this.markSet.indexOf(e)>-1},J.prototype.allowsMarks=function(e){if(null==this.markSet)return!0;for(var t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0},J.prototype.allowedMarks=function(e){if(null==this.markSet)return e;for(var t,n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||(t=e.slice(0,n));return t?t.length?t:u.empty:e},J.compile=function(e,t){var n=Object.create(null);e.forEach((function(e,r){return n[e]=new J(e,t,r)}));var r=t.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,X);var U=function(e){this.hasDefault=Object.prototype.hasOwnProperty.call(e,"default"),this.default=e.default},Y={isRequired:{configurable:!0}};Y.isRequired.get=function(){return!this.hasDefault},Object.defineProperties(U.prototype,Y);var G=function(e,t,n,r){this.name=e,this.schema=n,this.spec=r,this.attrs=q(r.attrs),this.rank=t,this.excluded=null;var o=H(this.attrs);this.instance=o&&new u(this,o)};G.prototype.create=function(e){return!e&&this.instance?this.instance:new u(this,W(this.attrs,e))},G.compile=function(e,t){var n=Object.create(null),r=0;return e.forEach((function(e,o){return n[e]=new G(e,r++,t,o)})),n},G.prototype.removeFromSet=function(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e},G.prototype.isInSet=function(e){for(var t=0;t<e.length;t++)if(e[t].type==this)return e[t]},G.prototype.excludes=function(e){return this.excluded.indexOf(e)>-1};var Q=function(e){for(var t in this.spec={},e)this.spec[t]=e[t];this.spec.nodes=o.from(e.nodes),this.spec.marks=o.from(e.marks),this.nodes=J.compile(this.spec.nodes,this),this.marks=G.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]=z.parse(s,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.markSet="_"==a?null:a?Z(this,a.split(" ")):""!=a&&i.inlineContent?null:[]}for(var l in this.marks){var c=this.marks[l],u=c.spec.excludes;c.excluded=null==u?[c]:""==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(e,t){for(var n=[],r=0;r<t.length;r++){var o=t[r],i=e.marks[o],s=i;if(i)n.push(i);else for(var a in e.marks){var l=e.marks[a];("_"==o||l.spec.group&&l.spec.group.split(" ").indexOf(o)>-1)&&n.push(s=l)}if(!s)throw new SyntaxError("Unknown mark type: '"+t[r]+"'")}return n}Q.prototype.node=function(e,t,n,r){if("string"==typeof e)e=this.nodeType(e);else{if(!(e instanceof J))throw new RangeError("Invalid node type: "+e);if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}return e.createChecked(t,n,r)},Q.prototype.text=function(e,t){var n=this.nodes.text;return new D(n,n.defaultAttrs,e,u.setFrom(t))},Q.prototype.mark=function(e,t){return"string"==typeof e&&(e=this.marks[e]),e.create(t)},Q.prototype.nodeFromJSON=function(e){return N.fromJSON(this,e)},Q.prototype.markFromJSON=function(e){return u.fromJSON(this,e)},Q.prototype.nodeType=function(e){var t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t};var ee=function(e,t){var n=this;this.schema=e,this.rules=t,this.tags=[],this.styles=[],t.forEach((function(e){e.tag?n.tags.push(e):e.style&&n.styles.push(e)})),this.normalizeLists=!this.tags.some((function(t){if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;var n=e.nodes[t.node];return n.contentMatch.matchType(n)}))};ee.prototype.parse=function(e,t){void 0===t&&(t={});var n=new se(this,t,!1);return n.addAll(e,null,t.from,t.to),n.finish()},ee.prototype.parseSlice=function(e,t){void 0===t&&(t={});var n=new se(this,t,!0);return n.addAll(e,null,t.from,t.to),p.maxOpen(n.finish())},ee.prototype.matchTag=function(e,t,n){for(var r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){var o=this.tags[r];if(le(e,o.tag)&&(void 0===o.namespace||e.namespaceURI==o.namespace)&&(!o.context||t.matchesContext(o.context))){if(o.getAttrs){var i=o.getAttrs(e);if(!1===i)continue;o.attrs=i}return o}}},ee.prototype.matchStyle=function(e,t,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(e)||i.context&&!n.matchesContext(i.context)||i.style.length>e.length&&(61!=i.style.charCodeAt(e.length)||i.style.slice(e.length+1)!=t))){if(i.getAttrs){var s=i.getAttrs(t);if(!1===s)continue;i.attrs=s}return i}}},ee.schemaRules=function(e){var t=[];function n(e){for(var n=null==e.priority?50:e.priority,r=0;r<t.length;r++){var o=t[r];if((null==o.priority?50:o.priority)<n)break}t.splice(r,0,e)}var r=function(t){var r=e.marks[t].spec.parseDOM;r&&r.forEach((function(e){n(e=ce(e)),e.mark=t}))};for(var o in e.marks)r(o);var i;for(var s in e.nodes)i=void 0,(i=e.nodes[s].spec.parseDOM)&&i.forEach((function(e){n(e=ce(e)),e.node=s}));return t},ee.fromSchema=function(e){return e.cached.domParser||(e.cached.domParser=new ee(e,ee.schemaRules(e)))};var te={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},ne={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},re={ol:!0,ul:!0};function oe(e,t,n){return null!=t?(t?1:0)|("full"===t?2:0):e&&"pre"==e.whitespace?3:-5&n}var ie=function(e,t,n,r,o,i,s){this.type=e,this.attrs=t,this.solid=o,this.match=i||(4&s?null:e.contentMatch),this.options=s,this.content=[],this.marks=n,this.activeMarks=u.none,this.pendingMarks=r,this.stashMarks=[]};ie.prototype.findWrapping=function(e){if(!this.match){if(!this.type)return[];var t=this.type.contentMatch.fillBefore(i.from(e));if(!t){var n,r=this.type.contentMatch;return(n=r.findWrapping(e.type))?(this.match=r,n):null}this.match=this.type.contentMatch.matchFragment(t)}return this.match.findWrapping(e.type)},ie.prototype.finish=function(e){if(!(1&this.options)){var t,n=this.content[this.content.length-1];n&&n.isText&&(t=/[ \t\r\n\u000c]+$/.exec(n.text))&&(n.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-t[0].length)))}var r=i.from(this.content);return!e&&this.match&&(r=r.append(this.match.fillBefore(i.empty,!0))),this.type?this.type.create(this.attrs,r,this.marks):r},ie.prototype.popFromStashMark=function(e){for(var t=this.stashMarks.length-1;t>=0;t--)if(e.eq(this.stashMarks[t]))return this.stashMarks.splice(t,1)[0]},ie.prototype.applyPending=function(e){for(var t=0,n=this.pendingMarks;t<n.length;t++){var r=n[t];(this.type?this.type.allowsMarkType(r.type):ue(r.type,e))&&!r.isInSet(this.activeMarks)&&(this.activeMarks=r.addToSet(this.activeMarks),this.pendingMarks=r.removeFromSet(this.pendingMarks))}},ie.prototype.inlineContext=function(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!te.hasOwnProperty(e.parentNode.nodeName.toLowerCase())};var se=function(e,t,n){this.parser=e,this.options=t,this.isOpen=n;var r,o=t.topNode,i=oe(null,t.preserveWhitespace,0)|(n?4:0);r=o?new ie(o.type,o.attrs,u.none,u.none,!0,t.topMatch||o.type.contentMatch,i):new ie(n?null:e.schema.topNodeType,null,u.none,u.none,!0,null,i),this.nodes=[r],this.open=0,this.find=t.findPositions,this.needsBlock=!1},ae={top:{configurable:!0},currentPos:{configurable:!0}};function le(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function ce(e){var t={};for(var n in e)t[n]=e[n];return t}function ue(e,t){var n=t.schema.nodes,r=function(r){var o=n[r];if(o.allowsMarkType(e)){var i=[],s=function(e){i.push(e);for(var n=0;n<e.edgeCount;n++){var r=e.edge(n),o=r.type,a=r.next;if(o==t)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}}ae.top.get=function(){return this.nodes[this.open]},se.prototype.addDOM=function(e){if(3==e.nodeType)this.addTextNode(e);else if(1==e.nodeType){var t=e.getAttribute("style"),n=t?this.readStyles(function(e){var t,n=/\s*([\w-]+)\s*:\s*([^;]+)/g,r=[];for(;t=n.exec(e);)r.push(t[1],t[2].trim());return r}(t)):null,r=this.top;if(null!=n)for(var o=0;o<n.length;o++)this.addPendingMark(n[o]);if(this.addElement(e),null!=n)for(var i=0;i<n.length;i++)this.removePendingMark(n[i],r)}},se.prototype.addTextNode=function(e){var t=e.nodeValue,n=this.top;if(2&n.options||n.inlineContext(e)||/[^ \t\r\n\u000c]/.test(t)){if(1&n.options)t=2&n.options?t.replace(/\r\n?/g,"\n"):t.replace(/\r?\n|\r/g," ");else if(t=t.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(t)&&this.open==this.nodes.length-1){var r=n.content[n.content.length-1],o=e.previousSibling;(!r||o&&"BR"==o.nodeName||r.isText&&/[ \t\r\n\u000c]$/.test(r.text))&&(t=t.slice(1))}t&&this.insertNode(this.parser.schema.text(t)),this.findInText(e)}else this.findInside(e)},se.prototype.addElement=function(e,t){var n,r=e.nodeName.toLowerCase();re.hasOwnProperty(r)&&this.parser.normalizeLists&&function(e){for(var t=e.firstChild,n=null;t;t=t.nextSibling){var r=1==t.nodeType?t.nodeName.toLowerCase():null;r&&re.hasOwnProperty(r)&&n?(n.appendChild(t),t=n):"li"==r?n=t:r&&(n=null)}}(e);var o=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(n=this.parser.matchTag(e,this,t));if(o?o.ignore:ne.hasOwnProperty(r))this.findInside(e),this.ignoreFallback(e);else if(!o||o.skip||o.closeParent){o&&o.closeParent?this.open=Math.max(0,this.open-1):o&&o.skip.nodeType&&(e=o.skip);var i,s=this.top,a=this.needsBlock;if(te.hasOwnProperty(r))i=!0,s.type||(this.needsBlock=!0);else if(!e.firstChild)return void this.leafFallback(e);this.addAll(e),i&&this.sync(s),this.needsBlock=a}else this.addElementByRule(e,o,!1===o.consuming?n:null)},se.prototype.leafFallback=function(e){"BR"==e.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode("\n"))},se.prototype.ignoreFallback=function(e){"BR"!=e.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"))},se.prototype.readStyles=function(e){var t=u.none;e:for(var n=0;n<e.length;n+=2)for(var r=null;;){var o=this.parser.matchStyle(e[n],e[n+1],this,r);if(!o)continue e;if(o.ignore)return null;if(t=this.parser.schema.marks[o.mark].create(o.attrs).addToSet(t),!1!==o.consuming)break;r=o}return t},se.prototype.addElementByRule=function(e,t,n){var r,o,i,s=this;t.node?(o=this.parser.schema.nodes[t.node]).isLeaf?this.insertNode(o.create(t.attrs))||this.leafFallback(e):r=this.enter(o,t.attrs,t.preserveWhitespace):(i=this.parser.schema.marks[t.mark].create(t.attrs),this.addPendingMark(i));var a=this.top;if(o&&o.isLeaf)this.findInside(e);else if(n)this.addElement(e,n);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach((function(e){return s.insertNode(e)}));else{var l=t.contentElement;"string"==typeof l?l=e.querySelector(l):"function"==typeof l&&(l=l(e)),l||(l=e),this.findAround(e,l,!0),this.addAll(l,r)}r&&(this.sync(a),this.open--),i&&this.removePendingMark(i,a)},se.prototype.addAll=function(e,t,n,r){for(var o=n||0,i=n?e.childNodes[n]:e.firstChild,s=null==r?null:e.childNodes[r];i!=s;i=i.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(i),t&&te.hasOwnProperty(i.nodeName.toLowerCase())&&this.sync(t);this.findAtPoint(e,o)},se.prototype.findPlace=function(e){for(var t,n,r=this.open;r>=0;r--){var o=this.nodes[r],i=o.findWrapping(e);if(i&&(!t||t.length>i.length)&&(t=i,n=o,!i.length))break;if(o.solid)break}if(!t)return!1;this.sync(n);for(var s=0;s<t.length;s++)this.enterInner(t[s],null,!1);return!0},se.prototype.insertNode=function(e){if(e.isInline&&this.needsBlock&&!this.top.type){var t=this.textblockFromContext();t&&this.enterInner(t)}if(this.findPlace(e)){this.closeExtra();var n=this.top;n.applyPending(e.type),n.match&&(n.match=n.match.matchType(e.type));for(var r=n.activeMarks,o=0;o<e.marks.length;o++)n.type&&!n.type.allowsMarkType(e.marks[o].type)||(r=e.marks[o].addToSet(r));return n.content.push(e.mark(r)),!0}return!1},se.prototype.enter=function(e,t,n){var r=this.findPlace(e.create(t));return r&&this.enterInner(e,t,!0,n),r},se.prototype.enterInner=function(e,t,n,r){this.closeExtra();var o=this.top;o.applyPending(e),o.match=o.match&&o.match.matchType(e,t);var i=oe(e,r,o.options);4&o.options&&0==o.content.length&&(i|=4),this.nodes.push(new ie(e,t,o.activeMarks,o.pendingMarks,n,null,i)),this.open++},se.prototype.closeExtra=function(e){var t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}},se.prototype.finish=function(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)},se.prototype.sync=function(e){for(var t=this.open;t>=0;t--)if(this.nodes[t]==e)return void(this.open=t)},ae.currentPos.get=function(){this.closeExtra();for(var e=0,t=this.open;t>=0;t--){for(var n=this.nodes[t].content,r=n.length-1;r>=0;r--)e+=n[r].nodeSize;t&&e++}return e},se.prototype.findAtPoint=function(e,t){if(this.find)for(var n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)},se.prototype.findInside=function(e){if(this.find)for(var t=0;t<this.find.length;t++)null==this.find[t].pos&&1==e.nodeType&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)},se.prototype.findAround=function(e,t,n){if(e!=t&&this.find)for(var r=0;r<this.find.length;r++){if(null==this.find[r].pos&&1==e.nodeType&&e.contains(this.find[r].node))t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}},se.prototype.findInText=function(e){if(this.find)for(var t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))},se.prototype.matchesContext=function(e){var t=this;if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);var n=e.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(e,a){for(;e>=0;e--){var l=n[e];if(""==l){if(e==n.length-1||0==e)continue;for(;a>=i;a--)if(s(e-1,a))return!0;return!1}var c=a>0||0==a&&o?t.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!c||c.name!=l&&-1==c.groups.indexOf(l))return!1;a--}return!0};return s(n.length-1,this.open)},se.prototype.textblockFromContext=function(){var e=this.options.context;if(e)for(var t=e.depth;t>=0;t--){var n=e.node(t).contentMatchAt(e.indexAfter(t)).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}},se.prototype.addPendingMark=function(e){var t=function(e,t){for(var n=0;n<t.length;n++)if(e.eq(t[n]))return t[n]}(e,this.top.pendingMarks);t&&this.top.stashMarks.push(t),this.top.pendingMarks=e.addToSet(this.top.pendingMarks)},se.prototype.removePendingMark=function(e,t){for(var n=this.open;n>=0;n--){var r=this.nodes[n];if(r.pendingMarks.lastIndexOf(e)>-1)r.pendingMarks=e.removeFromSet(r.pendingMarks);else{r.activeMarks=e.removeFromSet(r.activeMarks);var o=r.popFromStashMark(e);o&&r.type&&r.type.allowsMarkType(o.type)&&(r.activeMarks=o.addToSet(r.activeMarks))}if(r==t)break}},Object.defineProperties(se.prototype,ae);var de=function(e,t){this.nodes=e||{},this.marks=t||{}};function pe(e){var t={};for(var n in e){var r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function fe(e){return e.document||window.document}de.prototype.serializeFragment=function(e,t,n){var r=this;void 0===t&&(t={}),n||(n=fe(t).createDocumentFragment());var o=n,i=null;return e.forEach((function(e){if(i||e.marks.length){i||(i=[]);for(var n=0,s=0;n<i.length&&s<e.marks.length;){var a=e.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<e.marks.length;){var l=e.marks[s++],c=r.serializeMark(l,e.isInline,t);c&&(i.push(l,o),o.appendChild(c.dom),o=c.contentDOM||c.dom)}}o.appendChild(r.serializeNodeInner(e,t))})),n},de.prototype.serializeNodeInner=function(e,t){void 0===t&&(t={});var n=de.renderSpec(fe(t),this.nodes[e.type.name](e)),r=n.dom,o=n.contentDOM;if(o){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");t.onContent?t.onContent(e,o,t):this.serializeFragment(e.content,t,o)}return r},de.prototype.serializeNode=function(e,t){void 0===t&&(t={});for(var n=this.serializeNodeInner(e,t),r=e.marks.length-1;r>=0;r--){var o=this.serializeMark(e.marks[r],e.isInline,t);o&&((o.contentDOM||o.dom).appendChild(n),n=o.dom)}return n},de.prototype.serializeMark=function(e,t,n){void 0===n&&(n={});var r=this.marks[e.type.name];return r&&de.renderSpec(fe(n),r(e,t))},de.renderSpec=function(e,t,n){if(void 0===n&&(n=null),"string"==typeof t)return{dom:e.createTextNode(t)};if(null!=t.nodeType)return{dom:t};if(t.dom&&null!=t.dom.nodeType)return t;var r=t[0],o=r.indexOf(" ");o>0&&(n=r.slice(0,o),r=r.slice(o+1));var i=null,s=n?e.createElementNS(n,r):e.createElement(r),a=t[1],l=1;if(a&&"object"==typeof a&&null==a.nodeType&&!Array.isArray(a))for(var c in l=2,a)if(null!=a[c]){var u=c.indexOf(" ");u>0?s.setAttributeNS(c.slice(0,u),c.slice(u+1),a[c]):s.setAttribute(c,a[c])}for(var d=l;d<t.length;d++){var p=t[d];if(0===p){if(d<t.length-1||d>l)throw new RangeError("Content hole must be the only child of its parent node");return{dom:s,contentDOM:s}}var f=de.renderSpec(e,p,n),h=f.dom,m=f.contentDOM;if(s.appendChild(h),m){if(i)throw new RangeError("Multiple content holes");i=m}}return{dom:s,contentDOM:i}},de.fromSchema=function(e){return e.cached.domSerializer||(e.cached.domSerializer=new de(this.nodesFromSchema(e),this.marksFromSchema(e)))},de.nodesFromSchema=function(e){var t=pe(e.nodes);return t.text||(t.text=function(e){return e.text}),t},de.marksFromSchema=function(e){return pe(e.marks)}},function(e,t,n){"use strict";n.r(t),n.d(t,"AllSelection",(function(){return f})),n.d(t,"EditorState",(function(){return k})),n.d(t,"NodeSelection",(function(){return d})),n.d(t,"Plugin",(function(){return M})),n.d(t,"PluginKey",(function(){return A})),n.d(t,"Selection",(function(){return s})),n.d(t,"SelectionRange",(function(){return l})),n.d(t,"TextSelection",(function(){return c})),n.d(t,"Transaction",(function(){return g}));var r=n(0),o=n(2),i=Object.create(null),s=function(e,t,n){this.ranges=n||[new l(e.min(t),e.max(t))],this.$anchor=e,this.$head=t},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 e=this.ranges,t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$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(e,t){void 0===t&&(t=r.Slice.empty);for(var n=t.content.lastChild,o=null,i=0;i<t.openEnd;i++)o=n,n=n.lastChild;for(var s=e.steps.length,a=this.ranges,l=0;l<a.length;l++){var c=a[l],u=c.$from,d=c.$to,p=e.mapping.slice(s);e.replaceRange(p.map(u.pos),p.map(d.pos),l?r.Slice.empty:t),0==l&&v(e,s,(n?n.isInline:o&&o.isTextblock)?-1:1)}},s.prototype.replaceWith=function(e,t){for(var n=e.steps.length,r=this.ranges,o=0;o<r.length;o++){var i=r[o],s=i.$from,a=i.$to,l=e.mapping.slice(n),c=l.map(s.pos),u=l.map(a.pos);o?e.deleteRange(c,u):(e.replaceRangeWith(c,u,t),v(e,n,t.isInline?-1:1))}},s.findFrom=function(e,t,n){var r=e.parent.inlineContent?new c(e):m(e.node(0),e.parent,e.pos,e.index(),t,n);if(r)return r;for(var o=e.depth-1;o>=0;o--){var i=t<0?m(e.node(0),e.node(o),e.before(o+1),e.index(o),t,n):m(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,t,n);if(i)return i}},s.near=function(e,t){return void 0===t&&(t=1),this.findFrom(e,t)||this.findFrom(e,-t)||new f(e.node(0))},s.atStart=function(e){return m(e,e,0,0,1)||new f(e)},s.atEnd=function(e){return m(e,e,e.content.size,e.childCount,-1)||new f(e)},s.fromJSON=function(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");var n=i[t.type];if(!n)throw new RangeError("No selection type "+t.type+" defined");return n.fromJSON(e,t)},s.jsonID=function(e,t){if(e in i)throw new RangeError("Duplicate use of selection JSON ID "+e);return i[e]=t,t.prototype.jsonID=e,t},s.prototype.getBookmark=function(){return c.between(this.$anchor,this.$head).getBookmark()},Object.defineProperties(s.prototype,a),s.prototype.visible=!0;var l=function(e,t){this.$from=e,this.$to=t},c=function(e){function t(t,n){void 0===n&&(n=t),e.call(this,t,n)}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={$cursor:{configurable:!0}};return n.$cursor.get=function(){return this.$anchor.pos==this.$head.pos?this.$head:null},t.prototype.map=function(n,r){var o=n.resolve(r.map(this.head));if(!o.parent.inlineContent)return e.near(o);var i=n.resolve(r.map(this.anchor));return new t(i.parent.inlineContent?i:o,o)},t.prototype.replace=function(t,n){if(void 0===n&&(n=r.Slice.empty),e.prototype.replace.call(this,t,n),n==r.Slice.empty){var o=this.$from.marksAcross(this.$to);o&&t.ensureMarks(o)}},t.prototype.eq=function(e){return e instanceof t&&e.anchor==this.anchor&&e.head==this.head},t.prototype.getBookmark=function(){return new u(this.anchor,this.head)},t.prototype.toJSON=function(){return{type:"text",anchor:this.anchor,head:this.head}},t.fromJSON=function(e,n){if("number"!=typeof n.anchor||"number"!=typeof n.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new t(e.resolve(n.anchor),e.resolve(n.head))},t.create=function(e,t,n){void 0===n&&(n=t);var r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))},t.between=function(n,r,o){var i=n.pos-r.pos;if(o&&!i||(o=i>=0?1:-1),!r.parent.inlineContent){var s=e.findFrom(r,o,!0)||e.findFrom(r,-o,!0);if(!s)return e.near(r,o);r=s.$head}return n.parent.inlineContent||(0==i||(n=(e.findFrom(n,-o,!0)||e.findFrom(n,o,!0)).$anchor).pos<r.pos!=i<0)&&(n=r),new t(n,r)},Object.defineProperties(t.prototype,n),t}(s);s.jsonID("text",c);var u=function(e,t){this.anchor=e,this.head=t};u.prototype.map=function(e){return new u(e.map(this.anchor),e.map(this.head))},u.prototype.resolve=function(e){return c.between(e.resolve(this.anchor),e.resolve(this.head))};var d=function(e){function t(t){var n=t.nodeAfter,r=t.node(0).resolve(t.pos+n.nodeSize);e.call(this,t,r),this.node=n}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.map=function(n,r){var o=r.mapResult(this.anchor),i=o.deleted,s=o.pos,a=n.resolve(s);return i?e.near(a):new t(a)},t.prototype.content=function(){return new r.Slice(r.Fragment.from(this.node),0,0)},t.prototype.eq=function(e){return e instanceof t&&e.anchor==this.anchor},t.prototype.toJSON=function(){return{type:"node",anchor:this.anchor}},t.prototype.getBookmark=function(){return new p(this.anchor)},t.fromJSON=function(e,n){if("number"!=typeof n.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new t(e.resolve(n.anchor))},t.create=function(e,t){return new this(e.resolve(t))},t.isSelectable=function(e){return!e.isText&&!1!==e.type.spec.selectable},t}(s);d.prototype.visible=!1,s.jsonID("node",d);var p=function(e){this.anchor=e};p.prototype.map=function(e){var t=e.mapResult(this.anchor),n=t.deleted,r=t.pos;return n?new u(r,r):new p(r)},p.prototype.resolve=function(e){var t=e.resolve(this.anchor),n=t.nodeAfter;return n&&d.isSelectable(n)?new d(t):s.near(t)};var f=function(e){function t(t){e.call(this,t.resolve(0),t.resolve(t.content.size))}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.replace=function(t,n){if(void 0===n&&(n=r.Slice.empty),n==r.Slice.empty){t.delete(0,t.doc.content.size);var o=e.atStart(t.doc);o.eq(t.selection)||t.setSelection(o)}else e.prototype.replace.call(this,t,n)},t.prototype.toJSON=function(){return{type:"all"}},t.fromJSON=function(e){return new t(e)},t.prototype.map=function(e){return new t(e)},t.prototype.eq=function(e){return e instanceof t},t.prototype.getBookmark=function(){return h},t}(s);s.jsonID("all",f);var h={map:function(){return this},resolve:function(e){return new f(e)}};function m(e,t,n,r,o,i){if(t.inlineContent)return c.create(e,n);for(var s=r-(o>0?0:1);o>0?s<t.childCount:s>=0;s+=o){var a=t.child(s);if(a.isAtom){if(!i&&d.isSelectable(a))return d.create(e,n-(o<0?a.nodeSize:0))}else{var l=m(e,a,n+o,o<0?a.childCount:0,o,i);if(l)return l}n+=a.nodeSize*o}}function v(e,t,n){var r=e.steps.length-1;if(!(r<t)){var i,a=e.steps[r];if(a instanceof o.ReplaceStep||a instanceof o.ReplaceAroundStep)e.mapping.maps[r].forEach((function(e,t,n,r){null==i&&(i=r)})),e.setSelection(s.near(e.doc.resolve(i),n))}}var g=function(e){function t(t){e.call(this,t.doc),this.time=Date.now(),this.curSelection=t.selection,this.curSelectionFor=0,this.storedMarks=t.storedMarks,this.updated=0,this.meta=Object.create(null)}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;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},t.prototype.setSelection=function(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=-3&(1|this.updated),this.storedMarks=null,this},n.selectionSet.get=function(){return(1&this.updated)>0},t.prototype.setStoredMarks=function(e){return this.storedMarks=e,this.updated|=2,this},t.prototype.ensureMarks=function(e){return r.Mark.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this},t.prototype.addStoredMark=function(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))},t.prototype.removeStoredMark=function(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))},n.storedMarksSet.get=function(){return(2&this.updated)>0},t.prototype.addStep=function(t,n){e.prototype.addStep.call(this,t,n),this.updated=-3&this.updated,this.storedMarks=null},t.prototype.setTime=function(e){return this.time=e,this},t.prototype.replaceSelection=function(e){return this.selection.replace(this,e),this},t.prototype.replaceSelectionWith=function(e,t){var n=this.selection;return!1!==t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||r.Mark.none))),n.replaceWith(this,e),this},t.prototype.deleteSelection=function(){return this.selection.replace(this),this},t.prototype.insertText=function(e,t,n){void 0===n&&(n=t);var r=this.doc.type.schema;if(null==t)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();if(!e)return this.deleteRange(t,n);var o=this.storedMarks;if(!o){var i=this.doc.resolve(t);o=n==t?i.marks():i.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,o)),this.selection.empty||this.setSelection(s.near(this.selection.$to)),this},t.prototype.setMeta=function(e,t){return this.meta["string"==typeof e?e:e.key]=t,this},t.prototype.getMeta=function(e){return this.meta["string"==typeof e?e:e.key]},n.isGeneric.get=function(){for(var e in this.meta)return!1;return!0},t.prototype.scrollIntoView=function(){return this.updated|=4,this},n.scrolledIntoView.get=function(){return(4&this.updated)>0},Object.defineProperties(t.prototype,n),t}(o.Transform);function y(e,t){return t&&e?e.bind(t):e}var w=function(e,t,n){this.name=e,this.init=y(t.init,n),this.apply=y(t.apply,n)},b=[new w("doc",{init:function(e){return e.doc||e.schema.topNodeType.createAndFill()},apply:function(e){return e.doc}}),new w("selection",{init:function(e,t){return e.selection||s.atStart(t.doc)},apply:function(e){return e.selection}}),new w("storedMarks",{init:function(e){return e.storedMarks||null},apply:function(e,t,n,r){return r.selection.$cursor?e.storedMarks:null}}),new w("scrollToSelection",{init:function(){return 0},apply:function(e,t){return e.scrolledIntoView?t+1:t}})],S=function(e,t){var n=this;this.schema=e,this.fields=b.concat(),this.plugins=[],this.pluginsByKey=Object.create(null),t&&t.forEach((function(e){if(n.pluginsByKey[e.key])throw new RangeError("Adding different instances of a keyed plugin ("+e.key+")");n.plugins.push(e),n.pluginsByKey[e.key]=e,e.spec.state&&n.fields.push(new w(e.key,e.spec.state,e))}))},k=function(e){this.config=e},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(e){return this.applyTransaction(e).state},k.prototype.filterTransaction=function(e,t){void 0===t&&(t=-1);for(var n=0;n<this.config.plugins.length;n++)if(n!=t){var r=this.config.plugins[n];if(r.spec.filterTransaction&&!r.spec.filterTransaction.call(r,e,this))return!1}return!0},k.prototype.applyTransaction=function(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};for(var t=[e],n=this.applyInner(e),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,l=r?r[i].state:this,c=a<t.length&&s.spec.appendTransaction.call(s,a?t.slice(a):t,l,n);if(c&&n.filterTransaction(c,i)){if(c.setMeta("appendedTransaction",e),!r){r=[];for(var u=0;u<this.config.plugins.length;u++)r.push(u<i?{state:n,n:t.length}:{state:this,n:0})}t.push(c),n=n.applyInner(c),o=!0}r&&(r[i]={state:n,n:t.length})}}if(!o)return{state:n,transactions:t}}},k.prototype.applyInner=function(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");for(var t=new k(this.config),n=this.config.fields,r=0;r<n.length;r++){var o=n[r];t[o.name]=o.apply(e,this[o.name],this,t)}for(var i=0;i<C.length;i++)C[i](this,e,t);return t},x.tr.get=function(){return new g(this)},k.create=function(e){for(var t=new S(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new k(t),r=0;r<t.fields.length;r++)n[t.fields[r].name]=t.fields[r].init(e,n);return n},k.prototype.reconfigure=function(e){for(var t=new S(this.schema,e.plugins),n=t.fields,r=new k(t),o=0;o<n.length;o++){var i=n[o].name;r[i]=this.hasOwnProperty(i)?this[i]:n[o].init(e,r)}return r},k.prototype.toJSON=function(e){var t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map((function(e){return e.toJSON()}))),e&&"object"==typeof e)for(var n in e){if("doc"==n||"selection"==n)throw new RangeError("The JSON fields `doc` and `selection` are reserved");var r=e[n],o=r.spec.state;o&&o.toJSON&&(t[n]=o.toJSON.call(r,this[r.key]))}return t},k.fromJSON=function(e,t,n){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");var o=new S(e.schema,e.plugins),i=new k(o);return o.fields.forEach((function(o){if("doc"==o.name)i.doc=r.Node.fromJSON(e.schema,t.doc);else if("selection"==o.name)i.selection=s.fromJSON(i.doc,t.selection);else if("storedMarks"==o.name)t.storedMarks&&(i.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(n)for(var a in n){var l=n[a],c=l.spec.state;if(l.key==o.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,a))return void(i[o.name]=c.fromJSON.call(l,e,t[a],i))}i[o.name]=o.init(e,i)}})),i},k.addApplyListener=function(e){C.push(e)},k.removeApplyListener=function(e){var t=C.indexOf(e);t>-1&&C.splice(t,1)},Object.defineProperties(k.prototype,x);var C=[];var M=function(e){this.props={},e.props&&function e(t,n,r){for(var o in t){var i=t[o];i instanceof Function?i=i.bind(n):"handleDOMEvents"==o&&(i=e(i,n,{})),r[o]=i}return r}(e.props,this,this.props),this.spec=e,this.key=e.key?e.key.key:T("plugin")};M.prototype.getState=function(e){return e[this.key]};var O=Object.create(null);function T(e){return e in O?e+"$"+ ++O[e]:(O[e]=0,e+"$")}var A=function(e){void 0===e&&(e="key"),this.key=T(e)};A.prototype.get=function(e){return e.config.pluginsByKey[this.key]},A.prototype.getState=function(e){return e[this.key]}},function(e,t,n){"use strict";n.r(t),n.d(t,"AddMarkStep",(function(){return R})),n.d(t,"MapResult",(function(){return s})),n.d(t,"Mapping",(function(){return l})),n.d(t,"RemoveMarkStep",(function(){return D})),n.d(t,"ReplaceAroundStep",(function(){return g})),n.d(t,"ReplaceStep",(function(){return v})),n.d(t,"Step",(function(){return h})),n.d(t,"StepMap",(function(){return a})),n.d(t,"StepResult",(function(){return m})),n.d(t,"Transform",(function(){return u})),n.d(t,"TransformError",(function(){return c})),n.d(t,"canJoin",(function(){return C})),n.d(t,"canSplit",(function(){return x})),n.d(t,"dropPoint",(function(){return A})),n.d(t,"findWrapping",(function(){return S})),n.d(t,"insertPoint",(function(){return T})),n.d(t,"joinPoint",(function(){return O})),n.d(t,"liftTarget",(function(){return b})),n.d(t,"replaceStep",(function(){return E}));var r=n(0),o=Math.pow(2,16);function i(e){return 65535&e}var s=function(e,t,n){void 0===t&&(t=!1),void 0===n&&(n=null),this.pos=e,this.deleted=t,this.recover=n},a=function e(t,n){if(void 0===n&&(n=!1),!t.length&&e.empty)return e.empty;this.ranges=t,this.inverted=n};a.prototype.recover=function(e){var t=0,n=i(e);if(!this.inverted)for(var r=0;r<n;r++)t+=this.ranges[3*r+2]-this.ranges[3*r+1];return this.ranges[3*n]+t+function(e){return(e-(65535&e))/o}(e)},a.prototype.mapResult=function(e,t){return void 0===t&&(t=1),this._map(e,t,!1)},a.prototype.map=function(e,t){return void 0===t&&(t=1),this._map(e,t,!0)},a.prototype._map=function(e,t,n){for(var r=0,i=this.inverted?2:1,a=this.inverted?1:2,l=0;l<this.ranges.length;l+=3){var c=this.ranges[l]-(this.inverted?r:0);if(c>e)break;var u=this.ranges[l+i],d=this.ranges[l+a],p=c+u;if(e<=p){var f=c+r+((u?e==c?-1:e==p?1:t:t)<0?0:d);if(n)return f;var h=e==(t<0?c:p)?null:l/3+(e-c)*o;return new s(f,t<0?e!=c:e!=p,h)}r+=d-u}return n?e+r:new s(e+r)},a.prototype.touches=function(e,t){for(var n=0,r=i(t),o=this.inverted?2:1,s=this.inverted?1:2,a=0;a<this.ranges.length;a+=3){var l=this.ranges[a]-(this.inverted?n:0);if(l>e)break;var c=this.ranges[a+o];if(e<=l+c&&a==3*r)return!0;n+=this.ranges[a+s]-c}return!1},a.prototype.forEach=function(e){for(var t=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),l=this.ranges[r+t],c=this.ranges[r+n];e(s,s+l,a,a+c),o+=c-l}},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(e){return 0==e?a.empty:new a(e<0?[0,-e,0]:[0,0,e])},a.empty=new a([]);var l=function(e,t,n,r){this.maps=e||[],this.from=n||0,this.to=null==r?this.maps.length:r,this.mirror=t};function c(e){var t=Error.call(this,e);return t.__proto__=c.prototype,t}l.prototype.slice=function(e,t){return void 0===e&&(e=0),void 0===t&&(t=this.maps.length),new l(this.maps,this.mirror,e,t)},l.prototype.copy=function(){return new l(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)},l.prototype.appendMap=function(e,t){this.to=this.maps.push(e),null!=t&&this.setMirror(this.maps.length-1,t)},l.prototype.appendMapping=function(e){for(var t=0,n=this.maps.length;t<e.maps.length;t++){var r=e.getMirror(t);this.appendMap(e.maps[t],null!=r&&r<t?n+r:null)}},l.prototype.getMirror=function(e){if(this.mirror)for(var t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]},l.prototype.setMirror=function(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)},l.prototype.appendMappingInverted=function(e){for(var t=e.maps.length-1,n=this.maps.length+e.maps.length;t>=0;t--){var r=e.getMirror(t);this.appendMap(e.maps[t].invert(),null!=r&&r>t?n-r-1:null)}},l.prototype.invert=function(){var e=new l;return e.appendMappingInverted(this),e},l.prototype.map=function(e,t){if(void 0===t&&(t=1),this.mirror)return this._map(e,t,!0);for(var n=this.from;n<this.to;n++)e=this.maps[n].map(e,t);return e},l.prototype.mapResult=function(e,t){return void 0===t&&(t=1),this._map(e,t,!1)},l.prototype._map=function(e,t,n){for(var r=!1,o=this.from;o<this.to;o++){var i=this.maps[o].mapResult(e,t);if(null!=i.recover){var a=this.getMirror(o);if(null!=a&&a>o&&a<this.to){o=a,e=this.maps[a].recover(i.recover);continue}}i.deleted&&(r=!0),e=i.pos}return n?e:new s(e,r)},c.prototype=Object.create(Error.prototype),c.prototype.constructor=c,c.prototype.name="TransformError";var u=function(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new l},d={before:{configurable:!0},docChanged:{configurable:!0}};function p(){throw new Error("Override me")}d.before.get=function(){return this.docs.length?this.docs[0]:this.doc},u.prototype.step=function(e){var t=this.maybeStep(e);if(t.failed)throw new c(t.failed);return this},u.prototype.maybeStep=function(e){var t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t},d.docChanged.get=function(){return this.steps.length>0},u.prototype.addStep=function(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t},Object.defineProperties(u.prototype,d);var f=Object.create(null),h=function(){};h.prototype.apply=function(e){return p()},h.prototype.getMap=function(){return a.empty},h.prototype.invert=function(e){return p()},h.prototype.map=function(e){return p()},h.prototype.merge=function(e){return null},h.prototype.toJSON=function(){return p()},h.fromJSON=function(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");var n=f[t.stepType];if(!n)throw new RangeError("No step type "+t.stepType+" defined");return n.fromJSON(e,t)},h.jsonID=function(e,t){if(e in f)throw new RangeError("Duplicate use of step JSON ID "+e);return f[e]=t,t.prototype.jsonID=e,t};var m=function(e,t){this.doc=e,this.failed=t};m.ok=function(e){return new m(e,null)},m.fail=function(e){return new m(null,e)},m.fromReplace=function(e,t,n,o){try{return m.ok(e.replace(t,n,o))}catch(e){if(e instanceof r.ReplaceError)return m.fail(e.message);throw e}};var v=function(e){function t(t,n,r,o){e.call(this),this.from=t,this.to=n,this.slice=r,this.structure=!!o}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.apply=function(e){return this.structure&&y(e,this.from,this.to)?m.fail("Structure replace would overwrite content"):m.fromReplace(e,this.from,this.to,this.slice)},t.prototype.getMap=function(){return new a([this.from,this.to-this.from,this.slice.size])},t.prototype.invert=function(e){return new t(this.from,this.from+this.slice.size,e.slice(this.from,this.to))},t.prototype.map=function(e){var n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted?null:new t(n.pos,Math.max(n.pos,r.pos),this.slice)},t.prototype.merge=function(e){if(!(e instanceof t)||e.structure||this.structure)return null;if(this.from+this.slice.size!=e.from||this.slice.openEnd||e.slice.openStart){if(e.to!=this.from||this.slice.openStart||e.slice.openEnd)return null;var n=this.slice.size+e.slice.size==0?r.Slice.empty:new r.Slice(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new t(e.from,this.to,n,this.structure)}var o=this.slice.size+e.slice.size==0?r.Slice.empty:new r.Slice(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new t(this.from,this.to+(e.to-e.from),o,this.structure)},t.prototype.toJSON=function(){var e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e},t.fromJSON=function(e,n){if("number"!=typeof n.from||"number"!=typeof n.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new t(n.from,n.to,r.Slice.fromJSON(e,n.slice),!!n.structure)},t}(h);h.jsonID("replace",v);var g=function(e){function t(t,n,r,o,i,s,a){e.call(this),this.from=t,this.to=n,this.gapFrom=r,this.gapTo=o,this.slice=i,this.insert=s,this.structure=!!a}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.apply=function(e){if(this.structure&&(y(e,this.from,this.gapFrom)||y(e,this.gapTo,this.to)))return m.fail("Structure gap-replace would overwrite content");var t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return m.fail("Gap is not a flat range");var n=this.slice.insertAt(this.insert,t.content);return n?m.fromReplace(e,this.from,this.to,n):m.fail("Content does not fit in gap")},t.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])},t.prototype.invert=function(e){var n=this.gapTo-this.gapFrom;return new t(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)},t.prototype.map=function(e){var n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),o=e.map(this.gapFrom,-1),i=e.map(this.gapTo,1);return n.deleted&&r.deleted||o<n.pos||i>r.pos?null:new t(n.pos,r.pos,o,i,this.slice,this.insert,this.structure)},t.prototype.toJSON=function(){var e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e},t.fromJSON=function(e,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 t(n.from,n.to,n.gapFrom,n.gapTo,r.Slice.fromJSON(e,n.slice),n.insert,!!n.structure)},t}(h);function y(e,t,n){for(var r=e.resolve(t),o=n-t,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(e,t,n){return(0==t||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function b(e){for(var t=e.parent.content.cutByIndex(e.startIndex,e.endIndex),n=e.depth;;--n){var r=e.$from.node(n),o=e.$from.index(n),i=e.$to.indexAfter(n);if(n<e.depth&&r.canReplace(o,i,t))return n;if(0==n||r.type.spec.isolating||!w(r,o,i))break}}function S(e,t,n,r){void 0===r&&(r=e);var o=function(e,t){var n=e.parent,r=e.startIndex,o=e.endIndex,i=n.contentMatchAt(r).findWrapping(t);if(!i)return null;var s=i.length?i[0]:t;return n.canReplaceWith(r,o,s)?i:null}(e,t),i=o&&function(e,t){var n=e.parent,r=e.startIndex,o=e.endIndex,i=n.child(r),s=t.contentMatch.findWrapping(i.type);if(!s)return null;for(var a=(s.length?s[s.length-1]:t).contentMatch,l=r;a&&l<o;l++)a=a.matchType(n.child(l).type);if(!a||!a.validEnd)return null;return s}(r,t);return i?o.map(k).concat({type:t,attrs:n}).concat(i.map(k)):null}function k(e){return{type:e,attrs:null}}function x(e,t,n,r){void 0===n&&(n=1);var o=e.resolve(t),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,l=n-2;a>i;a--,l--){var c=o.node(a),u=o.index(a);if(c.type.spec.isolating)return!1;var d=c.content.cutByIndex(u,c.childCount),p=r&&r[l]||c;if(p!=c&&(d=d.replaceChild(0,p.type.create(p.attrs))),!c.canReplace(u+1,c.childCount)||!p.type.validContent(d))return!1}var f=o.indexAfter(i),h=r&&r[0];return o.node(i).canReplaceWith(f,f,h?h.type:o.node(i+1).type)}function C(e,t){var n=e.resolve(t),r=n.index();return M(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function M(e,t){return e&&t&&!e.isLeaf&&e.canAppend(t)}function O(e,t,n){void 0===n&&(n=-1);for(var r=e.resolve(t),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 t;if(0==o)break;t=n<0?r.before(o):r.after(o)}}function T(e,t,n){var r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;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 A(e,t,n){var r=e.resolve(t);if(!n.content.size)return t;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 l=a==r.depth?0:r.pos<=(r.start(a+1)+r.end(a+1))/2?-1:1,c=r.index(a)+(l>0?1:0),u=r.node(a),d=!1;if(1==s)d=u.canReplace(c,c,o);else{var p=u.contentMatchAt(c).findWrapping(o.firstChild.type);d=p&&u.canReplaceWith(c,c,p[0])}if(d)return 0==l?r.pos:l<0?r.before(a+1):r.after(a+1)}return null}function N(e,t,n){for(var o=[],i=0;i<e.childCount;i++){var s=e.child(i);s.content.size&&(s=s.copy(N(s.content,t,s))),s.isInline&&(s=t(s,n,i)),o.push(s)}return r.Fragment.fromArray(o)}h.jsonID("replaceAround",g),u.prototype.lift=function(e,t){for(var n=e.$from,o=e.$to,i=e.depth,s=n.before(i+1),a=o.after(i+1),l=s,c=a,u=r.Fragment.empty,d=0,p=i,f=!1;p>t;p--)f||n.index(p)>0?(f=!0,u=r.Fragment.from(n.node(p).copy(u)),d++):l--;for(var h=r.Fragment.empty,m=0,v=i,y=!1;v>t;v--)y||o.after(v+1)<o.end(v)?(y=!0,h=r.Fragment.from(o.node(v).copy(h)),m++):c++;return this.step(new g(l,c,s,a,new r.Slice(u.append(h),d,m),u.size-d,!0))},u.prototype.wrap=function(e,t){for(var n=r.Fragment.empty,o=t.length-1;o>=0;o--){if(n.size){var i=t[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(t[o].type.create(t[o].attrs,n))}var s=e.start,a=e.end;return this.step(new g(s,a,s,a,new r.Slice(n,0,0),t.length,!0))},u.prototype.setBlockType=function(e,t,n,o){var i=this;if(void 0===t&&(t=e),!n.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");var s=this.steps.length;return this.doc.nodesBetween(e,t,(function(e,t){if(e.isTextblock&&!e.hasMarkup(n,o)&&function(e,t,n){var r=e.resolve(t),o=r.index();return r.parent.canReplaceWith(o,o+1,n)}(i.doc,i.mapping.slice(s).map(t),n)){i.clearIncompatible(i.mapping.slice(s).map(t,1),n);var a=i.mapping.slice(s),l=a.map(t,1),c=a.map(t+e.nodeSize,1);return i.step(new g(l,c,l+1,c-1,new r.Slice(r.Fragment.from(n.create(o,null,e.marks)),0,0),1,!0)),!1}})),this},u.prototype.setNodeMarkup=function(e,t,n,o){var i=this.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");t||(t=i.type);var s=t.create(n,null,o||i.marks);if(i.isLeaf)return this.replaceWith(e,e+i.nodeSize,s);if(!t.validContent(i.content))throw new RangeError("Invalid content for node type "+t.name);return this.step(new g(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new r.Slice(r.Fragment.from(s),0,0),1,!0))},u.prototype.split=function(e,t,n){void 0===t&&(t=1);for(var o=this.doc.resolve(e),i=r.Fragment.empty,s=r.Fragment.empty,a=o.depth,l=o.depth-t,c=t-1;a>l;a--,c--){i=r.Fragment.from(o.node(a).copy(i));var u=n&&n[c];s=r.Fragment.from(u?u.type.create(u.attrs,s):o.node(a).copy(s))}return this.step(new v(e,e,new r.Slice(i.append(s),t,t),!0))},u.prototype.join=function(e,t){void 0===t&&(t=1);var n=new v(e-t,e+t,r.Slice.empty,!0);return this.step(n)};var R=function(e){function t(t,n,r){e.call(this),this.from=t,this.to=n,this.mark=r}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.apply=function(e){var t=this,n=e.slice(this.from,this.to),o=e.resolve(this.from),i=o.node(o.sharedDepth(this.to)),s=new r.Slice(N(n.content,(function(e,n){return e.isAtom&&n.type.allowsMarkType(t.mark.type)?e.mark(t.mark.addToSet(e.marks)):e}),i),n.openStart,n.openEnd);return m.fromReplace(e,this.from,this.to,s)},t.prototype.invert=function(){return new D(this.from,this.to,this.mark)},t.prototype.map=function(e){var n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new t(n.pos,r.pos,this.mark)},t.prototype.merge=function(e){if(e instanceof t&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from)return new t(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark)},t.prototype.toJSON=function(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}},t.fromJSON=function(e,n){if("number"!=typeof n.from||"number"!=typeof n.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new t(n.from,n.to,e.markFromJSON(n.mark))},t}(h);h.jsonID("addMark",R);var D=function(e){function t(t,n,r){e.call(this),this.from=t,this.to=n,this.mark=r}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.apply=function(e){var t=this,n=e.slice(this.from,this.to),o=new r.Slice(N(n.content,(function(e){return e.mark(t.mark.removeFromSet(e.marks))})),n.openStart,n.openEnd);return m.fromReplace(e,this.from,this.to,o)},t.prototype.invert=function(){return new R(this.from,this.to,this.mark)},t.prototype.map=function(e){var n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new t(n.pos,r.pos,this.mark)},t.prototype.merge=function(e){if(e instanceof t&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from)return new t(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark)},t.prototype.toJSON=function(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}},t.fromJSON=function(e,n){if("number"!=typeof n.from||"number"!=typeof n.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new t(n.from,n.to,e.markFromJSON(n.mark))},t}(h);function E(e,t,n,o){if(void 0===n&&(n=t),void 0===o&&(o=r.Slice.empty),t==n&&!o.size)return null;var i=e.resolve(t),s=e.resolve(n);return z(i,s,o)?new v(t,n,o):new _(i,s,o).fit()}function z(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}h.jsonID("removeMark",D),u.prototype.addMark=function(e,t,n){var r=this,o=[],i=[],s=null,a=null;return this.doc.nodesBetween(e,t,(function(r,l,c){if(r.isInline){var u=r.marks;if(!n.isInSet(u)&&c.type.allowsMarkType(n.type)){for(var d=Math.max(l,e),p=Math.min(l+r.nodeSize,t),f=n.addToSet(u),h=0;h<u.length;h++)u[h].isInSet(f)||(s&&s.to==d&&s.mark.eq(u[h])?s.to=p:o.push(s=new D(d,p,u[h])));a&&a.to==d?a.to=p:i.push(a=new R(d,p,n))}}})),o.forEach((function(e){return r.step(e)})),i.forEach((function(e){return r.step(e)})),this},u.prototype.removeMark=function(e,t,n){var o=this;void 0===n&&(n=null);var i=[],s=0;return this.doc.nodesBetween(e,t,(function(o,a){if(o.isInline){s++;var l=null;if(n instanceof r.MarkType)for(var c,u=o.marks;c=n.isInSet(u);)(l||(l=[])).push(c),u=c.removeFromSet(u);else n?n.isInSet(o.marks)&&(l=[n]):l=o.marks;if(l&&l.length)for(var d=Math.min(a+o.nodeSize,t),p=0;p<l.length;p++){for(var f=l[p],h=void 0,m=0;m<i.length;m++){var v=i[m];v.step==s-1&&f.eq(i[m].style)&&(h=v)}h?(h.to=d,h.step=s):i.push({style:f,from:Math.max(a,e),to:d,step:s})}}})),i.forEach((function(e){return o.step(new D(e.from,e.to,e.style))})),this},u.prototype.clearIncompatible=function(e,t,n){void 0===n&&(n=t.contentMatch);for(var o=this.doc.nodeAt(e),i=[],s=e+1,a=0;a<o.childCount;a++){var l=o.child(a),c=s+l.nodeSize,u=n.matchType(l.type,l.attrs);if(u){n=u;for(var d=0;d<l.marks.length;d++)t.allowsMarkType(l.marks[d].type)||this.step(new D(s,c,l.marks[d]))}else i.push(new v(s,c,r.Slice.empty));s=c}if(!n.validEnd){var p=n.fillBefore(r.Fragment.empty,!0);this.replace(s,s,new r.Slice(p,0,0))}for(var f=i.length-1;f>=0;f--)this.step(i[f]);return this},u.prototype.replace=function(e,t,n){void 0===t&&(t=e),void 0===n&&(n=r.Slice.empty);var o=E(this.doc,e,t,n);return o&&this.step(o),this},u.prototype.replaceWith=function(e,t,n){return this.replace(e,t,new r.Slice(r.Fragment.from(n),0,0))},u.prototype.delete=function(e,t){return this.replace(e,t,r.Slice.empty)},u.prototype.insert=function(e,t){return this.replaceWith(e,e,t)};var _=function(e,t,n){this.$to=t,this.$from=e,this.unplaced=n,this.frontier=[];for(var o=0;o<=e.depth;o++){var i=e.node(o);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(o))})}this.placed=r.Fragment.empty;for(var s=e.depth;s>0;s--)this.placed=r.Fragment.from(e.node(s).copy(this.placed))},I={depth:{configurable:!0}};function P(e,t,n){return 0==t?e.cutByIndex(n):e.replaceChild(0,e.firstChild.copy(P(e.firstChild.content,t-1,n)))}function $(e,t,n){return 0==t?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy($(e.lastChild.content,t-1,n)))}function F(e,t){for(var n=0;n<t;n++)e=e.firstChild.content;return e}function B(e,t,n){if(t<=0)return e;var o=e.content;return t>1&&(o=o.replaceChild(0,B(o.firstChild,t-1,1==o.childCount?n-1:0))),t>0&&(o=e.type.contentMatch.fillBefore(o).append(o),n<=0&&(o=o.append(e.type.contentMatch.matchFragment(o).fillBefore(r.Fragment.empty,!0)))),e.copy(o)}function L(e,t,n,r,o){var i=e.node(t),s=o?e.indexAfter(t):e.index(t);if(s==i.childCount&&!n.compatibleContent(i.type))return null;var a=r.fillBefore(i.content,!0,s);return a&&!function(e,t,n){for(var r=n;r<t.childCount;r++)if(!e.allowsMarks(t.child(r).marks))return!0;return!1}(n,i.content,s)?a:null}function V(e){return e.spec.defining||e.spec.definingForContent}function j(e,t,n,o,i){if(t<n){var s=e.firstChild;e=e.replaceChild(0,s.copy(j(s.content,t+1,n,o,s)))}if(t>o){var a=i.contentMatchAt(0),l=a.fillBefore(e).append(e);e=l.append(a.matchFragment(l).fillBefore(r.Fragment.empty,!0))}return e}function K(e,t){for(var n=[],r=Math.min(e.depth,t.depth);r>=0;r--){var o=e.start(r);if(o<e.pos-(e.depth-r)||t.end(r)>t.pos+(t.depth-r)||e.node(r).type.spec.isolating||t.node(r).type.spec.isolating)break;(o==t.start(r)||r==e.depth&&r==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&r&&t.start(r-1)==o-1)&&n.push(r)}return n}I.depth.get=function(){return this.frontier.length-1},_.prototype.fit=function(){for(;this.unplaced.size;){var e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}var t=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,o=this.$from,i=this.close(t<0?this.$to:o.doc.resolve(t));if(!i)return null;for(var s=this.placed,a=o.depth,l=i.depth;a&&l&&1==s.childCount;)s=s.firstChild.content,a--,l--;var c=new r.Slice(s,a,l);return t>-1?new g(o.pos,t,this.$to.pos,this.$to.end(),c,n):c.size||o.pos!=this.$to.pos?new v(o.pos,i.pos,c):void 0},_.prototype.findFittable=function(){for(var e=1;e<=2;e++)for(var t=this.unplaced.openStart;t>=0;t--)for(var n=void 0,o=(t?(n=F(this.unplaced.content,t-1).firstChild).content:this.unplaced.content).firstChild,i=this.depth;i>=0;i--){var s=this.frontier[i],a=s.type,l=s.match,c=void 0,u=void 0;if(1==e&&(o?l.matchType(o.type)||(u=l.fillBefore(r.Fragment.from(o),!1)):a.compatibleContent(n.type)))return{sliceDepth:t,frontierDepth:i,parent:n,inject:u};if(2==e&&o&&(c=l.findWrapping(o.type)))return{sliceDepth:t,frontierDepth:i,parent:n,wrap:c};if(n&&l.matchType(n.type))break}},_.prototype.openMore=function(){var e=this.unplaced,t=e.content,n=e.openStart,o=e.openEnd,i=F(t,n);return!(!i.childCount||i.firstChild.isLeaf)&&(this.unplaced=new r.Slice(t,n+1,Math.max(o,i.size+n>=t.size-o?n+1:0)),!0)},_.prototype.dropNode=function(){var e=this.unplaced,t=e.content,n=e.openStart,o=e.openEnd,i=F(t,n);if(i.childCount<=1&&n>0){var s=t.size-n<=n+i.size;this.unplaced=new r.Slice(P(t,n-1,1),n-1,s?n-1:o)}else this.unplaced=new r.Slice(P(t,n,1),n,o)},_.prototype.placeNodes=function(e){for(var t=e.sliceDepth,n=e.frontierDepth,o=e.parent,i=e.inject,s=e.wrap;this.depth>n;)this.closeFrontierNode();if(s)for(var a=0;a<s.length;a++)this.openFrontierNode(s[a]);var l=this.unplaced,c=o?o.content:l.content,u=l.openStart-t,d=0,p=[],f=this.frontier[n],h=f.match,m=f.type;if(i){for(var v=0;v<i.childCount;v++)p.push(i.child(v));h=h.matchFragment(i)}for(var g=c.size+t-(l.content.size-l.openEnd);d<c.childCount;){var y=c.child(d),w=h.matchType(y.type);if(!w)break;(++d>1||0==u||y.content.size)&&(h=w,p.push(B(y.mark(m.allowedMarks(y.marks)),1==d?u:0,d==c.childCount?g:-1)))}var b=d==c.childCount;b||(g=-1),this.placed=$(this.placed,n,r.Fragment.from(p)),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=c;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==t?r.Slice.empty:new r.Slice(P(l.content,t-1,1),t-1,g<0?l.openEnd:t-1):new r.Slice(P(l.content,t,d),l.openStart,l.openEnd)},_.prototype.mustMoveInline=function(){if(!this.$to.parent.isTextblock)return-1;var e,t=this.frontier[this.depth];if(!t.type.isTextblock||!L(this.$to,this.$to.depth,t.type,t.match,!1)||this.$to.depth==this.depth&&(e=this.findCloseLevel(this.$to))&&e.depth==this.depth)return-1;for(var n=this.$to.depth,r=this.$to.after(n);n>1&&r==this.$to.end(--n);)++r;return r},_.prototype.findCloseLevel=function(e){e:for(var t=Math.min(this.depth,e.depth);t>=0;t--){var n=this.frontier[t],r=n.match,o=n.type,i=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),s=L(e,t,o,r,i);if(s){for(var a=t-1;a>=0;a--){var l=this.frontier[a],c=l.match,u=L(e,a,l.type,c,!0);if(!u||u.childCount)continue e}return{depth:t,fit:s,move:i?e.doc.resolve(e.after(t+1)):e}}}},_.prototype.close=function(e){var t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=$(this.placed,t.depth,t.fit)),e=t.move;for(var n=t.depth+1;n<=e.depth;n++){var r=e.node(n),o=r.type.contentMatch.fillBefore(r.content,!0,e.index(n));this.openFrontierNode(r.type,r.attrs,o)}return e},_.prototype.openFrontierNode=function(e,t,n){var o=this.frontier[this.depth];o.match=o.match.matchType(e),this.placed=$(this.placed,this.depth,r.Fragment.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})},_.prototype.closeFrontierNode=function(){var e=this.frontier.pop().match.fillBefore(r.Fragment.empty,!0);e.childCount&&(this.placed=$(this.placed,this.frontier.length,e))},Object.defineProperties(_.prototype,I),u.prototype.replaceRange=function(e,t,n){if(!n.size)return this.deleteRange(e,t);var o=this.doc.resolve(e),i=this.doc.resolve(t);if(z(o,i,n))return this.step(new v(e,t,n));var s=K(o,this.doc.resolve(t));0==s[s.length-1]&&s.pop();var a=-(o.depth+1);s.unshift(a);for(var l=o.depth,c=o.pos-1;l>0;l--,c--){var u=o.node(l).type.spec;if(u.defining||u.definingAsContext||u.isolating)break;s.indexOf(l)>-1?a=l:o.before(l)==c&&s.splice(1,0,-l)}for(var d=s.indexOf(a),p=[],f=n.openStart,h=n.content,m=0;;m++){var g=h.firstChild;if(p.push(g),m==n.openStart)break;h=g.content}for(var y=f-1;y>=0;y--){var w=p[y].type,b=V(w);if(b&&o.node(d).type!=w)f=y;else if(b||!w.isTextblock)break}for(var S=n.openStart;S>=0;S--){var k=(S+f+1)%(n.openStart+1),x=p[k];if(x)for(var C=0;C<s.length;C++){var M=s[(C+d)%s.length],O=!0;M<0&&(O=!1,M=-M);var T=o.node(M-1),A=o.index(M-1);if(T.canReplaceWith(A,A,x.type,x.marks))return this.replace(o.before(M),O?i.after(M):t,new r.Slice(j(n.content,0,n.openStart,k),k,n.openEnd))}}for(var N=this.steps.length,R=s.length-1;R>=0&&(this.replace(e,t,n),!(this.steps.length>N));R--){var D=s[R];D<0||(e=o.before(D),t=i.after(D))}return this},u.prototype.replaceRangeWith=function(e,t,n){if(!n.isInline&&e==t&&this.doc.resolve(e).parent.content.size){var o=T(this.doc,e,n.type);null!=o&&(e=t=o)}return this.replaceRange(e,t,new r.Slice(r.Fragment.from(n),0,0))},u.prototype.deleteRange=function(e,t){for(var n=this.doc.resolve(e),r=this.doc.resolve(t),o=K(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 l=1;l<=n.depth&&l<=r.depth;l++)if(e-n.start(l)==n.depth-l&&t>n.end(l)&&r.end(l)-t!=r.depth-l)return this.delete(n.before(l),t);return this.delete(e,t)}},function(e,t,n){"use strict";n.r(t),n.d(t,"Decoration",(function(){return Nt})),n.d(t,"DecorationSet",(function(){return zt})),n.d(t,"EditorView",(function(){return Ht})),n.d(t,"__endComposition",(function(){return wt})),n.d(t,"__parseFromClipboard",(function(){return je})),n.d(t,"__serializeForClipboard",(function(){return Ve}));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),l=/MSIE \d/.test(navigator.userAgent),c=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),u=s.ie=!!(l||c||a);s.ie_version=l?document.documentMode||6:c?+c[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 d=!u&&/Chrome\/(\d+)/.exec(navigator.userAgent);s.chrome=!!d,s.chrome_version=d&&+d[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 p=function(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t},f=function(e){var t=e.assignedSlot||e.parentNode;return t&&11==t.nodeType?t.host:t},h=null,m=function(e,t,n){var r=h||(h=document.createRange());return r.setEnd(e,null==n?e.nodeValue.length:n),r.setStart(e,t||0),r},v=function(e,t,n,r){return n&&(y(e,t,n,r,-1)||y(e,t,n,r,1))},g=/^(img|br|input|textarea|hr)$/i;function y(e,t,n,r,o){for(;;){if(e==n&&t==r)return!0;if(t==(o<0?0:w(e))){var i=e.parentNode;if(!i||1!=i.nodeType||b(e)||g.test(e.nodeName)||"false"==e.contentEditable)return!1;t=p(e)+(o<0?0:1),e=i}else{if(1!=e.nodeType)return!1;if("false"==(e=e.childNodes[t+(o<0?-1:0)]).contentEditable)return!1;t=o<0?w(e):0}}}function w(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function b(e){for(var t,n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}var S=function(e){var t=e.isCollapsed;return t&&s.chrome&&e.rangeCount&&!e.getRangeAt(0).collapsed&&(t=!1),t};function k(e,t){var n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}function x(e){return{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function C(e,t){return"number"==typeof e?e:e[t]}function M(e){var t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function O(e,t,n){for(var r=e.someProp("scrollThreshold")||0,o=e.someProp("scrollMargin")||5,i=e.dom.ownerDocument,s=n||e.dom;s;s=f(s))if(1==s.nodeType){var a=s==i.body||1!=s.nodeType,l=a?x(i):M(s),c=0,u=0;if(t.top<l.top+C(r,"top")?u=-(l.top-t.top+C(o,"top")):t.bottom>l.bottom-C(r,"bottom")&&(u=t.bottom-l.bottom+C(o,"bottom")),t.left<l.left+C(r,"left")?c=-(l.left-t.left+C(o,"left")):t.right>l.right-C(r,"right")&&(c=t.right-l.right+C(o,"right")),c||u)if(a)i.defaultView.scrollBy(c,u);else{var d=s.scrollLeft,p=s.scrollTop;u&&(s.scrollTop+=u),c&&(s.scrollLeft+=c);var h=s.scrollLeft-d,m=s.scrollTop-p;t={left:t.left-h,top:t.top-m,right:t.right-h,bottom:t.bottom-m}}if(a)break}}function T(e){for(var t=[],n=e.ownerDocument;e&&(t.push({dom:e,top:e.scrollTop,left:e.scrollLeft}),e!=n);e=f(e));return t}function A(e,t){for(var n=0;n<e.length;n++){var r=e[n],o=r.dom,i=r.top,s=r.left;o.scrollTop!=i+t&&(o.scrollTop=i+t),o.scrollLeft!=s&&(o.scrollLeft=s)}}var N=null;function R(e,t){for(var n,r,o=2e8,i=0,s=t.top,a=t.top,l=e.firstChild,c=0;l;l=l.nextSibling,c++){var u=void 0;if(1==l.nodeType)u=l.getClientRects();else{if(3!=l.nodeType)continue;u=m(l).getClientRects()}for(var d=0;d<u.length;d++){var p=u[d];if(p.top<=s&&p.bottom>=a){s=Math.max(p.bottom,s),a=Math.min(p.top,a);var f=p.left>t.left?p.left-t.left:p.right<t.left?t.left-p.right:0;if(f<o){n=l,o=f,r=f&&3==n.nodeType?{left:p.right<t.left?p.right:p.left,top:t.top}:t,1==l.nodeType&&f&&(i=c+(t.left>=(p.left+p.right)/2?1:0));continue}}!n&&(t.left>=p.right&&t.top>=p.top||t.left>=p.left&&t.top>=p.bottom)&&(i=c+1)}}return n&&3==n.nodeType?function(e,t){for(var n=e.nodeValue.length,r=document.createRange(),o=0;o<n;o++){r.setEnd(e,o+1),r.setStart(e,o);var i=z(r,1);if(i.top!=i.bottom&&D(t,i))return{node:e,offset:o+(t.left>=(i.left+i.right)/2?1:0)}}return{node:e,offset:0}}(n,r):!n||o&&1==n.nodeType?{node:e,offset:i}:R(n,r)}function D(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function E(e,t){var n,r,o,i,a=e.dom.ownerDocument;if(a.caretPositionFromPoint)try{var l=a.caretPositionFromPoint(t.left,t.top);l&&(o=(n=l).offsetNode,i=n.offset)}catch(e){}if(!o&&a.caretRangeFromPoint){var c=a.caretRangeFromPoint(t.left,t.top);c&&(o=(r=c).startContainer,i=r.startOffset)}var u,d=(e.root.elementFromPoint?e.root:a).elementFromPoint(t.left,t.top+1);if(!d||!e.dom.contains(1!=d.nodeType?d.parentNode:d)){var p=e.dom.getBoundingClientRect();if(!D(t,p))return null;if(!(d=function e(t,n,r){var o=t.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=t.childNodes[s];if(1==a.nodeType)for(var l=a.getClientRects(),c=0;c<l.length;c++){var u=l[c];if(D(n,u))return e(a,n,u)}if((s=(s+1)%o)==i)break}return t}(e.dom,t,p)))return null}if(s.safari)for(var h=d;o&&h;h=f(h))h.draggable&&(o=i=null);if(d=function(e,t){var n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}(d,t),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<=t.left&&m.bottom>t.top&&i++}o==e.dom&&i==o.childNodes.length-1&&1==o.lastChild.nodeType&&t.top>o.lastChild.getBoundingClientRect().bottom?u=e.state.doc.content.size:0!=i&&1==o.nodeType&&"BR"==o.childNodes[i-1].nodeName||(u=function(e,t,n,r){for(var o=-1,i=t;i!=e.dom;){var s=e.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:e.docView.posFromDOM(t,n)}(e,o,i,t))}null==u&&(u=function(e,t,n){var r=R(t,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 e.docView.posFromDOM(o,i,s)}(e,d,t));var g=e.docView.nearestDesc(d,!0);return{pos:u,inside:g?g.posAtStart-g.border:-1}}function z(e,t){var n=e.getClientRects();return n.length?n[t<0?0:n.length-1]:e.getBoundingClientRect()}var _=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function I(e,t,n){var r=e.docView.domFromPos(t,n<0?-1:1),o=r.node,i=r.offset,a=s.webkit||s.gecko;if(3==o.nodeType){if(!a||!_.test(o.nodeValue)&&(n<0?i:i!=o.nodeValue.length)){var l=i,c=i,u=n<0?1:-1;return n<0&&!i?(c++,u=-1):n>=0&&i==o.nodeValue.length?(l--,u=1):n<0?l--:c++,P(z(m(o,l,c),u),u<0)}var d=z(m(o,i,i),n);if(s.gecko&&i&&/\s/.test(o.nodeValue[i-1])&&i<o.nodeValue.length){var p=z(m(o,i-1,i-1),-1);if(p.top==d.top){var f=z(m(o,i,i+1),-1);if(f.top!=d.top)return P(f,f.left<p.left)}}return d}if(!e.state.doc.resolve(t).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(z(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(z(S,-1),!0)}return P(z(3==o.nodeType?m(o):o,-n),n>=0)}function P(e,t){if(0==e.width)return e;var n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function $(e,t){if(0==e.height)return e;var n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function F(e,t,n){var r=e.state,o=e.root.activeElement;r!=t&&e.updateState(t),o!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),o!=e.dom&&o&&o.focus()}}var B=/[\u0590-\u08ac]/;var L=null,V=null,j=!1;function K(e,t,n){return L==t&&V==n?j:(L=t,V=n,j="up"==n||"down"==n?function(e,t,n){var r=t.selection,o="up"==n?r.$from:r.$to;return F(e,t,(function(){for(var t=e.docView.domFromPos(o.pos,"up"==n?-1:1).node;;){var r=e.docView.nearestDesc(t,!0);if(!r)break;if(r.node.isBlock){t=r.dom;break}t=r.dom.parentNode}for(var i=I(e,o.pos,1),s=t.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 l=0;l<a.length;l++){var c=a[l];if(c.bottom>c.top+1&&("up"==n?i.top-c.top>2*(c.bottom-i.top):c.bottom-i.bottom>2*(i.bottom-c.top)))return!1}}return!0}))}(e,t,n):function(e,t,n){var r=t.selection.$head;if(!r.parent.isTextblock)return!1;var o=r.parentOffset,i=!o,s=o==r.parent.content.size,a=e.root.getSelection();return B.test(r.parent.textContent)&&a.modify?F(e,t,(function(){var t=a.getRangeAt(0),o=a.focusNode,i=a.focusOffset,s=a.caretBidiLevel;a.modify("move",n,"character");var l=!(r.depth?e.docView.domAfterPos(r.before()):e.dom).contains(1==a.focusNode.nodeType?a.focusNode:a.focusNode.parentNode)||o==a.focusNode&&i==a.focusOffset;return a.removeAllRanges(),a.addRange(t),null!=s&&(a.caretBidiLevel=s),l})):"left"==n||"backward"==n?i:s}(e,t,n))}var H=function(e,t,n,r){this.parent=e,this.children=t,this.dom=n,n.pmViewDesc=this,this.contentDOM=r,this.dirty=0},W={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}};H.prototype.matchesWidget=function(){return!1},H.prototype.matchesMark=function(){return!1},H.prototype.matchesNode=function(){return!1},H.prototype.matchesHack=function(e){return!1},H.prototype.parseRule=function(){return null},H.prototype.stopEvent=function(){return!1},W.size.get=function(){for(var e=0,t=0;t<this.children.length;t++)e+=this.children[t].size;return e},W.border.get=function(){return 0},H.prototype.destroy=function(){this.parent=null,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=null);for(var e=0;e<this.children.length;e++)this.children[e].destroy()},H.prototype.posBeforeChild=function(e){for(var t=0,n=this.posAtStart;t<this.children.length;t++){var r=this.children[t];if(r==e)return n;n+=r.size}},W.posBefore.get=function(){return this.parent.posBeforeChild(this)},W.posAtStart.get=function(){return this.parent?this.parent.posBeforeChild(this)+this.border:0},W.posAfter.get=function(){return this.posBefore+this.size},W.posAtEnd.get=function(){return this.posAtStart+this.size-2*this.border},H.prototype.localPosFromDOM=function(e,t,n){if(this.contentDOM&&this.contentDOM.contains(1==e.nodeType?e:e.parentNode)){if(n<0){var r,o;if(e==this.contentDOM)r=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;r=e.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(e==this.contentDOM)i=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&(!(s=i.pmViewDesc)||s.parent!=this);)i=i.nextSibling;return i?this.posBeforeChild(s):this.posAtEnd}var a;if(e==this.dom&&this.contentDOM)a=t>p(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))a=2&e.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==t)for(var l=e;;l=l.parentNode){if(l==this.dom){a=!1;break}if(l.parentNode.firstChild!=l)break}if(null==a&&t==e.childNodes.length)for(var c=e;;c=c.parentNode){if(c==this.dom){a=!0;break}if(c.parentNode.lastChild!=c)break}}return(null==a?n>0:a)?this.posAtEnd:this.posAtStart},H.prototype.nearestDesc=function(e,t){for(var n=!0,r=e;r;r=r.parentNode){var o=this.getDesc(r);if(o&&(!t||o.node)){if(!n||!o.nodeDOM||(1==o.nodeDOM.nodeType?o.nodeDOM.contains(1==e.nodeType?e:e.parentNode):o.nodeDOM==e))return o;n=!1}}},H.prototype.getDesc=function(e){for(var t=e.pmViewDesc,n=t;n;n=n.parent)if(n==this)return t},H.prototype.posFromDOM=function(e,t,n){for(var r=e;r;r=r.parentNode){var o=this.getDesc(r);if(o)return o.localPosFromDOM(e,t,n)}return-1},H.prototype.descAt=function(e){for(var t=0,n=0;t<this.children.length;t++){var r=this.children[t],o=n+r.size;if(n==e&&o!=n){for(;!r.border&&r.children.length;)r=r.children[0];return r}if(e<o)return r.descAt(e-n-r.border);n=o}},H.prototype.domFromPos=function(e,t){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>e||i instanceof Z){r=e-o;break}o=s}if(r)return this.children[n].domFromPos(r-this.children[n].border,t);for(var a=void 0;n&&!(a=this.children[n-1]).size&&a instanceof J&&a.widget.type.side>=0;n--);if(t<=0){for(var l,c=!0;(l=n?this.children[n-1]:null)&&l.dom.parentNode!=this.contentDOM;n--,c=!1);return l&&t&&c&&!l.border&&!l.domAtom?l.domFromPos(l.size,t):{node:this.contentDOM,offset:l?p(l.dom)+1:0}}for(var u,d=!0;(u=n<this.children.length?this.children[n]:null)&&u.dom.parentNode!=this.contentDOM;n++,d=!1);return u&&d&&!u.border&&!u.domAtom?u.domFromPos(0,t):{node:this.contentDOM,offset:u?p(u.dom):this.contentDOM.childNodes.length}},H.prototype.parseRange=function(e,t,n){if(void 0===n&&(n=0),0==this.children.length)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};for(var r=-1,o=-1,i=n,s=0;;s++){var a=this.children[s],l=i+a.size;if(-1==r&&e<=l){var c=i+a.border;if(e>=c&&t<=l-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,c);e=i;for(var u=s;u>0;u--){var d=this.children[u-1];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(1)){r=p(d.dom)+1;break}e-=d.size}-1==r&&(r=0)}if(r>-1&&(l>t||s==this.children.length-1)){t=l;for(var f=s+1;f<this.children.length;f++){var h=this.children[f];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(-1)){o=p(h.dom);break}t+=h.size}-1==o&&(o=this.contentDOM.childNodes.length);break}i=l}return{node:this.contentDOM,from:e,to:t,fromOffset:r,toOffset:o}},H.prototype.emptyChildAt=function(e){if(this.border||!this.contentDOM||!this.children.length)return!1;var t=this.children[e<0?0:this.children.length-1];return 0==t.size||t.emptyChildAt(e)},H.prototype.domAfterPos=function(e){var t=this.domFromPos(e,0),n=t.node,r=t.offset;if(1!=n.nodeType||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]},H.prototype.setSelection=function(e,t,n,r){for(var o=Math.min(e,t),i=Math.max(e,t),a=0,l=0;a<this.children.length;a++){var c=this.children[a],u=l+c.size;if(o>l&&i<u)return c.setSelection(e-l-c.border,t-l-c.border,n,r);l=u}var d=this.domFromPos(e,e?-1:1),f=t==e?d:this.domFromPos(t,t?-1:1),h=n.getSelection(),m=!1;if((s.gecko||s.safari)&&e==t){var g=d.node,y=d.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&&(d=f={node:b.parentNode,offset:p(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!=f.node&&1==h.focusNode.nodeType){var x=h.focusNode.childNodes[h.focusOffset];x&&"false"==x.contentEditable&&(r=!0)}if(r||m&&s.safari||!v(d.node,d.offset,h.anchorNode,h.anchorOffset)||!v(f.node,f.offset,h.focusNode,h.focusOffset)){var C=!1;if((h.extend||e==t)&&!m){h.collapse(d.node,d.offset);try{e!=t&&h.extend(f.node,f.offset),C=!0}catch(e){if(!(e instanceof DOMException))throw e}}if(!C){if(e>t){var M=d;d=f,f=M}var O=document.createRange();O.setEnd(f.node,f.offset),O.setStart(d.node,d.offset),h.removeAllRanges(),h.addRange(O)}}},H.prototype.ignoreMutation=function(e){return!this.contentDOM&&"selection"!=e.type},W.contentLost.get=function(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)},H.prototype.markDirty=function(e,t){for(var n=0,r=0;r<this.children.length;r++){var o=this.children[r],i=n+o.size;if(n==i?e<=i&&t>=n:e<i&&t>n){var s=n+o.border,a=i-o.border;if(e>=s&&t<=a)return this.dirty=e==n||t==i?2:1,void(e!=s||t!=a||!o.contentLost&&o.dom.parentNode==this.contentDOM?o.markDirty(e-s,t-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},H.prototype.markParentsDirty=function(){for(var e=1,t=this.parent;t;t=t.parent,e++){var n=1==e?2:1;t.dirty<n&&(t.dirty=n)}},W.domAtom.get=function(){return!1},W.ignoreForCoords.get=function(){return!1},Object.defineProperties(H.prototype,W);var q=[],J=function(e){function t(t,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")}e.call(this,t,q,s,null),this.widget=n,i=this}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={domAtom:{configurable:!0}};return t.prototype.matchesWidget=function(e){return 0==this.dirty&&e.type.eq(this.widget.type)},t.prototype.parseRule=function(){return{ignore:!0}},t.prototype.stopEvent=function(e){var t=this.widget.spec.stopEvent;return!!t&&t(e)},t.prototype.ignoreMutation=function(e){return"selection"!=e.type||this.widget.spec.ignoreSelection},t.prototype.destroy=function(){this.widget.type.destroy(this.dom),e.prototype.destroy.call(this)},n.domAtom.get=function(){return!0},Object.defineProperties(t.prototype,n),t}(H),X=function(e){function t(t,n,r,o){e.call(this,t,q,n,null),this.textDOM=r,this.text=o}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={size:{configurable:!0}};return n.size.get=function(){return this.text.length},t.prototype.localPosFromDOM=function(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t},t.prototype.domFromPos=function(e){return{node:this.textDOM,offset:e}},t.prototype.ignoreMutation=function(e){return"characterData"===e.type&&e.target.nodeValue==e.oldValue},Object.defineProperties(t.prototype,n),t}(H),U=function(e){function t(t,n,r,o){e.call(this,t,[],r,o),this.mark=n}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.create=function(e,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 t(e,n,a.dom,a.contentDOM||a.dom)},t.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}},t.prototype.matchesMark=function(e){return 3!=this.dirty&&this.mark.eq(e)},t.prototype.markDirty=function(t,n){if(e.prototype.markDirty.call(this,t,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}},t.prototype.slice=function(e,n,r){var o=t.create(this.parent,this.mark,!0,r),i=this.children,s=this.size;n<s&&(i=de(i,n,s,r)),e>0&&(i=de(i,0,e,r));for(var a=0;a<i.length;a++)i[a].parent=o;return o.children=i,o},t}(H),Y=function(e){function t(t,n,r,o,i,s,a,l,c){e.call(this,t,n.isLeaf?q:[],i,s),this.nodeDOM=a,this.node=n,this.outerDeco=r,this.innerDeco=o,s&&this.updateChildren(l,c)}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={size:{configurable:!0},border:{configurable:!0},domAtom:{configurable:!0}};return t.create=function(e,n,r,i,s,a){var l,c,u=s.nodeViews[n.type.name],d=u&&u(n,s,(function(){return c?c.parent?c.parent.posBeforeChild(c):void 0:a}),r,i),p=d&&d.dom,f=d&&d.contentDOM;if(n.isText)if(p){if(3!=p.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else p=document.createTextNode(n.text);else p||(p=(l=o.DOMSerializer.renderSpec(document,n.type.spec.toDOM(n))).dom,f=l.contentDOM);f||n.isText||"BR"==p.nodeName||(p.hasAttribute("contenteditable")||(p.contentEditable=!1),n.type.spec.draggable&&(p.draggable=!0));var h=p;return p=se(p,r,n),d?c=new ee(e,n,r,i,p,f,h,d,s,a+1):n.isText?new Q(e,n,r,i,p,h,s):new t(e,n,r,i,p,f,h,s,a+1)},t.prototype.parseRule=function(){var e=this;if(this.node.type.spec.reparseInView)return null;var t={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(t.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)){t.contentElement=r.dom.parentNode;break}}t.contentElement||(t.getContent=function(){return o.Fragment.empty})}else t.contentElement=this.contentDOM;else t.getContent=function(){return e.node.content};return t},t.prototype.matchesNode=function(e,t,n){return 0==this.dirty&&e.eq(this.node)&&ae(t,this.outerDeco)&&n.eq(this.innerDeco)},n.size.get=function(){return this.node.nodeSize},n.border.get=function(){return this.node.isLeaf?0:1},t.prototype.updateChildren=function(e,t){var n=this,r=this.node.inlineContent,i=t,a=e.composing&&this.localCompositionInfo(e,t),l=a&&a.pos>-1?a:null,c=a&&a.pos<0,u=new ce(this,l&&l.node);!function(e,t,n,r){var o=t.locals(e),i=0;if(0==o.length){for(var s=0;s<e.childCount;s++){var a=e.child(s);r(a,o,t.forChild(i,a),s),i+=a.nodeSize}return}for(var l=0,c=[],u=null,d=0;;){if(l<o.length&&o[l].to==i){for(var p=o[l++],f=void 0;l<o.length&&o[l].to==i;)(f||(f=[p])).push(o[l++]);if(f){f.sort(ue);for(var h=0;h<f.length;h++)n(f[h],d,!!u)}else n(p,d,!!u)}var m=void 0,v=void 0;if(u)v=-1,m=u,u=null;else{if(!(d<e.childCount))break;v=d,m=e.child(d++)}for(var g=0;g<c.length;g++)c[g].to<=i&&c.splice(g--,1);for(;l<o.length&&o[l].from<=i&&o[l].to>i;)c.push(o[l++]);var y=i+m.nodeSize;if(m.isText){var w=y;l<o.length&&o[l].from<w&&(w=o[l].from);for(var b=0;b<c.length;b++)c[b].to<w&&(w=c[b].to);w<y&&(u=m.cut(w-i),m=m.cut(0,w-i),y=w,v=-1)}var S=c.length?m.isInline&&!m.isLeaf?c.filter((function(e){return!e.inline})):c.slice():q;r(m,S,t.forChild(i,m),v),i=y}}(this.node,this.innerDeco,(function(t,s,a){t.spec.marks?u.syncToMarks(t.spec.marks,r,e):t.type.side>=0&&!a&&u.syncToMarks(s==n.node.childCount?o.Mark.none:n.node.child(s).marks,r,e),u.placeWidget(t,e,i)}),(function(t,n,o,s){var l;u.syncToMarks(t.marks,r,e),u.findNodeMatch(t,n,o,s)||c&&e.state.selection.from>i&&e.state.selection.to<i+t.nodeSize&&(l=u.findIndexWithChild(a.node))>-1&&u.updateNodeAt(t,n,o,l,e)||u.updateNextNode(t,n,o,e,s)||u.addNode(t,n,o,e,i),i+=t.nodeSize})),u.syncToMarks(q,r,e),this.node.isTextblock&&u.addTextblockHacks(),u.destroyRest(),(u.changed||2==this.dirty)&&(l&&this.protectLocalComposition(e,l),function e(t,n,r){for(var o=t.firstChild,i=!1,s=0;s<n.length;s++){var a=n[s],l=a.dom;if(l.parentNode==t){for(;l!=o;)o=le(o),i=!0;o=o.nextSibling}else i=!0,t.insertBefore(l,o);if(a instanceof U){var c=o?o.previousSibling:t.lastChild;e(a.contentDOM,a.children,r),o=c?c.nextSibling:t.firstChild}}for(;o;)o=le(o),i=!0;i&&r.trackWrites==t&&(r.trackWrites=null)}(this.contentDOM,this.children,e),s.ios&&function(e){if("UL"==e.nodeName||"OL"==e.nodeName){var t=e.style.cssText;e.style.cssText=t+"; list-style: square !important",window.getComputedStyle(e).listStyle,e.style.cssText=t}}(this.dom))},t.prototype.localCompositionInfo=function(e,t){var n=e.state.selection,o=n.from,i=n.to;if(!(!(e.state.selection instanceof r.TextSelection)||o<t||i>t+this.node.content.size)){var s=e.root.getSelection(),a=function(e,t){for(;;){if(3==e.nodeType)return e;if(1==e.nodeType&&t>0){if(e.childNodes.length>t&&3==e.childNodes[t].nodeType)return e.childNodes[t];e=e.childNodes[t-1],t=w(e)}else{if(!(1==e.nodeType&&t<e.childNodes.length))return null;e=e.childNodes[t],t=0}}}(s.focusNode,s.focusOffset);if(a&&this.dom.contains(a.parentNode)){if(this.node.inlineContent){var l=a.nodeValue,c=function(e,t,n,r){for(var o=0,i=0;o<e.childCount&&i<=r;){var s=e.child(o++),a=i;if(i+=s.nodeSize,s.isText){for(var l=s.text;o<e.childCount;){var c=e.child(o++);if(i+=c.nodeSize,!c.isText)break;l+=c.text}if(i>=n){var u=a<r?l.lastIndexOf(t,r-a-1):-1;if(u>=0&&u+t.length+a>=n)return a+u;if(n==r&&l.length>=r+t.length-a&&l.slice(r-a,r-a+t.length)==t)return r}}}return-1}(this.node.content,l,o-t,i-t);return c<0?null:{node:a,pos:c,text:l}}return{node:a,pos:-1}}}},t.prototype.protectLocalComposition=function(e,t){var n=t.node,r=t.pos,o=t.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 X(this,i,n,o);e.compositionNodes.push(s),this.children=de(this.children,r,r+o.length,e,s)}},t.prototype.update=function(e,t,n,r){return!(3==this.dirty||!e.sameMarkup(this.node))&&(this.updateInner(e,t,n,r),!0)},t.prototype.updateInner=function(e,t,n,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=0},t.prototype.updateOuterDeco=function(e){if(!ae(e,this.outerDeco)){var t=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=oe(this.dom,this.nodeDOM,re(this.outerDeco,this.node,t),re(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=null,this.dom.pmViewDesc=this),this.outerDeco=e}},t.prototype.selectNode=function(){this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.dom.draggable=!0)},t.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(t.prototype,n),t}(H);function G(e,t,n,r,o){return se(r,t,e),new Y(null,e,t,n,r,r,r,o,0)}var Q=function(e){function t(t,n,r,o,i,s,a){e.call(this,t,n,r,o,i,null,s,a)}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={domAtom:{configurable:!0}};return t.prototype.parseRule=function(){for(var e=this.nodeDOM.parentNode;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}},t.prototype.update=function(e,t,n,r){return!(3==this.dirty||0!=this.dirty&&!this.inParent()||!e.sameMarkup(this.node))&&(this.updateOuterDeco(t),0==this.dirty&&e.text==this.node.text||e.text==this.nodeDOM.nodeValue||(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=0,!0)},t.prototype.inParent=function(){for(var e=this.parent.contentDOM,t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1},t.prototype.domFromPos=function(e){return{node:this.nodeDOM,offset:e}},t.prototype.localPosFromDOM=function(t,n,r){return t==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):e.prototype.localPosFromDOM.call(this,t,n,r)},t.prototype.ignoreMutation=function(e){return"characterData"!=e.type&&"selection"!=e.type},t.prototype.slice=function(e,n,r){var o=this.node.cut(e,n),i=document.createTextNode(o.text);return new t(this.parent,o,this.outerDeco,this.innerDeco,i,i,r)},t.prototype.markDirty=function(t,n){e.prototype.markDirty.call(this,t,n),this.dom==this.nodeDOM||0!=t&&n!=this.nodeDOM.nodeValue.length||(this.dirty=3)},n.domAtom.get=function(){return!1},Object.defineProperties(t.prototype,n),t}(Y),Z=function(e){function t(){e.apply(this,arguments)}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={domAtom:{configurable:!0},ignoreForCoords:{configurable:!0}};return t.prototype.parseRule=function(){return{ignore:!0}},t.prototype.matchesHack=function(e){return 0==this.dirty&&this.dom.nodeName==e},n.domAtom.get=function(){return!0},n.ignoreForCoords.get=function(){return"IMG"==this.dom.nodeName},Object.defineProperties(t.prototype,n),t}(H),ee=function(e){function t(t,n,r,o,i,s,a,l,c,u){e.call(this,t,n,r,o,i,s,a,c,u),this.spec=l}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.update=function(t,n,r,o){if(3==this.dirty)return!1;if(this.spec.update){var i=this.spec.update(t,n,r);return i&&this.updateInner(t,n,r,o),i}return!(!this.contentDOM&&!t.isLeaf)&&e.prototype.update.call(this,t,n,r,o)},t.prototype.selectNode=function(){this.spec.selectNode?this.spec.selectNode():e.prototype.selectNode.call(this)},t.prototype.deselectNode=function(){this.spec.deselectNode?this.spec.deselectNode():e.prototype.deselectNode.call(this)},t.prototype.setSelection=function(t,n,r,o){this.spec.setSelection?this.spec.setSelection(t,n,r):e.prototype.setSelection.call(this,t,n,r,o)},t.prototype.destroy=function(){this.spec.destroy&&this.spec.destroy(),e.prototype.destroy.call(this)},t.prototype.stopEvent=function(e){return!!this.spec.stopEvent&&this.spec.stopEvent(e)},t.prototype.ignoreMutation=function(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):e.prototype.ignoreMutation.call(this,t)},t}(Y);function te(e){e&&(this.nodeName=e)}te.prototype=Object.create(null);var ne=[new te];function re(e,t,n){if(0==e.length)return ne;for(var r=n?ne[0]:new te,o=[r],i=0;i<e.length;i++){var s=e[i].type.attrs;if(s)for(var a in s.nodeName&&o.push(r=new te(s.nodeName)),s){var l=s[a];null!=l&&(n&&1==o.length&&o.push(r=new te(t.isInline?"span":"div")),"class"==a?r.class=(r.class?r.class+" ":"")+l:"style"==a?r.style=(r.style?r.style+";":"")+l:"nodeName"!=a&&(r[a]=l))}}return o}function oe(e,t,n,r){if(n==ne&&r==ne)return t;for(var o=t,i=0;i<r.length;i++){var s=r[i],a=n[i];if(i){var l=void 0;a&&a.nodeName==s.nodeName&&o!=e&&(l=o.parentNode)&&l.tagName.toLowerCase()==s.nodeName||((l=document.createElement(s.nodeName)).pmIsDeco=!0,l.appendChild(o),a=ne[0]),o=l}ie(o,a||ne[0],s)}return o}function ie(e,t,n){for(var r in t)"class"==r||"style"==r||"nodeName"==r||r in n||e.removeAttribute(r);for(var o in n)"class"!=o&&"style"!=o&&"nodeName"!=o&&n[o]!=t[o]&&e.setAttribute(o,n[o]);if(t.class!=n.class){for(var i=t.class?t.class.split(" ").filter(Boolean):q,s=n.class?n.class.split(" ").filter(Boolean):q,a=0;a<i.length;a++)-1==s.indexOf(i[a])&&e.classList.remove(i[a]);for(var l=0;l<s.length;l++)-1==i.indexOf(s[l])&&e.classList.add(s[l]);0==e.classList.length&&e.removeAttribute("class")}if(t.style!=n.style){if(t.style)for(var c,u=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;c=u.exec(t.style);)e.style.removeProperty(c[1]);n.style&&(e.style.cssText+=n.style)}}function se(e,t,n){return oe(e,e,ne,re(t,n,1!=e.nodeType))}function ae(e,t){if(e.length!=t.length)return!1;for(var n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function le(e){var t=e.nextSibling;return e.parentNode.removeChild(e),t}var ce=function(e,t){this.top=e,this.lock=t,this.index=0,this.stack=[],this.changed=!1,this.preMatch=function(e,t){var n=t,r=n.children.length,o=e.childCount,i=new Map,s=[];e:for(;o>0;){for(var a=void 0;;)if(r){var l=n.children[r-1];if(!(l instanceof U)){a=l,r--;break}n=l,r=l.children.length}else{if(n==t)break e;r=n.parent.children.indexOf(n),n=n.parent}var c=a.node;if(c){if(c!=e.child(o-1))break;--o,i.set(a,o),s.push(a)}}return{index:o,matched:i,matches:s.reverse()}}(e.node.content,e)};function ue(e,t){return e.type.side-t.type.side}function de(e,t,n,r,o){for(var i=[],s=0,a=0;s<e.length;s++){var l=e[s],c=a,u=a+=l.size;c>=n||u<=t?i.push(l):(c<t&&i.push(l.slice(0,t-c,r)),o&&(i.push(o),o=null),u>n&&i.push(l.slice(n-c,l.size,r)))}return i}function pe(e,t){var n=e.root.getSelection(),o=e.state.doc;if(!n.focusNode)return null;var i=e.docView.nearestDesc(n.focusNode),s=i&&0==i.size,a=e.docView.posFromDOM(n.focusNode,n.focusOffset);if(a<0)return null;var l,c,u=o.resolve(a);if(S(n)){for(l=u;i&&!i.node;)i=i.parent;if(i&&i.node.isAtom&&r.NodeSelection.isSelectable(i.node)&&i.parent&&(!i.node.isInline||!function(e,t,n){for(var r=0==t,o=t==w(e);r||o;){if(e==n)return!0;var i=p(e);if(!(e=e.parentNode))return!1;r=r&&0==i,o=o&&i==w(e)}}(n.focusNode,n.focusOffset,i.dom))){var d=i.posBefore;c=new r.NodeSelection(a==d?u:o.resolve(d))}}else{var f=e.docView.posFromDOM(n.anchorNode,n.anchorOffset);if(f<0)return null;l=o.resolve(f)}c||(c=Se(e,l,u,"pointer"==t||e.state.selection.head<u.pos&&!s?1:-1));return c}function fe(e){return e.editable?e.hasFocus():xe(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function he(e,t){var n=e.state.selection;if(we(e,n),fe(e)){if(!t&&e.mouseDown&&e.mouseDown.allowDefault&&s.chrome){var o=e.root.getSelection(),i=e.domObserver.currentSelection;if(o.anchorNode&&v(o.anchorNode,o.anchorOffset,i.anchorNode,i.anchorOffset))return e.mouseDown.delayedSelectionSync=!0,void e.domObserver.setCurSelection()}if(e.domObserver.disconnectSelection(),e.cursorWrapper)!function(e){var t=e.root.getSelection(),n=document.createRange(),r=e.cursorWrapper.dom,o="IMG"==r.nodeName;o?n.setEnd(r.parentNode,p(r)+1):n.setEnd(r,0);n.collapse(!1),t.removeAllRanges(),t.addRange(n),!o&&!e.state.selection.visible&&s.ie&&s.ie_version<=11&&(r.disabled=!0,r.disabled=!1)}(e);else{var a,l,c=n.anchor,u=n.head;!me||n instanceof r.TextSelection||(n.$from.parent.inlineContent||(a=ve(e,n.from)),n.empty||n.$from.parent.inlineContent||(l=ve(e,n.to))),e.docView.setSelection(c,u,e.root,t),me&&(a&&ye(a),l&&ye(l)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(e){var t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.hideSelectionGuard);var n=e.root.getSelection(),r=n.anchorNode,o=n.anchorOffset;t.addEventListener("selectionchange",e.hideSelectionGuard=function(){n.anchorNode==r&&n.anchorOffset==o||(t.removeEventListener("selectionchange",e.hideSelectionGuard),setTimeout((function(){fe(e)&&!e.state.selection.visible||e.dom.classList.remove("ProseMirror-hideselection")}),20))})}(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}ce.prototype.destroyBetween=function(e,t){if(e!=t){for(var n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}},ce.prototype.destroyRest=function(){this.destroyBetween(this.index,this.top.children.length)},ce.prototype.syncToMarks=function(e,t,n){for(var r=0,o=this.stack.length>>1,i=Math.min(o,e.length);r<i&&(r==o-1?this.top:this.stack[r+1<<1]).matchesMark(e[r])&&!1!==e[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<e.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(e[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 l=U.create(this.top,e[o],t,n);this.top.children.splice(this.index,0,l),this.top=l,this.changed=!0}this.index=0,o++}},ce.prototype.findNodeMatch=function(e,t,n,r){var o,i=-1;if(r>=this.preMatch.index&&(o=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,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 l=this.top.children[s];if(l.matchesNode(e,t,n)&&!this.preMatch.matched.has(l)){i=s;break}}return!(i<0)&&(this.destroyBetween(this.index,i),this.index++,!0)},ce.prototype.updateNodeAt=function(e,t,n,r,o){return!!this.top.children[r].update(e,t,n,o)&&(this.destroyBetween(this.index,r),this.index=r+1,!0)},ce.prototype.findIndexWithChild=function(e){for(;;){var t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){var n=e.pmViewDesc;if(n)for(var r=this.index;r<this.top.children.length;r++)if(this.top.children[r]==n)return r;return-1}e=t}},ce.prototype.updateNextNode=function(e,t,n,r,o){for(var i=this.index;i<this.top.children.length;i++){var s=this.top.children[i];if(s instanceof Y){var a=this.preMatch.matched.get(s);if(null!=a&&a!=o)return!1;var l=s.dom;if(!(this.lock&&(l==this.lock||1==l.nodeType&&l.contains(this.lock.parentNode))&&!(e.isText&&s.node&&s.node.isText&&s.nodeDOM.nodeValue==e.text&&3!=s.dirty&&ae(t,s.outerDeco)))&&s.update(e,t,n,r))return this.destroyBetween(this.index,i),s.dom!=l&&(this.changed=!0),this.index++,!0;break}}return!1},ce.prototype.addNode=function(e,t,n,r,o){this.top.children.splice(this.index++,0,Y.create(this.top,e,t,n,r,o)),this.changed=!0},ce.prototype.placeWidget=function(e,t,n){var r=this.index<this.top.children.length?this.top.children[this.index]:null;if(!r||!r.matchesWidget(e)||e!=r.widget&&r.widget.type.toDOM.parentNode){var o=new J(this.top,e,t,n);this.top.children.splice(this.index++,0,o),this.changed=!0}else this.index++},ce.prototype.addTextblockHacks=function(){for(var e=this.top.children[this.index-1],t=this.top;e instanceof U;)e=(t=e).children[t.children.length-1];e&&e instanceof Q&&!/\n$/.test(e.node.text)||((s.safari||s.chrome)&&e&&"false"==e.dom.contentEditable&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))},ce.prototype.addHackNode=function(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{var n=document.createElement(e);"IMG"==e&&(n.className="ProseMirror-separator",n.alt=""),"BR"==e&&(n.className="ProseMirror-trailingBreak");var r=new Z(this.top,q,n,null);t!=this.top?t.children.push(r):t.children.splice(this.index++,0,r),this.changed=!0}};var me=s.safari||s.chrome&&s.chrome_version<63;function ve(e,t){var n=e.docView.domFromPos(t,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 ge(i);if(!(i&&"false"!=i.contentEditable||a&&"false"!=a.contentEditable)){if(i)return ge(i);if(a)return ge(a)}}function ge(e){return e.contentEditable="true",s.safari&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function ye(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function we(e,t){if(t instanceof r.NodeSelection){var n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(be(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else be(e)}function be(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=null)}function Se(e,t,n,o){return e.someProp("createSelectionBetween",(function(r){return r(e,t,n)}))||r.TextSelection.between(t,n,o)}function ke(e){return(!e.editable||e.root.activeElement==e.dom)&&xe(e)}function xe(e){var t=e.root.getSelection();if(!t.anchorNode)return!1;try{return e.dom.contains(3==t.anchorNode.nodeType?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(3==t.focusNode.nodeType?t.focusNode.parentNode:t.focusNode))}catch(e){return!1}}function Ce(e,t){var n=e.selection,o=n.$anchor,i=n.$head,s=t>0?o.max(i):o.min(i),a=s.parent.inlineContent?s.depth?e.doc.resolve(t>0?s.after():s.before()):null:s;return a&&r.Selection.findFrom(a,t)}function Me(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function Oe(e,t,n){var o=e.state.selection;if(!(o instanceof r.TextSelection)){if(o instanceof r.NodeSelection&&o.node.isInline)return Me(e,new r.TextSelection(t>0?o.$to:o.$from));var i=Ce(e.state,t);return!!i&&Me(e,i)}if(!o.empty||n.indexOf("s")>-1)return!1;if(e.endOfTextblock(t>0?"right":"left")){var a=Ce(e.state,t);return!!(a&&a instanceof r.NodeSelection)&&Me(e,a)}if(!(s.mac&&n.indexOf("m")>-1)){var l,c=o.$head,u=c.textOffset?null:t<0?c.nodeBefore:c.nodeAfter;if(!u||u.isText)return!1;var d=t<0?c.pos-u.nodeSize:c.pos;return!!(u.isAtom||(l=e.docView.descAt(d))&&!l.contentDOM)&&(r.NodeSelection.isSelectable(u)?Me(e,new r.NodeSelection(t<0?e.state.doc.resolve(c.pos-u.nodeSize):c)):!!s.webkit&&Me(e,new r.TextSelection(e.state.doc.resolve(t<0?d:d+u.nodeSize))))}}function Te(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function Ae(e){var t=e.pmViewDesc;return t&&0==t.size&&(e.nextSibling||"BR"!=e.nodeName)}function Ne(e){var t=e.root.getSelection(),n=t.focusNode,r=t.focusOffset;if(n){var o,i,a=!1;for(s.gecko&&1==n.nodeType&&r<Te(n)&&Ae(n.childNodes[r])&&(a=!0);;)if(r>0){if(1!=n.nodeType)break;var l=n.childNodes[r-1];if(Ae(l))o=n,i=--r;else{if(3!=l.nodeType)break;r=(n=l).nodeValue.length}}else{if(De(n))break;for(var c=n.previousSibling;c&&Ae(c);)o=n.parentNode,i=p(c),c=c.previousSibling;if(c)r=Te(n=c);else{if((n=n.parentNode)==e.dom)break;r=0}}a?Ee(e,t,n,r):o&&Ee(e,t,o,i)}}function Re(e){var t=e.root.getSelection(),n=t.focusNode,r=t.focusOffset;if(n){for(var o,i,s=Te(n);;)if(r<s){if(1!=n.nodeType)break;if(!Ae(n.childNodes[r]))break;o=n,i=++r}else{if(De(n))break;for(var a=n.nextSibling;a&&Ae(a);)o=a.parentNode,i=p(a)+1,a=a.nextSibling;if(a)r=0,s=Te(n=a);else{if((n=n.parentNode)==e.dom)break;r=s=0}}o&&Ee(e,t,o,i)}}function De(e){var t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function Ee(e,t,n,r){if(S(t)){var o=document.createRange();o.setEnd(n,r),o.setStart(n,r),t.removeAllRanges(),t.addRange(o)}else t.extend&&t.extend(n,r);e.domObserver.setCurSelection();var i=e.state;setTimeout((function(){e.state==i&&he(e)}),50)}function ze(e,t,n){var o=e.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||e.endOfTextblock(t<0?"up":"down")){var l=Ce(e.state,t);if(l&&l instanceof r.NodeSelection)return Me(e,l)}if(!i.parent.inlineContent){var c=t<0?i:a,u=o instanceof r.AllSelection?r.Selection.near(c,t):r.Selection.findFrom(c,t);return!!u&&Me(e,u)}return!1}function _e(e,t){if(!(e.state.selection instanceof r.TextSelection))return!0;var n=e.state.selection,o=n.$head,i=n.$anchor,s=n.empty;if(!o.sameParent(i))return!0;if(!s)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;var a=!o.textOffset&&(t<0?o.nodeBefore:o.nodeAfter);if(a&&!a.isText){var l=e.state.tr;return t<0?l.delete(o.pos-a.nodeSize,o.pos):l.delete(o.pos,o.pos+a.nodeSize),e.dispatch(l),!0}return!1}function Ie(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function Pe(e,t){var n=t.keyCode,r=function(e){var t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}(t);return 8==n||s.mac&&72==n&&"c"==r?_e(e,-1)||Ne(e):46==n||s.mac&&68==n&&"c"==r?_e(e,1)||Re(e):13==n||27==n||(37==n?Oe(e,-1,r)||Ne(e):39==n?Oe(e,1,r)||Re(e):38==n?ze(e,-1,r)||Ne(e):40==n?function(e){if(s.safari&&!(e.state.selection.$head.parentOffset>0)){var t=e.root.getSelection(),n=t.focusNode,r=t.focusOffset;if(n&&1==n.nodeType&&0==r&&n.firstChild&&"false"==n.firstChild.contentEditable){var o=n.firstChild;Ie(e,o,!0),setTimeout((function(){return Ie(e,o,!1)}),20)}}}(e)||ze(e,1,r)||Re(e):r==(s.mac?"m":"c")&&(66==n||73==n||89==n||90==n))}function $e(e){var t=e.pmViewDesc;if(t)return t.parseRule();if("BR"==e.nodeName&&e.parentNode){if(s.safari&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){var n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}if(e.parentNode.lastChild==e||s.safari&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if("IMG"==e.nodeName&&e.getAttribute("mark-placeholder"))return{ignore:!0}}function Fe(e,t,n,i,a){if(t<0){var l=e.lastSelectionTime>Date.now()-50?e.lastSelectionOrigin:null,c=pe(e,l);if(c&&!e.state.selection.eq(c)){var u=e.state.tr.setSelection(c);"pointer"==l?u.setMeta("pointer",!0):"key"==l&&u.scrollIntoView(),e.dispatch(u)}}else{var d=e.state.doc.resolve(t),p=d.sharedDepth(n);t=d.before(p+1),n=e.state.doc.resolve(n).after(p+1);var f=e.state.selection,h=function(e,t,n){var r=e.docView.parseRange(t,n),i=r.node,a=r.fromOffset,l=r.toOffset,c=r.from,u=r.to,d=e.root.getSelection(),p=null,f=d.anchorNode;if(f&&e.dom.contains(1==f.nodeType?f:f.parentNode)&&(p=[{node:f,offset:d.anchorOffset}],S(d)||p.push({node:d.focusNode,offset:d.focusOffset})),s.chrome&&8===e.lastKeyCode)for(var h=l;h>a;h--){var m=i.childNodes[h-1],v=m.pmViewDesc;if("BR"==m.nodeName&&!v){l=h;break}if(!v||v.size)break}var g=e.state.doc,y=e.someProp("domParser")||o.DOMParser.fromSchema(e.state.schema),w=g.resolve(c),b=null,k=y.parse(i,{topNode:w.parent,topMatch:w.parent.contentMatchAt(w.index()),topOpen:!0,from:a,to:l,preserveWhitespace:"pre"!=w.parent.type.whitespace||"full",editableContent:!0,findPositions:p,ruleFromNode:$e,context:w});if(p&&null!=p[0].pos){var x=p[0].pos,C=p[1]&&p[1].pos;null==C&&(C=x),b={anchor:x+c,head:C+c}}return{doc:k,sel:b,from:c,to:u}}(e,t,n);if(s.chrome&&e.cursorWrapper&&h.sel&&h.sel.anchor==e.cursorWrapper.deco.from){var m=e.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=e.state.doc,b=w.slice(h.from,h.to);8===e.lastKeyCode&&Date.now()-100<e.lastKeyCodeTime?(g=e.state.selection.to,y="end"):(g=e.state.selection.from,y="start"),e.lastKeyCode=null;var x=function(e,t,n,r,o){var i=e.findDiffStart(t,n);if(null==i)return null;var s=e.findDiffEnd(t,n+e.size,n+t.size),a=s.a,l=s.b;if("end"==o){var c=Math.max(0,i-Math.min(a,l));r-=a+c-i}if(a<i&&e.size<t.size){l=(i-=r<=i&&r>=a?i-r:0)+(l-a),a=i}else if(l<i){a=(i-=r<=i&&r>=l?i-r:0)+(a-l),l=i}return{start:i,endA:a,endB:l}}(b.content,h.doc.content,h.from,g,y);if((s.ios&&e.lastIOSEnter>Date.now()-225||s.android)&&a.some((function(e){return"DIV"==e.nodeName||"P"==e.nodeName}))&&(!x||x.endA>=x.endB)&&e.someProp("handleKeyDown",(function(t){return t(e,k(13,"Enter"))})))e.lastIOSEnter=0;else{if(!x){if(!(i&&f instanceof r.TextSelection&&!f.empty&&f.$head.sameParent(f.$anchor))||e.composing||h.sel&&h.sel.anchor!=h.sel.head){if(h.sel){var C=Be(e,e.state.doc,h.sel);C&&!C.eq(e.state.selection)&&e.dispatch(e.state.tr.setSelection(C))}return}x={start:f.from,endA:f.to,endB:f.to}}e.domChangeCount++,e.state.selection.from<e.state.selection.to&&x.start==x.endB&&e.state.selection instanceof r.TextSelection&&(x.start>e.state.selection.from&&x.start<=e.state.selection.from+2&&e.state.selection.from>=h.from?x.start=e.state.selection.from:x.endA<e.state.selection.to&&x.endA>=e.state.selection.to-2&&e.state.selection.to<=h.to&&(x.endB+=e.state.selection.to-x.endA,x.endA=e.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),A=O.sameParent(T)&&O.parent.inlineContent;if((s.ios&&e.lastIOSEnter>Date.now()-225&&(!A||a.some((function(e){return"DIV"==e.nodeName||"P"==e.nodeName})))||!A&&O.pos<h.doc.content.size&&(M=r.Selection.findFrom(h.doc.resolve(O.pos+1),1,!0))&&M.head==T.pos)&&e.someProp("handleKeyDown",(function(t){return t(e,k(13,"Enter"))})))e.lastIOSEnter=0;else if(e.state.selection.anchor>x.start&&function(e,t,n,r,o){if(!r.parent.isTextblock||n-t<=o.pos-r.pos||Le(r,!0,!1)<o.pos)return!1;var i=e.resolve(t);if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;var s=e.resolve(Le(i,!0,!0));if(!s.parent.isTextblock||s.pos>n||Le(s,!0,!1)<n)return!1;return r.parent.content.cut(r.parentOffset).eq(s.parent.content)}(w,x.start,x.endA,O,T)&&e.someProp("handleKeyDown",(function(t){return t(e,k(8,"Backspace"))})))s.android&&s.chrome&&e.domObserver.suppressSelectionUpdates();else{s.chrome&&s.android&&x.toB==x.from&&(e.lastAndroidDelete=Date.now()),s.android&&!A&&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(){e.someProp("handleKeyDown",(function(t){return t(e,k(13,"Enter"))}))}),20));var N,R,D,E,z=x.start,_=x.endA;if(A)if(O.pos==T.pos)s.ie&&s.ie_version<=11&&0==O.parentOffset&&(e.domObserver.suppressSelectionUpdates(),setTimeout((function(){return he(e)}),20)),N=e.state.tr.delete(z,_),R=w.resolve(x.start).marksAcross(w.resolve(x.endA));else if(x.endA==x.endB&&(E=w.resolve(x.start))&&(D=function(e,t){for(var n,r,i,s=e.firstChild.marks,a=t.firstChild.marks,l=s,c=a,u=0;u<a.length;u++)l=a[u].removeFromSet(l);for(var d=0;d<s.length;d++)c=s[d].removeFromSet(c);if(1==l.length&&0==c.length)r=l[0],n="add",i=function(e){return e.mark(r.addToSet(e.marks))};else{if(0!=l.length||1!=c.length)return null;r=c[0],n="remove",i=function(e){return e.mark(r.removeFromSet(e.marks))}}for(var p=[],f=0;f<t.childCount;f++)p.push(i(t.child(f)));if(o.Fragment.from(p).eq(e))return{mark:r,type:n}}(O.parent.content.cut(O.parentOffset,T.parentOffset),E.parent.content.cut(E.parentOffset,x.endA-E.start()))))N=e.state.tr,"add"==D.type?N.addMark(z,_,D.mark):N.removeMark(z,_,D.mark);else if(O.parent.child(O.index()).isText&&O.index()==T.index()-(T.textOffset?0:1)){var I=O.parent.textBetween(O.parentOffset,T.parentOffset);if(e.someProp("handleTextInput",(function(t){return t(e,z,_,I)})))return;N=e.state.tr.insertText(I,z,_)}if(N||(N=e.state.tr.replace(z,_,h.doc.slice(x.start-h.from,x.endB-h.from))),h.sel){var P=Be(e,N.doc,h.sel);P&&!(s.chrome&&s.android&&e.composing&&P.empty&&(x.start!=x.endB||e.lastAndroidDelete<Date.now()-100)&&(P.head==z||P.head==N.mapping.map(_)-1)||s.ie&&P.empty&&P.head==z)&&N.setSelection(P)}R&&N.ensureMarks(R),e.dispatch(N.scrollIntoView())}}}}function Be(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:Se(e,t.resolve(n.anchor),t.resolve(n.head))}function Le(e,t,n){for(var r=e.depth,o=t?e.end():e.pos;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,o++,t=!1;if(n)for(var i=e.node(r).maybeChild(e.indexAfter(r));i&&!i.isLeaf;)i=i.firstChild,o++;return o}function Ve(e,t){for(var n=[],r=t.content,i=t.openStart,s=t.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 l=e.someProp("clipboardSerializer")||o.DOMSerializer.fromSchema(e.state.schema),c=Ue(),u=c.createElement("div");u.appendChild(l.serializeFragment(r,{document:c}));for(var d,p=u.firstChild;p&&1==p.nodeType&&(d=Je[p.nodeName.toLowerCase()]);){for(var f=d.length-1;f>=0;f--){for(var h=c.createElement(d[f]);u.firstChild;)h.appendChild(u.firstChild);u.appendChild(h),"tbody"!=d[f]&&(i++,s++)}p=u.firstChild}return p&&1==p.nodeType&&p.setAttribute("data-pm-slice",i+" "+s+" "+JSON.stringify(n)),{dom:u,text:e.someProp("clipboardTextSerializer",(function(e){return e(t)}))||t.content.textBetween(0,t.content.size,"\n\n")}}function je(e,t,n,r,i){var a,l,c=i.parent.type.spec.code;if(!n&&!t)return null;var u=t&&(r||c||!n);if(u){if(e.someProp("transformPastedText",(function(e){t=e(t,c||r)})),c)return t?new o.Slice(o.Fragment.from(e.state.schema.text(t.replace(/\r\n?/g,"\n"))),0,0):o.Slice.empty;var d=e.someProp("clipboardTextParser",(function(e){return e(t,i,r)}));if(d)l=d;else{var p=i.marks(),f=e.state.schema,h=o.DOMSerializer.fromSchema(f);a=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach((function(e){var t=a.appendChild(document.createElement("p"));e&&t.appendChild(h.serializeNode(f.text(e,p)))}))}}else e.someProp("transformPastedHTML",(function(e){n=e(n)})),a=function(e){var t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));var n,r=Ue().createElement("div"),o=/<([a-z][^>\s]+)/i.exec(e);(n=o&&Je[o[1].toLowerCase()])&&(e=n.map((function(e){return"<"+e+">"})).join("")+e+n.map((function(e){return"</"+e+">"})).reverse().join(""));if(r.innerHTML=e,n)for(var i=0;i<n.length;i++)r=r.querySelector(n[i])||r;return r}(n),s.webkit&&function(e){for(var t=e.querySelectorAll(s.chrome?"span:not([class]):not([style])":"span.Apple-converted-space"),n=0;n<t.length;n++){var r=t[n];1==r.childNodes.length&&" "==r.textContent&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),r)}}(a);var m=a&&a.querySelector("[data-pm-slice]"),v=m&&/^(\d+) (\d+) (.*)/.exec(m.getAttribute("data-pm-slice"));if(!l){var g=e.someProp("clipboardParser")||e.someProp("domParser")||o.DOMParser.fromSchema(e.state.schema);l=g.parseSlice(a,{preserveWhitespace:!(!u&&!v),context:i,ruleFromNode:function(e){if("BR"==e.nodeName&&!e.nextSibling&&e.parentNode&&!Ke.test(e.parentNode.nodeName))return{ignore:!0}}})}if(v)l=function(e,t){if(!e.size)return e;var n,r=e.content.firstChild.type.schema;try{n=JSON.parse(t)}catch(t){return e}for(var i=e.content,s=e.openStart,a=e.openEnd,l=n.length-2;l>=0;l-=2){var c=r.nodes[n[l]];if(!c||c.hasRequiredAttrs())break;i=o.Fragment.from(c.create(n[l+1],i)),s++,a++}return new o.Slice(i,s,a)}(qe(l,+v[1],+v[2]),v[3]);else if((l=o.Slice.maxOpen(function(e,t){if(e.childCount<2)return e;for(var n=function(n){var r=t.node(n).contentMatchAt(t.index(n)),i=void 0,s=[];if(e.forEach((function(e){if(s){var t,n=r.findWrapping(e.type);if(!n)return s=null;if(t=s.length&&i.length&&function e(t,n,r,i,s){if(s<t.length&&s<n.length&&t[s]==n[s]){var a=e(t,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==t.length-1?r.type:t[s+1]))return i.copy(i.content.append(o.Fragment.from(He(r,t,s+1))))}}(n,i,e,s[s.length-1],0))s[s.length-1]=t;else{s.length&&(s[s.length-1]=function e(t,n){if(0==n)return t;var r=t.content.replaceChild(t.childCount-1,e(t.lastChild,n-1)),i=t.contentMatchAt(t.childCount).fillBefore(o.Fragment.empty,!0);return t.copy(r.append(i))}(s[s.length-1],i.length));var a=He(e,n);s.push(a),r=r.matchType(a.type,a.attrs),i=n}}})),s)return{v:o.Fragment.from(s)}},r=t.depth;r>=0;r--){var i=n(r);if(i)return i.v}return e}(l.content,i),!0)).openStart||l.openEnd){for(var y=0,w=0,b=l.content.firstChild;y<l.openStart&&!b.type.spec.isolating;y++,b=b.firstChild);for(var S=l.content.lastChild;w<l.openEnd&&!S.type.spec.isolating;w++,S=S.lastChild);l=qe(l,y,w)}return e.someProp("transformPasted",(function(e){l=e(l)})),l}var Ke=/^(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 He(e,t,n){void 0===n&&(n=0);for(var r=t.length-1;r>=n;r--)e=t[r].create(null,o.Fragment.from(e));return e}function We(e,t,n,r,i,s){var a=t<0?e.firstChild:e.lastChild,l=a.content;return i<r-1&&(l=We(l,t,n,r,i+1,s)),i>=n&&(l=t<0?a.contentMatchAt(0).fillBefore(l,e.childCount>1||s<=i).append(l):l.append(a.contentMatchAt(a.childCount).fillBefore(o.Fragment.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,a.copy(l))}function qe(e,t,n){return t<e.openStart&&(e=new o.Slice(We(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new o.Slice(We(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}var Je={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]},Xe=null;function Ue(){return Xe||(Xe=document.implementation.createHTMLDocument("title"))}var Ye={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Ge=s.ie&&s.ie_version<=11,Qe=function(){this.anchorNode=this.anchorOffset=this.focusNode=this.focusOffset=null};Qe.prototype.set=function(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset},Qe.prototype.eq=function(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset};var Ze=function(e,t){var n=this;this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=window.MutationObserver&&new window.MutationObserver((function(e){for(var t=0;t<e.length;t++)n.queue.push(e[t]);s.ie&&s.ie_version<=11&&e.some((function(e){return"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length}))?n.flushSoon():n.flush()})),this.currentSelection=new Qe,Ge&&(this.onCharData=function(e){n.queue.push({target:e.target,type:"characterData",oldValue:e.prevValue}),n.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.suppressingSelectionUpdates=!1};Ze.prototype.flushSoon=function(){var e=this;this.flushingSoon<0&&(this.flushingSoon=window.setTimeout((function(){e.flushingSoon=-1,e.flush()}),20))},Ze.prototype.forceFlush=function(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())},Ze.prototype.start=function(){this.observer&&this.observer.observe(this.view.dom,Ye),Ge&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()},Ze.prototype.stop=function(){var e=this;if(this.observer){var t=this.observer.takeRecords();if(t.length){for(var n=0;n<t.length;n++)this.queue.push(t[n]);window.setTimeout((function(){return e.flush()}),20)}this.observer.disconnect()}Ge&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()},Ze.prototype.connectSelection=function(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)},Ze.prototype.disconnectSelection=function(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)},Ze.prototype.suppressSelectionUpdates=function(){var e=this;this.suppressingSelectionUpdates=!0,setTimeout((function(){return e.suppressingSelectionUpdates=!1}),50)},Ze.prototype.onSelectionChange=function(){if(ke(this.view)){if(this.suppressingSelectionUpdates)return he(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()}},Ze.prototype.setCurSelection=function(){this.currentSelection.set(this.view.root.getSelection())},Ze.prototype.ignoreSelectionChange=function(e){if(0==e.rangeCount)return!0;var t=e.getRangeAt(0).commonAncestorContainer,n=this.view.docView.nearestDesc(t);return n&&n.ignoreMutation({type:"selection",target:3==t.nodeType?t.parentNode:t})?(this.setCurSelection(),!0):void 0},Ze.prototype.flush=function(){if(this.view.docView&&!(this.flushingSoon>-1)){var e=this.observer?this.observer.takeRecords():[];this.queue.length&&(e=this.queue.concat(e),this.queue.length=0);var t=this.view.root.getSelection(),n=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(t)&&ke(this.view)&&!this.ignoreSelectionChange(t),r=-1,o=-1,i=!1,a=[];if(this.view.editable)for(var l=0;l<e.length;l++){var c=this.registerMutation(e[l],a);c&&(r=r<0?c.from:Math.min(c.from,r),o=o<0?c.to:Math.max(c.to,o),c.typeOver&&(i=!0))}if(s.gecko&&a.length>1){var u=a.filter((function(e){return"BR"==e.nodeName}));if(2==u.length){var d=u[0],p=u[1];d.parentNode&&d.parentNode.parentNode==p.parentNode?p.remove():d.remove()}}(r>-1||n)&&(r>-1&&(this.view.docView.markDirty(r,o),function(e){if(et)return;et=!0,"normal"==getComputedStyle(e.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(t)||he(this.view),this.currentSelection.set(t))}},Ze.prototype.registerMutation=function(e,t){if(t.indexOf(e.target)>-1)return null;var n=this.view.docView.nearestDesc(e.target);if("attributes"==e.type&&(n==this.view.docView||"contenteditable"==e.attributeName||"style"==e.attributeName&&!e.oldValue&&!e.target.getAttribute("style")))return null;if(!n||n.ignoreMutation(e))return null;if("childList"==e.type){for(var r=0;r<e.addedNodes.length;r++)t.push(e.addedNodes[r]);if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};var o=e.previousSibling,i=e.nextSibling;if(s.ie&&s.ie_version<=11&&e.addedNodes.length)for(var a=0;a<e.addedNodes.length;a++){var l=e.addedNodes[a],c=l.previousSibling,u=l.nextSibling;(!c||Array.prototype.indexOf.call(e.addedNodes,c)<0)&&(o=c),(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(i=u)}var d=o&&o.parentNode==e.target?p(o)+1:0,f=n.localPosFromDOM(e.target,d,-1),h=i&&i.parentNode==e.target?p(i):e.target.childNodes.length;return{from:f,to:n.localPosFromDOM(e.target,h,1)}}return"attributes"==e.type?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}};var et=!1;var tt={},nt={};function rt(e,t){e.lastSelectionOrigin=t,e.lastSelectionTime=Date.now()}function ot(e){e.someProp("handleDOMEvents",(function(t){for(var n in t)e.eventHandlers[n]||e.dom.addEventListener(n,e.eventHandlers[n]=function(t){return it(e,t)})}))}function it(e,t){return e.someProp("handleDOMEvents",(function(n){var r=n[t.type];return!!r&&(r(e,t)||t.defaultPrevented)}))}function st(e){return{left:e.clientX,top:e.clientY}}function at(e,t,n,r,o){if(-1==r)return!1;for(var i=e.state.doc.resolve(r),s=function(r){if(e.someProp(t,(function(t){return r>i.depth?t(e,n,i.nodeAfter,i.before(r),o,!0):t(e,n,i.node(r),i.before(r),o,!1)})))return{v:!0}},a=i.depth+1;a>0;a--){var l=s(a);if(l)return l.v}return!1}function lt(e,t,n){e.focused||e.focus();var r=e.state.tr.setSelection(t);"pointer"==n&&r.setMeta("pointer",!0),e.dispatch(r)}function ct(e,t,n,o,i){return at(e,"handleClickOn",t,n,o)||e.someProp("handleClick",(function(n){return n(e,t,o)}))||(i?function(e,t){if(-1==t)return!1;var n,o,i=e.state.selection;i instanceof r.NodeSelection&&(n=i.node);for(var s=e.state.doc.resolve(t),a=s.depth+1;a>0;a--){var l=a>s.depth?s.nodeAfter:s.node(a);if(r.NodeSelection.isSelectable(l)){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&&(lt(e,r.NodeSelection.create(e.state.doc,o),"pointer"),!0)}(e,n):function(e,t){if(-1==t)return!1;var n=e.state.doc.resolve(t),o=n.nodeAfter;return!!(o&&o.isAtom&&r.NodeSelection.isSelectable(o))&&(lt(e,new r.NodeSelection(n),"pointer"),!0)}(e,n))}function ut(e,t,n,r){return at(e,"handleDoubleClickOn",t,n,r)||e.someProp("handleDoubleClick",(function(n){return n(e,t,r)}))}function dt(e,t,n,o){return at(e,"handleTripleClickOn",t,n,o)||e.someProp("handleTripleClick",(function(n){return n(e,t,o)}))||function(e,t,n){if(0!=n.button)return!1;var o=e.state.doc;if(-1==t)return!!o.inlineContent&&(lt(e,r.TextSelection.create(o,0,o.content.size),"pointer"),!0);for(var i=o.resolve(t),s=i.depth+1;s>0;s--){var a=s>i.depth?i.nodeAfter:i.node(s),l=i.before(s);if(a.inlineContent)lt(e,r.TextSelection.create(o,l+1,l+1+a.content.size),"pointer");else{if(!r.NodeSelection.isSelectable(a))continue;lt(e,r.NodeSelection.create(o,l),"pointer")}return!0}}(e,n,o)}function pt(e){return wt(e)}nt.keydown=function(e,t){if(e.shiftKey=16==t.keyCode||t.shiftKey,!mt(e,t)&&(e.lastKeyCode=t.keyCode,e.lastKeyCodeTime=Date.now(),!s.android||!s.chrome||13!=t.keyCode))if(229!=t.keyCode&&e.domObserver.forceFlush(),!s.ios||13!=t.keyCode||t.ctrlKey||t.altKey||t.metaKey)e.someProp("handleKeyDown",(function(n){return n(e,t)}))||Pe(e,t)?t.preventDefault():rt(e,"key");else{var n=Date.now();e.lastIOSEnter=n,e.lastIOSEnterFallbackTimeout=setTimeout((function(){e.lastIOSEnter==n&&(e.someProp("handleKeyDown",(function(t){return t(e,k(13,"Enter"))})),e.lastIOSEnter=0)}),200)}},nt.keyup=function(e,t){16==t.keyCode&&(e.shiftKey=!1)},nt.keypress=function(e,t){if(!(mt(e,t)||!t.charCode||t.ctrlKey&&!t.altKey||s.mac&&t.metaKey))if(e.someProp("handleKeyPress",(function(n){return n(e,t)})))t.preventDefault();else{var n=e.state.selection;if(!(n instanceof r.TextSelection&&n.$from.sameParent(n.$to))){var o=String.fromCharCode(t.charCode);e.someProp("handleTextInput",(function(t){return t(e,n.$from.pos,n.$to.pos,o)}))||e.dispatch(e.state.tr.insertText(o).scrollIntoView()),t.preventDefault()}}};var ft=s.mac?"metaKey":"ctrlKey";tt.mousedown=function(e,t){e.shiftKey=t.shiftKey;var n=pt(e),r=Date.now(),o="singleClick";r-e.lastClick.time<500&&function(e,t){var n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}(t,e.lastClick)&&!t[ft]&&("singleClick"==e.lastClick.type?o="doubleClick":"doubleClick"==e.lastClick.type&&(o="tripleClick")),e.lastClick={time:r,x:t.clientX,y:t.clientY,type:o};var i=e.posAtCoords(st(t));i&&("singleClick"==o?(e.mouseDown&&e.mouseDown.done(),e.mouseDown=new ht(e,i,t,n)):("doubleClick"==o?ut:dt)(e,i.pos,i.inside,t)?t.preventDefault():rt(e,"pointer"))};var ht=function(e,t,n,o){var i,a,l=this;if(this.view=e,this.startDoc=e.state.doc,this.pos=t,this.event=n,this.flushed=o,this.selectNode=n[ft],this.allowDefault=n.shiftKey,this.delayedSelectionSync=!1,t.inside>-1)i=e.state.doc.nodeAt(t.inside),a=t.inside;else{var c=e.state.doc.resolve(t.pos);i=c.parent,a=c.depth?c.before():0}this.mightDrag=null;var u=o?null:n.target,d=u?e.docView.nearestDesc(u,!0):null;this.target=d?d.dom:null;var p=e.state.selection;(0==n.button&&i.type.spec.draggable&&!1!==i.type.spec.selectable||p instanceof r.NodeSelection&&p.from<=a&&p.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(){l.view.mouseDown==l&&l.target.setAttribute("contentEditable","false")}),20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),rt(e,"pointer")};function mt(e,t){return!!e.composing||!!(s.safari&&Math.abs(t.timeStamp-e.compositionEndedAt)<500)&&(e.compositionEndedAt=-2e8,!0)}ht.prototype.done=function(){var e=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 he(e.view)})),this.view.mouseDown=null},ht.prototype.up=function(e){if(this.done(),this.view.dom.contains(3==e.target.nodeType?e.target.parentNode:e.target)){var t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(st(e))),this.allowDefault||!t?rt(this.view,"pointer"):ct(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():0==e.button&&(this.flushed||s.safari&&this.mightDrag&&!this.mightDrag.node.isAtom||s.chrome&&!(this.view.state.selection instanceof r.TextSelection)&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(lt(this.view,r.Selection.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):rt(this.view,"pointer")}},ht.prototype.move=function(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0),rt(this.view,"pointer"),0==e.buttons&&this.done()},tt.touchdown=function(e){pt(e),rt(e,"pointer")},tt.contextmenu=function(e){return pt(e)};var vt=s.android?5e3:-1;function gt(e,t){clearTimeout(e.composingTimeout),t>-1&&(e.composingTimeout=setTimeout((function(){return wt(e)}),t))}function yt(e){var t;for(e.composing&&(e.composing=!1,e.compositionEndedAt=((t=document.createEvent("Event")).initEvent("event",!0,!0),t.timeStamp));e.compositionNodes.length>0;)e.compositionNodes.pop().markParentsDirty()}function wt(e,t){if(!(s.android&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),yt(e),t||e.docView&&e.docView.dirty){var n=pe(e);return n&&!n.eq(e.state.selection)?e.dispatch(e.state.tr.setSelection(n)):e.updateState(e.state),!0}return!1}}nt.compositionstart=nt.compositionupdate=function(e){if(!e.composing){e.domObserver.flush();var t=e.state,n=t.selection.$from;if(t.selection.empty&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some((function(e){return!1===e.type.spec.inclusive}))))e.markCursor=e.state.storedMarks||n.marks(),wt(e,!0),e.markCursor=null;else if(wt(e),s.gecko&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length)for(var r=e.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}e.composing=!0}gt(e,vt)},nt.compositionend=function(e,t){e.composing&&(e.composing=!1,e.compositionEndedAt=t.timeStamp,gt(e,20))};var bt=s.ie&&s.ie_version<15||s.ios&&s.webkit_version<604;function St(e,t,n,r){var i=je(e,t,n,e.shiftKey,e.state.selection.$from);if(e.someProp("handlePaste",(function(t){return t(e,r,i||o.Slice.empty)})))return!0;if(!i)return!1;var s=function(e){return 0==e.openStart&&0==e.openEnd&&1==e.content.childCount?e.content.firstChild:null}(i),a=s?e.state.tr.replaceSelectionWith(s,e.shiftKey):e.state.tr.replaceSelection(i);return e.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}tt.copy=nt.cut=function(e,t){var n=e.state.selection,r="cut"==t.type;if(!n.empty){var o=bt?null:t.clipboardData,i=Ve(e,n.content()),s=i.dom,a=i.text;o?(t.preventDefault(),o.clearData(),o.setData("text/html",s.innerHTML),o.setData("text/plain",a)):function(e,t){if(e.dom.parentNode){var n=e.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(t),n.style.cssText="position: fixed; left: -10000px; top: 10px";var r=getSelection(),o=document.createRange();o.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout((function(){n.parentNode&&n.parentNode.removeChild(n),e.focus()}),50)}}(e,s),r&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))}},nt.paste=function(e,t){if(!e.composing||s.android){var n=bt?null:t.clipboardData;n&&St(e,n.getData("text/plain"),n.getData("text/html"),t)?t.preventDefault():function(e,t){if(e.dom.parentNode){var n=e.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus(),setTimeout((function(){e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?St(e,r.value,null,t):St(e,r.textContent,r.innerHTML,t)}),50)}}(e,t)}};var kt=function(e,t){this.slice=e,this.move=t},xt=s.mac?"altKey":"ctrlKey";for(var Ct in tt.dragstart=function(e,t){var n=e.mouseDown;if(n&&n.done(),t.dataTransfer){var o=e.state.selection,i=o.empty?null:e.posAtCoords(st(t));if(i&&i.pos>=o.from&&i.pos<=(o instanceof r.NodeSelection?o.to-1:o.to));else if(n&&n.mightDrag)e.dispatch(e.state.tr.setSelection(r.NodeSelection.create(e.state.doc,n.mightDrag.pos)));else if(t.target&&1==t.target.nodeType){var s=e.docView.nearestDesc(t.target,!0);s&&s.node.type.spec.draggable&&s!=e.docView&&e.dispatch(e.state.tr.setSelection(r.NodeSelection.create(e.state.doc,s.posBefore)))}var a=e.state.selection.content(),l=Ve(e,a),c=l.dom,u=l.text;t.dataTransfer.clearData(),t.dataTransfer.setData(bt?"Text":"text/html",c.innerHTML),t.dataTransfer.effectAllowed="copyMove",bt||t.dataTransfer.setData("text/plain",u),e.dragging=new kt(a,!t[xt])}},tt.dragend=function(e){var t=e.dragging;window.setTimeout((function(){e.dragging==t&&(e.dragging=null)}),50)},nt.dragover=nt.dragenter=function(e,t){return t.preventDefault()},nt.drop=function(e,t){var n=e.dragging;if(e.dragging=null,t.dataTransfer){var s=e.posAtCoords(st(t));if(s){var a=e.state.doc.resolve(s.pos);if(a){var l=n&&n.slice;l?e.someProp("transformPasted",(function(e){l=e(l)})):l=je(e,t.dataTransfer.getData(bt?"Text":"text/plain"),bt?null:t.dataTransfer.getData("text/html"),!1,a);var c=n&&!t[xt];if(e.someProp("handleDrop",(function(n){return n(e,t,l||o.Slice.empty,c)})))t.preventDefault();else if(l){t.preventDefault();var u=l?Object(i.dropPoint)(e.state.doc,a.pos,l):a.pos;null==u&&(u=a.pos);var d=e.state.tr;c&&d.deleteSelection();var p=d.mapping.map(u),f=0==l.openStart&&0==l.openEnd&&1==l.content.childCount,h=d.doc;if(f?d.replaceRangeWith(p,p,l.content.firstChild):d.replaceRange(p,p,l),!d.doc.eq(h)){var m=d.doc.resolve(p);if(f&&r.NodeSelection.isSelectable(l.content.firstChild)&&m.nodeAfter&&m.nodeAfter.sameMarkup(l.content.firstChild))d.setSelection(new r.NodeSelection(m));else{var v=d.mapping.map(u);d.mapping.maps[d.mapping.maps.length-1].forEach((function(e,t,n,r){return v=r})),d.setSelection(Se(e,m,d.doc.resolve(v)))}e.focus(),e.dispatch(d.setMeta("uiEvent","drop"))}}}}}},tt.focus=function(e){e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout((function(){e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.root.getSelection())&&he(e)}),20))},tt.blur=function(e,t){e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),t.relatedTarget&&e.dom.contains(t.relatedTarget)&&e.domObserver.currentSelection.set({}),e.focused=!1)},tt.beforeinput=function(e,t){if(s.chrome&&s.android&&"deleteContentBackward"==t.inputType){e.domObserver.flushSoon();var n=e.domChangeCount;setTimeout((function(){if(e.domChangeCount==n&&(e.dom.blur(),e.focus(),!e.someProp("handleKeyDown",(function(t){return t(e,k(8,"Backspace"))})))){var t=e.state.selection.$cursor;t&&t.pos>0&&e.dispatch(e.state.tr.delete(t.pos-1,t.pos).scrollIntoView())}}),50)}},nt)tt[Ct]=nt[Ct];function Mt(e,t){if(e==t)return!0;for(var n in e)if(e[n]!==t[n])return!1;for(var r in t)if(!(r in e))return!1;return!0}var Ot=function(e,t){this.spec=t||Et,this.side=this.spec.side||0,this.toDOM=e};Ot.prototype.map=function(e,t,n,r){var o=e.mapResult(t.from+r,this.side<0?-1:1),i=o.pos;return o.deleted?null:new Nt(i-n,i-n,this)},Ot.prototype.valid=function(){return!0},Ot.prototype.eq=function(e){return this==e||e instanceof Ot&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Mt(this.spec,e.spec))},Ot.prototype.destroy=function(e){this.spec.destroy&&this.spec.destroy(e)};var Tt=function(e,t){this.spec=t||Et,this.attrs=e};Tt.prototype.map=function(e,t,n,r){var o=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,i=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return o>=i?null:new Nt(o,i,this)},Tt.prototype.valid=function(e,t){return t.from<t.to},Tt.prototype.eq=function(e){return this==e||e instanceof Tt&&Mt(this.attrs,e.attrs)&&Mt(this.spec,e.spec)},Tt.is=function(e){return e.type instanceof Tt};var At=function(e,t){this.spec=t||Et,this.attrs=e};At.prototype.map=function(e,t,n,r){var o=e.mapResult(t.from+r,1);if(o.deleted)return null;var i=e.mapResult(t.to+r,-1);return i.deleted||i.pos<=o.pos?null:new Nt(o.pos-n,i.pos-n,this)},At.prototype.valid=function(e,t){var n,r=e.content.findIndex(t.from),o=r.index,i=r.offset;return i==t.from&&!(n=e.child(o)).isText&&i+n.nodeSize==t.to},At.prototype.eq=function(e){return this==e||e instanceof At&&Mt(this.attrs,e.attrs)&&Mt(this.spec,e.spec)};var Nt=function(e,t,n){this.from=e,this.to=t,this.type=n},Rt={spec:{configurable:!0},inline:{configurable:!0}};Nt.prototype.copy=function(e,t){return new Nt(e,t,this.type)},Nt.prototype.eq=function(e,t){return void 0===t&&(t=0),this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to},Nt.prototype.map=function(e,t,n){return this.type.map(e,this,t,n)},Nt.widget=function(e,t,n){return new Nt(e,e,new Ot(t,n))},Nt.inline=function(e,t,n,r){return new Nt(e,t,new Tt(n,r))},Nt.node=function(e,t,n,r){return new Nt(e,t,new At(n,r))},Rt.spec.get=function(){return this.type.spec},Rt.inline.get=function(){return this.type instanceof Tt},Object.defineProperties(Nt.prototype,Rt);var Dt=[],Et={},zt=function(e,t){this.local=e&&e.length?e:Dt,this.children=t&&t.length?t:Dt};zt.create=function(e,t){return t.length?Bt(t,e,0,Et):_t},zt.prototype.find=function(e,t,n){var r=[];return this.findInner(null==e?0:e,null==t?1e9:t,r,0,n),r},zt.prototype.findInner=function(e,t,n,r,o){for(var i=0;i<this.local.length;i++){var s=this.local[i];s.from<=t&&s.to>=e&&(!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]<t&&this.children[a+1]>e){var l=this.children[a]+1;this.children[a+2].findInner(e-l,t-l,n,r+l,o)}},zt.prototype.map=function(e,t,n){return this==_t||0==e.maps.length?this:this.mapInner(e,t,0,0,n||Et)},zt.prototype.mapInner=function(e,t,n,r,o){for(var i,s=0;s<this.local.length;s++){var a=this.local[s].map(e,n,r);a&&a.type.valid(t,a)?(i||(i=[])).push(a):o.onRemove&&o.onRemove(this.local[s].spec)}return this.children.length?function(e,t,n,r,o,i,s){for(var a=e.slice(),l=function(e,t,n,r){for(var s=0;s<a.length;s+=3){var l=a[s+1],c=void 0;if(!(l<0||e>l+i)){var u=a[s]+i;t>=u?a[s+1]=e<=u?-2:-1:n>=o&&(c=r-n-(t-e))&&(a[s]+=c,a[s+1]+=c)}}},c=0;c<n.maps.length;c++)n.maps[c].forEach(l);for(var u=!1,d=0;d<a.length;d+=3)if(a[d+1]<0){if(-2==a[d+1]){u=!0,a[d+1]=-1;continue}var p=n.map(e[d]+i),f=p-o;if(f<0||f>=r.content.size){u=!0;continue}var h=n.map(e[d+1]+i,-1)-o,m=r.content.findIndex(f),v=m.index,g=m.offset,y=r.maybeChild(v);if(y&&g==f&&g+y.nodeSize==h){var w=a[d+2].mapInner(n,y,p+1,e[d]+i+1,s);w!=_t?(a[d]=f,a[d+1]=h,a[d+2]=w):(a[d+1]=-2,u=!0)}else u=!0}if(u){var b=Bt(function(e,t,n,r,o,i,s){function a(e,t){for(var i=0;i<e.local.length;i++){var l=e.local[i].map(r,o,t);l?n.push(l):s.onRemove&&s.onRemove(e.local[i].spec)}for(var c=0;c<e.children.length;c+=3)a(e.children[c+2],e.children[c]+t+1)}for(var l=0;l<e.length;l+=3)-1==e[l+1]&&a(e[l+2],t[l]+i+1);return n}(a,e,t||[],n,o,i,s),r,0,s);t=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 zt(t&&t.sort(Lt),a)}(this.children,i,e,t,n,r,o):i?new zt(i.sort(Lt)):_t},zt.prototype.add=function(e,t){return t.length?this==_t?zt.create(e,t):this.addInner(e,t,0):this},zt.prototype.addInner=function(e,t,n){var r,o=this,i=0;e.forEach((function(e,s){var a,l=s+n;if(a=$t(t,e,l)){for(r||(r=o.children.slice());i<r.length&&r[i]<s;)i+=3;r[i]==s?r[i+2]=r[i+2].addInner(e,a,l+1):r.splice(i,0,s,s+e.nodeSize,Bt(a,e,l+1,Et)),i+=3}}));for(var s=Pt(i?Ft(t):t,-n),a=0;a<s.length;a++)s[a].type.valid(e,s[a])||s.splice(a--,1);return new zt(s.length?this.local.concat(s).sort(Lt):this.local,r||this.children)},zt.prototype.remove=function(e){return 0==e.length||this==_t?this:this.removeInner(e,0)},zt.prototype.removeInner=function(e,t){for(var n=this.children,r=this.local,o=0;o<n.length;o+=3){for(var i=void 0,s=n[o]+t,a=n[o+1]+t,l=0,c=void 0;l<e.length;l++)(c=e[l])&&c.from>s&&c.to<a&&(e[l]=null,(i||(i=[])).push(c));if(i){n==this.children&&(n=this.children.slice());var u=n[o+2].removeInner(i,s+1);u!=_t?n[o+2]=u:(n.splice(o,3),o-=3)}}if(r.length)for(var d=0,p=void 0;d<e.length;d++)if(p=e[d])for(var f=0;f<r.length;f++)r[f].eq(p,t)&&(r==this.local&&(r=this.local.slice()),r.splice(f--,1));return n==this.children&&r==this.local?this:r.length||n.length?new zt(r,n):_t},zt.prototype.forChild=function(e,t){if(this==_t)return this;if(t.isLeaf)return zt.empty;for(var n,r,o=0;o<this.children.length;o+=3)if(this.children[o]>=e){this.children[o]==e&&(n=this.children[o+2]);break}for(var i=e+1,s=i+t.content.size,a=0;a<this.local.length;a++){var l=this.local[a];if(l.from<s&&l.to>i&&l.type instanceof Tt){var c=Math.max(i,l.from)-i,u=Math.min(s,l.to)-i;c<u&&(r||(r=[])).push(l.copy(c,u))}}if(r){var d=new zt(r.sort(Lt));return n?new It([d,n]):d}return n||_t},zt.prototype.eq=function(e){if(this==e)return!0;if(!(e instanceof zt)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(var t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(var n=0;n<this.children.length;n+=3)if(this.children[n]!=e.children[n]||this.children[n+1]!=e.children[n+1]||!this.children[n+2].eq(e.children[n+2]))return!1;return!0},zt.prototype.locals=function(e){return Vt(this.localsInner(e))},zt.prototype.localsInner=function(e){if(this==_t)return Dt;if(e.inlineContent||!this.local.some(Tt.is))return this.local;for(var t=[],n=0;n<this.local.length;n++)this.local[n].type instanceof Tt||t.push(this.local[n]);return t};var _t=new zt;zt.empty=_t,zt.removeOverlap=Vt;var It=function(e){this.members=e};function Pt(e,t){if(!t||!e.length)return e;for(var n=[],r=0;r<e.length;r++){var o=e[r];n.push(new Nt(o.from+t,o.to+t,o.type))}return n}function $t(e,t,n){if(t.isLeaf)return null;for(var r=n+t.nodeSize,o=null,i=0,s=void 0;i<e.length;i++)(s=e[i])&&s.from>n&&s.to<r&&((o||(o=[])).push(s),e[i]=null);return o}function Ft(e){for(var t=[],n=0;n<e.length;n++)null!=e[n]&&t.push(e[n]);return t}function Bt(e,t,n,r){var o=[],i=!1;t.forEach((function(t,s){var a=$t(e,t,s+n);if(a){i=!0;var l=Bt(a,t,n+s+1,r);l!=_t&&o.push(s,s+t.nodeSize,l)}}));for(var s=Pt(i?Ft(e):e,-n).sort(Lt),a=0;a<s.length;a++)s[a].type.valid(t,s[a])||(r.onRemove&&r.onRemove(s[a].spec),s.splice(a--,1));return s.length||o.length?new zt(s,o):_t}function Lt(e,t){return e.from-t.from||e.to-t.to}function Vt(e){for(var t=e,n=0;n<t.length-1;n++){var r=t[n];if(r.from!=r.to)for(var o=n+1;o<t.length;o++){var i=t[o];if(i.from!=r.from){i.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,i.from),jt(t,o,r.copy(i.from,r.to)));break}i.to!=r.to&&(t==e&&(t=e.slice()),t[o]=i.copy(i.from,r.to),jt(t,o+1,i.copy(r.to,i.to)))}}return t}function jt(e,t,n){for(;t<e.length&&Lt(n,e[t])>0;)t++;e.splice(t,0,n)}function Kt(e){var t=[];return e.someProp("decorations",(function(n){var r=n(e.state);r&&r!=_t&&t.push(r)})),e.cursorWrapper&&t.push(zt.create(e.state.doc,[e.cursorWrapper.deco])),It.from(t)}It.prototype.map=function(e,t){var n=this.members.map((function(n){return n.map(e,t,Et)}));return It.from(n)},It.prototype.forChild=function(e,t){if(t.isLeaf)return zt.empty;for(var n=[],r=0;r<this.members.length;r++){var o=this.members[r].forChild(e,t);o!=_t&&(o instanceof It?n=n.concat(o.members):n.push(o))}return It.from(n)},It.prototype.eq=function(e){if(!(e instanceof It)||e.members.length!=this.members.length)return!1;for(var t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0},It.prototype.locals=function(e){for(var t,n=!0,r=0;r<this.members.length;r++){var o=this.members[r].localsInner(e);if(o.length)if(t){n&&(t=t.slice(),n=!1);for(var i=0;i<o.length;i++)t.push(o[i])}else t=o}return t?Vt(n?t:t.sort(Lt)):Dt},It.from=function(e){switch(e.length){case 0:return _t;case 1:return e[0];default:return new It(e)}};var Ht=function(e,t){this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Yt),this.dispatch=this.dispatch.bind(this),this._root=null,this.focused=!1,this.trackWrites=null,this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):e.apply?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Xt(this),this.markCursor=null,this.cursorWrapper=null,Jt(this),this.nodeViews=Ut(this),this.docView=G(this.state.doc,qt(this),Kt(this),this.dom,this),this.lastSelectedViewDesc=null,this.dragging=null,function(e){e.shiftKey=!1,e.mouseDown=null,e.lastKeyCode=null,e.lastKeyCodeTime=0,e.lastClick={time:0,x:0,y:0,type:""},e.lastSelectionOrigin=null,e.lastSelectionTime=0,e.lastIOSEnter=0,e.lastIOSEnterFallbackTimeout=null,e.lastAndroidDelete=0,e.composing=!1,e.composingTimeout=null,e.compositionNodes=[],e.compositionEndedAt=-2e8,e.domObserver=new Ze(e,(function(t,n,r,o){return Fe(e,t,n,r,o)})),e.domObserver.start(),e.domChangeCount=0,e.eventHandlers=Object.create(null);var t=function(t){var n=tt[t];e.dom.addEventListener(t,e.eventHandlers[t]=function(t){!function(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(var n=t.target;n!=e.dom;n=n.parentNode)if(!n||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}(e,t)||it(e,t)||!e.editable&&t.type in nt||n(e,t)})};for(var n in tt)t(n);s.safari&&e.dom.addEventListener("input",(function(){return null})),ot(e)}(this),this.prevDirectPlugins=[],this.pluginViews=[],this.updatePluginViews()},Wt={props:{configurable:!0},root:{configurable:!0},isDestroyed:{configurable:!0}};function qt(e){var t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(e.editable),t.translate="no",e.someProp("attributes",(function(n){if("function"==typeof n&&(n=n(e.state)),n)for(var r in n)"class"==r&&(t.class+=" "+n[r]),"style"==r?t.style=(t.style?t.style+";":"")+n[r]:t[r]||"contenteditable"==r||"nodeName"==r||(t[r]=String(n[r]))})),[Nt.node(0,e.state.doc.content.size,t)]}function Jt(e){if(e.markCursor){var t=document.createElement("img");t.className="ProseMirror-separator",t.setAttribute("mark-placeholder","true"),t.setAttribute("alt",""),e.cursorWrapper={dom:t,deco:Nt.widget(e.state.selection.head,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function Xt(e){return!e.someProp("editable",(function(t){return!1===t(e.state)}))}function Ut(e){var t={};return e.someProp("nodeViews",(function(e){for(var n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])})),t}function Yt(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}Wt.props.get=function(){if(this._props.state!=this.state){var e=this._props;for(var t in this._props={},e)this._props[t]=e[t];this._props.state=this.state}return this._props},Ht.prototype.update=function(e){e.handleDOMEvents!=this._props.handleDOMEvents&&ot(this),this._props=e,e.plugins&&(e.plugins.forEach(Yt),this.directPlugins=e.plugins),this.updateStateInner(e.state,!0)},Ht.prototype.setProps=function(e){var t={};for(var n in this._props)t[n]=this._props[n];for(var r in t.state=this.state,e)t[r]=e[r];this.update(t)},Ht.prototype.updateState=function(e){this.updateStateInner(e,this.state.plugins!=e.plugins)},Ht.prototype.updateStateInner=function(e,t){var n=this,o=this.state,i=!1,a=!1;if(e.storedMarks&&this.composing&&(yt(this),a=!0),this.state=e,t){var l=Ut(this);(function(e,t){var n=0,r=0;for(var o in e){if(e[o]!=t[o])return!0;n++}for(var i in t)r++;return n!=r})(l,this.nodeViews)&&(this.nodeViews=l,i=!0),ot(this)}this.editable=Xt(this),Jt(this);var c=Kt(this),u=qt(this),d=t?"reset":e.scrollToSelection>o.scrollToSelection?"to selection":"preserve",p=i||!this.docView.matchesNode(e.doc,u,c);!p&&e.selection.eq(o.selection)||(a=!0);var f,h,m,g,y,w,b,S,k,x,C,M="preserve"==d&&a&&null==this.dom.style.overflowAnchor&&function(e){for(var t,n,r=e.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=e.root.elementFromPoint(i,s);if(a!=e.dom&&e.dom.contains(a)){var l=a.getBoundingClientRect();if(l.top>=o-20){t=a,n=l.top;break}}}return{refDOM:t,refTop:n,stack:T(e.dom)}}(this);if(a){this.domObserver.stop();var N=p&&(s.ie||s.chrome)&&!this.composing&&!o.selection.empty&&!e.selection.empty&&(g=o.selection,y=e.selection,w=Math.min(g.$anchor.sharedDepth(g.head),y.$anchor.sharedDepth(y.head)),g.$anchor.start(w)!=y.$anchor.start(w));if(p){var R=s.chrome?this.trackWrites=this.root.getSelection().focusNode:null;!i&&this.docView.update(e.doc,u,c,this)||(this.docView.updateOuterDeco([]),this.docView.destroy(),this.docView=G(e.doc,u,c,this.dom,this)),R&&!this.trackWrites&&(N=!0)}N||!(this.mouseDown&&this.domObserver.currentSelection.eq(this.root.getSelection())&&(f=this,h=f.docView.domFromPos(f.state.selection.anchor,0),m=f.root.getSelection(),v(h.node,h.offset,m.anchorNode,m.anchorOffset)))?he(this,N):(we(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}if(this.updatePluginViews(o),"reset"==d)this.dom.scrollTop=0;else if("to selection"==d){var D=this.root.getSelection().focusNode;this.someProp("handleScrollToSelection",(function(e){return e(n)}))||(e.selection instanceof r.NodeSelection?O(this,this.docView.domAfterPos(e.selection.from).getBoundingClientRect(),D):O(this,this.coordsAtPos(e.selection.head,1),D))}else M&&(S=(b=M).refDOM,k=b.refTop,x=b.stack,C=S?S.getBoundingClientRect().top:0,A(x,0==C?0:C-k))},Ht.prototype.destroyPluginViews=function(){for(var e;e=this.pluginViews.pop();)e.destroy&&e.destroy()},Ht.prototype.updatePluginViews=function(e){if(e&&e.plugins==this.state.plugins&&this.directPlugins==this.prevDirectPlugins)for(var t=0;t<this.pluginViews.length;t++){var n=this.pluginViews[t];n.update&&n.update(this,e)}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))}}},Ht.prototype.someProp=function(e,t){var n,r=this._props&&this._props[e];if(null!=r&&(n=t?t(r):r))return n;for(var o=0;o<this.directPlugins.length;o++){var i=this.directPlugins[o].props[e];if(null!=i&&(n=t?t(i):i))return n}var s=this.state.plugins;if(s)for(var a=0;a<s.length;a++){var l=s[a].props[e];if(null!=l&&(n=t?t(l):l))return n}},Ht.prototype.hasFocus=function(){return this.root.activeElement==this.dom},Ht.prototype.focus=function(){this.domObserver.stop(),this.editable&&function(e){if(e.setActive)return e.setActive();if(N)return e.focus(N);var t=T(e);e.focus(null==N?{get preventScroll(){return N={preventScroll:!0},!0}}:void 0),N||(N=!1,A(t,0))}(this.dom),he(this),this.domObserver.start()},Wt.root.get=function(){var e=this._root;if(null==e)for(var t=this.dom.parentNode;t;t=t.parentNode)if(9==t.nodeType||11==t.nodeType&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=function(){return document.getSelection()}),this._root=t;return e||document},Ht.prototype.posAtCoords=function(e){return E(this,e)},Ht.prototype.coordsAtPos=function(e,t){return void 0===t&&(t=1),I(this,e,t)},Ht.prototype.domAtPos=function(e,t){return void 0===t&&(t=0),this.docView.domFromPos(e,t)},Ht.prototype.nodeDOM=function(e){var t=this.docView.descAt(e);return t?t.nodeDOM:null},Ht.prototype.posAtDOM=function(e,t,n){void 0===n&&(n=-1);var r=this.docView.posFromDOM(e,t,n);if(null==r)throw new RangeError("DOM position not inside the editor");return r},Ht.prototype.endOfTextblock=function(e,t){return K(this,t||this.state,e)},Ht.prototype.destroy=function(){this.docView&&(!function(e){for(var t in e.domObserver.stop(),e.eventHandlers)e.dom.removeEventListener(t,e.eventHandlers[t]);clearTimeout(e.composingTimeout),clearTimeout(e.lastIOSEnterFallbackTimeout)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Kt(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null)},Wt.isDestroyed.get=function(){return null==this.docView},Ht.prototype.dispatchEvent=function(e){return function(e,t){it(e,t)||!tt[t.type]||!e.editable&&t.type in nt||tt[t.type](e,t)}(this,e)},Ht.prototype.dispatch=function(e){var t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))},Object.defineProperties(Ht.prototype,Wt)},function(e,t,n){"use strict";n.r(t),n.d(t,"__extends",(function(){return o})),n.d(t,"__assign",(function(){return i})),n.d(t,"__rest",(function(){return s})),n.d(t,"__decorate",(function(){return a})),n.d(t,"__param",(function(){return l})),n.d(t,"__metadata",(function(){return c})),n.d(t,"__awaiter",(function(){return u})),n.d(t,"__generator",(function(){return d})),n.d(t,"__createBinding",(function(){return p})),n.d(t,"__exportStar",(function(){return f})),n.d(t,"__values",(function(){return h})),n.d(t,"__read",(function(){return m})),n.d(t,"__spread",(function(){return v})),n.d(t,"__spreadArrays",(function(){return g})),n.d(t,"__await",(function(){return y})),n.d(t,"__asyncGenerator",(function(){return w})),n.d(t,"__asyncDelegator",(function(){return b})),n.d(t,"__asyncValues",(function(){return S})),n.d(t,"__makeTemplateObject",(function(){return k})),n.d(t,"__importStar",(function(){return x})),n.d(t,"__importDefault",(function(){return C})),n.d(t,"__classPrivateFieldGet",(function(){return M})),n.d(t,"__classPrivateFieldSet",(function(){return O}));
|
|
2
2
|
/*! *****************************************************************************
|
|
3
3
|
Copyright (c) Microsoft Corporation.
|
|
4
4
|
|