summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@chimrod.com>2021-02-06 13:38:33 +0100
committerSébastien Dailly <sebastien@dailly.me>2022-02-07 16:43:33 +0100
commitcdd83641518d9b20e81f71e6a30bfe73866df2e8 (patch)
tree6521138cfa8b483fb55e9fb0bf47a33363d48d0c
parent898ae8a6f54418c792f7673298d698e356e8cab6 (diff)
Added prosemirror deps
-rw-r--r--editor/editor.css326
-rwxr-xr-xeditor/index.html2
-rw-r--r--resources/prosemirror.js2
3 files changed, 329 insertions, 1 deletions
diff --git a/editor/editor.css b/editor/editor.css
new file mode 100644
index 0000000..8f29bde
--- /dev/null
+++ b/editor/editor.css
@@ -0,0 +1,326 @@
+.ProseMirror {
+ position: relative;
+}
+
+.ProseMirror {
+ word-wrap: break-word;
+ white-space: pre-wrap;
+ white-space: break-spaces;
+ -webkit-font-variant-ligatures: none;
+ font-variant-ligatures: none;
+ font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
+}
+
+.ProseMirror pre {
+ white-space: pre-wrap;
+}
+
+.ProseMirror li {
+ position: relative;
+}
+
+.ProseMirror-hideselection *::selection { background: transparent; }
+.ProseMirror-hideselection *::-moz-selection { background: transparent; }
+.ProseMirror-hideselection { caret-color: transparent; }
+
+.ProseMirror-selectednode {
+ outline: 2px solid #8cf;
+}
+
+/* Make sure li selections wrap around markers */
+
+li.ProseMirror-selectednode {
+ outline: none;
+}
+
+li.ProseMirror-selectednode:after {
+ content: "";
+ position: absolute;
+ left: -32px;
+ right: -2px; top: -2px; bottom: -2px;
+ border: 2px solid #8cf;
+ pointer-events: none;
+}
+.ProseMirror-textblock-dropdown {
+ min-width: 3em;
+}
+
+.ProseMirror-menu {
+ margin: 0 -4px;
+ line-height: 1;
+}
+
+.ProseMirror-tooltip .ProseMirror-menu {
+ width: -webkit-fit-content;
+ width: fit-content;
+ white-space: pre;
+}
+
+.ProseMirror-menuitem {
+ margin-right: 3px;
+ display: inline-block;
+}
+
+.ProseMirror-menuseparator {
+ border-right: 1px solid #ddd;
+ margin-right: 3px;
+}
+
+.ProseMirror-menu-dropdown, .ProseMirror-menu-dropdown-menu {
+ font-size: 90%;
+ white-space: nowrap;
+}
+
+.ProseMirror-menu-dropdown {
+ vertical-align: 1px;
+ cursor: pointer;
+ position: relative;
+ padding-right: 15px;
+}
+
+.ProseMirror-menu-dropdown-wrap {
+ padding: 1px 0 1px 4px;
+ display: inline-block;
+ position: relative;
+}
+
+.ProseMirror-menu-dropdown:after {
+ content: "";
+ border-left: 4px solid transparent;
+ border-right: 4px solid transparent;
+ border-top: 4px solid currentColor;
+ opacity: .6;
+ position: absolute;
+ right: 4px;
+ top: calc(50% - 2px);
+}
+
+.ProseMirror-menu-dropdown-menu, .ProseMirror-menu-submenu {
+ position: absolute;
+ background: white;
+ color: #666;
+ border: 1px solid #aaa;
+ padding: 2px;
+}
+
+.ProseMirror-menu-dropdown-menu {
+ z-index: 15;
+ min-width: 6em;
+}
+
+.ProseMirror-menu-dropdown-item {
+ cursor: pointer;
+ padding: 2px 8px 2px 4px;
+}
+
+.ProseMirror-menu-dropdown-item:hover {
+ background: #f2f2f2;
+}
+
+.ProseMirror-menu-submenu-wrap {
+ position: relative;
+ margin-right: -4px;
+}
+
+.ProseMirror-menu-submenu-label:after {
+ content: "";
+ border-top: 4px solid transparent;
+ border-bottom: 4px solid transparent;
+ border-left: 4px solid currentColor;
+ opacity: .6;
+ position: absolute;
+ right: 4px;
+ top: calc(50% - 4px);
+}
+
+.ProseMirror-menu-submenu {
+ display: none;
+ min-width: 4em;
+ left: 100%;
+ top: -3px;
+}
+
+.ProseMirror-menu-active {
+ background: #eee;
+ border-radius: 4px;
+}
+
+.ProseMirror-menu-disabled {
+ opacity: .3;
+}
+
+.ProseMirror-menu-submenu-wrap:hover .ProseMirror-menu-submenu, .ProseMirror-menu-submenu-wrap-active .ProseMirror-menu-submenu {
+ display: block;
+}
+
+.ProseMirror-menubar {
+ border-top-left-radius: inherit;
+ border-top-right-radius: inherit;
+ position: relative;
+ min-height: 1em;
+ color: #666;
+ padding: 1px 6px;
+ top: 0; left: 0; right: 0;
+ border-bottom: 1px solid silver;
+ background: white;
+ z-index: 10;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+ overflow: visible;
+}
+
+.ProseMirror-icon {
+ display: inline-block;
+ line-height: .8;
+ vertical-align: -2px; /* Compensate for padding */
+ padding: 2px 8px;
+ cursor: pointer;
+}
+
+.ProseMirror-menu-disabled.ProseMirror-icon {
+ cursor: default;
+}
+
+.ProseMirror-icon svg {
+ fill: currentColor;
+ height: 1em;
+}
+
+.ProseMirror-icon span {
+ vertical-align: text-top;
+}
+.ProseMirror-gapcursor {
+ display: none;
+ pointer-events: none;
+ position: absolute;
+}
+
+.ProseMirror-gapcursor:after {
+ content: "";
+ display: block;
+ position: absolute;
+ top: -2px;
+ width: 20px;
+ border-top: 1px solid black;
+ animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
+}
+
+@keyframes ProseMirror-cursor-blink {
+ to {
+ visibility: hidden;
+ }
+}
+
+.ProseMirror-focused .ProseMirror-gapcursor {
+ display: block;
+}
+/* Add space around the hr to make clicking it easier */
+
+.ProseMirror-example-setup-style hr {
+ padding: 2px 10px;
+ border: none;
+ margin: 1em 0;
+}
+
+.ProseMirror-example-setup-style hr:after {
+ content: "";
+ display: block;
+ height: 1px;
+ background-color: silver;
+ line-height: 2px;
+}
+
+.ProseMirror ul, .ProseMirror ol {
+ padding-left: 30px;
+}
+
+.ProseMirror blockquote {
+ padding-left: 1em;
+ border-left: 3px solid #eee;
+ margin-left: 0; margin-right: 0;
+}
+
+.ProseMirror-example-setup-style img {
+ cursor: default;
+}
+
+.ProseMirror-prompt {
+ background: white;
+ padding: 5px 10px 5px 15px;
+ border: 1px solid silver;
+ position: fixed;
+ border-radius: 3px;
+ z-index: 11;
+ box-shadow: -.5px 2px 5px rgba(0, 0, 0, .2);
+}
+
+.ProseMirror-prompt h5 {
+ margin: 0;
+ font-weight: normal;
+ font-size: 100%;
+ color: #444;
+}
+
+.ProseMirror-prompt input[type="text"],
+.ProseMirror-prompt textarea {
+ background: #eee;
+ border: none;
+ outline: none;
+}
+
+.ProseMirror-prompt input[type="text"] {
+ padding: 0 4px;
+}
+
+.ProseMirror-prompt-close {
+ position: absolute;
+ left: 2px; top: 1px;
+ color: #666;
+ border: none; background: transparent; padding: 0;
+}
+
+.ProseMirror-prompt-close:after {
+ content: "✕";
+ font-size: 12px;
+}
+
+.ProseMirror-invalid {
+ background: #ffc;
+ border: 1px solid #cc7;
+ border-radius: 4px;
+ padding: 5px 10px;
+ position: absolute;
+ min-width: 10em;
+}
+
+.ProseMirror-prompt-buttons {
+ margin-top: 5px;
+ display: none;
+}
+#editor, .editor {
+ background: white;
+ color: black;
+ background-clip: padding-box;
+ border-radius: 4px;
+ border: 2px solid rgba(0, 0, 0, 0.2);
+ padding: 5px 0;
+ margin-bottom: 23px;
+}
+
+.ProseMirror p:first-child,
+.ProseMirror h1:first-child,
+.ProseMirror h2:first-child,
+.ProseMirror h3:first-child,
+.ProseMirror h4:first-child,
+.ProseMirror h5:first-child,
+.ProseMirror h6:first-child {
+ margin-top: 10px;
+}
+
+.ProseMirror {
+ padding: 4px 8px 4px 14px;
+ line-height: 1.2;
+ outline: none;
+}
+
+.ProseMirror p { margin-bottom: 1em }
diff --git a/editor/index.html b/editor/index.html
index 7f3a070..9f7189b 100755
--- a/editor/index.html
+++ b/editor/index.html
@@ -110,7 +110,7 @@
-<script src="prosemirror.js"></script>
+<script src="/resources/prosemirror.js"></script>
<noscript>Sorry, you need to enable JavaScript to see this page.</noscript>
<script id="script" type="text/javascript" defer="defer" src="editor.js"></script>
diff --git a/resources/prosemirror.js b/resources/prosemirror.js
new file mode 100644
index 0000000..94ad215
--- /dev/null
+++ b/resources/prosemirror.js
@@ -0,0 +1,2 @@
+!function(){"use strict";function s(t){this.content=t}s.prototype={constructor:s,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return-1==e?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,o=r.find(t),i=r.content.slice();return-1==o?i.push(n||t,e):(i[o+1]=e,n&&(i[o]=n)),new s(i)},remove:function(t){var e=this.find(t);if(-1==e)return this;var n=this.content.slice();return n.splice(e,2),new s(n)},addToStart:function(t,e){return new s([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new s(n)},addBefore:function(t,e,n){var r=this.remove(e),o=r.content.slice(),i=r.find(t);return o.splice(-1==i?o.length:i,0,e,n),new s(o)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return(t=s.from(t)).size?new s(t.content.concat(this.subtract(t).content)):this},append:function(t){return(t=s.from(t)).size?new s(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=s.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},get size(){return this.content.length>>1}},s.from=function(t){if(t instanceof s)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new s(e)};var p=s;var I=function(t,e){if(this.content=t,this.size=e||0,null==e)for(var n=0;n<t.length;n++)this.size+=t[n].nodeSize},t={firstChild:{configurable:!0},lastChild:{configurable:!0},childCount:{configurable:!0}};I.prototype.nodesBetween=function(t,e,n,r,o){void 0===r&&(r=0);for(var i=0,s=0;s<e;i++){var a,c=this.content[i],l=s+c.nodeSize;t<l&&!1!==n(c,r+s,o,i)&&c.content.size&&(a=s+1,c.nodesBetween(Math.max(0,t-a),Math.min(c.content.size,e-a),n,r+a)),s=l}},I.prototype.descendants=function(t){this.nodesBetween(0,this.size,t)},I.prototype.textBetween=function(n,r,o,i){var s="",a=!0;return this.nodesBetween(n,r,function(t,e){t.isText?(s+=t.text.slice(Math.max(n,e)-e,r-e),a=!o):t.isLeaf&&i?(s+=i,a=!o):!a&&t.isBlock&&(s+=o,a=!0)},0),s},I.prototype.append=function(t){if(!t.size)return this;if(!this.size)return t;var e=this.lastChild,n=t.firstChild,r=this.content.slice(),o=0;for(e.isText&&e.sameMarkup(n)&&(r[r.length-1]=e.withText(e.text+n.text),o=1);o<t.content.length;o++)r.push(t.content[o]);return new I(r,this.size+t.size)},I.prototype.cut=function(t,e){if(null==e&&(e=this.size),0==t&&e==this.size)return this;var n=[],r=0;if(t<e)for(var o=0,i=0;i<e;o++){var s=this.content[o],a=i+s.nodeSize;t<a&&((i<t||e<a)&&(s=s.isText?s.cut(Math.max(0,t-i),Math.min(s.text.length,e-i)):s.cut(Math.max(0,t-i-1),Math.min(s.content.size,e-i-1))),n.push(s),r+=s.nodeSize),i=a}return new I(n,r)},I.prototype.cutByIndex=function(t,e){return t==e?I.empty:0==t&&e==this.content.length?this:new I(this.content.slice(t,e))},I.prototype.replaceChild=function(t,e){var n=this.content[t];if(n==e)return this;var r=this.content.slice(),o=this.size+e.nodeSize-n.nodeSize;return r[t]=e,new I(r,o)},I.prototype.addToStart=function(t){return new I([t].concat(this.content),this.size+t.nodeSize)},I.prototype.addToEnd=function(t){return new I(this.content.concat(t),this.size+t.nodeSize)},I.prototype.eq=function(t){if(this.content.length!=t.content.length)return!1;for(var e=0;e<this.content.length;e++)if(!this.content[e].eq(t.content[e]))return!1;return!0},t.firstChild.get=function(){return this.content.length?this.content[0]:null},t.lastChild.get=function(){return this.content.length?this.content[this.content.length-1]:null},t.childCount.get=function(){return this.content.length},I.prototype.child=function(t){var e=this.content[t];if(!e)throw new RangeError("Index "+t+" out of range for "+this);return e},I.prototype.maybeChild=function(t){return this.content[t]},I.prototype.forEach=function(t){for(var e=0,n=0;e<this.content.length;e++){var r=this.content[e];t(r,n,e),n+=r.nodeSize}},I.prototype.findDiffStart=function(t,e){return void 0===e&&(e=0),function t(e,n,r){for(var o=0;;o++){if(o==e.childCount||o==n.childCount)return e.childCount==n.childCount?null:r;var i=e.child(o),s=n.child(o);if(i!=s){if(!i.sameMarkup(s))return r;if(i.isText&&i.text!=s.text){for(var a=0;i.text[a]==s.text[a];a++)r++;return r}if(i.content.size||s.content.size){var c=t(i.content,s.content,r+1);if(null!=c)return c}r+=i.nodeSize}else r+=i.nodeSize}}(this,t,e)},I.prototype.findDiffEnd=function(t,e,n){return void 0===e&&(e=this.size),void 0===n&&(n=t.size),function t(e,n,r,o){for(var i=e.childCount,s=n.childCount;;){if(0==i||0==s)return i==s?null:{a:r,b:o};var a=e.child(--i),c=n.child(--s),l=a.nodeSize;if(a!=c){if(!a.sameMarkup(c))return{a:r,b:o};if(a.isText&&a.text!=c.text){for(var p=0,h=Math.min(a.text.length,c.text.length);p<h&&a.text[a.text.length-p-1]==c.text[c.text.length-p-1];)p++,r--,o--;return{a:r,b:o}}if(a.content.size||c.content.size){var u=t(a.content,c.content,r-1,o-1);if(u)return u}r-=l,o-=l}else r-=l,o-=l}}(this,t,e,n)},I.prototype.findIndex=function(t,e){if(void 0===e&&(e=-1),0==t)return i(0,t);if(t==this.size)return i(this.content.length,t);if(t>this.size||t<0)throw new RangeError("Position "+t+" outside of fragment ("+this+")");for(var n=0,r=0;;n++){var o=r+this.child(n).nodeSize;if(t<=o)return o==t||0<e?i(n+1,o):i(n,r);r=o}},I.prototype.toString=function(){return"<"+this.toStringInner()+">"},I.prototype.toStringInner=function(){return this.content.join(", ")},I.prototype.toJSON=function(){return this.content.length?this.content.map(function(t){return t.toJSON()}):null},I.fromJSON=function(t,e){if(!e)return I.empty;if(!Array.isArray(e))throw new RangeError("Invalid input for Fragment.fromJSON");return new I(e.map(t.nodeFromJSON))},I.fromArray=function(t){if(!t.length)return I.empty;for(var e,n=0,r=0;r<t.length;r++){var o=t[r];n+=o.nodeSize,r&&o.isText&&t[r-1].sameMarkup(o)?(e=e||t.slice(0,r))[e.length-1]=o.withText(e[e.length-1].text+o.text):e&&e.push(o)}return new I(e||t,n)},I.from=function(t){if(!t)return I.empty;if(t instanceof I)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new I([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))},Object.defineProperties(I.prototype,t);var n={index:0,offset:0};function i(t,e){return n.index=t,n.offset=e,n}function a(t,e){if(t===e)return!0;if(!t||"object"!=typeof t||!e||"object"!=typeof e)return!1;var n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(var r=0;r<t.length;r++)if(!a(t[r],e[r]))return!1}else{for(var o in t)if(!(o in e&&a(t[o],e[o])))return!1;for(var i in e)if(!(i in t))return!1}return!0}I.empty=new I([],0);function c(t,e){this.type=t,this.attrs=e}function o(t){var e=Error.call(this,t);return e.__proto__=o.prototype,e}c.prototype.addToSet=function(t){for(var e,n=!1,r=0;r<t.length;r++){var o=t[r];if(this.eq(o))return t;if(this.type.excludes(o.type))e=e||t.slice(0,r);else{if(o.type.excludes(this.type))return t;!n&&o.type.rank>this.type.rank&&((e=e||t.slice(0,r)).push(this),n=!0),e&&e.push(o)}}return e=e||t.slice(),n||e.push(this),e},c.prototype.removeFromSet=function(t){for(var e=0;e<t.length;e++)if(this.eq(t[e]))return t.slice(0,e).concat(t.slice(e+1));return t},c.prototype.isInSet=function(t){for(var e=0;e<t.length;e++)if(this.eq(t[e]))return!0;return!1},c.prototype.eq=function(t){return this==t||this.type==t.type&&a(this.attrs,t.attrs)},c.prototype.toJSON=function(){var t={type:this.type.name};for(var e in this.attrs){t.attrs=this.attrs;break}return t},c.fromJSON=function(t,e){if(!e)throw new RangeError("Invalid input for Mark.fromJSON");var n=t.marks[e.type];if(!n)throw new RangeError("There is no mark type "+e.type+" in this schema");return n.create(e.attrs)},c.sameSet=function(t,e){if(t==e)return!0;if(t.length!=e.length)return!1;for(var n=0;n<t.length;n++)if(!t[n].eq(e[n]))return!1;return!0},c.setFrom=function(t){if(!t||0==t.length)return c.none;if(t instanceof c)return[t];var e=t.slice();return e.sort(function(t,e){return t.type.rank-e.type.rank}),e},c.none=[],((o.prototype=Object.create(Error.prototype)).constructor=o).prototype.name="ReplaceError";var N=function(t,e,n){this.content=t,this.openStart=e,this.openEnd=n},e={size:{configurable:!0}};function r(t,e,n){if(n.openStart>t.depth)throw new o("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new o("Inconsistent open depths");return function t(e,n,r,o){var i=e.index(o),s=e.node(o);{if(i==n.index(o)&&o<e.depth-r.openStart){var a=t(e,n,r,o+1);return s.copy(s.content.replaceChild(i,a))}if(r.content.size){if(r.openStart||r.openEnd||e.depth!=o||n.depth!=o){var c=g(r,e),l=c.start,p=c.end;return d(s,m(e,l,p,n,o))}var h=e.parent,u=h.content;return d(h,u.cut(0,e.parentOffset).append(r.content).append(u.cut(n.parentOffset)))}return d(s,v(e,n,o))}}(t,e,n,0)}function l(t,e){if(!e.type.compatibleContent(t.type))throw new o("Cannot join "+e.type.name+" onto "+t.type.name)}function h(t,e,n){var r=t.node(n);return l(r,e.node(n)),r}function u(t,e){var n=e.length-1;0<=n&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function f(t,e,n,r){var o=(e||t).node(n),i=0,s=e?e.index(n):o.childCount;t&&(i=t.index(n),t.depth>n?i++:t.textOffset&&(u(t.nodeAfter,r),i++));for(var a=i;a<s;a++)u(o.child(a),r);e&&e.depth==n&&e.textOffset&&u(e.nodeBefore,r)}function d(t,e){if(!t.type.validContent(e))throw new o("Invalid content for node "+t.type.name);return t.copy(e)}function m(t,e,n,r,o){var i=t.depth>o&&h(t,e,o+1),s=r.depth>o&&h(n,r,o+1),a=[];return f(null,t,o,a),i&&s&&e.index(o)==n.index(o)?(l(i,s),u(d(i,m(t,e,n,r,o+1)),a)):(i&&u(d(i,v(t,e,o+1)),a),f(e,n,o,a),s&&u(d(s,v(n,r,o+1)),a)),f(r,null,o,a),new I(a)}function v(t,e,n){var r=[];return f(null,t,n,r),t.depth>n&&u(d(h(t,e,n+1),v(t,e,n+1)),r),f(e,null,n,r),new I(r)}function g(t,e){for(var n=e.depth-t.openStart,r=e.node(n).copy(t.content),o=n-1;0<=o;o--)r=e.node(o).copy(I.from(r));return{start:r.resolveNoCache(t.openStart+n),end:r.resolveNoCache(r.content.size-t.openEnd-n)}}e.size.get=function(){return this.content.size-this.openStart-this.openEnd},N.prototype.insertAt=function(t,e){var n=function t(e,n,r,o){var i=e.findIndex(n);var s=i.index;var a=i.offset;var c=e.maybeChild(s);if(a==n||c.isText)return o&&!o.canReplace(s,s,r)?null:e.cut(0,n).append(r).append(e.cut(n));var l=t(c.content,n-a-1,r);return l&&e.replaceChild(s,c.copy(l))}(this.content,t+this.openStart,e,null);return n&&new N(n,this.openStart,this.openEnd)},N.prototype.removeBetween=function(t,e){return new N(function t(e,n,r){var o=e.findIndex(n);var i=o.index;var s=o.offset;var a=e.maybeChild(i);var c=e.findIndex(r);var l=c.index;var p=c.offset;if(s==n||a.isText){if(p!=r&&!e.child(l).isText)throw new RangeError("Removing non-flat range");return e.cut(0,n).append(e.cut(r))}if(i!=l)throw new RangeError("Removing non-flat range");return e.replaceChild(i,a.copy(t(a.content,n-s-1,r-s-1)))}(this.content,t+this.openStart,e+this.openStart),this.openStart,this.openEnd)},N.prototype.eq=function(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd},N.prototype.toString=function(){return this.content+"("+this.openStart+","+this.openEnd+")"},N.prototype.toJSON=function(){if(!this.content.size)return null;var t={content:this.content.toJSON()};return 0<this.openStart&&(t.openStart=this.openStart),0<this.openEnd&&(t.openEnd=this.openEnd),t},N.fromJSON=function(t,e){if(!e)return N.empty;var n=e.openStart||0,r=e.openEnd||0;if("number"!=typeof n||"number"!=typeof r)throw new RangeError("Invalid input for Slice.fromJSON");return new N(I.fromJSON(t,e.content),n,r)},N.maxOpen=function(t,e){void 0===e&&(e=!0);for(var n=0,r=0,o=t.firstChild;o&&!o.isLeaf&&(e||!o.type.spec.isolating);o=o.firstChild)n++;for(var i=t.lastChild;i&&!i.isLeaf&&(e||!i.type.spec.isolating);i=i.lastChild)r++;return new N(t,n,r)},Object.defineProperties(N.prototype,e),N.empty=new N(I.empty,0,0);function y(t,e,n){this.pos=t,this.path=e,this.depth=e.length/3-1,this.parentOffset=n}var w={parent:{configurable:!0},doc:{configurable:!0},textOffset:{configurable:!0},nodeAfter:{configurable:!0},nodeBefore:{configurable:!0}};y.prototype.resolveDepth=function(t){return null==t?this.depth:t<0?this.depth+t:t},w.parent.get=function(){return this.node(this.depth)},w.doc.get=function(){return this.node(0)},y.prototype.node=function(t){return this.path[3*this.resolveDepth(t)]},y.prototype.index=function(t){return this.path[3*this.resolveDepth(t)+1]},y.prototype.indexAfter=function(t){return t=this.resolveDepth(t),this.index(t)+(t!=this.depth||this.textOffset?1:0)},y.prototype.start=function(t){return 0==(t=this.resolveDepth(t))?0:this.path[3*t-1]+1},y.prototype.end=function(t){return t=this.resolveDepth(t),this.start(t)+this.node(t).content.size},y.prototype.before=function(t){if(!(t=this.resolveDepth(t)))throw new RangeError("There is no position before the top-level node");return t==this.depth+1?this.pos:this.path[3*t-1]},y.prototype.after=function(t){if(!(t=this.resolveDepth(t)))throw new RangeError("There is no position after the top-level node");return t==this.depth+1?this.pos:this.path[3*t-1]+this.path[3*t].nodeSize},w.textOffset.get=function(){return this.pos-this.path[this.path.length-1]},w.nodeAfter.get=function(){var t=this.parent,e=this.index(this.depth);if(e==t.childCount)return null;var n=this.pos-this.path[this.path.length-1],r=t.child(e);return n?t.child(e).cut(n):r},w.nodeBefore.get=function(){var t=this.index(this.depth),e=this.pos-this.path[this.path.length-1];return e?this.parent.child(t).cut(0,e):0==t?null:this.parent.child(t-1)},y.prototype.posAtIndex=function(t,e){e=this.resolveDepth(e);for(var n=this.path[3*e],r=0==e?0:this.path[3*e-1]+1,o=0;o<t;o++)r+=n.child(o).nodeSize;return r},y.prototype.marks=function(){var t=this.parent,e=this.index();if(0==t.content.size)return c.none;if(this.textOffset)return t.child(e).marks;var n,r=t.maybeChild(e-1),o=t.maybeChild(e);r||(n=r,r=o,o=n);for(var i=r.marks,s=0;s<i.length;s++)!1!==i[s].type.spec.inclusive||o&&i[s].isInSet(o.marks)||(i=i[s--].removeFromSet(i));return i},y.prototype.marksAcross=function(t){var e=this.parent.maybeChild(this.index());if(!e||!e.isInline)return null;for(var n=e.marks,r=t.parent.maybeChild(t.index()),o=0;o<n.length;o++)!1!==n[o].type.spec.inclusive||r&&n[o].isInSet(r.marks)||(n=n[o--].removeFromSet(n));return n},y.prototype.sharedDepth=function(t){for(var e=this.depth;0<e;e--)if(this.start(e)<=t&&this.end(e)>=t)return e;return 0},y.prototype.blockRange=function(t,e){if(void 0===t&&(t=this),t.pos<this.pos)return t.blockRange(this);for(var n=this.depth-(this.parent.inlineContent||this.pos==t.pos?1:0);0<=n;n--)if(t.pos<=this.end(n)&&(!e||e(this.node(n))))return new S(this,t,n)},y.prototype.sameParent=function(t){return this.pos-this.parentOffset==t.pos-t.parentOffset},y.prototype.max=function(t){return t.pos>this.pos?t:this},y.prototype.min=function(t){return t.pos<this.pos?t:this},y.prototype.toString=function(){for(var t="",e=1;e<=this.depth;e++)t+=(t?"/":"")+this.node(e).type.name+"_"+this.index(e-1);return t+":"+this.parentOffset},y.resolve=function(t,e){if(!(0<=e&&e<=t.content.size))throw new RangeError("Position "+e+" out of range");for(var n=[],r=0,o=e,i=t;;){var s=i.content.findIndex(o),a=s.index,c=s.offset,l=o-c;if(n.push(i,a,r+c),!l)break;if((i=i.child(a)).isText)break;o=l-1,r+=c+1}return new y(e,n,o)},y.resolveCached=function(t,e){for(var n=0;n<b.length;n++){var r=b[n];if(r.pos==e&&r.doc==t)return r}var o=b[k]=y.resolve(t,e);return k=(k+1)%x,o},Object.defineProperties(y.prototype,w);var b=[],k=0,x=12,S=function(t,e,n){this.$from=t,this.$to=e,this.depth=n},M={start:{configurable:!0},end:{configurable:!0},parent:{configurable:!0},startIndex:{configurable:!0},endIndex:{configurable:!0}};M.start.get=function(){return this.$from.before(this.depth+1)},M.end.get=function(){return this.$to.after(this.depth+1)},M.parent.get=function(){return this.$from.node(this.depth)},M.startIndex.get=function(){return this.$from.index(this.depth)},M.endIndex.get=function(){return this.$to.indexAfter(this.depth)},Object.defineProperties(S.prototype,M);function C(t,e,n,r){this.type=t,this.attrs=e,this.content=n||I.empty,this.marks=r||c.none}var O=Object.create(null),T={nodeSize:{configurable:!0},childCount:{configurable:!0},textContent:{configurable:!0},firstChild:{configurable:!0},lastChild:{configurable:!0},isBlock:{configurable:!0},isTextblock:{configurable:!0},inlineContent:{configurable:!0},isInline:{configurable:!0},isText:{configurable:!0},isLeaf:{configurable:!0},isAtom:{configurable:!0}};T.nodeSize.get=function(){return this.isLeaf?1:2+this.content.size},T.childCount.get=function(){return this.content.childCount},C.prototype.child=function(t){return this.content.child(t)},C.prototype.maybeChild=function(t){return this.content.maybeChild(t)},C.prototype.forEach=function(t){this.content.forEach(t)},C.prototype.nodesBetween=function(t,e,n,r){void 0===r&&(r=0),this.content.nodesBetween(t,e,n,r,this)},C.prototype.descendants=function(t){this.nodesBetween(0,this.content.size,t)},T.textContent.get=function(){return this.textBetween(0,this.content.size,"")},C.prototype.textBetween=function(t,e,n,r){return this.content.textBetween(t,e,n,r)},T.firstChild.get=function(){return this.content.firstChild},T.lastChild.get=function(){return this.content.lastChild},C.prototype.eq=function(t){return this==t||this.sameMarkup(t)&&this.content.eq(t.content)},C.prototype.sameMarkup=function(t){return this.hasMarkup(t.type,t.attrs,t.marks)},C.prototype.hasMarkup=function(t,e,n){return this.type==t&&a(this.attrs,e||t.defaultAttrs||O)&&c.sameSet(this.marks,n||c.none)},C.prototype.copy=function(t){return void 0===t&&(t=null),t==this.content?this:new this.constructor(this.type,this.attrs,t,this.marks)},C.prototype.mark=function(t){return t==this.marks?this:new this.constructor(this.type,this.attrs,this.content,t)},C.prototype.cut=function(t,e){return 0==t&&e==this.content.size?this:this.copy(this.content.cut(t,e))},C.prototype.slice=function(t,e,n){if(void 0===e&&(e=this.content.size),void 0===n&&(n=!1),t==e)return N.empty;var r=this.resolve(t),o=this.resolve(e),i=n?0:r.sharedDepth(e),s=r.start(i),a=r.node(i).content.cut(r.pos-s,o.pos-s);return new N(a,r.depth-i,o.depth-i)},C.prototype.replace=function(t,e,n){return r(this.resolve(t),this.resolve(e),n)},C.prototype.nodeAt=function(t){for(var e=this;;){var n=e.content.findIndex(t),r=n.index,o=n.offset;if(!(e=e.maybeChild(r)))return null;if(o==t||e.isText)return e;t-=o+1}},C.prototype.childAfter=function(t){var e=this.content.findIndex(t),n=e.index,r=e.offset;return{node:this.content.maybeChild(n),index:n,offset:r}},C.prototype.childBefore=function(t){if(0==t)return{node:null,index:0,offset:0};var e=this.content.findIndex(t),n=e.index,r=e.offset;if(r<t)return{node:this.content.child(n),index:n,offset:r};var o=this.content.child(n-1);return{node:o,index:n-1,offset:r-o.nodeSize}},C.prototype.resolve=function(t){return y.resolveCached(this,t)},C.prototype.resolveNoCache=function(t){return y.resolve(this,t)},C.prototype.rangeHasMark=function(t,e,n){var r=!1;return t<e&&this.nodesBetween(t,e,function(t){return n.isInSet(t.marks)&&(r=!0),!r}),r},T.isBlock.get=function(){return this.type.isBlock},T.isTextblock.get=function(){return this.type.isTextblock},T.inlineContent.get=function(){return this.type.inlineContent},T.isInline.get=function(){return this.type.isInline},T.isText.get=function(){return this.type.isText},T.isLeaf.get=function(){return this.type.isLeaf},T.isAtom.get=function(){return this.type.isAtom},C.prototype.toString=function(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);var t=this.type.name;return this.content.size&&(t+="("+this.content.toStringInner()+")"),E(this.marks,t)},C.prototype.contentMatchAt=function(t){var e=this.type.contentMatch.matchFragment(this.content,0,t);if(!e)throw new Error("Called contentMatchAt on a node with invalid content");return e},C.prototype.canReplace=function(t,e,n,r,o){void 0===n&&(n=I.empty),void 0===r&&(r=0),void 0===o&&(o=n.childCount);var i=this.contentMatchAt(t).matchFragment(n,r,o),s=i&&i.matchFragment(this.content,e);if(!s||!s.validEnd)return!1;for(var a=r;a<o;a++)if(!this.type.allowsMarks(n.child(a).marks))return!1;return!0},C.prototype.canReplaceWith=function(t,e,n,r){if(r&&!this.type.allowsMarks(r))return!1;var o=this.contentMatchAt(t).matchType(n),i=o&&o.matchFragment(this.content,e);return!!i&&i.validEnd},C.prototype.canAppend=function(t){return t.content.size?this.canReplace(this.childCount,this.childCount,t.content):this.type.compatibleContent(t.type)},C.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(t){return t.check()})},C.prototype.toJSON=function(){var t={type:this.type.name};for(var e in this.attrs){t.attrs=this.attrs;break}return this.content.size&&(t.content=this.content.toJSON()),this.marks.length&&(t.marks=this.marks.map(function(t){return t.toJSON()})),t},C.fromJSON=function(t,e){if(!e)throw new RangeError("Invalid input for Node.fromJSON");var n=null;if(e.marks){if(!Array.isArray(e.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=e.marks.map(t.markFromJSON)}if("text"==e.type){if("string"!=typeof e.text)throw new RangeError("Invalid text node in JSON");return t.text(e.text,n)}var r=I.fromJSON(t,e.content);return t.nodeType(e.type).create(e.attrs,r,n)},Object.defineProperties(C.prototype,T);var D=function(o){function e(t,e,n,r){if(o.call(this,t,e,null,r),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}o&&(e.__proto__=o);var t={textContent:{configurable:!0},nodeSize:{configurable:!0}};return((e.prototype=Object.create(o&&o.prototype)).constructor=e).prototype.toString=function(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):E(this.marks,JSON.stringify(this.text))},t.textContent.get=function(){return this.text},e.prototype.textBetween=function(t,e){return this.text.slice(t,e)},t.nodeSize.get=function(){return this.text.length},e.prototype.mark=function(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)},e.prototype.withText=function(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)},e.prototype.cut=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=this.text.length),0==t&&e==this.text.length?this:this.withText(this.text.slice(t,e))},e.prototype.eq=function(t){return this.sameMarkup(t)&&this.text==t.text},e.prototype.toJSON=function(){var t=o.prototype.toJSON.call(this);return t.text=this.text,t},Object.defineProperties(e.prototype,t),e}(C);function E(t,e){for(var n=t.length-1;0<=n;n--)e=t[n].type.name+"("+e+")";return e}function A(t){this.validEnd=t,this.next=[],this.wrapCache=[]}var R={inlineContent:{configurable:!0},defaultType:{configurable:!0},edgeCount:{configurable:!0}};A.parse=function(t,e){var n=new z(t,e);if(null==n.next)return A.empty;var r=_(n);n.next&&n.err("Unexpected trailing text");var s,a,o,i=(o=[[]],d(function n(t,r){{if("choice"==t.type)return t.exprs.reduce(function(t,e){return t.concat(n(e,r))},[]);if("seq"==t.type)for(var e=0;;e++){var o=n(t.exprs[e],r);if(e==t.exprs.length-1)return o;d(o,r=u())}else{if("star"==t.type){var i=u();return f(r,i),d(n(t.expr,i),i),[f(i)]}if("plus"==t.type){var s=u();return d(n(t.expr,r),s),d(n(t.expr,s),s),[f(s)]}if("opt"==t.type)return[f(r)].concat(n(t.expr,r));if("range"==t.type){for(var a=r,c=0;c<t.min;c++){var l=u();d(n(t.expr,a),l),a=l}if(-1==t.max)d(n(t.expr,a),a);else for(var p=t.min;p<t.max;p++){var h=u();f(a,h),d(n(t.expr,a),h),a=h}return[f(a)]}if("name"==t.type)return[f(r,null,t.value)]}}}(r,0),u()),s=o,a=Object.create(null),function t(e){var i=[];e.forEach(function(t){s[t].forEach(function(t){var e,n,r=t.term,o=t.to;r&&(e=i.indexOf(r),n=-1<e&&i[e+1],$(s,o).forEach(function(t){n||i.push(r,n=[]),-1==n.indexOf(t)&&n.push(t)}))})});var n=a[e.join(",")]=new A(-1<e.indexOf(s.length-1));for(var r=0;r<i.length;r+=2){var o=i[r+1].sort(V);n.next.push(i[r],a[o.join(",")]||t(o))}return n}($(s,0)));function u(){return o.push([])-1}function f(t,e,n){var r={term:n,to:e};return o[t].push(r),r}function d(t,e){t.forEach(function(t){return t.to=e})}return function(t,e){for(var n=0,r=[t];n<r.length;n++){for(var o=r[n],i=!o.validEnd,s=[],a=0;a<o.next.length;a+=2){var c=o.next[a],l=o.next[a+1];s.push(c.name),!i||c.isText||c.hasRequiredAttrs()||(i=!1),-1==r.indexOf(l)&&r.push(l)}i&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(i,n),i},A.prototype.matchType=function(t){for(var e=0;e<this.next.length;e+=2)if(this.next[e]==t)return this.next[e+1];return null},A.prototype.matchFragment=function(t,e,n){void 0===e&&(e=0),void 0===n&&(n=t.childCount);for(var r=this,o=e;r&&o<n;o++)r=r.matchType(t.child(o).type);return r},R.inlineContent.get=function(){var t=this.next[0];return!!t&&t.isInline},R.defaultType.get=function(){for(var t=0;t<this.next.length;t+=2){var e=this.next[t];if(!e.isText&&!e.hasRequiredAttrs())return e}},A.prototype.compatible=function(t){for(var e=0;e<this.next.length;e+=2)for(var n=0;n<t.next.length;n+=2)if(this.next[e]==t.next[n])return!0;return!1},A.prototype.fillBefore=function(c,l,p){void 0===l&&(l=!1),void 0===p&&(p=0);var h=[this];return function t(e,n){var r=e.matchFragment(c,p);if(r&&(!l||r.validEnd))return I.from(n.map(function(t){return t.createAndFill()}));for(var o=0;o<e.next.length;o+=2){var i=e.next[o],s=e.next[o+1];if(!i.isText&&!i.hasRequiredAttrs()&&-1==h.indexOf(s)){h.push(s);var a=t(s,n.concat(i));if(a)return a}}}(this,[])},A.prototype.findWrapping=function(t){for(var e=0;e<this.wrapCache.length;e+=2)if(this.wrapCache[e]==t)return this.wrapCache[e+1];var n=this.computeWrapping(t);return this.wrapCache.push(t,n),n},A.prototype.computeWrapping=function(t){for(var e=Object.create(null),n=[{match:this,type:null,via:null}];n.length;){var r=n.shift(),o=r.match;if(o.matchType(t)){for(var i=[],s=r;s.type;s=s.via)i.push(s.type);return i.reverse()}for(var a=0;a<o.next.length;a+=2){var c=o.next[a];c.isLeaf||c.hasRequiredAttrs()||c.name in e||r.type&&!o.next[a+1].validEnd||(n.push({match:c.contentMatch,type:c,via:r}),e[c.name]=!0)}}},R.edgeCount.get=function(){return this.next.length>>1},A.prototype.edge=function(t){var e=t<<1;if(e>=this.next.length)throw new RangeError("There's no "+t+"th edge in this content match");return{type:this.next[e],next:this.next[1+e]}},A.prototype.toString=function(){var o=[];return function t(e){o.push(e);for(var n=1;n<e.next.length;n+=2)-1==o.indexOf(e.next[n])&&t(e.next[n])}(this),o.map(function(t,e){for(var n=e+(t.validEnd?"*":" ")+" ",r=0;r<t.next.length;r+=2)n+=(r?", ":"")+t.next[r].name+"->"+o.indexOf(t.next[r+1]);return n}).join("\n")},Object.defineProperties(A.prototype,R),A.empty=new A(!0);var z=function(t,e){this.string=t,this.nodeTypes=e,this.inline=null,this.pos=0,this.tokens=t.split(/\s*(?=\b|\W|$)/),""==this.tokens[this.tokens.length-1]&&this.tokens.pop(),""==this.tokens[0]&&this.tokens.shift()},P={next:{configurable:!0}};function _(t){for(var e=[];e.push(function(t){var e=[];for(;e.push(function(t){for(var e=function(e){{if(e.eat("(")){var t=_(e);return e.eat(")")||e.err("Missing closing paren"),t}if(!/\W/.test(e.next)){var n=function(t,e){var n=t.nodeTypes,r=n[e];if(r)return[r];var o=[];for(var i in n){var s=n[i];-1<s.groups.indexOf(e)&&o.push(s)}0==o.length&&t.err("No node type or group '"+e+"' found");return o}(e,e.next).map(function(t){return null==e.inline?e.inline=t.isInline:e.inline!=t.isInline&&e.err("Mixing inline and block content"),{type:"name",value:t}});return e.pos++,1==n.length?n[0]:{type:"choice",exprs:n}}e.err("Unexpected token '"+e.next+"'")}}(t);;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else{if(!t.eat("{"))break;e=function(t,e){var n=B(t),r=n;t.eat(",")&&(r="}"!=t.next?B(t):-1);t.eat("}")||t.err("Unclosed braced range");return{type:"range",min:n,max:r,expr:e}}(t,e)}return e}(t)),t.next&&")"!=t.next&&"|"!=t.next;);return 1==e.length?e[0]:{type:"seq",exprs:e}}(t)),t.eat("|"););return 1==e.length?e[0]:{type:"choice",exprs:e}}function B(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");var e=Number(t.next);return t.pos++,e}function V(t,e){return e-t}function $(a,t){var c=[];return function t(e){var n=a[e];if(1==n.length&&!n[0].term)return t(n[0].to);c.push(e);for(var r=0;r<n.length;r++){var o=n[r],i=o.term,s=o.to;i||-1!=c.indexOf(s)||t(s)}}(t),c.sort(V)}function F(t){var e=Object.create(null);for(var n in t){var r=t[n];if(!r.hasDefault)return null;e[n]=r.default}return e}function q(t,e){var n=Object.create(null);for(var r in t){var o=e&&e[r];if(void 0===o){var i=t[r];if(!i.hasDefault)throw new RangeError("No value supplied for attribute "+r);o=i.default}n[r]=o}return n}function L(t){var e=Object.create(null);if(t)for(var n in t)e[n]=new W(t[n]);return e}P.next.get=function(){return this.tokens[this.pos]},z.prototype.eat=function(t){return this.next==t&&(this.pos++||!0)},z.prototype.err=function(t){throw new SyntaxError(t+" (in content expression '"+this.string+"')")},Object.defineProperties(z.prototype,P);function j(t,e,n){this.name=t,this.schema=e,this.spec=n,this.groups=n.group?n.group.split(" "):[],this.attrs=L(n.attrs),this.defaultAttrs=F(this.attrs),this.contentMatch=null,this.markSet=null,this.inlineContent=null,this.isBlock=!(n.inline||"text"==t),this.isText="text"==t}var J={isInline:{configurable:!0},isTextblock:{configurable:!0},isLeaf:{configurable:!0},isAtom:{configurable:!0}};J.isInline.get=function(){return!this.isBlock},J.isTextblock.get=function(){return this.isBlock&&this.inlineContent},J.isLeaf.get=function(){return this.contentMatch==A.empty},J.isAtom.get=function(){return this.isLeaf||this.spec.atom},j.prototype.hasRequiredAttrs=function(){for(var t in this.attrs)if(this.attrs[t].isRequired)return!0;return!1},j.prototype.compatibleContent=function(t){return this==t||this.contentMatch.compatible(t.contentMatch)},j.prototype.computeAttrs=function(t){return!t&&this.defaultAttrs?this.defaultAttrs:q(this.attrs,t)},j.prototype.create=function(t,e,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new C(this,this.computeAttrs(t),I.from(e),c.setFrom(n))},j.prototype.createChecked=function(t,e,n){if(e=I.from(e),!this.validContent(e))throw new RangeError("Invalid content for node "+this.name);return new C(this,this.computeAttrs(t),e,c.setFrom(n))},j.prototype.createAndFill=function(t,e,n){if(t=this.computeAttrs(t),(e=I.from(e)).size){var r=this.contentMatch.fillBefore(e);if(!r)return null;e=r.append(e)}var o=this.contentMatch.matchFragment(e).fillBefore(I.empty,!0);return o?new C(this,t,e.append(o),c.setFrom(n)):null},j.prototype.validContent=function(t){var e=this.contentMatch.matchFragment(t);if(!e||!e.validEnd)return!1;for(var n=0;n<t.childCount;n++)if(!this.allowsMarks(t.child(n).marks))return!1;return!0},j.prototype.allowsMarkType=function(t){return null==this.markSet||-1<this.markSet.indexOf(t)},j.prototype.allowsMarks=function(t){if(null==this.markSet)return!0;for(var e=0;e<t.length;e++)if(!this.allowsMarkType(t[e].type))return!1;return!0},j.prototype.allowedMarks=function(t){if(null==this.markSet)return t;for(var e,n=0;n<t.length;n++)this.allowsMarkType(t[n].type)?e&&e.push(t[n]):e=e||t.slice(0,n);return e?e.length?e:c.empty:t},j.compile=function(t,n){var r=Object.create(null);t.forEach(function(t,e){return r[t]=new j(t,n,e)});var e=n.spec.topNode||"doc";if(!r[e])throw new RangeError("Schema is missing its top node type ('"+e+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(var o in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r},Object.defineProperties(j.prototype,J);var W=function(t){this.hasDefault=Object.prototype.hasOwnProperty.call(t,"default"),this.default=t.default},K={isRequired:{configurable:!0}};K.isRequired.get=function(){return!this.hasDefault},Object.defineProperties(W.prototype,K);function H(t,e,n,r){this.name=t,this.schema=n,this.spec=r,this.attrs=L(r.attrs),this.rank=e,this.excluded=null;var o=F(this.attrs);this.instance=o&&new c(this,o)}H.prototype.create=function(t){return!t&&this.instance?this.instance:new c(this,q(this.attrs,t))},H.compile=function(t,n){var r=Object.create(null),o=0;return t.forEach(function(t,e){return r[t]=new H(t,o++,n,e)}),r},H.prototype.removeFromSet=function(t){for(var e=0;e<t.length;e++)if(t[e].type==this)return t.slice(0,e).concat(t.slice(e+1));return t},H.prototype.isInSet=function(t){for(var e=0;e<t.length;e++)if(t[e].type==this)return t[e]},H.prototype.excludes=function(t){return-1<this.excluded.indexOf(t)};function U(t){for(var e in this.spec={},t)this.spec[e]=t[e];this.spec.nodes=p.from(t.nodes),this.spec.marks=p.from(t.marks),this.nodes=j.compile(this.spec.nodes,this),this.marks=H.compile(this.spec.marks,this);var n=Object.create(null);for(var r in this.nodes){if(r in this.marks)throw new RangeError(r+" can not be both a node and a mark");var o=this.nodes[r],i=o.spec.content||"",s=o.spec.marks;o.contentMatch=n[i]||(n[i]=A.parse(i,this.nodes)),o.inlineContent=o.contentMatch.inlineContent,o.markSet="_"==s?null:s?G(this,s.split(" ")):""!=s&&o.inlineContent?null:[]}for(var a in this.marks){var c=this.marks[a],l=c.spec.excludes;c.excluded=null==l?[c]:""==l?[]:G(this,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)}function G(t,e){for(var n=[],r=0;r<e.length;r++){var o=e[r],i=t.marks[o],s=i;if(i)n.push(i);else for(var a in t.marks){var c=t.marks[a];("_"==o||c.spec.group&&-1<c.spec.group.split(" ").indexOf(o))&&n.push(s=c)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}U.prototype.node=function(t,e,n,r){if("string"==typeof t)t=this.nodeType(t);else{if(!(t instanceof j))throw new RangeError("Invalid node type: "+t);if(t.schema!=this)throw new RangeError("Node type from different schema used ("+t.name+")")}return t.createChecked(e,n,r)},U.prototype.text=function(t,e){var n=this.nodes.text;return new D(n,n.defaultAttrs,t,c.setFrom(e))},U.prototype.mark=function(t,e){return"string"==typeof t&&(t=this.marks[t]),t.create(e)},U.prototype.nodeFromJSON=function(t){return C.fromJSON(this,t)},U.prototype.markFromJSON=function(t){return c.fromJSON(this,t)},U.prototype.nodeType=function(t){var e=this.nodes[t];if(!e)throw new RangeError("Unknown node type: "+t);return e};var Q=function(n,t){var e=this;this.schema=n,this.rules=t,this.tags=[],this.styles=[],t.forEach(function(t){t.tag?e.tags.push(t):t.style&&e.styles.push(t)}),this.normalizeLists=!this.tags.some(function(t){if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;var e=n.nodes[t.node];return e.contentMatch.matchType(e)})};Q.prototype.parse=function(t,e){void 0===e&&(e={});var n=new nt(this,e,!1);return n.addAll(t,null,e.from,e.to),n.finish()},Q.prototype.parseSlice=function(t,e){void 0===e&&(e={});var n=new nt(this,e,!0);return n.addAll(t,null,e.from,e.to),N.maxOpen(n.finish())},Q.prototype.matchTag=function(t,e,n){for(var r,o,i=n?this.tags.indexOf(n)+1:0;i<this.tags.length;i++){var s=this.tags[i];if(r=t,o=s.tag,(r.matches||r.msMatchesSelector||r.webkitMatchesSelector||r.mozMatchesSelector).call(r,o)&&(void 0===s.namespace||t.namespaceURI==s.namespace)&&(!s.context||e.matchesContext(s.context))){if(s.getAttrs){var a=s.getAttrs(t);if(!1===a)continue;s.attrs=a}return s}}},Q.prototype.matchStyle=function(t,e,n,r){for(var o=r?this.styles.indexOf(r)+1:0;o<this.styles.length;o++){var i=this.styles[o];if(!(0!=i.style.indexOf(t)||i.context&&!n.matchesContext(i.context)||i.style.length>t.length&&(61!=i.style.charCodeAt(t.length)||i.style.slice(t.length+1)!=e))){if(i.getAttrs){var s=i.getAttrs(e);if(!1===s)continue;i.attrs=s}return i}}},Q.schemaRules=function(n){var o=[];function r(t){for(var e=null==t.priority?50:t.priority,n=0;n<o.length;n++){var r=o[n];if((null==r.priority?50:r.priority)<e)break}o.splice(n,0,t)}for(var t in n.marks)!function(e){var t=n.marks[e].spec.parseDOM;t&&t.forEach(function(t){r(t=ot(t)),t.mark=e})}(t);var e;for(var i in n.nodes)e=void 0,(e=n.nodes[i].spec.parseDOM)&&e.forEach(function(t){r(t=ot(t)),t.node=i});return o},Q.fromSchema=function(t){return t.cached.domParser||(t.cached.domParser=new Q(t,Q.schemaRules(t)))};var X={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},Y={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Z={ol:!0,ul:!0};function tt(t){return(t?1:0)|("full"===t?2:0)}function et(t,e,n,r,o,i,s){this.type=t,this.attrs=e,this.solid=o,this.match=i||(4&s?null:t.contentMatch),this.options=s,this.content=[],this.marks=n,this.activeMarks=c.none,this.pendingMarks=r,this.stashMarks=[]}et.prototype.findWrapping=function(t){if(!this.match){if(!this.type)return[];var e=this.type.contentMatch.fillBefore(I.from(t));if(!e){var n,r=this.type.contentMatch;return(n=r.findWrapping(t.type))?(this.match=r,n):null}this.match=this.type.contentMatch.matchFragment(e)}return this.match.findWrapping(t.type)},et.prototype.finish=function(t){var e,n;1&this.options||(e=this.content[this.content.length-1])&&e.isText&&(n=/[ \t\r\n\u000c]+$/.exec(e.text))&&(e.text.length==n[0].length?this.content.pop():this.content[this.content.length-1]=e.withText(e.text.slice(0,e.text.length-n[0].length)));var r=I.from(this.content);return!t&&this.match&&(r=r.append(this.match.fillBefore(I.empty,!0))),this.type?this.type.create(this.attrs,r,this.marks):r},et.prototype.popFromStashMark=function(t){for(var e=this.stashMarks.length-1;0<=e;e--)if(t.eq(this.stashMarks[e]))return this.stashMarks.splice(e,1)[0]},et.prototype.applyPending=function(t){for(var e=0,n=this.pendingMarks;e<n.length;e++){var r=n[e];(this.type?this.type.allowsMarkType(r.type):function(n,a){var r=a.schema.nodes;for(var t in r){var e=function(t){var e=r[t];if(e.allowsMarkType(n)){var i=[],s=function(t){i.push(t);for(var e=0;e<t.edgeCount;e++){var n=t.edge(e),r=n.type,o=n.next;if(r==a)return!0;if(i.indexOf(o)<0&&s(o))return!0}};return s(e.contentMatch)?{v:!0}:void 0}}(t);if(e)return e.v}}(r.type,t))&&!r.isInSet(this.activeMarks)&&(this.activeMarks=r.addToSet(this.activeMarks),this.pendingMarks=r.removeFromSet(this.pendingMarks))}};var nt=function(t,e,n){this.parser=t,this.options=e,this.isOpen=n;var r=e.topNode,o=tt(e.preserveWhitespace)|(n?4:0),i=r?new et(r.type,r.attrs,c.none,c.none,!0,e.topMatch||r.type.contentMatch,o):new et(n?null:t.schema.topNodeType,null,c.none,c.none,!0,null,o);this.nodes=[i],this.open=0,this.find=e.findPositions,this.needsBlock=!1},rt={top:{configurable:!0},currentPos:{configurable:!0}};function ot(t){var e={};for(var n in t)e[n]=t[n];return e}rt.top.get=function(){return this.nodes[this.open]},nt.prototype.addDOM=function(t){if(3==t.nodeType)this.addTextNode(t);else if(1==t.nodeType){var e=t.getAttribute("style"),n=e?this.readStyles(function(t){var e,n=/\s*([\w-]+)\s*:\s*([^;]+)/g,r=[];for(;e=n.exec(t);)r.push(e[1],e[2].trim());return r}(e)):null,r=this.top;if(null!=n)for(var o=0;o<n.length;o++)this.addPendingMark(n[o]);if(this.addElement(t),null!=n)for(var i=0;i<n.length;i++)this.removePendingMark(n[i],r)}},nt.prototype.addTextNode=function(t){var e,n,r=t.nodeValue,o=this.top;(o.type?o.type.inlineContent:o.content.length&&o.content[0].isInline)||/[^ \t\r\n\u000c]/.test(r)?(1&o.options?2&o.options||(r=r.replace(/\r?\n|\r/g," ")):(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1&&(e=o.content[o.content.length-1],n=t.previousSibling,(!e||n&&"BR"==n.nodeName||e.isText&&/[ \t\r\n\u000c]$/.test(e.text))&&(r=r.slice(1)))),r&&this.insertNode(this.parser.schema.text(r)),this.findInText(t)):this.findInside(t)},nt.prototype.addElement=function(t,e){var n,r=t.nodeName.toLowerCase();Z.hasOwnProperty(r)&&this.parser.normalizeLists&&function(t){for(var e=t.firstChild,n=null;e;e=e.nextSibling){var r=1==e.nodeType?e.nodeName.toLowerCase():null;r&&Z.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):"li"==r?n=e:r&&(n=null)}}(t);var o=this.options.ruleFromNode&&this.options.ruleFromNode(t)||(n=this.parser.matchTag(t,this,e));if(o?o.ignore:Y.hasOwnProperty(r))this.findInside(t);else if(!o||o.skip||o.closeParent){o&&o.closeParent?this.open=Math.max(0,this.open-1):o&&o.skip.nodeType&&(t=o.skip);var i,s=this.top,a=this.needsBlock;if(X.hasOwnProperty(r))i=!0,s.type||(this.needsBlock=!0);else if(!t.firstChild)return void this.leafFallback(t);this.addAll(t),i&&this.sync(s),this.needsBlock=a}else this.addElementByRule(t,o,!1===o.consuming?n:null)},nt.prototype.leafFallback=function(t){"BR"==t.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(t.ownerDocument.createTextNode("\n"))},nt.prototype.readStyles=function(t){var e=c.none;t:for(var n=0;n<t.length;n+=2)for(var r=null;;){var o=this.parser.matchStyle(t[n],t[n+1],this,r);if(!o)continue t;if(o.ignore)return null;if(e=this.parser.schema.marks[o.mark].create(o.attrs).addToSet(e),!1!==o.consuming)break;r=o}return e},nt.prototype.addElementByRule=function(t,e,n){var r,o,i,s=this;e.node?(o=this.parser.schema.nodes[e.node]).isLeaf?this.insertNode(o.create(e.attrs))||this.leafFallback(t):r=this.enter(o,e.attrs,e.preserveWhitespace):(i=this.parser.schema.marks[e.mark].create(e.attrs),this.addPendingMark(i));var a,c=this.top;o&&o.isLeaf?this.findInside(t):n?this.addElement(t,n):e.getContent?(this.findInside(t),e.getContent(t,this.parser.schema).forEach(function(t){return s.insertNode(t)})):("string"==typeof(a=e.contentElement)?a=t.querySelector(a):"function"==typeof a&&(a=a(t)),a=a||t,this.findAround(t,a,!0),this.addAll(a,r)),r&&(this.sync(c),this.open--),i&&this.removePendingMark(i,c)},nt.prototype.addAll=function(t,e,n,r){for(var o=n||0,i=n?t.childNodes[n]:t.firstChild,s=null==r?null:t.childNodes[r];i!=s;i=i.nextSibling,++o)this.findAtPoint(t,o),this.addDOM(i),e&&X.hasOwnProperty(i.nodeName.toLowerCase())&&this.sync(e);this.findAtPoint(t,o)},nt.prototype.findPlace=function(t){for(var e,n,r=this.open;0<=r;r--){var o=this.nodes[r],i=o.findWrapping(t);if(i&&(!e||e.length>i.length)&&(n=o,!(e=i).length))break;if(o.solid)break}if(!e)return!1;this.sync(n);for(var s=0;s<e.length;s++)this.enterInner(e[s],null,!1);return!0},nt.prototype.insertNode=function(t){var e;if(!t.isInline||!this.needsBlock||this.top.type||(e=this.textblockFromContext())&&this.enterInner(e),this.findPlace(t)){this.closeExtra();var n=this.top;n.applyPending(t.type),n.match&&(n.match=n.match.matchType(t.type));for(var r=n.activeMarks,o=0;o<t.marks.length;o++)n.type&&!n.type.allowsMarkType(t.marks[o].type)||(r=t.marks[o].addToSet(r));return n.content.push(t.mark(r)),!0}return!1},nt.prototype.enter=function(t,e,n){var r=this.findPlace(t.create(e));return r&&this.enterInner(t,e,!0,n),r},nt.prototype.enterInner=function(t,e,n,r){this.closeExtra();var o=this.top;o.applyPending(t),o.match=o.match&&o.match.matchType(t,e);var i=null==r?-5&o.options:tt(r);4&o.options&&0==o.content.length&&(i|=4),this.nodes.push(new et(t,e,o.activeMarks,o.pendingMarks,n,null,i)),this.open++},nt.prototype.closeExtra=function(t){var e=this.nodes.length-1;if(e>this.open){for(;e>this.open;e--)this.nodes[e-1].content.push(this.nodes[e].finish(t));this.nodes.length=this.open+1}},nt.prototype.finish=function(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)},nt.prototype.sync=function(t){for(var e=this.open;0<=e;e--)if(this.nodes[e]==t)return void(this.open=e)},rt.currentPos.get=function(){this.closeExtra();for(var t=0,e=this.open;0<=e;e--){for(var n=this.nodes[e].content,r=n.length-1;0<=r;r--)t+=n[r].nodeSize;e&&t++}return t},nt.prototype.findAtPoint=function(t,e){if(this.find)for(var n=0;n<this.find.length;n++)this.find[n].node==t&&this.find[n].offset==e&&(this.find[n].pos=this.currentPos)},nt.prototype.findInside=function(t){if(this.find)for(var e=0;e<this.find.length;e++)null==this.find[e].pos&&1==t.nodeType&&t.contains(this.find[e].node)&&(this.find[e].pos=this.currentPos)},nt.prototype.findAround=function(t,e,n){if(t!=e&&this.find)for(var r=0;r<this.find.length;r++){null==this.find[r].pos&&1==t.nodeType&&t.contains(this.find[r].node)&&e.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}},nt.prototype.findInText=function(t){if(this.find)for(var e=0;e<this.find.length;e++)this.find[e].node==t&&(this.find[e].pos=this.currentPos-(t.nodeValue.length-this.find[e].offset))},nt.prototype.matchesContext=function(t){var o=this;if(-1<t.indexOf("|"))return t.split(/\s*\|\s*/).some(this.matchesContext,this);var i=t.split("/"),s=this.options.context,a=!(this.isOpen||s&&s.parent.type!=this.nodes[0].type),c=-(s?s.depth+1:0)+(a?0:1),l=function(t,e){for(;0<=t;t--){var n=i[t];if(""==n){if(t==i.length-1||0==t)continue;for(;c<=e;e--)if(l(t-1,e))return!0;return!1}var r=0<e||0==e&&a?o.nodes[e].type:s&&c<=e?s.node(e-c).type:null;if(!r||r.name!=n&&-1==r.groups.indexOf(n))return!1;e--}return!0};return l(i.length-1,this.open)},nt.prototype.textblockFromContext=function(){var t=this.options.context;if(t)for(var e=t.depth;0<=e;e--){var n=t.node(e).contentMatchAt(t.indexAfter(e)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(var r in this.parser.schema.nodes){var o=this.parser.schema.nodes[r];if(o.isTextblock&&o.defaultAttrs)return o}},nt.prototype.addPendingMark=function(t){var e=function(t,e){for(var n=0;n<e.length;n++)if(t.eq(e[n]))return e[n]}(t,this.top.pendingMarks);e&&this.top.stashMarks.push(e),this.top.pendingMarks=t.addToSet(this.top.pendingMarks)},nt.prototype.removePendingMark=function(t,e){for(var n=this.open;0<=n;n--){var r,o=this.nodes[n];if(-1<o.pendingMarks.lastIndexOf(t)?o.pendingMarks=t.removeFromSet(o.pendingMarks):(o.activeMarks=t.removeFromSet(o.activeMarks),(r=o.popFromStashMark(t))&&(o.activeMarks=r.addToSet(o.activeMarks))),o==e)break}},Object.defineProperties(nt.prototype,rt);function it(t,e){this.nodes=t||{},this.marks=e||{}}function st(t){var e={};for(var n in t){var r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function at(t){return t.document||window.document}it.prototype.serializeFragment=function(t,s,e){var a=this;void 0===s&&(s={});var c=e=e||at(s).createDocumentFragment(),l=null;return t.forEach(function(t){if(l||t.marks.length){l=l||[];for(var e=0,n=0;e<l.length&&n<t.marks.length;){var r=t.marks[n];if(a.marks[r.type.name]){if(!r.eq(l[e])||!1===r.type.spec.spanning)break;e+=2,n++}else n++}for(;e<l.length;)c=l.pop(),l.pop();for(;n<t.marks.length;){var o=t.marks[n++],i=a.serializeMark(o,t.isInline,s);i&&(l.push(o,c),c.appendChild(i.dom),c=i.contentDOM||i.dom)}}c.appendChild(a.serializeNode(t,s))}),e},it.prototype.serializeNode=function(t,e){void 0===e&&(e={});var n=it.renderSpec(at(e),this.nodes[t.type.name](t)),r=n.dom,o=n.contentDOM;if(o){if(t.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");e.onContent?e.onContent(t,o,e):this.serializeFragment(t.content,e,o)}return r},it.prototype.serializeNodeAndMarks=function(t,e){void 0===e&&(e={});for(var n=this.serializeNode(t,e),r=t.marks.length-1;0<=r;r--){var o=this.serializeMark(t.marks[r],t.isInline,e);o&&((o.contentDOM||o.dom).appendChild(n),n=o.dom)}return n},it.prototype.serializeMark=function(t,e,n){void 0===n&&(n={});var r=this.marks[t.type.name];return r&&it.renderSpec(at(n),r(t,e))},it.renderSpec=function(t,e,n){if(void 0===n&&(n=null),"string"==typeof e)return{dom:t.createTextNode(e)};if(null!=e.nodeType)return{dom:e};if(e.dom&&null!=e.dom.nodeType)return e;var r=e[0],o=r.indexOf(" ");0<o&&(n=r.slice(0,o),r=r.slice(o+1));var i,s=null,a=n?t.createElementNS(n,r):t.createElement(r),c=e[1],l=1;if(c&&"object"==typeof c&&null==c.nodeType&&!Array.isArray(c))for(var p in l=2,c){null!=c[p]&&(0<(i=p.indexOf(" "))?a.setAttributeNS(p.slice(0,i),p.slice(i+1),c[p]):a.setAttribute(p,c[p]))}for(var h=l;h<e.length;h++){var u=e[h];if(0===u){if(h<e.length-1||l<h)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}var f=it.renderSpec(t,u,n),d=f.dom,m=f.contentDOM;if(a.appendChild(d),m){if(s)throw new RangeError("Multiple content holes");s=m}}return{dom:a,contentDOM:s}},it.fromSchema=function(t){return t.cached.domSerializer||(t.cached.domSerializer=new it(this.nodesFromSchema(t),this.marksFromSchema(t)))},it.nodesFromSchema=function(t){var e=st(t.nodes);return e.text||(e.text=function(t){return t.text}),e},it.marksFromSchema=function(t){return st(t.marks)};var ct=Object.freeze({__proto__:null,ContentMatch:A,DOMParser:Q,DOMSerializer:it,Fragment:I,Mark:c,MarkType:H,Node:C,NodeRange:S,NodeType:j,ReplaceError:o,ResolvedPos:y,Schema:U,Slice:N}),lt=Math.pow(2,16);function pt(t){return 65535&t}function ht(t,e,n){void 0===e&&(e=!1),void 0===n&&(n=null),this.pos=t,this.deleted=e,this.recover=n}function ut(t,e){void 0===e&&(e=!1),this.ranges=t,this.inverted=e}ut.prototype.recover=function(t){var e,n=0,r=pt(t);if(!this.inverted)for(var o=0;o<r;o++)n+=this.ranges[3*o+2]-this.ranges[3*o+1];return this.ranges[3*r]+n+((e=t)-(65535&e))/lt},ut.prototype.mapResult=function(t,e){return void 0===e&&(e=1),this._map(t,e,!1)},ut.prototype.map=function(t,e){return void 0===e&&(e=1),this._map(t,e,!0)},ut.prototype._map=function(t,e,n){for(var r=0,o=this.inverted?2:1,i=this.inverted?1:2,s=0;s<this.ranges.length;s+=3){var a=this.ranges[s]-(this.inverted?r:0);if(t<a)break;var c=this.ranges[s+o],l=this.ranges[s+i],p=a+c;if(t<=p){var h=a+r+((c?t==a?-1:t==p?1:e:e)<0?0:l);return n?h:new ht(h,e<0?t!=a:t!=p,t==(e<0?a:p)?null:s/3+(t-a)*lt)}r+=l-c}return n?t+r:new ht(t+r)},ut.prototype.touches=function(t,e){for(var n=0,r=pt(e),o=this.inverted?2:1,i=this.inverted?1:2,s=0;s<this.ranges.length;s+=3){var a=this.ranges[s]-(this.inverted?n:0);if(t<a)break;var c=this.ranges[s+o];if(t<=a+c&&s==3*r)return!0;n+=this.ranges[s+i]-c}return!1},ut.prototype.forEach=function(t){for(var e=this.inverted?2:1,n=this.inverted?1:2,r=0,o=0;r<this.ranges.length;r+=3){var i=this.ranges[r],s=i-(this.inverted?o:0),a=i+(this.inverted?0:o),c=this.ranges[r+e],l=this.ranges[r+n];t(s,s+c,a,a+l),o+=l-c}},ut.prototype.invert=function(){return new ut(this.ranges,!this.inverted)},ut.prototype.toString=function(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)},ut.offset=function(t){return 0==t?ut.empty:new ut(t<0?[0,-t,0]:[0,0,t])},ut.empty=new ut([]);function ft(t,e,n,r){this.maps=t||[],this.from=n||0,this.to=null==r?this.maps.length:r,this.mirror=e}function dt(t){var e=Error.call(this,t);return e.__proto__=dt.prototype,e}ft.prototype.slice=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=this.maps.length),new ft(this.maps,this.mirror,t,e)},ft.prototype.copy=function(){return new ft(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)},ft.prototype.appendMap=function(t,e){this.to=this.maps.push(t),null!=e&&this.setMirror(this.maps.length-1,e)},ft.prototype.appendMapping=function(t){for(var e=0,n=this.maps.length;e<t.maps.length;e++){var r=t.getMirror(e);this.appendMap(t.maps[e],null!=r&&r<e?n+r:null)}},ft.prototype.getMirror=function(t){if(this.mirror)for(var e=0;e<this.mirror.length;e++)if(this.mirror[e]==t)return this.mirror[e+(e%2?-1:1)]},ft.prototype.setMirror=function(t,e){this.mirror||(this.mirror=[]),this.mirror.push(t,e)},ft.prototype.appendMappingInverted=function(t){for(var e=t.maps.length-1,n=this.maps.length+t.maps.length;0<=e;e--){var r=t.getMirror(e);this.appendMap(t.maps[e].invert(),null!=r&&e<r?n-r-1:null)}},ft.prototype.invert=function(){var t=new ft;return t.appendMappingInverted(this),t},ft.prototype.map=function(t,e){if(void 0===e&&(e=1),this.mirror)return this._map(t,e,!0);for(var n=this.from;n<this.to;n++)t=this.maps[n].map(t,e);return t},ft.prototype.mapResult=function(t,e){return void 0===e&&(e=1),this._map(t,e,!1)},ft.prototype._map=function(t,e,n){for(var r=!1,o=this.from;o<this.to;o++){var i=this.maps[o].mapResult(t,e);if(null!=i.recover){var s=this.getMirror(o);if(null!=s&&o<s&&s<this.to){o=s,t=this.maps[s].recover(i.recover);continue}}i.deleted&&(r=!0),t=i.pos}return n?t:new ht(t,r)},((dt.prototype=Object.create(Error.prototype)).constructor=dt).prototype.name="TransformError";function mt(t){this.doc=t,this.steps=[],this.docs=[],this.mapping=new ft}var vt={before:{configurable:!0},docChanged:{configurable:!0}};function gt(){throw new Error("Override me")}vt.before.get=function(){return this.docs.length?this.docs[0]:this.doc},mt.prototype.step=function(t){var e=this.maybeStep(t);if(e.failed)throw new dt(e.failed);return this},mt.prototype.maybeStep=function(t){var e=t.apply(this.doc);return e.failed||this.addStep(t,e.doc),e},vt.docChanged.get=function(){return 0<this.steps.length},mt.prototype.addStep=function(t,e){this.docs.push(this.doc),this.steps.push(t),this.mapping.appendMap(t.getMap()),this.doc=e},Object.defineProperties(mt.prototype,vt);function yt(){}var wt=Object.create(null);yt.prototype.apply=gt,yt.prototype.getMap=function(){return ut.empty},yt.prototype.invert=gt,yt.prototype.map=gt,yt.prototype.merge=function(){return null},yt.prototype.toJSON=gt,yt.fromJSON=function(t,e){if(!e||!e.stepType)throw new RangeError("Invalid input for Step.fromJSON");var n=wt[e.stepType];if(!n)throw new RangeError("No step type "+e.stepType+" defined");return n.fromJSON(t,e)},yt.jsonID=function(t,e){if(t in wt)throw new RangeError("Duplicate use of step JSON ID "+t);return(wt[t]=e).prototype.jsonID=t,e};function bt(t,e){this.doc=t,this.failed=e}bt.ok=function(t){return new bt(t,null)},bt.fail=function(t){return new bt(null,t)},bt.fromReplace=function(t,e,n,r){try{return bt.ok(t.replace(e,n,r))}catch(t){if(t instanceof o)return bt.fail(t.message);throw t}};var kt=function(o){function r(t,e,n,r){o.call(this),this.from=t,this.to=e,this.slice=n,this.structure=!!r}return o&&(r.__proto__=o),((r.prototype=Object.create(o&&o.prototype)).constructor=r).prototype.apply=function(t){return this.structure&&St(t,this.from,this.to)?bt.fail("Structure replace would overwrite content"):bt.fromReplace(t,this.from,this.to,this.slice)},r.prototype.getMap=function(){return new ut([this.from,this.to-this.from,this.slice.size])},r.prototype.invert=function(t){return new r(this.from,this.from+this.slice.size,t.slice(this.from,this.to))},r.prototype.map=function(t){var e=t.mapResult(this.from,1),n=t.mapResult(this.to,-1);return e.deleted&&n.deleted?null:new r(e.pos,Math.max(e.pos,n.pos),this.slice)},r.prototype.merge=function(t){if(!(t instanceof r)||t.structure!=this.structure)return null;if(this.from+this.slice.size!=t.from||this.slice.openEnd||t.slice.openStart){if(t.to!=this.from||this.slice.openStart||t.slice.openEnd)return null;var e=this.slice.size+t.slice.size==0?N.empty:new N(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new r(t.from,this.to,e,this.structure)}var n=this.slice.size+t.slice.size==0?N.empty:new N(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new r(this.from,this.to+(t.to-t.from),n,this.structure)},r.prototype.toJSON=function(){var t={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t},r.fromJSON=function(t,e){if("number"!=typeof e.from||"number"!=typeof e.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new r(e.from,e.to,N.fromJSON(t,e.slice),!!e.structure)},r}(yt);yt.jsonID("replace",kt);var xt=function(a){function i(t,e,n,r,o,i,s){a.call(this),this.from=t,this.to=e,this.gapFrom=n,this.gapTo=r,this.slice=o,this.insert=i,this.structure=!!s}return a&&(i.__proto__=a),((i.prototype=Object.create(a&&a.prototype)).constructor=i).prototype.apply=function(t){if(this.structure&&(St(t,this.from,this.gapFrom)||St(t,this.gapTo,this.to)))return bt.fail("Structure gap-replace would overwrite content");var e=t.slice(this.gapFrom,this.gapTo);if(e.openStart||e.openEnd)return bt.fail("Gap is not a flat range");var n=this.slice.insertAt(this.insert,e.content);return n?bt.fromReplace(t,this.from,this.to,n):bt.fail("Content does not fit in gap")},i.prototype.getMap=function(){return new ut([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])},i.prototype.invert=function(t){var e=this.gapTo-this.gapFrom;return new i(this.from,this.from+this.slice.size+e,this.from+this.insert,this.from+this.insert+e,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)},i.prototype.map=function(t){var e=t.mapResult(this.from,1),n=t.mapResult(this.to,-1),r=t.map(this.gapFrom,-1),o=t.map(this.gapTo,1);return e.deleted&&n.deleted||r<e.pos||o>n.pos?null:new i(e.pos,n.pos,r,o,this.slice,this.insert,this.structure)},i.prototype.toJSON=function(){var t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t},i.fromJSON=function(t,e){if("number"!=typeof e.from||"number"!=typeof e.to||"number"!=typeof e.gapFrom||"number"!=typeof e.gapTo||"number"!=typeof e.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new i(e.from,e.to,e.gapFrom,e.gapTo,N.fromJSON(t,e.slice),e.insert,!!e.structure)},i}(yt);function St(t,e,n){for(var r=t.resolve(e),o=n-e,i=r.depth;0<o&&0<i&&r.indexAfter(i)==r.node(i).childCount;)i--,o--;if(0<o)for(var s=r.node(i).maybeChild(r.indexAfter(i));0<o;){if(!s||s.isLeaf)return 1;s=s.firstChild,o--}}function Mt(t){for(var e,n,r,o=t.parent.content.cutByIndex(t.startIndex,t.endIndex),i=t.depth;;--i){var s=t.$from.node(i),a=t.$from.index(i),c=t.$to.indexAfter(i);if(i<t.depth&&s.canReplace(a,c,o))return i;if(0==i||s.type.spec.isolating||(e=s,r=c,0!=(n=a)&&!e.canReplace(n,e.childCount)||r!=e.childCount&&!e.canReplace(0,r)))break}}function Ct(t,e,n,r){void 0===r&&(r=t);var o=function(t,e){var n=t.parent,r=t.startIndex,o=t.endIndex,i=n.contentMatchAt(r).findWrapping(e);if(!i)return null;var s=i.length?i[0]:e;return n.canReplaceWith(r,o,s)?i:null}(t,e),i=o&&function(t,e){var n=t.parent,r=t.startIndex,o=t.endIndex,i=n.child(r),s=e.contentMatch.findWrapping(i.type);if(!s)return null;for(var a=(s.length?s[s.length-1]:e).contentMatch,c=r;a&&c<o;c++)a=a.matchType(n.child(c).type);return a&&a.validEnd?s:null}(r,e);return i?o.map(Ot).concat({type:e,attrs:n}).concat(i.map(Ot)):null}function Ot(t){return{type:t,attrs:null}}function Nt(t,e,n,r){void 0===n&&(n=1);var o=t.resolve(e),i=o.depth-n,s=r&&r[r.length-1]||o.parent;if(i<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!s.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(var a=o.depth-1,c=n-2;i<a;a--,c--){var l=o.node(a),p=o.index(a);if(l.type.spec.isolating)return!1;var h=l.content.cutByIndex(p,l.childCount),u=r&&r[c]||l;if(u!=l&&(h=h.replaceChild(0,u.type.create(u.attrs))),!l.canReplace(p+1,l.childCount)||!u.type.validContent(h))return!1}var f=o.indexAfter(i),d=r&&r[0];return o.node(i).canReplaceWith(f,f,d?d.type:o.node(1+i).type)}function Tt(t,e){var n=t.resolve(e),r=n.index();return Dt(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function Dt(t,e){return t&&e&&!t.isLeaf&&t.canAppend(e)}function Et(t,e,n){void 0===n&&(n=-1);for(var r=t.resolve(e),o=r.depth;;o--){var i=void 0,s=void 0,a=r.index(o),s=o==r.depth?(i=r.nodeBefore,r.nodeAfter):0<n?(i=r.node(o+1),a++,r.node(o).maybeChild(a)):(i=r.node(o).maybeChild(a-1),r.node(o+1));if(i&&!i.isTextblock&&Dt(i,s)&&r.node(o).canReplace(a,a+1))return e;if(0==o)break;e=n<0?r.before(o):r.after(o)}}function At(t,e,n){var r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(0==r.parentOffset)for(var o=r.depth-1;0<=o;o--){var i=r.index(o);if(r.node(o).canReplaceWith(i,i,n))return r.before(o+1);if(0<i)return null}if(r.parentOffset==r.parent.content.size)for(var s=r.depth-1;0<=s;s--){var a=r.indexAfter(s);if(r.node(s).canReplaceWith(a,a,n))return r.after(s+1);if(a<r.node(s).childCount)return null}}function It(t,e,n){var r=t.resolve(e);if(!n.content.size)return e;for(var o=n.content,i=0;i<n.openStart;i++)o=o.firstChild.content;for(var s=1;s<=(0==n.openStart&&n.size?2:1);s++)for(var a=r.depth;0<=a;a--){var c=a==r.depth?0:r.pos<=(r.start(a+1)+r.end(a+1))/2?-1:1,l=r.index(a)+(0<c?1:0);if(1==s?r.node(a).canReplace(l,l,o):r.node(a).contentMatchAt(l).findWrapping(o.firstChild.type))return 0==c?r.pos:c<0?r.before(a+1):r.after(a+1)}return null}function Rt(t,e,n){for(var r=[],o=0;o<t.childCount;o++){var i=t.child(o);i.content.size&&(i=i.copy(Rt(i.content,e,i))),i.isInline&&(i=e(i,n,o)),r.push(i)}return I.fromArray(r)}yt.jsonID("replaceAround",xt),mt.prototype.lift=function(t,e){for(var n=t.$from,r=t.$to,o=t.depth,i=n.before(o+1),s=r.after(o+1),a=i,c=s,l=I.empty,p=0,h=o,u=!1;e<h;h--)u||0<n.index(h)?(u=!0,l=I.from(n.node(h).copy(l)),p++):a--;for(var f=I.empty,d=0,m=o,v=!1;e<m;m--)v||r.after(m+1)<r.end(m)?(v=!0,f=I.from(r.node(m).copy(f)),d++):c++;return this.step(new xt(a,c,i,s,new N(l.append(f),p,d),l.size-p,!0))},mt.prototype.wrap=function(t,e){for(var n=I.empty,r=e.length-1;0<=r;r--)n=I.from(e[r].type.create(e[r].attrs,n));var o=t.start,i=t.end;return this.step(new xt(o,i,o,i,new N(n,0,0),e.length,!0))},mt.prototype.setBlockType=function(t,e,p,h){var u=this;if(void 0===e&&(e=t),!p.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");var f=this.steps.length;return this.doc.nodesBetween(t,e,function(t,e){if(t.isTextblock&&!t.hasMarkup(p,h)&&(i=u.doc,s=u.mapping.slice(f).map(e),a=p,c=i.resolve(s),l=c.index(),c.parent.canReplaceWith(l,l+1,a))){u.clearIncompatible(u.mapping.slice(f).map(e,1),p);var n=u.mapping.slice(f),r=n.map(e,1),o=n.map(e+t.nodeSize,1);return u.step(new xt(r,o,r+1,o-1,new N(I.from(p.create(h,null,t.marks)),0,0),1,!0)),!1}var i,s,a,c,l}),this},mt.prototype.setNodeMarkup=function(t,e,n,r){var o=this.doc.nodeAt(t);if(!o)throw new RangeError("No node at given position");var i=(e=e||o.type).create(n,null,r||o.marks);if(o.isLeaf)return this.replaceWith(t,t+o.nodeSize,i);if(!e.validContent(o.content))throw new RangeError("Invalid content for node type "+e.name);return this.step(new xt(t,t+o.nodeSize,t+1,t+o.nodeSize-1,new N(I.from(i),0,0),1,!0))},mt.prototype.split=function(t,e,n){void 0===e&&(e=1);for(var r=this.doc.resolve(t),o=I.empty,i=I.empty,s=r.depth,a=r.depth-e,c=e-1;a<s;s--,c--){o=I.from(r.node(s).copy(o));var l=n&&n[c],i=I.from(l?l.type.create(l.attrs,i):r.node(s).copy(i))}return this.step(new kt(t,t,new N(o.append(i),e,e),!0))},mt.prototype.join=function(t,e){void 0===e&&(e=1);var n=new kt(t-e,t+e,N.empty,!0);return this.step(n)};var zt=function(r){function o(t,e,n){r.call(this),this.from=t,this.to=e,this.mark=n}return r&&(o.__proto__=r),((o.prototype=Object.create(r&&r.prototype)).constructor=o).prototype.apply=function(t){var n=this,e=t.slice(this.from,this.to),r=t.resolve(this.from),o=r.node(r.sharedDepth(this.to)),i=new N(Rt(e.content,function(t,e){return e.type.allowsMarkType(n.mark.type)?t.mark(n.mark.addToSet(t.marks)):t},o),e.openStart,e.openEnd);return bt.fromReplace(t,this.from,this.to,i)},o.prototype.invert=function(){return new Pt(this.from,this.to,this.mark)},o.prototype.map=function(t){var e=t.mapResult(this.from,1),n=t.mapResult(this.to,-1);return e.deleted&&n.deleted||e.pos>=n.pos?null:new o(e.pos,n.pos,this.mark)},o.prototype.merge=function(t){if(t instanceof o&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from)return new o(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark)},o.prototype.toJSON=function(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}},o.fromJSON=function(t,e){if("number"!=typeof e.from||"number"!=typeof e.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new o(e.from,e.to,t.markFromJSON(e.mark))},o}(yt);yt.jsonID("addMark",zt);var Pt=function(r){function o(t,e,n){r.call(this),this.from=t,this.to=e,this.mark=n}return r&&(o.__proto__=r),((o.prototype=Object.create(r&&r.prototype)).constructor=o).prototype.apply=function(t){var e=this,n=t.slice(this.from,this.to),r=new N(Rt(n.content,function(t){return t.mark(e.mark.removeFromSet(t.marks))}),n.openStart,n.openEnd);return bt.fromReplace(t,this.from,this.to,r)},o.prototype.invert=function(){return new zt(this.from,this.to,this.mark)},o.prototype.map=function(t){var e=t.mapResult(this.from,1),n=t.mapResult(this.to,-1);return e.deleted&&n.deleted||e.pos>=n.pos?null:new o(e.pos,n.pos,this.mark)},o.prototype.merge=function(t){if(t instanceof o&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from)return new o(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark)},o.prototype.toJSON=function(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}},o.fromJSON=function(t,e){if("number"!=typeof e.from||"number"!=typeof e.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new o(e.from,e.to,t.markFromJSON(e.mark))},o}(yt);function _t(t,e,n,r){if(void 0===n&&(n=e),void 0===r&&(r=N.empty),e==n&&!r.size)return null;var o=t.resolve(e),i=t.resolve(n);return Bt(o,i,r)?new kt(e,n,r):new Vt(o,i,r).fit()}function Bt(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}yt.jsonID("removeMark",Pt),mt.prototype.addMark=function(c,l,p){var e=this,h=[],u=[],f=null,d=null;return this.doc.nodesBetween(c,l,function(t,e,n){if(t.isInline){var r=t.marks;if(!p.isInSet(r)&&n.type.allowsMarkType(p.type)){for(var o=Math.max(e,c),i=Math.min(e+t.nodeSize,l),s=p.addToSet(r),a=0;a<r.length;a++)r[a].isInSet(s)||(f&&f.to==o&&f.mark.eq(r[a])?f.to=i:h.push(f=new Pt(o,i,r[a])));d&&d.to==o?d.to=i:u.push(d=new zt(o,i,p))}}}),h.forEach(function(t){return e.step(t)}),u.forEach(function(t){return e.step(t)}),this},mt.prototype.removeMark=function(p,h,u){var e=this;void 0===u&&(u=null);var f=[],d=0;return this.doc.nodesBetween(p,h,function(t,e){if(t.isInline){d++;var n,r=null;if(u instanceof H?(n=u.isInSet(t.marks))&&(r=[n]):u?u.isInSet(t.marks)&&(r=[u]):r=t.marks,r&&r.length)for(var o=Math.min(e+t.nodeSize,h),i=0;i<r.length;i++){for(var s=r[i],a=void 0,c=0;c<f.length;c++){var l=f[c];l.step==d-1&&s.eq(f[c].style)&&(a=l)}a?(a.to=o,a.step=d):f.push({style:s,from:Math.max(e,p),to:o,step:d})}}}),f.forEach(function(t){return e.step(new Pt(t.from,t.to,t.style))}),this},mt.prototype.clearIncompatible=function(t,e,n){void 0===n&&(n=e.contentMatch);for(var r,o=this.doc.nodeAt(t),i=[],s=t+1,a=0;a<o.childCount;a++){var c=o.child(a),l=s+c.nodeSize,p=n.matchType(c.type,c.attrs);if(p){n=p;for(var h=0;h<c.marks.length;h++)e.allowsMarkType(c.marks[h].type)||this.step(new Pt(s,l,c.marks[h]))}else i.push(new kt(s,l,N.empty));s=l}n.validEnd||(r=n.fillBefore(I.empty,!0),this.replace(s,s,new N(r,0,0)));for(var u=i.length-1;0<=u;u--)this.step(i[u]);return this},mt.prototype.replace=function(t,e,n){void 0===e&&(e=t),void 0===n&&(n=N.empty);var r=_t(this.doc,t,e,n);return r&&this.step(r),this},mt.prototype.replaceWith=function(t,e,n){return this.replace(t,e,new N(I.from(n),0,0))},mt.prototype.delete=function(t,e){return this.replace(t,e,N.empty)},mt.prototype.insert=function(t,e){return this.replaceWith(t,t,e)};var Vt=function(t,e,n){this.$to=e,this.$from=t,this.unplaced=n,this.frontier=[];for(var r=0;r<=t.depth;r++){var o=t.node(r);this.frontier.push({type:o.type,match:o.contentMatchAt(t.indexAfter(r))})}this.placed=I.empty;for(var i=t.depth;0<i;i--)this.placed=I.from(t.node(i).copy(this.placed))},$t={depth:{configurable:!0}};function Ft(t,e,n){return 0==e?t.cutByIndex(n):t.replaceChild(0,t.firstChild.copy(Ft(t.firstChild.content,e-1,n)))}function qt(t,e,n){return 0==e?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(qt(t.lastChild.content,e-1,n)))}function Lt(t,e){for(var n=0;n<e;n++)t=t.firstChild.content;return t}function jt(t,e,n,r,o){var i=t.node(e),s=o?t.indexAfter(e):t.index(e);if(s==i.childCount&&!n.compatibleContent(i.type))return null;var a=r.fillBefore(i.content,!0,s);return a&&!function(t,e,n){for(var r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}(n,i.content,s)?a:null}function Jt(t,e){for(var n=[],r=Math.min(t.depth,e.depth);0<=r;r--){var o=t.start(r);if(o<t.pos-(t.depth-r)||e.end(r)>e.pos+(e.depth-r)||t.node(r).type.spec.isolating||e.node(r).type.spec.isolating)break;o==e.start(r)&&n.push(r)}return n}$t.depth.get=function(){return this.frontier.length-1},Vt.prototype.fit=function(){for(;this.unplaced.size;){var t=this.findFittable();t?this.placeNodes(t):this.openMore()||this.dropNode()}var e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,o=this.close(e<0?this.$to:r.doc.resolve(e));if(!o)return null;for(var i=this.placed,s=r.depth,a=o.depth;s&&a&&1==i.childCount;)i=i.firstChild.content,s--,a--;var c=new N(i,s,a);return-1<e?new xt(r.pos,e,this.$to.pos,this.$to.end(),c,n):c.size||r.pos!=this.$to.pos?new kt(r.pos,o.pos,c):void 0},Vt.prototype.findFittable=function(){for(var t=1;t<=2;t++)for(var e=this.unplaced.openStart;0<=e;e--)for(var n=void 0,r=(e?(n=Lt(this.unplaced.content,e-1).firstChild).content:this.unplaced.content).firstChild,o=this.depth;0<=o;o--){var i=this.frontier[o],s=i.type,a=i.match,c=void 0,l=void 0;if(1==t&&(r?a.matchType(r.type)||(l=a.fillBefore(I.from(r),!1)):s.compatibleContent(n.type)))return{sliceDepth:e,frontierDepth:o,parent:n,inject:l};if(2==t&&r&&(c=a.findWrapping(r.type)))return{sliceDepth:e,frontierDepth:o,parent:n,wrap:c};if(n&&a.matchType(n.type))break}},Vt.prototype.openMore=function(){var t=this.unplaced,e=t.content,n=t.openStart,r=t.openEnd,o=Lt(e,n);return!(!o.childCount||o.firstChild.isLeaf)&&(this.unplaced=new N(e,n+1,Math.max(r,o.size+n>=e.size-r?n+1:0)),!0)},Vt.prototype.dropNode=function(){var t,e=this.unplaced,n=e.content,r=e.openStart,o=e.openEnd,i=Lt(n,r);i.childCount<=1&&0<r?(t=n.size-r<=r+i.size,this.unplaced=new N(Ft(n,r-1,1),r-1,t?r-1:o)):this.unplaced=new N(Ft(n,r,1),r,o)},Vt.prototype.placeNodes=function(t){for(var e=t.sliceDepth,n=t.frontierDepth,r=t.parent,o=t.inject,i=t.wrap;this.depth>n;)this.closeFrontierNode();if(i)for(var s=0;s<i.length;s++)this.openFrontierNode(i[s]);var a=this.unplaced,c=r?r.content:a.content,l=a.openStart-e,p=0,h=[],u=this.frontier[n],f=u.match,d=u.type;if(o){for(var m=0;m<o.childCount;m++)h.push(o.child(m));f=f.matchFragment(o)}for(var v=c.size+e-(a.content.size-a.openEnd);p<c.childCount;){var g=c.child(p),y=f.matchType(g.type);if(!y)break;(1<++p||0==l||g.content.size)&&(f=y,h.push(function t(e,n,r){if(n<=0)return e;var o=e.content;1<n&&(o=o.replaceChild(0,t(o.firstChild,n-1,1==o.childCount?r-1:0)));0<n&&(o=e.type.contentMatch.fillBefore(o).append(o),r<=0&&(o=o.append(e.type.contentMatch.matchFragment(o).fillBefore(I.empty,!0))));return e.copy(o)}(g.mark(d.allowedMarks(g.marks)),1==p?l:0,p==c.childCount?v:-1)))}var w=p==c.childCount;w||(v=-1),this.placed=qt(this.placed,n,I.from(h)),this.frontier[n].match=f,w&&v<0&&r&&r.type==this.frontier[this.depth].type&&1<this.frontier.length&&this.closeFrontierNode();for(var b=0,k=c;b<v;b++){var x=k.lastChild;this.frontier.push({type:x.type,match:x.contentMatchAt(x.childCount)}),k=x.content}this.unplaced=w?0==e?N.empty:new N(Ft(a.content,e-1,1),e-1,v<0?a.openEnd:e-1):new N(Ft(a.content,e,p),a.openStart,a.openEnd)},Vt.prototype.mustMoveInline=function(){if(!this.$to.parent.isTextblock||this.$to.end()==this.$to.pos)return-1;var t,e=this.frontier[this.depth];if(!e.type.isTextblock||!jt(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;for(var n=this.$to.depth,r=this.$to.after(n);1<n&&r==this.$to.end(--n);)++r;return r},Vt.prototype.findCloseLevel=function(t){t:for(var e=Math.min(this.depth,t.depth);0<=e;e--){var n=this.frontier[e],r=n.match,o=n.type,i=e<t.depth&&t.end(e+1)==t.pos+(t.depth-(e+1)),s=jt(t,e,o,r,i);if(s){for(var a=e-1;0<=a;a--){var c=this.frontier[a],l=c.match,p=jt(t,a,c.type,l,!0);if(!p||p.childCount)continue t}return{depth:e,fit:s,move:i?t.doc.resolve(t.after(e+1)):t}}}},Vt.prototype.close=function(t){var e=this.findCloseLevel(t);if(!e)return null;for(;this.depth>e.depth;)this.closeFrontierNode();e.fit.childCount&&(this.placed=qt(this.placed,e.depth,e.fit)),t=e.move;for(var n=e.depth+1;n<=t.depth;n++){var r=t.node(n),o=r.type.contentMatch.fillBefore(r.content,!0,t.index(n));this.openFrontierNode(r.type,r.attrs,o)}return t},Vt.prototype.openFrontierNode=function(t,e,n){var r=this.frontier[this.depth];r.match=r.match.matchType(t),this.placed=qt(this.placed,this.depth,I.from(t.create(e,n))),this.frontier.push({type:t,match:t.contentMatch})},Vt.prototype.closeFrontierNode=function(){var t=this.frontier.pop().match.fillBefore(I.empty,!0);t.childCount&&(this.placed=qt(this.placed,this.frontier.length,t))},Object.defineProperties(Vt.prototype,$t),mt.prototype.replaceRange=function(t,e,n){if(!n.size)return this.deleteRange(t,e);var r=this.doc.resolve(t),o=this.doc.resolve(e);if(Bt(r,o,n))return this.step(new kt(t,e,n));var i=Jt(r,this.doc.resolve(e));0==i[i.length-1]&&i.pop();var s=-(r.depth+1);i.unshift(s);for(var a=r.depth,c=r.pos-1;0<a;a--,c--){var l=r.node(a).type.spec;if(l.defining||l.isolating)break;-1<i.indexOf(a)?s=a:r.before(a)==c&&i.splice(1,0,-a)}for(var p=i.indexOf(s),h=[],u=n.openStart,f=n.content,d=0;;d++){var m=f.firstChild;if(h.push(m),d==n.openStart)break;f=m.content}0<u&&h[u-1].type.spec.defining&&r.node(p).type!=h[u-1].type?--u:2<=u&&h[u-1].isTextblock&&h[u-2].type.spec.defining&&r.node(p).type!=h[u-2].type&&(u-=2);for(var v=n.openStart;0<=v;v--){var g=(v+u+1)%(n.openStart+1),y=h[g];if(y)for(var w=0;w<i.length;w++){var b=i[(w+p)%i.length],k=!0;b<0&&(k=!1,b=-b);var x=r.node(b-1),S=r.index(b-1);if(x.canReplaceWith(S,S,y.type,y.marks))return this.replace(r.before(b),k?o.after(b):e,new N(function t(e,n,r,o,i){{var s;n<r&&(s=e.firstChild,e=e.replaceChild(0,s.copy(t(s.content,n+1,r,o,s))))}{var a,c;o<n&&(a=i.contentMatchAt(0),c=a.fillBefore(e).append(e),e=c.append(a.matchFragment(c).fillBefore(I.empty,!0)))}return e}(n.content,0,n.openStart,g),g,n.openEnd))}}for(var M=this.steps.length,C=i.length-1;0<=C&&(this.replace(t,e,n),!(this.steps.length>M));C--){var O=i[C];C<0||(t=r.before(O),e=o.after(O))}return this},mt.prototype.replaceRangeWith=function(t,e,n){var r;return n.isInline||t!=e||!this.doc.resolve(t).parent.content.size||null!=(r=At(this.doc,t,n.type))&&(t=e=r),this.replaceRange(t,e,new N(I.from(n),0,0))},mt.prototype.deleteRange=function(t,e){for(var n=this.doc.resolve(t),r=this.doc.resolve(e),o=Jt(n,r),i=0;i<o.length;i++){var s=o[i],a=i==o.length-1;if(a&&0==s||n.node(s).type.contentMatch.validEnd)return this.delete(n.start(s),r.end(s));if(0<s&&(a||n.node(s-1).canReplace(n.index(s-1),r.indexAfter(s-1))))return this.delete(n.before(s),r.after(s))}for(var c=1;c<=n.depth&&c<=r.depth;c++)if(t-n.start(c)==n.depth-c&&e>n.end(c)&&r.end(c)-e!=r.depth-c)return this.delete(n.before(c),e);return this.delete(t,e)};var Wt=Object.freeze({__proto__:null,AddMarkStep:zt,MapResult:ht,Mapping:ft,RemoveMarkStep:Pt,ReplaceAroundStep:xt,ReplaceStep:kt,Step:yt,StepMap:ut,StepResult:bt,Transform:mt,TransformError:dt,canJoin:Tt,canSplit:Nt,dropPoint:It,findWrapping:Ct,insertPoint:At,joinPoint:Et,liftTarget:Mt,replaceStep:_t}),Kt=Object.create(null),Ht=function(t,e,n){this.ranges=n||[new Gt(t.min(e),t.max(e))],this.$anchor=t,this.$head=e},Ut={anchor:{configurable:!0},head:{configurable:!0},from:{configurable:!0},to:{configurable:!0},$from:{configurable:!0},$to:{configurable:!0},empty:{configurable:!0}};Ut.anchor.get=function(){return this.$anchor.pos},Ut.head.get=function(){return this.$head.pos},Ut.from.get=function(){return this.$from.pos},Ut.to.get=function(){return this.$to.pos},Ut.$from.get=function(){return this.ranges[0].$from},Ut.$to.get=function(){return this.ranges[0].$to},Ut.empty.get=function(){for(var t=this.ranges,e=0;e<t.length;e++)if(t[e].$from.pos!=t[e].$to.pos)return!1;return!0},Ht.prototype.content=function(){return this.$from.node(0).slice(this.from,this.to,!0)},Ht.prototype.replace=function(t,e){void 0===e&&(e=N.empty);for(var n=e.content.lastChild,r=null,o=0;o<e.openEnd;o++)n=(r=n).lastChild;for(var i=t.steps.length,s=this.ranges,a=0;a<s.length;a++){var c=s[a],l=c.$from,p=c.$to,h=t.mapping.slice(i);t.replaceRange(h.map(l.pos),h.map(p.pos),a?N.empty:e),0==a&&re(t,i,(n?n.isInline:r&&r.isTextblock)?-1:1)}},Ht.prototype.replaceWith=function(t,e){for(var n=t.steps.length,r=this.ranges,o=0;o<r.length;o++){var i=r[o],s=i.$from,a=i.$to,c=t.mapping.slice(n),l=c.map(s.pos),p=c.map(a.pos);o?t.deleteRange(l,p):(t.replaceRangeWith(l,p,e),re(t,n,e.isInline?-1:1))}},Ht.findFrom=function(t,e,n){var r=t.parent.inlineContent?new Qt(t):ne(t.node(0),t.parent,t.pos,t.index(),e,n);if(r)return r;for(var o=t.depth-1;0<=o;o--){var i=e<0?ne(t.node(0),t.node(o),t.before(o+1),t.index(o),e,n):ne(t.node(0),t.node(o),t.after(o+1),t.index(o)+1,e,n);if(i)return i}},Ht.near=function(t,e){return void 0===e&&(e=1),this.findFrom(t,e)||this.findFrom(t,-e)||new te(t.node(0))},Ht.atStart=function(t){return ne(t,t,0,0,1)||new te(t)},Ht.atEnd=function(t){return ne(t,t,t.content.size,t.childCount,-1)||new te(t)},Ht.fromJSON=function(t,e){if(!e||!e.type)throw new RangeError("Invalid input for Selection.fromJSON");var n=Kt[e.type];if(!n)throw new RangeError("No selection type "+e.type+" defined");return n.fromJSON(t,e)},Ht.jsonID=function(t,e){if(t in Kt)throw new RangeError("Duplicate use of selection JSON ID "+t);return(Kt[t]=e).prototype.jsonID=t,e},Ht.prototype.getBookmark=function(){return Qt.between(this.$anchor,this.$head).getBookmark()},Object.defineProperties(Ht.prototype,Ut),Ht.prototype.visible=!0;var Gt=function(t,e){this.$from=t,this.$to=e},Qt=function(i){function s(t,e){void 0===e&&(e=t),i.call(this,t,e)}i&&(s.__proto__=i),(s.prototype=Object.create(i&&i.prototype)).constructor=s;var t={$cursor:{configurable:!0}};return t.$cursor.get=function(){return this.$anchor.pos==this.$head.pos?this.$head:null},s.prototype.map=function(t,e){var n=t.resolve(e.map(this.head));if(!n.parent.inlineContent)return i.near(n);var r=t.resolve(e.map(this.anchor));return new s(r.parent.inlineContent?r:n,n)},s.prototype.replace=function(t,e){var n;void 0===e&&(e=N.empty),i.prototype.replace.call(this,t,e),e!=N.empty||(n=this.$from.marksAcross(this.$to))&&t.ensureMarks(n)},s.prototype.eq=function(t){return t instanceof s&&t.anchor==this.anchor&&t.head==this.head},s.prototype.getBookmark=function(){return new Xt(this.anchor,this.head)},s.prototype.toJSON=function(){return{type:"text",anchor:this.anchor,head:this.head}},s.fromJSON=function(t,e){if("number"!=typeof e.anchor||"number"!=typeof e.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new s(t.resolve(e.anchor),t.resolve(e.head))},s.create=function(t,e,n){void 0===n&&(n=e);var r=t.resolve(e);return new this(r,n==e?r:t.resolve(n))},s.between=function(t,e,n){var r=t.pos-e.pos;if(n&&!r||(n=0<=r?1:-1),!e.parent.inlineContent){var o=i.findFrom(e,n,!0)||i.findFrom(e,-n,!0);if(!o)return i.near(e,n);e=o.$head}return t.parent.inlineContent||0!=r&&(t=(i.findFrom(t,-n,!0)||i.findFrom(t,n,!0)).$anchor).pos<e.pos==r<0||(t=e),new s(t,e)},Object.defineProperties(s.prototype,t),s}(Ht);Ht.jsonID("text",Qt);var Xt=function(t,e){this.anchor=t,this.head=e};Xt.prototype.map=function(t){return new Xt(t.map(this.anchor),t.map(this.head))},Xt.prototype.resolve=function(t){return Qt.between(t.resolve(this.anchor),t.resolve(this.head))};var Yt=function(s){function a(t){var e=t.nodeAfter,n=t.node(0).resolve(t.pos+e.nodeSize);s.call(this,t,n),this.node=e}return s&&(a.__proto__=s),((a.prototype=Object.create(s&&s.prototype)).constructor=a).prototype.map=function(t,e){var n=e.mapResult(this.anchor),r=n.deleted,o=n.pos,i=t.resolve(o);return r?s.near(i):new a(i)},a.prototype.content=function(){return new N(I.from(this.node),0,0)},a.prototype.eq=function(t){return t instanceof a&&t.anchor==this.anchor},a.prototype.toJSON=function(){return{type:"node",anchor:this.anchor}},a.prototype.getBookmark=function(){return new Zt(this.anchor)},a.fromJSON=function(t,e){if("number"!=typeof e.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new a(t.resolve(e.anchor))},a.create=function(t,e){return new this(t.resolve(e))},a.isSelectable=function(t){return!t.isText&&!1!==t.type.spec.selectable},a}(Ht);Yt.prototype.visible=!1,Ht.jsonID("node",Yt);var Zt=function(t){this.anchor=t};Zt.prototype.map=function(t){var e=t.mapResult(this.anchor),n=e.deleted,r=e.pos;return n?new Xt(r,r):new Zt(r)},Zt.prototype.resolve=function(t){var e=t.resolve(this.anchor),n=e.nodeAfter;return n&&Yt.isSelectable(n)?new Yt(e):Ht.near(e)};var te=function(r){function e(t){r.call(this,t.resolve(0),t.resolve(t.content.size))}return r&&(e.__proto__=r),((e.prototype=Object.create(r&&r.prototype)).constructor=e).prototype.replace=function(t,e){var n;void 0===e&&(e=N.empty),e==N.empty?(t.delete(0,t.doc.content.size),(n=r.atStart(t.doc)).eq(t.selection)||t.setSelection(n)):r.prototype.replace.call(this,t,e)},e.prototype.toJSON=function(){return{type:"all"}},e.fromJSON=function(t){return new e(t)},e.prototype.map=function(t){return new e(t)},e.prototype.eq=function(t){return t instanceof e},e.prototype.getBookmark=function(){return ee},e}(Ht);Ht.jsonID("all",te);var ee={map:function(){return this},resolve:function(t){return new te(t)}};function ne(t,e,n,r,o,i){if(e.inlineContent)return Qt.create(t,n);for(var s=r-(0<o?0:1);0<o?s<e.childCount:0<=s;s+=o){var a=e.child(s);if(a.isAtom){if(!i&&Yt.isSelectable(a))return Yt.create(t,n-(o<0?a.nodeSize:0))}else{var c=ne(t,a,n+o,o<0?a.childCount:0,o,i);if(c)return c}n+=a.nodeSize*o}}function re(t,e,n){var r,o,i=t.steps.length-1;i<e||((r=t.steps[i])instanceof kt||r instanceof xt)&&(t.mapping.maps[i].forEach(function(t,e,n,r){null==o&&(o=r)}),t.setSelection(Ht.near(t.doc.resolve(o),n)))}var oe=function(n){function t(t){n.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)}n&&(t.__proto__=n),(t.prototype=Object.create(n&&n.prototype)).constructor=t;var e={selection:{configurable:!0},selectionSet:{configurable:!0},storedMarksSet:{configurable:!0},isGeneric:{configurable:!0},scrolledIntoView:{configurable:!0}};return e.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(t){if(t.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=t,this.curSelectionFor=this.steps.length,this.updated=-3&(1|this.updated),this.storedMarks=null,this},e.selectionSet.get=function(){return 0<(1&this.updated)},t.prototype.setStoredMarks=function(t){return this.storedMarks=t,this.updated|=2,this},t.prototype.ensureMarks=function(t){return c.sameSet(this.storedMarks||this.selection.$from.marks(),t)||this.setStoredMarks(t),this},t.prototype.addStoredMark=function(t){return this.ensureMarks(t.addToSet(this.storedMarks||this.selection.$head.marks()))},t.prototype.removeStoredMark=function(t){return this.ensureMarks(t.removeFromSet(this.storedMarks||this.selection.$head.marks()))},e.storedMarksSet.get=function(){return 0<(2&this.updated)},t.prototype.addStep=function(t,e){n.prototype.addStep.call(this,t,e),this.updated=-3&this.updated,this.storedMarks=null},t.prototype.setTime=function(t){return this.time=t,this},t.prototype.replaceSelection=function(t){return this.selection.replace(this,t),this},t.prototype.replaceSelectionWith=function(t,e){var n=this.selection;return!1!==e&&(t=t.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||c.none))),n.replaceWith(this,t),this},t.prototype.deleteSelection=function(){return this.selection.replace(this),this},t.prototype.insertText=function(t,e,n){void 0===n&&(n=e);var r=this.doc.type.schema;if(null==e)return t?this.replaceSelectionWith(r.text(t),!0):this.deleteSelection();if(!t)return this.deleteRange(e,n);var o,i=this.storedMarks;return i||(o=this.doc.resolve(e),i=n==e?o.marks():o.marksAcross(this.doc.resolve(n))),this.replaceRangeWith(e,n,r.text(t,i)),this.selection.empty||this.setSelection(Ht.near(this.selection.$to)),this},t.prototype.setMeta=function(t,e){return this.meta["string"==typeof t?t:t.key]=e,this},t.prototype.getMeta=function(t){return this.meta["string"==typeof t?t:t.key]},e.isGeneric.get=function(){for(var t in this.meta)return!1;return!0},t.prototype.scrollIntoView=function(){return this.updated|=4,this},e.scrolledIntoView.get=function(){return 0<(4&this.updated)},Object.defineProperties(t.prototype,e),t}(mt);function ie(t,e){return e&&t?t.bind(e):t}function se(t,e,n){this.name=t,this.init=ie(e.init,n),this.apply=ie(e.apply,n)}function ae(t,e){var n=this;this.schema=t,this.fields=le.concat(),this.plugins=[],this.pluginsByKey=Object.create(null),e&&e.forEach(function(t){if(n.pluginsByKey[t.key])throw new RangeError("Adding different instances of a keyed plugin ("+t.key+")");n.plugins.push(t),(n.pluginsByKey[t.key]=t).spec.state&&n.fields.push(new se(t.key,t.spec.state,t))})}function ce(t){this.config=t}var le=[new se("doc",{init:function(t){return t.doc||t.schema.topNodeType.createAndFill()},apply:function(t){return t.doc}}),new se("selection",{init:function(t,e){return t.selection||Ht.atStart(e.doc)},apply:function(t){return t.selection}}),new se("storedMarks",{init:function(t){return t.storedMarks||null},apply:function(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new se("scrollToSelection",{init:function(){return 0},apply:function(t,e){return t.scrolledIntoView?e+1:e}})],pe={schema:{configurable:!0},plugins:{configurable:!0},tr:{configurable:!0}};pe.schema.get=function(){return this.config.schema},pe.plugins.get=function(){return this.config.plugins},ce.prototype.apply=function(t){return this.applyTransaction(t).state},ce.prototype.filterTransaction=function(t,e){void 0===e&&(e=-1);for(var n=0;n<this.config.plugins.length;n++)if(n!=e){var r=this.config.plugins[n];if(r.spec.filterTransaction&&!r.spec.filterTransaction.call(r,t,this))return!1}return!0},ce.prototype.applyTransaction=function(t){if(!this.filterTransaction(t))return{state:this,transactions:[]};for(var e=[t],n=this.applyInner(t),r=null;;){for(var o=!1,i=0;i<this.config.plugins.length;i++){var s=this.config.plugins[i];if(s.spec.appendTransaction){var a=r?r[i].n:0,c=r?r[i].state:this,l=a<e.length&&s.spec.appendTransaction.call(s,a?e.slice(a):e,c,n);if(l&&n.filterTransaction(l,i)){if(l.setMeta("appendedTransaction",t),!r){r=[];for(var p=0;p<this.config.plugins.length;p++)r.push(p<i?{state:n,n:e.length}:{state:this,n:0})}e.push(l),n=n.applyInner(l),o=!0}r&&(r[i]={state:n,n:e.length})}}if(!o)return{state:n,transactions:e}}},ce.prototype.applyInner=function(t){if(!t.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");for(var e=new ce(this.config),n=this.config.fields,r=0;r<n.length;r++){var o=n[r];e[o.name]=o.apply(t,this[o.name],this,e)}for(var i=0;i<he.length;i++)he[i](this,t,e);return e},pe.tr.get=function(){return new oe(this)},ce.create=function(t){for(var e=new ae(t.schema||t.doc.type.schema,t.plugins),n=new ce(e),r=0;r<e.fields.length;r++)n[e.fields[r].name]=e.fields[r].init(t,n);return n},ce.prototype.reconfigure=function(t){for(var e=new ae(t.schema||this.schema,t.plugins),n=e.fields,r=new ce(e),o=0;o<n.length;o++){var i=n[o].name;r[i]=this.hasOwnProperty(i)?this[i]:n[o].init(t,r)}return r},ce.prototype.toJSON=function(t){var e={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(e.storedMarks=this.storedMarks.map(function(t){return t.toJSON()})),t&&"object"==typeof t)for(var n in t){if("doc"==n||"selection"==n)throw new RangeError("The JSON fields `doc` and `selection` are reserved");var r=t[n],o=r.spec.state;o&&o.toJSON&&(e[n]=o.toJSON.call(r,this[r.key]))}return e},ce.fromJSON=function(o,i,s){if(!i)throw new RangeError("Invalid input for EditorState.fromJSON");if(!o.schema)throw new RangeError("Required config field 'schema' missing");var t=new ae(o.schema,o.plugins),a=new ce(t);return t.fields.forEach(function(t){if("doc"==t.name)a.doc=C.fromJSON(o.schema,i.doc);else if("selection"==t.name)a.selection=Ht.fromJSON(a.doc,i.selection);else if("storedMarks"==t.name)i.storedMarks&&(a.storedMarks=i.storedMarks.map(o.schema.markFromJSON));else{if(s)for(var e in s){var n=s[e],r=n.spec.state;if(n.key==t.name&&r&&r.fromJSON&&Object.prototype.hasOwnProperty.call(i,e))return void(a[t.name]=r.fromJSON.call(n,o,i[e],a))}a[t.name]=t.init(o,a)}}),a},ce.addApplyListener=function(t){he.push(t)},ce.removeApplyListener=function(t){var e=he.indexOf(t);-1<e&&he.splice(e,1)},Object.defineProperties(ce.prototype,pe);var he=[];var ue=function(t){this.props={},t.props&&function t(e,n,r){for(var o in e){var i=e[o];i instanceof Function?i=i.bind(n):"handleDOMEvents"==o&&(i=t(i,n,{})),r[o]=i}return r}(t.props,this,this.props),this.spec=t,this.key=t.key?t.key.key:de("plugin")};ue.prototype.getState=function(t){return t[this.key]};var fe=Object.create(null);function de(t){return t in fe?t+"$"+ ++fe[t]:(fe[t]=0,t+"$")}function me(t){void 0===t&&(t="key"),this.key=de(t)}me.prototype.get=function(t){return t.config.pluginsByKey[this.key]},me.prototype.getState=function(t){return t[this.key]};var ve,ge,ye,we,be,ke=Object.freeze({__proto__:null,AllSelection:te,EditorState:ce,NodeSelection:Yt,Plugin:ue,PluginKey:me,Selection:Ht,SelectionRange:Gt,TextSelection:Qt,Transaction:oe}),xe={};"undefined"!=typeof navigator&&"undefined"!=typeof document&&(ve=/Edge\/(\d+)/.exec(navigator.userAgent),ge=/MSIE \d/.test(navigator.userAgent),ye=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),xe.mac=/Mac/.test(navigator.platform),we=xe.ie=!!(ge||ye||ve),xe.ie_version=ge?document.documentMode||6:ye?+ye[1]:ve?+ve[1]:null,xe.gecko=!we&&/gecko\/(\d+)/i.test(navigator.userAgent),xe.gecko_version=xe.gecko&&+(/Firefox\/(\d+)/.exec(navigator.userAgent)||[0,0])[1],be=!we&&/Chrome\/(\d+)/.exec(navigator.userAgent),xe.chrome=!!be,xe.chrome_version=be&&+be[1],xe.safari=!we&&/Apple Computer/.test(navigator.vendor),xe.ios=xe.safari&&(/Mobile\/\w+/.test(navigator.userAgent)||2<navigator.maxTouchPoints),xe.android=/Android \d/.test(navigator.userAgent),xe.webkit="webkitFontSmoothing"in document.documentElement.style,xe.webkit_version=xe.webkit&&+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]);function Se(t,e,n,r){return n&&(De(t,e,n,r,-1)||De(t,e,n,r,1))}var Me=function(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e},Ce=function(t){var e=t.parentNode;return e&&11==e.nodeType?e.host:e},Oe=null,Ne=function(t,e,n){var r=Oe=Oe||document.createRange();return r.setEnd(t,null==n?t.nodeValue.length:n),r.setStart(t,e||0),r},Te=/^(img|br|input|textarea|hr)$/i;function De(t,e,n,r,o){for(;;){if(t==n&&e==r)return!0;if(e==(o<0?0:Ee(t))){var i=t.parentNode;if(1!=i.nodeType||function(t){for(var e,n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}(t)||Te.test(t.nodeName)||"false"==t.contentEditable)return!1;e=Me(t)+(o<0?0:1),t=i}else{if(1!=t.nodeType)return!1;if("false"==(t=t.childNodes[e+(o<0?-1:0)]).contentEditable)return!1;e=o<0?Ee(t):0}}}function Ee(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}var Ae=function(t){var e=t.isCollapsed;return e&&xe.chrome&&t.rangeCount&&!t.getRangeAt(0).collapsed&&(e=!1),e};function Ie(t,e){var n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function Re(t,e){return"number"==typeof t?t:t[e]}function ze(t,e,n){for(var r,o,i,s=t.someProp("scrollThreshold")||0,a=t.someProp("scrollMargin")||5,c=t.dom.ownerDocument,l=n||t.dom;l;l=Ce(l))if(1==l.nodeType){var p,h,u,f,d=l==c.body||1!=l.nodeType,m=d?{left:0,right:(i=c).documentElement.clientWidth,top:0,bottom:i.documentElement.clientHeight}:(o=void 0,{left:(o=(r=l).getBoundingClientRect()).left,right:o.left+r.clientWidth,top:o.top,bottom:o.top+r.clientHeight}),v=0,g=0;if(e.top<m.top+Re(s,"top")?g=-(m.top-e.top+Re(a,"top")):e.bottom>m.bottom-Re(s,"bottom")&&(g=e.bottom-m.bottom+Re(a,"bottom")),e.left<m.left+Re(s,"left")?v=-(m.left-e.left+Re(a,"left")):e.right>m.right-Re(s,"right")&&(v=e.right-m.right+Re(a,"right")),(v||g)&&(d?c.defaultView.scrollBy(v,g):(p=l.scrollLeft,h=l.scrollTop,g&&(l.scrollTop+=g),v&&(l.scrollLeft+=v),u=l.scrollLeft-p,f=l.scrollTop-h,e={left:e.left-u,top:e.top-f,right:e.right-u,bottom:e.bottom-f})),d)break}}function Pe(t){for(var e=[],n=t.ownerDocument;t&&(e.push({dom:t,top:t.scrollTop,left:t.scrollLeft}),t!=n);t=Ce(t));return e}function _e(t,e){for(var n=0;n<t.length;n++){var r=t[n],o=r.dom,i=r.top,s=r.left;o.scrollTop!=i+e&&(o.scrollTop=i+e),o.scrollLeft!=s&&(o.scrollLeft=s)}}var Be=null;function Ve(t,e){for(var n,r,o=2e8,i=0,s=e.top,a=e.top,c=t.firstChild,l=0;c;c=c.nextSibling,l++){var p=void 0;if(1==c.nodeType)p=c.getClientRects();else{if(3!=c.nodeType)continue;p=Ne(c).getClientRects()}for(var h=0;h<p.length;h++){var u=p[h];if(u.top<=s&&u.bottom>=a){s=Math.max(u.bottom,s),a=Math.min(u.top,a);var f=u.left>e.left?u.left-e.left:u.right<e.left?e.left-u.right:0;if(f<o){n=c,r=(o=f)&&3==n.nodeType?{left:u.right<e.left?u.right:u.left,top:e.top}:e,1==c.nodeType&&f&&(i=l+(e.left>=(u.left+u.right)/2?1:0));continue}}!n&&(e.left>=u.right&&e.top>=u.top||e.left>=u.left&&e.top>=u.bottom)&&(i=l+1)}}return n&&3==n.nodeType?function(t,e){for(var n=t.nodeValue.length,r=document.createRange(),o=0;o<n;o++){r.setEnd(t,o+1),r.setStart(t,o);var i=qe(r,1);if(i.top!=i.bottom&&$e(e,i))return{node:t,offset:o+(e.left>=(i.left+i.right)/2?1:0)}}return{node:t,offset:0}}(n,r):!n||o&&1==n.nodeType?{node:t,offset:i}:Ve(n,r)}function $e(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function Fe(t,e){var n,r,o=t.root;if(o.caretPositionFromPoint)try{var i=o.caretPositionFromPoint(e.left,e.top);i&&(n=i.offsetNode,u=i.offset)}catch(t){}n||!o.caretRangeFromPoint||(r=o.caretRangeFromPoint(e.left,e.top))&&(n=r.startContainer,u=r.startOffset);var s,a,c,l,p,h,u,f,d,m,v,g,y,w,b=o.elementFromPoint(e.left,e.top+1);if(!b||!t.dom.contains(1!=b.nodeType?b.parentNode:b)){var k=t.dom.getBoundingClientRect();if(!$e(e,k))return null;if(!(b=function t(e,n,r){var o=e.childNodes.length;if(o&&r.top<r.bottom)for(var i=Math.max(0,Math.min(o-1,Math.floor(o*(n.top-r.top)/(r.bottom-r.top))-2)),s=i;;){var a=e.childNodes[s];if(1==a.nodeType)for(var c=a.getClientRects(),l=0;l<c.length;l++){var p=c[l];if($e(n,p))return t(a,n,p)}if((s=(s+1)%o)==i)break}return e}(t.dom,e,k)))return null}xe.safari&&b.draggable&&(n=u=null),c=e,b=(l=(a=b).parentNode)&&/^li$/i.test(l.nodeName)&&c.left<a.getBoundingClientRect().left?l:a,n&&(xe.gecko&&1==n.nodeType&&(u=Math.min(u,n.childNodes.length))<n.childNodes.length&&("IMG"==(p=n.childNodes[u]).nodeName&&(h=p.getBoundingClientRect()).right<=e.left&&h.bottom>e.top&&u++),n==t.dom&&u==n.childNodes.length-1&&1==n.lastChild.nodeType&&e.top>n.lastChild.getBoundingClientRect().bottom?s=t.state.doc.content.size:0!=u&&1==n.nodeType&&"BR"==n.childNodes[u-1].nodeName||(s=function(t,e,n,r){for(var o=-1,i=e;i!=t.dom;){var s=t.docView.nearestDesc(i,!0);if(!s)return null;if(s.node.isBlock&&s.parent){var a=s.dom.getBoundingClientRect();if(a.left>r.left||a.top>r.top)o=s.posBefore;else{if(!(a.right<r.left||a.bottom<r.top))break;o=s.posAfter}}i=s.dom.parentNode}return-1<o?o:t.docView.posFromDOM(e,n)}(t,n,u,e))),null==s&&(f=t,v=Ve(b,d=e),g=v.node,y=v.offset,w=-1,1!=g.nodeType||g.firstChild||(w=(m=g.getBoundingClientRect()).left!=m.right&&d.left>(m.left+m.right)/2?1:-1),s=f.docView.posFromDOM(g,y,w));var x=t.docView.nearestDesc(b,!0);return{pos:s,inside:x?x.posAtStart-x.border:-1}}function qe(t,e){var n=t.getClientRects();return n.length?n[e<0?0:n.length-1]:t.getBoundingClientRect()}var Le=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function je(t,e,n){var r=t.docView.domFromPos(e,n<0?-1:1),o=r.node,i=r.offset,s=xe.webkit||xe.gecko;if(3==o.nodeType){if(!s||!Le.test(o.nodeValue)&&(n<0?i:i!=o.nodeValue.length)){var a=i,c=i,l=n<0?1:-1;return n<0&&!i?(c++,l=-1):0<=n&&i==o.nodeValue.length?(a--,l=1):n<0?a--:c++,Je(qe(Ne(o,a,c),l),l<0)}var p=qe(Ne(o,i,i),n);if(xe.gecko&&i&&/\s/.test(o.nodeValue[i-1])&&i<o.nodeValue.length){var h=qe(Ne(o,i-1,i-1),-1);if(h.top==p.top){var u=qe(Ne(o,i,i+1),-1);if(u.top!=p.top)return Je(u,u.left<h.left)}}return p}if(!t.state.doc.resolve(e).parent.inlineContent){if(i&&(n<0||i==Ee(o))){var f=o.childNodes[i-1];if(1==f.nodeType)return We(f.getBoundingClientRect(),!1)}if(i<Ee(o)){var d=o.childNodes[i];if(1==d.nodeType)return We(d.getBoundingClientRect(),!0)}return We(o.getBoundingClientRect(),0<=n)}if(i&&(n<0||i==Ee(o))){var m=o.childNodes[i-1],v=3==m.nodeType?Ne(m,Ee(m)-(s?0:1)):1!=m.nodeType||"BR"==m.nodeName&&m.nextSibling?null:m;if(v)return Je(qe(v,1),!1)}if(i<Ee(o)){var g=o.childNodes[i],y=3==g.nodeType?Ne(g,0,s?0:1):1==g.nodeType?g:null;if(y)return Je(qe(y,-1),!0)}return Je(qe(3==o.nodeType?Ne(o):o,-n),0<=n)}function Je(t,e){if(0==t.width)return t;var n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function We(t,e){if(0==t.height)return t;var n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function Ke(t,e,n){var r=t.state,o=t.root.activeElement;r!=e&&t.updateState(e),o!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),o!=t.dom&&o&&o.focus()}}var He=/[\u0590-\u08ac]/;var Ue=null,Ge=null,Qe=!1;function Xe(t,e,n){return Ue==e&&Ge==n?Qe:(Ue=e,Qe="up"==(Ge=n)||"down"==n?(a=t,c=n,o=(r=e).selection,l="up"==c?o.$from:o.$to,Ke(a,r,function(){for(var t=a.docView.domFromPos(l.pos,"up"==c?-1:1).node;;){var e=a.docView.nearestDesc(t,!0);if(!e)break;if(e.node.isBlock){t=e.dom;break}t=e.dom.parentNode}for(var n=je(a,l.pos,1),r=t.firstChild;r;r=r.nextSibling){var o=void 0;if(1==r.nodeType)o=r.getClientRects();else{if(3!=r.nodeType)continue;o=Ne(r,0,r.nodeValue.length).getClientRects()}for(var i=0;i<o.length;i++){var s=o[i];if(s.bottom>s.top&&("up"==c?s.bottom<n.top+1:s.top>n.bottom-1))return!1}}return!0})):function(i,t,s){var a=t.selection.$head;if(!a.parent.isTextblock)return!1;var e=a.parentOffset,n=!e,r=e==a.parent.content.size,c=getSelection();return He.test(a.parent.textContent)&&c.modify?Ke(i,t,function(){var t=c.getRangeAt(0),e=c.focusNode,n=c.focusOffset,r=c.caretBidiLevel;c.modify("move",s,"character");var o=!(a.depth?i.docView.domAfterPos(a.before()):i.dom).contains(1==c.focusNode.nodeType?c.focusNode:c.focusNode.parentNode)||e==c.focusNode&&n==c.focusOffset;return c.removeAllRanges(),c.addRange(t),null!=r&&(c.caretBidiLevel=r),o}):"left"==s||"backward"==s?n:r}(t,e,n));var a,r,c,o,l}function Ye(t,e,n,r){this.parent=t,this.children=e,((this.dom=n).pmViewDesc=this).contentDOM=r,this.dirty=0}var Ze={beforePosition:{configurable:!0},size:{configurable:!0},border:{configurable:!0},posBefore:{configurable:!0},posAtStart:{configurable:!0},posAfter:{configurable:!0},posAtEnd:{configurable:!0},contentLost:{configurable:!0},domAtom:{configurable:!0}};Ye.prototype.matchesWidget=function(){return!1},Ye.prototype.matchesMark=function(){return!1},Ye.prototype.matchesNode=function(){return!1},Ye.prototype.matchesHack=function(){return!1},Ze.beforePosition.get=function(){return!1},Ye.prototype.parseRule=function(){return null},Ye.prototype.stopEvent=function(){return!1},Ze.size.get=function(){for(var t=0,e=0;e<this.children.length;e++)t+=this.children[e].size;return t},Ze.border.get=function(){return 0},Ye.prototype.destroy=function(){this.parent=null,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=null);for(var t=0;t<this.children.length;t++)this.children[t].destroy()},Ye.prototype.posBeforeChild=function(t){for(var e=0,n=this.posAtStart;e<this.children.length;e++){var r=this.children[e];if(r==t)return n;n+=r.size}},Ze.posBefore.get=function(){return this.parent.posBeforeChild(this)},Ze.posAtStart.get=function(){return this.parent?this.parent.posBeforeChild(this)+this.border:0},Ze.posAfter.get=function(){return this.posBefore+this.size},Ze.posAtEnd.get=function(){return this.posAtStart+this.size-2*this.border},Ye.prototype.localPosFromDOM=function(t,e,n){if(this.contentDOM&&this.contentDOM.contains(1==t.nodeType?t:t.parentNode)){if(n<0){var r,o;if(t==this.contentDOM)r=t.childNodes[e-1];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;r=t.previousSibling}for(;r&&(!(o=r.pmViewDesc)||o.parent!=this);)r=r.previousSibling;return r?this.posBeforeChild(o)+o.size:this.posAtStart}var i,s;if(t==this.contentDOM)i=t.childNodes[e];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;i=t.nextSibling}for(;i&&(!(s=i.pmViewDesc)||s.parent!=this);)i=i.nextSibling;return i?this.posBeforeChild(s):this.posAtEnd}var a;if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))a=2&t.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==e)for(var c=t;;c=c.parentNode){if(c==this.dom){a=!1;break}if(c.parentNode.firstChild!=c)break}if(null==a&&e==t.childNodes.length)for(var l=t;;l=l.parentNode){if(l==this.dom){a=!0;break}if(l.parentNode.lastChild!=l)break}}return(null==a?0<n:a)?this.posAtEnd:this.posAtStart},Ye.prototype.nearestDesc=function(t,e){for(var n=!0,r=t;r;r=r.parentNode){var o=this.getDesc(r);if(o&&(!e||o.node)){if(!n||!o.nodeDOM||(1==o.nodeDOM.nodeType?o.nodeDOM.contains(1==t.nodeType?t:t.parentNode):o.nodeDOM==t))return o;n=!1}}},Ye.prototype.getDesc=function(t){for(var e=t.pmViewDesc,n=e;n;n=n.parent)if(n==this)return e},Ye.prototype.posFromDOM=function(t,e,n){for(var r=t;r;r=r.parentNode){var o=this.getDesc(r);if(o)return o.localPosFromDOM(t,e,n)}return-1},Ye.prototype.descAt=function(t){for(var e=0,n=0;e<this.children.length;e++){var r=this.children[e],o=n+r.size;if(n==t&&o!=n){for(;!r.border&&r.children.length;)r=r.children[0];return r}if(t<o)return r.descAt(t-n-r.border);n=o}},Ye.prototype.domFromPos=function(t,e){if(!this.contentDOM)return{node:this.dom,offset:0};for(var n=0,r=0,o=!0;;r++,o=!1){for(;r<this.children.length&&(this.children[r].beforePosition||this.children[r].dom.parentNode!=this.contentDOM);)n+=this.children[r++].size;var i=r==this.children.length?null:this.children[r];if(n==t&&(0==e||!i||i.border||e<0&&o)||i&&i.domAtom&&t<n+i.size)return{node:this.contentDOM,offset:i?Me(i.dom):this.contentDOM.childNodes.length};if(!i)throw new Error("Invalid position "+t);var s=n+i.size;if(!i.domAtom&&(e<0&&!i.border?t<=s:t<s))return i.domFromPos(t-n-i.border,e);n=s}},Ye.prototype.parseRange=function(t,e,n){if(void 0===n&&(n=0),0==this.children.length)return{node:this.contentDOM,from:t,to:e,fromOffset:0,toOffset:this.contentDOM.childNodes.length};for(var r=-1,o=-1,i=n,s=0;;s++){var a=this.children[s],c=i+a.size;if(-1==r&&t<=c){var l=i+a.border;if(l<=t&&e<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(t,e,l);t=i;for(var p=s;0<p;p--){var h=this.children[p-1];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(1)){r=Me(h.dom)+1;break}t-=h.size}-1==r&&(r=0)}if(-1<r&&(e<c||s==this.children.length-1)){e=c;for(var u=s+1;u<this.children.length;u++){var f=this.children[u];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){o=Me(f.dom);break}e+=f.size}-1==o&&(o=this.contentDOM.childNodes.length);break}i=c}return{node:this.contentDOM,from:t,to:e,fromOffset:r,toOffset:o}},Ye.prototype.emptyChildAt=function(t){if(this.border||!this.contentDOM||!this.children.length)return!1;var e=this.children[t<0?0:this.children.length-1];return 0==e.size||e.emptyChildAt(t)},Ye.prototype.domAfterPos=function(t){var e=this.domFromPos(t,0),n=e.node,r=e.offset;if(1!=n.nodeType||r==n.childNodes.length)throw new RangeError("No node after pos "+t);return n.childNodes[r]},Ye.prototype.setSelection=function(t,e,n,r){for(var o=Math.min(t,e),i=Math.max(t,e),s=0,a=0;s<this.children.length;s++){var c=this.children[s],l=a+c.size;if(a<o&&i<l)return c.setSelection(t-a-c.border,e-a-c.border,n,r);a=l}var p,h=this.domFromPos(t,t?-1:1),u=e==t?h:this.domFromPos(e,e?-1:1),f=n.getSelection(),d=!1;if((xe.gecko||xe.safari)&&t==e&&(d=3==h.node.nodeType?h.offset&&"\n"==h.node.nodeValue[h.offset-1]:(p=h.node.childNodes[h.offset-1])&&("BR"==p.nodeName||"false"==p.contentEditable)),r||d&&xe.safari||!Se(h.node,h.offset,f.anchorNode,f.anchorOffset)||!Se(u.node,u.offset,f.focusNode,f.focusOffset)){var m,v,g=!1;if((f.extend||t==e)&&!d){f.collapse(h.node,h.offset);try{t!=e&&f.extend(u.node,u.offset),g=!0}catch(t){if(!(t instanceof DOMException))throw t}}g||(e<t&&(m=h,h=u,u=m),(v=document.createRange()).setEnd(u.node,u.offset),v.setStart(h.node,h.offset),f.removeAllRanges(),f.addRange(v))}},Ye.prototype.ignoreMutation=function(t){return!this.contentDOM&&"selection"!=t.type},Ze.contentLost.get=function(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)},Ye.prototype.markDirty=function(t,e){for(var n=0,r=0;r<this.children.length;r++){var o=this.children[r],i=n+o.size;if(n==i?t<=i&&n<=e:t<i&&n<e){var s=n+o.border,a=i-o.border;if(s<=t&&e<=a)return this.dirty=t==n||e==i?2:1,void(t!=s||e!=a||!o.contentLost&&o.dom.parentNode==this.contentDOM?o.markDirty(t-s,e-s):o.dirty=3);o.dirty=3}n=i}this.dirty=2},Ye.prototype.markParentsDirty=function(){for(var t=1,e=this.parent;e;e=e.parent,t++){var n=1==t?2:1;e.dirty<n&&(e.dirty=n)}},Ze.domAtom.get=function(){return!1},Object.defineProperties(Ye.prototype,Ze);var tn=[],en=function(a){function t(t,e,n,r){var o,i,s=e.type.toDOM;"function"==typeof s&&(s=s(n,function(){return o?o.parent?o.parent.posBeforeChild(o):void 0:r})),e.type.spec.raw||(1!=s.nodeType&&((i=document.createElement("span")).appendChild(s),s=i),s.contentEditable=!1,s.classList.add("ProseMirror-widget")),a.call(this,t,tn,s,null),this.widget=e,o=this}a&&(t.__proto__=a),(t.prototype=Object.create(a&&a.prototype)).constructor=t;var e={beforePosition:{configurable:!0},domAtom:{configurable:!0}};return e.beforePosition.get=function(){return this.widget.type.side<0},t.prototype.matchesWidget=function(t){return 0==this.dirty&&t.type.eq(this.widget.type)},t.prototype.parseRule=function(){return{ignore:!0}},t.prototype.stopEvent=function(t){var e=this.widget.spec.stopEvent;return!!e&&e(t)},t.prototype.ignoreMutation=function(t){return"selection"!=t.type||this.widget.spec.ignoreSelection},e.domAtom.get=function(){return!0},Object.defineProperties(t.prototype,e),t}(Ye),nn=function(o){function t(t,e,n,r){o.call(this,t,tn,e,null),this.textDOM=n,this.text=r}o&&(t.__proto__=o),(t.prototype=Object.create(o&&o.prototype)).constructor=t;var e={size:{configurable:!0}};return e.size.get=function(){return this.text.length},t.prototype.localPosFromDOM=function(t,e){return t!=this.textDOM?this.posAtStart+(e?this.size:0):this.posAtStart+e},t.prototype.domFromPos=function(t){return{node:this.textDOM,offset:t}},t.prototype.ignoreMutation=function(t){return"characterData"===t.type&&t.target.nodeValue==t.oldValue},Object.defineProperties(t.prototype,e),t}(Ye),rn=function(o){function a(t,e,n,r){o.call(this,t,[],n,r),this.mark=e}return o&&(a.__proto__=o),((a.prototype=Object.create(o&&o.prototype)).constructor=a).create=function(t,e,n,r){var o=r.nodeViews[e.type.name],i=o&&o(e,r,n);return i&&i.dom||(i=it.renderSpec(document,e.type.spec.toDOM(e,n))),new a(t,e,i.dom,i.contentDOM||i.dom)},a.prototype.parseRule=function(){return{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}},a.prototype.matchesMark=function(t){return 3!=this.dirty&&this.mark.eq(t)},a.prototype.markDirty=function(t,e){if(o.prototype.markDirty.call(this,t,e),0!=this.dirty){for(var n=this.parent;!n.node;)n=n.parent;n.dirty<this.dirty&&(n.dirty=this.dirty),this.dirty=0}},a.prototype.slice=function(t,e,n){var r=a.create(this.parent,this.mark,!0,n),o=this.children,i=this.size;e<i&&(o=wn(o,e,i,n)),0<t&&(o=wn(o,0,t,n));for(var s=0;s<o.length;s++)o[s].parent=r;return r.children=o,r},a}(Ye),on=function(l){function f(t,e,n,r,o,i,s,a,c){l.call(this,t,e.isLeaf?tn:[],o,i),this.nodeDOM=s,this.node=e,this.outerDeco=n,this.innerDeco=r,i&&this.updateChildren(a,c)}l&&(f.__proto__=l);var t={size:{configurable:!0},border:{configurable:!0},domAtom:{configurable:!0}};return((f.prototype=Object.create(l&&l.prototype)).constructor=f).create=function(t,e,n,r,o,i){var s,a,c=o.nodeViews[e.type.name],l=c&&c(e,o,function(){return a?a.parent?a.parent.posBeforeChild(a):void 0:i},n),p=l&&l.dom,h=l&&l.contentDOM;if(e.isText)if(p){if(3!=p.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else p=document.createTextNode(e.text);else p||(p=(s=it.renderSpec(document,e.type.spec.toDOM(e))).dom,h=s.contentDOM);h||e.isText||"BR"==p.nodeName||(p.hasAttribute("contenteditable")||(p.contentEditable=!1),e.type.spec.draggable&&(p.draggable=!0));var u=p,p=dn(p,n,e);return l?a=new ln(t,e,n,r,p,h,u,l,o,i+1):e.isText?new an(t,e,n,r,p,u,o):new f(t,e,n,r,p,h,u,o,i+1)},f.prototype.parseRule=function(){var t=this;if(this.node.type.spec.reparseInView)return null;var e={node:this.node.type.name,attrs:this.node.attrs};return this.node.type.spec.code&&(e.preserveWhitespace="full"),this.contentDOM&&!this.contentLost?e.contentElement=this.contentDOM:e.getContent=function(){return t.contentDOM?I.empty:t.node.content},e},f.prototype.matchesNode=function(t,e,n){return 0==this.dirty&&t.eq(this.node)&&mn(e,this.outerDeco)&&n.eq(this.innerDeco)},t.size.get=function(){return this.node.nodeSize},t.border.get=function(){return this.node.isLeaf?0:1},f.prototype.updateChildren=function(o,t){var r=this,i=this.node.inlineContent,s=t,e=i&&o.composing&&this.localCompositionNode(o,t),a=new gn(this,e&&e.node);!function(t,e,n,r){var o=e.locals(t),i=0;if(0==o.length){for(var s=0;s<t.childCount;s++){var a=t.child(s);r(a,o,e.forChild(i,a),s),i+=a.nodeSize}return}for(var c=0,l=[],p=null,h=0;;){if(c<o.length&&o[c].to==i){for(var u=o[c++],f=void 0;c<o.length&&o[c].to==i;)(f=f||[u]).push(o[c++]);if(f){f.sort(yn);for(var d=0;d<f.length;d++)n(f[d],h,!!p)}else n(u,h,!!p)}var m=void 0,v=void 0;if(p)v=-1,m=p,p=null;else{if(!(h<t.childCount))break;v=h,m=t.child(h++)}for(var g=0;g<l.length;g++)l[g].to<=i&&l.splice(g--,1);for(;c<o.length&&o[c].from<=i&&o[c].to>i;)l.push(o[c++]);var y=i+m.nodeSize;if(m.isText){var w=y;c<o.length&&o[c].from<w&&(w=o[c].from);for(var b=0;b<l.length;b++)l[b].to<w&&(w=l[b].to);w<y&&(p=m.cut(w-i),m=m.cut(0,w-i),y=w,v=-1)}var k=l.length?m.isInline&&!m.isLeaf?l.filter(function(t){return!t.inline}):l.slice():tn;r(m,k,e.forChild(i,m),v),i=y}}(this.node,this.innerDeco,function(t,e,n){t.spec.marks?a.syncToMarks(t.spec.marks,i,o):0<=t.type.side&&!n&&a.syncToMarks(e==r.node.childCount?c.none:r.node.child(e).marks,i,o),a.placeWidget(t,o,s)},function(t,e,n,r){a.syncToMarks(t.marks,i,o),a.findNodeMatch(t,e,n,r)||a.updateNextNode(t,e,n,o,r)||a.addNode(t,e,n,o,s),s+=t.nodeSize}),a.syncToMarks(tn,i,o),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),!a.changed&&2!=this.dirty||(e&&this.protectLocalComposition(o,e),function t(e,n,r){var o=e.firstChild,i=!1;for(var s=0;s<n.length;s++){var a,c=n[s],l=c.dom;if(l.parentNode==e){for(;l!=o;)o=vn(o),i=!0;o=o.nextSibling}else i=!0,e.insertBefore(l,o);c instanceof rn&&(a=o?o.previousSibling:e.lastChild,t(c.contentDOM,c.children,r),o=a?a.nextSibling:e.firstChild)}for(;o;)o=vn(o),i=!0;i&&r.trackWrites==e&&(r.trackWrites=null)}(this.contentDOM,this.children,o),xe.ios&&function(t){{var e;"UL"!=t.nodeName&&"OL"!=t.nodeName||(e=t.style.cssText,t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e)}}(this.dom))},f.prototype.localCompositionNode=function(t,e){var n=t.state.selection,r=n.from,o=n.to;if(!(!(t.state.selection instanceof Qt)||r<e||o>e+this.node.content.size)){var i=t.root.getSelection(),s=function(t,e){for(;;){if(3==t.nodeType)return t;if(1==t.nodeType&&0<e){if(t.childNodes.length>e&&3==t.childNodes[e].nodeType)return t.childNodes[e];t=t.childNodes[e-1],e=Ee(t)}else{if(!(1==t.nodeType&&e<t.childNodes.length))return null;t=t.childNodes[e],e=0}}}(i.focusNode,i.focusOffset);if(s&&this.dom.contains(s.parentNode)){var a=s.nodeValue,c=function(t,e,n,r){for(var o=0,i=0;o<t.childCount&&i<=r;){var s=t.child(o++),a=i;if(i+=s.nodeSize,s.isText){for(var c=s.text;o<t.childCount;){var l=t.child(o++);if(i+=l.nodeSize,!l.isText)break;c+=l.text}if(n<=i){var p=c.lastIndexOf(e,r-a);if(0<=p&&p+e.length+a>=n)return a+p}}}return-1}(this.node.content,a,r-e,o-e);return c<0?null:{node:s,pos:c,text:a}}}},f.prototype.protectLocalComposition=function(t,e){var n=e.node,r=e.pos,o=e.text;if(!this.getDesc(n)){for(var i=n;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=null)}var s=new nn(this,i,n,o);t.compositionNodes.push(s),this.children=wn(this.children,r,r+o.length,t,s)}},f.prototype.update=function(t,e,n,r){return!(3==this.dirty||!t.sameMarkup(this.node))&&(this.updateInner(t,e,n,r),!0)},f.prototype.updateInner=function(t,e,n,r){this.updateOuterDeco(e),this.node=t,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=0},f.prototype.updateOuterDeco=function(t){var e,n;mn(t,this.outerDeco)||(e=1!=this.nodeDOM.nodeType,n=this.dom,this.dom=fn(this.dom,this.nodeDOM,un(this.outerDeco,this.node,e),un(t,this.node,e)),this.dom!=n&&(n.pmViewDesc=null,this.dom.pmViewDesc=this),this.outerDeco=t)},f.prototype.selectNode=function(){this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.dom.draggable=!0)},f.prototype.deselectNode=function(){this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||this.dom.removeAttribute("draggable")},t.domAtom.get=function(){return this.node.isAtom},Object.defineProperties(f.prototype,t),f}(Ye);function sn(t,e,n,r,o){return dn(r,e,t),new on(null,t,e,n,r,r,r,o,0)}var an=function(a){function i(t,e,n,r,o,i,s){a.call(this,t,e,n,r,o,null,i,s)}a&&(i.__proto__=a);var t={domAtom:{configurable:!0}};return((i.prototype=Object.create(a&&a.prototype)).constructor=i).prototype.parseRule=function(){for(var t=this.nodeDOM.parentNode;t&&t!=this.dom&&!t.pmIsDeco;)t=t.parentNode;return{skip:t||!0}},i.prototype.update=function(t,e,n,r){return!(3==this.dirty||0!=this.dirty&&!this.inParent()||!t.sameMarkup(this.node))&&(this.updateOuterDeco(e),0==this.dirty&&t.text==this.node.text||t.text==this.nodeDOM.nodeValue||(this.nodeDOM.nodeValue=t.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=t,!(this.dirty=0))},i.prototype.inParent=function(){for(var t=this.parent.contentDOM,e=this.nodeDOM;e;e=e.parentNode)if(e==t)return!0;return!1},i.prototype.domFromPos=function(t){return{node:this.nodeDOM,offset:t}},i.prototype.localPosFromDOM=function(t,e,n){return t==this.nodeDOM?this.posAtStart+Math.min(e,this.node.text.length):a.prototype.localPosFromDOM.call(this,t,e,n)},i.prototype.ignoreMutation=function(t){return"characterData"!=t.type&&"selection"!=t.type},i.prototype.slice=function(t,e,n){var r=this.node.cut(t,e),o=document.createTextNode(r.text);return new i(this.parent,r,this.outerDeco,this.innerDeco,o,o,n)},t.domAtom.get=function(){return!1},Object.defineProperties(i.prototype,t),i}(on),cn=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t);var n={domAtom:{configurable:!0}};return((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.parseRule=function(){return{ignore:!0}},e.prototype.matchesHack=function(){return 0==this.dirty},n.domAtom.get=function(){return!0},Object.defineProperties(e.prototype,n),e}(Ye),ln=function(p){function t(t,e,n,r,o,i,s,a,c,l){p.call(this,t,e,n,r,o,i,s,c,l),this.spec=a}return p&&(t.__proto__=p),((t.prototype=Object.create(p&&p.prototype)).constructor=t).prototype.update=function(t,e,n,r){if(3==this.dirty)return!1;if(this.spec.update){var o=this.spec.update(t,e);return o&&this.updateInner(t,e,n,r),o}return!(!this.contentDOM&&!t.isLeaf)&&p.prototype.update.call(this,t,e,n,r)},t.prototype.selectNode=function(){this.spec.selectNode?this.spec.selectNode():p.prototype.selectNode.call(this)},t.prototype.deselectNode=function(){this.spec.deselectNode?this.spec.deselectNode():p.prototype.deselectNode.call(this)},t.prototype.setSelection=function(t,e,n,r){this.spec.setSelection?this.spec.setSelection(t,e,n):p.prototype.setSelection.call(this,t,e,n,r)},t.prototype.destroy=function(){this.spec.destroy&&this.spec.destroy(),p.prototype.destroy.call(this)},t.prototype.stopEvent=function(t){return!!this.spec.stopEvent&&this.spec.stopEvent(t)},t.prototype.ignoreMutation=function(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):p.prototype.ignoreMutation.call(this,t)},t}(on);function pn(t){t&&(this.nodeName=t)}pn.prototype=Object.create(null);var hn=[new pn];function un(t,e,n){if(0==t.length)return hn;for(var r=n?hn[0]:new pn,o=[r],i=0;i<t.length;i++){var s=t[i].type.attrs;if(s)for(var a in s.nodeName&&o.push(r=new pn(s.nodeName)),s){var c=s[a];null!=c&&(n&&1==o.length&&o.push(r=new pn(e.isInline?"span":"div")),"class"==a?r.class=(r.class?r.class+" ":"")+c:"style"==a?r.style=(r.style?r.style+";":"")+c:"nodeName"!=a&&(r[a]=c))}}return o}function fn(t,e,n,r){if(n==hn&&r==hn)return e;for(var o=e,i=0;i<r.length;i++){var s,a=r[i],c=n[i];i&&(s=void 0,c&&c.nodeName==a.nodeName&&o!=t&&(s=o.parentNode)&&s.tagName.toLowerCase()==a.nodeName||((s=document.createElement(a.nodeName)).pmIsDeco=!0,s.appendChild(o),c=hn[0]),o=s),function(t,e,n){for(var r in e)"class"==r||"style"==r||"nodeName"==r||r in n||t.removeAttribute(r);for(var o in n)"class"!=o&&"style"!=o&&"nodeName"!=o&&n[o]!=e[o]&&t.setAttribute(o,n[o]);if(e.class!=n.class){for(var i=e.class?e.class.split(" "):tn,s=n.class?n.class.split(" "):tn,a=0;a<i.length;a++)-1==s.indexOf(i[a])&&t.classList.remove(i[a]);for(var c=0;c<s.length;c++)-1==i.indexOf(s[c])&&t.classList.add(s[c])}if(e.style!=n.style){if(e.style)for(var l,p=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;l=p.exec(e.style);)t.style.removeProperty(l[1]);n.style&&(t.style.cssText+=n.style)}}(o,c||hn[0],a)}return o}function dn(t,e,n){return fn(t,t,hn,un(e,n,1!=t.nodeType))}function mn(t,e){if(t.length!=e.length)return!1;for(var n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return!1;return!0}function vn(t){var e=t.nextSibling;return t.parentNode.removeChild(t),e}var gn=function(t,e){this.top=t,this.lock=e,this.index=0,this.stack=[],this.changed=!1;var n=function(t,e){for(var n=[],r=t.childCount,o=e.length-1;0<r&&0<=o;o--){var i=e[o],s=i.node;if(s){if(s!=t.child(r-1))break;n.push(i),--r}}return{nodes:n.reverse(),offset:r}}(t.node.content,t.children);this.preMatched=n.nodes,this.preMatchOffset=n.offset};function yn(t,e){return t.type.side-e.type.side}function wn(t,e,n,r,o){for(var i=[],s=0,a=0;s<t.length;s++){var c=t[s],l=a,p=a+=c.size;n<=l||p<=e?i.push(c):(l<e&&i.push(c.slice(0,e-l,r)),o&&(i.push(o),o=null),n<p&&i.push(c.slice(n-l,c.size,r)))}return i}function bn(t,e){var n=t.root.getSelection(),r=t.state.doc;if(!n.focusNode)return null;var o=t.docView.nearestDesc(n.focusNode),i=o&&0==o.size,s=t.docView.posFromDOM(n.focusNode,n.focusOffset);if(s<0)return null;var a,c,l,p=r.resolve(s);if(Ae(n)){for(a=p;o&&!o.node;)o=o.parent;!(o&&o.node.isAtom&&Yt.isSelectable(o.node)&&o.parent)||o.node.isInline&&function(t,e,n){for(var r=0==e,o=e==Ee(t);r||o;){if(t==n)return 1;var i=Me(t);if(!(t=t.parentNode))return;r=r&&0==i,o=o&&i==Ee(t)}}(n.focusNode,n.focusOffset,o.dom)||(c=o.posBefore,l=new Yt(s==c?p:r.resolve(c)))}else{var h=t.docView.posFromDOM(n.anchorNode,n.anchorOffset);if(h<0)return null;a=r.resolve(h)}return l=l||Tn(t,a,p,"pointer"==e||t.state.selection.head<p.pos&&!i?1:-1)}function kn(t,e){var n,r,o,i,s=t.state.selection;On(t,s),(t.editable?t.hasFocus():Dn(t)&&document.activeElement&&document.activeElement.contains(t.dom))&&(t.domObserver.disconnectSelection(),t.cursorWrapper?function(t){var e=t.root.getSelection(),n=document.createRange(),r=t.cursorWrapper.dom,o="IMG"==r.nodeName;o?n.setEnd(r.parentNode,Me(r)+1):n.setEnd(r,0);n.collapse(!1),e.removeAllRanges(),e.addRange(n),!o&&!t.state.selection.visible&&xe.ie&&xe.ie_version<=11&&(r.disabled=!0,r.disabled=!1)}(t):(n=s.anchor,r=s.head,!xn||s instanceof Qt||(s.$from.parent.inlineContent||(o=Sn(t,s.from)),s.empty||s.$from.parent.inlineContent||(i=Sn(t,s.to))),t.docView.setSelection(n,r,t.root,e),xn&&(o&&Cn(o),i&&Cn(i)),s.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(t){var e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.hideSelectionGuard);var n=t.root.getSelection(),r=n.anchorNode,o=n.anchorOffset;e.addEventListener("selectionchange",t.hideSelectionGuard=function(){n.anchorNode==r&&n.anchorOffset==o||(e.removeEventListener("selectionchange",t.hideSelectionGuard),t.dom.classList.remove("ProseMirror-hideselection"))})}(t))),t.domObserver.setCurSelection(),t.domObserver.connectSelection())}gn.prototype.getPreMatch=function(t){return t>=this.preMatchOffset?this.preMatched[t-this.preMatchOffset]:null},gn.prototype.destroyBetween=function(t,e){if(t!=e){for(var n=t;n<e;n++)this.top.children[n].destroy();this.top.children.splice(t,e-t),this.changed=!0}},gn.prototype.destroyRest=function(){this.destroyBetween(this.index,this.top.children.length)},gn.prototype.syncToMarks=function(t,e,n){for(var r=0,o=this.stack.length>>1,i=Math.min(o,t.length);r<i&&(r==o-1?this.top:this.stack[r+1<<1]).matchesMark(t[r])&&!1!==t[r].type.spec.spanning;)r++;for(;r<o;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<t.length;){this.stack.push(this.top,this.index+1);for(var s,a=-1,c=this.index;c<Math.min(this.index+3,this.top.children.length);c++)if(this.top.children[c].matchesMark(t[o])){a=c;break}-1<a?(a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index]):(s=rn.create(this.top,t[o],e,n),this.top.children.splice(this.index,0,s),this.top=s,this.changed=!0),this.index=0,o++}},gn.prototype.findNodeMatch=function(t,e,n,r){var o=-1,i=r<0?void 0:this.getPreMatch(r),s=this.top.children;if(i&&i.matchesNode(t,e,n))o=s.indexOf(i);else for(var a=this.index,c=Math.min(s.length,a+5);a<c;a++){var l=s[a];if(l.matchesNode(t,e,n)&&this.preMatched.indexOf(l)<0){o=a;break}}return!(o<0)&&(this.destroyBetween(this.index,o),this.index++,!0)},gn.prototype.updateNextNode=function(t,e,n,r,o){for(var i=this.index;i<this.top.children.length;i++){var s=this.top.children[i];if(s instanceof on){var a=this.preMatched.indexOf(s);if(-1<a&&a+this.preMatchOffset!=o)return!1;var c=s.dom;if(!(this.lock&&(c==this.lock||1==c.nodeType&&c.contains(this.lock.parentNode))&&!(t.isText&&s.node&&s.node.isText&&s.nodeDOM.nodeValue==t.text&&3!=s.dirty&&mn(e,s.outerDeco)))&&s.update(t,e,n,r))return this.destroyBetween(this.index,i),s.dom!=c&&(this.changed=!0),this.index++,!0;break}}return!1},gn.prototype.addNode=function(t,e,n,r,o){this.top.children.splice(this.index++,0,on.create(this.top,t,e,n,r,o)),this.changed=!0},gn.prototype.placeWidget=function(t,e,n){var r,o=this.index<this.top.children.length?this.top.children[this.index]:null;!o||!o.matchesWidget(t)||t!=o.widget&&o.widget.type.toDOM.parentNode?(r=new en(this.top,t,e,n),this.top.children.splice(this.index++,0,r),this.changed=!0):this.index++},gn.prototype.addTextblockHacks=function(){for(var t,e=this.top.children[this.index-1];e instanceof rn;)e=e.children[e.children.length-1];e&&e instanceof an&&!/\n$/.test(e.node.text)||(this.index<this.top.children.length&&this.top.children[this.index].matchesHack()?this.index++:(t=document.createElement("br"),this.top.children.splice(this.index++,0,new cn(this.top,tn,t,null)),this.changed=!0))};var xn=xe.safari||xe.chrome&&xe.chrome_version<63;function Sn(t,e){var n=t.docView.domFromPos(e,0),r=n.node,o=n.offset,i=o<r.childNodes.length?r.childNodes[o]:null,s=o?r.childNodes[o-1]:null;if(xe.safari&&i&&"false"==i.contentEditable)return Mn(i);if(!(i&&"false"!=i.contentEditable||s&&"false"!=s.contentEditable)){if(i)return Mn(i);if(s)return Mn(s)}}function Mn(t){return t.contentEditable="true",xe.safari&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function Cn(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function On(t,e){var n;e instanceof Yt?(n=t.docView.descAt(e.from))!=t.lastSelectedViewDesc&&(Nn(t),n&&n.selectNode(),t.lastSelectedViewDesc=n):Nn(t)}function Nn(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=null)}function Tn(e,n,r,t){return e.someProp("createSelectionBetween",function(t){return t(e,n,r)})||Qt.between(n,r,t)}function Dn(t){var e=t.root.getSelection();if(!e.anchorNode)return!1;try{return t.dom.contains(3==e.anchorNode.nodeType?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(3==e.focusNode.nodeType?e.focusNode.parentNode:e.focusNode))}catch(t){return!1}}function En(t,e){var n=t.selection,r=n.$anchor,o=n.$head,i=0<e?r.max(o):r.min(o),s=i.parent.inlineContent?i.depth?t.doc.resolve(0<e?i.after():i.before()):null:i;return s&&Ht.findFrom(s,e)}function An(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function In(t,e,n){var r=t.state.selection;if(!(r instanceof Qt)){if(r instanceof Yt&&r.node.isInline)return An(t,new Qt(0<e?r.$to:r.$from));var o=En(t.state,e);return!!o&&An(t,o)}if(!r.empty||-1<n.indexOf("s"))return!1;if(t.endOfTextblock(0<e?"right":"left")){var i=En(t.state,e);return i&&i instanceof Yt?An(t,i):!1}if(!(xe.mac&&-1<n.indexOf("m"))){var s,a=r.$head,c=a.textOffset?null:e<0?a.nodeBefore:a.nodeAfter;if(!c||c.isText)return!1;var l=e<0?a.pos-c.nodeSize:a.pos;return c.isAtom||(s=t.docView.descAt(l))&&!s.contentDOM?Yt.isSelectable(c)?An(t,new Yt(e<0?t.state.doc.resolve(a.pos-c.nodeSize):a)):!!xe.webkit&&An(t,new Qt(t.state.doc.resolve(e<0?l:l+c.nodeSize))):!1}}function Rn(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function zn(t){var e=t.pmViewDesc;return e&&0==e.size&&(t.nextSibling||"BR"!=t.nodeName)}function Pn(t){var e=t.root.getSelection(),n=e.focusNode,r=e.focusOffset;if(n){var o,i,s=!1;for(xe.gecko&&1==n.nodeType&&r<Rn(n)&&zn(n.childNodes[r])&&(s=!0);;)if(0<r){if(1!=n.nodeType)break;var a=n.childNodes[r-1];if(zn(a))o=n,i=--r;else{if(3!=a.nodeType)break;r=(n=a).nodeValue.length}}else{if(Bn(n))break;for(var c=n.previousSibling;c&&zn(c);)o=n.parentNode,i=Me(c),c=c.previousSibling;if(c)r=Rn(n=c);else{if((n=n.parentNode)==t.dom)break;r=0}}s?Vn(t,e,n,r):o&&Vn(t,e,o,i)}}function _n(t){var e=t.root.getSelection(),n=e.focusNode,r=e.focusOffset;if(n){for(var o,i,s=Rn(n);;)if(r<s){if(1!=n.nodeType)break;if(!zn(n.childNodes[r]))break;o=n,i=++r}else{if(Bn(n))break;for(var a=n.nextSibling;a&&zn(a);)o=a.parentNode,i=Me(a)+1,a=a.nextSibling;if(a)r=0,s=Rn(n=a);else{if((n=n.parentNode)==t.dom)break;r=s=0}}o&&Vn(t,e,o,i)}}function Bn(t){var e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function Vn(t,e,n,r){var o;Ae(e)?((o=document.createRange()).setEnd(n,r),o.setStart(n,r),e.removeAllRanges(),e.addRange(o)):e.extend&&e.extend(n,r),t.domObserver.setCurSelection();var i=t.state;setTimeout(function(){t.state==i&&kn(t)},50)}function $n(t,e,n){var r=t.state.selection;if(r instanceof Qt&&!r.empty||-1<n.indexOf("s"))return!1;if(xe.mac&&-1<n.indexOf("m"))return!1;var o=r.$from,i=r.$to;if(!o.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){var s=En(t.state,e);if(s&&s instanceof Yt)return An(t,s)}if(o.parent.inlineContent)return!1;var a=Ht.findFrom(e<0?o:i,e);return!a||An(t,a)}function Fn(t,e){if(!(t.state.selection instanceof Qt))return!0;var n=t.state.selection,r=n.$head,o=n.$anchor,i=n.empty;if(!r.sameParent(o))return!0;if(!i)return!1;if(t.endOfTextblock(0<e?"forward":"backward"))return!0;var s=!r.textOffset&&(e<0?r.nodeBefore:r.nodeAfter);if(!s||s.isText)return!1;var a=t.state.tr;return e<0?a.delete(r.pos-s.nodeSize,r.pos):a.delete(r.pos,r.pos+s.nodeSize),t.dispatch(a),!0}function qn(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function Ln(t,e){var n,r,o,i,s,a,c,l=e.keyCode,p=(r="",(n=e).ctrlKey&&(r+="c"),n.metaKey&&(r+="m"),n.altKey&&(r+="a"),n.shiftKey&&(r+="s"),r);return 8==l||xe.mac&&72==l&&"c"==p?Fn(t,-1)||Pn(t):46==l||xe.mac&&68==l&&"c"==p?Fn(t,1)||_n(t):13==l||27==l||(37==l?In(t,-1,p)||Pn(t):39==l?In(t,1,p)||_n(t):38==l?$n(t,-1,p)||Pn(t):40==l?(o=t,!xe.safari||0<o.state.selection.$head.parentOffset||(s=(i=o.root.getSelection()).focusNode,a=i.focusOffset,s&&1==s.nodeType&&0==a&&s.firstChild&&"false"==s.firstChild.contentEditable&&(c=s.firstChild,qn(o,c,!0),setTimeout(function(){return qn(o,c,!1)},20))),$n(t,1,p)||_n(t)):p==(xe.mac?"m":"c")&&(66==l||73==l||89==l||90==l))}function jn(t){var e=t.pmViewDesc;if(e)return e.parseRule();if("BR"==t.nodeName&&t.parentNode){if(xe.safari&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){var n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}if(t.parentNode.lastChild==t||xe.safari&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if("IMG"==t.nodeName&&t.getAttribute("mark-placeholder"))return{ignore:!0}}function Jn(e,t,n,r,o){if(t<0){var i,s=e.lastSelectionTime>Date.now()-50?e.lastSelectionOrigin:null,a=bn(e,s);a&&!e.state.selection.eq(a)&&(i=e.state.tr.setSelection(a),"pointer"==s?i.setMeta("pointer",!0):"key"==s&&i.scrollIntoView(),e.dispatch(i))}else{var c=e.state.doc.resolve(t),l=c.sharedDepth(n);t=c.before(l+1),n=e.state.doc.resolve(n).after(l+1);var p,h,u=e.state.selection,f=function(t,e,n){var r=t.docView.parseRange(e,n),o=r.node,i=r.fromOffset,s=r.toOffset,a=r.from,c=r.to,l=t.root.getSelection(),p=null,h=l.anchorNode;if(h&&t.dom.contains(1==h.nodeType?h:h.parentNode)&&(p=[{node:h,offset:l.anchorOffset}],Ae(l)||p.push({node:l.focusNode,offset:l.focusOffset})),xe.chrome&&8===t.lastKeyCode)for(var u=s;i<u;u--){var f=o.childNodes[u-1],d=f.pmViewDesc;if("BR"==f.nodeType&&!d){s=u;break}if(!d||d.size)break}var m,v,g=t.state.doc,y=t.someProp("domParser")||Q.fromSchema(t.state.schema),w=g.resolve(a),b=null,k=y.parse(o,{topNode:w.parent,topMatch:w.parent.contentMatchAt(w.index()),topOpen:!0,from:i,to:s,preserveWhitespace:!w.parent.type.spec.code||"full",editableContent:!0,findPositions:p,ruleFromNode:jn,context:w});return p&&null!=p[0].pos&&(m=p[0].pos,null==(v=p[1]&&p[1].pos)&&(v=m),b={anchor:m+a,head:v+a}),{doc:k,sel:b,from:a,to:c}}(e,t,n);xe.chrome&&e.cursorWrapper&&f.sel&&f.sel.anchor==e.cursorWrapper.deco.from&&(h=(p=e.cursorWrapper.deco.type.toDOM.nextSibling)&&p.nodeValue?p.nodeValue.length:1,f.sel={anchor:f.sel.anchor+h,head:f.sel.anchor+h});var d,m=e.state.doc,v=m.slice(f.from,f.to),g=8===e.lastKeyCode&&Date.now()-100<e.lastKeyCodeTime?(d=e.state.selection.to,"end"):(d=e.state.selection.from,"start");e.lastKeyCode=null;var y,w=function(t,e,n,r,o){var i=t.findDiffStart(e,n);if(null==i)return null;var s=t.findDiffEnd(e,n+t.size,n+e.size),a=s.a,c=s.b;{var l;"end"==o&&(l=Math.max(0,i-Math.min(a,c)),r-=a+l-i)}{a<i&&t.size<e.size?(c=(i-=r<=i&&a<=r?i-r:0)+(c-a),a=i):c<i&&(a=(i-=r<=i&&c<=r?i-r:0)+(a-c),c=i)}return{start:i,endA:a,endB:c}}(v.content,f.doc.content,f.from,d,g);if(!w)if(!(r&&u instanceof Qt&&!u.empty&&u.$head.sameParent(u.$anchor))||e.composing||f.sel&&f.sel.anchor!=f.sel.head)return xe.ios&&e.lastIOSEnter>Date.now()-225&&o.some(function(t){return"DIV"==t.nodeName||"P"==t.nodeName})&&e.someProp("handleKeyDown",function(t){return t(e,Ie(13,"Enter"))})?void(e.lastIOSEnter=0):void(!f.sel||(y=Wn(e,e.state.doc,f.sel))&&!y.eq(e.state.selection)&&e.dispatch(e.state.tr.setSelection(y)));else w={start:u.from,endA:u.to,endB:u.to};e.domChangeCount++,e.state.selection.from<e.state.selection.to&&w.start==w.endB&&e.state.selection instanceof Qt&&(w.start>e.state.selection.from&&w.start<=e.state.selection.from+2?w.start=e.state.selection.from:w.endA<e.state.selection.to&&w.endA>=e.state.selection.to-2&&(w.endB+=e.state.selection.to-w.endA,w.endA=e.state.selection.to)),xe.ie&&xe.ie_version<=11&&w.endB==w.start+1&&w.endA==w.start&&w.start>f.from&&"  "==f.doc.textBetween(w.start-f.from-1,w.start-f.from+1)&&(w.start--,w.endA--,w.endB--);var b,k=f.doc.resolveNoCache(w.start-f.from),x=f.doc.resolveNoCache(w.endB-f.from),S=k.sameParent(x)&&k.parent.inlineContent;if((xe.ios&&e.lastIOSEnter>Date.now()-225&&(!S||o.some(function(t){return"DIV"==t.nodeName||"P"==t.nodeName}))||!S&&k.pos<f.doc.content.size&&(b=Ht.findFrom(f.doc.resolve(k.pos+1),1,!0))&&b.head==x.pos)&&e.someProp("handleKeyDown",function(t){return t(e,Ie(13,"Enter"))}))e.lastIOSEnter=0;else if(e.state.selection.anchor>w.start&&function(t,e,n,r,o){if(!r.parent.isTextblock||n-e<=o.pos-r.pos||Kn(r,!0,!1)<o.pos)return!1;var i=t.resolve(e);if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;var s=t.resolve(Kn(i,!0,!0));if(!s.parent.isTextblock||s.pos>n||Kn(s,!0,!1)<n)return!1;return r.parent.content.cut(r.parentOffset).eq(s.parent.content)}(m,w.start,w.endA,k,x)&&e.someProp("handleKeyDown",function(t){return t(e,Ie(8,"Backspace"))}))xe.android&&xe.chrome&&e.domObserver.suppressSelectionUpdates();else{xe.android&&!S&&k.start()!=x.start()&&0==x.parentOffset&&k.depth==x.depth&&f.sel&&f.sel.anchor==f.sel.head&&f.sel.head==w.endA&&(w.endB-=2,x=f.doc.resolveNoCache(w.endB-f.from),setTimeout(function(){e.someProp("handleKeyDown",function(t){return t(e,Ie(13,"Enter"))})},20));var M,C,O,N,T,D=w.start,E=w.endA;if(S)if(k.pos==x.pos)xe.ie&&xe.ie_version<=11&&0==k.parentOffset&&(e.domObserver.suppressSelectionUpdates(),setTimeout(function(){return kn(e)},20)),M=e.state.tr.delete(D,E),C=m.resolve(w.start).marksAcross(m.resolve(w.endA));else if(w.endA==w.endB&&(N=m.resolve(w.start))&&(O=function(t,e){for(var n,r,o,i=t.firstChild.marks,s=e.firstChild.marks,a=i,c=s,l=0;l<s.length;l++)a=s[l].removeFromSet(a);for(var p=0;p<i.length;p++)c=i[p].removeFromSet(c);if(1==a.length&&0==c.length)r=a[0],n="add",o=function(t){return t.mark(r.addToSet(t.marks))};else{if(0!=a.length||1!=c.length)return null;r=c[0],n="remove",o=function(t){return t.mark(r.removeFromSet(t.marks))}}for(var h=[],u=0;u<e.childCount;u++)h.push(o(e.child(u)));if(I.from(h).eq(t))return{mark:r,type:n}}(k.parent.content.cut(k.parentOffset,x.parentOffset),N.parent.content.cut(N.parentOffset,w.endA-N.start()))))M=e.state.tr,"add"==O.type?M.addMark(D,E,O.mark):M.removeMark(D,E,O.mark);else if(k.parent.child(k.index()).isText&&k.index()==x.index()-(x.textOffset?0:1)){var A=k.parent.textBetween(k.parentOffset,x.parentOffset);if(e.someProp("handleTextInput",function(t){return t(e,D,E,A)}))return;M=e.state.tr.insertText(A,D,E)}M=M||e.state.tr.replace(D,E,f.doc.slice(w.start-f.from,w.endB-f.from)),!f.sel||(T=Wn(e,M.doc,f.sel))&&!(xe.chrome&&xe.android&&e.composing&&T.empty&&(T.head==D||T.head==M.mapping.map(E)-1)||xe.ie&&T.empty&&T.head==D)&&M.setSelection(T),C&&M.ensureMarks(C),e.dispatch(M.scrollIntoView())}}}function Wn(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:Tn(t,e.resolve(n.anchor),e.resolve(n.head))}function Kn(t,e,n){for(var r=t.depth,o=e?t.end():t.pos;0<r&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,o++,e=!1;if(n)for(var i=t.node(r).maybeChild(t.indexAfter(r));i&&!i.isLeaf;)i=i.firstChild,o++;return o}function Hn(t,e){for(var n=[],r=e.content,o=e.openStart,i=e.openEnd;1<o&&1<i&&1==r.childCount&&1==r.firstChild.childCount;){o--,i--;var s=r.firstChild;n.push(s.type.name,s.attrs!=s.type.defaultAttrs?s.attrs:null),r=s.content}var a=t.someProp("clipboardSerializer")||it.fromSchema(t.state.schema),c=Zn(),l=c.createElement("div");l.appendChild(a.serializeFragment(r,{document:c}));for(var p,h=l.firstChild;h&&1==h.nodeType&&(p=Xn[h.nodeName.toLowerCase()]);){for(var u=p.length-1;0<=u;u--){for(var f=c.createElement(p[u]);l.firstChild;)f.appendChild(l.firstChild);l.appendChild(f)}h=l.firstChild}return h&&1==h.nodeType&&h.setAttribute("data-pm-slice",o+" "+i+" "+JSON.stringify(n)),{dom:l,text:t.someProp("clipboardTextSerializer",function(t){return t(e)})||e.content.textBetween(0,e.content.size,"\n\n")}}function Un(t,e,n,r,o){var i,s=o.parent.type.spec.code;if(!n&&!e)return null;var a=e&&(r||s||!n);if(a){if(t.someProp("transformPastedText",function(t){e=t(e,s||r)}),s)return new N(I.from(t.state.schema.text(e)),0,0);var c=t.someProp("clipboardTextParser",function(t){return t(e,o,r)});c?l=c:(i=document.createElement("div"),e.trim().split(/(?:\r\n?|\n)+/).forEach(function(t){i.appendChild(document.createElement("p")).textContent=t}))}else t.someProp("transformPastedHTML",function(t){n=t(n)}),i=function(t){var e=/(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));var n,r=Zn().createElement("div"),o=/(?:<meta [^>]*>)*<([a-z][^>\s]+)/i.exec(t),i=0;(n=o&&Xn[o[1].toLowerCase()])&&(t=n.map(function(t){return"<"+t+">"}).join("")+t+n.map(function(t){return"</"+t+">"}).reverse().join(""),i=n.length);r.innerHTML=t;for(var s=0;s<i;s++)r=r.firstChild;return r}(n);var l,p=i&&i.querySelector("[data-pm-slice]"),h=p&&/^(\d+) (\d+) (.*)/.exec(p.getAttribute("data-pm-slice"));return l=l||(t.someProp("clipboardParser")||t.someProp("domParser")||Q.fromSchema(t.state.schema)).parseSlice(i,{preserveWhitespace:!(!a&&!h),context:o}),l=h?function(e,t){if(!e.size)return e;var n,r=e.content.firstChild.type.schema;try{n=JSON.parse(t)}catch(t){return e}for(var o=e.content,i=e.openStart,s=e.openEnd,a=n.length-2;0<=a;a-=2){var c=r.nodes[n[a]];if(!c||c.hasRequiredAttrs())break;o=I.from(c.create(n[a+1],o)),i++,s++}return new N(o,i,s)}(function(t,e,n){e<t.openStart&&(t=new N(Qn(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd));n<t.openEnd&&(t=new N(Qn(t.content,1,n,t.openEnd,0,0),t.openStart,n));return t}(l,+h[1],+h[2]),h[3]):N.maxOpen(function(e,n){if(e.childCount<2)return e;for(var t=function(t){var o=n.node(t).contentMatchAt(n.index(t)),i=void 0,s=[];if(e.forEach(function(t){if(s){var e,n,r=o.findWrapping(t.type);if(!r)return s=null;(e=s.length&&i.length&&function t(e,n,r,o,i){if(i<e.length&&i<n.length&&e[i]==n[i]){var s=t(e,n,r,o.lastChild,i+1);if(s)return o.copy(o.content.replaceChild(o.childCount-1,s));var a=o.contentMatchAt(o.childCount);if(a.matchType(i==e.length-1?r.type:e[i+1]))return o.copy(o.content.append(I.from(Gn(r,e,i+1))))}}(r,i,t,s[s.length-1],0))?s[s.length-1]=e:(s.length&&(s[s.length-1]=function t(e,n){if(0==n)return e;var r=e.content.replaceChild(e.childCount-1,t(e.lastChild,n-1));var o=e.contentMatchAt(e.childCount).fillBefore(I.empty,!0);return e.copy(r.append(o))}(s[s.length-1],i.length)),n=Gn(t,r),s.push(n),o=o.matchType(n.type,n.attrs),i=r)}}),s)return{v:I.from(s)}},r=n.depth;0<=r;r--){var o=t(r);if(o)return o.v}return e}(l.content,o),!1),t.someProp("transformPasted",function(t){l=t(l)}),l}function Gn(t,e,n){void 0===n&&(n=0);for(var r=e.length-1;n<=r;r--)t=e[r].create(null,I.from(t));return t}function Qn(t,e,n,r,o,i){var s=e<0?t.firstChild:t.lastChild,a=s.content;return o<r-1&&(a=Qn(a,e,n,r,o+1,i)),n<=o&&(a=e<0?s.contentMatchAt(0).fillBefore(a,1<t.childCount||i<=o).append(a):a.append(s.contentMatchAt(s.childCount).fillBefore(I.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,s.copy(a))}var Xn={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]},Yn=null;function Zn(){return Yn=Yn||document.implementation.createHTMLDocument("title")}function tr(){this.anchorNode=this.anchorOffset=this.focusNode=this.focusOffset=null}var er={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},nr=xe.ie&&xe.ie_version<=11;tr.prototype.set=function(t){this.anchorNode=t.anchorNode,this.anchorOffset=t.anchorOffset,this.focusNode=t.focusNode,this.focusOffset=t.focusOffset},tr.prototype.eq=function(t){return t.anchorNode==this.anchorNode&&t.anchorOffset==this.anchorOffset&&t.focusNode==this.focusNode&&t.focusOffset==this.focusOffset};function rr(t,e){var n=this;this.view=t,this.handleDOMChange=e,this.queue=[],this.flushingSoon=-1,this.observer=window.MutationObserver&&new window.MutationObserver(function(t){for(var e=0;e<t.length;e++)n.queue.push(t[e]);xe.ie&&xe.ie_version<=11&&t.some(function(t){return"childList"==t.type&&t.removedNodes.length||"characterData"==t.type&&t.oldValue.length>t.target.nodeValue.length})?n.flushSoon():n.flush()}),this.currentSelection=new tr,nr&&(this.onCharData=function(t){n.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),n.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.suppressingSelectionUpdates=!1}rr.prototype.flushSoon=function(){var t=this;this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(function(){t.flushingSoon=-1,t.flush()},20))},rr.prototype.forceFlush=function(){-1<this.flushingSoon&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())},rr.prototype.start=function(){this.observer&&this.observer.observe(this.view.dom,er),nr&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()},rr.prototype.stop=function(){var t=this;if(this.observer){var e=this.observer.takeRecords();if(e.length){for(var n=0;n<e.length;n++)this.queue.push(e[n]);window.setTimeout(function(){return t.flush()},20)}this.observer.disconnect()}nr&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()},rr.prototype.connectSelection=function(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)},rr.prototype.disconnectSelection=function(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)},rr.prototype.suppressSelectionUpdates=function(){var t=this;this.suppressingSelectionUpdates=!0,setTimeout(function(){return t.suppressingSelectionUpdates=!1},50)},rr.prototype.onSelectionChange=function(){if((!(t=this.view).editable||t.root.activeElement==t.dom)&&Dn(t)){var t;if(this.suppressingSelectionUpdates)return kn(this.view);if(xe.ie&&xe.ie_version<=11&&!this.view.state.selection.empty){var e=this.view.root.getSelection();if(e.focusNode&&Se(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}},rr.prototype.setCurSelection=function(){this.currentSelection.set(this.view.root.getSelection())},rr.prototype.ignoreSelectionChange=function(t){if(0==t.rangeCount)return!0;var e=t.getRangeAt(0).commonAncestorContainer,n=this.view.docView.nearestDesc(e);return n&&n.ignoreMutation({type:"selection",target:3==e.nodeType?e.parentNode:e})?(this.setCurSelection(),!0):void 0},rr.prototype.flush=function(){if(this.view.docView&&!(-1<this.flushingSoon)){var t=this.observer?this.observer.takeRecords():[];this.queue.length&&(t=this.queue.concat(t),this.queue.length=0);var e,n,r,o=this.view.root.getSelection(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(o)&&Dn(this.view)&&!this.ignoreSelectionChange(o),s=-1,a=-1,c=!1,l=[];if(this.view.editable)for(var p=0;p<t.length;p++){var h=this.registerMutation(t[p],l);h&&(s=s<0?h.from:Math.min(h.from,s),a=a<0?h.to:Math.max(h.to,a),h.typeOver&&(c=!0))}xe.gecko&&1<l.length&&(2==(e=l.filter(function(t){return"BR"==t.nodeName})).length&&(n=e[0],r=e[1],n.parentNode&&n.parentNode.parentNode==r.parentNode?r.remove():n.remove())),(-1<s||i)&&(-1<s&&(this.view.docView.markDirty(s,a),function(t){if(or)return;or=!0,"normal"==getComputedStyle(t.dom).whiteSpace&&console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package.")}(this.view)),this.handleDOMChange(s,a,c,l),this.view.docView.dirty?this.view.updateState(this.view.state):this.currentSelection.eq(o)||kn(this.view))}};var or=!(rr.prototype.registerMutation=function(t,e){if(-1<e.indexOf(t.target))return null;var n=this.view.docView.nearestDesc(t.target);if("attributes"==t.type&&(n==this.view.docView||"contenteditable"==t.attributeName||"style"==t.attributeName&&!t.oldValue&&!t.target.getAttribute("style")))return null;if(!n||n.ignoreMutation(t))return null;if("childList"!=t.type)return"attributes"==t.type?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:{from:n.posAtStart,to:n.posAtEnd,typeOver:t.target.nodeValue==t.oldValue};var r=t.previousSibling,o=t.nextSibling;if(xe.ie&&xe.ie_version<=11&&t.addedNodes.length)for(var i=0;i<t.addedNodes.length;i++){var s=t.addedNodes[i],a=s.previousSibling,c=s.nextSibling;(!a||Array.prototype.indexOf.call(t.addedNodes,a)<0)&&(r=a),(!c||Array.prototype.indexOf.call(t.addedNodes,c)<0)&&(o=c)}for(var l=r&&r.parentNode==t.target?Me(r)+1:0,p=n.localPosFromDOM(t.target,l,-1),h=o&&o.parentNode==t.target?Me(o):t.target.childNodes.length,u=0;u<t.addedNodes.length;u++)e.push(t.addedNodes[u]);return{from:p,to:n.localPosFromDOM(t.target,h,1)}});var ir={},sr={};function ar(o){o.shiftKey=!1,o.mouseDown=null,o.lastKeyCode=null,o.lastKeyCodeTime=0,o.lastClick={time:0,x:0,y:0,type:""},o.lastSelectionOrigin=null,o.lastSelectionTime=0,o.lastIOSEnter=0,o.lastIOSEnterFallbackTimeout=null,o.composing=!1,o.composingTimeout=null,o.compositionNodes=[],o.compositionEndedAt=-2e8,o.domObserver=new rr(o,function(t,e,n,r){return Jn(o,t,e,n,r)}),o.domObserver.start(),o.domChangeCount=0,o.eventHandlers=Object.create(null);for(var t in ir)!function(t){var e=ir[t];o.dom.addEventListener(t,o.eventHandlers[t]=function(t){!function(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(var n=e.target;n!=t.dom;n=n.parentNode)if(!n||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}(o,t)||pr(o,t)||!o.editable&&t.type in sr||e(o,t)})}(t);xe.safari&&o.dom.addEventListener("input",function(){return null}),lr(o)}function cr(t,e){t.lastSelectionOrigin=e,t.lastSelectionTime=Date.now()}function lr(n){n.someProp("handleDOMEvents",function(t){for(var e in t)n.eventHandlers[e]||n.dom.addEventListener(e,n.eventHandlers[e]=function(t){return pr(n,t)})})}function pr(n,r){return n.someProp("handleDOMEvents",function(t){var e=t[r.type];return!!e&&(e(n,r)||r.defaultPrevented)})}function hr(t){return{left:t.clientX,top:t.clientY}}function ur(n,t,r,e,o){if(-1==e)return!1;for(var i=n.state.doc.resolve(e),s=i.depth+1;0<s;s--){var a=function(e){if(n.someProp(t,function(t){return e>i.depth?t(n,r,i.nodeAfter,i.before(e),o,!0):t(n,r,i.node(e),i.before(e),o,!1)}))return{v:!0}}(s);if(a)return a.v}return!1}function fr(t,e,n){t.focused||t.focus();var r=t.state.tr.setSelection(e);"pointer"==n&&r.setMeta("pointer",!0),t.dispatch(r)}function dr(e,n,t,r,o){return ur(e,"handleClickOn",n,t,r)||e.someProp("handleClick",function(t){return t(e,n,r)})||(o?function(t,e){if(-1==e)return;var n,r,o=t.state.selection;o instanceof Yt&&(n=o.node);for(var i=t.state.doc.resolve(e),s=i.depth+1;0<s;s--){var a=s>i.depth?i.nodeAfter:i.node(s);if(Yt.isSelectable(a)){r=n&&0<o.$from.depth&&s>=o.$from.depth&&i.before(o.$from.depth+1)==o.$from.pos?i.before(o.$from.depth):i.before(s);break}}return null!=r&&(fr(t,Yt.create(t.state.doc,r),"pointer"),!0)}:function(t,e){if(-1==e)return;var n=t.state.doc.resolve(e),r=n.nodeAfter;return!!(r&&r.isAtom&&Yt.isSelectable(r))&&(fr(t,new Yt(n),"pointer"),!0)})(e,t)}function mr(e,n,t,r){return ur(e,"handleTripleClickOn",n,t,r)||e.someProp("handleTripleClick",function(t){return t(e,n,r)})||function(t,e){var n=t.state.doc;if(-1==e)return!!n.inlineContent&&(fr(t,Qt.create(n,0,n.content.size),"pointer"),!0);for(var r=n.resolve(e),o=r.depth+1;0<o;o--){var i=o>r.depth?r.nodeAfter:r.node(o),s=r.before(o);if(i.inlineContent)fr(t,Qt.create(n,s+1,s+1+i.content.size),"pointer");else{if(!Yt.isSelectable(i))continue;fr(t,Yt.create(n,s),"pointer")}return!0}}(e,t)}function vr(t){return Sr(t)}sr.keydown=function(e,n){var t;e.shiftKey=16==n.keyCode||n.shiftKey,wr(e,n)||(e.domObserver.forceFlush(),e.lastKeyCode=n.keyCode,e.lastKeyCodeTime=Date.now(),!xe.ios||13!=n.keyCode||n.ctrlKey||n.altKey||n.metaKey?e.someProp("handleKeyDown",function(t){return t(e,n)})||Ln(e,n)?n.preventDefault():cr(e,"key"):(t=Date.now(),e.lastIOSEnter=t,e.lastIOSEnterFallbackTimeout=setTimeout(function(){e.lastIOSEnter==t&&(e.someProp("handleKeyDown",function(t){return t(e,Ie(13,"Enter"))}),e.lastIOSEnter=0)},200)))},sr.keyup=function(t,e){16==e.keyCode&&(t.shiftKey=!1)},sr.keypress=function(e,n){var r,o;wr(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||xe.mac&&n.metaKey||(e.someProp("handleKeyPress",function(t){return t(e,n)})?n.preventDefault():(r=e.state.selection)instanceof Qt&&r.$from.sameParent(r.$to)||(o=String.fromCharCode(n.charCode),e.someProp("handleTextInput",function(t){return t(e,r.$from.pos,r.$to.pos,o)})||e.dispatch(e.state.tr.insertText(o).scrollIntoView()),n.preventDefault()))};var gr=xe.mac?"metaKey":"ctrlKey";ir.mousedown=function(t,e){t.shiftKey=e.shiftKey;var n,r,o,i,s=vr(t),a=Date.now(),c="singleClick";a-t.lastClick.time<500&&(n=e,r=t.lastClick,o=r.x-n.clientX,i=r.y-n.clientY,o*o+i*i<100)&&!e[gr]&&("singleClick"==t.lastClick.type?c="doubleClick":"doubleClick"==t.lastClick.type&&(c="tripleClick")),t.lastClick={time:a,x:e.clientX,y:e.clientY,type:c};var l=t.posAtCoords(hr(e));l&&("singleClick"==c?t.mouseDown=new yr(t,l,e,s):("doubleClick"==c?function(e,n,t,r){return ur(e,"handleDoubleClickOn",n,t,r)||e.someProp("handleDoubleClick",function(t){return t(e,n,r)})}:mr)(t,l.pos,l.inside,e)?e.preventDefault():cr(t,"pointer"))};var yr=function(t,e,n,r){var o,i,s,a=this;this.view=t,this.startDoc=t.state.doc,this.pos=e,this.event=n,this.flushed=r,this.selectNode=n[gr],this.allowDefault=n.shiftKey,s=-1<e.inside?(i=t.state.doc.nodeAt(e.inside),e.inside):(i=(o=t.state.doc.resolve(e.pos)).parent,o.depth?o.before():0),this.mightDrag=null;var c=r?null:n.target,l=c?t.docView.nearestDesc(c,!0):null;this.target=l?l.dom:null,(i.type.spec.draggable&&!1!==i.type.spec.selectable||t.state.selection instanceof Yt&&s==t.state.selection.from)&&(this.mightDrag={node:i,pos:s,addAttr:this.target&&!this.target.draggable,setUneditable:this.target&&xe.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 a.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),t.root.addEventListener("mouseup",this.up=this.up.bind(this)),t.root.addEventListener("mousemove",this.move=this.move.bind(this)),cr(t,"pointer")};function wr(t,e){return t.composing||xe.safari&&Math.abs(e.timeStamp-t.compositionEndedAt)<500&&(t.compositionEndedAt=-2e8)}yr.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.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.view.mouseDown=null},yr.prototype.up=function(t){var e;this.done(),this.view.dom.contains(3==t.target.nodeType?t.target.parentNode:t.target)&&(e=this.pos,this.view.state.doc!=this.startDoc&&(e=this.view.posAtCoords(hr(t))),this.allowDefault||!e?cr(this.view,"pointer"):dr(this.view,e.pos,e.inside,t,this.selectNode)?t.preventDefault():this.flushed||xe.safari&&this.mightDrag&&!this.mightDrag.node.isAtom||xe.chrome&&!(this.view.state.selection instanceof Qt)&&(e.pos==this.view.state.selection.from||e.pos==this.view.state.selection.to)?(fr(this.view,Ht.near(this.view.state.doc.resolve(e.pos)),"pointer"),t.preventDefault()):cr(this.view,"pointer"))},yr.prototype.move=function(t){!this.allowDefault&&(4<Math.abs(this.event.x-t.clientX)||4<Math.abs(this.event.y-t.clientY))&&(this.allowDefault=!0),cr(this.view,"pointer")},ir.touchdown=function(t){vr(t),cr(t,"pointer")},ir.contextmenu=vr;var br=xe.android?5e3:-1;function kr(t,e){clearTimeout(t.composingTimeout),-1<e&&(t.composingTimeout=setTimeout(function(){return Sr(t)},e))}function xr(t){for(t.composing=!1;0<t.compositionNodes.length;)t.compositionNodes.pop().markParentsDirty()}function Sr(t,e){if(t.domObserver.forceFlush(),xr(t),e||t.docView.dirty){var n=bn(t);return n&&!n.eq(t.state.selection)?t.dispatch(t.state.tr.setSelection(n)):t.updateState(t.state),!0}return!1}sr.compositionstart=sr.compositionupdate=function(t){if(!t.composing){t.domObserver.flush();var e=t.state,n=e.selection.$from;if(e.selection.empty&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(function(t){return!1===t.type.spec.inclusive})))t.markCursor=t.state.storedMarks||n.marks(),Sr(t,!0),t.markCursor=null;else if(Sr(t),xe.gecko&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length)for(var r=t.root.getSelection(),o=r.focusNode,i=r.focusOffset;o&&1==o.nodeType&&0!=i;){var s=i<0?o.lastChild:o.childNodes[i-1];if(!s)break;if(3==s.nodeType){r.collapse(s,s.nodeValue.length);break}o=s,i=-1}t.composing=!0}kr(t,br)},sr.compositionend=function(t,e){t.composing&&(t.composing=!1,t.compositionEndedAt=e.timeStamp,kr(t,20))};var Mr=xe.ie&&xe.ie_version<15||xe.ios&&xe.webkit_version<604;function Cr(e,t,n,r){var o=Un(e,t,n,e.shiftKey,e.state.selection.$from);if(e.someProp("handlePaste",function(t){return t(e,r,o||N.empty)}))return 1;if(o){var i,s=0==(i=o).openStart&&0==i.openEnd&&1==i.content.childCount?i.content.firstChild:null,a=s?e.state.tr.replaceSelectionWith(s,e.shiftKey):e.state.tr.replaceSelection(o);return e.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),1}}ir.copy=sr.cut=function(t,e){var n,r,o,i,s,a,c,l,p,h=t.state.selection,u="cut"==e.type;h.empty||(n=Mr?null:e.clipboardData,o=(r=Hn(t,h.content())).dom,i=r.text,n?(e.preventDefault(),n.clearData(),n.setData("text/html",o.innerHTML),n.setData("text/plain",i)):(a=o,(s=t).dom.parentNode&&((c=s.dom.parentNode.appendChild(document.createElement("div"))).appendChild(a),c.style.cssText="position: fixed; left: -10000px; top: 10px",l=getSelection(),(p=document.createRange()).selectNodeContents(a),s.dom.blur(),l.removeAllRanges(),l.addRange(p),setTimeout(function(){c.parentNode&&c.parentNode.removeChild(c),s.focus()},50))),u&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut")))},sr.paste=function(t,e){var n,r,o,i,s=Mr?null:e.clipboardData;s&&Cr(t,s.getData("text/plain"),s.getData("text/html"),e)?e.preventDefault():(r=e,(n=t).dom.parentNode&&(o=n.shiftKey||n.state.selection.$from.parent.type.spec.code,i=n.dom.parentNode.appendChild(document.createElement(o?"textarea":"div")),o||(i.contentEditable="true"),i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus(),setTimeout(function(){n.focus(),i.parentNode&&i.parentNode.removeChild(i),o?Cr(n,i.value,null,r):Cr(n,i.textContent,i.innerHTML,r)},50)))};function Or(t,e){this.slice=t,this.move=e}var Nr=xe.mac?"altKey":"ctrlKey";for(var Tr in ir.dragstart=function(t,e){var n=t.mouseDown;if(n&&n.done(),e.dataTransfer){var r=t.state.selection,o=r.empty?null:t.posAtCoords(hr(e));if(!(o&&o.pos>=r.from&&o.pos<=(r instanceof Yt?r.to-1:r.to)))if(n&&n.mightDrag)t.dispatch(t.state.tr.setSelection(Yt.create(t.state.doc,n.mightDrag.pos)));else if(e.target&&1==e.target.nodeType){var i=t.docView.nearestDesc(e.target,!0);if(!i||!i.node.type.spec.draggable||i==t.docView)return;t.dispatch(t.state.tr.setSelection(Yt.create(t.state.doc,i.posBefore)))}var s=t.state.selection.content(),a=Hn(t,s),c=a.dom,l=a.text;e.dataTransfer.clearData(),e.dataTransfer.setData(Mr?"Text":"text/html",c.innerHTML),Mr||e.dataTransfer.setData("text/plain",l),t.dragging=new Or(s,!e[Nr])}},ir.dragend=function(t){var e=t.dragging;window.setTimeout(function(){t.dragging==e&&(t.dragging=null)},50)},sr.dragover=sr.dragenter=function(t,e){return e.preventDefault()},sr.drop=function(e,n){var t,r,o,i,s,a,c,l,p,h,u,f=e.dragging;e.dragging=null,n.dataTransfer&&(!(t=e.posAtCoords(hr(n)))||(r=e.state.doc.resolve(t.pos))&&(o=f&&f.slice||Un(e,n.dataTransfer.getData(Mr?"Text":"text/plain"),Mr?null:n.dataTransfer.getData("text/html"),!1,r),i=f&&!n[Nr],e.someProp("handleDrop",function(t){return t(e,n,o||N.empty,i)})?n.preventDefault():o&&(n.preventDefault(),null==(s=o?It(e.state.doc,r.pos,o):r.pos)&&(s=r.pos),a=e.state.tr,i&&a.deleteSelection(),c=a.mapping.map(s),l=0==o.openStart&&0==o.openEnd&&1==o.content.childCount,p=a.doc,l?a.replaceRangeWith(c,c,o.content.firstChild):a.replaceRange(c,c,o),a.doc.eq(p)||(h=a.doc.resolve(c),l&&Yt.isSelectable(o.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(o.content.firstChild)?a.setSelection(new Yt(h)):(u=a.mapping.map(s),a.mapping.maps[a.mapping.maps.length-1].forEach(function(t,e,n,r){return u=r}),a.setSelection(Tn(e,h,a.doc.resolve(u)))),e.focus(),e.dispatch(a.setMeta("uiEvent","drop"))))))},ir.focus=function(t){t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(function(){t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.root.getSelection())&&kn(t)},20))},ir.blur=function(t){t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),t.domObserver.currentSelection.set({}),t.focused=!1)},ir.beforeinput=function(e,t){var n;xe.chrome&&xe.android&&"deleteContentBackward"==t.inputType&&(n=e.domChangeCount,setTimeout(function(){var t;e.domChangeCount==n&&(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",function(t){return t(e,Ie(8,"Backspace"))})||(t=e.state.selection.$cursor)&&0<t.pos&&e.dispatch(e.state.tr.delete(t.pos-1,t.pos).scrollIntoView()))},50))},sr)ir[Tr]=sr[Tr];function Dr(t,e){if(t==e)return!0;for(var n in t)if(t[n]!==e[n])return!1;for(var r in e)if(!(r in t))return!1;return!0}function Er(t,e){this.spec=e||_r,this.side=this.spec.side||0,this.toDOM=t}Er.prototype.map=function(t,e,n,r){var o=t.mapResult(e.from+r,this.side<0?-1:1),i=o.pos;return o.deleted?null:new Rr(i-n,i-n,this)},Er.prototype.valid=function(){return!0},Er.prototype.eq=function(t){return this==t||t instanceof Er&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&Dr(this.spec,t.spec))};function Ar(t,e){this.spec=e||_r,this.attrs=t}Ar.prototype.map=function(t,e,n,r){var o=t.map(e.from+r,this.spec.inclusiveStart?-1:1)-n,i=t.map(e.to+r,this.spec.inclusiveEnd?1:-1)-n;return i<=o?null:new Rr(o,i,this)},Ar.prototype.valid=function(t,e){return e.from<e.to},Ar.prototype.eq=function(t){return this==t||t instanceof Ar&&Dr(this.attrs,t.attrs)&&Dr(this.spec,t.spec)},Ar.is=function(t){return t.type instanceof Ar};function Ir(t,e){this.spec=e||_r,this.attrs=t}Ir.prototype.map=function(t,e,n,r){var o=t.mapResult(e.from+r,1);if(o.deleted)return null;var i=t.mapResult(e.to+r,-1);return i.deleted||i.pos<=o.pos?null:new Rr(o.pos-n,i.pos-n,this)},Ir.prototype.valid=function(t,e){var n=t.content.findIndex(e.from),r=n.index,o=n.offset;return o==e.from&&o+t.child(r).nodeSize==e.to},Ir.prototype.eq=function(t){return this==t||t instanceof Ir&&Dr(this.attrs,t.attrs)&&Dr(this.spec,t.spec)};var Rr=function(t,e,n){this.from=t,this.to=e,this.type=n},zr={spec:{configurable:!0},inline:{configurable:!0}};Rr.prototype.copy=function(t,e){return new Rr(t,e,this.type)},Rr.prototype.eq=function(t,e){return void 0===e&&(e=0),this.type.eq(t.type)&&this.from+e==t.from&&this.to+e==t.to},Rr.prototype.map=function(t,e,n){return this.type.map(t,this,e,n)},Rr.widget=function(t,e,n){return new Rr(t,t,new Er(e,n))},Rr.inline=function(t,e,n,r){return new Rr(t,e,new Ar(n,r))},Rr.node=function(t,e,n,r){return new Rr(t,e,new Ir(n,r))},zr.spec.get=function(){return this.type.spec},zr.inline.get=function(){return this.type instanceof Ar},Object.defineProperties(Rr.prototype,zr);var Pr=[],_r={},Br=function(t,e){this.local=t&&t.length?t:Pr,this.children=e&&e.length?e:Pr};Br.create=function(t,e){return e.length?jr(e,t,0,_r):Vr},Br.prototype.find=function(t,e,n){var r=[];return this.findInner(null==t?0:t,null==e?1e9:e,r,0,n),r},Br.prototype.findInner=function(t,e,n,r,o){for(var i=0;i<this.local.length;i++){var s=this.local[i];s.from<=e&&s.to>=t&&(!o||o(s.spec))&&n.push(s.copy(s.from+r,s.to+r))}for(var a,c=0;c<this.children.length;c+=3){this.children[c]<e&&this.children[c+1]>t&&(a=this.children[c]+1,this.children[c+2].findInner(t-a,e-a,n,r+a,o))}},Br.prototype.map=function(t,e,n){return this==Vr||0==t.maps.length?this:this.mapInner(t,e,0,0,n||_r)},Br.prototype.mapInner=function(t,e,n,r,o){for(var i,s=0;s<this.local.length;s++){var a=this.local[s].map(t,n,r);a&&a.type.valid(e,a)?(i=i||[]).push(a):o.onRemove&&o.onRemove(this.local[s].spec)}return this.children.length?function(t,e,n,r,a,c,o){for(var l=t.slice(),i=function(t,e,n,r){for(var o=0;o<l.length;o+=3){var i=l[o+1],s=void 0;-1==i||i+c<t||(e>=l[o]+c?l[o+1]=-1:a<=n&&(s=r-n-(e-t))&&(l[o]+=s,l[o+1]+=s))}},s=0;s<n.maps.length;s++)n.maps[s].forEach(i);for(var p=!1,h=0;h<l.length;h+=3)if(-1==l[h+1]){var u=n.map(t[h]+c),f=u-a;if(f<0||f>=r.content.size){p=!0;continue}var d,m=n.map(t[h+1]+c,-1)-a,v=r.content.findIndex(f),g=v.index,y=v.offset,w=r.maybeChild(g);w&&y==f&&y+w.nodeSize==m?(d=l[h+2].mapInner(n,w,u+1,t[h]+c+1,o))!=Vr?(l[h]=f,l[h+1]=m,l[h+2]=d):(l[h+1]=-2,p=!0):p=!0}if(p){var b=jr(function(t,e,s,a,c,n,l){for(var r=0;r<t.length;r+=3)-1==t[r+1]&&!function t(e,n){for(var r=0;r<e.local.length;r++){var o=e.local[r].map(a,c,n);o?s.push(o):l.onRemove&&l.onRemove(e.local[r].spec)}for(var i=0;i<e.children.length;i+=3)t(e.children[i+2],e.children[i]+n+1)}(t[r+2],e[r]+n+1);return s}(l,t,e||[],n,a,c,o),r,0,o);e=b.local;for(var k=0;k<l.length;k+=3)l[k+1]<0&&(l.splice(k,3),k-=3);for(var x=0,S=0;x<b.children.length;x+=3){for(var M=b.children[x];S<l.length&&l[S]<M;)S+=3;l.splice(S,0,b.children[x],b.children[x+1],b.children[x+2])}}return new Br(e&&e.sort(Jr),l)}(this.children,i,t,e,n,r,o):i?new Br(i.sort(Jr)):Vr},Br.prototype.add=function(t,e){return e.length?this==Vr?Br.create(t,e):this.addInner(t,e,0):this},Br.prototype.addInner=function(t,o,i){var s,a=this,c=0;t.forEach(function(t,e){var n,r=e+i;if(n=qr(o,t,r)){for(s=s||a.children.slice();c<s.length&&s[c]<e;)c+=3;s[c]==e?s[c+2]=s[c+2].addInner(t,n,r+1):s.splice(c,0,e,e+t.nodeSize,jr(n,t,r+1,_r)),c+=3}});var e=Fr(c?Lr(o):o,-i);return new Br(e.length?this.local.concat(e).sort(Jr):this.local,s||this.children)},Br.prototype.remove=function(t){return 0==t.length||this==Vr?this:this.removeInner(t,0)},Br.prototype.removeInner=function(t,e){for(var n=this.children,r=this.local,o=0;o<n.length;o+=3){for(var i,s,a=void 0,c=n[o]+e,l=n[o+1]+e,p=0;p<t.length;p++)(i=t[p])&&i.from>c&&i.to<l&&(t[p]=null,(a=a||[]).push(i));a&&(n==this.children&&(n=this.children.slice()),(s=n[o+2].removeInner(a,c+1))!=Vr?n[o+2]=s:(n.splice(o,3),o-=3))}if(r.length)for(var h,u=0;u<t.length;u++)if(h=t[u])for(var f=0;f<r.length;f++)r[f].eq(h,e)&&(r==this.local&&(r=this.local.slice()),r.splice(f--,1));return n==this.children&&r==this.local?this:r.length||n.length?new Br(r,n):Vr},Br.prototype.forChild=function(t,e){if(this==Vr)return this;if(e.isLeaf)return Br.empty;for(var n,r,o=0;o<this.children.length;o+=3)if(this.children[o]>=t){this.children[o]==t&&(n=this.children[o+2]);break}for(var i=t+1,s=i+e.content.size,a=0;a<this.local.length;a++){var c,l,p=this.local[a];p.from<s&&p.to>i&&p.type instanceof Ar&&((c=Math.max(i,p.from)-i)<(l=Math.min(s,p.to)-i)&&(r=r||[]).push(p.copy(c,l)))}if(r){var h=new Br(r.sort(Jr));return n?new $r([h,n]):h}return n||Vr},Br.prototype.eq=function(t){if(this==t)return!0;if(!(t instanceof Br)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(var e=0;e<this.local.length;e++)if(!this.local[e].eq(t.local[e]))return!1;for(var n=0;n<this.children.length;n+=3)if(this.children[n]!=t.children[n]||this.children[n+1]!=t.children[n+1]||!this.children[n+2].eq(t.children[n+2]))return!1;return!0},Br.prototype.locals=function(t){return Wr(this.localsInner(t))},Br.prototype.localsInner=function(t){if(this==Vr)return Pr;if(t.inlineContent||!this.local.some(Ar.is))return this.local;for(var e=[],n=0;n<this.local.length;n++)this.local[n].type instanceof Ar||e.push(this.local[n]);return e};var Vr=new Br;Br.empty=Vr,Br.removeOverlap=Wr;var $r=function(t){this.members=t};function Fr(t,e){if(!e||!t.length)return t;for(var n=[],r=0;r<t.length;r++){var o=t[r];n.push(new Rr(o.from+e,o.to+e,o.type))}return n}function qr(t,e,n){if(e.isLeaf)return null;for(var r,o=n+e.nodeSize,i=null,s=0;s<t.length;s++)(r=t[s])&&r.from>n&&r.to<o&&((i=i||[]).push(r),t[s]=null);return i}function Lr(t){for(var e=[],n=0;n<t.length;n++)null!=t[n]&&e.push(t[n]);return e}function jr(o,t,i,s){var a=[],c=!1;t.forEach(function(t,e){var n,r=qr(o,t,e+i);r&&(c=!0,(n=jr(r,t,i+e+1,s))!=Vr&&a.push(e,e+t.nodeSize,n))});for(var e=Fr(c?Lr(o):o,-i).sort(Jr),n=0;n<e.length;n++)e[n].type.valid(t,e[n])||(s.onRemove&&s.onRemove(e[n].spec),e.splice(n--,1));return e.length||a.length?new Br(e,a):Vr}function Jr(t,e){return t.from-e.from||t.to-e.to}function Wr(t){for(var e=t,n=0;n<e.length-1;n++){var r=e[n];if(r.from!=r.to)for(var o=n+1;o<e.length;o++){var i=e[o];if(i.from!=r.from){i.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,i.from),Kr(e,o,r.copy(i.from,r.to)));break}i.to!=r.to&&(e==t&&(e=t.slice()),e[o]=i.copy(i.from,r.to),Kr(e,o+1,i.copy(r.to,i.to)))}}return e}function Kr(t,e,n){for(;e<t.length&&0<Jr(n,t[e]);)e++;t.splice(e,0,n)}function Hr(n){var r=[];return n.someProp("decorations",function(t){var e=t(n.state);e&&e!=Vr&&r.push(e)}),n.cursorWrapper&&r.push(Br.create(n.state.doc,[n.cursorWrapper.deco])),$r.from(r)}$r.prototype.forChild=function(t,e){if(e.isLeaf)return Br.empty;for(var n=[],r=0;r<this.members.length;r++){var o=this.members[r].forChild(t,e);o!=Vr&&(o instanceof $r?n=n.concat(o.members):n.push(o))}return $r.from(n)},$r.prototype.eq=function(t){if(!(t instanceof $r)||t.members.length!=this.members.length)return!1;for(var e=0;e<this.members.length;e++)if(!this.members[e].eq(t.members[e]))return!1;return!0},$r.prototype.locals=function(t){for(var e,n=!0,r=0;r<this.members.length;r++){var o=this.members[r].localsInner(t);if(o.length)if(e){n&&(e=e.slice(),n=!1);for(var i=0;i<o.length;i++)e.push(o[i])}else e=o}return e?Wr(n?e:e.sort(Jr)):Pr},$r.from=function(t){switch(t.length){case 0:return Vr;case 1:return t[0];default:return new $r(t)}};function Ur(t,e){this._props=e,this.state=e.state,this.dispatch=this.dispatch.bind(this),this._root=null,this.focused=!1,this.trackWrites=null,this.dom=t&&t.mount||document.createElement("div"),t&&(t.appendChild?t.appendChild(this.dom):t.apply?t(this.dom):t.mount&&(this.mounted=!0)),this.editable=Yr(this),this.markCursor=null,this.cursorWrapper=null,Xr(this),this.nodeViews=Zr(this),this.docView=sn(this.state.doc,Qr(this),Hr(this),this.dom,this),this.lastSelectedViewDesc=null,this.dragging=null,ar(this),this.pluginViews=[],this.updatePluginViews()}var Gr={props:{configurable:!0},root:{configurable:!0}};function Qr(n){var r=Object.create(null);return r.class="ProseMirror",r.contenteditable=String(n.editable),n.someProp("attributes",function(t){if("function"==typeof t&&(t=t(n.state)),t)for(var e in t)"class"==e?r.class+=" "+t[e]:r[e]||"contenteditable"==e||"nodeName"==e||(r[e]=String(t[e]))}),[Rr.node(0,n.state.doc.content.size,r)]}function Xr(t){var e;t.markCursor?((e=document.createElement("img")).setAttribute("mark-placeholder","true"),t.cursorWrapper={dom:e,deco:Rr.widget(t.state.selection.head,e,{raw:!0,marks:t.markCursor})}):t.cursorWrapper=null}function Yr(e){return!e.someProp("editable",function(t){return!1===t(e.state)})}function Zr(t){var n={};return t.someProp("nodeViews",function(t){for(var e in t)Object.prototype.hasOwnProperty.call(n,e)||(n[e]=t[e])}),n}Gr.props.get=function(){if(this._props.state!=this.state){var t=this._props;for(var e in this._props={},t)this._props[e]=t[e];this._props.state=this.state}return this._props},Ur.prototype.update=function(t){t.handleDOMEvents!=this._props.handleDOMEvents&&lr(this),this._props=t,this.updateStateInner(t.state,!0)},Ur.prototype.setProps=function(t){var e={};for(var n in this._props)e[n]=this._props[n];for(var r in e.state=this.state,t)e[r]=t[r];this.update(e)},Ur.prototype.updateState=function(t){this.updateStateInner(t,this.state.plugins!=t.plugins)},Ur.prototype.updateStateInner=function(t,e){var n,r=this,o=this.state,i=!1,s=!1;t.storedMarks&&this.composing&&(xr(this),s=!0),this.state=t,e&&(function(t,e){var n=0,r=0;for(var o in t){if(t[o]!=e[o])return!0;n++}for(var i in e)r++;return n!=r}(n=Zr(this),this.nodeViews)&&(this.nodeViews=n,i=!0),lr(this)),this.editable=Yr(this),Xr(this);var a=Hr(this),c=Qr(this),l=e?"reset":t.scrollToSelection>o.scrollToSelection?"to selection":"preserve",p=i||!this.docView.matchesNode(t.doc,c,a);!p&&t.selection.eq(o.selection)||(s=!0);var h,u,f,d,m,v,g,y,w,b,k,x,S,M,C="preserve"==l&&s&&null==this.dom.style.overflowAnchor&&function(t){for(var e,n,r=t.dom.getBoundingClientRect(),o=Math.max(0,r.top),i=(r.left+r.right)/2,s=o+1;s<Math.min(innerHeight,r.bottom);s+=5){var a=t.root.elementFromPoint(i,s);if(a!=t.dom&&t.dom.contains(a)){var c=a.getBoundingClientRect();if(c.top>=o-20){e=a,n=c.top;break}}}return{refDOM:e,refTop:n,stack:Pe(t.dom)}}(this);s&&(this.domObserver.stop(),h=p&&(xe.ie||xe.chrome)&&!this.composing&&!o.selection.empty&&!t.selection.empty&&(v=o.selection,g=t.selection,y=Math.min(v.$anchor.sharedDepth(v.head),g.$anchor.sharedDepth(g.head)),v.$anchor.start(y)!=g.$anchor.start(y)),p&&(u=xe.chrome?this.trackWrites=this.root.getSelection().focusNode:null,!i&&this.docView.update(t.doc,c,a,this)||(this.docView.updateOuterDeco([]),this.docView.destroy(),this.docView=sn(t.doc,c,a,this.dom,this)),u&&!this.trackWrites&&(h=!0)),h||!(this.mouseDown&&this.domObserver.currentSelection.eq(this.root.getSelection())&&(d=(f=this).docView.domFromPos(f.state.selection.anchor,0),m=f.root.getSelection(),Se(d.node,d.offset,m.anchorNode,m.anchorOffset)))?kn(this,h):(On(this,t.selection),this.domObserver.setCurSelection()),this.domObserver.start()),this.updatePluginViews(o),"reset"==l?this.dom.scrollTop=0:"to selection"==l?(w=this.root.getSelection().focusNode,this.someProp("handleScrollToSelection",function(t){return t(r)})||(t.selection instanceof Yt?ze(this,this.docView.domAfterPos(t.selection.from).getBoundingClientRect(),w):ze(this,this.coordsAtPos(t.selection.head,1),w))):C&&(k=(b=C).refDOM,x=b.refTop,S=b.stack,M=k?k.getBoundingClientRect().top:0,_e(S,0==M?0:M-x))},Ur.prototype.destroyPluginViews=function(){for(var t;t=this.pluginViews.pop();)t.destroy&&t.destroy()},Ur.prototype.updatePluginViews=function(t){if(t&&t.plugins==this.state.plugins)for(var e=0;e<this.pluginViews.length;e++){var n=this.pluginViews[e];n.update&&n.update(this,t)}else{this.destroyPluginViews();for(var r=0;r<this.state.plugins.length;r++){var o=this.state.plugins[r];o.spec.view&&this.pluginViews.push(o.spec.view(this))}}},Ur.prototype.someProp=function(t,e){var n,r=this._props&&this._props[t];if(null!=r&&(n=e?e(r):r))return n;var o=this.state.plugins;if(o)for(var i=0;i<o.length;i++){var s=o[i].props[t];if(null!=s&&(n=e?e(s):s))return n}},Ur.prototype.hasFocus=function(){return this.root.activeElement==this.dom},Ur.prototype.focus=function(){this.domObserver.stop(),this.editable&&function(t){if(t.setActive)return t.setActive();if(Be)return t.focus(Be);var e=Pe(t);t.focus(null==Be?{get preventScroll(){return Be={preventScroll:!0},!0}}:void 0),Be||(Be=!1,_e(e,0))}(this.dom),kn(this),this.domObserver.start()},Gr.root.get=function(){var t=this._root;if(null==t)for(var e=this.dom.parentNode;e;e=e.parentNode)if(9==e.nodeType||11==e.nodeType&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=function(){return document.getSelection()}),this._root=e;return t||document},Ur.prototype.posAtCoords=function(t){return Fe(this,t)},Ur.prototype.coordsAtPos=function(t,e){return void 0===e&&(e=1),je(this,t,e)},Ur.prototype.domAtPos=function(t,e){return void 0===e&&(e=0),this.docView.domFromPos(t,e)},Ur.prototype.nodeDOM=function(t){var e=this.docView.descAt(t);return e?e.nodeDOM:null},Ur.prototype.posAtDOM=function(t,e,n){void 0===n&&(n=-1);var r=this.docView.posFromDOM(t,e,n);if(null==r)throw new RangeError("DOM position not inside the editor");return r},Ur.prototype.endOfTextblock=function(t,e){return Xe(this,e||this.state,t)},Ur.prototype.destroy=function(){this.docView&&(function(t){for(var e in t.domObserver.stop(),t.eventHandlers)t.dom.removeEventListener(e,t.eventHandlers[e]);clearTimeout(t.composingTimeout),clearTimeout(t.lastIOSEnterFallbackTimeout)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Hr(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null)},Ur.prototype.dispatchEvent=function(t){var e,n;pr(e=this,n=t)||!ir[n.type]||!e.editable&&n.type in sr||ir[n.type](e,n)},Ur.prototype.dispatch=function(t){var e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))},Object.defineProperties(Ur.prototype,Gr);for(var to=Object.freeze({__proto__:null,Decoration:Rr,DecorationSet:Br,EditorView:Ur,__endComposition:Sr,__parseFromClipboard:Un,__serializeForClipboard:Hn}),eo={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"},no={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"},ro="undefined"!=typeof navigator&&/Chrome\/(\d+)/.exec(navigator.userAgent),oo="undefined"!=typeof navigator&&/Apple Computer/.test(navigator.vendor),io="undefined"!=typeof navigator&&/Gecko\/\d+/.test(navigator.userAgent),so="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),ao="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),co=ro&&(so||+ro[1]<57)||io&&so,lo=0;lo<10;lo++)eo[48+lo]=eo[96+lo]=String(lo);for(lo=1;lo<=24;lo++)eo[lo+111]="F"+lo;for(lo=65;lo<=90;lo++)eo[lo]=String.fromCharCode(lo+32),no[lo]=String.fromCharCode(lo);for(var po in eo)no.hasOwnProperty(po)||(no[po]=eo[po]);var ho="undefined"!=typeof navigator&&/Mac/.test(navigator.platform);function uo(t){var e=Object.create(null);for(var n in t)e[function(t){var e,n,r,o,i=t.split(/-(?!$)/),s=i[i.length-1];"Space"==s&&(s=" ");for(var a=0;a<i.length-1;a++){var c=i[a];if(/^(cmd|meta|m)$/i.test(c))o=!0;else if(/^a(lt)?$/i.test(c))e=!0;else if(/^(c|ctrl|control)$/i.test(c))n=!0;else if(/^s(hift)?$/i.test(c))r=!0;else{if(!/^mod$/i.test(c))throw new Error("Unrecognized modifier name: "+c);ho?o=!0:n=!0}}return e&&(s="Alt-"+s),n&&(s="Ctrl-"+s),o&&(s="Meta-"+s),r&&(s="Shift-"+s),s}(n)]=t[n];return e}function fo(t,e,n){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),!1!==n&&e.shiftKey&&(t="Shift-"+t),t}function mo(t){return new ue({props:{handleKeyDown:vo(t)}})}function vo(t){var p=uo(t);return function(t,e){var n,r,o,i=(r=e,"Esc"==(o=!(co&&(r.ctrlKey||r.altKey||r.metaKey)||(oo||ao)&&r.shiftKey&&r.key&&1==r.key.length)&&r.key||(r.shiftKey?no:eo)[r.keyCode]||r.key||"Unidentified")&&(o="Escape"),"Del"==o&&(o="Delete"),"Left"==o&&(o="ArrowLeft"),"Up"==o&&(o="ArrowUp"),"Right"==o&&(o="ArrowRight"),"Down"==o&&(o="ArrowDown"),o),s=1==i.length&&" "!=i,a=p[fo(i,e,!s)];if(a&&a(t.state,t.dispatch,t))return!0;if(s&&(e.shiftKey||e.altKey||e.metaKey||127<i.charCodeAt(0))&&(n=eo[e.keyCode])&&n!=i){var c=p[fo(n,e,!0)];if(c&&c(t.state,t.dispatch,t))return!0}else if(s&&e.shiftKey){var l=p[fo(i,e,!0)];if(l&&l(t.state,t.dispatch,t))return!0}return!1}}var go=Object.freeze({__proto__:null,keydownHandler:vo,keymap:mo}),yo=function(t,e){var a;this.match=t,this.handler="string"==typeof e?(a=e,function(t,e,n,r){var o,i,s=a;return e[1]&&(o=e[0].lastIndexOf(e[1]),s+=e[0].slice(o+e[1].length),0<(i=(n+=o)-r)&&(s=e[0].slice(o-i,o)+s,n=r)),t.tr.insertText(s,n,r)}):e};var wo=500;function bo(t){var o=t.rules,i=new ue({state:{init:function(){return null},apply:function(t,e){var n=t.getMeta(this);return n||(t.selectionSet||t.docChanged?null:e)}},props:{handleTextInput:function(t,e,n,r){return ko(t,e,n,r,o,i)},handleDOMEvents:{compositionend:function(e){setTimeout(function(){var t=e.state.selection.$cursor;t&&ko(e,t.pos,t.pos,"",o,i)})}}},isInputRules:!0});return i}function ko(t,e,n,r,o,i){if(t.composing)return!1;var s=t.state,a=s.doc.resolve(e);if(a.parent.type.spec.code)return!1;for(var c=a.parent.textBetween(Math.max(0,a.parentOffset-wo),a.parentOffset,null,"")+r,l=0;l<o.length;l++){var p=o[l].match.exec(c),h=p&&o[l].handler(s,p,e-(p[0].length-r.length),n);if(h)return t.dispatch(h.setMeta(i,{transform:h,from:e,to:n,text:r})),!0}return!1}function xo(t,e){for(var n=t.plugins,r=0;r<n.length;r++){var o=n[r],i=void 0;if(o.spec.isInputRules&&(i=o.getState(t))){if(e){for(var s,a=t.tr,c=i.transform,l=c.steps.length-1;0<=l;l--)a.step(c.steps[l].invert(c.docs[l]));i.text?(s=a.doc.resolve(i.from).marks(),a.replaceWith(i.from,i.to,t.schema.text(i.text,s))):a.delete(i.from,i.to),e(a)}return!0}}return!1}var So=new yo(/--$/,"—"),Mo=new yo(/\.\.\.$/,"…"),Co=new yo(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“"),Oo=new yo(/"$/,"”"),No=new yo(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘"),To=new yo(/'$/,"’"),Do=[Co,Oo,No,To];function Eo(t,l,p,h){return new yo(t,function(t,e,n,r){var o=p instanceof Function?p(e):p,i=t.tr.delete(n,r),s=i.doc.resolve(n).blockRange(),a=s&&Ct(s,l,o);if(!a)return null;i.wrap(s,a);var c=i.doc.resolve(n-1).nodeBefore;return c&&c.type==l&&Tt(i.doc,n-1)&&(!h||h(e,c))&&i.join(n-1),i})}function Ao(t,s,a){return new yo(t,function(t,e,n,r){var o=t.doc.resolve(n),i=a instanceof Function?a(e):a;return o.node(-1).canReplaceWith(o.index(-1),o.indexAfter(-1),s)?t.tr.delete(n,r).setBlockType(n,n,s,i):null})}function Io(){}var Ro=Object.freeze({__proto__:null,InputRule:yo,closeDoubleQuote:Oo,closeSingleQuote:To,ellipsis:Mo,emDash:So,inputRules:bo,openDoubleQuote:Co,openSingleQuote:No,smartQuotes:Do,textblockTypeInputRule:Ao,undoInputRule:xo,wrappingInputRule:Eo});Io.prototype.append=function(t){return t.length?(t=Io.from(t),!this.length&&t||t.length<200&&this.leafAppend(t)||this.length<200&&t.leafPrepend(this)||this.appendInner(t)):this},Io.prototype.prepend=function(t){return t.length?Io.from(t).append(this):this},Io.prototype.appendInner=function(t){return new Po(this,t)},Io.prototype.slice=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=this.length),e<=t?Io.empty:this.sliceInner(Math.max(0,t),Math.min(this.length,e))},Io.prototype.get=function(t){if(!(t<0||t>=this.length))return this.getInner(t)},Io.prototype.forEach=function(t,e,n){void 0===e&&(e=0),void 0===n&&(n=this.length),e<=n?this.forEachInner(t,e,n,0):this.forEachInvertedInner(t,e,n,0)},Io.prototype.map=function(n,t,e){void 0===t&&(t=0),void 0===e&&(e=this.length);var r=[];return this.forEach(function(t,e){return r.push(n(t,e))},t,e),r},Io.from=function(t){return t instanceof Io?t:t&&t.length?new zo(t):Io.empty};var zo=function(e){function n(t){e.call(this),this.values=t}e&&(n.__proto__=e);var t={length:{configurable:!0},depth:{configurable:!0}};return((n.prototype=Object.create(e&&e.prototype)).constructor=n).prototype.flatten=function(){return this.values},n.prototype.sliceInner=function(t,e){return 0==t&&e==this.length?this:new n(this.values.slice(t,e))},n.prototype.getInner=function(t){return this.values[t]},n.prototype.forEachInner=function(t,e,n,r){for(var o=e;o<n;o++)if(!1===t(this.values[o],r+o))return!1},n.prototype.forEachInvertedInner=function(t,e,n,r){for(var o=e-1;n<=o;o--)if(!1===t(this.values[o],r+o))return!1},n.prototype.leafAppend=function(t){if(this.length+t.length<=200)return new n(this.values.concat(t.flatten()))},n.prototype.leafPrepend=function(t){if(this.length+t.length<=200)return new n(t.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(n.prototype,t),n}(Io);Io.empty=new zo([]);var Po=function(n){function r(t,e){n.call(this),this.left=t,this.right=e,this.length=t.length+e.length,this.depth=Math.max(t.depth,e.depth)+1}return n&&(r.__proto__=n),((r.prototype=Object.create(n&&n.prototype)).constructor=r).prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},r.prototype.getInner=function(t){return t<this.left.length?this.left.get(t):this.right.get(t-this.left.length)},r.prototype.forEachInner=function(t,e,n,r){var o=this.left.length;return!(e<o&&!1===this.left.forEachInner(t,e,Math.min(n,o),r))&&(!(o<n&&!1===this.right.forEachInner(t,Math.max(e-o,0),Math.min(this.length,n)-o,r+o))&&void 0)},r.prototype.forEachInvertedInner=function(t,e,n,r){var o=this.left.length;return!(o<e&&!1===this.right.forEachInvertedInner(t,e-o,Math.max(n,o)-o,r+o))&&(!(n<o&&!1===this.left.forEachInvertedInner(t,Math.min(e,o),n,r))&&void 0)},r.prototype.sliceInner=function(t,e){if(0==t&&e==this.length)return this;var n=this.left.length;return e<=n?this.left.slice(t,e):n<=t?this.right.slice(t-n,e-n):this.left.slice(t,n).append(this.right.slice(0,e-n))},r.prototype.leafAppend=function(t){var e=this.right.leafAppend(t);if(e)return new r(this.left,e)},r.prototype.leafPrepend=function(t){var e=this.left.leafPrepend(t);if(e)return new r(e,this.right)},r.prototype.appendInner=function(t){return this.left.depth>=Math.max(this.right.depth,t.depth)+1?new r(this.left,new r(this.right,t)):new r(this,t)},r}(Io),_o=Io,Bo=function(t,e){this.items=t,this.eventCount=e};Bo.prototype.popEvent=function(t,e){var o=this;if(0==this.eventCount)return null;for(var i,s,a=this.items.length;;a--){if(this.items.get(a-1).selection){--a;break}}e&&(i=this.remapping(a,this.items.length),s=i.maps.length);var c,l,p=t.tr,h=[],u=[];return this.items.forEach(function(t,e){return t.step?(i?(u.push(new Vo(t.map)),(n=t.step.map(i.slice(s)))&&p.maybeStep(n).doc&&(r=p.mapping.maps[p.mapping.maps.length-1],h.push(new Vo(r,null,null,h.length+u.length))),s--,r&&i.appendMap(r,s)):p.maybeStep(t.step),t.selection?(c=i?t.selection.map(i.slice(s)):t.selection,l=new Bo(o.items.slice(0,a).append(u.reverse().concat(h)),o.eventCount-1),!1):void 0):(i||(i=o.remapping(a,e+1),s=i.maps.length),s--,void u.push(t));var n,r},this.items.length,0),{remaining:l,transform:p,selection:c}},Bo.prototype.addTransform=function(t,e,n,r){for(var o=[],i=this.eventCount,s=this.items,a=!r&&s.length?s.get(s.length-1):null,c=0;c<t.steps.length;c++){var l,p=t.steps[c].invert(t.docs[c]),h=new Vo(t.mapping.maps[c],p,e);(l=a&&a.merge(h))&&(h=l,c?o.pop():s=s.slice(0,s.length-1)),o.push(h),e&&(i++,e=null),r||(a=h)}var u,f,d,m=i-n.depth;return Fo<m&&(f=m,(u=s).forEach(function(t,e){if(t.selection&&0==f--)return d=e,!1}),s=u.slice(d),i-=m),new Bo(s.append(o),i)},Bo.prototype.remapping=function(r,t){var o=new ft;return this.items.forEach(function(t,e){var n=null!=t.mirrorOffset&&e-t.mirrorOffset>=r?o.maps.length-t.mirrorOffset:null;o.appendMap(t.map,n)},r,t),o},Bo.prototype.addMaps=function(t){return 0==this.eventCount?this:new Bo(this.items.append(t.map(function(t){return new Vo(t)})),this.eventCount)},Bo.prototype.rebased=function(i,t){if(!this.eventCount)return this;var s=[],e=Math.max(0,this.items.length-t),a=i.mapping,c=i.steps.length,l=this.eventCount;this.items.forEach(function(t){t.selection&&l--},e);var p=t;this.items.forEach(function(t){var e,n,r,o=a.getMirror(--p);null!=o&&(c=Math.min(c,o),e=a.maps[o],t.step?(n=i.steps[o].invert(i.docs[o]),(r=t.selection&&t.selection.map(a.slice(p+1,o)))&&l++,s.push(new Vo(e,n,r))):s.push(new Vo(e)))},e);for(var n=[],r=t;r<c;r++)n.push(new Vo(a.maps[r]));var o=this.items.slice(0,e).append(n).append(s),h=new Bo(o,l);return 500<h.emptyItemCount()&&(h=h.compress(this.items.length-s.length)),h},Bo.prototype.emptyItemCount=function(){var e=0;return this.items.forEach(function(t){t.step||e++}),e},Bo.prototype.compress=function(c){void 0===c&&(c=this.items.length);var l=this.remapping(0,c),p=l.maps.length,h=[],u=0;return this.items.forEach(function(t,e){var n,r,o,i,s,a;c<=e?(h.push(t),t.selection&&u++):t.step?(r=(n=t.step.map(l.slice(p)))&&n.getMap(),p--,r&&l.appendMap(r,p),n&&((o=t.selection&&t.selection.map(l.slice(p)))&&u++,i=new Vo(r.invert(),n,o),a=h.length-1,(s=h.length&&h[a].merge(i))?h[a]=s:h.push(i))):t.map&&p--},this.items.length,0),new Bo(_o.from(h.reverse()),u)},Bo.empty=new Bo(_o.empty,0);var Vo=function(t,e,n,r){this.map=t,this.step=e,this.selection=n,this.mirrorOffset=r};Vo.prototype.merge=function(t){if(this.step&&t.step&&!t.selection){var e=t.step.merge(this.step);if(e)return new Vo(e.getMap().invert(),e,this.selection)}};var $o=function(t,e,n,r){this.done=t,this.undone=e,this.prevRanges=n,this.prevTime=r},Fo=20;function qo(t,e,n,r){var o,i=n.getMeta(Uo);if(i)return i.historyState;n.getMeta(Go)&&(t=new $o(t.done,t.undone,null,0));var s=n.getMeta("appendedTransaction");if(0==n.steps.length)return t;if(s&&s.getMeta(Uo))return s.getMeta(Uo).redo?new $o(t.done.addTransform(n,null,r,Ho(e)),t.undone,Lo(n.mapping.maps[n.steps.length-1]),t.prevTime):new $o(t.done,t.undone.addTransform(n,null,r,Ho(e)),null,t.prevTime);if(!1===n.getMeta("addToHistory")||s&&!1===s.getMeta("addToHistory"))return(o=n.getMeta("rebased"))?new $o(t.done.rebased(n,o),t.undone.rebased(n,o),jo(t.prevRanges,n.mapping),t.prevTime):new $o(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),jo(t.prevRanges,n.mapping),t.prevTime);var a=0==t.prevTime||!s&&(t.prevTime<(n.time||0)-r.newGroupDelay||!function(t,r){if(!r)return!1;if(!t.docChanged)return!0;var o=!1;return t.mapping.maps[0].forEach(function(t,e){for(var n=0;n<r.length;n+=2)t<=r[n+1]&&e>=r[n]&&(o=!0)}),o}(n,t.prevRanges)),c=s?jo(t.prevRanges,n.mapping):Lo(n.mapping.maps[n.steps.length-1]);return new $o(t.done.addTransform(n,a?e.selection.getBookmark():null,r,Ho(e)),Bo.empty,c,n.time)}function Lo(t){var o=[];return t.forEach(function(t,e,n,r){return o.push(n,r)}),o}function jo(t,e){if(!t)return null;for(var n=[],r=0;r<t.length;r+=2){var o=e.map(t[r],1),i=e.map(t[r+1],-1);o<=i&&n.push(o,i)}return n}function Jo(t,e,n,r){var o,i,s,a=Ho(e),c=Uo.get(e).spec.config,l=(r?t.undone:t.done).popEvent(e,a);l&&(o=l.selection.resolve(l.transform.doc),i=(r?t.done:t.undone).addTransform(l.transform,e.selection.getBookmark(),c,a),s=new $o(r?i:l.remaining,r?l.remaining:i,null,0),n(l.transform.setSelection(o).setMeta(Uo,{redo:r,historyState:s}).scrollIntoView()))}var Wo=!1,Ko=null;function Ho(t){var e=t.plugins;if(Ko!=e){Wo=!1,Ko=e;for(var n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){Wo=!0;break}}return Wo}var Uo=new me("history"),Go=new me("closeHistory");function Qo(r){return r={depth:r&&r.depth||100,newGroupDelay:r&&r.newGroupDelay||500},new ue({key:Uo,state:{init:function(){return new $o(Bo.empty,Bo.empty,null,0)},apply:function(t,e,n){return qo(e,n,t,r)}},config:r})}function Xo(t,e){var n=Uo.getState(t);return!(!n||0==n.done.eventCount)&&(e&&Jo(n,t,e,!1),!0)}function Yo(t,e){var n=Uo.getState(t);return!(!n||0==n.undone.eventCount)&&(e&&Jo(n,t,e,!0),!0)}var Zo=Object.freeze({__proto__:null,HistoryState:$o,closeHistory:function(t){return t.setMeta(Go,!0)},history:Qo,redo:Yo,redoDepth:function(t){var e=Uo.getState(t);return e?e.undone.eventCount:0},undo:Xo,undoDepth:function(t){var e=Uo.getState(t);return e?e.done.eventCount:0}});function ti(t,e){return!t.selection.empty&&(e&&e(t.tr.deleteSelection().scrollIntoView()),!0)}function ei(t,e,n){var r=t.selection.$cursor;if(!r||(n?!n.endOfTextblock("backward",t):0<r.parentOffset))return!1;var o=oi(r);if(!o){var i=r.blockRange(),s=i&&Mt(i);return null==s?!1:(e&&e(t.tr.lift(i,s).scrollIntoView()),!0)}var a,c=o.nodeBefore;return!(c.type.spec.isolating||!wi(t,o,e))||(0!=r.parent.content.size||!ni(c,"end")&&!Yt.isSelectable(c)?!(!c.isAtom||o.depth!=r.depth-1)&&(e&&e(t.tr.delete(o.pos-c.nodeSize,o.pos).scrollIntoView()),!0):(e&&((a=t.tr.deleteRange(r.before(),r.after())).setSelection(ni(c,"end")?Ht.findFrom(a.doc.resolve(a.mapping.map(o.pos,-1)),-1):Yt.create(a.doc,o.pos-c.nodeSize)),e(a.scrollIntoView())),!0))}function ni(t,e){for(;t;t="start"==e?t.firstChild:t.lastChild)if(t.isTextblock)return 1}function ri(t,e,n){var r=t.selection,o=r.$head,i=o;if(!r.empty)return!1;if(o.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):0<o.parentOffset)return!1;i=oi(o)}var s=i&&i.nodeBefore;return!(!s||!Yt.isSelectable(s))&&(e&&e(t.tr.setSelection(Yt.create(t.doc,i.pos-s.nodeSize)).scrollIntoView()),!0)}function oi(t){if(!t.parent.type.spec.isolating)for(var e=t.depth-1;0<=e;e--){if(0<t.index(e))return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function ii(t,e,n){var r=t.selection.$cursor;if(!r||(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size))return!1;var o=ai(r);if(!o)return!1;var i,s=o.nodeAfter;return!!wi(t,o,e)||(0!=r.parent.content.size||!ni(s,"start")&&!Yt.isSelectable(s)?!(!s.isAtom||o.depth!=r.depth-1)&&(e&&e(t.tr.delete(o.pos,o.pos+s.nodeSize).scrollIntoView()),!0):(e&&((i=t.tr.deleteRange(r.before(),r.after())).setSelection(ni(s,"start")?Ht.findFrom(i.doc.resolve(i.mapping.map(o.pos)),1):Yt.create(i.doc,i.mapping.map(o.pos))),e(i.scrollIntoView())),!0))}function si(t,e,n){var r=t.selection,o=r.$head,i=o;if(!r.empty)return!1;if(o.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):o.parentOffset<o.parent.content.size)return!1;i=ai(o)}var s=i&&i.nodeAfter;return!(!s||!Yt.isSelectable(s))&&(e&&e(t.tr.setSelection(Yt.create(t.doc,i.pos)).scrollIntoView()),!0)}function ai(t){if(!t.parent.type.spec.isolating)for(var e=t.depth-1;0<=e;e--){var n=t.node(e);if(t.index(e)+1<n.childCount)return t.doc.resolve(t.after(e+1));if(n.type.spec.isolating)break}return null}function ci(t,e){var n,r,o=t.selection,i=o instanceof Yt;if(i){if(o.node.isTextblock||!Tt(t.doc,o.from))return!1;n=o.from}else if(null==(n=Et(t.doc,o.from,-1)))return!1;return e&&(r=t.tr.join(n),i&&r.setSelection(Yt.create(r.doc,n-t.doc.resolve(n).nodeBefore.nodeSize)),e(r.scrollIntoView())),!0}function li(t,e){var n,r=t.selection;if(r instanceof Yt){if(r.node.isTextblock||!Tt(t.doc,r.to))return!1;n=r.to}else if(null==(n=Et(t.doc,r.to,1)))return!1;return e&&e(t.tr.join(n).scrollIntoView()),!0}function pi(t,e){var n=t.selection,r=n.$from,o=n.$to,i=r.blockRange(o),s=i&&Mt(i);return null!=s&&(e&&e(t.tr.lift(i,s).scrollIntoView()),!0)}function hi(t,e){var n=t.selection,r=n.$head,o=n.$anchor;return!(!r.parent.type.spec.code||!r.sameParent(o))&&(e&&e(t.tr.insertText("\n").scrollIntoView()),!0)}function ui(t){for(var e=0;e<t.edgeCount;e++){var n=t.edge(e).type;if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function fi(t,e){var n=t.selection,r=n.$head,o=n.$anchor;if(!r.parent.type.spec.code||!r.sameParent(o))return!1;var i,s,a=r.node(-1),c=r.indexAfter(-1),l=ui(a.contentMatchAt(c));return!!a.canReplaceWith(c,c,l)&&(e&&(i=r.after(),(s=t.tr.replaceWith(i,i,l.createAndFill())).setSelection(Ht.near(s.doc.resolve(i),1)),e(s.scrollIntoView())),!0)}function di(t,e){var n=t.selection,r=n.$from,o=n.$to;if(r.parent.inlineContent||o.parent.inlineContent)return!1;var i,s,a=ui(r.parent.contentMatchAt(o.indexAfter()));return!(!a||!a.isTextblock)&&(e&&(i=(!r.parentOffset&&o.index()<o.parent.childCount?r:o).pos,(s=t.tr.insert(i,a.createAndFill())).setSelection(Qt.create(s.doc,i+1)),e(s.scrollIntoView())),!0)}function mi(t,e){var n=t.selection.$cursor;if(!n||n.parent.content.size)return!1;if(1<n.depth&&n.after()!=n.end(-1)){var r=n.before();if(Nt(t.doc,r))return e&&e(t.tr.split(r).scrollIntoView()),!0}var o=n.blockRange(),i=o&&Mt(o);return null!=i&&(e&&e(t.tr.lift(o,i).scrollIntoView()),!0)}function vi(t,e){var n,r,o,i,s,a=t.selection,c=a.$from,l=a.$to;return t.selection instanceof Yt&&t.selection.node.isBlock?!(!c.parentOffset||!Nt(t.doc,c.pos))&&(e&&e(t.tr.split(c.pos).scrollIntoView()),!0):!!c.parent.isBlock&&(e&&(n=l.parentOffset==l.parent.content.size,r=t.tr,t.selection instanceof Qt&&r.deleteSelection(),o=0==c.depth?null:ui(c.node(-1).contentMatchAt(c.indexAfter(-1))),i=n&&o?[{type:o}]:null,s=Nt(r.doc,r.mapping.map(c.pos),1,i),i||s||!Nt(r.doc,r.mapping.map(c.pos),1,o&&[{type:o}])||(i=[{type:o}],s=!0),s&&(r.split(r.mapping.map(c.pos),1,i),n||c.parentOffset||c.parent.type==o||!c.node(-1).canReplace(c.index(-1),c.indexAfter(-1),I.from([o.create(),c.parent]))||r.setNodeMarkup(r.mapping.map(c.before()),o)),e(r.scrollIntoView())),!0)}function gi(t,e){var n,r=t.selection,o=r.$from,i=r.to,s=o.sharedDepth(i);return 0!=s&&(n=o.before(s),e&&e(t.tr.setSelection(Yt.create(t.doc,n))),!0)}function yi(t,e){return e&&e(t.tr.setSelection(new te(t.doc))),!0}function wi(t,e,n){var r,o,i=e.nodeBefore,s=e.nodeAfter;if(!i.type.spec.isolating&&!s.type.spec.isolating){if(function(t,e,n){var r=e.nodeBefore,o=e.nodeAfter,i=e.index();if(r&&o&&r.type.compatibleContent(o.type)){if(!r.content.size&&e.parent.canReplace(i-1,i))return n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),1;if(e.parent.canReplace(i,i+1)&&(o.isTextblock||Tt(t.doc,e.pos)))return n&&n(t.tr.clearIncompatible(e.pos,r.type,r.contentMatchAt(r.childCount)).join(e.pos).scrollIntoView()),1}}(t,e,n))return 1;var a=e.parent.canReplace(e.index(),e.index()+1);if(a&&(r=(o=i.contentMatchAt(i.childCount)).findWrapping(s.type))&&o.matchType(r[0]||s.type).validEnd){if(n){for(var c=e.pos+s.nodeSize,l=I.empty,p=r.length-1;0<=p;p--)l=I.from(r[p].create(null,l));l=I.from(i.copy(l));var h=t.tr.step(new xt(e.pos-1,c,e.pos,c,new N(l,1,0),r.length,!0)),u=c+2*r.length;Tt(h.doc,u)&&h.join(u),n(h.scrollIntoView())}return 1}var f=Ht.findFrom(e,1),d=f&&f.$from.blockRange(f.$to),m=d&&Mt(d);if(null!=m&&m>=e.depth)return n&&n(t.tr.lift(d,m).scrollIntoView()),1;if(a&&s.isTextblock&&ni(i,"end")){for(var v=i,g=[];g.push(v),!v.isTextblock;)v=v.lastChild;if(v.canReplace(v.childCount,v.childCount,s.content)){if(n){for(var y=I.empty,w=g.length-1;0<=w;w--)y=I.from(g[w].copy(y));n(t.tr.step(new xt(e.pos-g.length,e.pos+s.nodeSize,e.pos+1,e.pos+s.nodeSize-1,new N(y,g.length,0),0,!0)).scrollIntoView())}return 1}}}}function bi(a,c){return function(t,e){var n=t.selection,r=n.$from,o=n.$to,i=r.blockRange(o),s=i&&Ct(i,a,c);return!!s&&(e&&e(t.tr.wrap(i,s).scrollIntoView()),!0)}}function ki(s,a){return function(o,t){var e=o.selection,n=e.from,r=e.to,i=!1;return o.doc.nodesBetween(n,r,function(t,e){return!i&&void(t.isTextblock&&!t.hasMarkup(s,a)&&(i=t.type==s||(r=(n=o.doc.resolve(e)).index(),n.parent.canReplaceWith(r,r+1,s))));var n,r}),!!i&&(t&&t(o.tr.setBlockType(n,r,s,a).scrollIntoView()),!0)}}function xi(x,S){return function(t,e){var n=t.selection,r=n.empty,o=n.$cursor,i=n.ranges;if(r&&!o||!function(i,s,a){for(var t=0;t<s.length;t++){var e=function(t){var e=s[t],n=e.$from,r=e.$to,o=0==n.depth&&i.type.allowsMarkType(a);if(i.nodesBetween(n.pos,r.pos,function(t){return!o&&void(o=t.inlineContent&&t.type.allowsMarkType(a))}),o)return{v:!0}}(t);if(e)return e.v}}(t.doc,i,x))return!1;if(e)if(o)x.isInSet(t.storedMarks||o.marks())?e(t.tr.removeStoredMark(x)):e(t.tr.addStoredMark(x.create(S)));else{for(var s=!1,a=t.tr,c=0;!s&&c<i.length;c++)var l=i[c],p=l.$from,h=l.$to,s=t.doc.rangeHasMark(p.pos,h.pos,x);for(var u=0;u<i.length;u++){var f,d,m,v,g,y,w=i[u],b=w.$from,k=w.$to;s?a.removeMark(b.pos,k.pos,x):(f=b.pos,d=k.pos,m=b.nodeAfter,v=k.nodeBefore,g=m&&m.isText?/^\s*/.exec(m.text)[0].length:0,y=v&&v.isText?/\s*$/.exec(v.text)[0].length:0,f+g<d&&(f+=g,d-=y),a.addMark(f,d,x.create(S)))}e(a.scrollIntoView())}return!0}}function Si(){for(var t=arguments,o=[],e=arguments.length;e--;)o[e]=t[e];return function(t,e,n){for(var r=0;r<o.length;r++)if(o[r](t,e,n))return!0;return!1}}var Mi=Si(ti,ei,ri),Ci=Si(ti,ii,si),Oi={Enter:Si(hi,di,mi,vi),"Mod-Enter":fi,Backspace:Mi,"Mod-Backspace":Mi,Delete:Ci,"Mod-Delete":Ci,"Mod-a":yi},Ni={"Ctrl-h":Oi.Backspace,"Alt-Backspace":Oi["Mod-Backspace"],"Ctrl-d":Oi.Delete,"Ctrl-Alt-Backspace":Oi["Mod-Delete"],"Alt-Delete":Oi["Mod-Delete"],"Alt-d":Oi["Mod-Delete"]};for(var Ti in Oi)Ni[Ti]=Oi[Ti];var Di=("undefined"!=typeof navigator?/Mac/.test(navigator.platform):"undefined"!=typeof os&&"darwin"==os.platform())?Ni:Oi,Ei=Object.freeze({__proto__:null,autoJoin:function(n,r){var e;return Array.isArray(r)&&(e=r,r=function(t){return-1<e.indexOf(t.type.name)}),function(t,e){return n(t,e&&(g=e,y=r,function(t){if(!t.isGeneric)return g(t);for(var o=[],e=0;e<t.mapping.maps.length;e++){for(var n=t.mapping.maps[e],r=0;r<o.length;r++)o[r]=n.map(o[r]);n.forEach(function(t,e,n,r){return o.push(n,r)})}for(var i=[],s=0;s<o.length;s+=2)for(var a=o[s],c=o[s+1],l=t.doc.resolve(a),p=l.sharedDepth(c),h=l.node(p),u=l.indexAfter(p),f=l.after(p+1);f<=c;++u){var d,m=h.maybeChild(u);if(!m)break;!u||-1!=i.indexOf(f)||(d=h.child(u-1)).type==m.type&&y(d,m)&&i.push(f),f+=m.nodeSize}i.sort(function(t,e){return t-e});for(var v=i.length-1;0<=v;v--)Tt(t.doc,i[v])&&t.join(i[v]);g(t)}));var g,y}},baseKeymap:Di,chainCommands:Si,createParagraphNear:di,deleteSelection:ti,exitCode:fi,joinBackward:ei,joinDown:li,joinForward:ii,joinUp:ci,lift:pi,liftEmptyBlock:mi,macBaseKeymap:Ni,newlineInCode:hi,pcBaseKeymap:Oi,selectAll:yi,selectNodeBackward:ri,selectNodeForward:si,selectParentNode:gi,setBlockType:ki,splitBlock:vi,splitBlockKeepMarks:function(n,r){return vi(n,r&&function(t){var e=n.storedMarks||n.selection.$to.parentOffset&&n.selection.$from.marks();e&&t.ensureMarks(e),r(t)})},toggleMark:xi,wrapIn:bi}),Ai=["p",0],Ii=["blockquote",0],Ri=["hr"],zi=["pre",["code",0]],Pi=["br"],_i={doc:{content:"block+"},paragraph:{content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM:function(){return Ai}},blockquote:{content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM:function(){return Ii}},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM:function(){return Ri}},heading:{attrs:{level:{default:1}},content:"inline*",group:"block",defining:!0,parseDOM:[{tag:"h1",attrs:{level:1}},{tag:"h2",attrs:{level:2}},{tag:"h3",attrs:{level:3}},{tag:"h4",attrs:{level:4}},{tag:"h5",attrs:{level:5}},{tag:"h6",attrs:{level:6}}],toDOM:function(t){return["h"+t.attrs.level,0]}},code_block:{content:"text*",marks:"",group:"block",code:!0,defining:!0,parseDOM:[{tag:"pre",preserveWhitespace:"full"}],toDOM:function(){return zi}},text:{group:"inline"},image:{inline:!0,attrs:{src:{},alt:{default:null},title:{default:null}},group:"inline",draggable:!0,parseDOM:[{tag:"img[src]",getAttrs:function(t){return{src:t.getAttribute("src"),title:t.getAttribute("title"),alt:t.getAttribute("alt")}}}],toDOM:function(t){var e=t.attrs;return["img",{src:e.src,alt:e.alt,title:e.title}]}},hard_break:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:"br"}],toDOM:function(){return Pi}}},Bi=["em",0],Vi=["strong",0],$i=["code",0],Fi={link:{attrs:{href:{},title:{default:null}},inclusive:!1,parseDOM:[{tag:"a[href]",getAttrs:function(t){return{href:t.getAttribute("href"),title:t.getAttribute("title")}}}],toDOM:function(t){var e=t.attrs;return["a",{href:e.href,title:e.title},0]}},em:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style=italic"}],toDOM:function(){return Bi}},strong:{parseDOM:[{tag:"strong"},{tag:"b",getAttrs:function(t){return"normal"!=t.style.fontWeight&&null}},{style:"font-weight",getAttrs:function(t){return/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}}],toDOM:function(){return Vi}},code:{parseDOM:[{tag:"code"}],toDOM:function(){return $i}}},qi=new U({nodes:_i,marks:Fi}),Li=Object.freeze({__proto__:null,marks:Fi,nodes:_i,schema:qi}),ji=["ol",0],Ji=["ul",0],Wi=["li",0],Ki={attrs:{order:{default:1}},parseDOM:[{tag:"ol",getAttrs:function(t){return{order:t.hasAttribute("start")?+t.getAttribute("start"):1}}}],toDOM:function(t){return 1==t.attrs.order?ji:["ol",{start:t.attrs.order},0]}},Hi={parseDOM:[{tag:"ul"}],toDOM:function(){return Ji}},Ui={parseDOM:[{tag:"li"}],toDOM:function(){return Wi},defining:!0};function Gi(t,e){var n={};for(var r in t)n[r]=t[r];for(var o in e)n[o]=e[o];return n}function Qi(p,h){return function(t,e){var n=t.selection,r=n.$from,o=n.$to,i=r.blockRange(o),s=!1,a=i;if(!i)return!1;if(2<=i.depth&&r.node(i.depth-1).type.compatibleContent(p)&&0==i.startIndex){if(0==r.index(i.depth-1))return!1;var c=t.doc.resolve(i.start-2),a=new S(c,c,i.depth);i.endIndex<i.parent.childCount&&(i=new S(r,t.doc.resolve(o.end(i.depth)),i.depth)),s=!0}var l=Ct(a,p,h,i);return!!l&&(e&&e(function(t,e,n,r,o){for(var i=I.empty,s=n.length-1;0<=s;s--)i=I.from(n[s].type.create(n[s].attrs,i));t.step(new xt(e.start-(r?2:0),e.end,e.start,e.end,new N(i,0,0),n.length,!0));for(var a=0,c=0;c<n.length;c++)n[c].type==o&&(a=c+1);for(var l=n.length-a,p=e.start+n.length-(r?2:0),h=e.parent,u=e.startIndex,f=e.endIndex,d=!0;u<f;u++,d=!1)!d&&Nt(t.doc,p,l)&&(t.split(p,l),p+=2*l),p+=h.child(u).nodeSize;return t}(t.tr,i,l,s,p).scrollIntoView()),!0)}}function Xi(d){return function(t,e){var n=t.selection,r=n.$from,o=n.$to,i=n.node;if(i&&i.isBlock||r.depth<2||!r.sameParent(o))return!1;var s=r.node(-1);if(s.type!=d)return!1;if(0==r.parent.content.size&&r.node(-1).childCount==r.indexAfter(-1)){if(2==r.depth||r.node(-3).type!=d||r.index(-2)!=r.node(-2).childCount-1)return!1;if(e){for(var a=I.empty,c=0<r.index(-1),l=r.depth-(c?1:2);l>=r.depth-3;l--)a=I.from(r.node(l).copy(a));a=a.append(I.from(d.createAndFill()));var p=t.tr.replace(r.before(c?null:-1),r.after(-3),new N(a,c?3:2,2));p.setSelection(t.selection.constructor.near(p.doc.resolve(r.pos+(c?3:2)))),e(p.scrollIntoView())}return!0}var h=o.pos==r.end()?s.contentMatchAt(0).defaultType:null,u=t.tr.delete(r.pos,o.pos),f=h&&[null,{type:h}];return!!Nt(u.doc,r.pos,2,f)&&(e&&e(u.split(r.pos,2,f).scrollIntoView()),!0)}}function Yi(s){return function(t,e){var n=t.selection,r=n.$from,o=n.$to,i=r.blockRange(o,function(t){return t.childCount&&t.firstChild.type==s});return!!i&&(!e||(r.node(i.depth-1).type==s?function(t,e,n,r){var o=t.tr,i=r.end,s=r.$to.end(r.depth);i<s&&(o.step(new xt(i-1,s,i,s,new N(I.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new S(o.doc.resolve(r.$from.pos),o.doc.resolve(s),r.depth));return e(o.lift(r,Mt(r)).scrollIntoView()),!0}(t,e,s,i):function(t,e,n){for(var r=t.tr,o=n.parent,i=n.end,s=n.endIndex-1,a=n.startIndex;a<s;s--)i-=o.child(s).nodeSize,r.delete(i-1,i+1);var c=r.doc.resolve(n.start),l=c.nodeAfter,p=0==n.startIndex,h=n.endIndex==o.childCount,u=c.node(-1),f=c.index(-1);if(!u.canReplace(f+(p?0:1),f+1,l.content.append(h?I.empty:I.from(o))))return!1;var d=c.pos,m=d+l.nodeSize;return r.step(new xt(d-(p?1:0),m+(h?1:0),d+1,m-1,new N((p?I.empty:I.from(o.copy(I.empty))).append(h?I.empty:I.from(o.copy(I.empty))),p?0:1,h?0:1),p?0:1)),e(r.scrollIntoView()),!0}(t,e,i)))}}function Zi(d){return function(t,e){var n=t.selection,r=n.$from,o=n.$to,i=r.blockRange(o,function(t){return t.childCount&&t.firstChild.type==d});if(!i)return!1;var s=i.startIndex;if(0==s)return!1;var a,c,l,p,h,u=i.parent,f=u.child(s-1);return f.type==d&&(e&&(a=f.lastChild&&f.lastChild.type==u.type,c=I.from(a?d.create():null),l=new N(I.from(d.create(null,I.from(u.type.create(null,c)))),a?3:1,0),p=i.start,h=i.end,e(t.tr.step(new xt(p-(a?3:1),h,p,h,l,1,!0)).scrollIntoView())),!0)}}var ts=Object.freeze({__proto__:null,addListNodes:function(t,e,n){return t.append({ordered_list:Gi(Ki,{content:"list_item+",group:n}),bullet_list:Gi(Hi,{content:"list_item+",group:n}),list_item:Gi(Ui,{content:e})})},bulletList:Hi,liftListItem:Yi,listItem:Ui,orderedList:Ki,sinkListItem:Zi,splitListItem:Xi,wrapInList:Qi});function es(e){return void 0===e&&(e={}),new ue({view:function(t){return new ns(t,e)}})}var ns=function(n,t){var r=this;this.editorView=n,this.width=t.width||1,this.color=t.color||"black",this.class=t.class,this.cursorPos=null,this.element=null,this.timeout=null,this.handlers=["dragover","dragend","drop","dragleave"].map(function(e){function t(t){return r[e](t)}return n.dom.addEventListener(e,t),{name:e,handler:t}})};ns.prototype.destroy=function(){var r=this;this.handlers.forEach(function(t){var e=t.name,n=t.handler;return r.editorView.dom.removeEventListener(e,n)})},ns.prototype.update=function(t,e){null!=this.cursorPos&&e.doc!=t.state.doc&&this.updateOverlay()},ns.prototype.setCursor=function(t){t!=this.cursorPos&&(null==(this.cursorPos=t)?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())},ns.prototype.updateOverlay=function(){var t,e,n,r,o,i,s=this.editorView.state.doc.resolve(this.cursorPos);s.parent.inlineContent||(t=s.nodeBefore,e=s.nodeAfter,(t||e)&&(n=this.editorView.nodeDOM(this.cursorPos-(t?t.nodeSize:0)).getBoundingClientRect(),r=t?n.bottom:n.top,t&&e&&(r=(r+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2),i={left:n.left,right:n.right,top:r-this.width/2,bottom:r+this.width/2})),i||(i={left:(o=this.editorView.coordsAtPos(this.cursorPos)).left-this.width/2,right:o.left+this.width/2,top:o.top,bottom:o.bottom});var a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none; background-color: "+this.color);var c=!a||a==document.body&&"static"==getComputedStyle(a).position?{left:-pageXOffset,top:-pageYOffset}:a.getBoundingClientRect();this.element.style.left=i.left-c.left+"px",this.element.style.top=i.top-c.top+"px",this.element.style.width=i.right-i.left+"px",this.element.style.height=i.bottom-i.top+"px"},ns.prototype.scheduleRemoval=function(t){var e=this;clearTimeout(this.timeout),this.timeout=setTimeout(function(){return e.setCursor(null)},t)},ns.prototype.dragover=function(t){var e,n;!this.editorView.editable||(e=this.editorView.posAtCoords({left:t.clientX,top:t.clientY}))&&(n=e.pos,this.editorView.dragging&&this.editorView.dragging.slice&&null==(n=It(this.editorView.state.doc,n,this.editorView.dragging.slice))&&(n=e.pos),this.setCursor(n),this.scheduleRemoval(5e3))},ns.prototype.dragend=function(){this.scheduleRemoval(20)},ns.prototype.drop=function(){this.scheduleRemoval(20)},ns.prototype.dragleave=function(t){t.target!=this.editorView.dom&&this.editorView.dom.contains(t.relatedTarget)||this.setCursor(null)};var rs=Object.freeze({__proto__:null,dropCursor:es}),is=function(r){function p(t){r.call(this,t,t)}return r&&(p.__proto__=r),((p.prototype=Object.create(r&&r.prototype)).constructor=p).prototype.map=function(t,e){var n=t.resolve(e.map(this.head));return p.valid(n)?new p(n):r.near(n)},p.prototype.content=function(){return N.empty},p.prototype.eq=function(t){return t instanceof p&&t.head==this.head},p.prototype.toJSON=function(){return{type:"gapcursor",pos:this.head}},p.fromJSON=function(t,e){if("number"!=typeof e.pos)throw new RangeError("Invalid input for GapCursor.fromJSON");return new p(t.resolve(e.pos))},p.prototype.getBookmark=function(){return new ss(this.anchor)},p.valid=function(t){var e=t.parent;if(e.isTextblock||!function(t){for(var e=t.depth;0<=e;e--){var n=t.index(e);if(0!=n)for(var r=t.node(e).child(n-1);;r=r.lastChild){if(0==r.childCount&&!r.inlineContent||r.isAtom||r.type.spec.isolating)return!0;if(r.inlineContent)return!1}}return!0}(t)||!function(t){for(var e=t.depth;0<=e;e--){var n=t.indexAfter(e),r=t.node(e);if(n!=r.childCount)for(var o=r.child(n);;o=o.firstChild){if(0==o.childCount&&!o.inlineContent||o.isAtom||o.type.spec.isolating)return!0;if(o.inlineContent)return!1}}return!0}(t))return!1;var n=e.type.spec.allowGapCursor;if(null!=n)return n;var r=e.contentMatchAt(t.index()).defaultType;return r&&r.isTextblock},p.findFrom=function(t,e,n){t:for(;;){if(!n&&p.valid(t))return t;for(var r=t.pos,o=null,i=t.depth;;i--){var s=t.node(i);if(0<e?t.indexAfter(i)<s.childCount:0<t.index(i)){o=s.child(0<e?t.indexAfter(i):t.index(i)-1);break}if(0==i)return null;r+=e;var a=t.doc.resolve(r);if(p.valid(a))return a}for(;;){var c=0<e?o.firstChild:o.lastChild;if(!c){if(!o.isAtom||o.isText||Yt.isSelectable(o))break;t=t.doc.resolve(r+o.nodeSize*e),n=!1;continue t}o=c,r+=e;var l=t.doc.resolve(r);if(p.valid(l))return l}return null}},p}(Ht);is.prototype.visible=!1,Ht.jsonID("gapcursor",is);var ss=function(t){this.pos=t};ss.prototype.map=function(t){return new ss(t.map(this.pos))},ss.prototype.resolve=function(t){var e=t.resolve(this.pos);return is.valid(e)?new is(e):Ht.near(e)};function as(){return new ue({props:{decorations:hs,createSelectionBetween:function(t,e,n){if(e.pos==n.pos&&is.valid(n))return new is(n)},handleClick:ps,handleKeyDown:cs}})}var cs=vo({ArrowLeft:ls("horiz",-1),ArrowRight:ls("horiz",1),ArrowUp:ls("vert",-1),ArrowDown:ls("vert",1)});function ls(t,a){var c="vert"==t?0<a?"down":"up":0<a?"right":"left";return function(t,e,n){var r=t.selection,o=0<a?r.$to:r.$from,i=r.empty;if(r instanceof Qt){if(!n.endOfTextblock(c)||0==o.depth)return!1;i=!1,o=t.doc.resolve(0<a?o.after():o.before())}var s=is.findFrom(o,a,i);return!!s&&(e&&e(t.tr.setSelection(new is(s))),!0)}}function ps(t,e,n){if(!t.editable)return!1;var r=t.state.doc.resolve(e);if(!is.valid(r))return!1;var o=t.posAtCoords({left:n.clientX,top:n.clientY}).inside;return!(-1<o&&Yt.isSelectable(t.state.doc.nodeAt(o)))&&(t.dispatch(t.state.tr.setSelection(new is(r))),!0)}function hs(t){if(!(t.selection instanceof is))return null;var e=document.createElement("div");return e.className="ProseMirror-gapcursor",Br.create(t.doc,[Rr.widget(t.selection.head,e,{key:"gapcursor"})])}var us=Object.freeze({__proto__:null,GapCursor:is,gapCursor:as});function fs(t,e){var n=arguments,r=t;"string"==typeof r&&(r=document.createElement(r));var o,i=1,s=e;if(s&&"object"==typeof s&&null==s.nodeType&&!Array.isArray(s)){for(var a in s){Object.prototype.hasOwnProperty.call(s,a)&&("string"==typeof(o=s[a])?r.setAttribute(a,o):null!=o&&(r[a]=o))}i++}for(;i<arguments.length;i++)!function t(e,n){if("string"==typeof n)e.appendChild(document.createTextNode(n));else if(null!=n)if(null!=n.nodeType)e.appendChild(n);else{if(!Array.isArray(n))throw new RangeError("Unsupported child node: "+n);for(var r=0;r<n.length;r++)t(e,n[r])}}(r,n[i]);return r}var ds="http://www.w3.org/2000/svg",ms="ProseMirror-icon";function vs(t){var e,n,r=document.createElement("div");return r.className=ms,t.path?(e="pm-icon-"+function(t){for(var e=0,n=0;n<t.length;n++)e=(e<<5)-e+t.charCodeAt(n)|0;return e}(t.path).toString(16),document.getElementById(e)||function(t,e){var n=document.getElementById(ms+"-collection");n||((n=document.createElementNS(ds,"svg")).id=ms+"-collection",n.style.display="none",document.body.insertBefore(n,document.body.firstChild));var r=document.createElementNS(ds,"symbol");r.id=t,r.setAttribute("viewBox","0 0 "+e.width+" "+e.height),r.appendChild(document.createElementNS(ds,"path")).setAttribute("d",e.path),n.appendChild(r)}(e,t),(n=r.appendChild(document.createElementNS(ds,"svg"))).style.width=t.width/t.height+"em",n.appendChild(document.createElementNS(ds,"use")).setAttributeNS("http://www.w3.org/1999/xlink","href",/([^#]*)/.exec(document.location)[1]+"#"+e)):t.dom?r.appendChild(t.dom.cloneNode(!0)):(r.appendChild(document.createElement("span")).textContent=t.text||"",t.css&&(r.firstChild.style.cssText=t.css)),r}var gs="ProseMirror-menu",ys=function(t){this.spec=t};function ws(t,e){return t._props.translate?t._props.translate(e):e}ys.prototype.render=function(e){var t,o=this.spec,i=o.render?o.render(e):o.icon?vs(o.icon):o.label?fs("div",null,ws(e,o.label)):null;if(!i)throw new RangeError("MenuItem without icon or label property");return o.title&&(t="function"==typeof o.title?o.title(e.state):o.title,i.setAttribute("title",ws(e,t))),o.class&&i.classList.add(o.class),o.css&&(i.style.cssText+=o.css),i.addEventListener("mousedown",function(t){t.preventDefault(),i.classList.contains(gs+"-disabled")||o.run(e.state,e.dispatch,e,t)}),{dom:i,update:function(t){if(o.select){var e=o.select(t);if(i.style.display=e?"":"none",!e)return!1}var n,r=!0;return o.enable&&(r=o.enable(t)||!1,_s(i,gs+"-disabled",!r)),o.active&&(n=r&&o.active(t)||!1,_s(i,gs+"-active",n)),!0}}};var bs={time:0,node:null};function ks(t){bs.time=Date.now(),bs.node=t.target}function xs(t){return Date.now()-100<bs.time&&bs.node&&t.contains(bs.node)}var Ss=function(t,e){this.options=e||{},this.content=Array.isArray(t)?t:[t]};function Ms(t,e){for(var n=[],r=[],o=0;o<t.length;o++){var i=t[o].render(e),s=i.dom,a=i.update;n.push(fs("div",{class:gs+"-dropdown-item"},s)),r.push(a)}return{dom:n,update:Cs(r,n)}}function Cs(o,i){return function(t){for(var e=!1,n=0;n<o.length;n++){var r=o[n](t);i[n].style.display=r?"":"none",r&&(e=!0)}return e}}Ss.prototype.render=function(t){var e=this,n=Ms(this.content,t),r=fs("div",{class:gs+"-dropdown "+(this.options.class||""),style:this.options.css},ws(t,this.options.label));this.options.title&&r.setAttribute("title",ws(t,this.options.title));function o(){s&&s.close()&&(s=null,window.removeEventListener("mousedown",a))}var i=fs("div",{class:gs+"-dropdown-wrap"},r),s=null,a=null;return r.addEventListener("mousedown",function(t){t.preventDefault(),ks(t),s?o():(s=e.expand(i,n.dom),window.addEventListener("mousedown",a=function(){xs(i)||o()}))}),{dom:i,update:function(t){var e=n.update(t);return i.style.display=e?"":"none",e}}},Ss.prototype.expand=function(t,e){var n=fs("div",{class:gs+"-dropdown-menu "+(this.options.class||"")},e),r=!1;return t.appendChild(n),{close:function(){if(!r)return r=!0,t.removeChild(n),!0},node:n}};var Os=function(t,e){this.options=e||{},this.content=Array.isArray(t)?t:[t]};function Ns(t,e){for(var n=document.createDocumentFragment(),i=[],s=[],r=0;r<e.length;r++){for(var o=e[r],a=[],c=[],l=0;l<o.length;l++){var p=o[l].render(t),h=p.dom,u=p.update,f=fs("span",{class:gs+"item"},h);n.appendChild(f),c.push(f),a.push(u)}a.length&&(i.push(Cs(a,c)),r<e.length-1&&s.push(n.appendChild(fs("span",{class:gs+"separator"}))))}return{dom:n,update:function(t){for(var e=!1,n=!1,r=0;r<i.length;r++){var o=i[r](t);r&&(s[r-1].style.display=n&&o?"":"none"),(n=o)&&(e=!0)}return e}}}Os.prototype.render=function(t){var n=Ms(this.content,t),e=fs("div",{class:gs+"-submenu-label"},ws(t,this.options.label)),r=fs("div",{class:gs+"-submenu-wrap"},e,fs("div",{class:gs+"-submenu"},n.dom)),o=null;return e.addEventListener("mousedown",function(t){t.preventDefault(),ks(t),_s(r,gs+"-submenu-wrap-active"),o||window.addEventListener("mousedown",o=function(){xs(r)||(r.classList.remove(gs+"-submenu-wrap-active"),window.removeEventListener("mousedown",o),o=null)})}),{dom:r,update:function(t){var e=n.update(t);return r.style.display=e?"":"none",e}}};var Ts={join:{width:800,height:900,path:"M0 75h800v125h-800z M0 825h800v-125h-800z M250 400h100v-100h100v100h100v100h-100v100h-100v-100h-100z"},lift:{width:1024,height:1024,path:"M219 310v329q0 7-5 12t-12 5q-8 0-13-5l-164-164q-5-5-5-13t5-13l164-164q5-5 13-5 7 0 12 5t5 12zM1024 749v109q0 7-5 12t-12 5h-987q-7 0-12-5t-5-12v-109q0-7 5-12t12-5h987q7 0 12 5t5 12zM1024 530v109q0 7-5 12t-12 5h-621q-7 0-12-5t-5-12v-109q0-7 5-12t12-5h621q7 0 12 5t5 12zM1024 310v109q0 7-5 12t-12 5h-621q-7 0-12-5t-5-12v-109q0-7 5-12t12-5h621q7 0 12 5t5 12zM1024 91v109q0 7-5 12t-12 5h-987q-7 0-12-5t-5-12v-109q0-7 5-12t12-5h987q7 0 12 5t5 12z"},selectParentNode:{text:"⬚",css:"font-weight: bold"},undo:{width:1024,height:1024,path:"M761 1024c113-206 132-520-313-509v253l-384-384 384-384v248c534-13 594 472 313 775z"},redo:{width:1024,height:1024,path:"M576 248v-248l384 384-384 384v-253c-446-10-427 303-313 509-280-303-221-789 313-775z"},strong:{width:805,height:1024,path:"M317 869q42 18 80 18 214 0 214-191 0-65-23-102-15-25-35-42t-38-26-46-14-48-6-54-1q-41 0-57 5 0 30-0 90t-0 90q0 4-0 38t-0 55 2 47 6 38zM309 442q24 4 62 4 46 0 81-7t62-25 42-51 14-81q0-40-16-70t-45-46-61-24-70-8q-28 0-74 7 0 28 2 86t2 86q0 15-0 45t-0 45q0 26 0 39zM0 950l1-53q8-2 48-9t60-15q4-6 7-15t4-19 3-18 1-21 0-19v-37q0-561-12-585-2-4-12-8t-25-6-28-4-27-2-17-1l-2-47q56-1 194-6t213-5q13 0 39 0t38 0q40 0 78 7t73 24 61 40 42 59 16 78q0 29-9 54t-22 41-36 32-41 25-48 22q88 20 146 76t58 141q0 57-20 102t-53 74-78 48-93 27-100 8q-25 0-75-1t-75-1q-60 0-175 6t-132 6z"},em:{width:585,height:1024,path:"M0 949l9-48q3-1 46-12t63-21q16-20 23-57 0-4 35-165t65-310 29-169v-14q-13-7-31-10t-39-4-33-3l10-58q18 1 68 3t85 4 68 1q27 0 56-1t69-4 56-3q-2 22-10 50-17 5-58 16t-62 19q-4 10-8 24t-5 22-4 26-3 24q-15 84-50 239t-44 203q-1 5-7 33t-11 51-9 47-3 32l0 10q9 2 105 17-1 25-9 56-6 0-18 0t-18 0q-16 0-49-5t-49-5q-78-1-117-1-29 0-81 5t-69 6z"},code:{width:896,height:1024,path:"M608 192l-96 96 224 224-224 224 96 96 288-320-288-320zM288 192l-288 320 288 320 96-96-224-224 224-224-96-96z"},link:{width:951,height:1024,path:"M832 694q0-22-16-38l-118-118q-16-16-38-16-24 0-41 18 1 1 10 10t12 12 8 10 7 14 2 15q0 22-16 38t-38 16q-8 0-15-2t-14-7-10-8-12-12-10-10q-18 17-18 41 0 22 16 38l117 118q15 15 38 15 22 0 38-14l84-83q16-16 16-38zM430 292q0-22-16-38l-117-118q-16-16-38-16-22 0-38 15l-84 83q-16 16-16 38 0 22 16 38l118 118q15 15 38 15 24 0 41-17-1-1-10-10t-12-12-8-10-7-14-2-15q0-22 16-38t38-16q8 0 15 2t14 7 10 8 12 12 10 10q18-17 18-41zM941 694q0 68-48 116l-84 83q-47 47-116 47-69 0-116-48l-117-118q-47-47-47-116 0-70 50-119l-50-50q-49 50-118 50-68 0-116-48l-118-118q-48-48-48-116t48-116l84-83q47-47 116-47 69 0 116 48l117 118q47 47 47 116 0 70-50 119l50 50q49-50 118-50 68 0 116 48l118 118q48 48 48 116z"},bulletList:{width:768,height:896,path:"M0 512h128v-128h-128v128zM0 256h128v-128h-128v128zM0 768h128v-128h-128v128zM256 512h512v-128h-512v128zM256 256h512v-128h-512v128zM256 768h512v-128h-512v128z"},orderedList:{width:768,height:896,path:"M320 512h448v-128h-448v128zM320 768h448v-128h-448v128zM320 128v128h448v-128h-448zM79 384h78v-256h-36l-85 23v50l43-2v185zM189 590c0-36-12-78-96-78-33 0-64 6-83 16l1 66c21-10 42-15 67-15s32 11 32 28c0 26-30 58-110 112v50h192v-67l-91 2c49-30 87-66 87-113l1-1z"},blockquote:{width:640,height:896,path:"M0 448v256h256v-256h-128c0 0 0-128 128-128v-128c0 0-256 0-256 256zM640 320v-128c0 0-256 0-256 256v256h256v-256h-128c0 0 0-128 128-128z"}},Ds=new ys({title:"Join with above block",run:ci,select:function(t){return ci(t)},icon:Ts.join}),Es=new ys({title:"Lift out of enclosing block",run:pi,select:function(t){return pi(t)},icon:Ts.lift}),As=new ys({title:"Select parent node",run:gi,select:function(t){return gi(t)},icon:Ts.selectParentNode}),Is=new ys({title:"Undo last change",run:Xo,enable:function(t){return Xo(t)},icon:Ts.undo}),Rs=new ys({title:"Redo last undone change",run:Yo,enable:function(t){return Yo(t)},icon:Ts.redo});function zs(n,r){var t={run:function(t,e){return bi(n,r.attrs)(t,e)},select:function(t){return bi(n,r.attrs instanceof Function?null:r.attrs)(t)}};for(var e in r)t[e]=r[e];return new ys(t)}function Ps(i,s){var e=ki(i,s.attrs),t={run:e,enable:function(t){return e(t)},active:function(t){var e=t.selection,n=e.$from,r=e.to,o=e.node;return o?o.hasMarkup(i,s.attrs):r<=n.end()&&n.parent.hasMarkup(i,s.attrs)}};for(var n in s)t[n]=s[n];return new ys(t)}function _s(t,e,n){n?t.classList.add(e):t.classList.remove(e)}var Bs="ProseMirror-menubar";function Vs(e){return new ue({view:function(t){return new $s(t,e)}})}var $s=function(t,e){var n=this;this.editorView=t,this.options=e,this.wrapper=fs("div",{class:Bs+"-wrapper"}),this.menu=this.wrapper.appendChild(fs("div",{class:Bs})),this.menu.className=Bs,this.spacer=null,t.dom.parentNode.replaceChild(this.wrapper,t.dom),this.wrapper.appendChild(t.dom),this.maxHeight=0,this.widthForMaxHeight=0,this.floating=!1;var r,o=Ns(this.editorView,this.options.content),i=o.dom,s=o.update;this.contentUpdate=s,this.menu.appendChild(i),this.update(),e.floating&&!function(){if("undefined"!=typeof navigator){var t=navigator.userAgent;return!/Edge\/\d/.test(t)&&/AppleWebKit/.test(t)&&/Mobile\/\w+/.test(t)}}()&&(this.updateFloat(),r=function(t){for(var e=[window],n=t.parentNode;n;n=n.parentNode)e.push(n);return e}(this.wrapper),this.scrollFunc=function(t){var e=n.editorView.root;(e.body||e).contains(n.wrapper)?n.updateFloat(t.target.getBoundingClientRect&&t.target):r.forEach(function(t){return t.removeEventListener("scroll",n.scrollFunc)})},r.forEach(function(t){return t.addEventListener("scroll",n.scrollFunc)}))};$s.prototype.update=function(){this.contentUpdate(this.editorView.state),this.floating?this.updateScrollCursor():(this.menu.offsetWidth!=this.widthForMaxHeight&&(this.widthForMaxHeight=this.menu.offsetWidth,this.maxHeight=0),this.menu.offsetHeight>this.maxHeight&&(this.maxHeight=this.menu.offsetHeight,this.menu.style.minHeight=this.maxHeight+"px"))},$s.prototype.updateScrollCursor=function(){var t,e,n,r,o,i=this.editorView.root.getSelection();!i.focusNode||(e=(t=i.getRangeAt(0).getClientRects())[((n=i).anchorNode!=n.focusNode?n.anchorNode.compareDocumentPosition(n.focusNode)==Node.DOCUMENT_POSITION_FOLLOWING:n.anchorOffset>n.focusOffset)?0:t.length-1])&&(r=this.menu.getBoundingClientRect(),e.top<r.bottom&&e.bottom>r.top&&((o=function(t){for(var e=t.parentNode;e;e=e.parentNode)if(e.scrollHeight>e.clientHeight)return e}(this.wrapper))&&(o.scrollTop-=r.bottom-e.top)))},$s.prototype.updateFloat=function(t){var e,n,r=this.wrapper,o=r.getBoundingClientRect(),i=t?Math.max(0,t.getBoundingClientRect().top):0;this.floating?o.top>=i||o.bottom<this.menu.offsetHeight+10?(this.floating=!1,this.menu.style.position=this.menu.style.left=this.menu.style.top=this.menu.style.width="",this.menu.style.display="",this.spacer.parentNode.removeChild(this.spacer),this.spacer=null):(e=(r.offsetWidth-r.clientWidth)/2,this.menu.style.left=o.left+e+"px",this.menu.style.display=o.top>window.innerHeight?"none":"",t&&(this.menu.style.top=i+"px")):o.top<i&&o.bottom>=this.menu.offsetHeight+10&&(this.floating=!0,n=this.menu.getBoundingClientRect(),this.menu.style.left=n.left+"px",this.menu.style.width=n.width+"px",t&&(this.menu.style.top=i+"px"),this.menu.style.position="fixed",this.spacer=fs("div",{class:Bs+"-spacer",style:"height: "+n.height+"px"}),r.insertBefore(this.spacer,this.menu))},$s.prototype.destroy=function(){this.wrapper.parentNode&&this.wrapper.parentNode.replaceChild(this.editorView.dom,this.wrapper)};var Fs=Object.freeze({__proto__:null,Dropdown:Ss,DropdownSubmenu:Os,MenuItem:ys,blockTypeItem:Ps,icons:Ts,joinUpItem:Ds,liftItem:Es,menuBar:Vs,redoItem:Rs,renderGrouped:Ns,selectParentNodeItem:As,undoItem:Is,wrapItem:zs}),qs="ProseMirror-prompt";function Ls(e){var n=document.body.appendChild(document.createElement("div"));n.className=qs;function t(t){n.contains(t.target)||r()}setTimeout(function(){return window.addEventListener("mousedown",t)},50);var r=function(){window.removeEventListener("mousedown",t),n.parentNode&&n.parentNode.removeChild(n)},o=[];for(var i in e.fields)o.push(e.fields[i].render());var s=document.createElement("button");s.type="submit",s.className=qs+"-submit",s.textContent="OK";var a=document.createElement("button");a.type="button",a.className=qs+"-cancel",a.textContent="Cancel",a.addEventListener("click",r);var c=n.appendChild(document.createElement("form"));e.title&&(c.appendChild(document.createElement("h5")).textContent=e.title),o.forEach(function(t){c.appendChild(document.createElement("div")).appendChild(t)});var l=c.appendChild(document.createElement("div"));l.className=qs+"-buttons",l.appendChild(s),l.appendChild(document.createTextNode(" ")),l.appendChild(a);var p=n.getBoundingClientRect();n.style.top=(window.innerHeight-p.height)/2+"px",n.style.left=(window.innerWidth-p.width)/2+"px";function h(){var t=function(t,e){var n=Object.create(null),r=0;for(var o in t){var i=t[o],s=e[r++],a=i.read(s),c=i.validate(a);if(c)return function(t,e){var n=t.parentNode,r=n.appendChild(document.createElement("div"));r.style.left=t.offsetLeft+t.offsetWidth+2+"px",r.style.top=t.offsetTop-5+"px",r.className="ProseMirror-invalid",r.textContent=e,setTimeout(function(){return n.removeChild(r)},1500)}(s,c),null;n[o]=i.clean(a)}return n}(e.fields,o);t&&(r(),e.callback(t))}c.addEventListener("submit",function(t){t.preventDefault(),h()}),c.addEventListener("keydown",function(t){27==t.keyCode?(t.preventDefault(),r()):13!=t.keyCode||t.ctrlKey||t.metaKey||t.shiftKey?9==t.keyCode&&window.setTimeout(function(){n.contains(document.activeElement)||r()},500):(t.preventDefault(),h())});var u=c.elements[0];u&&u.focus()}function js(t){this.options=t}js.prototype.read=function(t){return t.value},js.prototype.validateType=function(){},js.prototype.validate=function(t){return!t&&this.options.required?"Required field":this.validateType(t)||this.options.validate&&this.options.validate(t)},js.prototype.clean=function(t){return this.options.clean?this.options.clean(t):t};var Js=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.render=function(){var t=document.createElement("input");return t.type="text",t.placeholder=this.options.label,t.value=this.options.value||"",t.autocomplete="off",t},e}(js);function Ws(t,e){for(var n=t.selection.$from,r=n.depth;0<=r;r--){var o=n.index(r);if(n.node(r).canReplaceWith(o,o,e))return!0}return!1}function Ks(e,t){var n={label:t.title,run:e};for(var r in t)n[r]=t[r];return t.enable&&!0!==t.enable||t.select||(n[t.enable?"enable":"select"]=function(t){return e(t)}),new ys(n)}function Hs(t,e){var n=t.selection,r=n.from,o=n.$from,i=n.to;return n.empty?e.isInSet(t.storedMarks||o.marks()):t.doc.rangeHasMark(r,i,e)}function Us(e,t){var n={active:function(t){return Hs(t,e)},enable:!0};for(var r in t)n[r]=t[r];return Ks(xi(e),n)}function Gs(t,e){return Ks(Qi(t,e.attrs),e)}function Qs(t){var e,r,a,n,o={};if((e=t.marks.strong)&&(o.toggleStrong=Us(e,{title:"Toggle strong style",icon:Ts.strong})),(e=t.marks.em)&&(o.toggleEm=Us(e,{title:"Toggle emphasis",icon:Ts.em})),(e=t.marks.code)&&(o.toggleCode=Us(e,{title:"Toggle code font",icon:Ts.code})),(e=t.marks.link)&&(o.toggleLink=(r=e,new ys({title:"Add or remove link",icon:Ts.link,active:function(t){return Hs(t,r)},enable:function(t){return!t.selection.empty},run:function(t,e,n){if(Hs(t,r))return xi(r)(t,e),!0;Ls({title:"Create a link",fields:{href:new Js({label:"Link target",required:!0}),title:new Js({label:"Title"})},callback:function(t){xi(r,t)(n.state,n.dispatch),n.focus()}})}}))),(e=t.nodes.image)&&(o.insertImage=(a=e,new ys({title:"Insert image",label:"Image",enable:function(t){return Ws(t,a)},run:function(t,e,n){var r=t.selection,o=r.from,i=r.to,s=null;t.selection instanceof Yt&&t.selection.node.type==a&&(s=t.selection.node.attrs),Ls({title:"Insert image",fields:{src:new Js({label:"Location",required:!0,value:s&&s.src}),title:new Js({label:"Title",value:s&&s.title}),alt:new Js({label:"Description",value:s?s.alt:t.doc.textBetween(o,i," ")})},callback:function(t){n.dispatch(n.state.tr.replaceSelectionWith(a.createAndFill(t))),n.focus()}})}}))),(e=t.nodes.bullet_list)&&(o.wrapBulletList=Gs(e,{title:"Wrap in bullet list",icon:Ts.bulletList})),(e=t.nodes.ordered_list)&&(o.wrapOrderedList=Gs(e,{title:"Wrap in ordered list",icon:Ts.orderedList})),(e=t.nodes.blockquote)&&(o.wrapBlockQuote=zs(e,{title:"Wrap in block quote",icon:Ts.blockquote})),(e=t.nodes.paragraph)&&(o.makeParagraph=Ps(e,{title:"Change to paragraph",label:"Plain"})),(e=t.nodes.code_block)&&(o.makeCodeBlock=Ps(e,{title:"Change to code block",label:"Code"})),e=t.nodes.heading)for(var i=1;i<=10;i++)o["makeHead"+i]=Ps(e,{title:"Change to heading "+i,label:"Level "+i,attrs:{level:i}});(e=t.nodes.horizontal_rule)&&(n=e,o.insertHorizontalRule=new ys({title:"Insert horizontal rule",label:"Horizontal rule",enable:function(t){return Ws(t,n)},run:function(t,e){e(t.tr.replaceSelectionWith(n.create()))}}));function s(t){return t.filter(function(t){return t})}return o.insertMenu=new Ss(s([o.insertImage,o.insertHorizontalRule]),{label:"Insert"}),o.typeMenu=new Ss(s([o.makeParagraph,o.makeCodeBlock,o.makeHead1&&new Os(s([o.makeHead1,o.makeHead2,o.makeHead3,o.makeHead4,o.makeHead5,o.makeHead6]),{label:"Heading"})]),{label:"Type..."}),o.inlineMenu=[s([o.toggleStrong,o.toggleEm,o.toggleCode,o.toggleLink])],o.blockMenu=[s([o.wrapBulletList,o.wrapOrderedList,o.wrapBlockQuote,Ds,Es,As])],o.fullMenu=o.inlineMenu.concat([[o.insertMenu,o.typeMenu]],[[Is,Rs]],o.blockMenu),o}var Xs="undefined"!=typeof navigator&&/Mac/.test(navigator.platform);function Ys(t,r){var e,n,o,i,s={};function a(t,e){if(r){var n=r[t];if(!1===n)return;n&&(t=n)}s[t]=e}if(a("Mod-z",Xo),a("Shift-Mod-z",Yo),a("Backspace",xo),Xs||a("Mod-y",Yo),a("Alt-ArrowUp",ci),a("Alt-ArrowDown",li),a("Mod-BracketLeft",pi),a("Escape",gi),(e=t.marks.strong)&&(a("Mod-b",xi(e)),a("Mod-B",xi(e))),(e=t.marks.em)&&(a("Mod-i",xi(e)),a("Mod-I",xi(e))),(e=t.marks.code)&&a("Mod-`",xi(e)),(e=t.nodes.bullet_list)&&a("Shift-Ctrl-8",Qi(e)),(e=t.nodes.ordered_list)&&a("Shift-Ctrl-9",Qi(e)),(e=t.nodes.blockquote)&&a("Ctrl->",bi(e)),(e=t.nodes.hard_break)&&(n=e,a("Mod-Enter",o=Si(fi,function(t,e){return e(t.tr.replaceSelectionWith(n.create()).scrollIntoView()),!0})),a("Shift-Enter",o),Xs&&a("Ctrl-Enter",o)),(e=t.nodes.list_item)&&(a("Enter",Xi(e)),a("Mod-[",Yi(e)),a("Mod-]",Zi(e))),(e=t.nodes.paragraph)&&a("Shift-Ctrl-0",ki(e)),(e=t.nodes.code_block)&&a("Shift-Ctrl-\\",ki(e)),e=t.nodes.heading)for(var c=1;c<=6;c++)a("Shift-Ctrl-"+c,ki(e,{level:c}));return(e=t.nodes.horizontal_rule)&&(i=e,a("Mod-_",function(t,e){return e(t.tr.replaceSelectionWith(i.create()).scrollIntoView()),!0})),s}function Zs(t){var e,n,r=Do.concat(Mo,So);return(e=t.nodes.blockquote)&&r.push(Eo(/^\s*>\s$/,e)),(e=t.nodes.ordered_list)&&r.push(Eo(/^(\d+)\.\s$/,e,function(t){return{order:+t[1]}},function(t,e){return e.childCount+e.attrs.order==+t[1]})),(e=t.nodes.bullet_list)&&r.push(Eo(/^\s*([-+*])\s$/,e)),(e=t.nodes.code_block)&&r.push(Ao(/^```$/,e)),(e=t.nodes.heading)&&r.push((n=e,Ao(new RegExp("^(#{1,"+6+"})\\s$"),n,function(t){return{level:t[1].length}}))),bo({rules:r})}var ta=Object.freeze({__proto__:null,buildInputRules:Zs,buildKeymap:Ys,buildMenuItems:Qs,exampleSetup:function(t){var e=[Zs(t.schema),mo(Ys(t.schema,t.mapKeys)),mo(Di),es(),as()];return!1!==t.menuBar&&e.push(Vs({floating:!1!==t.floatingMenu,content:t.menuContent||Qs(t.schema).fullMenu})),!1!==t.history&&e.push(Qo()),e.concat(new ue({props:{attributes:{class:"ProseMirror-example-setup-style"}}}))}});window.PM={model:ct,transform:Wt,state:ke,view:to,keymap:go,inputrules:Ro,history:Zo,commands:Ei,schema_basic:Li,schema_list:ts,dropcursor:rs,menu:Fs,example_setup:ta,gapcursor:us}}();
+