index of
/
home
/
thefkyzp
/
hulmvisaadvisor.com
/
wp-content
/
plugins
/
surecart
/
dist
/
File: /home/thefkyzp/hulmvisaadvisor.com/wp-content/plugins/surecart/dist/2000.js
"use strict";(self.webpackChunk_surecart_surecart=self.webpackChunk_surecart_surecart||[]).push([[2e3],{2e3:function(e,t,n){n.r(t),n.d(t,{sc_rich_text:function(){return vc}});var r=n(5987),i=n(9062),o=n(4942),s=n(7326),a=n(885),c=n(1120);function u(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=(0,c.Z)(e)););return e}function l(){return l="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var r=u(e,t);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i.get?i.get.call(arguments.length<3?e:n):i.value}},l.apply(this,arguments)}var d=n(136),h=n(2963),f=n(2407),p=n(1002),v=n(5671),m=n(3144),g=n(8860),y=["start"];function k(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function w(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?k(Object(n),!0).forEach((function(t){(0,o.Z)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):k(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function b(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=(0,c.Z)(e);if(t){var i=(0,c.Z)(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return(0,h.Z)(this,n)}}function x(e){this.content=e}function M(e,t,n){for(var r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;var i=e.child(r),o=t.child(r);if(i!=o){if(!i.sameMarkup(o))return n;if(i.isText&&i.text!=o.text){for(var s=0;i.text[s]==o.text[s];s++)n++;return n}if(i.content.size||o.content.size){var a=M(i.content,o.content,n+1);if(null!=a)return a}n+=i.nodeSize}else n+=i.nodeSize}}function S(e,t,n,r){for(var i=e.childCount,o=t.childCount;;){if(0==i||0==o)return i==o?null:{a:n,b:r};var s=e.child(--i),a=t.child(--o),c=s.nodeSize;if(s!=a){if(!s.sameMarkup(a))return{a:n,b:r};if(s.isText&&s.text!=a.text){for(var u=0,l=Math.min(s.text.length,a.text.length);u<l&&s.text[s.text.length-u-1]==a.text[a.text.length-u-1];)u++,n--,r--;return{a:n,b:r}}if(s.content.size||a.content.size){var d=S(s.content,a.content,n-1,r-1);if(d)return d}n-=c,r-=c}else n-=c,r-=c}}x.prototype={constructor:x,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return-1==t?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),o=r.content.slice();return-1==i?o.push(n||e,t):(o[i+1]=t,n&&(o[i]=n)),new x(o)},remove:function(e){var t=this.find(e);if(-1==t)return this;var n=this.content.slice();return n.splice(t,2),new x(n)},addToStart:function(e,t){return new x([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new x(n)},addBefore:function(e,t,n){var r=this.remove(t),i=r.content.slice(),o=r.find(e);return i.splice(-1==o?i.length:o,0,t,n),new x(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return(e=x.from(e)).size?new x(e.content.concat(this.subtract(e).content)):this},append:function(e){return(e=x.from(e)).size?new x(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=x.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach((function(t,n){e[t]=n})),e},get size(){return this.content.length>>1}},x.from=function(e){if(e instanceof x)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new x(t)};var C=function(){function e(t,n){if((0,v.Z)(this,e),this.content=t,this.size=n||0,null==n)for(var r=0;r<t.length;r++)this.size+=t[r].nodeSize}return(0,m.Z)(e,[{key:"nodesBetween",value:function(e,t,n){for(var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4?arguments[4]:void 0,o=0,s=0;s<t;o++){var a=this.content[o],c=s+a.nodeSize;if(c>e&&!1!==n(a,r+s,i||null,o)&&a.content.size){var u=s+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,t-u),n,r+u)}s=c}}},{key:"descendants",value:function(e){this.nodesBetween(0,this.size,e)}},{key:"textBetween",value:function(e,t,n,r){var i="",o=!0;return this.nodesBetween(e,t,(function(s,a){s.isText?(i+=s.text.slice(Math.max(e,a)-a,t-a),o=!n):s.isLeaf?(r?i+="function"==typeof r?r(s):r:s.type.spec.leafText&&(i+=s.type.spec.leafText(s)),o=!n):!o&&s.isBlock&&(i+=n,o=!0)}),0),i}},{key:"append",value:function(t){if(!t.size)return this;if(!this.size)return t;var n=this.lastChild,r=t.firstChild,i=this.content.slice(),o=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),o=1);o<t.content.length;o++)i.push(t.content[o]);return new e(i,this.size+t.size)}},{key:"cut",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.size;if(0==t&&n==this.size)return this;var r=[],i=0;if(n>t)for(var o=0,s=0;s<n;o++){var a=this.content[o],c=s+a.nodeSize;c>t&&((s<t||c>n)&&(a=a.isText?a.cut(Math.max(0,t-s),Math.min(a.text.length,n-s)):a.cut(Math.max(0,t-s-1),Math.min(a.content.size,n-s-1))),r.push(a),i+=a.nodeSize),s=c}return new e(r,i)}},{key:"cutByIndex",value:function(t,n){return t==n?e.empty:0==t&&n==this.content.length?this:new e(this.content.slice(t,n))}},{key:"replaceChild",value:function(t,n){var r=this.content[t];if(r==n)return this;var i=this.content.slice(),o=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,o)}},{key:"addToStart",value:function(t){return new e([t].concat(this.content),this.size+t.nodeSize)}},{key:"addToEnd",value:function(t){return new e(this.content.concat(t),this.size+t.nodeSize)}},{key:"eq",value:function(e){if(this.content.length!=e.content.length)return!1;for(var t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}},{key:"firstChild",get:function(){return this.content.length?this.content[0]:null}},{key:"lastChild",get:function(){return this.content.length?this.content[this.content.length-1]:null}},{key:"childCount",get:function(){return this.content.length}},{key:"child",value:function(e){var t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}},{key:"maybeChild",value:function(e){return this.content[e]||null}},{key:"forEach",value:function(e){for(var t=0,n=0;t<this.content.length;t++){var r=this.content[t];e(r,n,t),n+=r.nodeSize}}},{key:"findDiffStart",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return M(this,e,t)}},{key:"findDiffEnd",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.size,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.size;return S(this,e,t,n)}},{key:"findIndex",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1;if(0==e)return T(0,e);if(e==this.size)return T(this.content.length,e);if(e>this.size||e<0)throw new RangeError("Position ".concat(e," outside of fragment (").concat(this,")"));for(var n=0,r=0;;n++){var i=this.child(n),o=r+i.nodeSize;if(o>=e)return o==e||t>0?T(n+1,o):T(n,r);r=o}}},{key:"toString",value:function(){return"<"+this.toStringInner()+">"}},{key:"toStringInner",value:function(){return this.content.join(", ")}},{key:"toJSON",value:function(){return this.content.length?this.content.map((function(e){return e.toJSON()})):null}}],[{key:"fromJSON",value:function(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new e(n.map(t.nodeFromJSON))}},{key:"fromArray",value:function(t){if(!t.length)return e.empty;for(var n,r=0,i=0;i<t.length;i++){var o=t[i];r+=o.nodeSize,i&&o.isText&&t[i-1].sameMarkup(o)?(n||(n=t.slice(0,i)),n[n.length-1]=o.withText(n[n.length-1].text+o.text)):n&&n.push(o)}return new e(n||t,r)}},{key:"from",value:function(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}]),e}();C.empty=new C([],0);var O={index:0,offset:0};function T(e,t){return O.index=e,O.offset=t,O}function N(e,t){if(e===t)return!0;if(!e||"object"!=(0,p.Z)(e)||!t||"object"!=(0,p.Z)(t))return!1;var n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(var r=0;r<e.length;r++)if(!N(e[r],t[r]))return!1}else{for(var i in e)if(!(i in t)||!N(e[i],t[i]))return!1;for(var o in t)if(!(o in e))return!1}return!0}var E=function(){function e(t,n){(0,v.Z)(this,e),this.type=t,this.attrs=n}return(0,m.Z)(e,[{key:"addToSet",value:function(e){for(var t,n=!1,r=0;r<e.length;r++){var i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||(t=e.slice(0,r));else{if(i.type.excludes(this.type))return e;!n&&i.type.rank>this.type.rank&&(t||(t=e.slice(0,r)),t.push(this),n=!0),t&&t.push(i)}}return t||(t=e.slice()),n||t.push(this),t}},{key:"removeFromSet",value:function(e){for(var t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}},{key:"isInSet",value:function(e){for(var t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}},{key:"eq",value:function(e){return this==e||this.type==e.type&&N(this.attrs,e.attrs)}},{key:"toJSON",value:function(){var e={type:this.type.name};for(var t in this.attrs){e.attrs=this.attrs;break}return e}}],[{key:"fromJSON",value:function(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");var n=e.marks[t.type];if(!n)throw new RangeError("There is no mark type ".concat(t.type," in this schema"));return n.create(t.attrs)}},{key:"sameSet",value:function(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(var n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}},{key:"setFrom",value:function(t){if(!t||Array.isArray(t)&&0==t.length)return e.none;if(t instanceof e)return[t];var n=t.slice();return n.sort((function(e,t){return e.type.rank-t.type.rank})),n}}]),e}();E.none=[];var A=function(e){(0,d.Z)(n,e);var t=b(n);function n(){return(0,v.Z)(this,n),t.apply(this,arguments)}return(0,m.Z)(n)}((0,f.Z)(Error)),D=function(){function e(t,n,r){(0,v.Z)(this,e),this.content=t,this.openStart=n,this.openEnd=r}return(0,m.Z)(e,[{key:"size",get:function(){return this.content.size-this.openStart-this.openEnd}},{key:"insertAt",value:function(t,n){var r=I(this.content,t+this.openStart,n);return r&&new e(r,this.openStart,this.openEnd)}},{key:"removeBetween",value:function(t,n){return new e(P(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}},{key:"eq",value:function(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}},{key:"toString",value:function(){return this.content+"("+this.openStart+","+this.openEnd+")"}},{key:"toJSON",value:function(){if(!this.content.size)return null;var e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}}],[{key:"fromJSON",value:function(t,n){if(!n)return e.empty;var r=n.openStart||0,i=n.openEnd||0;if("number"!=typeof r||"number"!=typeof i)throw new RangeError("Invalid input for Slice.fromJSON");return new e(C.fromJSON(t,n.content),r,i)}},{key:"maxOpen",value:function(t){for(var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=0,i=0,o=t.firstChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.firstChild)r++;for(var _n=t.lastChild;_n&&!_n.isLeaf&&(n||!_n.type.spec.isolating);_n=_n.lastChild)i++;return new e(t,r,i)}}]),e}();function P(e,t,n){var r=e.findIndex(t),i=r.index,o=r.offset,s=e.maybeChild(i),a=e.findIndex(n),c=a.index,u=a.offset;if(o==t||s.isText){if(u!=n&&!e.child(c).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(n))}if(i!=c)throw new RangeError("Removing non-flat range");return e.replaceChild(i,s.copy(P(s.content,t-o-1,n-o-1)))}function I(e,t,n,r){var i=e.findIndex(t),o=i.index,s=i.offset,a=e.maybeChild(o);if(s==t||a.isText)return r&&!r.canReplace(o,o,n)?null:e.cut(0,t).append(n).append(e.cut(t));var c=I(a.content,t-s-1,n);return c&&e.replaceChild(o,a.copy(c))}function R(e,t,n){if(n.openStart>e.depth)throw new A("Inserted content deeper than insertion position");if(e.depth-n.openStart!=t.depth-n.openEnd)throw new A("Inconsistent open depths");return z(e,t,n,0)}function z(e,t,n,r){var i=e.index(r),o=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){var s=z(e,t,n,r+1);return o.copy(o.content.replaceChild(i,s))}if(n.content.size){if(n.openStart||n.openEnd||e.depth!=r||t.depth!=r){var a=function(e,t){for(var n=t.depth-e.openStart,r=t.node(n).copy(e.content),i=n-1;i>=0;i--)r=t.node(i).copy(C.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}(n,e);return F(o,V(e,a.start,a.end,t,r))}var c=e.parent,u=c.content;return F(c,u.cut(0,e.parentOffset).append(n.content).append(u.cut(t.parentOffset)))}return F(o,j(e,t,r))}function B(e,t){if(!t.type.compatibleContent(e.type))throw new A("Cannot join "+t.type.name+" onto "+e.type.name)}function Z(e,t,n){var r=e.node(n);return B(r,t.node(n)),r}function L(e,t){var n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function $(e,t,n,r){var i=(t||e).node(n),o=0,s=t?t.index(n):i.childCount;e&&(o=e.index(n),e.depth>n?o++:e.textOffset&&(L(e.nodeAfter,r),o++));for(var a=o;a<s;a++)L(i.child(a),r);t&&t.depth==n&&t.textOffset&&L(t.nodeBefore,r)}function F(e,t){return e.type.checkContent(t),e.copy(t)}function V(e,t,n,r,i){var o=e.depth>i&&Z(e,t,i+1),s=r.depth>i&&Z(n,r,i+1),a=[];return $(null,e,i,a),o&&s&&t.index(i)==n.index(i)?(B(o,s),L(F(o,V(e,t,n,r,i+1)),a)):(o&&L(F(o,j(e,t,i+1)),a),$(t,n,i,a),s&&L(F(s,j(n,r,i+1)),a)),$(r,null,i,a),new C(a)}function j(e,t,n){var r=[];return $(null,e,n,r),e.depth>n&&L(F(Z(e,t,n+1),j(e,t,n+1)),r),$(t,null,n,r),new C(r)}D.empty=new D(C.empty,0,0);var H=function(){function e(t,n,r){(0,v.Z)(this,e),this.pos=t,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}return(0,m.Z)(e,[{key:"resolveDepth",value:function(e){return null==e?this.depth:e<0?this.depth+e:e}},{key:"parent",get:function(){return this.node(this.depth)}},{key:"doc",get:function(){return this.node(0)}},{key:"node",value:function(e){return this.path[3*this.resolveDepth(e)]}},{key:"index",value:function(e){return this.path[3*this.resolveDepth(e)+1]}},{key:"indexAfter",value:function(e){return e=this.resolveDepth(e),this.index(e)+(e!=this.depth||this.textOffset?1:0)}},{key:"start",value:function(e){return 0==(e=this.resolveDepth(e))?0:this.path[3*e-1]+1}},{key:"end",value:function(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}},{key:"before",value:function(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]}},{key:"after",value:function(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]+this.path[3*e].nodeSize}},{key:"textOffset",get:function(){return this.pos-this.path[this.path.length-1]}},{key:"nodeAfter",get:function(){var e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;var n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}},{key:"nodeBefore",get:function(){var e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):0==e?null:this.parent.child(e-1)}},{key:"posAtIndex",value:function(e,t){t=this.resolveDepth(t);for(var n=this.path[3*t],r=0==t?0:this.path[3*t-1]+1,i=0;i<e;i++)r+=n.child(i).nodeSize;return r}},{key:"marks",value:function(){var e=this.parent,t=this.index();if(0==e.content.size)return E.none;if(this.textOffset)return e.child(t).marks;var n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){var i=n;n=r,r=i}for(var o=n.marks,s=0;s<o.length;s++)!1!==o[s].type.spec.inclusive||r&&o[s].isInSet(r.marks)||(o=o[s--].removeFromSet(o));return o}},{key:"marksAcross",value:function(e){var t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;for(var n=t.marks,r=e.parent.maybeChild(e.index()),i=0;i<n.length;i++)!1!==n[i].type.spec.inclusive||r&&n[i].isInSet(r.marks)||(n=n[i--].removeFromSet(n));return n}},{key:"sharedDepth",value:function(e){for(var t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}},{key:"blockRange",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this,t=arguments.length>1?arguments[1]:void 0;if(e.pos<this.pos)return e.blockRange(this);for(var n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new K(this,e,n);return null}},{key:"sameParent",value:function(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}},{key:"max",value:function(e){return e.pos>this.pos?e:this}},{key:"min",value:function(e){return e.pos<this.pos?e:this}},{key:"toString",value:function(){for(var e="",t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}}],[{key:"resolve",value:function(t,n){if(!(n>=0&&n<=t.content.size))throw new RangeError("Position "+n+" out of range");for(var r=[],i=0,o=n,s=t;;){var a=s.content.findIndex(o),c=a.index,u=a.offset,l=o-u;if(r.push(s,c,i+u),!l)break;if((s=s.child(c)).isText)break;o=l-1,i+=u+1}return new e(n,r,o)}},{key:"resolveCached",value:function(t,n){for(var r=0;r<J.length;r++){var i=J[r];if(i.pos==n&&i.doc==t)return i}var o=J[q]=e.resolve(t,n);return q=(q+1)%W,o}}]),e}(),J=[],q=0,W=12,K=function(){function e(t,n,r){(0,v.Z)(this,e),this.$from=t,this.$to=n,this.depth=r}return(0,m.Z)(e,[{key:"start",get:function(){return this.$from.before(this.depth+1)}},{key:"end",get:function(){return this.$to.after(this.depth+1)}},{key:"parent",get:function(){return this.$from.node(this.depth)}},{key:"startIndex",get:function(){return this.$from.index(this.depth)}},{key:"endIndex",get:function(){return this.$to.indexAfter(this.depth)}}]),e}(),_=Object.create(null),U=function(){function e(t,n,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:E.none;(0,v.Z)(this,e),this.type=t,this.attrs=n,this.marks=i,this.content=r||C.empty}return(0,m.Z)(e,[{key:"nodeSize",get:function(){return this.isLeaf?1:2+this.content.size}},{key:"childCount",get:function(){return this.content.childCount}},{key:"child",value:function(e){return this.content.child(e)}},{key:"maybeChild",value:function(e){return this.content.maybeChild(e)}},{key:"forEach",value:function(e){this.content.forEach(e)}},{key:"nodesBetween",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;this.content.nodesBetween(e,t,n,r,this)}},{key:"descendants",value:function(e){this.nodesBetween(0,this.content.size,e)}},{key:"textContent",get:function(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}},{key:"textBetween",value:function(e,t,n,r){return this.content.textBetween(e,t,n,r)}},{key:"firstChild",get:function(){return this.content.firstChild}},{key:"lastChild",get:function(){return this.content.lastChild}},{key:"eq",value:function(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}},{key:"sameMarkup",value:function(e){return this.hasMarkup(e.type,e.attrs,e.marks)}},{key:"hasMarkup",value:function(e,t,n){return this.type==e&&N(this.attrs,t||e.defaultAttrs||_)&&E.sameSet(this.marks,n||E.none)}},{key:"copy",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}},{key:"mark",value:function(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}},{key:"cut",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.content.size;return 0==e&&t==this.content.size?this:this.copy(this.content.cut(e,t))}},{key:"slice",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.content.size,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(e==t)return D.empty;var r=this.resolve(e),i=this.resolve(t),o=n?0:r.sharedDepth(t),s=r.start(o),a=r.node(o),c=a.content.cut(r.pos-s,i.pos-s);return new D(c,r.depth-o,i.depth-o)}},{key:"replace",value:function(e,t,n){return R(this.resolve(e),this.resolve(t),n)}},{key:"nodeAt",value:function(e){for(var t=this;;){var n=t.content.findIndex(e),r=n.index,i=n.offset;if(!(t=t.maybeChild(r)))return null;if(i==e||t.isText)return t;e-=i+1}}},{key:"childAfter",value:function(e){var t=this.content.findIndex(e),n=t.index,r=t.offset;return{node:this.content.maybeChild(n),index:n,offset:r}}},{key:"childBefore",value:function(e){if(0==e)return{node:null,index:0,offset:0};var t=this.content.findIndex(e),n=t.index,r=t.offset;if(r<e)return{node:this.content.child(n),index:n,offset:r};var i=this.content.child(n-1);return{node:i,index:n-1,offset:r-i.nodeSize}}},{key:"resolve",value:function(e){return H.resolveCached(this,e)}},{key:"resolveNoCache",value:function(e){return H.resolve(this,e)}},{key:"rangeHasMark",value:function(e,t,n){var r=!1;return t>e&&this.nodesBetween(e,t,(function(e){return n.isInSet(e.marks)&&(r=!0),!r})),r}},{key:"isBlock",get:function(){return this.type.isBlock}},{key:"isTextblock",get:function(){return this.type.isTextblock}},{key:"inlineContent",get:function(){return this.type.inlineContent}},{key:"isInline",get:function(){return this.type.isInline}},{key:"isText",get:function(){return this.type.isText}},{key:"isLeaf",get:function(){return this.type.isLeaf}},{key:"isAtom",get:function(){return this.type.isAtom}},{key:"toString",value:function(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);var e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),X(this.marks,e)}},{key:"contentMatchAt",value:function(e){var t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}},{key:"canReplace",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:C.empty,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:n.childCount,o=this.contentMatchAt(e).matchFragment(n,r,i),s=o&&o.matchFragment(this.content,t);if(!s||!s.validEnd)return!1;for(var a=r;a<i;a++)if(!this.type.allowsMarks(n.child(a).marks))return!1;return!0}},{key:"canReplaceWith",value:function(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;var i=this.contentMatchAt(e).matchType(n),o=i&&i.matchFragment(this.content,t);return!!o&&o.validEnd}},{key:"canAppend",value:function(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}},{key:"check",value:function(){this.type.checkContent(this.content);for(var e=E.none,t=0;t<this.marks.length;t++)e=this.marks[t].addToSet(e);if(!E.sameSet(e,this.marks))throw new RangeError("Invalid collection of marks for node ".concat(this.type.name,": ").concat(this.marks.map((function(e){return e.type.name}))));this.content.forEach((function(e){return e.check()}))}},{key:"toJSON",value:function(){var e={type:this.type.name};for(var t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map((function(e){return e.toJSON()}))),e}}],[{key:"fromJSON",value:function(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");var n=null;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=t.marks.map(e.markFromJSON)}if("text"==t.type){if("string"!=typeof t.text)throw new RangeError("Invalid text node in JSON");return e.text(t.text,n)}var r=C.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,r,n)}}]),e}();U.prototype.text=void 0;var G=function(e){(0,d.Z)(n,e);var t=b(n);function n(e,r,i,o){var s;if((0,v.Z)(this,n),s=t.call(this,e,r,null,o),!i)throw new RangeError("Empty text nodes are not allowed");return s.text=i,s}return(0,m.Z)(n,[{key:"toString",value:function(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):X(this.marks,JSON.stringify(this.text))}},{key:"textContent",get:function(){return this.text}},{key:"textBetween",value:function(e,t){return this.text.slice(e,t)}},{key:"nodeSize",get:function(){return this.text.length}},{key:"mark",value:function(e){return e==this.marks?this:new n(this.type,this.attrs,this.text,e)}},{key:"withText",value:function(e){return e==this.text?this:new n(this.type,this.attrs,e,this.marks)}},{key:"cut",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.text.length;return 0==e&&t==this.text.length?this:this.withText(this.text.slice(e,t))}},{key:"eq",value:function(e){return this.sameMarkup(e)&&this.text==e.text}},{key:"toJSON",value:function(){var e=l((0,c.Z)(n.prototype),"toJSON",this).call(this);return e.text=this.text,e}}]),n}(U);function X(e,t){for(var n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}var Y=function(){function e(t){(0,v.Z)(this,e),this.validEnd=t,this.next=[],this.wrapCache=[]}return(0,m.Z)(e,[{key:"matchType",value:function(e){for(var t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}},{key:"matchFragment",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.childCount,r=this,i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}},{key:"inlineContent",get:function(){return 0!=this.next.length&&this.next[0].type.isInline}},{key:"defaultType",get:function(){for(var e=0;e<this.next.length;e++){var t=this.next[e].type;if(!t.isText&&!t.hasRequiredAttrs())return t}return null}},{key:"compatible",value:function(e){for(var t=0;t<this.next.length;t++)for(var n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}},{key:"fillBefore",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=[this];function i(o,s){var a=o.matchFragment(e,n);if(a&&(!t||a.validEnd))return C.from(s.map((function(e){return e.createAndFill()})));for(var c=0;c<o.next.length;c++){var u=o.next[c],l=u.type,d=u.next;if(!l.isText&&!l.hasRequiredAttrs()&&-1==r.indexOf(d)){r.push(d);var h=i(d,s.concat(l));if(h)return h}}return null}return i(this,[])}},{key:"findWrapping",value:function(e){for(var t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];var n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}},{key:"computeWrapping",value:function(e){for(var t=Object.create(null),n=[{match:this,type:null,via:null}];n.length;){var r=n.shift(),i=r.match;if(i.matchType(e)){for(var o=[],s=r;s.type;s=s.via)o.push(s.type);return o.reverse()}for(var a=0;a<i.next.length;a++){var c=i.next[a],u=c.type,l=c.next;u.isLeaf||u.hasRequiredAttrs()||u.name in t||r.type&&!l.validEnd||(n.push({match:u.contentMatch,type:u,via:r}),t[u.name]=!0)}}return null}},{key:"edgeCount",get:function(){return this.next.length}},{key:"edge",value:function(e){if(e>=this.next.length)throw new RangeError("There's no ".concat(e,"th edge in this content match"));return this.next[e]}},{key:"toString",value:function(){var e=[];return function t(n){e.push(n);for(var r=0;r<n.next.length;r++)-1==e.indexOf(n.next[r].next)&&t(n.next[r].next)}(this),e.map((function(t,n){for(var r=n+(t.validEnd?"*":" ")+" ",i=0;i<t.next.length;i++)r+=(i?", ":"")+t.next[i].type.name+"->"+e.indexOf(t.next[i].next);return r})).join("\n")}}],[{key:"parse",value:function(t,n){var r=new Q(t,n);if(null==r.next)return e.empty;var i=ee(r);r.next&&r.err("Unexpected trailing text");var o=ae(function(e){var t=[[]];return i(function e(t,o){if("choice"==t.type)return t.exprs.reduce((function(t,n){return t.concat(e(n,o))}),[]);if("seq"!=t.type){if("star"==t.type){var s=n();return r(o,s),i(e(t.expr,s),s),[r(s)]}if("plus"==t.type){var a=n();return i(e(t.expr,o),a),i(e(t.expr,a),a),[r(a)]}if("opt"==t.type)return[r(o)].concat(e(t.expr,o));if("range"==t.type){for(var c=o,u=0;u<t.min;u++){var l=n();i(e(t.expr,c),l),c=l}if(-1==t.max)i(e(t.expr,c),c);else for(var d=t.min;d<t.max;d++){var h=n();r(c,h),i(e(t.expr,c),h),c=h}return[r(c)]}if("name"==t.type)return[r(o,void 0,t.value)];throw new Error("Unknown expr type")}for(var f=0;;f++){var p=e(t.exprs[f],o);if(f==t.exprs.length-1)return p;i(p,o=n())}}(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){var i={term:r,to:n};return t[e].push(i),i}function i(e,t){e.forEach((function(e){return e.to=t}))}}(i));return function(e,t){for(var n=0,r=[e];n<r.length;n++){for(var i=r[n],o=!i.validEnd,s=[],a=0;a<i.next.length;a++){var c=i.next[a],u=c.type,l=c.next;s.push(u.name),!o||u.isText||u.hasRequiredAttrs()||(o=!1),-1==r.indexOf(l)&&r.push(l)}o&&t.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(o,r),o}}]),e}();Y.empty=new Y(!0);var Q=function(){function e(t,n){(0,v.Z)(this,e),this.string=t,this.nodeTypes=n,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()}return(0,m.Z)(e,[{key:"next",get:function(){return this.tokens[this.pos]}},{key:"eat",value:function(e){return this.next==e&&(this.pos++||!0)}},{key:"err",value:function(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}]),e}();function ee(e){var t=[];do{t.push(te(e))}while(e.eat("|"));return 1==t.length?t[0]:{type:"choice",exprs:t}}function te(e){var t=[];do{t.push(ne(e))}while(e.next&&")"!=e.next&&"|"!=e.next);return 1==t.length?t[0]:{type:"seq",exprs:t}}function ne(e){for(var t=function(e){if(e.eat("(")){var t=ee(e);return e.eat(")")||e.err("Missing closing paren"),t}if(!/\W/.test(e.next)){var n=function(e,t){var n=e.nodeTypes,r=n[t];if(r)return[r];var i=[];for(var o in n){var s=n[o];s.groups.indexOf(t)>-1&&i.push(s)}return 0==i.length&&e.err("No node type or group '"+t+"' found"),i}(e,e.next).map((function(t){return null==e.inline?e.inline=t.isInline:e.inline!=t.isInline&&e.err("Mixing inline and block content"),{type:"name",value:t}}));return e.pos++,1==n.length?n[0]:{type:"choice",exprs:n}}e.err("Unexpected token '"+e.next+"'")}(e);;)if(e.eat("+"))t={type:"plus",expr:t};else if(e.eat("*"))t={type:"star",expr:t};else if(e.eat("?"))t={type:"opt",expr:t};else{if(!e.eat("{"))break;t=ie(e,t)}return t}function re(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");var t=Number(e.next);return e.pos++,t}function ie(e,t){var n=re(e),r=n;return e.eat(",")&&(r="}"!=e.next?re(e):-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:t}}function oe(e,t){return t-e}function se(e,t){var n=[];return function t(r){var i=e[r];if(1==i.length&&!i[0].term)return t(i[0].to);n.push(r);for(var o=0;o<i.length;o++){var s=i[o],a=s.term,c=s.to;a||-1!=n.indexOf(c)||t(c)}}(t),n.sort(oe)}function ae(e){var t=Object.create(null);return function n(r){var i=[];r.forEach((function(t){e[t].forEach((function(t){var n=t.term,r=t.to;if(n){for(var o,s=0;s<i.length;s++)i[s][0]==n&&(o=i[s][1]);se(e,r).forEach((function(e){o||i.push([n,o=[]]),-1==o.indexOf(e)&&o.push(e)}))}}))}));for(var o=t[r.join(",")]=new Y(r.indexOf(e.length-1)>-1),s=0;s<i.length;s++){var a=i[s][1].sort(oe);o.next.push({type:i[s][0],next:t[a.join(",")]||n(a)})}return o}(se(e,0))}function ce(e){var t=Object.create(null);for(var n in e){var r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function ue(e,t){var n=Object.create(null);for(var r in e){var i=t&&t[r];if(void 0===i){var o=e[r];if(!o.hasDefault)throw new RangeError("No value supplied for attribute "+r);i=o.default}n[r]=i}return n}function le(e){var t=Object.create(null);if(e)for(var n in e)t[n]=new he(e[n]);return t}var de=function(){function e(t,n,r){(0,v.Z)(this,e),this.name=t,this.schema=n,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=le(r.attrs),this.defaultAttrs=ce(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||"text"==t),this.isText="text"==t}return(0,m.Z)(e,[{key:"isInline",get:function(){return!this.isBlock}},{key:"isTextblock",get:function(){return this.isBlock&&this.inlineContent}},{key:"isLeaf",get:function(){return this.contentMatch==Y.empty}},{key:"isAtom",get:function(){return this.isLeaf||!!this.spec.atom}},{key:"whitespace",get:function(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}},{key:"hasRequiredAttrs",value:function(){for(var e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}},{key:"compatibleContent",value:function(e){return this==e||this.contentMatch.compatible(e.contentMatch)}},{key:"computeAttrs",value:function(e){return!e&&this.defaultAttrs?this.defaultAttrs:ue(this.attrs,e)}},{key:"create",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0;if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new U(this,this.computeAttrs(e),C.from(t),E.setFrom(n))}},{key:"createChecked",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0;return t=C.from(t),this.checkContent(t),new U(this,this.computeAttrs(e),t,E.setFrom(n))}},{key:"createAndFill",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0;if(e=this.computeAttrs(e),(t=C.from(t)).size){var r=this.contentMatch.fillBefore(t);if(!r)return null;t=r.append(t)}var i=this.contentMatch.matchFragment(t),o=i&&i.fillBefore(C.empty,!0);return o?new U(this,e,t.append(o),E.setFrom(n)):null}},{key:"validContent",value:function(e){var t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(var n=0;n<e.childCount;n++)if(!this.allowsMarks(e.child(n).marks))return!1;return!0}},{key:"checkContent",value:function(e){if(!this.validContent(e))throw new RangeError("Invalid content for node ".concat(this.name,": ").concat(e.toString().slice(0,50)))}},{key:"allowsMarkType",value:function(e){return null==this.markSet||this.markSet.indexOf(e)>-1}},{key:"allowsMarks",value:function(e){if(null==this.markSet)return!0;for(var t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}},{key:"allowedMarks",value:function(e){if(null==this.markSet)return e;for(var t,n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||(t=e.slice(0,n));return t?t.length?t:E.none:e}}],[{key:"compile",value:function(t,n){var r=Object.create(null);t.forEach((function(t,i){return r[t]=new e(t,n,i)}));var i=n.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(var o in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}}]),e}(),he=function(){function e(t){(0,v.Z)(this,e),this.hasDefault=Object.prototype.hasOwnProperty.call(t,"default"),this.default=t.default}return(0,m.Z)(e,[{key:"isRequired",get:function(){return!this.hasDefault}}]),e}(),fe=function(){function e(t,n,r,i){(0,v.Z)(this,e),this.name=t,this.rank=n,this.schema=r,this.spec=i,this.attrs=le(i.attrs),this.excluded=null;var o=ce(this.attrs);this.instance=o?new E(this,o):null}return(0,m.Z)(e,[{key:"create",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return!e&&this.instance?this.instance:new E(this,ue(this.attrs,e))}},{key:"removeFromSet",value:function(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}},{key:"isInSet",value:function(e){for(var t=0;t<e.length;t++)if(e[t].type==this)return e[t]}},{key:"excludes",value:function(e){return this.excluded.indexOf(e)>-1}}],[{key:"compile",value:function(t,n){var r=Object.create(null),i=0;return t.forEach((function(t,o){return r[t]=new e(t,i++,n,o)})),r}}]),e}(),pe=function(){function e(t){(0,v.Z)(this,e),this.cached=Object.create(null);var n=this.spec={};for(var r in t)n[r]=t[r];n.nodes=x.from(t.nodes),n.marks=x.from(t.marks||{}),this.nodes=de.compile(this.spec.nodes,this),this.marks=fe.compile(this.spec.marks,this);var i=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 s=this.nodes[o],a=s.spec.content||"",c=s.spec.marks;s.contentMatch=i[a]||(i[a]=Y.parse(a,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.markSet="_"==c?null:c?ve(this,c.split(" ")):""!=c&&s.inlineContent?null:[]}for(var u in this.marks){var l=this.marks[u],d=l.spec.excludes;l.excluded=null==d?[l]:""==d?[]:ve(this,d.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}return(0,m.Z)(e,[{key:"node",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2?arguments[2]:void 0,r=arguments.length>3?arguments[3]:void 0;if("string"==typeof e)e=this.nodeType(e);else{if(!(e instanceof de))throw new RangeError("Invalid node type: "+e);if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}return e.createChecked(t,n,r)}},{key:"text",value:function(e,t){var n=this.nodes.text;return new G(n,n.defaultAttrs,e,E.setFrom(t))}},{key:"mark",value:function(e,t){return"string"==typeof e&&(e=this.marks[e]),e.create(t)}},{key:"nodeFromJSON",value:function(e){return U.fromJSON(this,e)}},{key:"markFromJSON",value:function(e){return E.fromJSON(this,e)}},{key:"nodeType",value:function(e){var t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}]),e}();function ve(e,t){for(var n=[],r=0;r<t.length;r++){var i=t[r],o=e.marks[i],s=o;if(o)n.push(o);else for(var a in e.marks){var c=e.marks[a];("_"==i||c.spec.group&&c.spec.group.split(" ").indexOf(i)>-1)&&n.push(s=c)}if(!s)throw new SyntaxError("Unknown mark type: '"+t[r]+"'")}return n}var me=function(){function e(t,n){var r=this;(0,v.Z)(this,e),this.schema=t,this.rules=n,this.tags=[],this.styles=[],n.forEach((function(e){e.tag?r.tags.push(e):e.style&&r.styles.push(e)})),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)}))}return(0,m.Z)(e,[{key:"parse",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=new xe(this,t,!1);return n.addAll(e,t.from,t.to),n.finish()}},{key:"parseSlice",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=new xe(this,t,!0);return n.addAll(e,t.from,t.to),D.maxOpen(n.finish())}},{key:"matchTag",value:function(e,t,n){for(var r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){var i=this.tags[r];if(Me(e,i.tag)&&(void 0===i.namespace||e.namespaceURI==i.namespace)&&(!i.context||t.matchesContext(i.context))){if(i.getAttrs){var o=i.getAttrs(e);if(!1===o)continue;i.attrs=o||void 0}return i}}}},{key:"matchStyle",value:function(e,t,n,r){for(var i=r?this.styles.indexOf(r)+1:0;i<this.styles.length;i++){var o=this.styles[i],s=o.style;if(!(0!=s.indexOf(e)||o.context&&!n.matchesContext(o.context)||s.length>e.length&&(61!=s.charCodeAt(e.length)||s.slice(e.length+1)!=t))){if(o.getAttrs){var a=o.getAttrs(t);if(!1===a)continue;o.attrs=a||void 0}return o}}}}],[{key:"schemaRules",value:function(e){var t=[];function n(e){for(var n=null==e.priority?50:e.priority,r=0;r<t.length;r++){var i=t[r];if((null==i.priority?50:i.priority)<n)break}t.splice(r,0,e)}var r=function(t){var r=e.marks[t].spec.parseDOM;r&&r.forEach((function(e){n(e=Se(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)}))};for(var i in e.marks)r(i);var o=function(t){var r=e.nodes[t].spec.parseDOM;r&&r.forEach((function(e){n(e=Se(e)),e.node||e.ignore||e.mark||(e.node=t)}))};for(var s in e.nodes)o(s);return t}},{key:"fromSchema",value:function(t){return t.cached.domParser||(t.cached.domParser=new e(t,e.schemaRules(t)))}}]),e}(),ge={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},ye={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},ke={ol:!0,ul:!0};function we(e,t,n){return null!=t?(t?1:0)|("full"===t?2:0):e&&"pre"==e.whitespace?3:-5&n}var be=function(){function e(t,n,r,i,o,s,a){(0,v.Z)(this,e),this.type=t,this.attrs=n,this.marks=r,this.pendingMarks=i,this.solid=o,this.options=a,this.content=[],this.activeMarks=E.none,this.stashMarks=[],this.match=s||(4&a?null:t.contentMatch)}return(0,m.Z)(e,[{key:"findWrapping",value:function(e){if(!this.match){if(!this.type)return[];var t=this.type.contentMatch.fillBefore(C.from(e));if(!t){var n,r=this.type.contentMatch;return(n=r.findWrapping(e.type))?(this.match=r,n):null}this.match=this.type.contentMatch.matchFragment(t)}return this.match.findWrapping(e.type)}},{key:"finish",value:function(e){if(!(1&this.options)){var t,n=this.content[this.content.length-1];if(n&&n.isText&&(t=/[ \t\r\n\u000c]+$/.exec(n.text))){var r=n;n.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=r.withText(r.text.slice(0,r.text.length-t[0].length))}}var i=C.from(this.content);return!e&&this.match&&(i=i.append(this.match.fillBefore(C.empty,!0))),this.type?this.type.create(this.attrs,i,this.marks):i}},{key:"popFromStashMark",value:function(e){for(var t=this.stashMarks.length-1;t>=0;t--)if(e.eq(this.stashMarks[t]))return this.stashMarks.splice(t,1)[0]}},{key:"applyPending",value:function(e){for(var t=0,n=this.pendingMarks;t<n.length;t++){var r=n[t];(this.type?this.type.allowsMarkType(r.type):Ce(r.type,e))&&!r.isInSet(this.activeMarks)&&(this.activeMarks=r.addToSet(this.activeMarks),this.pendingMarks=r.removeFromSet(this.pendingMarks))}}},{key:"inlineContext",value:function(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!ge.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}]),e}(),xe=function(){function e(t,n,r){(0,v.Z)(this,e),this.parser=t,this.options=n,this.isOpen=r,this.open=0;var i,o=n.topNode,s=we(null,n.preserveWhitespace,0)|(r?4:0);i=o?new be(o.type,o.attrs,E.none,E.none,!0,n.topMatch||o.type.contentMatch,s):new be(r?null:t.schema.topNodeType,null,E.none,E.none,!0,null,s),this.nodes=[i],this.find=n.findPositions,this.needsBlock=!1}return(0,m.Z)(e,[{key:"top",get:function(){return this.nodes[this.open]}},{key:"addDOM",value:function(e){if(3==e.nodeType)this.addTextNode(e);else if(1==e.nodeType){var t=e.getAttribute("style");if(t){var n=this.readStyles(function(e){for(var t,n=/\s*([\w-]+)\s*:\s*([^;]+)/g,r=[];t=n.exec(e);)r.push(t[1],t[2].trim());return r}(t));if(!n)return;for(var r=(0,a.Z)(n,2),i=r[0],o=r[1],s=this.top,c=0;c<o.length;c++)this.removePendingMark(o[c],s);for(var u=0;u<i.length;u++)this.addPendingMark(i[u]);this.addElement(e);for(var l=0;l<i.length;l++)this.removePendingMark(i[l],s);for(var d=0;d<o.length;d++)this.addPendingMark(o[d])}else this.addElement(e)}}},{key:"addTextNode",value:function(e){var t=e.nodeValue,n=this.top;if(2&n.options||n.inlineContext(e)||/[^ \t\r\n\u000c]/.test(t)){if(1&n.options)t=2&n.options?t.replace(/\r\n?/g,"\n"):t.replace(/\r?\n|\r/g," ");else if(t=t.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(t)&&this.open==this.nodes.length-1){var r=n.content[n.content.length-1],i=e.previousSibling;(!r||i&&"BR"==i.nodeName||r.isText&&/[ \t\r\n\u000c]$/.test(r.text))&&(t=t.slice(1))}t&&this.insertNode(this.parser.schema.text(t)),this.findInText(e)}else this.findInside(e)}},{key:"addElement",value:function(e,t){var n,r=e.nodeName.toLowerCase();ke.hasOwnProperty(r)&&this.parser.normalizeLists&&function(e){for(var t=e.firstChild,n=null;t;t=t.nextSibling){var r=1==t.nodeType?t.nodeName.toLowerCase():null;r&&ke.hasOwnProperty(r)&&n?(n.appendChild(t),t=n):"li"==r?n=t:r&&(n=null)}}(e);var i=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(n=this.parser.matchTag(e,this,t));if(i?i.ignore:ye.hasOwnProperty(r))this.findInside(e),this.ignoreFallback(e);else if(!i||i.skip||i.closeParent){i&&i.closeParent?this.open=Math.max(0,this.open-1):i&&i.skip.nodeType&&(e=i.skip);var o,s=this.top,a=this.needsBlock;if(ge.hasOwnProperty(r))s.content.length&&s.content[0].isInline&&this.open&&(this.open--,s=this.top),o=!0,s.type||(this.needsBlock=!0);else if(!e.firstChild)return void this.leafFallback(e);this.addAll(e),o&&this.sync(s),this.needsBlock=a}else this.addElementByRule(e,i,!1===i.consuming?n:void 0)}},{key:"leafFallback",value:function(e){"BR"==e.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode("\n"))}},{key:"ignoreFallback",value:function(e){"BR"!=e.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"))}},{key:"readStyles",value:function(e){var t=this,n=E.none,r=E.none;e:for(var i=0;i<e.length;i+=2)for(var o=function(o){var a=t.parser.matchStyle(e[i],e[i+1],t,o);return a?a.ignore?(s=o,{v:null}):(a.clearMark?t.top.pendingMarks.forEach((function(e){a.clearMark(e)&&(r=e.addToSet(r))})):n=t.parser.schema.marks[a.mark].create(a.attrs).addToSet(n),!1!==a.consuming?(s=o,"break"):void(s=o=a)):(s=o,"continue|style")},s=void 0;;){var a=o(s);if("continue|style"===a)continue e;if("break"===a)break;if("object"===(0,p.Z)(a))return a.v}return[n,r]}},{key:"addElementByRule",value:function(e,t,n){var r,i,o,s=this;t.node?(i=this.parser.schema.nodes[t.node]).isLeaf?this.insertNode(i.create(t.attrs))||this.leafFallback(e):r=this.enter(i,t.attrs||null,t.preserveWhitespace):(o=this.parser.schema.marks[t.mark].create(t.attrs),this.addPendingMark(o));var a=this.top;if(i&&i.isLeaf)this.findInside(e);else if(n)this.addElement(e,n);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach((function(e){return s.insertNode(e)}));else{var c=e;"string"==typeof t.contentElement?c=e.querySelector(t.contentElement):"function"==typeof t.contentElement?c=t.contentElement(e):t.contentElement&&(c=t.contentElement),this.findAround(e,c,!0),this.addAll(c)}r&&this.sync(a)&&this.open--,o&&this.removePendingMark(o,a)}},{key:"addAll",value:function(e,t,n){for(var r=t||0,i=t?e.childNodes[t]:e.firstChild,o=null==n?null:e.childNodes[n];i!=o;i=i.nextSibling,++r)this.findAtPoint(e,r),this.addDOM(i);this.findAtPoint(e,r)}},{key:"findPlace",value:function(e){for(var t,n,r=this.open;r>=0;r--){var i=this.nodes[r],o=i.findWrapping(e);if(o&&(!t||t.length>o.length)&&(t=o,n=i,!o.length))break;if(i.solid)break}if(!t)return!1;this.sync(n);for(var s=0;s<t.length;s++)this.enterInner(t[s],null,!1);return!0}},{key:"insertNode",value:function(e){if(e.isInline&&this.needsBlock&&!this.top.type){var t=this.textblockFromContext();t&&this.enterInner(t)}if(this.findPlace(e)){this.closeExtra();var n=this.top;n.applyPending(e.type),n.match&&(n.match=n.match.matchType(e.type));for(var r=n.activeMarks,i=0;i<e.marks.length;i++)n.type&&!n.type.allowsMarkType(e.marks[i].type)||(r=e.marks[i].addToSet(r));return n.content.push(e.mark(r)),!0}return!1}},{key:"enter",value:function(e,t,n){var r=this.findPlace(e.create(t));return r&&this.enterInner(e,t,!0,n),r}},{key:"enterInner",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=arguments.length>3?arguments[3]:void 0;this.closeExtra();var i=this.top;i.applyPending(e),i.match=i.match&&i.match.matchType(e);var o=we(e,r,i.options);4&i.options&&0==i.content.length&&(o|=4),this.nodes.push(new be(e,t,i.activeMarks,i.pendingMarks,n,null,o)),this.open++}},{key:"closeExtra",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}},{key:"finish",value:function(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)}},{key:"sync",value:function(e){for(var t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;return!1}},{key:"currentPos",get:function(){this.closeExtra();for(var e=0,t=this.open;t>=0;t--){for(var n=this.nodes[t].content,r=n.length-1;r>=0;r--)e+=n[r].nodeSize;t&&e++}return e}},{key:"findAtPoint",value:function(e,t){if(this.find)for(var n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}},{key:"findInside",value:function(e){if(this.find)for(var t=0;t<this.find.length;t++)null==this.find[t].pos&&1==e.nodeType&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}},{key:"findAround",value:function(e,t,n){if(e!=t&&this.find)for(var r=0;r<this.find.length;r++)null==this.find[r].pos&&1==e.nodeType&&e.contains(this.find[r].node)&&t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}},{key:"findInText",value:function(e){if(this.find)for(var t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}},{key:"matchesContext",value:function(e){var t=this;if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);var n=e.split("/"),r=this.options.context,i=!(this.isOpen||r&&r.parent.type!=this.nodes[0].type),o=-(r?r.depth+1:0)+(i?0:1);return function e(s,a){for(;s>=0;s--){var c=n[s];if(""==c){if(s==n.length-1||0==s)continue;for(;a>=o;a--)if(e(s-1,a))return!0;return!1}var u=a>0||0==a&&i?t.nodes[a].type:r&&a>=o?r.node(a-o).type:null;if(!u||u.name!=c&&-1==u.groups.indexOf(c))return!1;a--}return!0}(n.length-1,this.open)}},{key:"textblockFromContext",value:function(){var e=this.options.context;if(e)for(var t=e.depth;t>=0;t--){var n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(var r in this.parser.schema.nodes){var i=this.parser.schema.nodes[r];if(i.isTextblock&&i.defaultAttrs)return i}}},{key:"addPendingMark",value:function(e){var t=function(e,t){for(var n=0;n<t.length;n++)if(e.eq(t[n]))return t[n]}(e,this.top.pendingMarks);t&&this.top.stashMarks.push(t),this.top.pendingMarks=e.addToSet(this.top.pendingMarks)}},{key:"removePendingMark",value:function(e,t){for(var n=this.open;n>=0;n--){var r=this.nodes[n];if(r.pendingMarks.lastIndexOf(e)>-1)r.pendingMarks=e.removeFromSet(r.pendingMarks);else{r.activeMarks=e.removeFromSet(r.activeMarks);var i=r.popFromStashMark(e);i&&r.type&&r.type.allowsMarkType(i.type)&&(r.activeMarks=i.addToSet(r.activeMarks))}if(r==t)break}}}]),e}();function Me(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function Se(e){var t={};for(var n in e)t[n]=e[n];return t}function Ce(e,t){var n=t.schema.nodes,r=function(r){var i=n[r];if(!i.allowsMarkType(e))return"continue";var o=[];return function e(n){o.push(n);for(var r=0;r<n.edgeCount;r++){var i=n.edge(r),s=i.type,a=i.next;if(s==t)return!0;if(o.indexOf(a)<0&&e(a))return!0}}(i.contentMatch)?{v:!0}:void 0};for(var i in n){var o=r(i);if("continue"!==o&&"object"===(0,p.Z)(o))return o.v}}var Oe=function(){function e(t,n){(0,v.Z)(this,e),this.nodes=t,this.marks=n}return(0,m.Z)(e,[{key:"serializeFragment",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2?arguments[2]:void 0;r||(r=Ne(n).createDocumentFragment());var i=r,o=[];return e.forEach((function(e){if(o.length||e.marks.length){for(var r=0,s=0;r<o.length&&s<e.marks.length;){var a=e.marks[s];if(t.marks[a.type.name]){if(!a.eq(o[r][0])||!1===a.type.spec.spanning)break;r++,s++}else s++}for(;r<o.length;)i=o.pop()[1];for(;s<e.marks.length;){var c=e.marks[s++],u=t.serializeMark(c,e.isInline,n);u&&(o.push([c,i]),i.appendChild(u.dom),i=u.contentDOM||u.dom)}}i.appendChild(t.serializeNodeInner(e,n))})),r}},{key:"serializeNodeInner",value:function(t,n){var r=e.renderSpec(Ne(n),this.nodes[t.type.name](t)),i=r.dom,o=r.contentDOM;if(o){if(t.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(t.content,n,o)}return i}},{key:"serializeNode",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.serializeNodeInner(e,t),r=e.marks.length-1;r>=0;r--){var i=this.serializeMark(e.marks[r],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}},{key:"serializeMark",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=this.marks[t.type.name];return i&&e.renderSpec(Ne(r),i(t,n))}}],[{key:"renderSpec",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if("string"==typeof n)return{dom:t.createTextNode(n)};if(null!=n.nodeType)return{dom:n};if(n.dom&&null!=n.dom.nodeType)return n;var i,o=n[0],s=o.indexOf(" ");s>0&&(r=o.slice(0,s),o=o.slice(s+1));var a=r?t.createElementNS(r,o):t.createElement(o),c=n[1],u=1;if(c&&"object"==(0,p.Z)(c)&&null==c.nodeType&&!Array.isArray(c))for(var l in u=2,c)if(null!=c[l]){var d=l.indexOf(" ");d>0?a.setAttributeNS(l.slice(0,d),l.slice(d+1),c[l]):a.setAttribute(l,c[l])}for(var h=u;h<n.length;h++){var f=n[h];if(0===f){if(h<n.length-1||h>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}var v=e.renderSpec(t,f,r),m=v.dom,g=v.contentDOM;if(a.appendChild(m),g){if(i)throw new RangeError("Multiple content holes");i=g}}return{dom:a,contentDOM:i}}},{key:"fromSchema",value:function(t){return t.cached.domSerializer||(t.cached.domSerializer=new e(this.nodesFromSchema(t),this.marksFromSchema(t)))}},{key:"nodesFromSchema",value:function(e){var t=Te(e.nodes);return t.text||(t.text=function(e){return e.text}),t}},{key:"marksFromSchema",value:function(e){return Te(e.marks)}}]),e}();function Te(e){var t={};for(var n in e){var r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function Ne(e){return e.document||window.document}var Ee=Math.pow(2,16);function Ae(e){return 65535&e}var De=function(){function e(t,n,r){(0,v.Z)(this,e),this.pos=t,this.delInfo=n,this.recover=r}return(0,m.Z)(e,[{key:"deleted",get:function(){return(8&this.delInfo)>0}},{key:"deletedBefore",get:function(){return(5&this.delInfo)>0}},{key:"deletedAfter",get:function(){return(6&this.delInfo)>0}},{key:"deletedAcross",get:function(){return(4&this.delInfo)>0}}]),e}(),Pe=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if((0,v.Z)(this,e),this.ranges=t,this.inverted=n,!t.length&&e.empty)return e.empty}return(0,m.Z)(e,[{key:"recover",value:function(e){var t=0,n=Ae(e);if(!this.inverted)for(var r=0;r<n;r++)t+=this.ranges[3*r+2]-this.ranges[3*r+1];return this.ranges[3*n]+t+function(e){return(e-(65535&e))/Ee}(e)}},{key:"mapResult",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return this._map(e,t,!1)}},{key:"map",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return this._map(e,t,!0)}},{key:"_map",value:function(e,t,n){for(var r=0,i=this.inverted?2:1,o=this.inverted?1:2,s=0;s<this.ranges.length;s+=3){var a=this.ranges[s]-(this.inverted?r:0);if(a>e)break;var c=this.ranges[s+i],u=this.ranges[s+o],l=a+c;if(e<=l){var d=a+r+((c?e==a?-1:e==l?1:t:t)<0?0:u);if(n)return d;var h=e==a?2:e==l?1:4;return(t<0?e!=a:e!=l)&&(h|=8),new De(d,h,e==(t<0?a:l)?null:s/3+(e-a)*Ee)}r+=u-c}return n?e+r:new De(e+r,0,null)}},{key:"touches",value:function(e,t){for(var n=0,r=Ae(t),i=this.inverted?2:1,o=this.inverted?1:2,s=0;s<this.ranges.length;s+=3){var a=this.ranges[s]-(this.inverted?n:0);if(a>e)break;var c=this.ranges[s+i];if(e<=a+c&&s==3*r)return!0;n+=this.ranges[s+o]-c}return!1}},{key:"forEach",value:function(e){for(var t=this.inverted?2:1,n=this.inverted?1:2,r=0,i=0;r<this.ranges.length;r+=3){var o=this.ranges[r],s=o-(this.inverted?i:0),a=o+(this.inverted?0:i),c=this.ranges[r+t],u=this.ranges[r+n];e(s,s+c,a,a+u),i+=u-c}}},{key:"invert",value:function(){return new e(this.ranges,!this.inverted)}},{key:"toString",value:function(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}}],[{key:"offset",value:function(t){return 0==t?e.empty:new e(t<0?[0,-t,0]:[0,0,t])}}]),e}();Pe.empty=new Pe([]);var Ie=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1?arguments[1]:void 0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:t.length;(0,v.Z)(this,e),this.maps=t,this.mirror=n,this.from=r,this.to=i}return(0,m.Z)(e,[{key:"slice",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.maps.length;return new e(this.maps,this.mirror,t,n)}},{key:"copy",value:function(){return new e(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)}},{key:"appendMap",value:function(e,t){this.to=this.maps.push(e),null!=t&&this.setMirror(this.maps.length-1,t)}},{key:"appendMapping",value:function(e){for(var t=0,n=this.maps.length;t<e.maps.length;t++){var r=e.getMirror(t);this.appendMap(e.maps[t],null!=r&&r<t?n+r:void 0)}}},{key:"getMirror",value:function(e){if(this.mirror)for(var t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}},{key:"setMirror",value:function(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}},{key:"appendMappingInverted",value:function(e){for(var t=e.maps.length-1,n=this.maps.length+e.maps.length;t>=0;t--){var r=e.getMirror(t);this.appendMap(e.maps[t].invert(),null!=r&&r>t?n-r-1:void 0)}}},{key:"invert",value:function(){var t=new e;return t.appendMappingInverted(this),t}},{key:"map",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(this.mirror)return this._map(e,t,!0);for(var n=this.from;n<this.to;n++)e=this.maps[n].map(e,t);return e}},{key:"mapResult",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return this._map(e,t,!1)}},{key:"_map",value:function(e,t,n){for(var r=0,i=this.from;i<this.to;i++){var o=this.maps[i].mapResult(e,t);if(null!=o.recover){var s=this.getMirror(i);if(null!=s&&s>i&&s<this.to){i=s,e=this.maps[s].recover(o.recover);continue}}r|=o.delInfo,e=o.pos}return n?e:new De(e,r,null)}}]),e}(),Re=Object.create(null),ze=function(){function e(){(0,v.Z)(this,e)}return(0,m.Z)(e,[{key:"getMap",value:function(){return Pe.empty}},{key:"merge",value:function(e){return null}}],[{key:"fromJSON",value:function(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");var n=Re[t.stepType];if(!n)throw new RangeError("No step type ".concat(t.stepType," defined"));return n.fromJSON(e,t)}},{key:"jsonID",value:function(e,t){if(e in Re)throw new RangeError("Duplicate use of step JSON ID "+e);return Re[e]=t,t.prototype.jsonID=e,t}}]),e}(),Be=function(){function e(t,n){(0,v.Z)(this,e),this.doc=t,this.failed=n}return(0,m.Z)(e,null,[{key:"ok",value:function(t){return new e(t,null)}},{key:"fail",value:function(t){return new e(null,t)}},{key:"fromReplace",value:function(t,n,r,i){try{return e.ok(t.replace(n,r,i))}catch(t){if(t instanceof A)return e.fail(t.message);throw t}}}]),e}();function Ze(e,t,n){for(var r=[],i=0;i<e.childCount;i++){var o=e.child(i);o.content.size&&(o=o.copy(Ze(o.content,t,o))),o.isInline&&(o=t(o,n,i)),r.push(o)}return C.fromArray(r)}var Le=function(e){(0,d.Z)(n,e);var t=b(n);function n(e,r,i){var o;return(0,v.Z)(this,n),(o=t.call(this)).from=e,o.to=r,o.mark=i,o}return(0,m.Z)(n,[{key:"apply",value:function(e){var t=this,n=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),o=new D(Ze(n.content,(function(e,n){return e.isAtom&&n.type.allowsMarkType(t.mark.type)?e.mark(t.mark.addToSet(e.marks)):e}),i),n.openStart,n.openEnd);return Be.fromReplace(e,this.from,this.to,o)}},{key:"invert",value:function(){return new $e(this.from,this.to,this.mark)}},{key:"map",value:function(e){var t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new n(t.pos,r.pos,this.mark)}},{key:"merge",value:function(e){return e instanceof n&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new n(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}},{key:"toJSON",value:function(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}}],[{key:"fromJSON",value:function(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new n(t.from,t.to,e.markFromJSON(t.mark))}}]),n}(ze);ze.jsonID("addMark",Le);var $e=function(e){(0,d.Z)(n,e);var t=b(n);function n(e,r,i){var o;return(0,v.Z)(this,n),(o=t.call(this)).from=e,o.to=r,o.mark=i,o}return(0,m.Z)(n,[{key:"apply",value:function(e){var t=this,n=e.slice(this.from,this.to),r=new D(Ze(n.content,(function(e){return e.mark(t.mark.removeFromSet(e.marks))}),e),n.openStart,n.openEnd);return Be.fromReplace(e,this.from,this.to,r)}},{key:"invert",value:function(){return new Le(this.from,this.to,this.mark)}},{key:"map",value:function(e){var t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new n(t.pos,r.pos,this.mark)}},{key:"merge",value:function(e){return e instanceof n&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new n(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}},{key:"toJSON",value:function(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}}],[{key:"fromJSON",value:function(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new n(t.from,t.to,e.markFromJSON(t.mark))}}]),n}(ze);ze.jsonID("removeMark",$e);var Fe=function(e){(0,d.Z)(n,e);var t=b(n);function n(e,r){var i;return(0,v.Z)(this,n),(i=t.call(this)).pos=e,i.mark=r,i}return(0,m.Z)(n,[{key:"apply",value:function(e){var t=e.nodeAt(this.pos);if(!t)return Be.fail("No node at mark step's position");var n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return Be.fromReplace(e,this.pos,this.pos+1,new D(C.from(n),0,t.isLeaf?0:1))}},{key:"invert",value:function(e){var t=e.nodeAt(this.pos);if(t){var r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(var i=0;i<t.marks.length;i++)if(!t.marks[i].isInSet(r))return new n(this.pos,t.marks[i]);return new n(this.pos,this.mark)}}return new Ve(this.pos,this.mark)}},{key:"map",value:function(e){var t=e.mapResult(this.pos,1);return t.deletedAfter?null:new n(t.pos,this.mark)}},{key:"toJSON",value:function(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}}],[{key:"fromJSON",value:function(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new n(t.pos,e.markFromJSON(t.mark))}}]),n}(ze);ze.jsonID("addNodeMark",Fe);var Ve=function(e){(0,d.Z)(n,e);var t=b(n);function n(e,r){var i;return(0,v.Z)(this,n),(i=t.call(this)).pos=e,i.mark=r,i}return(0,m.Z)(n,[{key:"apply",value:function(e){var t=e.nodeAt(this.pos);if(!t)return Be.fail("No node at mark step's position");var n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return Be.fromReplace(e,this.pos,this.pos+1,new D(C.from(n),0,t.isLeaf?0:1))}},{key:"invert",value:function(e){var t=e.nodeAt(this.pos);return t&&this.mark.isInSet(t.marks)?new Fe(this.pos,this.mark):this}},{key:"map",value:function(e){var t=e.mapResult(this.pos,1);return t.deletedAfter?null:new n(t.pos,this.mark)}},{key:"toJSON",value:function(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}}],[{key:"fromJSON",value:function(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new n(t.pos,e.markFromJSON(t.mark))}}]),n}(ze);ze.jsonID("removeNodeMark",Ve);var je=function(e){(0,d.Z)(n,e);var t=b(n);function n(e,r,i){var o,s=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return(0,v.Z)(this,n),(o=t.call(this)).from=e,o.to=r,o.slice=i,o.structure=s,o}return(0,m.Z)(n,[{key:"apply",value:function(e){return this.structure&&Je(e,this.from,this.to)?Be.fail("Structure replace would overwrite content"):Be.fromReplace(e,this.from,this.to,this.slice)}},{key:"getMap",value:function(){return new Pe([this.from,this.to-this.from,this.slice.size])}},{key:"invert",value:function(e){return new n(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}},{key:"map",value:function(e){var t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deletedAcross&&r.deletedAcross?null:new n(t.pos,Math.max(t.pos,r.pos),this.slice)}},{key:"merge",value:function(e){if(!(e instanceof n)||e.structure||this.structure)return null;if(this.from+this.slice.size!=e.from||this.slice.openEnd||e.slice.openStart){if(e.to!=this.from||this.slice.openStart||e.slice.openEnd)return null;var t=this.slice.size+e.slice.size==0?D.empty:new D(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new n(e.from,this.to,t,this.structure)}var r=this.slice.size+e.slice.size==0?D.empty:new D(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new n(this.from,this.to+(e.to-e.from),r,this.structure)}},{key:"toJSON",value:function(){var e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}}],[{key:"fromJSON",value:function(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new n(t.from,t.to,D.fromJSON(e,t.slice),!!t.structure)}}]),n}(ze);ze.jsonID("replace",je);var He=function(e){(0,d.Z)(n,e);var t=b(n);function n(e,r,i,o,s,a){var c,u=arguments.length>6&&void 0!==arguments[6]&&arguments[6];return(0,v.Z)(this,n),(c=t.call(this)).from=e,c.to=r,c.gapFrom=i,c.gapTo=o,c.slice=s,c.insert=a,c.structure=u,c}return(0,m.Z)(n,[{key:"apply",value:function(e){if(this.structure&&(Je(e,this.from,this.gapFrom)||Je(e,this.gapTo,this.to)))return Be.fail("Structure gap-replace would overwrite content");var t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return Be.fail("Gap is not a flat range");var n=this.slice.insertAt(this.insert,t.content);return n?Be.fromReplace(e,this.from,this.to,n):Be.fail("Content does not fit in gap")}},{key:"getMap",value:function(){return new Pe([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}},{key:"invert",value:function(e){var t=this.gapTo-this.gapFrom;return new n(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}},{key:"map",value:function(e){var t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=e.map(this.gapFrom,-1),o=e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||i<t.pos||o>r.pos?null:new n(t.pos,r.pos,i,o,this.slice,this.insert,this.structure)}},{key:"toJSON",value:function(){var e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}}],[{key:"fromJSON",value:function(e,t){if("number"!=typeof t.from||"number"!=typeof t.to||"number"!=typeof t.gapFrom||"number"!=typeof t.gapTo||"number"!=typeof t.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new n(t.from,t.to,t.gapFrom,t.gapTo,D.fromJSON(e,t.slice),t.insert,!!t.structure)}}]),n}(ze);function Je(e,t,n){for(var r=e.resolve(t),i=n-t,o=r.depth;i>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,i--;if(i>0)for(var s=r.node(o).maybeChild(r.indexAfter(o));i>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,i--}return!1}function qe(e,t,n){return(0==t||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function We(e){for(var t=e.parent.content.cutByIndex(e.startIndex,e.endIndex),n=e.depth;;--n){var r=e.$from.node(n),i=e.$from.index(n),o=e.$to.indexAfter(n);if(n<e.depth&&r.canReplace(i,o,t))return n;if(0==n||r.type.spec.isolating||!qe(r,i,o))break}return null}function Ke(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e,i=Ue(e,t),o=i&&Ge(r,t);return o?i.map(_e).concat({type:t,attrs:n}).concat(o.map(_e)):null}function _e(e){return{type:e,attrs:null}}function Ue(e,t){var n=e.parent,r=e.startIndex,i=e.endIndex,o=n.contentMatchAt(r).findWrapping(t);if(!o)return null;var s=o.length?o[0]:t;return n.canReplaceWith(r,i,s)?o:null}function Ge(e,t){var n=e.parent,r=e.startIndex,i=e.endIndex,o=n.child(r),s=t.contentMatch.findWrapping(o.type);if(!s)return null;for(var a=(s.length?s[s.length-1]:t).contentMatch,c=r;a&&c<i;c++)a=a.matchType(n.child(c).type);return a&&a.validEnd?s:null}function Xe(e,t,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");var o=e.steps.length;e.doc.nodesBetween(t,n,(function(t,n){if(t.isTextblock&&!t.hasMarkup(r,i)&&function(e,t,n){var r=e.resolve(t),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}(e.doc,e.mapping.slice(o).map(n),r)){e.clearIncompatible(e.mapping.slice(o).map(n,1),r);var s=e.mapping.slice(o),a=s.map(n,1),c=s.map(n+t.nodeSize,1);return e.step(new He(a,c,a+1,c-1,new D(C.from(r.create(i,null,t.marks)),0,0),1,!0)),!1}}))}function Ye(e,t,n,r,i){var o=e.doc.nodeAt(t);if(!o)throw new RangeError("No node at given position");n||(n=o.type);var s=n.create(r,null,i||o.marks);if(o.isLeaf)return e.replaceWith(t,t+o.nodeSize,s);if(!n.validContent(o.content))throw new RangeError("Invalid content for node type "+n.name);e.step(new He(t,t+o.nodeSize,t+1,t+o.nodeSize-1,new D(C.from(s),0,0),1,!0))}function Qe(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,r=arguments.length>3?arguments[3]:void 0,i=e.resolve(t),o=i.depth-n,s=r&&r[r.length-1]||i.parent;if(o<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!s.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(var a=i.depth-1,c=n-2;a>o;a--,c--){var u=i.node(a),l=i.index(a);if(u.type.spec.isolating)return!1;var d=u.content.cutByIndex(l,u.childCount),h=r&&r[c]||u;if(h!=u&&(d=d.replaceChild(0,h.type.create(h.attrs))),!u.canReplace(l+1,u.childCount)||!h.type.validContent(d))return!1}var f=i.indexAfter(o),p=r&&r[0];return i.node(o).canReplaceWith(f,f,p?p.type:i.node(o+1).type)}function et(e,t){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,r=arguments.length>3?arguments[3]:void 0,i=e.doc.resolve(t),o=C.empty,s=C.empty,a=i.depth,c=i.depth-n,u=n-1;a>c;a--,u--){o=C.from(i.node(a).copy(o));var l=r&&r[u];s=C.from(l?l.type.create(l.attrs,s):i.node(a).copy(s))}e.step(new je(t,t,new D(o.append(s),n,n),!0))}function tt(e,t){var n=e.resolve(t),r=n.index();return nt(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function nt(e,t){return!(!e||!t||e.isLeaf||!e.canAppend(t))}function rt(e,t){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1,r=e.resolve(t),i=r.depth;;i--){var o=void 0,s=void 0,a=r.index(i);if(i==r.depth?(o=r.nodeBefore,s=r.nodeAfter):n>0?(o=r.node(i+1),a++,s=r.node(i).maybeChild(a)):(o=r.node(i).maybeChild(a-1),s=r.node(i+1)),o&&!o.isTextblock&&nt(o,s)&&r.node(i).canReplace(a,a+1))return t;if(0==i)break;t=n<0?r.before(i):r.after(i)}}function it(e,t,n){var r=new je(t-n,t+n,D.empty,!0);e.step(r)}function ot(e,t,n){var r=e.resolve(t);if(!n.content.size)return t;for(var i=n.content,o=0;o<n.openStart;o++)i=i.firstChild.content;for(var s=1;s<=(0==n.openStart&&n.size?2:1);s++)for(var a=r.depth;a>=0;a--){var c=a==r.depth?0:r.pos<=(r.start(a+1)+r.end(a+1))/2?-1:1,u=r.index(a)+(c>0?1:0),l=r.node(a),d=!1;if(1==s)d=l.canReplace(u,u,i);else{var h=l.contentMatchAt(u).findWrapping(i.firstChild.type);d=h&&l.canReplaceWith(u,u,h[0])}if(d)return 0==c?r.pos:c<0?r.before(a+1):r.after(a+1)}return null}function st(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:D.empty;if(t==n&&!r.size)return null;var i=e.resolve(t),o=e.resolve(n);return at(i,o,r)?new je(t,n,r):new ct(i,o,r).fit()}function at(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}ze.jsonID("replaceAround",He);var ct=function(){function e(t,n,r){(0,v.Z)(this,e),this.$from=t,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=C.empty;for(var i=0;i<=t.depth;i++){var o=t.node(i);this.frontier.push({type:o.type,match:o.contentMatchAt(t.indexAfter(i))})}for(var s=t.depth;s>0;s--)this.placed=C.from(t.node(s).copy(this.placed))}return(0,m.Z)(e,[{key:"depth",get:function(){return this.frontier.length-1}},{key:"fit",value:function(){for(;this.unplaced.size;){var e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}var t=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(t<0?this.$to:r.doc.resolve(t));if(!i)return null;for(var o=this.placed,s=r.depth,a=i.depth;s&&a&&1==o.childCount;)o=o.firstChild.content,s--,a--;var c=new D(o,s,a);return t>-1?new He(r.pos,t,this.$to.pos,this.$to.end(),c,n):c.size||r.pos!=this.$to.pos?new je(r.pos,i.pos,c):null}},{key:"findFittable",value:function(){for(var e=this.unplaced.openStart,t=this.unplaced.content,n=0,r=this.unplaced.openEnd;n<e;n++){var i=t.firstChild;if(t.childCount>1&&(r=0),i.type.spec.isolating&&r<=n){e=n;break}t=i.content}for(var o=1;o<=2;o++)for(var s=1==o?e:this.unplaced.openStart;s>=0;s--)for(var a=null,c=(s?(a=dt(this.unplaced.content,s-1).firstChild).content:this.unplaced.content).firstChild,u=this.depth;u>=0;u--){var l=this.frontier[u],d=l.type,h=l.match,f=void 0,p=null;if(1==o&&(c?h.matchType(c.type)||(p=h.fillBefore(C.from(c),!1)):a&&d.compatibleContent(a.type)))return{sliceDepth:s,frontierDepth:u,parent:a,inject:p};if(2==o&&c&&(f=h.findWrapping(c.type)))return{sliceDepth:s,frontierDepth:u,parent:a,wrap:f};if(a&&h.matchType(a.type))break}}},{key:"openMore",value:function(){var e=this.unplaced,t=e.content,n=e.openStart,r=e.openEnd,i=dt(t,n);return!(!i.childCount||i.firstChild.isLeaf||(this.unplaced=new D(t,n+1,Math.max(r,i.size+n>=t.size-r?n+1:0)),0))}},{key:"dropNode",value:function(){var e=this.unplaced,t=e.content,n=e.openStart,r=e.openEnd,i=dt(t,n);if(i.childCount<=1&&n>0){var o=t.size-n<=n+i.size;this.unplaced=new D(ut(t,n-1,1),n-1,o?n-1:r)}else this.unplaced=new D(ut(t,n,1),n,r)}},{key:"placeNodes",value:function(e){for(var t=e.sliceDepth,n=e.frontierDepth,r=e.parent,i=e.inject,o=e.wrap;this.depth>n;)this.closeFrontierNode();if(o)for(var s=0;s<o.length;s++)this.openFrontierNode(o[s]);var a=this.unplaced,c=r?r.content:a.content,u=a.openStart-t,l=0,d=[],h=this.frontier[n],f=h.match,p=h.type;if(i){for(var v=0;v<i.childCount;v++)d.push(i.child(v));f=f.matchFragment(i)}for(var m=c.size+t-(a.content.size-a.openEnd);l<c.childCount;){var g=c.child(l),y=f.matchType(g.type);if(!y)break;(++l>1||0==u||g.content.size)&&(f=y,d.push(ht(g.mark(p.allowedMarks(g.marks)),1==l?u:0,l==c.childCount?m:-1)))}var k=l==c.childCount;k||(m=-1),this.placed=lt(this.placed,n,C.from(d)),this.frontier[n].match=f,k&&m<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(var w=0,b=c;w<m;w++){var x=b.lastChild;this.frontier.push({type:x.type,match:x.contentMatchAt(x.childCount)}),b=x.content}this.unplaced=k?0==t?D.empty:new D(ut(a.content,t-1,1),t-1,m<0?a.openEnd:t-1):new D(ut(a.content,t,l),a.openStart,a.openEnd)}},{key:"mustMoveInline",value:function(){if(!this.$to.parent.isTextblock)return-1;var e,t=this.frontier[this.depth];if(!t.type.isTextblock||!ft(this.$to,this.$to.depth,t.type,t.match,!1)||this.$to.depth==this.depth&&(e=this.findCloseLevel(this.$to))&&e.depth==this.depth)return-1;for(var n=this.$to.depth,r=this.$to.after(n);n>1&&r==this.$to.end(--n);)++r;return r}},{key:"findCloseLevel",value:function(e){e:for(var t=Math.min(this.depth,e.depth);t>=0;t--){var n=this.frontier[t],r=n.match,i=n.type,o=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),s=ft(e,t,i,r,o);if(s){for(var a=t-1;a>=0;a--){var c=this.frontier[a],u=c.match,l=ft(e,a,c.type,u,!0);if(!l||l.childCount)continue e}return{depth:t,fit:s,move:o?e.doc.resolve(e.after(t+1)):e}}}}},{key:"close",value:function(e){var t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=lt(this.placed,t.depth,t.fit)),e=t.move;for(var n=t.depth+1;n<=e.depth;n++){var r=e.node(n),i=r.type.contentMatch.fillBefore(r.content,!0,e.index(n));this.openFrontierNode(r.type,r.attrs,i)}return e}},{key:"openFrontierNode",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2?arguments[2]:void 0,r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=lt(this.placed,this.depth,C.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}},{key:"closeFrontierNode",value:function(){var e=this.frontier.pop().match.fillBefore(C.empty,!0);e.childCount&&(this.placed=lt(this.placed,this.frontier.length,e))}}]),e}();function ut(e,t,n){return 0==t?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(ut(e.firstChild.content,t-1,n)))}function lt(e,t,n){return 0==t?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(lt(e.lastChild.content,t-1,n)))}function dt(e,t){for(var n=0;n<t;n++)e=e.firstChild.content;return e}function ht(e,t,n){if(t<=0)return e;var r=e.content;return t>1&&(r=r.replaceChild(0,ht(r.firstChild,t-1,1==r.childCount?n-1:0))),t>0&&(r=e.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(e.type.contentMatch.matchFragment(r).fillBefore(C.empty,!0)))),e.copy(r)}function ft(e,t,n,r,i){var o=e.node(t),s=i?e.indexAfter(t):e.index(t);if(s==o.childCount&&!n.compatibleContent(o.type))return null;var a=r.fillBefore(o.content,!0,s);return a&&!function(e,t,n){for(var r=n;r<t.childCount;r++)if(!e.allowsMarks(t.child(r).marks))return!0;return!1}(n,o.content,s)?a:null}function pt(e){return e.spec.defining||e.spec.definingForContent}function vt(e,t,n,r,i){if(t<n){var o=e.firstChild;e=e.replaceChild(0,o.copy(vt(o.content,t+1,n,r,o)))}if(t>r){var s=i.contentMatchAt(0),a=s.fillBefore(e).append(e);e=a.append(s.matchFragment(a).fillBefore(C.empty,!0))}return e}function mt(e,t){for(var n=[],r=Math.min(e.depth,t.depth);r>=0;r--){var i=e.start(r);if(i<e.pos-(e.depth-r)||t.end(r)>t.pos+(t.depth-r)||e.node(r).type.spec.isolating||t.node(r).type.spec.isolating)break;(i==t.start(r)||r==e.depth&&r==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&r&&t.start(r-1)==i-1)&&n.push(r)}return n}var gt=function(e){(0,d.Z)(n,e);var t=b(n);function n(e,r,i){var o;return(0,v.Z)(this,n),(o=t.call(this)).pos=e,o.attr=r,o.value=i,o}return(0,m.Z)(n,[{key:"apply",value:function(e){var t=e.nodeAt(this.pos);if(!t)return Be.fail("No node at attribute step's position");var n=Object.create(null);for(var r in t.attrs)n[r]=t.attrs[r];n[this.attr]=this.value;var i=t.type.create(n,null,t.marks);return Be.fromReplace(e,this.pos,this.pos+1,new D(C.from(i),0,t.isLeaf?0:1))}},{key:"getMap",value:function(){return Pe.empty}},{key:"invert",value:function(e){return new n(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}},{key:"map",value:function(e){var t=e.mapResult(this.pos,1);return t.deletedAfter?null:new n(t.pos,this.attr,this.value)}},{key:"toJSON",value:function(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}}],[{key:"fromJSON",value:function(e,t){if("number"!=typeof t.pos||"string"!=typeof t.attr)throw new RangeError("Invalid input for AttrStep.fromJSON");return new n(t.pos,t.attr,t.value)}}]),n}(ze);ze.jsonID("attr",gt);var yt=Error;((yt=function e(t){var n=Error.call(this,t);return n.__proto__=e.prototype,n}).prototype=Object.create(Error.prototype)).constructor=yt,yt.prototype.name="TransformError";var kt=function(){function e(t){(0,v.Z)(this,e),this.doc=t,this.steps=[],this.docs=[],this.mapping=new Ie}return(0,m.Z)(e,[{key:"before",get:function(){return this.docs.length?this.docs[0]:this.doc}},{key:"step",value:function(e){var t=this.maybeStep(e);if(t.failed)throw new yt(t.failed);return this}},{key:"maybeStep",value:function(e){var t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}},{key:"docChanged",get:function(){return this.steps.length>0}},{key:"addStep",value:function(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}},{key:"replace",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:D.empty,r=st(this.doc,e,t,n);return r&&this.step(r),this}},{key:"replaceWith",value:function(e,t,n){return this.replace(e,t,new D(C.from(n),0,0))}},{key:"delete",value:function(e,t){return this.replace(e,t,D.empty)}},{key:"insert",value:function(e,t){return this.replaceWith(e,e,t)}},{key:"replaceRange",value:function(e,t,n){return function(e,t,n,r){if(!r.size)return e.deleteRange(t,n);var i=e.doc.resolve(t),o=e.doc.resolve(n);if(at(i,o,r))return e.step(new je(t,n,r));var s=mt(i,e.doc.resolve(n));0==s[s.length-1]&&s.pop();var a=-(i.depth+1);s.unshift(a);for(var c=i.depth,u=i.pos-1;c>0;c--,u--){var l=i.node(c).type.spec;if(l.defining||l.definingAsContext||l.isolating)break;s.indexOf(c)>-1?a=c:i.before(c)==u&&s.splice(1,0,-c)}for(var d=s.indexOf(a),h=[],f=r.openStart,p=r.content,v=0;;v++){var m=p.firstChild;if(h.push(m),v==r.openStart)break;p=m.content}for(var g=f-1;g>=0;g--){var y=h[g].type,k=pt(y);if(k&&i.node(d).type!=y)f=g;else if(k||!y.isTextblock)break}for(var w=r.openStart;w>=0;w--){var b=(w+f+1)%(r.openStart+1),x=h[b];if(x)for(var M=0;M<s.length;M++){var S=s[(M+d)%s.length],C=!0;S<0&&(C=!1,S=-S);var O=i.node(S-1),T=i.index(S-1);if(O.canReplaceWith(T,T,x.type,x.marks))return e.replace(i.before(S),C?o.after(S):n,new D(vt(r.content,0,r.openStart,b),b,r.openEnd))}}for(var N=e.steps.length,E=s.length-1;E>=0&&(e.replace(t,n,r),!(e.steps.length>N));E--){var A=s[E];A<0||(t=i.before(A),n=o.after(A))}}(this,e,t,n),this}},{key:"replaceRangeWith",value:function(e,t,n){return function(e,t,n,r){if(!r.isInline&&t==n&&e.doc.resolve(t).parent.content.size){var i=function(e,t,n){var r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(0==r.parentOffset)for(var i=r.depth-1;i>=0;i--){var o=r.index(i);if(r.node(i).canReplaceWith(o,o,n))return r.before(i+1);if(o>0)return null}if(r.parentOffset==r.parent.content.size)for(var s=r.depth-1;s>=0;s--){var a=r.indexAfter(s);if(r.node(s).canReplaceWith(a,a,n))return r.after(s+1);if(a<r.node(s).childCount)return null}return null}(e.doc,t,r.type);null!=i&&(t=n=i)}e.replaceRange(t,n,new D(C.from(r),0,0))}(this,e,t,n),this}},{key:"deleteRange",value:function(e,t){return function(e,t,n){for(var r=e.doc.resolve(t),i=e.doc.resolve(n),o=mt(r,i),s=0;s<o.length;s++){var a=o[s],c=s==o.length-1;if(c&&0==a||r.node(a).type.contentMatch.validEnd)return e.delete(r.start(a),i.end(a));if(a>0&&(c||r.node(a-1).canReplace(r.index(a-1),i.indexAfter(a-1))))return e.delete(r.before(a),i.after(a))}for(var u=1;u<=r.depth&&u<=i.depth;u++)if(t-r.start(u)==r.depth-u&&n>r.end(u)&&i.end(u)-n!=i.depth-u)return e.delete(r.before(u),n);e.delete(t,n)}(this,e,t),this}},{key:"lift",value:function(e,t){return function(e,t,n){for(var r=t.$from,i=t.$to,o=t.depth,s=r.before(o+1),a=i.after(o+1),c=s,u=a,l=C.empty,d=0,h=o,f=!1;h>n;h--)f||r.index(h)>0?(f=!0,l=C.from(r.node(h).copy(l)),d++):c--;for(var p=C.empty,v=0,m=o,g=!1;m>n;m--)g||i.after(m+1)<i.end(m)?(g=!0,p=C.from(i.node(m).copy(p)),v++):u++;e.step(new He(c,u,s,a,new D(l.append(p),d,v),l.size-d,!0))}(this,e,t),this}},{key:"join",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return it(this,e,t),this}},{key:"wrap",value:function(e,t){return function(e,t,n){for(var r=C.empty,i=n.length-1;i>=0;i--){if(r.size){var o=n[i].type.contentMatch.matchFragment(r);if(!o||!o.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=C.from(n[i].type.create(n[i].attrs,r))}var s=t.start,a=t.end;e.step(new He(s,a,s,a,new D(r,0,0),n.length,!0))}(this,e,t),this}},{key:"setBlockType",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e,n=arguments.length>2?arguments[2]:void 0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;return Xe(this,e,t,n,r),this}},{key:"setNodeMarkup",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=arguments.length>3?arguments[3]:void 0;return Ye(this,e,t,n,r),this}},{key:"setNodeAttribute",value:function(e,t,n){return this.step(new gt(e,t,n)),this}},{key:"addNodeMark",value:function(e,t){return this.step(new Fe(e,t)),this}},{key:"removeNodeMark",value:function(e,t){if(!(t instanceof E)){var n=this.doc.nodeAt(e);if(!n)throw new RangeError("No node at position "+e);if(!(t=t.isInSet(n.marks)))return this}return this.step(new Ve(e,t)),this}},{key:"split",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2?arguments[2]:void 0;return et(this,e,t,n),this}},{key:"addMark",value:function(e,t,n){return function(e,t,n,r){var i,o,s=[],a=[];e.doc.nodesBetween(t,n,(function(e,c,u){if(e.isInline){var l=e.marks;if(!r.isInSet(l)&&u.type.allowsMarkType(r.type)){for(var d=Math.max(c,t),h=Math.min(c+e.nodeSize,n),f=r.addToSet(l),p=0;p<l.length;p++)l[p].isInSet(f)||(i&&i.to==d&&i.mark.eq(l[p])?i.to=h:s.push(i=new $e(d,h,l[p])));o&&o.to==d?o.to=h:a.push(o=new Le(d,h,r))}}})),s.forEach((function(t){return e.step(t)})),a.forEach((function(t){return e.step(t)}))}(this,e,t,n),this}},{key:"removeMark",value:function(e,t,n){return function(e,t,n,r){var i=[],o=0;e.doc.nodesBetween(t,n,(function(e,s){if(e.isInline){o++;var a=null;if(r instanceof fe)for(var c,u=e.marks;c=r.isInSet(u);)(a||(a=[])).push(c),u=c.removeFromSet(u);else r?r.isInSet(e.marks)&&(a=[r]):a=e.marks;if(a&&a.length)for(var l=Math.min(s+e.nodeSize,n),d=0;d<a.length;d++){for(var h=a[d],f=void 0,p=0;p<i.length;p++){var v=i[p];v.step==o-1&&h.eq(i[p].style)&&(f=v)}f?(f.to=l,f.step=o):i.push({style:h,from:Math.max(s,t),to:l,step:o})}}})),i.forEach((function(t){return e.step(new $e(t.from,t.to,t.style))}))}(this,e,t,n),this}},{key:"clearIncompatible",value:function(e,t,n){return function(e,t,n){for(var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:n.contentMatch,i=e.doc.nodeAt(t),o=[],s=t+1,a=0;a<i.childCount;a++){var c=i.child(a),u=s+c.nodeSize,l=r.matchType(c.type);if(l){r=l;for(var d=0;d<c.marks.length;d++)n.allowsMarkType(c.marks[d].type)||e.step(new $e(s,u,c.marks[d]))}else o.push(new je(s,u,D.empty));s=u}if(!r.validEnd){var h=r.fillBefore(C.empty,!0);e.replace(s,s,new D(h,0,0))}for(var f=o.length-1;f>=0;f--)e.step(o[f])}(this,e,t,n),this}}]),e}(),wt=Object.create(null),bt=function(){function e(t,n,r){(0,v.Z)(this,e),this.$anchor=t,this.$head=n,this.ranges=r||[new xt(t.min(n),t.max(n))]}return(0,m.Z)(e,[{key:"anchor",get:function(){return this.$anchor.pos}},{key:"head",get:function(){return this.$head.pos}},{key:"from",get:function(){return this.$from.pos}},{key:"to",get:function(){return this.$to.pos}},{key:"$from",get:function(){return this.ranges[0].$from}},{key:"$to",get:function(){return this.ranges[0].$to}},{key:"empty",get:function(){for(var e=this.ranges,t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}},{key:"content",value:function(){return this.$from.doc.slice(this.from,this.to,!0)}},{key:"replace",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:D.empty,n=t.content.lastChild,r=null,i=0;i<t.openEnd;i++)r=n,n=n.lastChild;for(var o=e.steps.length,s=this.ranges,a=0;a<s.length;a++){var c=s[a],u=c.$from,l=c.$to,d=e.mapping.slice(o);e.replaceRange(d.map(u.pos),d.map(l.pos),a?D.empty:t),0==a&&Pt(e,o,(n?n.isInline:r&&r.isTextblock)?-1:1)}}},{key:"replaceWith",value:function(e,t){for(var n=e.steps.length,r=this.ranges,i=0;i<r.length;i++){var o=r[i],s=o.$from,a=o.$to,c=e.mapping.slice(n),u=c.map(s.pos),l=c.map(a.pos);i?e.deleteRange(u,l):(e.replaceRangeWith(u,l,t),Pt(e,n,t.isInline?-1:1))}}},{key:"getBookmark",value:function(){return Ct.between(this.$anchor,this.$head).getBookmark()}}],[{key:"findFrom",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=e.parent.inlineContent?new Ct(e):Dt(e.node(0),e.parent,e.pos,e.index(),t,n);if(r)return r;for(var i=e.depth-1;i>=0;i--){var o=t<0?Dt(e.node(0),e.node(i),e.before(i+1),e.index(i),t,n):Dt(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,t,n);if(o)return o}return null}},{key:"near",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return this.findFrom(e,t)||this.findFrom(e,-t)||new Et(e.node(0))}},{key:"atStart",value:function(e){return Dt(e,e,0,0,1)||new Et(e)}},{key:"atEnd",value:function(e){return Dt(e,e,e.content.size,e.childCount,-1)||new Et(e)}},{key:"fromJSON",value:function(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");var n=wt[t.type];if(!n)throw new RangeError("No selection type ".concat(t.type," defined"));return n.fromJSON(e,t)}},{key:"jsonID",value:function(e,t){if(e in wt)throw new RangeError("Duplicate use of selection JSON ID "+e);return wt[e]=t,t.prototype.jsonID=e,t}}]),e}();bt.prototype.visible=!0;var xt=(0,m.Z)((function e(t,n){(0,v.Z)(this,e),this.$from=t,this.$to=n})),Mt=!1;function St(e){Mt||e.parent.inlineContent||(Mt=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}var Ct=function(e){(0,d.Z)(n,e);var t=b(n);function n(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e;return(0,v.Z)(this,n),St(e),St(r),t.call(this,e,r)}return(0,m.Z)(n,[{key:"$cursor",get:function(){return this.$anchor.pos==this.$head.pos?this.$head:null}},{key:"map",value:function(e,t){var r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return bt.near(r);var i=e.resolve(t.map(this.anchor));return new n(i.parent.inlineContent?i:r,r)}},{key:"replace",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:D.empty;if(l((0,c.Z)(n.prototype),"replace",this).call(this,e,t),t==D.empty){var r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}},{key:"eq",value:function(e){return e instanceof n&&e.anchor==this.anchor&&e.head==this.head}},{key:"getBookmark",value:function(){return new Ot(this.anchor,this.head)}},{key:"toJSON",value:function(){return{type:"text",anchor:this.anchor,head:this.head}}}],[{key:"fromJSON",value:function(e,t){if("number"!=typeof t.anchor||"number"!=typeof t.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new n(e.resolve(t.anchor),e.resolve(t.head))}},{key:"create",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t,r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))}},{key:"between",value:function(e,t,r){var i=e.pos-t.pos;if(r&&!i||(r=i>=0?1:-1),!t.parent.inlineContent){var o=bt.findFrom(t,r,!0)||bt.findFrom(t,-r,!0);if(!o)return bt.near(t,r);t=o.$head}return e.parent.inlineContent||(0==i||(e=(bt.findFrom(e,-r,!0)||bt.findFrom(e,r,!0)).$anchor).pos<t.pos!=i<0)&&(e=t),new n(e,t)}}]),n}(bt);bt.jsonID("text",Ct);var Ot=function(){function e(t,n){(0,v.Z)(this,e),this.anchor=t,this.head=n}return(0,m.Z)(e,[{key:"map",value:function(t){return new e(t.map(this.anchor),t.map(this.head))}},{key:"resolve",value:function(e){return Ct.between(e.resolve(this.anchor),e.resolve(this.head))}}]),e}(),Tt=function(e){(0,d.Z)(n,e);var t=b(n);function n(e){var r;(0,v.Z)(this,n);var i=e.nodeAfter,o=e.node(0).resolve(e.pos+i.nodeSize);return(r=t.call(this,e,o)).node=i,r}return(0,m.Z)(n,[{key:"map",value:function(e,t){var r=t.mapResult(this.anchor),i=r.deleted,o=r.pos,s=e.resolve(o);return i?bt.near(s):new n(s)}},{key:"content",value:function(){return new D(C.from(this.node),0,0)}},{key:"eq",value:function(e){return e instanceof n&&e.anchor==this.anchor}},{key:"toJSON",value:function(){return{type:"node",anchor:this.anchor}}},{key:"getBookmark",value:function(){return new Nt(this.anchor)}}],[{key:"fromJSON",value:function(e,t){if("number"!=typeof t.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new n(e.resolve(t.anchor))}},{key:"create",value:function(e,t){return new n(e.resolve(t))}},{key:"isSelectable",value:function(e){return!e.isText&&!1!==e.type.spec.selectable}}]),n}(bt);Tt.prototype.visible=!1,bt.jsonID("node",Tt);var Nt=function(){function e(t){(0,v.Z)(this,e),this.anchor=t}return(0,m.Z)(e,[{key:"map",value:function(t){var n=t.mapResult(this.anchor),r=n.deleted,i=n.pos;return r?new Ot(i,i):new e(i)}},{key:"resolve",value:function(e){var t=e.resolve(this.anchor),n=t.nodeAfter;return n&&Tt.isSelectable(n)?new Tt(t):bt.near(t)}}]),e}(),Et=function(e){(0,d.Z)(n,e);var t=b(n);function n(e){return(0,v.Z)(this,n),t.call(this,e.resolve(0),e.resolve(e.content.size))}return(0,m.Z)(n,[{key:"replace",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:D.empty;if(t==D.empty){e.delete(0,e.doc.content.size);var r=bt.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else l((0,c.Z)(n.prototype),"replace",this).call(this,e,t)}},{key:"toJSON",value:function(){return{type:"all"}}},{key:"map",value:function(e){return new n(e)}},{key:"eq",value:function(e){return e instanceof n}},{key:"getBookmark",value:function(){return At}}],[{key:"fromJSON",value:function(e){return new n(e)}}]),n}(bt);bt.jsonID("all",Et);var At={map:function(){return this},resolve:function(e){return new Et(e)}};function Dt(e,t,n,r,i){var o=arguments.length>5&&void 0!==arguments[5]&&arguments[5];if(t.inlineContent)return Ct.create(e,n);for(var s=r-(i>0?0:1);i>0?s<t.childCount:s>=0;s+=i){var a=t.child(s);if(a.isAtom){if(!o&&Tt.isSelectable(a))return Tt.create(e,n-(i<0?a.nodeSize:0))}else{var c=Dt(e,a,n+i,i<0?a.childCount:0,i,o);if(c)return c}n+=a.nodeSize*i}return null}function Pt(e,t,n){var r=e.steps.length-1;if(!(r<t)){var i,o=e.steps[r];(o instanceof je||o instanceof He)&&(e.mapping.maps[r].forEach((function(e,t,n,r){null==i&&(i=r)})),e.setSelection(bt.near(e.doc.resolve(i),n)))}}var It=function(e){(0,d.Z)(n,e);var t=b(n);function n(e){var r;return(0,v.Z)(this,n),(r=t.call(this,e.doc)).curSelectionFor=0,r.updated=0,r.meta=Object.create(null),r.time=Date.now(),r.curSelection=e.selection,r.storedMarks=e.storedMarks,r}return(0,m.Z)(n,[{key:"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}},{key:"setSelection",value:function(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=-3&(1|this.updated),this.storedMarks=null,this}},{key:"selectionSet",get:function(){return(1&this.updated)>0}},{key:"setStoredMarks",value:function(e){return this.storedMarks=e,this.updated|=2,this}},{key:"ensureMarks",value:function(e){return E.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}},{key:"addStoredMark",value:function(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}},{key:"removeStoredMark",value:function(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}},{key:"storedMarksSet",get:function(){return(2&this.updated)>0}},{key:"addStep",value:function(e,t){l((0,c.Z)(n.prototype),"addStep",this).call(this,e,t),this.updated=-3&this.updated,this.storedMarks=null}},{key:"setTime",value:function(e){return this.time=e,this}},{key:"replaceSelection",value:function(e){return this.selection.replace(this,e),this}},{key:"replaceSelectionWith",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||E.none))),n.replaceWith(this,e),this}},{key:"deleteSelection",value:function(){return this.selection.replace(this),this}},{key:"insertText",value:function(e,t,n){var r=this.doc.type.schema;if(null==t)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();if(null==n&&(n=t),n=null==n?t:n,!e)return this.deleteRange(t,n);var i=this.storedMarks;if(!i){var o=this.doc.resolve(t);i=n==t?o.marks():o.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,i)),this.selection.empty||this.setSelection(bt.near(this.selection.$to)),this}},{key:"setMeta",value:function(e,t){return this.meta["string"==typeof e?e:e.key]=t,this}},{key:"getMeta",value:function(e){return this.meta["string"==typeof e?e:e.key]}},{key:"isGeneric",get:function(){for(var e in this.meta)return!1;return!0}},{key:"scrollIntoView",value:function(){return this.updated|=4,this}},{key:"scrolledIntoView",get:function(){return(4&this.updated)>0}}]),n}(kt);function Rt(e,t){return t&&e?e.bind(t):e}var zt=(0,m.Z)((function e(t,n,r){(0,v.Z)(this,e),this.name=t,this.init=Rt(n.init,r),this.apply=Rt(n.apply,r)})),Bt=[new zt("doc",{init:function(e){return e.doc||e.schema.topNodeType.createAndFill()},apply:function(e){return e.doc}}),new zt("selection",{init:function(e,t){return e.selection||bt.atStart(t.doc)},apply:function(e){return e.selection}}),new zt("storedMarks",{init:function(e){return e.storedMarks||null},apply:function(e,t,n,r){return r.selection.$cursor?e.storedMarks:null}}),new zt("scrollToSelection",{init:function(){return 0},apply:function(e,t){return e.scrolledIntoView?t+1:t}})],Zt=(0,m.Z)((function e(t,n){var r=this;(0,v.Z)(this,e),this.schema=t,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Bt.slice(),n&&n.forEach((function(e){if(r.pluginsByKey[e.key])throw new RangeError("Adding different instances of a keyed plugin ("+e.key+")");r.plugins.push(e),r.pluginsByKey[e.key]=e,e.spec.state&&r.fields.push(new zt(e.key,e.spec.state,e))}))})),Lt=function(){function e(t){(0,v.Z)(this,e),this.config=t}return(0,m.Z)(e,[{key:"schema",get:function(){return this.config.schema}},{key:"plugins",get:function(){return this.config.plugins}},{key:"apply",value:function(e){return this.applyTransaction(e).state}},{key:"filterTransaction",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1,n=0;n<this.config.plugins.length;n++)if(n!=t){var r=this.config.plugins[n];if(r.spec.filterTransaction&&!r.spec.filterTransaction.call(r,e,this))return!1}return!0}},{key:"applyTransaction",value:function(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};for(var t=[e],n=this.applyInner(e),r=null;;){for(var i=!1,o=0;o<this.config.plugins.length;o++){var s=this.config.plugins[o];if(s.spec.appendTransaction){var a=r?r[o].n:0,c=r?r[o].state:this,u=a<t.length&&s.spec.appendTransaction.call(s,a?t.slice(a):t,c,n);if(u&&n.filterTransaction(u,o)){if(u.setMeta("appendedTransaction",e),!r){r=[];for(var l=0;l<this.config.plugins.length;l++)r.push(l<o?{state:n,n:t.length}:{state:this,n:0})}t.push(u),n=n.applyInner(u),i=!0}r&&(r[o]={state:n,n:t.length})}}if(!i)return{state:n,transactions:t}}}},{key:"applyInner",value:function(t){if(!t.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");for(var n=new e(this.config),r=this.config.fields,i=0;i<r.length;i++){var o=r[i];n[o.name]=o.apply(t,this[o.name],this,n)}return n}},{key:"tr",get:function(){return new It(this)}},{key:"reconfigure",value:function(t){for(var n=new Zt(this.schema,t.plugins),r=n.fields,i=new e(n),o=0;o<r.length;o++){var s=r[o].name;i[s]=this.hasOwnProperty(s)?this[s]:r[o].init(t,i)}return i}},{key:"toJSON",value:function(e){var t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map((function(e){return e.toJSON()}))),e&&"object"==(0,p.Z)(e))for(var n in e){if("doc"==n||"selection"==n)throw new RangeError("The JSON fields `doc` and `selection` are reserved");var r=e[n],i=r.spec.state;i&&i.toJSON&&(t[n]=i.toJSON.call(r,this[r.key]))}return t}}],[{key:"create",value:function(t){for(var n=new Zt(t.doc?t.doc.type.schema:t.schema,t.plugins),r=new e(n),i=0;i<n.fields.length;i++)r[n.fields[i].name]=n.fields[i].init(t,r);return r}},{key:"fromJSON",value:function(t,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!t.schema)throw new RangeError("Required config field 'schema' missing");var i=new Zt(t.schema,t.plugins),o=new e(i);return i.fields.forEach((function(e){if("doc"==e.name)o.doc=U.fromJSON(t.schema,n.doc);else if("selection"==e.name)o.selection=bt.fromJSON(o.doc,n.selection);else if("storedMarks"==e.name)n.storedMarks&&(o.storedMarks=n.storedMarks.map(t.schema.markFromJSON));else{if(r)for(var i in r){var s=r[i],a=s.spec.state;if(s.key==e.name&&a&&a.fromJSON&&Object.prototype.hasOwnProperty.call(n,i))return void(o[e.name]=a.fromJSON.call(s,t,n[i],o))}o[e.name]=e.init(t,o)}})),o}}]),e}();function $t(e,t,n){for(var r in e){var i=e[r];i instanceof Function?i=i.bind(t):"handleDOMEvents"==r&&(i=$t(i,t,{})),n[r]=i}return n}var Ft=function(){function e(t){(0,v.Z)(this,e),this.spec=t,this.props={},t.props&&$t(t.props,this,this.props),this.key=t.key?t.key.key:jt("plugin")}return(0,m.Z)(e,[{key:"getState",value:function(e){return e[this.key]}}]),e}(),Vt=Object.create(null);function jt(e){return e in Vt?e+"$"+ ++Vt[e]:(Vt[e]=0,e+"$")}var Ht=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"key";(0,v.Z)(this,e),this.key=jt(t)}return(0,m.Z)(e,[{key:"get",value:function(e){return e.config.pluginsByKey[this.key]}},{key:"getState",value:function(e){return e[this.key]}}]),e}(),Jt=function(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t},qt=function(e){var t=e.assignedSlot||e.parentNode;return t&&11==t.nodeType?t.host:t},Wt=null,Kt=function(e,t,n){var r=Wt||(Wt=document.createRange());return r.setEnd(e,null==n?e.nodeValue.length:n),r.setStart(e,t||0),r},_t=function(e,t,n,r){return n&&(Gt(e,t,n,r,-1)||Gt(e,t,n,r,1))},Ut=/^(img|br|input|textarea|hr)$/i;function Gt(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:Xt(e))){var o=e.parentNode;if(!o||1!=o.nodeType||Qt(e)||Ut.test(e.nodeName)||"false"==e.contentEditable)return!1;t=Jt(e)+(i<0?0:1),e=o}else{if(1!=e.nodeType)return!1;if("false"==(e=e.childNodes[t+(i<0?-1:0)]).contentEditable)return!1;t=i<0?Xt(e):0}}}function Xt(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function Yt(e,t,n){for(var r=0==t,i=t==Xt(e);r||i;){if(e==n)return!0;var o=Jt(e);if(!(e=e.parentNode))return!1;r=r&&0==o,i=i&&o==Xt(e)}}function Qt(e){for(var t,n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}var en=function(e){return e.focusNode&&_t(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function tn(e,t){var n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}var nn="undefined"!=typeof navigator?navigator:null,rn="undefined"!=typeof document?document:null,on=nn&&nn.userAgent||"",sn=/Edge\/(\d+)/.exec(on),an=/MSIE \d/.exec(on),cn=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(on),un=!!(an||cn||sn),ln=an?document.documentMode:cn?+cn[1]:sn?+sn[1]:0,dn=!un&&/gecko\/(\d+)/i.test(on);dn&&(/Firefox\/(\d+)/.exec(on)||[0,0])[1];var hn=!un&&/Chrome\/(\d+)/.exec(on),fn=!!hn,pn=hn?+hn[1]:0,vn=!un&&!!nn&&/Apple Computer/.test(nn.vendor),mn=vn&&(/Mobile\/\w+/.test(on)||!!nn&&nn.maxTouchPoints>2),gn=mn||!!nn&&/Mac/.test(nn.platform),yn=/Android \d/.test(on),kn=!!rn&&"webkitFontSmoothing"in rn.documentElement.style,wn=kn?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function bn(e){return{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function xn(e,t){return"number"==typeof e?e:e[t]}function Mn(e){var t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function Sn(e,t,n){for(var r=e.someProp("scrollThreshold")||0,i=e.someProp("scrollMargin")||5,o=e.dom.ownerDocument,s=n||e.dom;s;s=qt(s))if(1==s.nodeType){var a=s,c=a==o.body,u=c?bn(o):Mn(a),l=0,d=0;if(t.top<u.top+xn(r,"top")?d=-(u.top-t.top+xn(i,"top")):t.bottom>u.bottom-xn(r,"bottom")&&(d=t.bottom-u.bottom+xn(i,"bottom")),t.left<u.left+xn(r,"left")?l=-(u.left-t.left+xn(i,"left")):t.right>u.right-xn(r,"right")&&(l=t.right-u.right+xn(i,"right")),l||d)if(c)o.defaultView.scrollBy(l,d);else{var h=a.scrollLeft,f=a.scrollTop;d&&(a.scrollTop+=d),l&&(a.scrollLeft+=l);var p=a.scrollLeft-h,v=a.scrollTop-f;t={left:t.left-p,top:t.top-v,right:t.right-p,bottom:t.bottom-v}}if(c)break}}function Cn(e){for(var t=[],n=e.ownerDocument,r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=qt(r));return t}function On(e,t){for(var n=0;n<e.length;n++){var r=e[n],i=r.dom,o=r.top,s=r.left;i.scrollTop!=o+t&&(i.scrollTop=o+t),i.scrollLeft!=s&&(i.scrollLeft=s)}}var Tn=null;function Nn(e,t){for(var n,r,i=2e8,o=0,s=t.top,a=t.top,c=e.firstChild,u=0;c;c=c.nextSibling,u++){var l=void 0;if(1==c.nodeType)l=c.getClientRects();else{if(3!=c.nodeType)continue;l=Kt(c).getClientRects()}for(var d=0;d<l.length;d++){var h=l[d];if(h.top<=s&&h.bottom>=a){s=Math.max(h.bottom,s),a=Math.min(h.top,a);var f=h.left>t.left?h.left-t.left:h.right<t.left?t.left-h.right:0;if(f<i){n=c,i=f,r=f&&3==n.nodeType?{left:h.right<t.left?h.right:h.left,top:t.top}:t,1==c.nodeType&&f&&(o=u+(t.left>=(h.left+h.right)/2?1:0));continue}}!n&&(t.left>=h.right&&t.top>=h.top||t.left>=h.left&&t.top>=h.bottom)&&(o=u+1)}}return n&&3==n.nodeType?function(e,t){for(var n=e.nodeValue.length,r=document.createRange(),i=0;i<n;i++){r.setEnd(e,i+1),r.setStart(e,i);var o=Pn(r,1);if(o.top!=o.bottom&&En(t,o))return{node:e,offset:i+(t.left>=(o.left+o.right)/2?1:0)}}return{node:e,offset:0}}(n,r):!n||i&&1==n.nodeType?{node:e,offset:o}:Nn(n,r)}function En(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function An(e,t,n){var r=e.childNodes.length;if(r&&n.top<n.bottom)for(var i=Math.max(0,Math.min(r-1,Math.floor(r*(t.top-n.top)/(n.bottom-n.top))-2)),o=i;;){var s=e.childNodes[o];if(1==s.nodeType)for(var a=s.getClientRects(),c=0;c<a.length;c++){var u=a[c];if(En(t,u))return An(s,t,u)}if((o=(o+1)%r)==i)break}return e}function Dn(e,t){var n,r=e.dom.ownerDocument,i=0;if(r.caretPositionFromPoint)try{var o=r.caretPositionFromPoint(t.left,t.top);o&&(n=o.offsetNode,i=o.offset)}catch(e){}if(!n&&r.caretRangeFromPoint){var s=r.caretRangeFromPoint(t.left,t.top);s&&(n=s.startContainer,i=s.startOffset)}var a,c=(e.root.elementFromPoint?e.root:r).elementFromPoint(t.left,t.top);if(!c||!e.dom.contains(1!=c.nodeType?c.parentNode:c)){var u=e.dom.getBoundingClientRect();if(!En(t,u))return null;if(!(c=An(e.dom,t,u)))return null}if(vn)for(var l=c;n&&l;l=qt(l))l.draggable&&(n=void 0);if(c=function(e,t){var n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}(c,t),n){if(dn&&1==n.nodeType&&(i=Math.min(i,n.childNodes.length))<n.childNodes.length){var d,h=n.childNodes[i];"IMG"==h.nodeName&&(d=h.getBoundingClientRect()).right<=t.left&&d.bottom>t.top&&i++}n==e.dom&&i==n.childNodes.length-1&&1==n.lastChild.nodeType&&t.top>n.lastChild.getBoundingClientRect().bottom?a=e.state.doc.content.size:0!=i&&1==n.nodeType&&"BR"==n.childNodes[i-1].nodeName||(a=function(e,t,n,r){for(var i=-1,o=t;o!=e.dom;){var s=e.docView.nearestDesc(o,!0);if(!s)return null;if(1==s.dom.nodeType&&(s.node.isBlock&&s.parent||!s.contentDOM)){var a=s.dom.getBoundingClientRect();if(s.node.isBlock&&s.parent&&(a.left>r.left||a.top>r.top?i=s.posBefore:(a.right<r.left||a.bottom<r.top)&&(i=s.posAfter)),!s.contentDOM&&i<0)return(s.node.isBlock?r.top<(a.top+a.bottom)/2:r.left<(a.left+a.right)/2)?s.posBefore:s.posAfter}o=s.dom.parentNode}return i>-1?i:e.docView.posFromDOM(t,n,-1)}(e,n,i,t))}null==a&&(a=function(e,t,n){var r=Nn(t,n),i=r.node,o=r.offset,s=-1;if(1==i.nodeType&&!i.firstChild){var a=i.getBoundingClientRect();s=a.left!=a.right&&n.left>(a.left+a.right)/2?1:-1}return e.docView.posFromDOM(i,o,s)}(e,c,t));var f=e.docView.nearestDesc(c,!0);return{pos:a,inside:f?f.posAtStart-f.border:-1}}function Pn(e,t){var n=e.getClientRects();return n.length?n[t<0?0:n.length-1]:e.getBoundingClientRect()}var In=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Rn(e,t,n){var r=e.docView.domFromPos(t,n<0?-1:1),i=r.node,o=r.offset,s=r.atom,a=kn||dn;if(3==i.nodeType){if(!a||!In.test(i.nodeValue)&&(n<0?o:o!=i.nodeValue.length)){var c=o,u=o,l=n<0?1:-1;return n<0&&!o?(u++,l=-1):n>=0&&o==i.nodeValue.length?(c--,l=1):n<0?c--:u++,zn(Pn(Kt(i,c,u),1),l<0)}var d=Pn(Kt(i,o,o),n);if(dn&&o&&/\s/.test(i.nodeValue[o-1])&&o<i.nodeValue.length){var h=Pn(Kt(i,o-1,o-1),-1);if(h.top==d.top){var f=Pn(Kt(i,o,o+1),-1);if(f.top!=d.top)return zn(f,f.left<h.left)}}return d}if(!e.state.doc.resolve(t-(s||0)).parent.inlineContent){if(null==s&&o&&(n<0||o==Xt(i))){var p=i.childNodes[o-1];if(1==p.nodeType)return Bn(p.getBoundingClientRect(),!1)}if(null==s&&o<Xt(i)){var v=i.childNodes[o];if(1==v.nodeType)return Bn(v.getBoundingClientRect(),!0)}return Bn(i.getBoundingClientRect(),n>=0)}if(null==s&&o&&(n<0||o==Xt(i))){var m=i.childNodes[o-1],g=3==m.nodeType?Kt(m,Xt(m)-(a?0:1)):1!=m.nodeType||"BR"==m.nodeName&&m.nextSibling?null:m;if(g)return zn(Pn(g,1),!1)}if(null==s&&o<Xt(i)){for(var y=i.childNodes[o];y.pmViewDesc&&y.pmViewDesc.ignoreForCoords;)y=y.nextSibling;var k=y?3==y.nodeType?Kt(y,0,a?0:1):1==y.nodeType?y:null:null;if(k)return zn(Pn(k,-1),!0)}return zn(Pn(3==i.nodeType?Kt(i):i,-n),n>=0)}function zn(e,t){if(0==e.width)return e;var n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function Bn(e,t){if(0==e.height)return e;var n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function Zn(e,t,n){var r=e.state,i=e.root.activeElement;r!=t&&e.updateState(t),i!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),i!=e.dom&&i&&i.focus()}}var Ln=/[\u0590-\u08ac]/,$n=null,Fn=null,Vn=!1;var jn=function(){function e(t,n,r,i){(0,v.Z)(this,e),this.parent=t,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=0,r.pmViewDesc=this}return(0,m.Z)(e,[{key:"matchesWidget",value:function(e){return!1}},{key:"matchesMark",value:function(e){return!1}},{key:"matchesNode",value:function(e,t,n){return!1}},{key:"matchesHack",value:function(e){return!1}},{key:"parseRule",value:function(){return null}},{key:"stopEvent",value:function(e){return!1}},{key:"size",get:function(){for(var e=0,t=0;t<this.children.length;t++)e+=this.children[t].size;return e}},{key:"border",get:function(){return 0}},{key:"destroy",value:function(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(var e=0;e<this.children.length;e++)this.children[e].destroy()}},{key:"posBeforeChild",value:function(e){for(var t=0,n=this.posAtStart;;t++){var r=this.children[t];if(r==e)return n;n+=r.size}}},{key:"posBefore",get:function(){return this.parent.posBeforeChild(this)}},{key:"posAtStart",get:function(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}},{key:"posAfter",get:function(){return this.posBefore+this.size}},{key:"posAtEnd",get:function(){return this.posAtStart+this.size-2*this.border}},{key:"localPosFromDOM",value:function(e,t,n){if(this.contentDOM&&this.contentDOM.contains(1==e.nodeType?e:e.parentNode)){if(n<0){var r,i;if(e==this.contentDOM)r=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;r=e.previousSibling}for(;r&&(!(i=r.pmViewDesc)||i.parent!=this);)r=r.previousSibling;return r?this.posBeforeChild(i)+i.size:this.posAtStart}var o,s;if(e==this.contentDOM)o=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.nextSibling}for(;o&&(!(s=o.pmViewDesc)||s.parent!=this);)o=o.nextSibling;return o?this.posBeforeChild(s):this.posAtEnd}var a;if(e==this.dom&&this.contentDOM)a=t>Jt(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))a=2&e.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==t)for(var c=e;;c=c.parentNode){if(c==this.dom){a=!1;break}if(c.previousSibling)break}if(null==a&&t==e.childNodes.length)for(var u=e;;u=u.parentNode){if(u==this.dom){a=!0;break}if(u.nextSibling)break}}return(null==a?n>0:a)?this.posAtEnd:this.posAtStart}},{key:"nearestDesc",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=!0,r=e;r;r=r.parentNode){var i=this.getDesc(r),o=void 0;if(i&&(!t||i.node)){if(!n||!(o=i.nodeDOM)||(1==o.nodeType?o.contains(1==e.nodeType?e:e.parentNode):o==e))return i;n=!1}}}},{key:"getDesc",value:function(e){for(var t=e.pmViewDesc,n=t;n;n=n.parent)if(n==this)return t}},{key:"posFromDOM",value:function(e,t,n){for(var r=e;r;r=r.parentNode){var i=this.getDesc(r);if(i)return i.localPosFromDOM(e,t,n)}return-1}},{key:"descAt",value:function(e){for(var t=0,n=0;t<this.children.length;t++){var r=this.children[t],i=n+r.size;if(n==e&&i!=n){for(;!r.border&&r.children.length;)r=r.children[0];return r}if(e<i)return r.descAt(e-n-r.border);n=i}}},{key:"domFromPos",value:function(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};for(var n,r=0,i=0,o=0;r<this.children.length;r++){var s=this.children[r],a=o+s.size;if(a>e||s instanceof Gn){i=e-o;break}o=a}if(i)return this.children[r].domFromPos(i-this.children[r].border,t);for(;r&&!(n=this.children[r-1]).size&&n instanceof Hn&&n.side>=0;r--);if(t<=0){for(var c,u=!0;(c=r?this.children[r-1]:null)&&c.dom.parentNode!=this.contentDOM;r--,u=!1);return c&&t&&u&&!c.border&&!c.domAtom?c.domFromPos(c.size,t):{node:this.contentDOM,offset:c?Jt(c.dom)+1:0}}for(var l,d=!0;(l=r<this.children.length?this.children[r]:null)&&l.dom.parentNode!=this.contentDOM;r++,d=!1);return l&&d&&!l.border&&!l.domAtom?l.domFromPos(0,t):{node:this.contentDOM,offset:l?Jt(l.dom):this.contentDOM.childNodes.length}}},{key:"parseRange",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(0==this.children.length)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};for(var r=-1,i=-1,o=n,s=0;;s++){var a=this.children[s],c=o+a.size;if(-1==r&&e<=c){var u=o+a.border;if(e>=u&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,u);e=o;for(var l=s;l>0;l--){var d=this.children[l-1];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(1)){r=Jt(d.dom)+1;break}e-=d.size}-1==r&&(r=0)}if(r>-1&&(c>t||s==this.children.length-1)){t=c;for(var h=s+1;h<this.children.length;h++){var f=this.children[h];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){i=Jt(f.dom);break}t+=f.size}-1==i&&(i=this.contentDOM.childNodes.length);break}o=c}return{node:this.contentDOM,from:e,to:t,fromOffset:r,toOffset:i}}},{key:"emptyChildAt",value:function(e){if(this.border||!this.contentDOM||!this.children.length)return!1;var t=this.children[e<0?0:this.children.length-1];return 0==t.size||t.emptyChildAt(e)}},{key:"domAfterPos",value:function(e){var t=this.domFromPos(e,0),n=t.node,r=t.offset;if(1!=n.nodeType||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}},{key:"setSelection",value:function(e,t,n){for(var r=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=Math.min(e,t),o=Math.max(e,t),s=0,a=0;s<this.children.length;s++){var c=this.children[s],u=a+c.size;if(i>a&&o<u)return c.setSelection(e-a-c.border,t-a-c.border,n,r);a=u}var l=this.domFromPos(e,e?-1:1),d=t==e?l:this.domFromPos(t,t?-1:1),h=n.getSelection(),f=!1;if((dn||vn)&&e==t){var p=l,v=p.node,m=p.offset;if(3==v.nodeType){if((f=!(!m||"\n"!=v.nodeValue[m-1]))&&m==v.nodeValue.length)for(var g,y=v;y;y=y.parentNode){if(g=y.nextSibling){"BR"==g.nodeName&&(l=d={node:g.parentNode,offset:Jt(g)+1});break}var k=y.pmViewDesc;if(k&&k.node&&k.node.isBlock)break}}else{var w=v.childNodes[m-1];f=w&&("BR"==w.nodeName||"false"==w.contentEditable)}}if(dn&&h.focusNode&&h.focusNode!=d.node&&1==h.focusNode.nodeType){var b=h.focusNode.childNodes[h.focusOffset];b&&"false"==b.contentEditable&&(r=!0)}if(r||f&&vn||!_t(l.node,l.offset,h.anchorNode,h.anchorOffset)||!_t(d.node,d.offset,h.focusNode,h.focusOffset)){var x=!1;if((h.extend||e==t)&&!f){h.collapse(l.node,l.offset);try{e!=t&&h.extend(d.node,d.offset),x=!0}catch(e){}}if(!x){if(e>t){var M=l;l=d,d=M}var S=document.createRange();S.setEnd(d.node,d.offset),S.setStart(l.node,l.offset),h.removeAllRanges(),h.addRange(S)}}}},{key:"ignoreMutation",value:function(e){return!this.contentDOM&&"selection"!=e.type}},{key:"contentLost",get:function(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}},{key:"markDirty",value:function(e,t){for(var n=0,r=0;r<this.children.length;r++){var i=this.children[r],o=n+i.size;if(n==o?e<=o&&t>=n:e<o&&t>n){var s=n+i.border,a=o-i.border;if(e>=s&&t<=a)return this.dirty=e==n||t==o?2:1,void(e!=s||t!=a||!i.contentLost&&i.dom.parentNode==this.contentDOM?i.markDirty(e-s,t-s):i.dirty=3);i.dirty=i.dom!=i.contentDOM||i.dom.parentNode!=this.contentDOM||i.children.length?3:2}n=o}this.dirty=2}},{key:"markParentsDirty",value:function(){for(var e=1,t=this.parent;t;t=t.parent,e++){var n=1==e?2:1;t.dirty<n&&(t.dirty=n)}}},{key:"domAtom",get:function(){return!1}},{key:"ignoreForCoords",get:function(){return!1}}]),e}(),Hn=function(e){(0,d.Z)(n,e);var t=b(n);function n(e,r,i,o){var a;(0,v.Z)(this,n);var c,u=r.type.toDOM;if("function"==typeof u&&(u=u(i,(function(){return c?c.parent?c.parent.posBeforeChild(c):void 0:o}))),!r.type.spec.raw){if(1!=u.nodeType){var l=document.createElement("span");l.appendChild(u),u=l}u.contentEditable="false",u.classList.add("ProseMirror-widget")}return(a=t.call(this,e,[],u,null)).widget=r,a.widget=r,c=(0,s.Z)(a),a}return(0,m.Z)(n,[{key:"matchesWidget",value:function(e){return 0==this.dirty&&e.type.eq(this.widget.type)}},{key:"parseRule",value:function(){return{ignore:!0}}},{key:"stopEvent",value:function(e){var t=this.widget.spec.stopEvent;return!!t&&t(e)}},{key:"ignoreMutation",value:function(e){return"selection"!=e.type||this.widget.spec.ignoreSelection}},{key:"destroy",value:function(){this.widget.type.destroy(this.dom),l((0,c.Z)(n.prototype),"destroy",this).call(this)}},{key:"domAtom",get:function(){return!0}},{key:"side",get:function(){return this.widget.type.side}}]),n}(jn),Jn=function(e){(0,d.Z)(n,e);var t=b(n);function n(e,r,i,o){var s;return(0,v.Z)(this,n),(s=t.call(this,e,[],r,null)).textDOM=i,s.text=o,s}return(0,m.Z)(n,[{key:"size",get:function(){return this.text.length}},{key:"localPosFromDOM",value:function(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}},{key:"domFromPos",value:function(e){return{node:this.textDOM,offset:e}}},{key:"ignoreMutation",value:function(e){return"characterData"===e.type&&e.target.nodeValue==e.oldValue}}]),n}(jn),qn=function(e){(0,d.Z)(n,e);var t=b(n);function n(e,r,i,o){var s;return(0,v.Z)(this,n),(s=t.call(this,e,[],i,o)).mark=r,s}return(0,m.Z)(n,[{key:"parseRule",value:function(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM||void 0}}},{key:"matchesMark",value:function(e){return 3!=this.dirty&&this.mark.eq(e)}},{key:"markDirty",value:function(e,t){if(l((0,c.Z)(n.prototype),"markDirty",this).call(this,e,t),0!=this.dirty){for(var r=this.parent;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=0}}},{key:"slice",value:function(e,t,r){var i=n.create(this.parent,this.mark,!0,r),o=this.children,s=this.size;t<s&&(o=ur(o,t,s,r)),e>0&&(o=ur(o,0,e,r));for(var a=0;a<o.length;a++)o[a].parent=i;return i.children=o,i}}],[{key:"create",value:function(e,t,r,i){var o=i.nodeViews[t.type.name],s=o&&o(t,i,r);return s&&s.dom||(s=Oe.renderSpec(document,t.type.spec.toDOM(t,r))),new n(e,t,s.dom,s.contentDOM||s.dom)}}]),n}(jn),Wn=function(e){(0,d.Z)(n,e);var t=b(n);function n(e,r,i,o,s,a,c,u,l){var d;return(0,v.Z)(this,n),(d=t.call(this,e,[],s,a)).node=r,d.outerDeco=i,d.innerDeco=o,d.nodeDOM=c,a&&d.updateChildren(u,l),d}return(0,m.Z)(n,[{key:"parseRule",value:function(){var e=this;if(this.node.type.spec.reparseInView)return null;var t={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(t.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(var n=this.children.length-1;n>=0;n--){var r=this.children[n];if(this.dom.contains(r.dom.parentNode)){t.contentElement=r.dom.parentNode;break}}t.contentElement||(t.getContent=function(){return C.empty})}else t.contentElement=this.contentDOM;else t.getContent=function(){return e.node.content};return t}},{key:"matchesNode",value:function(e,t,n){return 0==this.dirty&&e.eq(this.node)&&or(t,this.outerDeco)&&n.eq(this.innerDeco)}},{key:"size",get:function(){return this.node.nodeSize}},{key:"border",get:function(){return this.node.isLeaf?0:1}},{key:"updateChildren",value:function(e,t){var n=this,r=this.node.inlineContent,i=t,o=e.composing?this.localCompositionInfo(e,t):null,s=o&&o.pos>-1?o:null,a=o&&o.pos<0,c=new ar(this,s&&s.node,e);!function(e,t,n,r){var i=t.locals(e),o=0;if(0!=i.length)for(var s=0,a=[],c=null,u=0;;){if(s<i.length&&i[s].to==o){for(var l=i[s++],d=void 0;s<i.length&&i[s].to==o;)(d||(d=[l])).push(i[s++]);if(d){d.sort(cr);for(var h=0;h<d.length;h++)n(d[h],u,!!c)}else n(l,u,!!c)}var f=void 0,p=void 0;if(c)p=-1,f=c,c=null;else{if(!(u<e.childCount))break;p=u,f=e.child(u++)}for(var v=0;v<a.length;v++)a[v].to<=o&&a.splice(v--,1);for(;s<i.length&&i[s].from<=o&&i[s].to>o;)a.push(i[s++]);var m=o+f.nodeSize;if(f.isText){var g=m;s<i.length&&i[s].from<g&&(g=i[s].from);for(var y=0;y<a.length;y++)a[y].to<g&&(g=a[y].to);g<m&&(c=f.cut(g-o),f=f.cut(0,g-o),m=g,p=-1)}r(f,f.isInline&&!f.isLeaf?a.filter((function(e){return!e.inline})):a.slice(),t.forChild(o,f),p),o=m}else for(var k=0;k<e.childCount;k++){var w=e.child(k);r(w,i,t.forChild(o,w),k),o+=w.nodeSize}}(this.node,this.innerDeco,(function(t,o,s){t.spec.marks?c.syncToMarks(t.spec.marks,r,e):t.type.side>=0&&!s&&c.syncToMarks(o==n.node.childCount?E.none:n.node.child(o).marks,r,e),c.placeWidget(t,e,i)}),(function(t,n,s,u){var l;c.syncToMarks(t.marks,r,e),c.findNodeMatch(t,n,s,u)||a&&e.state.selection.from>i&&e.state.selection.to<i+t.nodeSize&&(l=c.findIndexWithChild(o.node))>-1&&c.updateNodeAt(t,n,s,l,e)||c.updateNextNode(t,n,s,e,u)||c.addNode(t,n,s,e,i),i+=t.nodeSize})),c.syncToMarks([],r,e),this.node.isTextblock&&c.addTextblockHacks(),c.destroyRest(),(c.changed||2==this.dirty)&&(s&&this.protectLocalComposition(e,s),Yn(this.contentDOM,this.children,e),mn&&function(e){if("UL"==e.nodeName||"OL"==e.nodeName){var t=e.style.cssText;e.style.cssText=t+"; list-style: square !important",window.getComputedStyle(e).listStyle,e.style.cssText=t}}(this.dom))}},{key:"localCompositionInfo",value:function(e,t){var n=e.state.selection,r=n.from,i=n.to;if(!(e.state.selection instanceof Ct)||r<t||i>t+this.node.content.size)return null;var o=e.domSelectionRange(),s=function(e,t){for(;;){if(3==e.nodeType)return e;if(1==e.nodeType&&t>0){if(e.childNodes.length>t&&3==e.childNodes[t].nodeType)return e.childNodes[t];t=Xt(e=e.childNodes[t-1])}else{if(!(1==e.nodeType&&t<e.childNodes.length))return null;e=e.childNodes[t],t=0}}}(o.focusNode,o.focusOffset);if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){var a=s.nodeValue,c=function(e,t,n,r){for(var i=0,o=0;i<e.childCount&&o<=r;){var s=e.child(i++),a=o;if(o+=s.nodeSize,s.isText){for(var c=s.text;i<e.childCount;){var u=e.child(i++);if(o+=u.nodeSize,!u.isText)break;c+=u.text}if(o>=n){var l=a<r?c.lastIndexOf(t,r-a-1):-1;if(l>=0&&l+t.length+a>=n)return a+l;if(n==r&&c.length>=r+t.length-a&&c.slice(r-a,r-a+t.length)==t)return r}}}return-1}(this.node.content,a,r-t,i-t);return c<0?null:{node:s,pos:c,text:a}}return{node:s,pos:-1,text:""}}},{key:"protectLocalComposition",value:function(e,t){var n=t.node,r=t.pos,i=t.text;if(!this.getDesc(n)){for(var o=n;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}var s=new Jn(this,o,n,i);e.input.compositionNodes.push(s),this.children=ur(this.children,r,r+i.length,e,s)}}},{key:"update",value:function(e,t,n,r){return!(3==this.dirty||!e.sameMarkup(this.node)||(this.updateInner(e,t,n,r),0))}},{key:"updateInner",value:function(e,t,n,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=0}},{key:"updateOuterDeco",value:function(e){if(!or(e,this.outerDeco)){var t=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=nr(this.dom,this.nodeDOM,tr(this.outerDeco,this.node,t),tr(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}}},{key:"selectNode",value:function(){1==this.nodeDOM.nodeType&&this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.dom.draggable=!0)}},{key:"deselectNode",value:function(){1==this.nodeDOM.nodeType&&this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||this.dom.removeAttribute("draggable")}},{key:"domAtom",get:function(){return this.node.isAtom}}],[{key:"create",value:function(e,t,r,i,o,s){var a,c=o.nodeViews[t.type.name],u=c&&c(t,o,(function(){return a?a.parent?a.parent.posBeforeChild(a):void 0:s}),r,i),l=u&&u.dom,d=u&&u.contentDOM;if(t.isText)if(l){if(3!=l.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else l=document.createTextNode(t.text);else if(!l){var h=Oe.renderSpec(document,t.type.spec.toDOM(t));l=h.dom,d=h.contentDOM}d||t.isText||"BR"==l.nodeName||(l.hasAttribute("contenteditable")||(l.contentEditable="false"),t.type.spec.draggable&&(l.draggable=!0));var f=l;return l=ir(l,r,t),u?a=new Xn(e,t,r,i,l,d||null,f,u,o,s+1):t.isText?new Un(e,t,r,i,l,f,o):new n(e,t,r,i,l,d||null,f,o,s+1)}}]),n}(jn);function Kn(e,t,n,r,i){return ir(r,t,e),new Wn(void 0,e,t,n,r,r,r,i,0)}var Un=function(e){(0,d.Z)(n,e);var t=b(n);function n(e,r,i,o,s,a,c){return(0,v.Z)(this,n),t.call(this,e,r,i,o,s,null,a,c,0)}return(0,m.Z)(n,[{key:"parseRule",value:function(){for(var e=this.nodeDOM.parentNode;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}},{key:"update",value:function(e,t,n,r){return!(3==this.dirty||0!=this.dirty&&!this.inParent()||!e.sameMarkup(this.node)||(this.updateOuterDeco(t),0==this.dirty&&e.text==this.node.text||e.text==this.nodeDOM.nodeValue||(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=0,0))}},{key:"inParent",value:function(){for(var e=this.parent.contentDOM,t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}},{key:"domFromPos",value:function(e){return{node:this.nodeDOM,offset:e}}},{key:"localPosFromDOM",value:function(e,t,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):l((0,c.Z)(n.prototype),"localPosFromDOM",this).call(this,e,t,r)}},{key:"ignoreMutation",value:function(e){return"characterData"!=e.type&&"selection"!=e.type}},{key:"slice",value:function(e,t,r){var i=this.node.cut(e,t),o=document.createTextNode(i.text);return new n(this.parent,i,this.outerDeco,this.innerDeco,o,o,r)}},{key:"markDirty",value:function(e,t){l((0,c.Z)(n.prototype),"markDirty",this).call(this,e,t),this.dom==this.nodeDOM||0!=e&&t!=this.nodeDOM.nodeValue.length||(this.dirty=3)}},{key:"domAtom",get:function(){return!1}}]),n}(Wn),Gn=function(e){(0,d.Z)(n,e);var t=b(n);function n(){return(0,v.Z)(this,n),t.apply(this,arguments)}return(0,m.Z)(n,[{key:"parseRule",value:function(){return{ignore:!0}}},{key:"matchesHack",value:function(e){return 0==this.dirty&&this.dom.nodeName==e}},{key:"domAtom",get:function(){return!0}},{key:"ignoreForCoords",get:function(){return"IMG"==this.dom.nodeName}}]),n}(jn),Xn=function(e){(0,d.Z)(n,e);var t=b(n);function n(e,r,i,o,s,a,c,u,l,d){var h;return(0,v.Z)(this,n),(h=t.call(this,e,r,i,o,s,a,c,l,d)).spec=u,h}return(0,m.Z)(n,[{key:"update",value:function(e,t,r,i){if(3==this.dirty)return!1;if(this.spec.update){var o=this.spec.update(e,t,r);return o&&this.updateInner(e,t,r,i),o}return!(!this.contentDOM&&!e.isLeaf)&&l((0,c.Z)(n.prototype),"update",this).call(this,e,t,r,i)}},{key:"selectNode",value:function(){this.spec.selectNode?this.spec.selectNode():l((0,c.Z)(n.prototype),"selectNode",this).call(this)}},{key:"deselectNode",value:function(){this.spec.deselectNode?this.spec.deselectNode():l((0,c.Z)(n.prototype),"deselectNode",this).call(this)}},{key:"setSelection",value:function(e,t,r,i){this.spec.setSelection?this.spec.setSelection(e,t,r):l((0,c.Z)(n.prototype),"setSelection",this).call(this,e,t,r,i)}},{key:"destroy",value:function(){this.spec.destroy&&this.spec.destroy(),l((0,c.Z)(n.prototype),"destroy",this).call(this)}},{key:"stopEvent",value:function(e){return!!this.spec.stopEvent&&this.spec.stopEvent(e)}},{key:"ignoreMutation",value:function(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):l((0,c.Z)(n.prototype),"ignoreMutation",this).call(this,e)}}]),n}(Wn);function Yn(e,t,n){for(var r=e.firstChild,i=!1,o=0;o<t.length;o++){var s=t[o],a=s.dom;if(a.parentNode==e){for(;a!=r;)r=sr(r),i=!0;r=r.nextSibling}else i=!0,e.insertBefore(a,r);if(s instanceof qn){var c=r?r.previousSibling:e.lastChild;Yn(s.contentDOM,s.children,n),r=c?c.nextSibling:e.firstChild}}for(;r;)r=sr(r),i=!0;i&&n.trackWrites==e&&(n.trackWrites=null)}var Qn=function(e){e&&(this.nodeName=e)};Qn.prototype=Object.create(null);var er=[new Qn];function tr(e,t,n){if(0==e.length)return er;for(var r=n?er[0]:new Qn,i=[r],o=0;o<e.length;o++){var s=e[o].type.attrs;if(s)for(var a in s.nodeName&&i.push(r=new Qn(s.nodeName)),s){var c=s[a];null!=c&&(n&&1==i.length&&i.push(r=new Qn(t.isInline?"span":"div")),"class"==a?r.class=(r.class?r.class+" ":"")+c:"style"==a?r.style=(r.style?r.style+";":"")+c:"nodeName"!=a&&(r[a]=c))}}return i}function nr(e,t,n,r){if(n==er&&r==er)return t;for(var i=t,o=0;o<r.length;o++){var s=r[o],a=n[o];if(o){var c=void 0;a&&a.nodeName==s.nodeName&&i!=e&&(c=i.parentNode)&&c.nodeName.toLowerCase()==s.nodeName||((c=document.createElement(s.nodeName)).pmIsDeco=!0,c.appendChild(i),a=er[0]),i=c}rr(i,a||er[0],s)}return i}function rr(e,t,n){for(var r in t)"class"==r||"style"==r||"nodeName"==r||r in n||e.removeAttribute(r);for(var i in n)"class"!=i&&"style"!=i&&"nodeName"!=i&&n[i]!=t[i]&&e.setAttribute(i,n[i]);if(t.class!=n.class){for(var o=t.class?t.class.split(" ").filter(Boolean):[],s=n.class?n.class.split(" ").filter(Boolean):[],a=0;a<o.length;a++)-1==s.indexOf(o[a])&&e.classList.remove(o[a]);for(var c=0;c<s.length;c++)-1==o.indexOf(s[c])&&e.classList.add(s[c]);0==e.classList.length&&e.removeAttribute("class")}if(t.style!=n.style){if(t.style)for(var u,l=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;u=l.exec(t.style);)e.style.removeProperty(u[1]);n.style&&(e.style.cssText+=n.style)}}function ir(e,t,n){return nr(e,e,er,tr(t,n,1!=e.nodeType))}function or(e,t){if(e.length!=t.length)return!1;for(var n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function sr(e){var t=e.nextSibling;return e.parentNode.removeChild(e),t}var ar=function(){function e(t,n,r){(0,v.Z)(this,e),this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=t,this.preMatch=function(e,t){var n=t,r=n.children.length,i=e.childCount,o=new Map,s=[];e:for(;i>0;){for(var a=void 0;;)if(r){var c=n.children[r-1];if(!(c instanceof qn)){a=c,r--;break}n=c,r=c.children.length}else{if(n==t)break e;r=n.parent.children.indexOf(n),n=n.parent}var u=a.node;if(u){if(u!=e.child(i-1))break;--i,o.set(a,i),s.push(a)}}return{index:i,matched:o,matches:s.reverse()}}(t.node.content,t)}return(0,m.Z)(e,[{key:"destroyBetween",value:function(e,t){if(e!=t){for(var n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}},{key:"destroyRest",value:function(){this.destroyBetween(this.index,this.top.children.length)}},{key:"syncToMarks",value:function(e,t,n){for(var r=0,i=this.stack.length>>1,o=Math.min(i,e.length);r<o&&(r==i-1?this.top:this.stack[r+1<<1]).matchesMark(e[r])&&!1!==e[r].type.spec.spanning;)r++;for(;r<i;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),i--;for(;i<e.length;){this.stack.push(this.top,this.index+1);for(var s=-1,a=this.index;a<Math.min(this.index+3,this.top.children.length);a++){var c=this.top.children[a];if(c.matchesMark(e[i])&&!this.isLocked(c.dom)){s=a;break}}if(s>-1)s>this.index&&(this.changed=!0,this.destroyBetween(this.index,s)),this.top=this.top.children[this.index];else{var u=qn.create(this.top,e[i],t,n);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,i++}}},{key:"findNodeMatch",value:function(e,t,n,r){var i,o=-1;if(r>=this.preMatch.index&&(i=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&i.matchesNode(e,t,n))o=this.top.children.indexOf(i,this.index);else for(var s=this.index,a=Math.min(this.top.children.length,s+5);s<a;s++){var c=this.top.children[s];if(c.matchesNode(e,t,n)&&!this.preMatch.matched.has(c)){o=s;break}}return!(o<0||(this.destroyBetween(this.index,o),this.index++,0))}},{key:"updateNodeAt",value:function(e,t,n,r,i){var o=this.top.children[r];return 3==o.dirty&&o.dom==o.contentDOM&&(o.dirty=2),!!o.update(e,t,n,i)&&(this.destroyBetween(this.index,r),this.index++,!0)}},{key:"findIndexWithChild",value:function(e){for(;;){var t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){var n=e.pmViewDesc;if(n)for(var r=this.index;r<this.top.children.length;r++)if(this.top.children[r]==n)return r;return-1}e=t}}},{key:"updateNextNode",value:function(e,t,n,r,i){for(var o=this.index;o<this.top.children.length;o++){var s=this.top.children[o];if(s instanceof Wn){var a=this.preMatch.matched.get(s);if(null!=a&&a!=i)return!1;var c=s.dom;if((!this.isLocked(c)||e.isText&&s.node&&s.node.isText&&s.nodeDOM.nodeValue==e.text&&3!=s.dirty&&or(t,s.outerDeco))&&s.update(e,t,n,r))return this.destroyBetween(this.index,o),s.dom!=c&&(this.changed=!0),this.index++,!0;break}}return!1}},{key:"addNode",value:function(e,t,n,r,i){this.top.children.splice(this.index++,0,Wn.create(this.top,e,t,n,r,i)),this.changed=!0}},{key:"placeWidget",value:function(e,t,n){var r=this.index<this.top.children.length?this.top.children[this.index]:null;if(!r||!r.matchesWidget(e)||e!=r.widget&&r.widget.type.toDOM.parentNode){var i=new Hn(this.top,e,t,n);this.top.children.splice(this.index++,0,i),this.changed=!0}else this.index++}},{key:"addTextblockHacks",value:function(){for(var e=this.top.children[this.index-1],t=this.top;e instanceof qn;)e=(t=e).children[t.children.length-1];(!e||!(e instanceof Un)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((vn||fn)&&e&&"false"==e.dom.contentEditable&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}},{key:"addHackNode",value:function(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{var n=document.createElement(e);"IMG"==e&&(n.className="ProseMirror-separator",n.alt=""),"BR"==e&&(n.className="ProseMirror-trailingBreak");var r=new Gn(this.top,[],n,null);t!=this.top?t.children.push(r):t.children.splice(this.index++,0,r),this.changed=!0}}},{key:"isLocked",value:function(e){return this.lock&&(e==this.lock||1==e.nodeType&&e.contains(this.lock.parentNode))}}]),e}();function cr(e,t){return e.type.side-t.type.side}function ur(e,t,n,r,i){for(var o=[],s=0,a=0;s<e.length;s++){var c=e[s],u=a,l=a+=c.size;u>=n||l<=t?o.push(c):(u<t&&o.push(c.slice(0,t-u,r)),i&&(o.push(i),i=void 0),l>n&&o.push(c.slice(n-u,c.size,r)))}return o}function lr(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;var i=e.docView.nearestDesc(n.focusNode),o=i&&0==i.size,s=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;var a,c,u=r.resolve(s);if(en(n)){for(a=u;i&&!i.node;)i=i.parent;var l=i.node;if(i&&l.isAtom&&Tt.isSelectable(l)&&i.parent&&(!l.isInline||!Yt(n.focusNode,n.focusOffset,i.dom))){var d=i.posBefore;c=new Tt(s==d?u:r.resolve(d))}}else{var h=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(h<0)return null;a=r.resolve(h)}if(!c){var f="pointer"==t||e.state.selection.head<u.pos&&!o?1:-1;c=br(e,a,u,f)}return c}function dr(e){return e.editable?e.hasFocus():Mr(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function hr(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=e.state.selection;if(kr(e,n),dr(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&fn){var r=e.domSelectionRange(),i=e.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&_t(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset))return e.input.mouseDown.delayedSelectionSync=!0,void e.domObserver.setCurSelection()}if(e.domObserver.disconnectSelection(),e.cursorWrapper)yr(e);else{var o,s,a=n.anchor,c=n.head;!fr||n instanceof Ct||(n.$from.parent.inlineContent||(o=pr(e,n.from)),n.empty||n.$from.parent.inlineContent||(s=pr(e,n.to))),e.docView.setSelection(a,c,e.root,t),fr&&(o&&mr(o),s&&mr(s)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&gr(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}var fr=vn||fn&&pn<63;function pr(e,t){var n=e.docView.domFromPos(t,0),r=n.node,i=n.offset,o=i<r.childNodes.length?r.childNodes[i]:null,s=i?r.childNodes[i-1]:null;if(vn&&o&&"false"==o.contentEditable)return vr(o);if(!(o&&"false"!=o.contentEditable||s&&"false"!=s.contentEditable)){if(o)return vr(o);if(s)return vr(s)}}function vr(e){return e.contentEditable="true",vn&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function mr(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function gr(e){var t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);var n=e.domSelectionRange(),r=n.anchorNode,i=n.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=function(){n.anchorNode==r&&n.anchorOffset==i||(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout((function(){dr(e)&&!e.state.selection.visible||e.dom.classList.remove("ProseMirror-hideselection")}),20))})}function yr(e){var t=e.domSelection(),n=document.createRange(),r=e.cursorWrapper.dom,i="IMG"==r.nodeName;i?n.setEnd(r.parentNode,Jt(r)+1):n.setEnd(r,0),n.collapse(!1),t.removeAllRanges(),t.addRange(n),!i&&!e.state.selection.visible&&un&&ln<=11&&(r.disabled=!0,r.disabled=!1)}function kr(e,t){if(t instanceof Tt){var n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(wr(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else wr(e)}function wr(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function br(e,t,n,r){return e.someProp("createSelectionBetween",(function(r){return r(e,t,n)}))||Ct.between(t,n,r)}function xr(e){return!(e.editable&&!e.hasFocus())&&Mr(e)}function Mr(e){var t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(3==t.anchorNode.nodeType?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(3==t.focusNode.nodeType?t.focusNode.parentNode:t.focusNode))}catch(e){return!1}}function Sr(e,t){var n=e.selection,r=n.$anchor,i=n.$head,o=t>0?r.max(i):r.min(i),s=o.parent.inlineContent?o.depth?e.doc.resolve(t>0?o.after():o.before()):null:o;return s&&bt.findFrom(s,t)}function Cr(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function Or(e,t,n){var r=e.state.selection;if(!(r instanceof Ct)){if(r instanceof Tt&&r.node.isInline)return Cr(e,new Ct(t>0?r.$to:r.$from));var i=Sr(e.state,t);return!!i&&Cr(e,i)}if(!r.empty||n.indexOf("s")>-1)return!1;if(e.endOfTextblock(t>0?"right":"left")){var o=Sr(e.state,t);return!!(o&&o instanceof Tt)&&Cr(e,o)}if(!(gn&&n.indexOf("m")>-1)){var s,a=r.$head,c=a.textOffset?null:t<0?a.nodeBefore:a.nodeAfter;if(!c||c.isText)return!1;var u=t<0?a.pos-c.nodeSize:a.pos;return!!(c.isAtom||(s=e.docView.descAt(u))&&!s.contentDOM)&&(Tt.isSelectable(c)?Cr(e,new Tt(t<0?e.state.doc.resolve(a.pos-c.nodeSize):a)):!!kn&&Cr(e,new Ct(e.state.doc.resolve(t<0?u:u+c.nodeSize))))}}function Tr(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function Nr(e){var t=e.pmViewDesc;return t&&0==t.size&&(e.nextSibling||"BR"!=e.nodeName)}function Er(e){var t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(n){var i,o,s=!1;for(dn&&1==n.nodeType&&r<Tr(n)&&Nr(n.childNodes[r])&&(s=!0);;)if(r>0){if(1!=n.nodeType)break;var a=n.childNodes[r-1];if(Nr(a))i=n,o=--r;else{if(3!=a.nodeType)break;r=(n=a).nodeValue.length}}else{if(Dr(n))break;for(var c=n.previousSibling;c&&Nr(c);)i=n.parentNode,o=Jt(c),c=c.previousSibling;if(c)r=Tr(n=c);else{if((n=n.parentNode)==e.dom)break;r=0}}s?Pr(e,n,r):i&&Pr(e,i,o)}}function Ar(e){var t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(n){for(var i,o,s=Tr(n);;)if(r<s){if(1!=n.nodeType)break;if(!Nr(n.childNodes[r]))break;i=n,o=++r}else{if(Dr(n))break;for(var a=n.nextSibling;a&&Nr(a);)i=a.parentNode,o=Jt(a)+1,a=a.nextSibling;if(a)r=0,s=Tr(n=a);else{if((n=n.parentNode)==e.dom)break;r=s=0}}i&&Pr(e,i,o)}}function Dr(e){var t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function Pr(e,t,n){var r=e.domSelection();if(en(r)){var i=document.createRange();i.setEnd(t,n),i.setStart(t,n),r.removeAllRanges(),r.addRange(i)}else r.extend&&r.extend(t,n);e.domObserver.setCurSelection();var o=e.state;setTimeout((function(){e.state==o&&hr(e)}),50)}function Ir(e,t,n){var r=e.state.selection;if(r instanceof Ct&&!r.empty||n.indexOf("s")>-1)return!1;if(gn&&n.indexOf("m")>-1)return!1;var i=r.$from,o=r.$to;if(!i.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){var s=Sr(e.state,t);if(s&&s instanceof Tt)return Cr(e,s)}if(!i.parent.inlineContent){var a=t<0?i:o,c=r instanceof Et?bt.near(a,t):bt.findFrom(a,t);return!!c&&Cr(e,c)}return!1}function Rr(e,t){if(!(e.state.selection instanceof Ct))return!0;var n=e.state.selection,r=n.$head,i=n.$anchor,o=n.empty;if(!r.sameParent(i))return!0;if(!o)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;var s=!r.textOffset&&(t<0?r.nodeBefore:r.nodeAfter);if(s&&!s.isText){var a=e.state.tr;return t<0?a.delete(r.pos-s.nodeSize,r.pos):a.delete(r.pos,r.pos+s.nodeSize),e.dispatch(a),!0}return!1}function zr(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function Br(e,t){e.someProp("transformCopied",(function(n){t=n(t,e)}));for(var n=[],r=t,i=r.content,o=r.openStart,s=r.openEnd;o>1&&s>1&&1==i.childCount&&1==i.firstChild.childCount;){o--,s--;var a=i.firstChild;n.push(a.type.name,a.attrs!=a.type.defaultAttrs?a.attrs:null),i=a.content}var c=e.someProp("clipboardSerializer")||Oe.fromSchema(e.state.schema),u=Wr(),l=u.createElement("div");l.appendChild(c.serializeFragment(i,{document:u}));for(var d,h=l.firstChild,f=0;h&&1==h.nodeType&&(d=Jr[h.nodeName.toLowerCase()]);){for(var p=d.length-1;p>=0;p--){for(var v=u.createElement(d[p]);l.firstChild;)v.appendChild(l.firstChild);l.appendChild(v),f++}h=l.firstChild}return h&&1==h.nodeType&&h.setAttribute("data-pm-slice","".concat(o," ").concat(s).concat(f?" -".concat(f):""," ").concat(JSON.stringify(n))),{dom:l,text:e.someProp("clipboardTextSerializer",(function(n){return n(t,e)}))||t.content.textBetween(0,t.content.size,"\n\n")}}function Zr(e,t,n,r,i){var o,s,a=i.parent.type.spec.code;if(!n&&!t)return null;var c=t&&(r||a||!n);if(c){if(e.someProp("transformPastedText",(function(n){t=n(t,a||r,e)})),a)return t?new D(C.from(e.state.schema.text(t.replace(/\r\n?/g,"\n"))),0,0):D.empty;var u=e.someProp("clipboardTextParser",(function(n){return n(t,i,r,e)}));if(u)s=u;else{var l=i.marks(),d=e.state.schema,h=Oe.fromSchema(d);o=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach((function(e){var t=o.appendChild(document.createElement("p"));e&&t.appendChild(h.serializeNode(d.text(e,l)))}))}}else e.someProp("transformPastedHTML",(function(t){n=t(n,e)})),o=function(e){var t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));var n,r=Wr().createElement("div"),i=/<([a-z][^>\s]+)/i.exec(e);if((n=i&&Jr[i[1].toLowerCase()])&&(e=n.map((function(e){return"<"+e+">"})).join("")+e+n.map((function(e){return"</"+e+">"})).reverse().join("")),r.innerHTML=e,n)for(var o=0;o<n.length;o++)r=r.querySelector(n[o])||r;return r}(n),kn&&function(e){for(var t=e.querySelectorAll(fn?"span:not([class]):not([style])":"span.Apple-converted-space"),n=0;n<t.length;n++){var r=t[n];1==r.childNodes.length&&" "==r.textContent&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),r)}}(o);var f=o&&o.querySelector("[data-pm-slice]"),v=f&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(f.getAttribute("data-pm-slice")||"");if(v&&v[3])for(var m=+v[3];m>0;m--){for(var g=o.firstChild;g&&1!=g.nodeType;)g=g.nextSibling;if(!g)break;o=g}if(!s){var y=e.someProp("clipboardParser")||e.someProp("domParser")||me.fromSchema(e.state.schema);s=y.parseSlice(o,{preserveWhitespace:!(!c&&!v),context:i,ruleFromNode:function(e){return"BR"!=e.nodeName||e.nextSibling||!e.parentNode||Lr.test(e.parentNode.nodeName)?null:{ignore:!0}}})}if(v)s=function(e,t){if(!e.size)return e;var n,r=e.content.firstChild.type.schema;try{n=JSON.parse(t)}catch(t){return e}for(var i=e.content,o=e.openStart,s=e.openEnd,a=n.length-2;a>=0;a-=2){var c=r.nodes[n[a]];if(!c||c.hasRequiredAttrs())break;i=C.from(c.create(n[a+1],i)),o++,s++}return new D(i,o,s)}(Hr(s,+v[1],+v[2]),v[4]);else if(s=D.maxOpen(function(e,t){if(e.childCount<2)return e;for(var n=function(n){var r=t.node(n).contentMatchAt(t.index(n)),i=void 0,o=[];if(e.forEach((function(e){if(o){var t,n=r.findWrapping(e.type);if(!n)return o=null;if(t=o.length&&i.length&&Fr(n,i,e,o[o.length-1],0))o[o.length-1]=t;else{o.length&&(o[o.length-1]=Vr(o[o.length-1],i.length));var s=$r(e,n);o.push(s),r=r.matchType(s.type),i=n}}})),o)return{v:C.from(o)}},r=t.depth;r>=0;r--){var i=n(r);if("object"===(0,p.Z)(i))return i.v}return e}(s.content,i),!0),s.openStart||s.openEnd){for(var k=0,w=0,b=s.content.firstChild;k<s.openStart&&!b.type.spec.isolating;k++,b=b.firstChild);for(var x=s.content.lastChild;w<s.openEnd&&!x.type.spec.isolating;w++,x=x.lastChild);s=Hr(s,k,w)}return e.someProp("transformPasted",(function(t){s=t(s,e)})),s}var Lr=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function $r(e,t){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=t.length-1;r>=n;r--)e=t[r].create(null,C.from(e));return e}function Fr(e,t,n,r,i){if(i<e.length&&i<t.length&&e[i]==t[i]){var o=Fr(e,t,n,r.lastChild,i+1);if(o)return r.copy(r.content.replaceChild(r.childCount-1,o));if(r.contentMatchAt(r.childCount).matchType(i==e.length-1?n.type:e[i+1]))return r.copy(r.content.append(C.from($r(n,e,i+1))))}}function Vr(e,t){if(0==t)return e;var n=e.content.replaceChild(e.childCount-1,Vr(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(C.empty,!0);return e.copy(n.append(r))}function jr(e,t,n,r,i,o){var s=t<0?e.firstChild:e.lastChild,a=s.content;return i<r-1&&(a=jr(a,t,n,r,i+1,o)),i>=n&&(a=t<0?s.contentMatchAt(0).fillBefore(a,e.childCount>1||o<=i).append(a):a.append(s.contentMatchAt(s.childCount).fillBefore(C.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,s.copy(a))}function Hr(e,t,n){return t<e.openStart&&(e=new D(jr(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new D(jr(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}var Jr={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]},qr=null;function Wr(){return qr||(qr=document.implementation.createHTMLDocument("title"))}var Kr={},_r={},Ur={touchstart:!0,touchmove:!0},Gr=(0,m.Z)((function e(){(0,v.Z)(this,e),this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastAndroidDelete=0,this.composing=!1,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}));function Xr(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function Yr(e){e.someProp("handleDOMEvents",(function(t){for(var n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=function(t){return Qr(e,t)})}))}function Qr(e,t){return e.someProp("handleDOMEvents",(function(n){var r=n[t.type];return!!r&&(r(e,t)||t.defaultPrevented)}))}function ei(e){return{left:e.clientX,top:e.clientY}}function ti(e,t,n,r,i){if(-1==r)return!1;for(var o=e.state.doc.resolve(r),s=function(r){if(e.someProp(t,(function(t){return r>o.depth?t(e,n,o.nodeAfter,o.before(r),i,!0):t(e,n,o.node(r),o.before(r),i,!1)})))return{v:!0}},a=o.depth+1;a>0;a--){var c=s(a);if("object"===(0,p.Z)(c))return c.v}return!1}function ni(e,t,n){e.focused||e.focus();var r=e.state.tr.setSelection(t);"pointer"==n&&r.setMeta("pointer",!0),e.dispatch(r)}function ri(e,t,n,r){return ti(e,"handleDoubleClickOn",t,n,r)||e.someProp("handleDoubleClick",(function(n){return n(e,t,r)}))}function ii(e,t,n,r){return ti(e,"handleTripleClickOn",t,n,r)||e.someProp("handleTripleClick",(function(n){return n(e,t,r)}))||function(e,t,n){if(0!=n.button)return!1;var r=e.state.doc;if(-1==t)return!!r.inlineContent&&(ni(e,Ct.create(r,0,r.content.size),"pointer"),!0);for(var i=r.resolve(t),o=i.depth+1;o>0;o--){var s=o>i.depth?i.nodeAfter:i.node(o),a=i.before(o);if(s.inlineContent)ni(e,Ct.create(r,a+1,a+1+s.content.size),"pointer");else{if(!Tt.isSelectable(s))continue;ni(e,Tt.create(r,a),"pointer")}return!0}}(e,n,r)}function oi(e){return hi(e)}_r.keydown=function(e,t){var n=t;if(e.input.shiftKey=16==n.keyCode||n.shiftKey,!ci(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!yn||!fn||13!=n.keyCode))if(229!=n.keyCode&&e.domObserver.forceFlush(),!mn||13!=n.keyCode||n.ctrlKey||n.altKey||n.metaKey)e.someProp("handleKeyDown",(function(t){return t(e,n)}))||function(e,t){var n=t.keyCode,r=function(e){var t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}(t);return 8==n||gn&&72==n&&"c"==r?Rr(e,-1)||Er(e):46==n||gn&&68==n&&"c"==r?Rr(e,1)||Ar(e):13==n||27==n||(37==n||gn&&66==n&&"c"==r?Or(e,-1,r)||Er(e):39==n||gn&&70==n&&"c"==r?Or(e,1,r)||Ar(e):38==n||gn&&80==n&&"c"==r?Ir(e,-1,r)||Er(e):40==n||gn&&78==n&&"c"==r?function(e){if(!vn||e.state.selection.$head.parentOffset>0)return!1;var t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(n&&1==n.nodeType&&0==r&&n.firstChild&&"false"==n.firstChild.contentEditable){var i=n.firstChild;zr(e,i,"true"),setTimeout((function(){return zr(e,i,"false")}),20)}return!1}(e)||Ir(e,1,r)||Ar(e):r==(gn?"m":"c")&&(66==n||73==n||89==n||90==n))}(e,n)?n.preventDefault():Xr(e,"key");else{var r=Date.now();e.input.lastIOSEnter=r,e.input.lastIOSEnterFallbackTimeout=setTimeout((function(){e.input.lastIOSEnter==r&&(e.someProp("handleKeyDown",(function(t){return t(e,tn(13,"Enter"))})),e.input.lastIOSEnter=0)}),200)}},_r.keyup=function(e,t){16==t.keyCode&&(e.input.shiftKey=!1)},_r.keypress=function(e,t){var n=t;if(!(ci(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||gn&&n.metaKey))if(e.someProp("handleKeyPress",(function(t){return t(e,n)})))n.preventDefault();else{var r=e.state.selection;if(!(r instanceof Ct&&r.$from.sameParent(r.$to))){var i=String.fromCharCode(n.charCode);/[\r\n]/.test(i)||e.someProp("handleTextInput",(function(t){return t(e,r.$from.pos,r.$to.pos,i)}))||e.dispatch(e.state.tr.insertText(i).scrollIntoView()),n.preventDefault()}}};var si=gn?"metaKey":"ctrlKey";Kr.mousedown=function(e,t){var n=t;e.input.shiftKey=n.shiftKey;var r=oi(e),i=Date.now(),o="singleClick";i-e.input.lastClick.time<500&&function(e,t){var n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}(n,e.input.lastClick)&&!n[si]&&("singleClick"==e.input.lastClick.type?o="doubleClick":"doubleClick"==e.input.lastClick.type&&(o="tripleClick")),e.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:o};var s=e.posAtCoords(ei(n));s&&("singleClick"==o?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new ai(e,s,n,!!r)):("doubleClick"==o?ri:ii)(e,s.pos,s.inside,n)?n.preventDefault():Xr(e,"pointer"))};var ai=function(){function e(t,n,r,i){var o,s,a=this;if((0,v.Z)(this,e),this.view=t,this.pos=n,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=t.state.doc,this.selectNode=!!r[si],this.allowDefault=r.shiftKey,n.inside>-1)o=t.state.doc.nodeAt(n.inside),s=n.inside;else{var c=t.state.doc.resolve(n.pos);o=c.parent,s=c.depth?c.before():0}var u=i?null:r.target,l=u?t.docView.nearestDesc(u,!0):null;this.target=l?l.dom:null;var d=t.state.selection;(0==r.button&&o.type.spec.draggable&&!1!==o.type.spec.selectable||d instanceof Tt&&d.from<=s&&d.to>s)&&(this.mightDrag={node:o,pos:s,addAttr:!(!this.target||this.target.draggable),setUneditable:!(!this.target||!dn||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(){a.view.input.mouseDown==a&&a.target.setAttribute("contentEditable","false")}),20),this.view.domObserver.start()),t.root.addEventListener("mouseup",this.up=this.up.bind(this)),t.root.addEventListener("mousemove",this.move=this.move.bind(this)),Xr(t,"pointer")}return(0,m.Z)(e,[{key:"done",value:function(){var e=this;this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout((function(){return hr(e.view)})),this.view.input.mouseDown=null}},{key:"up",value:function(e){if(this.done(),this.view.dom.contains(e.target)){var t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(ei(e))),this.updateAllowDefault(e),this.allowDefault||!t?Xr(this.view,"pointer"):function(e,t,n,r,i){return ti(e,"handleClickOn",t,n,r)||e.someProp("handleClick",(function(n){return n(e,t,r)}))||(i?function(e,t){if(-1==t)return!1;var n,r,i=e.state.selection;i instanceof Tt&&(n=i.node);for(var o=e.state.doc.resolve(t),s=o.depth+1;s>0;s--){var a=s>o.depth?o.nodeAfter:o.node(s);if(Tt.isSelectable(a)){r=n&&i.$from.depth>0&&s>=i.$from.depth&&o.before(i.$from.depth+1)==i.$from.pos?o.before(i.$from.depth):o.before(s);break}}return null!=r&&(ni(e,Tt.create(e.state.doc,r),"pointer"),!0)}(e,n):function(e,t){if(-1==t)return!1;var n=e.state.doc.resolve(t),r=n.nodeAfter;return!!(r&&r.isAtom&&Tt.isSelectable(r))&&(ni(e,new Tt(n),"pointer"),!0)}(e,n))}(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():0==e.button&&(this.flushed||vn&&this.mightDrag&&!this.mightDrag.node.isAtom||fn&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(ni(this.view,bt.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):Xr(this.view,"pointer")}}},{key:"move",value:function(e){this.updateAllowDefault(e),Xr(this.view,"pointer"),0==e.buttons&&this.done()}},{key:"updateAllowDefault",value:function(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}]),e}();function ci(e,t){return!!e.composing||!!(vn&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500)&&(e.input.compositionEndedAt=-2e8,!0)}Kr.touchstart=function(e){e.input.lastTouch=Date.now(),oi(e),Xr(e,"pointer")},Kr.touchmove=function(e){e.input.lastTouch=Date.now(),Xr(e,"pointer")},Kr.contextmenu=function(e){return oi(e)};var ui=yn?5e3:-1;function li(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout((function(){return hi(e)}),t))}function di(e){var t;for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=((t=document.createEvent("Event")).initEvent("event",!0,!0),t.timeStamp));e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function hi(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!(yn&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),di(e),t||e.docView&&e.docView.dirty){var n=lr(e);return n&&!n.eq(e.state.selection)?e.dispatch(e.state.tr.setSelection(n)):e.updateState(e.state),!0}return!1}}_r.compositionstart=_r.compositionupdate=function(e){if(!e.composing){e.domObserver.flush();var t=e.state,n=t.selection.$from;if(t.selection.empty&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some((function(e){return!1===e.type.spec.inclusive}))))e.markCursor=e.state.storedMarks||n.marks(),hi(e,!0),e.markCursor=null;else if(hi(e),dn&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length)for(var r=e.domSelectionRange(),i=r.focusNode,o=r.focusOffset;i&&1==i.nodeType&&0!=o;){var s=o<0?i.lastChild:i.childNodes[o-1];if(!s)break;if(3==s.nodeType){e.domSelection().collapse(s,s.nodeValue.length);break}i=s,o=-1}e.input.composing=!0}li(e,ui)},_r.compositionend=function(e,t){e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,li(e,20))};var fi=un&&ln<15||mn&&wn<604;function pi(e,t,n,r,i){var o=Zr(e,t,n,r,e.state.selection.$from);if(e.someProp("handlePaste",(function(t){return t(e,i,o||D.empty)})))return!0;if(!o)return!1;var s=function(e){return 0==e.openStart&&0==e.openEnd&&1==e.content.childCount?e.content.firstChild:null}(o),a=s?e.state.tr.replaceSelectionWith(s,e.input.shiftKey):e.state.tr.replaceSelection(o);return e.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}Kr.copy=_r.cut=function(e,t){var n=t,r=e.state.selection,i="cut"==n.type;if(!r.empty){var o=fi?null:n.clipboardData,s=Br(e,r.content()),a=s.dom,c=s.text;o?(n.preventDefault(),o.clearData(),o.setData("text/html",a.innerHTML),o.setData("text/plain",c)):function(e,t){if(e.dom.parentNode){var n=e.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(t),n.style.cssText="position: fixed; left: -10000px; top: 10px";var r=getSelection(),i=document.createRange();i.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout((function(){n.parentNode&&n.parentNode.removeChild(n),e.focus()}),50)}}(e,a),i&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))}},_r.paste=function(e,t){var n=t;if(!e.composing||yn){var r=fi?null:n.clipboardData;r&&pi(e,r.getData("text/plain"),r.getData("text/html"),e.input.shiftKey,n)?n.preventDefault():function(e,t){if(e.dom.parentNode){var n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus(),setTimeout((function(){e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?pi(e,r.value,null,e.input.shiftKey,t):pi(e,r.textContent,r.innerHTML,e.input.shiftKey,t)}),50)}}(e,n)}};var vi=(0,m.Z)((function e(t,n){(0,v.Z)(this,e),this.slice=t,this.move=n})),mi=gn?"altKey":"ctrlKey";for(var gi in Kr.dragstart=function(e,t){var n=t,r=e.input.mouseDown;if(r&&r.done(),n.dataTransfer){var i=e.state.selection,o=i.empty?null:e.posAtCoords(ei(n));if(o&&o.pos>=i.from&&o.pos<=(i instanceof Tt?i.to-1:i.to));else if(r&&r.mightDrag)e.dispatch(e.state.tr.setSelection(Tt.create(e.state.doc,r.mightDrag.pos)));else if(n.target&&1==n.target.nodeType){var s=e.docView.nearestDesc(n.target,!0);s&&s.node.type.spec.draggable&&s!=e.docView&&e.dispatch(e.state.tr.setSelection(Tt.create(e.state.doc,s.posBefore)))}var a=e.state.selection.content(),c=Br(e,a),u=c.dom,l=c.text;n.dataTransfer.clearData(),n.dataTransfer.setData(fi?"Text":"text/html",u.innerHTML),n.dataTransfer.effectAllowed="copyMove",fi||n.dataTransfer.setData("text/plain",l),e.dragging=new vi(a,!n[mi])}},Kr.dragend=function(e){var t=e.dragging;window.setTimeout((function(){e.dragging==t&&(e.dragging=null)}),50)},_r.dragover=_r.dragenter=function(e,t){return t.preventDefault()},_r.drop=function(e,t){var n=t,r=e.dragging;if(e.dragging=null,n.dataTransfer){var i=e.posAtCoords(ei(n));if(i){var o=e.state.doc.resolve(i.pos),s=r&&r.slice;s?e.someProp("transformPasted",(function(t){s=t(s,e)})):s=Zr(e,n.dataTransfer.getData(fi?"Text":"text/plain"),fi?null:n.dataTransfer.getData("text/html"),!1,o);var a=!(!r||n[mi]);if(e.someProp("handleDrop",(function(t){return t(e,n,s||D.empty,a)})))n.preventDefault();else if(s){n.preventDefault();var c=s?ot(e.state.doc,o.pos,s):o.pos;null==c&&(c=o.pos);var u=e.state.tr;a&&u.deleteSelection();var l=u.mapping.map(c),d=0==s.openStart&&0==s.openEnd&&1==s.content.childCount,h=u.doc;if(d?u.replaceRangeWith(l,l,s.content.firstChild):u.replaceRange(l,l,s),!u.doc.eq(h)){var f=u.doc.resolve(l);if(d&&Tt.isSelectable(s.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(s.content.firstChild))u.setSelection(new Tt(f));else{var p=u.mapping.map(c);u.mapping.maps[u.mapping.maps.length-1].forEach((function(e,t,n,r){return p=r})),u.setSelection(br(e,f,u.doc.resolve(p)))}e.focus(),e.dispatch(u.setMeta("uiEvent","drop"))}}}}},Kr.focus=function(e){e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout((function(){e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&hr(e)}),20))},Kr.blur=function(e,t){var n=t;e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)},Kr.beforeinput=function(e,t){if(fn&&yn&&"deleteContentBackward"==t.inputType){e.domObserver.flushSoon();var n=e.input.domChangeCount;setTimeout((function(){if(e.input.domChangeCount==n&&(e.dom.blur(),e.focus(),!e.someProp("handleKeyDown",(function(t){return t(e,tn(8,"Backspace"))})))){var t=e.state.selection.$cursor;t&&t.pos>0&&e.dispatch(e.state.tr.delete(t.pos-1,t.pos).scrollIntoView())}}),50)}},_r)Kr[gi]=_r[gi];function yi(e,t){if(e==t)return!0;for(var n in e)if(e[n]!==t[n])return!1;for(var r in t)if(!(r in e))return!1;return!0}var ki=function(){function e(t,n){(0,v.Z)(this,e),this.toDOM=t,this.spec=n||Si,this.side=this.spec.side||0}return(0,m.Z)(e,[{key:"map",value:function(e,t,n,r){var i=e.mapResult(t.from+r,this.side<0?-1:1),o=i.pos;return i.deleted?null:new xi(o-n,o-n,this)}},{key:"valid",value:function(){return!0}},{key:"eq",value:function(t){return this==t||t instanceof e&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&yi(this.spec,t.spec))}},{key:"destroy",value:function(e){this.spec.destroy&&this.spec.destroy(e)}}]),e}(),wi=function(){function e(t,n){(0,v.Z)(this,e),this.attrs=t,this.spec=n||Si}return(0,m.Z)(e,[{key:"map",value:function(e,t,n,r){var i=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,o=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return i>=o?null:new xi(i,o,this)}},{key:"valid",value:function(e,t){return t.from<t.to}},{key:"eq",value:function(t){return this==t||t instanceof e&&yi(this.attrs,t.attrs)&&yi(this.spec,t.spec)}},{key:"destroy",value:function(){}}],[{key:"is",value:function(t){return t.type instanceof e}}]),e}(),bi=function(){function e(t,n){(0,v.Z)(this,e),this.attrs=t,this.spec=n||Si}return(0,m.Z)(e,[{key:"map",value:function(e,t,n,r){var i=e.mapResult(t.from+r,1);if(i.deleted)return null;var o=e.mapResult(t.to+r,-1);return o.deleted||o.pos<=i.pos?null:new xi(i.pos-n,o.pos-n,this)}},{key:"valid",value:function(e,t){var n,r=e.content.findIndex(t.from),i=r.index,o=r.offset;return o==t.from&&!(n=e.child(i)).isText&&o+n.nodeSize==t.to}},{key:"eq",value:function(t){return this==t||t instanceof e&&yi(this.attrs,t.attrs)&&yi(this.spec,t.spec)}},{key:"destroy",value:function(){}}]),e}(),xi=function(){function e(t,n,r){(0,v.Z)(this,e),this.from=t,this.to=n,this.type=r}return(0,m.Z)(e,[{key:"copy",value:function(t,n){return new e(t,n,this.type)}},{key:"eq",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}},{key:"map",value:function(e,t,n){return this.type.map(e,this,t,n)}},{key:"spec",get:function(){return this.type.spec}},{key:"inline",get:function(){return this.type instanceof wi}}],[{key:"widget",value:function(t,n,r){return new e(t,t,new ki(n,r))}},{key:"inline",value:function(t,n,r,i){return new e(t,n,new wi(r,i))}},{key:"node",value:function(t,n,r,i){return new e(t,n,new bi(r,i))}}]),e}(),Mi=[],Si={},Ci=function(){function e(t,n){(0,v.Z)(this,e),this.local=t.length?t:Mi,this.children=n.length?n:Mi}return(0,m.Z)(e,[{key:"find",value:function(e,t,n){var r=[];return this.findInner(null==e?0:e,null==t?1e9:t,r,0,n),r}},{key:"findInner",value:function(e,t,n,r,i){for(var o=0;o<this.local.length;o++){var s=this.local[o];s.from<=t&&s.to>=e&&(!i||i(s.spec))&&n.push(s.copy(s.from+r,s.to+r))}for(var a=0;a<this.children.length;a+=3)if(this.children[a]<t&&this.children[a+1]>e){var c=this.children[a]+1;this.children[a+2].findInner(e-c,t-c,n,r+c,i)}}},{key:"map",value:function(e,t,n){return this==Oi||0==e.maps.length?this:this.mapInner(e,t,0,0,n||Si)}},{key:"mapInner",value:function(t,n,r,i,o){for(var s,a=0;a<this.local.length;a++){var c=this.local[a].map(t,r,i);c&&c.type.valid(n,c)?(s||(s=[])).push(c):o.onRemove&&o.onRemove(this.local[a].spec)}return this.children.length?Ni(this.children,s||[],t,n,r,i,o):s?new e(s.sort(Ii),Mi):Oi}},{key:"add",value:function(t,n){return n.length?this==Oi?e.create(t,n):this.addInner(t,n,0):this}},{key:"addInner",value:function(t,n,r){var i,o=this,s=0;t.forEach((function(e,t){var a,c=t+r;if(a=Ai(n,e,c)){for(i||(i=o.children.slice());s<i.length&&i[s]<t;)s+=3;i[s]==t?i[s+2]=i[s+2].addInner(e,a,c+1):i.splice(s,0,t,t+e.nodeSize,Pi(a,e,c+1,Si)),s+=3}}));for(var a=Ei(s?Di(n):n,-r),c=0;c<a.length;c++)a[c].type.valid(t,a[c])||a.splice(c--,1);return new e(a.length?this.local.concat(a).sort(Ii):this.local,i||this.children)}},{key:"remove",value:function(e){return 0==e.length||this==Oi?this:this.removeInner(e,0)}},{key:"removeInner",value:function(t,n){for(var r=this.children,i=this.local,o=0;o<r.length;o+=3){for(var s,a=void 0,c=r[o]+n,u=r[o+1]+n,l=0;l<t.length;l++)(s=t[l])&&s.from>c&&s.to<u&&(t[l]=null,(a||(a=[])).push(s));if(a){r==this.children&&(r=this.children.slice());var d=r[o+2].removeInner(a,c+1);d!=Oi?r[o+2]=d:(r.splice(o,3),o-=3)}}if(i.length)for(var h,f=0;f<t.length;f++)if(h=t[f])for(var p=0;p<i.length;p++)i[p].eq(h,n)&&(i==this.local&&(i=this.local.slice()),i.splice(p--,1));return r==this.children&&i==this.local?this:i.length||r.length?new e(i,r):Oi}},{key:"forChild",value:function(t,n){if(this==Oi)return this;if(n.isLeaf)return e.empty;for(var r,i,o=0;o<this.children.length;o+=3)if(this.children[o]>=t){this.children[o]==t&&(r=this.children[o+2]);break}for(var s=t+1,a=s+n.content.size,c=0;c<this.local.length;c++){var u=this.local[c];if(u.from<a&&u.to>s&&u.type instanceof wi){var l=Math.max(s,u.from)-s,d=Math.min(a,u.to)-s;l<d&&(i||(i=[])).push(u.copy(l,d))}}if(i){var h=new e(i.sort(Ii),Mi);return r?new Ti([h,r]):h}return r||Oi}},{key:"eq",value:function(t){if(this==t)return!0;if(!(t instanceof e)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(var n=0;n<this.local.length;n++)if(!this.local[n].eq(t.local[n]))return!1;for(var r=0;r<this.children.length;r+=3)if(this.children[r]!=t.children[r]||this.children[r+1]!=t.children[r+1]||!this.children[r+2].eq(t.children[r+2]))return!1;return!0}},{key:"locals",value:function(e){return Ri(this.localsInner(e))}},{key:"localsInner",value:function(e){if(this==Oi)return Mi;if(e.inlineContent||!this.local.some(wi.is))return this.local;for(var t=[],n=0;n<this.local.length;n++)this.local[n].type instanceof wi||t.push(this.local[n]);return t}}],[{key:"create",value:function(e,t){return t.length?Pi(t,e,0,Si):Oi}}]),e}();Ci.empty=new Ci([],[]),Ci.removeOverlap=Ri;var Oi=Ci.empty,Ti=function(){function e(t){(0,v.Z)(this,e),this.members=t}return(0,m.Z)(e,[{key:"map",value:function(t,n){var r=this.members.map((function(e){return e.map(t,n,Si)}));return e.from(r)}},{key:"forChild",value:function(t,n){if(n.isLeaf)return Ci.empty;for(var r=[],i=0;i<this.members.length;i++){var o=this.members[i].forChild(t,n);o!=Oi&&(o instanceof e?r=r.concat(o.members):r.push(o))}return e.from(r)}},{key:"eq",value:function(t){if(!(t instanceof e)||t.members.length!=this.members.length)return!1;for(var n=0;n<this.members.length;n++)if(!this.members[n].eq(t.members[n]))return!1;return!0}},{key:"locals",value:function(e){for(var t,n=!0,r=0;r<this.members.length;r++){var i=this.members[r].localsInner(e);if(i.length)if(t){n&&(t=t.slice(),n=!1);for(var o=0;o<i.length;o++)t.push(i[o])}else t=i}return t?Ri(n?t:t.sort(Ii)):Mi}}],[{key:"from",value:function(t){switch(t.length){case 0:return Oi;case 1:return t[0];default:return new e(t.every((function(e){return e instanceof Ci}))?t:t.reduce((function(e,t){return e.concat(t instanceof Ci?t:t.members)}),[]))}}}]),e}();function Ni(e,t,n,r,i,o,s){for(var a=e.slice(),c=function(e,t){var r=0;n.maps[t].forEach((function(t,n,o,s){for(var c=s-o-(n-t),u=0;u<a.length;u+=3){var l=a[u+1];if(!(l<0||t>l+e-r)){var d=a[u]+e-r;n>=d?a[u+1]=t<=d?-2:-1:o>=i&&c&&(a[u]+=c,a[u+1]+=c)}}r+=c})),e=n.maps[t].map(e,-1),l=e},u=0,l=o;u<n.maps.length;u++)c(l,u);for(var d=!1,h=0;h<a.length;h+=3)if(a[h+1]<0){if(-2==a[h+1]){d=!0,a[h+1]=-1;continue}var f=n.map(e[h]+o),p=f-i;if(p<0||p>=r.content.size){d=!0;continue}var v=n.map(e[h+1]+o,-1)-i,m=r.content.findIndex(p),g=m.index,y=m.offset,k=r.maybeChild(g);if(k&&y==p&&y+k.nodeSize==v){var w=a[h+2].mapInner(n,k,f+1,e[h]+o+1,s);w!=Oi?(a[h]=p,a[h+1]=v,a[h+2]=w):(a[h+1]=-2,d=!0)}else d=!0}if(d){var b=function(e,t,n,r,i,o,s){function a(e,t){for(var o=0;o<e.local.length;o++){var c=e.local[o].map(r,i,t);c?n.push(c):s.onRemove&&s.onRemove(e.local[o].spec)}for(var u=0;u<e.children.length;u+=3)a(e.children[u+2],e.children[u]+t+1)}for(var c=0;c<e.length;c+=3)-1==e[c+1]&&a(e[c+2],t[c]+o+1);return n}(a,e,t,n,i,o,s),x=Pi(b,r,0,s);t=x.local;for(var M=0;M<a.length;M+=3)a[M+1]<0&&(a.splice(M,3),M-=3);for(var S=0,C=0;S<x.children.length;S+=3){for(var O=x.children[S];C<a.length&&a[C]<O;)C+=3;a.splice(C,0,x.children[S],x.children[S+1],x.children[S+2])}}return new Ci(t.sort(Ii),a)}function Ei(e,t){if(!t||!e.length)return e;for(var n=[],r=0;r<e.length;r++){var i=e[r];n.push(new xi(i.from+t,i.to+t,i.type))}return n}function Ai(e,t,n){if(t.isLeaf)return null;for(var r,i=n+t.nodeSize,o=null,s=0;s<e.length;s++)(r=e[s])&&r.from>n&&r.to<i&&((o||(o=[])).push(r),e[s]=null);return o}function Di(e){for(var t=[],n=0;n<e.length;n++)null!=e[n]&&t.push(e[n]);return t}function Pi(e,t,n,r){var i=[],o=!1;t.forEach((function(t,s){var a=Ai(e,t,s+n);if(a){o=!0;var c=Pi(a,t,n+s+1,r);c!=Oi&&i.push(s,s+t.nodeSize,c)}}));for(var s=Ei(o?Di(e):e,-n).sort(Ii),a=0;a<s.length;a++)s[a].type.valid(t,s[a])||(r.onRemove&&r.onRemove(s[a].spec),s.splice(a--,1));return s.length||i.length?new Ci(s,i):Oi}function Ii(e,t){return e.from-t.from||e.to-t.to}function Ri(e){for(var t=e,n=0;n<t.length-1;n++){var r=t[n];if(r.from!=r.to)for(var i=n+1;i<t.length;i++){var o=t[i];if(o.from!=r.from){o.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,o.from),zi(t,i,r.copy(o.from,r.to)));break}o.to!=r.to&&(t==e&&(t=e.slice()),t[i]=o.copy(o.from,r.to),zi(t,i+1,o.copy(r.to,o.to)))}}return t}function zi(e,t,n){for(;t<e.length&&Ii(n,e[t])>0;)t++;e.splice(t,0,n)}function Bi(e){var t=[];return e.someProp("decorations",(function(n){var r=n(e.state);r&&r!=Oi&&t.push(r)})),e.cursorWrapper&&t.push(Ci.create(e.state.doc,[e.cursorWrapper.deco])),Ti.from(t)}var Zi={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Li=un&&ln<=11,$i=function(){function e(){(0,v.Z)(this,e),this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}return(0,m.Z)(e,[{key:"set",value:function(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}},{key:"clear",value:function(){this.anchorNode=this.focusNode=null}},{key:"eq",value:function(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}]),e}(),Fi=function(){function e(t,n){var r=this;(0,v.Z)(this,e),this.view=t,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new $i,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.observer=window.MutationObserver&&new window.MutationObserver((function(e){for(var t=0;t<e.length;t++)r.queue.push(e[t]);un&&ln<=11&&e.some((function(e){return"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length}))?r.flushSoon():r.flush()})),Li&&(this.onCharData=function(e){r.queue.push({target:e.target,type:"characterData",oldValue:e.prevValue}),r.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}return(0,m.Z)(e,[{key:"flushSoon",value:function(){var e=this;this.flushingSoon<0&&(this.flushingSoon=window.setTimeout((function(){e.flushingSoon=-1,e.flush()}),20))}},{key:"forceFlush",value:function(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}},{key:"start",value:function(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Zi)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}},{key:"stop",value:function(){var e=this;if(this.observer){var t=this.observer.takeRecords();if(t.length){for(var n=0;n<t.length;n++)this.queue.push(t[n]);window.setTimeout((function(){return e.flush()}),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}},{key:"connectSelection",value:function(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}},{key:"disconnectSelection",value:function(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}},{key:"suppressSelectionUpdates",value:function(){var e=this;this.suppressingSelectionUpdates=!0,setTimeout((function(){return e.suppressingSelectionUpdates=!1}),50)}},{key:"onSelectionChange",value:function(){if(xr(this.view)){if(this.suppressingSelectionUpdates)return hr(this.view);if(un&&ln<=11&&!this.view.state.selection.empty){var e=this.view.domSelectionRange();if(e.focusNode&&_t(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}},{key:"setCurSelection",value:function(){this.currentSelection.set(this.view.domSelectionRange())}},{key:"ignoreSelectionChange",value:function(e){if(!e.focusNode)return!0;for(var t,n=new Set,r=e.focusNode;r;r=qt(r))n.add(r);for(var i=e.anchorNode;i;i=qt(i))if(n.has(i)){t=i;break}var o=t&&this.view.docView.nearestDesc(t);return o&&o.ignoreMutation({type:"selection",target:3==t.nodeType?t.parentNode:t})?(this.setCurSelection(),!0):void 0}},{key:"flush",value:function(){var e=this.view;if(e.docView&&!(this.flushingSoon>-1)){var t=this.observer?this.observer.takeRecords():[];this.queue.length&&(t=this.queue.concat(t),this.queue.length=0);var n=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&xr(e)&&!this.ignoreSelectionChange(n),i=-1,o=-1,s=!1,a=[];if(e.editable)for(var c=0;c<t.length;c++){var u=this.registerMutation(t[c],a);u&&(i=i<0?u.from:Math.min(u.from,i),o=o<0?u.to:Math.max(u.to,o),u.typeOver&&(s=!0))}if(dn&&a.length>1){var l=a.filter((function(e){return"BR"==e.nodeName}));if(2==l.length){var d=l[0],h=l[1];d.parentNode&&d.parentNode.parentNode==h.parentNode?h.remove():d.remove()}}var f=null;i<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&en(n)&&(f=lr(e))&&f.eq(bt.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,hr(e),this.currentSelection.set(n),e.scrollToSelection()):(i>-1||r)&&(i>-1&&(e.docView.markDirty(i,o),function(e){if(!Vi.has(e)&&(Vi.set(e,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace))){if(e.requiresGeckoHackNode=dn,ji)return;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."),ji=!0}}(e)),this.handleDOMChange(i,o,s,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||hr(e),this.currentSelection.set(n))}}},{key:"registerMutation",value:function(e,t){if(t.indexOf(e.target)>-1)return null;var n=this.view.docView.nearestDesc(e.target);if("attributes"==e.type&&(n==this.view.docView||"contenteditable"==e.attributeName||"style"==e.attributeName&&!e.oldValue&&!e.target.getAttribute("style")))return null;if(!n||n.ignoreMutation(e))return null;if("childList"==e.type){for(var r=0;r<e.addedNodes.length;r++)t.push(e.addedNodes[r]);if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};var i=e.previousSibling,o=e.nextSibling;if(un&&ln<=11&&e.addedNodes.length)for(var s=0;s<e.addedNodes.length;s++){var a=e.addedNodes[s],c=a.previousSibling,u=a.nextSibling;(!c||Array.prototype.indexOf.call(e.addedNodes,c)<0)&&(i=c),(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(o=u)}var l=i&&i.parentNode==e.target?Jt(i)+1:0,d=n.localPosFromDOM(e.target,l,-1),h=o&&o.parentNode==e.target?Jt(o):e.target.childNodes.length;return{from:d,to:n.localPosFromDOM(e.target,h,1)}}return"attributes"==e.type?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}}}]),e}(),Vi=new WeakMap,ji=!1;function Hi(e){var t=e.pmViewDesc;if(t)return t.parseRule();if("BR"==e.nodeName&&e.parentNode){if(vn&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){var n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}if(e.parentNode.lastChild==e||vn&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if("IMG"==e.nodeName&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null}function Ji(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:br(e,t.resolve(n.anchor),t.resolve(n.head))}function qi(e,t,n){for(var r=e.depth,i=t?e.end():e.pos;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,i++,t=!1;if(n)for(var o=e.node(r).maybeChild(e.indexAfter(r));o&&!o.isLeaf;)o=o.firstChild,i++;return i}var Wi=function(){function e(t,n){var r=this;(0,v.Z)(this,e),this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new Gr,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(Xi),this.dispatch=this.dispatch.bind(this),this.dom=t&&t.mount||document.createElement("div"),t&&(t.appendChild?t.appendChild(this.dom):"function"==typeof t?t(this.dom):t.mount&&(this.mounted=!0)),this.editable=Ui(this),_i(this),this.nodeViews=Gi(this),this.docView=Kn(this.state.doc,Ki(this),Bi(this),this.dom,this),this.domObserver=new Fi(this,(function(e,t,n,i){return function(e,t,n,r,i){if(t<0){var o=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,s=lr(e,o);if(s&&!e.state.selection.eq(s)){if(fn&&yn&&13===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp("handleKeyDown",(function(t){return t(e,tn(13,"Enter"))})))return;var a=e.state.tr.setSelection(s);"pointer"==o?a.setMeta("pointer",!0):"key"==o&&a.scrollIntoView(),e.dispatch(a)}}else{var c=e.state.doc.resolve(t),u=c.sharedDepth(n);t=c.before(u+1),n=e.state.doc.resolve(n).after(u+1);var l,d,h=e.state.selection,f=function(e,t,n){var r,i=e.docView.parseRange(t,n),o=i.node,s=i.fromOffset,a=i.toOffset,c=i.from,u=i.to,l=e.domSelectionRange(),d=l.anchorNode;if(d&&e.dom.contains(1==d.nodeType?d:d.parentNode)&&(r=[{node:d,offset:l.anchorOffset}],en(l)||r.push({node:l.focusNode,offset:l.focusOffset})),fn&&8===e.input.lastKeyCode)for(var h=a;h>s;h--){var f=o.childNodes[h-1],p=f.pmViewDesc;if("BR"==f.nodeName&&!p){a=h;break}if(!p||p.size)break}var v=e.state.doc,m=e.someProp("domParser")||me.fromSchema(e.state.schema),g=v.resolve(c),y=null,k=m.parse(o,{topNode:g.parent,topMatch:g.parent.contentMatchAt(g.index()),topOpen:!0,from:s,to:a,preserveWhitespace:"pre"!=g.parent.type.whitespace||"full",findPositions:r,ruleFromNode:Hi,context:g});if(r&&null!=r[0].pos){var w=r[0].pos,b=r[1]&&r[1].pos;null==b&&(b=w),y={anchor:w+c,head:b+c}}return{doc:k,sel:y,from:c,to:u}}(e,t,n),p=e.state.doc,v=p.slice(f.from,f.to);8===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime?(l=e.state.selection.to,d="end"):(l=e.state.selection.from,d="start"),e.input.lastKeyCode=null;var m=function(e,t,n,r,i){var o=e.findDiffStart(t,n);if(null==o)return null;var s=e.findDiffEnd(t,n+e.size,n+t.size),a=s.a,c=s.b;return"end"==i&&(r-=a+Math.max(0,o-Math.min(a,c))-o),a<o&&e.size<t.size?(c=(o-=r<=o&&r>=a?o-r:0)+(c-a),a=o):c<o&&(a=(o-=r<=o&&r>=c?o-r:0)+(a-c),c=o),{start:o,endA:a,endB:c}}(v.content,f.doc.content,f.from,l,d);if((mn&&e.input.lastIOSEnter>Date.now()-225||yn)&&i.some((function(e){return"DIV"==e.nodeName||"P"==e.nodeName||"LI"==e.nodeName}))&&(!m||m.endA>=m.endB)&&e.someProp("handleKeyDown",(function(t){return t(e,tn(13,"Enter"))})))e.input.lastIOSEnter=0;else{if(!m){if(!(r&&h instanceof Ct&&!h.empty&&h.$head.sameParent(h.$anchor))||e.composing||f.sel&&f.sel.anchor!=f.sel.head){if(f.sel){var g=Ji(e,e.state.doc,f.sel);g&&!g.eq(e.state.selection)&&e.dispatch(e.state.tr.setSelection(g))}return}m={start:h.from,endA:h.to,endB:h.to}}if(fn&&e.cursorWrapper&&f.sel&&f.sel.anchor==e.cursorWrapper.deco.from&&f.sel.head==f.sel.anchor){var y=m.endB-m.start;f.sel={anchor:f.sel.anchor+y,head:f.sel.anchor+y}}e.input.domChangeCount++,e.state.selection.from<e.state.selection.to&&m.start==m.endB&&e.state.selection instanceof Ct&&(m.start>e.state.selection.from&&m.start<=e.state.selection.from+2&&e.state.selection.from>=f.from?m.start=e.state.selection.from:m.endA<e.state.selection.to&&m.endA>=e.state.selection.to-2&&e.state.selection.to<=f.to&&(m.endB+=e.state.selection.to-m.endA,m.endA=e.state.selection.to)),un&&ln<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>f.from&&" "==f.doc.textBetween(m.start-f.from-1,m.start-f.from+1)&&(m.start--,m.endA--,m.endB--);var k,w=f.doc.resolveNoCache(m.start-f.from),b=f.doc.resolveNoCache(m.endB-f.from),x=p.resolve(m.start),M=w.sameParent(b)&&w.parent.inlineContent&&x.end()>=m.endA;if((mn&&e.input.lastIOSEnter>Date.now()-225&&(!M||i.some((function(e){return"DIV"==e.nodeName||"P"==e.nodeName})))||!M&&w.pos<f.doc.content.size&&(k=bt.findFrom(f.doc.resolve(w.pos+1),1,!0))&&k.head==b.pos)&&e.someProp("handleKeyDown",(function(t){return t(e,tn(13,"Enter"))})))e.input.lastIOSEnter=0;else if(e.state.selection.anchor>m.start&&function(e,t,n,r,i){if(!r.parent.isTextblock||n-t<=i.pos-r.pos||qi(r,!0,!1)<i.pos)return!1;var o=e.resolve(t);if(o.parentOffset<o.parent.content.size||!o.parent.isTextblock)return!1;var s=e.resolve(qi(o,!0,!0));return!(!s.parent.isTextblock||s.pos>n||qi(s,!0,!1)<n)&&r.parent.content.cut(r.parentOffset).eq(s.parent.content)}(p,m.start,m.endA,w,b)&&e.someProp("handleKeyDown",(function(t){return t(e,tn(8,"Backspace"))})))yn&&fn&&e.domObserver.suppressSelectionUpdates();else{fn&&yn&&m.endB==m.start&&(e.input.lastAndroidDelete=Date.now()),yn&&!M&&w.start()!=b.start()&&0==b.parentOffset&&w.depth==b.depth&&f.sel&&f.sel.anchor==f.sel.head&&f.sel.head==m.endA&&(m.endB-=2,b=f.doc.resolveNoCache(m.endB-f.from),setTimeout((function(){e.someProp("handleKeyDown",(function(t){return t(e,tn(13,"Enter"))}))}),20));var S,O,T,N=m.start,E=m.endA;if(M)if(w.pos==b.pos)un&&ln<=11&&0==w.parentOffset&&(e.domObserver.suppressSelectionUpdates(),setTimeout((function(){return hr(e)}),20)),S=e.state.tr.delete(N,E),O=p.resolve(m.start).marksAcross(p.resolve(m.endA));else if(m.endA==m.endB&&(T=function(e,t){for(var n,r,i,o=e.firstChild.marks,s=t.firstChild.marks,a=o,c=s,u=0;u<s.length;u++)a=s[u].removeFromSet(a);for(var l=0;l<o.length;l++)c=o[l].removeFromSet(c);if(1==a.length&&0==c.length)r=a[0],n="add",i=function(e){return e.mark(r.addToSet(e.marks))};else{if(0!=a.length||1!=c.length)return null;r=c[0],n="remove",i=function(e){return e.mark(r.removeFromSet(e.marks))}}for(var d=[],h=0;h<t.childCount;h++)d.push(i(t.child(h)));if(C.from(d).eq(e))return{mark:r,type:n}}(w.parent.content.cut(w.parentOffset,b.parentOffset),x.parent.content.cut(x.parentOffset,m.endA-x.start()))))S=e.state.tr,"add"==T.type?S.addMark(N,E,T.mark):S.removeMark(N,E,T.mark);else if(w.parent.child(w.index()).isText&&w.index()==b.index()-(b.textOffset?0:1)){var A=w.parent.textBetween(w.parentOffset,b.parentOffset);if(e.someProp("handleTextInput",(function(t){return t(e,N,E,A)})))return;S=e.state.tr.insertText(A,N,E)}if(S||(S=e.state.tr.replace(N,E,f.doc.slice(m.start-f.from,m.endB-f.from))),f.sel){var D=Ji(e,S.doc,f.sel);D&&!(fn&&yn&&e.composing&&D.empty&&(m.start!=m.endB||e.input.lastAndroidDelete<Date.now()-100)&&(D.head==N||D.head==S.mapping.map(E)-1)||un&&D.empty&&D.head==N)&&S.setSelection(D)}O&&S.ensureMarks(O),e.dispatch(S.scrollIntoView())}}}}(r,e,t,n,i)})),this.domObserver.start(),function(e){var t=function(t){var n=Kr[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=function(t){!function(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(var n=t.target;n!=e.dom;n=n.parentNode)if(!n||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}(e,t)||Qr(e,t)||!e.editable&&t.type in _r||n(e,t)},Ur[t]?{passive:!0}:void 0)};for(var n in Kr)t(n);vn&&e.dom.addEventListener("input",(function(){return null})),Yr(e)}(this),this.updatePluginViews()}return(0,m.Z)(e,[{key:"composing",get:function(){return this.input.composing}},{key:"props",get:function(){if(this._props.state!=this.state){var e=this._props;for(var t in this._props={},e)this._props[t]=e[t];this._props.state=this.state}return this._props}},{key:"update",value:function(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Yr(this);var t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Xi),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}},{key:"setProps",value:function(e){var t={};for(var n in this._props)t[n]=this._props[n];for(var r in t.state=this.state,e)t[r]=e[r];this.update(t)}},{key:"updateState",value:function(e){this.updateStateInner(e,this._props)}},{key:"updateStateInner",value:function(e,t){var n=this.state,r=!1,i=!1;e.storedMarks&&this.composing&&(di(this),i=!0),this.state=e;var o=n.plugins!=e.plugins||this._props.plugins!=t.plugins;if(o||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){var s=Gi(this);(function(e,t){var n=0,r=0;for(var i in e){if(e[i]!=t[i])return!0;n++}for(var o in t)r++;return n!=r})(s,this.nodeViews)&&(this.nodeViews=s,r=!0)}(o||t.handleDOMEvents!=this._props.handleDOMEvents)&&Yr(this),this.editable=Ui(this),_i(this);var a=Bi(this),c=Ki(this),u=n.plugins==e.plugins||n.doc.eq(e.doc)?e.scrollToSelection>n.scrollToSelection?"to selection":"preserve":"reset",l=r||!this.docView.matchesNode(e.doc,c,a);!l&&e.selection.eq(n.selection)||(i=!0);var d,h,f,p,v,m,g,y,k,w,b="preserve"==u&&i&&null==this.dom.style.overflowAnchor&&function(e){for(var t,n,r=e.dom.getBoundingClientRect(),i=Math.max(0,r.top),o=(r.left+r.right)/2,s=i+1;s<Math.min(innerHeight,r.bottom);s+=5){var a=e.root.elementFromPoint(o,s);if(a&&a!=e.dom&&e.dom.contains(a)){var c=a.getBoundingClientRect();if(c.top>=i-20){t=a,n=c.top;break}}}return{refDOM:t,refTop:n,stack:Cn(e.dom)}}(this);if(i){this.domObserver.stop();var x=l&&(un||fn)&&!this.composing&&!n.selection.empty&&!e.selection.empty&&(p=n.selection,v=e.selection,m=Math.min(p.$anchor.sharedDepth(p.head),v.$anchor.sharedDepth(v.head)),p.$anchor.start(m)!=v.$anchor.start(m));if(l){var M=fn?this.trackWrites=this.domSelectionRange().focusNode:null;!r&&this.docView.update(e.doc,c,a,this)||(this.docView.updateOuterDeco([]),this.docView.destroy(),this.docView=Kn(e.doc,c,a,this.dom,this)),M&&!this.trackWrites&&(x=!0)}x||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&(d=this,h=d.docView.domFromPos(d.state.selection.anchor,0),f=d.domSelectionRange(),_t(h.node,h.offset,f.anchorNode,f.anchorOffset)))?hr(this,x):(kr(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(n),"reset"==u?this.dom.scrollTop=0:"to selection"==u?this.scrollToSelection():b&&(y=(g=b).refDOM,k=g.refTop,On(g.stack,0==(w=y?y.getBoundingClientRect().top:0)?0:w-k))}},{key:"scrollToSelection",value:function(){var e=this,t=this.domSelectionRange().focusNode;if(this.someProp("handleScrollToSelection",(function(t){return t(e)})));else if(this.state.selection instanceof Tt){var n=this.docView.domAfterPos(this.state.selection.from);1==n.nodeType&&Sn(this,n.getBoundingClientRect(),t)}else Sn(this,this.coordsAtPos(this.state.selection.head,1),t)}},{key:"destroyPluginViews",value:function(){for(var e;e=this.pluginViews.pop();)e.destroy&&e.destroy()}},{key:"updatePluginViews",value:function(e){if(e&&e.plugins==this.state.plugins&&this.directPlugins==this.prevDirectPlugins)for(var t=0;t<this.pluginViews.length;t++){var n=this.pluginViews[t];n.update&&n.update(this,e)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(var r=0;r<this.directPlugins.length;r++){var i=this.directPlugins[r];i.spec.view&&this.pluginViews.push(i.spec.view(this))}for(var o=0;o<this.state.plugins.length;o++){var s=this.state.plugins[o];s.spec.view&&this.pluginViews.push(s.spec.view(this))}}}},{key:"someProp",value:function(e,t){var n,r=this._props&&this._props[e];if(null!=r&&(n=t?t(r):r))return n;for(var i=0;i<this.directPlugins.length;i++){var o=this.directPlugins[i].props[e];if(null!=o&&(n=t?t(o):o))return n}var s=this.state.plugins;if(s)for(var a=0;a<s.length;a++){var c=s[a].props[e];if(null!=c&&(n=t?t(c):c))return n}}},{key:"hasFocus",value:function(){if(un){var e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if("false"==e.contentEditable)return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}},{key:"focus",value:function(){this.domObserver.stop(),this.editable&&function(e){if(e.setActive)return e.setActive();if(Tn)return e.focus(Tn);var t=Cn(e);e.focus(null==Tn?{get preventScroll(){return Tn={preventScroll:!0},!0}}:void 0),Tn||(Tn=!1,On(t,0))}(this.dom),hr(this),this.domObserver.start()}},{key:"root",get:function(){var e=this,t=this._root;if(null==t)for(var n=function(t){if(9==t.nodeType||11==t.nodeType&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=function(){return t.ownerDocument.getSelection()}),{v:e._root=t}},r=this.dom.parentNode;r;r=r.parentNode){var i=n(r);if("object"===(0,p.Z)(i))return i.v}return t||document}},{key:"posAtCoords",value:function(e){return Dn(this,e)}},{key:"coordsAtPos",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return Rn(this,e,t)}},{key:"domAtPos",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.docView.domFromPos(e,t)}},{key:"nodeDOM",value:function(e){var t=this.docView.descAt(e);return t?t.nodeDOM:null}},{key:"posAtDOM",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1,r=this.docView.posFromDOM(e,t,n);if(null==r)throw new RangeError("DOM position not inside the editor");return r}},{key:"endOfTextblock",value:function(e,t){return function(e,t,n){return $n==t&&Fn==n?Vn:($n=t,Fn=n,Vn="up"==n||"down"==n?function(e,t,n){var r=t.selection,i="up"==n?r.$from:r.$to;return Zn(e,t,(function(){for(var t=e.docView.domFromPos(i.pos,"up"==n?-1:1).node;;){var r=e.docView.nearestDesc(t,!0);if(!r)break;if(r.node.isBlock){t=r.contentDOM||r.dom;break}t=r.dom.parentNode}for(var o=Rn(e,i.pos,1),s=t.firstChild;s;s=s.nextSibling){var a=void 0;if(1==s.nodeType)a=s.getClientRects();else{if(3!=s.nodeType)continue;a=Kt(s,0,s.nodeValue.length).getClientRects()}for(var c=0;c<a.length;c++){var u=a[c];if(u.bottom>u.top+1&&("up"==n?o.top-u.top>2*(u.bottom-o.top):u.bottom-o.bottom>2*(o.bottom-u.top)))return!1}}return!0}))}(e,t,n):function(e,t,n){var r=t.selection.$head;if(!r.parent.isTextblock)return!1;var i=r.parentOffset,o=!i,s=i==r.parent.content.size,a=e.domSelection();return Ln.test(r.parent.textContent)&&a.modify?Zn(e,t,(function(){var t=e.domSelectionRange(),i=t.focusNode,o=t.focusOffset,s=t.anchorNode,c=t.anchorOffset,u=a.caretBidiLevel;a.modify("move",n,"character");var l=r.depth?e.docView.domAfterPos(r.before()):e.dom,d=e.domSelectionRange(),h=d.focusNode,f=d.focusOffset,p=h&&!l.contains(1==h.nodeType?h:h.parentNode)||i==h&&o==f;try{a.collapse(s,c),i&&(i!=s||o!=c)&&a.extend&&a.extend(i,o)}catch(e){}return null!=u&&(a.caretBidiLevel=u),p})):"left"==n||"backward"==n?o:s}(e,t,n))}(this,t||this.state,e)}},{key:"pasteHTML",value:function(e,t){return pi(this,"",e,!1,t||new ClipboardEvent("paste"))}},{key:"pasteText",value:function(e,t){return pi(this,e,null,!0,t||new ClipboardEvent("paste"))}},{key:"destroy",value:function(){this.docView&&(function(e){for(var t in e.domObserver.stop(),e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Bi(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null)}},{key:"isDestroyed",get:function(){return null==this.docView}},{key:"dispatchEvent",value:function(e){return function(e,t){Qr(e,t)||!Kr[t.type]||!e.editable&&t.type in _r||Kr[t.type](e,t)}(this,e)}},{key:"dispatch",value:function(e){var t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))}},{key:"domSelectionRange",value:function(){return vn&&11===this.root.nodeType&&function(e){for(var t=e.activeElement;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}(this.dom.ownerDocument)==this.dom?function(e){var t;function n(e){e.preventDefault(),e.stopImmediatePropagation(),t=e.getTargetRanges()[0]}e.dom.addEventListener("beforeinput",n,!0),document.execCommand("indent"),e.dom.removeEventListener("beforeinput",n,!0);var r=t.startContainer,i=t.startOffset,o=t.endContainer,s=t.endOffset,a=e.domAtPos(e.state.selection.anchor);if(_t(a.node,a.offset,o,s)){var c=[o,s,r,i];r=c[0],i=c[1],o=c[2],s=c[3]}return{anchorNode:r,anchorOffset:i,focusNode:o,focusOffset:s}}(this):this.domSelection()}},{key:"domSelection",value:function(){return this.root.getSelection()}}]),e}();function Ki(e){var t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(e.editable),t.translate="no",e.someProp("attributes",(function(n){if("function"==typeof n&&(n=n(e.state)),n)for(var r in n)"class"==r&&(t.class+=" "+n[r]),"style"==r?t.style=(t.style?t.style+";":"")+n[r]:t[r]||"contenteditable"==r||"nodeName"==r||(t[r]=String(n[r]))})),[xi.node(0,e.state.doc.content.size,t)]}function _i(e){if(e.markCursor){var t=document.createElement("img");t.className="ProseMirror-separator",t.setAttribute("mark-placeholder","true"),t.setAttribute("alt",""),e.cursorWrapper={dom:t,deco:xi.widget(e.state.selection.head,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function Ui(e){return!e.someProp("editable",(function(t){return!1===t(e.state)}))}function Gi(e){var t=Object.create(null);function n(e){for(var n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp("nodeViews",n),e.someProp("markViews",n),t}function Xi(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Yi={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:"'"},Qi={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},eo="undefined"!=typeof navigator&&/Chrome\/(\d+)/.exec(navigator.userAgent);"undefined"!=typeof navigator&&/Gecko\/\d+/.test(navigator.userAgent);for(var to="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),no="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),ro=to||eo&&+eo[1]<57,io=0;io<10;io++)Yi[48+io]=Yi[96+io]=String(io);for(io=1;io<=24;io++)Yi[io+111]="F"+io;for(io=65;io<=90;io++)Yi[io]=String.fromCharCode(io+32),Qi[io]=String.fromCharCode(io);for(var oo in Yi)Qi.hasOwnProperty(oo)||(Qi[oo]=Yi[oo]);var so="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform);function ao(e){var t,n,r,i,o=e.split(/-(?!$)/),s=o[o.length-1];"Space"==s&&(s=" ");for(var a=0;a<o.length-1;a++){var c=o[a];if(/^(cmd|meta|m)$/i.test(c))i=!0;else if(/^a(lt)?$/i.test(c))t=!0;else if(/^(c|ctrl|control)$/i.test(c))n=!0;else if(/^s(hift)?$/i.test(c))r=!0;else{if(!/^mod$/i.test(c))throw new Error("Unrecognized modifier name: "+c);so?i=!0:n=!0}}return t&&(s="Alt-"+s),n&&(s="Ctrl-"+s),i&&(s="Meta-"+s),r&&(s="Shift-"+s),s}function co(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),n&&t.shiftKey&&(e="Shift-"+e),e}function uo(e){var t=function(e){var t=Object.create(null);for(var n in e)t[ao(n)]=e[n];return t}(e);return function(e,n){var r,i=function(e){var t=!(ro&&(e.ctrlKey||e.altKey||e.metaKey)||no&&e.shiftKey&&e.key&&1==e.key.length||"Unidentified"==e.key)&&e.key||(e.shiftKey?Qi:Yi)[e.keyCode]||e.key||"Unidentified";return"Esc"==t&&(t="Escape"),"Del"==t&&(t="Delete"),"Left"==t&&(t="ArrowLeft"),"Up"==t&&(t="ArrowUp"),"Right"==t&&(t="ArrowRight"),"Down"==t&&(t="ArrowDown"),t}(n),o=t[co(i,n)];if(o&&o(e.state,e.dispatch,e))return!0;if(1==i.length&&" "!=i){if(n.shiftKey){var s=t[co(i,n,!1)];if(s&&s(e.state,e.dispatch,e))return!0}if((n.shiftKey||n.altKey||n.metaKey||i.charCodeAt(0)>127)&&(r=Yi[n.keyCode])&&r!=i){var a=t[co(r,n)];if(a&&a(e.state,e.dispatch,e))return!0}}return!1}}var lo=function(e,t){return!e.selection.empty&&(t&&t(e.tr.deleteSelection().scrollIntoView()),!0)},ho=function(e,t,n){var r=function(e,t){var n=e.selection.$cursor;return!n||(t?!t.endOfTextblock("backward",e):n.parentOffset>0)?null:n}(e,n);if(!r)return!1;var i=vo(r);if(!i){var o=r.blockRange(),s=o&&We(o);return null!=s&&(t&&t(e.tr.lift(o,s).scrollIntoView()),!0)}var a=i.nodeBefore;if(!a.type.spec.isolating&&Co(e,i,t))return!0;if(0==r.parent.content.size&&(fo(a,"end")||Tt.isSelectable(a))){var c=st(e.doc,r.before(),r.after(),D.empty);if(c&&c.slice.size<c.to-c.from){if(t){var u=e.tr.step(c);u.setSelection(fo(a,"end")?bt.findFrom(u.doc.resolve(u.mapping.map(i.pos,-1)),-1):Tt.create(u.doc,i.pos-a.nodeSize)),t(u.scrollIntoView())}return!0}}return!(!a.isAtom||i.depth!=r.depth-1||(t&&t(e.tr.delete(i.pos-a.nodeSize,i.pos).scrollIntoView()),0))};function fo(e,t){for(var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=e;r;r="start"==t?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&1!=r.childCount)return!1}return!1}var po=function(e,t,n){var r=e.selection,i=r.$head,o=i;if(!r.empty)return!1;if(i.parent.isTextblock){if(n?!n.endOfTextblock("backward",e):i.parentOffset>0)return!1;o=vo(i)}var s=o&&o.nodeBefore;return!(!s||!Tt.isSelectable(s)||(t&&t(e.tr.setSelection(Tt.create(e.doc,o.pos-s.nodeSize)).scrollIntoView()),0))};function vo(e){if(!e.parent.type.spec.isolating)for(var t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}var mo=function(e,t,n){var r=function(e,t){var n=e.selection.$cursor;return!n||(t?!t.endOfTextblock("forward",e):n.parentOffset<n.parent.content.size)?null:n}(e,n);if(!r)return!1;var i=yo(r);if(!i)return!1;var o=i.nodeAfter;if(Co(e,i,t))return!0;if(0==r.parent.content.size&&(fo(o,"start")||Tt.isSelectable(o))){var s=st(e.doc,r.before(),r.after(),D.empty);if(s&&s.slice.size<s.to-s.from){if(t){var a=e.tr.step(s);a.setSelection(fo(o,"start")?bt.findFrom(a.doc.resolve(a.mapping.map(i.pos)),1):Tt.create(a.doc,a.mapping.map(i.pos))),t(a.scrollIntoView())}return!0}}return!(!o.isAtom||i.depth!=r.depth-1||(t&&t(e.tr.delete(i.pos,i.pos+o.nodeSize).scrollIntoView()),0))},go=function(e,t,n){var r=e.selection,i=r.$head,o=i;if(!r.empty)return!1;if(i.parent.isTextblock){if(n?!n.endOfTextblock("forward",e):i.parentOffset<i.parent.content.size)return!1;o=yo(i)}var s=o&&o.nodeAfter;return!(!s||!Tt.isSelectable(s)||(t&&t(e.tr.setSelection(Tt.create(e.doc,o.pos)).scrollIntoView()),0))};function yo(e){if(!e.parent.type.spec.isolating)for(var t=e.depth-1;t>=0;t--){var n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}var ko=function(e,t){var n=e.selection,r=n.$from,i=n.$to,o=r.blockRange(i),s=o&&We(o);return null!=s&&(t&&t(e.tr.lift(o,s).scrollIntoView()),!0)},wo=function(e,t){var n=e.selection,r=n.$head,i=n.$anchor;return!(!r.parent.type.spec.code||!r.sameParent(i)||(t&&t(e.tr.insertText("\n").scrollIntoView()),0))};function bo(e){for(var t=0;t<e.edgeCount;t++){var n=e.edge(t).type;if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}var xo=function(e,t){var n=e.selection,r=n.$head,i=n.$anchor;if(!r.parent.type.spec.code||!r.sameParent(i))return!1;var o=r.node(-1),s=r.indexAfter(-1),a=bo(o.contentMatchAt(s));if(!a||!o.canReplaceWith(s,s,a))return!1;if(t){var c=r.after(),u=e.tr.replaceWith(c,c,a.createAndFill());u.setSelection(bt.near(u.doc.resolve(c),1)),t(u.scrollIntoView())}return!0},Mo=function(e,t){var n=e.selection,r=n.$from,i=n.$to;if(n instanceof Et||r.parent.inlineContent||i.parent.inlineContent)return!1;var o=bo(i.parent.contentMatchAt(i.indexAfter()));if(!o||!o.isTextblock)return!1;if(t){var s=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,a=e.tr.insert(s,o.createAndFill());a.setSelection(Ct.create(a.doc,s+1)),t(a.scrollIntoView())}return!0},So=function(e,t){var n=e.selection.$cursor;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){var r=n.before();if(Qe(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}var i=n.blockRange(),o=i&&We(i);return null!=o&&(t&&t(e.tr.lift(i,o).scrollIntoView()),!0)};function Co(e,t,n){var r,i,o=t.nodeBefore,s=t.nodeAfter;if(o.type.spec.isolating||s.type.spec.isolating)return!1;if(function(e,t,n){var r=t.nodeBefore,i=t.nodeAfter,o=t.index();return!(!(r&&i&&r.type.compatibleContent(i.type))||(!r.content.size&&t.parent.canReplace(o-1,o)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),0):!t.parent.canReplace(o,o+1)||!i.isTextblock&&!tt(e.doc,t.pos)||(n&&n(e.tr.clearIncompatible(t.pos,r.type,r.contentMatchAt(r.childCount)).join(t.pos).scrollIntoView()),0)))}(e,t,n))return!0;var a=t.parent.canReplace(t.index(),t.index()+1);if(a&&(r=(i=o.contentMatchAt(o.childCount)).findWrapping(s.type))&&i.matchType(r[0]||s.type).validEnd){if(n){for(var c=t.pos+s.nodeSize,u=C.empty,l=r.length-1;l>=0;l--)u=C.from(r[l].create(null,u));u=C.from(o.copy(u));var d=e.tr.step(new He(t.pos-1,c,t.pos,c,new D(u,1,0),r.length,!0)),h=c+2*r.length;tt(d.doc,h)&&d.join(h),n(d.scrollIntoView())}return!0}var f=bt.findFrom(t,1),p=f&&f.$from.blockRange(f.$to),v=p&&We(p);if(null!=v&&v>=t.depth)return n&&n(e.tr.lift(p,v).scrollIntoView()),!0;if(a&&fo(s,"start",!0)&&fo(o,"end")){for(var m=o,g=[];g.push(m),!m.isTextblock;)m=m.lastChild;for(var y=s,k=1;!y.isTextblock;y=y.firstChild)k++;if(m.canReplace(m.childCount,m.childCount,y.content)){if(n){for(var w=C.empty,b=g.length-1;b>=0;b--)w=C.from(g[b].copy(w));n(e.tr.step(new He(t.pos-g.length,t.pos+s.nodeSize,t.pos+k,t.pos+s.nodeSize-k,new D(w,g.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function Oo(e){return function(t,n){for(var r=t.selection,i=e<0?r.$from:r.$to,o=i.depth;i.node(o).isInline;){if(!o)return!1;o--}return!!i.node(o).isTextblock&&(n&&n(t.tr.setSelection(Ct.create(t.doc,e<0?i.start(o):i.end(o)))),!0)}}var To=Oo(-1),No=Oo(1);function Eo(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return function(n,r){var i=n.selection,o=i.$from,s=i.$to,a=o.blockRange(s),c=a&&Ke(a,e,t);return!!c&&(r&&r(n.tr.wrap(a,c).scrollIntoView()),!0)}}function Ao(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return function(n,r){for(var i=!1,o=0;o<n.selection.ranges.length&&!i;o++){var s=n.selection.ranges[o],a=s.$from.pos,c=s.$to.pos;n.doc.nodesBetween(a,c,(function(r,o){if(i)return!1;if(r.isTextblock&&!r.hasMarkup(e,t))if(r.type==e)i=!0;else{var s=n.doc.resolve(o),a=s.index();i=s.parent.canReplaceWith(a,a+1,e)}}))}if(!i)return!1;if(r){for(var u=n.tr,l=0;l<n.selection.ranges.length;l++){var d=n.selection.ranges[l],h=d.$from.pos,f=d.$to.pos;u.setBlockType(h,f,e,t)}r(u.scrollIntoView())}return!0}}function Do(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e,n,r){for(var i=0;i<t.length;i++)if(t[i](e,n,r))return!0;return!1}}var Po=Do(lo,ho,po),Io=Do(lo,mo,go),Ro={Enter:Do(wo,Mo,So,(function(e,t){var n=e.selection,r=n.$from,i=n.$to;if(e.selection instanceof Tt&&e.selection.node.isBlock)return!(!r.parentOffset||!Qe(e.doc,r.pos)||(t&&t(e.tr.split(r.pos).scrollIntoView()),0));if(!r.parent.isBlock)return!1;if(t){var o=i.parentOffset==i.parent.content.size,s=e.tr;(e.selection instanceof Ct||e.selection instanceof Et)&&s.deleteSelection();var a=0==r.depth?null:bo(r.node(-1).contentMatchAt(r.indexAfter(-1))),c=o&&a?[{type:a}]:void 0,u=Qe(s.doc,s.mapping.map(r.pos),1,c);if(c||u||!Qe(s.doc,s.mapping.map(r.pos),1,a?[{type:a}]:void 0)||(a&&(c=[{type:a}]),u=!0),u&&(s.split(s.mapping.map(r.pos),1,c),!o&&!r.parentOffset&&r.parent.type!=a)){var l=s.mapping.map(r.before()),d=s.doc.resolve(l);a&&r.node(-1).canReplaceWith(d.index(),d.index()+1,a)&&s.setNodeMarkup(s.mapping.map(r.before()),a)}t(s.scrollIntoView())}return!0})),"Mod-Enter":xo,Backspace:Po,"Mod-Backspace":Po,"Shift-Backspace":Po,Delete:Io,"Mod-Delete":Io,"Mod-a":function(e,t){return t&&t(e.tr.setSelection(new Et(e.doc))),!0}},zo={"Ctrl-h":Ro.Backspace,"Alt-Backspace":Ro["Mod-Backspace"],"Ctrl-d":Ro.Delete,"Ctrl-Alt-Backspace":Ro["Mod-Delete"],"Alt-Delete":Ro["Mod-Delete"],"Alt-d":Ro["Mod-Delete"],"Ctrl-a":To,"Ctrl-e":No};for(var Bo in Ro)zo[Bo]=Ro[Bo];function Zo(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return function(n,r){var i=n.selection,o=i.$from,s=i.$to,a=o.blockRange(s),c=!1,u=a;if(!a)return!1;if(a.depth>=2&&o.node(a.depth-1).type.compatibleContent(e)&&0==a.startIndex){if(0==o.index(a.depth-1))return!1;var l=n.doc.resolve(a.start-2);u=new K(l,l,a.depth),a.endIndex<a.parent.childCount&&(a=new K(o,n.doc.resolve(s.end(a.depth)),a.depth)),c=!0}var d=Ke(u,e,t,a);return!!d&&(r&&r(Lo(n.tr,a,d,c,e).scrollIntoView()),!0)}}function Lo(e,t,n,r,i){for(var o=C.empty,s=n.length-1;s>=0;s--)o=C.from(n[s].type.create(n[s].attrs,o));e.step(new He(t.start-(r?2:0),t.end,t.start,t.end,new D(o,0,0),n.length,!0));for(var a=0,c=0;c<n.length;c++)n[c].type==i&&(a=c+1);for(var u=n.length-a,l=t.start+n.length-(r?2:0),d=t.parent,h=t.startIndex,f=t.endIndex,p=!0;h<f;h++,p=!1)!p&&Qe(e.doc,l,u)&&(e.split(l,u),l+=2*u),l+=d.child(h).nodeSize;return e}function $o(e){var t=e.state,n=e.transaction,r=n.selection,i=n.doc,o=n.storedMarks;return w(w({},t),{},{apply:t.apply.bind(t),applyTransaction:t.applyTransaction.bind(t),filterTransaction:t.filterTransaction,plugins:t.plugins,schema:t.schema,reconfigure:t.reconfigure.bind(t),toJSON:t.toJSON.bind(t),get storedMarks(){return o},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,o=n.storedMarks,n}})}"undefined"!=typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):"undefined"!=typeof os&&os.platform&&os.platform();var Fo=function(){function e(t){(0,v.Z)(this,e),this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}return(0,m.Z)(e,[{key:"hasCustomState",get:function(){return!!this.customState}},{key:"state",get:function(){return this.customState||this.editor.state}},{key:"commands",get:function(){var e=this,t=this.rawCommands,n=this.editor,r=this.state,i=n.view,o=r.tr,s=this.buildProps(o);return Object.fromEntries(Object.entries(t).map((function(t){var n=(0,a.Z)(t,2),r=n[0],c=n[1];return[r,function(){var t=c.apply(void 0,arguments)(s);return o.getMeta("preventDispatch")||e.hasCustomState||i.dispatch(o),t}]})))}},{key:"chain",get:function(){var e=this;return function(){return e.createChain()}}},{key:"can",get:function(){var e=this;return function(){return e.createCan()}}},{key:"createChain",value:function(e){var t=this,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=this.rawCommands,i=this.editor,o=this.state,s=i.view,c=[],u=!!e,l=e||o.tr,d=function(){return u||!n||l.getMeta("preventDispatch")||t.hasCustomState||s.dispatch(l),c.every((function(e){return!0===e}))},h=w(w({},Object.fromEntries(Object.entries(r).map((function(e){var r=(0,a.Z)(e,2),i=r[0],o=r[1];return[i,function(){var e=t.buildProps(l,n),r=o.apply(void 0,arguments)(e);return c.push(r),h}]})))),{},{run:d});return h}},{key:"createCan",value:function(e){var t=this,n=this.rawCommands,r=this.state,i=e||r.tr,o=this.buildProps(i,!1),s=Object.fromEntries(Object.entries(n).map((function(e){var t=(0,a.Z)(e,2),n=t[0],r=t[1];return[n,function(){return r.apply(void 0,arguments)(w(w({},o),{},{dispatch:void 0}))}]})));return w(w({},s),{},{chain:function(){return t.createChain(i,!1)}})}},{key:"buildProps",value:function(e){var t=this,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=this.rawCommands,i=this.editor,o=this.state,s=i.view;o.storedMarks&&e.setStoredMarks(o.storedMarks);var c={tr:e,editor:i,view:s,state:$o({state:o,transaction:e}),dispatch:n?function(){}:void 0,chain:function(){return t.createChain(e)},can:function(){return t.createCan(e)},get commands(){return Object.fromEntries(Object.entries(r).map((function(e){var t=(0,a.Z)(e,2),n=t[0],r=t[1];return[n,function(){return r.apply(void 0,arguments)(c)}]})))}};return c}}]),e}(),Vo=function(){function e(){(0,v.Z)(this,e),this.callbacks={}}return(0,m.Z)(e,[{key:"on",value:function(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}},{key:"emit",value:function(e){for(var t=this,n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];var o=this.callbacks[e];return o&&o.forEach((function(e){return e.apply(t,r)})),this}},{key:"off",value:function(e,t){var n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter((function(e){return e!==t})):delete this.callbacks[e]),this}},{key:"removeAllListeners",value:function(){this.callbacks={}}}]),e}();function jo(e,t,n){return void 0===e.config[t]&&e.parent?jo(e.parent,t,n):"function"==typeof e.config[t]?e.config[t].bind(w(w({},n),{},{parent:e.parent?jo(e.parent,t,n):null})):e.config[t]}function Ho(e){return{baseExtensions:e.filter((function(e){return"extension"===e.type})),nodeExtensions:e.filter((function(e){return"node"===e.type})),markExtensions:e.filter((function(e){return"mark"===e.type}))}}function Jo(e){var t=[],n=Ho(e),r=n.nodeExtensions,o=n.markExtensions,s=[].concat((0,i.Z)(r),(0,i.Z)(o)),c={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return e.forEach((function(e){var n=jo(e,"addGlobalAttributes",{name:e.name,options:e.options,storage:e.storage});n&&n().forEach((function(e){e.types.forEach((function(n){Object.entries(e.attributes).forEach((function(e){var r=(0,a.Z)(e,2),i=r[0],o=r[1];t.push({type:n,name:i,attribute:w(w({},c),o)})}))}))}))})),s.forEach((function(e){var n={name:e.name,options:e.options,storage:e.storage},r=jo(e,"addAttributes",n);if(r){var i=r();Object.entries(i).forEach((function(n){var r=(0,a.Z)(n,2),i=r[0],o=r[1],s=w(w({},c),o);(null==o?void 0:o.isRequired)&&void 0===(null==o?void 0:o.default)&&delete s.default,t.push({type:e.name,name:i,attribute:s})}))}})),t}function qo(e,t){if("string"==typeof e){if(!t.nodes[e])throw Error("There is no node type named '".concat(e,"'. Maybe you forgot to add the extension?"));return t.nodes[e]}return e}function Wo(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.filter((function(e){return!!e})).reduce((function(e,t){var n=w({},e);return Object.entries(t).forEach((function(e){var t=(0,a.Z)(e,2),r=t[0],i=t[1];n[r]?n[r]="class"===r?[n[r],i].join(" "):"style"===r?[n[r],i].join("; "):i:n[r]=i})),n}),{})}function Ko(e,t){return t.filter((function(e){return e.attribute.rendered})).map((function(t){return t.attribute.renderHTML?t.attribute.renderHTML(e.attrs)||{}:(0,o.Z)({},t.name,e.attrs[t.name])})).reduce((function(e,t){return Wo(e,t)}),{})}function _o(e){return"function"==typeof e}function Uo(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;if(_o(e)){for(var n=arguments.length,r=new Array(n>2?n-2:0),i=2;i<n;i++)r[i-2]=arguments[i];return t?e.bind(t).apply(void 0,r):e.apply(void 0,r)}return e}function Go(e,t){return e.style?e:w(w({},e),{},{getAttrs:function(n){var r=e.getAttrs?e.getAttrs(n):e.attrs;if(!1===r)return!1;var i=t.reduce((function(e,t){var r=t.attribute.parseHTML?t.attribute.parseHTML(n):function(e){return"string"!=typeof e?e:e.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(e):"true"===e||"false"!==e&&e}(n.getAttribute(t.name));return null==r?e:w(w({},e),{},(0,o.Z)({},t.name,r))}),{});return w(w({},r),i)}})}function Xo(e){return Object.fromEntries(Object.entries(e).filter((function(e){var t=(0,a.Z)(e,2),n=t[0],r=t[1];return("attrs"!==n||!function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return 0===Object.keys(e).length&&e.constructor===Object}(r))&&null!=r})))}function Yo(e,t){return t.nodes[e]||t.marks[e]||null}function Qo(e,t){return Array.isArray(t)?t.some((function(t){return("string"==typeof t?t:t.name)===e.name})):t}function es(e){return"[object RegExp]"===Object.prototype.toString.call(e)}var ts=(0,m.Z)((function e(t){(0,v.Z)(this,e),this.find=t.find,this.handler=t.handler}));function ns(e){var t,n=e.editor,r=e.from,i=e.to,o=e.text,s=e.rules,a=e.plugin,c=n.view;if(c.composing)return!1;var u=c.state.doc.resolve(r);if(u.parent.type.spec.code||(null===(t=u.nodeBefore||u.nodeAfter)||void 0===t?void 0:t.marks.find((function(e){return e.type.spec.code}))))return!1;var l=!1,d=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:500,n="",r=e.parentOffset;return e.parent.nodesBetween(Math.max(0,r-t),r,(function(e,t,i,o){var s,a,c=(null===(a=(s=e.type.spec).toText)||void 0===a?void 0:a.call(s,{node:e,pos:t,parent:i,index:o}))||e.textContent||"%leaf%";n+=c.slice(0,Math.max(0,r-t))})),n}(u)+o;return s.forEach((function(e){if(!l){var t=function(e,t){if(es(t))return t.exec(e);var n=t(e);if(!n)return null;var r=[n.text];return r.index=n.index,r.input=e,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r}(d,e.find);if(t){var s=c.state.tr,u=$o({state:c.state,transaction:s}),h={from:r-(t[0].length-o.length),to:i},f=new Fo({editor:n,state:u}),p=f.commands,v=f.chain,m=f.can;null!==e.handler({state:u,range:h,match:t,commands:p,chain:v,can:m})&&s.steps.length&&(s.setMeta(a,{transform:s,from:r,to:i,text:o}),c.dispatch(s),l=!0)}}})),l}function rs(e){var t=e.editor,n=e.rules,r=new Ft({state:{init:function(){return null},apply:function(e,t){return e.getMeta(r)||(e.selectionSet||e.docChanged?null:t)}},props:{handleTextInput:function(e,i,o,s){return ns({editor:t,from:i,to:o,text:s,rules:n,plugin:r})},handleDOMEvents:{compositionend:function(e){return setTimeout((function(){var i=e.state.selection.$cursor;i&&ns({editor:t,from:i.pos,to:i.pos,text:"",rules:n,plugin:r})})),!1}},handleKeyDown:function(e,i){if("Enter"!==i.key)return!1;var o=e.state.selection.$cursor;return!!o&&ns({editor:t,from:o.pos,to:o.pos,text:"\n",rules:n,plugin:r})}},isInputRules:!0});return r}var is=(0,m.Z)((function e(t){(0,v.Z)(this,e),this.find=t.find,this.handler=t.handler}));var ss=function(){function e(t,n){var r=this;(0,v.Z)(this,e),this.splittableMarks=[],this.editor=n,this.extensions=e.resolve(t),this.schema=function(e){var t,n=Jo(e),r=Ho(e),i=r.nodeExtensions,o=r.markExtensions,s=null===(t=i.find((function(e){return jo(e,"topNode")})))||void 0===t?void 0:t.name,a=Object.fromEntries(i.map((function(t){var r=n.filter((function(e){return e.type===t.name})),i={name:t.name,options:t.options,storage:t.storage},o=e.reduce((function(e,n){var r=jo(n,"extendNodeSchema",i);return w(w({},e),r?r(t):{})}),{}),s=Xo(w(w({},o),{},{content:Uo(jo(t,"content",i)),marks:Uo(jo(t,"marks",i)),group:Uo(jo(t,"group",i)),inline:Uo(jo(t,"inline",i)),atom:Uo(jo(t,"atom",i)),selectable:Uo(jo(t,"selectable",i)),draggable:Uo(jo(t,"draggable",i)),code:Uo(jo(t,"code",i)),defining:Uo(jo(t,"defining",i)),isolating:Uo(jo(t,"isolating",i)),attrs:Object.fromEntries(r.map((function(e){var t;return[e.name,{default:null===(t=null==e?void 0:e.attribute)||void 0===t?void 0:t.default}]})))})),a=Uo(jo(t,"parseHTML",i));a&&(s.parseDOM=a.map((function(e){return Go(e,r)})));var c=jo(t,"renderHTML",i);c&&(s.toDOM=function(e){return c({node:e,HTMLAttributes:Ko(e,r)})});var u=jo(t,"renderText",i);return u&&(s.toText=u),[t.name,s]}))),c=Object.fromEntries(o.map((function(t){var r=n.filter((function(e){return e.type===t.name})),i={name:t.name,options:t.options,storage:t.storage},o=e.reduce((function(e,n){var r=jo(n,"extendMarkSchema",i);return w(w({},e),r?r(t):{})}),{}),s=Xo(w(w({},o),{},{inclusive:Uo(jo(t,"inclusive",i)),excludes:Uo(jo(t,"excludes",i)),group:Uo(jo(t,"group",i)),spanning:Uo(jo(t,"spanning",i)),code:Uo(jo(t,"code",i)),attrs:Object.fromEntries(r.map((function(e){var t;return[e.name,{default:null===(t=null==e?void 0:e.attribute)||void 0===t?void 0:t.default}]})))})),a=Uo(jo(t,"parseHTML",i));a&&(s.parseDOM=a.map((function(e){return Go(e,r)})));var c=jo(t,"renderHTML",i);return c&&(s.toDOM=function(e){return c({mark:e,HTMLAttributes:Ko(e,r)})}),[t.name,s]})));return new pe({topNode:s,nodes:a,marks:c})}(this.extensions),this.extensions.forEach((function(e){var t;r.editor.extensionStorage[e.name]=e.storage;var n={name:e.name,options:e.options,storage:e.storage,editor:r.editor,type:Yo(e.name,r.schema)};"mark"===e.type&&(null===(t=Uo(jo(e,"keepOnSplit",n)))||void 0===t||t)&&r.splittableMarks.push(e.name);var i=jo(e,"onBeforeCreate",n);i&&r.editor.on("beforeCreate",i);var o=jo(e,"onCreate",n);o&&r.editor.on("create",o);var s=jo(e,"onUpdate",n);s&&r.editor.on("update",s);var a=jo(e,"onSelectionUpdate",n);a&&r.editor.on("selectionUpdate",a);var c=jo(e,"onTransaction",n);c&&r.editor.on("transaction",c);var u=jo(e,"onFocus",n);u&&r.editor.on("focus",u);var l=jo(e,"onBlur",n);l&&r.editor.on("blur",l);var d=jo(e,"onDestroy",n);d&&r.editor.on("destroy",d)}))}return(0,m.Z)(e,[{key:"commands",get:function(){var e=this;return this.extensions.reduce((function(t,n){var r=jo(n,"addCommands",{name:n.name,options:n.options,storage:n.storage,editor:e.editor,type:Yo(n.name,e.schema)});return r?w(w({},t),r()):t}),{})}},{key:"plugins",get:function(){var t=this,n=this.editor,r=e.sort((0,i.Z)(this.extensions).reverse()),o=[],s=[],c=r.map((function(e){var r={name:e.name,options:e.options,storage:e.storage,editor:n,type:Yo(e.name,t.schema)},c=[],u=jo(e,"addKeyboardShortcuts",r),l={};if("mark"===e.type&&e.config.exitable&&(l.ArrowRight=function(){return Xs.handleExit({editor:n,mark:e})}),u){var d=Object.fromEntries(Object.entries(u()).map((function(e){var t=(0,a.Z)(e,2),r=t[0],i=t[1];return[r,function(){return i({editor:n})}]})));l=w(w({},l),d)}var h=function(e){return new Ft({props:{handleKeyDown:uo(e)}})}(l);c.push(h);var f=jo(e,"addInputRules",r);Qo(e,n.options.enableInputRules)&&f&&o.push.apply(o,(0,i.Z)(f()));var p=jo(e,"addPasteRules",r);Qo(e,n.options.enablePasteRules)&&p&&s.push.apply(s,(0,i.Z)(p()));var v=jo(e,"addProseMirrorPlugins",r);if(v){var m=v();c.push.apply(c,(0,i.Z)(m))}return c})).flat();return[rs({editor:n,rules:o})].concat((0,i.Z)(function(e){var t=e.editor,n=null,r=!1,o=!1;return e.rules.map((function(e){return new Ft({view:function(e){var t=function(t){var r;n=(null===(r=e.dom.parentElement)||void 0===r?void 0:r.contains(t.target))?e.dom.parentElement:null};return window.addEventListener("dragstart",t),{destroy:function(){window.removeEventListener("dragstart",t)}}},props:{handleDOMEvents:{drop:function(e){return o=n===e.dom.parentElement,!1},paste:function(e,t){var n,i=null===(n=t.clipboardData)||void 0===n?void 0:n.getData("text/html");return r=!!(null==i?void 0:i.includes("data-pm-slice")),!1}}},appendTransaction:function(n,s,a){var c=n[0],u="paste"===c.getMeta("uiEvent")&&!r,l="drop"===c.getMeta("uiEvent")&&!o;if(u||l){var d=s.doc.content.findDiffStart(a.doc.content),h=s.doc.content.findDiffEnd(a.doc.content);if("number"==typeof d&&h&&d!==h.b){var f=a.tr,p=$o({state:a,transaction:f});if(function(e){var t=e.editor,n=e.state,r=e.from,o=e.to,s=e.rule,a=new Fo({editor:t,state:n}),c=a.commands,u=a.chain,l=a.can,d=[];return n.doc.nodesBetween(r,o,(function(e,t){if(e.isTextblock&&!e.type.spec.code){var a=Math.max(r,t),h=Math.min(o,t+e.content.size);(function(e,t){if(es(t))return(0,i.Z)(e.matchAll(t));var n=t(e);return n?n.map((function(t){var n=[t.text];return n.index=t.index,n.input=e,n.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),n.push(t.replaceWith)),n})):[]})(e.textBetween(a-t,h-t,void 0,""),s.find).forEach((function(e){if(void 0!==e.index){var t=a+e.index+1,r=t+e[0].length,i={from:n.tr.mapping.map(t),to:n.tr.mapping.map(r)},o=s.handler({state:n,range:i,match:e,commands:c,chain:u,can:l});d.push(o)}}))}})),d.every((function(e){return null!==e}))}({editor:t,state:p,from:Math.max(d-1,0),to:h.b-1,rule:e})&&f.steps.length)return f}}}})}))}({editor:n,rules:s})),(0,i.Z)(c))}},{key:"attributes",get:function(){return Jo(this.extensions)}},{key:"nodeViews",get:function(){var e=this,t=this.editor,n=Ho(this.extensions).nodeExtensions;return Object.fromEntries(n.filter((function(e){return!!jo(e,"addNodeView")})).map((function(n){var r=e.attributes.filter((function(e){return e.type===n.name})),i={name:n.name,options:n.options,storage:n.storage,editor:t,type:qo(n.name,e.schema)},o=jo(n,"addNodeView",i);return o?[n.name,function(e,i,s,a){var c=Ko(e,r);return o()({editor:t,node:e,getPos:s,decorations:a,HTMLAttributes:c,extension:n})}]:[]})))}}],[{key:"resolve",value:function(t){var n,r,o=e.sort(e.flatten(t)),s=(r=(n=o.map((function(e){return e.name}))).filter((function(e,t){return n.indexOf(e)!==t})),(0,i.Z)(new Set(r)));return s.length&&console.warn("[tiptap warn]: Duplicate extension names found: [".concat(s.map((function(e){return"'".concat(e,"'")})).join(", "),"]. This can lead to issues.")),o}},{key:"flatten",value:function(e){var t=this;return e.map((function(e){var n=jo(e,"addExtensions",{name:e.name,options:e.options,storage:e.storage});return n?[e].concat((0,i.Z)(t.flatten(n()))):e})).flat(10)}},{key:"sort",value:function(e){return e.sort((function(e,t){var n=jo(e,"priority")||100,r=jo(t,"priority")||100;return n>r?-1:n<r?1:0}))}}]),e}();function as(e){return"Object"===function(e){return Object.prototype.toString.call(e).slice(8,-1)}(e)&&e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype}function cs(e,t){var n=w({},e);return as(e)&&as(t)&&Object.keys(t).forEach((function(r){as(t[r])&&r in e?n[r]=cs(e[r],t[r]):Object.assign(n,(0,o.Z)({},r,t[r]))})),n}var us=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(0,v.Z)(this,e),this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config=w(w({},this.config),t),this.name=this.config.name,t.defaultOptions&&console.warn('[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "'.concat(this.name,'".')),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=Uo(jo(this,"addOptions",{name:this.name}))),this.storage=Uo(jo(this,"addStorage",{name:this.name,options:this.options}))||{}}return(0,m.Z)(e,[{key:"configure",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=this.extend();return t.options=cs(this.options,e),t.storage=Uo(jo(t,"addStorage",{name:t.name,options:t.options})),t}},{key:"extend",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=new e(t);return n.parent=this,this.child=n,n.name=t.name?t.name:n.parent.name,t.defaultOptions&&console.warn('[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "'.concat(n.name,'".')),n.options=Uo(jo(n,"addOptions",{name:n.name})),n.storage=Uo(jo(n,"addStorage",{name:n.name,options:n.options})),n}}],[{key:"create",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new e(t)}}]),e}();function ls(e,t,n){var r=t.from,i=t.to,o=n||{},s=o.blockSeparator,a=void 0===s?"\n\n":s,c=o.textSerializers,u=void 0===c?{}:c,l="",d=!0;return e.nodesBetween(r,i,(function(e,n,o,s){var c,h=null==u?void 0:u[e.type.name];h?(e.isBlock&&!d&&(l+=a,d=!0),o&&(l+=h({node:e,pos:n,parent:o,index:s,range:t}))):e.isText?(l+=null===(c=null==e?void 0:e.text)||void 0===c?void 0:c.slice(Math.max(r,n)-n,i-n),d=!1):e.isBlock&&!d&&(l+=a,d=!0)})),l}function ds(e){return Object.fromEntries(Object.entries(e.nodes).filter((function(e){return(0,a.Z)(e,2)[1].spec.toText})).map((function(e){var t=(0,a.Z)(e,2);return[t[0],t[1].spec.toText]})))}var hs=us.create({name:"clipboardTextSerializer",addProseMirrorPlugins:function(){var e=this;return[new Ft({key:new Ht("clipboardTextSerializer"),props:{clipboardTextSerializer:function(){var t=e.editor,n=t.state,r=t.schema,o=n.doc,s=n.selection.ranges;return ls(o,{from:Math.min.apply(Math,(0,i.Z)(s.map((function(e){return e.$from.pos})))),to:Math.max.apply(Math,(0,i.Z)(s.map((function(e){return e.$to.pos}))))},{textSerializers:ds(r)})}}})]}});function fs(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{strict:!0},r=Object.keys(t);return!r.length||r.every((function(r){return n.strict?t[r]===e[r]:es(t[r])?t[r].test(e[r]):t[r]===e[r]}))}function ps(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return e.find((function(e){return e.type===t&&fs(e.attrs,n)}))}function vs(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return!!ps(e,t,n)}function ms(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(e&&t){var r=e.parent.childAfter(e.parentOffset);if(e.parentOffset===r.offset&&0!==r.offset&&(r=e.parent.childBefore(e.parentOffset)),r.node){var o=ps((0,i.Z)(r.node.marks),t,n);if(o){var s=r.index,a=e.start()+r.offset,c=s+1,u=a+r.node.nodeSize;for(ps((0,i.Z)(r.node.marks),t,n);s>0&&o.isInSet(e.parent.child(s-1).marks);)s-=1,a-=e.parent.child(s).nodeSize;for(;c<e.parent.childCount&&vs((0,i.Z)(e.parent.child(c).marks),t,n);)u+=e.parent.child(c).nodeSize,c+=1;return{from:a,to:u}}}}}function gs(e,t){if("string"==typeof e){if(!t.marks[e])throw Error("There is no mark type named '".concat(e,"'. Maybe you forgot to add the extension?"));return t.marks[e]}return e}function ys(e){return e instanceof Ct}function ks(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return Math.min(Math.max(e,t),n)}function ws(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(!t)return null;var n=bt.atStart(e),r=bt.atEnd(e);if("start"===t||!0===t)return n;if("end"===t)return r;var i=n.from,o=r.to;return"all"===t?Ct.create(e,ks(0,i,o),ks(e.content.size,i,o)):Ct.create(e,ks(t,i,o),ks(t,i,o))}function bs(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function xs(e){var t="<body>".concat(e,"</body>");return(new window.DOMParser).parseFromString(t,"text/html").body}function Ms(e,t,n){if(n=w({slice:!0,parseOptions:{}},n),"object"===(0,p.Z)(e)&&null!==e)try{return Array.isArray(e)?C.fromArray(e.map((function(e){return t.nodeFromJSON(e)}))):t.nodeFromJSON(e)}catch(r){return console.warn("[tiptap warn]: Invalid content.","Passed value:",e,"Error:",r),Ms("",t,n)}if("string"==typeof e){var r=me.fromSchema(t);return n.slice?r.parseSlice(xs(e),n.parseOptions).content:r.parse(xs(e),n.parseOptions)}return Ms("",t,n)}function Ss(){return"undefined"!=typeof navigator&&/Mac/.test(navigator.platform)}function Cs(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=e.selection,i=r.from,o=r.to,s=r.empty,a=t?qo(t,e.schema):null,c=[];e.doc.nodesBetween(i,o,(function(e,t){if(!e.isText){var n=Math.max(i,t),r=Math.min(o,t+e.nodeSize);c.push({node:e,from:n,to:r})}}));var u=o-i,l=c.filter((function(e){return!a||a.name===e.node.type.name})).filter((function(e){return fs(e.node.attrs,n,{strict:!1})}));if(s)return!!l.length;var d=l.reduce((function(e,t){return e+t.to-t.from}),0);return d>=u}function Os(e,t){return t.nodes[e]?"node":t.marks[e]?"mark":null}function Ts(e,t){var n="string"==typeof t?[t]:t;return Object.keys(e).reduce((function(t,r){return n.includes(r)||(t[r]=e[r]),t}),{})}function Ns(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return Ms(e,t,{slice:!1,parseOptions:n})}function Es(e){for(var t=0;t<e.edgeCount;t+=1){var n=e.edge(t).type;if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function As(e){return function(t){return function(e,t){for(var n=e.depth;n>0;n-=1){var r=e.node(n);if(t(r))return{pos:n>0?e.before(n):0,start:e.start(n),depth:n,node:r}}}(t.$from,e)}}function Ds(e,t){var n=gs(t,e.schema),r=e.selection,o=r.from,s=r.to,a=r.empty,c=[];a?(e.storedMarks&&c.push.apply(c,(0,i.Z)(e.storedMarks)),c.push.apply(c,(0,i.Z)(e.selection.$head.marks()))):e.doc.nodesBetween(o,s,(function(e){c.push.apply(c,(0,i.Z)(e.marks))}));var u=c.find((function(e){return e.type.name===n.name}));return u?w({},u.attrs):{}}function Ps(e,t,n){var r=[];return e===t?n.resolve(e).marks().forEach((function(t){var i=ms(n.resolve(e-1),t.type);i&&r.push(w({mark:t},i))})):n.nodesBetween(e,t,(function(e,t){r.push.apply(r,(0,i.Z)(e.marks.map((function(n){return{from:t,to:t+e.nodeSize,mark:n}}))))})),r}function Is(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=e.selection,o=r.empty,s=r.ranges,a=t?gs(t,e.schema):null;if(o)return!!(e.storedMarks||e.selection.$from.marks()).filter((function(e){return!a||a.name===e.type.name})).find((function(e){return fs(e.attrs,n,{strict:!1})}));var c=0,u=[];if(s.forEach((function(t){var n=t.$from,r=t.$to,o=n.pos,s=r.pos;e.doc.nodesBetween(o,s,(function(e,t){if(e.isText||e.marks.length){var n=Math.max(o,t),r=Math.min(s,t+e.nodeSize);c+=r-n,u.push.apply(u,(0,i.Z)(e.marks.map((function(e){return{mark:e,from:n,to:r}}))))}}))})),0===c)return!1;var l=u.filter((function(e){return!a||a.name===e.mark.type.name})).filter((function(e){return fs(e.mark.attrs,n,{strict:!1})})).reduce((function(e,t){return e+t.to-t.from}),0),d=u.filter((function(e){return!a||e.mark.type!==a&&e.mark.type.excludes(a)})).reduce((function(e,t){return e+t.to-t.from}),0),h=l>0?l+d:l;return h>=c}function Rs(e,t){var n=Ho(t).nodeExtensions.find((function(t){return t.name===e}));if(!n)return!1;var r=Uo(jo(n,"group",{name:n.name,options:n.options,storage:n.storage}));return"string"==typeof r&&r.split(" ").includes("list")}function zs(e,t,n){var r,i=t.selection,o=null;if(ys(i)&&(o=i.$cursor),o){var s=null!==(r=e.storedMarks)&&void 0!==r?r:o.marks();return!!n.isInSet(s)||!s.some((function(e){return e.type.excludes(n)}))}return i.ranges.some((function(t){var r=t.$from,i=t.$to,o=0===r.depth&&e.doc.inlineContent&&e.doc.type.allowsMarkType(n);return e.doc.nodesBetween(r.pos,i.pos,(function(e,t,r){if(o)return!1;if(e.isInline){var i=!r||r.type.allowsMarkType(n),s=!!n.isInSet(e.marks)||!e.marks.some((function(e){return e.type.excludes(n)}));o=i&&s}return!o})),o}))}function Bs(e,t,n){return Object.fromEntries(Object.entries(n).filter((function(n){var r=(0,a.Z)(n,1)[0],i=e.find((function(e){return e.type===t&&e.name===r}));return!!i&&i.attribute.keepOnSplit})))}function Zs(e,t){var n=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(n){var r=n.filter((function(e){return null==t?void 0:t.includes(e.type.name)}));e.tr.ensureMarks(r)}}var Ls=function(e,t){var n=As((function(e){return e.type===t}))(e.selection);if(!n)return!0;var r=e.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(void 0===r)return!0;var i=e.doc.nodeAt(r);return n.node.type!==(null==i?void 0:i.type)||!tt(e.doc,n.pos)||(e.join(n.pos),!0)},$s=function(e,t){var n=As((function(e){return e.type===t}))(e.selection);if(!n)return!0;var r=e.doc.resolve(n.start).after(n.depth);if(void 0===r)return!0;var i=e.doc.nodeAt(r);return n.node.type!==(null==i?void 0:i.type)||!tt(e.doc,r)||(e.join(r),!0)},Fs=Object.freeze({__proto__:null,blur:function(){return function(e){var t=e.editor,n=e.view;return requestAnimationFrame((function(){var e;t.isDestroyed||(n.dom.blur(),null===(e=null===window||void 0===window?void 0:window.getSelection())||void 0===e||e.removeAllRanges())})),!0}},clearContent:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return function(t){return t.commands.setContent("",e)}},clearNodes:function(){return function(e){var t=e.state,n=e.tr,r=e.dispatch,i=n.selection.ranges;return!r||(i.forEach((function(e){var r=e.$from,i=e.$to;t.doc.nodesBetween(r.pos,i.pos,(function(e,t){if(!e.type.isText){var r=n.doc,i=n.mapping,o=r.resolve(i.map(t)),s=r.resolve(i.map(t+e.nodeSize)),a=o.blockRange(s);if(a){var c=We(a);if(e.type.isTextblock){var u=o.parent.contentMatchAt(o.index()).defaultType;n.setNodeMarkup(a.start,u)}(c||0===c)&&n.lift(a,c)}}}))})),!0)}},command:function(e){return function(t){return e(t)}},createParagraphNear:function(){return function(e){var t=e.state,n=e.dispatch;return Mo(t,n)}},deleteCurrentNode:function(){return function(e){var t=e.tr,n=e.dispatch,r=t.selection.$anchor.node();if(r.content.size>0)return!1;for(var i=t.selection.$anchor,o=i.depth;o>0;o-=1)if(i.node(o).type===r.type){if(n){var s=i.before(o),a=i.after(o);t.delete(s,a).scrollIntoView()}return!0}return!1}},deleteNode:function(e){return function(t){for(var n=t.tr,r=t.state,i=t.dispatch,o=qo(e,r.schema),s=n.selection.$anchor,a=s.depth;a>0;a-=1)if(s.node(a).type===o){if(i){var c=s.before(a),u=s.after(a);n.delete(c,u).scrollIntoView()}return!0}return!1}},deleteRange:function(e){return function(t){var n=t.tr,r=t.dispatch,i=e.from,o=e.to;return r&&n.delete(i,o),!0}},deleteSelection:function(){return function(e){var t=e.state,n=e.dispatch;return lo(t,n)}},enter:function(){return function(e){return e.commands.keyboardShortcut("Enter")}},exitCode:function(){return function(e){var t=e.state,n=e.dispatch;return xo(t,n)}},extendMarkRange:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var r=n.tr,i=n.state,o=n.dispatch,s=gs(e,i.schema),a=r.doc,c=r.selection,u=c.$from,l=c.from,d=c.to;if(o){var h=ms(u,s,t);if(h&&h.from<=l&&h.to>=d){var f=Ct.create(a,h.from,h.to);r.setSelection(f)}}return!0}},first:function(e){return function(t){for(var n="function"==typeof e?e(t):e,r=0;r<n.length;r+=1)if(n[r](t))return!0;return!1}},focus:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var r=n.editor,i=n.view,o=n.tr,s=n.dispatch;t=w({scrollIntoView:!0},t);var a=function(){bs()&&i.dom.focus(),requestAnimationFrame((function(){r.isDestroyed||(i.focus(),(null==t?void 0:t.scrollIntoView)&&r.commands.scrollIntoView())}))};if(i.hasFocus()&&null===e||!1===e)return!0;if(s&&null===e&&!ys(r.state.selection))return a(),!0;var c=ws(o.doc,e)||r.state.selection,u=r.state.selection.eq(c);return s&&(u||o.setSelection(c),u&&o.storedMarks&&o.setStoredMarks(o.storedMarks),a()),!0}},forEach:function(e,t){return function(n){return e.every((function(e,r){return t(e,w(w({},n),{},{index:r}))}))}},insertContent:function(e,t){return function(n){var r=n.tr;return n.commands.insertContentAt({from:r.selection.from,to:r.selection.to},e,t)}},insertContentAt:function(e,t,n){return function(r){var i=r.tr,o=r.dispatch,s=r.editor;if(o){n=w({parseOptions:{},updateSelection:!0},n);var a=Ms(t,s.schema,{parseOptions:w({preserveWhitespace:"full"},n.parseOptions)});if("<>"===a.toString())return!0;var c="number"==typeof e?{from:e,to:e}:e,u=c.from,l=c.to,d=!0,h=!0;if((a.toString().startsWith("<")?a:[a]).forEach((function(e){e.check(),d=!!d&&e.isText&&0===e.marks.length,h=!!h&&e.isBlock})),u===l&&h){var f=i.doc.resolve(u).parent;f.isTextblock&&!f.type.spec.code&&!f.childCount&&(u-=1,l+=1)}d?i.insertText(t,u,l):i.replaceWith(u,l,a),n.updateSelection&&function(e,t,n){var r=e.steps.length-1;if(!(r<t)){var i=e.steps[r];if(i instanceof je||i instanceof He){var o=e.mapping.maps[r],s=0;o.forEach((function(e,t,n,r){0===s&&(s=r)})),e.setSelection(bt.near(e.doc.resolve(s),-1))}}}(i,i.steps.length-1)}return!0}},joinUp:function(){return function(e){return function(e,t){var n,r=e.selection,i=r instanceof Tt;if(i){if(r.node.isTextblock||!tt(e.doc,r.from))return!1;n=r.from}else if(null==(n=rt(e.doc,r.from,-1)))return!1;if(t){var o=e.tr.join(n);i&&o.setSelection(Tt.create(o.doc,n-e.doc.resolve(n).nodeBefore.nodeSize)),t(o.scrollIntoView())}return!0}(e.state,e.dispatch)}},joinDown:function(){return function(e){return function(e,t){var n,r=e.selection;if(r instanceof Tt){if(r.node.isTextblock||!tt(e.doc,r.to))return!1;n=r.to}else if(null==(n=rt(e.doc,r.to,1)))return!1;return t&&t(e.tr.join(n).scrollIntoView()),!0}(e.state,e.dispatch)}},joinBackward:function(){return function(e){var t=e.state,n=e.dispatch;return ho(t,n)}},joinForward:function(){return function(e){var t=e.state,n=e.dispatch;return mo(t,n)}},keyboardShortcut:function(e){return function(t){var n=t.editor,r=t.view,i=t.tr,o=t.dispatch,s=function(e){var t,n,r,i,o=e.split(/-(?!$)/),s=o[o.length-1];"Space"===s&&(s=" ");for(var a=0;a<o.length-1;a+=1){var c=o[a];if(/^(cmd|meta|m)$/i.test(c))i=!0;else if(/^a(lt)?$/i.test(c))t=!0;else if(/^(c|ctrl|control)$/i.test(c))n=!0;else if(/^s(hift)?$/i.test(c))r=!0;else{if(!/^mod$/i.test(c))throw new Error("Unrecognized modifier name: ".concat(c));bs()||Ss()?i=!0:n=!0}}return t&&(s="Alt-".concat(s)),n&&(s="Ctrl-".concat(s)),i&&(s="Meta-".concat(s)),r&&(s="Shift-".concat(s)),s}(e).split(/-(?!$)/),a=s.find((function(e){return!["Alt","Ctrl","Meta","Shift"].includes(e)})),c=new KeyboardEvent("keydown",{key:"Space"===a?" ":a,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0}),u=n.captureTransaction((function(){r.someProp("handleKeyDown",(function(e){return e(r,c)}))}));return null==u||u.steps.forEach((function(e){var t=e.map(i.mapping);t&&o&&i.maybeStep(t)})),!0}},lift:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var r=n.state,i=n.dispatch;return!!Cs(r,qo(e,r.schema),t)&&ko(r,i)}},liftEmptyBlock:function(){return function(e){var t=e.state,n=e.dispatch;return So(t,n)}},liftListItem:function(e){return function(t){var n,r=t.state,i=t.dispatch;return(n=qo(e,r.schema),function(e,t){var r=e.selection,i=r.$from,o=r.$to,s=i.blockRange(o,(function(e){return e.childCount>0&&e.firstChild.type==n}));return!!s&&(!t||(i.node(s.depth-1).type==n?function(e,t,n,r){var i=e.tr,o=r.end,s=r.$to.end(r.depth);o<s&&(i.step(new He(o-1,s,o,s,new D(C.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new K(i.doc.resolve(r.$from.pos),i.doc.resolve(s),r.depth));var a=We(r);if(null==a)return!1;i.lift(r,a);var c=i.mapping.map(o,-1)-1;return tt(i.doc,c)&&i.join(c),t(i.scrollIntoView()),!0}(e,t,n,s):function(e,t,n){for(var r=e.tr,i=n.parent,o=n.end,s=n.endIndex-1,a=n.startIndex;s>a;s--)o-=i.child(s).nodeSize,r.delete(o-1,o+1);var c=r.doc.resolve(n.start),u=c.nodeAfter;if(r.mapping.map(n.end)!=n.start+c.nodeAfter.nodeSize)return!1;var l=0==n.startIndex,d=n.endIndex==i.childCount,h=c.node(-1),f=c.index(-1);if(!h.canReplace(f+(l?0:1),f+1,u.content.append(d?C.empty:C.from(i))))return!1;var p=c.pos,v=p+u.nodeSize;return r.step(new He(p-(l?1:0),v+(d?1:0),p+1,v-1,new D((l?C.empty:C.from(i.copy(C.empty))).append(d?C.empty:C.from(i.copy(C.empty))),l?0:1,d?0:1),l?0:1)),t(r.scrollIntoView()),!0}(e,t,s)))})(r,i)}},newlineInCode:function(){return function(e){var t=e.state,n=e.dispatch;return wo(t,n)}},resetAttributes:function(e,t){return function(n){var r=n.tr,i=n.state,o=n.dispatch,s=null,a=null,c=Os("string"==typeof e?e:e.name,i.schema);return!!c&&("node"===c&&(s=qo(e,i.schema)),"mark"===c&&(a=gs(e,i.schema)),o&&r.selection.ranges.forEach((function(e){i.doc.nodesBetween(e.$from.pos,e.$to.pos,(function(e,n){s&&s===e.type&&r.setNodeMarkup(n,void 0,Ts(e.attrs,t)),a&&e.marks.length&&e.marks.forEach((function(i){a===i.type&&r.addMark(n,n+e.nodeSize,a.create(Ts(i.attrs,t)))}))}))})),!0)}},scrollIntoView:function(){return function(e){var t=e.tr;return e.dispatch&&t.scrollIntoView(),!0}},selectAll:function(){return function(e){var t=e.tr;return e.commands.setTextSelection({from:0,to:t.doc.content.size})}},selectNodeBackward:function(){return function(e){var t=e.state,n=e.dispatch;return po(t,n)}},selectNodeForward:function(){return function(e){var t=e.state,n=e.dispatch;return go(t,n)}},selectParentNode:function(){return function(e){return t=e.state,n=e.dispatch,i=t.selection,o=i.$from,s=i.to,0!=(a=o.sharedDepth(s))&&(r=o.before(a),n&&n(t.tr.setSelection(Tt.create(t.doc,r))),!0);var t,n,r,i,o,s,a}},selectTextblockEnd:function(){return function(e){var t=e.state,n=e.dispatch;return No(t,n)}},selectTextblockStart:function(){return function(e){var t=e.state,n=e.dispatch;return To(t,n)}},setContent:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return function(r){var i=r.tr,o=r.editor,s=r.dispatch,a=i.doc,c=Ns(e,o.schema,n);return s&&i.replaceWith(0,a.content.size,c).setMeta("preventUpdate",!t),!0}},setMark:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var r=n.tr,i=n.state,o=n.dispatch,s=r.selection,a=s.empty,c=s.ranges,u=gs(e,i.schema);if(o)if(a){var l=Ds(i,u);r.addStoredMark(u.create(w(w({},l),t)))}else c.forEach((function(e){var n=e.$from.pos,o=e.$to.pos;i.doc.nodesBetween(n,o,(function(e,i){var s=Math.max(i,n),a=Math.min(i+e.nodeSize,o);e.marks.find((function(e){return e.type===u}))?e.marks.forEach((function(e){u===e.type&&r.addMark(s,a,u.create(w(w({},e.attrs),t)))})):r.addMark(s,a,u.create(t))}))}));return zs(i,r,u)}},setMeta:function(e,t){return function(n){return n.tr.setMeta(e,t),!0}},setNode:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var r=n.state,i=n.dispatch,o=n.chain,s=qo(e,r.schema);return s.isTextblock?o().command((function(e){var n=e.commands;return!!Ao(s,t)(r)||n.clearNodes()})).command((function(e){var n=e.state;return Ao(s,t)(n,i)})).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)}},setNodeSelection:function(e){return function(t){var n=t.tr;if(t.dispatch){var r=n.doc,i=ks(e,0,r.content.size),o=Tt.create(r,i);n.setSelection(o)}return!0}},setTextSelection:function(e){return function(t){var n=t.tr;if(t.dispatch){var r=n.doc,i="number"==typeof e?{from:e,to:e}:e,o=i.from,s=i.to,a=Ct.atStart(r).from,c=Ct.atEnd(r).to,u=ks(o,a,c),l=ks(s,a,c),d=Ct.create(r,u,l);n.setSelection(d)}return!0}},sinkListItem:function(e){return function(t){var n,r=t.state,i=t.dispatch,o=qo(e,r.schema);return(n=o,function(e,t){var r=e.selection,i=r.$from,o=r.$to,s=i.blockRange(o,(function(e){return e.childCount>0&&e.firstChild.type==n}));if(!s)return!1;var a=s.startIndex;if(0==a)return!1;var c=s.parent,u=c.child(a-1);if(u.type!=n)return!1;if(t){var l=u.lastChild&&u.lastChild.type==c.type,d=C.from(l?n.create():null),h=new D(C.from(n.create(null,C.from(c.type.create(null,d)))),l?3:1,0),f=s.start,p=s.end;t(e.tr.step(new He(f-(l?3:1),p,f,p,h,1,!0)).scrollIntoView())}return!0})(r,i)}},splitBlock:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.keepMarks,n=void 0===t||t;return function(e){var t=e.tr,r=e.state,i=e.dispatch,o=e.editor,s=t.selection,a=t.doc,c=s.$from,u=s.$to,l=Bs(o.extensionManager.attributes,c.node().type.name,c.node().attrs);if(s instanceof Tt&&s.node.isBlock)return!(!c.parentOffset||!Qe(a,c.pos)||(i&&(n&&Zs(r,o.extensionManager.splittableMarks),t.split(c.pos).scrollIntoView()),0));if(!c.parent.isBlock)return!1;if(i){var d=u.parentOffset===u.parent.content.size;s instanceof Ct&&t.deleteSelection();var h=0===c.depth?void 0:Es(c.node(-1).contentMatchAt(c.indexAfter(-1))),f=d&&h?[{type:h,attrs:l}]:void 0,p=Qe(t.doc,t.mapping.map(c.pos),1,f);if(f||p||!Qe(t.doc,t.mapping.map(c.pos),1,h?[{type:h}]:void 0)||(p=!0,f=h?[{type:h,attrs:l}]:void 0),p&&(t.split(t.mapping.map(c.pos),1,f),h&&!d&&!c.parentOffset&&c.parent.type!==h)){var v=t.mapping.map(c.before()),m=t.doc.resolve(v);c.node(-1).canReplaceWith(m.index(),m.index()+1,h)&&t.setNodeMarkup(t.mapping.map(c.before()),h)}n&&Zs(r,o.extensionManager.splittableMarks),t.scrollIntoView()}return!0}},splitListItem:function(e){return function(t){var n,r=t.tr,i=t.state,o=t.dispatch,s=t.editor,a=qo(e,i.schema),c=i.selection,u=c.$from,l=c.$to,d=i.selection.node;if(d&&d.isBlock||u.depth<2||!u.sameParent(l))return!1;var h=u.node(-1);if(h.type!==a)return!1;var f=s.extensionManager.attributes;if(0===u.parent.content.size&&u.node(-1).childCount===u.indexAfter(-1)){if(2===u.depth||u.node(-3).type!==a||u.index(-2)!==u.node(-2).childCount-1)return!1;if(o){for(var p=C.empty,v=u.index(-1)?1:u.index(-2)?2:3,m=u.depth-v;m>=u.depth-3;m-=1)p=C.from(u.node(m).copy(p));var g=u.indexAfter(-1)<u.node(-2).childCount?1:u.indexAfter(-2)<u.node(-3).childCount?2:3,y=Bs(f,u.node().type.name,u.node().attrs),k=(null===(n=a.contentMatch.defaultType)||void 0===n?void 0:n.createAndFill(y))||void 0;p=p.append(C.from(a.createAndFill(null,k)||void 0));var w=u.before(u.depth-(v-1));r.replace(w,u.after(-g),new D(p,4-v,0));var b=-1;r.doc.nodesBetween(w,r.doc.content.size,(function(e,t){if(b>-1)return!1;e.isTextblock&&0===e.content.size&&(b=t+1)})),b>-1&&r.setSelection(Ct.near(r.doc.resolve(b))),r.scrollIntoView()}return!0}var x=l.pos===u.end()?h.contentMatchAt(0).defaultType:null,M=Bs(f,h.type.name,h.attrs),S=Bs(f,u.node().type.name,u.node().attrs);r.delete(u.pos,l.pos);var O=x?[{type:a,attrs:M},{type:x,attrs:S}]:[{type:a,attrs:M}];return!!Qe(r.doc,u.pos,2)&&(o&&r.split(u.pos,2,O).scrollIntoView(),!0)}},toggleList:function(e,t){return function(n){var r=n.editor,i=n.tr,o=n.state,s=n.dispatch,a=n.chain,c=n.commands,u=n.can,l=r.extensionManager.extensions,d=qo(e,o.schema),h=qo(t,o.schema),f=o.selection,p=f.$from,v=f.$to,m=p.blockRange(v);if(!m)return!1;var g=As((function(e){return Rs(e.type.name,l)}))(f);if(m.depth>=1&&g&&m.depth-g.depth<=1){if(g.node.type===d)return c.liftListItem(h);if(Rs(g.node.type.name,l)&&d.validContent(g.node.content)&&s)return a().command((function(){return i.setNodeMarkup(g.pos,d),!0})).command((function(){return Ls(i,d)})).command((function(){return $s(i,d)})).run()}return a().command((function(){return!!u().wrapInList(d)||c.clearNodes()})).wrapInList(d).command((function(){return Ls(i,d)})).command((function(){return $s(i,d)})).run()}},toggleMark:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return function(r){var i=r.state,o=r.commands,s=n.extendEmptyMarkRange,a=void 0!==s&&s,c=gs(e,i.schema);return Is(i,c,t)?o.unsetMark(c,{extendEmptyMarkRange:a}):o.setMark(c,t)}},toggleNode:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return function(r){var i=r.state,o=r.commands,s=qo(e,i.schema),a=qo(t,i.schema);return Cs(i,s,n)?o.setNode(a):o.setNode(s,n)}},toggleWrap:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var r=n.state,i=n.commands,o=qo(e,r.schema);return Cs(r,o,t)?i.lift(o):i.wrapIn(o,t)}},undoInputRule:function(){return function(e){for(var t=e.state,n=e.dispatch,r=t.plugins,i=0;i<r.length;i+=1){var o=r[i],s=void 0;if(o.spec.isInputRules&&(s=o.getState(t))){if(n){for(var a=t.tr,c=s.transform,u=c.steps.length-1;u>=0;u-=1)a.step(c.steps[u].invert(c.docs[u]));if(s.text){var l=a.doc.resolve(s.from).marks();a.replaceWith(s.from,s.to,t.schema.text(s.text,l))}else a.delete(s.from,s.to)}return!0}}return!1}},unsetAllMarks:function(){return function(e){var t=e.tr,n=e.dispatch,r=t.selection,i=r.empty,o=r.ranges;return i||n&&o.forEach((function(e){t.removeMark(e.$from.pos,e.$to.pos)})),!0}},unsetMark:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var r,i=n.tr,o=n.state,s=n.dispatch,a=t.extendEmptyMarkRange,c=void 0!==a&&a,u=i.selection,l=gs(e,o.schema),d=u.$from,h=u.empty,f=u.ranges;if(!s)return!0;if(h&&c){var p=u.from,v=u.to,m=null===(r=d.marks().find((function(e){return e.type===l})))||void 0===r?void 0:r.attrs,g=ms(d,l,m);g&&(p=g.from,v=g.to),i.removeMark(p,v,l)}else f.forEach((function(e){i.removeMark(e.$from.pos,e.$to.pos,l)}));return i.removeStoredMark(l),!0}},updateAttributes:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var r=n.tr,i=n.state,o=n.dispatch,s=null,a=null,c=Os("string"==typeof e?e:e.name,i.schema);return!!c&&("node"===c&&(s=qo(e,i.schema)),"mark"===c&&(a=gs(e,i.schema)),o&&r.selection.ranges.forEach((function(e){var n=e.$from.pos,o=e.$to.pos;i.doc.nodesBetween(n,o,(function(e,i){s&&s===e.type&&r.setNodeMarkup(i,void 0,w(w({},e.attrs),t)),a&&e.marks.length&&e.marks.forEach((function(s){if(a===s.type){var c=Math.max(i,n),u=Math.min(i+e.nodeSize,o);r.addMark(c,u,a.create(w(w({},s.attrs),t)))}}))}))})),!0)}},wrapIn:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var r=n.state,i=n.dispatch;return Eo(qo(e,r.schema),t)(r,i)}},wrapInList:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var r=n.state,i=n.dispatch;return Zo(qo(e,r.schema),t)(r,i)}}}),Vs=us.create({name:"commands",addCommands:function(){return w({},Fs)}}),js=us.create({name:"editable",addProseMirrorPlugins:function(){var e=this;return[new Ft({key:new Ht("editable"),props:{editable:function(){return e.editor.options.editable}}})]}}),Hs=us.create({name:"focusEvents",addProseMirrorPlugins:function(){var e=this.editor;return[new Ft({key:new Ht("focusEvents"),props:{handleDOMEvents:{focus:function(t,n){e.isFocused=!0;var r=e.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return t.dispatch(r),!1},blur:function(t,n){e.isFocused=!1;var r=e.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return t.dispatch(r),!1}}}})]}}),Js=us.create({name:"keymap",addKeyboardShortcuts:function(){var e=this,t=function(){return e.editor.commands.first((function(e){var t=e.commands;return[function(){return t.undoInputRule()},function(){return t.command((function(e){var n=e.tr,r=n.selection,i=n.doc,o=r.empty,s=r.$anchor,a=s.pos,c=s.parent,u=bt.atStart(i).from===a;return!(!(o&&u&&c.type.isTextblock)||c.textContent.length)&&t.clearNodes()}))},function(){return t.deleteSelection()},function(){return t.joinBackward()},function(){return t.selectNodeBackward()}]}))},n=function(){return e.editor.commands.first((function(e){var t=e.commands;return[function(){return t.deleteSelection()},function(){return t.deleteCurrentNode()},function(){return t.joinForward()},function(){return t.selectNodeForward()}]}))},r={Enter:function(){return e.editor.commands.first((function(e){var t=e.commands;return[function(){return t.newlineInCode()},function(){return t.createParagraphNear()},function(){return t.liftEmptyBlock()},function(){return t.splitBlock()}]}))},"Mod-Enter":function(){return e.editor.commands.exitCode()},Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:n,"Mod-Delete":n,"Mod-a":function(){return e.editor.commands.selectAll()}},i=w({},r),o=w(w({},r),{},{"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":n,"Ctrl-Alt-Backspace":n,"Alt-Delete":n,"Alt-d":n,"Ctrl-a":function(){return e.editor.commands.selectTextblockStart()},"Ctrl-e":function(){return e.editor.commands.selectTextblockEnd()}});return bs()||Ss()?o:i},addProseMirrorPlugins:function(){var e=this;return[new Ft({key:new Ht("clearDocument"),appendTransaction:function(t,n,r){if(t.some((function(e){return e.docChanged}))&&!n.doc.eq(r.doc)){var i=n.selection,o=i.empty,s=i.from,a=i.to,c=bt.atStart(n.doc).from,u=bt.atEnd(n.doc).to,l=s===c&&a===u,d=0===r.doc.textBetween(0,r.doc.content.size," "," ").length;if(!o&&l&&d){var h=r.tr,f=$o({state:r,transaction:h});if(new Fo({editor:e.editor,state:f}).commands.clearNodes(),h.steps.length)return h}}}})]}}),qs=us.create({name:"tabindex",addProseMirrorPlugins:function(){return[new Ft({key:new Ht("tabindex"),props:{attributes:this.editor.isEditable?{tabindex:"0"}:{}}})]}}),Ws=Object.freeze({__proto__:null,ClipboardTextSerializer:hs,Commands:Vs,Editable:js,FocusEvents:Hs,Keymap:Js,Tabindex:qs}),Ks=function(e){(0,d.Z)(n,e);var t=b(n);function n(){var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return(0,v.Z)(this,n),(e=t.call(this)).isFocused=!1,e.extensionStorage={},e.options={element:document.createElement("div"),content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,onBeforeCreate:function(){return null},onCreate:function(){return null},onUpdate:function(){return null},onSelectionUpdate:function(){return null},onTransaction:function(){return null},onFocus:function(){return null},onBlur:function(){return null},onDestroy:function(){return null}},e.isCapturingTransaction=!1,e.capturedTransaction=null,e.setOptions(r),e.createExtensionManager(),e.createCommandManager(),e.createSchema(),e.on("beforeCreate",e.options.onBeforeCreate),e.emit("beforeCreate",{editor:(0,s.Z)(e)}),e.createView(),e.injectCSS(),e.on("create",e.options.onCreate),e.on("update",e.options.onUpdate),e.on("selectionUpdate",e.options.onSelectionUpdate),e.on("transaction",e.options.onTransaction),e.on("focus",e.options.onFocus),e.on("blur",e.options.onBlur),e.on("destroy",e.options.onDestroy),window.setTimeout((function(){e.isDestroyed||(e.commands.focus(e.options.autofocus),e.emit("create",{editor:(0,s.Z)(e)}))}),0),e}return(0,m.Z)(n,[{key:"storage",get:function(){return this.extensionStorage}},{key:"commands",get:function(){return this.commandManager.commands}},{key:"chain",value:function(){return this.commandManager.chain()}},{key:"can",value:function(){return this.commandManager.can()}},{key:"injectCSS",value:function(){this.options.injectCSS&&document&&(this.css=function(e,t){var n=document.querySelector("style[data-tiptap-style]");if(null!==n)return n;var r=document.createElement("style");return t&&r.setAttribute("nonce",t),r.setAttribute("data-tiptap-style",""),r.innerHTML='.ProseMirror {\n position: relative;\n}\n\n.ProseMirror {\n word-wrap: break-word;\n white-space: pre-wrap;\n white-space: break-spaces;\n -webkit-font-variant-ligatures: none;\n font-variant-ligatures: none;\n font-feature-settings: "liga" 0; /* the above doesn\'t seem to work in Edge */\n}\n\n.ProseMirror [contenteditable="false"] {\n white-space: normal;\n}\n\n.ProseMirror [contenteditable="false"] [contenteditable="true"] {\n white-space: pre-wrap;\n}\n\n.ProseMirror pre {\n white-space: pre-wrap;\n}\n\nimg.ProseMirror-separator {\n display: inline !important;\n border: none !important;\n margin: 0 !important;\n width: 1px !important;\n height: 1px !important;\n}\n\n.ProseMirror-gapcursor {\n display: none;\n pointer-events: none;\n position: absolute;\n margin: 0;\n}\n\n.ProseMirror-gapcursor:after {\n content: "";\n display: block;\n position: absolute;\n top: -2px;\n width: 20px;\n border-top: 1px solid black;\n animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;\n}\n\n@keyframes ProseMirror-cursor-blink {\n to {\n visibility: hidden;\n }\n}\n\n.ProseMirror-hideselection *::selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection *::-moz-selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection * {\n caret-color: transparent;\n}\n\n.ProseMirror-focused .ProseMirror-gapcursor {\n display: block;\n}\n\n.tippy-box[data-animation=fade][data-state=hidden] {\n opacity: 0\n}',document.getElementsByTagName("head")[0].appendChild(r),r}(0,this.options.injectNonce))}},{key:"setOptions",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.options=w(w({},this.options),e),this.view&&this.state&&!this.isDestroyed&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}},{key:"setEditable",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];this.setOptions({editable:e}),t&&this.emit("update",{editor:this,transaction:this.state.tr})}},{key:"isEditable",get:function(){return this.options.editable&&this.view&&this.view.editable}},{key:"state",get:function(){return this.view.state}},{key:"registerPlugin",value:function(e,t){var n=_o(t)?t(e,(0,i.Z)(this.state.plugins)):[].concat((0,i.Z)(this.state.plugins),[e]),r=this.state.reconfigure({plugins:n});this.view.updateState(r)}},{key:"unregisterPlugin",value:function(e){if(!this.isDestroyed){var t="string"==typeof e?"".concat(e,"$"):e.key,n=this.state.reconfigure({plugins:this.state.plugins.filter((function(e){return!e.key.startsWith(t)}))});this.view.updateState(n)}}},{key:"createExtensionManager",value:function(){var e=this.options.enableCoreExtensions?Object.values(Ws):[],t=[].concat((0,i.Z)(e),(0,i.Z)(this.options.extensions)).filter((function(e){return["extension","node","mark"].includes(null==e?void 0:e.type)}));this.extensionManager=new ss(t,this)}},{key:"createCommandManager",value:function(){this.commandManager=new Fo({editor:this})}},{key:"createSchema",value:function(){this.schema=this.extensionManager.schema}},{key:"createView",value:function(){var e=Ns(this.options.content,this.schema,this.options.parseOptions),t=ws(e,this.options.autofocus);this.view=new Wi(this.options.element,w(w({},this.options.editorProps),{},{dispatchTransaction:this.dispatchTransaction.bind(this),state:Lt.create({doc:e,selection:t||void 0})}));var n=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(n),this.createNodeViews(),this.view.dom.editor=this}},{key:"createNodeViews",value:function(){this.view.setProps({nodeViews:this.extensionManager.nodeViews})}},{key:"captureTransaction",value:function(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;var t=this.capturedTransaction;return this.capturedTransaction=null,t}},{key:"dispatchTransaction",value:function(e){var t=this;if(this.isCapturingTransaction)return this.capturedTransaction?void e.steps.forEach((function(e){var n;return null===(n=t.capturedTransaction)||void 0===n?void 0:n.step(e)})):void(this.capturedTransaction=e);var n=this.state.apply(e),r=!this.state.selection.eq(n.selection);this.view.updateState(n),this.emit("transaction",{editor:this,transaction:e}),r&&this.emit("selectionUpdate",{editor:this,transaction:e});var i=e.getMeta("focus"),o=e.getMeta("blur");i&&this.emit("focus",{editor:this,event:i.event,transaction:e}),o&&this.emit("blur",{editor:this,event:o.event,transaction:e}),e.docChanged&&!e.getMeta("preventUpdate")&&this.emit("update",{editor:this,transaction:e})}},{key:"getAttributes",value:function(e){return t=this.state,"node"===(r=Os("string"==typeof(n=e)?n:n.name,t.schema))?function(e,t){var n=qo(t,e.schema),r=e.selection,i=r.from,o=r.to,s=[];e.doc.nodesBetween(i,o,(function(e){s.push(e)}));var a=s.reverse().find((function(e){return e.type.name===n.name}));return a?w({},a.attrs):{}}(t,n):"mark"===r?Ds(t,n):{};var t,n,r}},{key:"isActive",value:function(e,t){var n="string"==typeof e?e:null,r="string"==typeof e?t:e;return function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!t)return Cs(e,null,n)||Is(e,null,n);var r=Os(t,e.schema);return"node"===r?Cs(e,t,n):"mark"===r&&Is(e,t,n)}(this.state,n,r)}},{key:"getJSON",value:function(){return this.state.doc.toJSON()}},{key:"getHTML",value:function(){return e=this.state.doc.content,t=this.schema,n=Oe.fromSchema(t).serializeFragment(e),(r=document.implementation.createHTMLDocument().createElement("div")).appendChild(n),r.innerHTML;var e,t,n,r}},{key:"getText",value:function(e){var t=e||{},n=t.blockSeparator,r=void 0===n?"\n\n":n,i=t.textSerializers,o=void 0===i?{}:i;return function(e,t){return ls(e,{from:0,to:e.content.size},t)}(this.state.doc,{blockSeparator:r,textSerializers:w(w({},o),ds(this.schema))})}},{key:"isEmpty",get:function(){return n=null===(t=(e=this.state.doc).type.createAndFill())||void 0===t?void 0:t.toJSON(),r=e.toJSON(),JSON.stringify(n)===JSON.stringify(r);var e,t,n,r}},{key:"getCharacterCount",value:function(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}},{key:"destroy",value:function(){this.emit("destroy"),this.view&&this.view.destroy(),this.removeAllListeners()}},{key:"isDestroyed",get:function(){var e;return!(null===(e=this.view)||void 0===e?void 0:e.docView)}}]),n}(Vo);function _s(e){return new ts({find:e.find,handler:function(t){var n=t.state,r=t.range,i=t.match,o=Uo(e.getAttributes,void 0,i);if(!1===o||null===o)return null;var s=n.tr,a=i[i.length-1],c=i[0],u=r.to;if(a){var l=c.search(/\S/),d=r.from+c.indexOf(a),h=d+a.length;if(Ps(r.from,r.to,n.doc).filter((function(t){return t.mark.type.excluded.find((function(n){return n===e.type&&n!==t.mark.type}))})).filter((function(e){return e.to>d})).length)return null;h<r.to&&s.delete(h,r.to),d>r.from&&s.delete(r.from+l,d),u=r.from+l+a.length,s.addMark(r.from+l,u,e.type.create(o||{})),s.removeStoredMark(e.type)}}})}function Us(e){return new ts({find:e.find,handler:function(t){var n=t.state,r=t.range,i=t.match,o=n.doc.resolve(r.from),s=Uo(e.getAttributes,void 0,i)||{};if(!o.node(-1).canReplaceWith(o.index(-1),o.indexAfter(-1),e.type))return null;n.tr.delete(r.from,r.to).setBlockType(r.from,r.from,e.type,s)}})}function Gs(e){return new ts({find:e.find,handler:function(t){var n=t.state,r=t.range,i=t.match,o=Uo(e.getAttributes,void 0,i)||{},s=n.tr.delete(r.from,r.to),a=s.doc.resolve(r.from).blockRange(),c=a&&Ke(a,e.type,o);if(!c)return null;s.wrap(a,c);var u=s.doc.resolve(r.from-1).nodeBefore;u&&u.type===e.type&&tt(s.doc,r.from-1)&&(!e.joinPredicate||e.joinPredicate(i,u))&&s.join(r.from-1)}})}var Xs=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(0,v.Z)(this,e),this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config=w(w({},this.config),t),this.name=this.config.name,t.defaultOptions&&console.warn('[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "'.concat(this.name,'".')),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=Uo(jo(this,"addOptions",{name:this.name}))),this.storage=Uo(jo(this,"addStorage",{name:this.name,options:this.options}))||{}}return(0,m.Z)(e,[{key:"configure",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=this.extend();return t.options=cs(this.options,e),t.storage=Uo(jo(t,"addStorage",{name:t.name,options:t.options})),t}},{key:"extend",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=new e(t);return n.parent=this,this.child=n,n.name=t.name?t.name:n.parent.name,t.defaultOptions&&console.warn('[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "'.concat(n.name,'".')),n.options=Uo(jo(n,"addOptions",{name:n.name})),n.storage=Uo(jo(n,"addStorage",{name:n.name,options:n.options})),n}}],[{key:"create",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new e(t)}},{key:"handleExit",value:function(e){var t=e.editor,n=e.mark,r=t.state.tr,i=t.state.selection.$from;if(i.pos===i.end()){var o=i.marks();if(!o.find((function(e){return(null==e?void 0:e.type.name)===n.name})))return!1;var s=o.find((function(e){return(null==e?void 0:e.type.name)===n.name}));return s&&r.removeStoredMark(s),r.insertText(" ",i.pos),t.view.dispatch(r),!0}return!1}}]),e}(),Ys=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(0,v.Z)(this,e),this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config=w(w({},this.config),t),this.name=this.config.name,t.defaultOptions&&console.warn('[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "'.concat(this.name,'".')),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=Uo(jo(this,"addOptions",{name:this.name}))),this.storage=Uo(jo(this,"addStorage",{name:this.name,options:this.options}))||{}}return(0,m.Z)(e,[{key:"configure",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=this.extend();return t.options=cs(this.options,e),t.storage=Uo(jo(t,"addStorage",{name:t.name,options:t.options})),t}},{key:"extend",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=new e(t);return n.parent=this,this.child=n,n.name=t.name?t.name:n.parent.name,t.defaultOptions&&console.warn('[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "'.concat(n.name,'".')),n.options=Uo(jo(n,"addOptions",{name:n.name})),n.storage=Uo(jo(n,"addStorage",{name:n.name,options:n.options})),n}}],[{key:"create",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new e(t)}}]),e}();function Qs(e){return new is({find:e.find,handler:function(t){var n=t.state,r=t.range,i=t.match,o=Uo(e.getAttributes,void 0,i);if(!1===o||null===o)return null;var s=n.tr,a=i[i.length-1],c=i[0],u=r.to;if(a){var l=c.search(/\S/),d=r.from+c.indexOf(a),h=d+a.length;if(Ps(r.from,r.to,n.doc).filter((function(t){return t.mark.type.excluded.find((function(n){return n===e.type&&n!==t.mark.type}))})).filter((function(e){return e.to>d})).length)return null;h<r.to&&s.delete(h,r.to),d>r.from&&s.delete(r.from+l,d),u=r.from+l+a.length,s.addMark(r.from+l,u,e.type.create(o||{})),s.removeStoredMark(e.type)}}})}var ea=us.create({name:"characterCount",addOptions:function(){return{limit:null,mode:"textSize"}},addStorage:function(){return{characters:function(){return 0},words:function(){return 0}}},onBeforeCreate:function(){var e=this;this.storage.characters=function(t){var n=(null==t?void 0:t.node)||e.editor.state.doc;return"textSize"===((null==t?void 0:t.mode)||e.options.mode)?n.textBetween(0,n.content.size,void 0," ").length:n.nodeSize},this.storage.words=function(t){var n=(null==t?void 0:t.node)||e.editor.state.doc;return n.textBetween(0,n.content.size," "," ").split(" ").filter((function(e){return""!==e})).length}},addProseMirrorPlugins:function(){var e=this;return[new Ft({key:new Ht("characterCount"),filterTransaction:function(t,n){var r=e.options.limit;if(!t.docChanged||0===r||null==r)return!0;var i=e.storage.characters({node:n.doc}),o=e.storage.characters({node:t.doc});if(o<=r)return!0;if(i>r&&o>r&&o<=i)return!0;if(i>r&&o>r&&o>i)return!1;if(!t.getMeta("paste"))return!1;var s=t.selection.$head.pos,a=s-(o-r),c=s;return t.deleteRange(a,c),!(e.storage.characters({node:t.doc})>r)}})]}}),ta=us.create({name:"placeholder",addOptions:function(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins:function(){var e=this;return[new Ft({key:new Ht("placeholder"),props:{decorations:function(t){var n=t.doc,r=t.selection,i=e.editor.isEditable||!e.options.showOnlyWhenEditable,o=r.anchor,s=[];if(!i)return null;var a=n.type.createAndFill(),c=(null==a?void 0:a.sameMarkup(n))&&null===a.content.findDiffStart(n.content);return n.descendants((function(t,n){var r=o>=n&&o<=n+t.nodeSize,i=!t.isLeaf&&!t.childCount;if((r||!e.options.showOnlyCurrent)&&i){var a=[e.options.emptyNodeClass];c&&a.push(e.options.emptyEditorClass);var u=xi.node(n,n+t.nodeSize,{class:a.join(" "),"data-placeholder":"function"==typeof e.options.placeholder?e.options.placeholder({editor:e.editor,node:t,pos:n,hasAnchor:r}):e.options.placeholder});s.push(u)}return e.options.includeChildren})),Ci.create(n,s)}}})]}}),na=/^\s*>\s$/,ra=Ys.create({name:"blockquote",addOptions:function(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML:function(){return[{tag:"blockquote"}]},renderHTML:function(e){var t=e.HTMLAttributes;return["blockquote",Wo(this.options.HTMLAttributes,t),0]},addCommands:function(){var e=this;return{setBlockquote:function(){return function(t){return t.commands.wrapIn(e.name)}},toggleBlockquote:function(){return function(t){return t.commands.toggleWrap(e.name)}},unsetBlockquote:function(){return function(t){return t.commands.lift(e.name)}}}},addKeyboardShortcuts:function(){var e=this;return{"Mod-Shift-b":function(){return e.editor.commands.toggleBlockquote()}}},addInputRules:function(){return[Gs({find:na,type:this.type})]}}),ia=/(?:^|\s)((?:\*\*)((?:[^*]+))(?:\*\*))$/,oa=/(?:^|\s)((?:\*\*)((?:[^*]+))(?:\*\*))/g,sa=/(?:^|\s)((?:__)((?:[^__]+))(?:__))$/,aa=/(?:^|\s)((?:__)((?:[^__]+))(?:__))/g,ca=Xs.create({name:"bold",addOptions:function(){return{HTMLAttributes:{}}},parseHTML:function(){return[{tag:"strong"},{tag:"b",getAttrs:function(e){return"normal"!==e.style.fontWeight&&null}},{style:"font-weight",getAttrs:function(e){return/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}}]},renderHTML:function(e){var t=e.HTMLAttributes;return["strong",Wo(this.options.HTMLAttributes,t),0]},addCommands:function(){var e=this;return{setBold:function(){return function(t){return t.commands.setMark(e.name)}},toggleBold:function(){return function(t){return t.commands.toggleMark(e.name)}},unsetBold:function(){return function(t){return t.commands.unsetMark(e.name)}}}},addKeyboardShortcuts:function(){var e=this;return{"Mod-b":function(){return e.editor.commands.toggleBold()},"Mod-B":function(){return e.editor.commands.toggleBold()}}},addInputRules:function(){return[_s({find:ia,type:this.type}),_s({find:sa,type:this.type})]},addPasteRules:function(){return[Qs({find:oa,type:this.type}),Qs({find:aa,type:this.type})]}}),ua=/^\s*([-+*])\s$/,la=Ys.create({name:"bulletList",addOptions:function(){return{itemTypeName:"listItem",HTMLAttributes:{}}},group:"block list",content:function(){return"".concat(this.options.itemTypeName,"+")},parseHTML:function(){return[{tag:"ul"}]},renderHTML:function(e){var t=e.HTMLAttributes;return["ul",Wo(this.options.HTMLAttributes,t),0]},addCommands:function(){var e=this;return{toggleBulletList:function(){return function(t){return t.commands.toggleList(e.name,e.options.itemTypeName)}}}},addKeyboardShortcuts:function(){var e=this;return{"Mod-Shift-8":function(){return e.editor.commands.toggleBulletList()}}},addInputRules:function(){return[Gs({find:ua,type:this.type})]}}),da=/(?:^|\s)((?:`)((?:[^`]+))(?:`))$/,ha=/(?:^|\s)((?:`)((?:[^`]+))(?:`))/g,fa=Xs.create({name:"code",addOptions:function(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML:function(){return[{tag:"code"}]},renderHTML:function(e){var t=e.HTMLAttributes;return["code",Wo(this.options.HTMLAttributes,t),0]},addCommands:function(){var e=this;return{setCode:function(){return function(t){return t.commands.setMark(e.name)}},toggleCode:function(){return function(t){return t.commands.toggleMark(e.name)}},unsetCode:function(){return function(t){return t.commands.unsetMark(e.name)}}}},addKeyboardShortcuts:function(){var e=this;return{"Mod-e":function(){return e.editor.commands.toggleCode()}}},addInputRules:function(){return[_s({find:da,type:this.type})]},addPasteRules:function(){return[Qs({find:ha,type:this.type})]}}),pa=/^```([a-z]+)?[\s\n]$/,va=/^~~~([a-z]+)?[\s\n]$/,ma=Ys.create({name:"codeBlock",addOptions:function(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes:function(){var e=this;return{language:{default:null,parseHTML:function(t){var n,r=e.options.languageClassPrefix;return(0,i.Z)((null===(n=t.firstElementChild)||void 0===n?void 0:n.classList)||[]).filter((function(e){return e.startsWith(r)})).map((function(e){return e.replace(r,"")}))[0]||null},rendered:!1}}},parseHTML:function(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML:function(e){var t=e.node,n=e.HTMLAttributes;return["pre",Wo(this.options.HTMLAttributes,n),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},addCommands:function(){var e=this;return{setCodeBlock:function(t){return function(n){return n.commands.setNode(e.name,t)}},toggleCodeBlock:function(t){return function(n){return n.commands.toggleNode(e.name,"paragraph",t)}}}},addKeyboardShortcuts:function(){var e=this;return{"Mod-Alt-c":function(){return e.editor.commands.toggleCodeBlock()},Backspace:function(){var t=e.editor.state.selection,n=t.empty,r=t.$anchor,i=1===r.pos;return!(!n||r.parent.type.name!==e.name)&&!(!i&&r.parent.textContent.length)&&e.editor.commands.clearNodes()},Enter:function(t){var n=t.editor;if(!e.options.exitOnTripleEnter)return!1;var r=n.state.selection,i=r.$from;if(!r.empty||i.parent.type!==e.type)return!1;var o=i.parentOffset===i.parent.nodeSize-2,s=i.parent.textContent.endsWith("\n\n");return!(!o||!s)&&n.chain().command((function(e){return e.tr.delete(i.pos-2,i.pos),!0})).exitCode().run()},ArrowDown:function(t){var n=t.editor;if(!e.options.exitOnArrowDown)return!1;var r=n.state,i=r.selection,o=r.doc,s=i.$from;if(!i.empty||s.parent.type!==e.type)return!1;if(s.parentOffset!==s.parent.nodeSize-2)return!1;var a=s.after();return void 0!==a&&!o.nodeAt(a)&&n.commands.exitCode()}}},addInputRules:function(){return[Us({find:pa,type:this.type,getAttributes:function(e){return{language:e[1]}}}),Us({find:va,type:this.type,getAttributes:function(e){return{language:e[1]}}})]},addProseMirrorPlugins:function(){var e=this;return[new Ft({key:new Ht("codeBlockVSCodeHandler"),props:{handlePaste:function(t,n){if(!n.clipboardData)return!1;if(e.editor.isActive(e.type.name))return!1;var r=n.clipboardData.getData("text/plain"),i=n.clipboardData.getData("vscode-editor-data"),o=i?JSON.parse(i):void 0,s=null==o?void 0:o.mode;if(!r||!s)return!1;var a=t.state.tr;return a.replaceSelectionWith(e.type.create({language:s})),a.setSelection(Ct.near(a.doc.resolve(Math.max(0,a.selection.from-2)))),a.insertText(r.replace(/\r\n?/g,"\n")),a.setMeta("paste",!0),t.dispatch(a),!0}}})]}}),ga=Ys.create({name:"doc",topNode:!0,content:"block+"});function ya(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Ft({view:function(t){return new ka(t,e)}})}var ka=function(){function e(t,n){var r=this;(0,v.Z)(this,e),this.editorView=t,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=n.width||1,this.color=n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map((function(e){var n=function(t){r[e](t)};return t.dom.addEventListener(e,n),{name:e,handler:n}}))}return(0,m.Z)(e,[{key:"destroy",value:function(){var e=this;this.handlers.forEach((function(t){var n=t.name,r=t.handler;return e.editorView.dom.removeEventListener(n,r)}))}},{key:"update",value:function(e,t){null!=this.cursorPos&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}},{key:"setCursor",value:function(e){e!=this.cursorPos&&(this.cursorPos=e,null==e?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}},{key:"updateOverlay",value:function(){var e,t=this.editorView.state.doc.resolve(this.cursorPos),n=!t.parent.inlineContent;if(n){var r=t.nodeBefore,i=t.nodeAfter;if(r||i){var o=this.editorView.nodeDOM(this.cursorPos-(r?r.nodeSize:0));if(o){var s=o.getBoundingClientRect(),a=r?s.bottom:s.top;r&&i&&(a=(a+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2),e={left:s.left,right:s.right,top:a-this.width/2,bottom:a+this.width/2}}}}if(!e){var c=this.editorView.coordsAtPos(this.cursorPos);e={left:c.left-this.width/2,right:c.left+this.width/2,top:c.top,bottom:c.bottom}}var u,l,d=this.editorView.dom.offsetParent;if(this.element||(this.element=d.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),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n),!d||d==document.body&&"static"==getComputedStyle(d).position)u=-pageXOffset,l=-pageYOffset;else{var h=d.getBoundingClientRect();u=h.left-d.scrollLeft,l=h.top-d.scrollTop}this.element.style.left=e.left-u+"px",this.element.style.top=e.top-l+"px",this.element.style.width=e.right-e.left+"px",this.element.style.height=e.bottom-e.top+"px"}},{key:"scheduleRemoval",value:function(e){var t=this;clearTimeout(this.timeout),this.timeout=setTimeout((function(){return t.setCursor(null)}),e)}},{key:"dragover",value:function(e){if(this.editorView.editable){var t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,i="function"==typeof r?r(this.editorView,t,e):r;if(t&&!i){var o=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice&&null==(o=ot(this.editorView.state.doc,o,this.editorView.dragging.slice)))return this.setCursor(null);this.setCursor(o),this.scheduleRemoval(5e3)}}}},{key:"dragend",value:function(){this.scheduleRemoval(20)}},{key:"drop",value:function(){this.scheduleRemoval(20)}},{key:"dragleave",value:function(e){e.target!=this.editorView.dom&&this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}]),e}(),wa=us.create({name:"dropCursor",addOptions:function(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins:function(){return[ya(this.options)]}}),ba=function(e){(0,d.Z)(n,e);var t=b(n);function n(e){return(0,v.Z)(this,n),t.call(this,e,e)}return(0,m.Z)(n,[{key:"map",value:function(e,t){var r=e.resolve(t.map(this.head));return n.valid(r)?new n(r):bt.near(r)}},{key:"content",value:function(){return D.empty}},{key:"eq",value:function(e){return e instanceof n&&e.head==this.head}},{key:"toJSON",value:function(){return{type:"gapcursor",pos:this.head}}},{key:"getBookmark",value:function(){return new xa(this.anchor)}}],[{key:"fromJSON",value:function(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for GapCursor.fromJSON");return new n(e.resolve(t.pos))}},{key:"valid",value:function(e){var t=e.parent;if(t.isTextblock||!function(e){for(var t=e.depth;t>=0;t--){var n=e.index(t),r=e.node(t);if(0!=n)for(var i=r.child(n-1);;i=i.lastChild){if(0==i.childCount&&!i.inlineContent||i.isAtom||i.type.spec.isolating)return!0;if(i.inlineContent)return!1}else if(r.type.spec.isolating)return!0}return!0}(e)||!function(e){for(var t=e.depth;t>=0;t--){var n=e.indexAfter(t),r=e.node(t);if(n!=r.childCount)for(var i=r.child(n);;i=i.firstChild){if(0==i.childCount&&!i.inlineContent||i.isAtom||i.type.spec.isolating)return!0;if(i.inlineContent)return!1}else if(r.type.spec.isolating)return!0}return!0}(e))return!1;var n=t.type.spec.allowGapCursor;if(null!=n)return n;var r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}},{key:"findGapCursorFrom",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];e:for(;;){if(!r&&n.valid(e))return e;for(var i=e.pos,o=null,s=e.depth;;s--){var a=e.node(s);if(t>0?e.indexAfter(s)<a.childCount:e.index(s)>0){o=a.child(t>0?e.indexAfter(s):e.index(s)-1);break}if(0==s)return null;i+=t;var c=e.doc.resolve(i);if(n.valid(c))return c}for(;;){var u=t>0?o.firstChild:o.lastChild;if(!u){if(o.isAtom&&!o.isText&&!Tt.isSelectable(o)){e=e.doc.resolve(i+o.nodeSize*t),r=!1;continue e}break}o=u,i+=t;var l=e.doc.resolve(i);if(n.valid(l))return l}return null}}}]),n}(bt);ba.prototype.visible=!1,ba.findFrom=ba.findGapCursorFrom,bt.jsonID("gapcursor",ba);var xa=function(){function e(t){(0,v.Z)(this,e),this.pos=t}return(0,m.Z)(e,[{key:"map",value:function(t){return new e(t.map(this.pos))}},{key:"resolve",value:function(e){var t=e.resolve(this.pos);return ba.valid(t)?new ba(t):bt.near(t)}}]),e}(),Ma=uo({ArrowLeft:Sa("horiz",-1),ArrowRight:Sa("horiz",1),ArrowUp:Sa("vert",-1),ArrowDown:Sa("vert",1)});function Sa(e,t){var n="vert"==e?t>0?"down":"up":t>0?"right":"left";return function(e,r,i){var o=e.selection,s=t>0?o.$to:o.$from,a=o.empty;if(o instanceof Ct){if(!i.endOfTextblock(n)||0==s.depth)return!1;a=!1,s=e.doc.resolve(t>0?s.after():s.before())}var c=ba.findGapCursorFrom(s,t,a);return!!c&&(r&&r(e.tr.setSelection(new ba(c))),!0)}}function Ca(e,t,n){if(!e||!e.editable)return!1;var r=e.state.doc.resolve(t);if(!ba.valid(r))return!1;var i=e.posAtCoords({left:n.clientX,top:n.clientY});return!(i&&i.inside>-1&&Tt.isSelectable(e.state.doc.nodeAt(i.inside))||(e.dispatch(e.state.tr.setSelection(new ba(r))),0))}function Oa(e,t){if("insertCompositionText"!=t.inputType||!(e.state.selection instanceof ba))return!1;var n=e.state.selection.$from,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;for(var i=C.empty,o=r.length-1;o>=0;o--)i=C.from(r[o].createAndFill(null,i));var s=e.state.tr.replace(n.pos,n.pos,new D(i,0,0));return s.setSelection(Ct.near(s.doc.resolve(n.pos+1))),e.dispatch(s),!1}function Ta(e){if(!(e.selection instanceof ba))return null;var t=document.createElement("div");return t.className="ProseMirror-gapcursor",Ci.create(e.doc,[xi.widget(e.selection.head,t,{key:"gapcursor"})])}var Na=us.create({name:"gapCursor",addProseMirrorPlugins:function(){return[new Ft({props:{decorations:Ta,createSelectionBetween:function(e,t,n){return t.pos==n.pos&&ba.valid(n)?new ba(n):null},handleClick:Ca,handleKeyDown:Ma,handleDOMEvents:{beforeinput:Oa}}})]},extendNodeSchema:function(e){var t;return{allowGapCursor:null!==(t=Uo(jo(e,"allowGapCursor",{name:e.name,options:e.options,storage:e.storage})))&&void 0!==t?t:null}}}),Ea=Ys.create({name:"hardBreak",addOptions:function(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,parseHTML:function(){return[{tag:"br"}]},renderHTML:function(e){var t=e.HTMLAttributes;return["br",Wo(this.options.HTMLAttributes,t)]},renderText:function(){return"\n"},addCommands:function(){var e=this;return{setHardBreak:function(){return function(t){var n=t.commands,r=t.chain,i=t.state,o=t.editor;return n.first([function(){return n.exitCode()},function(){return n.command((function(){var t=i.selection,n=i.storedMarks;if(t.$from.parent.type.spec.isolating)return!1;var s=e.options.keepMarks,a=o.extensionManager.splittableMarks,c=n||t.$to.parentOffset&&t.$from.marks();return r().insertContent({type:e.name}).command((function(e){var t=e.tr;if(e.dispatch&&c&&s){var n=c.filter((function(e){return a.includes(e.type.name)}));t.ensureMarks(n)}return!0})).run()}))}])}}}},addKeyboardShortcuts:function(){var e=this;return{"Mod-Enter":function(){return e.editor.commands.setHardBreak()},"Shift-Enter":function(){return e.editor.commands.setHardBreak()}}}}),Aa=Ys.create({name:"heading",addOptions:function(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes:function(){return{level:{default:1,rendered:!1}}},parseHTML:function(){return this.options.levels.map((function(e){return{tag:"h".concat(e),attrs:{level:e}}}))},renderHTML:function(e){var t=e.node,n=e.HTMLAttributes,r=this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0];return["h".concat(r),Wo(this.options.HTMLAttributes,n),0]},addCommands:function(){var e=this;return{setHeading:function(t){return function(n){var r=n.commands;return!!e.options.levels.includes(t.level)&&r.setNode(e.name,t)}},toggleHeading:function(t){return function(n){var r=n.commands;return!!e.options.levels.includes(t.level)&&r.toggleNode(e.name,"paragraph",t)}}}},addKeyboardShortcuts:function(){var e=this;return this.options.levels.reduce((function(t,n){return w(w({},t),(0,o.Z)({},"Mod-Alt-".concat(n),(function(){return e.editor.commands.toggleHeading({level:n})})))}),{})},addInputRules:function(){var e=this;return this.options.levels.map((function(t){return Us({find:new RegExp("^(#{1,".concat(t,"})\\s$")),type:e.type,getAttributes:{level:t}})}))}}),Da=200,Pa=function(){};Pa.prototype.append=function(e){return e.length?(e=Pa.from(e),!this.length&&e||e.length<Da&&this.leafAppend(e)||this.length<Da&&e.leafPrepend(this)||this.appendInner(e)):this},Pa.prototype.prepend=function(e){return e.length?Pa.from(e).append(this):this},Pa.prototype.appendInner=function(e){return new Ra(this,e)},Pa.prototype.slice=function(e,t){return void 0===e&&(e=0),void 0===t&&(t=this.length),e>=t?Pa.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},Pa.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},Pa.prototype.forEach=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},Pa.prototype.map=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length);var r=[];return this.forEach((function(t,n){return r.push(e(t,n))}),t,n),r},Pa.from=function(e){return e instanceof Pa?e:e&&e.length?new Ia(e):Pa.empty};var Ia=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return 0==e&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var i=t;i<n;i++)if(!1===e(this.values[i],r+i))return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var i=t-1;i>=n;i--)if(!1===e(this.values[i],r+i))return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=Da)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=Da)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(Pa);Pa.empty=new Ia([]);var Ra=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,r){var i=this.left.length;return!(t<i&&!1===this.left.forEachInner(e,t,Math.min(n,i),r))&&!(n>i&&!1===this.right.forEachInner(e,Math.max(t-i,0),Math.min(this.length,n)-i,r+i))&&void 0},t.prototype.forEachInvertedInner=function(e,t,n,r){var i=this.left.length;return!(t>i&&!1===this.right.forEachInvertedInner(e,t-i,Math.max(n,i)-i,r+i))&&!(n<i&&!1===this.left.forEachInvertedInner(e,Math.min(t,i),n,r))&&void 0},t.prototype.sliceInner=function(e,t){if(0==e&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(Pa),za=Pa,Ba=function(){function e(t,n){(0,v.Z)(this,e),this.items=t,this.eventCount=n}return(0,m.Z)(e,[{key:"popEvent",value:function(t,n){var r=this;if(0==this.eventCount)return null;for(var i,o,s=this.items.length;;s--)if(this.items.get(s-1).selection){--s;break}n&&(i=this.remapping(s,this.items.length),o=i.maps.length);var a,c,u=t.tr,l=[],d=[];return this.items.forEach((function(t,n){if(!t.step)return i||(i=r.remapping(s,n+1),o=i.maps.length),o--,void d.push(t);if(i){d.push(new Za(t.map));var h,f=t.step.map(i.slice(o));f&&u.maybeStep(f).doc&&(h=u.mapping.maps[u.mapping.maps.length-1],l.push(new Za(h,void 0,void 0,l.length+d.length))),o--,h&&i.appendMap(h,o)}else u.maybeStep(t.step);return t.selection?(a=i?t.selection.map(i.slice(o)):t.selection,c=new e(r.items.slice(0,s).append(d.reverse().concat(l)),r.eventCount-1),!1):void 0}),this.items.length,0),{remaining:c,transform:u,selection:a}}},{key:"addTransform",value:function(t,n,r,i){for(var o=[],s=this.eventCount,a=this.items,c=!i&&a.length?a.get(a.length-1):null,u=0;u<t.steps.length;u++){var l,d=t.steps[u].invert(t.docs[u]),h=new Za(t.mapping.maps[u],d,n);(l=c&&c.merge(h))&&(h=l,u?o.pop():a=a.slice(0,a.length-1)),o.push(h),n&&(s++,n=void 0),i||(c=h)}var f,p,v,m=s-r.depth;return m>$a&&(p=m,(f=a).forEach((function(e,t){if(e.selection&&0==p--)return v=t,!1})),a=f.slice(v),s-=m),new e(a.append(o),s)}},{key:"remapping",value:function(e,t){var n=new Ie;return this.items.forEach((function(t,r){var i=null!=t.mirrorOffset&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,i)}),e,t),n}},{key:"addMaps",value:function(t){return 0==this.eventCount?this:new e(this.items.append(t.map((function(e){return new Za(e)}))),this.eventCount)}},{key:"rebased",value:function(t,n){if(!this.eventCount)return this;var r=[],i=Math.max(0,this.items.length-n),o=t.mapping,s=t.steps.length,a=this.eventCount;this.items.forEach((function(e){e.selection&&a--}),i);var c=n;this.items.forEach((function(e){var n=o.getMirror(--c);if(null!=n){s=Math.min(s,n);var i=o.maps[n];if(e.step){var u=t.steps[n].invert(t.docs[n]),l=e.selection&&e.selection.map(o.slice(c+1,n));l&&a++,r.push(new Za(i,u,l))}else r.push(new Za(i))}}),i);for(var u=[],l=n;l<s;l++)u.push(new Za(o.maps[l]));var d=new e(this.items.slice(0,i).append(u).append(r),a);return d.emptyItemCount()>500&&(d=d.compress(this.items.length-r.length)),d}},{key:"emptyItemCount",value:function(){var e=0;return this.items.forEach((function(t){t.step||e++})),e}},{key:"compress",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.items.length,n=this.remapping(0,t),r=n.maps.length,i=[],o=0;return this.items.forEach((function(e,s){if(s>=t)i.push(e),e.selection&&o++;else if(e.step){var a=e.step.map(n.slice(r)),c=a&&a.getMap();if(r--,c&&n.appendMap(c,r),a){var u=e.selection&&e.selection.map(n.slice(r));u&&o++;var l,d=new Za(c.invert(),a,u),h=i.length-1;(l=i.length&&i[h].merge(d))?i[h]=l:i.push(d)}}else e.map&&r--}),this.items.length,0),new e(za.from(i.reverse()),o)}}]),e}();Ba.empty=new Ba(za.empty,0);var Za=function(){function e(t,n,r,i){(0,v.Z)(this,e),this.map=t,this.step=n,this.selection=r,this.mirrorOffset=i}return(0,m.Z)(e,[{key:"merge",value:function(t){if(this.step&&t.step&&!t.selection){var n=t.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}}]),e}(),La=(0,m.Z)((function e(t,n,r,i){(0,v.Z)(this,e),this.done=t,this.undone=n,this.prevRanges=r,this.prevTime=i})),$a=20;function Fa(e,t,n,r){var i,o=n.getMeta(Ka);if(o)return o.historyState;n.getMeta(_a)&&(e=new La(e.done,e.undone,null,0));var s=n.getMeta("appendedTransaction");if(0==n.steps.length)return e;if(s&&s.getMeta(Ka))return s.getMeta(Ka).redo?new La(e.done.addTransform(n,void 0,r,Wa(t)),e.undone,Va(n.mapping.maps[n.steps.length-1]),e.prevTime):new La(e.done,e.undone.addTransform(n,void 0,r,Wa(t)),null,e.prevTime);if(!1===n.getMeta("addToHistory")||s&&!1===s.getMeta("addToHistory"))return(i=n.getMeta("rebased"))?new La(e.done.rebased(n,i),e.undone.rebased(n,i),ja(e.prevRanges,n.mapping),e.prevTime):new La(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),ja(e.prevRanges,n.mapping),e.prevTime);var a=0==e.prevTime||!s&&(e.prevTime<(n.time||0)-r.newGroupDelay||!function(e,t){if(!t)return!1;if(!e.docChanged)return!0;var n=!1;return e.mapping.maps[0].forEach((function(e,r){for(var i=0;i<t.length;i+=2)e<=t[i+1]&&r>=t[i]&&(n=!0)})),n}(n,e.prevRanges)),c=s?ja(e.prevRanges,n.mapping):Va(n.mapping.maps[n.steps.length-1]);return new La(e.done.addTransform(n,a?t.selection.getBookmark():void 0,r,Wa(t)),Ba.empty,c,n.time)}function Va(e){var t=[];return e.forEach((function(e,n,r,i){return t.push(r,i)})),t}function ja(e,t){if(!e)return null;for(var n=[],r=0;r<e.length;r+=2){var i=t.map(e[r],1),o=t.map(e[r+1],-1);i<=o&&n.push(i,o)}return n}function Ha(e,t,n,r){var i=Wa(t),o=Ka.get(t).spec.config,s=(r?e.undone:e.done).popEvent(t,i);if(s){var a=s.selection.resolve(s.transform.doc),c=(r?e.done:e.undone).addTransform(s.transform,t.selection.getBookmark(),o,i),u=new La(r?c:s.remaining,r?s.remaining:c,null,0);n(s.transform.setSelection(a).setMeta(Ka,{redo:r,historyState:u}).scrollIntoView())}}var Ja=!1,qa=null;function Wa(e){var t=e.plugins;if(qa!=t){Ja=!1,qa=t;for(var n=0;n<t.length;n++)if(t[n].spec.historyPreserveItems){Ja=!0;break}}return Ja}var Ka=new Ht("history"),_a=new Ht("closeHistory");function Ua(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new Ft({key:Ka,state:{init:function(){return new La(Ba.empty,Ba.empty,null,0)},apply:function(t,n,r){return Fa(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput:function(e,t){var n=t.inputType,r="historyUndo"==n?Ga:"historyRedo"==n?Xa:null;return!!r&&(t.preventDefault(),r(e.state,e.dispatch))}}}})}var Ga=function(e,t){var n=Ka.getState(e);return!(!n||0==n.done.eventCount||(t&&Ha(n,e,t,!1),0))},Xa=function(e,t){var n=Ka.getState(e);return!(!n||0==n.undone.eventCount||(t&&Ha(n,e,t,!0),0))},Ya=us.create({name:"history",addOptions:function(){return{depth:100,newGroupDelay:500}},addCommands:function(){return{undo:function(){return function(e){var t=e.state,n=e.dispatch;return Ga(t,n)}},redo:function(){return function(e){var t=e.state,n=e.dispatch;return Xa(t,n)}}}},addProseMirrorPlugins:function(){return[Ua(this.options)]},addKeyboardShortcuts:function(){var e=this;return{"Mod-z":function(){return e.editor.commands.undo()},"Mod-y":function(){return e.editor.commands.redo()},"Shift-Mod-z":function(){return e.editor.commands.redo()},"Mod-я":function(){return e.editor.commands.undo()},"Shift-Mod-я":function(){return e.editor.commands.redo()}}}}),Qa=Ys.create({name:"horizontalRule",addOptions:function(){return{HTMLAttributes:{}}},group:"block",parseHTML:function(){return[{tag:"hr"}]},renderHTML:function(e){var t=e.HTMLAttributes;return["hr",Wo(this.options.HTMLAttributes,t)]},addCommands:function(){var e=this;return{setHorizontalRule:function(){return function(t){return(0,t.chain)().insertContent({type:e.name}).command((function(e){var t,n=e.tr;if(e.dispatch){var r=n.selection.$to,i=r.end();if(r.nodeAfter)n.setSelection(Ct.create(n.doc,r.pos));else{var o=null===(t=r.parent.type.contentMatch.defaultType)||void 0===t?void 0:t.create();o&&(n.insert(i,o),n.setSelection(Ct.create(n.doc,i)))}n.scrollIntoView()}return!0})).run()}}}},addInputRules:function(){return[(e={find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type},new ts({find:e.find,handler:function(t){var n=t.state,r=t.range,i=t.match,o=Uo(e.getAttributes,void 0,i)||{},s=n.tr,a=r.from,c=r.to;if(i[1]){var u=a+i[0].lastIndexOf(i[1]);u>c?u=c:c=u+i[1].length;var l=i[0][i[0].length-1];s.insertText(l,a+i[0].length-1),s.replaceWith(u,c,e.type.create(o))}else i[0]&&s.replaceWith(a,c,e.type.create(o))}}))];var e}}),ec=/(?:^|\s)((?:\*)((?:[^*]+))(?:\*))$/,tc=/(?:^|\s)((?:\*)((?:[^*]+))(?:\*))/g,nc=/(?:^|\s)((?:_)((?:[^_]+))(?:_))$/,rc=/(?:^|\s)((?:_)((?:[^_]+))(?:_))/g,ic=Xs.create({name:"italic",addOptions:function(){return{HTMLAttributes:{}}},parseHTML:function(){return[{tag:"em"},{tag:"i",getAttrs:function(e){return"normal"!==e.style.fontStyle&&null}},{style:"font-style=italic"}]},renderHTML:function(e){var t=e.HTMLAttributes;return["em",Wo(this.options.HTMLAttributes,t),0]},addCommands:function(){var e=this;return{setItalic:function(){return function(t){return t.commands.setMark(e.name)}},toggleItalic:function(){return function(t){return t.commands.toggleMark(e.name)}},unsetItalic:function(){return function(t){return t.commands.unsetMark(e.name)}}}},addKeyboardShortcuts:function(){var e=this;return{"Mod-i":function(){return e.editor.commands.toggleItalic()},"Mod-I":function(){return e.editor.commands.toggleItalic()}}},addInputRules:function(){return[_s({find:ec,type:this.type}),_s({find:nc,type:this.type})]},addPasteRules:function(){return[Qs({find:tc,type:this.type}),Qs({find:rc,type:this.type})]}}),oc=Ys.create({name:"listItem",addOptions:function(){return{HTMLAttributes:{}}},content:"paragraph block*",defining:!0,parseHTML:function(){return[{tag:"li"}]},renderHTML:function(e){var t=e.HTMLAttributes;return["li",Wo(this.options.HTMLAttributes,t),0]},addKeyboardShortcuts:function(){var e=this;return{Enter:function(){return e.editor.commands.splitListItem(e.name)},Tab:function(){return e.editor.commands.sinkListItem(e.name)},"Shift-Tab":function(){return e.editor.commands.liftListItem(e.name)}}}}),sc=/^(\d+)\.\s$/,ac=Ys.create({name:"orderedList",addOptions:function(){return{itemTypeName:"listItem",HTMLAttributes:{}}},group:"block list",content:function(){return"".concat(this.options.itemTypeName,"+")},addAttributes:function(){return{start:{default:1,parseHTML:function(e){return e.hasAttribute("start")?parseInt(e.getAttribute("start")||"",10):1}}}},parseHTML:function(){return[{tag:"ol"}]},renderHTML:function(e){var t=e.HTMLAttributes,n=t.start,i=(0,r.Z)(t,y);return 1===n?["ol",Wo(this.options.HTMLAttributes,i),0]:["ol",Wo(this.options.HTMLAttributes,t),0]},addCommands:function(){var e=this;return{toggleOrderedList:function(){return function(t){return t.commands.toggleList(e.name,e.options.itemTypeName)}}}},addKeyboardShortcuts:function(){var e=this;return{"Mod-Shift-7":function(){return e.editor.commands.toggleOrderedList()}}},addInputRules:function(){return[Gs({find:sc,type:this.type,getAttributes:function(e){return{start:+e[1]}},joinPredicate:function(e,t){return t.childCount+t.attrs.start===+e[1]}})]}}),cc=Ys.create({name:"paragraph",priority:1e3,addOptions:function(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML:function(){return[{tag:"p"}]},renderHTML:function(e){var t=e.HTMLAttributes;return["p",Wo(this.options.HTMLAttributes,t),0]},addCommands:function(){var e=this;return{setParagraph:function(){return function(t){return t.commands.setNode(e.name)}}}},addKeyboardShortcuts:function(){var e=this;return{"Mod-Alt-0":function(){return e.editor.commands.setParagraph()}}}}),uc=/(?:^|\s)((?:~~)((?:[^~]+))(?:~~))$/,lc=/(?:^|\s)((?:~~)((?:[^~]+))(?:~~))/g,dc=Xs.create({name:"strike",addOptions:function(){return{HTMLAttributes:{}}},parseHTML:function(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:function(e){return!!e.includes("line-through")&&{}}}]},renderHTML:function(e){var t=e.HTMLAttributes;return["s",Wo(this.options.HTMLAttributes,t),0]},addCommands:function(){var e=this;return{setStrike:function(){return function(t){return t.commands.setMark(e.name)}},toggleStrike:function(){return function(t){return t.commands.toggleMark(e.name)}},unsetStrike:function(){return function(t){return t.commands.unsetMark(e.name)}}}},addKeyboardShortcuts:function(){var e=this;return{"Mod-Shift-x":function(){return e.editor.commands.toggleStrike()}}},addInputRules:function(){return[_s({find:uc,type:this.type})]},addPasteRules:function(){return[Qs({find:lc,type:this.type})]}}),hc=Ys.create({name:"text",group:"inline"}),fc=us.create({name:"starterKit",addExtensions:function(){var e,t,n,r,i,o,s,a,c,u,l,d,h,f,p,v,m,g,y=[];return!1!==this.options.blockquote&&y.push(ra.configure(null===(e=this.options)||void 0===e?void 0:e.blockquote)),!1!==this.options.bold&&y.push(ca.configure(null===(t=this.options)||void 0===t?void 0:t.bold)),!1!==this.options.bulletList&&y.push(la.configure(null===(n=this.options)||void 0===n?void 0:n.bulletList)),!1!==this.options.code&&y.push(fa.configure(null===(r=this.options)||void 0===r?void 0:r.code)),!1!==this.options.codeBlock&&y.push(ma.configure(null===(i=this.options)||void 0===i?void 0:i.codeBlock)),!1!==this.options.document&&y.push(ga.configure(null===(o=this.options)||void 0===o?void 0:o.document)),!1!==this.options.dropcursor&&y.push(wa.configure(null===(s=this.options)||void 0===s?void 0:s.dropcursor)),!1!==this.options.gapcursor&&y.push(Na.configure(null===(a=this.options)||void 0===a?void 0:a.gapcursor)),!1!==this.options.hardBreak&&y.push(Ea.configure(null===(c=this.options)||void 0===c?void 0:c.hardBreak)),!1!==this.options.heading&&y.push(Aa.configure(null===(u=this.options)||void 0===u?void 0:u.heading)),!1!==this.options.history&&y.push(Ya.configure(null===(l=this.options)||void 0===l?void 0:l.history)),!1!==this.options.horizontalRule&&y.push(Qa.configure(null===(d=this.options)||void 0===d?void 0:d.horizontalRule)),!1!==this.options.italic&&y.push(ic.configure(null===(h=this.options)||void 0===h?void 0:h.italic)),!1!==this.options.listItem&&y.push(oc.configure(null===(f=this.options)||void 0===f?void 0:f.listItem)),!1!==this.options.orderedList&&y.push(ac.configure(null===(p=this.options)||void 0===p?void 0:p.orderedList)),!1!==this.options.paragraph&&y.push(cc.configure(null===(v=this.options)||void 0===v?void 0:v.paragraph)),!1!==this.options.strike&&y.push(dc.configure(null===(m=this.options)||void 0===m?void 0:m.strike)),!1!==this.options.text&&y.push(hc.configure(null===(g=this.options)||void 0===g?void 0:g.text)),y}}),pc=0,vc=function(){function e(t){(0,v.Z)(this,e),(0,g.r)(this,t),this.scChange=(0,g.c)(this,"scChange",7),this.scInput=(0,g.c)(this,"scInput",7),this.scBlur=(0,g.c)(this,"scBlur",7),this.scFocus=(0,g.c)(this,"scFocus",7),this.inputId="sc-richtext-".concat(++pc),this.helpId="sc-richtext-help-text-".concat(pc),this.labelId="sc-richtext-label-".concat(pc),this.size="medium",this.name=void 0,this.value="",this.label="",this.showLabel=!0,this.help="",this.placeholder=void 0,this.maxlength=void 0,this.disabled=!1,this.readonly=!1,this.required=!1,this.updatedAt=Date.now(),this.hasFocus=void 0}return(0,m.Z)(e,[{key:"componentDidLoad",value:function(){var e=this;this.editor||(this.editor=new Ks({element:this.element,extensions:[fc,ta.configure({placeholder:this.placeholder})].concat((0,i.Z)((null==this?void 0:this.maxlength)>0?[ea.configure({limit:this.maxlength,mode:"nodeSize"})]:[])),content:this.value,onCreate:function(t){var n=t.editor;e.value=n.getHTML()},onUpdate:function(t){var n=t.editor;e.value=n.getHTML(),e.scInput.emit(),e.scChange.emit()},onSelectionUpdate:function(){e.updatedAt=Date.now()},onFocus:function(){e.handleFocus()},onBlur:function(){e.handleBlur()}}))}},{key:"handleFocus",value:function(){this.hasFocus=!0,this.scFocus.emit()}},{key:"handleBlur",value:function(){this.hasFocus=!1,this.scBlur.emit()}},{key:"isActive",value:function(e){var t,n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return null===(n=null===(t=this.editor)||void 0===t?void 0:t.isActive)||void 0===n?void 0:n.call(t,e,r)}},{key:"toggleHeading",value:function(e){this.editor.chain().toggleHeading(e).focus().run()}},{key:"toggleBold",value:function(){this.editor.chain().toggleBold().focus().run()}},{key:"toggleItalic",value:function(){this.editor.chain().toggleItalic().focus().run()}},{key:"can",value:function(e){var t,n,r,i,o,s,a,c,u;return null===(u=null===(c=null===(a=null===(s=null===(o=null===(i=null===(r=null===(n=null===(t=this.editor)||void 0===t?void 0:t.can())||void 0===n?void 0:n.chain)||void 0===r?void 0:r.call(n))||void 0===i?void 0:i.focus)||void 0===o?void 0:o.call(i))||void 0===s?void 0:s[e])||void 0===a?void 0:a.call(s))||void 0===c?void 0:c.run)||void 0===u?void 0:u.call(c)}},{key:"run",value:function(e){var t,n,r,i,o,s,a,c;return null===(c=null===(a=null===(s=null===(o=null===(i=null===(r=null===(n=null===(t=this.editor)||void 0===t?void 0:t.chain)||void 0===n?void 0:n.call(t))||void 0===r?void 0:r.focus)||void 0===i?void 0:i.call(r))||void 0===o?void 0:o[e])||void 0===s?void 0:s.call(o))||void 0===a?void 0:a.run)||void 0===c?void 0:c.call(a)}},{key:"remainingCharacters",value:function(){var e,t;return this.maxlength?this.maxlength-((null===(t=null===(e=null==this?void 0:this.editor)||void 0===e?void 0:e.storage)||void 0===t?void 0:t.characterCount.characters())||0):1e3}},{key:"handleKeyDown",value:function(e){"n"===e.key&&e.stopPropagation()}},{key:"render",value:function(){var e,t,n,r,i,o,s,a,c=this;return(0,g.h)(g.H,null,(0,g.h)("sc-form-control",{exportparts:"label, help-text, form-control",size:this.size,required:this.required,label:this.label,showLabel:this.showLabel,help:this.help,inputId:this.inputId,helpId:this.helpId,labelId:this.labelId,name:this.name},(0,g.h)("div",{part:"base",class:{"editor-base":!0,"editor--focused":this.hasFocus}},(0,g.h)("div",{class:"menu"},(0,g.h)("sc-button",{size:"small",type:(null===(t=null===(e=this.editor)||void 0===e?void 0:e.isActive)||void 0===t?void 0:t.call(e,"bold"))?"default":"text",onClick:function(){return c.run("toggleBold")},disabled:!this.can("toggleBold")},(0,g.h)("sc-icon",{name:"bold"})),(0,g.h)("sc-button",{size:"small",type:(null===(r=null===(n=this.editor)||void 0===n?void 0:n.isActive)||void 0===r?void 0:r.call(n,"italic"))?"default":"text",onClick:function(){return c.run("toggleItalic")},disabled:!this.can("toggleItalic")},(0,g.h)("sc-icon",{name:"italic"})),(0,g.h)("sc-button",{size:"small",type:(null===(o=null===(i=this.editor)||void 0===i?void 0:i.isActive)||void 0===o?void 0:o.call(i,"bulletList"))?"default":"text",onClick:function(){return c.run("toggleBulletList")}},(0,g.h)("sc-icon",{name:"list"})),(0,g.h)("sc-button",{size:"small",type:(null===(a=null===(s=this.editor)||void 0===s?void 0:s.isActive)||void 0===a?void 0:a.call(s,"strike"))?"default":"text",onClick:function(){return c.run("toggleStrike")}},(0,g.h)("sc-icon",{name:"minus"})),(0,g.h)("sc-button",{class:"right",size:"small",type:"text",onClick:function(){return c.run("undo")},disabled:!this.can("undo")},(0,g.h)("sc-icon",{name:"corner-up-left"})),(0,g.h)("sc-button",{size:"small",type:"text",onClick:function(){return c.run("redo")},disabled:!this.can("redo")},(0,g.h)("sc-icon",{name:"corner-up-right"}))),(0,g.h)("div",{part:"editor",class:{editor:!0},ref:function(e){return c.element=e}})),this.remainingCharacters()<20&&(0,g.h)("div",{class:"textarea__char-limit-warning"},wp.i18n.sprintf(wp.i18n.__("%d characters remaining","surecart"),this.remainingCharacters()))))}}]),e}();vc.style='@charset "UTF-8";\n:host {\n display: block;\n}\n\n.ProseMirror p.is-editor-empty:first-child::before {\n color: var(--sc-input-placeholder-color);\n content: attr(data-placeholder);\n float: left;\n height: 0;\n pointer-events: none;\n}\n\n.ProseMirror [class~=lead] {\n color: var(--sc-input-color);\n font-size: var(--sc-input-spacing-small);\n line-height: 1.6;\n margin-top: 1.2em;\n margin-bottom: 1.2em;\n}\n\n.ProseMirror a {\n position: relative;\n}\n\n.ProseMirror a::before {\n content: "";\n position: absolute;\n bottom: -0.3em;\n left: 0;\n right: 0;\n height: 3px;\n width: 100%;\n @apply bg-gradient-to-r bg-gradient-teal transition-transform duration-200 transform;\n pointer-events: none;\n}\n\n.ProseMirror a:hover::before,\n.ProseMirror a:focus::before {\n transform: scaleX(0.95);\n}\n\n.ProseMirror strong {\n font-weight: 600;\n}\n\n.ProseMirror ol {\n counter-reset: list-counter;\n margin-top: var(--sc-input-spacing-small);\n margin-bottom: var(--sc-input-spacing-small);\n}\n\n.ProseMirror ol > li {\n position: relative;\n}\n\n.ProseMirror ul > li {\n position: relative;\n}\n\n.ProseMirror ul > li::before {\n content: "";\n position: absolute;\n background-color: var(--sc-color-gray-400);\n border-radius: 50%;\n width: 0.375em;\n height: 0.375em;\n top: 0.6875em;\n left: -1rem;\n}\n\n.ProseMirror hr {\n border-color: var(--sc-color-gray-400);\n border-top-width: 1px;\n margin-top: 3em;\n margin-bottom: 3em;\n}\n\n.ProseMirror blockquote {\n font-weight: 500;\n font-style: italic;\n color: #1a202c;\n border-left-width: 0.25rem;\n border-left-color: var(--sc-color-gray-400);\n quotes: "“" "”" "‘" "’";\n margin-top: 1.6em;\n margin-bottom: 1.6em;\n padding-left: 1em;\n}\n\n.ProseMirror blockquote p:first-of-type::before {\n content: open-quote;\n}\n\n.ProseMirror blockquote p:last-of-type::after {\n content: close-quote;\n}\n\n.ProseMirror h1 {\n font-weight: 800;\n font-size: 2.25em;\n margin-top: 0;\n margin-bottom: 0.8888889em;\n line-height: 1.1111111;\n}\n\n.ProseMirror h2 {\n font-weight: 700;\n font-size: 1.5em;\n margin-top: 2em;\n margin-bottom: 1em;\n line-height: 1.3333333;\n}\n\n.ProseMirror h3 {\n font-weight: 600;\n font-size: var(--sc-input-spacing-small);\n margin-top: 1.6em;\n margin-bottom: 0.6em;\n line-height: 1.6;\n}\n\n.ProseMirror h4 {\n font-weight: 600;\n margin-top: 1.5em;\n margin-bottom: 0.5em;\n line-height: 1.5;\n}\n\n.ProseMirror figure figcaption {\n color: var(--sc-color-gray-600);\n font-size: 0.875em;\n line-height: 1.4285714;\n margin-top: 0.8571429em;\n}\n\n.ProseMirror code {\n color: var(--sc-color-gray-900);\n font-weight: 600;\n font-size: 0.875em;\n}\n\n.ProseMirror code::before {\n content: "`";\n}\n\n.ProseMirror code::after {\n content: "`";\n}\n\n.ProseMirror pre {\n color: var(--sc-color-gray-300);\n background-color: var(--sc-color-gray-800);\n overflow-x: auto;\n font-size: 0.875em;\n line-height: 1.7142857;\n margin-top: 1.7142857em;\n margin-bottom: 1.7142857em;\n border-radius: 0.375rem;\n padding-top: 0.8571429em;\n padding-right: 1.1428571em;\n padding-bottom: 0.8571429em;\n padding-left: 1.1428571em;\n}\n\n.ProseMirror pre code {\n background-color: transparent;\n border-width: 0;\n border-radius: 0;\n padding: 0;\n font-weight: 400;\n color: inherit;\n font-size: inherit;\n font-family: inherit;\n line-height: inherit;\n}\n\n.ProseMirror pre code::before {\n content: "";\n}\n\n.ProseMirror pre code::after {\n content: "";\n}\n\n.ProseMirror table {\n width: 100%;\n table-layout: auto;\n text-align: left;\n margin-top: 2em;\n margin-bottom: 2em;\n font-size: 0.875em;\n line-height: 1.7142857;\n}\n\n.ProseMirror thead {\n color: #1a202c;\n font-weight: 600;\n border-bottom-width: 1px;\n border-bottom-color: var(--sc-color-gray-400);\n}\n\n.ProseMirror thead th {\n vertical-align: bottom;\n padding-right: 0.5714286em;\n padding-bottom: 0.5714286em;\n padding-left: 0.5714286em;\n}\n\n.ProseMirror tbody tr {\n border-bottom-width: 1px;\n border-bottom-color: var(--sc-color-gray-400);\n}\n\n.ProseMirror tbody tr:last-child {\n border-bottom-width: 0;\n}\n\n.ProseMirror tbody td {\n vertical-align: top;\n padding-top: 0.5714286em;\n padding-right: 0.5714286em;\n padding-bottom: 0.5714286em;\n padding-left: 0.5714286em;\n}\n\n.ProseMirror {\n font-size: var(--sc-font-size-medium);\n color: var(--sc-input-color);\n line-height: 1.75;\n}\n\n.ProseMirror p {\n margin-top: var(--sc-input-spacing-small);\n margin-bottom: var(--sc-input-spacing-small);\n}\n\n.ProseMirror img {\n margin-top: 2em;\n margin-bottom: 2em;\n}\n\n.ProseMirror video {\n margin-top: 2em;\n margin-bottom: 2em;\n}\n\n.ProseMirror figure {\n margin-top: 2em;\n margin-bottom: 2em;\n}\n\n.ProseMirror figure > * {\n margin-top: 0;\n margin-bottom: 0;\n}\n\n.ProseMirror h2 code {\n font-size: 0.875em;\n}\n\n.ProseMirror h3 code {\n font-size: 0.9em;\n}\n\n.ProseMirror ul {\n margin-top: var(--sc-input-spacing-small);\n margin-bottom: var(--sc-input-spacing-small);\n list-style: none;\n}\n\n.ProseMirror li {\n margin-top: 0.5em;\n margin-bottom: 0.5em;\n}\n\n.ProseMirror ol > li:before {\n left: 0;\n}\n\n.ProseMirror > ul > li p {\n margin-top: 0.75em;\n margin-bottom: 0.75em;\n}\n\n.ProseMirror > ul > li > *:first-child {\n margin-top: var(--sc-input-spacing-small);\n}\n\n.ProseMirror > ul > li > *:last-child {\n margin-bottom: var(--sc-input-spacing-small);\n}\n\n.ProseMirror > ol > li > *:first-child {\n margin-top: var(--sc-input-spacing-small);\n}\n\n.ProseMirror > ol > li > *:last-child {\n margin-bottom: var(--sc-input-spacing-small);\n}\n\n.ProseMirror ul ul,\n.ProseMirror ul ol,\n.ProseMirror ol ul,\n.ProseMirror ol ol {\n margin-top: 0.75em;\n margin-bottom: 0.75em;\n}\n\n.ProseMirror hr + * {\n margin-top: 0;\n}\n\n.ProseMirror h2 + * {\n margin-top: 0;\n}\n\n.ProseMirror h3 + * {\n margin-top: 0;\n}\n\n.ProseMirror h4 + * {\n margin-top: 0;\n}\n\n.ProseMirror thead th:first-child {\n padding-left: 0;\n}\n\n.ProseMirror thead th:last-child {\n padding-right: 0;\n}\n\n.ProseMirror tbody td:first-child {\n padding-left: 0;\n}\n\n.ProseMirror tbody td:last-child {\n padding-right: 0;\n}\n\n.ProseMirror > :first-child {\n margin-top: 0;\n}\n\n.ProseMirror > :last-child {\n margin-bottom: 0;\n}\n\n.editor-base {\n position: relative;\n width: 100%;\n font-family: var(--sc-input-font-family);\n font-weight: var(--sc-input-font-weight);\n line-height: var(--sc-line-height-normal);\n letter-spacing: var(--sc-input-letter-spacing);\n vertical-align: middle;\n transition: var(--sc-transition-fast) color, var(--sc-transition-fast) border, var(--sc-transition-fast) box-shadow, var(--sc-transition-fast) background-color;\n cursor: text;\n background-color: var(--sc-input-background-color);\n border: solid var(--sc-input-border-width) var(--sc-input-border-color);\n}\n\n[contenteditable] {\n position: relative;\n outline: none;\n width: 100%;\n box-sizing: border-box;\n border-top: solid var(--sc-input-border-width) var(--sc-input-border-color);\n padding: var(--sc-input-spacing-medium);\n overflow-y: auto;\n max-height: var(--sc-rich-text-max-height, none);\n}\n\n.menu {\n display: flex;\n line-height: 0;\n gap: var(--sc-spacing-xx-small);\n padding: var(--sc-spacing-x-small);\n}\n\n.editor-base {\n display: grid;\n gap: 0;\n}\n\n.right {\n margin-left: auto;\n}\n\n.textarea__char-limit-warning {\n margin-top: var(--sc-input-spacing-small);\n color: var(--sc-input-help-text-color);\n font-size: var(--sc-input-help-text-font-size-medium);\n}'},4942:function(e,t,n){function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}n.d(t,{Z:function(){return r}})},5987:function(e,t,n){n.d(t,{Z:function(){return i}});var r=n(3366);function i(e,t){if(null==e)return{};var n,i,o=(0,r.Z)(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(i=0;i<s.length;i++)n=s[i],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}},3366:function(e,t,n){function r(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}n.d(t,{Z:function(){return r}})}}]);