Created
August 31, 2019 12:00
-
-
Save muthu32/da0158d0d62132ffb068d5b51e4d7280 to your computer and use it in GitHub Desktop.
Prosemirror iife compiled
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var prosemirror=function(e){'use strict';var d=String.fromCharCode,p=Math.floor,s=Math.max,l=Math.min;function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e["default"]:e}function o(e,t){return t={exports:{}},e(t,t.exports),t.exports}function n(e){this.content=e}function r(e){var t=ye&&(e.ctrlKey||e.altKey||e.metaKey)||fe&&e.shiftKey&&e.key&&1==e.key.length,o=!t&&e.key||(e.shiftKey?he:ce)[e.keyCode]||e.key||"Unidentified";return"Esc"==o&&(o="Escape"),"Del"==o&&(o="Delete"),"Left"==o&&(o="ArrowLeft"),"Up"==o&&(o="ArrowUp"),"Right"==o&&(o="ArrowRight"),"Down"==o&&(o="ArrowDown"),o}n.prototype={constructor:n,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,o){var r=o&&o!=e?this.remove(o):this,d=r.find(e),i=r.content.slice();return-1==d?i.push(o||e,t):(i[d+1]=t,o&&(i[d]=o)),new n(i)},remove:function(e){var t=this.find(e);if(-1==t)return this;var o=this.content.slice();return o.splice(t,2),new n(o)},addToStart:function(e,t){return new n([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var o=this.remove(e).content.slice();return o.push(e,t),new n(o)},addBefore:function(e,t,o){var r=this.remove(t),d=r.content.slice(),i=r.find(e);return d.splice(-1==i?d.length:i,0,t,o),new n(d)},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=n.from(e),e.size?new n(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=n.from(e),e.size?new n(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=n.from(e);for(var o=0;o<e.content.length;o+=2)t=t.remove(e.content[o]);return t},get size(){return this.content.length>>1}},n.from=function(e){if(e instanceof n)return e;var t=[];if(e)for(var o in e)t.push(o,e[o]);return new n(t)};var c=n,h=o(function(e,t){function o(e){return e&&"object"==typeof e&&"default"in e?e["default"]:e}function n(e,t,o){for(var r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:o;var d=e.child(r),p=t.child(r);if(d==p){o+=d.nodeSize;continue}if(!d.sameMarkup(p))return o;if(d.isText&&d.text!=p.text){for(var a=0;d.text[a]==p.text[a];a++)o++;return o}if(d.content.size||p.content.size){var s=n(d.content,p.content,o+1);if(null!=s)return s}o+=d.nodeSize}}function r(e,t,o,n){for(var d=e.childCount,i=t.childCount;;){if(0==d||0==i)return d==i?null:{a:o,b:n};var p=e.child(--d),a=t.child(--i),s=p.nodeSize;if(p==a){o-=s,n-=s;continue}if(!p.sameMarkup(a))return{a:o,b:n};if(p.isText&&p.text!=a.text){for(var c=0,h=l(p.text.length,a.text.length);c<h&&p.text[p.text.length-c-1]==a.text[a.text.length-c-1];)c++,o--,n--;return{a:o,b:n}}if(p.content.size||a.content.size){var m=r(p.content,a.content,o-1,n-1);if(m)return m}o-=s,n-=s}}function d(e,t){return Z.index=e,Z.offset=t,Z}function h(e,t){if(e===t)return!0;if(!(e&&"object"==typeof e)||!(t&&"object"==typeof t))return!1;var o=Array.isArray(e);if(Array.isArray(t)!=o)return!1;if(o){if(e.length!=t.length)return!1;for(var n=0;n<e.length;n++)if(!h(e[n],t[n]))return!1}else{for(var r in e)if(!(r in t)||!h(e[r],t[r]))return!1;for(var d in t)if(!(d in e))return!1}return!0}function m(e){var t=Error.call(this,e);return t.__proto__=m.prototype,t}function f(e,t,o){var n=e.findIndex(t),r=n.index,d=n.offset,i=e.maybeChild(r),p=e.findIndex(o),a=p.index,s=p.offset;if(d==t||i.isText){if(s!=o&&!e.child(a).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(o))}if(r!=a)throw new RangeError("Removing non-flat range");return e.replaceChild(r,i.copy(f(i.content,t-d-1,o-d-1)))}function g(e,t,o,n){var r=e.findIndex(t),d=r.index,i=r.offset,p=e.maybeChild(d);if(i==t||p.isText)return n&&!n.canReplace(d,d,o)?null:e.cut(0,t).append(o).append(e.cut(t));var a=g(p.content,t-i-1,o);return a&&e.replaceChild(d,p.copy(a))}function u(e,t,o){if(o.openStart>e.depth)throw new m("Inserted content deeper than insertion position");if(e.depth-o.openStart!=t.depth-o.openEnd)throw new m("Inconsistent open depths");return y(e,t,o,0)}function y(e,t,o,n){var r=e.index(n),d=e.node(n);if(r==t.index(n)&&n<e.depth-o.openStart){var i=y(e,t,o,n+1);return d.copy(d.content.replaceChild(r,i))}if(!o.content.size)return w(d,k(e,t,n));if(!o.openStart&&!o.openEnd&&e.depth==n&&t.depth==n){var p=e.parent,a=p.content;return w(p,a.cut(0,e.parentOffset).append(o.content).append(a.cut(t.parentOffset)))}var s=M(o,e),l=s.start,c=s.end;return w(d,x(e,l,c,t,n))}function S(e,t){if(!t.type.compatibleContent(e.type))throw new m("Cannot join "+t.type.name+" onto "+e.type.name)}function C(e,t,o){var n=e.node(o);return S(n,t.node(o)),n}function v(e,t){var o=t.length-1;0<=o&&e.isText&&e.sameMarkup(t[o])?t[o]=e.withText(t[o].text+e.text):t.push(e)}function b(e,t,o,n){var r=(t||e).node(o),d=0,p=t?t.index(o):r.childCount;e&&(d=e.index(o),e.depth>o?d++:e.textOffset&&(v(e.nodeAfter,n),d++));for(var a=d;a<p;a++)v(r.child(a),n);t&&t.depth==o&&t.textOffset&&v(t.nodeBefore,n)}function w(e,t){if(!e.type.validContent(t))throw new m("Invalid content for node "+e.type.name);return e.copy(t)}function x(e,t,o,n,r){var d=e.depth>r&&C(e,t,r+1),i=n.depth>r&&C(o,n,r+1),p=[];return b(null,e,r,p),d&&i&&t.index(r)==o.index(r)?(S(d,i),v(w(d,x(e,t,o,n,r+1)),p)):(d&&v(w(d,k(e,t,r+1)),p),b(t,o,r,p),i&&v(w(i,k(o,n,r+1)),p)),b(n,null,r,p),new Q(p)}function k(e,t,o){var n=[];if(b(null,e,o,n),e.depth>o){var r=C(e,t,o+1);v(w(r,k(e,t,o+1)),n)}return b(t,null,o,n),new Q(n)}function M(e,t){for(var o=t.depth-e.openStart,n=t.node(o),r=n.copy(e.content),d=o-1;0<=d;d--)r=t.node(d).copy(Q.from(r));return{start:r.resolveNoCache(e.openStart+o),end:r.resolveNoCache(r.content.size-e.openEnd-o)}}function T(e,t){for(var o=e.length-1;0<=o;o--)t=e[o].type.name+"("+t+")";return t}function N(e){var t=[];do t.push(O(e));while(e.eat("|"));return 1==t.length?t[0]:{type:"choice",exprs:t}}function O(e){var t=[];do t.push(A(e));while(e.next&&")"!=e.next&&"|"!=e.next);return 1==t.length?t[0]:{type:"seq",exprs:t}}function A(e){for(var t=P(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("{"))t=R(e,t);else break;return t}function D(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");var t=+e.next;return e.pos++,t}function R(e,t){var o=D(e),n=o;return e.eat(",")&&("}"==e.next?n=-1:n=D(e)),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:o,max:n,expr:t}}function I(e,t){var o=e.nodeTypes,n=o[t];if(n)return[n];var r=[];for(var d in o){var i=o[d];-1<i.groups.indexOf(t)&&r.push(i)}return 0==r.length&&e.err("No node type or group '"+t+"' found"),r}function P(e){if(e.eat("(")){var t=N(e);return e.eat(")")||e.err("Missing closing paren"),t}if(!/\W/.test(e.next)){var o=I(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==o.length?o[0]:{type:"choice",exprs:o}}e.err("Unexpected token '"+e.next+"'")}function E(e){function t(){return d.push([])-1}function o(e,t,o){var n={term:o,to:t};return d[e].push(n),n}function n(e,t){e.forEach(function(e){return e.to=t})}function r(e,d){if("choice"==e.type)return e.exprs.reduce(function(e,t){return e.concat(r(t,d))},[]);if("seq"==e.type)for(var p=0,a;;p++){if(a=r(e.exprs[p],d),p==e.exprs.length-1)return a;n(a,d=t())}else{if("star"==e.type){var s=t();return o(d,s),n(r(e.expr,s),s),[o(s)]}if("plus"==e.type){var l=t();return n(r(e.expr,d),l),n(r(e.expr,l),l),[o(l)]}if("opt"==e.type)return[o(d)].concat(r(e.expr,d));if("range"==e.type){for(var c=d,h=0,m;h<e.min;h++)m=t(),n(r(e.expr,c),m),c=m;if(-1==e.max)n(r(e.expr,c),c);else for(var f=e.min,g;f<e.max;f++)g=t(),o(c,g),n(r(e.expr,c),g),c=g;return[o(c)]}if("name"==e.type)return[o(d,null,e.value)]}}var d=[[]];return n(r(e,0),t()),d}function $(e,t){return e-t}function z(e,t){function o(t){var r=e[t];if(1==r.length&&!r[0].term)return o(r[0].to);n.push(t);for(var d=0;d<r.length;d++){var p=r[d],a=p.term,s=p.to;a||-1!=n.indexOf(s)||o(s)}}var n=[];return o(t),n.sort($)}function F(e){function t(n){var r=[];n.forEach(function(t){e[t].forEach(function(t){var o=t.term,n=t.to;if(o){var d=r.indexOf(o),i=-1<d&&r[d+1];z(e,n).forEach(function(e){i||r.push(o,i=[]),-1==i.indexOf(e)&&i.push(e)})}})});for(var d=o[n.join(",")]=new fe(-1<n.indexOf(e.length-1)),p=0,a;p<r.length;p+=2)a=r[p+1].sort($),d.next.push(r[p],o[a.join(",")]||t(a));return d}var o=Object.create(null);return t(z(e,0))}function B(e,t){for(var o=0,n=[e];o<n.length;o++){for(var r=n[o],d=!r.validEnd,p=[],a=0;a<r.next.length;a+=2){var s=r.next[a],l=r.next[a+1];p.push(s.name),d&&!(s.isText||s.hasRequiredAttrs())&&(d=!1),-1==n.indexOf(l)&&n.push(l)}d&&t.err("Only non-generatable nodes ("+p.join(", ")+") in a required position")}}function _(e){var t=Object.create(null);for(var o in e){var n=e[o];if(!n.hasDefault)return null;t[o]=n.default}return t}function V(e,t){var o=Object.create(null);for(var n in e){var r=t&&t[n];if(void 0===r){var d=e[n];if(d.hasDefault)r=d.default;else throw new RangeError("No value supplied for attribute "+n)}o[n]=r}return o}function L(e){var t=Object.create(null);if(e)for(var o in e)t[o]=new ve(e[o]);return t}function J(e,t){for(var o=[],n=0;n<t.length;n++){var r=t[n],d=e.marks[r],p=d;if(d)o.push(d);else for(var a in e.marks){var s=e.marks[a];("_"==r||s.spec.group&&-1<s.spec.group.split(" ").indexOf(r))&&o.push(p=s)}if(!p)throw new SyntaxError("Unknown mark type: '"+t[n]+"'")}return o}function W(e){return(e?1:0)|("full"===e?2:0)}function j(e){for(var t=e.firstChild,o=null,n;t;t=t.nextSibling)n=1==t.nodeType?t.nodeName.toLowerCase():null,n&&Ne.hasOwnProperty(n)&&o?(o.appendChild(t),t=o):"li"==n?o=t:n&&(o=null)}function K(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function q(e){for(var t=/\s*([\w-]+)\s*:\s*([^;]+)/g,o=[],n;n=t.exec(e);)o.push(n[1],n[2].trim());return o}function H(e){var t={};for(var o in e)t[o]=e[o];return t}function U(e){var t={};for(var o in e){var n=e[o].spec.toDOM;n&&(t[o]=n)}return t}function G(e){return e.document||window.document}Object.defineProperty(t,"__esModule",{value:!0});var X=o(c),Q=function(e,t){var o=this;if(this.content=e,this.size=t||0,null==t)for(var n=0;n<e.length;n++)o.size+=e[n].nodeSize},Y={firstChild:{},lastChild:{},childCount:{}};Q.prototype.nodesBetween=function(e,t,o,n,r){var d=this;void 0===n&&(n=0);for(var p=0,a=0;a<t;p++){var c=d.content[p],h=a+c.nodeSize;if(h>e&&!1!==o(c,n+a,r,p)&&c.content.size){var m=a+1;c.nodesBetween(s(0,e-m),l(c.content.size,t-m),o,n+m)}a=h}},Q.prototype.descendants=function(e){this.nodesBetween(0,this.size,e)},Q.prototype.textBetween=function(e,t,o,n){var r="",d=!0;return this.nodesBetween(e,t,function(i,p){i.isText?(r+=i.text.slice(s(e,p)-p,t-p),d=!o):i.isLeaf&&n?(r+=n,d=!o):!d&&i.isBlock&&(r+=o,d=!0)},0),r},Q.prototype.append=function(e){if(!e.size)return this;if(!this.size)return e;var t=this.lastChild,o=e.firstChild,n=this.content.slice(),r=0;for(t.isText&&t.sameMarkup(o)&&(n[n.length-1]=t.withText(t.text+o.text),r=1);r<e.content.length;r++)n.push(e.content[r]);return new Q(n,this.size+e.size)},Q.prototype.cut=function(e,t){var o=this;if(null==t&&(t=this.size),0==e&&t==this.size)return this;var n=[],r=0;if(t>e)for(var d=0,p=0;p<t;d++){var a=o.content[d],c=p+a.nodeSize;c>e&&((p<e||c>t)&&(a.isText?a=a.cut(s(0,e-p),l(a.text.length,t-p)):a=a.cut(s(0,e-p-1),l(a.content.size,t-p-1))),n.push(a),r+=a.nodeSize),p=c}return new Q(n,r)},Q.prototype.cutByIndex=function(e,t){return e==t?Q.empty:0==e&&t==this.content.length?this:new Q(this.content.slice(e,t))},Q.prototype.replaceChild=function(e,t){var o=this.content[e];if(o==t)return this;var n=this.content.slice(),r=this.size+t.nodeSize-o.nodeSize;return n[e]=t,new Q(n,r)},Q.prototype.addToStart=function(e){return new Q([e].concat(this.content),this.size+e.nodeSize)},Q.prototype.addToEnd=function(e){return new Q(this.content.concat(e),this.size+e.nodeSize)},Q.prototype.eq=function(e){var t=this;if(this.content.length!=e.content.length)return!1;for(var o=0;o<this.content.length;o++)if(!t.content[o].eq(e.content[o]))return!1;return!0},Y.firstChild.get=function(){return this.content.length?this.content[0]:null},Y.lastChild.get=function(){return this.content.length?this.content[this.content.length-1]:null},Y.childCount.get=function(){return this.content.length},Q.prototype.child=function(e){var t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t},Q.prototype.maybeChild=function(e){return this.content[e]},Q.prototype.forEach=function(e){for(var t=this,o=0,n=0,r;o<this.content.length;o++)r=t.content[o],e(r,n,o),n+=r.nodeSize},Q.prototype.findDiffStart=function(e,t){return void 0===t&&(t=0),n(this,e,t)},Q.prototype.findDiffEnd=function(e,t,o){return void 0===t&&(t=this.size),void 0===o&&(o=e.size),r(this,e,t,o)},Q.prototype.findIndex=function(e,t){var o=this;if(void 0===t&&(t=-1),0==e)return d(0,e);if(e==this.size)return d(this.content.length,e);if(e>this.size||0>e)throw new RangeError("Position "+e+" outside of fragment ("+this+")");for(var n=0,r=0;;n++){var p=o.child(n),a=r+p.nodeSize;if(a>=e)return a==e||0<t?d(n+1,a):d(n,r);r=a}},Q.prototype.toString=function(){return"<"+this.toStringInner()+">"},Q.prototype.toStringInner=function(){return this.content.join(", ")},Q.prototype.toJSON=function(){return this.content.length?this.content.map(function(e){return e.toJSON()}):null},Q.fromJSON=function(e,t){if(!t)return Q.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new Q(t.map(e.nodeFromJSON))},Q.fromArray=function(e){if(!e.length)return Q.empty;for(var t=0,o=0,n,r;o<e.length;o++)r=e[o],t+=r.nodeSize,o&&r.isText&&e[o-1].sameMarkup(r)?(!n&&(n=e.slice(0,o)),n[n.length-1]=r.withText(n[n.length-1].text+r.text)):n&&n.push(r);return new Q(n||e,t)},Q.from=function(e){if(!e)return Q.empty;if(e instanceof Q)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new Q([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(Q.prototype,Y);var Z={index:0,offset:0};Q.empty=new Q([],0);var ee=function(e,t){this.type=e,this.attrs=t};ee.prototype.addToSet=function(e){for(var t=this,o=!1,n=0,r,d;n<e.length;n++){if(d=e[n],t.eq(d))return e;if(t.type.excludes(d.type))r||(r=e.slice(0,n));else{if(d.type.excludes(t.type))return e;!o&&d.type.rank>t.type.rank&&(!r&&(r=e.slice(0,n)),r.push(t),o=!0),r&&r.push(d)}}return r||(r=e.slice()),o||r.push(this),r},ee.prototype.removeFromSet=function(e){for(var t=this,o=0;o<e.length;o++)if(t.eq(e[o]))return e.slice(0,o).concat(e.slice(o+1));return e},ee.prototype.isInSet=function(e){for(var t=this,o=0;o<e.length;o++)if(t.eq(e[o]))return!0;return!1},ee.prototype.eq=function(e){return this==e||this.type==e.type&&h(this.attrs,e.attrs)},ee.prototype.toJSON=function(){var e=this,t={type:this.type.name};for(var o in e.attrs){t.attrs=e.attrs;break}return t},ee.fromJSON=function(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");var o=e.marks[t.type];if(!o)throw new RangeError("There is no mark type "+t.type+" in this schema");return o.create(t.attrs)},ee.sameSet=function(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(var o=0;o<e.length;o++)if(!e[o].eq(t[o]))return!1;return!0},ee.setFrom=function(e){if(!e||0==e.length)return ee.none;if(e instanceof ee)return[e];var t=e.slice();return t.sort(function(e,t){return e.type.rank-t.type.rank}),t},ee.none=[],m.prototype=Object.create(Error.prototype),m.prototype.constructor=m,m.prototype.name="ReplaceError";var te=function(e,t,o){this.content=e,this.openStart=t,this.openEnd=o},oe={size:{}};oe.size.get=function(){return this.content.size-this.openStart-this.openEnd},te.prototype.insertAt=function(e,t){var o=g(this.content,e+this.openStart,t,null);return o&&new te(o,this.openStart,this.openEnd)},te.prototype.removeBetween=function(e,t){return new te(f(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)},te.prototype.eq=function(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd},te.prototype.toString=function(){return this.content+"("+this.openStart+","+this.openEnd+")"},te.prototype.toJSON=function(){if(!this.content.size)return null;var e={content:this.content.toJSON()};return 0<this.openStart&&(e.openStart=this.openStart),0<this.openEnd&&(e.openEnd=this.openEnd),e},te.fromJSON=function(e,t){if(!t)return te.empty;var o=t.openStart||0,n=t.openEnd||0;if("number"!=typeof o||"number"!=typeof n)throw new RangeError("Invalid input for Slice.fromJSON");return new te(Q.fromJSON(e,t.content),t.openStart||0,t.openEnd||0)},te.maxOpen=function(e,t){void 0===t&&(t=!0);for(var o=0,r=0,d=e.firstChild;d&&!d.isLeaf&&(t||!d.type.spec.isolating);d=d.firstChild)o++;for(var i=e.lastChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.lastChild)r++;return new te(e,o,r)},Object.defineProperties(te.prototype,oe),te.empty=new te(Q.empty,0,0);var ne=function(e,t,o){this.pos=e,this.path=t,this.depth=t.length/3-1,this.parentOffset=o},re={parent:{},doc:{},textOffset:{},nodeAfter:{},nodeBefore:{}};ne.prototype.resolveDepth=function(e){return null==e?this.depth:0>e?this.depth+e:e},re.parent.get=function(){return this.node(this.depth)},re.doc.get=function(){return this.node(0)},ne.prototype.node=function(e){return this.path[3*this.resolveDepth(e)]},ne.prototype.index=function(e){return this.path[3*this.resolveDepth(e)+1]},ne.prototype.indexAfter=function(e){return e=this.resolveDepth(e),this.index(e)+(e!=this.depth||this.textOffset?1:0)},ne.prototype.start=function(e){return e=this.resolveDepth(e),0==e?0:this.path[3*e-1]+1},ne.prototype.end=function(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size},ne.prototype.before=function(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]},ne.prototype.after=function(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]+this.path[3*e].nodeSize},re.textOffset.get=function(){return this.pos-this.path[this.path.length-1]},re.nodeAfter.get=function(){var e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;var o=this.pos-this.path[this.path.length-1],n=e.child(t);return o?e.child(t).cut(o):n},re.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)},ne.prototype.marks=function e(){var t=this.parent,o=this.index();if(0==t.content.size)return ee.none;if(this.textOffset)return t.child(o).marks;var n=t.maybeChild(o-1),r=t.maybeChild(o);if(!n){var d=n;n=r,r=d}for(var e=n.marks,p=0;p<e.length;p++)!1!==e[p].type.spec.inclusive||r&&e[p].isInSet(r.marks)||(e=e[p--].removeFromSet(e));return e},ne.prototype.marksAcross=function(e){var t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;for(var o=t.marks,n=e.parent.maybeChild(e.index()),r=0;r<o.length;r++)!1!==o[r].type.spec.inclusive||n&&o[r].isInSet(n.marks)||(o=o[r--].removeFromSet(o));return o},ne.prototype.sharedDepth=function(e){for(var t=this,o=this.depth;0<o;o--)if(t.start(o)<=e&&t.end(o)>=e)return o;return 0},ne.prototype.blockRange=function(e,t){var o=this;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);0<=n;n--)if(e.pos<=o.end(n)&&(!t||t(o.node(n))))return new ae(o,e,n)},ne.prototype.sameParent=function(e){return this.pos-this.parentOffset==e.pos-e.parentOffset},ne.prototype.max=function(e){return e.pos>this.pos?e:this},ne.prototype.min=function(e){return e.pos<this.pos?e:this},ne.prototype.toString=function(){for(var e=this,t="",o=1;o<=this.depth;o++)t+=(t?"/":"")+e.node(o).type.name+"_"+e.index(o-1);return t+":"+this.parentOffset},ne.resolve=function(e,t){if(!(0<=t&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");for(var o=[],n=0,r=t,d=e;;){var i=d.content.findIndex(r),p=i.index,a=i.offset,s=r-a;if(o.push(d,p,n+a),!s)break;if(d=d.child(p),d.isText)break;r=s-1,n+=a+1}return new ne(t,o,r)},ne.resolveCached=function(e,t){for(var o=0,n;o<de.length;o++)if(n=de[o],n.pos==t&&n.doc==e)return n;var r=de[ie]=ne.resolve(e,t);return ie=(ie+1)%pe,r},Object.defineProperties(ne.prototype,re);var de=[],ie=0,pe=12,ae=function(e,t,o){this.$from=e,this.$to=t,this.depth=o},se={start:{},end:{},parent:{},startIndex:{},endIndex:{}};se.start.get=function(){return this.$from.before(this.depth+1)},se.end.get=function(){return this.$to.after(this.depth+1)},se.parent.get=function(){return this.$from.node(this.depth)},se.startIndex.get=function(){return this.$from.index(this.depth)},se.endIndex.get=function(){return this.$to.indexAfter(this.depth)},Object.defineProperties(ae.prototype,se);var le=Object.create(null),ce=function(e,t,o,n){this.type=e,this.attrs=t,this.content=o||Q.empty,this.marks=n||ee.none},he={nodeSize:{},childCount:{},textContent:{},firstChild:{},lastChild:{},isBlock:{},isTextblock:{},inlineContent:{},isInline:{},isText:{},isLeaf:{},isAtom:{}};he.nodeSize.get=function(){return this.isLeaf?1:2+this.content.size},he.childCount.get=function(){return this.content.childCount},ce.prototype.child=function(e){return this.content.child(e)},ce.prototype.maybeChild=function(e){return this.content.maybeChild(e)},ce.prototype.forEach=function(e){this.content.forEach(e)},ce.prototype.nodesBetween=function(e,t,o,n){void 0===n&&(n=0),this.content.nodesBetween(e,t,o,n,this)},ce.prototype.descendants=function(e){this.nodesBetween(0,this.content.size,e)},he.textContent.get=function(){return this.textBetween(0,this.content.size,"")},ce.prototype.textBetween=function(e,t,o,n){return this.content.textBetween(e,t,o,n)},he.firstChild.get=function(){return this.content.firstChild},he.lastChild.get=function(){return this.content.lastChild},ce.prototype.eq=function(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)},ce.prototype.sameMarkup=function(e){return this.hasMarkup(e.type,e.attrs,e.marks)},ce.prototype.hasMarkup=function(e,t,o){return this.type==e&&h(this.attrs,t||e.defaultAttrs||le)&&ee.sameSet(this.marks,o||ee.none)},ce.prototype.copy=function(e){return void 0===e&&(e=null),e==this.content?this:new this.constructor(this.type,this.attrs,e,this.marks)},ce.prototype.mark=function(e){return e==this.marks?this:new this.constructor(this.type,this.attrs,this.content,e)},ce.prototype.cut=function(e,t){return 0==e&&t==this.content.size?this:this.copy(this.content.cut(e,t))},ce.prototype.slice=function(e,t,o){if(void 0===t&&(t=this.content.size),void 0===o&&(o=!1),e==t)return te.empty;var n=this.resolve(e),r=this.resolve(t),d=o?0:n.sharedDepth(t),i=n.start(d),p=n.node(d),a=p.content.cut(n.pos-i,r.pos-i);return new te(a,n.depth-d,r.depth-d)},ce.prototype.replace=function(e,t,o){return u(this.resolve(e),this.resolve(t),o)},ce.prototype.nodeAt=function(e){for(var t=this;;){var o=t.content.findIndex(e),n=o.index,r=o.offset;if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}},ce.prototype.childAfter=function(e){var t=this.content.findIndex(e),o=t.index,n=t.offset;return{node:this.content.maybeChild(o),index:o,offset:n}},ce.prototype.childBefore=function(e){if(0==e)return{node:null,index:0,offset:0};var t=this.content.findIndex(e),o=t.index,n=t.offset;if(n<e)return{node:this.content.child(o),index:o,offset:n};var r=this.content.child(o-1);return{node:r,index:o-1,offset:n-r.nodeSize}},ce.prototype.resolve=function(e){return ne.resolveCached(this,e)},ce.prototype.resolveNoCache=function(e){return ne.resolve(this,e)},ce.prototype.rangeHasMark=function(e,t,o){var n=!1;return t>e&&this.nodesBetween(e,t,function(e){return o.isInSet(e.marks)&&(n=!0),!n}),n},he.isBlock.get=function(){return this.type.isBlock},he.isTextblock.get=function(){return this.type.isTextblock},he.inlineContent.get=function(){return this.type.inlineContent},he.isInline.get=function(){return this.type.isInline},he.isText.get=function(){return this.type.isText},he.isLeaf.get=function(){return this.type.isLeaf},he.isAtom.get=function(){return this.type.isAtom},ce.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()+")"),T(this.marks,e)},ce.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},ce.prototype.canReplace=function(e,t,o,n,r){var d=this;void 0===o&&(o=Q.empty),void 0===n&&(n=0),void 0===r&&(r=o.childCount);var p=this.contentMatchAt(e).matchFragment(o,n,r),a=p&&p.matchFragment(this.content,t);if(!a||!a.validEnd)return!1;for(var s=n;s<r;s++)if(!d.type.allowsMarks(o.child(s).marks))return!1;return!0},ce.prototype.canReplaceWith=function(e,t,o,n){if(n&&!this.type.allowsMarks(n))return!1;var r=this.contentMatchAt(e).matchType(o),d=r&&r.matchFragment(this.content,t);return!!d&&d.validEnd},ce.prototype.canAppend=function(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)},ce.prototype.defaultContentType=function(e){return this.contentMatchAt(e).defaultType},ce.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));this.content.forEach(function(e){return e.check()})},ce.prototype.toJSON=function(){var e=this,t={type:this.type.name};for(var o in e.attrs){t.attrs=e.attrs;break}return this.content.size&&(t.content=this.content.toJSON()),this.marks.length&&(t.marks=this.marks.map(function(e){return e.toJSON()})),t},ce.fromJSON=function(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");var o=null;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");o=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,o)}var n=Q.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,n,o)},Object.defineProperties(ce.prototype,he);var me=function(e){function t(t,o,n,r){if(e.call(this,t,o,null,r),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var o={textContent:{},nodeSize:{}};return t.prototype.toString=function(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):T(this.marks,JSON.stringify(this.text))},o.textContent.get=function(){return this.text},t.prototype.textBetween=function(e,t){return this.text.slice(e,t)},o.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,o),t}(ce),fe=function(e){this.validEnd=e,this.next=[],this.wrapCache=[]},ge={inlineContent:{},defaultType:{},edgeCount:{}};fe.parse=function(e,t){var o=new ue(e,t);if(null==o.next)return fe.empty;var n=N(o);o.next&&o.err("Unexpected trailing text");var r=F(E(n));return B(r,o),r},fe.prototype.matchType=function(e){for(var t=this,o=0;o<this.next.length;o+=2)if(t.next[o]==e)return t.next[o+1];return null},fe.prototype.matchFragment=function(e,t,o){void 0===t&&(t=0),void 0===o&&(o=e.childCount);for(var n=this,r=t;n&&r<o;r++)n=n.matchType(e.child(r).type);return n},ge.inlineContent.get=function(){var e=this.next[0];return!!e&&e.isInline},ge.defaultType.get=function(){for(var e=this,t=0,o;t<this.next.length;t+=2)if(o=e.next[t],!(o.isText||o.hasRequiredAttrs()))return o},fe.prototype.compatible=function(e){for(var t=this,o=0;o<this.next.length;o+=2)for(var n=0;n<e.next.length;n+=2)if(t.next[o]==e.next[n])return!0;return!1},fe.prototype.fillBefore=function(e,t,o){function n(d,p){var a=d.matchFragment(e,o);if(a&&(!t||a.validEnd))return Q.from(p.map(function(e){return e.createAndFill()}));for(var s=0;s<d.next.length;s+=2){var l=d.next[s],c=d.next[s+1];if(!(l.isText||l.hasRequiredAttrs())&&-1==r.indexOf(c)){r.push(c);var h=n(c,p.concat(l));if(h)return h}}}void 0===t&&(t=!1),void 0===o&&(o=0);var r=[this];return n(this,[])},fe.prototype.findWrapping=function(e){for(var t=this,o=0;o<this.wrapCache.length;o+=2)if(t.wrapCache[o]==e)return t.wrapCache[o+1];var n=this.computeWrapping(e);return this.wrapCache.push(e,n),n},fe.prototype.computeWrapping=function(e){for(var t=Object.create(null),o=[{match:this,type:null,via:null}];o.length;){var n=o.shift(),r=n.match;if(r.matchType(e)){for(var d=[],p=n;p.type;p=p.via)d.push(p.type);return d.reverse()}for(var a=0,s;a<r.next.length;a+=2)s=r.next[a],s.isLeaf||s.hasRequiredAttrs()||s.name in t||n.type&&!r.next[a+1].validEnd||(o.push({match:s.contentMatch,type:s,via:n}),t[s.name]=!0)}},ge.edgeCount.get=function(){return this.next.length>>1},fe.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]}},fe.prototype.toString=function(){function e(o){t.push(o);for(var n=1;n<o.next.length;n+=2)-1==t.indexOf(o.next[n])&&e(o.next[n])}var t=[];return e(this),t.map(function(e,o){for(var n=o+(e.validEnd?"*":" ")+" ",r=0;r<e.next.length;r+=2)n+=(r?", ":"")+e.next[r].name+"->"+t.indexOf(e.next[r+1]);return n}).join("\n")},Object.defineProperties(fe.prototype,ge),fe.empty=new fe(!0);var ue=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.unshift()},ye={next:{}};ye.next.get=function(){return this.tokens[this.pos]},ue.prototype.eat=function(e){return this.next==e&&(this.pos++||!0)},ue.prototype.err=function(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")},Object.defineProperties(ue.prototype,ye);var Se=function(e,t,o){this.name=e,this.schema=t,this.spec=o,this.groups=o.group?o.group.split(" "):[],this.attrs=L(o.attrs),this.defaultAttrs=_(this.attrs),this.contentMatch=null,this.markSet=null,this.inlineContent=null,this.isBlock=!(o.inline||"text"==e),this.isText="text"==e},Ce={isInline:{},isTextblock:{},isLeaf:{},isAtom:{}};Ce.isInline.get=function(){return!this.isBlock},Ce.isTextblock.get=function(){return this.isBlock&&this.inlineContent},Ce.isLeaf.get=function(){return this.contentMatch==fe.empty},Ce.isAtom.get=function(){return this.isLeaf||this.spec.atom},Se.prototype.hasRequiredAttrs=function(e){var t=this;for(var o in t.attrs)if(t.attrs[o].isRequired&&(!e||!(o in e)))return!0;return!1},Se.prototype.compatibleContent=function(e){return this==e||this.contentMatch.compatible(e.contentMatch)},Se.prototype.computeAttrs=function(e){return!e&&this.defaultAttrs?this.defaultAttrs:V(this.attrs,e)},Se.prototype.create=function(e,t,o){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new ce(this,this.computeAttrs(e),Q.from(t),ee.setFrom(o))},Se.prototype.createChecked=function(e,t,o){if(t=Q.from(t),!this.validContent(t))throw new RangeError("Invalid content for node "+this.name);return new ce(this,this.computeAttrs(e),t,ee.setFrom(o))},Se.prototype.createAndFill=function(e,t,o){if(e=this.computeAttrs(e),t=Q.from(t),t.size){var n=this.contentMatch.fillBefore(t);if(!n)return null;t=n.append(t)}var r=this.contentMatch.matchFragment(t).fillBefore(Q.empty,!0);return r?new ce(this,e,t.append(r),ee.setFrom(o)):null},Se.prototype.validContent=function(e){var t=this,o=this.contentMatch.matchFragment(e);if(!o||!o.validEnd)return!1;for(var n=0;n<e.childCount;n++)if(!t.allowsMarks(e.child(n).marks))return!1;return!0},Se.prototype.allowsMarkType=function(e){return null==this.markSet||-1<this.markSet.indexOf(e)},Se.prototype.allowsMarks=function(e){var t=this;if(null==this.markSet)return!0;for(var o=0;o<e.length;o++)if(!t.allowsMarkType(e[o].type))return!1;return!0},Se.prototype.allowedMarks=function(e){var t=this;if(null==this.markSet)return e;for(var o=0,n;o<e.length;o++)t.allowsMarkType(e[o].type)?n&&n.push(e[o]):n||(n=e.slice(0,o));return n?n.length?n:ee.empty:e},Se.compile=function(e,t){var o=Object.create(null);e.forEach(function(e,n){return o[e]=new Se(e,t,n)});var n=t.spec.topNode||"doc";if(!o[n])throw new RangeError("Schema is missing its top node type ('"+n+"')");if(!o.text)throw new RangeError("Every schema needs a 'text' type");for(var r in o.text.attrs)throw new RangeError("The text node type should not have attributes");return o},Object.defineProperties(Se.prototype,Ce);var ve=function(e){this.hasDefault=Object.prototype.hasOwnProperty.call(e,"default"),this.default=e.default},be={isRequired:{}};be.isRequired.get=function(){return!this.hasDefault},Object.defineProperties(ve.prototype,be);var we=function(e,t,o,n){this.name=e,this.schema=o,this.spec=n,this.attrs=L(n.attrs),this.rank=t,this.excluded=null;var r=_(this.attrs);this.instance=r&&new ee(this,r)};we.prototype.create=function(e){return!e&&this.instance?this.instance:new ee(this,V(this.attrs,e))},we.compile=function(e,t){var o=Object.create(null),n=0;return e.forEach(function(e,r){return o[e]=new we(e,n++,t,r)}),o},we.prototype.removeFromSet=function(e){for(var t=this,o=0;o<e.length;o++)if(e[o].type==t)return e.slice(0,o).concat(e.slice(o+1));return e},we.prototype.isInSet=function(e){for(var t=this,o=0;o<e.length;o++)if(e[o].type==t)return e[o]},we.prototype.excludes=function(e){return-1<this.excluded.indexOf(e)};var xe=function(e){var t=this;for(var o in this.spec={},e)t.spec[o]=e[o];this.spec.nodes=X.from(e.nodes),this.spec.marks=X.from(e.marks),this.nodes=Se.compile(this.spec.nodes,this),this.marks=we.compile(this.spec.marks,this);var n=Object.create(null);for(var r in t.nodes){if(r in t.marks)throw new RangeError(r+" can not be both a node and a mark");var d=t.nodes[r],i=d.spec.content||"",p=d.spec.marks;d.contentMatch=n[i]||(n[i]=fe.parse(i,t.nodes)),d.inlineContent=d.contentMatch.inlineContent,d.markSet="_"==p?null:p?J(t,p.split(" ")):""!=p&&d.inlineContent?null:[]}for(var a in t.marks){var s=t.marks[a],l=s.spec.excludes;s.excluded=null==l?[s]:""==l?[]:J(t,l.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)};xe.prototype.node=function(e,t,o,n){if("string"==typeof e)e=this.nodeType(e);else if(!(e instanceof Se))throw new RangeError("Invalid node type: "+e);else if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")");return e.createChecked(t,o,n)},xe.prototype.text=function(e,t){var o=this.nodes.text;return new me(o,o.defaultAttrs,e,ee.setFrom(t))},xe.prototype.mark=function(e,t){return"string"==typeof e&&(e=this.marks[e]),e.create(t)},xe.prototype.nodeFromJSON=function(e){return ce.fromJSON(this,e)},xe.prototype.markFromJSON=function(e){return ee.fromJSON(this,e)},xe.prototype.nodeType=function(e){var t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t};var ke=function(e,t){var o=this;this.schema=e,this.rules=t,this.tags=[],this.styles=[],t.forEach(function(e){e.tag?o.tags.push(e):e.style&&o.styles.push(e)})};ke.prototype.parse=function(e,t){void 0===t&&(t={});var o=new Re(this,t,!1);return o.addAll(e,null,t.from,t.to),o.finish()},ke.prototype.parseSlice=function(e,t){void 0===t&&(t={});var o=new Re(this,t,!0);return o.addAll(e,null,t.from,t.to),te.maxOpen(o.finish())},ke.prototype.matchTag=function(e,t){for(var o=this,n=0,r;n<this.tags.length;n++)if(r=o.tags[n],K(e,r.tag)&&(void 0===r.namespace||e.namespaceURI==r.namespace)&&(!r.context||t.matchesContext(r.context))){if(r.getAttrs){var d=r.getAttrs(e);if(!1===d)continue;r.attrs=d}return r}},ke.prototype.matchStyle=function(e,t,o){for(var n=this,r=0,d;r<this.styles.length;r++)if(d=n.styles[r],!(0!=d.style.indexOf(e)||d.context&&!o.matchesContext(d.context)||d.style.length>e.length&&(61!=d.style.charCodeAt(e.length)||d.style.slice(e.length+1)!=t))){if(d.getAttrs){var p=d.getAttrs(t);if(!1===p)continue;d.attrs=p}return d}},ke.schemaRules=function(e){function t(e){for(var t=null==e.priority?50:e.priority,n=0;n<o.length;n++){var r=o[n],d=null==r.priority?50:r.priority;if(d<t)break}o.splice(n,0,e)}var o=[],n=function(o){var n=e.marks[o].spec.parseDOM;n&&n.forEach(function(e){t(e=H(e)),e.mark=o})};for(var r in e.marks)n(r);var d=function(){var o=e.nodes[i].spec.parseDOM;o&&o.forEach(function(e){t(e=H(e)),e.node=i})};for(var i in e.nodes)d();return o},ke.fromSchema=function(e){return e.cached.domParser||(e.cached.domParser=new ke(e,ke.schemaRules(e)))};var Me={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},Te={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Ne={ol:!0,ul:!0},Oe=1,Ae=4,De=function(e,t,o,n,r,d){this.type=e,this.attrs=t,this.solid=n,this.match=r||(d&Ae?null:e.contentMatch),this.options=d,this.content=[],this.marks=o,this.activeMarks=ee.none};De.prototype.findWrapping=function(e){if(!this.match){if(!this.type)return[];var t=this.type.contentMatch.fillBefore(Q.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{var o=this.type.contentMatch,n;return(n=o.findWrapping(e.type))?(this.match=o,n):null}}return this.match.findWrapping(e.type)},De.prototype.finish=function(e){if(!(this.options&Oe)){var t=this.content[this.content.length-1],o;t&&t.isText&&(o=/\s+$/.exec(t.text))&&(t.text.length==o[0].length?this.content.pop():this.content[this.content.length-1]=t.withText(t.text.slice(0,t.text.length-o[0].length)))}var n=Q.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(Q.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n};var Re=function(e,t,o){this.parser=e,this.options=t,this.isOpen=o,this.pendingMarks=[];var n=t.topNode,r=W(t.preserveWhitespace)|(o?Ae:0),d;d=n?new De(n.type,n.attrs,ee.none,!0,t.topMatch||n.type.contentMatch,r):o?new De(null,null,ee.none,!0,null,r):new De(e.schema.topNodeType,null,ee.none,!0,null,r),this.nodes=[d],this.open=0,this.find=t.findPositions,this.needsBlock=!1},Ie={top:{},currentPos:{}};Ie.top.get=function(){return this.nodes[this.open]},Re.prototype.addDOM=function(e){var t=this;if(3==e.nodeType)this.addTextNode(e);else if(1==e.nodeType){var o=e.getAttribute("style"),n=o?this.readStyles(q(o)):null;if(null!=n)for(var r=0;r<n.length;r++)t.addPendingMark(n[r]);if(this.addElement(e),null!=n)for(var d=0;d<n.length;d++)t.removePendingMark(n[d])}},Re.prototype.addTextNode=function(e){var t=e.nodeValue,o=this.top;if((o.type?o.type.inlineContent:o.content.length&&o.content[0].isInline)||/\S/.test(t)){if(!!(o.options&Oe))o.options&2||(t=t.replace(/\r?\n|\r/g," "));else if(t=t.replace(/\s+/g," "),/^\s/.test(t)&&this.open==this.nodes.length-1){var n=o.content[o.content.length-1],r=e.previousSibling;(!n||r&&"BR"==r.nodeName||n.isText&&/\s$/.test(n.text))&&(t=t.slice(1))}t&&this.insertNode(this.parser.schema.text(t)),this.findInText(e)}else this.findInside(e)},Re.prototype.addElement=function(e){var t=e.nodeName.toLowerCase();Ne.hasOwnProperty(t)&&j(e);var o=this.options.ruleFromNode&&this.options.ruleFromNode(e)||this.parser.matchTag(e,this);if(o?o.ignore:Te.hasOwnProperty(t))this.findInside(e);else if(!o||o.skip){o&&o.skip.nodeType&&(e=o.skip);var n=this.top,r=this.needsBlock,d;Me.hasOwnProperty(t)&&(d=!0,!n.type&&(this.needsBlock=!0)),this.addAll(e),d&&this.sync(n),this.needsBlock=r}else this.addElementByRule(e,o)},Re.prototype.readStyles=function(e){for(var t=this,o=ee.none,n=0,r;n<e.length;n+=2)if(r=t.parser.matchStyle(e[n],e[n+1],t),!!r){if(r.ignore)return null;o=t.parser.schema.marks[r.mark].create(r.attrs).addToSet(o)}return o},Re.prototype.addElementByRule=function(e,t){var o=this,n,r,d,i;t.node?(r=this.parser.schema.nodes[t.node],r.isLeaf?this.insertNode(r.create(t.attrs)):n=this.enter(r,t.attrs,t.preserveWhitespace)):(d=this.parser.schema.marks[t.mark],i=d.create(t.attrs),this.addPendingMark(i));var p=this.top;if(r&&r.isLeaf)this.findInside(e);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(function(e){return o.insertNode(e)});else{var a=t.contentElement;"string"==typeof a?a=e.querySelector(a):"function"==typeof a&&(a=a(e)),a||(a=e),this.findAround(e,a,!0),this.addAll(a,n)}return n&&(this.sync(p),this.open--),i&&this.removePendingMark(i),!0},Re.prototype.addAll=function(e,t,o,n){for(var r=this,d=o||0,i=o?e.childNodes[o]:e.firstChild,p=null==n?null:e.childNodes[n];i!=p;i=i.nextSibling,++d)r.findAtPoint(e,d),r.addDOM(i),t&&Me.hasOwnProperty(i.nodeName.toLowerCase())&&r.sync(t);this.findAtPoint(e,d)},Re.prototype.findPlace=function(e){for(var t=this,o=this.open,n,r;0<=o;o--){var d=t.nodes[o],p=d.findWrapping(e);if((!n||n.length>p.length)&&(n=p,r=d,!p.length))break;if(d.solid)break}if(!n)return!1;this.sync(r);for(var a=0;a<n.length;a++)t.enterInner(n[a],null,!1);return!0},Re.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 o=this.top;this.applyPendingMarks(o),o.match&&(o.match=o.match.matchType(e.type));for(var n=o.activeMarks,r=0;r<e.marks.length;r++)(!o.type||o.type.allowsMarkType(e.marks[r].type))&&(n=e.marks[r].addToSet(n));o.content.push(e.mark(n))}},Re.prototype.applyPendingMarks=function(e){for(var t=this,o=0,n;o<this.pendingMarks.length;o++)n=t.pendingMarks[o],e.type&&!e.type.allowsMarkType(n.type)||n.isInSet(e.activeMarks)||(e.activeMarks=n.addToSet(e.activeMarks),t.pendingMarks.splice(o--,1))},Re.prototype.enter=function(e,t,o){var n=this.findPlace(e.create(t));return n&&(this.applyPendingMarks(this.top),this.enterInner(e,t,!0,o)),n},Re.prototype.enterInner=function(e,t,o,n){this.closeExtra();var r=this.top;r.match=r.match&&r.match.matchType(e,t);var d=null==n?r.options&~Ae:W(n);r.options&Ae&&0==r.content.length&&(d|=Ae),this.nodes.push(new De(e,t,r.activeMarks,o,null,d)),this.open++},Re.prototype.closeExtra=function(e){var t=this,o=this.nodes.length-1;if(o>this.open){for(;o>this.open;o--)t.nodes[o-1].content.push(t.nodes[o].finish(e));this.nodes.length=this.open+1}},Re.prototype.finish=function(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)},Re.prototype.sync=function(e){for(var t=this,o=this.open;0<=o;o--)if(t.nodes[o]==e)return void(t.open=o)},Re.prototype.addPendingMark=function(e){this.pendingMarks.push(e)},Re.prototype.removePendingMark=function(e){var t=this.pendingMarks.lastIndexOf(e);if(-1<t)this.pendingMarks.splice(t,1);else{var o=this.top;o.activeMarks=e.removeFromSet(o.activeMarks)}},Ie.currentPos.get=function(){var e=this;this.closeExtra();for(var t=0,o=this.open,n;0<=o;o--){n=e.nodes[o].content;for(var r=n.length-1;0<=r;r--)t+=n[r].nodeSize;o&&t++}return t},Re.prototype.findAtPoint=function(e,t){var o=this;if(this.find)for(var n=0;n<this.find.length;n++)o.find[n].node==e&&o.find[n].offset==t&&(o.find[n].pos=o.currentPos)},Re.prototype.findInside=function(e){var t=this;if(this.find)for(var o=0;o<this.find.length;o++)null==t.find[o].pos&&1==e.nodeType&&e.contains(t.find[o].node)&&(t.find[o].pos=t.currentPos)},Re.prototype.findAround=function(e,t,o){var n=this;if(e!=t&&this.find)for(var r=0;r<this.find.length;r++)if(null==n.find[r].pos&&1==e.nodeType&&e.contains(n.find[r].node)){var d=t.compareDocumentPosition(n.find[r].node);d&(o?2:4)&&(n.find[r].pos=n.currentPos)}},Re.prototype.findInText=function(e){var t=this;if(this.find)for(var o=0;o<this.find.length;o++)t.find[o].node==e&&(t.find[o].pos=t.currentPos-(e.nodeValue.length-t.find[o].offset))},Re.prototype.matchesContext=function(e){var t=this;if(-1<e.indexOf("|"))return e.split(/\s*\|\s*/).some(this.matchesContext,this);var o=e.split("/"),n=this.options.context,r=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),d=-(n?n.depth+1:0)+(r?0:1),p=function(e,a){for(;0<=e;e--){var s=o[e];if(""==s){if(e==o.length-1||0==e)continue;for(;a>=d;a--)if(p(e-1,a))return!0;return!1}var l=0<a||0==a&&r?t.nodes[a].type:n&&a>=d?n.node(a-d).type:null;if(!l||l.name!=s&&-1==l.groups.indexOf(s))return!1;a--}return!0};return p(o.length-1,this.open)},Re.prototype.textblockFromContext=function(){var e=this,t=this.options.context;if(t)for(var o=t.depth,n;0<=o;o--)if(n=t.node(o).contentMatchAt(t.indexAfter(o)).defaultType,n&&n.isTextblock&&n.defaultAttrs)return n;for(var r in e.parser.schema.nodes){var i=e.parser.schema.nodes[r];if(i.isTextblock&&i.defaultAttrs)return i}},Object.defineProperties(Re.prototype,Ie);var Pe=function(e,t){this.nodes=e||{},this.marks=t||{}};Pe.prototype.serializeFragment=function(e,t,o){var n=this;void 0===t&&(t={}),o||(o=G(t).createDocumentFragment());var r=o,d=null;return e.forEach(function(e){if(d||e.marks.length){d||(d=[]);for(var o=0,i=0,p;o<d.length&&i<e.marks.length;){if(p=e.marks[i],!n.marks[p.type.name]){i++;continue}if(!p.eq(d[o])||!1===p.type.spec.spanning)break;o+=2,i++}for(;o<d.length;)r=d.pop(),d.pop();for(;i<e.marks.length;){var a=e.marks[i++],s=n.serializeMark(a,e.isInline,t);s&&(d.push(a,r),r.appendChild(s.dom),r=s.contentDOM||s.dom)}}r.appendChild(n.serializeNode(e,t))}),o},Pe.prototype.serializeNode=function(e,t){void 0===t&&(t={});var o=Pe.renderSpec(G(t),this.nodes[e.type.name](e)),n=o.dom,r=o.contentDOM;if(r){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");t.onContent?t.onContent(e,r,t):this.serializeFragment(e.content,t,r)}return n},Pe.prototype.serializeNodeAndMarks=function(e,t){var o=this;void 0===t&&(t={});for(var n=this.serializeNode(e,t),r=e.marks.length-1,d;0<=r;r--)d=o.serializeMark(e.marks[r],e.isInline,t),d&&((d.contentDOM||d.dom).appendChild(n),n=d.dom);return n},Pe.prototype.serializeMark=function(e,t,o){void 0===o&&(o={});var n=this.marks[e.type.name];return n&&Pe.renderSpec(G(o),n(e,t))},Pe.renderSpec=function(e,t){if("string"==typeof t)return{dom:e.createTextNode(t)};if(null!=t.nodeType)return{dom:t};var o=e.createElement(t[0]),n=null,r=t[1],d=1;if(r&&"object"==typeof r&&null==r.nodeType&&!Array.isArray(r))for(var p in d=2,r)null!=r[p]&&o.setAttribute(p,r[p]);for(var a=d,s;a<t.length;a++){if(s=t[a],0===s){if(a<t.length-1||a>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:o,contentDOM:o}}var l=Pe.renderSpec(e,s),c=l.dom,h=l.contentDOM;if(o.appendChild(c),h){if(n)throw new RangeError("Multiple content holes");n=h}}return{dom:o,contentDOM:n}},Pe.fromSchema=function(e){return e.cached.domSerializer||(e.cached.domSerializer=new Pe(this.nodesFromSchema(e),this.marksFromSchema(e)))},Pe.nodesFromSchema=function(e){var t=U(e.nodes);return t.text||(t.text=function(e){return e.text}),t},Pe.marksFromSchema=function(e){return U(e.marks)},t.Node=ce,t.ResolvedPos=ne,t.NodeRange=ae,t.Fragment=Q,t.Slice=te,t.ReplaceError=m,t.Mark=ee,t.Schema=xe,t.NodeType=Se,t.MarkType=we,t.ContentMatch=fe,t.DOMParser=ke,t.DOMSerializer=Pe});t(h);var m=h.Node,f=h.ResolvedPos,g=h.NodeRange,u=h.Fragment,y=h.Slice,S=h.ReplaceError,C=h.Mark,v=h.Schema,b=h.NodeType,w=h.MarkType,x=h.ContentMatch,k=h.DOMParser,M=h.DOMSerializer,T=o(function(e,t){var B=Math.pow;function o(e,t){return e+65536*t}function n(e){return 65535&e}function r(e){return(e-(65535&e))/65536}function d(e){var t=Error.call(this,e);return t.__proto__=d.prototype,t}function i(){throw new Error("Override me")}function p(e,t,o){for(var n=e.resolve(t),r=o-t,d=n.depth;0<r&&0<d&&n.indexAfter(d)==n.node(d).childCount;)d--,r--;if(0<r)for(var i=n.node(d).maybeChild(n.indexAfter(d));0<r;){if(!i||i.isLeaf)return!0;i=i.firstChild,r--}return!1}function a(e,t,o){return(0==t||e.canReplace(t,e.childCount))&&(o==e.childCount||e.canReplace(0,o))}function c(e){return{type:e,attrs:null}}function m(e,t){var o=e.parent,n=e.startIndex,r=e.endIndex,d=o.contentMatchAt(n).findWrapping(t);if(!d)return null;var i=d.length?d[0]:t;return o.canReplaceWith(n,r,i)?d:null}function f(e,t){var o=e.parent,n=e.startIndex,r=e.endIndex,d=o.child(n),p=t.contentMatch.findWrapping(d.type);if(!p)return null;for(var a=p.length?p[p.length-1]:t,s=a.contentMatch,l=n;s&&l<r;l++)s=s.matchType(o.child(l).type);return s&&s.validEnd?p:null}function g(e,t,o){var n=e.resolve(t),r=n.index();return n.parent.canReplaceWith(r,r+1,o)}function u(e,t,o,n){void 0===o&&(o=1);var r=e.resolve(t),p=r.depth-o,a=n&&n[n.length-1]||r.parent;if(0>p||r.parent.type.spec.isolating||!r.parent.canReplace(r.index(),r.parent.childCount)||!a.type.validContent(r.parent.content.cutByIndex(r.index(),r.parent.childCount)))return!1;for(var s=r.depth-1,l=o-2;s>p;s--,l--){var c=r.node(s),h=r.index(s);if(c.type.spec.isolating)return!1;var m=c.content.cutByIndex(h,c.childCount),f=n&&n[l]||c;if(f!=c&&(m=m.replaceChild(0,f.type.create(f.attrs))),!c.canReplace(h+1,c.childCount)||!f.type.validContent(m))return!1}var g=r.indexAfter(p),u=n&&n[0];return r.node(p).canReplaceWith(g,g,u?u.type:r.node(p+1).type)}function y(e,t){return e&&t&&!e.isLeaf&&e.canAppend(t)}function S(e,t,o){var n=e.resolve(t);if(n.parent.canReplaceWith(n.index(),n.index(),o))return t;if(0==n.parentOffset)for(var r=n.depth-1,i;0<=r;r--){if(i=n.index(r),n.node(r).canReplaceWith(i,i,o))return n.before(r+1);if(0<i)return null}if(n.parentOffset==n.parent.content.size)for(var p=n.depth-1,a;0<=p;p--){if(a=n.indexAfter(p),n.node(p).canReplaceWith(a,a,o))return n.after(p+1);if(a<n.node(p).childCount)return null}}function C(e,t,o){var n=e.resolve(t);if(!o.content.size)return t;for(var r=o.content,p=0;p<o.openStart;p++)r=r.firstChild.content;for(var a=1;a<=(0==o.openStart&&o.size?2:1);a++)for(var s=n.depth;0<=s;s--){var l=s==n.depth?0:n.pos<=(n.start(s+1)+n.end(s+1))/2?-1:1,c=n.index(s)+(0<l?1:0);if(1==a?n.node(s).canReplace(c,c,r):n.node(s).contentMatchAt(c).findWrapping(r.firstChild.type))return 0==l?n.pos:0>l?n.before(s+1):n.after(s+1)}return null}function v(e,t,o){for(var n=[],r=0,d;r<e.childCount;r++)d=e.child(r),d.content.size&&(d=d.copy(v(d.content,t,d))),d.isInline&&(d=t(d,o,r)),n.push(d);return h.Fragment.fromArray(n)}function b(e,t,o,n){if(void 0===o&&(o=t),void 0===n&&(n=h.Slice.empty),t==o&&!n.size)return null;var r=e.resolve(t),i=e.resolve(o);if(A(r,i,n))return new U(t,o,n);var p=I(r,n),a=x(r,p),s=O(r,i,a);if(!s)return null;if(a.size!=s.size&&D(r,i,a)){for(var l=i.depth,c=i.after(l);1<l&&c==i.end(--l);)++c;var m=O(r,e.resolve(c),a);if(m)return new G(t,c,o,i.end(),m,a.size)}return s.size||t!=o?new U(t,o,s):null}function w(e,t,o,n){var r=h.Fragment.empty,d=0,i=o[t];if(e.depth>t){var p=w(e,t+1,o,n||i);d=p.openEnd+1,r=h.Fragment.from(e.node(t+1).copy(p.content))}return i&&(r=r.append(i.content),d=i.openEnd),n&&(r=r.append(e.node(t).contentMatchAt(e.indexAfter(t)).fillBefore(h.Fragment.empty,!0)),d=0),{content:r,openEnd:d}}function x(e,t){var o=w(e,0,t,!1),n=o.content,r=o.openEnd;return new h.Slice(n,e.depth,r||0)}function k(e,t,o,n,r,d,p){var a=e.childCount,s=a-(0<p?1:0),l=0>d?t:o.node(r),c;c=0>d?l.contentMatchAt(s):1==a&&0<p?l.contentMatchAt(d?o.index(r):o.indexAfter(r)):l.contentMatchAt(o.indexAfter(r)).matchFragment(e,0<a&&d?1:0,s);var h=n.node(r);if(0<p&&r<n.depth){var m=h.content.cutByIndex(n.indexAfter(r)).addToStart(e.lastChild),f=c.fillBefore(m,!0);if(f&&f.size&&0<d&&1==a&&(f=null),f){var g=k(e.lastChild.content,e.lastChild,o,n,r+1,1==a?d-1:-1,p-1);if(g){var u=e.lastChild.copy(g);return f.size?e.cutByIndex(0,a-1).append(f).addToEnd(u):e.replaceChild(a-1,u)}}}0<p&&(c=c.matchType((1==a&&0<d?o.node(r+1):e.lastChild).type));var y=n.index(r);if(y==h.childCount&&!h.type.compatibleContent(t.type))return null;for(var S=c.fillBefore(h.content,!0,y),C=y;S&&C<h.content.childCount;C++)l.type.allowsMarks(h.content.child(C).marks)||(S=null);if(!S)return null;if(0<p){var v=M(e.lastChild,p-1,o,r+1,1==a?d-1:-1);e=e.replaceChild(a-1,v)}return e=e.append(S),n.depth>r&&(e=e.addToEnd(T(n,r+1))),e}function M(e,t,o,n,r){var d=e.content,i=d.childCount,p;if(p=0<=r?o.node(n).contentMatchAt(o.indexAfter(n)).matchFragment(d,0<r?1:0,i):e.contentMatchAt(i),0<t){var a=M(d.lastChild,t-1,o,n+1,1==i?r-1:-1);d=d.replaceChild(i-1,a)}return e.copy(d.append(p.fillBefore(h.Fragment.empty,!0)))}function T(e,t){var o=e.node(t),n=o.contentMatchAt(0).fillBefore(o.content,!0,e.index(t));return e.depth>t&&(n=n.addToEnd(T(e,t+1))),o.copy(n)}function N(e,t,o){for(;0<t&&0<o&&1==e.childCount;)e=e.firstChild.content,t--,o--;return new h.Slice(e,t,o)}function O(e,t,o){var n=k(o.content,e.node(0),e,t,0,o.openStart,o.openEnd);return n?N(n,o.openStart,t.depth):null}function A(e,t,o){return!o.openStart&&!o.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),o.content)}function D(e,t,o){if(!t.parent.isTextblock)return!1;var n=o.openEnd?R(o.content,o.openEnd):e.node(e.depth-(o.openStart-o.openEnd));if(!n.isTextblock)return!1;for(var r=t.index();r<t.parent.childCount;r++)if(!n.type.allowsMarks(t.parent.child(r).marks))return!1;var d;return o.openEnd?d=n.contentMatchAt(n.childCount):(d=n.contentMatchAt(n.childCount),o.size&&(d=d.matchFragment(o.content,o.openStart?1:0))),d=d.matchFragment(t.parent.content,t.index()),d&&d.validEnd}function R(e,t){for(var o=1;o<t;o++)e=e.lastChild.content;return e.lastChild}function I(e,t){for(var o=new Y(e),n=1,r;t.size&&3>=n;n++)r=o.placeSlice(t.content,t.openStart,t.openEnd,n),3==n&&r!=t&&r.size&&(n=0),t=r;for(;o.open.length;)o.closeNode();return o.placed}function P(e,t,o){var n=e.content;if(1<t){var r=P(e.firstChild,t-1,1==e.childCount?o-1:0);n=e.content.replaceChild(0,r)}var d=e.type.contentMatch.fillBefore(n,0==o);return e.copy(d.append(n))}function E(e,t){var o=e.content;if(1<t){var n=E(e.lastChild,t-1);o=e.content.replaceChild(e.childCount-1,n)}var r=e.contentMatchAt(e.childCount).fillBefore(h.Fragment.empty,!0);return e.copy(o.append(r))}function $(e,t){return t?e.replaceChild(e.childCount-1,E(e.lastChild,t)):e}function z(e,t,o,n,r){if(t<o){var d=e.firstChild;e=e.replaceChild(0,d.copy(z(d.content,t+1,o,n,d)))}return t>n&&(e=r.contentMatchAt(0).fillBefore(e,!0).append(e)),e}function F(e,t){for(var o=[],n=l(e.depth,t.depth),r=n,i;0<=r&&(i=e.start(r),!(i<e.pos-(e.depth-r)||t.end(r)>t.pos+(t.depth-r)||e.node(r).type.spec.isolating||t.node(r).type.spec.isolating));r--)i==t.start(r)&&o.push(r);return o}Object.defineProperty(t,"__esModule",{value:!0});var _=B(2,16),V=function(e,t,o){void 0===t&&(t=!1),void 0===o&&(o=null),this.pos=e,this.deleted=t,this.recover=o},L=function(e,t){void 0===t&&(t=!1),this.ranges=e,this.inverted=t};L.prototype.recover=function(e){var t=this,o=0,d=n(e);if(!this.inverted)for(var p=0;p<d;p++)o+=t.ranges[3*p+2]-t.ranges[3*p+1];return this.ranges[3*d]+o+r(e)},L.prototype.mapResult=function(e,t){return void 0===t&&(t=1),this._map(e,t,!1)},L.prototype.map=function(e,t){return void 0===t&&(t=1),this._map(e,t,!0)},L.prototype._map=function(e,t,n){for(var r=this,d=0,p=this.inverted?2:1,a=this.inverted?1:2,s=0,l;s<this.ranges.length&&(l=r.ranges[s]-(r.inverted?d:0),!(l>e));s+=3){var c=r.ranges[s+p],h=r.ranges[s+a],m=l+c;if(e<=m){var f=c?e==l?-1:e==m?1:t:t,g=l+d+(0>f?0:h);if(n)return g;var u=o(s/3,e-l);return new V(g,0>t?e!=l:e!=m,u)}d+=h-c}return n?e+d:new V(e+d)},L.prototype.touches=function(e,t){for(var o=this,r=0,d=n(t),p=this.inverted?2:1,a=this.inverted?1:2,s=0,l;s<this.ranges.length&&(l=o.ranges[s]-(o.inverted?r:0),!(l>e));s+=3){var c=o.ranges[s+p],h=l+c;if(e<=h&&s==3*d)return!0;r+=o.ranges[s+a]-c}return!1},L.prototype.forEach=function(e){for(var t=this,o=this.inverted?2:1,n=this.inverted?1:2,r=0,d=0;r<this.ranges.length;r+=3){var p=t.ranges[r],a=p-(t.inverted?d:0),s=p+(t.inverted?0:d),l=t.ranges[r+o],c=t.ranges[r+n];e(a,a+l,s,s+c),d+=c-l}},L.prototype.invert=function(){return new L(this.ranges,!this.inverted)},L.prototype.toString=function(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)},L.offset=function(e){return 0==e?L.empty:new L(0>e?[0,-e,0]:[0,0,e])},L.empty=new L([]);var J=function(e,t,o,n){this.maps=e||[],this.from=o||0,this.to=null==n?this.maps.length:n,this.mirror=t};J.prototype.slice=function(e,t){return void 0===e&&(e=0),void 0===t&&(t=this.maps.length),new J(this.maps,this.mirror,e,t)},J.prototype.copy=function(){return new J(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)},J.prototype.appendMap=function(e,t){this.to=this.maps.push(e),null!=t&&this.setMirror(this.maps.length-1,t)},J.prototype.appendMapping=function(e){for(var t=this,o=0,n=this.maps.length,r;o<e.maps.length;o++)r=e.getMirror(o),t.appendMap(e.maps[o],null!=r&&r<o?n+r:null)},J.prototype.getMirror=function(e){var t=this;if(this.mirror)for(var o=0;o<this.mirror.length;o++)if(t.mirror[o]==e)return t.mirror[o+(o%2?-1:1)]},J.prototype.setMirror=function(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)},J.prototype.appendMappingInverted=function(e){for(var t=this,o=e.maps.length-1,n=this.maps.length+e.maps.length,r;0<=o;o--)r=e.getMirror(o),t.appendMap(e.maps[o].invert(),null!=r&&r>o?n-r-1:null)},J.prototype.invert=function(){var e=new J;return e.appendMappingInverted(this),e},J.prototype.map=function(e,t){var o=this;if(void 0===t&&(t=1),this.mirror)return this._map(e,t,!0);for(var n=this.from;n<this.to;n++)e=o.maps[n].map(e,t);return e},J.prototype.mapResult=function(e,t){return void 0===t&&(t=1),this._map(e,t,!1)},J.prototype._map=function(e,t,o){for(var n=this,r=!1,d=null,p=this.from;p<this.to;p++){var a=n.maps[p],s=d&&d[p];if(null!=s&&a.touches(e,s)){e=a.recover(s);continue}var l=a.mapResult(e,t);if(null!=l.recover){var c=n.getMirror(p);if(null!=c&&c>p&&c<n.to)if(l.deleted){p=c,e=n.maps[c].recover(l.recover);continue}else(d||(d=Object.create(null)))[c]=l.recover}l.deleted&&(r=!0),e=l.pos}return o?e:new V(e,r)},d.prototype=Object.create(Error.prototype),d.prototype.constructor=d,d.prototype.name="TransformError";var W=function(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new J},j={before:{},docChanged:{}};j.before.get=function(){return this.docs.length?this.docs[0]:this.doc},W.prototype.step=function(e){var t=this.maybeStep(e);if(t.failed)throw new d(t.failed);return this},W.prototype.maybeStep=function(e){var t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t},j.docChanged.get=function(){return 0<this.steps.length},W.prototype.addStep=function(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t},Object.defineProperties(W.prototype,j);var K=Object.create(null),q=function(){};q.prototype.apply=function(){return i()},q.prototype.getMap=function(){return L.empty},q.prototype.invert=function(){return i()},q.prototype.map=function(){return i()},q.prototype.merge=function(){return null},q.prototype.toJSON=function(){return i()},q.fromJSON=function(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");var o=K[t.stepType];if(!o)throw new RangeError("No step type "+t.stepType+" defined");return o.fromJSON(e,t)},q.jsonID=function(e,t){if(e in K)throw new RangeError("Duplicate use of step JSON ID "+e);return K[e]=t,t.prototype.jsonID=e,t};var H=function(e,t){this.doc=e,this.failed=t};H.ok=function(e){return new H(e,null)},H.fail=function(e){return new H(null,e)},H.fromReplace=function(e,t,o,n){try{return H.ok(e.replace(t,o,n))}catch(t){if(t instanceof h.ReplaceError)return H.fail(t.message);throw t}};var U=function(e){function t(t,o,n,r){e.call(this),this.from=t,this.to=o,this.slice=n,this.structure=!!r}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.apply=function(e){return this.structure&&p(e,this.from,this.to)?H.fail("Structure replace would overwrite content"):H.fromReplace(e,this.from,this.to,this.slice)},t.prototype.getMap=function(){return new L([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 o=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return o.deleted&&n.deleted?null:new t(o.pos,s(o.pos,n.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){var o=0==this.slice.size+e.slice.size?h.Slice.empty:new h.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)}if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){var n=0==this.slice.size+e.slice.size?h.Slice.empty:new h.Slice(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new t(e.from,this.to,n,this.structure)}return null},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,o){if("number"!=typeof o.from||"number"!=typeof o.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new t(o.from,o.to,h.Slice.fromJSON(e,o.slice),!!o.structure)},t}(q);q.jsonID("replace",U);var G=function(e){function t(t,o,n,r,d,i,p){e.call(this),this.from=t,this.to=o,this.gapFrom=n,this.gapTo=r,this.slice=d,this.insert=i,this.structure=!!p}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.apply=function(e){if(this.structure&&(p(e,this.from,this.gapFrom)||p(e,this.gapTo,this.to)))return H.fail("Structure gap-replace would overwrite content");var t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return H.fail("Gap is not a flat range");var o=this.slice.insertAt(this.insert,t.content);return o?H.fromReplace(e,this.from,this.to,o):H.fail("Content does not fit in gap")},t.prototype.getMap=function(){return new L([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 o=this.gapTo-this.gapFrom;return new t(this.from,this.from+this.slice.size+o,this.from+this.insert,this.from+this.insert+o,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 o=e.mapResult(this.from,1),n=e.mapResult(this.to,-1),r=e.map(this.gapFrom,-1),d=e.map(this.gapTo,1);return o.deleted&&n.deleted||r<o.pos||d>n.pos?null:new t(o.pos,n.pos,r,d,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,o){if("number"!=typeof o.from||"number"!=typeof o.to||"number"!=typeof o.gapFrom||"number"!=typeof o.gapTo||"number"!=typeof o.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new t(o.from,o.to,o.gapFrom,o.gapTo,h.Slice.fromJSON(e,o.slice),o.insert,!!o.structure)},t}(q);q.jsonID("replaceAround",G),W.prototype.lift=function(e,t){for(var o=e.$from,n=e.$to,r=e.depth,i=o.before(r+1),p=n.after(r+1),a=i,s=p,l=h.Fragment.empty,c=0,m=r,f=!1;m>t;m--)f||0<o.index(m)?(f=!0,l=h.Fragment.from(o.node(m).copy(l)),c++):a--;for(var g=h.Fragment.empty,u=0,y=r,S=!1;y>t;y--)S||n.after(y+1)<n.end(y)?(S=!0,g=h.Fragment.from(n.node(y).copy(g)),u++):s++;return this.step(new G(a,s,i,p,new h.Slice(l.append(g),c,u),l.size-c,!0))},W.prototype.wrap=function(e,t){for(var o=h.Fragment.empty,n=t.length-1;0<=n;n--)o=h.Fragment.from(t[n].type.create(t[n].attrs,o));var r=e.start,d=e.end;return this.step(new G(r,d,r,d,new h.Slice(o,0,0),t.length,!0))},W.prototype.setBlockType=function(e,t,o,n){var r=this;if(void 0===t&&(t=e),!o.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");var d=this.steps.length;return this.doc.nodesBetween(e,t,function(e,t){if(e.isTextblock&&!e.hasMarkup(o,n)&&g(r.doc,r.mapping.slice(d).map(t),o)){r.clearIncompatible(r.mapping.slice(d).map(t,1),o);var i=r.mapping.slice(d),p=i.map(t,1),a=i.map(t+e.nodeSize,1);return r.step(new G(p,a,p+1,a-1,new h.Slice(h.Fragment.from(o.create(n,null,e.marks)),0,0),1,!0)),!1}}),this},W.prototype.setNodeMarkup=function(e,t,o,n){var r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at given position");t||(t=r.type);var d=t.create(o,null,n||r.marks);if(r.isLeaf)return this.replaceWith(e,e+r.nodeSize,d);if(!t.validContent(r.content))throw new RangeError("Invalid content for node type "+t.name);return this.step(new G(e,e+r.nodeSize,e+1,e+r.nodeSize-1,new h.Slice(h.Fragment.from(d),0,0),1,!0))},W.prototype.split=function(t,o,n){void 0===o&&(o=1);for(var r=this.doc.resolve(t),p=h.Fragment.empty,a=h.Fragment.empty,s=r.depth,l=r.depth-o,e=o-1;s>l;s--,e--){p=h.Fragment.from(r.node(s).copy(p));var c=n&&n[e];a=h.Fragment.from(c?c.type.create(c.attrs,a):r.node(s).copy(a))}return this.step(new U(t,t,new h.Slice(p.append(a),o,o),!0))},W.prototype.join=function(e,t){void 0===t&&(t=1);var o=new U(e-t,e+t,h.Slice.empty,!0);return this.step(o)};var X=function(e){function t(t,o,n){e.call(this),this.from=t,this.to=o,this.mark=n}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.apply=function(e){var t=this,o=e.slice(this.from,this.to),n=e.resolve(this.from),r=n.node(n.sharedDepth(this.to)),d=new h.Slice(v(o.content,function(e,o){return o.type.allowsMarkType(t.mark.type)?e.mark(t.mark.addToSet(e.marks)):e},r),o.openStart,o.openEnd);return H.fromReplace(e,this.from,this.to,d)},t.prototype.invert=function(){return new Q(this.from,this.to,this.mark)},t.prototype.map=function(e){var o=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return o.deleted&&n.deleted||o.pos>=n.pos?null:new t(o.pos,n.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(l(this.from,e.from),s(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,o){if("number"!=typeof o.from||"number"!=typeof o.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new t(o.from,o.to,e.markFromJSON(o.mark))},t}(q);q.jsonID("addMark",X);var Q=function(e){function t(t,o,n){e.call(this),this.from=t,this.to=o,this.mark=n}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.apply=function(e){var t=this,o=e.slice(this.from,this.to),n=new h.Slice(v(o.content,function(e){return e.mark(t.mark.removeFromSet(e.marks))}),o.openStart,o.openEnd);return H.fromReplace(e,this.from,this.to,n)},t.prototype.invert=function(){return new X(this.from,this.to,this.mark)},t.prototype.map=function(e){var o=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return o.deleted&&n.deleted||o.pos>=n.pos?null:new t(o.pos,n.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(l(this.from,e.from),s(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,o){if("number"!=typeof o.from||"number"!=typeof o.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new t(o.from,o.to,e.markFromJSON(o.mark))},t}(q);q.jsonID("removeMark",Q),W.prototype.addMark=function(e,t,o){var n=this,r=[],d=[],p=null,a=null;return this.doc.nodesBetween(e,t,function(n,c,h){if(n.isInline){var m=n.marks;if(!o.isInSet(m)&&h.type.allowsMarkType(o.type)){for(var f=s(c,e),g=l(c+n.nodeSize,t),u=o.addToSet(m),y=0;y<m.length;y++)m[y].isInSet(u)||(p&&p.to==f&&p.mark.eq(m[y])?p.to=g:r.push(p=new Q(f,g,m[y])));a&&a.to==f?a.to=g:d.push(a=new X(f,g,o))}}}),r.forEach(function(e){return n.step(e)}),d.forEach(function(e){return n.step(e)}),this},W.prototype.removeMark=function(e,t,o){var n=this;void 0===o&&(o=null);var r=[],d=0;return this.doc.nodesBetween(e,t,function(n,p){if(n.isInline){d++;var a=null;if(o instanceof h.MarkType){var c=o.isInSet(n.marks);c&&(a=[c])}else o?o.isInSet(n.marks)&&(a=[o]):a=n.marks;if(a&&a.length)for(var f=l(p+n.nodeSize,t),g=0;g<a.length;g++){for(var u=a[g],y=void 0,S=0,C;S<r.length;S++)C=r[S],C.step==d-1&&u.eq(r[S].style)&&(y=C);y?(y.to=f,y.step=d):r.push({style:u,from:s(p,e),to:f,step:d})}}}),r.forEach(function(e){return n.step(new Q(e.from,e.to,e.style))}),this},W.prototype.clearIncompatible=function(e,t,o){var n=this;void 0===o&&(o=t.contentMatch);for(var r=this.doc.nodeAt(e),d=[],p=e+1,a=0;a<r.childCount;a++){var s=r.child(a),l=p+s.nodeSize,c=o.matchType(s.type,s.attrs);if(!c)d.push(new U(p,l,h.Slice.empty));else{o=c;for(var m=0;m<s.marks.length;m++)t.allowsMarkType(s.marks[m].type)||n.step(new Q(p,l,s.marks[m]))}p=l}if(!o.validEnd){var f=o.fillBefore(h.Fragment.empty,!0);this.replace(p,p,new h.Slice(f,0,0))}for(var g=d.length-1;0<=g;g--)n.step(d[g]);return this},W.prototype.replace=function(e,t,o){void 0===t&&(t=e),void 0===o&&(o=h.Slice.empty);var n=b(this.doc,e,t,o);return n&&this.step(n),this},W.prototype.replaceWith=function(e,t,o){return this.replace(e,t,new h.Slice(h.Fragment.from(o),0,0))},W.prototype.delete=function(e,t){return this.replace(e,t,h.Slice.empty)},W.prototype.insert=function(e,t){return this.replaceWith(e,e,t)};var Y=function(e){var t=this;this.open=[];for(var o=0;o<=e.depth;o++){var n=e.node(o),r=n.contentMatchAt(e.indexAfter(o));t.open.push({parent:n,match:r,content:h.Fragment.empty,wrapper:!1,openEnd:0,depth:o})}this.placed=[]};Y.prototype.placeSlice=function(e,t,o,n,r){if(0<t){var d=e.firstChild,i=this.placeSlice(d.content,s(0,t-1),o&&1==e.childCount?o-1:0,n,d);i.content!=d.content&&(i.content.size?(e=e.replaceChild(0,d.copy(i.content)),t=i.openStart+1):(1==e.childCount&&(o=0),e=e.cutByIndex(1),t=0))}var p=this.placeContent(e,t,o,n,r);if(2<n&&p.size&&0==t){var a=p.content.firstChild,l=1==p.content.childCount;this.placeContent(a.content,0,o&&l?o-1:0,n,a),p=l?h.Fragment.empty:new h.Slice(p.content.cutByIndex(1),0,o)}return p},Y.prototype.placeContent=function(e,t,o,n,r){for(var p=this,a=0;a<e.childCount;a++){for(var s=e.child(a),l=!1,c=a==e.childCount-1,m=this.open.length-1;0<=m;m--){var f=p.open[m],g=void 0;if(1<n&&(g=f.match.findWrapping(s.type))&&!(r&&g.length&&g[g.length-1]==r.type)){for(;this.open.length-1>m;)p.closeNode();for(var u=0;u<g.length;u++)f.match=f.match.matchType(g[u]),m++,f={parent:g[u].create(),match:g[u].contentMatch,content:h.Fragment.empty,wrapper:!0,openEnd:0,depth:m+u},p.open.push(f)}var y=f.match.matchType(s.type);if(!y){var S=f.match.fillBefore(h.Fragment.from(s));if(S)for(var C=0,v;C<S.childCount;C++)v=S.child(C),p.addNode(f,v,0),y=f.match.matchFragment(v);else if(r&&f.match.matchType(r.type))break;else continue}for(;this.open.length-1>m;)p.closeNode();s=s.mark(f.parent.type.allowedMarks(s.marks)),t&&(s=P(s,t,c?o:0),t=0),p.addNode(f,s,c?o:0),f.match=y,c&&(o=0),l=!0;break}if(!l)break}return 1<this.open.length&&(0<a&&a==e.childCount||r&&this.open[this.open.length-1].parent.type==r.type)&&this.closeNode(),new h.Slice(e.cutByIndex(a),t,o)},Y.prototype.addNode=function(e,t,o){e.content=$(e.content,e.openEnd).addToEnd(t),e.openEnd=o},Y.prototype.closeNode=function(){var e=this.open.pop();if(0==e.content.size);else e.wrapper?this.addNode(this.open[this.open.length-1],e.parent.copy(e.content),e.openEnd+1):this.placed[e.depth]={depth:e.depth,content:e.content,openEnd:e.openEnd}},W.prototype.replaceRange=function(e,t,o){var n=this;if(!o.size)return this.deleteRange(e,t);var r=this.doc.resolve(e),p=this.doc.resolve(t);if(A(r,p,o))return this.step(new U(e,t,o));var a=F(r,this.doc.resolve(t));0==a[a.length-1]&&a.pop();var s=-(r.depth+1);a.unshift(s);for(var l=r.depth,c=r.pos-1,m;0<l&&(m=r.node(l).type.spec,!(m.defining||m.isolating));l--,c--)-1<a.indexOf(l)?s=l:r.before(l)==c&&a.splice(1,0,-l);for(var f=a.indexOf(s),g=[],u=o.openStart,y=o.content,S=0,C;;S++){if(C=y.firstChild,g.push(C),S==o.openStart)break;y=C.content}0<u&&g[u-1].type.spec.defining&&r.node(f).type!=g[u-1].type?u-=1:2<=u&&g[u-1].isTextblock&&g[u-2].type.spec.defining&&r.node(f).type!=g[u-2].type&&(u-=2);for(var v=o.openStart;0<=v;v--){var b=(v+u+1)%(o.openStart+1),w=g[b];if(w)for(var x=0;x<a.length;x++){var k=a[(x+f)%a.length],M=!0;0>k&&(M=!1,k=-k);var T=r.node(k-1),N=r.index(k-1);if(T.canReplaceWith(N,N,w.type,w.marks))return n.replace(r.before(k),M?p.after(k):t,new h.Slice(z(o.content,0,o.openStart,b),b,o.openEnd))}}for(var O=this.steps.length,D=a.length-1,R;0<=D&&(n.replace(e,t,o),!(n.steps.length>O));D--)R=a[D],0>D||(e=r.before(R),t=p.after(R));return this},W.prototype.replaceRangeWith=function(e,t,o){if(!o.isInline&&e==t&&this.doc.resolve(e).parent.content.size){var n=S(this.doc,e,o.type);null!=n&&(e=t=n)}return this.replaceRange(e,t,new h.Slice(h.Fragment.from(o),0,0))},W.prototype.deleteRange=function(e,t){for(var o=this,n=this.doc.resolve(e),r=this.doc.resolve(t),p=F(n,r),a=0;a<p.length;a++){var s=p[a],l=a==p.length-1;if(l&&0==s||n.node(s).type.contentMatch.validEnd)return o.delete(n.start(s),r.end(s));if(0<s&&(l||n.node(s-1).canReplace(n.index(s-1),r.indexAfter(s-1))))return o.delete(n.before(s),r.after(s))}for(var c=1;c<=n.depth;c++)if(e-n.start(c)==n.depth-c&&t>n.end(c))return o.delete(n.before(c),t);return this.delete(e,t)},t.Transform=W,t.TransformError=d,t.Step=q,t.StepResult=H,t.joinPoint=function(e,t,o){void 0===o&&(o=-1);for(var n=e.resolve(t),r=n.depth;;r--){var i=void 0,p=void 0;if(r==n.depth?(i=n.nodeBefore,p=n.nodeAfter):0<o?(i=n.node(r+1),p=n.node(r).maybeChild(n.index(r)+1)):(i=n.node(r).maybeChild(n.index(r)-1),p=n.node(r+1)),i&&!i.isTextblock&&y(i,p))return t;if(0==r)break;t=0>o?n.before(r):n.after(r)}},t.canJoin=function(e,t){var o=e.resolve(t),n=o.index();return y(o.nodeBefore,o.nodeAfter)&&o.parent.canReplace(n,n+1)},t.canSplit=u,t.insertPoint=S,t.dropPoint=C,t.liftTarget=function(e){for(var t=e.parent,o=t.content.cutByIndex(e.startIndex,e.endIndex),n=e.depth;;--n){var r=e.$from.node(n),d=e.$from.index(n),i=e.$to.indexAfter(n);if(n<e.depth&&r.canReplace(d,i,o))return n;if(0==n||r.type.spec.isolating||!a(r,d,i))break}},t.findWrapping=function(e,t,o,n){void 0===n&&(n=e);var r=m(e,t),d=r&&f(n,t);return d?r.map(c).concat({type:t,attrs:o}).concat(d.map(c)):null},t.StepMap=L,t.MapResult=V,t.Mapping=J,t.AddMarkStep=X,t.RemoveMarkStep=Q,t.ReplaceStep=U,t.ReplaceAroundStep=G,t.replaceStep=b});t(T);var N=T.Transform,O=T.TransformError,A=T.Step,D=T.StepResult,R=T.joinPoint,I=T.canJoin,P=T.canSplit,E=T.insertPoint,$=T.dropPoint,z=T.liftTarget,F=T.findWrapping,B=T.StepMap,_=T.MapResult,V=T.Mapping,L=T.AddMarkStep,J=T.RemoveMarkStep,W=T.ReplaceStep,j=T.ReplaceAroundStep,K=T.replaceStep,q=o(function(e,t){function o(e,t,n,r,d,p){if(t.inlineContent)return c.create(e,n);for(var a=r-(0<d?0:1),s;0<d?a<t.childCount:0<=a;a+=d){if(s=t.child(a),!s.isAtom){var l=o(e,s,n+d,0>d?s.childCount:0,d,p);if(l)return l}else if(!p&&f.isSelectable(s))return f.create(e,n-(0>d?s.nodeSize:0));n+=s.nodeSize*d}}function n(e,t,o){var n=e.steps.length-1;if(!(n<t)){var r=e.steps[n];if(r instanceof T.ReplaceStep||r instanceof T.ReplaceAroundStep){var d=e.mapping.maps[n],i;d.forEach(function(e,t,o,n){null==i&&(i=n)}),e.setSelection(a.near(e.doc.resolve(i),o))}}}function r(e,t){return t&&e?e.bind(t):e}function d(e,t,o){for(var n in e){var r=e[n];r instanceof Function?r=r.bind(t):"handleDOMEvents"==n&&(r=d(r,t,{})),o[n]=r}return o}function i(e){return e in D?e+"$"+ ++D[e]:(D[e]=0,e+"$")}Object.defineProperty(t,"__esModule",{value:!0});var p=Object.create(null),a=function(e,t,o){this.ranges=o||[new l(e.min(t),e.max(t))],this.$anchor=e,this.$head=t},s={anchor:{},head:{},from:{},to:{},$from:{},$to:{},empty:{}};s.anchor.get=function(){return this.$anchor.pos},s.head.get=function(){return this.$head.pos},s.from.get=function(){return this.$from.pos},s.to.get=function(){return this.$to.pos},s.$from.get=function(){return this.ranges[0].$from},s.$to.get=function(){return this.ranges[0].$to},s.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},a.prototype.content=function(){return this.$from.node(0).slice(this.from,this.to,!0)},a.prototype.replace=function(e,t){void 0===t&&(t=h.Slice.empty);for(var o=t.content.lastChild,r=null,d=0;d<t.openEnd;d++)r=o,o=o.lastChild;for(var p=e.steps.length,a=this.ranges,s=0;s<a.length;s++){var l=a[s],c=l.$from,m=l.$to,f=e.mapping.slice(p);e.replaceRange(f.map(c.pos),f.map(m.pos),s?h.Slice.empty:t),0==s&&n(e,p,(o?o.isInline:r&&r.isTextblock)?-1:1)}},a.prototype.replaceWith=function(e,t){for(var o=e.steps.length,r=this.ranges,d=0;d<r.length;d++){var p=r[d],a=p.$from,s=p.$to,l=e.mapping.slice(o),c=l.map(a.pos),h=l.map(s.pos);d?e.deleteRange(c,h):(e.replaceRangeWith(c,h,t),n(e,o,t.isInline?-1:1))}},a.findFrom=function(e,t,n){var r=e.parent.inlineContent?new c(e):o(e.node(0),e.parent,e.pos,e.index(),t,n);if(r)return r;for(var d=e.depth-1,i;0<=d;d--)if(i=0>t?o(e.node(0),e.node(d),e.before(d+1),e.index(d),t,n):o(e.node(0),e.node(d),e.after(d+1),e.index(d)+1,t,n),i)return i},a.near=function(e,t){return void 0===t&&(t=1),this.findFrom(e,t)||this.findFrom(e,-t)||new u(e.node(0))},a.atStart=function(e){return o(e,e,0,0,1)||new u(e)},a.atEnd=function(e){return o(e,e,e.content.size,e.childCount,-1)||new u(e)},a.fromJSON=function(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");var o=p[t.type];if(!o)throw new RangeError("No selection type "+t.type+" defined");return o.fromJSON(e,t)},a.jsonID=function(e,t){if(e in p)throw new RangeError("Duplicate use of selection JSON ID "+e);return p[e]=t,t.prototype.jsonID=e,t},a.prototype.getBookmark=function(){return c.between(this.$anchor,this.$head).getBookmark()},Object.defineProperties(a.prototype,s),a.prototype.visible=!0;var l=function(e,t){this.$from=e,this.$to=t},c=function(e){function t(t,o){void 0===o&&(o=t),e.call(this,t,o)}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var o={$cursor:{}};return o.$cursor.get=function(){return this.$anchor.pos==this.$head.pos?this.$head:null},t.prototype.map=function(o,n){var r=o.resolve(n.map(this.head));if(!r.parent.inlineContent)return e.near(r);var d=o.resolve(n.map(this.anchor));return new t(d.parent.inlineContent?d:r,r)},t.prototype.replace=function(t,o){if(void 0===o&&(o=h.Slice.empty),e.prototype.replace.call(this,t,o),o==h.Slice.empty){var n=this.$from.marksAcross(this.$to);n&&t.ensureMarks(n)}},t.prototype.eq=function(e){return e instanceof t&&e.anchor==this.anchor&&e.head==this.head},t.prototype.getBookmark=function(){return new m(this.anchor,this.head)},t.prototype.toJSON=function(){return{type:"text",anchor:this.anchor,head:this.head}},t.fromJSON=function(e,o){if("number"!=typeof o.anchor||"number"!=typeof o.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new t(e.resolve(o.anchor),e.resolve(o.head))},t.create=function(e,t,o){void 0===o&&(o=t);var n=e.resolve(t);return new this(n,o==t?n:e.resolve(o))},t.between=function(o,n,r){var d=o.pos-n.pos;if((!r||d)&&(r=0<=d?1:-1),!n.parent.inlineContent){var i=e.findFrom(n,r,!0)||e.findFrom(n,-r,!0);if(i)n=i.$head;else return e.near(n,r)}return o.parent.inlineContent||(0==d?o=n:(o=(e.findFrom(o,-r,!0)||e.findFrom(o,r,!0)).$anchor,o.pos<n.pos!=0>d&&(o=n))),new t(o,n)},Object.defineProperties(t.prototype,o),t}(a);a.jsonID("text",c);var m=function(e,t){this.anchor=e,this.head=t};m.prototype.map=function(e){return new m(e.map(this.anchor),e.map(this.head))},m.prototype.resolve=function(e){return c.between(e.resolve(this.anchor),e.resolve(this.head))};var f=function(e){function t(t){var o=t.nodeAfter,n=t.node(0).resolve(t.pos+o.nodeSize);e.call(this,t,n),this.node=o}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.map=function(o,n){var r=n.mapResult(this.anchor),d=r.deleted,i=r.pos,p=o.resolve(i);return d?e.near(p):new t(p)},t.prototype.content=function(){return new h.Slice(h.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 g(this.anchor)},t.fromJSON=function(e,o){if("number"!=typeof o.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new t(e.resolve(o.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}(a);f.prototype.visible=!1,a.jsonID("node",f);var g=function(e){this.anchor=e};g.prototype.map=function(e){var t=e.mapResult(this.anchor),o=t.deleted,n=t.pos;return o?new m(n,n):new g(n)},g.prototype.resolve=function(e){var t=e.resolve(this.anchor),o=t.nodeAfter;return o&&f.isSelectable(o)?new f(t):a.near(t)};var u=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.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 y},t}(a);a.jsonID("all",u);var y={map:function(){return this},resolve:function(e){return new u(e)}},S=1,C=2,v=4,b=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 o={selection:{},selectionSet:{},storedMarksSet:{},isGeneric:{},scrolledIntoView:{}};return o.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=(this.updated|S)&~C,this.storedMarks=null,this},o.selectionSet.get=function(){return 0<(this.updated&S)},t.prototype.setStoredMarks=function(e){return this.storedMarks=e,this.updated|=C,this},t.prototype.ensureMarks=function(e){return h.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()))},o.storedMarksSet.get=function(){return 0<(this.updated&C)},t.prototype.addStep=function(t,o){e.prototype.addStep.call(this,t,o),this.updated&=~C,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 o=this.selection;return!1!==t&&(e=e.mark(this.storedMarks||(o.empty?o.$from.marks():o.$from.marksAcross(o.$to)||h.Mark.none))),o.replaceWith(this,e),this},t.prototype.deleteSelection=function(){return this.selection.replace(this),this},t.prototype.insertText=function(e,t,o){void 0===o&&(o=t);var n=this.doc.type.schema;if(null==t)return e?this.replaceSelectionWith(n.text(e),!0):this.deleteSelection();if(!e)return this.deleteRange(t,o);var r=this.storedMarks;if(!r){var d=this.doc.resolve(t);r=o==t?d.marks():d.marksAcross(this.doc.resolve(o))}return this.replaceRangeWith(t,o,n.text(e,r)),this.selection.empty||this.setSelection(a.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]},o.isGeneric.get=function(){var e=this;for(var t in e.meta)return!1;return!0},t.prototype.scrollIntoView=function(){return this.updated|=v,this},o.scrolledIntoView.get=function(){return 0<(this.updated&v)},Object.defineProperties(t.prototype,o),t}(T.Transform),w=function(e,t,o){this.name=e,this.init=r(t.init,o),this.apply=r(t.apply,o)},x=[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||a.atStart(t.doc)},apply:function(e){return e.selection}}),new w("storedMarks",{init:function(e){return e.storedMarks||null},apply:function(e,t,o,n){return n.selection.$cursor?e.storedMarks:null}}),new w("scrollToSelection",{init:function(){return 0},apply:function(e,t){return e.scrolledIntoView?t+1:t}})],k=function(e,t){var o=this;this.schema=e,this.fields=x.concat(),this.plugins=[],this.pluginsByKey=Object.create(null),t&&t.forEach(function(e){if(o.pluginsByKey[e.key])throw new RangeError("Adding different instances of a keyed plugin ("+e.key+")");o.plugins.push(e),o.pluginsByKey[e.key]=e,e.spec.state&&o.fields.push(new w(e.key,e.spec.state,e))})},M=function(e){this.config=e},N={schema:{},plugins:{},tr:{}};N.schema.get=function(){return this.config.schema},N.plugins.get=function(){return this.config.plugins},M.prototype.apply=function(e){return this.applyTransaction(e).state},M.prototype.filterTransaction=function(e,t){var o=this;void 0===t&&(t=-1);for(var n=0;n<this.config.plugins.length;n++)if(n!=t){var r=o.config.plugins[n];if(r.spec.filterTransaction&&!r.spec.filterTransaction.call(r,e,o))return!1}return!0},M.prototype.applyTransaction=function(e){var t=this;if(!this.filterTransaction(e))return{state:this,transactions:[]};var o=[e],r=this.applyInner(e),d=null;outer:for(;;){for(var p=!1,a=0,s;a<this.config.plugins.length;a++)if(s=t.config.plugins[a],s.spec.appendTransaction){var l=d?d[a].n:0,n=d?d[a].state:t,c=l<o.length&&s.spec.appendTransaction.call(s,l?o.slice(l):o,n,r);if(c&&r.filterTransaction(c,a)){if(c.setMeta("appendedTransaction",e),!d){d=[];for(var h=0;h<this.config.plugins.length;h++)d.push(h<a?{state:r,n:o.length}:{state:t,n:0})}o.push(c),r=r.applyInner(c),p=!0}d&&(d[a]={state:r,n:o.length})}if(!p)return{state:r,transactions:o}}},M.prototype.applyInner=function(e){var t=this;if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");for(var o=new M(this.config),n=this.config.fields,r=0,d;r<n.length;r++)d=n[r],o[d.name]=d.apply(e,t[d.name],t,o);for(var p=0;p<O.length;p++)O[p](t,e,o);return o},N.tr.get=function(){return new b(this)},M.create=function(e){for(var t=new k(e.schema||e.doc.type.schema,e.plugins),o=new M(t),n=0;n<t.fields.length;n++)o[t.fields[n].name]=t.fields[n].init(e,o);return o},M.prototype.reconfigure=function(e){for(var t=this,o=new k(e.schema||this.schema,e.plugins),n=o.fields,r=new M(o),d=0,p;d<n.length;d++)p=n[d].name,r[p]=t.hasOwnProperty(p)?t[p]:n[d].init(e,r);return r},M.prototype.toJSON=function(e){var t=this,o={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(o.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],d=r.spec.state;d&&d.toJSON&&(o[n]=d.toJSON.call(r,t[r.key]))}return o},M.fromJSON=function(e,t,o){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");var n=new k(e.schema,e.plugins),r=new M(n);return n.fields.forEach(function(n){if("doc"==n.name)r.doc=h.Node.fromJSON(e.schema,t.doc);else if("selection"==n.name)r.selection=a.fromJSON(r.doc,t.selection);else if("storedMarks"==n.name)t.storedMarks&&(r.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(o)for(var d in o){var i=o[d],p=i.spec.state;if(i.key==n.name&&p&&p.fromJSON&&Object.prototype.hasOwnProperty.call(t,d))return void(r[n.name]=p.fromJSON.call(i,e,t[d],r))}r[n.name]=n.init(e,r)}}),r},M.addApplyListener=function(e){O.push(e)},M.removeApplyListener=function(e){var t=O.indexOf(e);-1<t&&O.splice(t,1)},Object.defineProperties(M.prototype,N);var O=[],A=function(e){this.props={},e.props&&d(e.props,this,this.props),this.spec=e,this.key=e.key?e.key.key:i("plugin")};A.prototype.getState=function(e){return e[this.key]};var D=Object.create(null),R=function(e){void 0===e&&(e="key"),this.key=i(e)};R.prototype.get=function(e){return e.config.pluginsByKey[this.key]},R.prototype.getState=function(e){return e[this.key]},t.Selection=a,t.SelectionRange=l,t.TextSelection=c,t.NodeSelection=f,t.AllSelection=u,t.Transaction=b,t.EditorState=M,t.Plugin=A,t.PluginKey=R});t(q);var H=q.Selection,U=q.SelectionRange,G=q.TextSelection,X=q.NodeSelection,Q=q.AllSelection,Y=q.Transaction,Z=q.EditorState,ee=q.Plugin,te=q.PluginKey,oe=o(function(e,t){var Rt=Math.abs;function o(e,t,o,d,i){for(;;){if(e==o&&t==d)return!0;if(t==(0>i?0:n(e))){var p=e.parentNode;if(1!=p.nodeType||r(e)||Lt.test(e.nodeName)||"false"==e.contentEditable)return!1;t=Ft(e)+(0>i?0:1),e=p}else if(1==e.nodeType)e=e.childNodes[t+(0>i?-1:0)],t=0>i?n(e):0;else return!1}}function n(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function r(e){var t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function i(e,t){var o=document.createEvent("Event");return o.initEvent("keydown",!0,!0),o.keyCode=e,o.key=o.code=t,o}function a(e){return{left:0,right:e.innerWidth,top:0,bottom:e.innerHeight}}function c(e,t){return"number"==typeof e?e:e[t]}function m(e,t,o){for(var n=e.someProp("scrollThreshold")||0,r=e.someProp("scrollMargin")||5,d=e.dom.ownerDocument,i=d.defaultView,p=o||e.dom;;p=Bt(p)){if(!p)break;if(1==p.nodeType){var s=p==d.body||1!=p.nodeType,l=s?a(i):p.getBoundingClientRect(),h=0,m=0;if(t.top<l.top+c(n,"top")?m=-(l.top-t.top+c(r,"top")):t.bottom>l.bottom-c(n,"bottom")&&(m=t.bottom-l.bottom+c(r,"bottom")),t.left<l.left+c(n,"left")?h=-(l.left-t.left+c(r,"left")):t.right>l.right-c(n,"right")&&(h=t.right-l.right+c(r,"right")),(h||m)&&(s?i.scrollBy(h,m):(m&&(p.scrollTop+=m),h&&(p.scrollLeft+=h))),s)break}}}function f(e){for(var t=e.dom.getBoundingClientRect(),o=s(0,t.top),n=e.dom.ownerDocument,r=(t.left+t.right)/2,d=o+1,i,p,a;d<l(innerHeight,t.bottom);d+=5)if(a=e.root.elementFromPoint(r,d),a!=e.dom&&e.dom.contains(a)){var c=a.getBoundingClientRect();if(c.top>=o-20){i=a,p=c.top;break}}for(var h=[],m=e.dom;m&&(h.push({dom:m,top:m.scrollTop,left:m.scrollLeft}),m!=n.body);m=Bt(m));return{refDOM:i,refTop:p,stack:h}}function g(e){for(var t=e.refDOM,o=e.refTop,n=e.stack,r=t?t.getBoundingClientRect().top:0,d=0==r?0:r-o,p=0;p<n.length;p++){var a=n[p],s=a.dom,l=a.top,c=a.left;s.scrollTop!=l+d&&(s.scrollTop=l+d),s.scrollLeft!=c&&(s.scrollLeft=c)}}function u(e,t){for(var o=2e8,n=0,r=t.top,d=t.top,p=e.firstChild,a=0,c,h,m;p;p=p.nextSibling,a++){if(m=void 0,1==p.nodeType)m=p.getClientRects();else if(3==p.nodeType)m=_t(p).getClientRects();else continue;for(var f=0,g;f<m.length;f++){if(g=m[f],g.top<=r&&g.bottom>=d){r=s(g.bottom,r),d=l(g.top,d);var S=g.left>t.left?g.left-t.left:g.right<t.left?t.left-g.right:0;if(S<o){c=p,o=S,h=S&&3==c.nodeType?{left:g.right<t.left?g.right:g.left,top:t.top}:t,1==p.nodeType&&S&&(n=a+(t.left>=(g.left+g.right)/2?1:0));continue}}!c&&(t.left>=g.right&&t.top>=g.top||t.left>=g.left&&t.top>=g.bottom)&&(n=a+1)}}return c&&3==c.nodeType?y(c,h):!c||o&&1==c.nodeType?{node:e,offset:n}:u(c,h)}function y(e,t){for(var o=e.nodeValue.length,n=document.createRange(),r=0;r<o;r++){n.setEnd(e,r+1),n.setStart(e,r);var d=k(n,1);if(d.top!=d.bottom&&S(t,d))return{node:e,offset:r+(t.left>=(d.left+d.right)/2?1:0)}}return{node:e,offset:0}}function S(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function C(e,t){var o=e.parentNode;return o&&/^li$/i.test(o.nodeName)&&t.left<e.getBoundingClientRect().left?o:e}function v(e,t,o){var n=u(t,o),r=n.node,d=n.offset,i=-1;if(1==r.nodeType&&!r.firstChild){var p=r.getBoundingClientRect();i=p.left!=p.right&&o.left>(p.left+p.right)/2?1:-1}return e.docView.posFromDOM(r,d,i)}function b(e,t,o,n){for(var r=-1,d=t;;){if(d==e.dom)break;var i=e.docView.nearestDesc(d,!0);if(!i)return null;if(i.node.isBlock&&i.parent){var p=i.dom.getBoundingClientRect();if(p.left>n.left||p.top>n.top)r=i.posBefore;else if(p.right<n.left||p.bottom<n.top)r=i.posAfter;else break}d=i.dom.parentNode}return-1<r?r:e.docView.posFromDOM(t,o)}function w(e,t,o){var n=e.childNodes.length;if(n&&o.top<o.bottom)for(var r=s(0,p(n*(t.top-o.top)/(o.bottom-o.top))-2),d=r,a;;){if(a=e.childNodes[d],1==a.nodeType)for(var l=a.getClientRects(),c=0,h;c<l.length;c++)if(h=l[c],S(t,h))return w(a,t,h);if((d=(d+1)%n)==r)break}return e}function x(e,t){var o=e.root,n,r;if(o.caretPositionFromPoint){var d=o.caretPositionFromPoint(t.left,t.top);if(d){var i;i=d,n=i.offsetNode,r=i.offset}}if(!n&&o.caretRangeFromPoint){var p=o.caretRangeFromPoint(t.left,t.top);if(p){var a;a=p,n=a.startContainer,r=a.startOffset}}var s=o.elementFromPoint(t.left,t.top+1),c;if(!s||!e.dom.contains(1==s.nodeType?s:s.parentNode)){var h=e.dom.getBoundingClientRect();if(!S(t,h))return null;if(s=w(e.dom,t,h),!s)return null}s=C(s,t),n&&(1==n.nodeType&&(r=l(r,n.childNodes.length)),n==e.dom&&r==n.childNodes.length-1&&1==n.lastChild.nodeType&&t.top>n.lastChild.getBoundingClientRect().bottom?c=e.state.doc.content.size:(0==r||1!=n.nodeType||"BR"!=n.childNodes[r-1].nodeName)&&(c=b(e,n,r,t))),null==c&&(c=v(e,s,t));var m=e.docView.nearestDesc(s,!0);return{pos:c,inside:m?m.posAtStart-m.border:-1}}function k(e,t){var o=e.getClientRects();return o.length?o[0>t?0:o.length-1]:e.getBoundingClientRect()}function M(e,t){var o=e.docView.domFromPos(t),r=o.node,d=o.offset;if(3==r.nodeType&&(It.chrome||It.gecko)){var i=k(_t(r,d,d),0);if(It.gecko&&d&&/\s/.test(r.nodeValue[d-1])&&d<r.nodeValue.length){var p=k(_t(r,d-1,d-1),-1);if(1>Rt(p.left-i.left)&&p.top==i.top){var a=k(_t(r,d,d+1),-1);return N(a,a.left<p.left)}}return i}if(1==r.nodeType&&!e.state.doc.resolve(t).parent.inlineContent){var s=!0,l;if(d<r.childNodes.length){var c=r.childNodes[d];1==c.nodeType&&(l=c.getBoundingClientRect())}if(!l&&d){var h=r.childNodes[d-1];1==h.nodeType&&(l=h.getBoundingClientRect(),s=!1)}return O(l||r.getBoundingClientRect(),s)}for(var m=-1;2>m;m+=2)if(0>m&&d){var f=void 0,g=3==r.nodeType?_t(r,d-1,d):3==(f=r.childNodes[d-1]).nodeType?_t(f):1==f.nodeType&&"BR"!=f.nodeName?f:null;if(g){var u=k(g,1);if(u.top<u.bottom)return N(u,!1)}}else if(0<m&&d<n(r)){var y=void 0,S=3==r.nodeType?_t(r,d,d+1):3==(y=r.childNodes[d]).nodeType?_t(y):1==y.nodeType?y:null;if(S){var C=k(S,-1);if(C.top<C.bottom)return N(C,!0)}}return N(k(3==r.nodeType?_t(r):r,0),!1)}function N(e,t){if(0==e.width)return e;var o=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:o,right:o}}function O(e,t){if(0==e.height)return e;var o=t?e.top:e.bottom;return{top:o,bottom:o,left:e.left,right:e.right}}function A(e,t,o){var n=e.state,r=e.root.activeElement;n!=t&&e.updateState(t),r!=e.dom&&e.focus();try{return o()}finally{n!=t&&e.updateState(n),r!=e.dom&&r.focus()}}function D(e,t,o){var n=t.selection,r="up"==o?n.$anchor.min(n.$head):n.$anchor.max(n.$head);return A(e,t,function(){for(var t=e.docView.domFromPos(r.pos),n=t.node,d;;){if(d=e.docView.nearestDesc(n,!0),!d)break;if(d.node.isBlock){n=d.dom;break}n=d.dom.parentNode}for(var p=M(e,r.pos),a=n.firstChild,s;a;a=a.nextSibling){if(s=void 0,1==a.nodeType)s=a.getClientRects();else if(3==a.nodeType)s=_t(a,0,a.nodeValue.length).getClientRects();else continue;for(var l=0,c;l<s.length;l++)if(c=s[l],c.bottom>c.top&&("up"==o?c.bottom<p.top+1:c.top>p.bottom-1))return!1}return!0})}function R(e,t,o){var n=t.selection,r=n.$head;if(!r.parent.isTextblock)return!1;var d=r.parentOffset,i=d==r.parent.content.size,p=getSelection();return Wt.test(r.parent.textContent)&&p.modify?A(e,t,function(){var t=p.getRangeAt(0),n=p.focusNode,d=p.focusOffset,i=p.caretBidiLevel;p.modify("move",o,"character");var a=r.depth?e.docView.domAfterPos(r.before()):e.dom,s=!a.contains(1==p.focusNode.nodeType?p.focusNode:p.focusNode.parentNode)||n==p.focusNode&&d==p.focusOffset;return p.removeAllRanges(),p.addRange(t),null!=i&&(p.caretBidiLevel=i),s}):"left"==o||"backward"==o?!d:i}function I(e,t,o){return jt==t&&Kt==o?qt:(jt=t,Kt=o,qt="up"==o||"down"==o?D(e,t,o):R(e,t,o))}function P(e,t,o,n,r){return _(n,t,e),new oo(null,e,t,o,n,n,n,r,0)}function E(e,t){for(var o=e.firstChild,n=0;n<t.length;n++){var r=t[n],d=r.dom;if(d.parentNode==e){for(;d!=o;)o=L(o);o=o.nextSibling}else e.insertBefore(d,o);if(r instanceof to){var p=o?o.previousSibling:e.lastChild;E(r.contentDOM,r.children),o=p?p.nextSibling:e.firstChild}}for(;o;)o=L(o)}function $(e){e&&(this.nodeName=e)}function z(e,t,o){if(0==e.length)return po;for(var n=o?po[0]:new $,r=[n],d=0;d<e.length;d++){var p=e[d].type.attrs,a=n;if(p)for(var s in p.nodeName&&r.push(a=new $(p.nodeName)),p){var l=p[s];null!=l&&(o&&1==r.length&&r.push(a=n=new $(t.isInline?"span":"div")),"class"==s?a.class=(a.class?a.class+" ":"")+l:"style"==s?a.style=(a.style?a.style+";":"")+l:"nodeName"!=s&&(a[s]=l))}}return r}function F(e,t,o,n){if(o==po&&n==po)return t;for(var r=t,d=0;d<n.length;d++){var p=n[d],a=o[d];if(d){var s=void 0;a&&a.nodeName==p.nodeName&&r!=e&&(s=t.parentNode)&&s.tagName.toLowerCase()==p.nodeName?r=s:(s=document.createElement(p.nodeName),s.appendChild(r),r=s)}B(r,a||po[0],p)}return r}function B(e,t,o){for(var n in t)"class"==n||"style"==n||"nodeName"==n||n in o||e.removeAttribute(n);for(var r in o)"class"!=r&&"style"!=r&&"nodeName"!=r&&o[r]!=t[r]&&e.setAttribute(r,o[r]);if(t.class!=o.class){for(var d=t.class?t.class.split(" "):Yt,p=o.class?o.class.split(" "):Yt,a=0;a<d.length;a++)-1==p.indexOf(d[a])&&e.classList.remove(d[a]);for(var s=0;s<p.length;s++)-1==d.indexOf(p[s])&&e.classList.add(p[s])}if(t.style!=o.style){if(t.style)for(var l=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,c;c=l.exec(t.style);)e.style[c[1].toLowerCase()]="";o.style&&(e.style.cssText+=o.style)}}function _(e,t,o){return F(e,e,po,z(t,o,1!=e.nodeType))}function V(e,t){if(e.length!=t.length)return!1;for(var o=0;o<e.length;o++)if(!e[o].type.eq(t[o].type))return!1;return!0}function L(e){var t=e.nextSibling;return e.parentNode.removeChild(e),t}function J(e,t){for(var o=[],n=e.childCount,r=t.length-1;0<n&&0<=r;r--){var d=t[r],p=d.node;if(p){if(p!=e.child(n-1))break;o.push(d),--n}}return{nodes:o.reverse(),offset:n}}function W(e,t){return e.type.side-t.type.side}function j(e,t,o,n){var r=t.locals(e),d=0;if(0==r.length){for(var p=0,a;p<e.childCount;p++)a=e.child(p),n(a,r,t.forChild(d,a),p),d+=a.nodeSize;return}for(var s=0,l=[],c=null,h=0;;){if(s<r.length&&r[s].to==d){for(var m=r[s++],f=void 0;s<r.length&&r[s].to==d;)(f||(f=[m])).push(r[s++]);if(f){f.sort(W);for(var g=0;g<f.length;g++)o(f[g],h)}else o(m,h)}var u=void 0,y=void 0;if(c)y=-1,u=c,c=null;else if(h<e.childCount)y=h,u=e.child(h++);else break;for(var S=0;S<l.length;S++)l[S].to<=d&&l.splice(S--,1);for(;s<r.length&&r[s].from==d;)l.push(r[s++]);var C=d+u.nodeSize;if(u.isText){var v=C;s<r.length&&r[s].from<v&&(v=r[s].from);for(var b=0;b<l.length;b++)l[b].to<v&&(v=l[b].to);v<C&&(c=u.cut(v-d),u=u.cut(0,v-d),C=v,y=-1)}n(u,l.length?l.slice():Yt,t.forChild(d,u),y),d=C}}function K(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}}function H(e,t){for(;;){if(3==e.nodeType)return e;if(1==e.nodeType&&0<t){if(e.childNodes.length>t&&3==e.childNodes[t].nodeType)return e.childNodes[t];e=e.childNodes[t-1],t=n(e)}else if(1==e.nodeType&&t<e.childNodes.length)e=e.childNodes[t],t=0;else return null}}function U(e,t,o,n){for(var r="",d=0,p=0;d<e.childCount;d++){var a=e.child(d),s=p+a.nodeSize;if(!a.isText)r="";else if(r+=a.text,s>=n){for(var l=s-r.length,c=r.lastIndexOf(t);-1<c&&l+c>o;)c=r.lastIndexOf(t,c-1);if(-1<c&&l+c+t.length>=n)return l+c;if(s>n)break}p=s}return-1}function G(e,t,o,n,r){for(var d=[],p=0,a=0;p<e.length;p++){var s=e[p],l=a,c=a+=s.size;l>=o||c<=t?d.push(s):(l<t&&d.push(s.slice(0,t-l,n)),r&&(d.push(r),r=null),c>o&&d.push(s.slice(o-l,s.size,n)))}return d}function X(e,t){var o=e.selection,n=o.$anchor,r=o.$head,d=0<t?n.max(r):n.min(r),i=d.parent.inlineContent?d.depth?e.doc.resolve(0<t?d.after():d.before()):null:d;return i&&q.Selection.findFrom(i,t)}function Q(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function Y(e,t,o){var n=e.state.selection;if(n instanceof q.TextSelection){if(!n.empty||-1<o.indexOf("s"))return!1;if(e.endOfTextblock(0<t?"right":"left")){var r=X(e.state,t);return!!(r&&r instanceof q.NodeSelection)&&Q(e,r)}var d=n.$head,i=d.textOffset?null:0>t?d.nodeBefore:d.nodeAfter,p;if(!i||i.isText)return!1;var a=0>t?d.pos-i.nodeSize:d.pos;return!!(i.isAtom||(p=e.docView.descAt(a))&&!p.contentDOM)&&(q.NodeSelection.isSelectable(i)?Q(e,new q.NodeSelection(0>t?e.state.doc.resolve(d.pos-i.nodeSize):d)):!!It.webkit&&Q(e,new q.TextSelection(e.state.doc.resolve(0>t?a:a+i.nodeSize))))}if(n instanceof q.NodeSelection&&n.node.isInline)return Q(e,new q.TextSelection(0<t?n.$to:n.$from));var s=X(e.state,t);return!!s&&Q(e,s)}function Z(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function ee(e){var t=e.pmViewDesc;return t&&0==t.size&&(e.nextSibling||"BR"!=e.nodeName)}function te(e){var t=e.root.getSelection(),o=t.focusNode,n=t.focusOffset;if(o){var r=!1,d,i;for(It.gecko&&1==o.nodeType&&n<Z(o)&&ee(o.childNodes[n])&&(r=!0);;)if(0<n){if(1!=o.nodeType)break;else{var p=o.childNodes[n-1];if(ee(p))d=o,i=--n;else if(3==p.nodeType)o=p,n=o.nodeValue.length;else break}}else if(ne(o))break;else{for(var a=o.previousSibling;a&&ee(a);)d=o.parentNode,i=Ft(a),a=a.previousSibling;if(!a){if(o=o.parentNode,o==e.dom)break;n=0}else o=a,n=Z(o)}r?re(e,t,o,n):d&&re(e,t,d,i)}}function oe(e){var t=e.root.getSelection(),o=t.focusNode,n=t.focusOffset;if(o){for(var r=Z(o),d,i;;)if(n<r){if(1!=o.nodeType)break;var p=o.childNodes[n];if(ee(p))d=o,i=++n;else break}else if(ne(o))break;else{for(var a=o.nextSibling;a&&ee(a);)d=a.parentNode,i=Ft(a)+1,a=a.nextSibling;if(!a){if(o=o.parentNode,o==e.dom)break;n=r=0}else o=a,n=0,r=Z(o)}d&&re(e,t,d,i)}}function ne(e){var t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function re(e,t,o,n){if(Jt(t)){var r=document.createRange();r.setEnd(o,n),r.setStart(o,n),t.removeAllRanges(),t.addRange(r)}else t.extend&&t.extend(o,n);e.domObserver.setCurSelection()}function de(e,t,o){var n=e.state.selection;if(n instanceof q.TextSelection&&!n.empty||-1<o.indexOf("s"))return!1;var r=n.$from,d=n.$to;if(!r.parent.inlineContent||e.endOfTextblock(0>t?"up":"down")){var i=X(e.state,t);if(i&&i instanceof q.NodeSelection)return Q(e,i)}if(!r.parent.inlineContent){var p=q.Selection.findFrom(0>t?r:d,t);return!p||Q(e,p)}return!1}function pe(e,t){if(!(e.state.selection instanceof q.TextSelection))return!0;var o=e.state.selection,n=o.$head,r=o.$anchor,d=o.empty;if(!n.sameParent(r))return!0;if(!d)return!1;if(e.endOfTextblock(0<t?"forward":"backward"))return!0;var i=!n.textOffset&&(0>t?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){var p=e.state.tr;return 0>t?p.delete(n.pos-i.nodeSize,n.pos):p.delete(n.pos,n.pos+i.nodeSize),e.dispatch(p),!0}return!1}function ae(e,t,o){e.domObserver.stop(),t.contentEditable=o,e.domObserver.start()}function se(e){if(It.chrome&&!(0<e.state.selection.$head.parentOffset)){var t=e.root.getSelection(),o=t.focusNode,n=t.focusOffset;if(o&&1==o.nodeType&&0==n&&o.firstChild&&"false"==o.firstChild.contentEditable){var r=o.firstChild;ae(e,r,!0),setTimeout(function(){return ae(e,r,!1)},20)}}}function le(e){var t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}function ce(e,t){var o=t.keyCode,n=le(t);return 8==o||It.mac&&72==o&&"c"==n?pe(e,-1)||te(e):46==o||It.mac&&68==o&&"c"==n?pe(e,1)||oe(e):13==o||27==o||(37==o?Y(e,-1,n)||te(e):39==o?Y(e,1,n)||oe(e):38==o?de(e,-1,n)||te(e):40==o?se(e)||de(e,1,n)||oe(e):n==(It.mac?"m":"c")&&(66==o||73==o||89==o||90==o))}function he(e,t){var o=e.root.getSelection(),n=e.state.doc,r=e.docView.nearestDesc(o.focusNode),d=r&&0==r.size,i=e.docView.posFromDOM(o.focusNode,o.focusOffset),p=n.resolve(i),a,s;if(Jt(o)){for(a=p;r&&!r.node;)r=r.parent;if(r&&r.node.isAtom&&q.NodeSelection.isSelectable(r.node)&&r.parent){var l=r.posBefore;s=new q.NodeSelection(i==l?p:n.resolve(l))}}else a=n.resolve(e.docView.posFromDOM(o.anchorNode,o.anchorOffset));if(!s){var c="pointer"==t||e.state.selection.head<p.pos&&!d?1:-1;s=Ce(e,a,p,c)}return s}function me(e,t,o){var n=e.state.selection;if(ye(e,n),e.editable&&!e.hasFocus()){if(!t)return;It.gecko&&55>=It.gecko_version&&(e.domObserver.disconnectSelection(),e.dom.focus(),e.domObserver.connectSelection())}else if(!e.editable&&!(be(e)&&document.activeElement.contains(e.dom))&&!t)return;if(e.domObserver.disconnectSelection(),e.cursorWrapper)ue(e);else{var r=n.anchor,d=n.head,i,p;so&&!(n instanceof q.TextSelection)&&(!n.$from.parent.inlineContent&&(i=fe(e,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(p=fe(e,n.to))),e.docView.setSelection(r,d,e.root,o),so&&(i&&(i.contentEditable="false"),p&&(p.contentEditable="false")),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):r!=d&&(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&ge(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}function fe(e,t){var o=e.docView.domFromPos(t),n=o.node,r=o.offset,d=r<n.childNodes.length?n.childNodes[r]:null,i=r?n.childNodes[r-1]:null;if((!d||"false"==d.contentEditable)&&(!i||"false"==i.contentEditable)){if(d)return d.contentEditable="true",d;if(i)return i.contentEditable="true",i}}function ge(e){var t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.hideSelectionGuard);var o=e.root.getSelection(),n=o.anchorNode,r=o.anchorOffset;t.addEventListener("selectionchange",e.hideSelectionGuard=function(){(o.anchorNode!=n||o.anchorOffset!=r)&&(t.removeEventListener("selectionchange",e.hideSelectionGuard),e.dom.classList.remove("ProseMirror-hideselection"))})}function ue(e){var t=e.root.getSelection(),o=document.createRange(),n=e.cursorWrapper.dom,r="IMG"==n.nodeName;r?o.setEnd(n.parentNode,Ft(n)+1):o.setEnd(n,0),o.collapse(!1),t.removeAllRanges(),t.addRange(o),!r&&!e.state.selection.visible&&It.ie&&11>=It.ie_version&&(n.disabled=!0,n.disabled=!1)}function ye(e,t){if(t instanceof q.NodeSelection){var o=e.docView.descAt(t.from);o!=e.lastSelectedViewDesc&&(Se(e),o&&o.selectNode(),e.lastSelectedViewDesc=o)}else Se(e)}function Se(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=null)}function Ce(e,t,o,n){return e.someProp("createSelectionBetween",function(n){return n(e,t,o)})||q.TextSelection.between(t,o,n)}function ve(e){return!(e.editable&&e.root.activeElement!=e.dom)&&be(e)}function be(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 we(e){var t=e.docView.domFromPos(e.state.selection.anchor),o=e.root.getSelection();return Vt(t.node,t.offset,o.anchorNode,o.anchorOffset)}function xe(e,t,o){var n=e.docView.parseRange(t,o),r=n.node,d=n.fromOffset,i=n.toOffset,p=n.from,a=n.to,s=e.root.getSelection(),l=null,c=s.anchorNode;if(c&&e.dom.contains(1==c.nodeType?c:c.parentNode)&&(l=[{node:c,offset:s.anchorOffset}],!Jt(s)&&l.push({node:s.focusNode,offset:s.focusOffset})),It.chrome&&8===e.lastKeyCode)for(var m=i;m>d;m--){var f=r.childNodes[m-1],g=f.pmViewDesc;if("BR"==f.nodeType&&!g){i=m;break}if(!g||g.size)break}var u=e.state.doc,y=e.someProp("domParser")||h.DOMParser.fromSchema(e.state.schema),S=u.resolve(p),C=null,v=y.parse(r,{topNode:S.parent,topMatch:S.parent.contentMatchAt(S.index()),topOpen:!0,from:d,to:i,preserveWhitespace:!S.parent.type.spec.code||"full",editableContent:!0,findPositions:l,ruleFromNode:ke(y,S),context:S});if(l&&null!=l[0].pos){var b=l[0].pos,w=l[1]&&l[1].pos;null==w&&(w=b),C={anchor:b+p,head:w+p}}return{doc:v,sel:C,from:p,to:a}}function ke(e,t){return function(o){var n=o.pmViewDesc;if(n)return n.parseRule();if("BR"==o.nodeName&&o.parentNode){if(It.safari&&/^(ul|ol)$/i.test(o.parentNode.nodeName))return e.matchTag(document.createElement("li"),t);if(o.parentNode.lastChild==o||It.safari&&/^(tr|table)$/i.test(o.parentNode.nodeName))return{ignore:!0}}else if("IMG"==o.nodeName&&o.getAttribute("mark-placeholder"))return{ignore:!0}}}function Me(e,t,o,n){if(0>t){var r=e.lastSelectionTime>Date.now()-50?e.lastSelectionOrigin:null,d=he(e,r);if(!e.state.selection.eq(d)){var p=e.state.tr.setSelection(d);"pointer"==r?p.setMeta("pointer",!0):"key"==r&&p.scrollIntoView(),e.dispatch(p)}return}var a=e.state.doc.resolve(t),s=a.sharedDepth(o);t=a.before(s+1),o=e.state.doc.resolve(o).after(s+1);var l=e.state.selection,c=xe(e,t,o),h=e.state.doc,m=h.slice(c.from,c.to),f,g;8===e.lastKeyCode&&Date.now()-100<e.lastKeyCodeTime?(f=e.state.selection.to,g="end"):(f=e.state.selection.from,g="start"),e.lastKeyCode=null;var u=De(m.content,c.doc.content,c.from,f,g);if(!u){if(n&&l instanceof q.TextSelection&&!l.empty&&l.$head.sameParent(l.$anchor)&&!e.composing&&!(c.sel&&c.sel.anchor!=c.sel.head)){var y=e.state,S=y.selection;e.dispatch(y.tr.replaceSelectionWith(y.schema.text(y.doc.textBetween(S.from,S.to)),!0).scrollIntoView())}else if(c.sel){var C=Te(e,e.state.doc,c.sel);C&&!C.eq(e.state.selection)&&e.dispatch(e.state.tr.setSelection(C))}return}e.domChangeCount++,e.state.selection.from<e.state.selection.to&&u.start==u.endB&&e.state.selection instanceof q.TextSelection&&(u.start>e.state.selection.from&&u.start<=e.state.selection.from+2?u.start=e.state.selection.from:u.endA<e.state.selection.to&&u.endA>=e.state.selection.to-2&&(u.endB+=e.state.selection.to-u.endA,u.endA=e.state.selection.to));var v=c.doc.resolveNoCache(u.start-c.from),b=c.doc.resolveNoCache(u.endB-c.from),w;if(!(!v.sameParent(b)&&v.pos<c.doc.content.size&&(w=q.Selection.findFrom(c.doc.resolve(v.pos+1),1,!0))&&w.head==b.pos&&e.someProp("handleKeyDown",function(t){return t(e,i(13,"Enter"))}))){if(e.state.selection.anchor>u.start&&Oe(h,u.start,u.endA,v,b)&&e.someProp("handleKeyDown",function(t){return t(e,i(8,"Backspace"))}))return void(It.android&&It.chrome&&e.domObserver.suppressSelectionUpdates());var x=u.start,k=u.endA,M,T,N,O;if(v.sameParent(b)&&v.parent.inlineContent)if(v.pos==b.pos)It.ie&&11>=It.ie_version&&0==v.parentOffset&&(e.domObserver.suppressSelectionUpdates(),setTimeout(function(){return me(e)},20)),M=e.state.tr.delete(x,k),T=h.resolve(u.start).marksAcross(h.resolve(u.endA));else if(u.endA==u.endB&&(O=h.resolve(u.start))&&(N=Ne(v.parent.content.cut(v.parentOffset,b.parentOffset),O.parent.content.cut(O.parentOffset,u.endA-O.start()))))M=e.state.tr,"add"==N.type?M.addMark(x,k,N.mark):M.removeMark(x,k,N.mark);else if(v.parent.child(v.index()).isText&&v.index()==b.index()-(b.textOffset?0:1)){var A=v.parent.textBetween(v.parentOffset,b.parentOffset);if(e.someProp("handleTextInput",function(t){return t(e,x,k,A)}))return;M=e.state.tr.insertText(A,x,k)}if(M||(M=e.state.tr.replace(x,k,c.doc.slice(u.start-c.from,u.endB-c.from))),c.sel){var D=Te(e,M.doc,c.sel);D&&M.setSelection(D)}T&&M.ensureMarks(T),e.dispatch(M.scrollIntoView())}}function Te(e,t,o){return s(o.anchor,o.head)>t.content.size?null:Ce(e,t.resolve(o.anchor),t.resolve(o.head))}function Ne(e,t){for(var o=e.firstChild.marks,n=t.firstChild.marks,r=o,d=n,p=0,a,s,l;p<n.length;p++)r=n[p].removeFromSet(r);for(var c=0;c<o.length;c++)d=o[c].removeFromSet(d);if(1==r.length&&0==d.length)s=r[0],a="add",l=function(e){return e.mark(s.addToSet(e.marks))};else if(0==r.length&&1==d.length)s=d[0],a="remove",l=function(e){return e.mark(s.removeFromSet(e.marks))};else return null;for(var m=[],f=0;f<t.childCount;f++)m.push(l(t.child(f)));if(h.Fragment.from(m).eq(e))return{mark:s,type:a}}function Oe(e,t,o,n,r){if(!n.parent.isTextblock||o-t<=r.pos-n.pos||Ae(n,!0,!1)<r.pos)return!1;var d=e.resolve(t);if(d.parentOffset<d.parent.content.size||!d.parent.isTextblock)return!1;var i=e.resolve(Ae(d,!0,!0));return!(!i.parent.isTextblock||i.pos>o||Ae(i,!0,!1)<o)&&n.parent.content.cut(n.parentOffset).eq(i.parent.content)}function Ae(e,t,o){for(var n=e.depth,r=t?e.end():e.pos;0<n&&(t||e.indexAfter(n)==e.node(n).childCount);)n--,r++,t=!1;if(o)for(var d=e.node(n).maybeChild(e.indexAfter(n));d&&!d.isLeaf;)d=d.firstChild,r++;return r}function De(e,t,o,n,r){var d=e.findDiffStart(t,o);if(null==d)return null;var i=e.findDiffEnd(t,o+e.size,o+t.size),p=i.a,a=i.b;if("end"==r){var c=s(0,d-l(p,a));n-=p+c-d}if(p<d&&e.size<t.size){var h=n<=d&&n>=p?d-n:0;d-=h,a=d+(a-p),p=d}else if(a<d){var m=n<=d&&n>=a?d-n:0;d-=m,p=d+(p-a),a=d}return{start:d,endA:p,endB:a}}function Re(e,t){for(var o=[],n=t.content,r=t.openStart,d=t.openEnd;1<r&&1<d&&1==n.childCount&&1==n.firstChild.childCount;){r--,d--;var p=n.firstChild;o.push(p.type.name,p.type.hasRequiredAttrs()?p.attrs:null),n=p.content}var a=e.someProp("clipboardSerializer")||h.DOMSerializer.fromSchema(e.state.schema),s=_e(),l=s.createElement("div");l.appendChild(a.serializeFragment(n,{document:s}));for(var c=l.firstChild,m;c&&1==c.nodeType&&(m=lo[c.nodeName.toLowerCase()]);){for(var f=m.length-1,g;0<=f;f--){for(g=s.createElement(m[f]);l.firstChild;)g.appendChild(l.firstChild);l.appendChild(g)}c=l.firstChild}c&&1==c.nodeType&&c.setAttribute("data-pm-slice",r+" "+d+" "+JSON.stringify(o));var u=e.someProp("clipboardTextSerializer",function(e){return e(t)})||t.content.textBetween(0,t.content.size,"\n\n");return{dom:l,text:u}}function Ie(e,t,o,n,r){var d=r.parent.type.spec.code,i,p;if(!o&&!t)return null;var a=t&&(n||d||!o);if(a){if(e.someProp("transformPastedText",function(e){t=e(t)}),d)return new h.Slice(h.Fragment.from(e.state.schema.text(t)),0,0);var s=e.someProp("clipboardTextParser",function(e){return e(t,r)});s?p=s:(i=document.createElement("div"),t.trim().split(/(?:\r\n?|\n)+/).forEach(function(e){i.appendChild(document.createElement("p")).textContent=e}))}else e.someProp("transformPastedHTML",function(e){o=e(o)}),i=Ve(o);var l=i&&i.querySelector("[data-pm-slice]"),c=l&&/^(\d+) (\d+) (.*)/.exec(l.getAttribute("data-pm-slice"));if(!p){var m=e.someProp("clipboardParser")||e.someProp("domParser")||h.DOMParser.fromSchema(e.state.schema);p=m.parseSlice(i,{preserveWhitespace:!!(a||c),context:r})}return p=c?Le(Be(p,+c[1],+c[2]),c[3]):h.Slice.maxOpen(Pe(p.content,r),!1),e.someProp("transformPasted",function(e){p=e(p)}),p}function Pe(e,t){if(2>e.childCount)return e;for(var o=function(o){var n=t.node(o),r=n.contentMatchAt(t.index(o)),d=void 0,i=[];return e.forEach(function(e){var t=r.findWrapping(e.type),o;if(!t)return i=null;if(o=i.length&&d.length&&$e(t,d,e,i[i.length-1],0))i[i.length-1]=o;else{i.length&&(i[i.length-1]=ze(i[i.length-1],d.length));var n=Ee(e,t);i.push(n),r=r.matchType(n.type,n.attrs),d=t}}),{v:h.Fragment.from(i)}},n=t.depth,r;0<=n;n--)if(r=o(n),r)return r.v;return e}function Ee(e,t,o){void 0===o&&(o=0);for(var n=t.length-1;n>=o;n--)e=t[n].create(null,h.Fragment.from(e));return e}function $e(e,t,o,n,r){if(r<e.length&&r<t.length&&e[r]==t[r]){var d=$e(e,t,o,n.lastChild,r+1);if(d)return n.copy(n.content.replaceChild(n.childCount-1,d));var i=n.contentMatchAt(n.childCount);if(i.matchType(r==e.length-1?o.type:e[r+1]))return n.copy(n.content.append(h.Fragment.from(Ee(o,e,r+1))))}}function ze(e,t){if(0==t)return e;var o=e.content.replaceChild(e.childCount-1,ze(e.lastChild,t-1)),n=e.contentMatchAt(e.childCount).fillBefore(h.Fragment.empty,!0);return e.copy(o.append(n))}function Fe(e,t,o,n,r,d){var i=0>t?e.firstChild:e.lastChild,p=i.content;return r<n-1&&(p=Fe(p,t,o,n,r+1,d)),r>=o&&(p=0>t?i.contentMatchAt(0).fillBefore(p,1<e.childCount||d<=r).append(p):p.append(i.contentMatchAt(i.childCount).fillBefore(h.Fragment.empty,!0))),e.replaceChild(0>t?0:e.childCount-1,i.copy(p))}function Be(e,t,o){return t<e.openStart&&(e=new h.Slice(Fe(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),o<e.openEnd&&(e=new h.Slice(Fe(e.content,1,o,e.openEnd,0,0),e.openStart,o)),e}function _e(){return co||(co=document.implementation.createHTMLDocument("title"))}function Ve(e){var t=/(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));var o=_e().createElement("div"),n=/(?:<meta [^>]*>)*<([a-z][^>\s]+)/i.exec(e),r=0,d;(d=n&&lo[n[1].toLowerCase()])&&(e=d.map(function(e){return"<"+e+">"}).join("")+e+d.map(function(e){return"</"+e+">"}).reverse().join(""),r=d.length),o.innerHTML=e;for(var p=0;p<r;p++)o=o.firstChild;return o}function Le(t,o){if(!t.size)return t;var n=t.content.firstChild.type.schema,r;try{r=JSON.parse(o)}catch(o){return t}for(var d=t.content,p=t.openStart,a=t.openEnd,s=r.length-2,e;0<=s&&(e=n.nodes[r[s]],e&&!e.hasRequiredAttrs());s-=2)d=h.Fragment.from(e.create(r[s+1],d)),p++,a++;return new h.Slice(d,p,a)}function Je(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.composing=!1,e.composingTimeout=null,e.compositionNodes=[],e.compositionEndedAt=-2e8,e.domObserver=new go(e,function(t,o,n){return Me(e,t,o,n)}),e.domObserver.start(),e.domChangeCount=0,e.eventHandlers=Object.create(null);var t=function(t){var o=uo[t];e.dom.addEventListener(t,e.eventHandlers[t]=function(t){He(e,t)&&!qe(e,t)&&(e.editable||!(t.type in yo))&&o(e,t)})};for(var o in uo)t(o);It.safari&&e.dom.addEventListener("input",function(){return null}),Ke(e)}function We(e,t){e.lastSelectionOrigin=t,e.lastSelectionTime=Date.now()}function je(e){for(var t in e.domObserver.stop(),e.eventHandlers)e.dom.removeEventListener(t,e.eventHandlers[t]);clearTimeout(e.composingTimeout)}function Ke(e){e.someProp("handleDOMEvents",function(t){for(var o in t)e.eventHandlers[o]||e.dom.addEventListener(o,e.eventHandlers[o]=function(t){return qe(e,t)})})}function qe(e,t){return e.someProp("handleDOMEvents",function(o){var n=o[t.type];return!!n&&(n(e,t)||t.defaultPrevented)})}function He(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(var o=t.target;o!=e.dom;o=o.parentNode)if(!o||11==o.nodeType||o.pmViewDesc&&o.pmViewDesc.stopEvent(t))return!1;return!0}function Ue(e,t){!qe(e,t)&&uo[t.type]&&(e.editable||!(t.type in yo))&&uo[t.type](e,t)}function Ge(e){return{left:e.clientX,top:e.clientY}}function Xe(e,t){var o=t.x-e.clientX,n=t.y-e.clientY;return 100>o*o+n*n}function Qe(e,t,o,n,r){if(-1==n)return!1;for(var d=e.state.doc.resolve(n),p=function(n){if(e.someProp(t,function(t){return n>d.depth?t(e,o,d.nodeAfter,d.before(n),r,!0):t(e,o,d.node(n),d.before(n),r,!1)}))return{v:!0}},a=d.depth+1,s;0<a;a--)if(s=p(a),s)return s.v;return!1}function Ye(e,t,o){e.focused||e.focus();var n=e.state.tr.setSelection(t);"pointer"==o&&n.setMeta("pointer",!0),e.dispatch(n)}function Ze(e,t){if(-1==t)return!1;var o=e.state.doc.resolve(t),n=o.nodeAfter;return!!(n&&n.isAtom&&q.NodeSelection.isSelectable(n))&&(Ye(e,new q.NodeSelection(o),"pointer"),!0)}function et(e,t){if(-1==t)return!1;var o=e.state.selection,n,r;o instanceof q.NodeSelection&&(n=o.node);for(var d=e.state.doc.resolve(t),p=d.depth+1,a;0<p;p--)if(a=p>d.depth?d.nodeAfter:d.node(p),q.NodeSelection.isSelectable(a)){r=n&&0<o.$from.depth&&p>=o.$from.depth&&d.before(o.$from.depth+1)==o.$from.pos?d.before(o.$from.depth):d.before(p);break}return null!=r&&(Ye(e,q.NodeSelection.create(e.state.doc,r),"pointer"),!0)}function tt(e,t,o,n,r){return Qe(e,"handleClickOn",t,o,n)||e.someProp("handleClick",function(o){return o(e,t,n)})||(r?et(e,o):Ze(e,o))}function ot(e,t,o,n){return Qe(e,"handleDoubleClickOn",t,o,n)||e.someProp("handleDoubleClick",function(o){return o(e,t,n)})}function nt(e,t,o,n){return Qe(e,"handleTripleClickOn",t,o,n)||e.someProp("handleTripleClick",function(o){return o(e,t,n)})||rt(e,o)}function rt(e,t){var o=e.state.doc;if(-1==t)return!!o.inlineContent&&(Ye(e,q.TextSelection.create(o,0,o.content.size),"pointer"),!0);for(var n=o.resolve(t),r=n.depth+1;0<r;r--){var d=r>n.depth?n.nodeAfter:n.node(r),p=n.before(r);if(d.inlineContent)Ye(e,q.TextSelection.create(o,p+1,p+1+d.content.size),"pointer");else if(q.NodeSelection.isSelectable(d))Ye(e,q.NodeSelection.create(o,p),"pointer");else continue;return!0}}function dt(e){return at(e)}function it(e,t){return!!e.composing||!!(It.safari&&500>Rt(t.timeStamp-e.compositionEndedAt))&&(e.compositionEndedAt=-2e8,!0)}function pt(e,t){clearTimeout(e.composingTimeout),-1<t&&(e.composingTimeout=setTimeout(function(){return at(e)},t))}function at(e,t){for(e.composing=!1;0<e.compositionNodes.length;)e.compositionNodes.pop().markParentsDirty();return!!(t||e.docView.dirty)&&(e.updateState(e.state),!0)}function st(e,t){var o=t.ownerDocument,n=o.body.appendChild(o.createElement("div"));n.appendChild(t),n.style.cssText="position: fixed; left: -10000px; top: 10px";var r=getSelection(),d=o.createRange();d.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(d),setTimeout(function(){o.body.removeChild(n),e.focus()},50)}function lt(e){return 0==e.openStart&&0==e.openEnd&&1==e.content.childCount?e.content.firstChild:null}function ct(t,o){var e=t.dom.ownerDocument,n=t.shiftKey||t.state.selection.$from.parent.type.spec.code,r=e.body.appendChild(e.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus(),setTimeout(function(){t.focus(),e.body.removeChild(r),n?ht(t,r.value,null,o):ht(t,r.textContent,r.innerHTML,o)},50)}function ht(t,o,n,r){var e=Ie(t,o,n,t.shiftKey,t.state.selection.$from);if(t.someProp("handlePaste",function(o){return o(t,r,e||h.Slice.empty)})||!e)return!0;var d=lt(e),i=d?t.state.tr.replaceSelectionWith(d,t.shiftKey):t.state.tr.replaceSelection(e);return t.dispatch(i.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function mt(e,t){if(e==t)return!0;for(var o in e)if(e[o]!==t[o])return!1;for(var n in t)if(!(n in e))return!1;return!0}function ft(e,t,o,n,r,d,p){for(var a=e.slice(),s=function(e,t,o,n){for(var p=0;p<a.length;p+=3){var s=a[p+1],l=void 0;-1==s||e>s+d||(t>=a[p]+d?a[p+1]=-1:(l=n-o-(t-e)+(d-r))&&(a[p]+=l,a[p+1]+=l))}},l=0;l<o.maps.length;l++)o.maps[l].forEach(s);for(var c=!1,h=0;h<a.length;h+=3)if(-1==a[h+1]){var m=o.map(a[h]+d),f=m-r;if(0>f||f>=n.content.size){c=!0;continue}var g=o.map(e[h+1]+d,-1),u=g-r,y=n.content.findIndex(f),S=y.index,C=y.offset,v=n.maybeChild(S);if(v&&C==f&&C+v.nodeSize==u){var b=a[h+2].mapInner(o,v,m+1,a[h]+d+1,p);b==Po?(a[h+1]=-2,c=!0):(a[h]=f,a[h+1]=u,a[h+2]=b)}else c=!0}if(c){var w=ut(a,e,t||[],o,r,d,p),x=Ct(w,n,0,p);t=x.local;for(var k=0;k<a.length;k+=3)0>a[k+1]&&(a.splice(k,3),k-=3);for(var M=0,T=0,N;M<x.children.length;M+=3){for(N=x.children[M];T<a.length&&a[T]<N;)T+=3;a.splice(T,0,x.children[M],x.children[M+1],x.children[M+2])}}return new Io(t&&t.sort(vt),a)}function gt(e,t){if(!t||!e.length)return e;for(var o=[],n=0,r;n<e.length;n++)r=e[n],o.push(new Oo(r.from+t,r.to+t,r.type));return o}function ut(e,t,o,n,r,d,p){function a(e,t){for(var d=0,s;d<e.local.length;d++)s=e.local[d].map(n,r,t),s?o.push(s):p.onRemove&&p.onRemove(e.local[d].spec);for(var l=0;l<e.children.length;l+=3)a(e.children[l+2],e.children[l]+t+1)}for(var s=0;s<e.length;s+=3)-1==e[s+1]&&a(e[s+2],t[s]+d+1);return o}function yt(e,t,o){if(t.isLeaf)return null;for(var n=o+t.nodeSize,r=null,d=0,p=void 0;d<e.length;d++)(p=e[d])&&p.from>o&&p.to<n&&((r||(r=[])).push(p),e[d]=null);return r}function St(e){for(var t=[],o=0;o<e.length;o++)null!=e[o]&&t.push(e[o]);return t}function Ct(e,t,o,n){var r=[],d=!1;t.forEach(function(t,i){var p=yt(e,t,i+o);if(p){d=!0;var a=Ct(p,t,o+i+1,n);a!=Po&&r.push(i,i+t.nodeSize,a)}});for(var p=gt(d?St(e):e,-o).sort(vt),a=0;a<p.length;a++)p[a].type.valid(t,p[a])||(n.onRemove&&n.onRemove(p[a].spec),p.splice(a--,1));return p.length||r.length?new Io(p,r):Po}function vt(e,t){return e.from-t.from||e.to-t.to}function bt(e){for(var t=e,o=0,n;o<t.length-1;o++)if(n=t[o],n.from!=n.to)for(var r=o+1,d;r<t.length;r++)if(d=t[r],d.from==n.from){d.to!=n.to&&(t==e&&(t=e.slice()),t[r]=d.copy(d.from,n.to),wt(t,r+1,d.copy(n.to,d.to)));continue}else{d.from<n.to&&(t==e&&(t=e.slice()),t[o]=n.copy(n.from,d.from),wt(t,r,n.copy(d.from,n.to)));break}return t}function wt(e,t,o){for(;t<e.length&&0<vt(o,e[t]);)t++;e.splice(t,0,o)}function xt(e){var t=[];return e.someProp("decorations",function(o){var n=o(e.state);n&&n!=Po&&t.push(n)}),e.cursorWrapper&&t.push(Io.create(e.state.doc,[e.cursorWrapper.deco])),Eo.from(t)}function kt(e){var t=Object.create(null);return t.class="ProseMirror",t.contenteditable=e.editable+"",e.someProp("attributes",function(o){if("function"==typeof o&&(o=o(e.state)),o)for(var n in o)"class"==n?t.class+=" "+o[n]:t[n]||"contenteditable"==n||"nodeName"==n||(t[n]=o[n]+"")}),[Oo.node(0,e.state.doc.content.size,t)]}function Mt(e){var t=e.state.selection,o=t.$head,n=t.$anchor,r=t.visible;if(e.markCursor){var d=document.createElement("img");d.setAttribute("mark-placeholder","true"),e.cursorWrapper={dom:d,deco:Oo.widget(o.pos,d,{raw:!0,marks:e.markCursor})}}else if(r||o.pos!=n.pos)e.cursorWrapper=null;else{var i;!e.cursorWrapper||e.cursorWrapper.dom.childNodes.length?(i=document.createElement("div"),i.style.position="absolute",i.style.left="-100000px"):e.cursorWrapper.deco.pos!=o.pos&&(i=e.cursorWrapper.dom),i&&(e.cursorWrapper={dom:i,deco:Oo.widget(o.pos,i,{raw:!0})})}}function Tt(e){return!e.someProp("editable",function(t){return!1===t(e.state)})}function Nt(e){var t=e.getSelection(),o=t.focusOffset,n=t.focusNode;return n&&3!=n.nodeType?[n,o,1==n.nodeType?n.childNodes[o-1]:null,1==n.nodeType?n.childNodes[o]:null]:null}function Ot(e,t){var o=Nt(t);if(!o||3==o[0].nodeType)return!1;for(var n=0;n<e.length;n++)if(o[n]!=e[n])return!0;return!1}function At(e){var t={};return e.someProp("nodeViews",function(e){for(var o in e)Object.prototype.hasOwnProperty.call(t,o)||(t[o]=e[o])}),t}function Dt(e,t){var o=0,n=0;for(var r in e){if(e[r]!=t[r])return!0;o++}for(var d in t)n++;return o!=n}Object.defineProperty(t,"__esModule",{value:!0});var It={};if("undefined"!=typeof navigator&&"undefined"!=typeof document){var Pt=/Edge\/(\d+)/.exec(navigator.userAgent),Et=/MSIE \d/.test(navigator.userAgent),$t=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);It.mac=/Mac/.test(navigator.platform);var zt=It.ie=!!(Et||$t||Pt);It.ie_version=Et?document.documentMode||6:$t?+$t[1]:Pt?+Pt[1]:null,It.gecko=!zt&&/gecko\/(\d+)/i.test(navigator.userAgent),It.gecko_version=It.gecko&&+(/Firefox\/(\d+)/.exec(navigator.userAgent)||[0,0])[1];var ie=!zt&&/Chrome\/(\d+)/.exec(navigator.userAgent);It.chrome=!!ie,It.chrome_version=ie&&+ie[1],It.ios=!zt&&/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent),It.android=/Android \d/.test(navigator.userAgent),It.webkit=!zt&&"WebkitAppearance"in document.documentElement.style,It.safari=/Apple Computer/.test(navigator.vendor),It.webkit_version=It.webkit&&+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]}var Ft=function(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t},Bt=function(e){var t=e.parentNode;return t&&11==t.nodeType?t.host:t},_t=function(e,t,o){var n=document.createRange();return n.setEnd(e,null==o?e.nodeValue.length:o),n.setStart(e,t||0),n},Vt=function(e,t,n,r){return n&&(o(e,t,n,r,-1)||o(e,t,n,r,1))},Lt=/^(img|br|input|textarea|hr)$/i,Jt=function(e){var t=e.isCollapsed;return t&&It.chrome&&e.rangeCount&&!e.getRangeAt(0).collapsed&&(t=!1),t},Wt=/[\u0590-\u08ac]/,jt=null,Kt=null,qt=!1,Ht=0,Ut=2,Gt=3,Xt=function(e,t,o,n){this.parent=e,this.children=t,this.dom=o,o.pmViewDesc=this,this.contentDOM=n,this.dirty=Ht},Qt={beforePosition:{},size:{},border:{},posBefore:{},posAtStart:{},posAfter:{},posAtEnd:{},contentLost:{}};Xt.prototype.matchesWidget=function(){return!1},Xt.prototype.matchesMark=function(){return!1},Xt.prototype.matchesNode=function(){return!1},Xt.prototype.matchesHack=function(){return!1},Qt.beforePosition.get=function(){return!1},Xt.prototype.parseRule=function(){return null},Xt.prototype.stopEvent=function(){return!1},Qt.size.get=function(){for(var e=this,t=0,o=0;o<this.children.length;o++)t+=e.children[o].size;return t},Qt.border.get=function(){return 0},Xt.prototype.destroy=function(){var e=this;this.parent=null,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=null);for(var t=0;t<this.children.length;t++)e.children[t].destroy()},Xt.prototype.posBeforeChild=function(e){for(var t=this,o=0,n=this.posAtStart,r;o<this.children.length;o++){if(r=t.children[o],r==e)return n;n+=r.size}},Qt.posBefore.get=function(){return this.parent.posBeforeChild(this)},Qt.posAtStart.get=function(){return this.parent?this.parent.posBeforeChild(this)+this.border:0},Qt.posAfter.get=function(){return this.posBefore+this.size},Qt.posAtEnd.get=function(){return this.posAtStart+this.size-2*this.border},Xt.prototype.localPosFromDOM=function(e,t,o){var n=this;if(this.contentDOM&&this.contentDOM.contains(1==e.nodeType?e:e.parentNode)){if(0>o){var r,d;if(e==this.contentDOM)r=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;r=e.previousSibling}for(;r&&!((d=r.pmViewDesc)&&d.parent==this);)r=r.previousSibling;return r?this.posBeforeChild(d)+d.size:this.posAtStart}var i,p;if(e==this.contentDOM)i=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&!((p=i.pmViewDesc)&&p.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(p):this.posAtEnd}var a;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 s=e;;s=s.parentNode){if(s==n.dom){a=!1;break}if(s.parentNode.firstChild!=s)break}if(null==a&&t==e.childNodes.length)for(var l=e;;l=l.parentNode){if(l==n.dom){a=!0;break}if(l.parentNode.lastChild!=l)break}}return(null==a?0<o:a)?this.posAtEnd:this.posAtStart},Xt.prototype.nearestDesc=function(e,t){for(var o=this,n=!0,r=e,d;r;r=r.parentNode)if(d=o.getDesc(r),d&&(!t||d.node))if(n&&d.nodeDOM&&(1==d.nodeDOM.nodeType?!d.nodeDOM.contains(e):d.nodeDOM!=e))n=!1;else return d},Xt.prototype.getDesc=function(e){for(var t=this,o=e.pmViewDesc,n=o;n;n=n.parent)if(n==t)return o},Xt.prototype.posFromDOM=function(e,t,o){for(var n=this,r=e,d;;r=r.parentNode)if(d=n.getDesc(r),d)return d.localPosFromDOM(e,t,o)},Xt.prototype.descAt=function(e){for(var t=this,o=0,n=0;o<this.children.length;o++){var r=t.children[o],d=n+r.size;if(n==e&&d!=n){for(;!r.border&&r.children.length;)r=r.children[0];return r}if(e<d)return r.descAt(e-n-r.border);n=d}},Xt.prototype.domFromPos=function(e){var t=this;if(!this.contentDOM)return{node:this.dom,offset:0};for(var o=0,n=0;;n++){if(o==e){for(;n<this.children.length&&(this.children[n].beforePosition||this.children[n].dom.parentNode!=this.contentDOM);)n++;return{node:t.contentDOM,offset:n==t.children.length?t.contentDOM.childNodes.length:Ft(t.children[n].dom)}}if(n==t.children.length)throw new Error("Invalid position "+e);var r=t.children[n],d=o+r.size;if(e<d)return r.domFromPos(e-o-r.border);o=d}},Xt.prototype.parseRange=function(e,t,o){var n=this;if(void 0===o&&(o=0),0==this.children.length)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};for(var r=-1,d=-1,p=o,a=0;;a++){var s=n.children[a],l=p+s.size;if(-1==r&&e<=l){var c=p+s.border;if(e>=c&&t<=l-s.border&&s.node&&s.contentDOM&&n.contentDOM.contains(s.contentDOM))return s.parseRange(e,t,c);e=p;for(var h=a,m;0<h;h--){if(m=n.children[h-1],m.size&&m.dom.parentNode==n.contentDOM&&!m.emptyChildAt(1)){r=Ft(m.dom)+1;break}e-=m.size}-1==r&&(r=0)}if(-1<r&&t<=l){t=l;for(var f=a+1,g;f<this.children.length;f++){if(g=n.children[f],g.size&&g.dom.parentNode==n.contentDOM&&!g.emptyChildAt(-1)){d=Ft(g.dom);break}t+=g.size}-1==d&&(d=n.contentDOM.childNodes.length);break}p=l}return{node:this.contentDOM,from:e,to:t,fromOffset:r,toOffset:d}},Xt.prototype.emptyChildAt=function(e){if(this.border||!this.contentDOM||!this.children.length)return!1;var t=this.children[0>e?0:this.children.length-1];return 0==t.size||t.emptyChildAt(e)},Xt.prototype.domAfterPos=function(e){var t=this.domFromPos(e),o=t.node,n=t.offset;if(1!=o.nodeType||n==o.childNodes.length)throw new RangeError("No node after pos "+e);return o.childNodes[n]},Xt.prototype.setSelection=function(e,t,o,n){for(var r=this,d=l(e,t),p=s(e,t),a=0,c=0;a<this.children.length;a++){var h=r.children[a],m=c+h.size;if(d>c&&p<m)return h.setSelection(e-c-h.border,t-c-h.border,o,n);c=m}var f=this.domFromPos(e),g=this.domFromPos(t),u=o.getSelection(),y=document.createRange();if(!(!n&&Vt(f.node,f.offset,u.anchorNode,u.anchorOffset)&&Vt(g.node,g.offset,u.focusNode,u.focusOffset))){if(u.extend)y.setEnd(f.node,f.offset),y.collapse(!1);else{if(e>t){var S=f;f=g,g=S}y.setEnd(g.node,g.offset),y.setStart(f.node,f.offset)}u.removeAllRanges(),u.addRange(y),u.extend&&u.extend(g.node,g.offset)}},Xt.prototype.ignoreMutation=function(){return!this.contentDOM},Qt.contentLost.get=function(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)},Xt.prototype.markDirty=function(e,t){for(var o=this,n=0,r=0;r<this.children.length;r++){var d=o.children[r],p=n+d.size;if(n==p?e<=p&&t>=n:e<p&&t>n){var a=n+d.border,s=p-d.border;if(e>=a&&t<=s)return o.dirty=e==n||t==p?Ut:1,void(e==a&&t==s&&d.contentLost?d.dirty=Gt:d.markDirty(e-a,t-a));d.dirty=Gt}n=p}this.dirty=Ut},Xt.prototype.markParentsDirty=function(){for(var e=this.parent,t;e;e=e.parent)t=Ut,e.dirty<t&&(e.dirty=t)},Object.defineProperties(Xt.prototype,Qt);var Yt=[],Zt=function(e){function t(t,o,n,r){var d=o.type.toDOM,i;if("function"==typeof d&&(d=d(n,function(){return i?i.parent?i.parent.posBeforeChild(i):void 0:r})),!o.type.spec.raw){if(1!=d.nodeType){var p=document.createElement("span");p.appendChild(d),d=p}d.contentEditable=!1,d.classList.add("ProseMirror-widget")}e.call(this,t,Yt,d,null),this.widget=o,i=this}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var o={beforePosition:{}};return o.beforePosition.get=function(){return 0>this.widget.type.side},t.prototype.matchesWidget=function(e){return this.dirty==Ht&&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)},Object.defineProperties(t.prototype,o),t}(Xt),eo=function(e){function t(t,o,n,r){e.call(this,t,Yt,o,null),this.textDOM=n,this.text=r}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var o={size:{}};return o.size.get=function(){return this.text.length},t.prototype.localPosFromDOM=function(e,t){return e==this.textDOM?this.posAtStart+t:this.posAtStart+(t?this.size:0)},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,o),t}(Xt),to=function(e){function t(t,o,n,r){e.call(this,t,[],n,r),this.mark=o}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.create=function(e,o,n,r){var d=r.nodeViews[o.type.name],i=d&&d(o,r,n);return i&&i.dom||(i=h.DOMSerializer.renderSpec(document,o.type.spec.toDOM(o,n))),new t(e,o,i.dom,i.contentDOM||i.dom)},t.prototype.parseRule=function(){return{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}},t.prototype.matchesMark=function(e){return this.dirty!=Gt&&this.mark.eq(e)},t.prototype.markDirty=function(t,o){if(e.prototype.markDirty.call(this,t,o),this.dirty!=Ht){for(var n=this.parent;!n.node;)n=n.parent;n.dirty<this.dirty&&(n.dirty=this.dirty),this.dirty=Ht}},t.prototype.slice=function(e,o,n){var r=t.create(this.parent,this.mark,!0,n),d=this.children,p=this.size;o<p&&(d=G(d,o,p,n)),0<e&&(d=G(d,0,e,n));for(var a=0;a<d.length;a++)d[a].parent=r;return r.children=d,r},t}(Xt),oo=function(e){function t(t,o,n,r,d,i,p,a,s){e.call(this,t,o.isLeaf?Yt:[],d,i),this.nodeDOM=p,this.node=o,this.outerDeco=n,this.innerDeco=r,i&&this.updateChildren(a,s)}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var o={size:{},border:{}};return t.create=function(e,o,n,r,d,i){var p=d.nodeViews[o.type.name],a=p&&p(o,d,function(){return c?c.parent?c.parent.posBeforeChild(c):void 0:i},n),s=a&&a.dom,l=a&&a.contentDOM,c;if(o.isText){if(!s)s=document.createTextNode(o.text);else if(3!=s.nodeType)throw new RangeError("Text must be rendered as a DOM text node");}else if(!s){var m;m=h.DOMSerializer.renderSpec(document,o.type.spec.toDOM(o)),s=m.dom,l=m.contentDOM}l||o.isText||"BR"==s.nodeName||(!s.hasAttribute("contenteditable")&&(s.contentEditable=!1),o.type.spec.draggable&&(s.draggable=!0));var f=s;return s=_(s,n,o),a?c=new io(e,o,n,r,s,l,f,a,d,i+1):o.isText?new no(e,o,n,r,s,f,d):new t(e,o,n,r,s,l,f,d,i+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};return this.node.type.spec.code&&(t.preserveWhitespace="full"),this.contentDOM&&!this.contentLost?t.contentElement=this.contentDOM:t.getContent=function(){return e.contentDOM?h.Fragment.empty:e.node.content},t},t.prototype.matchesNode=function(e,t,o){return this.dirty==Ht&&e.eq(this.node)&&V(t,this.outerDeco)&&o.eq(this.innerDeco)},o.size.get=function(){return this.node.nodeSize},o.border.get=function(){return this.node.isLeaf?0:1},t.prototype.updateChildren=function(e,t){var o=this,n=this.node.inlineContent,r=t,d=n&&e.composing&&this.localCompositionNode(e,t),p=new ao(this,d&&d.node);j(this.node,this.innerDeco,function(t,d){t.spec.marks?p.syncToMarks(t.spec.marks,n,e):0<=t.type.side&&p.syncToMarks(d==o.node.childCount?h.Mark.none:o.node.child(d).marks,n,e),p.placeWidget(t,e,r)},function(t,o,d,a){p.syncToMarks(t.marks,n,e),p.findNodeMatch(t,o,d,a)||p.updateNextNode(t,o,d,e,a)||p.addNode(t,o,d,e,r),r+=t.nodeSize}),p.syncToMarks(Yt,n,e),this.node.isTextblock&&p.addTextblockHacks(),p.destroyRest(),(p.changed||this.dirty==Ut)&&(d&&this.protectLocalComposition(e,d),this.renderChildren())},t.prototype.renderChildren=function(){E(this.contentDOM,this.children),It.ios&&K(this.dom)},t.prototype.localCompositionNode=function(e,t){var o=e.state.selection,n=o.from,r=o.to;if(!(!(e.state.selection instanceof q.TextSelection)||n<t||r>t+this.node.content.size)){var d=e.root.getSelection(),i=H(d.focusNode,d.focusOffset);if(i&&this.dom.contains(i.parentNode)){var p=i.nodeValue,a=U(this.node.content,p,n-t,r-t);return 0>a?null:{node:i,pos:a,text:p}}}},t.prototype.protectLocalComposition=function(e,t){var o=this,n=t.node,r=t.pos,d=t.text;if(!this.getDesc(n)){for(var i=n;;i=i.parentNode){if(i.parentNode==o.contentDOM)break;for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=null)}var p=new eo(this,i,n,d);e.compositionNodes.push(p),this.children=G(this.children,r,r+d.length,e,p)}},t.prototype.update=function(e,t,o,n){return!!(this.dirty!=Gt&&e.sameMarkup(this.node))&&(this.updateInner(e,t,o,n),!0)},t.prototype.updateInner=function(e,t,o,n){this.updateOuterDeco(t),this.node=e,this.innerDeco=o,this.contentDOM&&this.updateChildren(n,this.posAtStart),this.dirty=Ht},t.prototype.updateOuterDeco=function(e){if(!V(e,this.outerDeco)){var t=1!=this.nodeDOM.nodeType,o=this.dom;this.dom=F(this.dom,this.nodeDOM,z(this.outerDeco,this.node,t),z(e,this.node,t)),this.dom!=o&&(o.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.draggable=!1)},Object.defineProperties(t.prototype,o),t}(Xt),no=function(e){function t(t,o,n,r,d,i,p){e.call(this,t,o,n,r,d,null,i,p)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.parseRule=function(){var e=this.nodeDOM.parentNode;return e?{skip:e}:{ignore:!0}},t.prototype.update=function(e,t){return!!(this.dirty!=Gt&&(this.dirty==Ht||this.inParent())&&e.sameMarkup(this.node))&&(this.updateOuterDeco(t),(this.dirty!=Ht||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text),this.node=e,this.dirty=Ht,!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,o,n){return t==this.nodeDOM?this.posAtStart+l(o,this.node.text.length):e.prototype.localPosFromDOM.call(this,t,o,n)},t.prototype.ignoreMutation=function(e){return"characterData"!=e.type&&"selection"!=e.type},t.prototype.slice=function(e,o,n){var r=this.node.cut(e,o),d=document.createTextNode(r.text);return new t(this.parent,r,this.outerDeco,this.innerDeco,d,d,n)},t}(oo),ro=function(e){function t(){e.apply(this,arguments)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.parseRule=function(){return{ignore:!0}},t.prototype.matchesHack=function(){return this.dirty==Ht},t}(Xt),io=function(e){function t(t,o,n,r,d,i,p,a,s,l){e.call(this,t,o,n,r,d,i,p,s,l),this.spec=a}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.update=function(t,o,n,r){if(this.dirty==Gt)return!1;if(this.spec.update){var d=this.spec.update(t,o);return d&&this.updateInner(t,o,n,r),d}return!!(this.contentDOM||t.isLeaf)&&e.prototype.update.call(this,t,o,n,r)},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,o,n,r){this.spec.setSelection?this.spec.setSelection(t,o,n):e.prototype.setSelection.call(this,t,o,n,r)},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}(oo);$.prototype=Object.create(null);var po=[new $],ao=function(e,t){this.top=e,this.lock=t,this.index=0,this.stack=[],this.changed=!1;var o=J(e.node.content,e.children);this.preMatched=o.nodes,this.preMatchOffset=o.offset};ao.prototype.getPreMatch=function(e){return e>=this.preMatchOffset?this.preMatched[e-this.preMatchOffset]:null},ao.prototype.destroyBetween=function(e,t){var o=this;if(e!=t){for(var n=e;n<t;n++)o.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}},ao.prototype.destroyRest=function(){this.destroyBetween(this.index,this.top.children.length)},ao.prototype.syncToMarks=function(e,t,o){for(var n=this,r=0,d=this.stack.length>>1,p=l(d,e.length);r<p&&(r==d-1?this.top:this.stack[r+1<<1]).matchesMark(e[r])&&!1!==e[r].type.spec.spanning;)r++;for(;r<d;)n.destroyRest(),n.top.dirty=Ht,n.index=n.stack.pop(),n.top=n.stack.pop(),d--;for(;d<e.length;){n.stack.push(n.top,n.index+1);for(var a=-1,s=this.index;s<l(this.index+3,this.top.children.length);s++)if(n.top.children[s].matchesMark(e[d])){a=s;break}if(-1<a)a>n.index&&(n.changed=!0,n.destroyBetween(n.index,a)),n.top=n.top.children[n.index];else{var c=to.create(n.top,e[d],t,o);n.top.children.splice(n.index,0,c),n.top=c,n.changed=!0}n.index=0,d++}},ao.prototype.findNodeMatch=function(t,o,n,r){var d=this,p=-1,a=0>r?void 0:this.getPreMatch(r),s=this.top.children;if(a&&a.matchesNode(t,o,n))p=s.indexOf(a);else for(var c=this.index,h=l(s.length,c+5),e;c<h;c++)if(e=s[c],e.matchesNode(t,o,n)&&0>d.preMatched.indexOf(e)){p=c;break}return!(0>p)&&(this.destroyBetween(this.index,p),this.index++,!0)},ao.prototype.updateNextNode=function(e,t,o,n,r){if(this.index==this.top.children.length)return!1;var d=this.top.children[this.index];if(d instanceof oo){var i=this.preMatched.indexOf(d);if(-1<i&&i+this.preMatchOffset!=r)return!1;var p=d.dom,a=this.lock&&(p==this.lock||1==p.nodeType&&p.contains(this.lock.parentNode))&&!(e.isText&&d.node&&d.node.isText&&d.nodeDOM.nodeValue==e.text&&d.dirty!=Gt&&V(t,d.outerDeco));if(!a&&d.update(e,t,o,n))return d.dom!=p&&(this.changed=!0),this.index++,!0}return!1},ao.prototype.addNode=function(e,t,o,n,r){this.top.children.splice(this.index++,0,oo.create(this.top,e,t,o,n,r)),this.changed=!0},ao.prototype.placeWidget=function(e,t,o){if(this.index<this.top.children.length&&this.top.children[this.index].matchesWidget(e))this.index++;else{var n=new Zt(this.top,e,t,o);this.top.children.splice(this.index++,0,n),this.changed=!0}},ao.prototype.addTextblockHacks=function(){for(var e=this.top.children[this.index-1];e instanceof to;)e=e.children[e.children.length-1];if(!e||!(e instanceof no)||/\n$/.test(e.node.text))if(this.index<this.top.children.length&&this.top.children[this.index].matchesHack())this.index++;else{var t=document.createElement("br");this.top.children.splice(this.index++,0,new ro(this.top,Yt,t,null)),this.changed=!0}};var so=It.safari||It.chrome&&63>It.chrome_version,lo={thead:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]},co=null,ho={childList:!0,characterData:!0,attributes:!0,subtree:!0,characterDataOldValue:!0},mo=It.ie&&11>=It.ie_version,fo=function(){this.anchorNode=this.anchorOffset=this.focusNode=this.focusOffset=null};fo.prototype.set=function(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset},fo.prototype.eq=function(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset};var go=function(e,t){var o=this;this.view=e,this.handleDOMChange=t,this.observer=window.MutationObserver&&new window.MutationObserver(function(e){It.ie&&11>=It.ie_version&&e.some(function(e){return"childList"==e.type&&1==e.removedNodes.length&&e.removedNodes[0].parentNode==e.target})?setTimeout(function(){return o.flush(e)},10):o.flush(e)}),this.currentSelection=new fo,this.queue=[],mo&&(this.onCharData=function(t){o.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),window.setTimeout(function(){return o.flush()},20)}),this.onSelectionChange=this.onSelectionChange.bind(this),this.suppressingSelectionUpdates=!1};go.prototype.start=function(){this.observer&&this.observer.observe(this.view.dom,ho),mo&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()},go.prototype.stop=function(){var e=this,t=this.observer.takeRecords();if(t.length){for(var o=0;o<t.length;o++)e.queue.push(t[o]);window.setTimeout(function(){return e.flush()},20)}this.observer&&this.observer.disconnect(),mo&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()},go.prototype.connectSelection=function(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)},go.prototype.disconnectSelection=function(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)},go.prototype.suppressSelectionUpdates=function(){var e=this;this.suppressingSelectionUpdates=!0,setTimeout(function(){return e.suppressingSelectionUpdates=!1},50)},go.prototype.onSelectionChange=function(){return ve(this.view)?this.suppressingSelectionUpdates?me(this.view):void this.flush():void 0},go.prototype.setCurSelection=function(){this.currentSelection.set(this.view.root.getSelection())},go.prototype.ignoreSelectionChange=function(e){if(0==e.rangeCount)return!0;var t=e.getRangeAt(0).commonAncestorContainer,o=this.view.docView.nearestDesc(t);return o&&o.ignoreMutation({type:"selection",target:3==t.nodeType?t.parentNode:t})},go.prototype.flush=function(e){var t=this;if(this.view.docView){e||(e=this.observer.takeRecords()),this.queue.length&&(e=this.queue.concat(e),this.queue.length=0);var o=this.view.root.getSelection(),n=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(o)&&be(this.view)&&!this.ignoreSelectionChange(o),r=-1,d=-1,p=!1;if(this.view.editable)for(var a=0,c;a<e.length;a++)c=t.registerMutation(e[a]),c&&(r=0>r?c.from:l(c.from,r),d=0>d?c.to:s(c.to,d),c.typeOver&&!t.view.composing&&(p=!0));(-1<r||n)&&(-1<r&&this.view.docView.markDirty(r,d),this.handleDOMChange(r,d,p),this.view.docView.dirty?this.view.updateState(this.view.state):!this.currentSelection.eq(o)&&me(this.view))}},go.prototype.registerMutation=function(e){var t=this.view.docView.nearestDesc(e.target);if("attributes"==e.type&&(t==this.view.docView||"contenteditable"==e.attributeName||"style"==e.attributeName&&!e.oldValue&&!e.target.getAttribute("style")))return null;if(!t||t.ignoreMutation(e))return null;if("childList"==e.type){var o=e.previousSibling&&e.previousSibling.parentNode==e.target?Ft(e.previousSibling)+1:0,n=t.localPosFromDOM(e.target,o,-1),r=e.nextSibling&&e.nextSibling.parentNode==e.target?Ft(e.nextSibling):e.target.childNodes.length,d=t.localPosFromDOM(e.target,r,1);return{from:n,to:d}}return"attributes"==e.type?{from:t.posAtStart-t.border,to:t.posAtEnd+t.border}:{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}};var uo={},yo={};yo.keydown=function(e,t){e.shiftKey=16==t.keyCode||t.shiftKey,it(e,t)||(e.lastKeyCode=t.keyCode,e.lastKeyCodeTime=Date.now(),e.someProp("handleKeyDown",function(o){return o(e,t)})||ce(e,t)?t.preventDefault():We(e,"key"))},yo.keyup=function(t,o){16==o.keyCode&&(t.shiftKey=!1)},yo.keypress=function(e,t){if(!(it(e,t)||!t.charCode||t.ctrlKey&&!t.altKey||It.mac&&t.metaKey)){if(e.someProp("handleKeyPress",function(o){return o(e,t)}))return void t.preventDefault();var o=e.state.selection;if(!(o instanceof q.TextSelection)||!o.$from.sameParent(o.$to)){var n=d(t.charCode);e.someProp("handleTextInput",function(t){return t(e,o.$from.pos,o.$to.pos,n)})||e.dispatch(e.state.tr.insertText(n).scrollIntoView()),t.preventDefault()}}};var So=It.mac?"metaKey":"ctrlKey";uo.mousedown=function(e,t){e.shiftKey=t.shiftKey;var o=dt(e),n=Date.now(),r="singleClick";500>n-e.lastClick.time&&Xe(t,e.lastClick)&&!t[So]&&("singleClick"==e.lastClick.type?r="doubleClick":"doubleClick"==e.lastClick.type&&(r="tripleClick")),e.lastClick={time:n,x:t.clientX,y:t.clientY,type:r};var d=e.posAtCoords(Ge(t));d&&("singleClick"==r?e.mouseDown=new Co(e,d,t,o):("doubleClick"==r?ot:nt)(e,d.pos,d.inside,t)?t.preventDefault():We(e,"pointer"))};var Co=function(e,t,o,n){var r=this;this.view=e,this.startDoc=e.state.doc,this.pos=t,this.event=o,this.flushed=n,this.selectNode=o[So],this.allowDefault=o.shiftKey;var d,i;if(-1<t.inside)d=e.state.doc.nodeAt(t.inside),i=t.inside;else{var p=e.state.doc.resolve(t.pos);d=p.parent,i=p.depth?p.before():0}this.mightDrag=null;var a=n?null:o.target,s=a?e.docView.nearestDesc(a,!0):null;this.target=s?s.dom:null,(d.type.spec.draggable&&!1!==d.type.spec.selectable||e.state.selection instanceof q.NodeSelection&&i==e.state.selection.from)&&(this.mightDrag={node:d,pos:i,addAttr:this.target&&!this.target.draggable,setUneditable:this.target&&It.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(){return r.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)),We(e,"pointer")};Co.prototype.done=function(){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.draggable=!1),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.view.mouseDown=null},Co.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(Ge(e))),this.allowDefault||!t?We(this.view,"pointer"):tt(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():this.flushed||It.chrome&&!(this.view.state.selection instanceof q.TextSelection)&&(t.pos==this.view.state.selection.from||t.pos==this.view.state.selection.to)?(Ye(this.view,q.Selection.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):We(this.view,"pointer")}},Co.prototype.move=function(e){!this.allowDefault&&(4<Rt(this.event.x-e.clientX)||4<Rt(this.event.y-e.clientY))&&(this.allowDefault=!0),We(this.view,"pointer")},uo.touchdown=function(e){dt(e),We(e,"pointer")},uo.contextmenu=function(e){return dt(e)};var vo=It.android?5e3:-1;yo.compositionstart=yo.compositionupdate=function(e){if(!e.composing){e.domObserver.flush();var t=e.state,o=t.selection.$from;if(t.selection.empty&&(t.storedMarks||!o.textOffset&&o.parentOffset&&o.nodeBefore.marks.some(function(e){return!1===e.type.spec.inclusive})))e.markCursor=e.state.storedMarks||o.marks(),at(e,!0),e.markCursor=null;else if(at(e),It.gecko&&t.selection.empty&&o.parentOffset&&!o.textOffset&&o.nodeBefore.marks.length)for(var n=e.root.getSelection(),r=n.focusNode,d=n.focusOffset,i;r&&1==r.nodeType&&0!=d;)if(i=0>d?r.lastChild:r.childNodes[d-1],3==i.nodeType){n.collapse(i,i.nodeValue.length);break}else r=i,d=-1;e.composing=!0}pt(e,vo)},yo.compositionend=function(e,t){e.composing&&(e.composing=!1,e.compositionEndedAt=t.timeStamp,pt(e,20))};var bo=It.ie&&15>It.ie_version||It.ios&&604>It.webkit_version;uo.copy=yo.cut=function(t,o){var e=t.state.selection,n="cut"==o.type;if(!e.empty){var r=bo?null:o.clipboardData,d=e.content(),i=Re(t,d),p=i.dom,a=i.text;r?(o.preventDefault(),r.clearData(),r.setData("text/html",p.innerHTML),r.setData("text/plain",a)):st(t,p),n&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))}},yo.paste=function(t,o){var e=bo?null:o.clipboardData;e&&(ht(t,e.getData("text/plain"),e.getData("text/html"),o)||0<e.files.length)?o.preventDefault():ct(t,o)};var wo=function(e,t){this.slice=e,this.move=t},xo=It.mac?"altKey":"ctrlKey";for(var ko in uo.dragstart=function(t,o){var e=t.mouseDown;if(e&&e.done(),!!o.dataTransfer){var n=t.state.selection,r=n.empty?null:t.posAtCoords(Ge(o));if(r&&r.pos>=n.from&&r.pos<=(n instanceof q.NodeSelection?n.to-1:n.to));else if(e&&e.mightDrag)t.dispatch(t.state.tr.setSelection(q.NodeSelection.create(t.state.doc,e.mightDrag.pos)));else if(o.target&&1==o.target.nodeType){var d=t.docView.nearestDesc(o.target,!0);if(!d||!d.node.type.spec.draggable||d==t.docView)return;t.dispatch(t.state.tr.setSelection(q.NodeSelection.create(t.state.doc,d.posBefore)))}var i=t.state.selection.content(),p=Re(t,i),a=p.dom,s=p.text;o.dataTransfer.clearData(),o.dataTransfer.setData(bo?"Text":"text/html",a.innerHTML),bo||o.dataTransfer.setData("text/plain",s),t.dragging=new wo(i,!o[xo])}},uo.dragend=function(e){window.setTimeout(function(){return e.dragging=null},50)},yo.dragover=yo.dragenter=function(t,o){return o.preventDefault()},yo.drop=function(t,o){var e=t.dragging;if(t.dragging=null,!!o.dataTransfer){var n=t.posAtCoords(Ge(o));if(n){var r=t.state.doc.resolve(n.pos);if(r){var d=e&&e.slice||Ie(t,o.dataTransfer.getData(bo?"Text":"text/plain"),bo?null:o.dataTransfer.getData("text/html"),!1,r);if(d&&(o.preventDefault(),!t.someProp("handleDrop",function(n){return n(t,o,d,e&&e.move)}))){var i=d?T.dropPoint(t.state.doc,r.pos,d):r.pos;null==i&&(i=r.pos);var p=t.state.tr;e&&e.move&&p.deleteSelection();var a=p.mapping.map(i),s=0==d.openStart&&0==d.openEnd&&1==d.content.childCount,l=p.doc;if(s?p.replaceRangeWith(a,a,d.content.firstChild):p.replaceRange(a,a,d),!p.doc.eq(l)){var c=p.doc.resolve(a);s&&q.NodeSelection.isSelectable(d.content.firstChild)&&c.nodeAfter&&c.nodeAfter.sameMarkup(d.content.firstChild)?p.setSelection(new q.NodeSelection(c)):p.setSelection(Ce(t,c,p.doc.resolve(p.mapping.map(i)))),t.focus(),t.dispatch(p.setMeta("uiEvent","drop"))}}}}}},uo.focus=function(e){e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0)},uo.blur=function(e){e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),e.focused=!1)},uo.beforeinput=function(e,t){if(It.chrome&&It.android&&"deleteContentBackward"==t.inputType){var o=e.domChangeCount;setTimeout(function(){if(e.domChangeCount==o&&(e.dom.blur(),e.focus(),!e.someProp("handleKeyDown",function(t){return t(e,i(8,"Backspace"))}))){var t=e.state.selection,n=t.$cursor;n&&0<n.pos&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())}},50)}},yo)uo[ko]=yo[ko];var Mo=function(e,t){this.spec=t||Ro,this.side=this.spec.side||0,this.toDOM=e};Mo.prototype.map=function(e,t,o,n){var r=e.mapResult(t.from+n,0>this.side?-1:1),d=r.pos,i=r.deleted;return i?null:new Oo(d-o,d-o,this)},Mo.prototype.valid=function(){return!0},Mo.prototype.eq=function(e){return this==e||e instanceof Mo&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&mt(this.spec,e.spec))};var To=function(e,t){this.spec=t||Ro,this.attrs=e};To.prototype.map=function(e,t,o,n){var r=e.map(t.from+n,this.spec.inclusiveStart?-1:1)-o,d=e.map(t.to+n,this.spec.inclusiveEnd?1:-1)-o;return r>=d?null:new Oo(r,d,this)},To.prototype.valid=function(e,t){return t.from<t.to},To.prototype.eq=function(e){return this==e||e instanceof To&&mt(this.attrs,e.attrs)&&mt(this.spec,e.spec)},To.is=function(e){return e.type instanceof To};var No=function(e,t){this.spec=t||Ro,this.attrs=e};No.prototype.map=function(e,t,o,n){var r=e.mapResult(t.from+n,1);if(r.deleted)return null;var d=e.mapResult(t.to+n,-1);return d.deleted||d.pos<=r.pos?null:new Oo(r.pos-o,d.pos-o,this)},No.prototype.valid=function(e,t){var o=e.content.findIndex(t.from),n=o.index,r=o.offset;return r==t.from&&r+e.child(n).nodeSize==t.to},No.prototype.eq=function(e){return this==e||e instanceof No&&mt(this.attrs,e.attrs)&&mt(this.spec,e.spec)};var Oo=function(e,t,o){this.from=e,this.to=t,this.type=o},Ao={spec:{}};Oo.prototype.copy=function(e,t){return new Oo(e,t,this.type)},Oo.prototype.eq=function(e){return this.type.eq(e.type)&&this.from==e.from&&this.to==e.to},Oo.prototype.map=function(e,t,o){return this.type.map(e,this,t,o)},Oo.widget=function(e,t,o){return new Oo(e,e,new Mo(t,o))},Oo.inline=function(e,t,o,n){return new Oo(e,t,new To(o,n))},Oo.node=function(e,t,o,n){return new Oo(e,t,new No(o,n))},Ao.spec.get=function(){return this.type.spec},Object.defineProperties(Oo.prototype,Ao);var Do=[],Ro={},Io=function(e,t){this.local=e&&e.length?e:Do,this.children=t&&t.length?t:Do};Io.create=function(e,t){return t.length?Ct(t,e,0,Ro):Po},Io.prototype.find=function(e,t,o){var n=[];return this.findInner(null==e?0:e,null==t?1e9:t,n,0,o),n},Io.prototype.findInner=function(e,t,o,n,r){for(var d=this,p=0,a;p<this.local.length;p++)a=d.local[p],a.from<=t&&a.to>=e&&(!r||r(a.spec))&&o.push(a.copy(a.from+n,a.to+n));for(var s=0;s<this.children.length;s+=3)if(d.children[s]<t&&d.children[s+1]>e){var l=d.children[s]+1;d.children[s+2].findInner(e-l,t-l,o,n+l,r)}},Io.prototype.map=function(e,t,o){return this==Po||0==e.maps.length?this:this.mapInner(e,t,0,0,o||Ro)},Io.prototype.mapInner=function(e,t,o,n,r){for(var d=this,p=0,a,s;p<this.local.length;p++)s=d.local[p].map(e,o,n),s&&s.type.valid(t,s)?(a||(a=[])).push(s):r.onRemove&&r.onRemove(d.local[p].spec);return this.children.length?ft(this.children,a,e,t,o,n,r):a?new Io(a.sort(vt)):Po},Io.prototype.add=function(e,t){return t.length?this==Po?Io.create(e,t):this.addInner(e,t,0):this},Io.prototype.addInner=function(e,t,o){var n=this,r=0,d;e.forEach(function(e,i){var p=i+o,a;if(a=yt(t,e,p)){for(d||(d=n.children.slice());r<d.length&&d[r]<i;)r+=3;d[r]==i?d[r+2]=d[r+2].addInner(e,a,p+1):d.splice(r,0,i,i+e.nodeSize,Ct(a,e,p+1,Ro)),r+=3}});var i=gt(r?St(t):t,-o);return new Io(i.length?this.local.concat(i).sort(vt):this.local,d||this.children)},Io.prototype.remove=function(e){return 0==e.length||this==Po?this:this.removeInner(e,0)},Io.prototype.removeInner=function(e,t){for(var o=this,n=this.children,r=this.local,d=0;d<n.length;d+=3){for(var p=void 0,a=n[d]+t,s=n[d+1]+t,l=0,c=void 0;l<e.length;l++)(c=e[l])&&c.from>a&&c.to<s&&(e[l]=null,(p||(p=[])).push(c));if(p){n==o.children&&(n=o.children.slice());var h=n[d+2].removeInner(p,a+1);h==Po?(n.splice(d,3),d-=3):n[d+2]=h}}if(r.length)for(var m=0,f=void 0;m<e.length;m++)if(f=e[m])for(var g=0;g<r.length;g++)r[g].type.eq(f.type)&&(r==o.local&&(r=o.local.slice()),r.splice(g--,1));return n==this.children&&r==this.local?this:r.length||n.length?new Io(r,n):Po},Io.prototype.forChild=function(e,t){var o=this;if(this==Po)return this;if(t.isLeaf)return Io.empty;for(var n=0,r,d;n<this.children.length;n+=3)if(o.children[n]>=e){o.children[n]==e&&(r=o.children[n+2]);break}for(var p=e+1,a=p+t.content.size,c=0,h;c<this.local.length;c++)if(h=o.local[c],h.from<a&&h.to>p&&h.type instanceof To){var m=s(p,h.from)-p,f=l(a,h.to)-p;m<f&&(d||(d=[])).push(h.copy(m,f))}if(d){var g=new Io(d.sort(vt));return r?new Eo([g,r]):g}return r||Po},Io.prototype.eq=function(e){var t=this;if(this==e)return!0;if(!(e instanceof Io)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(var o=0;o<this.local.length;o++)if(!t.local[o].eq(e.local[o]))return!1;for(var n=0;n<this.children.length;n+=3)if(t.children[n]!=e.children[n]||t.children[n+1]!=e.children[n+1]||!t.children[n+2].eq(e.children[n+2]))return!1;return!0},Io.prototype.locals=function(e){return bt(this.localsInner(e))},Io.prototype.localsInner=function(e){var t=this;if(this==Po)return Do;if(e.inlineContent||!this.local.some(To.is))return this.local;for(var o=[],n=0;n<this.local.length;n++)t.local[n].type instanceof To||o.push(t.local[n]);return o};var Po=new Io;Io.empty=Po,Io.removeOverlap=bt;var Eo=function(e){this.members=e};Eo.prototype.forChild=function(e,t){var o=this;if(t.isLeaf)return Io.empty;for(var n=[],r=0,d;r<this.members.length;r++)(d=o.members[r].forChild(e,t),d!=Po)&&(d instanceof Eo?n=n.concat(d.members):n.push(d));return Eo.from(n)},Eo.prototype.eq=function(e){var t=this;if(!(e instanceof Eo)||e.members.length!=this.members.length)return!1;for(var o=0;o<this.members.length;o++)if(!t.members[o].eq(e.members[o]))return!1;return!0},Eo.prototype.locals=function e(t){for(var o=this,n=!0,r=0,d,e;r<this.members.length;r++)if(e=o.members[r].localsInner(t),!!e.length)if(!d)d=e;else{n&&(d=d.slice(),n=!1);for(var p=0;p<e.length;p++)d.push(e[p])}return d?bt(n?d:d.sort(vt)):Do},Eo.from=function(e){switch(e.length){case 0:return Po;case 1:return e[0];default:return new Eo(e);}};var $o=function(e,t){this._props=t,this.state=t.state,this.dispatch=this.dispatch.bind(this),this._root=null,this.focused=!1,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=Tt(this),this.markCursor=null,this.cursorWrapper=null,Mt(this),this.nodeViews=At(this),this.docView=P(this.state.doc,kt(this),xt(this),this.dom,this),this.lastSelectedViewDesc=null,this.dragging=null,Je(this),this.pluginViews=[],this.updatePluginViews()},zo={props:{},root:{}};zo.props.get=function(){var e=this;if(this._props.state!=this.state){var t=this._props;for(var o in this._props={},t)e._props[o]=t[o];this._props.state=this.state}return this._props},$o.prototype.update=function(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Ke(this),this._props=e,this.updateStateInner(e.state,!0)},$o.prototype.setProps=function(e){var t=this,o={};for(var n in t._props)o[n]=t._props[n];for(var r in o.state=this.state,e)o[r]=e[r];this.update(o)},$o.prototype.updateState=function(e){this.updateStateInner(e,this.state.plugins!=e.plugins)},$o.prototype.updateStateInner=function(e,t){var o=this,n=this.state,r=!1;if(this.state=e,t){var d=At(this);Dt(d,this.nodeViews)&&(this.nodeViews=d,r=!0),Ke(this)}this.editable=Tt(this),Mt(this);var i=xt(this),p=kt(this),a=t?"reset":e.scrollToSelection>n.scrollToSelection?"to selection":"preserve",s=r||!this.docView.matchesNode(e.doc,p,i),l=s||!e.selection.eq(n.selection),c="preserve"==a&&l&&null==this.dom.style.overflowAnchor&&f(this);if(l){this.domObserver.stop();var h=!1;if(s){var u=It.chrome&&Nt(this.root);(r||!this.docView.update(e.doc,p,i,this))&&(this.docView.destroy(),this.docView=P(e.doc,p,i,this.dom,this)),u&&(h=!this.composing&&Ot(u,this.root))}h||!(this.mouseDown&&this.domObserver.currentSelection.eq(this.root.getSelection())&&we(this))?me(this,!1,h):(ye(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}if(this.updatePluginViews(n),"reset"==a)this.dom.scrollTop=0;else if("to selection"==a){var y=this.root.getSelection().focusNode;if(this.someProp("handleScrollToSelection",function(e){return e(o)}));else e.selection instanceof q.NodeSelection?m(this,this.docView.domAfterPos(e.selection.from).getBoundingClientRect(),y):m(this,this.coordsAtPos(e.selection.head),y)}else c&&g(c)},$o.prototype.destroyPluginViews=function(){for(var e;e=this.pluginViews.pop();)e.destroy&&e.destroy()},$o.prototype.updatePluginViews=function(e){var t=this;if(!e||e.plugins!=this.state.plugins){this.destroyPluginViews();for(var o=0,n;o<this.state.plugins.length;o++)n=t.state.plugins[o],n.spec.view&&t.pluginViews.push(n.spec.view(t))}else for(var r=0,d;r<this.pluginViews.length;r++)d=t.pluginViews[r],d.update&&d.update(t,e)},$o.prototype.someProp=function(e,t){var o=this._props&&this._props[e],n;if(null!=o&&(n=t?t(o):o))return n;var r=this.state.plugins;if(r)for(var d=0,p;d<r.length;d++)if(p=r[d].props[e],null!=p&&(n=t?t(p):p))return n},$o.prototype.hasFocus=function(){return this.root.activeElement==this.dom},$o.prototype.focus=function(){this.domObserver.stop(),me(this,!0),this.editable&&(this.dom.setActive?this.dom.setActive():this.dom.focus({preventScroll:!0})),this.domObserver.start()},zo.root.get=function(){var e=this,t=this._root;if(null==t)for(var o=this.dom.parentNode;o;o=o.parentNode)if(9==o.nodeType||11==o.nodeType&&o.host)return e._root=o;return t||document},$o.prototype.posAtCoords=function(e){return x(this,e)},$o.prototype.coordsAtPos=function(e){return M(this,e)},$o.prototype.domAtPos=function(e){return this.docView.domFromPos(e)},$o.prototype.nodeDOM=function(e){var t=this.docView.descAt(e);return t?t.nodeDOM:null},$o.prototype.posAtDOM=function(e,t,o){void 0===o&&(o=-1);var n=this.docView.posFromDOM(e,t,o);if(null==n)throw new RangeError("DOM position not inside the editor");return n},$o.prototype.endOfTextblock=function(e,t){return I(this,t||this.state,e)},$o.prototype.destroy=function(){this.docView&&(je(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],xt(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null)},$o.prototype.dispatchEvent=function(e){return Ue(this,e)},$o.prototype.dispatch=function(e){var t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))},Object.defineProperties($o.prototype,zo),t.EditorView=$o,t.Decoration=Oo,t.DecorationSet=Io,t.__serializeForClipboard=Re,t.__parseFromClipboard=Ie,t.__endComposition=at});t(oe);var ne=oe.EditorView,re=oe.Decoration,de=oe.DecorationSet,ie=oe.__serializeForClipboard,pe=oe.__parseFromClipboard,ae=oe.__endComposition,se=o(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var o=function(e,t){var o=this;this.editorView=e,this.width=t.width||1,this.color=t.color||"black",this.cursorPos=null,this.element=null,this.timeout=null,this.handlers=["dragover","dragend","drop","dragleave"].map(function(t){var n=function(n){return o[t](n)};return e.dom.addEventListener(t,n),{name:t,handler:n}})};o.prototype.destroy=function(){var e=this;this.handlers.forEach(function(t){var o=t.name,n=t.handler;return e.editorView.dom.removeEventListener(o,n)})},o.prototype.update=function(e,t){null!=this.cursorPos&&t.doc!=e.state.doc&&this.updateOverlay()},o.prototype.setCursor=function(e){e==this.cursorPos||(this.cursorPos=e,null==e?(this.element.remove(),this.element=null):this.updateOverlay())},o.prototype.updateOverlay=function(){var e=this.editorView.state.doc.resolve(this.cursorPos),t;if(!e.parent.inlineContent){var o=e.nodeBefore,n=e.nodeAfter;if(o||n){var r=this.editorView.nodeDOM(this.cursorPos-(o?o.nodeSize:0)).getBoundingClientRect(),d=o?r.bottom:r.top;o&&n&&(d=(d+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2),t={left:r.left,right:r.right,top:d-this.width/2,bottom:d+this.width/2}}}if(!t){var i=this.editorView.coordsAtPos(this.cursorPos);t={left:i.left-this.width/2,right:i.left+this.width/2,top:i.top,bottom:i.bottom}}var p=this.editorView.dom.offsetParent;this.element||(this.element=p.appendChild(document.createElement("div")),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none; background-color: "+this.color);var a=p==document.body&&"static"==getComputedStyle(p).position?{left:-pageXOffset,top:-pageYOffset}:p.getBoundingClientRect();this.element.style.left=t.left-a.left+"px",this.element.style.top=t.top-a.top+"px",this.element.style.width=t.right-t.left+"px",this.element.style.height=t.bottom-t.top+"px"},o.prototype.scheduleRemoval=function(e){var t=this;clearTimeout(this.timeout),this.timeout=setTimeout(function(){return t.setCursor(null)},e)},o.prototype.dragover=function(e){var t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY});if(t){var o=t.pos;this.editorView.dragging&&this.editorView.dragging.slice&&(o=T.dropPoint(this.editorView.state.doc,o,this.editorView.dragging.slice),null==o&&(o=t.pos)),this.setCursor(o),this.scheduleRemoval(5e3)}},o.prototype.dragend=function(){this.scheduleRemoval(20)},o.prototype.drop=function(){this.scheduleRemoval(20)},o.prototype.dragleave=function(e){e.target!=this.editorView.dom&&this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)},t.dropCursor=function(e){return void 0===e&&(e={}),new q.Plugin({view:function(t){return new o(t,e)}})}});t(se);for(var le=se.dropCursor,ce={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",229:"q"},he={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:";",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:"\"",229:"Q"},me="undefined"!=typeof navigator&&/Chrome\/(\d+)/.exec(navigator.userAgent),fe="undefined"!=typeof navigator&&/Apple Computer/.test(navigator.vendor),ge="undefined"!=typeof navigator&&/Gecko\/\d+/.test(navigator.userAgent),ue="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),ye=me&&(ue||57>+me[1])||ge&&ue,Se=0;10>Se;Se++)ce[48+Se]=ce[96+Se]=Se+"";for(var Se=1;24>=Se;Se++)ce[Se+111]="F"+Se;for(var Se=65;90>=Se;Se++)ce[Se]=d(Se+32),he[Se]=d(Se);for(var a in ce)he.hasOwnProperty(a)||(he[a]=ce[a]);var Ce=r;r.base=ce,r.shift=he;var ve=o(function(e,t){function o(e){return e&&"object"==typeof e&&"default"in e?e["default"]:e}function n(e){var t=e.split(/-(?!$)/),o=t[t.length-1];"Space"==o&&(o=" ");for(var n=0,r,d,p,s,l;n<t.length-1;n++)if(l=t[n],/^(cmd|meta|m)$/i.test(l))s=!0;else if(/^a(lt)?$/i.test(l))r=!0;else if(/^(c|ctrl|control)$/i.test(l))d=!0;else if(/^s(hift)?$/i.test(l))p=!0;else if(/^mod$/i.test(l))a?s=!0:d=!0;else throw new Error("Unrecognized modifier name: "+l);return r&&(o="Alt-"+o),d&&(o="Ctrl-"+o),s&&(o="Meta-"+o),p&&(o="Shift-"+o),o}function r(e){var t=Object.create(null);for(var o in e)t[n(o)]=e[o];return t}function d(e,t,o){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),!1!==o&&t.shiftKey&&(e="Shift-"+e),e}function i(e){var t=r(e);return function(e,o){var n=p(o),r=1==n.length&&" "!=n,i=t[d(n,o,!r)],a;if(i&&i(e.state,e.dispatch,e))return!0;if(r&&(o.shiftKey||o.altKey||o.metaKey)&&(a=p.base[o.keyCode])&&a!=n){var s=t[d(a,o,!0)];if(s&&s(e.state,e.dispatch,e))return!0}return!1}}Object.defineProperty(t,"__esModule",{value:!0});var p=o(Ce),a="undefined"!=typeof navigator&&/Mac/.test(navigator.platform);t.keymap=function(e){return new q.Plugin({props:{handleKeyDown:i(e)}})},t.keydownHandler=i});t(ve);var be=ve.keymap,we=ve.keydownHandler,xe=o(function(e,t){function o(e){for(var t=e.depth,o;0<=t;t--)if(o=e.index(t),0!=o)for(var n=e.node(t).child(o-1);;n=n.lastChild){if(0==n.childCount&&!n.inlineContent||n.isAtom||n.type.spec.isolating)return!0;if(n.inlineContent)return!1}return!0}function n(e){for(var t=e.depth;0<=t;t--){var o=e.indexAfter(t),n=e.node(t);if(o!=n.childCount)for(var r=n.child(o);;r=r.firstChild){if(0==r.childCount&&!r.inlineContent||r.isAtom||r.type.spec.isolating)return!0;if(r.inlineContent)return!1}}return!0}function r(e,t){var o="vert"==e?0<t?"down":"up":0<t?"right":"left";return function(e,n,r){var d=e.selection,i=0<t?d.$to:d.$from,a=d.empty;if(d instanceof q.TextSelection){if(!r.endOfTextblock(o))return!1;a=!1,i=e.doc.resolve(0<t?i.after():i.before())}var s=p.findFrom(i,t,a);return!!s&&(n&&n(e.tr.setSelection(new p(s))),!0)}}function d(e,t,o){if(e.someProp("editable",function(t){return!1===t(e.state)}))return!1;var n=e.state.doc.resolve(t);if(!p.valid(n))return!1;var r=e.posAtCoords({left:o.clientX,top:o.clientY}),d=r.inside;return!(-1<d&&q.NodeSelection.isSelectable(e.state.doc.nodeAt(d)))&&(e.dispatch(e.state.tr.setSelection(new p(n))),!0)}function i(e){if(!(e.selection instanceof p))return null;var t=document.createElement("div");return t.className="ProseMirror-gapcursor",oe.DecorationSet.create(e.doc,[oe.Decoration.widget(e.selection.head,t,{key:"gapcursor"})])}Object.defineProperty(t,"__esModule",{value:!0});var p=function(e){function t(t){e.call(this,t,t)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.map=function(o,n){var r=o.resolve(n.map(this.head));return t.valid(r)?new t(r):e.near(r)},t.prototype.content=function(){return h.Slice.empty},t.prototype.eq=function(e){return e instanceof t&&e.head==this.head},t.prototype.toJSON=function(){return{type:"gapcursor",pos:this.head}},t.fromJSON=function(e,o){if("number"!=typeof o.pos)throw new RangeError("Invalid input for GapCursor.fromJSON");return new t(e.resolve(o.pos))},t.prototype.getBookmark=function(){return new a(this.anchor)},t.valid=function(e){var t=e.parent;if(t.isTextblock||!o(e)||!n(e))return!1;var r=t.type.spec.allowGapCursor;if(null!=r)return r;var d=t.contentMatchAt(e.index()).defaultType;return d&&d.isTextblock},t.findFrom=function(e,o,n){if(!n&&t.valid(e))return e;for(var r=e.pos,i=null,p=e.depth,a;;p--){if(a=e.node(p),0<o?e.indexAfter(p)<a.childCount:0<e.index(p)){i=a.maybeChild(0<o?e.indexAfter(p):e.index(p)-1);break}else if(0==p)return null;r+=o;var s=e.doc.resolve(r);if(t.valid(s))return s}for(;;){if(i=0<o?i.firstChild:i.lastChild,!i)break;r+=o;var l=e.doc.resolve(r);if(t.valid(l))return l}return null},t}(q.Selection);p.prototype.visible=!1,q.Selection.jsonID("gapcursor",p);var a=function(e){this.pos=e};a.prototype.map=function(e){return new a(e.map(this.pos))},a.prototype.resolve=function(e){var t=e.resolve(this.pos);return p.valid(t)?new p(t):q.Selection.near(t)};var s=ve.keydownHandler({ArrowLeft:r("horiz",-1),ArrowRight:r("horiz",1),ArrowUp:r("vert",-1),ArrowDown:r("vert",1)});t.gapCursor=function(){return new q.Plugin({props:{decorations:i,createSelectionBetween:function(e,t,o){if(t.pos==o.pos&&p.valid(o))return new p(o)},handleClick:d,handleKeyDown:s}})},t.GapCursor=p});t(xe);var ke=xe.gapCursor,Me=xe.GapCursor,Te=o(function(e,t){function o(e){return function(t,o,n,r){var d=e;if(o[1]){var i=o[0].lastIndexOf(o[1]);d+=o[0].slice(i+o[1].length),n+=i;var p=n-r;0<p&&(d=o[0].slice(i-p,i)+d,n=r)}return t.tr.insertText(d,n,r)}}function n(e,t,o,n,r,d){if(e.composing)return!1;var p=e.state,a=p.doc.resolve(t);if(a.parent.type.spec.code)return!1;for(var l=a.parent.textBetween(s(0,a.parentOffset-500),a.parentOffset,null,"\uFFFC")+n,c=0;c<r.length;c++){var h=r[c].match.exec(l),m=h&&r[c].handler(p,h,t-(h[0].length-n.length),o);if(m)return e.dispatch(m.setMeta(d,{transform:m,from:t,to:o,text:n})),!0}return!1}function r(e,t){for(var o=e.plugins,n=0;n<o.length;n++){var r=o[n],d=void 0;if(r.spec.isInputRules&&(d=r.getState(e))){if(t){for(var p=e.tr,a=d.transform,s=a.steps.length-1;0<=s;s--)p.step(a.steps[s].invert(a.docs[s]));var l=p.doc.resolve(d.from).marks();t(p.replaceWith(d.from,d.to,e.schema.text(d.text,l)))}return!0}}return!1}Object.defineProperty(t,"__esModule",{value:!0});var d=function(e,t){this.match=e,this.handler="string"==typeof t?o(t):t},i=new d(/--$/,"\u2014"),p=new d(/\.\.\.$/,"\u2026"),a=new d(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"\u201C"),l=new d(/"$/,"\u201D"),c=new d(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"\u2018"),h=new d(/'$/,"\u2019");t.InputRule=d,t.inputRules=function(e){var t=e.rules,o=new q.Plugin({state:{init:function(){return null},apply:function(e,t){var o=e.getMeta(this);return o?o:e.selectionSet||e.docChanged?null:t}},props:{handleTextInput:function(e,r,d,i){return n(e,r,d,i,t,o)},handleDOMEvents:{compositionend:function(e){setTimeout(function(){var r=e.state.selection,d=r.$cursor;d&&n(e,d.pos,d.pos,"",t,o)})}}},isInputRules:!0});return o},t.undoInputRule=r,t.emDash=i,t.ellipsis=p,t.openDoubleQuote=a,t.closeDoubleQuote=l,t.openSingleQuote=c,t.closeSingleQuote=h,t.smartQuotes=[a,l,c,h],t.wrappingInputRule=function(e,t,o,n){return new d(e,function(e,r,d,i){var p=o instanceof Function?o(r):o,a=e.tr.delete(d,i),s=a.doc.resolve(d),l=s.blockRange(),c=l&&T.findWrapping(l,t,p);if(!c)return null;a.wrap(l,c);var h=a.doc.resolve(d-1).nodeBefore;return h&&h.type==t&&T.canJoin(a.doc,d-1)&&(!n||n(r,h))&&a.join(d-1),a})},t.textblockTypeInputRule=function(e,t,o){return new d(e,function(e,n,r,d){var i=e.doc.resolve(r),p=o instanceof Function?o(n):o;return i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),t)?e.tr.delete(r,d).setBlockType(r,r,t,p):null})}});t(Te);var Ne=Te.InputRule,Oe=Te.inputRules,Ae=Te.undoInputRule,De=Te.emDash,Re=Te.ellipsis,Ie=Te.openDoubleQuote,Pe=Te.closeDoubleQuote,Ee=Te.openSingleQuote,$e=Te.closeSingleQuote,ze=Te.smartQuotes,Fe=Te.wrappingInputRule,Be=Te.textblockTypeInputRule,_e=o(function(e,t){function o(e,t){return!e.selection.empty&&(t&&t(e.tr.deleteSelection().scrollIntoView()),!0)}function n(e,t,o){var n=e.selection,d=n.$cursor;if(!d||(o?!o.endOfTextblock("backward",e):0<d.parentOffset))return!1;var p=i(d);if(!p){var a=d.blockRange(),s=a&&T.liftTarget(a);return null!=s&&(t&&t(e.tr.lift(a,s).scrollIntoView()),!0)}var l=p.nodeBefore;if(!l.type.spec.isolating&&S(e,p,t))return!0;if(0==d.parent.content.size&&(r(l,"end")||q.NodeSelection.isSelectable(l))){if(t){var c=e.tr.deleteRange(d.before(),d.after());c.setSelection(r(l,"end")?q.Selection.findFrom(c.doc.resolve(c.mapping.map(p.pos,-1)),-1):q.NodeSelection.create(c.doc,p.pos-l.nodeSize)),t(c.scrollIntoView())}return!0}return!!(l.isAtom&&p.depth==d.depth-1)&&(t&&t(e.tr.delete(p.pos-l.nodeSize,p.pos).scrollIntoView()),!0)}function r(e,t){for(;e;e="start"==t?e.firstChild:e.lastChild)if(e.isTextblock)return!0;return!1}function d(e,t,o){var n=e.selection,r=n.$cursor;if(!r||(o?!o.endOfTextblock("backward",e):0<r.parentOffset))return!1;var d=i(r),p=d&&d.nodeBefore;return!!(p&&q.NodeSelection.isSelectable(p))&&(t&&t(e.tr.setSelection(q.NodeSelection.create(e.doc,d.pos-p.nodeSize)).scrollIntoView()),!0)}function i(e){if(!e.parent.type.spec.isolating)for(var t=e.depth-1;0<=t;t--){if(0<e.index(t))return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function p(e,t,o){var n=e.selection,d=n.$cursor;if(!d||(o?!o.endOfTextblock("forward",e):d.parentOffset<d.parent.content.size))return!1;var i=s(d);if(!i)return!1;var p=i.nodeAfter;if(S(e,i,t))return!0;if(0==d.parent.content.size&&(r(p,"start")||q.NodeSelection.isSelectable(p))){if(t){var a=e.tr.deleteRange(d.before(),d.after());a.setSelection(r(p,"start")?q.Selection.findFrom(a.doc.resolve(a.mapping.map(i.pos)),1):q.NodeSelection.create(a.doc,a.mapping.map(i.pos))),t(a.scrollIntoView())}return!0}return!!(p.isAtom&&i.depth==d.depth-1)&&(t&&t(e.tr.delete(i.pos,i.pos+p.nodeSize).scrollIntoView()),!0)}function a(e,t,o){var n=e.selection,r=n.$cursor;if(!r||(o?!o.endOfTextblock("forward",e):r.parentOffset<r.parent.content.size))return!1;var d=s(r),i=d&&d.nodeAfter;return!!(i&&q.NodeSelection.isSelectable(i))&&(t&&t(e.tr.setSelection(q.NodeSelection.create(e.doc,d.pos)).scrollIntoView()),!0)}function s(e){if(!e.parent.type.spec.isolating)for(var t=e.depth-1,o;0<=t;t--){if(o=e.node(t),e.index(t)+1<o.childCount)return e.doc.resolve(e.after(t+1));if(o.type.spec.isolating)break}return null}function l(e,t){var o=e.selection,n=o.$head,r=o.$anchor;return!!(n.parent.type.spec.code&&n.sameParent(r))&&(t&&t(e.tr.insertText("\n").scrollIntoView()),!0)}function c(e,t){var o=e.selection,n=o.$head,r=o.$anchor;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;var d=n.node(-1),i=n.indexAfter(-1),p=d.contentMatchAt(i).defaultType;if(!d.canReplaceWith(i,i,p))return!1;if(t){var a=n.after(),s=e.tr.replaceWith(a,a,p.createAndFill());s.setSelection(q.Selection.near(s.doc.resolve(a),1)),t(s.scrollIntoView())}return!0}function m(e,t){var o=e.selection,n=o.$from,r=o.$to;if(n.parent.inlineContent||r.parent.inlineContent)return!1;var d=n.parent.contentMatchAt(r.indexAfter()).defaultType;if(!d||!d.isTextblock)return!1;if(t){var i=(!n.parentOffset&&r.index()<r.parent.childCount?n:r).pos,p=e.tr.insert(i,d.createAndFill());p.setSelection(q.TextSelection.create(p.doc,i+1)),t(p.scrollIntoView())}return!0}function f(e,t){var o=e.selection,n=o.$cursor;if(!n||n.parent.content.size)return!1;if(1<n.depth&&n.after()!=n.end(-1)){var r=n.before();if(T.canSplit(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}var d=n.blockRange(),i=d&&T.liftTarget(d);return null!=i&&(t&&t(e.tr.lift(d,i).scrollIntoView()),!0)}function g(e,t){var o=e.selection,n=o.$from,r=o.$to;if(e.selection instanceof q.NodeSelection&&e.selection.node.isBlock)return!!(n.parentOffset&&T.canSplit(e.doc,n.pos))&&(t&&t(e.tr.split(n.pos).scrollIntoView()),!0);if(!n.parent.isBlock)return!1;if(t){var d=r.parentOffset==r.parent.content.size,i=e.tr;e.selection instanceof q.TextSelection&&i.deleteSelection();var p=0==n.depth?null:n.node(-1).contentMatchAt(n.indexAfter(-1)).defaultType,a=d&&p?[{type:p}]:null,s=T.canSplit(i.doc,i.mapping.map(n.pos),1,a);a||s||!T.canSplit(i.doc,i.mapping.map(n.pos),1,p&&[{type:p}])||(a=[{type:p}],s=!0),s&&(i.split(i.mapping.map(n.pos),1,a),!d&&!n.parentOffset&&n.parent.type!=p&&n.node(-1).canReplace(n.index(-1),n.indexAfter(-1),h.Fragment.from(p.create(),n.parent))&&i.setNodeMarkup(i.mapping.map(n.before()),p)),t(i.scrollIntoView())}return!0}function u(e,t){return t&&t(e.tr.setSelection(new q.AllSelection(e.doc))),!0}function y(e,t,o){var n=t.nodeBefore,r=t.nodeAfter,d=t.index();return!!(n&&r&&n.type.compatibleContent(r.type))&&(!n.content.size&&t.parent.canReplace(d-1,d)?(o&&o(e.tr.delete(t.pos-n.nodeSize,t.pos).scrollIntoView()),!0):!!(t.parent.canReplace(d,d+1)&&(r.isTextblock||T.canJoin(e.doc,t.pos)))&&(o&&o(e.tr.clearIncompatible(t.pos,n.type,n.contentMatchAt(n.childCount)).join(t.pos).scrollIntoView()),!0))}function S(e,t,o){var n=t.nodeBefore,r=t.nodeAfter,d,p;if(n.type.spec.isolating||r.type.spec.isolating)return!1;if(y(e,t,o))return!0;if(t.parent.canReplace(t.index(),t.index()+1)&&(d=(p=n.contentMatchAt(n.childCount)).findWrapping(r.type))&&p.matchType(d[0]||r.type).validEnd){if(o){for(var a=t.pos+r.nodeSize,s=h.Fragment.empty,l=d.length-1;0<=l;l--)s=h.Fragment.from(d[l].create(null,s));s=h.Fragment.from(n.copy(s));var c=e.tr.step(new T.ReplaceAroundStep(t.pos-1,a,t.pos,a,new h.Slice(s,1,0),d.length,!0)),m=a+2*d.length;T.canJoin(c.doc,m)&&c.join(m),o(c.scrollIntoView())}return!0}var f=q.Selection.findFrom(t,1),g=f&&f.$from.blockRange(f.$to),u=g&&T.liftTarget(g);return!!(null!=u&&u>=t.depth)&&(o&&o(e.tr.lift(g,u).scrollIntoView()),!0)}function C(e,t,o){for(var n=function(n){var r=t[n],d=r.$from,i=r.$to,p=0==d.depth&&e.type.allowsMarkType(o);if(e.nodesBetween(d.pos,i.pos,function(e){return!p&&void(p=e.inlineContent&&e.type.allowsMarkType(o))}),p)return{v:!0}},r=0,d;r<t.length;r++)if(d=n(r),d)return d.v;return!1}function v(e,t){return function(o){if(!o.isGeneric)return e(o);for(var n=[],r=0,d;r<o.mapping.maps.length;r++){d=o.mapping.maps[r];for(var p=0;p<n.length;p++)n[p]=d.map(n[p]);d.forEach(function(e,t,o,r){return n.push(o,r)})}for(var a=[],s=0;s<n.length;s+=2)for(var l=n[s],c=n[s+1],h=o.doc.resolve(l),m=h.sharedDepth(c),f=h.node(m),g=h.indexAfter(m),u=h.after(m+1),y;u<=c&&(y=f.maybeChild(g),!!y);++g){if(g&&-1==a.indexOf(u)){var S=f.child(g-1);S.type==y.type&&t(S,y)&&a.push(u)}u+=y.nodeSize}a.sort(function(e,t){return e-t});for(var C=a.length-1;0<=C;C--)T.canJoin(o.doc,a[C])&&o.join(a[C]);e(o)}}function b(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return function(t,o,n){for(var r=0;r<e.length;r++)if(e[r](t,o,n))return!0;return!1}}Object.defineProperty(t,"__esModule",{value:!0});var w=b(o,n,d),x=b(o,p,a),k={Enter:b(l,m,f,g),"Mod-Enter":c,Backspace:w,"Mod-Backspace":w,Delete:x,"Mod-Delete":x,"Mod-a":u},M={"Ctrl-h":k.Backspace,"Alt-Backspace":k["Mod-Backspace"],"Ctrl-d":k.Delete,"Ctrl-Alt-Backspace":k["Mod-Delete"],"Alt-Delete":k["Mod-Delete"],"Alt-d":k["Mod-Delete"]};for(var N in k)M[N]=k[N];var O="undefined"==typeof navigator?"undefined"!=typeof os&&"darwin"==os.platform():/Mac/.test(navigator.platform),A=O?M:k;t.deleteSelection=o,t.joinBackward=n,t.selectNodeBackward=d,t.joinForward=p,t.selectNodeForward=a,t.joinUp=function(e,t){var o=e.selection,n=o instanceof q.NodeSelection,r;if(n){if(o.node.isTextblock||!T.canJoin(e.doc,o.from))return!1;r=o.from}else if(r=T.joinPoint(e.doc,o.from,-1),null==r)return!1;if(t){var d=e.tr.join(r);n&&d.setSelection(q.NodeSelection.create(d.doc,r-e.doc.resolve(r).nodeBefore.nodeSize)),t(d.scrollIntoView())}return!0},t.joinDown=function(e,t){var o=e.selection,n;if(o instanceof q.NodeSelection){if(o.node.isTextblock||!T.canJoin(e.doc,o.to))return!1;n=o.to}else if(n=T.joinPoint(e.doc,o.to,1),null==n)return!1;return t&&t(e.tr.join(n).scrollIntoView()),!0},t.lift=function(e,t){var o=e.selection,n=o.$from,r=o.$to,d=n.blockRange(r),i=d&&T.liftTarget(d);return null!=i&&(t&&t(e.tr.lift(d,i).scrollIntoView()),!0)},t.newlineInCode=l,t.exitCode=c,t.createParagraphNear=m,t.liftEmptyBlock=f,t.splitBlock=g,t.splitBlockKeepMarks=function(e,t){return g(e,t&&function(o){var n=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();n&&o.ensureMarks(n),t(o)})},t.selectParentNode=function(e,t){var o=e.selection,n=o.$from,r=o.to,d=n.sharedDepth(r),i;return 0!=d&&(i=n.before(d),t&&t(e.tr.setSelection(q.NodeSelection.create(e.doc,i))),!0)},t.selectAll=u,t.wrapIn=function(e,t){return function(o,n){var r=o.selection,d=r.$from,i=r.$to,p=d.blockRange(i),a=p&&T.findWrapping(p,e,t);return!!a&&(n&&n(o.tr.wrap(p,a).scrollIntoView()),!0)}},t.setBlockType=function(e,t){return function(o,n){var r=o.selection,d=r.from,i=r.to,p=!1;return(o.doc.nodesBetween(d,i,function(n,r){if(p)return!1;if(n.isTextblock&&!n.hasMarkup(e,t))if(n.type==e)p=!0;else{var d=o.doc.resolve(r),i=d.index();p=d.parent.canReplaceWith(i,i+1,e)}}),!!p)&&(n&&n(o.tr.setBlockType(d,i,e,t).scrollIntoView()),!0)}},t.toggleMark=function(e,t){return function(o,n){var r=o.selection,d=r.empty,p=r.$cursor,a=r.ranges;if(d&&!p||!C(o.doc,a,e))return!1;if(n)if(p)e.isInSet(o.storedMarks||p.marks())?n(o.tr.removeStoredMark(e)):n(o.tr.addStoredMark(e.create(t)));else{for(var s=!1,l=o.tr,c=0;!s&&c<a.length;c++){var h=a[c],m=h.$from,f=h.$to;s=o.doc.rangeHasMark(m.pos,f.pos,e)}for(var g=0;g<a.length;g++){var u=a[g],y=u.$from,S=u.$to;s?l.removeMark(y.pos,S.pos,e):l.addMark(y.pos,S.pos,e.create(t))}n(l.scrollIntoView())}return!0}},t.autoJoin=function(e,t){if(Array.isArray(t)){var o=t;t=function(e){return-1<o.indexOf(e.type.name)}}return function(o,n){return e(o,n&&v(n,t))}},t.chainCommands=b,t.pcBaseKeymap=k,t.macBaseKeymap=M,t.baseKeymap=A});t(_e);var Ve=_e.deleteSelection,Le=_e.joinBackward,Je=_e.selectNodeBackward,We=_e.joinForward,je=_e.selectNodeForward,Ke=_e.joinUp,qe=_e.joinDown,He=_e.lift,Ue=_e.newlineInCode,Ge=_e.exitCode,Xe=_e.createParagraphNear,Qe=_e.liftEmptyBlock,Ye=_e.splitBlock,Ze=_e.splitBlockKeepMarks,et=_e.selectParentNode,tt=_e.selectAll,ot=_e.wrapIn,nt=_e.setBlockType,rt=_e.toggleMark,dt=_e.autoJoin,it=_e.chainCommands,pt=_e.pcBaseKeymap,at=_e.macBaseKeymap,st=_e.baseKeymap,lt=o(function(e,t){function o(e,t){var o={};for(var n in e)o[n]=e[n];for(var r in t)o[r]=t[r];return o}function n(t,o,n,r,d){for(var p=h.Fragment.empty,a=n.length-1;0<=a;a--)p=h.Fragment.from(n[a].type.create(n[a].attrs,p));t.step(new T.ReplaceAroundStep(o.start-(r?2:0),o.end,o.start,o.end,new h.Slice(p,0,0),n.length,!0));for(var s=0,l=0;l<n.length;l++)n[l].type==d&&(s=l+1);for(var c=n.length-s,m=o.start+n.length-(r?2:0),f=o.parent,g=o.startIndex,u=o.endIndex,e=!0;g<u;g++,e=!1)!e&&T.canSplit(t.doc,m,c)&&(t.split(m,c),m+=2*c),m+=f.child(g).nodeSize;return t}function r(e,t,o,n){var r=e.tr,d=n.end,i=n.$to.end(n.depth);return d<i&&(r.step(new T.ReplaceAroundStep(d-1,i,d,i,new h.Slice(h.Fragment.from(o.create(null,n.parent.copy())),1,0),1,!0)),n=new h.NodeRange(r.doc.resolve(n.$from.pos),r.doc.resolve(i),n.depth)),t(r.lift(n,T.liftTarget(n)).scrollIntoView()),!0}function d(t,o,n){for(var r=t.tr,d=n.parent,p=n.end,a=n.endIndex-1,s=n.startIndex;a>s;a--)p-=d.child(a).nodeSize,r.delete(p-1,p+1);var e=r.doc.resolve(n.start),l=e.nodeAfter,c=0==n.startIndex,m=n.endIndex==d.childCount,f=e.node(-1),g=e.index(-1);if(!f.canReplace(g+(c?0:1),g+1,l.content.append(m?h.Fragment.empty:h.Fragment.from(d))))return!1;var u=e.pos,y=u+l.nodeSize;return r.step(new T.ReplaceAroundStep(u-(c?1:0),y+(m?1:0),u+1,y-1,new h.Slice((c?h.Fragment.empty:h.Fragment.from(d.copy(h.Fragment.empty))).append(m?h.Fragment.empty:h.Fragment.from(d.copy(h.Fragment.empty))),c?0:1,m?0:1),c?0:1)),o(r.scrollIntoView()),!0}Object.defineProperty(t,"__esModule",{value:!0});var i=["ol",0],p=["ul",0],a=["li",0],s={attrs:{order:{default:1}},parseDOM:[{tag:"ol",getAttrs:function(e){return{order:e.hasAttribute("start")?+e.getAttribute("start"):1}}}],toDOM:function(e){return 1==e.attrs.order?i:["ol",{start:e.attrs.order},0]}},l={parseDOM:[{tag:"ul"}],toDOM:function(){return p}},c={parseDOM:[{tag:"li"}],toDOM:function(){return a},defining:!0};t.orderedList=s,t.bulletList=l,t.listItem=c,t.addListNodes=function(e,t,n){return e.append({ordered_list:o(s,{content:"list_item+",group:n}),bullet_list:o(l,{content:"list_item+",group:n}),list_item:o(c,{content:t})})},t.wrapInList=function(e,t){return function(o,r){var d=o.selection,i=d.$from,p=d.$to,a=i.blockRange(p),s=!1,l=a;if(!a)return!1;if(2<=a.depth&&i.node(a.depth-1).type.compatibleContent(e)&&0==a.startIndex){if(0==i.index(a.depth-1))return!1;var c=o.doc.resolve(a.start-2);l=new h.NodeRange(c,c,a.depth),a.endIndex<a.parent.childCount&&(a=new h.NodeRange(i,o.doc.resolve(p.end(a.depth)),a.depth)),s=!0}var m=T.findWrapping(l,e,t,a);return!!m&&(r&&r(n(o.tr,a,m,s,e).scrollIntoView()),!0)}},t.splitListItem=function(e){return function(t,o){var n=t.selection,r=n.$from,i=n.$to,p=n.node;if(p&&p.isBlock||2>r.depth||!r.sameParent(i))return!1;var a=r.node(-1);if(a.type!=e)return!1;if(0==r.parent.content.size){if(2==r.depth||r.node(-3).type!=e||r.index(-2)!=r.node(-2).childCount-1)return!1;if(o){for(var s=h.Fragment.empty,l=0<r.index(-1),c=r.depth-(l?1:2);c>=r.depth-3;c--)s=h.Fragment.from(r.node(c).copy(s));s=s.append(h.Fragment.from(e.createAndFill()));var m=t.tr.replace(r.before(l?null:-1),r.after(-3),new h.Slice(s,l?3:2,2));m.setSelection(t.selection.constructor.near(m.doc.resolve(r.pos+(l?3:2)))),o(m.scrollIntoView())}return!0}var f=i.pos==r.end()?a.contentMatchAt(r.indexAfter(-1)).defaultType:null,g=t.tr.delete(r.pos,i.pos),u=f&&[null,{type:f}];return!!T.canSplit(g.doc,r.pos,2,u)&&(o&&o(g.split(r.pos,2,u).scrollIntoView()),!0)}},t.liftListItem=function(e){return function(t,o){var n=t.selection,i=n.$from,p=n.$to,a=i.blockRange(p,function(t){return t.childCount&&t.firstChild.type==e});return!!a&&(!o||(i.node(a.depth-1).type==e?r(t,o,e,a):d(t,o,a)))}},t.sinkListItem=function(e){return function(t,o){var n=t.selection,r=n.$from,d=n.$to,i=r.blockRange(d,function(t){return t.childCount&&t.firstChild.type==e});if(!i)return!1;var p=i.startIndex;if(0==p)return!1;var a=i.parent,s=a.child(p-1);if(s.type!=e)return!1;if(o){var l=s.lastChild&&s.lastChild.type==a.type,c=h.Fragment.from(l?e.create():null),m=new h.Slice(h.Fragment.from(e.create(null,h.Fragment.from(a.type.create(null,c)))),l?3:1,0),f=i.start,g=i.end;o(t.tr.step(new T.ReplaceAroundStep(f-(l?3:1),g,f,g,m,1,!0)).scrollIntoView())}return!0}}});t(lt);var ct=lt.orderedList,ht=lt.bulletList,mt=lt.listItem,ft=lt.addListNodes,gt=lt.wrapInList,ut=lt.splitListItem,yt=lt.liftListItem,St=lt.sinkListItem,Ct=o(function(e,t){function o(e){if("table"!=e.type.spec.tableRole)throw new RangeError("Not a table node: "+e.type.name);for(var t=n(e),o=e.childCount,d=[],p=0,a=null,s=[],l=0;l<t*o;l++)d[l]=0;for(var c=0,m=0,f;c<o;c++){f=e.child(c),m++;for(var g=0;;g++){for(;p<d.length&&0!=d[p];)p++;if(g==f.childCount)break;for(var u=f.child(g),y=u.attrs,S=y.colspan,C=y.rowspan,v=y.colwidth,b=0;b<C;b++){if(b+c>=o){(a||(a=[])).push({type:"overlong_rowspan",pos:m,n:C-b});break}for(var x=p+b*t,k=0;k<S;k++){0==d[x+k]?d[x+k]=m:(a||(a=[])).push({type:"collision",row:c,pos:m,n:S-k});var M=v&&v[k];if(M){var T=2*((x+k)%t),N=s[T];null==N||N!=M&&1==s[T+1]?(s[T]=M,s[T+1]=1):N==M&&s[T+1]++}}}p+=S,m+=u.nodeSize}for(var O=(c+1)*t,A=0;p<O;)0==d[p++]&&A++;A&&(a||(a=[])).push({type:"missing",row:c,n:A}),m++}for(var D=new Ee(t,o,d,a),R=!1,I=0;!R&&I<s.length;I+=2)null!=s[I]&&s[I+1]<o&&(R=!0);return R&&r(D,s,e),D}function n(e){for(var t=-1,o=!1,n=0;n<e.childCount;n++){var r=e.child(n),d=0;if(o)for(var p=0,a;p<n;p++){a=e.child(p);for(var l=0,c;l<a.childCount;l++)c=a.child(l),p+c.attrs.rowspan>n&&(d+=c.attrs.colspan)}for(var h=0,m;h<r.childCount;h++)m=r.child(h),d+=m.attrs.colspan,1<m.attrs.rowspan&&(o=!0);-1==t?t=d:t!=d&&(t=s(t,d))}return t}function r(e,t,o){e.problems||(e.problems=[]);for(var n=0,r={},p;n<e.map.length;n++)if(p=e.map[n],!r[p]){r[p]=!0;for(var a=o.nodeAt(p),s=null,l=0;l<a.attrs.colspan;l++){var c=(n+l)%e.width,h=t[2*c];null==h||a.attrs.colwidth&&a.attrs.colwidth[l]==h||((s||(s=d(a.attrs)))[l]=h)}s&&e.problems.unshift({type:"colwidth mismatch",pos:p,colwidth:s})}}function d(e){if(e.colwidth)return e.colwidth.slice();for(var t=[],o=0;o<e.colspan;o++)t.push(0);return t}function i(e){for(var t=e.depth-1;0<t;t--)if("row"==e.node(t).type.spec.tableRole)return e.node(0).resolve(e.before(t+1));return null}function p(e){for(var t=e.depth-1,o;0<t;t--)if(o=e.node(t).type.spec.tableRole,"cell"===o||"header_cell"===o)return e.node(t);return null}function a(e){for(var t=e.selection.$head,o=t.depth;0<o;o--)if("row"==t.node(o).type.spec.tableRole)return!0;return!1}function c(e){var t=e.selection;return t.$anchorCell?t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell:t.node&&"cell"==t.node.type.spec.tableRole?t.$anchor:i(t.$head)||m(t.$head)}function m(e){for(var t=e.nodeAfter,o=e.pos,n;t;t=t.firstChild,o++)if(n=t.type.spec.tableRole,"cell"==n||"header_cell"==n)return e.doc.resolve(o);for(var r=e.nodeBefore,d=e.pos,i;r;r=r.lastChild,d--)if(i=r.type.spec.tableRole,"cell"==i||"header_cell"==i)return e.doc.resolve(d-r.nodeSize)}function f(e){return"row"==e.parent.type.spec.tableRole&&e.nodeAfter}function g(e){return e.node(0).resolve(e.pos+e.nodeAfter.nodeSize)}function u(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function y(e,t,o){var n=e.start(-1),r=Ee.get(e.node(-1)),d=r.nextCell(e.pos-n,t,o);return null==d?null:e.node(0).resolve(n+d)}function S(e,t,o){var n={};for(var r in e)n[r]=e[r];return n[t]=o,n}function C(e,t,o){void 0===o&&(o=1);var r=S(e,"colspan",e.colspan-o);return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(t,o),!r.colwidth.some(function(e){return 0<e})&&(r.colwidth=null)),r}function v(e,t,o){void 0===o&&(o=1);var r=S(e,"colspan",e.colspan+o);if(r.colwidth){r.colwidth=r.colwidth.slice();for(var d=0;d<o;d++)r.colwidth.splice(t,0,0)}return r}function b(e){if(!(e.selection instanceof ze))return null;var t=[];return e.selection.forEachCell(function(e,o){t.push(oe.Decoration.node(o,o+e.nodeSize,{class:"selectedCell"}))}),oe.DecorationSet.create(e.doc,t)}function w(e){var t=e.$from,o=e.$to;if(t.pos==o.pos||t.pos<t.pos-6)return!1;for(var n=t.pos,r=o.pos,i=t.depth;0<=i&&!(t.after(i+1)<t.end(i));i--,n++);for(var p=o.depth;0<=p&&!(o.before(p+1)>o.start(p));p--,r--);return n==r&&/row|table/.test(t.node(i).type.spec.tableRole)}function x(e){for(var t=e.$from,o=e.$to,n=t.depth,r,d,p;0<n;n--)if(p=t.node(n),"cell"===p.type.spec.tableRole||"header_cell"===p.type.spec.tableRole){r=p;break}for(var a=o.depth,s;0<a;a--)if(s=o.node(a),"cell"===s.type.spec.tableRole||"header_cell"===s.type.spec.tableRole){d=s;break}return r!==d&&0===o.parentOffset}function k(e,t,o){var n=(t||e).selection,r=(t||e).doc,d,i;if(!(n instanceof q.NodeSelection&&(i=n.node.type.spec.tableRole)))n instanceof q.TextSelection&&w(n)?d=q.TextSelection.create(r,n.from):n instanceof q.TextSelection&&x(n)&&(d=q.TextSelection.create(r,n.$from.start(),n.$from.end()));else if("cell"==i||"header_cell"==i)d=ze.create(r,n.from);else if("row"==i){var p=r.resolve(n.from+1);d=ze.rowSelection(p,p)}else if(!o){var a=Ee.get(n.node),s=n.from+1,l=s+a.map[a.width*a.height-1];d=ze.create(r,s+1,l)}return d&&(t||(t=e.tr)).setSelection(d),t}function M(e,t){var o=e.getAttribute("data-colwidth"),n=o&&/^\d+(,\d+)*$/.test(o)?o.split(",").map(function(e){return+e}):null,r=+(e.getAttribute("colspan")||1),d={colspan:r,rowspan:+(e.getAttribute("rowspan")||1),colwidth:n&&n.length==r?n:null};for(var i in t){var p=t[i].getFromDOM,a=p&&p(e);null!=a&&(d[i]=a)}return d}function N(e,t){var o={};for(var n in 1!=e.attrs.colspan&&(o.colspan=e.attrs.colspan),1!=e.attrs.rowspan&&(o.rowspan=e.attrs.rowspan),e.attrs.colwidth&&(o["data-colwidth"]=e.attrs.colwidth.join(",")),t){var r=t[n].setDOMAttr;r&&r(e.attrs[n],o)}return o}function O(e){var t=e.cached.tableNodeTypes;if(!t)for(var o in t=e.cached.tableNodeTypes={},e.nodes){var n=e.nodes[o],r=n.spec.tableRole;r&&(t[r]=n)}return t}function A(e){if(!e.size)return null;for(var t=e.content,o=e.openStart,n=e.openEnd;1==t.childCount&&(0<o&&0<n||"table"==t.firstChild.type.spec.tableRole);)o--,n--,t=t.firstChild.content;var r=t.firstChild,d=r.type.spec.tableRole,p=r.type.schema,a=[];if("row"==d)for(var l=0;l<t.childCount;l++){var c=t.child(l).content,m=l?0:s(0,o-1),f=l<t.childCount-1?0:s(0,n-1);(m||f)&&(c=R(O(p).row,new h.Slice(c,m,f)).content),a.push(c)}else if("cell"==d||"header_cell"==d)a.push(o||n?R(O(p).row,new h.Slice(t,o,n)).content:t);else return null;return D(p,a)}function D(e,t){for(var o=[],n=0,d;n<t.length;n++){d=t[n];for(var p=d.childCount-1;0<=p;p--)for(var a=d.child(p).attrs,l=a.rowspan,c=a.colspan,m=n;m<n+l;m++)o[m]=(o[m]||0)+c}for(var f=0,g=0;g<o.length;g++)f=s(f,o[g]);for(var u=0;u<o.length;u++)if(u>=t.length&&t.push(h.Fragment.empty),o[u]<f){for(var y=O(e).cell.createAndFill(),S=[],C=o[u];C<f;C++)S.push(y);t[u]=t[u].append(h.Fragment.from(S))}return{height:t.length,width:f,rows:t}}function R(e,t){var o=e.createAndFill(),n=new T.Transform(o).replace(0,o.content.size,t);return n.doc}function I(e,t,o){var n=e.width,r=e.height,d=e.rows;if(n!=t){for(var p=[],a=[],s=0;s<d.length;s++){for(var l=d[s],c=[],m=p[s]||0,f=0,g;m<t;f++){g=l.child(f%l.childCount),m+g.attrs.colspan>t&&(g=g.type.create(C(g.attrs,g.attrs.colspan,m+g.attrs.colspan-t),g.content)),c.push(g),m+=g.attrs.colspan;for(var u=1;u<g.attrs.rowspan;u++)p[s+u]=(p[s+u]||0)+g.attrs.colspan}a.push(h.Fragment.from(c))}d=a,n=t}if(r!=o){for(var y=[],v=0,b=0;v<o;v++,b++){for(var w=[],x=d[b%r],k=0,M;k<x.childCount;k++)M=x.child(k),v+M.attrs.rowspan>o&&(M=M.type.create(S(M.attrs,"rowspan",o-M.attrs.rowspan),M.content)),w.push(M);y.push(h.Fragment.from(w))}d=y,r=o}return{width:n,height:r,rows:d}}function P(e,t,o,n,r,d,p){var a=e.doc.type.schema,l=O(a),c,m;if(r>t.width)for(var f=0,g=0,u;f<t.height;f++){u=o.child(f),g+=u.nodeSize;var y=[],S=void 0;S=null==u.lastChild||u.lastChild.type==l.cell?c||(c=l.cell.createAndFill()):m||(m=l.header_cell.createAndFill());for(var C=t.width;C<r;C++)y.push(S);e.insert(e.mapping.slice(p).map(g-1+n),y)}if(d>t.height){for(var v=[],b=0,w=(t.height-1)*t.width,x;b<s(t.width,r);b++)x=!(b>=t.width)&&o.nodeAt(t.map[w+b]).type==l.header_cell,v.push(x?m||(m=l.header_cell.createAndFill()):c||(c=l.cell.createAndFill()));for(var k=l.row.create(null,h.Fragment.from(v)),M=[],T=t.height;T<d;T++)M.push(k);e.insert(e.mapping.slice(p).map(n+o.nodeSize-2),M)}return!!(c||m)}function E(e,t,o,n,r,d,i,p){if(0==i||i==t.height)return!1;for(var a=!1,s=r;s<d;s++){var l=i*t.width+s,c=t.map[l];if(t.map[l-t.width]==c){a=!0;var h=o.nodeAt(c),m=t.findCell(c),f=m.top,g=m.left;e.setNodeMarkup(e.mapping.slice(p).map(c+n),null,S(h.attrs,"rowspan",i-f)),e.insert(e.mapping.slice(p).map(t.positionAt(i,g,o)),h.type.createAndFill(S(h.attrs,"rowspan",f+h.attrs.rowspan-i))),s+=h.attrs.colspan-1}}return a}function $(e,t,o,n,r,d,i,p){if(0==i||i==t.width)return!1;for(var a=!1,s=r;s<d;s++){var l=s*t.width+i,c=t.map[l];if(t.map[l-1]==c){a=!0;var h=o.nodeAt(c),m=t.colCount(c),f=e.mapping.slice(p).map(c+n);e.setNodeMarkup(f,null,C(h.attrs,i-m,h.attrs.colspan-(i-m))),e.insert(f+h.nodeSize,h.type.createAndFill(C(h.attrs,0,i-m))),s+=h.attrs.rowspan-1}}return a}function z(e,t,o,n,r){function d(){i=o?m.doc.nodeAt(o-1):m.doc,p=Ee.get(i),f=m.mapping.maps.length}var i=o?e.doc.nodeAt(o-1):e.doc,p=Ee.get(i),a=n.top,s=n.left,l=s+r.width,c=a+r.height,m=e.tr,f=0;P(m,p,i,o,l,c,f)&&d(),E(m,p,i,o,s,l,a,f)&&d(),E(m,p,i,o,s,l,c,f)&&d(),$(m,p,i,o,a,c,s,f)&&d(),$(m,p,i,o,a,c,l,f)&&d();for(var g=a;g<c;g++){var u=p.positionAt(g,s,i),y=p.positionAt(g,l,i);m.replace(m.mapping.slice(f).map(u+o),m.mapping.slice(f).map(y+o),new h.Slice(r.rows[g-a],0,0))}d(),m.setSelection(new ze(m.doc.resolve(o+p.positionAt(a,s,i)),m.doc.resolve(o+p.positionAt(c-1,l-1,i)))),t(m)}function F(e,t,o){return!o.eq(e.selection)&&(t&&t(e.tr.setSelection(o).scrollIntoView()),!0)}function B(e,t){return function(o,n,r){var d=o.selection;if(d instanceof ze)return F(o,n,q.Selection.near(d.$headCell,t));if("horiz"!=e&&!d.empty)return!1;var i=j(r,e,t);if(null==i)return!1;if("horiz"==e)return F(o,n,q.Selection.near(o.doc.resolve(d.head+t),t));var p=o.doc.resolve(i),a=y(p,e,t),s;return s=a?q.Selection.near(a,1):0>t?q.Selection.near(o.doc.resolve(p.before(-1)),-1):q.Selection.near(o.doc.resolve(p.after(-1)),1),F(o,n,s)}}function _(e,t){return function(o,n,r){var d=o.selection;if(!(d instanceof ze)){var i=j(r,e,t);if(null==i)return!1;d=new ze(o.doc.resolve(i))}var p=y(d.$headCell,e,t);return!!p&&F(o,n,new ze(d.$anchorCell,p))}}function V(e,t){var o=e.selection;if(!(o instanceof ze))return!1;if(t){var n=e.tr,r=O(e.schema).cell.createAndFill().content;o.forEachCell(function(e,t){e.content.eq(r)||n.replace(n.mapping.map(t+1),n.mapping.map(t+e.nodeSize-1),new h.Slice(r,0,0))}),n.docChanged&&t(n)}return!0}function L(e,t){var o=e.state.doc,n=i(o.resolve(t));return!!n&&(e.dispatch(e.state.tr.setSelection(new ze(n))),!0)}function J(e,t,o){if(!a(e.state))return!1;var n=A(o),r=e.state.selection;if(r instanceof ze){n||(n={width:1,height:1,rows:[h.Fragment.from(R(O(e.state.schema).cell,o))]});var d=r.$anchorCell.node(-1),i=r.$anchorCell.start(-1),p=Ee.get(d).rectBetween(r.$anchorCell.pos-i,r.$headCell.pos-i);return n=I(n,p.right-p.left,p.bottom-p.top),z(e.state,e.dispatch,i,p,n),!0}if(n){var s=c(e.state),l=s.start(-1);return z(e.state,e.dispatch,l,Ee.get(s.node(-1)).findCell(s.pos-l),n),!0}return!1}function W(e,t){function o(t,o){var n=H(e,o),r=null==$e.getState(e.state);if(!n||!u(t,n))if(r)n=t;else return;var d=new ze(t,n);if(r||!e.state.selection.eq(d)){var i=e.state.tr.setSelection(d);r&&i.setMeta($e,t.pos),e.dispatch(i)}}function n(){e.root.removeEventListener("mouseup",n),e.root.removeEventListener("dragstart",n),e.root.removeEventListener("mousemove",r),null!=$e.getState(e.state)&&e.dispatch(e.state.tr.setMeta($e,-1))}function r(r){var i=$e.getState(e.state),p;if(null!=i)p=e.state.doc.resolve(i);else if(K(e,r.target)!=d&&(p=H(e,t),!p))return n();p&&o(p,r)}if(!(t.ctrlKey||t.metaKey)){var d=K(e,t.target),p;if(t.shiftKey&&e.state.selection instanceof ze)o(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&d&&null!=(p=i(e.state.selection.$anchor))&&H(e,t).pos!=p.pos)o(p,t),t.preventDefault();else if(!d)return;e.root.addEventListener("mouseup",n),e.root.addEventListener("dragstart",n),e.root.addEventListener("mousemove",r)}}function j(e,t,o){if(!(e.state.selection instanceof q.TextSelection))return null;for(var n=e.state.selection,r=n.$head,i=r.depth-1;0<=i;i--){var p=r.node(i),a=0>o?r.index(i):r.indexAfter(i);if(a!=(0>o?0:p.childCount))return null;if("cell"==p.type.spec.tableRole||"header_cell"==p.type.spec.tableRole){var s=r.before(i),l="vert"==t?0<o?"down":"up":0<o?"right":"left";return e.endOfTextblock(l)?s:null}}return null}function K(e,t){for(;t&&t!=e.dom;t=t.parentNode)if("TD"==t.nodeName||"TH"==t.nodeName)return t}function H(e,t){var o=e.posAtCoords({left:t.clientX,top:t.clientY});return o?o?i(e.state.doc.resolve(o.pos)):null:null}function U(t,o,n,r){var d=t.childCount,p=o.childCount;outer:for(var a=0,s=0,c;a<p;a++){c=o.child(a);for(var h=s,m=l(d,a+3);h<m;h++)if(t.child(h)==c){s=h+1,n+=c.nodeSize;continue outer}r(c,n),s<d&&t.child(s).sameMarkup(c)?U(t.child(s),c,n+1,r):c.nodesBetween(0,c.content.size,r,n+1),n+=c.nodeSize}}function G(e,t){var o=function(t,o){"table"==t.type.spec.tableRole&&(n=X(e,t,o,n))},n;return t?t.doc!=e.doc&&U(t.doc,e.doc,0,o):e.doc.descendants(o),n}function X(e,t,o,n){var r=Ee.get(t);if(!r.problems)return n;n||(n=e.tr);for(var d=[],p=0;p<r.height;p++)d.push(0);for(var a=0,s;a<r.problems.length;a++)if(s=r.problems[a],"collision"==s.type){for(var l=t.nodeAt(s.pos),c=0;c<l.attrs.rowspan;c++)d[s.row+c]+=s.n;n.setNodeMarkup(n.mapping.map(o+1+s.pos),null,C(l.attrs,l.attrs.colspan-s.n,s.n))}else if("missing"==s.type)d[s.row]+=s.n;else if("overlong_rowspan"==s.type){var h=t.nodeAt(s.pos);n.setNodeMarkup(n.mapping.map(o+1+s.pos),null,S(h.attrs,"rowspan",h.attrs.rowspan-s.n))}else if("colwidth mismatch"==s.type){var m=t.nodeAt(s.pos);n.setNodeMarkup(n.mapping.map(o+1+s.pos),null,S(m.attrs,"colwidth",s.colwidth))}for(var f=0,g,u;f<d.length;f++)d[f]&&(null==g&&(g=f),u=f);for(var y=0,v=o+1;y<r.height;y++){var b=t.child(y),w=v+b.nodeSize,x=d[y];if(0<x){var k="cell";b.firstChild&&(k=b.firstChild.type.spec.tableRole);for(var M=[],T=0;T<x;T++)M.push(O(e.schema)[k].createAndFill());var N=(0==y||g==y-1)&&u==y?v+1:w-1;n.insert(n.mapping.map(N),M)}v=w}return n}function Q(e){var t=e.selection,o=c(e),n=o.node(-1),r=o.start(-1),d=Ee.get(n),i;return i=t instanceof ze?d.rectBetween(t.$anchorCell.pos-r,t.$headCell.pos-r):d.findCell(o.pos-r),i.tableStart=r,i.map=d,i.table=n,i}function Y(e,t,o){for(var n=O(t.type.schema).header_cell,r=0;r<e.height;r++)if(t.nodeAt(e.map[o+r*e.width]).type!=n)return!1;return!0}function Z(e,t,o){var n=t.map,r=t.tableStart,d=t.table,i=0<o?-1:0;Y(n,d,o+i)&&(i=0==o||o==n.width?null:0);for(var p=0,a;p<n.height;p++)if(a=p*n.width+o,0<o&&o<n.width&&n.map[a-1]==n.map[a]){var s=n.map[a],l=d.nodeAt(s);e.setNodeMarkup(e.mapping.map(r+s),null,v(l.attrs,o-n.colCount(s))),p+=l.attrs.rowspan-1}else{var c=null==i?O(d.type.schema).cell:d.nodeAt(n.map[a+i]).type,h=n.positionAt(p,o,d);e.insert(e.mapping.map(r+h),c.createAndFill())}return e}function ee(e,t,o){for(var n=t.map,r=t.table,d=t.tableStart,i=e.mapping.maps.length,p=0;p<n.height;){var a=p*n.width+o,s=n.map[a],l=r.nodeAt(s);if(0<o&&n.map[a-1]==s||o<n.width-1&&n.map[a+1]==s)e.setNodeMarkup(e.mapping.slice(i).map(d+s),null,C(l.attrs,o-n.colCount(s)));else{var c=e.mapping.slice(i).map(d+s);e.delete(c,c+l.nodeSize)}p+=l.attrs.rowspan}}function te(e,t){if(!a(e))return!1;if(t){var o=Q(e),n=e.tr;if(0==o.left&&o.right==o.map.width)return!1;for(var r=o.right-1;;r--){if(ee(n,o,r),r==o.left)break;o.table=o.tableStart?n.doc.nodeAt(o.tableStart-1):n.doc,o.map=Ee.get(o.table)}t(n)}return!0}function ne(e,t,o){for(var n=O(t.type.schema).header_cell,r=0;r<e.width;r++)if(t.nodeAt(e.map[r+o*e.width]).type!=n)return!1;return!0}function re(e,t,o){for(var n=t.map,r=t.tableStart,d=t.table,p=r,a=0;a<o;a++)p+=d.child(a).nodeSize;var s=[],l=0<o?-1:0;ne(n,d,o+l)&&(l=0==o||o==n.height?null:0);for(var c=0,h=n.width*o;c<n.width;c++,h++)if(0<o&&o<n.height&&n.map[h]==n.map[h-n.width]){var m=n.map[h],f=d.nodeAt(m).attrs;e.setNodeMarkup(r+m,null,S(f,"rowspan",f.rowspan+1)),c+=f.colspan-1}else{var g=null==l?O(d.type.schema).cell:d.nodeAt(n.map[h+l*n.width]).type;s.push(g.createAndFill())}return e.insert(p,O(d.type.schema).row.create(null,s)),e}function de(e,t,o){for(var n=t.map,r=t.table,d=t.tableStart,p=0,a=0;a<o;a++)p+=r.child(a).nodeSize;var s=p+r.child(o).nodeSize,l=e.mapping.maps.length;e.delete(p+d,s+d);for(var c=0,h=o*n.width,m;c<n.width;c++,h++)if(m=n.map[h],0<o&&m==n.map[h-n.width]){var f=r.nodeAt(m).attrs;e.setNodeMarkup(e.mapping.slice(l).map(m+d),null,S(f,"rowspan",f.rowspan-1)),c+=f.colspan-1}else if(o<n.width&&m==n.map[h+n.width]){var g=r.nodeAt(m),u=g.type.create(S(g.attrs,"rowspan",g.attrs.rowspan-1),g.content),y=n.positionAt(o+1,c,r);e.insert(e.mapping.slice(l).map(d+y),u),c+=g.attrs.colspan-1}}function ie(e,t){if(!a(e))return!1;if(t){var o=Q(e),n=e.tr;if(0==o.top&&o.bottom==o.map.height)return!1;for(var r=o.bottom-1;;r--){if(de(n,o,r),r==o.top)break;o.table=o.tableStart?n.doc.nodeAt(o.tableStart-1):n.doc,o.map=Ee.get(o.table)}t(n)}return!0}function pe(e){var t=e.content;return 1==t.childCount&&t.firstChild.isTextblock&&0==t.firstChild.childCount}function ae(e,t){for(var o=e.width,n=e.height,r=e.map,d=t.top*o+t.left,p=d,a=(t.bottom-1)*o+t.left,s=d+(t.right-t.left-1),l=t.top;l<t.bottom;l++){if(0<t.left&&r[p]==r[p-1]||t.right<o&&r[s]==r[s+1])return!0;p+=o,s+=o}for(var c=t.left;c<t.right;c++){if(0<t.top&&r[d]==r[d-o]||t.bottom<n&&r[a]==r[a+o])return!0;d++,a++}return!1}function se(e){return function(t,o){var n=t.selection,r,d;if(!(n instanceof ze)){if(r=p(n.$from),!r)return!1;d=i(n.$from).pos}else{if(n.$anchorCell.pos!=n.$headCell.pos)return!1;r=n.$anchorCell.nodeAfter,d=n.$anchorCell.pos}if(1==r.attrs.colspan&&1==r.attrs.rowspan)return!1;if(o){var a=r.attrs,s=[],l=a.colwidth;1<a.rowspan&&(a=S(a,"rowspan",1)),1<a.colspan&&(a=S(a,"colspan",1));for(var c=Q(t),h=t.tr,m=0;m<c.right-c.left;m++)s.push(l?S(a,"colwidth",l&&l[m]?[l[m]]:null):a);for(var f=c.top,g,u;f<c.bottom;f++){u=c.map.positionAt(f,c.left,c.table),f==c.top&&(u+=r.nodeSize);for(var y=c.left,C=0;y<c.right;y++,C++)(y!=c.left||f!=c.top)&&h.insert(g=h.mapping.map(u+c.tableStart,1),e({node:r,row:f,col:y}).createAndFill(s[C]))}h.setNodeMarkup(d,e({node:r,row:c.top,col:c.left}),s[0]),n instanceof ze&&h.setSelection(new ze(h.doc.resolve(n.$anchorCell.pos),g&&h.doc.resolve(g))),o(h)}return!0}}function le(e){return function(t,o){if(!a(t))return!1;if(o){for(var n=O(t.schema),r=Q(t),d=t.tr,p=r.map.cellsInRect("column"==e?new Pe(r.left,0,r.right,r.map.height):"row"==e?new Pe(0,r.top,r.map.width,r.bottom):r),s=p.map(function(e){return r.table.nodeAt(e)}),l=0;l<p.length;l++)s[l].type==n.header_cell&&d.setNodeMarkup(r.tableStart+p[l],n.cell,s[l].attrs);if(0==d.steps.length)for(var c=0;c<p.length;c++)d.setNodeMarkup(r.tableStart+p[c],n.header_cell,s[c].attrs);o(d)}return!0}}function ce(e,t,o){for(var n=t.map.cellsInRect({left:0,top:0,right:"row"==e?t.map.width:1,bottom:"column"==e?t.map.height:1}),r=0,d;r<n.length;r++)if(d=t.table.nodeAt(n[r]),d&&d.type!==o.header_cell)return!1;return!0}function he(e,t){return t=t||{useDeprecatedLogic:!1},t.useDeprecatedLogic?le(e):function(t,o){if(!a(t))return!1;if(o){var n=O(t.schema),r=Q(t),d=t.tr,i=ce("row",r,n),p=ce("column",r,n),s="column"===e?i:"row"==e&&p,l=s?1:0,c="column"==e?new Pe(0,l,1,r.map.height):"row"==e?new Pe(l,0,r.map.width,1):r,h="column"==e?p?n.cell:n.header_cell:"row"==e?i?n.cell:n.header_cell:n.cell;r.map.cellsInRect(c).forEach(function(e){var t=e+r.tableStart,o=d.doc.nodeAt(t);o&&d.setNodeMarkup(t,h,o.attrs)}),o(d)}return!0}}function me(e,t){if(0>t){var o=e.nodeBefore;if(o)return e.pos-o.nodeSize;for(var n=e.index(-1)-1,r=e.before(),d;0<=n;n--){if(d=e.node(-1).child(n),d.childCount)return r-1-d.lastChild.nodeSize;r-=d.nodeSize}}else{if(e.index()<e.parent.childCount-1)return e.pos+e.nodeAfter.nodeSize;for(var i=e.node(-1),p=e.indexAfter(-1),a=e.after(),s;p<i.childCount;p++){if(s=i.child(p),s.childCount)return a+1;a+=s.nodeSize}}}function fe(e,t,o,n,r,d){for(var p=0,a=!0,s=t.firstChild,l=e.firstChild,c=0,h=0;c<l.childCount;c++)for(var m=l.child(c).attrs,f=m.colspan,g=m.colwidth,u=0;u<f;u++,h++){var y=r==h?d:g&&g[u],S=y?y+"px":"";p+=y||n,y||(a=!1),s?(s.style.width!=S&&(s.style.width=S),s=s.nextSibling):t.appendChild(document.createElement("col")).style.width=S}for(;s;){var C=s.nextSibling;s.parentNode.removeChild(s),s=C}a?(o.style.width=p+"px",o.style.minWidth=""):(o.style.width="",o.style.minWidth=p+"px")}function ge(e,t,o,n,r){var d=We.getState(e.state);if(!d.dragging){var i=Ce(t.target),p=-1;if(i){var a=i.getBoundingClientRect(),s=a.left,l=a.right;t.clientX-s<=o?p=be(e,t,"left"):l-t.clientX<=o&&(p=be(e,t,"right"))}if(p!=d.activeHandle){if(!r&&-1!==p){var c=e.state.doc.resolve(p),h=c.node(-1),m=Ee.get(h),f=c.start(-1),g=m.colCount(c.pos-f)+c.nodeAfter.attrs.colspan-1;if(g==m.width-1)return}xe(e,p)}}}function ue(e){var t=We.getState(e.state);-1<t.activeHandle&&!t.dragging&&xe(e,-1)}function ye(e,t,o){function n(t){window.removeEventListener("mouseup",n),window.removeEventListener("mousemove",r);var d=We.getState(e.state);d.dragging&&(ke(e,d.activeHandle,we(d.dragging,t,o)),e.dispatch(e.state.tr.setMeta(We,{setDragging:null})))}function r(t){if(!t.which)return n(t);var r=We.getState(e.state),d=we(r.dragging,t,o);Me(e,r.activeHandle,d,o)}var d=We.getState(e.state);if(-1==d.activeHandle||d.dragging)return!1;var i=e.state.doc.nodeAt(d.activeHandle),p=Se(e,d.activeHandle,i.attrs);return e.dispatch(e.state.tr.setMeta(We,{setDragging:{startX:t.clientX,startWidth:p}})),window.addEventListener("mouseup",n),window.addEventListener("mousemove",r),t.preventDefault(),!0}function Se(e,t,o){var n=o.colspan,r=o.colwidth,d=r&&r[r.length-1];if(d)return d;var p=e.domAtPos(t),a=p.node.childNodes[p.offset],s=a.offsetWidth,l=n;if(r)for(var c=0;c<n;c++)r[c]&&(s-=r[c],l--);return s/l}function Ce(e){for(;e&&"TD"!=e.nodeName&&"TH"!=e.nodeName;)e=e.classList.contains("ProseMirror")?null:e.parentNode;return e}function be(e,t,o){var n=e.posAtCoords({left:t.clientX,top:t.clientY}),r=n.pos,d=i(e.state.doc.resolve(r));if(!d)return-1;if("right"==o)return d.pos;var p=Ee.get(d.node(-1)),a=d.start(-1),s=p.map.indexOf(d.pos-a);return 0==s%p.width?-1:a+p.map[s-1]}function we(e,t,o){var n=t.clientX-e.startX;return s(o,e.startWidth+n)}function xe(e,t){e.dispatch(e.state.tr.setMeta(We,{setHandle:t}))}function ke(e,t,o){for(var n=e.state.doc.resolve(t),r=n.node(-1),d=Ee.get(r),i=n.start(-1),p=d.colCount(n.pos-i)+n.nodeAfter.attrs.colspan-1,a=e.state.tr,s=0,l;s<d.height;s++)if(l=s*d.width+p,!(s&&d.map[l]==d.map[l-d.width])){var c=d.map[l],h=r.nodeAt(c),m=h.attrs,f=1==m.colspan?0:p-d.colCount(c);if(!(m.colwidth&&m.colwidth[f]==o)){var g=m.colwidth?m.colwidth.slice():Te(m.colspan);g[f]=o,a.setNodeMarkup(i+c,null,S(m,"colwidth",g))}}a.docChanged&&e.dispatch(a)}function Me(e,t,o,n){for(var r=e.state.doc.resolve(t),d=r.node(-1),i=r.start(-1),p=Ee.get(d).colCount(r.pos-i)+r.nodeAfter.attrs.colspan-1,a=e.domAtPos(r.start(-1)).node;"TABLE"!=a.nodeName;)a=a.parentNode;fe(d,a.firstChild,a,n,p,o)}function Te(e){for(var t=[],o=0;o<e;o++)t.push(0);return t}function Ne(e,t){for(var o=[],n=e.doc.resolve(t),r=n.node(-1),d=Ee.get(r),i=n.start(-1),p=d.colCount(n.pos-i)+n.nodeAfter.attrs.colspan,a=0,s;a<d.height;a++)if(s=p+a*d.width-1,(p==d.width||d.map[s]!=d.map[s+1])&&(0==a||d.map[s-1]!=d.map[s-1-d.width])){var l=d.map[s],c=i+l+r.nodeAt(l).nodeSize-1,h=document.createElement("div");h.className="column-resize-handle",o.push(oe.Decoration.widget(c,h))}return oe.DecorationSet.create(e.doc,o)}Object.defineProperty(t,"__esModule",{value:!0});var Oe,Ae;if("undefined"!=typeof WeakMap){var De=new WeakMap;Oe=function(e){return De.get(e)},Ae=function(e,t){return De.set(e,t),t}}else{var Re=[],Ie=0;Oe=function(e){for(var t=0;t<Re.length;t+=2)if(Re[t]==e)return Re[t+1]},Ae=function(e,t){return 10==Ie&&(Ie=0),Re[Ie++]=e,Re[Ie++]=t}}var Pe=function(e,t,o,n){this.left=e,this.top=t,this.right=o,this.bottom=n},Ee=function(e,t,o,n){this.width=e,this.height=t,this.map=o,this.problems=n};Ee.prototype.findCell=function(e){for(var t=this,o=0,n;o<this.map.length;o++)if(n=t.map[o],n==e){for(var r=o%t.width,d=0|o/t.width,p=r+1,a=d+1,s=1;p<this.width&&this.map[o+s]==n;s++)p++;for(var l=1;a<this.height&&this.map[o+this.width*l]==n;l++)a++;return new Pe(r,d,p,a)}throw new RangeError("No cell with offset "+e+" found")},Ee.prototype.colCount=function(e){for(var t=this,o=0;o<this.map.length;o++)if(t.map[o]==e)return o%t.width;throw new RangeError("No cell with offset "+e+" found")},Ee.prototype.nextCell=function(e,t,o){var n=this.findCell(e),r=n.left,d=n.right,i=n.top,p=n.bottom;return"horiz"==t?(0>o?0==r:d==this.width)?null:this.map[i*this.width+(0>o?r-1:d)]:(0>o?0==i:p==this.height)?null:this.map[r+this.width*(0>o?i-1:p)]},Ee.prototype.rectBetween=function(e,t){var o=this.findCell(e),n=o.left,r=o.right,d=o.top,i=o.bottom,p=this.findCell(t),a=p.left,c=p.right,h=p.top,m=p.bottom;return new Pe(l(n,a),l(d,h),s(r,c),s(i,m))},Ee.prototype.cellsInRect=function(e){for(var t=this,o=[],n={},r=e.top;r<e.bottom;r++)for(var d=e.left;d<e.right;d++){var i=r*t.width+d,p=t.map[i];n[p]||(n[p]=!0,d==e.left&&d&&t.map[i-1]==p||r==e.top&&r&&t.map[i-t.width]==p||o.push(p))}return o},Ee.prototype.positionAt=function(e,t,o){for(var n=this,r=0,d=0,p;;r++){if(p=d+o.child(r).nodeSize,r==e){for(var a=t+e*n.width,s=(e+1)*n.width;a<s&&this.map[a]<d;)a++;return a==s?p-1:n.map[a]}d=p}},Ee.get=function(e){return Oe(e)||Ae(e,o(e))};var $e=new q.PluginKey("selectingCells"),ze=function(e){function t(t,o){void 0===o&&(o=t);var n=t.node(-1),r=Ee.get(n),d=t.start(-1),i=r.rectBetween(t.pos-d,o.pos-d),p=t.node(0),a=r.cellsInRect(i).filter(function(e){return e!=o.pos-d});a.unshift(o.pos-d);var s=a.map(function(e){var t=n.nodeAt(e),o=e+d+1;return new q.SelectionRange(p.resolve(o),p.resolve(o+t.content.size))});e.call(this,s[0].$from,s[0].$to,s),this.$anchorCell=t,this.$headCell=o}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.map=function(e,o){var n=e.resolve(o.map(this.$anchorCell.pos)),r=e.resolve(o.map(this.$headCell.pos));if(f(n)&&f(r)&&u(n,r)){var d=this.$anchorCell.node(-1)!=n.node(-1);return d&&this.isRowSelection()?t.rowSelection(n,r):d&&this.isColSelection()?t.colSelection(n,r):new t(n,r)}return q.TextSelection.between(n,r)},t.prototype.content=function(){for(var e=this.$anchorCell.node(-1),t=Ee.get(e),o=this.$anchorCell.start(-1),n=t.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o),r={},d=[],i=n.top,p;i<n.bottom;i++){p=[];for(var a=i*t.width+n.left,c=n.left,m;c<n.right;c++,a++)if(m=t.map[a],!r[m]){r[m]=!0;var f=t.findCell(m),g=e.nodeAt(m),u=n.left-f.left,y=f.right-n.right;if(0<u||0<y){var v=g.attrs;0<u&&(v=C(v,0,u)),0<y&&(v=C(v,v.colspan-y,y)),g=f.left<n.left?g.type.createAndFill(v):g.type.create(v,g.content)}if(f.top<n.top||f.bottom>n.bottom){var b=S(g.attrs,"rowspan",l(f.bottom,n.bottom)-s(f.top,n.top));g=f.top<n.top?g.type.createAndFill(b):g.type.create(b,g.content)}p.push(g)}d.push(e.child(i).copy(h.Fragment.from(p)))}var w=this.isColSelection()&&this.isRowSelection()?e:d;return new h.Slice(h.Fragment.from(w),1,1)},t.prototype.replace=function(t,o){void 0===o&&(o=h.Slice.empty);for(var n=t.steps.length,r=this.ranges,d=0;d<r.length;d++){var p=r[d],a=p.$from,s=p.$to,l=t.mapping.slice(n);t.replace(l.map(a.pos),l.map(s.pos),d?h.Slice.empty:o)}var c=e.findFrom(t.doc.resolve(t.mapping.slice(n).map(this.to)),-1);c&&t.setSelection(c)},t.prototype.replaceWith=function(e,t){this.replace(e,new h.Slice(h.Fragment.from(t),0,0))},t.prototype.forEachCell=function(e){for(var t=this.$anchorCell.node(-1),o=Ee.get(t),n=this.$anchorCell.start(-1),r=o.cellsInRect(o.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n)),d=0;d<r.length;d++)e(t.nodeAt(r[d]),n+r[d])},t.prototype.isColSelection=function(){var e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(0<l(e,t))return!1;var o=e+this.$anchorCell.nodeAfter.attrs.rowspan,n=t+this.$headCell.nodeAfter.attrs.rowspan;return s(o,n)==this.$headCell.node(-1).childCount},t.colSelection=function(e,o){void 0===o&&(o=e);var n=Ee.get(e.node(-1)),r=e.start(-1),d=n.findCell(e.pos-r),i=n.findCell(o.pos-r),p=e.node(0);return d.top<=i.top?(0<d.top&&(e=p.resolve(r+n.map[d.left])),i.bottom<n.height&&(o=p.resolve(r+n.map[n.width*(n.height-1)+i.right-1]))):(0<i.top&&(o=p.resolve(r+n.map[i.left])),d.bottom<n.height&&(e=p.resolve(r+n.map[n.width*(n.height-1)+d.right-1]))),new t(e,o)},t.prototype.isRowSelection=function(){var e=Ee.get(this.$anchorCell.node(-1)),t=this.$anchorCell.start(-1),o=e.colCount(this.$anchorCell.pos-t),n=e.colCount(this.$headCell.pos-t);if(0<l(o,n))return!1;var r=o+this.$anchorCell.nodeAfter.attrs.colspan,d=n+this.$headCell.nodeAfter.attrs.colspan;return s(r,d)==e.width},t.prototype.eq=function(e){return e instanceof t&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos},t.rowSelection=function(e,o){void 0===o&&(o=e);var n=Ee.get(e.node(-1)),r=e.start(-1),d=n.findCell(e.pos-r),i=n.findCell(o.pos-r),p=e.node(0);return d.left<=i.left?(0<d.left&&(e=p.resolve(r+n.map[d.top*n.width])),i.right<n.width&&(o=p.resolve(r+n.map[n.width*(i.top+1)-1]))):(0<i.left&&(o=p.resolve(r+n.map[i.top*n.width])),d.right<n.width&&(e=p.resolve(r+n.map[n.width*(d.top+1)-1]))),new t(e,o)},t.prototype.toJSON=function(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}},t.fromJSON=function(e,o){return new t(e.resolve(o.anchor),e.resolve(o.head))},t.create=function(e,o,n){return void 0===n&&(n=o),new t(e.resolve(o),e.resolve(n))},t.prototype.getBookmark=function(){return new Fe(this.$anchorCell.pos,this.$headCell.pos)},t}(q.Selection);ze.prototype.visible=!1,q.Selection.jsonID("cell",ze);var Fe=function(e,t){this.anchor=e,this.head=t};Fe.prototype.map=function(e){return new Fe(e.map(this.anchor),e.map(this.head))},Fe.prototype.resolve=function(e){var t=e.resolve(this.anchor),o=e.resolve(this.head);return"row"==t.parent.type.spec.tableRole&&"row"==o.parent.type.spec.tableRole&&t.index()<t.parent.childCount&&o.index()<o.parent.childCount&&u(t,o)?new ze(t,o):q.Selection.near(o,1)};var Be=ve.keydownHandler({ArrowLeft:B("horiz",-1),ArrowRight:B("horiz",1),ArrowUp:B("vert",-1),ArrowDown:B("vert",1),"Shift-ArrowLeft":_("horiz",-1),"Shift-ArrowRight":_("horiz",1),"Shift-ArrowUp":_("vert",-1),"Shift-ArrowDown":_("vert",1),Backspace:V,"Mod-Backspace":V,Delete:V,"Mod-Delete":V}),_e=he("row",{useDeprecatedLogic:!0}),Ve=he("column",{useDeprecatedLogic:!0}),Le=he("cell",{useDeprecatedLogic:!0}),Je=function(e,t){this.node=e,this.cellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),fe(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))};Je.prototype.update=function(e){return e.type==this.node.type&&(this.node=e,fe(e,this.colgroup,this.table,this.cellMinWidth),!0)},Je.prototype.ignoreMutation=function(e){return"attributes"==e.type&&(e.target==this.table||this.colgroup.contains(e.target))};var We=new q.PluginKey("tableColumnResizing"),je=function(e,t){this.activeHandle=e,this.dragging=t};je.prototype.apply=function(e){var t=this,o=e.getMeta(We);if(o&&null!=o.setHandle)return new je(o.setHandle,null);if(o&&void 0!==o.setDragging)return new je(t.activeHandle,o.setDragging);if(-1<t.activeHandle&&e.docChanged){var n=e.mapping.map(t.activeHandle,-1);f(e.doc.resolve(n))||(n=null),t=new je(n,t.dragging)}return t},t.tableEditing=function(e){void 0===e&&(e={});var t=e.allowTableNodeSelection;return void 0===t&&(t=!1),new q.Plugin({key:$e,state:{init:function(){return null},apply:function(e,t){var o=e.getMeta($e);if(null!=o)return-1==o?null:o;if(null==t||!e.docChanged)return t;var n=e.mapping.mapResult(t),r=n.deleted,d=n.pos;return r?null:d}},props:{decorations:b,handleDOMEvents:{mousedown:W},createSelectionBetween:function(e){if(null!=$e.getState(e.state))return e.state.selection},handleTripleClick:L,handleKeyDown:Be,handlePaste:J},appendTransaction:function(e,o,n){return k(n,G(n,o),t)}})},t.fixTables=G,t.handlePaste=J,t.cellAround=i,t.isInTable=a,t.selectionCell=c,t.moveCellForward=g,t.inSameTable=u,t.findCell=function(e){return Ee.get(e.node(-1)).findCell(e.pos-e.start(-1))},t.colCount=function(e){return Ee.get(e.node(-1)).colCount(e.pos-e.start(-1))},t.nextCell=y,t.tableNodes=function(e){var t=e.cellAttributes||{},o={colspan:{default:1},rowspan:{default:1},colwidth:{default:null}};for(var n in t)o[n]={default:t[n].default};return{table:{content:"table_row+",tableRole:"table",isolating:!0,group:e.tableGroup,parseDOM:[{tag:"table"}],toDOM:function(){return["table",["tbody",0]]}},table_row:{content:"(table_cell | table_header)*",tableRole:"row",parseDOM:[{tag:"tr"}],toDOM:function(){return["tr",0]}},table_cell:{content:e.cellContent,attrs:o,tableRole:"cell",isolating:!0,parseDOM:[{tag:"td",getAttrs:function(e){return M(e,t)}}],toDOM:function(e){return["td",N(e,t),0]}},table_header:{content:e.cellContent,attrs:o,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:function(e){return M(e,t)}}],toDOM:function(e){return["th",N(e,t),0]}}}},t.CellSelection=ze,t.TableMap=Ee,t.columnResizing=function(e){void 0===e&&(e={});var t=e.handleWidth;void 0===t&&(t=5);var o=e.cellMinWidth;void 0===o&&(o=25);var n=e.View;void 0===n&&(n=Je);var r=e.lastColumnResizable;void 0===r&&(r=!0);var d=new q.Plugin({key:We,state:{init:function(e,t){return this.spec.props.nodeViews[O(t.schema).table.name]=function(e,t){return new n(e,o,t)},new je(-1,!1)},apply:function(e,t){return t.apply(e)}},props:{attributes:function(e){var t=We.getState(e);return-1<t.activeHandle?{class:"resize-cursor"}:null},handleDOMEvents:{mousemove:function(e,n){ge(e,n,t,o,r)},mouseleave:function(e){ue(e)},mousedown:function(e,t){ye(e,t,o)}},decorations:function(e){var t=We.getState(e);if(-1<t.activeHandle)return Ne(e,t.activeHandle)},nodeViews:{}}});return d},t.columnResizingPluginKey=We,t.updateColumnsOnResize=fe,t.__pastedCells=A,t.__insertCells=z,t.__clipCells=I,t.addColumn=Z,t.addColumnBefore=function(e,t){if(!a(e))return!1;if(t){var o=Q(e);t(Z(e.tr,o,o.left))}return!0},t.addColumnAfter=function(e,t){if(!a(e))return!1;if(t){var o=Q(e);t(Z(e.tr,o,o.right))}return!0},t.removeColumn=ee,t.deleteColumn=te,t.addRow=re,t.addRowBefore=function(e,t){if(!a(e))return!1;if(t){var o=Q(e);t(re(e.tr,o,o.top))}return!0},t.addRowAfter=function(e,t){if(!a(e))return!1;if(t){var o=Q(e);t(re(e.tr,o,o.bottom))}return!0},t.removeRow=de,t.deleteRow=ie,t.mergeCells=function(e,t){var o=e.selection;if(!(o instanceof ze)||o.$anchorCell.pos==o.$headCell.pos)return!1;var n=Q(e),r=n.map;if(ae(r,n))return!1;if(t){for(var d=e.tr,i={},p=h.Fragment.empty,a=n.top,s,l;a<n.bottom;a++)for(var c=n.left;c<n.right;c++){var m=r.map[a*r.width+c],f=n.table.nodeAt(m);if(!i[m])if(i[m]=!0,null==s)s=m,l=f;else{pe(f)||(p=p.append(f.content));var g=d.mapping.map(m+n.tableStart);d.delete(g,g+f.nodeSize)}}if(d.setNodeMarkup(s+n.tableStart,null,S(v(l.attrs,l.attrs.colspan,n.right-n.left-l.attrs.colspan),"rowspan",n.bottom-n.top)),p.size){var u=s+1+l.content.size,y=pe(l)?s+1:u;d.replaceWith(y+n.tableStart,u+n.tableStart,p)}d.setSelection(new ze(d.doc.resolve(s+n.tableStart))),t(d)}return!0},t.splitCell=function(e,t){var o=O(e.schema);return se(function(e){var t=e.node;return o[t.type.spec.tableRole]})(e,t)},t.splitCellWithType=se,t.setCellAttr=function(e,t){return function(o,n){if(!a(o))return!1;var r=c(o);if(r.nodeAfter.attrs[e]===t)return!1;if(n){var d=o.tr;o.selection instanceof ze?o.selection.forEachCell(function(o,n){o.attrs[e]!==t&&d.setNodeMarkup(n,null,S(o.attrs,e,t))}):d.setNodeMarkup(r.pos,null,S(r.nodeAfter.attrs,e,t)),n(d)}return!0}},t.toggleHeader=he,t.toggleHeaderRow=_e,t.toggleHeaderColumn=Ve,t.toggleHeaderCell=Le,t.goToNextCell=function(e){return function(t,o){if(!a(t))return!1;var n=me(c(t),e);if(null!=n){if(o){var r=t.doc.resolve(n);o(t.tr.setSelection(q.TextSelection.between(r,g(r))).scrollIntoView())}return!0}}},t.deleteTable=function(e,t){for(var o=e.selection.$anchor,n=o.depth,r;0<n;n--)if(r=o.node(n),"table"==r.type.spec.tableRole)return t&&t(e.tr.delete(o.before(n),o.after(n)).scrollIntoView()),!0;return!1}});t(Ct);var vt=Ct.tableEditing,bt=Ct.fixTables,wt=Ct.handlePaste,xt=Ct.cellAround,kt=Ct.isInTable,Mt=Ct.selectionCell,Tt=Ct.moveCellForward,Nt=Ct.inSameTable,Ot=Ct.findCell,At=Ct.colCount,Dt=Ct.nextCell,Rt=Ct.tableNodes,It=Ct.CellSelection,Pt=Ct.TableMap,Et=Ct.columnResizing,$t=Ct.columnResizingPluginKey,zt=Ct.updateColumnsOnResize,Ft=Ct.__pastedCells,Bt=Ct.__insertCells,_t=Ct.__clipCells,Vt=Ct.addColumn,Lt=Ct.addColumnBefore,Jt=Ct.addColumnAfter,Wt=Ct.removeColumn,jt=Ct.deleteColumn,Kt=Ct.addRow,qt=Ct.addRowBefore,Ht=Ct.addRowAfter,Ut=Ct.removeRow,Gt=Ct.deleteRow,Xt=Ct.mergeCells,Qt=Ct.splitCell,Yt=Ct.splitCellWithType,Zt=Ct.setCellAttr,eo=Ct.toggleHeader,to=Ct.toggleHeaderRow,oo=Ct.toggleHeaderColumn,no=Ct.toggleHeaderCell,ro=Ct.goToNextCell,io=Ct.deleteTable,po=o(function(e,t){function o(e){if(Array.isArray(e)){for(var t=0,o=Array(e.length);t<e.length;t++)o[t]=e[t];return o}return Array.from(e)}Object.defineProperty(t,"__esModule",{value:!0});var n=function(e,t){return function(o){Array.isArray(e)||(e=[e]);for(var n=0,r=e.length,d;n<r;n++)if(d=z(e[n])(o.selection),d){var p=u(d.pos,t)(o);if(p!==o)return p}return o}},r=function(e){return function(t){if(m(t.selection)){var o=t.selection,n=o.$from,r=o.$to;if(e instanceof h.Fragment&&n.parent.canReplace(n.index(),n.indexAfter(),e)||n.parent.canReplaceWith(n.index(),n.indexAfter(),e.type))return g(t.replaceWith(n.pos,r.pos,e).setSelection(new q.NodeSelection(t.doc.resolve(n.pos))))}return t}},d=function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1;return function(o){var n=q.Selection.findFrom(o.doc.resolve(e),t,!0);return n?o.setSelection(n):o}},i=function(e){return e.type&&e.type.spec.selectable},p=function(e){return i(e)&&e.type.isLeaf},a=function(e,t,o){return p(e)?o.setSelection(new q.NodeSelection(o.doc.resolve(t))):d(t)(o)},c=function(e,t,o){return function(d){var p="number"==typeof t,s=d.selection.$from,l=p?d.doc.resolve(t):m(d.selection)?d.doc.resolve(s.pos+1):s,c=l.parent;if(m(d.selection)&&o){var h=d;if(d=r(e)(d),h!==d)return d}if(b(c)){var f=d;if(d=n(c.type,e)(d),f!==d){var u=i(e)?l.before(l.depth):l.pos;return a(e,u,d)}}if(v(l,e)){d.insert(l.pos,e);var y=p?l.pos:i(e)?d.selection.$anchor.pos-1:d.selection.$anchor.pos;return g(a(e,y,d))}for(var S=l.depth;0<S;S--){var C=l.after(S),w=d.doc.resolve(C);if(v(w,e))return d.insert(C,e),g(a(e,C,d))}return d}},m=function(e){return e instanceof q.NodeSelection},f=function(e,t){return Array.isArray(e)&&-1<e.indexOf(t.type)||t.type===e},g=function(e){return Object.assign(Object.create(e),e).setTime(Date.now())},u=function(e,t){return function(o){var n=o.doc.nodeAt(e),r=o.doc.resolve(e);if(y(r,t)){o=o.replaceWith(e,e+n.nodeSize,t);var i=o.selection.$from.pos-1;return o=d(s(i,0),-1)(o),o=d(o.selection.$from.start())(o),g(o)}return o}},y=function(e,t){var o=e.node(e.depth);return o&&o.type.validContent(t instanceof h.Fragment?t:h.Fragment.from(t))},S=function(e){return function(t){var o=t.doc.nodeAt(e);return g(t.delete(e,e+o.nodeSize))}},C=function(e){if(e.cached.tableNodeTypes)return e.cached.tableNodeTypes;var t={};return Object.keys(e.nodes).forEach(function(o){var n=e.nodes[o];n.spec.tableRole&&(t[n.spec.tableRole]=n)}),e.cached.tableNodeTypes=t,t},v=function(e,t){var o=e.index();return t instanceof h.Fragment?e.parent.canReplace(o,o,t):!!(t instanceof h.Node)&&e.parent.canReplaceWith(o,o,t.type)},b=function(e){return!e||"paragraph"===e.type.name&&2===e.nodeSize},w=function(e){return P(e,function(e){return e.type.spec.tableRole&&/table/i.test(e.type.spec.tableRole)})},x=function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;return t?e.createChecked(null,t):e.createAndFill()},k=function(e){return function(t){for(var o=Ct.TableMap.get(t.$anchorCell.node(-1)),n=t.$anchorCell.start(-1),r=o.cellsInRect(e),d=o.cellsInRect(o.rectBetween(t.$anchorCell.pos-n,t.$headCell.pos-n)),p=0,a=r.length;p<a;p++)if(-1===d.indexOf(r[p]))return!1;return!0}},M=function(e){return e[0].map(function(t,o){return e.map(function(e){return e[o]})})},T=function(e){for(var t=Ct.TableMap.get(e),o=[],n=0;n<t.height;n++){for(var r=[],d={},i=0;i<t.width;i++){var p=t.map[n*t.width+i],a=e.nodeAt(p),s=t.findCell(p);if(d[p]||s.top!==n){r.push(null);continue}d[p]=!0,r.push(a)}o.push(r)}return o},N=function(e,t){for(var o=[],n=Ct.TableMap.get(e),r=0;r<n.height;r++){for(var d=e.child(r),i=[],p=0;p<n.width;p++)if(t[r][p]){var a=n.map[r*n.width+p],s=t[r][p],l=e.nodeAt(a),c=l.type.createChecked(Object.assign({},s.attrs),s.content,s.marks);i.push(c)}o.push(d.type.createChecked(d.attrs,i,d.marks))}var h=e.type.createChecked(e.attrs,o,e.marks);return h},O=function(e,t,o,n){var r=M(T(e.node));return r=D(r,t,o,n),r=M(r),N(e.node,r)},A=function(e,t,o,n){var r=T(e.node);return r=D(r,t,o,n),N(e.node,r)},D=function(e,t,o,n){var r=t[0]>o[0]?-1:1,d=e.splice(t[0],t.length),i=0==d.length%2?1:0,p=void 0;return p=-1===n&&1==r?o[0]-1:1===n&&-1==r?o[o.length-1]-i+1:-1==r?o[0]:o[o.length-1]-i,e.splice.apply(e,[p,0].concat(d)),e},R=function(e,t,o,n){var r=e>t?-1:1,d="Target position is invalid, you can't move the "+n+" "+e+" to "+t+", the target can't be split. You could use tryToFit option.";if(1==r){if(-1!==o.slice(0,o.length-1).indexOf(t))throw new Error(d);}else if(-1!==o.slice(1).indexOf(t))throw new Error(d);return!0},I=function(e){return function(t){var o=t.$from;return P(o,e)}},P=function(e,t){for(var o=e.depth,n;0<o;o--)if(n=e.node(o),t(n))return{pos:0<o?e.before(o):0,start:e.start(o),depth:o,node:n}},E=function(e,t){return function(o){var n=I(e)(o);if(n)return B(n.pos,t)}},$=function(e){return function(t){return!!I(e)(t)}},z=function(e){return function(t){return I(function(t){return f(e,t)})(t)}},F=function(e){var t=e.$from.nodeBefore,o=q.Selection.findFrom(e.$from,-1);if(o&&t){var n=z(t.type)(o);return n?n.pos:o.$from.pos}},B=function(e,t){var o=t(e),n=o.node.childNodes[o.offset];return o.node.nodeType===Node.TEXT_NODE?o.node.parentNode:n&&n.nodeType!==Node.TEXT_NODE?n:o.node},_=function(e){var t=!(1<arguments.length&&void 0!==arguments[1])||arguments[1];if(!e)throw new Error("Invalid \"node\" parameter");var o=[];return e.descendants(function(e,n){if(o.push({node:e,pos:n}),!t)return!1}),o},V=function(e,t,o){if(!e)throw new Error("Invalid \"node\" parameter");else if(!t)throw new Error("Invalid \"predicate\" parameter");return _(e,o).filter(function(e){return t(e.node)})},L=function(e,t,o){return V(e,function(e){return e.type===t},o)},J=function(e){return I(function(e){return e.type.spec.tableRole&&"table"===e.type.spec.tableRole})(e)},W=function(e){return e instanceof Ct.CellSelection},j=function(e){if(W(e)){var t=Ct.TableMap.get(e.$anchorCell.node(-1));return k({left:0,right:t.width,top:0,bottom:t.height})(e)}return!1},K=function(e){return function(t){var o=J(t);if(o){var n=Ct.TableMap.get(o.node),r=Array.isArray(e)?e:Array.from([e]);return r.reduce(function(e,t){if(0<=t&&t<=n.width-1){var r=n.cellsInRect({left:t,right:t+1,top:0,bottom:n.height});return e.concat(r.map(function(e){var t=o.node.nodeAt(e),n=e+o.start;return{pos:n,start:n+1,node:t}}))}},[])}}},H=function(e){return function(t){var o=J(t);if(o){var n=Ct.TableMap.get(o.node),r=Array.isArray(e)?e:Array.from([e]);return r.reduce(function(e,t){if(0<=t&&t<=n.height-1){var r=n.cellsInRect({left:0,right:n.width,top:t,bottom:t+1});return e.concat(r.map(function(e){var t=o.node.nodeAt(e),n=e+o.start;return{pos:n,start:n+1,node:t}}))}},[])}}},U=function(e){return function(t,o){return function(n){var r=J(n.selection),d="row"===e;if(r){var i=Ct.TableMap.get(r.node);if(0<=t&&t<(d?i.height:i.width)){var p=d?0:t,a=d?t:0,c=d?i.width:t+1,h=d?t+1:i.height;if(o){var m=de(n.selection.$from);if(!m)return n;var f=i.findCell(m.pos-r.start);d?(a=l(a,f.top),h=s(h,f.bottom)):(p=l(p,f.left),c=s(c,f.right))}var u=i.cellsInRect({left:p,top:a,right:d?c:p+1,bottom:d?a+1:h}),y=1==h-a?u:i.cellsInRect({left:d?p:c-1,top:d?h-1:a,right:c,bottom:h}),S=r.start+u[0],C=r.start+y[y.length-1],v=n.doc.resolve(S),b=n.doc.resolve(C);return g(n.setSelection(new Ct.CellSelection(b,v)))}}return n}}},G=U("column"),X=U("row"),Q=function(e){return function(t){var n=J(t.selection);if(n){var r=Ct.TableMap.get(n.node);if(0<=e&&e<=r.height){for(var d=n.node,p=C(d.type.schema),a=n.start,s=0;s<e+1;s++)a+=d.child(s).nodeSize;var l=d.child(e),h=[],m=0;if(l.forEach(function(e){1===e.attrs.rowspan&&(m+=e.attrs.colspan,h.push(p[e.type.spec.tableRole].createAndFill(e.attrs,e.marks)))}),m<r.width){for(var f=[],g=function(n){var r=pe(n,function(t){var o=t.node.attrs.rowspan;return 1<o&&n+o>e})(t);f.push.apply(f,o(r))},u=e;0<=u;u--)g(u);f.length&&f.forEach(function(e){t=ne(e,{rowspan:e.node.attrs.rowspan+1})(t)})}return c(p.row.create(l.attrs,h),a)(t)}}return t}},Y=function(e){return function(t){var o=J(t.selection);if(o){var n=Ct.TableMap.get(o.node);if(0===e&&1===n.width)return ee(t);if(0<=e&&e<=n.width)return Ct.removeColumn(t,{map:n,tableStart:o.start,table:o.node},e),g(t)}return t}},Z=function(e){return function(t){var o=J(t.selection);if(o){var n=Ct.TableMap.get(o.node);if(0===e&&1===n.height)return ee(t);if(0<=e&&e<=n.height)return Ct.removeRow(t,{map:n,tableStart:o.start,table:o.node},e),g(t)}return t}},ee=function(e){for(var t=e.selection.$from,o=t.depth,n;0<o;o--)if(n=t.node(o),"table"===n.type.spec.tableRole)return g(e.delete(t.before(o),t.after(o)));return e},te=function(e){var t=e.selection;if(j(t))return ee(e);if(W(t)){var o=J(t);if(o){var n=Ct.TableMap.get(o.node),r=n.rectBetween(t.$anchorCell.pos-o.start,t.$headCell.pos-o.start);if(0==r.left&&r.right==n.width)return!1;for(var d=Object.assign({},r,{map:n,table:o.node,tableStart:o.start}),p=d.right-1;;p--){if(Ct.removeColumn(e,d,p),p===d.left)break;d.table=d.tableStart?e.doc.nodeAt(d.tableStart-1):e.doc,d.map=Ct.TableMap.get(d.table)}return g(e)}}return e},oe=function(e){var t=e.selection;if(j(t))return ee(e);if(W(t)){var o=J(t);if(o){var n=Ct.TableMap.get(o.node),r=n.rectBetween(t.$anchorCell.pos-o.start,t.$headCell.pos-o.start);if(0==r.top&&r.bottom==n.height)return!1;for(var d=Object.assign({},r,{map:n,table:o.node,tableStart:o.start}),p=d.bottom-1;;p--){if(Ct.removeRow(e,d,p),p===d.top)break;d.table=d.tableStart?e.doc.nodeAt(d.tableStart-1):e.doc,d.map=Ct.TableMap.get(d.table)}return g(e)}}return e},ne=function(e,t){return function(o){return e?(o.setNodeMarkup(e.pos,null,Object.assign({},e.node.attrs,t)),g(o)):o}},re=function(e){for(var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:3,o=2<arguments.length&&void 0!==arguments[2]?arguments[2]:3,n=!(3<arguments.length&&void 0!==arguments[3])||arguments[3],r=4<arguments.length&&void 0!==arguments[4]?arguments[4]:null,d=C(e),p=d.cell,a=d.header_cell,s=d.row,l=d.table,c=[],h=[],m=0;m<o;m++)c.push(x(p,r)),n&&h.push(x(a,r));for(var f=[],g=0;g<t;g++)f.push(s.createChecked(null,n&&0==g?h:c));return l.createChecked(null,f)},de=function(e){return P(e,function(e){return e.type.spec.tableRole&&/cell/i.test(e.type.spec.tableRole)})},ie=function(e){var t=de(e);if(t){var o=w(e),n=Ct.TableMap.get(o.node),r=t.pos-o.start;return n.rectBetween(r,r)}},pe=function(e,t){return function(o){var n=[],r=H(e)(o.selection);if(r)for(var d=r.length-1;0<=d;d--)t(r[d],o)&&n.push(r[d]);return n}},ae=function(e){return function(t){for(var o=e,n=e,r=function(e){var r=K(e)(t.selection);r&&r.forEach(function(t){var r=t.node.attrs.colspan+e-1;r>=o&&(o=e),r>n&&(n=r)})},d=e;0<=d;d--)r(d);for(var p=function(e){var o=K(e)(t.selection);o&&o.forEach(function(t){var o=t.node.attrs.colspan+e-1;1<t.node.attrs.colspan&&o>n&&(n=o)})},d=e;d<=n;d++)p(d);for(var a=[],d=o,s;d<=n;d++)s=K(d)(t.selection),s&&s.length&&a.push(d);o=a[0],n=a[a.length-1];for(var l=K(o)(t.selection),c=H(0)(t.selection),h=t.doc.resolve(l[l.length-1].pos),m=void 0,f=n,g;f>=o;f--)if(g=K(f)(t.selection),g&&g.length){for(var u=c.length-1;0<=u;u--)if(c[u].pos===g[0].pos){m=g[0];break}if(m)break}var y=t.doc.resolve(m.pos);return{$anchor:h,$head:y,indexes:a}}},se=function(e){return function(t){for(var o=e,n=e,r=function(e){var r=H(e)(t.selection);r.forEach(function(t){var r=t.node.attrs.rowspan+e-1;r>=o&&(o=e),r>n&&(n=r)})},d=e;0<=d;d--)r(d);for(var p=function(e){var o=H(e)(t.selection);o.forEach(function(t){var o=t.node.attrs.rowspan+e-1;1<t.node.attrs.rowspan&&o>n&&(n=o)})},d=e;d<=n;d++)p(d);for(var a=[],d=o,s;d<=n;d++)s=H(d)(t.selection),s&&s.length&&a.push(d);o=a[0],n=a[a.length-1];for(var l=H(o)(t.selection),c=K(0)(t.selection),h=t.doc.resolve(l[l.length-1].pos),m=void 0,f=n,g;f>=o;f--)if(g=H(f)(t.selection),g&&g.length){for(var u=c.length-1;0<=u;u--)if(c[u].pos===g[0].pos){m=g[0];break}if(m)break}var y=t.doc.resolve(m.pos);return{$anchor:h,$head:y,indexes:a}}};t.isNodeSelection=m,t.canInsert=v,t.convertTableNodeToArrayOfRows=T,t.convertArrayOfRowsToTableNode=N,t.findParentNode=I,t.findParentNodeClosestToPos=P,t.findParentDomRef=E,t.hasParentNode=$,t.findParentNodeOfType=z,t.findParentNodeOfTypeClosestToPos=function(e,t){return P(e,function(e){return f(t,e)})},t.hasParentNodeOfType=function(e){return function(t){return $(function(t){return f(e,t)})(t)}},t.findParentDomRefOfType=function(e,t){return function(o){return E(function(t){return f(e,t)},t)(o)}},t.findSelectedNodeOfType=function(e){return function(t){if(m(t)){var o=t.node,n=t.$from;if(f(e,o))return{node:o,pos:n.pos,depth:n.depth}}}},t.findPositionOfNodeBefore=F,t.findDomRefAtPos=B,t.flatten=_,t.findChildren=V,t.findTextNodes=function(e,t){return V(e,function(e){return e.isText},t)},t.findInlineNodes=function(e,t){return V(e,function(e){return e.isInline},t)},t.findBlockNodes=function(e,t){return V(e,function(e){return e.isBlock},t)},t.findChildrenByAttr=function(e,t,o){return V(e,function(e){return!!t(e.attrs)},o)},t.findChildrenByType=L,t.findChildrenByMark=function(e,t,o){return V(e,function(e){return t.isInSet(e.marks)},o)},t.contains=function(e,t){return!!L(e,t).length},t.findTable=J,t.isCellSelection=W,t.getSelectionRect=function(e){if(W(e)){var t=e.$anchorCell.start(-1),o=Ct.TableMap.get(e.$anchorCell.node(-1));return o.rectBetween(e.$anchorCell.pos-t,e.$headCell.pos-t)}},t.isColumnSelected=function(e){return function(t){if(W(t)){var o=Ct.TableMap.get(t.$anchorCell.node(-1));return k({left:e,right:e+1,top:0,bottom:o.height})(t)}return!1}},t.isRowSelected=function(e){return function(t){if(W(t)){var o=Ct.TableMap.get(t.$anchorCell.node(-1));return k({left:0,right:o.width,top:e,bottom:e+1})(t)}return!1}},t.isTableSelected=j,t.getCellsInColumn=K,t.getCellsInRow=H,t.getCellsInTable=function(e){var t=J(e);if(t){var o=Ct.TableMap.get(t.node),n=o.cellsInRect({left:0,right:o.width,top:0,bottom:o.height});return n.map(function(e){var o=t.node.nodeAt(e),n=e+t.start;return{pos:n,start:n+1,node:o}})}},t.selectColumn=G,t.selectRow=X,t.selectTable=function(e){var t=J(e.selection);if(t){var o=Ct.TableMap.get(t.node),n=o.map;if(n&&n.length){var r=t.start+n[0],d=t.start+n[n.length-1],i=e.doc.resolve(r),p=e.doc.resolve(d);return g(e.setSelection(new Ct.CellSelection(p,i)))}}return e},t.emptyCell=function(e,t){return function(o){if(e){var n=C(t).cell.createAndFill(),r=n.content;if(!e.node.content.eq(r))return o.replaceWith(e.pos+1,e.pos+e.node.nodeSize,r),g(o)}return o}},t.addColumnAt=function(e){return function(t){var o=J(t.selection);if(o){var n=Ct.TableMap.get(o.node);if(0<=e&&e<=n.width)return g(Ct.addColumn(t,{map:n,tableStart:o.start,table:o.node},e))}return t}},t.moveRow=function(e,t,o){return function(n){var r=Object.assign({tryToFit:!1,direction:0},o),d=J(n.selection);if(!d)return n;var i=se(e)(n),p=i.indexes,a=se(t)(n),s=a.indexes;if(-1<p.indexOf(t))return n;!r.tryToFit&&1<s.length&&R(e,t,s,"row");var l=A(d,p,s,r.direction);return g(n).replaceWith(d.pos,d.pos+d.node.nodeSize,l)}},t.moveColumn=function(e,t,o){return function(n){var r=Object.assign({tryToFit:!1,direction:0},o),d=J(n.selection);if(!d)return n;var i=ae(e)(n),p=i.indexes,a=ae(t)(n),s=a.indexes;if(-1<p.indexOf(t))return n;!r.tryToFit&&1<s.length&&R(e,t,s,"column");var l=O(d,p,s,r.direction);return g(n).replaceWith(d.pos,d.pos+d.node.nodeSize,l)}},t.addRowAt=function(e,t){return function(o){var n=J(o.selection);if(n){var r=Ct.TableMap.get(n.node),d=e-1;if(t&&0<=d)return g(Q(d)(o));if(0<=e&&e<=r.height)return g(Ct.addRow(o,{map:r,tableStart:n.start,table:n.node},e))}return o}},t.cloneRowAt=Q,t.removeColumnAt=Y,t.removeRowAt=Z,t.removeTable=ee,t.removeSelectedColumns=te,t.removeSelectedRows=oe,t.removeColumnClosestToPos=function(e){return function(t){var o=ie(e);return o?Y(o.left)(d(e.pos)(t)):t}},t.removeRowClosestToPos=function(e){return function(t){var o=ie(e);return o?Z(o.top)(d(e.pos)(t)):t}},t.forEachCellInColumn=function(e,t,o){return function(n){var r=K(e)(n.selection);if(r){for(var d=r.length-1;0<=d;d--)n=t(r[d],n);if(o){var p=n.doc.resolve(n.mapping.map(r[r.length-1].pos));n.setSelection(q.Selection.near(p))}return g(n)}return n}},t.forEachCellInRow=function(e,t,o){return function(n){var r=H(e)(n.selection);if(r){for(var d=r.length-1;0<=d;d--)n=t(r[d],n);if(o){var p=n.doc.resolve(n.mapping.map(r[r.length-1].pos));n.setSelection(q.Selection.near(p))}}return n}},t.setCellAttrs=ne,t.createTable=re,t.findCellClosestToPos=de,t.findCellRectClosestToPos=ie,t.getSelectionRangeInColumn=ae,t.getSelectionRangeInRow=se,t.removeParentNodeOfType=function(e){return function(t){var o=z(e)(t.selection);return o?S(o.pos)(t):t}},t.replaceParentNodeOfType=n,t.removeSelectedNode=function(e){if(m(e.selection)){var t=e.selection.$from.pos,o=e.selection.$to.pos;return g(e.delete(t,o))}return e},t.replaceSelectedNode=r,t.setTextSelection=d,t.safeInsert=c,t.setParentNodeMarkup=function(e,t,o,n){return function(r){var d=z(e)(r.selection);return d?g(r.setNodeMarkup(d.pos,t,Object.assign({},d.node.attrs,o),n)):r}},t.selectParentNodeOfType=function(e){return function(t){if(!m(t.selection)){var o=z(e)(t.selection);if(o)return g(t.setSelection(q.NodeSelection.create(t.doc,o.pos)))}return t}},t.removeNodeBefore=function(e){var t=F(e.selection);return"number"==typeof t?S(t)(e):e}});t(po);var ao=po.isNodeSelection,so=po.canInsert,lo=po.convertTableNodeToArrayOfRows,co=po.convertArrayOfRowsToTableNode,ho=po.findParentNode,mo=po.findParentNodeClosestToPos,fo=po.findParentDomRef,go=po.hasParentNode,uo=po.findParentNodeOfType,yo=po.findParentNodeOfTypeClosestToPos,So=po.hasParentNodeOfType,Co=po.findParentDomRefOfType,vo=po.findSelectedNodeOfType,bo=po.findPositionOfNodeBefore,wo=po.findDomRefAtPos,xo=po.flatten,ko=po.findChildren,Mo=po.findTextNodes,To=po.findInlineNodes,No=po.findBlockNodes,Oo=po.findChildrenByAttr,Ao=po.findChildrenByType,Do=po.findChildrenByMark,Ro=po.contains,Io=po.findTable,Po=po.isCellSelection,Eo=po.getSelectionRect,$o=po.isColumnSelected,zo=po.isRowSelected,Fo=po.isTableSelected,Bo=po.getCellsInColumn,_o=po.getCellsInRow,Vo=po.getCellsInTable,Lo=po.selectColumn,Jo=po.selectRow,Wo=po.selectTable,jo=po.emptyCell,Ko=po.addColumnAt,qo=po.moveRow,Ho=po.moveColumn,Uo=po.addRowAt,Go=po.cloneRowAt,Xo=po.removeColumnAt,Qo=po.removeRowAt,Yo=po.removeTable,Zo=po.removeSelectedColumns,en=po.removeSelectedRows,tn=po.removeColumnClosestToPos,on=po.removeRowClosestToPos,nn=po.forEachCellInColumn,rn=po.forEachCellInRow,dn=po.setCellAttrs,pn=po.createTable,an=po.findCellClosestToPos,sn=po.findCellRectClosestToPos,ln=po.getSelectionRangeInColumn,cn=po.getSelectionRangeInRow,hn=po.removeParentNodeOfType,mn=po.replaceParentNodeOfType,fn=po.removeSelectedNode,gn=po.replaceSelectedNode,un=po.setTextSelection,yn=po.safeInsert,Sn=po.setParentNodeMarkup,Cn=po.selectParentNodeOfType,vn=po.removeNodeBefore,bn=o(function(e,t){function o(e,t,o){for(var n=e.length-1;0<=n;n--)o.step(e[n].inverted);for(var r=0;r<t.length;r++)o.step(t[r]);for(var p=[],a=0,s=e.length,l;a<e.length;a++)l=e[a].step.map(o.mapping.slice(s)),s--,l&&!o.maybeStep(l).failed&&(o.mapping.setMirror(s,o.steps.length-1),p.push(new d(l,l.invert(o.docs[o.docs.length-1]),e[a].origin)));return p}function n(e){for(var t=[],o=0;o<e.steps.length;o++)t.push(new d(e.steps[o],e.steps[o].invert(e.docs[o]),e));return t}function r(e,t,n,r){for(var d=s.getState(e),p=d.version+t.length,l=s.get(e).spec.config.clientID,c=0;c<n.length&&n[c]==l;)++c;var h=d.unconfirmed.slice(c);if(t=c?t.slice(c):t,!t.length)return e.tr.setMeta(s,new a(p,h));var m=h.length,f=e.tr;if(m)h=o(h,t,f);else{for(var g=0;g<t.length;g++)f.step(t[g]);h=[]}var u=new a(p,h);return r&&r.mapSelectionBackward&&e.selection instanceof q.TextSelection&&(f.setSelection(q.TextSelection.between(f.doc.resolve(f.mapping.map(e.selection.anchor,-1)),f.doc.resolve(f.mapping.map(e.selection.head,-1)),-1)),f.updated&=-2),f.setMeta("rebased",m).setMeta("addToHistory",!1).setMeta(s,u)}Object.defineProperty(t,"__esModule",{value:!0});var d=function(e,t,o){this.step=e,this.inverted=t,this.origin=o},a=function(e,t){this.version=e,this.unconfirmed=t},s=new q.PluginKey("collab");t.rebaseSteps=o,t.collab=function(e){return void 0===e&&(e={}),e={version:e.version||0,clientID:null==e.clientID?p(4294967295*Math.random()):e.clientID},new q.Plugin({key:s,state:{init:function(){return new a(e.version,[])},apply:function(e,t){var o=e.getMeta(s);return o?o:e.docChanged?new a(t.version,t.unconfirmed.concat(n(e))):t}},config:e,historyPreserveItems:!0})},t.receiveTransaction=r,t.sendableSteps=function(e){var t=s.getState(e);return 0==t.unconfirmed.length?null:{version:t.version,steps:t.unconfirmed.map(function(e){return e.step}),clientID:s.get(e).spec.config.clientID,get origins(){return this._origins||(this._origins=t.unconfirmed.map(function(e){return e.origin}))}}},t.getVersion=function(e){return s.getState(e).version}});t(bn);var wn=bn.rebaseSteps,xn=bn.collab,kn=bn.receiveTransaction,Mn=bn.sendableSteps,Tn=bn.getVersion,Nn=200,On=function(){};On.prototype.append=function(e){return e.length?(e=On.from(e),!this.length&&e||e.length<Nn&&this.leafAppend(e)||this.length<Nn&&e.leafPrepend(this)||this.appendInner(e)):this},On.prototype.prepend=function(e){return e.length?On.from(e).append(this):this},On.prototype.appendInner=function(e){return new Dn(this,e)},On.prototype.slice=function(e,t){return void 0===e&&(e=0),void 0===t&&(t=this.length),e>=t?On.empty:this.sliceInner(s(0,e),l(this.length,t))},On.prototype.get=function(e){return 0>e||e>=this.length?void 0:this.getInner(e)},On.prototype.forEach=function(e,t,o){void 0===t&&(t=0),void 0===o&&(o=this.length),t<=o?this.forEachInner(e,t,o,0):this.forEachInvertedInner(e,t,o,0)},On.prototype.map=function(e,t,o){void 0===t&&(t=0),void 0===o&&(o=this.length);var n=[];return this.forEach(function(t,o){return n.push(e(t,o))},t,o),n},On.from=function(e){return e instanceof On?e:e&&e.length?new An(e):On.empty};var An=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var o={length:{},depth:{}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,o){return 0==e&&o==this.length?this:new t(this.values.slice(e,o))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,o,n){for(var r=this,d=t;d<o;d++)if(!1===e(r.values[d],n+d))return!1},t.prototype.forEachInvertedInner=function(e,t,o,n){for(var r=this,d=t-1;d>=o;d--)if(!1===e(r.values[d],n+d))return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=Nn)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=Nn)return new t(e.flatten().concat(this.values))},o.length.get=function(){return this.values.length},o.depth.get=function(){return 0},Object.defineProperties(t.prototype,o),t}(On);On.empty=new An([]);var Dn=function(e){function t(t,o){e.call(this),this.left=t,this.right=o,this.length=t.length+o.length,this.depth=s(t.depth,o.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,o,n){var r=this.left.length;return!(t<r&&!1===this.left.forEachInner(e,t,l(o,r),n))&&!(o>r&&!1===this.right.forEachInner(e,s(t-r,0),l(this.length,o)-r,n+r))&&void 0},t.prototype.forEachInvertedInner=function(e,t,o,n){var r=this.left.length;return!(t>r&&!1===this.right.forEachInvertedInner(e,t-r,s(o,r)-r,n+r))&&!(o<r&&!1===this.left.forEachInvertedInner(e,l(t,r),o,n))&&void 0},t.prototype.sliceInner=function(e,t){if(0==e&&t==this.length)return this;var o=this.left.length;return t<=o?this.left.slice(e,t):e>=o?this.right.slice(e-o,t-o):this.left.slice(e,o).append(this.right.slice(0,t-o))},t.prototype.leafAppend=function(e){var o=this.right.leafAppend(e);if(o)return new t(this.left,o)},t.prototype.leafPrepend=function(e){var o=this.left.leafPrepend(e);if(o)return new t(o,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=s(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(On),Rn=On,In=o(function(e,t){function o(e){return e&&"object"==typeof e&&"default"in e?e["default"]:e}function n(e,t){var o;return e.forEach(function(e,n){if(e.selection&&0==t--)return o=n,!1}),e.slice(o)}function r(e,t,o,n){var r=o.getMeta(C),a;if(r)return r.historyState;o.getMeta(v)&&(e=new g(e.done,e.undone,null,0));var s=o.getMeta("appendedTransaction");if(0==o.steps.length)return e;if(s&&s.getMeta(C))return s.getMeta(C).redo?new g(e.done.addTransform(o,null,n,c(t)),e.undone,i(o.mapping.maps[o.steps.length-1]),e.prevTime):new g(e.done,e.undone.addTransform(o,null,n,c(t)),null,e.prevTime);if(!1!==o.getMeta("addToHistory")&&!(s&&!1===s.getMeta("addToHistory"))){var l=e.prevTime<(o.time||0)-n.newGroupDelay||!s&&!d(o,e.prevRanges),h=s?p(e.prevRanges,o.mapping):i(o.mapping.maps[o.steps.length-1]);return new g(e.done.addTransform(o,l?t.selection.getBookmark():null,n,c(t)),m.empty,h,o.time)}return(a=o.getMeta("rebased"))?new g(e.done.rebased(o,a),e.undone.rebased(o,a),p(e.prevRanges,o.mapping),e.prevTime):new g(e.done.addMaps(o.mapping.maps),e.undone.addMaps(o.mapping.maps),p(e.prevRanges,o.mapping),e.prevTime)}function d(e,t){if(!t)return!1;if(!e.docChanged)return!0;var o=!1;return e.mapping.maps[0].forEach(function(e,n){for(var r=0;r<t.length;r+=2)e<=t[r+1]&&n>=t[r]&&(o=!0)}),o}function i(e){var t=[];return e.forEach(function(e,o,n,r){return t.push(n,r)}),t}function p(e,t){if(!e)return null;for(var o=[],n=0;n<e.length;n+=2){var r=t.map(e[n],1),d=t.map(e[n+1],-1);r<=d&&o.push(r,d)}return o}function a(e,t,o,n){var r=c(t),d=C.get(t).spec.config,i=(n?e.undone:e.done).popEvent(t,r);if(i){var p=i.selection.resolve(i.transform.doc),a=(n?e.done:e.undone).addTransform(i.transform,t.selection.getBookmark(),d,r),s=new g(n?a:i.remaining,n?i.remaining:a,null,0);o(i.transform.setSelection(p).setMeta(C,{redo:n,historyState:s}).scrollIntoView())}}function c(e){var t=e.plugins;if(S!=t){y=!1,S=t;for(var o=0;o<t.length;o++)if(t[o].spec.historyPreserveItems){y=!0;break}}return y}Object.defineProperty(t,"__esModule",{value:!0});var h=o(Rn),m=function(e,t){this.items=e,this.eventCount=t};m.prototype.popEvent=function(e,t){var o=this;if(0==this.eventCount)return null;for(var n=this.items.length,r;;n--)if(r=o.items.get(n-1),r.selection){--n;break}var d,p;t&&(d=this.remapping(n,this.items.length),p=d.maps.length);var a=e.tr,s=[],l=[],c,h;return this.items.forEach(function(e,t){if(!e.step)return d||(d=o.remapping(n,t+1),p=d.maps.length),p--,void l.push(e);if(d){l.push(new f(e.map));var r=e.step.map(d.slice(p)),i;r&&a.maybeStep(r).doc&&(i=a.mapping.maps[a.mapping.maps.length-1],s.push(new f(i,null,null,s.length+l.length))),p--,i&&d.appendMap(i,p)}else a.maybeStep(e.step);return e.selection?(c=d?e.selection.map(d.slice(p)):e.selection,h=new m(o.items.slice(0,n).append(l.reverse().concat(s)),o.eventCount-1),!1):void 0},this.items.length,0),{remaining:h,transform:a,selection:c}},m.prototype.addTransform=function(e,t,o,r){for(var d=[],p=this.eventCount,a=this.items,s=!r&&a.length?a.get(a.length-1):null,l=0;l<e.steps.length;l++){var c=e.steps[l].invert(e.docs[l]),h=new f(e.mapping.maps[l],c,t),g=void 0;(g=s&&s.merge(h))&&(h=g,l?d.pop():a=a.slice(0,a.length-1)),d.push(h),t&&(p++,t=null),r||(s=h)}var y=p-o.depth;return y>u&&(a=n(a,y),p-=y),new m(a.append(d),p)},m.prototype.remapping=function(e,t){var o=new T.Mapping;return this.items.forEach(function(t,n){var r=null!=t.mirrorOffset&&n-t.mirrorOffset>=e?r=o.maps.length-t.mirrorOffset:null;o.appendMap(t.map,r)},e,t),o},m.prototype.addMaps=function(e){return 0==this.eventCount?this:new m(this.items.append(e.map(function(e){return new f(e)})),this.eventCount)},m.prototype.rebased=function(e,t){if(!this.eventCount)return this;var o=[],n=s(0,this.items.length-t),r=e.mapping,d=e.steps.length,p=this.eventCount;this.items.forEach(function(e){e.selection&&p--},n);var a=t;this.items.forEach(function(t){var n=r.getMirror(--a);if(null!=n){d=l(d,n);var i=r.maps[n];if(t.step){var s=e.steps[n].invert(e.docs[n]),c=t.selection&&t.selection.map(r.slice(a+1,n));c&&p++,o.push(new f(i,s,c))}else o.push(new f(i))}},n);for(var c=[],h=t;h<d;h++)c.push(new f(r.maps[h]));var g=this.items.slice(0,n).append(c).append(o),u=new m(g,p);return u.emptyItemCount()>500&&(u=u.compress(this.items.length-o.length)),u},m.prototype.emptyItemCount=function(){var e=0;return this.items.forEach(function(t){t.step||e++}),e},m.prototype.compress=function(e){void 0===e&&(e=this.items.length);var t=this.remapping(0,e),o=t.maps.length,n=[],r=0;return this.items.forEach(function(d,p){if(p>=e)n.push(d),d.selection&&r++;else if(d.step){var i=d.step.map(t.slice(o)),a=i&&i.getMap();if(o--,a&&t.appendMap(a,o),i){var s=d.selection&&d.selection.map(t.slice(o));s&&r++;var l=new f(a.invert(),i,s),c=n.length-1,h;(h=n.length&&n[c].merge(l))?n[c]=h:n.push(l)}}else d.map&&o--},this.items.length,0),new m(h.from(n.reverse()),r)},m.empty=new m(h.empty,0);var f=function(e,t,o,n){this.map=e,this.step=t,this.selection=o,this.mirrorOffset=n};f.prototype.merge=function(e){if(this.step&&e.step&&!e.selection){var t=e.step.merge(this.step);if(t)return new f(t.getMap().invert(),t,this.selection)}};var g=function(e,t,o,n){this.done=e,this.undone=t,this.prevRanges=o,this.prevTime=n},u=20,y=!1,S=null,C=new q.PluginKey("history"),v=new q.PluginKey("closeHistory");t.HistoryState=g,t.closeHistory=function(e){return e.setMeta(v,!0)},t.history=function(e){return e={depth:e&&e.depth||100,newGroupDelay:e&&e.newGroupDelay||500},new q.Plugin({key:C,state:{init:function(){return new g(m.empty,m.empty,null,0)},apply:function(t,o,n){return r(o,n,t,e)}},config:e})},t.undo=function(e,t){var o=C.getState(e);return!!(o&&0!=o.done.eventCount)&&(t&&a(o,e,t,!1),!0)},t.redo=function(e,t){var o=C.getState(e);return!!(o&&0!=o.undone.eventCount)&&(t&&a(o,e,t,!0),!0)},t.undoDepth=function(e){var t=C.getState(e);return t?t.done.eventCount:0},t.redoDepth=function(e){var t=C.getState(e);return t?t.undone.eventCount:0}});t(In);var Pn=In.HistoryState,En=In.closeHistory,$n=In.history,zn=In.undo,Fn=In.redo,Bn=In.undoDepth,_n=In.redoDepth;return e.prosemirrorCollab={collab:xn,sendableSteps:Mn,getVersion:Tn,receiveTransaction:kn},e.prosemirrorCommands={chainCommands:it,deleteSelection:Ve,joinBackward:Le,selectNodeBackward:Je,joinForward:We,selectNodeForward:je,joinUp:Ke,joinDown:qe,lift:He,newlineInCode:Ue,exitCode:Ge,createParagraphNear:Xe,liftEmptyBlock:Qe,splitBlock:Ye,splitBlockKeepMarks:Ze,selectParentNode:et,selectAll:tt,wrapIn:ot,setBlockType:nt,toggleMark:rt,autoJoin:dt,baseKeymap:st,pcBaseKeymap:pt,macBaseKeymap:at},e.prosemirrorDropcursor={dropCursor:le},e.prosemirrorGapcursor={gapCursor:ke},e.prosemirrorHistory={history:$n,undo:zn,redo:Fn},e.prosemirrorInputrules={InputRule:Ne,inputRules:Oe,undoInputRule:Ae,wrappingInputRule:Fe,textblockTypeInputRule:Be},e.prosemirrorKeymap={keymap:be},e.prosemirrorModel={Schema:v,DOMParser:k,Node:m,DOMSerializer:M,Slice:y,Fragment:u},e.prosemirrorSchemaList={addListNodes:ft,wrapInList:gt,splitListItem:ut,liftListItem:yt,sinkListItem:St},e.prosemirrorState={EditorState:Z,Plugin:ee,PluginKey:te,TextSelection:G,NodeSelection:X},e.prosemirrorTables={tableEditing:vt,columnResizing:Et,goToNextCell:ro,addColumnBefore:Lt,addColumnAfter:Jt,deleteColumn:jt,addRowBefore:qt,addRowAfter:Ht,deleteRow:Gt,deleteTable:io,mergeCells:Xt,splitCell:Qt,toggleHeaderColumn:oo,toggleHeaderRow:to,toggleHeaderCell:no,setCellAttr:Zt,fixTables:bt,tableNodes:Rt},e.prosemirrorTransform={Step:A},e.prosemirrorUtils={findParentNode:ho,findBlockNodes:No,createTable:pn,findSelectedNodeOfType:vo},e.prosemirrorView={EditorView:ne,DecorationSet:de,Decoration:re},e}({}); | |
var {prosemirrorState, prosemirrorView, prosemirrorModel, prosemirrorDropcursor, prosemirrorGapcursor, prosemirrorKeymap, prosemirrorCommands, prosemirrorInputrules, | |
prosemirrorUtils, prosemirrorTables, prosemirrorTransform, prosemirrorCollab, prosemirrorHistory,prosemirrorSchemaList}=prosemirror; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment