index of
/
home
/
thefkyzp
/
hulmvisaadvisor.com
/
wp-content
/
plugins
/
surecart
/
dist
/
File: /home/thefkyzp/hulmvisaadvisor.com/wp-content/plugins/surecart/dist/2179.js
"use strict";(self.webpackChunk_surecart_surecart=self.webpackChunk_surecart_surecart||[]).push([[2179],{2179:function(e,t,n){n.r(t),n.d(t,{sc_rich_text:function(){return mu}});var r=n(45),o=n(9394),i=n(4467),s=n(296),a=n(3954);function u(){return u="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=(0,a.A)(e)););return e}(e,t);if(r){var o=Object.getOwnPropertyDescriptor(r,t);return o.get?o.get.call(arguments.length<3?e:n):o.value}},u.apply(null,arguments)}var c=n(388),l=n(5501),d=n(8614),f=n(2284),h=n(3029),p=n(2901),v=n(1346),m=["start"];function g(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 y(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?g(Object(n),!0).forEach((function(t){(0,i.A)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):g(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function k(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return b(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?b(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,s=!0,a=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){a=!0,i=e},f:function(){try{s||null==n.return||n.return()}finally{if(a)throw i}}}}function b(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function w(e,t,n){return t=(0,a.A)(t),(0,c.A)(e,x()?Reflect.construct(t,n||[],(0,a.A)(e).constructor):t.apply(e,n))}function x(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(x=function(){return!!e})()}function M(e){this.content=e}function S(e,t,n){for(var r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;var o=e.child(r),i=t.child(r);if(o!=i){if(!o.sameMarkup(i))return n;if(o.isText&&o.text!=i.text){for(var s=0;o.text[s]==i.text[s];s++)n++;return n}if(o.content.size||i.content.size){var a=S(o.content,i.content,n+1);if(null!=a)return a}n+=o.nodeSize}else n+=o.nodeSize}}function A(e,t,n,r){for(var o=e.childCount,i=t.childCount;;){if(0==o||0==i)return o==i?null:{a:n,b:r};var s=e.child(--o),a=t.child(--i),u=s.nodeSize;if(s!=a){if(!s.sameMarkup(a))return{a:n,b:r};if(s.isText&&s.text!=a.text){for(var c=0,l=Math.min(s.text.length,a.text.length);c<l&&s.text[s.text.length-c-1]==a.text[a.text.length-c-1];)c++,n--,r--;return{a:n,b:r}}if(s.content.size||a.content.size){var d=A(s.content,a.content,n-1,r-1);if(d)return d}n-=u,r-=u}else n-=u,r-=u}}M.prototype={constructor:M,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,o=r.find(e),i=r.content.slice();return-1==o?i.push(n||e,t):(i[o+1]=t,n&&(i[o]=n)),new M(i)},remove:function(e){var t=this.find(e);if(-1==t)return this;var n=this.content.slice();return n.splice(t,2),new M(n)},addToStart:function(e,t){return new M([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new M(n)},addBefore:function(e,t,n){var r=this.remove(t),o=r.content.slice(),i=r.find(e);return o.splice(-1==i?o.length:i,0,t,n),new M(o)},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=M.from(e)).size?new M(e.content.concat(this.subtract(e).content)):this},append:function(e){return(e=M.from(e)).size?new M(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=M.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}},M.from=function(e){if(e instanceof M)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new M(t)};var C=function(){function e(t,n){if((0,h.A)(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,p.A)(e,[{key:"nodesBetween",value:function(e,t,n){for(var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=arguments.length>4?arguments[4]:void 0,i=0,s=0;s<t;i++){var a=this.content[i],u=s+a.nodeSize;if(u>e&&!1!==n(a,r+s,o||null,i)&&a.content.size){var c=s+1;a.nodesBetween(Math.max(0,e-c),Math.min(a.content.size,t-c),n,r+c)}s=u}}},{key:"descendants",value:function(e){this.nodesBetween(0,this.size,e)}},{key:"textBetween",value:function(e,t,n,r){var o="",i=!0;return this.nodesBetween(e,t,(function(s,a){var u=s.isText?s.text.slice(Math.max(e,a)-a,t-a):s.isLeaf?r?"function"==typeof r?r(s):r:s.type.spec.leafText?s.type.spec.leafText(s):"":"";s.isBlock&&(s.isLeaf&&u||s.isTextblock)&&n&&(i?i=!1:o+=n),o+=u}),0),o}},{key:"append",value:function(t){if(!t.size)return this;if(!this.size)return t;var n=this.lastChild,r=t.firstChild,o=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(r)&&(o[o.length-1]=n.withText(n.text+r.text),i=1);i<t.content.length;i++)o.push(t.content[i]);return new e(o,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=[],o=0;if(n>t)for(var i=0,s=0;s<n;i++){var a=this.content[i],u=s+a.nodeSize;u>t&&((s<t||u>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),o+=a.nodeSize),s=u}return new e(r,o)}},{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 o=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return o[t]=n,new e(o,i)}},{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){return S(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:0)}},{key:"findDiffEnd",value:function(e){return A(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.size,arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.size)}},{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 o=r+this.child(n).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,o=0;o<t.length;o++){var i=t[o];r+=i.nodeSize,o&&i.isText&&t[o-1].sameMarkup(i)?(n||(n=t.slice(0,o)),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}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)":""))}}])}();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,f.A)(e)||!t||"object"!=(0,f.A)(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 o in e)if(!(o in t)||!N(e[o],t[o]))return!1;for(var i in t)if(!(i in e))return!1}return!0}var E=function(){function e(t,n){(0,h.A)(this,e),this.type=t,this.attrs=n}return(0,p.A)(e,[{key:"addToSet",value:function(e){for(var t,n=!1,r=0;r<e.length;r++){var o=e[r];if(this.eq(o))return e;if(this.type.excludes(o.type))t||(t=e.slice(0,r));else{if(o.type.excludes(this.type))return e;!n&&o.type.rank>this.type.rank&&(t||(t=e.slice(0,r)),t.push(this),n=!0),t&&t.push(o)}}return t||(t=e.slice()),n||t.push(this),t}},{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.none=[];var D=function(e){function t(){return(0,h.A)(this,t),w(this,t,arguments)}return(0,l.A)(t,e),(0,p.A)(t)}((0,d.A)(Error)),P=function(){function e(t,n,r){(0,h.A)(this,e),this.content=t,this.openStart=n,this.openEnd=r}return(0,p.A)(e,[{key:"size",get:function(){return this.content.size-this.openStart-this.openEnd}},{key:"insertAt",value:function(t,n){var r=R(this.content,t+this.openStart,n);return r&&new e(r,this.openStart,this.openEnd)}},{key:"removeBetween",value:function(t,n){return new e(I(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,o=n.openEnd||0;if("number"!=typeof r||"number"!=typeof o)throw new RangeError("Invalid input for Slice.fromJSON");return new e(C.fromJSON(t,n.content),r,o)}},{key:"maxOpen",value:function(t){for(var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=0,o=0,i=t.firstChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.firstChild)r++;for(var _n=t.lastChild;_n&&!_n.isLeaf&&(n||!_n.type.spec.isolating);_n=_n.lastChild)o++;return new e(t,r,o)}}])}();function I(e,t,n){var r=e.findIndex(t),o=r.index,i=r.offset,s=e.maybeChild(o),a=e.findIndex(n),u=a.index,c=a.offset;if(i==t||s.isText){if(c!=n&&!e.child(u).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(n))}if(o!=u)throw new RangeError("Removing non-flat range");return e.replaceChild(o,s.copy(I(s.content,t-i-1,n-i-1)))}function R(e,t,n,r){var o=e.findIndex(t),i=o.index,s=o.offset,a=e.maybeChild(i);if(s==t||a.isText)return r&&!r.canReplace(i,i,n)?null:e.cut(0,t).append(n).append(e.cut(t));var u=R(a.content,t-s-1,n);return u&&e.replaceChild(i,a.copy(u))}function z(e,t,n){if(n.openStart>e.depth)throw new D("Inserted content deeper than insertion position");if(e.depth-n.openStart!=t.depth-n.openEnd)throw new D("Inconsistent open depths");return B(e,t,n,0)}function B(e,t,n,r){var o=e.index(r),i=e.node(r);if(o==t.index(r)&&r<e.depth-n.openStart){var s=B(e,t,n,r+1);return i.copy(i.content.replaceChild(o,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),o=n-1;o>=0;o--)r=t.node(o).copy(C.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}(n,e);return j(i,H(e,a.start,a.end,t,r))}var u=e.parent,c=u.content;return j(u,c.cut(0,e.parentOffset).append(n.content).append(c.cut(t.parentOffset)))}return j(i,q(e,t,r))}function L(e,t){if(!t.type.compatibleContent(e.type))throw new D("Cannot join "+t.type.name+" onto "+e.type.name)}function $(e,t,n){var r=e.node(n);return L(r,t.node(n)),r}function V(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 F(e,t,n,r){var o=(t||e).node(n),i=0,s=t?t.index(n):o.childCount;e&&(i=e.index(n),e.depth>n?i++:e.textOffset&&(V(e.nodeAfter,r),i++));for(var a=i;a<s;a++)V(o.child(a),r);t&&t.depth==n&&t.textOffset&&V(t.nodeBefore,r)}function j(e,t){return e.type.checkContent(t),e.copy(t)}function H(e,t,n,r,o){var i=e.depth>o&&$(e,t,o+1),s=r.depth>o&&$(n,r,o+1),a=[];return F(null,e,o,a),i&&s&&t.index(o)==n.index(o)?(L(i,s),V(j(i,H(e,t,n,r,o+1)),a)):(i&&V(j(i,q(e,t,o+1)),a),F(t,n,o,a),s&&V(j(s,q(n,r,o+1)),a)),F(r,null,o,a),new C(a)}function q(e,t,n){var r=[];return F(null,e,n,r),e.depth>n&&V(j($(e,t,n+1),q(e,t,n+1)),r),F(t,null,n,r),new C(r)}P.empty=new P(C.empty,0,0);var J=function(){function e(t,n,r){(0,h.A)(this,e),this.pos=t,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}return(0,p.A)(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,o=0;o<e;o++)r+=n.child(o).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 o=n;n=r,r=o}for(var i=n.marks,s=0;s<i.length;s++)!1!==i[s].type.spec.inclusive||r&&i[s].isInSet(r.marks)||(i=i[s--].removeFromSet(i));return i}},{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()),o=0;o<n.length;o++)!1!==n[o].type.spec.inclusive||r&&n[o].isInSet(r.marks)||(n=n[o--].removeFromSet(n));return n}},{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 U(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=[],o=0,i=n,s=t;;){var a=s.content.findIndex(i),u=a.index,c=a.offset,l=i-c;if(r.push(s,u,o+c),!l)break;if((s=s.child(u)).isText)break;i=l-1,o+=c+1}return new e(n,r,i)}},{key:"resolveCached",value:function(t,n){for(var r=0;r<W.length;r++){var o=W[r];if(o.pos==n&&o.doc==t)return o}var i=W[K]=e.resolve(t,n);return K=(K+1)%_,i}}])}(),W=[],K=0,_=12,U=function(){return(0,p.A)((function e(t,n,r){(0,h.A)(this,e),this.$from=t,this.$to=n,this.depth=r}),[{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)}}])}(),G=Object.create(null),X=function(){function e(t,n,r){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:E.none;(0,h.A)(this,e),this.type=t,this.attrs=n,this.marks=o,this.content=r||C.empty}return(0,p.A)(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||G)&&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 P.empty;var r=this.resolve(e),o=this.resolve(t),i=n?0:r.sharedDepth(t),s=r.start(i),a=r.node(i).content.cut(r.pos-s,o.pos-s);return new P(a,r.depth-i,o.depth-i)}},{key:"replace",value:function(e,t,n){return z(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,o=n.offset;if(!(t=t.maybeChild(r)))return null;if(o==e||t.isText)return t;e-=o+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 o=this.content.child(n-1);return{node:o,index:n-1,offset:r-o.nodeSize}}},{key:"resolve",value:function(e){return J.resolveCached(this,e)}},{key:"resolveNoCache",value:function(e){return J.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()+")"),Q(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,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:n.childCount,i=this.contentMatchAt(e).matchFragment(n,r,o),s=i&&i.matchFragment(this.content,t);if(!s||!s.validEnd)return!1;for(var a=r;a<o;a++)if(!this.type.allowsMarks(n.child(a).marks))return!1;return!0}},{key:"canReplaceWith",value:function(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;var o=this.contentMatchAt(e).matchType(n),i=o&&o.matchFragment(this.content,t);return!!i&&i.validEnd}},{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)}}])}();X.prototype.text=void 0;var Y=function(e){function t(e,n,r,o){var i;if((0,h.A)(this,t),i=w(this,t,[e,n,null,o]),!r)throw new RangeError("Empty text nodes are not allowed");return i.text=r,i}return(0,l.A)(t,e),(0,p.A)(t,[{key:"toString",value:function(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Q(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 t(this.type,this.attrs,this.text,e)}},{key:"withText",value:function(e){return e==this.text?this:new t(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=u((0,a.A)(t.prototype),"toJSON",this).call(this);return e.text=this.text,e}}])}(X);function Q(e,t){for(var n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}var Z=function(){function e(t){(0,h.A)(this,e),this.validEnd=t,this.next=[],this.wrapCache=[]}return(0,p.A)(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,o=t;r&&o<n;o++)r=r.matchType(e.child(o).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];return function o(i,s){var a=i.matchFragment(e,n);if(a&&(!t||a.validEnd))return C.from(s.map((function(e){return e.createAndFill()})));for(var u=0;u<i.next.length;u++){var c=i.next[u],l=c.type,d=c.next;if(!l.isText&&!l.hasRequiredAttrs()&&-1==r.indexOf(d)){r.push(d);var f=o(d,s.concat(l));if(f)return f}}return null}(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(),o=r.match;if(o.matchType(e)){for(var i=[],s=r;s.type;s=s.via)i.push(s.type);return i.reverse()}for(var a=0;a<o.next.length;a++){var u=o.next[a],c=u.type,l=u.next;c.isLeaf||c.hasRequiredAttrs()||c.name in t||r.type&&!l.validEnd||(n.push({match:c.contentMatch,type:c,via:r}),t[c.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?"*":" ")+" ",o=0;o<t.next.length;o++)r+=(o?", ":"")+t.next[o].type.name+"->"+e.indexOf(t.next[o].next);return r})).join("\n")}}],[{key:"parse",value:function(t,n){var r=new ee(t,n);if(null==r.next)return e.empty;var o=te(r);r.next&&r.err("Unexpected trailing text");var i=ue(function(e){var t=[[]];return o(function e(t,i){if("choice"==t.type)return t.exprs.reduce((function(t,n){return t.concat(e(n,i))}),[]);if("seq"!=t.type){if("star"==t.type){var s=n();return r(i,s),o(e(t.expr,s),s),[r(s)]}if("plus"==t.type){var a=n();return o(e(t.expr,i),a),o(e(t.expr,a),a),[r(a)]}if("opt"==t.type)return[r(i)].concat(e(t.expr,i));if("range"==t.type){for(var u=i,c=0;c<t.min;c++){var l=n();o(e(t.expr,u),l),u=l}if(-1==t.max)o(e(t.expr,u),u);else for(var d=t.min;d<t.max;d++){var f=n();r(u,f),o(e(t.expr,u),f),u=f}return[r(u)]}if("name"==t.type)return[r(i,void 0,t.value)];throw new Error("Unknown expr type")}for(var h=0;;h++){var p=e(t.exprs[h],i);if(h==t.exprs.length-1)return p;o(p,i=n())}}(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){var o={term:r,to:n};return t[e].push(o),o}function o(e,t){e.forEach((function(e){return e.to=t}))}}(o));return function(e,t){for(var n=0,r=[e];n<r.length;n++){for(var o=r[n],i=!o.validEnd,s=[],a=0;a<o.next.length;a++){var u=o.next[a],c=u.type,l=u.next;s.push(c.name),!i||c.isText||c.hasRequiredAttrs()||(i=!1),-1==r.indexOf(l)&&r.push(l)}i&&t.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(i,r),i}}])}();Z.empty=new Z(!0);var ee=function(){return(0,p.A)((function e(t,n){(0,h.A)(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()}),[{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+"')")}}])}();function te(e){var t=[];do{t.push(ne(e))}while(e.eat("|"));return 1==t.length?t[0]:{type:"choice",exprs:t}}function ne(e){var t=[];do{t.push(re(e))}while(e.next&&")"!=e.next&&"|"!=e.next);return 1==t.length?t[0]:{type:"seq",exprs:t}}function re(e){for(var t=function(e){if(e.eat("(")){var t=te(e);return e.eat(")")||e.err("Missing closing paren"),t}if(!/\W/.test(e.next)){var n=function(e,t){var n=e.nodeTypes,r=n[t];if(r)return[r];var o=[];for(var i in n){var s=n[i];s.groups.indexOf(t)>-1&&o.push(s)}return 0==o.length&&e.err("No node type or group '"+t+"' found"),o}(e,e.next).map((function(t){return null==e.inline?e.inline=t.isInline:e.inline!=t.isInline&&e.err("Mixing inline and block content"),{type:"name",value:t}}));return e.pos++,1==n.length?n[0]:{type:"choice",exprs:n}}e.err("Unexpected token '"+e.next+"'")}(e);;)if(e.eat("+"))t={type:"plus",expr:t};else if(e.eat("*"))t={type:"star",expr:t};else if(e.eat("?"))t={type:"opt",expr:t};else{if(!e.eat("{"))break;t=ie(e,t)}return t}function oe(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=oe(e),r=n;return e.eat(",")&&(r="}"!=e.next?oe(e):-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:t}}function se(e,t){return t-e}function ae(e,t){var n=[];return function t(r){var o=e[r];if(1==o.length&&!o[0].term)return t(o[0].to);n.push(r);for(var i=0;i<o.length;i++){var s=o[i],a=s.term,u=s.to;a||-1!=n.indexOf(u)||t(u)}}(t),n.sort(se)}function ue(e){var t=Object.create(null);return function n(r){var o=[];r.forEach((function(t){e[t].forEach((function(t){var n=t.term,r=t.to;if(n){for(var i,s=0;s<o.length;s++)o[s][0]==n&&(i=o[s][1]);ae(e,r).forEach((function(e){i||o.push([n,i=[]]),-1==i.indexOf(e)&&i.push(e)}))}}))}));for(var i=t[r.join(",")]=new Z(r.indexOf(e.length-1)>-1),s=0;s<o.length;s++){var a=o[s][1].sort(se);i.next.push({type:o[s][0],next:t[a.join(",")]||n(a)})}return i}(ae(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 le(e,t){var n=Object.create(null);for(var r in e){var o=t&&t[r];if(void 0===o){var i=e[r];if(!i.hasDefault)throw new RangeError("No value supplied for attribute "+r);o=i.default}n[r]=o}return n}function de(e){var t=Object.create(null);if(e)for(var n in e)t[n]=new he(e[n]);return t}var fe=function(){function e(t,n,r){(0,h.A)(this,e),this.name=t,this.schema=n,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=de(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,p.A)(e,[{key:"isInline",get:function(){return!this.isBlock}},{key:"isTextblock",get:function(){return this.isBlock&&this.inlineContent}},{key:"isLeaf",get:function(){return this.contentMatch==Z.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:le(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 X(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 X(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 o=this.contentMatch.matchFragment(t),i=o&&o.fillBefore(C.empty,!0);return i?new X(this,e,t.append(i),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,o){return r[t]=new e(t,n,o)}));var o=n.spec.topNode||"doc";if(!r[o])throw new RangeError("Schema is missing its top node type ('"+o+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(var i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}}])}(),he=function(){return(0,p.A)((function e(t){(0,h.A)(this,e),this.hasDefault=Object.prototype.hasOwnProperty.call(t,"default"),this.default=t.default}),[{key:"isRequired",get:function(){return!this.hasDefault}}])}(),pe=function(){function e(t,n,r,o){(0,h.A)(this,e),this.name=t,this.rank=n,this.schema=r,this.spec=o,this.attrs=de(o.attrs),this.excluded=null;var i=ce(this.attrs);this.instance=i?new E(this,i):null}return(0,p.A)(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,le(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),o=0;return t.forEach((function(t,i){return r[t]=new e(t,o++,n,i)})),r}}])}(),ve=function(){return(0,p.A)((function e(t){(0,h.A)(this,e),this.linebreakReplacement=null,this.cached=Object.create(null);var n=this.spec={};for(var r in t)n[r]=t[r];n.nodes=M.from(t.nodes),n.marks=M.from(t.marks||{}),this.nodes=fe.compile(this.spec.nodes,this),this.marks=pe.compile(this.spec.marks,this);var o=Object.create(null);for(var i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");var s=this.nodes[i],a=s.spec.content||"",u=s.spec.marks;if(s.contentMatch=o[a]||(o[a]=Z.parse(a,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet="_"==u?null:u?me(this,u.split(" ")):""!=u&&s.inlineContent?null:[]}for(var c in this.marks){var l=this.marks[c],d=l.spec.excludes;l.excluded=null==d?[l]:""==d?[]:me(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)}),[{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 fe))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 Y(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 X.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}}])}();function me(e,t){for(var n=[],r=0;r<t.length;r++){var o=t[r],i=e.marks[o],s=i;if(i)n.push(i);else for(var a in e.marks){var u=e.marks[a];("_"==o||u.spec.group&&u.spec.group.split(" ").indexOf(o)>-1)&&n.push(s=u)}if(!s)throw new SyntaxError("Unknown mark type: '"+t[r]+"'")}return n}var ge=function(){function e(t,n){var r=this;(0,h.A)(this,e),this.schema=t,this.rules=n,this.tags=[],this.styles=[],n.forEach((function(e){!function(e){return null!=e.tag}(e)?function(e){return null!=e.style}(e)&&r.styles.push(e):r.tags.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,p.A)(e,[{key:"parse",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=new Me(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 Me(this,t,!0);return n.addAll(e,t.from,t.to),P.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 o=this.tags[r];if(Se(e,o.tag)&&(void 0===o.namespace||e.namespaceURI==o.namespace)&&(!o.context||t.matchesContext(o.context))){if(o.getAttrs){var i=o.getAttrs(e);if(!1===i)continue;o.attrs=i||void 0}return o}}}},{key:"matchStyle",value:function(e,t,n,r){for(var o=r?this.styles.indexOf(r)+1:0;o<this.styles.length;o++){var i=this.styles[o],s=i.style;if(!(0!=s.indexOf(e)||i.context&&!n.matchesContext(i.context)||s.length>e.length&&(61!=s.charCodeAt(e.length)||s.slice(e.length+1)!=t))){if(i.getAttrs){var a=i.getAttrs(t);if(!1===a)continue;i.attrs=a||void 0}return i}}}}],[{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 o=t[r];if((null==o.priority?50:o.priority)<n)break}t.splice(r,0,e)}var r=function(t){var r=e.marks[t].spec.parseDOM;r&&r.forEach((function(e){n(e=Ae(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)}))};for(var o in e.marks)r(o);var i=function(t){var r=e.nodes[t].spec.parseDOM;r&&r.forEach((function(e){n(e=Ae(e)),e.node||e.ignore||e.mark||(e.node=t)}))};for(var s in e.nodes)i(s);return t}},{key:"fromSchema",value:function(t){return t.cached.domParser||(t.cached.domParser=new e(t,e.schemaRules(t)))}}])}(),ye={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},ke={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},be={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 xe=function(){return(0,p.A)((function e(t,n,r,o,i,s,a){(0,h.A)(this,e),this.type=t,this.attrs=n,this.marks=r,this.pendingMarks=o,this.solid=i,this.options=a,this.content=[],this.activeMarks=E.none,this.stashMarks=[],this.match=s||(4&a?null:t.contentMatch)}),[{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 o=C.from(this.content);return!e&&this.match&&(o=o.append(this.match.fillBefore(C.empty,!0))),this.type?this.type.create(this.attrs,o,this.marks):o}},{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&&!ye.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}])}(),Me=function(){return(0,p.A)((function e(t,n,r){(0,h.A)(this,e),this.parser=t,this.options=n,this.isOpen=r,this.open=0;var o,i=n.topNode,s=we(null,n.preserveWhitespace,0)|(r?4:0);o=i?new xe(i.type,i.attrs,E.none,E.none,!0,n.topMatch||i.type.contentMatch,s):new xe(r?null:t.schema.topNodeType,null,E.none,E.none,!0,null,s),this.nodes=[o],this.find=n.findPositions,this.needsBlock=!1}),[{key:"top",get:function(){return this.nodes[this.open]}},{key:"addDOM",value:function(e){3==e.nodeType?this.addTextNode(e):1==e.nodeType&&this.addElement(e)}},{key:"withStyleRules",value:function(e,t){var n=e.style;if(!n||!n.length)return t();var r=this.readStyles(e.style);if(r){for(var o=(0,s.A)(r,2),i=o[0],a=o[1],u=this.top,c=0;c<a.length;c++)this.removePendingMark(a[c],u);for(var l=0;l<i.length;l++)this.addPendingMark(i[l]);t();for(var d=0;d<i.length;d++)this.removePendingMark(i[d],u);for(var f=0;f<a.length;f++)this.addPendingMark(a[f])}}},{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],o=e.previousSibling;(!r||o&&"BR"==o.nodeName||r.isText&&/[ \t\r\n\u000c]$/.test(r.text))&&(t=t.slice(1))}t&&this.insertNode(this.parser.schema.text(t)),this.findInText(e)}else this.findInside(e)}},{key:"addElement",value:function(e,t){var n,r=this,o=e.nodeName.toLowerCase();be.hasOwnProperty(o)&&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&&be.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:ke.hasOwnProperty(o))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 s,a=this.top,u=this.needsBlock;if(ye.hasOwnProperty(o))a.content.length&&a.content[0].isInline&&this.open&&(this.open--,a=this.top),s=!0,a.type||(this.needsBlock=!0);else if(!e.firstChild)return void this.leafFallback(e);i&&i.skip?this.addAll(e):this.withStyleRules(e,(function(){return r.addAll(e)})),s&&this.sync(a),this.needsBlock=u}else this.withStyleRules(e,(function(){r.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){for(var t=this,n=E.none,r=E.none,o=0,i=e.length;o<i;o++)for(var s,a=e.item(o),u=function(o){var i=t.parser.matchStyle(a,e.getPropertyValue(a),t,o);return i?i.ignore?{v:null}:(i.clearMark?t.top.pendingMarks.concat(t.top.activeMarks).forEach((function(e){i.clearMark(e)&&(r=e.addToSet(r))})):n=t.parser.schema.marks[i.mark].create(i.attrs).addToSet(n),!1!==i.consuming?(c=o,0):void(c=o=i)):(c=o,0)},c=void 0;0!==(s=u(c));)if(s)return s.v;return[n,r]}},{key:"addElementByRule",value:function(e,t,n){var r,o,i,s=this;t.node?(o=this.parser.schema.nodes[t.node]).isLeaf?this.insertNode(o.create(t.attrs))||this.leafFallback(e):r=this.enter(o,t.attrs||null,t.preserveWhitespace):(i=this.parser.schema.marks[t.mark].create(t.attrs),this.addPendingMark(i));var a=this.top;if(o&&o.isLeaf)this.findInside(e);else if(n)this.addElement(e,n);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach((function(e){return s.insertNode(e)}));else{var u=e;"string"==typeof t.contentElement?u=e.querySelector(t.contentElement):"function"==typeof t.contentElement?u=t.contentElement(e):t.contentElement&&(u=t.contentElement),this.findAround(e,u,!0),this.addAll(u)}r&&this.sync(a)&&this.open--,i&&this.removePendingMark(i,a)}},{key:"addAll",value:function(e,t,n){for(var r=t||0,o=t?e.childNodes[t]:e.firstChild,i=null==n?null:e.childNodes[n];o!=i;o=o.nextSibling,++r)this.findAtPoint(e,r),this.addDOM(o);this.findAtPoint(e,r)}},{key:"findPlace",value:function(e){for(var t,n,r=this.open;r>=0;r--){var o=this.nodes[r],i=o.findWrapping(e);if(i&&(!t||t.length>i.length)&&(t=i,n=o,!i.length))break;if(o.solid)break}if(!t)return!1;this.sync(n);for(var s=0;s<t.length;s++)this.enterInner(t[s],null,!1);return!0}},{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,o=0;o<e.marks.length;o++)n.type&&!n.type.allowsMarkType(e.marks[o].type)||(r=e.marks[o].addToSet(r));return n.content.push(e.mark(r)),!0}return!1}},{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 o=this.top;o.applyPending(e),o.match=o.match&&o.match.matchType(e);var i=we(e,r,o.options);4&o.options&&0==o.content.length&&(i|=4),this.nodes.push(new xe(e,t,o.activeMarks,o.pendingMarks,n,null,i)),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,o=!(this.isOpen||r&&r.parent.type!=this.nodes[0].type),i=-(r?r.depth+1:0)+(o?0:1);return function e(s,a){for(;s>=0;s--){var u=n[s];if(""==u){if(s==n.length-1||0==s)continue;for(;a>=i;a--)if(e(s-1,a))return!0;return!1}var c=a>0||0==a&&o?t.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!c||c.name!=u&&-1==c.groups.indexOf(u))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 o=this.parser.schema.nodes[r];if(o.isTextblock&&o.defaultAttrs)return o}}},{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 o=r.popFromStashMark(e);o&&r.type&&r.type.allowsMarkType(o.type)&&(r.activeMarks=o.addToSet(r.activeMarks))}if(r==t)break}}}])}();function Se(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function Ae(e){var t={};for(var n in e)t[n]=e[n];return t}function Ce(e,t){var n,r=t.schema.nodes,o=function(){var n=r[i];if(!n.allowsMarkType(e))return 0;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}}(n.contentMatch)?{v:!0}:void 0};for(var i in r)if(0!==(n=o())&&n)return n.v}var Oe=function(){function e(t,n){(0,h.A)(this,e),this.nodes=t,this.marks=n}return(0,p.A)(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 o=r,i=[];return e.forEach((function(e){if(i.length||e.marks.length){for(var r=0,s=0;r<i.length&&s<e.marks.length;){var a=e.marks[s];if(t.marks[a.type.name]){if(!a.eq(i[r][0])||!1===a.type.spec.spanning)break;r++,s++}else s++}for(;r<i.length;)o=i.pop()[1];for(;s<e.marks.length;){var u=e.marks[s++],c=t.serializeMark(u,e.isInline,n);c&&(i.push([u,o]),o.appendChild(c.dom),o=c.contentDOM||c.dom)}}o.appendChild(t.serializeNodeInner(e,n))})),r}},{key:"serializeNodeInner",value:function(t,n){var r=e.renderSpec(Ne(n),this.nodes[t.type.name](t)),o=r.dom,i=r.contentDOM;if(i){if(t.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(t.content,n,i)}return o}},{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 o=this.serializeMark(e.marks[r],e.isInline,t);o&&((o.contentDOM||o.dom).appendChild(n),n=o.dom)}return n}},{key:"serializeMark",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=this.marks[t.type.name];return o&&e.renderSpec(Ne(r),o(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 o,i=n[0],s=i.indexOf(" ");s>0&&(r=i.slice(0,s),i=i.slice(s+1));var a=r?t.createElementNS(r,i):t.createElement(i),u=n[1],c=1;if(u&&"object"==(0,f.A)(u)&&null==u.nodeType&&!Array.isArray(u))for(var l in c=2,u)if(null!=u[l]){var d=l.indexOf(" ");d>0?a.setAttributeNS(l.slice(0,d),l.slice(d+1),u[l]):a.setAttribute(l,u[l])}for(var h=c;h<n.length;h++){var p=n[h];if(0===p){if(h<n.length-1||h>c)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}var v=e.renderSpec(t,p,r),m=v.dom,g=v.contentDOM;if(a.appendChild(m),g){if(o)throw new RangeError("Multiple content holes");o=g}}return{dom:a,contentDOM:o}}},{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)}}])}();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 De(e){return 65535&e}var Pe=function(){return(0,p.A)((function e(t,n,r){(0,h.A)(this,e),this.pos=t,this.delInfo=n,this.recover=r}),[{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}}])}(),Ie=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if((0,h.A)(this,e),this.ranges=t,this.inverted=n,!t.length&&e.empty)return e.empty}return(0,p.A)(e,[{key:"recover",value:function(e){var t=0,n=De(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,o=this.inverted?2:1,i=this.inverted?1:2,s=0;s<this.ranges.length;s+=3){var a=this.ranges[s]-(this.inverted?r:0);if(a>e)break;var u=this.ranges[s+o],c=this.ranges[s+i],l=a+u;if(e<=l){var d=a+r+((u?e==a?-1:e==l?1:t:t)<0?0:c);if(n)return d;var f=e==a?2:e==l?1:4;return(t<0?e!=a:e!=l)&&(f|=8),new Pe(d,f,e==(t<0?a:l)?null:s/3+(e-a)*Ee)}r+=c-u}return n?e+r:new Pe(e+r,0,null)}},{key:"touches",value:function(e,t){for(var n=0,r=De(t),o=this.inverted?2:1,i=this.inverted?1:2,s=0;s<this.ranges.length;s+=3){var a=this.ranges[s]-(this.inverted?n:0);if(a>e)break;var u=this.ranges[s+o];if(e<=a+u&&s==3*r)return!0;n+=this.ranges[s+i]-u}return!1}},{key:"forEach",value:function(e){for(var t=this.inverted?2:1,n=this.inverted?1:2,r=0,o=0;r<this.ranges.length;r+=3){var i=this.ranges[r],s=i-(this.inverted?o:0),a=i+(this.inverted?0:o),u=this.ranges[r+t],c=this.ranges[r+n];e(s,s+u,a,a+c),o+=c-u}}},{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])}}])}();Ie.empty=new Ie([]);var Re=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,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:t.length;(0,h.A)(this,e),this.maps=t,this.mirror=n,this.from=r,this.to=o}return(0,p.A)(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,o=this.from;o<this.to;o++){var i=this.maps[o].mapResult(e,t);if(null!=i.recover){var s=this.getMirror(o);if(null!=s&&s>o&&s<this.to){o=s,e=this.maps[s].recover(i.recover);continue}}r|=i.delInfo,e=i.pos}return n?e:new Pe(e,r,null)}}])}(),ze=Object.create(null),Be=function(){return(0,p.A)((function e(){(0,h.A)(this,e)}),[{key:"getMap",value:function(){return Ie.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=ze[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 ze)throw new RangeError("Duplicate use of step JSON ID "+e);return ze[e]=t,t.prototype.jsonID=e,t}}])}(),Le=function(){function e(t,n){(0,h.A)(this,e),this.doc=t,this.failed=n}return(0,p.A)(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,o){try{return e.ok(t.replace(n,r,o))}catch(t){if(t instanceof D)return e.fail(t.message);throw t}}}])}();function $e(e,t,n){for(var r=[],o=0;o<e.childCount;o++){var i=e.child(o);i.content.size&&(i=i.copy($e(i.content,t,i))),i.isInline&&(i=t(i,n,o)),r.push(i)}return C.fromArray(r)}var Ve=function(e){function t(e,n,r){var o;return(0,h.A)(this,t),(o=w(this,t)).from=e,o.to=n,o.mark=r,o}return(0,l.A)(t,e),(0,p.A)(t,[{key:"apply",value:function(e){var t=this,n=e.slice(this.from,this.to),r=e.resolve(this.from),o=r.node(r.sharedDepth(this.to)),i=new P($e(n.content,(function(e,n){return e.isAtom&&n.type.allowsMarkType(t.mark.type)?e.mark(t.mark.addToSet(e.marks)):e}),o),n.openStart,n.openEnd);return Le.fromReplace(e,this.from,this.to,i)}},{key:"invert",value:function(){return new Fe(this.from,this.to,this.mark)}},{key:"map",value:function(e){var n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new t(n.pos,r.pos,this.mark)}},{key:"merge",value:function(e){return e instanceof t&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new t(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,n){if("number"!=typeof n.from||"number"!=typeof n.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new t(n.from,n.to,e.markFromJSON(n.mark))}}])}(Be);Be.jsonID("addMark",Ve);var Fe=function(e){function t(e,n,r){var o;return(0,h.A)(this,t),(o=w(this,t)).from=e,o.to=n,o.mark=r,o}return(0,l.A)(t,e),(0,p.A)(t,[{key:"apply",value:function(e){var t=this,n=e.slice(this.from,this.to),r=new P($e(n.content,(function(e){return e.mark(t.mark.removeFromSet(e.marks))}),e),n.openStart,n.openEnd);return Le.fromReplace(e,this.from,this.to,r)}},{key:"invert",value:function(){return new Ve(this.from,this.to,this.mark)}},{key:"map",value:function(e){var n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new t(n.pos,r.pos,this.mark)}},{key:"merge",value:function(e){return e instanceof t&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new t(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,n){if("number"!=typeof n.from||"number"!=typeof n.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new t(n.from,n.to,e.markFromJSON(n.mark))}}])}(Be);Be.jsonID("removeMark",Fe);var je=function(e){function t(e,n){var r;return(0,h.A)(this,t),(r=w(this,t)).pos=e,r.mark=n,r}return(0,l.A)(t,e),(0,p.A)(t,[{key:"apply",value:function(e){var t=e.nodeAt(this.pos);if(!t)return Le.fail("No node at mark step's position");var n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return Le.fromReplace(e,this.pos,this.pos+1,new P(C.from(n),0,t.isLeaf?0:1))}},{key:"invert",value:function(e){var n=e.nodeAt(this.pos);if(n){var r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(var o=0;o<n.marks.length;o++)if(!n.marks[o].isInSet(r))return new t(this.pos,n.marks[o]);return new t(this.pos,this.mark)}}return new He(this.pos,this.mark)}},{key:"map",value:function(e){var n=e.mapResult(this.pos,1);return n.deletedAfter?null:new t(n.pos,this.mark)}},{key:"toJSON",value:function(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}}],[{key:"fromJSON",value:function(e,n){if("number"!=typeof n.pos)throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new t(n.pos,e.markFromJSON(n.mark))}}])}(Be);Be.jsonID("addNodeMark",je);var He=function(e){function t(e,n){var r;return(0,h.A)(this,t),(r=w(this,t)).pos=e,r.mark=n,r}return(0,l.A)(t,e),(0,p.A)(t,[{key:"apply",value:function(e){var t=e.nodeAt(this.pos);if(!t)return Le.fail("No node at mark step's position");var n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return Le.fromReplace(e,this.pos,this.pos+1,new P(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 je(this.pos,this.mark):this}},{key:"map",value:function(e){var n=e.mapResult(this.pos,1);return n.deletedAfter?null:new t(n.pos,this.mark)}},{key:"toJSON",value:function(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}}],[{key:"fromJSON",value:function(e,n){if("number"!=typeof n.pos)throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new t(n.pos,e.markFromJSON(n.mark))}}])}(Be);Be.jsonID("removeNodeMark",He);var qe=function(e){function t(e,n,r){var o,i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return(0,h.A)(this,t),(o=w(this,t)).from=e,o.to=n,o.slice=r,o.structure=i,o}return(0,l.A)(t,e),(0,p.A)(t,[{key:"apply",value:function(e){return this.structure&&We(e,this.from,this.to)?Le.fail("Structure replace would overwrite content"):Le.fromReplace(e,this.from,this.to,this.slice)}},{key:"getMap",value:function(){return new Ie([this.from,this.to-this.from,this.slice.size])}},{key:"invert",value:function(e){return new t(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}},{key:"map",value:function(e){var n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deletedAcross&&r.deletedAcross?null:new t(n.pos,Math.max(n.pos,r.pos),this.slice)}},{key:"merge",value:function(e){if(!(e instanceof t)||e.structure||this.structure)return null;if(this.from+this.slice.size!=e.from||this.slice.openEnd||e.slice.openStart){if(e.to!=this.from||this.slice.openStart||e.slice.openEnd)return null;var n=this.slice.size+e.slice.size==0?P.empty:new P(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new t(e.from,this.to,n,this.structure)}var r=this.slice.size+e.slice.size==0?P.empty:new P(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new t(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,n){if("number"!=typeof n.from||"number"!=typeof n.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new t(n.from,n.to,P.fromJSON(e,n.slice),!!n.structure)}}])}(Be);Be.jsonID("replace",qe);var Je=function(e){function t(e,n,r,o,i,s){var a,u=arguments.length>6&&void 0!==arguments[6]&&arguments[6];return(0,h.A)(this,t),(a=w(this,t)).from=e,a.to=n,a.gapFrom=r,a.gapTo=o,a.slice=i,a.insert=s,a.structure=u,a}return(0,l.A)(t,e),(0,p.A)(t,[{key:"apply",value:function(e){if(this.structure&&(We(e,this.from,this.gapFrom)||We(e,this.gapTo,this.to)))return Le.fail("Structure gap-replace would overwrite content");var t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return Le.fail("Gap is not a flat range");var n=this.slice.insertAt(this.insert,t.content);return n?Le.fromReplace(e,this.from,this.to,n):Le.fail("Content does not fit in gap")}},{key:"getMap",value:function(){return new Ie([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 n=this.gapTo-this.gapFrom;return new t(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}},{key:"map",value:function(e){var n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),o=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||o<n.pos||i>r.pos?null:new t(n.pos,r.pos,o,i,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,n){if("number"!=typeof n.from||"number"!=typeof n.to||"number"!=typeof n.gapFrom||"number"!=typeof n.gapTo||"number"!=typeof n.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new t(n.from,n.to,n.gapFrom,n.gapTo,P.fromJSON(e,n.slice),n.insert,!!n.structure)}}])}(Be);function We(e,t,n){for(var r=e.resolve(t),o=n-t,i=r.depth;o>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,o--;if(o>0)for(var s=r.node(i).maybeChild(r.indexAfter(i));o>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,o--}return!1}function Ke(e,t,n){for(var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:n.contentMatch,o=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],i=e.doc.nodeAt(t),s=[],a=t+1,u=0;u<i.childCount;u++){var c=i.child(u),l=a+c.nodeSize,d=r.matchType(c.type);if(d){r=d;for(var f=0;f<c.marks.length;f++)n.allowsMarkType(c.marks[f].type)||e.step(new Fe(a,l,c.marks[f]));if(o&&c.isText&&"pre"!=n.whitespace)for(var h=void 0,p=/\r?\n|\r/g,v=void 0;h=p.exec(c.text);)v||(v=new P(C.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),s.push(new qe(a+h.index,a+h.index+h[0].length,v))}else s.push(new qe(a,l,P.empty));a=l}if(!r.validEnd){var m=r.fillBefore(C.empty,!0);e.replace(a,a,new P(m,0,0))}for(var g=s.length-1;g>=0;g--)e.step(s[g])}function _e(e,t,n){return(0==t||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function Ue(e){for(var t=e.parent.content.cutByIndex(e.startIndex,e.endIndex),n=e.depth;;--n){var r=e.$from.node(n),o=e.$from.index(n),i=e.$to.indexAfter(n);if(n<e.depth&&r.canReplace(o,i,t))return n;if(0==n||r.type.spec.isolating||!_e(r,o,i))break}return null}function Ge(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,o=function(e,t){var n=e.parent,r=e.startIndex,o=e.endIndex,i=n.contentMatchAt(r).findWrapping(t);if(!i)return null;var s=i.length?i[0]:t;return n.canReplaceWith(r,o,s)?i:null}(e,t),i=o&&function(e,t){var n=e.parent,r=e.startIndex,o=e.endIndex,i=n.child(r),s=t.contentMatch.findWrapping(i.type);if(!s)return null;for(var a=(s.length?s[s.length-1]:t).contentMatch,u=r;a&&u<o;u++)a=a.matchType(n.child(u).type);return a&&a.validEnd?s:null}(r,t);return i?o.map(Xe).concat({type:t,attrs:n}).concat(i.map(Xe)):null}function Xe(e){return{type:e,attrs:null}}function Ye(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,r=arguments.length>3?arguments[3]:void 0,o=e.resolve(t),i=o.depth-n,s=r&&r[r.length-1]||o.parent;if(i<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!s.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(var a=o.depth-1,u=n-2;a>i;a--,u--){var c=o.node(a),l=o.index(a);if(c.type.spec.isolating)return!1;var d=c.content.cutByIndex(l,c.childCount),f=r&&r[u+1];f&&(d=d.replaceChild(0,f.type.create(f.attrs)));var h=r&&r[u]||c;if(!c.canReplace(l+1,c.childCount)||!h.type.validContent(d))return!1}var p=o.indexAfter(i),v=r&&r[0];return o.node(i).canReplaceWith(p,p,v?v.type:o.node(i+1).type)}function Qe(e,t){var n=e.resolve(t),r=n.index();return Ze(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function Ze(e,t){return!(!e||!t||e.isLeaf||!e.canAppend(t))}function et(e,t){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1,r=e.resolve(t),o=r.depth;;o--){var i=void 0,s=void 0,a=r.index(o);if(o==r.depth?(i=r.nodeBefore,s=r.nodeAfter):n>0?(i=r.node(o+1),a++,s=r.node(o).maybeChild(a)):(i=r.node(o).maybeChild(a-1),s=r.node(o+1)),i&&!i.isTextblock&&Ze(i,s)&&r.node(o).canReplace(a,a+1))return t;if(0==o)break;t=n<0?r.before(o):r.after(o)}}function tt(e,t,n){var r=e.resolve(t);if(!n.content.size)return t;for(var o=n.content,i=0;i<n.openStart;i++)o=o.firstChild.content;for(var s=1;s<=(0==n.openStart&&n.size?2:1);s++)for(var a=r.depth;a>=0;a--){var u=a==r.depth?0:r.pos<=(r.start(a+1)+r.end(a+1))/2?-1:1,c=r.index(a)+(u>0?1:0),l=r.node(a),d=!1;if(1==s)d=l.canReplace(c,c,o);else{var f=l.contentMatchAt(c).findWrapping(o.firstChild.type);d=f&&l.canReplaceWith(c,c,f[0])}if(d)return 0==u?r.pos:u<0?r.before(a+1):r.after(a+1)}return null}function nt(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:P.empty;if(t==n&&!r.size)return null;var o=e.resolve(t),i=e.resolve(n);return rt(o,i,r)?new qe(t,n,r):new ot(o,i,r).fit()}function rt(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}Be.jsonID("replaceAround",Je);var ot=function(){return(0,p.A)((function e(t,n,r){(0,h.A)(this,e),this.$from=t,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=C.empty;for(var o=0;o<=t.depth;o++){var i=t.node(o);this.frontier.push({type:i.type,match:i.contentMatchAt(t.indexAfter(o))})}for(var s=t.depth;s>0;s--)this.placed=C.from(t.node(s).copy(this.placed))}),[{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,o=this.close(t<0?this.$to:r.doc.resolve(t));if(!o)return null;for(var i=this.placed,s=r.depth,a=o.depth;s&&a&&1==i.childCount;)i=i.firstChild.content,s--,a--;var u=new P(i,s,a);return t>-1?new Je(r.pos,t,this.$to.pos,this.$to.end(),u,n):u.size||r.pos!=this.$to.pos?new qe(r.pos,o.pos,u):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 o=t.firstChild;if(t.childCount>1&&(r=0),o.type.spec.isolating&&r<=n){e=n;break}t=o.content}for(var i=1;i<=2;i++)for(var s=1==i?e:this.unplaced.openStart;s>=0;s--)for(var a=null,u=(s?(a=at(this.unplaced.content,s-1).firstChild).content:this.unplaced.content).firstChild,c=this.depth;c>=0;c--){var l=this.frontier[c],d=l.type,f=l.match,h=void 0,p=null;if(1==i&&(u?f.matchType(u.type)||(p=f.fillBefore(C.from(u),!1)):a&&d.compatibleContent(a.type)))return{sliceDepth:s,frontierDepth:c,parent:a,inject:p};if(2==i&&u&&(h=f.findWrapping(u.type)))return{sliceDepth:s,frontierDepth:c,parent:a,wrap:h};if(a&&f.matchType(a.type))break}}},{key:"openMore",value:function(){var e=this.unplaced,t=e.content,n=e.openStart,r=e.openEnd,o=at(t,n);return!(!o.childCount||o.firstChild.isLeaf||(this.unplaced=new P(t,n+1,Math.max(r,o.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,o=at(t,n);if(o.childCount<=1&&n>0){var i=t.size-n<=n+o.size;this.unplaced=new P(it(t,n-1,1),n-1,i?n-1:r)}else this.unplaced=new P(it(t,n,1),n,r)}},{key:"placeNodes",value:function(e){for(var t=e.sliceDepth,n=e.frontierDepth,r=e.parent,o=e.inject,i=e.wrap;this.depth>n;)this.closeFrontierNode();if(i)for(var s=0;s<i.length;s++)this.openFrontierNode(i[s]);var a=this.unplaced,u=r?r.content:a.content,c=a.openStart-t,l=0,d=[],f=this.frontier[n],h=f.match,p=f.type;if(o){for(var v=0;v<o.childCount;v++)d.push(o.child(v));h=h.matchFragment(o)}for(var m=u.size+t-(a.content.size-a.openEnd);l<u.childCount;){var g=u.child(l),y=h.matchType(g.type);if(!y)break;(++l>1||0==c||g.content.size)&&(h=y,d.push(ut(g.mark(p.allowedMarks(g.marks)),1==l?c:0,l==u.childCount?m:-1)))}var k=l==u.childCount;k||(m=-1),this.placed=st(this.placed,n,C.from(d)),this.frontier[n].match=h,k&&m<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(var b=0,w=u;b<m;b++){var x=w.lastChild;this.frontier.push({type:x.type,match:x.contentMatchAt(x.childCount)}),w=x.content}this.unplaced=k?0==t?P.empty:new P(it(a.content,t-1,1),t-1,m<0?a.openEnd:t-1):new P(it(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||!ct(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,o=n.type,i=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),s=ct(e,t,o,r,i);if(s){for(var a=t-1;a>=0;a--){var u=this.frontier[a],c=u.match,l=ct(e,a,u.type,c,!0);if(!l||l.childCount)continue e}return{depth:t,fit:s,move:i?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=st(this.placed,t.depth,t.fit)),e=t.move;for(var n=t.depth+1;n<=e.depth;n++){var r=e.node(n),o=r.type.contentMatch.fillBefore(r.content,!0,e.index(n));this.openFrontierNode(r.type,r.attrs,o)}return e}},{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=st(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=st(this.placed,this.frontier.length,e))}}])}();function it(e,t,n){return 0==t?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(it(e.firstChild.content,t-1,n)))}function st(e,t,n){return 0==t?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(st(e.lastChild.content,t-1,n)))}function at(e,t){for(var n=0;n<t;n++)e=e.firstChild.content;return e}function ut(e,t,n){if(t<=0)return e;var r=e.content;return t>1&&(r=r.replaceChild(0,ut(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 ct(e,t,n,r,o){var i=e.node(t),s=o?e.indexAfter(t):e.index(t);if(s==i.childCount&&!n.compatibleContent(i.type))return null;var a=r.fillBefore(i.content,!0,s);return a&&!function(e,t,n){for(var r=n;r<t.childCount;r++)if(!e.allowsMarks(t.child(r).marks))return!0;return!1}(n,i.content,s)?a:null}function lt(e,t,n,r,o){if(t<n){var i=e.firstChild;e=e.replaceChild(0,i.copy(lt(i.content,t+1,n,r,i)))}if(t>r){var s=o.contentMatchAt(0),a=s.fillBefore(e).append(e);e=a.append(s.matchFragment(a).fillBefore(C.empty,!0))}return e}function dt(e,t){for(var n=[],r=Math.min(e.depth,t.depth);r>=0;r--){var o=e.start(r);if(o<e.pos-(e.depth-r)||t.end(r)>t.pos+(t.depth-r)||e.node(r).type.spec.isolating||t.node(r).type.spec.isolating)break;(o==t.start(r)||r==e.depth&&r==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&r&&t.start(r-1)==o-1)&&n.push(r)}return n}var ft=function(e){function t(e,n,r){var o;return(0,h.A)(this,t),(o=w(this,t)).pos=e,o.attr=n,o.value=r,o}return(0,l.A)(t,e),(0,p.A)(t,[{key:"apply",value:function(e){var t=e.nodeAt(this.pos);if(!t)return Le.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 o=t.type.create(n,null,t.marks);return Le.fromReplace(e,this.pos,this.pos+1,new P(C.from(o),0,t.isLeaf?0:1))}},{key:"getMap",value:function(){return Ie.empty}},{key:"invert",value:function(e){return new t(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}},{key:"map",value:function(e){var n=e.mapResult(this.pos,1);return n.deletedAfter?null:new t(n.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,n){if("number"!=typeof n.pos||"string"!=typeof n.attr)throw new RangeError("Invalid input for AttrStep.fromJSON");return new t(n.pos,n.attr,n.value)}}])}(Be);Be.jsonID("attr",ft);var ht=function(e){function t(e,n){var r;return(0,h.A)(this,t),(r=w(this,t)).attr=e,r.value=n,r}return(0,l.A)(t,e),(0,p.A)(t,[{key:"apply",value:function(e){var t=Object.create(null);for(var n in e.attrs)t[n]=e.attrs[n];t[this.attr]=this.value;var r=e.type.create(t,e.content,e.marks);return Le.ok(r)}},{key:"getMap",value:function(){return Ie.empty}},{key:"invert",value:function(e){return new t(this.attr,e.attrs[this.attr])}},{key:"map",value:function(e){return this}},{key:"toJSON",value:function(){return{stepType:"docAttr",attr:this.attr,value:this.value}}}],[{key:"fromJSON",value:function(e,n){if("string"!=typeof n.attr)throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new t(n.attr,n.value)}}])}(Be);Be.jsonID("docAttr",ht);var pt=Error;((pt=function e(t){var n=Error.call(this,t);return n.__proto__=e.prototype,n}).prototype=Object.create(Error.prototype)).constructor=pt,pt.prototype.name="TransformError";var vt=function(){return(0,p.A)((function e(t){(0,h.A)(this,e),this.doc=t,this.steps=[],this.docs=[],this.mapping=new Re}),[{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 pt(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]:P.empty,r=nt(this.doc,e,t,n);return r&&this.step(r),this}},{key:"replaceWith",value:function(e,t,n){return this.replace(e,t,new P(C.from(n),0,0))}},{key:"delete",value:function(e,t){return this.replace(e,t,P.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 o=e.doc.resolve(t),i=e.doc.resolve(n);if(rt(o,i,r))return e.step(new qe(t,n,r));var s=dt(o,e.doc.resolve(n));0==s[s.length-1]&&s.pop();var a=-(o.depth+1);s.unshift(a);for(var u=o.depth,c=o.pos-1;u>0;u--,c--){var l=o.node(u).type.spec;if(l.defining||l.definingAsContext||l.isolating)break;s.indexOf(u)>-1?a=u:o.before(u)==c&&s.splice(1,0,-u)}for(var d,f=s.indexOf(a),h=[],p=r.openStart,v=r.content,m=0;;m++){var g=v.firstChild;if(h.push(g),m==r.openStart)break;v=g.content}for(var y=p-1;y>=0;y--){var k=h[y],b=(d=k.type).spec.defining||d.spec.definingForContent;if(b&&!k.sameMarkup(o.node(Math.abs(a)-1)))p=y;else if(b||!k.type.isTextblock)break}for(var w=r.openStart;w>=0;w--){var x=(w+p+1)%(r.openStart+1),M=h[x];if(M)for(var S=0;S<s.length;S++){var A=s[(S+f)%s.length],C=!0;A<0&&(C=!1,A=-A);var O=o.node(A-1),T=o.index(A-1);if(O.canReplaceWith(T,T,M.type,M.marks))return e.replace(o.before(A),C?i.after(A):n,new P(lt(r.content,0,r.openStart,x),x,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 D=s[E];D<0||(t=o.before(D),n=i.after(D))}}(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 o=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 o=r.depth-1;o>=0;o--){var i=r.index(o);if(r.node(o).canReplaceWith(i,i,n))return r.before(o+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(var s=r.depth-1;s>=0;s--){var a=r.indexAfter(s);if(r.node(s).canReplaceWith(a,a,n))return r.after(s+1);if(a<r.node(s).childCount)return null}return null}(e.doc,t,r.type);null!=o&&(t=n=o)}e.replaceRange(t,n,new P(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),o=e.doc.resolve(n),i=dt(r,o),s=0;s<i.length;s++){var a=i[s],u=s==i.length-1;if(u&&0==a||r.node(a).type.contentMatch.validEnd)return e.delete(r.start(a),o.end(a));if(a>0&&(u||r.node(a-1).canReplace(r.index(a-1),o.indexAfter(a-1))))return e.delete(r.before(a),o.after(a))}for(var c=1;c<=r.depth&&c<=o.depth;c++)if(t-r.start(c)==r.depth-c&&n>r.end(c)&&o.end(c)-n!=o.depth-c)return e.delete(r.before(c),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,o=t.$to,i=t.depth,s=r.before(i+1),a=o.after(i+1),u=s,c=a,l=C.empty,d=0,f=i,h=!1;f>n;f--)h||r.index(f)>0?(h=!0,l=C.from(r.node(f).copy(l)),d++):u--;for(var p=C.empty,v=0,m=i,g=!1;m>n;m--)g||o.after(m+1)<o.end(m)?(g=!0,p=C.from(o.node(m).copy(p)),v++):c++;e.step(new Je(u,c,s,a,new P(l.append(p),d,v),l.size-d,!0))}(this,e,t),this}},{key:"join",value:function(e){return function(e,t,n){var r=new qe(t-n,t+n,P.empty,!0);e.step(r)}(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:1),this}},{key:"wrap",value:function(e,t){return function(e,t,n){for(var r=C.empty,o=n.length-1;o>=0;o--){if(r.size){var i=n[o].type.contentMatch.matchFragment(r);if(!i||!i.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=C.from(n[o].type.create(n[o].attrs,r))}var s=t.start,a=t.end;e.step(new Je(s,a,s,a,new P(r,0,0),n.length,!0))}(this,e,t),this}},{key:"setBlockType",value:function(e){return function(e,t,n,r,o){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");var i=e.steps.length;e.doc.nodesBetween(t,n,(function(t,n){if(t.isTextblock&&!t.hasMarkup(r,o)&&function(e,t,n){var r=e.resolve(t),o=r.index();return r.parent.canReplaceWith(o,o+1,n)}(e.doc,e.mapping.slice(i).map(n),r)){var s=null;if(r.schema.linebreakReplacement){var a="pre"==r.whitespace,u=!!r.contentMatch.matchType(r.schema.linebreakReplacement);a&&!u?s=!1:!a&&u&&(s=!0)}!1===s&&function(e,t,n,r){t.forEach((function(o,i){if(o.type==o.type.schema.linebreakReplacement){var s=e.mapping.slice(r).map(n+1+i);e.replaceWith(s,s+1,t.type.schema.text("\n"))}}))}(e,t,n,i),Ke(e,e.mapping.slice(i).map(n,1),r,void 0,null===s);var c=e.mapping.slice(i),l=c.map(n,1),d=c.map(n+t.nodeSize,1);return e.step(new Je(l,d,l+1,d-1,new P(C.from(r.create(o,null,t.marks)),0,0),1,!0)),!0===s&&function(e,t,n,r){t.forEach((function(o,i){if(o.isText)for(var s,a=/\r?\n|\r/g;s=a.exec(o.text);){var u=e.mapping.slice(r).map(n+1+i+s.index);e.replaceWith(u,u+1,t.type.schema.linebreakReplacement.create())}}))}(e,t,n,i),!1}}))}(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:e,arguments.length>2?arguments[2]:void 0,arguments.length>3&&void 0!==arguments[3]?arguments[3]:null),this}},{key:"setNodeMarkup",value:function(e,t){return function(e,t,n,r,o){var i=e.doc.nodeAt(t);if(!i)throw new RangeError("No node at given position");n||(n=i.type);var s=n.create(r,null,o||i.marks);if(i.isLeaf)return e.replaceWith(t,t+i.nodeSize,s);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);e.step(new Je(t,t+i.nodeSize,t+1,t+i.nodeSize-1,new P(C.from(s),0,0),1,!0))}(this,e,t,arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,arguments.length>3?arguments[3]:void 0),this}},{key:"setNodeAttribute",value:function(e,t,n){return this.step(new ft(e,t,n)),this}},{key:"setDocAttribute",value:function(e,t){return this.step(new ht(e,t)),this}},{key:"addNodeMark",value:function(e,t){return this.step(new je(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 He(e,t)),this}},{key:"split",value:function(e){return function(e,t){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,r=arguments.length>3?arguments[3]:void 0,o=e.doc.resolve(t),i=C.empty,s=C.empty,a=o.depth,u=o.depth-n,c=n-1;a>u;a--,c--){i=C.from(o.node(a).copy(i));var l=r&&r[c];s=C.from(l?l.type.create(l.attrs,s):o.node(a).copy(s))}e.step(new qe(t,t,new P(i.append(s),n,n),!0))}(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,arguments.length>2?arguments[2]:void 0),this}},{key:"addMark",value:function(e,t,n){return function(e,t,n,r){var o,i,s=[],a=[];e.doc.nodesBetween(t,n,(function(e,u,c){if(e.isInline){var l=e.marks;if(!r.isInSet(l)&&c.type.allowsMarkType(r.type)){for(var d=Math.max(u,t),f=Math.min(u+e.nodeSize,n),h=r.addToSet(l),p=0;p<l.length;p++)l[p].isInSet(h)||(o&&o.to==d&&o.mark.eq(l[p])?o.to=f:s.push(o=new Fe(d,f,l[p])));i&&i.to==d?i.to=f:a.push(i=new Ve(d,f,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 o=[],i=0;e.doc.nodesBetween(t,n,(function(e,s){if(e.isInline){i++;var a=null;if(r instanceof pe)for(var u,c=e.marks;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c);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 f=a[d],h=void 0,p=0;p<o.length;p++){var v=o[p];v.step==i-1&&f.eq(o[p].style)&&(h=v)}h?(h.to=l,h.step=i):o.push({style:f,from:Math.max(s,t),to:l,step:i})}}})),o.forEach((function(t){return e.step(new Fe(t.from,t.to,t.style))}))}(this,e,t,n),this}},{key:"clearIncompatible",value:function(e,t,n){return Ke(this,e,t,n),this}}])}(),mt=Object.create(null),gt=function(){return(0,p.A)((function e(t,n,r){(0,h.A)(this,e),this.$anchor=t,this.$head=n,this.ranges=r||[new yt(t.min(n),t.max(n))]}),[{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]:P.empty,n=t.content.lastChild,r=null,o=0;o<t.openEnd;o++)r=n,n=n.lastChild;for(var i=e.steps.length,s=this.ranges,a=0;a<s.length;a++){var u=s[a],c=u.$from,l=u.$to,d=e.mapping.slice(i);e.replaceRange(d.map(c.pos),d.map(l.pos),a?P.empty:t),0==a&&Tt(e,i,(n?n.isInline:r&&r.isTextblock)?-1:1)}}},{key:"replaceWith",value:function(e,t){for(var n=e.steps.length,r=this.ranges,o=0;o<r.length;o++){var i=r[o],s=i.$from,a=i.$to,u=e.mapping.slice(n),c=u.map(s.pos),l=u.map(a.pos);o?e.deleteRange(c,l):(e.replaceRangeWith(c,l,t),Tt(e,n,t.isInline?-1:1))}}},{key:"getBookmark",value:function(){return wt.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 wt(e):Ot(e.node(0),e.parent,e.pos,e.index(),t,n);if(r)return r;for(var o=e.depth-1;o>=0;o--){var i=t<0?Ot(e.node(0),e.node(o),e.before(o+1),e.index(o),t,n):Ot(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,t,n);if(i)return i}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 At(e.node(0))}},{key:"atStart",value:function(e){return Ot(e,e,0,0,1)||new At(e)}},{key:"atEnd",value:function(e){return Ot(e,e,e.content.size,e.childCount,-1)||new At(e)}},{key:"fromJSON",value:function(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");var n=mt[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 mt)throw new RangeError("Duplicate use of selection JSON ID "+e);return mt[e]=t,t.prototype.jsonID=e,t}}])}();gt.prototype.visible=!0;var yt=(0,p.A)((function e(t,n){(0,h.A)(this,e),this.$from=t,this.$to=n})),kt=!1;function bt(e){kt||e.parent.inlineContent||(kt=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}var wt=function(e){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e;return(0,h.A)(this,t),bt(e),bt(n),w(this,t,[e,n])}return(0,l.A)(t,e),(0,p.A)(t,[{key:"$cursor",get:function(){return this.$anchor.pos==this.$head.pos?this.$head:null}},{key:"map",value:function(e,n){var r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return gt.near(r);var o=e.resolve(n.map(this.anchor));return new t(o.parent.inlineContent?o:r,r)}},{key:"replace",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:P.empty;if(u((0,a.A)(t.prototype),"replace",this).call(this,e,n),n==P.empty){var r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}},{key:"eq",value:function(e){return e instanceof t&&e.anchor==this.anchor&&e.head==this.head}},{key:"getBookmark",value:function(){return new xt(this.anchor,this.head)}},{key:"toJSON",value:function(){return{type:"text",anchor:this.anchor,head:this.head}}}],[{key:"fromJSON",value:function(e,n){if("number"!=typeof n.anchor||"number"!=typeof n.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new t(e.resolve(n.anchor),e.resolve(n.head))}},{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,n,r){var o=e.pos-n.pos;if(r&&!o||(r=o>=0?1:-1),!n.parent.inlineContent){var i=gt.findFrom(n,r,!0)||gt.findFrom(n,-r,!0);if(!i)return gt.near(n,r);n=i.$head}return e.parent.inlineContent||(0==o||(e=(gt.findFrom(e,-r,!0)||gt.findFrom(e,r,!0)).$anchor).pos<n.pos!=o<0)&&(e=n),new t(e,n)}}])}(gt);gt.jsonID("text",wt);var xt=function(){function e(t,n){(0,h.A)(this,e),this.anchor=t,this.head=n}return(0,p.A)(e,[{key:"map",value:function(t){return new e(t.map(this.anchor),t.map(this.head))}},{key:"resolve",value:function(e){return wt.between(e.resolve(this.anchor),e.resolve(this.head))}}])}(),Mt=function(e){function t(e){var n;(0,h.A)(this,t);var r=e.nodeAfter,o=e.node(0).resolve(e.pos+r.nodeSize);return(n=w(this,t,[e,o])).node=r,n}return(0,l.A)(t,e),(0,p.A)(t,[{key:"map",value:function(e,n){var r=n.mapResult(this.anchor),o=r.deleted,i=r.pos,s=e.resolve(i);return o?gt.near(s):new t(s)}},{key:"content",value:function(){return new P(C.from(this.node),0,0)}},{key:"eq",value:function(e){return e instanceof t&&e.anchor==this.anchor}},{key:"toJSON",value:function(){return{type:"node",anchor:this.anchor}}},{key:"getBookmark",value:function(){return new St(this.anchor)}}],[{key:"fromJSON",value:function(e,n){if("number"!=typeof n.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new t(e.resolve(n.anchor))}},{key:"create",value:function(e,n){return new t(e.resolve(n))}},{key:"isSelectable",value:function(e){return!e.isText&&!1!==e.type.spec.selectable}}])}(gt);Mt.prototype.visible=!1,gt.jsonID("node",Mt);var St=function(){function e(t){(0,h.A)(this,e),this.anchor=t}return(0,p.A)(e,[{key:"map",value:function(t){var n=t.mapResult(this.anchor),r=n.deleted,o=n.pos;return r?new xt(o,o):new e(o)}},{key:"resolve",value:function(e){var t=e.resolve(this.anchor),n=t.nodeAfter;return n&&Mt.isSelectable(n)?new Mt(t):gt.near(t)}}])}(),At=function(e){function t(e){return(0,h.A)(this,t),w(this,t,[e.resolve(0),e.resolve(e.content.size)])}return(0,l.A)(t,e),(0,p.A)(t,[{key:"replace",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:P.empty;if(n==P.empty){e.delete(0,e.doc.content.size);var r=gt.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else u((0,a.A)(t.prototype),"replace",this).call(this,e,n)}},{key:"toJSON",value:function(){return{type:"all"}}},{key:"map",value:function(e){return new t(e)}},{key:"eq",value:function(e){return e instanceof t}},{key:"getBookmark",value:function(){return Ct}}],[{key:"fromJSON",value:function(e){return new t(e)}}])}(gt);gt.jsonID("all",At);var Ct={map:function(){return this},resolve:function(e){return new At(e)}};function Ot(e,t,n,r,o){var i=arguments.length>5&&void 0!==arguments[5]&&arguments[5];if(t.inlineContent)return wt.create(e,n);for(var s=r-(o>0?0:1);o>0?s<t.childCount:s>=0;s+=o){var a=t.child(s);if(a.isAtom){if(!i&&Mt.isSelectable(a))return Mt.create(e,n-(o<0?a.nodeSize:0))}else{var u=Ot(e,a,n+o,o<0?a.childCount:0,o,i);if(u)return u}n+=a.nodeSize*o}return null}function Tt(e,t,n){var r=e.steps.length-1;if(!(r<t)){var o,i=e.steps[r];(i instanceof qe||i instanceof Je)&&(e.mapping.maps[r].forEach((function(e,t,n,r){null==o&&(o=r)})),e.setSelection(gt.near(e.doc.resolve(o),n)))}}var Nt=function(e){function t(e){var n;return(0,h.A)(this,t),(n=w(this,t,[e.doc])).curSelectionFor=0,n.updated=0,n.meta=Object.create(null),n.time=Date.now(),n.curSelection=e.selection,n.storedMarks=e.storedMarks,n}return(0,l.A)(t,e),(0,p.A)(t,[{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&this.updated|1,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,n){u((0,a.A)(t.prototype),"addStep",this).call(this,e,n),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 o=this.storedMarks;if(!o){var i=this.doc.resolve(t);o=n==t?i.marks():i.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,o)),this.selection.empty||this.setSelection(gt.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}}])}(vt);function Et(e,t){return t&&e?e.bind(t):e}var Dt=(0,p.A)((function e(t,n,r){(0,h.A)(this,e),this.name=t,this.init=Et(n.init,r),this.apply=Et(n.apply,r)})),Pt=[new Dt("doc",{init:function(e){return e.doc||e.schema.topNodeType.createAndFill()},apply:function(e){return e.doc}}),new Dt("selection",{init:function(e,t){return e.selection||gt.atStart(t.doc)},apply:function(e){return e.selection}}),new Dt("storedMarks",{init:function(e){return e.storedMarks||null},apply:function(e,t,n,r){return r.selection.$cursor?e.storedMarks:null}}),new Dt("scrollToSelection",{init:function(){return 0},apply:function(e,t){return e.scrolledIntoView?t+1:t}})],It=(0,p.A)((function e(t,n){var r=this;(0,h.A)(this,e),this.schema=t,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Pt.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 Dt(e.key,e.spec.state,e))}))})),Rt=function(){function e(t){(0,h.A)(this,e),this.config=t}return(0,p.A)(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 o=!1,i=0;i<this.config.plugins.length;i++){var s=this.config.plugins[i];if(s.spec.appendTransaction){var a=r?r[i].n:0,u=r?r[i].state:this,c=a<t.length&&s.spec.appendTransaction.call(s,a?t.slice(a):t,u,n);if(c&&n.filterTransaction(c,i)){if(c.setMeta("appendedTransaction",e),!r){r=[];for(var l=0;l<this.config.plugins.length;l++)r.push(l<i?{state:n,n:t.length}:{state:this,n:0})}t.push(c),n=n.applyInner(c),o=!0}r&&(r[i]={state:n,n:t.length})}}if(!o)return{state:n,transactions:t}}}},{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,o=0;o<r.length;o++){var i=r[o];n[i.name]=i.apply(t,this[i.name],this,n)}return n}},{key:"tr",get:function(){return new Nt(this)}},{key:"reconfigure",value:function(t){for(var n=new It(this.schema,t.plugins),r=n.fields,o=new e(n),i=0;i<r.length;i++){var s=r[i].name;o[s]=this.hasOwnProperty(s)?this[s]:r[i].init(t,o)}return o}},{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,f.A)(e))for(var n in e){if("doc"==n||"selection"==n)throw new RangeError("The JSON fields `doc` and `selection` are reserved");var r=e[n],o=r.spec.state;o&&o.toJSON&&(t[n]=o.toJSON.call(r,this[r.key]))}return t}}],[{key:"create",value:function(t){for(var n=new It(t.doc?t.doc.type.schema:t.schema,t.plugins),r=new e(n),o=0;o<n.fields.length;o++)r[n.fields[o].name]=n.fields[o].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 o=new It(t.schema,t.plugins),i=new e(o);return o.fields.forEach((function(e){if("doc"==e.name)i.doc=X.fromJSON(t.schema,n.doc);else if("selection"==e.name)i.selection=gt.fromJSON(i.doc,n.selection);else if("storedMarks"==e.name)n.storedMarks&&(i.storedMarks=n.storedMarks.map(t.schema.markFromJSON));else{if(r)for(var o in r){var s=r[o],a=s.spec.state;if(s.key==e.name&&a&&a.fromJSON&&Object.prototype.hasOwnProperty.call(n,o))return void(i[e.name]=a.fromJSON.call(s,t,n[o],i))}i[e.name]=e.init(t,i)}})),i}}])}();function zt(e,t,n){for(var r in e){var o=e[r];o instanceof Function?o=o.bind(t):"handleDOMEvents"==r&&(o=zt(o,t,{})),n[r]=o}return n}var Bt=function(){return(0,p.A)((function e(t){(0,h.A)(this,e),this.spec=t,this.props={},t.props&&zt(t.props,this,this.props),this.key=t.key?t.key.key:$t("plugin")}),[{key:"getState",value:function(e){return e[this.key]}}])}(),Lt=Object.create(null);function $t(e){return e in Lt?e+"$"+ ++Lt[e]:(Lt[e]=0,e+"$")}var Vt=function(){return(0,p.A)((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"key";(0,h.A)(this,e),this.key=$t(t)}),[{key:"get",value:function(e){return e.config.pluginsByKey[this.key]}},{key:"getState",value:function(e){return e[this.key]}}])}(),Ft=function(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t},jt=function(e){var t=e.assignedSlot||e.parentNode;return t&&11==t.nodeType?t.host:t},Ht=null,qt=function(e,t,n){var r=Ht||(Ht=document.createRange());return r.setEnd(e,null==n?e.nodeValue.length:n),r.setStart(e,t||0),r},Jt=function(e,t,n,r){return n&&(Kt(e,t,n,r,-1)||Kt(e,t,n,r,1))},Wt=/^(img|br|input|textarea|hr)$/i;function Kt(e,t,n,r,o){for(;;){if(e==n&&t==r)return!0;if(t==(o<0?0:_t(e))){var i=e.parentNode;if(!i||1!=i.nodeType||Ut(e)||Wt.test(e.nodeName)||"false"==e.contentEditable)return!1;t=Ft(e)+(o<0?0:1),e=i}else{if(1!=e.nodeType)return!1;if("false"==(e=e.childNodes[t+(o<0?-1:0)]).contentEditable)return!1;t=o<0?_t(e):0}}}function _t(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function Ut(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 Gt=function(e){return e.focusNode&&Jt(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function Xt(e,t){var n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}var Yt="undefined"!=typeof navigator?navigator:null,Qt="undefined"!=typeof document?document:null,Zt=Yt&&Yt.userAgent||"",en=/Edge\/(\d+)/.exec(Zt),tn=/MSIE \d/.exec(Zt),nn=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Zt),rn=!!(tn||nn||en),on=tn?document.documentMode:nn?+nn[1]:en?+en[1]:0,sn=!rn&&/gecko\/(\d+)/i.test(Zt);sn&&(/Firefox\/(\d+)/.exec(Zt)||[0,0])[1];var an=!rn&&/Chrome\/(\d+)/.exec(Zt),un=!!an,cn=an?+an[1]:0,ln=!rn&&!!Yt&&/Apple Computer/.test(Yt.vendor),dn=ln&&(/Mobile\/\w+/.test(Zt)||!!Yt&&Yt.maxTouchPoints>2),fn=dn||!!Yt&&/Mac/.test(Yt.platform),hn=!!Yt&&/Win/.test(Yt.platform),pn=/Android \d/.test(Zt),vn=!!Qt&&"webkitFontSmoothing"in Qt.documentElement.style,mn=vn?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function gn(e){var t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function yn(e,t){return"number"==typeof e?e:e[t]}function kn(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 bn(e,t,n){for(var r=e.someProp("scrollThreshold")||0,o=e.someProp("scrollMargin")||5,i=e.dom.ownerDocument,s=n||e.dom;s;s=jt(s))if(1==s.nodeType){var a=s,u=a==i.body,c=u?gn(i):kn(a),l=0,d=0;if(t.top<c.top+yn(r,"top")?d=-(c.top-t.top+yn(o,"top")):t.bottom>c.bottom-yn(r,"bottom")&&(d=t.bottom-t.top>c.bottom-c.top?t.top+yn(o,"top")-c.top:t.bottom-c.bottom+yn(o,"bottom")),t.left<c.left+yn(r,"left")?l=-(c.left-t.left+yn(o,"left")):t.right>c.right-yn(r,"right")&&(l=t.right-c.right+yn(o,"right")),l||d)if(u)i.defaultView.scrollBy(l,d);else{var f=a.scrollLeft,h=a.scrollTop;d&&(a.scrollTop+=d),l&&(a.scrollLeft+=l);var p=a.scrollLeft-f,v=a.scrollTop-h;t={left:t.left-p,top:t.top-v,right:t.right-p,bottom:t.bottom-v}}if(u||/^(fixed|sticky)$/.test(getComputedStyle(s).position))break}}function wn(e){for(var t=[],n=e.ownerDocument,r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=jt(r));return t}function xn(e,t){for(var n=0;n<e.length;n++){var r=e[n],o=r.dom,i=r.top,s=r.left;o.scrollTop!=i+t&&(o.scrollTop=i+t),o.scrollLeft!=s&&(o.scrollLeft=s)}}var Mn=null;function Sn(e,t){for(var n,r,o,i,s=2e8,a=0,u=t.top,c=t.top,l=e.firstChild,d=0;l;l=l.nextSibling,d++){var f=void 0;if(1==l.nodeType)f=l.getClientRects();else{if(3!=l.nodeType)continue;f=qt(l).getClientRects()}for(var h=0;h<f.length;h++){var p=f[h];if(p.top<=u&&p.bottom>=c){u=Math.max(p.bottom,u),c=Math.min(p.top,c);var v=p.left>t.left?p.left-t.left:p.right<t.left?t.left-p.right:0;if(v<s){n=l,s=v,r=v&&3==n.nodeType?{left:p.right<t.left?p.right:p.left,top:t.top}:t,1==l.nodeType&&v&&(a=d+(t.left>=(p.left+p.right)/2?1:0));continue}}else p.top>t.top&&!o&&p.left<=t.left&&p.right>=t.left&&(o=l,i={left:Math.max(p.left,Math.min(p.right,t.left)),top:p.top});!n&&(t.left>=p.right&&t.top>=p.top||t.left>=p.left&&t.top>=p.bottom)&&(a=d+1)}}return!n&&o&&(n=o,r=i,s=0),n&&3==n.nodeType?function(e,t){for(var n=e.nodeValue.length,r=document.createRange(),o=0;o<n;o++){r.setEnd(e,o+1),r.setStart(e,o);var i=Nn(r,1);if(i.top!=i.bottom&&An(t,i))return{node:e,offset:o+(t.left>=(i.left+i.right)/2?1:0)}}return{node:e,offset:0}}(n,r):!n||s&&1==n.nodeType?{node:e,offset:a}:Sn(n,r)}function An(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function Cn(e,t,n){var r=e.childNodes.length;if(r&&n.top<n.bottom)for(var o=Math.max(0,Math.min(r-1,Math.floor(r*(t.top-n.top)/(n.bottom-n.top))-2)),i=o;;){var s=e.childNodes[i];if(1==s.nodeType)for(var a=s.getClientRects(),u=0;u<a.length;u++){var c=a[u];if(An(t,c))return Cn(s,t,c)}if((i=(i+1)%r)==o)break}return e}function On(e,t){var n,r=e.dom.ownerDocument,o=0,i=function(e,t,n){if(e.caretPositionFromPoint)try{var r=e.caretPositionFromPoint(t,n);if(r)return{node:r.offsetNode,offset:r.offset}}catch(e){}if(e.caretRangeFromPoint){var o=e.caretRangeFromPoint(t,n);if(o)return{node:o.startContainer,offset:o.startOffset}}}(r,t.left,t.top);i&&(n=i.node,o=i.offset);var s,a=(e.root.elementFromPoint?e.root:r).elementFromPoint(t.left,t.top);if(!a||!e.dom.contains(1!=a.nodeType?a.parentNode:a)){var u=e.dom.getBoundingClientRect();if(!An(t,u))return null;if(!(a=Cn(e.dom,t,u)))return null}if(ln)for(var c=a;n&&c;c=jt(c))c.draggable&&(n=void 0);if(a=function(e,t){var n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}(a,t),n){if(sn&&1==n.nodeType&&(o=Math.min(o,n.childNodes.length))<n.childNodes.length){var l,d=n.childNodes[o];"IMG"==d.nodeName&&(l=d.getBoundingClientRect()).right<=t.left&&l.bottom>t.top&&o++}var f;vn&&o&&1==n.nodeType&&1==(f=n.childNodes[o-1]).nodeType&&"false"==f.contentEditable&&f.getBoundingClientRect().top>=t.top&&o--,n==e.dom&&o==n.childNodes.length-1&&1==n.lastChild.nodeType&&t.top>n.lastChild.getBoundingClientRect().bottom?s=e.state.doc.content.size:0!=o&&1==n.nodeType&&"BR"==n.childNodes[o-1].nodeName||(s=function(e,t,n,r){for(var o=-1,i=t,s=!1;i!=e.dom;){var a=e.docView.nearestDesc(i,!0);if(!a)return null;if(1==a.dom.nodeType&&(a.node.isBlock&&a.parent||!a.contentDOM)){var u=a.dom.getBoundingClientRect();if(a.node.isBlock&&a.parent&&(!s&&u.left>r.left||u.top>r.top?o=a.posBefore:(!s&&u.right<r.left||u.bottom<r.top)&&(o=a.posAfter),s=!0),!a.contentDOM&&o<0&&!a.node.isText)return(a.node.isBlock?r.top<(u.top+u.bottom)/2:r.left<(u.left+u.right)/2)?a.posBefore:a.posAfter}i=a.dom.parentNode}return o>-1?o:e.docView.posFromDOM(t,n,-1)}(e,n,o,t))}null==s&&(s=function(e,t,n){var r=Sn(t,n),o=r.node,i=r.offset,s=-1;if(1==o.nodeType&&!o.firstChild){var a=o.getBoundingClientRect();s=a.left!=a.right&&n.left>(a.left+a.right)/2?1:-1}return e.docView.posFromDOM(o,i,s)}(e,a,t));var h=e.docView.nearestDesc(a,!0);return{pos:s,inside:h?h.posAtStart-h.border:-1}}function Tn(e){return e.top<e.bottom||e.left<e.right}function Nn(e,t){var n=e.getClientRects();if(n.length){var r=n[t<0?0:n.length-1];if(Tn(r))return r}return Array.prototype.find.call(n,Tn)||e.getBoundingClientRect()}var En=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Dn(e,t,n){var r=e.docView.domFromPos(t,n<0?-1:1),o=r.node,i=r.offset,s=r.atom,a=vn||sn;if(3==o.nodeType){if(!a||!En.test(o.nodeValue)&&(n<0?i:i!=o.nodeValue.length)){var u=i,c=i,l=n<0?1:-1;return n<0&&!i?(c++,l=-1):n>=0&&i==o.nodeValue.length?(u--,l=1):n<0?u--:c++,Pn(Nn(qt(o,u,c),l),l<0)}var d=Nn(qt(o,i,i),n);if(sn&&i&&/\s/.test(o.nodeValue[i-1])&&i<o.nodeValue.length){var f=Nn(qt(o,i-1,i-1),-1);if(f.top==d.top){var h=Nn(qt(o,i,i+1),-1);if(h.top!=d.top)return Pn(h,h.left<f.left)}}return d}if(!e.state.doc.resolve(t-(s||0)).parent.inlineContent){if(null==s&&i&&(n<0||i==_t(o))){var p=o.childNodes[i-1];if(1==p.nodeType)return In(p.getBoundingClientRect(),!1)}if(null==s&&i<_t(o)){var v=o.childNodes[i];if(1==v.nodeType)return In(v.getBoundingClientRect(),!0)}return In(o.getBoundingClientRect(),n>=0)}if(null==s&&i&&(n<0||i==_t(o))){var m=o.childNodes[i-1],g=3==m.nodeType?qt(m,_t(m)-(a?0:1)):1!=m.nodeType||"BR"==m.nodeName&&m.nextSibling?null:m;if(g)return Pn(Nn(g,1),!1)}if(null==s&&i<_t(o)){for(var y=o.childNodes[i];y.pmViewDesc&&y.pmViewDesc.ignoreForCoords;)y=y.nextSibling;var k=y?3==y.nodeType?qt(y,0,a?0:1):1==y.nodeType?y:null:null;if(k)return Pn(Nn(k,-1),!0)}return Pn(Nn(3==o.nodeType?qt(o):o,-n),n>=0)}function Pn(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 In(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 Rn(e,t,n){var r=e.state,o=e.root.activeElement;r!=t&&e.updateState(t),o!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),o!=e.dom&&o&&o.focus()}}var zn=/[\u0590-\u08ac]/,Bn=null,Ln=null,$n=!1;var Vn=function(){return(0,p.A)((function e(t,n,r,o){(0,h.A)(this,e),this.parent=t,this.children=n,this.dom=r,this.contentDOM=o,this.dirty=0,r.pmViewDesc=this}),[{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,o;if(e==this.contentDOM)r=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;r=e.previousSibling}for(;r&&(!(o=r.pmViewDesc)||o.parent!=this);)r=r.previousSibling;return r?this.posBeforeChild(o)+o.size:this.posAtStart}var i,s;if(e==this.contentDOM)i=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&(!(s=i.pmViewDesc)||s.parent!=this);)i=i.nextSibling;return i?this.posBeforeChild(s):this.posAtEnd}var a;if(e==this.dom&&this.contentDOM)a=t>Ft(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 u=e;;u=u.parentNode){if(u==this.dom){a=!1;break}if(u.previousSibling)break}if(null==a&&t==e.childNodes.length)for(var c=e;;c=c.parentNode){if(c==this.dom){a=!0;break}if(c.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 o=this.getDesc(r),i=void 0;if(o&&(!t||o.node)){if(!n||!(i=o.nodeDOM)||(1==i.nodeType?i.contains(1==e.nodeType?e:e.parentNode):i==e))return o;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 o=this.getDesc(r);if(o)return o.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],o=n+r.size;if(n==e&&o!=n){for(;!r.border&&r.children.length;)r=r.children[0];return r}if(e<o)return r.descAt(e-n-r.border);n=o}}},{key:"domFromPos",value:function(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};for(var n,r=0,o=0,i=0;r<this.children.length;r++){var s=this.children[r],a=i+s.size;if(a>e||s instanceof Kn){o=e-i;break}i=a}if(o)return this.children[r].domFromPos(o-this.children[r].border,t);for(;r&&!(n=this.children[r-1]).size&&n instanceof Fn&&n.side>=0;r--);if(t<=0){for(var u,c=!0;(u=r?this.children[r-1]:null)&&u.dom.parentNode!=this.contentDOM;r--,c=!1);return u&&t&&c&&!u.border&&!u.domAtom?u.domFromPos(u.size,t):{node:this.contentDOM,offset:u?Ft(u.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?Ft(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,o=-1,i=n,s=0;;s++){var a=this.children[s],u=i+a.size;if(-1==r&&e<=u){var c=i+a.border;if(e>=c&&t<=u-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,c);e=i;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=Ft(d.dom)+1;break}e-=d.size}-1==r&&(r=0)}if(r>-1&&(u>t||s==this.children.length-1)){t=u;for(var f=s+1;f<this.children.length;f++){var h=this.children[f];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(-1)){o=Ft(h.dom);break}t+=h.size}-1==o&&(o=this.contentDOM.childNodes.length);break}i=u}return{node:this.contentDOM,from:e,to:t,fromOffset:r,toOffset:o}}},{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],o=Math.min(e,t),i=Math.max(e,t),s=0,a=0;s<this.children.length;s++){var u=this.children[s],c=a+u.size;if(o>a&&i<c)return u.setSelection(e-a-u.border,t-a-u.border,n,r);a=c}var l=this.domFromPos(e,e?-1:1),d=t==e?l:this.domFromPos(t,t?-1:1),f=n.getSelection(),h=!1;if((sn||ln)&&e==t){var p=l,v=p.node,m=p.offset;if(3==v.nodeType){if((h=!(!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:Ft(g)+1});break}var k=y.pmViewDesc;if(k&&k.node&&k.node.isBlock)break}}else{var b=v.childNodes[m-1];h=b&&("BR"==b.nodeName||"false"==b.contentEditable)}}if(sn&&f.focusNode&&f.focusNode!=d.node&&1==f.focusNode.nodeType){var w=f.focusNode.childNodes[f.focusOffset];w&&"false"==w.contentEditable&&(r=!0)}if(r||h&&ln||!Jt(l.node,l.offset,f.anchorNode,f.anchorOffset)||!Jt(d.node,d.offset,f.focusNode,f.focusOffset)){var x=!1;if((f.extend||e==t)&&!h){f.collapse(l.node,l.offset);try{e!=t&&f.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),f.removeAllRanges(),f.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 o=this.children[r],i=n+o.size;if(n==i?e<=i&&t>=n:e<i&&t>n){var s=n+o.border,a=i-o.border;if(e>=s&&t<=a)return this.dirty=e==n||t==i?2:1,void(e!=s||t!=a||!o.contentLost&&o.dom.parentNode==this.contentDOM?o.markDirty(e-s,t-s):o.dirty=3);o.dirty=o.dom!=o.contentDOM||o.dom.parentNode!=this.contentDOM||o.children.length?3:2}n=i}this.dirty=2}},{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}},{key:"isText",value:function(e){return!1}}])}(),Fn=function(e){function t(e,n,r,o){var i;(0,h.A)(this,t);var s,a=n.type.toDOM;if("function"==typeof a&&(a=a(r,(function(){return s?s.parent?s.parent.posBeforeChild(s):void 0:o}))),!n.type.spec.raw){if(1!=a.nodeType){var u=document.createElement("span");u.appendChild(a),a=u}a.contentEditable="false",a.classList.add("ProseMirror-widget")}return(i=w(this,t,[e,[],a,null])).widget=n,i.widget=n,s=i,i}return(0,l.A)(t,e),(0,p.A)(t,[{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),u((0,a.A)(t.prototype),"destroy",this).call(this)}},{key:"domAtom",get:function(){return!0}},{key:"side",get:function(){return this.widget.type.side}}])}(Vn),jn=function(e){function t(e,n,r,o){var i;return(0,h.A)(this,t),(i=w(this,t,[e,[],n,null])).textDOM=r,i.text=o,i}return(0,l.A)(t,e),(0,p.A)(t,[{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}}])}(Vn),Hn=function(e){function t(e,n,r,o){var i;return(0,h.A)(this,t),(i=w(this,t,[e,[],r,o])).mark=n,i}return(0,l.A)(t,e),(0,p.A)(t,[{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}}},{key:"matchesMark",value:function(e){return 3!=this.dirty&&this.mark.eq(e)}},{key:"markDirty",value:function(e,n){if(u((0,a.A)(t.prototype),"markDirty",this).call(this,e,n),0!=this.dirty){for(var r=this.parent;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=0}}},{key:"slice",value:function(e,n,r){var o=t.create(this.parent,this.mark,!0,r),i=this.children,s=this.size;n<s&&(i=sr(i,n,s,r)),e>0&&(i=sr(i,0,e,r));for(var a=0;a<i.length;a++)i[a].parent=o;return o.children=i,o}}],[{key:"create",value:function(e,n,r,o){var i=o.nodeViews[n.type.name],s=i&&i(n,o,r);return s&&s.dom||(s=Oe.renderSpec(document,n.type.spec.toDOM(n,r))),new t(e,n,s.dom,s.contentDOM||s.dom)}}])}(Vn),qn=function(e){function t(e,n,r,o,i,s,a,u,c){var l;return(0,h.A)(this,t),(l=w(this,t,[e,[],i,s])).node=n,l.outerDeco=r,l.innerDeco=o,l.nodeDOM=a,l}return(0,l.A)(t,e),(0,p.A)(t,[{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)&&nr(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,o=t,i=e.composing?this.localCompositionInfo(e,t):null,s=i&&i.pos>-1?i:null,a=i&&i.pos<0,u=new or(this,s&&s.node,e);!function(e,t,n,r){var o=t.locals(e),i=0;if(0!=o.length)for(var s=0,a=[],u=null,c=0;;){for(var l=void 0,d=void 0;s<o.length&&o[s].to==i;){var f=o[s++];f.widget&&(l?(d||(d=[l])).push(f):l=f)}if(l)if(d){d.sort(ir);for(var h=0;h<d.length;h++)n(d[h],c,!!u)}else n(l,c,!!u);var p=void 0,v=void 0;if(u)v=-1,p=u,u=null;else{if(!(c<e.childCount))break;v=c,p=e.child(c++)}for(var m=0;m<a.length;m++)a[m].to<=i&&a.splice(m--,1);for(;s<o.length&&o[s].from<=i&&o[s].to>i;)a.push(o[s++]);var g=i+p.nodeSize;if(p.isText){var y=g;s<o.length&&o[s].from<y&&(y=o[s].from);for(var k=0;k<a.length;k++)a[k].to<y&&(y=a[k].to);y<g&&(u=p.cut(y-i),p=p.cut(0,y-i),g=y,v=-1)}else for(;s<o.length&&o[s].to<g;)s++;r(p,p.isInline&&!p.isLeaf?a.filter((function(e){return!e.inline})):a.slice(),t.forChild(i,p),v),i=g}else for(var b=0;b<e.childCount;b++){var w=e.child(b);r(w,o,t.forChild(i,w),b),i+=w.nodeSize}}(this.node,this.innerDeco,(function(t,i,s){t.spec.marks?u.syncToMarks(t.spec.marks,r,e):t.type.side>=0&&!s&&u.syncToMarks(i==n.node.childCount?E.none:n.node.child(i).marks,r,e),u.placeWidget(t,e,o)}),(function(t,n,s,c){var l;u.syncToMarks(t.marks,r,e),u.findNodeMatch(t,n,s,c)||a&&e.state.selection.from>o&&e.state.selection.to<o+t.nodeSize&&(l=u.findIndexWithChild(i.node))>-1&&u.updateNodeAt(t,n,s,l,e)||u.updateNextNode(t,n,s,e,c,o)||u.addNode(t,n,s,e,o),o+=t.nodeSize})),u.syncToMarks([],r,e),this.node.isTextblock&&u.addTextblockHacks(),u.destroyRest(),(u.changed||2==this.dirty)&&(s&&this.protectLocalComposition(e,s),Gn(this.contentDOM,this.children,e),dn&&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,o=n.to;if(!(e.state.selection instanceof wt)||r<t||o>t+this.node.content.size)return null;var i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){var s=i.nodeValue,a=function(e,t,n,r){for(var o=0,i=0;o<e.childCount&&i<=r;){var s=e.child(o++),a=i;if(i+=s.nodeSize,s.isText){for(var u=s.text;o<e.childCount;){var c=e.child(o++);if(i+=c.nodeSize,!c.isText)break;u+=c.text}if(i>=n){if(i>=r&&u.slice(r-t.length-a,r-a)==t)return r-t.length;var l=a<r?u.lastIndexOf(t,r-a-1):-1;if(l>=0&&l+t.length+a>=n)return a+l;if(n==r&&u.length>=r+t.length-a&&u.slice(r-a,r-a+t.length)==t)return r}}}return-1}(this.node.content,s,r-t,o-t);return a<0?null:{node:i,pos:a,text:s}}return{node:i,pos:-1,text:""}}},{key:"protectLocalComposition",value:function(e,t){var n=t.node,r=t.pos,o=t.text;if(!this.getDesc(n)){for(var i=n;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}var s=new jn(this,i,n,o);e.input.compositionNodes.push(s),this.children=sr(this.children,r,r+o.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(!nr(e,this.outerDeco)){var t=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=Zn(this.dom,this.nodeDOM,Qn(this.outerDeco,this.node,t),Qn(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,n,r,o,i,s){var a,u=i.nodeViews[n.type.name],c=u&&u(n,i,(function(){return a?a.parent?a.parent.posBeforeChild(a):void 0:s}),r,o),l=c&&c.dom,d=c&&c.contentDOM;if(n.isText)if(l){if(3!=l.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else l=document.createTextNode(n.text);else if(!l){var f=Oe.renderSpec(document,n.type.spec.toDOM(n));l=f.dom,d=f.contentDOM}d||n.isText||"BR"==l.nodeName||(l.hasAttribute("contenteditable")||(l.contentEditable="false"),n.type.spec.draggable&&(l.draggable=!0));var h=l;return l=tr(l,r,n),c?a=new Un(e,n,r,o,l,d||null,h,c,i,s+1):n.isText?new Wn(e,n,r,o,l,h,i):new t(e,n,r,o,l,d||null,h,i,s+1)}}])}(Vn);function Jn(e,t,n,r,o){tr(r,t,e);var i=new qn(void 0,e,t,n,r,r,r,o,0);return i.contentDOM&&i.updateChildren(o,0),i}var Wn=function(e){function t(e,n,r,o,i,s,a){return(0,h.A)(this,t),w(this,t,[e,n,r,o,i,null,s,a,0])}return(0,l.A)(t,e),(0,p.A)(t,[{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,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):u((0,a.A)(t.prototype),"localPosFromDOM",this).call(this,e,n,r)}},{key:"ignoreMutation",value:function(e){return"characterData"!=e.type&&"selection"!=e.type}},{key:"slice",value:function(e,n,r){var o=this.node.cut(e,n),i=document.createTextNode(o.text);return new t(this.parent,o,this.outerDeco,this.innerDeco,i,i,r)}},{key:"markDirty",value:function(e,n){u((0,a.A)(t.prototype),"markDirty",this).call(this,e,n),this.dom==this.nodeDOM||0!=e&&n!=this.nodeDOM.nodeValue.length||(this.dirty=3)}},{key:"domAtom",get:function(){return!1}},{key:"isText",value:function(e){return this.node.text==e}}])}(qn),Kn=function(e){function t(){return(0,h.A)(this,t),w(this,t,arguments)}return(0,l.A)(t,e),(0,p.A)(t,[{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}}])}(Vn),Un=function(e){function t(e,n,r,o,i,s,a,u,c,l){var d;return(0,h.A)(this,t),(d=w(this,t,[e,n,r,o,i,s,a,c,l])).spec=u,d}return(0,l.A)(t,e),(0,p.A)(t,[{key:"update",value:function(e,n,r,o){if(3==this.dirty)return!1;if(this.spec.update){var i=this.spec.update(e,n,r);return i&&this.updateInner(e,n,r,o),i}return!(!this.contentDOM&&!e.isLeaf)&&u((0,a.A)(t.prototype),"update",this).call(this,e,n,r,o)}},{key:"selectNode",value:function(){this.spec.selectNode?this.spec.selectNode():u((0,a.A)(t.prototype),"selectNode",this).call(this)}},{key:"deselectNode",value:function(){this.spec.deselectNode?this.spec.deselectNode():u((0,a.A)(t.prototype),"deselectNode",this).call(this)}},{key:"setSelection",value:function(e,n,r,o){this.spec.setSelection?this.spec.setSelection(e,n,r):u((0,a.A)(t.prototype),"setSelection",this).call(this,e,n,r,o)}},{key:"destroy",value:function(){this.spec.destroy&&this.spec.destroy(),u((0,a.A)(t.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):u((0,a.A)(t.prototype),"ignoreMutation",this).call(this,e)}}])}(qn);function Gn(e,t,n){for(var r=e.firstChild,o=!1,i=0;i<t.length;i++){var s=t[i],a=s.dom;if(a.parentNode==e){for(;a!=r;)r=rr(r),o=!0;r=r.nextSibling}else o=!0,e.insertBefore(a,r);if(s instanceof Hn){var u=r?r.previousSibling:e.lastChild;Gn(s.contentDOM,s.children,n),r=u?u.nextSibling:e.firstChild}}for(;r;)r=rr(r),o=!0;o&&n.trackWrites==e&&(n.trackWrites=null)}var Xn=function(e){e&&(this.nodeName=e)};Xn.prototype=Object.create(null);var Yn=[new Xn];function Qn(e,t,n){if(0==e.length)return Yn;for(var r=n?Yn[0]:new Xn,o=[r],i=0;i<e.length;i++){var s=e[i].type.attrs;if(s)for(var a in s.nodeName&&o.push(r=new Xn(s.nodeName)),s){var u=s[a];null!=u&&(n&&1==o.length&&o.push(r=new Xn(t.isInline?"span":"div")),"class"==a?r.class=(r.class?r.class+" ":"")+u:"style"==a?r.style=(r.style?r.style+";":"")+u:"nodeName"!=a&&(r[a]=u))}}return o}function Zn(e,t,n,r){if(n==Yn&&r==Yn)return t;for(var o=t,i=0;i<r.length;i++){var s=r[i],a=n[i];if(i){var u=void 0;a&&a.nodeName==s.nodeName&&o!=e&&(u=o.parentNode)&&u.nodeName.toLowerCase()==s.nodeName||((u=document.createElement(s.nodeName)).pmIsDeco=!0,u.appendChild(o),a=Yn[0]),o=u}er(o,a||Yn[0],s)}return o}function er(e,t,n){for(var r in t)"class"==r||"style"==r||"nodeName"==r||r in n||e.removeAttribute(r);for(var o in n)"class"!=o&&"style"!=o&&"nodeName"!=o&&n[o]!=t[o]&&e.setAttribute(o,n[o]);if(t.class!=n.class){for(var i=t.class?t.class.split(" ").filter(Boolean):[],s=n.class?n.class.split(" ").filter(Boolean):[],a=0;a<i.length;a++)-1==s.indexOf(i[a])&&e.classList.remove(i[a]);for(var u=0;u<s.length;u++)-1==i.indexOf(s[u])&&e.classList.add(s[u]);0==e.classList.length&&e.removeAttribute("class")}if(t.style!=n.style){if(t.style)for(var c,l=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;c=l.exec(t.style);)e.style.removeProperty(c[1]);n.style&&(e.style.cssText+=n.style)}}function tr(e,t,n){return Zn(e,e,Yn,Qn(t,n,1!=e.nodeType))}function nr(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 rr(e){var t=e.nextSibling;return e.parentNode.removeChild(e),t}var or=function(){return(0,p.A)((function e(t,n,r){(0,h.A)(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,o=e.childCount,i=new Map,s=[];e:for(;o>0;){for(var a=void 0;;)if(r){var u=n.children[r-1];if(!(u instanceof Hn)){a=u,r--;break}n=u,r=u.children.length}else{if(n==t)break e;r=n.parent.children.indexOf(n),n=n.parent}var c=a.node;if(c){if(c!=e.child(o-1))break;--o,i.set(a,o),s.push(a)}}return{index:o,matched:i,matches:s.reverse()}}(t.node.content,t)}),[{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,o=this.stack.length>>1,i=Math.min(o,e.length);r<i&&(r==o-1?this.top:this.stack[r+1<<1]).matchesMark(e[r])&&!1!==e[r].type.spec.spanning;)r++;for(;r<o;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<e.length;){this.stack.push(this.top,this.index+1);for(var s=-1,a=this.index;a<Math.min(this.index+3,this.top.children.length);a++){var u=this.top.children[a];if(u.matchesMark(e[o])&&!this.isLocked(u.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 c=Hn.create(this.top,e[o],t,n);this.top.children.splice(this.index,0,c),this.top=c,this.changed=!0}this.index=0,o++}}},{key:"findNodeMatch",value:function(e,t,n,r){var o,i=-1;if(r>=this.preMatch.index&&(o=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,n))i=this.top.children.indexOf(o,this.index);else for(var s=this.index,a=Math.min(this.top.children.length,s+5);s<a;s++){var u=this.top.children[s];if(u.matchesNode(e,t,n)&&!this.preMatch.matched.has(u)){i=s;break}}return!(i<0||(this.destroyBetween(this.index,i),this.index++,0))}},{key:"updateNodeAt",value:function(e,t,n,r,o){var i=this.top.children[r];return 3==i.dirty&&i.dom==i.contentDOM&&(i.dirty=2),!!i.update(e,t,n,o)&&(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,o,i){for(var s=this.index;s<this.top.children.length;s++){var a=this.top.children[s];if(a instanceof qn){var u=this.preMatch.matched.get(a);if(null!=u&&u!=o)return!1;var c=a.dom,l=void 0,d=this.isLocked(c)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&3!=a.dirty&&nr(t,a.outerDeco));if(!d&&a.update(e,t,n,r))return this.destroyBetween(this.index,s),a.dom!=c&&(this.changed=!0),this.index++,!0;if(!d&&(l=this.recreateWrapper(a,e,t,n,r,i)))return this.top.children[this.index]=l,l.contentDOM&&(l.dirty=2,l.updateChildren(r,i+1),l.dirty=0),this.changed=!0,this.index++,!0;break}}return!1}},{key:"recreateWrapper",value:function(e,t,n,r,o,i){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content))return null;var s=qn.create(this.top,t,n,r,o,i);if(s.contentDOM){s.children=e.children,e.children=[];var a,u=k(s.children);try{for(u.s();!(a=u.n()).done;)a.value.parent=s}catch(e){u.e(e)}finally{u.f()}}return e.destroy(),s}},{key:"addNode",value:function(e,t,n,r,o){var i=qn.create(this.top,e,t,n,r,o);i.contentDOM&&i.updateChildren(r,o+1),this.top.children.splice(this.index++,0,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 o=new Fn(this.top,e,t,n);this.top.children.splice(this.index++,0,o),this.changed=!0}else this.index++}},{key:"addTextblockHacks",value:function(){for(var e=this.top.children[this.index-1],t=this.top;e instanceof Hn;)e=(t=e).children[t.children.length-1];(!e||!(e instanceof Wn)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ln||un)&&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 Kn(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))}}])}();function ir(e,t){return e.type.side-t.type.side}function sr(e,t,n,r,o){for(var i=[],s=0,a=0;s<e.length;s++){var u=e[s],c=a,l=a+=u.size;c>=n||l<=t?i.push(u):(c<t&&i.push(u.slice(0,t-c,r)),o&&(i.push(o),o=void 0),l>n&&i.push(u.slice(n-c,u.size,r)))}return i}function ar(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 o=e.docView.nearestDesc(n.focusNode),i=o&&0==o.size,s=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;var a,u,c=r.resolve(s);if(Gt(n)){for(a=c;o&&!o.node;)o=o.parent;var l=o.node;if(o&&l.isAtom&&Mt.isSelectable(l)&&o.parent&&(!l.isInline||!function(e,t,n){for(var r=0==t,o=t==_t(e);r||o;){if(e==n)return!0;var i=Ft(e);if(!(e=e.parentNode))return!1;r=r&&0==i,o=o&&i==_t(e)}}(n.focusNode,n.focusOffset,o.dom))){var d=o.posBefore;u=new Mt(s==d?c:r.resolve(d))}}else{var f=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(f<0)return null;a=r.resolve(f)}return u||(u=mr(e,a,c,"pointer"==t||e.state.selection.head<c.pos&&!i?1:-1)),u}function ur(e){return e.editable?e.hasFocus():yr(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function cr(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=e.state.selection;if(pr(e,n),ur(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&un){var r=e.domSelectionRange(),o=e.domObserver.currentSelection;if(r.anchorNode&&o.anchorNode&&Jt(r.anchorNode,r.anchorOffset,o.anchorNode,o.anchorOffset))return e.input.mouseDown.delayedSelectionSync=!0,void e.domObserver.setCurSelection()}if(e.domObserver.disconnectSelection(),e.cursorWrapper)!function(e){var t=e.domSelection(),n=document.createRange(),r=e.cursorWrapper.dom,o="IMG"==r.nodeName;o?n.setEnd(r.parentNode,Ft(r)+1):n.setEnd(r,0),n.collapse(!1),t.removeAllRanges(),t.addRange(n),!o&&!e.state.selection.visible&&rn&&on<=11&&(r.disabled=!0,r.disabled=!1)}(e);else{var i,s,a=n.anchor,u=n.head;!lr||n instanceof wt||(n.$from.parent.inlineContent||(i=dr(e,n.from)),n.empty||n.$from.parent.inlineContent||(s=dr(e,n.to))),e.docView.setSelection(a,u,e.root,t),lr&&(i&&hr(i),s&&hr(s)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(e){var t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);var n=e.domSelectionRange(),r=n.anchorNode,o=n.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=function(){n.anchorNode==r&&n.anchorOffset==o||(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout((function(){ur(e)&&!e.state.selection.visible||e.dom.classList.remove("ProseMirror-hideselection")}),20))})}(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}var lr=ln||un&&cn<63;function dr(e,t){var n=e.docView.domFromPos(t,0),r=n.node,o=n.offset,i=o<r.childNodes.length?r.childNodes[o]:null,s=o?r.childNodes[o-1]:null;if(ln&&i&&"false"==i.contentEditable)return fr(i);if(!(i&&"false"!=i.contentEditable||s&&"false"!=s.contentEditable)){if(i)return fr(i);if(s)return fr(s)}}function fr(e){return e.contentEditable="true",ln&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function hr(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function pr(e,t){if(t instanceof Mt){var n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(vr(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else vr(e)}function vr(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function mr(e,t,n,r){return e.someProp("createSelectionBetween",(function(r){return r(e,t,n)}))||wt.between(t,n,r)}function gr(e){return!(e.editable&&!e.hasFocus())&&yr(e)}function yr(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 kr(e,t){var n=e.selection,r=n.$anchor,o=n.$head,i=t>0?r.max(o):r.min(o),s=i.parent.inlineContent?i.depth?e.doc.resolve(t>0?i.after():i.before()):null:i;return s&>.findFrom(s,t)}function br(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function wr(e,t,n){var r=e.state.selection;if(!(r instanceof wt)){if(r instanceof Mt&&r.node.isInline)return br(e,new wt(t>0?r.$to:r.$from));var o=kr(e.state,t);return!!o&&br(e,o)}if(n.indexOf("s")>-1){var i=r.$head,s=i.textOffset?null:t<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;var a=e.state.doc.resolve(i.pos+s.nodeSize*(t<0?-1:1));return br(e,new wt(r.$anchor,a))}if(!r.empty)return!1;if(e.endOfTextblock(t>0?"forward":"backward")){var u=kr(e.state,t);return!!(u&&u instanceof Mt)&&br(e,u)}if(!(fn&&n.indexOf("m")>-1)){var c,l=r.$head,d=l.textOffset?null:t<0?l.nodeBefore:l.nodeAfter;if(!d||d.isText)return!1;var f=t<0?l.pos-d.nodeSize:l.pos;return!!(d.isAtom||(c=e.docView.descAt(f))&&!c.contentDOM)&&(Mt.isSelectable(d)?br(e,new Mt(t<0?e.state.doc.resolve(l.pos-d.nodeSize):l)):!!vn&&br(e,new wt(e.state.doc.resolve(t<0?f:f+d.nodeSize))))}}function xr(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function Mr(e,t){var n=e.pmViewDesc;return n&&0==n.size&&(t<0||e.nextSibling||"BR"!=e.nodeName)}function Sr(e,t){return t<0?function(e){var t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(n){var o,i,s=!1;for(sn&&1==n.nodeType&&r<xr(n)&&Mr(n.childNodes[r],-1)&&(s=!0);;)if(r>0){if(1!=n.nodeType)break;var a=n.childNodes[r-1];if(Mr(a,-1))o=n,i=--r;else{if(3!=a.nodeType)break;r=(n=a).nodeValue.length}}else{if(Ar(n))break;for(var u=n.previousSibling;u&&Mr(u,-1);)o=n.parentNode,i=Ft(u),u=u.previousSibling;if(u)r=xr(n=u);else{if((n=n.parentNode)==e.dom)break;r=0}}s?Cr(e,n,r):o&&Cr(e,o,i)}}(e):function(e){var t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(n){for(var o,i,s=xr(n);;)if(r<s){if(1!=n.nodeType)break;if(!Mr(n.childNodes[r],1))break;o=n,i=++r}else{if(Ar(n))break;for(var a=n.nextSibling;a&&Mr(a,1);)o=a.parentNode,i=Ft(a)+1,a=a.nextSibling;if(a)r=0,s=xr(n=a);else{if((n=n.parentNode)==e.dom)break;r=s=0}}o&&Cr(e,o,i)}}(e)}function Ar(e){var t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function Cr(e,t,n){var r,o;3!=t.nodeType&&((o=function(e,t){for(;e&&t==e.childNodes.length&&!Ut(e);)t=Ft(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){var n=e.childNodes[t];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;e=n,t=0}}(t,n))?(t=o,n=0):(r=function(e,t){for(;e&&!t&&!Ut(e);)t=Ft(e),e=e.parentNode;for(;e&&t;){var n=e.childNodes[t-1];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;t=(e=n).childNodes.length}}(t,n))&&(t=r,n=r.nodeValue.length));var i=e.domSelection();if(Gt(i)){var s=document.createRange();s.setEnd(t,n),s.setStart(t,n),i.removeAllRanges(),i.addRange(s)}else i.extend&&i.extend(t,n);e.domObserver.setCurSelection();var a=e.state;setTimeout((function(){e.state==a&&cr(e)}),50)}function Or(e,t){var n=e.state.doc.resolve(t);if(!un&&!hn&&n.parent.inlineContent){var r=e.coordsAtPos(t);if(t>n.start()){var o=e.coordsAtPos(t-1),i=(o.top+o.bottom)/2;if(i>r.top&&i<r.bottom&&Math.abs(o.left-r.left)>1)return o.left<r.left?"ltr":"rtl"}if(t<n.end()){var s=e.coordsAtPos(t+1),a=(s.top+s.bottom)/2;if(a>r.top&&a<r.bottom&&Math.abs(s.left-r.left)>1)return s.left>r.left?"ltr":"rtl"}}return"rtl"==getComputedStyle(e.dom).direction?"rtl":"ltr"}function Tr(e,t,n){var r=e.state.selection;if(r instanceof wt&&!r.empty||n.indexOf("s")>-1)return!1;if(fn&&n.indexOf("m")>-1)return!1;var o=r.$from,i=r.$to;if(!o.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){var s=kr(e.state,t);if(s&&s instanceof Mt)return br(e,s)}if(!o.parent.inlineContent){var a=t<0?o:i,u=r instanceof At?gt.near(a,t):gt.findFrom(a,t);return!!u&&br(e,u)}return!1}function Nr(e,t){if(!(e.state.selection instanceof wt))return!0;var n=e.state.selection,r=n.$head,o=n.$anchor,i=n.empty;if(!r.sameParent(o))return!0;if(!i)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 Er(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function Dr(e,t){e.someProp("transformCopied",(function(n){t=n(t,e)}));for(var n=[],r=t,o=r.content,i=r.openStart,s=r.openEnd;i>1&&s>1&&1==o.childCount&&1==o.firstChild.childCount;){i--,s--;var a=o.firstChild;n.push(a.type.name,a.attrs!=a.type.defaultAttrs?a.attrs:null),o=a.content}var u=e.someProp("clipboardSerializer")||Oe.fromSchema(e.state.schema),c=jr(),l=c.createElement("div");l.appendChild(u.serializeFragment(o,{document:c}));for(var d,f=l.firstChild,h=0;f&&1==f.nodeType&&(d=Vr[f.nodeName.toLowerCase()]);){for(var p=d.length-1;p>=0;p--){for(var v=c.createElement(d[p]);l.firstChild;)v.appendChild(l.firstChild);l.appendChild(v),h++}f=l.firstChild}return f&&1==f.nodeType&&f.setAttribute("data-pm-slice","".concat(i," ").concat(s).concat(h?" -".concat(h):""," ").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"),slice:t}}function Pr(e,t,n,r,o){var i,s,a=o.parent.type.spec.code;if(!n&&!t)return null;var u=t&&(r||a||!n);if(u){if(e.someProp("transformPastedText",(function(n){t=n(t,a||r,e)})),a)return t?new P(C.from(e.state.schema.text(t.replace(/\r\n?/g,"\n"))),0,0):P.empty;var c=e.someProp("clipboardTextParser",(function(n){return n(t,o,r,e)}));if(c)s=c;else{var l=o.marks(),d=e.state.schema,f=Oe.fromSchema(d);i=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach((function(e){var t=i.appendChild(document.createElement("p"));e&&t.appendChild(f.serializeNode(d.text(e,l)))}))}}else e.someProp("transformPastedHTML",(function(t){n=t(n,e)})),i=function(e){var t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));var n,r=jr().createElement("div"),o=/<([a-z][^>\s]+)/i.exec(e);if((n=o&&Vr[o[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 i=0;i<n.length;i++)r=r.querySelector(n[i])||r;return r}(n),vn&&function(e){for(var t=e.querySelectorAll(un?"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)}}(i);var h=i&&i.querySelector("[data-pm-slice]"),p=h&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(h.getAttribute("data-pm-slice")||"");if(p&&p[3])for(var v=+p[3];v>0;v--){for(var m=i.firstChild;m&&1!=m.nodeType;)m=m.nextSibling;if(!m)break;i=m}if(!s){var g=e.someProp("clipboardParser")||e.someProp("domParser")||ge.fromSchema(e.state.schema);s=g.parseSlice(i,{preserveWhitespace:!(!u&&!p),context:o,ruleFromNode:function(e){return"BR"!=e.nodeName||e.nextSibling||!e.parentNode||Ir.test(e.parentNode.nodeName)?null:{ignore:!0}}})}if(p)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 o=e.content,i=e.openStart,s=e.openEnd,a=n.length-2;a>=0;a-=2){var u=r.nodes[n[a]];if(!u||u.hasRequiredAttrs())break;o=C.from(u.create(n[a+1],o)),i++,s++}return new P(o,i,s)}($r(s,+p[1],+p[2]),p[4]);else if(s=P.maxOpen(function(e,t){if(e.childCount<2)return e;for(var n,r=function(){var n,r=t.node(o).contentMatchAt(t.index(o)),i=[];if(e.forEach((function(e){if(i){var t,o=r.findWrapping(e.type);if(!o)return i=null;if(t=i.length&&n.length&&zr(o,n,e,i[i.length-1],0))i[i.length-1]=t;else{i.length&&(i[i.length-1]=Br(i[i.length-1],n.length));var s=Rr(e,o);i.push(s),r=r.matchType(s.type),n=o}}})),i)return{v:C.from(i)}},o=t.depth;o>=0;o--)if(n=r())return n.v;return e}(s.content,o),!0),s.openStart||s.openEnd){for(var y=0,k=0,b=s.content.firstChild;y<s.openStart&&!b.type.spec.isolating;y++,b=b.firstChild);for(var w=s.content.lastChild;k<s.openEnd&&!w.type.spec.isolating;k++,w=w.lastChild);s=$r(s,y,k)}return e.someProp("transformPasted",(function(t){s=t(s,e)})),s}var Ir=/^(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 Rr(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 zr(e,t,n,r,o){if(o<e.length&&o<t.length&&e[o]==t[o]){var i=zr(e,t,n,r.lastChild,o+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(o==e.length-1?n.type:e[o+1]))return r.copy(r.content.append(C.from(Rr(n,e,o+1))))}}function Br(e,t){if(0==t)return e;var n=e.content.replaceChild(e.childCount-1,Br(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(C.empty,!0);return e.copy(n.append(r))}function Lr(e,t,n,r,o,i){var s=t<0?e.firstChild:e.lastChild,a=s.content;return e.childCount>1&&(i=0),o<r-1&&(a=Lr(a,t,n,r,o+1,i)),o>=n&&(a=t<0?s.contentMatchAt(0).fillBefore(a,i<=o).append(a):a.append(s.contentMatchAt(s.childCount).fillBefore(C.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,s.copy(a))}function $r(e,t,n){return t<e.openStart&&(e=new P(Lr(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new P(Lr(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}var Vr={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]},Fr=null;function jr(){return Fr||(Fr=document.implementation.createHTMLDocument("title"))}var Hr={},qr={},Jr={touchstart:!0,touchmove:!0},Wr=(0,p.A)((function e(){(0,h.A)(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.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}));function Kr(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function _r(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 Ur(e,t)})}))}function Ur(e,t){return e.someProp("handleDOMEvents",(function(n){var r=n[t.type];return!!r&&(r(e,t)||t.defaultPrevented)}))}function Gr(e){return{left:e.clientX,top:e.clientY}}function Xr(e,t,n,r,o){if(-1==r)return!1;for(var i,s=e.state.doc.resolve(r),a=function(r){if(e.someProp(t,(function(t){return r>s.depth?t(e,n,s.nodeAfter,s.before(r),o,!0):t(e,n,s.node(r),s.before(r),o,!1)})))return{v:!0}},u=s.depth+1;u>0;u--)if(i=a(u))return i.v;return!1}function Yr(e,t,n){e.focused||e.focus();var r=e.state.tr.setSelection(t);"pointer"==n&&r.setMeta("pointer",!0),e.dispatch(r)}function Qr(e,t,n,r){return Xr(e,"handleDoubleClickOn",t,n,r)||e.someProp("handleDoubleClick",(function(n){return n(e,t,r)}))}function Zr(e,t,n,r){return Xr(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&&(Yr(e,wt.create(r,0,r.content.size),"pointer"),!0);for(var o=r.resolve(t),i=o.depth+1;i>0;i--){var s=i>o.depth?o.nodeAfter:o.node(i),a=o.before(i);if(s.inlineContent)Yr(e,wt.create(r,a+1,a+1+s.content.size),"pointer");else{if(!Mt.isSelectable(s))continue;Yr(e,Mt.create(r,a),"pointer")}return!0}}(e,n,r)}function eo(e){return ao(e)}qr.keydown=function(e,t){var n=t;if(e.input.shiftKey=16==n.keyCode||n.shiftKey,!ro(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!pn||!un||13!=n.keyCode))if(229!=n.keyCode&&e.domObserver.forceFlush(),!dn||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);if(8==n||fn&&72==n&&"c"==r)return Nr(e,-1)||Sr(e,-1);if(46==n&&!t.shiftKey||fn&&68==n&&"c"==r)return Nr(e,1)||Sr(e,1);if(13==n||27==n)return!0;if(37==n||fn&&66==n&&"c"==r){var o=37==n?"ltr"==Or(e,e.state.selection.from)?-1:1:-1;return wr(e,o,r)||Sr(e,o)}if(39==n||fn&&70==n&&"c"==r){var i=39==n?"ltr"==Or(e,e.state.selection.from)?1:-1:1;return wr(e,i,r)||Sr(e,i)}return 38==n||fn&&80==n&&"c"==r?Tr(e,-1,r)||Sr(e,-1):40==n||fn&&78==n&&"c"==r?function(e){if(!ln||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 o=n.firstChild;Er(e,o,"true"),setTimeout((function(){return Er(e,o,"false")}),20)}return!1}(e)||Tr(e,1,r)||Sr(e,1):r==(fn?"m":"c")&&(66==n||73==n||89==n||90==n)}(e,n)?n.preventDefault():Kr(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,Xt(13,"Enter"))})),e.input.lastIOSEnter=0)}),200)}},qr.keyup=function(e,t){16==t.keyCode&&(e.input.shiftKey=!1)},qr.keypress=function(e,t){var n=t;if(!(ro(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||fn&&n.metaKey))if(e.someProp("handleKeyPress",(function(t){return t(e,n)})))n.preventDefault();else{var r=e.state.selection;if(!(r instanceof wt&&r.$from.sameParent(r.$to))){var o=String.fromCharCode(n.charCode);/[\r\n]/.test(o)||e.someProp("handleTextInput",(function(t){return t(e,r.$from.pos,r.$to.pos,o)}))||e.dispatch(e.state.tr.insertText(o).scrollIntoView()),n.preventDefault()}}};var to=fn?"metaKey":"ctrlKey";Hr.mousedown=function(e,t){var n=t;e.input.shiftKey=n.shiftKey;var r=eo(e),o=Date.now(),i="singleClick";o-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[to]&&("singleClick"==e.input.lastClick.type?i="doubleClick":"doubleClick"==e.input.lastClick.type&&(i="tripleClick")),e.input.lastClick={time:o,x:n.clientX,y:n.clientY,type:i};var s=e.posAtCoords(Gr(n));s&&("singleClick"==i?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new no(e,s,n,!!r)):("doubleClick"==i?Qr:Zr)(e,s.pos,s.inside,n)?n.preventDefault():Kr(e,"pointer"))};var no=function(){return(0,p.A)((function e(t,n,r,o){var i,s,a=this;if((0,h.A)(this,e),this.view=t,this.pos=n,this.event=r,this.flushed=o,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=t.state.doc,this.selectNode=!!r[to],this.allowDefault=r.shiftKey,n.inside>-1)i=t.state.doc.nodeAt(n.inside),s=n.inside;else{var u=t.state.doc.resolve(n.pos);i=u.parent,s=u.depth?u.before():0}var c=o?null:r.target,l=c?t.docView.nearestDesc(c,!0):null;this.target=l&&1==l.dom.nodeType?l.dom:null;var d=t.state.selection;(0==r.button&&i.type.spec.draggable&&!1!==i.type.spec.selectable||d instanceof Mt&&d.from<=s&&d.to>s)&&(this.mightDrag={node:i,pos:s,addAttr:!(!this.target||this.target.draggable),setUneditable:!(!this.target||!sn||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)),Kr(t,"pointer")}),[{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 cr(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(Gr(e))),this.updateAllowDefault(e),this.allowDefault||!t?Kr(this.view,"pointer"):function(e,t,n,r,o){return Xr(e,"handleClickOn",t,n,r)||e.someProp("handleClick",(function(n){return n(e,t,r)}))||(o?function(e,t){if(-1==t)return!1;var n,r,o=e.state.selection;o instanceof Mt&&(n=o.node);for(var i=e.state.doc.resolve(t),s=i.depth+1;s>0;s--){var a=s>i.depth?i.nodeAfter:i.node(s);if(Mt.isSelectable(a)){r=n&&o.$from.depth>0&&s>=o.$from.depth&&i.before(o.$from.depth+1)==o.$from.pos?i.before(o.$from.depth):i.before(s);break}}return null!=r&&(Yr(e,Mt.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&&Mt.isSelectable(r))&&(Yr(e,new Mt(n),"pointer"),!0)}(e,n))}(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():0==e.button&&(this.flushed||ln&&this.mightDrag&&!this.mightDrag.node.isAtom||un&&!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)?(Yr(this.view,gt.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):Kr(this.view,"pointer")}}},{key:"move",value:function(e){this.updateAllowDefault(e),Kr(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)}}])}();function ro(e,t){return!!e.composing||!!(ln&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500)&&(e.input.compositionEndedAt=-2e8,!0)}Hr.touchstart=function(e){e.input.lastTouch=Date.now(),eo(e),Kr(e,"pointer")},Hr.touchmove=function(e){e.input.lastTouch=Date.now(),Kr(e,"pointer")},Hr.contextmenu=function(e){return eo(e)};var oo=pn?5e3:-1;function io(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout((function(){return ao(e)}),t))}function so(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 ao(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!(pn&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),so(e),t||e.docView&&e.docView.dirty){var n=ar(e);return n&&!n.eq(e.state.selection)?e.dispatch(e.state.tr.setSelection(n)):e.updateState(e.state),!0}return!1}}qr.compositionstart=qr.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(),ao(e,!0),e.markCursor=null;else if(ao(e),sn&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length)for(var r=e.domSelectionRange(),o=r.focusNode,i=r.focusOffset;o&&1==o.nodeType&&0!=i;){var s=i<0?o.lastChild:o.childNodes[i-1];if(!s)break;if(3==s.nodeType){e.domSelection().collapse(s,s.nodeValue.length);break}o=s,i=-1}e.input.composing=!0}io(e,oo)},qr.compositionend=function(e,t){e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.compositionPendingChanges&&Promise.resolve().then((function(){return e.domObserver.flush()})),e.input.compositionID++,io(e,20))};var uo=rn&&on<15||dn&&mn<604;function co(e,t,n,r,o){var i=Pr(e,t,n,r,e.state.selection.$from);if(e.someProp("handlePaste",(function(t){return t(e,o,i||P.empty)})))return!0;if(!i)return!1;var s=function(e){return 0==e.openStart&&0==e.openEnd&&1==e.content.childCount?e.content.firstChild:null}(i),a=s?e.state.tr.replaceSelectionWith(s,r):e.state.tr.replaceSelection(i);return e.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function lo(e){var t=e.getData("text/plain")||e.getData("Text");if(t)return t;var n=e.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}Hr.copy=qr.cut=function(e,t){var n=t,r=e.state.selection,o="cut"==n.type;if(!r.empty){var i=uo?null:n.clipboardData,s=Dr(e,r.content()),a=s.dom,u=s.text;i?(n.preventDefault(),i.clearData(),i.setData("text/html",a.innerHTML),i.setData("text/plain",u)):function(e,t){if(e.dom.parentNode){var n=e.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(t),n.style.cssText="position: fixed; left: -10000px; top: 10px";var r=getSelection(),o=document.createRange();o.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout((function(){n.parentNode&&n.parentNode.removeChild(n),e.focus()}),50)}}(e,a),o&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))}},qr.paste=function(e,t){var n=t;if(!e.composing||pn){var r=uo?null:n.clipboardData,o=e.input.shiftKey&&45!=e.input.lastKeyCode;r&&co(e,lo(r),r.getData("text/html"),o,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();var o=e.input.shiftKey&&45!=e.input.lastKeyCode;setTimeout((function(){e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?co(e,r.value,null,o,t):co(e,r.textContent,r.innerHTML,o,t)}),50)}}(e,n)}};var fo=(0,p.A)((function e(t,n,r){(0,h.A)(this,e),this.slice=t,this.move=n,this.node=r})),ho=fn?"altKey":"ctrlKey";for(var po in Hr.dragstart=function(e,t){var n=t,r=e.input.mouseDown;if(r&&r.done(),n.dataTransfer){var o,i=e.state.selection,s=i.empty?null:e.posAtCoords(Gr(n));if(s&&s.pos>=i.from&&s.pos<=(i instanceof Mt?i.to-1:i.to));else if(r&&r.mightDrag)o=Mt.create(e.state.doc,r.mightDrag.pos);else if(n.target&&1==n.target.nodeType){var a=e.docView.nearestDesc(n.target,!0);a&&a.node.type.spec.draggable&&a!=e.docView&&(o=Mt.create(e.state.doc,a.posBefore))}var u=Dr(e,(o||e.state.selection).content()),c=u.dom,l=u.text,d=u.slice;n.dataTransfer.clearData(),n.dataTransfer.setData(uo?"Text":"text/html",c.innerHTML),n.dataTransfer.effectAllowed="copyMove",uo||n.dataTransfer.setData("text/plain",l),e.dragging=new fo(d,!n[ho],o)}},Hr.dragend=function(e){var t=e.dragging;window.setTimeout((function(){e.dragging==t&&(e.dragging=null)}),50)},qr.dragover=qr.dragenter=function(e,t){return t.preventDefault()},qr.drop=function(e,t){var n=t,r=e.dragging;if(e.dragging=null,n.dataTransfer){var o=e.posAtCoords(Gr(n));if(o){var i=e.state.doc.resolve(o.pos),s=r&&r.slice;s?e.someProp("transformPasted",(function(t){s=t(s,e)})):s=Pr(e,lo(n.dataTransfer),uo?null:n.dataTransfer.getData("text/html"),!1,i);var a=!(!r||n[ho]);if(e.someProp("handleDrop",(function(t){return t(e,n,s||P.empty,a)})))n.preventDefault();else if(s){n.preventDefault();var u=s?tt(e.state.doc,i.pos,s):i.pos;null==u&&(u=i.pos);var c=e.state.tr;if(a){var l=r.node;l?l.replace(c):c.deleteSelection()}var d=c.mapping.map(u),f=0==s.openStart&&0==s.openEnd&&1==s.content.childCount,h=c.doc;if(f?c.replaceRangeWith(d,d,s.content.firstChild):c.replaceRange(d,d,s),!c.doc.eq(h)){var p=c.doc.resolve(d);if(f&&Mt.isSelectable(s.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(s.content.firstChild))c.setSelection(new Mt(p));else{var v=c.mapping.map(u);c.mapping.maps[c.mapping.maps.length-1].forEach((function(e,t,n,r){return v=r})),c.setSelection(mr(e,p,c.doc.resolve(v)))}e.focus(),e.dispatch(c.setMeta("uiEvent","drop"))}}}}},Hr.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())&&cr(e)}),20))},Hr.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)},Hr.beforeinput=function(e,t){if(un&&pn&&"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,Xt(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)}},qr)Hr[po]=qr[po];function vo(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 mo=function(){function e(t,n){(0,h.A)(this,e),this.toDOM=t,this.spec=n||wo,this.side=this.spec.side||0}return(0,p.A)(e,[{key:"map",value:function(e,t,n,r){var o=e.mapResult(t.from+r,this.side<0?-1:1),i=o.pos;return o.deleted?null:new ko(i-n,i-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&&vo(this.spec,t.spec))}},{key:"destroy",value:function(e){this.spec.destroy&&this.spec.destroy(e)}}])}(),go=function(){function e(t,n){(0,h.A)(this,e),this.attrs=t,this.spec=n||wo}return(0,p.A)(e,[{key:"map",value:function(e,t,n,r){var o=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,i=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return o>=i?null:new ko(o,i,this)}},{key:"valid",value:function(e,t){return t.from<t.to}},{key:"eq",value:function(t){return this==t||t instanceof e&&vo(this.attrs,t.attrs)&&vo(this.spec,t.spec)}},{key:"destroy",value:function(){}}],[{key:"is",value:function(t){return t.type instanceof e}}])}(),yo=function(){function e(t,n){(0,h.A)(this,e),this.attrs=t,this.spec=n||wo}return(0,p.A)(e,[{key:"map",value:function(e,t,n,r){var o=e.mapResult(t.from+r,1);if(o.deleted)return null;var i=e.mapResult(t.to+r,-1);return i.deleted||i.pos<=o.pos?null:new ko(o.pos-n,i.pos-n,this)}},{key:"valid",value:function(e,t){var n,r=e.content.findIndex(t.from),o=r.index,i=r.offset;return i==t.from&&!(n=e.child(o)).isText&&i+n.nodeSize==t.to}},{key:"eq",value:function(t){return this==t||t instanceof e&&vo(this.attrs,t.attrs)&&vo(this.spec,t.spec)}},{key:"destroy",value:function(){}}])}(),ko=function(){function e(t,n,r){(0,h.A)(this,e),this.from=t,this.to=n,this.type=r}return(0,p.A)(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 go}},{key:"widget",get:function(){return this.type instanceof mo}}],[{key:"widget",value:function(t,n,r){return new e(t,t,new mo(n,r))}},{key:"inline",value:function(t,n,r,o){return new e(t,n,new go(r,o))}},{key:"node",value:function(t,n,r,o){return new e(t,n,new yo(r,o))}}])}(),bo=[],wo={},xo=function(){function e(t,n){(0,h.A)(this,e),this.local=t.length?t:bo,this.children=n.length?n:bo}return(0,p.A)(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,o){for(var i=0;i<this.local.length;i++){var s=this.local[i];s.from<=t&&s.to>=e&&(!o||o(s.spec))&&n.push(s.copy(s.from+r,s.to+r))}for(var a=0;a<this.children.length;a+=3)if(this.children[a]<t&&this.children[a+1]>e){var u=this.children[a]+1;this.children[a+2].findInner(e-u,t-u,n,r+u,o)}}},{key:"map",value:function(e,t,n){return this==Mo||0==e.maps.length?this:this.mapInner(e,t,0,0,n||wo)}},{key:"mapInner",value:function(t,n,r,o,i){for(var s,a=0;a<this.local.length;a++){var u=this.local[a].map(t,r,o);u&&u.type.valid(n,u)?(s||(s=[])).push(u):i.onRemove&&i.onRemove(this.local[a].spec)}return this.children.length?Ao(this.children,s||[],t,n,r,o,i):s?new e(s.sort(Eo),bo):Mo}},{key:"add",value:function(t,n){return n.length?this==Mo?e.create(t,n):this.addInner(t,n,0):this}},{key:"addInner",value:function(t,n,r){var o,i=this,s=0;t.forEach((function(e,t){var a,u=t+r;if(a=Oo(n,e,u)){for(o||(o=i.children.slice());s<o.length&&o[s]<t;)s+=3;o[s]==t?o[s+2]=o[s+2].addInner(e,a,u+1):o.splice(s,0,t,t+e.nodeSize,No(a,e,u+1,wo)),s+=3}}));for(var a=Co(s?To(n):n,-r),u=0;u<a.length;u++)a[u].type.valid(t,a[u])||a.splice(u--,1);return new e(a.length?this.local.concat(a).sort(Eo):this.local,o||this.children)}},{key:"remove",value:function(e){return 0==e.length||this==Mo?this:this.removeInner(e,0)}},{key:"removeInner",value:function(t,n){for(var r=this.children,o=this.local,i=0;i<r.length;i+=3){for(var s,a=void 0,u=r[i]+n,c=r[i+1]+n,l=0;l<t.length;l++)(s=t[l])&&s.from>u&&s.to<c&&(t[l]=null,(a||(a=[])).push(s));if(a){r==this.children&&(r=this.children.slice());var d=r[i+2].removeInner(a,u+1);d!=Mo?r[i+2]=d:(r.splice(i,3),i-=3)}}if(o.length)for(var f,h=0;h<t.length;h++)if(f=t[h])for(var p=0;p<o.length;p++)o[p].eq(f,n)&&(o==this.local&&(o=this.local.slice()),o.splice(p--,1));return r==this.children&&o==this.local?this:o.length||r.length?new e(o,r):Mo}},{key:"forChild",value:function(t,n){if(this==Mo)return this;if(n.isLeaf)return e.empty;for(var r,o,i=0;i<this.children.length;i+=3)if(this.children[i]>=t){this.children[i]==t&&(r=this.children[i+2]);break}for(var s=t+1,a=s+n.content.size,u=0;u<this.local.length;u++){var c=this.local[u];if(c.from<a&&c.to>s&&c.type instanceof go){var l=Math.max(s,c.from)-s,d=Math.min(a,c.to)-s;l<d&&(o||(o=[])).push(c.copy(l,d))}}if(o){var f=new e(o.sort(Eo),bo);return r?new So([f,r]):f}return r||Mo}},{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 Do(this.localsInner(e))}},{key:"localsInner",value:function(e){if(this==Mo)return bo;if(e.inlineContent||!this.local.some(go.is))return this.local;for(var t=[],n=0;n<this.local.length;n++)this.local[n].type instanceof go||t.push(this.local[n]);return t}}],[{key:"create",value:function(e,t){return t.length?No(t,e,0,wo):Mo}}])}();xo.empty=new xo([],[]),xo.removeOverlap=Do;var Mo=xo.empty,So=function(){function e(t){(0,h.A)(this,e),this.members=t}return(0,p.A)(e,[{key:"map",value:function(t,n){var r=this.members.map((function(e){return e.map(t,n,wo)}));return e.from(r)}},{key:"forChild",value:function(t,n){if(n.isLeaf)return xo.empty;for(var r=[],o=0;o<this.members.length;o++){var i=this.members[o].forChild(t,n);i!=Mo&&(i instanceof e?r=r.concat(i.members):r.push(i))}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 o=this.members[r].localsInner(e);if(o.length)if(t){n&&(t=t.slice(),n=!1);for(var i=0;i<o.length;i++)t.push(o[i])}else t=o}return t?Do(n?t:t.sort(Eo)):bo}}],[{key:"from",value:function(t){switch(t.length){case 0:return Mo;case 1:return t[0];default:return new e(t.every((function(e){return e instanceof xo}))?t:t.reduce((function(e,t){return e.concat(t instanceof xo?t:t.members)}),[]))}}}])}();function Ao(e,t,n,r,o,i,s){for(var a=e.slice(),u=function(e){var t=0;n.maps[c].forEach((function(n,r,o,i){for(var s=i-o-(r-n),u=0;u<a.length;u+=3){var c=a[u+1];if(!(c<0||n>c+e-t)){var l=a[u]+e-t;r>=l?a[u+1]=n<=l?-2:-1:n>=e&&s&&(a[u]+=s,a[u+1]+=s)}}t+=s})),e=n.maps[c].map(e,-1),l=e},c=0,l=i;c<n.maps.length;c++)u(l);for(var d=!1,f=0;f<a.length;f+=3)if(a[f+1]<0){if(-2==a[f+1]){d=!0,a[f+1]=-1;continue}var h=n.map(e[f]+i),p=h-o;if(p<0||p>=r.content.size){d=!0;continue}var v=n.map(e[f+1]+i,-1)-o,m=r.content.findIndex(p),g=m.index,y=m.offset,k=r.maybeChild(g);if(k&&y==p&&y+k.nodeSize==v){var b=a[f+2].mapInner(n,k,h+1,e[f]+i+1,s);b!=Mo?(a[f]=p,a[f+1]=v,a[f+2]=b):(a[f+1]=-2,d=!0)}else d=!0}if(d){var w=function(e,t,n,r,o,i,s){function a(e,t){for(var i=0;i<e.local.length;i++){var u=e.local[i].map(r,o,t);u?n.push(u):s.onRemove&&s.onRemove(e.local[i].spec)}for(var c=0;c<e.children.length;c+=3)a(e.children[c+2],e.children[c]+t+1)}for(var u=0;u<e.length;u+=3)-1==e[u+1]&&a(e[u+2],t[u]+i+1);return n}(a,e,t,n,o,i,s),x=No(w,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,A=0;S<x.children.length;S+=3){for(var C=x.children[S];A<a.length&&a[A]<C;)A+=3;a.splice(A,0,x.children[S],x.children[S+1],x.children[S+2])}}return new xo(t.sort(Eo),a)}function Co(e,t){if(!t||!e.length)return e;for(var n=[],r=0;r<e.length;r++){var o=e[r];n.push(new ko(o.from+t,o.to+t,o.type))}return n}function Oo(e,t,n){if(t.isLeaf)return null;for(var r,o=n+t.nodeSize,i=null,s=0;s<e.length;s++)(r=e[s])&&r.from>n&&r.to<o&&((i||(i=[])).push(r),e[s]=null);return i}function To(e){for(var t=[],n=0;n<e.length;n++)null!=e[n]&&t.push(e[n]);return t}function No(e,t,n,r){var o=[],i=!1;t.forEach((function(t,s){var a=Oo(e,t,s+n);if(a){i=!0;var u=No(a,t,n+s+1,r);u!=Mo&&o.push(s,s+t.nodeSize,u)}}));for(var s=Co(i?To(e):e,-n).sort(Eo),a=0;a<s.length;a++)s[a].type.valid(t,s[a])||(r.onRemove&&r.onRemove(s[a].spec),s.splice(a--,1));return s.length||o.length?new xo(s,o):Mo}function Eo(e,t){return e.from-t.from||e.to-t.to}function Do(e){for(var t=e,n=0;n<t.length-1;n++){var r=t[n];if(r.from!=r.to)for(var o=n+1;o<t.length;o++){var i=t[o];if(i.from!=r.from){i.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,i.from),Po(t,o,r.copy(i.from,r.to)));break}i.to!=r.to&&(t==e&&(t=e.slice()),t[o]=i.copy(i.from,r.to),Po(t,o+1,i.copy(r.to,i.to)))}}return t}function Po(e,t,n){for(;t<e.length&&Eo(n,e[t])>0;)t++;e.splice(t,0,n)}function Io(e){var t=[];return e.someProp("decorations",(function(n){var r=n(e.state);r&&r!=Mo&&t.push(r)})),e.cursorWrapper&&t.push(xo.create(e.state.doc,[e.cursorWrapper.deco])),So.from(t)}var Ro={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},zo=rn&&on<=11,Bo=function(){return(0,p.A)((function e(){(0,h.A)(this,e),this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}),[{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}}])}(),Lo=function(){return(0,p.A)((function e(t,n){var r=this;(0,h.A)(this,e),this.view=t,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Bo,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]);rn&&on<=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()})),zo&&(this.onCharData=function(e){r.queue.push({target:e.target,type:"characterData",oldValue:e.prevValue}),r.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}),[{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,Ro)),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(gr(this.view)){if(this.suppressingSelectionUpdates)return cr(this.view);if(rn&&on<=11&&!this.view.state.selection.empty){var e=this.view.domSelectionRange();if(e.focusNode&&Jt(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=jt(r))n.add(r);for(var o=e.anchorNode;o;o=jt(o))if(n.has(o)){t=o;break}var i=t&&this.view.docView.nearestDesc(t);return i&&i.ignoreMutation({type:"selection",target:3==t.nodeType?t.parentNode:t})?(this.setCurSelection(),!0):void 0}},{key:"pendingRecords",value:function(){if(this.observer){var e,t=k(this.observer.takeRecords());try{for(t.s();!(e=t.n()).done;){var n=e.value;this.queue.push(n)}}catch(e){t.e(e)}finally{t.f()}}return this.queue}},{key:"flush",value:function(){var e=this.view;if(e.docView&&!(this.flushingSoon>-1)){var t=this.pendingRecords();t.length&&(this.queue=[]);var n=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&gr(e)&&!this.ignoreSelectionChange(n),o=-1,i=-1,a=!1,u=[];if(e.editable)for(var c=0;c<t.length;c++){var l=this.registerMutation(t[c],u);l&&(o=o<0?l.from:Math.min(l.from,o),i=i<0?l.to:Math.max(l.to,i),l.typeOver&&(a=!0))}if(sn&&u.length){var d=u.filter((function(e){return"BR"==e.nodeName}));if(2==d.length){var f=(0,s.A)(d,2),h=f[0],p=f[1];h.parentNode&&h.parentNode.parentNode==p.parentNode?p.remove():h.remove()}else{var v,m=this.currentSelection.focusNode,g=k(d);try{for(g.s();!(v=g.n()).done;){var y=v.value,b=y.parentNode;!b||"LI"!=b.nodeName||m&&jo(e,m)==b||y.remove()}}catch(e){g.e(e)}finally{g.f()}}}var w=null;o<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Gt(n)&&(w=ar(e))&&w.eq(gt.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,cr(e),this.currentSelection.set(n),e.scrollToSelection()):(o>-1||r)&&(o>-1&&(e.docView.markDirty(o,i),function(e){if(!$o.has(e)&&($o.set(e,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace))){if(e.requiresGeckoHackNode=sn,Vo)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."),Vo=!0}}(e)),this.handleDOMChange(o,i,a,u),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||cr(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 o=e.previousSibling,i=e.nextSibling;if(rn&&on<=11&&e.addedNodes.length)for(var s=0;s<e.addedNodes.length;s++){var a=e.addedNodes[s],u=a.previousSibling,c=a.nextSibling;(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(o=u),(!c||Array.prototype.indexOf.call(e.addedNodes,c)<0)&&(i=c)}var l=o&&o.parentNode==e.target?Ft(o)+1:0,d=n.localPosFromDOM(e.target,l,-1),f=i&&i.parentNode==e.target?Ft(i):e.target.childNodes.length;return{from:d,to:n.localPosFromDOM(e.target,f,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}}}])}(),$o=new WeakMap,Vo=!1;function Fo(e,t){var n=t.startContainer,r=t.startOffset,o=t.endContainer,i=t.endOffset,s=e.domAtPos(e.state.selection.anchor);if(Jt(s.node,s.offset,o,i)){var a=[o,i,n,r];n=a[0],r=a[1],o=a[2],i=a[3]}return{anchorNode:n,anchorOffset:r,focusNode:o,focusOffset:i}}function jo(e,t){for(var n=t.parentNode;n&&n!=e.dom;n=n.parentNode){var r=e.docView.nearestDesc(n,!0);if(r&&r.node.isBlock)return n}return null}function Ho(e){var t=e.pmViewDesc;if(t)return t.parseRule();if("BR"==e.nodeName&&e.parentNode){if(ln&&/^(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||ln&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if("IMG"==e.nodeName&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null}var qo=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Jo(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:mr(e,t.resolve(n.anchor),t.resolve(n.head))}function Wo(e,t,n){for(var r=e.depth,o=t?e.end():e.pos;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,o++,t=!1;if(n)for(var i=e.node(r).maybeChild(e.indexAfter(r));i&&!i.isLeaf;)i=i.firstChild,o++;return o}function Ko(e){if(2!=e.length)return!1;var t=e.charCodeAt(0),n=e.charCodeAt(1);return t>=56320&&t<=57343&&n>=55296&&n<=56319}var _o=function(){return(0,p.A)((function e(t,n){var r=this;(0,h.A)(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 Wr,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(Qo),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=Xo(this),Go(this),this.nodeViews=Yo(this),this.docView=Jn(this.state.doc,Uo(this),Io(this),this.dom,this),this.domObserver=new Lo(this,(function(e,t,n,o){return function(e,t,n,r,o){var i=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){var s=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,a=ar(e,s);if(a&&!e.state.selection.eq(a)){if(un&&pn&&13===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp("handleKeyDown",(function(t){return t(e,Xt(13,"Enter"))})))return;var u=e.state.tr.setSelection(a);"pointer"==s?u.setMeta("pointer",!0):"key"==s&&u.scrollIntoView(),i&&u.setMeta("composition",i),e.dispatch(u)}}else{var c=e.state.doc.resolve(t),l=c.sharedDepth(n);t=c.before(l+1),n=e.state.doc.resolve(n).after(l+1);var d,f,h=e.state.selection,p=function(e,t,n){var r,o=e.docView.parseRange(t,n),i=o.node,s=o.fromOffset,a=o.toOffset,u=o.from,c=o.to,l=e.domSelectionRange(),d=l.anchorNode;if(d&&e.dom.contains(1==d.nodeType?d:d.parentNode)&&(r=[{node:d,offset:l.anchorOffset}],Gt(l)||r.push({node:l.focusNode,offset:l.focusOffset})),un&&8===e.input.lastKeyCode)for(var f=a;f>s;f--){var h=i.childNodes[f-1],p=h.pmViewDesc;if("BR"==h.nodeName&&!p){a=f;break}if(!p||p.size)break}var v=e.state.doc,m=e.someProp("domParser")||ge.fromSchema(e.state.schema),g=v.resolve(u),y=null,k=m.parse(i,{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:Ho,context:g});if(r&&null!=r[0].pos){var b=r[0].pos,w=r[1]&&r[1].pos;null==w&&(w=b),y={anchor:b+u,head:w+u}}return{doc:k,sel:y,from:u,to:c}}(e,t,n),v=e.state.doc,m=v.slice(p.from,p.to);8===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime?(d=e.state.selection.to,f="end"):(d=e.state.selection.from,f="start"),e.input.lastKeyCode=null;var g=function(e,t,n,r,o){var i=e.findDiffStart(t,n);if(null==i)return null;var s=e.findDiffEnd(t,n+e.size,n+t.size),a=s.a,u=s.b;if("end"==o&&(r-=a+Math.max(0,i-Math.min(a,u))-i),a<i&&e.size<t.size){var c=r<=i&&r>=a?i-r:0;(i-=c)&&i<t.size&&Ko(t.textBetween(i-1,i+1))&&(i+=c?1:-1),u=i+(u-a),a=i}else if(u<i){var l=r<=i&&r>=u?i-r:0;(i-=l)&&i<e.size&&Ko(e.textBetween(i-1,i+1))&&(i+=l?1:-1),a=i+(a-u),u=i}return{start:i,endA:a,endB:u}}(m.content,p.doc.content,p.from,d,f);if((dn&&e.input.lastIOSEnter>Date.now()-225||pn)&&o.some((function(e){return 1==e.nodeType&&!qo.test(e.nodeName)}))&&(!g||g.endA>=g.endB)&&e.someProp("handleKeyDown",(function(t){return t(e,Xt(13,"Enter"))})))e.input.lastIOSEnter=0;else{if(!g){if(!(r&&h instanceof wt&&!h.empty&&h.$head.sameParent(h.$anchor))||e.composing||p.sel&&p.sel.anchor!=p.sel.head){if(p.sel){var y=Jo(e,e.state.doc,p.sel);if(y&&!y.eq(e.state.selection)){var k=e.state.tr.setSelection(y);i&&k.setMeta("composition",i),e.dispatch(k)}}return}g={start:h.from,endA:h.to,endB:h.to}}e.input.domChangeCount++,e.state.selection.from<e.state.selection.to&&g.start==g.endB&&e.state.selection instanceof wt&&(g.start>e.state.selection.from&&g.start<=e.state.selection.from+2&&e.state.selection.from>=p.from?g.start=e.state.selection.from:g.endA<e.state.selection.to&&g.endA>=e.state.selection.to-2&&e.state.selection.to<=p.to&&(g.endB+=e.state.selection.to-g.endA,g.endA=e.state.selection.to)),rn&&on<=11&&g.endB==g.start+1&&g.endA==g.start&&g.start>p.from&&" "==p.doc.textBetween(g.start-p.from-1,g.start-p.from+1)&&(g.start--,g.endA--,g.endB--);var b,w=p.doc.resolveNoCache(g.start-p.from),x=p.doc.resolveNoCache(g.endB-p.from),M=v.resolve(g.start),S=w.sameParent(x)&&w.parent.inlineContent&&M.end()>=g.endA;if((dn&&e.input.lastIOSEnter>Date.now()-225&&(!S||o.some((function(e){return"DIV"==e.nodeName||"P"==e.nodeName})))||!S&&w.pos<p.doc.content.size&&!w.sameParent(x)&&(b=gt.findFrom(p.doc.resolve(w.pos+1),1,!0))&&b.head==x.pos)&&e.someProp("handleKeyDown",(function(t){return t(e,Xt(13,"Enter"))})))e.input.lastIOSEnter=0;else if(e.state.selection.anchor>g.start&&function(e,t,n,r,o){if(n-t<=o.pos-r.pos||Wo(r,!0,!1)<o.pos)return!1;var i=e.resolve(t);if(!r.parent.isTextblock){var s=i.nodeAfter;return null!=s&&n==t+s.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;var a=e.resolve(Wo(i,!0,!0));return!(!a.parent.isTextblock||a.pos>n||Wo(a,!0,!1)<n)&&r.parent.content.cut(r.parentOffset).eq(a.parent.content)}(v,g.start,g.endA,w,x)&&e.someProp("handleKeyDown",(function(t){return t(e,Xt(8,"Backspace"))})))pn&&un&&e.domObserver.suppressSelectionUpdates();else{un&&pn&&g.endB==g.start&&(e.input.lastAndroidDelete=Date.now()),pn&&!S&&w.start()!=x.start()&&0==x.parentOffset&&w.depth==x.depth&&p.sel&&p.sel.anchor==p.sel.head&&p.sel.head==g.endA&&(g.endB-=2,x=p.doc.resolveNoCache(g.endB-p.from),setTimeout((function(){e.someProp("handleKeyDown",(function(t){return t(e,Xt(13,"Enter"))}))}),20));var A,O,T,N=g.start,E=g.endA;if(S)if(w.pos==x.pos)rn&&on<=11&&0==w.parentOffset&&(e.domObserver.suppressSelectionUpdates(),setTimeout((function(){return cr(e)}),20)),A=e.state.tr.delete(N,E),O=v.resolve(g.start).marksAcross(v.resolve(g.endA));else if(g.endA==g.endB&&(T=function(e,t){for(var n,r,o,i=e.firstChild.marks,s=t.firstChild.marks,a=i,u=s,c=0;c<s.length;c++)a=s[c].removeFromSet(a);for(var l=0;l<i.length;l++)u=i[l].removeFromSet(u);if(1==a.length&&0==u.length)r=a[0],n="add",o=function(e){return e.mark(r.addToSet(e.marks))};else{if(0!=a.length||1!=u.length)return null;r=u[0],n="remove",o=function(e){return e.mark(r.removeFromSet(e.marks))}}for(var d=[],f=0;f<t.childCount;f++)d.push(o(t.child(f)));if(C.from(d).eq(e))return{mark:r,type:n}}(w.parent.content.cut(w.parentOffset,x.parentOffset),M.parent.content.cut(M.parentOffset,g.endA-M.start()))))A=e.state.tr,"add"==T.type?A.addMark(N,E,T.mark):A.removeMark(N,E,T.mark);else if(w.parent.child(w.index()).isText&&w.index()==x.index()-(x.textOffset?0:1)){var D=w.parent.textBetween(w.parentOffset,x.parentOffset);if(e.someProp("handleTextInput",(function(t){return t(e,N,E,D)})))return;A=e.state.tr.insertText(D,N,E)}if(A||(A=e.state.tr.replace(N,E,p.doc.slice(g.start-p.from,g.endB-p.from))),p.sel){var P=Jo(e,A.doc,p.sel);P&&!(un&&pn&&e.composing&&P.empty&&(g.start!=g.endB||e.input.lastAndroidDelete<Date.now()-100)&&(P.head==N||P.head==A.mapping.map(E)-1)||rn&&P.empty&&P.head==N)&&A.setSelection(P)}O&&A.ensureMarks(O),i&&A.setMeta("composition",i),e.dispatch(A.scrollIntoView())}}}}(r,e,t,n,o)})),this.domObserver.start(),function(e){var t=function(){var t=Hr[n];e.dom.addEventListener(n,e.input.eventHandlers[n]=function(n){!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,n)||Ur(e,n)||!e.editable&&n.type in qr||t(e,n)},Jr[n]?{passive:!0}:void 0)};for(var n in Hr)t();ln&&e.dom.addEventListener("input",(function(){return null})),_r(e)}(this),this.updatePluginViews()}),[{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&&_r(this);var t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Qo),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,r=this.state,o=!1,i=!1;e.storedMarks&&this.composing&&(so(this),i=!0),this.state=e;var s=r.plugins!=e.plugins||this._props.plugins!=t.plugins;if(s||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){var a=Yo(this);(function(e,t){var n=0,r=0;for(var o in e){if(e[o]!=t[o])return!0;n++}for(var i in t)r++;return n!=r})(a,this.nodeViews)&&(this.nodeViews=a,o=!0)}(s||t.handleDOMEvents!=this._props.handleDOMEvents)&&_r(this),this.editable=Xo(this),Go(this);var u=Io(this),c=Uo(this),l=r.plugins==e.plugins||r.doc.eq(e.doc)?e.scrollToSelection>r.scrollToSelection?"to selection":"preserve":"reset",d=o||!this.docView.matchesNode(e.doc,c,u);!d&&e.selection.eq(r.selection)||(i=!0);var f,h,p,v,m,g,y,k,b,w,x="preserve"==l&&i&&null==this.dom.style.overflowAnchor&&function(e){for(var t,n,r=e.dom.getBoundingClientRect(),o=Math.max(0,r.top),i=(r.left+r.right)/2,s=o+1;s<Math.min(innerHeight,r.bottom);s+=5){var a=e.root.elementFromPoint(i,s);if(a&&a!=e.dom&&e.dom.contains(a)){var u=a.getBoundingClientRect();if(u.top>=o-20){t=a,n=u.top;break}}}return{refDOM:t,refTop:n,stack:wn(e.dom)}}(this);if(i){this.domObserver.stop();var M=d&&(rn||un)&&!this.composing&&!r.selection.empty&&!e.selection.empty&&(v=r.selection,m=e.selection,g=Math.min(v.$anchor.sharedDepth(v.head),m.$anchor.sharedDepth(m.head)),v.$anchor.start(g)!=m.$anchor.start(g));if(d){var S=un?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=function(e){var t=e.domSelectionRange();if(!t.focusNode)return null;var n=function(e,t){for(;;){if(3==e.nodeType&&t)return e;if(1==e.nodeType&&t>0){if("false"==e.contentEditable)return null;t=_t(e=e.childNodes[t-1])}else{if(!e.parentNode||Ut(e))return null;t=Ft(e),e=e.parentNode}}}(t.focusNode,t.focusOffset),r=function(e,t){for(;;){if(3==e.nodeType&&t<e.nodeValue.length)return e;if(1==e.nodeType&&t<e.childNodes.length){if("false"==e.contentEditable)return null;e=e.childNodes[t],t=0}else{if(!e.parentNode||Ut(e))return null;t=Ft(e)+1,e=e.parentNode}}}(t.focusNode,t.focusOffset);if(n&&r&&n!=r){var o=r.pmViewDesc;if(!o||!o.isText(r.nodeValue))return r;if(e.input.compositionNode==r){var i=n.pmViewDesc;if(i&&i.isText(n.nodeValue))return r}}return n||r}(this)),!o&&this.docView.update(e.doc,c,u,this)||(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Jn(e.doc,c,u,this.dom,this)),S&&!this.trackWrites&&(M=!0)}M||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&(f=this,h=f.docView.domFromPos(f.state.selection.anchor,0),p=f.domSelectionRange(),Jt(h.node,h.offset,p.anchorNode,p.anchorOffset)))?cr(this,M):(pr(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(r),(null===(n=this.dragging)||void 0===n?void 0:n.node)&&!r.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,r),"reset"==l?this.dom.scrollTop=0:"to selection"==l?this.scrollToSelection():x&&(k=(y=x).refDOM,b=y.refTop,xn(y.stack,0==(w=k?k.getBoundingClientRect().top:0)?0:w-b))}},{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 Mt){var n=this.docView.domAfterPos(this.state.selection.from);1==n.nodeType&&bn(this,n.getBoundingClientRect(),t)}else bn(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 o=this.directPlugins[r];o.spec.view&&this.pluginViews.push(o.spec.view(this))}for(var i=0;i<this.state.plugins.length;i++){var s=this.state.plugins[i];s.spec.view&&this.pluginViews.push(s.spec.view(this))}}}},{key:"updateDraggedNode",value:function(e,t){var n=e.node,r=-1;if(this.state.doc.nodeAt(n.from)==n.node)r=n.from;else{var o=n.from+(this.state.doc.content.size-t.doc.content.size);(o>0&&this.state.doc.nodeAt(o))==n.node&&(r=o)}this.dragging=new fo(e.slice,e.move,r<0?void 0:Mt.create(this.state.doc,r))}},{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 o=0;o<this.directPlugins.length;o++){var i=this.directPlugins[o].props[e];if(null!=i&&(n=t?t(i):i))return n}var s=this.state.plugins;if(s)for(var a=0;a<s.length;a++){var u=s[a].props[e];if(null!=u&&(n=t?t(u):u))return n}}},{key:"hasFocus",value:function(){if(rn){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(Mn)return e.focus(Mn);var t=wn(e);e.focus(null==Mn?{get preventScroll(){return Mn={preventScroll:!0},!0}}:void 0),Mn||(Mn=!1,xn(t,0))}(this.dom),cr(this),this.domObserver.start()}},{key:"root",get:function(){var e=this,t=this._root;if(null==t)for(var n,r=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}},o=this.dom.parentNode;o;o=o.parentNode)if(n=r(o))return n.v;return t||document}},{key:"updateRoot",value:function(){this._root=null}},{key:"posAtCoords",value:function(e){return On(this,e)}},{key:"coordsAtPos",value:function(e){return Dn(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:1)}},{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 Bn==t&&Ln==n?$n:(Bn=t,Ln=n,$n="up"==n||"down"==n?function(e,t,n){var r=t.selection,o="up"==n?r.$from:r.$to;return Rn(e,t,(function(){for(var t=e.docView.domFromPos(o.pos,"up"==n?-1:1).node;;){var r=e.docView.nearestDesc(t,!0);if(!r)break;if(r.node.isBlock){t=r.contentDOM||r.dom;break}t=r.dom.parentNode}for(var i=Dn(e,o.pos,1),s=t.firstChild;s;s=s.nextSibling){var a=void 0;if(1==s.nodeType)a=s.getClientRects();else{if(3!=s.nodeType)continue;a=qt(s,0,s.nodeValue.length).getClientRects()}for(var u=0;u<a.length;u++){var c=a[u];if(c.bottom>c.top+1&&("up"==n?i.top-c.top>2*(c.bottom-i.top):c.bottom-i.bottom>2*(i.bottom-c.top)))return!1}}return!0}))}(e,t,n):function(e,t,n){var r=t.selection.$head;if(!r.parent.isTextblock)return!1;var o=r.parentOffset,i=!o,s=o==r.parent.content.size,a=e.domSelection();return zn.test(r.parent.textContent)&&a.modify?Rn(e,t,(function(){var t=e.domSelectionRange(),o=t.focusNode,i=t.focusOffset,s=t.anchorNode,u=t.anchorOffset,c=a.caretBidiLevel;a.modify("move",n,"character");var l=r.depth?e.docView.domAfterPos(r.before()):e.dom,d=e.domSelectionRange(),f=d.focusNode,h=d.focusOffset,p=f&&!l.contains(1==f.nodeType?f:f.parentNode)||o==f&&i==h;try{a.collapse(s,u),o&&(o!=s||i!=u)&&a.extend&&a.extend(o,i)}catch(e){}return null!=c&&(a.caretBidiLevel=c),p})):"left"==n||"backward"==n?i:s}(e,t,n))}(this,t||this.state,e)}},{key:"pasteHTML",value:function(e,t){return co(this,"",e,!1,t||new ClipboardEvent("paste"))}},{key:"pasteText",value:function(e,t){return co(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,[],Io(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Ht=null)}},{key:"isDestroyed",get:function(){return null==this.docView}},{key:"dispatchEvent",value:function(e){return function(e,t){Ur(e,t)||!Hr[t.type]||!e.editable&&t.type in qr||Hr[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(){var e=this.domSelection();return ln&&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,t){if(t.getComposedRanges){var n=t.getComposedRanges(e.root)[0];if(n)return Fo(e,n)}var r;function o(e){e.preventDefault(),e.stopImmediatePropagation(),r=e.getTargetRanges()[0]}return e.dom.addEventListener("beforeinput",o,!0),document.execCommand("indent"),e.dom.removeEventListener("beforeinput",o,!0),r?Fo(e,r):null}(this,e)||e}},{key:"domSelection",value:function(){return this.root.getSelection()}}])}();function Uo(e){var t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(e.editable),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]))})),t.translate||(t.translate="no"),[ko.node(0,e.state.doc.content.size,t)]}function Go(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:ko.widget(e.state.selection.head,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function Xo(e){return!e.someProp("editable",(function(t){return!1===t(e.state)}))}function Yo(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 Qo(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")}for(var Zo={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:"'"},ei={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},ti="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),ni="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),ri=0;ri<10;ri++)Zo[48+ri]=Zo[96+ri]=String(ri);for(ri=1;ri<=24;ri++)Zo[ri+111]="F"+ri;for(ri=65;ri<=90;ri++)Zo[ri]=String.fromCharCode(ri+32),ei[ri]=String.fromCharCode(ri);for(var oi in Zo)ei.hasOwnProperty(oi)||(ei[oi]=Zo[oi]);var ii="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform);function si(e){var t,n,r,o,i=e.split(/-(?!$)/),s=i[i.length-1];"Space"==s&&(s=" ");for(var a=0;a<i.length-1;a++){var u=i[a];if(/^(cmd|meta|m)$/i.test(u))o=!0;else if(/^a(lt)?$/i.test(u))t=!0;else if(/^(c|ctrl|control)$/i.test(u))n=!0;else if(/^s(hift)?$/i.test(u))r=!0;else{if(!/^mod$/i.test(u))throw new Error("Unrecognized modifier name: "+u);ii?o=!0:n=!0}}return t&&(s="Alt-"+s),n&&(s="Ctrl-"+s),o&&(s="Meta-"+s),r&&(s="Shift-"+s),s}function ai(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 ui(e){var t=function(e){var t=Object.create(null);for(var n in e)t[si(n)]=e[n];return t}(e);return function(e,n){var r,o=function(e){var t=!(ti&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||ni&&e.shiftKey&&e.key&&1==e.key.length||"Unidentified"==e.key)&&e.key||(e.shiftKey?ei:Zo)[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),i=t[ai(o,n)];if(i&&i(e.state,e.dispatch,e))return!0;if(1==o.length&&" "!=o){if(n.shiftKey){var s=t[ai(o,n,!1)];if(s&&s(e.state,e.dispatch,e))return!0}if((n.shiftKey||n.altKey||n.metaKey||o.charCodeAt(0)>127)&&(r=Zo[n.keyCode])&&r!=o){var a=t[ai(r,n)];if(a&&a(e.state,e.dispatch,e))return!0}}return!1}}var ci=function(e,t){return!e.selection.empty&&(t&&t(e.tr.deleteSelection().scrollIntoView()),!0)};function li(e,t){var n=e.selection.$cursor;return!n||(t?!t.endOfTextblock("backward",e):n.parentOffset>0)?null:n}var di=function(e,t,n){var r=li(e,n);if(!r)return!1;var o=vi(r);if(!o){var i=r.blockRange(),s=i&&Ue(i);return null!=s&&(t&&t(e.tr.lift(i,s).scrollIntoView()),!0)}var a=o.nodeBefore;if(!a.type.spec.isolating&&Ai(e,o,t))return!0;if(0==r.parent.content.size&&(hi(a,"end")||Mt.isSelectable(a))){var u=nt(e.doc,r.before(),r.after(),P.empty);if(u&&u.slice.size<u.to-u.from){if(t){var c=e.tr.step(u);c.setSelection(hi(a,"end")?gt.findFrom(c.doc.resolve(c.mapping.map(o.pos,-1)),-1):Mt.create(c.doc,o.pos-a.nodeSize)),t(c.scrollIntoView())}return!0}}return!(!a.isAtom||o.depth!=r.depth-1||(t&&t(e.tr.delete(o.pos-a.nodeSize,o.pos).scrollIntoView()),0))};function fi(e,t,n){for(var r=t.nodeBefore,o=t.pos-1;!r.isTextblock;o--){if(r.type.spec.isolating)return!1;var i=r.lastChild;if(!i)return!1;r=i}for(var s=t.nodeAfter,a=t.pos+1;!s.isTextblock;a++){if(s.type.spec.isolating)return!1;var u=s.firstChild;if(!u)return!1;s=u}var c=nt(e.doc,o,a,P.empty);if(!c||c.from!=o||c instanceof qe&&c.slice.size>=a-o)return!1;if(n){var l=e.tr.step(c);l.setSelection(wt.create(l.doc,o)),n(l.scrollIntoView())}return!0}function hi(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 pi=function(e,t,n){var r=e.selection,o=r.$head,i=o;if(!r.empty)return!1;if(o.parent.isTextblock){if(n?!n.endOfTextblock("backward",e):o.parentOffset>0)return!1;i=vi(o)}var s=i&&i.nodeBefore;return!(!s||!Mt.isSelectable(s)||(t&&t(e.tr.setSelection(Mt.create(e.doc,i.pos-s.nodeSize)).scrollIntoView()),0))};function vi(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}function mi(e,t){var n=e.selection.$cursor;return!n||(t?!t.endOfTextblock("forward",e):n.parentOffset<n.parent.content.size)?null:n}var gi=function(e,t,n){var r=mi(e,n);if(!r)return!1;var o=ki(r);if(!o)return!1;var i=o.nodeAfter;if(Ai(e,o,t))return!0;if(0==r.parent.content.size&&(hi(i,"start")||Mt.isSelectable(i))){var s=nt(e.doc,r.before(),r.after(),P.empty);if(s&&s.slice.size<s.to-s.from){if(t){var a=e.tr.step(s);a.setSelection(hi(i,"start")?gt.findFrom(a.doc.resolve(a.mapping.map(o.pos)),1):Mt.create(a.doc,a.mapping.map(o.pos))),t(a.scrollIntoView())}return!0}}return!(!i.isAtom||o.depth!=r.depth-1||(t&&t(e.tr.delete(o.pos,o.pos+i.nodeSize).scrollIntoView()),0))},yi=function(e,t,n){var r=e.selection,o=r.$head,i=o;if(!r.empty)return!1;if(o.parent.isTextblock){if(n?!n.endOfTextblock("forward",e):o.parentOffset<o.parent.content.size)return!1;i=ki(o)}var s=i&&i.nodeAfter;return!(!s||!Mt.isSelectable(s)||(t&&t(e.tr.setSelection(Mt.create(e.doc,i.pos)).scrollIntoView()),0))};function ki(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 bi=function(e,t){var n=e.selection,r=n.$head,o=n.$anchor;return!(!r.parent.type.spec.code||!r.sameParent(o)||(t&&t(e.tr.insertText("\n").scrollIntoView()),0))};function wi(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 xi=function(e,t){var n=e.selection,r=n.$head,o=n.$anchor;if(!r.parent.type.spec.code||!r.sameParent(o))return!1;var i=r.node(-1),s=r.indexAfter(-1),a=wi(i.contentMatchAt(s));if(!a||!i.canReplaceWith(s,s,a))return!1;if(t){var u=r.after(),c=e.tr.replaceWith(u,u,a.createAndFill());c.setSelection(gt.near(c.doc.resolve(u),1)),t(c.scrollIntoView())}return!0},Mi=function(e,t){var n=e.selection,r=n.$from,o=n.$to;if(n instanceof At||r.parent.inlineContent||o.parent.inlineContent)return!1;var i=wi(o.parent.contentMatchAt(o.indexAfter()));if(!i||!i.isTextblock)return!1;if(t){var s=(!r.parentOffset&&o.index()<o.parent.childCount?r:o).pos,a=e.tr.insert(s,i.createAndFill());a.setSelection(wt.create(a.doc,s+1)),t(a.scrollIntoView())}return!0},Si=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(Ye(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}var o=n.blockRange(),i=o&&Ue(o);return null!=i&&(t&&t(e.tr.lift(o,i).scrollIntoView()),!0)};function Ai(e,t,n){var r,o,i=t.nodeBefore,s=t.nodeAfter;if(i.type.spec.isolating||s.type.spec.isolating)return!1;if(function(e,t,n){var r=t.nodeBefore,o=t.nodeAfter,i=t.index();return!(!(r&&o&&r.type.compatibleContent(o.type))||(!r.content.size&&t.parent.canReplace(i-1,i)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),0):!t.parent.canReplace(i,i+1)||!o.isTextblock&&!Qe(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=(o=i.contentMatchAt(i.childCount)).findWrapping(s.type))&&o.matchType(r[0]||s.type).validEnd){if(n){for(var u=t.pos+s.nodeSize,c=C.empty,l=r.length-1;l>=0;l--)c=C.from(r[l].create(null,c));c=C.from(i.copy(c));var d=e.tr.step(new Je(t.pos-1,u,t.pos,u,new P(c,1,0),r.length,!0)),f=u+2*r.length;Qe(d.doc,f)&&d.join(f),n(d.scrollIntoView())}return!0}var h=gt.findFrom(t,1),p=h&&h.$from.blockRange(h.$to),v=p&&Ue(p);if(null!=v&&v>=t.depth)return n&&n(e.tr.lift(p,v).scrollIntoView()),!0;if(a&&hi(s,"start",!0)&&hi(i,"end")){for(var m=i,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 b=C.empty,w=g.length-1;w>=0;w--)b=C.from(g[w].copy(b));n(e.tr.step(new Je(t.pos-g.length,t.pos+s.nodeSize,t.pos+k,t.pos+s.nodeSize-k,new P(b,g.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function Ci(e){return function(t,n){for(var r=t.selection,o=e<0?r.$from:r.$to,i=o.depth;o.node(i).isInline;){if(!i)return!1;i--}return!!o.node(i).isTextblock&&(n&&n(t.tr.setSelection(wt.create(t.doc,e<0?o.start(i):o.end(i)))),!0)}}var Oi=Ci(-1),Ti=Ci(1);function Ni(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return function(n,r){for(var o=!1,i=0;i<n.selection.ranges.length&&!o;i++){var s=n.selection.ranges[i],a=s.$from.pos,u=s.$to.pos;n.doc.nodesBetween(a,u,(function(r,i){if(o)return!1;if(r.isTextblock&&!r.hasMarkup(e,t))if(r.type==e)o=!0;else{var s=n.doc.resolve(i),a=s.index();o=s.parent.canReplaceWith(a,a+1,e)}}))}if(!o)return!1;if(r){for(var c=n.tr,l=0;l<n.selection.ranges.length;l++){var d=n.selection.ranges[l],f=d.$from.pos,h=d.$to.pos;c.setBlockType(f,h,e,t)}r(c.scrollIntoView())}return!0}}function Ei(){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 o=0;o<t.length;o++)if(t[o](e,n,r))return!0;return!1}}var Di=Ei(ci,di,pi),Pi=Ei(ci,gi,yi),Ii={Enter:Ei(bi,Mi,Si,(function(e,t){var n=e.selection,r=n.$from,o=n.$to;if(e.selection instanceof Mt&&e.selection.node.isBlock)return!(!r.parentOffset||!Ye(e.doc,r.pos)||(t&&t(e.tr.split(r.pos).scrollIntoView()),0));if(!r.parent.isBlock)return!1;if(t){var i=o.parentOffset==o.parent.content.size,s=e.tr;(e.selection instanceof wt||e.selection instanceof At)&&s.deleteSelection();var a=0==r.depth?null:wi(r.node(-1).contentMatchAt(r.indexAfter(-1))),u=i&&a?[{type:a}]:void 0,c=Ye(s.doc,s.mapping.map(r.pos),1,u);if(u||c||!Ye(s.doc,s.mapping.map(r.pos),1,a?[{type:a}]:void 0)||(a&&(u=[{type:a}]),c=!0),c&&(s.split(s.mapping.map(r.pos),1,u),!i&&!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":xi,Backspace:Di,"Mod-Backspace":Di,"Shift-Backspace":Di,Delete:Pi,"Mod-Delete":Pi,"Mod-a":function(e,t){return t&&t(e.tr.setSelection(new At(e.doc))),!0}},Ri={"Ctrl-h":Ii.Backspace,"Alt-Backspace":Ii["Mod-Backspace"],"Ctrl-d":Ii.Delete,"Ctrl-Alt-Backspace":Ii["Mod-Delete"],"Alt-Delete":Ii["Mod-Delete"],"Alt-d":Ii["Mod-Delete"],"Ctrl-a":Oi,"Ctrl-e":Ti};for(var zi in Ii)Ri[zi]=Ii[zi];function Bi(e){var t=e.state,n=e.transaction,r=n.selection,o=n.doc,i=n.storedMarks;return y(y({},t),{},{apply:t.apply.bind(t),applyTransaction:t.applyTransaction.bind(t),plugins:t.plugins,schema:t.schema,reconfigure:t.reconfigure.bind(t),toJSON:t.toJSON.bind(t),get storedMarks(){return i},get selection(){return r},get doc(){return o},get tr(){return r=n.selection,o=n.doc,i=n.storedMarks,n}})}"undefined"!=typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):"undefined"!=typeof os&&os.platform&&os.platform();var Li=function(){return(0,p.A)((function e(t){(0,h.A)(this,e),this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}),[{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,o=n.view,i=r.tr,a=this.buildProps(i);return Object.fromEntries(Object.entries(t).map((function(t){var n=(0,s.A)(t,2),r=n[0],u=n[1];return[r,function(){var t=u.apply(void 0,arguments)(a);return i.getMeta("preventDispatch")||e.hasCustomState||o.dispatch(i),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,o=this.editor,i=this.state,a=o.view,u=[],c=!!e,l=e||i.tr,d=y(y({},Object.fromEntries(Object.entries(r).map((function(e){var r=(0,s.A)(e,2),o=r[0],i=r[1];return[o,function(){var e=t.buildProps(l,n),r=i.apply(void 0,arguments)(e);return u.push(r),d}]})))),{},{run:function(){return c||!n||l.getMeta("preventDispatch")||t.hasCustomState||a.dispatch(l),u.every((function(e){return!0===e}))}});return d}},{key:"createCan",value:function(e){var t=this,n=this.rawCommands,r=this.state,o=!1,i=e||r.tr,a=this.buildProps(i,o),u=Object.fromEntries(Object.entries(n).map((function(e){var t=(0,s.A)(e,2),n=t[0],r=t[1];return[n,function(){return r.apply(void 0,arguments)(y(y({},a),{},{dispatch:void 0}))}]})));return y(y({},u),{},{chain:function(){return t.createChain(i,o)}})}},{key:"buildProps",value:function(e){var t=this,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=this.rawCommands,o=this.editor,i=this.state,a=o.view,u={tr:e,editor:o,view:a,state:Bi({state:i,transaction:e}),dispatch:n?function(){}:void 0,chain:function(){return t.createChain(e,n)},can:function(){return t.createCan(e)},get commands(){return Object.fromEntries(Object.entries(r).map((function(e){var t=(0,s.A)(e,2),n=t[0],r=t[1];return[n,function(){return r.apply(void 0,arguments)(u)}]})))}};return u}}])}(),$i=function(){return(0,p.A)((function e(){(0,h.A)(this,e),this.callbacks={}}),[{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),o=1;o<n;o++)r[o-1]=arguments[o];var i=this.callbacks[e];return i&&i.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={}}}])}();function Vi(e,t,n){return void 0===e.config[t]&&e.parent?Vi(e.parent,t,n):"function"==typeof e.config[t]?e.config[t].bind(y(y({},n),{},{parent:e.parent?Vi(e.parent,t,n):null})):e.config[t]}function Fi(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 ji(e){var t=[],n=Fi(e),r=n.nodeExtensions,i=n.markExtensions,a=[].concat((0,o.A)(r),(0,o.A)(i)),u={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return e.forEach((function(e){var n=Vi(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,s.A)(e,2),o=r[0],i=r[1];t.push({type:n,name:o,attribute:y(y({},u),i)})}))}))}))})),a.forEach((function(e){var n={name:e.name,options:e.options,storage:e.storage},r=Vi(e,"addAttributes",n);if(r){var o=r();Object.entries(o).forEach((function(n){var r=(0,s.A)(n,2),o=r[0],i=r[1],a=y(y({},u),i);"function"==typeof(null==a?void 0:a.default)&&(a.default=a.default()),(null==a?void 0:a.isRequired)&&void 0===(null==a?void 0:a.default)&&delete a.default,t.push({type:e.name,name:o,attribute:a})}))}})),t}function Hi(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 qi(){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=y({},e);return Object.entries(t).forEach((function(e){var t=(0,s.A)(e,2),r=t[0],i=t[1];if(n[r])if("class"===r){var a=i?i.split(" "):[],u=n[r]?n[r].split(" "):[],c=a.filter((function(e){return!u.includes(e)}));n[r]=[].concat((0,o.A)(u),(0,o.A)(c)).join(" ")}else n[r]="style"===r?[n[r],i].join("; "):i;else n[r]=i})),n}),{})}function Ji(e,t){return t.filter((function(e){return e.attribute.rendered})).map((function(t){return t.attribute.renderHTML?t.attribute.renderHTML(e.attrs)||{}:(0,i.A)({},t.name,e.attrs[t.name])})).reduce((function(e,t){return qi(e,t)}),{})}function Wi(e){return"function"==typeof e}function Ki(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;if(Wi(e)){for(var n=arguments.length,r=new Array(n>2?n-2:0),o=2;o<n;o++)r[o-2]=arguments[o];return t?e.bind(t).apply(void 0,r):e.apply(void 0,r)}return e}function _i(e,t){return e.style?e:y(y({},e),{},{getAttrs:function(n){var r=e.getAttrs?e.getAttrs(n):e.attrs;if(!1===r)return!1;var o=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:y(y({},e),{},(0,i.A)({},t.name,r))}),{});return y(y({},r),o)}})}function Ui(e){return Object.fromEntries(Object.entries(e).filter((function(e){var t=(0,s.A)(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 Gi(e,t){return t.nodes[e]||t.marks[e]||null}function Xi(e,t){return Array.isArray(t)?t.some((function(t){return("string"==typeof t?t:t.name)===e.name})):t}var Yi=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,o,i){var s,a,u=(null===(a=(s=e.type.spec).toText)||void 0===a?void 0:a.call(s,{node:e,pos:t,parent:o,index:i}))||e.textContent||"%leaf%";n+=u.slice(0,Math.max(0,r-t))})),n};function Qi(e){return"[object RegExp]"===Object.prototype.toString.call(e)}var Zi=(0,p.A)((function e(t){(0,h.A)(this,e),this.find=t.find,this.handler=t.handler})),es=function(e,t){if(Qi(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};function ts(e){var t,n=e.editor,r=e.from,o=e.to,i=e.text,s=e.rules,a=e.plugin,u=n.view;if(u.composing)return!1;var c=u.state.doc.resolve(r);if(c.parent.type.spec.code||(null===(t=c.nodeBefore||c.nodeAfter)||void 0===t?void 0:t.marks.find((function(e){return e.type.spec.code}))))return!1;var l=!1,d=Yi(c)+i;return s.forEach((function(e){if(!l){var t=es(d,e.find);if(t){var s=u.state.tr,c=Bi({state:u.state,transaction:s}),f={from:r-(t[0].length-i.length),to:o},h=new Li({editor:n,state:c}),p=h.commands,v=h.chain,m=h.can;null!==e.handler({state:c,range:f,match:t,commands:p,chain:v,can:m})&&s.steps.length&&(s.setMeta(a,{transform:s,from:r,to:o,text:i}),u.dispatch(s),l=!0)}}})),l}function ns(e){var t=e.editor,n=e.rules,r=new Bt({state:{init:function(){return null},apply:function(e,o){var i=e.getMeta(r);if(i)return i;var s=e.getMeta("applyInputRules");return!!s&&setTimeout((function(){var e=s.from,o=s.text,i=e+o.length;ts({editor:t,from:e,to:i,text:o,rules:n,plugin:r})})),e.selectionSet||e.docChanged?null:o}},props:{handleTextInput:function(e,o,i,s){return ts({editor:t,from:o,to:i,text:s,rules:n,plugin:r})},handleDOMEvents:{compositionend:function(e){return setTimeout((function(){var o=e.state.selection.$cursor;o&&ts({editor:t,from:o.pos,to:o.pos,text:"",rules:n,plugin:r})})),!1}},handleKeyDown:function(e,o){if("Enter"!==o.key)return!1;var i=e.state.selection.$cursor;return!!i&&ts({editor:t,from:i.pos,to:i.pos,text:"\n",rules:n,plugin:r})}},isInputRules:!0});return r}var rs=(0,p.A)((function e(t){(0,h.A)(this,e),this.find=t.find,this.handler=t.handler}));function is(e){var t=e.editor,n=e.rules,r=null,i=!1,s=!1,a="undefined"!=typeof ClipboardEvent?new ClipboardEvent("paste"):null,u="undefined"!=typeof DragEvent?new DragEvent("drop"):null,c=function(e){var n=e.state,r=e.from,i=e.to,s=e.rule,c=e.pasteEvt,l=n.tr,d=Bi({state:n,transaction:l}),f=function(e){var t=e.state,n=e.from,r=e.to,i=e.rule,s=e.pasteEvent,a=e.dropEvent,u=new Li({editor:e.editor,state:t}),c=u.commands,l=u.chain,d=u.can,f=[];return t.doc.nodesBetween(n,r,(function(e,u){if(e.isTextblock&&!e.type.spec.code){var h=Math.max(n,u),p=Math.min(r,u+e.content.size);(function(e,t,n){if(Qi(t))return(0,o.A)(e.matchAll(t));var r=t(e,n);return r?r.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(h-u,p-u,void 0,""),i.find,s).forEach((function(e){if(void 0!==e.index){var n=h+e.index+1,r=n+e[0].length,o={from:t.tr.mapping.map(n),to:t.tr.mapping.map(r)},u=i.handler({state:t,range:o,match:e,commands:c,chain:l,can:d,pasteEvent:s,dropEvent:a});f.push(u)}}))}})),f.every((function(e){return null!==e}))}({editor:t,state:d,from:Math.max(r-1,0),to:i.b-1,rule:s,pasteEvent:c,dropEvent:u});if(f&&l.steps.length)return u="undefined"!=typeof DragEvent?new DragEvent("drop"):null,a="undefined"!=typeof ClipboardEvent?new ClipboardEvent("paste"):null,l};return n.map((function(e){return new Bt({view:function(e){var t=function(t){var n;r=(null===(n=e.dom.parentElement)||void 0===n?void 0:n.contains(t.target))?e.dom.parentElement:null};return window.addEventListener("dragstart",t),{destroy:function(){window.removeEventListener("dragstart",t)}}},props:{handleDOMEvents:{drop:function(e,t){return s=r===e.dom.parentElement,u=t,!1},paste:function(e,t){var n,r=null===(n=t.clipboardData)||void 0===n?void 0:n.getData("text/html");return a=t,i=!!(null==r?void 0:r.includes("data-pm-slice")),!1}}},appendTransaction:function(t,n,r){var o=t[0],u="paste"===o.getMeta("uiEvent")&&!i,l="drop"===o.getMeta("uiEvent")&&!s,d=o.getMeta("applyPasteRules"),f=!!d;if(u||l||f){if(f){var h=d.from,p=d.text,v=h+p.length,m=function(e){var t,n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return null===(t=n.clipboardData)||void 0===t||t.setData("text/html",e),n}(p);return c({rule:e,state:r,from:h,to:{b:v},pasteEvt:m})}var g=n.doc.content.findDiffStart(r.doc.content),y=n.doc.content.findDiffEnd(r.doc.content);if("number"==typeof g&&y&&g!==y.b)return c({rule:e,state:r,from:g,to:y,pasteEvt:a})}}})}))}var ss=function(){function e(t,n){(0,h.A)(this,e),this.splittableMarks=[],this.editor=n,this.extensions=e.resolve(t),this.schema=function(e,t){var n,r=ji(e),o=Fi(e),i=o.nodeExtensions,s=o.markExtensions,a=null===(n=i.find((function(e){return Vi(e,"topNode")})))||void 0===n?void 0:n.name,u=Object.fromEntries(i.map((function(n){var o=r.filter((function(e){return e.type===n.name})),i={name:n.name,options:n.options,storage:n.storage,editor:t},s=e.reduce((function(e,t){var r=Vi(t,"extendNodeSchema",i);return y(y({},e),r?r(n):{})}),{}),a=Ui(y(y({},s),{},{content:Ki(Vi(n,"content",i)),marks:Ki(Vi(n,"marks",i)),group:Ki(Vi(n,"group",i)),inline:Ki(Vi(n,"inline",i)),atom:Ki(Vi(n,"atom",i)),selectable:Ki(Vi(n,"selectable",i)),draggable:Ki(Vi(n,"draggable",i)),code:Ki(Vi(n,"code",i)),defining:Ki(Vi(n,"defining",i)),isolating:Ki(Vi(n,"isolating",i)),attrs:Object.fromEntries(o.map((function(e){var t;return[e.name,{default:null===(t=null==e?void 0:e.attribute)||void 0===t?void 0:t.default}]})))})),u=Ki(Vi(n,"parseHTML",i));u&&(a.parseDOM=u.map((function(e){return _i(e,o)})));var c=Vi(n,"renderHTML",i);c&&(a.toDOM=function(e){return c({node:e,HTMLAttributes:Ji(e,o)})});var l=Vi(n,"renderText",i);return l&&(a.toText=l),[n.name,a]}))),c=Object.fromEntries(s.map((function(n){var o=r.filter((function(e){return e.type===n.name})),i={name:n.name,options:n.options,storage:n.storage,editor:t},s=e.reduce((function(e,t){var r=Vi(t,"extendMarkSchema",i);return y(y({},e),r?r(n):{})}),{}),a=Ui(y(y({},s),{},{inclusive:Ki(Vi(n,"inclusive",i)),excludes:Ki(Vi(n,"excludes",i)),group:Ki(Vi(n,"group",i)),spanning:Ki(Vi(n,"spanning",i)),code:Ki(Vi(n,"code",i)),attrs:Object.fromEntries(o.map((function(e){var t;return[e.name,{default:null===(t=null==e?void 0:e.attribute)||void 0===t?void 0:t.default}]})))})),u=Ki(Vi(n,"parseHTML",i));u&&(a.parseDOM=u.map((function(e){return _i(e,o)})));var c=Vi(n,"renderHTML",i);return c&&(a.toDOM=function(e){return c({mark:e,HTMLAttributes:Ji(e,o)})}),[n.name,a]})));return new ve({topNode:a,nodes:u,marks:c})}(this.extensions,n),this.setupExtensions()}return(0,p.A)(e,[{key:"commands",get:function(){var e=this;return this.extensions.reduce((function(t,n){var r=Vi(n,"addCommands",{name:n.name,options:n.options,storage:n.storage,editor:e.editor,type:Gi(n.name,e.schema)});return r?y(y({},t),r()):t}),{})}},{key:"plugins",get:function(){var t=this,n=this.editor,r=e.sort((0,o.A)(this.extensions).reverse()),i=[],a=[],u=r.map((function(e){var r={name:e.name,options:e.options,storage:e.storage,editor:n,type:Gi(e.name,t.schema)},u=[],c=Vi(e,"addKeyboardShortcuts",r),l={};if("mark"===e.type&&e.config.exitable&&(l.ArrowRight=function(){return Xs.handleExit({editor:n,mark:e})}),c){var d=Object.fromEntries(Object.entries(c()).map((function(e){var t=(0,s.A)(e,2),r=t[0],o=t[1];return[r,function(){return o({editor:n})}]})));l=y(y({},l),d)}var f=function(e){return new Bt({props:{handleKeyDown:ui(e)}})}(l);u.push(f);var h=Vi(e,"addInputRules",r);Xi(e,n.options.enableInputRules)&&h&&i.push.apply(i,(0,o.A)(h()));var p=Vi(e,"addPasteRules",r);Xi(e,n.options.enablePasteRules)&&p&&a.push.apply(a,(0,o.A)(p()));var v=Vi(e,"addProseMirrorPlugins",r);if(v){var m=v();u.push.apply(u,(0,o.A)(m))}return u})).flat();return[ns({editor:n,rules:i})].concat((0,o.A)(is({editor:n,rules:a})),(0,o.A)(u))}},{key:"attributes",get:function(){return ji(this.extensions)}},{key:"nodeViews",get:function(){var e=this,t=this.editor,n=Fi(this.extensions).nodeExtensions;return Object.fromEntries(n.filter((function(e){return!!Vi(e,"addNodeView")})).map((function(n){var r=e.attributes.filter((function(e){return e.type===n.name})),o={name:n.name,options:n.options,storage:n.storage,editor:t,type:Hi(n.name,e.schema)},i=Vi(n,"addNodeView",o);return i?[n.name,function(e,o,s,a){var u=Ji(e,r);return i()({editor:t,node:e,getPos:s,decorations:a,HTMLAttributes:u,extension:n})}]:[]})))}},{key:"setupExtensions",value:function(){var e=this;this.extensions.forEach((function(t){var n;e.editor.extensionStorage[t.name]=t.storage;var r={name:t.name,options:t.options,storage:t.storage,editor:e.editor,type:Gi(t.name,e.schema)};"mark"===t.type&&(null===(n=Ki(Vi(t,"keepOnSplit",r)))||void 0===n||n)&&e.splittableMarks.push(t.name);var o=Vi(t,"onBeforeCreate",r),i=Vi(t,"onCreate",r),s=Vi(t,"onUpdate",r),a=Vi(t,"onSelectionUpdate",r),u=Vi(t,"onTransaction",r),c=Vi(t,"onFocus",r),l=Vi(t,"onBlur",r),d=Vi(t,"onDestroy",r);o&&e.editor.on("beforeCreate",o),i&&e.editor.on("create",i),s&&e.editor.on("update",s),a&&e.editor.on("selectionUpdate",a),u&&e.editor.on("transaction",u),c&&e.editor.on("focus",c),l&&e.editor.on("blur",l),d&&e.editor.on("destroy",d)}))}}],[{key:"resolve",value:function(t){var n,r,i=e.sort(e.flatten(t)),s=(r=(n=i.map((function(e){return e.name}))).filter((function(e,t){return n.indexOf(e)!==t})),(0,o.A)(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.")),i}},{key:"flatten",value:function(e){var t=this;return e.map((function(e){var n=Vi(e,"addExtensions",{name:e.name,options:e.options,storage:e.storage});return n?[e].concat((0,o.A)(t.flatten(n()))):e})).flat(10)}},{key:"sort",value:function(e){return e.sort((function(e,t){var n=Vi(e,"priority")||100,r=Vi(t,"priority")||100;return n>r?-1:n<r?1:0}))}}])}();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 us(e,t){var n=y({},e);return as(e)&&as(t)&&Object.keys(t).forEach((function(r){as(t[r])&&r in e?n[r]=us(e[r],t[r]):Object.assign(n,(0,i.A)({},r,t[r]))})),n}var cs=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(0,h.A)(this,e),this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config=y(y({},this.config),t),this.name=this.config.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&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=Ki(Vi(this,"addOptions",{name:this.name}))),this.storage=Ki(Vi(this,"addStorage",{name:this.name,options:this.options}))||{}}return(0,p.A)(e,[{key:"configure",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=this.extend();return t.parent=this.parent,t.options=us(this.options,e),t.storage=Ki(Vi(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(y(y({},this.config),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=Ki(Vi(n,"addOptions",{name:n.name})),n.storage=Ki(Vi(n,"addStorage",{name:n.name,options:n.options})),n}}],[{key:"create",value:function(){return new e(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})}}])}();function ls(e,t,n){var r=t.from,o=t.to,i=n||{},s=i.blockSeparator,a=void 0===s?"\n\n":s,u=i.textSerializers,c=void 0===u?{}:u,l="";return e.nodesBetween(r,o,(function(e,n,i,s){var u;e.isBlock&&n>r&&(l+=a);var d=null==c?void 0:c[e.type.name];if(d)return i&&(l+=d({node:e,pos:n,parent:i,index:s,range:t})),!1;e.isText&&(l+=null===(u=null==e?void 0:e.text)||void 0===u?void 0:u.slice(Math.max(r,n)-n,o-n))})),l}function ds(e){return Object.fromEntries(Object.entries(e.nodes).filter((function(e){return(0,s.A)(e,2)[1].spec.toText})).map((function(e){var t=(0,s.A)(e,2);return[t[0],t[1].spec.toText]})))}var fs=cs.create({name:"clipboardTextSerializer",addOptions:function(){return{blockSeparator:void 0}},addProseMirrorPlugins:function(){var e=this;return[new Bt({key:new Vt("clipboardTextSerializer"),props:{clipboardTextSerializer:function(){var t=e.editor,n=t.state,r=t.schema,i=n.doc,s=n.selection.ranges,a=Math.min.apply(Math,(0,o.A)(s.map((function(e){return e.$from.pos})))),u=Math.max.apply(Math,(0,o.A)(s.map((function(e){return e.$to.pos})))),c=ds(r);return ls(i,{from:a,to:u},y(y({},void 0!==e.options.blockSeparator?{blockSeparator:e.options.blockSeparator}:{}),{},{textSerializers:c}))}}})]}});function hs(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]:Qi(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&&hs(e.attrs,n)}))}function vs(e,t){return!!ps(e,t,arguments.length>2&&void 0!==arguments[2]?arguments[2]:{})}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 i=ps((0,o.A)(r.node.marks),t,n);if(i){var s=r.index,a=e.start()+r.offset,u=s+1,c=a+r.node.nodeSize;for(ps((0,o.A)(r.node.marks),t,n);s>0&&i.isInSet(e.parent.child(s-1).marks);)s-=1,a-=e.parent.child(s).nodeSize;for(;u<e.parent.childCount&&vs((0,o.A)(e.parent.child(u).marks),t,n);)c+=e.parent.child(u).nodeSize,u+=1;return{from:a,to:c}}}}}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 wt}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 bs(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(!t)return null;var n=gt.atStart(e),r=gt.atEnd(e);if("start"===t||!0===t)return n;if("end"===t)return r;var o=n.from,i=r.to;return"all"===t?wt.create(e,ks(0,o,i),ks(e.content.size,o,i)):wt.create(e,ks(t,o,i),ks(t,o,i))}function ws(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var xs=function e(t){for(var n=t.childNodes,r=n.length-1;r>=0;r-=1){var o=n[r];3===o.nodeType&&o.nodeValue&&/^(\n\s\s|\n)$/.test(o.nodeValue)?t.removeChild(o):1===o.nodeType&&e(o)}return t};function Ms(e){var t="<body>".concat(e,"</body>"),n=(new window.DOMParser).parseFromString(t,"text/html").body;return xs(n)}function Ss(e,t,n){n=y({slice:!0,parseOptions:{}},n);var r="string"==typeof e;if("object"===(0,f.A)(e)&&null!==e)try{return Array.isArray(e)&&e.length>0?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),Ss("",t,n)}if(r){var o=ge.fromSchema(t);return n.slice?o.parseSlice(Ms(e),n.parseOptions).content:o.parse(Ms(e),n.parseOptions)}return Ss("",t,n)}function As(){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,o=r.from,i=r.to,s=r.empty,a=t?Hi(t,e.schema):null,u=[];e.doc.nodesBetween(o,i,(function(e,t){if(!e.isText){var n=Math.max(o,t),r=Math.min(i,t+e.nodeSize);u.push({node:e,from:n,to:r})}}));var c=i-o,l=u.filter((function(e){return!a||a.name===e.node.type.name})).filter((function(e){return hs(e.node.attrs,n,{strict:!1})}));return s?!!l.length:l.reduce((function(e,t){return e+t.to-t.from}),0)>=c}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){return Ss(e,t,{slice:!1,parseOptions:arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}})}function Es(e,t){var n=gs(t,e.schema),r=e.selection,i=r.from,s=r.to,a=r.empty,u=[];a?(e.storedMarks&&u.push.apply(u,(0,o.A)(e.storedMarks)),u.push.apply(u,(0,o.A)(e.selection.$head.marks()))):e.doc.nodesBetween(i,s,(function(e){u.push.apply(u,(0,o.A)(e.marks))}));var c=u.find((function(e){return e.type.name===n.name}));return c?y({},c.attrs):{}}function Ds(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 Ps(e,t,n){var r=[];return e===t?n.resolve(e).marks().forEach((function(t){var o=ms(n.resolve(e-1),t.type);o&&r.push(y({mark:t},o))})):n.nodesBetween(e,t,(function(e,t){e&&void 0!==(null==e?void 0:e.nodeSize)&&r.push.apply(r,(0,o.A)(e.marks.map((function(n){return{from:t,to:t+e.nodeSize,mark:n}}))))})),r}function Is(e,t,n){return Object.fromEntries(Object.entries(n).filter((function(n){var r=(0,s.A)(n,1)[0],o=e.find((function(e){return e.type===t&&e.name===r}));return!!o&&o.attribute.keepOnSplit})))}function Rs(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=e.selection,i=r.empty,s=r.ranges,a=t?gs(t,e.schema):null;if(i)return!!(e.storedMarks||e.selection.$from.marks()).filter((function(e){return!a||a.name===e.type.name})).find((function(e){return hs(e.attrs,n,{strict:!1})}));var u=0,c=[];if(s.forEach((function(t){var n=t.$from,r=t.$to,i=n.pos,s=r.pos;e.doc.nodesBetween(i,s,(function(e,t){if(e.isText||e.marks.length){var n=Math.max(i,t),r=Math.min(s,t+e.nodeSize);u+=r-n,c.push.apply(c,(0,o.A)(e.marks.map((function(e){return{mark:e,from:n,to:r}}))))}}))})),0===u)return!1;var l=c.filter((function(e){return!a||a.name===e.mark.type.name})).filter((function(e){return hs(e.mark.attrs,n,{strict:!1})})).reduce((function(e,t){return e+t.to-t.from}),0),d=c.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);return(l>0?l+d:l)>=u}function zs(e,t){var n=Fi(t).nodeExtensions.find((function(t){return t.name===e}));if(!n)return!1;var r=Ki(Vi(n,"group",{name:n.name,options:n.options,storage:n.storage}));return"string"==typeof r&&r.split(" ").includes("list")}function Bs(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=Ds((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 o=e.doc.nodeAt(r);return n.node.type!==(null==o?void 0:o.type)||!Qe(e.doc,n.pos)||(e.join(n.pos),!0)},$s=function(e,t){var n=Ds((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 o=e.doc.nodeAt(r);return n.node.type!==(null==o?void 0:o.type)||!Qe(e.doc,r)||(e.join(r),!0)},Vs=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,o=n.selection.ranges;return!r||(o.forEach((function(e){var r=e.$from,o=e.$to;t.doc.nodesBetween(r.pos,o.pos,(function(e,t){if(!e.type.isText){var r=n.doc,o=n.mapping,i=r.resolve(o.map(t)),s=r.resolve(o.map(t+e.nodeSize)),a=i.blockRange(s);if(a){var u=Ue(a);if(e.type.isTextblock){var c=i.parent.contentMatchAt(i.index()).defaultType;n.setNodeMarkup(a.start,c)}(u||0===u)&&n.lift(a,u)}}}))})),!0)}},command:function(e){return function(t){return e(t)}},createParagraphNear:function(){return function(e){var t=e.state,n=e.dispatch;return Mi(t,n)}},cut:function(e,t){return function(n){var r=n.editor,o=n.tr,i=r.state.doc.slice(e.from,e.to);o.deleteRange(e.from,e.to);var s=o.mapping.map(t);return o.insert(s,i.content),o.setSelection(new wt(o.doc.resolve(s-1))),!0}},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 o=t.selection.$anchor,i=o.depth;i>0;i-=1)if(o.node(i).type===r.type){if(n){var s=o.before(i),a=o.after(i);t.delete(s,a).scrollIntoView()}return!0}return!1}},deleteNode:function(e){return function(t){for(var n=t.tr,r=t.state,o=t.dispatch,i=Hi(e,r.schema),s=n.selection.$anchor,a=s.depth;a>0;a-=1)if(s.node(a).type===i){if(o){var u=s.before(a),c=s.after(a);n.delete(u,c).scrollIntoView()}return!0}return!1}},deleteRange:function(e){return function(t){var n=t.tr,r=t.dispatch,o=e.from,i=e.to;return r&&n.delete(o,i),!0}},deleteSelection:function(){return function(e){var t=e.state,n=e.dispatch;return ci(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 xi(t,n)}},extendMarkRange:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var r=n.tr,o=n.state,i=n.dispatch,s=gs(e,o.schema),a=r.doc,u=r.selection,c=u.$from,l=u.from,d=u.to;if(i){var f=ms(c,s,t);if(f&&f.from<=l&&f.to>=d){var h=wt.create(a,f.from,f.to);r.setSelection(h)}}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,o=n.view,i=n.tr,s=n.dispatch;t=y({scrollIntoView:!0},t);var a=function(){ws()&&o.dom.focus(),requestAnimationFrame((function(){r.isDestroyed||(o.focus(),(null==t?void 0:t.scrollIntoView)&&r.commands.scrollIntoView())}))};if(o.hasFocus()&&null===e||!1===e)return!0;if(s&&null===e&&!ys(r.state.selection))return a(),!0;var u=bs(i.doc,e)||r.state.selection,c=r.state.selection.eq(u);return s&&(c||i.setSelection(u),c&&i.storedMarks&&i.setStoredMarks(i.storedMarks),a()),!0}},forEach:function(e,t){return function(n){return e.every((function(e,r){return t(e,y(y({},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 o=r.tr,i=r.dispatch,s=r.editor;if(i){n=y({parseOptions:{},updateSelection:!0,applyInputRules:!1,applyPasteRules:!1},n);var a=Ss(t,s.schema,{parseOptions:y({preserveWhitespace:"full"},n.parseOptions)});if("<>"===a.toString())return!0;var u,c="number"==typeof e?{from:e,to:e}:{from:e.from,to:e.to},l=c.from,d=c.to,h=!0,p=!0;if((a.toString().startsWith("<")?a:[a]).forEach((function(e){e.check(),h=!!h&&e.isText&&0===e.marks.length,p=!!p&&e.isBlock})),l===d&&p){var v=o.doc.resolve(l).parent;v.isTextblock&&!v.type.spec.code&&!v.childCount&&(l-=1,d+=1)}h?(u=Array.isArray(t)?t.map((function(e){return e.text||""})).join(""):"object"===(0,f.A)(t)&&t&&t.text?t.text:t,o.insertText(u,l,d)):(u=a,o.replaceWith(l,d,u)),n.updateSelection&&function(e,t,n){var r=e.steps.length-1;if(!(r<t)){var o=e.steps[r];if(o instanceof qe||o instanceof Je){var i=e.mapping.maps[r],s=0;i.forEach((function(e,t,n,r){0===s&&(s=r)})),e.setSelection(gt.near(e.doc.resolve(s),-1))}}}(o,o.steps.length-1),n.applyInputRules&&o.setMeta("applyInputRules",{from:l,text:u}),n.applyPasteRules&&o.setMeta("applyPasteRules",{from:l,text:u})}return!0}},joinUp:function(){return function(e){return function(e,t){var n,r=e.selection,o=r instanceof Mt;if(o){if(r.node.isTextblock||!Qe(e.doc,r.from))return!1;n=r.from}else if(null==(n=et(e.doc,r.from,-1)))return!1;if(t){var i=e.tr.join(n);o&&i.setSelection(Mt.create(i.doc,n-e.doc.resolve(n).nodeBefore.nodeSize)),t(i.scrollIntoView())}return!0}(e.state,e.dispatch)}},joinDown:function(){return function(e){return function(e,t){var n,r=e.selection;if(r instanceof Mt){if(r.node.isTextblock||!Qe(e.doc,r.to))return!1;n=r.to}else if(null==(n=et(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 di(t,n)}},joinForward:function(){return function(e){var t=e.state,n=e.dispatch;return gi(t,n)}},joinItemBackward:function(){return function(e){var t=e.tr,n=e.state,r=e.dispatch;try{var o=et(n.doc,n.selection.$from.pos,-1);return null!=o&&(t.join(o,2),r&&r(t),!0)}catch(e){return!1}}},joinItemForward:function(){return function(e){var t=e.state,n=e.dispatch,r=e.tr;try{var o=et(t.doc,t.selection.$from.pos,1);return null!=o&&(r.join(o,2),n&&n(r),!0)}catch(e){return!1}}},joinTextblockBackward:function(){return function(e){return function(e,t,n){var r=li(e,void 0);if(!r)return!1;var o=vi(r);return!!o&&fi(e,o,t)}(e.state,e.dispatch)}},joinTextblockForward:function(){return function(e){return function(e,t,n){var r=mi(e,void 0);if(!r)return!1;var o=ki(r);return!!o&&fi(e,o,t)}(e.state,e.dispatch)}},keyboardShortcut:function(e){return function(t){var n=t.editor,r=t.view,o=t.tr,i=t.dispatch,s=function(e){var t,n,r,o,i=e.split(/-(?!$)/),s=i[i.length-1];"Space"===s&&(s=" ");for(var a=0;a<i.length-1;a+=1){var u=i[a];if(/^(cmd|meta|m)$/i.test(u))o=!0;else if(/^a(lt)?$/i.test(u))t=!0;else if(/^(c|ctrl|control)$/i.test(u))n=!0;else if(/^s(hift)?$/i.test(u))r=!0;else{if(!/^mod$/i.test(u))throw new Error("Unrecognized modifier name: ".concat(u));ws()||As()?o=!0:n=!0}}return t&&(s="Alt-".concat(s)),n&&(s="Ctrl-".concat(s)),o&&(s="Meta-".concat(s)),r&&(s="Shift-".concat(s)),s}(e).split(/-(?!$)/),a=s.find((function(e){return!["Alt","Ctrl","Meta","Shift"].includes(e)})),u=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}),c=n.captureTransaction((function(){r.someProp("handleKeyDown",(function(e){return e(r,u)}))}));return null==c||c.steps.forEach((function(e){var t=e.map(o.mapping);t&&i&&o.maybeStep(t)})),!0}},lift:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var r=n.state,o=n.dispatch;return!!Cs(r,Hi(e,r.schema),t)&&function(e,t){var n=e.selection,r=n.$from,o=n.$to,i=r.blockRange(o),s=i&&Ue(i);return null!=s&&(t&&t(e.tr.lift(i,s).scrollIntoView()),!0)}(r,o)}},liftEmptyBlock:function(){return function(e){var t=e.state,n=e.dispatch;return Si(t,n)}},liftListItem:function(e){return function(t){var n,r=t.state,o=t.dispatch;return(n=Hi(e,r.schema),function(e,t){var r=e.selection,o=r.$from,i=r.$to,s=o.blockRange(i,(function(e){return e.childCount>0&&e.firstChild.type==n}));return!!s&&(!t||(o.node(s.depth-1).type==n?function(e,t,n,r){var o=e.tr,i=r.end,s=r.$to.end(r.depth);i<s&&(o.step(new Je(i-1,s,i,s,new P(C.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new U(o.doc.resolve(r.$from.pos),o.doc.resolve(s),r.depth));var a=Ue(r);if(null==a)return!1;o.lift(r,a);var u=o.mapping.map(i,-1)-1;return Qe(o.doc,u)&&o.join(u),t(o.scrollIntoView()),!0}(e,t,n,s):function(e,t,n){for(var r=e.tr,o=n.parent,i=n.end,s=n.endIndex-1,a=n.startIndex;s>a;s--)i-=o.child(s).nodeSize,r.delete(i-1,i+1);var u=r.doc.resolve(n.start),c=u.nodeAfter;if(r.mapping.map(n.end)!=n.start+u.nodeAfter.nodeSize)return!1;var l=0==n.startIndex,d=n.endIndex==o.childCount,f=u.node(-1),h=u.index(-1);if(!f.canReplace(h+(l?0:1),h+1,c.content.append(d?C.empty:C.from(o))))return!1;var p=u.pos,v=p+c.nodeSize;return r.step(new Je(p-(l?1:0),v+(d?1:0),p+1,v-1,new P((l?C.empty:C.from(o.copy(C.empty))).append(d?C.empty:C.from(o.copy(C.empty))),l?0:1,d?0:1),l?0:1)),t(r.scrollIntoView()),!0}(e,t,s)))})(r,o)}},newlineInCode:function(){return function(e){var t=e.state,n=e.dispatch;return bi(t,n)}},resetAttributes:function(e,t){return function(n){var r=n.tr,o=n.state,i=n.dispatch,s=null,a=null,u=Os("string"==typeof e?e:e.name,o.schema);return!!u&&("node"===u&&(s=Hi(e,o.schema)),"mark"===u&&(a=gs(e,o.schema)),i&&r.selection.ranges.forEach((function(e){o.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(o){a===o.type&&r.addMark(n,n+e.nodeSize,a.create(Ts(o.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 pi(t,n)}},selectNodeForward:function(){return function(e){var t=e.state,n=e.dispatch;return yi(t,n)}},selectParentNode:function(){return function(e){return t=e.state,n=e.dispatch,o=t.selection,i=o.$from,s=o.to,0!=(a=i.sharedDepth(s))&&(r=i.before(a),n&&n(t.tr.setSelection(Mt.create(t.doc,r))),!0);var t,n,r,o,i,s,a}},selectTextblockEnd:function(){return function(e){var t=e.state,n=e.dispatch;return Ti(t,n)}},selectTextblockStart:function(){return function(e){var t=e.state,n=e.dispatch;return Oi(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 o=r.tr,i=r.editor,s=r.dispatch,a=o.doc,u=Ns(e,i.schema,n);return s&&o.replaceWith(0,a.content.size,u).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,o=n.state,i=n.dispatch,s=r.selection,a=s.empty,u=s.ranges,c=gs(e,o.schema);if(i)if(a){var l=Es(o,c);r.addStoredMark(c.create(y(y({},l),t)))}else u.forEach((function(e){var n=e.$from.pos,i=e.$to.pos;o.doc.nodesBetween(n,i,(function(e,o){var s=Math.max(o,n),a=Math.min(o+e.nodeSize,i);e.marks.find((function(e){return e.type===c}))?e.marks.forEach((function(e){c===e.type&&r.addMark(s,a,c.create(y(y({},e.attrs),t)))})):r.addMark(s,a,c.create(t))}))}));return function(e,t,n){var r,o=t.selection,i=null;if(ys(o)&&(i=o.$cursor),i){var s=null!==(r=e.storedMarks)&&void 0!==r?r:i.marks();return!!n.isInSet(s)||!s.some((function(e){return e.type.excludes(n)}))}return o.ranges.some((function(t){var r=t.$from,o=t.$to,i=0===r.depth&&e.doc.inlineContent&&e.doc.type.allowsMarkType(n);return e.doc.nodesBetween(r.pos,o.pos,(function(e,t,r){if(i)return!1;if(e.isInline){var o=!r||r.type.allowsMarkType(n),s=!!n.isInSet(e.marks)||!e.marks.some((function(e){return e.type.excludes(n)}));i=o&&s}return!i})),i}))}(o,r,c)}},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,o=n.dispatch,i=n.chain,s=Hi(e,r.schema);return s.isTextblock?i().command((function(e){var n=e.commands;return!!Ni(s,t)(r)||n.clearNodes()})).command((function(e){var n=e.state;return Ni(s,t)(n,o)})).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,o=ks(e,0,r.content.size),i=Mt.create(r,o);n.setSelection(i)}return!0}},setTextSelection:function(e){return function(t){var n=t.tr;if(t.dispatch){var r=n.doc,o="number"==typeof e?{from:e,to:e}:e,i=o.from,s=o.to,a=wt.atStart(r).from,u=wt.atEnd(r).to,c=ks(i,a,u),l=ks(s,a,u),d=wt.create(r,c,l);n.setSelection(d)}return!0}},sinkListItem:function(e){return function(t){var n,r=t.state,o=t.dispatch,i=Hi(e,r.schema);return(n=i,function(e,t){var r=e.selection,o=r.$from,i=r.$to,s=o.blockRange(i,(function(e){return e.childCount>0&&e.firstChild.type==n}));if(!s)return!1;var a=s.startIndex;if(0==a)return!1;var u=s.parent,c=u.child(a-1);if(c.type!=n)return!1;if(t){var l=c.lastChild&&c.lastChild.type==u.type,d=C.from(l?n.create():null),f=new P(C.from(n.create(null,C.from(u.type.create(null,d)))),l?3:1,0),h=s.start,p=s.end;t(e.tr.step(new Je(h-(l?3:1),p,h,p,f,1,!0)).scrollIntoView())}return!0})(r,o)}},splitBlock:function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).keepMarks,t=void 0===e||e;return function(e){var n=e.tr,r=e.state,o=e.dispatch,i=e.editor,s=n.selection,a=n.doc,u=s.$from,c=s.$to,l=Is(i.extensionManager.attributes,u.node().type.name,u.node().attrs);if(s instanceof Mt&&s.node.isBlock)return!(!u.parentOffset||!Ye(a,u.pos)||(o&&(t&&Bs(r,i.extensionManager.splittableMarks),n.split(u.pos).scrollIntoView()),0));if(!u.parent.isBlock)return!1;if(o){var d=c.parentOffset===c.parent.content.size;s instanceof wt&&n.deleteSelection();var f=0===u.depth?void 0:function(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}(u.node(-1).contentMatchAt(u.indexAfter(-1))),h=d&&f?[{type:f,attrs:l}]:void 0,p=Ye(n.doc,n.mapping.map(u.pos),1,h);if(h||p||!Ye(n.doc,n.mapping.map(u.pos),1,f?[{type:f}]:void 0)||(p=!0,h=f?[{type:f,attrs:l}]:void 0),p&&(n.split(n.mapping.map(u.pos),1,h),f&&!d&&!u.parentOffset&&u.parent.type!==f)){var v=n.mapping.map(u.before()),m=n.doc.resolve(v);u.node(-1).canReplaceWith(m.index(),m.index()+1,f)&&n.setNodeMarkup(n.mapping.map(u.before()),f)}t&&Bs(r,i.extensionManager.splittableMarks),n.scrollIntoView()}return!0}},splitListItem:function(e){return function(t){var n,r=t.tr,o=t.state,i=t.dispatch,s=t.editor,a=Hi(e,o.schema),u=o.selection,c=u.$from,l=u.$to,d=o.selection.node;if(d&&d.isBlock||c.depth<2||!c.sameParent(l))return!1;var f=c.node(-1);if(f.type!==a)return!1;var h=s.extensionManager.attributes;if(0===c.parent.content.size&&c.node(-1).childCount===c.indexAfter(-1)){if(2===c.depth||c.node(-3).type!==a||c.index(-2)!==c.node(-2).childCount-1)return!1;if(i){for(var p=C.empty,v=c.index(-1)?1:c.index(-2)?2:3,m=c.depth-v;m>=c.depth-3;m-=1)p=C.from(c.node(m).copy(p));var g=c.indexAfter(-1)<c.node(-2).childCount?1:c.indexAfter(-2)<c.node(-3).childCount?2:3,y=Is(h,c.node().type.name,c.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 b=c.before(c.depth-(v-1));r.replace(b,c.after(-g),new P(p,4-v,0));var w=-1;r.doc.nodesBetween(b,r.doc.content.size,(function(e,t){if(w>-1)return!1;e.isTextblock&&0===e.content.size&&(w=t+1)})),w>-1&&r.setSelection(wt.near(r.doc.resolve(w))),r.scrollIntoView()}return!0}var x=l.pos===c.end()?f.contentMatchAt(0).defaultType:null,M=Is(h,f.type.name,f.attrs),S=Is(h,c.node().type.name,c.node().attrs);r.delete(c.pos,l.pos);var A=x?[{type:a,attrs:M},{type:x,attrs:S}]:[{type:a,attrs:M}];if(!Ye(r.doc,c.pos,2))return!1;if(i){var O=o.selection,T=o.storedMarks,N=s.extensionManager.splittableMarks,E=T||O.$to.parentOffset&&O.$from.marks();if(r.split(c.pos,2,A).scrollIntoView(),!E||!i)return!0;var D=E.filter((function(e){return N.includes(e.type.name)}));r.ensureMarks(D)}return!0}},toggleList:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return function(o){var i=o.editor,s=o.tr,a=o.state,u=o.dispatch,c=o.chain,l=o.commands,d=o.can,f=i.extensionManager,h=f.extensions,p=f.splittableMarks,v=Hi(e,a.schema),m=Hi(t,a.schema),g=a.selection,y=a.storedMarks,k=g.$from,b=g.$to,w=k.blockRange(b),x=y||g.$to.parentOffset&&g.$from.marks();if(!w)return!1;var M=Ds((function(e){return zs(e.type.name,h)}))(g);if(w.depth>=1&&M&&w.depth-M.depth<=1){if(M.node.type===v)return l.liftListItem(m);if(zs(M.node.type.name,h)&&v.validContent(M.node.content)&&u)return c().command((function(){return s.setNodeMarkup(M.pos,v),!0})).command((function(){return Ls(s,v)})).command((function(){return $s(s,v)})).run()}return n&&x&&u?c().command((function(){var e=d().wrapInList(v,r),t=x.filter((function(e){return p.includes(e.type.name)}));return s.ensureMarks(t),!!e||l.clearNodes()})).wrapInList(v,r).command((function(){return Ls(s,v)})).command((function(){return $s(s,v)})).run():c().command((function(){return!!d().wrapInList(v,r)||l.clearNodes()})).wrapInList(v,r).command((function(){return Ls(s,v)})).command((function(){return $s(s,v)})).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 o=r.state,i=r.commands,s=n.extendEmptyMarkRange,a=void 0!==s&&s,u=gs(e,o.schema);return Rs(o,u,t)?i.unsetMark(u,{extendEmptyMarkRange:a}):i.setMark(u,t)}},toggleNode:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return function(r){var o=r.state,i=r.commands,s=Hi(e,o.schema),a=Hi(t,o.schema);return Cs(o,s,n)?i.setNode(a):i.setNode(s,n)}},toggleWrap:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var r=n.state,o=n.commands,i=Hi(e,r.schema);return Cs(r,i,t)?o.lift(i):o.wrapIn(i,t)}},undoInputRule:function(){return function(e){for(var t=e.state,n=e.dispatch,r=t.plugins,o=0;o<r.length;o+=1){var i=r[o],s=void 0;if(i.spec.isInputRules&&(s=i.getState(t))){if(n){for(var a=t.tr,u=s.transform,c=u.steps.length-1;c>=0;c-=1)a.step(u.steps[c].invert(u.docs[c]));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,o=r.empty,i=r.ranges;return o||n&&i.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,o=n.tr,i=n.state,s=n.dispatch,a=t.extendEmptyMarkRange,u=void 0!==a&&a,c=o.selection,l=gs(e,i.schema),d=c.$from,f=c.empty,h=c.ranges;if(!s)return!0;if(f&&u){var p=c.from,v=c.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),o.removeMark(p,v,l)}else h.forEach((function(e){o.removeMark(e.$from.pos,e.$to.pos,l)}));return o.removeStoredMark(l),!0}},updateAttributes:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var r=n.tr,o=n.state,i=n.dispatch,s=null,a=null,u=Os("string"==typeof e?e:e.name,o.schema);return!!u&&("node"===u&&(s=Hi(e,o.schema)),"mark"===u&&(a=gs(e,o.schema)),i&&r.selection.ranges.forEach((function(e){var n=e.$from.pos,i=e.$to.pos;o.doc.nodesBetween(n,i,(function(e,o){s&&s===e.type&&r.setNodeMarkup(o,void 0,y(y({},e.attrs),t)),a&&e.marks.length&&e.marks.forEach((function(s){if(a===s.type){var u=Math.max(o,n),c=Math.min(o+e.nodeSize,i);r.addMark(u,c,a.create(y(y({},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,o=n.dispatch;return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return function(n,r){var o=n.selection,i=o.$from,s=o.$to,a=i.blockRange(s),u=a&&Ge(a,e,t);return!!u&&(r&&r(n.tr.wrap(a,u).scrollIntoView()),!0)}}(Hi(e,r.schema),t)(r,o)}},wrapInList:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n){var r=n.state,o=n.dispatch;return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return function(n,r){var o=n.selection,i=o.$from,s=o.$to,a=i.blockRange(s),u=!1,c=a;if(!a)return!1;if(a.depth>=2&&i.node(a.depth-1).type.compatibleContent(e)&&0==a.startIndex){if(0==i.index(a.depth-1))return!1;var l=n.doc.resolve(a.start-2);c=new U(l,l,a.depth),a.endIndex<a.parent.childCount&&(a=new U(i,n.doc.resolve(s.end(a.depth)),a.depth)),u=!0}var d=Ge(c,e,t,a);return!!d&&(r&&r(function(e,t,n,r,o){for(var i=C.empty,s=n.length-1;s>=0;s--)i=C.from(n[s].type.create(n[s].attrs,i));e.step(new Je(t.start-(r?2:0),t.end,t.start,t.end,new P(i,0,0),n.length,!0));for(var a=0,u=0;u<n.length;u++)n[u].type==o&&(a=u+1);for(var c=n.length-a,l=t.start+n.length-(r?2:0),d=t.parent,f=t.startIndex,h=t.endIndex,p=!0;f<h;f++,p=!1)!p&&Ye(e.doc,l,c)&&(e.split(l,c),l+=2*c),l+=d.child(f).nodeSize;return e}(n.tr,a,d,u,e).scrollIntoView()),!0)}}(Hi(e,r.schema),t)(r,o)}}}),Fs=cs.create({name:"commands",addCommands:function(){return y({},Vs)}}),js=cs.create({name:"editable",addProseMirrorPlugins:function(){var e=this;return[new Bt({key:new Vt("editable"),props:{editable:function(){return e.editor.options.editable}}})]}}),Hs=cs.create({name:"focusEvents",addProseMirrorPlugins:function(){var e=this.editor;return[new Bt({key:new Vt("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}}}})]}}),qs=cs.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,o=n.doc,i=r.empty,s=r.$anchor,a=s.pos,u=s.parent,c=s.parent.isTextblock&&a>0?n.doc.resolve(a-1):s,l=c.parent.type.spec.isolating,d=s.pos-s.parentOffset,f=l&&1===c.parent.childCount?d===s.pos:gt.atStart(o).from===a;return!(!i||!u.type.isTextblock||u.textContent.length||!f||f&&"paragraph"===s.parent.type.name)&&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()}},o=y({},r),i=y(y({},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 ws()||As()?i:o},addProseMirrorPlugins:function(){var e=this;return[new Bt({key:new Vt("clearDocument"),appendTransaction:function(t,n,r){if(t.some((function(e){return e.docChanged}))&&!n.doc.eq(r.doc)){var o=n.selection,i=o.empty,s=o.from,a=o.to,u=gt.atStart(n.doc).from,c=gt.atEnd(n.doc).to;if(!i&&s===u&&a===c&&0===r.doc.textBetween(0,r.doc.content.size," "," ").length){var l=r.tr,d=Bi({state:r,transaction:l});if(new Li({editor:e.editor,state:d}).commands.clearNodes(),l.steps.length)return l}}}})]}}),Js=cs.create({name:"tabindex",addProseMirrorPlugins:function(){return[new Bt({key:new Vt("tabindex"),props:{attributes:this.editor.isEditable?{tabindex:"0"}:{}}})]}}),Ws=function(){function e(t,n){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;(0,h.A)(this,e),this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=t,this.editor=n,this.currentNode=o}return(0,p.A)(e,[{key:"name",get:function(){return this.node.type.name}},{key:"node",get:function(){return this.currentNode||this.resolvedPos.node()}},{key:"element",get:function(){return this.editor.view.domAtPos(this.pos).node}},{key:"depth",get:function(){var e;return null!==(e=this.actualDepth)&&void 0!==e?e:this.resolvedPos.depth}},{key:"pos",get:function(){return this.resolvedPos.pos}},{key:"content",get:function(){return this.node.content},set:function(e){var t=this.from,n=this.to;if(this.isBlock){if(0===this.content.size)return void console.error("You can’t set content on a block node. Tried to set content on ".concat(this.name," at ").concat(this.pos));t=this.from+1,n=this.to-1}this.editor.commands.insertContentAt({from:t,to:n},e)}},{key:"attributes",get:function(){return this.node.attrs}},{key:"textContent",get:function(){return this.node.textContent}},{key:"size",get:function(){return this.node.nodeSize}},{key:"from",get:function(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}},{key:"range",get:function(){return{from:this.from,to:this.to}}},{key:"to",get:function(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}},{key:"parent",get:function(){if(0===this.depth)return null;var t=this.resolvedPos.start(this.resolvedPos.depth-1);return new e(this.resolvedPos.doc.resolve(t),this.editor)}},{key:"before",get:function(){var t=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.from-3)),new e(t,this.editor)}},{key:"after",get:function(){var t=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.to+3)),new e(t,this.editor)}},{key:"children",get:function(){var t=this,n=[];return this.node.content.forEach((function(r,o){var i=r.isBlock&&!r.isTextblock,s=t.pos+o+1,a=t.resolvedPos.doc.resolve(s);if(i||!(a.depth<=t.depth)){var u=new e(a,t.editor,i,i?r:null);i&&(u.actualDepth=t.depth+1),n.push(new e(a,t.editor,i,i?r:null))}})),n}},{key:"firstChild",get:function(){return this.children[0]||null}},{key:"lastChild",get:function(){var e=this.children;return e[e.length-1]||null}},{key:"closest",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=null,r=this.parent;r&&!n;)r.node.type.name===e&&(Object.keys(t).length>0||(n=r)),r=r.parent;return n}},{key:"querySelector",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.querySelectorAll(e,t,!0)[0]||null}},{key:"querySelectorAll",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=[];if(!this.children||0===this.children.length)return r;var o=Object.keys(t);return this.children.forEach((function(i){if(!(n&&r.length>0)){if(i.node.type.name===e){var s=o.every((function(e){return t[e]===i.node.attrs[e]}));s&&r.push(i)}n&&r.length>0||(r=r.concat(i.querySelectorAll(e,t,n)))}})),r}},{key:"setAttribute",value:function(e){var t=this.editor.state.selection;this.editor.chain().setTextSelection(this.from).updateAttributes(this.node.type.name,e).setTextSelection(t.from).run()}}])}(),Ks=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return(0,h.A)(this,t),(e=w(this,t)).isFocused=!1,e.extensionStorage={},e.options={element:document.createElement("div"),content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},coreExtensionOptions:{},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(n),e.createExtensionManager(),e.createCommandManager(),e.createSchema(),e.on("beforeCreate",e.options.onBeforeCreate),e.emit("beforeCreate",{editor: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:e}))}),0),e}return(0,l.A)(t,e),(0,p.A)(t,[{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,n){var r=document.querySelector("style[data-tiptap-style".concat("","]"));if(null!==r)return r;var o=document.createElement("style");return t&&o.setAttribute("nonce",t),o.setAttribute("data-tiptap-style".concat(""),""),o.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(o),o}(0,this.options.injectNonce))}},{key:"setOptions",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.options=y(y({},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=Wi(t)?t(e,(0,o.A)(this.state.plugins)):[].concat((0,o.A)(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,t,n=this.options.enableCoreExtensions?[js,fs.configure({blockSeparator:null===(t=null===(e=this.options.coreExtensionOptions)||void 0===e?void 0:e.clipboardTextSerializer)||void 0===t?void 0:t.blockSeparator}),Fs,Hs,qs,Js]:[],r=[].concat(n,(0,o.A)(this.options.extensions)).filter((function(e){return["extension","node","mark"].includes(null==e?void 0:e.type)}));this.extensionManager=new ss(r,this)}},{key:"createCommandManager",value:function(){this.commandManager=new Li({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=bs(e,this.options.autofocus);this.view=new _o(this.options.element,y(y({},this.options.editorProps),{},{dispatchTransaction:this.dispatchTransaction.bind(this),state:Rt.create({doc:e,selection:t||void 0})}));var n=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(n),this.createNodeViews(),this.prependClass(),this.view.dom.editor=this}},{key:"createNodeViews",value:function(){this.view.setProps({nodeViews:this.extensionManager.nodeViews})}},{key:"prependClass",value:function(){this.view.dom.className="tiptap ".concat(this.view.dom.className)}},{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.view.isDestroyed){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 o=e.getMeta("focus"),i=e.getMeta("blur");o&&this.emit("focus",{editor:this,event:o.event,transaction:e}),i&&this.emit("blur",{editor:this,event:i.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=Hi(t,e.schema),r=e.selection,o=r.from,i=r.to,s=[];e.doc.nodesBetween(o,i,(function(e){s.push(e)}));var a=s.reverse().find((function(e){return e.type.name===n.name}));return a?y({},a.attrs):{}}(t,n):"mark"===r?Es(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)||Rs(e,null,n);var r=Os(t,e.schema);return"node"===r?Cs(e,t,n):"mark"===r&&Rs(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,o=t.textSerializers,i=void 0===o?{}:o;return function(e,t){return ls(e,{from:0,to:e.content.size},t)}(this.state.doc,{blockSeparator:r,textSerializers:y(y({},ds(this.schema)),i)})}},{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)}},{key:"$node",value:function(e,t){var n;return(null===(n=this.$doc)||void 0===n?void 0:n.querySelector(e,t))||null}},{key:"$nodes",value:function(e,t){var n;return(null===(n=this.$doc)||void 0===n?void 0:n.querySelectorAll(e,t))||null}},{key:"$pos",value:function(e){var t=this.state.doc.resolve(e);return new Ws(t,this)}},{key:"$doc",get:function(){return this.$pos(0)}}])}($i);function _s(e){return new Zi({find:e.find,handler:function(t){var n=t.state,r=t.range,o=t.match,i=Ki(e.getAttributes,void 0,o);if(!1===i||null===i)return null;var s=n.tr,a=o[o.length-1],u=o[0];if(a){var c=u.search(/\S/),l=r.from+u.indexOf(a),d=l+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>l})).length)return null;d<r.to&&s.delete(d,r.to),l>r.from&&s.delete(r.from+c,l);var f=r.from+c+a.length;s.addMark(r.from+c,f,e.type.create(i||{})),s.removeStoredMark(e.type)}}})}function Us(e){return new Zi({find:e.find,handler:function(t){var n=t.state,r=t.range,o=t.match,i=n.doc.resolve(r.from),s=Ki(e.getAttributes,void 0,o)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.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 Zi({find:e.find,handler:function(t){var n=t.state,r=t.range,o=t.match,i=t.chain,s=Ki(e.getAttributes,void 0,o)||{},a=n.tr.delete(r.from,r.to),u=a.doc.resolve(r.from).blockRange(),c=u&&Ge(u,e.type,s);if(!c)return null;if(a.wrap(u,c),e.keepMarks&&e.editor){var l=n.selection,d=n.storedMarks,f=e.editor.extensionManager.splittableMarks,h=d||l.$to.parentOffset&&l.$from.marks();if(h){var p=h.filter((function(e){return f.includes(e.type.name)}));a.ensureMarks(p)}}if(e.keepAttributes){var v="bulletList"===e.type.name||"orderedList"===e.type.name?"listItem":"taskList";i().updateAttributes(v,s).run()}var m=a.doc.resolve(r.from-1).nodeBefore;m&&m.type===e.type&&Qe(a.doc,r.from-1)&&(!e.joinPredicate||e.joinPredicate(o,m))&&a.join(r.from-1)}})}var Xs=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(0,h.A)(this,e),this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config=y(y({},this.config),t),this.name=this.config.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&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=Ki(Vi(this,"addOptions",{name:this.name}))),this.storage=Ki(Vi(this,"addStorage",{name:this.name,options:this.options}))||{}}return(0,p.A)(e,[{key:"configure",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=this.extend();return t.options=us(this.options,e),t.storage=Ki(Vi(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(y(y({},this.config),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=Ki(Vi(n,"addOptions",{name:n.name})),n.storage=Ki(Vi(n,"addStorage",{name:n.name,options:n.options})),n}}],[{key:"create",value:function(){return new e(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})}},{key:"handleExit",value:function(e){var t=e.editor,n=e.mark,r=t.state.tr,o=t.state.selection.$from;if(o.pos===o.end()){var i=o.marks();if(!i.find((function(e){return(null==e?void 0:e.type.name)===n.name})))return!1;var s=i.find((function(e){return(null==e?void 0:e.type.name)===n.name}));return s&&r.removeStoredMark(s),r.insertText(" ",o.pos),t.view.dispatch(r),!0}return!1}}])}(),Ys=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(0,h.A)(this,e),this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config=y(y({},this.config),t),this.name=this.config.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&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=Ki(Vi(this,"addOptions",{name:this.name}))),this.storage=Ki(Vi(this,"addStorage",{name:this.name,options:this.options}))||{}}return(0,p.A)(e,[{key:"configure",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=this.extend();return t.options=us(this.options,e),t.storage=Ki(Vi(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(y(y({},this.config),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=Ki(Vi(n,"addOptions",{name:n.name})),n.storage=Ki(Vi(n,"addStorage",{name:n.name,options:n.options})),n}}],[{key:"create",value:function(){return new e(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})}}])}();function Qs(e){return new rs({find:e.find,handler:function(t){var n=t.state,r=t.range,o=t.match,i=t.pasteEvent,s=Ki(e.getAttributes,void 0,o,i);if(!1===s||null===s)return null;var a=n.tr,u=o[o.length-1],c=o[0],l=r.to;if(u){var d=c.search(/\S/),f=r.from+c.indexOf(u),h=f+u.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>f})).length)return null;h<r.to&&a.delete(h,r.to),f>r.from&&a.delete(r.from+d,f),l=r.from+d+u.length,a.addMark(r.from+d,l,e.type.create(s||{})),a.removeStoredMark(e.type)}}})}var Zs=cs.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 Bt({key:new Vt("characterCount"),filterTransaction:function(t,n){var r=e.options.limit;if(!t.docChanged||0===r||null==r)return!0;var o=e.storage.characters({node:n.doc}),i=e.storage.characters({node:t.doc});if(i<=r)return!0;if(o>r&&i>r&&i<=o)return!0;if(o>r&&i>r&&i>o)return!1;if(!t.getMeta("paste"))return!1;var s=t.selection.$head.pos,a=s-(i-r),u=s;return t.deleteRange(a,u),!(e.storage.characters({node:t.doc})>r)}})]}}),ea=cs.create({name:"placeholder",addOptions:function(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,considerAnyAsEmpty:!1,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins:function(){var e=this;return[new Bt({key:new Vt("placeholder"),props:{decorations:function(t){var n,r=t.doc,o=t.selection,i=e.editor.isEditable||!e.options.showOnlyWhenEditable,s=o.anchor,a=[];if(!i)return null;var u=r.content.firstChild,c=u&&u.type.isLeaf,l=u&&u.isAtom,d=!!e.options.considerAnyAsEmpty||u&&u.type.name===(null===(n=r.type.contentMatch.defaultType)||void 0===n?void 0:n.name),f=r.content.childCount<=1&&u&&d&&u.nodeSize<=2&&(!c||!l);return r.descendants((function(t,n){var r=s>=n&&s<=n+t.nodeSize,o=!t.isLeaf&&!t.childCount;if((r||!e.options.showOnlyCurrent)&&o){var i=[e.options.emptyNodeClass];f&&i.push(e.options.emptyEditorClass);var u=ko.node(n,n+t.nodeSize,{class:i.join(" "),"data-placeholder":"function"==typeof e.options.placeholder?e.options.placeholder({editor:e.editor,node:t,pos:n,hasAnchor:r}):e.options.placeholder});a.push(u)}return e.options.includeChildren})),xo.create(r,a)}}})]}}),ta=/^\s*>\s$/,na=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",qi(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:ta,type:this.type})]}}),ra=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,oa=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,ia=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,sa=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,aa=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",qi(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:ra,type:this.type}),_s({find:ia,type:this.type})]},addPasteRules:function(){return[Qs({find:oa,type:this.type}),Qs({find:sa,type:this.type})]}}),ua=Ys.create({name:"listItem",addOptions:function(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML:function(){return[{tag:"li"}]},renderHTML:function(e){var t=e.HTMLAttributes;return["li",qi(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)}}}}),ca=Xs.create({name:"textStyle",addOptions:function(){return{HTMLAttributes:{}}},parseHTML:function(){return[{tag:"span",getAttrs:function(e){return!!e.hasAttribute("style")&&{}}}]},renderHTML:function(e){var t=e.HTMLAttributes;return["span",qi(this.options.HTMLAttributes,t),0]},addCommands:function(){var e=this;return{removeEmptyTextStyle:function(){return function(t){var n=t.state,r=t.commands,o=Es(n,e.type);return!!Object.entries(o).some((function(e){return!!(0,s.A)(e,2)[1]}))||r.unsetMark(e.name)}}}}}),la=/^\s*([-+*])\s$/,da=Ys.create({name:"bulletList",addOptions:function(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content:function(){return"".concat(this.options.itemTypeName,"+")},parseHTML:function(){return[{tag:"ul"}]},renderHTML:function(e){var t=e.HTMLAttributes;return["ul",qi(this.options.HTMLAttributes,t),0]},addCommands:function(){var e=this;return{toggleBulletList:function(){return function(t){var n=t.commands,r=t.chain;return e.options.keepAttributes?r().toggleList(e.name,e.options.itemTypeName,e.options.keepMarks).updateAttributes(ua.name,e.editor.getAttributes(ca.name)).run():n.toggleList(e.name,e.options.itemTypeName,e.options.keepMarks)}}}},addKeyboardShortcuts:function(){var e=this;return{"Mod-Shift-8":function(){return e.editor.commands.toggleBulletList()}}},addInputRules:function(){var e=this,t=Gs({find:la,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Gs({find:la,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:function(){return e.editor.getAttributes(ca.name)},editor:this.editor})),[t]}}),fa=/(?:^|\s)(`(?!\s+`)((?:[^`]+))`(?!\s+`))$/,ha=/(?:^|\s)(`(?!\s+`)((?:[^`]+))`(?!\s+`))/g,pa=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",qi(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:fa,type:this.type})]},addPasteRules:function(){return[Qs({find:ha,type:this.type})]}}),va=/^```([a-z]+)?[\s\n]$/,ma=/^~~~([a-z]+)?[\s\n]$/,ga=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,o.A)((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",qi(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,o=1===r.pos;return!(!n||r.parent.type.name!==e.name)&&!(!o&&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,o=r.$from;if(!r.empty||o.parent.type!==e.type)return!1;var i=o.parentOffset===o.parent.nodeSize-2,s=o.parent.textContent.endsWith("\n\n");return!(!i||!s)&&n.chain().command((function(e){return e.tr.delete(o.pos-2,o.pos),!0})).exitCode().run()},ArrowDown:function(t){var n=t.editor;if(!e.options.exitOnArrowDown)return!1;var r=n.state,o=r.selection,i=r.doc,s=o.$from;if(!o.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&&!i.nodeAt(a)&&n.commands.exitCode()}}},addInputRules:function(){return[Us({find:va,type:this.type,getAttributes:function(e){return{language:e[1]}}}),Us({find:ma,type:this.type,getAttributes:function(e){return{language:e[1]}}})]},addProseMirrorPlugins:function(){var e=this;return[new Bt({key:new Vt("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"),o=n.clipboardData.getData("vscode-editor-data"),i=o?JSON.parse(o):void 0,s=null==i?void 0:i.mode;if(!r||!s)return!1;var a=t.state.tr;return t.state.selection.from===t.state.doc.nodeSize-(1+2*t.state.selection.$to.depth)?a.insert(t.state.selection.from-1,e.type.create({language:s})):a.replaceSelectionWith(e.type.create({language:s})),a.setSelection(wt.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}}})]}}),ya=Ys.create({name:"doc",topNode:!0,content:"block+"});function ka(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Bt({view:function(t){return new ba(t,e)}})}var ba=function(){return(0,p.A)((function e(t,n){var r,o=this;(0,h.A)(this,e),this.editorView=t,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=null!==(r=n.width)&&void 0!==r?r:1,this.color=!1===n.color?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map((function(e){var n=function(t){o[e](t)};return t.dom.addEventListener(e,n),{name:e,handler:n}}))}),[{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,o=t.nodeAfter;if(r||o){var i=this.editorView.nodeDOM(this.cursorPos-(r?r.nodeSize:0));if(i){var s=i.getBoundingClientRect(),a=r?s.bottom:s.top;r&&o&&(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 u=this.editorView.coordsAtPos(this.cursorPos);e={left:u.left-this.width/2,right:u.left+this.width/2,top:u.top,bottom:u.bottom}}var c,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;",this.color&&(this.element.style.backgroundColor=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)c=-pageXOffset,l=-pageYOffset;else{var f=d.getBoundingClientRect();c=f.left-d.scrollLeft,l=f.top-d.scrollTop}this.element.style.left=e.left-c+"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,o="function"==typeof r?r(this.editorView,t,e):r;if(t&&!o){var i=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){var s=tt(this.editorView.state.doc,i,this.editorView.dragging.slice);null!=s&&(i=s)}this.setCursor(i),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)}}])}(),wa=cs.create({name:"dropCursor",addOptions:function(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins:function(){return[ka(this.options)]}}),xa=function(e){function t(e){return(0,h.A)(this,t),w(this,t,[e,e])}return(0,l.A)(t,e),(0,p.A)(t,[{key:"map",value:function(e,n){var r=e.resolve(n.map(this.head));return t.valid(r)?new t(r):gt.near(r)}},{key:"content",value:function(){return P.empty}},{key:"eq",value:function(e){return e instanceof t&&e.head==this.head}},{key:"toJSON",value:function(){return{type:"gapcursor",pos:this.head}}},{key:"getBookmark",value:function(){return new Ma(this.anchor)}}],[{key:"fromJSON",value:function(e,n){if("number"!=typeof n.pos)throw new RangeError("Invalid input for GapCursor.fromJSON");return new t(e.resolve(n.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 o=r.child(n-1);;o=o.lastChild){if(0==o.childCount&&!o.inlineContent||o.isAtom||o.type.spec.isolating)return!0;if(o.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 o=r.child(n);;o=o.firstChild){if(0==o.childCount&&!o.inlineContent||o.isAtom||o.type.spec.isolating)return!0;if(o.inlineContent)return!1}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,n){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];e:for(;;){if(!r&&t.valid(e))return e;for(var o=e.pos,i=null,s=e.depth;;s--){var a=e.node(s);if(n>0?e.indexAfter(s)<a.childCount:e.index(s)>0){i=a.child(n>0?e.indexAfter(s):e.index(s)-1);break}if(0==s)return null;o+=n;var u=e.doc.resolve(o);if(t.valid(u))return u}for(;;){var c=n>0?i.firstChild:i.lastChild;if(!c){if(i.isAtom&&!i.isText&&!Mt.isSelectable(i)){e=e.doc.resolve(o+i.nodeSize*n),r=!1;continue e}break}i=c,o+=n;var l=e.doc.resolve(o);if(t.valid(l))return l}return null}}}])}(gt);xa.prototype.visible=!1,xa.findFrom=xa.findGapCursorFrom,gt.jsonID("gapcursor",xa);var Ma=function(){function e(t){(0,h.A)(this,e),this.pos=t}return(0,p.A)(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 xa.valid(t)?new xa(t):gt.near(t)}}])}(),Sa=ui({ArrowLeft:Aa("horiz",-1),ArrowRight:Aa("horiz",1),ArrowUp:Aa("vert",-1),ArrowDown:Aa("vert",1)});function Aa(e,t){var n="vert"==e?t>0?"down":"up":t>0?"right":"left";return function(e,r,o){var i=e.selection,s=t>0?i.$to:i.$from,a=i.empty;if(i instanceof wt){if(!o.endOfTextblock(n)||0==s.depth)return!1;a=!1,s=e.doc.resolve(t>0?s.after():s.before())}var u=xa.findGapCursorFrom(s,t,a);return!!u&&(r&&r(e.tr.setSelection(new xa(u))),!0)}}function Ca(e,t,n){if(!e||!e.editable)return!1;var r=e.state.doc.resolve(t);if(!xa.valid(r))return!1;var o=e.posAtCoords({left:n.clientX,top:n.clientY});return!(o&&o.inside>-1&&Mt.isSelectable(e.state.doc.nodeAt(o.inside))||(e.dispatch(e.state.tr.setSelection(new xa(r))),0))}function Oa(e,t){if("insertCompositionText"!=t.inputType||!(e.state.selection instanceof xa))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 o=C.empty,i=r.length-1;i>=0;i--)o=C.from(r[i].createAndFill(null,o));var s=e.state.tr.replace(n.pos,n.pos,new P(o,0,0));return s.setSelection(wt.near(s.doc.resolve(n.pos+1))),e.dispatch(s),!1}function Ta(e){if(!(e.selection instanceof xa))return null;var t=document.createElement("div");return t.className="ProseMirror-gapcursor",xo.create(e.doc,[ko.widget(e.selection.head,t,{key:"gapcursor"})])}var Na=cs.create({name:"gapCursor",addProseMirrorPlugins:function(){return[new Bt({props:{decorations:Ta,createSelectionBetween:function(e,t,n){return t.pos==n.pos&&xa.valid(n)?new xa(n):null},handleClick:Ca,handleKeyDown:Sa,handleDOMEvents:{beforeinput:Oa}}})]},extendNodeSchema:function(e){var t;return{allowGapCursor:null!==(t=Ki(Vi(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",qi(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,o=t.state,i=t.editor;return n.first([function(){return n.exitCode()},function(){return n.command((function(){var t=o.selection,n=o.storedMarks;if(t.$from.parent.type.spec.isolating)return!1;var s=e.options.keepMarks,a=i.extensionManager.splittableMarks,u=n||t.$to.parentOffset&&t.$from.marks();return r().insertContent({type:e.name}).command((function(e){var t=e.tr;if(e.dispatch&&u&&s){var n=u.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()}}}}),Da=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),qi(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 y(y({},t),(0,i.A)({},"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}})}))}}),Pa=200,Ia=function(){};Ia.prototype.append=function(e){return e.length?(e=Ia.from(e),!this.length&&e||e.length<Pa&&this.leafAppend(e)||this.length<Pa&&e.leafPrepend(this)||this.appendInner(e)):this},Ia.prototype.prepend=function(e){return e.length?Ia.from(e).append(this):this},Ia.prototype.appendInner=function(e){return new za(this,e)},Ia.prototype.slice=function(e,t){return void 0===e&&(e=0),void 0===t&&(t=this.length),e>=t?Ia.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},Ia.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},Ia.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)},Ia.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},Ia.from=function(e){return e instanceof Ia?e:e&&e.length?new Ra(e):Ia.empty};var Ra=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 o=t;o<n;o++)if(!1===e(this.values[o],r+o))return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var o=t-1;o>=n;o--)if(!1===e(this.values[o],r+o))return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=Pa)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=Pa)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}(Ia);Ia.empty=new Ra([]);var za=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 o=this.left.length;return!(t<o&&!1===this.left.forEachInner(e,t,Math.min(n,o),r))&&!(n>o&&!1===this.right.forEachInner(e,Math.max(t-o,0),Math.min(this.length,n)-o,r+o))&&void 0},t.prototype.forEachInvertedInner=function(e,t,n,r){var o=this.left.length;return!(t>o&&!1===this.right.forEachInvertedInner(e,t-o,Math.max(n,o)-o,r+o))&&!(n<o&&!1===this.left.forEachInvertedInner(e,Math.min(t,o),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}(Ia),Ba=function(){function e(t,n){(0,h.A)(this,e),this.items=t,this.eventCount=n}return(0,p.A)(e,[{key:"popEvent",value:function(t,n){var r=this;if(0==this.eventCount)return null;for(var o,i,s=this.items.length;;s--)if(this.items.get(s-1).selection){--s;break}n&&(o=this.remapping(s,this.items.length),i=o.maps.length);var a,u,c=t.tr,l=[],d=[];return this.items.forEach((function(t,n){if(!t.step)return o||(o=r.remapping(s,n+1),i=o.maps.length),i--,void d.push(t);if(o){d.push(new La(t.map));var f,h=t.step.map(o.slice(i));h&&c.maybeStep(h).doc&&(f=c.mapping.maps[c.mapping.maps.length-1],l.push(new La(f,void 0,void 0,l.length+d.length))),i--,f&&o.appendMap(f,i)}else c.maybeStep(t.step);return t.selection?(a=o?t.selection.map(o.slice(i)):t.selection,u=new e(r.items.slice(0,s).append(d.reverse().concat(l)),r.eventCount-1),!1):void 0}),this.items.length,0),{remaining:u,transform:c,selection:a}}},{key:"addTransform",value:function(t,n,r,o){for(var i=[],s=this.eventCount,a=this.items,u=!o&&a.length?a.get(a.length-1):null,c=0;c<t.steps.length;c++){var l,d=t.steps[c].invert(t.docs[c]),f=new La(t.mapping.maps[c],d,n);(l=u&&u.merge(f))&&(f=l,c?i.pop():a=a.slice(0,a.length-1)),i.push(f),n&&(s++,n=void 0),o||(u=f)}var h,p,v,m=s-r.depth;return m>Va&&(p=m,(h=a).forEach((function(e,t){if(e.selection&&0==p--)return v=t,!1})),a=h.slice(v),s-=m),new e(a.append(i),s)}},{key:"remapping",value:function(e,t){var n=new Re;return this.items.forEach((function(t,r){var o=null!=t.mirrorOffset&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,o)}),e,t),n}},{key:"addMaps",value:function(t){return 0==this.eventCount?this:new e(this.items.append(t.map((function(e){return new La(e)}))),this.eventCount)}},{key:"rebased",value:function(t,n){if(!this.eventCount)return this;var r=[],o=Math.max(0,this.items.length-n),i=t.mapping,s=t.steps.length,a=this.eventCount;this.items.forEach((function(e){e.selection&&a--}),o);var u=n;this.items.forEach((function(e){var n=i.getMirror(--u);if(null!=n){s=Math.min(s,n);var o=i.maps[n];if(e.step){var c=t.steps[n].invert(t.docs[n]),l=e.selection&&e.selection.map(i.slice(u+1,n));l&&a++,r.push(new La(o,c,l))}else r.push(new La(o))}}),o);for(var c=[],l=n;l<s;l++)c.push(new La(i.maps[l]));var d=new e(this.items.slice(0,o).append(c).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,o=[],i=0;return this.items.forEach((function(e,s){if(s>=t)o.push(e),e.selection&&i++;else if(e.step){var a=e.step.map(n.slice(r)),u=a&&a.getMap();if(r--,u&&n.appendMap(u,r),a){var c=e.selection&&e.selection.map(n.slice(r));c&&i++;var l,d=new La(u.invert(),a,c),f=o.length-1;(l=o.length&&o[f].merge(d))?o[f]=l:o.push(d)}}else e.map&&r--}),this.items.length,0),new e(Ia.from(o.reverse()),i)}}])}();Ba.empty=new Ba(Ia.empty,0);var La=function(){function e(t,n,r,o){(0,h.A)(this,e),this.map=t,this.step=n,this.selection=r,this.mirrorOffset=o}return(0,p.A)(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)}}}])}(),$a=(0,p.A)((function e(t,n,r,o,i){(0,h.A)(this,e),this.done=t,this.undone=n,this.prevRanges=r,this.prevTime=o,this.prevComposition=i})),Va=20;function Fa(e){var t=[];return e.forEach((function(e,n,r,o){return t.push(r,o)})),t}function ja(e,t){if(!e)return null;for(var n=[],r=0;r<e.length;r+=2){var o=t.map(e[r],1),i=t.map(e[r+1],-1);o<=i&&n.push(o,i)}return n}var Ha=!1,qa=null;function Ja(e){var t=e.plugins;if(qa!=t){Ha=!1,qa=t;for(var n=0;n<t.length;n++)if(t[n].spec.historyPreserveItems){Ha=!0;break}}return Ha}var Wa=new Vt("history"),Ka=new Vt("closeHistory");function _a(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new Bt({key:Wa,state:{init:function(){return new $a(Ba.empty,Ba.empty,null,0,-1)},apply:function(t,n,r){return function(e,t,n,r){var o,i=n.getMeta(Wa);if(i)return i.historyState;n.getMeta(Ka)&&(e=new $a(e.done,e.undone,null,0,-1));var s=n.getMeta("appendedTransaction");if(0==n.steps.length)return e;if(s&&s.getMeta(Wa))return s.getMeta(Wa).redo?new $a(e.done.addTransform(n,void 0,r,Ja(t)),e.undone,Fa(n.mapping.maps[n.steps.length-1]),e.prevTime,e.prevComposition):new $a(e.done,e.undone.addTransform(n,void 0,r,Ja(t)),null,e.prevTime,e.prevComposition);if(!1===n.getMeta("addToHistory")||s&&!1===s.getMeta("addToHistory"))return(o=n.getMeta("rebased"))?new $a(e.done.rebased(n,o),e.undone.rebased(n,o),ja(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new $a(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),ja(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);var a=n.getMeta("composition"),u=0==e.prevTime||!s&&e.prevComposition!=a&&(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 o=0;o<t.length;o+=2)e<=t[o+1]&&r>=t[o]&&(n=!0)})),n}(n,e.prevRanges)),c=s?ja(e.prevRanges,n.mapping):Fa(n.mapping.maps[n.steps.length-1]);return new $a(e.done.addTransform(n,u?t.selection.getBookmark():void 0,r,Ja(t)),Ba.empty,c,n.time,null==a?e.prevComposition:a)}(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))}}}})}function Ua(e,t){return function(n,r){var o=Wa.getState(n);if(!o||0==(e?o.undone:o.done).eventCount)return!1;if(r){var i=function(e,t,n){var r=Ja(t),o=Wa.get(t).spec.config,i=(n?e.undone:e.done).popEvent(t,r);if(!i)return null;var s=i.selection.resolve(i.transform.doc),a=(n?e.done:e.undone).addTransform(i.transform,t.selection.getBookmark(),o,r),u=new $a(n?a:i.remaining,n?i.remaining:a,null,0,-1);return i.transform.setSelection(s).setMeta(Wa,{redo:n,historyState:u})}(o,n,e);i&&r(t?i.scrollIntoView():i)}return!0}}var Ga=Ua(!1,!0),Xa=Ua(!0,!0),Ya=cs.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[_a(this.options)]},addKeyboardShortcuts:function(){var e=this;return{"Mod-z":function(){return e.editor.commands.undo()},"Shift-Mod-z":function(){return e.editor.commands.redo()},"Mod-y":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",qi(this.options.HTMLAttributes,t)]},addCommands:function(){var e=this;return{setHorizontalRule:function(){return function(t){var n=t.chain,r=t.state.selection.$to,o=n();return 0===r.parentOffset?o.insertContentAt(Math.max(r.pos-2,0),{type:e.name}):o.insertContent({type:e.name}),o.command((function(e){var t,n=e.tr;if(e.dispatch){var r=n.selection.$to,o=r.end();if(r.nodeAfter)r.nodeAfter.isTextblock?n.setSelection(wt.create(n.doc,r.pos+1)):r.nodeAfter.isBlock?n.setSelection(Mt.create(n.doc,r.pos)):n.setSelection(wt.create(n.doc,r.pos));else{var i=null===(t=r.parent.type.contentMatch.defaultType)||void 0===t?void 0:t.create();i&&(n.insert(o,i),n.setSelection(wt.create(n.doc,o+1)))}n.scrollIntoView()}return!0})).run()}}}},addInputRules:function(){return[(e={find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type},new Zi({find:e.find,handler:function(t){var n=t.state,r=t.range,o=t.match,i=Ki(e.getAttributes,void 0,o)||{},s=n.tr,a=r.from,u=r.to,c=e.type.create(i);if(o[1]){var l=a+o[0].lastIndexOf(o[1]);l>u?l=u:u=l+o[1].length;var d=o[0][o[0].length-1];s.insertText(d,a+o[0].length-1),s.replaceWith(l,u,c)}else o[0]&&s.insert(a-1,e.type.create(i)).delete(s.mapping.map(a),s.mapping.map(u));s.scrollIntoView()}}))];var e}}),Za=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,eu=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,tu=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,nu=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,ru=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",qi(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:Za,type:this.type}),_s({find:tu,type:this.type})]},addPasteRules:function(){return[Qs({find:eu,type:this.type}),Qs({find:nu,type:this.type})]}}),ou=Ys.create({name:"listItem",addOptions:function(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML:function(){return[{tag:"li"}]},renderHTML:function(e){var t=e.HTMLAttributes;return["li",qi(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)}}}}),iu=Ys.create({name:"listItem",addOptions:function(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML:function(){return[{tag:"li"}]},renderHTML:function(e){var t=e.HTMLAttributes;return["li",qi(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)}}}}),su=Xs.create({name:"textStyle",addOptions:function(){return{HTMLAttributes:{}}},parseHTML:function(){return[{tag:"span",getAttrs:function(e){return!!e.hasAttribute("style")&&{}}}]},renderHTML:function(e){var t=e.HTMLAttributes;return["span",qi(this.options.HTMLAttributes,t),0]},addCommands:function(){var e=this;return{removeEmptyTextStyle:function(){return function(t){var n=t.state,r=t.commands,o=Es(n,e.type);return!!Object.entries(o).some((function(e){return!!(0,s.A)(e,2)[1]}))||r.unsetMark(e.name)}}}}}),au=/^(\d+)\.\s$/,uu=Ys.create({name:"orderedList",addOptions:function(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},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,o=(0,r.A)(t,m);return 1===n?["ol",qi(this.options.HTMLAttributes,o),0]:["ol",qi(this.options.HTMLAttributes,t),0]},addCommands:function(){var e=this;return{toggleOrderedList:function(){return function(t){var n=t.commands,r=t.chain;return e.options.keepAttributes?r().toggleList(e.name,e.options.itemTypeName,e.options.keepMarks).updateAttributes(iu.name,e.editor.getAttributes(su.name)).run():n.toggleList(e.name,e.options.itemTypeName,e.options.keepMarks)}}}},addKeyboardShortcuts:function(){var e=this;return{"Mod-Shift-7":function(){return e.editor.commands.toggleOrderedList()}}},addInputRules:function(){var e=this,t=Gs({find:au,type:this.type,getAttributes:function(e){return{start:+e[1]}},joinPredicate:function(e,t){return t.childCount+t.attrs.start===+e[1]}});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Gs({find:au,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:function(t){return y({start:+t[1]},e.editor.getAttributes(su.name))},joinPredicate:function(e,t){return t.childCount+t.attrs.start===+e[1]},editor:this.editor})),[t]}}),cu=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",qi(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()}}}}),lu=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,du=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,fu=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",qi(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-s":function(){return e.editor.commands.toggleStrike()}}},addInputRules:function(){return[_s({find:lu,type:this.type})]},addPasteRules:function(){return[Qs({find:du,type:this.type})]}}),hu=Ys.create({name:"text",group:"inline"}),pu=cs.create({name:"starterKit",addExtensions:function(){var e,t,n,r,o,i,s,a,u,c,l,d,f,h,p,v,m,g,y=[];return!1!==this.options.blockquote&&y.push(na.configure(null===(e=this.options)||void 0===e?void 0:e.blockquote)),!1!==this.options.bold&&y.push(aa.configure(null===(t=this.options)||void 0===t?void 0:t.bold)),!1!==this.options.bulletList&&y.push(da.configure(null===(n=this.options)||void 0===n?void 0:n.bulletList)),!1!==this.options.code&&y.push(pa.configure(null===(r=this.options)||void 0===r?void 0:r.code)),!1!==this.options.codeBlock&&y.push(ga.configure(null===(o=this.options)||void 0===o?void 0:o.codeBlock)),!1!==this.options.document&&y.push(ya.configure(null===(i=this.options)||void 0===i?void 0:i.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===(u=this.options)||void 0===u?void 0:u.hardBreak)),!1!==this.options.heading&&y.push(Da.configure(null===(c=this.options)||void 0===c?void 0:c.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(ru.configure(null===(f=this.options)||void 0===f?void 0:f.italic)),!1!==this.options.listItem&&y.push(ou.configure(null===(h=this.options)||void 0===h?void 0:h.listItem)),!1!==this.options.orderedList&&y.push(uu.configure(null===(p=this.options)||void 0===p?void 0:p.orderedList)),!1!==this.options.paragraph&&y.push(cu.configure(null===(v=this.options)||void 0===v?void 0:v.paragraph)),!1!==this.options.strike&&y.push(fu.configure(null===(m=this.options)||void 0===m?void 0:m.strike)),!1!==this.options.text&&y.push(hu.configure(null===(g=this.options)||void 0===g?void 0:g.text)),y}}),vu=0,mu=function(){return(0,p.A)((function e(t){(0,h.A)(this,e),(0,v.r)(this,t),this.scChange=(0,v.c)(this,"scChange",7),this.scInput=(0,v.c)(this,"scInput",7),this.scBlur=(0,v.c)(this,"scBlur",7),this.scFocus=(0,v.c)(this,"scFocus",7),this.inputId="sc-richtext-".concat(++vu),this.helpId="sc-richtext-help-text-".concat(vu),this.labelId="sc-richtext-label-".concat(vu),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}),[{key:"componentDidLoad",value:function(){var e=this;this.editor||(this.editor=new Ks({element:this.element,extensions:[pu,ea.configure({placeholder:this.placeholder})].concat((0,o.A)((null==this?void 0:this.maxlength)>0?[Zs.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,o,i,s,a,u,c;return null===(c=null===(u=null===(a=null===(s=null===(i=null===(o=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===o?void 0:o.focus)||void 0===i?void 0:i.call(o))||void 0===s?void 0:s[e])||void 0===a?void 0:a.call(s))||void 0===u?void 0:u.run)||void 0===c?void 0:c.call(u)}},{key:"run",value:function(e){var t,n,r,o,i,s,a,u;return null===(u=null===(a=null===(s=null===(i=null===(o=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===o?void 0:o.call(r))||void 0===i?void 0:i[e])||void 0===s?void 0:s.call(i))||void 0===a?void 0:a.run)||void 0===u?void 0:u.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,o,i,s,a,u=this;return(0,v.h)(v.H,{key:"c38442cf221a7ba625ede10c595300298ff82a94"},(0,v.h)("sc-form-control",{key:"40bfeaf65e8e48df2ebbe4cde751f6c16128ed8f",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,v.h)("div",{key:"256c471c9995d7774ef2928cc2cc387c1d23a49d",part:"base",class:{"editor-base":!0,"editor--focused":this.hasFocus}},(0,v.h)("div",{key:"45713f2450193fd25ad2f19486cef533843c5e9e",class:"menu"},(0,v.h)("sc-button",{key:"381ed716530c15e32f24ec287c332de9c2062f8f",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 u.run("toggleBold")},disabled:!this.can("toggleBold")},(0,v.h)("sc-icon",{key:"cb94b839cf0ea63f96aeee2b62d7e37e3ba3152e",name:"bold"})),(0,v.h)("sc-button",{key:"bef6888524567e7c0d83afb8f56111107bb5d2ae",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 u.run("toggleItalic")},disabled:!this.can("toggleItalic")},(0,v.h)("sc-icon",{key:"16c7622a9287e32c563ee7ff152c3cfb1f06d314",name:"italic"})),(0,v.h)("sc-button",{key:"5a07464a7138eafeff1c3739f6060f1446196d11",size:"small",type:(null===(i=null===(o=this.editor)||void 0===o?void 0:o.isActive)||void 0===i?void 0:i.call(o,"bulletList"))?"default":"text",onClick:function(){return u.run("toggleBulletList")}},(0,v.h)("sc-icon",{key:"c1e0b58365a870de812e86f5e96a58c0757c4a43",name:"list"})),(0,v.h)("sc-button",{key:"e347089ad5e93bf75366e5b182643ef8df0cdcd6",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 u.run("toggleStrike")}},(0,v.h)("sc-icon",{key:"b497cd610daa97fb111a26fc5c9a1cc1949dd8ad",name:"minus"})),(0,v.h)("sc-button",{key:"3b234be6e543057932ceaa21801609b6bf820997",class:"right",size:"small",type:"text",onClick:function(){return u.run("undo")},disabled:!this.can("undo")},(0,v.h)("sc-icon",{key:"72095b9ca54fe98dc91094c54fd70d14ef66fac8",name:"corner-up-left"})),(0,v.h)("sc-button",{key:"63ba4ad2f2b102eb1cc1fb02afb8143689cbfc75",size:"small",type:"text",onClick:function(){return u.run("redo")},disabled:!this.can("redo")},(0,v.h)("sc-icon",{key:"c5882eb2add59ed91a7567cea56202a96fe9d044",name:"corner-up-right"}))),(0,v.h)("div",{key:"1d96180c36d76779507dacadae207a72bcbc71af",part:"editor",class:{editor:!0},ref:function(e){return u.element=e}})),this.remainingCharacters()<20&&(0,v.h)("div",{key:"5661c34e02e999ebd17352ba8c382bc5be37ad3c",class:"textarea__char-limit-warning"},wp.i18n.sprintf(wp.i18n.__("%d characters remaining","surecart"),this.remainingCharacters()))))}}])}();mu.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}'},45:function(e,t,n){n.d(t,{A:function(){return o}});var r=n(8587);function o(e,t){if(null==e)return{};var n,o,i=(0,r.A)(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(o=0;o<s.length;o++)n=s[o],t.indexOf(n)>=0||{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}},8587:function(e,t,n){function r(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}n.d(t,{A:function(){return r}})}}]);