@tiptap/suggestion 2.0.0-beta.21 → 2.0.0-beta.211
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- package/dist/index.cjs +235 -0
- package/dist/index.d.ts +70 -0
- package/dist/index.js +235 -0
- package/package.json +38 -12
- package/src/findSuggestionMatch.ts +24 -27
- package/src/suggestion.ts +118 -59
- package/CHANGELOG.md +0 -264
- package/LICENSE.md +0 -21
- package/dist/packages/suggestion/src/findSuggestionMatch.d.ts +0 -14
- package/dist/packages/suggestion/src/index.d.ts +0 -4
- package/dist/packages/suggestion/src/suggestion.d.ts +0 -43
- package/dist/tiptap-suggestion.bundle.umd.min.js +0 -2
- package/dist/tiptap-suggestion.bundle.umd.min.js.map +0 -1
- package/dist/tiptap-suggestion.cjs.js +0 -197
- package/dist/tiptap-suggestion.cjs.js.map +0 -1
- package/dist/tiptap-suggestion.esm.js +0 -192
- package/dist/tiptap-suggestion.esm.js.map +0 -1
- package/dist/tiptap-suggestion.umd.js +0 -200
- package/dist/tiptap-suggestion.umd.js.map +0 -1
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { Editor, Range } from '@tiptap/core';
|
|
2
|
-
import { Plugin } from 'prosemirror-state';
|
|
3
|
-
import { EditorView } from 'prosemirror-view';
|
|
4
|
-
export interface SuggestionOptions {
|
|
5
|
-
editor: Editor;
|
|
6
|
-
char?: string;
|
|
7
|
-
allowSpaces?: boolean;
|
|
8
|
-
startOfLine?: boolean;
|
|
9
|
-
decorationTag?: string;
|
|
10
|
-
decorationClass?: string;
|
|
11
|
-
command?: (props: {
|
|
12
|
-
editor: Editor;
|
|
13
|
-
range: Range;
|
|
14
|
-
props: any;
|
|
15
|
-
}) => void;
|
|
16
|
-
items?: (query: string) => any[];
|
|
17
|
-
render?: () => {
|
|
18
|
-
onStart?: (props: SuggestionProps) => void;
|
|
19
|
-
onUpdate?: (props: SuggestionProps) => void;
|
|
20
|
-
onExit?: (props: SuggestionProps) => void;
|
|
21
|
-
onKeyDown?: (props: SuggestionKeyDownProps) => boolean;
|
|
22
|
-
};
|
|
23
|
-
allow?: (props: {
|
|
24
|
-
editor: Editor;
|
|
25
|
-
range: Range;
|
|
26
|
-
}) => boolean;
|
|
27
|
-
}
|
|
28
|
-
export interface SuggestionProps {
|
|
29
|
-
editor: Editor;
|
|
30
|
-
range: Range;
|
|
31
|
-
query: string;
|
|
32
|
-
text: string;
|
|
33
|
-
items: any[];
|
|
34
|
-
command: (props: any) => void;
|
|
35
|
-
decorationNode: Element | null;
|
|
36
|
-
clientRect: () => (DOMRect | null);
|
|
37
|
-
}
|
|
38
|
-
export interface SuggestionKeyDownProps {
|
|
39
|
-
view: EditorView;
|
|
40
|
-
event: KeyboardEvent;
|
|
41
|
-
range: Range;
|
|
42
|
-
}
|
|
43
|
-
export declare function Suggestion({ editor, char, allowSpaces, startOfLine, decorationTag, decorationClass, command, items, render, allow, }: SuggestionOptions): Plugin<any, any>;
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self)["@tiptap/suggestion"]={})}(this,(function(t){"use strict";function e(t,n,r){for(var o=0;;o++){if(o==t.childCount||o==n.childCount)return t.childCount==n.childCount?null:r;var i=t.child(o),s=n.child(o);if(i!=s){if(!i.sameMarkup(s))return r;if(i.isText&&i.text!=s.text){for(var a=0;i.text[a]==s.text[a];a++)r++;return r}if(i.content.size||s.content.size){var c=e(i.content,s.content,r+1);if(null!=c)return c}r+=i.nodeSize}else r+=i.nodeSize}}function n(t,e,r,o){for(var i=t.childCount,s=e.childCount;;){if(0==i||0==s)return i==s?null:{a:r,b:o};var a=t.child(--i),c=e.child(--s),h=a.nodeSize;if(a!=c){if(!a.sameMarkup(c))return{a:r,b:o};if(a.isText&&a.text!=c.text){for(var p=0,l=Math.min(a.text.length,c.text.length);p<l&&a.text[a.text.length-p-1]==c.text[c.text.length-p-1];)p++,r--,o--;return{a:r,b:o}}if(a.content.size||c.content.size){var f=n(a.content,c.content,r-1,o-1);if(f)return f}r-=h,o-=h}else r-=h,o-=h}}var r=function(t,e){if(this.content=t,this.size=e||0,null==e)for(var n=0;n<t.length;n++)this.size+=t[n].nodeSize},o={firstChild:{configurable:!0},lastChild:{configurable:!0},childCount:{configurable:!0}};r.prototype.nodesBetween=function(t,e,n,r,o){void 0===r&&(r=0);for(var i=0,s=0;s<e;i++){var a=this.content[i],c=s+a.nodeSize;if(c>t&&!1!==n(a,r+s,o,i)&&a.content.size){var h=s+1;a.nodesBetween(Math.max(0,t-h),Math.min(a.content.size,e-h),n,r+h)}s=c}},r.prototype.descendants=function(t){this.nodesBetween(0,this.size,t)},r.prototype.textBetween=function(t,e,n,r){var o="",i=!0;return this.nodesBetween(t,e,(function(s,a){s.isText?(o+=s.text.slice(Math.max(t,a)-a,e-a),i=!n):s.isLeaf&&r?(o+=r,i=!n):!i&&s.isBlock&&(o+=n,i=!0)}),0),o},r.prototype.append=function(t){if(!t.size)return this;if(!this.size)return t;var e=this.lastChild,n=t.firstChild,o=this.content.slice(),i=0;for(e.isText&&e.sameMarkup(n)&&(o[o.length-1]=e.withText(e.text+n.text),i=1);i<t.content.length;i++)o.push(t.content[i]);return new r(o,this.size+t.size)},r.prototype.cut=function(t,e){if(null==e&&(e=this.size),0==t&&e==this.size)return this;var n=[],o=0;if(e>t)for(var i=0,s=0;s<e;i++){var a=this.content[i],c=s+a.nodeSize;c>t&&((s<t||c>e)&&(a=a.isText?a.cut(Math.max(0,t-s),Math.min(a.text.length,e-s)):a.cut(Math.max(0,t-s-1),Math.min(a.content.size,e-s-1))),n.push(a),o+=a.nodeSize),s=c}return new r(n,o)},r.prototype.cutByIndex=function(t,e){return t==e?r.empty:0==t&&e==this.content.length?this:new r(this.content.slice(t,e))},r.prototype.replaceChild=function(t,e){var n=this.content[t];if(n==e)return this;var o=this.content.slice(),i=this.size+e.nodeSize-n.nodeSize;return o[t]=e,new r(o,i)},r.prototype.addToStart=function(t){return new r([t].concat(this.content),this.size+t.nodeSize)},r.prototype.addToEnd=function(t){return new r(this.content.concat(t),this.size+t.nodeSize)},r.prototype.eq=function(t){if(this.content.length!=t.content.length)return!1;for(var e=0;e<this.content.length;e++)if(!this.content[e].eq(t.content[e]))return!1;return!0},o.firstChild.get=function(){return this.content.length?this.content[0]:null},o.lastChild.get=function(){return this.content.length?this.content[this.content.length-1]:null},o.childCount.get=function(){return this.content.length},r.prototype.child=function(t){var e=this.content[t];if(!e)throw new RangeError("Index "+t+" out of range for "+this);return e},r.prototype.maybeChild=function(t){return this.content[t]},r.prototype.forEach=function(t){for(var e=0,n=0;e<this.content.length;e++){var r=this.content[e];t(r,n,e),n+=r.nodeSize}},r.prototype.findDiffStart=function(t,n){return void 0===n&&(n=0),e(this,t,n)},r.prototype.findDiffEnd=function(t,e,r){return void 0===e&&(e=this.size),void 0===r&&(r=t.size),n(this,t,e,r)},r.prototype.findIndex=function(t,e){if(void 0===e&&(e=-1),0==t)return s(0,t);if(t==this.size)return s(this.content.length,t);if(t>this.size||t<0)throw new RangeError("Position "+t+" outside of fragment ("+this+")");for(var n=0,r=0;;n++){var o=r+this.child(n).nodeSize;if(o>=t)return o==t||e>0?s(n+1,o):s(n,r);r=o}},r.prototype.toString=function(){return"<"+this.toStringInner()+">"},r.prototype.toStringInner=function(){return this.content.join(", ")},r.prototype.toJSON=function(){return this.content.length?this.content.map((function(t){return t.toJSON()})):null},r.fromJSON=function(t,e){if(!e)return r.empty;if(!Array.isArray(e))throw new RangeError("Invalid input for Fragment.fromJSON");return new r(e.map(t.nodeFromJSON))},r.fromArray=function(t){if(!t.length)return r.empty;for(var e,n=0,o=0;o<t.length;o++){var i=t[o];n+=i.nodeSize,o&&i.isText&&t[o-1].sameMarkup(i)?(e||(e=t.slice(0,o)),e[e.length-1]=i.withText(e[e.length-1].text+i.text)):e&&e.push(i)}return new r(e||t,n)},r.from=function(t){if(!t)return r.empty;if(t instanceof r)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new r([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))},Object.defineProperties(r.prototype,o);var i={index:0,offset:0};function s(t,e){return i.index=t,i.offset=e,i}function a(t,e){if(t===e)return!0;if(!t||"object"!=typeof t||!e||"object"!=typeof e)return!1;var n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(var r=0;r<t.length;r++)if(!a(t[r],e[r]))return!1}else{for(var o in t)if(!(o in e)||!a(t[o],e[o]))return!1;for(var i in e)if(!(i in t))return!1}return!0}r.empty=new r([],0);var c=function(t,e){this.type=t,this.attrs=e};function h(t){var e=Error.call(this,t);return e.__proto__=h.prototype,e}c.prototype.addToSet=function(t){for(var e,n=!1,r=0;r<t.length;r++){var o=t[r];if(this.eq(o))return t;if(this.type.excludes(o.type))e||(e=t.slice(0,r));else{if(o.type.excludes(this.type))return t;!n&&o.type.rank>this.type.rank&&(e||(e=t.slice(0,r)),e.push(this),n=!0),e&&e.push(o)}}return e||(e=t.slice()),n||e.push(this),e},c.prototype.removeFromSet=function(t){for(var e=0;e<t.length;e++)if(this.eq(t[e]))return t.slice(0,e).concat(t.slice(e+1));return t},c.prototype.isInSet=function(t){for(var e=0;e<t.length;e++)if(this.eq(t[e]))return!0;return!1},c.prototype.eq=function(t){return this==t||this.type==t.type&&a(this.attrs,t.attrs)},c.prototype.toJSON=function(){var t={type:this.type.name};for(var e in this.attrs){t.attrs=this.attrs;break}return t},c.fromJSON=function(t,e){if(!e)throw new RangeError("Invalid input for Mark.fromJSON");var n=t.marks[e.type];if(!n)throw new RangeError("There is no mark type "+e.type+" in this schema");return n.create(e.attrs)},c.sameSet=function(t,e){if(t==e)return!0;if(t.length!=e.length)return!1;for(var n=0;n<t.length;n++)if(!t[n].eq(e[n]))return!1;return!0},c.setFrom=function(t){if(!t||0==t.length)return c.none;if(t instanceof c)return[t];var e=t.slice();return e.sort((function(t,e){return t.type.rank-e.type.rank})),e},c.none=[],h.prototype=Object.create(Error.prototype),h.prototype.constructor=h,h.prototype.name="ReplaceError";var p=function(t,e,n){this.content=t,this.openStart=e,this.openEnd=n},l={size:{configurable:!0}};function f(t,e,n){var r=t.findIndex(e),o=r.index,i=r.offset,s=t.maybeChild(o),a=t.findIndex(n),c=a.index,h=a.offset;if(i==e||s.isText){if(h!=n&&!t.child(c).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(o!=c)throw new RangeError("Removing non-flat range");return t.replaceChild(o,s.copy(f(s.content,e-i-1,n-i-1)))}function u(t,e,n,r){var o=t.findIndex(e),i=o.index,s=o.offset,a=t.maybeChild(i);if(s==e||a.isText)return r&&!r.canReplace(i,i,n)?null:t.cut(0,e).append(n).append(t.cut(e));var c=u(a.content,e-s-1,n);return c&&t.replaceChild(i,a.copy(c))}function d(t,e,n){if(n.openStart>t.depth)throw new h("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new h("Inconsistent open depths");return m(t,e,n,0)}function m(t,e,n,o){var i=t.index(o),s=t.node(o);if(i==e.index(o)&&o<t.depth-n.openStart){var a=m(t,e,n,o+1);return s.copy(s.content.replaceChild(i,a))}if(n.content.size){if(n.openStart||n.openEnd||t.depth!=o||e.depth!=o){var c=function(t,e){for(var n=e.depth-t.openStart,o=e.node(n).copy(t.content),i=n-1;i>=0;i--)o=e.node(i).copy(r.from(o));return{start:o.resolveNoCache(t.openStart+n),end:o.resolveNoCache(o.content.size-t.openEnd-n)}}(n,t);return b(s,x(t,c.start,c.end,e,o))}var h=t.parent,p=h.content;return b(h,p.cut(0,t.parentOffset).append(n.content).append(p.cut(e.parentOffset)))}return b(s,S(t,e,o))}function v(t,e){if(!e.type.compatibleContent(t.type))throw new h("Cannot join "+e.type.name+" onto "+t.type.name)}function g(t,e,n){var r=t.node(n);return v(r,e.node(n)),r}function y(t,e){var n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function w(t,e,n,r){var o=(e||t).node(n),i=0,s=e?e.index(n):o.childCount;t&&(i=t.index(n),t.depth>n?i++:t.textOffset&&(y(t.nodeAfter,r),i++));for(var a=i;a<s;a++)y(o.child(a),r);e&&e.depth==n&&e.textOffset&&y(e.nodeBefore,r)}function b(t,e){if(!t.type.validContent(e))throw new h("Invalid content for node "+t.type.name);return t.copy(e)}function x(t,e,n,o,i){var s=t.depth>i&&g(t,e,i+1),a=o.depth>i&&g(n,o,i+1),c=[];return w(null,t,i,c),s&&a&&e.index(i)==n.index(i)?(v(s,a),y(b(s,x(t,e,n,o,i+1)),c)):(s&&y(b(s,S(t,e,i+1)),c),w(e,n,i,c),a&&y(b(a,S(n,o,i+1)),c)),w(o,null,i,c),new r(c)}function S(t,e,n){var o=[];(w(null,t,n,o),t.depth>n)&&y(b(g(t,e,n+1),S(t,e,n+1)),o);return w(e,null,n,o),new r(o)}l.size.get=function(){return this.content.size-this.openStart-this.openEnd},p.prototype.insertAt=function(t,e){var n=u(this.content,t+this.openStart,e,null);return n&&new p(n,this.openStart,this.openEnd)},p.prototype.removeBetween=function(t,e){return new p(f(this.content,t+this.openStart,e+this.openStart),this.openStart,this.openEnd)},p.prototype.eq=function(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd},p.prototype.toString=function(){return this.content+"("+this.openStart+","+this.openEnd+")"},p.prototype.toJSON=function(){if(!this.content.size)return null;var t={content:this.content.toJSON()};return this.openStart>0&&(t.openStart=this.openStart),this.openEnd>0&&(t.openEnd=this.openEnd),t},p.fromJSON=function(t,e){if(!e)return p.empty;var n=e.openStart||0,o=e.openEnd||0;if("number"!=typeof n||"number"!=typeof o)throw new RangeError("Invalid input for Slice.fromJSON");return new p(r.fromJSON(t,e.content),n,o)},p.maxOpen=function(t,e){void 0===e&&(e=!0);for(var n=0,r=0,o=t.firstChild;o&&!o.isLeaf&&(e||!o.type.spec.isolating);o=o.firstChild)n++;for(var i=t.lastChild;i&&!i.isLeaf&&(e||!i.type.spec.isolating);i=i.lastChild)r++;return new p(t,n,r)},Object.defineProperties(p.prototype,l),p.empty=new p(r.empty,0,0);var k=function(t,e,n){this.pos=t,this.path=e,this.depth=e.length/3-1,this.parentOffset=n},O={parent:{configurable:!0},doc:{configurable:!0},textOffset:{configurable:!0},nodeAfter:{configurable:!0},nodeBefore:{configurable:!0}};k.prototype.resolveDepth=function(t){return null==t?this.depth:t<0?this.depth+t:t},O.parent.get=function(){return this.node(this.depth)},O.doc.get=function(){return this.node(0)},k.prototype.node=function(t){return this.path[3*this.resolveDepth(t)]},k.prototype.index=function(t){return this.path[3*this.resolveDepth(t)+1]},k.prototype.indexAfter=function(t){return t=this.resolveDepth(t),this.index(t)+(t!=this.depth||this.textOffset?1:0)},k.prototype.start=function(t){return 0==(t=this.resolveDepth(t))?0:this.path[3*t-1]+1},k.prototype.end=function(t){return t=this.resolveDepth(t),this.start(t)+this.node(t).content.size},k.prototype.before=function(t){if(!(t=this.resolveDepth(t)))throw new RangeError("There is no position before the top-level node");return t==this.depth+1?this.pos:this.path[3*t-1]},k.prototype.after=function(t){if(!(t=this.resolveDepth(t)))throw new RangeError("There is no position after the top-level node");return t==this.depth+1?this.pos:this.path[3*t-1]+this.path[3*t].nodeSize},O.textOffset.get=function(){return this.pos-this.path[this.path.length-1]},O.nodeAfter.get=function(){var t=this.parent,e=this.index(this.depth);if(e==t.childCount)return null;var n=this.pos-this.path[this.path.length-1],r=t.child(e);return n?t.child(e).cut(n):r},O.nodeBefore.get=function(){var t=this.index(this.depth),e=this.pos-this.path[this.path.length-1];return e?this.parent.child(t).cut(0,e):0==t?null:this.parent.child(t-1)},k.prototype.posAtIndex=function(t,e){e=this.resolveDepth(e);for(var n=this.path[3*e],r=0==e?0:this.path[3*e-1]+1,o=0;o<t;o++)r+=n.child(o).nodeSize;return r},k.prototype.marks=function(){var t=this.parent,e=this.index();if(0==t.content.size)return c.none;if(this.textOffset)return t.child(e).marks;var n=t.maybeChild(e-1),r=t.maybeChild(e);if(!n){var o=n;n=r,r=o}for(var i=n.marks,s=0;s<i.length;s++)!1!==i[s].type.spec.inclusive||r&&i[s].isInSet(r.marks)||(i=i[s--].removeFromSet(i));return i},k.prototype.marksAcross=function(t){var e=this.parent.maybeChild(this.index());if(!e||!e.isInline)return null;for(var n=e.marks,r=t.parent.maybeChild(t.index()),o=0;o<n.length;o++)!1!==n[o].type.spec.inclusive||r&&n[o].isInSet(r.marks)||(n=n[o--].removeFromSet(n));return n},k.prototype.sharedDepth=function(t){for(var e=this.depth;e>0;e--)if(this.start(e)<=t&&this.end(e)>=t)return e;return 0},k.prototype.blockRange=function(t,e){if(void 0===t&&(t=this),t.pos<this.pos)return t.blockRange(this);for(var n=this.depth-(this.parent.inlineContent||this.pos==t.pos?1:0);n>=0;n--)if(t.pos<=this.end(n)&&(!e||e(this.node(n))))return new D(this,t,n)},k.prototype.sameParent=function(t){return this.pos-this.parentOffset==t.pos-t.parentOffset},k.prototype.max=function(t){return t.pos>this.pos?t:this},k.prototype.min=function(t){return t.pos<this.pos?t:this},k.prototype.toString=function(){for(var t="",e=1;e<=this.depth;e++)t+=(t?"/":"")+this.node(e).type.name+"_"+this.index(e-1);return t+":"+this.parentOffset},k.resolve=function(t,e){if(!(e>=0&&e<=t.content.size))throw new RangeError("Position "+e+" out of range");for(var n=[],r=0,o=e,i=t;;){var s=i.content.findIndex(o),a=s.index,c=s.offset,h=o-c;if(n.push(i,a,r+c),!h)break;if((i=i.child(a)).isText)break;o=h-1,r+=c+1}return new k(e,n,o)},k.resolveCached=function(t,e){for(var n=0;n<M.length;n++){var r=M[n];if(r.pos==e&&r.doc==t)return r}var o=M[C]=k.resolve(t,e);return C=(C+1)%N,o},Object.defineProperties(k.prototype,O);var M=[],C=0,N=12,D=function(t,e,n){this.$from=t,this.$to=e,this.depth=n},T={start:{configurable:!0},end:{configurable:!0},parent:{configurable:!0},startIndex:{configurable:!0},endIndex:{configurable:!0}};T.start.get=function(){return this.$from.before(this.depth+1)},T.end.get=function(){return this.$to.after(this.depth+1)},T.parent.get=function(){return this.$from.node(this.depth)},T.startIndex.get=function(){return this.$from.index(this.depth)},T.endIndex.get=function(){return this.$to.indexAfter(this.depth)},Object.defineProperties(D.prototype,T);var E=Object.create(null),A=function(t,e,n,o){this.type=t,this.attrs=e,this.content=n||r.empty,this.marks=o||c.none},R={nodeSize:{configurable:!0},childCount:{configurable:!0},textContent:{configurable:!0},firstChild:{configurable:!0},lastChild:{configurable:!0},isBlock:{configurable:!0},isTextblock:{configurable:!0},inlineContent:{configurable:!0},isInline:{configurable:!0},isText:{configurable:!0},isLeaf:{configurable:!0},isAtom:{configurable:!0}};R.nodeSize.get=function(){return this.isLeaf?1:2+this.content.size},R.childCount.get=function(){return this.content.childCount},A.prototype.child=function(t){return this.content.child(t)},A.prototype.maybeChild=function(t){return this.content.maybeChild(t)},A.prototype.forEach=function(t){this.content.forEach(t)},A.prototype.nodesBetween=function(t,e,n,r){void 0===r&&(r=0),this.content.nodesBetween(t,e,n,r,this)},A.prototype.descendants=function(t){this.nodesBetween(0,this.content.size,t)},R.textContent.get=function(){return this.textBetween(0,this.content.size,"")},A.prototype.textBetween=function(t,e,n,r){return this.content.textBetween(t,e,n,r)},R.firstChild.get=function(){return this.content.firstChild},R.lastChild.get=function(){return this.content.lastChild},A.prototype.eq=function(t){return this==t||this.sameMarkup(t)&&this.content.eq(t.content)},A.prototype.sameMarkup=function(t){return this.hasMarkup(t.type,t.attrs,t.marks)},A.prototype.hasMarkup=function(t,e,n){return this.type==t&&a(this.attrs,e||t.defaultAttrs||E)&&c.sameSet(this.marks,n||c.none)},A.prototype.copy=function(t){return void 0===t&&(t=null),t==this.content?this:new this.constructor(this.type,this.attrs,t,this.marks)},A.prototype.mark=function(t){return t==this.marks?this:new this.constructor(this.type,this.attrs,this.content,t)},A.prototype.cut=function(t,e){return 0==t&&e==this.content.size?this:this.copy(this.content.cut(t,e))},A.prototype.slice=function(t,e,n){if(void 0===e&&(e=this.content.size),void 0===n&&(n=!1),t==e)return p.empty;var r=this.resolve(t),o=this.resolve(e),i=n?0:r.sharedDepth(e),s=r.start(i),a=r.node(i).content.cut(r.pos-s,o.pos-s);return new p(a,r.depth-i,o.depth-i)},A.prototype.replace=function(t,e,n){return d(this.resolve(t),this.resolve(e),n)},A.prototype.nodeAt=function(t){for(var e=this;;){var n=e.content.findIndex(t),r=n.index,o=n.offset;if(!(e=e.maybeChild(r)))return null;if(o==t||e.isText)return e;t-=o+1}},A.prototype.childAfter=function(t){var e=this.content.findIndex(t),n=e.index,r=e.offset;return{node:this.content.maybeChild(n),index:n,offset:r}},A.prototype.childBefore=function(t){if(0==t)return{node:null,index:0,offset:0};var e=this.content.findIndex(t),n=e.index,r=e.offset;if(r<t)return{node:this.content.child(n),index:n,offset:r};var o=this.content.child(n-1);return{node:o,index:n-1,offset:r-o.nodeSize}},A.prototype.resolve=function(t){return k.resolveCached(this,t)},A.prototype.resolveNoCache=function(t){return k.resolve(this,t)},A.prototype.rangeHasMark=function(t,e,n){var r=!1;return e>t&&this.nodesBetween(t,e,(function(t){return n.isInSet(t.marks)&&(r=!0),!r})),r},R.isBlock.get=function(){return this.type.isBlock},R.isTextblock.get=function(){return this.type.isTextblock},R.inlineContent.get=function(){return this.type.inlineContent},R.isInline.get=function(){return this.type.isInline},R.isText.get=function(){return this.type.isText},R.isLeaf.get=function(){return this.type.isLeaf},R.isAtom.get=function(){return this.type.isAtom},A.prototype.toString=function(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);var t=this.type.name;return this.content.size&&(t+="("+this.content.toStringInner()+")"),function(t,e){for(var n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}(this.marks,t)},A.prototype.contentMatchAt=function(t){var e=this.type.contentMatch.matchFragment(this.content,0,t);if(!e)throw new Error("Called contentMatchAt on a node with invalid content");return e},A.prototype.canReplace=function(t,e,n,o,i){void 0===n&&(n=r.empty),void 0===o&&(o=0),void 0===i&&(i=n.childCount);var s=this.contentMatchAt(t).matchFragment(n,o,i),a=s&&s.matchFragment(this.content,e);if(!a||!a.validEnd)return!1;for(var c=o;c<i;c++)if(!this.type.allowsMarks(n.child(c).marks))return!1;return!0},A.prototype.canReplaceWith=function(t,e,n,r){if(r&&!this.type.allowsMarks(r))return!1;var o=this.contentMatchAt(t).matchType(n),i=o&&o.matchFragment(this.content,e);return!!i&&i.validEnd},A.prototype.canAppend=function(t){return t.content.size?this.canReplace(this.childCount,this.childCount,t.content):this.type.compatibleContent(t.type)},A.prototype.check=function(){if(!this.type.validContent(this.content))throw new RangeError("Invalid content for node "+this.type.name+": "+this.content.toString().slice(0,50));for(var t=c.none,e=0;e<this.marks.length;e++)t=this.marks[e].addToSet(t);if(!c.sameSet(t,this.marks))throw new RangeError("Invalid collection of marks for node "+this.type.name+": "+this.marks.map((function(t){return t.type.name})));this.content.forEach((function(t){return t.check()}))},A.prototype.toJSON=function(){var t={type:this.type.name};for(var e in this.attrs){t.attrs=this.attrs;break}return this.content.size&&(t.content=this.content.toJSON()),this.marks.length&&(t.marks=this.marks.map((function(t){return t.toJSON()}))),t},A.fromJSON=function(t,e){if(!e)throw new RangeError("Invalid input for Node.fromJSON");var n=null;if(e.marks){if(!Array.isArray(e.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=e.marks.map(t.markFromJSON)}if("text"==e.type){if("string"!=typeof e.text)throw new RangeError("Invalid text node in JSON");return t.text(e.text,n)}var o=r.fromJSON(t,e.content);return t.nodeType(e.type).create(e.attrs,o,n)},Object.defineProperties(A.prototype,R);var z=function(t){this.validEnd=t,this.next=[],this.wrapCache=[]},P={inlineContent:{configurable:!0},defaultType:{configurable:!0},edgeCount:{configurable:!0}};z.parse=function(t,e){var n=new I(t,e);if(null==n.next)return z.empty;var r=F(n);n.next&&n.err("Unexpected trailing text");var o=function(t){var e=Object.create(null);return n(q(t,0));function n(r){var o=[];r.forEach((function(e){t[e].forEach((function(e){var n=e.term,r=e.to;if(n){var i=o.indexOf(n),s=i>-1&&o[i+1];q(t,r).forEach((function(t){s||o.push(n,s=[]),-1==s.indexOf(t)&&s.push(t)}))}}))}));for(var i=e[r.join(",")]=new z(r.indexOf(t.length-1)>-1),s=0;s<o.length;s+=2){var a=o[s+1].sort(j);i.next.push(o[s],e[a.join(",")]||n(a))}return i}}(function(t){var e=[[]];return o(i(t,0),n()),e;function n(){return e.push([])-1}function r(t,n,r){var o={term:r,to:n};return e[t].push(o),o}function o(t,e){t.forEach((function(t){return t.to=e}))}function i(t,e){if("choice"==t.type)return t.exprs.reduce((function(t,n){return t.concat(i(n,e))}),[]);if("seq"==t.type)for(var s=0;;s++){var a=i(t.exprs[s],e);if(s==t.exprs.length-1)return a;o(a,e=n())}else{if("star"==t.type){var c=n();return r(e,c),o(i(t.expr,c),c),[r(c)]}if("plus"==t.type){var h=n();return o(i(t.expr,e),h),o(i(t.expr,h),h),[r(h)]}if("opt"==t.type)return[r(e)].concat(i(t.expr,e));if("range"==t.type){for(var p=e,l=0;l<t.min;l++){var f=n();o(i(t.expr,p),f),p=f}if(-1==t.max)o(i(t.expr,p),p);else for(var u=t.min;u<t.max;u++){var d=n();r(p,d),o(i(t.expr,p),d),p=d}return[r(p)]}if("name"==t.type)return[r(e,null,t.value)]}}}(r));return function(t,e){for(var n=0,r=[t];n<r.length;n++){for(var o=r[n],i=!o.validEnd,s=[],a=0;a<o.next.length;a+=2){var c=o.next[a],h=o.next[a+1];s.push(c.name),!i||c.isText||c.hasRequiredAttrs()||(i=!1),-1==r.indexOf(h)&&r.push(h)}i&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(o,n),o},z.prototype.matchType=function(t){for(var e=0;e<this.next.length;e+=2)if(this.next[e]==t)return this.next[e+1];return null},z.prototype.matchFragment=function(t,e,n){void 0===e&&(e=0),void 0===n&&(n=t.childCount);for(var r=this,o=e;r&&o<n;o++)r=r.matchType(t.child(o).type);return r},P.inlineContent.get=function(){var t=this.next[0];return!!t&&t.isInline},P.defaultType.get=function(){for(var t=0;t<this.next.length;t+=2){var e=this.next[t];if(!e.isText&&!e.hasRequiredAttrs())return e}},z.prototype.compatible=function(t){for(var e=0;e<this.next.length;e+=2)for(var n=0;n<t.next.length;n+=2)if(this.next[e]==t.next[n])return!0;return!1},z.prototype.fillBefore=function(t,e,n){void 0===e&&(e=!1),void 0===n&&(n=0);var o=[this];return function i(s,a){var c=s.matchFragment(t,n);if(c&&(!e||c.validEnd))return r.from(a.map((function(t){return t.createAndFill()})));for(var h=0;h<s.next.length;h+=2){var p=s.next[h],l=s.next[h+1];if(!p.isText&&!p.hasRequiredAttrs()&&-1==o.indexOf(l)){o.push(l);var f=i(l,a.concat(p));if(f)return f}}}(this,[])},z.prototype.findWrapping=function(t){for(var e=0;e<this.wrapCache.length;e+=2)if(this.wrapCache[e]==t)return this.wrapCache[e+1];var n=this.computeWrapping(t);return this.wrapCache.push(t,n),n},z.prototype.computeWrapping=function(t){for(var e=Object.create(null),n=[{match:this,type:null,via:null}];n.length;){var r=n.shift(),o=r.match;if(o.matchType(t)){for(var i=[],s=r;s.type;s=s.via)i.push(s.type);return i.reverse()}for(var a=0;a<o.next.length;a+=2){var c=o.next[a];c.isLeaf||c.hasRequiredAttrs()||c.name in e||r.type&&!o.next[a+1].validEnd||(n.push({match:c.contentMatch,type:c,via:r}),e[c.name]=!0)}}},P.edgeCount.get=function(){return this.next.length>>1},z.prototype.edge=function(t){var e=t<<1;if(e>=this.next.length)throw new RangeError("There's no "+t+"th edge in this content match");return{type:this.next[e],next:this.next[e+1]}},z.prototype.toString=function(){var t=[];return function e(n){t.push(n);for(var r=1;r<n.next.length;r+=2)-1==t.indexOf(n.next[r])&&e(n.next[r])}(this),t.map((function(e,n){for(var r=n+(e.validEnd?"*":" ")+" ",o=0;o<e.next.length;o+=2)r+=(o?", ":"")+e.next[o].name+"->"+t.indexOf(e.next[o+1]);return r})).join("\n")},Object.defineProperties(z.prototype,P),z.empty=new z(!0);var I=function(t,e){this.string=t,this.nodeTypes=e,this.inline=null,this.pos=0,this.tokens=t.split(/\s*(?=\b|\W|$)/),""==this.tokens[this.tokens.length-1]&&this.tokens.pop(),""==this.tokens[0]&&this.tokens.shift()},B={next:{configurable:!0}};function F(t){var e=[];do{e.push(V(t))}while(t.eat("|"));return 1==e.length?e[0]:{type:"choice",exprs:e}}function V(t){var e=[];do{e.push($(t))}while(t.next&&")"!=t.next&&"|"!=t.next);return 1==e.length?e[0]:{type:"seq",exprs:e}}function $(t){for(var e=function(t){if(t.eat("(")){var e=F(t);return t.eat(")")||t.err("Missing closing paren"),e}if(!/\W/.test(t.next)){var n=function(t,e){var n=t.nodeTypes,r=n[e];if(r)return[r];var o=[];for(var i in n){var s=n[i];s.groups.indexOf(e)>-1&&o.push(s)}0==o.length&&t.err("No node type or group '"+e+"' found");return o}(t,t.next).map((function(e){return null==t.inline?t.inline=e.isInline:t.inline!=e.isInline&&t.err("Mixing inline and block content"),{type:"name",value:e}}));return t.pos++,1==n.length?n[0]:{type:"choice",exprs:n}}t.err("Unexpected token '"+t.next+"'")}(t);;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else{if(!t.eat("{"))break;e=L(t,e)}return e}function _(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");var e=Number(t.next);return t.pos++,e}function L(t,e){var n=_(t),r=n;return t.eat(",")&&(r="}"!=t.next?_(t):-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function j(t,e){return e-t}function q(t,e){var n=[];return function e(r){var o=t[r];if(1==o.length&&!o[0].term)return e(o[0].to);n.push(r);for(var i=0;i<o.length;i++){var s=o[i],a=s.term,c=s.to;a||-1!=n.indexOf(c)||e(c)}}(e),n.sort(j)}function J(t){var e=Object.create(null);for(var n in t){var r=t[n];if(!r.hasDefault)return null;e[n]=r.default}return e}function W(t,e){var n=Object.create(null);for(var r in t){var o=e&&e[r];if(void 0===o){var i=t[r];if(!i.hasDefault)throw new RangeError("No value supplied for attribute "+r);o=i.default}n[r]=o}return n}function K(t){var e=Object.create(null);if(t)for(var n in t)e[n]=new G(t[n]);return e}B.next.get=function(){return this.tokens[this.pos]},I.prototype.eat=function(t){return this.next==t&&(this.pos++||!0)},I.prototype.err=function(t){throw new SyntaxError(t+" (in content expression '"+this.string+"')")},Object.defineProperties(I.prototype,B);var H=function(t,e,n){this.name=t,this.schema=e,this.spec=n,this.groups=n.group?n.group.split(" "):[],this.attrs=K(n.attrs),this.defaultAttrs=J(this.attrs),this.contentMatch=null,this.markSet=null,this.inlineContent=null,this.isBlock=!(n.inline||"text"==t),this.isText="text"==t},U={isInline:{configurable:!0},isTextblock:{configurable:!0},isLeaf:{configurable:!0},isAtom:{configurable:!0}};U.isInline.get=function(){return!this.isBlock},U.isTextblock.get=function(){return this.isBlock&&this.inlineContent},U.isLeaf.get=function(){return this.contentMatch==z.empty},U.isAtom.get=function(){return this.isLeaf||this.spec.atom},H.prototype.hasRequiredAttrs=function(){for(var t in this.attrs)if(this.attrs[t].isRequired)return!0;return!1},H.prototype.compatibleContent=function(t){return this==t||this.contentMatch.compatible(t.contentMatch)},H.prototype.computeAttrs=function(t){return!t&&this.defaultAttrs?this.defaultAttrs:W(this.attrs,t)},H.prototype.create=function(t,e,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new A(this,this.computeAttrs(t),r.from(e),c.setFrom(n))},H.prototype.createChecked=function(t,e,n){if(e=r.from(e),!this.validContent(e))throw new RangeError("Invalid content for node "+this.name);return new A(this,this.computeAttrs(t),e,c.setFrom(n))},H.prototype.createAndFill=function(t,e,n){if(t=this.computeAttrs(t),(e=r.from(e)).size){var o=this.contentMatch.fillBefore(e);if(!o)return null;e=o.append(e)}var i=this.contentMatch.matchFragment(e).fillBefore(r.empty,!0);return i?new A(this,t,e.append(i),c.setFrom(n)):null},H.prototype.validContent=function(t){var e=this.contentMatch.matchFragment(t);if(!e||!e.validEnd)return!1;for(var n=0;n<t.childCount;n++)if(!this.allowsMarks(t.child(n).marks))return!1;return!0},H.prototype.allowsMarkType=function(t){return null==this.markSet||this.markSet.indexOf(t)>-1},H.prototype.allowsMarks=function(t){if(null==this.markSet)return!0;for(var e=0;e<t.length;e++)if(!this.allowsMarkType(t[e].type))return!1;return!0},H.prototype.allowedMarks=function(t){if(null==this.markSet)return t;for(var e,n=0;n<t.length;n++)this.allowsMarkType(t[n].type)?e&&e.push(t[n]):e||(e=t.slice(0,n));return e?e.length?e:c.empty:t},H.compile=function(t,e){var n=Object.create(null);t.forEach((function(t,r){return n[t]=new H(t,e,r)}));var r=e.spec.topNode||"doc";if(!n[r])throw new RangeError("Schema is missing its top node type ('"+r+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(var o in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n},Object.defineProperties(H.prototype,U);var G=function(t){this.hasDefault=Object.prototype.hasOwnProperty.call(t,"default"),this.default=t.default},X={isRequired:{configurable:!0}};X.isRequired.get=function(){return!this.hasDefault},Object.defineProperties(G.prototype,X);var Y=function(t,e,n,r){this.name=t,this.schema=n,this.spec=r,this.attrs=K(r.attrs),this.rank=e,this.excluded=null;var o=J(this.attrs);this.instance=o&&new c(this,o)};Y.prototype.create=function(t){return!t&&this.instance?this.instance:new c(this,W(this.attrs,t))},Y.compile=function(t,e){var n=Object.create(null),r=0;return t.forEach((function(t,o){return n[t]=new Y(t,r++,e,o)})),n},Y.prototype.removeFromSet=function(t){for(var e=0;e<t.length;e++)t[e].type==this&&(t=t.slice(0,e).concat(t.slice(e+1)),e--);return t},Y.prototype.isInSet=function(t){for(var e=0;e<t.length;e++)if(t[e].type==this)return t[e]},Y.prototype.excludes=function(t){return this.excluded.indexOf(t)>-1};var Q=function(t,e){var n=this;this.schema=t,this.rules=e,this.tags=[],this.styles=[],e.forEach((function(t){t.tag?n.tags.push(t):t.style&&n.styles.push(t)})),this.normalizeLists=!this.tags.some((function(e){if(!/^(ul|ol)\b/.test(e.tag)||!e.node)return!1;var n=t.nodes[e.node];return n.contentMatch.matchType(n)}))};Q.prototype.parse=function(t,e){void 0===e&&(e={});var n=new ot(this,e,!1);return n.addAll(t,null,e.from,e.to),n.finish()},Q.prototype.parseSlice=function(t,e){void 0===e&&(e={});var n=new ot(this,e,!0);return n.addAll(t,null,e.from,e.to),p.maxOpen(n.finish())},Q.prototype.matchTag=function(t,e,n){for(var r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){var o=this.tags[r];if(st(t,o.tag)&&(void 0===o.namespace||t.namespaceURI==o.namespace)&&(!o.context||e.matchesContext(o.context))){if(o.getAttrs){var i=o.getAttrs(t);if(!1===i)continue;o.attrs=i}return o}}},Q.prototype.matchStyle=function(t,e,n,r){for(var o=r?this.styles.indexOf(r)+1:0;o<this.styles.length;o++){var i=this.styles[o];if(!(0!=i.style.indexOf(t)||i.context&&!n.matchesContext(i.context)||i.style.length>t.length&&(61!=i.style.charCodeAt(t.length)||i.style.slice(t.length+1)!=e))){if(i.getAttrs){var s=i.getAttrs(e);if(!1===s)continue;i.attrs=s}return i}}},Q.schemaRules=function(t){var e=[];function n(t){for(var n=null==t.priority?50:t.priority,r=0;r<e.length;r++){var o=e[r];if((null==o.priority?50:o.priority)<n)break}e.splice(r,0,t)}var r=function(e){var r=t.marks[e].spec.parseDOM;r&&r.forEach((function(t){n(t=at(t)),t.mark=e}))};for(var o in t.marks)r(o);var i;for(var s in t.nodes)i=void 0,(i=t.nodes[s].spec.parseDOM)&&i.forEach((function(t){n(t=at(t)),t.node=s}));return e},Q.fromSchema=function(t){return t.cached.domParser||(t.cached.domParser=new Q(t,Q.schemaRules(t)))};var Z={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},tt={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},et={ol:!0,ul:!0};function nt(t){return(t?1:0)|("full"===t?2:0)}var rt=function(t,e,n,r,o,i,s){this.type=t,this.attrs=e,this.solid=o,this.match=i||(4&s?null:t.contentMatch),this.options=s,this.content=[],this.marks=n,this.activeMarks=c.none,this.pendingMarks=r,this.stashMarks=[]};rt.prototype.findWrapping=function(t){if(!this.match){if(!this.type)return[];var e=this.type.contentMatch.fillBefore(r.from(t));if(!e){var n,o=this.type.contentMatch;return(n=o.findWrapping(t.type))?(this.match=o,n):null}this.match=this.type.contentMatch.matchFragment(e)}return this.match.findWrapping(t.type)},rt.prototype.finish=function(t){if(!(1&this.options)){var e,n=this.content[this.content.length-1];n&&n.isText&&(e=/[ \t\r\n\u000c]+$/.exec(n.text))&&(n.text.length==e[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-e[0].length)))}var o=r.from(this.content);return!t&&this.match&&(o=o.append(this.match.fillBefore(r.empty,!0))),this.type?this.type.create(this.attrs,o,this.marks):o},rt.prototype.popFromStashMark=function(t){for(var e=this.stashMarks.length-1;e>=0;e--)if(t.eq(this.stashMarks[e]))return this.stashMarks.splice(e,1)[0]},rt.prototype.applyPending=function(t){for(var e=0,n=this.pendingMarks;e<n.length;e++){var r=n[e];(this.type?this.type.allowsMarkType(r.type):ct(r.type,t))&&!r.isInSet(this.activeMarks)&&(this.activeMarks=r.addToSet(this.activeMarks),this.pendingMarks=r.removeFromSet(this.pendingMarks))}};var ot=function(t,e,n){this.parser=t,this.options=e,this.isOpen=n;var r,o=e.topNode,i=nt(e.preserveWhitespace)|(n?4:0);r=o?new rt(o.type,o.attrs,c.none,c.none,!0,e.topMatch||o.type.contentMatch,i):new rt(n?null:t.schema.topNodeType,null,c.none,c.none,!0,null,i),this.nodes=[r],this.open=0,this.find=e.findPositions,this.needsBlock=!1},it={top:{configurable:!0},currentPos:{configurable:!0}};function st(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function at(t){var e={};for(var n in t)e[n]=t[n];return e}function ct(t,e){var n=e.schema.nodes,r=function(r){var o=n[r];if(o.allowsMarkType(t)){var i=[],s=function(t){i.push(t);for(var n=0;n<t.edgeCount;n++){var r=t.edge(n),o=r.type,a=r.next;if(o==e)return!0;if(i.indexOf(a)<0&&s(a))return!0}};return s(o.contentMatch)?{v:!0}:void 0}};for(var o in n){var i=r(o);if(i)return i.v}}it.top.get=function(){return this.nodes[this.open]},ot.prototype.addDOM=function(t){if(3==t.nodeType)this.addTextNode(t);else if(1==t.nodeType){var e=t.getAttribute("style"),n=e?this.readStyles(function(t){var e,n=/\s*([\w-]+)\s*:\s*([^;]+)/g,r=[];for(;e=n.exec(t);)r.push(e[1],e[2].trim());return r}(e)):null,r=this.top;if(null!=n)for(var o=0;o<n.length;o++)this.addPendingMark(n[o]);if(this.addElement(t),null!=n)for(var i=0;i<n.length;i++)this.removePendingMark(n[i],r)}},ot.prototype.addTextNode=function(t){var e=t.nodeValue,n=this.top;if((n.type?n.type.inlineContent:n.content.length&&n.content[0].isInline)||/[^ \t\r\n\u000c]/.test(e)){if(1&n.options)e=2&n.options?e.replace(/\r\n?/g,"\n"):e.replace(/\r?\n|\r/g," ");else if(e=e.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(e)&&this.open==this.nodes.length-1){var r=n.content[n.content.length-1],o=t.previousSibling;(!r||o&&"BR"==o.nodeName||r.isText&&/[ \t\r\n\u000c]$/.test(r.text))&&(e=e.slice(1))}e&&this.insertNode(this.parser.schema.text(e)),this.findInText(t)}else this.findInside(t)},ot.prototype.addElement=function(t,e){var n,r=t.nodeName.toLowerCase();et.hasOwnProperty(r)&&this.parser.normalizeLists&&function(t){for(var e=t.firstChild,n=null;e;e=e.nextSibling){var r=1==e.nodeType?e.nodeName.toLowerCase():null;r&&et.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):"li"==r?n=e:r&&(n=null)}}(t);var o=this.options.ruleFromNode&&this.options.ruleFromNode(t)||(n=this.parser.matchTag(t,this,e));if(o?o.ignore:tt.hasOwnProperty(r))this.findInside(t),this.ignoreFallback(t);else if(!o||o.skip||o.closeParent){o&&o.closeParent?this.open=Math.max(0,this.open-1):o&&o.skip.nodeType&&(t=o.skip);var i,s=this.top,a=this.needsBlock;if(Z.hasOwnProperty(r))i=!0,s.type||(this.needsBlock=!0);else if(!t.firstChild)return void this.leafFallback(t);this.addAll(t),i&&this.sync(s),this.needsBlock=a}else this.addElementByRule(t,o,!1===o.consuming?n:null)},ot.prototype.leafFallback=function(t){"BR"==t.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(t.ownerDocument.createTextNode("\n"))},ot.prototype.ignoreFallback=function(t){"BR"!=t.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"))},ot.prototype.readStyles=function(t){var e=c.none;t:for(var n=0;n<t.length;n+=2)for(var r=null;;){var o=this.parser.matchStyle(t[n],t[n+1],this,r);if(!o)continue t;if(o.ignore)return null;if(e=this.parser.schema.marks[o.mark].create(o.attrs).addToSet(e),!1!==o.consuming)break;r=o}return e},ot.prototype.addElementByRule=function(t,e,n){var r,o,i,s=this;e.node?(o=this.parser.schema.nodes[e.node]).isLeaf?this.insertNode(o.create(e.attrs))||this.leafFallback(t):r=this.enter(o,e.attrs,e.preserveWhitespace):(i=this.parser.schema.marks[e.mark].create(e.attrs),this.addPendingMark(i));var a=this.top;if(o&&o.isLeaf)this.findInside(t);else if(n)this.addElement(t,n);else if(e.getContent)this.findInside(t),e.getContent(t,this.parser.schema).forEach((function(t){return s.insertNode(t)}));else{var c=e.contentElement;"string"==typeof c?c=t.querySelector(c):"function"==typeof c&&(c=c(t)),c||(c=t),this.findAround(t,c,!0),this.addAll(c,r)}r&&(this.sync(a),this.open--),i&&this.removePendingMark(i,a)},ot.prototype.addAll=function(t,e,n,r){for(var o=n||0,i=n?t.childNodes[n]:t.firstChild,s=null==r?null:t.childNodes[r];i!=s;i=i.nextSibling,++o)this.findAtPoint(t,o),this.addDOM(i),e&&Z.hasOwnProperty(i.nodeName.toLowerCase())&&this.sync(e);this.findAtPoint(t,o)},ot.prototype.findPlace=function(t){for(var e,n,r=this.open;r>=0;r--){var o=this.nodes[r],i=o.findWrapping(t);if(i&&(!e||e.length>i.length)&&(e=i,n=o,!i.length))break;if(o.solid)break}if(!e)return!1;this.sync(n);for(var s=0;s<e.length;s++)this.enterInner(e[s],null,!1);return!0},ot.prototype.insertNode=function(t){if(t.isInline&&this.needsBlock&&!this.top.type){var e=this.textblockFromContext();e&&this.enterInner(e)}if(this.findPlace(t)){this.closeExtra();var n=this.top;n.applyPending(t.type),n.match&&(n.match=n.match.matchType(t.type));for(var r=n.activeMarks,o=0;o<t.marks.length;o++)n.type&&!n.type.allowsMarkType(t.marks[o].type)||(r=t.marks[o].addToSet(r));return n.content.push(t.mark(r)),!0}return!1},ot.prototype.enter=function(t,e,n){var r=this.findPlace(t.create(e));return r&&this.enterInner(t,e,!0,n),r},ot.prototype.enterInner=function(t,e,n,r){this.closeExtra();var o=this.top;o.applyPending(t),o.match=o.match&&o.match.matchType(t,e);var i=null==r?-5&o.options:nt(r);4&o.options&&0==o.content.length&&(i|=4),this.nodes.push(new rt(t,e,o.activeMarks,o.pendingMarks,n,null,i)),this.open++},ot.prototype.closeExtra=function(t){var e=this.nodes.length-1;if(e>this.open){for(;e>this.open;e--)this.nodes[e-1].content.push(this.nodes[e].finish(t));this.nodes.length=this.open+1}},ot.prototype.finish=function(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)},ot.prototype.sync=function(t){for(var e=this.open;e>=0;e--)if(this.nodes[e]==t)return void(this.open=e)},it.currentPos.get=function(){this.closeExtra();for(var t=0,e=this.open;e>=0;e--){for(var n=this.nodes[e].content,r=n.length-1;r>=0;r--)t+=n[r].nodeSize;e&&t++}return t},ot.prototype.findAtPoint=function(t,e){if(this.find)for(var n=0;n<this.find.length;n++)this.find[n].node==t&&this.find[n].offset==e&&(this.find[n].pos=this.currentPos)},ot.prototype.findInside=function(t){if(this.find)for(var e=0;e<this.find.length;e++)null==this.find[e].pos&&1==t.nodeType&&t.contains(this.find[e].node)&&(this.find[e].pos=this.currentPos)},ot.prototype.findAround=function(t,e,n){if(t!=e&&this.find)for(var r=0;r<this.find.length;r++){if(null==this.find[r].pos&&1==t.nodeType&&t.contains(this.find[r].node))e.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}},ot.prototype.findInText=function(t){if(this.find)for(var e=0;e<this.find.length;e++)this.find[e].node==t&&(this.find[e].pos=this.currentPos-(t.nodeValue.length-this.find[e].offset))},ot.prototype.matchesContext=function(t){var e=this;if(t.indexOf("|")>-1)return t.split(/\s*\|\s*/).some(this.matchesContext,this);var n=t.split("/"),r=this.options.context,o=!(this.isOpen||r&&r.parent.type!=this.nodes[0].type),i=-(r?r.depth+1:0)+(o?0:1),s=function(t,a){for(;t>=0;t--){var c=n[t];if(""==c){if(t==n.length-1||0==t)continue;for(;a>=i;a--)if(s(t-1,a))return!0;return!1}var h=a>0||0==a&&o?e.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!h||h.name!=c&&-1==h.groups.indexOf(c))return!1;a--}return!0};return s(n.length-1,this.open)},ot.prototype.textblockFromContext=function(){var t=this.options.context;if(t)for(var e=t.depth;e>=0;e--){var n=t.node(e).contentMatchAt(t.indexAfter(e)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(var r in this.parser.schema.nodes){var o=this.parser.schema.nodes[r];if(o.isTextblock&&o.defaultAttrs)return o}},ot.prototype.addPendingMark=function(t){var e=function(t,e){for(var n=0;n<e.length;n++)if(t.eq(e[n]))return e[n]}(t,this.top.pendingMarks);e&&this.top.stashMarks.push(e),this.top.pendingMarks=t.addToSet(this.top.pendingMarks)},ot.prototype.removePendingMark=function(t,e){for(var n=this.open;n>=0;n--){var r=this.nodes[n];if(r.pendingMarks.lastIndexOf(t)>-1)r.pendingMarks=t.removeFromSet(r.pendingMarks);else{r.activeMarks=t.removeFromSet(r.activeMarks);var o=r.popFromStashMark(t);o&&r.type&&r.type.allowsMarkType(o.type)&&(r.activeMarks=o.addToSet(r.activeMarks))}if(r==e)break}},Object.defineProperties(ot.prototype,it);var ht=function(t,e){this.nodes=t||{},this.marks=e||{}};function pt(t){var e={};for(var n in t){var r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function lt(t){return t.document||window.document}ht.prototype.serializeFragment=function(t,e,n){var r=this;void 0===e&&(e={}),n||(n=lt(e).createDocumentFragment());var o=n,i=null;return t.forEach((function(t){if(i||t.marks.length){i||(i=[]);for(var n=0,s=0;n<i.length&&s<t.marks.length;){var a=t.marks[s];if(r.marks[a.type.name]){if(!a.eq(i[n])||!1===a.type.spec.spanning)break;n+=2,s++}else s++}for(;n<i.length;)o=i.pop(),i.pop();for(;s<t.marks.length;){var c=t.marks[s++],h=r.serializeMark(c,t.isInline,e);h&&(i.push(c,o),o.appendChild(h.dom),o=h.contentDOM||h.dom)}}o.appendChild(r.serializeNode(t,e))})),n},ht.prototype.serializeNode=function(t,e){void 0===e&&(e={});var n=ht.renderSpec(lt(e),this.nodes[t.type.name](t)),r=n.dom,o=n.contentDOM;if(o){if(t.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");e.onContent?e.onContent(t,o,e):this.serializeFragment(t.content,e,o)}return r},ht.prototype.serializeNodeAndMarks=function(t,e){void 0===e&&(e={});for(var n=this.serializeNode(t,e),r=t.marks.length-1;r>=0;r--){var o=this.serializeMark(t.marks[r],t.isInline,e);o&&((o.contentDOM||o.dom).appendChild(n),n=o.dom)}return n},ht.prototype.serializeMark=function(t,e,n){void 0===n&&(n={});var r=this.marks[t.type.name];return r&&ht.renderSpec(lt(n),r(t,e))},ht.renderSpec=function(t,e,n){if(void 0===n&&(n=null),"string"==typeof e)return{dom:t.createTextNode(e)};if(null!=e.nodeType)return{dom:e};if(e.dom&&null!=e.dom.nodeType)return e;var r=e[0],o=r.indexOf(" ");o>0&&(n=r.slice(0,o),r=r.slice(o+1));var i=null,s=n?t.createElementNS(n,r):t.createElement(r),a=e[1],c=1;if(a&&"object"==typeof a&&null==a.nodeType&&!Array.isArray(a))for(var h in c=2,a)if(null!=a[h]){var p=h.indexOf(" ");p>0?s.setAttributeNS(h.slice(0,p),h.slice(p+1),a[h]):s.setAttribute(h,a[h])}for(var l=c;l<e.length;l++){var f=e[l];if(0===f){if(l<e.length-1||l>c)throw new RangeError("Content hole must be the only child of its parent node");return{dom:s,contentDOM:s}}var u=ht.renderSpec(t,f,n),d=u.dom,m=u.contentDOM;if(s.appendChild(d),m){if(i)throw new RangeError("Multiple content holes");i=m}}return{dom:s,contentDOM:i}},ht.fromSchema=function(t){return t.cached.domSerializer||(t.cached.domSerializer=new ht(this.nodesFromSchema(t),this.marksFromSchema(t)))},ht.nodesFromSchema=function(t){var e=pt(t.nodes);return e.text||(e.text=function(t){return t.text}),e},ht.marksFromSchema=function(t){return pt(t.marks)};var ft=Math.pow(2,16);function ut(t){return 65535&t}var dt=function(t,e,n){void 0===e&&(e=!1),void 0===n&&(n=null),this.pos=t,this.deleted=e,this.recover=n},mt=function(t,e){void 0===e&&(e=!1),this.ranges=t,this.inverted=e};mt.prototype.recover=function(t){var e=0,n=ut(t);if(!this.inverted)for(var r=0;r<n;r++)e+=this.ranges[3*r+2]-this.ranges[3*r+1];return this.ranges[3*n]+e+function(t){return(t-(65535&t))/ft}(t)},mt.prototype.mapResult=function(t,e){return void 0===e&&(e=1),this._map(t,e,!1)},mt.prototype.map=function(t,e){return void 0===e&&(e=1),this._map(t,e,!0)},mt.prototype._map=function(t,e,n){for(var r=0,o=this.inverted?2:1,i=this.inverted?1:2,s=0;s<this.ranges.length;s+=3){var a=this.ranges[s]-(this.inverted?r:0);if(a>t)break;var c=this.ranges[s+o],h=this.ranges[s+i],p=a+c;if(t<=p){var l=a+r+((c?t==a?-1:t==p?1:e:e)<0?0:h);if(n)return l;var f=t==(e<0?a:p)?null:s/3+(t-a)*ft;return new dt(l,e<0?t!=a:t!=p,f)}r+=h-c}return n?t+r:new dt(t+r)},mt.prototype.touches=function(t,e){for(var n=0,r=ut(e),o=this.inverted?2:1,i=this.inverted?1:2,s=0;s<this.ranges.length;s+=3){var a=this.ranges[s]-(this.inverted?n:0);if(a>t)break;var c=this.ranges[s+o];if(t<=a+c&&s==3*r)return!0;n+=this.ranges[s+i]-c}return!1},mt.prototype.forEach=function(t){for(var e=this.inverted?2:1,n=this.inverted?1:2,r=0,o=0;r<this.ranges.length;r+=3){var i=this.ranges[r],s=i-(this.inverted?o:0),a=i+(this.inverted?0:o),c=this.ranges[r+e],h=this.ranges[r+n];t(s,s+c,a,a+h),o+=h-c}},mt.prototype.invert=function(){return new mt(this.ranges,!this.inverted)},mt.prototype.toString=function(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)},mt.offset=function(t){return 0==t?mt.empty:new mt(t<0?[0,-t,0]:[0,0,t])},mt.empty=new mt([]);var vt=function(t,e,n,r){this.maps=t||[],this.from=n||0,this.to=null==r?this.maps.length:r,this.mirror=e};function gt(t){var e=Error.call(this,t);return e.__proto__=gt.prototype,e}vt.prototype.slice=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=this.maps.length),new vt(this.maps,this.mirror,t,e)},vt.prototype.copy=function(){return new vt(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)},vt.prototype.appendMap=function(t,e){this.to=this.maps.push(t),null!=e&&this.setMirror(this.maps.length-1,e)},vt.prototype.appendMapping=function(t){for(var e=0,n=this.maps.length;e<t.maps.length;e++){var r=t.getMirror(e);this.appendMap(t.maps[e],null!=r&&r<e?n+r:null)}},vt.prototype.getMirror=function(t){if(this.mirror)for(var e=0;e<this.mirror.length;e++)if(this.mirror[e]==t)return this.mirror[e+(e%2?-1:1)]},vt.prototype.setMirror=function(t,e){this.mirror||(this.mirror=[]),this.mirror.push(t,e)},vt.prototype.appendMappingInverted=function(t){for(var e=t.maps.length-1,n=this.maps.length+t.maps.length;e>=0;e--){var r=t.getMirror(e);this.appendMap(t.maps[e].invert(),null!=r&&r>e?n-r-1:null)}},vt.prototype.invert=function(){var t=new vt;return t.appendMappingInverted(this),t},vt.prototype.map=function(t,e){if(void 0===e&&(e=1),this.mirror)return this._map(t,e,!0);for(var n=this.from;n<this.to;n++)t=this.maps[n].map(t,e);return t},vt.prototype.mapResult=function(t,e){return void 0===e&&(e=1),this._map(t,e,!1)},vt.prototype._map=function(t,e,n){for(var r=!1,o=this.from;o<this.to;o++){var i=this.maps[o].mapResult(t,e);if(null!=i.recover){var s=this.getMirror(o);if(null!=s&&s>o&&s<this.to){o=s,t=this.maps[s].recover(i.recover);continue}}i.deleted&&(r=!0),t=i.pos}return n?t:new dt(t,r)},gt.prototype=Object.create(Error.prototype),gt.prototype.constructor=gt,gt.prototype.name="TransformError";var yt=function(t){this.doc=t,this.steps=[],this.docs=[],this.mapping=new vt},wt={before:{configurable:!0},docChanged:{configurable:!0}};function bt(){throw new Error("Override me")}wt.before.get=function(){return this.docs.length?this.docs[0]:this.doc},yt.prototype.step=function(t){var e=this.maybeStep(t);if(e.failed)throw new gt(e.failed);return this},yt.prototype.maybeStep=function(t){var e=t.apply(this.doc);return e.failed||this.addStep(t,e.doc),e},wt.docChanged.get=function(){return this.steps.length>0},yt.prototype.addStep=function(t,e){this.docs.push(this.doc),this.steps.push(t),this.mapping.appendMap(t.getMap()),this.doc=e},Object.defineProperties(yt.prototype,wt);var xt=Object.create(null),St=function(){};St.prototype.apply=function(t){return bt()},St.prototype.getMap=function(){return mt.empty},St.prototype.invert=function(t){return bt()},St.prototype.map=function(t){return bt()},St.prototype.merge=function(t){return null},St.prototype.toJSON=function(){return bt()},St.fromJSON=function(t,e){if(!e||!e.stepType)throw new RangeError("Invalid input for Step.fromJSON");var n=xt[e.stepType];if(!n)throw new RangeError("No step type "+e.stepType+" defined");return n.fromJSON(t,e)},St.jsonID=function(t,e){if(t in xt)throw new RangeError("Duplicate use of step JSON ID "+t);return xt[t]=e,e.prototype.jsonID=t,e};var kt=function(t,e){this.doc=t,this.failed=e};kt.ok=function(t){return new kt(t,null)},kt.fail=function(t){return new kt(null,t)},kt.fromReplace=function(t,e,n,r){try{return kt.ok(t.replace(e,n,r))}catch(t){if(t instanceof h)return kt.fail(t.message);throw t}};var Ot=function(t){function e(e,n,r,o){t.call(this),this.from=e,this.to=n,this.slice=r,this.structure=!!o}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.apply=function(t){return this.structure&&Ct(t,this.from,this.to)?kt.fail("Structure replace would overwrite content"):kt.fromReplace(t,this.from,this.to,this.slice)},e.prototype.getMap=function(){return new mt([this.from,this.to-this.from,this.slice.size])},e.prototype.invert=function(t){return new e(this.from,this.from+this.slice.size,t.slice(this.from,this.to))},e.prototype.map=function(t){var n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted?null:new e(n.pos,Math.max(n.pos,r.pos),this.slice)},e.prototype.merge=function(t){if(!(t instanceof e)||t.structure||this.structure)return null;if(this.from+this.slice.size!=t.from||this.slice.openEnd||t.slice.openStart){if(t.to!=this.from||this.slice.openStart||t.slice.openEnd)return null;var n=this.slice.size+t.slice.size==0?p.empty:new p(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new e(t.from,this.to,n,this.structure)}var r=this.slice.size+t.slice.size==0?p.empty:new p(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new e(this.from,this.to+(t.to-t.from),r,this.structure)},e.prototype.toJSON=function(){var t={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t},e.fromJSON=function(t,n){if("number"!=typeof n.from||"number"!=typeof n.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new e(n.from,n.to,p.fromJSON(t,n.slice),!!n.structure)},e}(St);St.jsonID("replace",Ot);var Mt=function(t){function e(e,n,r,o,i,s,a){t.call(this),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=o,this.slice=i,this.insert=s,this.structure=!!a}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.apply=function(t){if(this.structure&&(Ct(t,this.from,this.gapFrom)||Ct(t,this.gapTo,this.to)))return kt.fail("Structure gap-replace would overwrite content");var e=t.slice(this.gapFrom,this.gapTo);if(e.openStart||e.openEnd)return kt.fail("Gap is not a flat range");var n=this.slice.insertAt(this.insert,e.content);return n?kt.fromReplace(t,this.from,this.to,n):kt.fail("Content does not fit in gap")},e.prototype.getMap=function(){return new mt([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])},e.prototype.invert=function(t){var n=this.gapTo-this.gapFrom;return new e(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)},e.prototype.map=function(t){var n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1),o=t.map(this.gapFrom,-1),i=t.map(this.gapTo,1);return n.deleted&&r.deleted||o<n.pos||i>r.pos?null:new e(n.pos,r.pos,o,i,this.slice,this.insert,this.structure)},e.prototype.toJSON=function(){var t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t},e.fromJSON=function(t,n){if("number"!=typeof n.from||"number"!=typeof n.to||"number"!=typeof n.gapFrom||"number"!=typeof n.gapTo||"number"!=typeof n.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new e(n.from,n.to,n.gapFrom,n.gapTo,p.fromJSON(t,n.slice),n.insert,!!n.structure)},e}(St);function Ct(t,e,n){for(var r=t.resolve(e),o=n-e,i=r.depth;o>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,o--;if(o>0)for(var s=r.node(i).maybeChild(r.indexAfter(i));o>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,o--}return!1}function Nt(t,e,n){for(var o=[],i=0;i<t.childCount;i++){var s=t.child(i);s.content.size&&(s=s.copy(Nt(s.content,e,s))),s.isInline&&(s=e(s,n,i)),o.push(s)}return r.fromArray(o)}St.jsonID("replaceAround",Mt),yt.prototype.lift=function(t,e){for(var n=t.$from,o=t.$to,i=t.depth,s=n.before(i+1),a=o.after(i+1),c=s,h=a,l=r.empty,f=0,u=i,d=!1;u>e;u--)d||n.index(u)>0?(d=!0,l=r.from(n.node(u).copy(l)),f++):c--;for(var m=r.empty,v=0,g=i,y=!1;g>e;g--)y||o.after(g+1)<o.end(g)?(y=!0,m=r.from(o.node(g).copy(m)),v++):h++;return this.step(new Mt(c,h,s,a,new p(l.append(m),f,v),l.size-f,!0))},yt.prototype.wrap=function(t,e){for(var n=r.empty,o=e.length-1;o>=0;o--)n=r.from(e[o].type.create(e[o].attrs,n));var i=t.start,s=t.end;return this.step(new Mt(i,s,i,s,new p(n,0,0),e.length,!0))},yt.prototype.setBlockType=function(t,e,n,o){var i=this;if(void 0===e&&(e=t),!n.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");var s=this.steps.length;return this.doc.nodesBetween(t,e,(function(t,e){if(t.isTextblock&&!t.hasMarkup(n,o)&&function(t,e,n){var r=t.resolve(e),o=r.index();return r.parent.canReplaceWith(o,o+1,n)}(i.doc,i.mapping.slice(s).map(e),n)){i.clearIncompatible(i.mapping.slice(s).map(e,1),n);var a=i.mapping.slice(s),c=a.map(e,1),h=a.map(e+t.nodeSize,1);return i.step(new Mt(c,h,c+1,h-1,new p(r.from(n.create(o,null,t.marks)),0,0),1,!0)),!1}})),this},yt.prototype.setNodeMarkup=function(t,e,n,o){var i=this.doc.nodeAt(t);if(!i)throw new RangeError("No node at given position");e||(e=i.type);var s=e.create(n,null,o||i.marks);if(i.isLeaf)return this.replaceWith(t,t+i.nodeSize,s);if(!e.validContent(i.content))throw new RangeError("Invalid content for node type "+e.name);return this.step(new Mt(t,t+i.nodeSize,t+1,t+i.nodeSize-1,new p(r.from(s),0,0),1,!0))},yt.prototype.split=function(t,e,n){void 0===e&&(e=1);for(var o=this.doc.resolve(t),i=r.empty,s=r.empty,a=o.depth,c=o.depth-e,h=e-1;a>c;a--,h--){i=r.from(o.node(a).copy(i));var l=n&&n[h];s=r.from(l?l.type.create(l.attrs,s):o.node(a).copy(s))}return this.step(new Ot(t,t,new p(i.append(s),e,e),!0))},yt.prototype.join=function(t,e){void 0===e&&(e=1);var n=new Ot(t-e,t+e,p.empty,!0);return this.step(n)};var Dt=function(t){function e(e,n,r){t.call(this),this.from=e,this.to=n,this.mark=r}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.apply=function(t){var e=this,n=t.slice(this.from,this.to),r=t.resolve(this.from),o=r.node(r.sharedDepth(this.to)),i=new p(Nt(n.content,(function(t,n){return t.isAtom&&n.type.allowsMarkType(e.mark.type)?t.mark(e.mark.addToSet(t.marks)):t}),o),n.openStart,n.openEnd);return kt.fromReplace(t,this.from,this.to,i)},e.prototype.invert=function(){return new Tt(this.from,this.to,this.mark)},e.prototype.map=function(t){var n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)},e.prototype.merge=function(t){if(t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from)return new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark)},e.prototype.toJSON=function(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}},e.fromJSON=function(t,n){if("number"!=typeof n.from||"number"!=typeof n.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new e(n.from,n.to,t.markFromJSON(n.mark))},e}(St);St.jsonID("addMark",Dt);var Tt=function(t){function e(e,n,r){t.call(this),this.from=e,this.to=n,this.mark=r}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.apply=function(t){var e=this,n=t.slice(this.from,this.to),r=new p(Nt(n.content,(function(t){return t.mark(e.mark.removeFromSet(t.marks))})),n.openStart,n.openEnd);return kt.fromReplace(t,this.from,this.to,r)},e.prototype.invert=function(){return new Dt(this.from,this.to,this.mark)},e.prototype.map=function(t){var n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)},e.prototype.merge=function(t){if(t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from)return new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark)},e.prototype.toJSON=function(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}},e.fromJSON=function(t,n){if("number"!=typeof n.from||"number"!=typeof n.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new e(n.from,n.to,t.markFromJSON(n.mark))},e}(St);function Et(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}St.jsonID("removeMark",Tt),yt.prototype.addMark=function(t,e,n){var r=this,o=[],i=[],s=null,a=null;return this.doc.nodesBetween(t,e,(function(r,c,h){if(r.isInline){var p=r.marks;if(!n.isInSet(p)&&h.type.allowsMarkType(n.type)){for(var l=Math.max(c,t),f=Math.min(c+r.nodeSize,e),u=n.addToSet(p),d=0;d<p.length;d++)p[d].isInSet(u)||(s&&s.to==l&&s.mark.eq(p[d])?s.to=f:o.push(s=new Tt(l,f,p[d])));a&&a.to==l?a.to=f:i.push(a=new Dt(l,f,n))}}})),o.forEach((function(t){return r.step(t)})),i.forEach((function(t){return r.step(t)})),this},yt.prototype.removeMark=function(t,e,n){var r=this;void 0===n&&(n=null);var o=[],i=0;return this.doc.nodesBetween(t,e,(function(r,s){if(r.isInline){i++;var a=null;if(n instanceof Y)for(var c,h=r.marks;c=n.isInSet(h);)(a||(a=[])).push(c),h=c.removeFromSet(h);else n?n.isInSet(r.marks)&&(a=[n]):a=r.marks;if(a&&a.length)for(var p=Math.min(s+r.nodeSize,e),l=0;l<a.length;l++){for(var f=a[l],u=void 0,d=0;d<o.length;d++){var m=o[d];m.step==i-1&&f.eq(o[d].style)&&(u=m)}u?(u.to=p,u.step=i):o.push({style:f,from:Math.max(s,t),to:p,step:i})}}})),o.forEach((function(t){return r.step(new Tt(t.from,t.to,t.style))})),this},yt.prototype.clearIncompatible=function(t,e,n){void 0===n&&(n=e.contentMatch);for(var o=this.doc.nodeAt(t),i=[],s=t+1,a=0;a<o.childCount;a++){var c=o.child(a),h=s+c.nodeSize,l=n.matchType(c.type,c.attrs);if(l){n=l;for(var f=0;f<c.marks.length;f++)e.allowsMarkType(c.marks[f].type)||this.step(new Tt(s,h,c.marks[f]))}else i.push(new Ot(s,h,p.empty));s=h}if(!n.validEnd){var u=n.fillBefore(r.empty,!0);this.replace(s,s,new p(u,0,0))}for(var d=i.length-1;d>=0;d--)this.step(i[d]);return this},yt.prototype.replace=function(t,e,n){void 0===e&&(e=t),void 0===n&&(n=p.empty);var r=function(t,e,n,r){if(void 0===n&&(n=e),void 0===r&&(r=p.empty),e==n&&!r.size)return null;var o=t.resolve(e),i=t.resolve(n);return Et(o,i,r)?new Ot(e,n,r):new At(o,i,r).fit()}(this.doc,t,e,n);return r&&this.step(r),this},yt.prototype.replaceWith=function(t,e,n){return this.replace(t,e,new p(r.from(n),0,0))},yt.prototype.delete=function(t,e){return this.replace(t,e,p.empty)},yt.prototype.insert=function(t,e){return this.replaceWith(t,t,e)};var At=function(t,e,n){this.$to=e,this.$from=t,this.unplaced=n,this.frontier=[];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))})}this.placed=r.empty;for(var s=t.depth;s>0;s--)this.placed=r.from(t.node(s).copy(this.placed))},Rt={depth:{configurable:!0}};function zt(t,e,n){return 0==e?t.cutByIndex(n):t.replaceChild(0,t.firstChild.copy(zt(t.firstChild.content,e-1,n)))}function Pt(t,e,n){return 0==e?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Pt(t.lastChild.content,e-1,n)))}function It(t,e){for(var n=0;n<e;n++)t=t.firstChild.content;return t}function Bt(t,e,n){if(e<=0)return t;var o=t.content;return e>1&&(o=o.replaceChild(0,Bt(o.firstChild,e-1,1==o.childCount?n-1:0))),e>0&&(o=t.type.contentMatch.fillBefore(o).append(o),n<=0&&(o=o.append(t.type.contentMatch.matchFragment(o).fillBefore(r.empty,!0)))),t.copy(o)}function Ft(t,e,n,r,o){var i=t.node(e),s=o?t.indexAfter(e):t.index(e);if(s==i.childCount&&!n.compatibleContent(i.type))return null;var a=r.fillBefore(i.content,!0,s);return a&&!function(t,e,n){for(var r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}(n,i.content,s)?a:null}function Vt(t,e,n,o,i){if(e<n){var s=t.firstChild;t=t.replaceChild(0,s.copy(Vt(s.content,e+1,n,o,s)))}if(e>o){var a=i.contentMatchAt(0),c=a.fillBefore(t).append(t);t=c.append(a.matchFragment(c).fillBefore(r.empty,!0))}return t}function $t(t,e){for(var n=[],r=Math.min(t.depth,e.depth);r>=0;r--){var o=t.start(r);if(o<t.pos-(t.depth-r)||e.end(r)>e.pos+(e.depth-r)||t.node(r).type.spec.isolating||e.node(r).type.spec.isolating)break;o==e.start(r)&&n.push(r)}return n}Rt.depth.get=function(){return this.frontier.length-1},At.prototype.fit=function(){for(;this.unplaced.size;){var t=this.findFittable();t?this.placeNodes(t):this.openMore()||this.dropNode()}var e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,o=this.close(e<0?this.$to:r.doc.resolve(e));if(!o)return null;for(var i=this.placed,s=r.depth,a=o.depth;s&&a&&1==i.childCount;)i=i.firstChild.content,s--,a--;var c=new p(i,s,a);return e>-1?new Mt(r.pos,e,this.$to.pos,this.$to.end(),c,n):c.size||r.pos!=this.$to.pos?new Ot(r.pos,o.pos,c):void 0},At.prototype.findFittable=function(){for(var t=1;t<=2;t++)for(var e=this.unplaced.openStart;e>=0;e--)for(var n=void 0,o=(e?(n=It(this.unplaced.content,e-1).firstChild).content:this.unplaced.content).firstChild,i=this.depth;i>=0;i--){var s=this.frontier[i],a=s.type,c=s.match,h=void 0,p=void 0;if(1==t&&(o?c.matchType(o.type)||(p=c.fillBefore(r.from(o),!1)):a.compatibleContent(n.type)))return{sliceDepth:e,frontierDepth:i,parent:n,inject:p};if(2==t&&o&&(h=c.findWrapping(o.type)))return{sliceDepth:e,frontierDepth:i,parent:n,wrap:h};if(n&&c.matchType(n.type))break}},At.prototype.openMore=function(){var t=this.unplaced,e=t.content,n=t.openStart,r=t.openEnd,o=It(e,n);return!(!o.childCount||o.firstChild.isLeaf)&&(this.unplaced=new p(e,n+1,Math.max(r,o.size+n>=e.size-r?n+1:0)),!0)},At.prototype.dropNode=function(){var t=this.unplaced,e=t.content,n=t.openStart,r=t.openEnd,o=It(e,n);if(o.childCount<=1&&n>0){var i=e.size-n<=n+o.size;this.unplaced=new p(zt(e,n-1,1),n-1,i?n-1:r)}else this.unplaced=new p(zt(e,n,1),n,r)},At.prototype.placeNodes=function(t){for(var e=t.sliceDepth,n=t.frontierDepth,o=t.parent,i=t.inject,s=t.wrap;this.depth>n;)this.closeFrontierNode();if(s)for(var a=0;a<s.length;a++)this.openFrontierNode(s[a]);var c=this.unplaced,h=o?o.content:c.content,l=c.openStart-e,f=0,u=[],d=this.frontier[n],m=d.match,v=d.type;if(i){for(var g=0;g<i.childCount;g++)u.push(i.child(g));m=m.matchFragment(i)}for(var y=h.size+e-(c.content.size-c.openEnd);f<h.childCount;){var w=h.child(f),b=m.matchType(w.type);if(!b)break;(++f>1||0==l||w.content.size)&&(m=b,u.push(Bt(w.mark(v.allowedMarks(w.marks)),1==f?l:0,f==h.childCount?y:-1)))}var x=f==h.childCount;x||(y=-1),this.placed=Pt(this.placed,n,r.from(u)),this.frontier[n].match=m,x&&y<0&&o&&o.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(var S=0,k=h;S<y;S++){var O=k.lastChild;this.frontier.push({type:O.type,match:O.contentMatchAt(O.childCount)}),k=O.content}this.unplaced=x?0==e?p.empty:new p(zt(c.content,e-1,1),e-1,y<0?c.openEnd:e-1):new p(zt(c.content,e,f),c.openStart,c.openEnd)},At.prototype.mustMoveInline=function(){if(!this.$to.parent.isTextblock||this.$to.end()==this.$to.pos)return-1;var t,e=this.frontier[this.depth];if(!e.type.isTextblock||!Ft(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;for(var n=this.$to.depth,r=this.$to.after(n);n>1&&r==this.$to.end(--n);)++r;return r},At.prototype.findCloseLevel=function(t){t:for(var e=Math.min(this.depth,t.depth);e>=0;e--){var n=this.frontier[e],r=n.match,o=n.type,i=e<t.depth&&t.end(e+1)==t.pos+(t.depth-(e+1)),s=Ft(t,e,o,r,i);if(s){for(var a=e-1;a>=0;a--){var c=this.frontier[a],h=c.match,p=Ft(t,a,c.type,h,!0);if(!p||p.childCount)continue t}return{depth:e,fit:s,move:i?t.doc.resolve(t.after(e+1)):t}}}},At.prototype.close=function(t){var e=this.findCloseLevel(t);if(!e)return null;for(;this.depth>e.depth;)this.closeFrontierNode();e.fit.childCount&&(this.placed=Pt(this.placed,e.depth,e.fit)),t=e.move;for(var n=e.depth+1;n<=t.depth;n++){var r=t.node(n),o=r.type.contentMatch.fillBefore(r.content,!0,t.index(n));this.openFrontierNode(r.type,r.attrs,o)}return t},At.prototype.openFrontierNode=function(t,e,n){var o=this.frontier[this.depth];o.match=o.match.matchType(t),this.placed=Pt(this.placed,this.depth,r.from(t.create(e,n))),this.frontier.push({type:t,match:t.contentMatch})},At.prototype.closeFrontierNode=function(){var t=this.frontier.pop().match.fillBefore(r.empty,!0);t.childCount&&(this.placed=Pt(this.placed,this.frontier.length,t))},Object.defineProperties(At.prototype,Rt),yt.prototype.replaceRange=function(t,e,n){if(!n.size)return this.deleteRange(t,e);var r=this.doc.resolve(t),o=this.doc.resolve(e);if(Et(r,o,n))return this.step(new Ot(t,e,n));var i=$t(r,this.doc.resolve(e));0==i[i.length-1]&&i.pop();var s=-(r.depth+1);i.unshift(s);for(var a=r.depth,c=r.pos-1;a>0;a--,c--){var h=r.node(a).type.spec;if(h.defining||h.isolating)break;i.indexOf(a)>-1?s=a:r.before(a)==c&&i.splice(1,0,-a)}for(var l=i.indexOf(s),f=[],u=n.openStart,d=n.content,m=0;;m++){var v=d.firstChild;if(f.push(v),m==n.openStart)break;d=v.content}u>0&&f[u-1].type.spec.defining&&r.node(l).type!=f[u-1].type?u-=1:u>=2&&f[u-1].isTextblock&&f[u-2].type.spec.defining&&r.node(l).type!=f[u-2].type&&(u-=2);for(var g=n.openStart;g>=0;g--){var y=(g+u+1)%(n.openStart+1),w=f[y];if(w)for(var b=0;b<i.length;b++){var x=i[(b+l)%i.length],S=!0;x<0&&(S=!1,x=-x);var k=r.node(x-1),O=r.index(x-1);if(k.canReplaceWith(O,O,w.type,w.marks))return this.replace(r.before(x),S?o.after(x):e,new p(Vt(n.content,0,n.openStart,y),y,n.openEnd))}}for(var M=this.steps.length,C=i.length-1;C>=0&&(this.replace(t,e,n),!(this.steps.length>M));C--){var N=i[C];N<0||(t=r.before(N),e=o.after(N))}return this},yt.prototype.replaceRangeWith=function(t,e,n){if(!n.isInline&&t==e&&this.doc.resolve(t).parent.content.size){var o=function(t,e,n){var r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(0==r.parentOffset)for(var o=r.depth-1;o>=0;o--){var i=r.index(o);if(r.node(o).canReplaceWith(i,i,n))return r.before(o+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(var s=r.depth-1;s>=0;s--){var 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}}(this.doc,t,n.type);null!=o&&(t=e=o)}return this.replaceRange(t,e,new p(r.from(n),0,0))},yt.prototype.deleteRange=function(t,e){for(var n=this.doc.resolve(t),r=this.doc.resolve(e),o=$t(n,r),i=0;i<o.length;i++){var s=o[i],a=i==o.length-1;if(a&&0==s||n.node(s).type.contentMatch.validEnd)return this.delete(n.start(s),r.end(s));if(s>0&&(a||n.node(s-1).canReplace(n.index(s-1),r.indexAfter(s-1))))return this.delete(n.before(s),r.after(s))}for(var c=1;c<=n.depth&&c<=r.depth;c++)if(t-n.start(c)==n.depth-c&&e>n.end(c)&&r.end(c)-e!=r.depth-c)return this.delete(n.before(c),e);return this.delete(t,e)};var _t=Object.create(null),Lt=function(t,e,n){this.ranges=n||[new qt(t.min(e),t.max(e))],this.$anchor=t,this.$head=e},jt={anchor:{configurable:!0},head:{configurable:!0},from:{configurable:!0},to:{configurable:!0},$from:{configurable:!0},$to:{configurable:!0},empty:{configurable:!0}};jt.anchor.get=function(){return this.$anchor.pos},jt.head.get=function(){return this.$head.pos},jt.from.get=function(){return this.$from.pos},jt.to.get=function(){return this.$to.pos},jt.$from.get=function(){return this.ranges[0].$from},jt.$to.get=function(){return this.ranges[0].$to},jt.empty.get=function(){for(var t=this.ranges,e=0;e<t.length;e++)if(t[e].$from.pos!=t[e].$to.pos)return!1;return!0},Lt.prototype.content=function(){return this.$from.node(0).slice(this.from,this.to,!0)},Lt.prototype.replace=function(t,e){void 0===e&&(e=p.empty);for(var n=e.content.lastChild,r=null,o=0;o<e.openEnd;o++)r=n,n=n.lastChild;for(var i=t.steps.length,s=this.ranges,a=0;a<s.length;a++){var c=s[a],h=c.$from,l=c.$to,f=t.mapping.slice(i);t.replaceRange(f.map(h.pos),f.map(l.pos),a?p.empty:e),0==a&&Yt(t,i,(n?n.isInline:r&&r.isTextblock)?-1:1)}},Lt.prototype.replaceWith=function(t,e){for(var n=t.steps.length,r=this.ranges,o=0;o<r.length;o++){var i=r[o],s=i.$from,a=i.$to,c=t.mapping.slice(n),h=c.map(s.pos),p=c.map(a.pos);o?t.deleteRange(h,p):(t.replaceRangeWith(h,p,e),Yt(t,n,e.isInline?-1:1))}},Lt.findFrom=function(t,e,n){var r=t.parent.inlineContent?new Jt(t):Xt(t.node(0),t.parent,t.pos,t.index(),e,n);if(r)return r;for(var o=t.depth-1;o>=0;o--){var i=e<0?Xt(t.node(0),t.node(o),t.before(o+1),t.index(o),e,n):Xt(t.node(0),t.node(o),t.after(o+1),t.index(o)+1,e,n);if(i)return i}},Lt.near=function(t,e){return void 0===e&&(e=1),this.findFrom(t,e)||this.findFrom(t,-e)||new Ut(t.node(0))},Lt.atStart=function(t){return Xt(t,t,0,0,1)||new Ut(t)},Lt.atEnd=function(t){return Xt(t,t,t.content.size,t.childCount,-1)||new Ut(t)},Lt.fromJSON=function(t,e){if(!e||!e.type)throw new RangeError("Invalid input for Selection.fromJSON");var n=_t[e.type];if(!n)throw new RangeError("No selection type "+e.type+" defined");return n.fromJSON(t,e)},Lt.jsonID=function(t,e){if(t in _t)throw new RangeError("Duplicate use of selection JSON ID "+t);return _t[t]=e,e.prototype.jsonID=t,e},Lt.prototype.getBookmark=function(){return Jt.between(this.$anchor,this.$head).getBookmark()},Object.defineProperties(Lt.prototype,jt),Lt.prototype.visible=!0;var qt=function(t,e){this.$from=t,this.$to=e},Jt=function(t){function e(e,n){void 0===n&&(n=e),t.call(this,e,n)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={$cursor:{configurable:!0}};return n.$cursor.get=function(){return this.$anchor.pos==this.$head.pos?this.$head:null},e.prototype.map=function(n,r){var o=n.resolve(r.map(this.head));if(!o.parent.inlineContent)return t.near(o);var i=n.resolve(r.map(this.anchor));return new e(i.parent.inlineContent?i:o,o)},e.prototype.replace=function(e,n){if(void 0===n&&(n=p.empty),t.prototype.replace.call(this,e,n),n==p.empty){var r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}},e.prototype.eq=function(t){return t instanceof e&&t.anchor==this.anchor&&t.head==this.head},e.prototype.getBookmark=function(){return new Wt(this.anchor,this.head)},e.prototype.toJSON=function(){return{type:"text",anchor:this.anchor,head:this.head}},e.fromJSON=function(t,n){if("number"!=typeof n.anchor||"number"!=typeof n.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new e(t.resolve(n.anchor),t.resolve(n.head))},e.create=function(t,e,n){void 0===n&&(n=e);var r=t.resolve(e);return new this(r,n==e?r:t.resolve(n))},e.between=function(n,r,o){var i=n.pos-r.pos;if(o&&!i||(o=i>=0?1:-1),!r.parent.inlineContent){var s=t.findFrom(r,o,!0)||t.findFrom(r,-o,!0);if(!s)return t.near(r,o);r=s.$head}return n.parent.inlineContent||(0==i||(n=(t.findFrom(n,-o,!0)||t.findFrom(n,o,!0)).$anchor).pos<r.pos!=i<0)&&(n=r),new e(n,r)},Object.defineProperties(e.prototype,n),e}(Lt);Lt.jsonID("text",Jt);var Wt=function(t,e){this.anchor=t,this.head=e};Wt.prototype.map=function(t){return new Wt(t.map(this.anchor),t.map(this.head))},Wt.prototype.resolve=function(t){return Jt.between(t.resolve(this.anchor),t.resolve(this.head))};var Kt=function(t){function e(e){var n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);t.call(this,e,r),this.node=n}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.map=function(n,r){var o=r.mapResult(this.anchor),i=o.deleted,s=o.pos,a=n.resolve(s);return i?t.near(a):new e(a)},e.prototype.content=function(){return new p(r.from(this.node),0,0)},e.prototype.eq=function(t){return t instanceof e&&t.anchor==this.anchor},e.prototype.toJSON=function(){return{type:"node",anchor:this.anchor}},e.prototype.getBookmark=function(){return new Ht(this.anchor)},e.fromJSON=function(t,n){if("number"!=typeof n.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new e(t.resolve(n.anchor))},e.create=function(t,e){return new this(t.resolve(e))},e.isSelectable=function(t){return!t.isText&&!1!==t.type.spec.selectable},e}(Lt);Kt.prototype.visible=!1,Lt.jsonID("node",Kt);var Ht=function(t){this.anchor=t};Ht.prototype.map=function(t){var e=t.mapResult(this.anchor),n=e.deleted,r=e.pos;return n?new Wt(r,r):new Ht(r)},Ht.prototype.resolve=function(t){var e=t.resolve(this.anchor),n=e.nodeAfter;return n&&Kt.isSelectable(n)?new Kt(e):Lt.near(e)};var Ut=function(t){function e(e){t.call(this,e.resolve(0),e.resolve(e.content.size))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.replace=function(e,n){if(void 0===n&&(n=p.empty),n==p.empty){e.delete(0,e.doc.content.size);var r=t.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else t.prototype.replace.call(this,e,n)},e.prototype.toJSON=function(){return{type:"all"}},e.fromJSON=function(t){return new e(t)},e.prototype.map=function(t){return new e(t)},e.prototype.eq=function(t){return t instanceof e},e.prototype.getBookmark=function(){return Gt},e}(Lt);Lt.jsonID("all",Ut);var Gt={map:function(){return this},resolve:function(t){return new Ut(t)}};function Xt(t,e,n,r,o,i){if(e.inlineContent)return Jt.create(t,n);for(var s=r-(o>0?0:1);o>0?s<e.childCount:s>=0;s+=o){var a=e.child(s);if(a.isAtom){if(!i&&Kt.isSelectable(a))return Kt.create(t,n-(o<0?a.nodeSize:0))}else{var c=Xt(t,a,n+o,o<0?a.childCount:0,o,i);if(c)return c}n+=a.nodeSize*o}}function Yt(t,e,n){var r=t.steps.length-1;if(!(r<e)){var o,i=t.steps[r];if(i instanceof Ot||i instanceof Mt)t.mapping.maps[r].forEach((function(t,e,n,r){null==o&&(o=r)})),t.setSelection(Lt.near(t.doc.resolve(o),n))}}var Qt=function(t){function e(e){t.call(this,e.doc),this.time=Date.now(),this.curSelection=e.selection,this.curSelectionFor=0,this.storedMarks=e.storedMarks,this.updated=0,this.meta=Object.create(null)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={selection:{configurable:!0},selectionSet:{configurable:!0},storedMarksSet:{configurable:!0},isGeneric:{configurable:!0},scrolledIntoView:{configurable:!0}};return n.selection.get=function(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection},e.prototype.setSelection=function(t){if(t.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=t,this.curSelectionFor=this.steps.length,this.updated=-3&(1|this.updated),this.storedMarks=null,this},n.selectionSet.get=function(){return(1&this.updated)>0},e.prototype.setStoredMarks=function(t){return this.storedMarks=t,this.updated|=2,this},e.prototype.ensureMarks=function(t){return c.sameSet(this.storedMarks||this.selection.$from.marks(),t)||this.setStoredMarks(t),this},e.prototype.addStoredMark=function(t){return this.ensureMarks(t.addToSet(this.storedMarks||this.selection.$head.marks()))},e.prototype.removeStoredMark=function(t){return this.ensureMarks(t.removeFromSet(this.storedMarks||this.selection.$head.marks()))},n.storedMarksSet.get=function(){return(2&this.updated)>0},e.prototype.addStep=function(e,n){t.prototype.addStep.call(this,e,n),this.updated=-3&this.updated,this.storedMarks=null},e.prototype.setTime=function(t){return this.time=t,this},e.prototype.replaceSelection=function(t){return this.selection.replace(this,t),this},e.prototype.replaceSelectionWith=function(t,e){var n=this.selection;return!1!==e&&(t=t.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||c.none))),n.replaceWith(this,t),this},e.prototype.deleteSelection=function(){return this.selection.replace(this),this},e.prototype.insertText=function(t,e,n){void 0===n&&(n=e);var r=this.doc.type.schema;if(null==e)return t?this.replaceSelectionWith(r.text(t),!0):this.deleteSelection();if(!t)return this.deleteRange(e,n);var o=this.storedMarks;if(!o){var i=this.doc.resolve(e);o=n==e?i.marks():i.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(e,n,r.text(t,o)),this.selection.empty||this.setSelection(Lt.near(this.selection.$to)),this},e.prototype.setMeta=function(t,e){return this.meta["string"==typeof t?t:t.key]=e,this},e.prototype.getMeta=function(t){return this.meta["string"==typeof t?t:t.key]},n.isGeneric.get=function(){for(var t in this.meta)return!1;return!0},e.prototype.scrollIntoView=function(){return this.updated|=4,this},n.scrolledIntoView.get=function(){return(4&this.updated)>0},Object.defineProperties(e.prototype,n),e}(yt);function Zt(t,e){return e&&t?t.bind(e):t}var te=function(t,e,n){this.name=t,this.init=Zt(e.init,n),this.apply=Zt(e.apply,n)},ee=[new te("doc",{init:function(t){return t.doc||t.schema.topNodeType.createAndFill()},apply:function(t){return t.doc}}),new te("selection",{init:function(t,e){return t.selection||Lt.atStart(e.doc)},apply:function(t){return t.selection}}),new te("storedMarks",{init:function(t){return t.storedMarks||null},apply:function(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new te("scrollToSelection",{init:function(){return 0},apply:function(t,e){return t.scrolledIntoView?e+1:e}})],ne=function(t,e){var n=this;this.schema=t,this.fields=ee.concat(),this.plugins=[],this.pluginsByKey=Object.create(null),e&&e.forEach((function(t){if(n.pluginsByKey[t.key])throw new RangeError("Adding different instances of a keyed plugin ("+t.key+")");n.plugins.push(t),n.pluginsByKey[t.key]=t,t.spec.state&&n.fields.push(new te(t.key,t.spec.state,t))}))},re=function(t){this.config=t},oe={schema:{configurable:!0},plugins:{configurable:!0},tr:{configurable:!0}};oe.schema.get=function(){return this.config.schema},oe.plugins.get=function(){return this.config.plugins},re.prototype.apply=function(t){return this.applyTransaction(t).state},re.prototype.filterTransaction=function(t,e){void 0===e&&(e=-1);for(var n=0;n<this.config.plugins.length;n++)if(n!=e){var r=this.config.plugins[n];if(r.spec.filterTransaction&&!r.spec.filterTransaction.call(r,t,this))return!1}return!0},re.prototype.applyTransaction=function(t){if(!this.filterTransaction(t))return{state:this,transactions:[]};for(var e=[t],n=this.applyInner(t),r=null;;){for(var o=!1,i=0;i<this.config.plugins.length;i++){var s=this.config.plugins[i];if(s.spec.appendTransaction){var a=r?r[i].n:0,c=r?r[i].state:this,h=a<e.length&&s.spec.appendTransaction.call(s,a?e.slice(a):e,c,n);if(h&&n.filterTransaction(h,i)){if(h.setMeta("appendedTransaction",t),!r){r=[];for(var p=0;p<this.config.plugins.length;p++)r.push(p<i?{state:n,n:e.length}:{state:this,n:0})}e.push(h),n=n.applyInner(h),o=!0}r&&(r[i]={state:n,n:e.length})}}if(!o)return{state:n,transactions:e}}},re.prototype.applyInner=function(t){if(!t.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");for(var e=new re(this.config),n=this.config.fields,r=0;r<n.length;r++){var o=n[r];e[o.name]=o.apply(t,this[o.name],this,e)}for(var i=0;i<ie.length;i++)ie[i](this,t,e);return e},oe.tr.get=function(){return new Qt(this)},re.create=function(t){for(var e=new ne(t.doc?t.doc.type.schema:t.schema,t.plugins),n=new re(e),r=0;r<e.fields.length;r++)n[e.fields[r].name]=e.fields[r].init(t,n);return n},re.prototype.reconfigure=function(t){for(var e=new ne(this.schema,t.plugins),n=e.fields,r=new re(e),o=0;o<n.length;o++){var i=n[o].name;r[i]=this.hasOwnProperty(i)?this[i]:n[o].init(t,r)}return r},re.prototype.toJSON=function(t){var e={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(e.storedMarks=this.storedMarks.map((function(t){return t.toJSON()}))),t&&"object"==typeof t)for(var n in t){if("doc"==n||"selection"==n)throw new RangeError("The JSON fields `doc` and `selection` are reserved");var r=t[n],o=r.spec.state;o&&o.toJSON&&(e[n]=o.toJSON.call(r,this[r.key]))}return e},re.fromJSON=function(t,e,n){if(!e)throw new RangeError("Invalid input for EditorState.fromJSON");if(!t.schema)throw new RangeError("Required config field 'schema' missing");var r=new ne(t.schema,t.plugins),o=new re(r);return r.fields.forEach((function(r){if("doc"==r.name)o.doc=A.fromJSON(t.schema,e.doc);else if("selection"==r.name)o.selection=Lt.fromJSON(o.doc,e.selection);else if("storedMarks"==r.name)e.storedMarks&&(o.storedMarks=e.storedMarks.map(t.schema.markFromJSON));else{if(n)for(var i in n){var s=n[i],a=s.spec.state;if(s.key==r.name&&a&&a.fromJSON&&Object.prototype.hasOwnProperty.call(e,i))return void(o[r.name]=a.fromJSON.call(s,t,e[i],o))}o[r.name]=r.init(t,o)}})),o},re.addApplyListener=function(t){ie.push(t)},re.removeApplyListener=function(t){var e=ie.indexOf(t);e>-1&&ie.splice(e,1)},Object.defineProperties(re.prototype,oe);var ie=[];function se(t,e,n){for(var r in t){var o=t[r];o instanceof Function?o=o.bind(e):"handleDOMEvents"==r&&(o=se(o,e,{})),n[r]=o}return n}var ae=function(t){this.props={},t.props&&se(t.props,this,this.props),this.spec=t,this.key=t.key?t.key.key:he("plugin")};ae.prototype.getState=function(t){return t[this.key]};var ce=Object.create(null);function he(t){return t in ce?t+"$"+ ++ce[t]:(ce[t]=0,t+"$")}var pe=function(t){void 0===t&&(t="key"),this.key=he(t)};pe.prototype.get=function(t){return t.config.pluginsByKey[this.key]},pe.prototype.getState=function(t){return t[this.key]};var le={};if("undefined"!=typeof navigator&&"undefined"!=typeof document){var fe=/Edge\/(\d+)/.exec(navigator.userAgent),ue=/MSIE \d/.test(navigator.userAgent),de=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);le.mac=/Mac/.test(navigator.platform);var me=le.ie=!!(ue||de||fe);le.ie_version=ue?document.documentMode||6:de?+de[1]:fe?+fe[1]:null,le.gecko=!me&&/gecko\/(\d+)/i.test(navigator.userAgent),le.gecko_version=le.gecko&&+(/Firefox\/(\d+)/.exec(navigator.userAgent)||[0,0])[1];var ve=!me&&/Chrome\/(\d+)/.exec(navigator.userAgent);le.chrome=!!ve,le.chrome_version=ve&&+ve[1],le.safari=!me&&/Apple Computer/.test(navigator.vendor),le.ios=le.safari&&(/Mobile\/\w+/.test(navigator.userAgent)||navigator.maxTouchPoints>2),le.android=/Android \d/.test(navigator.userAgent),le.webkit="webkitFontSmoothing"in document.documentElement.style,le.webkit_version=le.webkit&&+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]}var ge=function(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e},ye=function(t){var e=t.parentNode;return e&&11==e.nodeType?e.host:e},we=null,be=function(t,e,n){var r=we||(we=document.createRange());return r.setEnd(t,null==n?t.nodeValue.length:n),r.setStart(t,e||0),r},xe=function(t,e,n,r){return n&&(ke(t,e,n,r,-1)||ke(t,e,n,r,1))},Se=/^(img|br|input|textarea|hr)$/i;function ke(t,e,n,r,o){for(;;){if(t==n&&e==r)return!0;if(e==(o<0?0:Oe(t))){var i=t.parentNode;if(1!=i.nodeType||Me(t)||Se.test(t.nodeName)||"false"==t.contentEditable)return!1;e=ge(t)+(o<0?0:1),t=i}else{if(1!=t.nodeType)return!1;if("false"==(t=t.childNodes[e+(o<0?-1:0)]).contentEditable)return!1;e=o<0?Oe(t):0}}}function Oe(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function Me(t){for(var e,n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}var Ce=function(t){var e=t.isCollapsed;return e&&le.chrome&&t.rangeCount&&!t.getRangeAt(0).collapsed&&(e=!1),e};function Ne(t,e){var n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function De(t){return{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function Te(t,e){return"number"==typeof t?t:t[e]}function Ee(t){var e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function Ae(t,e,n){for(var r=t.someProp("scrollThreshold")||0,o=t.someProp("scrollMargin")||5,i=t.dom.ownerDocument,s=n||t.dom;s;s=ye(s))if(1==s.nodeType){var a=s==i.body||1!=s.nodeType,c=a?De(i):Ee(s),h=0,p=0;if(e.top<c.top+Te(r,"top")?p=-(c.top-e.top+Te(o,"top")):e.bottom>c.bottom-Te(r,"bottom")&&(p=e.bottom-c.bottom+Te(o,"bottom")),e.left<c.left+Te(r,"left")?h=-(c.left-e.left+Te(o,"left")):e.right>c.right-Te(r,"right")&&(h=e.right-c.right+Te(o,"right")),h||p)if(a)i.defaultView.scrollBy(h,p);else{var l=s.scrollLeft,f=s.scrollTop;p&&(s.scrollTop+=p),h&&(s.scrollLeft+=h);var u=s.scrollLeft-l,d=s.scrollTop-f;e={left:e.left-u,top:e.top-d,right:e.right-u,bottom:e.bottom-d}}if(a)break}}function Re(t){for(var e=[],n=t.ownerDocument;t&&(e.push({dom:t,top:t.scrollTop,left:t.scrollLeft}),t!=n);t=ye(t));return e}function ze(t,e){for(var n=0;n<t.length;n++){var r=t[n],o=r.dom,i=r.top,s=r.left;o.scrollTop!=i+e&&(o.scrollTop=i+e),o.scrollLeft!=s&&(o.scrollLeft=s)}}var Pe=null;function Ie(t,e){for(var n,r,o=2e8,i=0,s=e.top,a=e.top,c=t.firstChild,h=0;c;c=c.nextSibling,h++){var p=void 0;if(1==c.nodeType)p=c.getClientRects();else{if(3!=c.nodeType)continue;p=be(c).getClientRects()}for(var l=0;l<p.length;l++){var f=p[l];if(f.top<=s&&f.bottom>=a){s=Math.max(f.bottom,s),a=Math.min(f.top,a);var u=f.left>e.left?f.left-e.left:f.right<e.left?e.left-f.right:0;if(u<o){n=c,o=u,r=u&&3==n.nodeType?{left:f.right<e.left?f.right:f.left,top:e.top}:e,1==c.nodeType&&u&&(i=h+(e.left>=(f.left+f.right)/2?1:0));continue}}!n&&(e.left>=f.right&&e.top>=f.top||e.left>=f.left&&e.top>=f.bottom)&&(i=h+1)}}return n&&3==n.nodeType?function(t,e){for(var n=t.nodeValue.length,r=document.createRange(),o=0;o<n;o++){r.setEnd(t,o+1),r.setStart(t,o);var i=$e(r,1);if(i.top!=i.bottom&&Be(e,i))return{node:t,offset:o+(e.left>=(i.left+i.right)/2?1:0)}}return{node:t,offset:0}}(n,r):!n||o&&1==n.nodeType?{node:t,offset:i}:Ie(n,r)}function Be(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function Fe(t,e,n){var r=t.childNodes.length;if(r&&n.top<n.bottom)for(var o=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),i=o;;){var s=t.childNodes[i];if(1==s.nodeType)for(var a=s.getClientRects(),c=0;c<a.length;c++){var h=a[c];if(Be(e,h))return Fe(s,e,h)}if((i=(i+1)%r)==o)break}return t}function Ve(t,e){var n,r,o,i,s=t.root;if(s.caretPositionFromPoint)try{var a=s.caretPositionFromPoint(e.left,e.top);a&&(o=(n=a).offsetNode,i=n.offset)}catch(t){}if(!o&&s.caretRangeFromPoint){var c=s.caretRangeFromPoint(e.left,e.top);c&&(o=(r=c).startContainer,i=r.startOffset)}var h,p=s.elementFromPoint(e.left,e.top+1);if(!p||!t.dom.contains(1!=p.nodeType?p.parentNode:p)){var l=t.dom.getBoundingClientRect();if(!Be(e,l))return null;if(!(p=Fe(t.dom,e,l)))return null}if(le.safari&&p.draggable&&(o=i=null),p=function(t,e){var n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}(p,e),o){if(le.gecko&&1==o.nodeType&&(i=Math.min(i,o.childNodes.length))<o.childNodes.length){var f,u=o.childNodes[i];"IMG"==u.nodeName&&(f=u.getBoundingClientRect()).right<=e.left&&f.bottom>e.top&&i++}o==t.dom&&i==o.childNodes.length-1&&1==o.lastChild.nodeType&&e.top>o.lastChild.getBoundingClientRect().bottom?h=t.state.doc.content.size:0!=i&&1==o.nodeType&&"BR"==o.childNodes[i-1].nodeName||(h=function(t,e,n,r){for(var o=-1,i=e;i!=t.dom;){var s=t.docView.nearestDesc(i,!0);if(!s)return null;if(s.node.isBlock&&s.parent){var a=s.dom.getBoundingClientRect();if(a.left>r.left||a.top>r.top)o=s.posBefore;else{if(!(a.right<r.left||a.bottom<r.top))break;o=s.posAfter}}i=s.dom.parentNode}return o>-1?o:t.docView.posFromDOM(e,n)}(t,o,i,e))}null==h&&(h=function(t,e,n){var r=Ie(e,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 t.docView.posFromDOM(o,i,s)}(t,p,e));var d=t.docView.nearestDesc(p,!0);return{pos:h,inside:d?d.posAtStart-d.border:-1}}function $e(t,e){var n=t.getClientRects();return n.length?n[e<0?0:n.length-1]:t.getBoundingClientRect()}var _e=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Le(t,e,n){var r=t.docView.domFromPos(e,n<0?-1:1),o=r.node,i=r.offset,s=le.webkit||le.gecko;if(3==o.nodeType){if(!s||!_e.test(o.nodeValue)&&(n<0?i:i!=o.nodeValue.length)){var a=i,c=i,h=n<0?1:-1;return n<0&&!i?(c++,h=-1):n>=0&&i==o.nodeValue.length?(a--,h=1):n<0?a--:c++,je($e(be(o,a,c),h),h<0)}var p=$e(be(o,i,i),n);if(le.gecko&&i&&/\s/.test(o.nodeValue[i-1])&&i<o.nodeValue.length){var l=$e(be(o,i-1,i-1),-1);if(l.top==p.top){var f=$e(be(o,i,i+1),-1);if(f.top!=p.top)return je(f,f.left<l.left)}}return p}if(!t.state.doc.resolve(e).parent.inlineContent){if(i&&(n<0||i==Oe(o))){var u=o.childNodes[i-1];if(1==u.nodeType)return qe(u.getBoundingClientRect(),!1)}if(i<Oe(o)){var d=o.childNodes[i];if(1==d.nodeType)return qe(d.getBoundingClientRect(),!0)}return qe(o.getBoundingClientRect(),n>=0)}if(i&&(n<0||i==Oe(o))){var m=o.childNodes[i-1],v=3==m.nodeType?be(m,Oe(m)-(s?0:1)):1!=m.nodeType||"BR"==m.nodeName&&m.nextSibling?null:m;if(v)return je($e(v,1),!1)}if(i<Oe(o)){var g=o.childNodes[i],y=3==g.nodeType?be(g,0,s?0:1):1==g.nodeType?g:null;if(y)return je($e(y,-1),!0)}return je($e(3==o.nodeType?be(o):o,-n),n>=0)}function je(t,e){if(0==t.width)return t;var n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function qe(t,e){if(0==t.height)return t;var n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function Je(t,e,n){var r=t.state,o=t.root.activeElement;r!=e&&t.updateState(e),o!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),o!=t.dom&&o&&o.focus()}}var We=/[\u0590-\u08ac]/;var Ke=null,He=null,Ue=!1;function Ge(t,e,n){return Ke==e&&He==n?Ue:(Ke=e,He=n,Ue="up"==n||"down"==n?function(t,e,n){var r=e.selection,o="up"==n?r.$from:r.$to;return Je(t,e,(function(){for(var e=t.docView.domFromPos(o.pos,"up"==n?-1:1).node;;){var r=t.docView.nearestDesc(e,!0);if(!r)break;if(r.node.isBlock){e=r.dom;break}e=r.dom.parentNode}for(var i=Le(t,o.pos,1),s=e.firstChild;s;s=s.nextSibling){var a=void 0;if(1==s.nodeType)a=s.getClientRects();else{if(3!=s.nodeType)continue;a=be(s,0,s.nodeValue.length).getClientRects()}for(var c=0;c<a.length;c++){var h=a[c];if(h.bottom>h.top&&("up"==n?h.bottom<i.top+1:h.top>i.bottom-1))return!1}}return!0}))}(t,e,n):function(t,e,n){var r=e.selection.$head;if(!r.parent.isTextblock)return!1;var o=r.parentOffset,i=!o,s=o==r.parent.content.size,a=getSelection();return We.test(r.parent.textContent)&&a.modify?Je(t,e,(function(){var e=a.getRangeAt(0),o=a.focusNode,i=a.focusOffset,s=a.caretBidiLevel;a.modify("move",n,"character");var c=!(r.depth?t.docView.domAfterPos(r.before()):t.dom).contains(1==a.focusNode.nodeType?a.focusNode:a.focusNode.parentNode)||o==a.focusNode&&i==a.focusOffset;return a.removeAllRanges(),a.addRange(e),null!=s&&(a.caretBidiLevel=s),c})):"left"==n||"backward"==n?i:s}(t,e,n))}var Xe=function(t,e,n,r){this.parent=t,this.children=e,this.dom=n,n.pmViewDesc=this,this.contentDOM=r,this.dirty=0},Ye={beforePosition:{configurable:!0},size:{configurable:!0},border:{configurable:!0},posBefore:{configurable:!0},posAtStart:{configurable:!0},posAfter:{configurable:!0},posAtEnd:{configurable:!0},contentLost:{configurable:!0},domAtom:{configurable:!0}};Xe.prototype.matchesWidget=function(){return!1},Xe.prototype.matchesMark=function(){return!1},Xe.prototype.matchesNode=function(){return!1},Xe.prototype.matchesHack=function(){return!1},Ye.beforePosition.get=function(){return!1},Xe.prototype.parseRule=function(){return null},Xe.prototype.stopEvent=function(){return!1},Ye.size.get=function(){for(var t=0,e=0;e<this.children.length;e++)t+=this.children[e].size;return t},Ye.border.get=function(){return 0},Xe.prototype.destroy=function(){this.parent=null,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=null);for(var t=0;t<this.children.length;t++)this.children[t].destroy()},Xe.prototype.posBeforeChild=function(t){for(var e=0,n=this.posAtStart;e<this.children.length;e++){var r=this.children[e];if(r==t)return n;n+=r.size}},Ye.posBefore.get=function(){return this.parent.posBeforeChild(this)},Ye.posAtStart.get=function(){return this.parent?this.parent.posBeforeChild(this)+this.border:0},Ye.posAfter.get=function(){return this.posBefore+this.size},Ye.posAtEnd.get=function(){return this.posAtStart+this.size-2*this.border},Xe.prototype.localPosFromDOM=function(t,e,n){if(this.contentDOM&&this.contentDOM.contains(1==t.nodeType?t:t.parentNode)){if(n<0){var r,o;if(t==this.contentDOM)r=t.childNodes[e-1];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;r=t.previousSibling}for(;r&&(!(o=r.pmViewDesc)||o.parent!=this);)r=r.previousSibling;return r?this.posBeforeChild(o)+o.size:this.posAtStart}var i,s;if(t==this.contentDOM)i=t.childNodes[e];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;i=t.nextSibling}for(;i&&(!(s=i.pmViewDesc)||s.parent!=this);)i=i.nextSibling;return i?this.posBeforeChild(s):this.posAtEnd}var a;if(t==this.dom&&this.contentDOM)a=e>ge(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))a=2&t.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==e)for(var c=t;;c=c.parentNode){if(c==this.dom){a=!1;break}if(c.parentNode.firstChild!=c)break}if(null==a&&e==t.childNodes.length)for(var h=t;;h=h.parentNode){if(h==this.dom){a=!0;break}if(h.parentNode.lastChild!=h)break}}return(null==a?n>0:a)?this.posAtEnd:this.posAtStart},Xe.prototype.nearestDesc=function(t,e){for(var n=!0,r=t;r;r=r.parentNode){var o=this.getDesc(r);if(o&&(!e||o.node)){if(!n||!o.nodeDOM||(1==o.nodeDOM.nodeType?o.nodeDOM.contains(1==t.nodeType?t:t.parentNode):o.nodeDOM==t))return o;n=!1}}},Xe.prototype.getDesc=function(t){for(var e=t.pmViewDesc,n=e;n;n=n.parent)if(n==this)return e},Xe.prototype.posFromDOM=function(t,e,n){for(var r=t;r;r=r.parentNode){var o=this.getDesc(r);if(o)return o.localPosFromDOM(t,e,n)}return-1},Xe.prototype.descAt=function(t){for(var e=0,n=0;e<this.children.length;e++){var r=this.children[e],o=n+r.size;if(n==t&&o!=n){for(;!r.border&&r.children.length;)r=r.children[0];return r}if(t<o)return r.descAt(t-n-r.border);n=o}},Xe.prototype.domFromPos=function(t,e){if(!this.contentDOM)return{node:this.dom,offset:0};for(var n=0,r=0,o=!0;;r++,o=!1){for(;r<this.children.length&&(this.children[r].beforePosition||this.children[r].dom.parentNode!=this.contentDOM);)n+=this.children[r++].size;var i=r==this.children.length?null:this.children[r];if(n==t&&(0==e||!i||!i.size||i.border||e<0&&o)||i&&i.domAtom&&t<n+i.size)return{node:this.contentDOM,offset:i?ge(i.dom):this.contentDOM.childNodes.length};if(!i)throw new Error("Invalid position "+t);var s=n+i.size;if(!i.domAtom&&(e<0&&!i.border?s>=t:s>t)&&(s>t||r+1>=this.children.length||!this.children[r+1].beforePosition))return i.domFromPos(t-n-i.border,e);n=s}},Xe.prototype.parseRange=function(t,e,n){if(void 0===n&&(n=0),0==this.children.length)return{node:this.contentDOM,from:t,to:e,fromOffset:0,toOffset:this.contentDOM.childNodes.length};for(var r=-1,o=-1,i=n,s=0;;s++){var a=this.children[s],c=i+a.size;if(-1==r&&t<=c){var h=i+a.border;if(t>=h&&e<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(t,e,h);t=i;for(var p=s;p>0;p--){var l=this.children[p-1];if(l.size&&l.dom.parentNode==this.contentDOM&&!l.emptyChildAt(1)){r=ge(l.dom)+1;break}t-=l.size}-1==r&&(r=0)}if(r>-1&&(c>e||s==this.children.length-1)){e=c;for(var f=s+1;f<this.children.length;f++){var u=this.children[f];if(u.size&&u.dom.parentNode==this.contentDOM&&!u.emptyChildAt(-1)){o=ge(u.dom);break}e+=u.size}-1==o&&(o=this.contentDOM.childNodes.length);break}i=c}return{node:this.contentDOM,from:t,to:e,fromOffset:r,toOffset:o}},Xe.prototype.emptyChildAt=function(t){if(this.border||!this.contentDOM||!this.children.length)return!1;var e=this.children[t<0?0:this.children.length-1];return 0==e.size||e.emptyChildAt(t)},Xe.prototype.domAfterPos=function(t){var e=this.domFromPos(t,0),n=e.node,r=e.offset;if(1!=n.nodeType||r==n.childNodes.length)throw new RangeError("No node after pos "+t);return n.childNodes[r]},Xe.prototype.setSelection=function(t,e,n,r){for(var o=Math.min(t,e),i=Math.max(t,e),s=0,a=0;s<this.children.length;s++){var c=this.children[s],h=a+c.size;if(o>a&&i<h)return c.setSelection(t-a-c.border,e-a-c.border,n,r);a=h}var p=this.domFromPos(t,t?-1:1),l=e==t?p:this.domFromPos(e,e?-1:1),f=n.getSelection(),u=!1;if((le.gecko||le.safari)&&t==e){var d=p.node,m=p.offset;if(3==d.nodeType)(u=m&&"\n"==d.nodeValue[m-1])&&m==d.nodeValue.length&&d.nextSibling&&"BR"==d.nextSibling.nodeName&&(p=l={node:d.parentNode,offset:ge(d)+1});else{var v=d.childNodes[m-1];u=v&&("BR"==v.nodeName||"false"==v.contentEditable)}}if(r||u&&le.safari||!xe(p.node,p.offset,f.anchorNode,f.anchorOffset)||!xe(l.node,l.offset,f.focusNode,f.focusOffset)){var g=!1;if((f.extend||t==e)&&!u){f.collapse(p.node,p.offset);try{t!=e&&f.extend(l.node,l.offset),g=!0}catch(t){if(!(t instanceof DOMException))throw t}}if(!g){if(t>e){var y=p;p=l,l=y}var w=document.createRange();w.setEnd(l.node,l.offset),w.setStart(p.node,p.offset),f.removeAllRanges(),f.addRange(w)}}},Xe.prototype.ignoreMutation=function(t){return!this.contentDOM&&"selection"!=t.type},Ye.contentLost.get=function(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)},Xe.prototype.markDirty=function(t,e){for(var n=0,r=0;r<this.children.length;r++){var o=this.children[r],i=n+o.size;if(n==i?t<=i&&e>=n:t<i&&e>n){var s=n+o.border,a=i-o.border;if(t>=s&&e<=a)return this.dirty=t==n||e==i?2:1,void(t!=s||e!=a||!o.contentLost&&o.dom.parentNode==this.contentDOM?o.markDirty(t-s,e-s):o.dirty=3);o.dirty=3}n=i}this.dirty=2},Xe.prototype.markParentsDirty=function(){for(var t=1,e=this.parent;e;e=e.parent,t++){var n=1==t?2:1;e.dirty<n&&(e.dirty=n)}},Ye.domAtom.get=function(){return!1},Object.defineProperties(Xe.prototype,Ye);var Qe=[],Ze=function(t){function e(e,n,r,o){var i,s=n.type.toDOM;if("function"==typeof s&&(s=s(r,(function(){return i?i.parent?i.parent.posBeforeChild(i):void 0:o}))),!n.type.spec.raw){if(1!=s.nodeType){var a=document.createElement("span");a.appendChild(s),s=a}s.contentEditable=!1,s.classList.add("ProseMirror-widget")}t.call(this,e,Qe,s,null),this.widget=n,i=this}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={beforePosition:{configurable:!0},domAtom:{configurable:!0}};return n.beforePosition.get=function(){return this.widget.type.side<0},e.prototype.matchesWidget=function(t){return 0==this.dirty&&t.type.eq(this.widget.type)},e.prototype.parseRule=function(){return{ignore:!0}},e.prototype.stopEvent=function(t){var e=this.widget.spec.stopEvent;return!!e&&e(t)},e.prototype.ignoreMutation=function(t){return"selection"!=t.type||this.widget.spec.ignoreSelection},n.domAtom.get=function(){return!0},Object.defineProperties(e.prototype,n),e}(Xe),tn=function(t){function e(e,n,r,o){t.call(this,e,Qe,n,null),this.textDOM=r,this.text=o}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={size:{configurable:!0}};return n.size.get=function(){return this.text.length},e.prototype.localPosFromDOM=function(t,e){return t!=this.textDOM?this.posAtStart+(e?this.size:0):this.posAtStart+e},e.prototype.domFromPos=function(t){return{node:this.textDOM,offset:t}},e.prototype.ignoreMutation=function(t){return"characterData"===t.type&&t.target.nodeValue==t.oldValue},Object.defineProperties(e.prototype,n),e}(Xe),en=function(t){function e(e,n,r,o){t.call(this,e,[],r,o),this.mark=n}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.create=function(t,n,r,o){var i=o.nodeViews[n.type.name],s=i&&i(n,o,r);return s&&s.dom||(s=ht.renderSpec(document,n.type.spec.toDOM(n,r))),new e(t,n,s.dom,s.contentDOM||s.dom)},e.prototype.parseRule=function(){return{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}},e.prototype.matchesMark=function(t){return 3!=this.dirty&&this.mark.eq(t)},e.prototype.markDirty=function(e,n){if(t.prototype.markDirty.call(this,e,n),0!=this.dirty){for(var r=this.parent;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=0}},e.prototype.slice=function(t,n,r){var o=e.create(this.parent,this.mark,!0,r),i=this.children,s=this.size;n<s&&(i=wn(i,n,s,r)),t>0&&(i=wn(i,0,t,r));for(var a=0;a<i.length;a++)i[a].parent=o;return o.children=i,o},e}(Xe),nn=function(t){function e(e,n,r,o,i,s,a,c,h){t.call(this,e,n.isLeaf?Qe:[],i,s),this.nodeDOM=a,this.node=n,this.outerDeco=r,this.innerDeco=o,s&&this.updateChildren(c,h)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={size:{configurable:!0},border:{configurable:!0},domAtom:{configurable:!0}};return e.create=function(t,n,r,o,i,s){var a,c,h=i.nodeViews[n.type.name],p=h&&h(n,i,(function(){return c?c.parent?c.parent.posBeforeChild(c):void 0:s}),r,o),l=p&&p.dom,f=p&&p.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 l||(l=(a=ht.renderSpec(document,n.type.spec.toDOM(n))).dom,f=a.contentDOM);f||n.isText||"BR"==l.nodeName||(l.hasAttribute("contenteditable")||(l.contentEditable=!1),n.type.spec.draggable&&(l.draggable=!0));var u=l;return l=dn(l,r,n),p?c=new an(t,n,r,o,l,f,u,p,i,s+1):n.isText?new on(t,n,r,o,l,u,i):new e(t,n,r,o,l,f,u,i,s+1)},e.prototype.parseRule=function(){var t=this;if(this.node.type.spec.reparseInView)return null;var e={node:this.node.type.name,attrs:this.node.attrs};return this.node.type.spec.code&&(e.preserveWhitespace="full"),this.contentDOM&&!this.contentLost?e.contentElement=this.contentDOM:e.getContent=function(){return t.contentDOM?r.empty:t.node.content},e},e.prototype.matchesNode=function(t,e,n){return 0==this.dirty&&t.eq(this.node)&&mn(e,this.outerDeco)&&n.eq(this.innerDeco)},n.size.get=function(){return this.node.nodeSize},n.border.get=function(){return this.node.isLeaf?0:1},e.prototype.updateChildren=function(t,e){var n=this,r=this.node.inlineContent,o=e,i=r&&t.composing&&this.localCompositionNode(t,e),s=new gn(this,i&&i.node);!function(t,e,n,r){var o=e.locals(t),i=0;if(0==o.length){for(var s=0;s<t.childCount;s++){var a=t.child(s);r(a,o,e.forChild(i,a),s),i+=a.nodeSize}return}for(var c=0,h=[],p=null,l=0;;){if(c<o.length&&o[c].to==i){for(var f=o[c++],u=void 0;c<o.length&&o[c].to==i;)(u||(u=[f])).push(o[c++]);if(u){u.sort(yn);for(var d=0;d<u.length;d++)n(u[d],l,!!p)}else n(f,l,!!p)}var m=void 0,v=void 0;if(p)v=-1,m=p,p=null;else{if(!(l<t.childCount))break;v=l,m=t.child(l++)}for(var g=0;g<h.length;g++)h[g].to<=i&&h.splice(g--,1);for(;c<o.length&&o[c].from<=i&&o[c].to>i;)h.push(o[c++]);var y=i+m.nodeSize;if(m.isText){var w=y;c<o.length&&o[c].from<w&&(w=o[c].from);for(var b=0;b<h.length;b++)h[b].to<w&&(w=h[b].to);w<y&&(p=m.cut(w-i),m=m.cut(0,w-i),y=w,v=-1)}r(m,h.length?m.isInline&&!m.isLeaf?h.filter((function(t){return!t.inline})):h.slice():Qe,e.forChild(i,m),v),i=y}}(this.node,this.innerDeco,(function(e,i,a){e.spec.marks?s.syncToMarks(e.spec.marks,r,t):e.type.side>=0&&!a&&s.syncToMarks(i==n.node.childCount?c.none:n.node.child(i).marks,r,t),s.placeWidget(e,t,o)}),(function(e,n,i,a){s.syncToMarks(e.marks,r,t),s.findNodeMatch(e,n,i,a)||s.updateNextNode(e,n,i,t,a)||s.addNode(e,n,i,t,o),o+=e.nodeSize})),s.syncToMarks(Qe,r,t),this.node.isTextblock&&s.addTextblockHacks(),s.destroyRest(),(s.changed||2==this.dirty)&&(i&&this.protectLocalComposition(t,i),cn(this.contentDOM,this.children,t),le.ios&&function(t){if("UL"==t.nodeName||"OL"==t.nodeName){var e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}(this.dom))},e.prototype.localCompositionNode=function(t,e){var n=t.state.selection,r=n.from,o=n.to;if(!(!(t.state.selection instanceof Jt)||r<e||o>e+this.node.content.size)){var i=t.root.getSelection(),s=function(t,e){for(;;){if(3==t.nodeType)return t;if(1==t.nodeType&&e>0){if(t.childNodes.length>e&&3==t.childNodes[e].nodeType)return t.childNodes[e];e=Oe(t=t.childNodes[e-1])}else{if(!(1==t.nodeType&&e<t.childNodes.length))return null;t=t.childNodes[e],e=0}}}(i.focusNode,i.focusOffset);if(s&&this.dom.contains(s.parentNode)){var a=s.nodeValue,c=function(t,e,n,r){for(var o=0,i=0;o<t.childCount&&i<=r;){var s=t.child(o++),a=i;if(i+=s.nodeSize,s.isText){for(var c=s.text;o<t.childCount;){var h=t.child(o++);if(i+=h.nodeSize,!h.isText)break;c+=h.text}if(i>=n){var p=c.lastIndexOf(e,r-a);if(p>=0&&p+e.length+a>=n)return a+p}}}return-1}(this.node.content,a,r-e,o-e);return c<0?null:{node:s,pos:c,text:a}}}},e.prototype.protectLocalComposition=function(t,e){var n=e.node,r=e.pos,o=e.text;if(!this.getDesc(n)){for(var i=n;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=null)}var s=new tn(this,i,n,o);t.compositionNodes.push(s),this.children=wn(this.children,r,r+o.length,t,s)}},e.prototype.update=function(t,e,n,r){return!(3==this.dirty||!t.sameMarkup(this.node))&&(this.updateInner(t,e,n,r),!0)},e.prototype.updateInner=function(t,e,n,r){this.updateOuterDeco(e),this.node=t,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=0},e.prototype.updateOuterDeco=function(t){if(!mn(t,this.outerDeco)){var e=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=fn(this.dom,this.nodeDOM,ln(this.outerDeco,this.node,e),ln(t,this.node,e)),this.dom!=n&&(n.pmViewDesc=null,this.dom.pmViewDesc=this),this.outerDeco=t}},e.prototype.selectNode=function(){this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.dom.draggable=!0)},e.prototype.deselectNode=function(){this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||this.dom.removeAttribute("draggable")},n.domAtom.get=function(){return this.node.isAtom},Object.defineProperties(e.prototype,n),e}(Xe);function rn(t,e,n,r,o){return dn(r,e,t),new nn(null,t,e,n,r,r,r,o,0)}var on=function(t){function e(e,n,r,o,i,s,a){t.call(this,e,n,r,o,i,null,s,a)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={domAtom:{configurable:!0}};return e.prototype.parseRule=function(){for(var t=this.nodeDOM.parentNode;t&&t!=this.dom&&!t.pmIsDeco;)t=t.parentNode;return{skip:t||!0}},e.prototype.update=function(t,e,n,r){return!(3==this.dirty||0!=this.dirty&&!this.inParent()||!t.sameMarkup(this.node))&&(this.updateOuterDeco(e),0==this.dirty&&t.text==this.node.text||t.text==this.nodeDOM.nodeValue||(this.nodeDOM.nodeValue=t.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=t,this.dirty=0,!0)},e.prototype.inParent=function(){for(var t=this.parent.contentDOM,e=this.nodeDOM;e;e=e.parentNode)if(e==t)return!0;return!1},e.prototype.domFromPos=function(t){return{node:this.nodeDOM,offset:t}},e.prototype.localPosFromDOM=function(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):t.prototype.localPosFromDOM.call(this,e,n,r)},e.prototype.ignoreMutation=function(t){return"characterData"!=t.type&&"selection"!=t.type},e.prototype.slice=function(t,n,r){var o=this.node.cut(t,n),i=document.createTextNode(o.text);return new e(this.parent,o,this.outerDeco,this.innerDeco,i,i,r)},n.domAtom.get=function(){return!1},Object.defineProperties(e.prototype,n),e}(nn),sn=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={domAtom:{configurable:!0}};return e.prototype.parseRule=function(){return{ignore:!0}},e.prototype.matchesHack=function(){return 0==this.dirty},n.domAtom.get=function(){return!0},Object.defineProperties(e.prototype,n),e}(Xe),an=function(t){function e(e,n,r,o,i,s,a,c,h,p){t.call(this,e,n,r,o,i,s,a,h,p),this.spec=c}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.update=function(e,n,r,o){if(3==this.dirty)return!1;if(this.spec.update){var i=this.spec.update(e,n,r);return i&&this.updateInner(e,n,r,o),i}return!(!this.contentDOM&&!e.isLeaf)&&t.prototype.update.call(this,e,n,r,o)},e.prototype.selectNode=function(){this.spec.selectNode?this.spec.selectNode():t.prototype.selectNode.call(this)},e.prototype.deselectNode=function(){this.spec.deselectNode?this.spec.deselectNode():t.prototype.deselectNode.call(this)},e.prototype.setSelection=function(e,n,r,o){this.spec.setSelection?this.spec.setSelection(e,n,r):t.prototype.setSelection.call(this,e,n,r,o)},e.prototype.destroy=function(){this.spec.destroy&&this.spec.destroy(),t.prototype.destroy.call(this)},e.prototype.stopEvent=function(t){return!!this.spec.stopEvent&&this.spec.stopEvent(t)},e.prototype.ignoreMutation=function(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):t.prototype.ignoreMutation.call(this,e)},e}(nn);function cn(t,e,n){for(var r=t.firstChild,o=!1,i=0;i<e.length;i++){var s=e[i],a=s.dom;if(a.parentNode==t){for(;a!=r;)r=vn(r),o=!0;r=r.nextSibling}else o=!0,t.insertBefore(a,r);if(s instanceof en){var c=r?r.previousSibling:t.lastChild;cn(s.contentDOM,s.children,n),r=c?c.nextSibling:t.firstChild}}for(;r;)r=vn(r),o=!0;o&&n.trackWrites==t&&(n.trackWrites=null)}function hn(t){t&&(this.nodeName=t)}hn.prototype=Object.create(null);var pn=[new hn];function ln(t,e,n){if(0==t.length)return pn;for(var r=n?pn[0]:new hn,o=[r],i=0;i<t.length;i++){var s=t[i].type.attrs;if(s)for(var a in s.nodeName&&o.push(r=new hn(s.nodeName)),s){var c=s[a];null!=c&&(n&&1==o.length&&o.push(r=new hn(e.isInline?"span":"div")),"class"==a?r.class=(r.class?r.class+" ":"")+c:"style"==a?r.style=(r.style?r.style+";":"")+c:"nodeName"!=a&&(r[a]=c))}}return o}function fn(t,e,n,r){if(n==pn&&r==pn)return e;for(var o=e,i=0;i<r.length;i++){var s=r[i],a=n[i];if(i){var c=void 0;a&&a.nodeName==s.nodeName&&o!=t&&(c=o.parentNode)&&c.tagName.toLowerCase()==s.nodeName||((c=document.createElement(s.nodeName)).pmIsDeco=!0,c.appendChild(o),a=pn[0]),o=c}un(o,a||pn[0],s)}return o}function un(t,e,n){for(var r in e)"class"==r||"style"==r||"nodeName"==r||r in n||t.removeAttribute(r);for(var o in n)"class"!=o&&"style"!=o&&"nodeName"!=o&&n[o]!=e[o]&&t.setAttribute(o,n[o]);if(e.class!=n.class){for(var i=e.class?e.class.split(" ").filter(Boolean):Qe,s=n.class?n.class.split(" ").filter(Boolean):Qe,a=0;a<i.length;a++)-1==s.indexOf(i[a])&&t.classList.remove(i[a]);for(var c=0;c<s.length;c++)-1==i.indexOf(s[c])&&t.classList.add(s[c])}if(e.style!=n.style){if(e.style)for(var h,p=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;h=p.exec(e.style);)t.style.removeProperty(h[1]);n.style&&(t.style.cssText+=n.style)}}function dn(t,e,n){return fn(t,t,pn,ln(e,n,1!=t.nodeType))}function mn(t,e){if(t.length!=e.length)return!1;for(var n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return!1;return!0}function vn(t){var e=t.nextSibling;return t.parentNode.removeChild(t),e}var gn=function(t,e){this.top=t,this.lock=e,this.index=0,this.stack=[],this.changed=!1,this.preMatch=function(t,e){for(var n=t.childCount,r=e.length,o=new Map;n>0&&r>0;r--){var i=e[r-1],s=i.node;if(s){if(s!=t.child(n-1))break;--n,o.set(i,n)}}return{index:n,matched:o}}(t.node.content,t.children)};function yn(t,e){return t.type.side-e.type.side}function wn(t,e,n,r,o){for(var i=[],s=0,a=0;s<t.length;s++){var c=t[s],h=a,p=a+=c.size;h>=n||p<=e?i.push(c):(h<e&&i.push(c.slice(0,e-h,r)),o&&(i.push(o),o=null),p>n&&i.push(c.slice(n-h,c.size,r)))}return i}function bn(t,e){var n=t.root.getSelection(),r=t.state.doc;if(!n.focusNode)return null;var o=t.docView.nearestDesc(n.focusNode),i=o&&0==o.size,s=t.docView.posFromDOM(n.focusNode,n.focusOffset);if(s<0)return null;var a,c,h=r.resolve(s);if(Ce(n)){for(a=h;o&&!o.node;)o=o.parent;if(o&&o.node.isAtom&&Kt.isSelectable(o.node)&&o.parent&&(!o.node.isInline||!function(t,e,n){for(var r=0==e,o=e==Oe(t);r||o;){if(t==n)return!0;var i=ge(t);if(!(t=t.parentNode))return!1;r=r&&0==i,o=o&&i==Oe(t)}}(n.focusNode,n.focusOffset,o.dom))){var p=o.posBefore;c=new Kt(s==p?h:r.resolve(p))}}else{var l=t.docView.posFromDOM(n.anchorNode,n.anchorOffset);if(l<0)return null;a=r.resolve(l)}c||(c=Tn(t,a,h,"pointer"==e||t.state.selection.head<h.pos&&!i?1:-1));return c}function xn(t){return t.editable?t.hasFocus():En(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Sn(t,e){var n=t.state.selection;if(Nn(t,n),xn(t)){if(t.domObserver.disconnectSelection(),t.cursorWrapper)!function(t){var e=t.root.getSelection(),n=document.createRange(),r=t.cursorWrapper.dom,o="IMG"==r.nodeName;o?n.setEnd(r.parentNode,ge(r)+1):n.setEnd(r,0);n.collapse(!1),e.removeAllRanges(),e.addRange(n),!o&&!t.state.selection.visible&&le.ie&&le.ie_version<=11&&(r.disabled=!0,r.disabled=!1)}(t);else{var r,o,i=n.anchor,s=n.head;!kn||n instanceof Jt||(n.$from.parent.inlineContent||(r=On(t,n.from)),n.empty||n.$from.parent.inlineContent||(o=On(t,n.to))),t.docView.setSelection(i,s,t.root,e),kn&&(r&&Cn(r),o&&Cn(o)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(t){var e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.hideSelectionGuard);var n=t.root.getSelection(),r=n.anchorNode,o=n.anchorOffset;e.addEventListener("selectionchange",t.hideSelectionGuard=function(){n.anchorNode==r&&n.anchorOffset==o||(e.removeEventListener("selectionchange",t.hideSelectionGuard),setTimeout((function(){xn(t)&&!t.state.selection.visible||t.dom.classList.remove("ProseMirror-hideselection")}),20))})}(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}gn.prototype.destroyBetween=function(t,e){if(t!=e){for(var n=t;n<e;n++)this.top.children[n].destroy();this.top.children.splice(t,e-t),this.changed=!0}},gn.prototype.destroyRest=function(){this.destroyBetween(this.index,this.top.children.length)},gn.prototype.syncToMarks=function(t,e,n){for(var r=0,o=this.stack.length>>1,i=Math.min(o,t.length);r<i&&(r==o-1?this.top:this.stack[r+1<<1]).matchesMark(t[r])&&!1!==t[r].type.spec.spanning;)r++;for(;r<o;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<t.length;){this.stack.push(this.top,this.index+1);for(var s=-1,a=this.index;a<Math.min(this.index+3,this.top.children.length);a++)if(this.top.children[a].matchesMark(t[o])){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=en.create(this.top,t[o],e,n);this.top.children.splice(this.index,0,c),this.top=c,this.changed=!0}this.index=0,o++}},gn.prototype.findNodeMatch=function(t,e,n,r){var o=this.top.children,i=-1;if(r>=this.preMatch.index){for(var s=this.index;s<o.length;s++)if(o[s].matchesNode(t,e,n)){i=s;break}}else for(var a=this.index,c=Math.min(o.length,a+1);a<c;a++){var h=o[a];if(h.matchesNode(t,e,n)&&!this.preMatch.matched.has(h)){i=a;break}}return!(i<0)&&(this.destroyBetween(this.index,i),this.index++,!0)},gn.prototype.updateNextNode=function(t,e,n,r,o){for(var i=this.index;i<this.top.children.length;i++){var s=this.top.children[i];if(s instanceof nn){var a=this.preMatch.matched.get(s);if(null!=a&&a!=o)return!1;var c=s.dom;if(!(this.lock&&(c==this.lock||1==c.nodeType&&c.contains(this.lock.parentNode))&&!(t.isText&&s.node&&s.node.isText&&s.nodeDOM.nodeValue==t.text&&3!=s.dirty&&mn(e,s.outerDeco)))&&s.update(t,e,n,r))return this.destroyBetween(this.index,i),s.dom!=c&&(this.changed=!0),this.index++,!0;break}}return!1},gn.prototype.addNode=function(t,e,n,r,o){this.top.children.splice(this.index++,0,nn.create(this.top,t,e,n,r,o)),this.changed=!0},gn.prototype.placeWidget=function(t,e,n){var r=this.index<this.top.children.length?this.top.children[this.index]:null;if(!r||!r.matchesWidget(t)||t!=r.widget&&r.widget.type.toDOM.parentNode){var o=new Ze(this.top,t,e,n);this.top.children.splice(this.index++,0,o),this.changed=!0}else this.index++},gn.prototype.addTextblockHacks=function(){for(var t=this.top.children[this.index-1];t instanceof en;)t=t.children[t.children.length-1];if(!t||!(t instanceof on)||/\n$/.test(t.node.text))if(this.index<this.top.children.length&&this.top.children[this.index].matchesHack())this.index++;else{var e=document.createElement("br");this.top.children.splice(this.index++,0,new sn(this.top,Qe,e,null)),this.changed=!0}};var kn=le.safari||le.chrome&&le.chrome_version<63;function On(t,e){var n=t.docView.domFromPos(e,0),r=n.node,o=n.offset,i=o<r.childNodes.length?r.childNodes[o]:null,s=o?r.childNodes[o-1]:null;if(le.safari&&i&&"false"==i.contentEditable)return Mn(i);if(!(i&&"false"!=i.contentEditable||s&&"false"!=s.contentEditable)){if(i)return Mn(i);if(s)return Mn(s)}}function Mn(t){return t.contentEditable="true",le.safari&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function Cn(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function Nn(t,e){if(e instanceof Kt){var n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(Dn(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else Dn(t)}function Dn(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=null)}function Tn(t,e,n,r){return t.someProp("createSelectionBetween",(function(r){return r(t,e,n)}))||Jt.between(e,n,r)}function En(t){var e=t.root.getSelection();if(!e.anchorNode)return!1;try{return t.dom.contains(3==e.anchorNode.nodeType?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(3==e.focusNode.nodeType?e.focusNode.parentNode:e.focusNode))}catch(t){return!1}}function An(t,e){var n=t.selection,r=n.$anchor,o=n.$head,i=e>0?r.max(o):r.min(o),s=i.parent.inlineContent?i.depth?t.doc.resolve(e>0?i.after():i.before()):null:i;return s&&Lt.findFrom(s,e)}function Rn(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function zn(t,e,n){var r=t.state.selection;if(!(r instanceof Jt)){if(r instanceof Kt&&r.node.isInline)return Rn(t,new Jt(e>0?r.$to:r.$from));var o=An(t.state,e);return!!o&&Rn(t,o)}if(!r.empty||n.indexOf("s")>-1)return!1;if(t.endOfTextblock(e>0?"right":"left")){var i=An(t.state,e);return!!(i&&i instanceof Kt)&&Rn(t,i)}if(!(le.mac&&n.indexOf("m")>-1)){var s,a=r.$head,c=a.textOffset?null:e<0?a.nodeBefore:a.nodeAfter;if(!c||c.isText)return!1;var h=e<0?a.pos-c.nodeSize:a.pos;return!!(c.isAtom||(s=t.docView.descAt(h))&&!s.contentDOM)&&(Kt.isSelectable(c)?Rn(t,new Kt(e<0?t.state.doc.resolve(a.pos-c.nodeSize):a)):!!le.webkit&&Rn(t,new Jt(t.state.doc.resolve(e<0?h:h+c.nodeSize))))}}function Pn(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function In(t){var e=t.pmViewDesc;return e&&0==e.size&&(t.nextSibling||"BR"!=t.nodeName)}function Bn(t){var e=t.root.getSelection(),n=e.focusNode,r=e.focusOffset;if(n){var o,i,s=!1;for(le.gecko&&1==n.nodeType&&r<Pn(n)&&In(n.childNodes[r])&&(s=!0);;)if(r>0){if(1!=n.nodeType)break;var a=n.childNodes[r-1];if(In(a))o=n,i=--r;else{if(3!=a.nodeType)break;r=(n=a).nodeValue.length}}else{if(Vn(n))break;for(var c=n.previousSibling;c&&In(c);)o=n.parentNode,i=ge(c),c=c.previousSibling;if(c)r=Pn(n=c);else{if((n=n.parentNode)==t.dom)break;r=0}}s?$n(t,e,n,r):o&&$n(t,e,o,i)}}function Fn(t){var e=t.root.getSelection(),n=e.focusNode,r=e.focusOffset;if(n){for(var o,i,s=Pn(n);;)if(r<s){if(1!=n.nodeType)break;if(!In(n.childNodes[r]))break;o=n,i=++r}else{if(Vn(n))break;for(var a=n.nextSibling;a&&In(a);)o=a.parentNode,i=ge(a)+1,a=a.nextSibling;if(a)r=0,s=Pn(n=a);else{if((n=n.parentNode)==t.dom)break;r=s=0}}o&&$n(t,e,o,i)}}function Vn(t){var e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function $n(t,e,n,r){if(Ce(e)){var o=document.createRange();o.setEnd(n,r),o.setStart(n,r),e.removeAllRanges(),e.addRange(o)}else e.extend&&e.extend(n,r);t.domObserver.setCurSelection();var i=t.state;setTimeout((function(){t.state==i&&Sn(t)}),50)}function _n(t,e,n){var r=t.state.selection;if(r instanceof Jt&&!r.empty||n.indexOf("s")>-1)return!1;if(le.mac&&n.indexOf("m")>-1)return!1;var o=r.$from,i=r.$to;if(!o.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){var s=An(t.state,e);if(s&&s instanceof Kt)return Rn(t,s)}if(!o.parent.inlineContent){var a=e<0?o:i,c=r instanceof Ut?Lt.near(a,e):Lt.findFrom(a,e);return!!c&&Rn(t,c)}return!1}function Ln(t,e){if(!(t.state.selection instanceof Jt))return!0;var n=t.state.selection,r=n.$head,o=n.$anchor,i=n.empty;if(!r.sameParent(o))return!0;if(!i)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;var s=!r.textOffset&&(e<0?r.nodeBefore:r.nodeAfter);if(s&&!s.isText){var a=t.state.tr;return e<0?a.delete(r.pos-s.nodeSize,r.pos):a.delete(r.pos,r.pos+s.nodeSize),t.dispatch(a),!0}return!1}function jn(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function qn(t,e){var n=e.keyCode,r=function(t){var e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}(e);return 8==n||le.mac&&72==n&&"c"==r?Ln(t,-1)||Bn(t):46==n||le.mac&&68==n&&"c"==r?Ln(t,1)||Fn(t):13==n||27==n||(37==n?zn(t,-1,r)||Bn(t):39==n?zn(t,1,r)||Fn(t):38==n?_n(t,-1,r)||Bn(t):40==n?function(t){if(le.safari&&!(t.state.selection.$head.parentOffset>0)){var e=t.root.getSelection(),n=e.focusNode,r=e.focusOffset;if(n&&1==n.nodeType&&0==r&&n.firstChild&&"false"==n.firstChild.contentEditable){var o=n.firstChild;jn(t,o,!0),setTimeout((function(){return jn(t,o,!1)}),20)}}}(t)||_n(t,1,r)||Fn(t):r==(le.mac?"m":"c")&&(66==n||73==n||89==n||90==n))}function Jn(t){var e=t.pmViewDesc;if(e)return e.parseRule();if("BR"==t.nodeName&&t.parentNode){if(le.safari&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){var n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}if(t.parentNode.lastChild==t||le.safari&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if("IMG"==t.nodeName&&t.getAttribute("mark-placeholder"))return{ignore:!0}}function Wn(t,e,n,o,i){if(e<0){var s=t.lastSelectionTime>Date.now()-50?t.lastSelectionOrigin:null,a=bn(t,s);if(a&&!t.state.selection.eq(a)){var c=t.state.tr.setSelection(a);"pointer"==s?c.setMeta("pointer",!0):"key"==s&&c.scrollIntoView(),t.dispatch(c)}}else{var h=t.state.doc.resolve(e),p=h.sharedDepth(n);e=h.before(p+1),n=t.state.doc.resolve(n).after(p+1);var l=t.state.selection,f=function(t,e,n){var r=t.docView.parseRange(e,n),o=r.node,i=r.fromOffset,s=r.toOffset,a=r.from,c=r.to,h=t.root.getSelection(),p=null,l=h.anchorNode;if(l&&t.dom.contains(1==l.nodeType?l:l.parentNode)&&(p=[{node:l,offset:h.anchorOffset}],Ce(h)||p.push({node:h.focusNode,offset:h.focusOffset})),le.chrome&&8===t.lastKeyCode)for(var f=s;f>i;f--){var u=o.childNodes[f-1],d=u.pmViewDesc;if("BR"==u.nodeType&&!d){s=f;break}if(!d||d.size)break}var m=t.state.doc,v=t.someProp("domParser")||Q.fromSchema(t.state.schema),g=m.resolve(a),y=null,w=v.parse(o,{topNode:g.parent,topMatch:g.parent.contentMatchAt(g.index()),topOpen:!0,from:i,to:s,preserveWhitespace:!g.parent.type.spec.code||"full",editableContent:!0,findPositions:p,ruleFromNode:Jn,context:g});if(p&&null!=p[0].pos){var b=p[0].pos,x=p[1]&&p[1].pos;null==x&&(x=b),y={anchor:b+a,head:x+a}}return{doc:w,sel:y,from:a,to:c}}(t,e,n);if(le.chrome&&t.cursorWrapper&&f.sel&&f.sel.anchor==t.cursorWrapper.deco.from){var u=t.cursorWrapper.deco.type.toDOM.nextSibling,d=u&&u.nodeValue?u.nodeValue.length:1;f.sel={anchor:f.sel.anchor+d,head:f.sel.anchor+d}}var m,v,g=t.state.doc,y=g.slice(f.from,f.to);8===t.lastKeyCode&&Date.now()-100<t.lastKeyCodeTime?(m=t.state.selection.to,v="end"):(m=t.state.selection.from,v="start"),t.lastKeyCode=null;var w=function(t,e,n,r,o){var i=t.findDiffStart(e,n);if(null==i)return null;var s=t.findDiffEnd(e,n+t.size,n+e.size),a=s.a,c=s.b;if("end"==o){r-=a+Math.max(0,i-Math.min(a,c))-i}if(a<i&&t.size<e.size){c=(i-=r<=i&&r>=a?i-r:0)+(c-a),a=i}else if(c<i){a=(i-=r<=i&&r>=c?i-r:0)+(a-c),c=i}return{start:i,endA:a,endB:c}}(y.content,f.doc.content,f.from,m,v);if(!w){if(!(o&&l instanceof Jt&&!l.empty&&l.$head.sameParent(l.$anchor))||t.composing||f.sel&&f.sel.anchor!=f.sel.head){if(le.ios&&t.lastIOSEnter>Date.now()-225&&i.some((function(t){return"DIV"==t.nodeName||"P"==t.nodeName}))&&t.someProp("handleKeyDown",(function(e){return e(t,Ne(13,"Enter"))})))return void(t.lastIOSEnter=0);if(f.sel){var b=Kn(t,t.state.doc,f.sel);b&&!b.eq(t.state.selection)&&t.dispatch(t.state.tr.setSelection(b))}return}w={start:l.from,endA:l.to,endB:l.to}}t.domChangeCount++,t.state.selection.from<t.state.selection.to&&w.start==w.endB&&t.state.selection instanceof Jt&&(w.start>t.state.selection.from&&w.start<=t.state.selection.from+2?w.start=t.state.selection.from:w.endA<t.state.selection.to&&w.endA>=t.state.selection.to-2&&(w.endB+=t.state.selection.to-w.endA,w.endA=t.state.selection.to)),le.ie&&le.ie_version<=11&&w.endB==w.start+1&&w.endA==w.start&&w.start>f.from&&" "==f.doc.textBetween(w.start-f.from-1,w.start-f.from+1)&&(w.start--,w.endA--,w.endB--);var x,S=f.doc.resolveNoCache(w.start-f.from),k=f.doc.resolveNoCache(w.endB-f.from),O=S.sameParent(k)&&S.parent.inlineContent;if((le.ios&&t.lastIOSEnter>Date.now()-225&&(!O||i.some((function(t){return"DIV"==t.nodeName||"P"==t.nodeName})))||!O&&S.pos<f.doc.content.size&&(x=Lt.findFrom(f.doc.resolve(S.pos+1),1,!0))&&x.head==k.pos)&&t.someProp("handleKeyDown",(function(e){return e(t,Ne(13,"Enter"))})))t.lastIOSEnter=0;else if(t.state.selection.anchor>w.start&&function(t,e,n,r,o){if(!r.parent.isTextblock||n-e<=o.pos-r.pos||Hn(r,!0,!1)<o.pos)return!1;var i=t.resolve(e);if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;var s=t.resolve(Hn(i,!0,!0));if(!s.parent.isTextblock||s.pos>n||Hn(s,!0,!1)<n)return!1;return r.parent.content.cut(r.parentOffset).eq(s.parent.content)}(g,w.start,w.endA,S,k)&&t.someProp("handleKeyDown",(function(e){return e(t,Ne(8,"Backspace"))})))le.android&&le.chrome&&t.domObserver.suppressSelectionUpdates();else{le.android&&!O&&S.start()!=k.start()&&0==k.parentOffset&&S.depth==k.depth&&f.sel&&f.sel.anchor==f.sel.head&&f.sel.head==w.endA&&(w.endB-=2,k=f.doc.resolveNoCache(w.endB-f.from),setTimeout((function(){t.someProp("handleKeyDown",(function(e){return e(t,Ne(13,"Enter"))}))}),20));var M,C,N,D,T=w.start,E=w.endA;if(O)if(S.pos==k.pos)le.ie&&le.ie_version<=11&&0==S.parentOffset&&(t.domObserver.suppressSelectionUpdates(),setTimeout((function(){return Sn(t)}),20)),M=t.state.tr.delete(T,E),C=g.resolve(w.start).marksAcross(g.resolve(w.endA));else if(w.endA==w.endB&&(D=g.resolve(w.start))&&(N=function(t,e){for(var n,o,i,s=t.firstChild.marks,a=e.firstChild.marks,c=s,h=a,p=0;p<a.length;p++)c=a[p].removeFromSet(c);for(var l=0;l<s.length;l++)h=s[l].removeFromSet(h);if(1==c.length&&0==h.length)o=c[0],n="add",i=function(t){return t.mark(o.addToSet(t.marks))};else{if(0!=c.length||1!=h.length)return null;o=h[0],n="remove",i=function(t){return t.mark(o.removeFromSet(t.marks))}}for(var f=[],u=0;u<e.childCount;u++)f.push(i(e.child(u)));if(r.from(f).eq(t))return{mark:o,type:n}}(S.parent.content.cut(S.parentOffset,k.parentOffset),D.parent.content.cut(D.parentOffset,w.endA-D.start()))))M=t.state.tr,"add"==N.type?M.addMark(T,E,N.mark):M.removeMark(T,E,N.mark);else if(S.parent.child(S.index()).isText&&S.index()==k.index()-(k.textOffset?0:1)){var A=S.parent.textBetween(S.parentOffset,k.parentOffset);if(t.someProp("handleTextInput",(function(e){return e(t,T,E,A)})))return;M=t.state.tr.insertText(A,T,E)}if(M||(M=t.state.tr.replace(T,E,f.doc.slice(w.start-f.from,w.endB-f.from))),f.sel){var R=Kn(t,M.doc,f.sel);R&&!(le.chrome&&le.android&&t.composing&&R.empty&&(R.head==T||R.head==M.mapping.map(E)-1)||le.ie&&R.empty&&R.head==T)&&M.setSelection(R)}C&&M.ensureMarks(C),t.dispatch(M.scrollIntoView())}}}function Kn(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:Tn(t,e.resolve(n.anchor),e.resolve(n.head))}function Hn(t,e,n){for(var r=t.depth,o=e?t.end():t.pos;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,o++,e=!1;if(n)for(var i=t.node(r).maybeChild(t.indexAfter(r));i&&!i.isLeaf;)i=i.firstChild,o++;return o}function Un(t,e){for(var n=[],r=e.content,o=e.openStart,i=e.openEnd;o>1&&i>1&&1==r.childCount&&1==r.firstChild.childCount;){o--,i--;var s=r.firstChild;n.push(s.type.name,s.attrs!=s.type.defaultAttrs?s.attrs:null),r=s.content}var a=t.someProp("clipboardSerializer")||ht.fromSchema(t.state.schema),c=nr(),h=c.createElement("div");h.appendChild(a.serializeFragment(r,{document:c}));for(var p,l=h.firstChild;l&&1==l.nodeType&&(p=tr[l.nodeName.toLowerCase()]);){for(var f=p.length-1;f>=0;f--){for(var u=c.createElement(p[f]);h.firstChild;)u.appendChild(h.firstChild);h.appendChild(u)}l=h.firstChild}return l&&1==l.nodeType&&l.setAttribute("data-pm-slice",o+" "+i+" "+JSON.stringify(n)),{dom:h,text:t.someProp("clipboardTextSerializer",(function(t){return t(e)}))||e.content.textBetween(0,e.content.size,"\n\n")}}function Gn(t,e,n,o,i){var s,a,c=i.parent.type.spec.code;if(!n&&!e)return null;var h=e&&(o||c||!n);if(h){if(t.someProp("transformPastedText",(function(t){e=t(e,c||o)})),c)return new p(r.from(t.state.schema.text(e.replace(/\r\n?/g,"\n"))),0,0);var l=t.someProp("clipboardTextParser",(function(t){return t(e,i,o)}));l?a=l:(s=document.createElement("div"),e.trim().split(/(?:\r\n?|\n)+/).forEach((function(t){s.appendChild(document.createElement("p")).textContent=t})))}else t.someProp("transformPastedHTML",(function(t){n=t(n)})),s=function(t){var e=/(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));var n,r=nr().createElement("div"),o=/(?:<meta [^>]*>)*<([a-z][^>\s]+)/i.exec(t),i=0;(n=o&&tr[o[1].toLowerCase()])&&(t=n.map((function(t){return"<"+t+">"})).join("")+t+n.map((function(t){return"</"+t+">"})).reverse().join(""),i=n.length);r.innerHTML=t;for(var s=0;s<i;s++)r=r.firstChild;return r}(n);var f=s&&s.querySelector("[data-pm-slice]"),u=f&&/^(\d+) (\d+) (.*)/.exec(f.getAttribute("data-pm-slice"));if(!a){var d=t.someProp("clipboardParser")||t.someProp("domParser")||Q.fromSchema(t.state.schema);a=d.parseSlice(s,{preserveWhitespace:!(!h&&!u),context:i})}return a=u?function(t,e){if(!t.size)return t;var n,o=t.content.firstChild.type.schema;try{n=JSON.parse(e)}catch(e){return t}for(var i=t.content,s=t.openStart,a=t.openEnd,c=n.length-2;c>=0;c-=2){var h=o.nodes[n[c]];if(!h||h.hasRequiredAttrs())break;i=r.from(h.create(n[c+1],i)),s++,a++}return new p(i,s,a)}(function(t,e,n){e<t.openStart&&(t=new p(Zn(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd));n<t.openEnd&&(t=new p(Zn(t.content,1,n,t.openEnd,0,0),t.openStart,n));return t}(a,+u[1],+u[2]),u[3]):p.maxOpen(function(t,e){if(t.childCount<2)return t;for(var n=function(n){var o=e.node(n).contentMatchAt(e.index(n)),i=void 0,s=[];if(t.forEach((function(t){if(s){var e,n=o.findWrapping(t.type);if(!n)return s=null;if(e=s.length&&i.length&&Yn(n,i,t,s[s.length-1],0))s[s.length-1]=e;else{s.length&&(s[s.length-1]=Qn(s[s.length-1],i.length));var r=Xn(t,n);s.push(r),o=o.matchType(r.type,r.attrs),i=n}}})),s)return{v:r.from(s)}},o=e.depth;o>=0;o--){var i=n(o);if(i)return i.v}return t}(a.content,i),!1),t.someProp("transformPasted",(function(t){a=t(a)})),a}function Xn(t,e,n){void 0===n&&(n=0);for(var o=e.length-1;o>=n;o--)t=e[o].create(null,r.from(t));return t}function Yn(t,e,n,o,i){if(i<t.length&&i<e.length&&t[i]==e[i]){var s=Yn(t,e,n,o.lastChild,i+1);if(s)return o.copy(o.content.replaceChild(o.childCount-1,s));if(o.contentMatchAt(o.childCount).matchType(i==t.length-1?n.type:t[i+1]))return o.copy(o.content.append(r.from(Xn(n,t,i+1))))}}function Qn(t,e){if(0==e)return t;var n=t.content.replaceChild(t.childCount-1,Qn(t.lastChild,e-1)),o=t.contentMatchAt(t.childCount).fillBefore(r.empty,!0);return t.copy(n.append(o))}function Zn(t,e,n,o,i,s){var a=e<0?t.firstChild:t.lastChild,c=a.content;return i<o-1&&(c=Zn(c,e,n,o,i+1,s)),i>=n&&(c=e<0?a.contentMatchAt(0).fillBefore(c,t.childCount>1||s<=i).append(c):c.append(a.contentMatchAt(a.childCount).fillBefore(r.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,a.copy(c))}var tr={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]},er=null;function nr(){return er||(er=document.implementation.createHTMLDocument("title"))}var rr={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},or=le.ie&&le.ie_version<=11,ir=function(){this.anchorNode=this.anchorOffset=this.focusNode=this.focusOffset=null};ir.prototype.set=function(t){this.anchorNode=t.anchorNode,this.anchorOffset=t.anchorOffset,this.focusNode=t.focusNode,this.focusOffset=t.focusOffset},ir.prototype.eq=function(t){return t.anchorNode==this.anchorNode&&t.anchorOffset==this.anchorOffset&&t.focusNode==this.focusNode&&t.focusOffset==this.focusOffset};var sr=function(t,e){var n=this;this.view=t,this.handleDOMChange=e,this.queue=[],this.flushingSoon=-1,this.observer=window.MutationObserver&&new window.MutationObserver((function(t){for(var e=0;e<t.length;e++)n.queue.push(t[e]);le.ie&&le.ie_version<=11&&t.some((function(t){return"childList"==t.type&&t.removedNodes.length||"characterData"==t.type&&t.oldValue.length>t.target.nodeValue.length}))?n.flushSoon():n.flush()})),this.currentSelection=new ir,or&&(this.onCharData=function(t){n.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),n.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.suppressingSelectionUpdates=!1};sr.prototype.flushSoon=function(){var t=this;this.flushingSoon<0&&(this.flushingSoon=window.setTimeout((function(){t.flushingSoon=-1,t.flush()}),20))},sr.prototype.forceFlush=function(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())},sr.prototype.start=function(){this.observer&&this.observer.observe(this.view.dom,rr),or&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()},sr.prototype.stop=function(){var t=this;if(this.observer){var e=this.observer.takeRecords();if(e.length){for(var n=0;n<e.length;n++)this.queue.push(e[n]);window.setTimeout((function(){return t.flush()}),20)}this.observer.disconnect()}or&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()},sr.prototype.connectSelection=function(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)},sr.prototype.disconnectSelection=function(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)},sr.prototype.suppressSelectionUpdates=function(){var t=this;this.suppressingSelectionUpdates=!0,setTimeout((function(){return t.suppressingSelectionUpdates=!1}),50)},sr.prototype.onSelectionChange=function(){if((!(t=this.view).editable||t.root.activeElement==t.dom)&&En(t)){var t;if(this.suppressingSelectionUpdates)return Sn(this.view);if(le.ie&&le.ie_version<=11&&!this.view.state.selection.empty){var e=this.view.root.getSelection();if(e.focusNode&&xe(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}},sr.prototype.setCurSelection=function(){this.currentSelection.set(this.view.root.getSelection())},sr.prototype.ignoreSelectionChange=function(t){if(0==t.rangeCount)return!0;var e=t.getRangeAt(0).commonAncestorContainer,n=this.view.docView.nearestDesc(e);return n&&n.ignoreMutation({type:"selection",target:3==e.nodeType?e.parentNode:e})?(this.setCurSelection(),!0):void 0},sr.prototype.flush=function(){if(this.view.docView&&!(this.flushingSoon>-1)){var t=this.observer?this.observer.takeRecords():[];this.queue.length&&(t=this.queue.concat(t),this.queue.length=0);var e=this.view.root.getSelection(),n=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(e)&&En(this.view)&&!this.ignoreSelectionChange(e),r=-1,o=-1,i=!1,s=[];if(this.view.editable)for(var a=0;a<t.length;a++){var c=this.registerMutation(t[a],s);c&&(r=r<0?c.from:Math.min(c.from,r),o=o<0?c.to:Math.max(c.to,o),c.typeOver&&(i=!0))}if(le.gecko&&s.length>1){var h=s.filter((function(t){return"BR"==t.nodeName}));if(2==h.length){var p=h[0],l=h[1];p.parentNode&&p.parentNode.parentNode==l.parentNode?l.remove():p.remove()}}(r>-1||n)&&(r>-1&&(this.view.docView.markDirty(r,o),function(t){if(ar)return;ar=!0,"normal"==getComputedStyle(t.dom).whiteSpace&&console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package.")}(this.view)),this.handleDOMChange(r,o,i,s),this.view.docView.dirty?this.view.updateState(this.view.state):this.currentSelection.eq(e)||Sn(this.view),this.currentSelection.set(e))}},sr.prototype.registerMutation=function(t,e){if(e.indexOf(t.target)>-1)return null;var n=this.view.docView.nearestDesc(t.target);if("attributes"==t.type&&(n==this.view.docView||"contenteditable"==t.attributeName||"style"==t.attributeName&&!t.oldValue&&!t.target.getAttribute("style")))return null;if(!n||n.ignoreMutation(t))return null;if("childList"==t.type){if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(t.target))return{from:n.posBefore,to:n.posAfter};var r=t.previousSibling,o=t.nextSibling;if(le.ie&&le.ie_version<=11&&t.addedNodes.length)for(var i=0;i<t.addedNodes.length;i++){var s=t.addedNodes[i],a=s.previousSibling,c=s.nextSibling;(!a||Array.prototype.indexOf.call(t.addedNodes,a)<0)&&(r=a),(!c||Array.prototype.indexOf.call(t.addedNodes,c)<0)&&(o=c)}for(var h=r&&r.parentNode==t.target?ge(r)+1:0,p=n.localPosFromDOM(t.target,h,-1),l=o&&o.parentNode==t.target?ge(o):t.target.childNodes.length,f=0;f<t.addedNodes.length;f++)e.push(t.addedNodes[f]);return{from:p,to:n.localPosFromDOM(t.target,l,1)}}return"attributes"==t.type?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:{from:n.posAtStart,to:n.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}};var ar=!1;var cr={},hr={};function pr(t,e){t.lastSelectionOrigin=e,t.lastSelectionTime=Date.now()}function lr(t){t.someProp("handleDOMEvents",(function(e){for(var n in e)t.eventHandlers[n]||t.dom.addEventListener(n,t.eventHandlers[n]=function(e){return fr(t,e)})}))}function fr(t,e){return t.someProp("handleDOMEvents",(function(n){var r=n[e.type];return!!r&&(r(t,e)||e.defaultPrevented)}))}function ur(t){return{left:t.clientX,top:t.clientY}}function dr(t,e,n,r,o){if(-1==r)return!1;for(var i=t.state.doc.resolve(r),s=function(r){if(t.someProp(e,(function(e){return r>i.depth?e(t,n,i.nodeAfter,i.before(r),o,!0):e(t,n,i.node(r),i.before(r),o,!1)})))return{v:!0}},a=i.depth+1;a>0;a--){var c=s(a);if(c)return c.v}return!1}function mr(t,e,n){t.focused||t.focus();var r=t.state.tr.setSelection(e);"pointer"==n&&r.setMeta("pointer",!0),t.dispatch(r)}function vr(t,e,n,r,o){return dr(t,"handleClickOn",e,n,r)||t.someProp("handleClick",(function(n){return n(t,e,r)}))||(o?function(t,e){if(-1==e)return!1;var n,r,o=t.state.selection;o instanceof Kt&&(n=o.node);for(var i=t.state.doc.resolve(e),s=i.depth+1;s>0;s--){var a=s>i.depth?i.nodeAfter:i.node(s);if(Kt.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&&(mr(t,Kt.create(t.state.doc,r),"pointer"),!0)}(t,n):function(t,e){if(-1==e)return!1;var n=t.state.doc.resolve(e),r=n.nodeAfter;return!!(r&&r.isAtom&&Kt.isSelectable(r))&&(mr(t,new Kt(n),"pointer"),!0)}(t,n))}function gr(t,e,n,r){return dr(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",(function(n){return n(t,e,r)}))}function yr(t,e,n,r){return dr(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",(function(n){return n(t,e,r)}))||function(t,e){var n=t.state.doc;if(-1==e)return!!n.inlineContent&&(mr(t,Jt.create(n,0,n.content.size),"pointer"),!0);for(var r=n.resolve(e),o=r.depth+1;o>0;o--){var i=o>r.depth?r.nodeAfter:r.node(o),s=r.before(o);if(i.inlineContent)mr(t,Jt.create(n,s+1,s+1+i.content.size),"pointer");else{if(!Kt.isSelectable(i))continue;mr(t,Kt.create(n,s),"pointer")}return!0}}(t,n)}function wr(t){return Cr(t)}hr.keydown=function(t,e){if(t.shiftKey=16==e.keyCode||e.shiftKey,!Sr(t,e))if(t.domObserver.forceFlush(),t.lastKeyCode=e.keyCode,t.lastKeyCodeTime=Date.now(),!le.ios||13!=e.keyCode||e.ctrlKey||e.altKey||e.metaKey)t.someProp("handleKeyDown",(function(n){return n(t,e)}))||qn(t,e)?e.preventDefault():pr(t,"key");else{var n=Date.now();t.lastIOSEnter=n,t.lastIOSEnterFallbackTimeout=setTimeout((function(){t.lastIOSEnter==n&&(t.someProp("handleKeyDown",(function(e){return e(t,Ne(13,"Enter"))})),t.lastIOSEnter=0)}),200)}},hr.keyup=function(t,e){16==e.keyCode&&(t.shiftKey=!1)},hr.keypress=function(t,e){if(!(Sr(t,e)||!e.charCode||e.ctrlKey&&!e.altKey||le.mac&&e.metaKey))if(t.someProp("handleKeyPress",(function(n){return n(t,e)})))e.preventDefault();else{var n=t.state.selection;if(!(n instanceof Jt&&n.$from.sameParent(n.$to))){var r=String.fromCharCode(e.charCode);t.someProp("handleTextInput",(function(e){return e(t,n.$from.pos,n.$to.pos,r)}))||t.dispatch(t.state.tr.insertText(r).scrollIntoView()),e.preventDefault()}}};var br=le.mac?"metaKey":"ctrlKey";cr.mousedown=function(t,e){t.shiftKey=e.shiftKey;var n=wr(t),r=Date.now(),o="singleClick";r-t.lastClick.time<500&&function(t,e){var n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}(e,t.lastClick)&&!e[br]&&("singleClick"==t.lastClick.type?o="doubleClick":"doubleClick"==t.lastClick.type&&(o="tripleClick")),t.lastClick={time:r,x:e.clientX,y:e.clientY,type:o};var i=t.posAtCoords(ur(e));i&&("singleClick"==o?t.mouseDown=new xr(t,i,e,n):("doubleClick"==o?gr:yr)(t,i.pos,i.inside,e)?e.preventDefault():pr(t,"pointer"))};var xr=function(t,e,n,r){var o,i,s=this;if(this.view=t,this.startDoc=t.state.doc,this.pos=e,this.event=n,this.flushed=r,this.selectNode=n[br],this.allowDefault=n.shiftKey,e.inside>-1)o=t.state.doc.nodeAt(e.inside),i=e.inside;else{var a=t.state.doc.resolve(e.pos);o=a.parent,i=a.depth?a.before():0}this.mightDrag=null;var c=r?null:n.target,h=c?t.docView.nearestDesc(c,!0):null;this.target=h?h.dom:null,(o.type.spec.draggable&&!1!==o.type.spec.selectable||t.state.selection instanceof Kt&&i==t.state.selection.from)&&(this.mightDrag={node:o,pos:i,addAttr:this.target&&!this.target.draggable,setUneditable:this.target&&le.gecko&&!this.target.hasAttribute("contentEditable")}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout((function(){return s.target.setAttribute("contentEditable","false")}),20),this.view.domObserver.start()),t.root.addEventListener("mouseup",this.up=this.up.bind(this)),t.root.addEventListener("mousemove",this.move=this.move.bind(this)),pr(t,"pointer")};function Sr(t,e){return!!t.composing||!!(le.safari&&Math.abs(e.timeStamp-t.compositionEndedAt)<500)&&(t.compositionEndedAt=-2e8,!0)}xr.prototype.done=function(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.view.mouseDown=null},xr.prototype.up=function(t){if(this.done(),this.view.dom.contains(3==t.target.nodeType?t.target.parentNode:t.target)){var e=this.pos;this.view.state.doc!=this.startDoc&&(e=this.view.posAtCoords(ur(t))),this.allowDefault||!e?pr(this.view,"pointer"):vr(this.view,e.pos,e.inside,t,this.selectNode)?t.preventDefault():this.flushed||le.safari&&this.mightDrag&&!this.mightDrag.node.isAtom||le.chrome&&!(this.view.state.selection instanceof Jt)&&(e.pos==this.view.state.selection.from||e.pos==this.view.state.selection.to)?(mr(this.view,Lt.near(this.view.state.doc.resolve(e.pos)),"pointer"),t.preventDefault()):pr(this.view,"pointer")}},xr.prototype.move=function(t){!this.allowDefault&&(Math.abs(this.event.x-t.clientX)>4||Math.abs(this.event.y-t.clientY)>4)&&(this.allowDefault=!0),pr(this.view,"pointer")},cr.touchdown=function(t){wr(t),pr(t,"pointer")},cr.contextmenu=function(t){return wr(t)};var kr=le.android?5e3:-1;function Or(t,e){clearTimeout(t.composingTimeout),e>-1&&(t.composingTimeout=setTimeout((function(){return Cr(t)}),e))}function Mr(t){for(t.composing=!1;t.compositionNodes.length>0;)t.compositionNodes.pop().markParentsDirty()}function Cr(t,e){if(t.domObserver.forceFlush(),Mr(t),e||t.docView.dirty){var n=bn(t);return n&&!n.eq(t.state.selection)?t.dispatch(t.state.tr.setSelection(n)):t.updateState(t.state),!0}return!1}hr.compositionstart=hr.compositionupdate=function(t){if(!t.composing){t.domObserver.flush();var e=t.state,n=e.selection.$from;if(e.selection.empty&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some((function(t){return!1===t.type.spec.inclusive}))))t.markCursor=t.state.storedMarks||n.marks(),Cr(t,!0),t.markCursor=null;else if(Cr(t),le.gecko&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length)for(var r=t.root.getSelection(),o=r.focusNode,i=r.focusOffset;o&&1==o.nodeType&&0!=i;){var s=i<0?o.lastChild:o.childNodes[i-1];if(!s)break;if(3==s.nodeType){r.collapse(s,s.nodeValue.length);break}o=s,i=-1}t.composing=!0}Or(t,kr)},hr.compositionend=function(t,e){t.composing&&(t.composing=!1,t.compositionEndedAt=e.timeStamp,Or(t,20))};var Nr=le.ie&&le.ie_version<15||le.ios&&le.webkit_version<604;function Dr(t,e,n,r){var o=Gn(t,e,n,t.shiftKey,t.state.selection.$from);if(t.someProp("handlePaste",(function(e){return e(t,r,o||p.empty)})))return!0;if(!o)return!1;var i=function(t){return 0==t.openStart&&0==t.openEnd&&1==t.content.childCount?t.content.firstChild:null}(o),s=i?t.state.tr.replaceSelectionWith(i,t.shiftKey):t.state.tr.replaceSelection(o);return t.dispatch(s.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}cr.copy=hr.cut=function(t,e){var n=t.state.selection,r="cut"==e.type;if(!n.empty){var o=Nr?null:e.clipboardData,i=Un(t,n.content()),s=i.dom,a=i.text;o?(e.preventDefault(),o.clearData(),o.setData("text/html",s.innerHTML),o.setData("text/plain",a)):function(t,e){if(t.dom.parentNode){var n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";var r=getSelection(),o=document.createRange();o.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout((function(){n.parentNode&&n.parentNode.removeChild(n),t.focus()}),50)}}(t,s),r&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))}},hr.paste=function(t,e){var n=Nr?null:e.clipboardData;n&&Dr(t,n.getData("text/plain"),n.getData("text/html"),e)?e.preventDefault():function(t,e){if(t.dom.parentNode){var n=t.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus(),setTimeout((function(){t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Dr(t,r.value,null,e):Dr(t,r.textContent,r.innerHTML,e)}),50)}}(t,e)};var Tr=function(t,e){this.slice=t,this.move=e},Er=le.mac?"altKey":"ctrlKey";for(var Ar in cr.dragstart=function(t,e){var n=t.mouseDown;if(n&&n.done(),e.dataTransfer){var r=t.state.selection,o=r.empty?null:t.posAtCoords(ur(e));if(o&&o.pos>=r.from&&o.pos<=(r instanceof Kt?r.to-1:r.to));else if(n&&n.mightDrag)t.dispatch(t.state.tr.setSelection(Kt.create(t.state.doc,n.mightDrag.pos)));else if(e.target&&1==e.target.nodeType){var i=t.docView.nearestDesc(e.target,!0);if(!i||!i.node.type.spec.draggable||i==t.docView)return;t.dispatch(t.state.tr.setSelection(Kt.create(t.state.doc,i.posBefore)))}var s=t.state.selection.content(),a=Un(t,s),c=a.dom,h=a.text;e.dataTransfer.clearData(),e.dataTransfer.setData(Nr?"Text":"text/html",c.innerHTML),Nr||e.dataTransfer.setData("text/plain",h),t.dragging=new Tr(s,!e[Er])}},cr.dragend=function(t){var e=t.dragging;window.setTimeout((function(){t.dragging==e&&(t.dragging=null)}),50)},hr.dragover=hr.dragenter=function(t,e){return e.preventDefault()},hr.drop=function(t,e){var n=t.dragging;if(t.dragging=null,e.dataTransfer){var r=t.posAtCoords(ur(e));if(r){var o=t.state.doc.resolve(r.pos);if(o){var i=n&&n.slice||Gn(t,e.dataTransfer.getData(Nr?"Text":"text/plain"),Nr?null:e.dataTransfer.getData("text/html"),!1,o),s=n&&!e[Er];if(t.someProp("handleDrop",(function(n){return n(t,e,i||p.empty,s)})))e.preventDefault();else if(i){e.preventDefault();var a=i?function(t,e,n){var r=t.resolve(e);if(!n.content.size)return e;for(var o=n.content,i=0;i<n.openStart;i++)o=o.firstChild.content;for(var s=1;s<=(0==n.openStart&&n.size?2:1);s++)for(var a=r.depth;a>=0;a--){var c=a==r.depth?0:r.pos<=(r.start(a+1)+r.end(a+1))/2?-1:1,h=r.index(a)+(c>0?1:0),p=r.node(a),l=!1;if(1==s)l=p.canReplace(h,h,o);else{var f=p.contentMatchAt(h).findWrapping(o.firstChild.type);l=f&&p.canReplaceWith(h,h,f[0])}if(l)return 0==c?r.pos:c<0?r.before(a+1):r.after(a+1)}return null}(t.state.doc,o.pos,i):o.pos;null==a&&(a=o.pos);var c=t.state.tr;s&&c.deleteSelection();var h=c.mapping.map(a),l=0==i.openStart&&0==i.openEnd&&1==i.content.childCount,f=c.doc;if(l?c.replaceRangeWith(h,h,i.content.firstChild):c.replaceRange(h,h,i),!c.doc.eq(f)){var u=c.doc.resolve(h);if(l&&Kt.isSelectable(i.content.firstChild)&&u.nodeAfter&&u.nodeAfter.sameMarkup(i.content.firstChild))c.setSelection(new Kt(u));else{var d=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((function(t,e,n,r){return d=r})),c.setSelection(Tn(t,u,c.doc.resolve(d)))}t.focus(),t.dispatch(c.setMeta("uiEvent","drop"))}}}}}},cr.focus=function(t){t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout((function(){t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.root.getSelection())&&Sn(t)}),20))},cr.blur=function(t){t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),t.domObserver.currentSelection.set({}),t.focused=!1)},cr.beforeinput=function(t,e){if(le.chrome&&le.android&&"deleteContentBackward"==e.inputType){var n=t.domChangeCount;setTimeout((function(){if(t.domChangeCount==n&&(t.dom.blur(),t.focus(),!t.someProp("handleKeyDown",(function(e){return e(t,Ne(8,"Backspace"))})))){var e=t.state.selection.$cursor;e&&e.pos>0&&t.dispatch(t.state.tr.delete(e.pos-1,e.pos).scrollIntoView())}}),50)}},hr)cr[Ar]=hr[Ar];function Rr(t,e){if(t==e)return!0;for(var n in t)if(t[n]!==e[n])return!1;for(var r in e)if(!(r in t))return!1;return!0}var zr=function(t,e){this.spec=e||$r,this.side=this.spec.side||0,this.toDOM=t};zr.prototype.map=function(t,e,n,r){var o=t.mapResult(e.from+r,this.side<0?-1:1),i=o.pos;return o.deleted?null:new Br(i-n,i-n,this)},zr.prototype.valid=function(){return!0},zr.prototype.eq=function(t){return this==t||t instanceof zr&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&Rr(this.spec,t.spec))};var Pr=function(t,e){this.spec=e||$r,this.attrs=t};Pr.prototype.map=function(t,e,n,r){var o=t.map(e.from+r,this.spec.inclusiveStart?-1:1)-n,i=t.map(e.to+r,this.spec.inclusiveEnd?1:-1)-n;return o>=i?null:new Br(o,i,this)},Pr.prototype.valid=function(t,e){return e.from<e.to},Pr.prototype.eq=function(t){return this==t||t instanceof Pr&&Rr(this.attrs,t.attrs)&&Rr(this.spec,t.spec)},Pr.is=function(t){return t.type instanceof Pr};var Ir=function(t,e){this.spec=e||$r,this.attrs=t};Ir.prototype.map=function(t,e,n,r){var o=t.mapResult(e.from+r,1);if(o.deleted)return null;var i=t.mapResult(e.to+r,-1);return i.deleted||i.pos<=o.pos?null:new Br(o.pos-n,i.pos-n,this)},Ir.prototype.valid=function(t,e){var n=t.content.findIndex(e.from),r=n.index,o=n.offset;return o==e.from&&o+t.child(r).nodeSize==e.to},Ir.prototype.eq=function(t){return this==t||t instanceof Ir&&Rr(this.attrs,t.attrs)&&Rr(this.spec,t.spec)};var Br=function(t,e,n){this.from=t,this.to=e,this.type=n},Fr={spec:{configurable:!0},inline:{configurable:!0}};Br.prototype.copy=function(t,e){return new Br(t,e,this.type)},Br.prototype.eq=function(t,e){return void 0===e&&(e=0),this.type.eq(t.type)&&this.from+e==t.from&&this.to+e==t.to},Br.prototype.map=function(t,e,n){return this.type.map(t,this,e,n)},Br.widget=function(t,e,n){return new Br(t,t,new zr(e,n))},Br.inline=function(t,e,n,r){return new Br(t,e,new Pr(n,r))},Br.node=function(t,e,n,r){return new Br(t,e,new Ir(n,r))},Fr.spec.get=function(){return this.type.spec},Fr.inline.get=function(){return this.type instanceof Pr},Object.defineProperties(Br.prototype,Fr);var Vr=[],$r={},_r=function(t,e){this.local=t&&t.length?t:Vr,this.children=e&&e.length?e:Vr};_r.create=function(t,e){return e.length?Kr(e,t,0,$r):Lr},_r.prototype.find=function(t,e,n){var r=[];return this.findInner(null==t?0:t,null==e?1e9:e,r,0,n),r},_r.prototype.findInner=function(t,e,n,r,o){for(var i=0;i<this.local.length;i++){var s=this.local[i];s.from<=e&&s.to>=t&&(!o||o(s.spec))&&n.push(s.copy(s.from+r,s.to+r))}for(var a=0;a<this.children.length;a+=3)if(this.children[a]<e&&this.children[a+1]>t){var c=this.children[a]+1;this.children[a+2].findInner(t-c,e-c,n,r+c,o)}},_r.prototype.map=function(t,e,n){return this==Lr||0==t.maps.length?this:this.mapInner(t,e,0,0,n||$r)},_r.prototype.mapInner=function(t,e,n,r,o){for(var i,s=0;s<this.local.length;s++){var a=this.local[s].map(t,n,r);a&&a.type.valid(e,a)?(i||(i=[])).push(a):o.onRemove&&o.onRemove(this.local[s].spec)}return this.children.length?function(t,e,n,r,o,i,s){for(var a=t.slice(),c=function(t,e,n,r){for(var s=0;s<a.length;s+=3){var c=a[s+1],h=void 0;-1==c||t>c+i||(e>=a[s]+i?a[s+1]=-1:n>=o&&(h=r-n-(e-t))&&(a[s]+=h,a[s+1]+=h))}},h=0;h<n.maps.length;h++)n.maps[h].forEach(c);for(var p=!1,l=0;l<a.length;l+=3)if(-1==a[l+1]){var f=n.map(t[l]+i),u=f-o;if(u<0||u>=r.content.size){p=!0;continue}var d=n.map(t[l+1]+i,-1)-o,m=r.content.findIndex(u),v=m.index,g=m.offset,y=r.maybeChild(v);if(y&&g==u&&g+y.nodeSize==d){var w=a[l+2].mapInner(n,y,f+1,t[l]+i+1,s);w!=Lr?(a[l]=u,a[l+1]=d,a[l+2]=w):(a[l+1]=-2,p=!0)}else p=!0}if(p){var b=Kr(function(t,e,n,r,o,i,s){function a(t,e){for(var i=0;i<t.local.length;i++){var c=t.local[i].map(r,o,e);c?n.push(c):s.onRemove&&s.onRemove(t.local[i].spec)}for(var h=0;h<t.children.length;h+=3)a(t.children[h+2],t.children[h]+e+1)}for(var c=0;c<t.length;c+=3)-1==t[c+1]&&a(t[c+2],e[c]+i+1);return n}(a,t,e||[],n,o,i,s),r,0,s);e=b.local;for(var x=0;x<a.length;x+=3)a[x+1]<0&&(a.splice(x,3),x-=3);for(var S=0,k=0;S<b.children.length;S+=3){for(var O=b.children[S];k<a.length&&a[k]<O;)k+=3;a.splice(k,0,b.children[S],b.children[S+1],b.children[S+2])}}return new _r(e&&e.sort(Hr),a)}(this.children,i,t,e,n,r,o):i?new _r(i.sort(Hr)):Lr},_r.prototype.add=function(t,e){return e.length?this==Lr?_r.create(t,e):this.addInner(t,e,0):this},_r.prototype.addInner=function(t,e,n){var r,o=this,i=0;t.forEach((function(t,s){var a,c=s+n;if(a=Jr(e,t,c)){for(r||(r=o.children.slice());i<r.length&&r[i]<s;)i+=3;r[i]==s?r[i+2]=r[i+2].addInner(t,a,c+1):r.splice(i,0,s,s+t.nodeSize,Kr(a,t,c+1,$r)),i+=3}}));for(var s=qr(i?Wr(e):e,-n),a=0;a<s.length;a++)s[a].type.valid(t,s[a])||s.splice(a--,1);return new _r(s.length?this.local.concat(s).sort(Hr):this.local,r||this.children)},_r.prototype.remove=function(t){return 0==t.length||this==Lr?this:this.removeInner(t,0)},_r.prototype.removeInner=function(t,e){for(var n=this.children,r=this.local,o=0;o<n.length;o+=3){for(var i=void 0,s=n[o]+e,a=n[o+1]+e,c=0,h=void 0;c<t.length;c++)(h=t[c])&&h.from>s&&h.to<a&&(t[c]=null,(i||(i=[])).push(h));if(i){n==this.children&&(n=this.children.slice());var p=n[o+2].removeInner(i,s+1);p!=Lr?n[o+2]=p:(n.splice(o,3),o-=3)}}if(r.length)for(var l=0,f=void 0;l<t.length;l++)if(f=t[l])for(var u=0;u<r.length;u++)r[u].eq(f,e)&&(r==this.local&&(r=this.local.slice()),r.splice(u--,1));return n==this.children&&r==this.local?this:r.length||n.length?new _r(r,n):Lr},_r.prototype.forChild=function(t,e){if(this==Lr)return this;if(e.isLeaf)return _r.empty;for(var n,r,o=0;o<this.children.length;o+=3)if(this.children[o]>=t){this.children[o]==t&&(n=this.children[o+2]);break}for(var i=t+1,s=i+e.content.size,a=0;a<this.local.length;a++){var c=this.local[a];if(c.from<s&&c.to>i&&c.type instanceof Pr){var h=Math.max(i,c.from)-i,p=Math.min(s,c.to)-i;h<p&&(r||(r=[])).push(c.copy(h,p))}}if(r){var l=new _r(r.sort(Hr));return n?new jr([l,n]):l}return n||Lr},_r.prototype.eq=function(t){if(this==t)return!0;if(!(t instanceof _r)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(var e=0;e<this.local.length;e++)if(!this.local[e].eq(t.local[e]))return!1;for(var n=0;n<this.children.length;n+=3)if(this.children[n]!=t.children[n]||this.children[n+1]!=t.children[n+1]||!this.children[n+2].eq(t.children[n+2]))return!1;return!0},_r.prototype.locals=function(t){return Ur(this.localsInner(t))},_r.prototype.localsInner=function(t){if(this==Lr)return Vr;if(t.inlineContent||!this.local.some(Pr.is))return this.local;for(var e=[],n=0;n<this.local.length;n++)this.local[n].type instanceof Pr||e.push(this.local[n]);return e};var Lr=new _r;_r.empty=Lr,_r.removeOverlap=Ur;var jr=function(t){this.members=t};function qr(t,e){if(!e||!t.length)return t;for(var n=[],r=0;r<t.length;r++){var o=t[r];n.push(new Br(o.from+e,o.to+e,o.type))}return n}function Jr(t,e,n){if(e.isLeaf)return null;for(var r=n+e.nodeSize,o=null,i=0,s=void 0;i<t.length;i++)(s=t[i])&&s.from>n&&s.to<r&&((o||(o=[])).push(s),t[i]=null);return o}function Wr(t){for(var e=[],n=0;n<t.length;n++)null!=t[n]&&e.push(t[n]);return e}function Kr(t,e,n,r){var o=[],i=!1;e.forEach((function(e,s){var a=Jr(t,e,s+n);if(a){i=!0;var c=Kr(a,e,n+s+1,r);c!=Lr&&o.push(s,s+e.nodeSize,c)}}));for(var s=qr(i?Wr(t):t,-n).sort(Hr),a=0;a<s.length;a++)s[a].type.valid(e,s[a])||(r.onRemove&&r.onRemove(s[a].spec),s.splice(a--,1));return s.length||o.length?new _r(s,o):Lr}function Hr(t,e){return t.from-e.from||t.to-e.to}function Ur(t){for(var e=t,n=0;n<e.length-1;n++){var r=e[n];if(r.from!=r.to)for(var o=n+1;o<e.length;o++){var i=e[o];if(i.from!=r.from){i.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,i.from),Gr(e,o,r.copy(i.from,r.to)));break}i.to!=r.to&&(e==t&&(e=t.slice()),e[o]=i.copy(i.from,r.to),Gr(e,o+1,i.copy(r.to,i.to)))}}return e}function Gr(t,e,n){for(;e<t.length&&Hr(n,t[e])>0;)e++;t.splice(e,0,n)}function Xr(t){var e=[];return t.someProp("decorations",(function(n){var r=n(t.state);r&&r!=Lr&&e.push(r)})),t.cursorWrapper&&e.push(_r.create(t.state.doc,[t.cursorWrapper.deco])),jr.from(e)}jr.prototype.forChild=function(t,e){if(e.isLeaf)return _r.empty;for(var n=[],r=0;r<this.members.length;r++){var o=this.members[r].forChild(t,e);o!=Lr&&(o instanceof jr?n=n.concat(o.members):n.push(o))}return jr.from(n)},jr.prototype.eq=function(t){if(!(t instanceof jr)||t.members.length!=this.members.length)return!1;for(var e=0;e<this.members.length;e++)if(!this.members[e].eq(t.members[e]))return!1;return!0},jr.prototype.locals=function(t){for(var e,n=!0,r=0;r<this.members.length;r++){var o=this.members[r].localsInner(t);if(o.length)if(e){n&&(e=e.slice(),n=!1);for(var i=0;i<o.length;i++)e.push(o[i])}else e=o}return e?Ur(n?e:e.sort(Hr)):Vr},jr.from=function(t){switch(t.length){case 0:return Lr;case 1:return t[0];default:return new jr(t)}};var Yr=function(t,e){this._props=e,this.state=e.state,this.dispatch=this.dispatch.bind(this),this._root=null,this.focused=!1,this.trackWrites=null,this.dom=t&&t.mount||document.createElement("div"),t&&(t.appendChild?t.appendChild(this.dom):t.apply?t(this.dom):t.mount&&(this.mounted=!0)),this.editable=eo(this),this.markCursor=null,this.cursorWrapper=null,to(this),this.nodeViews=no(this),this.docView=rn(this.state.doc,Zr(this),Xr(this),this.dom,this),this.lastSelectedViewDesc=null,this.dragging=null,function(t){t.shiftKey=!1,t.mouseDown=null,t.lastKeyCode=null,t.lastKeyCodeTime=0,t.lastClick={time:0,x:0,y:0,type:""},t.lastSelectionOrigin=null,t.lastSelectionTime=0,t.lastIOSEnter=0,t.lastIOSEnterFallbackTimeout=null,t.composing=!1,t.composingTimeout=null,t.compositionNodes=[],t.compositionEndedAt=-2e8,t.domObserver=new sr(t,(function(e,n,r,o){return Wn(t,e,n,r,o)})),t.domObserver.start(),t.domChangeCount=0,t.eventHandlers=Object.create(null);var e=function(e){var n=cr[e];t.dom.addEventListener(e,t.eventHandlers[e]=function(e){!function(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(var n=e.target;n!=t.dom;n=n.parentNode)if(!n||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}(t,e)||fr(t,e)||!t.editable&&e.type in hr||n(t,e)})};for(var n in cr)e(n);le.safari&&t.dom.addEventListener("input",(function(){return null})),lr(t)}(this),this.pluginViews=[],this.updatePluginViews()},Qr={props:{configurable:!0},root:{configurable:!0}};function Zr(t){var e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",(function(n){if("function"==typeof n&&(n=n(t.state)),n)for(var r in n)"class"==r?e.class+=" "+n[r]:e[r]||"contenteditable"==r||"nodeName"==r||(e[r]=String(n[r]))})),[Br.node(0,t.state.doc.content.size,e)]}function to(t){if(t.markCursor){var e=document.createElement("img");e.setAttribute("mark-placeholder","true"),t.cursorWrapper={dom:e,deco:Br.widget(t.state.selection.head,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function eo(t){return!t.someProp("editable",(function(e){return!1===e(t.state)}))}function no(t){var e={};return t.someProp("nodeViews",(function(t){for(var n in t)Object.prototype.hasOwnProperty.call(e,n)||(e[n]=t[n])})),e}function ro(t){const{char:e,allowSpaces:n,startOfLine:r,$position:o}=t;if(o.depth<=0)return null;const i=`\\${e}`,s=new RegExp(`\\s${i}$`),a=r?"^":"",c=n?new RegExp(`${a}${i}.*?(?=\\s${i}|$)`,"gm"):new RegExp(`${a}(?:^)?${i}[^\\s${i}]*`,"gm"),h=o.before(),p=o.pos,l=o.doc.textBetween(h,p,"\0","\0"),f=Array.from(l.matchAll(c)).pop();if(!f||void 0===f.input||void 0===f.index)return null;const u=f.input.slice(Math.max(0,f.index-1),f.index);if(!/^[\s\0]?$/.test(u))return null;const d=f.index+o.start();let m=d+f[0].length;return n&&s.test(l.slice(m-1,m+1))&&(f[0]+=" ",m+=1),d<o.pos&&m>=o.pos?{range:{from:d,to:m},query:f[0].slice(e.length),text:f[0]}:null}function oo({editor:t,char:e="@",allowSpaces:n=!1,startOfLine:r=!1,decorationTag:o="span",decorationClass:i="suggestion",command:s=(()=>null),items:a=(()=>[]),render:c=(()=>({})),allow:h=(()=>!0)}){const p=null==c?void 0:c();return new ae({key:new pe("suggestion"),view(){return{update:async(e,n)=>{var r,o,i,c,h;const l=null===(r=this.key)||void 0===r?void 0:r.getState(n),f=null===(o=this.key)||void 0===o?void 0:o.getState(e.state),u=l.active&&f.active&&l.range.from!==f.range.from,d=!l.active&&f.active,m=l.active&&!f.active,v=d||u,g=!d&&!m&&l.query!==f.query&&!u,y=m||u;if(!v&&!g&&!y)return;const w=y?l:f,b=document.querySelector(`[data-decoration-id="${w.decorationId}"]`),x={editor:t,range:w.range,query:w.query,text:w.text,items:g||v?await a(w.query):[],command:e=>{s({editor:t,range:w.range,props:e})},decorationNode:b,clientRect:()=>(null==b?void 0:b.getBoundingClientRect())||null};y&&(null===(i=null==p?void 0:p.onExit)||void 0===i||i.call(p,x)),g&&(null===(c=null==p?void 0:p.onUpdate)||void 0===c||c.call(p,x)),v&&(null===(h=null==p?void 0:p.onStart)||void 0===h||h.call(p,x))}}},state:{init:()=>({active:!1,range:{},query:null,text:null}),apply(o,i){const{selection:s}=o,a={...i};if(s.from===s.to){(s.from<i.range.from||s.from>i.range.to)&&(a.active=!1);const o=ro({char:e,allowSpaces:n,startOfLine:r,$position:s.$from}),c=`id_${Math.floor(4294967295*Math.random())}`;o&&h({editor:t,range:o.range})?(a.active=!0,a.decorationId=i.decorationId?i.decorationId:c,a.range=o.range,a.query=o.query,a.text=o.text):a.active=!1}else a.active=!1;return a.active||(a.decorationId=null,a.range={},a.query=null,a.text=null),a}},props:{handleKeyDown(t,e){var n;const{active:r,range:o}=this.getState(t.state);return r&&(null===(n=null==p?void 0:p.onKeyDown)||void 0===n?void 0:n.call(p,{view:t,event:e,range:o}))||!1},decorations(t){const{active:e,range:n,decorationId:r}=this.getState(t);return e?_r.create(t.doc,[Br.inline(n.from,n.to,{nodeName:o,class:i,"data-decoration-id":r})]):null}}})}Qr.props.get=function(){if(this._props.state!=this.state){var t=this._props;for(var e in this._props={},t)this._props[e]=t[e];this._props.state=this.state}return this._props},Yr.prototype.update=function(t){t.handleDOMEvents!=this._props.handleDOMEvents&&lr(this),this._props=t,this.updateStateInner(t.state,!0)},Yr.prototype.setProps=function(t){var e={};for(var n in this._props)e[n]=this._props[n];for(var r in e.state=this.state,t)e[r]=t[r];this.update(e)},Yr.prototype.updateState=function(t){this.updateStateInner(t,this.state.plugins!=t.plugins)},Yr.prototype.updateStateInner=function(t,e){var n=this,r=this.state,o=!1,i=!1;if(t.storedMarks&&this.composing&&(Mr(this),i=!0),this.state=t,e){var s=no(this);(function(t,e){var n=0,r=0;for(var o in t){if(t[o]!=e[o])return!0;n++}for(var i in e)r++;return n!=r})(s,this.nodeViews)&&(this.nodeViews=s,o=!0),lr(this)}this.editable=eo(this),to(this);var a=Xr(this),c=Zr(this),h=e?"reset":t.scrollToSelection>r.scrollToSelection?"to selection":"preserve",p=o||!this.docView.matchesNode(t.doc,c,a);!p&&t.selection.eq(r.selection)||(i=!0);var l,f,u,d,m,v,g,y,w,b,x,S="preserve"==h&&i&&null==this.dom.style.overflowAnchor&&function(t){for(var e,n,r=t.dom.getBoundingClientRect(),o=Math.max(0,r.top),i=(r.left+r.right)/2,s=o+1;s<Math.min(innerHeight,r.bottom);s+=5){var a=t.root.elementFromPoint(i,s);if(a!=t.dom&&t.dom.contains(a)){var c=a.getBoundingClientRect();if(c.top>=o-20){e=a,n=c.top;break}}}return{refDOM:e,refTop:n,stack:Re(t.dom)}}(this);if(i){this.domObserver.stop();var k=p&&(le.ie||le.chrome)&&!this.composing&&!r.selection.empty&&!t.selection.empty&&(d=r.selection,m=t.selection,v=Math.min(d.$anchor.sharedDepth(d.head),m.$anchor.sharedDepth(m.head)),d.$anchor.start(v)!=m.$anchor.start(v));if(p){var O=le.chrome?this.trackWrites=this.root.getSelection().focusNode:null;!o&&this.docView.update(t.doc,c,a,this)||(this.docView.updateOuterDeco([]),this.docView.destroy(),this.docView=rn(t.doc,c,a,this.dom,this)),O&&!this.trackWrites&&(k=!0)}k||!(this.mouseDown&&this.domObserver.currentSelection.eq(this.root.getSelection())&&(l=this,f=l.docView.domFromPos(l.state.selection.anchor,0),u=l.root.getSelection(),xe(f.node,f.offset,u.anchorNode,u.anchorOffset)))?Sn(this,k):(Nn(this,t.selection),this.domObserver.setCurSelection()),this.domObserver.start()}if(this.updatePluginViews(r),"reset"==h)this.dom.scrollTop=0;else if("to selection"==h){var M=this.root.getSelection().focusNode;this.someProp("handleScrollToSelection",(function(t){return t(n)}))||(t.selection instanceof Kt?Ae(this,this.docView.domAfterPos(t.selection.from).getBoundingClientRect(),M):Ae(this,this.coordsAtPos(t.selection.head,1),M))}else S&&(y=(g=S).refDOM,w=g.refTop,b=g.stack,x=y?y.getBoundingClientRect().top:0,ze(b,0==x?0:x-w))},Yr.prototype.destroyPluginViews=function(){for(var t;t=this.pluginViews.pop();)t.destroy&&t.destroy()},Yr.prototype.updatePluginViews=function(t){if(t&&t.plugins==this.state.plugins)for(var e=0;e<this.pluginViews.length;e++){var n=this.pluginViews[e];n.update&&n.update(this,t)}else{this.destroyPluginViews();for(var r=0;r<this.state.plugins.length;r++){var o=this.state.plugins[r];o.spec.view&&this.pluginViews.push(o.spec.view(this))}}},Yr.prototype.someProp=function(t,e){var n,r=this._props&&this._props[t];if(null!=r&&(n=e?e(r):r))return n;var o=this.state.plugins;if(o)for(var i=0;i<o.length;i++){var s=o[i].props[t];if(null!=s&&(n=e?e(s):s))return n}},Yr.prototype.hasFocus=function(){return this.root.activeElement==this.dom},Yr.prototype.focus=function(){this.domObserver.stop(),this.editable&&function(t){if(t.setActive)return t.setActive();if(Pe)return t.focus(Pe);var e=Re(t);t.focus(null==Pe?{get preventScroll(){return Pe={preventScroll:!0},!0}}:void 0),Pe||(Pe=!1,ze(e,0))}(this.dom),Sn(this),this.domObserver.start()},Qr.root.get=function(){var t=this._root;if(null==t)for(var e=this.dom.parentNode;e;e=e.parentNode)if(9==e.nodeType||11==e.nodeType&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=function(){return document.getSelection()}),this._root=e;return t||document},Yr.prototype.posAtCoords=function(t){return Ve(this,t)},Yr.prototype.coordsAtPos=function(t,e){return void 0===e&&(e=1),Le(this,t,e)},Yr.prototype.domAtPos=function(t,e){return void 0===e&&(e=0),this.docView.domFromPos(t,e)},Yr.prototype.nodeDOM=function(t){var e=this.docView.descAt(t);return e?e.nodeDOM:null},Yr.prototype.posAtDOM=function(t,e,n){void 0===n&&(n=-1);var r=this.docView.posFromDOM(t,e,n);if(null==r)throw new RangeError("DOM position not inside the editor");return r},Yr.prototype.endOfTextblock=function(t,e){return Ge(this,e||this.state,t)},Yr.prototype.destroy=function(){this.docView&&(!function(t){for(var e in t.domObserver.stop(),t.eventHandlers)t.dom.removeEventListener(e,t.eventHandlers[e]);clearTimeout(t.composingTimeout),clearTimeout(t.lastIOSEnterFallbackTimeout)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Xr(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null)},Yr.prototype.dispatchEvent=function(t){return function(t,e){fr(t,e)||!cr[e.type]||!t.editable&&e.type in hr||cr[e.type](t,e)}(this,t)},Yr.prototype.dispatch=function(t){var e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))},Object.defineProperties(Yr.prototype,Qr),t.Suggestion=oo,t.default=oo,t.findSuggestionMatch=ro,Object.defineProperty(t,"__esModule",{value:!0})}));
|
|
2
|
-
//# sourceMappingURL=tiptap-suggestion.bundle.umd.min.js.map
|