dash_mantine_components 2.3.0 → 2.4.1

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.
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see async-RichTextEditor.js.LICENSE.txt */
2
- "use strict";(self.webpackChunkdash_mantine_components=self.webpackChunkdash_mantine_components||[]).push([[330],{2162:(t,e,n)=>{var o=n(295),r=n(9888),i="function"==typeof Object.is?Object.is:function(t,e){return t===e&&(0!==t||1/t==1/e)||t!=t&&e!=e},s=r.useSyncExternalStore,l=o.useRef,a=o.useEffect,c=o.useMemo,d=o.useDebugValue;e.useSyncExternalStoreWithSelector=function(t,e,n,o,r){var h=l(null);if(null===h.current){var p={hasValue:!1,value:null};h.current=p}else p=h.current;h=c(function(){function t(t){if(!a){if(a=!0,s=t,t=o(t),void 0!==r&&p.hasValue){var e=p.value;if(r(e,t))return l=e}return l=t}if(e=l,i(s,t))return e;var n=o(t);return void 0!==r&&r(e,n)?(s=t,e):(s=t,l=n)}var s,l,a=!1,c=void 0===n?null:n;return[function(){return t(e())},null===c?void 0:function(){return t(c())}]},[e,n,o,r]);var u=s(t,h[0],h[1]);return a(function(){p.hasValue=!0,p.value=u},[u]),d(u),u}},2979:(t,e,n)=>{n.r(e),n.d(e,{default:()=>Xm});var o=n(1635),r=n(4848),i=n(295),s=n.n(i),l=n(2412),a=n(6100),c=n(2837),d=n(4791);const h={linkControlLabel:"Link",colorPickerControlLabel:"Text color",highlightControlLabel:"Highlight text",colorControlLabel:t=>`Set text color ${t}`,boldControlLabel:"Bold",italicControlLabel:"Italic",underlineControlLabel:"Underline",strikeControlLabel:"Strikethrough",clearFormattingControlLabel:"Clear formatting",unlinkControlLabel:"Remove link",bulletListControlLabel:"Bullet list",orderedListControlLabel:"Ordered list",sourceCodeControlLabel:"Switch between text/source code",h1ControlLabel:"Heading 1",h2ControlLabel:"Heading 2",h3ControlLabel:"Heading 3",h4ControlLabel:"Heading 4",h5ControlLabel:"Heading 5",h6ControlLabel:"Heading 6",blockquoteControlLabel:"Blockquote",alignLeftControlLabel:"Align text: left",alignCenterControlLabel:"Align text: center",alignRightControlLabel:"Align text: right",alignJustifyControlLabel:"Align text: justify",codeControlLabel:"Code",codeBlockControlLabel:"Code block",subscriptControlLabel:"Subscript",superscriptControlLabel:"Superscript",unsetColorControlLabel:"Unset color",hrControlLabel:"Horizontal line",undoControlLabel:"Undo",redoControlLabel:"Redo",tasksControlLabel:"Task list",tasksSinkLabel:"Decrease task level",tasksLiftLabel:"Increase task level",linkEditorInputLabel:"Enter URL",linkEditorInputPlaceholder:"https://example.com/",linkEditorExternalLink:"Open link in a new tab",linkEditorInternalLink:"Open link in the same tab",linkEditorSave:"Save",colorPickerCancel:"Cancel",colorPickerClear:"Clear color",colorPickerColorPicker:"Color picker",colorPickerPalette:"Color palette",colorPickerSave:"Save",colorPickerColorLabel:t=>`Set text color ${t}`};var p=n(6798);const[u,f]=(0,p.F)("RichTextEditor component was not found in tree");var m=n(3775),g=n(9888);function y(t){this.content=t}y.prototype={constructor:y,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return-1==e?void 0:this.content[e+1]},update:function(t,e,n){var o=n&&n!=t?this.remove(n):this,r=o.find(t),i=o.content.slice();return-1==r?i.push(n||t,e):(i[r+1]=e,n&&(i[r]=n)),new y(i)},remove:function(t){var e=this.find(t);if(-1==e)return this;var n=this.content.slice();return n.splice(e,2),new y(n)},addToStart:function(t,e){return new y([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new y(n)},addBefore:function(t,e,n){var o=this.remove(e),r=o.content.slice(),i=o.find(t);return r.splice(-1==i?r.length:i,0,e,n),new y(r)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return(t=y.from(t)).size?new y(t.content.concat(this.subtract(t).content)):this},append:function(t){return(t=y.from(t)).size?new y(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=y.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach(function(e,n){t[e]=n}),t},get size(){return this.content.length>>1}},y.from=function(t){if(t instanceof y)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new y(e)};const b=y;function v(t,e,n){for(let o=0;;o++){if(o==t.childCount||o==e.childCount)return t.childCount==e.childCount?null:n;let r=t.child(o),i=e.child(o);if(r!=i){if(!r.sameMarkup(i))return n;if(r.isText&&r.text!=i.text){for(let t=0;r.text[t]==i.text[t];t++)n++;return n}if(r.content.size||i.content.size){let t=v(r.content,i.content,n+1);if(null!=t)return t}n+=r.nodeSize}else n+=r.nodeSize}}function w(t,e,n,o){for(let r=t.childCount,i=e.childCount;;){if(0==r||0==i)return r==i?null:{a:n,b:o};let s=t.child(--r),l=e.child(--i),a=s.nodeSize;if(s!=l){if(!s.sameMarkup(l))return{a:n,b:o};if(s.isText&&s.text!=l.text){let t=0,e=Math.min(s.text.length,l.text.length);for(;t<e&&s.text[s.text.length-t-1]==l.text[l.text.length-t-1];)t++,n--,o--;return{a:n,b:o}}if(s.content.size||l.content.size){let t=w(s.content,l.content,n-1,o-1);if(t)return t}n-=a,o-=a}else n-=a,o-=a}}class k{constructor(t,e){if(this.content=t,this.size=e||0,null==e)for(let e=0;e<t.length;e++)this.size+=t[e].nodeSize}nodesBetween(t,e,n,o=0,r){for(let i=0,s=0;s<e;i++){let l=this.content[i],a=s+l.nodeSize;if(a>t&&!1!==n(l,o+s,r||null,i)&&l.content.size){let r=s+1;l.nodesBetween(Math.max(0,t-r),Math.min(l.content.size,e-r),n,o+r)}s=a}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,e,n,o){let r="",i=!0;return this.nodesBetween(t,e,(s,l)=>{let a=s.isText?s.text.slice(Math.max(t,l)-l,e-l):s.isLeaf?o?"function"==typeof o?o(s):o:s.type.spec.leafText?s.type.spec.leafText(s):"":"";s.isBlock&&(s.isLeaf&&a||s.isTextblock)&&n&&(i?i=!1:r+=n),r+=a},0),r}append(t){if(!t.size)return this;if(!this.size)return t;let e=this.lastChild,n=t.firstChild,o=this.content.slice(),r=0;for(e.isText&&e.sameMarkup(n)&&(o[o.length-1]=e.withText(e.text+n.text),r=1);r<t.content.length;r++)o.push(t.content[r]);return new k(o,this.size+t.size)}cut(t,e=this.size){if(0==t&&e==this.size)return this;let n=[],o=0;if(e>t)for(let r=0,i=0;i<e;r++){let s=this.content[r],l=i+s.nodeSize;l>t&&((i<t||l>e)&&(s=s.isText?s.cut(Math.max(0,t-i),Math.min(s.text.length,e-i)):s.cut(Math.max(0,t-i-1),Math.min(s.content.size,e-i-1))),n.push(s),o+=s.nodeSize),i=l}return new k(n,o)}cutByIndex(t,e){return t==e?k.empty:0==t&&e==this.content.length?this:new k(this.content.slice(t,e))}replaceChild(t,e){let n=this.content[t];if(n==e)return this;let o=this.content.slice(),r=this.size+e.nodeSize-n.nodeSize;return o[t]=e,new k(o,r)}addToStart(t){return new k([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new k(this.content.concat(t),this.size+t.nodeSize)}eq(t){if(this.content.length!=t.content.length)return!1;for(let e=0;e<this.content.length;e++)if(!this.content[e].eq(t.content[e]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(t){let e=this.content[t];if(!e)throw new RangeError("Index "+t+" out of range for "+this);return e}maybeChild(t){return this.content[t]||null}forEach(t){for(let e=0,n=0;e<this.content.length;e++){let o=this.content[e];t(o,n,e),n+=o.nodeSize}}findDiffStart(t,e=0){return v(this,t,e)}findDiffEnd(t,e=this.size,n=t.size){return w(this,t,e,n)}findIndex(t){if(0==t)return M(0,t);if(t==this.size)return M(this.content.length,t);if(t>this.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let e=0,n=0;;e++){let o=n+this.child(e).nodeSize;if(o>=t)return o==t?M(e+1,o):M(e,n);n=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(t=>t.toJSON()):null}static fromJSON(t,e){if(!e)return k.empty;if(!Array.isArray(e))throw new RangeError("Invalid input for Fragment.fromJSON");return new k(e.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return k.empty;let e,n=0;for(let o=0;o<t.length;o++){let r=t[o];n+=r.nodeSize,o&&r.isText&&t[o-1].sameMarkup(r)?(e||(e=t.slice(0,o)),e[e.length-1]=r.withText(e[e.length-1].text+r.text)):e&&e.push(r)}return new k(e||t,n)}static from(t){if(!t)return k.empty;if(t instanceof k)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new k([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}k.empty=new k([],0);const x={index:0,offset:0};function M(t,e){return x.index=t,x.offset=e,x}function C(t,e){if(t===e)return!0;if(!t||"object"!=typeof t||!e||"object"!=typeof e)return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!C(t[n],e[n]))return!1}else{for(let n in t)if(!(n in e)||!C(t[n],e[n]))return!1;for(let n in e)if(!(n in t))return!1}return!0}class S{constructor(t,e){this.type=t,this.attrs=e}addToSet(t){let e,n=!1;for(let o=0;o<t.length;o++){let r=t[o];if(this.eq(r))return t;if(this.type.excludes(r.type))e||(e=t.slice(0,o));else{if(r.type.excludes(this.type))return t;!n&&r.type.rank>this.type.rank&&(e||(e=t.slice(0,o)),e.push(this),n=!0),e&&e.push(r)}}return e||(e=t.slice()),n||e.push(this),e}removeFromSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return t.slice(0,e).concat(t.slice(e+1));return t}isInSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return!0;return!1}eq(t){return this==t||this.type==t.type&&C(this.attrs,t.attrs)}toJSON(){let t={type:this.type.name};for(let e in this.attrs){t.attrs=this.attrs;break}return t}static fromJSON(t,e){if(!e)throw new RangeError("Invalid input for Mark.fromJSON");let n=t.marks[e.type];if(!n)throw new RangeError(`There is no mark type ${e.type} in this schema`);let o=n.create(e.attrs);return n.checkAttrs(o.attrs),o}static sameSet(t,e){if(t==e)return!0;if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].eq(e[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&0==t.length)return S.none;if(t instanceof S)return[t];let e=t.slice();return e.sort((t,e)=>t.type.rank-e.type.rank),e}}S.none=[];class T extends Error{}class A{constructor(t,e,n){this.content=t,this.openStart=e,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,e){let n=O(this.content,t+this.openStart,e);return n&&new A(n,this.openStart,this.openEnd)}removeBetween(t,e){return new A(E(this.content,t+this.openStart,e+this.openStart),this.openStart,this.openEnd)}eq(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let t={content:this.content.toJSON()};return this.openStart>0&&(t.openStart=this.openStart),this.openEnd>0&&(t.openEnd=this.openEnd),t}static fromJSON(t,e){if(!e)return A.empty;let 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 A(k.fromJSON(t,e.content),n,o)}static maxOpen(t,e=!0){let n=0,o=0;for(let o=t.firstChild;o&&!o.isLeaf&&(e||!o.type.spec.isolating);o=o.firstChild)n++;for(let n=t.lastChild;n&&!n.isLeaf&&(e||!n.type.spec.isolating);n=n.lastChild)o++;return new A(t,n,o)}}function E(t,e,n){let{index:o,offset:r}=t.findIndex(e),i=t.maybeChild(o),{index:s,offset:l}=t.findIndex(n);if(r==e||i.isText){if(l!=n&&!t.child(s).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(o!=s)throw new RangeError("Removing non-flat range");return t.replaceChild(o,i.copy(E(i.content,e-r-1,n-r-1)))}function O(t,e,n,o){let{index:r,offset:i}=t.findIndex(e),s=t.maybeChild(r);if(i==e||s.isText)return o&&!o.canReplace(r,r,n)?null:t.cut(0,e).append(n).append(t.cut(e));let l=O(s.content,e-i-1,n,s);return l&&t.replaceChild(r,s.copy(l))}function N(t,e,n){if(n.openStart>t.depth)throw new T("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new T("Inconsistent open depths");return D(t,e,n,0)}function D(t,e,n,o){let r=t.index(o),i=t.node(o);if(r==e.index(o)&&o<t.depth-n.openStart){let s=D(t,e,n,o+1);return i.copy(i.content.replaceChild(r,s))}if(n.content.size){if(n.openStart||n.openEnd||t.depth!=o||e.depth!=o){let{start:r,end:s}=function(t,e){let n=e.depth-t.openStart,o=e.node(n).copy(t.content);for(let t=n-1;t>=0;t--)o=e.node(t).copy(k.from(o));return{start:o.resolveNoCache(t.openStart+n),end:o.resolveNoCache(o.content.size-t.openEnd-n)}}(n,t);return P(i,z(t,r,s,e,o))}{let o=t.parent,r=o.content;return P(o,r.cut(0,t.parentOffset).append(n.content).append(r.cut(e.parentOffset)))}}return P(i,$(t,e,o))}function L(t,e){if(!e.type.compatibleContent(t.type))throw new T("Cannot join "+e.type.name+" onto "+t.type.name)}function R(t,e,n){let o=t.node(n);return L(o,e.node(n)),o}function j(t,e){let 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 I(t,e,n,o){let r=(e||t).node(n),i=0,s=e?e.index(n):r.childCount;t&&(i=t.index(n),t.depth>n?i++:t.textOffset&&(j(t.nodeAfter,o),i++));for(let t=i;t<s;t++)j(r.child(t),o);e&&e.depth==n&&e.textOffset&&j(e.nodeBefore,o)}function P(t,e){return t.type.checkContent(e),t.copy(e)}function z(t,e,n,o,r){let i=t.depth>r&&R(t,e,r+1),s=o.depth>r&&R(n,o,r+1),l=[];return I(null,t,r,l),i&&s&&e.index(r)==n.index(r)?(L(i,s),j(P(i,z(t,e,n,o,r+1)),l)):(i&&j(P(i,$(t,e,r+1)),l),I(e,n,r,l),s&&j(P(s,$(n,o,r+1)),l)),I(o,null,r,l),new k(l)}function $(t,e,n){let o=[];return I(null,t,n,o),t.depth>n&&j(P(R(t,e,n+1),$(t,e,n+1)),o),I(e,null,n,o),new k(o)}A.empty=new A(k.empty,0,0);class H{constructor(t,e,n){this.pos=t,this.path=e,this.parentOffset=n,this.depth=e.length/3-1}resolveDepth(t){return null==t?this.depth:t<0?this.depth+t:t}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(t){return this.path[3*this.resolveDepth(t)]}index(t){return this.path[3*this.resolveDepth(t)+1]}indexAfter(t){return t=this.resolveDepth(t),this.index(t)+(t!=this.depth||this.textOffset?1:0)}start(t){return 0==(t=this.resolveDepth(t))?0:this.path[3*t-1]+1}end(t){return t=this.resolveDepth(t),this.start(t)+this.node(t).content.size}before(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]}after(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}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let t=this.parent,e=this.index(this.depth);if(e==t.childCount)return null;let n=this.pos-this.path[this.path.length-1],o=t.child(e);return n?t.child(e).cut(n):o}get nodeBefore(){let 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)}posAtIndex(t,e){e=this.resolveDepth(e);let n=this.path[3*e],o=0==e?0:this.path[3*e-1]+1;for(let e=0;e<t;e++)o+=n.child(e).nodeSize;return o}marks(){let t=this.parent,e=this.index();if(0==t.content.size)return S.none;if(this.textOffset)return t.child(e).marks;let n=t.maybeChild(e-1),o=t.maybeChild(e);if(!n){let t=n;n=o,o=t}let r=n.marks;for(var i=0;i<r.length;i++)!1!==r[i].type.spec.inclusive||o&&r[i].isInSet(o.marks)||(r=r[i--].removeFromSet(r));return r}marksAcross(t){let e=this.parent.maybeChild(this.index());if(!e||!e.isInline)return null;let n=e.marks,o=t.parent.maybeChild(t.index());for(var r=0;r<n.length;r++)!1!==n[r].type.spec.inclusive||o&&n[r].isInSet(o.marks)||(n=n[r--].removeFromSet(n));return n}sharedDepth(t){for(let e=this.depth;e>0;e--)if(this.start(e)<=t&&this.end(e)>=t)return e;return 0}blockRange(t=this,e){if(t.pos<this.pos)return t.blockRange(this);for(let 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 F(this,t,n);return null}sameParent(t){return this.pos-this.parentOffset==t.pos-t.parentOffset}max(t){return t.pos>this.pos?t:this}min(t){return t.pos<this.pos?t:this}toString(){let t="";for(let e=1;e<=this.depth;e++)t+=(t?"/":"")+this.node(e).type.name+"_"+this.index(e-1);return t+":"+this.parentOffset}static resolve(t,e){if(!(e>=0&&e<=t.content.size))throw new RangeError("Position "+e+" out of range");let n=[],o=0,r=e;for(let e=t;;){let{index:t,offset:i}=e.content.findIndex(r),s=r-i;if(n.push(e,t,o+i),!s)break;if(e=e.child(t),e.isText)break;r=s-1,o+=i+1}return new H(e,n,r)}static resolveCached(t,e){let n=_.get(t);if(n)for(let t=0;t<n.elts.length;t++){let o=n.elts[t];if(o.pos==e)return o}else _.set(t,n=new B);let o=n.elts[n.i]=H.resolve(t,e);return n.i=(n.i+1)%V,o}}class B{constructor(){this.elts=[],this.i=0}}const V=12,_=new WeakMap;class F{constructor(t,e,n){this.$from=t,this.$to=e,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const W=Object.create(null);class q{constructor(t,e,n,o=S.none){this.type=t,this.attrs=e,this.marks=o,this.content=n||k.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(t){return this.content.child(t)}maybeChild(t){return this.content.maybeChild(t)}forEach(t){this.content.forEach(t)}nodesBetween(t,e,n,o=0){this.content.nodesBetween(t,e,n,o,this)}descendants(t){this.nodesBetween(0,this.content.size,t)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(t,e,n,o){return this.content.textBetween(t,e,n,o)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(t){return this==t||this.sameMarkup(t)&&this.content.eq(t.content)}sameMarkup(t){return this.hasMarkup(t.type,t.attrs,t.marks)}hasMarkup(t,e,n){return this.type==t&&C(this.attrs,e||t.defaultAttrs||W)&&S.sameSet(this.marks,n||S.none)}copy(t=null){return t==this.content?this:new q(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new q(this.type,this.attrs,this.content,t)}cut(t,e=this.content.size){return 0==t&&e==this.content.size?this:this.copy(this.content.cut(t,e))}slice(t,e=this.content.size,n=!1){if(t==e)return A.empty;let o=this.resolve(t),r=this.resolve(e),i=n?0:o.sharedDepth(e),s=o.start(i),l=o.node(i).content.cut(o.pos-s,r.pos-s);return new A(l,o.depth-i,r.depth-i)}replace(t,e,n){return N(this.resolve(t),this.resolve(e),n)}nodeAt(t){for(let e=this;;){let{index:n,offset:o}=e.content.findIndex(t);if(e=e.maybeChild(n),!e)return null;if(o==t||e.isText)return e;t-=o+1}}childAfter(t){let{index:e,offset:n}=this.content.findIndex(t);return{node:this.content.maybeChild(e),index:e,offset:n}}childBefore(t){if(0==t)return{node:null,index:0,offset:0};let{index:e,offset:n}=this.content.findIndex(t);if(n<t)return{node:this.content.child(e),index:e,offset:n};let o=this.content.child(e-1);return{node:o,index:e-1,offset:n-o.nodeSize}}resolve(t){return H.resolveCached(this,t)}resolveNoCache(t){return H.resolve(this,t)}rangeHasMark(t,e,n){let o=!1;return e>t&&this.nodesBetween(t,e,t=>(n.isInSet(t.marks)&&(o=!0),!o)),o}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let t=this.type.name;return this.content.size&&(t+="("+this.content.toStringInner()+")"),J(this.marks,t)}contentMatchAt(t){let e=this.type.contentMatch.matchFragment(this.content,0,t);if(!e)throw new Error("Called contentMatchAt on a node with invalid content");return e}canReplace(t,e,n=k.empty,o=0,r=n.childCount){let i=this.contentMatchAt(t).matchFragment(n,o,r),s=i&&i.matchFragment(this.content,e);if(!s||!s.validEnd)return!1;for(let t=o;t<r;t++)if(!this.type.allowsMarks(n.child(t).marks))return!1;return!0}canReplaceWith(t,e,n,o){if(o&&!this.type.allowsMarks(o))return!1;let r=this.contentMatchAt(t).matchType(n),i=r&&r.matchFragment(this.content,e);return!!i&&i.validEnd}canAppend(t){return t.content.size?this.canReplace(this.childCount,this.childCount,t.content):this.type.compatibleContent(t.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let t=S.none;for(let e=0;e<this.marks.length;e++){let n=this.marks[e];n.type.checkAttrs(n.attrs),t=n.addToSet(t)}if(!S.sameSet(t,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let t={type:this.type.name};for(let 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(t=>t.toJSON())),t}static fromJSON(t,e){if(!e)throw new RangeError("Invalid input for Node.fromJSON");let n;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)}let o=k.fromJSON(t,e.content),r=t.nodeType(e.type).create(e.attrs,o,n);return r.type.checkAttrs(r.attrs),r}}q.prototype.text=void 0;class K extends q{constructor(t,e,n,o){if(super(t,e,null,o),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):J(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(t,e){return this.text.slice(t,e)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new K(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new K(this.type,this.attrs,t,this.marks)}cut(t=0,e=this.text.length){return 0==t&&e==this.text.length?this:this.withText(this.text.slice(t,e))}eq(t){return this.sameMarkup(t)&&this.text==t.text}toJSON(){let t=super.toJSON();return t.text=this.text,t}}function J(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class U{constructor(t){this.validEnd=t,this.next=[],this.wrapCache=[]}static parse(t,e){let n=new G(t,e);if(null==n.next)return U.empty;let o=Y(n);n.next&&n.err("Unexpected trailing text");let r=function(t){let e=Object.create(null);return function n(o){let r=[];o.forEach(e=>{t[e].forEach(({term:e,to:n})=>{if(!e)return;let o;for(let t=0;t<r.length;t++)r[t][0]==e&&(o=r[t][1]);nt(t,n).forEach(t=>{o||r.push([e,o=[]]),-1==o.indexOf(t)&&o.push(t)})})});let i=e[o.join(",")]=new U(o.indexOf(t.length-1)>-1);for(let t=0;t<r.length;t++){let o=r[t][1].sort(et);i.next.push({type:r[t][0],next:e[o.join(",")]||n(o)})}return i}(nt(t,0))}(function(t){let e=[[]];return r(function t(e,i){if("choice"==e.type)return e.exprs.reduce((e,n)=>e.concat(t(n,i)),[]);if("seq"!=e.type){if("star"==e.type){let s=n();return o(i,s),r(t(e.expr,s),s),[o(s)]}if("plus"==e.type){let s=n();return r(t(e.expr,i),s),r(t(e.expr,s),s),[o(s)]}if("opt"==e.type)return[o(i)].concat(t(e.expr,i));if("range"==e.type){let s=i;for(let o=0;o<e.min;o++){let o=n();r(t(e.expr,s),o),s=o}if(-1==e.max)r(t(e.expr,s),s);else for(let i=e.min;i<e.max;i++){let i=n();o(s,i),r(t(e.expr,s),i),s=i}return[o(s)]}if("name"==e.type)return[o(i,void 0,e.value)];throw new Error("Unknown expr type")}for(let o=0;;o++){let s=t(e.exprs[o],i);if(o==e.exprs.length-1)return s;r(s,i=n())}}(t,0),n()),e;function n(){return e.push([])-1}function o(t,n,o){let r={term:o,to:n};return e[t].push(r),r}function r(t,e){t.forEach(t=>t.to=e)}}(o));return function(t,e){for(let n=0,o=[t];n<o.length;n++){let t=o[n],r=!t.validEnd,i=[];for(let e=0;e<t.next.length;e++){let{type:n,next:s}=t.next[e];i.push(n.name),!r||n.isText||n.hasRequiredAttrs()||(r=!1),-1==o.indexOf(s)&&o.push(s)}r&&e.err("Only non-generatable nodes ("+i.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(r,n),r}matchType(t){for(let e=0;e<this.next.length;e++)if(this.next[e].type==t)return this.next[e].next;return null}matchFragment(t,e=0,n=t.childCount){let o=this;for(let r=e;o&&r<n;r++)o=o.matchType(t.child(r).type);return o}get inlineContent(){return 0!=this.next.length&&this.next[0].type.isInline}get defaultType(){for(let t=0;t<this.next.length;t++){let{type:e}=this.next[t];if(!e.isText&&!e.hasRequiredAttrs())return e}return null}compatible(t){for(let e=0;e<this.next.length;e++)for(let n=0;n<t.next.length;n++)if(this.next[e].type==t.next[n].type)return!0;return!1}fillBefore(t,e=!1,n=0){let o=[this];return function r(i,s){let l=i.matchFragment(t,n);if(l&&(!e||l.validEnd))return k.from(s.map(t=>t.createAndFill()));for(let t=0;t<i.next.length;t++){let{type:e,next:n}=i.next[t];if(!e.isText&&!e.hasRequiredAttrs()&&-1==o.indexOf(n)){o.push(n);let t=r(n,s.concat(e));if(t)return t}}return null}(this,[])}findWrapping(t){for(let e=0;e<this.wrapCache.length;e+=2)if(this.wrapCache[e]==t)return this.wrapCache[e+1];let e=this.computeWrapping(t);return this.wrapCache.push(t,e),e}computeWrapping(t){let e=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let o=n.shift(),r=o.match;if(r.matchType(t)){let t=[];for(let e=o;e.type;e=e.via)t.push(e.type);return t.reverse()}for(let t=0;t<r.next.length;t++){let{type:i,next:s}=r.next[t];i.isLeaf||i.hasRequiredAttrs()||i.name in e||o.type&&!s.validEnd||(n.push({match:i.contentMatch,type:i,via:o}),e[i.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(t){if(t>=this.next.length)throw new RangeError(`There's no ${t}th edge in this content match`);return this.next[t]}toString(){let t=[];return function e(n){t.push(n);for(let o=0;o<n.next.length;o++)-1==t.indexOf(n.next[o].next)&&e(n.next[o].next)}(this),t.map((e,n)=>{let o=n+(e.validEnd?"*":" ")+" ";for(let n=0;n<e.next.length;n++)o+=(n?", ":"")+e.next[n].type.name+"->"+t.indexOf(e.next[n].next);return o}).join("\n")}}U.empty=new U(!0);class G{constructor(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()}get next(){return this.tokens[this.pos]}eat(t){return this.next==t&&(this.pos++||!0)}err(t){throw new SyntaxError(t+" (in content expression '"+this.string+"')")}}function Y(t){let e=[];do{e.push(X(t))}while(t.eat("|"));return 1==e.length?e[0]:{type:"choice",exprs:e}}function X(t){let e=[];do{e.push(Q(t))}while(t.next&&")"!=t.next&&"|"!=t.next);return 1==e.length?e[0]:{type:"seq",exprs:e}}function Q(t){let e=function(t){if(t.eat("(")){let e=Y(t);return t.eat(")")||t.err("Missing closing paren"),e}if(!/\W/.test(t.next)){let e=function(t,e){let n=t.nodeTypes,o=n[e];if(o)return[o];let r=[];for(let t in n){let o=n[t];o.isInGroup(e)&&r.push(o)}return 0==r.length&&t.err("No node type or group '"+e+"' found"),r}(t,t.next).map(e=>(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==e.length?e[0]:{type:"choice",exprs:e}}t.err("Unexpected token '"+t.next+"'")}(t);for(;;)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=tt(t,e)}return e}function Z(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function tt(t,e){let n=Z(t),o=n;return t.eat(",")&&(o="}"!=t.next?Z(t):-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:o,expr:e}}function et(t,e){return e-t}function nt(t,e){let n=[];return function e(o){let r=t[o];if(1==r.length&&!r[0].term)return e(r[0].to);n.push(o);for(let t=0;t<r.length;t++){let{term:o,to:i}=r[t];o||-1!=n.indexOf(i)||e(i)}}(e),n.sort(et)}function ot(t){let e=Object.create(null);for(let n in t){let o=t[n];if(!o.hasDefault)return null;e[n]=o.default}return e}function rt(t,e){let n=Object.create(null);for(let o in t){let r=e&&e[o];if(void 0===r){let e=t[o];if(!e.hasDefault)throw new RangeError("No value supplied for attribute "+o);r=e.default}n[o]=r}return n}function it(t,e,n,o){for(let o in e)if(!(o in t))throw new RangeError(`Unsupported attribute ${o} for ${n} of type ${o}`);for(let n in t){let o=t[n];o.validate&&o.validate(e[n])}}function st(t,e){let n=Object.create(null);if(e)for(let o in e)n[o]=new at(t,o,e[o]);return n}class lt{constructor(t,e,n){this.name=t,this.schema=e,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(" "):[],this.attrs=st(t,n.attrs),this.defaultAttrs=ot(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||"text"==t),this.isText="text"==t}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==U.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(t){return this.groups.indexOf(t)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let t in this.attrs)if(this.attrs[t].isRequired)return!0;return!1}compatibleContent(t){return this==t||this.contentMatch.compatible(t.contentMatch)}computeAttrs(t){return!t&&this.defaultAttrs?this.defaultAttrs:rt(this.attrs,t)}create(t=null,e,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new q(this,this.computeAttrs(t),k.from(e),S.setFrom(n))}createChecked(t=null,e,n){return e=k.from(e),this.checkContent(e),new q(this,this.computeAttrs(t),e,S.setFrom(n))}createAndFill(t=null,e,n){if(t=this.computeAttrs(t),(e=k.from(e)).size){let t=this.contentMatch.fillBefore(e);if(!t)return null;e=t.append(e)}let o=this.contentMatch.matchFragment(e),r=o&&o.fillBefore(k.empty,!0);return r?new q(this,t,e.append(r),S.setFrom(n)):null}validContent(t){let e=this.contentMatch.matchFragment(t);if(!e||!e.validEnd)return!1;for(let e=0;e<t.childCount;e++)if(!this.allowsMarks(t.child(e).marks))return!1;return!0}checkContent(t){if(!this.validContent(t))throw new RangeError(`Invalid content for node ${this.name}: ${t.toString().slice(0,50)}`)}checkAttrs(t){it(this.attrs,t,"node",this.name)}allowsMarkType(t){return null==this.markSet||this.markSet.indexOf(t)>-1}allowsMarks(t){if(null==this.markSet)return!0;for(let e=0;e<t.length;e++)if(!this.allowsMarkType(t[e].type))return!1;return!0}allowedMarks(t){if(null==this.markSet)return t;let e;for(let 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:S.none:t}static compile(t,e){let n=Object.create(null);t.forEach((t,o)=>n[t]=new lt(t,e,o));let o=e.spec.topNode||"doc";if(!n[o])throw new RangeError("Schema is missing its top node type ('"+o+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(let t in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n}}class at{constructor(t,e,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate="string"==typeof n.validate?function(t,e,n){let o=n.split("|");return n=>{let r=null===n?"null":typeof n;if(o.indexOf(r)<0)throw new RangeError(`Expected value of type ${o} for attribute ${e} on type ${t}, got ${r}`)}}(t,e,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class ct{constructor(t,e,n,o){this.name=t,this.rank=e,this.schema=n,this.spec=o,this.attrs=st(t,o.attrs),this.excluded=null;let r=ot(this.attrs);this.instance=r?new S(this,r):null}create(t=null){return!t&&this.instance?this.instance:new S(this,rt(this.attrs,t))}static compile(t,e){let n=Object.create(null),o=0;return t.forEach((t,r)=>n[t]=new ct(t,o++,e,r)),n}removeFromSet(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}isInSet(t){for(let e=0;e<t.length;e++)if(t[e].type==this)return t[e]}checkAttrs(t){it(this.attrs,t,"mark",this.name)}excludes(t){return this.excluded.indexOf(t)>-1}}class dt{constructor(t){this.linebreakReplacement=null,this.cached=Object.create(null);let e=this.spec={};for(let n in t)e[n]=t[n];e.nodes=b.from(t.nodes),e.marks=b.from(t.marks||{}),this.nodes=lt.compile(this.spec.nodes,this),this.marks=ct.compile(this.spec.marks,this);let n=Object.create(null);for(let t in this.nodes){if(t in this.marks)throw new RangeError(t+" can not be both a node and a mark");let e=this.nodes[t],o=e.spec.content||"",r=e.spec.marks;if(e.contentMatch=n[o]||(n[o]=U.parse(o,this.nodes)),e.inlineContent=e.contentMatch.inlineContent,e.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!e.isInline||!e.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=e}e.markSet="_"==r?null:r?ht(this,r.split(" ")):""!=r&&e.inlineContent?null:[]}for(let t in this.marks){let e=this.marks[t],n=e.spec.excludes;e.excluded=null==n?[e]:""==n?[]:ht(this,n.split(" "))}this.nodeFromJSON=t=>q.fromJSON(this,t),this.markFromJSON=t=>S.fromJSON(this,t),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(t,e=null,n,o){if("string"==typeof t)t=this.nodeType(t);else{if(!(t instanceof lt))throw new RangeError("Invalid node type: "+t);if(t.schema!=this)throw new RangeError("Node type from different schema used ("+t.name+")")}return t.createChecked(e,n,o)}text(t,e){let n=this.nodes.text;return new K(n,n.defaultAttrs,t,S.setFrom(e))}mark(t,e){return"string"==typeof t&&(t=this.marks[t]),t.create(e)}nodeType(t){let e=this.nodes[t];if(!e)throw new RangeError("Unknown node type: "+t);return e}}function ht(t,e){let n=[];for(let o=0;o<e.length;o++){let r=e[o],i=t.marks[r],s=i;if(i)n.push(i);else for(let e in t.marks){let o=t.marks[e];("_"==r||o.spec.group&&o.spec.group.split(" ").indexOf(r)>-1)&&n.push(s=o)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[o]+"'")}return n}class pt{constructor(t,e){this.schema=t,this.rules=e,this.tags=[],this.styles=[];let n=this.matchedStyles=[];e.forEach(t=>{if(function(t){return null!=t.tag}(t))this.tags.push(t);else if(function(t){return null!=t.style}(t)){let e=/[^=]*/.exec(t.style)[0];n.indexOf(e)<0&&n.push(e),this.styles.push(t)}}),this.normalizeLists=!this.tags.some(e=>{if(!/^(ul|ol)\b/.test(e.tag)||!e.node)return!1;let n=t.nodes[e.node];return n.contentMatch.matchType(n)})}parse(t,e={}){let n=new bt(this,e,!1);return n.addAll(t,S.none,e.from,e.to),n.finish()}parseSlice(t,e={}){let n=new bt(this,e,!0);return n.addAll(t,S.none,e.from,e.to),A.maxOpen(n.finish())}matchTag(t,e,n){for(let o=n?this.tags.indexOf(n)+1:0;o<this.tags.length;o++){let n=this.tags[o];if(vt(t,n.tag)&&(void 0===n.namespace||t.namespaceURI==n.namespace)&&(!n.context||e.matchesContext(n.context))){if(n.getAttrs){let e=n.getAttrs(t);if(!1===e)continue;n.attrs=e||void 0}return n}}}matchStyle(t,e,n,o){for(let r=o?this.styles.indexOf(o)+1:0;r<this.styles.length;r++){let o=this.styles[r],i=o.style;if(!(0!=i.indexOf(t)||o.context&&!n.matchesContext(o.context)||i.length>t.length&&(61!=i.charCodeAt(t.length)||i.slice(t.length+1)!=e))){if(o.getAttrs){let t=o.getAttrs(e);if(!1===t)continue;o.attrs=t||void 0}return o}}}static schemaRules(t){let e=[];function n(t){let n=null==t.priority?50:t.priority,o=0;for(;o<e.length;o++){let t=e[o];if((null==t.priority?50:t.priority)<n)break}e.splice(o,0,t)}for(let e in t.marks){let o=t.marks[e].spec.parseDOM;o&&o.forEach(t=>{n(t=wt(t)),t.mark||t.ignore||t.clearMark||(t.mark=e)})}for(let e in t.nodes){let o=t.nodes[e].spec.parseDOM;o&&o.forEach(t=>{n(t=wt(t)),t.node||t.ignore||t.mark||(t.node=e)})}return e}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new pt(t,pt.schemaRules(t)))}}const ut={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},ft={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},mt={ol:!0,ul:!0};function gt(t,e,n){return null!=e?(e?1:0)|("full"===e?2:0):t&&"pre"==t.whitespace?3:-5&n}class yt{constructor(t,e,n,o,r,i){this.type=t,this.attrs=e,this.marks=n,this.solid=o,this.options=i,this.content=[],this.activeMarks=S.none,this.match=r||(4&i?null:t.contentMatch)}findWrapping(t){if(!this.match){if(!this.type)return[];let e=this.type.contentMatch.fillBefore(k.from(t));if(!e){let e,n=this.type.contentMatch;return(e=n.findWrapping(t.type))?(this.match=n,e):null}this.match=this.type.contentMatch.matchFragment(e)}return this.match.findWrapping(t.type)}finish(t){if(!(1&this.options)){let t,e=this.content[this.content.length-1];if(e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))){let n=e;e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-t[0].length))}}let e=k.from(this.content);return!t&&this.match&&(e=e.append(this.match.fillBefore(k.empty,!0))),this.type?this.type.create(this.attrs,e,this.marks):e}inlineContext(t){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:t.parentNode&&!ut.hasOwnProperty(t.parentNode.nodeName.toLowerCase())}}class bt{constructor(t,e,n){this.parser=t,this.options=e,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let o,r=e.topNode,i=gt(null,e.preserveWhitespace,0)|(n?4:0);o=r?new yt(r.type,r.attrs,S.none,!0,e.topMatch||r.type.contentMatch,i):new yt(n?null:t.schema.topNodeType,null,S.none,!0,null,i),this.nodes=[o],this.find=e.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(t,e){3==t.nodeType?this.addTextNode(t,e):1==t.nodeType&&this.addElement(t,e)}addTextNode(t,e){let n=t.nodeValue,o=this.top,r=2&o.options?"full":this.localPreserveWS||(1&o.options)>0;if("full"===r||o.inlineContext(t)||/[^ \t\r\n\u000c]/.test(n)){if(r)n="full"!==r?n.replace(/\r?\n|\r/g," "):n.replace(/\r\n?/g,"\n");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let e=o.content[o.content.length-1],r=t.previousSibling;(!e||r&&"BR"==r.nodeName||e.isText&&/[ \t\r\n\u000c]$/.test(e.text))&&(n=n.slice(1))}n&&this.insertNode(this.parser.schema.text(n),e,!/\S/.test(n)),this.findInText(t)}else this.findInside(t)}addElement(t,e,n){let o=this.localPreserveWS,r=this.top;("PRE"==t.tagName||/pre/.test(t.style&&t.style.whiteSpace))&&(this.localPreserveWS=!0);let i,s=t.nodeName.toLowerCase();mt.hasOwnProperty(s)&&this.parser.normalizeLists&&function(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let t=1==e.nodeType?e.nodeName.toLowerCase():null;t&&mt.hasOwnProperty(t)&&n?(n.appendChild(e),e=n):"li"==t?n=e:t&&(n=null)}}(t);let l=this.options.ruleFromNode&&this.options.ruleFromNode(t)||(i=this.parser.matchTag(t,this,n));t:if(l?l.ignore:ft.hasOwnProperty(s))this.findInside(t),this.ignoreFallback(t,e);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(t=l.skip);let n,o=this.needsBlock;if(ut.hasOwnProperty(s))r.content.length&&r.content[0].isInline&&this.open&&(this.open--,r=this.top),n=!0,r.type||(this.needsBlock=!0);else if(!t.firstChild){this.leafFallback(t,e);break t}let i=l&&l.skip?e:this.readStyles(t,e);i&&this.addAll(t,i),n&&this.sync(r),this.needsBlock=o}else{let n=this.readStyles(t,e);n&&this.addElementByRule(t,l,n,!1===l.consuming?i:void 0)}this.localPreserveWS=o}leafFallback(t,e){"BR"==t.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(t.ownerDocument.createTextNode("\n"),e)}ignoreFallback(t,e){"BR"!=t.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"),e,!0)}readStyles(t,e){let n=t.style;if(n&&n.length)for(let t=0;t<this.parser.matchedStyles.length;t++){let o=this.parser.matchedStyles[t],r=n.getPropertyValue(o);if(r)for(let t;;){let n=this.parser.matchStyle(o,r,this,t);if(!n)break;if(n.ignore)return null;if(e=n.clearMark?e.filter(t=>!n.clearMark(t)):e.concat(this.parser.schema.marks[n.mark].create(n.attrs)),!1!==n.consuming)break;t=n}}return e}addElementByRule(t,e,n,o){let r,i;if(e.node)if(i=this.parser.schema.nodes[e.node],i.isLeaf)this.insertNode(i.create(e.attrs),n,"BR"==t.nodeName)||this.leafFallback(t,n);else{let t=this.enter(i,e.attrs||null,n,e.preserveWhitespace);t&&(r=!0,n=t)}else{let t=this.parser.schema.marks[e.mark];n=n.concat(t.create(e.attrs))}let s=this.top;if(i&&i.isLeaf)this.findInside(t);else if(o)this.addElement(t,n,o);else if(e.getContent)this.findInside(t),e.getContent(t,this.parser.schema).forEach(t=>this.insertNode(t,n,!1));else{let o=t;"string"==typeof e.contentElement?o=t.querySelector(e.contentElement):"function"==typeof e.contentElement?o=e.contentElement(t):e.contentElement&&(o=e.contentElement),this.findAround(t,o,!0),this.addAll(o,n),this.findAround(t,o,!1)}r&&this.sync(s)&&this.open--}addAll(t,e,n,o){let r=n||0;for(let i=n?t.childNodes[n]:t.firstChild,s=null==o?null:t.childNodes[o];i!=s;i=i.nextSibling,++r)this.findAtPoint(t,r),this.addDOM(i,e);this.findAtPoint(t,r)}findPlace(t,e,n){let o,r;for(let e=this.open,i=0;e>=0;e--){let s=this.nodes[e],l=s.findWrapping(t);if(l&&(!o||o.length>l.length+i)&&(o=l,r=s,!l.length))break;if(s.solid){if(n)break;i+=2}}if(!o)return null;this.sync(r);for(let t=0;t<o.length;t++)e=this.enterInner(o[t],null,e,!1);return e}insertNode(t,e,n){if(t.isInline&&this.needsBlock&&!this.top.type){let t=this.textblockFromContext();t&&(e=this.enterInner(t,null,e))}let o=this.findPlace(t,e,n);if(o){this.closeExtra();let e=this.top;e.match&&(e.match=e.match.matchType(t.type));let n=S.none;for(let r of o.concat(t.marks))(e.type?e.type.allowsMarkType(r.type):kt(r.type,t.type))&&(n=r.addToSet(n));return e.content.push(t.mark(n)),!0}return!1}enter(t,e,n,o){let r=this.findPlace(t.create(e),n,!1);return r&&(r=this.enterInner(t,e,n,!0,o)),r}enterInner(t,e,n,o=!1,r){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(t);let s=gt(t,r,i.options);4&i.options&&0==i.content.length&&(s|=4);let l=S.none;return n=n.filter(e=>!(i.type?i.type.allowsMarkType(e.type):kt(e.type,t))||(l=e.addToSet(l),!1)),this.nodes.push(new yt(t,e,l,o,null,s)),this.open++,n}closeExtra(t=!1){let 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}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!(!this.isOpen&&!this.options.topOpen))}sync(t){for(let e=this.open;e>=0;e--){if(this.nodes[e]==t)return this.open=e,!0;this.localPreserveWS&&(this.nodes[e].options|=1)}return!1}get currentPos(){this.closeExtra();let t=0;for(let e=this.open;e>=0;e--){let n=this.nodes[e].content;for(let e=n.length-1;e>=0;e--)t+=n[e].nodeSize;e&&t++}return t}findAtPoint(t,e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==t&&this.find[n].offset==e&&(this.find[n].pos=this.currentPos)}findInside(t){if(this.find)for(let 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)}findAround(t,e,n){if(t!=e&&this.find)for(let o=0;o<this.find.length;o++)null==this.find[o].pos&&1==t.nodeType&&t.contains(this.find[o].node)&&e.compareDocumentPosition(this.find[o].node)&(n?2:4)&&(this.find[o].pos=this.currentPos)}findInText(t){if(this.find)for(let 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))}matchesContext(t){if(t.indexOf("|")>-1)return t.split(/\s*\|\s*/).some(this.matchesContext,this);let e=t.split("/"),n=this.options.context,o=!(this.isOpen||n&&n.parent.type!=this.nodes[0].type),r=-(n?n.depth+1:0)+(o?0:1),i=(t,s)=>{for(;t>=0;t--){let l=e[t];if(""==l){if(t==e.length-1||0==t)continue;for(;s>=r;s--)if(i(t-1,s))return!0;return!1}{let t=s>0||0==s&&o?this.nodes[s].type:n&&s>=r?n.node(s-r).type:null;if(!t||t.name!=l&&!t.isInGroup(l))return!1;s--}}return!0};return i(e.length-1,this.open)}textblockFromContext(){let t=this.options.context;if(t)for(let e=t.depth;e>=0;e--){let n=t.node(e).contentMatchAt(t.indexAfter(e)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let t in this.parser.schema.nodes){let e=this.parser.schema.nodes[t];if(e.isTextblock&&e.defaultAttrs)return e}}}function vt(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function wt(t){let e={};for(let n in t)e[n]=t[n];return e}function kt(t,e){let n=e.schema.nodes;for(let o in n){let r=n[o];if(!r.allowsMarkType(t))continue;let i=[],s=t=>{i.push(t);for(let n=0;n<t.edgeCount;n++){let{type:o,next:r}=t.edge(n);if(o==e)return!0;if(i.indexOf(r)<0&&s(r))return!0}};if(s(r.contentMatch))return!0}}class xt{constructor(t,e){this.nodes=t,this.marks=e}serializeFragment(t,e={},n){n||(n=Ct(e).createDocumentFragment());let o=n,r=[];return t.forEach(t=>{if(r.length||t.marks.length){let n=0,i=0;for(;n<r.length&&i<t.marks.length;){let e=t.marks[i];if(this.marks[e.type.name]){if(!e.eq(r[n][0])||!1===e.type.spec.spanning)break;n++,i++}else i++}for(;n<r.length;)o=r.pop()[1];for(;i<t.marks.length;){let n=t.marks[i++],s=this.serializeMark(n,t.isInline,e);s&&(r.push([n,o]),o.appendChild(s.dom),o=s.contentDOM||s.dom)}}o.appendChild(this.serializeNodeInner(t,e))}),n}serializeNodeInner(t,e){let{dom:n,contentDOM:o}=Tt(Ct(e),this.nodes[t.type.name](t),null,t.attrs);if(o){if(t.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(t.content,e,o)}return n}serializeNode(t,e={}){let n=this.serializeNodeInner(t,e);for(let o=t.marks.length-1;o>=0;o--){let r=this.serializeMark(t.marks[o],t.isInline,e);r&&((r.contentDOM||r.dom).appendChild(n),n=r.dom)}return n}serializeMark(t,e,n={}){let o=this.marks[t.type.name];return o&&Tt(Ct(n),o(t,e),null,t.attrs)}static renderSpec(t,e,n=null,o){return Tt(t,e,n,o)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new xt(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(t){let e=Mt(t.nodes);return e.text||(e.text=t=>t.text),e}static marksFromSchema(t){return Mt(t.marks)}}function Mt(t){let e={};for(let n in t){let o=t[n].spec.toDOM;o&&(e[n]=o)}return e}function Ct(t){return t.document||window.document}const St=new WeakMap;function Tt(t,e,n,o){if("string"==typeof e)return{dom:t.createTextNode(e)};if(null!=e.nodeType)return{dom:e};if(e.dom&&null!=e.dom.nodeType)return e;let r,i=e[0];if("string"!=typeof i)throw new RangeError("Invalid array passed to renderSpec");if(o&&(r=function(t){let e=St.get(t);return void 0===e&&St.set(t,e=function(t){let e=null;return function t(n){if(n&&"object"==typeof n)if(Array.isArray(n))if("string"==typeof n[0])e||(e=[]),e.push(n);else for(let e=0;e<n.length;e++)t(n[e]);else for(let e in n)t(n[e])}(t),e}(t)),e}(o))&&r.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let s,l=i.indexOf(" ");l>0&&(n=i.slice(0,l),i=i.slice(l+1));let a=n?t.createElementNS(n,i):t.createElement(i),c=e[1],d=1;if(c&&"object"==typeof c&&null==c.nodeType&&!Array.isArray(c)){d=2;for(let t in c)if(null!=c[t]){let e=t.indexOf(" ");e>0?a.setAttributeNS(t.slice(0,e),t.slice(e+1),c[t]):"style"==t&&a.style?a.style.cssText=c[t]:a.setAttribute(t,c[t])}}for(let r=d;r<e.length;r++){let i=e[r];if(0===i){if(r<e.length-1||r>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}{let{dom:e,contentDOM:r}=Tt(t,i,n,o);if(a.appendChild(e),r){if(s)throw new RangeError("Multiple content holes");s=r}}}return{dom:a,contentDOM:s}}const At=Math.pow(2,16);function Et(t,e){return t+e*At}function Ot(t){return 65535&t}class Nt{constructor(t,e,n){this.pos=t,this.delInfo=e,this.recover=n}get deleted(){return(8&this.delInfo)>0}get deletedBefore(){return(5&this.delInfo)>0}get deletedAfter(){return(6&this.delInfo)>0}get deletedAcross(){return(4&this.delInfo)>0}}class Dt{constructor(t,e=!1){if(this.ranges=t,this.inverted=e,!t.length&&Dt.empty)return Dt.empty}recover(t){let e=0,n=Ot(t);if(!this.inverted)for(let t=0;t<n;t++)e+=this.ranges[3*t+2]-this.ranges[3*t+1];return this.ranges[3*n]+e+function(t){return(t-(65535&t))/At}(t)}mapResult(t,e=1){return this._map(t,e,!1)}map(t,e=1){return this._map(t,e,!0)}_map(t,e,n){let o=0,r=this.inverted?2:1,i=this.inverted?1:2;for(let s=0;s<this.ranges.length;s+=3){let l=this.ranges[s]-(this.inverted?o:0);if(l>t)break;let a=this.ranges[s+r],c=this.ranges[s+i],d=l+a;if(t<=d){let r=l+o+((a?t==l?-1:t==d?1:e:e)<0?0:c);if(n)return r;let i=t==(e<0?l:d)?null:Et(s/3,t-l),h=t==l?2:t==d?1:4;return(e<0?t!=l:t!=d)&&(h|=8),new Nt(r,h,i)}o+=c-a}return n?t+o:new Nt(t+o,0,null)}touches(t,e){let n=0,o=Ot(e),r=this.inverted?2:1,i=this.inverted?1:2;for(let e=0;e<this.ranges.length;e+=3){let s=this.ranges[e]-(this.inverted?n:0);if(s>t)break;let l=this.ranges[e+r];if(t<=s+l&&e==3*o)return!0;n+=this.ranges[e+i]-l}return!1}forEach(t){let e=this.inverted?2:1,n=this.inverted?1:2;for(let o=0,r=0;o<this.ranges.length;o+=3){let i=this.ranges[o],s=i-(this.inverted?r:0),l=i+(this.inverted?0:r),a=this.ranges[o+e],c=this.ranges[o+n];t(s,s+a,l,l+c),r+=c-a}}invert(){return new Dt(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(t){return 0==t?Dt.empty:new Dt(t<0?[0,-t,0]:[0,0,t])}}Dt.empty=new Dt([]);class Lt{constructor(t,e,n=0,o=(t?t.length:0)){this.mirror=e,this.from=n,this.to=o,this._maps=t||[],this.ownData=!(t||e)}get maps(){return this._maps}slice(t=0,e=this.maps.length){return new Lt(this._maps,this.mirror,t,e)}appendMap(t,e){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(t),null!=e&&this.setMirror(this._maps.length-1,e)}appendMapping(t){for(let e=0,n=this._maps.length;e<t._maps.length;e++){let o=t.getMirror(e);this.appendMap(t._maps[e],null!=o&&o<e?n+o:void 0)}}getMirror(t){if(this.mirror)for(let e=0;e<this.mirror.length;e++)if(this.mirror[e]==t)return this.mirror[e+(e%2?-1:1)]}setMirror(t,e){this.mirror||(this.mirror=[]),this.mirror.push(t,e)}appendMappingInverted(t){for(let e=t.maps.length-1,n=this._maps.length+t._maps.length;e>=0;e--){let o=t.getMirror(e);this.appendMap(t._maps[e].invert(),null!=o&&o>e?n-o-1:void 0)}}invert(){let t=new Lt;return t.appendMappingInverted(this),t}map(t,e=1){if(this.mirror)return this._map(t,e,!0);for(let n=this.from;n<this.to;n++)t=this._maps[n].map(t,e);return t}mapResult(t,e=1){return this._map(t,e,!1)}_map(t,e,n){let o=0;for(let n=this.from;n<this.to;n++){let r=this._maps[n].mapResult(t,e);if(null!=r.recover){let e=this.getMirror(n);if(null!=e&&e>n&&e<this.to){n=e,t=this._maps[e].recover(r.recover);continue}}o|=r.delInfo,t=r.pos}return n?t:new Nt(t,o,null)}}const Rt=Object.create(null);class jt{getMap(){return Dt.empty}merge(t){return null}static fromJSON(t,e){if(!e||!e.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=Rt[e.stepType];if(!n)throw new RangeError(`No step type ${e.stepType} defined`);return n.fromJSON(t,e)}static jsonID(t,e){if(t in Rt)throw new RangeError("Duplicate use of step JSON ID "+t);return Rt[t]=e,e.prototype.jsonID=t,e}}class It{constructor(t,e){this.doc=t,this.failed=e}static ok(t){return new It(t,null)}static fail(t){return new It(null,t)}static fromReplace(t,e,n,o){try{return It.ok(t.replace(e,n,o))}catch(t){if(t instanceof T)return It.fail(t.message);throw t}}}function Pt(t,e,n){let o=[];for(let r=0;r<t.childCount;r++){let i=t.child(r);i.content.size&&(i=i.copy(Pt(i.content,e,i))),i.isInline&&(i=e(i,n,r)),o.push(i)}return k.fromArray(o)}class zt extends jt{constructor(t,e,n){super(),this.from=t,this.to=e,this.mark=n}apply(t){let e=t.slice(this.from,this.to),n=t.resolve(this.from),o=n.node(n.sharedDepth(this.to)),r=new A(Pt(e.content,(t,e)=>t.isAtom&&e.type.allowsMarkType(this.mark.type)?t.mark(this.mark.addToSet(t.marks)):t,o),e.openStart,e.openEnd);return It.fromReplace(t,this.from,this.to,r)}invert(){return new $t(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),n=t.mapResult(this.to,-1);return e.deleted&&n.deleted||e.pos>=n.pos?null:new zt(e.pos,n.pos,this.mark)}merge(t){return t instanceof zt&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new zt(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,e){if("number"!=typeof e.from||"number"!=typeof e.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new zt(e.from,e.to,t.markFromJSON(e.mark))}}jt.jsonID("addMark",zt);class $t extends jt{constructor(t,e,n){super(),this.from=t,this.to=e,this.mark=n}apply(t){let e=t.slice(this.from,this.to),n=new A(Pt(e.content,t=>t.mark(this.mark.removeFromSet(t.marks)),t),e.openStart,e.openEnd);return It.fromReplace(t,this.from,this.to,n)}invert(){return new zt(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),n=t.mapResult(this.to,-1);return e.deleted&&n.deleted||e.pos>=n.pos?null:new $t(e.pos,n.pos,this.mark)}merge(t){return t instanceof $t&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new $t(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,e){if("number"!=typeof e.from||"number"!=typeof e.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new $t(e.from,e.to,t.markFromJSON(e.mark))}}jt.jsonID("removeMark",$t);class Ht extends jt{constructor(t,e){super(),this.pos=t,this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return It.fail("No node at mark step's position");let n=e.type.create(e.attrs,null,this.mark.addToSet(e.marks));return It.fromReplace(t,this.pos,this.pos+1,new A(k.from(n),0,e.isLeaf?0:1))}invert(t){let e=t.nodeAt(this.pos);if(e){let t=this.mark.addToSet(e.marks);if(t.length==e.marks.length){for(let n=0;n<e.marks.length;n++)if(!e.marks[n].isInSet(t))return new Ht(this.pos,e.marks[n]);return new Ht(this.pos,this.mark)}}return new Bt(this.pos,this.mark)}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new Ht(e.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,e){if("number"!=typeof e.pos)throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Ht(e.pos,t.markFromJSON(e.mark))}}jt.jsonID("addNodeMark",Ht);class Bt extends jt{constructor(t,e){super(),this.pos=t,this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return It.fail("No node at mark step's position");let n=e.type.create(e.attrs,null,this.mark.removeFromSet(e.marks));return It.fromReplace(t,this.pos,this.pos+1,new A(k.from(n),0,e.isLeaf?0:1))}invert(t){let e=t.nodeAt(this.pos);return e&&this.mark.isInSet(e.marks)?new Ht(this.pos,this.mark):this}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new Bt(e.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,e){if("number"!=typeof e.pos)throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Bt(e.pos,t.markFromJSON(e.mark))}}jt.jsonID("removeNodeMark",Bt);class Vt extends jt{constructor(t,e,n,o=!1){super(),this.from=t,this.to=e,this.slice=n,this.structure=o}apply(t){return this.structure&&Ft(t,this.from,this.to)?It.fail("Structure replace would overwrite content"):It.fromReplace(t,this.from,this.to,this.slice)}getMap(){return new Dt([this.from,this.to-this.from,this.slice.size])}invert(t){return new Vt(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let e=t.mapResult(this.from,1),n=t.mapResult(this.to,-1);return e.deletedAcross&&n.deletedAcross?null:new Vt(e.pos,Math.max(e.pos,n.pos),this.slice,this.structure)}merge(t){if(!(t instanceof Vt)||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;{let e=this.slice.size+t.slice.size==0?A.empty:new A(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new Vt(t.from,this.to,e,this.structure)}}{let e=this.slice.size+t.slice.size==0?A.empty:new A(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new Vt(this.from,this.to+(t.to-t.from),e,this.structure)}}toJSON(){let t={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,e){if("number"!=typeof e.from||"number"!=typeof e.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Vt(e.from,e.to,A.fromJSON(t,e.slice),!!e.structure)}}jt.jsonID("replace",Vt);class _t extends jt{constructor(t,e,n,o,r,i,s=!1){super(),this.from=t,this.to=e,this.gapFrom=n,this.gapTo=o,this.slice=r,this.insert=i,this.structure=s}apply(t){if(this.structure&&(Ft(t,this.from,this.gapFrom)||Ft(t,this.gapTo,this.to)))return It.fail("Structure gap-replace would overwrite content");let e=t.slice(this.gapFrom,this.gapTo);if(e.openStart||e.openEnd)return It.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,e.content);return n?It.fromReplace(t,this.from,this.to,n):It.fail("Content does not fit in gap")}getMap(){return new Dt([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let e=this.gapTo-this.gapFrom;return new _t(this.from,this.from+this.slice.size+e,this.from+this.insert,this.from+this.insert+e,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let e=t.mapResult(this.from,1),n=t.mapResult(this.to,-1),o=this.from==this.gapFrom?e.pos:t.map(this.gapFrom,-1),r=this.to==this.gapTo?n.pos:t.map(this.gapTo,1);return e.deletedAcross&&n.deletedAcross||o<e.pos||r>n.pos?null:new _t(e.pos,n.pos,o,r,this.slice,this.insert,this.structure)}toJSON(){let 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}static fromJSON(t,e){if("number"!=typeof e.from||"number"!=typeof e.to||"number"!=typeof e.gapFrom||"number"!=typeof e.gapTo||"number"!=typeof e.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new _t(e.from,e.to,e.gapFrom,e.gapTo,A.fromJSON(t,e.slice),e.insert,!!e.structure)}}function Ft(t,e,n){let o=t.resolve(e),r=n-e,i=o.depth;for(;r>0&&i>0&&o.indexAfter(i)==o.node(i).childCount;)i--,r--;if(r>0){let t=o.node(i).maybeChild(o.indexAfter(i));for(;r>0;){if(!t||t.isLeaf)return!0;t=t.firstChild,r--}}return!1}function Wt(t,e,n,o=n.contentMatch,r=!0){let i=t.doc.nodeAt(e),s=[],l=e+1;for(let e=0;e<i.childCount;e++){let a=i.child(e),c=l+a.nodeSize,d=o.matchType(a.type);if(d){o=d;for(let e=0;e<a.marks.length;e++)n.allowsMarkType(a.marks[e].type)||t.step(new $t(l,c,a.marks[e]));if(r&&a.isText&&"pre"!=n.whitespace){let t,e,o=/\r?\n|\r/g;for(;t=o.exec(a.text);)e||(e=new A(k.from(n.schema.text(" ",n.allowedMarks(a.marks))),0,0)),s.push(new Vt(l+t.index,l+t.index+t[0].length,e))}}else s.push(new Vt(l,c,A.empty));l=c}if(!o.validEnd){let e=o.fillBefore(k.empty,!0);t.replace(l,l,new A(e,0,0))}for(let e=s.length-1;e>=0;e--)t.step(s[e])}function qt(t,e,n){return(0==e||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Kt(t){let e=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let n=t.depth;;--n){let o=t.$from.node(n),r=t.$from.index(n),i=t.$to.indexAfter(n);if(n<t.depth&&o.canReplace(r,i,e))return n;if(0==n||o.type.spec.isolating||!qt(o,r,i))break}return null}function Jt(t,e,n=null,o=t){let r=function(t,e){let{parent:n,startIndex:o,endIndex:r}=t,i=n.contentMatchAt(o).findWrapping(e);if(!i)return null;let s=i.length?i[0]:e;return n.canReplaceWith(o,r,s)?i:null}(t,e),i=r&&function(t,e){let{parent:n,startIndex:o,endIndex:r}=t,i=n.child(o),s=e.contentMatch.findWrapping(i.type);if(!s)return null;let l=(s.length?s[s.length-1]:e).contentMatch;for(let t=o;l&&t<r;t++)l=l.matchType(n.child(t).type);return l&&l.validEnd?s:null}(o,e);return i?r.map(Ut).concat({type:e,attrs:n}).concat(i.map(Ut)):null}function Ut(t){return{type:t,attrs:null}}function Gt(t,e,n,o){e.forEach((r,i)=>{if(r.isText){let s,l=/\r?\n|\r/g;for(;s=l.exec(r.text);){let r=t.mapping.slice(o).map(n+1+i+s.index);t.replaceWith(r,r+1,e.type.schema.linebreakReplacement.create())}}})}function Yt(t,e,n,o){e.forEach((r,i)=>{if(r.type==r.type.schema.linebreakReplacement){let r=t.mapping.slice(o).map(n+1+i);t.replaceWith(r,r+1,e.type.schema.text("\n"))}})}function Xt(t,e,n=1,o){let r=t.resolve(e),i=r.depth-n,s=o&&o[o.length-1]||r.parent;if(i<0||r.parent.type.spec.isolating||!r.parent.canReplace(r.index(),r.parent.childCount)||!s.type.validContent(r.parent.content.cutByIndex(r.index(),r.parent.childCount)))return!1;for(let t=r.depth-1,e=n-2;t>i;t--,e--){let n=r.node(t),i=r.index(t);if(n.type.spec.isolating)return!1;let s=n.content.cutByIndex(i,n.childCount),l=o&&o[e+1];l&&(s=s.replaceChild(0,l.type.create(l.attrs)));let a=o&&o[e]||n;if(!n.canReplace(i+1,n.childCount)||!a.type.validContent(s))return!1}let l=r.indexAfter(i),a=o&&o[0];return r.node(i).canReplaceWith(l,l,a?a.type:r.node(i+1).type)}function Qt(t,e){let n=t.resolve(e),o=n.index();return Zt(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(o,o+1)}function Zt(t,e){return!(!t||!e||t.isLeaf||!function(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:o}=t.type.schema;for(let r=0;r<e.childCount;r++){let i=e.child(r),s=i.type==o?t.type.schema.nodes.text:i.type;if(n=n.matchType(s),!n)return!1;if(!t.type.allowsMarks(i.marks))return!1}return n.validEnd}(t,e))}function te(t,e,n=-1){let o=t.resolve(e);for(let t=o.depth;;t--){let r,i,s=o.index(t);if(t==o.depth?(r=o.nodeBefore,i=o.nodeAfter):n>0?(r=o.node(t+1),s++,i=o.node(t).maybeChild(s)):(r=o.node(t).maybeChild(s-1),i=o.node(t+1)),r&&!r.isTextblock&&Zt(r,i)&&o.node(t).canReplace(s,s+1))return e;if(0==t)break;e=n<0?o.before(t):o.after(t)}}function ee(t,e,n){let o=t.resolve(e);if(!n.content.size)return e;let r=n.content;for(let t=0;t<n.openStart;t++)r=r.firstChild.content;for(let t=1;t<=(0==n.openStart&&n.size?2:1);t++)for(let e=o.depth;e>=0;e--){let n=e==o.depth?0:o.pos<=(o.start(e+1)+o.end(e+1))/2?-1:1,i=o.index(e)+(n>0?1:0),s=o.node(e),l=!1;if(1==t)l=s.canReplace(i,i,r);else{let t=s.contentMatchAt(i).findWrapping(r.firstChild.type);l=t&&s.canReplaceWith(i,i,t[0])}if(l)return 0==n?o.pos:n<0?o.before(e+1):o.after(e+1)}return null}function ne(t,e,n=e,o=A.empty){if(e==n&&!o.size)return null;let r=t.resolve(e),i=t.resolve(n);return oe(r,i,o)?new Vt(e,n,o):new re(r,i,o).fit()}function oe(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}jt.jsonID("replaceAround",_t);class re{constructor(t,e,n){this.$from=t,this.$to=e,this.unplaced=n,this.frontier=[],this.placed=k.empty;for(let e=0;e<=t.depth;e++){let n=t.node(e);this.frontier.push({type:n.type,match:n.contentMatchAt(t.indexAfter(e))})}for(let e=t.depth;e>0;e--)this.placed=k.from(t.node(e).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let t=this.findFittable();t?this.placeNodes(t):this.openMore()||this.dropNode()}let t=this.mustMoveInline(),e=this.placed.size-this.depth-this.$from.depth,n=this.$from,o=this.close(t<0?this.$to:n.doc.resolve(t));if(!o)return null;let r=this.placed,i=n.depth,s=o.depth;for(;i&&s&&1==r.childCount;)r=r.firstChild.content,i--,s--;let l=new A(r,i,s);return t>-1?new _t(n.pos,t,this.$to.pos,this.$to.end(),l,e):l.size||n.pos!=this.$to.pos?new Vt(n.pos,o.pos,l):null}findFittable(){let t=this.unplaced.openStart;for(let e=this.unplaced.content,n=0,o=this.unplaced.openEnd;n<t;n++){let r=e.firstChild;if(e.childCount>1&&(o=0),r.type.spec.isolating&&o<=n){t=n;break}e=r.content}for(let e=1;e<=2;e++)for(let n=1==e?t:this.unplaced.openStart;n>=0;n--){let t,o=null;n?(o=le(this.unplaced.content,n-1).firstChild,t=o.content):t=this.unplaced.content;let r=t.firstChild;for(let t=this.depth;t>=0;t--){let i,{type:s,match:l}=this.frontier[t],a=null;if(1==e&&(r?l.matchType(r.type)||(a=l.fillBefore(k.from(r),!1)):o&&s.compatibleContent(o.type)))return{sliceDepth:n,frontierDepth:t,parent:o,inject:a};if(2==e&&r&&(i=l.findWrapping(r.type)))return{sliceDepth:n,frontierDepth:t,parent:o,wrap:i};if(o&&l.matchType(o.type))break}}}openMore(){let{content:t,openStart:e,openEnd:n}=this.unplaced,o=le(t,e);return!(!o.childCount||o.firstChild.isLeaf||(this.unplaced=new A(t,e+1,Math.max(n,o.size+e>=t.size-n?e+1:0)),0))}dropNode(){let{content:t,openStart:e,openEnd:n}=this.unplaced,o=le(t,e);if(o.childCount<=1&&e>0){let r=t.size-e<=e+o.size;this.unplaced=new A(ie(t,e-1,1),e-1,r?e-1:n)}else this.unplaced=new A(ie(t,e,1),e,n)}placeNodes({sliceDepth:t,frontierDepth:e,parent:n,inject:o,wrap:r}){for(;this.depth>e;)this.closeFrontierNode();if(r)for(let t=0;t<r.length;t++)this.openFrontierNode(r[t]);let i=this.unplaced,s=n?n.content:i.content,l=i.openStart-t,a=0,c=[],{match:d,type:h}=this.frontier[e];if(o){for(let t=0;t<o.childCount;t++)c.push(o.child(t));d=d.matchFragment(o)}let p=s.size+t-(i.content.size-i.openEnd);for(;a<s.childCount;){let t=s.child(a),e=d.matchType(t.type);if(!e)break;a++,(a>1||0==l||t.content.size)&&(d=e,c.push(ae(t.mark(h.allowedMarks(t.marks)),1==a?l:0,a==s.childCount?p:-1)))}let u=a==s.childCount;u||(p=-1),this.placed=se(this.placed,e,k.from(c)),this.frontier[e].match=d,u&&p<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let t=0,e=s;t<p;t++){let t=e.lastChild;this.frontier.push({type:t.type,match:t.contentMatchAt(t.childCount)}),e=t.content}this.unplaced=u?0==t?A.empty:new A(ie(i.content,t-1,1),t-1,p<0?i.openEnd:t-1):new A(ie(i.content,t,a),i.openStart,i.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let t,e=this.frontier[this.depth];if(!e.type.isTextblock||!ce(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;let{depth:n}=this.$to,o=this.$to.after(n);for(;n>1&&o==this.$to.end(--n);)++o;return o}findCloseLevel(t){t:for(let e=Math.min(this.depth,t.depth);e>=0;e--){let{match:n,type:o}=this.frontier[e],r=e<t.depth&&t.end(e+1)==t.pos+(t.depth-(e+1)),i=ce(t,e,o,n,r);if(i){for(let n=e-1;n>=0;n--){let{match:e,type:o}=this.frontier[n],r=ce(t,n,o,e,!0);if(!r||r.childCount)continue t}return{depth:e,fit:i,move:r?t.doc.resolve(t.after(e+1)):t}}}}close(t){let e=this.findCloseLevel(t);if(!e)return null;for(;this.depth>e.depth;)this.closeFrontierNode();e.fit.childCount&&(this.placed=se(this.placed,e.depth,e.fit)),t=e.move;for(let n=e.depth+1;n<=t.depth;n++){let e=t.node(n),o=e.type.contentMatch.fillBefore(e.content,!0,t.index(n));this.openFrontierNode(e.type,e.attrs,o)}return t}openFrontierNode(t,e=null,n){let o=this.frontier[this.depth];o.match=o.match.matchType(t),this.placed=se(this.placed,this.depth,k.from(t.create(e,n))),this.frontier.push({type:t,match:t.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(k.empty,!0);t.childCount&&(this.placed=se(this.placed,this.frontier.length,t))}}function ie(t,e,n){return 0==e?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(ie(t.firstChild.content,e-1,n)))}function se(t,e,n){return 0==e?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(se(t.lastChild.content,e-1,n)))}function le(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function ae(t,e,n){if(e<=0)return t;let o=t.content;return e>1&&(o=o.replaceChild(0,ae(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(k.empty,!0)))),t.copy(o)}function ce(t,e,n,o,r){let i=t.node(e),s=r?t.indexAfter(e):t.index(e);if(s==i.childCount&&!n.compatibleContent(i.type))return null;let l=o.fillBefore(i.content,!0,s);return l&&!function(t,e,n){for(let o=n;o<e.childCount;o++)if(!t.allowsMarks(e.child(o).marks))return!0;return!1}(n,i.content,s)?l:null}function de(t){return t.spec.defining||t.spec.definingForContent}function he(t,e,n,o,r){if(e<n){let r=t.firstChild;t=t.replaceChild(0,r.copy(he(r.content,e+1,n,o,r)))}if(e>o){let e=r.contentMatchAt(0),n=e.fillBefore(t).append(t);t=n.append(e.matchFragment(n).fillBefore(k.empty,!0))}return t}function pe(t,e){let n=[];for(let o=Math.min(t.depth,e.depth);o>=0;o--){let r=t.start(o);if(r<t.pos-(t.depth-o)||e.end(o)>e.pos+(e.depth-o)||t.node(o).type.spec.isolating||e.node(o).type.spec.isolating)break;(r==e.start(o)||o==t.depth&&o==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&o&&e.start(o-1)==r-1)&&n.push(o)}return n}class ue extends jt{constructor(t,e,n){super(),this.pos=t,this.attr=e,this.value=n}apply(t){let e=t.nodeAt(this.pos);if(!e)return It.fail("No node at attribute step's position");let n=Object.create(null);for(let t in e.attrs)n[t]=e.attrs[t];n[this.attr]=this.value;let o=e.type.create(n,null,e.marks);return It.fromReplace(t,this.pos,this.pos+1,new A(k.from(o),0,e.isLeaf?0:1))}getMap(){return Dt.empty}invert(t){return new ue(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new ue(e.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,e){if("number"!=typeof e.pos||"string"!=typeof e.attr)throw new RangeError("Invalid input for AttrStep.fromJSON");return new ue(e.pos,e.attr,e.value)}}jt.jsonID("attr",ue);class fe extends jt{constructor(t,e){super(),this.attr=t,this.value=e}apply(t){let e=Object.create(null);for(let n in t.attrs)e[n]=t.attrs[n];e[this.attr]=this.value;let n=t.type.create(e,t.content,t.marks);return It.ok(n)}getMap(){return Dt.empty}invert(t){return new fe(this.attr,t.attrs[this.attr])}map(t){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(t,e){if("string"!=typeof e.attr)throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new fe(e.attr,e.value)}}jt.jsonID("docAttr",fe);let me=class extends Error{};me=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n},(me.prototype=Object.create(Error.prototype)).constructor=me,me.prototype.name="TransformError";class ge{constructor(t){this.doc=t,this.steps=[],this.docs=[],this.mapping=new Lt}get before(){return this.docs.length?this.docs[0]:this.doc}step(t){let e=this.maybeStep(t);if(e.failed)throw new me(e.failed);return this}maybeStep(t){let e=t.apply(this.doc);return e.failed||this.addStep(t,e.doc),e}get docChanged(){return this.steps.length>0}addStep(t,e){this.docs.push(this.doc),this.steps.push(t),this.mapping.appendMap(t.getMap()),this.doc=e}replace(t,e=t,n=A.empty){let o=ne(this.doc,t,e,n);return o&&this.step(o),this}replaceWith(t,e,n){return this.replace(t,e,new A(k.from(n),0,0))}delete(t,e){return this.replace(t,e,A.empty)}insert(t,e){return this.replaceWith(t,t,e)}replaceRange(t,e,n){return function(t,e,n,o){if(!o.size)return t.deleteRange(e,n);let r=t.doc.resolve(e),i=t.doc.resolve(n);if(oe(r,i,o))return t.step(new Vt(e,n,o));let s=pe(r,t.doc.resolve(n));0==s[s.length-1]&&s.pop();let l=-(r.depth+1);s.unshift(l);for(let t=r.depth,e=r.pos-1;t>0;t--,e--){let n=r.node(t).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;s.indexOf(t)>-1?l=t:r.before(t)==e&&s.splice(1,0,-t)}let a=s.indexOf(l),c=[],d=o.openStart;for(let t=o.content,e=0;;e++){let n=t.firstChild;if(c.push(n),e==o.openStart)break;t=n.content}for(let t=d-1;t>=0;t--){let e=c[t],n=de(e.type);if(n&&!e.sameMarkup(r.node(Math.abs(l)-1)))d=t;else if(n||!e.type.isTextblock)break}for(let e=o.openStart;e>=0;e--){let l=(e+d+1)%(o.openStart+1),h=c[l];if(h)for(let e=0;e<s.length;e++){let c=s[(e+a)%s.length],d=!0;c<0&&(d=!1,c=-c);let p=r.node(c-1),u=r.index(c-1);if(p.canReplaceWith(u,u,h.type,h.marks))return t.replace(r.before(c),d?i.after(c):n,new A(he(o.content,0,o.openStart,l),l,o.openEnd))}}let h=t.steps.length;for(let l=s.length-1;l>=0&&(t.replace(e,n,o),!(t.steps.length>h));l--){let t=s[l];t<0||(e=r.before(t),n=i.after(t))}}(this,t,e,n),this}replaceRangeWith(t,e,n){return function(t,e,n,o){if(!o.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let r=function(t,e,n){let o=t.resolve(e);if(o.parent.canReplaceWith(o.index(),o.index(),n))return e;if(0==o.parentOffset)for(let t=o.depth-1;t>=0;t--){let e=o.index(t);if(o.node(t).canReplaceWith(e,e,n))return o.before(t+1);if(e>0)return null}if(o.parentOffset==o.parent.content.size)for(let t=o.depth-1;t>=0;t--){let e=o.indexAfter(t);if(o.node(t).canReplaceWith(e,e,n))return o.after(t+1);if(e<o.node(t).childCount)return null}return null}(t.doc,e,o.type);null!=r&&(e=n=r)}t.replaceRange(e,n,new A(k.from(o),0,0))}(this,t,e,n),this}deleteRange(t,e){return function(t,e,n){let o=t.doc.resolve(e),r=t.doc.resolve(n),i=pe(o,r);for(let e=0;e<i.length;e++){let n=i[e],s=e==i.length-1;if(s&&0==n||o.node(n).type.contentMatch.validEnd)return t.delete(o.start(n),r.end(n));if(n>0&&(s||o.node(n-1).canReplace(o.index(n-1),r.indexAfter(n-1))))return t.delete(o.before(n),r.after(n))}for(let i=1;i<=o.depth&&i<=r.depth;i++)if(e-o.start(i)==o.depth-i&&n>o.end(i)&&r.end(i)-n!=r.depth-i&&o.start(i-1)==r.start(i-1)&&o.node(i-1).canReplace(o.index(i-1),r.index(i-1)))return t.delete(o.before(i),n);t.delete(e,n)}(this,t,e),this}lift(t,e){return function(t,e,n){let{$from:o,$to:r,depth:i}=e,s=o.before(i+1),l=r.after(i+1),a=s,c=l,d=k.empty,h=0;for(let t=i,e=!1;t>n;t--)e||o.index(t)>0?(e=!0,d=k.from(o.node(t).copy(d)),h++):a--;let p=k.empty,u=0;for(let t=i,e=!1;t>n;t--)e||r.after(t+1)<r.end(t)?(e=!0,p=k.from(r.node(t).copy(p)),u++):c++;t.step(new _t(a,c,s,l,new A(d.append(p),h,u),d.size-h,!0))}(this,t,e),this}join(t,e=1){return function(t,e,n){let o=null,{linebreakReplacement:r}=t.doc.type.schema,i=t.doc.resolve(e-n),s=i.node().type;if(r&&s.inlineContent){let t="pre"==s.whitespace,e=!!s.contentMatch.matchType(r);t&&!e?o=!1:!t&&e&&(o=!0)}let l=t.steps.length;if(!1===o){let o=t.doc.resolve(e+n);Yt(t,o.node(),o.before(),l)}s.inlineContent&&Wt(t,e+n-1,s,i.node().contentMatchAt(i.index()),null==o);let a=t.mapping.slice(l),c=a.map(e-n);if(t.step(new Vt(c,a.map(e+n,-1),A.empty,!0)),!0===o){let e=t.doc.resolve(c);Gt(t,e.node(),e.before(),t.steps.length)}}(this,t,e),this}wrap(t,e){return function(t,e,n){let o=k.empty;for(let t=n.length-1;t>=0;t--){if(o.size){let e=n[t].type.contentMatch.matchFragment(o);if(!e||!e.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}o=k.from(n[t].type.create(n[t].attrs,o))}let r=e.start,i=e.end;t.step(new _t(r,i,r,i,new A(o,0,0),n.length,!0))}(this,t,e),this}setBlockType(t,e=t,n,o=null){return function(t,e,n,o,r){if(!o.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=t.steps.length;t.doc.nodesBetween(e,n,(e,n)=>{let s="function"==typeof r?r(e):r;if(e.isTextblock&&!e.hasMarkup(o,s)&&function(t,e,n){let o=t.resolve(e),r=o.index();return o.parent.canReplaceWith(r,r+1,n)}(t.doc,t.mapping.slice(i).map(n),o)){let r=null;if(o.schema.linebreakReplacement){let t="pre"==o.whitespace,e=!!o.contentMatch.matchType(o.schema.linebreakReplacement);t&&!e?r=!1:!t&&e&&(r=!0)}!1===r&&Yt(t,e,n,i),Wt(t,t.mapping.slice(i).map(n,1),o,void 0,null===r);let l=t.mapping.slice(i),a=l.map(n,1),c=l.map(n+e.nodeSize,1);return t.step(new _t(a,c,a+1,c-1,new A(k.from(o.create(s,null,e.marks)),0,0),1,!0)),!0===r&&Gt(t,e,n,i),!1}})}(this,t,e,n,o),this}setNodeMarkup(t,e,n=null,o){return function(t,e,n,o,r){let i=t.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");n||(n=i.type);let s=n.create(o,null,r||i.marks);if(i.isLeaf)return t.replaceWith(e,e+i.nodeSize,s);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new _t(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new A(k.from(s),0,0),1,!0))}(this,t,e,n,o),this}setNodeAttribute(t,e,n){return this.step(new ue(t,e,n)),this}setDocAttribute(t,e){return this.step(new fe(t,e)),this}addNodeMark(t,e){return this.step(new Ht(t,e)),this}removeNodeMark(t,e){let n=this.doc.nodeAt(t);if(!n)throw new RangeError("No node at position "+t);if(e instanceof S)e.isInSet(n.marks)&&this.step(new Bt(t,e));else{let o,r=n.marks,i=[];for(;o=e.isInSet(r);)i.push(new Bt(t,o)),r=o.removeFromSet(r);for(let t=i.length-1;t>=0;t--)this.step(i[t])}return this}split(t,e=1,n){return function(t,e,n=1,o){let r=t.doc.resolve(e),i=k.empty,s=k.empty;for(let t=r.depth,e=r.depth-n,l=n-1;t>e;t--,l--){i=k.from(r.node(t).copy(i));let e=o&&o[l];s=k.from(e?e.type.create(e.attrs,s):r.node(t).copy(s))}t.step(new Vt(e,e,new A(i.append(s),n,n),!0))}(this,t,e,n),this}addMark(t,e,n){return function(t,e,n,o){let r,i,s=[],l=[];t.doc.nodesBetween(e,n,(t,a,c)=>{if(!t.isInline)return;let d=t.marks;if(!o.isInSet(d)&&c.type.allowsMarkType(o.type)){let c=Math.max(a,e),h=Math.min(a+t.nodeSize,n),p=o.addToSet(d);for(let t=0;t<d.length;t++)d[t].isInSet(p)||(r&&r.to==c&&r.mark.eq(d[t])?r.to=h:s.push(r=new $t(c,h,d[t])));i&&i.to==c?i.to=h:l.push(i=new zt(c,h,o))}}),s.forEach(e=>t.step(e)),l.forEach(e=>t.step(e))}(this,t,e,n),this}removeMark(t,e,n){return function(t,e,n,o){let r=[],i=0;t.doc.nodesBetween(e,n,(t,s)=>{if(!t.isInline)return;i++;let l=null;if(o instanceof ct){let e,n=t.marks;for(;e=o.isInSet(n);)(l||(l=[])).push(e),n=e.removeFromSet(n)}else o?o.isInSet(t.marks)&&(l=[o]):l=t.marks;if(l&&l.length){let o=Math.min(s+t.nodeSize,n);for(let t=0;t<l.length;t++){let n,a=l[t];for(let t=0;t<r.length;t++){let e=r[t];e.step==i-1&&a.eq(r[t].style)&&(n=e)}n?(n.to=o,n.step=i):r.push({style:a,from:Math.max(s,e),to:o,step:i})}}}),r.forEach(e=>t.step(new $t(e.from,e.to,e.style)))}(this,t,e,n),this}clearIncompatible(t,e,n){return Wt(this,t,e,n),this}}const ye=Object.create(null);class be{constructor(t,e,n){this.$anchor=t,this.$head=e,this.ranges=n||[new ve(t.min(e),t.max(e))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let t=this.ranges;for(let e=0;e<t.length;e++)if(t[e].$from.pos!=t[e].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(t,e=A.empty){let n=e.content.lastChild,o=null;for(let t=0;t<e.openEnd;t++)o=n,n=n.lastChild;let r=t.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:l,$to:a}=i[s],c=t.mapping.slice(r);t.replaceRange(c.map(l.pos),c.map(a.pos),s?A.empty:e),0==s&&Oe(t,r,(n?n.isInline:o&&o.isTextblock)?-1:1)}}replaceWith(t,e){let n=t.steps.length,o=this.ranges;for(let r=0;r<o.length;r++){let{$from:i,$to:s}=o[r],l=t.mapping.slice(n),a=l.map(i.pos),c=l.map(s.pos);r?t.deleteRange(a,c):(t.replaceRangeWith(a,c,e),Oe(t,n,e.isInline?-1:1))}}static findFrom(t,e,n=!1){let o=t.parent.inlineContent?new xe(t):Ee(t.node(0),t.parent,t.pos,t.index(),e,n);if(o)return o;for(let o=t.depth-1;o>=0;o--){let r=e<0?Ee(t.node(0),t.node(o),t.before(o+1),t.index(o),e,n):Ee(t.node(0),t.node(o),t.after(o+1),t.index(o)+1,e,n);if(r)return r}return null}static near(t,e=1){return this.findFrom(t,e)||this.findFrom(t,-e)||new Te(t.node(0))}static atStart(t){return Ee(t,t,0,0,1)||new Te(t)}static atEnd(t){return Ee(t,t,t.content.size,t.childCount,-1)||new Te(t)}static fromJSON(t,e){if(!e||!e.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=ye[e.type];if(!n)throw new RangeError(`No selection type ${e.type} defined`);return n.fromJSON(t,e)}static jsonID(t,e){if(t in ye)throw new RangeError("Duplicate use of selection JSON ID "+t);return ye[t]=e,e.prototype.jsonID=t,e}getBookmark(){return xe.between(this.$anchor,this.$head).getBookmark()}}be.prototype.visible=!0;class ve{constructor(t,e){this.$from=t,this.$to=e}}let we=!1;function ke(t){we||t.parent.inlineContent||(we=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class xe extends be{constructor(t,e=t){ke(t),ke(e),super(t,e)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,e){let n=t.resolve(e.map(this.head));if(!n.parent.inlineContent)return be.near(n);let o=t.resolve(e.map(this.anchor));return new xe(o.parent.inlineContent?o:n,n)}replace(t,e=A.empty){if(super.replace(t,e),e==A.empty){let e=this.$from.marksAcross(this.$to);e&&t.ensureMarks(e)}}eq(t){return t instanceof xe&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new Me(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(t,e){if("number"!=typeof e.anchor||"number"!=typeof e.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new xe(t.resolve(e.anchor),t.resolve(e.head))}static create(t,e,n=e){let o=t.resolve(e);return new this(o,n==e?o:t.resolve(n))}static between(t,e,n){let o=t.pos-e.pos;if(n&&!o||(n=o>=0?1:-1),!e.parent.inlineContent){let t=be.findFrom(e,n,!0)||be.findFrom(e,-n,!0);if(!t)return be.near(e,n);e=t.$head}return t.parent.inlineContent||(0==o||(t=(be.findFrom(t,-n,!0)||be.findFrom(t,n,!0)).$anchor).pos<e.pos!=o<0)&&(t=e),new xe(t,e)}}be.jsonID("text",xe);class Me{constructor(t,e){this.anchor=t,this.head=e}map(t){return new Me(t.map(this.anchor),t.map(this.head))}resolve(t){return xe.between(t.resolve(this.anchor),t.resolve(this.head))}}class Ce extends be{constructor(t){let e=t.nodeAfter,n=t.node(0).resolve(t.pos+e.nodeSize);super(t,n),this.node=e}map(t,e){let{deleted:n,pos:o}=e.mapResult(this.anchor),r=t.resolve(o);return n?be.near(r):new Ce(r)}content(){return new A(k.from(this.node),0,0)}eq(t){return t instanceof Ce&&t.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Se(this.anchor)}static fromJSON(t,e){if("number"!=typeof e.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Ce(t.resolve(e.anchor))}static create(t,e){return new Ce(t.resolve(e))}static isSelectable(t){return!t.isText&&!1!==t.type.spec.selectable}}Ce.prototype.visible=!1,be.jsonID("node",Ce);class Se{constructor(t){this.anchor=t}map(t){let{deleted:e,pos:n}=t.mapResult(this.anchor);return e?new Me(n,n):new Se(n)}resolve(t){let e=t.resolve(this.anchor),n=e.nodeAfter;return n&&Ce.isSelectable(n)?new Ce(e):be.near(e)}}class Te extends be{constructor(t){super(t.resolve(0),t.resolve(t.content.size))}replace(t,e=A.empty){if(e==A.empty){t.delete(0,t.doc.content.size);let e=be.atStart(t.doc);e.eq(t.selection)||t.setSelection(e)}else super.replace(t,e)}toJSON(){return{type:"all"}}static fromJSON(t){return new Te(t)}map(t){return new Te(t)}eq(t){return t instanceof Te}getBookmark(){return Ae}}be.jsonID("all",Te);const Ae={map(){return this},resolve:t=>new Te(t)};function Ee(t,e,n,o,r,i=!1){if(e.inlineContent)return xe.create(t,n);for(let s=o-(r>0?0:1);r>0?s<e.childCount:s>=0;s+=r){let o=e.child(s);if(o.isAtom){if(!i&&Ce.isSelectable(o))return Ce.create(t,n-(r<0?o.nodeSize:0))}else{let e=Ee(t,o,n+r,r<0?o.childCount:0,r,i);if(e)return e}n+=o.nodeSize*r}return null}function Oe(t,e,n){let o=t.steps.length-1;if(o<e)return;let r,i=t.steps[o];(i instanceof Vt||i instanceof _t)&&(t.mapping.maps[o].forEach((t,e,n,o)=>{null==r&&(r=o)}),t.setSelection(be.near(t.doc.resolve(r),n)))}class Ne extends ge{constructor(t){super(t.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=t.selection,this.storedMarks=t.storedMarks}get selection(){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}setSelection(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&this.updated|1,this.storedMarks=null,this}get selectionSet(){return(1&this.updated)>0}setStoredMarks(t){return this.storedMarks=t,this.updated|=2,this}ensureMarks(t){return S.sameSet(this.storedMarks||this.selection.$from.marks(),t)||this.setStoredMarks(t),this}addStoredMark(t){return this.ensureMarks(t.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(t){return this.ensureMarks(t.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(2&this.updated)>0}addStep(t,e){super.addStep(t,e),this.updated=-3&this.updated,this.storedMarks=null}setTime(t){return this.time=t,this}replaceSelection(t){return this.selection.replace(this,t),this}replaceSelectionWith(t,e=!0){let n=this.selection;return e&&(t=t.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||S.none))),n.replaceWith(this,t),this}deleteSelection(){return this.selection.replace(this),this}insertText(t,e,n){let o=this.doc.type.schema;if(null==e)return t?this.replaceSelectionWith(o.text(t),!0):this.deleteSelection();{if(null==n&&(n=e),n=null==n?e:n,!t)return this.deleteRange(e,n);let r=this.storedMarks;if(!r){let t=this.doc.resolve(e);r=n==e?t.marks():t.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(e,n,o.text(t,r)),this.selection.empty||this.setSelection(be.near(this.selection.$to)),this}}setMeta(t,e){return this.meta["string"==typeof t?t:t.key]=e,this}getMeta(t){return this.meta["string"==typeof t?t:t.key]}get isGeneric(){for(let t in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=4,this}get scrolledIntoView(){return(4&this.updated)>0}}function De(t,e){return e&&t?t.bind(e):t}class Le{constructor(t,e,n){this.name=t,this.init=De(e.init,n),this.apply=De(e.apply,n)}}const Re=[new Le("doc",{init:t=>t.doc||t.schema.topNodeType.createAndFill(),apply:t=>t.doc}),new Le("selection",{init:(t,e)=>t.selection||be.atStart(e.doc),apply:t=>t.selection}),new Le("storedMarks",{init:t=>t.storedMarks||null,apply:(t,e,n,o)=>o.selection.$cursor?t.storedMarks:null}),new Le("scrollToSelection",{init:()=>0,apply:(t,e)=>t.scrolledIntoView?e+1:e})];class je{constructor(t,e){this.schema=t,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Re.slice(),e&&e.forEach(t=>{if(this.pluginsByKey[t.key])throw new RangeError("Adding different instances of a keyed plugin ("+t.key+")");this.plugins.push(t),this.pluginsByKey[t.key]=t,t.spec.state&&this.fields.push(new Le(t.key,t.spec.state,t))})}}class Ie{constructor(t){this.config=t}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(t){return this.applyTransaction(t).state}filterTransaction(t,e=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=e){let e=this.config.plugins[n];if(e.spec.filterTransaction&&!e.spec.filterTransaction.call(e,t,this))return!1}return!0}applyTransaction(t){if(!this.filterTransaction(t))return{state:this,transactions:[]};let e=[t],n=this.applyInner(t),o=null;for(;;){let r=!1;for(let i=0;i<this.config.plugins.length;i++){let s=this.config.plugins[i];if(s.spec.appendTransaction){let l=o?o[i].n:0,a=o?o[i].state:this,c=l<e.length&&s.spec.appendTransaction.call(s,l?e.slice(l):e,a,n);if(c&&n.filterTransaction(c,i)){if(c.setMeta("appendedTransaction",t),!o){o=[];for(let t=0;t<this.config.plugins.length;t++)o.push(t<i?{state:n,n:e.length}:{state:this,n:0})}e.push(c),n=n.applyInner(c),r=!0}o&&(o[i]={state:n,n:e.length})}}if(!r)return{state:n,transactions:e}}}applyInner(t){if(!t.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let e=new Ie(this.config),n=this.config.fields;for(let o=0;o<n.length;o++){let r=n[o];e[r.name]=r.apply(t,this[r.name],this,e)}return e}get tr(){return new Ne(this)}static create(t){let e=new je(t.doc?t.doc.type.schema:t.schema,t.plugins),n=new Ie(e);for(let o=0;o<e.fields.length;o++)n[e.fields[o].name]=e.fields[o].init(t,n);return n}reconfigure(t){let e=new je(this.schema,t.plugins),n=e.fields,o=new Ie(e);for(let e=0;e<n.length;e++){let r=n[e].name;o[r]=this.hasOwnProperty(r)?this[r]:n[e].init(t,o)}return o}toJSON(t){let e={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(e.storedMarks=this.storedMarks.map(t=>t.toJSON())),t&&"object"==typeof t)for(let n in t){if("doc"==n||"selection"==n)throw new RangeError("The JSON fields `doc` and `selection` are reserved");let o=t[n],r=o.spec.state;r&&r.toJSON&&(e[n]=r.toJSON.call(o,this[o.key]))}return e}static fromJSON(t,e,n){if(!e)throw new RangeError("Invalid input for EditorState.fromJSON");if(!t.schema)throw new RangeError("Required config field 'schema' missing");let o=new je(t.schema,t.plugins),r=new Ie(o);return o.fields.forEach(o=>{if("doc"==o.name)r.doc=q.fromJSON(t.schema,e.doc);else if("selection"==o.name)r.selection=be.fromJSON(r.doc,e.selection);else if("storedMarks"==o.name)e.storedMarks&&(r.storedMarks=e.storedMarks.map(t.schema.markFromJSON));else{if(n)for(let i in n){let s=n[i],l=s.spec.state;if(s.key==o.name&&l&&l.fromJSON&&Object.prototype.hasOwnProperty.call(e,i))return void(r[o.name]=l.fromJSON.call(s,t,e[i],r))}r[o.name]=o.init(t,r)}}),r}}function Pe(t,e,n){for(let o in t){let r=t[o];r instanceof Function?r=r.bind(e):"handleDOMEvents"==o&&(r=Pe(r,e,{})),n[o]=r}return n}class ze{constructor(t){this.spec=t,this.props={},t.props&&Pe(t.props,this,this.props),this.key=t.key?t.key.key:He("plugin")}getState(t){return t[this.key]}}const $e=Object.create(null);function He(t){return t in $e?t+"$"+ ++$e[t]:($e[t]=0,t+"$")}class Be{constructor(t="key"){this.key=He(t)}get(t){return t.config.pluginsByKey[this.key]}getState(t){return t[this.key]}}const Ve=function(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e},_e=function(t){let e=t.assignedSlot||t.parentNode;return e&&11==e.nodeType?e.host:e};let Fe=null;const We=function(t,e,n){let o=Fe||(Fe=document.createRange());return o.setEnd(t,null==n?t.nodeValue.length:n),o.setStart(t,e||0),o},qe=function(t,e,n,o){return n&&(Je(t,e,n,o,-1)||Je(t,e,n,o,1))},Ke=/^(img|br|input|textarea|hr)$/i;function Je(t,e,n,o,r){for(var i;;){if(t==n&&e==o)return!0;if(e==(r<0?0:Ue(t))){let n=t.parentNode;if(!n||1!=n.nodeType||Ge(t)||Ke.test(t.nodeName)||"false"==t.contentEditable)return!1;e=Ve(t)+(r<0?0:1),t=n}else{if(1!=t.nodeType)return!1;{let n=t.childNodes[e+(r<0?-1:0)];if(1==n.nodeType&&"false"==n.contentEditable){if(!(null===(i=n.pmViewDesc)||void 0===i?void 0:i.ignoreForSelection))return!1;e+=r}else t=n,e=r<0?Ue(t):0}}}}function Ue(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function Ge(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const Ye=function(t){return t.focusNode&&qe(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Xe(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}const Qe="undefined"!=typeof navigator?navigator:null,Ze="undefined"!=typeof document?document:null,tn=Qe&&Qe.userAgent||"",en=/Edge\/(\d+)/.exec(tn),nn=/MSIE \d/.exec(tn),on=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(tn),rn=!!(nn||on||en),sn=nn?document.documentMode:on?+on[1]:en?+en[1]:0,ln=!rn&&/gecko\/(\d+)/i.test(tn);ln&&(/Firefox\/(\d+)/.exec(tn)||[0,0])[1];const an=!rn&&/Chrome\/(\d+)/.exec(tn),cn=!!an,dn=an?+an[1]:0,hn=!rn&&!!Qe&&/Apple Computer/.test(Qe.vendor),pn=hn&&(/Mobile\/\w+/.test(tn)||!!Qe&&Qe.maxTouchPoints>2),un=pn||!!Qe&&/Mac/.test(Qe.platform),fn=!!Qe&&/Win/.test(Qe.platform),mn=/Android \d/.test(tn),gn=!!Ze&&"webkitFontSmoothing"in Ze.documentElement.style,yn=gn?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function bn(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function vn(t,e){return"number"==typeof t?t:t[e]}function wn(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,o=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*o}}function kn(t,e,n){let o=t.someProp("scrollThreshold")||0,r=t.someProp("scrollMargin")||5,i=t.dom.ownerDocument;for(let s=n||t.dom;s;){if(1!=s.nodeType){s=_e(s);continue}let t=s,n=t==i.body,l=n?bn(i):wn(t),a=0,c=0;if(e.top<l.top+vn(o,"top")?c=-(l.top-e.top+vn(r,"top")):e.bottom>l.bottom-vn(o,"bottom")&&(c=e.bottom-e.top>l.bottom-l.top?e.top+vn(r,"top")-l.top:e.bottom-l.bottom+vn(r,"bottom")),e.left<l.left+vn(o,"left")?a=-(l.left-e.left+vn(r,"left")):e.right>l.right-vn(o,"right")&&(a=e.right-l.right+vn(r,"right")),a||c)if(n)i.defaultView.scrollBy(a,c);else{let n=t.scrollLeft,o=t.scrollTop;c&&(t.scrollTop+=c),a&&(t.scrollLeft+=a);let r=t.scrollLeft-n,i=t.scrollTop-o;e={left:e.left-r,top:e.top-i,right:e.right-r,bottom:e.bottom-i}}let d=n?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(d))break;s="absolute"==d?s.offsetParent:_e(s)}}function xn(t){let e=[],n=t.ownerDocument;for(let o=t;o&&(e.push({dom:o,top:o.scrollTop,left:o.scrollLeft}),t!=n);o=_e(o));return e}function Mn(t,e){for(let n=0;n<t.length;n++){let{dom:o,top:r,left:i}=t[n];o.scrollTop!=r+e&&(o.scrollTop=r+e),o.scrollLeft!=i&&(o.scrollLeft=i)}}let Cn=null;function Sn(t,e){let n,o,r,i,s=2e8,l=0,a=e.top,c=e.top;for(let d=t.firstChild,h=0;d;d=d.nextSibling,h++){let t;if(1==d.nodeType)t=d.getClientRects();else{if(3!=d.nodeType)continue;t=We(d).getClientRects()}for(let p=0;p<t.length;p++){let u=t[p];if(u.top<=a&&u.bottom>=c){a=Math.max(u.bottom,a),c=Math.min(u.top,c);let t=u.left>e.left?u.left-e.left:u.right<e.left?e.left-u.right:0;if(t<s){n=d,s=t,o=t&&3==n.nodeType?{left:u.right<e.left?u.right:u.left,top:e.top}:e,1==d.nodeType&&t&&(l=h+(e.left>=(u.left+u.right)/2?1:0));continue}}else u.top>e.top&&!r&&u.left<=e.left&&u.right>=e.left&&(r=d,i={left:Math.max(u.left,Math.min(u.right,e.left)),top:u.top});!n&&(e.left>=u.right&&e.top>=u.top||e.left>=u.left&&e.top>=u.bottom)&&(l=h+1)}}return!n&&r&&(n=r,o=i,s=0),n&&3==n.nodeType?function(t,e){let n=t.nodeValue.length,o=document.createRange();for(let r=0;r<n;r++){o.setEnd(t,r+1),o.setStart(t,r);let n=Nn(o,1);if(n.top!=n.bottom&&Tn(e,n))return{node:t,offset:r+(e.left>=(n.left+n.right)/2?1:0)}}return{node:t,offset:0}}(n,o):!n||s&&1==n.nodeType?{node:t,offset:l}:Sn(n,o)}function Tn(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function An(t,e,n){let o=t.childNodes.length;if(o&&n.top<n.bottom)for(let r=Math.max(0,Math.min(o-1,Math.floor(o*(e.top-n.top)/(n.bottom-n.top))-2)),i=r;;){let n=t.childNodes[i];if(1==n.nodeType){let t=n.getClientRects();for(let o=0;o<t.length;o++){let r=t[o];if(Tn(e,r))return An(n,e,r)}}if((i=(i+1)%o)==r)break}return t}function En(t,e){let n,o=t.dom.ownerDocument,r=0,i=function(t,e,n){if(t.caretPositionFromPoint)try{let o=t.caretPositionFromPoint(e,n);if(o)return{node:o.offsetNode,offset:Math.min(Ue(o.offsetNode),o.offset)}}catch(t){}if(t.caretRangeFromPoint){let o=t.caretRangeFromPoint(e,n);if(o)return{node:o.startContainer,offset:Math.min(Ue(o.startContainer),o.startOffset)}}}(o,e.left,e.top);i&&({node:n,offset:r}=i);let s,l=(t.root.elementFromPoint?t.root:o).elementFromPoint(e.left,e.top);if(!l||!t.dom.contains(1!=l.nodeType?l.parentNode:l)){let n=t.dom.getBoundingClientRect();if(!Tn(e,n))return null;if(l=An(t.dom,e,n),!l)return null}if(hn)for(let t=l;n&&t;t=_e(t))t.draggable&&(n=void 0);if(l=function(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}(l,e),n){if(ln&&1==n.nodeType&&(r=Math.min(r,n.childNodes.length),r<n.childNodes.length)){let t,o=n.childNodes[r];"IMG"==o.nodeName&&(t=o.getBoundingClientRect()).right<=e.left&&t.bottom>e.top&&r++}let o;gn&&r&&1==n.nodeType&&1==(o=n.childNodes[r-1]).nodeType&&"false"==o.contentEditable&&o.getBoundingClientRect().top>=e.top&&r--,n==t.dom&&r==n.childNodes.length-1&&1==n.lastChild.nodeType&&e.top>n.lastChild.getBoundingClientRect().bottom?s=t.state.doc.content.size:0!=r&&1==n.nodeType&&"BR"==n.childNodes[r-1].nodeName||(s=function(t,e,n,o){let r=-1;for(let n=e,i=!1;n!=t.dom;){let e,s=t.docView.nearestDesc(n,!0);if(!s)return null;if(1==s.dom.nodeType&&(s.node.isBlock&&s.parent||!s.contentDOM)&&((e=s.dom.getBoundingClientRect()).width||e.height)&&(s.node.isBlock&&s.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(s.dom.nodeName)&&(!i&&e.left>o.left||e.top>o.top?r=s.posBefore:(!i&&e.right<o.left||e.bottom<o.top)&&(r=s.posAfter),i=!0),!s.contentDOM&&r<0&&!s.node.isText))return(s.node.isBlock?o.top<(e.top+e.bottom)/2:o.left<(e.left+e.right)/2)?s.posBefore:s.posAfter;n=s.dom.parentNode}return r>-1?r:t.docView.posFromDOM(e,n,-1)}(t,n,r,e))}null==s&&(s=function(t,e,n){let{node:o,offset:r}=Sn(e,n),i=-1;if(1==o.nodeType&&!o.firstChild){let t=o.getBoundingClientRect();i=t.left!=t.right&&n.left>(t.left+t.right)/2?1:-1}return t.docView.posFromDOM(o,r,i)}(t,l,e));let a=t.docView.nearestDesc(l,!0);return{pos:s,inside:a?a.posAtStart-a.border:-1}}function On(t){return t.top<t.bottom||t.left<t.right}function Nn(t,e){let n=t.getClientRects();if(n.length){let t=n[e<0?0:n.length-1];if(On(t))return t}return Array.prototype.find.call(n,On)||t.getBoundingClientRect()}const Dn=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Ln(t,e,n){let{node:o,offset:r,atom:i}=t.docView.domFromPos(e,n<0?-1:1),s=gn||ln;if(3==o.nodeType){if(!s||!Dn.test(o.nodeValue)&&(n<0?r:r!=o.nodeValue.length)){let t=r,e=r,i=n<0?1:-1;return n<0&&!r?(e++,i=-1):n>=0&&r==o.nodeValue.length?(t--,i=1):n<0?t--:e++,Rn(Nn(We(o,t,e),i),i<0)}{let t=Nn(We(o,r,r),n);if(ln&&r&&/\s/.test(o.nodeValue[r-1])&&r<o.nodeValue.length){let e=Nn(We(o,r-1,r-1),-1);if(e.top==t.top){let n=Nn(We(o,r,r+1),-1);if(n.top!=t.top)return Rn(n,n.left<e.left)}}return t}}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(null==i&&r&&(n<0||r==Ue(o))){let t=o.childNodes[r-1];if(1==t.nodeType)return jn(t.getBoundingClientRect(),!1)}if(null==i&&r<Ue(o)){let t=o.childNodes[r];if(1==t.nodeType)return jn(t.getBoundingClientRect(),!0)}return jn(o.getBoundingClientRect(),n>=0)}if(null==i&&r&&(n<0||r==Ue(o))){let t=o.childNodes[r-1],e=3==t.nodeType?We(t,Ue(t)-(s?0:1)):1!=t.nodeType||"BR"==t.nodeName&&t.nextSibling?null:t;if(e)return Rn(Nn(e,1),!1)}if(null==i&&r<Ue(o)){let t=o.childNodes[r];for(;t.pmViewDesc&&t.pmViewDesc.ignoreForCoords;)t=t.nextSibling;let e=t?3==t.nodeType?We(t,0,s?0:1):1==t.nodeType?t:null:null;if(e)return Rn(Nn(e,-1),!0)}return Rn(Nn(3==o.nodeType?We(o):o,-n),n>=0)}function Rn(t,e){if(0==t.width)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function jn(t,e){if(0==t.height)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function In(t,e,n){let o=t.state,r=t.root.activeElement;o!=e&&t.updateState(e),r!=t.dom&&t.focus();try{return n()}finally{o!=e&&t.updateState(o),r!=t.dom&&r&&r.focus()}}const Pn=/[\u0590-\u08ac]/;let zn=null,$n=null,Hn=!1;class Bn{constructor(t,e,n,o){this.parent=t,this.children=e,this.dom=n,this.contentDOM=o,this.dirty=0,n.pmViewDesc=this}matchesWidget(t){return!1}matchesMark(t){return!1}matchesNode(t,e,n){return!1}matchesHack(t){return!1}parseRule(){return null}stopEvent(t){return!1}get size(){let t=0;for(let e=0;e<this.children.length;e++)t+=this.children[e].size;return t}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let t=0;t<this.children.length;t++)this.children[t].destroy()}posBeforeChild(t){for(let e=0,n=this.posAtStart;;e++){let o=this.children[e];if(o==t)return n;n+=o.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(t,e,n){if(this.contentDOM&&this.contentDOM.contains(1==t.nodeType?t:t.parentNode)){if(n<0){let n,o;if(t==this.contentDOM)n=t.childNodes[e-1];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;n=t.previousSibling}for(;n&&(!(o=n.pmViewDesc)||o.parent!=this);)n=n.previousSibling;return n?this.posBeforeChild(o)+o.size:this.posAtStart}{let n,o;if(t==this.contentDOM)n=t.childNodes[e];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;n=t.nextSibling}for(;n&&(!(o=n.pmViewDesc)||o.parent!=this);)n=n.nextSibling;return n?this.posBeforeChild(o):this.posAtEnd}}let o;if(t==this.dom&&this.contentDOM)o=e>Ve(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))o=2&t.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==e)for(let e=t;;e=e.parentNode){if(e==this.dom){o=!1;break}if(e.previousSibling)break}if(null==o&&e==t.childNodes.length)for(let e=t;;e=e.parentNode){if(e==this.dom){o=!0;break}if(e.nextSibling)break}}return(null==o?n>0:o)?this.posAtEnd:this.posAtStart}nearestDesc(t,e=!1){for(let n=!0,o=t;o;o=o.parentNode){let r,i=this.getDesc(o);if(i&&(!e||i.node)){if(!n||!(r=i.nodeDOM)||(1==r.nodeType?r.contains(1==t.nodeType?t:t.parentNode):r==t))return i;n=!1}}}getDesc(t){let e=t.pmViewDesc;for(let t=e;t;t=t.parent)if(t==this)return e}posFromDOM(t,e,n){for(let o=t;o;o=o.parentNode){let r=this.getDesc(o);if(r)return r.localPosFromDOM(t,e,n)}return-1}descAt(t){for(let e=0,n=0;e<this.children.length;e++){let o=this.children[e],r=n+o.size;if(n==t&&r!=n){for(;!o.border&&o.children.length;)for(let t=0;t<o.children.length;t++){let e=o.children[t];if(e.size){o=e;break}}return o}if(t<r)return o.descAt(t-n-o.border);n=r}}domFromPos(t,e){if(!this.contentDOM)return{node:this.dom,offset:0,atom:t+1};let n=0,o=0;for(let e=0;n<this.children.length;n++){let r=this.children[n],i=e+r.size;if(i>t||r instanceof Jn){o=t-e;break}e=i}if(o)return this.children[n].domFromPos(o-this.children[n].border,e);for(let t;n&&!(t=this.children[n-1]).size&&t instanceof Vn&&t.side>=0;n--);if(e<=0){let t,o=!0;for(;t=n?this.children[n-1]:null,t&&t.dom.parentNode!=this.contentDOM;n--,o=!1);return t&&e&&o&&!t.border&&!t.domAtom?t.domFromPos(t.size,e):{node:this.contentDOM,offset:t?Ve(t.dom)+1:0}}{let t,o=!0;for(;t=n<this.children.length?this.children[n]:null,t&&t.dom.parentNode!=this.contentDOM;n++,o=!1);return t&&o&&!t.border&&!t.domAtom?t.domFromPos(0,e):{node:this.contentDOM,offset:t?Ve(t.dom):this.contentDOM.childNodes.length}}}parseRange(t,e,n=0){if(0==this.children.length)return{node:this.contentDOM,from:t,to:e,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let o=-1,r=-1;for(let i=n,s=0;;s++){let n=this.children[s],l=i+n.size;if(-1==o&&t<=l){let r=i+n.border;if(t>=r&&e<=l-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(t,e,r);t=i;for(let e=s;e>0;e--){let n=this.children[e-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){o=Ve(n.dom)+1;break}t-=n.size}-1==o&&(o=0)}if(o>-1&&(l>e||s==this.children.length-1)){e=l;for(let t=s+1;t<this.children.length;t++){let n=this.children[t];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(-1)){r=Ve(n.dom);break}e+=n.size}-1==r&&(r=this.contentDOM.childNodes.length);break}i=l}return{node:this.contentDOM,from:t,to:e,fromOffset:o,toOffset:r}}emptyChildAt(t){if(this.border||!this.contentDOM||!this.children.length)return!1;let e=this.children[t<0?0:this.children.length-1];return 0==e.size||e.emptyChildAt(t)}domAfterPos(t){let{node:e,offset:n}=this.domFromPos(t,0);if(1!=e.nodeType||n==e.childNodes.length)throw new RangeError("No node after pos "+t);return e.childNodes[n]}setSelection(t,e,n,o=!1){let r=Math.min(t,e),i=Math.max(t,e);for(let s=0,l=0;s<this.children.length;s++){let a=this.children[s],c=l+a.size;if(r>l&&i<c)return a.setSelection(t-l-a.border,e-l-a.border,n,o);l=c}let s=this.domFromPos(t,t?-1:1),l=e==t?s:this.domFromPos(e,e?-1:1),a=n.root.getSelection(),c=n.domSelectionRange(),d=!1;if((ln||hn)&&t==e){let{node:t,offset:e}=s;if(3==t.nodeType){if(d=!(!e||"\n"!=t.nodeValue[e-1]),d&&e==t.nodeValue.length)for(let e,n=t;n;n=n.parentNode){if(e=n.nextSibling){"BR"==e.nodeName&&(s=l={node:e.parentNode,offset:Ve(e)+1});break}let t=n.pmViewDesc;if(t&&t.node&&t.node.isBlock)break}}else{let n=t.childNodes[e-1];d=n&&("BR"==n.nodeName||"false"==n.contentEditable)}}if(ln&&c.focusNode&&c.focusNode!=l.node&&1==c.focusNode.nodeType){let t=c.focusNode.childNodes[c.focusOffset];t&&"false"==t.contentEditable&&(o=!0)}if(!(o||d&&hn)&&qe(s.node,s.offset,c.anchorNode,c.anchorOffset)&&qe(l.node,l.offset,c.focusNode,c.focusOffset))return;let h=!1;if((a.extend||t==e)&&(!d||!ln)){a.collapse(s.node,s.offset);try{t!=e&&a.extend(l.node,l.offset),h=!0}catch(t){}}if(!h){if(t>e){let t=s;s=l,l=t}let n=document.createRange();n.setEnd(l.node,l.offset),n.setStart(s.node,s.offset),a.removeAllRanges(),a.addRange(n)}}ignoreMutation(t){return!this.contentDOM&&"selection"!=t.type}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(t,e){for(let n=0,o=0;o<this.children.length;o++){let r=this.children[o],i=n+r.size;if(n==i?t<=i&&e>=n:t<i&&e>n){let o=n+r.border,s=i-r.border;if(t>=o&&e<=s)return this.dirty=t==n||e==i?2:1,void(t!=o||e!=s||!r.contentLost&&r.dom.parentNode==this.contentDOM?r.markDirty(t-o,e-o):r.dirty=3);r.dirty=r.dom!=r.contentDOM||r.dom.parentNode!=this.contentDOM||r.children.length?3:2}n=i}this.dirty=2}markParentsDirty(){let t=1;for(let e=this.parent;e;e=e.parent,t++){let n=1==t?2:1;e.dirty<n&&(e.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(t){return!1}}class Vn extends Bn{constructor(t,e,n,o){let r,i=e.type.toDOM;if("function"==typeof i&&(i=i(n,()=>r?r.parent?r.parent.posBeforeChild(r):void 0:o)),!e.type.spec.raw){if(1!=i.nodeType){let t=document.createElement("span");t.appendChild(i),i=t}i.contentEditable="false",i.classList.add("ProseMirror-widget")}super(t,[],i,null),this.widget=e,this.widget=e,r=this}matchesWidget(t){return 0==this.dirty&&t.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(t){let e=this.widget.spec.stopEvent;return!!e&&e(t)}ignoreMutation(t){return"selection"!=t.type||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class _n extends Bn{constructor(t,e,n,o){super(t,[],e,null),this.textDOM=n,this.text=o}get size(){return this.text.length}localPosFromDOM(t,e){return t!=this.textDOM?this.posAtStart+(e?this.size:0):this.posAtStart+e}domFromPos(t){return{node:this.textDOM,offset:t}}ignoreMutation(t){return"characterData"===t.type&&t.target.nodeValue==t.oldValue}}class Fn extends Bn{constructor(t,e,n,o,r){super(t,[],n,o),this.mark=e,this.spec=r}static create(t,e,n,o){let r=o.nodeViews[e.type.name],i=r&&r(e,o,n);return i&&i.dom||(i=xt.renderSpec(document,e.type.spec.toDOM(e,n),null,e.attrs)),new Fn(t,e,i.dom,i.contentDOM||i.dom,i)}parseRule(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(t){return 3!=this.dirty&&this.mark.eq(t)}markDirty(t,e){if(super.markDirty(t,e),0!=this.dirty){let t=this.parent;for(;!t.node;)t=t.parent;t.dirty<this.dirty&&(t.dirty=this.dirty),this.dirty=0}}slice(t,e,n){let o=Fn.create(this.parent,this.mark,!0,n),r=this.children,i=this.size;e<i&&(r=so(r,e,i,n)),t>0&&(r=so(r,0,t,n));for(let t=0;t<r.length;t++)r[t].parent=o;return o.children=r,o}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class Wn extends Bn{constructor(t,e,n,o,r,i,s,l,a){super(t,[],r,i),this.node=e,this.outerDeco=n,this.innerDeco=o,this.nodeDOM=s}static create(t,e,n,o,r,i){let s,l=r.nodeViews[e.type.name],a=l&&l(e,r,()=>s?s.parent?s.parent.posBeforeChild(s):void 0:i,n,o),c=a&&a.dom,d=a&&a.contentDOM;if(e.isText)if(c){if(3!=c.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else c=document.createTextNode(e.text);else if(!c){let t=xt.renderSpec(document,e.type.spec.toDOM(e),null,e.attrs);({dom:c,contentDOM:d}=t)}d||e.isText||"BR"==c.nodeName||(c.hasAttribute("contenteditable")||(c.contentEditable="false"),e.type.spec.draggable&&(c.draggable=!0));let h=c;return c=eo(c,n,e),a?s=new Un(t,e,n,o,c,d||null,h,a,r,i+1):e.isText?new Kn(t,e,n,o,c,h,r):new Wn(t,e,n,o,c,d||null,h,r,i+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(t.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(let e=this.children.length-1;e>=0;e--){let n=this.children[e];if(this.dom.contains(n.dom.parentNode)){t.contentElement=n.dom.parentNode;break}}t.contentElement||(t.getContent=()=>k.empty)}else t.contentElement=this.contentDOM;else t.getContent=()=>this.node.content;return t}matchesNode(t,e,n){return 0==this.dirty&&t.eq(this.node)&&no(e,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(t,e){let n=this.node.inlineContent,o=e,r=t.composing?this.localCompositionInfo(t,e):null,i=r&&r.pos>-1?r:null,s=r&&r.pos<0,l=new ro(this,i&&i.node,t);!function(t,e,n,o){let r=e.locals(t),i=0;if(0==r.length){for(let n=0;n<t.childCount;n++){let s=t.child(n);o(s,r,e.forChild(i,s),n),i+=s.nodeSize}return}let s=0,l=[],a=null;for(let c=0;;){let d,h,p,u;for(;s<r.length&&r[s].to==i;){let t=r[s++];t.widget&&(d?(h||(h=[d])).push(t):d=t)}if(d)if(h){h.sort(io);for(let t=0;t<h.length;t++)n(h[t],c,!!a)}else n(d,c,!!a);if(a)u=-1,p=a,a=null;else{if(!(c<t.childCount))break;u=c,p=t.child(c++)}for(let t=0;t<l.length;t++)l[t].to<=i&&l.splice(t--,1);for(;s<r.length&&r[s].from<=i&&r[s].to>i;)l.push(r[s++]);let f=i+p.nodeSize;if(p.isText){let t=f;s<r.length&&r[s].from<t&&(t=r[s].from);for(let e=0;e<l.length;e++)l[e].to<t&&(t=l[e].to);t<f&&(a=p.cut(t-i),p=p.cut(0,t-i),f=t,u=-1)}else for(;s<r.length&&r[s].to<f;)s++;o(p,p.isInline&&!p.isLeaf?l.filter(t=>!t.inline):l.slice(),e.forChild(i,p),u),i=f}}(this.node,this.innerDeco,(e,r,i)=>{e.spec.marks?l.syncToMarks(e.spec.marks,n,t):e.type.side>=0&&!i&&l.syncToMarks(r==this.node.childCount?S.none:this.node.child(r).marks,n,t),l.placeWidget(e,t,o)},(e,i,a,c)=>{let d;l.syncToMarks(e.marks,n,t),l.findNodeMatch(e,i,a,c)||s&&t.state.selection.from>o&&t.state.selection.to<o+e.nodeSize&&(d=l.findIndexWithChild(r.node))>-1&&l.updateNodeAt(e,i,a,d,t)||l.updateNextNode(e,i,a,t,c,o)||l.addNode(e,i,a,t,o),o+=e.nodeSize}),l.syncToMarks([],n,t),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||2==this.dirty)&&(i&&this.protectLocalComposition(t,i),Gn(this.contentDOM,this.children,t),pn&&function(t){if("UL"==t.nodeName||"OL"==t.nodeName){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}(this.dom))}localCompositionInfo(t,e){let{from:n,to:o}=t.state.selection;if(!(t.state.selection instanceof xe)||n<e||o>e+this.node.content.size)return null;let r=t.input.compositionNode;if(!r||!this.dom.contains(r.parentNode))return null;if(this.node.inlineContent){let t=r.nodeValue,i=function(t,e,n,o){for(let r=0,i=0;r<t.childCount&&i<=o;){let s=t.child(r++),l=i;if(i+=s.nodeSize,!s.isText)continue;let a=s.text;for(;r<t.childCount;){let e=t.child(r++);if(i+=e.nodeSize,!e.isText)break;a+=e.text}if(i>=n){if(i>=o&&a.slice(o-e.length-l,o-l)==e)return o-e.length;let t=l<o?a.lastIndexOf(e,o-l-1):-1;if(t>=0&&t+e.length+l>=n)return l+t;if(n==o&&a.length>=o+e.length-l&&a.slice(o-l,o-l+e.length)==e)return o}}return-1}(this.node.content,t,n-e,o-e);return i<0?null:{node:r,pos:i,text:t}}return{node:r,pos:-1,text:""}}protectLocalComposition(t,{node:e,pos:n,text:o}){if(this.getDesc(e))return;let r=e;for(;r.parentNode!=this.contentDOM;r=r.parentNode){for(;r.previousSibling;)r.parentNode.removeChild(r.previousSibling);for(;r.nextSibling;)r.parentNode.removeChild(r.nextSibling);r.pmViewDesc&&(r.pmViewDesc=void 0)}let i=new _n(this,r,e,o);t.input.compositionNodes.push(i),this.children=so(this.children,n,n+o.length,t,i)}update(t,e,n,o){return!(3==this.dirty||!t.sameMarkup(this.node)||(this.updateInner(t,e,n,o),0))}updateInner(t,e,n,o){this.updateOuterDeco(e),this.node=t,this.innerDeco=n,this.contentDOM&&this.updateChildren(o,this.posAtStart),this.dirty=0}updateOuterDeco(t){if(no(t,this.outerDeco))return;let e=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=Zn(this.dom,this.nodeDOM,Qn(this.outerDeco,this.node,e),Qn(t,this.node,e)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=t}selectNode(){1==this.nodeDOM.nodeType&&this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.dom.draggable=!0)}deselectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function qn(t,e,n,o,r){eo(o,e,t);let i=new Wn(void 0,t,e,n,o,o,o,r,0);return i.contentDOM&&i.updateChildren(r,0),i}class Kn extends Wn{constructor(t,e,n,o,r,i,s){super(t,e,n,o,r,null,i,s,0)}parseRule(){let t=this.nodeDOM.parentNode;for(;t&&t!=this.dom&&!t.pmIsDeco;)t=t.parentNode;return{skip:t||!0}}update(t,e,n,o){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,o.trackWrites==this.nodeDOM&&(o.trackWrites=null)),this.node=t,this.dirty=0,0))}inParent(){let t=this.parent.contentDOM;for(let e=this.nodeDOM;e;e=e.parentNode)if(e==t)return!0;return!1}domFromPos(t){return{node:this.nodeDOM,offset:t}}localPosFromDOM(t,e,n){return t==this.nodeDOM?this.posAtStart+Math.min(e,this.node.text.length):super.localPosFromDOM(t,e,n)}ignoreMutation(t){return"characterData"!=t.type&&"selection"!=t.type}slice(t,e,n){let o=this.node.cut(t,e),r=document.createTextNode(o.text);return new Kn(this.parent,o,this.outerDeco,this.innerDeco,r,r,n)}markDirty(t,e){super.markDirty(t,e),this.dom==this.nodeDOM||0!=t&&e!=this.nodeDOM.nodeValue.length||(this.dirty=3)}get domAtom(){return!1}isText(t){return this.node.text==t}}class Jn extends Bn{parseRule(){return{ignore:!0}}matchesHack(t){return 0==this.dirty&&this.dom.nodeName==t}get domAtom(){return!0}get ignoreForCoords(){return"IMG"==this.dom.nodeName}}class Un extends Wn{constructor(t,e,n,o,r,i,s,l,a,c){super(t,e,n,o,r,i,s,a,c),this.spec=l}update(t,e,n,o){if(3==this.dirty)return!1;if(this.spec.update&&(this.node.type==t.type||this.spec.multiType)){let r=this.spec.update(t,e,n);return r&&this.updateInner(t,e,n,o),r}return!(!this.contentDOM&&!t.isLeaf)&&super.update(t,e,n,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(t,e,n,o){this.spec.setSelection?this.spec.setSelection(t,e,n.root):super.setSelection(t,e,n,o)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(t){return!!this.spec.stopEvent&&this.spec.stopEvent(t)}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}}function Gn(t,e,n){let o=t.firstChild,r=!1;for(let i=0;i<e.length;i++){let s=e[i],l=s.dom;if(l.parentNode==t){for(;l!=o;)o=oo(o),r=!0;o=o.nextSibling}else r=!0,t.insertBefore(l,o);if(s instanceof Fn){let e=o?o.previousSibling:t.lastChild;Gn(s.contentDOM,s.children,n),o=e?e.nextSibling:t.firstChild}}for(;o;)o=oo(o),r=!0;r&&n.trackWrites==t&&(n.trackWrites=null)}const Yn=function(t){t&&(this.nodeName=t)};Yn.prototype=Object.create(null);const Xn=[new Yn];function Qn(t,e,n){if(0==t.length)return Xn;let o=n?Xn[0]:new Yn,r=[o];for(let i=0;i<t.length;i++){let s=t[i].type.attrs;if(s){s.nodeName&&r.push(o=new Yn(s.nodeName));for(let t in s){let i=s[t];null!=i&&(n&&1==r.length&&r.push(o=new Yn(e.isInline?"span":"div")),"class"==t?o.class=(o.class?o.class+" ":"")+i:"style"==t?o.style=(o.style?o.style+";":"")+i:"nodeName"!=t&&(o[t]=i))}}}return r}function Zn(t,e,n,o){if(n==Xn&&o==Xn)return e;let r=e;for(let e=0;e<o.length;e++){let i=o[e],s=n[e];if(e){let e;s&&s.nodeName==i.nodeName&&r!=t&&(e=r.parentNode)&&e.nodeName.toLowerCase()==i.nodeName||(e=document.createElement(i.nodeName),e.pmIsDeco=!0,e.appendChild(r),s=Xn[0]),r=e}to(r,s||Xn[0],i)}return r}function to(t,e,n){for(let o in e)"class"==o||"style"==o||"nodeName"==o||o in n||t.removeAttribute(o);for(let o in n)"class"!=o&&"style"!=o&&"nodeName"!=o&&n[o]!=e[o]&&t.setAttribute(o,n[o]);if(e.class!=n.class){let o=e.class?e.class.split(" ").filter(Boolean):[],r=n.class?n.class.split(" ").filter(Boolean):[];for(let e=0;e<o.length;e++)-1==r.indexOf(o[e])&&t.classList.remove(o[e]);for(let e=0;e<r.length;e++)-1==o.indexOf(r[e])&&t.classList.add(r[e]);0==t.classList.length&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let n,o=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;for(;n=o.exec(e.style);)t.style.removeProperty(n[1])}n.style&&(t.style.cssText+=n.style)}}function eo(t,e,n){return Zn(t,t,Xn,Qn(e,n,1!=t.nodeType))}function no(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return!1;return!0}function oo(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class ro{constructor(t,e,n){this.lock=e,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=t,this.preMatch=function(t,e){let n=e,o=n.children.length,r=t.childCount,i=new Map,s=[];t:for(;r>0;){let l;for(;;)if(o){let t=n.children[o-1];if(!(t instanceof Fn)){l=t,o--;break}n=t,o=t.children.length}else{if(n==e)break t;o=n.parent.children.indexOf(n),n=n.parent}let a=l.node;if(a){if(a!=t.child(r-1))break;--r,i.set(l,r),s.push(l)}}return{index:r,matched:i,matches:s.reverse()}}(t.node.content,t)}destroyBetween(t,e){if(t!=e){for(let n=t;n<e;n++)this.top.children[n].destroy();this.top.children.splice(t,e-t),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(t,e,n){let o=0,r=this.stack.length>>1,i=Math.min(r,t.length);for(;o<i&&(o==r-1?this.top:this.stack[o+1<<1]).matchesMark(t[o])&&!1!==t[o].type.spec.spanning;)o++;for(;o<r;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),r--;for(;r<t.length;){this.stack.push(this.top,this.index+1);let o=-1;for(let e=this.index;e<Math.min(this.index+3,this.top.children.length);e++){let n=this.top.children[e];if(n.matchesMark(t[r])&&!this.isLocked(n.dom)){o=e;break}}if(o>-1)o>this.index&&(this.changed=!0,this.destroyBetween(this.index,o)),this.top=this.top.children[this.index];else{let o=Fn.create(this.top,t[r],e,n);this.top.children.splice(this.index,0,o),this.top=o,this.changed=!0}this.index=0,r++}}findNodeMatch(t,e,n,o){let r,i=-1;if(o>=this.preMatch.index&&(r=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&r.matchesNode(t,e,n))i=this.top.children.indexOf(r,this.index);else for(let o=this.index,r=Math.min(this.top.children.length,o+5);o<r;o++){let r=this.top.children[o];if(r.matchesNode(t,e,n)&&!this.preMatch.matched.has(r)){i=o;break}}return!(i<0||(this.destroyBetween(this.index,i),this.index++,0))}updateNodeAt(t,e,n,o,r){let i=this.top.children[o];return 3==i.dirty&&i.dom==i.contentDOM&&(i.dirty=2),!!i.update(t,e,n,r)&&(this.destroyBetween(this.index,o),this.index++,!0)}findIndexWithChild(t){for(;;){let e=t.parentNode;if(!e)return-1;if(e==this.top.contentDOM){let e=t.pmViewDesc;if(e)for(let t=this.index;t<this.top.children.length;t++)if(this.top.children[t]==e)return t;return-1}t=e}}updateNextNode(t,e,n,o,r,i){for(let s=this.index;s<this.top.children.length;s++){let l=this.top.children[s];if(l instanceof Wn){let a=this.preMatch.matched.get(l);if(null!=a&&a!=r)return!1;let c,d=l.dom,h=this.isLocked(d)&&!(t.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==t.text&&3!=l.dirty&&no(e,l.outerDeco));if(!h&&l.update(t,e,n,o))return this.destroyBetween(this.index,s),l.dom!=d&&(this.changed=!0),this.index++,!0;if(!h&&(c=this.recreateWrapper(l,t,e,n,o,i)))return this.destroyBetween(this.index,s),this.top.children[this.index]=c,c.contentDOM&&(c.dirty=2,c.updateChildren(o,i+1),c.dirty=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(t,e,n,o,r,i){if(t.dirty||e.isAtom||!t.children.length||!t.node.content.eq(e.content)||!no(n,t.outerDeco)||!o.eq(t.innerDeco))return null;let s=Wn.create(this.top,e,n,o,r,i);if(s.contentDOM){s.children=t.children,t.children=[];for(let t of s.children)t.parent=s}return t.destroy(),s}addNode(t,e,n,o,r){let i=Wn.create(this.top,t,e,n,o,r);i.contentDOM&&i.updateChildren(o,r+1),this.top.children.splice(this.index++,0,i),this.changed=!0}placeWidget(t,e,n){let o=this.index<this.top.children.length?this.top.children[this.index]:null;if(!o||!o.matchesWidget(t)||t!=o.widget&&o.widget.type.toDOM.parentNode){let o=new Vn(this.top,t,e,n);this.top.children.splice(this.index++,0,o),this.changed=!0}else this.index++}addTextblockHacks(){let t=this.top.children[this.index-1],e=this.top;for(;t instanceof Fn;)e=t,t=e.children[e.children.length-1];(!t||!(t instanceof Kn)||/\n$/.test(t.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(t.node.text))&&((hn||cn)&&t&&"false"==t.dom.contentEditable&&this.addHackNode("IMG",e),this.addHackNode("BR",this.top))}addHackNode(t,e){if(e==this.top&&this.index<e.children.length&&e.children[this.index].matchesHack(t))this.index++;else{let n=document.createElement(t);"IMG"==t&&(n.className="ProseMirror-separator",n.alt=""),"BR"==t&&(n.className="ProseMirror-trailingBreak");let o=new Jn(this.top,[],n,null);e!=this.top?e.children.push(o):e.children.splice(this.index++,0,o),this.changed=!0}}isLocked(t){return this.lock&&(t==this.lock||1==t.nodeType&&t.contains(this.lock.parentNode))}}function io(t,e){return t.type.side-e.type.side}function so(t,e,n,o,r){let i=[];for(let s=0,l=0;s<t.length;s++){let a=t[s],c=l,d=l+=a.size;c>=n||d<=e?i.push(a):(c<e&&i.push(a.slice(0,e-c,o)),r&&(i.push(r),r=void 0),d>n&&i.push(a.slice(n-c,a.size,o)))}return i}function lo(t,e=null){let n=t.domSelectionRange(),o=t.state.doc;if(!n.focusNode)return null;let r=t.docView.nearestDesc(n.focusNode),i=r&&0==r.size,s=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let l,a,c=o.resolve(s);if(Ye(n)){for(l=s;r&&!r.node;)r=r.parent;let t=r.node;if(r&&t.isAtom&&Ce.isSelectable(t)&&r.parent&&(!t.isInline||!function(t,e,n){for(let o=0==e,r=e==Ue(t);o||r;){if(t==n)return!0;let e=Ve(t);if(!(t=t.parentNode))return!1;o=o&&0==e,r=r&&e==Ue(t)}}(n.focusNode,n.focusOffset,r.dom))){let t=r.posBefore;a=new Ce(s==t?c:o.resolve(t))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let e=s,r=s;for(let o=0;o<n.rangeCount;o++){let i=n.getRangeAt(o);e=Math.min(e,t.docView.posFromDOM(i.startContainer,i.startOffset,1)),r=Math.max(r,t.docView.posFromDOM(i.endContainer,i.endOffset,-1))}if(e<0)return null;[l,s]=r==t.state.selection.anchor?[r,e]:[e,r],c=o.resolve(s)}else l=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(l<0)return null}let d=o.resolve(l);return a||(a=yo(t,d,c,"pointer"==e||t.state.selection.head<c.pos&&!i?1:-1)),a}function ao(t){return t.editable?t.hasFocus():vo(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function co(t,e=!1){let n=t.state.selection;if(mo(t,n),ao(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&cn){let e=t.domSelectionRange(),n=t.domObserver.currentSelection;if(e.anchorNode&&n.anchorNode&&qe(e.anchorNode,e.anchorOffset,n.anchorNode,n.anchorOffset))return t.input.mouseDown.delayedSelectionSync=!0,void t.domObserver.setCurSelection()}if(t.domObserver.disconnectSelection(),t.cursorWrapper)!function(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,o="IMG"==n.nodeName;o?e.collapse(n.parentNode,Ve(n)+1):e.collapse(n,0),!o&&!t.state.selection.visible&&rn&&sn<=11&&(n.disabled=!0,n.disabled=!1)}(t);else{let o,r,{anchor:i,head:s}=n;!ho||n instanceof xe||(n.$from.parent.inlineContent||(o=po(t,n.from)),n.empty||n.$from.parent.inlineContent||(r=po(t,n.to))),t.docView.setSelection(i,s,t,e),ho&&(o&&fo(o),r&&fo(r)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),o=n.anchorNode,r=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{n.anchorNode==o&&n.anchorOffset==r||(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{ao(t)&&!t.state.selection.visible||t.dom.classList.remove("ProseMirror-hideselection")},20))})}(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const ho=hn||cn&&dn<63;function po(t,e){let{node:n,offset:o}=t.docView.domFromPos(e,0),r=o<n.childNodes.length?n.childNodes[o]:null,i=o?n.childNodes[o-1]:null;if(hn&&r&&"false"==r.contentEditable)return uo(r);if(!(r&&"false"!=r.contentEditable||i&&"false"!=i.contentEditable)){if(r)return uo(r);if(i)return uo(i)}}function uo(t){return t.contentEditable="true",hn&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function fo(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function mo(t,e){if(e instanceof Ce){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(go(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else go(t)}function go(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function yo(t,e,n,o){return t.someProp("createSelectionBetween",o=>o(t,e,n))||xe.between(e,n,o)}function bo(t){return!(t.editable&&!t.hasFocus())&&vo(t)}function vo(t){let e=t.domSelectionRange();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 wo(t,e){let{$anchor:n,$head:o}=t.selection,r=e>0?n.max(o):n.min(o),i=r.parent.inlineContent?r.depth?t.doc.resolve(e>0?r.after():r.before()):null:r;return i&&be.findFrom(i,e)}function ko(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function xo(t,e,n){let o=t.state.selection;if(!(o instanceof xe)){if(o instanceof Ce&&o.node.isInline)return ko(t,new xe(e>0?o.$to:o.$from));{let n=wo(t.state,e);return!!n&&ko(t,n)}}if(n.indexOf("s")>-1){let{$head:n}=o,r=n.textOffset?null:e<0?n.nodeBefore:n.nodeAfter;if(!r||r.isText||!r.isLeaf)return!1;let i=t.state.doc.resolve(n.pos+r.nodeSize*(e<0?-1:1));return ko(t,new xe(o.$anchor,i))}if(!o.empty)return!1;if(t.endOfTextblock(e>0?"forward":"backward")){let n=wo(t.state,e);return!!(n&&n instanceof Ce)&&ko(t,n)}if(!(un&&n.indexOf("m")>-1)){let n,r=o.$head,i=r.textOffset?null:e<0?r.nodeBefore:r.nodeAfter;if(!i||i.isText)return!1;let s=e<0?r.pos-i.nodeSize:r.pos;return!!(i.isAtom||(n=t.docView.descAt(s))&&!n.contentDOM)&&(Ce.isSelectable(i)?ko(t,new Ce(e<0?t.state.doc.resolve(r.pos-i.nodeSize):r)):!!gn&&ko(t,new xe(t.state.doc.resolve(e<0?s:s+i.nodeSize))))}}function Mo(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function Co(t,e){let n=t.pmViewDesc;return n&&0==n.size&&(e<0||t.nextSibling||"BR"!=t.nodeName)}function So(t,e){return e<0?function(t){let e=t.domSelectionRange(),n=e.focusNode,o=e.focusOffset;if(!n)return;let r,i,s=!1;for(ln&&1==n.nodeType&&o<Mo(n)&&Co(n.childNodes[o],-1)&&(s=!0);;)if(o>0){if(1!=n.nodeType)break;{let t=n.childNodes[o-1];if(Co(t,-1))r=n,i=--o;else{if(3!=t.nodeType)break;n=t,o=n.nodeValue.length}}}else{if(To(n))break;{let e=n.previousSibling;for(;e&&Co(e,-1);)r=n.parentNode,i=Ve(e),e=e.previousSibling;if(e)n=e,o=Mo(n);else{if(n=n.parentNode,n==t.dom)break;o=0}}}s?Ao(t,n,o):r&&Ao(t,r,i)}(t):function(t){let e=t.domSelectionRange(),n=e.focusNode,o=e.focusOffset;if(!n)return;let r,i,s=Mo(n);for(;;)if(o<s){if(1!=n.nodeType)break;if(!Co(n.childNodes[o],1))break;r=n,i=++o}else{if(To(n))break;{let e=n.nextSibling;for(;e&&Co(e,1);)r=e.parentNode,i=Ve(e)+1,e=e.nextSibling;if(e)n=e,o=0,s=Mo(n);else{if(n=n.parentNode,n==t.dom)break;o=s=0}}}r&&Ao(t,r,i)}(t)}function To(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function Ao(t,e,n){if(3!=e.nodeType){let t,o;(o=function(t,e){for(;t&&e==t.childNodes.length&&!Ge(t);)e=Ve(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;t=n,e=0}}(e,n))?(e=o,n=0):(t=function(t,e){for(;t&&!e&&!Ge(t);)e=Ve(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;e=(t=n).childNodes.length}}(e,n))&&(e=t,n=t.nodeValue.length)}let o=t.domSelection();if(!o)return;if(Ye(o)){let t=document.createRange();t.setEnd(e,n),t.setStart(e,n),o.removeAllRanges(),o.addRange(t)}else o.extend&&o.extend(e,n);t.domObserver.setCurSelection();let{state:r}=t;setTimeout(()=>{t.state==r&&co(t)},50)}function Eo(t,e){let n=t.state.doc.resolve(e);if(!cn&&!fn&&n.parent.inlineContent){let o=t.coordsAtPos(e);if(e>n.start()){let n=t.coordsAtPos(e-1),r=(n.top+n.bottom)/2;if(r>o.top&&r<o.bottom&&Math.abs(n.left-o.left)>1)return n.left<o.left?"ltr":"rtl"}if(e<n.end()){let n=t.coordsAtPos(e+1),r=(n.top+n.bottom)/2;if(r>o.top&&r<o.bottom&&Math.abs(n.left-o.left)>1)return n.left>o.left?"ltr":"rtl"}}return"rtl"==getComputedStyle(t.dom).direction?"rtl":"ltr"}function Oo(t,e,n){let o=t.state.selection;if(o instanceof xe&&!o.empty||n.indexOf("s")>-1)return!1;if(un&&n.indexOf("m")>-1)return!1;let{$from:r,$to:i}=o;if(!r.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let n=wo(t.state,e);if(n&&n instanceof Ce)return ko(t,n)}if(!r.parent.inlineContent){let n=e<0?r:i,s=o instanceof Te?be.near(n,e):be.findFrom(n,e);return!!s&&ko(t,s)}return!1}function No(t,e){if(!(t.state.selection instanceof xe))return!0;let{$head:n,$anchor:o,empty:r}=t.state.selection;if(!n.sameParent(o))return!0;if(!r)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let o=t.state.tr;return e<0?o.delete(n.pos-i.nodeSize,n.pos):o.delete(n.pos,n.pos+i.nodeSize),t.dispatch(o),!0}return!1}function Do(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function Lo(t,e){t.someProp("transformCopied",n=>{e=n(e,t)});let n=[],{content:o,openStart:r,openEnd:i}=e;for(;r>1&&i>1&&1==o.childCount&&1==o.firstChild.childCount;){r--,i--;let t=o.firstChild;n.push(t.type.name,t.attrs!=t.type.defaultAttrs?t.attrs:null),o=t.content}let s=t.someProp("clipboardSerializer")||xt.fromSchema(t.state.schema),l=_o(),a=l.createElement("div");a.appendChild(s.serializeFragment(o,{document:l}));let c,d=a.firstChild,h=0;for(;d&&1==d.nodeType&&(c=Bo[d.nodeName.toLowerCase()]);){for(let t=c.length-1;t>=0;t--){let e=l.createElement(c[t]);for(;a.firstChild;)e.appendChild(a.firstChild);a.appendChild(e),h++}d=a.firstChild}return d&&1==d.nodeType&&d.setAttribute("data-pm-slice",`${r} ${i}${h?` -${h}`:""} ${JSON.stringify(n)}`),{dom:a,text:t.someProp("clipboardTextSerializer",n=>n(e,t))||e.content.textBetween(0,e.content.size,"\n\n"),slice:e}}function Ro(t,e,n,o,r){let i,s,l=r.parent.type.spec.code;if(!n&&!e)return null;let a=!!e&&(o||l||!n);if(a){if(t.someProp("transformPastedText",n=>{e=n(e,l||o,t)}),l)return s=new A(k.from(t.state.schema.text(e.replace(/\r\n?/g,"\n"))),0,0),t.someProp("transformPasted",e=>{s=e(s,t,!0)}),s;let n=t.someProp("clipboardTextParser",n=>n(e,r,o,t));if(n)s=n;else{let n=r.marks(),{schema:o}=t.state,s=xt.fromSchema(o);i=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(t=>{let e=i.appendChild(document.createElement("p"));t&&e.appendChild(s.serializeNode(o.text(t,n)))})}}else t.someProp("transformPastedHTML",e=>{n=e(n,t)}),i=function(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n,o=_o().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t);if((n=r&&Bo[r[1].toLowerCase()])&&(t=n.map(t=>"<"+t+">").join("")+t+n.map(t=>"</"+t+">").reverse().join("")),o.innerHTML=function(t){let e=window.trustedTypes;return e?(Fo||(Fo=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),Fo.createHTML(t)):t}(t),n)for(let t=0;t<n.length;t++)o=o.querySelector(n[t])||o;return o}(n),gn&&function(t){let e=t.querySelectorAll(cn?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let o=e[n];1==o.childNodes.length&&" "==o.textContent&&o.parentNode&&o.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),o)}}(i);let c=i&&i.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let t=+d[3];t>0;t--){let t=i.firstChild;for(;t&&1!=t.nodeType;)t=t.nextSibling;if(!t)break;i=t}if(!s){let e=t.someProp("clipboardParser")||t.someProp("domParser")||pt.fromSchema(t.state.schema);s=e.parseSlice(i,{preserveWhitespace:!(!a&&!d),context:r,ruleFromNode:t=>"BR"!=t.nodeName||t.nextSibling||!t.parentNode||jo.test(t.parentNode.nodeName)?null:{ignore:!0}})}if(d)s=function(t,e){if(!t.size)return t;let n,o=t.content.firstChild.type.schema;try{n=JSON.parse(e)}catch(e){return t}let{content:r,openStart:i,openEnd:s}=t;for(let t=n.length-2;t>=0;t-=2){let e=o.nodes[n[t]];if(!e||e.hasRequiredAttrs())break;r=k.from(e.create(n[t+1],r)),i++,s++}return new A(r,i,s)}(Ho(s,+d[1],+d[2]),d[4]);else if(s=A.maxOpen(function(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let o,r=e.node(n).contentMatchAt(e.index(n)),i=[];if(t.forEach(t=>{if(!i)return;let e,n=r.findWrapping(t.type);if(!n)return i=null;if(e=i.length&&o.length&&Po(n,o,t,i[i.length-1],0))i[i.length-1]=e;else{i.length&&(i[i.length-1]=zo(i[i.length-1],o.length));let e=Io(t,n);i.push(e),r=r.matchType(e.type),o=n}}),i)return k.from(i)}return t}(s.content,r),!0),s.openStart||s.openEnd){let t=0,e=0;for(let e=s.content.firstChild;t<s.openStart&&!e.type.spec.isolating;t++,e=e.firstChild);for(let t=s.content.lastChild;e<s.openEnd&&!t.type.spec.isolating;e++,t=t.lastChild);s=Ho(s,t,e)}return t.someProp("transformPasted",e=>{s=e(s,t,a)}),s}const jo=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function Io(t,e,n=0){for(let o=e.length-1;o>=n;o--)t=e[o].create(null,k.from(t));return t}function Po(t,e,n,o,r){if(r<t.length&&r<e.length&&t[r]==e[r]){let i=Po(t,e,n,o.lastChild,r+1);if(i)return o.copy(o.content.replaceChild(o.childCount-1,i));if(o.contentMatchAt(o.childCount).matchType(r==t.length-1?n.type:t[r+1]))return o.copy(o.content.append(k.from(Io(n,t,r+1))))}}function zo(t,e){if(0==e)return t;let n=t.content.replaceChild(t.childCount-1,zo(t.lastChild,e-1)),o=t.contentMatchAt(t.childCount).fillBefore(k.empty,!0);return t.copy(n.append(o))}function $o(t,e,n,o,r,i){let s=e<0?t.firstChild:t.lastChild,l=s.content;return t.childCount>1&&(i=0),r<o-1&&(l=$o(l,e,n,o,r+1,i)),r>=n&&(l=e<0?s.contentMatchAt(0).fillBefore(l,i<=r).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(k.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,s.copy(l))}function Ho(t,e,n){return e<t.openStart&&(t=new A($o(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new A($o(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const Bo={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let Vo=null;function _o(){return Vo||(Vo=document.implementation.createHTMLDocument("title"))}let Fo=null;const Wo={},qo={},Ko={touchstart:!0,touchmove:!0};class Jo{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function Uo(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function Go(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=e=>Yo(t,e))})}function Yo(t,e){return t.someProp("handleDOMEvents",n=>{let o=n[e.type];return!!o&&(o(t,e)||e.defaultPrevented)})}function Xo(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function Qo(t){return{left:t.clientX,top:t.clientY}}function Zo(t,e,n,o,r){if(-1==o)return!1;let i=t.state.doc.resolve(o);for(let o=i.depth+1;o>0;o--)if(t.someProp(e,e=>o>i.depth?e(t,n,i.nodeAfter,i.before(o),r,!0):e(t,n,i.node(o),i.before(o),r,!1)))return!0;return!1}function tr(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let o=t.state.tr.setSelection(e);"pointer"==n&&o.setMeta("pointer",!0),t.dispatch(o)}function er(t,e,n,o){return Zo(t,"handleDoubleClickOn",e,n,o)||t.someProp("handleDoubleClick",n=>n(t,e,o))}function nr(t,e,n,o){return Zo(t,"handleTripleClickOn",e,n,o)||t.someProp("handleTripleClick",n=>n(t,e,o))||function(t,e,n){if(0!=n.button)return!1;let o=t.state.doc;if(-1==e)return!!o.inlineContent&&(tr(t,xe.create(o,0,o.content.size),"pointer"),!0);let r=o.resolve(e);for(let e=r.depth+1;e>0;e--){let n=e>r.depth?r.nodeAfter:r.node(e),i=r.before(e);if(n.inlineContent)tr(t,xe.create(o,i+1,i+1+n.content.size),"pointer");else{if(!Ce.isSelectable(n))continue;tr(t,Ce.create(o,i),"pointer")}return!0}}(t,n,o)}function or(t){return dr(t)}qo.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=16==n.keyCode||n.shiftKey,!sr(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!mn||!cn||13!=n.keyCode))if(229!=n.keyCode&&t.domObserver.forceFlush(),!pn||13!=n.keyCode||n.ctrlKey||n.altKey||n.metaKey)t.someProp("handleKeyDown",e=>e(t,n))||function(t,e){let n=e.keyCode,o=function(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}(e);if(8==n||un&&72==n&&"c"==o)return No(t,-1)||So(t,-1);if(46==n&&!e.shiftKey||un&&68==n&&"c"==o)return No(t,1)||So(t,1);if(13==n||27==n)return!0;if(37==n||un&&66==n&&"c"==o){let e=37==n?"ltr"==Eo(t,t.state.selection.from)?-1:1:-1;return xo(t,e,o)||So(t,e)}if(39==n||un&&70==n&&"c"==o){let e=39==n?"ltr"==Eo(t,t.state.selection.from)?1:-1:1;return xo(t,e,o)||So(t,e)}return 38==n||un&&80==n&&"c"==o?Oo(t,-1,o)||So(t,-1):40==n||un&&78==n&&"c"==o?function(t){if(!hn||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&1==e.nodeType&&0==n&&e.firstChild&&"false"==e.firstChild.contentEditable){let n=e.firstChild;Do(t,n,"true"),setTimeout(()=>Do(t,n,"false"),20)}return!1}(t)||Oo(t,1,o)||So(t,1):o==(un?"m":"c")&&(66==n||73==n||89==n||90==n)}(t,n)?n.preventDefault():Uo(t,"key");else{let e=Date.now();t.input.lastIOSEnter=e,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==e&&(t.someProp("handleKeyDown",e=>e(t,Xe(13,"Enter"))),t.input.lastIOSEnter=0)},200)}},qo.keyup=(t,e)=>{16==e.keyCode&&(t.input.shiftKey=!1)},qo.keypress=(t,e)=>{let n=e;if(sr(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||un&&n.metaKey)return;if(t.someProp("handleKeyPress",e=>e(t,n)))return void n.preventDefault();let o=t.state.selection;if(!(o instanceof xe&&o.$from.sameParent(o.$to))){let e=String.fromCharCode(n.charCode),r=()=>t.state.tr.insertText(e).scrollIntoView();/[\r\n]/.test(e)||t.someProp("handleTextInput",n=>n(t,o.$from.pos,o.$to.pos,e,r))||t.dispatch(r()),n.preventDefault()}};const rr=un?"metaKey":"ctrlKey";Wo.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let o=or(t),r=Date.now(),i="singleClick";r-t.input.lastClick.time<500&&function(t,e){let n=e.x-t.clientX,o=e.y-t.clientY;return n*n+o*o<100}(n,t.input.lastClick)&&!n[rr]&&t.input.lastClick.button==n.button&&("singleClick"==t.input.lastClick.type?i="doubleClick":"doubleClick"==t.input.lastClick.type&&(i="tripleClick")),t.input.lastClick={time:r,x:n.clientX,y:n.clientY,type:i,button:n.button};let s=t.posAtCoords(Qo(n));s&&("singleClick"==i?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new ir(t,s,n,!!o)):("doubleClick"==i?er:nr)(t,s.pos,s.inside,n)?n.preventDefault():Uo(t,"pointer"))};class ir{constructor(t,e,n,o){let r,i;if(this.view=t,this.pos=e,this.event=n,this.flushed=o,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=t.state.doc,this.selectNode=!!n[rr],this.allowDefault=n.shiftKey,e.inside>-1)r=t.state.doc.nodeAt(e.inside),i=e.inside;else{let n=t.state.doc.resolve(e.pos);r=n.parent,i=n.depth?n.before():0}const s=o?null:n.target,l=s?t.docView.nearestDesc(s,!0):null;this.target=l&&1==l.dom.nodeType?l.dom:null;let{selection:a}=t.state;(0==n.button&&r.type.spec.draggable&&!1!==r.type.spec.selectable||a instanceof Ce&&a.from<=i&&a.to>i)&&(this.mightDrag={node:r,pos:i,addAttr:!(!this.target||this.target.draggable),setUneditable:!(!this.target||!ln||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(()=>{this.view.input.mouseDown==this&&this.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)),Uo(t,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>co(this.view)),this.view.input.mouseDown=null}up(t){if(this.done(),!this.view.dom.contains(t.target))return;let e=this.pos;this.view.state.doc!=this.startDoc&&(e=this.view.posAtCoords(Qo(t))),this.updateAllowDefault(t),this.allowDefault||!e?Uo(this.view,"pointer"):function(t,e,n,o,r){return Zo(t,"handleClickOn",e,n,o)||t.someProp("handleClick",n=>n(t,e,o))||(r?function(t,e){if(-1==e)return!1;let n,o,r=t.state.selection;r instanceof Ce&&(n=r.node);let i=t.state.doc.resolve(e);for(let t=i.depth+1;t>0;t--){let e=t>i.depth?i.nodeAfter:i.node(t);if(Ce.isSelectable(e)){o=n&&r.$from.depth>0&&t>=r.$from.depth&&i.before(r.$from.depth+1)==r.$from.pos?i.before(r.$from.depth):i.before(t);break}}return null!=o&&(tr(t,Ce.create(t.state.doc,o),"pointer"),!0)}(t,n):function(t,e){if(-1==e)return!1;let n=t.state.doc.resolve(e),o=n.nodeAfter;return!!(o&&o.isAtom&&Ce.isSelectable(o))&&(tr(t,new Ce(n),"pointer"),!0)}(t,n))}(this.view,e.pos,e.inside,t,this.selectNode)?t.preventDefault():0==t.button&&(this.flushed||hn&&this.mightDrag&&!this.mightDrag.node.isAtom||cn&&!this.view.state.selection.visible&&Math.min(Math.abs(e.pos-this.view.state.selection.from),Math.abs(e.pos-this.view.state.selection.to))<=2)?(tr(this.view,be.near(this.view.state.doc.resolve(e.pos)),"pointer"),t.preventDefault()):Uo(this.view,"pointer")}move(t){this.updateAllowDefault(t),Uo(this.view,"pointer"),0==t.buttons&&this.done()}updateAllowDefault(t){!this.allowDefault&&(Math.abs(this.event.x-t.clientX)>4||Math.abs(this.event.y-t.clientY)>4)&&(this.allowDefault=!0)}}function sr(t,e){return!!t.composing||!!(hn&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500)&&(t.input.compositionEndedAt=-2e8,!0)}Wo.touchstart=t=>{t.input.lastTouch=Date.now(),or(t),Uo(t,"pointer")},Wo.touchmove=t=>{t.input.lastTouch=Date.now(),Uo(t,"pointer")},Wo.contextmenu=t=>or(t);const lr=mn?5e3:-1;function ar(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>dr(t),e))}function cr(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=function(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function dr(t,e=!1){if(!(mn&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),cr(t),e||t.docView&&t.docView.dirty){let n=lo(t),o=t.state.selection;return n&&!n.eq(o)?t.dispatch(t.state.tr.setSelection(n)):!t.markCursor&&!e||o.$from.node(o.$from.sharedDepth(o.to)).inlineContent?t.updateState(t.state):t.dispatch(t.state.tr.deleteSelection()),!0}return!1}}qo.compositionstart=qo.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof xe&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(t=>!1===t.type.spec.inclusive)))t.markCursor=t.state.storedMarks||n.marks(),dr(t,!0),t.markCursor=null;else if(dr(t,!e.selection.empty),ln&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let e=t.domSelectionRange();for(let n=e.focusNode,o=e.focusOffset;n&&1==n.nodeType&&0!=o;){let e=o<0?n.lastChild:n.childNodes[o-1];if(!e)break;if(3==e.nodeType){let n=t.domSelection();n&&n.collapse(e,e.nodeValue.length);break}n=e,o=-1}}t.input.composing=!0}ar(t,lr)},qo.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,ar(t,20))};const hr=rn&&sn<15||pn&&yn<604;function pr(t,e,n,o,r){let i=Ro(t,e,n,o,t.state.selection.$from);if(t.someProp("handlePaste",e=>e(t,r,i||A.empty)))return!0;if(!i)return!1;let s=function(t){return 0==t.openStart&&0==t.openEnd&&1==t.content.childCount?t.content.firstChild:null}(i),l=s?t.state.tr.replaceSelectionWith(s,o):t.state.tr.replaceSelection(i);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function ur(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}Wo.copy=qo.cut=(t,e)=>{let n=e,o=t.state.selection,r="cut"==n.type;if(o.empty)return;let i=hr?null:n.clipboardData,s=o.content(),{dom:l,text:a}=Lo(t,s);i?(n.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):function(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let o=getSelection(),r=document.createRange();r.selectNodeContents(e),t.dom.blur(),o.removeAllRanges(),o.addRange(r),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}(t,l),r&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},qo.paste=(t,e)=>{let n=e;if(t.composing&&!mn)return;let o=hr?null:n.clipboardData,r=t.input.shiftKey&&45!=t.input.lastKeyCode;o&&pr(t,ur(o),o.getData("text/html"),r,n)?n.preventDefault():function(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,o=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(o.contentEditable="true"),o.style.cssText="position: fixed; left: -10000px; top: 10px",o.focus();let r=t.input.shiftKey&&45!=t.input.lastKeyCode;setTimeout(()=>{t.focus(),o.parentNode&&o.parentNode.removeChild(o),n?pr(t,o.value,null,r,e):pr(t,o.textContent,o.innerHTML,r,e)},50)}(t,n)};class fr{constructor(t,e,n){this.slice=t,this.move=e,this.node=n}}const mr=un?"altKey":"ctrlKey";function gr(t,e){let n=t.someProp("dragCopies",t=>!t(e));return null!=n?n:!e[mr]}Wo.dragstart=(t,e)=>{let n=e,o=t.input.mouseDown;if(o&&o.done(),!n.dataTransfer)return;let r,i=t.state.selection,s=i.empty?null:t.posAtCoords(Qo(n));if(s&&s.pos>=i.from&&s.pos<=(i instanceof Ce?i.to-1:i.to));else if(o&&o.mightDrag)r=Ce.create(t.state.doc,o.mightDrag.pos);else if(n.target&&1==n.target.nodeType){let e=t.docView.nearestDesc(n.target,!0);e&&e.node.type.spec.draggable&&e!=t.docView&&(r=Ce.create(t.state.doc,e.posBefore))}let l=(r||t.state.selection).content(),{dom:a,text:c,slice:d}=Lo(t,l);(!n.dataTransfer.files.length||!cn||dn>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(hr?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",hr||n.dataTransfer.setData("text/plain",c),t.dragging=new fr(d,gr(t,n),r)},Wo.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)},qo.dragover=qo.dragenter=(t,e)=>e.preventDefault(),qo.drop=(t,e)=>{let n=e,o=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let r=t.posAtCoords(Qo(n));if(!r)return;let i=t.state.doc.resolve(r.pos),s=o&&o.slice;s?t.someProp("transformPasted",e=>{s=e(s,t,!1)}):s=Ro(t,ur(n.dataTransfer),hr?null:n.dataTransfer.getData("text/html"),!1,i);let l=!(!o||!gr(t,n));if(t.someProp("handleDrop",e=>e(t,n,s||A.empty,l)))return void n.preventDefault();if(!s)return;n.preventDefault();let a=s?ee(t.state.doc,i.pos,s):i.pos;null==a&&(a=i.pos);let c=t.state.tr;if(l){let{node:t}=o;t?t.replace(c):c.deleteSelection()}let d=c.mapping.map(a),h=0==s.openStart&&0==s.openEnd&&1==s.content.childCount,p=c.doc;if(h?c.replaceRangeWith(d,d,s.content.firstChild):c.replaceRange(d,d,s),c.doc.eq(p))return;let u=c.doc.resolve(d);if(h&&Ce.isSelectable(s.content.firstChild)&&u.nodeAfter&&u.nodeAfter.sameMarkup(s.content.firstChild))c.setSelection(new Ce(u));else{let e=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((t,n,o,r)=>e=r),c.setSelection(yo(t,u,c.doc.resolve(e)))}t.focus(),t.dispatch(c.setMeta("uiEvent","drop"))},Wo.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&co(t)},20))},Wo.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)},Wo.beforeinput=(t,e)=>{if(cn&&mn&&"deleteContentBackward"==e.inputType){t.domObserver.flushSoon();let{domChangeCount:e}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=e)return;if(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",e=>e(t,Xe(8,"Backspace"))))return;let{$cursor:n}=t.state.selection;n&&n.pos>0&&t.dispatch(t.state.tr.delete(n.pos-1,n.pos).scrollIntoView())},50)}};for(let t in qo)Wo[t]=qo[t];function yr(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class br{constructor(t,e){this.toDOM=t,this.spec=e||Mr,this.side=this.spec.side||0}map(t,e,n,o){let{pos:r,deleted:i}=t.mapResult(e.from+o,this.side<0?-1:1);return i?null:new kr(r-n,r-n,this)}valid(){return!0}eq(t){return this==t||t instanceof br&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&yr(this.spec,t.spec))}destroy(t){this.spec.destroy&&this.spec.destroy(t)}}class vr{constructor(t,e){this.attrs=t,this.spec=e||Mr}map(t,e,n,o){let r=t.map(e.from+o,this.spec.inclusiveStart?-1:1)-n,i=t.map(e.to+o,this.spec.inclusiveEnd?1:-1)-n;return r>=i?null:new kr(r,i,this)}valid(t,e){return e.from<e.to}eq(t){return this==t||t instanceof vr&&yr(this.attrs,t.attrs)&&yr(this.spec,t.spec)}static is(t){return t.type instanceof vr}destroy(){}}class wr{constructor(t,e){this.attrs=t,this.spec=e||Mr}map(t,e,n,o){let r=t.mapResult(e.from+o,1);if(r.deleted)return null;let i=t.mapResult(e.to+o,-1);return i.deleted||i.pos<=r.pos?null:new kr(r.pos-n,i.pos-n,this)}valid(t,e){let n,{index:o,offset:r}=t.content.findIndex(e.from);return r==e.from&&!(n=t.child(o)).isText&&r+n.nodeSize==e.to}eq(t){return this==t||t instanceof wr&&yr(this.attrs,t.attrs)&&yr(this.spec,t.spec)}destroy(){}}class kr{constructor(t,e,n){this.from=t,this.to=e,this.type=n}copy(t,e){return new kr(t,e,this.type)}eq(t,e=0){return this.type.eq(t.type)&&this.from+e==t.from&&this.to+e==t.to}map(t,e,n){return this.type.map(t,this,e,n)}static widget(t,e,n){return new kr(t,t,new br(e,n))}static inline(t,e,n,o){return new kr(t,e,new vr(n,o))}static node(t,e,n,o){return new kr(t,e,new wr(n,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof vr}get widget(){return this.type instanceof br}}const xr=[],Mr={};class Cr{constructor(t,e){this.local=t.length?t:xr,this.children=e.length?e:xr}static create(t,e){return e.length?Nr(e,t,0,Mr):Sr}find(t,e,n){let o=[];return this.findInner(null==t?0:t,null==e?1e9:e,o,0,n),o}findInner(t,e,n,o,r){for(let i=0;i<this.local.length;i++){let s=this.local[i];s.from<=e&&s.to>=t&&(!r||r(s.spec))&&n.push(s.copy(s.from+o,s.to+o))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<e&&this.children[i+1]>t){let s=this.children[i]+1;this.children[i+2].findInner(t-s,e-s,n,o+s,r)}}map(t,e,n){return this==Sr||0==t.maps.length?this:this.mapInner(t,e,0,0,n||Mr)}mapInner(t,e,n,o,r){let i;for(let s=0;s<this.local.length;s++){let l=this.local[s].map(t,n,o);l&&l.type.valid(e,l)?(i||(i=[])).push(l):r.onRemove&&r.onRemove(this.local[s].spec)}return this.children.length?function(t,e,n,o,r,i,s){let l=t.slice();for(let t=0,e=i;t<n.maps.length;t++){let o=0;n.maps[t].forEach((t,n,r,i)=>{let s=i-r-(n-t);for(let r=0;r<l.length;r+=3){let i=l[r+1];if(i<0||t>i+e-o)continue;let a=l[r]+e-o;n>=a?l[r+1]=t<=a?-2:-1:t>=e&&s&&(l[r]+=s,l[r+1]+=s)}o+=s}),e=n.maps[t].map(e,-1)}let a=!1;for(let e=0;e<l.length;e+=3)if(l[e+1]<0){if(-2==l[e+1]){a=!0,l[e+1]=-1;continue}let c=n.map(t[e]+i),d=c-r;if(d<0||d>=o.content.size){a=!0;continue}let h=n.map(t[e+1]+i,-1)-r,{index:p,offset:u}=o.content.findIndex(d),f=o.maybeChild(p);if(f&&u==d&&u+f.nodeSize==h){let o=l[e+2].mapInner(n,f,c+1,t[e]+i+1,s);o!=Sr?(l[e]=d,l[e+1]=h,l[e+2]=o):(l[e+1]=-2,a=!0)}else a=!0}if(a){let a=function(t,e,n,o,r,i,s){function l(t,e){for(let i=0;i<t.local.length;i++){let l=t.local[i].map(o,r,e);l?n.push(l):s.onRemove&&s.onRemove(t.local[i].spec)}for(let n=0;n<t.children.length;n+=3)l(t.children[n+2],t.children[n]+e+1)}for(let n=0;n<t.length;n+=3)-1==t[n+1]&&l(t[n+2],e[n]+i+1);return n}(l,t,e,n,r,i,s),c=Nr(a,o,0,s);e=c.local;for(let t=0;t<l.length;t+=3)l[t+1]<0&&(l.splice(t,3),t-=3);for(let t=0,e=0;t<c.children.length;t+=3){let n=c.children[t];for(;e<l.length&&l[e]<n;)e+=3;l.splice(e,0,c.children[t],c.children[t+1],c.children[t+2])}}return new Cr(e.sort(Dr),l)}(this.children,i||[],t,e,n,o,r):i?new Cr(i.sort(Dr),xr):Sr}add(t,e){return e.length?this==Sr?Cr.create(t,e):this.addInner(t,e,0):this}addInner(t,e,n){let o,r=0;t.forEach((t,i)=>{let s,l=i+n;if(s=Er(e,t,l)){for(o||(o=this.children.slice());r<o.length&&o[r]<i;)r+=3;o[r]==i?o[r+2]=o[r+2].addInner(t,s,l+1):o.splice(r,0,i,i+t.nodeSize,Nr(s,t,l+1,Mr)),r+=3}});let i=Ar(r?Or(e):e,-n);for(let e=0;e<i.length;e++)i[e].type.valid(t,i[e])||i.splice(e--,1);return new Cr(i.length?this.local.concat(i).sort(Dr):this.local,o||this.children)}remove(t){return 0==t.length||this==Sr?this:this.removeInner(t,0)}removeInner(t,e){let n=this.children,o=this.local;for(let o=0;o<n.length;o+=3){let r,i=n[o]+e,s=n[o+1]+e;for(let e,n=0;n<t.length;n++)(e=t[n])&&e.from>i&&e.to<s&&(t[n]=null,(r||(r=[])).push(e));if(!r)continue;n==this.children&&(n=this.children.slice());let l=n[o+2].removeInner(r,i+1);l!=Sr?n[o+2]=l:(n.splice(o,3),o-=3)}if(o.length)for(let n,r=0;r<t.length;r++)if(n=t[r])for(let t=0;t<o.length;t++)o[t].eq(n,e)&&(o==this.local&&(o=this.local.slice()),o.splice(t--,1));return n==this.children&&o==this.local?this:o.length||n.length?new Cr(o,n):Sr}forChild(t,e){if(this==Sr)return this;if(e.isLeaf)return Cr.empty;let n,o;for(let e=0;e<this.children.length;e+=3)if(this.children[e]>=t){this.children[e]==t&&(n=this.children[e+2]);break}let r=t+1,i=r+e.content.size;for(let t=0;t<this.local.length;t++){let e=this.local[t];if(e.from<i&&e.to>r&&e.type instanceof vr){let t=Math.max(r,e.from)-r,n=Math.min(i,e.to)-r;t<n&&(o||(o=[])).push(e.copy(t,n))}}if(o){let t=new Cr(o.sort(Dr),xr);return n?new Tr([t,n]):t}return n||Sr}eq(t){if(this==t)return!0;if(!(t instanceof Cr)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(let e=0;e<this.local.length;e++)if(!this.local[e].eq(t.local[e]))return!1;for(let e=0;e<this.children.length;e+=3)if(this.children[e]!=t.children[e]||this.children[e+1]!=t.children[e+1]||!this.children[e+2].eq(t.children[e+2]))return!1;return!0}locals(t){return Lr(this.localsInner(t))}localsInner(t){if(this==Sr)return xr;if(t.inlineContent||!this.local.some(vr.is))return this.local;let e=[];for(let t=0;t<this.local.length;t++)this.local[t].type instanceof vr||e.push(this.local[t]);return e}forEachSet(t){t(this)}}Cr.empty=new Cr([],[]),Cr.removeOverlap=Lr;const Sr=Cr.empty;class Tr{constructor(t){this.members=t}map(t,e){const n=this.members.map(n=>n.map(t,e,Mr));return Tr.from(n)}forChild(t,e){if(e.isLeaf)return Cr.empty;let n=[];for(let o=0;o<this.members.length;o++){let r=this.members[o].forChild(t,e);r!=Sr&&(r instanceof Tr?n=n.concat(r.members):n.push(r))}return Tr.from(n)}eq(t){if(!(t instanceof Tr)||t.members.length!=this.members.length)return!1;for(let e=0;e<this.members.length;e++)if(!this.members[e].eq(t.members[e]))return!1;return!0}locals(t){let e,n=!0;for(let o=0;o<this.members.length;o++){let r=this.members[o].localsInner(t);if(r.length)if(e){n&&(e=e.slice(),n=!1);for(let t=0;t<r.length;t++)e.push(r[t])}else e=r}return e?Lr(n?e:e.sort(Dr)):xr}static from(t){switch(t.length){case 0:return Sr;case 1:return t[0];default:return new Tr(t.every(t=>t instanceof Cr)?t:t.reduce((t,e)=>t.concat(e instanceof Cr?e:e.members),[]))}}forEachSet(t){for(let e=0;e<this.members.length;e++)this.members[e].forEachSet(t)}}function Ar(t,e){if(!e||!t.length)return t;let n=[];for(let o=0;o<t.length;o++){let r=t[o];n.push(new kr(r.from+e,r.to+e,r.type))}return n}function Er(t,e,n){if(e.isLeaf)return null;let o=n+e.nodeSize,r=null;for(let e,i=0;i<t.length;i++)(e=t[i])&&e.from>n&&e.to<o&&((r||(r=[])).push(e),t[i]=null);return r}function Or(t){let e=[];for(let n=0;n<t.length;n++)null!=t[n]&&e.push(t[n]);return e}function Nr(t,e,n,o){let r=[],i=!1;e.forEach((e,s)=>{let l=Er(t,e,s+n);if(l){i=!0;let t=Nr(l,e,n+s+1,o);t!=Sr&&r.push(s,s+e.nodeSize,t)}});let s=Ar(i?Or(t):t,-n).sort(Dr);for(let t=0;t<s.length;t++)s[t].type.valid(e,s[t])||(o.onRemove&&o.onRemove(s[t].spec),s.splice(t--,1));return s.length||r.length?new Cr(s,r):Sr}function Dr(t,e){return t.from-e.from||t.to-e.to}function Lr(t){let e=t;for(let n=0;n<e.length-1;n++){let o=e[n];if(o.from!=o.to)for(let r=n+1;r<e.length;r++){let i=e[r];if(i.from!=o.from){i.from<o.to&&(e==t&&(e=t.slice()),e[n]=o.copy(o.from,i.from),Rr(e,r,o.copy(i.from,o.to)));break}i.to!=o.to&&(e==t&&(e=t.slice()),e[r]=i.copy(i.from,o.to),Rr(e,r+1,i.copy(o.to,i.to)))}}return e}function Rr(t,e,n){for(;e<t.length&&Dr(n,t[e])>0;)e++;t.splice(e,0,n)}function jr(t){let e=[];return t.someProp("decorations",n=>{let o=n(t.state);o&&o!=Sr&&e.push(o)}),t.cursorWrapper&&e.push(Cr.create(t.state.doc,[t.cursorWrapper.deco])),Tr.from(e)}const Ir={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Pr=rn&&sn<=11;class zr{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(t){this.anchorNode=t.anchorNode,this.anchorOffset=t.anchorOffset,this.focusNode=t.focusNode,this.focusOffset=t.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(t){return t.anchorNode==this.anchorNode&&t.anchorOffset==this.anchorOffset&&t.focusNode==this.focusNode&&t.focusOffset==this.focusOffset}}class $r{constructor(t,e){this.view=t,this.handleDOMChange=e,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new zr,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);rn&&sn<=11&&t.some(t=>"childList"==t.type&&t.removedNodes.length||"characterData"==t.type&&t.oldValue.length>t.target.nodeValue.length)?this.flushSoon():this.flush()}),Pr&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Ir)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let t=this.observer.takeRecords();if(t.length){for(let e=0;e<t.length;e++)this.queue.push(t[e]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(bo(this.view)){if(this.suppressingSelectionUpdates)return co(this.view);if(rn&&sn<=11&&!this.view.state.selection.empty){let t=this.view.domSelectionRange();if(t.focusNode&&qe(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(t){if(!t.focusNode)return!0;let e,n=new Set;for(let e=t.focusNode;e;e=_e(e))n.add(e);for(let o=t.anchorNode;o;o=_e(o))if(n.has(o)){e=o;break}let o=e&&this.view.docView.nearestDesc(e);return o&&o.ignoreMutation({type:"selection",target:3==e.nodeType?e.parentNode:e})?(this.setCurSelection(),!0):void 0}pendingRecords(){if(this.observer)for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}flush(){let{view:t}=this;if(!t.docView||this.flushingSoon>-1)return;let e=this.pendingRecords();e.length&&(this.queue=[]);let n=t.domSelectionRange(),o=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&bo(t)&&!this.ignoreSelectionChange(n),r=-1,i=-1,s=!1,l=[];if(t.editable)for(let t=0;t<e.length;t++){let n=this.registerMutation(e[t],l);n&&(r=r<0?n.from:Math.min(n.from,r),i=i<0?n.to:Math.max(n.to,i),n.typeOver&&(s=!0))}if(ln&&l.length){let e=l.filter(t=>"BR"==t.nodeName);if(2==e.length){let[t,n]=e;t.parentNode&&t.parentNode.parentNode==n.parentNode?n.remove():t.remove()}else{let{focusNode:n}=this.currentSelection;for(let o of e){let e=o.parentNode;!e||"LI"!=e.nodeName||n&&_r(t,n)==e||o.remove()}}}let a=null;r<0&&o&&t.input.lastFocus>Date.now()-200&&Math.max(t.input.lastTouch,t.input.lastClick.time)<Date.now()-300&&Ye(n)&&(a=lo(t))&&a.eq(be.near(t.state.doc.resolve(0),1))?(t.input.lastFocus=0,co(t),this.currentSelection.set(n),t.scrollToSelection()):(r>-1||o)&&(r>-1&&(t.docView.markDirty(r,i),function(t){if(!Hr.has(t)&&(Hr.set(t,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace))){if(t.requiresGeckoHackNode=ln,Br)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),Br=!0}}(t)),this.handleDOMChange(r,i,s,l),t.docView&&t.docView.dirty?t.updateState(t.state):this.currentSelection.eq(n)||co(t),this.currentSelection.set(n))}registerMutation(t,e){if(e.indexOf(t.target)>-1)return null;let n=this.view.docView.nearestDesc(t.target);if("attributes"==t.type&&(n==this.view.docView||"contenteditable"==t.attributeName||"style"==t.attributeName&&!t.oldValue&&!t.target.getAttribute("style")))return null;if(!n||n.ignoreMutation(t))return null;if("childList"==t.type){for(let n=0;n<t.addedNodes.length;n++){let o=t.addedNodes[n];e.push(o),3==o.nodeType&&(this.lastChangedTextNode=o)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(t.target))return{from:n.posBefore,to:n.posAfter};let o=t.previousSibling,r=t.nextSibling;if(rn&&sn<=11&&t.addedNodes.length)for(let e=0;e<t.addedNodes.length;e++){let{previousSibling:n,nextSibling:i}=t.addedNodes[e];(!n||Array.prototype.indexOf.call(t.addedNodes,n)<0)&&(o=n),(!i||Array.prototype.indexOf.call(t.addedNodes,i)<0)&&(r=i)}let i=o&&o.parentNode==t.target?Ve(o)+1:0,s=n.localPosFromDOM(t.target,i,-1),l=r&&r.parentNode==t.target?Ve(r):t.target.childNodes.length;return{from:s,to:n.localPosFromDOM(t.target,l,1)}}return"attributes"==t.type?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:(this.lastChangedTextNode=t.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:t.target.nodeValue==t.oldValue})}}let Hr=new WeakMap,Br=!1;function Vr(t,e){let n=e.startContainer,o=e.startOffset,r=e.endContainer,i=e.endOffset,s=t.domAtPos(t.state.selection.anchor);return qe(s.node,s.offset,r,i)&&([n,o,r,i]=[r,i,n,o]),{anchorNode:n,anchorOffset:o,focusNode:r,focusOffset:i}}function _r(t,e){for(let n=e.parentNode;n&&n!=t.dom;n=n.parentNode){let e=t.docView.nearestDesc(n,!0);if(e&&e.node.isBlock)return n}return null}function Fr(t){let e=t.pmViewDesc;if(e)return e.parseRule();if("BR"==t.nodeName&&t.parentNode){if(hn&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}if(t.parentNode.lastChild==t||hn&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if("IMG"==t.nodeName&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const Wr=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function qr(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:yo(t,e.resolve(n.anchor),e.resolve(n.head))}function Kr(t,e,n){let o=t.depth,r=e?t.end():t.pos;for(;o>0&&(e||t.indexAfter(o)==t.node(o).childCount);)o--,r++,e=!1;if(n){let e=t.node(o).maybeChild(t.indexAfter(o));for(;e&&!e.isLeaf;)e=e.firstChild,r++}return r}function Jr(t){if(2!=t.length)return!1;let e=t.charCodeAt(0),n=t.charCodeAt(1);return e>=56320&&e<=57343&&n>=55296&&n<=56319}class Ur{constructor(t,e){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new Jo,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=e,this.state=e.state,this.directPlugins=e.plugins||[],this.directPlugins.forEach(Zr),this.dispatch=this.dispatch.bind(this),this.dom=t&&t.mount||document.createElement("div"),t&&(t.appendChild?t.appendChild(this.dom):"function"==typeof t?t(this.dom):t.mount&&(this.mounted=!0)),this.editable=Xr(this),Yr(this),this.nodeViews=Qr(this),this.docView=qn(this.state.doc,Gr(this),jr(this),this.dom,this),this.domObserver=new $r(this,(t,e,n,o)=>function(t,e,n,o,r){let i=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let e=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,n=lo(t,e);if(n&&!t.state.selection.eq(n)){if(cn&&mn&&13===t.input.lastKeyCode&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",e=>e(t,Xe(13,"Enter"))))return;let o=t.state.tr.setSelection(n);"pointer"==e?o.setMeta("pointer",!0):"key"==e&&o.scrollIntoView(),i&&o.setMeta("composition",i),t.dispatch(o)}return}let s=t.state.doc.resolve(e),l=s.sharedDepth(n);e=s.before(l+1),n=t.state.doc.resolve(n).after(l+1);let a,c,d=t.state.selection,h=function(t,e,n){let o,{node:r,fromOffset:i,toOffset:s,from:l,to:a}=t.docView.parseRange(e,n),c=t.domSelectionRange(),d=c.anchorNode;if(d&&t.dom.contains(1==d.nodeType?d:d.parentNode)&&(o=[{node:d,offset:c.anchorOffset}],Ye(c)||o.push({node:c.focusNode,offset:c.focusOffset})),cn&&8===t.input.lastKeyCode)for(let t=s;t>i;t--){let e=r.childNodes[t-1],n=e.pmViewDesc;if("BR"==e.nodeName&&!n){s=t;break}if(!n||n.size)break}let h=t.state.doc,p=t.someProp("domParser")||pt.fromSchema(t.state.schema),u=h.resolve(l),f=null,m=p.parse(r,{topNode:u.parent,topMatch:u.parent.contentMatchAt(u.index()),topOpen:!0,from:i,to:s,preserveWhitespace:"pre"!=u.parent.type.whitespace||"full",findPositions:o,ruleFromNode:Fr,context:u});if(o&&null!=o[0].pos){let t=o[0].pos,e=o[1]&&o[1].pos;null==e&&(e=t),f={anchor:t+l,head:e+l}}return{doc:m,sel:f,from:l,to:a}}(t,e,n),p=t.state.doc,u=p.slice(h.from,h.to);8===t.input.lastKeyCode&&Date.now()-100<t.input.lastKeyCodeTime?(a=t.state.selection.to,c="end"):(a=t.state.selection.from,c="start"),t.input.lastKeyCode=null;let f=function(t,e,n,o,r){let i=t.findDiffStart(e,n);if(null==i)return null;let{a:s,b:l}=t.findDiffEnd(e,n+t.size,n+e.size);if("end"==r&&(o-=s+Math.max(0,i-Math.min(s,l))-i),s<i&&t.size<e.size){let t=o<=i&&o>=s?i-o:0;i-=t,i&&i<e.size&&Jr(e.textBetween(i-1,i+1))&&(i+=t?1:-1),l=i+(l-s),s=i}else if(l<i){let e=o<=i&&o>=l?i-o:0;i-=e,i&&i<t.size&&Jr(t.textBetween(i-1,i+1))&&(i+=e?1:-1),s=i+(s-l),l=i}return{start:i,endA:s,endB:l}}(u.content,h.doc.content,h.from,a,c);if(f&&t.input.domChangeCount++,(pn&&t.input.lastIOSEnter>Date.now()-225||mn)&&r.some(t=>1==t.nodeType&&!Wr.test(t.nodeName))&&(!f||f.endA>=f.endB)&&t.someProp("handleKeyDown",e=>e(t,Xe(13,"Enter"))))return void(t.input.lastIOSEnter=0);if(!f){if(!(o&&d instanceof xe&&!d.empty&&d.$head.sameParent(d.$anchor))||t.composing||h.sel&&h.sel.anchor!=h.sel.head){if(h.sel){let e=qr(t,t.state.doc,h.sel);if(e&&!e.eq(t.state.selection)){let n=t.state.tr.setSelection(e);i&&n.setMeta("composition",i),t.dispatch(n)}}return}f={start:d.from,endA:d.to,endB:d.to}}t.state.selection.from<t.state.selection.to&&f.start==f.endB&&t.state.selection instanceof xe&&(f.start>t.state.selection.from&&f.start<=t.state.selection.from+2&&t.state.selection.from>=h.from?f.start=t.state.selection.from:f.endA<t.state.selection.to&&f.endA>=t.state.selection.to-2&&t.state.selection.to<=h.to&&(f.endB+=t.state.selection.to-f.endA,f.endA=t.state.selection.to)),rn&&sn<=11&&f.endB==f.start+1&&f.endA==f.start&&f.start>h.from&&"  "==h.doc.textBetween(f.start-h.from-1,f.start-h.from+1)&&(f.start--,f.endA--,f.endB--);let m,g=h.doc.resolveNoCache(f.start-h.from),y=h.doc.resolveNoCache(f.endB-h.from),b=p.resolve(f.start),v=g.sameParent(y)&&g.parent.inlineContent&&b.end()>=f.endA;if((pn&&t.input.lastIOSEnter>Date.now()-225&&(!v||r.some(t=>"DIV"==t.nodeName||"P"==t.nodeName))||!v&&g.pos<h.doc.content.size&&(!g.sameParent(y)||!g.parent.inlineContent)&&!/\S/.test(h.doc.textBetween(g.pos,y.pos,"",""))&&(m=be.findFrom(h.doc.resolve(g.pos+1),1,!0))&&m.head>g.pos)&&t.someProp("handleKeyDown",e=>e(t,Xe(13,"Enter"))))return void(t.input.lastIOSEnter=0);if(t.state.selection.anchor>f.start&&function(t,e,n,o,r){if(n-e<=r.pos-o.pos||Kr(o,!0,!1)<r.pos)return!1;let i=t.resolve(e);if(!o.parent.isTextblock){let t=i.nodeAfter;return null!=t&&n==e+t.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let s=t.resolve(Kr(i,!0,!0));return!(!s.parent.isTextblock||s.pos>n||Kr(s,!0,!1)<n)&&o.parent.content.cut(o.parentOffset).eq(s.parent.content)}(p,f.start,f.endA,g,y)&&t.someProp("handleKeyDown",e=>e(t,Xe(8,"Backspace"))))return void(mn&&cn&&t.domObserver.suppressSelectionUpdates());cn&&f.endB==f.start&&(t.input.lastChromeDelete=Date.now()),mn&&!v&&g.start()!=y.start()&&0==y.parentOffset&&g.depth==y.depth&&h.sel&&h.sel.anchor==h.sel.head&&h.sel.head==f.endA&&(f.endB-=2,y=h.doc.resolveNoCache(f.endB-h.from),setTimeout(()=>{t.someProp("handleKeyDown",function(e){return e(t,Xe(13,"Enter"))})},20));let w,x=f.start,M=f.endA,C=e=>{let n=e||t.state.tr.replace(x,M,h.doc.slice(f.start-h.from,f.endB-h.from));if(h.sel){let e=qr(t,n.doc,h.sel);e&&!(cn&&t.composing&&e.empty&&(f.start!=f.endB||t.input.lastChromeDelete<Date.now()-100)&&(e.head==x||e.head==n.mapping.map(M)-1)||rn&&e.empty&&e.head==x)&&n.setSelection(e)}return i&&n.setMeta("composition",i),n.scrollIntoView()};if(v){if(g.pos==y.pos){rn&&sn<=11&&0==g.parentOffset&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>co(t),20));let e=C(t.state.tr.delete(x,M)),n=p.resolve(f.start).marksAcross(p.resolve(f.endA));n&&e.ensureMarks(n),t.dispatch(e)}else if(f.endA==f.endB&&(w=function(t,e){let n,o,r,i=t.firstChild.marks,s=e.firstChild.marks,l=i,a=s;for(let t=0;t<s.length;t++)l=s[t].removeFromSet(l);for(let t=0;t<i.length;t++)a=i[t].removeFromSet(a);if(1==l.length&&0==a.length)o=l[0],n="add",r=t=>t.mark(o.addToSet(t.marks));else{if(0!=l.length||1!=a.length)return null;o=a[0],n="remove",r=t=>t.mark(o.removeFromSet(t.marks))}let c=[];for(let t=0;t<e.childCount;t++)c.push(r(e.child(t)));if(k.from(c).eq(t))return{mark:o,type:n}}(g.parent.content.cut(g.parentOffset,y.parentOffset),b.parent.content.cut(b.parentOffset,f.endA-b.start())))){let e=C(t.state.tr);"add"==w.type?e.addMark(x,M,w.mark):e.removeMark(x,M,w.mark),t.dispatch(e)}else if(g.parent.child(g.index()).isText&&g.index()==y.index()-(y.textOffset?0:1)){let e=g.parent.textBetween(g.parentOffset,y.parentOffset),n=()=>C(t.state.tr.insertText(e,x,M));t.someProp("handleTextInput",o=>o(t,x,M,e,n))||t.dispatch(n())}}else t.dispatch(C())}(this,t,e,n,o)),this.domObserver.start(),function(t){for(let e in Wo){let n=Wo[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=e=>{!Xo(t,e)||Yo(t,e)||!t.editable&&e.type in qo||n(t,e)},Ko[e]?{passive:!0}:void 0)}hn&&t.dom.addEventListener("input",()=>null),Go(t)}(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let t=this._props;this._props={};for(let e in t)this._props[e]=t[e];this._props.state=this.state}return this._props}update(t){t.handleDOMEvents!=this._props.handleDOMEvents&&Go(this);let e=this._props;this._props=t,t.plugins&&(t.plugins.forEach(Zr),this.directPlugins=t.plugins),this.updateStateInner(t.state,e)}setProps(t){let e={};for(let t in this._props)e[t]=this._props[t];e.state=this.state;for(let n in t)e[n]=t[n];this.update(e)}updateState(t){this.updateStateInner(t,this._props)}updateStateInner(t,e){var n;let o=this.state,r=!1,i=!1;t.storedMarks&&this.composing&&(cr(this),i=!0),this.state=t;let s=o.plugins!=t.plugins||this._props.plugins!=e.plugins;if(s||this._props.plugins!=e.plugins||this._props.nodeViews!=e.nodeViews){let t=Qr(this);(function(t,e){let n=0,o=0;for(let o in t){if(t[o]!=e[o])return!0;n++}for(let t in e)o++;return n!=o})(t,this.nodeViews)&&(this.nodeViews=t,r=!0)}(s||e.handleDOMEvents!=this._props.handleDOMEvents)&&Go(this),this.editable=Xr(this),Yr(this);let l=jr(this),a=Gr(this),c=o.plugins==t.plugins||o.doc.eq(t.doc)?t.scrollToSelection>o.scrollToSelection?"to selection":"preserve":"reset",d=r||!this.docView.matchesNode(t.doc,a,l);!d&&t.selection.eq(o.selection)||(i=!0);let h="preserve"==c&&i&&null==this.dom.style.overflowAnchor&&function(t){let e,n,o=t.dom.getBoundingClientRect(),r=Math.max(0,o.top);for(let i=(o.left+o.right)/2,s=r+1;s<Math.min(innerHeight,o.bottom);s+=5){let o=t.root.elementFromPoint(i,s);if(!o||o==t.dom||!t.dom.contains(o))continue;let l=o.getBoundingClientRect();if(l.top>=r-20){e=o,n=l.top;break}}return{refDOM:e,refTop:n,stack:xn(t.dom)}}(this);if(i){this.domObserver.stop();let e=d&&(rn||cn)&&!this.composing&&!o.selection.empty&&!t.selection.empty&&function(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}(o.selection,t.selection);if(d){let n=cn?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=function(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=function(t,e){for(;;){if(3==t.nodeType&&e)return t;if(1==t.nodeType&&e>0){if("false"==t.contentEditable)return null;e=Ue(t=t.childNodes[e-1])}else{if(!t.parentNode||Ge(t))return null;e=Ve(t),t=t.parentNode}}}(e.focusNode,e.focusOffset),o=function(t,e){for(;;){if(3==t.nodeType&&e<t.nodeValue.length)return t;if(1==t.nodeType&&e<t.childNodes.length){if("false"==t.contentEditable)return null;t=t.childNodes[e],e=0}else{if(!t.parentNode||Ge(t))return null;e=Ve(t)+1,t=t.parentNode}}}(e.focusNode,e.focusOffset);if(n&&o&&n!=o){let e=o.pmViewDesc,r=t.domObserver.lastChangedTextNode;if(n==r||o==r)return r;if(!e||!e.isText(o.nodeValue))return o;if(t.input.compositionNode==o){let t=n.pmViewDesc;if(t&&t.isText(n.nodeValue))return o}}return n||o}(this)),!r&&this.docView.update(t.doc,a,l,this)||(this.docView.updateOuterDeco(a),this.docView.destroy(),this.docView=qn(t.doc,a,l,this.dom,this)),n&&!this.trackWrites&&(e=!0)}e||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&function(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return qe(e.node,e.offset,n.anchorNode,n.anchorOffset)}(this))?co(this,e):(mo(this,t.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(o),(null===(n=this.dragging)||void 0===n?void 0:n.node)&&!o.doc.eq(t.doc)&&this.updateDraggedNode(this.dragging,o),"reset"==c?this.dom.scrollTop=0:"to selection"==c?this.scrollToSelection():h&&function({refDOM:t,refTop:e,stack:n}){let o=t?t.getBoundingClientRect().top:0;Mn(n,0==o?0:o-e)}(h)}scrollToSelection(){let t=this.domSelectionRange().focusNode;if(t&&this.dom.contains(1==t.nodeType?t:t.parentNode))if(this.someProp("handleScrollToSelection",t=>t(this)));else if(this.state.selection instanceof Ce){let e=this.docView.domAfterPos(this.state.selection.from);1==e.nodeType&&kn(this,e.getBoundingClientRect(),t)}else kn(this,this.coordsAtPos(this.state.selection.head,1),t)}destroyPluginViews(){let t;for(;t=this.pluginViews.pop();)t.destroy&&t.destroy()}updatePluginViews(t){if(t&&t.plugins==this.state.plugins&&this.directPlugins==this.prevDirectPlugins)for(let e=0;e<this.pluginViews.length;e++){let n=this.pluginViews[e];n.update&&n.update(this,t)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let e=this.directPlugins[t];e.spec.view&&this.pluginViews.push(e.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let e=this.state.plugins[t];e.spec.view&&this.pluginViews.push(e.spec.view(this))}}}updateDraggedNode(t,e){let n=t.node,o=-1;if(this.state.doc.nodeAt(n.from)==n.node)o=n.from;else{let t=n.from+(this.state.doc.content.size-e.doc.content.size);(t>0&&this.state.doc.nodeAt(t))==n.node&&(o=t)}this.dragging=new fr(t.slice,t.move,o<0?void 0:Ce.create(this.state.doc,o))}someProp(t,e){let n,o=this._props&&this._props[t];if(null!=o&&(n=e?e(o):o))return n;for(let o=0;o<this.directPlugins.length;o++){let r=this.directPlugins[o].props[t];if(null!=r&&(n=e?e(r):r))return n}let r=this.state.plugins;if(r)for(let o=0;o<r.length;o++){let i=r[o].props[t];if(null!=i&&(n=e?e(i):i))return n}}hasFocus(){if(rn){let t=this.root.activeElement;if(t==this.dom)return!0;if(!t||!this.dom.contains(t))return!1;for(;t&&this.dom!=t&&this.dom.contains(t);){if("false"==t.contentEditable)return!1;t=t.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&function(t){if(t.setActive)return t.setActive();if(Cn)return t.focus(Cn);let e=xn(t);t.focus(null==Cn?{get preventScroll(){return Cn={preventScroll:!0},!0}}:void 0),Cn||(Cn=!1,Mn(e,0))}(this.dom),co(this),this.domObserver.start()}get root(){let t=this._root;if(null==t)for(let t=this.dom.parentNode;t;t=t.parentNode)if(9==t.nodeType||11==t.nodeType&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t;return t||document}updateRoot(){this._root=null}posAtCoords(t){return En(this,t)}coordsAtPos(t,e=1){return Ln(this,t,e)}domAtPos(t,e=0){return this.docView.domFromPos(t,e)}nodeDOM(t){let e=this.docView.descAt(t);return e?e.nodeDOM:null}posAtDOM(t,e,n=-1){let o=this.docView.posFromDOM(t,e,n);if(null==o)throw new RangeError("DOM position not inside the editor");return o}endOfTextblock(t,e){return function(t,e,n){return zn==e&&$n==n?Hn:(zn=e,$n=n,Hn="up"==n||"down"==n?function(t,e,n){let o=e.selection,r="up"==n?o.$from:o.$to;return In(t,e,()=>{let{node:e}=t.docView.domFromPos(r.pos,"up"==n?-1:1);for(;;){let n=t.docView.nearestDesc(e,!0);if(!n)break;if(n.node.isBlock){e=n.contentDOM||n.dom;break}e=n.dom.parentNode}let o=Ln(t,r.pos,1);for(let t=e.firstChild;t;t=t.nextSibling){let e;if(1==t.nodeType)e=t.getClientRects();else{if(3!=t.nodeType)continue;e=We(t,0,t.nodeValue.length).getClientRects()}for(let t=0;t<e.length;t++){let r=e[t];if(r.bottom>r.top+1&&("up"==n?o.top-r.top>2*(r.bottom-o.top):r.bottom-o.bottom>2*(o.bottom-r.top)))return!1}}return!0})}(t,e,n):function(t,e,n){let{$head:o}=e.selection;if(!o.parent.isTextblock)return!1;let r=o.parentOffset,i=!r,s=r==o.parent.content.size,l=t.domSelection();return l?Pn.test(o.parent.textContent)&&l.modify?In(t,e,()=>{let{focusNode:e,focusOffset:r,anchorNode:i,anchorOffset:s}=t.domSelectionRange(),a=l.caretBidiLevel;l.modify("move",n,"character");let c=o.depth?t.docView.domAfterPos(o.before()):t.dom,{focusNode:d,focusOffset:h}=t.domSelectionRange(),p=d&&!c.contains(1==d.nodeType?d:d.parentNode)||e==d&&r==h;try{l.collapse(i,s),e&&(e!=i||r!=s)&&l.extend&&l.extend(e,r)}catch(t){}return null!=a&&(l.caretBidiLevel=a),p}):"left"==n||"backward"==n?i:s:o.pos==o.start()||o.pos==o.end()}(t,e,n))}(this,e||this.state,t)}pasteHTML(t,e){return pr(this,"",t,!1,e||new ClipboardEvent("paste"))}pasteText(t,e){return pr(this,t,null,!0,e||new ClipboardEvent("paste"))}serializeForClipboard(t){return Lo(this,t)}destroy(){this.docView&&(function(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],jr(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Fe=null)}get isDestroyed(){return null==this.docView}dispatchEvent(t){return function(t,e){Yo(t,e)||!Wo[e.type]||!t.editable&&e.type in qo||Wo[e.type](t,e)}(this,t)}domSelectionRange(){let t=this.domSelection();return t?hn&&11===this.root.nodeType&&function(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}(this.dom.ownerDocument)==this.dom&&function(t,e){if(e.getComposedRanges){let n=e.getComposedRanges(t.root)[0];if(n)return Vr(t,n)}let n;function o(t){t.preventDefault(),t.stopImmediatePropagation(),n=t.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",o,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",o,!0),n?Vr(t,n):null}(this,t)||t:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function Gr(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if("function"==typeof n&&(n=n(t.state)),n)for(let t in n)"class"==t?e.class+=" "+n[t]:"style"==t?e.style=(e.style?e.style+";":"")+n[t]:e[t]||"contenteditable"==t||"nodeName"==t||(e[t]=String(n[t]))}),e.translate||(e.translate="no"),[kr.node(0,t.state.doc.content.size,e)]}function Yr(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:kr.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function Xr(t){return!t.someProp("editable",e=>!1===e(t.state))}function Qr(t){let e=Object.create(null);function n(t){for(let n in t)Object.prototype.hasOwnProperty.call(e,n)||(e[n]=t[n])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function Zr(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}Ur.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};for(var ti={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},ei={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},ni="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),oi="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),ri=0;ri<10;ri++)ti[48+ri]=ti[96+ri]=String(ri);for(ri=1;ri<=24;ri++)ti[ri+111]="F"+ri;for(ri=65;ri<=90;ri++)ti[ri]=String.fromCharCode(ri+32),ei[ri]=String.fromCharCode(ri);for(var ii in ti)ei.hasOwnProperty(ii)||(ei[ii]=ti[ii]);const si="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),li="undefined"!=typeof navigator&&/Win/.test(navigator.platform);function ai(t){let e,n,o,r,i=t.split(/-(?!$)/),s=i[i.length-1];"Space"==s&&(s=" ");for(let t=0;t<i.length-1;t++){let s=i[t];if(/^(cmd|meta|m)$/i.test(s))r=!0;else if(/^a(lt)?$/i.test(s))e=!0;else if(/^(c|ctrl|control)$/i.test(s))n=!0;else if(/^s(hift)?$/i.test(s))o=!0;else{if(!/^mod$/i.test(s))throw new Error("Unrecognized modifier name: "+s);si?r=!0:n=!0}}return e&&(s="Alt-"+s),n&&(s="Ctrl-"+s),r&&(s="Meta-"+s),o&&(s="Shift-"+s),s}function ci(t,e,n=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n&&e.shiftKey&&(t="Shift-"+t),t}function di(t){let e=function(t){let e=Object.create(null);for(let n in t)e[ai(n)]=t[n];return e}(t);return function(t,n){let o,r=function(t){var e=!(ni&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||oi&&t.shiftKey&&t.key&&1==t.key.length||"Unidentified"==t.key)&&t.key||(t.shiftKey?ei:ti)[t.keyCode]||t.key||"Unidentified";return"Esc"==e&&(e="Escape"),"Del"==e&&(e="Delete"),"Left"==e&&(e="ArrowLeft"),"Up"==e&&(e="ArrowUp"),"Right"==e&&(e="ArrowRight"),"Down"==e&&(e="ArrowDown"),e}(n),i=e[ci(r,n)];if(i&&i(t.state,t.dispatch,t))return!0;if(1==r.length&&" "!=r){if(n.shiftKey){let o=e[ci(r,n,!1)];if(o&&o(t.state,t.dispatch,t))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(li&&n.ctrlKey&&n.altKey)&&(o=ti[n.keyCode])&&o!=r){let r=e[ci(o,n)];if(r&&r(t.state,t.dispatch,t))return!0}}return!1}}const hi=(t,e)=>!t.selection.empty&&(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function pi(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const ui=(t,e,n)=>{let o=pi(t,n);if(!o)return!1;let r=yi(o);if(!r){let n=o.blockRange(),r=n&&Kt(n);return null!=r&&(e&&e(t.tr.lift(n,r).scrollIntoView()),!0)}let i=r.nodeBefore;if(Ei(t,r,e,-1))return!0;if(0==o.parent.content.size&&(mi(i,"end")||Ce.isSelectable(i)))for(let n=o.depth;;n--){let s=ne(t.doc,o.before(n),o.after(n),A.empty);if(s&&s.slice.size<s.to-s.from){if(e){let n=t.tr.step(s);n.setSelection(mi(i,"end")?be.findFrom(n.doc.resolve(n.mapping.map(r.pos,-1)),-1):Ce.create(n.doc,r.pos-i.nodeSize)),e(n.scrollIntoView())}return!0}if(1==n||o.node(n-1).childCount>1)break}return!(!i.isAtom||r.depth!=o.depth-1||(e&&e(t.tr.delete(r.pos-i.nodeSize,r.pos).scrollIntoView()),0))};function fi(t,e,n){let o=e.nodeBefore,r=e.pos-1;for(;!o.isTextblock;r--){if(o.type.spec.isolating)return!1;let t=o.lastChild;if(!t)return!1;o=t}let i=e.nodeAfter,s=e.pos+1;for(;!i.isTextblock;s++){if(i.type.spec.isolating)return!1;let t=i.firstChild;if(!t)return!1;i=t}let l=ne(t.doc,r,s,A.empty);if(!l||l.from!=r||l instanceof Vt&&l.slice.size>=s-r)return!1;if(n){let e=t.tr.step(l);e.setSelection(xe.create(e.doc,r)),n(e.scrollIntoView())}return!0}function mi(t,e,n=!1){for(let o=t;o;o="start"==e?o.firstChild:o.lastChild){if(o.isTextblock)return!0;if(n&&1!=o.childCount)return!1}return!1}const gi=(t,e,n)=>{let{$head:o,empty:r}=t.selection,i=o;if(!r)return!1;if(o.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):o.parentOffset>0)return!1;i=yi(o)}let s=i&&i.nodeBefore;return!(!s||!Ce.isSelectable(s)||(e&&e(t.tr.setSelection(Ce.create(t.doc,i.pos-s.nodeSize)).scrollIntoView()),0))};function yi(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function bi(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const vi=(t,e,n)=>{let o=bi(t,n);if(!o)return!1;let r=ki(o);if(!r)return!1;let i=r.nodeAfter;if(Ei(t,r,e,1))return!0;if(0==o.parent.content.size&&(mi(i,"start")||Ce.isSelectable(i))){let n=ne(t.doc,o.before(),o.after(),A.empty);if(n&&n.slice.size<n.to-n.from){if(e){let o=t.tr.step(n);o.setSelection(mi(i,"start")?be.findFrom(o.doc.resolve(o.mapping.map(r.pos)),1):Ce.create(o.doc,o.mapping.map(r.pos))),e(o.scrollIntoView())}return!0}}return!(!i.isAtom||r.depth!=o.depth-1||(e&&e(t.tr.delete(r.pos,r.pos+i.nodeSize).scrollIntoView()),0))},wi=(t,e,n)=>{let{$head:o,empty:r}=t.selection,i=o;if(!r)return!1;if(o.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):o.parentOffset<o.parent.content.size)return!1;i=ki(o)}let s=i&&i.nodeAfter;return!(!s||!Ce.isSelectable(s)||(e&&e(t.tr.setSelection(Ce.create(t.doc,i.pos)).scrollIntoView()),0))};function ki(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let n=t.node(e);if(t.index(e)+1<n.childCount)return t.doc.resolve(t.after(e+1));if(n.type.spec.isolating)break}return null}const xi=(t,e)=>{let{$head:n,$anchor:o}=t.selection;return!(!n.parent.type.spec.code||!n.sameParent(o)||(e&&e(t.tr.insertText("\n").scrollIntoView()),0))};function Mi(t){for(let e=0;e<t.edgeCount;e++){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const Ci=(t,e)=>{let{$head:n,$anchor:o}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(o))return!1;let r=n.node(-1),i=n.indexAfter(-1),s=Mi(r.contentMatchAt(i));if(!s||!r.canReplaceWith(i,i,s))return!1;if(e){let o=n.after(),r=t.tr.replaceWith(o,o,s.createAndFill());r.setSelection(be.near(r.doc.resolve(o),1)),e(r.scrollIntoView())}return!0},Si=(t,e)=>{let n=t.selection,{$from:o,$to:r}=n;if(n instanceof Te||o.parent.inlineContent||r.parent.inlineContent)return!1;let i=Mi(r.parent.contentMatchAt(r.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let n=(!o.parentOffset&&r.index()<r.parent.childCount?o:r).pos,s=t.tr.insert(n,i.createAndFill());s.setSelection(xe.create(s.doc,n+1)),e(s.scrollIntoView())}return!0},Ti=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let o=n.before();if(Xt(t.doc,o))return e&&e(t.tr.split(o).scrollIntoView()),!0}let o=n.blockRange(),r=o&&Kt(o);return null!=r&&(e&&e(t.tr.lift(o,r).scrollIntoView()),!0)};var Ai;function Ei(t,e,n,o){let r,i,s=e.nodeBefore,l=e.nodeAfter,a=s.type.spec.isolating||l.type.spec.isolating;if(!a&&function(t,e,n){let o=e.nodeBefore,r=e.nodeAfter,i=e.index();return!(!(o&&r&&o.type.compatibleContent(r.type))||(!o.content.size&&e.parent.canReplace(i-1,i)?(n&&n(t.tr.delete(e.pos-o.nodeSize,e.pos).scrollIntoView()),0):!e.parent.canReplace(i,i+1)||!r.isTextblock&&!Qt(t.doc,e.pos)||(n&&n(t.tr.join(e.pos).scrollIntoView()),0)))}(t,e,n))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(r=(i=s.contentMatchAt(s.childCount)).findWrapping(l.type))&&i.matchType(r[0]||l.type).validEnd){if(n){let o=e.pos+l.nodeSize,i=k.empty;for(let t=r.length-1;t>=0;t--)i=k.from(r[t].create(null,i));i=k.from(s.copy(i));let a=t.tr.step(new _t(e.pos-1,o,e.pos,o,new A(i,1,0),r.length,!0)),c=a.doc.resolve(o+2*r.length);c.nodeAfter&&c.nodeAfter.type==s.type&&Qt(a.doc,c.pos)&&a.join(c.pos),n(a.scrollIntoView())}return!0}let d=l.type.spec.isolating||o>0&&a?null:be.findFrom(e,1),h=d&&d.$from.blockRange(d.$to),p=h&&Kt(h);if(null!=p&&p>=e.depth)return n&&n(t.tr.lift(h,p).scrollIntoView()),!0;if(c&&mi(l,"start",!0)&&mi(s,"end")){let o=s,r=[];for(;r.push(o),!o.isTextblock;)o=o.lastChild;let i=l,a=1;for(;!i.isTextblock;i=i.firstChild)a++;if(o.canReplace(o.childCount,o.childCount,i.content)){if(n){let o=k.empty;for(let t=r.length-1;t>=0;t--)o=k.from(r[t].copy(o));n(t.tr.step(new _t(e.pos-r.length,e.pos+l.nodeSize,e.pos+a,e.pos+l.nodeSize-a,new A(o,r.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function Oi(t){return function(e,n){let o=e.selection,r=t<0?o.$from:o.$to,i=r.depth;for(;r.node(i).isInline;){if(!i)return!1;i--}return!!r.node(i).isTextblock&&(n&&n(e.tr.setSelection(xe.create(e.doc,t<0?r.start(i):r.end(i)))),!0)}}const Ni=Oi(-1),Di=Oi(1);function Li(t,e=null){return function(n,o){let r=!1;for(let o=0;o<n.selection.ranges.length&&!r;o++){let{$from:{pos:i},$to:{pos:s}}=n.selection.ranges[o];n.doc.nodesBetween(i,s,(o,i)=>{if(r)return!1;if(o.isTextblock&&!o.hasMarkup(t,e))if(o.type==t)r=!0;else{let e=n.doc.resolve(i),o=e.index();r=e.parent.canReplaceWith(o,o+1,t)}})}if(!r)return!1;if(o){let r=n.tr;for(let o=0;o<n.selection.ranges.length;o++){let{$from:{pos:i},$to:{pos:s}}=n.selection.ranges[o];r.setBlockType(i,s,t,e)}o(r.scrollIntoView())}return!0}}function Ri(...t){return function(e,n,o){for(let r=0;r<t.length;r++)if(t[r](e,n,o))return!0;return!1}}let ji=Ri(hi,ui,gi),Ii=Ri(hi,vi,wi);const Pi={Enter:Ri(xi,Si,Ti,(t,e)=>{let{$from:n,$to:o}=t.selection;if(t.selection instanceof Ce&&t.selection.node.isBlock)return!(!n.parentOffset||!Xt(t.doc,n.pos)||(e&&e(t.tr.split(n.pos).scrollIntoView()),0));if(!n.depth)return!1;let r,i,s=[],l=!1,a=!1;for(let t=n.depth;;t--){if(n.node(t).isBlock){l=n.end(t)==n.pos+(n.depth-t),a=n.start(t)==n.pos-(n.depth-t),i=Mi(n.node(t-1).contentMatchAt(n.indexAfter(t-1)));let e=Ai;s.unshift(e||(l&&i?{type:i}:null)),r=t;break}if(1==t)return!1;s.unshift(null)}let c=t.tr;(t.selection instanceof xe||t.selection instanceof Te)&&c.deleteSelection();let d=c.mapping.map(n.pos),h=Xt(c.doc,d,s.length,s);if(h||(s[0]=i?{type:i}:null,h=Xt(c.doc,d,s.length,s)),!h)return!1;if(c.split(d,s.length,s),!l&&a&&n.node(r).type!=i){let t=c.mapping.map(n.before(r)),e=c.doc.resolve(t);i&&n.node(r-1).canReplaceWith(e.index(),e.index()+1,i)&&c.setNodeMarkup(c.mapping.map(n.before(r)),i)}return e&&e(c.scrollIntoView()),!0}),"Mod-Enter":Ci,Backspace:ji,"Mod-Backspace":ji,"Shift-Backspace":ji,Delete:Ii,"Mod-Delete":Ii,"Mod-a":(t,e)=>(e&&e(t.tr.setSelection(new Te(t.doc))),!0)},zi={"Ctrl-h":Pi.Backspace,"Alt-Backspace":Pi["Mod-Backspace"],"Ctrl-d":Pi.Delete,"Ctrl-Alt-Backspace":Pi["Mod-Delete"],"Alt-Delete":Pi["Mod-Delete"],"Alt-d":Pi["Mod-Delete"],"Ctrl-a":Ni,"Ctrl-e":Di};for(let t in Pi)zi[t]=Pi[t];"undefined"!=typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):"undefined"!=typeof os&&os.platform&&os.platform();var $i=Object.defineProperty,Hi=(t,e)=>{for(var n in e)$i(t,n,{get:e[n],enumerable:!0})};function Bi(t){const{state:e,transaction:n}=t;let{selection:o}=n,{doc:r}=n,{storedMarks:i}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return i},get selection(){return o},get doc(){return r},get tr(){return o=n.selection,r=n.doc,i=n.storedMarks,n}}}var Vi=class{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:o}=e,{tr:r}=n,i=this.buildProps(r);return Object.fromEntries(Object.entries(t).map(([t,e])=>[t,(...t)=>{const n=e(...t)(i);return r.getMeta("preventDispatch")||this.hasCustomState||o.dispatch(r),n}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:o,state:r}=this,{view:i}=o,s=[],l=!!t,a=t||r.tr,c={...Object.fromEntries(Object.entries(n).map(([t,n])=>[t,(...t)=>{const o=this.buildProps(a,e),r=n(...t)(o);return s.push(r),c}])),run:()=>(l||!e||a.getMeta("preventDispatch")||this.hasCustomState||i.dispatch(a),s.every(t=>!0===t))};return c}createCan(t){const{rawCommands:e,state:n}=this,o=!1,r=t||n.tr,i=this.buildProps(r,o);return{...Object.fromEntries(Object.entries(e).map(([t,e])=>[t,(...t)=>e(...t)({...i,dispatch:void 0})])),chain:()=>this.createChain(r,o)}}buildProps(t,e=!0){const{rawCommands:n,editor:o,state:r}=this,{view:i}=o,s={tr:t,editor:o,view:i,state:Bi({state:r,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map(([t,e])=>[t,(...t)=>e(...t)(s)]))}};return s}},_i=class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const n=this.callbacks[t];return n&&n.forEach(t=>t.apply(this,e)),this}off(t,e){const n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter(t=>t!==e):delete this.callbacks[t]),this}once(t,e){const n=(...o)=>{this.off(t,n),e.apply(this,o)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}};function Fi(t,e){const n=new ge(t);return e.forEach(t=>{t.steps.forEach(t=>{n.step(t)})}),n}var Wi=t=>{const e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){const o=e[n];3===o.nodeType&&o.nodeValue&&/^(\n\s\s|\n)$/.test(o.nodeValue)?t.removeChild(o):1===o.nodeType&&Wi(o)}return t};function qi(t){if("undefined"==typeof window)throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${t}</body>`,n=(new window.DOMParser).parseFromString(e,"text/html").body;return Wi(n)}function Ki(t,e,n){if(t instanceof q||t instanceof k)return t;n={slice:!0,parseOptions:{},...n};const o="string"==typeof t;if("object"==typeof t&&null!==t)try{if(Array.isArray(t)&&t.length>0)return k.fromArray(t.map(t=>e.nodeFromJSON(t)));const o=e.nodeFromJSON(t);return n.errorOnInvalidContent&&o.check(),o}catch(o){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:o});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",o),Ki("",e,n)}if(o){if(n.errorOnInvalidContent){let o=!1,r="";const i=new dt({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:t=>(o=!0,r="string"==typeof t?t:t.outerHTML,null)}]}})});if(n.slice?pt.fromSchema(i).parseSlice(qi(t),n.parseOptions):pt.fromSchema(i).parse(qi(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${r}`)})}const o=pt.fromSchema(e);return n.slice?o.parseSlice(qi(t),n.parseOptions).content:o.parse(qi(t),n.parseOptions)}return Ki("",e,n)}function Ji(t,e,n={},o={}){return Ki(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:o.errorOnInvalidContent})}function Ui(t,e){for(let n=t.depth;n>0;n-=1){const o=t.node(n);if(e(o))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:o}}}function Gi(t){return e=>Ui(e.$from,t)}function Yi(t,e,n){return void 0===t.config[e]&&t.parent?Yi(t.parent,e,n):"function"==typeof t.config[e]?t.config[e].bind({...n,parent:t.parent?Yi(t.parent,e,n):null}):t.config[e]}function Xi(t){return t.map(t=>{const e=Yi(t,"addExtensions",{name:t.name,options:t.options,storage:t.storage});return e?[t,...Xi(e())]:t}).flat(10)}function Qi(t,e){const n=xt.fromSchema(e).serializeFragment(t),o=document.implementation.createHTMLDocument().createElement("div");return o.appendChild(n),o.innerHTML}function Zi(t){return"function"==typeof t}function ts(t,e=void 0,...n){return Zi(t)?e?t.bind(e)(...n):t(...n):t}function es(t){return{baseExtensions:t.filter(t=>"extension"===t.type),nodeExtensions:t.filter(t=>"node"===t.type),markExtensions:t.filter(t=>"mark"===t.type)}}function ns(t){const e=[],{nodeExtensions:n,markExtensions:o}=es(t),r=[...n,...o],i={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach(t=>{const n=Yi(t,"addGlobalAttributes",{name:t.name,options:t.options,storage:t.storage,extensions:r});n&&n().forEach(t=>{t.types.forEach(n=>{Object.entries(t.attributes).forEach(([t,o])=>{e.push({type:n,name:t,attribute:{...i,...o}})})})})}),r.forEach(t=>{const n={name:t.name,options:t.options,storage:t.storage},o=Yi(t,"addAttributes",n);if(!o)return;const r=o();Object.entries(r).forEach(([n,o])=>{const r={...i,...o};"function"==typeof(null==r?void 0:r.default)&&(r.default=r.default()),(null==r?void 0:r.isRequired)&&void 0===(null==r?void 0:r.default)&&delete r.default,e.push({type:t.name,name:n,attribute:r})})}),e}function rs(...t){return t.filter(t=>!!t).reduce((t,e)=>{const n={...t};return Object.entries(e).forEach(([t,e])=>{if(n[t])if("class"===t){const o=e?String(e).split(" "):[],r=n[t]?n[t].split(" "):[],i=o.filter(t=>!r.includes(t));n[t]=[...r,...i].join(" ")}else if("style"===t){const o=e?e.split(";").map(t=>t.trim()).filter(Boolean):[],r=n[t]?n[t].split(";").map(t=>t.trim()).filter(Boolean):[],i=new Map;r.forEach(t=>{const[e,n]=t.split(":").map(t=>t.trim());i.set(e,n)}),o.forEach(t=>{const[e,n]=t.split(":").map(t=>t.trim());i.set(e,n)}),n[t]=Array.from(i.entries()).map(([t,e])=>`${t}: ${e}`).join("; ")}else n[t]=e;else n[t]=e}),n},{})}function is(t,e){return e.filter(e=>e.type===t.type.name).filter(t=>t.attribute.rendered).map(e=>e.attribute.renderHTML?e.attribute.renderHTML(t.attrs)||{}:{[e.name]:t.attrs[e.name]}).reduce((t,e)=>rs(t,e),{})}function ss(t,e){return"style"in t?t:{...t,getAttrs:n=>{const o=t.getAttrs?t.getAttrs(n):t.attrs;if(!1===o)return!1;const r=e.reduce((t,e)=>{const o=e.attribute.parseHTML?e.attribute.parseHTML(n):function(t){return"string"!=typeof t?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):"true"===t||"false"!==t&&t}(n.getAttribute(e.name));return null==o?t:{...t,[e.name]:o}},{});return{...o,...r}}}}function ls(t){return Object.fromEntries(Object.entries(t).filter(([t,e])=>("attrs"!==t||!function(t={}){return 0===Object.keys(t).length&&t.constructor===Object}(e))&&null!=e))}function as(t){return t.sort((t,e)=>{const n=Yi(t,"priority")||100,o=Yi(e,"priority")||100;return n>o?-1:n<o?1:0})}function cs(t){const e=as(Xi(t)),n=function(t){const e=t.filter((e,n)=>t.indexOf(e)!==n);return Array.from(new Set(e))}(e.map(t=>t.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(t=>`'${t}'`).join(", ")}]. This can lead to issues.`),e}function ds(t,e,n){const{from:o,to:r}=e,{blockSeparator:i="\n\n",textSerializers:s={}}=n||{};let l="";return t.nodesBetween(o,r,(t,n,a,c)=>{var d;t.isBlock&&n>o&&(l+=i);const h=null==s?void 0:s[t.type.name];if(h)return a&&(l+=h({node:t,pos:n,parent:a,index:c,range:e})),!1;t.isText&&(l+=null==(d=null==t?void 0:t.text)?void 0:d.slice(Math.max(o,n)-n,r-n))}),l}function hs(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,t])=>t.spec.toText).map(([t,e])=>[t,e.spec.toText]))}function ps(t,e){if("string"==typeof t){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}function us(t,e){const n=ps(e,t.schema),{from:o,to:r,empty:i}=t.selection,s=[];i?(t.storedMarks&&s.push(...t.storedMarks),s.push(...t.selection.$head.marks())):t.doc.nodesBetween(o,r,t=>{s.push(...t.marks)});const l=s.find(t=>t.type.name===n.name);return l?{...l.attrs}:{}}function fs(t,e){if("string"==typeof t){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}function ms(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function gs(t,e){const n=ms("string"==typeof e?e:e.name,t.schema);return"node"===n?function(t,e){const n=fs(e,t.schema),{from:o,to:r}=t.selection,i=[];t.doc.nodesBetween(o,r,t=>{i.push(t)});const s=i.reverse().find(t=>t.type.name===n.name);return s?{...s.attrs}:{}}(t,e):"mark"===n?us(t,e):{}}function ys(t){const{mapping:e,steps:n}=t,o=[];return e.maps.forEach((t,r)=>{const i=[];if(t.ranges.length)t.forEach((t,e)=>{i.push({from:t,to:e})});else{const{from:t,to:e}=n[r];if(void 0===t||void 0===e)return;i.push({from:t,to:e})}i.forEach(({from:t,to:n})=>{const i=e.slice(r).map(t,-1),s=e.slice(r).map(n),l=e.invert().map(i,-1),a=e.invert().map(s);o.push({oldRange:{from:l,to:a},newRange:{from:i,to:s}})})}),function(t){const e=function(t,e=JSON.stringify){const n={};return t.filter(t=>{const o=e(t);return!Object.prototype.hasOwnProperty.call(n,o)&&(n[o]=!0)})}(t);return 1===e.length?e:e.filter((t,n)=>{const o=e.filter((t,e)=>e!==n);return!o.some(e=>t.oldRange.from>=e.oldRange.from&&t.oldRange.to<=e.oldRange.to&&t.newRange.from>=e.newRange.from&&t.newRange.to<=e.newRange.to)})}(o)}function bs(t){return"[object RegExp]"===Object.prototype.toString.call(t)}function vs(t,e,n={strict:!0}){const o=Object.keys(e);return!o.length||o.every(o=>n.strict?e[o]===t[o]:bs(e[o])?e[o].test(t[o]):e[o]===t[o])}function ws(t,e,n={}){return t.find(t=>t.type===e&&vs(Object.fromEntries(Object.keys(n).map(e=>[e,t.attrs[e]])),n))}function ks(t,e,n={}){return!!ws(t,e,n)}function xs(t,e,n){var o;if(!t||!e)return;let r=t.parent.childAfter(t.parentOffset);if(r.node&&r.node.marks.some(t=>t.type===e)||(r=t.parent.childBefore(t.parentOffset)),!r.node||!r.node.marks.some(t=>t.type===e))return;if(n=n||(null==(o=r.node.marks[0])?void 0:o.attrs),!ws([...r.node.marks],e,n))return;let i=r.index,s=t.start()+r.offset,l=i+1,a=s+r.node.nodeSize;for(;i>0&&ks([...t.parent.child(i-1).marks],e,n);)i-=1,s-=t.parent.child(i).nodeSize;for(;l<t.parent.childCount&&ks([...t.parent.child(l).marks],e,n);)a+=t.parent.child(l).nodeSize,l+=1;return{from:s,to:a}}function Ms(t,e,n){const o=[];return t===e?n.resolve(t).marks().forEach(e=>{const r=xs(n.resolve(t),e.type);r&&o.push({mark:e,...r})}):n.nodesBetween(t,e,(t,e)=>{t&&void 0!==(null==t?void 0:t.nodeSize)&&o.push(...t.marks.map(n=>({from:e,to:e+t.nodeSize,mark:n})))}),o}function Cs(t,e){return e.nodes[t]||e.marks[t]||null}function Ss(t,e,n){return Object.fromEntries(Object.entries(n).filter(([n])=>{const o=t.find(t=>t.type===e&&t.name===n);return!!o&&o.attribute.keepOnSplit}))}function Ts(t,e,n={}){const{empty:o,ranges:r}=t.selection,i=e?ps(e,t.schema):null;if(o)return!!(t.storedMarks||t.selection.$from.marks()).filter(t=>!i||i.name===t.type.name).find(t=>vs(t.attrs,n,{strict:!1}));let s=0;const l=[];if(r.forEach(({$from:e,$to:n})=>{const o=e.pos,r=n.pos;t.doc.nodesBetween(o,r,(t,e)=>{if(!t.isText&&!t.marks.length)return;const n=Math.max(o,e),i=Math.min(r,e+t.nodeSize);s+=i-n,l.push(...t.marks.map(t=>({mark:t,from:n,to:i})))})}),0===s)return!1;const a=l.filter(t=>!i||i.name===t.mark.type.name).filter(t=>vs(t.mark.attrs,n,{strict:!1})).reduce((t,e)=>t+e.to-e.from,0),c=l.filter(t=>!i||t.mark.type!==i&&t.mark.type.excludes(i)).reduce((t,e)=>t+e.to-e.from,0);return(a>0?a+c:a)>=s}function As(t,e,n={}){const{from:o,to:r,empty:i}=t.selection,s=e?fs(e,t.schema):null,l=[];t.doc.nodesBetween(o,r,(t,e)=>{if(t.isText)return;const n=Math.max(o,e),i=Math.min(r,e+t.nodeSize);l.push({node:t,from:n,to:i})});const a=r-o,c=l.filter(t=>!s||s.name===t.node.type.name).filter(t=>vs(t.node.attrs,n,{strict:!1}));return i?!!c.length:c.reduce((t,e)=>t+e.to-e.from,0)>=a}function Es(t,e){return Array.isArray(e)?e.some(e=>("string"==typeof e?e:e.name)===t.name):e}function Os(t,e){const{nodeExtensions:n}=es(e),o=n.find(e=>e.name===t);if(!o)return!1;const r=ts(Yi(o,"group",{name:o.name,options:o.options,storage:o.storage}));return"string"==typeof r&&r.split(" ").includes("list")}function Ns(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var o;if(n){if("hardBreak"===t.type.name)return!0;if(t.isText)return/^\s*$/m.test(null!=(o=t.text)?o:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(0===t.content.childCount)return!0;if(e){let o=!0;return t.content.forEach(t=>{!1!==o&&(Ns(t,{ignoreWhitespace:n,checkChildren:e})||(o=!1))}),o}return!1}function Ds(t){return t instanceof Ce}function Ls(t){return t instanceof xe}function Rs(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function js(t,e=null){if(!e)return null;const n=be.atStart(t),o=be.atEnd(t);if("start"===e||!0===e)return n;if("end"===e)return o;const r=n.from,i=o.to;return"all"===e?xe.create(t,Rs(0,r,i),Rs(t.content.size,r,i)):xe.create(t,Rs(e,r,i),Rs(e,r,i))}var Is=class{constructor(t){this.find=t.find,this.handler=t.handler}};function Ps(t){var e;const{editor:n,from:o,to:r,text:i,rules:s,plugin:l}=t,{view:a}=n;if(a.composing)return!1;const c=a.state.doc.resolve(o);if(c.parent.type.spec.code||(null==(e=c.nodeBefore||c.nodeAfter)?void 0:e.marks.find(t=>t.type.spec.code)))return!1;let d=!1;const h=((t,e=500)=>{let n="";const o=t.parentOffset;return t.parent.nodesBetween(Math.max(0,o-e),o,(t,e,r,i)=>{var s,l;const a=(null==(l=(s=t.type.spec).toText)?void 0:l.call(s,{node:t,pos:e,parent:r,index:i}))||t.textContent||"%leaf%";n+=t.isAtom&&!t.isText?a:a.slice(0,Math.max(0,o-e))}),n})(c)+i;return s.forEach(t=>{if(d)return;const e=((t,e)=>{if(bs(e))return e.exec(t);const n=e(t);if(!n)return null;const o=[n.text];return o.index=n.index,o.input=t,o.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),o.push(n.replaceWith)),o})(h,t.find);if(!e)return;const s=a.state.tr,c=Bi({state:a.state,transaction:s}),p={from:o-(e[0].length-i.length),to:r},{commands:u,chain:f,can:m}=new Vi({editor:n,state:c});null!==t.handler({state:c,range:p,match:e,commands:u,chain:f,can:m})&&s.steps.length&&(s.setMeta(l,{transform:s,from:o,to:r,text:i}),a.dispatch(s),d=!0)}),d}function zs(t){return"Object"===function(t){return Object.prototype.toString.call(t).slice(8,-1)}(t)&&t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function $s(t,e){const n={...t};return zs(t)&&zs(e)&&Object.keys(e).forEach(o=>{zs(e[o])&&zs(t[o])?n[o]=$s(t[o],e[o]):n[o]=e[o]}),n}var Hs=class{constructor(t={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...t},this.name=this.config.name}get options(){return{...ts(Yi(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...ts(Yi(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>$s(this.options,t)});return e.name=this.name,e.parent=this.parent,e}extend(t={}){const e=new this.constructor({...this.config,...t});return e.parent=this,this.child=e,e.name="name"in t?t.name:e.parent.name,e}},Bs=class t extends Hs{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n="function"==typeof e?e():e;return new t(n)}static handleExit({editor:t,mark:e}){const{tr:n}=t.state,o=t.state.selection.$from;if(o.pos===o.end()){const r=o.marks();if(!r.find(t=>(null==t?void 0:t.type.name)===e.name))return!1;const i=r.find(t=>(null==t?void 0:t.type.name)===e.name);return i&&n.removeStoredMark(i),n.insertText(" ",o.pos),t.view.dispatch(n),!0}return!1}configure(t){return super.configure(t)}extend(t){const e="function"==typeof t?t():t;return super.extend(e)}},Vs=class{constructor(t){this.find=t.find,this.handler=t.handler}};var _s=null;function Fs(t){const{editor:e,rules:n}=t;let o,r=null,i=!1,s=!1,l="undefined"!=typeof ClipboardEvent?new ClipboardEvent("paste"):null;try{o="undefined"!=typeof DragEvent?new DragEvent("drop"):null}catch{o=null}const a=({state:t,from:n,to:r,rule:i,pasteEvt:s})=>{const a=t.tr,c=Bi({state:t,transaction:a});if(function(t){const{editor:e,state:n,from:o,to:r,rule:i,pasteEvent:s,dropEvent:l}=t,{commands:a,chain:c,can:d}=new Vi({editor:e,state:n}),h=[];return n.doc.nodesBetween(o,r,(t,e)=>{var p,u,f,m,g;if((null==(u=null==(p=t.type)?void 0:p.spec)?void 0:u.code)||!(t.isText||t.isTextblock||t.isInline))return;const y=null!=(g=null!=(m=null==(f=t.content)?void 0:f.size)?m:t.nodeSize)?g:0,b=Math.max(o,e),v=Math.min(r,e+y);if(b>=v)return;const w=((t,e,n)=>{if(bs(e))return[...t.matchAll(e)];const o=e(t,n);return o?o.map(e=>{const n=[e.text];return n.index=e.index,n.input=t,n.data=e.data,e.replaceWith&&(e.text.includes(e.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),n.push(e.replaceWith)),n}):[]})(t.isText?t.text||"":t.textBetween(b-e,v-e,void 0,""),i.find,s);w.forEach(t=>{if(void 0===t.index)return;const e=b+t.index+1,o=e+t[0].length,r={from:n.tr.mapping.map(e),to:n.tr.mapping.map(o)},p=i.handler({state:n,range:r,match:t,commands:a,chain:c,can:d,pasteEvent:s,dropEvent:l});h.push(p)})}),h.every(t=>null!==t)}({editor:e,state:c,from:Math.max(n-1,0),to:r.b-1,rule:i,pasteEvent:s,dropEvent:o})&&a.steps.length){try{o="undefined"!=typeof DragEvent?new DragEvent("drop"):null}catch{o=null}return l="undefined"!=typeof ClipboardEvent?new ClipboardEvent("paste"):null,a}};return n.map(t=>new ze({view(t){const n=n=>{var o;r=(null==(o=t.dom.parentElement)?void 0:o.contains(n.target))?t.dom.parentElement:null,r&&(_s=e)},o=()=>{_s&&(_s=null)};return window.addEventListener("dragstart",n),window.addEventListener("dragend",o),{destroy(){window.removeEventListener("dragstart",n),window.removeEventListener("dragend",o)}}},props:{handleDOMEvents:{drop:(t,e)=>{if(s=r===t.dom.parentElement,o=e,!s){const t=_s;(null==t?void 0:t.isEditable)&&setTimeout(()=>{const e=t.state.selection;e&&t.commands.deleteRange({from:e.from,to:e.to})},10)}return!1},paste:(t,e)=>{var n;const o=null==(n=e.clipboardData)?void 0:n.getData("text/html");return l=e,i=!!(null==o?void 0:o.includes("data-pm-slice")),!1}}},appendTransaction:(e,n,o)=>{const r=e[0],c="paste"===r.getMeta("uiEvent")&&!i,d="drop"===r.getMeta("uiEvent")&&!s,h=r.getMeta("applyPasteRules"),p=!!h;if(!c&&!d&&!p)return;if(p){let{text:e}=h;"string"==typeof e||(e=Qi(k.from(e),o.schema));const{from:n}=h,r=n+e.length,i=(t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return null==(e=n.clipboardData)||e.setData("text/html",t),n})(e);return a({rule:t,state:o,from:n,to:{b:r},pasteEvt:i})}const u=n.doc.content.findDiffStart(o.doc.content),f=n.doc.content.findDiffEnd(o.doc.content);return"number"==typeof u&&f&&u!==f.b?a({rule:t,state:o,from:u,to:f,pasteEvt:l}):void 0}}))}var Ws=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.extensions=cs(t),this.schema=function(t,e){var n;const o=ns(t),{nodeExtensions:r,markExtensions:i}=es(t),s=null==(n=r.find(t=>Yi(t,"topNode")))?void 0:n.name,l=Object.fromEntries(r.map(n=>{const r=o.filter(t=>t.type===n.name),i={name:n.name,options:n.options,storage:n.storage,editor:e},s=ls({...t.reduce((t,e)=>{const o=Yi(e,"extendNodeSchema",i);return{...t,...o?o(n):{}}},{}),content:ts(Yi(n,"content",i)),marks:ts(Yi(n,"marks",i)),group:ts(Yi(n,"group",i)),inline:ts(Yi(n,"inline",i)),atom:ts(Yi(n,"atom",i)),selectable:ts(Yi(n,"selectable",i)),draggable:ts(Yi(n,"draggable",i)),code:ts(Yi(n,"code",i)),whitespace:ts(Yi(n,"whitespace",i)),linebreakReplacement:ts(Yi(n,"linebreakReplacement",i)),defining:ts(Yi(n,"defining",i)),isolating:ts(Yi(n,"isolating",i)),attrs:Object.fromEntries(r.map(t=>{var e,n;return[t.name,{default:null==(e=null==t?void 0:t.attribute)?void 0:e.default,validate:null==(n=null==t?void 0:t.attribute)?void 0:n.validate}]}))}),l=ts(Yi(n,"parseHTML",i));l&&(s.parseDOM=l.map(t=>ss(t,r)));const a=Yi(n,"renderHTML",i);a&&(s.toDOM=t=>a({node:t,HTMLAttributes:is(t,r)}));const c=Yi(n,"renderText",i);return c&&(s.toText=c),[n.name,s]})),a=Object.fromEntries(i.map(n=>{const r=o.filter(t=>t.type===n.name),i={name:n.name,options:n.options,storage:n.storage,editor:e},s=ls({...t.reduce((t,e)=>{const o=Yi(e,"extendMarkSchema",i);return{...t,...o?o(n):{}}},{}),inclusive:ts(Yi(n,"inclusive",i)),excludes:ts(Yi(n,"excludes",i)),group:ts(Yi(n,"group",i)),spanning:ts(Yi(n,"spanning",i)),code:ts(Yi(n,"code",i)),attrs:Object.fromEntries(r.map(t=>{var e,n;return[t.name,{default:null==(e=null==t?void 0:t.attribute)?void 0:e.default,validate:null==(n=null==t?void 0:t.attribute)?void 0:n.validate}]}))}),l=ts(Yi(n,"parseHTML",i));l&&(s.parseDOM=l.map(t=>ss(t,r)));const a=Yi(n,"renderHTML",i);return a&&(s.toDOM=t=>a({mark:t,HTMLAttributes:is(t,r)})),[n.name,s]}));return new dt({topNode:s,nodes:l,marks:a})}(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((t,e)=>{const n=Yi(e,"addCommands",{name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Cs(e.name,this.schema)});return n?{...t,...n()}:t},{})}get plugins(){const{editor:t}=this,e=as([...this.extensions].reverse()).map(e=>{const n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:t,type:Cs(e.name,this.schema)},o=[],r=Yi(e,"addKeyboardShortcuts",n);let i={};if("mark"===e.type&&Yi(e,"exitable",n)&&(i.ArrowRight=()=>Bs.handleExit({editor:t,mark:e})),r){const e=Object.fromEntries(Object.entries(r()).map(([e,n])=>[e,()=>n({editor:t})]));i={...i,...e}}const s=new ze({props:{handleKeyDown:di(i)}});o.push(s);const l=Yi(e,"addInputRules",n);if(Es(e,t.options.enableInputRules)&&l){const e=l();if(e&&e.length){const n=function(t){const{editor:e,rules:n}=t,o=new ze({state:{init:()=>null,apply(t,r,i){const s=t.getMeta(o);if(s)return s;const l=t.getMeta("applyInputRules");return!!l&&setTimeout(()=>{let{text:t}=l;"string"==typeof t||(t=Qi(k.from(t),i.schema));const{from:r}=l,s=r+t.length;Ps({editor:e,from:r,to:s,text:t,rules:n,plugin:o})}),t.selectionSet||t.docChanged?null:r}},props:{handleTextInput:(t,r,i,s)=>Ps({editor:e,from:r,to:i,text:s,rules:n,plugin:o}),handleDOMEvents:{compositionend:t=>(setTimeout(()=>{const{$cursor:r}=t.state.selection;r&&Ps({editor:e,from:r.pos,to:r.pos,text:"",rules:n,plugin:o})}),!1)},handleKeyDown(t,r){if("Enter"!==r.key)return!1;const{$cursor:i}=t.state.selection;return!!i&&Ps({editor:e,from:i.pos,to:i.pos,text:"\n",rules:n,plugin:o})}},isInputRules:!0});return o}({editor:t,rules:e}),r=Array.isArray(n)?n:[n];o.push(...r)}}const a=Yi(e,"addPasteRules",n);if(Es(e,t.options.enablePasteRules)&&a){const e=a();if(e&&e.length){const n=Fs({editor:t,rules:e});o.push(...n)}}const c=Yi(e,"addProseMirrorPlugins",n);if(c){const t=c();o.push(...t)}return o}).flat();return e}get attributes(){return ns(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=es(this.extensions);return Object.fromEntries(e.filter(t=>!!Yi(t,"addNodeView")).map(e=>{const n=this.attributes.filter(t=>t.type===e.name),o={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:t,type:fs(e.name,this.schema)},r=Yi(e,"addNodeView",o);return r?[e.name,(o,i,s,l,a)=>{const c=is(o,n);return r()({node:o,view:i,getPos:s,decorations:l,innerDecorations:a,editor:t,extension:e,HTMLAttributes:c})}]:[]}))}get markViews(){const{editor:t}=this,{markExtensions:e}=es(this.extensions);return Object.fromEntries(e.filter(t=>!!Yi(t,"addMarkView")).map(e=>{const n=this.attributes.filter(t=>t.type===e.name),o={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:t,type:ps(e.name,this.schema)},r=Yi(e,"addMarkView",o);return r?[e.name,(o,i,s)=>{const l=is(o,n);return r()({mark:o,view:i,inline:s,editor:t,extension:e,HTMLAttributes:l,updateAttributes:e=>{!function(t,e,n={}){const{state:o}=e,{doc:r,tr:i}=o,s=t;r.descendants((e,o)=>{const r=i.mapping.map(o),l=i.mapping.map(o)+e.nodeSize;let a=null;if(e.marks.forEach(t=>{if(t!==s)return!1;a=t}),!a)return;let c=!1;if(Object.keys(n).forEach(t=>{n[t]!==a.attrs[t]&&(c=!0)}),c){const e=t.type.create({...t.attrs,...n});i.removeMark(r,l,t.type),i.addMark(r,l,e)}}),i.docChanged&&e.view.dispatch(i)}(o,t,e)}})}]:[]}))}setupExtensions(){const t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(t=>[t.name,t.storage])),t.forEach(t=>{var e;const n={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:this.editor,type:Cs(t.name,this.schema)};"mark"===t.type&&(null==(e=ts(Yi(t,"keepOnSplit",n)))||e)&&this.splittableMarks.push(t.name);const o=Yi(t,"onBeforeCreate",n),r=Yi(t,"onCreate",n),i=Yi(t,"onUpdate",n),s=Yi(t,"onSelectionUpdate",n),l=Yi(t,"onTransaction",n),a=Yi(t,"onFocus",n),c=Yi(t,"onBlur",n),d=Yi(t,"onDestroy",n);o&&this.editor.on("beforeCreate",o),r&&this.editor.on("create",r),i&&this.editor.on("update",i),s&&this.editor.on("selectionUpdate",s),l&&this.editor.on("transaction",l),a&&this.editor.on("focus",a),c&&this.editor.on("blur",c),d&&this.editor.on("destroy",d)})}};Ws.resolve=cs,Ws.sort=as,Ws.flatten=Xi,Hi({},{ClipboardTextSerializer:()=>Ks,Commands:()=>ra,Delete:()=>ia,Drop:()=>sa,Editable:()=>la,FocusEvents:()=>ca,Keymap:()=>da,Paste:()=>ha,Tabindex:()=>pa,focusEventsPluginKey:()=>aa});var qs=class t extends Hs{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n="function"==typeof e?e():e;return new t(n)}configure(t){return super.configure(t)}extend(t){const e="function"==typeof t?t():t;return super.extend(e)}},Ks=qs.create({name:"clipboardTextSerializer",addOptions:()=>({blockSeparator:void 0}),addProseMirrorPlugins(){return[new ze({key:new Be("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:o,selection:r}=e,{ranges:i}=r,s=Math.min(...i.map(t=>t.$from.pos)),l=Math.max(...i.map(t=>t.$to.pos)),a=hs(n);return ds(o,{from:s,to:l},{...void 0!==this.options.blockSeparator?{blockSeparator:this.options.blockSeparator}:{},textSerializers:a})}}})]}}),Js={};Hi(Js,{blur:()=>Us,clearContent:()=>Gs,clearNodes:()=>Ys,command:()=>Xs,createParagraphNear:()=>Qs,cut:()=>Zs,deleteCurrentNode:()=>tl,deleteNode:()=>el,deleteRange:()=>nl,deleteSelection:()=>ol,enter:()=>rl,exitCode:()=>il,extendMarkRange:()=>sl,first:()=>ll,focus:()=>cl,forEach:()=>dl,insertContent:()=>hl,insertContentAt:()=>pl,joinBackward:()=>ml,joinDown:()=>fl,joinForward:()=>gl,joinItemBackward:()=>yl,joinItemForward:()=>bl,joinTextblockBackward:()=>vl,joinTextblockForward:()=>wl,joinUp:()=>ul,keyboardShortcut:()=>xl,lift:()=>Ml,liftEmptyBlock:()=>Cl,liftListItem:()=>Sl,newlineInCode:()=>Tl,resetAttributes:()=>El,scrollIntoView:()=>Ol,selectAll:()=>Nl,selectNodeBackward:()=>Dl,selectNodeForward:()=>Ll,selectParentNode:()=>Rl,selectTextblockEnd:()=>jl,selectTextblockStart:()=>Il,setContent:()=>Pl,setMark:()=>zl,setMeta:()=>$l,setNode:()=>Hl,setNodeSelection:()=>Bl,setTextSelection:()=>Vl,sinkListItem:()=>_l,splitBlock:()=>Wl,splitListItem:()=>ql,toggleList:()=>Ul,toggleMark:()=>Gl,toggleNode:()=>Yl,toggleWrap:()=>Xl,undoInputRule:()=>Ql,unsetAllMarks:()=>Zl,unsetMark:()=>ta,updateAttributes:()=>ea,wrapIn:()=>na,wrapInList:()=>oa});var Us=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),null==(n=null==window?void 0:window.getSelection())||n.removeAllRanges())}),!0),Gs=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),Ys=()=>({state:t,tr:e,dispatch:n})=>{const{selection:o}=e,{ranges:r}=o;return!n||(r.forEach(({$from:n,$to:o})=>{t.doc.nodesBetween(n.pos,o.pos,(t,n)=>{if(t.type.isText)return;const{doc:o,mapping:r}=e,i=o.resolve(r.map(n)),s=o.resolve(r.map(n+t.nodeSize)),l=i.blockRange(s);if(!l)return;const a=Kt(l);if(t.type.isTextblock){const{defaultType:t}=i.parent.contentMatchAt(i.index());e.setNodeMarkup(l.start,t)}(a||0===a)&&e.lift(l,a)})}),!0)},Xs=t=>e=>t(e),Qs=()=>({state:t,dispatch:e})=>Si(t,e),Zs=(t,e)=>({editor:n,tr:o})=>{const{state:r}=n,i=r.doc.slice(t.from,t.to);o.deleteRange(t.from,t.to);const s=o.mapping.map(e);return o.insert(s,i.content),o.setSelection(new xe(o.doc.resolve(Math.max(s-1,0)))),!0},tl=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,o=n.$anchor.node();if(o.content.size>0)return!1;const r=t.selection.$anchor;for(let n=r.depth;n>0;n-=1)if(r.node(n).type===o.type){if(e){const e=r.before(n),o=r.after(n);t.delete(e,o).scrollIntoView()}return!0}return!1},el=t=>({tr:e,state:n,dispatch:o})=>{const r=fs(t,n.schema),i=e.selection.$anchor;for(let t=i.depth;t>0;t-=1)if(i.node(t).type===r){if(o){const n=i.before(t),o=i.after(t);e.delete(n,o).scrollIntoView()}return!0}return!1},nl=t=>({tr:e,dispatch:n})=>{const{from:o,to:r}=t;return n&&e.delete(o,r),!0},ol=()=>({state:t,dispatch:e})=>hi(t,e),rl=()=>({commands:t})=>t.keyboardShortcut("Enter"),il=()=>({state:t,dispatch:e})=>Ci(t,e),sl=(t,e={})=>({tr:n,state:o,dispatch:r})=>{const i=ps(t,o.schema),{doc:s,selection:l}=n,{$from:a,from:c,to:d}=l;if(r){const t=xs(a,i,e);if(t&&t.from<=c&&t.to>=d){const e=xe.create(s,t.from,t.to);n.setSelection(e)}}return!0},ll=t=>e=>{const n="function"==typeof t?t(e):t;for(let t=0;t<n.length;t+=1)if(n[t](e))return!0;return!1};function al(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var cl=(t=null,e={})=>({editor:n,view:o,tr:r,dispatch:i})=>{e={scrollIntoView:!0,...e};const s=()=>{(al()||"Android"===navigator.platform||/android/i.test(navigator.userAgent))&&o.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(o.focus(),(null==e?void 0:e.scrollIntoView)&&n.commands.scrollIntoView())})};if(o.hasFocus()&&null===t||!1===t)return!0;if(i&&null===t&&!Ls(n.state.selection))return s(),!0;const l=js(r.doc,t)||n.state.selection,a=n.state.selection.eq(l);return i&&(a||r.setSelection(l),a&&r.storedMarks&&r.setStoredMarks(r.storedMarks),s()),!0},dl=(t,e)=>n=>t.every((t,o)=>e(t,{...n,index:o})),hl=(t,e)=>({tr:n,commands:o})=>o.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),pl=(t,e,n)=>({tr:o,dispatch:r,editor:i})=>{var s;if(r){let r;n={parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};const{selection:l}=i.state,a=t=>{i.emit("contentError",{editor:i,error:t,disableCollaboration:()=>{"collaboration"in i.storage&&"object"==typeof i.storage.collaboration&&i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!i.options.enableContentCheck&&i.options.emitContentError)try{Ki(e,i.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(t){a(t)}try{r=Ki(e,i.schema,{parseOptions:c,errorOnInvalidContent:null!=(s=n.errorOnInvalidContent)?s:i.options.enableContentCheck})}catch(t){return a(t),!1}let d,{from:h,to:p}="number"==typeof t?{from:t,to:t}:{from:t.from,to:t.to},u=!0,f=!0;if(("type"in r?[r]:r).forEach(t=>{t.check(),u=!!u&&t.isText&&0===t.marks.length,f=!!f&&t.isBlock}),h===p&&f){const{parent:t}=o.doc.resolve(h);t.isTextblock&&!t.type.spec.code&&!t.childCount&&(h-=1,p+=1)}if(u){if(Array.isArray(e))d=e.map(t=>t.text||"").join("");else if(e instanceof k){let t="";e.forEach(e=>{e.text&&(t+=e.text)}),d=t}else d="object"==typeof e&&e&&e.text?e.text:e;o.insertText(d,h,p)}else{d=r;const t=0===l.$from.parentOffset,e=l.$from.node().isText||l.$from.node().isTextblock,n=l.$from.node().content.size>0;t&&e&&n&&(h=Math.max(0,h-1)),o.replaceWith(h,p,d)}n.updateSelection&&function(t,e){const n=t.steps.length-1;if(n<e)return;const o=t.steps[n];if(!(o instanceof Vt||o instanceof _t))return;const r=t.mapping.maps[n];let i=0;r.forEach((t,e,n,o)=>{0===i&&(i=o)}),t.setSelection(be.near(t.doc.resolve(i),-1))}(o,o.steps.length-1),n.applyInputRules&&o.setMeta("applyInputRules",{from:h,text:d}),n.applyPasteRules&&o.setMeta("applyPasteRules",{from:h,text:d})}return!0},ul=()=>({state:t,dispatch:e})=>((t,e)=>{let n,o=t.selection,r=o instanceof Ce;if(r){if(o.node.isTextblock||!Qt(t.doc,o.from))return!1;n=o.from}else if(n=te(t.doc,o.from,-1),null==n)return!1;if(e){let o=t.tr.join(n);r&&o.setSelection(Ce.create(o.doc,n-t.doc.resolve(n).nodeBefore.nodeSize)),e(o.scrollIntoView())}return!0})(t,e),fl=()=>({state:t,dispatch:e})=>((t,e)=>{let n,o=t.selection;if(o instanceof Ce){if(o.node.isTextblock||!Qt(t.doc,o.to))return!1;n=o.to}else if(n=te(t.doc,o.to,1),null==n)return!1;return e&&e(t.tr.join(n).scrollIntoView()),!0})(t,e),ml=()=>({state:t,dispatch:e})=>ui(t,e),gl=()=>({state:t,dispatch:e})=>vi(t,e),yl=()=>({state:t,dispatch:e,tr:n})=>{try{const o=te(t.doc,t.selection.$from.pos,-1);return null!=o&&(n.join(o,2),e&&e(n),!0)}catch{return!1}},bl=()=>({state:t,dispatch:e,tr:n})=>{try{const o=te(t.doc,t.selection.$from.pos,1);return null!=o&&(n.join(o,2),e&&e(n),!0)}catch{return!1}},vl=()=>({state:t,dispatch:e})=>((t,e)=>{let n=pi(t,void 0);if(!n)return!1;let o=yi(n);return!!o&&fi(t,o,e)})(t,e),wl=()=>({state:t,dispatch:e})=>((t,e)=>{let n=bi(t,void 0);if(!n)return!1;let o=ki(n);return!!o&&fi(t,o,e)})(t,e);function kl(){return"undefined"!=typeof navigator&&/Mac/.test(navigator.platform)}var xl=t=>({editor:e,view:n,tr:o,dispatch:r})=>{const i=function(t){const e=t.split(/-(?!$)/);let n,o,r,i,s=e[e.length-1];"Space"===s&&(s=" ");for(let t=0;t<e.length-1;t+=1){const s=e[t];if(/^(cmd|meta|m)$/i.test(s))i=!0;else if(/^a(lt)?$/i.test(s))n=!0;else if(/^(c|ctrl|control)$/i.test(s))o=!0;else if(/^s(hift)?$/i.test(s))r=!0;else{if(!/^mod$/i.test(s))throw new Error(`Unrecognized modifier name: ${s}`);al()||kl()?i=!0:o=!0}}return n&&(s=`Alt-${s}`),o&&(s=`Ctrl-${s}`),i&&(s=`Meta-${s}`),r&&(s=`Shift-${s}`),s}(t).split(/-(?!$)/),s=i.find(t=>!["Alt","Ctrl","Meta","Shift"].includes(t)),l=new KeyboardEvent("keydown",{key:"Space"===s?" ":s,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction(()=>{n.someProp("handleKeyDown",t=>t(n,l))});return null==a||a.steps.forEach(t=>{const e=t.map(o.mapping);e&&r&&o.maybeStep(e)}),!0},Ml=(t,e={})=>({state:n,dispatch:o})=>!!As(n,fs(t,n.schema),e)&&((t,e)=>{let{$from:n,$to:o}=t.selection,r=n.blockRange(o),i=r&&Kt(r);return null!=i&&(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)})(n,o),Cl=()=>({state:t,dispatch:e})=>Ti(t,e),Sl=t=>({state:e,dispatch:n})=>{return(o=fs(t,e.schema),function(t,e){let{$from:n,$to:r}=t.selection,i=n.blockRange(r,t=>t.childCount>0&&t.firstChild.type==o);return!!i&&(!e||(n.node(i.depth-1).type==o?function(t,e,n,o){let r=t.tr,i=o.end,s=o.$to.end(o.depth);i<s&&(r.step(new _t(i-1,s,i,s,new A(k.from(n.create(null,o.parent.copy())),1,0),1,!0)),o=new F(r.doc.resolve(o.$from.pos),r.doc.resolve(s),o.depth));const l=Kt(o);if(null==l)return!1;r.lift(o,l);let a=r.doc.resolve(r.mapping.map(i,-1)-1);return Qt(r.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&r.join(a.pos),e(r.scrollIntoView()),!0}(t,e,o,i):function(t,e,n){let o=t.tr,r=n.parent;for(let t=n.end,e=n.endIndex-1,i=n.startIndex;e>i;e--)t-=r.child(e).nodeSize,o.delete(t-1,t+1);let i=o.doc.resolve(n.start),s=i.nodeAfter;if(o.mapping.map(n.end)!=n.start+i.nodeAfter.nodeSize)return!1;let l=0==n.startIndex,a=n.endIndex==r.childCount,c=i.node(-1),d=i.index(-1);if(!c.canReplace(d+(l?0:1),d+1,s.content.append(a?k.empty:k.from(r))))return!1;let h=i.pos,p=h+s.nodeSize;return o.step(new _t(h-(l?1:0),p+(a?1:0),h+1,p-1,new A((l?k.empty:k.from(r.copy(k.empty))).append(a?k.empty:k.from(r.copy(k.empty))),l?0:1,a?0:1),l?0:1)),e(o.scrollIntoView()),!0}(t,e,i)))})(e,n);var o},Tl=()=>({state:t,dispatch:e})=>xi(t,e);function Al(t,e){const n="string"==typeof e?[e]:e;return Object.keys(t).reduce((e,o)=>(n.includes(o)||(e[o]=t[o]),e),{})}var El=(t,e)=>({tr:n,state:o,dispatch:r})=>{let i=null,s=null;const l=ms("string"==typeof t?t:t.name,o.schema);return!!l&&("node"===l&&(i=fs(t,o.schema)),"mark"===l&&(s=ps(t,o.schema)),r&&n.selection.ranges.forEach(t=>{o.doc.nodesBetween(t.$from.pos,t.$to.pos,(t,o)=>{i&&i===t.type&&n.setNodeMarkup(o,void 0,Al(t.attrs,e)),s&&t.marks.length&&t.marks.forEach(r=>{s===r.type&&n.addMark(o,o+t.nodeSize,s.create(Al(r.attrs,e)))})})}),!0)},Ol=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),Nl=()=>({tr:t,dispatch:e})=>{if(e){const e=new Te(t.doc);t.setSelection(e)}return!0},Dl=()=>({state:t,dispatch:e})=>gi(t,e),Ll=()=>({state:t,dispatch:e})=>wi(t,e),Rl=()=>({state:t,dispatch:e})=>((t,e)=>{let n,{$from:o,to:r}=t.selection,i=o.sharedDepth(r);return 0!=i&&(n=o.before(i),e&&e(t.tr.setSelection(Ce.create(t.doc,n))),!0)})(t,e),jl=()=>({state:t,dispatch:e})=>Di(t,e),Il=()=>({state:t,dispatch:e})=>Ni(t,e),Pl=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:o={}}={})=>({editor:r,tr:i,dispatch:s,commands:l})=>{const{doc:a}=i;if("full"!==o.preserveWhitespace){const l=Ji(t,r.schema,o,{errorOnInvalidContent:null!=e?e:r.options.enableContentCheck});return s&&i.replaceWith(0,a.content.size,l).setMeta("preventUpdate",!n),!0}return s&&i.setMeta("preventUpdate",!n),l.insertContentAt({from:0,to:a.content.size},t,{parseOptions:o,errorOnInvalidContent:null!=e?e:r.options.enableContentCheck})},zl=(t,e={})=>({tr:n,state:o,dispatch:r})=>{const{selection:i}=n,{empty:s,ranges:l}=i,a=ps(t,o.schema);if(r)if(s){const t=us(o,a);n.addStoredMark(a.create({...t,...e}))}else l.forEach(t=>{const r=t.$from.pos,i=t.$to.pos;o.doc.nodesBetween(r,i,(t,o)=>{const s=Math.max(o,r),l=Math.min(o+t.nodeSize,i);t.marks.find(t=>t.type===a)?t.marks.forEach(t=>{a===t.type&&n.addMark(s,l,a.create({...t.attrs,...e}))}):n.addMark(s,l,a.create(e))})});return function(t,e,n){var o;const{selection:r}=e;let i=null;if(Ls(r)&&(i=r.$cursor),i){const e=null!=(o=t.storedMarks)?o:i.marks();return i.parent.type.allowsMarkType(n)&&(!!n.isInSet(e)||!e.some(t=>t.type.excludes(n)))}const{ranges:s}=r;return s.some(({$from:e,$to:o})=>{let r=0===e.depth&&t.doc.inlineContent&&t.doc.type.allowsMarkType(n);return t.doc.nodesBetween(e.pos,o.pos,(t,e,o)=>{if(r)return!1;if(t.isInline){const e=!o||o.type.allowsMarkType(n),i=!!n.isInSet(t.marks)||!t.marks.some(t=>t.type.excludes(n));r=e&&i}return!r}),r})}(o,n,a)},$l=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),Hl=(t,e={})=>({state:n,dispatch:o,chain:r})=>{const i=fs(t,n.schema);let s;return n.selection.$anchor.sameParent(n.selection.$head)&&(s=n.selection.$anchor.parent.attrs),i.isTextblock?r().command(({commands:t})=>!!Li(i,{...s,...e})(n)||t.clearNodes()).command(({state:t})=>Li(i,{...s,...e})(t,o)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},Bl=t=>({tr:e,dispatch:n})=>{if(n){const{doc:n}=e,o=Rs(t,0,n.content.size),r=Ce.create(n,o);e.setSelection(r)}return!0},Vl=t=>({tr:e,dispatch:n})=>{if(n){const{doc:n}=e,{from:o,to:r}="number"==typeof t?{from:t,to:t}:t,i=xe.atStart(n).from,s=xe.atEnd(n).to,l=Rs(o,i,s),a=Rs(r,i,s),c=xe.create(n,l,a);e.setSelection(c)}return!0},_l=t=>({state:e,dispatch:n})=>{const o=fs(t,e.schema);return(r=o,function(t,e){let{$from:n,$to:o}=t.selection,i=n.blockRange(o,t=>t.childCount>0&&t.firstChild.type==r);if(!i)return!1;let s=i.startIndex;if(0==s)return!1;let l=i.parent,a=l.child(s-1);if(a.type!=r)return!1;if(e){let n=a.lastChild&&a.lastChild.type==l.type,o=k.from(n?r.create():null),s=new A(k.from(r.create(null,k.from(l.type.create(null,o)))),n?3:1,0),c=i.start,d=i.end;e(t.tr.step(new _t(c-(n?3:1),d,c,d,s,1,!0)).scrollIntoView())}return!0})(e,n);var r};function Fl(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const o=n.filter(t=>null==e?void 0:e.includes(t.type.name));t.tr.ensureMarks(o)}}var Wl=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:o,editor:r})=>{const{selection:i,doc:s}=e,{$from:l,$to:a}=i,c=Ss(r.extensionManager.attributes,l.node().type.name,l.node().attrs);if(i instanceof Ce&&i.node.isBlock)return!(!l.parentOffset||!Xt(s,l.pos)||(o&&(t&&Fl(n,r.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),0));if(!l.parent.isBlock)return!1;const d=a.parentOffset===a.parent.content.size,h=0===l.depth?void 0:function(t){for(let e=0;e<t.edgeCount;e+=1){const{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}(l.node(-1).contentMatchAt(l.indexAfter(-1)));let p=d&&h?[{type:h,attrs:c}]:void 0,u=Xt(e.doc,e.mapping.map(l.pos),1,p);if(p||u||!Xt(e.doc,e.mapping.map(l.pos),1,h?[{type:h}]:void 0)||(u=!0,p=h?[{type:h,attrs:c}]:void 0),o){if(u&&(i instanceof xe&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,p),h&&!d&&!l.parentOffset&&l.parent.type!==h)){const t=e.mapping.map(l.before()),n=e.doc.resolve(t);l.node(-1).canReplaceWith(n.index(),n.index()+1,h)&&e.setNodeMarkup(e.mapping.map(l.before()),h)}t&&Fl(n,r.extensionManager.splittableMarks),e.scrollIntoView()}return u},ql=(t,e={})=>({tr:n,state:o,dispatch:r,editor:i})=>{var s;const l=fs(t,o.schema),{$from:a,$to:c}=o.selection,d=o.selection.node;if(d&&d.isBlock||a.depth<2||!a.sameParent(c))return!1;const h=a.node(-1);if(h.type!==l)return!1;const p=i.extensionManager.attributes;if(0===a.parent.content.size&&a.node(-1).childCount===a.indexAfter(-1)){if(2===a.depth||a.node(-3).type!==l||a.index(-2)!==a.node(-2).childCount-1)return!1;if(r){let t=k.empty;const o=a.index(-1)?1:a.index(-2)?2:3;for(let e=a.depth-o;e>=a.depth-3;e-=1)t=k.from(a.node(e).copy(t));const r=a.indexAfter(-1)<a.node(-2).childCount?1:a.indexAfter(-2)<a.node(-3).childCount?2:3,i={...Ss(p,a.node().type.name,a.node().attrs),...e},c=(null==(s=l.contentMatch.defaultType)?void 0:s.createAndFill(i))||void 0;t=t.append(k.from(l.createAndFill(null,c)||void 0));const d=a.before(a.depth-(o-1));n.replace(d,a.after(-r),new A(t,4-o,0));let h=-1;n.doc.nodesBetween(d,n.doc.content.size,(t,e)=>{if(h>-1)return!1;t.isTextblock&&0===t.content.size&&(h=e+1)}),h>-1&&n.setSelection(xe.near(n.doc.resolve(h))),n.scrollIntoView()}return!0}const u=c.pos===a.end()?h.contentMatchAt(0).defaultType:null,f={...Ss(p,h.type.name,h.attrs),...e},m={...Ss(p,a.node().type.name,a.node().attrs),...e};n.delete(a.pos,c.pos);const g=u?[{type:l,attrs:f},{type:u,attrs:m}]:[{type:l,attrs:f}];if(!Xt(n.doc,a.pos,2))return!1;if(r){const{selection:t,storedMarks:e}=o,{splittableMarks:s}=i.extensionManager,l=e||t.$to.parentOffset&&t.$from.marks();if(n.split(a.pos,2,g).scrollIntoView(),!l||!r)return!0;const c=l.filter(t=>s.includes(t.type.name));n.ensureMarks(c)}return!0},Kl=(t,e)=>{const n=Gi(t=>t.type===e)(t.selection);if(!n)return!0;const o=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(void 0===o)return!0;const r=t.doc.nodeAt(o);return n.node.type!==(null==r?void 0:r.type)||!Qt(t.doc,n.pos)||(t.join(n.pos),!0)},Jl=(t,e)=>{const n=Gi(t=>t.type===e)(t.selection);if(!n)return!0;const o=t.doc.resolve(n.start).after(n.depth);if(void 0===o)return!0;const r=t.doc.nodeAt(o);return n.node.type!==(null==r?void 0:r.type)||!Qt(t.doc,o)||(t.join(o),!0)},Ul=(t,e,n,o={})=>({editor:r,tr:i,state:s,dispatch:l,chain:a,commands:c,can:d})=>{const{extensions:h,splittableMarks:p}=r.extensionManager,u=fs(t,s.schema),f=fs(e,s.schema),{selection:m,storedMarks:g}=s,{$from:y,$to:b}=m,v=y.blockRange(b),w=g||m.$to.parentOffset&&m.$from.marks();if(!v)return!1;const k=Gi(t=>Os(t.type.name,h))(m);if(v.depth>=1&&k&&v.depth-k.depth<=1){if(k.node.type===u)return c.liftListItem(f);if(Os(k.node.type.name,h)&&u.validContent(k.node.content)&&l)return a().command(()=>(i.setNodeMarkup(k.pos,u),!0)).command(()=>Kl(i,u)).command(()=>Jl(i,u)).run()}return n&&w&&l?a().command(()=>{const t=d().wrapInList(u,o),e=w.filter(t=>p.includes(t.type.name));return i.ensureMarks(e),!!t||c.clearNodes()}).wrapInList(u,o).command(()=>Kl(i,u)).command(()=>Jl(i,u)).run():a().command(()=>!!d().wrapInList(u,o)||c.clearNodes()).wrapInList(u,o).command(()=>Kl(i,u)).command(()=>Jl(i,u)).run()},Gl=(t,e={},n={})=>({state:o,commands:r})=>{const{extendEmptyMarkRange:i=!1}=n,s=ps(t,o.schema);return Ts(o,s,e)?r.unsetMark(s,{extendEmptyMarkRange:i}):r.setMark(s,e)},Yl=(t,e,n={})=>({state:o,commands:r})=>{const i=fs(t,o.schema),s=fs(e,o.schema),l=As(o,i,n);let a;return o.selection.$anchor.sameParent(o.selection.$head)&&(a=o.selection.$anchor.parent.attrs),l?r.setNode(s,a):r.setNode(i,{...a,...n})},Xl=(t,e={})=>({state:n,commands:o})=>{const r=fs(t,n.schema);return As(n,r,e)?o.lift(r):o.wrapIn(r,e)},Ql=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let o=0;o<n.length;o+=1){const r=n[o];let i;if(r.spec.isInputRules&&(i=r.getState(t))){if(e){const e=t.tr,n=i.transform;for(let t=n.steps.length-1;t>=0;t-=1)e.step(n.steps[t].invert(n.docs[t]));if(i.text){const n=e.doc.resolve(i.from).marks();e.replaceWith(i.from,i.to,t.schema.text(i.text,n))}else e.delete(i.from,i.to)}return!0}}return!1},Zl=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:o,ranges:r}=n;return o||e&&r.forEach(e=>{t.removeMark(e.$from.pos,e.$to.pos)}),!0},ta=(t,e={})=>({tr:n,state:o,dispatch:r})=>{var i;const{extendEmptyMarkRange:s=!1}=e,{selection:l}=n,a=ps(t,o.schema),{$from:c,empty:d,ranges:h}=l;if(!r)return!0;if(d&&s){let{from:t,to:e}=l;const o=null==(i=c.marks().find(t=>t.type===a))?void 0:i.attrs,r=xs(c,a,o);r&&(t=r.from,e=r.to),n.removeMark(t,e,a)}else h.forEach(t=>{n.removeMark(t.$from.pos,t.$to.pos,a)});return n.removeStoredMark(a),!0},ea=(t,e={})=>({tr:n,state:o,dispatch:r})=>{let i=null,s=null;const l=ms("string"==typeof t?t:t.name,o.schema);return!!l&&("node"===l&&(i=fs(t,o.schema)),"mark"===l&&(s=ps(t,o.schema)),r&&n.selection.ranges.forEach(t=>{const r=t.$from.pos,l=t.$to.pos;let a,c,d,h;n.selection.empty?o.doc.nodesBetween(r,l,(t,e)=>{i&&i===t.type&&(d=Math.max(e,r),h=Math.min(e+t.nodeSize,l),a=e,c=t)}):o.doc.nodesBetween(r,l,(t,o)=>{o<r&&i&&i===t.type&&(d=Math.max(o,r),h=Math.min(o+t.nodeSize,l),a=o,c=t),o>=r&&o<=l&&(i&&i===t.type&&n.setNodeMarkup(o,void 0,{...t.attrs,...e}),s&&t.marks.length&&t.marks.forEach(i=>{if(s===i.type){const a=Math.max(o,r),c=Math.min(o+t.nodeSize,l);n.addMark(a,c,s.create({...i.attrs,...e}))}}))}),c&&(void 0!==a&&n.setNodeMarkup(a,void 0,{...c.attrs,...e}),s&&c.marks.length&&c.marks.forEach(t=>{s===t.type&&n.addMark(d,h,s.create({...t.attrs,...e}))}))}),!0)},na=(t,e={})=>({state:n,dispatch:o})=>function(t,e=null){return function(n,o){let{$from:r,$to:i}=n.selection,s=r.blockRange(i),l=s&&Jt(s,t,e);return!!l&&(o&&o(n.tr.wrap(s,l).scrollIntoView()),!0)}}(fs(t,n.schema),e)(n,o),oa=(t,e={})=>({state:n,dispatch:o})=>function(t,e=null){return function(n,o){let{$from:r,$to:i}=n.selection,s=r.blockRange(i);if(!s)return!1;let l=o?n.tr:null;return!!function(t,e,n,o=null){let r=!1,i=e,s=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&0==e.startIndex){if(0==e.$from.index(e.depth-1))return!1;let t=s.resolve(e.start-2);i=new F(t,t,e.depth),e.endIndex<e.parent.childCount&&(e=new F(e.$from,s.resolve(e.$to.end(e.depth)),e.depth)),r=!0}let l=Jt(i,n,o,e);return!!l&&(t&&function(t,e,n,o,r){let i=k.empty;for(let t=n.length-1;t>=0;t--)i=k.from(n[t].type.create(n[t].attrs,i));t.step(new _t(e.start-(o?2:0),e.end,e.start,e.end,new A(i,0,0),n.length,!0));let s=0;for(let t=0;t<n.length;t++)n[t].type==r&&(s=t+1);let l=n.length-s,a=e.start+n.length-(o?2:0),c=e.parent;for(let n=e.startIndex,o=e.endIndex,r=!0;n<o;n++,r=!1)!r&&Xt(t.doc,a,l)&&(t.split(a,l),a+=2*l),a+=c.child(n).nodeSize}(t,e,l,r,n),!0)}(l,s,t,e)&&(o&&o(l.scrollIntoView()),!0)}}(fs(t,n.schema),e)(n,o),ra=qs.create({name:"commands",addCommands:()=>({...Js})}),ia=qs.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,o,r;const i=()=>{var n,o,r,i;if(null!=(i=null==(r=null==(o=null==(n=this.editor.options.coreExtensionOptions)?void 0:n.delete)?void 0:o.filterTransaction)?void 0:r.call(o,t))?i:t.getMeta("y-sync$"))return;const s=Fi(t.before,[t,...e]);ys(s).forEach(e=>{s.mapping.mapResult(e.oldRange.from).deletedAfter&&s.mapping.mapResult(e.oldRange.to).deletedBefore&&s.before.nodesBetween(e.oldRange.from,e.oldRange.to,(n,o)=>{const r=o+n.nodeSize-2,i=e.oldRange.from<=o&&r<=e.oldRange.to;this.editor.emit("delete",{type:"node",node:n,from:o,to:r,newFrom:s.mapping.map(o),newTo:s.mapping.map(r),deletedRange:e.oldRange,newRange:e.newRange,partial:!i,editor:this.editor,transaction:t,combinedTransform:s})})});const l=s.mapping;s.steps.forEach((e,n)=>{var o,r;if(e instanceof $t){const i=l.slice(n).map(e.from,-1),a=l.slice(n).map(e.to),c=l.invert().map(i,-1),d=l.invert().map(a),h=null==(o=s.doc.nodeAt(i-1))?void 0:o.marks.some(t=>t.eq(e.mark)),p=null==(r=s.doc.nodeAt(a))?void 0:r.marks.some(t=>t.eq(e.mark));this.editor.emit("delete",{type:"mark",mark:e.mark,from:e.from,to:e.to,deletedRange:{from:c,to:d},newRange:{from:i,to:a},partial:Boolean(p||h),editor:this.editor,transaction:t,combinedTransform:s})}})};null==(r=null==(o=null==(n=this.editor.options.coreExtensionOptions)?void 0:n.delete)?void 0:o.async)||r?setTimeout(i,0):i()}}),sa=qs.create({name:"drop",addProseMirrorPlugins(){return[new ze({key:new Be("tiptapDrop"),props:{handleDrop:(t,e,n,o)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:o})}}})]}}),la=qs.create({name:"editable",addProseMirrorPlugins(){return[new ze({key:new Be("editable"),props:{editable:()=>this.editor.options.editable}})]}}),aa=new Be("focusEvents"),ca=qs.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new ze({key:aa,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const o=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(o),!1},blur:(e,n)=>{t.isFocused=!1;const o=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(o),!1}}}})]}}),da=qs.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:t})=>[()=>t.undoInputRule(),()=>t.command(({tr:e})=>{const{selection:n,doc:o}=e,{empty:r,$anchor:i}=n,{pos:s,parent:l}=i,a=i.parent.isTextblock&&s>0?e.doc.resolve(s-1):i,c=a.parent.type.spec.isolating,d=i.pos-i.parentOffset,h=c&&1===a.parent.childCount?d===i.pos:be.atStart(o).from===s;return!(!r||!l.type.isTextblock||l.textContent.length||!h||h&&"paragraph"===i.parent.type.name)&&t.clearNodes()}),()=>t.deleteSelection(),()=>t.joinBackward(),()=>t.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:t})=>[()=>t.deleteSelection(),()=>t.deleteCurrentNode(),()=>t.joinForward(),()=>t.selectNodeForward()]),n={Enter:()=>this.editor.commands.first(({commands:t})=>[()=>t.newlineInCode(),()=>t.createParagraphNear(),()=>t.liftEmptyBlock(),()=>t.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},o={...n},r={...n,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return al()||kl()?r:o},addProseMirrorPlugins(){return[new ze({key:new Be("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(t=>t.getMeta("composition")))return;const o=t.some(t=>t.docChanged)&&!e.doc.eq(n.doc),r=t.some(t=>t.getMeta("preventClearDocument"));if(!o||r)return;const{empty:i,from:s,to:l}=e.selection,a=be.atStart(e.doc).from,c=be.atEnd(e.doc).to;if(i||s!==a||l!==c)return;if(!Ns(n.doc))return;const d=n.tr,h=Bi({state:n,transaction:d}),{commands:p}=new Vi({editor:this.editor,state:h});return p.clearNodes(),d.steps.length?d:void 0}})]}}),ha=qs.create({name:"paste",addProseMirrorPlugins(){return[new ze({key:new Be("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),pa=qs.create({name:"tabindex",addProseMirrorPlugins(){return[new ze({key:new Be("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),ua=class t{constructor(t,e,n=!1,o=null){this.currentNode=null,this.actualDepth=null,this.isBlock=n,this.resolvedPos=t,this.editor=e,this.currentNode=o}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var t;return null!=(t=this.actualDepth)?t:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(t){let e=this.from,n=this.to;if(this.isBlock){if(0===this.content.size)return void console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);e=this.from+1,n=this.to-1}this.editor.commands.insertContentAt({from:e,to:n},t)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(0===this.depth)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new t(n,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new t(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new t(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,o)=>{const r=n.isBlock&&!n.isTextblock,i=n.isAtom&&!n.isText,s=this.pos+o+(i?0:1);if(s<0||s>this.resolvedPos.doc.nodeSize-2)return;const l=this.resolvedPos.doc.resolve(s);if(!r&&l.depth<=this.depth)return;const a=new t(l,this.editor,r,r?n:null);r&&(a.actualDepth=this.depth+1),e.push(new t(l,this.editor,r,r?n:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const t=this.children;return t[t.length-1]||null}closest(t,e={}){let n=null,o=this.parent;for(;o&&!n;){if(o.node.type.name===t)if(Object.keys(e).length>0){const t=o.node.attrs,n=Object.keys(e);for(let o=0;o<n.length;o+=1){const r=n[o];if(t[r]!==e[r])break}}else n=o;o=o.parent}return n}querySelector(t,e={}){return this.querySelectorAll(t,e,!0)[0]||null}querySelectorAll(t,e={},n=!1){let o=[];if(!this.children||0===this.children.length)return o;const r=Object.keys(e);return this.children.forEach(i=>{n&&o.length>0||(i.node.type.name===t&&r.every(t=>e[t]===i.node.attrs[t])&&o.push(i),n&&o.length>0||(o=o.concat(i.querySelectorAll(t,e,n))))}),o}setAttribute(t){const{tr:e}=this.editor.state;e.setNodeMarkup(this.from,void 0,{...this.node.attrs,...t}),this.editor.view.dispatch(e)}},fa=class extends _i{constructor(t={}){super(),this.css=null,this.editorView=null,this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:"undefined"!=typeof document?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:t})=>{throw t},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:t,slice:e,moved:n})=>this.options.onDrop(t,e,n)),this.on("paste",({event:t,slice:e})=>this.options.onPaste(t,e)),this.on("delete",this.options.onDelete);const e=this.createDoc(),n=js(e,this.options.autofocus);this.editorState=Ie.create({doc:e,schema:this.schema,selection:n||void 0}),this.options.element&&this.mount(this.options.element)}mount(t){if("undefined"==typeof document)throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(t),this.emit("mount",{editor:this}),window.setTimeout(()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){const t=this.editorView.dom;(null==t?void 0:t.editor)&&delete t.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css)try{"function"==typeof this.css.remove?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(t){console.warn("Failed to remove CSS element:",t)}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&"undefined"!=typeof document&&(this.css=function(t,e){const n=document.querySelector("style[data-tiptap-style]");if(null!==n)return n;const o=document.createElement("style");return e&&o.setAttribute("nonce",e),o.setAttribute("data-tiptap-style",""),o.innerHTML='.ProseMirror {\n position: relative;\n}\n\n.ProseMirror {\n word-wrap: break-word;\n white-space: pre-wrap;\n white-space: break-spaces;\n -webkit-font-variant-ligatures: none;\n font-variant-ligatures: none;\n font-feature-settings: "liga" 0; /* the above doesn\'t seem to work in Edge */\n}\n\n.ProseMirror [contenteditable="false"] {\n white-space: normal;\n}\n\n.ProseMirror [contenteditable="false"] [contenteditable="true"] {\n white-space: pre-wrap;\n}\n\n.ProseMirror pre {\n white-space: pre-wrap;\n}\n\nimg.ProseMirror-separator {\n display: inline !important;\n border: none !important;\n margin: 0 !important;\n width: 0 !important;\n height: 0 !important;\n}\n\n.ProseMirror-gapcursor {\n display: none;\n pointer-events: none;\n position: absolute;\n margin: 0;\n}\n\n.ProseMirror-gapcursor:after {\n content: "";\n display: block;\n position: absolute;\n top: -2px;\n width: 20px;\n border-top: 1px solid black;\n animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;\n}\n\n@keyframes ProseMirror-cursor-blink {\n to {\n visibility: hidden;\n }\n}\n\n.ProseMirror-hideselection *::selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection *::-moz-selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection * {\n caret-color: transparent;\n}\n\n.ProseMirror-focused .ProseMirror-gapcursor {\n display: block;\n}',document.getElementsByTagName("head")[0].appendChild(o),o}(0,this.options.injectNonce))}setOptions(t={}){this.options={...this.options,...t},this.editorView&&this.state&&!this.isDestroyed&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(t,e=!0){this.setOptions({editable:t}),e&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:t=>{this.editorState=t},dispatch:t=>{this.editorState=this.state.apply(t)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(t,e)=>{if("state"===e)return this.editorState;if(e in t)return Reflect.get(t,e);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${e}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(t,e){const n=Zi(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],o=this.state.reconfigure({plugins:n});return this.view.updateState(o),o}unregisterPlugin(t){if(this.isDestroyed)return;const e=this.state.plugins;let n=e;if([].concat(t).forEach(t=>{const e="string"==typeof t?`${t}$`:t.key;n=n.filter(t=>!t.key.startsWith(e))}),e.length===n.length)return;const o=this.state.reconfigure({plugins:n});return this.view.updateState(o),o}createExtensionManager(){var t,e;const n=[...this.options.enableCoreExtensions?[la,Ks.configure({blockSeparator:null==(e=null==(t=this.options.coreExtensionOptions)?void 0:t.clipboardTextSerializer)?void 0:e.blockSeparator}),ra,ca,da,pa,sa,ha,ia].filter(t=>"object"!=typeof this.options.enableCoreExtensions||!1!==this.options.enableCoreExtensions[t.name]):[],...this.options.extensions].filter(t=>["extension","node","mark"].includes(null==t?void 0:t.type));this.extensionManager=new Ws(n,this)}createCommandManager(){this.commandManager=new Vi({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=Ji(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error&&["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message)))throw e;this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{"collaboration"in this.storage&&"object"==typeof this.storage.collaboration&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(t=>"collaboration"!==t.name),this.createExtensionManager()}}),t=Ji(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){var e;this.editorView=new Ur(t,{...this.options.editorProps,attributes:{role:"textbox",...null==(e=this.options.editorProps)?void 0:e.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const n=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(n),this.prependClass(),this.injectCSS(),this.view.dom.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`tiptap ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction)return this.capturedTransaction?void t.steps.forEach(t=>{var e;return null==(e=this.capturedTransaction)?void 0:e.step(t)}):void(this.capturedTransaction=t);const{state:e,transactions:n}=this.state.applyTransaction(t),o=!this.state.selection.eq(e.selection),r=n.includes(t),i=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!r)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),o&&this.emit("selectionUpdate",{editor:this,transaction:t});const s=n.findLast(t=>t.getMeta("focus")||t.getMeta("blur")),l=null==s?void 0:s.getMeta("focus"),a=null==s?void 0:s.getMeta("blur");l&&this.emit("focus",{editor:this,event:l.event,transaction:s}),a&&this.emit("blur",{editor:this,event:a.event,transaction:s}),t.getMeta("preventUpdate")||!n.some(t=>t.docChanged)||i.doc.eq(e.doc)||this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return gs(this.state,t)}isActive(t,e){const n="string"==typeof t?t:null,o="string"==typeof t?e:t;return function(t,e,n={}){if(!e)return As(t,null,n)||Ts(t,null,n);const o=ms(e,t.schema);return"node"===o?As(t,e,n):"mark"===o&&Ts(t,e,n)}(this.state,n,o)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Qi(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e="\n\n",textSerializers:n={}}=t||{};return function(t,e){return ds(t,{from:0,to:t.content.size},e)}(this.state.doc,{blockSeparator:e,textSerializers:{...hs(this.schema),...n}})}get isEmpty(){return Ns(this.state.doc)}destroy(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}get isDestroyed(){var t,e;return null==(e=null==(t=this.editorView)?void 0:t.isDestroyed)||e}$node(t,e){var n;return(null==(n=this.$doc)?void 0:n.querySelector(t,e))||null}$nodes(t,e){var n;return(null==(n=this.$doc)?void 0:n.querySelectorAll(t,e))||null}$pos(t){const e=this.state.doc.resolve(t);return new ua(e,this)}get $doc(){return this.$pos(0)}};function ma(t){return new Is({find:t.find,handler:({state:e,range:n,match:o})=>{const r=ts(t.getAttributes,void 0,o);if(!1===r||null===r)return null;const{tr:i}=e,s=o[o.length-1],l=o[0];if(s){const o=l.search(/\S/),a=n.from+l.indexOf(s),c=a+s.length;if(Ms(n.from,n.to,e.doc).filter(e=>e.mark.type.excluded.find(n=>n===t.type&&n!==e.mark.type)).filter(t=>t.to>a).length)return null;c<n.to&&i.delete(c,n.to),a>n.from&&i.delete(n.from+o,a);const d=n.from+o+s.length;i.addMark(n.from+o,d,t.type.create(r||{})),i.removeStoredMark(t.type)}}})}function ga(t){return new Is({find:t.find,handler:({state:e,range:n,match:o})=>{const r=ts(t.getAttributes,void 0,o)||{},{tr:i}=e,s=n.from;let l=n.to;const a=t.type.create(r);if(o[1]){let t=s+o[0].lastIndexOf(o[1]);t>l?t=l:l=t+o[1].length;const e=o[0][o[0].length-1];i.insertText(e,s+o[0].length-1),i.replaceWith(t,l,a)}else if(o[0]){const e=t.type.isInline?s:s-1;i.insert(e,t.type.create(r)).delete(i.mapping.map(s),i.mapping.map(l))}i.scrollIntoView()}})}function ya(t){return new Is({find:t.find,handler:({state:e,range:n,match:o})=>{const r=e.doc.resolve(n.from),i=ts(t.getAttributes,void 0,o)||{};if(!r.node(-1).canReplaceWith(r.index(-1),r.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,i)}})}function ba(t){return new Is({find:t.find,handler:({state:e,range:n,match:o,chain:r})=>{const i=ts(t.getAttributes,void 0,o)||{},s=e.tr.delete(n.from,n.to),l=s.doc.resolve(n.from).blockRange(),a=l&&Jt(l,t.type,i);if(!a)return null;if(s.wrap(l,a),t.keepMarks&&t.editor){const{selection:n,storedMarks:o}=e,{splittableMarks:r}=t.editor.extensionManager,i=o||n.$to.parentOffset&&n.$from.marks();if(i){const t=i.filter(t=>r.includes(t.type.name));s.ensureMarks(t)}}if(t.keepAttributes){const e="bulletList"===t.type.name||"orderedList"===t.type.name?"listItem":"taskList";r().updateAttributes(e,i).run()}const c=s.doc.resolve(n.from-1).nodeBefore;c&&c.type===t.type&&Qt(s.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(o,c))&&s.join(n.from-1)}})}var va=class t extends Hs{constructor(){super(...arguments),this.type="node"}static create(e={}){const n="function"==typeof e?e():e;return new t(n)}configure(t){return super.configure(t)}extend(t){const e="function"==typeof t?t():t;return super.extend(e)}};function wa(t){return new Vs({find:t.find,handler:({state:e,range:n,match:o,pasteEvent:r})=>{const i=ts(t.getAttributes,void 0,o,r);if(!1===i||null===i)return null;const{tr:s}=e,l=o[o.length-1],a=o[0];let c=n.to;if(l){const o=a.search(/\S/),r=n.from+a.indexOf(l),d=r+l.length;if(Ms(n.from,n.to,e.doc).filter(e=>e.mark.type.excluded.find(n=>n===t.type&&n!==e.mark.type)).filter(t=>t.to>r).length)return null;d<n.to&&s.delete(d,n.to),r>n.from&&s.delete(n.from+o,r),c=n.from+o+l.length,s.addMark(n.from+o,c,t.type.create(i||{})),s.removeStoredMark(t.type)}}})}var ka=n(5095),xa=n(9242),Ma=(...t)=>e=>{t.forEach(t=>{"function"==typeof t?t(e):t&&(t.current=e)})},Ca=({contentComponent:t})=>{const e=(0,g.useSyncExternalStore)(t.subscribe,t.getSnapshot,t.getServerSnapshot);return(0,r.jsx)(r.Fragment,{children:Object.values(e)})},Sa=class extends i.Component{constructor(t){var e;super(t),this.editorContentRef=i.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:Boolean(null==(e=t.editor)?void 0:e.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){const t=this.props.editor;if(t&&!t.isDestroyed&&t.options.element){if(t.contentComponent)return;const e=this.editorContentRef.current;e.append(...t.options.element.childNodes),t.setOptions({element:e}),t.contentComponent=function(){const t=new Set;let e={};return{subscribe:e=>(t.add(e),()=>{t.delete(e)}),getSnapshot:()=>e,getServerSnapshot:()=>e,setRenderer(n,o){e={...e,[n]:m.createPortal(o.reactElement,o.element,n)},t.forEach(t=>t())},removeRenderer(n){const o={...e};delete o[n],e=o,t.forEach(t=>t())}}}(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=t.contentComponent.subscribe(()=>{this.setState(t=>t.hasContentComponentInitialized?t:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),t.createNodeViews(),this.initialized=!0}}componentWillUnmount(){var t;const e=this.props.editor;if(!e)return;if(this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null,!(null==(t=e.options.element)?void 0:t.firstChild))return;const n=document.createElement("div");n.append(...e.options.element.childNodes),e.setOptions({element:n})}render(){const{editor:t,innerRef:e,...n}=this.props;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{ref:Ma(e,this.editorContentRef),...n}),(null==t?void 0:t.contentComponent)&&(0,r.jsx)(Ca,{contentComponent:t.contentComponent})]})}},Ta=(0,i.forwardRef)((t,e)=>{const n=i.useMemo(()=>Math.floor(4294967295*Math.random()).toString(),[t.editor]);return i.createElement(Sa,{key:n,innerRef:e,...t})}),Aa=i.memo(Ta),Ea="undefined"!=typeof window?i.useLayoutEffect:i.useEffect,Oa=class{constructor(t){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=t,this.lastSnapshot={editor:t,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber||(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber}),this.lastSnapshot}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}watch(t){if(this.editor=t,this.editor){const t=()=>{this.transactionNumber+=1,this.subscribers.forEach(t=>t())},e=this.editor;return e.on("transaction",t),()=>{e.off("transaction",t)}}}},Na="undefined"==typeof window,Da=Na||Boolean("undefined"!=typeof window&&window.next),La=class t{constructor(t){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=t,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(t){this.editor=t,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(t=>t())}getInitialEditor(){return void 0===this.options.current.immediatelyRender?Na||Da?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const t={...this.options.current,onBeforeCreate:(...t)=>{var e,n;return null==(n=(e=this.options.current).onBeforeCreate)?void 0:n.call(e,...t)},onBlur:(...t)=>{var e,n;return null==(n=(e=this.options.current).onBlur)?void 0:n.call(e,...t)},onCreate:(...t)=>{var e,n;return null==(n=(e=this.options.current).onCreate)?void 0:n.call(e,...t)},onDestroy:(...t)=>{var e,n;return null==(n=(e=this.options.current).onDestroy)?void 0:n.call(e,...t)},onFocus:(...t)=>{var e,n;return null==(n=(e=this.options.current).onFocus)?void 0:n.call(e,...t)},onSelectionUpdate:(...t)=>{var e,n;return null==(n=(e=this.options.current).onSelectionUpdate)?void 0:n.call(e,...t)},onTransaction:(...t)=>{var e,n;return null==(n=(e=this.options.current).onTransaction)?void 0:n.call(e,...t)},onUpdate:(...t)=>{var e,n;return null==(n=(e=this.options.current).onUpdate)?void 0:n.call(e,...t)},onContentError:(...t)=>{var e,n;return null==(n=(e=this.options.current).onContentError)?void 0:n.call(e,...t)},onDrop:(...t)=>{var e,n;return null==(n=(e=this.options.current).onDrop)?void 0:n.call(e,...t)},onPaste:(...t)=>{var e,n;return null==(n=(e=this.options.current).onPaste)?void 0:n.call(e,...t)},onDelete:(...t)=>{var e,n;return null==(n=(e=this.options.current).onDelete)?void 0:n.call(e,...t)}};return new fa(t)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(t){return this.subscriptions.add(t),()=>{this.subscriptions.delete(t)}}static compareOptions(t,e){return Object.keys(t).every(n=>!!["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(n)||("extensions"===n&&t.extensions&&e.extensions?t.extensions.length===e.extensions.length&&t.extensions.every((t,n)=>{var o;return t===(null==(o=e.extensions)?void 0:o[n])}):t[n]===e[n]))}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&0===e.length?t.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(t){if(this.editor&&!this.editor.isDestroyed){if(null===this.previousDeps)return void(this.previousDeps=t);if(this.previousDeps.length===t.length&&this.previousDeps.every((e,n)=>e===t[n]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=t}scheduleDestroy(){const t=this.instanceId,e=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{this.isComponentMounted&&this.instanceId===t?e&&e.setOptions(this.options.current):e&&!e.isDestroyed&&(e.destroy(),this.instanceId===t&&this.setEditor(null))},1)}};(0,i.createContext)({editor:null}).Consumer;var Ra=(0,i.createContext)({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}});i.forwardRef((t,e)=>{const{onDragStart:n}=(0,i.useContext)(Ra),o=t.as||"div";return(0,r.jsx)(o,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})}),i.createContext({markViewContentRef:()=>{}});var ja=n(936),Ia={root:"m_dd3f7539",Typography:"m_f2016866",content:"m_c2204cc2",linkEditorDropdown:"m_8a991b4f",control:"m_c2207da6",controlIcon:"m_9cdfeb3f",controlsGroup:"m_2ab47ef2",linkEditor:"m_b67b711e",linkEditorInput:"m_296cf94c",linkEditorExternalControl:"m_cfef614",linkEditorSave:"m_3b28e7bb",toolbar:"m_4574a3c4",taskList:"m_8b44009a"};const Pa=(0,l.P9)((t,e)=>{const n=(0,a.Y)("RichTextEditorContent",null,t),{classNames:o,className:i,style:s,styles:l,vars:c,...h}=n,p=f();return p.withTypographyStyles?(0,r.jsx)(ja.o,{...p.getStyles("Typography",{className:i,style:s,styles:l,classNames:o}),unstyled:p.unstyled,ref:e,children:(0,r.jsx)(d.a,{component:Aa,editor:p.editor,...p.getStyles("content",{classNames:o,styles:l}),...h})}):(0,r.jsx)(d.a,{component:Aa,editor:p.editor,...p.getStyles("content",{classNames:o,styles:l,className:i,style:s}),...h})});function za(t){return(0,r.jsx)("svg",{...t,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})}function $a(t){return(0,r.jsxs)(za,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M7 5h6a3.5 3.5 0 0 1 0 7h-6z"}),(0,r.jsx)("path",{d:"M13 12h1a3.5 3.5 0 0 1 0 7h-7v-7"})]})}function Ha(t){return(0,r.jsxs)(za,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M11 5l6 0"}),(0,r.jsx)("path",{d:"M7 19l6 0"}),(0,r.jsx)("path",{d:"M14 5l-4 14"})]})}function Ba(t){return(0,r.jsxs)(za,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M7 5v5a5 5 0 0 0 10 0v-5"}),(0,r.jsx)("path",{d:"M5 19h14"})]})}function Va(t){return(0,r.jsxs)(za,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M5 12l14 0"}),(0,r.jsx)("path",{d:"M16 6.5a4 2 0 0 0 -4 -1.5h-1a3.5 3.5 0 0 0 0 7h2a3.5 3.5 0 0 1 0 7h-1.5a4 2 0 0 1 -4 -1.5"})]})}function _a(t){return(0,r.jsxs)(za,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M17 15l4 4m0 -4l-4 4"}),(0,r.jsx)("path",{d:"M7 6v-1h11v1"}),(0,r.jsx)("path",{d:"M7 19l4 0"}),(0,r.jsx)("path",{d:"M13 5l-4 14"})]})}function Fa(t){return(0,r.jsxs)(za,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M19 18v-8l-2 2"}),(0,r.jsx)("path",{d:"M4 6v12"}),(0,r.jsx)("path",{d:"M12 6v12"}),(0,r.jsx)("path",{d:"M11 18h2"}),(0,r.jsx)("path",{d:"M3 18h2"}),(0,r.jsx)("path",{d:"M4 12h8"}),(0,r.jsx)("path",{d:"M3 6h2"}),(0,r.jsx)("path",{d:"M11 6h2"})]})}function Wa(t){return(0,r.jsxs)(za,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M17 12a2 2 0 1 1 4 0c0 .591 -.417 1.318 -.816 1.858l-3.184 4.143l4 0"}),(0,r.jsx)("path",{d:"M4 6v12"}),(0,r.jsx)("path",{d:"M12 6v12"}),(0,r.jsx)("path",{d:"M11 18h2"}),(0,r.jsx)("path",{d:"M3 18h2"}),(0,r.jsx)("path",{d:"M4 12h8"}),(0,r.jsx)("path",{d:"M3 6h2"}),(0,r.jsx)("path",{d:"M11 6h2"})]})}function qa(t){return(0,r.jsxs)(za,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M19 14a2 2 0 1 0 -2 -2"}),(0,r.jsx)("path",{d:"M17 16a2 2 0 1 0 2 -2"}),(0,r.jsx)("path",{d:"M4 6v12"}),(0,r.jsx)("path",{d:"M12 6v12"}),(0,r.jsx)("path",{d:"M11 18h2"}),(0,r.jsx)("path",{d:"M3 18h2"}),(0,r.jsx)("path",{d:"M4 12h8"}),(0,r.jsx)("path",{d:"M3 6h2"}),(0,r.jsx)("path",{d:"M11 6h2"})]})}function Ka(t){return(0,r.jsxs)(za,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M20 18v-8l-4 6h5"}),(0,r.jsx)("path",{d:"M4 6v12"}),(0,r.jsx)("path",{d:"M12 6v12"}),(0,r.jsx)("path",{d:"M11 18h2"}),(0,r.jsx)("path",{d:"M3 18h2"}),(0,r.jsx)("path",{d:"M4 12h8"}),(0,r.jsx)("path",{d:"M3 6h2"}),(0,r.jsx)("path",{d:"M11 6h2"})]})}function Ja(t){return(0,r.jsxs)(za,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M17 18h2a2 2 0 1 0 0 -4h-2v-4h4"}),(0,r.jsx)("path",{d:"M4 6v12"}),(0,r.jsx)("path",{d:"M12 6v12"}),(0,r.jsx)("path",{d:"M11 18h2"}),(0,r.jsx)("path",{d:"M3 18h2"}),(0,r.jsx)("path",{d:"M4 12h8"}),(0,r.jsx)("path",{d:"M3 6h2"}),(0,r.jsx)("path",{d:"M11 6h2"})]})}function Ua(t){return(0,r.jsxs)(za,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M19 14a2 2 0 1 0 0 4a2 2 0 0 0 0 -4z"}),(0,r.jsx)("path",{d:"M21 12a2 2 0 1 0 -4 0v4"}),(0,r.jsx)("path",{d:"M4 6v12"}),(0,r.jsx)("path",{d:"M12 6v12"}),(0,r.jsx)("path",{d:"M11 18h2"}),(0,r.jsx)("path",{d:"M3 18h2"}),(0,r.jsx)("path",{d:"M4 12h8"}),(0,r.jsx)("path",{d:"M3 6h2"}),(0,r.jsx)("path",{d:"M11 6h2"})]})}function Ga(t){return(0,r.jsxs)(za,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M9 6l11 0"}),(0,r.jsx)("path",{d:"M9 12l11 0"}),(0,r.jsx)("path",{d:"M9 18l11 0"}),(0,r.jsx)("path",{d:"M5 6l0 .01"}),(0,r.jsx)("path",{d:"M5 12l0 .01"}),(0,r.jsx)("path",{d:"M5 18l0 .01"})]})}function Ya(t){return(0,r.jsxs)(za,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M11 6h9"}),(0,r.jsx)("path",{d:"M11 12h9"}),(0,r.jsx)("path",{d:"M12 18h8"}),(0,r.jsx)("path",{d:"M4 16a2 2 0 1 1 4 0c0 .591 -.5 1 -1 1.5l-3 2.5h4"}),(0,r.jsx)("path",{d:"M6 10v-6l-2 2"})]})}function Xa(t){return(0,r.jsxs)(za,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M17 22v-2"}),(0,r.jsx)("path",{d:"M9 15l6 -6"}),(0,r.jsx)("path",{d:"M11 6l.463 -.536a5 5 0 0 1 7.071 7.072l-.534 .464"}),(0,r.jsx)("path",{d:"M13 18l-.397 .534a5.068 5.068 0 0 1 -7.127 0a4.972 4.972 0 0 1 0 -7.071l.524 -.463"}),(0,r.jsx)("path",{d:"M20 17h2"}),(0,r.jsx)("path",{d:"M2 7h2"}),(0,r.jsx)("path",{d:"M7 2v2"})]})}function Qa(t){return(0,r.jsxs)(za,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M6 15h15"}),(0,r.jsx)("path",{d:"M21 19h-15"}),(0,r.jsx)("path",{d:"M15 11h6"}),(0,r.jsx)("path",{d:"M21 7h-6"}),(0,r.jsx)("path",{d:"M9 9h1a1 1 0 1 1 -1 1v-2.5a2 2 0 0 1 2 -2"}),(0,r.jsx)("path",{d:"M3 9h1a1 1 0 1 1 -1 1v-2.5a2 2 0 0 1 2 -2"})]})}function Za(t){return(0,r.jsxs)(za,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M4 6l16 0"}),(0,r.jsx)("path",{d:"M4 12l10 0"}),(0,r.jsx)("path",{d:"M4 18l14 0"})]})}function tc(t){return(0,r.jsxs)(za,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M4 6l16 0"}),(0,r.jsx)("path",{d:"M10 12l10 0"}),(0,r.jsx)("path",{d:"M6 18l14 0"})]})}function ec(t){return(0,r.jsxs)(za,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M4 6l16 0"}),(0,r.jsx)("path",{d:"M8 12l8 0"}),(0,r.jsx)("path",{d:"M6 18l12 0"})]})}function nc(t){return(0,r.jsxs)(za,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M4 6l16 0"}),(0,r.jsx)("path",{d:"M4 12l16 0"}),(0,r.jsx)("path",{d:"M4 18l12 0"})]})}function oc(t){return(0,r.jsxs)(za,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M5 7l8 10m-8 0l8 -10"}),(0,r.jsx)("path",{d:"M21 20h-4l3.5 -4a1.73 1.73 0 0 0 -3.5 -2"})]})}function rc(t){return(0,r.jsxs)(za,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M5 7l8 10m-8 0l8 -10"}),(0,r.jsx)("path",{d:"M21 11h-4l3.5 -4a1.73 1.73 0 0 0 -3.5 -2"})]})}function ic(t){return(0,r.jsxs)(za,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M7 8l-4 4l4 4"}),(0,r.jsx)("path",{d:"M17 8l4 4l-4 4"}),(0,r.jsx)("path",{d:"M14 4l-4 16"})]})}function sc(t){return(0,r.jsxs)(za,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M3 19h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4"}),(0,r.jsx)("path",{d:"M12.5 5.5l4 4"}),(0,r.jsx)("path",{d:"M4.5 13.5l4 4"}),(0,r.jsx)("path",{d:"M21 15v4h-8l4 -4z"})]})}function lc(t){return(0,r.jsxs)(za,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M5 12h2"}),(0,r.jsx)("path",{d:"M17 12h2"}),(0,r.jsx)("path",{d:"M11 12h2"})]})}function ac(t){return(0,r.jsxs)(za,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M20.042 16.045a9 9 0 0 0 -12.087 -12.087m-2.318 1.677a9 9 0 1 0 12.725 12.73"}),(0,r.jsx)("path",{d:"M3 3l18 18"})]})}function cc(t){return(0,r.jsxs)(za,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M11 7l6 6"}),(0,r.jsx)("path",{d:"M4 16l11.7 -11.7a1 1 0 0 1 1.4 0l2.6 2.6a1 1 0 0 1 0 1.4l-11.7 11.7h-4v-4z"})]})}function dc(t){return(0,r.jsxs)(za,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M18 6l-12 12"}),(0,r.jsx)("path",{d:"M6 6l12 12"})]})}function hc(t){return(0,r.jsxs)(za,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M12 21a9 9 0 0 1 0 -18c4.97 0 9 3.582 9 8c0 1.06 -.474 2.078 -1.318 2.828c-.844 .75 -1.989 1.172 -3.182 1.172h-2.5a2 2 0 0 0 -1 3.75a1.3 1.3 0 0 1 -1 2.25"}),(0,r.jsx)("path",{d:"M8.5 10.5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"}),(0,r.jsx)("path",{d:"M12.5 7.5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"}),(0,r.jsx)("path",{d:"M16.5 10.5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"})]})}function pc(t){return(0,r.jsxs)(za,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M5 12l5 5l10 -10"})]})}function uc(t){return(0,r.jsxs)(za,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M9 15l6 -6"}),(0,r.jsx)("path",{d:"M11 6l.463 -.536a5 5 0 0 1 7.071 7.072l-.534 .464"}),(0,r.jsx)("path",{d:"M13 18l-.397 .534a5.068 5.068 0 0 1 -7.127 0a4.972 4.972 0 0 1 0 -7.071l.524 -.463"})]})}function fc(t){return(0,r.jsxs)(za,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M12 6h-6a2 2 0 0 0 -2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-6"}),(0,r.jsx)("path",{d:"M11 13l9 -9"}),(0,r.jsx)("path",{d:"M15 4h5v5"})]})}function mc(t){return(0,r.jsxs)(za,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M9 14l-4 -4l4 -4"}),(0,r.jsx)("path",{d:"M5 10h11a4 4 0 1 1 0 8h-1"})]})}function gc(t){return(0,r.jsxs)(za,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M15 14l4 -4l-4 -4"}),(0,r.jsx)("path",{d:"M19 10h-11a4 4 0 1 0 0 8h1"})]})}function yc(t){return(0,r.jsxs)(za,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M3.5 5.5l1.5 1.5l2.5 -2.5"}),(0,r.jsx)("path",{d:"M3.5 11.5l1.5 1.5l2.5 -2.5"}),(0,r.jsx)("path",{d:"M3.5 17.5l1.5 1.5l2.5 -2.5"}),(0,r.jsx)("path",{d:"M11 6l9 0"}),(0,r.jsx)("path",{d:"M11 12l9 0"}),(0,r.jsx)("path",{d:"M11 18l9 0"})]})}function bc(t){return(0,r.jsxs)(za,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M20 6l-11 0"}),(0,r.jsx)("path",{d:"M20 12l-7 0"}),(0,r.jsx)("path",{d:"M20 18l-11 0"}),(0,r.jsx)("path",{d:"M4 8l4 4l-4 4"})]})}function vc(t){return(0,r.jsxs)(za,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M20 6l-7 0"}),(0,r.jsx)("path",{d:"M20 12l-9 0"}),(0,r.jsx)("path",{d:"M20 18l-7 0"}),(0,r.jsx)("path",{d:"M8 8l-4 4l4 4"})]})}function wc(t){return(0,r.jsxs)(za,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M19 3v16a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V7.914\n a1 1 0 0 1 .293-.707l3.914-3.914A1 1 0 0 1 9.914 3H18\n a1 1 0 0 1 1 1Z"}),(0,r.jsx)("path",{d:"M10 11l-2 2 2 2"}),(0,r.jsx)("path",{d:"M14 11l2 2-2 2"})]})}Pa.classes=Ia,Pa.displayName="@mantine/tiptap/RichTextEditorContent";var kc=n(6076);const xc={interactive:!0},Mc=(0,l.P9)((t,e)=>{const n=(0,a.Y)("RichTextEditorControl",xc,t),{classNames:o,className:i,style:s,styles:l,vars:c,interactive:d,active:h,onMouseDown:p,disabled:u,...m}=n,g=f();return(0,r.jsx)(kc.N,{...m,...g.getStyles("control",{className:i,style:s,classNames:o,styles:l}),disabled:u,"data-rich-text-editor-control":!0,tabIndex:d?0:-1,"data-interactive":d||void 0,"data-disabled":u||void 0,"data-active":h||void 0,"aria-pressed":h&&d||void 0,"aria-hidden":!d||void 0,ref:e,unstyled:g.unstyled,variant:g.variant||"default",onMouseDown:t=>{t.preventDefault(),p?.(t)}})});Mc.classes=Ia,Mc.displayName="@mantine/tiptap/RichTextEditorControl";const Cc=(0,i.forwardRef)(({className:t,icon:e,...n},o)=>{const i=f();return(0,r.jsx)(Mc,{ref:o,...n,children:(0,r.jsx)(e,{...i.getStyles("controlIcon")})})});function Sc({label:t,isActive:e,operation:n,icon:o,isDisabled:s}){const l=(0,i.forwardRef)((i,l)=>{const{editor:a,labels:c}=f(),d=c[t];return(0,r.jsx)(Cc,{"aria-label":d,title:d,active:!!e?.name&&a?.isActive(e.name,e.attributes),ref:l,onClick:()=>a?.chain().focus()[n.name](n.attributes).run(),icon:i.icon||o,disabled:s?.(a)||!1,...i})});return l.displayName=`@mantine/tiptap/${t}`,l}Cc.displayName="@mantine/tiptap/RichTextEditorControlBase";const Tc=Sc({label:"boldControlLabel",icon:t=>(0,r.jsx)($a,{...t}),isActive:{name:"bold"},operation:{name:"toggleBold"}}),Ac=Sc({label:"italicControlLabel",icon:t=>(0,r.jsx)(Ha,{...t}),isActive:{name:"italic"},operation:{name:"toggleItalic"}}),Ec=Sc({label:"underlineControlLabel",icon:t=>(0,r.jsx)(Ba,{...t}),isActive:{name:"underline"},operation:{name:"toggleUnderline"}}),Oc=Sc({label:"strikeControlLabel",icon:t=>(0,r.jsx)(Va,{...t}),isActive:{name:"strike"},operation:{name:"toggleStrike"}}),Nc=Sc({label:"clearFormattingControlLabel",icon:t=>(0,r.jsx)(_a,{...t}),operation:{name:"unsetAllMarks"}}),Dc=Sc({label:"unlinkControlLabel",icon:t=>(0,r.jsx)(Xa,{...t}),operation:{name:"unsetLink"}}),Lc=Sc({label:"bulletListControlLabel",icon:t=>(0,r.jsx)(Ga,{...t}),isActive:{name:"bulletList"},operation:{name:"toggleBulletList"}}),Rc=Sc({label:"orderedListControlLabel",icon:t=>(0,r.jsx)(Ya,{...t}),isActive:{name:"orderedList"},operation:{name:"toggleOrderedList"}}),jc=Sc({label:"h1ControlLabel",icon:t=>(0,r.jsx)(Fa,{...t}),isActive:{name:"heading",attributes:{level:1}},operation:{name:"toggleHeading",attributes:{level:1}}}),Ic=Sc({label:"h2ControlLabel",icon:t=>(0,r.jsx)(Wa,{...t}),isActive:{name:"heading",attributes:{level:2}},operation:{name:"toggleHeading",attributes:{level:2}}}),Pc=Sc({label:"h3ControlLabel",icon:t=>(0,r.jsx)(qa,{...t}),isActive:{name:"heading",attributes:{level:3}},operation:{name:"toggleHeading",attributes:{level:3}}}),zc=Sc({label:"h4ControlLabel",icon:t=>(0,r.jsx)(Ka,{...t}),isActive:{name:"heading",attributes:{level:4}},operation:{name:"toggleHeading",attributes:{level:4}}}),$c=Sc({label:"h5ControlLabel",icon:t=>(0,r.jsx)(Ja,{...t}),isActive:{name:"heading",attributes:{level:5}},operation:{name:"toggleHeading",attributes:{level:5}}}),Hc=Sc({label:"h6ControlLabel",icon:t=>(0,r.jsx)(Ua,{...t}),isActive:{name:"heading",attributes:{level:6}},operation:{name:"toggleHeading",attributes:{level:6}}}),Bc=Sc({label:"blockquoteControlLabel",icon:t=>(0,r.jsx)(Qa,{...t}),isActive:{name:"blockquote"},operation:{name:"toggleBlockquote"}}),Vc=Sc({label:"alignLeftControlLabel",icon:t=>(0,r.jsx)(Za,{...t}),operation:{name:"setTextAlign",attributes:"left"}}),_c=Sc({label:"alignRightControlLabel",icon:t=>(0,r.jsx)(tc,{...t}),operation:{name:"setTextAlign",attributes:"right"}}),Fc=Sc({label:"alignCenterControlLabel",icon:t=>(0,r.jsx)(ec,{...t}),operation:{name:"setTextAlign",attributes:"center"}}),Wc=Sc({label:"alignJustifyControlLabel",icon:t=>(0,r.jsx)(nc,{...t}),operation:{name:"setTextAlign",attributes:"justify"}}),qc=Sc({label:"subscriptControlLabel",icon:t=>(0,r.jsx)(oc,{...t}),isActive:{name:"subscript"},operation:{name:"toggleSubscript"}}),Kc=Sc({label:"superscriptControlLabel",icon:t=>(0,r.jsx)(rc,{...t}),isActive:{name:"superscript"},operation:{name:"toggleSuperscript"}}),Jc=Sc({label:"codeControlLabel",icon:t=>(0,r.jsx)(ic,{...t}),isActive:{name:"code"},operation:{name:"toggleCode"}}),Uc=Sc({label:"codeBlockControlLabel",icon:t=>(0,r.jsx)(ic,{...t}),isActive:{name:"codeBlock"},operation:{name:"toggleCodeBlock"}}),Gc=Sc({label:"highlightControlLabel",icon:t=>(0,r.jsx)(sc,{...t}),isActive:{name:"highlight"},operation:{name:"toggleHighlight"}}),Yc=Sc({label:"hrControlLabel",icon:t=>(0,r.jsx)(lc,{...t}),operation:{name:"setHorizontalRule"}}),Xc=Sc({label:"unsetColorControlLabel",icon:t=>(0,r.jsx)(ac,{...t}),operation:{name:"unsetColor"}}),Qc=Sc({label:"undoControlLabel",icon:t=>(0,r.jsx)(mc,{...t}),isDisabled:t=>!t?.can().undo(),operation:{name:"undo"}}),Zc=Sc({label:"redoControlLabel",icon:t=>(0,r.jsx)(gc,{...t}),isDisabled:t=>!t?.can().redo(),operation:{name:"redo"}}),td=Sc({label:"tasksControlLabel",icon:t=>(0,r.jsx)(yc,{...t}),isActive:{name:"taskList"},operation:{name:"toggleTaskList"}}),ed=Sc({label:"tasksSinkLabel",icon:t=>(0,r.jsx)(bc,{...t}),operation:{name:"sinkListItem",attributes:"taskItem"},isDisabled:t=>!t?.can().sinkListItem("taskItem")}),nd=Sc({label:"tasksLiftLabel",icon:t=>(0,r.jsx)(vc,{...t}),operation:{name:"liftListItem",attributes:"taskItem"},isDisabled:t=>!t?.can().liftListItem("taskItem")});var od=n(9274),rd=n(5172),id=n(7193),sd=n(2335),ld=n(8149),ad=n(5055);function cd(t){return e=>{if(e)if("function"==typeof e)t(e);else if("object"==typeof e&&"nativeEvent"in e){const{currentTarget:n}=e;"checkbox"===n.type?t(n.checked):t(n.value)}else t(e);else t(e)}}var dd=n(3489),hd=n(977);const pd=t=>(0,r.jsx)(uc,{...t}),ud=(0,l.P9)((t,e)=>{const n=(0,a.Y)("RichTextEditorLinkControl",null,t),{classNames:o,className:s,style:l,styles:c,vars:d,icon:h,popoverProps:p,disableTooltips:u,initialExternal:m,...g}=n,y=f(),b={classNames:o,styles:c},[v,w]=function(){const[t,e]=(0,i.useState)("");return[t,cd(e)]}(),[k,x]=(0,i.useState)(m),[M,{open:C,close:S}]=(0,dd.j)(!1),T=()=>{C();const t=y.editor?.getAttributes("link");w(t?.href||""),x(t?.href?"_blank"===t?.target:m)},A=()=>{S(),w(""),x(m)},E=()=>{A(),""===v?y.editor?.chain().focus().extendMarkRange("link").unsetLink().run():y.editor?.chain().focus().extendMarkRange("link").setLink({href:v,target:k?"_blank":null}).run()};(0,hd.M)("edit-link",T,!1);const{resolvedClassNames:O,resolvedStyles:N}=(0,od.Y)({classNames:o,styles:c,props:n});return(0,r.jsxs)(rd.A,{trapFocus:!0,shadow:"md",withinPortal:!0,opened:M,onChange:t=>!t&&A(),offset:-44,zIndex:1e4,...p,children:[(0,r.jsx)(rd.A.Target,{children:(0,r.jsx)(Cc,{icon:h||pd,...g,"aria-label":y.labels.linkControlLabel,title:y.labels.linkControlLabel,onClick:T,active:y.editor?.isActive("link"),ref:e,classNames:O,styles:N,className:s,style:l,variant:y.variant})}),(0,r.jsx)(rd.A.Dropdown,{...y.getStyles("linkEditorDropdown",b),children:(0,r.jsxs)("div",{...y.getStyles("linkEditor",b),children:[(0,r.jsx)(id.k,{placeholder:y.labels.linkEditorInputPlaceholder,"aria-label":y.labels.linkEditorInputLabel,type:"url",value:v,onChange:w,classNames:{input:y.getStyles("linkEditorInput",b).className},onKeyDown:t=>{"Enter"===t.key&&(t.preventDefault(),E())},rightSection:(0,r.jsx)(sd.m,{label:k?y.labels.linkEditorExternalLink:y.labels.linkEditorInternalLink,events:{hover:!0,focus:!0,touch:!0},withinPortal:!0,withArrow:!0,disabled:u,zIndex:1e4,children:(0,r.jsx)(kc.N,{onClick:()=>x(t=>!t),"data-active":k||void 0,...y.getStyles("linkEditorExternalControl",b),children:(0,r.jsx)(fc,{style:{width:(0,ld.D)(14),height:(0,ld.D)(14)}})})})}),(0,r.jsx)(ad.$,{variant:"default",onClick:E,...y.getStyles("linkEditorSave",b),children:y.labels.linkEditorSave})]})})]})});ud.classes=Ia,ud.displayName="@mantine/tiptap/RichTextEditorLinkControl";var fd=n(9731),md=n(9277),gd=n(2865),yd=n(4999),bd=n(8324);const vd=(0,i.forwardRef)((t,e)=>{const{popoverProps:n,colors:o,colorPickerProps:s,...l}=(0,a.Y)("RichTextEditorColorPickerControl",null,t),{editor:c,labels:d,getStyles:h,variant:p}=f(),[u,{toggle:m,close:g}]=(0,dd.j)(!1),[y,b]=(0,i.useState)("palette"),v=c?.getAttributes("textStyle").color||"var(--mantine-color-text)",w=(t,e=!0)=>{(c?.chain()).focus().setColor(t).run(),e&&g()},k=o.map((t,e)=>(0,r.jsx)(fd.q,{component:"button",color:t,onClick:()=>w(t),size:26,radius:"xs",style:{cursor:"pointer"},title:d.colorPickerColorLabel(t),"aria-label":d.colorPickerColorLabel(t)},e));return(0,r.jsxs)(rd.A,{opened:u,withinPortal:!0,trapFocus:!0,onChange:t=>!t&&g(),...n,children:[(0,r.jsx)(rd.A.Target,{children:(0,r.jsx)(Mc,{...l,variant:p,"aria-label":d.colorPickerControlLabel,title:d.colorPickerControlLabel,ref:e,onClick:m,children:(0,r.jsx)(fd.q,{color:v,size:14})})}),(0,r.jsxs)(rd.A.Dropdown,{...h("linkEditorDropdown"),children:["palette"===y&&(0,r.jsx)(md.r,{cols:7,spacing:2,children:k}),"colorPicker"===y&&(0,r.jsx)(gd.s,{defaultValue:v,onChange:t=>w(t,!1),...s}),(0,r.jsx)(sd.m.Group,{closeDelay:200,children:(0,r.jsxs)(yd.Y,{justify:"flex-end",gap:"xs",mt:"sm",children:["palette"===y&&(0,r.jsx)(bd.M,{variant:"default",onClick:g,title:d.colorPickerCancel,"aria-label":d.colorPickerCancel,children:(0,r.jsx)(dc,{style:{width:(0,ld.D)(16),height:(0,ld.D)(16)}})}),(0,r.jsx)(bd.M,{variant:"default",onClick:()=>{(c?.chain()).focus().unsetColor().run(),g()},title:d.colorPickerClear,"aria-label":d.colorPickerClear,children:(0,r.jsx)(ac,{style:{width:(0,ld.D)(16),height:(0,ld.D)(16)}})}),"palette"===y?(0,r.jsx)(bd.M,{variant:"default",onClick:()=>b("colorPicker"),title:d.colorPickerColorPicker,"aria-label":d.colorPickerColorPicker,children:(0,r.jsx)(cc,{style:{width:(0,ld.D)(16),height:(0,ld.D)(16)}})}):(0,r.jsx)(bd.M,{variant:"default",onClick:()=>b("palette"),"aria-label":d.colorPickerPalette,title:d.colorPickerPalette,children:(0,r.jsx)(hc,{style:{width:(0,ld.D)(16),height:(0,ld.D)(16)}})}),"colorPicker"===y&&(0,r.jsx)(bd.M,{variant:"default",onClick:g,title:d.colorPickerSave,"aria-label":d.colorPickerSave,children:(0,r.jsx)(pc,{style:{width:(0,ld.D)(16),height:(0,ld.D)(16)}})})]})})]})]})});vd.displayName="@mantine/tiptap/ColorPickerControl";const wd=(0,i.forwardRef)((t,e)=>{const{color:n,...o}=(0,a.Y)("RichTextEditorColorControl",null,t),{editor:i,labels:s,variant:l}=f(),c=i?.getAttributes("textStyle").color||null,d=s.colorControlLabel(n);return(0,r.jsx)(Mc,{...o,variant:l,active:c===n,"aria-label":d,title:d,onClick:()=>(i?.chain()).focus().setColor(n).run(),ref:e,children:(0,r.jsx)(fd.q,{color:n,size:14})})});wd.displayName="@mantine/tiptap/RichTextEditorColorControl";const kd={},xd=(0,i.forwardRef)((t,e)=>{const{...n}=(0,a.Y)("RichTextEditorSourceCodeControl",kd,t),{editor:o,labels:s,variant:l,onSourceCodeTextSwitch:c}=f(),[d,h]=(0,i.useState)(!1);return(0,r.jsx)(Mc,{...n,variant:l,active:d,"aria-label":s.sourceCodeControlLabel,title:s.sourceCodeControlLabel,onClick:()=>(()=>{d?o?.commands.setContent(o.getText(),{emitUpdate:!0}):o?.commands.setContent(`<textarea>${o.getHTML()}</textarea>`);const t=!d;h(t),c?.(t)})(),ref:e,children:(0,r.jsx)(wc,{style:{width:(0,ld.D)(16),height:(0,ld.D)(16)}})})});xd.displayName="@mantine/tiptap/RichTextEditorSourceCodeControl";const Md=(0,l.P9)((t,e)=>{const n=(0,a.Y)("RichTextEditorControlsGroup",null,t),{classNames:o,className:i,style:s,styles:l,vars:c,variant:h,...p}=n,u=f();return(0,r.jsx)(d.a,{ref:e,variant:h||u.variant,...u.getStyles("controlsGroup",{className:i,style:s,styles:l,classNames:o}),...p})});Md.classes=Ia,Md.displayName="@mantine/tiptap/RichTextEditorControlsGroup";const Cd=(0,l.P9)((t,e)=>{const n=(0,a.Y)("RichTextEditorToolbar",null,t),{classNames:o,className:i,style:s,styles:l,vars:c,sticky:h,stickyOffset:p,mod:u,variant:m,...g}=n,y=f();return(0,r.jsx)(d.a,{ref:e,mod:[{sticky:h},u],variant:m||y.variant,...y.getStyles("toolbar",{className:i,style:s,styles:l,classNames:o}),...g,__vars:{"--rte-sticky-offset":(0,ld.D)(p)}})});Cd.classes=Ia,Cd.displayName="@mantine/tiptap/RichTextEditorToolbar";const Sd={withCodeHighlightStyles:!0,withTypographyStyles:!0,variant:"default"},Td=(0,l.P9)((t,e)=>{const n=(0,a.Y)("RichTextEditor",Sd,t),{classNames:o,className:s,style:l,styles:p,unstyled:f,vars:m,editor:g,withCodeHighlightStyles:y,withTypographyStyles:b,onSourceCodeTextSwitch:v,labels:w,children:k,variant:x,attributes:M,...C}=n,S=(0,c.I)({name:"RichTextEditor",classes:Ia,props:n,className:s,style:l,classNames:o,styles:p,unstyled:f,attributes:M,vars:m}),T=(0,i.useMemo)(()=>({...h,...w}),[w]);return(0,r.jsx)(u,{value:{editor:g,getStyles:S,labels:T,withCodeHighlightStyles:y,withTypographyStyles:b,onSourceCodeTextSwitch:v,unstyled:f,variant:x},children:(0,r.jsx)(d.a,{...S("root"),...C,ref:e,children:k})})});Td.classes=Ia,Td.displayName="@mantine/tiptap/RichTextEditor",Td.Content=Pa,Td.Control=Mc,Td.Toolbar=Cd,Td.ControlsGroup=Md,Td.Bold=Tc,Td.Italic=Ac,Td.Strikethrough=Oc,Td.Underline=Ec,Td.ClearFormatting=Nc,Td.H1=jc,Td.H2=Ic,Td.H3=Pc,Td.H4=zc,Td.H5=$c,Td.H6=Hc,Td.BulletList=Lc,Td.OrderedList=Rc,Td.Link=ud,Td.Unlink=Dc,Td.Blockquote=Bc,Td.AlignLeft=Vc,Td.AlignRight=_c,Td.AlignCenter=Fc,Td.AlignJustify=Wc,Td.Superscript=Kc,Td.Subscript=qc,Td.Code=Jc,Td.CodeBlock=Uc,Td.ColorPicker=vd,Td.Color=wd,Td.Highlight=Gc,Td.Hr=Yc,Td.UnsetColor=Xc,Td.Undo=Qc,Td.Redo=Zc,Td.TaskList=td,Td.TaskListSink=ed,Td.TaskListLift=nd,Td.SourceCode=xd;var Ad=n(5072),Ed=n.n(Ad),Od=n(7825),Nd=n.n(Od),Dd=n(5056),Ld=n.n(Dd),Rd=n(540),jd=n.n(Rd),Id=n(1113),Pd=n.n(Id),zd=n(6541),$d={};$d.styleTagTransform=Pd(),$d.setAttributes=Ld(),$d.insert=function(t){var e=document.querySelector("head"),n=window._lastElementInsertedByStyleLoader;n?n.nextSibling?e.insertBefore(t,n.nextSibling):e.appendChild(t):e.insertBefore(t,e.firstChild),window._lastElementInsertedByStyleLoader=t},$d.domAPI=Nd(),$d.insertStyleElement=jd(),Ed()(zd.A,$d),zd.A&&zd.A.locals&&zd.A.locals;var Hd=n(4193),Bd=n(297),Vd=n(8734),_d=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,Fd=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,Wd=Bs.create({name:"highlight",addOptions:()=>({multicolor:!1,HTMLAttributes:{}}),addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:t=>t.getAttribute("data-color")||t.style.backgroundColor,renderHTML:t=>t.color?{"data-color":t.color,style:`background-color: ${t.color}; color: inherit`}:{}}}:{}},parseHTML:()=>[{tag:"mark"}],renderHTML({HTMLAttributes:t}){return["mark",rs(this.options.HTMLAttributes,t),0]},addCommands(){return{setHighlight:t=>({commands:e})=>e.setMark(this.name,t),toggleHighlight:t=>({commands:e})=>e.toggleMark(this.name,t),unsetHighlight:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[ma({find:_d,type:this.type})]},addPasteRules(){return[wa({find:Fd,type:this.type})]}}),qd=(t,e)=>{if("slot"===t)return 0;if(t instanceof Function)return t(e);const{children:n,...o}=null!=e?e:{};if("svg"===t)throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[t,o,n]},Kd=/^\s*>\s$/,Jd=va.create({name:"blockquote",addOptions:()=>({HTMLAttributes:{}}),content:"block+",group:"block",defining:!0,parseHTML:()=>[{tag:"blockquote"}],renderHTML({HTMLAttributes:t}){return qd("blockquote",{...rs(this.options.HTMLAttributes,t),children:qd("slot",{})})},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[ba({find:Kd,type:this.type})]}}),Ud=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Gd=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Yd=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Xd=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Qd=Bs.create({name:"bold",addOptions:()=>({HTMLAttributes:{}}),parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>"normal"!==t.style.fontWeight&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return qd("strong",{...rs(this.options.HTMLAttributes,t),children:qd("slot",{})})},addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[ma({find:Ud,type:this.type}),ma({find:Yd,type:this.type})]},addPasteRules(){return[wa({find:Gd,type:this.type}),wa({find:Xd,type:this.type})]}}),Zd=/(^|[^`])`([^`]+)`(?!`)$/,th=/(^|[^`])`([^`]+)`(?!`)/g,eh=Bs.create({name:"code",addOptions:()=>({HTMLAttributes:{}}),excludes:"_",code:!0,exitable:!0,parseHTML:()=>[{tag:"code"}],renderHTML({HTMLAttributes:t}){return["code",rs(this.options.HTMLAttributes,t),0]},addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[ma({find:Zd,type:this.type})]},addPasteRules(){return[wa({find:th,type:this.type})]}}),nh=/^```([a-z]+)?[\s\n]$/,oh=/^~~~([a-z]+)?[\s\n]$/,rh=va.create({name:"codeBlock",addOptions:()=>({languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:4,HTMLAttributes:{}}),content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options;return[...(null==(e=t.firstElementChild)?void 0:e.classList)||[]].filter(t=>t.startsWith(n)).map(t=>t.replace(n,""))[0]||null},rendered:!1}}},parseHTML:()=>[{tag:"pre",preserveWhitespace:"full"}],renderHTML({node:t,HTMLAttributes:e}){return["pre",rs(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=1===e.pos;return!(!t||e.parent.type.name!==this.name)&&!(!n&&e.parent.textContent.length)&&this.editor.commands.clearNodes()},Tab:({editor:t})=>{if(!this.options.enableTabIndentation)return!1;const{state:e}=t,{selection:n}=e,{$from:o,empty:r}=n;if(o.parent.type!==this.type)return!1;const i=" ".repeat(this.options.tabSize);return r?t.commands.insertContent(i):t.commands.command(({tr:t})=>{const{from:o,to:r}=n,s=e.doc.textBetween(o,r,"\n","\n").split("\n").map(t=>i+t).join("\n");return t.replaceWith(o,r,e.schema.text(s)),!0})},"Shift-Tab":({editor:t})=>{if(!this.options.enableTabIndentation)return!1;const{state:e}=t,{selection:n}=e,{$from:o,empty:r}=n;return o.parent.type===this.type&&(r?t.commands.command(({tr:t})=>{var n;const{pos:r}=o,i=o.start(),s=o.end(),l=e.doc.textBetween(i,s,"\n","\n").split("\n");let a=0,c=0;const d=r-i;for(let t=0;t<l.length;t+=1){if(c+l[t].length>=d){a=t;break}c+=l[t].length+1}const h=(null==(n=l[a].match(/^ */))?void 0:n[0])||"",p=Math.min(h.length,this.options.tabSize);if(0===p)return!0;let u=i;for(let t=0;t<a;t+=1)u+=l[t].length+1;return t.delete(u,u+p),r-u<=p&&t.setSelection(xe.create(t.doc,u)),!0}):t.commands.command(({tr:t})=>{const{from:o,to:r}=n,i=e.doc.textBetween(o,r,"\n","\n").split("\n").map(t=>{var e;const n=(null==(e=t.match(/^ */))?void 0:e[0])||"",o=Math.min(n.length,this.options.tabSize);return t.slice(o)}).join("\n");return t.replaceWith(o,r,e.schema.text(i)),!0}))},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:o,empty:r}=n;if(!r||o.parent.type!==this.type)return!1;const i=o.parentOffset===o.parent.nodeSize-2,s=o.parent.textContent.endsWith("\n\n");return!(!i||!s)&&t.chain().command(({tr:t})=>(t.delete(o.pos-2,o.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:o}=e,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;if(r.parentOffset!==r.parent.nodeSize-2)return!1;const s=r.after();return void 0!==s&&(o.nodeAt(s)?t.commands.command(({tr:t})=>(t.setSelection(be.near(o.resolve(s))),!0)):t.commands.exitCode())}}},addInputRules(){return[ya({find:nh,type:this.type,getAttributes:t=>({language:t[1]})}),ya({find:oh,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new ze({key:new Be("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData)return!1;if(this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),o=e.clipboardData.getData("vscode-editor-data"),r=o?JSON.parse(o):void 0,i=null==r?void 0:r.mode;if(!n||!i)return!1;const{tr:s,schema:l}=t.state,a=l.text(n.replace(/\r\n?/g,"\n"));return s.replaceSelectionWith(this.type.create({language:i},a)),s.selection.$from.parent.type!==this.type&&s.setSelection(xe.near(s.doc.resolve(Math.max(0,s.selection.from-2)))),s.setMeta("paste",!0),t.dispatch(s),!0}}})]}}),ih=va.create({name:"doc",topNode:!0,content:"block+"}),sh=va.create({name:"hardBreak",addOptions:()=>({keepMarks:!0,HTMLAttributes:{}}),inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML:()=>[{tag:"br"}],renderHTML({HTMLAttributes:t}){return["br",rs(this.options.HTMLAttributes,t)]},renderText:()=>"\n",addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:o})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:t,storedMarks:r}=n;if(t.$from.parent.type.spec.isolating)return!1;const{keepMarks:i}=this.options,{splittableMarks:s}=o.extensionManager,l=r||t.$to.parentOffset&&t.$from.marks();return e().insertContent({type:this.name}).command(({tr:t,dispatch:e})=>{if(e&&l&&i){const e=l.filter(t=>s.includes(t.type.name));t.ensureMarks(e)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),lh=va.create({name:"heading",addOptions:()=>({levels:[1,2,3,4,5,6],HTMLAttributes:{}}),content:"inline*",group:"block",defining:!0,addAttributes:()=>({level:{default:1,rendered:!1}}),parseHTML(){return this.options.levels.map(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,rs(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:t=>({commands:e})=>!!this.options.levels.includes(t.level)&&e.setNode(this.name,t),toggleHeading:t=>({commands:e})=>!!this.options.levels.includes(t.level)&&e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>ya({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),ah=va.create({name:"horizontalRule",addOptions:()=>({HTMLAttributes:{}}),group:"block",parseHTML:()=>[{tag:"hr"}],renderHTML({HTMLAttributes:t}){return["hr",rs(this.options.HTMLAttributes,t)]},addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!function(t,e){const{selection:n}=t,{$from:o}=n;if(n instanceof Ce){const t=o.index();return o.parent.canReplaceWith(t,t+1,e)}let r=o.depth;for(;r>=0;){const t=o.index(r);if(o.node(r).contentMatchAt(t).matchType(e))return!0;r-=1}return!1}(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:o}=n,r=t();return Ds(n)?r.insertContentAt(o.pos,{type:this.name}):r.insertContent({type:this.name}),r.command(({tr:t,dispatch:e})=>{var n;if(e){const{$to:e}=t.selection,o=e.end();if(e.nodeAfter)e.nodeAfter.isTextblock?t.setSelection(xe.create(t.doc,e.pos+1)):e.nodeAfter.isBlock?t.setSelection(Ce.create(t.doc,e.pos)):t.setSelection(xe.create(t.doc,e.pos));else{const r=null==(n=e.parent.type.contentMatch.defaultType)?void 0:n.create();r&&(t.insert(o,r),t.setSelection(xe.create(t.doc,o+1)))}t.scrollIntoView()}return!0}).run()}}},addInputRules(){return[ga({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),ch=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,dh=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,hh=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,ph=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,uh=Bs.create({name:"italic",addOptions:()=>({HTMLAttributes:{}}),parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>"normal"!==t.style.fontStyle&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",rs(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[ma({find:ch,type:this.type}),ma({find:hh,type:this.type})]},addPasteRules(){return[wa({find:dh,type:this.type}),wa({find:ph,type:this.type})]}});const fh="numeric",mh="ascii",gh="alpha",yh="asciinumeric",bh="alphanumeric",vh="domain",wh="emoji",kh="scheme",xh="slashscheme",Mh="whitespace";function Ch(t,e){return t in e||(e[t]=[]),e[t]}function Sh(t,e,n){e[fh]&&(e[yh]=!0,e[bh]=!0),e[mh]&&(e[yh]=!0,e[gh]=!0),e[yh]&&(e[bh]=!0),e[gh]&&(e[bh]=!0),e[bh]&&(e[vh]=!0),e[wh]&&(e[vh]=!0);for(const o in e){const e=Ch(o,n);e.indexOf(t)<0&&e.push(t)}}function Th(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}Th.groups={},Th.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let n=0;n<e.jr.length;n++){const o=e.jr[n][0],r=e.jr[n][1];if(r&&o.test(t))return r}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,o){for(let r=0;r<t.length;r++)this.tt(t[r],e,n,o)},tr(t,e,n,o){let r;return o=o||Th.groups,e&&e.j?r=e:(r=new Th(e),n&&o&&Sh(e,n,o)),this.jr.push([t,r]),r},ts(t,e,n,o){let r=this;const i=t.length;if(!i)return r;for(let e=0;e<i-1;e++)r=r.tt(t[e]);return r.tt(t[i-1],e,n,o)},tt(t,e,n,o){o=o||Th.groups;const r=this;if(e&&e.j)return r.j[t]=e,e;const i=e;let s,l=r.go(t);if(l?(s=new Th,Object.assign(s.j,l.j),s.jr.push.apply(s.jr,l.jr),s.jd=l.jd,s.t=l.t):s=new Th,i){if(o)if(s.t&&"string"==typeof s.t){const t=Object.assign(function(t,e){const n={};for(const o in e)e[o].indexOf(t)>=0&&(n[o]=!0);return n}(s.t,o),n);Sh(i,t,o)}else n&&Sh(i,n,o);s.t=i}return r.j[t]=s,s}};const Ah=(t,e,n,o,r)=>t.ta(e,n,o,r),Eh=(t,e,n,o,r)=>t.tr(e,n,o,r),Oh=(t,e,n,o,r)=>t.ts(e,n,o,r),Nh=(t,e,n,o,r)=>t.tt(e,n,o,r),Dh="WORD",Lh="UWORD",Rh="ASCIINUMERICAL",jh="ALPHANUMERICAL",Ih="LOCALHOST",Ph="TLD",zh="UTLD",$h="SCHEME",Hh="SLASH_SCHEME",Bh="NUM",Vh="WS",_h="NL",Fh="OPENBRACE",Wh="CLOSEBRACE",qh="OPENBRACKET",Kh="CLOSEBRACKET",Jh="OPENPAREN",Uh="CLOSEPAREN",Gh="OPENANGLEBRACKET",Yh="CLOSEANGLEBRACKET",Xh="FULLWIDTHLEFTPAREN",Qh="FULLWIDTHRIGHTPAREN",Zh="LEFTCORNERBRACKET",tp="RIGHTCORNERBRACKET",ep="LEFTWHITECORNERBRACKET",np="RIGHTWHITECORNERBRACKET",op="FULLWIDTHLESSTHAN",rp="FULLWIDTHGREATERTHAN",ip="AMPERSAND",sp="APOSTROPHE",lp="ASTERISK",ap="AT",cp="BACKSLASH",dp="BACKTICK",hp="CARET",pp="COLON",up="COMMA",fp="DOLLAR",mp="DOT",gp="EQUALS",yp="EXCLAMATION",bp="HYPHEN",vp="PERCENT",wp="PIPE",kp="PLUS",xp="POUND",Mp="QUERY",Cp="QUOTE",Sp="FULLWIDTHMIDDLEDOT",Tp="SEMI",Ap="SLASH",Ep="TILDE",Op="UNDERSCORE",Np="EMOJI",Dp="SYM";var Lp=Object.freeze({__proto__:null,ALPHANUMERICAL:jh,AMPERSAND:ip,APOSTROPHE:sp,ASCIINUMERICAL:Rh,ASTERISK:lp,AT:ap,BACKSLASH:cp,BACKTICK:dp,CARET:hp,CLOSEANGLEBRACKET:Yh,CLOSEBRACE:Wh,CLOSEBRACKET:Kh,CLOSEPAREN:Uh,COLON:pp,COMMA:up,DOLLAR:fp,DOT:mp,EMOJI:Np,EQUALS:gp,EXCLAMATION:yp,FULLWIDTHGREATERTHAN:rp,FULLWIDTHLEFTPAREN:Xh,FULLWIDTHLESSTHAN:op,FULLWIDTHMIDDLEDOT:Sp,FULLWIDTHRIGHTPAREN:Qh,HYPHEN:bp,LEFTCORNERBRACKET:Zh,LEFTWHITECORNERBRACKET:ep,LOCALHOST:Ih,NL:_h,NUM:Bh,OPENANGLEBRACKET:Gh,OPENBRACE:Fh,OPENBRACKET:qh,OPENPAREN:Jh,PERCENT:vp,PIPE:wp,PLUS:kp,POUND:xp,QUERY:Mp,QUOTE:Cp,RIGHTCORNERBRACKET:tp,RIGHTWHITECORNERBRACKET:np,SCHEME:$h,SEMI:Tp,SLASH:Ap,SLASH_SCHEME:Hh,SYM:Dp,TILDE:Ep,TLD:Ph,UNDERSCORE:Op,UTLD:zh,UWORD:Lh,WORD:Dh,WS:Vh});const Rp=/[a-z]/,jp=/\p{L}/u,Ip=/\p{Emoji}/u,Pp=/\d/,zp=/\s/;let $p=null,Hp=null;function Bp(t,e){const n=function(t){const e=[],n=t.length;let o=0;for(;o<n;){let r,i=t.charCodeAt(o),s=i<55296||i>56319||o+1===n||(r=t.charCodeAt(o+1))<56320||r>57343?t[o]:t.slice(o,o+2);e.push(s),o+=s.length}return e}(e.replace(/[A-Z]/g,t=>t.toLowerCase())),o=n.length,r=[];let i=0,s=0;for(;s<o;){let l=t,a=null,c=0,d=null,h=-1,p=-1;for(;s<o&&(a=l.go(n[s]));)l=a,l.accepts()?(h=0,p=0,d=l):h>=0&&(h+=n[s].length,p++),c+=n[s].length,i+=n[s].length,s++;i-=h,s-=p,c-=h,r.push({t:d.t,v:e.slice(i-c,i),s:i-c,e:i})}return r}function Vp(t,e,n,o,r){let i;const s=e.length;for(let n=0;n<s-1;n++){const s=e[n];t.j[s]?i=t.j[s]:(i=new Th(o),i.jr=r.slice(),t.j[s]=i),t=i}return i=new Th(n),i.jr=r.slice(),t.j[e[s-1]]=i,i}function _p(t){const e=[],n=[];let o=0;for(;o<t.length;){let r=0;for(;"0123456789".indexOf(t[o+r])>=0;)r++;if(r>0){e.push(n.join(""));for(let e=parseInt(t.substring(o,o+r),10);e>0;e--)n.pop();o+=r}else n.push(t[o]),o++}return e}const Fp={defaultProtocol:"http",events:null,format:qp,formatHref:qp,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Wp(t,e=null){let n=Object.assign({},Fp);t&&(n=Object.assign(n,t instanceof Wp?t.o:t));const o=n.ignoreTags,r=[];for(let t=0;t<o.length;t++)r.push(o[t].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=r}function qp(t){return t}function Kp(t,e){this.t="token",this.v=t,this.tk=e}function Jp(t,e){class n extends Kp{constructor(e,n){super(e,n),this.t=t}}for(const t in e)n.prototype[t]=e[t];return n.t=t,n}Wp.prototype={o:Fp,ignoreTags:[],defaultRender:t=>t,check(t){return this.get("validate",t.toString(),t)},get(t,e,n){const o=null!=e;let r=this.o[t];return r?("object"==typeof r?(r=n.t in r?r[n.t]:Fp[t],"function"==typeof r&&o&&(r=r(e,n))):"function"==typeof r&&o&&(r=r(e,n.t,n)),r):r},getObj(t,e,n){let o=this.o[t];return"function"==typeof o&&null!=e&&(o=o(e,n.t,n)),o},render(t){const e=t.render(this);return(this.get("render",null,t)||this.defaultRender)(e,t.t,t)}},Kp.prototype={isLink:!1,toString(){return this.v},toHref(t){return this.toString()},toFormattedString(t){const e=this.toString(),n=t.get("truncate",e,this),o=t.get("format",e,this);return n&&o.length>n?o.substring(0,n)+"…":o},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t=Fp.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,n=this.toHref(t.get("defaultProtocol")),o=t.get("formatHref",n,this),r=t.get("tagName",n,e),i=this.toFormattedString(t),s={},l=t.get("className",n,e),a=t.get("target",n,e),c=t.get("rel",n,e),d=t.getObj("attributes",n,e),h=t.getObj("events",n,e);return s.href=o,l&&(s.class=l),a&&(s.target=a),c&&(s.rel=c),d&&Object.assign(s,d),{tagName:r,attributes:s,content:i,eventListeners:h}}};const Up=Jp("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Gp=Jp("text"),Yp=Jp("nl"),Xp=Jp("url",{isLink:!0,toHref(t=Fp.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==Ih&&t[1].t===pp}}),Qp=t=>new Th(t);function Zp(t,e,n){const o=n[0].s,r=n[n.length-1].e;return new t(e.slice(o,r),n)}const tu="undefined"!=typeof console&&console&&console.warn||(()=>{}),eu={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function nu(t,e=!1){if(eu.initialized&&tu(`linkifyjs: already initialized - will not register custom scheme "${t}" until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error('linkifyjs: incorrect scheme format.\n1. Must only contain digits, lowercase ASCII letters or "-"\n2. Cannot start or end with "-"\n3. "-" cannot repeat');eu.customSchemes.push([t,e])}function ou(t){return eu.initialized||function(){eu.scanner=function(t=[]){const e={};Th.groups=e;const n=new Th;null==$p&&($p=_p("aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2")),null==Hp&&(Hp=_p("ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2")),Nh(n,"'",sp),Nh(n,"{",Fh),Nh(n,"}",Wh),Nh(n,"[",qh),Nh(n,"]",Kh),Nh(n,"(",Jh),Nh(n,")",Uh),Nh(n,"<",Gh),Nh(n,">",Yh),Nh(n,"(",Xh),Nh(n,")",Qh),Nh(n,"「",Zh),Nh(n,"」",tp),Nh(n,"『",ep),Nh(n,"』",np),Nh(n,"<",op),Nh(n,">",rp),Nh(n,"&",ip),Nh(n,"*",lp),Nh(n,"@",ap),Nh(n,"`",dp),Nh(n,"^",hp),Nh(n,":",pp),Nh(n,",",up),Nh(n,"$",fp),Nh(n,".",mp),Nh(n,"=",gp),Nh(n,"!",yp),Nh(n,"-",bp),Nh(n,"%",vp),Nh(n,"|",wp),Nh(n,"+",kp),Nh(n,"#",xp),Nh(n,"?",Mp),Nh(n,'"',Cp),Nh(n,"/",Ap),Nh(n,";",Tp),Nh(n,"~",Ep),Nh(n,"_",Op),Nh(n,"\\",cp),Nh(n,"・",Sp);const o=Eh(n,Pp,Bh,{[fh]:!0});Eh(o,Pp,o);const r=Eh(o,Rp,Rh,{[yh]:!0}),i=Eh(o,jp,jh,{[bh]:!0}),s=Eh(n,Rp,Dh,{[mh]:!0});Eh(s,Pp,r),Eh(s,Rp,s),Eh(r,Pp,r),Eh(r,Rp,r);const l=Eh(n,jp,Lh,{[gh]:!0});Eh(l,Rp),Eh(l,Pp,i),Eh(l,jp,l),Eh(i,Pp,i),Eh(i,Rp),Eh(i,jp,i);const a=Nh(n,"\n",_h,{[Mh]:!0}),c=Nh(n,"\r",Vh,{[Mh]:!0}),d=Eh(n,zp,Vh,{[Mh]:!0});Nh(n,"",d),Nh(c,"\n",a),Nh(c,"",d),Eh(c,zp,d),Nh(d,"\r"),Nh(d,"\n"),Eh(d,zp,d),Nh(d,"",d);const h=Eh(n,Ip,Np,{[wh]:!0});Nh(h,"#"),Eh(h,Ip,h),Nh(h,"️",h);const p=Nh(h,"‍");Nh(p,"#"),Eh(p,Ip,h);const u=[[Rp,s],[Pp,r]],f=[[Rp,null],[jp,l],[Pp,i]];for(let t=0;t<$p.length;t++)Vp(n,$p[t],Ph,Dh,u);for(let t=0;t<Hp.length;t++)Vp(n,Hp[t],zh,Lh,f);Sh(Ph,{tld:!0,ascii:!0},e),Sh(zh,{utld:!0,alpha:!0},e),Vp(n,"file",$h,Dh,u),Vp(n,"mailto",$h,Dh,u),Vp(n,"http",Hh,Dh,u),Vp(n,"https",Hh,Dh,u),Vp(n,"ftp",Hh,Dh,u),Vp(n,"ftps",Hh,Dh,u),Sh($h,{scheme:!0,ascii:!0},e),Sh(Hh,{slashscheme:!0,ascii:!0},e),t=t.sort((t,e)=>t[0]>e[0]?1:-1);for(let e=0;e<t.length;e++){const o=t[e][0],r=t[e][1]?{[kh]:!0}:{[xh]:!0};o.indexOf("-")>=0?r[vh]=!0:Rp.test(o)?Pp.test(o)?r[yh]=!0:r[mh]=!0:r[fh]=!0,Oh(n,o,o,r)}return Oh(n,"localhost",Ih,{ascii:!0}),n.jd=new Th(Dp),{start:n,tokens:Object.assign({groups:e},Lp)}}(eu.customSchemes);for(let t=0;t<eu.tokenQueue.length;t++)eu.tokenQueue[t][1]({scanner:eu.scanner});eu.parser=function({groups:t}){const e=t.domain.concat([ip,lp,ap,cp,dp,hp,fp,gp,bp,Bh,vp,wp,kp,xp,Ap,Dp,Ep,Op]),n=[sp,pp,up,mp,yp,vp,Mp,Cp,Tp,Gh,Yh,Fh,Wh,Kh,qh,Jh,Uh,Xh,Qh,Zh,tp,ep,np,op,rp],o=[ip,sp,lp,cp,dp,hp,fp,gp,bp,Fh,Wh,vp,wp,kp,xp,Mp,Ap,Dp,Ep,Op],r=Qp(),i=Nh(r,Ep);Ah(i,o,i),Ah(i,t.domain,i);const s=Qp(),l=Qp(),a=Qp();Ah(r,t.domain,s),Ah(r,t.scheme,l),Ah(r,t.slashscheme,a),Ah(s,o,i),Ah(s,t.domain,s);const c=Nh(s,ap);Nh(i,ap,c),Nh(l,ap,c),Nh(a,ap,c);const d=Nh(i,mp);Ah(d,o,i),Ah(d,t.domain,i);const h=Qp();Ah(c,t.domain,h),Ah(h,t.domain,h);const p=Nh(h,mp);Ah(p,t.domain,h);const u=Qp(Up);Ah(p,t.tld,u),Ah(p,t.utld,u),Nh(c,Ih,u);const f=Nh(h,bp);Nh(f,bp,f),Ah(f,t.domain,h),Ah(u,t.domain,h),Nh(u,mp,p),Nh(u,bp,f);const m=Nh(u,pp);Ah(m,t.numeric,Up);const g=Nh(s,bp),y=Nh(s,mp);Nh(g,bp,g),Ah(g,t.domain,s),Ah(y,o,i),Ah(y,t.domain,s);const b=Qp(Xp);Ah(y,t.tld,b),Ah(y,t.utld,b),Ah(b,t.domain,s),Ah(b,o,i),Nh(b,mp,y),Nh(b,bp,g),Nh(b,ap,c);const v=Nh(b,pp),w=Qp(Xp);Ah(v,t.numeric,w);const k=Qp(Xp),x=Qp();Ah(k,e,k),Ah(k,n,x),Ah(x,e,k),Ah(x,n,x),Nh(b,Ap,k),Nh(w,Ap,k);const M=Nh(l,pp),C=Nh(a,pp),S=Nh(C,Ap),T=Nh(S,Ap);Ah(l,t.domain,s),Nh(l,mp,y),Nh(l,bp,g),Ah(a,t.domain,s),Nh(a,mp,y),Nh(a,bp,g),Ah(M,t.domain,k),Nh(M,Ap,k),Nh(M,Mp,k),Ah(T,t.domain,k),Ah(T,e,k),Nh(T,Ap,k);const A=[[Fh,Wh],[qh,Kh],[Jh,Uh],[Gh,Yh],[Xh,Qh],[Zh,tp],[ep,np],[op,rp]];for(let t=0;t<A.length;t++){const[o,r]=A[t],i=Nh(k,o);Nh(x,o,i),Nh(i,r,k);const s=Qp(Xp);Ah(i,e,s);const l=Qp();Ah(i,n),Ah(s,e,s),Ah(s,n,l),Ah(l,e,s),Ah(l,n,l),Nh(s,r,k),Nh(l,r,k)}return Nh(r,Ih,b),Nh(r,_h,Yp),{start:r,tokens:Lp}}(eu.scanner.tokens);for(let t=0;t<eu.pluginQueue.length;t++)eu.pluginQueue[t][1]({scanner:eu.scanner,parser:eu.parser});eu.initialized=!0}(),function(t,e,n){let o=n.length,r=0,i=[],s=[];for(;r<o;){let l=t,a=null,c=null,d=0,h=null,p=-1;for(;r<o&&!(a=l.go(n[r].t));)s.push(n[r++]);for(;r<o&&(c=a||l.go(n[r].t));)a=null,l=c,l.accepts()?(p=0,h=l):p>=0&&p++,r++,d++;if(p<0)r-=d,r<o&&(s.push(n[r]),r++);else{s.length>0&&(i.push(Zp(Gp,e,s)),s=[]),r-=p,d-=p;const t=h.t,o=n.slice(r-d,r);i.push(Zp(t,e,o))}}return s.length>0&&i.push(Zp(Gp,e,s)),i}(eu.parser.start,t,Bp(eu.scanner.start,t))}function ru(t,e=null,n=null){if(e&&"object"==typeof e){if(n)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);n=e,e=null}const o=new Wp(n),r=ou(t),i=[];for(let t=0;t<r.length;t++){const n=r[t];!n.isLink||e&&n.t!==e||!o.check(n)||i.push(n.toFormattedObject(o))}return i}ou.scan=Bp;var iu="[\0-   ᠎ -\u2029  ]",su=new RegExp(iu),lu=new RegExp(`${iu}$`),au=new RegExp(iu,"g");function cu(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(t=>{const e="string"==typeof t?t:t.scheme;e&&n.push(e)}),!t||t.replace(au,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var du=Bs.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(t=>{"string"!=typeof t?nu(t.scheme,t.optionalSlashes):nu(t)})},onDestroy(){Th.groups={},eu.scanner=null,eu.parser=null,eu.tokenQueue=[],eu.pluginQueue=[],eu.customSchemes=[],eu.initialized=!1},inclusive(){return this.options.autolink},addOptions:()=>({openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!cu(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>!!t}),addAttributes(){return{href:{default:null,parseHTML:t=>t.getAttribute("href")},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const e=t.getAttribute("href");return!(!e||!this.options.isAllowedUri(e,{defaultValidate:t=>!!cu(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}))&&null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:t=>!!cu(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",rs(this.options.HTMLAttributes,t),0]:["a",rs(this.options.HTMLAttributes,{...t,href:""}),0]},addCommands(){return{setLink:t=>({chain:e})=>{const{href:n}=t;return!!this.options.isAllowedUri(n,{defaultValidate:t=>!!cu(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})&&e().setMark(this.name,t).setMeta("preventAutolink",!0).run()},toggleLink:t=>({chain:e})=>{const{href:n}=t||{};return!(n&&!this.options.isAllowedUri(n,{defaultValidate:t=>!!cu(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}))&&e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[wa({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:o}=this.options,r=ru(t).filter(t=>t.isLink&&this.options.isAllowedUri(t.value,{defaultValidate:t=>!!cu(t,n),protocols:n,defaultProtocol:o}));r.length&&r.forEach(t=>e.push({text:t.value,data:{href:t.href},index:t.start}))}return e},type:this.type,getAttributes:t=>{var e;return{href:null==(e=t.data)?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(function(t){return new ze({key:new Be("autolink"),appendTransaction:(e,n,o)=>{const r=e.some(t=>t.docChanged)&&!n.doc.eq(o.doc),i=e.some(t=>t.getMeta("preventAutolink"));if(!r||i)return;const{tr:s}=o;return ys(Fi(n.doc,[...e])).forEach(({newRange:e})=>{const n=function(t,e){const n=[];return t.nodesBetween(e.from,e.to,(t,e)=>{(t=>t.isTextblock)(t)&&n.push({node:t,pos:e})}),n}(o.doc,e);let r,i;if(n.length>1)r=n[0],i=o.doc.textBetween(r.pos,r.pos+r.node.nodeSize,void 0," ");else if(n.length){const t=o.doc.textBetween(e.from,e.to," "," ");if(!lu.test(t))return;r=n[0],i=o.doc.textBetween(r.pos,e.to,void 0," ")}if(r&&i){const e=i.split(su).filter(Boolean);if(e.length<=0)return!1;const n=e[e.length-1],a=r.pos+i.lastIndexOf(n);if(!n)return!1;const c=ou(n).map(e=>e.toObject(t.defaultProtocol));if(!(1===(l=c).length?l[0].isLink:3===l.length&&l[1].isLink&&["()","[]"].includes(l[0].value+l[2].value)))return!1;c.filter(t=>t.isLink).map(t=>({...t,from:a+t.start+1,to:a+t.end+1})).filter(t=>!o.schema.marks.code||!o.doc.rangeHasMark(t.from,t.to,o.schema.marks.code)).filter(e=>t.validate(e.value)).filter(e=>t.shouldAutoLink(e.value)).forEach(e=>{Ms(e.from,e.to,o.doc).some(e=>e.mark.type===t.type)||s.addMark(e.from,e.to,t.type.create({href:e.href}))})}var l}),s.steps.length?s:void 0}})}({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:t=>this.options.isAllowedUri(t,{defaultValidate:t=>!!cu(t,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),!0===this.options.openOnClick&&t.push(function(t){return new ze({key:new Be("handleClickLink"),props:{handleClick:(e,n,o)=>{var r,i;if(0!==o.button)return!1;if(!e.editable)return!1;let s=null;if(o.target instanceof HTMLAnchorElement)s=o.target;else{let t=o.target;const e=[];for(;"DIV"!==t.nodeName;)e.push(t),t=t.parentNode;s=e.find(t=>"A"===t.nodeName)}if(!s)return!1;const l=gs(e.state,t.type.name),a=null!=(r=null==s?void 0:s.href)?r:l.href,c=null!=(i=null==s?void 0:s.target)?i:l.target;return t.enableClickSelection&&t.editor.commands.extendMarkRange(t.type.name),!(!s||!a||(window.open(a,c),0))}}})}({type:this.type,editor:this.editor,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(function(t){return new ze({key:new Be("handlePasteLink"),props:{handlePaste:(e,n,o)=>{const{state:r}=e,{selection:i}=r,{empty:s}=i;if(s)return!1;let l="";o.content.forEach(t=>{l+=t.textContent});const a=ru(l,{defaultProtocol:t.defaultProtocol}).find(t=>t.isLink&&t.value===l);return!(!l||!a)&&t.editor.commands.setMark(t.type,{href:a.href})}}})}({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),t}}),hu=Object.defineProperty,pu="textStyle",uu=/^\s*([-+*])\s$/,fu=va.create({name:"bulletList",addOptions:()=>({itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}),group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML:()=>[{tag:"ul"}],renderHTML({HTMLAttributes:t}){return["ul",rs(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes("listItem",this.editor.getAttributes(pu)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=ba({find:uu,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=ba({find:uu,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(pu),editor:this.editor})),[t]}}),mu=va.create({name:"listItem",addOptions:()=>({HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}),content:"paragraph block*",defining:!0,parseHTML:()=>[{tag:"li"}],renderHTML({HTMLAttributes:t}){return["li",rs(this.options.HTMLAttributes,t),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}});((t,e)=>{for(var n in e)hu(t,n,{get:e[n],enumerable:!0})})({},{findListItemPos:()=>gu,getNextListDepth:()=>yu,handleBackspace:()=>ku,handleDelete:()=>Cu,hasListBefore:()=>bu,hasListItemAfter:()=>Su,hasListItemBefore:()=>vu,listItemHasSubList:()=>wu,nextListIsDeeper:()=>xu,nextListIsHigher:()=>Mu});var gu=(t,e)=>{const{$from:n}=e.selection,o=fs(t,e.schema);let r=null,i=n.depth,s=n.pos,l=null;for(;i>0&&null===l;)r=n.node(i),r.type===o?l=i:(i-=1,s-=1);return null===l?null:{$pos:e.doc.resolve(s),depth:l}},yu=(t,e)=>{const n=gu(t,e);if(!n)return!1;const[,o]=((t,e,n,o=20)=>{const r=t.doc.resolve(n);let i=o,s=null;for(;i>0&&null===s;){const t=r.node(i);(null==t?void 0:t.type.name)===e?s=t:i-=1}return[s,i]})(e,t,n.$pos.pos+4);return o},bu=(t,e,n)=>{const{$anchor:o}=t.selection,r=Math.max(0,o.pos-2),i=t.doc.resolve(r).node();return!(!i||!n.includes(i.type.name))},vu=(t,e)=>{var n;const{$anchor:o}=e.selection,r=e.doc.resolve(o.pos-2);return 0!==r.index()&&(null==(n=r.nodeBefore)?void 0:n.type.name)===t},wu=(t,e,n)=>{if(!n)return!1;const o=fs(t,e.schema);let r=!1;return n.descendants(t=>{t.type===o&&(r=!0)}),r},ku=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!As(t.state,e)&&bu(t.state,e,n)){const{$anchor:n}=t.state.selection,o=t.state.doc.resolve(n.before()-1),r=[];o.node().descendants((t,n)=>{t.type.name===e&&r.push({node:t,pos:n})});const i=r.at(-1);if(!i)return!1;const s=t.state.doc.resolve(o.start()+i.pos+1);return t.chain().cut({from:n.start()-1,to:n.end()+1},s.end()).joinForward().run()}if(!As(t.state,e))return!1;if(!(t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)})(t.state))return!1;const o=gu(e,t.state);if(!o)return!1;const r=t.state.doc.resolve(o.$pos.pos-2).node(o.depth),i=wu(e,t.state,r);return vu(e,t.state)&&!i?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},xu=(t,e)=>{const n=yu(t,e),o=gu(t,e);return!(!o||!n)&&n>o.depth},Mu=(t,e)=>{const n=yu(t,e),o=gu(t,e);return!(!o||!n)&&n<o.depth},Cu=(t,e)=>{if(!As(t.state,e))return!1;if(!((t,e)=>{const{$from:n,$to:o,$anchor:r}=t.selection;if(e){const n=Gi(t=>t.type.name===e)(t.selection);if(!n)return!1;const o=t.doc.resolve(n.pos+1);return r.pos+1===o.end()}return!(o.parentOffset<o.parent.nodeSize-2||n.pos!==o.pos)})(t.state,e))return!1;const{selection:n}=t.state,{$from:o,$to:r}=n;return!(!n.empty&&o.sameParent(r))&&(xu(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():Mu(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward())},Su=(t,e)=>{var n;const{$anchor:o}=e.selection,r=e.doc.resolve(o.pos-o.parentOffset-2);return r.index()!==r.parent.childCount-1&&(null==(n=r.nodeAfter)?void 0:n.type.name)===t},Tu=qs.create({name:"listKeymap",addOptions:()=>({listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}),addKeyboardShortcuts(){return{Delete:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{void 0!==t.state.schema.nodes[n]&&Cu(t,n)&&(e=!0)}),e},"Mod-Delete":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{void 0!==t.state.schema.nodes[n]&&Cu(t,n)&&(e=!0)}),e},Backspace:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:o})=>{void 0!==t.state.schema.nodes[n]&&ku(t,n,o)&&(e=!0)}),e},"Mod-Backspace":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:o})=>{void 0!==t.state.schema.nodes[n]&&ku(t,n,o)&&(e=!0)}),e}}}}),Au="textStyle",Eu=/^(\d+)\.\s$/,Ou=va.create({name:"orderedList",addOptions:()=>({itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}),group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes:()=>({start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>t.getAttribute("type")}}),parseHTML:()=>[{tag:"ol"}],renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return 1===e?["ol",rs(this.options.HTMLAttributes,n),0]:["ol",rs(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes("listItem",this.editor.getAttributes(Au)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=ba({find:Eu,type:this.type,getAttributes:t=>({start:+t[1]}),joinPredicate:(t,e)=>e.childCount+e.attrs.start===+t[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=ba({find:Eu,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:t=>({start:+t[1],...this.editor.getAttributes(Au)}),joinPredicate:(t,e)=>e.childCount+e.attrs.start===+t[1],editor:this.editor})),[t]}}),Nu=/^\s*(\[([( |x])?\])\s$/,Du=va.create({name:"taskItem",addOptions:()=>({nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}),content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes:()=>({checked:{default:!1,keepOnSplit:!1,parseHTML:t=>{const e=t.getAttribute("data-checked");return""===e||"true"===e},renderHTML:t=>({"data-checked":t.checked})}}),parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:t,HTMLAttributes:e}){return["li",rs(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:o})=>{const r=document.createElement("li"),i=document.createElement("label"),s=document.createElement("span"),l=document.createElement("input"),a=document.createElement("div"),c=t=>{var e,n;l.ariaLabel=(null==(n=null==(e=this.options.a11y)?void 0:e.checkboxLabel)?void 0:n.call(e,t,l.checked))||`Task item checkbox for ${t.textContent||"empty task item"}`};return c(t),i.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",t=>t.preventDefault()),l.addEventListener("change",e=>{if(!o.isEditable&&!this.options.onReadOnlyChecked)return void(l.checked=!l.checked);const{checked:r}=e.target;o.isEditable&&"function"==typeof n&&o.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:t})=>{const e=n();if("number"!=typeof e)return!1;const o=t.doc.nodeAt(e);return t.setNodeMarkup(e,void 0,{...null==o?void 0:o.attrs,checked:r}),!0}).run(),!o.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,r)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([t,e])=>{r.setAttribute(t,e)}),r.dataset.checked=t.attrs.checked,l.checked=t.attrs.checked,i.append(l,s),r.append(i,a),Object.entries(e).forEach(([t,e])=>{r.setAttribute(t,e)}),{dom:r,contentDOM:a,update:t=>t.type===this.type&&(r.dataset.checked=t.attrs.checked,l.checked=t.attrs.checked,c(t),!0)}}},addInputRules(){return[ba({find:Nu,type:this.type,getAttributes:t=>({checked:"x"===t[t.length-1]})})]}}),Lu=va.create({name:"taskList",addOptions:()=>({itemTypeName:"taskItem",HTMLAttributes:{}}),group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",rs(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}}),Ru=(qs.create({name:"listKit",addExtensions(){const t=[];return!1!==this.options.bulletList&&t.push(fu.configure(this.options.bulletList)),!1!==this.options.listItem&&t.push(mu.configure(this.options.listItem)),!1!==this.options.listKeymap&&t.push(Tu.configure(this.options.listKeymap)),!1!==this.options.orderedList&&t.push(Ou.configure(this.options.orderedList)),!1!==this.options.taskItem&&t.push(Du.configure(this.options.taskItem)),!1!==this.options.taskList&&t.push(Lu.configure(this.options.taskList)),t}}),va.create({name:"paragraph",priority:1e3,addOptions:()=>({HTMLAttributes:{}}),group:"block",content:"inline*",parseHTML:()=>[{tag:"p"}],renderHTML({HTMLAttributes:t}){return["p",rs(this.options.HTMLAttributes,t),0]},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}})),ju=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Iu=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Pu=Bs.create({name:"strike",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>!!t.includes("line-through")&&{}}],renderHTML({HTMLAttributes:t}){return["s",rs(this.options.HTMLAttributes,t),0]},addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[ma({find:ju,type:this.type})]},addPasteRules(){return[wa({find:Iu,type:this.type})]}}),zu=va.create({name:"text",group:"inline"}),$u=Bs.create({name:"underline",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>!!t.includes("underline")&&{}}],renderHTML({HTMLAttributes:t}){return["u",rs(this.options.HTMLAttributes,t),0]},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function Hu(t={}){return new ze({view:e=>new Bu(e,t)})}class Bu{constructor(t,e){var n;this.editorView=t,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=null!==(n=e.width)&&void 0!==n?n:1,this.color=!1===e.color?void 0:e.color||"black",this.class=e.class,this.handlers=["dragover","dragend","drop","dragleave"].map(e=>{let n=t=>{this[e](t)};return t.dom.addEventListener(e,n),{name:e,handler:n}})}destroy(){this.handlers.forEach(({name:t,handler:e})=>this.editorView.dom.removeEventListener(t,e))}update(t,e){null!=this.cursorPos&&e.doc!=t.state.doc&&(this.cursorPos>t.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(t){t!=this.cursorPos&&(this.cursorPos=t,null==t?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let t,e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,o=this.editorView.dom,r=o.getBoundingClientRect(),i=r.width/o.offsetWidth,s=r.height/o.offsetHeight;if(n){let n=e.nodeBefore,o=e.nodeAfter;if(n||o){let e=this.editorView.nodeDOM(this.cursorPos-(n?n.nodeSize:0));if(e){let r=e.getBoundingClientRect(),i=n?r.bottom:r.top;n&&o&&(i=(i+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let l=this.width/2*s;t={left:r.left,right:r.right,top:i-l,bottom:i+l}}}}if(!t){let e=this.editorView.coordsAtPos(this.cursorPos),n=this.width/2*i;t={left:e.left-n,right:e.left+n,top:e.top,bottom:e.bottom}}let l,a,c=this.editorView.dom.offsetParent;if(this.element||(this.element=c.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n),!c||c==document.body&&"static"==getComputedStyle(c).position)l=-pageXOffset,a=-pageYOffset;else{let t=c.getBoundingClientRect(),e=t.width/c.offsetWidth,n=t.height/c.offsetHeight;l=t.left-c.scrollLeft*e,a=t.top-c.scrollTop*n}this.element.style.left=(t.left-l)/i+"px",this.element.style.top=(t.top-a)/s+"px",this.element.style.width=(t.right-t.left)/i+"px",this.element.style.height=(t.bottom-t.top)/s+"px"}scheduleRemoval(t){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),t)}dragover(t){if(!this.editorView.editable)return;let e=this.editorView.posAtCoords({left:t.clientX,top:t.clientY}),n=e&&e.inside>=0&&this.editorView.state.doc.nodeAt(e.inside),o=n&&n.type.spec.disableDropCursor,r="function"==typeof o?o(this.editorView,e,t):o;if(e&&!r){let t=e.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let e=ee(this.editorView.state.doc,t,this.editorView.dragging.slice);null!=e&&(t=e)}this.setCursor(t),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(t){this.editorView.dom.contains(t.relatedTarget)||this.setCursor(null)}}class Vu extends be{constructor(t){super(t,t)}map(t,e){let n=t.resolve(e.map(this.head));return Vu.valid(n)?new Vu(n):be.near(n)}content(){return A.empty}eq(t){return t instanceof Vu&&t.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(t,e){if("number"!=typeof e.pos)throw new RangeError("Invalid input for GapCursor.fromJSON");return new Vu(t.resolve(e.pos))}getBookmark(){return new _u(this.anchor)}static valid(t){let e=t.parent;if(e.isTextblock||!function(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),o=t.node(e);if(0!=n)for(let t=o.child(n-1);;t=t.lastChild){if(0==t.childCount&&!t.inlineContent||t.isAtom||t.type.spec.isolating)return!0;if(t.inlineContent)return!1}else if(o.type.spec.isolating)return!0}return!0}(t)||!function(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),o=t.node(e);if(n!=o.childCount)for(let t=o.child(n);;t=t.firstChild){if(0==t.childCount&&!t.inlineContent||t.isAtom||t.type.spec.isolating)return!0;if(t.inlineContent)return!1}else if(o.type.spec.isolating)return!0}return!0}(t))return!1;let n=e.type.spec.allowGapCursor;if(null!=n)return n;let o=e.contentMatchAt(t.index()).defaultType;return o&&o.isTextblock}static findGapCursorFrom(t,e,n=!1){t:for(;;){if(!n&&Vu.valid(t))return t;let o=t.pos,r=null;for(let n=t.depth;;n--){let i=t.node(n);if(e>0?t.indexAfter(n)<i.childCount:t.index(n)>0){r=i.child(e>0?t.indexAfter(n):t.index(n)-1);break}if(0==n)return null;o+=e;let s=t.doc.resolve(o);if(Vu.valid(s))return s}for(;;){let i=e>0?r.firstChild:r.lastChild;if(!i){if(r.isAtom&&!r.isText&&!Ce.isSelectable(r)){t=t.doc.resolve(o+r.nodeSize*e),n=!1;continue t}break}r=i,o+=e;let s=t.doc.resolve(o);if(Vu.valid(s))return s}return null}}}Vu.prototype.visible=!1,Vu.findFrom=Vu.findGapCursorFrom,be.jsonID("gapcursor",Vu);class _u{constructor(t){this.pos=t}map(t){return new _u(t.map(this.pos))}resolve(t){let e=t.resolve(this.pos);return Vu.valid(e)?new Vu(e):be.near(e)}}const Fu=di({ArrowLeft:Wu("horiz",-1),ArrowRight:Wu("horiz",1),ArrowUp:Wu("vert",-1),ArrowDown:Wu("vert",1)});function Wu(t,e){const n="vert"==t?e>0?"down":"up":e>0?"right":"left";return function(t,o,r){let i=t.selection,s=e>0?i.$to:i.$from,l=i.empty;if(i instanceof xe){if(!r.endOfTextblock(n)||0==s.depth)return!1;l=!1,s=t.doc.resolve(e>0?s.after():s.before())}let a=Vu.findGapCursorFrom(s,e,l);return!!a&&(o&&o(t.tr.setSelection(new Vu(a))),!0)}}function qu(t,e,n){if(!t||!t.editable)return!1;let o=t.state.doc.resolve(e);if(!Vu.valid(o))return!1;let r=t.posAtCoords({left:n.clientX,top:n.clientY});return!(r&&r.inside>-1&&Ce.isSelectable(t.state.doc.nodeAt(r.inside))||(t.dispatch(t.state.tr.setSelection(new Vu(o))),0))}function Ku(t,e){if("insertCompositionText"!=e.inputType||!(t.state.selection instanceof Vu))return!1;let{$from:n}=t.state.selection,o=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!o)return!1;let r=k.empty;for(let t=o.length-1;t>=0;t--)r=k.from(o[t].createAndFill(null,r));let i=t.state.tr.replace(n.pos,n.pos,new A(r,0,0));return i.setSelection(xe.near(i.doc.resolve(n.pos+1))),t.dispatch(i),!1}function Ju(t){if(!(t.selection instanceof Vu))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",Cr.create(t.doc,[kr.widget(t.selection.head,e,{key:"gapcursor"})])}var Uu=200,Gu=function(){};Gu.prototype.append=function(t){return t.length?(t=Gu.from(t),!this.length&&t||t.length<Uu&&this.leafAppend(t)||this.length<Uu&&t.leafPrepend(this)||this.appendInner(t)):this},Gu.prototype.prepend=function(t){return t.length?Gu.from(t).append(this):this},Gu.prototype.appendInner=function(t){return new Xu(this,t)},Gu.prototype.slice=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=this.length),t>=e?Gu.empty:this.sliceInner(Math.max(0,t),Math.min(this.length,e))},Gu.prototype.get=function(t){if(!(t<0||t>=this.length))return this.getInner(t)},Gu.prototype.forEach=function(t,e,n){void 0===e&&(e=0),void 0===n&&(n=this.length),e<=n?this.forEachInner(t,e,n,0):this.forEachInvertedInner(t,e,n,0)},Gu.prototype.map=function(t,e,n){void 0===e&&(e=0),void 0===n&&(n=this.length);var o=[];return this.forEach(function(e,n){return o.push(t(e,n))},e,n),o},Gu.from=function(t){return t instanceof Gu?t:t&&t.length?new Yu(t):Gu.empty};var Yu=function(t){function e(e){t.call(this),this.values=e}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(t,n){return 0==t&&n==this.length?this:new e(this.values.slice(t,n))},e.prototype.getInner=function(t){return this.values[t]},e.prototype.forEachInner=function(t,e,n,o){for(var r=e;r<n;r++)if(!1===t(this.values[r],o+r))return!1},e.prototype.forEachInvertedInner=function(t,e,n,o){for(var r=e-1;r>=n;r--)if(!1===t(this.values[r],o+r))return!1},e.prototype.leafAppend=function(t){if(this.length+t.length<=Uu)return new e(this.values.concat(t.flatten()))},e.prototype.leafPrepend=function(t){if(this.length+t.length<=Uu)return new e(t.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e}(Gu);Gu.empty=new Yu([]);var Xu=function(t){function e(e,n){t.call(this),this.left=e,this.right=n,this.length=e.length+n.length,this.depth=Math.max(e.depth,n.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(t){return t<this.left.length?this.left.get(t):this.right.get(t-this.left.length)},e.prototype.forEachInner=function(t,e,n,o){var r=this.left.length;return!(e<r&&!1===this.left.forEachInner(t,e,Math.min(n,r),o))&&!(n>r&&!1===this.right.forEachInner(t,Math.max(e-r,0),Math.min(this.length,n)-r,o+r))&&void 0},e.prototype.forEachInvertedInner=function(t,e,n,o){var r=this.left.length;return!(e>r&&!1===this.right.forEachInvertedInner(t,e-r,Math.max(n,r)-r,o+r))&&!(n<r&&!1===this.left.forEachInvertedInner(t,Math.min(e,r),n,o))&&void 0},e.prototype.sliceInner=function(t,e){if(0==t&&e==this.length)return this;var n=this.left.length;return e<=n?this.left.slice(t,e):t>=n?this.right.slice(t-n,e-n):this.left.slice(t,n).append(this.right.slice(0,e-n))},e.prototype.leafAppend=function(t){var n=this.right.leafAppend(t);if(n)return new e(this.left,n)},e.prototype.leafPrepend=function(t){var n=this.left.leafPrepend(t);if(n)return new e(n,this.right)},e.prototype.appendInner=function(t){return this.left.depth>=Math.max(this.right.depth,t.depth)+1?new e(this.left,new e(this.right,t)):new e(this,t)},e}(Gu);const Qu=Gu;class Zu{constructor(t,e){this.items=t,this.eventCount=e}popEvent(t,e){if(0==this.eventCount)return null;let n,o,r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}e&&(n=this.remapping(r,this.items.length),o=n.maps.length);let i,s,l=t.tr,a=[],c=[];return this.items.forEach((t,e)=>{if(!t.step)return n||(n=this.remapping(r,e+1),o=n.maps.length),o--,void c.push(t);if(n){c.push(new tf(t.map));let e,r=t.step.map(n.slice(o));r&&l.maybeStep(r).doc&&(e=l.mapping.maps[l.mapping.maps.length-1],a.push(new tf(e,void 0,void 0,a.length+c.length))),o--,e&&n.appendMap(e,o)}else l.maybeStep(t.step);return t.selection?(i=n?t.selection.map(n.slice(o)):t.selection,s=new Zu(this.items.slice(0,r).append(c.reverse().concat(a)),this.eventCount-1),!1):void 0},this.items.length,0),{remaining:s,transform:l,selection:i}}addTransform(t,e,n,o){let r=[],i=this.eventCount,s=this.items,l=!o&&s.length?s.get(s.length-1):null;for(let n=0;n<t.steps.length;n++){let a,c=t.steps[n].invert(t.docs[n]),d=new tf(t.mapping.maps[n],c,e);(a=l&&l.merge(d))&&(d=a,n?r.pop():s=s.slice(0,s.length-1)),r.push(d),e&&(i++,e=void 0),o||(l=d)}let a=i-n.depth;return a>nf&&(s=function(t,e){let n;return t.forEach((t,o)=>{if(t.selection&&0==e--)return n=o,!1}),t.slice(n)}(s,a),i-=a),new Zu(s.append(r),i)}remapping(t,e){let n=new Lt;return this.items.forEach((e,o)=>{let r=null!=e.mirrorOffset&&o-e.mirrorOffset>=t?n.maps.length-e.mirrorOffset:void 0;n.appendMap(e.map,r)},t,e),n}addMaps(t){return 0==this.eventCount?this:new Zu(this.items.append(t.map(t=>new tf(t))),this.eventCount)}rebased(t,e){if(!this.eventCount)return this;let n=[],o=Math.max(0,this.items.length-e),r=t.mapping,i=t.steps.length,s=this.eventCount;this.items.forEach(t=>{t.selection&&s--},o);let l=e;this.items.forEach(e=>{let o=r.getMirror(--l);if(null==o)return;i=Math.min(i,o);let a=r.maps[o];if(e.step){let i=t.steps[o].invert(t.docs[o]),c=e.selection&&e.selection.map(r.slice(l+1,o));c&&s++,n.push(new tf(a,i,c))}else n.push(new tf(a))},o);let a=[];for(let t=e;t<i;t++)a.push(new tf(r.maps[t]));let c=this.items.slice(0,o).append(a).append(n),d=new Zu(c,s);return d.emptyItemCount()>500&&(d=d.compress(this.items.length-n.length)),d}emptyItemCount(){let t=0;return this.items.forEach(e=>{e.step||t++}),t}compress(t=this.items.length){let e=this.remapping(0,t),n=e.maps.length,o=[],r=0;return this.items.forEach((i,s)=>{if(s>=t)o.push(i),i.selection&&r++;else if(i.step){let t=i.step.map(e.slice(n)),s=t&&t.getMap();if(n--,s&&e.appendMap(s,n),t){let l=i.selection&&i.selection.map(e.slice(n));l&&r++;let a,c=new tf(s.invert(),t,l),d=o.length-1;(a=o.length&&o[d].merge(c))?o[d]=a:o.push(c)}}else i.map&&n--},this.items.length,0),new Zu(Qu.from(o.reverse()),r)}}Zu.empty=new Zu(Qu.empty,0);class tf{constructor(t,e,n,o){this.map=t,this.step=e,this.selection=n,this.mirrorOffset=o}merge(t){if(this.step&&t.step&&!t.selection){let e=t.step.merge(this.step);if(e)return new tf(e.getMap().invert(),e,this.selection)}}}class ef{constructor(t,e,n,o,r){this.done=t,this.undone=e,this.prevRanges=n,this.prevTime=o,this.prevComposition=r}}const nf=20;function of(t){let e=[];for(let n=t.length-1;n>=0&&0==e.length;n--)t[n].forEach((t,n,o,r)=>e.push(o,r));return e}function rf(t,e){if(!t)return null;let n=[];for(let o=0;o<t.length;o+=2){let r=e.map(t[o],1),i=e.map(t[o+1],-1);r<=i&&n.push(r,i)}return n}let sf=!1,lf=null;function af(t){let e=t.plugins;if(lf!=e){sf=!1,lf=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){sf=!0;break}}return sf}const cf=new Be("history"),df=new Be("closeHistory");function hf(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new ze({key:cf,state:{init:()=>new ef(Zu.empty,Zu.empty,null,0,-1),apply:(e,n,o)=>function(t,e,n,o){let r,i=n.getMeta(cf);if(i)return i.historyState;n.getMeta(df)&&(t=new ef(t.done,t.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(0==n.steps.length)return t;if(s&&s.getMeta(cf))return s.getMeta(cf).redo?new ef(t.done.addTransform(n,void 0,o,af(e)),t.undone,of(n.mapping.maps),t.prevTime,t.prevComposition):new ef(t.done,t.undone.addTransform(n,void 0,o,af(e)),null,t.prevTime,t.prevComposition);if(!1===n.getMeta("addToHistory")||s&&!1===s.getMeta("addToHistory"))return(r=n.getMeta("rebased"))?new ef(t.done.rebased(n,r),t.undone.rebased(n,r),rf(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new ef(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),rf(t.prevRanges,n.mapping),t.prevTime,t.prevComposition);{let r=n.getMeta("composition"),i=0==t.prevTime||!s&&t.prevComposition!=r&&(t.prevTime<(n.time||0)-o.newGroupDelay||!function(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((t,o)=>{for(let r=0;r<e.length;r+=2)t<=e[r+1]&&o>=e[r]&&(n=!0)}),n}(n,t.prevRanges)),l=s?rf(t.prevRanges,n.mapping):of(n.mapping.maps);return new ef(t.done.addTransform(n,i?e.selection.getBookmark():void 0,o,af(e)),Zu.empty,l,n.time,null==r?t.prevComposition:r)}}(n,o,e,t)},config:t,props:{handleDOMEvents:{beforeinput(t,e){let n=e.inputType,o="historyUndo"==n?uf:"historyRedo"==n?ff:null;return!!o&&(e.preventDefault(),o(t.state,t.dispatch))}}}})}function pf(t,e){return(n,o)=>{let r=cf.getState(n);if(!r||0==(t?r.undone:r.done).eventCount)return!1;if(o){let i=function(t,e,n){let o=af(e),r=cf.get(e).spec.config,i=(n?t.undone:t.done).popEvent(e,o);if(!i)return null;let s=i.selection.resolve(i.transform.doc),l=(n?t.done:t.undone).addTransform(i.transform,e.selection.getBookmark(),r,o),a=new ef(n?l:i.remaining,n?i.remaining:l,null,0,-1);return i.transform.setSelection(s).setMeta(cf,{redo:n,historyState:a})}(r,n,t);i&&o(e?i.scrollIntoView():i)}return!0}}const uf=pf(!1,!0),ff=pf(!0,!0);pf(!1,!1),pf(!0,!1),qs.create({name:"characterCount",addOptions:()=>({limit:null,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(t=>""!==t).length}),addStorage:()=>({characters:()=>0,words:()=>0}),onBeforeCreate(){this.storage.characters=t=>{const e=(null==t?void 0:t.node)||this.editor.state.doc;if("textSize"===((null==t?void 0:t.mode)||this.options.mode)){const t=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(t)}return e.nodeSize},this.storage.words=t=>{const e=(null==t?void 0:t.node)||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new ze({key:new Be("characterCount"),appendTransaction:(e,n,o)=>{if(t)return;const r=this.options.limit;if(null==r||0===r)return void(t=!0);const i=this.storage.characters({node:o.doc});if(i>r){const e=0,n=i-r;console.warn(`[CharacterCount] Initial content exceeded limit of ${r} characters. Content was automatically trimmed.`);const s=o.tr.deleteRange(e,n);return t=!0,s}t=!0},filterTransaction:(t,e)=>{const n=this.options.limit;if(!t.docChanged||0===n||null==n)return!0;const o=this.storage.characters({node:e.doc}),r=this.storage.characters({node:t.doc});if(r<=n)return!0;if(o>n&&r>n&&r<=o)return!0;if(o>n&&r>n&&r>o)return!1;if(!t.getMeta("paste"))return!1;const i=t.selection.$head.pos,s=i-(r-n),l=i;return t.deleteRange(s,l),!(this.storage.characters({node:t.doc})>n)}})]}});var mf=qs.create({name:"dropCursor",addOptions:()=>({color:"currentColor",width:1,class:void 0}),addProseMirrorPlugins(){return[Hu(this.options)]}}),gf=(qs.create({name:"focus",addOptions:()=>({className:"has-focus",mode:"all"}),addProseMirrorPlugins(){return[new ze({key:new Be("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:o}=this.editor,{anchor:r}=e,i=[];if(!n||!o)return Cr.create(t,[]);let s=0;"deepest"===this.options.mode&&t.descendants((t,e)=>{if(!t.isText)return r>=e&&r<=e+t.nodeSize-1&&void(s+=1)});let l=0;return t.descendants((t,e)=>!t.isText&&(r>=e&&r<=e+t.nodeSize-1&&(l+=1,"deepest"===this.options.mode&&s-l>0||"shallowest"===this.options.mode&&l>1?"deepest"===this.options.mode:void i.push(kr.node(e,e+t.nodeSize,{class:this.options.className}))))),Cr.create(t,i)}}})]}}),qs.create({name:"gapCursor",addProseMirrorPlugins:()=>[new ze({props:{decorations:Ju,createSelectionBetween:(t,e,n)=>e.pos==n.pos&&Vu.valid(n)?new Vu(n):null,handleClick:qu,handleKeyDown:Fu,handleDOMEvents:{beforeinput:Ku}}})],extendNodeSchema(t){var e;return{allowGapCursor:null!=(e=ts(Yi(t,"allowGapCursor",{name:t.name,options:t.options,storage:t.storage})))?e:null}}})),yf=qs.create({name:"placeholder",addOptions:()=>({emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}),addProseMirrorPlugins(){return[new ze({key:new Be("placeholder"),props:{decorations:({doc:t,selection:e})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:o}=e,r=[];if(!n)return null;const i=this.editor.isEmpty;return t.descendants((t,e)=>{const n=o>=e&&o<=e+t.nodeSize,s=!t.isLeaf&&Ns(t);if((n||!this.options.showOnlyCurrent)&&s){const o=[this.options.emptyNodeClass];i&&o.push(this.options.emptyEditorClass);const s=kr.node(e,e+t.nodeSize,{class:o.join(" "),"data-placeholder":"function"==typeof this.options.placeholder?this.options.placeholder({editor:this.editor,node:t,pos:e,hasAnchor:n}):this.options.placeholder});r.push(s)}return this.options.includeChildren}),Cr.create(t,r)}}})]}});function bf({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||(null==e?void 0:e.type)===t}qs.create({name:"selection",addOptions:()=>({className:"selection"}),addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new ze({key:new Be("selection"),props:{decorations:n=>n.selection.empty||t.isFocused||!t.isEditable||Ds(n.selection)||t.view.dragging?null:Cr.create(n.doc,[kr.inline(n.selection.from,n.selection.to,{class:e.className})])}})]}});var vf,wf,kf=qs.create({name:"trailingNode",addOptions:()=>({node:"paragraph",notAfter:[]}),addProseMirrorPlugins(){const t=new Be(this.name),e=Object.entries(this.editor.schema.nodes).map(([,t])=>t).filter(t=>(this.options.notAfter||[]).concat(this.options.node).includes(t.name));return[new ze({key:t,appendTransaction:(e,n,o)=>{const{doc:r,tr:i,schema:s}=o,l=t.getState(o),a=r.content.size,c=s.nodes[this.options.node];if(l)return i.insert(a,c.create())},state:{init:(t,n)=>!bf({node:n.tr.doc.lastChild,types:e}),apply:(t,n)=>t.docChanged?!bf({node:t.doc.lastChild,types:e}):n}})]}}),xf=qs.create({name:"undoRedo",addOptions:()=>({depth:100,newGroupDelay:500}),addCommands:()=>({undo:()=>({state:t,dispatch:e})=>uf(t,e),redo:()=>({state:t,dispatch:e})=>ff(t,e)}),addProseMirrorPlugins(){return[hf(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),Mf=qs.create({name:"starterKit",addExtensions(){var t,e,n,o;const r=[];return!1!==this.options.bold&&r.push(Qd.configure(this.options.bold)),!1!==this.options.blockquote&&r.push(Jd.configure(this.options.blockquote)),!1!==this.options.bulletList&&r.push(fu.configure(this.options.bulletList)),!1!==this.options.code&&r.push(eh.configure(this.options.code)),!1!==this.options.codeBlock&&r.push(rh.configure(this.options.codeBlock)),!1!==this.options.document&&r.push(ih.configure(this.options.document)),!1!==this.options.dropcursor&&r.push(mf.configure(this.options.dropcursor)),!1!==this.options.gapcursor&&r.push(gf.configure(this.options.gapcursor)),!1!==this.options.hardBreak&&r.push(sh.configure(this.options.hardBreak)),!1!==this.options.heading&&r.push(lh.configure(this.options.heading)),!1!==this.options.undoRedo&&r.push(xf.configure(this.options.undoRedo)),!1!==this.options.horizontalRule&&r.push(ah.configure(this.options.horizontalRule)),!1!==this.options.italic&&r.push(uh.configure(this.options.italic)),!1!==this.options.listItem&&r.push(mu.configure(this.options.listItem)),!1!==this.options.listKeymap&&r.push(Tu.configure(null==(t=this.options)?void 0:t.listKeymap)),!1!==this.options.link&&r.push(du.configure(null==(e=this.options)?void 0:e.link)),!1!==this.options.orderedList&&r.push(Ou.configure(this.options.orderedList)),!1!==this.options.paragraph&&r.push(Ru.configure(this.options.paragraph)),!1!==this.options.strike&&r.push(Pu.configure(this.options.strike)),!1!==this.options.text&&r.push(zu.configure(this.options.text)),!1!==this.options.underline&&r.push($u.configure(null==(n=this.options)?void 0:n.underline)),!1!==this.options.trailingNode&&r.push(kf.configure(null==(o=this.options)?void 0:o.trailingNode)),r}}),Cf=qs.create({name:"textAlign",addOptions:()=>({types:[],alignments:["left","center","right","justify"],defaultAlignment:null}),addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{const e=t.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:t=>t.textAlign?{style:`text-align: ${t.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>!!this.options.alignments.includes(t)&&this.options.types.map(n=>e.updateAttributes(n,{textAlign:t})).every(t=>t),unsetTextAlign:()=>({commands:t})=>this.options.types.map(e=>t.resetAttributes(e,"textAlign")).every(t=>t),toggleTextAlign:t=>({editor:e,commands:n})=>!!this.options.alignments.includes(t)&&(e.isActive({textAlign:t})?n.unsetTextAlign():n.setTextAlign(t))}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),Sf=Bs.create({name:"superscript",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"sup"},{style:"vertical-align",getAttrs:t=>"super"===t&&null}],renderHTML({HTMLAttributes:t}){return["sup",rs(this.options.HTMLAttributes,t),0]},addCommands(){return{setSuperscript:()=>({commands:t})=>t.setMark(this.name),toggleSuperscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSuperscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}}),Tf=Bs.create({name:"subscript",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"sub"},{style:"vertical-align",getAttrs:t=>"sub"===t&&null}],renderHTML({HTMLAttributes:t}){return["sub",rs(this.options.HTMLAttributes,t),0]},addCommands(){return{setSubscript:()=>({commands:t})=>t.setMark(this.name),toggleSubscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSubscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}});if("undefined"!=typeof WeakMap){let t=new WeakMap;vf=e=>t.get(e),wf=(e,n)=>(t.set(e,n),n)}else{const t=[],e=10;let n=0;vf=e=>{for(let n=0;n<t.length;n+=2)if(t[n]==e)return t[n+1]},wf=(o,r)=>(n==e&&(n=0),t[n++]=o,t[n++]=r)}var Af=class{constructor(t,e,n,o){this.width=t,this.height=e,this.map=n,this.problems=o}findCell(t){for(let e=0;e<this.map.length;e++){const n=this.map[e];if(n!=t)continue;const o=e%this.width,r=e/this.width|0;let i=o+1,s=r+1;for(let t=1;i<this.width&&this.map[e+t]==n;t++)i++;for(let t=1;s<this.height&&this.map[e+this.width*t]==n;t++)s++;return{left:o,top:r,right:i,bottom:s}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let e=0;e<this.map.length;e++)if(this.map[e]==t)return e%this.width;throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,e,n){const{left:o,right:r,top:i,bottom:s}=this.findCell(t);return"horiz"==e?(n<0?0==o:r==this.width)?null:this.map[i*this.width+(n<0?o-1:r)]:(n<0?0==i:s==this.height)?null:this.map[o+this.width*(n<0?i-1:s)]}rectBetween(t,e){const{left:n,right:o,top:r,bottom:i}=this.findCell(t),{left:s,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(n,s),top:Math.min(r,a),right:Math.max(o,l),bottom:Math.max(i,c)}}cellsInRect(t){const e=[],n={};for(let o=t.top;o<t.bottom;o++)for(let r=t.left;r<t.right;r++){const i=o*this.width+r,s=this.map[i];n[s]||(n[s]=!0,r==t.left&&r&&this.map[i-1]==s||o==t.top&&o&&this.map[i-this.width]==s||e.push(s))}return e}positionAt(t,e,n){for(let o=0,r=0;;o++){const i=r+n.child(o).nodeSize;if(o==t){let n=e+t*this.width;const o=(t+1)*this.width;for(;n<o&&this.map[n]<r;)n++;return n==o?i-1:this.map[n]}r=i}}static get(t){return vf(t)||wf(t,function(t){if("table"!=t.type.spec.tableRole)throw new RangeError("Not a table node: "+t.type.name);const e=function(t){let e=-1,n=!1;for(let o=0;o<t.childCount;o++){const r=t.child(o);let i=0;if(n)for(let e=0;e<o;e++){const n=t.child(e);for(let t=0;t<n.childCount;t++){const r=n.child(t);e+r.attrs.rowspan>o&&(i+=r.attrs.colspan)}}for(let t=0;t<r.childCount;t++){const e=r.child(t);i+=e.attrs.colspan,e.attrs.rowspan>1&&(n=!0)}-1==e?e=i:e!=i&&(e=Math.max(e,i))}return e}(t),n=t.childCount,o=[];let r=0,i=null;const s=[];for(let t=0,r=e*n;t<r;t++)o[t]=0;for(let l=0,a=0;l<n;l++){const c=t.child(l);a++;for(let t=0;;t++){for(;r<o.length&&0!=o[r];)r++;if(t==c.childCount)break;const d=c.child(t),{colspan:h,rowspan:p,colwidth:u}=d.attrs;for(let t=0;t<p;t++){if(t+l>=n){(i||(i=[])).push({type:"overlong_rowspan",pos:a,n:p-t});break}const c=r+t*e;for(let t=0;t<h;t++){0==o[c+t]?o[c+t]=a:(i||(i=[])).push({type:"collision",row:l,pos:a,n:h-t});const n=u&&u[t];if(n){const o=(c+t)%e*2,r=s[o];null==r||r!=n&&1==s[o+1]?(s[o]=n,s[o+1]=1):r==n&&s[o+1]++}}}r+=h,a+=d.nodeSize}const d=(l+1)*e;let h=0;for(;r<d;)0==o[r++]&&h++;h&&(i||(i=[])).push({type:"missing",row:l,n:h}),a++}0!==e&&0!==n||(i||(i=[])).push({type:"zero_sized"});const l=new Af(e,n,o,i);let a=!1;for(let t=0;!a&&t<s.length;t+=2)null!=s[t]&&s[t+1]<n&&(a=!0);return a&&function(t,e,n){t.problems||(t.problems=[]);const o={};for(let r=0;r<t.map.length;r++){const i=t.map[r];if(o[i])continue;o[i]=!0;const s=n.nodeAt(i);if(!s)throw new RangeError(`No cell with offset ${i} found`);let l=null;const a=s.attrs;for(let n=0;n<a.colspan;n++){const o=e[(r+n)%t.width*2];null==o||a.colwidth&&a.colwidth[n]==o||((l||(l=Ef(a)))[n]=o)}l&&t.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}(l,s,t),l}(t))}};function Ef(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function Of(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const n in t.nodes){const o=t.nodes[n],r=o.spec.tableRole;r&&(e[r]=o)}}return e}var Nf=new Be("selectingCells");function Df(t){for(let e=t.depth-1;e>0;e--)if("row"==t.node(e).type.spec.tableRole)return t.node(0).resolve(t.before(e+1));return null}function Lf(t){const e=t.selection.$head;for(let t=e.depth;t>0;t--)if("row"==e.node(t).type.spec.tableRole)return!0;return!1}function Rf(t){const e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&"cell"==e.node.type.spec.tableRole)return e.$anchor;const n=Df(e.$head)||function(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){const o=e.type.spec.tableRole;if("cell"==o||"header_cell"==o)return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){const o=e.type.spec.tableRole;if("cell"==o||"header_cell"==o)return t.doc.resolve(n-e.nodeSize)}}(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function jf(t){return"row"==t.parent.type.spec.tableRole&&!!t.nodeAfter}function If(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function Pf(t,e,n){const o=t.node(-1),r=Af.get(o),i=t.start(-1),s=r.nextCell(t.pos-i,e,n);return null==s?null:t.node(0).resolve(i+s)}function zf(t,e,n=1){const o={...t,colspan:t.colspan-n};return o.colwidth&&(o.colwidth=o.colwidth.slice(),o.colwidth.splice(e,n),o.colwidth.some(t=>t>0)||(o.colwidth=null)),o}function $f(t,e,n=1){const o={...t,colspan:t.colspan+n};if(o.colwidth){o.colwidth=o.colwidth.slice();for(let t=0;t<n;t++)o.colwidth.splice(e,0,0)}return o}var Hf=class t extends be{constructor(t,e=t){const n=t.node(-1),o=Af.get(n),r=t.start(-1),i=o.rectBetween(t.pos-r,e.pos-r),s=t.node(0),l=o.cellsInRect(i).filter(t=>t!=e.pos-r);l.unshift(e.pos-r);const a=l.map(t=>{const e=n.nodeAt(t);if(!e)throw RangeError(`No cell with offset ${t} found`);const o=r+t+1;return new ve(s.resolve(o),s.resolve(o+e.content.size))});super(a[0].$from,a[0].$to,a),this.$anchorCell=t,this.$headCell=e}map(e,n){const o=e.resolve(n.map(this.$anchorCell.pos)),r=e.resolve(n.map(this.$headCell.pos));if(jf(o)&&jf(r)&&If(o,r)){const e=this.$anchorCell.node(-1)!=o.node(-1);return e&&this.isRowSelection()?t.rowSelection(o,r):e&&this.isColSelection()?t.colSelection(o,r):new t(o,r)}return xe.between(o,r)}content(){const t=this.$anchorCell.node(-1),e=Af.get(t),n=this.$anchorCell.start(-1),o=e.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),r={},i=[];for(let n=o.top;n<o.bottom;n++){const s=[];for(let i=n*e.width+o.left,l=o.left;l<o.right;l++,i++){const n=e.map[i];if(r[n])continue;r[n]=!0;const l=e.findCell(n);let a=t.nodeAt(n);if(!a)throw RangeError(`No cell with offset ${n} found`);const c=o.left-l.left,d=l.right-o.right;if(c>0||d>0){let t=a.attrs;if(c>0&&(t=zf(t,0,c)),d>0&&(t=zf(t,t.colspan-d,d)),l.left<o.left){if(a=a.type.createAndFill(t),!a)throw RangeError(`Could not create cell with attrs ${JSON.stringify(t)}`)}else a=a.type.create(t,a.content)}if(l.top<o.top||l.bottom>o.bottom){const t={...a.attrs,rowspan:Math.min(l.bottom,o.bottom)-Math.max(l.top,o.top)};a=l.top<o.top?a.type.createAndFill(t):a.type.create(t,a.content)}s.push(a)}i.push(t.child(n).copy(k.from(s)))}const s=this.isColSelection()&&this.isRowSelection()?t:i;return new A(k.from(s),1,1)}replace(t,e=A.empty){const n=t.steps.length,o=this.ranges;for(let r=0;r<o.length;r++){const{$from:i,$to:s}=o[r],l=t.mapping.slice(n);t.replace(l.map(i.pos),l.map(s.pos),r?A.empty:e)}const r=be.findFrom(t.doc.resolve(t.mapping.slice(n).map(this.to)),-1);r&&t.setSelection(r)}replaceWith(t,e){this.replace(t,new A(k.from(e),0,0))}forEachCell(t){const e=this.$anchorCell.node(-1),n=Af.get(e),o=this.$anchorCell.start(-1),r=n.cellsInRect(n.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o));for(let n=0;n<r.length;n++)t(e.nodeAt(r[n]),o+r[n])}isColSelection(){const t=this.$anchorCell.index(-1),e=this.$headCell.index(-1);if(Math.min(t,e)>0)return!1;const n=t+this.$anchorCell.nodeAfter.attrs.rowspan,o=e+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,o)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const o=e.node(-1),r=Af.get(o),i=e.start(-1),s=r.findCell(e.pos-i),l=r.findCell(n.pos-i),a=e.node(0);return s.top<=l.top?(s.top>0&&(e=a.resolve(i+r.map[s.left])),l.bottom<r.height&&(n=a.resolve(i+r.map[r.width*(r.height-1)+l.right-1]))):(l.top>0&&(n=a.resolve(i+r.map[l.left])),s.bottom<r.height&&(e=a.resolve(i+r.map[r.width*(r.height-1)+s.right-1]))),new t(e,n)}isRowSelection(){const t=this.$anchorCell.node(-1),e=Af.get(t),n=this.$anchorCell.start(-1),o=e.colCount(this.$anchorCell.pos-n),r=e.colCount(this.$headCell.pos-n);if(Math.min(o,r)>0)return!1;const i=o+this.$anchorCell.nodeAfter.attrs.colspan,s=r+this.$headCell.nodeAfter.attrs.colspan;return Math.max(i,s)==e.width}eq(e){return e instanceof t&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const o=e.node(-1),r=Af.get(o),i=e.start(-1),s=r.findCell(e.pos-i),l=r.findCell(n.pos-i),a=e.node(0);return s.left<=l.left?(s.left>0&&(e=a.resolve(i+r.map[s.top*r.width])),l.right<r.width&&(n=a.resolve(i+r.map[r.width*(l.top+1)-1]))):(l.left>0&&(n=a.resolve(i+r.map[l.top*r.width])),s.right<r.width&&(e=a.resolve(i+r.map[r.width*(s.top+1)-1]))),new t(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new t(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,o=n){return new t(e.resolve(n),e.resolve(o))}getBookmark(){return new Bf(this.$anchorCell.pos,this.$headCell.pos)}};Hf.prototype.visible=!1,be.jsonID("cell",Hf);var Bf=class t{constructor(t,e){this.anchor=t,this.head=e}map(e){return new t(e.map(this.anchor),e.map(this.head))}resolve(t){const e=t.resolve(this.anchor),n=t.resolve(this.head);return"row"==e.parent.type.spec.tableRole&&"row"==n.parent.type.spec.tableRole&&e.index()<e.parent.childCount&&n.index()<n.parent.childCount&&If(e,n)?new Hf(e,n):be.near(n,1)}};function Vf(t){if(!(t.selection instanceof Hf))return null;const e=[];return t.selection.forEachCell((t,n)=>{e.push(kr.node(n,n+t.nodeSize,{class:"selectedCell"}))}),Cr.create(t.doc,e)}var _f=new Be("fix-tables");function Ff(t,e,n,o){const r=t.childCount,i=e.childCount;t:for(let s=0,l=0;s<i;s++){const i=e.child(s);for(let e=l,o=Math.min(r,s+3);e<o;e++)if(t.child(e)==i){l=e+1,n+=i.nodeSize;continue t}o(i,n),l<r&&t.child(l).sameMarkup(i)?Ff(t.child(l),i,n+1,o):i.nodesBetween(0,i.content.size,o,n+1),n+=i.nodeSize}}function Wf(t,e){let n;const o=(e,o)=>{"table"==e.type.spec.tableRole&&(n=function(t,e,n,o){const r=Af.get(e);if(!r.problems)return o;o||(o=t.tr);const i=[];for(let t=0;t<r.height;t++)i.push(0);for(let t=0;t<r.problems.length;t++){const s=r.problems[t];if("collision"==s.type){const t=e.nodeAt(s.pos);if(!t)continue;const r=t.attrs;for(let t=0;t<r.rowspan;t++)i[s.row+t]+=s.n;o.setNodeMarkup(o.mapping.map(n+1+s.pos),null,zf(r,r.colspan-s.n,s.n))}else if("missing"==s.type)i[s.row]+=s.n;else if("overlong_rowspan"==s.type){const t=e.nodeAt(s.pos);if(!t)continue;o.setNodeMarkup(o.mapping.map(n+1+s.pos),null,{...t.attrs,rowspan:t.attrs.rowspan-s.n})}else if("colwidth mismatch"==s.type){const t=e.nodeAt(s.pos);if(!t)continue;o.setNodeMarkup(o.mapping.map(n+1+s.pos),null,{...t.attrs,colwidth:s.colwidth})}else if("zero_sized"==s.type){const t=o.mapping.map(n);o.delete(t,t+e.nodeSize)}}let s,l;for(let t=0;t<i.length;t++)i[t]&&(null==s&&(s=t),l=t);for(let a=0,c=n+1;a<r.height;a++){const n=e.child(a),r=c+n.nodeSize,d=i[a];if(d>0){let e="cell";n.firstChild&&(e=n.firstChild.type.spec.tableRole);const i=[];for(let n=0;n<d;n++){const n=Of(t.schema)[e].createAndFill();n&&i.push(n)}const h=0!=a&&s!=a-1||l!=a?r-1:c+1;o.insert(o.mapping.map(h),i)}c=r}return o.setMeta(_f,{fixTables:!0})}(t,e,o,n))};return e?e.doc!=t.doc&&Ff(e.doc,t.doc,0,o):t.doc.descendants(o),n}function qf(t){const e=t.selection,n=Rf(t),o=n.node(-1),r=n.start(-1),i=Af.get(o);return{...e instanceof Hf?i.rectBetween(e.$anchorCell.pos-r,e.$headCell.pos-r):i.findCell(n.pos-r),tableStart:r,map:i,table:o}}function Kf(t,{map:e,tableStart:n,table:o},r){let i=r>0?-1:0;(function(t,e,n){const o=Of(e.type.schema).header_cell;for(let r=0;r<t.height;r++)if(e.nodeAt(t.map[n+r*t.width]).type!=o)return!1;return!0})(e,o,r+i)&&(i=0==r||r==e.width?null:0);for(let s=0;s<e.height;s++){const l=s*e.width+r;if(r>0&&r<e.width&&e.map[l-1]==e.map[l]){const i=e.map[l],a=o.nodeAt(i);t.setNodeMarkup(t.mapping.map(n+i),null,$f(a.attrs,r-e.colCount(i))),s+=a.attrs.rowspan-1}else{const a=null==i?Of(o.type.schema).cell:o.nodeAt(e.map[l+i]).type,c=e.positionAt(s,r,o);t.insert(t.mapping.map(n+c),a.createAndFill())}}return t}function Jf(t,{map:e,table:n,tableStart:o},r){const i=t.mapping.maps.length;for(let s=0;s<e.height;){const l=s*e.width+r,a=e.map[l],c=n.nodeAt(a),d=c.attrs;if(r>0&&e.map[l-1]==a||r<e.width-1&&e.map[l+1]==a)t.setNodeMarkup(t.mapping.slice(i).map(o+a),null,zf(d,r-e.colCount(a)));else{const e=t.mapping.slice(i).map(o+a);t.delete(e,e+c.nodeSize)}s+=d.rowspan}}function Uf(t,{map:e,tableStart:n,table:o},r){var i;let s=n;for(let t=0;t<r;t++)s+=o.child(t).nodeSize;const l=[];let a=r>0?-1:0;(function(t,e,n){var o;const r=Of(e.type.schema).header_cell;for(let i=0;i<t.width;i++)if((null==(o=e.nodeAt(t.map[i+n*t.width]))?void 0:o.type)!=r)return!1;return!0})(e,o,r+a)&&(a=0==r||r==e.height?null:0);for(let s=0,c=e.width*r;s<e.width;s++,c++)if(r>0&&r<e.height&&e.map[c]==e.map[c-e.width]){const r=e.map[c],i=o.nodeAt(r).attrs;t.setNodeMarkup(n+r,null,{...i,rowspan:i.rowspan+1}),s+=i.colspan-1}else{const t=null==a?Of(o.type.schema).cell:null==(i=o.nodeAt(e.map[c+a*e.width]))?void 0:i.type,n=null==t?void 0:t.createAndFill();n&&l.push(n)}return t.insert(s,Of(o.type.schema).row.create(null,l)),t}function Gf(t,{map:e,table:n,tableStart:o},r){let i=0;for(let t=0;t<r;t++)i+=n.child(t).nodeSize;const s=i+n.child(r).nodeSize,l=t.mapping.maps.length;t.delete(i+o,s+o);const a=new Set;for(let i=0,s=r*e.width;i<e.width;i++,s++){const c=e.map[s];if(!a.has(c))if(a.add(c),r>0&&c==e.map[s-e.width]){const e=n.nodeAt(c).attrs;t.setNodeMarkup(t.mapping.slice(l).map(c+o),null,{...e,rowspan:e.rowspan-1}),i+=e.colspan-1}else if(r<e.height&&c==e.map[s+e.width]){const s=n.nodeAt(c),a=s.attrs,d=s.type.create({...a,rowspan:s.attrs.rowspan-1},s.content),h=e.positionAt(r+1,i,n);t.insert(t.mapping.slice(l).map(o+h),d),i+=a.colspan-1}}}function Yf(t){const e=t.content;return 1==e.childCount&&e.child(0).isTextblock&&0==e.child(0).childCount}function Xf(t,e){const n=t.selection;if(!(n instanceof Hf)||n.$anchorCell.pos==n.$headCell.pos)return!1;const o=qf(t),{map:r}=o;if(function({width:t,height:e,map:n},o){let r=o.top*t+o.left,i=r,s=(o.bottom-1)*t+o.left,l=r+(o.right-o.left-1);for(let e=o.top;e<o.bottom;e++){if(o.left>0&&n[i]==n[i-1]||o.right<t&&n[l]==n[l+1])return!0;i+=t,l+=t}for(let i=o.left;i<o.right;i++){if(o.top>0&&n[r]==n[r-t]||o.bottom<e&&n[s]==n[s+t])return!0;r++,s++}return!1}(r,o))return!1;if(e){const n=t.tr,i={};let s,l,a=k.empty;for(let t=o.top;t<o.bottom;t++)for(let e=o.left;e<o.right;e++){const c=r.map[t*r.width+e],d=o.table.nodeAt(c);if(!i[c]&&d)if(i[c]=!0,null==s)s=c,l=d;else{Yf(d)||(a=a.append(d.content));const t=n.mapping.map(c+o.tableStart);n.delete(t,t+d.nodeSize)}}if(null==s||null==l)return!0;if(n.setNodeMarkup(s+o.tableStart,null,{...$f(l.attrs,l.attrs.colspan,o.right-o.left-l.attrs.colspan),rowspan:o.bottom-o.top}),a.size){const t=s+1+l.content.size,e=Yf(l)?s+1:t;n.replaceWith(e+o.tableStart,t+o.tableStart,a)}n.setSelection(new Hf(n.doc.resolve(s+o.tableStart))),e(n)}return!0}function Qf(t,e){const n=Of(t.schema);return(o=({node:t})=>n[t.type.spec.tableRole],(t,e)=>{var n;const r=t.selection;let i,s;if(r instanceof Hf){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;i=r.$anchorCell.nodeAfter,s=r.$anchorCell.pos}else{if(i=function(t){for(let e=t.depth;e>0;e--){const n=t.node(e).type.spec.tableRole;if("cell"===n||"header_cell"===n)return t.node(e)}return null}(r.$from),!i)return!1;s=null==(n=Df(r.$from))?void 0:n.pos}if(null==i||null==s)return!1;if(1==i.attrs.colspan&&1==i.attrs.rowspan)return!1;if(e){let n=i.attrs;const l=[],a=n.colwidth;n.rowspan>1&&(n={...n,rowspan:1}),n.colspan>1&&(n={...n,colspan:1});const c=qf(t),d=t.tr;for(let t=0;t<c.right-c.left;t++)l.push(a?{...n,colwidth:a&&a[t]?[a[t]]:null}:n);let h;for(let t=c.top;t<c.bottom;t++){let e=c.map.positionAt(t,c.left,c.table);t==c.top&&(e+=i.nodeSize);for(let n=c.left,r=0;n<c.right;n++,r++)n==c.left&&t==c.top||d.insert(h=d.mapping.map(e+c.tableStart,1),o({node:i,row:t,col:n}).createAndFill(l[r]))}d.setNodeMarkup(s,o({node:i,row:c.top,col:c.left}),l[0]),r instanceof Hf&&d.setSelection(new Hf(d.doc.resolve(r.$anchorCell.pos),h?d.doc.resolve(h):void 0)),e(d)}return!0})(t,e);var o}function Zf(t,e,n){const o=e.map.cellsInRect({left:0,top:0,right:"row"==t?e.map.width:1,bottom:"column"==t?e.map.height:1});for(let t=0;t<o.length;t++){const r=e.table.nodeAt(o[t]);if(r&&r.type!==n.header_cell)return!1}return!0}function tm(t,e){return(e=e||{useDeprecatedLogic:!1}).useDeprecatedLogic?function(t){return function(e,n){if(!Lf(e))return!1;if(n){const o=Of(e.schema),r=qf(e),i=e.tr,s=r.map.cellsInRect("column"==t?{left:r.left,top:0,right:r.right,bottom:r.map.height}:"row"==t?{left:0,top:r.top,right:r.map.width,bottom:r.bottom}:r),l=s.map(t=>r.table.nodeAt(t));for(let t=0;t<s.length;t++)l[t].type==o.header_cell&&i.setNodeMarkup(r.tableStart+s[t],o.cell,l[t].attrs);if(0==i.steps.length)for(let t=0;t<s.length;t++)i.setNodeMarkup(r.tableStart+s[t],o.header_cell,l[t].attrs);n(i)}return!0}}(t):function(e,n){if(!Lf(e))return!1;if(n){const o=Of(e.schema),r=qf(e),i=e.tr,s=Zf("row",r,o),l=Zf("column",r,o),a=("column"===t?s:"row"===t&&l)?1:0,c="column"==t?{left:0,top:a,right:1,bottom:r.map.height}:"row"==t?{left:a,top:0,right:r.map.width,bottom:1}:r,d="column"==t?l?o.cell:o.header_cell:"row"==t?s?o.cell:o.header_cell:o.cell;r.map.cellsInRect(c).forEach(t=>{const e=t+r.tableStart,n=i.doc.nodeAt(e);n&&i.setNodeMarkup(e,d,n.attrs)}),n(i)}return!0}}tm("row",{useDeprecatedLogic:!0}),tm("column",{useDeprecatedLogic:!0});var em=tm("cell",{useDeprecatedLogic:!0});function nm(t){return function(e,n){if(!Lf(e))return!1;const o=function(t,e){if(e<0){const e=t.nodeBefore;if(e)return t.pos-e.nodeSize;for(let e=t.index(-1)-1,n=t.before();e>=0;e--){const o=t.node(-1).child(e),r=o.lastChild;if(r)return n-1-r.nodeSize;n-=o.nodeSize}}else{if(t.index()<t.parent.childCount-1)return t.pos+t.nodeAfter.nodeSize;const e=t.node(-1);for(let n=t.indexAfter(-1),o=t.after();n<e.childCount;n++){const t=e.child(n);if(t.childCount)return o+1;o+=t.nodeSize}}return null}(Rf(e),t);if(null==o)return!1;if(n){const t=e.doc.resolve(o);n(e.tr.setSelection(xe.between(t,(r=t,r.node(0).resolve(r.pos+r.nodeAfter.nodeSize)))).scrollIntoView())}var r;return!0}}function om(t,e){const n=t.selection;if(!(n instanceof Hf))return!1;if(e){const o=t.tr,r=Of(t.schema).cell.createAndFill().content;n.forEachCell((t,e)=>{t.content.eq(r)||o.replace(o.mapping.map(e+1),o.mapping.map(e+t.nodeSize-1),new A(r,0,0))}),o.docChanged&&e(o)}return!0}function rm(t,e){const n=t.createAndFill();return new ge(n).replace(0,n.content.size,e).doc}function im(t,e,n,o,r,i,s,l){if(0==s||s==e.height)return!1;let a=!1;for(let c=r;c<i;c++){const r=s*e.width+c,i=e.map[r];if(e.map[r-e.width]==i){a=!0;const r=n.nodeAt(i),{top:d,left:h}=e.findCell(i);t.setNodeMarkup(t.mapping.slice(l).map(i+o),null,{...r.attrs,rowspan:s-d}),t.insert(t.mapping.slice(l).map(e.positionAt(s,h,n)),r.type.createAndFill({...r.attrs,rowspan:d+r.attrs.rowspan-s})),c+=r.attrs.colspan-1}}return a}function sm(t,e,n,o,r,i,s,l){if(0==s||s==e.width)return!1;let a=!1;for(let c=r;c<i;c++){const r=c*e.width+s,i=e.map[r];if(e.map[r-1]==i){a=!0;const r=n.nodeAt(i),d=e.colCount(i),h=t.mapping.slice(l).map(i+o);t.setNodeMarkup(h,null,zf(r.attrs,s-d,r.attrs.colspan-(s-d))),t.insert(h+r.nodeSize,r.type.createAndFill(zf(r.attrs,0,s-d))),c+=r.attrs.rowspan-1}}return a}function lm(t,e,n,o,r){let i=n?t.doc.nodeAt(n-1):t.doc;if(!i)throw new Error("No table found");let s=Af.get(i);const{top:l,left:a}=o,c=a+r.width,d=l+r.height,h=t.tr;let p=0;function u(){if(i=n?h.doc.nodeAt(n-1):h.doc,!i)throw new Error("No table found");s=Af.get(i),p=h.mapping.maps.length}(function(t,e,n,o,r,i,s){const l=Of(t.doc.type.schema);let a,c;if(r>e.width)for(let i=0,d=0;i<e.height;i++){const h=n.child(i);d+=h.nodeSize;const p=[];let u;u=null==h.lastChild||h.lastChild.type==l.cell?a||(a=l.cell.createAndFill()):c||(c=l.header_cell.createAndFill());for(let t=e.width;t<r;t++)p.push(u);t.insert(t.mapping.slice(s).map(d-1+o),p)}if(i>e.height){const d=[];for(let t=0,o=(e.height-1)*e.width;t<Math.max(e.width,r);t++){const r=!(t>=e.width)&&n.nodeAt(e.map[o+t]).type==l.header_cell;d.push(r?c||(c=l.header_cell.createAndFill()):a||(a=l.cell.createAndFill()))}const h=l.row.create(null,k.from(d)),p=[];for(let t=e.height;t<i;t++)p.push(h);t.insert(t.mapping.slice(s).map(o+n.nodeSize-2),p)}return!(!a&&!c)})(h,s,i,n,c,d,p)&&u(),im(h,s,i,n,a,c,l,p)&&u(),im(h,s,i,n,a,c,d,p)&&u(),sm(h,s,i,n,l,d,a,p)&&u(),sm(h,s,i,n,l,d,c,p)&&u();for(let t=l;t<d;t++){const e=s.positionAt(t,a,i),o=s.positionAt(t,c,i);h.replace(h.mapping.slice(p).map(e+n),h.mapping.slice(p).map(o+n),new A(r.rows[t-l],0,0))}u(),h.setSelection(new Hf(h.doc.resolve(n+s.positionAt(l,a,i)),h.doc.resolve(n+s.positionAt(d-1,c-1,i)))),e(h)}var am=di({ArrowLeft:dm("horiz",-1),ArrowRight:dm("horiz",1),ArrowUp:dm("vert",-1),ArrowDown:dm("vert",1),"Shift-ArrowLeft":hm("horiz",-1),"Shift-ArrowRight":hm("horiz",1),"Shift-ArrowUp":hm("vert",-1),"Shift-ArrowDown":hm("vert",1),Backspace:om,"Mod-Backspace":om,Delete:om,"Mod-Delete":om});function cm(t,e,n){return!n.eq(t.selection)&&(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function dm(t,e){return(n,o,r)=>{if(!r)return!1;const i=n.selection;if(i instanceof Hf)return cm(n,o,be.near(i.$headCell,e));if("horiz"!=t&&!i.empty)return!1;const s=mm(r,t,e);if(null==s)return!1;if("horiz"==t)return cm(n,o,be.near(n.doc.resolve(i.head+e),e));{const r=n.doc.resolve(s),i=Pf(r,t,e);let l;return l=i?be.near(i,1):e<0?be.near(n.doc.resolve(r.before(-1)),-1):be.near(n.doc.resolve(r.after(-1)),1),cm(n,o,l)}}}function hm(t,e){return(n,o,r)=>{if(!r)return!1;const i=n.selection;let s;if(i instanceof Hf)s=i;else{const o=mm(r,t,e);if(null==o)return!1;s=new Hf(n.doc.resolve(o))}const l=Pf(s.$headCell,t,e);return!!l&&cm(n,o,new Hf(s.$anchorCell,l))}}function pm(t,e){const n=Df(t.state.doc.resolve(e));return!!n&&(t.dispatch(t.state.tr.setSelection(new Hf(n))),!0)}function um(t,e,n){if(!Lf(t.state))return!1;let o=function(t){if(!t.size)return null;let{content:e,openStart:n,openEnd:o}=t;for(;1==e.childCount&&(n>0&&o>0||"table"==e.child(0).type.spec.tableRole);)n--,o--,e=e.child(0).content;const r=e.child(0),i=r.type.spec.tableRole,s=r.type.schema,l=[];if("row"==i)for(let t=0;t<e.childCount;t++){let r=e.child(t).content;const i=t?0:Math.max(0,n-1),a=t<e.childCount-1?0:Math.max(0,o-1);(i||a)&&(r=rm(Of(s).row,new A(r,i,a)).content),l.push(r)}else{if("cell"!=i&&"header_cell"!=i)return null;l.push(n||o?rm(Of(s).row,new A(e,n,o)).content:e)}return function(t,e){const n=[];for(let t=0;t<e.length;t++){const o=e[t];for(let e=o.childCount-1;e>=0;e--){const{rowspan:r,colspan:i}=o.child(e).attrs;for(let e=t;e<t+r;e++)n[e]=(n[e]||0)+i}}let o=0;for(let t=0;t<n.length;t++)o=Math.max(o,n[t]);for(let r=0;r<n.length;r++)if(r>=e.length&&e.push(k.empty),n[r]<o){const i=Of(t).cell.createAndFill(),s=[];for(let t=n[r];t<o;t++)s.push(i);e[r]=e[r].append(k.from(s))}return{height:e.length,width:o,rows:e}}(s,l)}(n);const r=t.state.selection;if(r instanceof Hf){o||(o={width:1,height:1,rows:[k.from(rm(Of(t.state.schema).cell,n))]});const e=r.$anchorCell.node(-1),i=r.$anchorCell.start(-1),s=Af.get(e).rectBetween(r.$anchorCell.pos-i,r.$headCell.pos-i);return o=function({width:t,height:e,rows:n},o,r){if(t!=o){const e=[],r=[];for(let t=0;t<n.length;t++){const i=n[t],s=[];for(let n=e[t]||0,r=0;n<o;r++){let l=i.child(r%i.childCount);n+l.attrs.colspan>o&&(l=l.type.createChecked(zf(l.attrs,l.attrs.colspan,n+l.attrs.colspan-o),l.content)),s.push(l),n+=l.attrs.colspan;for(let n=1;n<l.attrs.rowspan;n++)e[t+n]=(e[t+n]||0)+l.attrs.colspan}r.push(k.from(s))}n=r,t=o}if(e!=r){const t=[];for(let o=0,i=0;o<r;o++,i++){const s=[],l=n[i%e];for(let t=0;t<l.childCount;t++){let e=l.child(t);o+e.attrs.rowspan>r&&(e=e.type.create({...e.attrs,rowspan:Math.max(1,r-e.attrs.rowspan)},e.content)),s.push(e)}t.push(k.from(s))}n=t,e=r}return{width:t,height:e,rows:n}}(o,s.right-s.left,s.bottom-s.top),lm(t.state,t.dispatch,i,s,o),!0}if(o){const e=Rf(t.state),n=e.start(-1);return lm(t.state,t.dispatch,n,Af.get(e.node(-1)).findCell(e.pos-n),o),!0}return!1}function fm(t,e){var n;if(e.ctrlKey||e.metaKey)return;const o=gm(t,e.target);let r;if(e.shiftKey&&t.state.selection instanceof Hf)i(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&o&&null!=(r=Df(t.state.selection.$anchor))&&(null==(n=ym(t,e))?void 0:n.pos)!=r.pos)i(r,e),e.preventDefault();else if(!o)return;function i(e,n){let o=ym(t,n);const r=null==Nf.getState(t.state);if(!o||!If(e,o)){if(!r)return;o=e}const i=new Hf(e,o);if(r||!t.state.selection.eq(i)){const n=t.state.tr.setSelection(i);r&&n.setMeta(Nf,e.pos),t.dispatch(n)}}function s(){t.root.removeEventListener("mouseup",s),t.root.removeEventListener("dragstart",s),t.root.removeEventListener("mousemove",l),null!=Nf.getState(t.state)&&t.dispatch(t.state.tr.setMeta(Nf,-1))}function l(n){const r=n,l=Nf.getState(t.state);let a;if(null!=l)a=t.state.doc.resolve(l);else if(gm(t,r.target)!=o&&(a=ym(t,e),!a))return s();a&&i(a,r)}t.root.addEventListener("mouseup",s),t.root.addEventListener("dragstart",s),t.root.addEventListener("mousemove",l)}function mm(t,e,n){if(!(t.state.selection instanceof xe))return null;const{$head:o}=t.state.selection;for(let r=o.depth-1;r>=0;r--){const i=o.node(r);if((n<0?o.index(r):o.indexAfter(r))!=(n<0?0:i.childCount))return null;if("cell"==i.type.spec.tableRole||"header_cell"==i.type.spec.tableRole){const i=o.before(r),s="vert"==e?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(s)?i:null}}return null}function gm(t,e){for(;e&&e!=t.dom;e=e.parentNode)if("TD"==e.nodeName||"TH"==e.nodeName)return e;return null}function ym(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});return n&&n?Df(t.state.doc.resolve(n.pos)):null}var bm=class{constructor(t,e){this.node=t,this.defaultCellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${e}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),vm(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type==this.node.type&&(this.node=t,vm(t,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(t){return"attributes"==t.type&&(t.target==this.table||this.colgroup.contains(t.target))}};function vm(t,e,n,o,r,i){var s;let l=0,a=!0,c=e.firstChild;const d=t.firstChild;if(d){for(let t=0,n=0;t<d.childCount;t++){const{colspan:s,colwidth:h}=d.child(t).attrs;for(let t=0;t<s;t++,n++){const s=r==n?i:h&&h[t],d=s?s+"px":"";if(l+=s||o,s||(a=!1),c)c.style.width!=d&&(c.style.width=d),c=c.nextSibling;else{const t=document.createElement("col");t.style.width=d,e.appendChild(t)}}}for(;c;){const t=c.nextSibling;null==(s=c.parentNode)||s.removeChild(c),c=t}a?(n.style.width=l+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=l+"px")}}var wm=new Be("tableColumnResizing");function km({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:o=bm,lastColumnResizable:r=!0}={}){const i=new ze({key:wm,state:{init(t,e){var r,s;const l=null==(s=null==(r=i.spec)?void 0:r.props)?void 0:s.nodeViews,a=Of(e.schema).table.name;return o&&l&&(l[a]=(t,e)=>new o(t,n,e)),new xm(-1,!1)},apply:(t,e)=>e.apply(t)},props:{attributes:t=>{const e=wm.getState(t);return e&&e.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(e,n)=>{!function(t,e,n,o){if(!t.editable)return;const r=wm.getState(t.state);if(r&&!r.dragging){const i=function(t){for(;t&&"TD"!=t.nodeName&&"TH"!=t.nodeName;)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}(e.target);let s=-1;if(i){const{left:o,right:r}=i.getBoundingClientRect();e.clientX-o<=n?s=Mm(t,e,"left",n):r-e.clientX<=n&&(s=Mm(t,e,"right",n))}if(s!=r.activeHandle){if(!o&&-1!==s){const e=t.state.doc.resolve(s),n=e.node(-1),o=Af.get(n),r=e.start(-1);if(o.colCount(e.pos-r)+e.nodeAfter.attrs.colspan-1==o.width-1)return}Sm(t,s)}}}(e,n,t,r)},mouseleave:t=>{!function(t){if(!t.editable)return;const e=wm.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&Sm(t,-1)}(t)},mousedown:(t,o)=>{!function(t,e,n,o){var r;if(!t.editable)return!1;const i=null!=(r=t.dom.ownerDocument.defaultView)?r:window,s=wm.getState(t.state);if(!s||-1==s.activeHandle||s.dragging)return!1;const l=t.state.doc.nodeAt(s.activeHandle),a=function(t,e,{colspan:n,colwidth:o}){const r=o&&o[o.length-1];if(r)return r;const i=t.domAtPos(e);let s=i.node.childNodes[i.offset].offsetWidth,l=n;if(o)for(let t=0;t<n;t++)o[t]&&(s-=o[t],l--);return s/l}(t,s.activeHandle,l.attrs);function c(e){i.removeEventListener("mouseup",c),i.removeEventListener("mousemove",d);const o=wm.getState(t.state);(null==o?void 0:o.dragging)&&(function(t,e,n){const o=t.state.doc.resolve(e),r=o.node(-1),i=Af.get(r),s=o.start(-1),l=i.colCount(o.pos-s)+o.nodeAfter.attrs.colspan-1,a=t.state.tr;for(let t=0;t<i.height;t++){const e=t*i.width+l;if(t&&i.map[e]==i.map[e-i.width])continue;const o=i.map[e],c=r.nodeAt(o).attrs,d=1==c.colspan?0:l-i.colCount(o);if(c.colwidth&&c.colwidth[d]==n)continue;const h=c.colwidth?c.colwidth.slice():Am(c.colspan);h[d]=n,a.setNodeMarkup(s+o,null,{...c,colwidth:h})}a.docChanged&&t.dispatch(a)}(t,o.activeHandle,Cm(o.dragging,e,n)),t.dispatch(t.state.tr.setMeta(wm,{setDragging:null})))}function d(e){if(!e.which)return c(e);const r=wm.getState(t.state);if(r&&r.dragging){const i=Cm(r.dragging,e,n);Tm(t,r.activeHandle,i,o)}}t.dispatch(t.state.tr.setMeta(wm,{setDragging:{startX:e.clientX,startWidth:a}})),Tm(t,s.activeHandle,a,o),i.addEventListener("mouseup",c),i.addEventListener("mousemove",d),e.preventDefault()}(t,o,e,n)}},decorations:t=>{const e=wm.getState(t);if(e&&e.activeHandle>-1)return function(t,e){var n;const o=[],r=t.doc.resolve(e),i=r.node(-1);if(!i)return Cr.empty;const s=Af.get(i),l=r.start(-1),a=s.colCount(r.pos-l)+r.nodeAfter.attrs.colspan-1;for(let e=0;e<s.height;e++){const r=a+e*s.width;if(!(a!=s.width-1&&s.map[r]==s.map[r+1]||0!=e&&s.map[r]==s.map[r-s.width])){const e=s.map[r],a=l+e+i.nodeAt(e).nodeSize-1,c=document.createElement("div");c.className="column-resize-handle",(null==(n=wm.getState(t))?void 0:n.dragging)&&o.push(kr.node(l+e,l+e+i.nodeAt(e).nodeSize,{class:"column-resize-dragging"})),o.push(kr.widget(a,c))}}return Cr.create(t.doc,o)}(t,e.activeHandle)},nodeViews:{}}});return i}var xm=class t{constructor(t,e){this.activeHandle=t,this.dragging=e}apply(e){const n=this,o=e.getMeta(wm);if(o&&null!=o.setHandle)return new t(o.setHandle,!1);if(o&&void 0!==o.setDragging)return new t(n.activeHandle,o.setDragging);if(n.activeHandle>-1&&e.docChanged){let o=e.mapping.map(n.activeHandle,-1);return jf(e.doc.resolve(o))||(o=-1),new t(o,n.dragging)}return n}};function Mm(t,e,n,o){const r="right"==n?-o:o,i=t.posAtCoords({left:e.clientX+r,top:e.clientY});if(!i)return-1;const{pos:s}=i,l=Df(t.state.doc.resolve(s));if(!l)return-1;if("right"==n)return l.pos;const a=Af.get(l.node(-1)),c=l.start(-1),d=a.map.indexOf(l.pos-c);return d%a.width==0?-1:c+a.map[d-1]}function Cm(t,e,n){const o=e.clientX-t.startX;return Math.max(n,t.startWidth+o)}function Sm(t,e){t.dispatch(t.state.tr.setMeta(wm,{setHandle:e}))}function Tm(t,e,n,o){const r=t.state.doc.resolve(e),i=r.node(-1),s=r.start(-1),l=Af.get(i).colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1;let a=t.domAtPos(r.start(-1)).node;for(;a&&"TABLE"!=a.nodeName;)a=a.parentNode;a&&vm(i,a.firstChild,a,o,l,n)}function Am(t){return Array(t).fill(0)}function Em({allowTableNodeSelection:t=!1}={}){return new ze({key:Nf,state:{init:()=>null,apply(t,e){const n=t.getMeta(Nf);if(null!=n)return-1==n?null:n;if(null==e||!t.docChanged)return e;const{deleted:o,pos:r}=t.mapping.mapResult(e);return o?null:r}},props:{decorations:Vf,handleDOMEvents:{mousedown:fm},createSelectionBetween:t=>null!=Nf.getState(t.state)?t.state.selection:null,handleTripleClick:pm,handleKeyDown:am,handlePaste:um},appendTransaction:(e,n,o)=>function(t,e,n){const o=(e||t).selection,r=(e||t).doc;let i,s;if(o instanceof Ce&&(s=o.node.type.spec.tableRole)){if("cell"==s||"header_cell"==s)i=Hf.create(r,o.from);else if("row"==s){const t=r.resolve(o.from+1);i=Hf.rowSelection(t,t)}else if(!n){const t=Af.get(o.node),e=o.from+1,n=e+t.map[t.width*t.height-1];i=Hf.create(r,e+1,n)}}else o instanceof xe&&function({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let n=t.pos,o=e.pos,r=t.depth;for(;r>=0&&!(t.after(r+1)<t.end(r));r--,n++);for(let t=e.depth;t>=0&&!(e.before(t+1)>e.start(t));t--,o--);return n==o&&/row|table/.test(t.node(r).type.spec.tableRole)}(o)?i=xe.create(r,o.from):o instanceof xe&&function({$from:t,$to:e}){let n,o;for(let e=t.depth;e>0;e--){const o=t.node(e);if("cell"===o.type.spec.tableRole||"header_cell"===o.type.spec.tableRole){n=o;break}}for(let t=e.depth;t>0;t--){const n=e.node(t);if("cell"===n.type.spec.tableRole||"header_cell"===n.type.spec.tableRole){o=n;break}}return n!==o&&0===e.parentOffset}(o)&&(i=xe.create(r,o.$from.start(),o.$from.end()));return i&&(e||(e=t.tr)).setSelection(i),e}(o,Wf(o,n),t)})}var Om=va.create({name:"tableCell",addOptions:()=>({HTMLAttributes:{}}),content:"block+",addAttributes:()=>({colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(t=>parseInt(t,10)):null}}}),tableRole:"cell",isolating:!0,parseHTML:()=>[{tag:"td"}],renderHTML({HTMLAttributes:t}){return["td",rs(this.options.HTMLAttributes,t),0]}}),Nm=va.create({name:"tableHeader",addOptions:()=>({HTMLAttributes:{}}),content:"block+",addAttributes:()=>({colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(t=>parseInt(t,10)):null}}}),tableRole:"header_cell",isolating:!0,parseHTML:()=>[{tag:"th"}],renderHTML({HTMLAttributes:t}){return["th",rs(this.options.HTMLAttributes,t),0]}}),Dm=va.create({name:"tableRow",addOptions:()=>({HTMLAttributes:{}}),content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML:()=>[{tag:"tr"}],renderHTML({HTMLAttributes:t}){return["tr",rs(this.options.HTMLAttributes,t),0]}});function Lm(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function Rm(t,e,n,o,r,i){var s;let l=0,a=!0,c=e.firstChild;const d=t.firstChild;if(null!==d)for(let t=0,n=0;t<d.childCount;t+=1){const{colspan:s,colwidth:h}=d.child(t).attrs;for(let t=0;t<s;t+=1,n+=1){const s=r===n?i:h&&h[t],d=s?`${s}px`:"";if(l+=s||o,s||(a=!1),c){if(c.style.width!==d){const[t,e]=Lm(o,s);c.style.setProperty(t,e)}c=c.nextSibling}else{const t=document.createElement("col"),[n,r]=Lm(o,s);t.style.setProperty(n,r),e.appendChild(t)}}}for(;c;){const t=c.nextSibling;null==(s=c.parentNode)||s.removeChild(c),c=t}a?(n.style.width=`${l}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${l}px`)}var jm=class{constructor(t,e){this.node=t,this.cellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Rm(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type===this.node.type&&(this.node=t,Rm(t,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(t){return"attributes"===t.type&&(t.target===this.table||this.colgroup.contains(t.target))}};function Im(t,e){return e?t.createChecked(null,e):t.createAndFill()}var Pm=({editor:t})=>{const{selection:e}=t.state;if(!(e instanceof Hf))return!1;let n=0;const o=Ui(e.ranges[0].$from,t=>"table"===t.type.name);return null==o||o.node.descendants(t=>{if("table"===t.type.name)return!1;["tableCell","tableHeader"].includes(t.type.name)&&(n+=1)}),n===e.ranges.length&&(t.commands.deleteTable(),!0)},zm=va.create({name:"table",addOptions:()=>({HTMLAttributes:{},resizable:!1,handleWidth:5,cellMinWidth:25,View:jm,lastColumnResizable:!0,allowTableNodeSelection:!1}),content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML:()=>[{tag:"table"}],renderHTML({node:t,HTMLAttributes:e}){const{colgroup:n,tableWidth:o,tableMinWidth:r}=function(t,e){let n=0,o=!0;const r=[],i=t.firstChild;if(!i)return{};for(let t=0,s=0;t<i.childCount;t+=1){const{colspan:l,colwidth:a}=i.child(t).attrs;for(let t=0;t<l;t+=1,s+=1){const i=undefined===s?undefined:a&&a[t];n+=i||e,i||(o=!1);const[l,c]=Lm(e,i);r.push(["col",{style:`${l}: ${c}`}])}}const s=o?`${n}px`:"",l=o?"":`${n}px`;return{colgroup:["colgroup",{},...r],tableWidth:s,tableMinWidth:l}}(t,this.options.cellMinWidth);return["table",rs(this.options.HTMLAttributes,e,{style:o?`width: ${o}`:`min-width: ${r}`}),n,["tbody",0]]},addCommands:()=>({insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:o,dispatch:r,editor:i})=>{const s=function(t,e,n,o,r){const i=function(t){if(t.cached.tableNodeTypes)return t.cached.tableNodeTypes;const e={};return Object.keys(t.nodes).forEach(n=>{const o=t.nodes[n];o.spec.tableRole&&(e[o.spec.tableRole]=o)}),t.cached.tableNodeTypes=e,e}(t),s=[],l=[];for(let t=0;t<n;t+=1){const t=Im(i.cell,r);if(t&&l.push(t),o){const t=Im(i.header_cell,r);t&&s.push(t)}}const a=[];for(let t=0;t<e;t+=1)a.push(i.row.createChecked(null,o&&0===t?s:l));return i.table.createChecked(null,a)}(i.schema,t,e,n);if(r){const t=o.selection.from+1;o.replaceSelectionWith(s).scrollIntoView().setSelection(xe.near(o.doc.resolve(t)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>function(t,e){if(!Lf(t))return!1;if(e){const n=qf(t);e(Kf(t.tr,n,n.left))}return!0}(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>function(t,e){if(!Lf(t))return!1;if(e){const n=qf(t);e(Kf(t.tr,n,n.right))}return!0}(t,e),deleteColumn:()=>({state:t,dispatch:e})=>function(t,e){if(!Lf(t))return!1;if(e){const n=qf(t),o=t.tr;if(0==n.left&&n.right==n.map.width)return!1;for(let t=n.right-1;Jf(o,n,t),t!=n.left;t--){const t=n.tableStart?o.doc.nodeAt(n.tableStart-1):o.doc;if(!t)throw RangeError("No table found");n.table=t,n.map=Af.get(t)}e(o)}return!0}(t,e),addRowBefore:()=>({state:t,dispatch:e})=>function(t,e){if(!Lf(t))return!1;if(e){const n=qf(t);e(Uf(t.tr,n,n.top))}return!0}(t,e),addRowAfter:()=>({state:t,dispatch:e})=>function(t,e){if(!Lf(t))return!1;if(e){const n=qf(t);e(Uf(t.tr,n,n.bottom))}return!0}(t,e),deleteRow:()=>({state:t,dispatch:e})=>function(t,e){if(!Lf(t))return!1;if(e){const n=qf(t),o=t.tr;if(0==n.top&&n.bottom==n.map.height)return!1;for(let t=n.bottom-1;Gf(o,n,t),t!=n.top;t--){const t=n.tableStart?o.doc.nodeAt(n.tableStart-1):o.doc;if(!t)throw RangeError("No table found");n.table=t,n.map=Af.get(n.table)}e(o)}return!0}(t,e),deleteTable:()=>({state:t,dispatch:e})=>function(t,e){const n=t.selection.$anchor;for(let o=n.depth;o>0;o--)if("table"==n.node(o).type.spec.tableRole)return e&&e(t.tr.delete(n.before(o),n.after(o)).scrollIntoView()),!0;return!1}(t,e),mergeCells:()=>({state:t,dispatch:e})=>Xf(t,e),splitCell:()=>({state:t,dispatch:e})=>Qf(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>tm("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>tm("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>em(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>!!Xf(t,e)||Qf(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:o})=>function(t,e){return function(n,o){if(!Lf(n))return!1;const r=Rf(n);if(r.nodeAfter.attrs[t]===e)return!1;if(o){const i=n.tr;n.selection instanceof Hf?n.selection.forEachCell((n,o)=>{n.attrs[t]!==e&&i.setNodeMarkup(o,null,{...n.attrs,[t]:e})}):i.setNodeMarkup(r.pos,null,{...r.nodeAfter.attrs,[t]:e}),o(i)}return!0}}(t,e)(n,o),goToNextCell:()=>({state:t,dispatch:e})=>nm(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>nm(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&Wf(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const n=Hf.create(e.doc,t.anchorCell,t.headCell);e.setSelection(n)}return!0}}),addKeyboardShortcuts(){return{Tab:()=>!!this.editor.commands.goToNextCell()||!!this.editor.can().addRowAfter()&&this.editor.chain().addRowAfter().goToNextCell().run(),"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:Pm,"Mod-Backspace":Pm,Delete:Pm,"Mod-Delete":Pm}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[km({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],Em({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema:t=>({tableRole:ts(Yi(t,"tableRole",{name:t.name,options:t.options,storage:t.storage}))})}),$m=(qs.create({name:"tableKit",addExtensions(){const t=[];return!1!==this.options.table&&t.push(zm.configure(this.options.table)),!1!==this.options.tableCell&&t.push(Om.configure(this.options.tableCell)),!1!==this.options.tableHeader&&t.push(Nm.configure(this.options.tableHeader)),!1!==this.options.tableRow&&t.push(Dm.configure(this.options.tableRow)),t}}),Bs.create({name:"textStyle",priority:101,addOptions:()=>({HTMLAttributes:{},mergeNestedSpanStyles:!0}),parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>!!t.hasAttribute("style")&&(this.options.mergeNestedSpanStyles&&(t=>{if(!t.children.length)return;const e=t.querySelectorAll("span");e&&e.forEach(t=>{var e,n;const o=t.getAttribute("style"),r=null==(n=null==(e=t.parentElement)?void 0:e.closest("span"))?void 0:n.getAttribute("style");t.setAttribute("style",`${r};${o}`)})})(t),{})}]},renderHTML({HTMLAttributes:t}){return["span",rs(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleTextStyle:t=>({commands:e})=>e.toggleMark(this.name,t),removeEmptyTextStyle:()=>({tr:t})=>{const{selection:e}=t;return t.doc.nodesBetween(e.from,e.to,(e,n)=>{if(e.isTextblock)return!0;e.marks.filter(t=>t.type===this.type).some(t=>Object.values(t.attrs).some(t=>!!t))||t.removeMark(n,n+e.nodeSize,this.type)}),!0}}}})),Hm=qs.create({name:"backgroundColor",addOptions:()=>({types:["textStyle"]}),addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const t=n.split(";").map(t=>t.trim()).filter(Boolean);for(let e=t.length-1;e>=0;e-=1){const n=t[e].split(":");if(n.length>=2){const t=n[0].trim().toLowerCase(),e=n.slice(1).join(":").trim();if("background-color"===t)return e.replace(/['"]+/g,"")}}}return null==(e=t.style.backgroundColor)?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.backgroundColor?{style:`background-color: ${t.backgroundColor}`}:{}}}}]},addCommands:()=>({setBackgroundColor:t=>({chain:e})=>e().setMark("textStyle",{backgroundColor:t}).run(),unsetBackgroundColor:()=>({chain:t})=>t().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()})}),Bm=qs.create({name:"color",addOptions:()=>({types:["textStyle"]}),addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const t=n.split(";").map(t=>t.trim()).filter(Boolean);for(let e=t.length-1;e>=0;e-=1){const n=t[e].split(":");if(n.length>=2){const t=n[0].trim().toLowerCase(),e=n.slice(1).join(":").trim();if("color"===t)return e.replace(/['"]+/g,"")}}}return null==(e=t.style.color)?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}}}}]},addCommands:()=>({setColor:t=>({chain:e})=>e().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()})}),Vm=qs.create({name:"fontFamily",addOptions:()=>({types:["textStyle"]}),addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:t=>t.style.fontFamily,renderHTML:t=>t.fontFamily?{style:`font-family: ${t.fontFamily}`}:{}}}}]},addCommands:()=>({setFontFamily:t=>({chain:e})=>e().setMark("textStyle",{fontFamily:t}).run(),unsetFontFamily:()=>({chain:t})=>t().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()})}),_m=qs.create({name:"fontSize",addOptions:()=>({types:["textStyle"]}),addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:t=>t.style.fontSize,renderHTML:t=>t.fontSize?{style:`font-size: ${t.fontSize}`}:{}}}}]},addCommands:()=>({setFontSize:t=>({chain:e})=>e().setMark("textStyle",{fontSize:t}).run(),unsetFontSize:()=>({chain:t})=>t().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()})}),Fm=qs.create({name:"lineHeight",addOptions:()=>({types:["textStyle"]}),addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:t=>t.style.lineHeight,renderHTML:t=>t.lineHeight?{style:`line-height: ${t.lineHeight}`}:{}}}}]},addCommands:()=>({setLineHeight:t=>({chain:e})=>e().setMark("textStyle",{lineHeight:t}).run(),unsetLineHeight:()=>({chain:t})=>t().setMark("textStyle",{lineHeight:null}).removeEmptyTextStyle().run()})}),Wm=(qs.create({name:"textStyleKit",addExtensions(){const t=[];return!1!==this.options.backgroundColor&&t.push(Hm.configure(this.options.backgroundColor)),!1!==this.options.color&&t.push(Bm.configure(this.options.color)),!1!==this.options.fontFamily&&t.push(Vm.configure(this.options.fontFamily)),!1!==this.options.fontSize&&t.push(_m.configure(this.options.fontSize)),!1!==this.options.lineHeight&&t.push(Fm.configure(this.options.lineHeight)),!1!==this.options.textStyle&&t.push($m.configure(this.options.textStyle)),t}}),/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/),qm=va.create({name:"image",addOptions:()=>({inline:!1,allowBase64:!1,HTMLAttributes:{}}),inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes:()=>({src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}),parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:t}){return["img",rs(this.options.HTMLAttributes,t)]},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[ga({find:Wm,type:this.type,getAttributes:t=>{const[,,e,n,o]=t;return{src:n,alt:e,title:o}}})]}}),Km=qm,Jm=n(7479),Um={StarterKit:Mf,Superscript:Sf,Subscript:Tf,Highlight:Wd,Table:zm,TableCell:Om,TableHeader:Nm,TableRow:Dm,TextAlign:Cf,Placeholder:yf,Color:Bm,TextStyle:$m,BackgroundColor:Hm,FontFamily:Vm,FontSize:_m,LineHeight:Fm,Image:Km},Gm=function(t){var e=t.i,n=t.componentPath,r=t.editor,i=t.onClick,l=t.children,a=(0,o.Tt)(t,["i","componentPath","editor","onClick","children"]);return s().createElement(Td.Control,(0,o.Cl)({onClick:function(t){r&&(0,Vd.q)(i)({editor:r,event:t})}},a),(0,Jm.o5)(l,e,(0,o.fX)((0,o.fX)([],n,!0),["CustomControl","children"],!1)))},Ym=function(t){var e=t.setProps,n=t.loading_state,r=(t.persistence,t.persisted_props,t.persistence_type,t.html),l=t.json,a=t.variant,c=t.extensions,d=void 0===c?["StarterKit","Superscript","Subscript","Highlight","Table","TableCell","TableHeader","TableRow",{Placeholder:{placeholder:"Write or paste content here..."}},{TextAlign:{types:["heading","paragraph"]}},"Color","TextStyle","BackgroundColor","FontFamily","FontSize","LineHeight","Image"]:c,h=t.toolbar,p=t.debounce,u=void 0===p?100:p,f=t.n_blur,m=void 0===f?0:f,y=(t.selected,t.labels),b=(0,o.Tt)(t,["setProps","loading_state","persistence","persisted_props","persistence_type","html","json","variant","extensions","toolbar","debounce","n_blur","selected","labels"]),v=function(t){void 0===t&&(t={}),D&&e((0,o.Cl)({html:D.getHTML(),json:D.getJSON()},t))},w=(0,i.useState)(""),k=w[0],x=w[1],M="number"==typeof u?u:0,C=(0,Hd.o)(k,M)[0];(0,Bd.C)(function(){"number"!=typeof u&&!1!==u||v()},[C]),(0,Bd.C)(function(){D&&D.getHTML()!==r&&(D.commands.setContent(r),v())},[r]),(0,Bd.C)(function(){D&&JSON.stringify(D.getJSON())!==JSON.stringify(l)&&(D.commands.setContent(l),v())},[l]);var S=(0,i.useState)(""),T=S[0],A=S[1],E=(0,Hd.o)(T,M)[0];(0,Bd.C)(function(){"number"!=typeof u&&!1!==u||e({selected:E})},[E]);var O=y&&(0,o.Cl)((0,o.Cl)((0,o.Cl)({},y),y.colorControlLabel&&{colorControlLabel:function(t){return y.colorControlLabel.replace("{color}",t)}}),y.colorPickerColorLabel&&{colorPickerColorLabel:function(t){return y.colorPickerColorLabel.replace("{color}",t)}}),N=void 0,D=function(t={},e=[]){const n=(0,i.useRef)(t);n.current=t;const[o]=(0,i.useState)(()=>new La(n)),r=(0,g.useSyncExternalStore)(o.subscribe,o.getEditor,o.getServerSnapshot);return(0,i.useDebugValue)(r),(0,i.useEffect)(o.onRender(e)),function(t){var e;const[n]=(0,i.useState)(()=>new Oa(t.editor)),o=(0,xa.useSyncExternalStoreWithSelector)(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,null!=(e=t.equalityFn)?e:ka);Ea(()=>n.watch(t.editor),[t.editor,n]),(0,i.useDebugValue)(o)}({editor:r,selector:({transactionNumber:e})=>!1===t.shouldRerenderOnTransaction||void 0===t.shouldRerenderOnTransaction?null:t.immediatelyRender&&0===e?0:e+1}),r}({extensions:d.map(function(t){if("string"==typeof t)return Um[t];var e=Object.keys(t)[0];return Um[e].configure(t[e])}),content:l||r,onUpdate:function(t){var e=t.editor;x(e.getJSON())},onBlur:function(){D&&!0===u&&v({n_blur:m+1,selected:T})},onSelectionUpdate:function(t){var e=t.editor;if(e){var n=e.state.selection,o=n.from,r=n.to,i=e.state.doc.textBetween(o,r," ");A(i)}},onCreate:v,shouldRerenderOnTransaction:!0});if(void 0!==h){var L=(0,Jm.z5)();N=s().createElement(Td.Toolbar,{sticky:h.sticky,stickyOffset:h.stickyOffset},h.controlsGroups.map(function(t,e){return s().createElement(Td.ControlsGroup,{key:e},t.map(function(t,n){return function(t,e,n,r){if("string"==typeof t)return s().createElement(Td[t],{key:e});var i=Object.keys(t)[0],l=t[i];return"CustomControl"!==i?s().createElement(Td[i],(0,o.Cl)({key:e},l)):s().createElement(Gm,(0,o.Cl)({i:e,key:"custom-".concat(e),componentPath:r,editor:n},l))}(t,n,D,(0,o.fX)((0,o.fX)([],L,!0),["props","toolbar","controlsGroups",e,n],!1))}))}))}return s().createElement(Td,(0,o.Cl)({variant:a,editor:D,"data-dash-is-loading":(0,Jm.A_)(n)||void 0,labels:O},b),N,s().createElement(Td.Content,null))};(0,Jm.oM)(Ym,["html","json"]);const Xm=Ym},4417:t=>{t.exports=function(t,e){return e||(e={}),t?(t=String(t.__esModule?t.default:t),/^['"].*['"]$/.test(t)&&(t=t.slice(1,-1)),e.hash&&(t+=e.hash),/["'() \t\n]|(%20)/.test(t)||e.needQuotes?'"'.concat(t.replace(/"/g,'\\"').replace(/\n/g,"\\n"),'"'):t):t}},4985:t=>{t.exports="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCAxMCA3Ij48cGF0aCBmaWxsPSIjZmZmIiBkPSJNNCA0LjU4NkwxLjcwNyAyLjI5M0ExIDEgMCAxMC4yOTMgMy43MDdsMyAzYS45OTcuOTk3IDAgMDAxLjQxNCAwbDUtNUExIDEgMCAxMDguMjkzLjI5M0w0IDQuNTg2eiIvPjwvc3ZnPg=="},5095:t=>{t.exports=function t(e,n){if(e===n)return!0;if(e&&n&&"object"==typeof e&&"object"==typeof n){if(e.constructor!==n.constructor)return!1;var o,r,i;if(Array.isArray(e)){if((o=e.length)!=n.length)return!1;for(r=o;0!==r--;)if(!t(e[r],n[r]))return!1;return!0}if(e instanceof Map&&n instanceof Map){if(e.size!==n.size)return!1;for(r of e.entries())if(!n.has(r[0]))return!1;for(r of e.entries())if(!t(r[1],n.get(r[0])))return!1;return!0}if(e instanceof Set&&n instanceof Set){if(e.size!==n.size)return!1;for(r of e.entries())if(!n.has(r[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(n)){if((o=e.length)!=n.length)return!1;for(r=o;0!==r--;)if(e[r]!==n[r])return!1;return!0}if(e.constructor===RegExp)return e.source===n.source&&e.flags===n.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===n.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===n.toString();if((o=(i=Object.keys(e)).length)!==Object.keys(n).length)return!1;for(r=o;0!==r--;)if(!Object.prototype.hasOwnProperty.call(n,i[r]))return!1;for(r=o;0!==r--;){var s=i[r];if(!("_owner"===s&&e.$$typeof||t(e[s],n[s])))return!1}return!0}return e!=e&&n!=n}},6541:(t,e,n)=>{n.d(e,{A:()=>p});var o=n(1601),r=n.n(o),i=n(6314),s=n.n(i),l=n(4417),a=n.n(l),c=new URL(n(4985),n.b),d=s()(r()),h=a()(c);d.push([t.id,`.m_dd3f7539 {\n position: relative;\n border: calc(0.0625rem * var(--mantine-scale)) solid;\n border-radius: var(--mantine-radius-default);\n}\n\n :where([data-mantine-color-scheme='light']) .m_dd3f7539 {\n border-color: var(--mantine-color-gray-4);\n}\n\n :where([data-mantine-color-scheme='dark']) .m_dd3f7539 {\n border-color: var(--mantine-color-dark-4);\n}\n\n.m_f2016866 {\n padding: 0;\n margin: 0;\n}\n\n.m_f2016866 li > p {\n margin: 0;\n }\n\n.m_f2016866 ul li,\n .m_f2016866 ol li {\n margin-top: calc(0.125rem * var(--mantine-scale));\n }\n\n.m_f2016866 p {\n margin-bottom: calc(0.4375rem * var(--mantine-scale));\n }\n\n.m_f2016866 h1,\n .m_f2016866 h2,\n .m_f2016866 h3,\n .m_f2016866 h4,\n .m_f2016866 h5,\n .m_f2016866 h6,\n .m_f2016866 p {\n margin-top: 0;\n }\n\n.m_c2204cc2 {\n background-color: var(--mantine-color-body);\n border-radius: var(--mantine-radius-default);\n}\n\n.m_c2204cc2 .ProseMirror {\n outline: 0;\n padding: var(--mantine-spacing-md);\n }\n\n.m_c2204cc2 .ProseMirror > *:last-child {\n margin-bottom: 0;\n }\n\n.m_c2204cc2 .ProseMirror p.is-editor-empty:first-of-type::before {\n content: attr(data-placeholder);\n pointer-events: none;\n user-select: none;\n float: left;\n height: 0;\n color: var(--mantine-color-placeholder);\n }\n\n.m_c2204cc2 pre {\n font-family: var(--mantine-font-family-monospace);\n border-radius: var(--mantine-radius-default);\n padding: var(--mantine-spacing-sm) var(--mantine-spacing-md);\n }\n\n:where([data-mantine-color-scheme='light']) .m_c2204cc2 pre {\n background-color: var(--mantine-color-gray-0);\n color: var(--mantine-color-gray-9);\n --code-color-comment: var(--mantine-color-gray-5);\n --code-color-var: var(--mantine-color-red-7);\n --code-color-number: var(--mantine-color-blue-7);\n --code-color-title: var(--mantine-color-pink-7);\n --code-color-keyword: var(--mantine-color-violet-7);\n}\n\n:where([data-mantine-color-scheme='dark']) .m_c2204cc2 pre {\n background-color: var(--mantine-color-dark-8);\n color: var(--mantine-color-dark-1);\n --code-color-comment: var(--mantine-color-dark-2);\n --code-color-var: var(--mantine-color-red-5);\n --code-color-number: var(--mantine-color-cyan-5);\n --code-color-title: var(--mantine-color-yellow-5);\n --code-color-keyword: var(--mantine-color-violet-3);\n}\n\n.m_c2204cc2 pre code {\n background: none !important;\n color: inherit;\n font-size: var(--mantine-font-size-sm);\n padding: 0;\n }\n\n.m_c2204cc2 pre .hljs-comment,\n .m_c2204cc2 pre .hljs-quote {\n color: var(--code-color-comment);\n }\n\n.m_c2204cc2 pre .hljs-variable,\n .m_c2204cc2 pre .hljs-template-variable,\n .m_c2204cc2 pre .hljs-attribute,\n .m_c2204cc2 pre .hljs-tag,\n .m_c2204cc2 pre .hljs-regexp,\n .m_c2204cc2 pre .hljs-link,\n .m_c2204cc2 pre .hljs-name,\n .m_c2204cc2 pre .hljs-selector-id,\n .m_c2204cc2 pre .hljs-selector-class {\n color: var(--code-color-var);\n }\n\n.m_c2204cc2 pre .hljs-number,\n .m_c2204cc2 pre .hljs-meta,\n .m_c2204cc2 pre .hljs-built_in,\n .m_c2204cc2 pre .hljs-builtin-name,\n .m_c2204cc2 pre .hljs-literal,\n .m_c2204cc2 pre .hljs-type,\n .m_c2204cc2 pre .hljs-params {\n color: var(--code-color-number);\n }\n\n.m_c2204cc2 pre .hljs-string,\n .m_c2204cc2 pre .hljs-symbol,\n .m_c2204cc2 pre .hljs-bullet {\n color: var(--code-color-var);\n }\n\n.m_c2204cc2 pre .hljs-title,\n .m_c2204cc2 pre .hljs-section {\n color: var(--code-color-title);\n }\n\n.m_c2204cc2 pre .hljs-keyword,\n .m_c2204cc2 pre .hljs-selector-tag {\n color: var(--code-color-keyword);\n }\n\n.m_c2204cc2 pre .hljs-emphasis {\n font-style: italic;\n }\n\n.m_c2204cc2 pre .hljs-strong {\n font-weight: 700;\n }\n\n.m_8a991b4f {\n background-color: var(--mantine-color-body);\n}\n\n.m_c2207da6 {\n display: flex;\n justify-content: center;\n align-items: center;\n border-radius: var(--mantine-radius-default);\n cursor: default;\n}\n\n.m_c2207da6:where([data-variant='default']) {\n border: calc(0.0625rem * var(--mantine-scale)) solid;\n min-width: calc(1.625rem * var(--mantine-scale));\n height: calc(1.625rem * var(--mantine-scale));\n }\n\n.m_c2207da6:where([data-variant='subtle']) {\n --control-icon-size: calc(1.25rem * var(--mantine-scale));\n min-width: calc(2rem * var(--mantine-scale));\n height: calc(2rem * var(--mantine-scale));\n }\n\n:where([data-mantine-color-scheme='light']) .m_c2207da6 {\n background-color: var(--mantine-color-white);\n border-color: var(--mantine-color-gray-4);\n color: var(--mantine-color-gray-7);\n}\n\n:where([data-mantine-color-scheme='dark']) .m_c2207da6 {\n border-color: var(--mantine-color-dark-4);\n color: var(--mantine-color-dark-1);\n}\n\n:where([data-mantine-color-scheme='dark']) .m_c2207da6:where([data-variant='default']) {\n background-color: var(--mantine-color-dark-6);\n }\n\n:where([data-mantine-color-scheme='dark']) .m_c2207da6:where([data-variant='subtle']) {\n background-color: var(--mantine-color-dark-7);\n }\n\n.m_c2207da6:where([data-disabled]) {\n cursor: not-allowed;\n color: var(--mantine-color-disabled-color);\n background-color: var(--mantine-color-disabled);\n }\n\n.m_c2207da6:where([data-interactive]:not([data-disabled])) {\n cursor: pointer;\n }\n\n@media (hover: hover) {\n\n .m_c2207da6:where([data-interactive]:not([data-disabled])):hover {\n color: var(--mantine-color-bright);\n }\n :where([data-mantine-color-scheme='light']) .m_c2207da6:where([data-interactive]:not([data-disabled])):hover:where([data-variant='default']) {\n background-color: var(--mantine-color-gray-0);\n }\n\n :where([data-mantine-color-scheme='light']) .m_c2207da6:where([data-interactive]:not([data-disabled])):hover:where([data-variant='subtle']) {\n background-color: var(--mantine-color-gray-1);\n }\n\n :where([data-mantine-color-scheme='dark']) .m_c2207da6:where([data-interactive]:not([data-disabled])):hover {\n background-color: var(--mantine-color-dark-5);\n }\n}\n\n@media (hover: none) {\n\n .m_c2207da6:where([data-interactive]:not([data-disabled])):active {\n color: var(--mantine-color-bright);\n }\n :where([data-mantine-color-scheme='light']) .m_c2207da6:where([data-interactive]:not([data-disabled])):active:where([data-variant='default']) {\n background-color: var(--mantine-color-gray-0);\n }\n\n :where([data-mantine-color-scheme='light']) .m_c2207da6:where([data-interactive]:not([data-disabled])):active:where([data-variant='subtle']) {\n background-color: var(--mantine-color-gray-1);\n }\n\n :where([data-mantine-color-scheme='dark']) .m_c2207da6:where([data-interactive]:not([data-disabled])):active {\n background-color: var(--mantine-color-dark-5);\n }\n}\n\n.m_c2207da6:where([data-active]) {\n background-color: var(--mantine-primary-color-light);\n color: var(--mantine-primary-color-light-color);\n }\n\n@media (hover: hover) {\n\n .m_c2207da6:where([data-active]):hover {\n background-color: var(--mantine-primary-color-light-hover);\n }\n}\n\n@media (hover: none) {\n\n .m_c2207da6:where([data-active]):active {\n background-color: var(--mantine-primary-color-light-hover);\n }\n}\n\n.m_9cdfeb3f {\n width: var(--control-icon-size, 16px);\n height: var(--control-icon-size, 16px);\n}\n\n.m_2ab47ef2 {\n display: flex;\n background-color: var(--mantine-color-body);\n}\n\n.m_2ab47ef2:where([data-variant='default']) :where([data-rich-text-editor-control]) {\n border-radius: 0;\n }\n\n.m_2ab47ef2:where([data-variant='default']) :where([data-rich-text-editor-control]):where(:not(:last-of-type)) {\n border-inline-end-width: 0;\n }\n\n.m_2ab47ef2:where([data-variant='default']) :where([data-rich-text-editor-control]):where(:last-of-type) {\n border-start-end-radius: var(--mantine-radius-default);\n border-end-end-radius: var(--mantine-radius-default);\n }\n\n.m_2ab47ef2:where([data-variant='default']) :where([data-rich-text-editor-control]):where(:first-of-type) {\n border-start-start-radius: var(--mantine-radius-default);\n border-end-start-radius: var(--mantine-radius-default);\n }\n\n.m_b67b711e {\n display: flex;\n}\n\n.m_296cf94c {\n border-start-end-radius: 0;\n border-end-end-radius: 0;\n border-inline-end: 0;\n}\n\n.m_cfef614 {\n border: calc(0.0625rem * var(--mantine-scale)) solid;\n color: var(--mantine-color-text);\n height: calc(1.5rem * var(--mantine-scale));\n width: calc(1.5rem * var(--mantine-scale));\n display: flex;\n justify-content: center;\n align-items: center;\n border-radius: var(--mantine-radius-default);\n}\n\n:where([data-mantine-color-scheme='light']) .m_cfef614 {\n background-color: var(--mantine-color-white);\n border-color: var(--mantine-color-gray-4);\n}\n\n:where([data-mantine-color-scheme='dark']) .m_cfef614 {\n background-color: var(--mantine-color-dark-7);\n border-color: var(--mantine-color-dark-4);\n}\n\n.m_cfef614:where([data-active]) {\n background-color: var(--mantine-primary-color-light);\n color: var(--mantine-primary-color-filled);\n }\n\n@media (hover: hover) {\n\n .m_cfef614:where([data-active]):hover {\n background-color: var(--mantine-primary-color-light-hover);\n }\n}\n\n@media (hover: none) {\n\n .m_cfef614:where([data-active]):active {\n background-color: var(--mantine-primary-color-light-hover);\n }\n}\n\n.m_3b28e7bb {\n border-start-start-radius: 0;\n border-end-start-radius: 0;\n}\n\n.m_4574a3c4 {\n display: flex;\n align-items: center;\n flex-wrap: wrap;\n gap: var(--mantine-spacing-sm);\n top: var(--rte-sticky-offset, 0px);\n background-color: var(--mantine-color-body);\n z-index: 1;\n border-start-end-radius: var(--mantine-radius-default);\n border-start-start-radius: var(--mantine-radius-default);\n border-bottom: calc(0.0625rem * var(--mantine-scale)) solid;\n}\n\n.m_4574a3c4:where([data-variant='default']) {\n padding: var(--mantine-spacing-xs) var(--mantine-spacing-md);\n }\n\n.m_4574a3c4:where([data-variant='subtle']) {\n padding: calc(0.25rem * var(--mantine-scale));\n row-gap: 0;\n }\n\n:where([data-mantine-color-scheme='light']) .m_4574a3c4 {\n border-color: var(--mantine-color-gray-4);\n}\n\n:where([data-mantine-color-scheme='dark']) .m_4574a3c4 {\n border-color: var(--mantine-color-dark-4);\n}\n\n.m_4574a3c4:where([data-sticky]) {\n position: sticky;\n }\n\n.m_8b44009a {\n list-style-type: none;\n padding: 0;\n padding-inline-start: 0;\n}\n\n.m_8b44009a :where(li) {\n margin: 0;\n padding: 0;\n display: flex;\n }\n\n.m_8b44009a :where(ul) {\n margin-top: calc(0.3125rem * var(--mantine-scale));\n }\n\n.m_8b44009a p {\n margin: 0;\n padding: 0;\n }\n\n.m_8b44009a :where(label) {\n display: inline-block;\n }\n\n.m_8b44009a :where(input) {\n cursor: pointer;\n appearance: none;\n width: calc(1.125rem * var(--mantine-scale));\n height: calc(1.125rem * var(--mantine-scale));\n border: calc(0.0625rem * var(--mantine-scale)) solid;\n border-radius: var(--mantine-radius-default);\n vertical-align: middle;\n position: relative;\n }\n\n:where([data-mantine-color-scheme='light']) .m_8b44009a :where(input) {\n background-color: var(--mantine-color-white);\n border-color: var(--mantine-color-gray-4);\n}\n\n:where([data-mantine-color-scheme='dark']) .m_8b44009a :where(input) {\n background-color: var(--mantine-color-dark-6);\n border-color: var(--mantine-color-dark-4);\n}\n\n.m_8b44009a :where(input):checked {\n background-color: var(--mantine-primary-color-filled);\n border-color: var(--mantine-primary-color-filled);\n }\n\n.m_8b44009a :where(input):checked::before {\n position: absolute;\n content: '';\n inset: 0;\n background-image: url(${h});\n background-repeat: no-repeat;\n background-size: calc(0.625rem * var(--mantine-scale));\n background-position: center;\n }\n\n.m_8b44009a :where(li > label) {\n margin-inline-end: var(--mantine-spacing-sm);\n }\n`,""]);const p=d},8493:(t,e,n)=>{var o=n(295),r="function"==typeof Object.is?Object.is:function(t,e){return t===e&&(0!==t||1/t==1/e)||t!=t&&e!=e},i=o.useState,s=o.useEffect,l=o.useLayoutEffect,a=o.useDebugValue;function c(t){var e=t.getSnapshot;t=t.value;try{var n=e();return!r(t,n)}catch(t){return!0}}var d="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(t,e){return e()}:function(t,e){var n=e(),o=i({inst:{value:n,getSnapshot:e}}),r=o[0].inst,d=o[1];return l(function(){r.value=n,r.getSnapshot=e,c(r)&&d({inst:r})},[t,n,e]),s(function(){return c(r)&&d({inst:r}),t(function(){c(r)&&d({inst:r})})},[t]),a(n),n};e.useSyncExternalStore=void 0!==o.useSyncExternalStore?o.useSyncExternalStore:d},9242:(t,e,n)=>{t.exports=n(2162)},9888:(t,e,n)=>{t.exports=n(8493)}}]);
2
+ "use strict";(self.webpackChunkdash_mantine_components=self.webpackChunkdash_mantine_components||[]).push([[330],{654:(t,e,n)=>{n.r(e),n.d(e,{default:()=>Ig});var o=n(1635),r=n(4848),i=n(295),s=n.n(i),a=n(2412),l=n(6100),c=n(2837),d=n(4791);const h={linkControlLabel:"Link",colorPickerControlLabel:"Text color",highlightControlLabel:"Highlight text",colorControlLabel:t=>`Set text color ${t}`,boldControlLabel:"Bold",italicControlLabel:"Italic",underlineControlLabel:"Underline",strikeControlLabel:"Strikethrough",clearFormattingControlLabel:"Clear formatting",unlinkControlLabel:"Remove link",bulletListControlLabel:"Bullet list",orderedListControlLabel:"Ordered list",sourceCodeControlLabel:"Switch between text/source code",h1ControlLabel:"Heading 1",h2ControlLabel:"Heading 2",h3ControlLabel:"Heading 3",h4ControlLabel:"Heading 4",h5ControlLabel:"Heading 5",h6ControlLabel:"Heading 6",blockquoteControlLabel:"Blockquote",alignLeftControlLabel:"Align text: left",alignCenterControlLabel:"Align text: center",alignRightControlLabel:"Align text: right",alignJustifyControlLabel:"Align text: justify",codeControlLabel:"Code",codeBlockControlLabel:"Code block",subscriptControlLabel:"Subscript",superscriptControlLabel:"Superscript",unsetColorControlLabel:"Unset color",hrControlLabel:"Horizontal line",undoControlLabel:"Undo",redoControlLabel:"Redo",tasksControlLabel:"Task list",tasksSinkLabel:"Decrease task level",tasksLiftLabel:"Increase task level",linkEditorInputLabel:"Enter URL",linkEditorInputPlaceholder:"https://example.com/",linkEditorExternalLink:"Open link in a new tab",linkEditorInternalLink:"Open link in the same tab",linkEditorSave:"Save",colorPickerCancel:"Cancel",colorPickerClear:"Clear color",colorPickerColorPicker:"Color picker",colorPickerPalette:"Color palette",colorPickerSave:"Save",colorPickerColorLabel:t=>`Set text color ${t}`};var p=n(6798);const[u,f]=(0,p.F)("RichTextEditor component was not found in tree");var m=n(3775),g=n(9888);function y(t){this.content=t}y.prototype={constructor:y,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return-1==e?void 0:this.content[e+1]},update:function(t,e,n){var o=n&&n!=t?this.remove(n):this,r=o.find(t),i=o.content.slice();return-1==r?i.push(n||t,e):(i[r+1]=e,n&&(i[r]=n)),new y(i)},remove:function(t){var e=this.find(t);if(-1==e)return this;var n=this.content.slice();return n.splice(e,2),new y(n)},addToStart:function(t,e){return new y([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new y(n)},addBefore:function(t,e,n){var o=this.remove(e),r=o.content.slice(),i=o.find(t);return r.splice(-1==i?r.length:i,0,e,n),new y(r)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return(t=y.from(t)).size?new y(t.content.concat(this.subtract(t).content)):this},append:function(t){return(t=y.from(t)).size?new y(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=y.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach(function(e,n){t[e]=n}),t},get size(){return this.content.length>>1}},y.from=function(t){if(t instanceof y)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new y(e)};const b=y;function v(t,e,n){for(let o=0;;o++){if(o==t.childCount||o==e.childCount)return t.childCount==e.childCount?null:n;let r=t.child(o),i=e.child(o);if(r!=i){if(!r.sameMarkup(i))return n;if(r.isText&&r.text!=i.text){for(let t=0;r.text[t]==i.text[t];t++)n++;return n}if(r.content.size||i.content.size){let t=v(r.content,i.content,n+1);if(null!=t)return t}n+=r.nodeSize}else n+=r.nodeSize}}function w(t,e,n,o){for(let r=t.childCount,i=e.childCount;;){if(0==r||0==i)return r==i?null:{a:n,b:o};let s=t.child(--r),a=e.child(--i),l=s.nodeSize;if(s!=a){if(!s.sameMarkup(a))return{a:n,b:o};if(s.isText&&s.text!=a.text){let t=0,e=Math.min(s.text.length,a.text.length);for(;t<e&&s.text[s.text.length-t-1]==a.text[a.text.length-t-1];)t++,n--,o--;return{a:n,b:o}}if(s.content.size||a.content.size){let t=w(s.content,a.content,n-1,o-1);if(t)return t}n-=l,o-=l}else n-=l,o-=l}}class k{constructor(t,e){if(this.content=t,this.size=e||0,null==e)for(let e=0;e<t.length;e++)this.size+=t[e].nodeSize}nodesBetween(t,e,n,o=0,r){for(let i=0,s=0;s<e;i++){let a=this.content[i],l=s+a.nodeSize;if(l>t&&!1!==n(a,o+s,r||null,i)&&a.content.size){let r=s+1;a.nodesBetween(Math.max(0,t-r),Math.min(a.content.size,e-r),n,o+r)}s=l}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,e,n,o){let r="",i=!0;return this.nodesBetween(t,e,(s,a)=>{let l=s.isText?s.text.slice(Math.max(t,a)-a,e-a):s.isLeaf?o?"function"==typeof o?o(s):o:s.type.spec.leafText?s.type.spec.leafText(s):"":"";s.isBlock&&(s.isLeaf&&l||s.isTextblock)&&n&&(i?i=!1:r+=n),r+=l},0),r}append(t){if(!t.size)return this;if(!this.size)return t;let e=this.lastChild,n=t.firstChild,o=this.content.slice(),r=0;for(e.isText&&e.sameMarkup(n)&&(o[o.length-1]=e.withText(e.text+n.text),r=1);r<t.content.length;r++)o.push(t.content[r]);return new k(o,this.size+t.size)}cut(t,e=this.size){if(0==t&&e==this.size)return this;let n=[],o=0;if(e>t)for(let r=0,i=0;i<e;r++){let s=this.content[r],a=i+s.nodeSize;a>t&&((i<t||a>e)&&(s=s.isText?s.cut(Math.max(0,t-i),Math.min(s.text.length,e-i)):s.cut(Math.max(0,t-i-1),Math.min(s.content.size,e-i-1))),n.push(s),o+=s.nodeSize),i=a}return new k(n,o)}cutByIndex(t,e){return t==e?k.empty:0==t&&e==this.content.length?this:new k(this.content.slice(t,e))}replaceChild(t,e){let n=this.content[t];if(n==e)return this;let o=this.content.slice(),r=this.size+e.nodeSize-n.nodeSize;return o[t]=e,new k(o,r)}addToStart(t){return new k([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new k(this.content.concat(t),this.size+t.nodeSize)}eq(t){if(this.content.length!=t.content.length)return!1;for(let e=0;e<this.content.length;e++)if(!this.content[e].eq(t.content[e]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(t){let e=this.content[t];if(!e)throw new RangeError("Index "+t+" out of range for "+this);return e}maybeChild(t){return this.content[t]||null}forEach(t){for(let e=0,n=0;e<this.content.length;e++){let o=this.content[e];t(o,n,e),n+=o.nodeSize}}findDiffStart(t,e=0){return v(this,t,e)}findDiffEnd(t,e=this.size,n=t.size){return w(this,t,e,n)}findIndex(t){if(0==t)return M(0,t);if(t==this.size)return M(this.content.length,t);if(t>this.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let e=0,n=0;;e++){let o=n+this.child(e).nodeSize;if(o>=t)return o==t?M(e+1,o):M(e,n);n=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(t=>t.toJSON()):null}static fromJSON(t,e){if(!e)return k.empty;if(!Array.isArray(e))throw new RangeError("Invalid input for Fragment.fromJSON");return new k(e.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return k.empty;let e,n=0;for(let o=0;o<t.length;o++){let r=t[o];n+=r.nodeSize,o&&r.isText&&t[o-1].sameMarkup(r)?(e||(e=t.slice(0,o)),e[e.length-1]=r.withText(e[e.length-1].text+r.text)):e&&e.push(r)}return new k(e||t,n)}static from(t){if(!t)return k.empty;if(t instanceof k)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new k([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}k.empty=new k([],0);const x={index:0,offset:0};function M(t,e){return x.index=t,x.offset=e,x}function C(t,e){if(t===e)return!0;if(!t||"object"!=typeof t||!e||"object"!=typeof e)return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!C(t[n],e[n]))return!1}else{for(let n in t)if(!(n in e)||!C(t[n],e[n]))return!1;for(let n in e)if(!(n in t))return!1}return!0}class S{constructor(t,e){this.type=t,this.attrs=e}addToSet(t){let e,n=!1;for(let o=0;o<t.length;o++){let r=t[o];if(this.eq(r))return t;if(this.type.excludes(r.type))e||(e=t.slice(0,o));else{if(r.type.excludes(this.type))return t;!n&&r.type.rank>this.type.rank&&(e||(e=t.slice(0,o)),e.push(this),n=!0),e&&e.push(r)}}return e||(e=t.slice()),n||e.push(this),e}removeFromSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return t.slice(0,e).concat(t.slice(e+1));return t}isInSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return!0;return!1}eq(t){return this==t||this.type==t.type&&C(this.attrs,t.attrs)}toJSON(){let t={type:this.type.name};for(let e in this.attrs){t.attrs=this.attrs;break}return t}static fromJSON(t,e){if(!e)throw new RangeError("Invalid input for Mark.fromJSON");let n=t.marks[e.type];if(!n)throw new RangeError(`There is no mark type ${e.type} in this schema`);let o=n.create(e.attrs);return n.checkAttrs(o.attrs),o}static sameSet(t,e){if(t==e)return!0;if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].eq(e[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&0==t.length)return S.none;if(t instanceof S)return[t];let e=t.slice();return e.sort((t,e)=>t.type.rank-e.type.rank),e}}S.none=[];class T extends Error{}class A{constructor(t,e,n){this.content=t,this.openStart=e,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,e){let n=N(this.content,t+this.openStart,e);return n&&new A(n,this.openStart,this.openEnd)}removeBetween(t,e){return new A(E(this.content,t+this.openStart,e+this.openStart),this.openStart,this.openEnd)}eq(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let t={content:this.content.toJSON()};return this.openStart>0&&(t.openStart=this.openStart),this.openEnd>0&&(t.openEnd=this.openEnd),t}static fromJSON(t,e){if(!e)return A.empty;let 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 A(k.fromJSON(t,e.content),n,o)}static maxOpen(t,e=!0){let n=0,o=0;for(let o=t.firstChild;o&&!o.isLeaf&&(e||!o.type.spec.isolating);o=o.firstChild)n++;for(let n=t.lastChild;n&&!n.isLeaf&&(e||!n.type.spec.isolating);n=n.lastChild)o++;return new A(t,n,o)}}function E(t,e,n){let{index:o,offset:r}=t.findIndex(e),i=t.maybeChild(o),{index:s,offset:a}=t.findIndex(n);if(r==e||i.isText){if(a!=n&&!t.child(s).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(o!=s)throw new RangeError("Removing non-flat range");return t.replaceChild(o,i.copy(E(i.content,e-r-1,n-r-1)))}function N(t,e,n,o){let{index:r,offset:i}=t.findIndex(e),s=t.maybeChild(r);if(i==e||s.isText)return o&&!o.canReplace(r,r,n)?null:t.cut(0,e).append(n).append(t.cut(e));let a=N(s.content,e-i-1,n,s);return a&&t.replaceChild(r,s.copy(a))}function O(t,e,n){if(n.openStart>t.depth)throw new T("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new T("Inconsistent open depths");return L(t,e,n,0)}function L(t,e,n,o){let r=t.index(o),i=t.node(o);if(r==e.index(o)&&o<t.depth-n.openStart){let s=L(t,e,n,o+1);return i.copy(i.content.replaceChild(r,s))}if(n.content.size){if(n.openStart||n.openEnd||t.depth!=o||e.depth!=o){let{start:r,end:s}=function(t,e){let n=e.depth-t.openStart,o=e.node(n).copy(t.content);for(let t=n-1;t>=0;t--)o=e.node(t).copy(k.from(o));return{start:o.resolveNoCache(t.openStart+n),end:o.resolveNoCache(o.content.size-t.openEnd-n)}}(n,t);return z(i,$(t,r,s,e,o))}{let o=t.parent,r=o.content;return z(o,r.cut(0,t.parentOffset).append(n.content).append(r.cut(e.parentOffset)))}}return z(i,P(t,e,o))}function R(t,e){if(!e.type.compatibleContent(t.type))throw new T("Cannot join "+e.type.name+" onto "+t.type.name)}function D(t,e,n){let o=t.node(n);return R(o,e.node(n)),o}function j(t,e){let 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 I(t,e,n,o){let r=(e||t).node(n),i=0,s=e?e.index(n):r.childCount;t&&(i=t.index(n),t.depth>n?i++:t.textOffset&&(j(t.nodeAfter,o),i++));for(let t=i;t<s;t++)j(r.child(t),o);e&&e.depth==n&&e.textOffset&&j(e.nodeBefore,o)}function z(t,e){return t.type.checkContent(e),t.copy(e)}function $(t,e,n,o,r){let i=t.depth>r&&D(t,e,r+1),s=o.depth>r&&D(n,o,r+1),a=[];return I(null,t,r,a),i&&s&&e.index(r)==n.index(r)?(R(i,s),j(z(i,$(t,e,n,o,r+1)),a)):(i&&j(z(i,P(t,e,r+1)),a),I(e,n,r,a),s&&j(z(s,P(n,o,r+1)),a)),I(o,null,r,a),new k(a)}function P(t,e,n){let o=[];return I(null,t,n,o),t.depth>n&&j(z(D(t,e,n+1),P(t,e,n+1)),o),I(e,null,n,o),new k(o)}A.empty=new A(k.empty,0,0);class H{constructor(t,e,n){this.pos=t,this.path=e,this.parentOffset=n,this.depth=e.length/3-1}resolveDepth(t){return null==t?this.depth:t<0?this.depth+t:t}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(t){return this.path[3*this.resolveDepth(t)]}index(t){return this.path[3*this.resolveDepth(t)+1]}indexAfter(t){return t=this.resolveDepth(t),this.index(t)+(t!=this.depth||this.textOffset?1:0)}start(t){return 0==(t=this.resolveDepth(t))?0:this.path[3*t-1]+1}end(t){return t=this.resolveDepth(t),this.start(t)+this.node(t).content.size}before(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]}after(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}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let t=this.parent,e=this.index(this.depth);if(e==t.childCount)return null;let n=this.pos-this.path[this.path.length-1],o=t.child(e);return n?t.child(e).cut(n):o}get nodeBefore(){let 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)}posAtIndex(t,e){e=this.resolveDepth(e);let n=this.path[3*e],o=0==e?0:this.path[3*e-1]+1;for(let e=0;e<t;e++)o+=n.child(e).nodeSize;return o}marks(){let t=this.parent,e=this.index();if(0==t.content.size)return S.none;if(this.textOffset)return t.child(e).marks;let n=t.maybeChild(e-1),o=t.maybeChild(e);if(!n){let t=n;n=o,o=t}let r=n.marks;for(var i=0;i<r.length;i++)!1!==r[i].type.spec.inclusive||o&&r[i].isInSet(o.marks)||(r=r[i--].removeFromSet(r));return r}marksAcross(t){let e=this.parent.maybeChild(this.index());if(!e||!e.isInline)return null;let n=e.marks,o=t.parent.maybeChild(t.index());for(var r=0;r<n.length;r++)!1!==n[r].type.spec.inclusive||o&&n[r].isInSet(o.marks)||(n=n[r--].removeFromSet(n));return n}sharedDepth(t){for(let e=this.depth;e>0;e--)if(this.start(e)<=t&&this.end(e)>=t)return e;return 0}blockRange(t=this,e){if(t.pos<this.pos)return t.blockRange(this);for(let 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 F(this,t,n);return null}sameParent(t){return this.pos-this.parentOffset==t.pos-t.parentOffset}max(t){return t.pos>this.pos?t:this}min(t){return t.pos<this.pos?t:this}toString(){let t="";for(let e=1;e<=this.depth;e++)t+=(t?"/":"")+this.node(e).type.name+"_"+this.index(e-1);return t+":"+this.parentOffset}static resolve(t,e){if(!(e>=0&&e<=t.content.size))throw new RangeError("Position "+e+" out of range");let n=[],o=0,r=e;for(let e=t;;){let{index:t,offset:i}=e.content.findIndex(r),s=r-i;if(n.push(e,t,o+i),!s)break;if(e=e.child(t),e.isText)break;r=s-1,o+=i+1}return new H(e,n,r)}static resolveCached(t,e){let n=V.get(t);if(n)for(let t=0;t<n.elts.length;t++){let o=n.elts[t];if(o.pos==e)return o}else V.set(t,n=new B);let o=n.elts[n.i]=H.resolve(t,e);return n.i=(n.i+1)%_,o}}class B{constructor(){this.elts=[],this.i=0}}const _=12,V=new WeakMap;class F{constructor(t,e,n){this.$from=t,this.$to=e,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const W=Object.create(null);class K{constructor(t,e,n,o=S.none){this.type=t,this.attrs=e,this.marks=o,this.content=n||k.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(t){return this.content.child(t)}maybeChild(t){return this.content.maybeChild(t)}forEach(t){this.content.forEach(t)}nodesBetween(t,e,n,o=0){this.content.nodesBetween(t,e,n,o,this)}descendants(t){this.nodesBetween(0,this.content.size,t)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(t,e,n,o){return this.content.textBetween(t,e,n,o)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(t){return this==t||this.sameMarkup(t)&&this.content.eq(t.content)}sameMarkup(t){return this.hasMarkup(t.type,t.attrs,t.marks)}hasMarkup(t,e,n){return this.type==t&&C(this.attrs,e||t.defaultAttrs||W)&&S.sameSet(this.marks,n||S.none)}copy(t=null){return t==this.content?this:new K(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new K(this.type,this.attrs,this.content,t)}cut(t,e=this.content.size){return 0==t&&e==this.content.size?this:this.copy(this.content.cut(t,e))}slice(t,e=this.content.size,n=!1){if(t==e)return A.empty;let o=this.resolve(t),r=this.resolve(e),i=n?0:o.sharedDepth(e),s=o.start(i),a=o.node(i).content.cut(o.pos-s,r.pos-s);return new A(a,o.depth-i,r.depth-i)}replace(t,e,n){return O(this.resolve(t),this.resolve(e),n)}nodeAt(t){for(let e=this;;){let{index:n,offset:o}=e.content.findIndex(t);if(e=e.maybeChild(n),!e)return null;if(o==t||e.isText)return e;t-=o+1}}childAfter(t){let{index:e,offset:n}=this.content.findIndex(t);return{node:this.content.maybeChild(e),index:e,offset:n}}childBefore(t){if(0==t)return{node:null,index:0,offset:0};let{index:e,offset:n}=this.content.findIndex(t);if(n<t)return{node:this.content.child(e),index:e,offset:n};let o=this.content.child(e-1);return{node:o,index:e-1,offset:n-o.nodeSize}}resolve(t){return H.resolveCached(this,t)}resolveNoCache(t){return H.resolve(this,t)}rangeHasMark(t,e,n){let o=!1;return e>t&&this.nodesBetween(t,e,t=>(n.isInSet(t.marks)&&(o=!0),!o)),o}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let t=this.type.name;return this.content.size&&(t+="("+this.content.toStringInner()+")"),U(this.marks,t)}contentMatchAt(t){let e=this.type.contentMatch.matchFragment(this.content,0,t);if(!e)throw new Error("Called contentMatchAt on a node with invalid content");return e}canReplace(t,e,n=k.empty,o=0,r=n.childCount){let i=this.contentMatchAt(t).matchFragment(n,o,r),s=i&&i.matchFragment(this.content,e);if(!s||!s.validEnd)return!1;for(let t=o;t<r;t++)if(!this.type.allowsMarks(n.child(t).marks))return!1;return!0}canReplaceWith(t,e,n,o){if(o&&!this.type.allowsMarks(o))return!1;let r=this.contentMatchAt(t).matchType(n),i=r&&r.matchFragment(this.content,e);return!!i&&i.validEnd}canAppend(t){return t.content.size?this.canReplace(this.childCount,this.childCount,t.content):this.type.compatibleContent(t.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let t=S.none;for(let e=0;e<this.marks.length;e++){let n=this.marks[e];n.type.checkAttrs(n.attrs),t=n.addToSet(t)}if(!S.sameSet(t,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let t={type:this.type.name};for(let 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(t=>t.toJSON())),t}static fromJSON(t,e){if(!e)throw new RangeError("Invalid input for Node.fromJSON");let n;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)}let o=k.fromJSON(t,e.content),r=t.nodeType(e.type).create(e.attrs,o,n);return r.type.checkAttrs(r.attrs),r}}K.prototype.text=void 0;class q extends K{constructor(t,e,n,o){if(super(t,e,null,o),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):U(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(t,e){return this.text.slice(t,e)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new q(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new q(this.type,this.attrs,t,this.marks)}cut(t=0,e=this.text.length){return 0==t&&e==this.text.length?this:this.withText(this.text.slice(t,e))}eq(t){return this.sameMarkup(t)&&this.text==t.text}toJSON(){let t=super.toJSON();return t.text=this.text,t}}function U(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class J{constructor(t){this.validEnd=t,this.next=[],this.wrapCache=[]}static parse(t,e){let n=new G(t,e);if(null==n.next)return J.empty;let o=Y(n);n.next&&n.err("Unexpected trailing text");let r=function(t){let e=Object.create(null);return function n(o){let r=[];o.forEach(e=>{t[e].forEach(({term:e,to:n})=>{if(!e)return;let o;for(let t=0;t<r.length;t++)r[t][0]==e&&(o=r[t][1]);nt(t,n).forEach(t=>{o||r.push([e,o=[]]),-1==o.indexOf(t)&&o.push(t)})})});let i=e[o.join(",")]=new J(o.indexOf(t.length-1)>-1);for(let t=0;t<r.length;t++){let o=r[t][1].sort(et);i.next.push({type:r[t][0],next:e[o.join(",")]||n(o)})}return i}(nt(t,0))}(function(t){let e=[[]];return r(function t(e,i){if("choice"==e.type)return e.exprs.reduce((e,n)=>e.concat(t(n,i)),[]);if("seq"!=e.type){if("star"==e.type){let s=n();return o(i,s),r(t(e.expr,s),s),[o(s)]}if("plus"==e.type){let s=n();return r(t(e.expr,i),s),r(t(e.expr,s),s),[o(s)]}if("opt"==e.type)return[o(i)].concat(t(e.expr,i));if("range"==e.type){let s=i;for(let o=0;o<e.min;o++){let o=n();r(t(e.expr,s),o),s=o}if(-1==e.max)r(t(e.expr,s),s);else for(let i=e.min;i<e.max;i++){let i=n();o(s,i),r(t(e.expr,s),i),s=i}return[o(s)]}if("name"==e.type)return[o(i,void 0,e.value)];throw new Error("Unknown expr type")}for(let o=0;;o++){let s=t(e.exprs[o],i);if(o==e.exprs.length-1)return s;r(s,i=n())}}(t,0),n()),e;function n(){return e.push([])-1}function o(t,n,o){let r={term:o,to:n};return e[t].push(r),r}function r(t,e){t.forEach(t=>t.to=e)}}(o));return function(t,e){for(let n=0,o=[t];n<o.length;n++){let t=o[n],r=!t.validEnd,i=[];for(let e=0;e<t.next.length;e++){let{type:n,next:s}=t.next[e];i.push(n.name),!r||n.isText||n.hasRequiredAttrs()||(r=!1),-1==o.indexOf(s)&&o.push(s)}r&&e.err("Only non-generatable nodes ("+i.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(r,n),r}matchType(t){for(let e=0;e<this.next.length;e++)if(this.next[e].type==t)return this.next[e].next;return null}matchFragment(t,e=0,n=t.childCount){let o=this;for(let r=e;o&&r<n;r++)o=o.matchType(t.child(r).type);return o}get inlineContent(){return 0!=this.next.length&&this.next[0].type.isInline}get defaultType(){for(let t=0;t<this.next.length;t++){let{type:e}=this.next[t];if(!e.isText&&!e.hasRequiredAttrs())return e}return null}compatible(t){for(let e=0;e<this.next.length;e++)for(let n=0;n<t.next.length;n++)if(this.next[e].type==t.next[n].type)return!0;return!1}fillBefore(t,e=!1,n=0){let o=[this];return function r(i,s){let a=i.matchFragment(t,n);if(a&&(!e||a.validEnd))return k.from(s.map(t=>t.createAndFill()));for(let t=0;t<i.next.length;t++){let{type:e,next:n}=i.next[t];if(!e.isText&&!e.hasRequiredAttrs()&&-1==o.indexOf(n)){o.push(n);let t=r(n,s.concat(e));if(t)return t}}return null}(this,[])}findWrapping(t){for(let e=0;e<this.wrapCache.length;e+=2)if(this.wrapCache[e]==t)return this.wrapCache[e+1];let e=this.computeWrapping(t);return this.wrapCache.push(t,e),e}computeWrapping(t){let e=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let o=n.shift(),r=o.match;if(r.matchType(t)){let t=[];for(let e=o;e.type;e=e.via)t.push(e.type);return t.reverse()}for(let t=0;t<r.next.length;t++){let{type:i,next:s}=r.next[t];i.isLeaf||i.hasRequiredAttrs()||i.name in e||o.type&&!s.validEnd||(n.push({match:i.contentMatch,type:i,via:o}),e[i.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(t){if(t>=this.next.length)throw new RangeError(`There's no ${t}th edge in this content match`);return this.next[t]}toString(){let t=[];return function e(n){t.push(n);for(let o=0;o<n.next.length;o++)-1==t.indexOf(n.next[o].next)&&e(n.next[o].next)}(this),t.map((e,n)=>{let o=n+(e.validEnd?"*":" ")+" ";for(let n=0;n<e.next.length;n++)o+=(n?", ":"")+e.next[n].type.name+"->"+t.indexOf(e.next[n].next);return o}).join("\n")}}J.empty=new J(!0);class G{constructor(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()}get next(){return this.tokens[this.pos]}eat(t){return this.next==t&&(this.pos++||!0)}err(t){throw new SyntaxError(t+" (in content expression '"+this.string+"')")}}function Y(t){let e=[];do{e.push(X(t))}while(t.eat("|"));return 1==e.length?e[0]:{type:"choice",exprs:e}}function X(t){let e=[];do{e.push(Q(t))}while(t.next&&")"!=t.next&&"|"!=t.next);return 1==e.length?e[0]:{type:"seq",exprs:e}}function Q(t){let e=function(t){if(t.eat("(")){let e=Y(t);return t.eat(")")||t.err("Missing closing paren"),e}if(!/\W/.test(t.next)){let e=function(t,e){let n=t.nodeTypes,o=n[e];if(o)return[o];let r=[];for(let t in n){let o=n[t];o.isInGroup(e)&&r.push(o)}return 0==r.length&&t.err("No node type or group '"+e+"' found"),r}(t,t.next).map(e=>(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==e.length?e[0]:{type:"choice",exprs:e}}t.err("Unexpected token '"+t.next+"'")}(t);for(;;)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=tt(t,e)}return e}function Z(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function tt(t,e){let n=Z(t),o=n;return t.eat(",")&&(o="}"!=t.next?Z(t):-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:o,expr:e}}function et(t,e){return e-t}function nt(t,e){let n=[];return function e(o){let r=t[o];if(1==r.length&&!r[0].term)return e(r[0].to);n.push(o);for(let t=0;t<r.length;t++){let{term:o,to:i}=r[t];o||-1!=n.indexOf(i)||e(i)}}(e),n.sort(et)}function ot(t){let e=Object.create(null);for(let n in t){let o=t[n];if(!o.hasDefault)return null;e[n]=o.default}return e}function rt(t,e){let n=Object.create(null);for(let o in t){let r=e&&e[o];if(void 0===r){let e=t[o];if(!e.hasDefault)throw new RangeError("No value supplied for attribute "+o);r=e.default}n[o]=r}return n}function it(t,e,n,o){for(let o in e)if(!(o in t))throw new RangeError(`Unsupported attribute ${o} for ${n} of type ${o}`);for(let n in t){let o=t[n];o.validate&&o.validate(e[n])}}function st(t,e){let n=Object.create(null);if(e)for(let o in e)n[o]=new lt(t,o,e[o]);return n}class at{constructor(t,e,n){this.name=t,this.schema=e,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(" "):[],this.attrs=st(t,n.attrs),this.defaultAttrs=ot(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||"text"==t),this.isText="text"==t}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==J.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(t){return this.groups.indexOf(t)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let t in this.attrs)if(this.attrs[t].isRequired)return!0;return!1}compatibleContent(t){return this==t||this.contentMatch.compatible(t.contentMatch)}computeAttrs(t){return!t&&this.defaultAttrs?this.defaultAttrs:rt(this.attrs,t)}create(t=null,e,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new K(this,this.computeAttrs(t),k.from(e),S.setFrom(n))}createChecked(t=null,e,n){return e=k.from(e),this.checkContent(e),new K(this,this.computeAttrs(t),e,S.setFrom(n))}createAndFill(t=null,e,n){if(t=this.computeAttrs(t),(e=k.from(e)).size){let t=this.contentMatch.fillBefore(e);if(!t)return null;e=t.append(e)}let o=this.contentMatch.matchFragment(e),r=o&&o.fillBefore(k.empty,!0);return r?new K(this,t,e.append(r),S.setFrom(n)):null}validContent(t){let e=this.contentMatch.matchFragment(t);if(!e||!e.validEnd)return!1;for(let e=0;e<t.childCount;e++)if(!this.allowsMarks(t.child(e).marks))return!1;return!0}checkContent(t){if(!this.validContent(t))throw new RangeError(`Invalid content for node ${this.name}: ${t.toString().slice(0,50)}`)}checkAttrs(t){it(this.attrs,t,"node",this.name)}allowsMarkType(t){return null==this.markSet||this.markSet.indexOf(t)>-1}allowsMarks(t){if(null==this.markSet)return!0;for(let e=0;e<t.length;e++)if(!this.allowsMarkType(t[e].type))return!1;return!0}allowedMarks(t){if(null==this.markSet)return t;let e;for(let 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:S.none:t}static compile(t,e){let n=Object.create(null);t.forEach((t,o)=>n[t]=new at(t,e,o));let o=e.spec.topNode||"doc";if(!n[o])throw new RangeError("Schema is missing its top node type ('"+o+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(let t in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n}}class lt{constructor(t,e,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate="string"==typeof n.validate?function(t,e,n){let o=n.split("|");return n=>{let r=null===n?"null":typeof n;if(o.indexOf(r)<0)throw new RangeError(`Expected value of type ${o} for attribute ${e} on type ${t}, got ${r}`)}}(t,e,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class ct{constructor(t,e,n,o){this.name=t,this.rank=e,this.schema=n,this.spec=o,this.attrs=st(t,o.attrs),this.excluded=null;let r=ot(this.attrs);this.instance=r?new S(this,r):null}create(t=null){return!t&&this.instance?this.instance:new S(this,rt(this.attrs,t))}static compile(t,e){let n=Object.create(null),o=0;return t.forEach((t,r)=>n[t]=new ct(t,o++,e,r)),n}removeFromSet(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}isInSet(t){for(let e=0;e<t.length;e++)if(t[e].type==this)return t[e]}checkAttrs(t){it(this.attrs,t,"mark",this.name)}excludes(t){return this.excluded.indexOf(t)>-1}}class dt{constructor(t){this.linebreakReplacement=null,this.cached=Object.create(null);let e=this.spec={};for(let n in t)e[n]=t[n];e.nodes=b.from(t.nodes),e.marks=b.from(t.marks||{}),this.nodes=at.compile(this.spec.nodes,this),this.marks=ct.compile(this.spec.marks,this);let n=Object.create(null);for(let t in this.nodes){if(t in this.marks)throw new RangeError(t+" can not be both a node and a mark");let e=this.nodes[t],o=e.spec.content||"",r=e.spec.marks;if(e.contentMatch=n[o]||(n[o]=J.parse(o,this.nodes)),e.inlineContent=e.contentMatch.inlineContent,e.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!e.isInline||!e.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=e}e.markSet="_"==r?null:r?ht(this,r.split(" ")):""!=r&&e.inlineContent?null:[]}for(let t in this.marks){let e=this.marks[t],n=e.spec.excludes;e.excluded=null==n?[e]:""==n?[]:ht(this,n.split(" "))}this.nodeFromJSON=t=>K.fromJSON(this,t),this.markFromJSON=t=>S.fromJSON(this,t),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(t,e=null,n,o){if("string"==typeof t)t=this.nodeType(t);else{if(!(t instanceof at))throw new RangeError("Invalid node type: "+t);if(t.schema!=this)throw new RangeError("Node type from different schema used ("+t.name+")")}return t.createChecked(e,n,o)}text(t,e){let n=this.nodes.text;return new q(n,n.defaultAttrs,t,S.setFrom(e))}mark(t,e){return"string"==typeof t&&(t=this.marks[t]),t.create(e)}nodeType(t){let e=this.nodes[t];if(!e)throw new RangeError("Unknown node type: "+t);return e}}function ht(t,e){let n=[];for(let o=0;o<e.length;o++){let r=e[o],i=t.marks[r],s=i;if(i)n.push(i);else for(let e in t.marks){let o=t.marks[e];("_"==r||o.spec.group&&o.spec.group.split(" ").indexOf(r)>-1)&&n.push(s=o)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[o]+"'")}return n}class pt{constructor(t,e){this.schema=t,this.rules=e,this.tags=[],this.styles=[];let n=this.matchedStyles=[];e.forEach(t=>{if(function(t){return null!=t.tag}(t))this.tags.push(t);else if(function(t){return null!=t.style}(t)){let e=/[^=]*/.exec(t.style)[0];n.indexOf(e)<0&&n.push(e),this.styles.push(t)}}),this.normalizeLists=!this.tags.some(e=>{if(!/^(ul|ol)\b/.test(e.tag)||!e.node)return!1;let n=t.nodes[e.node];return n.contentMatch.matchType(n)})}parse(t,e={}){let n=new bt(this,e,!1);return n.addAll(t,S.none,e.from,e.to),n.finish()}parseSlice(t,e={}){let n=new bt(this,e,!0);return n.addAll(t,S.none,e.from,e.to),A.maxOpen(n.finish())}matchTag(t,e,n){for(let o=n?this.tags.indexOf(n)+1:0;o<this.tags.length;o++){let n=this.tags[o];if(vt(t,n.tag)&&(void 0===n.namespace||t.namespaceURI==n.namespace)&&(!n.context||e.matchesContext(n.context))){if(n.getAttrs){let e=n.getAttrs(t);if(!1===e)continue;n.attrs=e||void 0}return n}}}matchStyle(t,e,n,o){for(let r=o?this.styles.indexOf(o)+1:0;r<this.styles.length;r++){let o=this.styles[r],i=o.style;if(!(0!=i.indexOf(t)||o.context&&!n.matchesContext(o.context)||i.length>t.length&&(61!=i.charCodeAt(t.length)||i.slice(t.length+1)!=e))){if(o.getAttrs){let t=o.getAttrs(e);if(!1===t)continue;o.attrs=t||void 0}return o}}}static schemaRules(t){let e=[];function n(t){let n=null==t.priority?50:t.priority,o=0;for(;o<e.length;o++){let t=e[o];if((null==t.priority?50:t.priority)<n)break}e.splice(o,0,t)}for(let e in t.marks){let o=t.marks[e].spec.parseDOM;o&&o.forEach(t=>{n(t=wt(t)),t.mark||t.ignore||t.clearMark||(t.mark=e)})}for(let e in t.nodes){let o=t.nodes[e].spec.parseDOM;o&&o.forEach(t=>{n(t=wt(t)),t.node||t.ignore||t.mark||(t.node=e)})}return e}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new pt(t,pt.schemaRules(t)))}}const ut={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},ft={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},mt={ol:!0,ul:!0};function gt(t,e,n){return null!=e?(e?1:0)|("full"===e?2:0):t&&"pre"==t.whitespace?3:-5&n}class yt{constructor(t,e,n,o,r,i){this.type=t,this.attrs=e,this.marks=n,this.solid=o,this.options=i,this.content=[],this.activeMarks=S.none,this.match=r||(4&i?null:t.contentMatch)}findWrapping(t){if(!this.match){if(!this.type)return[];let e=this.type.contentMatch.fillBefore(k.from(t));if(!e){let e,n=this.type.contentMatch;return(e=n.findWrapping(t.type))?(this.match=n,e):null}this.match=this.type.contentMatch.matchFragment(e)}return this.match.findWrapping(t.type)}finish(t){if(!(1&this.options)){let t,e=this.content[this.content.length-1];if(e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))){let n=e;e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-t[0].length))}}let e=k.from(this.content);return!t&&this.match&&(e=e.append(this.match.fillBefore(k.empty,!0))),this.type?this.type.create(this.attrs,e,this.marks):e}inlineContext(t){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:t.parentNode&&!ut.hasOwnProperty(t.parentNode.nodeName.toLowerCase())}}class bt{constructor(t,e,n){this.parser=t,this.options=e,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let o,r=e.topNode,i=gt(null,e.preserveWhitespace,0)|(n?4:0);o=r?new yt(r.type,r.attrs,S.none,!0,e.topMatch||r.type.contentMatch,i):new yt(n?null:t.schema.topNodeType,null,S.none,!0,null,i),this.nodes=[o],this.find=e.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(t,e){3==t.nodeType?this.addTextNode(t,e):1==t.nodeType&&this.addElement(t,e)}addTextNode(t,e){let n=t.nodeValue,o=this.top,r=2&o.options?"full":this.localPreserveWS||(1&o.options)>0;if("full"===r||o.inlineContext(t)||/[^ \t\r\n\u000c]/.test(n)){if(r)n="full"!==r?n.replace(/\r?\n|\r/g," "):n.replace(/\r\n?/g,"\n");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let e=o.content[o.content.length-1],r=t.previousSibling;(!e||r&&"BR"==r.nodeName||e.isText&&/[ \t\r\n\u000c]$/.test(e.text))&&(n=n.slice(1))}n&&this.insertNode(this.parser.schema.text(n),e,!/\S/.test(n)),this.findInText(t)}else this.findInside(t)}addElement(t,e,n){let o=this.localPreserveWS,r=this.top;("PRE"==t.tagName||/pre/.test(t.style&&t.style.whiteSpace))&&(this.localPreserveWS=!0);let i,s=t.nodeName.toLowerCase();mt.hasOwnProperty(s)&&this.parser.normalizeLists&&function(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let t=1==e.nodeType?e.nodeName.toLowerCase():null;t&&mt.hasOwnProperty(t)&&n?(n.appendChild(e),e=n):"li"==t?n=e:t&&(n=null)}}(t);let a=this.options.ruleFromNode&&this.options.ruleFromNode(t)||(i=this.parser.matchTag(t,this,n));t:if(a?a.ignore:ft.hasOwnProperty(s))this.findInside(t),this.ignoreFallback(t,e);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(t=a.skip);let n,o=this.needsBlock;if(ut.hasOwnProperty(s))r.content.length&&r.content[0].isInline&&this.open&&(this.open--,r=this.top),n=!0,r.type||(this.needsBlock=!0);else if(!t.firstChild){this.leafFallback(t,e);break t}let i=a&&a.skip?e:this.readStyles(t,e);i&&this.addAll(t,i),n&&this.sync(r),this.needsBlock=o}else{let n=this.readStyles(t,e);n&&this.addElementByRule(t,a,n,!1===a.consuming?i:void 0)}this.localPreserveWS=o}leafFallback(t,e){"BR"==t.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(t.ownerDocument.createTextNode("\n"),e)}ignoreFallback(t,e){"BR"!=t.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"),e,!0)}readStyles(t,e){let n=t.style;if(n&&n.length)for(let t=0;t<this.parser.matchedStyles.length;t++){let o=this.parser.matchedStyles[t],r=n.getPropertyValue(o);if(r)for(let t;;){let n=this.parser.matchStyle(o,r,this,t);if(!n)break;if(n.ignore)return null;if(e=n.clearMark?e.filter(t=>!n.clearMark(t)):e.concat(this.parser.schema.marks[n.mark].create(n.attrs)),!1!==n.consuming)break;t=n}}return e}addElementByRule(t,e,n,o){let r,i;if(e.node)if(i=this.parser.schema.nodes[e.node],i.isLeaf)this.insertNode(i.create(e.attrs),n,"BR"==t.nodeName)||this.leafFallback(t,n);else{let t=this.enter(i,e.attrs||null,n,e.preserveWhitespace);t&&(r=!0,n=t)}else{let t=this.parser.schema.marks[e.mark];n=n.concat(t.create(e.attrs))}let s=this.top;if(i&&i.isLeaf)this.findInside(t);else if(o)this.addElement(t,n,o);else if(e.getContent)this.findInside(t),e.getContent(t,this.parser.schema).forEach(t=>this.insertNode(t,n,!1));else{let o=t;"string"==typeof e.contentElement?o=t.querySelector(e.contentElement):"function"==typeof e.contentElement?o=e.contentElement(t):e.contentElement&&(o=e.contentElement),this.findAround(t,o,!0),this.addAll(o,n),this.findAround(t,o,!1)}r&&this.sync(s)&&this.open--}addAll(t,e,n,o){let r=n||0;for(let i=n?t.childNodes[n]:t.firstChild,s=null==o?null:t.childNodes[o];i!=s;i=i.nextSibling,++r)this.findAtPoint(t,r),this.addDOM(i,e);this.findAtPoint(t,r)}findPlace(t,e,n){let o,r;for(let e=this.open,i=0;e>=0;e--){let s=this.nodes[e],a=s.findWrapping(t);if(a&&(!o||o.length>a.length+i)&&(o=a,r=s,!a.length))break;if(s.solid){if(n)break;i+=2}}if(!o)return null;this.sync(r);for(let t=0;t<o.length;t++)e=this.enterInner(o[t],null,e,!1);return e}insertNode(t,e,n){if(t.isInline&&this.needsBlock&&!this.top.type){let t=this.textblockFromContext();t&&(e=this.enterInner(t,null,e))}let o=this.findPlace(t,e,n);if(o){this.closeExtra();let e=this.top;e.match&&(e.match=e.match.matchType(t.type));let n=S.none;for(let r of o.concat(t.marks))(e.type?e.type.allowsMarkType(r.type):kt(r.type,t.type))&&(n=r.addToSet(n));return e.content.push(t.mark(n)),!0}return!1}enter(t,e,n,o){let r=this.findPlace(t.create(e),n,!1);return r&&(r=this.enterInner(t,e,n,!0,o)),r}enterInner(t,e,n,o=!1,r){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(t);let s=gt(t,r,i.options);4&i.options&&0==i.content.length&&(s|=4);let a=S.none;return n=n.filter(e=>!(i.type?i.type.allowsMarkType(e.type):kt(e.type,t))||(a=e.addToSet(a),!1)),this.nodes.push(new yt(t,e,a,o,null,s)),this.open++,n}closeExtra(t=!1){let 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}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!(!this.isOpen&&!this.options.topOpen))}sync(t){for(let e=this.open;e>=0;e--){if(this.nodes[e]==t)return this.open=e,!0;this.localPreserveWS&&(this.nodes[e].options|=1)}return!1}get currentPos(){this.closeExtra();let t=0;for(let e=this.open;e>=0;e--){let n=this.nodes[e].content;for(let e=n.length-1;e>=0;e--)t+=n[e].nodeSize;e&&t++}return t}findAtPoint(t,e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==t&&this.find[n].offset==e&&(this.find[n].pos=this.currentPos)}findInside(t){if(this.find)for(let 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)}findAround(t,e,n){if(t!=e&&this.find)for(let o=0;o<this.find.length;o++)null==this.find[o].pos&&1==t.nodeType&&t.contains(this.find[o].node)&&e.compareDocumentPosition(this.find[o].node)&(n?2:4)&&(this.find[o].pos=this.currentPos)}findInText(t){if(this.find)for(let 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))}matchesContext(t){if(t.indexOf("|")>-1)return t.split(/\s*\|\s*/).some(this.matchesContext,this);let e=t.split("/"),n=this.options.context,o=!(this.isOpen||n&&n.parent.type!=this.nodes[0].type),r=-(n?n.depth+1:0)+(o?0:1),i=(t,s)=>{for(;t>=0;t--){let a=e[t];if(""==a){if(t==e.length-1||0==t)continue;for(;s>=r;s--)if(i(t-1,s))return!0;return!1}{let t=s>0||0==s&&o?this.nodes[s].type:n&&s>=r?n.node(s-r).type:null;if(!t||t.name!=a&&!t.isInGroup(a))return!1;s--}}return!0};return i(e.length-1,this.open)}textblockFromContext(){let t=this.options.context;if(t)for(let e=t.depth;e>=0;e--){let n=t.node(e).contentMatchAt(t.indexAfter(e)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let t in this.parser.schema.nodes){let e=this.parser.schema.nodes[t];if(e.isTextblock&&e.defaultAttrs)return e}}}function vt(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function wt(t){let e={};for(let n in t)e[n]=t[n];return e}function kt(t,e){let n=e.schema.nodes;for(let o in n){let r=n[o];if(!r.allowsMarkType(t))continue;let i=[],s=t=>{i.push(t);for(let n=0;n<t.edgeCount;n++){let{type:o,next:r}=t.edge(n);if(o==e)return!0;if(i.indexOf(r)<0&&s(r))return!0}};if(s(r.contentMatch))return!0}}class xt{constructor(t,e){this.nodes=t,this.marks=e}serializeFragment(t,e={},n){n||(n=Ct(e).createDocumentFragment());let o=n,r=[];return t.forEach(t=>{if(r.length||t.marks.length){let n=0,i=0;for(;n<r.length&&i<t.marks.length;){let e=t.marks[i];if(this.marks[e.type.name]){if(!e.eq(r[n][0])||!1===e.type.spec.spanning)break;n++,i++}else i++}for(;n<r.length;)o=r.pop()[1];for(;i<t.marks.length;){let n=t.marks[i++],s=this.serializeMark(n,t.isInline,e);s&&(r.push([n,o]),o.appendChild(s.dom),o=s.contentDOM||s.dom)}}o.appendChild(this.serializeNodeInner(t,e))}),n}serializeNodeInner(t,e){let{dom:n,contentDOM:o}=Tt(Ct(e),this.nodes[t.type.name](t),null,t.attrs);if(o){if(t.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(t.content,e,o)}return n}serializeNode(t,e={}){let n=this.serializeNodeInner(t,e);for(let o=t.marks.length-1;o>=0;o--){let r=this.serializeMark(t.marks[o],t.isInline,e);r&&((r.contentDOM||r.dom).appendChild(n),n=r.dom)}return n}serializeMark(t,e,n={}){let o=this.marks[t.type.name];return o&&Tt(Ct(n),o(t,e),null,t.attrs)}static renderSpec(t,e,n=null,o){return Tt(t,e,n,o)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new xt(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(t){let e=Mt(t.nodes);return e.text||(e.text=t=>t.text),e}static marksFromSchema(t){return Mt(t.marks)}}function Mt(t){let e={};for(let n in t){let o=t[n].spec.toDOM;o&&(e[n]=o)}return e}function Ct(t){return t.document||window.document}const St=new WeakMap;function Tt(t,e,n,o){if("string"==typeof e)return{dom:t.createTextNode(e)};if(null!=e.nodeType)return{dom:e};if(e.dom&&null!=e.dom.nodeType)return e;let r,i=e[0];if("string"!=typeof i)throw new RangeError("Invalid array passed to renderSpec");if(o&&(r=function(t){let e=St.get(t);return void 0===e&&St.set(t,e=function(t){let e=null;return function t(n){if(n&&"object"==typeof n)if(Array.isArray(n))if("string"==typeof n[0])e||(e=[]),e.push(n);else for(let e=0;e<n.length;e++)t(n[e]);else for(let e in n)t(n[e])}(t),e}(t)),e}(o))&&r.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let s,a=i.indexOf(" ");a>0&&(n=i.slice(0,a),i=i.slice(a+1));let l=n?t.createElementNS(n,i):t.createElement(i),c=e[1],d=1;if(c&&"object"==typeof c&&null==c.nodeType&&!Array.isArray(c)){d=2;for(let t in c)if(null!=c[t]){let e=t.indexOf(" ");e>0?l.setAttributeNS(t.slice(0,e),t.slice(e+1),c[t]):"style"==t&&l.style?l.style.cssText=c[t]:l.setAttribute(t,c[t])}}for(let r=d;r<e.length;r++){let i=e[r];if(0===i){if(r<e.length-1||r>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}{let{dom:e,contentDOM:r}=Tt(t,i,n,o);if(l.appendChild(e),r){if(s)throw new RangeError("Multiple content holes");s=r}}}return{dom:l,contentDOM:s}}const At=Math.pow(2,16);function Et(t,e){return t+e*At}function Nt(t){return 65535&t}class Ot{constructor(t,e,n){this.pos=t,this.delInfo=e,this.recover=n}get deleted(){return(8&this.delInfo)>0}get deletedBefore(){return(5&this.delInfo)>0}get deletedAfter(){return(6&this.delInfo)>0}get deletedAcross(){return(4&this.delInfo)>0}}class Lt{constructor(t,e=!1){if(this.ranges=t,this.inverted=e,!t.length&&Lt.empty)return Lt.empty}recover(t){let e=0,n=Nt(t);if(!this.inverted)for(let t=0;t<n;t++)e+=this.ranges[3*t+2]-this.ranges[3*t+1];return this.ranges[3*n]+e+function(t){return(t-(65535&t))/At}(t)}mapResult(t,e=1){return this._map(t,e,!1)}map(t,e=1){return this._map(t,e,!0)}_map(t,e,n){let o=0,r=this.inverted?2:1,i=this.inverted?1:2;for(let s=0;s<this.ranges.length;s+=3){let a=this.ranges[s]-(this.inverted?o:0);if(a>t)break;let l=this.ranges[s+r],c=this.ranges[s+i],d=a+l;if(t<=d){let r=a+o+((l?t==a?-1:t==d?1:e:e)<0?0:c);if(n)return r;let i=t==(e<0?a:d)?null:Et(s/3,t-a),h=t==a?2:t==d?1:4;return(e<0?t!=a:t!=d)&&(h|=8),new Ot(r,h,i)}o+=c-l}return n?t+o:new Ot(t+o,0,null)}touches(t,e){let n=0,o=Nt(e),r=this.inverted?2:1,i=this.inverted?1:2;for(let e=0;e<this.ranges.length;e+=3){let s=this.ranges[e]-(this.inverted?n:0);if(s>t)break;let a=this.ranges[e+r];if(t<=s+a&&e==3*o)return!0;n+=this.ranges[e+i]-a}return!1}forEach(t){let e=this.inverted?2:1,n=this.inverted?1:2;for(let o=0,r=0;o<this.ranges.length;o+=3){let i=this.ranges[o],s=i-(this.inverted?r:0),a=i+(this.inverted?0:r),l=this.ranges[o+e],c=this.ranges[o+n];t(s,s+l,a,a+c),r+=c-l}}invert(){return new Lt(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(t){return 0==t?Lt.empty:new Lt(t<0?[0,-t,0]:[0,0,t])}}Lt.empty=new Lt([]);class Rt{constructor(t,e,n=0,o=(t?t.length:0)){this.mirror=e,this.from=n,this.to=o,this._maps=t||[],this.ownData=!(t||e)}get maps(){return this._maps}slice(t=0,e=this.maps.length){return new Rt(this._maps,this.mirror,t,e)}appendMap(t,e){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(t),null!=e&&this.setMirror(this._maps.length-1,e)}appendMapping(t){for(let e=0,n=this._maps.length;e<t._maps.length;e++){let o=t.getMirror(e);this.appendMap(t._maps[e],null!=o&&o<e?n+o:void 0)}}getMirror(t){if(this.mirror)for(let e=0;e<this.mirror.length;e++)if(this.mirror[e]==t)return this.mirror[e+(e%2?-1:1)]}setMirror(t,e){this.mirror||(this.mirror=[]),this.mirror.push(t,e)}appendMappingInverted(t){for(let e=t.maps.length-1,n=this._maps.length+t._maps.length;e>=0;e--){let o=t.getMirror(e);this.appendMap(t._maps[e].invert(),null!=o&&o>e?n-o-1:void 0)}}invert(){let t=new Rt;return t.appendMappingInverted(this),t}map(t,e=1){if(this.mirror)return this._map(t,e,!0);for(let n=this.from;n<this.to;n++)t=this._maps[n].map(t,e);return t}mapResult(t,e=1){return this._map(t,e,!1)}_map(t,e,n){let o=0;for(let n=this.from;n<this.to;n++){let r=this._maps[n].mapResult(t,e);if(null!=r.recover){let e=this.getMirror(n);if(null!=e&&e>n&&e<this.to){n=e,t=this._maps[e].recover(r.recover);continue}}o|=r.delInfo,t=r.pos}return n?t:new Ot(t,o,null)}}const Dt=Object.create(null);class jt{getMap(){return Lt.empty}merge(t){return null}static fromJSON(t,e){if(!e||!e.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=Dt[e.stepType];if(!n)throw new RangeError(`No step type ${e.stepType} defined`);return n.fromJSON(t,e)}static jsonID(t,e){if(t in Dt)throw new RangeError("Duplicate use of step JSON ID "+t);return Dt[t]=e,e.prototype.jsonID=t,e}}class It{constructor(t,e){this.doc=t,this.failed=e}static ok(t){return new It(t,null)}static fail(t){return new It(null,t)}static fromReplace(t,e,n,o){try{return It.ok(t.replace(e,n,o))}catch(t){if(t instanceof T)return It.fail(t.message);throw t}}}function zt(t,e,n){let o=[];for(let r=0;r<t.childCount;r++){let i=t.child(r);i.content.size&&(i=i.copy(zt(i.content,e,i))),i.isInline&&(i=e(i,n,r)),o.push(i)}return k.fromArray(o)}class $t extends jt{constructor(t,e,n){super(),this.from=t,this.to=e,this.mark=n}apply(t){let e=t.slice(this.from,this.to),n=t.resolve(this.from),o=n.node(n.sharedDepth(this.to)),r=new A(zt(e.content,(t,e)=>t.isAtom&&e.type.allowsMarkType(this.mark.type)?t.mark(this.mark.addToSet(t.marks)):t,o),e.openStart,e.openEnd);return It.fromReplace(t,this.from,this.to,r)}invert(){return new Pt(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),n=t.mapResult(this.to,-1);return e.deleted&&n.deleted||e.pos>=n.pos?null:new $t(e.pos,n.pos,this.mark)}merge(t){return t instanceof $t&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new $t(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,e){if("number"!=typeof e.from||"number"!=typeof e.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new $t(e.from,e.to,t.markFromJSON(e.mark))}}jt.jsonID("addMark",$t);class Pt extends jt{constructor(t,e,n){super(),this.from=t,this.to=e,this.mark=n}apply(t){let e=t.slice(this.from,this.to),n=new A(zt(e.content,t=>t.mark(this.mark.removeFromSet(t.marks)),t),e.openStart,e.openEnd);return It.fromReplace(t,this.from,this.to,n)}invert(){return new $t(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),n=t.mapResult(this.to,-1);return e.deleted&&n.deleted||e.pos>=n.pos?null:new Pt(e.pos,n.pos,this.mark)}merge(t){return t instanceof Pt&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new Pt(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,e){if("number"!=typeof e.from||"number"!=typeof e.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Pt(e.from,e.to,t.markFromJSON(e.mark))}}jt.jsonID("removeMark",Pt);class Ht extends jt{constructor(t,e){super(),this.pos=t,this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return It.fail("No node at mark step's position");let n=e.type.create(e.attrs,null,this.mark.addToSet(e.marks));return It.fromReplace(t,this.pos,this.pos+1,new A(k.from(n),0,e.isLeaf?0:1))}invert(t){let e=t.nodeAt(this.pos);if(e){let t=this.mark.addToSet(e.marks);if(t.length==e.marks.length){for(let n=0;n<e.marks.length;n++)if(!e.marks[n].isInSet(t))return new Ht(this.pos,e.marks[n]);return new Ht(this.pos,this.mark)}}return new Bt(this.pos,this.mark)}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new Ht(e.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,e){if("number"!=typeof e.pos)throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Ht(e.pos,t.markFromJSON(e.mark))}}jt.jsonID("addNodeMark",Ht);class Bt extends jt{constructor(t,e){super(),this.pos=t,this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return It.fail("No node at mark step's position");let n=e.type.create(e.attrs,null,this.mark.removeFromSet(e.marks));return It.fromReplace(t,this.pos,this.pos+1,new A(k.from(n),0,e.isLeaf?0:1))}invert(t){let e=t.nodeAt(this.pos);return e&&this.mark.isInSet(e.marks)?new Ht(this.pos,this.mark):this}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new Bt(e.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,e){if("number"!=typeof e.pos)throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Bt(e.pos,t.markFromJSON(e.mark))}}jt.jsonID("removeNodeMark",Bt);class _t extends jt{constructor(t,e,n,o=!1){super(),this.from=t,this.to=e,this.slice=n,this.structure=o}apply(t){return this.structure&&Ft(t,this.from,this.to)?It.fail("Structure replace would overwrite content"):It.fromReplace(t,this.from,this.to,this.slice)}getMap(){return new Lt([this.from,this.to-this.from,this.slice.size])}invert(t){return new _t(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let e=t.mapResult(this.from,1),n=t.mapResult(this.to,-1);return e.deletedAcross&&n.deletedAcross?null:new _t(e.pos,Math.max(e.pos,n.pos),this.slice,this.structure)}merge(t){if(!(t instanceof _t)||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;{let e=this.slice.size+t.slice.size==0?A.empty:new A(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new _t(t.from,this.to,e,this.structure)}}{let e=this.slice.size+t.slice.size==0?A.empty:new A(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new _t(this.from,this.to+(t.to-t.from),e,this.structure)}}toJSON(){let t={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,e){if("number"!=typeof e.from||"number"!=typeof e.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new _t(e.from,e.to,A.fromJSON(t,e.slice),!!e.structure)}}jt.jsonID("replace",_t);class Vt extends jt{constructor(t,e,n,o,r,i,s=!1){super(),this.from=t,this.to=e,this.gapFrom=n,this.gapTo=o,this.slice=r,this.insert=i,this.structure=s}apply(t){if(this.structure&&(Ft(t,this.from,this.gapFrom)||Ft(t,this.gapTo,this.to)))return It.fail("Structure gap-replace would overwrite content");let e=t.slice(this.gapFrom,this.gapTo);if(e.openStart||e.openEnd)return It.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,e.content);return n?It.fromReplace(t,this.from,this.to,n):It.fail("Content does not fit in gap")}getMap(){return new Lt([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let e=this.gapTo-this.gapFrom;return new Vt(this.from,this.from+this.slice.size+e,this.from+this.insert,this.from+this.insert+e,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let e=t.mapResult(this.from,1),n=t.mapResult(this.to,-1),o=this.from==this.gapFrom?e.pos:t.map(this.gapFrom,-1),r=this.to==this.gapTo?n.pos:t.map(this.gapTo,1);return e.deletedAcross&&n.deletedAcross||o<e.pos||r>n.pos?null:new Vt(e.pos,n.pos,o,r,this.slice,this.insert,this.structure)}toJSON(){let 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}static fromJSON(t,e){if("number"!=typeof e.from||"number"!=typeof e.to||"number"!=typeof e.gapFrom||"number"!=typeof e.gapTo||"number"!=typeof e.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Vt(e.from,e.to,e.gapFrom,e.gapTo,A.fromJSON(t,e.slice),e.insert,!!e.structure)}}function Ft(t,e,n){let o=t.resolve(e),r=n-e,i=o.depth;for(;r>0&&i>0&&o.indexAfter(i)==o.node(i).childCount;)i--,r--;if(r>0){let t=o.node(i).maybeChild(o.indexAfter(i));for(;r>0;){if(!t||t.isLeaf)return!0;t=t.firstChild,r--}}return!1}function Wt(t,e,n,o=n.contentMatch,r=!0){let i=t.doc.nodeAt(e),s=[],a=e+1;for(let e=0;e<i.childCount;e++){let l=i.child(e),c=a+l.nodeSize,d=o.matchType(l.type);if(d){o=d;for(let e=0;e<l.marks.length;e++)n.allowsMarkType(l.marks[e].type)||t.step(new Pt(a,c,l.marks[e]));if(r&&l.isText&&"pre"!=n.whitespace){let t,e,o=/\r?\n|\r/g;for(;t=o.exec(l.text);)e||(e=new A(k.from(n.schema.text(" ",n.allowedMarks(l.marks))),0,0)),s.push(new _t(a+t.index,a+t.index+t[0].length,e))}}else s.push(new _t(a,c,A.empty));a=c}if(!o.validEnd){let e=o.fillBefore(k.empty,!0);t.replace(a,a,new A(e,0,0))}for(let e=s.length-1;e>=0;e--)t.step(s[e])}function Kt(t,e,n){return(0==e||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function qt(t){let e=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let n=t.depth;;--n){let o=t.$from.node(n),r=t.$from.index(n),i=t.$to.indexAfter(n);if(n<t.depth&&o.canReplace(r,i,e))return n;if(0==n||o.type.spec.isolating||!Kt(o,r,i))break}return null}function Ut(t,e,n=null,o=t){let r=function(t,e){let{parent:n,startIndex:o,endIndex:r}=t,i=n.contentMatchAt(o).findWrapping(e);if(!i)return null;let s=i.length?i[0]:e;return n.canReplaceWith(o,r,s)?i:null}(t,e),i=r&&function(t,e){let{parent:n,startIndex:o,endIndex:r}=t,i=n.child(o),s=e.contentMatch.findWrapping(i.type);if(!s)return null;let a=(s.length?s[s.length-1]:e).contentMatch;for(let t=o;a&&t<r;t++)a=a.matchType(n.child(t).type);return a&&a.validEnd?s:null}(o,e);return i?r.map(Jt).concat({type:e,attrs:n}).concat(i.map(Jt)):null}function Jt(t){return{type:t,attrs:null}}function Gt(t,e,n,o){e.forEach((r,i)=>{if(r.isText){let s,a=/\r?\n|\r/g;for(;s=a.exec(r.text);){let r=t.mapping.slice(o).map(n+1+i+s.index);t.replaceWith(r,r+1,e.type.schema.linebreakReplacement.create())}}})}function Yt(t,e,n,o){e.forEach((r,i)=>{if(r.type==r.type.schema.linebreakReplacement){let r=t.mapping.slice(o).map(n+1+i);t.replaceWith(r,r+1,e.type.schema.text("\n"))}})}function Xt(t,e,n=1,o){let r=t.resolve(e),i=r.depth-n,s=o&&o[o.length-1]||r.parent;if(i<0||r.parent.type.spec.isolating||!r.parent.canReplace(r.index(),r.parent.childCount)||!s.type.validContent(r.parent.content.cutByIndex(r.index(),r.parent.childCount)))return!1;for(let t=r.depth-1,e=n-2;t>i;t--,e--){let n=r.node(t),i=r.index(t);if(n.type.spec.isolating)return!1;let s=n.content.cutByIndex(i,n.childCount),a=o&&o[e+1];a&&(s=s.replaceChild(0,a.type.create(a.attrs)));let l=o&&o[e]||n;if(!n.canReplace(i+1,n.childCount)||!l.type.validContent(s))return!1}let a=r.indexAfter(i),l=o&&o[0];return r.node(i).canReplaceWith(a,a,l?l.type:r.node(i+1).type)}function Qt(t,e){let n=t.resolve(e),o=n.index();return Zt(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(o,o+1)}function Zt(t,e){return!(!t||!e||t.isLeaf||!function(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:o}=t.type.schema;for(let r=0;r<e.childCount;r++){let i=e.child(r),s=i.type==o?t.type.schema.nodes.text:i.type;if(n=n.matchType(s),!n)return!1;if(!t.type.allowsMarks(i.marks))return!1}return n.validEnd}(t,e))}function te(t,e,n=-1){let o=t.resolve(e);for(let t=o.depth;;t--){let r,i,s=o.index(t);if(t==o.depth?(r=o.nodeBefore,i=o.nodeAfter):n>0?(r=o.node(t+1),s++,i=o.node(t).maybeChild(s)):(r=o.node(t).maybeChild(s-1),i=o.node(t+1)),r&&!r.isTextblock&&Zt(r,i)&&o.node(t).canReplace(s,s+1))return e;if(0==t)break;e=n<0?o.before(t):o.after(t)}}function ee(t,e,n){let o=t.resolve(e);if(!n.content.size)return e;let r=n.content;for(let t=0;t<n.openStart;t++)r=r.firstChild.content;for(let t=1;t<=(0==n.openStart&&n.size?2:1);t++)for(let e=o.depth;e>=0;e--){let n=e==o.depth?0:o.pos<=(o.start(e+1)+o.end(e+1))/2?-1:1,i=o.index(e)+(n>0?1:0),s=o.node(e),a=!1;if(1==t)a=s.canReplace(i,i,r);else{let t=s.contentMatchAt(i).findWrapping(r.firstChild.type);a=t&&s.canReplaceWith(i,i,t[0])}if(a)return 0==n?o.pos:n<0?o.before(e+1):o.after(e+1)}return null}function ne(t,e,n=e,o=A.empty){if(e==n&&!o.size)return null;let r=t.resolve(e),i=t.resolve(n);return oe(r,i,o)?new _t(e,n,o):new re(r,i,o).fit()}function oe(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}jt.jsonID("replaceAround",Vt);class re{constructor(t,e,n){this.$from=t,this.$to=e,this.unplaced=n,this.frontier=[],this.placed=k.empty;for(let e=0;e<=t.depth;e++){let n=t.node(e);this.frontier.push({type:n.type,match:n.contentMatchAt(t.indexAfter(e))})}for(let e=t.depth;e>0;e--)this.placed=k.from(t.node(e).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let t=this.findFittable();t?this.placeNodes(t):this.openMore()||this.dropNode()}let t=this.mustMoveInline(),e=this.placed.size-this.depth-this.$from.depth,n=this.$from,o=this.close(t<0?this.$to:n.doc.resolve(t));if(!o)return null;let r=this.placed,i=n.depth,s=o.depth;for(;i&&s&&1==r.childCount;)r=r.firstChild.content,i--,s--;let a=new A(r,i,s);return t>-1?new Vt(n.pos,t,this.$to.pos,this.$to.end(),a,e):a.size||n.pos!=this.$to.pos?new _t(n.pos,o.pos,a):null}findFittable(){let t=this.unplaced.openStart;for(let e=this.unplaced.content,n=0,o=this.unplaced.openEnd;n<t;n++){let r=e.firstChild;if(e.childCount>1&&(o=0),r.type.spec.isolating&&o<=n){t=n;break}e=r.content}for(let e=1;e<=2;e++)for(let n=1==e?t:this.unplaced.openStart;n>=0;n--){let t,o=null;n?(o=ae(this.unplaced.content,n-1).firstChild,t=o.content):t=this.unplaced.content;let r=t.firstChild;for(let t=this.depth;t>=0;t--){let i,{type:s,match:a}=this.frontier[t],l=null;if(1==e&&(r?a.matchType(r.type)||(l=a.fillBefore(k.from(r),!1)):o&&s.compatibleContent(o.type)))return{sliceDepth:n,frontierDepth:t,parent:o,inject:l};if(2==e&&r&&(i=a.findWrapping(r.type)))return{sliceDepth:n,frontierDepth:t,parent:o,wrap:i};if(o&&a.matchType(o.type))break}}}openMore(){let{content:t,openStart:e,openEnd:n}=this.unplaced,o=ae(t,e);return!(!o.childCount||o.firstChild.isLeaf||(this.unplaced=new A(t,e+1,Math.max(n,o.size+e>=t.size-n?e+1:0)),0))}dropNode(){let{content:t,openStart:e,openEnd:n}=this.unplaced,o=ae(t,e);if(o.childCount<=1&&e>0){let r=t.size-e<=e+o.size;this.unplaced=new A(ie(t,e-1,1),e-1,r?e-1:n)}else this.unplaced=new A(ie(t,e,1),e,n)}placeNodes({sliceDepth:t,frontierDepth:e,parent:n,inject:o,wrap:r}){for(;this.depth>e;)this.closeFrontierNode();if(r)for(let t=0;t<r.length;t++)this.openFrontierNode(r[t]);let i=this.unplaced,s=n?n.content:i.content,a=i.openStart-t,l=0,c=[],{match:d,type:h}=this.frontier[e];if(o){for(let t=0;t<o.childCount;t++)c.push(o.child(t));d=d.matchFragment(o)}let p=s.size+t-(i.content.size-i.openEnd);for(;l<s.childCount;){let t=s.child(l),e=d.matchType(t.type);if(!e)break;l++,(l>1||0==a||t.content.size)&&(d=e,c.push(le(t.mark(h.allowedMarks(t.marks)),1==l?a:0,l==s.childCount?p:-1)))}let u=l==s.childCount;u||(p=-1),this.placed=se(this.placed,e,k.from(c)),this.frontier[e].match=d,u&&p<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let t=0,e=s;t<p;t++){let t=e.lastChild;this.frontier.push({type:t.type,match:t.contentMatchAt(t.childCount)}),e=t.content}this.unplaced=u?0==t?A.empty:new A(ie(i.content,t-1,1),t-1,p<0?i.openEnd:t-1):new A(ie(i.content,t,l),i.openStart,i.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let t,e=this.frontier[this.depth];if(!e.type.isTextblock||!ce(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;let{depth:n}=this.$to,o=this.$to.after(n);for(;n>1&&o==this.$to.end(--n);)++o;return o}findCloseLevel(t){t:for(let e=Math.min(this.depth,t.depth);e>=0;e--){let{match:n,type:o}=this.frontier[e],r=e<t.depth&&t.end(e+1)==t.pos+(t.depth-(e+1)),i=ce(t,e,o,n,r);if(i){for(let n=e-1;n>=0;n--){let{match:e,type:o}=this.frontier[n],r=ce(t,n,o,e,!0);if(!r||r.childCount)continue t}return{depth:e,fit:i,move:r?t.doc.resolve(t.after(e+1)):t}}}}close(t){let e=this.findCloseLevel(t);if(!e)return null;for(;this.depth>e.depth;)this.closeFrontierNode();e.fit.childCount&&(this.placed=se(this.placed,e.depth,e.fit)),t=e.move;for(let n=e.depth+1;n<=t.depth;n++){let e=t.node(n),o=e.type.contentMatch.fillBefore(e.content,!0,t.index(n));this.openFrontierNode(e.type,e.attrs,o)}return t}openFrontierNode(t,e=null,n){let o=this.frontier[this.depth];o.match=o.match.matchType(t),this.placed=se(this.placed,this.depth,k.from(t.create(e,n))),this.frontier.push({type:t,match:t.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(k.empty,!0);t.childCount&&(this.placed=se(this.placed,this.frontier.length,t))}}function ie(t,e,n){return 0==e?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(ie(t.firstChild.content,e-1,n)))}function se(t,e,n){return 0==e?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(se(t.lastChild.content,e-1,n)))}function ae(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function le(t,e,n){if(e<=0)return t;let o=t.content;return e>1&&(o=o.replaceChild(0,le(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(k.empty,!0)))),t.copy(o)}function ce(t,e,n,o,r){let i=t.node(e),s=r?t.indexAfter(e):t.index(e);if(s==i.childCount&&!n.compatibleContent(i.type))return null;let a=o.fillBefore(i.content,!0,s);return a&&!function(t,e,n){for(let o=n;o<e.childCount;o++)if(!t.allowsMarks(e.child(o).marks))return!0;return!1}(n,i.content,s)?a:null}function de(t){return t.spec.defining||t.spec.definingForContent}function he(t,e,n,o,r){if(e<n){let r=t.firstChild;t=t.replaceChild(0,r.copy(he(r.content,e+1,n,o,r)))}if(e>o){let e=r.contentMatchAt(0),n=e.fillBefore(t).append(t);t=n.append(e.matchFragment(n).fillBefore(k.empty,!0))}return t}function pe(t,e){let n=[];for(let o=Math.min(t.depth,e.depth);o>=0;o--){let r=t.start(o);if(r<t.pos-(t.depth-o)||e.end(o)>e.pos+(e.depth-o)||t.node(o).type.spec.isolating||e.node(o).type.spec.isolating)break;(r==e.start(o)||o==t.depth&&o==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&o&&e.start(o-1)==r-1)&&n.push(o)}return n}class ue extends jt{constructor(t,e,n){super(),this.pos=t,this.attr=e,this.value=n}apply(t){let e=t.nodeAt(this.pos);if(!e)return It.fail("No node at attribute step's position");let n=Object.create(null);for(let t in e.attrs)n[t]=e.attrs[t];n[this.attr]=this.value;let o=e.type.create(n,null,e.marks);return It.fromReplace(t,this.pos,this.pos+1,new A(k.from(o),0,e.isLeaf?0:1))}getMap(){return Lt.empty}invert(t){return new ue(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new ue(e.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,e){if("number"!=typeof e.pos||"string"!=typeof e.attr)throw new RangeError("Invalid input for AttrStep.fromJSON");return new ue(e.pos,e.attr,e.value)}}jt.jsonID("attr",ue);class fe extends jt{constructor(t,e){super(),this.attr=t,this.value=e}apply(t){let e=Object.create(null);for(let n in t.attrs)e[n]=t.attrs[n];e[this.attr]=this.value;let n=t.type.create(e,t.content,t.marks);return It.ok(n)}getMap(){return Lt.empty}invert(t){return new fe(this.attr,t.attrs[this.attr])}map(t){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(t,e){if("string"!=typeof e.attr)throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new fe(e.attr,e.value)}}jt.jsonID("docAttr",fe);let me=class extends Error{};me=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n},(me.prototype=Object.create(Error.prototype)).constructor=me,me.prototype.name="TransformError";class ge{constructor(t){this.doc=t,this.steps=[],this.docs=[],this.mapping=new Rt}get before(){return this.docs.length?this.docs[0]:this.doc}step(t){let e=this.maybeStep(t);if(e.failed)throw new me(e.failed);return this}maybeStep(t){let e=t.apply(this.doc);return e.failed||this.addStep(t,e.doc),e}get docChanged(){return this.steps.length>0}addStep(t,e){this.docs.push(this.doc),this.steps.push(t),this.mapping.appendMap(t.getMap()),this.doc=e}replace(t,e=t,n=A.empty){let o=ne(this.doc,t,e,n);return o&&this.step(o),this}replaceWith(t,e,n){return this.replace(t,e,new A(k.from(n),0,0))}delete(t,e){return this.replace(t,e,A.empty)}insert(t,e){return this.replaceWith(t,t,e)}replaceRange(t,e,n){return function(t,e,n,o){if(!o.size)return t.deleteRange(e,n);let r=t.doc.resolve(e),i=t.doc.resolve(n);if(oe(r,i,o))return t.step(new _t(e,n,o));let s=pe(r,t.doc.resolve(n));0==s[s.length-1]&&s.pop();let a=-(r.depth+1);s.unshift(a);for(let t=r.depth,e=r.pos-1;t>0;t--,e--){let n=r.node(t).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;s.indexOf(t)>-1?a=t:r.before(t)==e&&s.splice(1,0,-t)}let l=s.indexOf(a),c=[],d=o.openStart;for(let t=o.content,e=0;;e++){let n=t.firstChild;if(c.push(n),e==o.openStart)break;t=n.content}for(let t=d-1;t>=0;t--){let e=c[t],n=de(e.type);if(n&&!e.sameMarkup(r.node(Math.abs(a)-1)))d=t;else if(n||!e.type.isTextblock)break}for(let e=o.openStart;e>=0;e--){let a=(e+d+1)%(o.openStart+1),h=c[a];if(h)for(let e=0;e<s.length;e++){let c=s[(e+l)%s.length],d=!0;c<0&&(d=!1,c=-c);let p=r.node(c-1),u=r.index(c-1);if(p.canReplaceWith(u,u,h.type,h.marks))return t.replace(r.before(c),d?i.after(c):n,new A(he(o.content,0,o.openStart,a),a,o.openEnd))}}let h=t.steps.length;for(let a=s.length-1;a>=0&&(t.replace(e,n,o),!(t.steps.length>h));a--){let t=s[a];t<0||(e=r.before(t),n=i.after(t))}}(this,t,e,n),this}replaceRangeWith(t,e,n){return function(t,e,n,o){if(!o.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let r=function(t,e,n){let o=t.resolve(e);if(o.parent.canReplaceWith(o.index(),o.index(),n))return e;if(0==o.parentOffset)for(let t=o.depth-1;t>=0;t--){let e=o.index(t);if(o.node(t).canReplaceWith(e,e,n))return o.before(t+1);if(e>0)return null}if(o.parentOffset==o.parent.content.size)for(let t=o.depth-1;t>=0;t--){let e=o.indexAfter(t);if(o.node(t).canReplaceWith(e,e,n))return o.after(t+1);if(e<o.node(t).childCount)return null}return null}(t.doc,e,o.type);null!=r&&(e=n=r)}t.replaceRange(e,n,new A(k.from(o),0,0))}(this,t,e,n),this}deleteRange(t,e){return function(t,e,n){let o=t.doc.resolve(e),r=t.doc.resolve(n),i=pe(o,r);for(let e=0;e<i.length;e++){let n=i[e],s=e==i.length-1;if(s&&0==n||o.node(n).type.contentMatch.validEnd)return t.delete(o.start(n),r.end(n));if(n>0&&(s||o.node(n-1).canReplace(o.index(n-1),r.indexAfter(n-1))))return t.delete(o.before(n),r.after(n))}for(let i=1;i<=o.depth&&i<=r.depth;i++)if(e-o.start(i)==o.depth-i&&n>o.end(i)&&r.end(i)-n!=r.depth-i&&o.start(i-1)==r.start(i-1)&&o.node(i-1).canReplace(o.index(i-1),r.index(i-1)))return t.delete(o.before(i),n);t.delete(e,n)}(this,t,e),this}lift(t,e){return function(t,e,n){let{$from:o,$to:r,depth:i}=e,s=o.before(i+1),a=r.after(i+1),l=s,c=a,d=k.empty,h=0;for(let t=i,e=!1;t>n;t--)e||o.index(t)>0?(e=!0,d=k.from(o.node(t).copy(d)),h++):l--;let p=k.empty,u=0;for(let t=i,e=!1;t>n;t--)e||r.after(t+1)<r.end(t)?(e=!0,p=k.from(r.node(t).copy(p)),u++):c++;t.step(new Vt(l,c,s,a,new A(d.append(p),h,u),d.size-h,!0))}(this,t,e),this}join(t,e=1){return function(t,e,n){let o=null,{linebreakReplacement:r}=t.doc.type.schema,i=t.doc.resolve(e-n),s=i.node().type;if(r&&s.inlineContent){let t="pre"==s.whitespace,e=!!s.contentMatch.matchType(r);t&&!e?o=!1:!t&&e&&(o=!0)}let a=t.steps.length;if(!1===o){let o=t.doc.resolve(e+n);Yt(t,o.node(),o.before(),a)}s.inlineContent&&Wt(t,e+n-1,s,i.node().contentMatchAt(i.index()),null==o);let l=t.mapping.slice(a),c=l.map(e-n);if(t.step(new _t(c,l.map(e+n,-1),A.empty,!0)),!0===o){let e=t.doc.resolve(c);Gt(t,e.node(),e.before(),t.steps.length)}}(this,t,e),this}wrap(t,e){return function(t,e,n){let o=k.empty;for(let t=n.length-1;t>=0;t--){if(o.size){let e=n[t].type.contentMatch.matchFragment(o);if(!e||!e.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}o=k.from(n[t].type.create(n[t].attrs,o))}let r=e.start,i=e.end;t.step(new Vt(r,i,r,i,new A(o,0,0),n.length,!0))}(this,t,e),this}setBlockType(t,e=t,n,o=null){return function(t,e,n,o,r){if(!o.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=t.steps.length;t.doc.nodesBetween(e,n,(e,n)=>{let s="function"==typeof r?r(e):r;if(e.isTextblock&&!e.hasMarkup(o,s)&&function(t,e,n){let o=t.resolve(e),r=o.index();return o.parent.canReplaceWith(r,r+1,n)}(t.doc,t.mapping.slice(i).map(n),o)){let r=null;if(o.schema.linebreakReplacement){let t="pre"==o.whitespace,e=!!o.contentMatch.matchType(o.schema.linebreakReplacement);t&&!e?r=!1:!t&&e&&(r=!0)}!1===r&&Yt(t,e,n,i),Wt(t,t.mapping.slice(i).map(n,1),o,void 0,null===r);let a=t.mapping.slice(i),l=a.map(n,1),c=a.map(n+e.nodeSize,1);return t.step(new Vt(l,c,l+1,c-1,new A(k.from(o.create(s,null,e.marks)),0,0),1,!0)),!0===r&&Gt(t,e,n,i),!1}})}(this,t,e,n,o),this}setNodeMarkup(t,e,n=null,o){return function(t,e,n,o,r){let i=t.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");n||(n=i.type);let s=n.create(o,null,r||i.marks);if(i.isLeaf)return t.replaceWith(e,e+i.nodeSize,s);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new Vt(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new A(k.from(s),0,0),1,!0))}(this,t,e,n,o),this}setNodeAttribute(t,e,n){return this.step(new ue(t,e,n)),this}setDocAttribute(t,e){return this.step(new fe(t,e)),this}addNodeMark(t,e){return this.step(new Ht(t,e)),this}removeNodeMark(t,e){let n=this.doc.nodeAt(t);if(!n)throw new RangeError("No node at position "+t);if(e instanceof S)e.isInSet(n.marks)&&this.step(new Bt(t,e));else{let o,r=n.marks,i=[];for(;o=e.isInSet(r);)i.push(new Bt(t,o)),r=o.removeFromSet(r);for(let t=i.length-1;t>=0;t--)this.step(i[t])}return this}split(t,e=1,n){return function(t,e,n=1,o){let r=t.doc.resolve(e),i=k.empty,s=k.empty;for(let t=r.depth,e=r.depth-n,a=n-1;t>e;t--,a--){i=k.from(r.node(t).copy(i));let e=o&&o[a];s=k.from(e?e.type.create(e.attrs,s):r.node(t).copy(s))}t.step(new _t(e,e,new A(i.append(s),n,n),!0))}(this,t,e,n),this}addMark(t,e,n){return function(t,e,n,o){let r,i,s=[],a=[];t.doc.nodesBetween(e,n,(t,l,c)=>{if(!t.isInline)return;let d=t.marks;if(!o.isInSet(d)&&c.type.allowsMarkType(o.type)){let c=Math.max(l,e),h=Math.min(l+t.nodeSize,n),p=o.addToSet(d);for(let t=0;t<d.length;t++)d[t].isInSet(p)||(r&&r.to==c&&r.mark.eq(d[t])?r.to=h:s.push(r=new Pt(c,h,d[t])));i&&i.to==c?i.to=h:a.push(i=new $t(c,h,o))}}),s.forEach(e=>t.step(e)),a.forEach(e=>t.step(e))}(this,t,e,n),this}removeMark(t,e,n){return function(t,e,n,o){let r=[],i=0;t.doc.nodesBetween(e,n,(t,s)=>{if(!t.isInline)return;i++;let a=null;if(o instanceof ct){let e,n=t.marks;for(;e=o.isInSet(n);)(a||(a=[])).push(e),n=e.removeFromSet(n)}else o?o.isInSet(t.marks)&&(a=[o]):a=t.marks;if(a&&a.length){let o=Math.min(s+t.nodeSize,n);for(let t=0;t<a.length;t++){let n,l=a[t];for(let t=0;t<r.length;t++){let e=r[t];e.step==i-1&&l.eq(r[t].style)&&(n=e)}n?(n.to=o,n.step=i):r.push({style:l,from:Math.max(s,e),to:o,step:i})}}}),r.forEach(e=>t.step(new Pt(e.from,e.to,e.style)))}(this,t,e,n),this}clearIncompatible(t,e,n){return Wt(this,t,e,n),this}}const ye=Object.create(null);class be{constructor(t,e,n){this.$anchor=t,this.$head=e,this.ranges=n||[new ve(t.min(e),t.max(e))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let t=this.ranges;for(let e=0;e<t.length;e++)if(t[e].$from.pos!=t[e].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(t,e=A.empty){let n=e.content.lastChild,o=null;for(let t=0;t<e.openEnd;t++)o=n,n=n.lastChild;let r=t.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:a,$to:l}=i[s],c=t.mapping.slice(r);t.replaceRange(c.map(a.pos),c.map(l.pos),s?A.empty:e),0==s&&Ne(t,r,(n?n.isInline:o&&o.isTextblock)?-1:1)}}replaceWith(t,e){let n=t.steps.length,o=this.ranges;for(let r=0;r<o.length;r++){let{$from:i,$to:s}=o[r],a=t.mapping.slice(n),l=a.map(i.pos),c=a.map(s.pos);r?t.deleteRange(l,c):(t.replaceRangeWith(l,c,e),Ne(t,n,e.isInline?-1:1))}}static findFrom(t,e,n=!1){let o=t.parent.inlineContent?new xe(t):Ee(t.node(0),t.parent,t.pos,t.index(),e,n);if(o)return o;for(let o=t.depth-1;o>=0;o--){let r=e<0?Ee(t.node(0),t.node(o),t.before(o+1),t.index(o),e,n):Ee(t.node(0),t.node(o),t.after(o+1),t.index(o)+1,e,n);if(r)return r}return null}static near(t,e=1){return this.findFrom(t,e)||this.findFrom(t,-e)||new Te(t.node(0))}static atStart(t){return Ee(t,t,0,0,1)||new Te(t)}static atEnd(t){return Ee(t,t,t.content.size,t.childCount,-1)||new Te(t)}static fromJSON(t,e){if(!e||!e.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=ye[e.type];if(!n)throw new RangeError(`No selection type ${e.type} defined`);return n.fromJSON(t,e)}static jsonID(t,e){if(t in ye)throw new RangeError("Duplicate use of selection JSON ID "+t);return ye[t]=e,e.prototype.jsonID=t,e}getBookmark(){return xe.between(this.$anchor,this.$head).getBookmark()}}be.prototype.visible=!0;class ve{constructor(t,e){this.$from=t,this.$to=e}}let we=!1;function ke(t){we||t.parent.inlineContent||(we=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class xe extends be{constructor(t,e=t){ke(t),ke(e),super(t,e)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,e){let n=t.resolve(e.map(this.head));if(!n.parent.inlineContent)return be.near(n);let o=t.resolve(e.map(this.anchor));return new xe(o.parent.inlineContent?o:n,n)}replace(t,e=A.empty){if(super.replace(t,e),e==A.empty){let e=this.$from.marksAcross(this.$to);e&&t.ensureMarks(e)}}eq(t){return t instanceof xe&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new Me(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(t,e){if("number"!=typeof e.anchor||"number"!=typeof e.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new xe(t.resolve(e.anchor),t.resolve(e.head))}static create(t,e,n=e){let o=t.resolve(e);return new this(o,n==e?o:t.resolve(n))}static between(t,e,n){let o=t.pos-e.pos;if(n&&!o||(n=o>=0?1:-1),!e.parent.inlineContent){let t=be.findFrom(e,n,!0)||be.findFrom(e,-n,!0);if(!t)return be.near(e,n);e=t.$head}return t.parent.inlineContent||(0==o||(t=(be.findFrom(t,-n,!0)||be.findFrom(t,n,!0)).$anchor).pos<e.pos!=o<0)&&(t=e),new xe(t,e)}}be.jsonID("text",xe);class Me{constructor(t,e){this.anchor=t,this.head=e}map(t){return new Me(t.map(this.anchor),t.map(this.head))}resolve(t){return xe.between(t.resolve(this.anchor),t.resolve(this.head))}}class Ce extends be{constructor(t){let e=t.nodeAfter,n=t.node(0).resolve(t.pos+e.nodeSize);super(t,n),this.node=e}map(t,e){let{deleted:n,pos:o}=e.mapResult(this.anchor),r=t.resolve(o);return n?be.near(r):new Ce(r)}content(){return new A(k.from(this.node),0,0)}eq(t){return t instanceof Ce&&t.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Se(this.anchor)}static fromJSON(t,e){if("number"!=typeof e.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Ce(t.resolve(e.anchor))}static create(t,e){return new Ce(t.resolve(e))}static isSelectable(t){return!t.isText&&!1!==t.type.spec.selectable}}Ce.prototype.visible=!1,be.jsonID("node",Ce);class Se{constructor(t){this.anchor=t}map(t){let{deleted:e,pos:n}=t.mapResult(this.anchor);return e?new Me(n,n):new Se(n)}resolve(t){let e=t.resolve(this.anchor),n=e.nodeAfter;return n&&Ce.isSelectable(n)?new Ce(e):be.near(e)}}class Te extends be{constructor(t){super(t.resolve(0),t.resolve(t.content.size))}replace(t,e=A.empty){if(e==A.empty){t.delete(0,t.doc.content.size);let e=be.atStart(t.doc);e.eq(t.selection)||t.setSelection(e)}else super.replace(t,e)}toJSON(){return{type:"all"}}static fromJSON(t){return new Te(t)}map(t){return new Te(t)}eq(t){return t instanceof Te}getBookmark(){return Ae}}be.jsonID("all",Te);const Ae={map(){return this},resolve:t=>new Te(t)};function Ee(t,e,n,o,r,i=!1){if(e.inlineContent)return xe.create(t,n);for(let s=o-(r>0?0:1);r>0?s<e.childCount:s>=0;s+=r){let o=e.child(s);if(o.isAtom){if(!i&&Ce.isSelectable(o))return Ce.create(t,n-(r<0?o.nodeSize:0))}else{let e=Ee(t,o,n+r,r<0?o.childCount:0,r,i);if(e)return e}n+=o.nodeSize*r}return null}function Ne(t,e,n){let o=t.steps.length-1;if(o<e)return;let r,i=t.steps[o];(i instanceof _t||i instanceof Vt)&&(t.mapping.maps[o].forEach((t,e,n,o)=>{null==r&&(r=o)}),t.setSelection(be.near(t.doc.resolve(r),n)))}class Oe extends ge{constructor(t){super(t.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=t.selection,this.storedMarks=t.storedMarks}get selection(){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}setSelection(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&this.updated|1,this.storedMarks=null,this}get selectionSet(){return(1&this.updated)>0}setStoredMarks(t){return this.storedMarks=t,this.updated|=2,this}ensureMarks(t){return S.sameSet(this.storedMarks||this.selection.$from.marks(),t)||this.setStoredMarks(t),this}addStoredMark(t){return this.ensureMarks(t.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(t){return this.ensureMarks(t.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(2&this.updated)>0}addStep(t,e){super.addStep(t,e),this.updated=-3&this.updated,this.storedMarks=null}setTime(t){return this.time=t,this}replaceSelection(t){return this.selection.replace(this,t),this}replaceSelectionWith(t,e=!0){let n=this.selection;return e&&(t=t.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||S.none))),n.replaceWith(this,t),this}deleteSelection(){return this.selection.replace(this),this}insertText(t,e,n){let o=this.doc.type.schema;if(null==e)return t?this.replaceSelectionWith(o.text(t),!0):this.deleteSelection();{if(null==n&&(n=e),n=null==n?e:n,!t)return this.deleteRange(e,n);let r=this.storedMarks;if(!r){let t=this.doc.resolve(e);r=n==e?t.marks():t.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(e,n,o.text(t,r)),this.selection.empty||this.setSelection(be.near(this.selection.$to)),this}}setMeta(t,e){return this.meta["string"==typeof t?t:t.key]=e,this}getMeta(t){return this.meta["string"==typeof t?t:t.key]}get isGeneric(){for(let t in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=4,this}get scrolledIntoView(){return(4&this.updated)>0}}function Le(t,e){return e&&t?t.bind(e):t}class Re{constructor(t,e,n){this.name=t,this.init=Le(e.init,n),this.apply=Le(e.apply,n)}}const De=[new Re("doc",{init:t=>t.doc||t.schema.topNodeType.createAndFill(),apply:t=>t.doc}),new Re("selection",{init:(t,e)=>t.selection||be.atStart(e.doc),apply:t=>t.selection}),new Re("storedMarks",{init:t=>t.storedMarks||null,apply:(t,e,n,o)=>o.selection.$cursor?t.storedMarks:null}),new Re("scrollToSelection",{init:()=>0,apply:(t,e)=>t.scrolledIntoView?e+1:e})];class je{constructor(t,e){this.schema=t,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=De.slice(),e&&e.forEach(t=>{if(this.pluginsByKey[t.key])throw new RangeError("Adding different instances of a keyed plugin ("+t.key+")");this.plugins.push(t),this.pluginsByKey[t.key]=t,t.spec.state&&this.fields.push(new Re(t.key,t.spec.state,t))})}}class Ie{constructor(t){this.config=t}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(t){return this.applyTransaction(t).state}filterTransaction(t,e=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=e){let e=this.config.plugins[n];if(e.spec.filterTransaction&&!e.spec.filterTransaction.call(e,t,this))return!1}return!0}applyTransaction(t){if(!this.filterTransaction(t))return{state:this,transactions:[]};let e=[t],n=this.applyInner(t),o=null;for(;;){let r=!1;for(let i=0;i<this.config.plugins.length;i++){let s=this.config.plugins[i];if(s.spec.appendTransaction){let a=o?o[i].n:0,l=o?o[i].state:this,c=a<e.length&&s.spec.appendTransaction.call(s,a?e.slice(a):e,l,n);if(c&&n.filterTransaction(c,i)){if(c.setMeta("appendedTransaction",t),!o){o=[];for(let t=0;t<this.config.plugins.length;t++)o.push(t<i?{state:n,n:e.length}:{state:this,n:0})}e.push(c),n=n.applyInner(c),r=!0}o&&(o[i]={state:n,n:e.length})}}if(!r)return{state:n,transactions:e}}}applyInner(t){if(!t.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let e=new Ie(this.config),n=this.config.fields;for(let o=0;o<n.length;o++){let r=n[o];e[r.name]=r.apply(t,this[r.name],this,e)}return e}get tr(){return new Oe(this)}static create(t){let e=new je(t.doc?t.doc.type.schema:t.schema,t.plugins),n=new Ie(e);for(let o=0;o<e.fields.length;o++)n[e.fields[o].name]=e.fields[o].init(t,n);return n}reconfigure(t){let e=new je(this.schema,t.plugins),n=e.fields,o=new Ie(e);for(let e=0;e<n.length;e++){let r=n[e].name;o[r]=this.hasOwnProperty(r)?this[r]:n[e].init(t,o)}return o}toJSON(t){let e={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(e.storedMarks=this.storedMarks.map(t=>t.toJSON())),t&&"object"==typeof t)for(let n in t){if("doc"==n||"selection"==n)throw new RangeError("The JSON fields `doc` and `selection` are reserved");let o=t[n],r=o.spec.state;r&&r.toJSON&&(e[n]=r.toJSON.call(o,this[o.key]))}return e}static fromJSON(t,e,n){if(!e)throw new RangeError("Invalid input for EditorState.fromJSON");if(!t.schema)throw new RangeError("Required config field 'schema' missing");let o=new je(t.schema,t.plugins),r=new Ie(o);return o.fields.forEach(o=>{if("doc"==o.name)r.doc=K.fromJSON(t.schema,e.doc);else if("selection"==o.name)r.selection=be.fromJSON(r.doc,e.selection);else if("storedMarks"==o.name)e.storedMarks&&(r.storedMarks=e.storedMarks.map(t.schema.markFromJSON));else{if(n)for(let i in n){let s=n[i],a=s.spec.state;if(s.key==o.name&&a&&a.fromJSON&&Object.prototype.hasOwnProperty.call(e,i))return void(r[o.name]=a.fromJSON.call(s,t,e[i],r))}r[o.name]=o.init(t,r)}}),r}}function ze(t,e,n){for(let o in t){let r=t[o];r instanceof Function?r=r.bind(e):"handleDOMEvents"==o&&(r=ze(r,e,{})),n[o]=r}return n}class $e{constructor(t){this.spec=t,this.props={},t.props&&ze(t.props,this,this.props),this.key=t.key?t.key.key:He("plugin")}getState(t){return t[this.key]}}const Pe=Object.create(null);function He(t){return t in Pe?t+"$"+ ++Pe[t]:(Pe[t]=0,t+"$")}class Be{constructor(t="key"){this.key=He(t)}get(t){return t.config.pluginsByKey[this.key]}getState(t){return t[this.key]}}const _e=(t,e)=>!t.selection.empty&&(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function Ve(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const Fe=(t,e,n)=>{let o=Ve(t,n);if(!o)return!1;let r=Ue(o);if(!r){let n=o.blockRange(),r=n&&qt(n);return null!=r&&(e&&e(t.tr.lift(n,r).scrollIntoView()),!0)}let i=r.nodeBefore;if(rn(t,r,e,-1))return!0;if(0==o.parent.content.size&&(Ke(i,"end")||Ce.isSelectable(i)))for(let n=o.depth;;n--){let s=ne(t.doc,o.before(n),o.after(n),A.empty);if(s&&s.slice.size<s.to-s.from){if(e){let n=t.tr.step(s);n.setSelection(Ke(i,"end")?be.findFrom(n.doc.resolve(n.mapping.map(r.pos,-1)),-1):Ce.create(n.doc,r.pos-i.nodeSize)),e(n.scrollIntoView())}return!0}if(1==n||o.node(n-1).childCount>1)break}return!(!i.isAtom||r.depth!=o.depth-1||(e&&e(t.tr.delete(r.pos-i.nodeSize,r.pos).scrollIntoView()),0))};function We(t,e,n){let o=e.nodeBefore,r=e.pos-1;for(;!o.isTextblock;r--){if(o.type.spec.isolating)return!1;let t=o.lastChild;if(!t)return!1;o=t}let i=e.nodeAfter,s=e.pos+1;for(;!i.isTextblock;s++){if(i.type.spec.isolating)return!1;let t=i.firstChild;if(!t)return!1;i=t}let a=ne(t.doc,r,s,A.empty);if(!a||a.from!=r||a instanceof _t&&a.slice.size>=s-r)return!1;if(n){let e=t.tr.step(a);e.setSelection(xe.create(e.doc,r)),n(e.scrollIntoView())}return!0}function Ke(t,e,n=!1){for(let o=t;o;o="start"==e?o.firstChild:o.lastChild){if(o.isTextblock)return!0;if(n&&1!=o.childCount)return!1}return!1}const qe=(t,e,n)=>{let{$head:o,empty:r}=t.selection,i=o;if(!r)return!1;if(o.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):o.parentOffset>0)return!1;i=Ue(o)}let s=i&&i.nodeBefore;return!(!s||!Ce.isSelectable(s)||(e&&e(t.tr.setSelection(Ce.create(t.doc,i.pos-s.nodeSize)).scrollIntoView()),0))};function Ue(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function Je(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const Ge=(t,e,n)=>{let o=Je(t,n);if(!o)return!1;let r=Xe(o);if(!r)return!1;let i=r.nodeAfter;if(rn(t,r,e,1))return!0;if(0==o.parent.content.size&&(Ke(i,"start")||Ce.isSelectable(i))){let n=ne(t.doc,o.before(),o.after(),A.empty);if(n&&n.slice.size<n.to-n.from){if(e){let o=t.tr.step(n);o.setSelection(Ke(i,"start")?be.findFrom(o.doc.resolve(o.mapping.map(r.pos)),1):Ce.create(o.doc,o.mapping.map(r.pos))),e(o.scrollIntoView())}return!0}}return!(!i.isAtom||r.depth!=o.depth-1||(e&&e(t.tr.delete(r.pos,r.pos+i.nodeSize).scrollIntoView()),0))},Ye=(t,e,n)=>{let{$head:o,empty:r}=t.selection,i=o;if(!r)return!1;if(o.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):o.parentOffset<o.parent.content.size)return!1;i=Xe(o)}let s=i&&i.nodeAfter;return!(!s||!Ce.isSelectable(s)||(e&&e(t.tr.setSelection(Ce.create(t.doc,i.pos)).scrollIntoView()),0))};function Xe(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let n=t.node(e);if(t.index(e)+1<n.childCount)return t.doc.resolve(t.after(e+1));if(n.type.spec.isolating)break}return null}const Qe=(t,e)=>{let{$head:n,$anchor:o}=t.selection;return!(!n.parent.type.spec.code||!n.sameParent(o)||(e&&e(t.tr.insertText("\n").scrollIntoView()),0))};function Ze(t){for(let e=0;e<t.edgeCount;e++){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const tn=(t,e)=>{let{$head:n,$anchor:o}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(o))return!1;let r=n.node(-1),i=n.indexAfter(-1),s=Ze(r.contentMatchAt(i));if(!s||!r.canReplaceWith(i,i,s))return!1;if(e){let o=n.after(),r=t.tr.replaceWith(o,o,s.createAndFill());r.setSelection(be.near(r.doc.resolve(o),1)),e(r.scrollIntoView())}return!0},en=(t,e)=>{let n=t.selection,{$from:o,$to:r}=n;if(n instanceof Te||o.parent.inlineContent||r.parent.inlineContent)return!1;let i=Ze(r.parent.contentMatchAt(r.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let n=(!o.parentOffset&&r.index()<r.parent.childCount?o:r).pos,s=t.tr.insert(n,i.createAndFill());s.setSelection(xe.create(s.doc,n+1)),e(s.scrollIntoView())}return!0},nn=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let o=n.before();if(Xt(t.doc,o))return e&&e(t.tr.split(o).scrollIntoView()),!0}let o=n.blockRange(),r=o&&qt(o);return null!=r&&(e&&e(t.tr.lift(o,r).scrollIntoView()),!0)};var on;function rn(t,e,n,o){let r,i,s=e.nodeBefore,a=e.nodeAfter,l=s.type.spec.isolating||a.type.spec.isolating;if(!l&&function(t,e,n){let o=e.nodeBefore,r=e.nodeAfter,i=e.index();return!(!(o&&r&&o.type.compatibleContent(r.type))||(!o.content.size&&e.parent.canReplace(i-1,i)?(n&&n(t.tr.delete(e.pos-o.nodeSize,e.pos).scrollIntoView()),0):!e.parent.canReplace(i,i+1)||!r.isTextblock&&!Qt(t.doc,e.pos)||(n&&n(t.tr.join(e.pos).scrollIntoView()),0)))}(t,e,n))return!0;let c=!l&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(r=(i=s.contentMatchAt(s.childCount)).findWrapping(a.type))&&i.matchType(r[0]||a.type).validEnd){if(n){let o=e.pos+a.nodeSize,i=k.empty;for(let t=r.length-1;t>=0;t--)i=k.from(r[t].create(null,i));i=k.from(s.copy(i));let l=t.tr.step(new Vt(e.pos-1,o,e.pos,o,new A(i,1,0),r.length,!0)),c=l.doc.resolve(o+2*r.length);c.nodeAfter&&c.nodeAfter.type==s.type&&Qt(l.doc,c.pos)&&l.join(c.pos),n(l.scrollIntoView())}return!0}let d=a.type.spec.isolating||o>0&&l?null:be.findFrom(e,1),h=d&&d.$from.blockRange(d.$to),p=h&&qt(h);if(null!=p&&p>=e.depth)return n&&n(t.tr.lift(h,p).scrollIntoView()),!0;if(c&&Ke(a,"start",!0)&&Ke(s,"end")){let o=s,r=[];for(;r.push(o),!o.isTextblock;)o=o.lastChild;let i=a,l=1;for(;!i.isTextblock;i=i.firstChild)l++;if(o.canReplace(o.childCount,o.childCount,i.content)){if(n){let o=k.empty;for(let t=r.length-1;t>=0;t--)o=k.from(r[t].copy(o));n(t.tr.step(new Vt(e.pos-r.length,e.pos+a.nodeSize,e.pos+l,e.pos+a.nodeSize-l,new A(o,r.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function sn(t){return function(e,n){let o=e.selection,r=t<0?o.$from:o.$to,i=r.depth;for(;r.node(i).isInline;){if(!i)return!1;i--}return!!r.node(i).isTextblock&&(n&&n(e.tr.setSelection(xe.create(e.doc,t<0?r.start(i):r.end(i)))),!0)}}const an=sn(-1),ln=sn(1);function cn(t,e=null){return function(n,o){let r=!1;for(let o=0;o<n.selection.ranges.length&&!r;o++){let{$from:{pos:i},$to:{pos:s}}=n.selection.ranges[o];n.doc.nodesBetween(i,s,(o,i)=>{if(r)return!1;if(o.isTextblock&&!o.hasMarkup(t,e))if(o.type==t)r=!0;else{let e=n.doc.resolve(i),o=e.index();r=e.parent.canReplaceWith(o,o+1,t)}})}if(!r)return!1;if(o){let r=n.tr;for(let o=0;o<n.selection.ranges.length;o++){let{$from:{pos:i},$to:{pos:s}}=n.selection.ranges[o];r.setBlockType(i,s,t,e)}o(r.scrollIntoView())}return!0}}function dn(...t){return function(e,n,o){for(let r=0;r<t.length;r++)if(t[r](e,n,o))return!0;return!1}}let hn=dn(_e,Fe,qe),pn=dn(_e,Ge,Ye);const un={Enter:dn(Qe,en,nn,(t,e)=>{let{$from:n,$to:o}=t.selection;if(t.selection instanceof Ce&&t.selection.node.isBlock)return!(!n.parentOffset||!Xt(t.doc,n.pos)||(e&&e(t.tr.split(n.pos).scrollIntoView()),0));if(!n.depth)return!1;let r,i,s=[],a=!1,l=!1;for(let t=n.depth;;t--){if(n.node(t).isBlock){a=n.end(t)==n.pos+(n.depth-t),l=n.start(t)==n.pos-(n.depth-t),i=Ze(n.node(t-1).contentMatchAt(n.indexAfter(t-1)));let e=on;s.unshift(e||(a&&i?{type:i}:null)),r=t;break}if(1==t)return!1;s.unshift(null)}let c=t.tr;(t.selection instanceof xe||t.selection instanceof Te)&&c.deleteSelection();let d=c.mapping.map(n.pos),h=Xt(c.doc,d,s.length,s);if(h||(s[0]=i?{type:i}:null,h=Xt(c.doc,d,s.length,s)),!h)return!1;if(c.split(d,s.length,s),!a&&l&&n.node(r).type!=i){let t=c.mapping.map(n.before(r)),e=c.doc.resolve(t);i&&n.node(r-1).canReplaceWith(e.index(),e.index()+1,i)&&c.setNodeMarkup(c.mapping.map(n.before(r)),i)}return e&&e(c.scrollIntoView()),!0}),"Mod-Enter":tn,Backspace:hn,"Mod-Backspace":hn,"Shift-Backspace":hn,Delete:pn,"Mod-Delete":pn,"Mod-a":(t,e)=>(e&&e(t.tr.setSelection(new Te(t.doc))),!0)},fn={"Ctrl-h":un.Backspace,"Alt-Backspace":un["Mod-Backspace"],"Ctrl-d":un.Delete,"Ctrl-Alt-Backspace":un["Mod-Delete"],"Alt-Delete":un["Mod-Delete"],"Alt-d":un["Mod-Delete"],"Ctrl-a":an,"Ctrl-e":ln};for(let t in un)fn[t]=un[t];"undefined"!=typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):"undefined"!=typeof os&&os.platform&&os.platform();const mn=function(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e},gn=function(t){let e=t.assignedSlot||t.parentNode;return e&&11==e.nodeType?e.host:e};let yn=null;const bn=function(t,e,n){let o=yn||(yn=document.createRange());return o.setEnd(t,null==n?t.nodeValue.length:n),o.setStart(t,e||0),o},vn=function(t,e,n,o){return n&&(kn(t,e,n,o,-1)||kn(t,e,n,o,1))},wn=/^(img|br|input|textarea|hr)$/i;function kn(t,e,n,o,r){for(var i;;){if(t==n&&e==o)return!0;if(e==(r<0?0:xn(t))){let n=t.parentNode;if(!n||1!=n.nodeType||Mn(t)||wn.test(t.nodeName)||"false"==t.contentEditable)return!1;e=mn(t)+(r<0?0:1),t=n}else{if(1!=t.nodeType)return!1;{let n=t.childNodes[e+(r<0?-1:0)];if(1==n.nodeType&&"false"==n.contentEditable){if(!(null===(i=n.pmViewDesc)||void 0===i?void 0:i.ignoreForSelection))return!1;e+=r}else t=n,e=r<0?xn(t):0}}}}function xn(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function Mn(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const Cn=function(t){return t.focusNode&&vn(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Sn(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}const Tn="undefined"!=typeof navigator?navigator:null,An="undefined"!=typeof document?document:null,En=Tn&&Tn.userAgent||"",Nn=/Edge\/(\d+)/.exec(En),On=/MSIE \d/.exec(En),Ln=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(En),Rn=!!(On||Ln||Nn),Dn=On?document.documentMode:Ln?+Ln[1]:Nn?+Nn[1]:0,jn=!Rn&&/gecko\/(\d+)/i.test(En);jn&&(/Firefox\/(\d+)/.exec(En)||[0,0])[1];const In=!Rn&&/Chrome\/(\d+)/.exec(En),zn=!!In,$n=In?+In[1]:0,Pn=!Rn&&!!Tn&&/Apple Computer/.test(Tn.vendor),Hn=Pn&&(/Mobile\/\w+/.test(En)||!!Tn&&Tn.maxTouchPoints>2),Bn=Hn||!!Tn&&/Mac/.test(Tn.platform),_n=!!Tn&&/Win/.test(Tn.platform),Vn=/Android \d/.test(En),Fn=!!An&&"webkitFontSmoothing"in An.documentElement.style,Wn=Fn?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Kn(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function qn(t,e){return"number"==typeof t?t:t[e]}function Un(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,o=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*o}}function Jn(t,e,n){let o=t.someProp("scrollThreshold")||0,r=t.someProp("scrollMargin")||5,i=t.dom.ownerDocument;for(let s=n||t.dom;s;){if(1!=s.nodeType){s=gn(s);continue}let t=s,n=t==i.body,a=n?Kn(i):Un(t),l=0,c=0;if(e.top<a.top+qn(o,"top")?c=-(a.top-e.top+qn(r,"top")):e.bottom>a.bottom-qn(o,"bottom")&&(c=e.bottom-e.top>a.bottom-a.top?e.top+qn(r,"top")-a.top:e.bottom-a.bottom+qn(r,"bottom")),e.left<a.left+qn(o,"left")?l=-(a.left-e.left+qn(r,"left")):e.right>a.right-qn(o,"right")&&(l=e.right-a.right+qn(r,"right")),l||c)if(n)i.defaultView.scrollBy(l,c);else{let n=t.scrollLeft,o=t.scrollTop;c&&(t.scrollTop+=c),l&&(t.scrollLeft+=l);let r=t.scrollLeft-n,i=t.scrollTop-o;e={left:e.left-r,top:e.top-i,right:e.right-r,bottom:e.bottom-i}}let d=n?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(d))break;s="absolute"==d?s.offsetParent:gn(s)}}function Gn(t){let e=[],n=t.ownerDocument;for(let o=t;o&&(e.push({dom:o,top:o.scrollTop,left:o.scrollLeft}),t!=n);o=gn(o));return e}function Yn(t,e){for(let n=0;n<t.length;n++){let{dom:o,top:r,left:i}=t[n];o.scrollTop!=r+e&&(o.scrollTop=r+e),o.scrollLeft!=i&&(o.scrollLeft=i)}}let Xn=null;function Qn(t,e){let n,o,r,i,s=2e8,a=0,l=e.top,c=e.top;for(let d=t.firstChild,h=0;d;d=d.nextSibling,h++){let t;if(1==d.nodeType)t=d.getClientRects();else{if(3!=d.nodeType)continue;t=bn(d).getClientRects()}for(let p=0;p<t.length;p++){let u=t[p];if(u.top<=l&&u.bottom>=c){l=Math.max(u.bottom,l),c=Math.min(u.top,c);let t=u.left>e.left?u.left-e.left:u.right<e.left?e.left-u.right:0;if(t<s){n=d,s=t,o=t&&3==n.nodeType?{left:u.right<e.left?u.right:u.left,top:e.top}:e,1==d.nodeType&&t&&(a=h+(e.left>=(u.left+u.right)/2?1:0));continue}}else u.top>e.top&&!r&&u.left<=e.left&&u.right>=e.left&&(r=d,i={left:Math.max(u.left,Math.min(u.right,e.left)),top:u.top});!n&&(e.left>=u.right&&e.top>=u.top||e.left>=u.left&&e.top>=u.bottom)&&(a=h+1)}}return!n&&r&&(n=r,o=i,s=0),n&&3==n.nodeType?function(t,e){let n=t.nodeValue.length,o=document.createRange();for(let r=0;r<n;r++){o.setEnd(t,r+1),o.setStart(t,r);let n=oo(o,1);if(n.top!=n.bottom&&Zn(e,n))return{node:t,offset:r+(e.left>=(n.left+n.right)/2?1:0)}}return{node:t,offset:0}}(n,o):!n||s&&1==n.nodeType?{node:t,offset:a}:Qn(n,o)}function Zn(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function to(t,e,n){let o=t.childNodes.length;if(o&&n.top<n.bottom)for(let r=Math.max(0,Math.min(o-1,Math.floor(o*(e.top-n.top)/(n.bottom-n.top))-2)),i=r;;){let n=t.childNodes[i];if(1==n.nodeType){let t=n.getClientRects();for(let o=0;o<t.length;o++){let r=t[o];if(Zn(e,r))return to(n,e,r)}}if((i=(i+1)%o)==r)break}return t}function eo(t,e){let n,o=t.dom.ownerDocument,r=0,i=function(t,e,n){if(t.caretPositionFromPoint)try{let o=t.caretPositionFromPoint(e,n);if(o)return{node:o.offsetNode,offset:Math.min(xn(o.offsetNode),o.offset)}}catch(t){}if(t.caretRangeFromPoint){let o=t.caretRangeFromPoint(e,n);if(o)return{node:o.startContainer,offset:Math.min(xn(o.startContainer),o.startOffset)}}}(o,e.left,e.top);i&&({node:n,offset:r}=i);let s,a=(t.root.elementFromPoint?t.root:o).elementFromPoint(e.left,e.top);if(!a||!t.dom.contains(1!=a.nodeType?a.parentNode:a)){let n=t.dom.getBoundingClientRect();if(!Zn(e,n))return null;if(a=to(t.dom,e,n),!a)return null}if(Pn)for(let t=a;n&&t;t=gn(t))t.draggable&&(n=void 0);if(a=function(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}(a,e),n){if(jn&&1==n.nodeType&&(r=Math.min(r,n.childNodes.length),r<n.childNodes.length)){let t,o=n.childNodes[r];"IMG"==o.nodeName&&(t=o.getBoundingClientRect()).right<=e.left&&t.bottom>e.top&&r++}let o;Fn&&r&&1==n.nodeType&&1==(o=n.childNodes[r-1]).nodeType&&"false"==o.contentEditable&&o.getBoundingClientRect().top>=e.top&&r--,n==t.dom&&r==n.childNodes.length-1&&1==n.lastChild.nodeType&&e.top>n.lastChild.getBoundingClientRect().bottom?s=t.state.doc.content.size:0!=r&&1==n.nodeType&&"BR"==n.childNodes[r-1].nodeName||(s=function(t,e,n,o){let r=-1;for(let n=e,i=!1;n!=t.dom;){let e,s=t.docView.nearestDesc(n,!0);if(!s)return null;if(1==s.dom.nodeType&&(s.node.isBlock&&s.parent||!s.contentDOM)&&((e=s.dom.getBoundingClientRect()).width||e.height)&&(s.node.isBlock&&s.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(s.dom.nodeName)&&(!i&&e.left>o.left||e.top>o.top?r=s.posBefore:(!i&&e.right<o.left||e.bottom<o.top)&&(r=s.posAfter),i=!0),!s.contentDOM&&r<0&&!s.node.isText))return(s.node.isBlock?o.top<(e.top+e.bottom)/2:o.left<(e.left+e.right)/2)?s.posBefore:s.posAfter;n=s.dom.parentNode}return r>-1?r:t.docView.posFromDOM(e,n,-1)}(t,n,r,e))}null==s&&(s=function(t,e,n){let{node:o,offset:r}=Qn(e,n),i=-1;if(1==o.nodeType&&!o.firstChild){let t=o.getBoundingClientRect();i=t.left!=t.right&&n.left>(t.left+t.right)/2?1:-1}return t.docView.posFromDOM(o,r,i)}(t,a,e));let l=t.docView.nearestDesc(a,!0);return{pos:s,inside:l?l.posAtStart-l.border:-1}}function no(t){return t.top<t.bottom||t.left<t.right}function oo(t,e){let n=t.getClientRects();if(n.length){let t=n[e<0?0:n.length-1];if(no(t))return t}return Array.prototype.find.call(n,no)||t.getBoundingClientRect()}const ro=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function io(t,e,n){let{node:o,offset:r,atom:i}=t.docView.domFromPos(e,n<0?-1:1),s=Fn||jn;if(3==o.nodeType){if(!s||!ro.test(o.nodeValue)&&(n<0?r:r!=o.nodeValue.length)){let t=r,e=r,i=n<0?1:-1;return n<0&&!r?(e++,i=-1):n>=0&&r==o.nodeValue.length?(t--,i=1):n<0?t--:e++,so(oo(bn(o,t,e),i),i<0)}{let t=oo(bn(o,r,r),n);if(jn&&r&&/\s/.test(o.nodeValue[r-1])&&r<o.nodeValue.length){let e=oo(bn(o,r-1,r-1),-1);if(e.top==t.top){let n=oo(bn(o,r,r+1),-1);if(n.top!=t.top)return so(n,n.left<e.left)}}return t}}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(null==i&&r&&(n<0||r==xn(o))){let t=o.childNodes[r-1];if(1==t.nodeType)return ao(t.getBoundingClientRect(),!1)}if(null==i&&r<xn(o)){let t=o.childNodes[r];if(1==t.nodeType)return ao(t.getBoundingClientRect(),!0)}return ao(o.getBoundingClientRect(),n>=0)}if(null==i&&r&&(n<0||r==xn(o))){let t=o.childNodes[r-1],e=3==t.nodeType?bn(t,xn(t)-(s?0:1)):1!=t.nodeType||"BR"==t.nodeName&&t.nextSibling?null:t;if(e)return so(oo(e,1),!1)}if(null==i&&r<xn(o)){let t=o.childNodes[r];for(;t.pmViewDesc&&t.pmViewDesc.ignoreForCoords;)t=t.nextSibling;let e=t?3==t.nodeType?bn(t,0,s?0:1):1==t.nodeType?t:null:null;if(e)return so(oo(e,-1),!0)}return so(oo(3==o.nodeType?bn(o):o,-n),n>=0)}function so(t,e){if(0==t.width)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function ao(t,e){if(0==t.height)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function lo(t,e,n){let o=t.state,r=t.root.activeElement;o!=e&&t.updateState(e),r!=t.dom&&t.focus();try{return n()}finally{o!=e&&t.updateState(o),r!=t.dom&&r&&r.focus()}}const co=/[\u0590-\u08ac]/;let ho=null,po=null,uo=!1;class fo{constructor(t,e,n,o){this.parent=t,this.children=e,this.dom=n,this.contentDOM=o,this.dirty=0,n.pmViewDesc=this}matchesWidget(t){return!1}matchesMark(t){return!1}matchesNode(t,e,n){return!1}matchesHack(t){return!1}parseRule(){return null}stopEvent(t){return!1}get size(){let t=0;for(let e=0;e<this.children.length;e++)t+=this.children[e].size;return t}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let t=0;t<this.children.length;t++)this.children[t].destroy()}posBeforeChild(t){for(let e=0,n=this.posAtStart;;e++){let o=this.children[e];if(o==t)return n;n+=o.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(t,e,n){if(this.contentDOM&&this.contentDOM.contains(1==t.nodeType?t:t.parentNode)){if(n<0){let n,o;if(t==this.contentDOM)n=t.childNodes[e-1];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;n=t.previousSibling}for(;n&&(!(o=n.pmViewDesc)||o.parent!=this);)n=n.previousSibling;return n?this.posBeforeChild(o)+o.size:this.posAtStart}{let n,o;if(t==this.contentDOM)n=t.childNodes[e];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;n=t.nextSibling}for(;n&&(!(o=n.pmViewDesc)||o.parent!=this);)n=n.nextSibling;return n?this.posBeforeChild(o):this.posAtEnd}}let o;if(t==this.dom&&this.contentDOM)o=e>mn(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))o=2&t.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==e)for(let e=t;;e=e.parentNode){if(e==this.dom){o=!1;break}if(e.previousSibling)break}if(null==o&&e==t.childNodes.length)for(let e=t;;e=e.parentNode){if(e==this.dom){o=!0;break}if(e.nextSibling)break}}return(null==o?n>0:o)?this.posAtEnd:this.posAtStart}nearestDesc(t,e=!1){for(let n=!0,o=t;o;o=o.parentNode){let r,i=this.getDesc(o);if(i&&(!e||i.node)){if(!n||!(r=i.nodeDOM)||(1==r.nodeType?r.contains(1==t.nodeType?t:t.parentNode):r==t))return i;n=!1}}}getDesc(t){let e=t.pmViewDesc;for(let t=e;t;t=t.parent)if(t==this)return e}posFromDOM(t,e,n){for(let o=t;o;o=o.parentNode){let r=this.getDesc(o);if(r)return r.localPosFromDOM(t,e,n)}return-1}descAt(t){for(let e=0,n=0;e<this.children.length;e++){let o=this.children[e],r=n+o.size;if(n==t&&r!=n){for(;!o.border&&o.children.length;)for(let t=0;t<o.children.length;t++){let e=o.children[t];if(e.size){o=e;break}}return o}if(t<r)return o.descAt(t-n-o.border);n=r}}domFromPos(t,e){if(!this.contentDOM)return{node:this.dom,offset:0,atom:t+1};let n=0,o=0;for(let e=0;n<this.children.length;n++){let r=this.children[n],i=e+r.size;if(i>t||r instanceof ko){o=t-e;break}e=i}if(o)return this.children[n].domFromPos(o-this.children[n].border,e);for(let t;n&&!(t=this.children[n-1]).size&&t instanceof mo&&t.side>=0;n--);if(e<=0){let t,o=!0;for(;t=n?this.children[n-1]:null,t&&t.dom.parentNode!=this.contentDOM;n--,o=!1);return t&&e&&o&&!t.border&&!t.domAtom?t.domFromPos(t.size,e):{node:this.contentDOM,offset:t?mn(t.dom)+1:0}}{let t,o=!0;for(;t=n<this.children.length?this.children[n]:null,t&&t.dom.parentNode!=this.contentDOM;n++,o=!1);return t&&o&&!t.border&&!t.domAtom?t.domFromPos(0,e):{node:this.contentDOM,offset:t?mn(t.dom):this.contentDOM.childNodes.length}}}parseRange(t,e,n=0){if(0==this.children.length)return{node:this.contentDOM,from:t,to:e,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let o=-1,r=-1;for(let i=n,s=0;;s++){let n=this.children[s],a=i+n.size;if(-1==o&&t<=a){let r=i+n.border;if(t>=r&&e<=a-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(t,e,r);t=i;for(let e=s;e>0;e--){let n=this.children[e-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){o=mn(n.dom)+1;break}t-=n.size}-1==o&&(o=0)}if(o>-1&&(a>e||s==this.children.length-1)){e=a;for(let t=s+1;t<this.children.length;t++){let n=this.children[t];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(-1)){r=mn(n.dom);break}e+=n.size}-1==r&&(r=this.contentDOM.childNodes.length);break}i=a}return{node:this.contentDOM,from:t,to:e,fromOffset:o,toOffset:r}}emptyChildAt(t){if(this.border||!this.contentDOM||!this.children.length)return!1;let e=this.children[t<0?0:this.children.length-1];return 0==e.size||e.emptyChildAt(t)}domAfterPos(t){let{node:e,offset:n}=this.domFromPos(t,0);if(1!=e.nodeType||n==e.childNodes.length)throw new RangeError("No node after pos "+t);return e.childNodes[n]}setSelection(t,e,n,o=!1){let r=Math.min(t,e),i=Math.max(t,e);for(let s=0,a=0;s<this.children.length;s++){let l=this.children[s],c=a+l.size;if(r>a&&i<c)return l.setSelection(t-a-l.border,e-a-l.border,n,o);a=c}let s=this.domFromPos(t,t?-1:1),a=e==t?s:this.domFromPos(e,e?-1:1),l=n.root.getSelection(),c=n.domSelectionRange(),d=!1;if((jn||Pn)&&t==e){let{node:t,offset:e}=s;if(3==t.nodeType){if(d=!(!e||"\n"!=t.nodeValue[e-1]),d&&e==t.nodeValue.length)for(let e,n=t;n;n=n.parentNode){if(e=n.nextSibling){"BR"==e.nodeName&&(s=a={node:e.parentNode,offset:mn(e)+1});break}let t=n.pmViewDesc;if(t&&t.node&&t.node.isBlock)break}}else{let n=t.childNodes[e-1];d=n&&("BR"==n.nodeName||"false"==n.contentEditable)}}if(jn&&c.focusNode&&c.focusNode!=a.node&&1==c.focusNode.nodeType){let t=c.focusNode.childNodes[c.focusOffset];t&&"false"==t.contentEditable&&(o=!0)}if(!(o||d&&Pn)&&vn(s.node,s.offset,c.anchorNode,c.anchorOffset)&&vn(a.node,a.offset,c.focusNode,c.focusOffset))return;let h=!1;if((l.extend||t==e)&&(!d||!jn)){l.collapse(s.node,s.offset);try{t!=e&&l.extend(a.node,a.offset),h=!0}catch(t){}}if(!h){if(t>e){let t=s;s=a,a=t}let n=document.createRange();n.setEnd(a.node,a.offset),n.setStart(s.node,s.offset),l.removeAllRanges(),l.addRange(n)}}ignoreMutation(t){return!this.contentDOM&&"selection"!=t.type}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(t,e){for(let n=0,o=0;o<this.children.length;o++){let r=this.children[o],i=n+r.size;if(n==i?t<=i&&e>=n:t<i&&e>n){let o=n+r.border,s=i-r.border;if(t>=o&&e<=s)return this.dirty=t==n||e==i?2:1,void(t!=o||e!=s||!r.contentLost&&r.dom.parentNode==this.contentDOM?r.markDirty(t-o,e-o):r.dirty=3);r.dirty=r.dom!=r.contentDOM||r.dom.parentNode!=this.contentDOM||r.children.length?3:2}n=i}this.dirty=2}markParentsDirty(){let t=1;for(let e=this.parent;e;e=e.parent,t++){let n=1==t?2:1;e.dirty<n&&(e.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(t){return!1}}class mo extends fo{constructor(t,e,n,o){let r,i=e.type.toDOM;if("function"==typeof i&&(i=i(n,()=>r?r.parent?r.parent.posBeforeChild(r):void 0:o)),!e.type.spec.raw){if(1!=i.nodeType){let t=document.createElement("span");t.appendChild(i),i=t}i.contentEditable="false",i.classList.add("ProseMirror-widget")}super(t,[],i,null),this.widget=e,this.widget=e,r=this}matchesWidget(t){return 0==this.dirty&&t.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(t){let e=this.widget.spec.stopEvent;return!!e&&e(t)}ignoreMutation(t){return"selection"!=t.type||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class go extends fo{constructor(t,e,n,o){super(t,[],e,null),this.textDOM=n,this.text=o}get size(){return this.text.length}localPosFromDOM(t,e){return t!=this.textDOM?this.posAtStart+(e?this.size:0):this.posAtStart+e}domFromPos(t){return{node:this.textDOM,offset:t}}ignoreMutation(t){return"characterData"===t.type&&t.target.nodeValue==t.oldValue}}class yo extends fo{constructor(t,e,n,o,r){super(t,[],n,o),this.mark=e,this.spec=r}static create(t,e,n,o){let r=o.nodeViews[e.type.name],i=r&&r(e,o,n);return i&&i.dom||(i=xt.renderSpec(document,e.type.spec.toDOM(e,n),null,e.attrs)),new yo(t,e,i.dom,i.contentDOM||i.dom,i)}parseRule(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(t){return 3!=this.dirty&&this.mark.eq(t)}markDirty(t,e){if(super.markDirty(t,e),0!=this.dirty){let t=this.parent;for(;!t.node;)t=t.parent;t.dirty<this.dirty&&(t.dirty=this.dirty),this.dirty=0}}slice(t,e,n){let o=yo.create(this.parent,this.mark,!0,n),r=this.children,i=this.size;e<i&&(r=jo(r,e,i,n)),t>0&&(r=jo(r,0,t,n));for(let t=0;t<r.length;t++)r[t].parent=o;return o.children=r,o}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class bo extends fo{constructor(t,e,n,o,r,i,s,a,l){super(t,[],r,i),this.node=e,this.outerDeco=n,this.innerDeco=o,this.nodeDOM=s}static create(t,e,n,o,r,i){let s,a=r.nodeViews[e.type.name],l=a&&a(e,r,()=>s?s.parent?s.parent.posBeforeChild(s):void 0:i,n,o),c=l&&l.dom,d=l&&l.contentDOM;if(e.isText)if(c){if(3!=c.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else c=document.createTextNode(e.text);else if(!c){let t=xt.renderSpec(document,e.type.spec.toDOM(e),null,e.attrs);({dom:c,contentDOM:d}=t)}d||e.isText||"BR"==c.nodeName||(c.hasAttribute("contenteditable")||(c.contentEditable="false"),e.type.spec.draggable&&(c.draggable=!0));let h=c;return c=No(c,n,e),l?s=new xo(t,e,n,o,c,d||null,h,l,r,i+1):e.isText?new wo(t,e,n,o,c,h,r):new bo(t,e,n,o,c,d||null,h,r,i+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(t.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(let e=this.children.length-1;e>=0;e--){let n=this.children[e];if(this.dom.contains(n.dom.parentNode)){t.contentElement=n.dom.parentNode;break}}t.contentElement||(t.getContent=()=>k.empty)}else t.contentElement=this.contentDOM;else t.getContent=()=>this.node.content;return t}matchesNode(t,e,n){return 0==this.dirty&&t.eq(this.node)&&Oo(e,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(t,e){let n=this.node.inlineContent,o=e,r=t.composing?this.localCompositionInfo(t,e):null,i=r&&r.pos>-1?r:null,s=r&&r.pos<0,a=new Ro(this,i&&i.node,t);!function(t,e,n,o){let r=e.locals(t),i=0;if(0==r.length){for(let n=0;n<t.childCount;n++){let s=t.child(n);o(s,r,e.forChild(i,s),n),i+=s.nodeSize}return}let s=0,a=[],l=null;for(let c=0;;){let d,h,p,u;for(;s<r.length&&r[s].to==i;){let t=r[s++];t.widget&&(d?(h||(h=[d])).push(t):d=t)}if(d)if(h){h.sort(Do);for(let t=0;t<h.length;t++)n(h[t],c,!!l)}else n(d,c,!!l);if(l)u=-1,p=l,l=null;else{if(!(c<t.childCount))break;u=c,p=t.child(c++)}for(let t=0;t<a.length;t++)a[t].to<=i&&a.splice(t--,1);for(;s<r.length&&r[s].from<=i&&r[s].to>i;)a.push(r[s++]);let f=i+p.nodeSize;if(p.isText){let t=f;s<r.length&&r[s].from<t&&(t=r[s].from);for(let e=0;e<a.length;e++)a[e].to<t&&(t=a[e].to);t<f&&(l=p.cut(t-i),p=p.cut(0,t-i),f=t,u=-1)}else for(;s<r.length&&r[s].to<f;)s++;o(p,p.isInline&&!p.isLeaf?a.filter(t=>!t.inline):a.slice(),e.forChild(i,p),u),i=f}}(this.node,this.innerDeco,(e,r,i)=>{e.spec.marks?a.syncToMarks(e.spec.marks,n,t):e.type.side>=0&&!i&&a.syncToMarks(r==this.node.childCount?S.none:this.node.child(r).marks,n,t),a.placeWidget(e,t,o)},(e,i,l,c)=>{let d;a.syncToMarks(e.marks,n,t),a.findNodeMatch(e,i,l,c)||s&&t.state.selection.from>o&&t.state.selection.to<o+e.nodeSize&&(d=a.findIndexWithChild(r.node))>-1&&a.updateNodeAt(e,i,l,d,t)||a.updateNextNode(e,i,l,t,c,o)||a.addNode(e,i,l,t,o),o+=e.nodeSize}),a.syncToMarks([],n,t),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||2==this.dirty)&&(i&&this.protectLocalComposition(t,i),Mo(this.contentDOM,this.children,t),Hn&&function(t){if("UL"==t.nodeName||"OL"==t.nodeName){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}(this.dom))}localCompositionInfo(t,e){let{from:n,to:o}=t.state.selection;if(!(t.state.selection instanceof xe)||n<e||o>e+this.node.content.size)return null;let r=t.input.compositionNode;if(!r||!this.dom.contains(r.parentNode))return null;if(this.node.inlineContent){let t=r.nodeValue,i=function(t,e,n,o){for(let r=0,i=0;r<t.childCount&&i<=o;){let s=t.child(r++),a=i;if(i+=s.nodeSize,!s.isText)continue;let l=s.text;for(;r<t.childCount;){let e=t.child(r++);if(i+=e.nodeSize,!e.isText)break;l+=e.text}if(i>=n){if(i>=o&&l.slice(o-e.length-a,o-a)==e)return o-e.length;let t=a<o?l.lastIndexOf(e,o-a-1):-1;if(t>=0&&t+e.length+a>=n)return a+t;if(n==o&&l.length>=o+e.length-a&&l.slice(o-a,o-a+e.length)==e)return o}}return-1}(this.node.content,t,n-e,o-e);return i<0?null:{node:r,pos:i,text:t}}return{node:r,pos:-1,text:""}}protectLocalComposition(t,{node:e,pos:n,text:o}){if(this.getDesc(e))return;let r=e;for(;r.parentNode!=this.contentDOM;r=r.parentNode){for(;r.previousSibling;)r.parentNode.removeChild(r.previousSibling);for(;r.nextSibling;)r.parentNode.removeChild(r.nextSibling);r.pmViewDesc&&(r.pmViewDesc=void 0)}let i=new go(this,r,e,o);t.input.compositionNodes.push(i),this.children=jo(this.children,n,n+o.length,t,i)}update(t,e,n,o){return!(3==this.dirty||!t.sameMarkup(this.node)||(this.updateInner(t,e,n,o),0))}updateInner(t,e,n,o){this.updateOuterDeco(e),this.node=t,this.innerDeco=n,this.contentDOM&&this.updateChildren(o,this.posAtStart),this.dirty=0}updateOuterDeco(t){if(Oo(t,this.outerDeco))return;let e=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=Ao(this.dom,this.nodeDOM,To(this.outerDeco,this.node,e),To(t,this.node,e)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=t}selectNode(){1==this.nodeDOM.nodeType&&this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.dom.draggable=!0)}deselectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function vo(t,e,n,o,r){No(o,e,t);let i=new bo(void 0,t,e,n,o,o,o,r,0);return i.contentDOM&&i.updateChildren(r,0),i}class wo extends bo{constructor(t,e,n,o,r,i,s){super(t,e,n,o,r,null,i,s,0)}parseRule(){let t=this.nodeDOM.parentNode;for(;t&&t!=this.dom&&!t.pmIsDeco;)t=t.parentNode;return{skip:t||!0}}update(t,e,n,o){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,o.trackWrites==this.nodeDOM&&(o.trackWrites=null)),this.node=t,this.dirty=0,0))}inParent(){let t=this.parent.contentDOM;for(let e=this.nodeDOM;e;e=e.parentNode)if(e==t)return!0;return!1}domFromPos(t){return{node:this.nodeDOM,offset:t}}localPosFromDOM(t,e,n){return t==this.nodeDOM?this.posAtStart+Math.min(e,this.node.text.length):super.localPosFromDOM(t,e,n)}ignoreMutation(t){return"characterData"!=t.type&&"selection"!=t.type}slice(t,e,n){let o=this.node.cut(t,e),r=document.createTextNode(o.text);return new wo(this.parent,o,this.outerDeco,this.innerDeco,r,r,n)}markDirty(t,e){super.markDirty(t,e),this.dom==this.nodeDOM||0!=t&&e!=this.nodeDOM.nodeValue.length||(this.dirty=3)}get domAtom(){return!1}isText(t){return this.node.text==t}}class ko extends fo{parseRule(){return{ignore:!0}}matchesHack(t){return 0==this.dirty&&this.dom.nodeName==t}get domAtom(){return!0}get ignoreForCoords(){return"IMG"==this.dom.nodeName}}class xo extends bo{constructor(t,e,n,o,r,i,s,a,l,c){super(t,e,n,o,r,i,s,l,c),this.spec=a}update(t,e,n,o){if(3==this.dirty)return!1;if(this.spec.update&&(this.node.type==t.type||this.spec.multiType)){let r=this.spec.update(t,e,n);return r&&this.updateInner(t,e,n,o),r}return!(!this.contentDOM&&!t.isLeaf)&&super.update(t,e,n,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(t,e,n,o){this.spec.setSelection?this.spec.setSelection(t,e,n.root):super.setSelection(t,e,n,o)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(t){return!!this.spec.stopEvent&&this.spec.stopEvent(t)}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}}function Mo(t,e,n){let o=t.firstChild,r=!1;for(let i=0;i<e.length;i++){let s=e[i],a=s.dom;if(a.parentNode==t){for(;a!=o;)o=Lo(o),r=!0;o=o.nextSibling}else r=!0,t.insertBefore(a,o);if(s instanceof yo){let e=o?o.previousSibling:t.lastChild;Mo(s.contentDOM,s.children,n),o=e?e.nextSibling:t.firstChild}}for(;o;)o=Lo(o),r=!0;r&&n.trackWrites==t&&(n.trackWrites=null)}const Co=function(t){t&&(this.nodeName=t)};Co.prototype=Object.create(null);const So=[new Co];function To(t,e,n){if(0==t.length)return So;let o=n?So[0]:new Co,r=[o];for(let i=0;i<t.length;i++){let s=t[i].type.attrs;if(s){s.nodeName&&r.push(o=new Co(s.nodeName));for(let t in s){let i=s[t];null!=i&&(n&&1==r.length&&r.push(o=new Co(e.isInline?"span":"div")),"class"==t?o.class=(o.class?o.class+" ":"")+i:"style"==t?o.style=(o.style?o.style+";":"")+i:"nodeName"!=t&&(o[t]=i))}}}return r}function Ao(t,e,n,o){if(n==So&&o==So)return e;let r=e;for(let e=0;e<o.length;e++){let i=o[e],s=n[e];if(e){let e;s&&s.nodeName==i.nodeName&&r!=t&&(e=r.parentNode)&&e.nodeName.toLowerCase()==i.nodeName||(e=document.createElement(i.nodeName),e.pmIsDeco=!0,e.appendChild(r),s=So[0]),r=e}Eo(r,s||So[0],i)}return r}function Eo(t,e,n){for(let o in e)"class"==o||"style"==o||"nodeName"==o||o in n||t.removeAttribute(o);for(let o in n)"class"!=o&&"style"!=o&&"nodeName"!=o&&n[o]!=e[o]&&t.setAttribute(o,n[o]);if(e.class!=n.class){let o=e.class?e.class.split(" ").filter(Boolean):[],r=n.class?n.class.split(" ").filter(Boolean):[];for(let e=0;e<o.length;e++)-1==r.indexOf(o[e])&&t.classList.remove(o[e]);for(let e=0;e<r.length;e++)-1==o.indexOf(r[e])&&t.classList.add(r[e]);0==t.classList.length&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let n,o=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;for(;n=o.exec(e.style);)t.style.removeProperty(n[1])}n.style&&(t.style.cssText+=n.style)}}function No(t,e,n){return Ao(t,t,So,To(e,n,1!=t.nodeType))}function Oo(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return!1;return!0}function Lo(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class Ro{constructor(t,e,n){this.lock=e,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=t,this.preMatch=function(t,e){let n=e,o=n.children.length,r=t.childCount,i=new Map,s=[];t:for(;r>0;){let a;for(;;)if(o){let t=n.children[o-1];if(!(t instanceof yo)){a=t,o--;break}n=t,o=t.children.length}else{if(n==e)break t;o=n.parent.children.indexOf(n),n=n.parent}let l=a.node;if(l){if(l!=t.child(r-1))break;--r,i.set(a,r),s.push(a)}}return{index:r,matched:i,matches:s.reverse()}}(t.node.content,t)}destroyBetween(t,e){if(t!=e){for(let n=t;n<e;n++)this.top.children[n].destroy();this.top.children.splice(t,e-t),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(t,e,n){let o=0,r=this.stack.length>>1,i=Math.min(r,t.length);for(;o<i&&(o==r-1?this.top:this.stack[o+1<<1]).matchesMark(t[o])&&!1!==t[o].type.spec.spanning;)o++;for(;o<r;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),r--;for(;r<t.length;){this.stack.push(this.top,this.index+1);let o=-1;for(let e=this.index;e<Math.min(this.index+3,this.top.children.length);e++){let n=this.top.children[e];if(n.matchesMark(t[r])&&!this.isLocked(n.dom)){o=e;break}}if(o>-1)o>this.index&&(this.changed=!0,this.destroyBetween(this.index,o)),this.top=this.top.children[this.index];else{let o=yo.create(this.top,t[r],e,n);this.top.children.splice(this.index,0,o),this.top=o,this.changed=!0}this.index=0,r++}}findNodeMatch(t,e,n,o){let r,i=-1;if(o>=this.preMatch.index&&(r=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&r.matchesNode(t,e,n))i=this.top.children.indexOf(r,this.index);else for(let o=this.index,r=Math.min(this.top.children.length,o+5);o<r;o++){let r=this.top.children[o];if(r.matchesNode(t,e,n)&&!this.preMatch.matched.has(r)){i=o;break}}return!(i<0||(this.destroyBetween(this.index,i),this.index++,0))}updateNodeAt(t,e,n,o,r){let i=this.top.children[o];return 3==i.dirty&&i.dom==i.contentDOM&&(i.dirty=2),!!i.update(t,e,n,r)&&(this.destroyBetween(this.index,o),this.index++,!0)}findIndexWithChild(t){for(;;){let e=t.parentNode;if(!e)return-1;if(e==this.top.contentDOM){let e=t.pmViewDesc;if(e)for(let t=this.index;t<this.top.children.length;t++)if(this.top.children[t]==e)return t;return-1}t=e}}updateNextNode(t,e,n,o,r,i){for(let s=this.index;s<this.top.children.length;s++){let a=this.top.children[s];if(a instanceof bo){let l=this.preMatch.matched.get(a);if(null!=l&&l!=r)return!1;let c,d=a.dom,h=this.isLocked(d)&&!(t.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==t.text&&3!=a.dirty&&Oo(e,a.outerDeco));if(!h&&a.update(t,e,n,o))return this.destroyBetween(this.index,s),a.dom!=d&&(this.changed=!0),this.index++,!0;if(!h&&(c=this.recreateWrapper(a,t,e,n,o,i)))return this.destroyBetween(this.index,s),this.top.children[this.index]=c,c.contentDOM&&(c.dirty=2,c.updateChildren(o,i+1),c.dirty=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(t,e,n,o,r,i){if(t.dirty||e.isAtom||!t.children.length||!t.node.content.eq(e.content)||!Oo(n,t.outerDeco)||!o.eq(t.innerDeco))return null;let s=bo.create(this.top,e,n,o,r,i);if(s.contentDOM){s.children=t.children,t.children=[];for(let t of s.children)t.parent=s}return t.destroy(),s}addNode(t,e,n,o,r){let i=bo.create(this.top,t,e,n,o,r);i.contentDOM&&i.updateChildren(o,r+1),this.top.children.splice(this.index++,0,i),this.changed=!0}placeWidget(t,e,n){let o=this.index<this.top.children.length?this.top.children[this.index]:null;if(!o||!o.matchesWidget(t)||t!=o.widget&&o.widget.type.toDOM.parentNode){let o=new mo(this.top,t,e,n);this.top.children.splice(this.index++,0,o),this.changed=!0}else this.index++}addTextblockHacks(){let t=this.top.children[this.index-1],e=this.top;for(;t instanceof yo;)e=t,t=e.children[e.children.length-1];(!t||!(t instanceof wo)||/\n$/.test(t.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(t.node.text))&&((Pn||zn)&&t&&"false"==t.dom.contentEditable&&this.addHackNode("IMG",e),this.addHackNode("BR",this.top))}addHackNode(t,e){if(e==this.top&&this.index<e.children.length&&e.children[this.index].matchesHack(t))this.index++;else{let n=document.createElement(t);"IMG"==t&&(n.className="ProseMirror-separator",n.alt=""),"BR"==t&&(n.className="ProseMirror-trailingBreak");let o=new ko(this.top,[],n,null);e!=this.top?e.children.push(o):e.children.splice(this.index++,0,o),this.changed=!0}}isLocked(t){return this.lock&&(t==this.lock||1==t.nodeType&&t.contains(this.lock.parentNode))}}function Do(t,e){return t.type.side-e.type.side}function jo(t,e,n,o,r){let i=[];for(let s=0,a=0;s<t.length;s++){let l=t[s],c=a,d=a+=l.size;c>=n||d<=e?i.push(l):(c<e&&i.push(l.slice(0,e-c,o)),r&&(i.push(r),r=void 0),d>n&&i.push(l.slice(n-c,l.size,o)))}return i}function Io(t,e=null){let n=t.domSelectionRange(),o=t.state.doc;if(!n.focusNode)return null;let r=t.docView.nearestDesc(n.focusNode),i=r&&0==r.size,s=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let a,l,c=o.resolve(s);if(Cn(n)){for(a=s;r&&!r.node;)r=r.parent;let t=r.node;if(r&&t.isAtom&&Ce.isSelectable(t)&&r.parent&&(!t.isInline||!function(t,e,n){for(let o=0==e,r=e==xn(t);o||r;){if(t==n)return!0;let e=mn(t);if(!(t=t.parentNode))return!1;o=o&&0==e,r=r&&e==xn(t)}}(n.focusNode,n.focusOffset,r.dom))){let t=r.posBefore;l=new Ce(s==t?c:o.resolve(t))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let e=s,r=s;for(let o=0;o<n.rangeCount;o++){let i=n.getRangeAt(o);e=Math.min(e,t.docView.posFromDOM(i.startContainer,i.startOffset,1)),r=Math.max(r,t.docView.posFromDOM(i.endContainer,i.endOffset,-1))}if(e<0)return null;[a,s]=r==t.state.selection.anchor?[r,e]:[e,r],c=o.resolve(s)}else a=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(a<0)return null}let d=o.resolve(a);return l||(l=Wo(t,d,c,"pointer"==e||t.state.selection.head<c.pos&&!i?1:-1)),l}function zo(t){return t.editable?t.hasFocus():qo(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function $o(t,e=!1){let n=t.state.selection;if(Vo(t,n),zo(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&zn){let e=t.domSelectionRange(),n=t.domObserver.currentSelection;if(e.anchorNode&&n.anchorNode&&vn(e.anchorNode,e.anchorOffset,n.anchorNode,n.anchorOffset))return t.input.mouseDown.delayedSelectionSync=!0,void t.domObserver.setCurSelection()}if(t.domObserver.disconnectSelection(),t.cursorWrapper)!function(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,o="IMG"==n.nodeName;o?e.collapse(n.parentNode,mn(n)+1):e.collapse(n,0),!o&&!t.state.selection.visible&&Rn&&Dn<=11&&(n.disabled=!0,n.disabled=!1)}(t);else{let o,r,{anchor:i,head:s}=n;!Po||n instanceof xe||(n.$from.parent.inlineContent||(o=Ho(t,n.from)),n.empty||n.$from.parent.inlineContent||(r=Ho(t,n.to))),t.docView.setSelection(i,s,t,e),Po&&(o&&_o(o),r&&_o(r)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),o=n.anchorNode,r=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{n.anchorNode==o&&n.anchorOffset==r||(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{zo(t)&&!t.state.selection.visible||t.dom.classList.remove("ProseMirror-hideselection")},20))})}(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const Po=Pn||zn&&$n<63;function Ho(t,e){let{node:n,offset:o}=t.docView.domFromPos(e,0),r=o<n.childNodes.length?n.childNodes[o]:null,i=o?n.childNodes[o-1]:null;if(Pn&&r&&"false"==r.contentEditable)return Bo(r);if(!(r&&"false"!=r.contentEditable||i&&"false"!=i.contentEditable)){if(r)return Bo(r);if(i)return Bo(i)}}function Bo(t){return t.contentEditable="true",Pn&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function _o(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function Vo(t,e){if(e instanceof Ce){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(Fo(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else Fo(t)}function Fo(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Wo(t,e,n,o){return t.someProp("createSelectionBetween",o=>o(t,e,n))||xe.between(e,n,o)}function Ko(t){return!(t.editable&&!t.hasFocus())&&qo(t)}function qo(t){let e=t.domSelectionRange();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 Uo(t,e){let{$anchor:n,$head:o}=t.selection,r=e>0?n.max(o):n.min(o),i=r.parent.inlineContent?r.depth?t.doc.resolve(e>0?r.after():r.before()):null:r;return i&&be.findFrom(i,e)}function Jo(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function Go(t,e,n){let o=t.state.selection;if(!(o instanceof xe)){if(o instanceof Ce&&o.node.isInline)return Jo(t,new xe(e>0?o.$to:o.$from));{let n=Uo(t.state,e);return!!n&&Jo(t,n)}}if(n.indexOf("s")>-1){let{$head:n}=o,r=n.textOffset?null:e<0?n.nodeBefore:n.nodeAfter;if(!r||r.isText||!r.isLeaf)return!1;let i=t.state.doc.resolve(n.pos+r.nodeSize*(e<0?-1:1));return Jo(t,new xe(o.$anchor,i))}if(!o.empty)return!1;if(t.endOfTextblock(e>0?"forward":"backward")){let n=Uo(t.state,e);return!!(n&&n instanceof Ce)&&Jo(t,n)}if(!(Bn&&n.indexOf("m")>-1)){let n,r=o.$head,i=r.textOffset?null:e<0?r.nodeBefore:r.nodeAfter;if(!i||i.isText)return!1;let s=e<0?r.pos-i.nodeSize:r.pos;return!!(i.isAtom||(n=t.docView.descAt(s))&&!n.contentDOM)&&(Ce.isSelectable(i)?Jo(t,new Ce(e<0?t.state.doc.resolve(r.pos-i.nodeSize):r)):!!Fn&&Jo(t,new xe(t.state.doc.resolve(e<0?s:s+i.nodeSize))))}}function Yo(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function Xo(t,e){let n=t.pmViewDesc;return n&&0==n.size&&(e<0||t.nextSibling||"BR"!=t.nodeName)}function Qo(t,e){return e<0?function(t){let e=t.domSelectionRange(),n=e.focusNode,o=e.focusOffset;if(!n)return;let r,i,s=!1;for(jn&&1==n.nodeType&&o<Yo(n)&&Xo(n.childNodes[o],-1)&&(s=!0);;)if(o>0){if(1!=n.nodeType)break;{let t=n.childNodes[o-1];if(Xo(t,-1))r=n,i=--o;else{if(3!=t.nodeType)break;n=t,o=n.nodeValue.length}}}else{if(Zo(n))break;{let e=n.previousSibling;for(;e&&Xo(e,-1);)r=n.parentNode,i=mn(e),e=e.previousSibling;if(e)n=e,o=Yo(n);else{if(n=n.parentNode,n==t.dom)break;o=0}}}s?tr(t,n,o):r&&tr(t,r,i)}(t):function(t){let e=t.domSelectionRange(),n=e.focusNode,o=e.focusOffset;if(!n)return;let r,i,s=Yo(n);for(;;)if(o<s){if(1!=n.nodeType)break;if(!Xo(n.childNodes[o],1))break;r=n,i=++o}else{if(Zo(n))break;{let e=n.nextSibling;for(;e&&Xo(e,1);)r=e.parentNode,i=mn(e)+1,e=e.nextSibling;if(e)n=e,o=0,s=Yo(n);else{if(n=n.parentNode,n==t.dom)break;o=s=0}}}r&&tr(t,r,i)}(t)}function Zo(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function tr(t,e,n){if(3!=e.nodeType){let t,o;(o=function(t,e){for(;t&&e==t.childNodes.length&&!Mn(t);)e=mn(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;t=n,e=0}}(e,n))?(e=o,n=0):(t=function(t,e){for(;t&&!e&&!Mn(t);)e=mn(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;e=(t=n).childNodes.length}}(e,n))&&(e=t,n=t.nodeValue.length)}let o=t.domSelection();if(!o)return;if(Cn(o)){let t=document.createRange();t.setEnd(e,n),t.setStart(e,n),o.removeAllRanges(),o.addRange(t)}else o.extend&&o.extend(e,n);t.domObserver.setCurSelection();let{state:r}=t;setTimeout(()=>{t.state==r&&$o(t)},50)}function er(t,e){let n=t.state.doc.resolve(e);if(!zn&&!_n&&n.parent.inlineContent){let o=t.coordsAtPos(e);if(e>n.start()){let n=t.coordsAtPos(e-1),r=(n.top+n.bottom)/2;if(r>o.top&&r<o.bottom&&Math.abs(n.left-o.left)>1)return n.left<o.left?"ltr":"rtl"}if(e<n.end()){let n=t.coordsAtPos(e+1),r=(n.top+n.bottom)/2;if(r>o.top&&r<o.bottom&&Math.abs(n.left-o.left)>1)return n.left>o.left?"ltr":"rtl"}}return"rtl"==getComputedStyle(t.dom).direction?"rtl":"ltr"}function nr(t,e,n){let o=t.state.selection;if(o instanceof xe&&!o.empty||n.indexOf("s")>-1)return!1;if(Bn&&n.indexOf("m")>-1)return!1;let{$from:r,$to:i}=o;if(!r.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let n=Uo(t.state,e);if(n&&n instanceof Ce)return Jo(t,n)}if(!r.parent.inlineContent){let n=e<0?r:i,s=o instanceof Te?be.near(n,e):be.findFrom(n,e);return!!s&&Jo(t,s)}return!1}function or(t,e){if(!(t.state.selection instanceof xe))return!0;let{$head:n,$anchor:o,empty:r}=t.state.selection;if(!n.sameParent(o))return!0;if(!r)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let o=t.state.tr;return e<0?o.delete(n.pos-i.nodeSize,n.pos):o.delete(n.pos,n.pos+i.nodeSize),t.dispatch(o),!0}return!1}function rr(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function ir(t,e){t.someProp("transformCopied",n=>{e=n(e,t)});let n=[],{content:o,openStart:r,openEnd:i}=e;for(;r>1&&i>1&&1==o.childCount&&1==o.firstChild.childCount;){r--,i--;let t=o.firstChild;n.push(t.type.name,t.attrs!=t.type.defaultAttrs?t.attrs:null),o=t.content}let s=t.someProp("clipboardSerializer")||xt.fromSchema(t.state.schema),a=mr(),l=a.createElement("div");l.appendChild(s.serializeFragment(o,{document:a}));let c,d=l.firstChild,h=0;for(;d&&1==d.nodeType&&(c=ur[d.nodeName.toLowerCase()]);){for(let t=c.length-1;t>=0;t--){let e=a.createElement(c[t]);for(;l.firstChild;)e.appendChild(l.firstChild);l.appendChild(e),h++}d=l.firstChild}return d&&1==d.nodeType&&d.setAttribute("data-pm-slice",`${r} ${i}${h?` -${h}`:""} ${JSON.stringify(n)}`),{dom:l,text:t.someProp("clipboardTextSerializer",n=>n(e,t))||e.content.textBetween(0,e.content.size,"\n\n"),slice:e}}function sr(t,e,n,o,r){let i,s,a=r.parent.type.spec.code;if(!n&&!e)return null;let l=!!e&&(o||a||!n);if(l){if(t.someProp("transformPastedText",n=>{e=n(e,a||o,t)}),a)return s=new A(k.from(t.state.schema.text(e.replace(/\r\n?/g,"\n"))),0,0),t.someProp("transformPasted",e=>{s=e(s,t,!0)}),s;let n=t.someProp("clipboardTextParser",n=>n(e,r,o,t));if(n)s=n;else{let n=r.marks(),{schema:o}=t.state,s=xt.fromSchema(o);i=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(t=>{let e=i.appendChild(document.createElement("p"));t&&e.appendChild(s.serializeNode(o.text(t,n)))})}}else t.someProp("transformPastedHTML",e=>{n=e(n,t)}),i=function(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n,o=mr().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t);if((n=r&&ur[r[1].toLowerCase()])&&(t=n.map(t=>"<"+t+">").join("")+t+n.map(t=>"</"+t+">").reverse().join("")),o.innerHTML=function(t){let e=window.trustedTypes;return e?(gr||(gr=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),gr.createHTML(t)):t}(t),n)for(let t=0;t<n.length;t++)o=o.querySelector(n[t])||o;return o}(n),Fn&&function(t){let e=t.querySelectorAll(zn?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let o=e[n];1==o.childNodes.length&&" "==o.textContent&&o.parentNode&&o.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),o)}}(i);let c=i&&i.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let t=+d[3];t>0;t--){let t=i.firstChild;for(;t&&1!=t.nodeType;)t=t.nextSibling;if(!t)break;i=t}if(!s){let e=t.someProp("clipboardParser")||t.someProp("domParser")||pt.fromSchema(t.state.schema);s=e.parseSlice(i,{preserveWhitespace:!(!l&&!d),context:r,ruleFromNode:t=>"BR"!=t.nodeName||t.nextSibling||!t.parentNode||ar.test(t.parentNode.nodeName)?null:{ignore:!0}})}if(d)s=function(t,e){if(!t.size)return t;let n,o=t.content.firstChild.type.schema;try{n=JSON.parse(e)}catch(e){return t}let{content:r,openStart:i,openEnd:s}=t;for(let t=n.length-2;t>=0;t-=2){let e=o.nodes[n[t]];if(!e||e.hasRequiredAttrs())break;r=k.from(e.create(n[t+1],r)),i++,s++}return new A(r,i,s)}(pr(s,+d[1],+d[2]),d[4]);else if(s=A.maxOpen(function(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let o,r=e.node(n).contentMatchAt(e.index(n)),i=[];if(t.forEach(t=>{if(!i)return;let e,n=r.findWrapping(t.type);if(!n)return i=null;if(e=i.length&&o.length&&cr(n,o,t,i[i.length-1],0))i[i.length-1]=e;else{i.length&&(i[i.length-1]=dr(i[i.length-1],o.length));let e=lr(t,n);i.push(e),r=r.matchType(e.type),o=n}}),i)return k.from(i)}return t}(s.content,r),!0),s.openStart||s.openEnd){let t=0,e=0;for(let e=s.content.firstChild;t<s.openStart&&!e.type.spec.isolating;t++,e=e.firstChild);for(let t=s.content.lastChild;e<s.openEnd&&!t.type.spec.isolating;e++,t=t.lastChild);s=pr(s,t,e)}return t.someProp("transformPasted",e=>{s=e(s,t,l)}),s}const ar=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function lr(t,e,n=0){for(let o=e.length-1;o>=n;o--)t=e[o].create(null,k.from(t));return t}function cr(t,e,n,o,r){if(r<t.length&&r<e.length&&t[r]==e[r]){let i=cr(t,e,n,o.lastChild,r+1);if(i)return o.copy(o.content.replaceChild(o.childCount-1,i));if(o.contentMatchAt(o.childCount).matchType(r==t.length-1?n.type:t[r+1]))return o.copy(o.content.append(k.from(lr(n,t,r+1))))}}function dr(t,e){if(0==e)return t;let n=t.content.replaceChild(t.childCount-1,dr(t.lastChild,e-1)),o=t.contentMatchAt(t.childCount).fillBefore(k.empty,!0);return t.copy(n.append(o))}function hr(t,e,n,o,r,i){let s=e<0?t.firstChild:t.lastChild,a=s.content;return t.childCount>1&&(i=0),r<o-1&&(a=hr(a,e,n,o,r+1,i)),r>=n&&(a=e<0?s.contentMatchAt(0).fillBefore(a,i<=r).append(a):a.append(s.contentMatchAt(s.childCount).fillBefore(k.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,s.copy(a))}function pr(t,e,n){return e<t.openStart&&(t=new A(hr(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new A(hr(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const ur={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let fr=null;function mr(){return fr||(fr=document.implementation.createHTMLDocument("title"))}let gr=null;const yr={},br={},vr={touchstart:!0,touchmove:!0};class wr{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function kr(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function xr(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=e=>Mr(t,e))})}function Mr(t,e){return t.someProp("handleDOMEvents",n=>{let o=n[e.type];return!!o&&(o(t,e)||e.defaultPrevented)})}function Cr(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function Sr(t){return{left:t.clientX,top:t.clientY}}function Tr(t,e,n,o,r){if(-1==o)return!1;let i=t.state.doc.resolve(o);for(let o=i.depth+1;o>0;o--)if(t.someProp(e,e=>o>i.depth?e(t,n,i.nodeAfter,i.before(o),r,!0):e(t,n,i.node(o),i.before(o),r,!1)))return!0;return!1}function Ar(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let o=t.state.tr.setSelection(e);"pointer"==n&&o.setMeta("pointer",!0),t.dispatch(o)}function Er(t,e,n,o){return Tr(t,"handleDoubleClickOn",e,n,o)||t.someProp("handleDoubleClick",n=>n(t,e,o))}function Nr(t,e,n,o){return Tr(t,"handleTripleClickOn",e,n,o)||t.someProp("handleTripleClick",n=>n(t,e,o))||function(t,e,n){if(0!=n.button)return!1;let o=t.state.doc;if(-1==e)return!!o.inlineContent&&(Ar(t,xe.create(o,0,o.content.size),"pointer"),!0);let r=o.resolve(e);for(let e=r.depth+1;e>0;e--){let n=e>r.depth?r.nodeAfter:r.node(e),i=r.before(e);if(n.inlineContent)Ar(t,xe.create(o,i+1,i+1+n.content.size),"pointer");else{if(!Ce.isSelectable(n))continue;Ar(t,Ce.create(o,i),"pointer")}return!0}}(t,n,o)}function Or(t){return $r(t)}br.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=16==n.keyCode||n.shiftKey,!Dr(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!Vn||!zn||13!=n.keyCode))if(229!=n.keyCode&&t.domObserver.forceFlush(),!Hn||13!=n.keyCode||n.ctrlKey||n.altKey||n.metaKey)t.someProp("handleKeyDown",e=>e(t,n))||function(t,e){let n=e.keyCode,o=function(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}(e);if(8==n||Bn&&72==n&&"c"==o)return or(t,-1)||Qo(t,-1);if(46==n&&!e.shiftKey||Bn&&68==n&&"c"==o)return or(t,1)||Qo(t,1);if(13==n||27==n)return!0;if(37==n||Bn&&66==n&&"c"==o){let e=37==n?"ltr"==er(t,t.state.selection.from)?-1:1:-1;return Go(t,e,o)||Qo(t,e)}if(39==n||Bn&&70==n&&"c"==o){let e=39==n?"ltr"==er(t,t.state.selection.from)?1:-1:1;return Go(t,e,o)||Qo(t,e)}return 38==n||Bn&&80==n&&"c"==o?nr(t,-1,o)||Qo(t,-1):40==n||Bn&&78==n&&"c"==o?function(t){if(!Pn||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&1==e.nodeType&&0==n&&e.firstChild&&"false"==e.firstChild.contentEditable){let n=e.firstChild;rr(t,n,"true"),setTimeout(()=>rr(t,n,"false"),20)}return!1}(t)||nr(t,1,o)||Qo(t,1):o==(Bn?"m":"c")&&(66==n||73==n||89==n||90==n)}(t,n)?n.preventDefault():kr(t,"key");else{let e=Date.now();t.input.lastIOSEnter=e,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==e&&(t.someProp("handleKeyDown",e=>e(t,Sn(13,"Enter"))),t.input.lastIOSEnter=0)},200)}},br.keyup=(t,e)=>{16==e.keyCode&&(t.input.shiftKey=!1)},br.keypress=(t,e)=>{let n=e;if(Dr(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Bn&&n.metaKey)return;if(t.someProp("handleKeyPress",e=>e(t,n)))return void n.preventDefault();let o=t.state.selection;if(!(o instanceof xe&&o.$from.sameParent(o.$to))){let e=String.fromCharCode(n.charCode),r=()=>t.state.tr.insertText(e).scrollIntoView();/[\r\n]/.test(e)||t.someProp("handleTextInput",n=>n(t,o.$from.pos,o.$to.pos,e,r))||t.dispatch(r()),n.preventDefault()}};const Lr=Bn?"metaKey":"ctrlKey";yr.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let o=Or(t),r=Date.now(),i="singleClick";r-t.input.lastClick.time<500&&function(t,e){let n=e.x-t.clientX,o=e.y-t.clientY;return n*n+o*o<100}(n,t.input.lastClick)&&!n[Lr]&&t.input.lastClick.button==n.button&&("singleClick"==t.input.lastClick.type?i="doubleClick":"doubleClick"==t.input.lastClick.type&&(i="tripleClick")),t.input.lastClick={time:r,x:n.clientX,y:n.clientY,type:i,button:n.button};let s=t.posAtCoords(Sr(n));s&&("singleClick"==i?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new Rr(t,s,n,!!o)):("doubleClick"==i?Er:Nr)(t,s.pos,s.inside,n)?n.preventDefault():kr(t,"pointer"))};class Rr{constructor(t,e,n,o){let r,i;if(this.view=t,this.pos=e,this.event=n,this.flushed=o,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=t.state.doc,this.selectNode=!!n[Lr],this.allowDefault=n.shiftKey,e.inside>-1)r=t.state.doc.nodeAt(e.inside),i=e.inside;else{let n=t.state.doc.resolve(e.pos);r=n.parent,i=n.depth?n.before():0}const s=o?null:n.target,a=s?t.docView.nearestDesc(s,!0):null;this.target=a&&1==a.dom.nodeType?a.dom:null;let{selection:l}=t.state;(0==n.button&&r.type.spec.draggable&&!1!==r.type.spec.selectable||l instanceof Ce&&l.from<=i&&l.to>i)&&(this.mightDrag={node:r,pos:i,addAttr:!(!this.target||this.target.draggable),setUneditable:!(!this.target||!jn||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(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),t.root.addEventListener("mouseup",this.up=this.up.bind(this)),t.root.addEventListener("mousemove",this.move=this.move.bind(this)),kr(t,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>$o(this.view)),this.view.input.mouseDown=null}up(t){if(this.done(),!this.view.dom.contains(t.target))return;let e=this.pos;this.view.state.doc!=this.startDoc&&(e=this.view.posAtCoords(Sr(t))),this.updateAllowDefault(t),this.allowDefault||!e?kr(this.view,"pointer"):function(t,e,n,o,r){return Tr(t,"handleClickOn",e,n,o)||t.someProp("handleClick",n=>n(t,e,o))||(r?function(t,e){if(-1==e)return!1;let n,o,r=t.state.selection;r instanceof Ce&&(n=r.node);let i=t.state.doc.resolve(e);for(let t=i.depth+1;t>0;t--){let e=t>i.depth?i.nodeAfter:i.node(t);if(Ce.isSelectable(e)){o=n&&r.$from.depth>0&&t>=r.$from.depth&&i.before(r.$from.depth+1)==r.$from.pos?i.before(r.$from.depth):i.before(t);break}}return null!=o&&(Ar(t,Ce.create(t.state.doc,o),"pointer"),!0)}(t,n):function(t,e){if(-1==e)return!1;let n=t.state.doc.resolve(e),o=n.nodeAfter;return!!(o&&o.isAtom&&Ce.isSelectable(o))&&(Ar(t,new Ce(n),"pointer"),!0)}(t,n))}(this.view,e.pos,e.inside,t,this.selectNode)?t.preventDefault():0==t.button&&(this.flushed||Pn&&this.mightDrag&&!this.mightDrag.node.isAtom||zn&&!this.view.state.selection.visible&&Math.min(Math.abs(e.pos-this.view.state.selection.from),Math.abs(e.pos-this.view.state.selection.to))<=2)?(Ar(this.view,be.near(this.view.state.doc.resolve(e.pos)),"pointer"),t.preventDefault()):kr(this.view,"pointer")}move(t){this.updateAllowDefault(t),kr(this.view,"pointer"),0==t.buttons&&this.done()}updateAllowDefault(t){!this.allowDefault&&(Math.abs(this.event.x-t.clientX)>4||Math.abs(this.event.y-t.clientY)>4)&&(this.allowDefault=!0)}}function Dr(t,e){return!!t.composing||!!(Pn&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500)&&(t.input.compositionEndedAt=-2e8,!0)}yr.touchstart=t=>{t.input.lastTouch=Date.now(),Or(t),kr(t,"pointer")},yr.touchmove=t=>{t.input.lastTouch=Date.now(),kr(t,"pointer")},yr.contextmenu=t=>Or(t);const jr=Vn?5e3:-1;function Ir(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>$r(t),e))}function zr(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=function(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function $r(t,e=!1){if(!(Vn&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),zr(t),e||t.docView&&t.docView.dirty){let n=Io(t),o=t.state.selection;return n&&!n.eq(o)?t.dispatch(t.state.tr.setSelection(n)):!t.markCursor&&!e||o.$from.node(o.$from.sharedDepth(o.to)).inlineContent?t.updateState(t.state):t.dispatch(t.state.tr.deleteSelection()),!0}return!1}}br.compositionstart=br.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof xe&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(t=>!1===t.type.spec.inclusive)))t.markCursor=t.state.storedMarks||n.marks(),$r(t,!0),t.markCursor=null;else if($r(t,!e.selection.empty),jn&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let e=t.domSelectionRange();for(let n=e.focusNode,o=e.focusOffset;n&&1==n.nodeType&&0!=o;){let e=o<0?n.lastChild:n.childNodes[o-1];if(!e)break;if(3==e.nodeType){let n=t.domSelection();n&&n.collapse(e,e.nodeValue.length);break}n=e,o=-1}}t.input.composing=!0}Ir(t,jr)},br.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,Ir(t,20))};const Pr=Rn&&Dn<15||Hn&&Wn<604;function Hr(t,e,n,o,r){let i=sr(t,e,n,o,t.state.selection.$from);if(t.someProp("handlePaste",e=>e(t,r,i||A.empty)))return!0;if(!i)return!1;let s=function(t){return 0==t.openStart&&0==t.openEnd&&1==t.content.childCount?t.content.firstChild:null}(i),a=s?t.state.tr.replaceSelectionWith(s,o):t.state.tr.replaceSelection(i);return t.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Br(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}yr.copy=br.cut=(t,e)=>{let n=e,o=t.state.selection,r="cut"==n.type;if(o.empty)return;let i=Pr?null:n.clipboardData,s=o.content(),{dom:a,text:l}=ir(t,s);i?(n.preventDefault(),i.clearData(),i.setData("text/html",a.innerHTML),i.setData("text/plain",l)):function(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let o=getSelection(),r=document.createRange();r.selectNodeContents(e),t.dom.blur(),o.removeAllRanges(),o.addRange(r),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}(t,a),r&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},br.paste=(t,e)=>{let n=e;if(t.composing&&!Vn)return;let o=Pr?null:n.clipboardData,r=t.input.shiftKey&&45!=t.input.lastKeyCode;o&&Hr(t,Br(o),o.getData("text/html"),r,n)?n.preventDefault():function(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,o=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(o.contentEditable="true"),o.style.cssText="position: fixed; left: -10000px; top: 10px",o.focus();let r=t.input.shiftKey&&45!=t.input.lastKeyCode;setTimeout(()=>{t.focus(),o.parentNode&&o.parentNode.removeChild(o),n?Hr(t,o.value,null,r,e):Hr(t,o.textContent,o.innerHTML,r,e)},50)}(t,n)};class _r{constructor(t,e,n){this.slice=t,this.move=e,this.node=n}}const Vr=Bn?"altKey":"ctrlKey";function Fr(t,e){let n=t.someProp("dragCopies",t=>!t(e));return null!=n?n:!e[Vr]}yr.dragstart=(t,e)=>{let n=e,o=t.input.mouseDown;if(o&&o.done(),!n.dataTransfer)return;let r,i=t.state.selection,s=i.empty?null:t.posAtCoords(Sr(n));if(s&&s.pos>=i.from&&s.pos<=(i instanceof Ce?i.to-1:i.to));else if(o&&o.mightDrag)r=Ce.create(t.state.doc,o.mightDrag.pos);else if(n.target&&1==n.target.nodeType){let e=t.docView.nearestDesc(n.target,!0);e&&e.node.type.spec.draggable&&e!=t.docView&&(r=Ce.create(t.state.doc,e.posBefore))}let a=(r||t.state.selection).content(),{dom:l,text:c,slice:d}=ir(t,a);(!n.dataTransfer.files.length||!zn||$n>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Pr?"Text":"text/html",l.innerHTML),n.dataTransfer.effectAllowed="copyMove",Pr||n.dataTransfer.setData("text/plain",c),t.dragging=new _r(d,Fr(t,n),r)},yr.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)},br.dragover=br.dragenter=(t,e)=>e.preventDefault(),br.drop=(t,e)=>{let n=e,o=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let r=t.posAtCoords(Sr(n));if(!r)return;let i=t.state.doc.resolve(r.pos),s=o&&o.slice;s?t.someProp("transformPasted",e=>{s=e(s,t,!1)}):s=sr(t,Br(n.dataTransfer),Pr?null:n.dataTransfer.getData("text/html"),!1,i);let a=!(!o||!Fr(t,n));if(t.someProp("handleDrop",e=>e(t,n,s||A.empty,a)))return void n.preventDefault();if(!s)return;n.preventDefault();let l=s?ee(t.state.doc,i.pos,s):i.pos;null==l&&(l=i.pos);let c=t.state.tr;if(a){let{node:t}=o;t?t.replace(c):c.deleteSelection()}let d=c.mapping.map(l),h=0==s.openStart&&0==s.openEnd&&1==s.content.childCount,p=c.doc;if(h?c.replaceRangeWith(d,d,s.content.firstChild):c.replaceRange(d,d,s),c.doc.eq(p))return;let u=c.doc.resolve(d);if(h&&Ce.isSelectable(s.content.firstChild)&&u.nodeAfter&&u.nodeAfter.sameMarkup(s.content.firstChild))c.setSelection(new Ce(u));else{let e=c.mapping.map(l);c.mapping.maps[c.mapping.maps.length-1].forEach((t,n,o,r)=>e=r),c.setSelection(Wo(t,u,c.doc.resolve(e)))}t.focus(),t.dispatch(c.setMeta("uiEvent","drop"))},yr.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&$o(t)},20))},yr.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)},yr.beforeinput=(t,e)=>{if(zn&&Vn&&"deleteContentBackward"==e.inputType){t.domObserver.flushSoon();let{domChangeCount:e}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=e)return;if(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",e=>e(t,Sn(8,"Backspace"))))return;let{$cursor:n}=t.state.selection;n&&n.pos>0&&t.dispatch(t.state.tr.delete(n.pos-1,n.pos).scrollIntoView())},50)}};for(let t in br)yr[t]=br[t];function Wr(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class Kr{constructor(t,e){this.toDOM=t,this.spec=e||Yr,this.side=this.spec.side||0}map(t,e,n,o){let{pos:r,deleted:i}=t.mapResult(e.from+o,this.side<0?-1:1);return i?null:new Jr(r-n,r-n,this)}valid(){return!0}eq(t){return this==t||t instanceof Kr&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&Wr(this.spec,t.spec))}destroy(t){this.spec.destroy&&this.spec.destroy(t)}}class qr{constructor(t,e){this.attrs=t,this.spec=e||Yr}map(t,e,n,o){let r=t.map(e.from+o,this.spec.inclusiveStart?-1:1)-n,i=t.map(e.to+o,this.spec.inclusiveEnd?1:-1)-n;return r>=i?null:new Jr(r,i,this)}valid(t,e){return e.from<e.to}eq(t){return this==t||t instanceof qr&&Wr(this.attrs,t.attrs)&&Wr(this.spec,t.spec)}static is(t){return t.type instanceof qr}destroy(){}}class Ur{constructor(t,e){this.attrs=t,this.spec=e||Yr}map(t,e,n,o){let r=t.mapResult(e.from+o,1);if(r.deleted)return null;let i=t.mapResult(e.to+o,-1);return i.deleted||i.pos<=r.pos?null:new Jr(r.pos-n,i.pos-n,this)}valid(t,e){let n,{index:o,offset:r}=t.content.findIndex(e.from);return r==e.from&&!(n=t.child(o)).isText&&r+n.nodeSize==e.to}eq(t){return this==t||t instanceof Ur&&Wr(this.attrs,t.attrs)&&Wr(this.spec,t.spec)}destroy(){}}class Jr{constructor(t,e,n){this.from=t,this.to=e,this.type=n}copy(t,e){return new Jr(t,e,this.type)}eq(t,e=0){return this.type.eq(t.type)&&this.from+e==t.from&&this.to+e==t.to}map(t,e,n){return this.type.map(t,this,e,n)}static widget(t,e,n){return new Jr(t,t,new Kr(e,n))}static inline(t,e,n,o){return new Jr(t,e,new qr(n,o))}static node(t,e,n,o){return new Jr(t,e,new Ur(n,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof qr}get widget(){return this.type instanceof Kr}}const Gr=[],Yr={};class Xr{constructor(t,e){this.local=t.length?t:Gr,this.children=e.length?e:Gr}static create(t,e){return e.length?oi(e,t,0,Yr):Qr}find(t,e,n){let o=[];return this.findInner(null==t?0:t,null==e?1e9:e,o,0,n),o}findInner(t,e,n,o,r){for(let i=0;i<this.local.length;i++){let s=this.local[i];s.from<=e&&s.to>=t&&(!r||r(s.spec))&&n.push(s.copy(s.from+o,s.to+o))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<e&&this.children[i+1]>t){let s=this.children[i]+1;this.children[i+2].findInner(t-s,e-s,n,o+s,r)}}map(t,e,n){return this==Qr||0==t.maps.length?this:this.mapInner(t,e,0,0,n||Yr)}mapInner(t,e,n,o,r){let i;for(let s=0;s<this.local.length;s++){let a=this.local[s].map(t,n,o);a&&a.type.valid(e,a)?(i||(i=[])).push(a):r.onRemove&&r.onRemove(this.local[s].spec)}return this.children.length?function(t,e,n,o,r,i,s){let a=t.slice();for(let t=0,e=i;t<n.maps.length;t++){let o=0;n.maps[t].forEach((t,n,r,i)=>{let s=i-r-(n-t);for(let r=0;r<a.length;r+=3){let i=a[r+1];if(i<0||t>i+e-o)continue;let l=a[r]+e-o;n>=l?a[r+1]=t<=l?-2:-1:t>=e&&s&&(a[r]+=s,a[r+1]+=s)}o+=s}),e=n.maps[t].map(e,-1)}let l=!1;for(let e=0;e<a.length;e+=3)if(a[e+1]<0){if(-2==a[e+1]){l=!0,a[e+1]=-1;continue}let c=n.map(t[e]+i),d=c-r;if(d<0||d>=o.content.size){l=!0;continue}let h=n.map(t[e+1]+i,-1)-r,{index:p,offset:u}=o.content.findIndex(d),f=o.maybeChild(p);if(f&&u==d&&u+f.nodeSize==h){let o=a[e+2].mapInner(n,f,c+1,t[e]+i+1,s);o!=Qr?(a[e]=d,a[e+1]=h,a[e+2]=o):(a[e+1]=-2,l=!0)}else l=!0}if(l){let l=function(t,e,n,o,r,i,s){function a(t,e){for(let i=0;i<t.local.length;i++){let a=t.local[i].map(o,r,e);a?n.push(a):s.onRemove&&s.onRemove(t.local[i].spec)}for(let n=0;n<t.children.length;n+=3)a(t.children[n+2],t.children[n]+e+1)}for(let n=0;n<t.length;n+=3)-1==t[n+1]&&a(t[n+2],e[n]+i+1);return n}(a,t,e,n,r,i,s),c=oi(l,o,0,s);e=c.local;for(let t=0;t<a.length;t+=3)a[t+1]<0&&(a.splice(t,3),t-=3);for(let t=0,e=0;t<c.children.length;t+=3){let n=c.children[t];for(;e<a.length&&a[e]<n;)e+=3;a.splice(e,0,c.children[t],c.children[t+1],c.children[t+2])}}return new Xr(e.sort(ri),a)}(this.children,i||[],t,e,n,o,r):i?new Xr(i.sort(ri),Gr):Qr}add(t,e){return e.length?this==Qr?Xr.create(t,e):this.addInner(t,e,0):this}addInner(t,e,n){let o,r=0;t.forEach((t,i)=>{let s,a=i+n;if(s=ei(e,t,a)){for(o||(o=this.children.slice());r<o.length&&o[r]<i;)r+=3;o[r]==i?o[r+2]=o[r+2].addInner(t,s,a+1):o.splice(r,0,i,i+t.nodeSize,oi(s,t,a+1,Yr)),r+=3}});let i=ti(r?ni(e):e,-n);for(let e=0;e<i.length;e++)i[e].type.valid(t,i[e])||i.splice(e--,1);return new Xr(i.length?this.local.concat(i).sort(ri):this.local,o||this.children)}remove(t){return 0==t.length||this==Qr?this:this.removeInner(t,0)}removeInner(t,e){let n=this.children,o=this.local;for(let o=0;o<n.length;o+=3){let r,i=n[o]+e,s=n[o+1]+e;for(let e,n=0;n<t.length;n++)(e=t[n])&&e.from>i&&e.to<s&&(t[n]=null,(r||(r=[])).push(e));if(!r)continue;n==this.children&&(n=this.children.slice());let a=n[o+2].removeInner(r,i+1);a!=Qr?n[o+2]=a:(n.splice(o,3),o-=3)}if(o.length)for(let n,r=0;r<t.length;r++)if(n=t[r])for(let t=0;t<o.length;t++)o[t].eq(n,e)&&(o==this.local&&(o=this.local.slice()),o.splice(t--,1));return n==this.children&&o==this.local?this:o.length||n.length?new Xr(o,n):Qr}forChild(t,e){if(this==Qr)return this;if(e.isLeaf)return Xr.empty;let n,o;for(let e=0;e<this.children.length;e+=3)if(this.children[e]>=t){this.children[e]==t&&(n=this.children[e+2]);break}let r=t+1,i=r+e.content.size;for(let t=0;t<this.local.length;t++){let e=this.local[t];if(e.from<i&&e.to>r&&e.type instanceof qr){let t=Math.max(r,e.from)-r,n=Math.min(i,e.to)-r;t<n&&(o||(o=[])).push(e.copy(t,n))}}if(o){let t=new Xr(o.sort(ri),Gr);return n?new Zr([t,n]):t}return n||Qr}eq(t){if(this==t)return!0;if(!(t instanceof Xr)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(let e=0;e<this.local.length;e++)if(!this.local[e].eq(t.local[e]))return!1;for(let e=0;e<this.children.length;e+=3)if(this.children[e]!=t.children[e]||this.children[e+1]!=t.children[e+1]||!this.children[e+2].eq(t.children[e+2]))return!1;return!0}locals(t){return ii(this.localsInner(t))}localsInner(t){if(this==Qr)return Gr;if(t.inlineContent||!this.local.some(qr.is))return this.local;let e=[];for(let t=0;t<this.local.length;t++)this.local[t].type instanceof qr||e.push(this.local[t]);return e}forEachSet(t){t(this)}}Xr.empty=new Xr([],[]),Xr.removeOverlap=ii;const Qr=Xr.empty;class Zr{constructor(t){this.members=t}map(t,e){const n=this.members.map(n=>n.map(t,e,Yr));return Zr.from(n)}forChild(t,e){if(e.isLeaf)return Xr.empty;let n=[];for(let o=0;o<this.members.length;o++){let r=this.members[o].forChild(t,e);r!=Qr&&(r instanceof Zr?n=n.concat(r.members):n.push(r))}return Zr.from(n)}eq(t){if(!(t instanceof Zr)||t.members.length!=this.members.length)return!1;for(let e=0;e<this.members.length;e++)if(!this.members[e].eq(t.members[e]))return!1;return!0}locals(t){let e,n=!0;for(let o=0;o<this.members.length;o++){let r=this.members[o].localsInner(t);if(r.length)if(e){n&&(e=e.slice(),n=!1);for(let t=0;t<r.length;t++)e.push(r[t])}else e=r}return e?ii(n?e:e.sort(ri)):Gr}static from(t){switch(t.length){case 0:return Qr;case 1:return t[0];default:return new Zr(t.every(t=>t instanceof Xr)?t:t.reduce((t,e)=>t.concat(e instanceof Xr?e:e.members),[]))}}forEachSet(t){for(let e=0;e<this.members.length;e++)this.members[e].forEachSet(t)}}function ti(t,e){if(!e||!t.length)return t;let n=[];for(let o=0;o<t.length;o++){let r=t[o];n.push(new Jr(r.from+e,r.to+e,r.type))}return n}function ei(t,e,n){if(e.isLeaf)return null;let o=n+e.nodeSize,r=null;for(let e,i=0;i<t.length;i++)(e=t[i])&&e.from>n&&e.to<o&&((r||(r=[])).push(e),t[i]=null);return r}function ni(t){let e=[];for(let n=0;n<t.length;n++)null!=t[n]&&e.push(t[n]);return e}function oi(t,e,n,o){let r=[],i=!1;e.forEach((e,s)=>{let a=ei(t,e,s+n);if(a){i=!0;let t=oi(a,e,n+s+1,o);t!=Qr&&r.push(s,s+e.nodeSize,t)}});let s=ti(i?ni(t):t,-n).sort(ri);for(let t=0;t<s.length;t++)s[t].type.valid(e,s[t])||(o.onRemove&&o.onRemove(s[t].spec),s.splice(t--,1));return s.length||r.length?new Xr(s,r):Qr}function ri(t,e){return t.from-e.from||t.to-e.to}function ii(t){let e=t;for(let n=0;n<e.length-1;n++){let o=e[n];if(o.from!=o.to)for(let r=n+1;r<e.length;r++){let i=e[r];if(i.from!=o.from){i.from<o.to&&(e==t&&(e=t.slice()),e[n]=o.copy(o.from,i.from),si(e,r,o.copy(i.from,o.to)));break}i.to!=o.to&&(e==t&&(e=t.slice()),e[r]=i.copy(i.from,o.to),si(e,r+1,i.copy(o.to,i.to)))}}return e}function si(t,e,n){for(;e<t.length&&ri(n,t[e])>0;)e++;t.splice(e,0,n)}function ai(t){let e=[];return t.someProp("decorations",n=>{let o=n(t.state);o&&o!=Qr&&e.push(o)}),t.cursorWrapper&&e.push(Xr.create(t.state.doc,[t.cursorWrapper.deco])),Zr.from(e)}const li={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},ci=Rn&&Dn<=11;class di{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(t){this.anchorNode=t.anchorNode,this.anchorOffset=t.anchorOffset,this.focusNode=t.focusNode,this.focusOffset=t.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(t){return t.anchorNode==this.anchorNode&&t.anchorOffset==this.anchorOffset&&t.focusNode==this.focusNode&&t.focusOffset==this.focusOffset}}class hi{constructor(t,e){this.view=t,this.handleDOMChange=e,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new di,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);Rn&&Dn<=11&&t.some(t=>"childList"==t.type&&t.removedNodes.length||"characterData"==t.type&&t.oldValue.length>t.target.nodeValue.length)?this.flushSoon():this.flush()}),ci&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,li)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let t=this.observer.takeRecords();if(t.length){for(let e=0;e<t.length;e++)this.queue.push(t[e]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(Ko(this.view)){if(this.suppressingSelectionUpdates)return $o(this.view);if(Rn&&Dn<=11&&!this.view.state.selection.empty){let t=this.view.domSelectionRange();if(t.focusNode&&vn(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(t){if(!t.focusNode)return!0;let e,n=new Set;for(let e=t.focusNode;e;e=gn(e))n.add(e);for(let o=t.anchorNode;o;o=gn(o))if(n.has(o)){e=o;break}let o=e&&this.view.docView.nearestDesc(e);return o&&o.ignoreMutation({type:"selection",target:3==e.nodeType?e.parentNode:e})?(this.setCurSelection(),!0):void 0}pendingRecords(){if(this.observer)for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}flush(){let{view:t}=this;if(!t.docView||this.flushingSoon>-1)return;let e=this.pendingRecords();e.length&&(this.queue=[]);let n=t.domSelectionRange(),o=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&Ko(t)&&!this.ignoreSelectionChange(n),r=-1,i=-1,s=!1,a=[];if(t.editable)for(let t=0;t<e.length;t++){let n=this.registerMutation(e[t],a);n&&(r=r<0?n.from:Math.min(n.from,r),i=i<0?n.to:Math.max(n.to,i),n.typeOver&&(s=!0))}if(jn&&a.length){let e=a.filter(t=>"BR"==t.nodeName);if(2==e.length){let[t,n]=e;t.parentNode&&t.parentNode.parentNode==n.parentNode?n.remove():t.remove()}else{let{focusNode:n}=this.currentSelection;for(let o of e){let e=o.parentNode;!e||"LI"!=e.nodeName||n&&mi(t,n)==e||o.remove()}}}let l=null;r<0&&o&&t.input.lastFocus>Date.now()-200&&Math.max(t.input.lastTouch,t.input.lastClick.time)<Date.now()-300&&Cn(n)&&(l=Io(t))&&l.eq(be.near(t.state.doc.resolve(0),1))?(t.input.lastFocus=0,$o(t),this.currentSelection.set(n),t.scrollToSelection()):(r>-1||o)&&(r>-1&&(t.docView.markDirty(r,i),function(t){if(!pi.has(t)&&(pi.set(t,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace))){if(t.requiresGeckoHackNode=jn,ui)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),ui=!0}}(t)),this.handleDOMChange(r,i,s,a),t.docView&&t.docView.dirty?t.updateState(t.state):this.currentSelection.eq(n)||$o(t),this.currentSelection.set(n))}registerMutation(t,e){if(e.indexOf(t.target)>-1)return null;let n=this.view.docView.nearestDesc(t.target);if("attributes"==t.type&&(n==this.view.docView||"contenteditable"==t.attributeName||"style"==t.attributeName&&!t.oldValue&&!t.target.getAttribute("style")))return null;if(!n||n.ignoreMutation(t))return null;if("childList"==t.type){for(let n=0;n<t.addedNodes.length;n++){let o=t.addedNodes[n];e.push(o),3==o.nodeType&&(this.lastChangedTextNode=o)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(t.target))return{from:n.posBefore,to:n.posAfter};let o=t.previousSibling,r=t.nextSibling;if(Rn&&Dn<=11&&t.addedNodes.length)for(let e=0;e<t.addedNodes.length;e++){let{previousSibling:n,nextSibling:i}=t.addedNodes[e];(!n||Array.prototype.indexOf.call(t.addedNodes,n)<0)&&(o=n),(!i||Array.prototype.indexOf.call(t.addedNodes,i)<0)&&(r=i)}let i=o&&o.parentNode==t.target?mn(o)+1:0,s=n.localPosFromDOM(t.target,i,-1),a=r&&r.parentNode==t.target?mn(r):t.target.childNodes.length;return{from:s,to:n.localPosFromDOM(t.target,a,1)}}return"attributes"==t.type?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:(this.lastChangedTextNode=t.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:t.target.nodeValue==t.oldValue})}}let pi=new WeakMap,ui=!1;function fi(t,e){let n=e.startContainer,o=e.startOffset,r=e.endContainer,i=e.endOffset,s=t.domAtPos(t.state.selection.anchor);return vn(s.node,s.offset,r,i)&&([n,o,r,i]=[r,i,n,o]),{anchorNode:n,anchorOffset:o,focusNode:r,focusOffset:i}}function mi(t,e){for(let n=e.parentNode;n&&n!=t.dom;n=n.parentNode){let e=t.docView.nearestDesc(n,!0);if(e&&e.node.isBlock)return n}return null}function gi(t){let e=t.pmViewDesc;if(e)return e.parseRule();if("BR"==t.nodeName&&t.parentNode){if(Pn&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}if(t.parentNode.lastChild==t||Pn&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if("IMG"==t.nodeName&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const yi=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function bi(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:Wo(t,e.resolve(n.anchor),e.resolve(n.head))}function vi(t,e,n){let o=t.depth,r=e?t.end():t.pos;for(;o>0&&(e||t.indexAfter(o)==t.node(o).childCount);)o--,r++,e=!1;if(n){let e=t.node(o).maybeChild(t.indexAfter(o));for(;e&&!e.isLeaf;)e=e.firstChild,r++}return r}function wi(t){if(2!=t.length)return!1;let e=t.charCodeAt(0),n=t.charCodeAt(1);return e>=56320&&e<=57343&&n>=55296&&n<=56319}class ki{constructor(t,e){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new wr,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=e,this.state=e.state,this.directPlugins=e.plugins||[],this.directPlugins.forEach(Ti),this.dispatch=this.dispatch.bind(this),this.dom=t&&t.mount||document.createElement("div"),t&&(t.appendChild?t.appendChild(this.dom):"function"==typeof t?t(this.dom):t.mount&&(this.mounted=!0)),this.editable=Ci(this),Mi(this),this.nodeViews=Si(this),this.docView=vo(this.state.doc,xi(this),ai(this),this.dom,this),this.domObserver=new hi(this,(t,e,n,o)=>function(t,e,n,o,r){let i=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let e=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,n=Io(t,e);if(n&&!t.state.selection.eq(n)){if(zn&&Vn&&13===t.input.lastKeyCode&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",e=>e(t,Sn(13,"Enter"))))return;let o=t.state.tr.setSelection(n);"pointer"==e?o.setMeta("pointer",!0):"key"==e&&o.scrollIntoView(),i&&o.setMeta("composition",i),t.dispatch(o)}return}let s=t.state.doc.resolve(e),a=s.sharedDepth(n);e=s.before(a+1),n=t.state.doc.resolve(n).after(a+1);let l,c,d=t.state.selection,h=function(t,e,n){let o,{node:r,fromOffset:i,toOffset:s,from:a,to:l}=t.docView.parseRange(e,n),c=t.domSelectionRange(),d=c.anchorNode;if(d&&t.dom.contains(1==d.nodeType?d:d.parentNode)&&(o=[{node:d,offset:c.anchorOffset}],Cn(c)||o.push({node:c.focusNode,offset:c.focusOffset})),zn&&8===t.input.lastKeyCode)for(let t=s;t>i;t--){let e=r.childNodes[t-1],n=e.pmViewDesc;if("BR"==e.nodeName&&!n){s=t;break}if(!n||n.size)break}let h=t.state.doc,p=t.someProp("domParser")||pt.fromSchema(t.state.schema),u=h.resolve(a),f=null,m=p.parse(r,{topNode:u.parent,topMatch:u.parent.contentMatchAt(u.index()),topOpen:!0,from:i,to:s,preserveWhitespace:"pre"!=u.parent.type.whitespace||"full",findPositions:o,ruleFromNode:gi,context:u});if(o&&null!=o[0].pos){let t=o[0].pos,e=o[1]&&o[1].pos;null==e&&(e=t),f={anchor:t+a,head:e+a}}return{doc:m,sel:f,from:a,to:l}}(t,e,n),p=t.state.doc,u=p.slice(h.from,h.to);8===t.input.lastKeyCode&&Date.now()-100<t.input.lastKeyCodeTime?(l=t.state.selection.to,c="end"):(l=t.state.selection.from,c="start"),t.input.lastKeyCode=null;let f=function(t,e,n,o,r){let i=t.findDiffStart(e,n);if(null==i)return null;let{a:s,b:a}=t.findDiffEnd(e,n+t.size,n+e.size);if("end"==r&&(o-=s+Math.max(0,i-Math.min(s,a))-i),s<i&&t.size<e.size){let t=o<=i&&o>=s?i-o:0;i-=t,i&&i<e.size&&wi(e.textBetween(i-1,i+1))&&(i+=t?1:-1),a=i+(a-s),s=i}else if(a<i){let e=o<=i&&o>=a?i-o:0;i-=e,i&&i<t.size&&wi(t.textBetween(i-1,i+1))&&(i+=e?1:-1),s=i+(s-a),a=i}return{start:i,endA:s,endB:a}}(u.content,h.doc.content,h.from,l,c);if(f&&t.input.domChangeCount++,(Hn&&t.input.lastIOSEnter>Date.now()-225||Vn)&&r.some(t=>1==t.nodeType&&!yi.test(t.nodeName))&&(!f||f.endA>=f.endB)&&t.someProp("handleKeyDown",e=>e(t,Sn(13,"Enter"))))return void(t.input.lastIOSEnter=0);if(!f){if(!(o&&d instanceof xe&&!d.empty&&d.$head.sameParent(d.$anchor))||t.composing||h.sel&&h.sel.anchor!=h.sel.head){if(h.sel){let e=bi(t,t.state.doc,h.sel);if(e&&!e.eq(t.state.selection)){let n=t.state.tr.setSelection(e);i&&n.setMeta("composition",i),t.dispatch(n)}}return}f={start:d.from,endA:d.to,endB:d.to}}t.state.selection.from<t.state.selection.to&&f.start==f.endB&&t.state.selection instanceof xe&&(f.start>t.state.selection.from&&f.start<=t.state.selection.from+2&&t.state.selection.from>=h.from?f.start=t.state.selection.from:f.endA<t.state.selection.to&&f.endA>=t.state.selection.to-2&&t.state.selection.to<=h.to&&(f.endB+=t.state.selection.to-f.endA,f.endA=t.state.selection.to)),Rn&&Dn<=11&&f.endB==f.start+1&&f.endA==f.start&&f.start>h.from&&"  "==h.doc.textBetween(f.start-h.from-1,f.start-h.from+1)&&(f.start--,f.endA--,f.endB--);let m,g=h.doc.resolveNoCache(f.start-h.from),y=h.doc.resolveNoCache(f.endB-h.from),b=p.resolve(f.start),v=g.sameParent(y)&&g.parent.inlineContent&&b.end()>=f.endA;if((Hn&&t.input.lastIOSEnter>Date.now()-225&&(!v||r.some(t=>"DIV"==t.nodeName||"P"==t.nodeName))||!v&&g.pos<h.doc.content.size&&(!g.sameParent(y)||!g.parent.inlineContent)&&!/\S/.test(h.doc.textBetween(g.pos,y.pos,"",""))&&(m=be.findFrom(h.doc.resolve(g.pos+1),1,!0))&&m.head>g.pos)&&t.someProp("handleKeyDown",e=>e(t,Sn(13,"Enter"))))return void(t.input.lastIOSEnter=0);if(t.state.selection.anchor>f.start&&function(t,e,n,o,r){if(n-e<=r.pos-o.pos||vi(o,!0,!1)<r.pos)return!1;let i=t.resolve(e);if(!o.parent.isTextblock){let t=i.nodeAfter;return null!=t&&n==e+t.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let s=t.resolve(vi(i,!0,!0));return!(!s.parent.isTextblock||s.pos>n||vi(s,!0,!1)<n)&&o.parent.content.cut(o.parentOffset).eq(s.parent.content)}(p,f.start,f.endA,g,y)&&t.someProp("handleKeyDown",e=>e(t,Sn(8,"Backspace"))))return void(Vn&&zn&&t.domObserver.suppressSelectionUpdates());zn&&f.endB==f.start&&(t.input.lastChromeDelete=Date.now()),Vn&&!v&&g.start()!=y.start()&&0==y.parentOffset&&g.depth==y.depth&&h.sel&&h.sel.anchor==h.sel.head&&h.sel.head==f.endA&&(f.endB-=2,y=h.doc.resolveNoCache(f.endB-h.from),setTimeout(()=>{t.someProp("handleKeyDown",function(e){return e(t,Sn(13,"Enter"))})},20));let w,x=f.start,M=f.endA,C=e=>{let n=e||t.state.tr.replace(x,M,h.doc.slice(f.start-h.from,f.endB-h.from));if(h.sel){let e=bi(t,n.doc,h.sel);e&&!(zn&&t.composing&&e.empty&&(f.start!=f.endB||t.input.lastChromeDelete<Date.now()-100)&&(e.head==x||e.head==n.mapping.map(M)-1)||Rn&&e.empty&&e.head==x)&&n.setSelection(e)}return i&&n.setMeta("composition",i),n.scrollIntoView()};if(v){if(g.pos==y.pos){Rn&&Dn<=11&&0==g.parentOffset&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>$o(t),20));let e=C(t.state.tr.delete(x,M)),n=p.resolve(f.start).marksAcross(p.resolve(f.endA));n&&e.ensureMarks(n),t.dispatch(e)}else if(f.endA==f.endB&&(w=function(t,e){let n,o,r,i=t.firstChild.marks,s=e.firstChild.marks,a=i,l=s;for(let t=0;t<s.length;t++)a=s[t].removeFromSet(a);for(let t=0;t<i.length;t++)l=i[t].removeFromSet(l);if(1==a.length&&0==l.length)o=a[0],n="add",r=t=>t.mark(o.addToSet(t.marks));else{if(0!=a.length||1!=l.length)return null;o=l[0],n="remove",r=t=>t.mark(o.removeFromSet(t.marks))}let c=[];for(let t=0;t<e.childCount;t++)c.push(r(e.child(t)));if(k.from(c).eq(t))return{mark:o,type:n}}(g.parent.content.cut(g.parentOffset,y.parentOffset),b.parent.content.cut(b.parentOffset,f.endA-b.start())))){let e=C(t.state.tr);"add"==w.type?e.addMark(x,M,w.mark):e.removeMark(x,M,w.mark),t.dispatch(e)}else if(g.parent.child(g.index()).isText&&g.index()==y.index()-(y.textOffset?0:1)){let e=g.parent.textBetween(g.parentOffset,y.parentOffset),n=()=>C(t.state.tr.insertText(e,x,M));t.someProp("handleTextInput",o=>o(t,x,M,e,n))||t.dispatch(n())}}else t.dispatch(C())}(this,t,e,n,o)),this.domObserver.start(),function(t){for(let e in yr){let n=yr[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=e=>{!Cr(t,e)||Mr(t,e)||!t.editable&&e.type in br||n(t,e)},vr[e]?{passive:!0}:void 0)}Pn&&t.dom.addEventListener("input",()=>null),xr(t)}(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let t=this._props;this._props={};for(let e in t)this._props[e]=t[e];this._props.state=this.state}return this._props}update(t){t.handleDOMEvents!=this._props.handleDOMEvents&&xr(this);let e=this._props;this._props=t,t.plugins&&(t.plugins.forEach(Ti),this.directPlugins=t.plugins),this.updateStateInner(t.state,e)}setProps(t){let e={};for(let t in this._props)e[t]=this._props[t];e.state=this.state;for(let n in t)e[n]=t[n];this.update(e)}updateState(t){this.updateStateInner(t,this._props)}updateStateInner(t,e){var n;let o=this.state,r=!1,i=!1;t.storedMarks&&this.composing&&(zr(this),i=!0),this.state=t;let s=o.plugins!=t.plugins||this._props.plugins!=e.plugins;if(s||this._props.plugins!=e.plugins||this._props.nodeViews!=e.nodeViews){let t=Si(this);(function(t,e){let n=0,o=0;for(let o in t){if(t[o]!=e[o])return!0;n++}for(let t in e)o++;return n!=o})(t,this.nodeViews)&&(this.nodeViews=t,r=!0)}(s||e.handleDOMEvents!=this._props.handleDOMEvents)&&xr(this),this.editable=Ci(this),Mi(this);let a=ai(this),l=xi(this),c=o.plugins==t.plugins||o.doc.eq(t.doc)?t.scrollToSelection>o.scrollToSelection?"to selection":"preserve":"reset",d=r||!this.docView.matchesNode(t.doc,l,a);!d&&t.selection.eq(o.selection)||(i=!0);let h="preserve"==c&&i&&null==this.dom.style.overflowAnchor&&function(t){let e,n,o=t.dom.getBoundingClientRect(),r=Math.max(0,o.top);for(let i=(o.left+o.right)/2,s=r+1;s<Math.min(innerHeight,o.bottom);s+=5){let o=t.root.elementFromPoint(i,s);if(!o||o==t.dom||!t.dom.contains(o))continue;let a=o.getBoundingClientRect();if(a.top>=r-20){e=o,n=a.top;break}}return{refDOM:e,refTop:n,stack:Gn(t.dom)}}(this);if(i){this.domObserver.stop();let e=d&&(Rn||zn)&&!this.composing&&!o.selection.empty&&!t.selection.empty&&function(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}(o.selection,t.selection);if(d){let n=zn?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=function(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=function(t,e){for(;;){if(3==t.nodeType&&e)return t;if(1==t.nodeType&&e>0){if("false"==t.contentEditable)return null;e=xn(t=t.childNodes[e-1])}else{if(!t.parentNode||Mn(t))return null;e=mn(t),t=t.parentNode}}}(e.focusNode,e.focusOffset),o=function(t,e){for(;;){if(3==t.nodeType&&e<t.nodeValue.length)return t;if(1==t.nodeType&&e<t.childNodes.length){if("false"==t.contentEditable)return null;t=t.childNodes[e],e=0}else{if(!t.parentNode||Mn(t))return null;e=mn(t)+1,t=t.parentNode}}}(e.focusNode,e.focusOffset);if(n&&o&&n!=o){let e=o.pmViewDesc,r=t.domObserver.lastChangedTextNode;if(n==r||o==r)return r;if(!e||!e.isText(o.nodeValue))return o;if(t.input.compositionNode==o){let t=n.pmViewDesc;if(t&&t.isText(n.nodeValue))return o}}return n||o}(this)),!r&&this.docView.update(t.doc,l,a,this)||(this.docView.updateOuterDeco(l),this.docView.destroy(),this.docView=vo(t.doc,l,a,this.dom,this)),n&&!this.trackWrites&&(e=!0)}e||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&function(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return vn(e.node,e.offset,n.anchorNode,n.anchorOffset)}(this))?$o(this,e):(Vo(this,t.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(o),(null===(n=this.dragging)||void 0===n?void 0:n.node)&&!o.doc.eq(t.doc)&&this.updateDraggedNode(this.dragging,o),"reset"==c?this.dom.scrollTop=0:"to selection"==c?this.scrollToSelection():h&&function({refDOM:t,refTop:e,stack:n}){let o=t?t.getBoundingClientRect().top:0;Yn(n,0==o?0:o-e)}(h)}scrollToSelection(){let t=this.domSelectionRange().focusNode;if(t&&this.dom.contains(1==t.nodeType?t:t.parentNode))if(this.someProp("handleScrollToSelection",t=>t(this)));else if(this.state.selection instanceof Ce){let e=this.docView.domAfterPos(this.state.selection.from);1==e.nodeType&&Jn(this,e.getBoundingClientRect(),t)}else Jn(this,this.coordsAtPos(this.state.selection.head,1),t)}destroyPluginViews(){let t;for(;t=this.pluginViews.pop();)t.destroy&&t.destroy()}updatePluginViews(t){if(t&&t.plugins==this.state.plugins&&this.directPlugins==this.prevDirectPlugins)for(let e=0;e<this.pluginViews.length;e++){let n=this.pluginViews[e];n.update&&n.update(this,t)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let e=this.directPlugins[t];e.spec.view&&this.pluginViews.push(e.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let e=this.state.plugins[t];e.spec.view&&this.pluginViews.push(e.spec.view(this))}}}updateDraggedNode(t,e){let n=t.node,o=-1;if(this.state.doc.nodeAt(n.from)==n.node)o=n.from;else{let t=n.from+(this.state.doc.content.size-e.doc.content.size);(t>0&&this.state.doc.nodeAt(t))==n.node&&(o=t)}this.dragging=new _r(t.slice,t.move,o<0?void 0:Ce.create(this.state.doc,o))}someProp(t,e){let n,o=this._props&&this._props[t];if(null!=o&&(n=e?e(o):o))return n;for(let o=0;o<this.directPlugins.length;o++){let r=this.directPlugins[o].props[t];if(null!=r&&(n=e?e(r):r))return n}let r=this.state.plugins;if(r)for(let o=0;o<r.length;o++){let i=r[o].props[t];if(null!=i&&(n=e?e(i):i))return n}}hasFocus(){if(Rn){let t=this.root.activeElement;if(t==this.dom)return!0;if(!t||!this.dom.contains(t))return!1;for(;t&&this.dom!=t&&this.dom.contains(t);){if("false"==t.contentEditable)return!1;t=t.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&function(t){if(t.setActive)return t.setActive();if(Xn)return t.focus(Xn);let e=Gn(t);t.focus(null==Xn?{get preventScroll(){return Xn={preventScroll:!0},!0}}:void 0),Xn||(Xn=!1,Yn(e,0))}(this.dom),$o(this),this.domObserver.start()}get root(){let t=this._root;if(null==t)for(let t=this.dom.parentNode;t;t=t.parentNode)if(9==t.nodeType||11==t.nodeType&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t;return t||document}updateRoot(){this._root=null}posAtCoords(t){return eo(this,t)}coordsAtPos(t,e=1){return io(this,t,e)}domAtPos(t,e=0){return this.docView.domFromPos(t,e)}nodeDOM(t){let e=this.docView.descAt(t);return e?e.nodeDOM:null}posAtDOM(t,e,n=-1){let o=this.docView.posFromDOM(t,e,n);if(null==o)throw new RangeError("DOM position not inside the editor");return o}endOfTextblock(t,e){return function(t,e,n){return ho==e&&po==n?uo:(ho=e,po=n,uo="up"==n||"down"==n?function(t,e,n){let o=e.selection,r="up"==n?o.$from:o.$to;return lo(t,e,()=>{let{node:e}=t.docView.domFromPos(r.pos,"up"==n?-1:1);for(;;){let n=t.docView.nearestDesc(e,!0);if(!n)break;if(n.node.isBlock){e=n.contentDOM||n.dom;break}e=n.dom.parentNode}let o=io(t,r.pos,1);for(let t=e.firstChild;t;t=t.nextSibling){let e;if(1==t.nodeType)e=t.getClientRects();else{if(3!=t.nodeType)continue;e=bn(t,0,t.nodeValue.length).getClientRects()}for(let t=0;t<e.length;t++){let r=e[t];if(r.bottom>r.top+1&&("up"==n?o.top-r.top>2*(r.bottom-o.top):r.bottom-o.bottom>2*(o.bottom-r.top)))return!1}}return!0})}(t,e,n):function(t,e,n){let{$head:o}=e.selection;if(!o.parent.isTextblock)return!1;let r=o.parentOffset,i=!r,s=r==o.parent.content.size,a=t.domSelection();return a?co.test(o.parent.textContent)&&a.modify?lo(t,e,()=>{let{focusNode:e,focusOffset:r,anchorNode:i,anchorOffset:s}=t.domSelectionRange(),l=a.caretBidiLevel;a.modify("move",n,"character");let c=o.depth?t.docView.domAfterPos(o.before()):t.dom,{focusNode:d,focusOffset:h}=t.domSelectionRange(),p=d&&!c.contains(1==d.nodeType?d:d.parentNode)||e==d&&r==h;try{a.collapse(i,s),e&&(e!=i||r!=s)&&a.extend&&a.extend(e,r)}catch(t){}return null!=l&&(a.caretBidiLevel=l),p}):"left"==n||"backward"==n?i:s:o.pos==o.start()||o.pos==o.end()}(t,e,n))}(this,e||this.state,t)}pasteHTML(t,e){return Hr(this,"",t,!1,e||new ClipboardEvent("paste"))}pasteText(t,e){return Hr(this,t,null,!0,e||new ClipboardEvent("paste"))}serializeForClipboard(t){return ir(this,t)}destroy(){this.docView&&(function(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],ai(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,yn=null)}get isDestroyed(){return null==this.docView}dispatchEvent(t){return function(t,e){Mr(t,e)||!yr[e.type]||!t.editable&&e.type in br||yr[e.type](t,e)}(this,t)}domSelectionRange(){let t=this.domSelection();return t?Pn&&11===this.root.nodeType&&function(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}(this.dom.ownerDocument)==this.dom&&function(t,e){if(e.getComposedRanges){let n=e.getComposedRanges(t.root)[0];if(n)return fi(t,n)}let n;function o(t){t.preventDefault(),t.stopImmediatePropagation(),n=t.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",o,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",o,!0),n?fi(t,n):null}(this,t)||t:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function xi(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if("function"==typeof n&&(n=n(t.state)),n)for(let t in n)"class"==t?e.class+=" "+n[t]:"style"==t?e.style=(e.style?e.style+";":"")+n[t]:e[t]||"contenteditable"==t||"nodeName"==t||(e[t]=String(n[t]))}),e.translate||(e.translate="no"),[Jr.node(0,t.state.doc.content.size,e)]}function Mi(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:Jr.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function Ci(t){return!t.someProp("editable",e=>!1===e(t.state))}function Si(t){let e=Object.create(null);function n(t){for(let n in t)Object.prototype.hasOwnProperty.call(e,n)||(e[n]=t[n])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function Ti(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}ki.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};for(var Ai={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Ei={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Ni="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),Oi="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Li=0;Li<10;Li++)Ai[48+Li]=Ai[96+Li]=String(Li);for(Li=1;Li<=24;Li++)Ai[Li+111]="F"+Li;for(Li=65;Li<=90;Li++)Ai[Li]=String.fromCharCode(Li+32),Ei[Li]=String.fromCharCode(Li);for(var Ri in Ai)Ei.hasOwnProperty(Ri)||(Ei[Ri]=Ai[Ri]);const Di="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),ji="undefined"!=typeof navigator&&/Win/.test(navigator.platform);function Ii(t){let e,n,o,r,i=t.split(/-(?!$)/),s=i[i.length-1];"Space"==s&&(s=" ");for(let t=0;t<i.length-1;t++){let s=i[t];if(/^(cmd|meta|m)$/i.test(s))r=!0;else if(/^a(lt)?$/i.test(s))e=!0;else if(/^(c|ctrl|control)$/i.test(s))n=!0;else if(/^s(hift)?$/i.test(s))o=!0;else{if(!/^mod$/i.test(s))throw new Error("Unrecognized modifier name: "+s);Di?r=!0:n=!0}}return e&&(s="Alt-"+s),n&&(s="Ctrl-"+s),r&&(s="Meta-"+s),o&&(s="Shift-"+s),s}function zi(t,e,n=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n&&e.shiftKey&&(t="Shift-"+t),t}function $i(t){let e=function(t){let e=Object.create(null);for(let n in t)e[Ii(n)]=t[n];return e}(t);return function(t,n){let o,r=function(t){var e=!(Ni&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||Oi&&t.shiftKey&&t.key&&1==t.key.length||"Unidentified"==t.key)&&t.key||(t.shiftKey?Ei:Ai)[t.keyCode]||t.key||"Unidentified";return"Esc"==e&&(e="Escape"),"Del"==e&&(e="Delete"),"Left"==e&&(e="ArrowLeft"),"Up"==e&&(e="ArrowUp"),"Right"==e&&(e="ArrowRight"),"Down"==e&&(e="ArrowDown"),e}(n),i=e[zi(r,n)];if(i&&i(t.state,t.dispatch,t))return!0;if(1==r.length&&" "!=r){if(n.shiftKey){let o=e[zi(r,n,!1)];if(o&&o(t.state,t.dispatch,t))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(ji&&n.ctrlKey&&n.altKey)&&(o=Ai[n.keyCode])&&o!=r){let r=e[zi(o,n)];if(r&&r(t.state,t.dispatch,t))return!0}}return!1}}var Pi=Object.defineProperty,Hi=(t,e)=>{for(var n in e)Pi(t,n,{get:e[n],enumerable:!0})};function Bi(t){const{state:e,transaction:n}=t;let{selection:o}=n,{doc:r}=n,{storedMarks:i}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return i},get selection(){return o},get doc(){return r},get tr(){return o=n.selection,r=n.doc,i=n.storedMarks,n}}}var _i=class{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:o}=e,{tr:r}=n,i=this.buildProps(r);return Object.fromEntries(Object.entries(t).map(([t,e])=>[t,(...t)=>{const n=e(...t)(i);return r.getMeta("preventDispatch")||this.hasCustomState||o.dispatch(r),n}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:o,state:r}=this,{view:i}=o,s=[],a=!!t,l=t||r.tr,c={...Object.fromEntries(Object.entries(n).map(([t,n])=>[t,(...t)=>{const o=this.buildProps(l,e),r=n(...t)(o);return s.push(r),c}])),run:()=>(a||!e||l.getMeta("preventDispatch")||this.hasCustomState||i.dispatch(l),s.every(t=>!0===t))};return c}createCan(t){const{rawCommands:e,state:n}=this,o=!1,r=t||n.tr,i=this.buildProps(r,o);return{...Object.fromEntries(Object.entries(e).map(([t,e])=>[t,(...t)=>e(...t)({...i,dispatch:void 0})])),chain:()=>this.createChain(r,o)}}buildProps(t,e=!0){const{rawCommands:n,editor:o,state:r}=this,{view:i}=o,s={tr:t,editor:o,view:i,state:Bi({state:r,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map(([t,e])=>[t,(...t)=>e(...t)(s)]))}};return s}},Vi={};Hi(Vi,{blur:()=>Fi,clearContent:()=>Wi,clearNodes:()=>Ki,command:()=>qi,createParagraphNear:()=>Ui,cut:()=>Ji,deleteCurrentNode:()=>Gi,deleteNode:()=>Xi,deleteRange:()=>Qi,deleteSelection:()=>Zi,enter:()=>ts,exitCode:()=>es,extendMarkRange:()=>cs,first:()=>ds,focus:()=>ms,forEach:()=>gs,insertContent:()=>ys,insertContentAt:()=>ks,joinBackward:()=>Cs,joinDown:()=>Ms,joinForward:()=>Ss,joinItemBackward:()=>Ts,joinItemForward:()=>As,joinTextblockBackward:()=>Es,joinTextblockForward:()=>Ns,joinUp:()=>xs,keyboardShortcut:()=>Ls,lift:()=>Ds,liftEmptyBlock:()=>js,liftListItem:()=>Is,newlineInCode:()=>zs,resetAttributes:()=>Hs,scrollIntoView:()=>Bs,selectAll:()=>_s,selectNodeBackward:()=>Vs,selectNodeForward:()=>Fs,selectParentNode:()=>Ws,selectTextblockEnd:()=>Ks,selectTextblockStart:()=>qs,setContent:()=>Js,setMark:()=>Na,setMeta:()=>Oa,setNode:()=>La,setNodeSelection:()=>Ra,setTextDirection:()=>Da,setTextSelection:()=>ja,sinkListItem:()=>Ia,splitBlock:()=>$a,splitListItem:()=>Pa,toggleList:()=>_a,toggleMark:()=>Va,toggleNode:()=>Fa,toggleWrap:()=>Wa,undoInputRule:()=>Ka,unsetAllMarks:()=>qa,unsetMark:()=>Ua,unsetTextDirection:()=>Ja,updateAttributes:()=>Ga,wrapIn:()=>Ya,wrapInList:()=>Xa});var Fi=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),null==(n=null==window?void 0:window.getSelection())||n.removeAllRanges())}),!0),Wi=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),Ki=()=>({state:t,tr:e,dispatch:n})=>{const{selection:o}=e,{ranges:r}=o;return!n||(r.forEach(({$from:n,$to:o})=>{t.doc.nodesBetween(n.pos,o.pos,(t,n)=>{if(t.type.isText)return;const{doc:o,mapping:r}=e,i=o.resolve(r.map(n)),s=o.resolve(r.map(n+t.nodeSize)),a=i.blockRange(s);if(!a)return;const l=qt(a);if(t.type.isTextblock){const{defaultType:t}=i.parent.contentMatchAt(i.index());e.setNodeMarkup(a.start,t)}(l||0===l)&&e.lift(a,l)})}),!0)},qi=t=>e=>t(e),Ui=()=>({state:t,dispatch:e})=>en(t,e),Ji=(t,e)=>({editor:n,tr:o})=>{const{state:r}=n,i=r.doc.slice(t.from,t.to);o.deleteRange(t.from,t.to);const s=o.mapping.map(e);return o.insert(s,i.content),o.setSelection(new xe(o.doc.resolve(Math.max(s-1,0)))),!0},Gi=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,o=n.$anchor.node();if(o.content.size>0)return!1;const r=t.selection.$anchor;for(let n=r.depth;n>0;n-=1)if(r.node(n).type===o.type){if(e){const e=r.before(n),o=r.after(n);t.delete(e,o).scrollIntoView()}return!0}return!1};function Yi(t,e){if("string"==typeof t){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}var Xi=t=>({tr:e,state:n,dispatch:o})=>{const r=Yi(t,n.schema),i=e.selection.$anchor;for(let t=i.depth;t>0;t-=1)if(i.node(t).type===r){if(o){const n=i.before(t),o=i.after(t);e.delete(n,o).scrollIntoView()}return!0}return!1},Qi=t=>({tr:e,dispatch:n})=>{const{from:o,to:r}=t;return n&&e.delete(o,r),!0},Zi=()=>({state:t,dispatch:e})=>_e(t,e),ts=()=>({commands:t})=>t.keyboardShortcut("Enter"),es=()=>({state:t,dispatch:e})=>tn(t,e);function ns(t){return"[object RegExp]"===Object.prototype.toString.call(t)}function rs(t,e,n={strict:!0}){const o=Object.keys(e);return!o.length||o.every(o=>n.strict?e[o]===t[o]:ns(e[o])?e[o].test(t[o]):e[o]===t[o])}function is(t,e,n={}){return t.find(t=>t.type===e&&rs(Object.fromEntries(Object.keys(n).map(e=>[e,t.attrs[e]])),n))}function ss(t,e,n={}){return!!is(t,e,n)}function as(t,e,n){var o;if(!t||!e)return;let r=t.parent.childAfter(t.parentOffset);if(r.node&&r.node.marks.some(t=>t.type===e)||(r=t.parent.childBefore(t.parentOffset)),!r.node||!r.node.marks.some(t=>t.type===e))return;if(n=n||(null==(o=r.node.marks[0])?void 0:o.attrs),!is([...r.node.marks],e,n))return;let i=r.index,s=t.start()+r.offset,a=i+1,l=s+r.node.nodeSize;for(;i>0&&ss([...t.parent.child(i-1).marks],e,n);)i-=1,s-=t.parent.child(i).nodeSize;for(;a<t.parent.childCount&&ss([...t.parent.child(a).marks],e,n);)l+=t.parent.child(a).nodeSize,a+=1;return{from:s,to:l}}function ls(t,e){if("string"==typeof t){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}var cs=(t,e={})=>({tr:n,state:o,dispatch:r})=>{const i=ls(t,o.schema),{doc:s,selection:a}=n,{$from:l,from:c,to:d}=a;if(r){const t=as(l,i,e);if(t&&t.from<=c&&t.to>=d){const e=xe.create(s,t.from,t.to);n.setSelection(e)}}return!0},ds=t=>e=>{const n="function"==typeof t?t(e):t;for(let t=0;t<n.length;t+=1)if(n[t](e))return!0;return!1};function hs(t){return t instanceof xe}function ps(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function us(t,e=null){if(!e)return null;const n=be.atStart(t),o=be.atEnd(t);if("start"===e||!0===e)return n;if("end"===e)return o;const r=n.from,i=o.to;return"all"===e?xe.create(t,ps(0,r,i),ps(t.content.size,r,i)):xe.create(t,ps(e,r,i),ps(e,r,i))}function fs(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var ms=(t=null,e={})=>({editor:n,view:o,tr:r,dispatch:i})=>{e={scrollIntoView:!0,...e};const s=()=>{(fs()||"Android"===navigator.platform||/android/i.test(navigator.userAgent))&&o.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(o.focus(),(null==e?void 0:e.scrollIntoView)&&n.commands.scrollIntoView())})};if(o.hasFocus()&&null===t||!1===t)return!0;if(i&&null===t&&!hs(n.state.selection))return s(),!0;const a=us(r.doc,t)||n.state.selection,l=n.state.selection.eq(a);return i&&(l||r.setSelection(a),l&&r.storedMarks&&r.setStoredMarks(r.storedMarks),s()),!0},gs=(t,e)=>n=>t.every((t,o)=>e(t,{...n,index:o})),ys=(t,e)=>({tr:n,commands:o})=>o.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),bs=t=>{const e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){const o=e[n];3===o.nodeType&&o.nodeValue&&/^(\n\s\s|\n)$/.test(o.nodeValue)?t.removeChild(o):1===o.nodeType&&bs(o)}return t};function vs(t){if("undefined"==typeof window)throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${t}</body>`,n=(new window.DOMParser).parseFromString(e,"text/html").body;return bs(n)}function ws(t,e,n){if(t instanceof K||t instanceof k)return t;n={slice:!0,parseOptions:{},...n};const o="string"==typeof t;if("object"==typeof t&&null!==t)try{if(Array.isArray(t)&&t.length>0)return k.fromArray(t.map(t=>e.nodeFromJSON(t)));const o=e.nodeFromJSON(t);return n.errorOnInvalidContent&&o.check(),o}catch(o){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:o});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",o),ws("",e,n)}if(o){if(n.errorOnInvalidContent){let o=!1,r="";const i=new dt({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:t=>(o=!0,r="string"==typeof t?t:t.outerHTML,null)}]}})});if(n.slice?pt.fromSchema(i).parseSlice(vs(t),n.parseOptions):pt.fromSchema(i).parse(vs(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${r}`)})}const o=pt.fromSchema(e);return n.slice?o.parseSlice(vs(t),n.parseOptions).content:o.parse(vs(t),n.parseOptions)}return ws("",e,n)}var ks=(t,e,n)=>({tr:o,dispatch:r,editor:i})=>{var s;if(r){let r;const a=t=>{i.emit("contentError",{editor:i,error:t,disableCollaboration:()=>{"collaboration"in i.storage&&"object"==typeof i.storage.collaboration&&i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}})},l={preserveWhitespace:"full",...(n={parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n}).parseOptions};if(!n.errorOnInvalidContent&&!i.options.enableContentCheck&&i.options.emitContentError)try{ws(e,i.schema,{parseOptions:l,errorOnInvalidContent:!0})}catch(t){a(t)}try{r=ws(e,i.schema,{parseOptions:l,errorOnInvalidContent:null!=(s=n.errorOnInvalidContent)?s:i.options.enableContentCheck})}catch(t){return a(t),!1}let c,{from:d,to:h}="number"==typeof t?{from:t,to:t}:{from:t.from,to:t.to},p=!0,u=!0;if(("type"in r?[r]:r).forEach(t=>{t.check(),p=!!p&&t.isText&&0===t.marks.length,u=!!u&&t.isBlock}),d===h&&u){const{parent:t}=o.doc.resolve(d);t.isTextblock&&!t.type.spec.code&&!t.childCount&&(d-=1,h+=1)}if(p){if(Array.isArray(e))c=e.map(t=>t.text||"").join("");else if(e instanceof k){let t="";e.forEach(e=>{e.text&&(t+=e.text)}),c=t}else c="object"==typeof e&&e&&e.text?e.text:e;o.insertText(c,d,h)}else{c=r;const t=o.doc.resolve(d),e=t.node(),n=0===t.parentOffset,i=e.isText||e.isTextblock,s=e.content.size>0;n&&i&&s&&(d=Math.max(0,d-1)),o.replaceWith(d,h,c)}n.updateSelection&&function(t,e){const n=t.steps.length-1;if(n<e)return;const o=t.steps[n];if(!(o instanceof _t||o instanceof Vt))return;const r=t.mapping.maps[n];let i=0;r.forEach((t,e,n,o)=>{0===i&&(i=o)}),t.setSelection(be.near(t.doc.resolve(i),-1))}(o,o.steps.length-1),n.applyInputRules&&o.setMeta("applyInputRules",{from:d,text:c}),n.applyPasteRules&&o.setMeta("applyPasteRules",{from:d,text:c})}return!0},xs=()=>({state:t,dispatch:e})=>((t,e)=>{let n,o=t.selection,r=o instanceof Ce;if(r){if(o.node.isTextblock||!Qt(t.doc,o.from))return!1;n=o.from}else if(n=te(t.doc,o.from,-1),null==n)return!1;if(e){let o=t.tr.join(n);r&&o.setSelection(Ce.create(o.doc,n-t.doc.resolve(n).nodeBefore.nodeSize)),e(o.scrollIntoView())}return!0})(t,e),Ms=()=>({state:t,dispatch:e})=>((t,e)=>{let n,o=t.selection;if(o instanceof Ce){if(o.node.isTextblock||!Qt(t.doc,o.to))return!1;n=o.to}else if(n=te(t.doc,o.to,1),null==n)return!1;return e&&e(t.tr.join(n).scrollIntoView()),!0})(t,e),Cs=()=>({state:t,dispatch:e})=>Fe(t,e),Ss=()=>({state:t,dispatch:e})=>Ge(t,e),Ts=()=>({state:t,dispatch:e,tr:n})=>{try{const o=te(t.doc,t.selection.$from.pos,-1);return null!=o&&(n.join(o,2),e&&e(n),!0)}catch{return!1}},As=()=>({state:t,dispatch:e,tr:n})=>{try{const o=te(t.doc,t.selection.$from.pos,1);return null!=o&&(n.join(o,2),e&&e(n),!0)}catch{return!1}},Es=()=>({state:t,dispatch:e})=>((t,e)=>{let n=Ve(t,void 0);if(!n)return!1;let o=Ue(n);return!!o&&We(t,o,e)})(t,e),Ns=()=>({state:t,dispatch:e})=>((t,e)=>{let n=Je(t,void 0);if(!n)return!1;let o=Xe(n);return!!o&&We(t,o,e)})(t,e);function Os(){return"undefined"!=typeof navigator&&/Mac/.test(navigator.platform)}var Ls=t=>({editor:e,view:n,tr:o,dispatch:r})=>{const i=function(t){const e=t.split(/-(?!$)/);let n,o,r,i,s=e[e.length-1];"Space"===s&&(s=" ");for(let t=0;t<e.length-1;t+=1){const s=e[t];if(/^(cmd|meta|m)$/i.test(s))i=!0;else if(/^a(lt)?$/i.test(s))n=!0;else if(/^(c|ctrl|control)$/i.test(s))o=!0;else if(/^s(hift)?$/i.test(s))r=!0;else{if(!/^mod$/i.test(s))throw new Error(`Unrecognized modifier name: ${s}`);fs()||Os()?i=!0:o=!0}}return n&&(s=`Alt-${s}`),o&&(s=`Ctrl-${s}`),i&&(s=`Meta-${s}`),r&&(s=`Shift-${s}`),s}(t).split(/-(?!$)/),s=i.find(t=>!["Alt","Ctrl","Meta","Shift"].includes(t)),a=new KeyboardEvent("keydown",{key:"Space"===s?" ":s,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),l=e.captureTransaction(()=>{n.someProp("handleKeyDown",t=>t(n,a))});return null==l||l.steps.forEach(t=>{const e=t.map(o.mapping);e&&r&&o.maybeStep(e)}),!0};function Rs(t,e,n={}){const{from:o,to:r,empty:i}=t.selection,s=e?Yi(e,t.schema):null,a=[];t.doc.nodesBetween(o,r,(t,e)=>{if(t.isText)return;const n=Math.max(o,e),i=Math.min(r,e+t.nodeSize);a.push({node:t,from:n,to:i})});const l=r-o,c=a.filter(t=>!s||s.name===t.node.type.name).filter(t=>rs(t.node.attrs,n,{strict:!1}));return i?!!c.length:c.reduce((t,e)=>t+e.to-e.from,0)>=l}var Ds=(t,e={})=>({state:n,dispatch:o})=>!!Rs(n,Yi(t,n.schema),e)&&((t,e)=>{let{$from:n,$to:o}=t.selection,r=n.blockRange(o),i=r&&qt(r);return null!=i&&(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)})(n,o),js=()=>({state:t,dispatch:e})=>nn(t,e),Is=t=>({state:e,dispatch:n})=>{return(o=Yi(t,e.schema),function(t,e){let{$from:n,$to:r}=t.selection,i=n.blockRange(r,t=>t.childCount>0&&t.firstChild.type==o);return!!i&&(!e||(n.node(i.depth-1).type==o?function(t,e,n,o){let r=t.tr,i=o.end,s=o.$to.end(o.depth);i<s&&(r.step(new Vt(i-1,s,i,s,new A(k.from(n.create(null,o.parent.copy())),1,0),1,!0)),o=new F(r.doc.resolve(o.$from.pos),r.doc.resolve(s),o.depth));const a=qt(o);if(null==a)return!1;r.lift(o,a);let l=r.doc.resolve(r.mapping.map(i,-1)-1);return Qt(r.doc,l.pos)&&l.nodeBefore.type==l.nodeAfter.type&&r.join(l.pos),e(r.scrollIntoView()),!0}(t,e,o,i):function(t,e,n){let o=t.tr,r=n.parent;for(let t=n.end,e=n.endIndex-1,i=n.startIndex;e>i;e--)t-=r.child(e).nodeSize,o.delete(t-1,t+1);let i=o.doc.resolve(n.start),s=i.nodeAfter;if(o.mapping.map(n.end)!=n.start+i.nodeAfter.nodeSize)return!1;let a=0==n.startIndex,l=n.endIndex==r.childCount,c=i.node(-1),d=i.index(-1);if(!c.canReplace(d+(a?0:1),d+1,s.content.append(l?k.empty:k.from(r))))return!1;let h=i.pos,p=h+s.nodeSize;return o.step(new Vt(h-(a?1:0),p+(l?1:0),h+1,p-1,new A((a?k.empty:k.from(r.copy(k.empty))).append(l?k.empty:k.from(r.copy(k.empty))),a?0:1,l?0:1),a?0:1)),e(o.scrollIntoView()),!0}(t,e,i)))})(e,n);var o},zs=()=>({state:t,dispatch:e})=>Qe(t,e);function $s(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function Ps(t,e){const n="string"==typeof e?[e]:e;return Object.keys(t).reduce((e,o)=>(n.includes(o)||(e[o]=t[o]),e),{})}var Hs=(t,e)=>({tr:n,state:o,dispatch:r})=>{let i=null,s=null;const a=$s("string"==typeof t?t:t.name,o.schema);if(!a)return!1;"node"===a&&(i=Yi(t,o.schema)),"mark"===a&&(s=ls(t,o.schema));let l=!1;return n.selection.ranges.forEach(t=>{o.doc.nodesBetween(t.$from.pos,t.$to.pos,(t,o)=>{i&&i===t.type&&(l=!0,r&&n.setNodeMarkup(o,void 0,Ps(t.attrs,e))),s&&t.marks.length&&t.marks.forEach(i=>{s===i.type&&(l=!0,r&&n.addMark(o,o+t.nodeSize,s.create(Ps(i.attrs,e))))})})}),l},Bs=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),_s=()=>({tr:t,dispatch:e})=>{if(e){const e=new Te(t.doc);t.setSelection(e)}return!0},Vs=()=>({state:t,dispatch:e})=>qe(t,e),Fs=()=>({state:t,dispatch:e})=>Ye(t,e),Ws=()=>({state:t,dispatch:e})=>((t,e)=>{let n,{$from:o,to:r}=t.selection,i=o.sharedDepth(r);return 0!=i&&(n=o.before(i),e&&e(t.tr.setSelection(Ce.create(t.doc,n))),!0)})(t,e),Ks=()=>({state:t,dispatch:e})=>ln(t,e),qs=()=>({state:t,dispatch:e})=>an(t,e);function Us(t,e,n={},o={}){return ws(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:o.errorOnInvalidContent})}var Js=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:o={}}={})=>({editor:r,tr:i,dispatch:s,commands:a})=>{const{doc:l}=i;if("full"!==o.preserveWhitespace){const a=Us(t,r.schema,o,{errorOnInvalidContent:null!=e?e:r.options.enableContentCheck});return s&&i.replaceWith(0,l.content.size,a).setMeta("preventUpdate",!n),!0}return s&&i.setMeta("preventUpdate",!n),a.insertContentAt({from:0,to:l.content.size},t,{parseOptions:o,errorOnInvalidContent:null!=e?e:r.options.enableContentCheck})};function Gs(t,e){const n=ls(e,t.schema),{from:o,to:r,empty:i}=t.selection,s=[];i?(t.storedMarks&&s.push(...t.storedMarks),s.push(...t.selection.$head.marks())):t.doc.nodesBetween(o,r,t=>{s.push(...t.marks)});const a=s.find(t=>t.type.name===n.name);return a?{...a.attrs}:{}}function Ys(t,e){const n=new ge(t);return e.forEach(t=>{t.steps.forEach(t=>{n.step(t)})}),n}function Xs(t,e){const n=[];return t.descendants((t,o)=>{e(t)&&n.push({node:t,pos:o})}),n}function Qs(t,e){for(let n=t.depth;n>0;n-=1){const o=t.node(n);if(e(o))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:o}}}function Zs(t){return e=>Qs(e.$from,t)}function ta(t,e,n){return void 0===t.config[e]&&t.parent?ta(t.parent,e,n):"function"==typeof t.config[e]?t.config[e].bind({...n,parent:t.parent?ta(t.parent,e,n):null}):t.config[e]}function ea(t){return t.map(t=>{const e=ta(t,"addExtensions",{name:t.name,options:t.options,storage:t.storage});return e?[t,...ea(e())]:t}).flat(10)}function na(t,e){const n=xt.fromSchema(e).serializeFragment(t),o=document.implementation.createHTMLDocument().createElement("div");return o.appendChild(n),o.innerHTML}function oa(t){return"function"==typeof t}function ra(t,e=void 0,...n){return oa(t)?e?t.bind(e)(...n):t(...n):t}function ia(t){return{baseExtensions:t.filter(t=>"extension"===t.type),nodeExtensions:t.filter(t=>"node"===t.type),markExtensions:t.filter(t=>"mark"===t.type)}}function sa(t){const e=[],{nodeExtensions:n,markExtensions:o}=ia(t),r=[...n,...o],i={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach(t=>{const n=ta(t,"addGlobalAttributes",{name:t.name,options:t.options,storage:t.storage,extensions:r});n&&n().forEach(t=>{t.types.forEach(n=>{Object.entries(t.attributes).forEach(([t,o])=>{e.push({type:n,name:t,attribute:{...i,...o}})})})})}),r.forEach(t=>{const n={name:t.name,options:t.options,storage:t.storage},o=ta(t,"addAttributes",n);if(!o)return;const r=o();Object.entries(r).forEach(([n,o])=>{const r={...i,...o};"function"==typeof(null==r?void 0:r.default)&&(r.default=r.default()),(null==r?void 0:r.isRequired)&&void 0===(null==r?void 0:r.default)&&delete r.default,e.push({type:t.name,name:n,attribute:r})})}),e}function aa(...t){return t.filter(t=>!!t).reduce((t,e)=>{const n={...t};return Object.entries(e).forEach(([t,e])=>{if(n[t])if("class"===t){const o=e?String(e).split(" "):[],r=n[t]?n[t].split(" "):[],i=o.filter(t=>!r.includes(t));n[t]=[...r,...i].join(" ")}else if("style"===t){const o=e?e.split(";").map(t=>t.trim()).filter(Boolean):[],r=n[t]?n[t].split(";").map(t=>t.trim()).filter(Boolean):[],i=new Map;r.forEach(t=>{const[e,n]=t.split(":").map(t=>t.trim());i.set(e,n)}),o.forEach(t=>{const[e,n]=t.split(":").map(t=>t.trim());i.set(e,n)}),n[t]=Array.from(i.entries()).map(([t,e])=>`${t}: ${e}`).join("; ")}else n[t]=e;else n[t]=e}),n},{})}function la(t,e){return e.filter(e=>e.type===t.type.name).filter(t=>t.attribute.rendered).map(e=>e.attribute.renderHTML?e.attribute.renderHTML(t.attrs)||{}:{[e.name]:t.attrs[e.name]}).reduce((t,e)=>aa(t,e),{})}function ca(t,e){return"style"in t?t:{...t,getAttrs:n=>{const o=t.getAttrs?t.getAttrs(n):t.attrs;if(!1===o)return!1;const r=e.reduce((t,e)=>{const o=e.attribute.parseHTML?e.attribute.parseHTML(n):function(t){return"string"!=typeof t?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):"true"===t||"false"!==t&&t}(n.getAttribute(e.name));return null==o?t:{...t,[e.name]:o}},{});return{...o,...r}}}}function da(t){return Object.fromEntries(Object.entries(t).filter(([t,e])=>("attrs"!==t||!function(t={}){return 0===Object.keys(t).length&&t.constructor===Object}(e))&&null!=e))}function ha(t){var e,n;const o={};return!(null==(e=null==t?void 0:t.attribute)?void 0:e.isRequired)&&"default"in((null==t?void 0:t.attribute)||{})&&(o.default=t.attribute.default),void 0!==(null==(n=null==t?void 0:t.attribute)?void 0:n.validate)&&(o.validate=t.attribute.validate),[t.name,o]}function pa(t){return t.sort((t,e)=>{const n=ta(t,"priority")||100,o=ta(e,"priority")||100;return n>o?-1:n<o?1:0})}function ua(t){const e=pa(ea(t)),n=function(t){const e=t.filter((e,n)=>t.indexOf(e)!==n);return Array.from(new Set(e))}(e.map(t=>t.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(t=>`'${t}'`).join(", ")}]. This can lead to issues.`),e}function fa(t,e,n){const{from:o,to:r}=e,{blockSeparator:i="\n\n",textSerializers:s={}}=n||{};let a="";return t.nodesBetween(o,r,(t,n,l,c)=>{var d;t.isBlock&&n>o&&(a+=i);const h=null==s?void 0:s[t.type.name];if(h)return l&&(a+=h({node:t,pos:n,parent:l,index:c,range:e})),!1;t.isText&&(a+=null==(d=null==t?void 0:t.text)?void 0:d.slice(Math.max(o,n)-n,r-n))}),a}function ma(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,t])=>t.spec.toText).map(([t,e])=>[t,e.spec.toText]))}function ga(t,e){const n=$s("string"==typeof e?e:e.name,t.schema);return"node"===n?function(t,e){const n=Yi(e,t.schema),{from:o,to:r}=t.selection,i=[];t.doc.nodesBetween(o,r,t=>{i.push(t)});const s=i.reverse().find(t=>t.type.name===n.name);return s?{...s.attrs}:{}}(t,e):"mark"===n?Gs(t,e):{}}function ya(t){const{mapping:e,steps:n}=t,o=[];return e.maps.forEach((t,r)=>{const i=[];if(t.ranges.length)t.forEach((t,e)=>{i.push({from:t,to:e})});else{const{from:t,to:e}=n[r];if(void 0===t||void 0===e)return;i.push({from:t,to:e})}i.forEach(({from:t,to:n})=>{const i=e.slice(r).map(t,-1),s=e.slice(r).map(n),a=e.invert().map(i,-1),l=e.invert().map(s);o.push({oldRange:{from:a,to:l},newRange:{from:i,to:s}})})}),function(t){const e=function(t,e=JSON.stringify){const n={};return t.filter(t=>{const o=e(t);return!Object.prototype.hasOwnProperty.call(n,o)&&(n[o]=!0)})}(t);return 1===e.length?e:e.filter((t,n)=>{const o=e.filter((t,e)=>e!==n);return!o.some(e=>t.oldRange.from>=e.oldRange.from&&t.oldRange.to<=e.oldRange.to&&t.newRange.from>=e.newRange.from&&t.newRange.to<=e.newRange.to)})}(o)}function ba(t,e,n){const o=[];return t===e?n.resolve(t).marks().forEach(e=>{const r=as(n.resolve(t),e.type);r&&o.push({mark:e,...r})}):n.nodesBetween(t,e,(t,e)=>{t&&void 0!==(null==t?void 0:t.nodeSize)&&o.push(...t.marks.map(n=>({from:e,to:e+t.nodeSize,mark:n})))}),o}function va(t,e){return e.nodes[t]||e.marks[t]||null}function wa(t,e,n){return Object.fromEntries(Object.entries(n).filter(([n])=>{const o=t.find(t=>t.type===e&&t.name===n);return!!o&&o.attribute.keepOnSplit}))}function ka(t,e,n={}){const{empty:o,ranges:r}=t.selection,i=e?ls(e,t.schema):null;if(o)return!!(t.storedMarks||t.selection.$from.marks()).filter(t=>!i||i.name===t.type.name).find(t=>rs(t.attrs,n,{strict:!1}));let s=0;const a=[];if(r.forEach(({$from:e,$to:n})=>{const o=e.pos,r=n.pos;t.doc.nodesBetween(o,r,(t,e)=>{if(!t.isText&&!t.marks.length)return;const n=Math.max(o,e),i=Math.min(r,e+t.nodeSize);s+=i-n,a.push(...t.marks.map(t=>({mark:t,from:n,to:i})))})}),0===s)return!1;const l=a.filter(t=>!i||i.name===t.mark.type.name).filter(t=>rs(t.mark.attrs,n,{strict:!1})).reduce((t,e)=>t+e.to-e.from,0),c=a.filter(t=>!i||t.mark.type!==i&&t.mark.type.excludes(i)).reduce((t,e)=>t+e.to-e.from,0);return(l>0?l+c:l)>=s}function xa(t,e){return Array.isArray(e)?e.some(e=>("string"==typeof e?e:e.name)===t.name):e}function Ma(t,e){const{nodeExtensions:n}=ia(e),o=n.find(e=>e.name===t);if(!o)return!1;const r=ra(ta(o,"group",{name:o.name,options:o.options,storage:o.storage}));return"string"==typeof r&&r.split(" ").includes("list")}function Ca(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var o;if(n){if("hardBreak"===t.type.name)return!0;if(t.isText)return/^\s*$/m.test(null!=(o=t.text)?o:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(0===t.content.childCount)return!0;if(e){let o=!0;return t.content.forEach(t=>{!1!==o&&(Ca(t,{ignoreWhitespace:n,checkChildren:e})||(o=!1))}),o}return!1}function Sa(t){return t instanceof Ce}var Ta=class t{constructor(t){this.position=t}static fromJSON(e){return new t(e.position)}toJSON(){return{position:this.position}}};function Aa(t,e){const n=e.mapping.mapResult(t.position);return{position:new Ta(n.pos),mapResult:n}}function Ea(t){return new Ta(t)}var Na=(t,e={})=>({tr:n,state:o,dispatch:r})=>{const{selection:i}=n,{empty:s,ranges:a}=i,l=ls(t,o.schema);if(r)if(s){const t=Gs(o,l);n.addStoredMark(l.create({...t,...e}))}else a.forEach(t=>{const r=t.$from.pos,i=t.$to.pos;o.doc.nodesBetween(r,i,(t,o)=>{const s=Math.max(o,r),a=Math.min(o+t.nodeSize,i);t.marks.find(t=>t.type===l)?t.marks.forEach(t=>{l===t.type&&n.addMark(s,a,l.create({...t.attrs,...e}))}):n.addMark(s,a,l.create(e))})});return function(t,e,n){var o;const{selection:r}=e;let i=null;if(hs(r)&&(i=r.$cursor),i){const e=null!=(o=t.storedMarks)?o:i.marks();return i.parent.type.allowsMarkType(n)&&(!!n.isInSet(e)||!e.some(t=>t.type.excludes(n)))}const{ranges:s}=r;return s.some(({$from:e,$to:o})=>{let r=0===e.depth&&t.doc.inlineContent&&t.doc.type.allowsMarkType(n);return t.doc.nodesBetween(e.pos,o.pos,(t,e,o)=>{if(r)return!1;if(t.isInline){const e=!o||o.type.allowsMarkType(n),i=!!n.isInSet(t.marks)||!t.marks.some(t=>t.type.excludes(n));r=e&&i}return!r}),r})}(o,n,l)},Oa=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),La=(t,e={})=>({state:n,dispatch:o,chain:r})=>{const i=Yi(t,n.schema);let s;return n.selection.$anchor.sameParent(n.selection.$head)&&(s=n.selection.$anchor.parent.attrs),i.isTextblock?r().command(({commands:t})=>!!cn(i,{...s,...e})(n)||t.clearNodes()).command(({state:t})=>cn(i,{...s,...e})(t,o)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},Ra=t=>({tr:e,dispatch:n})=>{if(n){const{doc:n}=e,o=ps(t,0,n.content.size),r=Ce.create(n,o);e.setSelection(r)}return!0},Da=(t,e)=>({tr:n,state:o,dispatch:r})=>{const{selection:i}=o;let s,a;return"number"==typeof e?(s=e,a=e):e&&"from"in e&&"to"in e?(s=e.from,a=e.to):(s=i.from,a=i.to),r&&n.doc.nodesBetween(s,a,(e,o)=>{e.isText||n.setNodeMarkup(o,void 0,{...e.attrs,dir:t})}),!0},ja=t=>({tr:e,dispatch:n})=>{if(n){const{doc:n}=e,{from:o,to:r}="number"==typeof t?{from:t,to:t}:t,i=xe.atStart(n).from,s=xe.atEnd(n).to,a=ps(o,i,s),l=ps(r,i,s),c=xe.create(n,a,l);e.setSelection(c)}return!0},Ia=t=>({state:e,dispatch:n})=>{const o=Yi(t,e.schema);return(r=o,function(t,e){let{$from:n,$to:o}=t.selection,i=n.blockRange(o,t=>t.childCount>0&&t.firstChild.type==r);if(!i)return!1;let s=i.startIndex;if(0==s)return!1;let a=i.parent,l=a.child(s-1);if(l.type!=r)return!1;if(e){let n=l.lastChild&&l.lastChild.type==a.type,o=k.from(n?r.create():null),s=new A(k.from(r.create(null,k.from(a.type.create(null,o)))),n?3:1,0),c=i.start,d=i.end;e(t.tr.step(new Vt(c-(n?3:1),d,c,d,s,1,!0)).scrollIntoView())}return!0})(e,n);var r};function za(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const o=n.filter(t=>null==e?void 0:e.includes(t.type.name));t.tr.ensureMarks(o)}}var $a=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:o,editor:r})=>{const{selection:i,doc:s}=e,{$from:a,$to:l}=i,c=wa(r.extensionManager.attributes,a.node().type.name,a.node().attrs);if(i instanceof Ce&&i.node.isBlock)return!(!a.parentOffset||!Xt(s,a.pos)||(o&&(t&&za(n,r.extensionManager.splittableMarks),e.split(a.pos).scrollIntoView()),0));if(!a.parent.isBlock)return!1;const d=l.parentOffset===l.parent.content.size,h=0===a.depth?void 0:function(t){for(let e=0;e<t.edgeCount;e+=1){const{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}(a.node(-1).contentMatchAt(a.indexAfter(-1)));let p=d&&h?[{type:h,attrs:c}]:void 0,u=Xt(e.doc,e.mapping.map(a.pos),1,p);if(p||u||!Xt(e.doc,e.mapping.map(a.pos),1,h?[{type:h}]:void 0)||(u=!0,p=h?[{type:h,attrs:c}]:void 0),o){if(u&&(i instanceof xe&&e.deleteSelection(),e.split(e.mapping.map(a.pos),1,p),h&&!d&&!a.parentOffset&&a.parent.type!==h)){const t=e.mapping.map(a.before()),n=e.doc.resolve(t);a.node(-1).canReplaceWith(n.index(),n.index()+1,h)&&e.setNodeMarkup(e.mapping.map(a.before()),h)}t&&za(n,r.extensionManager.splittableMarks),e.scrollIntoView()}return u},Pa=(t,e={})=>({tr:n,state:o,dispatch:r,editor:i})=>{var s;const a=Yi(t,o.schema),{$from:l,$to:c}=o.selection,d=o.selection.node;if(d&&d.isBlock||l.depth<2||!l.sameParent(c))return!1;const h=l.node(-1);if(h.type!==a)return!1;const p=i.extensionManager.attributes;if(0===l.parent.content.size&&l.node(-1).childCount===l.indexAfter(-1)){if(2===l.depth||l.node(-3).type!==a||l.index(-2)!==l.node(-2).childCount-1)return!1;if(r){let t=k.empty;const o=l.index(-1)?1:l.index(-2)?2:3;for(let e=l.depth-o;e>=l.depth-3;e-=1)t=k.from(l.node(e).copy(t));const r=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,i={...wa(p,l.node().type.name,l.node().attrs),...e},c=(null==(s=a.contentMatch.defaultType)?void 0:s.createAndFill(i))||void 0;t=t.append(k.from(a.createAndFill(null,c)||void 0));const d=l.before(l.depth-(o-1));n.replace(d,l.after(-r),new A(t,4-o,0));let h=-1;n.doc.nodesBetween(d,n.doc.content.size,(t,e)=>{if(h>-1)return!1;t.isTextblock&&0===t.content.size&&(h=e+1)}),h>-1&&n.setSelection(xe.near(n.doc.resolve(h))),n.scrollIntoView()}return!0}const u=c.pos===l.end()?h.contentMatchAt(0).defaultType:null,f={...wa(p,h.type.name,h.attrs),...e},m={...wa(p,l.node().type.name,l.node().attrs),...e};n.delete(l.pos,c.pos);const g=u?[{type:a,attrs:f},{type:u,attrs:m}]:[{type:a,attrs:f}];if(!Xt(n.doc,l.pos,2))return!1;if(r){const{selection:t,storedMarks:e}=o,{splittableMarks:s}=i.extensionManager,a=e||t.$to.parentOffset&&t.$from.marks();if(n.split(l.pos,2,g).scrollIntoView(),!a||!r)return!0;const c=a.filter(t=>s.includes(t.type.name));n.ensureMarks(c)}return!0},Ha=(t,e)=>{const n=Zs(t=>t.type===e)(t.selection);if(!n)return!0;const o=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(void 0===o)return!0;const r=t.doc.nodeAt(o);return n.node.type!==(null==r?void 0:r.type)||!Qt(t.doc,n.pos)||(t.join(n.pos),!0)},Ba=(t,e)=>{const n=Zs(t=>t.type===e)(t.selection);if(!n)return!0;const o=t.doc.resolve(n.start).after(n.depth);if(void 0===o)return!0;const r=t.doc.nodeAt(o);return n.node.type!==(null==r?void 0:r.type)||!Qt(t.doc,o)||(t.join(o),!0)},_a=(t,e,n,o={})=>({editor:r,tr:i,state:s,dispatch:a,chain:l,commands:c,can:d})=>{const{extensions:h,splittableMarks:p}=r.extensionManager,u=Yi(t,s.schema),f=Yi(e,s.schema),{selection:m,storedMarks:g}=s,{$from:y,$to:b}=m,v=y.blockRange(b),w=g||m.$to.parentOffset&&m.$from.marks();if(!v)return!1;const k=Zs(t=>Ma(t.type.name,h))(m);if(v.depth>=1&&k&&v.depth-k.depth<=1){if(k.node.type===u)return c.liftListItem(f);if(Ma(k.node.type.name,h)&&u.validContent(k.node.content)&&a)return l().command(()=>(i.setNodeMarkup(k.pos,u),!0)).command(()=>Ha(i,u)).command(()=>Ba(i,u)).run()}return n&&w&&a?l().command(()=>{const t=d().wrapInList(u,o),e=w.filter(t=>p.includes(t.type.name));return i.ensureMarks(e),!!t||c.clearNodes()}).wrapInList(u,o).command(()=>Ha(i,u)).command(()=>Ba(i,u)).run():l().command(()=>!!d().wrapInList(u,o)||c.clearNodes()).wrapInList(u,o).command(()=>Ha(i,u)).command(()=>Ba(i,u)).run()},Va=(t,e={},n={})=>({state:o,commands:r})=>{const{extendEmptyMarkRange:i=!1}=n,s=ls(t,o.schema);return ka(o,s,e)?r.unsetMark(s,{extendEmptyMarkRange:i}):r.setMark(s,e)},Fa=(t,e,n={})=>({state:o,commands:r})=>{const i=Yi(t,o.schema),s=Yi(e,o.schema),a=Rs(o,i,n);let l;return o.selection.$anchor.sameParent(o.selection.$head)&&(l=o.selection.$anchor.parent.attrs),a?r.setNode(s,l):r.setNode(i,{...l,...n})},Wa=(t,e={})=>({state:n,commands:o})=>{const r=Yi(t,n.schema);return Rs(n,r,e)?o.lift(r):o.wrapIn(r,e)},Ka=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let o=0;o<n.length;o+=1){const r=n[o];let i;if(r.spec.isInputRules&&(i=r.getState(t))){if(e){const e=t.tr,n=i.transform;for(let t=n.steps.length-1;t>=0;t-=1)e.step(n.steps[t].invert(n.docs[t]));if(i.text){const n=e.doc.resolve(i.from).marks();e.replaceWith(i.from,i.to,t.schema.text(i.text,n))}else e.delete(i.from,i.to)}return!0}}return!1},qa=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:o,ranges:r}=n;return o||e&&r.forEach(e=>{t.removeMark(e.$from.pos,e.$to.pos)}),!0},Ua=(t,e={})=>({tr:n,state:o,dispatch:r})=>{var i;const{extendEmptyMarkRange:s=!1}=e,{selection:a}=n,l=ls(t,o.schema),{$from:c,empty:d,ranges:h}=a;if(!r)return!0;if(d&&s){let{from:t,to:e}=a;const o=null==(i=c.marks().find(t=>t.type===l))?void 0:i.attrs,r=as(c,l,o);r&&(t=r.from,e=r.to),n.removeMark(t,e,l)}else h.forEach(t=>{n.removeMark(t.$from.pos,t.$to.pos,l)});return n.removeStoredMark(l),!0},Ja=t=>({tr:e,state:n,dispatch:o})=>{const{selection:r}=n;let i,s;return"number"==typeof t?(i=t,s=t):t&&"from"in t&&"to"in t?(i=t.from,s=t.to):(i=r.from,s=r.to),o&&e.doc.nodesBetween(i,s,(t,n)=>{if(t.isText)return;const o={...t.attrs};delete o.dir,e.setNodeMarkup(n,void 0,o)}),!0},Ga=(t,e={})=>({tr:n,state:o,dispatch:r})=>{let i=null,s=null;const a=$s("string"==typeof t?t:t.name,o.schema);if(!a)return!1;"node"===a&&(i=Yi(t,o.schema)),"mark"===a&&(s=ls(t,o.schema));let l=!1;return n.selection.ranges.forEach(t=>{const a=t.$from.pos,c=t.$to.pos;let d,h,p,u;n.selection.empty?o.doc.nodesBetween(a,c,(t,e)=>{i&&i===t.type&&(l=!0,p=Math.max(e,a),u=Math.min(e+t.nodeSize,c),d=e,h=t)}):o.doc.nodesBetween(a,c,(t,o)=>{o<a&&i&&i===t.type&&(l=!0,p=Math.max(o,a),u=Math.min(o+t.nodeSize,c),d=o,h=t),o>=a&&o<=c&&(i&&i===t.type&&(l=!0,r&&n.setNodeMarkup(o,void 0,{...t.attrs,...e})),s&&t.marks.length&&t.marks.forEach(i=>{if(s===i.type&&(l=!0,r)){const r=Math.max(o,a),l=Math.min(o+t.nodeSize,c);n.addMark(r,l,s.create({...i.attrs,...e}))}}))}),h&&(void 0!==d&&r&&n.setNodeMarkup(d,void 0,{...h.attrs,...e}),s&&h.marks.length&&h.marks.forEach(t=>{s===t.type&&r&&n.addMark(p,u,s.create({...t.attrs,...e}))}))}),l},Ya=(t,e={})=>({state:n,dispatch:o})=>function(t,e=null){return function(n,o){let{$from:r,$to:i}=n.selection,s=r.blockRange(i),a=s&&Ut(s,t,e);return!!a&&(o&&o(n.tr.wrap(s,a).scrollIntoView()),!0)}}(Yi(t,n.schema),e)(n,o),Xa=(t,e={})=>({state:n,dispatch:o})=>function(t,e=null){return function(n,o){let{$from:r,$to:i}=n.selection,s=r.blockRange(i);if(!s)return!1;let a=o?n.tr:null;return!!function(t,e,n,o=null){let r=!1,i=e,s=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&0==e.startIndex){if(0==e.$from.index(e.depth-1))return!1;let t=s.resolve(e.start-2);i=new F(t,t,e.depth),e.endIndex<e.parent.childCount&&(e=new F(e.$from,s.resolve(e.$to.end(e.depth)),e.depth)),r=!0}let a=Ut(i,n,o,e);return!!a&&(t&&function(t,e,n,o,r){let i=k.empty;for(let t=n.length-1;t>=0;t--)i=k.from(n[t].type.create(n[t].attrs,i));t.step(new Vt(e.start-(o?2:0),e.end,e.start,e.end,new A(i,0,0),n.length,!0));let s=0;for(let t=0;t<n.length;t++)n[t].type==r&&(s=t+1);let a=n.length-s,l=e.start+n.length-(o?2:0),c=e.parent;for(let n=e.startIndex,o=e.endIndex,r=!0;n<o;n++,r=!1)!r&&Xt(t.doc,l,a)&&(t.split(l,a),l+=2*a),l+=c.child(n).nodeSize}(t,e,a,r,n),!0)}(a,s,t,e)&&(o&&o(a.scrollIntoView()),!0)}}(Yi(t,n.schema),e)(n,o),Qa=class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const n=this.callbacks[t];return n&&n.forEach(t=>t.apply(this,e)),this}off(t,e){const n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter(t=>t!==e):delete this.callbacks[t]),this}once(t,e){const n=(...o)=>{this.off(t,n),e.apply(this,o)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}},Za=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=null==(e=t.undoable)||e}};function tl(t){var e;const{editor:n,from:o,to:r,text:i,rules:s,plugin:a}=t,{view:l}=n;if(l.composing)return!1;const c=l.state.doc.resolve(o);if(c.parent.type.spec.code||(null==(e=c.nodeBefore||c.nodeAfter)?void 0:e.marks.find(t=>t.type.spec.code)))return!1;let d=!1;const h=((t,e=500)=>{let n="";const o=t.parentOffset;return t.parent.nodesBetween(Math.max(0,o-e),o,(t,e,r,i)=>{var s,a;const l=(null==(a=(s=t.type.spec).toText)?void 0:a.call(s,{node:t,pos:e,parent:r,index:i}))||t.textContent||"%leaf%";n+=t.isAtom&&!t.isText?l:l.slice(0,Math.max(0,o-e))}),n})(c)+i;return s.forEach(t=>{if(d)return;const e=((t,e)=>{if(ns(e))return e.exec(t);const n=e(t);if(!n)return null;const o=[n.text];return o.index=n.index,o.input=t,o.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),o.push(n.replaceWith)),o})(h,t.find);if(!e)return;const s=l.state.tr,c=Bi({state:l.state,transaction:s}),p={from:o-(e[0].length-i.length),to:r},{commands:u,chain:f,can:m}=new _i({editor:n,state:c});null!==t.handler({state:c,range:p,match:e,commands:u,chain:f,can:m})&&s.steps.length&&(t.undoable&&s.setMeta(a,{transform:s,from:o,to:r,text:i}),l.dispatch(s),d=!0)}),d}function el(t){return"Object"===function(t){return Object.prototype.toString.call(t).slice(8,-1)}(t)&&t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function nl(t,e){const n={...t};return el(t)&&el(e)&&Object.keys(e).forEach(o=>{el(e[o])&&el(t[o])?n[o]=nl(t[o],e[o]):n[o]=e[o]}),n}var ol=class{constructor(t={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...t},this.name=this.config.name}get options(){return{...ra(ta(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...ra(ta(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>nl(this.options,t)});return e.name=this.name,e.parent=this.parent,e}extend(t={}){const e=new this.constructor({...this.config,...t});return e.parent=this,this.child=e,e.name="name"in t?t.name:e.parent.name,e}},rl=class t extends ol{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n="function"==typeof e?e():e;return new t(n)}static handleExit({editor:t,mark:e}){const{tr:n}=t.state,o=t.state.selection.$from;if(o.pos===o.end()){const r=o.marks();if(!r.find(t=>(null==t?void 0:t.type.name)===e.name))return!1;const i=r.find(t=>(null==t?void 0:t.type.name)===e.name);return i&&n.removeStoredMark(i),n.insertText(" ",o.pos),t.view.dispatch(n),!0}return!1}configure(t){return super.configure(t)}extend(t){const e="function"==typeof t?t():t;return super.extend(e)}},il=class{constructor(t){this.find=t.find,this.handler=t.handler}};var sl=null;function al(t){const{editor:e,rules:n}=t;let o,r=null,i=!1,s=!1,a="undefined"!=typeof ClipboardEvent?new ClipboardEvent("paste"):null;try{o="undefined"!=typeof DragEvent?new DragEvent("drop"):null}catch{o=null}const l=({state:t,from:n,to:r,rule:i,pasteEvt:s})=>{const l=t.tr,c=Bi({state:t,transaction:l});if(function(t){const{editor:e,state:n,from:o,to:r,rule:i,pasteEvent:s,dropEvent:a}=t,{commands:l,chain:c,can:d}=new _i({editor:e,state:n}),h=[];return n.doc.nodesBetween(o,r,(t,e)=>{var p,u,f,m,g;if((null==(u=null==(p=t.type)?void 0:p.spec)?void 0:u.code)||!(t.isText||t.isTextblock||t.isInline))return;const y=null!=(g=null!=(m=null==(f=t.content)?void 0:f.size)?m:t.nodeSize)?g:0,b=Math.max(o,e),v=Math.min(r,e+y);if(b>=v)return;const w=((t,e,n)=>{if(ns(e))return[...t.matchAll(e)];const o=e(t,n);return o?o.map(e=>{const n=[e.text];return n.index=e.index,n.input=t,n.data=e.data,e.replaceWith&&(e.text.includes(e.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),n.push(e.replaceWith)),n}):[]})(t.isText?t.text||"":t.textBetween(b-e,v-e,void 0,""),i.find,s);w.forEach(t=>{if(void 0===t.index)return;const e=b+t.index+1,o=e+t[0].length,r={from:n.tr.mapping.map(e),to:n.tr.mapping.map(o)},p=i.handler({state:n,range:r,match:t,commands:l,chain:c,can:d,pasteEvent:s,dropEvent:a});h.push(p)})}),h.every(t=>null!==t)}({editor:e,state:c,from:Math.max(n-1,0),to:r.b-1,rule:i,pasteEvent:s,dropEvent:o})&&l.steps.length){try{o="undefined"!=typeof DragEvent?new DragEvent("drop"):null}catch{o=null}return a="undefined"!=typeof ClipboardEvent?new ClipboardEvent("paste"):null,l}};return n.map(t=>new $e({view(t){const n=n=>{var o;r=(null==(o=t.dom.parentElement)?void 0:o.contains(n.target))?t.dom.parentElement:null,r&&(sl=e)},o=()=>{sl&&(sl=null)};return window.addEventListener("dragstart",n),window.addEventListener("dragend",o),{destroy(){window.removeEventListener("dragstart",n),window.removeEventListener("dragend",o)}}},props:{handleDOMEvents:{drop:(t,e)=>{if(s=r===t.dom.parentElement,o=e,!s){const t=sl;(null==t?void 0:t.isEditable)&&setTimeout(()=>{const e=t.state.selection;e&&t.commands.deleteRange({from:e.from,to:e.to})},10)}return!1},paste:(t,e)=>{var n;const o=null==(n=e.clipboardData)?void 0:n.getData("text/html");return a=e,i=!!(null==o?void 0:o.includes("data-pm-slice")),!1}}},appendTransaction:(e,n,o)=>{const r=e[0],c="paste"===r.getMeta("uiEvent")&&!i,d="drop"===r.getMeta("uiEvent")&&!s,h=r.getMeta("applyPasteRules"),p=!!h;if(!c&&!d&&!p)return;if(p){let{text:e}=h;"string"==typeof e||(e=na(k.from(e),o.schema));const{from:n}=h,r=n+e.length,i=(t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return null==(e=n.clipboardData)||e.setData("text/html",t),n})(e);return l({rule:t,state:o,from:n,to:{b:r},pasteEvt:i})}const u=n.doc.content.findDiffStart(o.doc.content),f=n.doc.content.findDiffEnd(o.doc.content);return"number"==typeof u&&f&&u!==f.b?l({rule:t,state:o,from:u,to:f,pasteEvt:a}):void 0}}))}var ll=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=ua(t),this.schema=function(t,e){var n;const o=sa(t),{nodeExtensions:r,markExtensions:i}=ia(t),s=null==(n=r.find(t=>ta(t,"topNode")))?void 0:n.name,a=Object.fromEntries(r.map(n=>{const r=o.filter(t=>t.type===n.name),i={name:n.name,options:n.options,storage:n.storage,editor:e},s=da({...t.reduce((t,e)=>{const o=ta(e,"extendNodeSchema",i);return{...t,...o?o(n):{}}},{}),content:ra(ta(n,"content",i)),marks:ra(ta(n,"marks",i)),group:ra(ta(n,"group",i)),inline:ra(ta(n,"inline",i)),atom:ra(ta(n,"atom",i)),selectable:ra(ta(n,"selectable",i)),draggable:ra(ta(n,"draggable",i)),code:ra(ta(n,"code",i)),whitespace:ra(ta(n,"whitespace",i)),linebreakReplacement:ra(ta(n,"linebreakReplacement",i)),defining:ra(ta(n,"defining",i)),isolating:ra(ta(n,"isolating",i)),attrs:Object.fromEntries(r.map(ha))}),a=ra(ta(n,"parseHTML",i));a&&(s.parseDOM=a.map(t=>ca(t,r)));const l=ta(n,"renderHTML",i);l&&(s.toDOM=t=>l({node:t,HTMLAttributes:la(t,r)}));const c=ta(n,"renderText",i);return c&&(s.toText=c),[n.name,s]})),l=Object.fromEntries(i.map(n=>{const r=o.filter(t=>t.type===n.name),i={name:n.name,options:n.options,storage:n.storage,editor:e},s=da({...t.reduce((t,e)=>{const o=ta(e,"extendMarkSchema",i);return{...t,...o?o(n):{}}},{}),inclusive:ra(ta(n,"inclusive",i)),excludes:ra(ta(n,"excludes",i)),group:ra(ta(n,"group",i)),spanning:ra(ta(n,"spanning",i)),code:ra(ta(n,"code",i)),attrs:Object.fromEntries(r.map(ha))}),a=ra(ta(n,"parseHTML",i));a&&(s.parseDOM=a.map(t=>ca(t,r)));const l=ta(n,"renderHTML",i);return l&&(s.toDOM=t=>l({mark:t,HTMLAttributes:la(t,r)})),[n.name,s]}));return new dt({topNode:s,nodes:a,marks:l})}(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((t,e)=>{const n=ta(e,"addCommands",{name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:va(e.name,this.schema)});return n?{...t,...n()}:t},{})}get plugins(){const{editor:t}=this,e=pa([...this.extensions].reverse()).flatMap(e=>{const n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:t,type:va(e.name,this.schema)},o=[],r=ta(e,"addKeyboardShortcuts",n);let i={};if("mark"===e.type&&ta(e,"exitable",n)&&(i.ArrowRight=()=>rl.handleExit({editor:t,mark:e})),r){const e=Object.fromEntries(Object.entries(r()).map(([e,n])=>[e,()=>n({editor:t})]));i={...i,...e}}const s=new $e({props:{handleKeyDown:$i(i)}});o.push(s);const a=ta(e,"addInputRules",n);if(xa(e,t.options.enableInputRules)&&a){const e=a();if(e&&e.length){const n=function(t){const{editor:e,rules:n}=t,o=new $e({state:{init:()=>null,apply(t,r,i){const s=t.getMeta(o);if(s)return s;const a=t.getMeta("applyInputRules");return!!a&&setTimeout(()=>{let{text:t}=a;"string"==typeof t||(t=na(k.from(t),i.schema));const{from:r}=a,s=r+t.length;tl({editor:e,from:r,to:s,text:t,rules:n,plugin:o})}),t.selectionSet||t.docChanged?null:r}},props:{handleTextInput:(t,r,i,s)=>tl({editor:e,from:r,to:i,text:s,rules:n,plugin:o}),handleDOMEvents:{compositionend:t=>(setTimeout(()=>{const{$cursor:r}=t.state.selection;r&&tl({editor:e,from:r.pos,to:r.pos,text:"",rules:n,plugin:o})}),!1)},handleKeyDown(t,r){if("Enter"!==r.key)return!1;const{$cursor:i}=t.state.selection;return!!i&&tl({editor:e,from:i.pos,to:i.pos,text:"\n",rules:n,plugin:o})}},isInputRules:!0});return o}({editor:t,rules:e}),r=Array.isArray(n)?n:[n];o.push(...r)}}const l=ta(e,"addPasteRules",n);if(xa(e,t.options.enablePasteRules)&&l){const e=l();if(e&&e.length){const n=al({editor:t,rules:e});o.push(...n)}}const c=ta(e,"addProseMirrorPlugins",n);if(c){const t=c();o.push(...t)}return o});return e}get attributes(){return sa(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=ia(this.extensions);return Object.fromEntries(e.filter(t=>!!ta(t,"addNodeView")).map(e=>{const n=this.attributes.filter(t=>t.type===e.name),o={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:t,type:Yi(e.name,this.schema)},r=ta(e,"addNodeView",o);if(!r)return[];const i=r();return i?[e.name,(o,r,s,a,l)=>{const c=la(o,n);return i({node:o,view:r,getPos:s,decorations:a,innerDecorations:l,editor:t,extension:e,HTMLAttributes:c})}]:[]}))}get markViews(){const{editor:t}=this,{markExtensions:e}=ia(this.extensions);return Object.fromEntries(e.filter(t=>!!ta(t,"addMarkView")).map(e=>{const n=this.attributes.filter(t=>t.type===e.name),o={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:t,type:ls(e.name,this.schema)},r=ta(e,"addMarkView",o);return r?[e.name,(o,i,s)=>{const a=la(o,n);return r()({mark:o,view:i,inline:s,editor:t,extension:e,HTMLAttributes:a,updateAttributes:e=>{!function(t,e,n={}){const{state:o}=e,{doc:r,tr:i}=o,s=t;r.descendants((e,o)=>{const r=i.mapping.map(o),a=i.mapping.map(o)+e.nodeSize;let l=null;if(e.marks.forEach(t=>{if(t!==s)return!1;l=t}),!l)return;let c=!1;if(Object.keys(n).forEach(t=>{n[t]!==l.attrs[t]&&(c=!0)}),c){const e=t.type.create({...t.attrs,...n});i.removeMark(r,a,t.type),i.addMark(r,a,e)}}),i.docChanged&&e.view.dispatch(i)}(o,t,e)}})}]:[]}))}setupExtensions(){const t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(t=>[t.name,t.storage])),t.forEach(t=>{var e;const n={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:this.editor,type:va(t.name,this.schema)};"mark"===t.type&&(null==(e=ra(ta(t,"keepOnSplit",n)))||e)&&this.splittableMarks.push(t.name);const o=ta(t,"onBeforeCreate",n),r=ta(t,"onCreate",n),i=ta(t,"onUpdate",n),s=ta(t,"onSelectionUpdate",n),a=ta(t,"onTransaction",n),l=ta(t,"onFocus",n),c=ta(t,"onBlur",n),d=ta(t,"onDestroy",n);o&&this.editor.on("beforeCreate",o),r&&this.editor.on("create",r),i&&this.editor.on("update",i),s&&this.editor.on("selectionUpdate",s),a&&this.editor.on("transaction",a),l&&this.editor.on("focus",l),c&&this.editor.on("blur",c),d&&this.editor.on("destroy",d)})}};ll.resolve=ua,ll.sort=pa,ll.flatten=ea,Hi({},{ClipboardTextSerializer:()=>dl,Commands:()=>hl,Delete:()=>pl,Drop:()=>ul,Editable:()=>fl,FocusEvents:()=>gl,Keymap:()=>yl,Paste:()=>bl,Tabindex:()=>vl,TextDirection:()=>wl,focusEventsPluginKey:()=>ml});var cl=class t extends ol{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n="function"==typeof e?e():e;return new t(n)}configure(t){return super.configure(t)}extend(t){const e="function"==typeof t?t():t;return super.extend(e)}},dl=cl.create({name:"clipboardTextSerializer",addOptions:()=>({blockSeparator:void 0}),addProseMirrorPlugins(){return[new $e({key:new Be("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:o,selection:r}=e,{ranges:i}=r,s=Math.min(...i.map(t=>t.$from.pos)),a=Math.max(...i.map(t=>t.$to.pos)),l=ma(n);return fa(o,{from:s,to:a},{...void 0!==this.options.blockSeparator?{blockSeparator:this.options.blockSeparator}:{},textSerializers:l})}}})]}}),hl=cl.create({name:"commands",addCommands:()=>({...Vi})}),pl=cl.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,o,r;const i=()=>{var n,o,r,i;if(null!=(i=null==(r=null==(o=null==(n=this.editor.options.coreExtensionOptions)?void 0:n.delete)?void 0:o.filterTransaction)?void 0:r.call(o,t))?i:t.getMeta("y-sync$"))return;const s=Ys(t.before,[t,...e]);ya(s).forEach(e=>{s.mapping.mapResult(e.oldRange.from).deletedAfter&&s.mapping.mapResult(e.oldRange.to).deletedBefore&&s.before.nodesBetween(e.oldRange.from,e.oldRange.to,(n,o)=>{const r=o+n.nodeSize-2,i=e.oldRange.from<=o&&r<=e.oldRange.to;this.editor.emit("delete",{type:"node",node:n,from:o,to:r,newFrom:s.mapping.map(o),newTo:s.mapping.map(r),deletedRange:e.oldRange,newRange:e.newRange,partial:!i,editor:this.editor,transaction:t,combinedTransform:s})})});const a=s.mapping;s.steps.forEach((e,n)=>{var o,r;if(e instanceof Pt){const i=a.slice(n).map(e.from,-1),l=a.slice(n).map(e.to),c=a.invert().map(i,-1),d=a.invert().map(l),h=null==(o=s.doc.nodeAt(i-1))?void 0:o.marks.some(t=>t.eq(e.mark)),p=null==(r=s.doc.nodeAt(l))?void 0:r.marks.some(t=>t.eq(e.mark));this.editor.emit("delete",{type:"mark",mark:e.mark,from:e.from,to:e.to,deletedRange:{from:c,to:d},newRange:{from:i,to:l},partial:Boolean(p||h),editor:this.editor,transaction:t,combinedTransform:s})}})};null==(r=null==(o=null==(n=this.editor.options.coreExtensionOptions)?void 0:n.delete)?void 0:o.async)||r?setTimeout(i,0):i()}}),ul=cl.create({name:"drop",addProseMirrorPlugins(){return[new $e({key:new Be("tiptapDrop"),props:{handleDrop:(t,e,n,o)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:o})}}})]}}),fl=cl.create({name:"editable",addProseMirrorPlugins(){return[new $e({key:new Be("editable"),props:{editable:()=>this.editor.options.editable}})]}}),ml=new Be("focusEvents"),gl=cl.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new $e({key:ml,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const o=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(o),!1},blur:(e,n)=>{t.isFocused=!1;const o=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(o),!1}}}})]}}),yl=cl.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:t})=>[()=>t.undoInputRule(),()=>t.command(({tr:e})=>{const{selection:n,doc:o}=e,{empty:r,$anchor:i}=n,{pos:s,parent:a}=i,l=i.parent.isTextblock&&s>0?e.doc.resolve(s-1):i,c=l.parent.type.spec.isolating,d=i.pos-i.parentOffset,h=c&&1===l.parent.childCount?d===i.pos:be.atStart(o).from===s;return!(!r||!a.type.isTextblock||a.textContent.length||!h||h&&"paragraph"===i.parent.type.name)&&t.clearNodes()}),()=>t.deleteSelection(),()=>t.joinBackward(),()=>t.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:t})=>[()=>t.deleteSelection(),()=>t.deleteCurrentNode(),()=>t.joinForward(),()=>t.selectNodeForward()]),n={Enter:()=>this.editor.commands.first(({commands:t})=>[()=>t.newlineInCode(),()=>t.createParagraphNear(),()=>t.liftEmptyBlock(),()=>t.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},o={...n},r={...n,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return fs()||Os()?r:o},addProseMirrorPlugins(){return[new $e({key:new Be("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(t=>t.getMeta("composition")))return;const o=t.some(t=>t.docChanged)&&!e.doc.eq(n.doc),r=t.some(t=>t.getMeta("preventClearDocument"));if(!o||r)return;const{empty:i,from:s,to:a}=e.selection,l=be.atStart(e.doc).from,c=be.atEnd(e.doc).to;if(i||s!==l||a!==c)return;if(!Ca(n.doc))return;const d=n.tr,h=Bi({state:n,transaction:d}),{commands:p}=new _i({editor:this.editor,state:h});return p.clearNodes(),d.steps.length?d:void 0}})]}}),bl=cl.create({name:"paste",addProseMirrorPlugins(){return[new $e({key:new Be("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),vl=cl.create({name:"tabindex",addProseMirrorPlugins(){return[new $e({key:new Be("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),wl=cl.create({name:"textDirection",addOptions:()=>({direction:void 0}),addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=ia(this.extensions);return[{types:t.filter(t=>"text"!==t.name).map(t=>t.name),attributes:{dir:{default:this.options.direction,parseHTML:t=>{const e=t.getAttribute("dir");return!e||"ltr"!==e&&"rtl"!==e&&"auto"!==e?this.options.direction:e},renderHTML:t=>t.dir?{dir:t.dir}:{}}}}]},addProseMirrorPlugins(){return[new $e({key:new Be("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),kl=class t{constructor(t,e,n=!1,o=null){this.currentNode=null,this.actualDepth=null,this.isBlock=n,this.resolvedPos=t,this.editor=e,this.currentNode=o}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var t;return null!=(t=this.actualDepth)?t:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(t){let e=this.from,n=this.to;if(this.isBlock){if(0===this.content.size)return void console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);e=this.from+1,n=this.to-1}this.editor.commands.insertContentAt({from:e,to:n},t)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(0===this.depth)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new t(n,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new t(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new t(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,o)=>{const r=n.isBlock&&!n.isTextblock,i=n.isAtom&&!n.isText,s=this.pos+o+(i?0:1);if(s<0||s>this.resolvedPos.doc.nodeSize-2)return;const a=this.resolvedPos.doc.resolve(s);if(!r&&a.depth<=this.depth)return;const l=new t(a,this.editor,r,r?n:null);r&&(l.actualDepth=this.depth+1),e.push(new t(a,this.editor,r,r?n:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const t=this.children;return t[t.length-1]||null}closest(t,e={}){let n=null,o=this.parent;for(;o&&!n;){if(o.node.type.name===t)if(Object.keys(e).length>0){const t=o.node.attrs,n=Object.keys(e);for(let o=0;o<n.length;o+=1){const r=n[o];if(t[r]!==e[r])break}}else n=o;o=o.parent}return n}querySelector(t,e={}){return this.querySelectorAll(t,e,!0)[0]||null}querySelectorAll(t,e={},n=!1){let o=[];if(!this.children||0===this.children.length)return o;const r=Object.keys(e);return this.children.forEach(i=>{n&&o.length>0||(i.node.type.name===t&&r.every(t=>e[t]===i.node.attrs[t])&&o.push(i),n&&o.length>0||(o=o.concat(i.querySelectorAll(t,e,n))))}),o}setAttribute(t){const{tr:e}=this.editor.state;e.setNodeMarkup(this.from,void 0,{...this.node.attrs,...t}),this.editor.view.dispatch(e)}},xl=class extends Qa{constructor(t={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:"undefined"!=typeof document?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:t})=>{throw t},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:Aa,createMappablePosition:Ea},this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:t,slice:e,moved:n})=>this.options.onDrop(t,e,n)),this.on("paste",({event:t,slice:e})=>this.options.onPaste(t,e)),this.on("delete",this.options.onDelete);const e=this.createDoc(),n=us(e,this.options.autofocus);this.editorState=Ie.create({doc:e,schema:this.schema,selection:n||void 0}),this.options.element&&this.mount(this.options.element)}mount(t){if("undefined"==typeof document)throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(t),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(!1!==this.options.autofocus&&null!==this.options.autofocus&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){const t=this.editorView.dom;(null==t?void 0:t.editor)&&delete t.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{"function"==typeof this.css.remove?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(t){console.warn("Failed to remove CSS element:",t)}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&"undefined"!=typeof document&&(this.css=function(t,e){const n=document.querySelector("style[data-tiptap-style]");if(null!==n)return n;const o=document.createElement("style");return e&&o.setAttribute("nonce",e),o.setAttribute("data-tiptap-style",""),o.innerHTML='.ProseMirror {\n position: relative;\n}\n\n.ProseMirror {\n word-wrap: break-word;\n white-space: pre-wrap;\n white-space: break-spaces;\n -webkit-font-variant-ligatures: none;\n font-variant-ligatures: none;\n font-feature-settings: "liga" 0; /* the above doesn\'t seem to work in Edge */\n}\n\n.ProseMirror [contenteditable="false"] {\n white-space: normal;\n}\n\n.ProseMirror [contenteditable="false"] [contenteditable="true"] {\n white-space: pre-wrap;\n}\n\n.ProseMirror pre {\n white-space: pre-wrap;\n}\n\nimg.ProseMirror-separator {\n display: inline !important;\n border: none !important;\n margin: 0 !important;\n width: 0 !important;\n height: 0 !important;\n}\n\n.ProseMirror-gapcursor {\n display: none;\n pointer-events: none;\n position: absolute;\n margin: 0;\n}\n\n.ProseMirror-gapcursor:after {\n content: "";\n display: block;\n position: absolute;\n top: -2px;\n width: 20px;\n border-top: 1px solid black;\n animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;\n}\n\n@keyframes ProseMirror-cursor-blink {\n to {\n visibility: hidden;\n }\n}\n\n.ProseMirror-hideselection *::selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection *::-moz-selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection * {\n caret-color: transparent;\n}\n\n.ProseMirror-focused .ProseMirror-gapcursor {\n display: block;\n}',document.getElementsByTagName("head")[0].appendChild(o),o}(0,this.options.injectNonce))}setOptions(t={}){this.options={...this.options,...t},this.editorView&&this.state&&!this.isDestroyed&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(t,e=!0){this.setOptions({editable:t}),e&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:t=>{this.editorState=t},dispatch:t=>{this.dispatchTransaction(t)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(t,e)=>{if(this.editorView)return this.editorView[e];if("state"===e)return this.editorState;if(e in t)return Reflect.get(t,e);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${e}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(t,e){const n=oa(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],o=this.state.reconfigure({plugins:n});return this.view.updateState(o),o}unregisterPlugin(t){if(this.isDestroyed)return;const e=this.state.plugins;let n=e;if([].concat(t).forEach(t=>{const e="string"==typeof t?`${t}$`:t.key;n=n.filter(t=>!t.key.startsWith(e))}),e.length===n.length)return;const o=this.state.reconfigure({plugins:n});return this.view.updateState(o),o}createExtensionManager(){var t,e;const n=[...this.options.enableCoreExtensions?[fl,dl.configure({blockSeparator:null==(e=null==(t=this.options.coreExtensionOptions)?void 0:t.clipboardTextSerializer)?void 0:e.blockSeparator}),hl,gl,yl,vl,ul,bl,pl,wl.configure({direction:this.options.textDirection})].filter(t=>"object"!=typeof this.options.enableCoreExtensions||!1!==this.options.enableCoreExtensions[t.name]):[],...this.options.extensions].filter(t=>["extension","node","mark"].includes(null==t?void 0:t.type));this.extensionManager=new ll(n,this)}createCommandManager(){this.commandManager=new _i({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=Us(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error&&["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message)))throw e;this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{"collaboration"in this.storage&&"object"==typeof this.storage.collaboration&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(t=>"collaboration"!==t.name),this.createExtensionManager()}}),t=Us(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){var e;this.editorView=new ki(t,{...this.options.editorProps,attributes:{role:"textbox",...null==(e=this.options.editorProps)?void 0:e.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const n=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(n),this.prependClass(),this.injectCSS(),this.view.dom.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction)return this.capturedTransaction?void t.steps.forEach(t=>{var e;return null==(e=this.capturedTransaction)?void 0:e.step(t)}):void(this.capturedTransaction=t);const{state:e,transactions:n}=this.state.applyTransaction(t),o=!this.state.selection.eq(e.selection),r=n.includes(t),i=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!r)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),o&&this.emit("selectionUpdate",{editor:this,transaction:t});const s=n.findLast(t=>t.getMeta("focus")||t.getMeta("blur")),a=null==s?void 0:s.getMeta("focus"),l=null==s?void 0:s.getMeta("blur");a&&this.emit("focus",{editor:this,event:a.event,transaction:s}),l&&this.emit("blur",{editor:this,event:l.event,transaction:s}),t.getMeta("preventUpdate")||!n.some(t=>t.docChanged)||i.doc.eq(e.doc)||this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return ga(this.state,t)}isActive(t,e){const n="string"==typeof t?t:null,o="string"==typeof t?e:t;return function(t,e,n={}){if(!e)return Rs(t,null,n)||ka(t,null,n);const o=$s(e,t.schema);return"node"===o?Rs(t,e,n):"mark"===o&&ka(t,e,n)}(this.state,n,o)}getJSON(){return this.state.doc.toJSON()}getHTML(){return na(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e="\n\n",textSerializers:n={}}=t||{};return function(t,e){return fa(t,{from:0,to:t.content.size},e)}(this.state.doc,{blockSeparator:e,textSerializers:{...ma(this.schema),...n}})}get isEmpty(){return Ca(this.state.doc)}destroy(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}get isDestroyed(){var t,e;return null==(e=null==(t=this.editorView)?void 0:t.isDestroyed)||e}$node(t,e){var n;return(null==(n=this.$doc)?void 0:n.querySelector(t,e))||null}$nodes(t,e){var n;return(null==(n=this.$doc)?void 0:n.querySelectorAll(t,e))||null}$pos(t){const e=this.state.doc.resolve(t);return new kl(e,this)}get $doc(){return this.$pos(0)}};function Ml(t){return new Za({find:t.find,handler:({state:e,range:n,match:o})=>{const r=ra(t.getAttributes,void 0,o);if(!1===r||null===r)return null;const{tr:i}=e,s=o[o.length-1],a=o[0];if(s){const o=a.search(/\S/),l=n.from+a.indexOf(s),c=l+s.length;if(ba(n.from,n.to,e.doc).filter(e=>e.mark.type.excluded.find(n=>n===t.type&&n!==e.mark.type)).filter(t=>t.to>l).length)return null;c<n.to&&i.delete(c,n.to),l>n.from&&i.delete(n.from+o,l);const d=n.from+o+s.length;i.addMark(n.from+o,d,t.type.create(r||{})),i.removeStoredMark(t.type)}},undoable:t.undoable})}function Cl(t){return new Za({find:t.find,handler:({state:e,range:n,match:o})=>{const r=ra(t.getAttributes,void 0,o)||{},{tr:i}=e,s=n.from;let a=n.to;const l=t.type.create(r);if(o[1]){let t=s+o[0].lastIndexOf(o[1]);t>a?t=a:a=t+o[1].length;const e=o[0][o[0].length-1];i.insertText(e,s+o[0].length-1),i.replaceWith(t,a,l)}else if(o[0]){const e=t.type.isInline?s:s-1;i.insert(e,t.type.create(r)).delete(i.mapping.map(s),i.mapping.map(a))}i.scrollIntoView()},undoable:t.undoable})}function Sl(t){return new Za({find:t.find,handler:({state:e,range:n,match:o})=>{const r=e.doc.resolve(n.from),i=ra(t.getAttributes,void 0,o)||{};if(!r.node(-1).canReplaceWith(r.index(-1),r.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,i)},undoable:t.undoable})}function Tl(t){return new Za({find:t.find,handler:({state:e,range:n,match:o,chain:r})=>{const i=ra(t.getAttributes,void 0,o)||{},s=e.tr.delete(n.from,n.to),a=s.doc.resolve(n.from).blockRange(),l=a&&Ut(a,t.type,i);if(!l)return null;if(s.wrap(a,l),t.keepMarks&&t.editor){const{selection:n,storedMarks:o}=e,{splittableMarks:r}=t.editor.extensionManager,i=o||n.$to.parentOffset&&n.$from.marks();if(i){const t=i.filter(t=>r.includes(t.type.name));s.ensureMarks(t)}}if(t.keepAttributes){const e="bulletList"===t.type.name||"orderedList"===t.type.name?"listItem":"taskList";r().updateAttributes(e,i).run()}const c=s.doc.resolve(n.from-1).nodeBefore;c&&c.type===t.type&&Qt(s.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(o,c))&&s.join(n.from-1)},undoable:t.undoable})}var Al=class{constructor(t){var e,n,o,r,i,s;this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.lastEditableState=void 0,this.handleMap=new Map,this.handleMouseMove=t=>{if(!this.isResizing||!this.activeHandle)return;const e=t.clientX-this.startX,n=t.clientY-this.startY;this.handleResize(e,n)},this.handleTouchMove=t=>{if(!this.isResizing||!this.activeHandle)return;const e=t.touches[0];if(!e)return;const n=e.clientX-this.startX,o=e.clientY-this.startY;this.handleResize(n,o)},this.handleMouseUp=()=>{if(!this.isResizing)return;const t=this.element.offsetWidth,e=this.element.offsetHeight;this.onCommit(t,e),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)},this.handleKeyDown=t=>{"Shift"===t.key&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=t=>{"Shift"===t.key&&(this.isShiftKeyPressed=!1)},this.node=t.node,this.editor=t.editor,this.element=t.element,this.contentElement=t.contentElement,this.getPos=t.getPos,this.onResize=t.onResize,this.onCommit=t.onCommit,this.onUpdate=t.onUpdate,(null==(e=t.options)?void 0:e.min)&&(this.minSize={...this.minSize,...t.options.min}),(null==(n=t.options)?void 0:n.max)&&(this.maxSize=t.options.max),(null==(o=null==t?void 0:t.options)?void 0:o.directions)&&(this.directions=t.options.directions),(null==(r=t.options)?void 0:r.preserveAspectRatio)&&(this.preserveAspectRatio=t.options.preserveAspectRatio),(null==(i=t.options)?void 0:i.className)&&(this.classNames={container:t.options.className.container||"",wrapper:t.options.className.wrapper||"",handle:t.options.className.handle||"",resizing:t.options.className.resizing||""}),(null==(s=t.options)?void 0:s.createCustomHandle)&&(this.createCustomHandle=t.options.createCustomHandle),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles(),this.editor.on("update",this.handleEditorUpdate.bind(this))}get dom(){return this.container}get contentDOM(){return this.contentElement}handleEditorUpdate(){const t=this.editor.isEditable;t!==this.lastEditableState&&(this.lastEditableState=t,t?t&&0===this.handleMap.size&&this.attachHandles():this.removeHandles())}update(t,e,n){return t.type===this.node.type&&(this.node=t,!this.onUpdate||this.onUpdate(t,e,n))}destroy(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.editor.off("update",this.handleEditorUpdate.bind(this)),this.container.remove()}createContainer(){const t=document.createElement("div");return t.dataset.resizeContainer="",t.dataset.node=this.node.type.name,t.style.display="flex",this.classNames.container&&(t.className=this.classNames.container),t.appendChild(this.wrapper),t}createWrapper(){const t=document.createElement("div");return t.style.position="relative",t.style.display="block",t.dataset.resizeWrapper="",this.classNames.wrapper&&(t.className=this.classNames.wrapper),t.appendChild(this.element),t}createHandle(t){const e=document.createElement("div");return e.dataset.resizeHandle=t,e.style.position="absolute",this.classNames.handle&&(e.className=this.classNames.handle),e}positionHandle(t,e){const n=e.includes("top"),o=e.includes("bottom"),r=e.includes("left"),i=e.includes("right");n&&(t.style.top="0"),o&&(t.style.bottom="0"),r&&(t.style.left="0"),i&&(t.style.right="0"),"top"!==e&&"bottom"!==e||(t.style.left="0",t.style.right="0"),"left"!==e&&"right"!==e||(t.style.top="0",t.style.bottom="0")}attachHandles(){this.directions.forEach(t=>{let e;e=this.createCustomHandle?this.createCustomHandle(t):this.createHandle(t),e instanceof HTMLElement||(console.warn(`[ResizableNodeView] createCustomHandle("${t}") did not return an HTMLElement. Falling back to default handle.`),e=this.createHandle(t)),this.createCustomHandle||this.positionHandle(e,t),e.addEventListener("mousedown",e=>this.handleResizeStart(e,t)),e.addEventListener("touchstart",e=>this.handleResizeStart(e,t)),this.handleMap.set(t,e),this.wrapper.appendChild(e)})}removeHandles(){this.handleMap.forEach(t=>t.remove()),this.handleMap.clear()}applyInitialSize(){const t=this.node.attrs.width,e=this.node.attrs.height;t?(this.element.style.width=`${t}px`,this.initialWidth=t):this.initialWidth=this.element.offsetWidth,e?(this.element.style.height=`${e}px`,this.initialHeight=e):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(t,e){t.preventDefault(),t.stopPropagation(),this.isResizing=!0,this.activeHandle=e,"touches"in t?(this.startX=t.touches[0].clientX,this.startY=t.touches[0].clientY):(this.startX=t.clientX,this.startY=t.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}handleResize(t,e){if(!this.activeHandle)return;const n=this.preserveAspectRatio||this.isShiftKeyPressed,{width:o,height:r}=this.calculateNewDimensions(this.activeHandle,t,e),i=this.applyConstraints(o,r,n);this.element.style.width=`${i.width}px`,this.element.style.height=`${i.height}px`,this.onResize&&this.onResize(i.width,i.height)}calculateNewDimensions(t,e,n){let o=this.startWidth,r=this.startHeight;const i=t.includes("right"),s=t.includes("left"),a=t.includes("bottom"),l=t.includes("top");return i?o=this.startWidth+e:s&&(o=this.startWidth-e),a?r=this.startHeight+n:l&&(r=this.startHeight-n),"right"!==t&&"left"!==t||(o=this.startWidth+(i?e:-e)),"top"!==t&&"bottom"!==t||(r=this.startHeight+(a?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(o,r,t):{width:o,height:r}}applyConstraints(t,e,n){var o,r,i,s;if(!n){let n=Math.max(this.minSize.width,t),i=Math.max(this.minSize.height,e);return(null==(o=this.maxSize)?void 0:o.width)&&(n=Math.min(this.maxSize.width,n)),(null==(r=this.maxSize)?void 0:r.height)&&(i=Math.min(this.maxSize.height,i)),{width:n,height:i}}let a=t,l=e;return a<this.minSize.width&&(a=this.minSize.width,l=a/this.aspectRatio),l<this.minSize.height&&(l=this.minSize.height,a=l*this.aspectRatio),(null==(i=this.maxSize)?void 0:i.width)&&a>this.maxSize.width&&(a=this.maxSize.width,l=a/this.aspectRatio),(null==(s=this.maxSize)?void 0:s.height)&&l>this.maxSize.height&&(l=this.maxSize.height,a=l*this.aspectRatio),{width:a,height:l}}applyAspectRatio(t,e,n){const o="top"===n||"bottom"===n;return"left"===n||"right"===n?{width:t,height:t/this.aspectRatio}:o?{width:e*this.aspectRatio,height:e}:{width:t,height:t/this.aspectRatio}}};function El(t){if(!(null==t?void 0:t.trim()))return{};const e={},n=[],o=t.replace(/["']([^"']*)["']/g,t=>(n.push(t),`__QUOTED_${n.length-1}__`)),r=o.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(r){const t=r.map(t=>t.trim().slice(1));e.class=t.join(" ")}const i=o.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);i&&(e.id=i[1]),Array.from(o.matchAll(/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g)).forEach(([,t,o])=>{var r;const i=parseInt((null==(r=o.match(/__QUOTED_(\d+)__/))?void 0:r[1])||"0",10),s=n[i];s&&(e[t]=s.slice(1,-1))});const s=o.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return s&&s.split(/\s+/).filter(Boolean).forEach(t=>{t.match(/^[a-zA-Z][\w-]*$/)&&(e[t]=!0)}),e}function Nl(t){if(!t||0===Object.keys(t).length)return"";const e=[];return t.class&&String(t.class).split(/\s+/).filter(Boolean).forEach(t=>e.push(`.${t}`)),t.id&&e.push(`#${t.id}`),Object.entries(t).forEach(([t,n])=>{"class"!==t&&"id"!==t&&(!0===n?e.push(t):!1!==n&&null!=n&&e.push(`${t}="${String(n)}"`))}),e.join(" ")}function Ol(t){const{nodeName:e,name:n,parseAttributes:o=El,serializeAttributes:r=Nl,defaultAttributes:i={},requiredAttributes:s=[],allowedAttributes:a}=t,l=n||e;return{parseMarkdown:(t,n)=>{const o={...i,...t.attributes};return n.createNode(e,o,[])},markdownTokenizer:{name:e,level:"block",start(t){var e;const n=new RegExp(`^:::${l}(?:\\s|$)`,"m"),o=null==(e=t.match(n))?void 0:e.index;return void 0!==o?o:-1},tokenize(t,n,r){const i=new RegExp(`^:::${l}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),a=t.match(i);if(!a)return;const c=a[1]||"",d=o(c);return s.find(t=>!(t in d))?void 0:{type:e,raw:a[0],attributes:d}}},renderMarkdown:t=>{const e=(t=>{if(!a)return t;const e={};return a.forEach(n=>{n in t&&(e[n]=t[n])}),e})(t.attrs||{}),n=r(e);return`:::${l}${n?` {${n}}`:""} :::`}}}function Ll(t){const{nodeName:e,name:n,getContent:o,parseAttributes:r=El,serializeAttributes:i=Nl,defaultAttributes:s={},content:a="block",allowedAttributes:l}=t,c=n||e;return{parseMarkdown:(t,n)=>{let r;if(o){const e=o(t);r="string"==typeof e?[{type:"text",text:e}]:e}else r="block"===a?n.parseChildren(t.tokens||[]):n.parseInline(t.tokens||[]);const i={...s,...t.attributes};return n.createNode(e,i,r)},markdownTokenizer:{name:e,level:"block",start(t){var e;const n=new RegExp(`^:::${c}`,"m"),o=null==(e=t.match(n))?void 0:e.index;return void 0!==o?o:-1},tokenize(t,n,o){var i;const s=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),l=t.match(s);if(!l)return;const[d,h=""]=l,p=r(h);let u=1;const f=d.length;let m="";const g=/^:::([\w-]*)(\s.*)?/gm,y=t.slice(f);for(g.lastIndex=0;;){const n=g.exec(y);if(null===n)break;const r=n.index,s=n[1];if(!(null==(i=n[2])?void 0:i.endsWith(":::")))if(s)u+=1;else if(u-=1,0===u){const i=y.slice(0,r);m=i.trim();const s=t.slice(0,f+r+n[0].length);let l=[];if(m)if("block"===a)for(l=o.blockTokens(i),l.forEach(t=>{!t.text||t.tokens&&0!==t.tokens.length||(t.tokens=o.inlineTokens(t.text))});l.length>0;){const t=l[l.length-1];if("paragraph"!==t.type||t.text&&""!==t.text.trim())break;l.pop()}else l=o.inlineTokens(m);return{type:e,raw:s,attributes:p,content:m,tokens:l}}}}},renderMarkdown:(t,e)=>{const n=(t=>{if(!l)return t;const e={};return l.forEach(n=>{n in t&&(e[n]=t[n])}),e})(t.attrs||{}),o=i(n),r=o?` {${o}}`:"",s=e.renderChildren(t.content||[],"\n\n");return`:::${c}${r}\n\n${s}\n\n:::`}}}function Rl(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let o=n.exec(t);for(;null!==o;){const[,r,i,s]=o;e[r]=i||s,o=n.exec(t)}return e}function Dl(t){return Object.entries(t).filter(([,t])=>null!=t).map(([t,e])=>`${t}="${e}"`).join(" ")}function jl(t){const{nodeName:e,name:n,getContent:o,parseAttributes:r=Rl,serializeAttributes:i=Dl,defaultAttributes:s={},selfClosing:a=!1,allowedAttributes:l}=t,c=n||e,d=c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(t,n)=>{const r={...s,...t.attributes};if(a)return n.createNode(e,r);const i=o?o(t):t.content||"";return i?n.createNode(e,r,[n.createTextNode(i)]):n.createNode(e,r,[])},markdownTokenizer:{name:e,level:"inline",start(t){const e=a?new RegExp(`\\[${d}\\s*[^\\]]*\\]`):new RegExp(`\\[${d}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${d}\\]`),n=t.match(e),o=null==n?void 0:n.index;return void 0!==o?o:-1},tokenize(t,n,o){const i=a?new RegExp(`^\\[${d}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${d}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${d}\\]`),s=t.match(i);if(!s)return;let l="",c="";if(a){const[,t]=s;c=t}else{const[,t,e]=s;c=t,l=e||""}const h=r(c.trim());return{type:e,raw:s[0],content:l.trim(),attributes:h}}},renderMarkdown:t=>{let e="";o?e=o(t):t.content&&t.content.length>0&&(e=t.content.filter(t=>"text"===t.type).map(t=>t.text).join(""));const n=(t=>{if(!l)return t;const e={};return l.forEach(n=>{const o="string"==typeof n?n:n.name,r="string"==typeof n?void 0:n.skipIfDefault;if(o in t){const n=t[o];if(void 0!==r&&n===r)return;e[o]=n}}),e})(t.attrs||{}),r=i(n),s=r?` ${r}`:"";return a?`[${c}${s}]`:`[${c}${s}]${e}[/${c}]`}}}function Il(t,e,n){var o,r,i,s;const a=t.split("\n"),l=[];let c="",d=0;const h=e.baseIndentSize||2;for(;d<a.length;){const t=a[d],p=t.match(e.itemPattern);if(!p){if(l.length>0)break;if(""===t.trim()){d+=1,c=`${c}${t}\n`;continue}return}const u=e.extractItemData(p),{indentLevel:f,mainContent:m}=u;c=`${c}${t}\n`;const g=[m];for(d+=1;d<a.length;){const t=a[d];if(""===t.trim()){const e=a.slice(d+1).findIndex(t=>""!==t.trim());if(-1===e)break;if(((null==(r=null==(o=a[d+1+e].match(/^(\s*)/))?void 0:o[1])?void 0:r.length)||0)>f){g.push(t),c=`${c}${t}\n`,d+=1;continue}break}if(!(((null==(s=null==(i=t.match(/^(\s*)/))?void 0:i[1])?void 0:s.length)||0)>f))break;g.push(t),c=`${c}${t}\n`,d+=1}let y;const b=g.slice(1);if(b.length>0){const t=b.map(t=>t.slice(f+h)).join("\n");t.trim()&&(y=e.customNestedParser?e.customNestedParser(t):n.blockTokens(t))}const v=e.createToken(u,y);l.push(v)}if(0!==l.length)return{items:l,raw:c}}function zl(t,e,n,o){if(!t||!Array.isArray(t.content))return"";const r="function"==typeof n?n(o):n,[i,...s]=t.content,a=[`${r}${e.renderChildren([i])}`];return s&&s.length>0&&s.forEach(t=>{const n=e.renderChildren([t]);if(n){const t=n.split("\n").map(t=>t?e.indent(t):"").join("\n");a.push(t)}}),a.join("\n")}Hi({},{createAtomBlockMarkdownSpec:()=>Ol,createBlockMarkdownSpec:()=>Ll,createInlineMarkdownSpec:()=>jl,parseAttributes:()=>El,parseIndentedBlocks:()=>Il,renderNestedMarkdownContent:()=>zl,serializeAttributes:()=>Nl});var $l=class t extends ol{constructor(){super(...arguments),this.type="node"}static create(e={}){const n="function"==typeof e?e():e;return new t(n)}configure(t){return super.configure(t)}extend(t){const e="function"==typeof t?t():t;return super.extend(e)}};function Pl(t){return new il({find:t.find,handler:({state:e,range:n,match:o,pasteEvent:r})=>{const i=ra(t.getAttributes,void 0,o,r);if(!1===i||null===i)return null;const{tr:s}=e,a=o[o.length-1],l=o[0];let c=n.to;if(a){const o=l.search(/\S/),r=n.from+l.indexOf(a),d=r+a.length;if(ba(n.from,n.to,e.doc).filter(e=>e.mark.type.excluded.find(n=>n===t.type&&n!==e.mark.type)).filter(t=>t.to>r).length)return null;d<n.to&&s.delete(d,n.to),r>n.from&&s.delete(n.from+o,r),c=n.from+o+a.length,s.addMark(n.from+o,c,t.type.create(i||{})),s.removeStoredMark(t.type)}}})}var Hl=n(3741),Bl=n(9242),_l=(...t)=>e=>{t.forEach(t=>{"function"==typeof t?t(e):t&&(t.current=e)})},Vl=({contentComponent:t})=>{const e=(0,g.useSyncExternalStore)(t.subscribe,t.getSnapshot,t.getServerSnapshot);return(0,r.jsx)(r.Fragment,{children:Object.values(e)})},Fl=class extends i.Component{constructor(t){var e;super(t),this.editorContentRef=i.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:Boolean(null==(e=t.editor)?void 0:e.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){var t;const e=this.props.editor;if(e&&!e.isDestroyed&&(null==(t=e.view.dom)?void 0:t.parentNode)){if(e.contentComponent)return;const t=this.editorContentRef.current;t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t}),e.contentComponent=function(){const t=new Set;let e={};return{subscribe:e=>(t.add(e),()=>{t.delete(e)}),getSnapshot:()=>e,getServerSnapshot:()=>e,setRenderer(n,o){e={...e,[n]:m.createPortal(o.reactElement,o.element,n)},t.forEach(t=>t())},removeRenderer(n){const o={...e};delete o[n],e=o,t.forEach(t=>t())}}}(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=e.contentComponent.subscribe(()=>{this.setState(t=>t.hasContentComponentInitialized?t:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),e.createNodeViews(),this.initialized=!0}}componentWillUnmount(){var t;const e=this.props.editor;if(e){this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null;try{if(!(null==(t=e.view.dom)?void 0:t.parentNode))return;const n=document.createElement("div");n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n})}catch{}}}render(){const{editor:t,innerRef:e,...n}=this.props;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{ref:_l(e,this.editorContentRef),...n}),(null==t?void 0:t.contentComponent)&&(0,r.jsx)(Vl,{contentComponent:t.contentComponent})]})}},Wl=(0,i.forwardRef)((t,e)=>{const n=i.useMemo(()=>Math.floor(4294967295*Math.random()).toString(),[t.editor]);return i.createElement(Fl,{key:n,innerRef:e,...t})}),Kl=i.memo(Wl),ql="undefined"!=typeof window?i.useLayoutEffect:i.useEffect,Ul=class{constructor(t){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=t,this.lastSnapshot={editor:t,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber||(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber}),this.lastSnapshot}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}watch(t){if(this.editor=t,this.editor){const t=()=>{this.transactionNumber+=1,this.subscribers.forEach(t=>t())},e=this.editor;return e.on("transaction",t),()=>{e.off("transaction",t)}}}},Jl="undefined"==typeof window,Gl=Jl||Boolean("undefined"!=typeof window&&window.next),Yl=class t{constructor(t){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=t,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(t){this.editor=t,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(t=>t())}getInitialEditor(){return void 0===this.options.current.immediatelyRender?Jl||Gl?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const t={...this.options.current,onBeforeCreate:(...t)=>{var e,n;return null==(n=(e=this.options.current).onBeforeCreate)?void 0:n.call(e,...t)},onBlur:(...t)=>{var e,n;return null==(n=(e=this.options.current).onBlur)?void 0:n.call(e,...t)},onCreate:(...t)=>{var e,n;return null==(n=(e=this.options.current).onCreate)?void 0:n.call(e,...t)},onDestroy:(...t)=>{var e,n;return null==(n=(e=this.options.current).onDestroy)?void 0:n.call(e,...t)},onFocus:(...t)=>{var e,n;return null==(n=(e=this.options.current).onFocus)?void 0:n.call(e,...t)},onSelectionUpdate:(...t)=>{var e,n;return null==(n=(e=this.options.current).onSelectionUpdate)?void 0:n.call(e,...t)},onTransaction:(...t)=>{var e,n;return null==(n=(e=this.options.current).onTransaction)?void 0:n.call(e,...t)},onUpdate:(...t)=>{var e,n;return null==(n=(e=this.options.current).onUpdate)?void 0:n.call(e,...t)},onContentError:(...t)=>{var e,n;return null==(n=(e=this.options.current).onContentError)?void 0:n.call(e,...t)},onDrop:(...t)=>{var e,n;return null==(n=(e=this.options.current).onDrop)?void 0:n.call(e,...t)},onPaste:(...t)=>{var e,n;return null==(n=(e=this.options.current).onPaste)?void 0:n.call(e,...t)},onDelete:(...t)=>{var e,n;return null==(n=(e=this.options.current).onDelete)?void 0:n.call(e,...t)}};return new xl(t)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(t){return this.subscriptions.add(t),()=>{this.subscriptions.delete(t)}}static compareOptions(t,e){return Object.keys(t).every(n=>!!["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(n)||("extensions"===n&&t.extensions&&e.extensions?t.extensions.length===e.extensions.length&&t.extensions.every((t,n)=>{var o;return t===(null==(o=e.extensions)?void 0:o[n])}):t[n]===e[n]))}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&0===e.length?t.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(t){if(this.editor&&!this.editor.isDestroyed){if(null===this.previousDeps)return void(this.previousDeps=t);if(this.previousDeps.length===t.length&&this.previousDeps.every((e,n)=>e===t[n]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=t}scheduleDestroy(){const t=this.instanceId,e=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{this.isComponentMounted&&this.instanceId===t?e&&e.setOptions(this.options.current):e&&!e.isDestroyed&&(e.destroy(),this.instanceId===t&&this.setEditor(null))},1)}};(0,i.createContext)({editor:null}).Consumer;var Xl=(0,i.createContext)({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}});i.forwardRef((t,e)=>{const{onDragStart:n}=(0,i.useContext)(Xl),o=t.as||"div";return(0,r.jsx)(o,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})}),i.createContext({markViewContentRef:()=>{}});var Ql=n(936),Zl={root:"m_dd3f7539",Typography:"m_f2016866",content:"m_c2204cc2",linkEditorDropdown:"m_8a991b4f",control:"m_c2207da6",controlIcon:"m_9cdfeb3f",controlsGroup:"m_2ab47ef2",linkEditor:"m_b67b711e",linkEditorInput:"m_296cf94c",linkEditorExternalControl:"m_cfef614",linkEditorSave:"m_3b28e7bb",toolbar:"m_4574a3c4",taskList:"m_8b44009a"};const tc=(0,a.P9)((t,e)=>{const n=(0,l.Y)("RichTextEditorContent",null,t),{classNames:o,className:i,style:s,styles:a,vars:c,...h}=n,p=f();return p.withTypographyStyles?(0,r.jsx)(Ql.o,{...p.getStyles("Typography",{className:i,style:s,styles:a,classNames:o}),unstyled:p.unstyled,ref:e,children:(0,r.jsx)(d.a,{component:Kl,editor:p.editor,...p.getStyles("content",{classNames:o,styles:a}),...h})}):(0,r.jsx)(d.a,{component:Kl,editor:p.editor,...p.getStyles("content",{classNames:o,styles:a,className:i,style:s}),...h})});function ec(t){return(0,r.jsx)("svg",{...t,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})}function nc(t){return(0,r.jsxs)(ec,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M7 5h6a3.5 3.5 0 0 1 0 7h-6z"}),(0,r.jsx)("path",{d:"M13 12h1a3.5 3.5 0 0 1 0 7h-7v-7"})]})}function oc(t){return(0,r.jsxs)(ec,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M11 5l6 0"}),(0,r.jsx)("path",{d:"M7 19l6 0"}),(0,r.jsx)("path",{d:"M14 5l-4 14"})]})}function rc(t){return(0,r.jsxs)(ec,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M7 5v5a5 5 0 0 0 10 0v-5"}),(0,r.jsx)("path",{d:"M5 19h14"})]})}function ic(t){return(0,r.jsxs)(ec,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M5 12l14 0"}),(0,r.jsx)("path",{d:"M16 6.5a4 2 0 0 0 -4 -1.5h-1a3.5 3.5 0 0 0 0 7h2a3.5 3.5 0 0 1 0 7h-1.5a4 2 0 0 1 -4 -1.5"})]})}function sc(t){return(0,r.jsxs)(ec,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M17 15l4 4m0 -4l-4 4"}),(0,r.jsx)("path",{d:"M7 6v-1h11v1"}),(0,r.jsx)("path",{d:"M7 19l4 0"}),(0,r.jsx)("path",{d:"M13 5l-4 14"})]})}function ac(t){return(0,r.jsxs)(ec,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M19 18v-8l-2 2"}),(0,r.jsx)("path",{d:"M4 6v12"}),(0,r.jsx)("path",{d:"M12 6v12"}),(0,r.jsx)("path",{d:"M11 18h2"}),(0,r.jsx)("path",{d:"M3 18h2"}),(0,r.jsx)("path",{d:"M4 12h8"}),(0,r.jsx)("path",{d:"M3 6h2"}),(0,r.jsx)("path",{d:"M11 6h2"})]})}function lc(t){return(0,r.jsxs)(ec,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M17 12a2 2 0 1 1 4 0c0 .591 -.417 1.318 -.816 1.858l-3.184 4.143l4 0"}),(0,r.jsx)("path",{d:"M4 6v12"}),(0,r.jsx)("path",{d:"M12 6v12"}),(0,r.jsx)("path",{d:"M11 18h2"}),(0,r.jsx)("path",{d:"M3 18h2"}),(0,r.jsx)("path",{d:"M4 12h8"}),(0,r.jsx)("path",{d:"M3 6h2"}),(0,r.jsx)("path",{d:"M11 6h2"})]})}function cc(t){return(0,r.jsxs)(ec,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M19 14a2 2 0 1 0 -2 -2"}),(0,r.jsx)("path",{d:"M17 16a2 2 0 1 0 2 -2"}),(0,r.jsx)("path",{d:"M4 6v12"}),(0,r.jsx)("path",{d:"M12 6v12"}),(0,r.jsx)("path",{d:"M11 18h2"}),(0,r.jsx)("path",{d:"M3 18h2"}),(0,r.jsx)("path",{d:"M4 12h8"}),(0,r.jsx)("path",{d:"M3 6h2"}),(0,r.jsx)("path",{d:"M11 6h2"})]})}function dc(t){return(0,r.jsxs)(ec,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M20 18v-8l-4 6h5"}),(0,r.jsx)("path",{d:"M4 6v12"}),(0,r.jsx)("path",{d:"M12 6v12"}),(0,r.jsx)("path",{d:"M11 18h2"}),(0,r.jsx)("path",{d:"M3 18h2"}),(0,r.jsx)("path",{d:"M4 12h8"}),(0,r.jsx)("path",{d:"M3 6h2"}),(0,r.jsx)("path",{d:"M11 6h2"})]})}function hc(t){return(0,r.jsxs)(ec,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M17 18h2a2 2 0 1 0 0 -4h-2v-4h4"}),(0,r.jsx)("path",{d:"M4 6v12"}),(0,r.jsx)("path",{d:"M12 6v12"}),(0,r.jsx)("path",{d:"M11 18h2"}),(0,r.jsx)("path",{d:"M3 18h2"}),(0,r.jsx)("path",{d:"M4 12h8"}),(0,r.jsx)("path",{d:"M3 6h2"}),(0,r.jsx)("path",{d:"M11 6h2"})]})}function pc(t){return(0,r.jsxs)(ec,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M19 14a2 2 0 1 0 0 4a2 2 0 0 0 0 -4z"}),(0,r.jsx)("path",{d:"M21 12a2 2 0 1 0 -4 0v4"}),(0,r.jsx)("path",{d:"M4 6v12"}),(0,r.jsx)("path",{d:"M12 6v12"}),(0,r.jsx)("path",{d:"M11 18h2"}),(0,r.jsx)("path",{d:"M3 18h2"}),(0,r.jsx)("path",{d:"M4 12h8"}),(0,r.jsx)("path",{d:"M3 6h2"}),(0,r.jsx)("path",{d:"M11 6h2"})]})}function uc(t){return(0,r.jsxs)(ec,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M9 6l11 0"}),(0,r.jsx)("path",{d:"M9 12l11 0"}),(0,r.jsx)("path",{d:"M9 18l11 0"}),(0,r.jsx)("path",{d:"M5 6l0 .01"}),(0,r.jsx)("path",{d:"M5 12l0 .01"}),(0,r.jsx)("path",{d:"M5 18l0 .01"})]})}function fc(t){return(0,r.jsxs)(ec,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M11 6h9"}),(0,r.jsx)("path",{d:"M11 12h9"}),(0,r.jsx)("path",{d:"M12 18h8"}),(0,r.jsx)("path",{d:"M4 16a2 2 0 1 1 4 0c0 .591 -.5 1 -1 1.5l-3 2.5h4"}),(0,r.jsx)("path",{d:"M6 10v-6l-2 2"})]})}function mc(t){return(0,r.jsxs)(ec,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M17 22v-2"}),(0,r.jsx)("path",{d:"M9 15l6 -6"}),(0,r.jsx)("path",{d:"M11 6l.463 -.536a5 5 0 0 1 7.071 7.072l-.534 .464"}),(0,r.jsx)("path",{d:"M13 18l-.397 .534a5.068 5.068 0 0 1 -7.127 0a4.972 4.972 0 0 1 0 -7.071l.524 -.463"}),(0,r.jsx)("path",{d:"M20 17h2"}),(0,r.jsx)("path",{d:"M2 7h2"}),(0,r.jsx)("path",{d:"M7 2v2"})]})}function gc(t){return(0,r.jsxs)(ec,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M6 15h15"}),(0,r.jsx)("path",{d:"M21 19h-15"}),(0,r.jsx)("path",{d:"M15 11h6"}),(0,r.jsx)("path",{d:"M21 7h-6"}),(0,r.jsx)("path",{d:"M9 9h1a1 1 0 1 1 -1 1v-2.5a2 2 0 0 1 2 -2"}),(0,r.jsx)("path",{d:"M3 9h1a1 1 0 1 1 -1 1v-2.5a2 2 0 0 1 2 -2"})]})}function yc(t){return(0,r.jsxs)(ec,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M4 6l16 0"}),(0,r.jsx)("path",{d:"M4 12l10 0"}),(0,r.jsx)("path",{d:"M4 18l14 0"})]})}function bc(t){return(0,r.jsxs)(ec,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M4 6l16 0"}),(0,r.jsx)("path",{d:"M10 12l10 0"}),(0,r.jsx)("path",{d:"M6 18l14 0"})]})}function vc(t){return(0,r.jsxs)(ec,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M4 6l16 0"}),(0,r.jsx)("path",{d:"M8 12l8 0"}),(0,r.jsx)("path",{d:"M6 18l12 0"})]})}function wc(t){return(0,r.jsxs)(ec,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M4 6l16 0"}),(0,r.jsx)("path",{d:"M4 12l16 0"}),(0,r.jsx)("path",{d:"M4 18l12 0"})]})}function kc(t){return(0,r.jsxs)(ec,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M5 7l8 10m-8 0l8 -10"}),(0,r.jsx)("path",{d:"M21 20h-4l3.5 -4a1.73 1.73 0 0 0 -3.5 -2"})]})}function xc(t){return(0,r.jsxs)(ec,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M5 7l8 10m-8 0l8 -10"}),(0,r.jsx)("path",{d:"M21 11h-4l3.5 -4a1.73 1.73 0 0 0 -3.5 -2"})]})}function Mc(t){return(0,r.jsxs)(ec,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M7 8l-4 4l4 4"}),(0,r.jsx)("path",{d:"M17 8l4 4l-4 4"}),(0,r.jsx)("path",{d:"M14 4l-4 16"})]})}function Cc(t){return(0,r.jsxs)(ec,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M3 19h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4"}),(0,r.jsx)("path",{d:"M12.5 5.5l4 4"}),(0,r.jsx)("path",{d:"M4.5 13.5l4 4"}),(0,r.jsx)("path",{d:"M21 15v4h-8l4 -4z"})]})}function Sc(t){return(0,r.jsxs)(ec,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M5 12h2"}),(0,r.jsx)("path",{d:"M17 12h2"}),(0,r.jsx)("path",{d:"M11 12h2"})]})}function Tc(t){return(0,r.jsxs)(ec,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M20.042 16.045a9 9 0 0 0 -12.087 -12.087m-2.318 1.677a9 9 0 1 0 12.725 12.73"}),(0,r.jsx)("path",{d:"M3 3l18 18"})]})}function Ac(t){return(0,r.jsxs)(ec,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M11 7l6 6"}),(0,r.jsx)("path",{d:"M4 16l11.7 -11.7a1 1 0 0 1 1.4 0l2.6 2.6a1 1 0 0 1 0 1.4l-11.7 11.7h-4v-4z"})]})}function Ec(t){return(0,r.jsxs)(ec,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M18 6l-12 12"}),(0,r.jsx)("path",{d:"M6 6l12 12"})]})}function Nc(t){return(0,r.jsxs)(ec,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M12 21a9 9 0 0 1 0 -18c4.97 0 9 3.582 9 8c0 1.06 -.474 2.078 -1.318 2.828c-.844 .75 -1.989 1.172 -3.182 1.172h-2.5a2 2 0 0 0 -1 3.75a1.3 1.3 0 0 1 -1 2.25"}),(0,r.jsx)("path",{d:"M8.5 10.5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"}),(0,r.jsx)("path",{d:"M12.5 7.5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"}),(0,r.jsx)("path",{d:"M16.5 10.5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"})]})}function Oc(t){return(0,r.jsxs)(ec,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M5 12l5 5l10 -10"})]})}function Lc(t){return(0,r.jsxs)(ec,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M9 15l6 -6"}),(0,r.jsx)("path",{d:"M11 6l.463 -.536a5 5 0 0 1 7.071 7.072l-.534 .464"}),(0,r.jsx)("path",{d:"M13 18l-.397 .534a5.068 5.068 0 0 1 -7.127 0a4.972 4.972 0 0 1 0 -7.071l.524 -.463"})]})}function Rc(t){return(0,r.jsxs)(ec,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M12 6h-6a2 2 0 0 0 -2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-6"}),(0,r.jsx)("path",{d:"M11 13l9 -9"}),(0,r.jsx)("path",{d:"M15 4h5v5"})]})}function Dc(t){return(0,r.jsxs)(ec,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M9 14l-4 -4l4 -4"}),(0,r.jsx)("path",{d:"M5 10h11a4 4 0 1 1 0 8h-1"})]})}function jc(t){return(0,r.jsxs)(ec,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M15 14l4 -4l-4 -4"}),(0,r.jsx)("path",{d:"M19 10h-11a4 4 0 1 0 0 8h1"})]})}function Ic(t){return(0,r.jsxs)(ec,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M3.5 5.5l1.5 1.5l2.5 -2.5"}),(0,r.jsx)("path",{d:"M3.5 11.5l1.5 1.5l2.5 -2.5"}),(0,r.jsx)("path",{d:"M3.5 17.5l1.5 1.5l2.5 -2.5"}),(0,r.jsx)("path",{d:"M11 6l9 0"}),(0,r.jsx)("path",{d:"M11 12l9 0"}),(0,r.jsx)("path",{d:"M11 18l9 0"})]})}function zc(t){return(0,r.jsxs)(ec,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M20 6l-11 0"}),(0,r.jsx)("path",{d:"M20 12l-7 0"}),(0,r.jsx)("path",{d:"M20 18l-11 0"}),(0,r.jsx)("path",{d:"M4 8l4 4l-4 4"})]})}function $c(t){return(0,r.jsxs)(ec,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M20 6l-7 0"}),(0,r.jsx)("path",{d:"M20 12l-9 0"}),(0,r.jsx)("path",{d:"M20 18l-7 0"}),(0,r.jsx)("path",{d:"M8 8l-4 4l4 4"})]})}function Pc(t){return(0,r.jsxs)(ec,{...t,children:[(0,r.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M19 3v16a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V7.914\n a1 1 0 0 1 .293-.707l3.914-3.914A1 1 0 0 1 9.914 3H18\n a1 1 0 0 1 1 1Z"}),(0,r.jsx)("path",{d:"M10 11l-2 2 2 2"}),(0,r.jsx)("path",{d:"M14 11l2 2-2 2"})]})}tc.classes=Zl,tc.displayName="@mantine/tiptap/RichTextEditorContent";var Hc=n(6076);const Bc={interactive:!0},_c=(0,a.P9)((t,e)=>{const n=(0,l.Y)("RichTextEditorControl",Bc,t),{classNames:o,className:i,style:s,styles:a,vars:c,interactive:d,active:h,onMouseDown:p,disabled:u,...m}=n,g=f();return(0,r.jsx)(Hc.N,{...m,...g.getStyles("control",{className:i,style:s,classNames:o,styles:a}),disabled:u,"data-rich-text-editor-control":!0,tabIndex:d?0:-1,"data-interactive":d||void 0,"data-disabled":u||void 0,"data-active":h||void 0,"aria-pressed":h&&d||void 0,"aria-hidden":!d||void 0,ref:e,unstyled:g.unstyled,variant:g.variant||"default",onMouseDown:t=>{t.preventDefault(),p?.(t)}})});_c.classes=Zl,_c.displayName="@mantine/tiptap/RichTextEditorControl";const Vc=(0,i.forwardRef)(({className:t,icon:e,...n},o)=>{const i=f();return(0,r.jsx)(_c,{ref:o,...n,children:(0,r.jsx)(e,{...i.getStyles("controlIcon")})})});function Fc({label:t,isActive:e,operation:n,icon:o,isDisabled:s}){const a=(0,i.forwardRef)((i,a)=>{const{editor:l,labels:c}=f(),d=c[t];return(0,r.jsx)(Vc,{"aria-label":d,title:d,active:!!e?.name&&l?.isActive(e.name,e.attributes),ref:a,icon:i.icon||o,disabled:s?.(l)||!1,...i,onClick:()=>l?.chain().focus()[n.name](n.attributes).run()})});return a.displayName=`@mantine/tiptap/${t}`,a}Vc.displayName="@mantine/tiptap/RichTextEditorControlBase";const Wc=Fc({label:"boldControlLabel",icon:t=>(0,r.jsx)(nc,{...t}),isActive:{name:"bold"},operation:{name:"toggleBold"}}),Kc=Fc({label:"italicControlLabel",icon:t=>(0,r.jsx)(oc,{...t}),isActive:{name:"italic"},operation:{name:"toggleItalic"}}),qc=Fc({label:"underlineControlLabel",icon:t=>(0,r.jsx)(rc,{...t}),isActive:{name:"underline"},operation:{name:"toggleUnderline"}}),Uc=Fc({label:"strikeControlLabel",icon:t=>(0,r.jsx)(ic,{...t}),isActive:{name:"strike"},operation:{name:"toggleStrike"}}),Jc=Fc({label:"clearFormattingControlLabel",icon:t=>(0,r.jsx)(sc,{...t}),operation:{name:"unsetAllMarks"}}),Gc=Fc({label:"unlinkControlLabel",icon:t=>(0,r.jsx)(mc,{...t}),operation:{name:"unsetLink"}}),Yc=Fc({label:"bulletListControlLabel",icon:t=>(0,r.jsx)(uc,{...t}),isActive:{name:"bulletList"},operation:{name:"toggleBulletList"}}),Xc=Fc({label:"orderedListControlLabel",icon:t=>(0,r.jsx)(fc,{...t}),isActive:{name:"orderedList"},operation:{name:"toggleOrderedList"}}),Qc=Fc({label:"h1ControlLabel",icon:t=>(0,r.jsx)(ac,{...t}),isActive:{name:"heading",attributes:{level:1}},operation:{name:"toggleHeading",attributes:{level:1}}}),Zc=Fc({label:"h2ControlLabel",icon:t=>(0,r.jsx)(lc,{...t}),isActive:{name:"heading",attributes:{level:2}},operation:{name:"toggleHeading",attributes:{level:2}}}),td=Fc({label:"h3ControlLabel",icon:t=>(0,r.jsx)(cc,{...t}),isActive:{name:"heading",attributes:{level:3}},operation:{name:"toggleHeading",attributes:{level:3}}}),ed=Fc({label:"h4ControlLabel",icon:t=>(0,r.jsx)(dc,{...t}),isActive:{name:"heading",attributes:{level:4}},operation:{name:"toggleHeading",attributes:{level:4}}}),nd=Fc({label:"h5ControlLabel",icon:t=>(0,r.jsx)(hc,{...t}),isActive:{name:"heading",attributes:{level:5}},operation:{name:"toggleHeading",attributes:{level:5}}}),od=Fc({label:"h6ControlLabel",icon:t=>(0,r.jsx)(pc,{...t}),isActive:{name:"heading",attributes:{level:6}},operation:{name:"toggleHeading",attributes:{level:6}}}),rd=Fc({label:"blockquoteControlLabel",icon:t=>(0,r.jsx)(gc,{...t}),isActive:{name:"blockquote"},operation:{name:"toggleBlockquote"}}),id=Fc({label:"alignLeftControlLabel",icon:t=>(0,r.jsx)(yc,{...t}),operation:{name:"setTextAlign",attributes:"left"}}),sd=Fc({label:"alignRightControlLabel",icon:t=>(0,r.jsx)(bc,{...t}),operation:{name:"setTextAlign",attributes:"right"}}),ad=Fc({label:"alignCenterControlLabel",icon:t=>(0,r.jsx)(vc,{...t}),operation:{name:"setTextAlign",attributes:"center"}}),ld=Fc({label:"alignJustifyControlLabel",icon:t=>(0,r.jsx)(wc,{...t}),operation:{name:"setTextAlign",attributes:"justify"}}),cd=Fc({label:"subscriptControlLabel",icon:t=>(0,r.jsx)(kc,{...t}),isActive:{name:"subscript"},operation:{name:"toggleSubscript"}}),dd=Fc({label:"superscriptControlLabel",icon:t=>(0,r.jsx)(xc,{...t}),isActive:{name:"superscript"},operation:{name:"toggleSuperscript"}}),hd=Fc({label:"codeControlLabel",icon:t=>(0,r.jsx)(Mc,{...t}),isActive:{name:"code"},operation:{name:"toggleCode"}}),pd=Fc({label:"codeBlockControlLabel",icon:t=>(0,r.jsx)(Mc,{...t}),isActive:{name:"codeBlock"},operation:{name:"toggleCodeBlock"}}),ud=Fc({label:"highlightControlLabel",icon:t=>(0,r.jsx)(Cc,{...t}),isActive:{name:"highlight"},operation:{name:"toggleHighlight"}}),fd=Fc({label:"hrControlLabel",icon:t=>(0,r.jsx)(Sc,{...t}),operation:{name:"setHorizontalRule"}}),md=Fc({label:"unsetColorControlLabel",icon:t=>(0,r.jsx)(Tc,{...t}),operation:{name:"unsetColor"}}),gd=Fc({label:"undoControlLabel",icon:t=>(0,r.jsx)(Dc,{...t}),isDisabled:t=>!t?.can().undo(),operation:{name:"undo"}}),yd=Fc({label:"redoControlLabel",icon:t=>(0,r.jsx)(jc,{...t}),isDisabled:t=>!t?.can().redo(),operation:{name:"redo"}}),bd=Fc({label:"tasksControlLabel",icon:t=>(0,r.jsx)(Ic,{...t}),isActive:{name:"taskList"},operation:{name:"toggleTaskList"}}),vd=Fc({label:"tasksSinkLabel",icon:t=>(0,r.jsx)(zc,{...t}),operation:{name:"sinkListItem",attributes:"taskItem"},isDisabled:t=>!t?.can().sinkListItem("taskItem")}),wd=Fc({label:"tasksLiftLabel",icon:t=>(0,r.jsx)($c,{...t}),operation:{name:"liftListItem",attributes:"taskItem"},isDisabled:t=>!t?.can().liftListItem("taskItem")});var kd=n(9274),xd=n(5172),Md=n(7193),Cd=n(2335),Sd=n(8149),Td=n(5055);function Ad(t){return e=>{if(e)if("function"==typeof e)t(e);else if("object"==typeof e&&"nativeEvent"in e){const{currentTarget:n}=e;"checkbox"===n.type?t(n.checked):t(n.value)}else t(e);else t(e)}}var Ed=n(3489),Nd=n(977);const Od=t=>(0,r.jsx)(Lc,{...t}),Ld=(0,a.P9)((t,e)=>{const n=(0,l.Y)("RichTextEditorLinkControl",null,t),{classNames:o,className:s,style:a,styles:c,vars:d,icon:h,popoverProps:p,disableTooltips:u,initialExternal:m,...g}=n,y=f(),b={classNames:o,styles:c},[v,w]=function(){const[t,e]=(0,i.useState)("");return[t,Ad(e)]}(),[k,x]=(0,i.useState)(m),[M,{open:C,close:S}]=(0,Ed.j)(!1),T=()=>{C();const t=y.editor?.getAttributes("link");w(t?.href||""),x(t?.href?"_blank"===t?.target:m)},A=()=>{S(),w(""),x(m)},E=()=>{A(),""===v?y.editor?.chain().focus().extendMarkRange("link").unsetLink().run():y.editor?.chain().focus().extendMarkRange("link").setLink({href:v,target:k?"_blank":null}).run()};(0,Nd.M)("edit-link",T,!1);const{resolvedClassNames:N,resolvedStyles:O}=(0,kd.Y)({classNames:o,styles:c,props:n});return(0,r.jsxs)(xd.A,{trapFocus:!0,shadow:"md",withinPortal:!0,opened:M,onChange:t=>!t&&A(),offset:-44,zIndex:1e4,...p,children:[(0,r.jsx)(xd.A.Target,{children:(0,r.jsx)(Vc,{icon:h||Od,...g,"aria-label":y.labels.linkControlLabel,title:y.labels.linkControlLabel,onClick:T,active:y.editor?.isActive("link"),ref:e,classNames:N,styles:O,className:s,style:a,variant:y.variant})}),(0,r.jsx)(xd.A.Dropdown,{...y.getStyles("linkEditorDropdown",b),children:(0,r.jsxs)("div",{...y.getStyles("linkEditor",b),children:[(0,r.jsx)(Md.k,{placeholder:y.labels.linkEditorInputPlaceholder,"aria-label":y.labels.linkEditorInputLabel,type:"url",value:v,onChange:w,classNames:{input:y.getStyles("linkEditorInput",b).className},onKeyDown:t=>{"Enter"===t.key&&(t.preventDefault(),E())},rightSection:(0,r.jsx)(Cd.m,{label:k?y.labels.linkEditorExternalLink:y.labels.linkEditorInternalLink,events:{hover:!0,focus:!0,touch:!0},withinPortal:!0,withArrow:!0,disabled:u,zIndex:1e4,children:(0,r.jsx)(Hc.N,{onClick:()=>x(t=>!t),"data-active":k||void 0,...y.getStyles("linkEditorExternalControl",b),children:(0,r.jsx)(Rc,{style:{width:(0,Sd.D)(14),height:(0,Sd.D)(14)}})})})}),(0,r.jsx)(Td.$,{variant:"default",onClick:E,...y.getStyles("linkEditorSave",b),children:y.labels.linkEditorSave})]})})]})});Ld.classes=Zl,Ld.displayName="@mantine/tiptap/RichTextEditorLinkControl";var Rd=n(9731),Dd=n(9277),jd=n(2865),Id=n(4999),zd=n(8324);const $d=(0,i.forwardRef)((t,e)=>{const{popoverProps:n,colors:o,colorPickerProps:s,...a}=(0,l.Y)("RichTextEditorColorPickerControl",null,t),{editor:c,labels:d,getStyles:h,variant:p}=f(),[u,{toggle:m,close:g}]=(0,Ed.j)(!1),[y,b]=(0,i.useState)("palette"),v=c?.getAttributes("textStyle").color||"var(--mantine-color-text)",w=(t,e=!0)=>{(c?.chain()).focus().setColor(t).run(),e&&g()},k=o.map((t,e)=>(0,r.jsx)(Rd.q,{component:"button",color:t,onClick:()=>w(t),size:26,radius:"xs",style:{cursor:"pointer"},title:d.colorPickerColorLabel(t),"aria-label":d.colorPickerColorLabel(t)},e));return(0,r.jsxs)(xd.A,{opened:u,withinPortal:!0,trapFocus:!0,onChange:t=>!t&&g(),...n,children:[(0,r.jsx)(xd.A.Target,{children:(0,r.jsx)(_c,{...a,variant:p,"aria-label":d.colorPickerControlLabel,title:d.colorPickerControlLabel,ref:e,onClick:m,children:(0,r.jsx)(Rd.q,{color:v,size:14})})}),(0,r.jsxs)(xd.A.Dropdown,{...h("linkEditorDropdown"),children:["palette"===y&&(0,r.jsx)(Dd.r,{cols:7,spacing:2,children:k}),"colorPicker"===y&&(0,r.jsx)(jd.s,{defaultValue:v,onChange:t=>w(t,!1),...s}),(0,r.jsx)(Cd.m.Group,{closeDelay:200,children:(0,r.jsxs)(Id.Y,{justify:"flex-end",gap:"xs",mt:"sm",children:["palette"===y&&(0,r.jsx)(zd.M,{variant:"default",onClick:g,title:d.colorPickerCancel,"aria-label":d.colorPickerCancel,children:(0,r.jsx)(Ec,{style:{width:(0,Sd.D)(16),height:(0,Sd.D)(16)}})}),(0,r.jsx)(zd.M,{variant:"default",onClick:()=>{(c?.chain()).focus().unsetColor().run(),g()},title:d.colorPickerClear,"aria-label":d.colorPickerClear,children:(0,r.jsx)(Tc,{style:{width:(0,Sd.D)(16),height:(0,Sd.D)(16)}})}),"palette"===y?(0,r.jsx)(zd.M,{variant:"default",onClick:()=>b("colorPicker"),title:d.colorPickerColorPicker,"aria-label":d.colorPickerColorPicker,children:(0,r.jsx)(Ac,{style:{width:(0,Sd.D)(16),height:(0,Sd.D)(16)}})}):(0,r.jsx)(zd.M,{variant:"default",onClick:()=>b("palette"),"aria-label":d.colorPickerPalette,title:d.colorPickerPalette,children:(0,r.jsx)(Nc,{style:{width:(0,Sd.D)(16),height:(0,Sd.D)(16)}})}),"colorPicker"===y&&(0,r.jsx)(zd.M,{variant:"default",onClick:g,title:d.colorPickerSave,"aria-label":d.colorPickerSave,children:(0,r.jsx)(Oc,{style:{width:(0,Sd.D)(16),height:(0,Sd.D)(16)}})})]})})]})]})});$d.displayName="@mantine/tiptap/ColorPickerControl";const Pd=(0,i.forwardRef)((t,e)=>{const{color:n,...o}=(0,l.Y)("RichTextEditorColorControl",null,t),{editor:i,labels:s,variant:a}=f(),c=i?.getAttributes("textStyle").color||null,d=s.colorControlLabel(n);return(0,r.jsx)(_c,{...o,variant:a,active:c===n,"aria-label":d,title:d,onClick:()=>(i?.chain()).focus().setColor(n).run(),ref:e,children:(0,r.jsx)(Rd.q,{color:n,size:14})})});Pd.displayName="@mantine/tiptap/RichTextEditorColorControl";const Hd={},Bd=(0,i.forwardRef)((t,e)=>{const{...n}=(0,l.Y)("RichTextEditorSourceCodeControl",Hd,t),{editor:o,labels:s,variant:a,onSourceCodeTextSwitch:c}=f(),[d,h]=(0,i.useState)(!1);return(0,r.jsx)(_c,{...n,variant:a,active:d,"aria-label":s.sourceCodeControlLabel,title:s.sourceCodeControlLabel,onClick:()=>(()=>{d?o?.commands.setContent(o.getText(),{emitUpdate:!0}):o?.commands.setContent(`<textarea>${o.getHTML()}</textarea>`);const t=!d;h(t),c?.(t)})(),ref:e,children:(0,r.jsx)(Pc,{style:{width:(0,Sd.D)(16),height:(0,Sd.D)(16)}})})});Bd.displayName="@mantine/tiptap/RichTextEditorSourceCodeControl";const _d=(0,a.P9)((t,e)=>{const n=(0,l.Y)("RichTextEditorControlsGroup",null,t),{classNames:o,className:i,style:s,styles:a,vars:c,variant:h,...p}=n,u=f();return(0,r.jsx)(d.a,{ref:e,variant:h||u.variant,...u.getStyles("controlsGroup",{className:i,style:s,styles:a,classNames:o}),...p})});_d.classes=Zl,_d.displayName="@mantine/tiptap/RichTextEditorControlsGroup";const Vd=(0,a.P9)((t,e)=>{const n=(0,l.Y)("RichTextEditorToolbar",null,t),{classNames:o,className:i,style:s,styles:a,vars:c,sticky:h,stickyOffset:p,mod:u,variant:m,...g}=n,y=f();return(0,r.jsx)(d.a,{ref:e,mod:[{sticky:h},u],variant:m||y.variant,...y.getStyles("toolbar",{className:i,style:s,styles:a,classNames:o}),...g,__vars:{"--rte-sticky-offset":(0,Sd.D)(p)}})});Vd.classes=Zl,Vd.displayName="@mantine/tiptap/RichTextEditorToolbar";const Fd={withCodeHighlightStyles:!0,withTypographyStyles:!0,variant:"default"},Wd=(0,a.P9)((t,e)=>{const n=(0,l.Y)("RichTextEditor",Fd,t),{classNames:o,className:s,style:a,styles:p,unstyled:f,vars:m,editor:g,withCodeHighlightStyles:y,withTypographyStyles:b,onSourceCodeTextSwitch:v,labels:w,children:k,variant:x,attributes:M,...C}=n,S=(0,c.I)({name:"RichTextEditor",classes:Zl,props:n,className:s,style:a,classNames:o,styles:p,unstyled:f,attributes:M,vars:m}),T=(0,i.useMemo)(()=>({...h,...w}),[w]);return(0,r.jsx)(u,{value:{editor:g,getStyles:S,labels:T,withCodeHighlightStyles:y,withTypographyStyles:b,onSourceCodeTextSwitch:v,unstyled:f,variant:x},children:(0,r.jsx)(d.a,{...S("root"),...C,ref:e,children:k})})});Wd.classes=Zl,Wd.displayName="@mantine/tiptap/RichTextEditor",Wd.Content=tc,Wd.Control=_c,Wd.Toolbar=Vd,Wd.ControlsGroup=_d,Wd.Bold=Wc,Wd.Italic=Kc,Wd.Strikethrough=Uc,Wd.Underline=qc,Wd.ClearFormatting=Jc,Wd.H1=Qc,Wd.H2=Zc,Wd.H3=td,Wd.H4=ed,Wd.H5=nd,Wd.H6=od,Wd.BulletList=Yc,Wd.OrderedList=Xc,Wd.Link=Ld,Wd.Unlink=Gc,Wd.Blockquote=rd,Wd.AlignLeft=id,Wd.AlignRight=sd,Wd.AlignCenter=ad,Wd.AlignJustify=ld,Wd.Superscript=dd,Wd.Subscript=cd,Wd.Code=hd,Wd.CodeBlock=pd,Wd.ColorPicker=$d,Wd.Color=Pd,Wd.Highlight=ud,Wd.Hr=fd,Wd.UnsetColor=md,Wd.Undo=gd,Wd.Redo=yd,Wd.TaskList=bd,Wd.TaskListSink=vd,Wd.TaskListLift=wd,Wd.SourceCode=Bd;var Kd=n(5072),qd=n.n(Kd),Ud=n(7825),Jd=n.n(Ud),Gd=n(5056),Yd=n.n(Gd),Xd=n(540),Qd=n.n(Xd),Zd=n(1113),th=n.n(Zd),eh=n(6541),nh={};nh.styleTagTransform=th(),nh.setAttributes=Yd(),nh.insert=function(t){var e=document.querySelector("head"),n=window._lastElementInsertedByStyleLoader;n?n.nextSibling?e.insertBefore(t,n.nextSibling):e.appendChild(t):e.insertBefore(t,e.firstChild),window._lastElementInsertedByStyleLoader=t},nh.domAPI=Jd(),nh.insertStyleElement=Qd(),qd()(eh.A,nh),eh.A&&eh.A.locals&&eh.A.locals;var oh=n(4193),rh=n(297),ih=n(8734),sh=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,ah=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,lh=rl.create({name:"highlight",addOptions:()=>({multicolor:!1,HTMLAttributes:{}}),addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:t=>t.getAttribute("data-color")||t.style.backgroundColor,renderHTML:t=>t.color?{"data-color":t.color,style:`background-color: ${t.color}; color: inherit`}:{}}}:{}},parseHTML:()=>[{tag:"mark"}],renderHTML({HTMLAttributes:t}){return["mark",aa(this.options.HTMLAttributes,t),0]},renderMarkdown:(t,e)=>`==${e.renderChildren(t)}==`,parseMarkdown:(t,e)=>e.applyMark("highlight",e.parseInline(t.tokens||[])),markdownTokenizer:{name:"highlight",level:"inline",start:t=>t.indexOf("=="),tokenize(t,e,n){const o=/^(==)([^=]+)(==)/.exec(t);if(o){const t=o[2].trim(),e=n.inlineTokens(t);return{type:"highlight",raw:o[0],text:t,tokens:e}}}},addCommands(){return{setHighlight:t=>({commands:e})=>e.setMark(this.name,t),toggleHighlight:t=>({commands:e})=>e.toggleMark(this.name,t),unsetHighlight:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[Ml({find:sh,type:this.type})]},addPasteRules(){return[Pl({find:ah,type:this.type})]}}),ch=(t,e)=>{if("slot"===t)return 0;if(t instanceof Function)return t(e);const{children:n,...o}=null!=e?e:{};if("svg"===t)throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[t,o,n]},dh=/^\s*>\s$/,hh=$l.create({name:"blockquote",addOptions:()=>({HTMLAttributes:{}}),content:"block+",group:"block",defining:!0,parseHTML:()=>[{tag:"blockquote"}],renderHTML({HTMLAttributes:t}){return ch("blockquote",{...aa(this.options.HTMLAttributes,t),children:ch("slot",{})})},parseMarkdown:(t,e)=>e.createNode("blockquote",void 0,e.parseChildren(t.tokens||[])),renderMarkdown:(t,e)=>{if(!t.content)return"";const n=[];return t.content.forEach(t=>{const o=e.renderChildren([t]).split("\n").map(t=>""===t.trim()?">":`> ${t}`);n.push(o.join("\n"))}),n.join("\n>\n")},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[Tl({find:dh,type:this.type})]}}),ph=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,uh=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,fh=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,mh=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,gh=rl.create({name:"bold",addOptions:()=>({HTMLAttributes:{}}),parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>"normal"!==t.style.fontWeight&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return ch("strong",{...aa(this.options.HTMLAttributes,t),children:ch("slot",{})})},markdownTokenName:"strong",parseMarkdown:(t,e)=>e.applyMark("bold",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`**${e.renderChildren(t)}**`,addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Ml({find:ph,type:this.type}),Ml({find:fh,type:this.type})]},addPasteRules(){return[Pl({find:uh,type:this.type}),Pl({find:mh,type:this.type})]}}),yh=/(^|[^`])`([^`]+)`(?!`)$/,bh=/(^|[^`])`([^`]+)`(?!`)/g,vh=rl.create({name:"code",addOptions:()=>({HTMLAttributes:{}}),excludes:"_",code:!0,exitable:!0,parseHTML:()=>[{tag:"code"}],renderHTML({HTMLAttributes:t}){return["code",aa(this.options.HTMLAttributes,t),0]},markdownTokenName:"codespan",parseMarkdown:(t,e)=>e.applyMark("code",[{type:"text",text:t.text||""}]),renderMarkdown:(t,e)=>t.content?`\`${e.renderChildren(t.content)}\``:"",addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Ml({find:yh,type:this.type})]},addPasteRules(){return[Pl({find:bh,type:this.type})]}}),wh=/^```([a-z]+)?[\s\n]$/,kh=/^~~~([a-z]+)?[\s\n]$/,xh=$l.create({name:"codeBlock",addOptions:()=>({languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:4,HTMLAttributes:{}}),content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options;if(!n)return null;return[...(null==(e=t.firstElementChild)?void 0:e.classList)||[]].filter(t=>t.startsWith(n)).map(t=>t.replace(n,""))[0]||null},rendered:!1}}},parseHTML:()=>[{tag:"pre",preserveWhitespace:"full"}],renderHTML({node:t,HTMLAttributes:e}){return["pre",aa(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var n;return!1===(null==(n=t.raw)?void 0:n.startsWith("```"))&&"indented"!==t.codeBlockStyle?[]:e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var n;let o="";const r=(null==(n=t.attrs)?void 0:n.language)||"";return o=t.content?[`\`\`\`${r}`,e.renderChildren(t.content),"```"].join("\n"):`\`\`\`${r}\n\n\`\`\``,o},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=1===e.pos;return!(!t||e.parent.type.name!==this.name)&&!(!n&&e.parent.textContent.length)&&this.editor.commands.clearNodes()},Tab:({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=null!=(e=this.options.tabSize)?e:4,{state:o}=t,{selection:r}=o,{$from:i,empty:s}=r;if(i.parent.type!==this.type)return!1;const a=" ".repeat(n);return s?t.commands.insertContent(a):t.commands.command(({tr:t})=>{const{from:e,to:n}=r,i=o.doc.textBetween(e,n,"\n","\n").split("\n").map(t=>a+t).join("\n");return t.replaceWith(e,n,o.schema.text(i)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=null!=(e=this.options.tabSize)?e:4,{state:o}=t,{selection:r}=o,{$from:i,empty:s}=r;return i.parent.type===this.type&&(s?t.commands.command(({tr:t})=>{var e;const{pos:r}=i,s=i.start(),a=i.end(),l=o.doc.textBetween(s,a,"\n","\n").split("\n");let c=0,d=0;const h=r-s;for(let t=0;t<l.length;t+=1){if(d+l[t].length>=h){c=t;break}d+=l[t].length+1}const p=(null==(e=l[c].match(/^ */))?void 0:e[0])||"",u=Math.min(p.length,n);if(0===u)return!0;let f=s;for(let t=0;t<c;t+=1)f+=l[t].length+1;return t.delete(f,f+u),r-f<=u&&t.setSelection(xe.create(t.doc,f)),!0}):t.commands.command(({tr:t})=>{const{from:e,to:i}=r,s=o.doc.textBetween(e,i,"\n","\n").split("\n").map(t=>{var e;const o=(null==(e=t.match(/^ */))?void 0:e[0])||"",r=Math.min(o.length,n);return t.slice(r)}).join("\n");return t.replaceWith(e,i,o.schema.text(s)),!0}))},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:o,empty:r}=n;if(!r||o.parent.type!==this.type)return!1;const i=o.parentOffset===o.parent.nodeSize-2,s=o.parent.textContent.endsWith("\n\n");return!(!i||!s)&&t.chain().command(({tr:t})=>(t.delete(o.pos-2,o.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:o}=e,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;if(r.parentOffset!==r.parent.nodeSize-2)return!1;const s=r.after();return void 0!==s&&(o.nodeAt(s)?t.commands.command(({tr:t})=>(t.setSelection(be.near(o.resolve(s))),!0)):t.commands.exitCode())}}},addInputRules(){return[Sl({find:wh,type:this.type,getAttributes:t=>({language:t[1]})}),Sl({find:kh,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new $e({key:new Be("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData)return!1;if(this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),o=e.clipboardData.getData("vscode-editor-data"),r=o?JSON.parse(o):void 0,i=null==r?void 0:r.mode;if(!n||!i)return!1;const{tr:s,schema:a}=t.state,l=a.text(n.replace(/\r\n?/g,"\n"));return s.replaceSelectionWith(this.type.create({language:i},l)),s.selection.$from.parent.type!==this.type&&s.setSelection(xe.near(s.doc.resolve(Math.max(0,s.selection.from-2)))),s.setMeta("paste",!0),t.dispatch(s),!0}}})]}}),Mh=xh,Ch=$l.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,"\n\n"):""}),Sh=$l.create({name:"hardBreak",markdownTokenName:"br",addOptions:()=>({keepMarks:!0,HTMLAttributes:{}}),inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML:()=>[{tag:"br"}],renderHTML({HTMLAttributes:t}){return["br",aa(this.options.HTMLAttributes,t)]},renderText:()=>"\n",renderMarkdown:()=>" \n",parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:o})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:t,storedMarks:r}=n;if(t.$from.parent.type.spec.isolating)return!1;const{keepMarks:i}=this.options,{splittableMarks:s}=o.extensionManager,a=r||t.$to.parentOffset&&t.$from.marks();return e().insertContent({type:this.name}).command(({tr:t,dispatch:e})=>{if(e&&a&&i){const e=a.filter(t=>s.includes(t.type.name));t.ensureMarks(e)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),Th=$l.create({name:"heading",addOptions:()=>({levels:[1,2,3,4,5,6],HTMLAttributes:{}}),content:"inline*",group:"block",defining:!0,addAttributes:()=>({level:{default:1,rendered:!1}}),parseHTML(){return this.options.levels.map(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,aa(this.options.HTMLAttributes,e),0]},parseMarkdown:(t,e)=>e.createNode("heading",{level:t.depth||1},e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>{var n;const o=(null==(n=t.attrs)?void 0:n.level)?parseInt(t.attrs.level,10):1,r="#".repeat(o);return t.content?`${r} ${e.renderChildren(t.content)}`:""},addCommands(){return{setHeading:t=>({commands:e})=>!!this.options.levels.includes(t.level)&&e.setNode(this.name,t),toggleHeading:t=>({commands:e})=>!!this.options.levels.includes(t.level)&&e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>Sl({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),Ah=$l.create({name:"horizontalRule",addOptions:()=>({HTMLAttributes:{},nextNodeType:"paragraph"}),group:"block",parseHTML:()=>[{tag:"hr"}],renderHTML({HTMLAttributes:t}){return["hr",aa(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!function(t,e){const{selection:n}=t,{$from:o}=n;if(n instanceof Ce){const t=o.index();return o.parent.canReplaceWith(t,t+1,e)}let r=o.depth;for(;r>=0;){const t=o.index(r);if(o.node(r).contentMatchAt(t).matchType(e))return!0;r-=1}return!1}(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:o}=n,r=t();return Sa(n)?r.insertContentAt(o.pos,{type:this.name}):r.insertContent({type:this.name}),r.command(({state:t,tr:e,dispatch:n})=>{if(n){const{$to:n}=e.selection,o=n.end();if(n.nodeAfter)n.nodeAfter.isTextblock?e.setSelection(xe.create(e.doc,n.pos+1)):n.nodeAfter.isBlock?e.setSelection(Ce.create(e.doc,n.pos)):e.setSelection(xe.create(e.doc,n.pos));else{const r=t.schema.nodes[this.options.nextNodeType]||n.parent.type.contentMatch.defaultType,i=null==r?void 0:r.create();i&&(e.insert(o,i),e.setSelection(xe.create(e.doc,o+1)))}e.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Cl({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),Eh=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Nh=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Oh=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Lh=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Rh=rl.create({name:"italic",addOptions:()=>({HTMLAttributes:{}}),parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>"normal"!==t.style.fontStyle&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",aa(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(t,e)=>e.applyMark("italic",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Ml({find:Eh,type:this.type}),Ml({find:Oh,type:this.type})]},addPasteRules(){return[Pl({find:Nh,type:this.type}),Pl({find:Lh,type:this.type})]}});const Dh="numeric",jh="ascii",Ih="alpha",zh="asciinumeric",$h="alphanumeric",Ph="domain",Hh="emoji",Bh="scheme",_h="slashscheme",Vh="whitespace";function Fh(t,e){return t in e||(e[t]=[]),e[t]}function Wh(t,e,n){e[Dh]&&(e[zh]=!0,e[$h]=!0),e[jh]&&(e[zh]=!0,e[Ih]=!0),e[zh]&&(e[$h]=!0),e[Ih]&&(e[$h]=!0),e[$h]&&(e[Ph]=!0),e[Hh]&&(e[Ph]=!0);for(const o in e){const e=Fh(o,n);e.indexOf(t)<0&&e.push(t)}}function Kh(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}Kh.groups={},Kh.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let n=0;n<e.jr.length;n++){const o=e.jr[n][0],r=e.jr[n][1];if(r&&o.test(t))return r}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,o){for(let r=0;r<t.length;r++)this.tt(t[r],e,n,o)},tr(t,e,n,o){let r;return o=o||Kh.groups,e&&e.j?r=e:(r=new Kh(e),n&&o&&Wh(e,n,o)),this.jr.push([t,r]),r},ts(t,e,n,o){let r=this;const i=t.length;if(!i)return r;for(let e=0;e<i-1;e++)r=r.tt(t[e]);return r.tt(t[i-1],e,n,o)},tt(t,e,n,o){o=o||Kh.groups;const r=this;if(e&&e.j)return r.j[t]=e,e;const i=e;let s,a=r.go(t);if(a?(s=new Kh,Object.assign(s.j,a.j),s.jr.push.apply(s.jr,a.jr),s.jd=a.jd,s.t=a.t):s=new Kh,i){if(o)if(s.t&&"string"==typeof s.t){const t=Object.assign(function(t,e){const n={};for(const o in e)e[o].indexOf(t)>=0&&(n[o]=!0);return n}(s.t,o),n);Wh(i,t,o)}else n&&Wh(i,n,o);s.t=i}return r.j[t]=s,s}};const qh=(t,e,n,o,r)=>t.ta(e,n,o,r),Uh=(t,e,n,o,r)=>t.tr(e,n,o,r),Jh=(t,e,n,o,r)=>t.ts(e,n,o,r),Gh=(t,e,n,o,r)=>t.tt(e,n,o,r),Yh="WORD",Xh="UWORD",Qh="ASCIINUMERICAL",Zh="ALPHANUMERICAL",tp="LOCALHOST",ep="TLD",np="UTLD",op="SCHEME",rp="SLASH_SCHEME",ip="NUM",sp="WS",ap="NL",lp="OPENBRACE",cp="CLOSEBRACE",dp="OPENBRACKET",hp="CLOSEBRACKET",pp="OPENPAREN",up="CLOSEPAREN",fp="OPENANGLEBRACKET",mp="CLOSEANGLEBRACKET",gp="FULLWIDTHLEFTPAREN",yp="FULLWIDTHRIGHTPAREN",bp="LEFTCORNERBRACKET",vp="RIGHTCORNERBRACKET",wp="LEFTWHITECORNERBRACKET",kp="RIGHTWHITECORNERBRACKET",xp="FULLWIDTHLESSTHAN",Mp="FULLWIDTHGREATERTHAN",Cp="AMPERSAND",Sp="APOSTROPHE",Tp="ASTERISK",Ap="AT",Ep="BACKSLASH",Np="BACKTICK",Op="CARET",Lp="COLON",Rp="COMMA",Dp="DOLLAR",jp="DOT",Ip="EQUALS",zp="EXCLAMATION",$p="HYPHEN",Pp="PERCENT",Hp="PIPE",Bp="PLUS",_p="POUND",Vp="QUERY",Fp="QUOTE",Wp="FULLWIDTHMIDDLEDOT",Kp="SEMI",qp="SLASH",Up="TILDE",Jp="UNDERSCORE",Gp="EMOJI",Yp="SYM";var Xp=Object.freeze({__proto__:null,ALPHANUMERICAL:Zh,AMPERSAND:Cp,APOSTROPHE:Sp,ASCIINUMERICAL:Qh,ASTERISK:Tp,AT:Ap,BACKSLASH:Ep,BACKTICK:Np,CARET:Op,CLOSEANGLEBRACKET:mp,CLOSEBRACE:cp,CLOSEBRACKET:hp,CLOSEPAREN:up,COLON:Lp,COMMA:Rp,DOLLAR:Dp,DOT:jp,EMOJI:Gp,EQUALS:Ip,EXCLAMATION:zp,FULLWIDTHGREATERTHAN:Mp,FULLWIDTHLEFTPAREN:gp,FULLWIDTHLESSTHAN:xp,FULLWIDTHMIDDLEDOT:Wp,FULLWIDTHRIGHTPAREN:yp,HYPHEN:$p,LEFTCORNERBRACKET:bp,LEFTWHITECORNERBRACKET:wp,LOCALHOST:tp,NL:ap,NUM:ip,OPENANGLEBRACKET:fp,OPENBRACE:lp,OPENBRACKET:dp,OPENPAREN:pp,PERCENT:Pp,PIPE:Hp,PLUS:Bp,POUND:_p,QUERY:Vp,QUOTE:Fp,RIGHTCORNERBRACKET:vp,RIGHTWHITECORNERBRACKET:kp,SCHEME:op,SEMI:Kp,SLASH:qp,SLASH_SCHEME:rp,SYM:Yp,TILDE:Up,TLD:ep,UNDERSCORE:Jp,UTLD:np,UWORD:Xh,WORD:Yh,WS:sp});const Qp=/[a-z]/,Zp=/\p{L}/u,tu=/\p{Emoji}/u,eu=/\d/,nu=/\s/;let ou=null,ru=null;function iu(t,e){const n=function(t){const e=[],n=t.length;let o=0;for(;o<n;){let r,i=t.charCodeAt(o),s=i<55296||i>56319||o+1===n||(r=t.charCodeAt(o+1))<56320||r>57343?t[o]:t.slice(o,o+2);e.push(s),o+=s.length}return e}(e.replace(/[A-Z]/g,t=>t.toLowerCase())),o=n.length,r=[];let i=0,s=0;for(;s<o;){let a=t,l=null,c=0,d=null,h=-1,p=-1;for(;s<o&&(l=a.go(n[s]));)a=l,a.accepts()?(h=0,p=0,d=a):h>=0&&(h+=n[s].length,p++),c+=n[s].length,i+=n[s].length,s++;i-=h,s-=p,c-=h,r.push({t:d.t,v:e.slice(i-c,i),s:i-c,e:i})}return r}function su(t,e,n,o,r){let i;const s=e.length;for(let n=0;n<s-1;n++){const s=e[n];t.j[s]?i=t.j[s]:(i=new Kh(o),i.jr=r.slice(),t.j[s]=i),t=i}return i=new Kh(n),i.jr=r.slice(),t.j[e[s-1]]=i,i}function au(t){const e=[],n=[];let o=0;for(;o<t.length;){let r=0;for(;"0123456789".indexOf(t[o+r])>=0;)r++;if(r>0){e.push(n.join(""));for(let e=parseInt(t.substring(o,o+r),10);e>0;e--)n.pop();o+=r}else n.push(t[o]),o++}return e}const lu={defaultProtocol:"http",events:null,format:du,formatHref:du,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function cu(t,e=null){let n=Object.assign({},lu);t&&(n=Object.assign(n,t instanceof cu?t.o:t));const o=n.ignoreTags,r=[];for(let t=0;t<o.length;t++)r.push(o[t].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=r}function du(t){return t}function hu(t,e){this.t="token",this.v=t,this.tk=e}function pu(t,e){class n extends hu{constructor(e,n){super(e,n),this.t=t}}for(const t in e)n.prototype[t]=e[t];return n.t=t,n}cu.prototype={o:lu,ignoreTags:[],defaultRender:t=>t,check(t){return this.get("validate",t.toString(),t)},get(t,e,n){const o=null!=e;let r=this.o[t];return r?("object"==typeof r?(r=n.t in r?r[n.t]:lu[t],"function"==typeof r&&o&&(r=r(e,n))):"function"==typeof r&&o&&(r=r(e,n.t,n)),r):r},getObj(t,e,n){let o=this.o[t];return"function"==typeof o&&null!=e&&(o=o(e,n.t,n)),o},render(t){const e=t.render(this);return(this.get("render",null,t)||this.defaultRender)(e,t.t,t)}},hu.prototype={isLink:!1,toString(){return this.v},toHref(t){return this.toString()},toFormattedString(t){const e=this.toString(),n=t.get("truncate",e,this),o=t.get("format",e,this);return n&&o.length>n?o.substring(0,n)+"…":o},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t=lu.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,n=this.toHref(t.get("defaultProtocol")),o=t.get("formatHref",n,this),r=t.get("tagName",n,e),i=this.toFormattedString(t),s={},a=t.get("className",n,e),l=t.get("target",n,e),c=t.get("rel",n,e),d=t.getObj("attributes",n,e),h=t.getObj("events",n,e);return s.href=o,a&&(s.class=a),l&&(s.target=l),c&&(s.rel=c),d&&Object.assign(s,d),{tagName:r,attributes:s,content:i,eventListeners:h}}};const uu=pu("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),fu=pu("text"),mu=pu("nl"),gu=pu("url",{isLink:!0,toHref(t=lu.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==tp&&t[1].t===Lp}}),yu=t=>new Kh(t);function bu(t,e,n){const o=n[0].s,r=n[n.length-1].e;return new t(e.slice(o,r),n)}const vu="undefined"!=typeof console&&console&&console.warn||(()=>{}),wu={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function ku(t,e=!1){if(wu.initialized&&vu(`linkifyjs: already initialized - will not register custom scheme "${t}" until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error('linkifyjs: incorrect scheme format.\n1. Must only contain digits, lowercase ASCII letters or "-"\n2. Cannot start or end with "-"\n3. "-" cannot repeat');wu.customSchemes.push([t,e])}function xu(t){return wu.initialized||function(){wu.scanner=function(t=[]){const e={};Kh.groups=e;const n=new Kh;null==ou&&(ou=au("aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2")),null==ru&&(ru=au("ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2")),Gh(n,"'",Sp),Gh(n,"{",lp),Gh(n,"}",cp),Gh(n,"[",dp),Gh(n,"]",hp),Gh(n,"(",pp),Gh(n,")",up),Gh(n,"<",fp),Gh(n,">",mp),Gh(n,"(",gp),Gh(n,")",yp),Gh(n,"「",bp),Gh(n,"」",vp),Gh(n,"『",wp),Gh(n,"』",kp),Gh(n,"<",xp),Gh(n,">",Mp),Gh(n,"&",Cp),Gh(n,"*",Tp),Gh(n,"@",Ap),Gh(n,"`",Np),Gh(n,"^",Op),Gh(n,":",Lp),Gh(n,",",Rp),Gh(n,"$",Dp),Gh(n,".",jp),Gh(n,"=",Ip),Gh(n,"!",zp),Gh(n,"-",$p),Gh(n,"%",Pp),Gh(n,"|",Hp),Gh(n,"+",Bp),Gh(n,"#",_p),Gh(n,"?",Vp),Gh(n,'"',Fp),Gh(n,"/",qp),Gh(n,";",Kp),Gh(n,"~",Up),Gh(n,"_",Jp),Gh(n,"\\",Ep),Gh(n,"・",Wp);const o=Uh(n,eu,ip,{[Dh]:!0});Uh(o,eu,o);const r=Uh(o,Qp,Qh,{[zh]:!0}),i=Uh(o,Zp,Zh,{[$h]:!0}),s=Uh(n,Qp,Yh,{[jh]:!0});Uh(s,eu,r),Uh(s,Qp,s),Uh(r,eu,r),Uh(r,Qp,r);const a=Uh(n,Zp,Xh,{[Ih]:!0});Uh(a,Qp),Uh(a,eu,i),Uh(a,Zp,a),Uh(i,eu,i),Uh(i,Qp),Uh(i,Zp,i);const l=Gh(n,"\n",ap,{[Vh]:!0}),c=Gh(n,"\r",sp,{[Vh]:!0}),d=Uh(n,nu,sp,{[Vh]:!0});Gh(n,"",d),Gh(c,"\n",l),Gh(c,"",d),Uh(c,nu,d),Gh(d,"\r"),Gh(d,"\n"),Uh(d,nu,d),Gh(d,"",d);const h=Uh(n,tu,Gp,{[Hh]:!0});Gh(h,"#"),Uh(h,tu,h),Gh(h,"️",h);const p=Gh(h,"‍");Gh(p,"#"),Uh(p,tu,h);const u=[[Qp,s],[eu,r]],f=[[Qp,null],[Zp,a],[eu,i]];for(let t=0;t<ou.length;t++)su(n,ou[t],ep,Yh,u);for(let t=0;t<ru.length;t++)su(n,ru[t],np,Xh,f);Wh(ep,{tld:!0,ascii:!0},e),Wh(np,{utld:!0,alpha:!0},e),su(n,"file",op,Yh,u),su(n,"mailto",op,Yh,u),su(n,"http",rp,Yh,u),su(n,"https",rp,Yh,u),su(n,"ftp",rp,Yh,u),su(n,"ftps",rp,Yh,u),Wh(op,{scheme:!0,ascii:!0},e),Wh(rp,{slashscheme:!0,ascii:!0},e),t=t.sort((t,e)=>t[0]>e[0]?1:-1);for(let e=0;e<t.length;e++){const o=t[e][0],r=t[e][1]?{[Bh]:!0}:{[_h]:!0};o.indexOf("-")>=0?r[Ph]=!0:Qp.test(o)?eu.test(o)?r[zh]=!0:r[jh]=!0:r[Dh]=!0,Jh(n,o,o,r)}return Jh(n,"localhost",tp,{ascii:!0}),n.jd=new Kh(Yp),{start:n,tokens:Object.assign({groups:e},Xp)}}(wu.customSchemes);for(let t=0;t<wu.tokenQueue.length;t++)wu.tokenQueue[t][1]({scanner:wu.scanner});wu.parser=function({groups:t}){const e=t.domain.concat([Cp,Tp,Ap,Ep,Np,Op,Dp,Ip,$p,ip,Pp,Hp,Bp,_p,qp,Yp,Up,Jp]),n=[Sp,Lp,Rp,jp,zp,Pp,Vp,Fp,Kp,fp,mp,lp,cp,hp,dp,pp,up,gp,yp,bp,vp,wp,kp,xp,Mp],o=[Cp,Sp,Tp,Ep,Np,Op,Dp,Ip,$p,lp,cp,Pp,Hp,Bp,_p,Vp,qp,Yp,Up,Jp],r=yu(),i=Gh(r,Up);qh(i,o,i),qh(i,t.domain,i);const s=yu(),a=yu(),l=yu();qh(r,t.domain,s),qh(r,t.scheme,a),qh(r,t.slashscheme,l),qh(s,o,i),qh(s,t.domain,s);const c=Gh(s,Ap);Gh(i,Ap,c),Gh(a,Ap,c),Gh(l,Ap,c);const d=Gh(i,jp);qh(d,o,i),qh(d,t.domain,i);const h=yu();qh(c,t.domain,h),qh(h,t.domain,h);const p=Gh(h,jp);qh(p,t.domain,h);const u=yu(uu);qh(p,t.tld,u),qh(p,t.utld,u),Gh(c,tp,u);const f=Gh(h,$p);Gh(f,$p,f),qh(f,t.domain,h),qh(u,t.domain,h),Gh(u,jp,p),Gh(u,$p,f);const m=Gh(u,Lp);qh(m,t.numeric,uu);const g=Gh(s,$p),y=Gh(s,jp);Gh(g,$p,g),qh(g,t.domain,s),qh(y,o,i),qh(y,t.domain,s);const b=yu(gu);qh(y,t.tld,b),qh(y,t.utld,b),qh(b,t.domain,s),qh(b,o,i),Gh(b,jp,y),Gh(b,$p,g),Gh(b,Ap,c);const v=Gh(b,Lp),w=yu(gu);qh(v,t.numeric,w);const k=yu(gu),x=yu();qh(k,e,k),qh(k,n,x),qh(x,e,k),qh(x,n,x),Gh(b,qp,k),Gh(w,qp,k);const M=Gh(a,Lp),C=Gh(l,Lp),S=Gh(C,qp),T=Gh(S,qp);qh(a,t.domain,s),Gh(a,jp,y),Gh(a,$p,g),qh(l,t.domain,s),Gh(l,jp,y),Gh(l,$p,g),qh(M,t.domain,k),Gh(M,qp,k),Gh(M,Vp,k),qh(T,t.domain,k),qh(T,e,k),Gh(T,qp,k);const A=[[lp,cp],[dp,hp],[pp,up],[fp,mp],[gp,yp],[bp,vp],[wp,kp],[xp,Mp]];for(let t=0;t<A.length;t++){const[o,r]=A[t],i=Gh(k,o);Gh(x,o,i),Gh(i,r,k);const s=yu(gu);qh(i,e,s);const a=yu();qh(i,n),qh(s,e,s),qh(s,n,a),qh(a,e,s),qh(a,n,a),Gh(s,r,k),Gh(a,r,k)}return Gh(r,tp,b),Gh(r,ap,mu),{start:r,tokens:Xp}}(wu.scanner.tokens);for(let t=0;t<wu.pluginQueue.length;t++)wu.pluginQueue[t][1]({scanner:wu.scanner,parser:wu.parser});wu.initialized=!0}(),function(t,e,n){let o=n.length,r=0,i=[],s=[];for(;r<o;){let a=t,l=null,c=null,d=0,h=null,p=-1;for(;r<o&&!(l=a.go(n[r].t));)s.push(n[r++]);for(;r<o&&(c=l||a.go(n[r].t));)l=null,a=c,a.accepts()?(p=0,h=a):p>=0&&p++,r++,d++;if(p<0)r-=d,r<o&&(s.push(n[r]),r++);else{s.length>0&&(i.push(bu(fu,e,s)),s=[]),r-=p,d-=p;const t=h.t,o=n.slice(r-d,r);i.push(bu(t,e,o))}}return s.length>0&&i.push(bu(fu,e,s)),i}(wu.parser.start,t,iu(wu.scanner.start,t))}function Mu(t,e=null,n=null){if(e&&"object"==typeof e){if(n)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);n=e,e=null}const o=new cu(n),r=xu(t),i=[];for(let t=0;t<r.length;t++){const n=r[t];!n.isLink||e&&n.t!==e||!o.check(n)||i.push(n.toFormattedObject(o))}return i}xu.scan=iu;var Cu="[\0-   ᠎ -\u2029  ]",Su=new RegExp(Cu),Tu=new RegExp(`${Cu}$`),Au=new RegExp(Cu,"g");function Eu(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(t=>{const e="string"==typeof t?t:t.scheme;e&&n.push(e)}),!t||t.replace(Au,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var Nu=rl.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(t=>{"string"!=typeof t?ku(t.scheme,t.optionalSlashes):ku(t)})},onDestroy(){Kh.groups={},wu.scanner=null,wu.parser=null,wu.tokenQueue=[],wu.pluginQueue=[],wu.customSchemes=[],wu.initialized=!1},inclusive(){return this.options.autolink},addOptions:()=>({openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!Eu(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>!!t}),addAttributes(){return{href:{default:null,parseHTML:t=>t.getAttribute("href")},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const e=t.getAttribute("href");return!(!e||!this.options.isAllowedUri(e,{defaultValidate:t=>!!Eu(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}))&&null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:t=>!!Eu(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",aa(this.options.HTMLAttributes,t),0]:["a",aa(this.options.HTMLAttributes,{...t,href:""}),0]},markdownTokenName:"link",parseMarkdown:(t,e)=>e.applyMark("link",e.parseInline(t.tokens||[]),{href:t.href,title:t.title||null}),renderMarkdown:(t,e)=>{var n;const o=(null==(n=t.attrs)?void 0:n.href)||"";return`[${e.renderChildren(t)}](${o})`},addCommands(){return{setLink:t=>({chain:e})=>{const{href:n}=t;return!!this.options.isAllowedUri(n,{defaultValidate:t=>!!Eu(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})&&e().setMark(this.name,t).setMeta("preventAutolink",!0).run()},toggleLink:t=>({chain:e})=>{const{href:n}=t||{};return!(n&&!this.options.isAllowedUri(n,{defaultValidate:t=>!!Eu(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}))&&e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[Pl({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:o}=this.options,r=Mu(t).filter(t=>t.isLink&&this.options.isAllowedUri(t.value,{defaultValidate:t=>!!Eu(t,n),protocols:n,defaultProtocol:o}));r.length&&r.forEach(t=>{this.options.shouldAutoLink(t.value)&&e.push({text:t.value,data:{href:t.href},index:t.start})})}return e},type:this.type,getAttributes:t=>{var e;return{href:null==(e=t.data)?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(function(t){return new $e({key:new Be("autolink"),appendTransaction:(e,n,o)=>{const r=e.some(t=>t.docChanged)&&!n.doc.eq(o.doc),i=e.some(t=>t.getMeta("preventAutolink"));if(!r||i)return;const{tr:s}=o;return ya(Ys(n.doc,[...e])).forEach(({newRange:e})=>{const n=function(t,e){const n=[];return t.nodesBetween(e.from,e.to,(t,e)=>{(t=>t.isTextblock)(t)&&n.push({node:t,pos:e})}),n}(o.doc,e);let r,i;if(n.length>1)r=n[0],i=o.doc.textBetween(r.pos,r.pos+r.node.nodeSize,void 0," ");else if(n.length){const t=o.doc.textBetween(e.from,e.to," "," ");if(!Tu.test(t))return;r=n[0],i=o.doc.textBetween(r.pos,e.to,void 0," ")}if(r&&i){const e=i.split(Su).filter(Boolean);if(e.length<=0)return!1;const n=e[e.length-1],l=r.pos+i.lastIndexOf(n);if(!n)return!1;const c=xu(n).map(e=>e.toObject(t.defaultProtocol));if(!(1===(a=c).length?a[0].isLink:3===a.length&&a[1].isLink&&["()","[]"].includes(a[0].value+a[2].value)))return!1;c.filter(t=>t.isLink).map(t=>({...t,from:l+t.start+1,to:l+t.end+1})).filter(t=>!o.schema.marks.code||!o.doc.rangeHasMark(t.from,t.to,o.schema.marks.code)).filter(e=>t.validate(e.value)).filter(e=>t.shouldAutoLink(e.value)).forEach(e=>{ba(e.from,e.to,o.doc).some(e=>e.mark.type===t.type)||s.addMark(e.from,e.to,t.type.create({href:e.href}))})}var a}),s.steps.length?s:void 0}})}({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:t=>this.options.isAllowedUri(t,{defaultValidate:t=>!!Eu(t,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push(function(t){return new $e({key:new Be("handleClickLink"),props:{handleClick:(e,n,o)=>{var r,i;if(0!==o.button)return!1;if(!e.editable)return!1;let s=!1;if(t.enableClickSelection&&(s=t.editor.commands.extendMarkRange(t.type.name)),t.openOnClick){let n=null;if(o.target instanceof HTMLAnchorElement)n=o.target;else{let t=o.target;const e=[];for(;"DIV"!==t.nodeName;)e.push(t),t=t.parentNode;n=e.find(t=>"A"===t.nodeName)}if(!n)return s;const a=ga(e.state,t.type.name),l=null!=(r=null==n?void 0:n.href)?r:a.href,c=null!=(i=null==n?void 0:n.target)?i:a.target;n&&l&&(window.open(l,c),s=!0)}return s}}})}({type:this.type,editor:this.editor,openOnClick:"whenNotEditable"===this.options.openOnClick||this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(function(t){return new $e({key:new Be("handlePasteLink"),props:{handlePaste:(e,n,o)=>{const{shouldAutoLink:r}=t,{state:i}=e,{selection:s}=i,{empty:a}=s;if(a)return!1;let l="";o.content.forEach(t=>{l+=t.textContent});const c=Mu(l,{defaultProtocol:t.defaultProtocol}).find(t=>t.isLink&&t.value===l);return!(!l||!c||void 0!==r&&!r(c.href))&&t.editor.commands.setMark(t.type,{href:c.href})}}})}({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),Ou=Object.defineProperty,Lu="textStyle",Ru=/^\s*([-+*])\s$/,Du=$l.create({name:"bulletList",addOptions:()=>({itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}),group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML:()=>[{tag:"ul"}],renderHTML({HTMLAttributes:t}){return["ul",aa(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>"list"!==t.type||t.ordered?[]:{type:"bulletList",content:t.items?e.parseChildren(t.items):[]},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,"\n"):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes("listItem",this.editor.getAttributes(Lu)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=Tl({find:Ru,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Tl({find:Ru,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Lu),editor:this.editor})),[t]}}),ju=$l.create({name:"listItem",addOptions:()=>({HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}),content:"paragraph block*",defining:!0,parseHTML:()=>[{tag:"li"}],renderHTML({HTMLAttributes:t}){return["li",aa(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:(t,e)=>{if("list_item"!==t.type)return[];let n=[];if(t.tokens&&t.tokens.length>0)if(t.tokens.some(t=>"paragraph"===t.type))n=e.parseChildren(t.tokens);else{const o=t.tokens[0];if(o&&"text"===o.type&&o.tokens&&o.tokens.length>0){if(n=[{type:"paragraph",content:e.parseInline(o.tokens)}],t.tokens.length>1){const o=t.tokens.slice(1),r=e.parseChildren(o);n.push(...r)}}else n=e.parseChildren(t.tokens)}return 0===n.length&&(n=[{type:"paragraph",content:[]}]),{type:"listItem",content:n}},renderMarkdown:(t,e,n)=>zl(t,e,t=>"bulletList"===t.parentType?"- ":"orderedList"===t.parentType?`${t.index+1}. `:"- ",n),addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}});((t,e)=>{for(var n in e)Ou(t,n,{get:e[n],enumerable:!0})})({},{findListItemPos:()=>Iu,getNextListDepth:()=>zu,handleBackspace:()=>Bu,handleDelete:()=>Fu,hasListBefore:()=>$u,hasListItemAfter:()=>Wu,hasListItemBefore:()=>Pu,listItemHasSubList:()=>Hu,nextListIsDeeper:()=>_u,nextListIsHigher:()=>Vu});var Iu=(t,e)=>{const{$from:n}=e.selection,o=Yi(t,e.schema);let r=null,i=n.depth,s=n.pos,a=null;for(;i>0&&null===a;)r=n.node(i),r.type===o?a=i:(i-=1,s-=1);return null===a?null:{$pos:e.doc.resolve(s),depth:a}},zu=(t,e)=>{const n=Iu(t,e);if(!n)return!1;const[,o]=((t,e,n,o=20)=>{const r=t.doc.resolve(n);let i=o,s=null;for(;i>0&&null===s;){const t=r.node(i);(null==t?void 0:t.type.name)===e?s=t:i-=1}return[s,i]})(e,t,n.$pos.pos+4);return o},$u=(t,e,n)=>{const{$anchor:o}=t.selection,r=Math.max(0,o.pos-2),i=t.doc.resolve(r).node();return!(!i||!n.includes(i.type.name))},Pu=(t,e)=>{var n;const{$anchor:o}=e.selection,r=e.doc.resolve(o.pos-2);return 0!==r.index()&&(null==(n=r.nodeBefore)?void 0:n.type.name)===t},Hu=(t,e,n)=>{if(!n)return!1;const o=Yi(t,e.schema);let r=!1;return n.descendants(t=>{t.type===o&&(r=!0)}),r},Bu=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!Rs(t.state,e)&&$u(t.state,e,n)){const{$anchor:n}=t.state.selection,o=t.state.doc.resolve(n.before()-1),r=[];o.node().descendants((t,n)=>{t.type.name===e&&r.push({node:t,pos:n})});const i=r.at(-1);if(!i)return!1;const s=t.state.doc.resolve(o.start()+i.pos+1);return t.chain().cut({from:n.start()-1,to:n.end()+1},s.end()).joinForward().run()}if(!Rs(t.state,e))return!1;if(!(t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)})(t.state))return!1;const o=Iu(e,t.state);if(!o)return!1;const r=t.state.doc.resolve(o.$pos.pos-2).node(o.depth),i=Hu(e,t.state,r);return Pu(e,t.state)&&!i?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},_u=(t,e)=>{const n=zu(t,e),o=Iu(t,e);return!(!o||!n)&&n>o.depth},Vu=(t,e)=>{const n=zu(t,e),o=Iu(t,e);return!(!o||!n)&&n<o.depth},Fu=(t,e)=>{if(!Rs(t.state,e))return!1;if(!((t,e)=>{const{$from:n,$to:o,$anchor:r}=t.selection;if(e){const n=Zs(t=>t.type.name===e)(t.selection);if(!n)return!1;const o=t.doc.resolve(n.pos+1);return r.pos+1===o.end()}return!(o.parentOffset<o.parent.nodeSize-2||n.pos!==o.pos)})(t.state,e))return!1;const{selection:n}=t.state,{$from:o,$to:r}=n;return!(!n.empty&&o.sameParent(r))&&(_u(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():Vu(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward())},Wu=(t,e)=>{var n;const{$anchor:o}=e.selection,r=e.doc.resolve(o.pos-o.parentOffset-2);return r.index()!==r.parent.childCount-1&&(null==(n=r.nodeAfter)?void 0:n.type.name)===t},Ku=cl.create({name:"listKeymap",addOptions:()=>({listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}),addKeyboardShortcuts(){return{Delete:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{void 0!==t.state.schema.nodes[n]&&Fu(t,n)&&(e=!0)}),e},"Mod-Delete":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{void 0!==t.state.schema.nodes[n]&&Fu(t,n)&&(e=!0)}),e},Backspace:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:o})=>{void 0!==t.state.schema.nodes[n]&&Bu(t,n,o)&&(e=!0)}),e},"Mod-Backspace":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:o})=>{void 0!==t.state.schema.nodes[n]&&Bu(t,n,o)&&(e=!0)}),e}}}}),qu=/^(\s*)(\d+)\.\s+(.*)$/,Uu=/^\s/;function Ju(t,e,n){var o;const r=[];let i=0;for(;i<t.length;){const s=t[i];if(s.indent===e){const a=s.content.split("\n"),l=(null==(o=a[0])?void 0:o.trim())||"",c=[];l&&c.push({type:"paragraph",raw:l,tokens:n.inlineTokens(l)});const d=a.slice(1).join("\n").trim();if(d){const t=n.blockTokens(d);c.push(...t)}let h=i+1;const p=[];for(;h<t.length&&t[h].indent>e;)p.push(t[h]),h+=1;if(p.length>0){const t=Math.min(...p.map(t=>t.indent)),e=Ju(p,t,n);c.push({type:"list",ordered:!0,start:p[0].number,items:e,raw:p.map(t=>t.raw).join("\n")})}r.push({type:"list_item",raw:s.raw,tokens:c}),i=h}else i+=1}return r}var Gu="textStyle",Yu=/^(\d+)\.\s$/,Xu=$l.create({name:"orderedList",addOptions:()=>({itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}),group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes:()=>({start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>t.getAttribute("type")}}),parseHTML:()=>[{tag:"ol"}],renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return 1===e?["ol",aa(this.options.HTMLAttributes,n),0]:["ol",aa(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>{if("list"!==t.type||!t.ordered)return[];const n=t.start||1,o=t.items?function(t,e){return t.map(t=>{if("list_item"!==t.type)return e.parseChildren([t])[0];const n=[];return t.tokens&&t.tokens.length>0&&t.tokens.forEach(t=>{if("paragraph"===t.type||"list"===t.type||"blockquote"===t.type||"code"===t.type)n.push(...e.parseChildren([t]));else if("text"===t.type&&t.tokens){const o=e.parseChildren([t]);n.push({type:"paragraph",content:o})}else{const o=e.parseChildren([t]);o.length>0&&n.push(...o)}}),{type:"listItem",content:n}})}(t.items,e):[];return 1!==n?{type:"orderedList",attrs:{start:n},content:o}:{type:"orderedList",content:o}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,"\n"):"",markdownTokenizer:{name:"orderedList",level:"block",start:t=>{const e=t.match(/^(\s*)(\d+)\.\s+/),n=null==e?void 0:e.index;return void 0!==n?n:-1},tokenize:(t,e,n)=>{var o;const r=t.split("\n"),[i,s]=function(t){const e=[];let n=0,o=0;for(;n<t.length;){const r=t[n],i=r.match(qu);if(!i)break;const[,s,a,l]=i,c=s.length;let d=l,h=n+1;const p=[r];for(;h<t.length;){const e=t[h];if(e.match(qu))break;if(""===e.trim())p.push(e),d+="\n",h+=1;else{if(!e.match(Uu))break;p.push(e),d+=`\n${e.slice(c+2)}`,h+=1}}e.push({indent:c,number:parseInt(a,10),content:d.trim(),raw:p.join("\n")}),o=h,n=h}return[e,o]}(r);if(0===i.length)return;const a=Ju(i,0,n);return 0!==a.length?{type:"list",ordered:!0,start:(null==(o=i[0])?void 0:o.number)||1,items:a,raw:r.slice(0,s).join("\n")}:void 0}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes("listItem",this.editor.getAttributes(Gu)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=Tl({find:Yu,type:this.type,getAttributes:t=>({start:+t[1]}),joinPredicate:(t,e)=>e.childCount+e.attrs.start===+t[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Tl({find:Yu,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:t=>({start:+t[1],...this.editor.getAttributes(Gu)}),joinPredicate:(t,e)=>e.childCount+e.attrs.start===+t[1],editor:this.editor})),[t]}}),Qu=/^\s*(\[([( |x])?\])\s$/,Zu=$l.create({name:"taskItem",addOptions:()=>({nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}),content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes:()=>({checked:{default:!1,keepOnSplit:!1,parseHTML:t=>{const e=t.getAttribute("data-checked");return""===e||"true"===e},renderHTML:t=>({"data-checked":t.checked})}}),parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:t,HTMLAttributes:e}){return["li",aa(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(t,e)=>{const n=[];if(t.tokens&&t.tokens.length>0?n.push(e.createNode("paragraph",{},e.parseInline(t.tokens))):t.text?n.push(e.createNode("paragraph",{},[e.createNode("text",{text:t.text})])):n.push(e.createNode("paragraph",{},[])),t.nestedTokens&&t.nestedTokens.length>0){const o=e.parseChildren(t.nestedTokens);n.push(...o)}return e.createNode("taskItem",{checked:t.checked||!1},n)},renderMarkdown:(t,e)=>{var n;return zl(t,e,`- [${(null==(n=t.attrs)?void 0:n.checked)?"x":" "}] `)},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:o})=>{const r=document.createElement("li"),i=document.createElement("label"),s=document.createElement("span"),a=document.createElement("input"),l=document.createElement("div"),c=t=>{var e,n;a.ariaLabel=(null==(n=null==(e=this.options.a11y)?void 0:e.checkboxLabel)?void 0:n.call(e,t,a.checked))||`Task item checkbox for ${t.textContent||"empty task item"}`};return c(t),i.contentEditable="false",a.type="checkbox",a.addEventListener("mousedown",t=>t.preventDefault()),a.addEventListener("change",e=>{if(!o.isEditable&&!this.options.onReadOnlyChecked)return void(a.checked=!a.checked);const{checked:r}=e.target;o.isEditable&&"function"==typeof n&&o.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:t})=>{const e=n();if("number"!=typeof e)return!1;const o=t.doc.nodeAt(e);return t.setNodeMarkup(e,void 0,{...null==o?void 0:o.attrs,checked:r}),!0}).run(),!o.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,r)||(a.checked=!a.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([t,e])=>{r.setAttribute(t,e)}),r.dataset.checked=t.attrs.checked,a.checked=t.attrs.checked,i.append(a,s),r.append(i,l),Object.entries(e).forEach(([t,e])=>{r.setAttribute(t,e)}),{dom:r,contentDOM:l,update:t=>t.type===this.type&&(r.dataset.checked=t.attrs.checked,a.checked=t.attrs.checked,c(t),!0)}}},addInputRules(){return[Tl({find:Qu,type:this.type,getAttributes:t=>({checked:"x"===t[t.length-1]})})]}}),tf=$l.create({name:"taskList",addOptions:()=>({itemTypeName:"taskItem",HTMLAttributes:{}}),group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",aa(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,"\n"):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const n=null==(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))?void 0:e.index;return void 0!==n?n:-1},tokenize(t,e,n){const o=t=>{const e=Il(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:t=>({indentLevel:t[1].length,mainContent:t[4],checked:"x"===t[3].toLowerCase()}),createToken:(t,e)=>({type:"taskItem",raw:"",mainContent:t.mainContent,indentLevel:t.indentLevel,checked:t.checked,text:t.mainContent,tokens:n.inlineTokens(t.mainContent),nestedTokens:e}),customNestedParser:o},n);return e?[{type:"taskList",raw:e.raw,items:e.items}]:n.blockTokens(t)},r=Il(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:t=>({indentLevel:t[1].length,mainContent:t[4],checked:"x"===t[3].toLowerCase()}),createToken:(t,e)=>({type:"taskItem",raw:"",mainContent:t.mainContent,indentLevel:t.indentLevel,checked:t.checked,text:t.mainContent,tokens:n.inlineTokens(t.mainContent),nestedTokens:e}),customNestedParser:o},n);if(r)return{type:"taskList",raw:r.raw,items:r.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}}),ef=(cl.create({name:"listKit",addExtensions(){const t=[];return!1!==this.options.bulletList&&t.push(Du.configure(this.options.bulletList)),!1!==this.options.listItem&&t.push(ju.configure(this.options.listItem)),!1!==this.options.listKeymap&&t.push(Ku.configure(this.options.listKeymap)),!1!==this.options.orderedList&&t.push(Xu.configure(this.options.orderedList)),!1!==this.options.taskItem&&t.push(Zu.configure(this.options.taskItem)),!1!==this.options.taskList&&t.push(tf.configure(this.options.taskList)),t}}),$l.create({name:"paragraph",priority:1e3,addOptions:()=>({HTMLAttributes:{}}),group:"block",content:"inline*",parseHTML:()=>[{tag:"p"}],renderHTML({HTMLAttributes:t}){return["p",aa(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{const n=t.tokens||[];return 1===n.length&&"image"===n[0].type?e.parseChildren([n[0]]):e.createNode("paragraph",void 0,e.parseInline(n))},renderMarkdown:(t,e)=>t&&Array.isArray(t.content)?e.renderChildren(t.content):"",addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}})),nf=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,of=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,rf=rl.create({name:"strike",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>!!t.includes("line-through")&&{}}],renderHTML({HTMLAttributes:t}){return["s",aa(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:(t,e)=>e.applyMark("strike",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`~~${e.renderChildren(t)}~~`,addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Ml({find:nf,type:this.type})]},addPasteRules(){return[Pl({find:of,type:this.type})]}}),sf=$l.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),af=rl.create({name:"underline",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>!!t.includes("underline")&&{}}],renderHTML({HTMLAttributes:t}){return["u",aa(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown:(t,e)=>`++${e.renderChildren(t)}++`,markdownTokenizer:{name:"underline",level:"inline",start:t=>t.indexOf("++"),tokenize(t,e,n){const o=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!o)return;const r=o[2].trim();return{type:"underline",raw:o[0],text:r,tokens:n.inlineTokens(r)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function lf(t={}){return new $e({view:e=>new cf(e,t)})}class cf{constructor(t,e){var n;this.editorView=t,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=null!==(n=e.width)&&void 0!==n?n:1,this.color=!1===e.color?void 0:e.color||"black",this.class=e.class,this.handlers=["dragover","dragend","drop","dragleave"].map(e=>{let n=t=>{this[e](t)};return t.dom.addEventListener(e,n),{name:e,handler:n}})}destroy(){this.handlers.forEach(({name:t,handler:e})=>this.editorView.dom.removeEventListener(t,e))}update(t,e){null!=this.cursorPos&&e.doc!=t.state.doc&&(this.cursorPos>t.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(t){t!=this.cursorPos&&(this.cursorPos=t,null==t?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let t,e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,o=this.editorView.dom,r=o.getBoundingClientRect(),i=r.width/o.offsetWidth,s=r.height/o.offsetHeight;if(n){let n=e.nodeBefore,o=e.nodeAfter;if(n||o){let e=this.editorView.nodeDOM(this.cursorPos-(n?n.nodeSize:0));if(e){let r=e.getBoundingClientRect(),i=n?r.bottom:r.top;n&&o&&(i=(i+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let a=this.width/2*s;t={left:r.left,right:r.right,top:i-a,bottom:i+a}}}}if(!t){let e=this.editorView.coordsAtPos(this.cursorPos),n=this.width/2*i;t={left:e.left-n,right:e.left+n,top:e.top,bottom:e.bottom}}let a,l,c=this.editorView.dom.offsetParent;if(this.element||(this.element=c.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n),!c||c==document.body&&"static"==getComputedStyle(c).position)a=-pageXOffset,l=-pageYOffset;else{let t=c.getBoundingClientRect(),e=t.width/c.offsetWidth,n=t.height/c.offsetHeight;a=t.left-c.scrollLeft*e,l=t.top-c.scrollTop*n}this.element.style.left=(t.left-a)/i+"px",this.element.style.top=(t.top-l)/s+"px",this.element.style.width=(t.right-t.left)/i+"px",this.element.style.height=(t.bottom-t.top)/s+"px"}scheduleRemoval(t){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),t)}dragover(t){if(!this.editorView.editable)return;let e=this.editorView.posAtCoords({left:t.clientX,top:t.clientY}),n=e&&e.inside>=0&&this.editorView.state.doc.nodeAt(e.inside),o=n&&n.type.spec.disableDropCursor,r="function"==typeof o?o(this.editorView,e,t):o;if(e&&!r){let t=e.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let e=ee(this.editorView.state.doc,t,this.editorView.dragging.slice);null!=e&&(t=e)}this.setCursor(t),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(t){this.editorView.dom.contains(t.relatedTarget)||this.setCursor(null)}}class df extends be{constructor(t){super(t,t)}map(t,e){let n=t.resolve(e.map(this.head));return df.valid(n)?new df(n):be.near(n)}content(){return A.empty}eq(t){return t instanceof df&&t.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(t,e){if("number"!=typeof e.pos)throw new RangeError("Invalid input for GapCursor.fromJSON");return new df(t.resolve(e.pos))}getBookmark(){return new hf(this.anchor)}static valid(t){let e=t.parent;if(e.isTextblock||!function(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),o=t.node(e);if(0!=n)for(let t=o.child(n-1);;t=t.lastChild){if(0==t.childCount&&!t.inlineContent||t.isAtom||t.type.spec.isolating)return!0;if(t.inlineContent)return!1}else if(o.type.spec.isolating)return!0}return!0}(t)||!function(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),o=t.node(e);if(n!=o.childCount)for(let t=o.child(n);;t=t.firstChild){if(0==t.childCount&&!t.inlineContent||t.isAtom||t.type.spec.isolating)return!0;if(t.inlineContent)return!1}else if(o.type.spec.isolating)return!0}return!0}(t))return!1;let n=e.type.spec.allowGapCursor;if(null!=n)return n;let o=e.contentMatchAt(t.index()).defaultType;return o&&o.isTextblock}static findGapCursorFrom(t,e,n=!1){t:for(;;){if(!n&&df.valid(t))return t;let o=t.pos,r=null;for(let n=t.depth;;n--){let i=t.node(n);if(e>0?t.indexAfter(n)<i.childCount:t.index(n)>0){r=i.child(e>0?t.indexAfter(n):t.index(n)-1);break}if(0==n)return null;o+=e;let s=t.doc.resolve(o);if(df.valid(s))return s}for(;;){let i=e>0?r.firstChild:r.lastChild;if(!i){if(r.isAtom&&!r.isText&&!Ce.isSelectable(r)){t=t.doc.resolve(o+r.nodeSize*e),n=!1;continue t}break}r=i,o+=e;let s=t.doc.resolve(o);if(df.valid(s))return s}return null}}}df.prototype.visible=!1,df.findFrom=df.findGapCursorFrom,be.jsonID("gapcursor",df);class hf{constructor(t){this.pos=t}map(t){return new hf(t.map(this.pos))}resolve(t){let e=t.resolve(this.pos);return df.valid(e)?new df(e):be.near(e)}}const pf=$i({ArrowLeft:uf("horiz",-1),ArrowRight:uf("horiz",1),ArrowUp:uf("vert",-1),ArrowDown:uf("vert",1)});function uf(t,e){const n="vert"==t?e>0?"down":"up":e>0?"right":"left";return function(t,o,r){let i=t.selection,s=e>0?i.$to:i.$from,a=i.empty;if(i instanceof xe){if(!r.endOfTextblock(n)||0==s.depth)return!1;a=!1,s=t.doc.resolve(e>0?s.after():s.before())}let l=df.findGapCursorFrom(s,e,a);return!!l&&(o&&o(t.tr.setSelection(new df(l))),!0)}}function ff(t,e,n){if(!t||!t.editable)return!1;let o=t.state.doc.resolve(e);if(!df.valid(o))return!1;let r=t.posAtCoords({left:n.clientX,top:n.clientY});return!(r&&r.inside>-1&&Ce.isSelectable(t.state.doc.nodeAt(r.inside))||(t.dispatch(t.state.tr.setSelection(new df(o))),0))}function mf(t,e){if("insertCompositionText"!=e.inputType||!(t.state.selection instanceof df))return!1;let{$from:n}=t.state.selection,o=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!o)return!1;let r=k.empty;for(let t=o.length-1;t>=0;t--)r=k.from(o[t].createAndFill(null,r));let i=t.state.tr.replace(n.pos,n.pos,new A(r,0,0));return i.setSelection(xe.near(i.doc.resolve(n.pos+1))),t.dispatch(i),!1}function gf(t){if(!(t.selection instanceof df))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",Xr.create(t.doc,[Jr.widget(t.selection.head,e,{key:"gapcursor"})])}var yf=200,bf=function(){};bf.prototype.append=function(t){return t.length?(t=bf.from(t),!this.length&&t||t.length<yf&&this.leafAppend(t)||this.length<yf&&t.leafPrepend(this)||this.appendInner(t)):this},bf.prototype.prepend=function(t){return t.length?bf.from(t).append(this):this},bf.prototype.appendInner=function(t){return new wf(this,t)},bf.prototype.slice=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=this.length),t>=e?bf.empty:this.sliceInner(Math.max(0,t),Math.min(this.length,e))},bf.prototype.get=function(t){if(!(t<0||t>=this.length))return this.getInner(t)},bf.prototype.forEach=function(t,e,n){void 0===e&&(e=0),void 0===n&&(n=this.length),e<=n?this.forEachInner(t,e,n,0):this.forEachInvertedInner(t,e,n,0)},bf.prototype.map=function(t,e,n){void 0===e&&(e=0),void 0===n&&(n=this.length);var o=[];return this.forEach(function(e,n){return o.push(t(e,n))},e,n),o},bf.from=function(t){return t instanceof bf?t:t&&t.length?new vf(t):bf.empty};var vf=function(t){function e(e){t.call(this),this.values=e}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(t,n){return 0==t&&n==this.length?this:new e(this.values.slice(t,n))},e.prototype.getInner=function(t){return this.values[t]},e.prototype.forEachInner=function(t,e,n,o){for(var r=e;r<n;r++)if(!1===t(this.values[r],o+r))return!1},e.prototype.forEachInvertedInner=function(t,e,n,o){for(var r=e-1;r>=n;r--)if(!1===t(this.values[r],o+r))return!1},e.prototype.leafAppend=function(t){if(this.length+t.length<=yf)return new e(this.values.concat(t.flatten()))},e.prototype.leafPrepend=function(t){if(this.length+t.length<=yf)return new e(t.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e}(bf);bf.empty=new vf([]);var wf=function(t){function e(e,n){t.call(this),this.left=e,this.right=n,this.length=e.length+n.length,this.depth=Math.max(e.depth,n.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(t){return t<this.left.length?this.left.get(t):this.right.get(t-this.left.length)},e.prototype.forEachInner=function(t,e,n,o){var r=this.left.length;return!(e<r&&!1===this.left.forEachInner(t,e,Math.min(n,r),o))&&!(n>r&&!1===this.right.forEachInner(t,Math.max(e-r,0),Math.min(this.length,n)-r,o+r))&&void 0},e.prototype.forEachInvertedInner=function(t,e,n,o){var r=this.left.length;return!(e>r&&!1===this.right.forEachInvertedInner(t,e-r,Math.max(n,r)-r,o+r))&&!(n<r&&!1===this.left.forEachInvertedInner(t,Math.min(e,r),n,o))&&void 0},e.prototype.sliceInner=function(t,e){if(0==t&&e==this.length)return this;var n=this.left.length;return e<=n?this.left.slice(t,e):t>=n?this.right.slice(t-n,e-n):this.left.slice(t,n).append(this.right.slice(0,e-n))},e.prototype.leafAppend=function(t){var n=this.right.leafAppend(t);if(n)return new e(this.left,n)},e.prototype.leafPrepend=function(t){var n=this.left.leafPrepend(t);if(n)return new e(n,this.right)},e.prototype.appendInner=function(t){return this.left.depth>=Math.max(this.right.depth,t.depth)+1?new e(this.left,new e(this.right,t)):new e(this,t)},e}(bf);const kf=bf;class xf{constructor(t,e){this.items=t,this.eventCount=e}popEvent(t,e){if(0==this.eventCount)return null;let n,o,r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}e&&(n=this.remapping(r,this.items.length),o=n.maps.length);let i,s,a=t.tr,l=[],c=[];return this.items.forEach((t,e)=>{if(!t.step)return n||(n=this.remapping(r,e+1),o=n.maps.length),o--,void c.push(t);if(n){c.push(new Mf(t.map));let e,r=t.step.map(n.slice(o));r&&a.maybeStep(r).doc&&(e=a.mapping.maps[a.mapping.maps.length-1],l.push(new Mf(e,void 0,void 0,l.length+c.length))),o--,e&&n.appendMap(e,o)}else a.maybeStep(t.step);return t.selection?(i=n?t.selection.map(n.slice(o)):t.selection,s=new xf(this.items.slice(0,r).append(c.reverse().concat(l)),this.eventCount-1),!1):void 0},this.items.length,0),{remaining:s,transform:a,selection:i}}addTransform(t,e,n,o){let r=[],i=this.eventCount,s=this.items,a=!o&&s.length?s.get(s.length-1):null;for(let n=0;n<t.steps.length;n++){let l,c=t.steps[n].invert(t.docs[n]),d=new Mf(t.mapping.maps[n],c,e);(l=a&&a.merge(d))&&(d=l,n?r.pop():s=s.slice(0,s.length-1)),r.push(d),e&&(i++,e=void 0),o||(a=d)}let l=i-n.depth;return l>Sf&&(s=function(t,e){let n;return t.forEach((t,o)=>{if(t.selection&&0==e--)return n=o,!1}),t.slice(n)}(s,l),i-=l),new xf(s.append(r),i)}remapping(t,e){let n=new Rt;return this.items.forEach((e,o)=>{let r=null!=e.mirrorOffset&&o-e.mirrorOffset>=t?n.maps.length-e.mirrorOffset:void 0;n.appendMap(e.map,r)},t,e),n}addMaps(t){return 0==this.eventCount?this:new xf(this.items.append(t.map(t=>new Mf(t))),this.eventCount)}rebased(t,e){if(!this.eventCount)return this;let n=[],o=Math.max(0,this.items.length-e),r=t.mapping,i=t.steps.length,s=this.eventCount;this.items.forEach(t=>{t.selection&&s--},o);let a=e;this.items.forEach(e=>{let o=r.getMirror(--a);if(null==o)return;i=Math.min(i,o);let l=r.maps[o];if(e.step){let i=t.steps[o].invert(t.docs[o]),c=e.selection&&e.selection.map(r.slice(a+1,o));c&&s++,n.push(new Mf(l,i,c))}else n.push(new Mf(l))},o);let l=[];for(let t=e;t<i;t++)l.push(new Mf(r.maps[t]));let c=this.items.slice(0,o).append(l).append(n),d=new xf(c,s);return d.emptyItemCount()>500&&(d=d.compress(this.items.length-n.length)),d}emptyItemCount(){let t=0;return this.items.forEach(e=>{e.step||t++}),t}compress(t=this.items.length){let e=this.remapping(0,t),n=e.maps.length,o=[],r=0;return this.items.forEach((i,s)=>{if(s>=t)o.push(i),i.selection&&r++;else if(i.step){let t=i.step.map(e.slice(n)),s=t&&t.getMap();if(n--,s&&e.appendMap(s,n),t){let a=i.selection&&i.selection.map(e.slice(n));a&&r++;let l,c=new Mf(s.invert(),t,a),d=o.length-1;(l=o.length&&o[d].merge(c))?o[d]=l:o.push(c)}}else i.map&&n--},this.items.length,0),new xf(kf.from(o.reverse()),r)}}xf.empty=new xf(kf.empty,0);class Mf{constructor(t,e,n,o){this.map=t,this.step=e,this.selection=n,this.mirrorOffset=o}merge(t){if(this.step&&t.step&&!t.selection){let e=t.step.merge(this.step);if(e)return new Mf(e.getMap().invert(),e,this.selection)}}}class Cf{constructor(t,e,n,o,r){this.done=t,this.undone=e,this.prevRanges=n,this.prevTime=o,this.prevComposition=r}}const Sf=20;function Tf(t){let e=[];for(let n=t.length-1;n>=0&&0==e.length;n--)t[n].forEach((t,n,o,r)=>e.push(o,r));return e}function Af(t,e){if(!t)return null;let n=[];for(let o=0;o<t.length;o+=2){let r=e.map(t[o],1),i=e.map(t[o+1],-1);r<=i&&n.push(r,i)}return n}let Ef=!1,Nf=null;function Of(t){let e=t.plugins;if(Nf!=e){Ef=!1,Nf=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){Ef=!0;break}}return Ef}const Lf=new Be("history"),Rf=new Be("closeHistory");function Df(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new $e({key:Lf,state:{init:()=>new Cf(xf.empty,xf.empty,null,0,-1),apply:(e,n,o)=>function(t,e,n,o){let r,i=n.getMeta(Lf);if(i)return i.historyState;n.getMeta(Rf)&&(t=new Cf(t.done,t.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(0==n.steps.length)return t;if(s&&s.getMeta(Lf))return s.getMeta(Lf).redo?new Cf(t.done.addTransform(n,void 0,o,Of(e)),t.undone,Tf(n.mapping.maps),t.prevTime,t.prevComposition):new Cf(t.done,t.undone.addTransform(n,void 0,o,Of(e)),null,t.prevTime,t.prevComposition);if(!1===n.getMeta("addToHistory")||s&&!1===s.getMeta("addToHistory"))return(r=n.getMeta("rebased"))?new Cf(t.done.rebased(n,r),t.undone.rebased(n,r),Af(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Cf(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Af(t.prevRanges,n.mapping),t.prevTime,t.prevComposition);{let r=n.getMeta("composition"),i=0==t.prevTime||!s&&t.prevComposition!=r&&(t.prevTime<(n.time||0)-o.newGroupDelay||!function(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((t,o)=>{for(let r=0;r<e.length;r+=2)t<=e[r+1]&&o>=e[r]&&(n=!0)}),n}(n,t.prevRanges)),a=s?Af(t.prevRanges,n.mapping):Tf(n.mapping.maps);return new Cf(t.done.addTransform(n,i?e.selection.getBookmark():void 0,o,Of(e)),xf.empty,a,n.time,null==r?t.prevComposition:r)}}(n,o,e,t)},config:t,props:{handleDOMEvents:{beforeinput(t,e){let n=e.inputType,o="historyUndo"==n?If:"historyRedo"==n?zf:null;return!!o&&(e.preventDefault(),o(t.state,t.dispatch))}}}})}function jf(t,e){return(n,o)=>{let r=Lf.getState(n);if(!r||0==(t?r.undone:r.done).eventCount)return!1;if(o){let i=function(t,e,n){let o=Of(e),r=Lf.get(e).spec.config,i=(n?t.undone:t.done).popEvent(e,o);if(!i)return null;let s=i.selection.resolve(i.transform.doc),a=(n?t.done:t.undone).addTransform(i.transform,e.selection.getBookmark(),r,o),l=new Cf(n?a:i.remaining,n?i.remaining:a,null,0,-1);return i.transform.setSelection(s).setMeta(Lf,{redo:n,historyState:l})}(r,n,t);i&&o(e?i.scrollIntoView():i)}return!0}}const If=jf(!1,!0),zf=jf(!0,!0);jf(!1,!1),jf(!0,!1),cl.create({name:"characterCount",addOptions:()=>({limit:null,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(t=>""!==t).length}),addStorage:()=>({characters:()=>0,words:()=>0}),onBeforeCreate(){this.storage.characters=t=>{const e=(null==t?void 0:t.node)||this.editor.state.doc;if("textSize"===((null==t?void 0:t.mode)||this.options.mode)){const t=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(t)}return e.nodeSize},this.storage.words=t=>{const e=(null==t?void 0:t.node)||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new $e({key:new Be("characterCount"),appendTransaction:(e,n,o)=>{if(t)return;const r=this.options.limit;if(null==r||0===r)return void(t=!0);const i=this.storage.characters({node:o.doc});if(i>r){const e=0,n=i-r;console.warn(`[CharacterCount] Initial content exceeded limit of ${r} characters. Content was automatically trimmed.`);const s=o.tr.deleteRange(e,n);return t=!0,s}t=!0},filterTransaction:(t,e)=>{const n=this.options.limit;if(!t.docChanged||0===n||null==n)return!0;const o=this.storage.characters({node:e.doc}),r=this.storage.characters({node:t.doc});if(r<=n)return!0;if(o>n&&r>n&&r<=o)return!0;if(o>n&&r>n&&r>o)return!1;if(!t.getMeta("paste"))return!1;const i=t.selection.$head.pos,s=i-(r-n),a=i;return t.deleteRange(s,a),!(this.storage.characters({node:t.doc})>n)}})]}});var $f=cl.create({name:"dropCursor",addOptions:()=>({color:"currentColor",width:1,class:void 0}),addProseMirrorPlugins(){return[lf(this.options)]}}),Pf=(cl.create({name:"focus",addOptions:()=>({className:"has-focus",mode:"all"}),addProseMirrorPlugins(){return[new $e({key:new Be("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:o}=this.editor,{anchor:r}=e,i=[];if(!n||!o)return Xr.create(t,[]);let s=0;"deepest"===this.options.mode&&t.descendants((t,e)=>{if(!t.isText)return r>=e&&r<=e+t.nodeSize-1&&void(s+=1)});let a=0;return t.descendants((t,e)=>!t.isText&&(r>=e&&r<=e+t.nodeSize-1&&(a+=1,"deepest"===this.options.mode&&s-a>0||"shallowest"===this.options.mode&&a>1?"deepest"===this.options.mode:void i.push(Jr.node(e,e+t.nodeSize,{class:this.options.className}))))),Xr.create(t,i)}}})]}}),cl.create({name:"gapCursor",addProseMirrorPlugins:()=>[new $e({props:{decorations:gf,createSelectionBetween:(t,e,n)=>e.pos==n.pos&&df.valid(n)?new df(n):null,handleClick:ff,handleKeyDown:pf,handleDOMEvents:{beforeinput:mf}}})],extendNodeSchema(t){var e;return{allowGapCursor:null!=(e=ra(ta(t,"allowGapCursor",{name:t.name,options:t.options,storage:t.storage})))?e:null}}})),Hf=cl.create({name:"placeholder",addOptions:()=>({emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}),addProseMirrorPlugins(){return[new $e({key:new Be("placeholder"),props:{decorations:({doc:t,selection:e})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:o}=e,r=[];if(!n)return null;const i=this.editor.isEmpty;return t.descendants((t,e)=>{const n=o>=e&&o<=e+t.nodeSize,s=!t.isLeaf&&Ca(t);if((n||!this.options.showOnlyCurrent)&&s){const o=[this.options.emptyNodeClass];i&&o.push(this.options.emptyEditorClass);const s=Jr.node(e,e+t.nodeSize,{class:o.join(" "),"data-placeholder":"function"==typeof this.options.placeholder?this.options.placeholder({editor:this.editor,node:t,pos:e,hasAnchor:n}):this.options.placeholder});r.push(s)}return this.options.includeChildren}),Xr.create(t,r)}}})]}});function Bf({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||(null==e?void 0:e.type)===t}cl.create({name:"selection",addOptions:()=>({className:"selection"}),addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new $e({key:new Be("selection"),props:{decorations:n=>n.selection.empty||t.isFocused||!t.isEditable||Sa(n.selection)||t.view.dragging?null:Xr.create(n.doc,[Jr.inline(n.selection.from,n.selection.to,{class:e.className})])}})]}});var _f,Vf,Ff=cl.create({name:"trailingNode",addOptions:()=>({node:void 0,notAfter:[]}),addProseMirrorPlugins(){var t;const e=new Be(this.name),n=this.options.node||(null==(t=this.editor.schema.topNodeType.contentMatch.defaultType)?void 0:t.name)||"paragraph",o=Object.entries(this.editor.schema.nodes).map(([,t])=>t).filter(t=>(this.options.notAfter||[]).concat(n).includes(t.name));return[new $e({key:e,appendTransaction:(t,o,r)=>{const{doc:i,tr:s,schema:a}=r,l=e.getState(r),c=i.content.size,d=a.nodes[n];if(l)return s.insert(c,d.create())},state:{init:(t,e)=>!Bf({node:e.tr.doc.lastChild,types:o}),apply:(t,e)=>t.docChanged?t.getMeta("__uniqueIDTransaction")?e:!Bf({node:t.doc.lastChild,types:o}):e}})]}}),Wf=cl.create({name:"undoRedo",addOptions:()=>({depth:100,newGroupDelay:500}),addCommands:()=>({undo:()=>({state:t,dispatch:e})=>If(t,e),redo:()=>({state:t,dispatch:e})=>zf(t,e)}),addProseMirrorPlugins(){return[Df(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),Kf=cl.create({name:"starterKit",addExtensions(){var t,e,n,o;const r=[];return!1!==this.options.bold&&r.push(gh.configure(this.options.bold)),!1!==this.options.blockquote&&r.push(hh.configure(this.options.blockquote)),!1!==this.options.bulletList&&r.push(Du.configure(this.options.bulletList)),!1!==this.options.code&&r.push(vh.configure(this.options.code)),!1!==this.options.codeBlock&&r.push(xh.configure(this.options.codeBlock)),!1!==this.options.document&&r.push(Ch.configure(this.options.document)),!1!==this.options.dropcursor&&r.push($f.configure(this.options.dropcursor)),!1!==this.options.gapcursor&&r.push(Pf.configure(this.options.gapcursor)),!1!==this.options.hardBreak&&r.push(Sh.configure(this.options.hardBreak)),!1!==this.options.heading&&r.push(Th.configure(this.options.heading)),!1!==this.options.undoRedo&&r.push(Wf.configure(this.options.undoRedo)),!1!==this.options.horizontalRule&&r.push(Ah.configure(this.options.horizontalRule)),!1!==this.options.italic&&r.push(Rh.configure(this.options.italic)),!1!==this.options.listItem&&r.push(ju.configure(this.options.listItem)),!1!==this.options.listKeymap&&r.push(Ku.configure(null==(t=this.options)?void 0:t.listKeymap)),!1!==this.options.link&&r.push(Nu.configure(null==(e=this.options)?void 0:e.link)),!1!==this.options.orderedList&&r.push(Xu.configure(this.options.orderedList)),!1!==this.options.paragraph&&r.push(ef.configure(this.options.paragraph)),!1!==this.options.strike&&r.push(rf.configure(this.options.strike)),!1!==this.options.text&&r.push(sf.configure(this.options.text)),!1!==this.options.underline&&r.push(af.configure(null==(n=this.options)?void 0:n.underline)),!1!==this.options.trailingNode&&r.push(Ff.configure(null==(o=this.options)?void 0:o.trailingNode)),r}}),qf=cl.create({name:"textAlign",addOptions:()=>({types:[],alignments:["left","center","right","justify"],defaultAlignment:null}),addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{const e=t.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:t=>t.textAlign?{style:`text-align: ${t.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>!!this.options.alignments.includes(t)&&this.options.types.map(n=>e.updateAttributes(n,{textAlign:t})).some(t=>t),unsetTextAlign:()=>({commands:t})=>this.options.types.map(e=>t.resetAttributes(e,"textAlign")).some(t=>t),toggleTextAlign:t=>({editor:e,commands:n})=>!!this.options.alignments.includes(t)&&(e.isActive({textAlign:t})?n.unsetTextAlign():n.setTextAlign(t))}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),Uf=rl.create({name:"superscript",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"sup"},{style:"vertical-align",getAttrs:t=>"super"===t&&null}],renderHTML({HTMLAttributes:t}){return["sup",aa(this.options.HTMLAttributes,t),0]},addCommands(){return{setSuperscript:()=>({commands:t})=>t.setMark(this.name),toggleSuperscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSuperscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}}),Jf=rl.create({name:"subscript",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"sub"},{style:"vertical-align",getAttrs:t=>"sub"===t&&null}],renderHTML({HTMLAttributes:t}){return["sub",aa(this.options.HTMLAttributes,t),0]},addCommands(){return{setSubscript:()=>({commands:t})=>t.setMark(this.name),toggleSubscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSubscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}});if("undefined"!=typeof WeakMap){let t=new WeakMap;_f=e=>t.get(e),Vf=(e,n)=>(t.set(e,n),n)}else{const t=[],e=10;let n=0;_f=e=>{for(let n=0;n<t.length;n+=2)if(t[n]==e)return t[n+1]},Vf=(o,r)=>(n==e&&(n=0),t[n++]=o,t[n++]=r)}var Gf=class{constructor(t,e,n,o){this.width=t,this.height=e,this.map=n,this.problems=o}findCell(t){for(let e=0;e<this.map.length;e++){const n=this.map[e];if(n!=t)continue;const o=e%this.width,r=e/this.width|0;let i=o+1,s=r+1;for(let t=1;i<this.width&&this.map[e+t]==n;t++)i++;for(let t=1;s<this.height&&this.map[e+this.width*t]==n;t++)s++;return{left:o,top:r,right:i,bottom:s}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let e=0;e<this.map.length;e++)if(this.map[e]==t)return e%this.width;throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,e,n){const{left:o,right:r,top:i,bottom:s}=this.findCell(t);return"horiz"==e?(n<0?0==o:r==this.width)?null:this.map[i*this.width+(n<0?o-1:r)]:(n<0?0==i:s==this.height)?null:this.map[o+this.width*(n<0?i-1:s)]}rectBetween(t,e){const{left:n,right:o,top:r,bottom:i}=this.findCell(t),{left:s,right:a,top:l,bottom:c}=this.findCell(e);return{left:Math.min(n,s),top:Math.min(r,l),right:Math.max(o,a),bottom:Math.max(i,c)}}cellsInRect(t){const e=[],n={};for(let o=t.top;o<t.bottom;o++)for(let r=t.left;r<t.right;r++){const i=o*this.width+r,s=this.map[i];n[s]||(n[s]=!0,r==t.left&&r&&this.map[i-1]==s||o==t.top&&o&&this.map[i-this.width]==s||e.push(s))}return e}positionAt(t,e,n){for(let o=0,r=0;;o++){const i=r+n.child(o).nodeSize;if(o==t){let n=e+t*this.width;const o=(t+1)*this.width;for(;n<o&&this.map[n]<r;)n++;return n==o?i-1:this.map[n]}r=i}}static get(t){return _f(t)||Vf(t,function(t){if("table"!=t.type.spec.tableRole)throw new RangeError("Not a table node: "+t.type.name);const e=function(t){let e=-1,n=!1;for(let o=0;o<t.childCount;o++){const r=t.child(o);let i=0;if(n)for(let e=0;e<o;e++){const n=t.child(e);for(let t=0;t<n.childCount;t++){const r=n.child(t);e+r.attrs.rowspan>o&&(i+=r.attrs.colspan)}}for(let t=0;t<r.childCount;t++){const e=r.child(t);i+=e.attrs.colspan,e.attrs.rowspan>1&&(n=!0)}-1==e?e=i:e!=i&&(e=Math.max(e,i))}return e}(t),n=t.childCount,o=[];let r=0,i=null;const s=[];for(let t=0,r=e*n;t<r;t++)o[t]=0;for(let a=0,l=0;a<n;a++){const c=t.child(a);l++;for(let t=0;;t++){for(;r<o.length&&0!=o[r];)r++;if(t==c.childCount)break;const d=c.child(t),{colspan:h,rowspan:p,colwidth:u}=d.attrs;for(let t=0;t<p;t++){if(t+a>=n){(i||(i=[])).push({type:"overlong_rowspan",pos:l,n:p-t});break}const c=r+t*e;for(let t=0;t<h;t++){0==o[c+t]?o[c+t]=l:(i||(i=[])).push({type:"collision",row:a,pos:l,n:h-t});const n=u&&u[t];if(n){const o=(c+t)%e*2,r=s[o];null==r||r!=n&&1==s[o+1]?(s[o]=n,s[o+1]=1):r==n&&s[o+1]++}}}r+=h,l+=d.nodeSize}const d=(a+1)*e;let h=0;for(;r<d;)0==o[r++]&&h++;h&&(i||(i=[])).push({type:"missing",row:a,n:h}),l++}0!==e&&0!==n||(i||(i=[])).push({type:"zero_sized"});const a=new Gf(e,n,o,i);let l=!1;for(let t=0;!l&&t<s.length;t+=2)null!=s[t]&&s[t+1]<n&&(l=!0);return l&&function(t,e,n){t.problems||(t.problems=[]);const o={};for(let r=0;r<t.map.length;r++){const i=t.map[r];if(o[i])continue;o[i]=!0;const s=n.nodeAt(i);if(!s)throw new RangeError(`No cell with offset ${i} found`);let a=null;const l=s.attrs;for(let n=0;n<l.colspan;n++){const o=e[(r+n)%t.width*2];null==o||l.colwidth&&l.colwidth[n]==o||((a||(a=Yf(l)))[n]=o)}a&&t.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:a})}}(a,s,t),a}(t))}};function Yf(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function Xf(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const n in t.nodes){const o=t.nodes[n],r=o.spec.tableRole;r&&(e[r]=o)}}return e}var Qf=new Be("selectingCells");function Zf(t){for(let e=t.depth-1;e>0;e--)if("row"==t.node(e).type.spec.tableRole)return t.node(0).resolve(t.before(e+1));return null}function tm(t){const e=t.selection.$head;for(let t=e.depth;t>0;t--)if("row"==e.node(t).type.spec.tableRole)return!0;return!1}function em(t){const e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&"cell"==e.node.type.spec.tableRole)return e.$anchor;const n=Zf(e.$head)||function(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){const o=e.type.spec.tableRole;if("cell"==o||"header_cell"==o)return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){const o=e.type.spec.tableRole;if("cell"==o||"header_cell"==o)return t.doc.resolve(n-e.nodeSize)}}(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function nm(t){return"row"==t.parent.type.spec.tableRole&&!!t.nodeAfter}function om(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function rm(t,e,n){const o=t.node(-1),r=Gf.get(o),i=t.start(-1),s=r.nextCell(t.pos-i,e,n);return null==s?null:t.node(0).resolve(i+s)}function im(t,e,n=1){const o={...t,colspan:t.colspan-n};return o.colwidth&&(o.colwidth=o.colwidth.slice(),o.colwidth.splice(e,n),o.colwidth.some(t=>t>0)||(o.colwidth=null)),o}function sm(t,e,n=1){const o={...t,colspan:t.colspan+n};if(o.colwidth){o.colwidth=o.colwidth.slice();for(let t=0;t<n;t++)o.colwidth.splice(e,0,0)}return o}var am=class t extends be{constructor(t,e=t){const n=t.node(-1),o=Gf.get(n),r=t.start(-1),i=o.rectBetween(t.pos-r,e.pos-r),s=t.node(0),a=o.cellsInRect(i).filter(t=>t!=e.pos-r);a.unshift(e.pos-r);const l=a.map(t=>{const e=n.nodeAt(t);if(!e)throw RangeError(`No cell with offset ${t} found`);const o=r+t+1;return new ve(s.resolve(o),s.resolve(o+e.content.size))});super(l[0].$from,l[0].$to,l),this.$anchorCell=t,this.$headCell=e}map(e,n){const o=e.resolve(n.map(this.$anchorCell.pos)),r=e.resolve(n.map(this.$headCell.pos));if(nm(o)&&nm(r)&&om(o,r)){const e=this.$anchorCell.node(-1)!=o.node(-1);return e&&this.isRowSelection()?t.rowSelection(o,r):e&&this.isColSelection()?t.colSelection(o,r):new t(o,r)}return xe.between(o,r)}content(){const t=this.$anchorCell.node(-1),e=Gf.get(t),n=this.$anchorCell.start(-1),o=e.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),r={},i=[];for(let n=o.top;n<o.bottom;n++){const s=[];for(let i=n*e.width+o.left,a=o.left;a<o.right;a++,i++){const n=e.map[i];if(r[n])continue;r[n]=!0;const a=e.findCell(n);let l=t.nodeAt(n);if(!l)throw RangeError(`No cell with offset ${n} found`);const c=o.left-a.left,d=a.right-o.right;if(c>0||d>0){let t=l.attrs;if(c>0&&(t=im(t,0,c)),d>0&&(t=im(t,t.colspan-d,d)),a.left<o.left){if(l=l.type.createAndFill(t),!l)throw RangeError(`Could not create cell with attrs ${JSON.stringify(t)}`)}else l=l.type.create(t,l.content)}if(a.top<o.top||a.bottom>o.bottom){const t={...l.attrs,rowspan:Math.min(a.bottom,o.bottom)-Math.max(a.top,o.top)};l=a.top<o.top?l.type.createAndFill(t):l.type.create(t,l.content)}s.push(l)}i.push(t.child(n).copy(k.from(s)))}const s=this.isColSelection()&&this.isRowSelection()?t:i;return new A(k.from(s),1,1)}replace(t,e=A.empty){const n=t.steps.length,o=this.ranges;for(let r=0;r<o.length;r++){const{$from:i,$to:s}=o[r],a=t.mapping.slice(n);t.replace(a.map(i.pos),a.map(s.pos),r?A.empty:e)}const r=be.findFrom(t.doc.resolve(t.mapping.slice(n).map(this.to)),-1);r&&t.setSelection(r)}replaceWith(t,e){this.replace(t,new A(k.from(e),0,0))}forEachCell(t){const e=this.$anchorCell.node(-1),n=Gf.get(e),o=this.$anchorCell.start(-1),r=n.cellsInRect(n.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o));for(let n=0;n<r.length;n++)t(e.nodeAt(r[n]),o+r[n])}isColSelection(){const t=this.$anchorCell.index(-1),e=this.$headCell.index(-1);if(Math.min(t,e)>0)return!1;const n=t+this.$anchorCell.nodeAfter.attrs.rowspan,o=e+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,o)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const o=e.node(-1),r=Gf.get(o),i=e.start(-1),s=r.findCell(e.pos-i),a=r.findCell(n.pos-i),l=e.node(0);return s.top<=a.top?(s.top>0&&(e=l.resolve(i+r.map[s.left])),a.bottom<r.height&&(n=l.resolve(i+r.map[r.width*(r.height-1)+a.right-1]))):(a.top>0&&(n=l.resolve(i+r.map[a.left])),s.bottom<r.height&&(e=l.resolve(i+r.map[r.width*(r.height-1)+s.right-1]))),new t(e,n)}isRowSelection(){const t=this.$anchorCell.node(-1),e=Gf.get(t),n=this.$anchorCell.start(-1),o=e.colCount(this.$anchorCell.pos-n),r=e.colCount(this.$headCell.pos-n);if(Math.min(o,r)>0)return!1;const i=o+this.$anchorCell.nodeAfter.attrs.colspan,s=r+this.$headCell.nodeAfter.attrs.colspan;return Math.max(i,s)==e.width}eq(e){return e instanceof t&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const o=e.node(-1),r=Gf.get(o),i=e.start(-1),s=r.findCell(e.pos-i),a=r.findCell(n.pos-i),l=e.node(0);return s.left<=a.left?(s.left>0&&(e=l.resolve(i+r.map[s.top*r.width])),a.right<r.width&&(n=l.resolve(i+r.map[r.width*(a.top+1)-1]))):(a.left>0&&(n=l.resolve(i+r.map[a.top*r.width])),s.right<r.width&&(e=l.resolve(i+r.map[r.width*(s.top+1)-1]))),new t(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new t(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,o=n){return new t(e.resolve(n),e.resolve(o))}getBookmark(){return new lm(this.$anchorCell.pos,this.$headCell.pos)}};am.prototype.visible=!1,be.jsonID("cell",am);var lm=class t{constructor(t,e){this.anchor=t,this.head=e}map(e){return new t(e.map(this.anchor),e.map(this.head))}resolve(t){const e=t.resolve(this.anchor),n=t.resolve(this.head);return"row"==e.parent.type.spec.tableRole&&"row"==n.parent.type.spec.tableRole&&e.index()<e.parent.childCount&&n.index()<n.parent.childCount&&om(e,n)?new am(e,n):be.near(n,1)}};function cm(t){if(!(t.selection instanceof am))return null;const e=[];return t.selection.forEachCell((t,n)=>{e.push(Jr.node(n,n+t.nodeSize,{class:"selectedCell"}))}),Xr.create(t.doc,e)}var dm=new Be("fix-tables");function hm(t,e,n,o){const r=t.childCount,i=e.childCount;t:for(let s=0,a=0;s<i;s++){const i=e.child(s);for(let e=a,o=Math.min(r,s+3);e<o;e++)if(t.child(e)==i){a=e+1,n+=i.nodeSize;continue t}o(i,n),a<r&&t.child(a).sameMarkup(i)?hm(t.child(a),i,n+1,o):i.nodesBetween(0,i.content.size,o,n+1),n+=i.nodeSize}}function pm(t,e){let n;const o=(e,o)=>{"table"==e.type.spec.tableRole&&(n=function(t,e,n,o){const r=Gf.get(e);if(!r.problems)return o;o||(o=t.tr);const i=[];for(let t=0;t<r.height;t++)i.push(0);for(let t=0;t<r.problems.length;t++){const s=r.problems[t];if("collision"==s.type){const t=e.nodeAt(s.pos);if(!t)continue;const r=t.attrs;for(let t=0;t<r.rowspan;t++)i[s.row+t]+=s.n;o.setNodeMarkup(o.mapping.map(n+1+s.pos),null,im(r,r.colspan-s.n,s.n))}else if("missing"==s.type)i[s.row]+=s.n;else if("overlong_rowspan"==s.type){const t=e.nodeAt(s.pos);if(!t)continue;o.setNodeMarkup(o.mapping.map(n+1+s.pos),null,{...t.attrs,rowspan:t.attrs.rowspan-s.n})}else if("colwidth mismatch"==s.type){const t=e.nodeAt(s.pos);if(!t)continue;o.setNodeMarkup(o.mapping.map(n+1+s.pos),null,{...t.attrs,colwidth:s.colwidth})}else if("zero_sized"==s.type){const t=o.mapping.map(n);o.delete(t,t+e.nodeSize)}}let s,a;for(let t=0;t<i.length;t++)i[t]&&(null==s&&(s=t),a=t);for(let l=0,c=n+1;l<r.height;l++){const n=e.child(l),r=c+n.nodeSize,d=i[l];if(d>0){let e="cell";n.firstChild&&(e=n.firstChild.type.spec.tableRole);const i=[];for(let n=0;n<d;n++){const n=Xf(t.schema)[e].createAndFill();n&&i.push(n)}const h=0!=l&&s!=l-1||a!=l?r-1:c+1;o.insert(o.mapping.map(h),i)}c=r}return o.setMeta(dm,{fixTables:!0})}(t,e,o,n))};return e?e.doc!=t.doc&&hm(e.doc,t.doc,0,o):t.doc.descendants(o),n}function um(t){const e=t.selection,n=em(t),o=n.node(-1),r=n.start(-1),i=Gf.get(o);return{...e instanceof am?i.rectBetween(e.$anchorCell.pos-r,e.$headCell.pos-r):i.findCell(n.pos-r),tableStart:r,map:i,table:o}}function fm(t,{map:e,tableStart:n,table:o},r){let i=r>0?-1:0;(function(t,e,n){const o=Xf(e.type.schema).header_cell;for(let r=0;r<t.height;r++)if(e.nodeAt(t.map[n+r*t.width]).type!=o)return!1;return!0})(e,o,r+i)&&(i=0==r||r==e.width?null:0);for(let s=0;s<e.height;s++){const a=s*e.width+r;if(r>0&&r<e.width&&e.map[a-1]==e.map[a]){const i=e.map[a],l=o.nodeAt(i);t.setNodeMarkup(t.mapping.map(n+i),null,sm(l.attrs,r-e.colCount(i))),s+=l.attrs.rowspan-1}else{const l=null==i?Xf(o.type.schema).cell:o.nodeAt(e.map[a+i]).type,c=e.positionAt(s,r,o);t.insert(t.mapping.map(n+c),l.createAndFill())}}return t}function mm(t,{map:e,table:n,tableStart:o},r){const i=t.mapping.maps.length;for(let s=0;s<e.height;){const a=s*e.width+r,l=e.map[a],c=n.nodeAt(l),d=c.attrs;if(r>0&&e.map[a-1]==l||r<e.width-1&&e.map[a+1]==l)t.setNodeMarkup(t.mapping.slice(i).map(o+l),null,im(d,r-e.colCount(l)));else{const e=t.mapping.slice(i).map(o+l);t.delete(e,e+c.nodeSize)}s+=d.rowspan}}function gm(t,{map:e,tableStart:n,table:o},r){var i;let s=n;for(let t=0;t<r;t++)s+=o.child(t).nodeSize;const a=[];let l=r>0?-1:0;(function(t,e,n){var o;const r=Xf(e.type.schema).header_cell;for(let i=0;i<t.width;i++)if((null==(o=e.nodeAt(t.map[i+n*t.width]))?void 0:o.type)!=r)return!1;return!0})(e,o,r+l)&&(l=0==r||r==e.height?null:0);for(let s=0,c=e.width*r;s<e.width;s++,c++)if(r>0&&r<e.height&&e.map[c]==e.map[c-e.width]){const r=e.map[c],i=o.nodeAt(r).attrs;t.setNodeMarkup(n+r,null,{...i,rowspan:i.rowspan+1}),s+=i.colspan-1}else{const t=null==l?Xf(o.type.schema).cell:null==(i=o.nodeAt(e.map[c+l*e.width]))?void 0:i.type,n=null==t?void 0:t.createAndFill();n&&a.push(n)}return t.insert(s,Xf(o.type.schema).row.create(null,a)),t}function ym(t,{map:e,table:n,tableStart:o},r){let i=0;for(let t=0;t<r;t++)i+=n.child(t).nodeSize;const s=i+n.child(r).nodeSize,a=t.mapping.maps.length;t.delete(i+o,s+o);const l=new Set;for(let i=0,s=r*e.width;i<e.width;i++,s++){const c=e.map[s];if(!l.has(c))if(l.add(c),r>0&&c==e.map[s-e.width]){const e=n.nodeAt(c).attrs;t.setNodeMarkup(t.mapping.slice(a).map(c+o),null,{...e,rowspan:e.rowspan-1}),i+=e.colspan-1}else if(r<e.height&&c==e.map[s+e.width]){const s=n.nodeAt(c),l=s.attrs,d=s.type.create({...l,rowspan:s.attrs.rowspan-1},s.content),h=e.positionAt(r+1,i,n);t.insert(t.mapping.slice(a).map(o+h),d),i+=l.colspan-1}}}function bm(t){const e=t.content;return 1==e.childCount&&e.child(0).isTextblock&&0==e.child(0).childCount}function vm(t,e){const n=t.selection;if(!(n instanceof am)||n.$anchorCell.pos==n.$headCell.pos)return!1;const o=um(t),{map:r}=o;if(function({width:t,height:e,map:n},o){let r=o.top*t+o.left,i=r,s=(o.bottom-1)*t+o.left,a=r+(o.right-o.left-1);for(let e=o.top;e<o.bottom;e++){if(o.left>0&&n[i]==n[i-1]||o.right<t&&n[a]==n[a+1])return!0;i+=t,a+=t}for(let i=o.left;i<o.right;i++){if(o.top>0&&n[r]==n[r-t]||o.bottom<e&&n[s]==n[s+t])return!0;r++,s++}return!1}(r,o))return!1;if(e){const n=t.tr,i={};let s,a,l=k.empty;for(let t=o.top;t<o.bottom;t++)for(let e=o.left;e<o.right;e++){const c=r.map[t*r.width+e],d=o.table.nodeAt(c);if(!i[c]&&d)if(i[c]=!0,null==s)s=c,a=d;else{bm(d)||(l=l.append(d.content));const t=n.mapping.map(c+o.tableStart);n.delete(t,t+d.nodeSize)}}if(null==s||null==a)return!0;if(n.setNodeMarkup(s+o.tableStart,null,{...sm(a.attrs,a.attrs.colspan,o.right-o.left-a.attrs.colspan),rowspan:o.bottom-o.top}),l.size){const t=s+1+a.content.size,e=bm(a)?s+1:t;n.replaceWith(e+o.tableStart,t+o.tableStart,l)}n.setSelection(new am(n.doc.resolve(s+o.tableStart))),e(n)}return!0}function wm(t,e){const n=Xf(t.schema);return(o=({node:t})=>n[t.type.spec.tableRole],(t,e)=>{var n;const r=t.selection;let i,s;if(r instanceof am){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;i=r.$anchorCell.nodeAfter,s=r.$anchorCell.pos}else{if(i=function(t){for(let e=t.depth;e>0;e--){const n=t.node(e).type.spec.tableRole;if("cell"===n||"header_cell"===n)return t.node(e)}return null}(r.$from),!i)return!1;s=null==(n=Zf(r.$from))?void 0:n.pos}if(null==i||null==s)return!1;if(1==i.attrs.colspan&&1==i.attrs.rowspan)return!1;if(e){let n=i.attrs;const a=[],l=n.colwidth;n.rowspan>1&&(n={...n,rowspan:1}),n.colspan>1&&(n={...n,colspan:1});const c=um(t),d=t.tr;for(let t=0;t<c.right-c.left;t++)a.push(l?{...n,colwidth:l&&l[t]?[l[t]]:null}:n);let h;for(let t=c.top;t<c.bottom;t++){let e=c.map.positionAt(t,c.left,c.table);t==c.top&&(e+=i.nodeSize);for(let n=c.left,r=0;n<c.right;n++,r++)n==c.left&&t==c.top||d.insert(h=d.mapping.map(e+c.tableStart,1),o({node:i,row:t,col:n}).createAndFill(a[r]))}d.setNodeMarkup(s,o({node:i,row:c.top,col:c.left}),a[0]),r instanceof am&&d.setSelection(new am(d.doc.resolve(r.$anchorCell.pos),h?d.doc.resolve(h):void 0)),e(d)}return!0})(t,e);var o}function km(t,e,n){const o=e.map.cellsInRect({left:0,top:0,right:"row"==t?e.map.width:1,bottom:"column"==t?e.map.height:1});for(let t=0;t<o.length;t++){const r=e.table.nodeAt(o[t]);if(r&&r.type!==n.header_cell)return!1}return!0}function xm(t,e){return(e=e||{useDeprecatedLogic:!1}).useDeprecatedLogic?function(t){return function(e,n){if(!tm(e))return!1;if(n){const o=Xf(e.schema),r=um(e),i=e.tr,s=r.map.cellsInRect("column"==t?{left:r.left,top:0,right:r.right,bottom:r.map.height}:"row"==t?{left:0,top:r.top,right:r.map.width,bottom:r.bottom}:r),a=s.map(t=>r.table.nodeAt(t));for(let t=0;t<s.length;t++)a[t].type==o.header_cell&&i.setNodeMarkup(r.tableStart+s[t],o.cell,a[t].attrs);if(0==i.steps.length)for(let t=0;t<s.length;t++)i.setNodeMarkup(r.tableStart+s[t],o.header_cell,a[t].attrs);n(i)}return!0}}(t):function(e,n){if(!tm(e))return!1;if(n){const o=Xf(e.schema),r=um(e),i=e.tr,s=km("row",r,o),a=km("column",r,o),l=("column"===t?s:"row"===t&&a)?1:0,c="column"==t?{left:0,top:l,right:1,bottom:r.map.height}:"row"==t?{left:l,top:0,right:r.map.width,bottom:1}:r,d="column"==t?a?o.cell:o.header_cell:"row"==t?s?o.cell:o.header_cell:o.cell;r.map.cellsInRect(c).forEach(t=>{const e=t+r.tableStart,n=i.doc.nodeAt(e);n&&i.setNodeMarkup(e,d,n.attrs)}),n(i)}return!0}}xm("row",{useDeprecatedLogic:!0}),xm("column",{useDeprecatedLogic:!0});var Mm=xm("cell",{useDeprecatedLogic:!0});function Cm(t){return function(e,n){if(!tm(e))return!1;const o=function(t,e){if(e<0){const e=t.nodeBefore;if(e)return t.pos-e.nodeSize;for(let e=t.index(-1)-1,n=t.before();e>=0;e--){const o=t.node(-1).child(e),r=o.lastChild;if(r)return n-1-r.nodeSize;n-=o.nodeSize}}else{if(t.index()<t.parent.childCount-1)return t.pos+t.nodeAfter.nodeSize;const e=t.node(-1);for(let n=t.indexAfter(-1),o=t.after();n<e.childCount;n++){const t=e.child(n);if(t.childCount)return o+1;o+=t.nodeSize}}return null}(em(e),t);if(null==o)return!1;if(n){const t=e.doc.resolve(o);n(e.tr.setSelection(xe.between(t,(r=t,r.node(0).resolve(r.pos+r.nodeAfter.nodeSize)))).scrollIntoView())}var r;return!0}}function Sm(t,e){const n=t.selection;if(!(n instanceof am))return!1;if(e){const o=t.tr,r=Xf(t.schema).cell.createAndFill().content;n.forEachCell((t,e)=>{t.content.eq(r)||o.replace(o.mapping.map(e+1),o.mapping.map(e+t.nodeSize-1),new A(r,0,0))}),o.docChanged&&e(o)}return!0}function Tm(t,e){const n=t.createAndFill();return new ge(n).replace(0,n.content.size,e).doc}function Am(t,e,n,o,r,i,s,a){if(0==s||s==e.height)return!1;let l=!1;for(let c=r;c<i;c++){const r=s*e.width+c,i=e.map[r];if(e.map[r-e.width]==i){l=!0;const r=n.nodeAt(i),{top:d,left:h}=e.findCell(i);t.setNodeMarkup(t.mapping.slice(a).map(i+o),null,{...r.attrs,rowspan:s-d}),t.insert(t.mapping.slice(a).map(e.positionAt(s,h,n)),r.type.createAndFill({...r.attrs,rowspan:d+r.attrs.rowspan-s})),c+=r.attrs.colspan-1}}return l}function Em(t,e,n,o,r,i,s,a){if(0==s||s==e.width)return!1;let l=!1;for(let c=r;c<i;c++){const r=c*e.width+s,i=e.map[r];if(e.map[r-1]==i){l=!0;const r=n.nodeAt(i),d=e.colCount(i),h=t.mapping.slice(a).map(i+o);t.setNodeMarkup(h,null,im(r.attrs,s-d,r.attrs.colspan-(s-d))),t.insert(h+r.nodeSize,r.type.createAndFill(im(r.attrs,0,s-d))),c+=r.attrs.rowspan-1}}return l}function Nm(t,e,n,o,r){let i=n?t.doc.nodeAt(n-1):t.doc;if(!i)throw new Error("No table found");let s=Gf.get(i);const{top:a,left:l}=o,c=l+r.width,d=a+r.height,h=t.tr;let p=0;function u(){if(i=n?h.doc.nodeAt(n-1):h.doc,!i)throw new Error("No table found");s=Gf.get(i),p=h.mapping.maps.length}(function(t,e,n,o,r,i,s){const a=Xf(t.doc.type.schema);let l,c;if(r>e.width)for(let i=0,d=0;i<e.height;i++){const h=n.child(i);d+=h.nodeSize;const p=[];let u;u=null==h.lastChild||h.lastChild.type==a.cell?l||(l=a.cell.createAndFill()):c||(c=a.header_cell.createAndFill());for(let t=e.width;t<r;t++)p.push(u);t.insert(t.mapping.slice(s).map(d-1+o),p)}if(i>e.height){const d=[];for(let t=0,o=(e.height-1)*e.width;t<Math.max(e.width,r);t++){const r=!(t>=e.width)&&n.nodeAt(e.map[o+t]).type==a.header_cell;d.push(r?c||(c=a.header_cell.createAndFill()):l||(l=a.cell.createAndFill()))}const h=a.row.create(null,k.from(d)),p=[];for(let t=e.height;t<i;t++)p.push(h);t.insert(t.mapping.slice(s).map(o+n.nodeSize-2),p)}return!(!l&&!c)})(h,s,i,n,c,d,p)&&u(),Am(h,s,i,n,l,c,a,p)&&u(),Am(h,s,i,n,l,c,d,p)&&u(),Em(h,s,i,n,a,d,l,p)&&u(),Em(h,s,i,n,a,d,c,p)&&u();for(let t=a;t<d;t++){const e=s.positionAt(t,l,i),o=s.positionAt(t,c,i);h.replace(h.mapping.slice(p).map(e+n),h.mapping.slice(p).map(o+n),new A(r.rows[t-a],0,0))}u(),h.setSelection(new am(h.doc.resolve(n+s.positionAt(a,l,i)),h.doc.resolve(n+s.positionAt(d-1,c-1,i)))),e(h)}var Om=$i({ArrowLeft:Rm("horiz",-1),ArrowRight:Rm("horiz",1),ArrowUp:Rm("vert",-1),ArrowDown:Rm("vert",1),"Shift-ArrowLeft":Dm("horiz",-1),"Shift-ArrowRight":Dm("horiz",1),"Shift-ArrowUp":Dm("vert",-1),"Shift-ArrowDown":Dm("vert",1),Backspace:Sm,"Mod-Backspace":Sm,Delete:Sm,"Mod-Delete":Sm});function Lm(t,e,n){return!n.eq(t.selection)&&(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function Rm(t,e){return(n,o,r)=>{if(!r)return!1;const i=n.selection;if(i instanceof am)return Lm(n,o,be.near(i.$headCell,e));if("horiz"!=t&&!i.empty)return!1;const s=$m(r,t,e);if(null==s)return!1;if("horiz"==t)return Lm(n,o,be.near(n.doc.resolve(i.head+e),e));{const r=n.doc.resolve(s),i=rm(r,t,e);let a;return a=i?be.near(i,1):e<0?be.near(n.doc.resolve(r.before(-1)),-1):be.near(n.doc.resolve(r.after(-1)),1),Lm(n,o,a)}}}function Dm(t,e){return(n,o,r)=>{if(!r)return!1;const i=n.selection;let s;if(i instanceof am)s=i;else{const o=$m(r,t,e);if(null==o)return!1;s=new am(n.doc.resolve(o))}const a=rm(s.$headCell,t,e);return!!a&&Lm(n,o,new am(s.$anchorCell,a))}}function jm(t,e){const n=Zf(t.state.doc.resolve(e));return!!n&&(t.dispatch(t.state.tr.setSelection(new am(n))),!0)}function Im(t,e,n){if(!tm(t.state))return!1;let o=function(t){if(!t.size)return null;let{content:e,openStart:n,openEnd:o}=t;for(;1==e.childCount&&(n>0&&o>0||"table"==e.child(0).type.spec.tableRole);)n--,o--,e=e.child(0).content;const r=e.child(0),i=r.type.spec.tableRole,s=r.type.schema,a=[];if("row"==i)for(let t=0;t<e.childCount;t++){let r=e.child(t).content;const i=t?0:Math.max(0,n-1),l=t<e.childCount-1?0:Math.max(0,o-1);(i||l)&&(r=Tm(Xf(s).row,new A(r,i,l)).content),a.push(r)}else{if("cell"!=i&&"header_cell"!=i)return null;a.push(n||o?Tm(Xf(s).row,new A(e,n,o)).content:e)}return function(t,e){const n=[];for(let t=0;t<e.length;t++){const o=e[t];for(let e=o.childCount-1;e>=0;e--){const{rowspan:r,colspan:i}=o.child(e).attrs;for(let e=t;e<t+r;e++)n[e]=(n[e]||0)+i}}let o=0;for(let t=0;t<n.length;t++)o=Math.max(o,n[t]);for(let r=0;r<n.length;r++)if(r>=e.length&&e.push(k.empty),n[r]<o){const i=Xf(t).cell.createAndFill(),s=[];for(let t=n[r];t<o;t++)s.push(i);e[r]=e[r].append(k.from(s))}return{height:e.length,width:o,rows:e}}(s,a)}(n);const r=t.state.selection;if(r instanceof am){o||(o={width:1,height:1,rows:[k.from(Tm(Xf(t.state.schema).cell,n))]});const e=r.$anchorCell.node(-1),i=r.$anchorCell.start(-1),s=Gf.get(e).rectBetween(r.$anchorCell.pos-i,r.$headCell.pos-i);return o=function({width:t,height:e,rows:n},o,r){if(t!=o){const e=[],r=[];for(let t=0;t<n.length;t++){const i=n[t],s=[];for(let n=e[t]||0,r=0;n<o;r++){let a=i.child(r%i.childCount);n+a.attrs.colspan>o&&(a=a.type.createChecked(im(a.attrs,a.attrs.colspan,n+a.attrs.colspan-o),a.content)),s.push(a),n+=a.attrs.colspan;for(let n=1;n<a.attrs.rowspan;n++)e[t+n]=(e[t+n]||0)+a.attrs.colspan}r.push(k.from(s))}n=r,t=o}if(e!=r){const t=[];for(let o=0,i=0;o<r;o++,i++){const s=[],a=n[i%e];for(let t=0;t<a.childCount;t++){let e=a.child(t);o+e.attrs.rowspan>r&&(e=e.type.create({...e.attrs,rowspan:Math.max(1,r-e.attrs.rowspan)},e.content)),s.push(e)}t.push(k.from(s))}n=t,e=r}return{width:t,height:e,rows:n}}(o,s.right-s.left,s.bottom-s.top),Nm(t.state,t.dispatch,i,s,o),!0}if(o){const e=em(t.state),n=e.start(-1);return Nm(t.state,t.dispatch,n,Gf.get(e.node(-1)).findCell(e.pos-n),o),!0}return!1}function zm(t,e){var n;if(e.ctrlKey||e.metaKey)return;const o=Pm(t,e.target);let r;if(e.shiftKey&&t.state.selection instanceof am)i(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&o&&null!=(r=Zf(t.state.selection.$anchor))&&(null==(n=Hm(t,e))?void 0:n.pos)!=r.pos)i(r,e),e.preventDefault();else if(!o)return;function i(e,n){let o=Hm(t,n);const r=null==Qf.getState(t.state);if(!o||!om(e,o)){if(!r)return;o=e}const i=new am(e,o);if(r||!t.state.selection.eq(i)){const n=t.state.tr.setSelection(i);r&&n.setMeta(Qf,e.pos),t.dispatch(n)}}function s(){t.root.removeEventListener("mouseup",s),t.root.removeEventListener("dragstart",s),t.root.removeEventListener("mousemove",a),null!=Qf.getState(t.state)&&t.dispatch(t.state.tr.setMeta(Qf,-1))}function a(n){const r=n,a=Qf.getState(t.state);let l;if(null!=a)l=t.state.doc.resolve(a);else if(Pm(t,r.target)!=o&&(l=Hm(t,e),!l))return s();l&&i(l,r)}t.root.addEventListener("mouseup",s),t.root.addEventListener("dragstart",s),t.root.addEventListener("mousemove",a)}function $m(t,e,n){if(!(t.state.selection instanceof xe))return null;const{$head:o}=t.state.selection;for(let r=o.depth-1;r>=0;r--){const i=o.node(r);if((n<0?o.index(r):o.indexAfter(r))!=(n<0?0:i.childCount))return null;if("cell"==i.type.spec.tableRole||"header_cell"==i.type.spec.tableRole){const i=o.before(r),s="vert"==e?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(s)?i:null}}return null}function Pm(t,e){for(;e&&e!=t.dom;e=e.parentNode)if("TD"==e.nodeName||"TH"==e.nodeName)return e;return null}function Hm(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});return n&&n?Zf(t.state.doc.resolve(n.pos)):null}var Bm=class{constructor(t,e){this.node=t,this.defaultCellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${e}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),_m(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type==this.node.type&&(this.node=t,_m(t,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(t){return"attributes"==t.type&&(t.target==this.table||this.colgroup.contains(t.target))}};function _m(t,e,n,o,r,i){var s;let a=0,l=!0,c=e.firstChild;const d=t.firstChild;if(d){for(let t=0,n=0;t<d.childCount;t++){const{colspan:s,colwidth:h}=d.child(t).attrs;for(let t=0;t<s;t++,n++){const s=r==n?i:h&&h[t],d=s?s+"px":"";if(a+=s||o,s||(l=!1),c)c.style.width!=d&&(c.style.width=d),c=c.nextSibling;else{const t=document.createElement("col");t.style.width=d,e.appendChild(t)}}}for(;c;){const t=c.nextSibling;null==(s=c.parentNode)||s.removeChild(c),c=t}l?(n.style.width=a+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=a+"px")}}var Vm=new Be("tableColumnResizing");function Fm({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:o=Bm,lastColumnResizable:r=!0}={}){const i=new $e({key:Vm,state:{init(t,e){var r,s;const a=null==(s=null==(r=i.spec)?void 0:r.props)?void 0:s.nodeViews,l=Xf(e.schema).table.name;return o&&a&&(a[l]=(t,e)=>new o(t,n,e)),new Wm(-1,!1)},apply:(t,e)=>e.apply(t)},props:{attributes:t=>{const e=Vm.getState(t);return e&&e.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(e,n)=>{!function(t,e,n,o){if(!t.editable)return;const r=Vm.getState(t.state);if(r&&!r.dragging){const i=function(t){for(;t&&"TD"!=t.nodeName&&"TH"!=t.nodeName;)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}(e.target);let s=-1;if(i){const{left:o,right:r}=i.getBoundingClientRect();e.clientX-o<=n?s=Km(t,e,"left",n):r-e.clientX<=n&&(s=Km(t,e,"right",n))}if(s!=r.activeHandle){if(!o&&-1!==s){const e=t.state.doc.resolve(s),n=e.node(-1),o=Gf.get(n),r=e.start(-1);if(o.colCount(e.pos-r)+e.nodeAfter.attrs.colspan-1==o.width-1)return}Um(t,s)}}}(e,n,t,r)},mouseleave:t=>{!function(t){if(!t.editable)return;const e=Vm.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&Um(t,-1)}(t)},mousedown:(t,o)=>{!function(t,e,n,o){var r;if(!t.editable)return!1;const i=null!=(r=t.dom.ownerDocument.defaultView)?r:window,s=Vm.getState(t.state);if(!s||-1==s.activeHandle||s.dragging)return!1;const a=t.state.doc.nodeAt(s.activeHandle),l=function(t,e,{colspan:n,colwidth:o}){const r=o&&o[o.length-1];if(r)return r;const i=t.domAtPos(e);let s=i.node.childNodes[i.offset].offsetWidth,a=n;if(o)for(let t=0;t<n;t++)o[t]&&(s-=o[t],a--);return s/a}(t,s.activeHandle,a.attrs);function c(e){i.removeEventListener("mouseup",c),i.removeEventListener("mousemove",d);const o=Vm.getState(t.state);(null==o?void 0:o.dragging)&&(function(t,e,n){const o=t.state.doc.resolve(e),r=o.node(-1),i=Gf.get(r),s=o.start(-1),a=i.colCount(o.pos-s)+o.nodeAfter.attrs.colspan-1,l=t.state.tr;for(let t=0;t<i.height;t++){const e=t*i.width+a;if(t&&i.map[e]==i.map[e-i.width])continue;const o=i.map[e],c=r.nodeAt(o).attrs,d=1==c.colspan?0:a-i.colCount(o);if(c.colwidth&&c.colwidth[d]==n)continue;const h=c.colwidth?c.colwidth.slice():Gm(c.colspan);h[d]=n,l.setNodeMarkup(s+o,null,{...c,colwidth:h})}l.docChanged&&t.dispatch(l)}(t,o.activeHandle,qm(o.dragging,e,n)),t.dispatch(t.state.tr.setMeta(Vm,{setDragging:null})))}function d(e){if(!e.which)return c(e);const r=Vm.getState(t.state);if(r&&r.dragging){const i=qm(r.dragging,e,n);Jm(t,r.activeHandle,i,o)}}t.dispatch(t.state.tr.setMeta(Vm,{setDragging:{startX:e.clientX,startWidth:l}})),Jm(t,s.activeHandle,l,o),i.addEventListener("mouseup",c),i.addEventListener("mousemove",d),e.preventDefault()}(t,o,e,n)}},decorations:t=>{const e=Vm.getState(t);if(e&&e.activeHandle>-1)return function(t,e){var n;const o=[],r=t.doc.resolve(e),i=r.node(-1);if(!i)return Xr.empty;const s=Gf.get(i),a=r.start(-1),l=s.colCount(r.pos-a)+r.nodeAfter.attrs.colspan-1;for(let e=0;e<s.height;e++){const r=l+e*s.width;if(!(l!=s.width-1&&s.map[r]==s.map[r+1]||0!=e&&s.map[r]==s.map[r-s.width])){const e=s.map[r],l=a+e+i.nodeAt(e).nodeSize-1,c=document.createElement("div");c.className="column-resize-handle",(null==(n=Vm.getState(t))?void 0:n.dragging)&&o.push(Jr.node(a+e,a+e+i.nodeAt(e).nodeSize,{class:"column-resize-dragging"})),o.push(Jr.widget(l,c))}}return Xr.create(t.doc,o)}(t,e.activeHandle)},nodeViews:{}}});return i}var Wm=class t{constructor(t,e){this.activeHandle=t,this.dragging=e}apply(e){const n=this,o=e.getMeta(Vm);if(o&&null!=o.setHandle)return new t(o.setHandle,!1);if(o&&void 0!==o.setDragging)return new t(n.activeHandle,o.setDragging);if(n.activeHandle>-1&&e.docChanged){let o=e.mapping.map(n.activeHandle,-1);return nm(e.doc.resolve(o))||(o=-1),new t(o,n.dragging)}return n}};function Km(t,e,n,o){const r="right"==n?-o:o,i=t.posAtCoords({left:e.clientX+r,top:e.clientY});if(!i)return-1;const{pos:s}=i,a=Zf(t.state.doc.resolve(s));if(!a)return-1;if("right"==n)return a.pos;const l=Gf.get(a.node(-1)),c=a.start(-1),d=l.map.indexOf(a.pos-c);return d%l.width==0?-1:c+l.map[d-1]}function qm(t,e,n){const o=e.clientX-t.startX;return Math.max(n,t.startWidth+o)}function Um(t,e){t.dispatch(t.state.tr.setMeta(Vm,{setHandle:e}))}function Jm(t,e,n,o){const r=t.state.doc.resolve(e),i=r.node(-1),s=r.start(-1),a=Gf.get(i).colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1;let l=t.domAtPos(r.start(-1)).node;for(;l&&"TABLE"!=l.nodeName;)l=l.parentNode;l&&_m(i,l.firstChild,l,o,a,n)}function Gm(t){return Array(t).fill(0)}function Ym({allowTableNodeSelection:t=!1}={}){return new $e({key:Qf,state:{init:()=>null,apply(t,e){const n=t.getMeta(Qf);if(null!=n)return-1==n?null:n;if(null==e||!t.docChanged)return e;const{deleted:o,pos:r}=t.mapping.mapResult(e);return o?null:r}},props:{decorations:cm,handleDOMEvents:{mousedown:zm},createSelectionBetween:t=>null!=Qf.getState(t.state)?t.state.selection:null,handleTripleClick:jm,handleKeyDown:Om,handlePaste:Im},appendTransaction:(e,n,o)=>function(t,e,n){const o=(e||t).selection,r=(e||t).doc;let i,s;if(o instanceof Ce&&(s=o.node.type.spec.tableRole)){if("cell"==s||"header_cell"==s)i=am.create(r,o.from);else if("row"==s){const t=r.resolve(o.from+1);i=am.rowSelection(t,t)}else if(!n){const t=Gf.get(o.node),e=o.from+1,n=e+t.map[t.width*t.height-1];i=am.create(r,e+1,n)}}else o instanceof xe&&function({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let n=t.pos,o=e.pos,r=t.depth;for(;r>=0&&!(t.after(r+1)<t.end(r));r--,n++);for(let t=e.depth;t>=0&&!(e.before(t+1)>e.start(t));t--,o--);return n==o&&/row|table/.test(t.node(r).type.spec.tableRole)}(o)?i=xe.create(r,o.from):o instanceof xe&&function({$from:t,$to:e}){let n,o;for(let e=t.depth;e>0;e--){const o=t.node(e);if("cell"===o.type.spec.tableRole||"header_cell"===o.type.spec.tableRole){n=o;break}}for(let t=e.depth;t>0;t--){const n=e.node(t);if("cell"===n.type.spec.tableRole||"header_cell"===n.type.spec.tableRole){o=n;break}}return n!==o&&0===e.parentOffset}(o)&&(i=xe.create(r,o.$from.start(),o.$from.end()));return i&&(e||(e=t.tr)).setSelection(i),e}(o,pm(o,n),t)})}var Xm=$l.create({name:"tableCell",addOptions:()=>({HTMLAttributes:{}}),content:"block+",addAttributes:()=>({colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{var e,n;const o=t.getAttribute("colwidth"),r=o?o.split(",").map(t=>parseInt(t,10)):null;if(!r){const o=null==(e=t.closest("table"))?void 0:e.querySelectorAll("colgroup > col"),r=Array.from((null==(n=t.parentElement)?void 0:n.children)||[]).indexOf(t);if(r&&r>-1&&o&&o[r]){const t=o[r].getAttribute("width");return t?[parseInt(t,10)]:null}}return r}}}),tableRole:"cell",isolating:!0,parseHTML:()=>[{tag:"td"}],renderHTML({HTMLAttributes:t}){return["td",aa(this.options.HTMLAttributes,t),0]}}),Qm=$l.create({name:"tableHeader",addOptions:()=>({HTMLAttributes:{}}),content:"block+",addAttributes:()=>({colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(t=>parseInt(t,10)):null}}}),tableRole:"header_cell",isolating:!0,parseHTML:()=>[{tag:"th"}],renderHTML({HTMLAttributes:t}){return["th",aa(this.options.HTMLAttributes,t),0]}}),Zm=$l.create({name:"tableRow",addOptions:()=>({HTMLAttributes:{}}),content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML:()=>[{tag:"tr"}],renderHTML({HTMLAttributes:t}){return["tr",aa(this.options.HTMLAttributes,t),0]}});function tg(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function eg(t,e,n,o,r,i){var s;let a=0,l=!0,c=e.firstChild;const d=t.firstChild;if(null!==d)for(let t=0,n=0;t<d.childCount;t+=1){const{colspan:s,colwidth:h}=d.child(t).attrs;for(let t=0;t<s;t+=1,n+=1){const s=r===n?i:h&&h[t],d=s?`${s}px`:"";if(a+=s||o,s||(l=!1),c){if(c.style.width!==d){const[t,e]=tg(o,s);c.style.setProperty(t,e)}c=c.nextSibling}else{const t=document.createElement("col"),[n,r]=tg(o,s);t.style.setProperty(n,r),e.appendChild(t)}}}for(;c;){const t=c.nextSibling;null==(s=c.parentNode)||s.removeChild(c),c=t}const h=t.attrs.style&&"string"==typeof t.attrs.style&&/\bwidth\s*:/i.test(t.attrs.style);l&&!h?(n.style.width=`${a}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${a}px`)}var ng=class{constructor(t,e){this.node=t,this.cellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),t.attrs.style&&(this.table.style.cssText=t.attrs.style),this.colgroup=this.table.appendChild(document.createElement("colgroup")),eg(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type===this.node.type&&(this.node=t,eg(t,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(t){const e=t.target,n=this.dom.contains(e),o=this.contentDOM.contains(e);return!(!n||o||"attributes"!==t.type&&"childList"!==t.type&&"characterData"!==t.type)}};function og(t,e){return e?t.createChecked(null,e):t.createAndFill()}var rg=({editor:t})=>{const{selection:e}=t.state;if(!(e instanceof am))return!1;let n=0;const o=Qs(e.ranges[0].$from,t=>"table"===t.type.name);return null==o||o.node.descendants(t=>{if("table"===t.type.name)return!1;["tableCell","tableHeader"].includes(t.type.name)&&(n+=1)}),n===e.ranges.length&&(t.commands.deleteTable(),!0)},ig=$l.create({name:"table",addOptions:()=>({HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:ng,lastColumnResizable:!0,allowTableNodeSelection:!1}),content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML:()=>[{tag:"table"}],renderHTML({node:t,HTMLAttributes:e}){const{colgroup:n,tableWidth:o,tableMinWidth:r}=function(t,e){let n=0,o=!0;const r=[],i=t.firstChild;if(!i)return{};for(let t=0,s=0;t<i.childCount;t+=1){const{colspan:a,colwidth:l}=i.child(t).attrs;for(let t=0;t<a;t+=1,s+=1){const i=undefined===s?undefined:l&&l[t];n+=i||e,i||(o=!1);const[a,c]=tg(e,i);r.push(["col",{style:`${a}: ${c}`}])}}const s=o?`${n}px`:"",a=o?"":`${n}px`;return{colgroup:["colgroup",{},...r],tableWidth:s,tableMinWidth:a}}(t,this.options.cellMinWidth),i=e.style,s=["table",aa(this.options.HTMLAttributes,e,{style:i||(o?`width: ${o}`:`min-width: ${r}`)}),n,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},s]:s},parseMarkdown:(t,e)=>{const n=[];if(t.header){const o=[];t.header.forEach(t=>{o.push(e.createNode("tableHeader",{},[{type:"paragraph",content:e.parseInline(t.tokens)}]))}),n.push(e.createNode("tableRow",{},o))}return t.rows&&t.rows.forEach(t=>{const o=[];t.forEach(t=>{o.push(e.createNode("tableCell",{},[{type:"paragraph",content:e.parseInline(t.tokens)}]))}),n.push(e.createNode("tableRow",{},o))}),e.createNode("table",void 0,n)},renderMarkdown:(t,e)=>function(t,e,n={}){var o;const r=null!=(o=n.cellLineSeparator)?o:"";if(!t||!t.content||0===t.content.length)return"";const i=[];t.content.forEach(t=>{const n=[];t.content&&t.content.forEach(t=>{let o="";o=t.content&&Array.isArray(t.content)&&t.content.length>1?t.content.map(t=>e.renderChildren(t)).join(r):t.content?e.renderChildren(t.content):"";const i=(o||"").replace(/\s+/g," ").trim(),s="tableHeader"===t.type;n.push({text:i,isHeader:s})}),i.push(n)});const s=i.reduce((t,e)=>Math.max(t,e.length),0);if(0===s)return"";const a=new Array(s).fill(0);i.forEach(t=>{var e;for(let n=0;n<s;n+=1){const o=((null==(e=t[n])?void 0:e.text)||"").length;o>a[n]&&(a[n]=o),a[n]<3&&(a[n]=3)}});const l=(t,e)=>t+" ".repeat(Math.max(0,e-t.length)),c=i[0],d=c.some(t=>t.isHeader);let h="\n";const p=new Array(s).fill(0).map((t,e)=>d&&c[e]&&c[e].text||"");return h+=`| ${p.map((t,e)=>l(t,a[e])).join(" | ")} |\n`,h+=`| ${a.map(t=>"-".repeat(Math.max(3,t))).join(" | ")} |\n`,(d?i.slice(1):i).forEach(t=>{h+=`| ${new Array(s).fill(0).map((e,n)=>l(t[n]&&t[n].text||"",a[n])).join(" | ")} |\n`}),h}(t,e),addCommands:()=>({insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:o,dispatch:r,editor:i})=>{const s=function(t,e,n,o,r){const i=function(t){if(t.cached.tableNodeTypes)return t.cached.tableNodeTypes;const e={};return Object.keys(t.nodes).forEach(n=>{const o=t.nodes[n];o.spec.tableRole&&(e[o.spec.tableRole]=o)}),t.cached.tableNodeTypes=e,e}(t),s=[],a=[];for(let t=0;t<n;t+=1){const t=og(i.cell,r);if(t&&a.push(t),o){const t=og(i.header_cell,r);t&&s.push(t)}}const l=[];for(let t=0;t<e;t+=1)l.push(i.row.createChecked(null,o&&0===t?s:a));return i.table.createChecked(null,l)}(i.schema,t,e,n);if(r){const t=o.selection.from+1;o.replaceSelectionWith(s).scrollIntoView().setSelection(xe.near(o.doc.resolve(t)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>function(t,e){if(!tm(t))return!1;if(e){const n=um(t);e(fm(t.tr,n,n.left))}return!0}(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>function(t,e){if(!tm(t))return!1;if(e){const n=um(t);e(fm(t.tr,n,n.right))}return!0}(t,e),deleteColumn:()=>({state:t,dispatch:e})=>function(t,e){if(!tm(t))return!1;if(e){const n=um(t),o=t.tr;if(0==n.left&&n.right==n.map.width)return!1;for(let t=n.right-1;mm(o,n,t),t!=n.left;t--){const t=n.tableStart?o.doc.nodeAt(n.tableStart-1):o.doc;if(!t)throw RangeError("No table found");n.table=t,n.map=Gf.get(t)}e(o)}return!0}(t,e),addRowBefore:()=>({state:t,dispatch:e})=>function(t,e){if(!tm(t))return!1;if(e){const n=um(t);e(gm(t.tr,n,n.top))}return!0}(t,e),addRowAfter:()=>({state:t,dispatch:e})=>function(t,e){if(!tm(t))return!1;if(e){const n=um(t);e(gm(t.tr,n,n.bottom))}return!0}(t,e),deleteRow:()=>({state:t,dispatch:e})=>function(t,e){if(!tm(t))return!1;if(e){const n=um(t),o=t.tr;if(0==n.top&&n.bottom==n.map.height)return!1;for(let t=n.bottom-1;ym(o,n,t),t!=n.top;t--){const t=n.tableStart?o.doc.nodeAt(n.tableStart-1):o.doc;if(!t)throw RangeError("No table found");n.table=t,n.map=Gf.get(n.table)}e(o)}return!0}(t,e),deleteTable:()=>({state:t,dispatch:e})=>function(t,e){const n=t.selection.$anchor;for(let o=n.depth;o>0;o--)if("table"==n.node(o).type.spec.tableRole)return e&&e(t.tr.delete(n.before(o),n.after(o)).scrollIntoView()),!0;return!1}(t,e),mergeCells:()=>({state:t,dispatch:e})=>vm(t,e),splitCell:()=>({state:t,dispatch:e})=>wm(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>xm("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>xm("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>Mm(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>!!vm(t,e)||wm(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:o})=>function(t,e){return function(n,o){if(!tm(n))return!1;const r=em(n);if(r.nodeAfter.attrs[t]===e)return!1;if(o){const i=n.tr;n.selection instanceof am?n.selection.forEachCell((n,o)=>{n.attrs[t]!==e&&i.setNodeMarkup(o,null,{...n.attrs,[t]:e})}):i.setNodeMarkup(r.pos,null,{...r.nodeAfter.attrs,[t]:e}),o(i)}return!0}}(t,e)(n,o),goToNextCell:()=>({state:t,dispatch:e})=>Cm(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>Cm(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&pm(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const n=am.create(e.doc,t.anchorCell,t.headCell);e.setSelection(n)}return!0}}),addKeyboardShortcuts(){return{Tab:()=>!!this.editor.commands.goToNextCell()||!!this.editor.can().addRowAfter()&&this.editor.chain().addRowAfter().goToNextCell().run(),"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:rg,"Mod-Backspace":rg,Delete:rg,"Mod-Delete":rg}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[Fm({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],Ym({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema:t=>({tableRole:ra(ta(t,"tableRole",{name:t.name,options:t.options,storage:t.storage}))})}),sg=(cl.create({name:"tableKit",addExtensions(){const t=[];return!1!==this.options.table&&t.push(ig.configure(this.options.table)),!1!==this.options.tableCell&&t.push(Xm.configure(this.options.tableCell)),!1!==this.options.tableHeader&&t.push(Qm.configure(this.options.tableHeader)),!1!==this.options.tableRow&&t.push(Zm.configure(this.options.tableRow)),t}}),(t,e=0)=>{const n=[];return!t.children.length||e>20||Array.from(t.children).forEach(t=>{"SPAN"===t.tagName?n.push(t):t.children.length&&n.push(...sg(t,e+1))}),n}),ag=rl.create({name:"textStyle",priority:101,addOptions:()=>({HTMLAttributes:{},mergeNestedSpanStyles:!0}),parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>!!t.hasAttribute("style")&&(this.options.mergeNestedSpanStyles&&(t=>{if(!t.children.length)return;const e=sg(t);e&&e.forEach(t=>{var e,n;const o=t.getAttribute("style"),r=null==(n=null==(e=t.parentElement)?void 0:e.closest("span"))?void 0:n.getAttribute("style");t.setAttribute("style",`${r};${o}`)})})(t),{})}]},renderHTML({HTMLAttributes:t}){return["span",aa(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleTextStyle:t=>({commands:e})=>e.toggleMark(this.name,t),removeEmptyTextStyle:()=>({tr:t})=>{const{selection:e}=t;return t.doc.nodesBetween(e.from,e.to,(e,n)=>{if(e.isTextblock)return!0;e.marks.filter(t=>t.type===this.type).some(t=>Object.values(t.attrs).some(t=>!!t))||t.removeMark(n,n+e.nodeSize,this.type)}),!0}}}}),lg=cl.create({name:"backgroundColor",addOptions:()=>({types:["textStyle"]}),addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const t=n.split(";").map(t=>t.trim()).filter(Boolean);for(let e=t.length-1;e>=0;e-=1){const n=t[e].split(":");if(n.length>=2){const t=n[0].trim().toLowerCase(),e=n.slice(1).join(":").trim();if("background-color"===t)return e.replace(/['"]+/g,"")}}}return null==(e=t.style.backgroundColor)?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.backgroundColor?{style:`background-color: ${t.backgroundColor}`}:{}}}}]},addCommands:()=>({setBackgroundColor:t=>({chain:e})=>e().setMark("textStyle",{backgroundColor:t}).run(),unsetBackgroundColor:()=>({chain:t})=>t().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()})}),cg=cl.create({name:"color",addOptions:()=>({types:["textStyle"]}),addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const t=n.split(";").map(t=>t.trim()).filter(Boolean);for(let e=t.length-1;e>=0;e-=1){const n=t[e].split(":");if(n.length>=2){const t=n[0].trim().toLowerCase(),e=n.slice(1).join(":").trim();if("color"===t)return e.replace(/['"]+/g,"")}}}return null==(e=t.style.color)?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}}}}]},addCommands:()=>({setColor:t=>({chain:e})=>e().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()})}),dg=cl.create({name:"fontFamily",addOptions:()=>({types:["textStyle"]}),addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:t=>t.style.fontFamily,renderHTML:t=>t.fontFamily?{style:`font-family: ${t.fontFamily}`}:{}}}}]},addCommands:()=>({setFontFamily:t=>({chain:e})=>e().setMark("textStyle",{fontFamily:t}).run(),unsetFontFamily:()=>({chain:t})=>t().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()})}),hg=cl.create({name:"fontSize",addOptions:()=>({types:["textStyle"]}),addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:t=>t.style.fontSize,renderHTML:t=>t.fontSize?{style:`font-size: ${t.fontSize}`}:{}}}}]},addCommands:()=>({setFontSize:t=>({chain:e})=>e().setMark("textStyle",{fontSize:t}).run(),unsetFontSize:()=>({chain:t})=>t().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()})}),pg=cl.create({name:"lineHeight",addOptions:()=>({types:["textStyle"]}),addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:t=>t.style.lineHeight,renderHTML:t=>t.lineHeight?{style:`line-height: ${t.lineHeight}`}:{}}}}]},addCommands:()=>({setLineHeight:t=>({chain:e})=>e().setMark("textStyle",{lineHeight:t}).run(),unsetLineHeight:()=>({chain:t})=>t().setMark("textStyle",{lineHeight:null}).removeEmptyTextStyle().run()})}),ug=(cl.create({name:"textStyleKit",addExtensions(){const t=[];return!1!==this.options.backgroundColor&&t.push(lg.configure(this.options.backgroundColor)),!1!==this.options.color&&t.push(cg.configure(this.options.color)),!1!==this.options.fontFamily&&t.push(dg.configure(this.options.fontFamily)),!1!==this.options.fontSize&&t.push(hg.configure(this.options.fontSize)),!1!==this.options.lineHeight&&t.push(pg.configure(this.options.lineHeight)),!1!==this.options.textStyle&&t.push(ag.configure(this.options.textStyle)),t}}),/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/),fg=$l.create({name:"image",addOptions:()=>({inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}),inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes:()=>({src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}),parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:t}){return["img",aa(this.options.HTMLAttributes,t)]},parseMarkdown:(t,e)=>e.createNode("image",{src:t.href,title:t.title,alt:t.text}),renderMarkdown:t=>{var e,n,o,r,i,s;const a=null!=(n=null==(e=t.attrs)?void 0:e.src)?n:"",l=null!=(r=null==(o=t.attrs)?void 0:o.alt)?r:"",c=null!=(s=null==(i=t.attrs)?void 0:i.title)?s:"";return c?`![${l}](${a} "${c}")`:`![${l}](${a})`},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||"undefined"==typeof document)return null;const{directions:t,minWidth:e,minHeight:n,alwaysPreserveAspectRatio:o}=this.options.resize;return({node:r,getPos:i,HTMLAttributes:s,editor:a})=>{const l=document.createElement("img");Object.entries(s).forEach(([t,e])=>{if(null!=e)switch(t){case"width":case"height":break;default:l.setAttribute(t,e)}}),l.src=s.src;const c=new Al({element:l,editor:a,node:r,getPos:i,onResize:(t,e)=>{l.style.width=`${t}px`,l.style.height=`${e}px`},onCommit:(t,e)=>{const n=i();void 0!==n&&this.editor.chain().setNodeSelection(n).updateAttributes(this.name,{width:t,height:e}).run()},onUpdate:(t,e,n)=>t.type===r.type,options:{directions:t,min:{width:e,height:n},preserveAspectRatio:!0===o}}),d=c.dom;return d.style.visibility="hidden",d.style.pointerEvents="none",l.onload=()=>{d.style.visibility="",d.style.pointerEvents=""},c}},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[Cl({find:ug,type:this.type,getAttributes:t=>{const[,,e,n,o]=t;return{src:n,alt:e,title:o}}})]}}),mg=fg,gg=n(11);function yg(t,e=[]){return t.flatMap(t=>{const n=[...e,...t.properties?t.properties.className:[]];return t.children?yg(t.children,n):{text:t.value,classes:n}})}function bg(t){return t.value||t.children||[]}function vg({doc:t,name:e,lowlight:n,defaultLanguage:o}){const r=[];return Xs(t,t=>t.type.name===e).forEach(t=>{var e;let i=t.pos+1;const s=t.node.attrs.language||o,a=n.listLanguages();var l;yg(s&&(a.includes(s)||(l=s,Boolean(gg.A.getLanguage(l)))||(null==(e=n.registered)?void 0:e.call(n,s)))?bg(n.highlight(s,t.node.textContent)):bg(n.highlightAuto(t.node.textContent))).forEach(t=>{const e=i+t.text.length;if(t.classes.length){const n=Jr.inline(i,e,{class:t.classes.join(" ")});r.push(n)}i=e})}),Xr.create(t,r)}function wg({name:t,lowlight:e,defaultLanguage:n}){if(!["highlight","highlightAuto","listLanguages"].every(t=>"function"==typeof e[t]))throw Error("You should provide an instance of lowlight to use the code-block-lowlight extension");const o=new $e({key:new Be("lowlight"),state:{init:(o,{doc:r})=>vg({doc:r,name:t,lowlight:e,defaultLanguage:n}),apply:(o,r,i,s)=>{const a=i.selection.$head.parent.type.name,l=s.selection.$head.parent.type.name,c=Xs(i.doc,e=>e.type.name===t),d=Xs(s.doc,e=>e.type.name===t);return o.docChanged&&([a,l].includes(t)||d.length!==c.length||o.steps.some(t=>void 0!==t.from&&void 0!==t.to&&c.some(e=>e.pos>=t.from&&e.pos+e.node.nodeSize<=t.to)))?vg({doc:o.doc,name:t,lowlight:e,defaultLanguage:n}):r.map(o.mapping,o.doc)}},props:{decorations:t=>o.getState(t)}});return o}var kg=Mh.extend({addOptions(){var t;return{...null==(t=this.parent)?void 0:t.call(this),lowlight:{},languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:4,HTMLAttributes:{}}},addProseMirrorPlugins(){var t;return[...(null==(t=this.parent)?void 0:t.call(this))||[],wg({name:this.name,lowlight:this.options.lowlight,defaultLanguage:this.options.defaultLanguage})]}});const xg={};class Mg{constructor(t){this.options=t,this.root={type:"root",children:[],data:{language:void 0,relevance:0}},this.stack=[this.root]}addText(t){if(""===t)return;const e=this.stack[this.stack.length-1],n=e.children[e.children.length-1];n&&"text"===n.type?n.value+=t:e.children.push({type:"text",value:t})}startScope(t){this.openNode(String(t))}endScope(){this.closeNode()}__addSublanguage(t,e){const n=this.stack[this.stack.length-1],o=t.root.children;e?n.children.push({type:"element",tagName:"span",properties:{className:[e]},children:o}):n.children.push(...o)}openNode(t){const e=this,n=t.split(".").map(function(t,n){return n?t+"_".repeat(n):e.options.classPrefix+t}),o={type:"element",tagName:"span",properties:{className:n},children:[]};this.stack[this.stack.length-1].children.push(o),this.stack.push(o)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}var Cg=n(5387),Sg=n(5603),Tg=n(5262),Ag=n(2753),Eg=n(9510),Ng=n(7479),Og=n(8906),Lg=function(){const t=gg.A.newInstance();return{highlight:e,highlightAuto:function(o,r){const i=(r||xg).subset||n();let s,a=-1,l=0;for(;++a<i.length;){const n=i[a];if(!t.getLanguage(n))continue;const c=e(n,o,r);c.data&&void 0!==c.data.relevance&&c.data.relevance>l&&(l=c.data.relevance,s=c)}return s||{type:"root",children:[],data:{language:void 0,relevance:l}}},listLanguages:n,register:o,registerAlias:function(e,n){if("string"==typeof e)t.registerAliases("string"==typeof n?n:[...n],{languageName:e});else{let n;for(n in e)if(Object.hasOwn(e,n)){const o=e[n];t.registerAliases("string"==typeof o?o:[...o],{languageName:n})}}},registered:function(e){return Boolean(t.getLanguage(e))}};function e(e,n,o){const r=o||xg,i="string"==typeof r.prefix?r.prefix:"hljs-";if(!t.getLanguage(e))throw new Error("Unknown language: `"+e+"` is not registered");t.configure({__emitter:Mg,classPrefix:i});const s=t.highlight(n,{ignoreIllegals:!0,language:e});if(s.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:s.errorRaised});const a=s._emitter.root,l=a.data;return l.language=s.language,l.relevance=s.relevance,a}function n(){return t.listLanguages()}function o(e,n){if("string"==typeof e)t.registerLanguage(e,n);else{let n;for(n in e)Object.hasOwn(e,n)&&t.registerLanguage(n,e[n])}}}();Lg.register({ts:Cg.A,js:Sg.A,python:Tg.A,py:Tg.A,css:Ag.A,bash:Eg.A,shell:Eg.A,text:function(t){return{name:"Plain text",aliases:["text","txt"],disableAutodetect:!0}}});var Rg={StarterKit:Kf,Superscript:Uf,Subscript:Jf,Highlight:lh,Table:ig,TableCell:Xm,TableHeader:Qm,TableRow:Zm,TextAlign:qf,Placeholder:Hf,Color:cg,TextStyle:ag,BackgroundColor:lg,FontFamily:dg,FontSize:hg,LineHeight:pg,Image:mg,CodeBlockLowlight:kg},Dg=function(t){var e=t.i,n=t.componentPath,r=t.editor,i=t.onClick,a=t.children,l=(0,o.Tt)(t,["i","componentPath","editor","onClick","children"]);return s().createElement(Wd.Control,(0,o.Cl)({onClick:function(t){r&&(0,ih.q)(i)({editor:r,event:t})}},l),(0,Ng.o5)(a,e,(0,o.fX)((0,o.fX)([],n,!0),["CustomControl","children"],!1)))},jg=function(t){var e=t.id,n=t.setProps,r=t.loading_state,a=(t.persistence,t.persisted_props,t.persistence_type,t.html),l=t.json,c=t.variant,d=t.extensions,h=void 0===d?[{StarterKit:{codeBlock:!1}},{CodeBlockLowlight:{lowlight:Lg}},"Superscript","Subscript","Highlight","Table","TableCell","TableHeader","TableRow",{Placeholder:{placeholder:"Write or paste content here..."}},{TextAlign:{types:["heading","paragraph"]}},"Color","TextStyle","BackgroundColor","FontFamily","FontSize","LineHeight","Image"]:d,p=t.toolbar,u=t.debounce,f=void 0===u?100:u,m=t.n_blur,y=void 0===m?0:m,b=(t.selected,t.labels),v=t.focus,w=t.editable,k=void 0===w||w,x=(0,o.Tt)(t,["id","setProps","loading_state","persistence","persisted_props","persistence_type","html","json","variant","extensions","toolbar","debounce","n_blur","selected","labels","focus","editable"]),M=function(t){void 0===t&&(t={}),z&&n((0,o.Cl)({html:z.getHTML(),json:z.getJSON()},t))},C=(0,i.useState)(""),S=C[0],T=C[1],A="number"==typeof f?f:0,E=(0,oh.o)(S,A)[0];(0,rh.C)(function(){"number"!=typeof f&&!1!==f||M()},[E]),(0,rh.C)(function(){z&&z.getHTML()!==a&&(z.commands.setContent(a),M())},[a]),(0,rh.C)(function(){z&&JSON.stringify(z.getJSON())!==JSON.stringify(l)&&(z.commands.setContent(l),M())},[l]);var N=(0,i.useState)(""),O=N[0],L=N[1],R=(0,oh.o)(O,A)[0];(0,rh.C)(function(){"number"!=typeof f&&!1!==f||n({selected:R})},[R]);var D=b&&(0,o.Cl)((0,o.Cl)((0,o.Cl)({},b),b.colorControlLabel&&{colorControlLabel:function(t){return b.colorControlLabel.replace("{color}",t)}}),b.colorPickerColorLabel&&{colorPickerColorLabel:function(t){return b.colorPickerColorLabel.replace("{color}",t)}}),j=void 0,I=h.map(function(t){if("string"==typeof t){if("CodeBlockLowlight"===t)return Rg.CodeBlockLowlight.configure({lowlight:Lg});if(!(t in Rg))throw new Error('Unknown extension: "'.concat(t,'"'));return Rg[t]}if(!t||"object"!=typeof t)throw new Error("Invalid extension format: ".concat(t));var e=Object.keys(t);if(0===e.length)throw new Error("Empty extension object");if(e.length>1)throw new Error("Extension object should have one key, got: ".concat(e.join(", ")));var n=e[0];if(!(n in Rg))throw new Error('Unknown extension: "'.concat(n,'"'));return"CodeBlockLowlight"===n?Rg.CodeBlockLowlight.configure((0,o.Cl)({lowlight:Lg},t.CodeBlockLowlight||{})):Rg[n].configure(t[n])}).filter(Boolean),z=function(t={},e=[]){const n=(0,i.useRef)(t);n.current=t;const[o]=(0,i.useState)(()=>new Yl(n)),r=(0,g.useSyncExternalStore)(o.subscribe,o.getEditor,o.getServerSnapshot);return(0,i.useDebugValue)(r),(0,i.useEffect)(o.onRender(e)),function(t){var e;const[n]=(0,i.useState)(()=>new Ul(t.editor)),o=(0,Bl.useSyncExternalStoreWithSelector)(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,null!=(e=t.equalityFn)?e:Hl.bD);ql(()=>n.watch(t.editor),[t.editor,n]),(0,i.useDebugValue)(o)}({editor:r,selector:({transactionNumber:e})=>!1===t.shouldRerenderOnTransaction||void 0===t.shouldRerenderOnTransaction?null:t.immediatelyRender&&0===e?0:e+1}),r}({extensions:I,content:l||a,onUpdate:function(t){var e=t.editor;T(e.getJSON())},onBlur:function(){z&&!0===f&&M({n_blur:y+1,selected:O})},onSelectionUpdate:function(t){var e=t.editor;if(e){var n=e.state.selection,o=n.from,r=n.to,i=e.state.doc.textBetween(o,r," ");L(i)}},onCreate:M,shouldRerenderOnTransaction:!0});if((0,i.useEffect)(function(){return z&&e&&(Og.u[e]=z),function(){e&&delete Og.u[e]}},[z,e]),(0,i.useEffect)(function(){z&&void 0!==v&&(!1===v?z.commands.blur():z.commands.focus(!0===v?void 0:v),n({focus:void 0}))},[v,z]),(0,i.useEffect)(function(){z&&z.setEditable(k)},[k,z]),void 0!==p&&k){var $=(0,Ng.z5)();j=s().createElement(Wd.Toolbar,{sticky:p.sticky,stickyOffset:p.stickyOffset},p.controlsGroups.map(function(t,e){return s().createElement(Wd.ControlsGroup,{key:e},t.map(function(t,n){return function(t,e,n,r){if("string"==typeof t)return s().createElement(Wd[t],{key:e});var i=Object.keys(t)[0],a=t[i];return"CustomControl"!==i?s().createElement(Wd[i],(0,o.Cl)({key:e},a)):s().createElement(Dg,(0,o.Cl)({i:e,key:"custom-".concat(e),componentPath:r,editor:n},a))}(t,n,z,(0,o.fX)((0,o.fX)([],$,!0),["props","toolbar","controlsGroups",e,n],!1))}))}))}return s().createElement(Wd,(0,o.Cl)({id:e,variant:c,editor:z,"data-dash-is-loading":(0,Ng.A_)(r)||void 0,labels:D},x),j,s().createElement(Wd.Content,null))};(0,Ng.oM)(jg,["html","json"]);const Ig=jg},2162:(t,e,n)=>{var o=n(295),r=n(9888),i="function"==typeof Object.is?Object.is:function(t,e){return t===e&&(0!==t||1/t==1/e)||t!=t&&e!=e},s=r.useSyncExternalStore,a=o.useRef,l=o.useEffect,c=o.useMemo,d=o.useDebugValue;e.useSyncExternalStoreWithSelector=function(t,e,n,o,r){var h=a(null);if(null===h.current){var p={hasValue:!1,value:null};h.current=p}else p=h.current;h=c(function(){function t(t){if(!l){if(l=!0,s=t,t=o(t),void 0!==r&&p.hasValue){var e=p.value;if(r(e,t))return a=e}return a=t}if(e=a,i(s,t))return e;var n=o(t);return void 0!==r&&r(e,n)?(s=t,e):(s=t,a=n)}var s,a,l=!1,c=void 0===n?null:n;return[function(){return t(e())},null===c?void 0:function(){return t(c())}]},[e,n,o,r]);var u=s(t,h[0],h[1]);return l(function(){p.hasValue=!0,p.value=u},[u]),d(u),u}},4417:t=>{t.exports=function(t,e){return e||(e={}),t?(t=String(t.__esModule?t.default:t),/^['"].*['"]$/.test(t)&&(t=t.slice(1,-1)),e.hash&&(t+=e.hash),/["'() \t\n]|(%20)/.test(t)||e.needQuotes?'"'.concat(t.replace(/"/g,'\\"').replace(/\n/g,"\\n"),'"'):t):t}},4985:t=>{t.exports="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCAxMCA3Ij48cGF0aCBmaWxsPSIjZmZmIiBkPSJNNCA0LjU4NkwxLjcwNyAyLjI5M0ExIDEgMCAxMC4yOTMgMy43MDdsMyAzYS45OTcuOTk3IDAgMDAxLjQxNCAwbDUtNUExIDEgMCAxMDguMjkzLjI5M0w0IDQuNTg2eiIvPjwvc3ZnPg=="},6541:(t,e,n)=>{n.d(e,{A:()=>p});var o=n(1601),r=n.n(o),i=n(6314),s=n.n(i),a=n(4417),l=n.n(a),c=new URL(n(4985),n.b),d=s()(r()),h=l()(c);d.push([t.id,`.m_dd3f7539 {\n position: relative;\n border: calc(0.0625rem * var(--mantine-scale)) solid;\n border-radius: var(--mantine-radius-default);\n}\n\n :where([data-mantine-color-scheme='light']) .m_dd3f7539 {\n border-color: var(--mantine-color-gray-4);\n}\n\n :where([data-mantine-color-scheme='dark']) .m_dd3f7539 {\n border-color: var(--mantine-color-dark-4);\n}\n\n.m_f2016866 {\n padding: 0;\n margin: 0;\n}\n\n.m_f2016866 li > p {\n margin: 0;\n }\n\n.m_f2016866 ul li,\n .m_f2016866 ol li {\n margin-top: calc(0.125rem * var(--mantine-scale));\n }\n\n.m_f2016866 p {\n margin-bottom: calc(0.4375rem * var(--mantine-scale));\n }\n\n.m_f2016866 h1,\n .m_f2016866 h2,\n .m_f2016866 h3,\n .m_f2016866 h4,\n .m_f2016866 h5,\n .m_f2016866 h6,\n .m_f2016866 p {\n margin-top: 0;\n }\n\n.m_c2204cc2 {\n background-color: var(--mantine-color-body);\n border-radius: var(--mantine-radius-default);\n}\n\n.m_c2204cc2 .ProseMirror {\n outline: 0;\n padding: var(--mantine-spacing-md);\n }\n\n.m_c2204cc2 .ProseMirror > *:last-child {\n margin-bottom: 0;\n }\n\n.m_c2204cc2 .ProseMirror p.is-editor-empty:first-of-type::before {\n content: attr(data-placeholder);\n pointer-events: none;\n user-select: none;\n float: left;\n height: 0;\n color: var(--mantine-color-placeholder);\n }\n\n.m_c2204cc2 pre {\n font-family: var(--mantine-font-family-monospace);\n border-radius: var(--mantine-radius-default);\n padding: var(--mantine-spacing-sm) var(--mantine-spacing-md);\n }\n\n:where([data-mantine-color-scheme='light']) .m_c2204cc2 pre {\n background-color: var(--mantine-color-gray-0);\n color: var(--mantine-color-gray-9);\n --code-color-comment: var(--mantine-color-gray-5);\n --code-color-var: var(--mantine-color-red-7);\n --code-color-number: var(--mantine-color-blue-7);\n --code-color-title: var(--mantine-color-pink-7);\n --code-color-keyword: var(--mantine-color-violet-7);\n}\n\n:where([data-mantine-color-scheme='dark']) .m_c2204cc2 pre {\n background-color: var(--mantine-color-dark-8);\n color: var(--mantine-color-dark-1);\n --code-color-comment: var(--mantine-color-dark-2);\n --code-color-var: var(--mantine-color-red-5);\n --code-color-number: var(--mantine-color-cyan-5);\n --code-color-title: var(--mantine-color-yellow-5);\n --code-color-keyword: var(--mantine-color-violet-3);\n}\n\n.m_c2204cc2 pre code {\n background: none !important;\n color: inherit;\n font-size: var(--mantine-font-size-sm);\n padding: 0;\n }\n\n.m_c2204cc2 pre .hljs-comment,\n .m_c2204cc2 pre .hljs-quote {\n color: var(--code-color-comment);\n }\n\n.m_c2204cc2 pre .hljs-variable,\n .m_c2204cc2 pre .hljs-template-variable,\n .m_c2204cc2 pre .hljs-attribute,\n .m_c2204cc2 pre .hljs-tag,\n .m_c2204cc2 pre .hljs-regexp,\n .m_c2204cc2 pre .hljs-link,\n .m_c2204cc2 pre .hljs-name,\n .m_c2204cc2 pre .hljs-selector-id,\n .m_c2204cc2 pre .hljs-selector-class {\n color: var(--code-color-var);\n }\n\n.m_c2204cc2 pre .hljs-number,\n .m_c2204cc2 pre .hljs-meta,\n .m_c2204cc2 pre .hljs-built_in,\n .m_c2204cc2 pre .hljs-builtin-name,\n .m_c2204cc2 pre .hljs-literal,\n .m_c2204cc2 pre .hljs-type,\n .m_c2204cc2 pre .hljs-params {\n color: var(--code-color-number);\n }\n\n.m_c2204cc2 pre .hljs-string,\n .m_c2204cc2 pre .hljs-symbol,\n .m_c2204cc2 pre .hljs-bullet {\n color: var(--code-color-var);\n }\n\n.m_c2204cc2 pre .hljs-title,\n .m_c2204cc2 pre .hljs-section {\n color: var(--code-color-title);\n }\n\n.m_c2204cc2 pre .hljs-keyword,\n .m_c2204cc2 pre .hljs-selector-tag {\n color: var(--code-color-keyword);\n }\n\n.m_c2204cc2 pre .hljs-emphasis {\n font-style: italic;\n }\n\n.m_c2204cc2 pre .hljs-strong {\n font-weight: 700;\n }\n\n.m_8a991b4f {\n background-color: var(--mantine-color-body);\n}\n\n.m_c2207da6 {\n display: flex;\n justify-content: center;\n align-items: center;\n border-radius: var(--mantine-radius-default);\n cursor: default;\n}\n\n.m_c2207da6:where([data-variant='default']) {\n border: calc(0.0625rem * var(--mantine-scale)) solid;\n min-width: calc(1.625rem * var(--mantine-scale));\n height: calc(1.625rem * var(--mantine-scale));\n }\n\n.m_c2207da6:where([data-variant='subtle']) {\n --control-icon-size: calc(1.25rem * var(--mantine-scale));\n min-width: calc(2rem * var(--mantine-scale));\n height: calc(2rem * var(--mantine-scale));\n }\n\n:where([data-mantine-color-scheme='light']) .m_c2207da6 {\n background-color: var(--mantine-color-white);\n border-color: var(--mantine-color-gray-4);\n color: var(--mantine-color-gray-7);\n}\n\n:where([data-mantine-color-scheme='dark']) .m_c2207da6 {\n border-color: var(--mantine-color-dark-4);\n color: var(--mantine-color-dark-1);\n}\n\n:where([data-mantine-color-scheme='dark']) .m_c2207da6:where([data-variant='default']) {\n background-color: var(--mantine-color-dark-6);\n }\n\n:where([data-mantine-color-scheme='dark']) .m_c2207da6:where([data-variant='subtle']) {\n background-color: var(--mantine-color-dark-7);\n }\n\n.m_c2207da6:where([data-disabled]) {\n cursor: not-allowed;\n color: var(--mantine-color-disabled-color);\n background-color: var(--mantine-color-disabled);\n }\n\n.m_c2207da6:where([data-interactive]:not([data-disabled])) {\n cursor: pointer;\n }\n\n@media (hover: hover) {\n\n .m_c2207da6:where([data-interactive]:not([data-disabled])):hover {\n color: var(--mantine-color-bright);\n }\n :where([data-mantine-color-scheme='light']) .m_c2207da6:where([data-interactive]:not([data-disabled])):hover:where([data-variant='default']) {\n background-color: var(--mantine-color-gray-0);\n }\n\n :where([data-mantine-color-scheme='light']) .m_c2207da6:where([data-interactive]:not([data-disabled])):hover:where([data-variant='subtle']) {\n background-color: var(--mantine-color-gray-1);\n }\n\n :where([data-mantine-color-scheme='dark']) .m_c2207da6:where([data-interactive]:not([data-disabled])):hover {\n background-color: var(--mantine-color-dark-5);\n }\n}\n\n@media (hover: none) {\n\n .m_c2207da6:where([data-interactive]:not([data-disabled])):active {\n color: var(--mantine-color-bright);\n }\n :where([data-mantine-color-scheme='light']) .m_c2207da6:where([data-interactive]:not([data-disabled])):active:where([data-variant='default']) {\n background-color: var(--mantine-color-gray-0);\n }\n\n :where([data-mantine-color-scheme='light']) .m_c2207da6:where([data-interactive]:not([data-disabled])):active:where([data-variant='subtle']) {\n background-color: var(--mantine-color-gray-1);\n }\n\n :where([data-mantine-color-scheme='dark']) .m_c2207da6:where([data-interactive]:not([data-disabled])):active {\n background-color: var(--mantine-color-dark-5);\n }\n}\n\n.m_c2207da6:where([data-active]) {\n background-color: var(--mantine-primary-color-light);\n color: var(--mantine-primary-color-light-color);\n }\n\n@media (hover: hover) {\n\n .m_c2207da6:where([data-active]):hover {\n background-color: var(--mantine-primary-color-light-hover);\n }\n}\n\n@media (hover: none) {\n\n .m_c2207da6:where([data-active]):active {\n background-color: var(--mantine-primary-color-light-hover);\n }\n}\n\n.m_9cdfeb3f {\n width: var(--control-icon-size, 16px);\n height: var(--control-icon-size, 16px);\n}\n\n.m_2ab47ef2 {\n display: flex;\n background-color: var(--mantine-color-body);\n}\n\n.m_2ab47ef2:where([data-variant='default']) :where([data-rich-text-editor-control]) {\n border-radius: 0;\n }\n\n.m_2ab47ef2:where([data-variant='default']) :where([data-rich-text-editor-control]):where(:not(:last-of-type)) {\n border-inline-end-width: 0;\n }\n\n.m_2ab47ef2:where([data-variant='default']) :where([data-rich-text-editor-control]):where(:last-of-type) {\n border-start-end-radius: var(--mantine-radius-default);\n border-end-end-radius: var(--mantine-radius-default);\n }\n\n.m_2ab47ef2:where([data-variant='default']) :where([data-rich-text-editor-control]):where(:first-of-type) {\n border-start-start-radius: var(--mantine-radius-default);\n border-end-start-radius: var(--mantine-radius-default);\n }\n\n.m_b67b711e {\n display: flex;\n}\n\n.m_296cf94c {\n border-start-end-radius: 0;\n border-end-end-radius: 0;\n border-inline-end: 0;\n}\n\n.m_cfef614 {\n border: calc(0.0625rem * var(--mantine-scale)) solid;\n color: var(--mantine-color-text);\n height: calc(1.5rem * var(--mantine-scale));\n width: calc(1.5rem * var(--mantine-scale));\n display: flex;\n justify-content: center;\n align-items: center;\n border-radius: var(--mantine-radius-default);\n}\n\n:where([data-mantine-color-scheme='light']) .m_cfef614 {\n background-color: var(--mantine-color-white);\n border-color: var(--mantine-color-gray-4);\n}\n\n:where([data-mantine-color-scheme='dark']) .m_cfef614 {\n background-color: var(--mantine-color-dark-7);\n border-color: var(--mantine-color-dark-4);\n}\n\n.m_cfef614:where([data-active]) {\n background-color: var(--mantine-primary-color-light);\n color: var(--mantine-primary-color-filled);\n }\n\n@media (hover: hover) {\n\n .m_cfef614:where([data-active]):hover {\n background-color: var(--mantine-primary-color-light-hover);\n }\n}\n\n@media (hover: none) {\n\n .m_cfef614:where([data-active]):active {\n background-color: var(--mantine-primary-color-light-hover);\n }\n}\n\n.m_3b28e7bb {\n border-start-start-radius: 0;\n border-end-start-radius: 0;\n}\n\n.m_4574a3c4 {\n display: flex;\n align-items: center;\n flex-wrap: wrap;\n gap: var(--mantine-spacing-sm);\n top: var(--rte-sticky-offset, 0px);\n background-color: var(--mantine-color-body);\n border-start-end-radius: var(--mantine-radius-default);\n border-start-start-radius: var(--mantine-radius-default);\n border-bottom: calc(0.0625rem * var(--mantine-scale)) solid;\n}\n\n.m_4574a3c4:where([data-variant='default']) {\n padding: var(--mantine-spacing-xs) var(--mantine-spacing-md);\n }\n\n.m_4574a3c4:where([data-variant='subtle']) {\n padding: calc(0.25rem * var(--mantine-scale));\n row-gap: 0;\n }\n\n:where([data-mantine-color-scheme='light']) .m_4574a3c4 {\n border-color: var(--mantine-color-gray-4);\n}\n\n:where([data-mantine-color-scheme='dark']) .m_4574a3c4 {\n border-color: var(--mantine-color-dark-4);\n}\n\n.m_4574a3c4:where([data-sticky]) {\n position: sticky;\n z-index: 1;\n }\n\n.m_8b44009a {\n list-style-type: none;\n padding: 0;\n padding-inline-start: 0;\n}\n\n.m_8b44009a :where(li) {\n margin: 0;\n padding: 0;\n display: flex;\n }\n\n.m_8b44009a :where(ul) {\n margin-top: calc(0.3125rem * var(--mantine-scale));\n }\n\n.m_8b44009a p {\n margin: 0;\n padding: 0;\n }\n\n.m_8b44009a :where(label) {\n display: inline-block;\n }\n\n.m_8b44009a :where(input) {\n cursor: pointer;\n appearance: none;\n width: calc(1.125rem * var(--mantine-scale));\n height: calc(1.125rem * var(--mantine-scale));\n border: calc(0.0625rem * var(--mantine-scale)) solid;\n border-radius: var(--mantine-radius-default);\n vertical-align: middle;\n position: relative;\n }\n\n:where([data-mantine-color-scheme='light']) .m_8b44009a :where(input) {\n background-color: var(--mantine-color-white);\n border-color: var(--mantine-color-gray-4);\n}\n\n:where([data-mantine-color-scheme='dark']) .m_8b44009a :where(input) {\n background-color: var(--mantine-color-dark-6);\n border-color: var(--mantine-color-dark-4);\n}\n\n.m_8b44009a :where(input):checked {\n background-color: var(--mantine-primary-color-filled);\n border-color: var(--mantine-primary-color-filled);\n }\n\n.m_8b44009a :where(input):checked::before {\n position: absolute;\n content: '';\n inset: 0;\n background-image: url(${h});\n background-repeat: no-repeat;\n background-size: calc(0.625rem * var(--mantine-scale));\n background-position: center;\n }\n\n.m_8b44009a :where(li > label) {\n margin-inline-end: var(--mantine-spacing-sm);\n }\n`,""]);const p=d},8493:(t,e,n)=>{var o=n(295),r="function"==typeof Object.is?Object.is:function(t,e){return t===e&&(0!==t||1/t==1/e)||t!=t&&e!=e},i=o.useState,s=o.useEffect,a=o.useLayoutEffect,l=o.useDebugValue;function c(t){var e=t.getSnapshot;t=t.value;try{var n=e();return!r(t,n)}catch(t){return!0}}var d="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(t,e){return e()}:function(t,e){var n=e(),o=i({inst:{value:n,getSnapshot:e}}),r=o[0].inst,d=o[1];return a(function(){r.value=n,r.getSnapshot=e,c(r)&&d({inst:r})},[t,n,e]),s(function(){return c(r)&&d({inst:r}),t(function(){c(r)&&d({inst:r})})},[t]),l(n),n};e.useSyncExternalStore=void 0!==o.useSyncExternalStore?o.useSyncExternalStore:d},9242:(t,e,n)=>{t.exports=n(2162)},9888:(t,e,n)=>{t.exports=n(8493)}}]);