text: (()=>{"use strict";function t(t){this.content=t}t.prototype={constructor:t,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(e,n,r){var o=r&&r!=e?this.remove(r):this,i=o.find(e),s=o.content.slice();return-1==i?s.push(r||e,n):(s[i+1]=n,r&&(s[i]=r)),new t(s)},remove:function(e){var n=this.find(e);if(-1==n)return this;var r=this.content.slice();return r.splice(n,2),new t(r)},addToStart:function(e,n){return new t([e,n].concat(this.remove(e).content))},addToEnd:function(e,n){var r=this.remove(e).content.slice();return r.push(e,n),new t(r)},addBefore:function(e,n,r){var o=this.remove(n),i=o.content.slice(),s=o.find(e);return i.splice(-1==s?i.length:s,0,n,r),new t(i)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(e){return(e=t.from(e)).size?new t(e.content.concat(this.subtract(e).content)):this},append:function(e){return(e=t.from(e)).size?new t(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var n=this;e=t.from(e);for(var r=0;r<e.content.length;r+=2)n=n.remove(e.content[r]);return n},get size(){return this.content.length>>1}},t.from=function(e){if(e instanceof t)return e;var n=[];if(e)for(var r in e)n.push(r,e[r]);return new t(n)};const e=t;function n(t,e,r){for(var o=0;;o++){if(o==t.childCount||o==e.childCount)return t.childCount==e.childCount?null:r;var i=t.child(o),s=e.child(o);if(i!=s){if(!i.sameMarkup(s))return r;if(i.isText&&i.text!=s.text){for(var c=0;i.text[c]==s.text[c];c++)r++;return r}if(i.content.size||s.content.size){var a=n(i.content,s.content,r+1);if(null!=a)return a}r+=i.nodeSize}else r+=i.nodeSize}}function r(t,e,n,o){for(var i=t.childCount,s=e.childCount;;){if(0==i||0==s)return i==s?null:{a:n,b:o};var c=t.child(--i),a=e.child(--s),l=c.nodeSize;if(c!=a){if(!c.sameMarkup(a))return{a:n,b:o};if(c.isText&&c.text!=a.text){for(var h=0,u=Math.min(c.text.length,a.text.length);h<u&&c.text[c.text.length-h-1]==a.text[a.text.length-h-1];)h++,n--,o--;return{a:n,b:o}}if(c.content.size||a.content.size){var d=r(c.content,a.content,n-1,o-1);if(d)return d}n-=l,o-=l}else n-=l,o-=l}}var o=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},i={firstChild:{configurable:!0},lastChild:{configurable:!0},childCount:{configurable:!0}};o.prototype.nodesBetween=function(t,e,n,r,o){void 0===r&&(r=0);for(var i=0,s=0;s<e;i++){var c=this.content[i],a=s+c.nodeSize;if(a>t&&!1!==n(c,r+s,o,i)&&c.content.size){var l=s+1;c.nodesBetween(Math.max(0,t-l),Math.min(c.content.size,e-l),n,r+l)}s=a}},o.prototype.descendants=function(t){this.nodesBetween(0,this.size,t)},o.prototype.textBetween=function(t,e,n,r){var o="",i=!0;return this.nodesBetween(t,e,(function(s,c){s.isText?(o+=s.text.slice(Math.max(t,c)-c,e-c),i=!n):s.isLeaf&&r?(o+="function"==typeof r?r(s):r,i=!n):!i&&s.isBlock&&(o+=n,i=!0)}),0),o},o.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(),i=0;for(e.isText&&e.sameMarkup(n)&&(r[r.length-1]=e.withText(e.text+n.text),i=1);i<t.content.length;i++)r.push(t.content[i]);return new o(r,this.size+t.size)},o.prototype.cut=function(t,e){if(null==e&&(e=this.size),0==t&&e==this.size)return this;var n=[],r=0;if(e>t)for(var i=0,s=0;s<e;i++){var c=this.content[i],a=s+c.nodeSize;a>t&&((s<t||a>e)&&(c=c.isText?c.cut(Math.max(0,t-s),Math.min(c.text.length,e-s)):c.cut(Math.max(0,t-s-1),Math.min(c.content.size,e-s-1))),n.push(c),r+=c.nodeSize),s=a}return new o(n,r)},o.prototype.cutByIndex=function(t,e){return t==e?o.empty:0==t&&e==this.content.length?this:new o(this.content.slice(t,e))},o.prototype.replaceChild=function(t,e){var n=this.content[t];if(n==e)return this;var r=this.content.slice(),i=this.size+e.nodeSize-n.nodeSize;return r[t]=e,new o(r,i)},o.prototype.addToStart=function(t){return new o([t].concat(this.content),this.size+t.nodeSize)},o.prototype.addToEnd=function(t){return new o(this.content.concat(t),this.size+t.nodeSize)},o.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},i.firstChild.get=function(){return this.content.length?this.content[0]:null},i.lastChild.get=function(){return this.content.length?this.content[this.content.length-1]:null},i.childCount.get=function(){return this.content.length},o.prototype.child=function(t){var e=this.content[t];if(!e)throw new RangeError("Index "+t+" out of range for "+this);return e},o.prototype.maybeChild=function(t){return this.content[t]},o.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}},o.prototype.findDiffStart=function(t,e){return void 0===e&&(e=0),n(this,t,e)},o.prototype.findDiffEnd=function(t,e,n){return void 0===e&&(e=this.size),void 0===n&&(n=t.size),r(this,t,e,n)},o.prototype.findIndex=function(t,e){if(void 0===e&&(e=-1),0==t)return c(0,t);if(t==this.size)return c(this.content.length,t);if(t>this.size||t<0)throw new RangeError("Position "+t+" outside of fragment ("+this+")");for(var n=0,r=0;;n++){var o=r+this.child(n).nodeSize;if(o>=t)return o==t||e>0?c(n+1,o):c(n,r);r=o}},o.prototype.toString=function(){return"<"+this.toStringInner()+">"},o.prototype.toStringInner=function(){return this.content.join(", ")},o.prototype.toJSON=function(){return this.content.length?this.content.map((function(t){return t.toJSON()})):null},o.fromJSON=function(t,e){if(!e)return o.empty;if(!Array.isArray(e))throw new RangeError("Invalid input for Fragment.fromJSON");return new o(e.map(t.nodeFromJSON))},o.fromArray=function(t){if(!t.length)return o.empty;for(var e,n=0,r=0;r<t.length;r++){var i=t[r];n+=i.nodeSize,r&&i.isText&&t[r-1].sameMarkup(i)?(e||(e=t.slice(0,r)),e[e.length-1]=i.withText(e[e.length-1].text+i.text)):e&&e.push(i)}return new o(e||t,n)},o.from=function(t){if(!t)return o.empty;if(t instanceof o)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new o([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(o.prototype,i);var s={index:0,offset:0};function c(t,e){return s.index=t,s.offset=e,s}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}o.empty=new o([],0);var l=function(t,e){this.type=t,this.attrs=e};function h(t){var e=Error.call(this,t);return e.__proto__=h.prototype,e}l.prototype.addToSet=function(t){for(var e,n=!1,r=0;r<t.length;r++){var o=t[r];if(this.eq(o))return t;if(this.type.excludes(o.type))e||(e=t.slice(0,r));else{if(o.type.excludes(this.type))return t;!n&&o.type.rank>this.type.rank&&(e||(e=t.slice(0,r)),e.push(this),n=!0),e&&e.push(o)}}return e||(e=t.slice()),n||e.push(this),e},l.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},l.prototype.isInSet=function(t){for(var e=0;e<t.length;e++)if(this.eq(t[e]))return!0;return!1},l.prototype.eq=function(t){return this==t||this.type==t.type&&a(this.attrs,t.attrs)},l.prototype.toJSON=function(){var t={type:this.type.name};for(var e in this.attrs){t.attrs=this.attrs;break}return t},l.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)},l.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},l.setFrom=function(t){if(!t||0==t.length)return l.none;if(t instanceof l)return[t];var e=t.slice();return e.sort((function(t,e){return t.type.rank-e.type.rank})),e},l.none=[],h.prototype=Object.create(Error.prototype),h.prototype.constructor=h,h.prototype.name="ReplaceError";var u=function(t,e,n){this.content=t,this.openStart=e,this.openEnd=n},d={size:{configurable:!0}};function p(t,e,n){var r=t.findIndex(e),o=r.index,i=r.offset,s=t.maybeChild(o),c=t.findIndex(n),a=c.index,l=c.offset;if(i==e||s.isText){if(l!=n&&!t.child(a).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(o!=a)throw new RangeError("Removing non-flat range");return t.replaceChild(o,s.copy(p(s.content,e-i-1,n-i-1)))}function f(t,e,n,r){var o=t.findIndex(e),i=o.index,s=o.offset,c=t.maybeChild(i);if(s==e||c.isText)return r&&!r.canReplace(i,i,n)?null:t.cut(0,e).append(n).append(t.cut(e));var a=f(c.content,e-s-1,n);return a&&t.replaceChild(i,c.copy(a))}function g(t,e,n){if(n.openStart>t.depth)throw new h("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new h("Inconsistent open depths");return m(t,e,n,0)}function m(t,e,n,r){var i=t.index(r),s=t.node(r);if(i==e.index(r)&&r<t.depth-n.openStart){var c=m(t,e,n,r+1);return s.copy(s.content.replaceChild(i,c))}if(n.content.size){if(n.openStart||n.openEnd||t.depth!=r||e.depth!=r){var a=function(t,e){for(var n=e.depth-t.openStart,r=e.node(n).copy(t.content),i=n-1;i>=0;i--)r=e.node(i).copy(o.from(r));return{start:r.resolveNoCache(t.openStart+n),end:r.resolveNoCache(r.content.size-t.openEnd-n)}}(n,t);return k(s,S(t,a.start,a.end,e,r))}var l=t.parent,h=l.content;return k(l,h.cut(0,t.parentOffset).append(n.content).append(h.cut(e.parentOffset)))}return k(s,C(t,e,r))}function v(t,e){if(!e.type.compatibleContent(t.type))throw new h("Cannot join "+e.type.name+" onto "+t.type.name)}function y(t,e,n){var r=t.node(n);return v(r,e.node(n)),r}function w(t,e){var n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function b(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&&(w(t.nodeAfter,r),i++));for(var c=i;c<s;c++)w(o.child(c),r);e&&e.depth==n&&e.textOffset&&w(e.nodeBefore,r)}function k(t,e){if(!t.type.validContent(e))throw new h("Invalid content for node "+t.type.name);return t.copy(e)}function S(t,e,n,r,i){var s=t.depth>i&&y(t,e,i+1),c=r.depth>i&&y(n,r,i+1),a=[];return b(null,t,i,a),s&&c&&e.index(i)==n.index(i)?(v(s,c),w(k(s,S(t,e,n,r,i+1)),a)):(s&&w(k(s,C(t,e,i+1)),a),b(e,n,i,a),c&&w(k(c,C(n,r,i+1)),a)),b(r,null,i,a),new o(a)}function C(t,e,n){var r=[];return b(null,t,n,r),t.depth>n&&w(k(y(t,e,n+1),C(t,e,n+1)),r),b(e,null,n,r),new o(r)}d.size.get=function(){return this.content.size-this.openStart-this.openEnd},u.prototype.insertAt=function(t,e){var n=f(this.content,t+this.openStart,e,null);return n&&new u(n,this.openStart,this.openEnd)},u.prototype.removeBetween=function(t,e){return new u(p(this.content,t+this.openStart,e+this.openStart),this.openStart,this.openEnd)},u.prototype.eq=function(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd},u.prototype.toString=function(){return this.content+"("+this.openStart+","+this.openEnd+")"},u.prototype.toJSON=function(){if(!this.content.size)return null;var t={content:this.content.toJSON()};return this.openStart>0&&(t.openStart=this.openStart),this.openEnd>0&&(t.openEnd=this.openEnd),t},u.fromJSON=function(t,e){if(!e)return u.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 u(o.fromJSON(t,e.content),n,r)},u.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 u(t,n,r)},Object.defineProperties(u.prototype,d),u.empty=new u(o.empty,0,0);var x=function(t,e,n){this.pos=t,this.path=e,this.depth=e.length/3-1,this.parentOffset=n},M={parent:{configurable:!0},doc:{configurable:!0},textOffset:{configurable:!0},nodeAfter:{configurable:!0},nodeBefore:{configurable:!0}};x.prototype.resolveDepth=function(t){return null==t?this.depth:t<0?this.depth+t:t},M.parent.get=function(){return this.node(this.depth)},M.doc.get=function(){return this.node(0)},x.prototype.node=function(t){return this.path[3*this.resolveDepth(t)]},x.prototype.index=function(t){return this.path[3*this.resolveDepth(t)+1]},x.prototype.indexAfter=function(t){return t=this.resolveDepth(t),this.index(t)+(t!=this.depth||this.textOffset?1:0)},x.prototype.start=function(t){return 0==(t=this.resolveDepth(t))?0:this.path[3*t-1]+1},x.prototype.end=function(t){return t=this.resolveDepth(t),this.start(t)+this.node(t).content.size},x.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]},x.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},M.textOffset.get=function(){return this.pos-this.path[this.path.length-1]},M.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},M.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)},x.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},x.prototype.marks=function(){var t=this.parent,e=this.index();if(0==t.content.size)return l.none;if(this.textOffset)return t.child(e).marks;var n=t.maybeChild(e-1),r=t.maybeChild(e);if(!n){var o=n;n=r,r=o}for(var i=n.marks,s=0;s<i.length;s++)!1!==i[s].type.spec.inclusive||r&&i[s].isInSet(r.marks)||(i=i[s--].removeFromSet(i));return i},x.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},x.prototype.sharedDepth=function(t){for(var e=this.depth;e>0;e--)if(this.start(e)<=t&&this.end(e)>=t)return e;return 0},x.prototype.blockRange=function(t,e){if(void 0===t&&(t=this),t.pos<this.pos)return t.blockRange(this);for(var n=this.depth-(this.parent.inlineContent||this.pos==t.pos?1:0);n>=0;n--)if(t.pos<=this.end(n)&&(!e||e(this.node(n))))return new D(this,t,n)},x.prototype.sameParent=function(t){return this.pos-this.parentOffset==t.pos-t.parentOffset},x.prototype.max=function(t){return t.pos>this.pos?t:this},x.prototype.min=function(t){return t.pos<this.pos?t:this},x.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},x.resolve=function(t,e){if(!(e>=0&&e<=t.content.size))throw new RangeError("Position "+e+" out of range");for(var n=[],r=0,o=e,i=t;;){var s=i.content.findIndex(o),c=s.index,a=s.offset,l=o-a;if(n.push(i,c,r+a),!l)break;if((i=i.child(c)).isText)break;o=l-1,r+=a+1}return new x(e,n,o)},x.resolveCached=function(t,e){for(var n=0;n<_.length;n++){var r=_[n];if(r.pos==e&&r.doc==t)return r}var o=_[E]=x.resolve(t,e);return E=(E+1)%O,o},Object.defineProperties(x.prototype,M);var _=[],E=0,O=12,D=function(t,e,n){this.$from=t,this.$to=e,this.depth=n},N={start:{configurable:!0},end:{configurable:!0},parent:{configurable:!0},startIndex:{configurable:!0},endIndex:{configurable:!0}};N.start.get=function(){return this.$from.before(this.depth+1)},N.end.get=function(){return this.$to.after(this.depth+1)},N.parent.get=function(){return this.$from.node(this.depth)},N.startIndex.get=function(){return this.$from.index(this.depth)},N.endIndex.get=function(){return this.$to.indexAfter(this.depth)},Object.defineProperties(D.prototype,N);var A=Object.create(null),T=function(t,e,n,r){this.type=t,this.attrs=e,this.content=n||o.empty,this.marks=r||l.none},I={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}};I.nodeSize.get=function(){return this.isLeaf?1:2+this.content.size},I.childCount.get=function(){return this.content.childCount},T.prototype.child=function(t){return this.content.child(t)},T.prototype.maybeChild=function(t){return this.content.maybeChild(t)},T.prototype.forEach=function(t){this.content.forEach(t)},T.prototype.nodesBetween=function(t,e,n,r){void 0===r&&(r=0),this.content.nodesBetween(t,e,n,r,this)},T.prototype.descendants=function(t){this.nodesBetween(0,this.content.size,t)},I.textContent.get=function(){return this.textBetween(0,this.content.size,"")},T.prototype.textBetween=function(t,e,n,r){return this.content.textBetween(t,e,n,r)},I.firstChild.get=function(){return this.content.firstChild},I.lastChild.get=function(){return this.content.lastChild},T.prototype.eq=function(t){return this==t||this.sameMarkup(t)&&this.content.eq(t.content)},T.prototype.sameMarkup=function(t){return this.hasMarkup(t.type,t.attrs,t.marks)},T.prototype.hasMarkup=function(t,e,n){return this.type==t&&a(this.attrs,e||t.defaultAttrs||A)&&l.sameSet(this.marks,n||l.none)},T.prototype.copy=function(t){return void 0===t&&(t=null),t==this.content?this:new this.constructor(this.type,this.attrs,t,this.marks)},T.prototype.mark=function(t){return t==this.marks?this:new this.constructor(this.type,this.attrs,this.content,t)},T.prototype.cut=function(t,e){return 0==t&&e==this.content.size?this:this.copy(this.content.cut(t,e))},T.prototype.slice=function(t,e,n){if(void 0===e&&(e=this.content.size),void 0===n&&(n=!1),t==e)return u.empty;var r=this.resolve(t),o=this.resolve(e),i=n?0:r.sharedDepth(e),s=r.start(i),c=r.node(i).content.cut(r.pos-s,o.pos-s);return new u(c,r.depth-i,o.depth-i)},T.prototype.replace=function(t,e,n){return g(this.resolve(t),this.resolve(e),n)},T.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}},T.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}},T.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}},T.prototype.resolve=function(t){return x.resolveCached(this,t)},T.prototype.resolveNoCache=function(t){return x.resolve(this,t)},T.prototype.rangeHasMark=function(t,e,n){var r=!1;return e>t&&this.nodesBetween(t,e,(function(t){return n.isInSet(t.marks)&&(r=!0),!r})),r},I.isBlock.get=function(){return this.type.isBlock},I.isTextblock.get=function(){return this.type.isTextblock},I.inlineContent.get=function(){return this.type.inlineContent},I.isInline.get=function(){return this.type.isInline},I.isText.get=function(){return this.type.isText},I.isLeaf.get=function(){return this.type.isLeaf},I.isAtom.get=function(){return this.type.isAtom},T.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()+")"),z(this.marks,t)},T.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},T.prototype.canReplace=function(t,e,n,r,i){void 0===n&&(n=o.empty),void 0===r&&(r=0),void 0===i&&(i=n.childCount);var s=this.contentMatchAt(t).matchFragment(n,r,i),c=s&&s.matchFragment(this.content,e);if(!c||!c.validEnd)return!1;for(var a=r;a<i;a++)if(!this.type.allowsMarks(n.child(a).marks))return!1;return!0},T.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},T.prototype.canAppend=function(t){return t.content.size?this.canReplace(this.childCount,this.childCount,t.content):this.type.compatibleContent(t.type)},T.prototype.check=function(){if(!this.type.validContent(this.content))throw new RangeError("Invalid content for node "+this.type.name+": "+this.content.toString().slice(0,50));for(var t=l.none,e=0;e<this.marks.length;e++)t=this.marks[e].addToSet(t);if(!l.sameSet(t,this.marks))throw new RangeError("Invalid collection of marks for node "+this.type.name+": "+this.marks.map((function(t){return t.type.name})));this.content.forEach((function(t){return t.check()}))},T.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},T.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=o.fromJSON(t,e.content);return t.nodeType(e.type).create(e.attrs,r,n)},Object.defineProperties(T.prototype,I);var R=function(t){function e(e,n,r,o){if(t.call(this,e,n,null,o),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={textContent:{configurable:!0},nodeSize:{configurable:!0}};return e.prototype.toString=function(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):z(this.marks,JSON.stringify(this.text))},n.textContent.get=function(){return this.text},e.prototype.textBetween=function(t,e){return this.text.slice(t,e)},n.nodeSize.get=function(){return this.text.length},e.prototype.mark=function(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)},e.prototype.withText=function(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)},e.prototype.cut=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=this.text.length),0==t&&e==this.text.length?this:this.withText(this.text.slice(t,e))},e.prototype.eq=function(t){return this.sameMarkup(t)&&this.text==t.text},e.prototype.toJSON=function(){var e=t.prototype.toJSON.call(this);return e.text=this.text,e},Object.defineProperties(e.prototype,n),e}(T);function z(t,e){for(var n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}var P=function(t){this.validEnd=t,this.next=[],this.wrapCache=[]},L={inlineContent:{configurable:!0},defaultType:{configurable:!0},edgeCount:{configurable:!0}};P.parse=function(t,e){var n=new B(t,e);if(null==n.next)return P.empty;var r=F(n);n.next&&n.err("Unexpected trailing text");var o,i,s=(o=function(t){var e=[[]];return o(function t(e,i){if("choice"==e.type)return e.exprs.reduce((function(e,n){return e.concat(t(n,i))}),[]);if("seq"==e.type)for(var s=0;;s++){var c=t(e.exprs[s],i);if(s==e.exprs.length-1)return c;o(c,i=n())}else{if("star"==e.type){var a=n();return r(i,a),o(t(e.expr,a),a),[r(a)]}if("plus"==e.type){var l=n();return o(t(e.expr,i),l),o(t(e.expr,l),l),[r(l)]}if("opt"==e.type)return[r(i)].concat(t(e.expr,i));if("range"==e.type){for(var h=i,u=0;u<e.min;u++){var d=n();o(t(e.expr,h),d),h=d}if(-1==e.max)o(t(e.expr,h),h);else for(var p=e.min;p<e.max;p++){var f=n();r(h,f),o(t(e.expr,h),f),h=f}return[r(h)]}if("name"==e.type)return[r(i,null,e.value)]}}(t,0),n()),e;function n(){return e.push([])-1}function r(t,n,r){var o={term:r,to:n};return e[t].push(o),o}function o(t,e){t.forEach((function(t){return t.to=e}))}}(r),i=Object.create(null),function t(e){var n=[];e.forEach((function(t){o[t].forEach((function(t){var e=t.term,r=t.to;if(e){var i=n.indexOf(e),s=i>-1&&n[i+1];W(o,r).forEach((function(t){s||n.push(e,s=[]),-1==s.indexOf(t)&&s.push(t)}))}}))}));for(var r=i[e.join(",")]=new P(e.indexOf(o.length-1)>-1),s=0;s<n.length;s+=2){var c=n[s+1].sort(J);r.next.push(n[s],i[c.join(",")]||t(c))}return r}(W(o,0)));return function(t,e){for(var n=0,r=[t];n<r.length;n++){for(var o=r[n],i=!o.validEnd,s=[],c=0;c<o.next.length;c+=2){var a=o.next[c],l=o.next[c+1];s.push(a.name),!i||a.isText||a.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)")}}(s,n),s},P.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},P.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},L.inlineContent.get=function(){var t=this.next[0];return!!t&&t.isInline},L.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}},P.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},P.prototype.fillBefore=function(t,e,n){void 0===e&&(e=!1),void 0===n&&(n=0);var r=[this];return function i(s,c){var a=s.matchFragment(t,n);if(a&&(!e||a.validEnd))return o.from(c.map((function(t){return t.createAndFill()})));for(var l=0;l<s.next.length;l+=2){var h=s.next[l],u=s.next[l+1];if(!h.isText&&!h.hasRequiredAttrs()&&-1==r.indexOf(u)){r.push(u);var d=i(u,c.concat(h));if(d)return d}}}(this,[])},P.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},P.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 c=0;c<o.next.length;c+=2){var a=o.next[c];a.isLeaf||a.hasRequiredAttrs()||a.name in e||r.type&&!o.next[c+1].validEnd||(n.push({match:a.contentMatch,type:a,via:r}),e[a.name]=!0)}}},L.edgeCount.get=function(){return this.next.length>>1},P.prototype.edge=function(t){var e=t<<1;if(e>=this.next.length)throw new RangeError("There's no "+t+"th edge in this content match");return{type:this.next[e],next:this.next[e+1]}},P.prototype.toString=function(){var t=[];return function e(n){t.push(n);for(var r=1;r<n.next.length;r+=2)-1==t.indexOf(n.next[r])&&e(n.next[r])}(this),t.map((function(e,n){for(var r=n+(e.validEnd?"*":" ")+" ",o=0;o<e.next.length;o+=2)r+=(o?", ":"")+e.next[o].name+"->"+t.indexOf(e.next[o+1]);return r})).join("\n")},Object.defineProperties(P.prototype,L),P.empty=new P(!0);var B=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()},V={next:{configurable:!0}};function F(t){var e=[];do{e.push($(t))}while(t.eat("|"));return 1==e.length?e[0]:{type:"choice",exprs:e}}function $(t){var e=[];do{e.push(q(t))}while(t.next&&")"!=t.next&&"|"!=t.next);return 1==e.length?e[0]:{type:"seq",exprs:e}}function q(t){for(var e=function(t){if(t.eat("(")){var e=F(t);return t.eat(")")||t.err("Missing closing paren"),e}if(!/\W/.test(t.next)){var n=function(t,e){var n=t.nodeTypes,r=n[e];if(r)return[r];var o=[];for(var i in n){var s=n[i];s.groups.indexOf(e)>-1&&o.push(s)}return 0==o.length&&t.err("No node type or group '"+e+"' found"),o}(t,t.next).map((function(e){return null==t.inline?t.inline=e.isInline:t.inline!=e.isInline&&t.err("Mixing inline and block content"),{type:"name",value:e}}));return t.pos++,1==n.length?n[0]:{type:"choice",exprs:n}}t.err("Unexpected token '"+t.next+"'")}(t);;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else{if(!t.eat("{"))break;e=U(t,e)}return e}function j(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");var e=Number(t.next);return t.pos++,e}function U(t,e){var n=j(t),r=n;return t.eat(",")&&(r="}"!=t.next?j(t):-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function J(t,e){return e-t}function W(t,e){var n=[];return function e(r){var o=t[r];if(1==o.length&&!o[0].term)return e(o[0].to);n.push(r);for(var i=0;i<o.length;i++){var s=o[i],c=s.term,a=s.to;c||-1!=n.indexOf(a)||e(a)}}(e),n.sort(J)}function K(t){var e=Object.create(null);for(var n in t){var r=t[n];if(!r.hasDefault)return null;e[n]=r.default}return e}function H(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 G(t){var e=Object.create(null);if(t)for(var n in t)e[n]=new Q(t[n]);return e}V.next.get=function(){return this.tokens[this.pos]},B.prototype.eat=function(t){return this.next==t&&(this.pos++||!0)},B.prototype.err=function(t){throw new SyntaxError(t+" (in content expression '"+this.string+"')")},Object.defineProperties(B.prototype,V);var Y=function(t,e,n){this.name=t,this.schema=e,this.spec=n,this.groups=n.group?n.group.split(" "):[],this.attrs=G(n.attrs),this.defaultAttrs=K(this.attrs),this.contentMatch=null,this.markSet=null,this.inlineContent=null,this.isBlock=!(n.inline||"text"==t),this.isText="text"==t},X={isInline:{configurable:!0},isTextblock:{configurable:!0},isLeaf:{configurable:!0},isAtom:{configurable:!0}};X.isInline.get=function(){return!this.isBlock},X.isTextblock.get=function(){return this.isBlock&&this.inlineContent},X.isLeaf.get=function(){return this.contentMatch==P.empty},X.isAtom.get=function(){return this.isLeaf||this.spec.atom},Y.prototype.hasRequiredAttrs=function(){for(var t in this.attrs)if(this.attrs[t].isRequired)return!0;return!1},Y.prototype.compatibleContent=function(t){return this==t||this.contentMatch.compatible(t.contentMatch)},Y.prototype.computeAttrs=function(t){return!t&&this.defaultAttrs?this.defaultAttrs:H(this.attrs,t)},Y.prototype.create=function(t,e,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new T(this,this.computeAttrs(t),o.from(e),l.setFrom(n))},Y.prototype.createChecked=function(t,e,n){if(e=o.from(e),!this.validContent(e))throw new RangeError("Invalid content for node "+this.name);return new T(this,this.computeAttrs(t),e,l.setFrom(n))},Y.prototype.createAndFill=function(t,e,n){if(t=this.computeAttrs(t),(e=o.from(e)).size){var r=this.contentMatch.fillBefore(e);if(!r)return null;e=r.append(e)}var i=this.contentMatch.matchFragment(e).fillBefore(o.empty,!0);return i?new T(this,t,e.append(i),l.setFrom(n)):null},Y.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},Y.prototype.allowsMarkType=function(t){return null==this.markSet||this.markSet.indexOf(t)>-1},Y.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},Y.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:l.empty:t},Y.compile=function(t,e){var n=Object.create(null);t.forEach((function(t,r){return n[t]=new Y(t,e,r)}));var r=e.spec.topNode||"doc";if(!n[r])throw new RangeError("Schema is missing its top node type ('"+r+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(var o in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n},Object.defineProperties(Y.prototype,X);var Q=function(t){this.hasDefault=Object.prototype.hasOwnProperty.call(t,"default"),this.default=t.default},Z={isRequired:{configurable:!0}};Z.isRequired.get=function(){return!this.hasDefault},Object.defineProperties(Q.prototype,Z);var tt=function(t,e,n,r){this.name=t,this.schema=n,this.spec=r,this.attrs=G(r.attrs),this.rank=e,this.excluded=null;var o=K(this.attrs);this.instance=o&&new l(this,o)};tt.prototype.create=function(t){return!t&&this.instance?this.instance:new l(this,H(this.attrs,t))},tt.compile=function(t,e){var n=Object.create(null),r=0;return t.forEach((function(t,o){return n[t]=new tt(t,r++,e,o)})),n},tt.prototype.removeFromSet=function(t){for(var e=0;e<t.length;e++)t[e].type==this&&(t=t.slice(0,e).concat(t.slice(e+1)),e--);return t},tt.prototype.isInSet=function(t){for(var e=0;e<t.length;e++)if(t[e].type==this)return t[e]},tt.prototype.excludes=function(t){return this.excluded.indexOf(t)>-1};var et=function(t){for(var n in this.spec={},t)this.spec[n]=t[n];this.spec.nodes=e.from(t.nodes),this.spec.marks=e.from(t.marks),this.nodes=Y.compile(this.spec.nodes,this),this.marks=tt.compile(this.spec.marks,this);var r=Object.create(null);for(var o in this.nodes){if(o in this.marks)throw new RangeError(o+" can not be both a node and a mark");var i=this.nodes[o],s=i.spec.content||"",c=i.spec.marks;i.contentMatch=r[s]||(r[s]=P.parse(s,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.markSet="_"==c?null:c?nt(this,c.split(" ")):""!=c&&i.inlineContent?null:[]}for(var a in this.marks){var l=this.marks[a],h=l.spec.excludes;l.excluded=null==h?[l]:""==h?[]:nt(this,h.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 nt(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 c in t.marks){var a=t.marks[c];("_"==o||a.spec.group&&a.spec.group.split(" ").indexOf(o)>-1)&&n.push(s=a)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}et.prototype.node=function(t,e,n,r){if("string"==typeof t)t=this.nodeType(t);else{if(!(t instanceof Y))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)},et.prototype.text=function(t,e){var n=this.nodes.text;return new R(n,n.defaultAttrs,t,l.setFrom(e))},et.prototype.mark=function(t,e){return"string"==typeof t&&(t=this.marks[t]),t.create(e)},et.prototype.nodeFromJSON=function(t){return T.fromJSON(this,t)},et.prototype.markFromJSON=function(t){return l.fromJSON(this,t)},et.prototype.nodeType=function(t){var e=this.nodes[t];if(!e)throw new RangeError("Unknown node type: "+t);return e};var rt=function(t,e){var n=this;this.schema=t,this.rules=e,this.tags=[],this.styles=[],e.forEach((function(t){t.tag?n.tags.push(t):t.style&&n.styles.push(t)})),this.normalizeLists=!this.tags.some((function(e){if(!/^(ul|ol)\b/.test(e.tag)||!e.node)return!1;var n=t.nodes[e.node];return n.contentMatch.matchType(n)}))};rt.prototype.parse=function(t,e){void 0===e&&(e={});var n=new lt(this,e,!1);return n.addAll(t,null,e.from,e.to),n.finish()},rt.prototype.parseSlice=function(t,e){void 0===e&&(e={});var n=new lt(this,e,!0);return n.addAll(t,null,e.from,e.to),u.maxOpen(n.finish())},rt.prototype.matchTag=function(t,e,n){for(var r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){var o=this.tags[r];if(ut(t,o.tag)&&(void 0===o.namespace||t.namespaceURI==o.namespace)&&(!o.context||e.matchesContext(o.context))){if(o.getAttrs){var i=o.getAttrs(t);if(!1===i)continue;o.attrs=i}return o}}},rt.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}}},rt.schemaRules=function(t){var e=[];function n(t){for(var n=null==t.priority?50:t.priority,r=0;r<e.length;r++){var o=e[r];if((null==o.priority?50:o.priority)<n)break}e.splice(r,0,t)}var r,o=function(e){var r=t.marks[e].spec.parseDOM;r&&r.forEach((function(t){n(t=dt(t)),t.mark=e}))};for(var i in t.marks)o(i);for(var s in t.nodes)r=void 0,(r=t.nodes[s].spec.parseDOM)&&r.forEach((function(t){n(t=dt(t)),t.node=s}));return e},rt.fromSchema=function(t){return t.cached.domParser||(t.cached.domParser=new rt(t,rt.schemaRules(t)))};var ot={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},it={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},st={ol:!0,ul:!0};function ct(t){return(t?1:0)|("full"===t?2:0)}var at=function(t,e,n,r,o,i,s){this.type=t,this.attrs=e,this.solid=o,this.match=i||(4&s?null:t.contentMatch),this.options=s,this.content=[],this.marks=n,this.activeMarks=l.none,this.pendingMarks=r,this.stashMarks=[]};at.prototype.findWrapping=function(t){if(!this.match){if(!this.type)return[];var e=this.type.contentMatch.fillBefore(o.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)},at.prototype.finish=function(t){if(!(1&this.options)){var e,n=this.content[this.content.length-1];n&&n.isText&&(e=/[ \t\r\n\u000c]+$/.exec(n.text))&&(n.text.length==e[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-e[0].length)))}var r=o.from(this.content);return!t&&this.match&&(r=r.append(this.match.fillBefore(o.empty,!0))),this.type?this.type.create(this.attrs,r,this.marks):r},at.prototype.popFromStashMark=function(t){for(var e=this.stashMarks.length-1;e>=0;e--)if(t.eq(this.stashMarks[e]))return this.stashMarks.splice(e,1)[0]},at.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):pt(r.type,t))&&!r.isInSet(this.activeMarks)&&(this.activeMarks=r.addToSet(this.activeMarks),this.pendingMarks=r.removeFromSet(this.pendingMarks))}},at.prototype.inlineContext=function(t){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:t.parentNode&&!ot.hasOwnProperty(t.parentNode.nodeName.toLowerCase())};var lt=function(t,e,n){this.parser=t,this.options=e,this.isOpen=n;var r,o=e.topNode,i=ct(e.preserveWhitespace)|(n?4:0);r=o?new at(o.type,o.attrs,l.none,l.none,!0,e.topMatch||o.type.contentMatch,i):new at(n?null:t.schema.topNodeType,null,l.none,l.none,!0,null,i),this.nodes=[r],this.open=0,this.find=e.findPositions,this.needsBlock=!1},ht={top:{configurable:!0},currentPos:{configurable:!0}};function ut(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function dt(t){var e={};for(var n in t)e[n]=t[n];return e}function pt(t,e){var n=e.schema.nodes,r=function(r){var o=n[r];if(o.allowsMarkType(t)){var i=[],s=function(t){i.push(t);for(var n=0;n<t.edgeCount;n++){var r=t.edge(n),o=r.type,c=r.next;if(o==e)return!0;if(i.indexOf(c)<0&&s(c))return!0}};return s(o.contentMatch)?{v:!0}:void 0}};for(var o in n){var i=r(o);if(i)return i.v}}ht.top.get=function(){return this.nodes[this.open]},lt.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){for(var e,n=/\s*([\w-]+)\s*:\s*([^;]+)/g,r=[];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)}},lt.prototype.addTextNode=function(t){var e=t.nodeValue,n=this.top;if(2&n.options||n.inlineContext(t)||/[^ \t\r\n\u000c]/.test(e)){if(1&n.options)e=2&n.options?e.replace(/\r\n?/g,"\n"):e.replace(/\r?\n|\r/g," ");else if(e=e.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(e)&&this.open==this.nodes.length-1){var r=n.content[n.content.length-1],o=t.previousSibling;(!r||o&&"BR"==o.nodeName||r.isText&&/[ \t\r\n\u000c]$/.test(r.text))&&(e=e.slice(1))}e&&this.insertNode(this.parser.schema.text(e)),this.findInText(t)}else this.findInside(t)},lt.prototype.addElement=function(t,e){var n,r=t.nodeName.toLowerCase();st.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&&st.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:it.hasOwnProperty(r))this.findInside(t),this.ignoreFallback(t);else if(!o||o.skip||o.closeParent){o&&o.closeParent?this.open=Math.max(0,this.open-1):o&&o.skip.nodeType&&(t=o.skip);var i,s=this.top,c=this.needsBlock;if(ot.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=c}else this.addElementByRule(t,o,!1===o.consuming?n:null)},lt.prototype.leafFallback=function(t){"BR"==t.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(t.ownerDocument.createTextNode("\n"))},lt.prototype.ignoreFallback=function(t){"BR"!=t.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"))},lt.prototype.readStyles=function(t){var e=l.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},lt.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 c=this.top;if(o&&o.isLeaf)this.findInside(t);else if(n)this.addElement(t,n);else if(e.getContent)this.findInside(t),e.getContent(t,this.parser.schema).forEach((function(t){return s.insertNode(t)}));else{var a=e.contentElement;"string"==typeof a?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)},lt.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&&ot.hasOwnProperty(i.nodeName.toLowerCase())&&this.sync(e);this.findAtPoint(t,o)},lt.prototype.findPlace=function(t){for(var e,n,r=this.open;r>=0;r--){var o=this.nodes[r],i=o.findWrapping(t);if(i&&(!e||e.length>i.length)&&(e=i,n=o,!i.length))break;if(o.solid)break}if(!e)return!1;this.sync(n);for(var s=0;s<e.length;s++)this.enterInner(e[s],null,!1);return!0},lt.prototype.insertNode=function(t){if(t.isInline&&this.needsBlock&&!this.top.type){var e=this.textblockFromContext();e&&this.enterInner(e)}if(this.findPlace(t)){this.closeExtra();var n=this.top;n.applyPending(t.type),n.match&&(n.match=n.match.matchType(t.type));for(var r=n.activeMarks,o=0;o<t.marks.length;o++)n.type&&!n.type.allowsMarkType(t.marks[o].type)||(r=t.marks[o].addToSet(r));return n.content.push(t.mark(r)),!0}return!1},lt.prototype.enter=function(t,e,n){var r=this.findPlace(t.create(e));return r&&this.enterInner(t,e,!0,n),r},lt.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:ct(r);4&o.options&&0==o.content.length&&(i|=4),this.nodes.push(new at(t,e,o.activeMarks,o.pendingMarks,n,null,i)),this.open++},lt.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}},lt.prototype.finish=function(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)},lt.prototype.sync=function(t){for(var e=this.open;e>=0;e--)if(this.nodes[e]==t)return void(this.open=e)},ht.currentPos.get=function(){this.closeExtra();for(var t=0,e=this.open;e>=0;e--){for(var n=this.nodes[e].content,r=n.length-1;r>=0;r--)t+=n[r].nodeSize;e&&t++}return t},lt.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)},lt.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)},lt.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)},lt.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))},lt.prototype.matchesContext=function(t){var e=this;if(t.indexOf("|")>-1)return t.split(/\s*\|\s*/).some(this.matchesContext,this);var n=t.split("/"),r=this.options.context,o=!(this.isOpen||r&&r.parent.type!=this.nodes[0].type),i=-(r?r.depth+1:0)+(o?0:1),s=function(t,c){for(;t>=0;t--){var a=n[t];if(""==a){if(t==n.length-1||0==t)continue;for(;c>=i;c--)if(s(t-1,c))return!0;return!1}var l=c>0||0==c&&o?e.nodes[c].type:r&&c>=i?r.node(c-i).type:null;if(!l||l.name!=a&&-1==l.groups.indexOf(a))return!1;c--}return!0};return s(n.length-1,this.open)},lt.prototype.textblockFromContext=function(){var t=this.options.context;if(t)for(var e=t.depth;e>=0;e--){var n=t.node(e).contentMatchAt(t.indexAfter(e)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(var r in this.parser.schema.nodes){var o=this.parser.schema.nodes[r];if(o.isTextblock&&o.defaultAttrs)return o}},lt.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)},lt.prototype.removePendingMark=function(t,e){for(var n=this.open;n>=0;n--){var r=this.nodes[n];if(r.pendingMarks.lastIndexOf(t)>-1)r.pendingMarks=t.removeFromSet(r.pendingMarks);else{r.activeMarks=t.removeFromSet(r.activeMarks);var o=r.popFromStashMark(t);o&&r.type&&r.type.allowsMarkType(o.type)&&(r.activeMarks=o.addToSet(r.activeMarks))}if(r==e)break}},Object.defineProperties(lt.prototype,ht);var ft=function(t,e){this.nodes=t||{},this.marks=e||{}};function gt(t){var e={};for(var n in t){var r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function mt(t){return t.document||window.document}ft.prototype.serializeFragment=function(t,e,n){var r=this;void 0===e&&(e={}),n||(n=mt(e).createDocumentFragment());var o=n,i=null;return t.forEach((function(t){if(i||t.marks.length){i||(i=[]);for(var n=0,s=0;n<i.length&&s<t.marks.length;){var c=t.marks[s];if(r.marks[c.type.name]){if(!c.eq(i[n])||!1===c.type.spec.spanning)break;n+=2,s++}else s++}for(;n<i.length;)o=i.pop(),i.pop();for(;s<t.marks.length;){var a=t.marks[s++],l=r.serializeMark(a,t.isInline,e);l&&(i.push(a,o),o.appendChild(l.dom),o=l.contentDOM||l.dom)}}o.appendChild(r.serializeNodeInner(t,e))})),n},ft.prototype.serializeNodeInner=function(t,e){void 0===e&&(e={});var n=ft.renderSpec(mt(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},ft.prototype.serializeNode=function(t,e){void 0===e&&(e={});for(var n=this.serializeNodeInner(t,e),r=t.marks.length-1;r>=0;r--){var o=this.serializeMark(t.marks[r],t.isInline,e);o&&((o.contentDOM||o.dom).appendChild(n),n=o.dom)}return n},ft.prototype.serializeMark=function(t,e,n){void 0===n&&(n={});var r=this.marks[t.type.name];return r&&ft.renderSpec(mt(n),r(t,e))},ft.renderSpec=function(t,e,n){if(void 0===n&&(n=null),"string"==typeof e)return{dom:t.createTextNode(e)};if(null!=e.nodeType)return{dom:e};if(e.dom&&null!=e.dom.nodeType)return e;var r=e[0],o=r.indexOf(" ");o>0&&(n=r.slice(0,o),r=r.slice(o+1));var i=null,s=n?t.createElementNS(n,r):t.createElement(r),c=e[1],a=1;if(c&&"object"==typeof c&&null==c.nodeType&&!Array.isArray(c))for(var l in a=2,c)if(null!=c[l]){var h=l.indexOf(" ");h>0?s.setAttributeNS(l.slice(0,h),l.slice(h+1),c[l]):s.setAttribute(l,c[l])}for(var u=a;u<e.length;u++){var d=e[u];if(0===d){if(u<e.length-1||u>a)throw new RangeError("Content hole must be the only child of its parent node");return{dom:s,contentDOM:s}}var p=ft.renderSpec(t,d,n),f=p.dom,g=p.contentDOM;if(s.appendChild(f),g){if(i)throw new RangeError("Multiple content holes");i=g}}return{dom:s,contentDOM:i}},ft.fromSchema=function(t){return t.cached.domSerializer||(t.cached.domSerializer=new ft(this.nodesFromSchema(t),this.marksFromSchema(t)))},ft.nodesFromSchema=function(t){var e=gt(t.nodes);return e.text||(e.text=function(t){return t.text}),e},ft.marksFromSchema=function(t){return gt(t.marks)};var vt=Math.pow(2,16);function yt(t){return 65535&t}var wt=function(t,e,n){void 0===e&&(e=!1),void 0===n&&(n=null),this.pos=t,this.deleted=e,this.recover=n},bt=function(t,e){void 0===e&&(e=!1),this.ranges=t,this.inverted=e};bt.prototype.recover=function(t){var e=0,n=yt(t);if(!this.inverted)for(var r=0;r<n;r++)e+=this.ranges[3*r+2]-this.ranges[3*r+1];return this.ranges[3*n]+e+function(t){return(t-(65535&t))/vt}(t)},bt.prototype.mapResult=function(t,e){return void 0===e&&(e=1),this._map(t,e,!1)},bt.prototype.map=function(t,e){return void 0===e&&(e=1),this._map(t,e,!0)},bt.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 c=this.ranges[s]-(this.inverted?r:0);if(c>t)break;var a=this.ranges[s+o],l=this.ranges[s+i],h=c+a;if(t<=h){var u=c+r+((a?t==c?-1:t==h?1:e:e)<0?0:l);return n?u:new wt(u,e<0?t!=c:t!=h,t==(e<0?c:h)?null:s/3+(t-c)*vt)}r+=l-a}return n?t+r:new wt(t+r)},bt.prototype.touches=function(t,e){for(var n=0,r=yt(e),o=this.inverted?2:1,i=this.inverted?1:2,s=0;s<this.ranges.length;s+=3){var c=this.ranges[s]-(this.inverted?n:0);if(c>t)break;var a=this.ranges[s+o];if(t<=c+a&&s==3*r)return!0;n+=this.ranges[s+i]-a}return!1},bt.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),c=i+(this.inverted?0:o),a=this.ranges[r+e],l=this.ranges[r+n];t(s,s+a,c,c+l),o+=l-a}},bt.prototype.invert=function(){return new bt(this.ranges,!this.inverted)},bt.prototype.toString=function(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)},bt.offset=function(t){return 0==t?bt.empty:new bt(t<0?[0,-t,0]:[0,0,t])},bt.empty=new bt([]);var kt=function(t,e,n,r){this.maps=t||[],this.from=n||0,this.to=null==r?this.maps.length:r,this.mirror=e};function St(t){var e=Error.call(this,t);return e.__proto__=St.prototype,e}kt.prototype.slice=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=this.maps.length),new kt(this.maps,this.mirror,t,e)},kt.prototype.copy=function(){return new kt(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)},kt.prototype.appendMap=function(t,e){this.to=this.maps.push(t),null!=e&&this.setMirror(this.maps.length-1,e)},kt.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)}},kt.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)]},kt.prototype.setMirror=function(t,e){this.mirror||(this.mirror=[]),this.mirror.push(t,e)},kt.prototype.appendMappingInverted=function(t){for(var e=t.maps.length-1,n=this.maps.length+t.maps.length;e>=0;e--){var r=t.getMirror(e);this.appendMap(t.maps[e].invert(),null!=r&&r>e?n-r-1:null)}},kt.prototype.invert=function(){var t=new kt;return t.appendMappingInverted(this),t},kt.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},kt.prototype.mapResult=function(t,e){return void 0===e&&(e=1),this._map(t,e,!1)},kt.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&&s>o&&s<this.to){o=s,t=this.maps[s].recover(i.recover);continue}}i.deleted&&(r=!0),t=i.pos}return n?t:new wt(t,r)},St.prototype=Object.create(Error.prototype),St.prototype.constructor=St,St.prototype.name="TransformError";var Ct=function(t){this.doc=t,this.steps=[],this.docs=[],this.mapping=new kt},xt={before:{configurable:!0},docChanged:{configurable:!0}};function Mt(){throw new Error("Override me")}xt.before.get=function(){return this.docs.length?this.docs[0]:this.doc},Ct.prototype.step=function(t){var e=this.maybeStep(t);if(e.failed)throw new St(e.failed);return this},Ct.prototype.maybeStep=function(t){var e=t.apply(this.doc);return e.failed||this.addStep(t,e.doc),e},xt.docChanged.get=function(){return this.steps.length>0},Ct.prototype.addStep=function(t,e){this.docs.push(this.doc),this.steps.push(t),this.mapping.appendMap(t.getMap()),this.doc=e},Object.defineProperties(Ct.prototype,xt);var _t=Object.create(null),Et=function(){};Et.prototype.apply=function(t){return Mt()},Et.prototype.getMap=function(){return bt.empty},Et.prototype.invert=function(t){return Mt()},Et.prototype.map=function(t){return Mt()},Et.prototype.merge=function(t){return null},Et.prototype.toJSON=function(){return Mt()},Et.fromJSON=function(t,e){if(!e||!e.stepType)throw new RangeError("Invalid input for Step.fromJSON");var n=_t[e.stepType];if(!n)throw new RangeError("No step type "+e.stepType+" defined");return n.fromJSON(t,e)},Et.jsonID=function(t,e){if(t in _t)throw new RangeError("Duplicate use of step JSON ID "+t);return _t[t]=e,e.prototype.jsonID=t,e};var Ot=function(t,e){this.doc=t,this.failed=e};Ot.ok=function(t){return new Ot(t,null)},Ot.fail=function(t){return new Ot(null,t)},Ot.fromReplace=function(t,e,n,r){try{return Ot.ok(t.replace(e,n,r))}catch(t){if(t instanceof h)return Ot.fail(t.message);throw t}};var Dt=function(t){function e(e,n,r,o){t.call(this),this.from=e,this.to=n,this.slice=r,this.structure=!!o}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.apply=function(t){return this.structure&&At(t,this.from,this.to)?Ot.fail("Structure replace would overwrite content"):Ot.fromReplace(t,this.from,this.to,this.slice)},e.prototype.getMap=function(){return new bt([this.from,this.to-this.from,this.slice.size])},e.prototype.invert=function(t){return new e(this.from,this.from+this.slice.size,t.slice(this.from,this.to))},e.prototype.map=function(t){var n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted?null:new e(n.pos,Math.max(n.pos,r.pos),this.slice)},e.prototype.merge=function(t){if(!(t instanceof e)||t.structure||this.structure)return null;if(this.from+this.slice.size!=t.from||this.slice.openEnd||t.slice.openStart){if(t.to!=this.from||this.slice.openStart||t.slice.openEnd)return null;var n=this.slice.size+t.slice.size==0?u.empty:new u(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new e(t.from,this.to,n,this.structure)}var r=this.slice.size+t.slice.size==0?u.empty:new u(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new e(this.from,this.to+(t.to-t.from),r,this.structure)},e.prototype.toJSON=function(){var t={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t},e.fromJSON=function(t,n){if("number"!=typeof n.from||"number"!=typeof n.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new e(n.from,n.to,u.fromJSON(t,n.slice),!!n.structure)},e}(Et);Et.jsonID("replace",Dt);var Nt=function(t){function e(e,n,r,o,i,s,c){t.call(this),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=o,this.slice=i,this.insert=s,this.structure=!!c}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.apply=function(t){if(this.structure&&(At(t,this.from,this.gapFrom)||At(t,this.gapTo,this.to)))return Ot.fail("Structure gap-replace would overwrite content");var e=t.slice(this.gapFrom,this.gapTo);if(e.openStart||e.openEnd)return Ot.fail("Gap is not a flat range");var n=this.slice.insertAt(this.insert,e.content);return n?Ot.fromReplace(t,this.from,this.to,n):Ot.fail("Content does not fit in gap")},e.prototype.getMap=function(){return new bt([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])},e.prototype.invert=function(t){var n=this.gapTo-this.gapFrom;return new e(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)},e.prototype.map=function(t){var n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1),o=t.map(this.gapFrom,-1),i=t.map(this.gapTo,1);return n.deleted&&r.deleted||o<n.pos||i>r.pos?null:new e(n.pos,r.pos,o,i,this.slice,this.insert,this.structure)},e.prototype.toJSON=function(){var t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t},e.fromJSON=function(t,n){if("number"!=typeof n.from||"number"!=typeof n.to||"number"!=typeof n.gapFrom||"number"!=typeof n.gapTo||"number"!=typeof n.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new e(n.from,n.to,n.gapFrom,n.gapTo,u.fromJSON(t,n.slice),n.insert,!!n.structure)},e}(Et);function At(t,e,n){for(var r=t.resolve(e),o=n-e,i=r.depth;o>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,o--;if(o>0)for(var s=r.node(i).maybeChild(r.indexAfter(i));o>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,o--}return!1}function Tt(t,e,n){return(0==e||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function It(t){for(var e=t.parent.content.cutByIndex(t.startIndex,t.endIndex),n=t.depth;;--n){var r=t.$from.node(n),o=t.$from.index(n),i=t.$to.indexAfter(n);if(n<t.depth&&r.canReplace(o,i,e))return n;if(0==n||r.type.spec.isolating||!Tt(r,o,i))break}}function Rt(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 c=(s.length?s[s.length-1]:e).contentMatch,a=r;c&&a<o;a++)c=c.matchType(n.child(a).type);return c&&c.validEnd?s:null}(r,e);return i?o.map(zt).concat({type:e,attrs:n}).concat(i.map(zt)):null}function zt(t){return{type:t,attrs:null}}function Pt(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 c=o.depth-1,a=n-2;c>i;c--,a--){var l=o.node(c),h=o.index(c);if(l.type.spec.isolating)return!1;var u=l.content.cutByIndex(h,l.childCount),d=r&&r[a]||l;if(d!=l&&(u=u.replaceChild(0,d.type.create(d.attrs))),!l.canReplace(h+1,l.childCount)||!d.type.validContent(u))return!1}var p=o.indexAfter(i),f=r&&r[0];return o.node(i).canReplaceWith(p,p,f?f.type:o.node(i+1).type)}function Lt(t,e){var n=t.resolve(e),r=n.index();return Bt(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function Bt(t,e){return t&&e&&!t.isLeaf&&t.canAppend(e)}function Vt(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,c=r.index(o);if(o==r.depth?(i=r.nodeBefore,s=r.nodeAfter):n>0?(i=r.node(o+1),c++,s=r.node(o).maybeChild(c)):(i=r.node(o).maybeChild(c-1),s=r.node(o+1)),i&&!i.isTextblock&&Bt(i,s)&&r.node(o).canReplace(c,c+1))return e;if(0==o)break;e=n<0?r.before(o):r.after(o)}}function Ft(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 c=r.depth;c>=0;c--){var a=c==r.depth?0:r.pos<=(r.start(c+1)+r.end(c+1))/2?-1:1,l=r.index(c)+(a>0?1:0),h=r.node(c),u=!1;if(1==s)u=h.canReplace(l,l,o);else{var d=h.contentMatchAt(l).findWrapping(o.firstChild.type);u=d&&h.canReplaceWith(l,l,d[0])}if(u)return 0==a?r.pos:a<0?r.before(c+1):r.after(c+1)}return null}function $t(t,e,n){for(var r=[],i=0;i<t.childCount;i++){var s=t.child(i);s.content.size&&(s=s.copy($t(s.content,e,s))),s.isInline&&(s=e(s,n,i)),r.push(s)}return o.fromArray(r)}Et.jsonID("replaceAround",Nt),Ct.prototype.lift=function(t,e){for(var n=t.$from,r=t.$to,i=t.depth,s=n.before(i+1),c=r.after(i+1),a=s,l=c,h=o.empty,d=0,p=i,f=!1;p>e;p--)f||n.index(p)>0?(f=!0,h=o.from(n.node(p).copy(h)),d++):a--;for(var g=o.empty,m=0,v=i,y=!1;v>e;v--)y||r.after(v+1)<r.end(v)?(y=!0,g=o.from(r.node(v).copy(g)),m++):l++;return this.step(new Nt(a,l,s,c,new u(h.append(g),d,m),h.size-d,!0))},Ct.prototype.wrap=function(t,e){for(var n=o.empty,r=e.length-1;r>=0;r--)n=o.from(e[r].type.create(e[r].attrs,n));var i=t.start,s=t.end;return this.step(new Nt(i,s,i,s,new u(n,0,0),e.length,!0))},Ct.prototype.setBlockType=function(t,e,n,r){var i=this;if(void 0===e&&(e=t),!n.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");var s=this.steps.length;return this.doc.nodesBetween(t,e,(function(t,e){if(t.isTextblock&&!t.hasMarkup(n,r)&&function(t,e,n){var r=t.resolve(e),o=r.index();return r.parent.canReplaceWith(o,o+1,n)}(i.doc,i.mapping.slice(s).map(e),n)){i.clearIncompatible(i.mapping.slice(s).map(e,1),n);var c=i.mapping.slice(s),a=c.map(e,1),l=c.map(e+t.nodeSize,1);return i.step(new Nt(a,l,a+1,l-1,new u(o.from(n.create(r,null,t.marks)),0,0),1,!0)),!1}})),this},Ct.prototype.setNodeMarkup=function(t,e,n,r){var i=this.doc.nodeAt(t);if(!i)throw new RangeError("No node at given position");e||(e=i.type);var s=e.create(n,null,r||i.marks);if(i.isLeaf)return this.replaceWith(t,t+i.nodeSize,s);if(!e.validContent(i.content))throw new RangeError("Invalid content for node type "+e.name);return this.step(new Nt(t,t+i.nodeSize,t+1,t+i.nodeSize-1,new u(o.from(s),0,0),1,!0))},Ct.prototype.split=function(t,e,n){void 0===e&&(e=1);for(var r=this.doc.resolve(t),i=o.empty,s=o.empty,c=r.depth,a=r.depth-e,l=e-1;c>a;c--,l--){i=o.from(r.node(c).copy(i));var h=n&&n[l];s=o.from(h?h.type.create(h.attrs,s):r.node(c).copy(s))}return this.step(new Dt(t,t,new u(i.append(s),e,e),!0))},Ct.prototype.join=function(t,e){void 0===e&&(e=1);var n=new Dt(t-e,t+e,u.empty,!0);return this.step(n)};var qt=function(t){function e(e,n,r){t.call(this),this.from=e,this.to=n,this.mark=r}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.apply=function(t){var e=this,n=t.slice(this.from,this.to),r=t.resolve(this.from),o=r.node(r.sharedDepth(this.to)),i=new u($t(n.content,(function(t,n){return t.isAtom&&n.type.allowsMarkType(e.mark.type)?t.mark(e.mark.addToSet(t.marks)):t}),o),n.openStart,n.openEnd);return Ot.fromReplace(t,this.from,this.to,i)},e.prototype.invert=function(){return new jt(this.from,this.to,this.mark)},e.prototype.map=function(t){var n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)},e.prototype.merge=function(t){if(t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from)return new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark)},e.prototype.toJSON=function(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}},e.fromJSON=function(t,n){if("number"!=typeof n.from||"number"!=typeof n.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new e(n.from,n.to,t.markFromJSON(n.mark))},e}(Et);Et.jsonID("addMark",qt);var jt=function(t){function e(e,n,r){t.call(this),this.from=e,this.to=n,this.mark=r}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.apply=function(t){var e=this,n=t.slice(this.from,this.to),r=new u($t(n.content,(function(t){return t.mark(e.mark.removeFromSet(t.marks))})),n.openStart,n.openEnd);return Ot.fromReplace(t,this.from,this.to,r)},e.prototype.invert=function(){return new qt(this.from,this.to,this.mark)},e.prototype.map=function(t){var n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)},e.prototype.merge=function(t){if(t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from)return new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark)},e.prototype.toJSON=function(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}},e.fromJSON=function(t,n){if("number"!=typeof n.from||"number"!=typeof n.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new e(n.from,n.to,t.markFromJSON(n.mark))},e}(Et);function Ut(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}Et.jsonID("removeMark",jt),Ct.prototype.addMark=function(t,e,n){var r=this,o=[],i=[],s=null,c=null;return this.doc.nodesBetween(t,e,(function(r,a,l){if(r.isInline){var h=r.marks;if(!n.isInSet(h)&&l.type.allowsMarkType(n.type)){for(var u=Math.max(a,t),d=Math.min(a+r.nodeSize,e),p=n.addToSet(h),f=0;f<h.length;f++)h[f].isInSet(p)||(s&&s.to==u&&s.mark.eq(h[f])?s.to=d:o.push(s=new jt(u,d,h[f])));c&&c.to==u?c.to=d:i.push(c=new qt(u,d,n))}}})),o.forEach((function(t){return r.step(t)})),i.forEach((function(t){return r.step(t)})),this},Ct.prototype.removeMark=function(t,e,n){var r=this;void 0===n&&(n=null);var o=[],i=0;return this.doc.nodesBetween(t,e,(function(r,s){if(r.isInline){i++;var c=null;if(n instanceof tt)for(var a,l=r.marks;a=n.isInSet(l);)(c||(c=[])).push(a),l=a.removeFromSet(l);else n?n.isInSet(r.marks)&&(c=[n]):c=r.marks;if(c&&c.length)for(var h=Math.min(s+r.nodeSize,e),u=0;u<c.length;u++){for(var d=c[u],p=void 0,f=0;f<o.length;f++){var g=o[f];g.step==i-1&&d.eq(o[f].style)&&(p=g)}p?(p.to=h,p.step=i):o.push({style:d,from:Math.max(s,t),to:h,step:i})}}})),o.forEach((function(t){return r.step(new jt(t.from,t.to,t.style))})),this},Ct.prototype.clearIncompatible=function(t,e,n){void 0===n&&(n=e.contentMatch);for(var r=this.doc.nodeAt(t),i=[],s=t+1,c=0;c<r.childCount;c++){var a=r.child(c),l=s+a.nodeSize,h=n.matchType(a.type,a.attrs);if(h){n=h;for(var d=0;d<a.marks.length;d++)e.allowsMarkType(a.marks[d].type)||this.step(new jt(s,l,a.marks[d]))}else i.push(new Dt(s,l,u.empty));s=l}if(!n.validEnd){var p=n.fillBefore(o.empty,!0);this.replace(s,s,new u(p,0,0))}for(var f=i.length-1;f>=0;f--)this.step(i[f]);return this},Ct.prototype.replace=function(t,e,n){void 0===e&&(e=t),void 0===n&&(n=u.empty);var r=function(t,e,n,r){if(void 0===n&&(n=e),void 0===r&&(r=u.empty),e==n&&!r.size)return null;var o=t.resolve(e),i=t.resolve(n);return Ut(o,i,r)?new Dt(e,n,r):new Jt(o,i,r).fit()}(this.doc,t,e,n);return r&&this.step(r),this},Ct.prototype.replaceWith=function(t,e,n){return this.replace(t,e,new u(o.from(n),0,0))},Ct.prototype.delete=function(t,e){return this.replace(t,e,u.empty)},Ct.prototype.insert=function(t,e){return this.replaceWith(t,t,e)};var Jt=function(t,e,n){this.$to=e,this.$from=t,this.unplaced=n,this.frontier=[];for(var r=0;r<=t.depth;r++){var i=t.node(r);this.frontier.push({type:i.type,match:i.contentMatchAt(t.indexAfter(r))})}this.placed=o.empty;for(var s=t.depth;s>0;s--)this.placed=o.from(t.node(s).copy(this.placed))},Wt={depth:{configurable:!0}};function Kt(t,e,n){return 0==e?t.cutByIndex(n):t.replaceChild(0,t.firstChild.copy(Kt(t.firstChild.content,e-1,n)))}function Ht(t,e,n){return 0==e?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Ht(t.lastChild.content,e-1,n)))}function Gt(t,e){for(var n=0;n<e;n++)t=t.firstChild.content;return t}function Yt(t,e,n){if(e<=0)return t;var r=t.content;return e>1&&(r=r.replaceChild(0,Yt(r.firstChild,e-1,1==r.childCount?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(o.empty,!0)))),t.copy(r)}function Xt(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 c=r.fillBefore(i.content,!0,s);return c&&!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)?c:null}function Qt(t,e,n,r,i){if(e<n){var s=t.firstChild;t=t.replaceChild(0,s.copy(Qt(s.content,e+1,n,r,s)))}if(e>r){var c=i.contentMatchAt(0),a=c.fillBefore(t).append(t);t=a.append(c.matchFragment(a).fillBefore(o.empty,!0))}return t}function Zt(t,e){for(var n=[],r=Math.min(t.depth,e.depth);r>=0;r--){var o=t.start(r);if(o<t.pos-(t.depth-r)||e.end(r)>e.pos+(e.depth-r)||t.node(r).type.spec.isolating||e.node(r).type.spec.isolating)break;(o==e.start(r)||r==t.depth&&r==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&r&&e.start(r-1)==o-1)&&n.push(r)}return n}Wt.depth.get=function(){return this.frontier.length-1},Jt.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,c=o.depth;s&&c&&1==i.childCount;)i=i.firstChild.content,s--,c--;var a=new u(i,s,c);return e>-1?new Nt(r.pos,e,this.$to.pos,this.$to.end(),a,n):a.size||r.pos!=this.$to.pos?new Dt(r.pos,o.pos,a):void 0},Jt.prototype.findFittable=function(){for(var t=1;t<=2;t++)for(var e=this.unplaced.openStart;e>=0;e--)for(var n=void 0,r=(e?(n=Gt(this.unplaced.content,e-1).firstChild).content:this.unplaced.content).firstChild,i=this.depth;i>=0;i--){var s=this.frontier[i],c=s.type,a=s.match,l=void 0,h=void 0;if(1==t&&(r?a.matchType(r.type)||(h=a.fillBefore(o.from(r),!1)):c.compatibleContent(n.type)))return{sliceDepth:e,frontierDepth:i,parent:n,inject:h};if(2==t&&r&&(l=a.findWrapping(r.type)))return{sliceDepth:e,frontierDepth:i,parent:n,wrap:l};if(n&&a.matchType(n.type))break}},Jt.prototype.openMore=function(){var t=this.unplaced,e=t.content,n=t.openStart,r=t.openEnd,o=Gt(e,n);return!(!o.childCount||o.firstChild.isLeaf||(this.unplaced=new u(e,n+1,Math.max(r,o.size+n>=e.size-r?n+1:0)),0))},Jt.prototype.dropNode=function(){var t=this.unplaced,e=t.content,n=t.openStart,r=t.openEnd,o=Gt(e,n);if(o.childCount<=1&&n>0){var i=e.size-n<=n+o.size;this.unplaced=new u(Kt(e,n-1,1),n-1,i?n-1:r)}else this.unplaced=new u(Kt(e,n,1),n,r)},Jt.prototype.placeNodes=function(t){for(var e=t.sliceDepth,n=t.frontierDepth,r=t.parent,i=t.inject,s=t.wrap;this.depth>n;)this.closeFrontierNode();if(s)for(var c=0;c<s.length;c++)this.openFrontierNode(s[c]);var a=this.unplaced,l=r?r.content:a.content,h=a.openStart-e,d=0,p=[],f=this.frontier[n],g=f.match,m=f.type;if(i){for(var v=0;v<i.childCount;v++)p.push(i.child(v));g=g.matchFragment(i)}for(var y=l.size+e-(a.content.size-a.openEnd);d<l.childCount;){var w=l.child(d),b=g.matchType(w.type);if(!b)break;(++d>1||0==h||w.content.size)&&(g=b,p.push(Yt(w.mark(m.allowedMarks(w.marks)),1==d?h:0,d==l.childCount?y:-1)))}var k=d==l.childCount;k||(y=-1),this.placed=Ht(this.placed,n,o.from(p)),this.frontier[n].match=g,k&&y<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(var S=0,C=l;S<y;S++){var x=C.lastChild;this.frontier.push({type:x.type,match:x.contentMatchAt(x.childCount)}),C=x.content}this.unplaced=k?0==e?u.empty:new u(Kt(a.content,e-1,1),e-1,y<0?a.openEnd:e-1):new u(Kt(a.content,e,d),a.openStart,a.openEnd)},Jt.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||!Xt(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;for(var n=this.$to.depth,r=this.$to.after(n);n>1&&r==this.$to.end(--n);)++r;return r},Jt.prototype.findCloseLevel=function(t){t:for(var e=Math.min(this.depth,t.depth);e>=0;e--){var n=this.frontier[e],r=n.match,o=n.type,i=e<t.depth&&t.end(e+1)==t.pos+(t.depth-(e+1)),s=Xt(t,e,o,r,i);if(s){for(var c=e-1;c>=0;c--){var a=this.frontier[c],l=a.match,h=Xt(t,c,a.type,l,!0);if(!h||h.childCount)continue t}return{depth:e,fit:s,move:i?t.doc.resolve(t.after(e+1)):t}}}},Jt.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=Ht(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},Jt.prototype.openFrontierNode=function(t,e,n){var r=this.frontier[this.depth];r.match=r.match.matchType(t),this.placed=Ht(this.placed,this.depth,o.from(t.create(e,n))),this.frontier.push({type:t,match:t.contentMatch})},Jt.prototype.closeFrontierNode=function(){var t=this.frontier.pop().match.fillBefore(o.empty,!0);t.childCount&&(this.placed=Ht(this.placed,this.frontier.length,t))},Object.defineProperties(Jt.prototype,Wt),Ct.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(Ut(r,o,n))return this.step(new Dt(t,e,n));var i=Zt(r,this.doc.resolve(e));0==i[i.length-1]&&i.pop();var s=-(r.depth+1);i.unshift(s);for(var c=r.depth,a=r.pos-1;c>0;c--,a--){var l=r.node(c).type.spec;if(l.defining||l.isolating)break;i.indexOf(c)>-1?s=c:r.before(c)==a&&i.splice(1,0,-c)}for(var h=i.indexOf(s),d=[],p=n.openStart,f=n.content,g=0;;g++){var m=f.firstChild;if(d.push(m),g==n.openStart)break;f=m.content}p>0&&d[p-1].type.spec.defining&&r.node(h).type!=d[p-1].type?p-=1:p>=2&&d[p-1].isTextblock&&d[p-2].type.spec.defining&&r.node(h).type!=d[p-2].type&&(p-=2);for(var v=n.openStart;v>=0;v--){var y=(v+p+1)%(n.openStart+1),w=d[y];if(w)for(var b=0;b<i.length;b++){var k=i[(b+h)%i.length],S=!0;k<0&&(S=!1,k=-k);var C=r.node(k-1),x=r.index(k-1);if(C.canReplaceWith(x,x,w.type,w.marks))return this.replace(r.before(k),S?o.after(k):e,new u(Qt(n.content,0,n.openStart,y),y,n.openEnd))}}for(var M=this.steps.length,_=i.length-1;_>=0&&(this.replace(t,e,n),!(this.steps.length>M));_--){var E=i[_];E<0||(t=r.before(E),e=o.after(E))}return this},Ct.prototype.replaceRangeWith=function(t,e,n){if(!n.isInline&&t==e&&this.doc.resolve(t).parent.content.size){var r=function(t,e,n){var r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(0==r.parentOffset)for(var o=r.depth-1;o>=0;o--){var i=r.index(o);if(r.node(o).canReplaceWith(i,i,n))return r.before(o+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(var s=r.depth-1;s>=0;s--){var c=r.indexAfter(s);if(r.node(s).canReplaceWith(c,c,n))return r.after(s+1);if(c<r.node(s).childCount)return null}}(this.doc,t,n.type);null!=r&&(t=e=r)}return this.replaceRange(t,e,new u(o.from(n),0,0))},Ct.prototype.deleteRange=function(t,e){for(var n=this.doc.resolve(t),r=this.doc.resolve(e),o=Zt(n,r),i=0;i<o.length;i++){var s=o[i],c=i==o.length-1;if(c&&0==s||n.node(s).type.contentMatch.validEnd)return this.delete(n.start(s),r.end(s));if(s>0&&(c||n.node(s-1).canReplace(n.index(s-1),r.indexAfter(s-1))))return this.delete(n.before(s),r.after(s))}for(var a=1;a<=n.depth&&a<=r.depth;a++)if(t-n.start(a)==n.depth-a&&e>n.end(a)&&r.end(a)-e!=r.depth-a)return this.delete(n.before(a),e);return this.delete(t,e)};var te=Object.create(null),ee=function(t,e,n){this.ranges=n||[new re(t.min(e),t.max(e))],this.$anchor=t,this.$head=e},ne={anchor:{configurable:!0},head:{configurable:!0},from:{configurable:!0},to:{configurable:!0},$from:{configurable:!0},$to:{configurable:!0},empty:{configurable:!0}};ne.anchor.get=function(){return this.$anchor.pos},ne.head.get=function(){return this.$head.pos},ne.from.get=function(){return this.$from.pos},ne.to.get=function(){return this.$to.pos},ne.$from.get=function(){return this.ranges[0].$from},ne.$to.get=function(){return this.ranges[0].$to},ne.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},ee.prototype.content=function(){return this.$from.node(0).slice(this.from,this.to,!0)},ee.prototype.replace=function(t,e){void 0===e&&(e=u.empty);for(var n=e.content.lastChild,r=null,o=0;o<e.openEnd;o++)r=n,n=n.lastChild;for(var i=t.steps.length,s=this.ranges,c=0;c<s.length;c++){var a=s[c],l=a.$from,h=a.$to,d=t.mapping.slice(i);t.replaceRange(d.map(l.pos),d.map(h.pos),c?u.empty:e),0==c&&ue(t,i,(n?n.isInline:r&&r.isTextblock)?-1:1)}},ee.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,c=i.$to,a=t.mapping.slice(n),l=a.map(s.pos),h=a.map(c.pos);o?t.deleteRange(l,h):(t.replaceRangeWith(l,h,e),ue(t,n,e.isInline?-1:1))}},ee.findFrom=function(t,e,n){var r=t.parent.inlineContent?new oe(t):he(t.node(0),t.parent,t.pos,t.index(),e,n);if(r)return r;for(var o=t.depth-1;o>=0;o--){var i=e<0?he(t.node(0),t.node(o),t.before(o+1),t.index(o),e,n):he(t.node(0),t.node(o),t.after(o+1),t.index(o)+1,e,n);if(i)return i}},ee.near=function(t,e){return void 0===e&&(e=1),this.findFrom(t,e)||this.findFrom(t,-e)||new ae(t.node(0))},ee.atStart=function(t){return he(t,t,0,0,1)||new ae(t)},ee.atEnd=function(t){return he(t,t,t.content.size,t.childCount,-1)||new ae(t)},ee.fromJSON=function(t,e){if(!e||!e.type)throw new RangeError("Invalid input for Selection.fromJSON");var n=te[e.type];if(!n)throw new RangeError("No selection type "+e.type+" defined");return n.fromJSON(t,e)},ee.jsonID=function(t,e){if(t in te)throw new RangeError("Duplicate use of selection JSON ID "+t);return te[t]=e,e.prototype.jsonID=t,e},ee.prototype.getBookmark=function(){return oe.between(this.$anchor,this.$head).getBookmark()},Object.defineProperties(ee.prototype,ne),ee.prototype.visible=!0;var re=function(t,e){this.$from=t,this.$to=e},oe=function(t){function e(e,n){void 0===n&&(n=e),t.call(this,e,n)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={$cursor:{configurable:!0}};return n.$cursor.get=function(){return this.$anchor.pos==this.$head.pos?this.$head:null},e.prototype.map=function(n,r){var o=n.resolve(r.map(this.head));if(!o.parent.inlineContent)return t.near(o);var i=n.resolve(r.map(this.anchor));return new e(i.parent.inlineContent?i:o,o)},e.prototype.replace=function(e,n){if(void 0===n&&(n=u.empty),t.prototype.replace.call(this,e,n),n==u.empty){var r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}},e.prototype.eq=function(t){return t instanceof e&&t.anchor==this.anchor&&t.head==this.head},e.prototype.getBookmark=function(){return new ie(this.anchor,this.head)},e.prototype.toJSON=function(){return{type:"text",anchor:this.anchor,head:this.head}},e.fromJSON=function(t,n){if("number"!=typeof n.anchor||"number"!=typeof n.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new e(t.resolve(n.anchor),t.resolve(n.head))},e.create=function(t,e,n){void 0===n&&(n=e);var r=t.resolve(e);return new this(r,n==e?r:t.resolve(n))},e.between=function(n,r,o){var i=n.pos-r.pos;if(o&&!i||(o=i>=0?1:-1),!r.parent.inlineContent){var s=t.findFrom(r,o,!0)||t.findFrom(r,-o,!0);if(!s)return t.near(r,o);r=s.$head}return n.parent.inlineContent||(0==i||(n=(t.findFrom(n,-o,!0)||t.findFrom(n,o,!0)).$anchor).pos<r.pos!=i<0)&&(n=r),new e(n,r)},Object.defineProperties(e.prototype,n),e}(ee);ee.jsonID("text",oe);var ie=function(t,e){this.anchor=t,this.head=e};ie.prototype.map=function(t){return new ie(t.map(this.anchor),t.map(this.head))},ie.prototype.resolve=function(t){return oe.between(t.resolve(this.anchor),t.resolve(this.head))};var se=function(t){function e(e){var n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);t.call(this,e,r),this.node=n}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.map=function(n,r){var o=r.mapResult(this.anchor),i=o.deleted,s=o.pos,c=n.resolve(s);return i?t.near(c):new e(c)},e.prototype.content=function(){return new u(o.from(this.node),0,0)},e.prototype.eq=function(t){return t instanceof e&&t.anchor==this.anchor},e.prototype.toJSON=function(){return{type:"node",anchor:this.anchor}},e.prototype.getBookmark=function(){return new ce(this.anchor)},e.fromJSON=function(t,n){if("number"!=typeof n.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new e(t.resolve(n.anchor))},e.create=function(t,e){return new this(t.resolve(e))},e.isSelectable=function(t){return!t.isText&&!1!==t.type.spec.selectable},e}(ee);se.prototype.visible=!1,ee.jsonID("node",se);var ce=function(t){this.anchor=t};ce.prototype.map=function(t){var e=t.mapResult(this.anchor),n=e.deleted,r=e.pos;return n?new ie(r,r):new ce(r)},ce.prototype.resolve=function(t){var e=t.resolve(this.anchor),n=e.nodeAfter;return n&&se.isSelectable(n)?new se(e):ee.near(e)};var ae=function(t){function e(e){t.call(this,e.resolve(0),e.resolve(e.content.size))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.replace=function(e,n){if(void 0===n&&(n=u.empty),n==u.empty){e.delete(0,e.doc.content.size);var r=t.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else t.prototype.replace.call(this,e,n)},e.prototype.toJSON=function(){return{type:"all"}},e.fromJSON=function(t){return new e(t)},e.prototype.map=function(t){return new e(t)},e.prototype.eq=function(t){return t instanceof e},e.prototype.getBookmark=function(){return le},e}(ee);ee.jsonID("all",ae);var le={map:function(){return this},resolve:function(t){return new ae(t)}};function he(t,e,n,r,o,i){if(e.inlineContent)return oe.create(t,n);for(var s=r-(o>0?0:1);o>0?s<e.childCount:s>=0;s+=o){var c=e.child(s);if(c.isAtom){if(!i&&se.isSelectable(c))return se.create(t,n-(o<0?c.nodeSize:0))}else{var a=he(t,c,n+o,o<0?c.childCount:0,o,i);if(a)return a}n+=c.nodeSize*o}}function ue(t,e,n){var r=t.steps.length-1;if(!(r<e)){var o,i=t.steps[r];(i instanceof Dt||i instanceof Nt)&&(t.mapping.maps[r].forEach((function(t,e,n,r){null==o&&(o=r)})),t.setSelection(ee.near(t.doc.resolve(o),n)))}}var de=function(t){function e(e){t.call(this,e.doc),this.time=Date.now(),this.curSelection=e.selection,this.curSelectionFor=0,this.storedMarks=e.storedMarks,this.updated=0,this.meta=Object.create(null)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={selection:{configurable:!0},selectionSet:{configurable:!0},storedMarksSet:{configurable:!0},isGeneric:{configurable:!0},scrolledIntoView:{configurable:!0}};return n.selection.get=function(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection},e.prototype.setSelection=function(t){if(t.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=t,this.curSelectionFor=this.steps.length,this.updated=-3&(1|this.updated),this.storedMarks=null,this},n.selectionSet.get=function(){return(1&this.updated)>0},e.prototype.setStoredMarks=function(t){return this.storedMarks=t,this.updated|=2,this},e.prototype.ensureMarks=function(t){return l.sameSet(this.storedMarks||this.selection.$from.marks(),t)||this.setStoredMarks(t),this},e.prototype.addStoredMark=function(t){return this.ensureMarks(t.addToSet(this.storedMarks||this.selection.$head.marks()))},e.prototype.removeStoredMark=function(t){return this.ensureMarks(t.removeFromSet(this.storedMarks||this.selection.$head.marks()))},n.storedMarksSet.get=function(){return(2&this.updated)>0},e.prototype.addStep=function(e,n){t.prototype.addStep.call(this,e,n),this.updated=-3&this.updated,this.storedMarks=null},e.prototype.setTime=function(t){return this.time=t,this},e.prototype.replaceSelection=function(t){return this.selection.replace(this,t),this},e.prototype.replaceSelectionWith=function(t,e){var n=this.selection;return!1!==e&&(t=t.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||l.none))),n.replaceWith(this,t),this},e.prototype.deleteSelection=function(){return this.selection.replace(this),this},e.prototype.insertText=function(t,e,n){void 0===n&&(n=e);var r=this.doc.type.schema;if(null==e)return t?this.replaceSelectionWith(r.text(t),!0):this.deleteSelection();if(!t)return this.deleteRange(e,n);var o=this.storedMarks;if(!o){var i=this.doc.resolve(e);o=n==e?i.marks():i.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(e,n,r.text(t,o)),this.selection.empty||this.setSelection(ee.near(this.selection.$to)),this},e.prototype.setMeta=function(t,e){return this.meta["string"==typeof t?t:t.key]=e,this},e.prototype.getMeta=function(t){return this.meta["string"==typeof t?t:t.key]},n.isGeneric.get=function(){for(var t in this.meta)return!1;return!0},e.prototype.scrollIntoView=function(){return this.updated|=4,this},n.scrolledIntoView.get=function(){return(4&this.updated)>0},Object.defineProperties(e.prototype,n),e}(Ct);function pe(t,e){return e&&t?t.bind(e):t}var fe=function(t,e,n){this.name=t,this.init=pe(e.init,n),this.apply=pe(e.apply,n)},ge=[new fe("doc",{init:function(t){return t.doc||t.schema.topNodeType.createAndFill()},apply:function(t){return t.doc}}),new fe("selection",{init:function(t,e){return t.selection||ee.atStart(e.doc)},apply:function(t){return t.selection}}),new fe("storedMarks",{init:function(t){return t.storedMarks||null},apply:function(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new fe("scrollToSelection",{init:function(){return 0},apply:function(t,e){return t.scrolledIntoView?e+1:e}})],me=function(t,e){var n=this;this.schema=t,this.fields=ge.concat(),this.plugins=[],this.pluginsByKey=Object.create(null),e&&e.forEach((function(t){if(n.pluginsByKey[t.key])throw new RangeError("Adding different instances of a keyed plugin ("+t.key+")");n.plugins.push(t),n.pluginsByKey[t.key]=t,t.spec.state&&n.fields.push(new fe(t.key,t.spec.state,t))}))},ve=function(t){this.config=t},ye={schema:{configurable:!0},plugins:{configurable:!0},tr:{configurable:!0}};ye.schema.get=function(){return this.config.schema},ye.plugins.get=function(){return this.config.plugins},ve.prototype.apply=function(t){return this.applyTransaction(t).state},ve.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},ve.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 c=r?r[i].n:0,a=r?r[i].state:this,l=c<e.length&&s.spec.appendTransaction.call(s,c?e.slice(c):e,a,n);if(l&&n.filterTransaction(l,i)){if(l.setMeta("appendedTransaction",t),!r){r=[];for(var h=0;h<this.config.plugins.length;h++)r.push(h<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}}},ve.prototype.applyInner=function(t){if(!t.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");for(var e=new ve(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<we.length;i++)we[i](this,t,e);return e},ye.tr.get=function(){return new de(this)},ve.create=function(t){for(var e=new me(t.doc?t.doc.type.schema:t.schema,t.plugins),n=new ve(e),r=0;r<e.fields.length;r++)n[e.fields[r].name]=e.fields[r].init(t,n);return n},ve.prototype.reconfigure=function(t){for(var e=new me(this.schema,t.plugins),n=e.fields,r=new ve(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},ve.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},ve.fromJSON=function(t,e,n){if(!e)throw new RangeError("Invalid input for EditorState.fromJSON");if(!t.schema)throw new RangeError("Required config field 'schema' missing");var r=new me(t.schema,t.plugins),o=new ve(r);return r.fields.forEach((function(r){if("doc"==r.name)o.doc=T.fromJSON(t.schema,e.doc);else if("selection"==r.name)o.selection=ee.fromJSON(o.doc,e.selection);else if("storedMarks"==r.name)e.storedMarks&&(o.storedMarks=e.storedMarks.map(t.schema.markFromJSON));else{if(n)for(var i in n){var s=n[i],c=s.spec.state;if(s.key==r.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(e,i))return void(o[r.name]=c.fromJSON.call(s,t,e[i],o))}o[r.name]=r.init(t,o)}})),o},ve.addApplyListener=function(t){we.push(t)},ve.removeApplyListener=function(t){var e=we.indexOf(t);e>-1&&we.splice(e,1)},Object.defineProperties(ve.prototype,ye);var we=[];function be(t,e,n){for(var r in t){var o=t[r];o instanceof Function?o=o.bind(e):"handleDOMEvents"==r&&(o=be(o,e,{})),n[r]=o}return n}var ke=function(t){this.props={},t.props&&be(t.props,this,this.props),this.spec=t,this.key=t.key?t.key.key:Ce("plugin")};ke.prototype.getState=function(t){return t[this.key]};var Se=Object.create(null);function Ce(t){return t in Se?t+"$"+ ++Se[t]:(Se[t]=0,t+"$")}var xe=function(t){void 0===t&&(t="key"),this.key=Ce(t)};xe.prototype.get=function(t){return t.config.pluginsByKey[this.key]},xe.prototype.getState=function(t){return t[this.key]};var Me={};if("undefined"!=typeof navigator&&"undefined"!=typeof document){var _e=/Edge\/(\d+)/.exec(navigator.userAgent),Ee=/MSIE \d/.test(navigator.userAgent),Oe=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);Me.mac=/Mac/.test(navigator.platform);var De=Me.ie=!!(Ee||Oe||_e);Me.ie_version=Ee?document.documentMode||6:Oe?+Oe[1]:_e?+_e[1]:null,Me.gecko=!De&&/gecko\/(\d+)/i.test(navigator.userAgent),Me.gecko_version=Me.gecko&&+(/Firefox\/(\d+)/.exec(navigator.userAgent)||[0,0])[1];var Ne=!De&&/Chrome\/(\d+)/.exec(navigator.userAgent);Me.chrome=!!Ne,Me.chrome_version=Ne&&+Ne[1],Me.safari=!De&&/Apple Computer/.test(navigator.vendor),Me.ios=Me.safari&&(/Mobile\/\w+/.test(navigator.userAgent)||navigator.maxTouchPoints>2),Me.android=/Android \d/.test(navigator.userAgent),Me.webkit="webkitFontSmoothing"in document.documentElement.style,Me.webkit_version=Me.webkit&&+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]}var Ae=function(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e},Te=function(t){var e=t.assignedSlot||t.parentNode;return e&&11==e.nodeType?e.host:e},Ie=null,Re=function(t,e,n){var r=Ie||(Ie=document.createRange());return r.setEnd(t,null==n?t.nodeValue.length:n),r.setStart(t,e||0),r},ze=function(t,e,n,r){return n&&(Le(t,e,n,r,-1)||Le(t,e,n,r,1))},Pe=/^(img|br|input|textarea|hr)$/i;function Le(t,e,n,r,o){for(;;){if(t==n&&e==r)return!0;if(e==(o<0?0:Be(t))){var i=t.parentNode;if(1!=i.nodeType||Ve(t)||Pe.test(t.nodeName)||"false"==t.contentEditable)return!1;e=Ae(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?Be(t):0}}}function Be(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function Ve(t){for(var e,n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}var Fe=function(t){var e=t.isCollapsed;return e&&Me.chrome&&t.rangeCount&&!t.getRangeAt(0).collapsed&&(e=!1),e};function $e(t,e){var n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function qe(t){return{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function je(t,e){return"number"==typeof t?t:t[e]}function Ue(t){var e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function Je(t,e,n){for(var r=t.someProp("scrollThreshold")||0,o=t.someProp("scrollMargin")||5,i=t.dom.ownerDocument,s=n||t.dom;s;s=Te(s))if(1==s.nodeType){var c=s==i.body||1!=s.nodeType,a=c?qe(i):Ue(s),l=0,h=0;if(e.top<a.top+je(r,"top")?h=-(a.top-e.top+je(o,"top")):e.bottom>a.bottom-je(r,"bottom")&&(h=e.bottom-a.bottom+je(o,"bottom")),e.left<a.left+je(r,"left")?l=-(a.left-e.left+je(o,"left")):e.right>a.right-je(r,"right")&&(l=e.right-a.right+je(o,"right")),l||h)if(c)i.defaultView.scrollBy(l,h);else{var u=s.scrollLeft,d=s.scrollTop;h&&(s.scrollTop+=h),l&&(s.scrollLeft+=l);var p=s.scrollLeft-u,f=s.scrollTop-d;e={left:e.left-p,top:e.top-f,right:e.right-p,bottom:e.bottom-f}}if(c)break}}function We(t){for(var e=[],n=t.ownerDocument;t&&(e.push({dom:t,top:t.scrollTop,left:t.scrollLeft}),t!=n);t=Te(t));return e}function Ke(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 He=null;function Ge(t,e){for(var n,r,o=2e8,i=0,s=e.top,c=e.top,a=t.firstChild,l=0;a;a=a.nextSibling,l++){var h=void 0;if(1==a.nodeType)h=a.getClientRects();else{if(3!=a.nodeType)continue;h=Re(a).getClientRects()}for(var u=0;u<h.length;u++){var d=h[u];if(d.top<=s&&d.bottom>=c){s=Math.max(d.bottom,s),c=Math.min(d.top,c);var p=d.left>e.left?d.left-e.left:d.right<e.left?e.left-d.right:0;if(p<o){n=a,o=p,r=p&&3==n.nodeType?{left:d.right<e.left?d.right:d.left,top:e.top}:e,1==a.nodeType&&p&&(i=l+(e.left>=(d.left+d.right)/2?1:0));continue}}!n&&(e.left>=d.right&&e.top>=d.top||e.left>=d.left&&e.top>=d.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=Ze(r,1);if(i.top!=i.bottom&&Ye(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}:Ge(n,r)}function Ye(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function Xe(t,e,n){var r=t.childNodes.length;if(r&&n.top<n.bottom)for(var o=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),i=o;;){var s=t.childNodes[i];if(1==s.nodeType)for(var c=s.getClientRects(),a=0;a<c.length;a++){var l=c[a];if(Ye(e,l))return Xe(s,e,l)}if((i=(i+1)%r)==o)break}return t}function Qe(t,e){var n,r,o,i,s=t.dom.ownerDocument;if(s.caretPositionFromPoint)try{var c=s.caretPositionFromPoint(e.left,e.top);c&&(o=(n=c).offsetNode,i=n.offset)}catch(t){}if(!o&&s.caretRangeFromPoint){var a=s.caretRangeFromPoint(e.left,e.top);a&&(o=(r=a).startContainer,i=r.startOffset)}var l,h=(t.root.elementFromPoint?t.root:s).elementFromPoint(e.left,e.top+1);if(!h||!t.dom.contains(1!=h.nodeType?h.parentNode:h)){var u=t.dom.getBoundingClientRect();if(!Ye(e,u))return null;if(!(h=Xe(t.dom,e,u)))return null}if(Me.safari)for(var d=h;o&&d;d=Te(d))d.draggable&&(o=i=null);if(h=function(t,e){var n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}(h,e),o){if(Me.gecko&&1==o.nodeType&&(i=Math.min(i,o.childNodes.length))<o.childNodes.length){var p,f=o.childNodes[i];"IMG"==f.nodeName&&(p=f.getBoundingClientRect()).right<=e.left&&p.bottom>e.top&&i++}o==t.dom&&i==o.childNodes.length-1&&1==o.lastChild.nodeType&&e.top>o.lastChild.getBoundingClientRect().bottom?l=t.state.doc.content.size:0!=i&&1==o.nodeType&&"BR"==o.childNodes[i-1].nodeName||(l=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 c=s.dom.getBoundingClientRect();if(c.left>r.left||c.top>r.top)o=s.posBefore;else{if(!(c.right<r.left||c.bottom<r.top))break;o=s.posAfter}}i=s.dom.parentNode}return o>-1?o:t.docView.posFromDOM(e,n)}(t,o,i,e))}null==l&&(l=function(t,e,n){var r=Ge(e,n),o=r.node,i=r.offset,s=-1;if(1==o.nodeType&&!o.firstChild){var c=o.getBoundingClientRect();s=c.left!=c.right&&n.left>(c.left+c.right)/2?1:-1}return t.docView.posFromDOM(o,i,s)}(t,h,e));var g=t.docView.nearestDesc(h,!0);return{pos:l,inside:g?g.posAtStart-g.border:-1}}function Ze(t,e){var n=t.getClientRects();return n.length?n[e<0?0:n.length-1]:t.getBoundingClientRect()}var tn=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function en(t,e,n){var r=t.docView.domFromPos(e,n<0?-1:1),o=r.node,i=r.offset,s=Me.webkit||Me.gecko;if(3==o.nodeType){if(!s||!tn.test(o.nodeValue)&&(n<0?i:i!=o.nodeValue.length)){var c=i,a=i,l=n<0?1:-1;return n<0&&!i?(a++,l=-1):n>=0&&i==o.nodeValue.length?(c--,l=1):n<0?c--:a++,nn(Ze(Re(o,c,a),l),l<0)}var h=Ze(Re(o,i,i),n);if(Me.gecko&&i&&/\s/.test(o.nodeValue[i-1])&&i<o.nodeValue.length){var u=Ze(Re(o,i-1,i-1),-1);if(u.top==h.top){var d=Ze(Re(o,i,i+1),-1);if(d.top!=h.top)return nn(d,d.left<u.left)}}return h}if(!t.state.doc.resolve(e).parent.inlineContent){if(i&&(n<0||i==Be(o))){var p=o.childNodes[i-1];if(1==p.nodeType)return rn(p.getBoundingClientRect(),!1)}if(i<Be(o)){var f=o.childNodes[i];if(1==f.nodeType)return rn(f.getBoundingClientRect(),!0)}return rn(o.getBoundingClientRect(),n>=0)}if(i&&(n<0||i==Be(o))){var g=o.childNodes[i-1],m=3==g.nodeType?Re(g,Be(g)-(s?0:1)):1!=g.nodeType||"BR"==g.nodeName&&g.nextSibling?null:g;if(m)return nn(Ze(m,1),!1)}if(i<Be(o)){for(var v=o.childNodes[i];v.pmViewDesc&&v.pmViewDesc.ignoreForCoords;)v=v.nextSibling;var y=v?3==v.nodeType?Re(v,0,s?0:1):1==v.nodeType?v:null:null;if(y)return nn(Ze(y,-1),!0)}return nn(Ze(3==o.nodeType?Re(o):o,-n),n>=0)}function nn(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 rn(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 on(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 sn=/[\u0590-\u08ac]/,cn=null,an=null,ln=!1;var hn=function(t,e,n,r){this.parent=t,this.children=e,this.dom=n,n.pmViewDesc=this,this.contentDOM=r,this.dirty=0},un={size:{configurable:!0},border:{configurable:!0},posBefore:{configurable:!0},posAtStart:{configurable:!0},posAfter:{configurable:!0},posAtEnd:{configurable:!0},contentLost:{configurable:!0},domAtom:{configurable:!0},ignoreForCoords:{configurable:!0}};hn.prototype.matchesWidget=function(){return!1},hn.prototype.matchesMark=function(){return!1},hn.prototype.matchesNode=function(){return!1},hn.prototype.matchesHack=function(t){return!1},hn.prototype.parseRule=function(){return null},hn.prototype.stopEvent=function(){return!1},un.size.get=function(){for(var t=0,e=0;e<this.children.length;e++)t+=this.children[e].size;return t},un.border.get=function(){return 0},hn.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()},hn.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}},un.posBefore.get=function(){return this.parent.posBeforeChild(this)},un.posAtStart.get=function(){return this.parent?this.parent.posBeforeChild(this)+this.border:0},un.posAfter.get=function(){return this.posBefore+this.size},un.posAtEnd.get=function(){return this.posAtStart+this.size-2*this.border},hn.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 c;if(t==this.dom&&this.contentDOM)c=e>Ae(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))c=2&t.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==e)for(var a=t;;a=a.parentNode){if(a==this.dom){c=!1;break}if(a.parentNode.firstChild!=a)break}if(null==c&&e==t.childNodes.length)for(var l=t;;l=l.parentNode){if(l==this.dom){c=!0;break}if(l.parentNode.lastChild!=l)break}}return(null==c?n>0:c)?this.posAtEnd:this.posAtStart},hn.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}}},hn.prototype.getDesc=function(t){for(var e=t.pmViewDesc,n=e;n;n=n.parent)if(n==this)return e},hn.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},hn.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}},hn.prototype.domFromPos=function(t,e){if(!this.contentDOM)return{node:this.dom,offset:0};for(var n=0,r=0,o=0;n<this.children.length;n++){var i=this.children[n],s=o+i.size;if(s>t||i instanceof wn){r=t-o;break}o=s}if(r)return this.children[n].domFromPos(r-this.children[n].border,e);for(var c=void 0;n&&!(c=this.children[n-1]).size&&c instanceof pn&&c.widget.type.side>=0;n--);if(e<=0){for(var a,l=!0;(a=n?this.children[n-1]:null)&&a.dom.parentNode!=this.contentDOM;n--,l=!1);return a&&e&&l&&!a.border&&!a.domAtom?a.domFromPos(a.size,e):{node:this.contentDOM,offset:a?Ae(a.dom)+1:0}}for(var h,u=!0;(h=n<this.children.length?this.children[n]:null)&&h.dom.parentNode!=this.contentDOM;n++,u=!1);return h&&u&&!h.border&&!h.domAtom?h.domFromPos(0,e):{node:this.contentDOM,offset:h?Ae(h.dom):this.contentDOM.childNodes.length}},hn.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 c=this.children[s],a=i+c.size;if(-1==r&&t<=a){var l=i+c.border;if(t>=l&&e<=a-c.border&&c.node&&c.contentDOM&&this.contentDOM.contains(c.contentDOM))return c.parseRange(t,e,l);t=i;for(var h=s;h>0;h--){var u=this.children[h-1];if(u.size&&u.dom.parentNode==this.contentDOM&&!u.emptyChildAt(1)){r=Ae(u.dom)+1;break}t-=u.size}-1==r&&(r=0)}if(r>-1&&(a>e||s==this.children.length-1)){e=a;for(var d=s+1;d<this.children.length;d++){var p=this.children[d];if(p.size&&p.dom.parentNode==this.contentDOM&&!p.emptyChildAt(-1)){o=Ae(p.dom);break}e+=p.size}-1==o&&(o=this.contentDOM.childNodes.length);break}i=a}return{node:this.contentDOM,from:t,to:e,fromOffset:r,toOffset:o}},hn.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)},hn.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]},hn.prototype.setSelection=function(t,e,n,r){for(var o=Math.min(t,e),i=Math.max(t,e),s=0,c=0;s<this.children.length;s++){var a=this.children[s],l=c+a.size;if(o>c&&i<l)return a.setSelection(t-c-a.border,e-c-a.border,n,r);c=l}var h=this.domFromPos(t,t?-1:1),u=e==t?h:this.domFromPos(e,e?-1:1),d=n.getSelection(),p=!1;if((Me.gecko||Me.safari)&&t==e){var f=h.node,g=h.offset;if(3==f.nodeType){if((p=g&&"\n"==f.nodeValue[g-1])&&g==f.nodeValue.length)for(var m=f,v=void 0;m;m=m.parentNode){if(v=m.nextSibling){"BR"==v.nodeName&&(h=u={node:v.parentNode,offset:Ae(v)+1});break}var y=m.pmViewDesc;if(y&&y.node&&y.node.isBlock)break}}else{var w=f.childNodes[g-1];p=w&&("BR"==w.nodeName||"false"==w.contentEditable)}}if(Me.gecko&&d.focusNode&&d.focusNode!=u.node&&1==d.focusNode.nodeType){var b=d.focusNode.childNodes[d.focusOffset];b&&"false"==b.contentEditable&&(r=!0)}if(r||p&&Me.safari||!ze(h.node,h.offset,d.anchorNode,d.anchorOffset)||!ze(u.node,u.offset,d.focusNode,d.focusOffset)){var k=!1;if((d.extend||t==e)&&!p){d.collapse(h.node,h.offset);try{t!=e&&d.extend(u.node,u.offset),k=!0}catch(t){if(!(t instanceof DOMException))throw t}}if(!k){if(t>e){var S=h;h=u,u=S}var C=document.createRange();C.setEnd(u.node,u.offset),C.setStart(h.node,h.offset),d.removeAllRanges(),d.addRange(C)}}},hn.prototype.ignoreMutation=function(t){return!this.contentDOM&&"selection"!=t.type},un.contentLost.get=function(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)},hn.prototype.markDirty=function(t,e){for(var n=0,r=0;r<this.children.length;r++){var o=this.children[r],i=n+o.size;if(n==i?t<=i&&e>=n:t<i&&e>n){var s=n+o.border,c=i-o.border;if(t>=s&&e<=c)return this.dirty=t==n||e==i?2:1,void(t!=s||e!=c||!o.contentLost&&o.dom.parentNode==this.contentDOM?o.markDirty(t-s,e-s):o.dirty=3);o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM?2:3}n=i}this.dirty=2},hn.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)}},un.domAtom.get=function(){return!1},un.ignoreForCoords.get=function(){return!1},Object.defineProperties(hn.prototype,un);var dn=[],pn=function(t){function e(e,n,r,o){var i,s=n.type.toDOM;if("function"==typeof s&&(s=s(r,(function(){return i?i.parent?i.parent.posBeforeChild(i):void 0:o}))),!n.type.spec.raw){if(1!=s.nodeType){var c=document.createElement("span");c.appendChild(s),s=c}s.contentEditable=!1,s.classList.add("ProseMirror-widget")}t.call(this,e,dn,s,null),this.widget=n,i=this}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={domAtom:{configurable:!0}};return e.prototype.matchesWidget=function(t){return 0==this.dirty&&t.type.eq(this.widget.type)},e.prototype.parseRule=function(){return{ignore:!0}},e.prototype.stopEvent=function(t){var e=this.widget.spec.stopEvent;return!!e&&e(t)},e.prototype.ignoreMutation=function(t){return"selection"!=t.type||this.widget.spec.ignoreSelection},n.domAtom.get=function(){return!0},Object.defineProperties(e.prototype,n),e}(hn),fn=function(t){function e(e,n,r,o){t.call(this,e,dn,n,null),this.textDOM=r,this.text=o}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={size:{configurable:!0}};return n.size.get=function(){return this.text.length},e.prototype.localPosFromDOM=function(t,e){return t!=this.textDOM?this.posAtStart+(e?this.size:0):this.posAtStart+e},e.prototype.domFromPos=function(t){return{node:this.textDOM,offset:t}},e.prototype.ignoreMutation=function(t){return"characterData"===t.type&&t.target.nodeValue==t.oldValue},Object.defineProperties(e.prototype,n),e}(hn),gn=function(t){function e(e,n,r,o){t.call(this,e,[],r,o),this.mark=n}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.create=function(t,n,r,o){var i=o.nodeViews[n.type.name],s=i&&i(n,o,r);return s&&s.dom||(s=ft.renderSpec(document,n.type.spec.toDOM(n,r))),new e(t,n,s.dom,s.contentDOM||s.dom)},e.prototype.parseRule=function(){return{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}},e.prototype.matchesMark=function(t){return 3!=this.dirty&&this.mark.eq(t)},e.prototype.markDirty=function(e,n){if(t.prototype.markDirty.call(this,e,n),0!=this.dirty){for(var r=this.parent;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=0}},e.prototype.slice=function(t,n,r){var o=e.create(this.parent,this.mark,!0,r),i=this.children,s=this.size;n<s&&(i=Tn(i,n,s,r)),t>0&&(i=Tn(i,0,t,r));for(var c=0;c<i.length;c++)i[c].parent=o;return o.children=i,o},e}(hn),mn=function(t){function e(e,n,r,o,i,s,c,a,l){t.call(this,e,n.isLeaf?dn:[],i,s),this.nodeDOM=c,this.node=n,this.outerDeco=r,this.innerDeco=o,s&&this.updateChildren(a,l)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={size:{configurable:!0},border:{configurable:!0},domAtom:{configurable:!0}};return e.create=function(t,n,r,o,i,s){var c,a,l=i.nodeViews[n.type.name],h=l&&l(n,i,(function(){return a?a.parent?a.parent.posBeforeChild(a):void 0:s}),r,o),u=h&&h.dom,d=h&&h.contentDOM;if(n.isText)if(u){if(3!=u.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else u=document.createTextNode(n.text);else u||(u=(c=ft.renderSpec(document,n.type.spec.toDOM(n))).dom,d=c.contentDOM);d||n.isText||"BR"==u.nodeName||(u.hasAttribute("contenteditable")||(u.contentEditable=!1),n.type.spec.draggable&&(u.draggable=!0));var p=u;return u=En(u,r,n),h?a=new bn(t,n,r,o,u,d,p,h,i,s+1):n.isText?new yn(t,n,r,o,u,p,i):new e(t,n,r,o,u,d,p,i,s+1)},e.prototype.parseRule=function(){var t=this;if(this.node.type.spec.reparseInView)return null;var e={node:this.node.type.name,attrs:this.node.attrs};return this.node.type.spec.code&&(e.preserveWhitespace="full"),this.contentDOM&&!this.contentLost?e.contentElement=this.contentDOM:e.getContent=function(){return t.contentDOM?o.empty:t.node.content},e},e.prototype.matchesNode=function(t,e,n){return 0==this.dirty&&t.eq(this.node)&&On(e,this.outerDeco)&&n.eq(this.innerDeco)},n.size.get=function(){return this.node.nodeSize},n.border.get=function(){return this.node.isLeaf?0:1},e.prototype.updateChildren=function(t,e){var n=this,r=this.node.inlineContent,o=e,i=t.composing&&this.localCompositionInfo(t,e),s=i&&i.pos>-1?i:null,c=i&&i.pos<0,a=new Nn(this,s&&s.node);!function(t,e,n,r){var o=e.locals(t),i=0;if(0!=o.length)for(var s=0,c=[],a=null,l=0;;){if(s<o.length&&o[s].to==i){for(var h=o[s++],u=void 0;s<o.length&&o[s].to==i;)(u||(u=[h])).push(o[s++]);if(u){u.sort(An);for(var d=0;d<u.length;d++)n(u[d],l,!!a)}else n(h,l,!!a)}var p=void 0,f=void 0;if(a)f=-1,p=a,a=null;else{if(!(l<t.childCount))break;f=l,p=t.child(l++)}for(var g=0;g<c.length;g++)c[g].to<=i&&c.splice(g--,1);for(;s<o.length&&o[s].from<=i&&o[s].to>i;)c.push(o[s++]);var m=i+p.nodeSize;if(p.isText){var v=m;s<o.length&&o[s].from<v&&(v=o[s].from);for(var y=0;y<c.length;y++)c[y].to<v&&(v=c[y].to);v<m&&(a=p.cut(v-i),p=p.cut(0,v-i),m=v,f=-1)}r(p,c.length?p.isInline&&!p.isLeaf?c.filter((function(t){return!t.inline})):c.slice():dn,e.forChild(i,p),f),i=m}else for(var w=0;w<t.childCount;w++){var b=t.child(w);r(b,o,e.forChild(i,b),w),i+=b.nodeSize}}(this.node,this.innerDeco,(function(e,i,s){e.spec.marks?a.syncToMarks(e.spec.marks,r,t):e.type.side>=0&&!s&&a.syncToMarks(i==n.node.childCount?l.none:n.node.child(i).marks,r,t),a.placeWidget(e,t,o)}),(function(e,n,s,l){var h;a.syncToMarks(e.marks,r,t),a.findNodeMatch(e,n,s,l)||c&&t.state.selection.from>o&&t.state.selection.to<o+e.nodeSize&&(h=a.findIndexWithChild(i.node))>-1&&a.updateNodeAt(e,n,s,h,t)||a.updateNextNode(e,n,s,t,l)||a.addNode(e,n,s,t,o),o+=e.nodeSize})),a.syncToMarks(dn,r,t),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||2==this.dirty)&&(s&&this.protectLocalComposition(t,s),kn(this.contentDOM,this.children,t),Me.ios&&function(t){if("UL"==t.nodeName||"OL"==t.nodeName){var e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}(this.dom))},e.prototype.localCompositionInfo=function(t,e){var n=t.state.selection,r=n.from,o=n.to;if(!(!(t.state.selection instanceof oe)||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&&e>0){if(t.childNodes.length>e&&3==t.childNodes[e].nodeType)return t.childNodes[e];e=Be(t=t.childNodes[e-1])}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)){if(this.node.inlineContent){var c=s.nodeValue,a=function(t,e,n,r){for(var o=0,i=0;o<t.childCount&&i<=r;){var s=t.child(o++),c=i;if(i+=s.nodeSize,s.isText){for(var a=s.text;o<t.childCount;){var l=t.child(o++);if(i+=l.nodeSize,!l.isText)break;a+=l.text}if(i>=n){var h=a.lastIndexOf(e,r-c);if(h>=0&&h+e.length+c>=n)return c+h}}}return-1}(this.node.content,c,r-e,o-e);return a<0?null:{node:s,pos:a,text:c}}return{node:s,pos:-1}}}},e.prototype.protectLocalComposition=function(t,e){var n=e.node,r=e.pos,o=e.text;if(!this.getDesc(n)){for(var i=n;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=null)}var s=new fn(this,i,n,o);t.compositionNodes.push(s),this.children=Tn(this.children,r,r+o.length,t,s)}},e.prototype.update=function(t,e,n,r){return!(3==this.dirty||!t.sameMarkup(this.node)||(this.updateInner(t,e,n,r),0))},e.prototype.updateInner=function(t,e,n,r){this.updateOuterDeco(e),this.node=t,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=0},e.prototype.updateOuterDeco=function(t){if(!On(t,this.outerDeco)){var e=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=Mn(this.dom,this.nodeDOM,xn(this.outerDeco,this.node,e),xn(t,this.node,e)),this.dom!=n&&(n.pmViewDesc=null,this.dom.pmViewDesc=this),this.outerDeco=t}},e.prototype.selectNode=function(){this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.dom.draggable=!0)},e.prototype.deselectNode=function(){this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||this.dom.removeAttribute("draggable")},n.domAtom.get=function(){return this.node.isAtom},Object.defineProperties(e.prototype,n),e}(hn);function vn(t,e,n,r,o){return En(r,e,t),new mn(null,t,e,n,r,r,r,o,0)}var yn=function(t){function e(e,n,r,o,i,s,c){t.call(this,e,n,r,o,i,null,s,c)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={domAtom:{configurable:!0}};return e.prototype.parseRule=function(){for(var t=this.nodeDOM.parentNode;t&&t!=this.dom&&!t.pmIsDeco;)t=t.parentNode;return{skip:t||!0}},e.prototype.update=function(t,e,n,r){return!(3==this.dirty||0!=this.dirty&&!this.inParent()||!t.sameMarkup(this.node)||(this.updateOuterDeco(e),0==this.dirty&&t.text==this.node.text||t.text==this.nodeDOM.nodeValue||(this.nodeDOM.nodeValue=t.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=t,this.dirty=0,0))},e.prototype.inParent=function(){for(var t=this.parent.contentDOM,e=this.nodeDOM;e;e=e.parentNode)if(e==t)return!0;return!1},e.prototype.domFromPos=function(t){return{node:this.nodeDOM,offset:t}},e.prototype.localPosFromDOM=function(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):t.prototype.localPosFromDOM.call(this,e,n,r)},e.prototype.ignoreMutation=function(t){return"characterData"!=t.type&&"selection"!=t.type},e.prototype.slice=function(t,n,r){var o=this.node.cut(t,n),i=document.createTextNode(o.text);return new e(this.parent,o,this.outerDeco,this.innerDeco,i,i,r)},e.prototype.markDirty=function(e,n){t.prototype.markDirty.call(this,e,n),this.dom==this.nodeDOM||0!=e&&n!=this.nodeDOM.nodeValue.length||(this.dirty=3)},n.domAtom.get=function(){return!1},Object.defineProperties(e.prototype,n),e}(mn),wn=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={domAtom:{configurable:!0},ignoreForCoords:{configurable:!0}};return e.prototype.parseRule=function(){return{ignore:!0}},e.prototype.matchesHack=function(t){return 0==this.dirty&&this.dom.nodeName==t},n.domAtom.get=function(){return!0},n.ignoreForCoords.get=function(){return"IMG"==this.dom.nodeName},Object.defineProperties(e.prototype,n),e}(hn),bn=function(t){function e(e,n,r,o,i,s,c,a,l,h){t.call(this,e,n,r,o,i,s,c,l,h),this.spec=a}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.update=function(e,n,r,o){if(3==this.dirty)return!1;if(this.spec.update){var i=this.spec.update(e,n,r);return i&&this.updateInner(e,n,r,o),i}return!(!this.contentDOM&&!e.isLeaf)&&t.prototype.update.call(this,e,n,r,o)},e.prototype.selectNode=function(){this.spec.selectNode?this.spec.selectNode():t.prototype.selectNode.call(this)},e.prototype.deselectNode=function(){this.spec.deselectNode?this.spec.deselectNode():t.prototype.deselectNode.call(this)},e.prototype.setSelection=function(e,n,r,o){this.spec.setSelection?this.spec.setSelection(e,n,r):t.prototype.setSelection.call(this,e,n,r,o)},e.prototype.destroy=function(){this.spec.destroy&&this.spec.destroy(),t.prototype.destroy.call(this)},e.prototype.stopEvent=function(t){return!!this.spec.stopEvent&&this.spec.stopEvent(t)},e.prototype.ignoreMutation=function(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):t.prototype.ignoreMutation.call(this,e)},e}(mn);function kn(t,e,n){for(var r=t.firstChild,o=!1,i=0;i<e.length;i++){var s=e[i],c=s.dom;if(c.parentNode==t){for(;c!=r;)r=Dn(r),o=!0;r=r.nextSibling}else o=!0,t.insertBefore(c,r);if(s instanceof gn){var a=r?r.previousSibling:t.lastChild;kn(s.contentDOM,s.children,n),r=a?a.nextSibling:t.firstChild}}for(;r;)r=Dn(r),o=!0;o&&n.trackWrites==t&&(n.trackWrites=null)}function Sn(t){t&&(this.nodeName=t)}Sn.prototype=Object.create(null);var Cn=[new Sn];function xn(t,e,n){if(0==t.length)return Cn;for(var r=n?Cn[0]:new Sn,o=[r],i=0;i<t.length;i++){var s=t[i].type.attrs;if(s)for(var c in s.nodeName&&o.push(r=new Sn(s.nodeName)),s){var a=s[c];null!=a&&(n&&1==o.length&&o.push(r=new Sn(e.isInline?"span":"div")),"class"==c?r.class=(r.class?r.class+" ":"")+a:"style"==c?r.style=(r.style?r.style+";":"")+a:"nodeName"!=c&&(r[c]=a))}}return o}function Mn(t,e,n,r){if(n==Cn&&r==Cn)return e;for(var o=e,i=0;i<r.length;i++){var s=r[i],c=n[i];if(i){var a=void 0;c&&c.nodeName==s.nodeName&&o!=t&&(a=o.parentNode)&&a.tagName.toLowerCase()==s.nodeName||((a=document.createElement(s.nodeName)).pmIsDeco=!0,a.appendChild(o),c=Cn[0]),o=a}_n(o,c||Cn[0],s)}return o}function _n(t,e,n){for(var r in e)"class"==r||"style"==r||"nodeName"==r||r in n||t.removeAttribute(r);for(var o in n)"class"!=o&&"style"!=o&&"nodeName"!=o&&n[o]!=e[o]&&t.setAttribute(o,n[o]);if(e.class!=n.class){for(var i=e.class?e.class.split(" ").filter(Boolean):dn,s=n.class?n.class.split(" ").filter(Boolean):dn,c=0;c<i.length;c++)-1==s.indexOf(i[c])&&t.classList.remove(i[c]);for(var a=0;a<s.length;a++)-1==i.indexOf(s[a])&&t.classList.add(s[a])}if(e.style!=n.style){if(e.style)for(var l,h=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;l=h.exec(e.style);)t.style.removeProperty(l[1]);n.style&&(t.style.cssText+=n.style)}}function En(t,e,n){return Mn(t,t,Cn,xn(e,n,1!=t.nodeType))}function On(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 Dn(t){var e=t.nextSibling;return t.parentNode.removeChild(t),e}var Nn=function(t,e){this.top=t,this.lock=e,this.index=0,this.stack=[],this.changed=!1,this.preMatch=function(t,e){for(var n=t.childCount,r=e.length,o=new Map;n>0&&r>0;r--){var i=e[r-1],s=i.node;if(s){if(s!=t.child(n-1))break;--n,o.set(i,n)}}return{index:n,matched:o}}(t.node.content,t.children)};function An(t,e){return t.type.side-e.type.side}function Tn(t,e,n,r,o){for(var i=[],s=0,c=0;s<t.length;s++){var a=t[s],l=c,h=c+=a.size;l>=n||h<=e?i.push(a):(l<e&&i.push(a.slice(0,e-l,r)),o&&(i.push(o),o=null),h>n&&i.push(a.slice(n-l,a.size,r)))}return i}function In(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 c,a,l=r.resolve(s);if(Fe(n)){for(c=l;o&&!o.node;)o=o.parent;if(o&&o.node.isAtom&&se.isSelectable(o.node)&&o.parent&&(!o.node.isInline||!function(t,e,n){for(var r=0==e,o=e==Be(t);r||o;){if(t==n)return!0;var i=Ae(t);if(!(t=t.parentNode))return!1;r=r&&0==i,o=o&&i==Be(t)}}(n.focusNode,n.focusOffset,o.dom))){var h=o.posBefore;a=new se(s==h?l:r.resolve(h))}}else{var u=t.docView.posFromDOM(n.anchorNode,n.anchorOffset);if(u<0)return null;c=r.resolve(u)}return a||(a=qn(t,c,l,"pointer"==e||t.state.selection.head<l.pos&&!i?1:-1)),a}function Rn(t){return t.editable?t.hasFocus():jn(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function zn(t,e){var n=t.state.selection;if(Fn(t,n),Rn(t)){if(!e&&t.mouseDown&&t.mouseDown.allowDefault)return t.mouseDown.delayedSelectionSync=!0,void t.domObserver.setCurSelection();if(t.domObserver.disconnectSelection(),t.cursorWrapper)!function(t){var e=t.root.getSelection(),n=document.createRange(),r=t.cursorWrapper.dom,o="IMG"==r.nodeName;o?n.setEnd(r.parentNode,Ae(r)+1):n.setEnd(r,0),n.collapse(!1),e.removeAllRanges(),e.addRange(n),!o&&!t.state.selection.visible&&Me.ie&&Me.ie_version<=11&&(r.disabled=!0,r.disabled=!1)}(t);else{var r,o,i=n.anchor,s=n.head;!Pn||n instanceof oe||(n.$from.parent.inlineContent||(r=Ln(t,n.from)),n.empty||n.$from.parent.inlineContent||(o=Ln(t,n.to))),t.docView.setSelection(i,s,t.root,e),Pn&&(r&&Vn(r),o&&Vn(o)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(t){var e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.hideSelectionGuard);var n=t.root.getSelection(),r=n.anchorNode,o=n.anchorOffset;e.addEventListener("selectionchange",t.hideSelectionGuard=function(){n.anchorNode==r&&n.anchorOffset==o||(e.removeEventListener("selectionchange",t.hideSelectionGuard),setTimeout((function(){Rn(t)&&!t.state.selection.visible||t.dom.classList.remove("ProseMirror-hideselection")}),20))})}(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}Nn.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}},Nn.prototype.destroyRest=function(){this.destroyBetween(this.index,this.top.children.length)},Nn.prototype.syncToMarks=function(t,e,n){for(var r=0,o=this.stack.length>>1,i=Math.min(o,t.length);r<i&&(r==o-1?this.top:this.stack[r+1<<1]).matchesMark(t[r])&&!1!==t[r].type.spec.spanning;)r++;for(;r<o;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<t.length;){this.stack.push(this.top,this.index+1);for(var s=-1,c=this.index;c<Math.min(this.index+3,this.top.children.length);c++)if(this.top.children[c].matchesMark(t[o])){s=c;break}if(s>-1)s>this.index&&(this.changed=!0,this.destroyBetween(this.index,s)),this.top=this.top.children[this.index];else{var a=gn.create(this.top,t[o],e,n);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,o++}},Nn.prototype.findNodeMatch=function(t,e,n,r){var o=this.top.children,i=-1;if(r>=this.preMatch.index){for(var s=this.index;s<o.length;s++)if(o[s].matchesNode(t,e,n)){i=s;break}}else for(var c=this.index,a=Math.min(o.length,c+1);c<a;c++){var l=o[c];if(l.matchesNode(t,e,n)&&!this.preMatch.matched.has(l)){i=c;break}}return!(i<0||(this.destroyBetween(this.index,i),this.index++,0))},Nn.prototype.updateNodeAt=function(t,e,n,r,o){return!!this.top.children[r].update(t,e,n,o)&&(this.destroyBetween(this.index,r),this.index=r+1,!0)},Nn.prototype.findIndexWithChild=function(t){for(;;){var e=t.parentNode;if(!e)return-1;if(e==this.top.contentDOM){var n=t.pmViewDesc;if(n)for(var r=this.index;r<this.top.children.length;r++)if(this.top.children[r]==n)return r;return-1}t=e}},Nn.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 mn){var c=this.preMatch.matched.get(s);if(null!=c&&c!=o)return!1;var a=s.dom;if((!this.lock||!(a==this.lock||1==a.nodeType&&a.contains(this.lock.parentNode))||t.isText&&s.node&&s.node.isText&&s.nodeDOM.nodeValue==t.text&&3!=s.dirty&&On(e,s.outerDeco))&&s.update(t,e,n,r))return this.destroyBetween(this.index,i),s.dom!=a&&(this.changed=!0),this.index++,!0;break}}return!1},Nn.prototype.addNode=function(t,e,n,r,o){this.top.children.splice(this.index++,0,mn.create(this.top,t,e,n,r,o)),this.changed=!0},Nn.prototype.placeWidget=function(t,e,n){var r=this.index<this.top.children.length?this.top.children[this.index]:null;if(!r||!r.matchesWidget(t)||t!=r.widget&&r.widget.type.toDOM.parentNode){var o=new pn(this.top,t,e,n);this.top.children.splice(this.index++,0,o),this.changed=!0}else this.index++},Nn.prototype.addTextblockHacks=function(){for(var t=this.top.children[this.index-1];t instanceof gn;)t=t.children[t.children.length-1];t&&t instanceof yn&&!/\n$/.test(t.node.text)||((Me.safari||Me.chrome)&&t&&"false"==t.dom.contentEditable&&this.addHackNode("IMG"),this.addHackNode("BR"))},Nn.prototype.addHackNode=function(t){if(this.index<this.top.children.length&&this.top.children[this.index].matchesHack(t))this.index++;else{var e=document.createElement(t);"IMG"==t&&(e.className="ProseMirror-separator"),"BR"==t&&(e.className="ProseMirror-trailingBreak"),this.top.children.splice(this.index++,0,new wn(this.top,dn,e,null)),this.changed=!0}};var Pn=Me.safari||Me.chrome&&Me.chrome_version<63;function Ln(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(Me.safari&&i&&"false"==i.contentEditable)return Bn(i);if(!(i&&"false"!=i.contentEditable||s&&"false"!=s.contentEditable)){if(i)return Bn(i);if(s)return Bn(s)}}function Bn(t){return t.contentEditable="true",Me.safari&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function Vn(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function Fn(t,e){if(e instanceof se){var n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&($n(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else $n(t)}function $n(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=null)}function qn(t,e,n,r){return t.someProp("createSelectionBetween",(function(r){return r(t,e,n)}))||oe.between(e,n,r)}function jn(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 Un(t,e){var n=t.selection,r=n.$anchor,o=n.$head,i=e>0?r.max(o):r.min(o),s=i.parent.inlineContent?i.depth?t.doc.resolve(e>0?i.after():i.before()):null:i;return s&&ee.findFrom(s,e)}function Jn(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function Wn(t,e,n){var r=t.state.selection;if(!(r instanceof oe)){if(r instanceof se&&r.node.isInline)return Jn(t,new oe(e>0?r.$to:r.$from));var o=Un(t.state,e);return!!o&&Jn(t,o)}if(!r.empty||n.indexOf("s")>-1)return!1;if(t.endOfTextblock(e>0?"right":"left")){var i=Un(t.state,e);return!!(i&&i instanceof se)&&Jn(t,i)}if(!(Me.mac&&n.indexOf("m")>-1)){var s,c=r.$head,a=c.textOffset?null:e<0?c.nodeBefore:c.nodeAfter;if(!a||a.isText)return!1;var l=e<0?c.pos-a.nodeSize:c.pos;return!!(a.isAtom||(s=t.docView.descAt(l))&&!s.contentDOM)&&(se.isSelectable(a)?Jn(t,new se(e<0?t.state.doc.resolve(c.pos-a.nodeSize):c)):!!Me.webkit&&Jn(t,new oe(t.state.doc.resolve(e<0?l:l+a.nodeSize))))}}function Kn(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function Hn(t){var e=t.pmViewDesc;return e&&0==e.size&&(t.nextSibling||"BR"!=t.nodeName)}function Gn(t){var e=t.root.getSelection(),n=e.focusNode,r=e.focusOffset;if(n){var o,i,s=!1;for(Me.gecko&&1==n.nodeType&&r<Kn(n)&&Hn(n.childNodes[r])&&(s=!0);;)if(r>0){if(1!=n.nodeType)break;var c=n.childNodes[r-1];if(Hn(c))o=n,i=--r;else{if(3!=c.nodeType)break;r=(n=c).nodeValue.length}}else{if(Xn(n))break;for(var a=n.previousSibling;a&&Hn(a);)o=n.parentNode,i=Ae(a),a=a.previousSibling;if(a)r=Kn(n=a);else{if((n=n.parentNode)==t.dom)break;r=0}}s?Qn(t,e,n,r):o&&Qn(t,e,o,i)}}function Yn(t){var e=t.root.getSelection(),n=e.focusNode,r=e.focusOffset;if(n){for(var o,i,s=Kn(n);;)if(r<s){if(1!=n.nodeType)break;if(!Hn(n.childNodes[r]))break;o=n,i=++r}else{if(Xn(n))break;for(var c=n.nextSibling;c&&Hn(c);)o=c.parentNode,i=Ae(c)+1,c=c.nextSibling;if(c)r=0,s=Kn(n=c);else{if((n=n.parentNode)==t.dom)break;r=s=0}}o&&Qn(t,e,o,i)}}function Xn(t){var e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function Qn(t,e,n,r){if(Fe(e)){var o=document.createRange();o.setEnd(n,r),o.setStart(n,r),e.removeAllRanges(),e.addRange(o)}else e.extend&&e.extend(n,r);t.domObserver.setCurSelection();var i=t.state;setTimeout((function(){t.state==i&&zn(t)}),50)}function Zn(t,e,n){var r=t.state.selection;if(r instanceof oe&&!r.empty||n.indexOf("s")>-1)return!1;if(Me.mac&&n.indexOf("m")>-1)return!1;var o=r.$from,i=r.$to;if(!o.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){var s=Un(t.state,e);if(s&&s instanceof se)return Jn(t,s)}if(!o.parent.inlineContent){var c=e<0?o:i,a=r instanceof ae?ee.near(c,e):ee.findFrom(c,e);return!!a&&Jn(t,a)}return!1}function tr(t,e){if(!(t.state.selection instanceof oe))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(e>0?"forward":"backward"))return!0;var s=!r.textOffset&&(e<0?r.nodeBefore:r.nodeAfter);if(s&&!s.isText){var c=t.state.tr;return e<0?c.delete(r.pos-s.nodeSize,r.pos):c.delete(r.pos,r.pos+s.nodeSize),t.dispatch(c),!0}return!1}function er(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function nr(t){var e=t.pmViewDesc;if(e)return e.parseRule();if("BR"==t.nodeName&&t.parentNode){if(Me.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||Me.safari&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if("IMG"==t.nodeName&&t.getAttribute("mark-placeholder"))return{ignore:!0}}function rr(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:qn(t,e.resolve(n.anchor),e.resolve(n.head))}function or(t,e,n){for(var r=t.depth,o=e?t.end():t.pos;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,o++,e=!1;if(n)for(var i=t.node(r).maybeChild(t.indexAfter(r));i&&!i.isLeaf;)i=i.firstChild,o++;return o}function ir(t,e){for(var n=[],r=e.content,o=e.openStart,i=e.openEnd;o>1&&i>1&&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 c=t.someProp("clipboardSerializer")||ft.fromSchema(t.state.schema),a=fr(),l=a.createElement("div");l.appendChild(c.serializeFragment(r,{document:a}));for(var h,u=l.firstChild;u&&1==u.nodeType&&(h=dr[u.nodeName.toLowerCase()]);){for(var d=h.length-1;d>=0;d--){for(var p=a.createElement(h[d]);l.firstChild;)p.appendChild(l.firstChild);l.appendChild(p),"tbody"!=h[d]&&(o++,i++)}u=l.firstChild}return u&&1==u.nodeType&&u.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 sr(t,e,n,r,i){var s,c,a=i.parent.type.spec.code;if(!n&&!e)return null;var l=e&&(r||a||!n);if(l){if(t.someProp("transformPastedText",(function(t){e=t(e,a||r)})),a)return e?new u(o.from(t.state.schema.text(e.replace(/\r\n?/g,"\n"))),0,0):u.empty;var h=t.someProp("clipboardTextParser",(function(t){return t(e,i,r)}));if(h)c=h;else{var d=i.marks(),p=t.state.schema,f=ft.fromSchema(p);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach((function(t){var e=s.appendChild(document.createElement("p"));t&&e.appendChild(f.serializeNode(p.text(t,d)))}))}}else t.someProp("transformPastedHTML",(function(t){n=t(n)})),s=function(t){var e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));var n,r=fr().createElement("div"),o=/<([a-z][^>\s]+)/i.exec(t);if((n=o&&dr[o[1].toLowerCase()])&&(t=n.map((function(t){return"<"+t+">"})).join("")+t+n.map((function(t){return"</"+t+">"})).reverse().join("")),r.innerHTML=t,n)for(var i=0;i<n.length;i++)r=r.querySelector(n[i])||r;return r}(n),Me.webkit&&function(t){for(var e=t.querySelectorAll(Me.chrome?"span:not([class]):not([style])":"span.Apple-converted-space"),n=0;n<e.length;n++){var r=e[n];1==r.childNodes.length&&" "==r.textContent&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}(s);var g=s&&s.querySelector("[data-pm-slice]"),m=g&&/^(\d+) (\d+) (.*)/.exec(g.getAttribute("data-pm-slice"));if(!c){var v=t.someProp("clipboardParser")||t.someProp("domParser")||rt.fromSchema(t.state.schema);c=v.parseSlice(s,{preserveWhitespace:!(!l&&!m),context:i})}if(m)c=function(t,e){if(!t.size)return t;var n,r=t.content.firstChild.type.schema;try{n=JSON.parse(e)}catch(e){return t}for(var i=t.content,s=t.openStart,c=t.openEnd,a=n.length-2;a>=0;a-=2){var l=r.nodes[n[a]];if(!l||l.hasRequiredAttrs())break;i=o.from(l.create(n[a+1],i)),s++,c++}return new u(i,s,c)}(ur(c,+m[1],+m[2]),m[3]);else if(c=u.maxOpen(function(t,e){if(t.childCount<2)return t;for(var n=function(n){var r=e.node(n).contentMatchAt(e.index(n)),i=void 0,s=[];if(t.forEach((function(t){if(s){var e,n=r.findWrapping(t.type);if(!n)return s=null;if(e=s.length&&i.length&&ar(n,i,t,s[s.length-1],0))s[s.length-1]=e;else{s.length&&(s[s.length-1]=lr(s[s.length-1],i.length));var o=cr(t,n);s.push(o),r=r.matchType(o.type,o.attrs),i=n}}})),s)return{v:o.from(s)}},r=e.depth;r>=0;r--){var i=n(r);if(i)return i.v}return t}(c.content,i),!0),c.openStart||c.openEnd){for(var y=0,w=0,b=c.content.firstChild;y<c.openStart&&!b.type.spec.isolating;y++,b=b.firstChild);for(var k=c.content.lastChild;w<c.openEnd&&!k.type.spec.isolating;w++,k=k.lastChild);c=ur(c,y,w)}return t.someProp("transformPasted",(function(t){c=t(c)})),c}function cr(t,e,n){void 0===n&&(n=0);for(var r=e.length-1;r>=n;r--)t=e[r].create(null,o.from(t));return t}function ar(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){var s=ar(t,e,n,r.lastChild,i+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(i==t.length-1?n.type:t[i+1]))return r.copy(r.content.append(o.from(cr(n,t,i+1))))}}function lr(t,e){if(0==e)return t;var n=t.content.replaceChild(t.childCount-1,lr(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(o.empty,!0);return t.copy(n.append(r))}function hr(t,e,n,r,i,s){var c=e<0?t.firstChild:t.lastChild,a=c.content;return i<r-1&&(a=hr(a,e,n,r,i+1,s)),i>=n&&(a=e<0?c.contentMatchAt(0).fillBefore(a,t.childCount>1||s<=i).append(a):a.append(c.contentMatchAt(c.childCount).fillBefore(o.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,c.copy(a))}function ur(t,e,n){return e<t.openStart&&(t=new u(hr(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new u(hr(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}var dr={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]},pr=null;function fr(){return pr||(pr=document.implementation.createHTMLDocument("title"))}var gr={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},mr=Me.ie&&Me.ie_version<=11,vr=function(){this.anchorNode=this.anchorOffset=this.focusNode=this.focusOffset=null};vr.prototype.set=function(t){this.anchorNode=t.anchorNode,this.anchorOffset=t.anchorOffset,this.focusNode=t.focusNode,this.focusOffset=t.focusOffset},vr.prototype.eq=function(t){return t.anchorNode==this.anchorNode&&t.anchorOffset==this.anchorOffset&&t.focusNode==this.focusNode&&t.focusOffset==this.focusOffset};var yr=function(t,e){var n=this;this.view=t,this.handleDOMChange=e,this.queue=[],this.flushingSoon=-1,this.observer=window.MutationObserver&&new window.MutationObserver((function(t){for(var e=0;e<t.length;e++)n.queue.push(t[e]);Me.ie&&Me.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 vr,mr&&(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};yr.prototype.flushSoon=function(){var t=this;this.flushingSoon<0&&(this.flushingSoon=window.setTimeout((function(){t.flushingSoon=-1,t.flush()}),20))},yr.prototype.forceFlush=function(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())},yr.prototype.start=function(){this.observer&&this.observer.observe(this.view.dom,gr),mr&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()},yr.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()}mr&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()},yr.prototype.connectSelection=function(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)},yr.prototype.disconnectSelection=function(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)},yr.prototype.suppressSelectionUpdates=function(){var t=this;this.suppressingSelectionUpdates=!0,setTimeout((function(){return t.suppressingSelectionUpdates=!1}),50)},yr.prototype.onSelectionChange=function(){if((!(t=this.view).editable||t.root.activeElement==t.dom)&&jn(t)){var t;if(this.suppressingSelectionUpdates)return zn(this.view);if(Me.ie&&Me.ie_version<=11&&!this.view.state.selection.empty){var e=this.view.root.getSelection();if(e.focusNode&&ze(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}},yr.prototype.setCurSelection=function(){this.currentSelection.set(this.view.root.getSelection())},yr.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},yr.prototype.flush=function(){if(this.view.docView&&!(this.flushingSoon>-1)){var t=this.observer?this.observer.takeRecords():[];this.queue.length&&(t=this.queue.concat(t),this.queue.length=0);var e=this.view.root.getSelection(),n=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(e)&&jn(this.view)&&!this.ignoreSelectionChange(e),r=-1,o=-1,i=!1,s=[];if(this.view.editable)for(var c=0;c<t.length;c++){var a=this.registerMutation(t[c],s);a&&(r=r<0?a.from:Math.min(a.from,r),o=o<0?a.to:Math.max(a.to,o),a.typeOver&&(i=!0))}if(Me.gecko&&s.length>1){var l=s.filter((function(t){return"BR"==t.nodeName}));if(2==l.length){var h=l[0],u=l[1];h.parentNode&&h.parentNode.parentNode==u.parentNode?u.remove():h.remove()}}(r>-1||n)&&(r>-1&&(this.view.docView.markDirty(r,o),d=this.view,wr||(wr=!0,"normal"==getComputedStyle(d.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.handleDOMChange(r,o,i,s),this.view.docView.dirty?this.view.updateState(this.view.state):this.currentSelection.eq(e)||zn(this.view),this.currentSelection.set(e))}var d},yr.prototype.registerMutation=function(t,e){if(e.indexOf(t.target)>-1)return null;var n=this.view.docView.nearestDesc(t.target);if("attributes"==t.type&&(n==this.view.docView||"contenteditable"==t.attributeName||"style"==t.attributeName&&!t.oldValue&&!t.target.getAttribute("style")))return null;if(!n||n.ignoreMutation(t))return null;if("childList"==t.type){for(var r=0;r<t.addedNodes.length;r++)e.push(t.addedNodes[r]);if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(t.target))return{from:n.posBefore,to:n.posAfter};var o=t.previousSibling,i=t.nextSibling;if(Me.ie&&Me.ie_version<=11&&t.addedNodes.length)for(var s=0;s<t.addedNodes.length;s++){var c=t.addedNodes[s],a=c.previousSibling,l=c.nextSibling;(!a||Array.prototype.indexOf.call(t.addedNodes,a)<0)&&(o=a),(!l||Array.prototype.indexOf.call(t.addedNodes,l)<0)&&(i=l)}var h=o&&o.parentNode==t.target?Ae(o)+1:0,u=n.localPosFromDOM(t.target,h,-1),d=i&&i.parentNode==t.target?Ae(i):t.target.childNodes.length;return{from:u,to:n.localPosFromDOM(t.target,d,1)}}return"attributes"==t.type?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:{from:n.posAtStart,to:n.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}};var wr=!1,br={},kr={};function Sr(t,e){t.lastSelectionOrigin=e,t.lastSelectionTime=Date.now()}function Cr(t){t.someProp("handleDOMEvents",(function(e){for(var n in e)t.eventHandlers[n]||t.dom.addEventListener(n,t.eventHandlers[n]=function(e){return xr(t,e)})}))}function xr(t,e){return t.someProp("handleDOMEvents",(function(n){var r=n[e.type];return!!r&&(r(t,e)||e.defaultPrevented)}))}function Mr(t){return{left:t.clientX,top:t.clientY}}function _r(t,e,n,r,o){if(-1==r)return!1;for(var i=t.state.doc.resolve(r),s=function(r){if(t.someProp(e,(function(e){return r>i.depth?e(t,n,i.nodeAfter,i.before(r),o,!0):e(t,n,i.node(r),i.before(r),o,!1)})))return{v:!0}},c=i.depth+1;c>0;c--){var a=s(c);if(a)return a.v}return!1}function Er(t,e,n){t.focused||t.focus();var r=t.state.tr.setSelection(e);"pointer"==n&&r.setMeta("pointer",!0),t.dispatch(r)}function Or(t,e,n,r){return _r(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",(function(n){return n(t,e,r)}))}function Dr(t,e,n,r){return _r(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",(function(n){return n(t,e,r)}))||function(t,e,n){if(0!=n.button)return!1;var r=t.state.doc;if(-1==e)return!!r.inlineContent&&(Er(t,oe.create(r,0,r.content.size),"pointer"),!0);for(var o=r.resolve(e),i=o.depth+1;i>0;i--){var s=i>o.depth?o.nodeAfter:o.node(i),c=o.before(i);if(s.inlineContent)Er(t,oe.create(r,c+1,c+1+s.content.size),"pointer");else{if(!se.isSelectable(s))continue;Er(t,se.create(r,c),"pointer")}return!0}}(t,n,r)}function Nr(t){return Lr(t)}kr.keydown=function(t,e){if(t.shiftKey=16==e.keyCode||e.shiftKey,!Ir(t,e))if(229!=e.keyCode&&t.domObserver.forceFlush(),t.lastKeyCode=e.keyCode,t.lastKeyCodeTime=Date.now(),!Me.ios||13!=e.keyCode||e.ctrlKey||e.altKey||e.metaKey)t.someProp("handleKeyDown",(function(n){return n(t,e)}))||function(t,e){var n=e.keyCode,r=function(t){var e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}(e);return 8==n||Me.mac&&72==n&&"c"==r?tr(t,-1)||Gn(t):46==n||Me.mac&&68==n&&"c"==r?tr(t,1)||Yn(t):13==n||27==n||(37==n?Wn(t,-1,r)||Gn(t):39==n?Wn(t,1,r)||Yn(t):38==n?Zn(t,-1,r)||Gn(t):40==n?function(t){if(Me.safari&&!(t.state.selection.$head.parentOffset>0)){var e=t.root.getSelection(),n=e.focusNode,r=e.focusOffset;if(n&&1==n.nodeType&&0==r&&n.firstChild&&"false"==n.firstChild.contentEditable){var o=n.firstChild;er(t,o,!0),setTimeout((function(){return er(t,o,!1)}),20)}}}(t)||Zn(t,1,r)||Yn(t):r==(Me.mac?"m":"c")&&(66==n||73==n||89==n||90==n))}(t,e)?e.preventDefault():Sr(t,"key");else{var n=Date.now();t.lastIOSEnter=n,t.lastIOSEnterFallbackTimeout=setTimeout((function(){t.lastIOSEnter==n&&(t.someProp("handleKeyDown",(function(e){return e(t,$e(13,"Enter"))})),t.lastIOSEnter=0)}),200)}},kr.keyup=function(t,e){16==e.keyCode&&(t.shiftKey=!1)},kr.keypress=function(t,e){if(!(Ir(t,e)||!e.charCode||e.ctrlKey&&!e.altKey||Me.mac&&e.metaKey))if(t.someProp("handleKeyPress",(function(n){return n(t,e)})))e.preventDefault();else{var n=t.state.selection;if(!(n instanceof oe&&n.$from.sameParent(n.$to))){var r=String.fromCharCode(e.charCode);t.someProp("handleTextInput",(function(e){return e(t,n.$from.pos,n.$to.pos,r)}))||t.dispatch(t.state.tr.insertText(r).scrollIntoView()),e.preventDefault()}}};var Ar=Me.mac?"metaKey":"ctrlKey";br.mousedown=function(t,e){t.shiftKey=e.shiftKey;var n=Nr(t),r=Date.now(),o="singleClick";r-t.lastClick.time<500&&function(t,e){var n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}(e,t.lastClick)&&!e[Ar]&&("singleClick"==t.lastClick.type?o="doubleClick":"doubleClick"==t.lastClick.type&&(o="tripleClick")),t.lastClick={time:r,x:e.clientX,y:e.clientY,type:o};var i=t.posAtCoords(Mr(e));i&&("singleClick"==o?(t.mouseDown&&t.mouseDown.done(),t.mouseDown=new Tr(t,i,e,n)):("doubleClick"==o?Or:Dr)(t,i.pos,i.inside,e)?e.preventDefault():Sr(t,"pointer"))};var Tr=function(t,e,n,r){var o,i,s=this;if(this.view=t,this.startDoc=t.state.doc,this.pos=e,this.event=n,this.flushed=r,this.selectNode=n[Ar],this.allowDefault=n.shiftKey,this.delayedSelectionSync=!1,e.inside>-1)o=t.state.doc.nodeAt(e.inside),i=e.inside;else{var c=t.state.doc.resolve(e.pos);o=c.parent,i=c.depth?c.before():0}this.mightDrag=null;var a=r?null:n.target,l=a?t.docView.nearestDesc(a,!0):null;this.target=l?l.dom:null;var h=t.state.selection;(0==n.button&&o.type.spec.draggable&&!1!==o.type.spec.selectable||h instanceof se&&h.from<=i&&h.to>i)&&(this.mightDrag={node:o,pos:i,addAttr:this.target&&!this.target.draggable,setUneditable:this.target&&Me.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(){s.view.mouseDown==s&&s.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)),Sr(t,"pointer")};function Ir(t,e){return!!t.composing||!!(Me.safari&&Math.abs(e.timeStamp-t.compositionEndedAt)<500)&&(t.compositionEndedAt=-2e8,!0)}Tr.prototype.done=function(){var t=this;this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout((function(){return zn(t.view)})),this.view.mouseDown=null},Tr.prototype.up=function(t){if(this.done(),this.view.dom.contains(3==t.target.nodeType?t.target.parentNode:t.target)){var e=this.pos;this.view.state.doc!=this.startDoc&&(e=this.view.posAtCoords(Mr(t))),this.allowDefault||!e?Sr(this.view,"pointer"):function(t,e,n,r,o){return _r(t,"handleClickOn",e,n,r)||t.someProp("handleClick",(function(n){return n(t,e,r)}))||(o?function(t,e){if(-1==e)return!1;var n,r,o=t.state.selection;o instanceof se&&(n=o.node);for(var i=t.state.doc.resolve(e),s=i.depth+1;s>0;s--){var c=s>i.depth?i.nodeAfter:i.node(s);if(se.isSelectable(c)){r=n&&o.$from.depth>0&&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&&(Er(t,se.create(t.state.doc,r),"pointer"),!0)}(t,n):function(t,e){if(-1==e)return!1;var n=t.state.doc.resolve(e),r=n.nodeAfter;return!!(r&&r.isAtom&&se.isSelectable(r))&&(Er(t,new se(n),"pointer"),!0)}(t,n))}(this.view,e.pos,e.inside,t,this.selectNode)?t.preventDefault():0==t.button&&(this.flushed||Me.safari&&this.mightDrag&&!this.mightDrag.node.isAtom||Me.chrome&&!(this.view.state.selection instanceof oe)&&Math.min(Math.abs(e.pos-this.view.state.selection.from),Math.abs(e.pos-this.view.state.selection.to))<=2)?(Er(this.view,ee.near(this.view.state.doc.resolve(e.pos)),"pointer"),t.preventDefault()):Sr(this.view,"pointer")}},Tr.prototype.move=function(t){!this.allowDefault&&(Math.abs(this.event.x-t.clientX)>4||Math.abs(this.event.y-t.clientY)>4)&&(this.allowDefault=!0),Sr(this.view,"pointer"),0==t.buttons&&this.done()},br.touchdown=function(t){Nr(t),Sr(t,"pointer")},br.contextmenu=function(t){return Nr(t)};var Rr=Me.android?5e3:-1;function zr(t,e){clearTimeout(t.composingTimeout),e>-1&&(t.composingTimeout=setTimeout((function(){return Lr(t)}),e))}function Pr(t){var e;for(t.composing&&(t.composing=!1,t.compositionEndedAt=((e=document.createEvent("Event")).initEvent("event",!0,!0),e.timeStamp));t.compositionNodes.length>0;)t.compositionNodes.pop().markParentsDirty()}function Lr(t,e){if(t.domObserver.forceFlush(),Pr(t),e||t.docView.dirty){var n=In(t);return n&&!n.eq(t.state.selection)?t.dispatch(t.state.tr.setSelection(n)):t.updateState(t.state),!0}return!1}kr.compositionstart=kr.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(),Lr(t,!0),t.markCursor=null;else if(Lr(t),Me.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}zr(t,Rr)},kr.compositionend=function(t,e){t.composing&&(t.composing=!1,t.compositionEndedAt=e.timeStamp,zr(t,20))};var Br=Me.ie&&Me.ie_version<15||Me.ios&&Me.webkit_version<604;function Vr(t,e,n,r){var o=sr(t,e,n,t.shiftKey,t.state.selection.$from);if(t.someProp("handlePaste",(function(e){return e(t,r,o||u.empty)})))return!0;if(!o)return!1;var i=function(t){return 0==t.openStart&&0==t.openEnd&&1==t.content.childCount?t.content.firstChild:null}(o),s=i?t.state.tr.replaceSelectionWith(i,t.shiftKey):t.state.tr.replaceSelection(o);return t.dispatch(s.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}br.copy=kr.cut=function(t,e){var n=t.state.selection,r="cut"==e.type;if(!n.empty){var o=Br?null:e.clipboardData,i=ir(t,n.content()),s=i.dom,c=i.text;o?(e.preventDefault(),o.clearData(),o.setData("text/html",s.innerHTML),o.setData("text/plain",c)):function(t,e){if(t.dom.parentNode){var n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";var r=getSelection(),o=document.createRange();o.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout((function(){n.parentNode&&n.parentNode.removeChild(n),t.focus()}),50)}}(t,s),r&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))}},kr.paste=function(t,e){var n=Br?null:e.clipboardData;n&&Vr(t,n.getData("text/plain"),n.getData("text/html"),e)?e.preventDefault():function(t,e){if(t.dom.parentNode){var n=t.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus(),setTimeout((function(){t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Vr(t,r.value,null,e):Vr(t,r.textContent,r.innerHTML,e)}),50)}}(t,e)};var Fr=function(t,e){this.slice=t,this.move=e},$r=Me.mac?"altKey":"ctrlKey";for(var qr in br.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(Mr(e));if(o&&o.pos>=r.from&&o.pos<=(r instanceof se?r.to-1:r.to));else if(n&&n.mightDrag)t.dispatch(t.state.tr.setSelection(se.create(t.state.doc,n.mightDrag.pos)));else if(e.target&&1==e.target.nodeType){var i=t.docView.nearestDesc(e.target,!0);i&&i.node.type.spec.draggable&&i!=t.docView&&t.dispatch(t.state.tr.setSelection(se.create(t.state.doc,i.posBefore)))}var s=t.state.selection.content(),c=ir(t,s),a=c.dom,l=c.text;e.dataTransfer.clearData(),e.dataTransfer.setData(Br?"Text":"text/html",a.innerHTML),e.dataTransfer.effectAllowed="copyMove",Br||e.dataTransfer.setData("text/plain",l),t.dragging=new Fr(s,!e[$r])}},br.dragend=function(t){var e=t.dragging;window.setTimeout((function(){t.dragging==e&&(t.dragging=null)}),50)},kr.dragover=kr.dragenter=function(t,e){return e.preventDefault()},kr.drop=function(t,e){var n=t.dragging;if(t.dragging=null,e.dataTransfer){var r=t.posAtCoords(Mr(e));if(r){var o=t.state.doc.resolve(r.pos);if(o){var i=n&&n.slice;i?t.someProp("transformPasted",(function(t){i=t(i)})):i=sr(t,e.dataTransfer.getData(Br?"Text":"text/plain"),Br?null:e.dataTransfer.getData("text/html"),!1,o);var s=n&&!e[$r];if(t.someProp("handleDrop",(function(n){return n(t,e,i||u.empty,s)})))e.preventDefault();else if(i){e.preventDefault();var c=i?Ft(t.state.doc,o.pos,i):o.pos;null==c&&(c=o.pos);var a=t.state.tr;s&&a.deleteSelection();var l=a.mapping.map(c),h=0==i.openStart&&0==i.openEnd&&1==i.content.childCount,d=a.doc;if(h?a.replaceRangeWith(l,l,i.content.firstChild):a.replaceRange(l,l,i),!a.doc.eq(d)){var p=a.doc.resolve(l);if(h&&se.isSelectable(i.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(i.content.firstChild))a.setSelection(new se(p));else{var f=a.mapping.map(c);a.mapping.maps[a.mapping.maps.length-1].forEach((function(t,e,n,r){return f=r})),a.setSelection(qn(t,p,a.doc.resolve(f)))}t.focus(),t.dispatch(a.setMeta("uiEvent","drop"))}}}}}},br.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())&&zn(t)}),20))},br.blur=function(t,e){t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),e.relatedTarget&&t.dom.contains(e.relatedTarget)&&t.domObserver.currentSelection.set({}),t.focused=!1)},br.beforeinput=function(t,e){if(Me.chrome&&Me.android&&"deleteContentBackward"==e.inputType){var n=t.domChangeCount;setTimeout((function(){if(t.domChangeCount==n&&(t.dom.blur(),t.focus(),!t.someProp("handleKeyDown",(function(e){return e(t,$e(8,"Backspace"))})))){var e=t.state.selection.$cursor;e&&e.pos>0&&t.dispatch(t.state.tr.delete(e.pos-1,e.pos).scrollIntoView())}}),50)}},kr)br[qr]=kr[qr];function jr(t,e){if(t==e)return!0;for(var n in t)if(t[n]!==e[n])return!1;for(var r in e)if(!(r in t))return!1;return!0}var Ur=function(t,e){this.spec=e||Yr,this.side=this.spec.side||0,this.toDOM=t};Ur.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 Kr(i-n,i-n,this)},Ur.prototype.valid=function(){return!0},Ur.prototype.eq=function(t){return this==t||t instanceof Ur&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&jr(this.spec,t.spec))};var Jr=function(t,e){this.spec=e||Yr,this.attrs=t};Jr.prototype.map=function(t,e,n,r){var o=t.map(e.from+r,this.spec.inclusiveStart?-1:1)-n,i=t.map(e.to+r,this.spec.inclusiveEnd?1:-1)-n;return o>=i?null:new Kr(o,i,this)},Jr.prototype.valid=function(t,e){return e.from<e.to},Jr.prototype.eq=function(t){return this==t||t instanceof Jr&&jr(this.attrs,t.attrs)&&jr(this.spec,t.spec)},Jr.is=function(t){return t.type instanceof Jr};var Wr=function(t,e){this.spec=e||Yr,this.attrs=t};Wr.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 Kr(o.pos-n,i.pos-n,this)},Wr.prototype.valid=function(t,e){var n,r=t.content.findIndex(e.from),o=r.index,i=r.offset;return i==e.from&&!(n=t.child(o)).isText&&i+n.nodeSize==e.to},Wr.prototype.eq=function(t){return this==t||t instanceof Wr&&jr(this.attrs,t.attrs)&&jr(this.spec,t.spec)};var Kr=function(t,e,n){this.from=t,this.to=e,this.type=n},Hr={spec:{configurable:!0},inline:{configurable:!0}};Kr.prototype.copy=function(t,e){return new Kr(t,e,this.type)},Kr.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},Kr.prototype.map=function(t,e,n){return this.type.map(t,this,e,n)},Kr.widget=function(t,e,n){return new Kr(t,t,new Ur(e,n))},Kr.inline=function(t,e,n,r){return new Kr(t,e,new Jr(n,r))},Kr.node=function(t,e,n,r){return new Kr(t,e,new Wr(n,r))},Hr.spec.get=function(){return this.type.spec},Hr.inline.get=function(){return this.type instanceof Jr},Object.defineProperties(Kr.prototype,Hr);var Gr=[],Yr={},Xr=function(t,e){this.local=t&&t.length?t:Gr,this.children=e&&e.length?e:Gr};Xr.create=function(t,e){return e.length?ro(e,t,0,Yr):Qr},Xr.prototype.find=function(t,e,n){var r=[];return this.findInner(null==t?0:t,null==e?1e9:e,r,0,n),r},Xr.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 c=0;c<this.children.length;c+=3)if(this.children[c]<e&&this.children[c+1]>t){var a=this.children[c]+1;this.children[c+2].findInner(t-a,e-a,n,r+a,o)}},Xr.prototype.map=function(t,e,n){return this==Qr||0==t.maps.length?this:this.mapInner(t,e,0,0,n||Yr)},Xr.prototype.mapInner=function(t,e,n,r,o){for(var i,s=0;s<this.local.length;s++){var c=this.local[s].map(t,n,r);c&&c.type.valid(e,c)?(i||(i=[])).push(c):o.onRemove&&o.onRemove(this.local[s].spec)}return this.children.length?function(t,e,n,r,o,i,s){for(var c=t.slice(),a=function(t,e,n,r){for(var s=0;s<c.length;s+=3){var a=c[s+1],l=void 0;-1==a||t>a+i||(e>=c[s]+i?c[s+1]=-1:n>=o&&(l=r-n-(e-t))&&(c[s]+=l,c[s+1]+=l))}},l=0;l<n.maps.length;l++)n.maps[l].forEach(a);for(var h=!1,u=0;u<c.length;u+=3)if(-1==c[u+1]){var d=n.map(t[u]+i),p=d-o;if(p<0||p>=r.content.size){h=!0;continue}var f=n.map(t[u+1]+i,-1)-o,g=r.content.findIndex(p),m=g.index,v=g.offset,y=r.maybeChild(m);if(y&&v==p&&v+y.nodeSize==f){var w=c[u+2].mapInner(n,y,d+1,t[u]+i+1,s);w!=Qr?(c[u]=p,c[u+1]=f,c[u+2]=w):(c[u+1]=-2,h=!0)}else h=!0}if(h){var b=function(t,e,n,r,o,i,s){function c(t,e){for(var i=0;i<t.local.length;i++){var a=t.local[i].map(r,o,e);a?n.push(a):s.onRemove&&s.onRemove(t.local[i].spec)}for(var l=0;l<t.children.length;l+=3)c(t.children[l+2],t.children[l]+e+1)}for(var a=0;a<t.length;a+=3)-1==t[a+1]&&c(t[a+2],e[a]+i+1);return n}(c,t,e||[],n,o,i,s),k=ro(b,r,0,s);e=k.local;for(var S=0;S<c.length;S+=3)c[S+1]<0&&(c.splice(S,3),S-=3);for(var C=0,x=0;C<k.children.length;C+=3){for(var M=k.children[C];x<c.length&&c[x]<M;)x+=3;c.splice(x,0,k.children[C],k.children[C+1],k.children[C+2])}}return new Xr(e&&e.sort(oo),c)}(this.children,i,t,e,n,r,o):i?new Xr(i.sort(oo)):Qr},Xr.prototype.add=function(t,e){return e.length?this==Qr?Xr.create(t,e):this.addInner(t,e,0):this},Xr.prototype.addInner=function(t,e,n){var r,o=this,i=0;t.forEach((function(t,s){var c,a=s+n;if(c=eo(e,t,a)){for(r||(r=o.children.slice());i<r.length&&r[i]<s;)i+=3;r[i]==s?r[i+2]=r[i+2].addInner(t,c,a+1):r.splice(i,0,s,s+t.nodeSize,ro(c,t,a+1,Yr)),i+=3}}));for(var s=to(i?no(e):e,-n),c=0;c<s.length;c++)s[c].type.valid(t,s[c])||s.splice(c--,1);return new Xr(s.length?this.local.concat(s).sort(oo):this.local,r||this.children)},Xr.prototype.remove=function(t){return 0==t.length||this==Qr?this:this.removeInner(t,0)},Xr.prototype.removeInner=function(t,e){for(var n=this.children,r=this.local,o=0;o<n.length;o+=3){for(var i=void 0,s=n[o]+e,c=n[o+1]+e,a=0,l=void 0;a<t.length;a++)(l=t[a])&&l.from>s&&l.to<c&&(t[a]=null,(i||(i=[])).push(l));if(i){n==this.children&&(n=this.children.slice());var h=n[o+2].removeInner(i,s+1);h!=Qr?n[o+2]=h:(n.splice(o,3),o-=3)}}if(r.length)for(var u=0,d=void 0;u<t.length;u++)if(d=t[u])for(var p=0;p<r.length;p++)r[p].eq(d,e)&&(r==this.local&&(r=this.local.slice()),r.splice(p--,1));return n==this.children&&r==this.local?this:r.length||n.length?new Xr(r,n):Qr},Xr.prototype.forChild=function(t,e){if(this==Qr)return this;if(e.isLeaf)return Xr.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,c=0;c<this.local.length;c++){var a=this.local[c];if(a.from<s&&a.to>i&&a.type instanceof Jr){var l=Math.max(i,a.from)-i,h=Math.min(s,a.to)-i;l<h&&(r||(r=[])).push(a.copy(l,h))}}if(r){var u=new Xr(r.sort(oo));return n?new Zr([u,n]):u}return n||Qr},Xr.prototype.eq=function(t){if(this==t)return!0;if(!(t instanceof Xr)||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},Xr.prototype.locals=function(t){return io(this.localsInner(t))},Xr.prototype.localsInner=function(t){if(this==Qr)return Gr;if(t.inlineContent||!this.local.some(Jr.is))return this.local;for(var e=[],n=0;n<this.local.length;n++)this.local[n].type instanceof Jr||e.push(this.local[n]);return e};var Qr=new Xr;Xr.empty=Qr,Xr.removeOverlap=io;var Zr=function(t){this.members=t};function to(t,e){if(!e||!t.length)return t;for(var n=[],r=0;r<t.length;r++){var o=t[r];n.push(new Kr(o.from+e,o.to+e,o.type))}return n}function eo(t,e,n){if(e.isLeaf)return null;for(var r=n+e.nodeSize,o=null,i=0,s=void 0;i<t.length;i++)(s=t[i])&&s.from>n&&s.to<r&&((o||(o=[])).push(s),t[i]=null);return o}function no(t){for(var e=[],n=0;n<t.length;n++)null!=t[n]&&e.push(t[n]);return e}function ro(t,e,n,r){var o=[],i=!1;e.forEach((function(e,s){var c=eo(t,e,s+n);if(c){i=!0;var a=ro(c,e,n+s+1,r);a!=Qr&&o.push(s,s+e.nodeSize,a)}}));for(var s=to(i?no(t):t,-n).sort(oo),c=0;c<s.length;c++)s[c].type.valid(e,s[c])||(r.onRemove&&r.onRemove(s[c].spec),s.splice(c--,1));return s.length||o.length?new Xr(s,o):Qr}function oo(t,e){return t.from-e.from||t.to-e.to}function io(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),so(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),so(e,o+1,i.copy(r.to,i.to)))}}return e}function so(t,e,n){for(;e<t.length&&oo(n,t[e])>0;)e++;t.splice(e,0,n)}function co(t){var e=[];return t.someProp("decorations",(function(n){var r=n(t.state);r&&r!=Qr&&e.push(r)})),t.cursorWrapper&&e.push(Xr.create(t.state.doc,[t.cursorWrapper.deco])),Zr.from(e)}Zr.prototype.map=function(t,e){var n=this.members.map((function(n){return n.map(t,e,Yr)}));return Zr.from(n)},Zr.prototype.forChild=function(t,e){if(e.isLeaf)return Xr.empty;for(var n=[],r=0;r<this.members.length;r++){var o=this.members[r].forChild(t,e);o!=Qr&&(o instanceof Zr?n=n.concat(o.members):n.push(o))}return Zr.from(n)},Zr.prototype.eq=function(t){if(!(t instanceof Zr)||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},Zr.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?io(n?e:e.sort(oo)):Gr},Zr.from=function(t){switch(t.length){case 0:return Qr;case 1:return t[0];default:return new Zr(t)}};var ao=function(t,e){this._props=e,this.state=e.state,this.directPlugins=e.plugins||[],this.directPlugins.forEach(go),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=po(this),this.markCursor=null,this.cursorWrapper=null,uo(this),this.nodeViews=fo(this),this.docView=vn(this.state.doc,ho(this),co(this),this.dom,this),this.lastSelectedViewDesc=null,this.dragging=null,function(t){t.shiftKey=!1,t.mouseDown=null,t.lastKeyCode=null,t.lastKeyCodeTime=0,t.lastClick={time:0,x:0,y:0,type:""},t.lastSelectionOrigin=null,t.lastSelectionTime=0,t.lastIOSEnter=0,t.lastIOSEnterFallbackTimeout=null,t.lastAndroidDelete=0,t.composing=!1,t.composingTimeout=null,t.compositionNodes=[],t.compositionEndedAt=-2e8,t.domObserver=new yr(t,(function(e,n,r,i){return function(t,e,n,r,i){if(e<0){var s=t.lastSelectionTime>Date.now()-50?t.lastSelectionOrigin:null,c=In(t,s);if(c&&!t.state.selection.eq(c)){var a=t.state.tr.setSelection(c);"pointer"==s?a.setMeta("pointer",!0):"key"==s&&a.scrollIntoView(),t.dispatch(a)}}else{var l=t.state.doc.resolve(e),h=l.sharedDepth(n);e=l.before(h+1),n=t.state.doc.resolve(n).after(h+1);var u=t.state.selection,d=function(t,e,n){var r=t.docView.parseRange(e,n),o=r.node,i=r.fromOffset,s=r.toOffset,c=r.from,a=r.to,l=t.root.getSelection(),h=null,u=l.anchorNode;if(u&&t.dom.contains(1==u.nodeType?u:u.parentNode)&&(h=[{node:u,offset:l.anchorOffset}],Fe(l)||h.push({node:l.focusNode,offset:l.focusOffset})),Me.chrome&&8===t.lastKeyCode)for(var d=s;d>i;d--){var p=o.childNodes[d-1],f=p.pmViewDesc;if("BR"==p.nodeName&&!f){s=d;break}if(!f||f.size)break}var g=t.state.doc,m=t.someProp("domParser")||rt.fromSchema(t.state.schema),v=g.resolve(c),y=null,w=m.parse(o,{topNode:v.parent,topMatch:v.parent.contentMatchAt(v.index()),topOpen:!0,from:i,to:s,preserveWhitespace:!v.parent.type.spec.code||"full",editableContent:!0,findPositions:h,ruleFromNode:nr,context:v});if(h&&null!=h[0].pos){var b=h[0].pos,k=h[1]&&h[1].pos;null==k&&(k=b),y={anchor:b+c,head:k+c}}return{doc:w,sel:y,from:c,to:a}}(t,e,n);if(Me.chrome&&t.cursorWrapper&&d.sel&&d.sel.anchor==t.cursorWrapper.deco.from){var p=t.cursorWrapper.deco.type.toDOM.nextSibling,f=p&&p.nodeValue?p.nodeValue.length:1;d.sel={anchor:d.sel.anchor+f,head:d.sel.anchor+f}}var g,m,v=t.state.doc,y=v.slice(d.from,d.to);8===t.lastKeyCode&&Date.now()-100<t.lastKeyCodeTime?(g=t.state.selection.to,m="end"):(g=t.state.selection.from,m="start"),t.lastKeyCode=null;var 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),c=s.a,a=s.b;return"end"==o&&(r-=c+Math.max(0,i-Math.min(c,a))-i),c<i&&t.size<e.size?(a=(i-=r<=i&&r>=c?i-r:0)+(a-c),c=i):a<i&&(c=(i-=r<=i&&r>=a?i-r:0)+(c-a),a=i),{start:i,endA:c,endB:a}}(y.content,d.doc.content,d.from,g,m);if(!w){if(!(r&&u instanceof oe&&!u.empty&&u.$head.sameParent(u.$anchor))||t.composing||d.sel&&d.sel.anchor!=d.sel.head){if((Me.ios&&t.lastIOSEnter>Date.now()-225||Me.android)&&i.some((function(t){return"DIV"==t.nodeName||"P"==t.nodeName}))&&t.someProp("handleKeyDown",(function(e){return e(t,$e(13,"Enter"))})))return void(t.lastIOSEnter=0);if(d.sel){var b=rr(t,t.state.doc,d.sel);b&&!b.eq(t.state.selection)&&t.dispatch(t.state.tr.setSelection(b))}return}w={start:u.from,endA:u.to,endB:u.to}}t.domChangeCount++,t.state.selection.from<t.state.selection.to&&w.start==w.endB&&t.state.selection instanceof oe&&(w.start>t.state.selection.from&&w.start<=t.state.selection.from+2?w.start=t.state.selection.from:w.endA<t.state.selection.to&&w.endA>=t.state.selection.to-2&&(w.endB+=t.state.selection.to-w.endA,w.endA=t.state.selection.to)),Me.ie&&Me.ie_version<=11&&w.endB==w.start+1&&w.endA==w.start&&w.start>d.from&&"  "==d.doc.textBetween(w.start-d.from-1,w.start-d.from+1)&&(w.start--,w.endA--,w.endB--);var k,S=d.doc.resolveNoCache(w.start-d.from),C=d.doc.resolveNoCache(w.endB-d.from),x=S.sameParent(C)&&S.parent.inlineContent;if((Me.ios&&t.lastIOSEnter>Date.now()-225&&(!x||i.some((function(t){return"DIV"==t.nodeName||"P"==t.nodeName})))||!x&&S.pos<d.doc.content.size&&(k=ee.findFrom(d.doc.resolve(S.pos+1),1,!0))&&k.head==C.pos)&&t.someProp("handleKeyDown",(function(e){return e(t,$e(13,"Enter"))})))t.lastIOSEnter=0;else if(t.state.selection.anchor>w.start&&function(t,e,n,r,o){if(!r.parent.isTextblock||n-e<=o.pos-r.pos||or(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(or(i,!0,!0));return!(!s.parent.isTextblock||s.pos>n||or(s,!0,!1)<n)&&r.parent.content.cut(r.parentOffset).eq(s.parent.content)}(v,w.start,w.endA,S,C)&&t.someProp("handleKeyDown",(function(e){return e(t,$e(8,"Backspace"))})))Me.android&&Me.chrome&&t.domObserver.suppressSelectionUpdates();else{Me.chrome&&Me.android&&w.toB==w.from&&(t.lastAndroidDelete=Date.now()),Me.android&&!x&&S.start()!=C.start()&&0==C.parentOffset&&S.depth==C.depth&&d.sel&&d.sel.anchor==d.sel.head&&d.sel.head==w.endA&&(w.endB-=2,C=d.doc.resolveNoCache(w.endB-d.from),setTimeout((function(){t.someProp("handleKeyDown",(function(e){return e(t,$e(13,"Enter"))}))}),20));var M,_,E,O,D=w.start,N=w.endA;if(x)if(S.pos==C.pos)Me.ie&&Me.ie_version<=11&&0==S.parentOffset&&(t.domObserver.suppressSelectionUpdates(),setTimeout((function(){return zn(t)}),20)),M=t.state.tr.delete(D,N),_=v.resolve(w.start).marksAcross(v.resolve(w.endA));else if(w.endA==w.endB&&(O=v.resolve(w.start))&&(E=function(t,e){for(var n,r,i,s=t.firstChild.marks,c=e.firstChild.marks,a=s,l=c,h=0;h<c.length;h++)a=c[h].removeFromSet(a);for(var u=0;u<s.length;u++)l=s[u].removeFromSet(l);if(1==a.length&&0==l.length)r=a[0],n="add",i=function(t){return t.mark(r.addToSet(t.marks))};else{if(0!=a.length||1!=l.length)return null;r=l[0],n="remove",i=function(t){return t.mark(r.removeFromSet(t.marks))}}for(var d=[],p=0;p<e.childCount;p++)d.push(i(e.child(p)));if(o.from(d).eq(t))return{mark:r,type:n}}(S.parent.content.cut(S.parentOffset,C.parentOffset),O.parent.content.cut(O.parentOffset,w.endA-O.start()))))M=t.state.tr,"add"==E.type?M.addMark(D,N,E.mark):M.removeMark(D,N,E.mark);else if(S.parent.child(S.index()).isText&&S.index()==C.index()-(C.textOffset?0:1)){var A=S.parent.textBetween(S.parentOffset,C.parentOffset);if(t.someProp("handleTextInput",(function(e){return e(t,D,N,A)})))return;M=t.state.tr.insertText(A,D,N)}if(M||(M=t.state.tr.replace(D,N,d.doc.slice(w.start-d.from,w.endB-d.from))),d.sel){var T=rr(t,M.doc,d.sel);T&&!(Me.chrome&&Me.android&&t.composing&&T.empty&&(w.start!=w.endB||t.lastAndroidDelete<Date.now()-100)&&(T.head==D||T.head==M.mapping.map(N)-1)||Me.ie&&T.empty&&T.head==D)&&M.setSelection(T)}_&&M.ensureMarks(_),t.dispatch(M.scrollIntoView())}}}(t,e,n,r,i)})),t.domObserver.start(),t.domChangeCount=0,t.eventHandlers=Object.create(null);var e=function(e){var n=br[e];t.dom.addEventListener(e,t.eventHandlers[e]=function(e){!function(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(var n=e.target;n!=t.dom;n=n.parentNode)if(!n||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}(t,e)||xr(t,e)||!t.editable&&e.type in kr||n(t,e)})};for(var n in br)e(n);Me.safari&&t.dom.addEventListener("input",(function(){return null})),Cr(t)}(this),this.prevDirectPlugins=[],this.pluginViews=[],this.updatePluginViews()},lo={props:{configurable:!0},root:{configurable:!0}};function ho(t){var e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),e.translate="no",t.someProp("attributes",(function(n){if("function"==typeof n&&(n=n(t.state)),n)for(var r in n)"class"==r?e.class+=" "+n[r]:e[r]||"contenteditable"==r||"nodeName"==r||(e[r]=String(n[r]))})),[Kr.node(0,t.state.doc.content.size,e)]}function uo(t){if(t.markCursor){var e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),t.cursorWrapper={dom:e,deco:Kr.widget(t.state.selection.head,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function po(t){return!t.someProp("editable",(function(e){return!1===e(t.state)}))}function fo(t){var e={};return t.someProp("nodeViews",(function(t){for(var n in t)Object.prototype.hasOwnProperty.call(e,n)||(e[n]=t[n])})),e}function go(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}lo.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},ao.prototype.update=function(t){t.handleDOMEvents!=this._props.handleDOMEvents&&Cr(this),this._props=t,t.plugins&&(t.plugins.forEach(go),this.directPlugins=t.plugins),this.updateStateInner(t.state,!0)},ao.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)},ao.prototype.updateState=function(t){this.updateStateInner(t,this.state.plugins!=t.plugins)},ao.prototype.updateStateInner=function(t,e){var n=this,r=this.state,o=!1,i=!1;if(t.storedMarks&&this.composing&&(Pr(this),i=!0),this.state=t,e){var s=fo(this);(function(t,e){var n=0,r=0;for(var o in t){if(t[o]!=e[o])return!0;n++}for(var i in e)r++;return n!=r})(s,this.nodeViews)&&(this.nodeViews=s,o=!0),Cr(this)}this.editable=po(this),uo(this);var c=co(this),a=ho(this),l=e?"reset":t.scrollToSelection>r.scrollToSelection?"to selection":"preserve",h=o||!this.docView.matchesNode(t.doc,a,c);!h&&t.selection.eq(r.selection)||(i=!0);var u,d,p,f,g,m,v,y,w,b,k="preserve"==l&&i&&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 c=t.root.elementFromPoint(i,s);if(c!=t.dom&&t.dom.contains(c)){var a=c.getBoundingClientRect();if(a.top>=o-20){e=c,n=a.top;break}}}return{refDOM:e,refTop:n,stack:We(t.dom)}}(this);if(i){this.domObserver.stop();var S=h&&(Me.ie||Me.chrome)&&!this.composing&&!r.selection.empty&&!t.selection.empty&&(f=r.selection,g=t.selection,m=Math.min(f.$anchor.sharedDepth(f.head),g.$anchor.sharedDepth(g.head)),f.$anchor.start(m)!=g.$anchor.start(m));if(h){var C=Me.chrome?this.trackWrites=this.root.getSelection().focusNode:null;!o&&this.docView.update(t.doc,a,c,this)||(this.docView.updateOuterDeco([]),this.docView.destroy(),this.docView=vn(t.doc,a,c,this.dom,this)),C&&!this.trackWrites&&(S=!0)}S||!(this.mouseDown&&this.domObserver.currentSelection.eq(this.root.getSelection())&&(u=this,d=u.docView.domFromPos(u.state.selection.anchor,0),p=u.root.getSelection(),ze(d.node,d.offset,p.anchorNode,p.anchorOffset)))?zn(this,S):(Fn(this,t.selection),this.domObserver.setCurSelection()),this.domObserver.start()}if(this.updatePluginViews(r),"reset"==l)this.dom.scrollTop=0;else if("to selection"==l){var x=this.root.getSelection().focusNode;this.someProp("handleScrollToSelection",(function(t){return t(n)}))||(t.selection instanceof se?Je(this,this.docView.domAfterPos(t.selection.from).getBoundingClientRect(),x):Je(this,this.coordsAtPos(t.selection.head,1),x))}else k&&(y=(v=k).refDOM,w=v.refTop,Ke(v.stack,0==(b=y?y.getBoundingClientRect().top:0)?0:b-w))},ao.prototype.destroyPluginViews=function(){for(var t;t=this.pluginViews.pop();)t.destroy&&t.destroy()},ao.prototype.updatePluginViews=function(t){if(t&&t.plugins==this.state.plugins&&this.directPlugins==this.prevDirectPlugins)for(var e=0;e<this.pluginViews.length;e++){var n=this.pluginViews[e];n.update&&n.update(this,t)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(var r=0;r<this.directPlugins.length;r++){var o=this.directPlugins[r];o.spec.view&&this.pluginViews.push(o.spec.view(this))}for(var i=0;i<this.state.plugins.length;i++){var s=this.state.plugins[i];s.spec.view&&this.pluginViews.push(s.spec.view(this))}}},ao.prototype.someProp=function(t,e){var n,r=this._props&&this._props[t];if(null!=r&&(n=e?e(r):r))return n;for(var o=0;o<this.directPlugins.length;o++){var i=this.directPlugins[o].props[t];if(null!=i&&(n=e?e(i):i))return n}var s=this.state.plugins;if(s)for(var c=0;c<s.length;c++){var a=s[c].props[t];if(null!=a&&(n=e?e(a):a))return n}},ao.prototype.hasFocus=function(){return this.root.activeElement==this.dom},ao.prototype.focus=function(){this.domObserver.stop(),this.editable&&function(t){if(t.setActive)return t.setActive();if(He)return t.focus(He);var e=We(t);t.focus(null==He?{get preventScroll(){return He={preventScroll:!0},!0}}:void 0),He||(He=!1,Ke(e,0))}(this.dom),zn(this),this.domObserver.start()},lo.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},ao.prototype.posAtCoords=function(t){return Qe(this,t)},ao.prototype.coordsAtPos=function(t,e){return void 0===e&&(e=1),en(this,t,e)},ao.prototype.domAtPos=function(t,e){return void 0===e&&(e=0),this.docView.domFromPos(t,e)},ao.prototype.nodeDOM=function(t){var e=this.docView.descAt(t);return e?e.nodeDOM:null},ao.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},ao.prototype.endOfTextblock=function(t,e){return function(t,e,n){return cn==e&&an==n?ln:(cn=e,an=n,ln="up"==n||"down"==n?function(t,e,n){var r=e.selection,o="up"==n?r.$from:r.$to;return on(t,e,(function(){for(var e=t.docView.domFromPos(o.pos,"up"==n?-1:1).node;;){var r=t.docView.nearestDesc(e,!0);if(!r)break;if(r.node.isBlock){e=r.dom;break}e=r.dom.parentNode}for(var i=en(t,o.pos,1),s=e.firstChild;s;s=s.nextSibling){var c=void 0;if(1==s.nodeType)c=s.getClientRects();else{if(3!=s.nodeType)continue;c=Re(s,0,s.nodeValue.length).getClientRects()}for(var a=0;a<c.length;a++){var l=c[a];if(l.bottom>l.top+1&&("up"==n?i.top-l.top>2*(l.bottom-i.top):l.bottom-i.bottom>2*(i.bottom-l.top)))return!1}}return!0}))}(t,e,n):function(t,e,n){var r=e.selection.$head;if(!r.parent.isTextblock)return!1;var o=r.parentOffset,i=!o,s=o==r.parent.content.size,c=t.root.getSelection();return sn.test(r.parent.textContent)&&c.modify?on(t,e,(function(){var e=c.getRangeAt(0),o=c.focusNode,i=c.focusOffset,s=c.caretBidiLevel;c.modify("move",n,"character");var a=!(r.depth?t.docView.domAfterPos(r.before()):t.dom).contains(1==c.focusNode.nodeType?c.focusNode:c.focusNode.parentNode)||o==c.focusNode&&i==c.focusOffset;return c.removeAllRanges(),c.addRange(e),null!=s&&(c.caretBidiLevel=s),a})):"left"==n||"backward"==n?i:s}(t,e,n))}(this,e||this.state,t)},ao.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,[],co(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null)},ao.prototype.dispatchEvent=function(t){return function(t,e){xr(t,e)||!br[e.type]||!t.editable&&e.type in kr||br[e.type](t,e)}(this,t)},ao.prototype.dispatch=function(t){var e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))},Object.defineProperties(ao.prototype,lo);var mo=["p",0],vo=["blockquote",0],yo=["hr"],wo=["pre",["code",0]],bo=["br"],ko=["em",0],So=["strong",0],Co=["code",0],xo=new et({nodes:{doc:{content:"block+"},paragraph:{content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM:function(){return mo}},blockquote:{content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM:function(){return vo}},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM:function(){return yo}},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 wo}},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 bo}}},marks:{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 ko}},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 So}},code:{parseDOM:[{tag:"code"}],toDOM:function(){return Co}}}}),Mo=["ol",0],_o=["ul",0],Eo=["li",0],Oo={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?Mo:["ol",{start:t.attrs.order},0]}},Do={parseDOM:[{tag:"ul"}],toDOM:function(){return _o}},No={parseDOM:[{tag:"li"}],toDOM:function(){return Eo},defining:!0};function Ao(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 To(t,e){return function(n,r){var i=n.selection,s=i.$from,c=i.$to,a=s.blockRange(c),l=!1,h=a;if(!a)return!1;if(a.depth>=2&&s.node(a.depth-1).type.compatibleContent(t)&&0==a.startIndex){if(0==s.index(a.depth-1))return!1;var d=n.doc.resolve(a.start-2);h=new D(d,d,a.depth),a.endIndex<a.parent.childCount&&(a=new D(s,n.doc.resolve(c.end(a.depth)),a.depth)),l=!0}var p=Rt(h,t,e,a);return!!p&&(r&&r(function(t,e,n,r,i){for(var s=o.empty,c=n.length-1;c>=0;c--)s=o.from(n[c].type.create(n[c].attrs,s));t.step(new Nt(e.start-(r?2:0),e.end,e.start,e.end,new u(s,0,0),n.length,!0));for(var a=0,l=0;l<n.length;l++)n[l].type==i&&(a=l+1);for(var h=n.length-a,d=e.start+n.length-(r?2:0),p=e.parent,f=e.startIndex,g=e.endIndex,m=!0;f<g;f++,m=!1)!m&&Pt(t.doc,d,h)&&(t.split(d,h),d+=2*h),d+=p.child(f).nodeSize;return t}(n.tr,a,p,l,t).scrollIntoView()),!0)}}for(var Io={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"},Ro={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"},zo="undefined"!=typeof navigator&&/Chrome\/(\d+)/.exec(navigator.userAgent),Po="undefined"!=typeof navigator&&/Apple Computer/.test(navigator.vendor),Lo="undefined"!=typeof navigator&&/Gecko\/\d+/.test(navigator.userAgent),Bo="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),Vo="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Fo=zo&&(Bo||+zo[1]<57)||Lo&&Bo,$o=0;$o<10;$o++)Io[48+$o]=Io[96+$o]=String($o);for($o=1;$o<=24;$o++)Io[$o+111]="F"+$o;for($o=65;$o<=90;$o++)Io[$o]=String.fromCharCode($o+32),Ro[$o]=String.fromCharCode($o);for(var qo in Io)Ro.hasOwnProperty(qo)||(Ro[qo]=Io[qo]);var jo="undefined"!=typeof navigator&&/Mac/.test(navigator.platform);function Uo(t){var e,n,r,o,i=t.split(/-(?!$)/),s=i[i.length-1];"Space"==s&&(s=" ");for(var c=0;c<i.length-1;c++){var a=i[c];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))e=!0;else if(/^(c|ctrl|control)$/i.test(a))n=!0;else if(/^s(hift)?$/i.test(a))r=!0;else{if(!/^mod$/i.test(a))throw new Error("Unrecognized modifier name: "+a);jo?o=!0:n=!0}}return e&&(s="Alt-"+s),n&&(s="Ctrl-"+s),o&&(s="Meta-"+s),r&&(s="Shift-"+s),s}function Jo(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 Wo(t){return new ke({props:{handleKeyDown:Ko(t)}})}function Ko(t){var e=function(t){var e=Object.create(null);for(var n in t)e[Uo(n)]=t[n];return e}(t);return function(t,n){var r,o=function(t){var e=!(Fo&&(t.ctrlKey||t.altKey||t.metaKey)||(Po||Vo)&&t.shiftKey&&t.key&&1==t.key.length)&&t.key||(t.shiftKey?Ro:Io)[t.keyCode]||t.key||"Unidentified";return"Esc"==e&&(e="Escape"),"Del"==e&&(e="Delete"),"Left"==e&&(e="ArrowLeft"),"Up"==e&&(e="ArrowUp"),"Right"==e&&(e="ArrowRight"),"Down"==e&&(e="ArrowDown"),e}(n),i=1==o.length&&" "!=o,s=e[Jo(o,n,!i)];if(s&&s(t.state,t.dispatch,t))return!0;if(i&&(n.shiftKey||n.altKey||n.metaKey||o.charCodeAt(0)>127)&&(r=Io[n.keyCode])&&r!=o){var c=e[Jo(r,n,!0)];if(c&&c(t.state,t.dispatch,t))return!0}else if(i&&n.shiftKey){var a=e[Jo(o,n,!0)];if(a&&a(t.state,t.dispatch,t))return!0}return!1}}var Ho=200,Go=function(){};Go.prototype.append=function(t){return t.length?(t=Go.from(t),!this.length&&t||t.length<Ho&&this.leafAppend(t)||this.length<Ho&&t.leafPrepend(this)||this.appendInner(t)):this},Go.prototype.prepend=function(t){return t.length?Go.from(t).append(this):this},Go.prototype.appendInner=function(t){return new Xo(this,t)},Go.prototype.slice=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=this.length),t>=e?Go.empty:this.sliceInner(Math.max(0,t),Math.min(this.length,e))},Go.prototype.get=function(t){if(!(t<0||t>=this.length))return this.getInner(t)},Go.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)},Go.prototype.map=function(t,e,n){void 0===e&&(e=0),void 0===n&&(n=this.length);var r=[];return this.forEach((function(e,n){return r.push(t(e,n))}),e,n),r},Go.from=function(t){return t instanceof Go?t:t&&t.length?new Yo(t):Go.empty};var Yo=function(t){function e(e){t.call(this),this.values=e}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(t,n){return 0==t&&n==this.length?this:new e(this.values.slice(t,n))},e.prototype.getInner=function(t){return this.values[t]},e.prototype.forEachInner=function(t,e,n,r){for(var o=e;o<n;o++)if(!1===t(this.values[o],r+o))return!1},e.prototype.forEachInvertedInner=function(t,e,n,r){for(var o=e-1;o>=n;o--)if(!1===t(this.values[o],r+o))return!1},e.prototype.leafAppend=function(t){if(this.length+t.length<=Ho)return new e(this.values.concat(t.flatten()))},e.prototype.leafPrepend=function(t){if(this.length+t.length<=Ho)return new e(t.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e}(Go);Go.empty=new Yo([]);var Xo=function(t){function e(e,n){t.call(this),this.left=e,this.right=n,this.length=e.length+n.length,this.depth=Math.max(e.depth,n.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(t){return t<this.left.length?this.left.get(t):this.right.get(t-this.left.length)},e.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))&&!(n>o&&!1===this.right.forEachInner(t,Math.max(e-o,0),Math.min(this.length,n)-o,r+o))&&void 0},e.prototype.forEachInvertedInner=function(t,e,n,r){var o=this.left.length;return!(e>o&&!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},e.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):t>=n?this.right.slice(t-n,e-n):this.left.slice(t,n).append(this.right.slice(0,e-n))},e.prototype.leafAppend=function(t){var n=this.right.leafAppend(t);if(n)return new e(this.left,n)},e.prototype.leafPrepend=function(t){var n=this.left.leafPrepend(t);if(n)return new e(n,this.right)},e.prototype.appendInner=function(t){return this.left.depth>=Math.max(this.right.depth,t.depth)+1?new e(this.left,new e(this.right,t)):new e(this,t)},e}(Go);const Qo=Go;var Zo=function(t,e){this.items=t,this.eventCount=e};Zo.prototype.popEvent=function(t,e){var n=this;if(0==this.eventCount)return null;for(var r,o,i=this.items.length;;i--)if(this.items.get(i-1).selection){--i;break}e&&(r=this.remapping(i,this.items.length),o=r.maps.length);var s,c,a=t.tr,l=[],h=[];return this.items.forEach((function(t,e){if(!t.step)return r||(r=n.remapping(i,e+1),o=r.maps.length),o--,void h.push(t);if(r){h.push(new ti(t.map));var u,d=t.step.map(r.slice(o));d&&a.maybeStep(d).doc&&(u=a.mapping.maps[a.mapping.maps.length-1],l.push(new ti(u,null,null,l.length+h.length))),o--,u&&r.appendMap(u,o)}else a.maybeStep(t.step);return t.selection?(s=r?t.selection.map(r.slice(o)):t.selection,c=new Zo(n.items.slice(0,i).append(h.reverse().concat(l)),n.eventCount-1),!1):void 0}),this.items.length,0),{remaining:c,transform:a,selection:s}},Zo.prototype.addTransform=function(t,e,n,r){for(var o=[],i=this.eventCount,s=this.items,c=!r&&s.length?s.get(s.length-1):null,a=0;a<t.steps.length;a++){var l,h=t.steps[a].invert(t.docs[a]),u=new ti(t.mapping.maps[a],h,e);(l=c&&c.merge(u))&&(u=l,a?o.pop():s=s.slice(0,s.length-1)),o.push(u),e&&(i++,e=null),r||(c=u)}var d,p,f,g=i-n.depth;return g>ni&&(p=g,(d=s).forEach((function(t,e){if(t.selection&&0==p--)return f=e,!1})),s=d.slice(f),i-=g),new Zo(s.append(o),i)},Zo.prototype.remapping=function(t,e){var n=new kt;return this.items.forEach((function(e,r){var o=null!=e.mirrorOffset&&r-e.mirrorOffset>=t?n.maps.length-e.mirrorOffset:null;n.appendMap(e.map,o)}),t,e),n},Zo.prototype.addMaps=function(t){return 0==this.eventCount?this:new Zo(this.items.append(t.map((function(t){return new ti(t)}))),this.eventCount)},Zo.prototype.rebased=function(t,e){if(!this.eventCount)return this;var n=[],r=Math.max(0,this.items.length-e),o=t.mapping,i=t.steps.length,s=this.eventCount;this.items.forEach((function(t){t.selection&&s--}),r);var c=e;this.items.forEach((function(e){var r=o.getMirror(--c);if(null!=r){i=Math.min(i,r);var a=o.maps[r];if(e.step){var l=t.steps[r].invert(t.docs[r]),h=e.selection&&e.selection.map(o.slice(c+1,r));h&&s++,n.push(new ti(a,l,h))}else n.push(new ti(a))}}),r);for(var a=[],l=e;l<i;l++)a.push(new ti(o.maps[l]));var h=this.items.slice(0,r).append(a).append(n),u=new Zo(h,s);return u.emptyItemCount()>500&&(u=u.compress(this.items.length-n.length)),u},Zo.prototype.emptyItemCount=function(){var t=0;return this.items.forEach((function(e){e.step||t++})),t},Zo.prototype.compress=function(t){void 0===t&&(t=this.items.length);var e=this.remapping(0,t),n=e.maps.length,r=[],o=0;return this.items.forEach((function(i,s){if(s>=t)r.push(i),i.selection&&o++;else if(i.step){var c=i.step.map(e.slice(n)),a=c&&c.getMap();if(n--,a&&e.appendMap(a,n),c){var l=i.selection&&i.selection.map(e.slice(n));l&&o++;var h,u=new ti(a.invert(),c,l),d=r.length-1;(h=r.length&&r[d].merge(u))?r[d]=h:r.push(u)}}else i.map&&n--}),this.items.length,0),new Zo(Qo.from(r.reverse()),o)},Zo.empty=new Zo(Qo.empty,0);var ti=function(t,e,n,r){this.map=t,this.step=e,this.selection=n,this.mirrorOffset=r};ti.prototype.merge=function(t){if(this.step&&t.step&&!t.selection){var e=t.step.merge(this.step);if(e)return new ti(e.getMap().invert(),e,this.selection)}};var ei=function(t,e,n,r){this.done=t,this.undone=e,this.prevRanges=n,this.prevTime=r},ni=20;function ri(t){var e=[];return t.forEach((function(t,n,r,o){return e.push(r,o)})),e}function oi(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 ii(t,e,n,r){var o=ai(e),i=li.get(e).spec.config,s=(r?t.undone:t.done).popEvent(e,o);if(s){var c=s.selection.resolve(s.transform.doc),a=(r?t.done:t.undone).addTransform(s.transform,e.selection.getBookmark(),i,o),l=new ei(r?a:s.remaining,r?s.remaining:a,null,0);n(s.transform.setSelection(c).setMeta(li,{redo:r,historyState:l}).scrollIntoView())}}var si=!1,ci=null;function ai(t){var e=t.plugins;if(ci!=e){si=!1,ci=e;for(var n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){si=!0;break}}return si}var li=new xe("history"),hi=new xe("closeHistory");function ui(t,e){var n=li.getState(t);return!(!n||0==n.done.eventCount||(e&&ii(n,t,e,!1),0))}function di(t,e){var n=li.getState(t);return!(!n||0==n.undone.eventCount||(e&&ii(n,t,e,!0),0))}function pi(t,e){return!t.selection.empty&&(e&&e(t.tr.deleteSelection().scrollIntoView()),!0)}function fi(t,e,n){for(;t;t="start"==e?t.firstChild:t.lastChild){if(t.isTextblock)return!0;if(n&&1!=t.childCount)return!1}return!1}function gi(t){if(!t.parent.type.spec.isolating)for(var e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function mi(t){if(!t.parent.type.spec.isolating)for(var e=t.depth-1;e>=0;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 vi(t,e){var n,r=t.selection,o=r instanceof se;if(o){if(r.node.isTextblock||!Lt(t.doc,r.from))return!1;n=r.from}else if(null==(n=Vt(t.doc,r.from,-1)))return!1;if(e){var i=t.tr.join(n);o&&i.setSelection(se.create(i.doc,n-t.doc.resolve(n).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0}function yi(t,e){var n,r=t.selection;if(r instanceof se){if(r.node.isTextblock||!Lt(t.doc,r.to))return!1;n=r.to}else if(null==(n=Vt(t.doc,r.to,1)))return!1;return e&&e(t.tr.join(n).scrollIntoView()),!0}function wi(t,e){var n=t.selection,r=n.$from,o=n.$to,i=r.blockRange(o),s=i&&It(i);return null!=s&&(e&&e(t.tr.lift(i,s).scrollIntoView()),!0)}function bi(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 ki(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=r.node(-1),s=r.indexAfter(-1),c=bi(i.contentMatchAt(s));if(!i.canReplaceWith(s,s,c))return!1;if(e){var a=r.after(),l=t.tr.replaceWith(a,a,c.createAndFill());l.setSelection(ee.near(l.doc.resolve(a),1)),e(l.scrollIntoView())}return!0}function Si(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(se.create(t.doc,n))),!0)}function Ci(t,e,n){var r,i,s=e.nodeBefore,c=e.nodeAfter;if(s.type.spec.isolating||c.type.spec.isolating)return!1;if(function(t,e,n){var r=e.nodeBefore,o=e.nodeAfter,i=e.index();return!(!(r&&o&&r.type.compatibleContent(o.type))||(!r.content.size&&e.parent.canReplace(i-1,i)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),0):!e.parent.canReplace(i,i+1)||!o.isTextblock&&!Lt(t.doc,e.pos)||(n&&n(t.tr.clearIncompatible(e.pos,r.type,r.contentMatchAt(r.childCount)).join(e.pos).scrollIntoView()),0)))}(t,e,n))return!0;var a=e.parent.canReplace(e.index(),e.index()+1);if(a&&(r=(i=s.contentMatchAt(s.childCount)).findWrapping(c.type))&&i.matchType(r[0]||c.type).validEnd){if(n){for(var l=e.pos+c.nodeSize,h=o.empty,d=r.length-1;d>=0;d--)h=o.from(r[d].create(null,h));h=o.from(s.copy(h));var p=t.tr.step(new Nt(e.pos-1,l,e.pos,l,new u(h,1,0),r.length,!0)),f=l+2*r.length;Lt(p.doc,f)&&p.join(f),n(p.scrollIntoView())}return!0}var g=ee.findFrom(e,1),m=g&&g.$from.blockRange(g.$to),v=m&&It(m);if(null!=v&&v>=e.depth)return n&&n(t.tr.lift(m,v).scrollIntoView()),!0;if(a&&fi(c,"start",!0)&&fi(s,"end")){for(var y=s,w=[];w.push(y),!y.isTextblock;)y=y.lastChild;for(var b=c,k=1;!b.isTextblock;b=b.firstChild)k++;if(y.canReplace(y.childCount,y.childCount,b.content)){if(n){for(var S=o.empty,C=w.length-1;C>=0;C--)S=o.from(w[C].copy(S));n(t.tr.step(new Nt(e.pos-w.length,e.pos+c.nodeSize,e.pos+k,e.pos+c.nodeSize-k,new u(S,w.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function xi(t,e){return function(n,r){var o=n.selection,i=o.$from,s=o.$to,c=i.blockRange(s),a=c&&Rt(c,t,e);return!!a&&(r&&r(n.tr.wrap(c,a).scrollIntoView()),!0)}}function Mi(t,e){return function(n,r){var o=n.selection,i=o.from,s=o.to,c=!1;return n.doc.nodesBetween(i,s,(function(r,o){if(c)return!1;if(r.isTextblock&&!r.hasMarkup(t,e))if(r.type==t)c=!0;else{var i=n.doc.resolve(o),s=i.index();c=i.parent.canReplaceWith(s,s+1,t)}})),!!c&&(r&&r(n.tr.setBlockType(i,s,t,e).scrollIntoView()),!0)}}function _i(t,e){return function(n,r){var o=n.selection,i=o.empty,s=o.$cursor,c=o.ranges;if(i&&!s||!function(t,e,n){for(var r=function(r){var o=e[r],i=o.$from,s=o.$to,c=0==i.depth&&t.type.allowsMarkType(n);if(t.nodesBetween(i.pos,s.pos,(function(t){if(c)return!1;c=t.inlineContent&&t.type.allowsMarkType(n)})),c)return{v:!0}},o=0;o<e.length;o++){var i=r(o);if(i)return i.v}return!1}(n.doc,c,t))return!1;if(r)if(s)t.isInSet(n.storedMarks||s.marks())?r(n.tr.removeStoredMark(t)):r(n.tr.addStoredMark(t.create(e)));else{for(var a=!1,l=n.tr,h=0;!a&&h<c.length;h++){var u=c[h],d=u.$from,p=u.$to;a=n.doc.rangeHasMark(d.pos,p.pos,t)}for(var f=0;f<c.length;f++){var g=c[f],m=g.$from,v=g.$to;if(a)l.removeMark(m.pos,v.pos,t);else{var y=m.pos,w=v.pos,b=m.nodeAfter,k=v.nodeBefore,S=b&&b.isText?/^\s*/.exec(b.text)[0].length:0,C=k&&k.isText?/\s*$/.exec(k.text)[0].length:0;y+S<w&&(y+=S,w-=C),l.addMark(y,w,t.create(e))}}r(l.scrollIntoView())}return!0}}function Ei(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return function(e,n,r){for(var o=0;o<t.length;o++)if(t[o](e,n,r))return!0;return!1}}var Oi=Ei(pi,(function(t,e,n){var r=t.selection.$cursor;if(!r||(n?!n.endOfTextblock("backward",t):r.parentOffset>0))return!1;var o=gi(r);if(!o){var i=r.blockRange(),s=i&&It(i);return null!=s&&(e&&e(t.tr.lift(i,s).scrollIntoView()),!0)}var c=o.nodeBefore;if(!c.type.spec.isolating&&Ci(t,o,e))return!0;if(0==r.parent.content.size&&(fi(c,"end")||se.isSelectable(c))){if(e){var a=t.tr.deleteRange(r.before(),r.after());a.setSelection(fi(c,"end")?ee.findFrom(a.doc.resolve(a.mapping.map(o.pos,-1)),-1):se.create(a.doc,o.pos-c.nodeSize)),e(a.scrollIntoView())}return!0}return!(!c.isAtom||o.depth!=r.depth-1||(e&&e(t.tr.delete(o.pos-c.nodeSize,o.pos).scrollIntoView()),0))}),(function(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):o.parentOffset>0)return!1;i=gi(o)}var s=i&&i.nodeBefore;return!(!s||!se.isSelectable(s)||(e&&e(t.tr.setSelection(se.create(t.doc,i.pos-s.nodeSize)).scrollIntoView()),0))})),Di=Ei(pi,(function(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=mi(r);if(!o)return!1;var i=o.nodeAfter;if(Ci(t,o,e))return!0;if(0==r.parent.content.size&&(fi(i,"start")||se.isSelectable(i))){if(e){var s=t.tr.deleteRange(r.before(),r.after());s.setSelection(fi(i,"start")?ee.findFrom(s.doc.resolve(s.mapping.map(o.pos)),1):se.create(s.doc,s.mapping.map(o.pos))),e(s.scrollIntoView())}return!0}return!(!i.isAtom||o.depth!=r.depth-1||(e&&e(t.tr.delete(o.pos,o.pos+i.nodeSize).scrollIntoView()),0))}),(function(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=mi(o)}var s=i&&i.nodeAfter;return!(!s||!se.isSelectable(s)||(e&&e(t.tr.setSelection(se.create(t.doc,i.pos)).scrollIntoView()),0))})),Ni={Enter:Ei((function(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(t,e){var n=t.selection,r=n.$from,o=n.$to;if(n instanceof ae||r.parent.inlineContent||o.parent.inlineContent)return!1;var i=bi(o.parent.contentMatchAt(o.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){var s=(!r.parentOffset&&o.index()<o.parent.childCount?r:o).pos,c=t.tr.insert(s,i.createAndFill());c.setSelection(oe.create(c.doc,s+1)),e(c.scrollIntoView())}return!0}),(function(t,e){var n=t.selection.$cursor;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){var r=n.before();if(Pt(t.doc,r))return e&&e(t.tr.split(r).scrollIntoView()),!0}var o=n.blockRange(),i=o&&It(o);return null!=i&&(e&&e(t.tr.lift(o,i).scrollIntoView()),!0)}),(function(t,e){var n=t.selection,r=n.$from,o=n.$to;if(t.selection instanceof se&&t.selection.node.isBlock)return!(!r.parentOffset||!Pt(t.doc,r.pos)||(e&&e(t.tr.split(r.pos).scrollIntoView()),0));if(!r.parent.isBlock)return!1;if(e){var i=o.parentOffset==o.parent.content.size,s=t.tr;(t.selection instanceof oe||t.selection instanceof ae)&&s.deleteSelection();var c=0==r.depth?null:bi(r.node(-1).contentMatchAt(r.indexAfter(-1))),a=i&&c?[{type:c}]:null,l=Pt(s.doc,s.mapping.map(r.pos),1,a);if(a||l||!Pt(s.doc,s.mapping.map(r.pos),1,c&&[{type:c}])||(a=[{type:c}],l=!0),l&&(s.split(s.mapping.map(r.pos),1,a),!i&&!r.parentOffset&&r.parent.type!=c)){var h=s.mapping.map(r.before()),u=s.doc.resolve(h);r.node(-1).canReplaceWith(u.index(),u.index()+1,c)&&s.setNodeMarkup(s.mapping.map(r.before()),c)}e(s.scrollIntoView())}return!0})),"Mod-Enter":ki,Backspace:Oi,"Mod-Backspace":Oi,"Shift-Backspace":Oi,Delete:Di,"Mod-Delete":Di,"Mod-a":function(t,e){return e&&e(t.tr.setSelection(new ae(t.doc))),!0}},Ai={"Ctrl-h":Ni.Backspace,"Alt-Backspace":Ni["Mod-Backspace"],"Ctrl-d":Ni.Delete,"Ctrl-Alt-Backspace":Ni["Mod-Delete"],"Alt-Delete":Ni["Mod-Delete"],"Alt-d":Ni["Mod-Delete"]};for(var Ti in Ni)Ai[Ti]=Ni[Ti];var Ii=("undefined"!=typeof navigator?/Mac/.test(navigator.platform):"undefined"!=typeof os&&"darwin"==os.platform())?Ai:Ni;function Ri(t){return void 0===t&&(t={}),new ke({view:function(e){return new zi(e,t)}})}var zi=function(t,e){var n=this;this.editorView=t,this.width=e.width||1,this.color=e.color||"black",this.class=e.class,this.cursorPos=null,this.element=null,this.timeout=null,this.handlers=["dragover","dragend","drop","dragleave"].map((function(e){var r=function(t){return n[e](t)};return t.dom.addEventListener(e,r),{name:e,handler:r}}))};zi.prototype.destroy=function(){var t=this;this.handlers.forEach((function(e){var n=e.name,r=e.handler;return t.editorView.dom.removeEventListener(n,r)}))},zi.prototype.update=function(t,e){null!=this.cursorPos&&e.doc!=t.state.doc&&(this.cursorPos>t.state.doc.content.size?this.setCursor(null):this.updateOverlay())},zi.prototype.setCursor=function(t){t!=this.cursorPos&&(this.cursorPos=t,null==t?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())},zi.prototype.updateOverlay=function(){var t,e=this.editorView.state.doc.resolve(this.cursorPos);if(!e.parent.inlineContent){var n=e.nodeBefore,r=e.nodeAfter;if(n||r){var o=this.editorView.nodeDOM(this.cursorPos-(n?n.nodeSize:0)).getBoundingClientRect(),i=n?o.bottom:o.top;n&&r&&(i=(i+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2),t={left:o.left,right:o.right,top:i-this.width/2,bottom:i+this.width/2}}}if(!t){var s=this.editorView.coordsAtPos(this.cursorPos);t={left:s.left-this.width/2,right:s.left+this.width/2,top:s.top,bottom:s.bottom}}var c,a,l=this.editorView.dom.offsetParent;if(this.element||(this.element=l.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),!l||l==document.body&&"static"==getComputedStyle(l).position)c=-pageXOffset,a=-pageYOffset;else{var h=l.getBoundingClientRect();c=h.left-l.scrollLeft,a=h.top-l.scrollTop}this.element.style.left=t.left-c+"px",this.element.style.top=t.top-a+"px",this.element.style.width=t.right-t.left+"px",this.element.style.height=t.bottom-t.top+"px"},zi.prototype.scheduleRemoval=function(t){var e=this;clearTimeout(this.timeout),this.timeout=setTimeout((function(){return e.setCursor(null)}),t)},zi.prototype.dragover=function(t){if(this.editorView.editable){var e=this.editorView.posAtCoords({left:t.clientX,top:t.clientY});if(e){var n=e.pos;if(this.editorView.dragging&&this.editorView.dragging.slice&&null==(n=Ft(this.editorView.state.doc,n,this.editorView.dragging.slice)))return this.setCursor(null);this.setCursor(n),this.scheduleRemoval(5e3)}}},zi.prototype.dragend=function(){this.scheduleRemoval(20)},zi.prototype.drop=function(){this.scheduleRemoval(20)},zi.prototype.dragleave=function(t){t.target!=this.editorView.dom&&this.editorView.dom.contains(t.relatedTarget)||this.setCursor(null)};var Pi=function(t){function e(e){t.call(this,e,e)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.map=function(n,r){var o=n.resolve(r.map(this.head));return e.valid(o)?new e(o):t.near(o)},e.prototype.content=function(){return u.empty},e.prototype.eq=function(t){return t instanceof e&&t.head==this.head},e.prototype.toJSON=function(){return{type:"gapcursor",pos:this.head}},e.fromJSON=function(t,n){if("number"!=typeof n.pos)throw new RangeError("Invalid input for GapCursor.fromJSON");return new e(t.resolve(n.pos))},e.prototype.getBookmark=function(){return new Li(this.anchor)},e.valid=function(t){var e=t.parent;if(e.isTextblock||!function(t){for(var e=t.depth;e>=0;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;e>=0;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},e.findFrom=function(t,n,r){t:for(;;){if(!r&&e.valid(t))return t;for(var o=t.pos,i=null,s=t.depth;;s--){var c=t.node(s);if(n>0?t.indexAfter(s)<c.childCount:t.index(s)>0){i=c.child(n>0?t.indexAfter(s):t.index(s)-1);break}if(0==s)return null;o+=n;var a=t.doc.resolve(o);if(e.valid(a))return a}for(;;){var l=n>0?i.firstChild:i.lastChild;if(!l){if(i.isAtom&&!i.isText&&!se.isSelectable(i)){t=t.doc.resolve(o+i.nodeSize*n),r=!1;continue t}break}i=l,o+=n;var h=t.doc.resolve(o);if(e.valid(h))return h}return null}},e}(ee);Pi.prototype.visible=!1,ee.jsonID("gapcursor",Pi);var Li=function(t){this.pos=t};Li.prototype.map=function(t){return new Li(t.map(this.pos))},Li.prototype.resolve=function(t){var e=t.resolve(this.pos);return Pi.valid(e)?new Pi(e):ee.near(e)};var Bi=Ko({ArrowLeft:Vi("horiz",-1),ArrowRight:Vi("horiz",1),ArrowUp:Vi("vert",-1),ArrowDown:Vi("vert",1)});function Vi(t,e){var n="vert"==t?e>0?"down":"up":e>0?"right":"left";return function(t,r,o){var i=t.selection,s=e>0?i.$to:i.$from,c=i.empty;if(i instanceof oe){if(!o.endOfTextblock(n)||0==s.depth)return!1;c=!1,s=t.doc.resolve(e>0?s.after():s.before())}var a=Pi.findFrom(s,e,c);return!!a&&(r&&r(t.tr.setSelection(new Pi(a))),!0)}}function Fi(t,e,n){if(!t.editable)return!1;var r=t.state.doc.resolve(e);if(!Pi.valid(r))return!1;var o=t.posAtCoords({left:n.clientX,top:n.clientY}).inside;return!(o>-1&&se.isSelectable(t.state.doc.nodeAt(o))||(t.dispatch(t.state.tr.setSelection(new Pi(r))),0))}function $i(t){if(!(t.selection instanceof Pi))return null;var e=document.createElement("div");return e.className="ProseMirror-gapcursor",Xr.create(t.doc,[Kr.widget(t.selection.head,e,{key:"gapcursor"})])}function qi(){var t=arguments[0];"string"==typeof t&&(t=document.createElement(t));var e=1,n=arguments[1];if(n&&"object"==typeof n&&null==n.nodeType&&!Array.isArray(n)){for(var r in n)if(Object.prototype.hasOwnProperty.call(n,r)){var o=n[r];"string"==typeof o?t.setAttribute(r,o):null!=o&&(t[r]=o)}e++}for(;e<arguments.length;e++)ji(t,arguments[e]);return t}function ji(t,e){if("string"==typeof e)t.appendChild(document.createTextNode(e));else if(null==e);else if(null!=e.nodeType)t.appendChild(e);else{if(!Array.isArray(e))throw new RangeError("Unsupported child node: "+e);for(var n=0;n<e.length;n++)ji(t,e[n])}}var Ui="http://www.w3.org/2000/svg",Ji="ProseMirror-icon";var Wi="ProseMirror-menu",Ki=function(t){this.spec=t};function Hi(t,e){return t._props.translate?t._props.translate(e):e}Ki.prototype.render=function(t){var e=this.spec,n=e.render?e.render(t):e.icon?function(t){var e=document.createElement("div");if(e.className=Ji,t.path){var n="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(n)||function(t,e){var n=document.getElementById(Ji+"-collection");n||((n=document.createElementNS(Ui,"svg")).id=Ji+"-collection",n.style.display="none",document.body.insertBefore(n,document.body.firstChild));var r=document.createElementNS(Ui,"symbol");r.id=t,r.setAttribute("viewBox","0 0 "+e.width+" "+e.height),r.appendChild(document.createElementNS(Ui,"path")).setAttribute("d",e.path),n.appendChild(r)}(n,t);var r=e.appendChild(document.createElementNS(Ui,"svg"));r.style.width=t.width/t.height+"em",r.appendChild(document.createElementNS(Ui,"use")).setAttributeNS("http://www.w3.org/1999/xlink","href",/([^#]*)/.exec(document.location)[1]+"#"+n)}else t.dom?e.appendChild(t.dom.cloneNode(!0)):(e.appendChild(document.createElement("span")).textContent=t.text||"",t.css&&(e.firstChild.style.cssText=t.css));return e}(e.icon):e.label?qi("div",null,Hi(t,e.label)):null;if(!n)throw new RangeError("MenuItem without icon or label property");if(e.title){var r="function"==typeof e.title?e.title(t.state):e.title;n.setAttribute("title",Hi(t,r))}return e.class&&n.classList.add(e.class),e.css&&(n.style.cssText+=e.css),n.addEventListener("mousedown",(function(r){r.preventDefault(),n.classList.contains(Wi+"-disabled")||e.run(t.state,t.dispatch,t,r)})),{dom:n,update:function(t){if(e.select){var r=e.select(t);if(n.style.display=r?"":"none",!r)return!1}var o=!0;if(e.enable&&(o=e.enable(t)||!1,hs(n,Wi+"-disabled",!o)),e.active){var i=o&&e.active(t)||!1;hs(n,Wi+"-active",i)}return!0}}};var Gi={time:0,node:null};function Yi(t){Gi.time=Date.now(),Gi.node=t.target}function Xi(t){return Date.now()-100<Gi.time&&Gi.node&&t.contains(Gi.node)}var Qi=function(t,e){this.options=e||{},this.content=Array.isArray(t)?t:[t]};function Zi(t,e){for(var n=[],r=[],o=0;o<t.length;o++){var i=t[o].render(e),s=i.dom,c=i.update;n.push(qi("div",{class:Wi+"-dropdown-item"},s)),r.push(c)}return{dom:n,update:ts(r,n)}}function ts(t,e){return function(n){for(var r=!1,o=0;o<t.length;o++){var i=t[o](n);e[o].style.display=i?"":"none",i&&(r=!0)}return r}}Qi.prototype.render=function(t){var e=this,n=Zi(this.content,t),r=qi("div",{class:Wi+"-dropdown "+(this.options.class||""),style:this.options.css},Hi(t,this.options.label));this.options.title&&r.setAttribute("title",Hi(t,this.options.title));var o=qi("div",{class:Wi+"-dropdown-wrap"},r),i=null,s=null,c=function(){i&&i.close()&&(i=null,window.removeEventListener("mousedown",s))};return r.addEventListener("mousedown",(function(t){t.preventDefault(),Yi(t),i?c():(i=e.expand(o,n.dom),window.addEventListener("mousedown",s=function(){Xi(o)||c()}))})),{dom:o,update:function(t){var e=n.update(t);return o.style.display=e?"":"none",e}}},Qi.prototype.expand=function(t,e){var n=qi("div",{class:Wi+"-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 es=function(t,e){this.options=e||{},this.content=Array.isArray(t)?t:[t]};es.prototype.render=function(t){var e=Zi(this.content,t),n=qi("div",{class:Wi+"-submenu-label"},Hi(t,this.options.label)),r=qi("div",{class:Wi+"-submenu-wrap"},n,qi("div",{class:Wi+"-submenu"},e.dom)),o=null;return n.addEventListener("mousedown",(function(t){t.preventDefault(),Yi(t),hs(r,Wi+"-submenu-wrap-active"),o||window.addEventListener("mousedown",o=function(){Xi(r)||(r.classList.remove(Wi+"-submenu-wrap-active"),window.removeEventListener("mousedown",o),o=null)})})),{dom:r,update:function(t){var n=e.update(t);return r.style.display=n?"":"none",n}}};var ns={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"}},rs=new Ki({title:"Join with above block",run:vi,select:function(t){return vi(t)},icon:ns.join}),is=new Ki({title:"Lift out of enclosing block",run:wi,select:function(t){return wi(t)},icon:ns.lift}),ss=new Ki({title:"Select parent node",run:Si,select:function(t){return Si(t)},icon:ns.selectParentNode}),cs=new Ki({title:"Undo last change",run:ui,enable:function(t){return ui(t)},icon:ns.undo}),as=new Ki({title:"Redo last undone change",run:di,enable:function(t){return di(t)},icon:ns.redo});function ls(t,e){var n=Mi(t,e.attrs),r={run:n,enable:function(t){return n(t)},active:function(n){var r=n.selection,o=r.$from,i=r.to,s=r.node;return s?s.hasMarkup(t,e.attrs):i<=o.end()&&o.parent.hasMarkup(t,e.attrs)}};for(var o in e)r[o]=e[o];return new Ki(r)}function hs(t,e,n){n?t.classList.add(e):t.classList.remove(e)}var us="ProseMirror-menubar",ds=function(t,e){var n=this;this.editorView=t,this.options=e,this.wrapper=qi("div",{class:us+"-wrapper"}),this.menu=this.wrapper.appendChild(qi("div",{class:us})),this.menu.className=us,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=function(t,e){for(var n=document.createDocumentFragment(),r=[],o=[],i=0;i<e.length;i++){for(var s=e[i],c=[],a=[],l=0;l<s.length;l++){var h=s[l].render(t),u=h.dom,d=h.update,p=qi("span",{class:Wi+"item"},u);n.appendChild(p),a.push(p),c.push(d)}c.length&&(r.push(ts(c,a)),i<e.length-1&&o.push(n.appendChild(qi("span",{class:Wi+"separator"}))))}return{dom:n,update:function(t){for(var e=!1,n=!1,i=0;i<r.length;i++){var s=r[i](t);i&&(o[i-1].style.display=n&&s?"":"none"),n=s,s&&(e=!0)}return e}}}(this.editorView,this.options.content),o=r.dom,i=r.update;if(this.contentUpdate=i,this.menu.appendChild(o),this.update(),e.floating&&!function(){if("undefined"==typeof navigator)return!1;var t=navigator.userAgent;return!/Edge\/\d/.test(t)&&/AppleWebKit/.test(t)&&/Mobile\/\w+/.test(t)}()){this.updateFloat();var s=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):s.forEach((function(t){return t.removeEventListener("scroll",n.scrollFunc)}))},s.forEach((function(t){return t.addEventListener("scroll",n.scrollFunc)}))}};ds.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"))},ds.prototype.updateScrollCursor=function(){var t=this.editorView.root.getSelection();if(t.focusNode){var e=t.getRangeAt(0).getClientRects(),n=e[function(t){return t.anchorNode==t.focusNode?t.anchorOffset>t.focusOffset:t.anchorNode.compareDocumentPosition(t.focusNode)==Node.DOCUMENT_POSITION_FOLLOWING}(t)?0:e.length-1];if(n){var r=this.menu.getBoundingClientRect();if(n.top<r.bottom&&n.bottom>r.top){var o=function(t){for(var e=t.parentNode;e;e=e.parentNode)if(e.scrollHeight>e.clientHeight)return e}(this.wrapper);o&&(o.scrollTop-=r.bottom-n.top)}}}},ds.prototype.updateFloat=function(t){var e=this.wrapper,n=e.getBoundingClientRect(),r=t?Math.max(0,t.getBoundingClientRect().top):0;if(this.floating)if(n.top>=r||n.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;else{var o=(e.offsetWidth-e.clientWidth)/2;this.menu.style.left=n.left+o+"px",this.menu.style.display=n.top>window.innerHeight?"none":"",t&&(this.menu.style.top=r+"px")}else if(n.top<r&&n.bottom>=this.menu.offsetHeight+10){this.floating=!0;var i=this.menu.getBoundingClientRect();this.menu.style.left=i.left+"px",this.menu.style.width=i.width+"px",t&&(this.menu.style.top=r+"px"),this.menu.style.position="fixed",this.spacer=qi("div",{class:us+"-spacer",style:"height: "+i.height+"px"}),e.insertBefore(this.spacer,this.menu)}},ds.prototype.destroy=function(){this.wrapper.parentNode&&this.wrapper.parentNode.replaceChild(this.editorView.dom,this.wrapper)};var ps=function(t,e){var n;this.match=t,this.handler="string"==typeof e?(n=e,function(t,e,r,o){var i=n;if(e[1]){var s=e[0].lastIndexOf(e[1]);i+=e[0].slice(s+e[1].length);var c=(r+=s)-o;c>0&&(i=e[0].slice(s-c,s)+i,r=o)}return t.tr.insertText(i,r,o)}):e};function fs(t,e,n,r,o,i){if(t.composing)return!1;var s=t.state,c=s.doc.resolve(e);if(c.parent.type.spec.code)return!1;for(var a=c.parent.textBetween(Math.max(0,c.parentOffset-500),c.parentOffset,null,"￼")+r,l=0;l<o.length;l++){var h=o[l].match.exec(a),u=h&&o[l].handler(s,h,e-(h[0].length-r.length),n);if(u)return t.dispatch(u.setMeta(i,{transform:u,from:e,to:n,text:r})),!0}return!1}function gs(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=t.tr,c=i.transform,a=c.steps.length-1;a>=0;a--)s.step(c.steps[a].invert(c.docs[a]));if(i.text){var l=s.doc.resolve(i.from).marks();s.replaceWith(i.from,i.to,t.schema.text(i.text,l))}else s.delete(i.from,i.to);e(s)}return!0}}return!1}var ms=new ps(/--$/,"—"),vs=new ps(/\.\.\.$/,"…"),ys=[new ps(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“"),new ps(/"$/,"”"),new ps(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘"),new ps(/'$/,"’")];function ws(t,e,n,r){return new ps(t,(function(t,o,i,s){var c=n instanceof Function?n(o):n,a=t.tr.delete(i,s),l=a.doc.resolve(i).blockRange(),h=l&&Rt(l,e,c);if(!h)return null;a.wrap(l,h);var u=a.doc.resolve(i-1).nodeBefore;return u&&u.type==e&&Lt(a.doc,i-1)&&(!r||r(o,u))&&a.join(i-1),a}))}function bs(t,e,n){return new ps(t,(function(t,r,o,i){var s=t.doc.resolve(o),c=n instanceof Function?n(r):n;return s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),e)?t.tr.delete(o,i).setBlockType(o,o,e,c):null}))}var ks="ProseMirror-prompt";function Ss(t){var e=document.body.appendChild(document.createElement("div"));e.className=ks;var n=function(t){e.contains(t.target)||r()};setTimeout((function(){return window.addEventListener("mousedown",n)}),50);var r=function(){window.removeEventListener("mousedown",n),e.parentNode&&e.parentNode.removeChild(e)},o=[];for(var i in t.fields)o.push(t.fields[i].render());var s=document.createElement("button");s.type="submit",s.className=ks+"-submit",s.textContent="OK";var c=document.createElement("button");c.type="button",c.className=ks+"-cancel",c.textContent="Cancel",c.addEventListener("click",r);var a=e.appendChild(document.createElement("form"));t.title&&(a.appendChild(document.createElement("h5")).textContent=t.title),o.forEach((function(t){a.appendChild(document.createElement("div")).appendChild(t)}));var l=a.appendChild(document.createElement("div"));l.className=ks+"-buttons",l.appendChild(s),l.appendChild(document.createTextNode(" ")),l.appendChild(c);var h=e.getBoundingClientRect();e.style.top=(window.innerHeight-h.height)/2+"px",e.style.left=(window.innerWidth-h.width)/2+"px";var u=function(){var e=function(t,e){var n=Object.create(null),r=0;for(var o in t){var i=t[o],s=e[r++],c=i.read(s),a=i.validate(c);if(a)return Cs(s,a),null;n[o]=i.clean(c)}return n}(t.fields,o);e&&(r(),t.callback(e))};a.addEventListener("submit",(function(t){t.preventDefault(),u()})),a.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(){e.contains(document.activeElement)||r()}),500):(t.preventDefault(),u())}));var d=a.elements[0];d&&d.focus()}function Cs(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)}var xs=function(t){this.options=t};xs.prototype.read=function(t){return t.value},xs.prototype.validateType=function(t){},xs.prototype.validate=function(t){return!t&&this.options.required?"Required field":this.validateType(t)||this.options.validate&&this.options.validate(t)},xs.prototype.clean=function(t){return this.options.clean?this.options.clean(t):t};var Ms=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,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}(xs);function _s(t,e){for(var n=t.selection.$from,r=n.depth;r>=0;r--){var o=n.index(r);if(n.node(r).canReplaceWith(o,o,e))return!0}return!1}function Es(t,e){var n={label:e.title,run:t};for(var r in e)n[r]=e[r];return e.enable&&!0!==e.enable||e.select||(n[e.enable?"enable":"select"]=function(e){return t(e)}),new Ki(n)}function Os(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 Ds(t,e){var n={active:function(e){return Os(e,t)},enable:!0};for(var r in e)n[r]=e[r];return Es(_i(t),n)}function Ns(t,e){return Es(To(t,e.attrs),e)}function As(t){var e,n,r,o={};if((e=t.marks.strong)&&(o.toggleStrong=Ds(e,{title:"Toggle strong style",icon:ns.strong})),(e=t.marks.em)&&(o.toggleEm=Ds(e,{title:"Toggle emphasis",icon:ns.em})),(e=t.marks.code)&&(o.toggleCode=Ds(e,{title:"Toggle code font",icon:ns.code})),(e=t.marks.link)&&(o.toggleLink=(n=e,new Ki({title:"Add or remove link",icon:ns.link,active:function(t){return Os(t,n)},enable:function(t){return!t.selection.empty},run:function(t,e,r){if(Os(t,n))return _i(n)(t,e),!0;Ss({title:"Create a link",fields:{href:new Ms({label:"Link target",required:!0}),title:new Ms({label:"Title"})},callback:function(t){_i(n,t)(r.state,r.dispatch),r.focus()}})}}))),(e=t.nodes.image)&&(o.insertImage=(r=e,new Ki({title:"Insert image",label:"Image",enable:function(t){return _s(t,r)},run:function(t,e,n){var o=t.selection,i=o.from,s=o.to,c=null;t.selection instanceof se&&t.selection.node.type==r&&(c=t.selection.node.attrs),Ss({title:"Insert image",fields:{src:new Ms({label:"Location",required:!0,value:c&&c.src}),title:new Ms({label:"Title",value:c&&c.title}),alt:new Ms({label:"Description",value:c?c.alt:t.doc.textBetween(i,s," ")})},callback:function(t){n.dispatch(n.state.tr.replaceSelectionWith(r.createAndFill(t))),n.focus()}})}}))),(e=t.nodes.bullet_list)&&(o.wrapBulletList=Ns(e,{title:"Wrap in bullet list",icon:ns.bulletList})),(e=t.nodes.ordered_list)&&(o.wrapOrderedList=Ns(e,{title:"Wrap in ordered list",icon:ns.orderedList})),(e=t.nodes.blockquote)&&(o.wrapBlockQuote=function(t,e){var n={run:function(n,r){return xi(t,e.attrs)(n,r)},select:function(n){return xi(t,e.attrs instanceof Function?null:e.attrs)(n)}};for(var r in e)n[r]=e[r];return new Ki(n)}(e,{title:"Wrap in block quote",icon:ns.blockquote})),(e=t.nodes.paragraph)&&(o.makeParagraph=ls(e,{title:"Change to paragraph",label:"Plain"})),(e=t.nodes.code_block)&&(o.makeCodeBlock=ls(e,{title:"Change to code block",label:"Code"})),e=t.nodes.heading)for(var i=1;i<=10;i++)o["makeHead"+i]=ls(e,{title:"Change to heading "+i,label:"Level "+i,attrs:{level:i}});if(e=t.nodes.horizontal_rule){var s=e;o.insertHorizontalRule=new Ki({title:"Insert horizontal rule",label:"Horizontal rule",enable:function(t){return _s(t,s)},run:function(t,e){e(t.tr.replaceSelectionWith(s.create()))}})}var c=function(t){return t.filter((function(t){return t}))};return o.insertMenu=new Qi(c([o.insertImage,o.insertHorizontalRule]),{label:"Insert"}),o.typeMenu=new Qi(c([o.makeParagraph,o.makeCodeBlock,o.makeHead1&&new es(c([o.makeHead1,o.makeHead2,o.makeHead3,o.makeHead4,o.makeHead5,o.makeHead6]),{label:"Heading"})]),{label:"Type..."}),o.inlineMenu=[c([o.toggleStrong,o.toggleEm,o.toggleCode,o.toggleLink])],o.blockMenu=[c([o.wrapBulletList,o.wrapOrderedList,o.wrapBlockQuote,rs,is,ss])],o.fullMenu=o.inlineMenu.concat([[o.insertMenu,o.typeMenu]],[[cs,as]],o.blockMenu),o}var Ts="undefined"!=typeof navigator&&/Mac/.test(navigator.platform);function Is(t,e){var n,r,i={};function s(t,n){if(e){var r=e[t];if(!1===r)return;r&&(t=r)}i[t]=n}if(s("Mod-z",ui),s("Shift-Mod-z",di),s("Backspace",gs),Ts||s("Mod-y",di),s("Alt-ArrowUp",vi),s("Alt-ArrowDown",yi),s("Mod-BracketLeft",wi),s("Escape",Si),(n=t.marks.strong)&&(s("Mod-b",_i(n)),s("Mod-B",_i(n))),(n=t.marks.em)&&(s("Mod-i",_i(n)),s("Mod-I",_i(n))),(n=t.marks.code)&&s("Mod-`",_i(n)),(n=t.nodes.bullet_list)&&s("Shift-Ctrl-8",To(n)),(n=t.nodes.ordered_list)&&s("Shift-Ctrl-9",To(n)),(n=t.nodes.blockquote)&&s("Ctrl->",xi(n)),n=t.nodes.hard_break){var c=n,a=Ei(ki,(function(t,e){return e(t.tr.replaceSelectionWith(c.create()).scrollIntoView()),!0}));s("Mod-Enter",a),s("Shift-Enter",a),Ts&&s("Ctrl-Enter",a)}if((n=t.nodes.list_item)&&(s("Enter",(r=n,function(t,e){var n=t.selection,i=n.$from,s=n.$to,c=n.node;if(c&&c.isBlock||i.depth<2||!i.sameParent(s))return!1;var a=i.node(-1);if(a.type!=r)return!1;if(0==i.parent.content.size&&i.node(-1).childCount==i.indexAfter(-1)){if(2==i.depth||i.node(-3).type!=r||i.index(-2)!=i.node(-2).childCount-1)return!1;if(e){for(var l=o.empty,h=i.index(-1)?1:i.index(-2)?2:3,d=i.depth-h;d>=i.depth-3;d--)l=o.from(i.node(d).copy(l));var p=i.indexAfter(-1)<i.node(-2).childCount?1:i.indexAfter(-2)<i.node(-3).childCount?2:3;l=l.append(o.from(r.createAndFill()));var f=i.before(i.depth-(h-1)),g=t.tr.replace(f,i.after(-p),new u(l,4-h,0)),m=-1;g.doc.nodesBetween(f,g.doc.content.size,(function(t,e){if(m>-1)return!1;t.isTextblock&&0==t.content.size&&(m=e+1)})),m>-1&&g.setSelection(t.selection.constructor.near(g.doc.resolve(m))),e(g.scrollIntoView())}return!0}var v=s.pos==i.end()?a.contentMatchAt(0).defaultType:null,y=t.tr.delete(i.pos,s.pos),w=v&&[null,{type:v}];return!!Pt(y.doc,i.pos,2,w)&&(e&&e(y.split(i.pos,2,w).scrollIntoView()),!0)})),s("Mod-[",function(t){return function(e,n){var r=e.selection,i=r.$from,s=r.$to,c=i.blockRange(s,(function(e){return e.childCount&&e.firstChild.type==t}));return!!c&&(!n||(i.node(c.depth-1).type==t?function(t,e,n,r){var i=t.tr,s=r.end,c=r.$to.end(r.depth);return s<c&&(i.step(new Nt(s-1,c,s,c,new u(o.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new D(i.doc.resolve(r.$from.pos),i.doc.resolve(c),r.depth)),e(i.lift(r,It(r)).scrollIntoView()),!0}(e,n,t,c):function(t,e,n){for(var r=t.tr,i=n.parent,s=n.end,c=n.endIndex-1,a=n.startIndex;c>a;c--)s-=i.child(c).nodeSize,r.delete(s-1,s+1);var l=r.doc.resolve(n.start),h=l.nodeAfter;if(r.mapping.map(n.end)!=n.start+l.nodeAfter.nodeSize)return!1;var d=0==n.startIndex,p=n.endIndex==i.childCount,f=l.node(-1),g=l.index(-1);if(!f.canReplace(g+(d?0:1),g+1,h.content.append(p?o.empty:o.from(i))))return!1;var m=l.pos,v=m+h.nodeSize;return r.step(new Nt(m-(d?1:0),v+(p?1:0),m+1,v-1,new u((d?o.empty:o.from(i.copy(o.empty))).append(p?o.empty:o.from(i.copy(o.empty))),d?0:1,p?0:1),d?0:1)),e(r.scrollIntoView()),!0}(e,n,c)))}}(n)),s("Mod-]",function(t){return function(e,n){var r=e.selection,i=r.$from,s=r.$to,c=i.blockRange(s,(function(e){return e.childCount&&e.firstChild.type==t}));if(!c)return!1;var a=c.startIndex;if(0==a)return!1;var l=c.parent,h=l.child(a-1);if(h.type!=t)return!1;if(n){var d=h.lastChild&&h.lastChild.type==l.type,p=o.from(d?t.create():null),f=new u(o.from(t.create(null,o.from(l.type.create(null,p)))),d?3:1,0),g=c.start,m=c.end;n(e.tr.step(new Nt(g-(d?3:1),m,g,m,f,1,!0)).scrollIntoView())}return!0}}(n))),(n=t.nodes.paragraph)&&s("Shift-Ctrl-0",Mi(n)),(n=t.nodes.code_block)&&s("Shift-Ctrl-\\",Mi(n)),n=t.nodes.heading)for(var l=1;l<=6;l++)s("Shift-Ctrl-"+l,Mi(n,{level:l}));if(n=t.nodes.horizontal_rule){var h=n;s("Mod-_",(function(t,e){return e(t.tr.replaceSelectionWith(h.create()).scrollIntoView()),!0}))}return i}function Rs(t){var e,n=ys.concat(vs,ms);return(e=t.nodes.blockquote)&&n.push(ws(/^\s*>\s$/,e)),(e=t.nodes.ordered_list)&&n.push(ws(/^(\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)&&n.push(function(t){return ws(/^\s*([-+*])\s$/,t)}(e)),(e=t.nodes.code_block)&&n.push(function(t){return bs(/^```$/,t)}(e)),(e=t.nodes.heading)&&n.push(function(t,e){return bs(new RegExp("^(#{1,6})\\s$"),t,(function(t){return{level:t[1].length}}))}(e)),function(t){var e=t.rules,n=new ke({state:{init:function(){return null},apply:function(t,e){return t.getMeta(this)||(t.selectionSet||t.docChanged?null:e)}},props:{handleTextInput:function(t,r,o,i){return fs(t,r,o,i,e,n)},handleDOMEvents:{compositionend:function(t){setTimeout((function(){var r=t.state.selection.$cursor;r&&fs(t,r.pos,r.pos,"",e,n)}))}}},isInputRules:!0});return n}({rules:n})}function zs(t){var e,n=[Rs(t.schema),Wo(Is(t.schema,t.mapKeys)),Wo(Ii),Ri(),new ke({props:{decorations:$i,createSelectionBetween:function(t,e,n){if(e.pos==n.pos&&Pi.valid(n))return new Pi(n)},handleClick:Fi,handleKeyDown:Bi}})];return!1!==t.menuBar&&n.push(function(t){return new ke({view:function(e){return new ds(e,t)}})}({floating:!1!==t.floatingMenu,content:t.menuContent||As(t.schema).fullMenu})),!1!==t.history&&n.push((e={depth:e&&e.depth||100,newGroupDelay:e&&e.newGroupDelay||500},new ke({key:li,state:{init:function(){return new ei(Zo.empty,Zo.empty,null,0)},apply:function(t,n,r){return function(t,e,n,r){var o,i=n.getMeta(li);if(i)return i.historyState;n.getMeta(hi)&&(t=new ei(t.done,t.undone,null,0));var s=n.getMeta("appendedTransaction");if(0==n.steps.length)return t;if(s&&s.getMeta(li))return s.getMeta(li).redo?new ei(t.done.addTransform(n,null,r,ai(e)),t.undone,ri(n.mapping.maps[n.steps.length-1]),t.prevTime):new ei(t.done,t.undone.addTransform(n,null,r,ai(e)),null,t.prevTime);if(!1===n.getMeta("addToHistory")||s&&!1===s.getMeta("addToHistory"))return(o=n.getMeta("rebased"))?new ei(t.done.rebased(n,o),t.undone.rebased(n,o),oi(t.prevRanges,n.mapping),t.prevTime):new ei(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),oi(t.prevRanges,n.mapping),t.prevTime);var c=0==t.prevTime||!s&&(t.prevTime<(n.time||0)-r.newGroupDelay||!function(t,e){if(!e)return!1;if(!t.docChanged)return!0;var n=!1;return t.mapping.maps[0].forEach((function(t,r){for(var o=0;o<e.length;o+=2)t<=e[o+1]&&r>=e[o]&&(n=!0)})),n}(n,t.prevRanges)),a=s?oi(t.prevRanges,n.mapping):ri(n.mapping.maps[n.steps.length-1]);return new ei(t.done.addTransform(n,c?e.selection.getBookmark():null,r,ai(e)),Zo.empty,a,n.time)}(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput:function(t,e){var n="historyUndo"==e.inputType?ui(t.state,t.dispatch):"historyRedo"==e.inputType&&di(t.state,t.dispatch);return n&&e.preventDefault(),n}}}}))),n.concat(new ke({props:{attributes:{class:"ProseMirror-example-setup-style"}}}))}const Ps=()=>new Map,Ls=t=>{const e=Ps();return t.forEach(((t,n)=>{e.set(n,t)})),e},Bs=(t,e,n)=>{let r=t.get(e);return void 0===r&&t.set(e,r=n()),r},Vs=()=>new Set,Fs=t=>t[t.length-1],$s=(t,e)=>{for(let n=0;n<e.length;n++)t.push(e[n])},qs=Array.from,js=Math.floor,Us=(Math.ceil,Math.abs),Js=(Math.imul,Math.round,Math.log10,Math.log2,Math.log,Math.sqrt,(t,e)=>t<e?t:e),Ws=(t,e)=>t>e?t:e,Ks=(Number.isNaN,Math.pow,Math.sign,t=>0!==t?t<0:1/t<0),Hs=(String.fromCharCode,String.fromCodePoint,/^\s*/g),Gs=/([A-Z])/g,Ys=(t,e)=>(t=>t.replace(Hs,""))(t.replace(Gs,(t=>`${e}${(t=>t.toLowerCase())(t)}`)));"undefined"!=typeof TextEncoder&&new TextEncoder;let Xs="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});Xs&&1===Xs.decode(new Uint8Array).length&&(Xs=null);let Qs=new class{constructor(){this.map=new Map}setItem(t,e){this.map.set(t,e)}getItem(t){return this.map.get(t)}},Zs=!0;try{"undefined"!=typeof localStorage&&(Qs=localStorage,Zs=!1)}catch(t){}const tc=Qs,ec="undefined"!=typeof process&&process.release&&/node|io\.js/.test(process.release.name);let nc;"undefined"!=typeof navigator&&/Mac/.test(navigator.platform);const rc=[];(t=>(()=>{if(void 0===nc)if(ec){nc=Ps();const t=process.argv;let e=null;for(let n=0;n<t.length;n++){const r=t[n];"-"===r[0]?(null!==e&&nc.set(e,""),e=r):null!==e?(nc.set(e,r),e=null):rc.push(r)}null!==e&&nc.set(e,"")}else"object"==typeof location?(nc=Ps(),(location.search||"?").slice(1).split("&").forEach((t=>{if(0!==t.length){const[e,n]=t.split("=");nc.set(`--${Ys(e,"-")}`,n),nc.set(`-${Ys(e,"-")}`,n)}}))):nc=Ps();return nc})().has(t))("--"+"production")||(t=>{return void 0===(e=ec?process.env[t.toUpperCase()]:tc.getItem(t))?null:e;var e})("production");const oc=(t,e,n)=>new Uint8Array(t,e,n),ic=64,sc=128,cc=127,ac=(Number.MAX_SAFE_INTEGER,Number.MIN_SAFE_INTEGER,Number.isInteger||(t=>"number"==typeof t&&isFinite(t)&&js(t)===t));Number.isNaN;class lc{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const hc=()=>new lc,uc=t=>{const e=new Uint8Array((t=>{let e=t.cpos;for(let n=0;n<t.bufs.length;n++)e+=t.bufs[n].length;return e})(t));let n=0;for(let r=0;r<t.bufs.length;r++){const o=t.bufs[r];e.set(o,n),n+=o.length}return e.set(oc(t.cbuf.buffer,0,t.cpos),n),e},dc=(t,e)=>{const n=t.cbuf.length;t.cpos===n&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(2*n),t.cpos=0),t.cbuf[t.cpos++]=e},pc=dc,fc=(t,e)=>{for(;e>cc;)dc(t,sc|cc&e),e>>>=7;dc(t,cc&e)},gc=(t,e)=>{const n=Ks(e);for(n&&(e=-e),dc(t,(e>63?sc:0)|(n?ic:0)|63&e),e>>>=6;e>0;)dc(t,(e>cc?sc:0)|cc&e),e>>>=7},mc=(t,e)=>{const n=unescape(encodeURIComponent(e)),r=n.length;fc(t,r);for(let e=0;e<r;e++)dc(t,n.codePointAt(e))},vc=(t,e)=>{const n=t.cbuf.length,r=t.cpos,o=Js(n-r,e.length),i=e.length-o;t.cbuf.set(e.subarray(0,o),r),t.cpos+=o,i>0&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(Ws(2*n,i)),t.cbuf.set(e.subarray(o)),t.cpos=i)},yc=(t,e)=>{fc(t,e.byteLength),vc(t,e)},wc=(t,e)=>{((t,e)=>{const n=t.cbuf.length;n-t.cpos<e&&(t.bufs.push(oc(t.cbuf.buffer,0,t.cpos)),t.cbuf=new Uint8Array(2*Ws(n,e)),t.cpos=0)})(t,e);const n=new DataView(t.cbuf.buffer,t.cpos,e);return t.cpos+=e,n},bc=new DataView(new ArrayBuffer(4)),kc=(t,e)=>{switch(typeof e){case"string":dc(t,119),mc(t,e);break;case"number":ac(e)&&e<=2147483647?(dc(t,125),gc(t,e)):(n=e,bc.setFloat32(0,n),bc.getFloat32(0)===n?(dc(t,124),((t,e)=>{wc(t,4).setFloat32(0,e,!1)})(t,e)):(dc(t,123),((t,e)=>{wc(t,8).setFloat64(0,e,!1)})(t,e)));break;case"bigint":dc(t,122),((t,e)=>{wc(t,8).setBigInt64(0,e,!1)})(t,e);break;case"object":if(null===e)dc(t,126);else if(e instanceof Array){dc(t,117),fc(t,e.length);for(let n=0;n<e.length;n++)kc(t,e[n])}else if(e instanceof Uint8Array)dc(t,116),yc(t,e);else{dc(t,118);const n=Object.keys(e);fc(t,n.length);for(let r=0;r<n.length;r++){const o=n[r];mc(t,o),kc(t,e[o])}}break;case"boolean":dc(t,e?120:121);break;default:dc(t,127)}var n};class Sc extends lc{constructor(t){super(),this.w=t,this.s=null,this.count=0}write(t){this.s===t?this.count++:(this.count>0&&fc(this,this.count-1),this.count=1,this.w(this,t),this.s=t)}}const Cc=t=>{t.count>0&&(gc(t.encoder,1===t.count?t.s:-t.s),t.count>1&&fc(t.encoder,t.count-2))};class xc{constructor(){this.encoder=new lc,this.s=0,this.count=0}write(t){this.s===t?this.count++:(Cc(this),this.count=1,this.s=t)}toUint8Array(){return Cc(this),uc(this.encoder)}}const Mc=t=>{if(t.count>0){const e=t.diff<<1|(1===t.count?0:1);gc(t.encoder,e),t.count>1&&fc(t.encoder,t.count-2)}};class _c{constructor(){this.encoder=new lc,this.s=0,this.count=0,this.diff=0}write(t){this.diff===t-this.s?(this.s=t,this.count++):(Mc(this),this.count=1,this.diff=t-this.s,this.s=t)}toUint8Array(){return Mc(this),uc(this.encoder)}}class Ec{constructor(){this.sarr=[],this.s="",this.lensE=new xc}write(t){this.s+=t,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(t.length)}toUint8Array(){const t=new lc;return this.sarr.push(this.s),this.s="",mc(t,this.sarr.join("")),vc(t,this.lensE.toUint8Array()),uc(t)}}class Oc{constructor(t){this.arr=t,this.pos=0}}const Dc=t=>new Oc(t),Nc=t=>((t,e)=>{const n=oc(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,n})(t,Tc(t)),Ac=t=>t.arr[t.pos++],Tc=t=>{let e=0,n=0;for(;;){const r=t.arr[t.pos++];if(e|=(r&cc)<<n,n+=7,r<sc)return e>>>0;if(n>35)throw new Error("Integer out of range!")}},Ic=t=>{let e=t.arr[t.pos++],n=63&e,r=6;const o=(e&ic)>0?-1:1;if(0==(e&sc))return o*n;for(;;){if(e=t.arr[t.pos++],n|=(e&cc)<<r,r+=7,e<sc)return o*(n>>>0);if(r>41)throw new Error("Integer out of range!")}},Rc=t=>{let e=Tc(t);if(0===e)return"";{let n=String.fromCodePoint(Ac(t));if(--e<100)for(;e--;)n+=String.fromCodePoint(Ac(t));else for(;e>0;){const r=e<1e4?e:1e4,o=t.arr.subarray(t.pos,t.pos+r);t.pos+=r,n+=String.fromCodePoint.apply(null,o),e-=r}return decodeURIComponent(escape(n))}},zc=(t,e)=>{const n=new DataView(t.arr.buffer,t.arr.byteOffset+t.pos,e);return t.pos+=e,n},Pc=[t=>{},t=>null,Ic,t=>zc(t,4).getFloat32(0,!1),t=>zc(t,8).getFloat64(0,!1),t=>zc(t,8).getBigInt64(0,!1),t=>!1,t=>!0,Rc,t=>{const e=Tc(t),n={};for(let r=0;r<e;r++)n[Rc(t)]=Lc(t);return n},t=>{const e=Tc(t),n=[];for(let r=0;r<e;r++)n.push(Lc(t));return n},Nc],Lc=t=>Pc[127-Ac(t)](t);class Bc extends Oc{constructor(t,e){super(t),this.reader=e,this.s=null,this.count=0}read(){return 0===this.count&&(this.s=this.reader(this),(t=this).pos!==t.arr.length?this.count=Tc(this)+1:this.count=-1),this.count--,this.s;var t}}class Vc extends Oc{constructor(t){super(t),this.s=0,this.count=0}read(){if(0===this.count){this.s=Ic(this);const t=Ks(this.s);this.count=1,t&&(this.s=-this.s,this.count=Tc(this)+2)}return this.count--,this.s}}class Fc extends Oc{constructor(t){super(t),this.s=0,this.count=0,this.diff=0}read(){if(0===this.count){const t=Ic(this),e=1&t;this.diff=t>>1,this.count=1,e&&(this.count=Tc(this)+2)}return this.s+=this.diff,this.count--,this.s}}class $c{constructor(t){this.decoder=new Vc(t),this.str=Rc(this.decoder),this.spos=0}read(){const t=this.spos+this.decoder.read(),e=this.str.slice(this.spos,t);return this.spos=t,e}}"undefined"==typeof window||void 0!==window.performance&&window.performance;const qc="undefined"==typeof crypto?null:crypto,jc=null!==qc?t=>{const e=new ArrayBuffer(t),n=new Uint8Array(e);return qc.getRandomValues(n),e}:t=>{const e=new ArrayBuffer(t),n=new Uint8Array(e);for(let e=0;e<t;e++)n[e]=Math.ceil(4294967295*Math.random()>>>0);return e},Uc=(Math.random,()=>new Uint32Array(jc(4))[0]),Jc=[1e7]+-1e3+-4e3+-8e3+-1e11,Wc=()=>Jc.replace(/[018]/g,(t=>(t^Uc()&15>>t/4).toString(16))),Kc=t=>new Error(t),Hc=()=>{throw Kc("Method unimplemented")},Gc=()=>{throw Kc("Unexpected case")},Yc=(t,e,n=0)=>{try{for(;n<t.length;n++)t[n](...e)}finally{n<t.length&&Yc(t,e,n+1)}},Xc=Symbol;class Qc{constructor(t,e){this.left=t,this.right=e}}const Zc=(t,e)=>new Qc(t,e),ta="undefined"!=typeof document?document:{},ea=("undefined"!=typeof DOMParser&&new DOMParser,ta.ELEMENT_NODE,ta.TEXT_NODE,ta.CDATA_SECTION_NODE,ta.COMMENT_NODE,ta.DOCUMENT_NODE,ta.DOCUMENT_TYPE_NODE,ta.DOCUMENT_FRAGMENT_NODE,Date.now),na=Xc(),ra=Xc(),oa=Xc(),ia=Xc(),sa=Xc(),ca=Xc(),aa=Xc(),la=Xc(),ha=Xc(),ua={[na]:Zc("font-weight","bold"),[ra]:Zc("font-weight","normal"),[oa]:Zc("color","blue"),[sa]:Zc("color","green"),[ia]:Zc("color","grey"),[ca]:Zc("color","red"),[aa]:Zc("color","purple"),[la]:Zc("color","orange"),[ha]:Zc("color","black")},da={[na]:"[1m",[ra]:"[2m",[oa]:"[34m",[sa]:"[32m",[ia]:"[37m",[ca]:"[31m",[aa]:"[35m",[la]:"[38;5;208m",[ha]:"[0m"},pa=ec?t=>{const e=[],n=[];let r=0;for(;r<t.length;r++){const n=t[r],o=da[n];if(void 0!==o)e.push(o);else{if(n.constructor!==String&&n.constructor!==Number)break;e.push(n)}}for(r>0&&(e.push("[0m"),n.push(e.join("")));r<t.length;r++){const e=t[r];e instanceof Symbol||n.push(e)}return n}:t=>{const e=[],n=[],r=Ps();let o=[],i=0;for(;i<t.length;i++){const o=t[i],s=ua[o];if(void 0!==s)r.set(s.left,s.right);else{if(o.constructor!==String&&o.constructor!==Number)break;{const t=((t,e)=>{const n=[];for(const[r,o]of t)n.push(e(o,r));return n})(r,((t,e)=>`${e}:${t};`)).join("");i>0||t.length>0?(e.push("%c"+o),n.push(t)):e.push(o)}}}for(i>0&&(o=n,o.unshift(e.join("")));i<t.length;i++){const e=t[i];e instanceof Symbol||o.push(e)}return o},fa=new Set;ea();const ga=t=>({[Symbol.iterator](){return this},next:t}),ma=(t,e)=>ga((()=>{const{done:n,value:r}=t.next();return{done:n,value:n?void 0:e(r)}})),va=(Object.assign,Object.keys),ya=t=>va(t).length;class wa{constructor(t,e){this.clock=t,this.len=e}}class ba{constructor(){this.clients=new Map}}const ka=(t,e,n)=>e.clients.forEach(((e,r)=>{const o=t.doc.store.clients.get(r);for(let r=0;r<e.length;r++){const i=e[r];ll(t,o,i.clock,i.len,n)}})),Sa=(t,e)=>{const n=t.clients.get(e.client);return void 0!==n&&null!==((t,e)=>{let n=0,r=t.length-1;for(;n<=r;){const o=js((n+r)/2),i=t[o],s=i.clock;if(s<=e){if(e<s+i.len)return o;n=o+1}else r=o-1}return null})(n,e.clock)},Ca=t=>{t.clients.forEach((t=>{let e,n;for(t.sort(((t,e)=>t.clock-e.clock)),e=1,n=1;e<t.length;e++){const r=t[n-1],o=t[e];r.clock+r.len>=o.clock?r.len=Ws(r.len,o.clock+o.len-r.clock):(n<e&&(t[n]=o),n++)}t.length=n}))},xa=(t,e,n,r)=>{Bs(t.clients,e,(()=>[])).push(new wa(n,r))},Ma=()=>new ba,_a=(t,e)=>{fc(t.restEncoder,e.clients.size),e.clients.forEach(((e,n)=>{t.resetDsCurVal(),fc(t.restEncoder,n);const r=e.length;fc(t.restEncoder,r);for(let n=0;n<r;n++){const r=e[n];t.writeDsClock(r.clock),t.writeDsLen(r.len)}}))},Ea=t=>{const e=new ba,n=Tc(t.restDecoder);for(let r=0;r<n;r++){t.resetDsCurVal();const n=Tc(t.restDecoder),r=Tc(t.restDecoder);if(r>0){const o=Bs(e.clients,n,(()=>[]));for(let e=0;e<r;e++)o.push(new wa(t.readDsClock(),t.readDsLen()))}}return e},Oa=(t,e,n)=>{const r=new ba,o=Tc(t.restDecoder);for(let i=0;i<o;i++){t.resetDsCurVal();const o=Tc(t.restDecoder),i=Tc(t.restDecoder),s=n.clients.get(o)||[],c=nl(n,o);for(let n=0;n<i;n++){const n=t.readDsClock(),i=n+t.readDsLen();if(n<c){c<i&&xa(r,o,c,i-c);let t=ol(s,n),a=s[t];for(!a.deleted&&a.id.clock<n&&(s.splice(t+1,0,Fh(e,a,n-a.id.clock)),t++);t<s.length&&(a=s[t++],a.id.clock<i);)a.deleted||(i<a.id.clock+a.length&&s.splice(t,0,Fh(e,a,i-a.id.clock)),a.delete(e))}else xa(r,o,n,i-n)}}if(r.clients.size>0){const t=new za;return fc(t.restEncoder,0),_a(t,r),t.toUint8Array()}return null},Da=Uc;class Na extends class{constructor(){this._observers=Ps()}on(t,e){Bs(this._observers,t,Vs).add(e)}once(t,e){const n=(...r)=>{this.off(t,n),e(...r)};this.on(t,n)}off(t,e){const n=this._observers.get(t);void 0!==n&&(n.delete(e),0===n.size&&this._observers.delete(t))}emit(t,e){return qs((this._observers.get(t)||Ps()).values()).forEach((t=>t(...e)))}destroy(){this._observers=Ps()}}{constructor({guid:t=Wc(),gc:e=!0,gcFilter:n=(()=>!0),meta:r=null,autoLoad:o=!1}={}){super(),this.gc=e,this.gcFilter=n,this.clientID=Da(),this.guid=t,this.share=new Map,this.store=new tl,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=o,this.autoLoad=o,this.meta=r}load(){const t=this._item;null===t||this.shouldLoad||gl(t.parent.doc,(t=>{t.subdocsLoaded.add(this)}),null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(Array.from(this.subdocs).map((t=>t.guid)))}transact(t,e=null){gl(this,t,e)}get(t,e=Rl){const n=Bs(this.share,t,(()=>{const t=new e;return t._integrate(this,null),t})),r=n.constructor;if(e!==Rl&&r!==e){if(r===Rl){const r=new e;r._map=n._map,n._map.forEach((t=>{for(;null!==t;t=t.left)t.parent=r})),r._start=n._start;for(let t=r._start;null!==t;t=t.right)t.parent=r;return r._length=n._length,this.share.set(t,r),r._integrate(this,null),r}throw new Error(`Type with the name ${t} has already been defined with a different constructor`)}return n}getArray(t=""){return this.get(t,Ql)}getText(t=""){return this.get(t,fh)}getMap(t=""){return this.get(t,th)}getXmlFragment(t=""){return this.get(t,mh)}toJSON(){const t={};return this.share.forEach(((e,n)=>{t[n]=e.toJSON()})),t}destroy(){qs(this.subdocs).forEach((t=>t.destroy()));const t=this._item;if(null!==t){this._item=null;const e=t.content;t.deleted?e.doc=null:(e.doc=new Na({guid:this.guid,...e.opts}),e.doc._item=t),gl(t.parent.doc,(n=>{t.deleted||n.subdocsAdded.add(e.doc),n.subdocsRemoved.add(this)}),null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}on(t,e){super.on(t,e)}off(t,e){super.off(t,e)}}class Aa{constructor(t){this.restDecoder=t}resetDsCurVal(){}readDsClock(){return Tc(this.restDecoder)}readDsLen(){return Tc(this.restDecoder)}}class Ta extends Aa{readLeftID(){return Ha(Tc(this.restDecoder),Tc(this.restDecoder))}readRightID(){return Ha(Tc(this.restDecoder),Tc(this.restDecoder))}readClient(){return Tc(this.restDecoder)}readInfo(){return Ac(this.restDecoder)}readString(){return Rc(this.restDecoder)}readParentInfo(){return 1===Tc(this.restDecoder)}readTypeRef(){return Tc(this.restDecoder)}readLen(){return Tc(this.restDecoder)}readAny(){return Lc(this.restDecoder)}readBuf(){return(t=>{const e=(n=t.byteLength,new Uint8Array(n));var n;return e.set(t),e})(Nc(this.restDecoder))}readJSON(){return JSON.parse(Rc(this.restDecoder))}readKey(){return Rc(this.restDecoder)}}class Ia extends class{constructor(t){this.dsCurrVal=0,this.restDecoder=t}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=Tc(this.restDecoder),this.dsCurrVal}readDsLen(){const t=Tc(this.restDecoder)+1;return this.dsCurrVal+=t,t}}{constructor(t){super(t),this.keys=[],Tc(t),this.keyClockDecoder=new Fc(Nc(t)),this.clientDecoder=new Vc(Nc(t)),this.leftClockDecoder=new Fc(Nc(t)),this.rightClockDecoder=new Fc(Nc(t)),this.infoDecoder=new Bc(Nc(t),Ac),this.stringDecoder=new $c(Nc(t)),this.parentInfoDecoder=new Bc(Nc(t),Ac),this.typeRefDecoder=new Vc(Nc(t)),this.lenDecoder=new Vc(Nc(t))}readLeftID(){return new Wa(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new Wa(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return 1===this.parentInfoDecoder.read()}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return Lc(this.restDecoder)}readBuf(){return Nc(this.restDecoder)}readJSON(){return Lc(this.restDecoder)}readKey(){const t=this.keyClockDecoder.read();if(t<this.keys.length)return this.keys[t];{const t=this.stringDecoder.read();return this.keys.push(t),t}}}class Ra extends class{constructor(){this.restEncoder=hc()}toUint8Array(){return uc(this.restEncoder)}resetDsCurVal(){}writeDsClock(t){fc(this.restEncoder,t)}writeDsLen(t){fc(this.restEncoder,t)}}{writeLeftID(t){fc(this.restEncoder,t.client),fc(this.restEncoder,t.clock)}writeRightID(t){fc(this.restEncoder,t.client),fc(this.restEncoder,t.clock)}writeClient(t){fc(this.restEncoder,t)}writeInfo(t){pc(this.restEncoder,t)}writeString(t){mc(this.restEncoder,t)}writeParentInfo(t){fc(this.restEncoder,t?1:0)}writeTypeRef(t){fc(this.restEncoder,t)}writeLen(t){fc(this.restEncoder,t)}writeAny(t){kc(this.restEncoder,t)}writeBuf(t){yc(this.restEncoder,t)}writeJSON(t){mc(this.restEncoder,JSON.stringify(t))}writeKey(t){mc(this.restEncoder,t)}}class za extends class{constructor(){this.restEncoder=hc(),this.dsCurrVal=0}toUint8Array(){return uc(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(t){const e=t-this.dsCurrVal;this.dsCurrVal=t,fc(this.restEncoder,e)}writeDsLen(t){0===t&&Gc(),fc(this.restEncoder,t-1),this.dsCurrVal+=t}}{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new _c,this.clientEncoder=new xc,this.leftClockEncoder=new _c,this.rightClockEncoder=new _c,this.infoEncoder=new Sc(pc),this.stringEncoder=new Ec,this.parentInfoEncoder=new Sc(pc),this.typeRefEncoder=new xc,this.lenEncoder=new xc}toUint8Array(){const t=hc();return fc(t,0),yc(t,this.keyClockEncoder.toUint8Array()),yc(t,this.clientEncoder.toUint8Array()),yc(t,this.leftClockEncoder.toUint8Array()),yc(t,this.rightClockEncoder.toUint8Array()),yc(t,uc(this.infoEncoder)),yc(t,this.stringEncoder.toUint8Array()),yc(t,uc(this.parentInfoEncoder)),yc(t,this.typeRefEncoder.toUint8Array()),yc(t,this.lenEncoder.toUint8Array()),vc(t,uc(this.restEncoder)),uc(t)}writeLeftID(t){this.clientEncoder.write(t.client),this.leftClockEncoder.write(t.clock)}writeRightID(t){this.clientEncoder.write(t.client),this.rightClockEncoder.write(t.clock)}writeClient(t){this.clientEncoder.write(t)}writeInfo(t){this.infoEncoder.write(t)}writeString(t){this.stringEncoder.write(t)}writeParentInfo(t){this.parentInfoEncoder.write(t?1:0)}writeTypeRef(t){this.typeRefEncoder.write(t)}writeLen(t){this.lenEncoder.write(t)}writeAny(t){kc(this.restEncoder,t)}writeBuf(t){yc(this.restEncoder,t)}writeJSON(t){kc(this.restEncoder,t)}writeKey(t){void 0===this.keyMap.get(t)?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(t)):this.keyClockEncoder.write(this.keyClock++)}}const Pa=(t,e,n)=>{const r=new Map;n.forEach(((t,n)=>{nl(e,n)>t&&r.set(n,t)})),el(e).forEach(((t,e)=>{n.has(e)||r.set(e,0)})),fc(t.restEncoder,r.size),Array.from(r.entries()).sort(((t,e)=>e[0]-t[0])).forEach((([n,r])=>{((t,e,n,r)=>{r=Ws(r,e[0].id.clock);const o=ol(e,r);fc(t.restEncoder,e.length-o),t.writeClient(n),fc(t.restEncoder,r);const i=e[o];i.write(t,r-i.id.clock);for(let n=o+1;n<e.length;n++)e[n].write(t,0)})(t,e.clients.get(n),n,r)}))},La=(t,e,n,r=Ia)=>{const o=Dc(e);((t,e,n,r=new Ia(t))=>{gl(e,(t=>{t.local=!1;let e=!1;const n=t.doc,o=n.store,i=((t,e)=>{const n=Ps(),r=Tc(t.restDecoder);for(let o=0;o<r;o++){const r=Tc(t.restDecoder),o=new Array(r),i=t.readClient();let s=Tc(t.restDecoder);n.set(i,{i:0,refs:o});for(let n=0;n<r;n++){const r=t.readInfo();switch(31&r){case 0:{const e=t.readLen();o[n]=new Sh(Ha(i,s),e),s+=e;break}case 10:{const e=Tc(t.restDecoder);o[n]=new Uh(Ha(i,s),e),s+=e;break}default:{const c=0==(192&r),a=new $h(Ha(i,s),null,(r&sc)===sc?t.readLeftID():null,null,(r&ic)===ic?t.readRightID():null,c?t.readParentInfo()?e.get(t.readString()):t.readLeftID():null,c&&32==(32&r)?t.readString():null,qh(t,r));o[n]=a,s+=a.length}}}}return n})(r,n),s=((t,e,n)=>{const r=[];let o=Array.from(n.keys()).sort(((t,e)=>t-e));if(0===o.length)return null;const i=()=>{if(0===o.length)return null;let t=n.get(o[o.length-1]);for(;t.refs.length===t.i;){if(o.pop(),!(o.length>0))return null;t=n.get(o[o.length-1])}return t};let s=i();if(null===s&&0===r.length)return null;const c=new tl,a=new Map,l=(t,e)=>{const n=a.get(t);(null==n||n>e)&&a.set(t,e)};let h=s.refs[s.i++];const u=new Map,d=()=>{for(const t of r){const e=t.id.client,r=n.get(e);r?(r.i--,c.clients.set(e,r.refs.slice(r.i)),n.delete(e),r.i=0,r.refs=[]):c.clients.set(e,[t]),o=o.filter((t=>t!==e))}r.length=0};for(;;){if(h.constructor!==Uh){const o=Bs(u,h.id.client,(()=>nl(e,h.id.client)))-h.id.clock;if(o<0)r.push(h),l(h.id.client,h.id.clock-1),d();else{const i=h.getMissing(t,e);if(null!==i){r.push(h);const t=n.get(i)||{refs:[],i:0};if(t.refs.length!==t.i){h=t.refs[t.i++];continue}l(i,nl(e,i)),d()}else(0===o||o<h.length)&&(h.integrate(t,o),u.set(h.id.client,h.id.clock+h.length))}}if(r.length>0)h=r.pop();else if(null!==s&&s.i<s.refs.length)h=s.refs[s.i++];else{if(s=i(),null===s)break;h=s.refs[s.i++]}}if(c.clients.size>0){const t=new za;return Pa(t,c,new Map),fc(t.restEncoder,0),{missing:a,update:t.toUint8Array()}}return null})(t,o,i),c=o.pendingStructs;if(c){for(const[t,n]of c.missing)if(n<nl(o,t)){e=!0;break}if(s){for(const[t,e]of s.missing){const n=c.missing.get(t);(null==n||n>e)&&c.missing.set(t,e)}c.update=bl([c.update,s.update])}}else o.pendingStructs=s;const a=Oa(r,t,o);if(o.pendingDs){const e=new Ia(Dc(o.pendingDs));Tc(e.restDecoder);const n=Oa(e,t,o);o.pendingDs=a&&n?bl([a,n]):a||n}else o.pendingDs=a;if(e){const e=o.pendingStructs.update;o.pendingStructs=null,La(t.doc,e)}}),n,!1)})(o,t,n,new r(o))},Ba=(t,e,n)=>La(t,e,n,Ta),Va=(t,e=new Uint8Array([0]),n=new za)=>{((t,e,n=new Map)=>{Pa(t,e.store,n),_a(t,(t=>{const e=Ma();return t.clients.forEach(((t,n)=>{const r=[];for(let e=0;e<t.length;e++){const n=t[e];if(n.deleted){const o=n.id.clock;let i=n.length;if(e+1<t.length)for(let n=t[e+1];e+1<t.length&&n.deleted;n=t[1+ ++e])i+=n.length;r.push(new wa(o,i))}}r.length>0&&e.clients.set(n,r)})),e})(e.store))})(n,t,Fa(e));const r=[n.toUint8Array()];if(t.store.pendingDs&&r.push(t.store.pendingDs),t.store.pendingStructs&&r.push(kl(t.store.pendingStructs.update,e)),r.length>1){if(n.constructor===Ra)return yl(r.map(((t,e)=>0===e?t:Ml(t))));if(n.constructor===za)return bl(r)}return r[0]},Fa=t=>(t=>{const e=new Map,n=Tc(t.restDecoder);for(let r=0;r<n;r++){const n=Tc(t.restDecoder),r=Tc(t.restDecoder);e.set(n,r)}return e})(new Aa(Dc(t)));class $a{constructor(){this.l=[]}}const qa=()=>new $a,ja=(t,e)=>t.l.push(e),Ua=(t,e)=>{const n=t.l,r=n.length;t.l=n.filter((t=>e!==t)),r===t.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},Ja=(t,e,n)=>Yc(t.l,[e,n]);class Wa{constructor(t,e){this.client=t,this.clock=e}}const Ka=(t,e)=>t===e||null!==t&&null!==e&&t.client===e.client&&t.clock===e.clock,Ha=(t,e)=>new Wa(t,e);class Ga{constructor(t,e){this.ds=t,this.sv=e}}const Ya=(Qa=Ma(),Za=new Map,new Ga(Qa,Za),(t,e)=>void 0===e?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!Sa(e.ds,t.id)),Xa=(t,e)=>{const n=Bs(t.meta,Xa,Vs),r=t.doc.store;n.has(e)||(e.sv.forEach(((e,n)=>{e<nl(r,n)&&cl(t,Ha(n,e))})),ka(t,e.ds,(t=>{})),n.add(e))};var Qa,Za;class tl{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const el=t=>{const e=new Map;return t.clients.forEach(((t,n)=>{const r=t[t.length-1];e.set(n,r.id.clock+r.length)})),e},nl=(t,e)=>{const n=t.clients.get(e);if(void 0===n)return 0;const r=n[n.length-1];return r.id.clock+r.length},rl=(t,e)=>{let n=t.clients.get(e.id.client);if(void 0===n)n=[],t.clients.set(e.id.client,n);else{const t=n[n.length-1];if(t.id.clock+t.length!==e.id.clock)throw Gc()}n.push(e)},ol=(t,e)=>{let n=0,r=t.length-1,o=t[r],i=o.id.clock;if(i===e)return r;let s=js(e/(i+o.length-1)*r);for(;n<=r;){if(o=t[s],i=o.id.clock,i<=e){if(e<i+o.length)return s;n=s+1}else r=s-1;s=js((n+r)/2)}throw Gc()},il=(t,e)=>{const n=t.clients.get(e.client);return n[ol(n,e.clock)]},sl=(t,e,n)=>{const r=ol(e,n),o=e[r];return o.id.clock<n&&o instanceof $h?(e.splice(r+1,0,Fh(t,o,n-o.id.clock)),r+1):r},cl=(t,e)=>{const n=t.doc.store.clients.get(e.client);return n[sl(t,n,e.clock)]},al=(t,e,n)=>{const r=e.clients.get(n.client),o=ol(r,n.clock),i=r[o];return n.clock!==i.id.clock+i.length-1&&i.constructor!==Sh&&r.splice(o+1,0,Fh(t,i,n.clock-i.id.clock+1)),i},ll=(t,e,n,r,o)=>{if(0===r)return;const i=n+r;let s,c=sl(t,e,n);do{s=e[c++],i<s.id.clock+s.length&&sl(t,e,i),o(s)}while(c<e.length&&e[c].id.clock<i)};class hl{constructor(t,e,n){this.doc=t,this.deleteSet=new ba,this.beforeState=el(t.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=e,this.meta=new Map,this.local=n,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set}}const ul=(t,e)=>!(0===e.deleteSet.clients.size&&!((t,n)=>{for(const[n,i]of t)if(r=i,o=n,e.beforeState.get(o)!==r)return!0;var r,o;return!1})(e.afterState)||(Ca(e.deleteSet),((t,e)=>{Pa(t,e.doc.store,e.beforeState)})(t,e),_a(t,e.deleteSet),0)),dl=(t,e,n)=>{const r=e._item;(null===r||r.id.clock<(t.beforeState.get(r.id.client)||0)&&!r.deleted)&&Bs(t.changed,e,Vs).add(n)},pl=(t,e)=>{const n=t[e-1],r=t[e];n.deleted===r.deleted&&n.constructor===r.constructor&&n.mergeWith(r)&&(t.splice(e,1),r instanceof $h&&null!==r.parentSub&&r.parent._map.get(r.parentSub)===r&&r.parent._map.set(r.parentSub,n))},fl=(t,e)=>{if(e<t.length){const n=t[e],r=n.doc,o=r.store,i=n.deleteSet,s=n._mergeStructs;try{Ca(i),n.afterState=el(n.doc.store),r._transaction=null,r.emit("beforeObserverCalls",[n,r]);const c=[];n.changed.forEach(((t,e)=>c.push((()=>{null!==e._item&&e._item.deleted||e._callObserver(n,t)})))),c.push((()=>{n.changedParentTypes.forEach(((t,e)=>c.push((()=>{null!==e._item&&e._item.deleted||((t=t.filter((t=>null===t.target._item||!t.target._item.deleted))).forEach((t=>{t.currentTarget=e})),t.sort(((t,e)=>t.path.length-e.path.length)),Ja(e._dEH,t,n))})))),c.push((()=>r.emit("afterTransaction",[n,r])))})),Yc(c,[])}finally{r.gc&&((t,e,n)=>{for(const[r,o]of t.clients.entries()){const t=e.clients.get(r);for(let r=o.length-1;r>=0;r--){const i=o[r],s=i.clock+i.len;for(let r=ol(t,i.clock),o=t[r];r<t.length&&o.id.clock<s;o=t[++r]){const o=t[r];if(i.clock+i.len<=o.id.clock)break;o instanceof $h&&o.deleted&&!o.keep&&n(o)&&o.gc(e,!1)}}}})(i,o,r.gcFilter),((t,e)=>{t.clients.forEach(((t,n)=>{const r=e.clients.get(n);for(let e=t.length-1;e>=0;e--){const n=t[e];for(let t=Js(r.length-1,1+ol(r,n.clock+n.len-1)),e=r[t];t>0&&e.id.clock>=n.clock;e=r[--t])pl(r,t)}}))})(i,o),n.afterState.forEach(((t,e)=>{const r=n.beforeState.get(e)||0;if(r!==t){const t=o.clients.get(e),n=Ws(ol(t,r),1);for(let e=t.length-1;e>=n;e--)pl(t,e)}}));for(let t=0;t<s.length;t++){const{client:e,clock:n}=s[t].id,r=o.clients.get(e),i=ol(r,n);i+1<r.length&&pl(r,i+1),i>0&&pl(r,i)}if(n.local||n.afterState.get(r.clientID)===n.beforeState.get(r.clientID)||(r.clientID=Da(),((...t)=>{console.log(...pa(t)),fa.forEach((e=>e.print(t)))})(la,na,"[yjs] ",ra,ca,"Changed the client-id because another client seems to be using it.")),r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){const t=new Ra;ul(t,n)&&r.emit("update",[t.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){const t=new za;ul(t,n)&&r.emit("updateV2",[t.toUint8Array(),n.origin,r,n])}n.subdocsAdded.forEach((t=>r.subdocs.add(t))),n.subdocsRemoved.forEach((t=>r.subdocs.delete(t))),r.emit("subdocs",[{loaded:n.subdocsLoaded,added:n.subdocsAdded,removed:n.subdocsRemoved}]),n.subdocsRemoved.forEach((t=>t.destroy())),t.length<=e+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,t])):fl(t,e+1)}}},gl=(t,e,n=null,r=!0)=>{const o=t._transactionCleanups;let i=!1;null===t._transaction&&(i=!0,t._transaction=new hl(t,n,r),o.push(t._transaction),1===o.length&&t.emit("beforeAllTransactions",[t]),t.emit("beforeTransaction",[t._transaction,t]));try{e(t._transaction)}finally{i&&o[0]===t._transaction&&fl(o,0)}};class ml{constructor(t,e){this.gen=function*(t){const e=Tc(t.restDecoder);for(let n=0;n<e;n++){const e=Tc(t.restDecoder),n=t.readClient();let r=Tc(t.restDecoder);for(let o=0;o<e;o++){const e=t.readInfo();if(10===e){const e=Tc(t.restDecoder);yield new Uh(Ha(n,r),e),r+=e}else if(0!=(31&e)){const o=0==(192&e),i=new $h(Ha(n,r),null,(e&sc)===sc?t.readLeftID():null,null,(e&ic)===ic?t.readRightID():null,o?t.readParentInfo()?t.readString():t.readLeftID():null,o&&32==(32&e)?t.readString():null,qh(t,e));yield i,r+=i.length}else{const e=t.readLen();yield new Sh(Ha(n,r),e),r+=e}}}}(t),this.curr=null,this.done=!1,this.filterSkips=e,this.next()}next(){do{this.curr=this.gen.next().value||null}while(this.filterSkips&&null!==this.curr&&this.curr.constructor===Uh);return this.curr}}class vl{constructor(t){this.currClient=0,this.startClock=0,this.written=0,this.encoder=t,this.clientStructs=[]}}const yl=t=>bl(t,Ta,Ra),wl=(t,e)=>{if(t.constructor===Sh){const{client:n,clock:r}=t.id;return new Sh(Ha(n,r+e),t.length-e)}if(t.constructor===Uh){const{client:n,clock:r}=t.id;return new Uh(Ha(n,r+e),t.length-e)}{const n=t,{client:r,clock:o}=n.id;return new $h(Ha(r,o+e),null,Ha(r,o+e-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(e))}},bl=(t,e=Ia,n=za)=>{if(1===t.length)return t[0];const r=t.map((t=>new e(Dc(t))));let o=r.map((t=>new ml(t,!0))),i=null;const s=new n,c=new vl(s);for(;o=o.filter((t=>null!==t.curr)),o.sort(((t,e)=>{if(t.curr.id.client===e.curr.id.client){const n=t.curr.id.clock-e.curr.id.clock;return 0===n?t.curr.constructor===e.curr.constructor?0:t.curr.constructor===Uh?1:-1:n}return e.curr.id.client-t.curr.id.client})),0!==o.length;){const t=o[0],e=t.curr.id.client;if(null!==i){let n=t.curr,r=!1;for(;null!==n&&n.id.clock+n.length<=i.struct.id.clock+i.struct.length&&n.id.client>=i.struct.id.client;)n=t.next(),r=!0;if(null===n||n.id.client!==e||r&&n.id.clock>i.struct.id.clock+i.struct.length)continue;if(e!==i.struct.id.client)Cl(c,i.struct,i.offset),i={struct:n,offset:0},t.next();else if(i.struct.id.clock+i.struct.length<n.id.clock)if(i.struct.constructor===Uh)i.struct.length=n.id.clock+n.length-i.struct.id.clock;else{Cl(c,i.struct,i.offset);const t=n.id.clock-i.struct.id.clock-i.struct.length;i={struct:new Uh(Ha(e,i.struct.id.clock+i.struct.length),t),offset:0}}else{const e=i.struct.id.clock+i.struct.length-n.id.clock;e>0&&(i.struct.constructor===Uh?i.struct.length-=e:n=wl(n,e)),i.struct.mergeWith(n)||(Cl(c,i.struct,i.offset),i={struct:n,offset:0},t.next())}}else i={struct:t.curr,offset:0},t.next();for(let n=t.curr;null!==n&&n.id.client===e&&n.id.clock===i.struct.id.clock+i.struct.length&&n.constructor!==Uh;n=t.next())Cl(c,i.struct,i.offset),i={struct:n,offset:0}}null!==i&&(Cl(c,i.struct,i.offset),i=null),xl(c);const a=(t=>{const e=new ba;for(let n=0;n<t.length;n++)t[n].clients.forEach(((r,o)=>{if(!e.clients.has(o)){const i=r.slice();for(let e=n+1;e<t.length;e++)$s(i,t[e].clients.get(o)||[]);e.clients.set(o,i)}}));return Ca(e),e})(r.map((t=>Ea(t))));return _a(s,a),s.toUint8Array()},kl=(t,e,n=Ia,r=za)=>{const o=Fa(e),i=new r,s=new vl(i),c=new n(Dc(t)),a=new ml(c,!1);for(;a.curr;){const t=a.curr,e=t.id.client,n=o.get(e)||0;if(a.curr.constructor!==Uh)if(t.id.clock+t.length>n)for(Cl(s,t,Ws(n-t.id.clock,0)),a.next();a.curr&&a.curr.id.client===e;)Cl(s,a.curr,0),a.next();else for(;a.curr&&a.curr.id.client===e&&a.curr.id.clock+a.curr.length<=n;)a.next();else a.next()}xl(s);const l=Ea(c);return _a(i,l),i.toUint8Array()},Sl=t=>{t.written>0&&(t.clientStructs.push({written:t.written,restEncoder:uc(t.encoder.restEncoder)}),t.encoder.restEncoder=hc(),t.written=0)},Cl=(t,e,n)=>{t.written>0&&t.currClient!==e.id.client&&Sl(t),0===t.written&&(t.currClient=e.id.client,t.encoder.writeClient(e.id.client),fc(t.encoder.restEncoder,e.id.clock+n)),e.write(t.encoder,n),t.written++},xl=t=>{Sl(t);const e=t.encoder.restEncoder;fc(e,t.clientStructs.length);for(let n=0;n<t.clientStructs.length;n++){const r=t.clientStructs[n];fc(e,r.written),vc(e,r.restEncoder)}},Ml=t=>((t,e,n)=>{const r=new e(Dc(t)),o=new ml(r,!1),i=new n,s=new vl(i);for(let t=o.curr;null!==t;t=o.next())Cl(s,t,0);xl(s);const c=Ea(r);return _a(i,c),i.toUint8Array()})(t,Ia,Ra);class _l{constructor(t,e){this.target=t,this.currentTarget=t,this.transaction=e,this._changes=null,this._keys=null,this._delta=null}get path(){return El(this.currentTarget,this.target)}deletes(t){return Sa(this.transaction.deleteSet,t.id)}get keys(){if(null===this._keys){const t=new Map,e=this.target;this.transaction.changed.get(e).forEach((n=>{if(null!==n){const r=e._map.get(n);let o,i;if(this.adds(r)){let t=r.left;for(;null!==t&&this.adds(t);)t=t.left;if(this.deletes(r)){if(null===t||!this.deletes(t))return;o="delete",i=Fs(t.content.getContent())}else null!==t&&this.deletes(t)?(o="update",i=Fs(t.content.getContent())):(o="add",i=void 0)}else{if(!this.deletes(r))return;o="delete",i=Fs(r.content.getContent())}t.set(n,{action:o,oldValue:i})}})),this._keys=t}return this._keys}get delta(){return this.changes.delta}adds(t){return t.id.clock>=(this.transaction.beforeState.get(t.id.client)||0)}get changes(){let t=this._changes;if(null===t){const e=this.target,n=Vs(),r=Vs(),o=[];if(t={added:n,deleted:r,delta:o,keys:this.keys},this.transaction.changed.get(e).has(null)){let t=null;const i=()=>{t&&o.push(t)};for(let o=e._start;null!==o;o=o.right)o.deleted?this.deletes(o)&&!this.adds(o)&&(null!==t&&void 0!==t.delete||(i(),t={delete:0}),t.delete+=o.length,r.add(o)):this.adds(o)?(null!==t&&void 0!==t.insert||(i(),t={insert:[]}),t.insert=t.insert.concat(o.content.getContent()),n.add(o)):(null!==t&&void 0!==t.retain||(i(),t={retain:0}),t.retain+=o.length);null!==t&&void 0===t.retain&&i()}this._changes=t}return t}}const El=(t,e)=>{const n=[];for(;null!==e._item&&e!==t;){if(null!==e._item.parentSub)n.unshift(e._item.parentSub);else{let t=0,r=e._item.parent._start;for(;r!==e._item&&null!==r;)r.deleted||t++,r=r.right;n.unshift(t)}e=e._item.parent}return n};let Ol=0;class Dl{constructor(t,e){t.marker=!0,this.p=t,this.index=e,this.timestamp=Ol++}}const Nl=(t,e,n)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=n,t.timestamp=Ol++},Al=(t,e)=>{if(null===t._start||0===e||null===t._searchMarker)return null;const n=0===t._searchMarker.length?null:t._searchMarker.reduce(((t,n)=>Us(e-t.index)<Us(e-n.index)?t:n));let r=t._start,o=0;for(null!==n&&(r=n.p,o=n.index,(t=>{t.timestamp=Ol++})(n));null!==r.right&&o<e;){if(!r.deleted&&r.countable){if(e<o+r.length)break;o+=r.length}r=r.right}for(;null!==r.left&&o>e;)r=r.left,!r.deleted&&r.countable&&(o-=r.length);for(;null!==r.left&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(o-=r.length);return null!==n&&Us(n.index-o)<r.parent.length/80?(Nl(n,r,o),n):((t,e,n)=>{if(t.length>=80){const r=t.reduce(((t,e)=>t.timestamp<e.timestamp?t:e));return Nl(r,e,n),r}{const r=new Dl(e,n);return t.push(r),r}})(t._searchMarker,r,o)},Tl=(t,e,n)=>{for(let r=t.length-1;r>=0;r--){const o=t[r];if(n>0){let e=o.p;for(e.marker=!1;e&&(e.deleted||!e.countable);)e=e.left,e&&!e.deleted&&e.countable&&(o.index-=e.length);if(null===e||!0===e.marker){t.splice(r,1);continue}o.p=e,e.marker=!0}(e<o.index||n>0&&e===o.index)&&(o.index=Ws(e,o.index+n))}},Il=(t,e,n)=>{const r=t,o=e.changedParentTypes;for(;Bs(o,t,(()=>[])).push(n),null!==t._item;)t=t._item.parent;Ja(r._eH,n,e)};class Rl{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=qa(),this._dEH=qa(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(t,e){this.doc=t,this._item=e}_copy(){throw Hc()}clone(){throw Hc()}_write(t){}get _first(){let t=this._start;for(;null!==t&&t.deleted;)t=t.right;return t}_callObserver(t,e){!t.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(t){ja(this._eH,t)}observeDeep(t){ja(this._dEH,t)}unobserve(t){Ua(this._eH,t)}unobserveDeep(t){Ua(this._dEH,t)}toJSON(){}}const zl=(t,e,n)=>{e<0&&(e=t._length+e),n<0&&(n=t._length+n);let r=n-e;const o=[];let i=t._start;for(;null!==i&&r>0;){if(i.countable&&!i.deleted){const t=i.content.getContent();if(t.length<=e)e-=t.length;else{for(let n=e;n<t.length&&r>0;n++)o.push(t[n]),r--;e=0}}i=i.right}return o},Pl=t=>{const e=[];let n=t._start;for(;null!==n;){if(n.countable&&!n.deleted){const t=n.content.getContent();for(let n=0;n<t.length;n++)e.push(t[n])}n=n.right}return e},Ll=(t,e)=>{let n=0,r=t._start;for(;null!==r;){if(r.countable&&!r.deleted){const o=r.content.getContent();for(let r=0;r<o.length;r++)e(o[r],n++,t)}r=r.right}},Bl=(t,e)=>{const n=[];return Ll(t,((r,o)=>{n.push(e(r,o,t))})),n},Vl=t=>{let e=t._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(null===n){for(;null!==e&&e.deleted;)e=e.right;if(null===e)return{done:!0,value:void 0};n=e.content.getContent(),r=0,e=e.right}const t=n[r++];return n.length<=r&&(n=null),{done:!1,value:t}}}},Fl=(t,e)=>{const n=Al(t,e);let r=t._start;for(null!==n&&(r=n.p,e-=n.index);null!==r;r=r.right)if(!r.deleted&&r.countable){if(e<r.length)return r.content.getContent()[e];e-=r.length}},$l=(t,e,n,r)=>{let o=n;const i=t.doc,s=i.clientID,c=i.store,a=null===n?e._start:n.right;let l=[];const h=()=>{l.length>0&&(o=new $h(Ha(s,nl(c,s)),o,o&&o.lastId,a,a&&a.id,e,null,new Dh(l)),o.integrate(t,0),l=[])};r.forEach((n=>{if(null===n)l.push(n);else switch(n.constructor){case Number:case Object:case Boolean:case Array:case String:l.push(n);break;default:switch(h(),n.constructor){case Uint8Array:case ArrayBuffer:o=new $h(Ha(s,nl(c,s)),o,o&&o.lastId,a,a&&a.id,e,null,new Ch(new Uint8Array(n))),o.integrate(t,0);break;case Na:o=new $h(Ha(s,nl(c,s)),o,o&&o.lastId,a,a&&a.id,e,null,new Mh(n)),o.integrate(t,0);break;default:if(!(n instanceof Rl))throw new Error("Unexpected content type in insert operation");o=new $h(Ha(s,nl(c,s)),o,o&&o.lastId,a,a&&a.id,e,null,new Vh(n)),o.integrate(t,0)}}})),h()},ql=Kc("Length exceeded!"),jl=(t,e,n,r)=>{if(n>e._length)throw ql;if(0===n)return e._searchMarker&&Tl(e._searchMarker,n,r.length),$l(t,e,null,r);const o=n,i=Al(e,n);let s=e._start;for(null!==i&&(s=i.p,0==(n-=i.index)&&(s=s.prev,n+=s&&s.countable&&!s.deleted?s.length:0));null!==s;s=s.right)if(!s.deleted&&s.countable){if(n<=s.length){n<s.length&&cl(t,Ha(s.id.client,s.id.clock+n));break}n-=s.length}return e._searchMarker&&Tl(e._searchMarker,o,r.length),$l(t,e,s,r)},Ul=(t,e,n,r)=>{if(0===r)return;const o=n,i=r,s=Al(e,n);let c=e._start;for(null!==s&&(c=s.p,n-=s.index);null!==c&&n>0;c=c.right)!c.deleted&&c.countable&&(n<c.length&&cl(t,Ha(c.id.client,c.id.clock+n)),n-=c.length);for(;r>0&&null!==c;)c.deleted||(r<c.length&&cl(t,Ha(c.id.client,c.id.clock+r)),c.delete(t),r-=c.length),c=c.right;if(r>0)throw ql;e._searchMarker&&Tl(e._searchMarker,o,-i+r)},Jl=(t,e,n)=>{const r=e._map.get(n);void 0!==r&&r.delete(t)},Wl=(t,e,n,r)=>{const o=e._map.get(n)||null,i=t.doc,s=i.clientID;let c;if(null==r)c=new Dh([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:c=new Dh([r]);break;case Uint8Array:c=new Ch(r);break;case Na:c=new Mh(r);break;default:if(!(r instanceof Rl))throw new Error("Unexpected content type");c=new Vh(r)}new $h(Ha(s,nl(i.store,s)),o,o&&o.lastId,null,null,e,n,c).integrate(t,0)},Kl=(t,e)=>{const n=t._map.get(e);return void 0===n||n.deleted?void 0:n.content.getContent()[n.length-1]},Hl=t=>{const e={};return t._map.forEach(((t,n)=>{t.deleted||(e[n]=t.content.getContent()[t.length-1])})),e},Gl=(t,e)=>{const n=t._map.get(e);return void 0!==n&&!n.deleted},Yl=t=>{return e=t.entries(),n=t=>!t[1].deleted,ga((()=>{let t;do{t=e.next()}while(!t.done&&!n(t.value));return t}));var e,n};class Xl extends _l{constructor(t,e){super(t,e),this._transaction=e}}class Ql extends Rl{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(t){const e=new Ql;return e.push(t),e}_integrate(t,e){super._integrate(t,e),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new Ql}clone(){const t=new Ql;return t.insert(0,this.toArray().map((t=>t instanceof Rl?t.clone():t))),t}get length(){return null===this._prelimContent?this._length:this._prelimContent.length}_callObserver(t,e){super._callObserver(t,e),Il(this,t,new Xl(this,t))}insert(t,e){null!==this.doc?gl(this.doc,(n=>{jl(n,this,t,e)})):this._prelimContent.splice(t,0,...e)}push(t){this.insert(this.length,t)}unshift(t){this.insert(0,t)}delete(t,e=1){null!==this.doc?gl(this.doc,(n=>{Ul(n,this,t,e)})):this._prelimContent.splice(t,e)}get(t){return Fl(this,t)}toArray(){return Pl(this)}slice(t=0,e=this.length){return zl(this,t,e)}toJSON(){return this.map((t=>t instanceof Rl?t.toJSON():t))}map(t){return Bl(this,t)}forEach(t){Ll(this,t)}[Symbol.iterator](){return Vl(this)}_write(t){t.writeTypeRef(Th)}}class Zl extends _l{constructor(t,e,n){super(t,e),this.keysChanged=n}}class th extends Rl{constructor(t){super(),this._prelimContent=null,this._prelimContent=void 0===t?new Map:new Map(t)}_integrate(t,e){super._integrate(t,e),this._prelimContent.forEach(((t,e)=>{this.set(e,t)})),this._prelimContent=null}_copy(){return new th}clone(){const t=new th;return this.forEach(((e,n)=>{t.set(n,e instanceof Rl?e.clone():e)})),t}_callObserver(t,e){Il(this,t,new Zl(this,t,e))}toJSON(){const t={};return this._map.forEach(((e,n)=>{if(!e.deleted){const r=e.content.getContent()[e.length-1];t[n]=r instanceof Rl?r.toJSON():r}})),t}get size(){return[...Yl(this._map)].length}keys(){return ma(Yl(this._map),(t=>t[0]))}values(){return ma(Yl(this._map),(t=>t[1].content.getContent()[t[1].length-1]))}entries(){return ma(Yl(this._map),(t=>[t[0],t[1].content.getContent()[t[1].length-1]]))}forEach(t){return this._map.forEach(((e,n)=>{e.deleted||t(e.content.getContent()[e.length-1],n,this)})),{}}[Symbol.iterator](){return this.entries()}delete(t){null!==this.doc?gl(this.doc,(e=>{Jl(e,this,t)})):this._prelimContent.delete(t)}set(t,e){return null!==this.doc?gl(this.doc,(n=>{Wl(n,this,t,e)})):this._prelimContent.set(t,e),e}get(t){return Kl(this,t)}has(t){return Gl(this,t)}clear(){null!==this.doc?gl(this.doc,(t=>{this.forEach((function(e,n,r){Jl(t,r,n)}))})):this._prelimContent.clear()}_write(t){t.writeTypeRef(Ih)}}const eh=(t,e)=>t===e||"object"==typeof t&&"object"==typeof e&&t&&e&&((t,e)=>t===e||ya(t)===ya(e)&&((t,e)=>{for(const n in t)if(!e(t[n],n))return!1;return!0})(t,((t,n)=>(void 0!==t||((t,e)=>Object.prototype.hasOwnProperty.call(t,e))(e,n))&&e[n]===t)))(t,e);class nh{constructor(t,e,n,r){this.left=t,this.right=e,this.index=n,this.currentAttributes=r}forward(){null===this.right&&Gc(),this.right.content.constructor===Eh?this.right.deleted||sh(this.currentAttributes,this.right.content):this.right.deleted||(this.index+=this.right.length),this.left=this.right,this.right=this.right.right}}const rh=(t,e,n)=>{for(;null!==e.right&&n>0;)e.right.content.constructor===Eh?e.right.deleted||sh(e.currentAttributes,e.right.content):e.right.deleted||(n<e.right.length&&cl(t,Ha(e.right.id.client,e.right.id.clock+n)),e.index+=e.right.length,n-=e.right.length),e.left=e.right,e.right=e.right.right;return e},oh=(t,e,n)=>{const r=new Map,o=Al(e,n);if(o){const e=new nh(o.p.left,o.p,o.index,r);return rh(t,e,n-o.index)}{const o=new nh(null,e._start,0,r);return rh(t,o,n)}},ih=(t,e,n,r)=>{for(;null!==n.right&&(!0===n.right.deleted||n.right.content.constructor===Eh&&eh(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();const o=t.doc,i=o.clientID;r.forEach(((r,s)=>{const c=n.left,a=n.right,l=new $h(Ha(i,nl(o.store,i)),c,c&&c.lastId,a,a&&a.id,e,null,new Eh(s,r));l.integrate(t,0),n.right=l,n.forward()}))},sh=(t,e)=>{const{key:n,value:r}=e;null===r?t.delete(n):t.set(n,r)},ch=(t,e)=>{for(;null!==t.right&&(t.right.deleted||t.right.content.constructor===Eh&&eh(e[t.right.content.key]||null,t.right.content.value));)t.forward()},ah=(t,e,n,r)=>{const o=t.doc,i=o.clientID,s=new Map;for(const c in r){const a=r[c],l=n.currentAttributes.get(c)||null;if(!eh(l,a)){s.set(c,l);const{left:r,right:h}=n;n.right=new $h(Ha(i,nl(o.store,i)),r,r&&r.lastId,h,h&&h.id,e,null,new Eh(c,a)),n.right.integrate(t,0),n.forward()}}return s},lh=(t,e,n,r,o)=>{n.currentAttributes.forEach(((t,e)=>{void 0===o[e]&&(o[e]=null)}));const i=t.doc,s=i.clientID;ch(n,o);const c=ah(t,e,n,o),a=r.constructor===String?new Nh(r):r instanceof Rl?new Vh(r):new _h(r);let{left:l,right:h,index:u}=n;e._searchMarker&&Tl(e._searchMarker,n.index,a.getLength()),h=new $h(Ha(s,nl(i.store,s)),l,l&&l.lastId,h,h&&h.id,e,null,a),h.integrate(t,0),n.right=h,n.index=u,n.forward(),ih(t,e,n,c)},hh=(t,e,n,r,o)=>{const i=t.doc,s=i.clientID;ch(n,o);const c=ah(t,e,n,o);for(;r>0&&null!==n.right;){if(!n.right.deleted)switch(n.right.content.constructor){case Eh:{const{key:e,value:r}=n.right.content,i=o[e];void 0!==i&&(eh(i,r)?c.delete(e):c.set(e,r),n.right.delete(t));break}default:r<n.right.length&&cl(t,Ha(n.right.id.client,n.right.id.clock+r)),r-=n.right.length}n.forward()}if(r>0){let o="";for(;r>0;r--)o+="\n";n.right=new $h(Ha(s,nl(i.store,s)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,e,null,new Nh(o)),n.right.integrate(t,0),n.forward()}ih(t,e,n,c)},uh=(t,e,n,r,o)=>{for(;n&&(!n.countable||n.deleted);)n.deleted||n.content.constructor!==Eh||sh(o,n.content),n=n.right;let i=0;for(;e!==n;){if(!e.deleted){const n=e.content;switch(n.constructor){case Eh:{const{key:s,value:c}=n;(o.get(s)||null)===c&&(r.get(s)||null)!==c||(e.delete(t),i++);break}}}e=e.right}return i},dh=(t,e,n)=>{const r=n,o=Ls(e.currentAttributes),i=e.right;for(;n>0&&null!==e.right;){if(!1===e.right.deleted)switch(e.right.content.constructor){case Vh:case _h:case Nh:n<e.right.length&&cl(t,Ha(e.right.id.client,e.right.id.clock+n)),n-=e.right.length,e.right.delete(t)}e.forward()}i&&uh(t,i,e.right,o,Ls(e.currentAttributes));const s=(e.left||e.right).parent;return s._searchMarker&&Tl(s._searchMarker,e.index,-r+n),e};class ph extends _l{constructor(t,e,n){super(t,e),this.childListChanged=!1,this.keysChanged=new Set,n.forEach((t=>{null===t?this.childListChanged=!0:this.keysChanged.add(t)}))}get changes(){if(null===this._changes){const t={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=t}return this._changes}get delta(){if(null===this._delta){const t=this.target.doc,e=[];gl(t,(t=>{const n=new Map,r=new Map;let o=this.target._start,i=null;const s={};let c="",a=0,l=0;const h=()=>{if(null!==i){let t;switch(i){case"delete":t={delete:l},l=0;break;case"insert":t={insert:c},n.size>0&&(t.attributes={},n.forEach(((e,n)=>{null!==e&&(t.attributes[n]=e)}))),c="";break;case"retain":if(t={retain:a},Object.keys(s).length>0){t.attributes={};for(const e in s)t.attributes[e]=s[e]}a=0}e.push(t),i=null}};for(;null!==o;){switch(o.content.constructor){case Vh:case _h:this.adds(o)?this.deletes(o)||(h(),i="insert",c=o.content.getContent()[0],h()):this.deletes(o)?("delete"!==i&&(h(),i="delete"),l+=1):o.deleted||("retain"!==i&&(h(),i="retain"),a+=1);break;case Nh:this.adds(o)?this.deletes(o)||("insert"!==i&&(h(),i="insert"),c+=o.content.str):this.deletes(o)?("delete"!==i&&(h(),i="delete"),l+=o.length):o.deleted||("retain"!==i&&(h(),i="retain"),a+=o.length);break;case Eh:{const{key:e,value:c}=o.content;if(this.adds(o)){if(!this.deletes(o)){const a=n.get(e)||null;eh(a,c)?o.delete(t):("retain"===i&&h(),eh(c,r.get(e)||null)?delete s[e]:s[e]=c)}}else if(this.deletes(o)){r.set(e,c);const t=n.get(e)||null;eh(t,c)||("retain"===i&&h(),s[e]=t)}else if(!o.deleted){r.set(e,c);const n=s[e];void 0!==n&&(eh(n,c)?o.delete(t):("retain"===i&&h(),null===c?s[e]=c:delete s[e]))}o.deleted||("insert"===i&&h(),sh(n,o.content));break}}o=o.right}for(h();e.length>0;){const t=e[e.length-1];if(void 0===t.retain||void 0!==t.attributes)break;e.pop()}})),this._delta=e}return this._delta}}class fh extends Rl{constructor(t){super(),this._pending=void 0!==t?[()=>this.insert(0,t)]:[],this._searchMarker=[]}get length(){return this._length}_integrate(t,e){super._integrate(t,e);try{this._pending.forEach((t=>t()))}catch(t){console.error(t)}this._pending=null}_copy(){return new fh}clone(){const t=new fh;return t.applyDelta(this.toDelta()),t}_callObserver(t,e){super._callObserver(t,e);const n=new ph(this,t,e),r=t.doc;if(Il(this,t,n),!t.local){let e=!1;for(const[n,o]of t.afterState.entries()){const i=t.beforeState.get(n)||0;if(o!==i&&(ll(t,r.store.clients.get(n),i,o,(t=>{t.deleted||t.content.constructor!==Eh||(e=!0)})),e))break}e||ka(t,t.deleteSet,(t=>{t instanceof Sh||e||t.parent===this&&t.content.constructor===Eh&&(e=!0)})),gl(r,(t=>{e?(t=>{let e=0;gl(t.doc,(n=>{let r=t._start,o=t._start,i=Ps();const s=Ls(i);for(;o;)!1===o.deleted&&(o.content.constructor===Eh?sh(s,o.content):(e+=uh(n,r,o,i,s),i=Ls(s),r=o)),o=o.right}))})(this):ka(t,t.deleteSet,(e=>{e instanceof Sh||e.parent===this&&((t,e)=>{for(;e&&e.right&&(e.right.deleted||!e.right.countable);)e=e.right;const n=new Set;for(;e&&(e.deleted||!e.countable);){if(!e.deleted&&e.content.constructor===Eh){const r=e.content.key;n.has(r)?e.delete(t):n.add(r)}e=e.left}})(t,e)}))}))}}toString(){let t="",e=this._start;for(;null!==e;)!e.deleted&&e.countable&&e.content.constructor===Nh&&(t+=e.content.str),e=e.right;return t}toJSON(){return this.toString()}applyDelta(t,{sanitize:e=!0}={}){null!==this.doc?gl(this.doc,(n=>{const r=new nh(null,this._start,0,new Map);for(let o=0;o<t.length;o++){const i=t[o];if(void 0!==i.insert){const s=e||"string"!=typeof i.insert||o!==t.length-1||null!==r.right||"\n"!==i.insert.slice(-1)?i.insert:i.insert.slice(0,-1);("string"!=typeof s||s.length>0)&&lh(n,this,r,s,i.attributes||{})}else void 0!==i.retain?hh(n,this,r,i.retain,i.attributes||{}):void 0!==i.delete&&dh(n,r,i.delete)}})):this._pending.push((()=>this.applyDelta(t)))}toDelta(t,e,n){const r=[],o=new Map,i=this.doc;let s="",c=this._start;function a(){if(s.length>0){const t={};let e=!1;o.forEach(((n,r)=>{e=!0,t[r]=n}));const n={insert:s};e&&(n.attributes=t),r.push(n),s=""}}return gl(i,(i=>{for(t&&Xa(i,t),e&&Xa(i,e);null!==c;){if(Ya(c,t)||void 0!==e&&Ya(c,e))switch(c.content.constructor){case Nh:{const r=o.get("ychange");void 0===t||Ya(c,t)?void 0===e||Ya(c,e)?void 0!==r&&(a(),o.delete("ychange")):void 0!==r&&r.user===c.id.client&&"added"===r.state||(a(),o.set("ychange",n?n("added",c.id):{type:"added"})):void 0!==r&&r.user===c.id.client&&"removed"===r.state||(a(),o.set("ychange",n?n("removed",c.id):{type:"removed"})),s+=c.content.str;break}case Vh:case _h:{a();const t={insert:c.content.getContent()[0]};if(o.size>0){const e={};t.attributes=e,o.forEach(((t,n)=>{e[n]=t}))}r.push(t);break}case Eh:Ya(c,t)&&(a(),sh(o,c.content))}c=c.right}a()}),Xa),r}insert(t,e,n){if(e.length<=0)return;const r=this.doc;null!==r?gl(r,(r=>{const o=oh(r,this,t);n||(n={},o.currentAttributes.forEach(((t,e)=>{n[e]=t}))),lh(r,this,o,e,n)})):this._pending.push((()=>this.insert(t,e,n)))}insertEmbed(t,e,n={}){const r=this.doc;null!==r?gl(r,(r=>{const o=oh(r,this,t);lh(r,this,o,e,n)})):this._pending.push((()=>this.insertEmbed(t,e,n)))}delete(t,e){if(0===e)return;const n=this.doc;null!==n?gl(n,(n=>{dh(n,oh(n,this,t),e)})):this._pending.push((()=>this.delete(t,e)))}format(t,e,n){if(0===e)return;const r=this.doc;null!==r?gl(r,(r=>{const o=oh(r,this,t);null!==o.right&&hh(r,this,o,e,n)})):this._pending.push((()=>this.format(t,e,n)))}removeAttribute(t){null!==this.doc?gl(this.doc,(e=>{Jl(e,this,t)})):this._pending.push((()=>this.removeAttribute(t)))}setAttribute(t,e){null!==this.doc?gl(this.doc,(n=>{Wl(n,this,t,e)})):this._pending.push((()=>this.setAttribute(t,e)))}getAttribute(t){return Kl(this,t)}getAttributes(t){return Hl(this)}_write(t){t.writeTypeRef(Rh)}}class gh{constructor(t,e=(()=>!0)){this._filter=e,this._root=t,this._currentNode=t._start,this._firstCall=!0}[Symbol.iterator](){return this}next(){let t=this._currentNode,e=t&&t.content&&t.content.type;if(null!==t&&(!this._firstCall||t.deleted||!this._filter(e)))do{if(e=t.content.type,t.deleted||e.constructor!==vh&&e.constructor!==mh||null===e._start)for(;null!==t;){if(null!==t.right){t=t.right;break}t=t.parent===this._root?null:t.parent._item}else t=e._start}while(null!==t&&(t.deleted||!this._filter(t.content.type)));return this._firstCall=!1,null===t?{value:void 0,done:!0}:(this._currentNode=t,{value:t.content.type,done:!1})}}class mh extends Rl{constructor(){super(),this._prelimContent=[]}get firstChild(){const t=this._first;return t?t.content.getContent()[0]:null}_integrate(t,e){super._integrate(t,e),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new mh}clone(){const t=new mh;return t.insert(0,this.toArray().map((t=>t instanceof Rl?t.clone():t))),t}get length(){return null===this._prelimContent?this._length:this._prelimContent.length}createTreeWalker(t){return new gh(this,t)}querySelector(t){t=t.toUpperCase();const e=new gh(this,(e=>e.nodeName&&e.nodeName.toUpperCase()===t)).next();return e.done?null:e.value}querySelectorAll(t){return t=t.toUpperCase(),Array.from(new gh(this,(e=>e.nodeName&&e.nodeName.toUpperCase()===t)))}_callObserver(t,e){Il(this,t,new yh(this,e,t))}toString(){return Bl(this,(t=>t.toString())).join("")}toJSON(){return this.toString()}toDOM(t=document,e={},n){const r=t.createDocumentFragment();return void 0!==n&&n._createAssociation(r,this),Ll(this,(o=>{r.insertBefore(o.toDOM(t,e,n),null)})),r}insert(t,e){null!==this.doc?gl(this.doc,(n=>{jl(n,this,t,e)})):this._prelimContent.splice(t,0,...e)}insertAfter(t,e){if(null!==this.doc)gl(this.doc,(n=>{const r=t&&t instanceof Rl?t._item:t;$l(n,this,r,e)}));else{const n=this._prelimContent,r=null===t?0:n.findIndex((e=>e===t))+1;if(0===r&&null!==t)throw Kc("Reference item not found");n.splice(r,0,...e)}}delete(t,e=1){null!==this.doc?gl(this.doc,(n=>{Ul(n,this,t,e)})):this._prelimContent.splice(t,e)}toArray(){return Pl(this)}push(t){this.insert(this.length,t)}unshift(t){this.insert(0,t)}get(t){return Fl(this,t)}slice(t=0,e=this.length){return zl(this,t,e)}_write(t){t.writeTypeRef(Ph)}}class vh extends mh{constructor(t="UNDEFINED"){super(),this.nodeName=t,this._prelimAttrs=new Map}get nextSibling(){const t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){const t=this._item?this._item.prev:null;return t?t.content.type:null}_integrate(t,e){super._integrate(t,e),this._prelimAttrs.forEach(((t,e)=>{this.setAttribute(e,t)})),this._prelimAttrs=null}_copy(){return new vh(this.nodeName)}clone(){const t=new vh(this.nodeName),e=this.getAttributes();for(const n in e)t.setAttribute(n,e[n]);return t.insert(0,this.toArray().map((t=>t instanceof Rl?t.clone():t))),t}toString(){const t=this.getAttributes(),e=[],n=[];for(const e in t)n.push(e);n.sort();const r=n.length;for(let o=0;o<r;o++){const r=n[o];e.push(r+'="'+t[r]+'"')}const o=this.nodeName.toLocaleLowerCase();return`<${o}${e.length>0?" "+e.join(" "):""}>${super.toString()}</${o}>`}removeAttribute(t){null!==this.doc?gl(this.doc,(e=>{Jl(e,this,t)})):this._prelimAttrs.delete(t)}setAttribute(t,e){null!==this.doc?gl(this.doc,(n=>{Wl(n,this,t,e)})):this._prelimAttrs.set(t,e)}getAttribute(t){return Kl(this,t)}hasAttribute(t){return Gl(this,t)}getAttributes(t){return Hl(this)}toDOM(t=document,e={},n){const r=t.createElement(this.nodeName),o=this.getAttributes();for(const t in o)r.setAttribute(t,o[t]);return Ll(this,(o=>{r.appendChild(o.toDOM(t,e,n))})),void 0!==n&&n._createAssociation(r,this),r}_write(t){t.writeTypeRef(zh),t.writeKey(this.nodeName)}}class yh extends _l{constructor(t,e,n){super(t,n),this.childListChanged=!1,this.attributesChanged=new Set,e.forEach((t=>{null===t?this.childListChanged=!0:this.attributesChanged.add(t)}))}}class wh extends th{constructor(t){super(),this.hookName=t}_copy(){return new wh(this.hookName)}clone(){const t=new wh(this.hookName);return this.forEach(((e,n)=>{t.set(n,e)})),t}toDOM(t=document,e={},n){const r=e[this.hookName];let o;return o=void 0!==r?r.createDom(this):document.createElement(this.hookName),o.setAttribute("data-yjs-hook",this.hookName),void 0!==n&&n._createAssociation(o,this),o}_write(t){t.writeTypeRef(Lh),t.writeKey(this.hookName)}}class bh extends fh{get nextSibling(){const t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){const t=this._item?this._item.prev:null;return t?t.content.type:null}_copy(){return new bh}clone(){const t=new bh;return t.applyDelta(this.toDelta()),t}toDOM(t=document,e,n){const r=t.createTextNode(this.toString());return void 0!==n&&n._createAssociation(r,this),r}toString(){return this.toDelta().map((t=>{const e=[];for(const n in t.attributes){const r=[];for(const e in t.attributes[n])r.push({key:e,value:t.attributes[n][e]});r.sort(((t,e)=>t.key<e.key?-1:1)),e.push({nodeName:n,attrs:r})}e.sort(((t,e)=>t.nodeName<e.nodeName?-1:1));let n="";for(let t=0;t<e.length;t++){const r=e[t];n+=`<${r.nodeName}`;for(let t=0;t<r.attrs.length;t++){const e=r.attrs[t];n+=` ${e.key}="${e.value}"`}n+=">"}n+=t.insert;for(let t=e.length-1;t>=0;t--)n+=`</${e[t].nodeName}>`;return n})).join("")}toJSON(){return this.toString()}_write(t){t.writeTypeRef(Bh)}}class kh{constructor(t,e){this.id=t,this.length=e}get deleted(){throw Hc()}mergeWith(t){return!1}write(t,e,n){throw Hc()}integrate(t,e){throw Hc()}}class Sh extends kh{get deleted(){return!0}delete(){}mergeWith(t){return this.constructor===t.constructor&&(this.length+=t.length,!0)}integrate(t,e){e>0&&(this.id.clock+=e,this.length-=e),rl(t.doc.store,this)}write(t,e){t.writeInfo(0),t.writeLen(this.length-e)}getMissing(t,e){return null}}class Ch{constructor(t){this.content=t}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new Ch(this.content)}splice(t){throw Hc()}mergeWith(t){return!1}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeBuf(this.content)}getRef(){return 3}}class xh{constructor(t){this.len=t}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new xh(this.len)}splice(t){const e=new xh(this.len-t);return this.len=t,e}mergeWith(t){return this.len+=t.len,!0}integrate(t,e){xa(t.deleteSet,e.id.client,e.id.clock,this.len),e.markDeleted()}delete(t){}gc(t){}write(t,e){t.writeLen(this.len-e)}getRef(){return 1}}class Mh{constructor(t){t._item&&console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid."),this.doc=t;const e={};this.opts=e,t.gc||(e.gc=!1),t.autoLoad&&(e.autoLoad=!0),null!==t.meta&&(e.meta=t.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new Mh(this.doc)}splice(t){throw Hc()}mergeWith(t){return!1}integrate(t,e){this.doc._item=e,t.subdocsAdded.add(this.doc),this.doc.shouldLoad&&t.subdocsLoaded.add(this.doc)}delete(t){t.subdocsAdded.has(this.doc)?t.subdocsAdded.delete(this.doc):t.subdocsRemoved.add(this.doc)}gc(t){}write(t,e){t.writeString(this.doc.guid),t.writeAny(this.opts)}getRef(){return 9}}class _h{constructor(t){this.embed=t}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new _h(this.embed)}splice(t){throw Hc()}mergeWith(t){return!1}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeJSON(this.embed)}getRef(){return 5}}class Eh{constructor(t,e){this.key=t,this.value=e}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new Eh(this.key,this.value)}splice(t){throw Hc()}mergeWith(t){return!1}integrate(t,e){e.parent._searchMarker=null}delete(t){}gc(t){}write(t,e){t.writeKey(this.key),t.writeJSON(this.value)}getRef(){return 6}}class Oh{constructor(t){this.arr=t}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Oh(this.arr)}splice(t){const e=new Oh(this.arr.slice(t));return this.arr=this.arr.slice(0,t),e}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){const n=this.arr.length;t.writeLen(n-e);for(let r=e;r<n;r++){const e=this.arr[r];t.writeString(void 0===e?"undefined":JSON.stringify(e))}}getRef(){return 2}}class Dh{constructor(t){this.arr=t}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Dh(this.arr)}splice(t){const e=new Dh(this.arr.slice(t));return this.arr=this.arr.slice(0,t),e}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){const n=this.arr.length;t.writeLen(n-e);for(let r=e;r<n;r++){const e=this.arr[r];t.writeAny(e)}}getRef(){return 8}}class Nh{constructor(t){this.str=t}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new Nh(this.str)}splice(t){const e=new Nh(this.str.slice(t));this.str=this.str.slice(0,t);const n=this.str.charCodeAt(t-1);return n>=55296&&n<=56319&&(this.str=this.str.slice(0,t-1)+"�",e.str="�"+e.str.slice(1)),e}mergeWith(t){return this.str+=t.str,!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeString(0===e?this.str:this.str.slice(e))}getRef(){return 4}}const Ah=[t=>new Ql,t=>new th,t=>new fh,t=>new vh(t.readKey()),t=>new mh,t=>new wh(t.readKey()),t=>new bh],Th=0,Ih=1,Rh=2,zh=3,Ph=4,Lh=5,Bh=6;class Vh{constructor(t){this.type=t}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new Vh(this.type._copy())}splice(t){throw Hc()}mergeWith(t){return!1}integrate(t,e){this.type._integrate(t.doc,e)}delete(t){let e=this.type._start;for(;null!==e;)e.deleted?t._mergeStructs.push(e):e.delete(t),e=e.right;this.type._map.forEach((e=>{e.deleted?t._mergeStructs.push(e):e.delete(t)})),t.changed.delete(this.type)}gc(t){let e=this.type._start;for(;null!==e;)e.gc(t,!0),e=e.right;this.type._start=null,this.type._map.forEach((e=>{for(;null!==e;)e.gc(t,!0),e=e.left})),this.type._map=new Map}write(t,e){this.type._write(t)}getRef(){return 7}}const Fh=(t,e,n)=>{const{client:r,clock:o}=e.id,i=new $h(Ha(r,o+n),e,Ha(r,o+n-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(n));return e.deleted&&i.markDeleted(),e.keep&&(i.keep=!0),null!==e.redone&&(i.redone=Ha(e.redone.client,e.redone.clock+n)),e.right=i,null!==i.right&&(i.right.left=i),t._mergeStructs.push(i),null!==i.parentSub&&null===i.right&&i.parent._map.set(i.parentSub,i),e.length=n,i};class $h extends kh{constructor(t,e,n,r,o,i,s,c){super(t,c.getLength()),this.origin=n,this.left=e,this.right=r,this.rightOrigin=o,this.parent=i,this.parentSub=s,this.redone=null,this.content=c,this.info=this.content.isCountable()?2:0}set marker(t){(8&this.info)>0!==t&&(this.info^=8)}get marker(){return(8&this.info)>0}get keep(){return(1&this.info)>0}set keep(t){this.keep!==t&&(this.info^=1)}get countable(){return(2&this.info)>0}get deleted(){return(4&this.info)>0}set deleted(t){this.deleted!==t&&(this.info^=4)}markDeleted(){this.info|=4}getMissing(t,e){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=nl(e,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=nl(e,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===Wa&&this.id.client!==this.parent.client&&this.parent.clock>=nl(e,this.parent.client))return this.parent.client;if(this.origin&&(this.left=al(t,e,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=cl(t,this.rightOrigin),this.rightOrigin=this.right.id),(this.left&&this.left.constructor===Sh||this.right&&this.right.constructor===Sh)&&(this.parent=null),this.parent){if(this.parent.constructor===Wa){const t=il(e,this.parent);t.constructor===Sh?this.parent=null:this.parent=t.content.type}}else this.left&&this.left.constructor===$h&&(this.parent=this.left.parent,this.parentSub=this.left.parentSub),this.right&&this.right.constructor===$h&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);return null}integrate(t,e){if(e>0&&(this.id.clock+=e,this.left=al(t,t.doc.store,Ha(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(e),this.length-=e),this.parent){if(!this.left&&(!this.right||null!==this.right.left)||this.left&&this.left.right!==this.right){let e,n=this.left;if(null!==n)e=n.right;else if(null!==this.parentSub)for(e=this.parent._map.get(this.parentSub)||null;null!==e&&null!==e.left;)e=e.left;else e=this.parent._start;const r=new Set,o=new Set;for(;null!==e&&e!==this.right;){if(o.add(e),r.add(e),Ka(this.origin,e.origin)){if(e.id.client<this.id.client)n=e,r.clear();else if(Ka(this.rightOrigin,e.rightOrigin))break}else{if(null===e.origin||!o.has(il(t.doc.store,e.origin)))break;r.has(il(t.doc.store,e.origin))||(n=e,r.clear())}e=e.right}this.left=n}if(null!==this.left){const t=this.left.right;this.right=t,this.left.right=this}else{let t;if(null!==this.parentSub)for(t=this.parent._map.get(this.parentSub)||null;null!==t&&null!==t.left;)t=t.left;else t=this.parent._start,this.parent._start=this;this.right=t}null!==this.right?this.right.left=this:null!==this.parentSub&&(this.parent._map.set(this.parentSub,this),null!==this.left&&this.left.delete(t)),null===this.parentSub&&this.countable&&!this.deleted&&(this.parent._length+=this.length),rl(t.doc.store,this),this.content.integrate(t,this),dl(t,this.parent,this.parentSub),(null!==this.parent._item&&this.parent._item.deleted||null!==this.parentSub&&null!==this.right)&&this.delete(t)}else new Sh(this.id,this.length).integrate(t,0)}get next(){let t=this.right;for(;null!==t&&t.deleted;)t=t.right;return t}get prev(){let t=this.left;for(;null!==t&&t.deleted;)t=t.left;return t}get lastId(){return 1===this.length?this.id:Ha(this.id.client,this.id.clock+this.length-1)}mergeWith(t){if(this.constructor===t.constructor&&Ka(t.origin,this.lastId)&&this.right===t&&Ka(this.rightOrigin,t.rightOrigin)&&this.id.client===t.id.client&&this.id.clock+this.length===t.id.clock&&this.deleted===t.deleted&&null===this.redone&&null===t.redone&&this.content.constructor===t.content.constructor&&this.content.mergeWith(t.content)){const e=this.parent._searchMarker;return e&&e.forEach((e=>{e.p===t&&(e.p=this,!this.deleted&&this.countable&&(e.index-=this.length))})),t.keep&&(this.keep=!0),this.right=t.right,null!==this.right&&(this.right.left=this),this.length+=t.length,!0}return!1}delete(t){if(!this.deleted){const e=this.parent;this.countable&&null===this.parentSub&&(e._length-=this.length),this.markDeleted(),xa(t.deleteSet,this.id.client,this.id.clock,this.length),dl(t,e,this.parentSub),this.content.delete(t)}}gc(t,e){if(!this.deleted)throw Gc();this.content.gc(t),e?((t,e,n)=>{const r=t.clients.get(e.id.client);r[ol(r,e.id.clock)]=n})(t,this,new Sh(this.id,this.length)):this.content=new xh(this.length)}write(t,e){const n=e>0?Ha(this.id.client,this.id.clock+e-1):this.origin,r=this.rightOrigin,o=this.parentSub,i=31&this.content.getRef()|(null===n?0:sc)|(null===r?0:ic)|(null===o?0:32);if(t.writeInfo(i),null!==n&&t.writeLeftID(n),null!==r&&t.writeRightID(r),null===n&&null===r){const e=this.parent;if(void 0!==e._item){const n=e._item;if(null===n){const n=(t=>{for(const[e,n]of t.doc.share.entries())if(n===t)return e;throw Gc()})(e);t.writeParentInfo(!0),t.writeString(n)}else t.writeParentInfo(!1),t.writeLeftID(n.id)}else e.constructor===String?(t.writeParentInfo(!0),t.writeString(e)):e.constructor===Wa?(t.writeParentInfo(!1),t.writeLeftID(e)):Gc();null!==o&&t.writeString(o)}this.content.write(t,e)}}const qh=(t,e)=>jh[31&e](t),jh=[()=>{Gc()},t=>new xh(t.readLen()),t=>{const e=t.readLen(),n=[];for(let r=0;r<e;r++){const e=t.readString();"undefined"===e?n.push(void 0):n.push(JSON.parse(e))}return new Oh(n)},t=>new Ch(t.readBuf()),t=>new Nh(t.readString()),t=>new _h(t.readJSON()),t=>new Eh(t.readString(),t.readJSON()),t=>new Vh(Ah[t.readTypeRef()](t)),t=>{const e=t.readLen(),n=[];for(let r=0;r<e;r++)n.push(t.readAny());return new Dh(n)},t=>new Mh(new Na({guid:t.readString(),...t.readAny()})),()=>{Gc()}];class Uh extends kh{get deleted(){return!0}delete(){}mergeWith(t){return this.constructor===t.constructor&&(this.length+=t.length,!0)}integrate(t,e){Gc()}write(t,e){t.writeInfo(10),fc(t.restEncoder,this.length-e)}getMissing(t,e){return null}}const Jh="undefined"!=typeof window?window:"undefined"!=typeof global?global:{};!0===Jh["__ $YJS$ __"]&&console.warn("Yjs was already imported. Importing different versions of Yjs often leads to issues."),Jh["__ $YJS$ __"]=!0;const Wh=(t="case")=>new Error("Unexpected "+t),Kh=(t="Operation")=>new Error(t+" failed"),Hh="break",Gh=-1;function Yh(t,e,n,r){if(0===n)return t.insert(0,r),Gh;let o=0,i=0;return eu(t,(function(s){if(n===o)return t.insert(i,r),o=Gh,Hh;if(s.content.type.constructor===bh){const t=function(t,e,n,r){return n<t.length?(t.insert(n,r.map((function(t){return function(t){let e="";return t.doc=new Na,t._pending.forEach((function(t){t()})),eu(t,(function(t){t.content.constructor===Nh&&(e+=t.content.str)})),e}(t)})).join("")),Gh):t.length}(s.content.type,0,n-o,r);if(t===Gh)return o=Gh,Hh;o+=t,i+=1}else{if(s.content.type.constructor!==vh)throw Wh();if(e.nodes[s.content.type.nodeName].isLeaf)o+=1,i+=1;else{o+=1;const t=function(t,e,n,r){return Yh(t,e,n,r)}(s.content.type,e,n-o,r);if(t===Gh)return o=Gh,Hh;o+=t,o+=1,i+=1}}})),o}const Xh={[Vh](t,e,n,r){let o=0,i=0;if(r<=0)return{removedLength:o,totalLength:i};const{type:s}=t.content;switch(s.constructor){case vh:const{nodeName:t}=s,c=e.nodes[t];if(c.isBlock&&c.isLeaf)i=1,o+=Math.max(0,i-n)+Math.max(0,n+r-i);else{if(!c.isBlock||c.isLeaf)throw Wh();{i+=1,n-=1;const{removedLength:t,totalLength:c}=Qh(s,e,n,r);o+=t,i+=c,i+=1,n-=1}}break;case bh:const a=s._length;i+=a,s.delete(n,r),o+=s._length-a;break;default:throw Wh()}return{removedLength:o,totalLength:i}},[Nh](t,e,n,r){const o=t.content.str.length,i=Math.max(0,o-n)+Math.max(0,n+r-o);return i&&t.content.remove(n,r),{removedLength:i,totalLength:o}}};function Qh(t,e,n,r){let o=0,i=0;return eu(t,(function(t){const s=Xh[t.content.constructor];if(!s)throw Wh();const{removedLength:c,totalLength:a}=s(t,e,n,r);n-=a,r-=c,o+=a,i+=c})),{removedLength:i,totalLength:o}}function Zh(t,e){const n=tu(t);e.insert(0,n)}function tu(t){return t.content.map((function(t){return function(t){if("text"===t.type.name)return function(t){const e=new bh;return e.insert(0,t.text),t.marks.forEach((function(n){e.format(0,t.nodeSize,{[n.type.name]:n.attrs})})),e}(t);const e=new vh(t.type.name);return Object.keys(t.attrs).forEach((function(n){e.setAttribute(n,t.attrs[n])})),t.isLeaf||Zh(t.content,e),e}(t)}))}function eu(t,e){let n=t._start;for(;n;){if(!n.deleted){const t=e(n);if(t===Hh)return t}n=n.right}}function nu(t,e){let n=o.empty;return eu(t,(function(t){if(t.content.constructor===Vh)if(t.content.type.constructor===vh){const r=function(t,e){const n=t.nodeName,r=function(t){const e={};return function(t,e){for(const[n,r]of t._map)e(r,n)}(t,(function(t,n){let r=null;eu(t,(function(t){t&&!t.deleted&&(r=t.value)})),r&&(e[n]=r)})),e}(t),o=nu(t,e);return e.node(n,r,o)}(t.content.type,e);n=n.addToEnd(r)}else{if(t.content.type.constructor!==bh)throw Wh();{const r=function(t,e){const n=[];let r="";const o={};return eu(t,(function(t){t.content.constructor===Eh?(n.push(e.text(r,function(t,e){return Object.keys(t).map((function(n){return e.mark(n,t[n])}))}(o,e))),null===t.content.value?delete o[t.content.key]:o[t.content.key]=t.content.value,r=""):t.content.constructor===Nh&&(r+=t.content.str)})),r&&n.push(e.text(r)),n}(t.content.type,e);r.forEach((function(t){n=n.addToEnd(t)}))}}})),n}function ru(t,e,n,r,o){ou(t,e,n,r,o)}function ou(t,e,n,r,o){let i=0;return eu(t,(function(t){if(t.content.constructor===Vh)if(t.content.type.constructor===vh)e.nodes[t.content.type.nodeName].isLeaf||(i+=1,i+=ou(t.content.type,e,n-i,r-i,o)),i+=1;else{if(t.content.type.constructor!==bh)throw Wh();i+=function(t,e,n,r,o){return t.format(n,r-n,o),t.length}(t.content.type,0,n,r,o)}if(i>r)return Hh})),i}const iu=new xe("yjs"),su=new ke({key:iu,state:{init:t=>{const{yjs:e}=t;return e.xmlFragment.doc.on("update",(function(t,n){"local"===n&&e.onLocalUpdate(t,e.id)})),e.xmlFragment.observeDeep((function(t,n){if(console.log("observeDeep",e.xmlFragment.doc.clientID,n.origin),"remote"===n.origin){const t=e.getView(),n=function(t,e){const n=nu(t,e);return e.node("doc",null,n)}(e.xmlFragment,t.state.schema);t.dispatch(t.state.tr.setMeta(iu,{origin:"remote"}).replace(0,t.state.doc.content.size,new u(n.content,0,0)))}})),e},apply:(t,e,n,r)=>{if(!t.docChanged)return e;const o=t.getMeta(iu);return o&&"remote"===o.origin||(gl(e.xmlFragment.doc,(function(){t.steps.forEach((function(t){const r=t;switch(r.structure&&r.slice.content.content.reduce(((t,e)=>t+e.textContent),"").length,!0){case r instanceof Dt:r.to>r.from&&function(t,e,n,r){console.assert("number"==typeof n&&"number"==typeof r),Qh(t,e,n,r)}(e.xmlFragment,n.schema,r.from,r.to-r.from),r.slice.content.size&&function(t,e,n,r){if(Yh(t,e,n,tu(r.content))!==Gh)throw Kh("Insert")}(e.xmlFragment,n.schema,r.from,r.slice);break;case r instanceof Nt:break;case r instanceof qt:ru(e.xmlFragment,n.schema,r.from,r.to,{[r.mark.type.name]:r.mark.attrs});break;case r instanceof jt:ru(e.xmlFragment,n.schema,r.from,r.to,{[r.mark.type.name]:null});break;default:throw new Error("Unexpect step constructor"+r.constructor)}}))}),"local"),console.log(e.xmlFragment.toJSON())),e}}});String.fromCharCode,String.fromCodePoint;const cu=/^\s*/g,au=/([A-Z])/g,lu=(t,e)=>(t=>t.replace(cu,""))(t.replace(au,(t=>`${e}${(t=>t.toLowerCase())(t)}`)));"undefined"!=typeof TextEncoder&&new TextEncoder;let hu="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});hu&&1===hu.decode(new Uint8Array).length&&(hu=null);const uu=()=>new Map,du=t=>{const e=uu();return t.forEach(((t,n)=>{e.set(n,t)})),e},pu=(t,e,n)=>{let r=t.get(e);return void 0===r&&t.set(e,r=n()),r};let fu=new class{constructor(){this.map=new Map}setItem(t,e){this.map.set(t,e)}getItem(t){return this.map.get(t)}},gu=!0;try{"undefined"!=typeof localStorage&&(fu=localStorage,gu=!1)}catch(t){}const mu=fu,vu="undefined"!=typeof process&&process.release&&/node|io\.js/.test(process.release.name);let yu;"undefined"!=typeof navigator&&/Mac/.test(navigator.platform);const wu=[],bu=((t=>{(()=>{if(void 0===yu)if(vu){yu=uu();const t=process.argv;let e=null;for(let n=0;n<t.length;n++){const r=t[n];"-"===r[0]?(null!==e&&yu.set(e,""),e=r):null!==e?(yu.set(e,r),e=null):wu.push(r)}null!==e&&yu.set(e,"")}else"object"==typeof location?(yu=uu(),(location.search||"?").slice(1).split("&").forEach((t=>{if(0!==t.length){const[e,n]=t.split("=");yu.set(`--${lu(e,"-")}`,n),yu.set(`-${lu(e,"-")}`,n)}}))):yu=uu();return yu})().has("--production")||(t=>{return void 0===(e=vu?process.env[t.toUpperCase()]:mu.getItem(t))?null:e;var e})(t)})("production"),(t,e,n)=>new Uint8Array(t,e,n)),ku=128,Su=127;class Cu{constructor(t){this.arr=t,this.pos=0}}const xu=t=>new Cu(t),Mu=t=>((t,e)=>{const n=bu(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,n})(t,Eu(t)),_u=t=>t.arr[t.pos++],Eu=t=>{let e=0,n=0;for(;;){const r=t.arr[t.pos++];if(e|=(r&Su)<<n,n+=7,r<ku)return e>>>0;if(n>35)throw new Error("Integer out of range!")}},Ou=t=>{let e=Eu(t);if(0===e)return"";{let n=String.fromCodePoint(_u(t));if(--e<100)for(;e--;)n+=String.fromCodePoint(_u(t));else for(;e>0;){const r=e<1e4?e:1e4,o=t.arr.subarray(t.pos,t.pos+r);t.pos+=r,n+=String.fromCodePoint.apply(null,o),e-=r}return decodeURIComponent(escape(n))}},Du=(t,e)=>{const n=new DataView(t.arr.buffer,t.arr.byteOffset+t.pos,e);return t.pos+=e,n},Nu=[t=>{},t=>null,t=>{let e=t.arr[t.pos++],n=63&e,r=6;const o=(64&e)>0?-1:1;if(0==(e&ku))return o*n;for(;;){if(e=t.arr[t.pos++],n|=(e&Su)<<r,r+=7,e<ku)return o*(n>>>0);if(r>41)throw new Error("Integer out of range!")}},t=>Du(t,4).getFloat32(0,!1),t=>Du(t,8).getFloat64(0,!1),t=>Du(t,8).getBigInt64(0,!1),t=>!1,t=>!0,Ou,t=>{const e=Eu(t),n={};for(let r=0;r<e;r++)n[Ou(t)]=Au(t);return n},t=>{const e=Eu(t),n=[];for(let r=0;r<e;r++)n.push(Au(t));return n},Mu],Au=t=>Nu[127-_u(t)](t),Tu=t=>new Error(t),Iu=()=>{throw Tu("Method unimplemented")},Ru=()=>{throw Tu("Unexpected case")},zu=()=>new Set,Pu=t=>t[t.length-1],Lu=Array.from,Bu=Math.floor,Vu=(Math.ceil,Math.abs),Fu=(Math.imul,Math.round,Math.log10,Math.log2,Math.log,Math.sqrt,(t,e)=>t<e?t:e),$u=(t,e)=>t>e?t:e,qu=(Number.isNaN,Math.pow,Math.sign,Number.MAX_SAFE_INTEGER,Number.MIN_SAFE_INTEGER,Number.isInteger||(t=>"number"==typeof t&&isFinite(t)&&Bu(t)===t));Number.isNaN;class ju{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const Uu=()=>new ju,Ju=t=>{const e=new Uint8Array((t=>{let e=t.cpos;for(let n=0;n<t.bufs.length;n++)e+=t.bufs[n].length;return e})(t));let n=0;for(let r=0;r<t.bufs.length;r++){const o=t.bufs[r];e.set(o,n),n+=o.length}return e.set(bu(t.cbuf.buffer,0,t.cpos),n),e},Wu=(t,e)=>{const n=t.cbuf.length;t.cpos===n&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(2*n),t.cpos=0),t.cbuf[t.cpos++]=e},Ku=Wu,Hu=(t,e)=>{for(;e>Su;)Wu(t,ku|Su&e),e>>>=7;Wu(t,Su&e)},Gu=(t,e)=>{const n=0!==(r=e)?r<0:1/r<0;var r;for(n&&(e=-e),Wu(t,(e>63?ku:0)|(n?64:0)|63&e),e>>>=6;e>0;)Wu(t,(e>Su?ku:0)|Su&e),e>>>=7},Yu=(t,e)=>{const n=unescape(encodeURIComponent(e)),r=n.length;Hu(t,r);for(let e=0;e<r;e++)Wu(t,n.codePointAt(e))},Xu=(t,e)=>{const n=t.cbuf.length,r=t.cpos,o=Fu(n-r,e.length),i=e.length-o;t.cbuf.set(e.subarray(0,o),r),t.cpos+=o,i>0&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array($u(2*n,i)),t.cbuf.set(e.subarray(o)),t.cpos=i)},Qu=(t,e)=>{Hu(t,e.byteLength),Xu(t,e)},Zu=(t,e)=>{((t,e)=>{const n=t.cbuf.length;n-t.cpos<e&&(t.bufs.push(bu(t.cbuf.buffer,0,t.cpos)),t.cbuf=new Uint8Array(2*$u(n,e)),t.cpos=0)})(t,e);const n=new DataView(t.cbuf.buffer,t.cpos,e);return t.cpos+=e,n},td=new DataView(new ArrayBuffer(4)),ed=(t,e)=>{switch(typeof e){case"string":Wu(t,119),Yu(t,e);break;case"number":qu(e)&&e<=2147483647?(Wu(t,125),Gu(t,e)):(n=e,td.setFloat32(0,n),td.getFloat32(0)===n?(Wu(t,124),((t,e)=>{Zu(t,4).setFloat32(0,e,!1)})(t,e)):(Wu(t,123),((t,e)=>{Zu(t,8).setFloat64(0,e,!1)})(t,e)));break;case"bigint":Wu(t,122),((t,e)=>{Zu(t,8).setBigInt64(0,e,!1)})(t,e);break;case"object":if(null===e)Wu(t,126);else if(e instanceof Array){Wu(t,117),Hu(t,e.length);for(let n=0;n<e.length;n++)ed(t,e[n])}else if(e instanceof Uint8Array)Wu(t,116),Qu(t,e);else{Wu(t,118);const n=Object.keys(e);Hu(t,n.length);for(let r=0;r<n.length;r++){const o=n[r];Yu(t,o),ed(t,e[o])}}break;case"boolean":Wu(t,e?120:121);break;default:Wu(t,127)}var n};class nd extends ju{constructor(t){super(),this.w=t,this.s=null,this.count=0}write(t){this.s===t?this.count++:(this.count>0&&Hu(this,this.count-1),this.count=1,this.w(this,t),this.s=t)}}const rd=t=>{t.count>0&&(Gu(t.encoder,1===t.count?t.s:-t.s),t.count>1&&Hu(t.encoder,t.count-2))};class od{constructor(){this.encoder=new ju,this.s=0,this.count=0}write(t){this.s===t?this.count++:(rd(this),this.count=1,this.s=t)}toUint8Array(){return rd(this),Ju(this.encoder)}}const id=t=>{if(t.count>0){const e=t.diff<<1|(1===t.count?0:1);Gu(t.encoder,e),t.count>1&&Hu(t.encoder,t.count-2)}};class sd{constructor(){this.encoder=new ju,this.s=0,this.count=0,this.diff=0}write(t){this.diff===t-this.s?(this.s=t,this.count++):(id(this),this.count=1,this.diff=t-this.s,this.s=t)}toUint8Array(){return id(this),Ju(this.encoder)}}class cd{constructor(){this.sarr=[],this.s="",this.lensE=new od}write(t){this.s+=t,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(t.length)}toUint8Array(){const t=new ju;return this.sarr.push(this.s),this.s="",Yu(t,this.sarr.join("")),Xu(t,this.lensE.toUint8Array()),Ju(t)}}"undefined"==typeof window||void 0!==window.performance&&window.performance;const ad="undefined"==typeof crypto?null:crypto,ld=null!==ad?t=>{const e=new ArrayBuffer(t),n=new Uint8Array(e);return ad.getRandomValues(n),e}:t=>{const e=new ArrayBuffer(t),n=new Uint8Array(e);for(let e=0;e<t;e++)n[e]=Math.ceil(4294967295*Math.random()>>>0);return e},hd=(Math.random,()=>new Uint32Array(ld(4))[0]),ud=[1e7]+-1e3+-4e3+-8e3+-1e11,dd=()=>ud.replace(/[018]/g,(t=>(t^hd()&15>>t/4).toString(16))),pd=(t,e,n=0)=>{try{for(;n<t.length;n++)t[n](...e)}finally{n<t.length&&pd(t,e,n+1)}},fd=Symbol;class gd{constructor(t,e){this.left=t,this.right=e}}const md=(t,e)=>new gd(t,e),vd="undefined"!=typeof document?document:{},yd=("undefined"!=typeof DOMParser&&new DOMParser,vd.ELEMENT_NODE,vd.TEXT_NODE,vd.CDATA_SECTION_NODE,vd.COMMENT_NODE,vd.DOCUMENT_NODE,vd.DOCUMENT_TYPE_NODE,vd.DOCUMENT_FRAGMENT_NODE,Date.now),wd=fd(),bd=fd(),kd=fd(),Sd=fd(),Cd=fd(),xd=fd(),Md=fd(),_d=fd(),Ed=fd(),Od={[wd]:md("font-weight","bold"),[bd]:md("font-weight","normal"),[kd]:md("color","blue"),[Cd]:md("color","green"),[Sd]:md("color","grey"),[xd]:md("color","red"),[Md]:md("color","purple"),[_d]:md("color","orange"),[Ed]:md("color","black")},Dd={[wd]:"[1m",[bd]:"[2m",[kd]:"[34m",[Cd]:"[32m",[Sd]:"[37m",[xd]:"[31m",[Md]:"[35m",[_d]:"[38;5;208m",[Ed]:"[0m"},Nd=vu?t=>{const e=[],n=[];let r=0;for(;r<t.length;r++){const n=t[r],o=Dd[n];if(void 0!==o)e.push(o);else{if(n.constructor!==String&&n.constructor!==Number)break;e.push(n)}}for(r>0&&(e.push("[0m"),n.push(e.join("")));r<t.length;r++){const e=t[r];e instanceof Symbol||n.push(e)}return n}:t=>{const e=[],n=[],r=uu();let o=[],i=0;for(;i<t.length;i++){const o=t[i],s=Od[o];if(void 0!==s)r.set(s.left,s.right);else{if(o.constructor!==String&&o.constructor!==Number)break;{const t=((t,e)=>{const n=[];for(const[r,o]of t)n.push(e(o,r));return n})(r,((t,e)=>`${e}:${t};`)).join("");i>0||t.length>0?(e.push("%c"+o),n.push(t)):e.push(o)}}}for(i>0&&(o=n,o.unshift(e.join("")));i<t.length;i++){const e=t[i];e instanceof Symbol||o.push(e)}return o},Ad=new Set;yd();const Td=t=>({[Symbol.iterator](){return this},next:t}),Id=(t,e)=>Td((()=>{const{done:n,value:r}=t.next();return{done:n,value:n?void 0:e(r)}})),Rd=(Object.assign,Object.keys),zd=t=>Rd(t).length;class Pd{constructor(t,e){this.clock=t,this.len=e}}class Ld{constructor(){this.clients=new Map}}const Bd=(t,e,n)=>e.clients.forEach(((e,r)=>{const o=t.doc.store.clients.get(r);for(let r=0;r<e.length;r++){const i=e[r];dp(t,o,i.clock,i.len,n)}})),Vd=(t,e)=>{const n=t.clients.get(e.client);return void 0!==n&&null!==((t,e)=>{let n=0,r=t.length-1;for(;n<=r;){const o=Bu((n+r)/2),i=t[o],s=i.clock;if(s<=e){if(e<s+i.len)return o;n=o+1}else r=o-1}return null})(n,e.clock)},Fd=t=>{t.clients.forEach((t=>{let e,n;for(t.sort(((t,e)=>t.clock-e.clock)),e=1,n=1;e<t.length;e++){const r=t[n-1],o=t[e];r.clock+r.len>=o.clock?r.len=$u(r.len,o.clock+o.len-r.clock):(n<e&&(t[n]=o),n++)}t.length=n}))},$d=(t,e,n,r)=>{pu(t.clients,e,(()=>[])).push(new Pd(n,r))},qd=hd;class jd extends class{constructor(){this._observers=uu()}on(t,e){pu(this._observers,t,zu).add(e)}once(t,e){const n=(...r)=>{this.off(t,n),e(...r)};this.on(t,n)}off(t,e){const n=this._observers.get(t);void 0!==n&&(n.delete(e),0===n.size&&this._observers.delete(t))}emit(t,e){return Lu((this._observers.get(t)||uu()).values()).forEach((t=>t(...e)))}destroy(){this._observers=uu()}}{constructor({guid:t=dd(),gc:e=!0,gcFilter:n=(()=>!0),meta:r=null,autoLoad:o=!1}={}){super(),this.gc=e,this.gcFilter=n,this.clientID=qd(),this.guid=t,this.share=new Map,this.store=new rp,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=o,this.autoLoad=o,this.meta=r}load(){const t=this._item;null===t||this.shouldLoad||yp(t.parent.doc,(t=>{t.subdocsLoaded.add(this)}),null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(Array.from(this.subdocs).map((t=>t.guid)))}transact(t,e=null){yp(this,t,e)}get(t,e=Ep){const n=pu(this.share,t,(()=>{const t=new e;return t._integrate(this,null),t})),r=n.constructor;if(e!==Ep&&r!==e){if(r===Ep){const r=new e;r._map=n._map,n._map.forEach((t=>{for(;null!==t;t=t.left)t.parent=r})),r._start=n._start;for(let t=r._start;null!==t;t=t.right)t.parent=r;return r._length=n._length,this.share.set(t,r),r._integrate(this,null),r}throw new Error(`Type with the name ${t} has already been defined with a different constructor`)}return n}getArray(t=""){return this.get(t,Jp)}getText(t=""){return this.get(t,af)}getMap(t=""){return this.get(t,Kp)}getXmlFragment(t=""){return this.get(t,hf)}toJSON(){const t={};return this.share.forEach(((e,n)=>{t[n]=e.toJSON()})),t}destroy(){Lu(this.subdocs).forEach((t=>t.destroy()));const t=this._item;if(null!==t){this._item=null;const e=t.content;t.deleted?e.doc=null:(e.doc=new jd({guid:this.guid,...e.opts}),e.doc._item=t),yp(t.parent.doc,(n=>{t.deleted||n.subdocsAdded.add(e.doc),n.subdocsRemoved.add(this)}),null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}on(t,e){super.on(t,e)}off(t,e){super.off(t,e)}}class Ud extends class{constructor(){this.restEncoder=Uu()}toUint8Array(){return Ju(this.restEncoder)}resetDsCurVal(){}writeDsClock(t){Hu(this.restEncoder,t)}writeDsLen(t){Hu(this.restEncoder,t)}}{writeLeftID(t){Hu(this.restEncoder,t.client),Hu(this.restEncoder,t.clock)}writeRightID(t){Hu(this.restEncoder,t.client),Hu(this.restEncoder,t.clock)}writeClient(t){Hu(this.restEncoder,t)}writeInfo(t){Ku(this.restEncoder,t)}writeString(t){Yu(this.restEncoder,t)}writeParentInfo(t){Hu(this.restEncoder,t?1:0)}writeTypeRef(t){Hu(this.restEncoder,t)}writeLen(t){Hu(this.restEncoder,t)}writeAny(t){ed(this.restEncoder,t)}writeBuf(t){Qu(this.restEncoder,t)}writeJSON(t){Yu(this.restEncoder,JSON.stringify(t))}writeKey(t){Yu(this.restEncoder,t)}}class Jd extends class{constructor(){this.restEncoder=Uu(),this.dsCurrVal=0}toUint8Array(){return Ju(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(t){const e=t-this.dsCurrVal;this.dsCurrVal=t,Hu(this.restEncoder,e)}writeDsLen(t){0===t&&Ru(),Hu(this.restEncoder,t-1),this.dsCurrVal+=t}}{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new sd,this.clientEncoder=new od,this.leftClockEncoder=new sd,this.rightClockEncoder=new sd,this.infoEncoder=new nd(Ku),this.stringEncoder=new cd,this.parentInfoEncoder=new nd(Ku),this.typeRefEncoder=new od,this.lenEncoder=new od}toUint8Array(){const t=Uu();return Hu(t,0),Qu(t,this.keyClockEncoder.toUint8Array()),Qu(t,this.clientEncoder.toUint8Array()),Qu(t,this.leftClockEncoder.toUint8Array()),Qu(t,this.rightClockEncoder.toUint8Array()),Qu(t,Ju(this.infoEncoder)),Qu(t,this.stringEncoder.toUint8Array()),Qu(t,Ju(this.parentInfoEncoder)),Qu(t,this.typeRefEncoder.toUint8Array()),Qu(t,this.lenEncoder.toUint8Array()),Xu(t,Ju(this.restEncoder)),Ju(t)}writeLeftID(t){this.clientEncoder.write(t.client),this.leftClockEncoder.write(t.clock)}writeRightID(t){this.clientEncoder.write(t.client),this.rightClockEncoder.write(t.clock)}writeClient(t){this.clientEncoder.write(t)}writeInfo(t){this.infoEncoder.write(t)}writeString(t){this.stringEncoder.write(t)}writeParentInfo(t){this.parentInfoEncoder.write(t?1:0)}writeTypeRef(t){this.typeRefEncoder.write(t)}writeLen(t){this.lenEncoder.write(t)}writeAny(t){ed(this.restEncoder,t)}writeBuf(t){Qu(this.restEncoder,t)}writeJSON(t){ed(this.restEncoder,t)}writeKey(t){void 0===this.keyMap.get(t)?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(t)):this.keyClockEncoder.write(this.keyClock++)}}class Wd{constructor(){this.l=[]}}const Kd=()=>new Wd,Hd=(t,e)=>t.l.push(e),Gd=(t,e)=>{const n=t.l,r=n.length;t.l=n.filter((t=>e!==t)),r===t.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},Yd=(t,e,n)=>pd(t.l,[e,n]);class Xd{constructor(t,e){this.client=t,this.clock=e}}const Qd=(t,e)=>t===e||null!==t&&null!==e&&t.client===e.client&&t.clock===e.clock,Zd=(t,e)=>new Xd(t,e);class tp{constructor(t,e){this.ds=t,this.sv=e}}const ep=(((t,e)=>{new tp(t,e)})(new Ld,new Map),(t,e)=>void 0===e?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!Vd(e.ds,t.id)),np=(t,e)=>{const n=pu(t.meta,np,zu),r=t.doc.store;n.has(e)||(e.sv.forEach(((e,n)=>{e<ip(r,n)&&hp(t,Zd(n,e))})),Bd(t,e.ds,(t=>{})),n.add(e))};class rp{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const op=t=>{const e=new Map;return t.clients.forEach(((t,n)=>{const r=t[t.length-1];e.set(n,r.id.clock+r.length)})),e},ip=(t,e)=>{const n=t.clients.get(e);if(void 0===n)return 0;const r=n[n.length-1];return r.id.clock+r.length},sp=(t,e)=>{let n=t.clients.get(e.id.client);if(void 0===n)n=[],t.clients.set(e.id.client,n);else{const t=n[n.length-1];if(t.id.clock+t.length!==e.id.clock)throw Ru()}n.push(e)},cp=(t,e)=>{let n=0,r=t.length-1,o=t[r],i=o.id.clock;if(i===e)return r;let s=Bu(e/(i+o.length-1)*r);for(;n<=r;){if(o=t[s],i=o.id.clock,i<=e){if(e<i+o.length)return s;n=s+1}else r=s-1;s=Bu((n+r)/2)}throw Ru()},ap=(t,e)=>{const n=t.clients.get(e.client);return n[cp(n,e.clock)]},lp=(t,e,n)=>{const r=cp(e,n),o=e[r];return o.id.clock<n&&o instanceof Df?(e.splice(r+1,0,Of(t,o,n-o.id.clock)),r+1):r},hp=(t,e)=>{const n=t.doc.store.clients.get(e.client);return n[lp(t,n,e.clock)]},up=(t,e,n)=>{const r=e.clients.get(n.client),o=cp(r,n.clock),i=r[o];return n.clock!==i.id.clock+i.length-1&&i.constructor!==ff&&r.splice(o+1,0,Of(t,i,n.clock-i.id.clock+1)),i},dp=(t,e,n,r,o)=>{if(0===r)return;const i=n+r;let s,c=lp(t,e,n);do{s=e[c++],i<s.id.clock+s.length&&lp(t,e,i),o(s)}while(c<e.length&&e[c].id.clock<i)};class pp{constructor(t,e,n){this.doc=t,this.deleteSet=new Ld,this.beforeState=op(t.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=e,this.meta=new Map,this.local=n,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set}}const fp=(t,e)=>!(0===e.deleteSet.clients.size&&!((t,n)=>{for(const[n,i]of t)if(r=i,o=n,e.beforeState.get(o)!==r)return!0;var r,o;return!1})(e.afterState)||(Fd(e.deleteSet),((t,e)=>{((t,e,n)=>{const r=new Map;n.forEach(((t,n)=>{ip(e,n)>t&&r.set(n,t)})),op(e).forEach(((t,e)=>{n.has(e)||r.set(e,0)})),Hu(t.restEncoder,r.size),Array.from(r.entries()).sort(((t,e)=>e[0]-t[0])).forEach((([n,r])=>{((t,e,n,r)=>{r=$u(r,e[0].id.clock);const o=cp(e,r);Hu(t.restEncoder,e.length-o),t.writeClient(n),Hu(t.restEncoder,r);const i=e[o];i.write(t,r-i.id.clock);for(let n=o+1;n<e.length;n++)e[n].write(t,0)})(t,e.clients.get(n),n,r)}))})(t,e.doc.store,e.beforeState)})(t,e),((t,e)=>{Hu(t.restEncoder,e.clients.size),e.clients.forEach(((e,n)=>{t.resetDsCurVal(),Hu(t.restEncoder,n);const r=e.length;Hu(t.restEncoder,r);for(let n=0;n<r;n++){const r=e[n];t.writeDsClock(r.clock),t.writeDsLen(r.len)}}))})(t,e.deleteSet),0)),gp=(t,e,n)=>{const r=e._item;(null===r||r.id.clock<(t.beforeState.get(r.id.client)||0)&&!r.deleted)&&pu(t.changed,e,zu).add(n)},mp=(t,e)=>{const n=t[e-1],r=t[e];n.deleted===r.deleted&&n.constructor===r.constructor&&n.mergeWith(r)&&(t.splice(e,1),r instanceof Df&&null!==r.parentSub&&r.parent._map.get(r.parentSub)===r&&r.parent._map.set(r.parentSub,n))},vp=(t,e)=>{if(e<t.length){const n=t[e],r=n.doc,o=r.store,i=n.deleteSet,s=n._mergeStructs;try{Fd(i),n.afterState=op(n.doc.store),r._transaction=null,r.emit("beforeObserverCalls",[n,r]);const c=[];n.changed.forEach(((t,e)=>c.push((()=>{null!==e._item&&e._item.deleted||e._callObserver(n,t)})))),c.push((()=>{n.changedParentTypes.forEach(((t,e)=>c.push((()=>{null!==e._item&&e._item.deleted||((t=t.filter((t=>null===t.target._item||!t.target._item.deleted))).forEach((t=>{t.currentTarget=e})),t.sort(((t,e)=>t.path.length-e.path.length)),Yd(e._dEH,t,n))})))),c.push((()=>r.emit("afterTransaction",[n,r])))})),pd(c,[])}finally{r.gc&&((t,e,n)=>{for(const[r,o]of t.clients.entries()){const t=e.clients.get(r);for(let r=o.length-1;r>=0;r--){const i=o[r],s=i.clock+i.len;for(let r=cp(t,i.clock),o=t[r];r<t.length&&o.id.clock<s;o=t[++r]){const o=t[r];if(i.clock+i.len<=o.id.clock)break;o instanceof Df&&o.deleted&&!o.keep&&n(o)&&o.gc(e,!1)}}}})(i,o,r.gcFilter),((t,e)=>{t.clients.forEach(((t,n)=>{const r=e.clients.get(n);for(let e=t.length-1;e>=0;e--){const n=t[e];for(let t=Fu(r.length-1,1+cp(r,n.clock+n.len-1)),e=r[t];t>0&&e.id.clock>=n.clock;e=r[--t])mp(r,t)}}))})(i,o),n.afterState.forEach(((t,e)=>{const r=n.beforeState.get(e)||0;if(r!==t){const t=o.clients.get(e),n=$u(cp(t,r),1);for(let e=t.length-1;e>=n;e--)mp(t,e)}}));for(let t=0;t<s.length;t++){const{client:e,clock:n}=s[t].id,r=o.clients.get(e),i=cp(r,n);i+1<r.length&&mp(r,i+1),i>0&&mp(r,i)}if(n.local||n.afterState.get(r.clientID)===n.beforeState.get(r.clientID)||(r.clientID=qd(),((...t)=>{console.log(...Nd(t)),Ad.forEach((e=>e.print(t)))})(_d,wd,"[yjs] ",bd,xd,"Changed the client-id because another client seems to be using it.")),r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){const t=new Ud;fp(t,n)&&r.emit("update",[t.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){const t=new Jd;fp(t,n)&&r.emit("updateV2",[t.toUint8Array(),n.origin,r,n])}n.subdocsAdded.forEach((t=>r.subdocs.add(t))),n.subdocsRemoved.forEach((t=>r.subdocs.delete(t))),r.emit("subdocs",[{loaded:n.subdocsLoaded,added:n.subdocsAdded,removed:n.subdocsRemoved}]),n.subdocsRemoved.forEach((t=>t.destroy())),t.length<=e+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,t])):vp(t,e+1)}}},yp=(t,e,n=null,r=!0)=>{const o=t._transactionCleanups;let i=!1;null===t._transaction&&(i=!0,t._transaction=new pp(t,n,r),o.push(t._transaction),1===o.length&&t.emit("beforeAllTransactions",[t]),t.emit("beforeTransaction",[t._transaction,t]));try{e(t._transaction)}finally{i&&o[0]===t._transaction&&vp(o,0)}};class wp{constructor(t,e){this.target=t,this.currentTarget=t,this.transaction=e,this._changes=null,this._keys=null,this._delta=null}get path(){return bp(this.currentTarget,this.target)}deletes(t){return Vd(this.transaction.deleteSet,t.id)}get keys(){if(null===this._keys){const t=new Map,e=this.target;this.transaction.changed.get(e).forEach((n=>{if(null!==n){const r=e._map.get(n);let o,i;if(this.adds(r)){let t=r.left;for(;null!==t&&this.adds(t);)t=t.left;if(this.deletes(r)){if(null===t||!this.deletes(t))return;o="delete",i=Pu(t.content.getContent())}else null!==t&&this.deletes(t)?(o="update",i=Pu(t.content.getContent())):(o="add",i=void 0)}else{if(!this.deletes(r))return;o="delete",i=Pu(r.content.getContent())}t.set(n,{action:o,oldValue:i})}})),this._keys=t}return this._keys}get delta(){return this.changes.delta}adds(t){return t.id.clock>=(this.transaction.beforeState.get(t.id.client)||0)}get changes(){let t=this._changes;if(null===t){const e=this.target,n=zu(),r=zu(),o=[];if(t={added:n,deleted:r,delta:o,keys:this.keys},this.transaction.changed.get(e).has(null)){let t=null;const i=()=>{t&&o.push(t)};for(let o=e._start;null!==o;o=o.right)o.deleted?this.deletes(o)&&!this.adds(o)&&(null!==t&&void 0!==t.delete||(i(),t={delete:0}),t.delete+=o.length,r.add(o)):this.adds(o)?(null!==t&&void 0!==t.insert||(i(),t={insert:[]}),t.insert=t.insert.concat(o.content.getContent()),n.add(o)):(null!==t&&void 0!==t.retain||(i(),t={retain:0}),t.retain+=o.length);null!==t&&void 0===t.retain&&i()}this._changes=t}return t}}const bp=(t,e)=>{const n=[];for(;null!==e._item&&e!==t;){if(null!==e._item.parentSub)n.unshift(e._item.parentSub);else{let t=0,r=e._item.parent._start;for(;r!==e._item&&null!==r;)r.deleted||t++,r=r.right;n.unshift(t)}e=e._item.parent}return n};let kp=0;class Sp{constructor(t,e){t.marker=!0,this.p=t,this.index=e,this.timestamp=kp++}}const Cp=(t,e,n)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=n,t.timestamp=kp++},xp=(t,e)=>{if(null===t._start||0===e||null===t._searchMarker)return null;const n=0===t._searchMarker.length?null:t._searchMarker.reduce(((t,n)=>Vu(e-t.index)<Vu(e-n.index)?t:n));let r=t._start,o=0;for(null!==n&&(r=n.p,o=n.index,(t=>{t.timestamp=kp++})(n));null!==r.right&&o<e;){if(!r.deleted&&r.countable){if(e<o+r.length)break;o+=r.length}r=r.right}for(;null!==r.left&&o>e;)r=r.left,!r.deleted&&r.countable&&(o-=r.length);for(;null!==r.left&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(o-=r.length);return null!==n&&Vu(n.index-o)<r.parent.length/80?(Cp(n,r,o),n):((t,e,n)=>{if(t.length>=80){const r=t.reduce(((t,e)=>t.timestamp<e.timestamp?t:e));return Cp(r,e,n),r}{const r=new Sp(e,n);return t.push(r),r}})(t._searchMarker,r,o)},Mp=(t,e,n)=>{for(let r=t.length-1;r>=0;r--){const o=t[r];if(n>0){let e=o.p;for(e.marker=!1;e&&(e.deleted||!e.countable);)e=e.left,e&&!e.deleted&&e.countable&&(o.index-=e.length);if(null===e||!0===e.marker){t.splice(r,1);continue}o.p=e,e.marker=!0}(e<o.index||n>0&&e===o.index)&&(o.index=$u(e,o.index+n))}},_p=(t,e,n)=>{const r=t,o=e.changedParentTypes;for(;pu(o,t,(()=>[])).push(n),null!==t._item;)t=t._item.parent;Yd(r._eH,n,e)};class Ep{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=Kd(),this._dEH=Kd(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(t,e){this.doc=t,this._item=e}_copy(){throw Iu()}clone(){throw Iu()}_write(t){}get _first(){let t=this._start;for(;null!==t&&t.deleted;)t=t.right;return t}_callObserver(t,e){!t.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(t){Hd(this._eH,t)}observeDeep(t){Hd(this._dEH,t)}unobserve(t){Gd(this._eH,t)}unobserveDeep(t){Gd(this._dEH,t)}toJSON(){}}const Op=(t,e,n)=>{e<0&&(e=t._length+e),n<0&&(n=t._length+n);let r=n-e;const o=[];let i=t._start;for(;null!==i&&r>0;){if(i.countable&&!i.deleted){const t=i.content.getContent();if(t.length<=e)e-=t.length;else{for(let n=e;n<t.length&&r>0;n++)o.push(t[n]),r--;e=0}}i=i.right}return o},Dp=t=>{const e=[];let n=t._start;for(;null!==n;){if(n.countable&&!n.deleted){const t=n.content.getContent();for(let n=0;n<t.length;n++)e.push(t[n])}n=n.right}return e},Np=(t,e)=>{let n=0,r=t._start;for(;null!==r;){if(r.countable&&!r.deleted){const o=r.content.getContent();for(let r=0;r<o.length;r++)e(o[r],n++,t)}r=r.right}},Ap=(t,e)=>{const n=[];return Np(t,((r,o)=>{n.push(e(r,o,t))})),n},Tp=t=>{let e=t._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(null===n){for(;null!==e&&e.deleted;)e=e.right;if(null===e)return{done:!0,value:void 0};n=e.content.getContent(),r=0,e=e.right}const t=n[r++];return n.length<=r&&(n=null),{done:!1,value:t}}}},Ip=(t,e)=>{const n=xp(t,e);let r=t._start;for(null!==n&&(r=n.p,e-=n.index);null!==r;r=r.right)if(!r.deleted&&r.countable){if(e<r.length)return r.content.getContent()[e];e-=r.length}},Rp=(t,e,n,r)=>{let o=n;const i=t.doc,s=i.clientID,c=i.store,a=null===n?e._start:n.right;let l=[];const h=()=>{l.length>0&&(o=new Df(Zd(s,ip(c,s)),o,o&&o.lastId,a,a&&a.id,e,null,new bf(l)),o.integrate(t,0),l=[])};r.forEach((n=>{switch(n.constructor){case Number:case Object:case Boolean:case Array:case String:l.push(n);break;default:switch(h(),n.constructor){case Uint8Array:case ArrayBuffer:o=new Df(Zd(s,ip(c,s)),o,o&&o.lastId,a,a&&a.id,e,null,new gf(new Uint8Array(n))),o.integrate(t,0);break;case jd:o=new Df(Zd(s,ip(c,s)),o,o&&o.lastId,a,a&&a.id,e,null,new vf(n)),o.integrate(t,0);break;default:if(!(n instanceof Ep))throw new Error("Unexpected content type in insert operation");o=new Df(Zd(s,ip(c,s)),o,o&&o.lastId,a,a&&a.id,e,null,new Ef(n)),o.integrate(t,0)}}})),h()},zp=Tu("Length exceeded!"),Pp=(t,e,n,r)=>{if(n>e._length)throw zp;if(0===n)return e._searchMarker&&Mp(e._searchMarker,n,r.length),Rp(t,e,null,r);const o=n,i=xp(e,n);let s=e._start;for(null!==i&&(s=i.p,0==(n-=i.index)&&(s=s.prev,n+=s&&s.countable&&!s.deleted?s.length:0));null!==s;s=s.right)if(!s.deleted&&s.countable){if(n<=s.length){n<s.length&&hp(t,Zd(s.id.client,s.id.clock+n));break}n-=s.length}return e._searchMarker&&Mp(e._searchMarker,o,r.length),Rp(t,e,s,r)},Lp=(t,e,n,r)=>{if(0===r)return;const o=n,i=r,s=xp(e,n);let c=e._start;for(null!==s&&(c=s.p,n-=s.index);null!==c&&n>0;c=c.right)!c.deleted&&c.countable&&(n<c.length&&hp(t,Zd(c.id.client,c.id.clock+n)),n-=c.length);for(;r>0&&null!==c;)c.deleted||(r<c.length&&hp(t,Zd(c.id.client,c.id.clock+r)),c.delete(t),r-=c.length),c=c.right;if(r>0)throw zp;e._searchMarker&&Mp(e._searchMarker,o,-i+r)},Bp=(t,e,n)=>{const r=e._map.get(n);void 0!==r&&r.delete(t)},Vp=(t,e,n,r)=>{const o=e._map.get(n)||null,i=t.doc,s=i.clientID;let c;if(null==r)c=new bf([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:c=new bf([r]);break;case Uint8Array:c=new gf(r);break;case jd:c=new vf(r);break;default:if(!(r instanceof Ep))throw new Error("Unexpected content type");c=new Ef(r)}new Df(Zd(s,ip(i.store,s)),o,o&&o.lastId,null,null,e,n,c).integrate(t,0)},Fp=(t,e)=>{const n=t._map.get(e);return void 0===n||n.deleted?void 0:n.content.getContent()[n.length-1]},$p=t=>{const e={};return t._map.forEach(((t,n)=>{t.deleted||(e[n]=t.content.getContent()[t.length-1])})),e},qp=(t,e)=>{const n=t._map.get(e);return void 0!==n&&!n.deleted},jp=t=>{return e=t.entries(),n=t=>!t[1].deleted,Td((()=>{let t;do{t=e.next()}while(!t.done&&!n(t.value));return t}));var e,n};class Up extends wp{constructor(t,e){super(t,e),this._transaction=e}}class Jp extends Ep{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(t){const e=new Jp;return e.push(t),e}_integrate(t,e){super._integrate(t,e),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new Jp}clone(){const t=new Jp;return t.insert(0,this.toArray().map((t=>t instanceof Ep?t.clone():t))),t}get length(){return null===this._prelimContent?this._length:this._prelimContent.length}_callObserver(t,e){super._callObserver(t,e),_p(this,t,new Up(this,t))}insert(t,e){null!==this.doc?yp(this.doc,(n=>{Pp(n,this,t,e)})):this._prelimContent.splice(t,0,...e)}push(t){this.insert(this.length,t)}unshift(t){this.insert(0,t)}delete(t,e=1){null!==this.doc?yp(this.doc,(n=>{Lp(n,this,t,e)})):this._prelimContent.splice(t,e)}get(t){return Ip(this,t)}toArray(){return Dp(this)}slice(t=0,e=this.length){return Op(this,t,e)}toJSON(){return this.map((t=>t instanceof Ep?t.toJSON():t))}map(t){return Ap(this,t)}forEach(t){Np(this,t)}[Symbol.iterator](){return Tp(this)}_write(t){t.writeTypeRef(Sf)}}class Wp extends wp{constructor(t,e,n){super(t,e),this.keysChanged=n}}class Kp extends Ep{constructor(t){super(),this._prelimContent=null,this._prelimContent=void 0===t?new Map:new Map(t)}_integrate(t,e){super._integrate(t,e),this._prelimContent.forEach(((t,e)=>{this.set(e,t)})),this._prelimContent=null}_copy(){return new Kp}clone(){const t=new Kp;return this.forEach(((e,n)=>{t.set(n,e instanceof Ep?e.clone():e)})),t}_callObserver(t,e){_p(this,t,new Wp(this,t,e))}toJSON(){const t={};return this._map.forEach(((e,n)=>{if(!e.deleted){const r=e.content.getContent()[e.length-1];t[n]=r instanceof Ep?r.toJSON():r}})),t}get size(){return[...jp(this._map)].length}keys(){return Id(jp(this._map),(t=>t[0]))}values(){return Id(jp(this._map),(t=>t[1].content.getContent()[t[1].length-1]))}entries(){return Id(jp(this._map),(t=>[t[0],t[1].content.getContent()[t[1].length-1]]))}forEach(t){return this._map.forEach(((e,n)=>{e.deleted||t(e.content.getContent()[e.length-1],n,this)})),{}}[Symbol.iterator](){return this.entries()}delete(t){null!==this.doc?yp(this.doc,(e=>{Bp(e,this,t)})):this._prelimContent.delete(t)}set(t,e){return null!==this.doc?yp(this.doc,(n=>{Vp(n,this,t,e)})):this._prelimContent.set(t,e),e}get(t){return Fp(this,t)}has(t){return qp(this,t)}clear(){null!==this.doc?yp(this.doc,(t=>{this.forEach((function(e,n,r){Bp(t,r,n)}))})):this._prelimContent.clear()}_write(t){t.writeTypeRef(Cf)}}const Hp=(t,e)=>t===e||"object"==typeof t&&"object"==typeof e&&t&&e&&((t,e)=>t===e||zd(t)===zd(e)&&((t,e)=>{for(const n in t)if(!e(t[n],n))return!1;return!0})(t,((t,n)=>(void 0!==t||((t,e)=>Object.prototype.hasOwnProperty.call(t,e))(e,n))&&e[n]===t)))(t,e);class Gp{constructor(t,e,n,r){this.left=t,this.right=e,this.index=n,this.currentAttributes=r}forward(){switch(null===this.right&&Ru(),this.right.content.constructor){case yf:case kf:this.right.deleted||(this.index+=this.right.length);break;case wf:this.right.deleted||Zp(this.currentAttributes,this.right.content)}this.left=this.right,this.right=this.right.right}}const Yp=(t,e,n)=>{for(;null!==e.right&&n>0;){switch(e.right.content.constructor){case yf:case kf:e.right.deleted||(n<e.right.length&&hp(t,Zd(e.right.id.client,e.right.id.clock+n)),e.index+=e.right.length,n-=e.right.length);break;case wf:e.right.deleted||Zp(e.currentAttributes,e.right.content)}e.left=e.right,e.right=e.right.right}return e},Xp=(t,e,n)=>{const r=new Map,o=xp(e,n);if(o){const e=new Gp(o.p.left,o.p,o.index,r);return Yp(t,e,n-o.index)}{const o=new Gp(null,e._start,0,r);return Yp(t,o,n)}},Qp=(t,e,n,r)=>{for(;null!==n.right&&(!0===n.right.deleted||n.right.content.constructor===wf&&Hp(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();const o=t.doc,i=o.clientID;let s=n.left;const c=n.right;r.forEach(((r,a)=>{s=new Df(Zd(i,ip(o.store,i)),s,s&&s.lastId,c,c&&c.id,e,null,new wf(a,r)),s.integrate(t,0),n.right=s}))},Zp=(t,e)=>{const{key:n,value:r}=e;null===r?t.delete(n):t.set(n,r)},tf=(t,e)=>{for(;null!==t.right&&(t.right.deleted||t.right.content.constructor===wf&&Hp(e[t.right.content.key]||null,t.right.content.value));)t.forward()},ef=(t,e,n,r)=>{const o=t.doc,i=o.clientID,s=new Map;for(const c in r){const a=r[c],l=n.currentAttributes.get(c)||null;if(!Hp(l,a)){s.set(c,l);const{left:r,right:h}=n;n.right=new Df(Zd(i,ip(o.store,i)),r,r&&r.lastId,h,h&&h.id,e,null,new wf(c,a)),n.right.integrate(t,0),n.forward()}}return s},nf=(t,e,n,r,o)=>{n.currentAttributes.forEach(((t,e)=>{void 0===o[e]&&(o[e]=null)}));const i=t.doc,s=i.clientID;tf(n,o);const c=ef(t,e,n,o),a=r.constructor===String?new kf(r):new yf(r);let{left:l,right:h,index:u}=n;e._searchMarker&&Mp(e._searchMarker,n.index,a.getLength()),h=new Df(Zd(s,ip(i.store,s)),l,l&&l.lastId,h,h&&h.id,e,null,a),h.integrate(t,0),n.right=h,n.index=u,n.forward(),Qp(t,e,n,c)},rf=(t,e,n,r,o)=>{const i=t.doc,s=i.clientID;tf(n,o);const c=ef(t,e,n,o);for(;r>0&&null!==n.right;){if(!n.right.deleted)switch(n.right.content.constructor){case wf:{const{key:e,value:r}=n.right.content,i=o[e];void 0!==i&&(Hp(i,r)?c.delete(e):c.set(e,r),n.right.delete(t));break}case yf:case kf:r<n.right.length&&hp(t,Zd(n.right.id.client,n.right.id.clock+r)),r-=n.right.length}n.forward()}if(r>0){let o="";for(;r>0;r--)o+="\n";n.right=new Df(Zd(s,ip(i.store,s)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,e,null,new kf(o)),n.right.integrate(t,0),n.forward()}Qp(t,e,n,c)},of=(t,e,n,r,o)=>{for(;n&&n.content.constructor!==kf&&n.content.constructor!==yf;)n.deleted||n.content.constructor!==wf||Zp(o,n.content),n=n.right;let i=0;for(;e!==n;){if(!e.deleted){const n=e.content;switch(n.constructor){case wf:{const{key:s,value:c}=n;(o.get(s)||null)===c&&(r.get(s)||null)!==c||(e.delete(t),i++);break}}}e=e.right}return i},sf=(t,e,n)=>{const r=n,o=du(e.currentAttributes),i=e.right;for(;n>0&&null!==e.right;){if(!1===e.right.deleted)switch(e.right.content.constructor){case yf:case kf:n<e.right.length&&hp(t,Zd(e.right.id.client,e.right.id.clock+n)),n-=e.right.length,e.right.delete(t)}e.forward()}i&&of(t,i,e.right,o,du(e.currentAttributes));const s=(e.left||e.right).parent;return s._searchMarker&&Mp(s._searchMarker,e.index,-r+n),e};class cf extends wp{constructor(t,e,n){super(t,e),this.childListChanged=!1,this.keysChanged=new Set,n.forEach((t=>{null===t?this.childListChanged=!0:this.keysChanged.add(t)}))}get changes(){if(null===this._changes){const t={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=t}return this._changes}get delta(){if(null===this._delta){const t=this.target.doc,e=[];yp(t,(t=>{const n=new Map,r=new Map;let o=this.target._start,i=null;const s={};let c="",a=0,l=0;const h=()=>{if(null!==i){let t;switch(i){case"delete":t={delete:l},l=0;break;case"insert":t={insert:c},n.size>0&&(t.attributes={},n.forEach(((e,n)=>{null!==e&&(t.attributes[n]=e)}))),c="";break;case"retain":if(t={retain:a},Object.keys(s).length>0){t.attributes={};for(const e in s)t.attributes[e]=s[e]}a=0}e.push(t),i=null}};for(;null!==o;){switch(o.content.constructor){case yf:this.adds(o)?this.deletes(o)||(h(),i="insert",c=o.content.embed,h()):this.deletes(o)?("delete"!==i&&(h(),i="delete"),l+=1):o.deleted||("retain"!==i&&(h(),i="retain"),a+=1);break;case kf:this.adds(o)?this.deletes(o)||("insert"!==i&&(h(),i="insert"),c+=o.content.str):this.deletes(o)?("delete"!==i&&(h(),i="delete"),l+=o.length):o.deleted||("retain"!==i&&(h(),i="retain"),a+=o.length);break;case wf:{const{key:e,value:c}=o.content;if(this.adds(o)){if(!this.deletes(o)){const a=n.get(e)||null;Hp(a,c)?o.delete(t):("retain"===i&&h(),Hp(c,r.get(e)||null)?delete s[e]:s[e]=c)}}else if(this.deletes(o)){r.set(e,c);const t=n.get(e)||null;Hp(t,c)||("retain"===i&&h(),s[e]=t)}else if(!o.deleted){r.set(e,c);const n=s[e];void 0!==n&&(Hp(n,c)?o.delete(t):("retain"===i&&h(),null===c?s[e]=c:delete s[e]))}o.deleted||("insert"===i&&h(),Zp(n,o.content));break}}o=o.right}for(h();e.length>0;){const t=e[e.length-1];if(void 0===t.retain||void 0!==t.attributes)break;e.pop()}})),this._delta=e}return this._delta}}class af extends Ep{constructor(t){super(),this._pending=void 0!==t?[()=>this.insert(0,t)]:[],this._searchMarker=[]}get length(){return this._length}_integrate(t,e){super._integrate(t,e);try{this._pending.forEach((t=>t()))}catch(t){console.error(t)}this._pending=null}_copy(){return new af}clone(){const t=new af;return t.applyDelta(this.toDelta()),t}_callObserver(t,e){super._callObserver(t,e);const n=new cf(this,t,e),r=t.doc;if(_p(this,t,n),!t.local){let e=!1;for(const[n,o]of t.afterState.entries()){const i=t.beforeState.get(n)||0;if(o!==i&&(dp(t,r.store.clients.get(n),i,o,(t=>{t.deleted||t.content.constructor!==wf||(e=!0)})),e))break}e||Bd(t,t.deleteSet,(t=>{t instanceof ff||e||t.parent===this&&t.content.constructor===wf&&(e=!0)})),yp(r,(t=>{e?(t=>{let e=0;yp(t.doc,(n=>{let r=t._start,o=t._start,i=uu();const s=du(i);for(;o;){if(!1===o.deleted)switch(o.content.constructor){case wf:Zp(s,o.content);break;case yf:case kf:e+=of(n,r,o,i,s),i=du(s),r=o}o=o.right}}))})(this):Bd(t,t.deleteSet,(e=>{e instanceof ff||e.parent===this&&((t,e)=>{for(;e&&e.right&&(e.right.deleted||e.right.content.constructor!==kf&&e.right.content.constructor!==yf);)e=e.right;const n=new Set;for(;e&&(e.deleted||e.content.constructor!==kf&&e.content.constructor!==yf);){if(!e.deleted&&e.content.constructor===wf){const r=e.content.key;n.has(r)?e.delete(t):n.add(r)}e=e.left}})(t,e)}))}))}}toString(){let t="",e=this._start;for(;null!==e;)!e.deleted&&e.countable&&e.content.constructor===kf&&(t+=e.content.str),e=e.right;return t}toJSON(){return this.toString()}applyDelta(t,{sanitize:e=!0}={}){null!==this.doc?yp(this.doc,(n=>{const r=new Gp(null,this._start,0,new Map);for(let o=0;o<t.length;o++){const i=t[o];if(void 0!==i.insert){const s=e||"string"!=typeof i.insert||o!==t.length-1||null!==r.right||"\n"!==i.insert.slice(-1)?i.insert:i.insert.slice(0,-1);("string"!=typeof s||s.length>0)&&nf(n,this,r,s,i.attributes||{})}else void 0!==i.retain?rf(n,this,r,i.retain,i.attributes||{}):void 0!==i.delete&&sf(n,r,i.delete)}})):this._pending.push((()=>this.applyDelta(t)))}toDelta(t,e,n){const r=[],o=new Map,i=this.doc;let s="",c=this._start;function a(){if(s.length>0){const t={};let e=!1;o.forEach(((n,r)=>{e=!0,t[r]=n}));const n={insert:s};e&&(n.attributes=t),r.push(n),s=""}}return yp(i,(i=>{for(t&&np(i,t),e&&np(i,e);null!==c;){if(ep(c,t)||void 0!==e&&ep(c,e))switch(c.content.constructor){case kf:{const r=o.get("ychange");void 0===t||ep(c,t)?void 0===e||ep(c,e)?void 0!==r&&(a(),o.delete("ychange")):void 0!==r&&r.user===c.id.client&&"added"===r.state||(a(),o.set("ychange",n?n("added",c.id):{type:"added"})):void 0!==r&&r.user===c.id.client&&"removed"===r.state||(a(),o.set("ychange",n?n("removed",c.id):{type:"removed"})),s+=c.content.str;break}case yf:{a();const t={insert:c.content.embed};if(o.size>0){const e={};t.attributes=e,o.forEach(((t,n)=>{e[n]=t}))}r.push(t);break}case wf:ep(c,t)&&(a(),Zp(o,c.content))}c=c.right}a()}),np),r}insert(t,e,n){if(e.length<=0)return;const r=this.doc;null!==r?yp(r,(r=>{const o=Xp(r,this,t);n||(n={},o.currentAttributes.forEach(((t,e)=>{n[e]=t}))),nf(r,this,o,e,n)})):this._pending.push((()=>this.insert(t,e,n)))}insertEmbed(t,e,n={}){if(e.constructor!==Object)throw new Error("Embed must be an Object");const r=this.doc;null!==r?yp(r,(r=>{const o=Xp(r,this,t);nf(r,this,o,e,n)})):this._pending.push((()=>this.insertEmbed(t,e,n)))}delete(t,e){if(0===e)return;const n=this.doc;null!==n?yp(n,(n=>{sf(n,Xp(n,this,t),e)})):this._pending.push((()=>this.delete(t,e)))}format(t,e,n){if(0===e)return;const r=this.doc;null!==r?yp(r,(r=>{const o=Xp(r,this,t);null!==o.right&&rf(r,this,o,e,n)})):this._pending.push((()=>this.format(t,e,n)))}removeAttribute(t){null!==this.doc?yp(this.doc,(e=>{Bp(e,this,t)})):this._pending.push((()=>this.removeAttribute(t)))}setAttribute(t,e){null!==this.doc?yp(this.doc,(n=>{Vp(n,this,t,e)})):this._pending.push((()=>this.setAttribute(t,e)))}getAttribute(t){return Fp(this,t)}getAttributes(t){return $p(this)}_write(t){t.writeTypeRef(xf)}}class lf{constructor(t,e=(()=>!0)){this._filter=e,this._root=t,this._currentNode=t._start,this._firstCall=!0}[Symbol.iterator](){return this}next(){let t=this._currentNode,e=t&&t.content&&t.content.type;if(null!==t&&(!this._firstCall||t.deleted||!this._filter(e)))do{if(e=t.content.type,t.deleted||e.constructor!==uf&&e.constructor!==hf||null===e._start)for(;null!==t;){if(null!==t.right){t=t.right;break}t=t.parent===this._root?null:t.parent._item}else t=e._start}while(null!==t&&(t.deleted||!this._filter(t.content.type)));return this._firstCall=!1,null===t?{value:void 0,done:!0}:(this._currentNode=t,{value:t.content.type,done:!1})}}class hf extends Ep{constructor(){super(),this._prelimContent=[]}get firstChild(){const t=this._first;return t?t.content.getContent()[0]:null}_integrate(t,e){super._integrate(t,e),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new hf}clone(){const t=new hf;return t.insert(0,t.toArray().map((t=>t instanceof Ep?t.clone():t))),t}get length(){return null===this._prelimContent?this._length:this._prelimContent.length}createTreeWalker(t){return new lf(this,t)}querySelector(t){t=t.toUpperCase();const e=new lf(this,(e=>e.nodeName&&e.nodeName.toUpperCase()===t)).next();return e.done?null:e.value}querySelectorAll(t){return t=t.toUpperCase(),Array.from(new lf(this,(e=>e.nodeName&&e.nodeName.toUpperCase()===t)))}_callObserver(t,e){_p(this,t,new df(this,e,t))}toString(){return Ap(this,(t=>t.toString())).join("")}toJSON(){return this.toString()}toDOM(t=document,e={},n){const r=t.createDocumentFragment();return void 0!==n&&n._createAssociation(r,this),Np(this,(o=>{r.insertBefore(o.toDOM(t,e,n),null)})),r}insert(t,e){null!==this.doc?yp(this.doc,(n=>{Pp(n,this,t,e)})):this._prelimContent.splice(t,0,...e)}insertAfter(t,e){if(null!==this.doc)yp(this.doc,(n=>{const r=t&&t instanceof Ep?t._item:t;Rp(n,this,r,e)}));else{const n=this._prelimContent,r=null===t?0:n.findIndex((e=>e===t))+1;if(0===r&&null!==t)throw Tu("Reference item not found");n.splice(r,0,...e)}}delete(t,e=1){null!==this.doc?yp(this.doc,(n=>{Lp(n,this,t,e)})):this._prelimContent.splice(t,e)}toArray(){return Dp(this)}push(t){this.insert(this.length,t)}unshift(t){this.insert(0,t)}get(t){return Ip(this,t)}slice(t=0,e=this.length){return Op(this,t,e)}_write(t){t.writeTypeRef(_f)}}class uf extends hf{constructor(t="UNDEFINED"){super(),this.nodeName=t,this._prelimAttrs=new Map}get nextSibling(){const t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){const t=this._item?this._item.prev:null;return t?t.content.type:null}_integrate(t,e){super._integrate(t,e),this._prelimAttrs.forEach(((t,e)=>{this.setAttribute(e,t)})),this._prelimAttrs=null}_copy(){return new uf(this.nodeName)}clone(){const t=new uf(this.nodeName),e=this.getAttributes();for(const n in e)t.setAttribute(n,e[n]);return t.insert(0,t.toArray().map((t=>t instanceof Ep?t.clone():t))),t}toString(){const t=this.getAttributes(),e=[],n=[];for(const e in t)n.push(e);n.sort();const r=n.length;for(let o=0;o<r;o++){const r=n[o];e.push(r+'="'+t[r]+'"')}const o=this.nodeName.toLocaleLowerCase();return`<${o}${e.length>0?" "+e.join(" "):""}>${super.toString()}</${o}>`}removeAttribute(t){null!==this.doc?yp(this.doc,(e=>{Bp(e,this,t)})):this._prelimAttrs.delete(t)}setAttribute(t,e){null!==this.doc?yp(this.doc,(n=>{Vp(n,this,t,e)})):this._prelimAttrs.set(t,e)}getAttribute(t){return Fp(this,t)}hasAttribute(t){return qp(this,t)}getAttributes(t){return $p(this)}toDOM(t=document,e={},n){const r=t.createElement(this.nodeName),o=this.getAttributes();for(const t in o)r.setAttribute(t,o[t]);return Np(this,(o=>{r.appendChild(o.toDOM(t,e,n))})),void 0!==n&&n._createAssociation(r,this),r}_write(t){t.writeTypeRef(Mf),t.writeKey(this.nodeName)}}class df extends wp{constructor(t,e,n){super(t,n),this.childListChanged=!1,this.attributesChanged=new Set,e.forEach((t=>{null===t?this.childListChanged=!0:this.attributesChanged.add(t)}))}}class pf{constructor(t,e){this.id=t,this.length=e}get deleted(){throw Iu()}mergeWith(t){return!1}write(t,e,n){throw Iu()}integrate(t,e){throw Iu()}}class ff extends pf{get deleted(){return!0}delete(){}mergeWith(t){return this.constructor===t.constructor&&(this.length+=t.length,!0)}integrate(t,e){e>0&&(this.id.clock+=e,this.length-=e),sp(t.doc.store,this)}write(t,e){t.writeInfo(0),t.writeLen(this.length-e)}getMissing(t,e){return null}}class gf{constructor(t){this.content=t}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new gf(this.content)}splice(t){throw Iu()}mergeWith(t){return!1}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeBuf(this.content)}getRef(){return 3}}class mf{constructor(t){this.len=t}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new mf(this.len)}splice(t){const e=new mf(this.len-t);return this.len=t,e}mergeWith(t){return this.len+=t.len,!0}integrate(t,e){$d(t.deleteSet,e.id.client,e.id.clock,this.len),e.markDeleted()}delete(t){}gc(t){}write(t,e){t.writeLen(this.len-e)}getRef(){return 1}}class vf{constructor(t){t._item&&console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid."),this.doc=t;const e={};this.opts=e,t.gc||(e.gc=!1),t.autoLoad&&(e.autoLoad=!0),null!==t.meta&&(e.meta=t.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new vf(this.doc)}splice(t){throw Iu()}mergeWith(t){return!1}integrate(t,e){this.doc._item=e,t.subdocsAdded.add(this.doc),this.doc.shouldLoad&&t.subdocsLoaded.add(this.doc)}delete(t){t.subdocsAdded.has(this.doc)?t.subdocsAdded.delete(this.doc):t.subdocsRemoved.add(this.doc)}gc(t){}write(t,e){t.writeString(this.doc.guid),t.writeAny(this.opts)}getRef(){return 9}}class yf{constructor(t){this.embed=t}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new yf(this.embed)}splice(t){throw Iu()}mergeWith(t){return!1}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeJSON(this.embed)}getRef(){return 5}}class wf{constructor(t,e){this.key=t,this.value=e}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new wf(this.key,this.value)}splice(t){throw Iu()}mergeWith(t){return!1}integrate(t,e){e.parent._searchMarker=null}delete(t){}gc(t){}write(t,e){t.writeKey(this.key),t.writeJSON(this.value)}getRef(){return 6}}class bf{constructor(t){this.arr=t}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new bf(this.arr)}splice(t){const e=new bf(this.arr.slice(t));return this.arr=this.arr.slice(0,t),e}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){const n=this.arr.length;t.writeLen(n-e);for(let r=e;r<n;r++){const e=this.arr[r];t.writeAny(e)}}getRef(){return 8}}class kf{constructor(t){this.str=t}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new kf(this.str)}splice(t){const e=new kf(this.str.slice(t));this.str=this.str.slice(0,t);const n=this.str.charCodeAt(t-1);return n>=55296&&n<=56319&&(this.str=this.str.slice(0,t-1)+"�",e.str="�"+e.str.slice(1)),e}mergeWith(t){return this.str+=t.str,!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeString(0===e?this.str:this.str.slice(e))}getRef(){return 4}}const Sf=0,Cf=1,xf=2,Mf=3,_f=4;class Ef{constructor(t){this.type=t}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new Ef(this.type._copy())}splice(t){throw Iu()}mergeWith(t){return!1}integrate(t,e){this.type._integrate(t.doc,e)}delete(t){let e=this.type._start;for(;null!==e;)e.deleted?t._mergeStructs.push(e):e.delete(t),e=e.right;this.type._map.forEach((e=>{e.deleted?t._mergeStructs.push(e):e.delete(t)})),t.changed.delete(this.type)}gc(t){let e=this.type._start;for(;null!==e;)e.gc(t,!0),e=e.right;this.type._start=null,this.type._map.forEach((e=>{for(;null!==e;)e.gc(t,!0),e=e.left})),this.type._map=new Map}write(t,e){this.type._write(t)}getRef(){return 7}}const Of=(t,e,n)=>{const{client:r,clock:o}=e.id,i=new Df(Zd(r,o+n),e,Zd(r,o+n-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(n));return e.deleted&&i.markDeleted(),e.keep&&(i.keep=!0),null!==e.redone&&(i.redone=Zd(e.redone.client,e.redone.clock+n)),e.right=i,null!==i.right&&(i.right.left=i),t._mergeStructs.push(i),null!==i.parentSub&&null===i.right&&i.parent._map.set(i.parentSub,i),e.length=n,i};class Df extends pf{constructor(t,e,n,r,o,i,s,c){super(t,c.getLength()),this.origin=n,this.left=e,this.right=r,this.rightOrigin=o,this.parent=i,this.parentSub=s,this.redone=null,this.content=c,this.info=this.content.isCountable()?2:0}set marker(t){(8&this.info)>0!==t&&(this.info^=8)}get marker(){return(8&this.info)>0}get keep(){return(1&this.info)>0}set keep(t){this.keep!==t&&(this.info^=1)}get countable(){return(2&this.info)>0}get deleted(){return(4&this.info)>0}set deleted(t){this.deleted!==t&&(this.info^=4)}markDeleted(){this.info|=4}getMissing(t,e){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=ip(e,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=ip(e,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===Xd&&this.id.client!==this.parent.client&&this.parent.clock>=ip(e,this.parent.client))return this.parent.client;if(this.origin&&(this.left=up(t,e,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=hp(t,this.rightOrigin),this.rightOrigin=this.right.id),(this.left&&this.left.constructor===ff||this.right&&this.right.constructor===ff)&&(this.parent=null),this.parent){if(this.parent.constructor===Xd){const t=ap(e,this.parent);t.constructor===ff?this.parent=null:this.parent=t.content.type}}else this.left&&this.left.constructor===Df&&(this.parent=this.left.parent,this.parentSub=this.left.parentSub),this.right&&this.right.constructor===Df&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);return null}integrate(t,e){if(e>0&&(this.id.clock+=e,this.left=up(t,t.doc.store,Zd(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(e),this.length-=e),this.parent){if(!this.left&&(!this.right||null!==this.right.left)||this.left&&this.left.right!==this.right){let e,n=this.left;if(null!==n)e=n.right;else if(null!==this.parentSub)for(e=this.parent._map.get(this.parentSub)||null;null!==e&&null!==e.left;)e=e.left;else e=this.parent._start;const r=new Set,o=new Set;for(;null!==e&&e!==this.right;){if(o.add(e),r.add(e),Qd(this.origin,e.origin)){if(e.id.client<this.id.client)n=e,r.clear();else if(Qd(this.rightOrigin,e.rightOrigin))break}else{if(null===e.origin||!o.has(ap(t.doc.store,e.origin)))break;r.has(ap(t.doc.store,e.origin))||(n=e,r.clear())}e=e.right}this.left=n}if(null!==this.left){const t=this.left.right;this.right=t,this.left.right=this}else{let t;if(null!==this.parentSub)for(t=this.parent._map.get(this.parentSub)||null;null!==t&&null!==t.left;)t=t.left;else t=this.parent._start,this.parent._start=this;this.right=t}null!==this.right?this.right.left=this:null!==this.parentSub&&(this.parent._map.set(this.parentSub,this),null!==this.left&&this.left.delete(t)),null===this.parentSub&&this.countable&&!this.deleted&&(this.parent._length+=this.length),sp(t.doc.store,this),this.content.integrate(t,this),gp(t,this.parent,this.parentSub),(null!==this.parent._item&&this.parent._item.deleted||null!==this.parentSub&&null!==this.right)&&this.delete(t)}else new ff(this.id,this.length).integrate(t,0)}get next(){let t=this.right;for(;null!==t&&t.deleted;)t=t.right;return t}get prev(){let t=this.left;for(;null!==t&&t.deleted;)t=t.left;return t}get lastId(){return 1===this.length?this.id:Zd(this.id.client,this.id.clock+this.length-1)}mergeWith(t){if(this.constructor===t.constructor&&Qd(t.origin,this.lastId)&&this.right===t&&Qd(this.rightOrigin,t.rightOrigin)&&this.id.client===t.id.client&&this.id.clock+this.length===t.id.clock&&this.deleted===t.deleted&&null===this.redone&&null===t.redone&&this.content.constructor===t.content.constructor&&this.content.mergeWith(t.content)){const e=this.parent._searchMarker;return e&&e.forEach((e=>{e.p===t&&(e.p=this,!this.deleted&&this.countable&&(e.index-=this.length))})),t.keep&&(this.keep=!0),this.right=t.right,null!==this.right&&(this.right.left=this),this.length+=t.length,!0}return!1}delete(t){if(!this.deleted){const e=this.parent;this.countable&&null===this.parentSub&&(e._length-=this.length),this.markDeleted(),$d(t.deleteSet,this.id.client,this.id.clock,this.length),gp(t,e,this.parentSub),this.content.delete(t)}}gc(t,e){if(!this.deleted)throw Ru();this.content.gc(t),e?((t,e,n)=>{const r=t.clients.get(e.id.client);r[cp(r,e.id.clock)]=n})(t,this,new ff(this.id,this.length)):this.content=new mf(this.length)}write(t,e){const n=e>0?Zd(this.id.client,this.id.clock+e-1):this.origin,r=this.rightOrigin,o=this.parentSub,i=31&this.content.getRef()|(null===n?0:ku)|(null===r?0:64)|(null===o?0:32);if(t.writeInfo(i),null!==n&&t.writeLeftID(n),null!==r&&t.writeRightID(r),null===n&&null===r){const e=this.parent;if(void 0!==e._item){const n=e._item;if(null===n){const n=(t=>{for(const[e,n]of t.doc.share.entries())if(n===t)return e;throw Ru()})(e);t.writeParentInfo(!0),t.writeString(n)}else t.writeParentInfo(!1),t.writeLeftID(n.id)}else e.constructor===String?(t.writeParentInfo(!0),t.writeString(e)):e.constructor===Xd?(t.writeParentInfo(!1),t.writeLeftID(e)):Ru();null!==o&&t.writeString(o)}this.content.write(t,e)}}const Nf=[()=>new Jp,()=>new Kp,()=>new af,t=>{Ou(t)},t=>{},t=>{Ou(t)},t=>{}],Af="GC",Tf="Item",If="Skip",Rf="ContentAny",zf="ContentBinary",Pf="ContentDeleted",Lf="ContentEmbed",Bf="ContentFormat",Vf="ContentJSON",Ff="ContentString",$f="ContentType",qf=[()=>{throw Ru()},function(t){return{type:Pf,length:Eu(t)}},function(t){const e=Eu(t),n=[];for(let r=0;r<e;r++){const e=Ou(t);"undefined"===e?n.push(void 0):n.push(JSON.parse(e))}return{type:Vf,content:n,length:e}},function(t){const e=Mu(t);return{type:zf,content:e,length:1}},function(t){const e=Ou(t);return{type:Ff,string:e,length:e.length}},function(t){const e=Ou(t);return{type:Lf,content:e,length:1}},function(t){const e=Ou(t),n=Ou(t);return{type:Bf,content:{key:e,value:n},length:1}},function(t){const e=Nf[Eu(t)](t);return{type:$f,content:e,length:1}},function(t){const e=Eu(t),n=[];for(let r=0;r<e;r++){const e=Au(t);n.push(e)}return{type:Rf,content:n,length:e}}],jf=qf;function Uf(t){return{client:Eu(t),clock:Eu(t)}}class Jf{constructor(t,e,n,r,o,i,s,c,a,l){this.type=t,this.client=e,this.clock=n,this.left=o,this.origin=i,this.right=s,this.rightOrigin=c,this.parentYKey=a,this.parent=l,Object.keys(r).forEach((t=>{this[t]=r[t]}))}}function Wf(t,e,n,r){const o=(r&ku)===ku?Uf(n):null,i=64==(64&r)?Uf(n):null,s=0==(192&r),c=!!s&&1===Eu(n),a=s&&c?Ou(n):null;let l=null;s&&!c&&(l=Uf(n)),s&&32==(32&r)&&Ou(n);const h=function(t,e){return jf[31&e](t)}(n,r);return new Jf(Tf,t,e,h,null,o,null,i,a,l)}const Kf=new et({nodes:(Hf=xo.spec.nodes,Gf="block",Hf.append({ordered_list:Ao(Oo,{content:"list_item+",group:Gf}),bullet_list:Ao(Do,{content:"list_item+",group:Gf}),list_item:Ao(No,{content:"paragraph block*"})})),marks:xo.spec.marks});var Hf,Gf;function Yf(t,e){const n=window.views.filter((function(t){return su.getState(t.state).id!==e}));console.log("update",function(t){return function(t){const e=function(t){const e={},n=Eu(t);for(let r=0;r<n;r++){const n=Eu(t),r=[];let{clock:o,client:i}=Uf(t);for(let e=0;e<n;e++){const e=_u(t);let n;const s=31&e;n=0===s?new Jf(Af,i,o,{length:Eu(t)}):10===s?new Jf(If,i,o,{length:Eu(t)}):Wf(i,o,t,e),r.push(n),o+=n.length}e[i]=r}return e}(t),n=function(t){t instanceof Cu||(t=xu(t));const e={clients:{}},n=Eu(t);for(let r=0;r<n;r++){const n=Eu(t),r=Eu(t);if(r>0){e.clients[n]=[];for(let o=0;o<r;o++)e.clients[n].push({clock:Eu(t),length:Eu(t)})}}return e}(t);return{clientsStructs:e,deleteSet:n}}(xu(t))}(t)),setTimeout((function(){n.forEach((function(e){const{xmlFragment:n}=su.getState(e.state);console.log("broadcast to",n.doc.clientID),Ba(n.doc,t,"remote")}))}),300)}function Xf(t,e){const n=new Na;n.clientID=Number(t.id.split("-")[1]),Ba(n,e);const r=n.get("prosemirror",mh),o=new ao(t,{state:ve.create({doc:Qf,yjs:{id:t.id,xmlFragment:r,onLocalUpdate:Yf,getView:()=>o},plugins:[...zs({schema:Kf}),su]})});return o}const Qf=rt.fromSchema(Kf).parse(document.querySelector("#content")),Zf=new Na,tg=Zf.get("prosemirror",mh);!function(t,e){console.assert("doc"===t.type.name),gl(e.doc,(function(){Zh(t.content,e)}),"local")}(Qf,tg);const eg=((t,e)=>Va(t,void 0,new Ra))(Zf);window.views=[Xf(document.getElementById("editor-1"),eg),Xf(document.getElementById("editor-2"),eg)]})();
  //# sourceMappingURL=bundle.js.map