@colixsystems/widget-sdk 0.277.0 → 0.277.2

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,4 +1,4 @@
1
1
  // GENERATED by packages/widget-sdk/scripts/build-markdown-editor.mjs — do not edit.
2
2
  // The page <MarkdownInput>'s native field runs its editor in (sc-15080).
3
3
  /* eslint-disable */
4
- export const MARKDOWN_EDITOR_HTML = "<!doctype html><html><head><meta charset=\"utf-8\"><meta name=\"viewport\" content=\"width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no\"><meta http-equiv=\"Content-Security-Policy\" content=\"default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; img-src https: http:\"><style>html,body{margin:0;padding:0;background:transparent;-webkit-text-size-adjust:100%}</style></head><body><div id=\"root\"></div><script>(()=>{var Gl=Object.defineProperty,Xl=(t,e)=>{let n={};for(var r in t)Gl(n,r,{get:t[r],enumerable:!0});return e||Gl(n,Symbol.toStringTag,{value:\"Module\"}),n};function se(t){this.content=t}se.prototype={constructor:se,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 e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,o=r.find(t),i=r.content.slice();return o==-1?i.push(n||t,e):(i[o+1]=e,n&&(i[o]=n)),new se(i)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new se(n)},addToStart:function(t,e){return new se([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new se(n)},addBefore:function(t,e,n){var r=this.remove(e),o=r.content.slice(),i=r.find(t);return o.splice(i==-1?o.length:i,0,e,n),new se(o)},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=se.from(t),t.size?new se(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=se.from(t),t.size?new se(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=se.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}};se.from=function(t){if(t instanceof se)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new se(e)};var ni=se;function la(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let o=t.child(r),i=e.child(r);if(o==i){n+=o.nodeSize;continue}if(!o.sameMarkup(i))return n;if(o.isText&&o.text!=i.text){let s=o.text,l=i.text,a=0;for(;s[a]==l[a];a++)n++;return a&&a<s.length&&a<l.length&&ua(s.charCodeAt(a-1))&&ca(s.charCodeAt(a))&&n--,n}if(o.content.size||i.content.size){let s=la(o.content,i.content,n+1);if(s!=null)return s}n+=o.nodeSize}}function aa(t,e,n,r){for(let o=t.childCount,i=e.childCount;;){if(o==0||i==0)return o==i?null:{a:n,b:r};let s=t.child(--o),l=e.child(--i),a=s.nodeSize;if(s==l){n-=a,r-=a;continue}if(!s.sameMarkup(l))return{a:n,b:r};if(s.isText&&s.text!=l.text){let c=s.text,u=l.text,d=c.length,f=u.length;for(;d>0&&f>0&&c[d-1]==u[f-1];)d--,f--,n--,r--;return d&&f&&d<c.length&&ua(c.charCodeAt(d-1))&&ca(c.charCodeAt(d))&&(n++,r++),{a:n,b:r}}if(s.content.size||l.content.size){let c=aa(s.content,l.content,n-1,r-1);if(c)return c}n-=a,r-=a}}function ca(t){return t>=56320&&t<57344}function ua(t){return t>=55296&&t<56320}var b=class t{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,o=0,i){for(let s=0,l=0;l<n;s++){let a=this.content[s],c=l+a.nodeSize;if(c>e&&r(a,o+l,i||null,s)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,n-u),r,o+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,o){let i=\"\",s=!0;return this.nodesBetween(e,n,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,n-a):l.isLeaf?o?typeof o==\"function\"?o(l):o:l.type.spec.leafText?l.type.spec.leafText(l):\"\":\"\";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(s?s=!1:i+=r),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,o=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(r)&&(o[o.length-1]=n.withText(n.text+r.text),i=1);i<e.content.length;i++)o.push(e.content[i]);return new t(o,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],o=0;if(n>e)for(let i=0,s=0;s<n;i++){let l=this.content[i],a=s+l.nodeSize;a>e&&((s<e||a>n)&&(l.isText?l=l.cut(Math.max(0,e-s),Math.min(l.text.length,n-s)):l=l.cut(Math.max(0,e-s-1),Math.min(l.content.size,n-s-1))),r.push(l),o+=l.nodeSize),s=a}return new t(r,o)}cutByIndex(e,n){return e==n?t.empty:e==0&&n==this.content.length?this:new t(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let o=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return o[e]=n,new t(o,i)}addToStart(e){return new t([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new t(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))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(e){let n=this.content[e];if(!n)throw new RangeError(\"Index \"+e+\" out of range for \"+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let o=this.content[n];e(o,r,n),r+=o.nodeSize}}findDiffStart(e,n=0){return la(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return aa(this,e,n,r)}findIndex(e){if(e==0)return hr(0,e);if(e==this.size)return hr(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let o=this.child(n),i=r+o.nodeSize;if(i>=e)return i==e?hr(n+1,i):hr(n,r);r=i}}toString(){return\"<\"+this.toStringInner()+\">\"}toStringInner(){return this.content.join(\", \")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return t.empty;if(!Array.isArray(n))throw new RangeError(\"Invalid input for Fragment.fromJSON\");return t.fromArray(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return t.empty;let n,r=0;for(let o=0;o<e.length;o++){let i=e[o];r+=i.nodeSize,o&&i.isText&&e[o-1].sameMarkup(i)?(n||(n=e.slice(0,o)),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new t(n||e,r)}static from(e){if(!e)return t.empty;if(e instanceof t)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new t([e],e.nodeSize);throw new RangeError(\"Can not convert \"+e+\" to a Fragment\"+(e.nodesBetween?\" (looks like multiple versions of prosemirror-model were loaded)\":\"\"))}};b.empty=new b([],0);var ri={index:0,offset:0};function hr(t,e){return ri.index=t,ri.offset=e,ri}function gr(t,e){if(t===e)return!0;if(!(t&&typeof t==\"object\")||!(e&&typeof e==\"object\"))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 r=0;r<t.length;r++)if(!gr(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!gr(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}var $=class t{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let o=0;o<e.length;o++){let i=e[o];if(this.eq(i))return e;if(this.type.excludes(i.type))n||(n=e.slice(0,o));else{if(i.type.excludes(this.type))return e;!r&&i.type.rank>this.type.rank&&(n||(n=e.slice(0,o)),n.push(this),r=!0),n&&n.push(i)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&gr(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError(\"Invalid input for Mark.fromJSON\");let r=e.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);return r.create(n.attrs)}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return t.none;if(e instanceof t)return[e];let n=e.slice();return n.sort((r,o)=>r.type.rank-o.type.rank),n}};$.none=[];var it=class extends Error{},C=class t{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=fa(this.content,e+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new t(r,this.openStart,this.openEnd)}removeBetween(e,n){return new t(da(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+\"(\"+this.openStart+\",\"+this.openEnd+\")\"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return t.empty;let r=n.openStart||0,o=n.openEnd||0;if(typeof r!=\"number\"||typeof o!=\"number\")throw new RangeError(\"Invalid input for Slice.fromJSON\");return new t(b.fromJSON(e,n.content),r,o)}static maxOpen(e,n=!0){let r=0,o=0;for(let i=e.firstChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.lastChild)o++;return new t(e,r,o)}};C.empty=new C(b.empty,0,0);function da(t,e,n){let{index:r,offset:o}=t.findIndex(e),i=t.maybeChild(r),{index:s,offset:l}=t.findIndex(n);if(o==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(r!=s)throw new RangeError(\"Removing non-flat range\");return t.replaceChild(r,i.copy(da(i.content,e-o-1,n-o-1)))}function fa(t,e,n,r,o,i){let{index:s,offset:l}=t.findIndex(e),a=t.maybeChild(s);if(l==e||a.isText)return i&&r<=0&&o<=0&&!i.canReplace(s,s,n)?null:t.cut(0,e).append(n).append(t.cut(e));let c=fa(a.content,e-l-1,n,s==0?r-1:0,s==t.childCount-1?o-1:0,a);return c&&t.replaceChild(s,a.copy(c))}function Kh(t,e,n){if(n.openStart>t.depth)throw new it(\"Inserted content deeper than insertion position\");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new it(\"Inconsistent open depths\");return ha(t,e,n,0)}function ha(t,e,n,r){let o=t.index(r),i=t.node(r);if(o==e.index(r)&&r<t.depth-n.openStart){let s=ha(t,e,n,r+1);return i.copy(i.content.replaceChild(o,s))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let s=t.parent,l=s.content;return xt(s,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:s,end:l}=Uh(n,t);return xt(i,ma(t,s,l,e,r))}else return xt(i,yr(t,e,r))}function pa(t,e){if(!e.type.compatibleContent(t.type))throw new it(\"Cannot join \"+e.type.name+\" onto \"+t.type.name)}function oi(t,e,n){let r=t.node(n);return pa(r,e.node(n)),r}function St(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 vn(t,e,n,r){let o=(e||t).node(n),i=0,s=e?e.index(n):o.childCount;t&&(i=t.index(n),t.depth>n?i++:t.textOffset&&(St(t.nodeAfter,r),i++));for(let l=i;l<s;l++)St(o.child(l),r);e&&e.depth==n&&e.textOffset&&St(e.nodeBefore,r)}function xt(t,e){if(!t.type.validContent(e))throw new it(\"Invalid content for node \"+t.type.name);return t.copy(e)}function ma(t,e,n,r,o){let i=t.depth>o&&oi(t,e,o+1),s=r.depth>o&&oi(n,r,o+1),l=[];return vn(null,t,o,l),i&&s&&e.index(o)==n.index(o)?(pa(i,s),St(xt(i,ma(t,e,n,r,o+1)),l)):(i&&St(xt(i,yr(t,e,o+1)),l),vn(e,n,o,l),s&&St(xt(s,yr(n,r,o+1)),l)),vn(r,null,o,l),new b(l)}function yr(t,e,n){let r=[];if(vn(null,t,n,r),t.depth>n){let o=oi(t,e,n+1);St(xt(o,yr(t,e,n+1)),r)}return vn(e,null,n,r),new b(r)}function Uh(t,e){let n=e.depth-t.openStart,o=e.node(n).copy(t.content);for(let i=n-1;i>=0;i--)o=e.node(i).copy(b.from(o));return{start:o.resolveNoCache(t.openStart+n),end:o.resolveNoCache(o.content.size-t.openEnd-n)}}var br=class t{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError(\"There is no position before the top-level node\");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError(\"There is no position after the top-level node\");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],o=e.child(n);return r?e.child(n).cut(r):o}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],o=n==0?0:this.path[n*3-1]+1;for(let i=0;i<e;i++)o+=r.child(i).nodeSize;return o}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return $.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),o=e.maybeChild(n);if(!r){let l=r;r=o,o=l}let i=r.marks;for(var s=0;s<i.length;s++)i[s].type.spec.inclusive===!1&&(!o||!i[s].isInSet(o.marks))&&(i=i[s--].removeFromSet(i));return i}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,o=e.parent.maybeChild(e.index());for(var i=0;i<r.length;i++)r[i].type.spec.inclusive===!1&&(!o||!r[i].isInSet(o.marks))&&(r=r[i--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new Ct(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e=\"\";for(let n=1;n<=this.depth;n++)e+=(e?\"/\":\"\")+this.node(n).type.name+\"_\"+this.index(n-1);return e+\":\"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError(\"Position \"+n+\" out of range\");let r=[],o=0,i=n;for(let s=e;;){let{index:l,offset:a}=s.content.findIndex(i),c=i-a;if(r.push(s,l,o+a),!c||(s=s.child(l),s.isText))break;i=c-1,o+=a+1}return new t(n,r,i)}static resolveCached(e,n){let r=Yl.get(e);if(r)for(let i=0;i<r.elts.length;i++){let s=r.elts[i];if(s.pos==n)return s}else Yl.set(e,r=new ii);let o=r.elts[r.i]=t.resolve(e,n);return r.i=(r.i+1)%Jh,o}},ii=class{constructor(){this.elts=[],this.i=0}},Jh=12,Yl=new WeakMap,Ct=class{constructor(e,n,r){this.$from=e,this.$to=n,this.depth=r}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)}},qh=Object.create(null),Te=class t{constructor(e,n,r,o=$.none){this.type=e,this.attrs=n,this.marks=o,this.content=r||b.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,n,r,o=0){this.content.nodesBetween(e,n,r,o,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,\"\")}textBetween(e,n,r,o){return this.content.textBetween(e,n,r,o)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,r){return this.type==e&&gr(this.attrs,n||e.defaultAttrs||qh)&&$.sameSet(this.marks,r||$.none)}copy(e=null){return e==this.content?this:new t(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new t(this.type,this.attrs,this.content,e)}cut(e,n=this.content.size){return e==0&&n==this.content.size?this:this.copy(this.content.cut(e,n))}slice(e,n=this.content.size,r=!1){if(e==n)return C.empty;let o=this.resolve(e),i=this.resolve(n),s=r?0:o.sharedDepth(n),l=o.start(s),c=o.node(s).content.cut(o.pos-l,i.pos-l);return new C(c,o.depth-s,i.depth-s)}replace(e,n,r){return Kh(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:o}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(o==e||n.isText)return n;e-=o+1}}childAfter(e){let{index:n,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(n),index:n,offset:r};let o=this.content.child(n-1);return{node:o,index:n-1,offset:r-o.nodeSize}}resolve(e){return br.resolveCached(this,e)}resolveNoCache(e){return br.resolve(this,e)}rangeHasMark(e,n,r){let o=!1;return n>e&&this.nodesBetween(e,n,i=>(r.isInSet(i.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 e=this.type.name;return this.content.size&&(e+=\"(\"+this.content.toStringInner()+\")\"),ga(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error(\"Called contentMatchAt on a node with invalid content\");return n}canReplace(e,n,r=b.empty,o=0,i=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,o,i),l=s&&s.matchFragment(this.content,n);if(!l||!l.validEnd)return!1;for(let a=o;a<i;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,n,r,o){if(o&&!this.type.allowsMarks(o))return!1;let i=this.contentMatchAt(e).matchType(r),s=i&&i.matchFragment(this.content,n);return s?s.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),Ql(this.type.attrs,this.attrs,\"node\",this.type.name);let e=$.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];Ql(r.type.attrs,r.attrs,\"mark\",r.type.name),e=r.addToSet(e)}if(!$.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError(\"Invalid input for Node.fromJSON\");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError(\"Invalid mark data for Node.fromJSON\");r=n.marks.map(e.markFromJSON)}if(n.type==\"text\"){if(typeof n.text!=\"string\")throw new RangeError(\"Invalid text node in JSON\");return e.text(n.text,r)}let o=b.fromJSON(e,n.content);return e.nodeType(n.type).create(n.attrs,o,r)}};Te.prototype.text=void 0;var si=class t extends Te{constructor(e,n,r,o){if(super(e,n,null,o),!r)throw new RangeError(\"Empty text nodes are not allowed\");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):ga(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new t(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new t(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function ga(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+\"(\"+e+\")\";return e}function Ql(t,e,n,r){for(let o in e)if(!(o in t))throw new RangeError(`Unsupported attribute ${o} for ${n} of type ${r}`);for(let o in t)t[o].validate&&t[o].validate(e[o])}var Mt=class t{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new li(e,n);if(r.next==null)return t.empty;let o=ya(r);r.next&&r.err(\"Unexpected trailing text\");let i=tp(ep(o));return np(i,r),i}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let o=this;for(let i=n;o&&i<r;i++)o=o.matchType(e.child(i).type);return o}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let o=[this];function i(s,l){let a=s.matchFragment(e,r);if(a&&(!n||a.validEnd))return b.from(l.map(c=>c.createAndFill()));for(let c=0;c<s.next.length;c++){let{type:u,next:d}=s.next[c];if(!(u.isText||u.hasRequiredAttrs())&&o.indexOf(d)==-1){o.push(d);let f=i(d,l.concat(u));if(f)return f}}return null}return i(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let o=r.shift(),i=o.match;if(i.matchType(e)){let s=[];for(let l=o;l.type;l=l.via)s.push(l.type);return s.reverse()}for(let s=0;s<i.next.length;s++){let{type:l,next:a}=i.next[s];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in n)&&(!o.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:o}),n[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let o=0;o<r.next.length;o++)e.indexOf(r.next[o].next)==-1&&n(r.next[o].next)}return n(this),e.map((r,o)=>{let i=o+(r.validEnd?\"*\":\" \")+\" \";for(let s=0;s<r.next.length;s++)i+=(s?\", \":\"\")+r.next[s].type.name+\"->\"+e.indexOf(r.next[s].next);return i}).join(`\n`)}};Mt.empty=new Mt(!0);var li=class{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.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(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+\" (in content expression '\"+this.string+\"')\")}};function ya(t){let e=[];do e.push(Gh(t));while(t.eat(\"|\"));return e.length==1?e[0]:{type:\"choice\",exprs:e}}function Gh(t){let e=[];do e.push(Xh(t));while(t.next&&t.next!=\")\"&&t.next!=\"|\");return e.length==1?e[0]:{type:\"seq\",exprs:e}}function Xh(t){let e=Zh(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(\"{\"))e=Yh(t,e);else break;return e}function Zl(t){/\\D/.test(t.next)&&t.err(\"Expected number, got '\"+t.next+\"'\");let e=Number(t.next);return t.pos++,e}function Yh(t,e){let n=Zl(t),r=n;return t.eat(\",\")&&(t.next!=\"}\"?r=Zl(t):r=-1),t.eat(\"}\")||t.err(\"Unclosed braced range\"),{type:\"range\",min:n,max:r,expr:e}}function Qh(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let o=[];for(let i in n){let s=n[i];s.isInGroup(e)&&o.push(s)}return o.length==0&&t.err(\"No node type or group '\"+e+\"' found\"),o}function Zh(t){if(t.eat(\"(\")){let e=ya(t);return t.eat(\")\")||t.err(\"Missing closing paren\"),e}else if(/\\W/.test(t.next))t.err(\"Unexpected token '\"+t.next+\"'\");else{let e=Qh(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err(\"Mixing inline and block content\"),{type:\"name\",value:n}));return t.pos++,e.length==1?e[0]:{type:\"choice\",exprs:e}}}function ep(t){let e=[[]];return o(i(t,0),n()),e;function n(){return e.push([])-1}function r(s,l,a){let c={term:a,to:l};return e[s].push(c),c}function o(s,l){s.forEach(a=>a.to=l)}function i(s,l){if(s.type==\"choice\")return s.exprs.reduce((a,c)=>a.concat(i(c,l)),[]);if(s.type==\"seq\")for(let a=0;;a++){let c=i(s.exprs[a],l);if(a==s.exprs.length-1)return c;o(c,l=n())}else if(s.type==\"star\"){let a=n();return r(l,a),o(i(s.expr,a),a),[r(a)]}else if(s.type==\"plus\"){let a=n();return o(i(s.expr,l),a),o(i(s.expr,a),a),[r(a)]}else{if(s.type==\"opt\")return[r(l)].concat(i(s.expr,l));if(s.type==\"range\"){let a=l;for(let c=0;c<s.min;c++){let u=n();o(i(s.expr,a),u),a=u}if(s.max==-1)o(i(s.expr,a),a);else for(let c=s.min;c<s.max;c++){let u=n();r(a,u),o(i(s.expr,a),u),a=u}return[r(a)]}else{if(s.type==\"name\")return[r(l,void 0,s.value)];throw new Error(\"Unknown expr type\")}}}}function ba(t,e){return e-t}function ea(t,e){let n=[];return r(e),n.sort(ba);function r(o){let i=t[o];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(o);for(let s=0;s<i.length;s++){let{term:l,to:a}=i[s];!l&&n.indexOf(a)==-1&&r(a)}}}function tp(t){let e=Object.create(null);return n(ea(t,0));function n(r){let o=[];r.forEach(s=>{t[s].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let u=0;u<o.length;u++)o[u][0]==l&&(c=o[u][1]);ea(t,a).forEach(u=>{c||o.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let i=e[r.join(\",\")]=new Mt(r.indexOf(t.length-1)>-1);for(let s=0;s<o.length;s++){let l=o[s][1].sort(ba);i.next.push({type:o[s][0],next:e[l.join(\",\")]||n(l)})}return i}}function np(t,e){for(let n=0,r=[t];n<r.length;n++){let o=r[n],i=!o.validEnd,s=[];for(let l=0;l<o.next.length;l++){let{type:a,next:c}=o.next[l];s.push(a.name),i&&!(a.isText||a.hasRequiredAttrs())&&(i=!1),r.indexOf(c)==-1&&r.push(c)}i&&e.err(\"Only non-generatable nodes (\"+s.join(\", \")+\") in a required position (see https://prosemirror.net/docs/guide/#generatable)\")}}function ka(t){let e=Object.create(null);for(let n in t){let r=t[n];if(!r.hasDefault)return null;e[n]=r.default}return e}function wa(t,e){let n=Object.create(null);for(let r in t){let o=t[r],i=e&&e[r];if(i===void 0)if(o.hasDefault)i=o.default;else throw new RangeError(\"No value supplied for attribute \"+r);else o.validate&&o.validate(i);n[r]=i}return n}function Sa(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new ai(t,r,e[r]);return n}var kr=class t{constructor(e,n,r){this.name=e,this.schema=n,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(\" \"):[],this.attrs=Sa(e,r.attrs),this.defaultAttrs=ka(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e==\"text\"),this.isText=e==\"text\"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Mt.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?\"pre\":\"normal\")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:wa(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error(\"NodeType.create can't construct text nodes\");return new Te(this,this.computeAttrs(e),b.from(n),$.setFrom(r))}createChecked(e=null,n,r){return n=b.from(n),this.checkContent(n),new Te(this,this.computeAttrs(e),n,$.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=b.from(n),n.size){let s=this.contentMatch.fillBefore(n);if(!s)return null;n=s.append(n)}let o=this.contentMatch.matchFragment(n),i=o&&o.fillBefore(b.empty,!0);return i?new Te(this,e,n.append(i),$.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;n<e.length;n++)if(!this.allowsMarkType(e[n].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let n;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?n&&n.push(e[r]):n||(n=e.slice(0,r));return n?n.length?n:$.none:e}static compile(e,n){let r=Object.create(null);e.forEach((i,s)=>r[i]=new t(i,n,s));let o=n.spec.topNode||\"doc\";if(!r[o])throw new RangeError(\"Schema is missing its top node type ('\"+o+\"')\");if(!r.text)throw new RangeError(\"Every schema needs a 'text' type\");for(let i in r.text.attrs)throw new RangeError(\"The text node type should not have attributes\");return r}};function rp(t,e,n){let r=n.split(\"|\");return o=>{let i=o===null?\"null\":typeof o;if(r.indexOf(i)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${i}`)}}var ai=class{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,\"default\"),this.default=r.default,this.validate=typeof r.validate==\"string\"?rp(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}},An=class t{constructor(e,n,r,o){this.name=e,this.rank=n,this.schema=r,this.spec=o,this.attrs=Sa(e,o.attrs),this.excluded=null;let i=ka(this.attrs);this.instance=i?new $(this,i):null}create(e=null){return!e&&this.instance?this.instance:new $(this,wa(this.attrs,e))}static compile(e,n){let r=Object.create(null),o=0;return e.forEach((i,s)=>r[i]=new t(i,o++,n,s)),r}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}excludes(e){return this.excluded.indexOf(e)>-1}},vt=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let o in e)n[o]=e[o];n.nodes=ni.from(e.nodes),n.marks=ni.from(e.marks||{}),this.nodes=kr.compile(this.spec.nodes,this),this.marks=An.compile(this.spec.marks,this);let r=Object.create(null);for(let o in this.nodes){if(o in this.marks)throw new RangeError(o+\" can not be both a node and a mark\");let i=this.nodes[o],s=i.spec.content||\"\",l=i.spec.marks;if(i.contentMatch=r[s]||(r[s]=Mt.parse(s,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError(\"Multiple linebreak nodes defined\");if(!i.isInline||!i.isLeaf)throw new RangeError(\"Linebreak replacement nodes must be inline leaf nodes\");this.linebreakReplacement=i}i.markSet=l==\"_\"?null:l?ta(this,l.split(\" \")):l==\"\"||!i.inlineContent?[]:null}for(let o in this.marks){let i=this.marks[o],s=i.spec.excludes;i.excluded=s==null?[i]:s==\"\"?[]:ta(this,s.split(\" \"))}this.nodeFromJSON=o=>Te.fromJSON(this,o),this.markFromJSON=o=>$.fromJSON(this,o),this.topNodeType=this.nodes[this.spec.topNode||\"doc\"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,o){if(typeof e==\"string\")e=this.nodeType(e);else if(e instanceof kr){if(e.schema!=this)throw new RangeError(\"Node type from different schema used (\"+e.name+\")\")}else throw new RangeError(\"Invalid node type: \"+e);return e.createChecked(n,r,o)}text(e,n){let r=this.nodes.text;return new si(r,r.defaultAttrs,e,$.setFrom(n))}mark(e,n){return typeof e==\"string\"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError(\"Unknown node type: \"+e);return n}};function ta(t,e){let n=[];for(let r=0;r<e.length;r++){let o=e[r],i=t.marks[o],s=i;if(i)n.push(i);else for(let l in t.marks){let a=t.marks[l];(o==\"_\"||a.spec.group&&a.spec.group.split(\" \").indexOf(o)>-1)&&n.push(s=a)}if(!s)throw new SyntaxError(\"Unknown mark type: '\"+e[r]+\"'\")}return n}function op(t){return t.tag!=null}function ip(t){return t.style!=null}var je=class t{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(o=>{if(op(o))this.tags.push(o);else if(ip(o)){let i=/[^=]*/.exec(o.style)[0];r.indexOf(i)<0&&r.push(i),this.styles.push(o)}}),this.normalizeLists=!this.tags.some(o=>{if(!/^(ul|ol)\\b/.test(o.tag)||!o.node)return!1;let i=e.nodes[o.node];return i.contentMatch.matchType(i)})}parse(e,n={}){let r=new wr(this,n,!1);return r.addAll(e,$.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new wr(this,n,!0);return r.addAll(e,$.none,n.from,n.to),C.maxOpen(r.finish())}matchTag(e,n,r){for(let o=r?this.tags.indexOf(r)+1:0;o<this.tags.length;o++){let i=this.tags[o];if(ap(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||n.matchesContext(i.context))){if(i.getAttrs){let s=i.getAttrs(e);if(s===!1)continue;i.attrs=s||void 0}return i}}}matchStyle(e,n,r,o){for(let i=o?this.styles.indexOf(o)+1:0;i<this.styles.length;i++){let s=this.styles[i],l=s.style;if(!(l.indexOf(e)!=0||s.context&&!r.matchesContext(s.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=n))){if(s.getAttrs){let a=s.getAttrs(n);if(a===!1)continue;s.attrs=a||void 0}return s}}}static schemaRules(e){let n=[];function r(o){let i=o.priority==null?50:o.priority,s=0;for(;s<n.length;s++){let l=n[s];if((l.priority==null?50:l.priority)<i)break}n.splice(s,0,o)}for(let o in e.marks){let i=e.marks[o].spec.parseDOM;i&&i.forEach(s=>{r(s=ra(s)),s.mark||s.ignore||s.clearMark||(s.mark=o)})}for(let o in e.nodes){let i=e.nodes[o].spec.parseDOM;i&&i.forEach(s=>{r(s=ra(s)),s.node||s.ignore||s.mark||(s.node=o)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new t(e,t.schemaRules(e)))}},xa={address:!0,article:!0,aside:!0,blockquote:!0,body:!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},sp={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Ca={ol:!0,ul:!0},Tn=1,ci=2,En=4;function na(t,e,n){return e!=null?(e?Tn:0)|(e===\"full\"?ci:0):t&&t.whitespace==\"pre\"?Tn|ci:n&~En}var Jt=class{constructor(e,n,r,o,i,s){this.type=e,this.attrs=n,this.marks=r,this.solid=o,this.options=s,this.content=[],this.activeMarks=$.none,this.match=i||(s&En?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(b.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,o;return(o=r.findWrapping(e.type))?(this.match=r,o):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Tn)){let r=this.content[this.content.length-1],o;if(r&&r.isText&&(o=/[ \\t\\r\\n\\u000c]+$/.exec(r.text))){let i=r;r.text.length==o[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-o[0].length))}}let n=b.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(b.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!xa.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},wr=class{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let o=n.topNode,i,s=na(null,n.preserveWhitespace,0)|(r?En:0);o?i=new Jt(o.type,o.attrs,$.none,!0,n.topMatch||o.type.contentMatch,s):r?i=new Jt(null,null,$.none,!0,null,s):i=new Jt(e.schema.topNodeType,null,$.none,!0,null,s),this.nodes=[i],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,o=this.top,i=o.options&ci?\"full\":this.localPreserveWS||(o.options&Tn)>0,{schema:s}=this.parser;if(i===\"full\"||o.inlineContext(e)||/[^ \\t\\r\\n\\u000c]/.test(r)){if(i)if(i===\"full\")r=r.replace(/\\r\\n?/g,`\n`);else if(s.linebreakReplacement&&/[\\r\\n]/.test(r)&&this.top.findWrapping(s.linebreakReplacement.create())){let l=r.split(/\\r?\\n|\\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(s.linebreakReplacement.create(),n,!0),l[a]&&this.insertNode(s.text(l[a]),n,!/\\S/.test(l[a]));r=\"\"}else r=r.replace(/\\r?\\n|\\r/g,\" \");else if(r=r.replace(/[ \\t\\r\\n\\u000c]+/g,\" \"),/^[ \\t\\r\\n\\u000c]/.test(r)&&this.open==this.nodes.length-1){let l=o.content[o.content.length-1],a=e.previousSibling;(!l||a&&a.nodeName==\"BR\"||l.isText&&/[ \\t\\r\\n\\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(s.text(r),n,!/\\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let o=this.localPreserveWS,i=this.top;(e.tagName==\"PRE\"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let s=e.nodeName.toLowerCase(),l;Ca.hasOwnProperty(s)&&this.parser.normalizeLists&&lp(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:sp.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,n);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,u=this.needsBlock;if(xa.hasOwnProperty(s))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),c=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let d=a&&a.skip?n:this.readStyles(e,n);d&&this.addAll(e,d),c&&this.sync(i),this.needsBlock=u}else{let c=this.readStyles(e,n);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=o}leafFallback(e,n){e.nodeName==\"BR\"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`\n`),n)}ignoreFallback(e,n){e.nodeName==\"BR\"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text(\"-\"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let o=0;o<this.parser.matchedStyles.length;o++){let i=this.parser.matchedStyles[o],s=r.getPropertyValue(i);if(s)for(let l=void 0;;){let a=this.parser.matchStyle(i,s,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?n=n.filter(c=>!a.clearMark(c)):n=n.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return n}addElementByRule(e,n,r,o){let i,s;if(n.node)if(s=this.parser.schema.nodes[n.node],s.isLeaf)this.insertNode(s.create(n.attrs),r,e.nodeName==\"BR\")||this.leafFallback(e,r);else{let a=this.enter(s,n.attrs||null,r,n.preserveWhitespace);a&&(i=!0,r=a)}else{let a=this.parser.schema.marks[n.mark];r=r.concat(a.create(n.attrs))}let l=this.top;if(s&&s.isLeaf)this.findInside(e);else if(o)this.addElement(e,r,o);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof n.contentElement==\"string\"?a=e.querySelector(n.contentElement):typeof n.contentElement==\"function\"?a=n.contentElement(e):n.contentElement&&(a=n.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}i&&this.sync(l)&&this.open--}addAll(e,n,r,o){let i=r||0;for(let s=r?e.childNodes[r]:e.firstChild,l=o==null?null:e.childNodes[o];s!=l;s=s.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(s,n);this.findAtPoint(e,i)}findPlace(e,n,r){let o,i;for(let s=this.open,l=0;s>=0;s--){let a=this.nodes[s],c=a.findWrapping(e);if(c&&(!o||o.length>c.length+l)&&(o=c,i=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!o)return null;this.sync(i);for(let s=0;s<o.length;s++)n=this.enterInner(o[s],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(n=this.enterInner(i,null,n))}let o=this.findPlace(e,n,r);if(o){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let s=$.none;for(let l of o.concat(e.marks))(i.type?i.type.allowsMarkType(l.type):oa(l.type,e.type))&&(s=l.addToSet(s));return i.content.push(e.mark(s)),!0}return!1}enter(e,n,r,o){let i=this.findPlace(e.create(n),r,!1);return i&&(i=this.enterInner(e,n,r,!0,o)),i}enterInner(e,n,r,o=!1,i){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(e);let l=na(e,i,s.options);s.options&En&&s.content.length==0&&(l|=En);let a=$.none;return r=r.filter(c=>(s.type?s.type.allowsMarkType(c.type):oa(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new Jt(e,n,a,o,null,l)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));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(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=Tn)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let o=r.length-1;o>=0;o--)e+=r[o].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let o=0;o<this.find.length;o++)this.find[o].pos==null&&e.nodeType==1&&e.contains(this.find[o].node)&&n.compareDocumentPosition(this.find[o].node)&(r?2:4)&&(this.find[o].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf(\"|\")>-1)return e.split(/\\s*\\|\\s*/).some(this.matchesContext,this);let n=e.split(\"/\"),r=this.options.context,o=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(o?0:1),s=(l,a)=>{for(;l>=0;l--){let c=n[l];if(c==\"\"){if(l==n.length-1||l==0)continue;for(;a>=i;a--)if(s(l-1,a))return!0;return!1}else{let u=a>0||a==0&&o?this.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;a--}}return!0};return s(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}};function lp(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Ca.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r==\"li\"?n=e:r&&(n=null)}}function ap(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function ra(t){let e={};for(let n in t)e[n]=t[n];return e}function oa(t,e){let n=e.schema.nodes;for(let r in n){let o=n[r];if(!o.allowsMarkType(t))continue;let i=[],s=l=>{i.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:u}=l.edge(a);if(c==e||i.indexOf(u)<0&&s(u))return!0}};if(s(o.contentMatch))return!0}}var We=class t{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=pr(n).createDocumentFragment());let o=r,i=[];return e.forEach(s=>{if(i.length||s.marks.length){let l=0,a=0;for(;l<i.length&&a<s.marks.length;){let c=s.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(i[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<i.length;)o=i.pop()[1];for(;a<s.marks.length;){let c=s.marks[a++],u=this.serializeMark(c,s.isInline,n);u&&(i.push([c,o]),o.appendChild(u.dom),o=u.contentDOM||u.dom)}}o.appendChild(this.serializeNodeInner(s,n))}),r}serializeNodeInner(e,n){if(e.isText)return pr(n).createTextNode(e.text);let{dom:r,contentDOM:o}=mr(pr(n),this.nodes[e.type.name](e),null,e.attrs);if(o){if(e.isLeaf)throw new RangeError(\"Content hole not allowed in a leaf node spec\");this.serializeFragment(e.content,n,o)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let o=e.marks.length-1;o>=0;o--){let i=this.serializeMark(e.marks[o],e.isInline,n);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,n,r={}){let o=this.marks[e.type.name];return o&&mr(pr(r),o(e,n),null,e.attrs)}static renderSpec(e,n,r=null,o){return typeof n==\"string\"?{dom:e.createTextNode(n)}:mr(e,n,r,o)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new t(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=ia(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return ia(e.marks)}};function ia(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function pr(t){return t.document||window.document}var sa=new WeakMap;function cp(t){let e=sa.get(t);return e===void 0&&sa.set(t,e=up(t)),e}function up(t){let e=null;function n(r){if(r&&typeof r==\"object\")if(Array.isArray(r))if(typeof r[0]==\"string\")e||(e=[]),e.push(r);else for(let o=0;o<r.length;o++)n(r[o]);else for(let o in r)n(r[o])}return n(t),e}function mr(t,e,n,r){if(e.nodeType==1)return{dom:e};if(e.dom&&e.dom.nodeType==1)return e;let o=e[0],i;if(typeof o!=\"string\")throw new RangeError(\"Invalid array passed to renderSpec\");if(r&&(i=cp(r))&&i.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=o.indexOf(\" \");s>0&&(n=o.slice(0,s),o=o.slice(s+1));let l,a=n?t.createElementNS(n,o):t.createElement(o),c=e[1],u=1;if(c&&typeof c==\"object\"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let d in c)if(c[d]!=null){let f=d.indexOf(\" \");f>0?a.setAttributeNS(d.slice(0,f),d.slice(f+1),c[d]):d==\"style\"&&a.style?a.style.cssText=c[d]:a.setAttribute(d,c[d])}}for(let d=u;d<e.length;d++){let f=e[d];if(f===0){if(d<e.length-1||d>u)throw new RangeError(\"Content hole must be the only child of its parent node\");return{dom:a,contentDOM:a}}else if(typeof f==\"string\")a.appendChild(t.createTextNode(f));else{let{dom:h,contentDOM:p}=mr(t,f,n,r);if(a.appendChild(h),p){if(l)throw new RangeError(\"Multiple content holes\");l=p}}}return{dom:a,contentDOM:l}}var Ta=65535,Na=Math.pow(2,16);function dp(t,e){return t+e*Na}function Ma(t){return t&Ta}function fp(t){return(t-(t&Ta))/Na}var Oa=1,Ra=2,Sr=4,Da=8,Rn=class{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&Da)>0}get deletedBefore(){return(this.delInfo&(Oa|Sr))>0}get deletedAfter(){return(this.delInfo&(Ra|Sr))>0}get deletedAcross(){return(this.delInfo&Sr)>0}},Ve=class t{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&t.empty)return t.empty}recover(e){let n=0,r=Ma(e);if(!this.inverted)for(let o=0;o<r;o++)n+=this.ranges[o*3+2]-this.ranges[o*3+1];return this.ranges[r*3]+n+fp(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let o=0,i=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?o:0);if(a>e)break;let c=this.ranges[l+i],u=this.ranges[l+s],d=a+c;if(e<=d){let f=c?e==a?-1:e==d?1:n:n,h=a+o+(f<0?0:u);if(r)return h;let p=e==(n<0?a:d)?null:dp(l/3,e-a),m=0;return c&&(m|=e==a?Ra:e==d?Oa:Sr,(n<0?e!=a:e!=d)&&(m|=Da)),new Rn(h,m,p)}o+=u-c}return r?e+o:new Rn(e+o,0,null)}touches(e,n){let r=0,o=Ma(n),i=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+i],u=a+c;if(e<=u&&l==o*3)return!0;r+=this.ranges[l+s]-c}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let o=0,i=0;o<this.ranges.length;o+=3){let s=this.ranges[o],l=s-(this.inverted?i:0),a=s+(this.inverted?0:i),c=this.ranges[o+n],u=this.ranges[o+r];e(l,l+c,a,a+u),i+=u-c}}invert(){return new t(this.ranges,!this.inverted)}toString(){return(this.inverted?\"-\":\"\")+JSON.stringify(this.ranges)}static offset(e){return e==0?t.empty:new t(e<0?[0,-e,0]:[0,0,e])}};Ve.empty=new Ve([]);var Dn=class t{constructor(e,n,r=0,o=e?e.length:0){this.mirror=n,this.from=r,this.to=o,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new t(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=0,r=this._maps.length;n<e._maps.length;n++){let o=e.getMirror(n);this.appendMap(e._maps[n],o!=null&&o<n?r+o:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,r=this._maps.length+e._maps.length;n>=0;n--){let o=e.getMirror(n);this.appendMap(e._maps[n].invert(),o!=null&&o>n?r-o-1:void 0)}}invert(){let e=new t;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let o=0;for(let i=this.from;i<this.to;i++){let s=this._maps[i],l=s.mapResult(e,n);if(l.recover!=null){let a=this.getMirror(i);if(a!=null&&a>i&&a<this.to){i=a,e=this._maps[a].recover(l.recover);continue}}o|=l.delInfo,e=l.pos}return r?e:new Rn(e,o,null)}},ui=Object.create(null),te=class{getMap(){return Ve.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError(\"Invalid input for Step.fromJSON\");let r=ui[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in ui)throw new RangeError(\"Duplicate use of step JSON ID \"+e);return ui[e]=n,n.prototype.jsonID=e,n}},ne=class t{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new t(e,null)}static fail(e){return new t(null,e)}static fromReplace(e,n,r,o){try{return t.ok(e.replace(n,r,o))}catch(i){if(i instanceof it)return t.fail(i.message);throw i}}};function pi(t,e,n){let r=[];for(let o=0;o<t.childCount;o++){let i=t.child(o);i.content.size&&(i=i.copy(pi(i.content,e,i))),i.isInline&&(i=e(i,n,o)),r.push(i)}return b.fromArray(r)}var In=class t extends te{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),o=r.node(r.sharedDepth(this.to)),i=new C(pi(n.content,(s,l)=>!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),o),n.openStart,n.openEnd);return ne.fromReplace(e,this.from,this.to,i)}invert(){return new _e(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new t(n.pos,r.pos,this.mark)}merge(e){return e instanceof t&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new t(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:\"addMark\",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!=\"number\"||typeof n.to!=\"number\")throw new RangeError(\"Invalid input for AddMarkStep.fromJSON\");return new t(n.from,n.to,e.markFromJSON(n.mark))}};te.jsonID(\"addMark\",In);var _e=class t extends te{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new C(pi(n.content,o=>o.mark(this.mark.removeFromSet(o.marks)),e),n.openStart,n.openEnd);return ne.fromReplace(e,this.from,this.to,r)}invert(){return new In(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new t(n.pos,r.pos,this.mark)}merge(e){return e instanceof t&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new t(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:\"removeMark\",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!=\"number\"||typeof n.to!=\"number\")throw new RangeError(\"Invalid input for RemoveMarkStep.fromJSON\");return new t(n.from,n.to,e.markFromJSON(n.mark))}};te.jsonID(\"removeMark\",_e);var Pn=class t extends te{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ne.fail(\"No node at mark step's position\");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return ne.fromReplace(e,this.pos,this.pos+1,new C(b.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let o=0;o<n.marks.length;o++)if(!n.marks[o].isInSet(r))return new t(this.pos,n.marks[o]);return new t(this.pos,this.mark)}}return new qt(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new t(n.pos,this.mark)}toJSON(){return{stepType:\"addNodeMark\",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!=\"number\")throw new RangeError(\"Invalid input for AddNodeMarkStep.fromJSON\");return new t(n.pos,e.markFromJSON(n.mark))}};te.jsonID(\"addNodeMark\",Pn);var qt=class t extends te{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ne.fail(\"No node at mark step's position\");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return ne.fromReplace(e,this.pos,this.pos+1,new C(b.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new Pn(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new t(n.pos,this.mark)}toJSON(){return{stepType:\"removeNodeMark\",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!=\"number\")throw new RangeError(\"Invalid input for RemoveNodeMarkStep.fromJSON\");return new t(n.pos,e.markFromJSON(n.mark))}};te.jsonID(\"removeNodeMark\",qt);var G=class t extends te{constructor(e,n,r,o=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=o}apply(e){return this.structure&&fi(e,this.from,this.to)?ne.fail(\"Structure replace would overwrite content\"):ne.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Ve([this.from,this.to-this.from,this.slice.size])}invert(e){return new t(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.to,-1),r=this.from==this.to&&t.MAP_BIAS<0?n:e.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new t(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(e){if(!(e instanceof t)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?C.empty:new C(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new t(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?C.empty:new C(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new t(e.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:\"replace\",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!=\"number\"||typeof n.to!=\"number\")throw new RangeError(\"Invalid input for ReplaceStep.fromJSON\");return new t(n.from,n.to,C.fromJSON(e,n.slice),!!n.structure)}};G.MAP_BIAS=1;te.jsonID(\"replace\",G);var X=class t extends te{constructor(e,n,r,o,i,s,l=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=o,this.slice=i,this.insert=s,this.structure=l}apply(e){if(this.structure&&(fi(e,this.from,this.gapFrom)||fi(e,this.gapTo,this.to)))return ne.fail(\"Structure gap-replace would overwrite content\");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return ne.fail(\"Gap is not a flat range\");let r=this.slice.insertAt(this.insert,n.content);return r?ne.fromReplace(e,this.from,this.to,r):ne.fail(\"Content does not fit in gap\")}getMap(){return new Ve([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new t(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),o=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||o<n.pos||i>r.pos?null:new t(n.pos,r.pos,o,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:\"replaceAround\",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!=\"number\"||typeof n.to!=\"number\"||typeof n.gapFrom!=\"number\"||typeof n.gapTo!=\"number\"||typeof n.insert!=\"number\")throw new RangeError(\"Invalid input for ReplaceAroundStep.fromJSON\");return new t(n.from,n.to,n.gapFrom,n.gapTo,C.fromJSON(e,n.slice),n.insert,!!n.structure)}};te.jsonID(\"replaceAround\",X);function fi(t,e,n){let r=t.resolve(e),o=n-e,i=r.depth;for(;o>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,o--;if(o>0){let s=r.node(i).maybeChild(r.indexAfter(i));for(;o>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,o--}}return!1}function hp(t,e,n,r){let o=[],i=[],s,l;t.doc.nodesBetween(e,n,(a,c,u)=>{if(!a.isInline)return;let d=a.marks;if(!r.isInSet(d)&&u.type.allowsMarkType(r.type)){let f=Math.max(c,e),h=Math.min(c+a.nodeSize,n),p=r.addToSet(d);for(let m=0;m<d.length;m++)d[m].isInSet(p)||(s&&s.to==f&&s.mark.eq(d[m])?s.to=h:o.push(s=new _e(f,h,d[m])));l&&l.to==f?l.to=h:i.push(l=new In(f,h,r))}}),o.forEach(a=>t.step(a)),i.forEach(a=>t.step(a))}function pp(t,e,n,r){let o=[],i=0;t.doc.nodesBetween(e,n,(s,l)=>{if(!s.isInline)return;i++;let a=null;if(r instanceof An){let c=s.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(s.marks)&&(a=[r]):a=s.marks;if(a&&a.length){let c=Math.min(l+s.nodeSize,n);for(let u=0;u<a.length;u++){let d=a[u],f;for(let h=0;h<o.length;h++){let p=o[h];p.step==i-1&&d.eq(o[h].style)&&(f=p)}f?(f.to=c,f.step=i):o.push({style:d,from:Math.max(l,e),to:c,step:i})}}}),o.forEach(s=>t.step(new _e(s.from,s.to,s.style)))}function mi(t,e,n,r=n.contentMatch,o=!0){let i=t.doc.nodeAt(e),s=[],l=e+1;for(let a=0;a<i.childCount;a++){let c=i.child(a),u=l+c.nodeSize,d=r.matchType(c.type);if(!d)s.push(new G(l,u,C.empty));else{r=d;for(let f=0;f<c.marks.length;f++)n.allowsMarkType(c.marks[f].type)||t.step(new _e(l,u,c.marks[f]));if(o&&c.isText&&n.whitespace!=\"pre\"){let f,h=/\\r?\\n|\\r/g,p;for(;f=h.exec(c.text);)p||(p=new C(b.from(n.schema.text(\" \",n.allowedMarks(c.marks))),0,0)),s.push(new G(l+f.index,l+f.index+f[0].length,p))}}l=u}if(!r.validEnd){let a=r.fillBefore(b.empty,!0);t.replace(l,l,new C(a,0,0))}for(let a=s.length-1;a>=0;a--)t.step(s[a])}function mp(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Ke(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,o=0,i=0;;--r){let s=t.$from.node(r),l=t.$from.index(r)+o,a=t.$to.indexAfter(r)-i;if(r<t.depth&&s.canReplace(l,a,n))return r;if(r==0||s.type.spec.isolating||!mp(s,l,a))break;l&&(o=1),a<s.childCount&&(i=1)}return null}function gp(t,e,n){let{$from:r,$to:o,depth:i}=e,s=r.before(i+1),l=o.after(i+1),a=s,c=l,u=b.empty,d=0;for(let p=i,m=!1;p>n;p--)m||r.index(p)>0?(m=!0,u=b.from(r.node(p).copy(u)),d++):a--;let f=b.empty,h=0;for(let p=i,m=!1;p>n;p--)m||o.after(p+1)<o.end(p)?(m=!0,f=b.from(o.node(p).copy(f)),h++):c++;t.step(new X(a,c,s,l,new C(u.append(f),d,h),u.size-d,!0))}function Xt(t,e,n=null,r=t){let o=yp(t,e),i=o&&bp(r,e);return i?o.map(va).concat({type:e,attrs:n}).concat(i.map(va)):null}function va(t){return{type:t,attrs:null}}function yp(t,e){let{parent:n,startIndex:r,endIndex:o}=t,i=n.contentMatchAt(r).findWrapping(e);if(!i)return null;let s=i.length?i[0]:e;return n.canReplaceWith(r,o,s)?i:null}function bp(t,e){let{parent:n,startIndex:r,endIndex:o}=t,i=n.child(r),s=e.contentMatch.findWrapping(i.type);if(!s)return null;let a=(s.length?s[s.length-1]:e).contentMatch;for(let c=r;a&&c<o;c++)a=a.matchType(n.child(c).type);return!a||!a.validEnd?null:s}function kp(t,e,n){let r=b.empty;for(let s=n.length-1;s>=0;s--){if(r.size){let l=n[s].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError(\"Wrapper type given to Transform.wrap does not form valid content of its parent wrapper\")}r=b.from(n[s].type.create(n[s].attrs,r))}let o=e.start,i=e.end;t.step(new X(o,i,o,i,new C(r,0,0),n.length,!0))}function wp(t,e,n,r,o){if(!r.isTextblock)throw new RangeError(\"Type given to setBlockType should be a textblock\");let i=t.steps.length;t.doc.nodesBetween(e,n,(s,l)=>{let a=typeof o==\"function\"?o(s):o;if(s.isTextblock&&!s.hasMarkup(r,a)&&Sp(t.doc,t.mapping.slice(i).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let h=r.whitespace==\"pre\",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!p?c=!1:!h&&p&&(c=!0)}c===!1&&Pa(t,s,l,i),mi(t,t.mapping.slice(i).map(l,1),r,void 0,c===null);let u=t.mapping.slice(i),d=u.map(l,1),f=u.map(l+s.nodeSize,1);return t.step(new X(d,f,d+1,f-1,new C(b.from(r.create(a,null,s.marks)),0,0),1,!0)),c===!0&&Ia(t,s,l,i),!1}})}function Ia(t,e,n,r){e.forEach((o,i)=>{if(o.isText){let s,l=/\\r?\\n|\\r/g;for(;s=l.exec(o.text);){let a=t.mapping.slice(r).map(n+1+i+s.index);t.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Pa(t,e,n,r){e.forEach((o,i)=>{if(o.type==o.type.schema.linebreakReplacement){let s=t.mapping.slice(r).map(n+1+i);t.replaceWith(s,s+1,e.type.schema.text(`\n`))}})}function Sp(t,e,n){let r=t.resolve(e),o=r.index();return r.parent.canReplaceWith(o,o+1,n)}function xp(t,e,n,r,o){let i=t.doc.nodeAt(e);if(!i)throw new RangeError(\"No node at given position\");n||(n=i.type);let s=n.create(r,null,o||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 X(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new C(b.from(s),0,0),1,!0))}function Ce(t,e,n=1,r){let o=t.resolve(e),i=o.depth-n,s=r&&r[r.length-1]||o.parent;if(i<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!s.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(let c=o.depth-1,u=n-2;c>i;c--,u--){let d=o.node(c),f=o.index(c);if(d.type.spec.isolating)return!1;let h=d.content.cutByIndex(f,d.childCount),p=r&&r[u+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let m=r&&r[u]||d;if(!d.canReplace(f+1,d.childCount)||!m.type.validContent(h))return!1}let l=o.indexAfter(i),a=r&&r[0];return o.node(i).canReplaceWith(l,l,a?a.type:o.node(i+1).type)}function Cp(t,e,n=1,r){let o=t.doc.resolve(e),i=b.empty,s=b.empty;for(let l=o.depth,a=o.depth-n,c=n-1;l>a;l--,c--){i=b.from(o.node(l).copy(i));let u=r&&r[c];s=b.from(u?u.type.create(u.attrs,s):o.node(l).copy(s))}t.step(new G(e,e,new C(i.append(s),n,n),!0))}function Ne(t,e){let n=t.resolve(e),r=n.index();return La(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function Mp(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let o=0;o<e.childCount;o++){let i=e.child(o),s=i.type==r?t.type.schema.nodes.text:i.type;if(n=n.matchType(s),!n||!t.type.allowsMarks(i.marks))return!1}return n.validEnd}function La(t,e){return!!(t&&e&&!t.isLeaf&&Mp(t,e))}function Yt(t,e,n=-1){let r=t.resolve(e);for(let o=r.depth;;o--){let i,s,l=r.index(o);if(o==r.depth?(i=r.nodeBefore,s=r.nodeAfter):n>0?(i=r.node(o+1),l++,s=r.node(o).maybeChild(l)):(i=r.node(o).maybeChild(l-1),s=r.node(o+1)),i&&!i.isTextblock&&La(i,s)&&r.node(o).canReplace(l,l+1))return e;if(o==0)break;e=n<0?r.before(o):r.after(o)}}function vp(t,e,n){let r=null,{linebreakReplacement:o}=t.doc.type.schema,i=t.doc.resolve(e-n),s=i.node().type;if(o&&s.inlineContent){let u=s.whitespace==\"pre\",d=!!s.contentMatch.matchType(o);u&&!d?r=!1:!u&&d&&(r=!0)}let l=t.steps.length;if(r===!1){let u=t.doc.resolve(e+n);Pa(t,u.node(),u.before(),l)}s.inlineContent&&mi(t,e+n-1,s,i.node().contentMatchAt(i.index()),r==null);let a=t.mapping.slice(l),c=a.map(e-n);if(t.step(new G(c,a.map(e+n,-1),C.empty,!0)),r===!0){let u=t.doc.resolve(c);Ia(t,u.node(),u.before(),t.steps.length)}return t}function Ep(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let o=r.depth-1;o>=0;o--){let i=r.index(o);if(r.node(o).canReplaceWith(i,i,n))return r.before(o+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let o=r.depth-1;o>=0;o--){let i=r.indexAfter(o);if(r.node(o).canReplaceWith(i,i,n))return r.after(o+1);if(i<r.node(o).childCount)return null}return null}function Mr(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let o=n.content;for(let i=0;i<n.openStart;i++)o=o.firstChild.content;for(let i=1;i<=(n.openStart==0&&n.size?2:1);i++)for(let s=r.depth;s>=0;s--){let l=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1,a=r.index(s)+(l>0?1:0),c=r.node(s),u=!1;if(i==1)u=c.canReplace(a,a,o);else{let d=c.contentMatchAt(a).findWrapping(o.firstChild.type);u=d&&c.canReplaceWith(a,a,d[0])}if(u)return l==0?r.pos:l<0?r.before(s+1):r.after(s+1)}return null}function Ln(t,e,n=e,r=C.empty){if(e==n&&!r.size)return null;let o=t.resolve(e),i=t.resolve(n);return $a(o,i,r)?new G(e,n,r):new hi(o,i,r).fit()}function $a(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}var hi=class{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=b.empty;for(let o=0;o<=e.depth;o++){let i=e.node(o);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(o))})}for(let o=e.depth;o>0;o--)this.placed=b.from(e.node(o).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,o=this.close(e<0?this.$to:r.doc.resolve(e));if(!o)return null;let i=this.placed,s=r.depth,l=o.depth;for(;s&&l&&i.childCount==1;)i=i.firstChild.content,s--,l--;let a=new C(i,s,l);return e>-1?new X(r.pos,e,this.$to.pos,this.$to.end(),a,n):a.size||r.pos!=this.$to.pos?new G(r.pos,o.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,o=this.unplaced.openEnd;r<e;r++){let i=n.firstChild;if(n.childCount>1&&(o=0),i.type.spec.isolating&&o<=r){e=r;break}n=i.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let o,i=null;r?(i=Ea(this.unplaced.content,r-1).firstChild,o=i.content):o=this.unplaced.content;let s=o.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],u,d=null;if(n==1&&(s?c.matchType(s.type)||(d=c.fillBefore(b.from(s),!1)):i&&a.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:l,parent:i,inject:d};if(n==2&&s&&(u=c.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:l,parent:i,wrap:u};if(i&&c.matchType(i.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced;return Aa(e,-1)<=n?!1:(this.unplaced.size>1&&Aa(e,1)>r&&r++,this.unplaced=new C(e,n+1,r),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,o=Ea(e,n);if(o.childCount<=1&&n>0){let i=e.size-n<=n+o.size;this.unplaced=new C(Nn(e,n-1,1),n-1,i?n-1:r)}else this.unplaced=new C(Nn(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:o,wrap:i}){for(;this.depth>n;)this.closeFrontierNode();if(i)for(let m=0;m<i.length;m++)this.openFrontierNode(i[m]);let s=this.unplaced,l=r?r.content:s.content,a=s.openStart-e,c=0,u=[],{match:d,type:f}=this.frontier[n];if(o){for(let m=0;m<o.childCount;m++)u.push(o.child(m));d=d.matchFragment(o)}let h=l.size+e-(s.content.size-s.openEnd);for(;c<l.childCount;){let m=l.child(c),g=d.matchType(m.type);if(!g)break;c++,(c>1||a==0||m.content.size)&&(d=g,u.push(za(m.mark(f.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?h:-1)))}let p=c==l.childCount;p||(h=-1),this.placed=On(this.placed,n,b.from(u)),this.frontier[n].match=d,p&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=l;m<h;m++){let y=g.lastChild;this.frontier.push({type:y.type,match:y.contentMatchAt(y.childCount)}),g=y.content}this.unplaced=p?e==0?C.empty:new C(Nn(s.content,e-1,1),e-1,h<0?s.openEnd:e-1):new C(Nn(s.content,e,c),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!di(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:r}=this.$to,o=this.$to.after(r);for(;r>1&&o==this.$to.end(--r);)++o;return o}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:o}=this.frontier[n],i=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),s=di(e,n,o,r,i);if(s){for(let l=n-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=di(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:n,fit:s,move:i?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=On(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let o=e.node(r),i=o.type.contentMatch.fillBefore(o.content,!0,e.index(r));this.openFrontierNode(o.type,o.attrs,i)}return e}openFrontierNode(e,n=null,r){let o=this.frontier[this.depth];o.match=o.match.matchType(e),this.placed=On(this.placed,this.depth,b.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(b.empty,!0);n.childCount&&(this.placed=On(this.placed,this.frontier.length,n))}};function Nn(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Nn(t.firstChild.content,e-1,n)))}function On(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(On(t.lastChild.content,e-1,n)))}function Ea(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function za(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,za(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(b.empty,!0)))),t.copy(r)}function di(t,e,n,r,o){let i=t.node(e),s=o?t.indexAfter(e):t.index(e);if(s==i.childCount&&!n.compatibleContent(i.type))return null;let l=r.fillBefore(i.content,!0,s);return l&&!Ap(n,i.content,s)?l:null}function Ap(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function Tp(t){return t.spec.defining||t.spec.definingForContent}function Aa(t,e){for(let n=0;;n++){let r=e<0?t.firstChild:t.lastChild;if(!r||r.isAtom)return n;t=r.content}}function Np(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let o=t.doc.resolve(e),i=t.doc.resolve(n);if($a(o,i,r))return t.step(new G(e,n,r));let s=Fa(o,i);s[s.length-1]==0&&s.pop();let l=-(o.depth+1);s.unshift(l);for(let f=o.depth,h=o.pos-1;f>0;f--,h--){let p=o.node(f).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;s.indexOf(f)>-1?l=f:o.before(f)==h&&s.splice(1,0,-f)}let a=s.indexOf(l),c=[],u=r.openStart;for(let f=r.content,h=0;;h++){let p=f.firstChild;if(c.push(p),h==r.openStart)break;f=p.content}for(let f=u-1;f>=0;f--){let h=c[f],p=Tp(h.type);if(p&&!h.sameMarkup(o.node(Math.abs(l)-1)))u=f;else if(p||!h.type.isTextblock)break}for(let f=r.openStart;f>=0;f--){let h=(f+u+1)%(r.openStart+1),p=c[h];if(p)for(let m=0;m<s.length;m++){let g=s[(m+a)%s.length],y=!0;g<0&&(y=!1,g=-g);let S=o.node(g-1),k=o.index(g-1);if(S.canReplaceWith(k,k,p.type,p.marks))return t.replace(o.before(g),y?i.after(g):n,new C(Ba(r.content,0,r.openStart,h),h,r.openEnd))}}let d=t.steps.length;for(let f=s.length-1;f>=0&&(t.replace(e,n,r),!(t.steps.length>d));f--){let h=s[f];h<0||(e=o.before(h),n=i.after(h))}}function Ba(t,e,n,r,o){if(e<n){let i=t.firstChild;t=t.replaceChild(0,i.copy(Ba(i.content,e+1,n,r,i)))}if(e>r){let i=o.contentMatchAt(0),s=i.fillBefore(t).append(t);t=s.append(i.matchFragment(s).fillBefore(b.empty,!0))}return t}function Op(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let o=Ep(t.doc,e,r.type);o!=null&&(e=n=o)}t.replaceRange(e,n,new C(b.from(r),0,0))}function Rp(t,e,n){let r=t.doc.resolve(e),o=t.doc.resolve(n);if(r.parent.isTextblock&&o.parent.isTextblock&&r.start()!=o.start()&&r.parentOffset==0&&o.parentOffset==0){let s=r.sharedDepth(n),l=!1;for(let a=r.depth;a>s;a--)r.node(a).type.spec.isolating&&(l=!0);for(let a=o.depth;a>s;a--)o.node(a).type.spec.isolating&&(l=!0);if(!l){for(let a=r.depth;a>0&&e==r.start(a);a--)e=r.before(a);for(let a=o.depth;a>0&&n==o.start(a);a--)n=o.before(a);r=t.doc.resolve(e),o=t.doc.resolve(n)}}let i=Fa(r,o);for(let s=0;s<i.length;s++){let l=i[s],a=s==i.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return t.delete(r.start(l),o.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),o.indexAfter(l-1))))return t.delete(r.before(l),o.after(l))}for(let s=1;s<=r.depth&&s<=o.depth;s++)if(e-r.start(s)==r.depth-s&&n>r.end(s)&&o.end(s)-n!=o.depth-s&&r.start(s-1)==o.start(s-1)&&r.node(s-1).canReplace(r.index(s-1),o.index(s-1)))return t.delete(r.before(s),n);t.delete(e,n)}function Fa(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let o=r;o>=0;o--){let i=t.start(o);if(i<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;(i==e.start(o)||o==t.depth&&o==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&o&&e.start(o-1)==i-1)&&n.push(o)}return n}var xr=class t extends te{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return ne.fail(\"No node at attribute step's position\");let r=Object.create(null);for(let i in n.attrs)r[i]=n.attrs[i];r[this.attr]=this.value;let o=n.type.create(r,null,n.marks);return ne.fromReplace(e,this.pos,this.pos+1,new C(b.from(o),0,n.isLeaf?0:1))}getMap(){return Ve.empty}invert(e){return new t(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new t(n.pos,this.attr,this.value)}toJSON(){return{stepType:\"attr\",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!=\"number\"||typeof n.attr!=\"string\")throw new RangeError(\"Invalid input for AttrStep.fromJSON\");return new t(n.pos,n.attr,n.value)}};te.jsonID(\"attr\",xr);var Cr=class t extends te{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let o in e.attrs)n[o]=e.attrs[o];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return ne.ok(r)}getMap(){return Ve.empty}invert(e){return new t(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:\"docAttr\",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!=\"string\")throw new RangeError(\"Invalid input for DocAttrStep.fromJSON\");return new t(n.attr,n.value)}};te.jsonID(\"docAttr\",Cr);var Gt=class extends Error{};Gt=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Gt.prototype=Object.create(Error.prototype);Gt.prototype.constructor=Gt;Gt.prototype.name=\"TransformError\";var st=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Dn}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new Gt(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,n=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let o=this.mapping.maps[r];r&&(e=o.map(e,1),n=o.map(n,-1)),o.forEach((i,s,l,a)=>{e=Math.min(e,l),n=Math.max(n,a)})}return e==1e9?null:{from:e,to:n}}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=C.empty){let o=Ln(this.doc,e,n,r);return o&&this.step(o),this}replaceWith(e,n,r){return this.replace(e,n,new C(b.from(r),0,0))}delete(e,n){return this.replace(e,n,C.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return Np(this,e,n,r),this}replaceRangeWith(e,n,r){return Op(this,e,n,r),this}deleteRange(e,n){return Rp(this,e,n),this}lift(e,n){return gp(this,e,n),this}join(e,n=1){return vp(this,e,n),this}wrap(e,n){return kp(this,e,n),this}setBlockType(e,n=e,r,o=null){return wp(this,e,n,r,o),this}setNodeMarkup(e,n,r=null,o){return xp(this,e,n,r,o),this}setNodeAttribute(e,n,r){return this.step(new xr(e,n,r)),this}setDocAttribute(e,n){return this.step(new Cr(e,n)),this}addNodeMark(e,n){return this.step(new Pn(e,n)),this}removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError(\"No node at position \"+e);if(n instanceof $)n.isInSet(r.marks)&&this.step(new qt(e,n));else{let o=r.marks,i,s=[];for(;i=n.isInSet(o);)s.push(new qt(e,i)),o=i.removeFromSet(o);for(let l=s.length-1;l>=0;l--)this.step(s[l])}return this}split(e,n=1,r){return Cp(this,e,n,r),this}addMark(e,n,r){return hp(this,e,n,r),this}removeMark(e,n,r){return pp(this,e,n,r),this}clearIncompatible(e,n,r){return mi(this,e,n,r),this}};var gi=Object.create(null),E=class{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new Zt(e.min(n),e.max(n))]}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 e=this.ranges;for(let n=0;n<e.length;n++)if(e[n].$from.pos!=e[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,n=C.empty){let r=n.content.lastChild,o=null;for(let l=0;l<n.openEnd;l++)o=r,r=r.lastChild;let i=e.steps.length,s=this.ranges;for(let l=0;l<s.length;l++){let{$from:a,$to:c}=s[l],u=e.mapping.slice(i);e.replaceRange(u.map(a.pos),u.map(c.pos),l?C.empty:n),l==0&&Wa(e,i,(r?r.isInline:o&&o.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,o=this.ranges;for(let i=0;i<o.length;i++){let{$from:s,$to:l}=o[i],a=e.mapping.slice(r),c=a.map(s.pos),u=a.map(l.pos);i?e.deleteRange(c,u):(e.replaceRangeWith(c,u,n),Wa(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let o=e.parent.inlineContent?new M(e):Qt(e.node(0),e.parent,e.pos,e.index(),n,r);if(o)return o;for(let i=e.depth-1;i>=0;i--){let s=n<0?Qt(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):Qt(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,n,r);if(s)return s}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new pe(e.node(0))}static atStart(e){return Qt(e,e,0,0,1)||new pe(e)}static atEnd(e){return Qt(e,e,e.content.size,e.childCount,-1)||new pe(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError(\"Invalid input for Selection.fromJSON\");let r=gi[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in gi)throw new RangeError(\"Duplicate use of selection JSON ID \"+e);return gi[e]=n,n.prototype.jsonID=e,n}getBookmark(){return M.between(this.$anchor,this.$head).getBookmark()}};E.prototype.visible=!0;var Zt=class{constructor(e,n){this.$from=e,this.$to=n}},Ha=!1;function ja(t){!Ha&&!t.parent.inlineContent&&(Ha=!0,console.warn(\"TextSelection endpoint not pointing into a node with inline content (\"+t.parent.type.name+\")\"))}var M=class t extends E{constructor(e,n=e){ja(e),ja(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return E.near(r);let o=e.resolve(n.map(this.anchor));return new t(o.parent.inlineContent?o:r,r)}replace(e,n=C.empty){if(super.replace(e,n),n==C.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof t&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Er(this.anchor,this.head)}toJSON(){return{type:\"text\",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!=\"number\"||typeof n.head!=\"number\")throw new RangeError(\"Invalid input for TextSelection.fromJSON\");return new t(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let o=e.resolve(n);return new this(o,r==n?o:e.resolve(r))}static between(e,n,r){let o=e.pos-n.pos;if((!r||o)&&(r=o>=0?1:-1),!n.parent.inlineContent){let i=E.findFrom(n,r,!0)||E.findFrom(n,-r,!0);if(i)n=i.$head;else return E.near(n,r)}return e.parent.inlineContent||(o==0?e=n:(e=(E.findFrom(e,-r,!0)||E.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=o<0&&(e=n))),new t(e,n)}};E.jsonID(\"text\",M);var Er=class t{constructor(e,n){this.anchor=e,this.head=n}map(e){return new t(e.map(this.anchor),e.map(this.head))}resolve(e){return M.between(e.resolve(this.anchor),e.resolve(this.head))}},A=class t extends E{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:o}=n.mapResult(this.anchor),i=e.resolve(o);return r?E.near(i):new t(i)}content(){return new C(b.from(this.node),0,0)}eq(e){return e instanceof t&&e.anchor==this.anchor}toJSON(){return{type:\"node\",anchor:this.anchor}}getBookmark(){return new bi(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!=\"number\")throw new RangeError(\"Invalid input for NodeSelection.fromJSON\");return new t(e.resolve(n.anchor))}static create(e,n){return new t(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}};A.prototype.visible=!1;E.jsonID(\"node\",A);var bi=class t{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new Er(r,r):new t(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&A.isSelectable(r)?new A(n):E.near(n)}},pe=class t extends E{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=C.empty){if(n==C.empty){e.delete(0,e.doc.content.size);let r=E.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:\"all\"}}static fromJSON(e){return new t(e)}map(e){return new t(e)}eq(e){return e instanceof t}getBookmark(){return Dp}};E.jsonID(\"all\",pe);var Dp={map(){return this},resolve(t){return new pe(t)}};function Qt(t,e,n,r,o,i=!1){if(e.inlineContent)return M.create(t,n);for(let s=r-(o>0?0:1);o>0?s<e.childCount:s>=0;s+=o){let l=e.child(s);if(l.isAtom){if(!i&&A.isSelectable(l))return A.create(t,n-(o<0?l.nodeSize:0))}else{let a=Qt(t,l,n+o,o<0?l.childCount:0,o,i);if(a)return a}n+=l.nodeSize*o}return null}function Wa(t,e,n){let r=t.steps.length-1;if(r<e)return;let o=t.steps[r];if(!(o instanceof G||o instanceof X))return;let i=t.mapping.maps[r],s;i.forEach((l,a,c,u)=>{s==null&&(s=u)}),t.setSelection(E.near(t.doc.resolve(s),n))}var Va=1,vr=2,_a=4,ki=class extends st{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.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(e){if(e.$from.doc!=this.doc)throw new RangeError(\"Selection passed to setSelection must point at the current document\");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|Va)&~vr,this.storedMarks=null,this}get selectionSet(){return(this.updated&Va)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=vr,this}ensureMarks(e){return $.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&vr)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~vr,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||$.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let o=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(o.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let i=this.storedMarks;if(!i){let s=this.doc.resolve(n);i=r==n?s.marks():s.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,o.text(e,i)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(E.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e==\"string\"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e==\"string\"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=_a,this}get scrolledIntoView(){return(this.updated&_a)>0}};function Ka(t,e){return!e||!t?t:t.bind(e)}var Et=class{constructor(e,n,r){this.name=e,this.init=Ka(n.init,r),this.apply=Ka(n.apply,r)}},Ip=[new Et(\"doc\",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Et(\"selection\",{init(t,e){return t.selection||E.atStart(e.doc)},apply(t){return t.selection}}),new Et(\"storedMarks\",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Et(\"scrollToSelection\",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})],$n=class{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Ip.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError(\"Adding different instances of a keyed plugin (\"+r.key+\")\");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Et(r.key,r.spec.state,r))})}},At=class t{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=n){let o=this.config.plugins[r];if(o.spec.filterTransaction&&!o.spec.filterTransaction.call(o,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),o=null;for(;;){let i=!1;for(let s=0;s<this.config.plugins.length;s++){let l=this.config.plugins[s];if(l.spec.appendTransaction){let a=o?o[s].n:0,c=o?o[s].state:this,u=a<n.length&&l.spec.appendTransaction.call(l,a?n.slice(a):n,c,r);if(u&&r.filterTransaction(u,s)){if(u.setMeta(\"appendedTransaction\",e),!o){o=[];for(let d=0;d<this.config.plugins.length;d++)o.push(d<s?{state:r,n:n.length}:{state:this,n:0})}n.push(u),r=r.applyInner(u),i=!0}o&&(o[s]={state:r,n:n.length})}}if(!i)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError(\"Applying a mismatched transaction\");let n=new t(this.config),r=this.config.fields;for(let o=0;o<r.length;o++){let i=r[o];n[i.name]=i.apply(e,this[i.name],this,n)}return n}get tr(){return new ki(this)}static create(e){let n=new $n(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new t(n);for(let o=0;o<n.fields.length;o++)r[n.fields[o].name]=n.fields[o].init(e,r);return r}reconfigure(e){let n=new $n(this.schema,e.plugins),r=n.fields,o=new t(n);for(let i=0;i<r.length;i++){let s=r[i].name;o[s]=this.hasOwnProperty(s)?this[s]:r[i].init(e,o)}return o}toJSON(e){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e==\"object\")for(let r in e){if(r==\"doc\"||r==\"selection\")throw new RangeError(\"The JSON fields `doc` and `selection` are reserved\");let o=e[r],i=o.spec.state;i&&i.toJSON&&(n[r]=i.toJSON.call(o,this[o.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError(\"Invalid input for EditorState.fromJSON\");if(!e.schema)throw new RangeError(\"Required config field 'schema' missing\");let o=new $n(e.schema,e.plugins),i=new t(o);return o.fields.forEach(s=>{if(s.name==\"doc\")i.doc=Te.fromJSON(e.schema,n.doc);else if(s.name==\"selection\")i.selection=E.fromJSON(i.doc,n.selection);else if(s.name==\"storedMarks\")n.storedMarks&&(i.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==s.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){i[s.name]=c.fromJSON.call(a,e,n[l],i);return}}i[s.name]=s.init(e,i)}}),i}};function Ua(t,e,n){for(let r in t){let o=t[r];o instanceof Function?o=o.bind(e):r==\"handleDOMEvents\"&&(o=Ua(o,e,{})),n[r]=o}return n}var R=class{constructor(e){this.spec=e,this.props={},e.props&&Ua(e.props,this,this.props),this.key=e.key?e.key.key:Ja(\"plugin\")}getState(e){return e[this.key]}},yi=Object.create(null);function Ja(t){return t in yi?t+\"$\"+ ++yi[t]:(yi[t]=0,t+\"$\")}var P=class{constructor(e=\"key\"){this.key=Ja(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}};var Ga=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function Xa(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock(\"backward\",t):n.parentOffset>0)?null:n}var Si=(t,e,n)=>{let r=Xa(t,n);if(!r)return!1;let o=Ci(r);if(!o){let s=r.blockRange(),l=s&&Ke(s);return l==null?!1:(e&&e(t.tr.lift(s,l).scrollIntoView()),!0)}let i=o.nodeBefore;if(rc(t,o,e,-1))return!0;if(r.parent.content.size==0&&(en(i,\"end\")||A.isSelectable(i)))for(let s=r.depth;;s--){let l=Ln(t.doc,r.before(s),r.after(s),C.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=t.tr.step(l);a.setSelection(en(i,\"end\")?E.findFrom(a.doc.resolve(a.mapping.map(o.pos,-1)),-1):A.create(a.doc,o.pos-i.nodeSize)),e(a.scrollIntoView())}return!0}if(s==1||r.node(s-1).childCount>1)break}return i.isAtom&&o.depth==r.depth-1?(e&&e(t.tr.delete(o.pos-i.nodeSize,o.pos).scrollIntoView()),!0):!1},Ar=(t,e,n)=>{let r=Xa(t,n);if(!r)return!1;let o=Ci(r);return o?Ya(t,o,e):!1},Tr=(t,e,n)=>{let r=Qa(t,n);if(!r)return!1;let o=Ei(r);return o?Ya(t,o,e):!1};function Ya(t,e,n){let r=e.nodeBefore,o=r,i=e.pos-1;for(;!o.isTextblock;i--){if(o.type.spec.isolating)return!1;let u=o.lastChild;if(!u)return!1;o=u}let s=e.nodeAfter,l=s,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let u=l.firstChild;if(!u)return!1;l=u}let c=Ln(t.doc,i,a,C.empty);if(!c||c.from!=i||c instanceof G&&c.slice.size>=a-i)return!1;if(n){let u=t.tr.step(c);u.setSelection(M.create(u.doc,i)),n(u.scrollIntoView())}return!0}function en(t,e,n=!1){for(let r=t;r;r=e==\"start\"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}var xi=(t,e,n)=>{let{$head:r,empty:o}=t.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock(\"backward\",t):r.parentOffset>0)return!1;i=Ci(r)}let s=i&&i.nodeBefore;return!s||!A.isSelectable(s)?!1:(e&&e(t.tr.setSelection(A.create(t.doc,i.pos-s.nodeSize)).scrollIntoView()),!0)};function Ci(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 Qa(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock(\"forward\",t):n.parentOffset<n.parent.content.size)?null:n}var Mi=(t,e,n)=>{let r=Qa(t,n);if(!r)return!1;let o=Ei(r);if(!o)return!1;let i=o.nodeAfter;if(rc(t,o,e,1))return!0;if(r.parent.content.size==0&&(en(i,\"start\")||A.isSelectable(i))){let s=Ln(t.doc,r.before(),r.after(),C.empty);if(s&&s.slice.size<s.to-s.from){if(e){let l=t.tr.step(s);l.setSelection(en(i,\"start\")?E.findFrom(l.doc.resolve(l.mapping.map(o.pos)),1):A.create(l.doc,l.mapping.map(o.pos))),e(l.scrollIntoView())}return!0}}return i.isAtom&&o.depth==r.depth-1?(e&&e(t.tr.delete(o.pos,o.pos+i.nodeSize).scrollIntoView()),!0):!1},vi=(t,e,n)=>{let{$head:r,empty:o}=t.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock(\"forward\",t):r.parentOffset<r.parent.content.size)return!1;i=Ei(r)}let s=i&&i.nodeAfter;return!s||!A.isSelectable(s)?!1:(e&&e(t.tr.setSelection(A.create(t.doc,i.pos)).scrollIntoView()),!0)};function Ei(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}var Za=(t,e)=>{let n=t.selection,r=n instanceof A,o;if(r){if(n.node.isTextblock||!Ne(t.doc,n.from))return!1;o=n.from}else if(o=Yt(t.doc,n.from,-1),o==null)return!1;if(e){let i=t.tr.join(o);r&&i.setSelection(A.create(i.doc,o-t.doc.resolve(o).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},ec=(t,e)=>{let n=t.selection,r;if(n instanceof A){if(n.node.isTextblock||!Ne(t.doc,n.to))return!1;r=n.to}else if(r=Yt(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},tc=(t,e)=>{let{$from:n,$to:r}=t.selection,o=n.blockRange(r),i=o&&Ke(o);return i==null?!1:(e&&e(t.tr.lift(o,i).scrollIntoView()),!0)},Ai=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`\n`).scrollIntoView()),!0)};function Ti(t){for(let e=0;e<t.edgeCount;e++){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}var Ni=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let o=n.node(-1),i=n.indexAfter(-1),s=Ti(o.contentMatchAt(i));if(!s||!o.canReplaceWith(i,i,s))return!1;if(e){let l=n.after(),a=t.tr.replaceWith(l,l,s.createAndFill());a.setSelection(E.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Oi=(t,e)=>{let n=t.selection,{$from:r,$to:o}=n;if(n instanceof pe||r.parent.inlineContent||o.parent.inlineContent)return!1;let i=Ti(o.parent.contentMatchAt(o.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let s=(!r.parentOffset&&o.index()<o.parent.childCount?r:o).pos,l=t.tr.insert(s,i.createAndFill());l.setSelection(M.create(l.doc,s+1)),e(l.scrollIntoView())}return!0},Ri=(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 i=n.before();if(Ce(t.doc,i))return e&&e(t.tr.split(i).scrollIntoView()),!0}let r=n.blockRange(),o=r&&Ke(r);return o==null?!1:(e&&e(t.tr.lift(r,o).scrollIntoView()),!0)};function Pp(t){return(e,n)=>{if(e.selection instanceof A&&e.selection.node.isBlock){let{$from:h}=e.selection;return!h.parentOffset||!Ce(e.doc,h.pos)?!1:(n&&n(e.tr.split(h.pos).scrollIntoView()),!0)}if(!e.selection.$from.depth)return!1;let r=e.tr;!e.selection.empty&&(e.selection instanceof M||e.selection instanceof pe)&&r.deleteSelection();let{$from:o}=r.selection,i=r.steps.length,s=[],l,a,c=!1,u=!1;for(let h=o.depth;;h--)if(o.node(h).isBlock){c=o.end(h)==o.pos+(o.depth-h),u=o.start(h)==o.pos-(o.depth-h),a=Ti(o.node(h-1).contentMatchAt(o.indexAfter(h-1)));let m=t&&t(o.parent,c,o);s.unshift(m||(c&&a?{type:a}:null)),l=h;break}else{if(h==1)return!1;s.unshift(null)}let d=o.pos,f=Ce(r.doc,d,s.length,s);if(f||(s[0]=a?{type:a}:null,f=Ce(r.doc,d,s.length,s)),!f)return!1;if(r.split(d,s.length,s),!c&&u&&o.node(l).type!=a){let h=r.mapping.slice(i),p=h.map(o.before(l)),m=r.doc.resolve(p);a&&o.node(l-1).canReplaceWith(m.index(),m.index()+1,a)&&r.setNodeMarkup(h.map(o.before(l)),a)}return n&&n(r.scrollIntoView()),!0}}var Lp=Pp();var nc=(t,e)=>{let{$from:n,to:r}=t.selection,o,i=n.sharedDepth(r);return i==0?!1:(o=n.before(i),e&&e(t.tr.setSelection(A.create(t.doc,o))),!0)},$p=(t,e)=>(e&&e(t.tr.setSelection(new pe(t.doc))),!0);function zp(t,e,n){let r=e.nodeBefore,o=e.nodeAfter,i=e.index();return!r||!o||!r.type.compatibleContent(o.type)?!1:!r.content.size&&e.parent.canReplace(i-1,i)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(o.isTextblock||Ne(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function rc(t,e,n,r){let o=e.nodeBefore,i=e.nodeAfter,s,l,a=o.type.spec.isolating||i.type.spec.isolating;if(!a&&zp(t,e,n))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(s=(l=o.contentMatchAt(o.childCount)).findWrapping(i.type))&&l.matchType(s[0]||i.type).validEnd){if(n){let h=e.pos+i.nodeSize,p=b.empty;for(let y=s.length-1;y>=0;y--)p=b.from(s[y].create(null,p));p=b.from(o.copy(p));let m=t.tr.step(new X(e.pos-1,h,e.pos,h,new C(p,1,0),s.length,!0)),g=m.doc.resolve(h+2*s.length);g.nodeAfter&&g.nodeAfter.type==o.type&&Ne(m.doc,g.pos)&&m.join(g.pos),n(m.scrollIntoView())}return!0}let u=i.type.spec.isolating||r>0&&a?null:E.findFrom(e,1),d=u&&u.$from.blockRange(u.$to),f=d&&Ke(d);if(f!=null&&f>=e.depth)return n&&n(t.tr.lift(d,f).scrollIntoView()),!0;if(c&&en(i,\"start\",!0)&&en(o,\"end\")){let h=o,p=[];for(;p.push(h),!h.isTextblock;)h=h.lastChild;let m=i,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(h.canReplace(h.childCount,h.childCount,m.content)){if(n){let y=b.empty;for(let k=p.length-1;k>=0;k--)y=b.from(p[k].copy(y));let S=t.tr.step(new X(e.pos-p.length,e.pos+i.nodeSize,e.pos+g,e.pos+i.nodeSize-g,new C(y,p.length,0),0,!0));n(S.scrollIntoView())}return!0}}return!1}function oc(t){return function(e,n){let r=e.selection,o=t<0?r.$from:r.$to,i=o.depth;for(;o.node(i).isInline;){if(!i)return!1;i--}return o.node(i).isTextblock?(n&&n(e.tr.setSelection(M.create(e.doc,t<0?o.start(i):o.end(i)))),!0):!1}}var Di=oc(-1),Ii=oc(1);function ic(t,e=null){return function(n,r){let{$from:o,$to:i}=n.selection,s=o.blockRange(i),l=s&&Xt(s,t,e);return l?(r&&r(n.tr.wrap(s,l).scrollIntoView()),!0):!1}}function Pi(t,e=null){return function(n,r){let o=!1;for(let i=0;i<n.selection.ranges.length&&!o;i++){let{$from:{pos:s},$to:{pos:l}}=n.selection.ranges[i];n.doc.nodesBetween(s,l,(a,c)=>{if(o)return!1;if(!(!a.isTextblock||a.hasMarkup(t,e)))if(a.type==t)o=!0;else{let u=n.doc.resolve(c),d=u.index();o=u.parent.canReplaceWith(d,d+1,t)}})}if(!o)return!1;if(r){let i=n.tr;for(let s=0;s<n.selection.ranges.length;s++){let{$from:{pos:l},$to:{pos:a}}=n.selection.ranges[s];i.setBlockType(l,a,t,e)}r(i.scrollIntoView())}return!0}}function Li(...t){return function(e,n,r){for(let o=0;o<t.length;o++)if(t[o](e,n,r))return!0;return!1}}var wi=Li(Ga,Si,xi),qa=Li(Ga,Mi,vi),lt={Enter:Li(Ai,Oi,Ri,Lp),\"Mod-Enter\":Ni,Backspace:wi,\"Mod-Backspace\":wi,\"Shift-Backspace\":wi,Delete:qa,\"Mod-Delete\":qa,\"Mod-a\":$p},Bp={\"Ctrl-h\":lt.Backspace,\"Alt-Backspace\":lt[\"Mod-Backspace\"],\"Ctrl-d\":lt.Delete,\"Ctrl-Alt-Backspace\":lt[\"Mod-Delete\"],\"Alt-Delete\":lt[\"Mod-Delete\"],\"Alt-d\":lt[\"Mod-Delete\"],\"Ctrl-a\":Di,\"Ctrl-e\":Ii};for(let t in lt)Bp[t]=lt[t];var oS=typeof navigator<\"u\"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<\"u\"&&os.platform?os.platform()==\"darwin\":!1;function sc(t,e=null){return function(n,r){let{$from:o,$to:i}=n.selection,s=o.blockRange(i);if(!s)return!1;let l=r?n.tr:null;return Fp(l,s,t,e)?(r&&r(l.scrollIntoView()),!0):!1}}function Fp(t,e,n,r=null){let o=!1,i=e,s=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=s.resolve(e.start-2);i=new Ct(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new Ct(e.$from,s.resolve(e.$to.end(e.depth)),e.depth)),o=!0}let l=Xt(i,n,r,e);return l?(t&&Hp(t,e,l,o,n),!0):!1}function Hp(t,e,n,r,o){let i=b.empty;for(let u=n.length-1;u>=0;u--)i=b.from(n[u].type.create(n[u].attrs,i));t.step(new X(e.start-(r?2:0),e.end,e.start,e.end,new C(i,0,0),n.length,!0));let s=0;for(let u=0;u<n.length;u++)n[u].type==o&&(s=u+1);let l=n.length-s,a=e.start+n.length-(r?2:0),c=e.parent;for(let u=e.startIndex,d=e.endIndex,f=!0;u<d;u++,f=!1)!f&&Ce(t.doc,a,l)&&(t.split(a,l),a+=2*l),a+=c.child(u).nodeSize;return t}function lc(t){return function(e,n){let{$from:r,$to:o}=e.selection,i=r.blockRange(o,s=>s.childCount>0&&s.firstChild.type==t);return i?n?r.node(i.depth-1).type==t?jp(e,n,t,i):Wp(e,n,i):!0:!1}}function jp(t,e,n,r){let o=t.tr,i=r.end,s=r.$to.end(r.depth);i<s&&(o.step(new X(i-1,s,i,s,new C(b.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new Ct(o.doc.resolve(r.$from.pos),o.doc.resolve(s),r.depth));let l=Ke(r);if(l==null)return!1;o.lift(r,l);let a=o.doc.resolve(o.mapping.map(i,-1)-1);return Ne(o.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&o.join(a.pos),e(o.scrollIntoView()),!0}function Wp(t,e,n){let r=t.tr,o=n.parent;for(let h=n.end,p=n.endIndex-1,m=n.startIndex;p>m;p--)h-=o.child(p).nodeSize,r.delete(h-1,h+1);let i=r.doc.resolve(n.start),s=i.nodeAfter;if(r.mapping.map(n.end)!=n.start+i.nodeAfter.nodeSize)return!1;let l=n.startIndex==0,a=n.endIndex==o.childCount,c=i.node(-1),u=i.index(-1);if(!c.canReplace(u+(l?0:1),u+1,s.content.append(a?b.empty:b.from(o))))return!1;let d=i.pos,f=d+s.nodeSize;return r.step(new X(d-(l?1:0),f+(a?1:0),d+1,f-1,new C((l?b.empty:b.from(o.copy(b.empty))).append(a?b.empty:b.from(o.copy(b.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function ac(t){return function(e,n){let{$from:r,$to:o}=e.selection,i=r.blockRange(o,c=>c.childCount>0&&c.firstChild.type==t);if(!i)return!1;let s=i.startIndex;if(s==0)return!1;let l=i.parent,a=l.child(s-1);if(a.type!=t)return!1;if(n){let c=a.lastChild&&a.lastChild.type==l.type,u=b.from(c?t.create():null),d=new C(b.from(t.create(null,b.from(l.type.create(null,u)))),c?3:1,0),f=i.start,h=i.end;n(e.tr.step(new X(f-(c?3:1),h,f,h,d,1,!0)).scrollIntoView())}return!0}}var re=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},on=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e},Hi=null,Je=function(t,e,n){let r=Hi||(Hi=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},Vp=function(){Hi=null},Lt=function(t,e,n,r){return n&&(cc(t,e,n,r,-1)||cc(t,e,n,r,1))},_p=/^(img|br|input|textarea|hr)$/i;function cc(t,e,n,r,o){for(var i;;){if(t==n&&e==r)return!0;if(e==(o<0?0:ae(t))){let s=t.parentNode;if(!s||!N(s)||Kn(t)||_p.test(t.nodeName)||t.contentEditable==\"false\")return!1;e=re(t)+(o<0?0:1),t=s}else if(N(t)){let s=t.childNodes[e+(o<0?-1:0)];if(N(s)&&s.contentEditable==\"false\")if(!((i=s.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)e+=o;else return!1;else t=s,e=o<0?ae(t):0}else return!1}}function ae(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function N(t){return t.nodeType==1}function Z(t){return t.nodeType==3}function $t(t,e){return e?t.contains(N(e)?e:e.parentNode):!1}function Kp(t,e){for(;;){if(Z(t)&&e)return t;if(N(t)&&e>0){if(t.contentEditable==\"false\")return null;t=t.childNodes[e-1],e=ae(t)}else if(t.parentNode&&!Kn(t))e=re(t),t=t.parentNode;else return null}}function Up(t,e){for(;;){if(Z(t)&&e<t.nodeValue.length)return t;if(N(t)&&e<t.childNodes.length){if(t.contentEditable==\"false\")return null;t=t.childNodes[e],e=0}else if(t.parentNode&&!Kn(t))e=re(t)+1,t=t.parentNode;else return null}}function Jp(t,e,n){for(let r=e==0,o=e==ae(t);r||o;){if(t==n)return!0;let i=re(t);if(t=t.parentNode,!t)return!1;r=r&&i==0,o=o&&i==ae(t)}}function Kn(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)}var Fr=function(t){return t.focusNode&&Lt(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Tt(t,e){let n=document.createEvent(\"Event\");return n.initEvent(\"keydown\",!0,!0),n.keyCode=t,n.key=n.code=e,n}function qp(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Gp(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(ae(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(ae(r.startContainer),r.startOffset)}}}var Ie=typeof navigator<\"u\"?navigator:null,uc=typeof document<\"u\"?document:null,ft=Ie&&Ie.userAgent||\"\",ji=/Edge\\/(\\d+)/.exec(ft),Fc=/MSIE \\d/.exec(ft),Wi=/Trident\\/(?:[7-9]|\\d{2,})\\..*rv:(\\d+)/.exec(ft),be=!!(Fc||Wi||ji),ut=Fc?document.documentMode:Wi?+Wi[1]:ji?+ji[1]:0,we=!be&&/gecko\\/(\\d+)/i.test(ft);we&&+(/Firefox\\/(\\d+)/.exec(ft)||[0,0])[1];var Vi=!be&&/Chrome\\/(\\d+)/.exec(ft),oe=!!Vi,Hc=Vi?+Vi[1]:0,ce=!be&&!!Ie&&/Apple Computer/.test(Ie.vendor),sn=ce&&(/Mobile\\/\\w+/.test(ft)||!!Ie&&Ie.maxTouchPoints>2),Me=sn||(Ie?/Mac/.test(Ie.platform):!1),jc=Ie?/Win/.test(Ie.platform):!1,qe=/Android \\d/.test(ft),Hr=!!uc&&\"webkitFontSmoothing\"in uc.documentElement.style,Xp=Hr?+(/\\bAppleWebKit\\/(\\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Yp(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 Ue(t,e){return typeof t==\"number\"?t:t[e]}function Qp(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function dc(t,e,n){if(!_i(e)&&e.left==0)return;let r=t.someProp(\"scrollThreshold\")||0,o=t.someProp(\"scrollMargin\")||5,i=t.dom.ownerDocument;for(let s=n||t.dom;s;){if(!N(s)){s=on(s);continue}let l=s==i.body,a=l?Yp(i):Qp(s),c=0,u=0;if(e.top<a.top+Ue(r,\"top\")?u=-(a.top-e.top+Ue(o,\"top\")):e.bottom>a.bottom-Ue(r,\"bottom\")&&(u=e.bottom-e.top>a.bottom-a.top?e.top+Ue(o,\"top\")-a.top:e.bottom-a.bottom+Ue(o,\"bottom\")),e.left<a.left+Ue(r,\"left\")?c=-(a.left-e.left+Ue(o,\"left\")):e.right>a.right-Ue(r,\"right\")&&(c=e.right-a.right+Ue(o,\"right\")),c||u)if(l)i.defaultView.scrollBy(c,u);else{let f=s.scrollLeft,h=s.scrollTop;u&&(s.scrollTop+=u),c&&(s.scrollLeft+=c);let p=s.scrollLeft-f,m=s.scrollTop-h;e={left:e.left-p,top:e.top-m,right:e.right-p,bottom:e.bottom-m}}let d=l?\"fixed\":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(d))break;s=d==\"absolute\"?s.offsetParent:on(s)}}function Zp(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,o;for(let i=(e.left+e.right)/2,s=n+1;s<Math.min(innerHeight,e.bottom);s+=5){let l=t.root.elementFromPoint(i,s);if(!l||l==t.dom||!t.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=n-20){r=l,o=a.top;break}}return{refDOM:r,refTop:o,stack:Wc(t.dom)}}function Wc(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=on(r));return e}function em({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;Vc(n,r==0?0:r-e)}function Vc(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:o,left:i}=t[n];r.scrollTop!=o+e&&(r.scrollTop=o+e),r.scrollLeft!=i&&(r.scrollLeft=i)}}var tn=null;function tm(t){if(t.setActive)return t.setActive();if(tn)return t.focus(tn);let e=Wc(t);t.focus(tn==null?{get preventScroll(){return tn={preventScroll:!0},!0}}:void 0),tn||(tn=!1,Vc(e,0))}function _c(t,e){let n,r=2e8,o,i=0,s=e.top,l=e.top,a,c;for(let u=t.firstChild,d=0;u;u=u.nextSibling,d++){let f;if(N(u))f=u.getClientRects();else if(Z(u))f=Je(u).getClientRects();else continue;for(let h=0;h<f.length;h++){let p=f[h];if(p.top<=s&&p.bottom>=l){s=Math.max(p.bottom,s),l=Math.min(p.top,l);let m=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(m<r){n=u,r=m,o=m&&Z(n)?{left:p.right<e.left?p.right:p.left,top:e.top}:e,N(u)&&m&&(i=d+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=u,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!n&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(i=d+1)}}return!n&&a&&(n=a,o=c,r=0),n&&Z(n)?nm(n,o):!n||r?{node:t,offset:i}:_c(n,o)}function nm(t,e){let n=t.nodeValue.length,r=document.createRange(),o;for(let i=0;i<n;i++){r.setEnd(t,i+1),r.setStart(t,i);let s=at(r,1);if(s.top!=s.bottom&&ls(e,s)){o={node:t,offset:i+(e.left>=(s.left+s.right)/2?1:0)};break}}return r.detach(),o||{node:t,offset:0}}function ls(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function rm(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function om(t,e,n){let{node:r,offset:o}=_c(e,n),i=-1;if(N(r)&&!r.firstChild){let s=r.getBoundingClientRect();i=s.left!=s.right&&n.left>(s.left+s.right)/2?1:-1}return t.docView.posFromDOM(r,o,i)}function im(t,e,n,r){let o=-1;for(let i=e,s=!1;i!=t.dom;){let l=t.docView.nearestDesc(i,!0),a;if(!l)return null;if(N(l.dom)&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!s&&a.left>r.left||a.top>r.top?o=l.posBefore:(!s&&a.right<r.left||a.bottom<r.top)&&(o=l.posAfter),s=!0),!l.contentDOM&&o<0&&!l.node.isText))return(l.node.isBlock?r.top<(a.top+a.bottom)/2:r.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;i=l.dom.parentNode}return o>-1?o:t.docView.posFromDOM(e,n,-1)}function Kc(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let o=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),i=o;;){let s=t.childNodes[i];if(N(s)){let l=s.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(ls(e,c))return Kc(s,e,c)}}if((i=(i+1)%r)==o)break}return t}function sm(t,e){let n=t.dom.ownerDocument,r,o=0,i=Gp(n,e.left,e.top);i&&({node:r,offset:o}=i);let s=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),l;if(!s||!t.dom.contains(s)){let c=t.dom.getBoundingClientRect();if(!ls(e,c)||(s=Kc(t.dom,e,c),!s))return null}if(ce)for(let c=s;r&&c;c=on(c))c.draggable&&(r=void 0);if(s=rm(s,e),r){if(we&&N(r)&&(o=Math.min(o,r.childNodes.length),o<r.childNodes.length)){let u=r.childNodes[o],d;u.nodeName==\"IMG\"&&(d=u.getBoundingClientRect()).right<=e.left&&d.bottom>e.top&&o++}let c;Hr&&o&&N(r)&&N(c=r.childNodes[o-1])&&c.contentEditable==\"false\"&&c.getBoundingClientRect().top>=e.top&&o--,r==t.dom&&o==r.childNodes.length-1&&N(r.lastChild)&&e.top>r.lastChild.getBoundingClientRect().bottom?l=t.state.doc.content.size:(o==0||!N(r)||r.childNodes[o-1].nodeName!=\"BR\")&&(l=im(t,r,o,e))}l==null&&(l=om(t,s,e));let a=t.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function _i(t){return t.top<t.bottom||t.left<t.right}function at(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(_i(r))return r}return Array.prototype.find.call(n,_i)||t.getBoundingClientRect()}var lm=/[\\u0590-\\u05f4\\u0600-\\u06ff\\u0700-\\u08ac]/;function Uc(t,e,n){let{node:r,offset:o,atom:i}=t.docView.domFromPos(e,n<0?-1:1),s=Hr||we;if(Z(r))if(s&&(lm.test(r.nodeValue)||(n<0?!o:o==r.nodeValue.length))){let a=at(Je(r,o,o),n);if(we&&o&&/\\s/.test(r.nodeValue[o-1])&&o<r.nodeValue.length){let c=at(Je(r,o-1,o-1),-1);if(c.top==a.top){let u=at(Je(r,o,o+1),-1);if(u.top!=a.top)return zn(u,u.left<c.left)}}return a}else{let a=o,c=o,u=n<0?1:-1;return n<0&&!o?(c++,u=-1):n>=0&&o==r.nodeValue.length?(a--,u=1):n<0?a--:c++,zn(at(Je(r,a,c),u),u<0)}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&o&&(n<0||o==ae(r))){let a=r.childNodes[o-1];if(N(a))return $i(a.getBoundingClientRect(),!1)}if(i==null&&o<ae(r)){let a=r.childNodes[o];if(N(a))return $i(a.getBoundingClientRect(),!0)}return $i(r.getBoundingClientRect(),n>=0)}if(i==null&&o&&(n<0||o==ae(r))){let a=r.childNodes[o-1],c=Z(a)?Je(a,ae(a)-(s?0:1)):N(a)&&(a.nodeName!=\"BR\"||!a.nextSibling)?a:null;if(c)return zn(at(c,1),!1)}if(i==null&&o<ae(r)){let a=r.childNodes[o];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?Z(a)?Je(a,0,s?0:1):N(a)?a:null:null;if(c)return zn(at(c,-1),!0)}return zn(at(Z(r)?Je(r):r,-n),n>=0)}function zn(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function $i(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function Jc(t,e,n){let r=t.state,o=t.root.activeElement;r!=e&&t.updateState(e),o!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),o!=t.dom&&o&&o.focus()}}function am(t,e,n){let r=e.selection,o=n==\"up\"?r.$from:r.$to;return Jc(t,e,()=>{let{node:i}=t.docView.domFromPos(o.pos,n==\"up\"?-1:1);for(;;){let l=t.docView.nearestDesc(i,!0);if(!l)break;if(l.node.isBlock){i=l.contentDOM||l.dom;break}i=l.dom.parentNode}let s=Uc(t,o.pos,1);for(let l=i.firstChild;l;l=l.nextSibling){let a;if(N(l))a=l.getClientRects();else if(Z(l))a=Je(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let u=a[c];if(u.bottom>u.top+1&&(n==\"up\"?s.top-u.top>(u.bottom-s.top)*2:u.bottom-s.bottom>(s.bottom-u.top)*2))return!1}}return!0})}var cm=/[\\u0590-\\u08ac]/;function um(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let o=r.parentOffset,i=!o,s=o==r.parent.content.size,l=t.domSelection();return l?!cm.test(r.parent.textContent)||!l.modify?n==\"left\"||n==\"backward\"?i:s:Jc(t,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:u,anchorOffset:d}=t.domSelectionRange(),f=l.caretBidiLevel;l.modify(\"move\",n,\"character\");let h=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:p,focusOffset:m}=t.domSelectionRange(),g=p&&!$t(h,p)||a==p&&c==m;try{l.collapse(u,d),a&&(a!=u||c!=d)&&l.extend&&l.extend(a,c)}catch{}return f!=null&&(l.caretBidiLevel=f),g}):r.pos==r.start()||r.pos==r.end()}var fc=null,hc=null,pc=!1;function dm(t,e,n){return fc==e&&hc==n?pc:(fc=e,hc=n,pc=n==\"up\"||n==\"down\"?am(t,e,n):um(t,e,n))}var ve=0,mc=1,Nt=2,Oe=3,zt=class{constructor(e,n,r,o){this.parent=e,this.children=n,this.dom=r,this.contentDOM=o,this.dirty=ve,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(e){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let n=0,r=this.posAtStart;;n++){let o=this.children[n];if(o==e)return r;r+=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(e,n,r){if(this.contentDOM&&$t(this.contentDOM,e))if(r<0){let i,s;if(e==this.contentDOM)i=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&!((s=i.pmViewDesc)&&s.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(s)+s.size:this.posAtStart}else{let i,s;if(e==this.contentDOM)i=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&!((s=i.pmViewDesc)&&s.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(s):this.posAtEnd}let o;if(e==this.dom&&this.contentDOM)o=n>re(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))o=!!(e.compareDocumentPosition(this.contentDOM)&4);else if(this.dom.firstChild){if(n==0)for(let i=e;;i=i.parentNode){if(i==this.dom){o=!1;break}if(i.previousSibling)break}if(o==null&&n==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){o=!0;break}if(i.nextSibling)break}}return o??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,o=e;o;o=o.parentNode){let i=this.getDesc(o),s;if(i&&(!n||i.node))if(r&&(s=i.nodeDOM)&&!(N(s)?$t(s,e):s==e))r=!1;else return i}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let o=e;o;o=o.parentNode){let i=this.getDesc(o);if(i)return i.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let o=this.children[n],i=r+o.size;if(r==e&&i!=r){for(;!o.border&&o.children.length;)for(let s=0;s<o.children.length;s++){let l=o.children[s];if(l.size){o=l;break}}return o}if(e<i)return o.descAt(e-r-o.border);r=i}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,o=0;for(let i=0;r<this.children.length;r++){let s=this.children[r],l=i+s.size;if(l>e){o=e-i;break}i=l}if(o)return this.children[r].domFromPos(o-this.children[r].border,n);for(;r>0;r--){let i=this.children[r-1];if(i.size||!(i instanceof Rr||i instanceof Nr&&i.side>=0))break}if(n<=0){let i,s=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,s=!1);return i&&n&&s&&!i.border&&!i.domAtom?i.domFromPos(i.size,n):{node:this.contentDOM,offset:i?re(i.dom)+1:0}}else{let i,s=!0;for(;i=r<this.children.length?this.children[r]:null,!(!i||i.dom.parentNode==this.contentDOM);r++,s=!1);return i&&s&&!i.border&&!i.domAtom?i.domFromPos(0,n):{node:this.contentDOM,offset:i?re(i.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let o=-1,i=-1;for(let s=r,l=0;;l++){let a=this.children[l],c=s+a.size;if(o==-1&&e<=c){let u=s+a.border;if(e>=u&&n<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,n,u);e=s;for(let d=l;d>0;d--){let f=this.children[d-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){o=re(f.dom)+1;break}e-=f.size}o==-1&&(o=0)}if(o>-1&&(c>n||l==this.children.length-1)){n=c;for(let u=l+1;u<this.children.length;u++){let d=this.children[u];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(-1)){i=re(d.dom);break}n+=d.size}i==-1&&(i=this.contentDOM.childNodes.length);break}s=c}return{node:this.contentDOM,from:e,to:n,fromOffset:o,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:r}=this.domFromPos(e,0);if(!N(n)||r==n.childNodes.length)throw new RangeError(\"No node after pos \"+e);return n.childNodes[r]}setSelection(e,n,r,o=!1){let i=Math.min(e,n),s=Math.max(e,n);for(let h=0,p=0;h<this.children.length;h++){let m=this.children[h],g=p+m.size;if(i>p&&s<g)return m.setSelection(e-p-m.border,n-p-m.border,r,o);p=g}let l=this.domFromPos(e,e?-1:1),a=n==e?l:this.domFromPos(n,n?-1:1),c=r.root.getSelection(),u=r.domSelectionRange(),d=!1;if((we||ce)&&e==n){let{node:h,offset:p}=l;if(Z(h)){if(d=!!(p&&h.nodeValue[p-1]==`\n`),d&&p==h.nodeValue.length)for(let m=h,g;m;m=m.parentNode){if(g=m.nextSibling){g.nodeName==\"BR\"&&(l=a={node:g.parentNode,offset:re(g)+1});break}let y=m.pmViewDesc;if(y&&y.node&&y.node.isBlock)break}}else{let m=h.childNodes[p-1];d=m&&(m.nodeName==\"BR\"||m.contentEditable==\"false\")}}if(we&&u.focusNode&&u.focusNode!=a.node&&N(u.focusNode)){let h=u.focusNode.childNodes[u.focusOffset];h&&h.contentEditable==\"false\"&&(o=!0)}if(!(o||d&&ce)&&Lt(l.node,l.offset,u.anchorNode,u.anchorOffset)&&Lt(a.node,a.offset,u.focusNode,u.focusOffset))return;let f=!1;if((c.extend||e==n)&&!(d&&we)){c.collapse(l.node,l.offset);try{e!=n&&c.extend(a.node,a.offset),f=!0}catch{}}if(!f){if(e>n){let p=l;l=a,a=p}let h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!=\"selection\"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,o=0;o<this.children.length;o++){let i=this.children[o],s=r+i.size;if(r==s?e<=s&&n>=r:e<s&&n>r){let l=r+i.border,a=s-i.border;if(e>=l&&n<=a){this.dirty=e==r||n==s?Nt:mc,e==l&&n==a&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=Oe:i.markDirty(e-l,n-l);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Nt:Oe}r=s}this.dirty=Nt}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Nt:mc;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},Nr=class extends zt{constructor(e,n,r,o){let i,s=n.type.toDOM;if(typeof s==\"function\"&&(s=s(r,()=>{if(!i)return o;if(i.parent)return i.parent.posBeforeChild(i)})),!n.type.spec.raw){let l=N(s)?s:document.createElement(\"span\");l!=s&&l.appendChild(s),l.hasAttribute(\"contenteditable\")||(l.contentEditable=\"false\"),l.classList.add(\"ProseMirror-widget\")}super(e,[],s,null),this.widget=n,this.widget=n,i=this}matchesWidget(e){return this.dirty==ve&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!=\"selection\"||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}},Ki=class extends zt{constructor(e,n,r,o){super(e,[],n,null),this.textDOM=r,this.text=o}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type===\"characterData\"&&e.target.nodeValue==e.oldValue}},Rt=class t extends zt{constructor(e,n,r,o,i){super(e,[],r,o),this.mark=n,this.spec=i}static create(e,n,r,o){let i=o.nodeViews[n.type.name],s=i&&i(n,o,r);return(!s||!s.dom)&&(s=We.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new t(e,n,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&Oe||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Oe&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=ve){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=ve}}slice(e,n,r){let o=t.create(this.parent,this.mark,!0,r),i=this.children,s=this.size;n<s&&(i=Gi(i,n,s,r)),e>0&&(i=Gi(i,0,e,r));for(let l=0;l<i.length;l++)i[l].parent=o;return o.children=i,o}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},dt=class t extends zt{constructor(e,n,r,o,i,s,l){super(e,[],i,s),this.node=n,this.outerDeco=r,this.innerDeco=o,this.nodeDOM=l}static create(e,n,r,o,i,s){let l=i.nodeViews[n.type.name],a,c=l&&l(n,i,()=>{if(!a)return s;if(a.parent)return a.parent.posBeforeChild(a)},r,o),u=c&&c.dom,d=c&&c.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(!Z(u))throw new RangeError(\"Text must be rendered as a DOM text node\")}else u||({dom:u,contentDOM:d}=We.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!d&&!n.isText&&u.nodeName!=\"BR\"&&(u.hasAttribute(\"contenteditable\")||(u.contentEditable=\"false\"),n.type.spec.draggable&&(u.draggable=!0));let f=u;return u=Xc(u,r,n),c?a=new Ui(e,n,r,o,u,d||null,f,c):n.isText?new Or(e,n,r,o,u,f):new t(e,n,r,o,u,d||null,f)}parseRule(e){if(this.node.type.spec.reparseInView)return null;let n={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace==\"pre\"&&(n.preserveWhitespace=\"full\"),!this.contentDOM)n.getContent=()=>this.node.content;else if(!this.contentLost)n.contentElement=this.contentDOM;else{for(let r=this.children.length-1;r>=0;r--){let o=this.children[r];if(this.dom.contains(o.dom.parentNode)){n.contentElement=o.dom.parentNode;break}}if(!n.contentElement){let r=e&&e.find(o=>N(o)&&e.indexOf(o.parentNode)<0&&this.dom.contains(o));r?n.contentElement=r:n.getContent=()=>b.empty}}return n}matchesNode(e,n,r){return this.dirty==ve&&e.eq(this.node)&&Dr(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,o=n,i=e.composing?this.localCompositionInfo(e,n):null,s=i&&i.pos>-1?i:null,l=i&&i.pos<0,a=new qi(this,s&&s.node,e),c=this.node.inlineContent,u=c&&this.node.isBlock;mm(this.node,this.innerDeco,(d,f,h)=>{d.spec.marks?a.syncToMarks(d.spec.marks,r,e,f):d.type.side>=0&&!h&&a.syncToMarks(f==this.node.childCount?$.none:this.node.child(f).marks,r,e,f),a.placeWidget(d,e,o)},(d,f,h,p)=>{a.syncToMarks(d.marks,r,e,p),u&&d.isAtom&&!d.isText&&a.addHackNode(\"IMG\",a.top);let m;a.findNodeMatch(d,f,h,p)||l&&e.state.selection.from>o&&e.state.selection.to<o+d.nodeSize&&(m=a.findIndexWithChild(i.node))>-1&&a.updateNodeAt(d,f,h,m,e)||a.updateNextNode(d,f,h,e,p,o)||a.addNode(d,f,h,e,o),o+=d.nodeSize,c&&(u=d.isAtom&&!d.isText)}),a.syncToMarks([],r,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==Nt)&&(s&&this.protectLocalComposition(e,s),qc(this.contentDOM,this.children,e),sn&&gm(this.dom))}localCompositionInfo(e,n){let{from:r,to:o}=e.state.selection;if(!(e.state.selection instanceof M)||r<n||o>n+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let s=i.nodeValue,l=ym(this.node.content,s,r-n,o-n);return l<0?null:{node:i,pos:l,text:s}}else return{node:i,pos:-1,text:\"\"}}protectLocalComposition(e,{node:n,pos:r,text:o}){if(this.getDesc(n))return;let i=n;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let s=new Ki(this,i,n,o);e.input.compositionNodes.push(s),this.children=Gi(this.children,r,r+o.length,e,s)}update(e,n,r,o){return this.dirty==Oe||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,o),!0)}updateInner(e,n,r,o){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(o,this.posAtStart),this.dirty=ve}updateOuterDeco(e){if(Dr(e,this.outerDeco))return;let n=!N(this.nodeDOM),r=this.dom;this.dom=Gc(this.dom,this.nodeDOM,Ji(this.outerDeco,this.node,n),Ji(e,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){N(this.nodeDOM)&&(this.nodeDOM.classList.add(\"ProseMirror-selectednode\"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){N(this.nodeDOM)&&(this.nodeDOM.classList.remove(\"ProseMirror-selectednode\"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute(\"draggable\"))}get domAtom(){return this.node.isAtom}};function gc(t,e,n,r,o){Xc(r,e,t);let i=new dt(void 0,t,e,n,r,r,r);return i.contentDOM&&i.updateChildren(o,0),i}var Or=class t extends dt{constructor(e,n,r,o,i,s){super(e,n,r,o,i,null,s)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,o){return this.dirty==Oe||this.dirty!=ve&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=ve||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,o.trackWrites==this.nodeDOM&&(o.trackWrites=null)),this.node=e,this.dirty=ve,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!=\"characterData\"&&e.type!=\"selection\"}slice(e,n,r){let o=this.node.cut(e,n),i=document.createTextNode(o.text);return new t(this.parent,o,this.outerDeco,this.innerDeco,i,i)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=Oe)}get domAtom(){return!1}isText(e){return this.node.text==e}},Rr=class extends zt{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==ve&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName==\"IMG\"}},Ui=class extends dt{constructor(e,n,r,o,i,s,l,a){super(e,n,r,o,i,s,l),this.spec=a}update(e,n,r,o){if(this.dirty==Oe)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,n,r);return i&&this.updateInner(e,n,r,o),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,o){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,o)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}};function qc(t,e,n){let r=t.firstChild,o=!1;for(let i=0;i<e.length;i++){let s=e[i],l=s.dom;if(l.parentNode==t){for(;l!=r;)r=yc(r),o=!0;r=r.nextSibling}else o=!0,t.insertBefore(l,r);if(s instanceof Rt){let a=r?r.previousSibling:t.lastChild;qc(s.contentDOM,s.children,n),r=a?a.nextSibling:t.firstChild}}for(;r;)r=yc(r),o=!0;o&&n.trackWrites==t&&(n.trackWrites=null)}var Fn=function(t){t&&(this.nodeName=t)};Fn.prototype=Object.create(null);var Ot=[new Fn];function Ji(t,e,n){if(t.length==0)return Ot;let r=n?Ot[0]:new Fn,o=[r];for(let i=0;i<t.length;i++){let s=t[i].type.attrs;if(s){s.nodeName&&o.push(r=new Fn(s.nodeName));for(let l in s){let a=s[l];a!=null&&(n&&o.length==1&&o.push(r=new Fn(e.isInline?\"span\":\"div\")),l==\"class\"?r.class=(r.class?r.class+\" \":\"\")+a:l==\"style\"?r.style=(r.style?r.style+\";\":\"\")+a:l!=\"nodeName\"&&(r[l]=a))}}}return o}function Gc(t,e,n,r){if(n==Ot&&r==Ot)return e;let o=e;for(let i=0;i<r.length;i++){let s=r[i],l=n[i];if(i){let a;l&&l.nodeName==s.nodeName&&o!=t&&(a=o.parentNode)&&a.nodeName.toLowerCase()==s.nodeName||(a=document.createElement(s.nodeName),a.pmIsDeco=!0,a.appendChild(o),l=Ot[0]),o=a}fm(o,l||Ot[0],s)}return o}function fm(t,e,n){for(let r in e)r!=\"class\"&&r!=\"style\"&&r!=\"nodeName\"&&!(r in n)&&t.removeAttribute(r);for(let r in n)r!=\"class\"&&r!=\"style\"&&r!=\"nodeName\"&&n[r]!=e[r]&&t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(\" \").filter(Boolean):[],o=n.class?n.class.split(\" \").filter(Boolean):[];for(let i=0;i<r.length;i++)o.indexOf(r[i])==-1&&t.classList.remove(r[i]);for(let i=0;i<o.length;i++)r.indexOf(o[i])==-1&&t.classList.add(o[i]);t.classList.length==0&&t.removeAttribute(\"class\")}if(e.style!=n.style){if(e.style){let r=/\\s*([\\w\\-\\xa1-\\uffff]+)\\s*:(?:\"(?:\\\\.|[^\"])*\"|'(?:\\\\.|[^'])*'|\\(.*?\\)|[^;])*/g,o;for(;o=r.exec(e.style);)t.style.removeProperty(o[1])}n.style&&(t.style.cssText+=n.style)}}function Xc(t,e,n){return Gc(t,t,Ot,Ji(e,n,!N(t)))}function Dr(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 yc(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}var qi=class{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=hm(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let r=e;r<n;r++)this.top.children[r].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,r,o){let i=0,s=this.stack.length>>1,l=Math.min(s,e.length);for(;i<l&&(i==s-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<s;)this.destroyRest(),this.top.dirty=ve,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let a=-1,c=this.top.children.length;o<this.preMatch.index&&(c=Math.min(this.index+3,c));for(let u=this.index;u<c;u++){let d=this.top.children[u];if(d.matchesMark(e[s])&&!this.isLocked(d.dom)){a=u;break}}if(a<0&&this.index<this.top.children.length){let u=this.top.children[this.index];u instanceof Rt&&u.dirty!=Oe&&u.mark.type==e[s].type&&u.spec.update&&!this.isLocked(u.dom)&&u.spec.update(e[s])&&(u.mark=e[s],a=this.index,this.changed=!0)}if(a>-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let u=Rt.create(this.top,e[s],n,r);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,s++}}findNodeMatch(e,n,r,o){let i=-1,s;if(o>=this.preMatch.index&&(s=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&s.matchesNode(e,n,r))i=this.top.children.indexOf(s,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,n,r)&&!this.preMatch.matched.has(c)){i=l;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,n,r,o,i){let s=this.top.children[o];return s.dirty==Oe&&s.dom==s.contentDOM&&(s.dirty=Nt),s.update(e,n,r,i)?(this.destroyBetween(this.index,o),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let o=this.index;o<this.top.children.length;o++)if(this.top.children[o]==r)return o}return-1}e=n}}updateNextNode(e,n,r,o,i,s){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof dt){let c=this.preMatch.matched.get(a);if(c!=null&&c!=i)return!1;let u=a.dom,d,f=this.isLocked(u)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=Oe&&Dr(n,a.outerDeco));if(!f&&a.update(e,n,r,o))return this.destroyBetween(this.index,l),a.dom!=u&&(this.changed=!0),this.index++,!0;if(!f&&(d=this.recreateWrapper(a,e,n,r,o,s)))return this.destroyBetween(this.index,l),this.top.children[this.index]=d,d.contentDOM&&(d.dirty=Nt,d.updateChildren(o,s+1),d.dirty=ve),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,o,i,s){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!Dr(r,e.outerDeco)||!o.eq(e.innerDeco))return null;let l=dt.create(this.top,n,r,o,i,s);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,n,r,o,i){let s=dt.create(this.top,e,n,r,o,i);s.contentDOM&&s.updateChildren(o,i+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(e,n,r){let o=this.index<this.top.children.length?this.top.children[this.index]:null;if(o&&o.matchesWidget(e)&&(e==o.widget||!o.widget.type.toDOM.parentNode))this.index++;else{let i=new Nr(this.top,e,n,r);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof Rt;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof Or)||/\\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\\s$/.test(e.node.text))&&((ce||oe)&&e&&e.dom.contentEditable==\"false\"&&this.addHackNode(\"IMG\",n),this.addHackNode(\"BR\",this.top))}addHackNode(e,n){if(n==this.top&&this.index<n.children.length&&n.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e==\"IMG\"&&(r.className=\"ProseMirror-separator\",r.alt=\"\"),e==\"BR\"&&(r.className=\"ProseMirror-trailingBreak\");let o=new Rr(this.top,[],r,null);n!=this.top?n.children.push(o):n.children.splice(this.index++,0,o),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||N(e)&&e.contains(this.lock.parentNode))}};function hm(t,e){let n=e,r=n.children.length,o=t.childCount,i=new Map,s=[];e:for(;o>0;){let l;for(;;)if(r){let c=n.children[r-1];if(c instanceof Rt)n=c,r=c.children.length;else{l=c,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let a=l.node;if(a){if(a!=t.child(o-1))break;--o,i.set(l,o),s.push(l)}}return{index:o,matched:i,matches:s.reverse()}}function pm(t,e){return t.type.side-e.type.side}function mm(t,e,n,r){let o=e.locals(t),i=0;if(o.length==0){for(let c=0;c<t.childCount;c++){let u=t.child(c);r(u,o,e.forChild(i,u),c),i+=u.nodeSize}return}let s=0,l=[],a=null;for(let c=0;;){let u,d;for(;s<o.length&&o[s].to==i;){let g=o[s++];g.widget&&(u?(d||(d=[u])).push(g):u=g)}if(u)if(d){d.sort(pm);for(let g=0;g<d.length;g++)n(d[g],c,!!a)}else n(u,c,!!a);let f,h;if(a)h=-1,f=a,a=null;else if(c<t.childCount)h=c,f=t.child(c++);else break;for(let g=0;g<l.length;g++)l[g].to<=i&&l.splice(g--,1);for(;s<o.length&&o[s].from<=i&&o[s].to>i;)l.push(o[s++]);let p=i+f.nodeSize;if(f.isText){let g=p;s<o.length&&o[s].from<g&&(g=o[s].from);for(let y=0;y<l.length;y++)l[y].to<g&&(g=l[y].to);g<p&&(a=f.cut(g-i),f=f.cut(0,g-i),p=g,h=-1)}else for(;s<o.length&&o[s].to<p;)s++;let m=f.isInline&&!f.isLeaf?l.filter(g=>!g.inline):l.slice();r(f,m,e.forChild(i,f),h),i=p}}function gm(t){if(t.nodeName==\"UL\"||t.nodeName==\"OL\"){let e=t.style.cssText;t.style.cssText=e+\"; list-style: square !important\",window.getComputedStyle(t).listStyle,t.style.cssText=e}}function ym(t,e,n,r){for(let o=0,i=0;o<t.childCount&&i<=r;){let s=t.child(o++),l=i;if(i+=s.nodeSize,!s.isText)continue;let a=s.text;for(;o<t.childCount;){let c=t.child(o++);if(i+=c.nodeSize,!c.isText)break;a+=c.text}if(i>=n){if(i>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l<r?a.lastIndexOf(e,r-l-1):-1;if(c>=0&&c+e.length+l>=n)return l+c;if(n==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function Gi(t,e,n,r,o){let i=[];for(let s=0,l=0;s<t.length;s++){let a=t[s],c=l,u=l+=a.size;c>=n||u<=e?i.push(a):(c<e&&i.push(a.slice(0,e-c,r)),o&&(i.push(o),o=void 0),u>n&&i.push(a.slice(n-c,a.size,r)))}return i}function as(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let o=t.docView.nearestDesc(n.focusNode),i=o&&o.size==0,s=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let l=r.resolve(s),a,c;if(Fr(n)){for(a=s;o&&!o.node;)o=o.parent;if(o&&o.node.isAtom&&A.isSelectable(o.node)&&o.parent&&!(o.node.isInline&&Jp(n.focusNode,n.focusOffset,o.dom))){let d=o.posBefore;c=new A(s==d?l:r.resolve(d))}else if(we&&e==\"key\"&&s>t.state.selection.to&&N(n.focusNode)&&n.focusOffset==n.focusNode.childNodes.length&&o&&o.posAtStart>t.state.selection.to)for(let d=n.focusNode;;d=d.parentNode){if(getComputedStyle(d).overflow!=\"visible\"){c=E.findFrom(r.resolve(o.posAtStart),1);break}if(d==o.dom||d.nextSibling||!d.parentNode||!N(d.parentNode))break}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let d=s,f=s;for(let h=0;h<n.rangeCount;h++){let p=n.getRangeAt(h);d=Math.min(d,t.docView.posFromDOM(p.startContainer,p.startOffset,1)),f=Math.max(f,t.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(d<0)return null;[a,s]=f==t.state.selection.anchor?[f,d]:[d,f],l=r.resolve(s)}else a=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(a<0)return null}let u=r.resolve(a);if(!c){let d=e==\"pointer\"||t.state.selection.head<l.pos&&!i?1:-1;c=cs(t,u,l,d)}return c}function Yc(t){return t.editable?t.hasFocus():Zc(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Xe(t,e=!1){let n=t.state.selection;if(Qc(t,n),!Yc(t))return;let r=t.input.mouseDown;if(!e&&oe&&r){let o=t.domSelectionRange(),i=t.domObserver.currentSelection;if(o.anchorNode&&i.anchorNode&&Lt(o.anchorNode,o.anchorOffset,i.anchorNode,i.anchorOffset)&&r.delaySelUpdate()){t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)km(t);else{let{anchor:o,head:i}=n,s,l;bc&&!(n instanceof M)&&(n.$from.parent.inlineContent||(s=kc(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(l=kc(t,n.to))),t.docView.setSelection(o,i,t,e),bc&&(s&&wc(s),l&&wc(l)),n.visible?t.dom.classList.remove(\"ProseMirror-hideselection\"):(t.dom.classList.add(\"ProseMirror-hideselection\"),\"onselectionchange\"in document&&bm(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}var bc=ce||oe&&Hc<63;function kc(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),o=r<n.childNodes.length?n.childNodes[r]:null,i=r?n.childNodes[r-1]:null;if(ce&&o&&o.contentEditable==\"false\")return zi(o);if((!o||o.contentEditable==\"false\")&&(!i||i.contentEditable==\"false\")){if(o)return zi(o);if(i)return zi(i)}}function zi(t){return t.contentEditable=\"true\",ce&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function wc(t){t.contentEditable=\"false\",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function bm(t){let e=t.dom.ownerDocument;e.removeEventListener(\"selectionchange\",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,o=n.anchorOffset;e.addEventListener(\"selectionchange\",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=o)&&(e.removeEventListener(\"selectionchange\",t.input.hideSelectionGuard),setTimeout(()=>{(!Yc(t)||t.state.selection.visible)&&t.dom.classList.remove(\"ProseMirror-hideselection\")},20))})}function km(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName==\"IMG\";r?e.collapse(n.parentNode,re(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&be&&ut<=11&&(n.disabled=!0,n.disabled=!1)}function Qc(t,e){if(e instanceof A){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(Sc(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else Sc(t)}function Sc(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function cs(t,e,n,r){return t.someProp(\"createSelectionBetween\",o=>o(t,e,n))||M.between(e,n,r)}function xc(t){return t.editable&&!t.hasFocus()?!1:Zc(t)}function Zc(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return $t(t.dom,e.anchorNode)&&(t.editable||$t(t.dom,e.focusNode))}catch{return!1}}function wm(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Lt(e.node,e.offset,n.anchorNode,n.anchorOffset)}function Xi(t,e){let{$anchor:n,$head:r}=t.selection,o=e>0?n.max(r):n.min(r),i=o.parent.inlineContent?o.depth?t.doc.resolve(e>0?o.after():o.before()):null:o;return i&&E.findFrom(i,e)}function ct(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function Cc(t,e,n){let r=t.state.selection;if(r instanceof M)if(n.indexOf(\"s\")>-1){let{$head:o}=r,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let s=t.state.doc.resolve(o.pos+i.nodeSize*(e<0?-1:1));return ct(t,new M(r.$anchor,s))}else if(r.empty){if(t.endOfTextblock(e>0?\"forward\":\"backward\")){let o=Xi(t.state,e);return o&&o instanceof A?ct(t,o):!1}else if(!(Me&&n.indexOf(\"m\")>-1)){let o=r.$head,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter,s;if(!i||i.isText)return!1;let l=e<0?o.pos-i.nodeSize:o.pos;return i.isAtom||(s=t.docView.descAt(l))&&!s.contentDOM?A.isSelectable(i)?ct(t,new A(e<0?t.state.doc.resolve(o.pos-i.nodeSize):o)):ct(t,new M(t.state.doc.resolve(e<0?l:l+i.nodeSize))):!1}}else return!1;else{if(r instanceof A&&r.node.isInline)return ct(t,new M(e>0?r.$to:r.$from));{let o=Xi(t.state,e);return o?ct(t,o):!1}}}function Hn(t,e){let n=t.pmViewDesc;return n?n.size==0&&(e<0||t.nextSibling||t.nodeName!=\"BR\"):N(t)&&t.contentEditable==\"false\"}function nn(t,e){return e<0?Sm(t):xm(t)}function Sm(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let o,i,s=!1;for(we&&N(n)&&r<ae(n)&&Hn(n.childNodes[r],-1)&&(s=!0);;)if(r>0){if(!N(n))break;let l=n.childNodes[r-1];if(Hn(l,-1))o=n,i=--r;else if(Z(l))n=l,r=n.nodeValue.length;else break}else{if(eu(n))break;{let l=n.previousSibling;for(;l&&Hn(l,-1);)o=n.parentNode,i=re(l),l=l.previousSibling;if(l)n=l,r=ae(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}s?Yi(t,n,r):o&&Yi(t,o,i)}function xm(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let o=ae(n),i,s;for(;;)if(r<o){if(!N(n))break;let l=n.childNodes[r];if(Hn(l,1))i=n,s=++r;else break}else{if(eu(n))break;{let l=n.nextSibling;for(;l&&Hn(l,1);)i=l.parentNode,s=re(l)+1,l=l.nextSibling;if(l)n=l,r=0,o=ae(n);else{if(n=n.parentNode,n==t.dom)break;r=o=0}}}i&&Yi(t,i,s)}function eu(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function Cm(t,e){for(;t&&e==t.childNodes.length&&!Kn(t);)e=re(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(Z(n))return n;if(N(n)&&n.contentEditable==\"false\")break;t=n,e=0}}function Mm(t,e){for(;t&&!e&&!Kn(t);)e=re(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(Z(n))return n;if(N(n)&&n.contentEditable==\"false\")break;t=n,e=t.childNodes.length}}function Yi(t,e,n){if(!Z(e)){let i,s;(s=Cm(e,n))?(e=s,n=0):(i=Mm(e,n))&&(e=i,n=i.nodeValue.length)}let r=t.domSelection();if(!r)return;if(Fr(r)){let i=document.createRange();i.setEnd(e,n),i.setStart(e,n),r.removeAllRanges(),r.addRange(i)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:o}=t;setTimeout(()=>{t.state==o&&Xe(t)},50)}function Mc(t,e){let n=t.state.doc.resolve(e);if(!(oe||jc)&&n.parent.inlineContent){let o=t.coordsAtPos(e);if(e>n.start()){let i=t.coordsAtPos(e-1),s=(i.top+i.bottom)/2;if(s>o.top&&s<o.bottom&&Math.abs(i.left-o.left)>1)return i.left<o.left?\"ltr\":\"rtl\"}if(e<n.end()){let i=t.coordsAtPos(e+1),s=(i.top+i.bottom)/2;if(s>o.top&&s<o.bottom&&Math.abs(i.left-o.left)>1)return i.left>o.left?\"ltr\":\"rtl\"}}return getComputedStyle(t.dom).direction==\"rtl\"?\"rtl\":\"ltr\"}function vc(t,e,n){let r=t.state.selection;if(r instanceof M&&!r.empty||n.indexOf(\"s\")>-1||Me&&n.indexOf(\"m\")>-1)return!1;let{$from:o,$to:i}=r;if(!o.parent.inlineContent||t.endOfTextblock(e<0?\"up\":\"down\")){let s=Xi(t.state,e);if(s&&s instanceof A)return ct(t,s)}if(!o.parent.inlineContent){let s=e<0?o:i,l=r instanceof pe?E.near(s,e):E.findFrom(s,e);return l?ct(t,l):!1}return!1}function Ec(t,e){if(!(t.state.selection instanceof M))return!0;let{$head:n,$anchor:r,empty:o}=t.state.selection;if(!n.sameParent(r))return!0;if(!o)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 s=t.state.tr;return e<0?s.delete(n.pos-i.nodeSize,n.pos):s.delete(n.pos,n.pos+i.nodeSize),t.dispatch(s),!0}return!1}function Ac(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function vm(t){if(!ce||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&N(e)&&n==0&&e.firstChild&&N(e.firstChild)&&e.firstChild.contentEditable==\"false\"){let r=e.firstChild;Ac(t,r,\"true\"),setTimeout(()=>Ac(t,r,\"false\"),20)}return!1}function Em(t){let e=\"\";return t.ctrlKey&&(e+=\"c\"),t.metaKey&&(e+=\"m\"),t.altKey&&(e+=\"a\"),t.shiftKey&&(e+=\"s\"),e}function Am(t,e){let n=e.keyCode,r=Em(e);if(n==8||Me&&n==72&&r==\"c\")return Ec(t,-1)||nn(t,-1);if(n==46&&!e.shiftKey||Me&&n==68&&r==\"c\")return Ec(t,1)||nn(t,1);if(n==13||n==27)return!0;if(n==37||Me&&n==66&&r==\"c\"){let o=n==37?Mc(t,t.state.selection.from)==\"ltr\"?-1:1:-1;return Cc(t,o,r)||nn(t,o)}else if(n==39||Me&&n==70&&r==\"c\"){let o=n==39?Mc(t,t.state.selection.from)==\"ltr\"?1:-1:1;return Cc(t,o,r)||nn(t,o)}else{if(n==38||Me&&n==80&&r==\"c\")return vc(t,-1,r)||nn(t,-1);if(n==40||Me&&n==78&&r==\"c\")return vm(t)||vc(t,1,r)||nn(t,1);if(r==(Me?\"m\":\"c\")&&(n==66||n==73||n==89||n==90))return!0}return!1}function us(t,e){t.someProp(\"transformCopied\",h=>{e=h(e,t)});let n=[],{content:r,openStart:o,openEnd:i}=e;for(;o>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){o--,i--;let h=r.firstChild;n.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let s=t.someProp(\"clipboardSerializer\")||We.fromSchema(t.state.schema),l=su(),a=l.createElement(\"div\");a.appendChild(s.serializeFragment(r,{document:l}));let c=a.firstChild,u,d=0;for(;c&&N(c)&&(u=iu[c.nodeName.toLowerCase()]);){for(let h=u.length-1;h>=0;h--){let p=l.createElement(u[h]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),d++}c=a.firstChild}c&&N(c)&&c.setAttribute(\"data-pm-slice\",`${o} ${i}${d?` -${d}`:\"\"} ${JSON.stringify(n)}`);let f=t.someProp(\"clipboardTextSerializer\",h=>h(e,t))||e.content.textBetween(0,e.content.size,`\n\n`);return{dom:a,text:f,slice:e}}function tu(t,e,n,r,o){let i=o.parent.type.spec.code,s,l;if(!n&&!e)return null;let a=!!e&&(r||i||!n);if(a){if(t.someProp(\"transformPastedText\",f=>{e=f(e,i||r,t)}),i)return l=new C(b.from(t.state.schema.text(e.replace(/\\r\\n?/g,`\n`))),0,0),t.someProp(\"transformPasted\",f=>{l=f(l,t,!0)}),l;let d=t.someProp(\"clipboardTextParser\",f=>f(e,o,r,t));if(d)l=d;else{let f=o.marks(),{schema:h}=t.state,p=We.fromSchema(h);s=document.createElement(\"div\"),e.split(/(?:\\r\\n?|\\n)+/).forEach(m=>{let g=s.appendChild(document.createElement(\"p\"));m&&g.appendChild(p.serializeNode(h.text(m,f)))})}}else t.someProp(\"transformPastedHTML\",d=>{n=d(n,t)}),s=Rm(n),Hr&&Dm(s);let c=s&&s.querySelector(\"[data-pm-slice]\"),u=c&&/^(\\d+) (\\d+)(?: -(\\d+))? (.*)/.exec(c.getAttribute(\"data-pm-slice\")||\"\");if(u&&u[3])for(let d=+u[3];d>0;d--){let f=s.firstChild;for(;f&&!N(f);)f=f.nextSibling;if(!f)break;s=f}if(l||(l=(t.someProp(\"clipboardParser\")||t.someProp(\"domParser\")||je.fromSchema(t.state.schema)).parseSlice(s,{preserveWhitespace:!!(a||u),context:o,ruleFromNode(f){return f.nodeName==\"BR\"&&!f.nextSibling&&f.parentNode&&!Tm.test(f.parentNode.nodeName)?{ignore:!0}:null}})),u)l=Im(Tc(l,+u[1],+u[2]),u[4]);else if(l=C.maxOpen(Nm(l.content,o),!0),l.openStart||l.openEnd){let d=0,f=0;for(let h=l.content.firstChild;d<l.openStart&&!h.type.spec.isolating;d++,h=h.firstChild);for(let h=l.content.lastChild;f<l.openEnd&&!h.type.spec.isolating;f++,h=h.lastChild);l=Tc(l,d,f)}return t.someProp(\"transformPasted\",d=>{l=d(l,t,a)}),l}var Tm=/^(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 Nm(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let o=e.node(n).contentMatchAt(e.index(n)),i,s=[];if(t.forEach(l=>{if(!s)return;let a=o.findWrapping(l.type),c;if(!a)return s=null;if(c=s.length&&i.length&&ru(a,i,l,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=ou(s[s.length-1],i.length));let u=nu(l,a);s.push(u),o=o.matchType(u.type),i=a}}),s)return b.from(s)}return t}function nu(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,b.from(t));return t}function ru(t,e,n,r,o){if(o<t.length&&o<e.length&&t[o]==e[o]){let i=ru(t,e,n,r.lastChild,o+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(o==t.length-1?n.type:t[o+1]))return r.copy(r.content.append(b.from(nu(n,t,o+1))))}}function ou(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,ou(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(b.empty,!0);return t.copy(n.append(r))}function Qi(t,e,n,r,o,i){let s=e<0?t.firstChild:t.lastChild,l=s.content;return t.childCount>1&&(i=0),o<r-1&&(l=Qi(l,e,n,r,o+1,i)),o>=n&&(l=e<0?s.contentMatchAt(0).fillBefore(l,i<=o).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(b.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,s.copy(l))}function Tc(t,e,n){return e<t.openStart&&(t=new C(Qi(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new C(Qi(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}var iu={thead:[\"table\"],tbody:[\"table\"],tfoot:[\"table\"],caption:[\"table\"],colgroup:[\"table\"],col:[\"table\",\"colgroup\"],tr:[\"table\",\"tbody\"],td:[\"table\",\"tbody\",\"tr\"],th:[\"table\",\"tbody\",\"tr\"]};function su(){return document.implementation.createHTMLDocument(\"title\")}var Bn=null;function Om(t){let e=window.trustedTypes;if(!e)return t;if(!Bn){if(Bn=e.defaultPolicy)try{return Bn.createHTML(t)}catch{}Bn=e.createPolicy(\"ProseMirrorClipboard\",{createHTML:n=>n})}return Bn.createHTML(t)}function Rm(t){let e=/^(\\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=su(),r=n.body,o=/<([a-z][^>\\s]+)/i.exec(t),i;if((i=o&&iu[o[1].toLowerCase()])&&(t=i.map(s=>\"<\"+s+\">\").join(\"\")+t+i.map(s=>\"</\"+s+\">\").reverse().join(\"\")),r.innerHTML=Om(t),i)for(let s=0;s<i.length;s++)r=r.querySelector(i[s])||r;for(let s=0;s<n.styleSheets.length;s++){let l=n.styleSheets[s];for(let a=0;a<l.rules.length;a++){let c=l.rules[a];if(c instanceof CSSStyleRule){let u=r.querySelectorAll(c.selectorText);for(let d=0;d<u.length;d++)u[d].style.cssText+=c.style.cssText}}}return r}function Dm(t){let e=t.querySelectorAll(oe?\"span:not([class]):not([style])\":\"span.Apple-converted-space\");for(let n=0;n<e.length;n++){let r=e[n];r.childNodes.length==1&&r.textContent==\"\\xA0\"&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(\" \"),r)}}function Im(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:o,openStart:i,openEnd:s}=t;for(let l=r.length-2;l>=0;l-=2){let a=n.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;try{o=b.from(a.create(r[l+1],o))}catch{break}i++,s++}return new C(o,i,s)}var me={},ge={},Pm={touchstart:!0,touchmove:!0},Zi=class{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.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function Lm(t){for(let e in me){let n=me[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{zm(t,r)&&!ds(t,r)&&(t.editable||!(r.type in ge))&&n(t,r)},Pm[e]?{passive:!0}:void 0)}ce&&t.dom.addEventListener(\"input\",()=>null),es(t)}function Ge(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function $m(t){t.input.mouseDown&&t.input.mouseDown.done(),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)}function es(t){t.someProp(\"handleDOMEvents\",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>ds(t,r))})}function ds(t,e){return t.someProp(\"handleDOMEvents\",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function zm(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||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function Bm(t,e){!ds(t,e)&&me[e.type]&&(t.editable||!(e.type in ge))&&me[e.type](t,e)}ge.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!cu(t)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(qe&&oe&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),sn&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp(\"handleKeyDown\",o=>o(t,Tt(13,\"Enter\"))),t.input.lastIOSEnter=0)},200)}else t.someProp(\"handleKeyDown\",r=>r(t,n))||Am(t,n)?n.preventDefault():Ge(t,\"key\")};ge.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};ge.keypress=(t,e)=>{let n=e;if(cu(t)||!n.charCode||n.ctrlKey&&!n.altKey||Me&&n.metaKey)return;if(t.someProp(\"handleKeyPress\",o=>o(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof M)||!r.$from.sameParent(r.$to)){let o=String.fromCharCode(n.charCode),i=()=>t.state.tr.insertText(o).scrollIntoView();!/[\\r\\n]/.test(o)&&!t.someProp(\"handleTextInput\",s=>s(t,r.$from.pos,r.$to.pos,o,i))&&t.dispatch(i()),n.preventDefault()}};function Un(t){return{left:t.clientX,top:t.clientY}}function Fm(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function fs(t,e,n,r,o){if(r==-1)return!1;let i=t.state.doc.resolve(r);for(let s=i.depth+1;s>0;s--)if(t.someProp(e,l=>s>i.depth?l(t,n,i.nodeAfter,i.before(s),o,!0):l(t,n,i.node(s),i.before(s),o,!1)))return!0;return!1}function Jn(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);r.setMeta(\"pointer\",!0),t.dispatch(r)}function Hm(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&A.isSelectable(r)?(Jn(t,new A(n)),!0):!1}function jm(t,e){if(e==-1)return!1;let n=t.state.selection,r,o;n instanceof A&&(r=n.node);let i=t.state.doc.resolve(e);for(let s=i.depth+1;s>0;s--){let l=s>i.depth?i.nodeAfter:i.node(s);if(A.isSelectable(l)){r&&n.$from.depth>0&&s>=n.$from.depth&&i.before(n.$from.depth+1)==n.$from.pos?o=i.before(n.$from.depth):o=i.before(s);break}}return o!=null?(Jn(t,A.create(t.state.doc,o)),!0):!1}function Wm(t,e,n,r,o){return fs(t,\"handleClickOn\",e,n,r)||t.someProp(\"handleClick\",i=>i(t,e,r))||(o?jm(t,n):Hm(t,n))}function Vm(t,e,n,r){return fs(t,\"handleDoubleClickOn\",e,n,r)||t.someProp(\"handleDoubleClick\",o=>o(t,e,r))}function _m(t,e,n,r){return fs(t,\"handleTripleClickOn\",e,n,r)||t.someProp(\"handleTripleClick\",o=>o(t,e,r))||Km(t,n,r)}function Km(t,e,n){if(n.button!=0)return!1;let r=lu(t,e,!0),o=t.state.doc;return r?(Jn(t,r),r instanceof M&&o.eq(t.state.doc)&&(t.input.mouseDown=new ns(t,r)),!0):!1}function lu(t,e,n){let r=t.state.doc;if(e==-1)return r.inlineContent?M.create(r,0,r.content.size):null;let o=r.resolve(e);for(let i=o.depth+1;i>0;i--){let s=i>o.depth?o.nodeAfter:o.node(i),l=o.before(i);if(s.inlineContent)return M.create(r,l+1,l+1+s.content.size);if(n&&A.isSelectable(s))return A.create(r,l)}return null}function hs(t){return Pr(t)}var au=Me?\"metaKey\":\"ctrlKey\";me.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=hs(t),o=Date.now(),i=\"singleClick\";o-t.input.lastClick.time<500&&Fm(n,t.input.lastClick)&&!n[au]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type==\"singleClick\"?i=\"doubleClick\":t.input.lastClick.type==\"doubleClick\"&&(i=\"tripleClick\")),t.input.lastClick={time:o,x:n.clientX,y:n.clientY,type:i,button:n.button},t.input.mouseDown&&t.input.mouseDown.done();let s=t.posAtCoords(Un(n));s&&(i==\"singleClick\"?t.input.mouseDown=new ts(t,s,n,!!r):(i==\"doubleClick\"?Vm:_m)(t,s.pos,s.inside,n)?n.preventDefault():Ge(t,\"pointer\"))};var Ir=class{constructor(e){this.view=e,this.mightDrag=null,e.root.addEventListener(\"mouseup\",this.up=this.up.bind(this)),e.root.addEventListener(\"mousemove\",this.move=this.move.bind(this))}up(e){this.done()}move(e){e.buttons==0&&this.done()}done(){this.view.root.removeEventListener(\"mouseup\",this.up),this.view.root.removeEventListener(\"mousemove\",this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null)}delaySelUpdate(){return!1}},ts=class extends Ir{constructor(e,n,r,o){super(e),this.pos=n,this.event=r,this.flushed=o,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!r[au],this.allowDefault=r.shiftKey;let i,s;if(n.inside>-1)i=e.state.doc.nodeAt(n.inside),s=n.inside;else{let u=e.state.doc.resolve(n.pos);i=u.parent,s=u.depth?u.before():0}let l=o?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&N(a.nodeDOM)?a.nodeDOM:null;let{selection:c}=e.state;r.button==0&&(i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof A&&c.from<=s&&c.to>s)&&(this.mightDrag={node:i,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&we&&!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()),Ge(e,\"pointer\")}done(){super.done(),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(()=>{this.view.isDestroyed||Xe(this.view)})}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(Un(e))),this.updateAllowDefault(e),this.allowDefault||!n?Ge(this.view,\"pointer\"):Wm(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ce&&this.mightDrag&&!this.mightDrag.node.isAtom||oe&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(Jn(this.view,E.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Ge(this.view,\"pointer\")}move(e){this.updateAllowDefault(e),Ge(this.view,\"pointer\"),super.move(e)}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return this.allowDefault?(this.delayedSelectionSync=!0,!0):!1}},ns=class extends Ir{constructor(e,n){super(e),this.startSelection=n,this.startDoc=e.state.doc}move(e){if(e.buttons==0||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc)){this.done();return}e.preventDefault(),Ge(this.view,\"pointer\");let n=this.view.posAtCoords(Un(e)),r=n&&lu(this.view,n.inside,!1);if(!r)return;let{doc:o}=this.view.state,i=this.startSelection,[s,l]=r.from<i.from?[i.to,r.from]:[i.from,r.to];Jn(this.view,M.create(o,s,l))}};me.touchstart=t=>{t.input.lastTouch=Date.now(),hs(t),Ge(t,\"pointer\")};me.touchmove=t=>{t.input.lastTouch=Date.now(),Ge(t,\"pointer\")};me.contextmenu=t=>hs(t);function cu(t,e){return t.composing?!0:ce&&Math.abs(Date.now()-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}var Um=qe?5e3:-1;ge.compositionstart=ge.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof M&&e.selection.empty&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||oe&&jc&&Jm(t)))t.markCursor=t.state.storedMarks||n.marks(),Pr(t,!0),t.markCursor=null;else if(Pr(t,!e.selection.empty),we&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let o=r.focusNode,i=r.focusOffset;o&&N(o)&&i!=0;){let s=i<0?o.lastChild:o.childNodes[i-1];if(!s)break;if(Z(s)){let l=t.domSelection();l&&l.collapse(s,s.nodeValue.length);break}else o=s,i=-1}}t.input.composing=!0}uu(t,Um)};function Jm(t){let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(!e||!N(e)||n>=e.childNodes.length)return!1;let r=e.childNodes[n];return N(r)&&r.contentEditable==\"false\"}ge.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Date.now(),t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.badSafariComposition?t.domObserver.forceFlush():t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,uu(t,20))};function uu(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>Pr(t),e))}function du(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Date.now());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function qm(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=Kp(e.focusNode,e.focusOffset),r=Up(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let o=r.pmViewDesc,i=t.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!o||!o.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let s=n.pmViewDesc;if(!(!s||!s.isText(n.nodeValue)))return r}}return n||r}function Pr(t,e=!1){if(!(qe&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),du(t),e||t.docView&&t.docView.dirty){let n=as(t),r=t.state.selection;return n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function Gm(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 r=getSelection(),o=document.createRange();o.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}var jn=be&&ut<15||sn&&Xp<604;me.copy=ge.cut=(t,e)=>{let n=e,r=t.state.selection,o=n.type==\"cut\";if(r.empty)return;let i=jn?null:n.clipboardData,s=r.content(),{dom:l,text:a}=us(t,s);i?(n.preventDefault(),i.clearData(),i.setData(\"text/html\",l.innerHTML),i.setData(\"text/plain\",a)):Gm(t,l),o&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta(\"uiEvent\",\"cut\"))};function Xm(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function Ym(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?\"textarea\":\"div\"));n||(r.contentEditable=\"true\"),r.style.cssText=\"position: fixed; left: -10000px; top: 10px\",r.focus();let o=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Wn(t,r.value,null,o,e):Wn(t,r.textContent,r.innerHTML,o,e)},50)}function Wn(t,e,n,r,o){let i=tu(t,e,n,r,t.state.selection.$from);if(t.someProp(\"handlePaste\",a=>a(t,o,i||C.empty)))return!0;if(!i)return!1;let s=Xm(i),l=s?t.state.tr.replaceSelectionWith(s,r):t.state.tr.replaceSelection(i);return t.dispatch(l.scrollIntoView().setMeta(\"paste\",!0).setMeta(\"uiEvent\",\"paste\")),!0}function fu(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,\" \"):\"\"}ge.paste=(t,e)=>{let n=e;if(t.composing&&!qe)return;let r=jn?null:n.clipboardData,o=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&Wn(t,fu(r),r.getData(\"text/html\"),o,n)?n.preventDefault():Ym(t,n)};var Lr=class{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}},Qm=Me?\"altKey\":\"ctrlKey\";function hu(t,e){let n;return t.someProp(\"dragCopies\",r=>{n=n||r(e)}),n!=null?!n:!e[Qm]}me.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let o=t.state.selection,i=o.empty?null:t.posAtCoords(Un(n)),s;if(!(i&&i.pos>=o.from&&i.pos<=(o instanceof A?o.to-1:o.to))){if(r&&r.mightDrag)s=A.create(t.state.doc,r.mightDrag.pos);else if(n.target&&N(n.target)){let d=t.docView.nearestDesc(n.target,!0);d&&d.node.type.spec.draggable&&d!=t.docView&&(s=A.create(t.state.doc,d.posBefore))}}let l=(s||t.state.selection).content(),{dom:a,text:c,slice:u}=us(t,l);(!n.dataTransfer.files.length||!oe||Hc>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(jn?\"Text\":\"text/html\",a.innerHTML),n.dataTransfer.effectAllowed=\"copyMove\",jn||n.dataTransfer.setData(\"text/plain\",c),t.dragging=new Lr(u,hu(t,n),s)};me.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};ge.dragover=ge.dragenter=(t,e)=>e.preventDefault();ge.drop=(t,e)=>{try{Zm(t,e,t.dragging)}finally{t.dragging=null}};function Zm(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(Un(e));if(!r)return;let o=t.state.doc.resolve(r.pos),i=n&&n.slice;i?t.someProp(\"transformPasted\",h=>{i=h(i,t,!1)}):i=tu(t,fu(e.dataTransfer),jn?null:e.dataTransfer.getData(\"text/html\"),!1,o);let s=!!(n&&hu(t,e));if(t.someProp(\"handleDrop\",h=>h(t,e,i||C.empty,s))){e.preventDefault();return}if(!i)return;e.preventDefault();let l=i?Mr(t.state.doc,o.pos,i):o.pos;l==null&&(l=o.pos);let a=t.state.tr;if(s){let{node:h}=n;h?h.replace(a):a.deleteSelection()}let c=a.mapping.map(l),u=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,d=a.doc;if(u?a.replaceRangeWith(c,c,i.content.firstChild):a.replaceRange(c,c,i),a.doc.eq(d))return;let f=a.doc.resolve(c);if(u&&A.isSelectable(i.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(i.content.firstChild))a.setSelection(new A(f));else{let h=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((p,m,g,y)=>h=y),a.setSelection(cs(t,f,a.doc.resolve(h)))}t.focus(),t.dispatch(a.setMeta(\"uiEvent\",\"drop\"))}me.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())&&Xe(t)},20))};me.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)};me.beforeinput=(t,e)=>{if(qe&&e.inputType==\"deleteContentBackward\"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp(\"handleKeyDown\",i=>i(t,Tt(8,\"Backspace\")))))return;let{$cursor:o}=t.state.selection;o&&o.pos>0&&t.dispatch(t.state.tr.delete(o.pos-1,o.pos).scrollIntoView())},50)}};for(let t in ge)me[t]=ge[t];function Vn(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}var $r=class t{constructor(e,n){this.toDOM=e,this.spec=n||It,this.side=this.spec.side||0}map(e,n,r,o){let{pos:i,deleted:s}=e.mapResult(n.from+o,this.side<0?-1:1);return s?null:new ee(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof t&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Vn(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},Dt=class t{constructor(e,n){this.attrs=e,this.spec=n||It}map(e,n,r,o){let i=e.map(n.from+o,this.spec.inclusiveStart?-1:1)-r,s=e.map(n.to+o,this.spec.inclusiveEnd?1:-1)-r;return i>=s?null:new ee(i,s,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof t&&Vn(this.attrs,e.attrs)&&Vn(this.spec,e.spec)}static is(e){return e.type instanceof t}destroy(){}},rs=class t{constructor(e,n){this.attrs=e,this.spec=n||It}map(e,n,r,o){let i=e.mapResult(n.from+o,1);if(i.deleted)return null;let s=e.mapResult(n.to+o,-1);return s.deleted||s.pos<=i.pos?null:new ee(i.pos-r,s.pos-r,this)}valid(e,n){let{index:r,offset:o}=e.content.findIndex(n.from),i;return o==n.from&&!(i=e.child(r)).isText&&o+i.nodeSize==n.to}eq(e){return this==e||e instanceof t&&Vn(this.attrs,e.attrs)&&Vn(this.spec,e.spec)}destroy(){}},ee=class t{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new t(e,n,this.type)}eq(e,n=0){return this.type.eq(e.type)&&this.from+n==e.from&&this.to+n==e.to}map(e,n,r){return this.type.map(e,this,n,r)}static widget(e,n,r){return new t(e,e,new $r(n,r))}static inline(e,n,r,o){return new t(e,n,new Dt(r,o))}static node(e,n,r,o){return new t(e,n,new rs(r,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof Dt}get widget(){return this.type instanceof $r}},rn=[],It={},z=class t{constructor(e,n){this.local=e.length?e:rn,this.children=n.length?n:rn}static create(e,n){return n.length?Br(n,e,0,It):le}find(e,n,r){let o=[];return this.findInner(e??0,n??1e9,o,0,r),o}findInner(e,n,r,o,i){for(let s=0;s<this.local.length;s++){let l=this.local[s];l.from<=n&&l.to>=e&&(!i||i(l.spec))&&r.push(l.copy(l.from+o,l.to+o))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<n&&this.children[s+1]>e){let l=this.children[s]+1;this.children[s+2].findInner(e-l,n-l,r,o+l,i)}}map(e,n,r){return this==le||e.maps.length==0?this:this.mapInner(e,n,0,0,r||It)}mapInner(e,n,r,o,i){let s;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,o);a&&a.type.valid(n,a)?(s||(s=[])).push(a):i.onRemove&&i.onRemove(this.local[l].spec)}return this.children.length?eg(this.children,s||[],e,n,r,o,i):s?new t(s.sort(Pt),rn):le}add(e,n){return n.length?this==le?t.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let o,i=0;e.forEach((l,a)=>{let c=a+r,u;if(u=mu(n,l,c)){for(o||(o=this.children.slice());i<o.length&&o[i]<a;)i+=3;o[i]==a?o[i+2]=o[i+2].addInner(l,u,c+1):o.splice(i,0,a,a+l.nodeSize,Br(u,l,c+1,It)),i+=3}});let s=pu(i?gu(n):n,-r);for(let l=0;l<s.length;l++)s[l].type.valid(e,s[l])||s.splice(l--,1);return new t(s.length?this.local.concat(s).sort(Pt):this.local,o||this.children)}remove(e){return e.length==0||this==le?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,o=this.local;for(let i=0;i<r.length;i+=3){let s,l=r[i]+n,a=r[i+1]+n;for(let u=0,d;u<e.length;u++)(d=e[u])&&d.from>l&&d.to<a&&(e[u]=null,(s||(s=[])).push(d));if(!s)continue;r==this.children&&(r=this.children.slice());let c=r[i+2].removeInner(s,l+1);c!=le?r[i+2]=c:(r.splice(i,3),i-=3)}if(o.length){for(let i=0,s;i<e.length;i++)if(s=e[i])for(let l=0;l<o.length;l++)o[l].eq(s,n)&&(o==this.local&&(o=this.local.slice()),o.splice(l--,1))}return r==this.children&&o==this.local?this:o.length||r.length?new t(o,r):le}forChild(e,n){if(this==le)return this;if(n.isLeaf)return t.empty;let r,o;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let i=e+1,s=i+n.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<s&&a.to>i&&a.type instanceof Dt){let c=Math.max(i,a.from)-i,u=Math.min(s,a.to)-i;c<u&&(o||(o=[])).push(a.copy(c,u))}}if(o){let l=new t(o.sort(Pt),rn);return r?new zr([l,r]):l}return r||le}eq(e){if(this==e)return!0;if(!(e instanceof t)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(e.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=e.children[n]||this.children[n+1]!=e.children[n+1]||!this.children[n+2].eq(e.children[n+2]))return!1;return!0}locals(e){return ps(this.localsInner(e))}localsInner(e){if(this==le)return rn;if(e.inlineContent||!this.local.some(Dt.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Dt||n.push(this.local[r]);return n}forEachSet(e){e(this)}};z.empty=new z([],[]);z.removeOverlap=ps;var le=z.empty,zr=class t{constructor(e){this.members=e}map(e,n){let r=this.members.map(o=>o.map(e,n,It));return t.from(r)}forChild(e,n){if(n.isLeaf)return z.empty;let r=[];for(let o=0;o<this.members.length;o++){let i=this.members[o].forChild(e,n);i!=le&&(i instanceof t?r=r.concat(i.members):r.push(i))}return t.from(r)}eq(e){if(!(e instanceof t)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let o=0;o<this.members.length;o++){let i=this.members[o].localsInner(e);if(i.length)if(!n)n=i;else{r&&(n=n.slice(),r=!1);for(let s=0;s<i.length;s++)n.push(i[s])}}return n?ps(r?n:n.sort(Pt)):rn}static from(e){switch(e.length){case 0:return le;case 1:return e[0];default:return new t(e.every(n=>n instanceof z)?e:e.reduce((n,r)=>n.concat(r instanceof z?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}};function eg(t,e,n,r,o,i,s){let l=t.slice();for(let c=0,u=i;c<n.maps.length;c++){let d=0;n.maps[c].forEach((f,h,p,m)=>{let g=m-p-(h-f);for(let y=0;y<l.length;y+=3){let S=l[y+1];if(S<0||f>S+u-d)continue;let k=l[y]+u-d;h>=k?l[y+1]=f<=k?-2:-1:f>=u&&g&&(l[y]+=g,l[y+1]+=g)}d+=g}),u=n.maps[c].map(u,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let u=n.map(t[c]+i),d=u-o;if(d<0||d>=r.content.size){a=!0;continue}let f=n.map(t[c+1]+i,-1),h=f-o,{index:p,offset:m}=r.content.findIndex(d),g=r.maybeChild(p);if(g&&m==d&&m+g.nodeSize==h){let y=l[c+2].mapInner(n,g,u+1,t[c]+i+1,s);y!=le?(l[c]=d,l[c+1]=h,l[c+2]=y):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=tg(l,t,e,n,o,i,s),u=Br(c,r,0,s);e=u.local;for(let d=0;d<l.length;d+=3)l[d+1]<0&&(l.splice(d,3),d-=3);for(let d=0,f=0;d<u.children.length;d+=3){let h=u.children[d];for(;f<l.length&&l[f]<h;)f+=3;l.splice(f,0,u.children[d],u.children[d+1],u.children[d+2])}}return new z(e.sort(Pt),l)}function pu(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let o=t[r];n.push(new ee(o.from+e,o.to+e,o.type))}return n}function tg(t,e,n,r,o,i,s){function l(a,c){for(let u=0;u<a.local.length;u++){let d=a.local[u].map(r,o,c);d?n.push(d):s.onRemove&&s.onRemove(a.local[u].spec)}for(let u=0;u<a.children.length;u+=3)l(a.children[u+2],a.children[u]+c+1)}for(let a=0;a<t.length;a+=3)t[a+1]==-1&&l(t[a+2],e[a]+i+1);return n}function mu(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,o=null;for(let i=0,s;i<t.length;i++)(s=t[i])&&s.from>n&&s.to<r&&((o||(o=[])).push(s),t[i]=null);return o}function gu(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function Br(t,e,n,r){let o=[],i=!1;e.forEach((l,a)=>{let c=mu(t,l,a+n);if(c){i=!0;let u=Br(c,l,n+a+1,r);u!=le&&o.push(a,a+l.nodeSize,u)}});let s=pu(i?gu(t):t,-n).sort(Pt);for(let l=0;l<s.length;l++)s[l].type.valid(e,s[l])||(r.onRemove&&r.onRemove(s[l].spec),s.splice(l--,1));return s.length||o.length?new z(s,o):le}function Pt(t,e){return t.from-e.from||t.to-e.to}function ps(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let o=n+1;o<e.length;o++){let i=e[o];if(i.from==r.from){i.to!=r.to&&(e==t&&(e=t.slice()),e[o]=i.copy(i.from,r.to),Nc(e,o+1,i.copy(r.to,i.to)));continue}else{i.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,i.from),Nc(e,o,r.copy(i.from,r.to)));break}}}return e}function Nc(t,e,n){for(;e<t.length&&Pt(n,t[e])>0;)e++;t.splice(e,0,n)}function Bi(t){let e=[];return t.someProp(\"decorations\",n=>{let r=n(t.state);r&&r!=le&&e.push(r)}),t.cursorWrapper&&e.push(z.create(t.state.doc,[t.cursorWrapper.deco])),zr.from(e)}var ng={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},rg=be&&ut<=11,is=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}},ss=class{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new is,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let o=0;o<r.length;o++)this.queue.push(r[o]);be&&ut<=11&&r.some(o=>o.type==\"childList\"&&o.removedNodes.length||o.type==\"characterData\"&&o.oldValue.length>o.target.nodeValue.length)?this.flushSoon():ce&&e.composing&&r.some(o=>o.type==\"childList\"&&o.target.nodeName==\"TR\")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),rg&&(this.onCharData=r=>{this.queue.push({target:r.target,type:\"characterData\",oldValue:r.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,ng)),this.onCharData&&this.view.dom.addEventListener(\"DOMCharacterDataModified\",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let n=0;n<e.length;n++)this.queue.push(e[n]);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(xc(this.view)){if(this.suppressingSelectionUpdates)return Xe(this.view);if(be&&ut<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Lt(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let i=e.focusNode;i;i=on(i))n.add(i);for(let i=e.anchorNode;i;i=on(i))if(n.has(i)){r=i;break}let o=r&&this.view.docView.nearestDesc(r);if(o&&o.ignoreMutation({type:\"selection\",target:Z(r)?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),o=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&xc(e)&&!this.ignoreSelectionChange(r),i=-1,s=-1,l=!1,a=[];if(e.editable)for(let u=0;u<n.length;u++){let d=this.registerMutation(n[u],a);d&&(i=i<0?d.from:Math.min(d.from,i),s=s<0?d.to:Math.max(d.to,s),d.typeOver&&(l=!0))}if(a.some(u=>u.nodeName==\"BR\")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46||oe&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&n.some(u=>u.type==\"childList\"&&u.removedNodes.length))){for(let u of a)if(u.nodeName==\"BR\"&&u.parentNode){let d=u.nextSibling;for(;d&&N(d);){if(d.contentEditable==\"false\"){u.parentNode.removeChild(u);break}d=d.firstChild}}}else if(we&&a.length){let u=a.filter(d=>d.nodeName==\"BR\");if(u.length==2){let[d,f]=u;d.parentNode&&d.parentNode.parentNode==f.parentNode?f.remove():d.remove()}else{let{focusNode:d}=this.currentSelection;for(let f of u){let h=f.parentNode;h&&h.nodeName==\"LI\"&&(!d||sg(e,d)!=h)&&f.remove()}}}let c=null;i<0&&o&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Fr(r)&&(c=as(e))&&c.eq(E.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Xe(e),this.currentSelection.set(r),e.scrollToSelection()):(i>-1||o)&&(i>-1&&(e.docView.markDirty(i,s),og(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,lg(e,a)),this.handleDOMChange(i,s,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Xe(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type==\"attributes\"&&(r==this.view.docView||e.attributeName==\"contenteditable\"||e.attributeName==\"style\"&&!e.oldValue&&!e.target.getAttribute(\"style\"))||!r||r.ignoreMutation(e))return null;if(e.type==\"childList\"){for(let u=0;u<e.addedNodes.length;u++){let d=e.addedNodes[u];n.push(d),Z(d)&&(this.lastChangedTextNode=d)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let o=e.previousSibling,i=e.nextSibling;if(be&&ut<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:d,nextSibling:f}=e.addedNodes[u];(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(o=d),(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(i=f)}let s=o&&o.parentNode==e.target?re(o)+1:0,l=r.localPosFromDOM(e.target,s,-1),a=i&&i.parentNode==e.target?re(i):e.target.childNodes.length,c=r.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type==\"attributes\"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}},Oc=new WeakMap,Rc=!1;function og(t){if(!Oc.has(t)&&(Oc.set(t,null),[\"normal\",\"nowrap\",\"pre-line\"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=we,Rc)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.\"),Rc=!0}}function Dc(t,e){let n=e.startContainer,r=e.startOffset,o=e.endContainer,i=e.endOffset,s=t.domAtPos(t.state.selection.anchor);return Lt(s.node,s.offset,o,i)&&([n,r,o,i]=[o,i,n,r]),{anchorNode:n,anchorOffset:r,focusNode:o,focusOffset:i}}function ig(t,e){if(e.getComposedRanges){let o=e.getComposedRanges(t.root)[0];if(o)return Dc(t,o)}let n;function r(o){o.preventDefault(),o.stopImmediatePropagation(),n=o.getTargetRanges()[0]}return t.dom.addEventListener(\"beforeinput\",r,!0),document.execCommand(\"indent\"),t.dom.removeEventListener(\"beforeinput\",r,!0),n?Dc(t,n):null}function sg(t,e){for(let n=e.parentNode;n&&n!=t.dom;n=n.parentNode){let r=t.docView.nearestDesc(n,!0);if(r&&r.node.isBlock)return n}return null}function lg(t,e){var n;let{focusNode:r,focusOffset:o}=t.domSelectionRange();for(let i of e)if(((n=i.parentNode)===null||n===void 0?void 0:n.nodeName)==\"TR\"){let s=i.nextSibling;for(;s&&s.nodeName!=\"TD\"&&s.nodeName!=\"TH\";)s=s.nextSibling;if(s){let l=s;for(;;){let a=l.firstChild;if(!a||!N(a)||a.contentEditable==\"false\"||/^(BR|IMG)$/.test(a.nodeName))break;l=a}l.insertBefore(i,l.firstChild),r==i&&t.domSelection().collapse(i,o)}else i.parentNode.removeChild(i)}}function ag(t,e,n,r){let{node:o,fromOffset:i,toOffset:s,from:l,to:a}=t.docView.parseRange(e,n),c=t.domSelectionRange(),u,d=c.anchorNode;if(d&&$t(t.dom,d)&&(u=[{node:d,offset:c.anchorOffset}],Fr(c)||u.push({node:c.focusNode,offset:c.focusOffset})),oe&&t.input.lastKeyCode===8)for(let y=s;y>i;y--){let S=o.childNodes[y-1],k=S.pmViewDesc;if(S.nodeName==\"BR\"&&!k){s=y;break}if(!k||k.size)break}let f=t.state.doc,h=t.someProp(\"domParser\")||je.fromSchema(t.state.schema),p=f.resolve(l),m=null,g=h.parse(o,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:s,preserveWhitespace:p.parent.type.whitespace==\"pre\"?\"full\":!0,findPositions:u,ruleFromNode:cg(r),context:p});if(u&&u[0].pos!=null){let y=u[0].pos,S=u[1]&&u[1].pos;S==null&&(S=y),m={anchor:y+l,head:S+l}}return{doc:g,sel:m,from:l,to:a}}var cg=t=>e=>{let n=e.pmViewDesc;if(n)return n.parseRule(t);if(e.nodeName==\"BR\"&&e.parentNode){if(ce&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let r=document.createElement(\"div\");return r.appendChild(document.createElement(\"li\")),{skip:r}}else if(e.parentNode.lastChild==e||ce&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName==\"IMG\"&&e.getAttribute(\"mark-placeholder\"))return{ignore:!0};return null},ug=/^(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 dg(t,e,n,r,o){let i=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let T=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,I=as(t,T);if(I&&!t.state.selection.eq(I)){if(oe&&qe&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp(\"handleKeyDown\",W=>W(t,Tt(13,\"Enter\"))))return;let F=t.state.tr.setSelection(I);T==\"pointer\"?F.setMeta(\"pointer\",!0):T==\"key\"&&F.scrollIntoView(),i&&F.setMeta(\"composition\",i),t.dispatch(F)}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=t.state.selection,c=ag(t,e,n,o),u=t.state.doc,d=u.slice(c.from,c.to),f,h;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(f=t.state.selection.to,h=\"end\"):(f=t.state.selection.from,h=\"start\"),t.input.lastKeyCode=null;let p=mg(d.content,c.doc.content,c.from,f,h);if(p&&t.input.domChangeCount++,(sn&&t.input.lastIOSEnter>Date.now()-225||qe)&&o.some(T=>N(T)&&!ug.test(T.nodeName))&&(!p||p.endA>=p.endB)&&t.someProp(\"handleKeyDown\",T=>T(t,Tt(13,\"Enter\")))){t.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof M&&!a.empty&&a.$head.sameParent(a.$anchor)&&!t.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let T=Ic(t,t.state.doc,c.sel);if(T&&!T.eq(t.state.selection)){let I=t.state.tr.setSelection(T);i&&I.setMeta(\"composition\",i),t.dispatch(I)}}return}t.state.selection.from<t.state.selection.to&&p.start==p.endB&&t.state.selection instanceof M&&(p.start>t.state.selection.from&&p.start<=t.state.selection.from+2&&t.state.selection.from>=c.from?p.start=t.state.selection.from:p.endA<t.state.selection.to&&p.endA>=t.state.selection.to-2&&t.state.selection.to<=c.to&&(p.endB+=t.state.selection.to-p.endA,p.endA=t.state.selection.to)),be&&ut<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)==\" \\xA0\"&&(p.start--,p.endA--,p.endB--);let m=c.doc.resolveNoCache(p.start-c.from),g=c.doc.resolveNoCache(p.endB-c.from),y=u.resolve(p.start),S=m.sameParent(g)&&m.parent.inlineContent&&y.end()>=p.endA;if((sn&&t.input.lastIOSEnter>Date.now()-225&&(!S||o.some(T=>T.nodeName==\"DIV\"||T.nodeName==\"P\"))||!S&&pg(c.doc,m.pos,g.pos))&&t.someProp(\"handleKeyDown\",T=>T(t,Tt(13,\"Enter\")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>p.start&&hg(u,p.start,p.endA,m,g)&&t.someProp(\"handleKeyDown\",T=>T(t,Tt(8,\"Backspace\")))){qe&&oe&&t.domObserver.suppressSelectionUpdates();return}oe&&p.endB==p.start&&(t.input.lastChromeDelete=Date.now()),qe&&!S&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,g=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{t.someProp(\"handleKeyDown\",function(T){return T(t,Tt(13,\"Enter\"))})},20));let k=p.start,x=p.endA,O=T=>{let I=T||t.state.tr.replace(k,x,c.doc.slice(p.start-c.from,p.endB-c.from));if(c.sel){let F=Ic(t,I.doc,c.sel);F&&!(oe&&t.composing&&F.empty&&(p.start!=p.endB||t.input.lastChromeDelete<Date.now()-100)&&(F.head==k||F.head==I.mapping.map(x)-1)||be&&F.empty&&F.head==k)&&I.setSelection(F)}return i&&I.setMeta(\"composition\",i),I.scrollIntoView()},H;if(S)if(m.pos==g.pos){be&&ut<=11&&m.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>Xe(t),20));let T=O(t.state.tr.delete(k,x)),I=u.resolve(p.start).marksAcross(u.resolve(p.endA));I&&T.ensureMarks(I),t.dispatch(T)}else if(p.endA==p.endB&&(H=fg(m.parent.content.cut(m.parentOffset,g.parentOffset),y.parent.content.cut(y.parentOffset,p.endA-y.start())))){let T=O(t.state.tr);H.type==\"add\"?T.addMark(k,x,H.mark):T.removeMark(k,x,H.mark),t.dispatch(T)}else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let T=m.parent.textBetween(m.parentOffset,g.parentOffset),I=()=>O(t.state.tr.insertText(T,k,x));t.someProp(\"handleTextInput\",F=>F(t,k,x,T,I))||t.dispatch(I())}else t.dispatch(O());else t.dispatch(O())}function Ic(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:cs(t,e.resolve(n.anchor),e.resolve(n.head))}function fg(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,o=n,i=r,s,l,a;for(let u=0;u<r.length;u++)o=r[u].removeFromSet(o);for(let u=0;u<n.length;u++)i=n[u].removeFromSet(i);if(o.length==1&&i.length==0)l=o[0],s=\"add\",a=u=>u.mark(l.addToSet(u.marks));else if(o.length==0&&i.length==1)l=i[0],s=\"remove\",a=u=>u.mark(l.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<e.childCount;u++)c.push(a(e.child(u)));if(b.from(c).eq(t))return{mark:l,type:s}}function hg(t,e,n,r,o){if(n-e<=o.pos-r.pos||Fi(r,!0,!1)<o.pos)return!1;let i=t.resolve(e);if(!r.parent.isTextblock){let l=i.nodeAfter;return l!=null&&n==e+l.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let s=t.resolve(Fi(i,!0,!0));return!s.parent.isTextblock||s.pos>n||Fi(s,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(s.parent.content)}function pg(t,e,n){let r=0,o=0;return t.nodesBetween(e,n,(i,s)=>{i.isTextblock&&s>=e&&s<n?r++:(i.isText?/\\S/.test(i.text.slice(Math.max(0,e-s),Math.min(i.nodeSize,n-s))):i.isLeaf)&&o++}),o==0&&r==1}function Fi(t,e,n){let r=t.depth,o=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,o++,e=!1;if(n){let i=t.node(r).maybeChild(t.indexAfter(r));for(;i&&!i.isLeaf;)i=i.firstChild,o++}return o}function mg(t,e,n,r,o){let i=t.findDiffStart(e,n),s=n+t.size,l=n+e.size;if(i==null)return null;let{a,b:c}=t.findDiffEnd(e,s,l);if(o==\"end\"){let u=Math.max(0,i-Math.min(a,c));r-=a+u-i}if(a<i&&s<l){let u=r<=i&&r>=a?i-r:0;i-=u,c=i+(c-a),a=i}else if(c<i){let u=r<=i&&r>=c?i-r:0;i-=u,a=i+(a-c),c=i}return{start:i,endA:a,endB:c}}var _n=class{constructor(e,n){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 Zi,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(Bc),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement(\"div\"),e&&(e.appendChild?e.appendChild(this.dom):typeof e==\"function\"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=$c(this),Lc(this),this.nodeViews=zc(this),this.docView=gc(this.state.doc,Pc(this),Bi(this),this.dom,this),this.domObserver=new ss(this,(r,o,i,s)=>dg(this,r,o,i,s)),this.domObserver.start(),Lm(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&es(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Bc),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let o=this.state,i=!1,s=!1;e.storedMarks&&this.composing&&(du(this),s=!0),this.state=e;let l=o.plugins!=e.plugins||this._props.plugins!=n.plugins;if(l||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let h=zc(this);yg(h,this.nodeViews)&&(this.nodeViews=h,i=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&es(this),this.editable=$c(this),Lc(this);let a=Bi(this),c=Pc(this),u=o.plugins!=e.plugins&&!o.doc.eq(e.doc)?\"reset\":e.scrollToSelection>o.scrollToSelection?\"to selection\":\"preserve\",d=i||!this.docView.matchesNode(e.doc,c,a);(d||!e.selection.eq(o.selection))&&(s=!0);let f=u==\"preserve\"&&s&&this.dom.style.overflowAnchor==null&&Zp(this);if(s){this.domObserver.stop();let h=d&&(be||oe)&&!this.composing&&!o.selection.empty&&!e.selection.empty&&gg(o.selection,e.selection);if(d){let m=oe?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=qm(this)),(i||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=gc(e.doc,c,a,this.dom,this)),m&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(h=!0)}let p=this.input.mouseDown;h||!(p&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&wm(this)&&p.delaySelUpdate())?Xe(this,h):(Qc(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(o),!((r=this.dragging)===null||r===void 0)&&r.node&&!o.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,o),u==\"reset\"?this.dom.scrollTop=0:u==\"to selection\"?this.scrollToSelection():f&&em(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!$t(this.dom,e))){if(!this.someProp(\"handleScrollToSelection\",n=>n(this)))if(this.state.selection instanceof A){let n=this.docView.domAfterPos(this.state.selection.from);N(n)&&dc(this,n.getBoundingClientRect(),e)}else dc(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n<this.directPlugins.length;n++){let r=this.directPlugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let r=this.state.plugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let r=this.pluginViews[n];r.update&&r.update(this,e)}}updateDraggedNode(e,n){let r=e.node,o=-1;if(r.from<this.state.doc.content.size&&this.state.doc.nodeAt(r.from)==r.node)o=r.from;else{let i=r.from+(this.state.doc.content.size-n.doc.content.size);(i>0&&i<this.state.doc.content.size&&this.state.doc.nodeAt(i))==r.node&&(o=i)}this.dragging=new Lr(e.slice,e.move,o<0?void 0:A.create(this.state.doc,o))}someProp(e,n){let r=this._props&&this._props[e],o;if(r!=null&&(o=n?n(r):r))return o;for(let s=0;s<this.directPlugins.length;s++){let l=this.directPlugins[s].props[e];if(l!=null&&(o=n?n(l):l))return o}let i=this.state.plugins;if(i)for(let s=0;s<i.length;s++){let l=i[s].props[e];if(l!=null&&(o=n?n(l):l))return o}}hasFocus(){if(be){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable==\"false\")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&tm(this.dom),Xe(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let n=this.dom.parentNode;n;n=n.parentNode)if(n.nodeType==9||n.nodeType==11&&n.host)return n.getSelection||(Object.getPrototypeOf(n).getSelection=()=>n.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return sm(this,e)}coordsAtPos(e,n=1){return Uc(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let o=this.docView.posFromDOM(e,n,r);if(o==null)throw new RangeError(\"DOM position not inside the editor\");return o}endOfTextblock(e,n){return dm(this,n||this.state,e)}pasteHTML(e,n){return Wn(this,\"\",e,!1,n||new ClipboardEvent(\"paste\"))}pasteText(e,n){return Wn(this,e,null,!0,n||new ClipboardEvent(\"paste\"))}serializeForClipboard(e){return us(this,e)}destroy(){this.docView&&($m(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Bi(this),this),this.dom.textContent=\"\"):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Vp())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Bm(this,e)}domSelectionRange(){let e=this.dom.isConnected!==!1&&this.domSelection();return e?ce&&this.root.nodeType===11&&qp(this.dom.ownerDocument)==this.dom&&ig(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};_n.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function Pc(t){let e=Object.create(null);return e.class=\"ProseMirror\",e.contenteditable=String(t.editable),t.someProp(\"attributes\",n=>{if(typeof n==\"function\"&&(n=n(t.state)),n)for(let r in n)r==\"class\"?e.class+=\" \"+n[r]:r==\"style\"?e.style=(e.style?e.style+\";\":\"\")+n[r]:!e[r]&&r!=\"contenteditable\"&&r!=\"nodeName\"&&(e[r]=String(n[r]))}),e.translate||(e.translate=\"no\"),[ee.node(0,t.state.doc.content.size,e)]}function Lc(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:ee.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function $c(t){return!t.someProp(\"editable\",e=>e(t.state)===!1)}function gg(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)}function zc(t){let e=Object.create(null);function n(r){for(let o in r)Object.prototype.hasOwnProperty.call(e,o)||(e[o]=r[o])}return t.someProp(\"nodeViews\",n),t.someProp(\"markViews\",n),e}function yg(t,e){let n=0,r=0;for(let o in t){if(t[o]!=e[o])return!0;n++}for(let o in e)r++;return n!=r}function Bc(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\")}var Ye={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:\"'\"},Wr={48:\")\",49:\"!\",50:\"@\",51:\"#\",52:\"$\",53:\"%\",54:\"^\",55:\"&\",56:\"*\",57:\"(\",59:\":\",61:\"+\",173:\"_\",186:\":\",187:\"+\",188:\"<\",189:\"_\",190:\">\",191:\"?\",192:\"~\",219:\"{\",220:\"|\",221:\"}\",222:'\"'},bg=typeof navigator<\"u\"&&/Mac/.test(navigator.platform),kg=typeof navigator<\"u\"&&/MSIE \\d|Trident\\/(?:[7-9]|\\d{2,})\\..*rv:(\\d+)/.exec(navigator.userAgent);for(Y=0;Y<10;Y++)Ye[48+Y]=Ye[96+Y]=String(Y);var Y;for(Y=1;Y<=24;Y++)Ye[Y+111]=\"F\"+Y;var Y;for(Y=65;Y<=90;Y++)Ye[Y]=String.fromCharCode(Y+32),Wr[Y]=String.fromCharCode(Y);var Y;for(jr in Ye)Wr.hasOwnProperty(jr)||(Wr[jr]=Ye[jr]);var jr;function yu(t){var e=bg&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||kg&&t.shiftKey&&t.key&&t.key.length==1||t.key==\"Unidentified\",n=!e&&t.key||(t.shiftKey?Wr:Ye)[t.keyCode]||t.key||\"Unidentified\";return n==\"Esc\"&&(n=\"Escape\"),n==\"Del\"&&(n=\"Delete\"),n==\"Left\"&&(n=\"ArrowLeft\"),n==\"Up\"&&(n=\"ArrowUp\"),n==\"Right\"&&(n=\"ArrowRight\"),n==\"Down\"&&(n=\"ArrowDown\"),n}var wg=typeof navigator<\"u\"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Sg=typeof navigator<\"u\"&&/Win/.test(navigator.platform);function xg(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n==\"Space\"&&(n=\" \");let r,o,i,s;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))s=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))o=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))wg?s=!0:o=!0;else throw new Error(\"Unrecognized modifier name: \"+a)}return r&&(n=\"Alt-\"+n),o&&(n=\"Ctrl-\"+n),s&&(n=\"Meta-\"+n),i&&(n=\"Shift-\"+n),n}function Cg(t){let e=Object.create(null);for(let n in t)e[xg(n)]=t[n];return e}function ms(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 bu(t){return new R({props:{handleKeyDown:qn(t)}})}function qn(t){let e=Cg(t);return function(n,r){let o=yu(r),i,s=e[ms(o,r)];if(s&&s(n.state,n.dispatch,n))return!0;if(o.length==1&&o!=\" \"){if(r.shiftKey){let l=e[ms(o,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(Sg&&r.ctrlKey&&r.altKey)&&(i=Ye[r.keyCode])&&i!=o){let l=e[ms(i,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var Vr=200,ie=function(){};ie.prototype.append=function(e){return e.length?(e=ie.from(e),!this.length&&e||e.length<Vr&&this.leafAppend(e)||this.length<Vr&&e.leafPrepend(this)||this.appendInner(e)):this};ie.prototype.prepend=function(e){return e.length?ie.from(e).append(this):this};ie.prototype.appendInner=function(e){return new Mg(this,e)};ie.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?ie.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};ie.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};ie.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)};ie.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var o=[];return this.forEach(function(i,s){return o.push(e(i,s))},n,r),o};ie.from=function(e){return e instanceof ie?e:e&&e.length?new ku(e):ie.empty};var ku=(function(t){function e(r){t.call(this),this.values=r}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(o,i){return o==0&&i==this.length?this:new e(this.values.slice(o,i))},e.prototype.getInner=function(o){return this.values[o]},e.prototype.forEachInner=function(o,i,s,l){for(var a=i;a<s;a++)if(o(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(o,i,s,l){for(var a=i-1;a>=s;a--)if(o(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(o){if(this.length+o.length<=Vr)return new e(this.values.concat(o.flatten()))},e.prototype.leafPrepend=function(o){if(this.length+o.length<=Vr)return new e(o.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(ie);ie.empty=new ku([]);var Mg=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.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(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,o,i,s){var l=this.left.length;if(o<l&&this.left.forEachInner(r,o,Math.min(i,l),s)===!1||i>l&&this.right.forEachInner(r,Math.max(o-l,0),Math.min(this.length,i)-l,s+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,o,i,s){var l=this.left.length;if(o>l&&this.right.forEachInvertedInner(r,o-l,Math.max(i,l)-l,s+l)===!1||i<l&&this.left.forEachInvertedInner(r,Math.min(o,l),i,s)===!1)return!1},e.prototype.sliceInner=function(r,o){if(r==0&&o==this.length)return this;var i=this.left.length;return o<=i?this.left.slice(r,o):r>=i?this.right.slice(r-i,o-i):this.left.slice(r,i).append(this.right.slice(0,o-i))},e.prototype.leafAppend=function(r){var o=this.right.leafAppend(r);if(o)return new e(this.left,o)},e.prototype.leafPrepend=function(r){var o=this.left.leafPrepend(r);if(o)return new e(o,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(ie),gs=ie;var vg=500,Bt=class t{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let o,i;n&&(o=this.remapping(r,this.items.length),i=o.maps.length);let s=e.tr,l,a,c=[],u=[];return this.items.forEach((d,f)=>{if(!d.step){o||(o=this.remapping(r,f+1),i=o.maps.length),i--,u.push(d);return}if(o){u.push(new Pe(d.map));let h=d.step.map(o.slice(i)),p;h&&s.maybeStep(h).doc&&(p=s.mapping.maps[s.mapping.maps.length-1],c.push(new Pe(p,void 0,void 0,c.length+u.length))),i--,p&&o.appendMap(p,i)}else s.maybeStep(d.step);if(d.selection)return l=o?d.selection.map(o.slice(i)):d.selection,a=new t(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:s,selection:l}}addTransform(e,n,r,o){let i=[],s=this.eventCount,l=this.items,a=!o&&l.length?l.get(l.length-1):null;for(let u=0;u<e.steps.length;u++){let d=e.steps[u].invert(e.docs[u]),f=new Pe(e.mapping.maps[u],d,n),h;(h=a&&a.merge(f))&&(f=h,u?i.pop():l=l.slice(0,l.length-1)),i.push(f),n&&(s++,n=void 0),o||(a=f)}let c=s-r.depth;return c>Ag&&(l=Eg(l,c),s-=c),new t(l.append(i),s)}remapping(e,n){let r=new Dn;return this.items.forEach((o,i)=>{let s=o.mirrorOffset!=null&&i-o.mirrorOffset>=e?r.maps.length-o.mirrorOffset:void 0;r.appendMap(o.map,s)},e,n),r}addMaps(e){return this.eventCount==0?this:new t(this.items.append(e.map(n=>new Pe(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;n=Math.min(this.items.length,n);let r=[],o=this.items.length-n,i=e.mapping,s=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},o);let a=n;this.items.forEach(f=>{let h=i.getMirror(--a);if(h==null)return;s=Math.min(s,h);let p=i.maps[h];if(f.step){let m=e.steps[h].invert(e.docs[h]),g=f.selection&&f.selection.map(i.slice(a+1,h));g&&l++,r.push(new Pe(p,m,g))}else r.push(new Pe(p))},o);let c=[];for(let f=n;f<s;f++)c.push(new Pe(i.maps[f]));let u=this.items.slice(0,o).append(c).append(r),d=new t(u,l);return d.emptyItemCount()>vg&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,o=[],i=0;return this.items.forEach((s,l)=>{if(l>=e)o.push(s),s.selection&&i++;else if(s.step){let a=s.step.map(n.slice(r)),c=a&&a.getMap();if(r--,c&&n.appendMap(c,r),a){let u=s.selection&&s.selection.map(n.slice(r));u&&i++;let d=new Pe(c.invert(),a,u),f,h=o.length-1;(f=o.length&&o[h].merge(d))?o[h]=f:o.push(d)}}else s.map&&r--},this.items.length,0),new t(gs.from(o.reverse()),i)}};Bt.empty=new Bt(gs.empty,0);function Eg(t,e){let n;return t.forEach((r,o)=>{if(r.selection&&e--==0)return n=o,!1}),t.slice(n)}var Pe=class t{constructor(e,n,r,o){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=o}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new t(n.getMap().invert(),n,this.selection)}}},Le=class{constructor(e,n,r,o,i){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=o,this.prevComposition=i}},Ag=20;function Tg(t,e,n,r){let o=n.getMeta(ht),i;if(o)return o.historyState;n.getMeta(Cu)&&(t=new Le(t.done,t.undone,null,0,-1));let s=n.getMeta(\"appendedTransaction\");if(n.steps.length==0)return t;if(s&&s.getMeta(ht))return s.getMeta(ht).redo?new Le(t.done.addTransform(n,void 0,r,_r(e)),t.undone,wu(n.mapping.maps),t.prevTime,t.prevComposition):new Le(t.done,t.undone.addTransform(n,void 0,r,_r(e)),null,t.prevTime,t.prevComposition);if(n.getMeta(\"addToHistory\")!==!1&&!(s&&s.getMeta(\"addToHistory\")===!1)){let l=n.getMeta(\"composition\"),a=t.prevTime==0||!s&&t.prevComposition!=l&&(t.prevTime<(n.time||0)-r.newGroupDelay||!Ng(n,t.prevRanges)),c=s?ys(t.prevRanges,n.mapping):wu(n.mapping.maps);return new Le(t.done.addTransform(n,a?e.selection.getBookmark():void 0,r,_r(e)),Bt.empty,c,n.time,l??t.prevComposition)}else return(i=n.getMeta(\"rebased\"))?new Le(t.done.rebased(n,i),t.undone.rebased(n,i),ys(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Le(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),ys(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function Ng(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,o)=>{for(let i=0;i<e.length;i+=2)r<=e[i+1]&&o>=e[i]&&(n=!0)}),n}function wu(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,o,i,s)=>e.push(i,s));return e}function ys(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let o=e.map(t[r],1),i=e.map(t[r+1],-1);o<=i&&n.push(o,i)}return n}function Og(t,e,n){let r=_r(e),o=ht.get(e).spec.config,i=(n?t.undone:t.done).popEvent(e,r);if(!i)return null;let s=i.selection.resolve(i.transform.doc),l=(n?t.done:t.undone).addTransform(i.transform,e.selection.getBookmark(),o,r),a=new Le(n?l:i.remaining,n?i.remaining:l,null,0,-1);return i.transform.setSelection(s).setMeta(ht,{redo:n,historyState:a})}var bs=!1,Su=null;function _r(t){let e=t.plugins;if(Su!=e){bs=!1,Su=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){bs=!0;break}}return bs}function xu(t){return t.setMeta(Cu,!0)}var ht=new P(\"history\"),Cu=new P(\"closeHistory\");function Mu(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new R({key:ht,state:{init(){return new Le(Bt.empty,Bt.empty,null,0,-1)},apply(e,n,r){return Tg(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,o=r==\"historyUndo\"?ks:r==\"historyRedo\"?ws:null;return!o||!e.editable?!1:(n.preventDefault(),o(e.state,e.dispatch))}}}})}function Kr(t,e){return(n,r)=>{let o=ht.getState(n);if(!o||(t?o.undone:o.done).eventCount==0)return!1;if(r){let i=Og(o,n,t);i&&r(e?i.scrollIntoView():i)}return!0}}var ks=Kr(!1,!0),ws=Kr(!0,!0),IS=Kr(!1,!1),PS=Kr(!0,!1);function vu(t){return t.getMeta(ht)!=null}function eo(t){let{state:e,transaction:n}=t,{selection:r}=n,{doc:o}=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 r},get doc(){return o},get tr(){return r=n.selection,o=n.doc,i=n.storedMarks,n}}}var dn=class Uu{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){let{rawCommands:e,editor:n,state:r}=this,{view:o}=n,{tr:i}=r,s=this.buildProps(i);return Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...u)=>{let d=a(...u)(s);return!i.getMeta(\"preventDispatch\")&&!this.hasCustomState&&o.dispatch(i),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,n=!0){let{rawCommands:r,editor:o,state:i}=this,{view:s}=o,l=[],a=!!e,c=e||i.tr,u=()=>(!a&&n&&!c.getMeta(\"preventDispatch\")&&!this.hasCustomState&&s.dispatch(c),l.every(f=>f===!0)),d={...Object.fromEntries(Object.entries(r).map(([f,h])=>[f,(...m)=>{let g=this.buildProps(c,n),y=h(...m)(g);return l.push(y),d}])),run:u};return d}static createFakeChain(){let e=new Proxy({},{get:(n,r)=>{if(r!==\"then\")return r===\"run\"?()=>!1:()=>e}});return e}createCan(e){let{rawCommands:n,state:r}=this,o=!1,i=e||r.tr,s=this.buildProps(i,o);return{...Object.fromEntries(Object.entries(n).map(([l,a])=>[l,(...c)=>a(...c)({...s,dispatch:void 0})])),chain:()=>this.createChain(i,o)}}static createFallbackCan(){let e=Uu.createFakeChain();return new Proxy({chain:()=>e},{get:(n,r)=>{if(r!==\"then\")return r===\"chain\"?n.chain:()=>!1}})}buildProps(e,n=!0){let{rawCommands:r,editor:o,state:i}=this,{view:s}=o,l={tr:e,editor:o,view:s,state:eo({state:i,transaction:e}),dispatch:n?()=>{}:void 0,chain:()=>this.createChain(e,n),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(r).map(([a,c])=>[a,(...u)=>c(...u)(l)]))}};return l}},Rg=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{if(!t.isDestroyed){var n;e.dom.blur(),(n=window)===null||n===void 0||(n=n.getSelection())===null||n===void 0||n.removeAllRanges()}}),!0),Dg=(t=!0)=>({commands:e})=>e.setContent(\"\",{emitUpdate:t}),Ig=()=>({state:t,tr:e,dispatch:n})=>{let{selection:r}=e,{ranges:o}=r;return n&&o.forEach(({$from:i,$to:s})=>{t.doc.nodesBetween(i.pos,s.pos,(l,a)=>{if(l.type.isText)return;let{doc:c,mapping:u}=e,d=c.resolve(u.map(a)),f=c.resolve(u.map(a+l.nodeSize)),h=d.blockRange(f);if(!h)return;let p=Ke(h);if(l.type.isTextblock){let{defaultType:m}=d.parent.contentMatchAt(d.index());e.setNodeMarkup(h.start,m)}(p||p===0)&&e.lift(h,p)})}),!0},Pg=t=>e=>t(e),Lg=()=>({state:t,dispatch:e})=>Oi(t,e),$g=(t,e)=>({editor:n,tr:r})=>{let{state:o}=n,i=o.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);let s=r.mapping.map(e);return r.insert(s,i.content),r.setSelection(new M(r.doc.resolve(Math.max(s-1,0)))),!0},zg=()=>({tr:t,dispatch:e})=>{let{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;let o=t.selection.$anchor;for(let i=o.depth;i>0;i-=1)if(o.node(i).type===r.type){if(e){let s=o.before(i),l=o.after(i);t.delete(s,l).scrollIntoView()}return!0}return!1};function Q(t,e){if(typeof t==\"string\"){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 Bg=t=>({tr:e,state:n,dispatch:r})=>{let o=Q(t,n.schema),i=e.selection.$anchor;for(let s=i.depth;s>0;s-=1)if(i.node(s).type===o){if(r){let l=i.before(s),a=i.after(s);e.delete(l,a).scrollIntoView()}return!0}return!1},Fg=t=>({tr:e,dispatch:n})=>{let{from:r,to:o}=t;return n&&e.delete(r,o),!0},Hg=t=>t.content?/^text(\\*|\\+)/.test(t.content):!1,Eu=(t,e,n)=>{if(!t.parent.isInline||n===\"left\"&&t.pos>t.start()||n===\"right\"&&t.pos<t.end())return t.pos;let r=e.nodes[t.parent.type.name].spec;return Hg(r)?n===\"left\"?t.start()-1:t.end()+1:t.pos},jg=(t,e,n)=>({from:Eu(t,n,\"left\"),to:Eu(e,n,\"right\")}),Wg=()=>({state:t,dispatch:e})=>{if(t.selection.empty)return!1;if(e){let n=t.tr,{ranges:r}=t.selection,o=t.selection instanceof M?t.selection.$from.marksAcross(t.selection.$to):null,i=n.steps.length;r.forEach(s=>{let l=n.mapping.slice(i),a=n.doc.resolve(l.map(s.$from.pos)),c=n.doc.resolve(l.map(s.$to.pos)),{from:u,to:d}=jg(a,c,t.schema);n.deleteRange(u,d)}),n.selection.empty||n.setSelection(M.near(n.doc.resolve(n.selection.from))),o&&n.ensureMarks(o),n.scrollIntoView(),e(n)}return!0},Vg=()=>({commands:t})=>t.keyboardShortcut(\"Enter\"),_g=()=>({state:t,dispatch:e})=>Ni(t,e);function vs(t){return Object.prototype.toString.call(t)===\"[object RegExp]\"}function Qr(t,e,n={strict:!0}){let r=Object.keys(e);return r.length?r.every(o=>n.strict?e[o]===t[o]:vs(e[o])?e[o].test(t[o]):e[o]===t[o]):!0}function Ju(t,e,n={}){return t.find(r=>r.type===e&&Qr(Object.fromEntries(Object.keys(n).map(o=>[o,r.attrs[o]])),n))}function Au(t,e,n={}){return!!Ju(t,e,n)}function Es(t,e,n){if(!t||!e)return;let r=t.parent.childAfter(t.parentOffset);if((!r.node||!r.node.marks.some(a=>a.type===e))&&(r=t.parent.childBefore(t.parentOffset)),!r.node||!r.node.marks.some(a=>a.type===e))return;if(!n){let a=r.node.marks.find(c=>c.type===e);a&&(n=a.attrs)}if(!Ju([...r.node.marks],e,n))return;let o=r.index,i=t.start()+r.offset,s=o+1,l=i+r.node.nodeSize;for(;o>0&&Au([...t.parent.child(o-1).marks],e,n);)o-=1,i-=t.parent.child(o).nodeSize;for(;s<t.parent.childCount&&Au([...t.parent.child(s).marks],e,n);)l+=t.parent.child(s).nodeSize,s+=1;return{from:i,to:l}}function Qe(t,e){if(typeof t==\"string\"){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 Kg=(t,e)=>({tr:n,state:r,dispatch:o})=>{let i=Qe(t,r.schema),{doc:s,selection:l}=n,{$from:a,from:c,to:u}=l;if(o){let d=Es(a,i,e);if(d&&d.from<=c&&d.to>=u){let f=M.create(s,d.from,d.to);n.setSelection(f)}}return!0},Ug=t=>e=>{let n=typeof t==\"function\"?t(e):t;for(let r=0;r<n.length;r+=1)if(n[r](e))return!0;return!1};function qu(t){return t instanceof M}function Ft(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function Ss(t,e=null){if(!e)return null;let n=E.atStart(t),r=E.atEnd(t);if(e===\"start\"||e===!0)return n;if(e===\"end\")return r;let o=n.from,i=r.to;return e===\"all\"?M.create(t,Ft(0,o,i),Ft(t.content.size,o,i)):M.create(t,Ft(e,o,i),Ft(e,o,i))}function Tu(){return[\"Android\"].includes(navigator.platform)||/android/i.test(navigator.userAgent)}function Zr(){return[\"iPad Simulator\",\"iPhone Simulator\",\"iPod Simulator\",\"iPad\",\"iPhone\",\"iPod\"].includes(navigator.platform)||navigator.userAgent.includes(\"Mac\")&&\"ontouchend\"in document}function Jg(){return typeof navigator<\"u\"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var qg=(t=null,e={})=>({editor:n,view:r,tr:o,dispatch:i})=>{e={scrollIntoView:!0,...e};let s=()=>{(Zr()||Tu())&&r.dom.focus(),Jg()&&!Zr()&&!Tu()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e?.scrollIntoView&&n.commands.scrollIntoView())})};try{if(r.hasFocus()&&t===null||t===!1)return!0}catch{return!1}if(i&&t===null&&!qu(n.state.selection))return s(),!0;let l=Ss(o.doc,t)||n.state.selection,a=n.state.selection.eq(l);return i&&(a||o.setSelection(l),a&&o.storedMarks&&o.setStoredMarks(o.storedMarks),s()),!0},Gg=(t,e)=>n=>t.every((r,o)=>e(r,{...n,index:o})),Xg=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),Gu=t=>{let e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){let r=e[n];r.nodeType===3&&r.nodeValue&&/^(\\n\\s\\s|\\n)$/.test(r.nodeValue)?t.removeChild(r):r.nodeType===1&&Gu(r)}return t};function Ur(t){if(typeof window>\"u\")throw new Error(\"[tiptap error]: there is no window object available, so this function cannot be used\");let e=`<body>${t}</body>`,n=new window.DOMParser().parseFromString(e,\"text/html\").body;return Gu(n)}function Xu(t){return typeof t?.nodesBetween==\"function\"}function fn(t,e,n){if(Xu(t))return t;let r=typeof t==\"object\"&&t!==null;n={slice:!0,parseOptions:{},...n};let o=typeof t==\"string\";if(r)try{if(Array.isArray(t)&&t.length>0)return b.fromArray(t.map(s=>e.nodeFromJSON(s)));let i=e.nodeFromJSON(t);return n.errorOnInvalidContent&&i.check(),i}catch(i){if(n.errorOnInvalidContent)throw new Error(\"[tiptap error]: Invalid JSON content\",{cause:i});return console.warn(\"[tiptap warn]: Invalid content.\",\"Passed value:\",t,\"Error:\",i),fn(\"\",e,n)}if(o){if(n.errorOnInvalidContent){let s=!1,l=\"\",a=new vt({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:c=>(s=!0,l=typeof c==\"string\"?c:c.outerHTML,null)}]}})});if(n.slice?je.fromSchema(a).parseSlice(Ur(t),n.parseOptions):je.fromSchema(a).parse(Ur(t),n.parseOptions),n.errorOnInvalidContent&&s)throw new Error(\"[tiptap error]: Invalid HTML content\",{cause:new Error(`Invalid element found: ${l}`)})}let i=je.fromSchema(e);return n.slice?i.parseSlice(Ur(t),n.parseOptions).content:i.parse(Ur(t),n.parseOptions)}return fn(\"\",e,n)}function Yu(t){return!(\"type\"in t)}function Qu(t,e,n){let r=t.steps.length-1;if(r<e)return;let o=t.steps[r];if(!(o instanceof G||o instanceof X))return;let i=t.mapping.maps[r],s=0;i.forEach((l,a,c,u)=>{s===0&&(s=u)}),t.setSelection(E.near(t.doc.resolve(s),n))}var Yg=(t,e,n)=>({tr:r,dispatch:o,editor:i})=>{if(o){n={parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let l,a=g=>{i.emit(\"contentError\",{editor:i,error:g,disableCollaboration:()=>{\"collaboration\"in i.storage&&typeof i.storage.collaboration==\"object\"&&i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:\"full\",...n.parseOptions};if(!n.errorOnInvalidContent&&!i.options.enableContentCheck&&i.options.emitContentError)try{fn(e,i.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(g){a(g)}try{var s;l=fn(e,i.schema,{parseOptions:c,errorOnInvalidContent:(s=n.errorOnInvalidContent)!==null&&s!==void 0?s:i.options.enableContentCheck})}catch(g){return a(g),!1}let{from:u,to:d}=typeof t==\"number\"?{from:t,to:t}:{from:t.from,to:t.to},f=!0,h=!0,p=Yu(l)?l.content:[l];if(p.forEach(g=>{g.check(),f=f?g.isText&&g.marks.length===0:!1,h=h?g.isBlock:!1}),u===d&&h){let{parent:g}=r.doc.resolve(u);g.isTextblock&&!g.type.spec.code&&!g.childCount&&(u-=1,d+=1)}let m;if(f)Array.isArray(e)?m=e.map(g=>g.text||\"\").join(\"\"):Xu(e)?m=p.map(g=>{var y;return(y=g.text)!==null&&y!==void 0?y:\"\"}).join(\"\"):typeof e==\"object\"&&e&&e.text?m=e.text:m=e,r.insertText(m,u,d);else{m=b.from(p);let g=r.doc.resolve(u),y=g.node(),S=g.parentOffset===0,k=y.isText||y.isTextblock,x=y.content.size>0;S&&k&&x&&h&&(u=Math.max(0,u-1)),r.replaceWith(u,d,p)}n.updateSelection&&Qu(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta(\"applyInputRules\",{from:u,text:m}),n.applyPasteRules&&r.setMeta(\"applyPasteRules\",{from:u,text:m})}return!0};function Zu(t){for(let e=0;e<t.edgeCount;e+=1){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}var Qg=(t={})=>({tr:e,dispatch:n,editor:r})=>{let{pos:o,attrs:i,content:s,updateSelection:l=!0}=t,a;typeof o==\"number\"?a=e.doc.resolve(o):o?a=o:a=e.selection.$from;let c=Zu(a.parent.contentMatchAt(a.index()));if(!c)return!1;let u=Object.keys(c.spec.attrs||{}),d=i?Object.fromEntries(Object.entries(i).filter(([h])=>u.includes(h))):{},f;if(s){let h=fn(s,r.schema);f=c.createAndFill(d,h)}else f=c.createAndFill(d);return f?(n&&(e.insert(a.pos,f),l&&Qu(e,e.steps.length-1,-1)),!0):!1},Zg=()=>({state:t,dispatch:e})=>Za(t,e),ey=()=>({state:t,dispatch:e})=>ec(t,e),ty=()=>({state:t,dispatch:e})=>Si(t,e),ny=()=>({state:t,dispatch:e})=>Mi(t,e),ed=(t,e)=>{let n=t.resolve(e),r=n.nodeBefore,o=n.nodeAfter;return!r||!o?!1:!r.type.spec.isolating&&!o.type.spec.isolating},ry=()=>({state:t,dispatch:e,tr:n})=>{try{let r=Yt(t.doc,t.selection.$from.pos,-1);return r==null||!ed(t.doc,r)?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},oy=()=>({state:t,dispatch:e,tr:n})=>{try{let r=Yt(t.doc,t.selection.$from.pos,1);return r==null||!ed(t.doc,r)?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},iy=()=>({state:t,dispatch:e})=>Ar(t,e),sy=()=>({state:t,dispatch:e})=>Tr(t,e);function td(){return typeof navigator<\"u\"?/Mac/.test(navigator.platform):!1}function ly(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n===\"Space\"&&(n=\" \");let r,o,i,s;for(let l=0;l<e.length-1;l+=1){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))s=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))o=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))Zr()||td()?s=!0:o=!0;else throw new Error(`Unrecognized modifier name: ${a}`)}return r&&(n=`Alt-${n}`),o&&(n=`Ctrl-${n}`),s&&(n=`Meta-${n}`),i&&(n=`Shift-${n}`),n}var ay=t=>({editor:e,view:n,tr:r,dispatch:o})=>{let i=ly(t).split(/-(?!$)/),s=i.find(c=>![\"Alt\",\"Ctrl\",\"Meta\",\"Shift\"].includes(c)),l=new KeyboardEvent(\"keydown\",{key:s===\"Space\"?\" \":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\",c=>c(n,l))});return a?.steps.forEach(c=>{let u=c.map(r.mapping);u&&o&&r.maybeStep(u)}),!0};function $e(t,e,n={}){let{from:r,to:o,empty:i}=t.selection,s=e?Q(e,t.schema):null,l=[];t.doc.nodesBetween(r,o,(u,d)=>{if(u.isText)return;let f=Math.max(r,d),h=Math.min(o,d+u.nodeSize);l.push({node:u,from:f,to:h})});let a=o-r,c=l.filter(u=>s?s.name===u.node.type.name:!0).filter(u=>Qr(u.node.attrs,n,{strict:!1}));return i?!!c.length:c.reduce((u,d)=>u+d.to-d.from,0)>=a}var cy=(t,e={})=>({state:n,dispatch:r})=>$e(n,Q(t,n.schema),e)?tc(n,r):!1,uy=()=>({state:t,dispatch:e})=>Ri(t,e),dy=t=>({state:e,dispatch:n})=>{let r=Q(t,e.schema);return lc(r)(e,n)},fy=()=>({state:t,dispatch:e})=>Ai(t,e);function to(t,e){return e.nodes[t]?\"node\":e.marks[t]?\"mark\":null}function Nu(t,e){let n=typeof e==\"string\"?[e]:e;return Object.keys(t).reduce((r,o)=>(n.includes(o)||(r[o]=t[o]),r),{})}var hy=(t,e)=>({tr:n,state:r,dispatch:o})=>{let i=null,s=null,l=to(typeof t==\"string\"?t:t.name,r.schema);if(!l)return!1;l===\"node\"&&(i=Q(t,r.schema)),l===\"mark\"&&(s=Qe(t,r.schema));let a=!1;return n.selection.ranges.forEach(c=>{r.doc.nodesBetween(c.$from.pos,c.$to.pos,(u,d)=>{i&&i===u.type&&(a=!0,o&&n.setNodeMarkup(d,void 0,Nu(u.attrs,e))),s&&u.marks.length&&u.marks.forEach(f=>{s===f.type&&(a=!0,o&&n.addMark(d,d+u.nodeSize,s.create(Nu(f.attrs,e))))})})}),a},py=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),my=()=>({tr:t,dispatch:e})=>{if(e){let n=new pe(t.doc);t.setSelection(n)}return!0},gy=()=>({state:t,dispatch:e})=>xi(t,e),yy=()=>({state:t,dispatch:e})=>vi(t,e),by=()=>({state:t,dispatch:e})=>nc(t,e),ky=()=>({state:t,dispatch:e})=>Ii(t,e),wy=()=>({state:t,dispatch:e})=>Di(t,e);function xs(t,e,n={},r={}){return fn(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var Sy=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:o,tr:i,dispatch:s,commands:l})=>{let{doc:a}=i;if(r.preserveWhitespace!==\"full\"){let c=xs(t,o.schema,r,{errorOnInvalidContent:e??o.options.enableContentCheck});if(s){let u=Yu(c)?c.content:[c];i.replaceWith(0,a.content.size,u).setMeta(\"preventUpdate\",!n)}return!0}return s&&i.setMeta(\"preventUpdate\",!n),l.insertContentAt({from:0,to:a.content.size},t,{parseOptions:r,errorOnInvalidContent:e??o.options.enableContentCheck})};function nd(t,e){let n=Qe(e,t.schema),{from:r,to:o,empty:i}=t.selection,s=[];i?(t.storedMarks&&s.push(...t.storedMarks),s.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,o,a=>{s.push(...a.marks)});let l=s.find(a=>a.type.name===n.name);return l?{...l.attrs}:{}}function As(t,e){let n=new st(t);return e.forEach(r=>{r.steps.forEach(o=>{n.step(o)})}),n}function rd(t,e,n){let r=[];return t.nodesBetween(e.from,e.to,(o,i)=>{n(o)&&r.push({node:o,pos:i})}),r}function pn(t,e){for(let n=t.depth;n>0;n-=1){let r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}function no(t){return e=>pn(e.$from,t)}function v(t,e,n){return t.config[e]===void 0&&t.parent?v(t.parent,e,n):typeof t.config[e]==\"function\"?t.config[e].bind({...n,parent:t.parent?v(t.parent,e,n):null}):t.config[e]}function Ts(t){return t.map(e=>{let n=v(e,\"addExtensions\",{name:e.name,options:e.options,storage:e.storage});return n?[e,...Ts(n())]:e}).flat(10)}function Ns(t,e){let n=We.fromSchema(e).serializeFragment(t),r=document.implementation.createHTMLDocument().createElement(\"div\");return r.appendChild(n),r.innerHTML}function od(t,e){let n=new Map;for(let o of t){var r;let i=(r=n.get(o.type))!==null&&r!==void 0?r:new Map;i.set(o.name,o),n.set(o.type,i)}return[...Object.values(e.nodes),...Object.values(e.marks)].flatMap(o=>{var i;return Object.entries((i=o.spec.attrs)!==null&&i!==void 0?i:{}).map(([s,l])=>{var a;let c=(a=n.get(o.name))===null||a===void 0?void 0:a.get(s),u=Object.hasOwn(l,\"default\");return{type:o.name,name:s,attribute:{rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,...c?.attribute,default:l.default,isRequired:!u,validate:l.validate}}})})}var xy={content:\"string\",marks:\"string\",group:\"string\",inline:\"boolean\",atom:\"boolean\",selectable:\"boolean\",draggable:\"boolean\",code:\"boolean\",whitespace:[\"pre\",\"normal\"],definingAsContext:\"boolean\",definingForContent:\"boolean\",defining:\"boolean\",isolating:\"boolean\",linebreakReplacement:\"boolean\"},Cy={inclusive:\"boolean\",excludes:\"string\",group:\"string\",spanning:\"boolean\",code:\"boolean\"};function My(t,e,n){return Object.fromEntries(Object.entries(e).flatMap(([r,o])=>{let i=t[r];if(i===void 0)return[];if(!(typeof o==\"string\"?typeof i===o:typeof i==\"string\"&&o.includes(i)))throw new RangeError(`Invalid schemaSpec field '${n}.${r}'`);return[[r,i]]}))}function Ou(t,e,n,r){return{...Object.fromEntries(Object.entries(e).filter(([o])=>o!==\"attrs\"&&!Object.hasOwn(r,o))),...My(n,r,t),attrs:n.attrs}}function Ru(t,e,n){for(let r of Object.keys(e))if(!Object.hasOwn(t,r))throw new RangeError(`schemaSpec requires a local ${n} extension named '${r}'`);for(let r of Object.keys(t))if(!Object.hasOwn(e,r))throw new RangeError(`Local ${n} extension '${r}' is not in schemaSpec`)}function vy(t,e){Ru(t.nodes,e.nodes,\"node\"),Ru(t.marks,e.marks,\"mark\");let n=e.spec.nodes,r=e.spec.marks;return e.spec.nodes.forEach((o,i)=>{n=n.update(o,Ou(o,t.nodes[o],i,xy))}),e.spec.marks.forEach((o,i)=>{r=r.update(o,Ou(o,t.marks[o],i,Cy))}),{topNode:e.topNodeType.name,nodes:n,marks:r}}function id(t){let e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function hn(t){return{baseExtensions:t.filter(e=>e.type===\"extension\"),nodeExtensions:t.filter(e=>e.type===\"node\"),markExtensions:t.filter(e=>e.type===\"mark\")}}function Os(t){let e=[],{nodeExtensions:n,markExtensions:r}=hn(t),o=[...n,...r],i={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},s=n.filter(c=>c.name!==\"text\").map(c=>c.name),l=r.map(c=>c.name),a=[...s,...l];return t.forEach(c=>{let u=v(c,\"addGlobalAttributes\",{name:c.name,options:c.options,storage:c.storage,extensions:o});u&&u().forEach(d=>{let f;Array.isArray(d.types)?f=d.types:d.types===\"*\"?f=a:d.types===\"nodes\"?f=s:d.types===\"marks\"?f=l:f=[],f.forEach(h=>{Object.entries(d.attributes).forEach(([p,m])=>{e.push({type:h,name:p,attribute:{...i,...m}})})})})}),o.forEach(c=>{let u=v(c,\"addAttributes\",{name:c.name,options:c.options,storage:c.storage});if(!u)return;let d=u();Object.entries(d).forEach(([f,h])=>{let p={...i,...h};typeof p?.default==\"function\"&&(p.default=p.default()),p?.isRequired&&p?.default===void 0&&delete p.default,e.push({type:c.name,name:f,attribute:p})})}),e}function Cs(t){return typeof t==\"function\"}function L(t,e=void 0,...n){return Cs(t)?e?t.bind(e)(...n):t(...n):t}function Ey(t={}){return Object.keys(t).length===0&&t.constructor===Object}function Ay(t){let e=[],n=\"\",r=!1,o=!1,i=0,s=t.length;for(let l=0;l<s;l+=1){let a=t[l];if(a===\"'\"&&!o){r=!r,n+=a;continue}if(a==='\"'&&!r){o=!o,n+=a;continue}if(!r&&!o){if(a===\"(\"){i+=1,n+=a;continue}if(a===\")\"&&i>0){i-=1,n+=a;continue}if(a===\";\"&&i===0){e.push(n),n=\"\";continue}}n+=a}return n&&e.push(n),e}function Du(t){let e=[],n=Ay(t||\"\"),r=n.length;for(let o=0;o<r;o+=1){let i=n[o],s=i.indexOf(\":\");if(s===-1)continue;let l=i.slice(0,s).trim(),a=i.slice(s+1).trim();l&&a&&e.push([l,a])}return e}function B(...t){return t.filter(e=>!!e).reduce((e,n)=>{let r={...e};return Object.entries(n).forEach(([o,i])=>{if(o===\"__proto__\"){Object.defineProperty(r,o,{configurable:!0,enumerable:!0,value:i,writable:!0});return}if(!r[o]){r[o]=i;return}if(o===\"class\"){let s=i?String(i).split(\" \"):[],l=r[o]?r[o].split(\" \"):[],a=s.filter(c=>!l.includes(c));r[o]=[...l,...a].join(\" \")}else if(o===\"style\"){let s=new Map([...Du(r[o]),...Du(i)]);r[o]=Array.from(s.entries()).map(([l,a])=>`${l}: ${a}`).join(\"; \")}else r[o]=i}),r},{})}function pt(t,e){return e.filter(n=>n.type===t.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(t.attrs)||{}:{[n.name]:t.attrs[n.name]}).reduce((n,r)=>B(n,r),{})}function Ty(t){return typeof t!=\"string\"?t:t.match(/^[+-]?(?:\\d*\\.)?\\d+$/)?Number(t):t===\"true\"?!0:t===\"false\"?!1:t}function Iu(t,e){return\"style\"in t?t:{...t,getAttrs:n=>{let r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;let o=e.reduce((i,s)=>{let l=s.attribute.parseHTML?s.attribute.parseHTML(n):Ty(n.getAttribute(s.name));return l==null?i:{...i,[s.name]:l}},{});return{...r,...o}}}}function Pu(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e===\"attrs\"&&Ey(n)?!1:n!=null))}function Lu(t){var e,n;let r={};return!(!(t==null||(e=t.attribute)===null||e===void 0)&&e.isRequired)&&\"default\"in(t?.attribute||{})&&(r.default=t.attribute.default),(t==null||(n=t.attribute)===null||n===void 0?void 0:n.validate)!==void 0&&(r.validate=t.attribute.validate),[t.name,r]}function $u(t,e,n=Os(t)){var r;let{nodeExtensions:o,markExtensions:i}=hn(t);return{topNode:(r=o.find(s=>v(s,\"topNode\")))===null||r===void 0?void 0:r.name,nodes:Object.fromEntries(o.map(s=>{let l=n.filter(h=>h.type===s.name),a={name:s.name,options:s.options,storage:s.storage,editor:e},c=Pu({...t.reduce((h,p)=>{let m=v(p,\"extendNodeSchema\",a);return{...h,...m?m(s):{}}},{}),content:L(v(s,\"content\",a)),marks:L(v(s,\"marks\",a)),group:L(v(s,\"group\",a)),inline:L(v(s,\"inline\",a)),atom:L(v(s,\"atom\",a)),selectable:L(v(s,\"selectable\",a)),draggable:L(v(s,\"draggable\",a)),code:L(v(s,\"code\",a)),whitespace:L(v(s,\"whitespace\",a)),linebreakReplacement:L(v(s,\"linebreakReplacement\",a)),defining:L(v(s,\"defining\",a)),isolating:L(v(s,\"isolating\",a)),attrs:Object.fromEntries(l.map(Lu))}),u=L(v(s,\"parseHTML\",a));u&&(c.parseDOM=u.map(h=>Iu(h,l)));let d=v(s,\"renderHTML\",a);d&&(c.toDOM=h=>d({node:h,HTMLAttributes:pt(h,l)}));let f=v(s,\"renderText\",a);return f&&(c.toText=f),[s.name,c]})),marks:Object.fromEntries(i.map(s=>{let l=n.filter(f=>f.type===s.name),a={name:s.name,options:s.options,storage:s.storage,editor:e},c=Pu({...t.reduce((f,h)=>{let p=v(h,\"extendMarkSchema\",a);return{...f,...p?p(s):{}}},{}),inclusive:L(v(s,\"inclusive\",a)),excludes:L(v(s,\"excludes\",a)),group:L(v(s,\"group\",a)),spanning:L(v(s,\"spanning\",a)),code:L(v(s,\"code\",a)),attrs:Object.fromEntries(l.map(Lu))}),u=L(v(s,\"parseHTML\",a));u&&(c.parseDOM=u.map(f=>Iu(f,l)));let d=v(s,\"renderHTML\",a);return d&&(c.toDOM=f=>d({mark:f,HTMLAttributes:pt(f,l)})),[s.name,c]}))}}function Ny(t,e,n){if(n===void 0)return new vt($u(t,e));let r=id(t.filter(s=>s.type!==\"extension\").map(s=>s.name));if(r.length)throw new RangeError(`Duplicate local schema types: ${r.join(\", \")}`);let o=new vt(n),i=$u(t,e,od(Os(t),o));return new vt(vy(i,o))}function Yn(t){return t.sort((n,r)=>{let o=v(n,\"priority\")||100,i=v(r,\"priority\")||100;return o>i?-1:o<i?1:0})}function sd(t){let e=Yn(Ts(t)),n=id(e.map(r=>r.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(r=>`'${r}'`).join(\", \")}]. This can lead to issues.`),e}function ld(t,e,n){let{from:r,to:o}=e,{blockSeparator:i=`\n\n`,textSerializers:s={}}=n||{},l=\"\";return t.nodesBetween(r,o,(a,c,u,d)=>{a.isBlock&&c>r&&(l+=i);let f=s?.[a.type.name];if(f)return u&&(l+=f({node:a,pos:c,parent:u,index:d,range:e})),!1;if(a.isText){var h;l+=a==null||(h=a.text)===null||h===void 0?void 0:h.slice(Math.max(r,c)-c,o-c)}}),l}function Oy(t,e){return ld(t,{from:0,to:t.content.size},e)}function ad(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function Ry(t,e){let n=Q(e,t.schema),{from:r,to:o}=t.selection,i=[];t.doc.nodesBetween(r,o,l=>{i.push(l)});let s=i.reverse().find(l=>l.type.name===n.name);return s?{...s.attrs}:{}}function Rs(t,e){let n=to(typeof e==\"string\"?e:e.name,t.schema);return n===\"node\"?Ry(t,e):n===\"mark\"?nd(t,e):{}}function Dy(t,e=JSON.stringify){let n={};return t.filter(r=>{let o=e(r);return Object.prototype.hasOwnProperty.call(n,o)?!1:n[o]=!0})}function Iy(t){let e=Dy(t);return e.length===1?e:e.filter((n,r)=>!e.filter((o,i)=>i!==r).some(o=>n.oldRange.from>=o.oldRange.from&&n.oldRange.to<=o.oldRange.to&&n.newRange.from>=o.newRange.from&&n.newRange.to<=o.newRange.to))}function mn(t){let{mapping:e,steps:n}=t,r=[],o=e.invert();return e.maps.forEach((i,s)=>{let l=[];if(i.ranges.length)i.forEach((c,u)=>{l.push({from:c,to:u})});else{let{from:c,to:u}=n[s];if(c===void 0||u===void 0)return;l.push({from:c,to:u})}let a=e.slice(s);l.forEach(({from:c,to:u})=>{let d=a.map(c,-1),f=a.map(u),h=o.map(d,-1),p=o.map(f);r.push({oldRange:{from:h,to:p},newRange:{from:d,to:f}})})}),Iy(r)}function Qn(t,e,n){let r=[];return t===e?n.resolve(t).marks().forEach(o=>{let i=Es(n.resolve(t),o.type);i&&r.push({mark:o,...i})}):n.nodesBetween(t,e,(o,i)=>{!o||o?.nodeSize===void 0||r.push(...o.marks.map(s=>({from:i,to:i+o.nodeSize,mark:s})))}),r}var cd=(t,e,n,r=20)=>{let o=t.doc.resolve(n),i=r,s=null;for(;i>0&&s===null;){let l=o.node(i);l?.type.name===e?s=l:i-=1}return[s,i]},ud=t=>{let e=t.depth-1;if(e<0)return null;let n=t.index(e);return n===0?null:t.node(e).child(n-1)};function ln(t,e){return e.nodes[t]||e.marks[t]||null}function Yr(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{let o=t.find(i=>i.type===e&&i.name===r);return o?o.attribute.keepOnSplit:!1}))}var Py=(t,e=500)=>{let n=\"\",r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(o,i,s,l)=>{var a,c;let u=((a=(c=o.type.spec).toText)===null||a===void 0?void 0:a.call(c,{node:o,pos:i,parent:s,index:l}))||o.textContent||\"%leaf%\";n+=o.isAtom&&!o.isText?u:u.slice(0,Math.max(0,r-i))}),n};function Ms(t,e,n={}){let{empty:r,ranges:o}=t.selection,i=e?Qe(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(u=>i?i.name===u.type.name:!0).find(u=>Qr(u.attrs,n,{strict:!1}));let s=0,l=[];if(o.forEach(({$from:u,$to:d})=>{let f=u.pos,h=d.pos;t.doc.nodesBetween(f,h,(p,m)=>{if(i&&p.inlineContent&&!p.type.allowsMarkType(i))return!1;if(!p.isText&&!p.marks.length)return;let g=Math.max(f,m),y=Math.min(h,m+p.nodeSize),S=y-g;s+=S,l.push(...p.marks.map(k=>({mark:k,from:g,to:y})))})}),s===0)return!1;let a=l.filter(u=>i?i.name===u.mark.type.name:!0).filter(u=>Qr(u.mark.attrs,n,{strict:!1})).reduce((u,d)=>u+d.to-d.from,0),c=l.filter(u=>i?u.mark.type!==i&&u.mark.type.excludes(i):!0).reduce((u,d)=>u+d.to-d.from,0);return(a>0?a+c:a)>=s}function Ly(t,e,n={}){if(!e)return $e(t,null,n)||Ms(t,null,n);let r=to(e,t.schema);return r===\"node\"?$e(t,e,n):r===\"mark\"?Ms(t,e,n):!1}var dd=(t,e)=>{let{$from:n,$to:r,$anchor:o}=t.selection;if(e){let i=no(l=>l.type.name===e)(t.selection);if(!i)return!1;let s=t.doc.resolve(i.pos+1);return o.pos+1===s.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},fd=t=>{let{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function zu(t,e){return Array.isArray(e)?e.some(n=>(typeof n==\"string\"?n:n.name)===t.name):e}function Gn(t,e){let{nodeExtensions:n}=hn(e),r=n.find(i=>i.name===t);if(!r)return!1;let o=L(v(r,\"group\",{name:r.name,options:r.options,storage:r.storage}));return typeof o!=\"string\"?!1:o.split(\" \").includes(\"list\")}function gn(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){if(n){if(t.type.name===\"hardBreak\")return!0;if(t.isText){var r;return!/\\S/.test((r=t.text)!==null&&r!==void 0?r:\"\")}}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let o=!0;return t.content.forEach(i=>{o!==!1&&(gn(i,{ignoreWhitespace:n,checkChildren:e})||(o=!1))}),o}return!1}function hd(t){return t instanceof A}function $y(t){if(t===null||typeof t!=\"object\")return!1;let e=t;return!(typeof e.apply!=\"function\"||typeof e.getMap!=\"function\"||typeof e.invert!=\"function\"||typeof e.map!=\"function\"||typeof e.merge!=\"function\"||typeof e.toJSON!=\"function\")}function zy(t){if(t===null||typeof t!=\"object\")return!1;let e=t;if(!$y(e))return!1;let n=e.toJSON();return!(n===null||typeof n!=\"object\"||n.stepType!==\"replace\")}var pd=class md{constructor(e){this.position=e}static fromJSON(e){return new md(e.position)}toJSON(){return{position:this.position}}};function By(t,e){let n=e.mapping.mapResult(t.position);return{position:new pd(n.pos),mapResult:n}}function Fy(t){return new pd(t)}function Hy(t,e,n){let{selection:r}=e,o=null;if(qu(r)&&(o=r.$cursor),o){var i;let l=(i=t.storedMarks)!==null&&i!==void 0?i:o.marks();return o.parent.type.allowsMarkType(n)&&(!!n.isInSet(l)||!l.some(a=>a.type.excludes(n)))}let{ranges:s}=r;return s.some(({$from:l,$to:a})=>{let c=l.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(l.pos,a.pos,(u,d,f)=>{if(c)return!1;if(u.isInline){let h=!f||f.type.allowsMarkType(n),p=!!n.isInSet(u.marks)||!u.marks.some(m=>m.type.excludes(n));c=h&&p}return!c}),c})}var jy=(t,e={})=>({tr:n,state:r,dispatch:o})=>{let{selection:i}=n,{empty:s,ranges:l}=i,a=Qe(t,r.schema);if(o)if(s){let c=nd(r,a);n.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{let u=c.$from.pos,d=c.$to.pos;r.doc.nodesBetween(u,d,(f,h)=>{let p=Math.max(h,u),m=Math.min(h+f.nodeSize,d);f.marks.find(g=>g.type===a)?f.marks.forEach(g=>{a===g.type&&n.addMark(p,m,a.create({...g.attrs,...e}))}):n.addMark(p,m,a.create(e))})});return Hy(r,n,a)},Wy=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),Vy=(t,e={})=>({state:n,dispatch:r,chain:o})=>{let i=Q(t,n.schema),s;return n.selection.$anchor.sameParent(n.selection.$head)&&(s=n.selection.$anchor.parent.attrs),i.isTextblock?o().command(({commands:l})=>Pi(i,{...s,...e})(n)?!0:l.clearNodes()).command(({state:l})=>Pi(i,{...s,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently \"setNode()\" only supports text block nodes.'),!1)},_y=t=>({tr:e,dispatch:n})=>{if(n){let{doc:r}=e,o=Ft(t,0,r.content.size),i=A.create(r,o);e.setSelection(i)}return!0},Ky=(t,e)=>({tr:n,state:r,dispatch:o})=>{let{selection:i}=r,s,l;return typeof e==\"number\"?(s=e,l=e):e&&\"from\"in e&&\"to\"in e?(s=e.from,l=e.to):(s=i.from,l=i.to),o&&n.doc.nodesBetween(s,l,(a,c)=>{a.isText||n.setNodeMarkup(c,void 0,{...a.attrs,dir:t})}),!0},Uy=t=>({tr:e,dispatch:n})=>{if(n){let{doc:r}=e,{from:o,to:i}=typeof t==\"number\"?{from:t,to:t}:t,s=M.atStart(r).from,l=M.atEnd(r).to,a=Ft(o,s,l),c=Ft(i,s,l),u=M.create(r,a,c);e.setSelection(u)}return!0},Jy=t=>({state:e,dispatch:n})=>{let r=Q(t,e.schema);return ac(r)(e,n)};function Bu(t,e){let n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){let r=n.filter(o=>e?.includes(o.type.name));t.tr.ensureMarks(r)}}var qy=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:o})=>{let{selection:i,doc:s}=e,{$from:l,$to:a}=i,c=o.extensionManager.attributes,u=Yr(c,l.node().type.name,l.node().attrs);if(i instanceof A&&i.node.isBlock)return!l.parentOffset||!Ce(s,l.pos)?!1:(r&&(t&&Bu(n,o.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;let d=a.parentOffset===a.parent.content.size,f=l.depth===0?void 0:Zu(l.node(-1).contentMatchAt(l.indexAfter(-1))),h=d&&f?[{type:f,attrs:u}]:void 0,p=i instanceof M&&!i.empty?At.create({doc:e.doc,selection:i}).tr.deleteSelection():null,m=p?p.doc:e.doc,g=p?p.mapping.map(l.pos):l.pos,y=Ce(m,g,1,h);if(!h&&!y&&Ce(m,g,1,f?[{type:f}]:void 0)&&(y=!0,h=f?[{type:f,attrs:u}]:void 0),r){if(y){let S=e.steps.length;if(i instanceof M&&e.deleteSelection(),e.split(e.mapping.slice(S).map(l.pos),1,h),f&&!d&&!l.parentOffset&&l.parent.type!==f){let k=e.mapping.slice(S).map(l.before()),x=e.doc.resolve(k);l.node(-1).canReplaceWith(x.index(),x.index()+1,f)&&e.setNodeMarkup(e.mapping.slice(S).map(l.before()),f)}}t&&Bu(n,o.extensionManager.splittableMarks),e.scrollIntoView()}return y},Gy=(t,e={})=>({tr:n,state:r,dispatch:o,editor:i})=>{let s=Q(t,r.schema),{$from:l,$to:a}=r.selection,c=r.selection.node;if(c&&c.isBlock||l.depth<2||!l.sameParent(a))return!1;let u=l.node(-1);if(u.type!==s)return!1;let d=i.extensionManager.attributes;if(l.parent.content.size===0&&l.node(-1).childCount===l.indexAfter(-1)){if(l.depth===2||l.node(-3).type!==s||l.index(-2)!==l.node(-2).childCount-1)return!1;if(o){var f;let x=b.empty,O=l.index(-1)?1:l.index(-2)?2:3;for(let xe=l.depth-O;xe>=l.depth-3;xe-=1)x=b.from(l.node(xe).copy(x));let H=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,T={...Yr(d,l.node().type.name,l.node().attrs),...e},I=((f=s.contentMatch.defaultType)===null||f===void 0?void 0:f.createAndFill(T))||void 0;x=x.append(b.from(s.createAndFill(null,I)||void 0));let F=l.before(l.depth-(O-1));n.replace(F,l.after(-H),new C(x,4-O,0));let W=-1;n.doc.nodesBetween(F,n.doc.content.size,(xe,kt)=>{if(W>-1)return!1;xe.isTextblock&&xe.content.size===0&&(W=kt+1)}),W>-1&&n.setSelection(M.near(n.doc.resolve(W))),n.scrollIntoView()}return!0}let h=a.pos===l.end()?u.contentMatchAt(0).defaultType:null,p={...Yr(d,u.type.name,u.attrs),...e},m={...Yr(d,l.node().type.name,l.node().attrs),...e},g=l.parentOffset===0&&l.index(-1)===0,y=l.before(-1);n.delete(l.pos,a.pos);let S=g?u.attrs:p,k=h?[{type:s,attrs:S},{type:h,attrs:m}]:[{type:s,attrs:S}];if(!Ce(n.doc,l.pos,2))return!1;if(o){let{selection:x,storedMarks:O}=r,{splittableMarks:H}=i.extensionManager,T=O||x.$to.parentOffset&&x.$from.marks();if(n.split(l.pos,2,k).scrollIntoView(),g&&n.setNodeMarkup(y,void 0,p),!T||!o)return!0;let I=T.filter(F=>H.includes(F.type.name));n.ensureMarks(I)}return!0};function gd(t,e,n){if(!t.validContent(e))return null;try{return t.create(n,e)}catch{return null}}function Ds(t,e){if(t.pendingContent.length===0)return!0;let n=gd(e,b.from(t.pendingContent));return n?(t.items.push(n),t.pendingContent=[],!0):!1}function Xy(t,e,n){return n.validContent(b.from([...e.pendingContent,t]))?(e.pendingContent.push(t),!0):!Ds(e,n)||!n.validContent(b.from(t))?!1:(e.pendingContent.push(t),!0)}function Yy(t,e,n,r){let o=r(t,n);if(!o)return!1;let i=gd(n.listType,b.from(o),t.attrs);return i?n.itemType.validContent(b.from([...e.pendingContent,i]))?(e.pendingContent.push(i),!0):Ds(e,n.itemType)?(e.items.push(...o),!0):!1:!1}function Qy(t,e,n){let r={items:[],pendingContent:[]};for(let o=0;o<t.childCount;o+=1){let i=t.child(o);if(!(e.isListNode(i)?Yy(i,r,e,n):Xy(i,r,e.itemType)))return null}return Ds(r,e.itemType)?r.items:null}function yd(t,e){let n=[];for(let r=0;r<t.childCount;r+=1){let o=Qy(t.child(r),e,yd);if(!o)return null;n.push(...o)}return n}function Fu(t,e){let n=null;return t.descendants((r,o)=>r!==e?!0:(n=o,!1)),n}function Hu(t){return!t||t===\"1\"?null:t}function bd(t,e){return Hu(t)===Hu(e)}var Jr=(t,e)=>{let n=no(i=>i.type===e)(t.selection);if(!n)return!0;let r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;let o=t.doc.nodeAt(r);return!(n.node.type===o?.type&&Ne(t.doc,n.pos))||!bd(n.node.attrs.type,o?.attrs.type)||t.join(n.pos),!0},qr=(t,e)=>{let n=no(i=>i.type===e)(t.selection);if(!n)return!0;let r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;let o=t.doc.nodeAt(r);return!(n.node.type===o?.type&&Ne(t.doc,r))||!bd(n.node.attrs.type,o?.attrs.type)||t.join(r),!0};function Zy(t){let e=t.doc,n=e.firstChild;if(!n)return null;let r=e.resolve(1),o=e.resolve(n.nodeSize-1);return M.between(r,o)}var e0=(t,e,n,r={})=>({editor:o,tr:i,state:s,dispatch:l,chain:a,commands:c,can:u})=>{let{extensions:d,splittableMarks:f}=o.extensionManager,h=Q(t,s.schema),p=Q(e,s.schema),{selection:m,storedMarks:g}=s,{$from:y,$to:S}=m,k=y.blockRange(S),x=g||m.$to.parentOffset&&m.$from.marks();if(!k)return!1;let O=no(fe=>Gn(fe.type.name,d))(m),H=m.from===0&&m.to===s.doc.content.size,T=s.doc.content.content,I=T.length===1?T[0]:null,F=H&&I&&Gn(I.type.name,d)?{node:I,pos:0,depth:0}:null,W=O??F,xe=!!O&&k.depth>=1&&k.depth-O.depth<=1,kt=!!F;if((xe||kt)&&W){if(W.node.type===h)return H&&kt?a().command(({tr:fe,dispatch:ye})=>{let he=Zy(fe);return he?(fe.setSelection(he),ye&&ye(fe),!0):!1}).liftListItem(p).run():c.liftListItem(p);if(Gn(W.node.type.name,d)&&h.validContent(W.node.content))return a().command(()=>(i.setNodeMarkup(W.pos,h),!0)).command(()=>Jr(i,h)).command(()=>qr(i,h)).run();if(Gn(W.node.type.name,d)){var wt;let fe=(wt=W.node.firstChild)===null||wt===void 0?void 0:wt.type;if(fe&&fe!==p){let ye=yd(W.node,{listType:h,itemType:p,isListNode:dr=>Gn(dr.type.name,d)}),he=ye?b.from(ye):null;return!he||!h.validContent(he)?!1:a().command(()=>{let{$anchor:dr,$head:_l}=i.selection,Kl=dr.parent,Ul=_l.parent,jh=dr.parentOffset,Wh=_l.parentOffset,fr;try{fr=h.create(r,he)}catch{return!1}if(i.replaceWith(W.pos,W.pos+W.node.nodeSize,fr),Kl.inlineContent&&Ul.inlineContent){let Jl=Fu(fr,Kl),ql=Fu(fr,Ul);if(Jl!==null&&ql!==null){let Vh=W.pos+Jl+2+jh,_h=W.pos+ql+2+Wh;i.setSelection(M.create(i.doc,Vh,_h))}}return!0}).command(()=>Jr(i,h)).command(()=>qr(i,h)).run()}}}return!n||!x||!l?a().command(()=>u().wrapInList(h,r)?!0:c.clearNodes()).wrapInList(h,r).command(()=>Jr(i,h)).command(()=>qr(i,h)).run():a().command(()=>{let fe=u().wrapInList(h,r),ye=x.filter(he=>f.includes(he.type.name));return i.ensureMarks(ye),fe?!0:c.clearNodes()}).wrapInList(h,r).command(()=>Jr(i,h)).command(()=>qr(i,h)).run()},t0=(t,e={},n={})=>({state:r,commands:o})=>{let{extendEmptyMarkRange:i=!1}=n,s=Qe(t,r.schema);return Ms(r,s,e)?o.unsetMark(s,{extendEmptyMarkRange:i}):o.setMark(s,e)},n0=(t,e,n={})=>({state:r,commands:o})=>{let i=Q(t,r.schema),s=Q(e,r.schema),l=$e(r,i,n),a;return r.selection.$anchor.sameParent(r.selection.$head)&&(a=r.selection.$anchor.parent.attrs),l?o.setNode(s,a):o.setNode(i,{...a,...n})},r0=(t,e={})=>({state:n,commands:r})=>{let o=Q(t,n.schema);return $e(n,o,e)?r.lift(o):r.wrapIn(o,e)},o0=()=>({state:t,dispatch:e})=>{let n=t.plugins;for(let r=0;r<n.length;r+=1){let o=n[r],i;if(o.spec.isInputRules&&(i=o.getState(t))){if(e){let s=t.tr,l=i.transform;for(let a=l.steps.length-1;a>=0;a-=1)s.step(l.steps[a].invert(l.docs[a]));if(i.text){let a=s.doc.resolve(i.from).marks();s.replaceWith(i.from,i.to,t.schema.text(i.text,a))}else s.delete(i.from,i.to)}return!0}}return!1},i0=(t={})=>({tr:e,dispatch:n,editor:r})=>{let{ignoreClearable:o=!1}=t,{selection:i}=e,{empty:s,ranges:l}=i;if(s)return!0;let{nonClearableMarks:a}=r.extensionManager;if(n){let c=Object.values(r.schema.marks).filter(u=>o||!a.includes(u.name));l.forEach(u=>{for(let d of c)e.removeMark(u.$from.pos,u.$to.pos,d)})}return!0},s0=(t,e={})=>({tr:n,state:r,dispatch:o})=>{let{extendEmptyMarkRange:i=!1}=e,{selection:s}=n,l=Qe(t,r.schema),{$from:a,empty:c,ranges:u}=s;if(!o)return!0;if(c&&i){var d;let{from:f,to:h}=s,p=Es(a,l,(d=a.marks().find(m=>m.type===l))===null||d===void 0?void 0:d.attrs);p&&(f=p.from,h=p.to),n.removeMark(f,h,l)}else u.forEach(f=>{n.removeMark(f.$from.pos,f.$to.pos,l)});return n.removeStoredMark(l),!0},l0=t=>({tr:e,state:n,dispatch:r})=>{let{selection:o}=n,i,s;return typeof t==\"number\"?(i=t,s=t):t&&\"from\"in t&&\"to\"in t?(i=t.from,s=t.to):(i=o.from,s=o.to),r&&e.doc.nodesBetween(i,s,(l,a)=>{if(l.isText)return;let c={...l.attrs};delete c.dir,e.setNodeMarkup(a,void 0,c)}),!0},a0=(t,e={})=>({tr:n,state:r,dispatch:o})=>{let i=null,s=null,l=to(typeof t==\"string\"?t:t.name,r.schema);if(!l)return!1;l===\"node\"&&(i=Q(t,r.schema)),l===\"mark\"&&(s=Qe(t,r.schema));let a=!1;return n.selection.ranges.forEach(c=>{let u=c.$from.pos,d=c.$to.pos,f,h,p,m;n.selection.empty?r.doc.nodesBetween(u,d,(g,y)=>{i&&i===g.type&&(a=!0,p=Math.max(y,u),m=Math.min(y+g.nodeSize,d),f=y,h=g)}):r.doc.nodesBetween(u,d,(g,y)=>{y<u&&i&&i===g.type&&(a=!0,p=Math.max(y,u),m=Math.min(y+g.nodeSize,d),f=y,h=g),y>=u&&y<=d&&(i&&i===g.type&&(a=!0,o&&n.setNodeMarkup(y,void 0,{...g.attrs,...e})),s&&g.marks.length&&g.marks.forEach(S=>{if(s===S.type&&(a=!0,o)){let k=Math.max(y,u),x=Math.min(y+g.nodeSize,d);n.addMark(k,x,s.create({...S.attrs,...e}))}}))}),h&&(f!==void 0&&o&&n.setNodeMarkup(f,void 0,{...h.attrs,...e}),s&&h.marks.length&&h.marks.forEach(g=>{s===g.type&&o&&n.addMark(p,m,s.create({...g.attrs,...e}))}))}),a},cn=new P(\"__tiptap_decorations__\"),c0=t=>({tr:e,dispatch:n})=>(n&&e.setMeta(cn,{type:\"force\",name:t}),!0),u0=(t,e={})=>({state:n,dispatch:r})=>{let o=Q(t,n.schema);return ic(o,e)(n,r)},d0=(t,e={})=>({state:n,dispatch:r})=>{let o=Q(t,n.schema);return sc(o,e)(n,r)},f0=Xl({blur:()=>Rg,clearContent:()=>Dg,clearNodes:()=>Ig,command:()=>Pg,createParagraphNear:()=>Lg,cut:()=>$g,deleteCurrentNode:()=>zg,deleteNode:()=>Bg,deleteRange:()=>Fg,deleteSelection:()=>Wg,enter:()=>Vg,exitCode:()=>_g,extendMarkRange:()=>Kg,first:()=>Ug,focus:()=>qg,forEach:()=>Gg,insertContent:()=>Xg,insertContentAt:()=>Yg,insertDefaultBlock:()=>Qg,joinBackward:()=>ty,joinDown:()=>ey,joinForward:()=>ny,joinItemBackward:()=>ry,joinItemForward:()=>oy,joinTextblockBackward:()=>iy,joinTextblockForward:()=>sy,joinUp:()=>Zg,keyboardShortcut:()=>ay,lift:()=>cy,liftEmptyBlock:()=>uy,liftListItem:()=>dy,newlineInCode:()=>fy,resetAttributes:()=>hy,scrollIntoView:()=>py,selectAll:()=>my,selectNodeBackward:()=>gy,selectNodeForward:()=>yy,selectParentNode:()=>by,selectTextblockEnd:()=>ky,selectTextblockStart:()=>wy,setContent:()=>Sy,setMark:()=>jy,setMeta:()=>Wy,setNode:()=>Vy,setNodeSelection:()=>_y,setTextDirection:()=>Ky,setTextSelection:()=>Uy,sinkListItem:()=>Jy,splitBlock:()=>qy,splitListItem:()=>Gy,toggleList:()=>e0,toggleMark:()=>t0,toggleNode:()=>n0,toggleWrap:()=>r0,undoInputRule:()=>o0,unsetAllMarks:()=>i0,unsetMark:()=>s0,unsetTextDirection:()=>l0,updateAttributes:()=>a0,updateDecorations:()=>c0,wrapIn:()=>u0,wrapInList:()=>d0}),un=new WeakMap;function h0(t,e){var n;un.set(t,((n=un.get(t))!==null&&n!==void 0?n:0)+1);try{return e()}finally{var r;let o=((r=un.get(t))!==null&&r!==void 0?r:1)-1;o>0?un.set(t,o):un.delete(t)}}function p0(t){return un.has(t)}var m0=class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){let n=this.callbacks[t];return n&&n.forEach(r=>r.apply(this,e)),this}off(t,e){let n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter(r=>r!==e):delete this.callbacks[t]),this}once(t,e){let n=(...r)=>{this.off(t,n),e.apply(this,r)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}},kd=typeof process<\"u\"&&!1;function g0(t){return t.kind===\"widget\"}function wd(t,e){let n=[],r=new Set;for(let o of t)o.kind===\"widget\"&&g0(o)&&r.add(o.key),n.push(o.toPMDecoration(e));return{decorations:n,widgetKeys:r}}function y0(t,e,n){let{decorations:r,widgetKeys:o}=wd(e,n);return{set:z.create(t,r),widgetKeys:o}}function Sd({position:t,from:e,to:n,docSize:r}){return t<e?!1:t<n?!0:t===n&&n===r}function b0({decorations:t,from:e,to:n,docSize:r,extensionName:o,warnedExtensions:i}){return t.filter(s=>Sd({position:s.anchor,from:e,to:n,docSize:r})?!0:(s.anchor===n||i.has(o)||(i.add(o),console.warn(`[tiptap warn]: Extension \"${o}\" returned a decoration outside the requested range [${e}, ${n}). It was ignored.`)),!1))}function xd(t){var e;let n=(e=t.spec)===null||e===void 0?void 0:e.key;return typeof n==\"string\"?n:void 0}function k0(t){let e=new Map,n=new Map;for(let s of t.find()){var r,o,i;let l=xd(s);if(!l)continue;let a=(r=s.spec.extensionName)!==null&&r!==void 0?r:\"unknown\",c=(o=e.get(l))!==null&&o!==void 0?o:new Set;c.add(a),e.set(l,c),n.set(l,((i=n.get(l))!==null&&i!==void 0?i:0)+1)}return Array.from(e,([s,l])=>({key:s,extensions:l})).filter(({key:s})=>{var l;return((l=n.get(s))!==null&&l!==void 0?l:0)>1})}function Cd(t){return t.jsonID===\"attr\"}function w0(t){let e=!1;if(t.getMap().forEach(()=>{e=!0}),e||Cd(t))return!0;let n=t;return typeof n.from==\"number\"&&typeof n.to==\"number\"}function S0(t,e){let n=null,r=0,o=0;for(let i=0;i<t.childCount&&!(o>e.to);i+=1){let s=o+t.child(i).nodeSize;s>=e.from&&(n===null&&(n=o),r=s),o=s}return n===null?null:{from:n,to:r}}function x0(t,e){if(t.steps.some(i=>!w0(i)))return{type:\"full\"};let n=mn(t).map(({newRange:i})=>i);t.steps.forEach((i,s)=>{if(!Cd(i))return;let l=t.mapping.slice(s);n.push({from:l.map(i.pos,-1),to:l.map(i.pos+1)})});let r=[];for(let i of n){let s=S0(e,i);s&&r.push(s)}r.sort((i,s)=>i.from-s.from);let o=[];for(let i of r){let s=o[o.length-1];s&&i.from<=s.to?s.to=Math.max(s.to,i.to):o.push({...i})}return{type:\"ranges\",ranges:o}}function Md(t,e,n,r){return t.map(e,n,{onRemove:o=>{let i=o?.key;typeof i==\"string\"&&r.delete(i)}})}function C0(t,e,n){var r,o;let i=(r=e.decorationSetsByExtension[t])!==null&&r!==void 0?r:z.empty,s=new Set((o=e.widgetKeysByExtension[t])!==null&&o!==void 0?o:[]);return{set:Md(i,n.mapping,n.doc,s),widgetKeys:s}}function ju(t,e){let n=Object.values(e).flatMap(r=>r.find());return z.create(t,n)}function Wu(t){let e=new Set;for(let n of Object.values(t))for(let r of n)e.add(r);return e}function M0(t,e){var n;switch((n=e.update)!==null&&n!==void 0?n:\"document\"){case\"document\":if(e.createInRange)throw new Error(`[tiptap error]: Extension \"${t}\" provides createInRange() but does not use the \"changedRanges\" decoration update strategy.`);return;case\"changedRanges\":if(!e.createInRange)throw new Error(`[tiptap error]: Extension \"${t}\" uses the \"changedRanges\" decoration update strategy but does not provide createInRange().`);return;case\"manual\":if(e.createInRange)throw new Error(`[tiptap error]: Extension \"${t}\" uses the \"manual\" decoration update strategy, which is not compatible with createInRange(). createInRange() requires the \"changedRanges\" strategy.`);if(e.shouldUpdate)throw new Error(`[tiptap error]: Extension \"${t}\" cannot combine the \"manual\" decoration update strategy with shouldUpdate().`);return;default:throw new Error(`[tiptap error]: Extension \"${t}\" uses an unknown decoration update strategy. Expected \"document\", \"changedRanges\", or \"manual\".`)}}function v0(t,e,n){return n?!0:t.update===\"manual\"?!1:t.shouldUpdate?t.shouldUpdate(e):e.tr.docChanged}var E0=new Set;var A0=class{constructor(t){this.warnedWidgetKeys=new Set,this.warnedOutOfRangeExtensions=new Set,this.handleBeforeTransaction=({nextState:e})=>{let n=cn.getState(e);n&&this.warnDuplicateWidgetKeys(n)},this.editor=t.editor,this.entries=this.resolveEntries(t.entries),this.entries.forEach(({name:e,spec:n})=>M0(e,n)),this.plugin=this.entries.length>0?this.createPlugin():null,this.editor.on(\"beforeTransaction\",this.handleBeforeTransaction)}destroy(){this.editor.off(\"beforeTransaction\",this.handleBeforeTransaction)}liveWidgetKeys(){var t,e;return(t=(e=cn.getState(this.editor.state))===null||e===void 0?void 0:e.widgetKeys)!==null&&t!==void 0?t:E0}get mountedView(){return this.editor.isDestroyed?null:this.editor.view}resolveEntries(t){let e=[];for(let{name:n,addDecorations:r}of t){let o=r();o&&e.push({name:n,spec:o})}return e}createPlugin(){let{editor:t,entries:e}=this;return new R({key:cn,state:{init:(n,r)=>{let o={},i={};for(let{name:l,spec:a}of e){let{set:c,widgetKeys:u}=this.buildFullSet(l,a,r);o[l]=c,i[l]=u}let s={decorationSetsByExtension:o,widgetKeysByExtension:i,mergedDecorationSet:this.buildMergedSet(r.doc,o),widgetKeys:Wu(i)};return this.warnDuplicateWidgetKeys(s),s},apply:(n,r,o,i)=>{let s=n.getMeta(cn),l=s?.type===\"force\"&&!s.name,a=s?.type===\"force\"?s.name:void 0,c={},u={},d=new Set;return h0(t,()=>{for(let{name:f,spec:h}of e){let p=l||a===f;if(v0(h,{editor:t,tr:n,oldState:o,newState:i},p))if(h.update===\"changedRanges\"&&n.docChanged&&!p){let m=this.applyChangedRangesRecompute(f,h,r,n,i);c[f]=m.set,u[f]=m.widgetKeys,d.add(f)}else{let{set:m,widgetKeys:g}=this.buildFullSet(f,h,i);c[f]=m,u[f]=g,d.add(f)}else{let m=C0(f,r,n);c[f]=m.set,u[f]=m.widgetKeys}}}),d.size===0&&!n.docChanged?r:{decorationSetsByExtension:c,widgetKeysByExtension:u,mergedDecorationSet:this.mergeAfterApply({entries:e,previous:r,tr:n,decorationSetsByExtension:c,recomputedNames:d}),widgetKeys:Wu(u)}}},props:{decorations(n){var r,o;return(r=(o=cn.getState(n))===null||o===void 0?void 0:o.mergedDecorationSet)!==null&&r!==void 0?r:z.empty}}})}applyChangedRangesRecompute(t,e,n,r,o){let i=x0(r,o.doc);return i.type===\"full\"?this.buildFullSet(t,e,o):this.rebuildRanges(t,e,n,r,o,i.ranges)}rebuildRanges(t,e,n,r,o,i){var s,l;let a=(s=n.decorationSetsByExtension[t])!==null&&s!==void 0?s:z.empty,c=new Set((l=n.widgetKeysByExtension[t])!==null&&l!==void 0?l:[]),u=Md(a,r.mapping,r.doc,c),d=o.doc.content.size;for(let{from:f,to:h}of i){let p=u.find(f,h).filter(y=>Sd({position:y.from,from:f,to:h,docSize:d}));for(let y of p){let S=xd(y);S&&c.delete(S)}u=u.remove(p);let{decorations:m,widgetKeys:g}=wd(b0({decorations:this.runCreate(t,\"createInRange\",()=>e.createInRange({editor:this.editor,state:o,view:this.mountedView,from:f,to:h})),from:f,to:h,docSize:d,extensionName:t,warnedExtensions:this.warnedOutOfRangeExtensions}),t);u=u.add(o.doc,m);for(let y of g)c.add(y)}return{set:u,widgetKeys:c}}buildFullSet(t,e,n){let r=this.runCreate(t,\"create\",()=>e.create({editor:this.editor,state:n,view:this.mountedView}));return y0(n.doc,r,t)}runCreate(t,e,n){try{return n()}catch(r){return console.error(`[tiptap error]: Extension \"${t}\" threw in \\`addDecorations().${e}()\\`. Its decorations were dropped for this update.`,r),[]}}warnDuplicateWidgetKeys(t){if(!kd)return;if(t.widgetKeys.size===0){this.warnedWidgetKeys.clear();return}let e=k0(t.mergedDecorationSet),n=new Set(e.map(({key:r})=>r));for(let{key:r,extensions:o}of e){if(this.warnedWidgetKeys.has(r))continue;let i=Array.from(o).map(s=>`\"${s}\"`).join(\", \");console.warn(`[tiptap warn]: Duplicate widget decoration key \"${r}\" in extension${o.size===1?\"\":\"s\"} ${i}. Widget decoration keys must be globally unique, otherwise ProseMirror misplaces the widget DOM. Use a stable, unique key (e.g. \\`comment-\\${id}\\`).`)}this.warnedWidgetKeys=n}buildMergedSet(t,e){let n=Object.keys(e);return n.length===1?e[n[0]]:ju(t,e)}mergeAfterApply({entries:t,previous:e,tr:n,decorationSetsByExtension:r,recomputedNames:o}){return t.length===1?r[t[0].name]:o.size===0?e.mergedDecorationSet.map(n.mapping,n.doc):ju(n.doc,r)}};function T0(t,e,n){let r=document.querySelector(`style[data-tiptap-style${n?`-${n}`:\"\"}]`);if(r!==null)return r;let o=document.createElement(\"style\");return e&&o.setAttribute(\"nonce\",e),o.setAttribute(`data-tiptap-style${n?`-${n}`:\"\"}`,\"\"),o.innerHTML=t,document.getElementsByTagName(\"head\")[0].appendChild(o),o}function N0(t){return typeof t==\"number\"}function O0(t){return Object.prototype.toString.call(t).slice(8,-1)}function Gr(t){return O0(t)!==\"Object\"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function vd(t){return typeof t==\"string\"&&t.trim().length>0&&!/[;{}]/.test(t)}function R0(t,e){return t.replace(/^[ \\t]*/,n=>{let o=0;for(let i of n)o+=i===\"\t\"?4-o%4:1;return\" \".repeat(Math.max(0,o-e))})}function D0(t,e){let n=`text\n${t}\n`,r=e(n)[0];return(r?.type===\"paragraph\"||r?.type===\"text\")&&r.raw===n}function I0(t,e,n){var r;let o=e.split(`\n`),i=(r=n.isParagraphContinuation)!==null&&r!==void 0?r:(l=>D0(l,n.blockTokens)),s=0;for(let l of o){if(!l.trim()||!i(l))break;s+=1}return{mainContent:[t,...o.slice(0,s).map(l=>l.trimStart())].join(`\n`),nestedContent:o.slice(s).join(`\n`)}}function Is(t,e,n){let r=t.split(`\n`),o=[],i=\"\",s=0,l=e.baseIndentSize||2;for(;s<r.length;){let u=r[s],d=u.match(e.itemPattern);if(!d){if(o.length>0)break;if(u.trim()===\"\"){s+=1,i=`${i}${u}\n`;continue}else return}let f=e.extractItemData(d),{indentLevel:h,mainContent:p}=f;i=`${i}${u}\n`;let m=[p];for(s+=1;s<r.length;){var a;let k=r[s];if(k.trim()===\"\"){var c;let x=r.slice(s+1).findIndex(O=>O.trim()!==\"\");if(x===-1)break;if((((c=r[s+1+x].match(/^(\\s*)/))===null||c===void 0||(c=c[1])===null||c===void 0?void 0:c.length)||0)>h){m.push(k),i=`${i}${k}\n`,s+=1;continue}else break}if((((a=k.match(/^(\\s*)/))===null||a===void 0||(a=a[1])===null||a===void 0?void 0:a.length)||0)>h)m.push(k),i=`${i}${k}\n`,s+=1;else break}let g,y=m.slice(1);if(y.length>0){let k=I0(p,y.map(O=>R0(O,h+l)).join(`\n`),n);f.mainContent=k.mainContent;let x=k.nestedContent;x.trim()&&(e.customNestedParser?g=e.customNestedParser(x):g=n.blockTokens(x))}let S=e.createToken(f,g);o.push(S)}if(o.length!==0)return{items:o,raw:i.slice(0,t.length)}}var Vu=4;function _u(t){let e=0;for(let n of t)e=n===\"\t\"?e+Vu-e%Vu:e+1;return e}function Ps(t,e,n,r,o){if(!t||!Array.isArray(t.content))return\"\";let i=typeof n==\"function\"?n(r):n,[s,...l]=t.content,a=e.renderChildren([s]),c=`${i}${o?.indentMainContent?a.split(`\n`).map((u,d)=>d===0?u:e.indent(u)).join(`\n`):a}`;return l&&l.length>0&&l.forEach((u,d)=>{var f,h;let p=(f=(h=e.renderChild)===null||h===void 0?void 0:h.call(e,u,d+1))!==null&&f!==void 0?f:e.renderChildren([u]);if(p!=null){let m=y=>{if(!o?.alignNestedToPrefix)return e.indent(y);let S=e.indent(\"\"),k=_u(i);return(_u(S)>=k?S:\" \".repeat(k))+y},g=p.split(`\n`).map(y=>m(y||\"\")).join(`\n`);c+=u.type===\"paragraph\"?`\n\n${g}`:`\n${g}`}}),c}function Ed(t,e){let n={...t};return Gr(t)&&Gr(e)&&Object.keys(e).forEach(r=>{Gr(e[r])&&Gr(t[r])?n[r]=Ed(t[r],e[r]):n[r]=e[r]}),n}function P0(t,e,n={}){let{state:r}=e,{doc:o,tr:i}=r,s=t;o.descendants((l,a)=>{let c=i.mapping.map(a),u=i.mapping.map(a)+l.nodeSize,d=null;if(l.marks.forEach(h=>{if(h!==s)return!1;d=h}),!d)return;let f=!1;if(Object.keys(n).forEach(h=>{n[h]!==d.attrs[h]&&(f=!0)}),f){let h=t.type.create({...t.attrs,...n});i.removeMark(c,u,t.type),i.addMark(c,u,h)}}),i.docChanged&&e.view.dispatch(i)}var yn=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!==null&&e!==void 0?e:!0}},L0=(t,e)=>{if(vs(e))return e.exec(t);let n=e(t);if(!n)return null;let r=[n.text];return r.index=n.index,r.input=t,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: \"inputRuleMatch.replaceWith\" must be part of \"inputRuleMatch.text\".'),r.push(n.replaceWith)),r};function $0(t){let{editor:e,from:n,to:r,text:o,insertText:i}=t;if(!i)return{inputTransaction:null,tr:e.view.state.tr};let s=e.view.state.tr.insertText(o,n,r);return{inputTransaction:s,tr:At.create({doc:s.doc,selection:s.selection,storedMarks:s.storedMarks}).tr}}function z0(t){let{editor:e,from:n,to:r,text:o,rule:i,match:s,plugin:l,insertText:a}=t,{view:c}=e,{inputTransaction:u,tr:d}=$0({editor:e,from:n,to:r,text:o,insertText:a}),f=u?n+o.length:r,h=eo({state:c.state,transaction:d}),p={from:n-(s[0].length-o.length),to:f},{commands:m,chain:g,can:y}=new dn({editor:e,state:h});return i.handler({state:h,range:p,match:s,commands:m,chain:g,can:y})===null||!d.steps.length?!1:(u&&(c.dispatch(u),!c.state.doc.eq(u.doc))||(xu(d),d.setMeta(\"inputRule\",!0),i.undoable&&d.setMeta(l,{transform:d,from:n,to:f,text:o}),c.dispatch(d)),!0)}function B0(t,e,n){let r=e[0].length-n.length;if(r<=0)return!0;let o=t.parentOffset-r;return o>=0&&t.parent.textBetween(o,t.parentOffset)===e[0].slice(0,r)}function Xr(t){var e;let{editor:n,from:r,to:o,text:i,rules:s,plugin:l,insertText:a}=t,{view:c}=n;if(c.composing)return!1;let u=c.state.doc.resolve(r);if(u.parent.type.spec.code||!((e=u.nodeBefore||u.nodeAfter)===null||e===void 0)&&e.marks.find(f=>f.type.spec.code))return!1;let d=Py(u)+i;for(let f of s){let h=L0(d,f.find);if(!(!h||!B0(u,h,i))&&z0({editor:n,from:r,to:o,text:i,rule:f,match:h,plugin:l,insertText:a}))return!0}return!1}function F0(t){let{editor:e,rules:n}=t,r=new R({state:{init(){return null},apply(o,i,s){let l=o.getMeta(r);if(l)return l;let a=o.getMeta(\"applyInputRules\");return a&&setTimeout(()=>{let{text:c}=a;typeof c==\"string\"?c=c:c=Ns(b.from(c),s.schema);let{from:u}=a,d=u+c.length;Xr({editor:e,from:u,to:d,text:c,rules:n,plugin:r})}),o.selectionSet||o.docChanged?null:i}},props:{handleTextInput(o,i,s,l){return Xr({editor:e,from:i,to:s,text:l,rules:n,plugin:r,insertText:!0})},handleDOMEvents:{compositionend:o=>(setTimeout(()=>{let{$cursor:i}=o.state.selection;i&&Xr({editor:e,from:i.pos,to:i.pos,text:\"\",rules:n,plugin:r})}),!1)},handleKeyDown(o,i){if(i.key!==\"Enter\")return!1;let{$cursor:s}=o.state.selection;return s?Xr({editor:e,from:s.pos,to:s.pos,text:`\n`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}var Ls=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{...L(v(this,\"addOptions\",{name:this.name}))}}get storage(){return{...L(v(this,\"addStorage\",{name:this.name,options:this.options}))}}configure(t={}){let e=this.extend({...this.config,addOptions:()=>Ed(this.options,t)});return e.name=this.name,e.parent=this.parent,this.child=null,e}extend(t={}){let 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}},Ze=class Ad extends Ls{constructor(...e){super(...e),this.type=\"mark\"}static create(e={}){let n=typeof e==\"function\"?e():e;return new Ad(n)}static handleExit({editor:e,mark:n}){let{tr:r}=e.state,o=e.state.selection.$from;if(o.pos===o.end()){let i=o.marks();if(!i.find(l=>l?.type.name===n.name))return!1;let s=i.find(l=>l?.type.name===n.name);return s&&r.removeStoredMark(s),r.insertText(\" \",o.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){let n=typeof e==\"function\"?e():e;return super.extend(n)}},$s=class{constructor(t){this.find=t.find,this.handler=t.handler}},H0=(t,e,n)=>{if(vs(e))return[...t.matchAll(e)];let r=e(t,n);return r?r.map(o=>{let i=[o.text];return i.index=o.index,i.input=t,i.data=o.data,o.replaceWith&&(o.text.includes(o.replaceWith)||console.warn('[tiptap warn]: \"pasteRuleMatch.replaceWith\" must be part of \"pasteRuleMatch.text\".'),i.push(o.replaceWith)),i}):[]};function j0(t){let{editor:e,state:n,from:r,to:o,rule:i,pasteEvent:s,dropEvent:l}=t,{commands:a,chain:c,can:u}=new dn({editor:e,state:n}),d=[];return n.doc.nodesBetween(r,o,(f,h)=>{var p,m,g,y;if(!((p=f.type)===null||p===void 0||(p=p.spec)===null||p===void 0)&&p.code||!(f.isText||f.isTextblock||f.isInline))return;let S=(m=(g=(y=f.content)===null||y===void 0?void 0:y.size)!==null&&g!==void 0?g:f.nodeSize)!==null&&m!==void 0?m:0,k=Math.max(r,h),x=Math.min(o,h+S);if(k>=x)return;let O=f.isText?f.text||\"\":f.textBetween(k-h,x-h,void 0,\"\\uFFFC\");H0(O,i.find,s).forEach(H=>{if(H.index===void 0)return;let T=k+H.index+1,I=T+H[0].length,F={from:n.tr.mapping.map(T),to:n.tr.mapping.map(I)},W=i.handler({state:n,range:F,match:H,commands:a,chain:c,can:u,pasteEvent:s,dropEvent:l});d.push(W)})}),d.every(f=>f!==null)}var an=null,W0=t=>{var e;let n=new ClipboardEvent(\"paste\",{clipboardData:new DataTransfer});return(e=n.clipboardData)===null||e===void 0||e.setData(\"text/html\",t),n};function V0(t){let{editor:e,rules:n}=t,r=null,o=!1,i=!1,s=typeof ClipboardEvent<\"u\"?new ClipboardEvent(\"paste\"):null,l;try{l=typeof DragEvent<\"u\"?new DragEvent(\"drop\"):null}catch{l=null}let a=({state:c,from:u,to:d,rule:f,pasteEvt:h})=>{let p=c.tr,m=eo({state:c,transaction:p});if(!(!j0({editor:e,state:m,from:Math.max(u-1,0),to:d.b-1,rule:f,pasteEvent:h,dropEvent:l})||!p.steps.length)){try{l=typeof DragEvent<\"u\"?new DragEvent(\"drop\"):null}catch{l=null}return s=typeof ClipboardEvent<\"u\"?new ClipboardEvent(\"paste\"):null,p}};return e.on(\"destroy\",()=>{an===e&&(an=null)}),n.map(c=>new R({view(u){let d=h=>{var p;r=!((p=u.dom.parentElement)===null||p===void 0)&&p.contains(h.target)?u.dom.parentElement:null,r&&(an=e)},f=()=>{an&&(an=null)};return window.addEventListener(\"dragstart\",d),window.addEventListener(\"dragend\",f),{destroy(){window.removeEventListener(\"dragstart\",d),window.removeEventListener(\"dragend\",f)}}},props:{handleDOMEvents:{drop:(u,d)=>{if(i=r===u.dom.parentElement,l=d,!i){let f=an;f?.isEditable&&setTimeout(()=>{if(f.isDestroyed)return;let h=f.state.selection;h&&f.commands.deleteRange({from:h.from,to:h.to})},10)}return!1},paste:(u,d)=>{var f;let h=(f=d.clipboardData)===null||f===void 0?void 0:f.getData(\"text/html\");return s=d,o=!!h?.includes(\"data-pm-slice\"),!1}}},appendTransaction:(u,d,f)=>{let h=u[0],p=h.getMeta(\"uiEvent\")===\"paste\"&&!o,m=h.getMeta(\"uiEvent\")===\"drop\"&&!i,g=h.getMeta(\"applyPasteRules\"),y=!!g;if(!p&&!m&&!y)return;if(y){let{text:x}=g;typeof x==\"string\"?x=x:x=Ns(b.from(x),f.schema);let{from:O}=g,H=O+x.length,T=W0(x);return a({rule:c,state:f,from:O,to:{b:H},pasteEvt:T})}let S=d.doc.content.findDiffStart(f.doc.content),k=d.doc.content.findDiffEnd(f.doc.content);if(!(!N0(S)||!k||S===k.b))return a({rule:c,state:f,from:S,to:k,pasteEvt:s})}}))}var ro=class{constructor(t,e){this.splittableMarks=[],this.nonClearableMarks=[],this.decorationManager=null,this.editor=e,this.baseExtensions=t,this.extensions=sd(t),this.hasSchemaSpec=e.options.schemaSpec!==void 0,this.schema=Ny(this.extensions,e,e.options.schemaSpec),this.setupExtensions()}get commands(){return this.extensions.reduce((t,e)=>{let n=v(e,\"addCommands\",{name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:ln(e.name,this.schema)});return n?{...t,...n()}:t},{})}get plugins(){let{editor:t}=this,e=Yn([...this.extensions].reverse()).flatMap(r=>{let o={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:ln(r.name,this.schema)},i=[],s=v(r,\"addKeyboardShortcuts\",o),l={};if(r.type===\"mark\"&&v(r,\"exitable\",o)&&(l.ArrowRight=()=>Ze.handleExit({editor:t,mark:r})),s){let f=Object.fromEntries(Object.entries(s()).map(([h,p])=>[h,()=>p({editor:t})]));l={...l,...f}}let a=bu(l);i.push(a);let c=v(r,\"addInputRules\",o);if(zu(r,t.options.enableInputRules)&&c){let f=c();if(f&&f.length){let h=F0({editor:t,rules:f}),p=Array.isArray(h)?h:[h];i.push(...p)}}let u=v(r,\"addPasteRules\",o);if(zu(r,t.options.enablePasteRules)&&u){let f=u();if(f&&f.length){let h=V0({editor:t,rules:f});i.push(...h)}}let d=v(r,\"addProseMirrorPlugins\",o);if(d){let f=d();i.push(...f)}return i}),n=this.createDecorationPlugin();return n&&e.push(n),e}createDecorationPlugin(){var t;let{editor:e}=this;(t=this.decorationManager)===null||t===void 0||t.destroy();let n=[];return this.extensions.forEach(r=>{let o=v(r,\"addDecorations\",{name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:e,type:ln(r.name,this.schema)});o&&n.push({name:r.name,addDecorations:o})}),this.decorationManager=new A0({editor:e,entries:n}),this.decorationManager.plugin}get attributes(){let t=Os(this.extensions);return this.hasSchemaSpec?od(t,this.schema):t}get nodeViews(){let{editor:t}=this,{nodeExtensions:e}=hn(this.extensions);return Object.fromEntries(e.filter(n=>!!v(n,\"addNodeView\")).map(n=>{let r=this.attributes.filter(l=>l.type===n.name),o=v(n,\"addNodeView\",{name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Q(n.name,this.schema)});if(!o)return[];let i=o();if(!i)return[];let s=(l,a,c,u,d)=>{let f=pt(l,r);return i({node:l,view:a,getPos:c,decorations:u,innerDecorations:d,editor:t,extension:n,HTMLAttributes:f})};return[n.name,s]}))}dispatchTransaction(t){let{editor:e}=this;return Yn([...this.extensions].reverse()).reduceRight((n,r)=>{let o={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:e,type:ln(r.name,this.schema)},i=v(r,\"dispatchTransaction\",o);return i?s=>{i.call(o,{transaction:s,next:n})}:n},t)}transformPastedHTML(t){let{editor:e}=this;return Yn([...this.extensions]).reduce((n,r)=>{let o={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:e,type:ln(r.name,this.schema)},i=v(r,\"transformPastedHTML\",o);return i?(s,l)=>{let a=n(s,l);return i.call(o,a)}:n},t||(n=>n))}get markViews(){let{editor:t}=this,{markExtensions:e}=hn(this.extensions);return Object.fromEntries(e.filter(n=>!!v(n,\"addMarkView\")).map(n=>{let r=this.attributes.filter(s=>s.type===n.name),o=v(n,\"addMarkView\",{name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Qe(n.name,this.schema)});if(!o)return[];let i=(s,l,a)=>{let c=pt(s,r);return o()({mark:s,view:l,inline:a,editor:t,extension:n,HTMLAttributes:c,updateAttributes:u=>{P0(s,t,u)}})};return[n.name,i]}))}destroy(){var t;(t=this.decorationManager)===null||t===void 0||t.destroy(),this.extensions.forEach(e=>{let n=e;for(;n.parent;){let r=n.parent;r.child===n&&(r.child=null),n=r}}),this.extensions=[],this.baseExtensions=[],this.decorationManager=null,this.schema=null,this.editor=null}setupExtensions(){let t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(e=>[e.name,e.storage])),t.forEach(e=>{let n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:ln(e.name,this.schema)};if(e.type===\"mark\"){var r,o;(!((r=L(v(e,\"keepOnSplit\",n)))!==null&&r!==void 0)||r)&&this.splittableMarks.push(e.name),!((o=L(v(e,\"clearable\",n)))!==null&&o!==void 0)||o||this.nonClearableMarks.push(e.name)}let i=v(e,\"onBeforeCreate\",n),s=v(e,\"onCreate\",n),l=v(e,\"onUpdate\",n),a=v(e,\"onSelectionUpdate\",n),c=v(e,\"onTransaction\",n),u=v(e,\"onFocus\",n),d=v(e,\"onBlur\",n),f=v(e,\"onDestroy\",n);i&&this.editor.on(\"beforeCreate\",i),s&&this.editor.on(\"create\",s),l&&this.editor.on(\"update\",l),a&&this.editor.on(\"selectionUpdate\",a),c&&this.editor.on(\"transaction\",c),u&&this.editor.on(\"focus\",u),d&&this.editor.on(\"blur\",d),f&&this.editor.on(\"destroy\",f)})}};ro.resolve=sd;ro.sort=Yn;ro.flatten=Ts;var V=class Td extends Ls{constructor(...e){super(...e),this.type=\"extension\"}static create(e={}){let n=typeof e==\"function\"?e():e;return new Td(n)}configure(e){return super.configure(e)}extend(e){let n=typeof e==\"function\"?e():e;return super.extend(n)}},_0=V.create({name:\"clipboardTextSerializer\",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new R({key:new P(\"clipboardTextSerializer\"),props:{clipboardTextSerializer:()=>{let{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:o}=e,i=ad(n),{blockSeparator:s}=this.options,l={...s!==void 0?{blockSeparator:s}:{},textSerializers:i};return[...o.ranges].sort((a,c)=>a.$from.pos-c.$from.pos).map(({$from:a,$to:c})=>ld(r,{from:a.pos,to:c.pos},l)).join(s??`\n\n`)}}})]}}),K0=V.create({name:\"commands\",addCommands(){return{...f0}}}),U0=V.create({name:\"delete\",onUpdate({transaction:t,appendedTransactions:e}){var n,r;let o=()=>{var i,s,l;if((i=(s=this.editor.options.coreExtensionOptions)===null||s===void 0||(s=s.delete)===null||s===void 0||(l=s.filterTransaction)===null||l===void 0?void 0:l.call(s,t))!==null&&i!==void 0?i:t.getMeta(\"y-sync$\"))return;let a=As(t.before,[t,...e]);mn(a).forEach(u=>{a.mapping.mapResult(u.oldRange.from).deletedAfter&&a.mapping.mapResult(u.oldRange.to).deletedBefore&&a.before.nodesBetween(u.oldRange.from,u.oldRange.to,(d,f)=>{let h=f+d.nodeSize-2,p=u.oldRange.from<=f&&h<=u.oldRange.to;this.editor.emit(\"delete\",{type:\"node\",node:d,from:f,to:h,newFrom:a.mapping.map(f),newTo:a.mapping.map(h),deletedRange:u.oldRange,newRange:u.newRange,partial:!p,editor:this.editor,transaction:t,combinedTransform:a})})});let c=a.mapping;a.steps.forEach((u,d)=>{if(u instanceof _e){var f,h;let p=c.slice(d).map(u.from,-1),m=c.slice(d).map(u.to),g=c.invert().map(p,-1),y=c.invert().map(m),S=p>0?(f=a.doc.nodeAt(p-1))===null||f===void 0?void 0:f.marks.some(x=>x.eq(u.mark)):!1,k=(h=a.doc.nodeAt(m))===null||h===void 0?void 0:h.marks.some(x=>x.eq(u.mark));this.editor.emit(\"delete\",{type:\"mark\",mark:u.mark,from:u.from,to:u.to,deletedRange:{from:g,to:y},newRange:{from:p,to:m},partial:!!(k||S),editor:this.editor,transaction:t,combinedTransform:a})}})};!((n=(r=this.editor.options.coreExtensionOptions)===null||r===void 0||(r=r.delete)===null||r===void 0?void 0:r.async)!==null&&n!==void 0)||n?setTimeout(o,0):o()}}),J0=V.create({name:\"drop\",addProseMirrorPlugins(){return[new R({key:new P(\"tiptapDrop\"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit(\"drop\",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),q0=V.create({name:\"editable\",addProseMirrorPlugins(){return[new R({key:new P(\"editable\"),props:{editable:()=>this.editor.options.editable}})]}}),G0=new P(\"focusEvents\"),X0=V.create({name:\"focusEvents\",addProseMirrorPlugins(){let{editor:t}=this;return[new R({key:G0,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;let r=t.state.tr.setMeta(\"focus\",{event:n}).setMeta(\"addToHistory\",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;let r=t.state.tr.setMeta(\"blur\",{event:n}).setMeta(\"addToHistory\",!1);return e.dispatch(r),!1}}}})]}}),Y0=V.create({name:\"keymap\",addKeyboardShortcuts(){let t=()=>this.editor.commands.first(({commands:s})=>[()=>s.undoInputRule(),()=>s.command(({tr:l})=>{let{selection:a,doc:c}=l,{empty:u,$anchor:d}=a,{pos:f,parent:h}=d,p=d.parent.isTextblock&&f>0?l.doc.resolve(f-1):d,m=p.parent.type.spec.isolating,g=d.pos-d.parentOffset,y=m&&p.parent.childCount===1?g===d.pos:E.atStart(c).from===f;return!u||!h.type.isTextblock||h.textContent.length||!y||y&&d.parent.type.name===\"paragraph\"?!1:s.clearNodes()}),()=>s.deleteSelection(),()=>s.joinBackward(),()=>s.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:s})=>[()=>s.deleteSelection(),()=>s.deleteCurrentNode(),()=>s.joinForward(),()=>s.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:s})=>[()=>s.newlineInCode(),()=>s.createParagraphNear(),()=>s.liftEmptyBlock(),()=>s.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={...r},i={...r,\"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 Zr()||td()?i:o},addProseMirrorPlugins(){return[new R({key:new P(\"clearDocument\"),appendTransaction:(t,e,n)=>{if(t.some(h=>h.getMeta(\"composition\")))return;let r=t.some(h=>h.docChanged)&&!e.doc.eq(n.doc),o=t.some(h=>h.getMeta(\"preventClearDocument\"));if(!r||o)return;let{empty:i,from:s,to:l}=e.selection,a=E.atStart(e.doc).from,c=E.atEnd(e.doc).to;if(i||!(s===a&&l===c)||!gn(n.doc))return;let u=n.tr,d=eo({state:n,transaction:u}),{commands:f}=new dn({editor:this.editor,state:d});if(f.clearNodes(),!!u.steps.length)return u}})]}}),Q0=V.create({name:\"paste\",addProseMirrorPlugins(){return[new R({key:new P(\"tiptapPaste\"),props:{handlePaste:(t,e,n)=>{this.editor.emit(\"paste\",{editor:this.editor,event:e,slice:n})}}})]}}),Z0=V.create({name:\"tabindex\",addOptions(){return{value:void 0}},addProseMirrorPlugins(){return[new R({key:new P(\"tabindex\"),props:{attributes:()=>{var t;return!this.editor.isEditable&&this.options.value===void 0?{}:{tabindex:(t=this.options.value)!==null&&t!==void 0?t:\"0\"}}}})]}}),eb=V.create({name:\"textDirection\",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];let{nodeExtensions:t}=hn(this.extensions);return[{types:t.filter(e=>e.name!==\"text\").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{let n=e.getAttribute(\"dir\");return n&&(n===\"ltr\"||n===\"rtl\"||n===\"auto\")?n:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new R({key:new P(\"textDirection\"),props:{attributes:()=>{let t=this.options.direction;return t?{dir:t}:{}}}})]}});var Ku=!1;function tb(t){if(Ku)return;Ku=!0;let e;try{let n=G.fromJSON(t,{from:0,to:0});if(!zy(n))return;e=n.slice.content}catch{return}e instanceof b||console.warn(\"[tiptap warn]: prosemirror-model is loaded more than once. Wrapping and splitting nodes will fail. Deduplicate it in your lock file, or alias it to a single copy in your bundler.\")}var nb=class Xn{get name(){return this.node.type.name}constructor(e,n,r=!1,o=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,this.currentNode=o}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!==null&&e!==void 0?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let n=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can\\u2019t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:n,to:r},e)}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(this.depth===0)return null;let e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new Xn(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 Xn(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 Xn(e,this.editor)}get children(){let e=[];return this.node.content.forEach((n,r)=>{let o=n.isBlock&&!n.isTextblock,i=n.isAtom&&!n.isText,s=n.isInline,l=this.pos+r+(i?0:1);if(l<0||l>this.resolvedPos.doc.nodeSize-2)return;let a=this.resolvedPos.doc.resolve(l);if(!o&&!s&&a.depth<=this.depth)return;let c=new Xn(a,this.editor,o,o||s?n:null);o&&(c.actualDepth=this.depth+1),e.push(c)}),e}get firstChild(){return this.children[0]||null}get lastChild(){let e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,o=this.parent;for(;o&&!r;){if(o.node.type.name===e)if(Object.keys(n).length>0){let i=o.node.attrs,s=Object.keys(n);for(let l=0;l<s.length;l+=1){let a=s[l];if(i[a]!==n[a])break}}else r=o;o=o.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let o=[];if(!this.children||this.children.length===0)return o;let i=Object.keys(n);return this.children.forEach(s=>{r&&o.length>0||(s.node.type.name===e&&i.every(l=>n[l]===s.node.attrs[l])&&o.push(s),!(r&&o.length>0)&&(o=o.concat(s.querySelectorAll(e,n,r))))}),o}setAttribute(e){let{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},rb=`.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}`,Nd=class extends m0{constructor(t={}){super(),this.css=null,this.className=\"tiptap\",this.editorView=null,this.isFocused=!1,this.destroyed=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.hasWarnedStaleDecorationRead=!1,this.options={element:typeof document<\"u\"?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:n})=>{throw n},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:By,createMappablePosition:Fy},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:n,slice:r,moved:o})=>this.options.onDrop(n,r,o)),this.on(\"paste\",({event:n,slice:r})=>this.options.onPaste(n,r)),this.on(\"delete\",this.options.onDelete);let e=this.createDoc();if(!this.editorState){let n=Ss(e,this.options.autofocus);this.editorState=At.create({doc:e,schema:this.schema,selection:n||void 0})}tb(this.schema),this.options.element&&this.mount(this.options.element)}mount(t){if(typeof document>\"u\")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||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit(\"create\",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){this.editorState=this.editorView.state;let t=this.editorView.dom;t?.editor&&delete t.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove==\"function\"?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?this.commandManager.chain():dn.createFakeChain()}can(){return this.commandManager?this.commandManager.can():dn.createFallbackCan()}injectCSS(){this.options.injectCSS&&typeof document<\"u\"&&(this.css=T0(rb,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,attributes:this.getEditorViewAttributes()}),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(e===\"state\")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 kd&&!this.hasWarnedStaleDecorationRead&&p0(this)&&(this.hasWarnedStaleDecorationRead=!0,console.warn(\"[tiptap warn]: `editor.state` was read while decoration `create()` was running. It returns the pre-transaction document. Use the `state` argument passed to `create()` instead. Helpers like `editor.isActive()` read `editor.state` too, so pass `state` to their standalone versions instead of calling them on the editor.\")),this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(t,e){let n=Cs(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(t){if(this.isDestroyed)return;let e=this.state.plugins,n=e;if([].concat(t).forEach(o=>{let i=typeof o==\"string\"?`${o}$`:o.key;n=n.filter(s=>!s.key.startsWith(i))}),e.length===n.length)return;let r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var t,e;let n=[...this.options.enableCoreExtensions?[q0,_0.configure({blockSeparator:(t=this.options.coreExtensionOptions)===null||t===void 0||(t=t.clipboardTextSerializer)===null||t===void 0?void 0:t.blockSeparator}),K0,X0,Y0,Z0.configure({value:(e=this.options.coreExtensionOptions)===null||e===void 0||(e=e.tabindex)===null||e===void 0?void 0:e.value}),J0,Q0,U0,eb.configure({direction:this.options.textDirection})].filter(r=>typeof this.options.enableCoreExtensions==\"object\"?this.options.enableCoreExtensions[r.name]!==!1:!0):[],...this.options.extensions].filter(r=>[\"extension\",\"node\",\"mark\"].includes(r?.type));this.extensionManager=new ro(n,this)}createCommandManager(){this.commandManager=new dn({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=xs(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;let n=xs(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1});return this.editorState=At.create({doc:n,schema:this.schema,selection:Ss(n,this.options.autofocus)||void 0}),this.emit(\"contentError\",{editor:this,error:e,disableCollaboration:()=>{\"collaboration\"in this.storage&&typeof this.storage.collaboration==\"object\"&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(r=>r.name!==\"collaboration\"),this.createExtensionManager()}}),this.editorState.doc}return t}getEditorViewAttributes(){var t;let e=(t=this.options.editorProps)===null||t===void 0?void 0:t.attributes;return Cs(e)?n=>({role:\"textbox\",...e(n)}):{role:\"textbox\",...e}}createView(t){let{editorProps:e,enableExtensionDispatchTransaction:n}=this.options,r=e.dispatchTransaction||this.dispatchTransaction.bind(this),o=n?this.extensionManager.dispatchTransaction(r):r,i=e.transformPastedHTML,s=this.extensionManager.transformPastedHTML(i);this.editorView=new _n(t,{...e,attributes:this.getEditorViewAttributes(),dispatchTransaction:o,transformPastedHTML:s,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});let l=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(l),this.prependClass(),this.injectCSS();let a=this.view.dom;a.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;let e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach(c=>{var u;return(u=this.capturedTransaction)===null||u===void 0?void 0:u.step(c)});return}let{state:e,transactions:n}=this.state.applyTransaction(t),r=!this.state.selection.eq(e.selection),o=n.includes(t),i=this.state;if(this.emit(\"beforeTransaction\",{editor:this,transaction:t,nextState:e}),!o)return;this.view.updateState(e),this.emit(\"transaction\",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),r&&this.emit(\"selectionUpdate\",{editor:this,transaction:t});let s=n.findLast(c=>c.getMeta(\"focus\")||c.getMeta(\"blur\")),l=s?.getMeta(\"focus\"),a=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(c=>c.docChanged)||i.doc.eq(e.doc))&&this.emit(\"update\",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return Rs(this.state,t)}isActive(t,e){let n=typeof t==\"string\"?t:null,r=typeof t==\"string\"?e:t;return Ly(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Ns(this.state.doc.content,this.schema)}getText(t){let{blockSeparator:e=`\n\n`,textSerializers:n={}}=t||{};return Oy(this.state.doc,{blockSeparator:e,textSerializers:{...ad(this.schema),...n}})}get isEmpty(){return gn(this.state.doc)}destroy(){this.destroyed||(this.destroyed=!0,this.emit(\"destroy\"),this.unmount(),this.removeAllListeners(),this.extensionManager.destroy(),this.extensionManager=null,this.schema=null,this.commandManager=null,this.extensionStorage={})}get isDestroyed(){var t,e;return(t=(e=this.editorView)===null||e===void 0?void 0:e.isDestroyed)!==null&&t!==void 0?t:!0}$node(t,e){var n;return((n=this.$doc)===null||n===void 0?void 0:n.querySelector(t,e))||null}$nodes(t,e){var n;return((n=this.$doc)===null||n===void 0?void 0:n.querySelectorAll(t,e))||null}$pos(t){let e=this.state.doc.resolve(t),n=t>0&&e.nodeAfter&&!e.nodeAfter.isText&&e.nodeAfter.isAtom?e.nodeAfter:null;return new nb(e,this,!1,n)}get $doc(){return this.$pos(0)}};function ze(t){return new yn({find:t.find,handler:({state:e,range:n,match:r})=>{let o=L(t.getAttributes,void 0,r);if(o===!1||o===null)return null;let{tr:i}=e,s=r[r.length-1],l=r[0];if(s){let a=l.search(/\\S/),c=n.from+l.indexOf(s),u=c+s.length;if(Qn(n.from,n.to,e.doc).filter(f=>f.mark.type.excluded.find(h=>h===t.type&&h!==f.mark.type)).filter(f=>f.to>c).length)return null;u<n.to&&i.delete(u,n.to),c>n.from&&i.delete(n.from+a,c);let d=n.from+a+s.length;i.addMark(n.from+a,d,t.type.create(o||{})),i.removeStoredMark(t.type)}},undoable:t.undoable})}function Od(t){return new yn({find:t.find,handler:({state:e,range:n,match:r})=>{let o=L(t.getAttributes,void 0,r)||{},{tr:i}=e,s=n.from,l=n.to,a=t.type.create(o);if(r[1]){let c=s+r[0].lastIndexOf(r[1]);c>l?c=l:l=c+r[1].length;let u=r[0][r[0].length-1];i.insertText(u,s+r[0].length-1),i.replaceWith(c,l,a)}else if(r[0]){let c=t.type.isInline?s:s-1;i.insert(c,t.type.create(o)).delete(i.mapping.map(s),i.mapping.map(l))}i.scrollIntoView()},undoable:t.undoable})}function Zn(t){return new yn({find:t.find,handler:({state:e,range:n,match:r})=>{let o=e.doc.resolve(n.from),i=L(t.getAttributes,void 0,r)||{};if(!o.node(-1).canReplaceWith(o.index(-1),o.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 bn(t){return new yn({find:t.find,handler:({state:e,range:n,match:r,chain:o})=>{let i=L(t.getAttributes,void 0,r)||{},s=e.tr.delete(n.from,n.to),l=s.doc.resolve(n.from).blockRange(),a=l&&Xt(l,t.type,i);if(!a)return null;if(s.wrap(l,a),t.keepMarks&&t.editor){let{selection:u,storedMarks:d}=e,{splittableMarks:f}=t.editor.extensionManager,h=d||u.$to.parentOffset&&u.$from.marks();if(h){let p=h.filter(m=>f.includes(m.type.name));s.ensureMarks(p)}}if(t.keepAttributes){let u=t.type.name===\"bulletList\"||t.type.name===\"orderedList\"?\"listItem\":\"taskList\";o().updateAttributes(u,i).run()}let c=s.doc.resolve(n.from-1).nodeBefore;c&&c.type===t.type&&Ne(s.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,c))&&s.join(n.from-1)},undoable:t.undoable})}var ob=t=>\"touches\"in t,Rd=class{constructor(t){var e,n,r,o,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=l=>{if(!this.isResizing||!this.activeHandle)return;let a=l.clientX-this.startX,c=l.clientY-this.startY;this.handleResize(a,c)},this.handleTouchMove=l=>{if(!this.isResizing||!this.activeHandle)return;let a=l.touches[0];if(!a)return;let c=a.clientX-this.startX,u=a.clientY-this.startY;this.handleResize(c,u)},this.handleMouseUp=()=>{if(!this.isResizing)return;let l=this.element.offsetWidth,a=this.element.offsetHeight;this.onCommit(l,a),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=l=>{l.key===\"Shift\"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=l=>{l.key===\"Shift\"&&(this.isShiftKeyPressed=!1)},this.node=t.node,this.editor=t.editor,this.element=t.element,this.element.draggable=!1,this.contentElement=t.contentElement,this.getPos=t.getPos,this.onResize=t.onResize,this.onCommit=t.onCommit,this.onUpdate=t.onUpdate,!((e=t.options)===null||e===void 0)&&e.min&&(this.minSize={...this.minSize,...t.options.min}),!((n=t.options)===null||n===void 0)&&n.max&&(this.maxSize=t.options.max),!(t==null||(r=t.options)===null||r===void 0)&&r.directions&&(this.directions=t.options.directions),!((o=t.options)===null||o===void 0)&&o.preserveAspectRatio&&(this.preserveAspectRatio=t.options.preserveAspectRatio),!((i=t.options)===null||i===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||\"\"}),!((s=t.options)===null||s===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(){var t;return(t=this.contentElement)!==null&&t!==void 0?t:null}handleEditorUpdate(){let t=this.editor.isEditable;t!==this.lastEditableState&&(this.lastEditableState=t,t?t&&this.handleMap.size===0&&this.attachHandles():this.removeHandles())}update(t,e,n){return t.type!==this.node.type?!1:(this.node=t,this.onUpdate?this.onUpdate(t,e,n):!0)}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(){let t=document.createElement(\"div\");return t.dataset.resizeContainer=\"\",t.dataset.node=this.node.type.name,t.style.display=this.node.type.isInline?\"inline-flex\":\"flex\",this.classNames.container&&(t.className=this.classNames.container),t.appendChild(this.wrapper),t}createWrapper(){let 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){let 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){let n=e.includes(\"top\"),r=e.includes(\"bottom\"),o=e.includes(\"left\"),i=e.includes(\"right\");n&&(t.style.top=\"0\"),r&&(t.style.bottom=\"0\"),o&&(t.style.left=\"0\"),i&&(t.style.right=\"0\"),(e===\"top\"||e===\"bottom\")&&(t.style.left=\"0\",t.style.right=\"0\"),(e===\"left\"||e===\"right\")&&(t.style.top=\"0\",t.style.bottom=\"0\")}attachHandles(){this.directions.forEach(t=>{let e;this.createCustomHandle?e=this.createCustomHandle(t):e=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\",n=>this.handleResizeStart(n,t)),e.addEventListener(\"touchstart\",n=>this.handleResizeStart(n,t)),this.handleMap.set(t,e),this.wrapper.appendChild(e)})}removeHandles(){this.handleMap.forEach(t=>t.remove()),this.handleMap.clear()}applyInitialSize(){let 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,ob(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;let n=this.preserveAspectRatio||this.isShiftKeyPressed,{width:r,height:o}=this.calculateNewDimensions(this.activeHandle,t,e),i=this.applyConstraints(r,o,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 r=this.startWidth,o=this.startHeight,i=t.includes(\"right\"),s=t.includes(\"left\"),l=t.includes(\"bottom\"),a=t.includes(\"top\");return i?r=this.startWidth+e:s&&(r=this.startWidth-e),l?o=this.startHeight+n:a&&(o=this.startHeight-n),(t===\"right\"||t===\"left\")&&(r=this.startWidth+(i?e:-e)),(t===\"top\"||t===\"bottom\")&&(o=this.startHeight+(l?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,o,t):{width:r,height:o}}applyConstraints(t,e,n){var r,o;if(!n){var i,s;let c=Math.max(this.minSize.width,t),u=Math.max(this.minSize.height,e);return!((i=this.maxSize)===null||i===void 0)&&i.width&&(c=Math.min(this.maxSize.width,c)),!((s=this.maxSize)===null||s===void 0)&&s.height&&(u=Math.min(this.maxSize.height,u)),{width:c,height:u}}let l=t,a=e;return l<this.minSize.width&&(l=this.minSize.width,a=l/this.aspectRatio),a<this.minSize.height&&(a=this.minSize.height,l=a*this.aspectRatio),!((r=this.maxSize)===null||r===void 0)&&r.width&&l>this.maxSize.width&&(l=this.maxSize.width,a=l/this.aspectRatio),!((o=this.maxSize)===null||o===void 0)&&o.height&&a>this.maxSize.height&&(a=this.maxSize.height,l=a*this.aspectRatio),{width:l,height:a}}applyAspectRatio(t,e,n){let r=n===\"left\"||n===\"right\",o=n===\"top\"||n===\"bottom\";return r?{width:t,height:t/this.aspectRatio}:o?{width:e*this.aspectRatio,height:e}:{width:t,height:t/this.aspectRatio}}};var K=class Dd extends Ls{constructor(...e){super(...e),this.type=\"node\"}static create(e={}){let n=typeof e==\"function\"?e():e;return new Dd(n)}configure(e){return super.configure(e)}extend(e){let n=typeof e==\"function\"?e():e;return super.extend(n)}};function Re(t){return new $s({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:o})=>{let i=L(t.getAttributes,void 0,r,o);if(i===!1||i===null)return null;let{tr:s}=e,l=r[r.length-1],a=r[0],c=n.to;if(l){let u=a.search(/\\S/),d=n.from+a.indexOf(l),f=d+l.length;if(Qn(n.from,n.to,e.doc).filter(h=>h.mark.type.excluded.find(p=>p===t.type&&p!==h.mark.type)).filter(h=>h.to>d).length)return null;f<n.to&&s.delete(f,n.to),d>n.from&&s.delete(n.from+u,d),c=n.from+u+l.length,s.addMark(n.from+u,c,t.type.create(i||{})),r.index!==void 0&&r.input!==void 0&&r.index+r[0].length>=r.input.length||s.removeStoredMark(t.type)}}})}var Id=K.create({name:\"doc\",topNode:!0,content:\"block+\",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`\n\n`):\"\"});var oo=\"&nbsp;\",zs=\"\\xA0\",Pd=K.create({name:\"paragraph\",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:\"block\",content:\"inline*\",parseHTML(){return[{tag:\"p\"}]},renderHTML({HTMLAttributes:t}){return[\"p\",B(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{let n=t.tokens||[];if(n.length===1&&n[0].type===\"image\")return e.parseChildren([n[0]]);let r=e.parseInline(n);return n.length===1&&n[0].type===\"text\"&&(n[0].raw===oo||n[0].text===oo||n[0].raw===zs||n[0].text===zs)&&r.length===1&&r[0].type===\"text\"&&(r[0].text===oo||r[0].text===zs)?e.createNode(\"paragraph\",void 0,[]):e.createNode(\"paragraph\",void 0,r)},renderMarkdown:(t,e,n)=>{if(!t)return\"\";let r=Array.isArray(t.content)?t.content:[];if(r.length===0){var o,i;let s=Array.isArray(n==null||(o=n.previousNode)===null||o===void 0?void 0:o.content)?n.previousNode.content:[];return(n==null||(i=n.previousNode)===null||i===void 0?void 0:i.type)===\"paragraph\"&&s.length===0?oo:\"\"}return e.renderChildren(r)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{\"Mod-Alt-0\":()=>this.editor.commands.setParagraph()}}});var Ld=K.create({name:\"text\",group:\"inline\",parseMarkdown:t=>({type:\"text\",text:t.text||\"\"}),renderMarkdown:t=>t.text||\"\"});var $d=new WeakSet,zd=new WeakSet;function Ht(t){let e=t;return $d.add(e),e}function Bs(t){return Array.isArray(t)&&$d.has(t)}function Bd(t){return t.flatMap(e=>e==null?[]:Array.isArray(e)&&zd.has(e)&&!Bs(e)?Bd(e):[e])}function ib(t,e){if(t===\"slot\")return 0;if(t instanceof Function){let o=t(e);return Array.isArray(o)&&!Bs(o)&&!zd.has(o)?Ht(o):o}let{children:n,...r}=e??{};if(t===\"svg\")throw new Error(\"SVG elements are not supported in the JSX syntax, use the array syntax instead\");if(Array.isArray(n)){if(Bs(n))return Ht([t,r,n]);if(n.length===0)return Ht([t,r]);let o=Bd(n);return o.length===0?Ht([t,r]):Ht([t,r,...o])}return n!=null?Ht([t,r,n]):Ht([t,r])}var Fs=(t,e)=>ib(t,e);var sb=/(?:^|\\s)(\\*\\*(?!\\s+\\*\\*)((?:[^*]+))\\*\\*(?!\\s+\\*\\*))$/,lb=/(?:^|\\s)(\\*\\*(?!\\s+\\*\\*)((?:[^*]+))\\*\\*(?!\\s+\\*\\*))/g,ab=/(?:^|\\s)(__(?!\\s+__)((?:[^_]+))__(?!\\s+__))$/,cb=/(?:^|\\s)(__(?!\\s+__)((?:[^_]+))__(?!\\s+__))/g,Fd=Ze.create({name:\"bold\",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:\"strong\"},{tag:\"b\",getAttrs:t=>t.style.fontWeight!==\"normal\"&&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 Fs(\"strong\",{...B(this.options.HTMLAttributes,t),children:Fs(\"slot\",{})})},markdownTokenName:\"strong\",parseMarkdown:(t,e)=>e.applyMark(\"bold\",e.parseInline(t.tokens||[])),markdownOptions:{htmlReopen:{open:\"<strong>\",close:\"</strong>\"}},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[ze({find:sb,type:this.type}),ze({find:ab,type:this.type})]},addPasteRules(){return[Re({find:lb,type:this.type}),Re({find:cb,type:this.type})]}});var ub=/(?:^|\\s)(\\*(?!\\s+\\*)((?:[^*]+))\\*(?!\\s+\\*))$/,db=/(?:^|\\s)(\\*(?!\\s+\\*)((?:[^*]+))\\*(?!\\s+\\*))/g,fb=/(?:^|\\s)(_(?!\\s+_)((?:[^_]+))_(?!\\s+_))$/,hb=/(?:^|\\s)(_(?!\\s+_)((?:[^_]+))_(?!\\s+_))/g,Hd=Ze.create({name:\"italic\",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:\"em\"},{tag:\"i\",getAttrs:t=>t.style.fontStyle!==\"normal\"&&null},{style:\"font-style=normal\",clearMark:t=>t.type.name===this.name},{style:\"font-style=italic\"}]},renderHTML({HTMLAttributes:t}){return[\"em\",B(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||[])),markdownOptions:{htmlReopen:{open:\"<em>\",close:\"</em>\"}},renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{\"Mod-i\":()=>this.editor.commands.toggleItalic(),\"Mod-I\":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[ze({find:ub,type:this.type}),ze({find:fb,type:this.type})]},addPasteRules(){return[Re({find:db,type:this.type}),Re({find:hb,type:this.type})]}});var pb=t=>{let e=/`([^`]+)`(?!`)$/.exec(t);return!e||e.index>0&&t[e.index-1]===\"`\"?null:{index:e.index,text:e[0],replaceWith:e[1]}},mb=t=>{let e=/`([^`]+)`(?!`)/g,n=[],r;for(;(r=e.exec(t))!==null;)r.index>0&&t[r.index-1]===\"`\"||n.push({index:r.index,text:r[0],replaceWith:r[1]});return n};function gb(t){let e=new Set((t.match(/`+/g)||[]).map(r=>r.length)),n=1;for(;e.has(n);)n+=1;return n}var jd=Ze.create({name:\"code\",addOptions(){return{HTMLAttributes:{}}},excludes:\"_\",code:!0,exitable:!0,parseHTML(){return[{tag:\"code\"}]},renderHTML({HTMLAttributes:t}){return[\"code\",B(this.options.HTMLAttributes,t),0]},markdownTokenName:\"codespan\",parseMarkdown:(t,e)=>e.applyMark(\"code\",[{type:\"text\",text:t.text||\"\"}]),renderMarkdown:(t,e,n)=>{var r;if(!t.content)return\"\";let o=typeof(n==null||(r=n.meta)===null||r===void 0?void 0:r.markText)==\"string\"?n.meta.markText:\"\",i=\"`\".repeat(gb(o)),s=o.startsWith(\"`\")||o.endsWith(\"`\")?\" \":\"\";return`${i}${s}${e.renderChildren(t.content)}${s}${i}`},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[ze({find:pb,type:this.type})]},addPasteRules(){return[Re({find:mb,type:this.type})]}});var Wd=K.create({name:\"heading\",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:\"inline*\",group:\"block\",defining:!0,addAttributes(){return{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]}`,B(this.options.HTMLAttributes,e),0]},parseMarkdown(t,e){let n=t.depth||1;return this.options.levels.includes(n)?e.createNode(\"heading\",{level:n},e.parseInline(t.tokens||[])):e.createNode(\"paragraph\",void 0,e.parseInline(t.tokens||[]))},renderMarkdown:(t,e)=>{var n;let r=!((n=t.attrs)===null||n===void 0)&&n.level?parseInt(t.attrs.level,10):1,o=\"#\".repeat(r);return t.content?`${o} ${e.renderChildren(t.content)}`:\"\"},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,\"paragraph\",t):!1}},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=>Zn({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\\\s$`),type:this.type,getAttributes:{level:t}}))}});var yb=\"listItem\",Vd=\"textStyle\",_d=/^\\s*([-+*])\\s$/,Hs=K.create({name:\"bulletList\",addOptions(){return{itemTypeName:\"listItem\",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:\"block list\",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:\"ul\"}]},renderHTML({HTMLAttributes:t}){return[\"ul\",B(this.options.HTMLAttributes,t),0]},markdownTokenName:\"list\",parseMarkdown:(t,e)=>t.type!==\"list\"||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(yb,this.editor.getAttributes(Vd)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{\"Mod-Shift-8\":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=bn({find:_d,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=bn({find:_d,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Vd),editor:this.editor})),[t]}}),bb=(t,e,n)=>{let{selection:r}=t;if(!r.empty)return null;let{$from:o}=r;if(!o.parent.isTextblock||o.parentOffset!==o.parent.content.size)return null;let i=-1;for(let h=o.depth;h>0;h-=1)if(o.node(h).type.name===e){i=h;break}if(i<0)return null;let s=o.node(i),l=o.index(i);if(l+1>=s.childCount)return null;let a=s.child(l+1);if(!n.includes(a.type.name))return null;let c=t.schema.nodes[e],u=!1;if(a.forEach(h=>{h.type===c&&h.childCount>1&&(u=!0)}),!u)return null;let d=t.doc.resolve(o.after()).nodeAfter;if(!d||!n.includes(d.type.name))return null;let f=[];return d.forEach(h=>{f.push(h)}),f.length===0?null:{listItemDepth:i,nestedList:d,nestedListPos:o.after(),insertPos:o.after(i),items:f}},kb=(t,e,n,r)=>{let o=bb(t,n,r);if(!o)return!1;let{selection:i}=t,{nestedList:s,nestedListPos:l,insertPos:a,items:c}=o,u=t.tr;u.delete(l,l+s.nodeSize);let d=u.mapping.map(a);return u.insert(d,b.from(c)),u.setSelection(i.map(u.doc,u.mapping)),e&&e(u),!0},wb=(t,e,n)=>kb(t.state,t.view.dispatch,e,n),Zd=(t,e)=>V.create({name:`${t}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){let n=()=>wb(this.editor,t,e);return{Delete:n,\"Mod-Delete\":n}}}),ef=[[1e3,\"m\"],[900,\"cm\"],[500,\"d\"],[400,\"cd\"],[100,\"c\"],[90,\"xc\"],[50,\"l\"],[40,\"xl\"],[10,\"x\"],[9,\"ix\"],[5,\"v\"],[4,\"iv\"],[1,\"i\"]],io=\"abcdefghijklmnopqrstuvwxyz\",tf=String.raw`\\d+|[ivxlcdmIVXLCDM]+|${\"[a-zA-Z]{1,2}\"}`;function ao(t){let e=t,n=\"\";for(let[r,o]of ef)for(;e>=r;)n+=o,e-=r;return n}function js(t){return ao(t).toUpperCase()}function nf(t){let e=t.toLowerCase(),n=0,r=0;for(;n<e.length;){let o=!1;for(let[i,s]of ef)if(e.startsWith(s,n)){r+=i,n+=s.length,o=!0;break}if(!o)return 0}return r}function Sb(t){if(!/^[ivxlcdmIVXLCDM]+$/.test(t))return!1;let e=nf(t);return e<=0?!1:(t===t.toLowerCase()?ao(e):js(e))===t}function xb(t){let e=t.toLowerCase();if(e.length===1)return e.charCodeAt(0)-97+1;if(e.length===2){let n=e.charCodeAt(0)-97,r=e.charCodeAt(1)-97;return(n+1)*26+r+1}return 0}function so(t){if(t<=26)return io[t-1];let e=Math.floor((t-1)/26)-1,n=(t-1)%26;return e<0?io[n]:io[e]+io[n]}function co(t){if(!(!t||/^\\d+$/.test(t))){if(Sb(t))return t===t.toLowerCase()?\"i\":\"I\";if(/^[a-z]{1,2}$/.test(t))return\"a\";if(/^[A-Z]{1,2}$/.test(t))return\"A\"}}function Ws(t){if(/^\\d+$/.test(t))return parseInt(t,10);let e=co(t);if(e===\"i\"||e===\"I\")return nf(t);if(e===\"a\"||e===\"A\"){let r=xb(t);return r>0?r:1}let n=parseInt(t,10);return Number.isNaN(n)?1:n}function Cb(t,e){if(t===\"numeric\")return String(e);switch(t){case\"a\":return so(e);case\"A\":return so(e).toUpperCase();case\"i\":return ao(e);case\"I\":return js(e);default:return String(e)}}function Mb(t){var e;if(t.length===0)return!1;let n=(e=co(t[0]))!==null&&e!==void 0?e:\"numeric\",r=Ws(t[0]);if(r<1)return!1;for(let o=0;o<t.length;o++){let i=Cb(n,r+o);if(t[o]!==i)return!1}return!0}function vb(t){return{type:co(t),start:Ws(t)}}function Eb(t){let{type:e,start:n}=vb(t),r={};return e&&(r.type=e),n!==1&&(r.start=n),r}function Ab(t,e,n=\". \"){let r=e+1;if(!t||t===\"1\")return`${r}${n}`;switch(t){case\"a\":return`${so(r)}${n}`;case\"A\":return`${so(r).toUpperCase()}${n}`;case\"i\":return`${ao(r)}${n}`;case\"I\":return`${js(r)}${n}`;default:return`${r}${n}`}}function Tb(t){return!t[0]||t[0].type===\"paragraph\"?t:[{type:\"paragraph\",content:[]},...t]}function Nb(t){var e,n;let r=(e=t.content)===null||e===void 0?void 0:e[0];return r?.type===\"paragraph\"&&!(!((n=r.content)===null||n===void 0)&&n.length)}var Ob=\"&nbsp;\",Kd=1,Rb=t=>{var e;return((e=t?.level)!==null&&e!==void 0?e:Kd)>Kd};function Db(t){var e,n;let r=(e=t.tokens)===null||e===void 0?void 0:e[0];return!!(t.text&&((n=t.tokens)===null||n===void 0?void 0:n.length)===1&&r?.type===\"list\"&&r.ordered&&r.raw===t.text)}function Ib(t,e){return e.tokenizeInline?e.parseInline(e.tokenizeInline(t)):e.parseInline([{type:\"text\",raw:t,text:t}])}var Vs=K.create({name:\"listItem\",addOptions(){return{HTMLAttributes:{},bulletListTypeName:\"bulletList\",orderedListTypeName:\"orderedList\"}},content:\"paragraph block*\",defining:!0,parseHTML(){return[{tag:\"li\"}]},renderHTML({HTMLAttributes:t}){return[\"li\",B(this.options.HTMLAttributes,t),0]},markdownTokenName:\"list_item\",parseMarkdown:(t,e)=>{var n;if(t.type!==\"list_item\")return[];let r=(n=e.parseBlockChildren)!==null&&n!==void 0?n:e.parseChildren,o=[];if(t.tokens&&t.tokens.length>0){if(Db(t))return{type:\"listItem\",content:[{type:\"paragraph\",content:Ib(t.text||\"\",e)}]};let[s,...l]=t.tokens;if(s.type===\"heading\"){var i;return{type:\"listItem\",content:[{type:\"paragraph\",content:e.parseInline((i=s.tokens)!==null&&i!==void 0?i:[])},...l.length>0?r(l):[]]}}if(t.tokens.some(a=>a.type===\"paragraph\"))o=r(t.tokens);else if(s.type===\"text\"&&s.tokens&&s.tokens.length>0){if(o=[{type:\"paragraph\",content:e.parseInline(s.tokens)}],t.tokens.length>1){let a=r(t.tokens.slice(1));o.push(...a)}}else o=r(t.tokens)}return o.length===0&&(o=[{type:\"paragraph\",content:[]}]),{type:\"listItem\",content:Tb(o)}},renderMarkdown:(t,e,n)=>{let r=s=>{if(s.parentType===\"bulletList\")return\"- \";if(s.parentType===\"orderedList\"){var l,a;let c=((l=s.meta)===null||l===void 0||(l=l.parentAttrs)===null||l===void 0?void 0:l.start)||1;return Ab((a=s.meta)===null||a===void 0||(a=a.parentAttrs)===null||a===void 0?void 0:a.type,c-1+(s.index||0),\". \")}return\"- \"},o=Ps(t,e,r,n,{alignNestedToPrefix:n?.parentType===\"orderedList\"});if(!Nb(t)||!Rb(n))return o;let i=r(n);return`${i}${Ob}${o.slice(i.length)}`},addExtensions(){return[Zd(this.name,[this.options.bulletListTypeName,this.options.orderedListTypeName])]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),\"Shift-Tab\":()=>this.editor.commands.liftListItem(this.name)}}}),_s=(t,e)=>{let{$from:n}=e.selection,r=Q(t,e.schema),o=null,i=n.depth,s=n.pos,l=null;for(;i>0&&l===null;)o=n.node(i),o.type===r?l=i:(i-=1,s-=1);return l===null?null:{$pos:e.doc.resolve(s),depth:l}},rf=(t,e)=>{let n=_s(t,e);if(!n)return!1;let[,r]=cd(e,t,n.$pos.pos+4);return r},Pb=(t,e,n)=>{let{$anchor:r}=t.selection,o=Math.max(0,r.pos-2),i=t.doc.resolve(o).node();return!(!i||!n.includes(i.type.name))},Ud=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!$e(t.state,e)&&Pb(t.state,e,n)){let{$anchor:i}=t.state.selection,s=t.state.doc.resolve(i.before()-1),l=[];s.node().descendants((u,d)=>{u.type.name===e&&l.push({node:u,pos:d})});let a=l.at(-1);if(!a)return!1;let c=t.state.doc.resolve(s.start()+a.pos+1);return t.chain().command(({tr:u})=>{let d=c.end();return u.delete(i.before(),i.after()).insert(d,i.parent),u.setSelection(M.create(u.doc,d+1)),!0}).command(({state:u,dispatch:d})=>(Ar(u,d),!0)).run()}if(!$e(t.state,e)||!fd(t.state))return!1;let{$from:r}=t.state.selection,o=r.depth-1;return r.node(o).type!==t.schema.nodes[e]||r.index(o)!==0?!1:t.chain().liftListItem(e).run()},Lb=(t,e)=>{let n=rf(t,e),r=_s(t,e);return!r||!n?!1:n>r.depth},$b=(t,e)=>{let n=rf(t,e),r=_s(t,e);return!r||!n?!1:n<r.depth},Jd=(t,e)=>!$e(t.state,e)||!dd(t.state,e)||!t.state.selection.empty?!1:Lb(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():$b(e,t.state)?t.commands.command(({state:n,dispatch:r})=>Tr(n,r)):t.commands.joinItemForward(),zb=(t,e,n)=>{let{state:r}=t,{selection:o}=r;if(!o.empty)return!1;let{$from:i}=o;if(i.parentOffset!==0||!i.parent.isTextblock||$e(r,e))return!1;let s=ud(i);if(!s||!n.includes(s.type.name))return!1;let l=s.lastChild;if(!l||l.type.name!==e)return!1;let a=i.parent;if(!l.canReplace(l.childCount,l.childCount,b.from(a)))return!1;let c=i.before(),u=i.after(),d=c-2;return t.commands.command(({tr:f,dispatch:h})=>(h&&(f.delete(c,u).insert(d,b.from(a)),f.setSelection(M.create(f.doc,d+1)),f.scrollIntoView()),!0))};var Ks=V.create({name:\"listKeymap\",addOptions(){return{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})=>{t.state.schema.nodes[n]!==void 0&&Jd(t,n)&&(e=!0)}),e},\"Mod-Delete\":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&Jd(t,n)&&(e=!0)}),e},Backspace:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&Ud(t,n,r)&&(e=!0)}),e},\"Mod-Backspace\":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&Ud(t,n,r)&&(e=!0)}),e},Tab:({editor:t})=>{for(let{itemName:e,wrapperNames:n}of this.options.listTypes)if(t.state.schema.nodes[e]!==void 0&&zb(t,e,n))return!0;return!1}}}}),lo=new RegExp(`^(\\\\s*)(${tf})([.)])\\\\s+(.*)$`),Bb=/^\\s/,kn={heading:/^#{1,6}(?:\\s|$)/,bulletItem:/^[-+*]\\s+/,codeFence:/^(?:```|~~~)/,blockMath:/^\\$\\$/,thematicBreak:/^(?:(?:-[ \\t]*){3,}|(?:_[ \\t]*){3,}|(?:\\*[ \\t]*){3,})$/};function Fb(t){return lo.test(t.trimStart())}function Hb(t){let e=t.trimStart();return kn.bulletItem.test(e)||Fb(e)||kn.heading.test(e)||kn.thematicBreak.test(e)&&!e.startsWith(\"-\")||/^>\\s?/.test(e)||kn.codeFence.test(e)||kn.blockMath.test(e)}function jb(t){return Object.values(kn).some(e=>e.test(t))}function Wb(t){let e=[],n=[],r=!1;return t.forEach(o=>{if(r){n.push(o);return}if(o.trim()===\"\"){r=!0,n.push(o);return}if(e.length>0&&Hb(o)){r=!0,n.push(o);return}e.push(o)}),{paragraphLines:e,blockLines:n}}function qd(t){let e=[],n=0,r=0;for(;n<t.length;){let o=t[n],i=o.match(lo);if(!i)break;let[,s,l,a,c]=i,u=s.length,d=parseInt(l,10),f=isNaN(d)?co(l):void 0,h=isNaN(d)?Ws(l):d,p=[c],m=n+1,g=[o],y=!1;for(;m<t.length;){let S=t[m];if(S.match(lo))break;if(S.trim()===\"\")g.push(S),p.push(\"\"),y=!0,m+=1;else if(S.match(Bb)){let k=S.length-S.trimStart().length,x=u+l.length+1;g.push(S),p.push(S.slice(Math.min(k,x))),m+=1}else{if(y||jb(S))break;g.push(S),p.push(S),m+=1}}e.push({indent:u,number:h,type:f,content:p.join(`\n`).trim(),contentLines:p,raw:g.join(`\n`)}),r=m,n=m}return[e,r]}var Vb=new RegExp(`^(${tf})([.)])\\\\s+(.+)$`);function _b(t){let e=t.split(`\n`).filter(r=>r.trim().length>0);if(e.length===0)return null;let n=[];for(let r of e){let o=r.trim().match(Vb);if(!o)return null;n.push({marker:o[1],content:o[3]})}return Mb(n.map(r=>r.marker))?{type:\"orderedList\",attrs:Eb(n[0].marker),content:n.map(r=>({type:\"listItem\",content:[{type:\"paragraph\",content:[{type:\"text\",text:r.content}]}]}))}:null}function of(t,e,n){let r=[],o=0;for(;o<t.length;){let i=t[o];if(i.indent===e){let{paragraphLines:s,blockLines:l}=Wb(i.contentLines),a=s.join(`\n`).trim(),c=[];a&&c.push({type:\"paragraph\",raw:a,tokens:n.inlineTokens(a)});let u=l.join(`\n`).trim();if(u){let h=n.blockTokens(u);c.push(...h)}let d=o+1,f=[];for(;d<t.length&&t[d].indent>e;)f.push(t[d]),d+=1;if(f.length>0){let h=of(f,Math.min(...f.map(p=>p.indent)),n);c.push({type:\"list\",ordered:!0,start:f[0].number,typeMarker:f[0].type,items:h,raw:f.map(p=>p.raw).join(`\n`)})}r.push({type:\"list_item\",raw:i.raw,tokens:c}),o=d}else o+=1}return r}function Kb(t,e){return t.map(n=>{if(n.type!==\"list_item\")return e.parseChildren([n])[0];let r=[];return n.tokens&&n.tokens.length>0&&n.tokens.forEach(o=>{if(o.type===\"paragraph\"||o.type===\"list\"||o.type===\"blockquote\"||o.type===\"code\")r.push(...e.parseChildren([o]));else if(o.type===\"text\"&&o.tokens){let i=e.parseChildren([o]);r.push({type:\"paragraph\",content:i})}else{let i=e.parseChildren([o]);i.length>0&&r.push(...i)}}),{type:\"listItem\",content:r}})}var Ub=64;function Gd(t,e){let n=[],r=0;for(;n.length<e;){let o=t.indexOf(`\n`,r);if(o===-1)return n.push(t.slice(r)),n;n.push(t.slice(r,o)),r=o+1}return n}function Jb(t){let e=t.indexOf(`\n`),n=e===-1?t:t.slice(0,e);if(!lo.test(n))return[[],0,[]];let r=Ub,o=Gd(t,r),i=qd(o);for(;i[1]===o.length&&o.length===r;)r*=2,o=Gd(t,r),i=qd(o);return[i[0],i[1],o]}var qb=\"listItem\",Xd=\"textStyle\",Yd=/^(\\d+)\\.\\s$/;function Qd(t){let e=t.match(/list-style-type\\s*:\\s*([^;]+)/i);if(!e)return null;switch(e[1].trim().toLowerCase()){case\"upper-roman\":return\"I\";case\"lower-roman\":return\"i\";case\"upper-alpha\":case\"upper-latin\":return\"A\";case\"lower-alpha\":case\"lower-latin\":return\"a\";default:return null}}var Us=K.create({name:\"orderedList\",addOptions(){return{itemTypeName:\"listItem\",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:\"block list\",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute(\"start\")?parseInt(t.getAttribute(\"start\")||\"\",10):1},type:{default:null,parseHTML:t=>{let e=t.getAttribute(\"type\");if(e)return e;let n=t.getAttribute(\"style\");if(n){let o=Qd(n);if(o)return o}let r=t.querySelector(\"li\");if(r){let o=r.getAttribute(\"style\");if(o){let i=Qd(o);if(i)return i}}return null}}}},parseHTML(){return[{tag:\"ol\"}]},renderHTML({HTMLAttributes:t}){let{start:e,type:n,...r}=t,o=B(this.options.HTMLAttributes,r);return e!==1&&(o.start=e),n&&n!==\"1\"&&(o.type=n),[\"ol\",o,0]},markdownTokenName:\"list\",parseMarkdown:(t,e)=>{if(t.type!==\"list\"||!t.ordered)return[];let n=t.start||1,r=t.typeMarker,o=t.items?Kb(t.items,e):[],i={};return n!==1&&(i.start=n),r&&(i.type=r),Object.keys(i).length>0?{type:\"orderedList\",attrs:i,content:o}:{type:\"orderedList\",content:o}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`\n`):\"\",markdownTokenizer:{name:\"orderedList\",level:\"block\",start:()=>-1,tokenize:(t,e,n)=>{var r,o;let[i,s,l]=Jb(t);if(i.length===0)return;let a=of(i,i[0].indent,n);if(a.length!==0)return{type:\"list\",ordered:!0,start:((r=i[0])===null||r===void 0?void 0:r.number)||1,typeMarker:(o=i[0])===null||o===void 0?void 0:o.type,items:a,raw:l.slice(0,s).join(`\n`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(qb,this.editor.getAttributes(Xd)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{\"Mod-Shift-7\":()=>this.editor.commands.toggleOrderedList()}},addProseMirrorPlugins(){return[new R({props:{handlePaste:(t,e)=>{var n,r;let o=(n=e.clipboardData)===null||n===void 0?void 0:n.getData(\"text/html\");if(o?.trim())return!1;let i=(r=e.clipboardData)===null||r===void 0?void 0:r.getData(\"text/plain\");if(!i)return!1;let s=_b(i);if(!s)return!1;try{let l=t.state.schema.nodeFromJSON(s),a=t.state.tr.replaceSelectionWith(l);return t.dispatch(a),!0}catch{return!1}}}})]},addInputRules(){let t=(n,r)=>(!r.attrs.type||r.attrs.type===\"1\")&&r.childCount+r.attrs.start===+n[1],e=bn({find:Yd,type:this.type,getAttributes:n=>({start:+n[1]}),joinPredicate:t});return(this.options.keepMarks||this.options.keepAttributes)&&(e=bn({find:Yd,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:n=>({start:+n[1],...this.editor.getAttributes(Xd)}),joinPredicate:t,editor:this.editor})),[e]}}),Gb=/^\\s*(\\[([( |x])?\\])\\s$/,Xb=\"position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0\",Yb=(t,e,n)=>{var r;return(n==null||(r=n.checkboxLabel)===null||r===void 0?void 0:r.call(n,t,e))||`Task item checkbox for ${t.textContent||\"empty task item\"}`},Qb=K.create({name:\"taskItem\",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:\"taskList\",a11y:void 0}},content(){return this.options.nested?\"paragraph block*\":\"paragraph+\"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:t=>{let e=t.getAttribute(\"data-checked\");return e===\"\"||e===\"true\"},renderHTML:t=>({\"data-checked\":t.checked})}}},parseHTML(){return[{tag:`li[data-type=\"${this.name}\"]`,priority:51,contentElement:t=>{var e;return(e=t.querySelector(\"div\"))!==null&&e!==void 0?e:t}}]},renderHTML({node:t,HTMLAttributes:e}){return[\"li\",B(this.options.HTMLAttributes,e,{\"data-type\":this.name}),[\"label\",[\"input\",{type:\"checkbox\",checked:t.attrs.checked?\"checked\":null}],[\"span\"]],[\"div\",0]]},parseMarkdown:(t,e)=>{let 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){let r=e.parseChildren(t.nestedTokens);n.push(...r)}return e.createNode(\"taskItem\",{checked:t.checked||!1},n)},renderMarkdown:(t,e)=>{var n;let r=`- [${!((n=t.attrs)===null||n===void 0)&&n.checked?\"x\":\" \"}] `;return Ps(t,e,r,void 0,{indentMainContent:!0})},addExtensions(){return this.options.nested?[Zd(this.name,[this.options.taskListTypeName])]:[]},addKeyboardShortcuts(){let 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:r})=>{let o=document.createElement(\"li\"),i=document.createElement(\"label\"),s=document.createElement(\"span\"),l=document.createElement(\"input\"),a=document.createElement(\"div\");s.style.cssText=Xb;let c=d=>{let f=Yb(d,d.attrs.checked,this.options.a11y);l.setAttribute(\"aria-label\",f),s.textContent=f};c(t),i.contentEditable=\"false\",l.type=\"checkbox\",l.addEventListener(\"mousedown\",d=>d.preventDefault()),l.addEventListener(\"change\",d=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}let{checked:f}=d.target;r.isEditable&&typeof n==\"function\"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:h})=>{let p=n();if(typeof p!=\"number\")return!1;let m=h.doc.nodeAt(p);return h.setNodeMarkup(p,void 0,{...m?.attrs,checked:f}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,f)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([d,f])=>{o.setAttribute(d,f)}),o.dataset.checked=t.attrs.checked,l.checked=t.attrs.checked,i.append(l,s),o.append(i,a),Object.entries(e).forEach(([d,f])=>{o.setAttribute(d,f)});let u=new Set(Object.keys(e));return{dom:o,contentDOM:a,update:d=>{if(d.type!==this.type)return!1;o.dataset.checked=d.attrs.checked,l.checked=d.attrs.checked,c(d);let f=r.extensionManager.attributes,h=pt(d,f),p=new Set(Object.keys(h)),m=this.options.HTMLAttributes;return u.forEach(g=>{p.has(g)||(g in m?o.setAttribute(g,m[g]):o.removeAttribute(g))}),Object.entries(h).forEach(([g,y])=>{y==null?g in m?o.setAttribute(g,m[g]):o.removeAttribute(g):o.setAttribute(g,y)}),u=p,!0}}}},addInputRules(){return[bn({find:Gb,type:this.type,getAttributes:t=>({checked:t[t.length-1]===\"x\"})})]}}),Zb=K.create({name:\"taskList\",addOptions(){return{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\",B(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;let n=(e=t.match(/^\\s*[-+*]\\s+\\[([ xX])\\]\\s+/))===null||e===void 0?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){let r=i=>{let s=Is(i,{itemPattern:/^(\\s*)([-+*])\\s+\\[([ xX])\\]\\s+(.*)$/,extractItemData:l=>({indentLevel:l[1].length,mainContent:l[4],checked:l[3].toLowerCase()===\"x\"}),createToken:(l,a)=>({type:\"taskItem\",raw:\"\",mainContent:l.mainContent,indentLevel:l.indentLevel,checked:l.checked,text:l.mainContent,tokens:n.inlineTokens(l.mainContent),nestedTokens:a}),customNestedParser:r},n);if(s){let l={type:\"taskList\",raw:s.raw,items:s.items},a=i.slice(s.raw.length);return a.trim()?[l,...n.blockTokens(a)]:[l]}return n.blockTokens(i)},o=Is(t,{itemPattern:/^(\\s*)([-+*])\\s+\\[([ xX])\\]\\s+(.*)$/,extractItemData:i=>({indentLevel:i[1].length,mainContent:i[4],checked:i[3].toLowerCase()===\"x\"}),createToken:(i,s)=>({type:\"taskItem\",raw:\"\",mainContent:i.mainContent,indentLevel:i.indentLevel,checked:i.checked,text:i.mainContent,tokens:n.inlineTokens(i.mainContent),nestedTokens:s}),customNestedParser:r},n);if(o)return{type:\"taskList\",raw:o.raw,items:o.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()}}}),vx=V.create({name:\"listKit\",addExtensions(){let t=[];return this.options.bulletList!==!1&&t.push(Hs.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(Vs.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(Ks.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(Us.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(Qb.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(Zb.configure(this.options.taskList)),t}});var ek=\"aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos6kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5m\\xF6gensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12b0cam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2\",tk=\"\\u03B5\\u03BB1\\u03C52\\u0431\\u04331\\u0435\\u043B3\\u0434\\u0435\\u0442\\u04384\\u0435\\u044E2\\u043A\\u0430\\u0442\\u043E\\u043B\\u0438\\u043A6\\u043E\\u043C3\\u043C\\u043A\\u04342\\u043E\\u043D1\\u0441\\u043A\\u0432\\u04306\\u043E\\u043D\\u043B\\u0430\\u0439\\u043D5\\u0440\\u04333\\u0440\\u0443\\u04412\\u04442\\u0441\\u0430\\u0439\\u04423\\u0440\\u04313\\u0443\\u043A\\u04403\\u049B\\u0430\\u04373\\u0570\\u0561\\u05753\\u05D9\\u05E9\\u05E8\\u05D0\\u05DC5\\u05E7\\u05D5\\u05DD3\\u0627\\u0628\\u0648\\u0638\\u0628\\u064A5\\u0631\\u0627\\u0645\\u0643\\u06485\\u0644\\u0627\\u0631\\u062F\\u06464\\u0628\\u062D\\u0631\\u064A\\u06465\\u062C\\u0632\\u0627\\u0626\\u06315\\u0633\\u0639\\u0648\\u062F\\u064A\\u06296\\u0639\\u0644\\u064A\\u0627\\u06465\\u0645\\u063A\\u0631\\u06285\\u0645\\u0627\\u0631\\u0627\\u062A5\\u06CC\\u0631\\u0627\\u06465\\u0628\\u0627\\u0631\\u062A2\\u0632\\u0627\\u06314\\u064A\\u062A\\u06433\\u06BE\\u0627\\u0631\\u062A5\\u062A\\u0648\\u0646\\u06334\\u0633\\u0648\\u062F\\u0627\\u06463\\u0631\\u064A\\u06295\\u0634\\u0628\\u0643\\u06294\\u0639\\u0631\\u0627\\u06422\\u06282\\u0645\\u0627\\u06464\\u0641\\u0644\\u0633\\u0637\\u064A\\u06466\\u0642\\u0637\\u06313\\u0643\\u0627\\u062B\\u0648\\u0644\\u064A\\u06436\\u0648\\u06453\\u0645\\u0635\\u06312\\u0644\\u064A\\u0633\\u064A\\u06275\\u0648\\u0631\\u064A\\u062A\\u0627\\u0646\\u064A\\u06277\\u0642\\u06394\\u0647\\u0645\\u0631\\u0627\\u06475\\u067E\\u0627\\u06A9\\u0633\\u062A\\u0627\\u06467\\u0680\\u0627\\u0631\\u062A4\\u0915\\u0949\\u092E3\\u0928\\u0947\\u091F3\\u092D\\u093E\\u0930\\u09240\\u092E\\u094D3\\u094B\\u09245\\u0938\\u0902\\u0917\\u0920\\u09285\\u09AC\\u09BE\\u0982\\u09B2\\u09BE5\\u09AD\\u09BE\\u09B0\\u09A42\\u09F0\\u09A44\\u0A2D\\u0A3E\\u0A30\\u0A244\\u0AAD\\u0ABE\\u0AB0\\u0AA44\\u0B2D\\u0B3E\\u0B30\\u0B244\\u0B87\\u0BA8\\u0BCD\\u0BA4\\u0BBF\\u0BAF\\u0BBE6\\u0BB2\\u0B99\\u0BCD\\u0B95\\u0BC86\\u0B9A\\u0BBF\\u0B99\\u0BCD\\u0B95\\u0BAA\\u0BCD\\u0BAA\\u0BC2\\u0BB0\\u0BCD11\\u0C2D\\u0C3E\\u0C30\\u0C24\\u0C4D5\\u0CAD\\u0CBE\\u0CB0\\u0CA44\\u0D2D\\u0D3E\\u0D30\\u0D24\\u0D025\\u0DBD\\u0D82\\u0D9A\\u0DCF4\\u0E04\\u0E2D\\u0E213\\u0E44\\u0E17\\u0E223\\u0EA5\\u0EB2\\u0EA73\\u10D2\\u10D42\\u307F\\u3093\\u306A3\\u30A2\\u30DE\\u30BE\\u30F34\\u30AF\\u30E9\\u30A6\\u30C94\\u30B0\\u30FC\\u30B0\\u30EB4\\u30B3\\u30E02\\u30B9\\u30C8\\u30A23\\u30BB\\u30FC\\u30EB3\\u30D5\\u30A1\\u30C3\\u30B7\\u30E7\\u30F36\\u30DD\\u30A4\\u30F3\\u30C84\\u4E16\\u754C2\\u4E2D\\u4FE11\\u56FD1\\u570B1\\u6587\\u7F513\\u4E9A\\u9A6C\\u900A3\\u4F01\\u4E1A2\\u4F5B\\u5C712\\u4FE1\\u606F2\\u5065\\u5EB72\\u516B\\u53662\\u516C\\u53F81\\u76CA2\\u53F0\\u6E7E1\\u70632\\u5546\\u57CE1\\u5E971\\u68072\\u5609\\u91CC0\\u5927\\u9152\\u5E975\\u5728\\u7EBF2\\u5927\\u62FF2\\u5929\\u4E3B\\u65593\\u5A31\\u4E502\\u5BB6\\u96FB2\\u5E7F\\u4E1C2\\u5FAE\\u535A2\\u6148\\u55842\\u6211\\u7231\\u4F603\\u624B\\u673A2\\u62DB\\u80582\\u653F\\u52A11\\u5E9C2\\u65B0\\u52A0\\u57612\\u95FB2\\u65F6\\u5C1A2\\u66F8\\u7C4D2\\u673A\\u67842\\u6DE1\\u9A6C\\u95213\\u6E38\\u620F2\\u6FB3\\u95802\\u70B9\\u770B2\\u79FB\\u52A82\\u7EC4\\u7EC7\\u673A\\u67844\\u7F51\\u57401\\u5E971\\u7AD91\\u7EDC2\\u8054\\u901A2\\u8C37\\u6B4C2\\u8D2D\\u72692\\u901A\\u8CA92\\u96C6\\u56E22\\u96FB\\u8A0A\\u76C8\\u79D14\\u98DE\\u5229\\u6D663\\u98DF\\u54C12\\u9910\\u53852\\u9999\\u683C\\u91CC\\u62C93\\u6E2F2\\uB2F7\\uB1371\\uCEF42\\uC0BC\\uC1312\\uD55C\\uAD6D2\",Qs=\"numeric\",Zs=\"ascii\",el=\"alpha\",tr=\"asciinumeric\",er=\"alphanumeric\",tl=\"domain\",df=\"emoji\",nk=\"scheme\",rk=\"slashscheme\",Js=\"whitespace\";function ok(t,e){return t in e||(e[t]=[]),e[t]}function Wt(t,e,n){e[Qs]&&(e[tr]=!0,e[er]=!0),e[Zs]&&(e[tr]=!0,e[el]=!0),e[tr]&&(e[er]=!0),e[el]&&(e[er]=!0),e[er]&&(e[tl]=!0),e[df]&&(e[tl]=!0);for(let r in e){let o=ok(r,n);o.indexOf(t)<0&&o.push(t)}}function ik(t,e){let n={};for(let r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function ke(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}ke.groups={};ke.prototype={accepts(){return!!this.t},go(t){let e=this,n=e.j[t];if(n)return n;for(let r=0;r<e.jr.length;r++){let o=e.jr[r][0],i=e.jr[r][1];if(i&&o.test(t))return i}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let o=0;o<t.length;o++)this.tt(t[o],e,n,r)},tr(t,e,n,r){r=r||ke.groups;let o;return e&&e.j?o=e:(o=new ke(e),n&&r&&Wt(e,n,r)),this.jr.push([t,o]),o},ts(t,e,n,r){let o=this,i=t.length;if(!i)return o;for(let s=0;s<i-1;s++)o=o.tt(t[s]);return o.tt(t[i-1],e,n,r)},tt(t,e,n,r){r=r||ke.groups;let o=this;if(e&&e.j)return o.j[t]=e,e;let i=e,s,l=o.go(t);if(l?(s=new ke,Object.assign(s.j,l.j),s.jr.push.apply(s.jr,l.jr),s.jd=l.jd,s.t=l.t):s=new ke,i){if(r)if(s.t&&typeof s.t==\"string\"){let a=Object.assign(ik(s.t,r),n);Wt(i,a,r)}else n&&Wt(i,n,r);s.t=i}return o.j[t]=s,s}};var D=(t,e,n,r,o)=>t.ta(e,n,r,o),U=(t,e,n,r,o)=>t.tr(e,n,r,o),sf=(t,e,n,r,o)=>t.ts(e,n,r,o),w=(t,e,n,r,o)=>t.tt(e,n,r,o),nt=\"WORD\",nl=\"UWORD\",ff=\"ASCIINUMERICAL\",hf=\"ALPHANUMERICAL\",sr=\"LOCALHOST\",rl=\"TLD\",ol=\"UTLD\",po=\"SCHEME\",wn=\"SLASH_SCHEME\",sl=\"NUM\",il=\"WS\",ll=\"NL\",nr=\"OPENBRACE\",rr=\"CLOSEBRACE\",go=\"OPENBRACKET\",yo=\"CLOSEBRACKET\",bo=\"OPENPAREN\",ko=\"CLOSEPAREN\",wo=\"OPENANGLEBRACKET\",So=\"CLOSEANGLEBRACKET\",xo=\"FULLWIDTHLEFTPAREN\",Co=\"FULLWIDTHRIGHTPAREN\",Mo=\"LEFTCORNERBRACKET\",vo=\"RIGHTCORNERBRACKET\",Eo=\"LEFTWHITECORNERBRACKET\",Ao=\"RIGHTWHITECORNERBRACKET\",To=\"FULLWIDTHLESSTHAN\",No=\"FULLWIDTHGREATERTHAN\",Oo=\"AMPERSAND\",Ro=\"APOSTROPHE\",Do=\"ASTERISK\",gt=\"AT\",Io=\"BACKSLASH\",Po=\"BACKTICK\",Lo=\"CARET\",Vt=\"COLON\",al=\"COMMA\",$o=\"DOLLAR\",Be=\"DOT\",zo=\"EQUALS\",cl=\"EXCLAMATION\",Ae=\"HYPHEN\",or=\"PERCENT\",Bo=\"PIPE\",Fo=\"PLUS\",xn=\"POUND\",jt=\"QUERY\",ul=\"QUOTE\",pf=\"FULLWIDTHMIDDLEDOT\",dl=\"SEMI\",Fe=\"SLASH\",ir=\"TILDE\",Ho=\"UNDERSCORE\",mf=\"EMOJI\",jo=\"SYM\",gf=Object.freeze({__proto__:null,ALPHANUMERICAL:hf,AMPERSAND:Oo,APOSTROPHE:Ro,ASCIINUMERICAL:ff,ASTERISK:Do,AT:gt,BACKSLASH:Io,BACKTICK:Po,CARET:Lo,CLOSEANGLEBRACKET:So,CLOSEBRACE:rr,CLOSEBRACKET:yo,CLOSEPAREN:ko,COLON:Vt,COMMA:al,DOLLAR:$o,DOT:Be,EMOJI:mf,EQUALS:zo,EXCLAMATION:cl,FULLWIDTHGREATERTHAN:No,FULLWIDTHLEFTPAREN:xo,FULLWIDTHLESSTHAN:To,FULLWIDTHMIDDLEDOT:pf,FULLWIDTHRIGHTPAREN:Co,HYPHEN:Ae,LEFTCORNERBRACKET:Mo,LEFTWHITECORNERBRACKET:Eo,LOCALHOST:sr,NL:ll,NUM:sl,OPENANGLEBRACKET:wo,OPENBRACE:nr,OPENBRACKET:go,OPENPAREN:bo,PERCENT:or,PIPE:Bo,PLUS:Fo,POUND:xn,QUERY:jt,QUOTE:ul,RIGHTCORNERBRACKET:vo,RIGHTWHITECORNERBRACKET:Ao,SCHEME:po,SEMI:dl,SLASH:Fe,SLASH_SCHEME:wn,SYM:jo,TILDE:ir,TLD:rl,UNDERSCORE:Ho,UTLD:ol,UWORD:nl,WORD:nt,WS:il}),et=/[a-z]/,Sn=/[a-z]/i,mo=/[\\u{1F000}-\\u{1FAFF}\\u{2600}-\\u{27BF}]|\\u{FE0F}/u;try{Sn=new RegExp(\"\\\\p{L}\",\"u\"),mo=new RegExp(\"\\\\p{Emoji}\",\"u\")}catch{}var tt=/\\d/,qs=/\\s/;var lf=\"\\r\",Gs=`\n`,sk=\"\\uFE0F\",lk=\"\\u200D\",Xs=\"\\uFFFC\",uo=null,fo=null;function ak(t=[]){let e={};ke.groups=e;let n=new ke;uo==null&&(uo=af(ek)),fo==null&&(fo=af(tk)),w(n,\"'\",Ro),w(n,\"{\",nr),w(n,\"}\",rr),w(n,\"[\",go),w(n,\"]\",yo),w(n,\"(\",bo),w(n,\")\",ko),w(n,\"<\",wo),w(n,\">\",So),w(n,\"\\uFF08\",xo),w(n,\"\\uFF09\",Co),w(n,\"\\u300C\",Mo),w(n,\"\\u300D\",vo),w(n,\"\\u300E\",Eo),w(n,\"\\u300F\",Ao),w(n,\"\\uFF1C\",To),w(n,\"\\uFF1E\",No),w(n,\"&\",Oo),w(n,\"*\",Do),w(n,\"@\",gt),w(n,\"`\",Po),w(n,\"^\",Lo),w(n,\":\",Vt),w(n,\",\",al),w(n,\"$\",$o),w(n,\".\",Be),w(n,\"=\",zo),w(n,\"!\",cl),w(n,\"-\",Ae),w(n,\"%\",or),w(n,\"|\",Bo),w(n,\"+\",Fo),w(n,\"#\",xn),w(n,\"?\",jt),w(n,'\"',ul),w(n,\"/\",Fe),w(n,\";\",dl),w(n,\"~\",ir),w(n,\"_\",Ho),w(n,\"\\\\\",Io),w(n,\"\\u30FB\",pf);let r=U(n,tt,sl,{[Qs]:!0});U(r,tt,r);let o=U(r,et,ff,{[tr]:!0}),i=U(r,Sn,hf,{[er]:!0}),s=U(n,et,nt,{[Zs]:!0});U(s,tt,o),U(s,et,s),U(o,tt,o),U(o,et,o);let l=U(n,Sn,nl,{[el]:!0});U(l,et),U(l,tt,i),U(l,Sn,l),U(i,tt,i),U(i,et),U(i,Sn,i);let a=w(n,Gs,ll,{[Js]:!0}),c=w(n,lf,il,{[Js]:!0}),u=U(n,qs,il,{[Js]:!0});w(n,Xs,u),w(c,Gs,a),w(c,Xs,u),U(c,qs,u),w(u,lf),w(u,Gs),U(u,qs,u),w(u,Xs,u);let d=U(n,mo,mf,{[df]:!0});w(d,\"#\"),U(d,mo,d),w(d,sk,d);let f=w(d,lk);w(f,\"#\"),U(f,mo,d);let h=[[et,s],[tt,o]],p=[[et,null],[Sn,l],[tt,i]];for(let m=0;m<uo.length;m++)mt(n,uo[m],rl,nt,h);for(let m=0;m<fo.length;m++)mt(n,fo[m],ol,nl,p);Wt(rl,{tld:!0,ascii:!0},e),Wt(ol,{utld:!0,alpha:!0},e),mt(n,\"file\",po,nt,h),mt(n,\"mailto\",po,nt,h),mt(n,\"http\",wn,nt,h),mt(n,\"https\",wn,nt,h),mt(n,\"ftp\",wn,nt,h),mt(n,\"ftps\",wn,nt,h),Wt(po,{scheme:!0,ascii:!0},e),Wt(wn,{slashscheme:!0,ascii:!0},e),t=t.sort((m,g)=>m[0]>g[0]?1:-1);for(let m=0;m<t.length;m++){let g=t[m][0],S=t[m][1]?{[nk]:!0}:{[rk]:!0};g.indexOf(\"-\")>=0?S[tl]=!0:et.test(g)?tt.test(g)?S[tr]=!0:S[Zs]=!0:S[Qs]=!0,sf(n,g,g,S)}return sf(n,\"localhost\",sr,{ascii:!0}),n.jd=new ke(jo),{start:n,tokens:Object.assign({groups:e},gf)}}function yf(t,e){let n=ck(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=n.length,o=[],i=0,s=0;for(;s<r;){let l=t,a=null,c=0,u=null,d=-1,f=-1;for(;s<r&&(a=l.go(n[s]));)l=a,l.accepts()?(d=0,f=0,u=l):d>=0&&(d+=n[s].length,f++),c+=n[s].length,i+=n[s].length,s++;i-=d,s-=f,c-=d,o.push({t:u.t,v:e.slice(i-c,i),s:i-c,e:i})}return o}function ck(t){let e=[],n=t.length,r=0;for(;r<n;){let o=t.charCodeAt(r),i,s=o<55296||o>56319||r+1===n||(i=t.charCodeAt(r+1))<56320||i>57343?t[r]:t.slice(r,r+2);e.push(s),r+=s.length}return e}function mt(t,e,n,r,o){let i,s=e.length;for(let l=0;l<s-1;l++){let a=e[l];t.j[a]?i=t.j[a]:(i=new ke(r),i.jr=o.slice(),t.j[a]=i),t=i}return i=new ke(n),i.jr=o.slice(),t.j[e[s-1]]=i,i}function af(t){let e=[],n=[],r=0,o=\"0123456789\";for(;r<t.length;){let i=0;for(;o.indexOf(t[r+i])>=0;)i++;if(i>0){e.push(n.join(\"\"));for(let s=parseInt(t.substring(r,r+i),10);s>0;s--)n.pop();r+=i}else n.push(t[r]),r++}return e}var lr={defaultProtocol:\"http\",events:null,format:cf,formatHref:cf,nl2br:!1,tagName:\"a\",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],ignoreClasses:[],render:null};function fl(t,e=null){let n=Object.assign({},lr);t&&(n=Object.assign(n,t instanceof fl?t.o:t));let r=n.ignoreTags,o=[];for(let i=0;i<r.length;i++)o.push(r[i].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=o,this.ignoreClasses=n.ignoreClasses.slice()}fl.prototype={o:lr,ignoreTags:[],ignoreClasses:[],isIgnoredClass(t){if(typeof t!=\"string\"||this.ignoreClasses.length===0)return!1;let e=t.split(/\\s+/);for(let n=0;n<e.length;n++)if(this.ignoreClasses.indexOf(e[n])>=0)return!0;return!1},defaultRender(t){return t},check(t){return this.get(\"validate\",t.toString(),t)},get(t,e,n){let r=e!=null,o=this.o[t];return o&&(typeof o==\"object\"?(o=n.t in o?o[n.t]:lr[t],typeof o==\"function\"&&r&&(o=o(e,n))):typeof o==\"function\"&&r&&(o=o(e,n.t,n)),o)},getObj(t,e,n){let r=this.o[t];return typeof r==\"function\"&&e!=null&&(r=r(e,n.t,n)),r},render(t){let e=t.render(this);return(this.get(\"render\",null,t)||this.defaultRender)(e,t.t,t)}};function cf(t){return t}function bf(t,e){this.t=\"token\",this.v=t,this.tk=e}bf.prototype={isLink:!1,toString(){return this.v},toHref(t){return this.toString()},toFormattedString(t){let e=this.toString(),n=t.get(\"truncate\",e,this),r=t.get(\"format\",e,this);return n&&r.length>n?r.substring(0,n)+\"\\u2026\":r},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=lr.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){let e=this,n=this.toHref(t.get(\"defaultProtocol\")),r=t.get(\"formatHref\",n,this),o=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),u=t.getObj(\"attributes\",n,e),d=t.getObj(\"events\",n,e);return s.href=r,l&&(s.class=l),a&&(s.target=a),c&&(s.rel=c),u&&Object.assign(s,u),{tagName:o,attributes:s,content:i,eventListeners:d}}};function Wo(t,e){class n extends bf{constructor(o,i){super(o,i),this.t=t}}for(let r in e)n.prototype[r]=e[r];return n.t=t,n}var uk=Wo(\"email\",{isLink:!0,toHref(){return\"mailto:\"+this.toString()}}),uf=Wo(\"text\"),dk=Wo(\"nl\"),ho=Wo(\"url\",{isLink:!0,toHref(t=lr.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){let t=this.tk;return t.length>=2&&t[0].t!==sr&&t[1].t===Vt}});var Ee=t=>new ke(t);function fk({groups:t}){let e=t.domain.concat([Oo,Do,gt,Io,Po,Lo,$o,zo,Ae,sl,or,Bo,Fo,xn,Fe,jo,ir,Ho]),n=[Ro,Vt,al,Be,cl,or,jt,ul,dl,wo,So,nr,rr,yo,go,bo,ko,xo,Co,Mo,vo,Eo,Ao,To,No],r=[Oo,Ro,Do,Io,Po,Lo,$o,zo,Ae,nr,rr,or,Bo,Fo,xn,jt,Fe,jo,ir,Ho],o=Ee(),i=w(o,ir);D(i,r,i),D(i,t.domain,i);let s=Ee(),l=Ee(),a=Ee();D(o,t.domain,s),D(o,t.scheme,l),D(o,t.slashscheme,a),D(s,r,i),D(s,t.domain,s);let c=w(s,gt);w(i,gt,c),w(l,gt,c),w(a,gt,c);let u=w(i,Be);D(u,r,i),D(u,t.domain,i);let d=Ee();D(c,t.domain,d),D(d,t.domain,d);let f=w(d,Be);D(f,t.domain,d);let h=Ee(uk);D(f,t.tld,h),D(f,t.utld,h),w(c,sr,h);let p=w(d,Ae);w(p,Ae,p),D(p,t.domain,d),D(h,t.domain,d),w(h,Be,f),w(h,Ae,p);let m=w(s,Ae),g=w(s,Be);w(m,Ae,m),D(m,t.domain,s),D(g,r,i),D(g,t.domain,s);let y=Ee(ho);D(g,t.tld,y),D(g,t.utld,y),D(y,t.domain,s),D(y,r,i),w(y,Be,g),w(y,Ae,m),w(y,gt,c);let S=w(y,Vt),k=Ee(ho);D(S,t.numeric,k);let x=Ee(ho),O=Ee();D(x,e,x),D(x,n,O),D(O,e,x),D(O,n,O),w(y,Fe,x),w(k,Fe,x),w(y,jt,O),w(y,xn,x),w(k,jt,O),w(k,xn,x);let H=w(l,Vt),T=w(a,Vt),I=w(T,Fe),F=w(I,Fe);D(l,t.domain,s),w(l,Be,g),w(l,Ae,m),D(a,t.domain,s),w(a,Be,g),w(a,Ae,m),D(H,t.domain,x),w(H,Fe,x),w(H,jt,x),D(F,t.domain,x),D(F,e,x),w(F,Fe,x);let W=[[nr,rr],[go,yo],[bo,ko],[wo,So],[xo,Co],[Mo,vo],[Eo,Ao],[To,No]];for(let xe=0;xe<W.length;xe++){let[kt,wt]=W[xe],fe=w(x,kt);w(O,kt,fe);let ye=Ee(ho);D(fe,e,ye);let he=Ee();D(fe,n,he),w(fe,wt,x),D(ye,e,ye),D(ye,n,he),D(he,e,ye),D(he,n,he),w(ye,wt,x),w(he,wt,x)}return w(o,sr,y),w(o,ll,dk),{start:o,tokens:gf}}function hk(t,e,n){let r=n.length,o=0,i=[],s=[],l=[];for(;o<r;){let a=t,c=null,u=null,d=0,f=null,h=-1,p=[];for(;o<r&&!(c=a.go(n[o].t));)s.push(n[o++]);for(;o<r&&(u=c||a.go(n[o].t));)if(c=null,a=u,o++,d++,a.accepts())h=0,f=a,p=[];else if(h>=0&&h++,p.push(a),l[o]&&l[o].has(a))break;for(let m=0,g=o-p.length+1;m<p.length;m++,g++)(l[g]||(l[g]=new Set)).add(p[m]);if(h<0)o-=d,o<r&&(s.push(n[o]),o++);else{s.length>0&&(i.push(Ys(uf,e,s)),s=[]),o-=h,d-=h;let m=f.t,g=n.slice(o-d,o);i.push(Ys(m,e,g))}}return s.length>0&&i.push(Ys(uf,e,s)),i}function Ys(t,e,n){let r=n[0].s,o=n[n.length-1].e,i=e.slice(r,o);return new t(i,n)}var pk=typeof console<\"u\"&&console&&console.warn||(()=>{}),mk=\"until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.\",_={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function kf(){return ke.groups={},_.scanner=null,_.parser=null,_.tokenQueue=[],_.pluginQueue=[],_.customSchemes=[],_.initialized=!1,_}function hl(t,e=!1){if(_.initialized&&pk(`linkifyjs: already initialized - will not register custom scheme \"${t}\" ${mk}`),!/^[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`);_.customSchemes.push([t,e])}function gk(){_.scanner=ak(_.customSchemes);for(let t=0;t<_.tokenQueue.length;t++)_.tokenQueue[t][1]({scanner:_.scanner});_.parser=fk(_.scanner.tokens);for(let t=0;t<_.pluginQueue.length;t++)_.pluginQueue[t][1]({scanner:_.scanner,parser:_.parser});return _.initialized=!0,_}function Vo(t){return _.initialized||gk(),hk(_.parser.start,t,yf(_.scanner.start,t))}Vo.scan=yf;function pl(t,e=null,n=null){if(e&&typeof e==\"object\"){if(n)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);n=e,e=null}let r=new fl(n),o=Vo(t),i=[];for(let s=0;s<o.length;s++){let l=o[s];l.isLink&&(!e||l.t===e)&&r.check(l)&&i.push(l.toFormattedObject(r))}return i}var _o=\"[\\0- \\xA0\\u1680\\u180E\\u2000-\\u2029\\u205F\\u3000]\",yk=new RegExp(_o),bk=new RegExp(`${_o}$`),kk=new RegExp(`${_o}+$`),wk=new RegExp(_o,\"g\");function Sk(t,e,n){var r,o;let i=t.doc.resolve(e.to);if(!(!((r=i.nodeBefore)===null||r===void 0)&&r.isText))return;let s=(o=t.doc.textBetween(e.from,e.to,\"\\uFFFC\",\"\\uFFFC\").match(kk))===null||o===void 0?void 0:o[0];if(!s)return;let l=e.to-s.length,a=Qn(l,e.to,t.doc).filter(d=>d.mark.type===n);if(!a.length)return;let{nodeAfter:c}=i;if(c&&a.some(d=>d.mark.isInSet(c.marks)))return;let u=t.storedMarks;t.removeMark(l,e.to,n),t.setStoredMarks(u),t.selection.empty&&t.selection.from===e.to&&t.removeStoredMark(n)}function xk(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?[\"()\",\"[]\"].includes(t[0].value+t[2].value):!1}function Ck(t){return new R({key:new P(\"autolink\"),appendTransaction:(e,n,r)=>{let o=e.some(a=>a.docChanged)&&!n.doc.eq(r.doc),i=e.some(a=>a.getMeta(\"preventAutolink\"));if(!o||i)return;let{tr:s}=r,l=As(n.doc,[...e]);if(!e.some(vu)){let a=[];l.steps.forEach((c,u)=>{if(!(c instanceof G)||!c.slice.size)return;let d=l.mapping.slice(u+1),f=d.map(c.from,1),h=d.map(c.from+c.slice.size,-1);f<h&&a.push({from:f,to:h})}),a.sort((c,u)=>u.to-c.to),a.forEach(c=>Sk(s,c,t.type))}if(mn(l).forEach(({newRange:a})=>{let c=rd(r.doc,a,f=>f.isTextblock),u,d;if(c.length>1)u=c[0],d=r.doc.textBetween(u.pos,u.pos+u.node.nodeSize,void 0,\" \");else if(c.length){let f=r.doc.textBetween(a.from,a.to,\" \",\" \");if(!bk.test(f))return;u=c[0],d=r.doc.textBetween(u.pos,a.to,void 0,\" \")}if(u&&d){let f=d.split(yk).filter(Boolean);if(f.length<=0)return!1;let h=f[f.length-1],p=u.pos+d.lastIndexOf(h);if(!h)return!1;let m=Vo(h).map(g=>g.toObject(t.defaultProtocol));if(!xk(m))return!1;m.filter(g=>g.isLink).map(g=>({...g,from:p+g.start+1,to:p+g.end+1})).filter(g=>r.schema.marks.code?!r.doc.rangeHasMark(g.from,g.to,r.schema.marks.code):!0).filter(g=>t.validate(g.value)).filter(g=>t.shouldAutoLink(g.value)).forEach(g=>{Qn(g.from,g.to,r.doc).some(y=>y.mark.type===t.type)||s.addMark(g.from,g.to,t.type.create({href:g.href}))})}}),!!s.steps.length)return s}})}function Mk(t){return new R({key:new P(\"handleClickLink\"),props:{handleClick:(e,n,r)=>{if(r.button!==0||!e.editable)return!1;let o=null;if(r.target instanceof HTMLAnchorElement)o=r.target;else{let a=r.target;if(!a)return!1;let c=t.editor.view.dom;o=a.closest(\"a\"),o&&!c.contains(o)&&(o=null)}if(!o)return!1;let i=!1;if(t.enableClickSelection&&(i=t.editor.commands.extendMarkRange(t.type.name)),t.openOnClick){var s,l;let a=Rs(e.state,t.type.name),c=(s=o.href)!==null&&s!==void 0?s:a.href,u=(l=o.target)!==null&&l!==void 0?l:a.target;c&&(window.open(c,u),i=!0)}return i}}})}var vk=/\\[([^[\\]]+)\\]\\(((?:[^\\s()]|\\([^\\s()]*\\))+)(?:\\s+(?:([\"'])(.*?)\\3|“(.*?)”|‘(.*?)’))?\\)$/,Ek=/\\[([^[\\]]+)\\]\\(((?:[^\\s()]|\\([^\\s()]*\\))+)(?:\\s+(?:([\"'])(.*?)\\3|“(.*?)”|‘(.*?)’))?\\)/g;function wf(t,e){let n=0;for(let r=e-1;r>=0&&t[r]===\"\\\\\";r-=1)n+=1;return n%2===1}function Ak(t,e){let n=0,r=0;for(;r<e;){if(t[r]!==\"`\"){r+=1;continue}if(n===0&&wf(t,r)){r+=1;continue}let o=0;for(;r<e&&t[r]===\"`\";)o+=1,r+=1;n===0?n=o:o===n&&(n=0)}return n>0}function Sf(t,e,n){var r,o;let[,i,s]=e;return(e.index?t[e.index-1]:void 0)===\"!\"||wf(t,(r=e.index)!==null&&r!==void 0?r:0)||Ak(t,(o=e.index)!==null&&o!==void 0?o:0)?!1:!!i.trim()&&n(s)}function xf(t){var e,n;let[r,o,i,,s,l,a]=t,c=(e=s??l)!==null&&e!==void 0?e:a;return{index:(n=t.index)!==null&&n!==void 0?n:0,text:r,replaceWith:o,data:{href:i,title:c||null,markdown:!0}}}function Tk(t,e){return t.index<e.index+e.text.length&&e.index<t.index+t.text.length}function Cf(t){var e,n,r;return{href:(e=t.data)===null||e===void 0?void 0:e.href,title:(n=(r=t.data)===null||r===void 0?void 0:r.title)!==null&&n!==void 0?n:null}}function Nk(t){let e=ze({find:n=>{let r=vk.exec(n);return!r||!Sf(n,r,t.isAllowedHref)?null:xf(r)},type:t.type,getAttributes:Cf});return new yn({find:e.find,handler:n=>{let r=e.handler(n);return r!==null&&n.state.tr.steps.length&&n.state.tr.setMeta(\"preventAutolink\",!0),r}})}function Ok(t){let e=Re({find:n=>{var r,o;let i=[];for(let l of n.matchAll(Ek))Sf(n,l,t.isAllowedHref)&&i.push(xf(l));let s=((r=(o=t.findPlainUrls)===null||o===void 0?void 0:o.call(t,n))!==null&&r!==void 0?r:[]).filter(l=>!i.some(a=>Tk(a,l)));return[...i,...s]},type:t.type,getAttributes:Cf});return new $s({find:e.find,handler:n=>{var r;let o=e.handler(n);return o!==null&&n.state.tr.steps.length&&(!((r=n.match.data)===null||r===void 0)&&r.markdown)&&n.state.tr.setMeta(\"preventAutolink\",!0),o}})}function Rk(t){return new R({key:new P(\"handlePasteLink\"),props:{handlePaste:(e,n,r)=>{let{shouldAutoLink:o}=t,{state:i}=e,{selection:s}=i,{empty:l}=s;if(l)return!1;let a=\"\";r.content.forEach(u=>{a+=u.textContent});let c=pl(a,{defaultProtocol:t.defaultProtocol}).find(u=>u.isLink&&u.value===a);return!a||!c||o!==void 0&&!o(c.value)?!1:t.editor.commands.setMark(t.type,{href:c.href})}}})}function rt(t,e){let n=[\"http\",\"https\",\"ftp\",\"ftps\",\"mailto\",\"tel\",\"callto\",\"sms\",\"cid\",\"xmpp\"];return e&&e.forEach(r=>{let o=typeof r==\"string\"?r:r.scheme;o&&n.push(o)}),!t||t.replace(wk,\"\").match(new RegExp(`^(?:(?:${n.map(r=>r.replace(/[-/\\\\^$*+?.()|[\\]{}]/g,\"\\\\$&\")).join(\"|\")}):|[^a-z]|[a-z0-9+.\\\\-]+(?:[^a-z+.\\\\-:]|$))`,\"i\"))}var Mf=Ze.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=>{if(typeof t==\"string\"){hl(t);return}hl(t.scheme,t.optionalSlashes)})},onDestroy(){kf()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,markdownLinks:!1,autolink:!0,protocols:[],defaultProtocol:\"http\",HTMLAttributes:{target:\"_blank\",rel:\"noopener noreferrer nofollow\",class:null},isAllowedUri:(t,e)=>!!rt(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>{let e=/^[a-z][a-z0-9+.-]*:\\/\\//i.test(t),n=/^[a-z][a-z0-9+.-]*:/i.test(t);if(e||n&&!t.includes(\"@\"))return!0;let r=(t.includes(\"@\")?t.split(\"@\").pop():t).split(/[/?#:]/)[0];return!(/^\\d{1,3}(\\.\\d{1,3}){3}$/.test(r)||!/\\./.test(r))}}},addAttributes(){var t,e,n;return{href:{default:null,parseHTML(r){return r.getAttribute(\"href\")}},target:{default:(t=this.options.HTMLAttributes.target)!==null&&t!==void 0?t:null},rel:{default:(e=this.options.HTMLAttributes.rel)!==null&&e!==void 0?e:null},class:{default:(n=this.options.HTMLAttributes.class)!==null&&n!==void 0?n:null},title:{default:null}}},parseHTML(){return[{tag:\"a[href]\",getAttrs:t=>{let e=t.getAttribute(\"href\");return!e||!this.options.isAllowedUri(e,{defaultValidate:n=>!!rt(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!rt(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?[\"a\",B(this.options.HTMLAttributes,t),0]:[\"a\",B(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,r,o,i;let s=(n=(r=t.attrs)===null||r===void 0?void 0:r.href)!==null&&n!==void 0?n:\"\",l=(o=(i=t.attrs)===null||i===void 0?void 0:i.title)!==null&&o!==void 0?o:\"\",a=e.renderChildren(t);return l?`[${a}](${s} \"${l}\")`:`[${a}](${s})`},addCommands(){return{setLink:t=>({chain:e})=>{let{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!rt(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,t).setMeta(\"preventAutolink\",!0).run():!1},toggleLink:t=>({chain:e})=>{let{href:n}=t||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:r=>!!rt(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta(\"preventAutolink\",!0).run()},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta(\"preventAutolink\",!0).run()}},addInputRules(){return this.options.markdownLinks?[Nk({type:this.type,isAllowedHref:t=>this.options.isAllowedUri(t,{defaultValidate:e=>!!rt(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})})]:[]},addPasteRules(){let t=e=>{let n=[];if(e){let{protocols:r,defaultProtocol:o}=this.options;pl(e).filter(i=>i.isLink&&this.options.isAllowedUri(i.value,{defaultValidate:s=>!!rt(s,r),protocols:r,defaultProtocol:o})).forEach(i=>{this.options.shouldAutoLink(i.value)&&n.push({text:i.value,data:{href:i.href},index:i.start})})}return n};return this.options.markdownLinks?[Ok({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:n=>!!rt(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}),findPlainUrls:t})]:[Re({find:t,type:this.type,getAttributes:e=>{var n;return{href:(n=e.data)===null||n===void 0?void 0:n.href}}})]},addProseMirrorPlugins(){let t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(Ck({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:o=>!!rt(o,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push(Mk({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick===\"whenNotEditable\"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(Rk({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}});var ml=4,Dk=/^```([a-z]+)?[\\s\\n]$/,Ik=/^~~~([a-z]+)?[\\s\\n]$/,vf=K.create({name:\"codeBlock\",addOptions(){return{languageClassPrefix:\"language-\",exitOnTripleEnter:!0,exitOnArrowDown:!0,exitOnArrowUp:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:ml,HTMLAttributes:{}}},content:\"text*\",marks:\"\",group:\"block\",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;let{languageClassPrefix:n}=this.options;if(!n)return null;let r=[...((e=t.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(o=>o.startsWith(n)).map(o=>o.replace(n,\"\"))[0];return r||null},rendered:!1}}},parseHTML(){return[{tag:\"pre\",preserveWhitespace:\"full\"}]},renderHTML({node:t,HTMLAttributes:e}){return[\"pre\",B(this.options.HTMLAttributes,e),[\"code\",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:\"code\",parseMarkdown:(t,e)=>{var n,r;return((n=t.raw)===null||n===void 0?void 0:n.startsWith(\"```\"))===!1&&((r=t.raw)===null||r===void 0?void 0:r.startsWith(\"~~~\"))===!1&&t.codeBlockStyle!==\"indented\"?[]:e.createNode(\"codeBlock\",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var n;let r=\"\",o=((n=t.attrs)===null||n===void 0?void 0:n.language)||\"\";return t.content?r=[`\\`\\`\\`${o}`,e.renderChildren(t.content),\"```\"].join(`\n`):r=`\\`\\`\\`${o}\n\n\\`\\`\\``,r},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:()=>{let{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;let n=(e=this.options.tabSize)!==null&&e!==void 0?e:ml,{state:r}=t,{selection:o}=r,{$from:i,empty:s}=o;if(i.parent.type!==this.type)return!1;let l=\" \".repeat(n);return s?t.commands.insertContent(l):t.commands.command(({tr:a})=>{let{from:c,to:u}=o,d=r.doc.textBetween(c,u,`\n`,`\n`).split(`\n`).map(f=>l+f).join(`\n`);return a.replaceWith(c,u,r.schema.text(d)),!0})},\"Shift-Tab\":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;let n=(e=this.options.tabSize)!==null&&e!==void 0?e:ml,{state:r}=t,{selection:o}=r,{$from:i,empty:s}=o;return i.parent.type!==this.type?!1:s?t.commands.command(({tr:l})=>{var a;let{pos:c}=i,u=i.start(),d=i.end(),f=r.doc.textBetween(u,d,`\n`,`\n`).split(`\n`),h=0,p=0,m=c-u;for(let k=0;k<f.length;k+=1){if(p+f[k].length>=m){h=k;break}p+=f[k].length+1}let g=((a=f[h].match(/^ */))===null||a===void 0?void 0:a[0])||\"\",y=Math.min(g.length,n);if(y===0)return!0;let S=u;for(let k=0;k<h;k+=1)S+=f[k].length+1;return l.delete(S,S+y),c-S<=y&&l.setSelection(M.create(l.doc,S)),!0}):t.commands.command(({tr:l})=>{let{from:a,to:c}=o,u=r.doc.textBetween(a,c,`\n`,`\n`).split(`\n`).map(d=>{var f;let h=((f=d.match(/^ */))===null||f===void 0?void 0:f[0])||\"\",p=Math.min(h.length,n);return d.slice(p)}).join(`\n`);return l.replaceWith(a,c,r.schema.text(u)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;let{state:e}=t,{selection:n}=e,{$from:r,empty:o}=n;if(!o||r.parent.type!==this.type)return!1;let i=r.parentOffset===r.parent.nodeSize-2,s=r.parent.textContent.endsWith(`\n\n`);return!i||!s?!1:t.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowUp:({editor:t})=>{if(!this.options.exitOnArrowUp)return!1;let{state:e}=t,{selection:n}=e,{$from:r,empty:o}=n;if(!o||r.parent.type!==this.type||r.parentOffset!==0)return!1;let i=r.before();return i>0?!1:t.commands.insertDefaultBlock({pos:i})},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;let{state:e}=t,{selection:n,doc:r}=e,{$from:o,empty:i}=n;if(!i||o.parent.type!==this.type||o.parentOffset!==o.parent.nodeSize-2)return!1;let s=o.after();return s===void 0?!1:r.nodeAt(s)?t.commands.command(({tr:l})=>(l.setSelection(E.near(r.resolve(s))),!0)):t.commands.exitCode()}}},addInputRules(){return[Zn({find:Dk,type:this.type,getAttributes:t=>({language:t[1]})}),Zn({find:Ik,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new R({key:new P(\"codeBlockVSCodeHandler\"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;let n=e.clipboardData.getData(\"text/plain\"),r=e.clipboardData.getData(\"vscode-editor-data\"),o=r?JSON.parse(r):void 0,i=o?.mode;if(!n||!i)return!1;let{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(M.near(s.doc.resolve(Math.max(0,s.selection.from-2)))),s.setMeta(\"paste\",!0),t.dispatch(s),!0}}})]}});var Pk=/(?:^|\\s)(!\\[(.+|:?)]\\((\\S+)(?:(?:\\s+)[\"'](\\S+)[\"'])?\\))$/,Ef=K.create({name:\"image\",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},inline(){return this.options.inline},group(){return this.options.inline?\"inline\":\"block\"},draggable:!0,addAttributes(){return{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\",B(this.options.HTMLAttributes,t)]},parseMarkdown:(t,e)=>e.createNode(\"image\",{src:t.href,title:t.title,alt:t.text}),renderMarkdown:t=>{var e,n,r,o,i,s;let l=(e=(n=t.attrs)===null||n===void 0?void 0:n.src)!==null&&e!==void 0?e:\"\",a=(r=(o=t.attrs)===null||o===void 0?void 0:o.alt)!==null&&r!==void 0?r:\"\",c=(i=(s=t.attrs)===null||s===void 0?void 0:s.title)!==null&&i!==void 0?i:\"\";return c?`![${a}](${l} \"${c}\")`:`![${a}](${l})`},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>\"u\")return null;let{directions:t,minWidth:e,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize,o=new Set([\"src\",\"width\",\"height\"]);return({node:i,getPos:s,HTMLAttributes:l,editor:a})=>{let c=document.createElement(\"img\");c.draggable=!1;let u=B(this.options.HTMLAttributes,l);Object.entries(u).forEach(([y,S])=>{if(S!=null)switch(y){case\"src\":case\"width\":case\"height\":break;default:c.setAttribute(y,S)}}),u.src!==null&&(c.src=u.src);let d={...l},f=y=>{if(typeof y==\"string\"&&y!==\"\"){c.getAttribute(\"src\")!==y&&(c.src=y);return}c.hasAttribute(\"src\")&&c.removeAttribute(\"src\"),c.src!==\"\"&&(c.src=\"\")};f(l.src);let h=y=>{if(y.type!==i.type)return!1;let S=a.extensionManager.attributes.filter(x=>x.type===y.type.name),k=pt(y,S);return Object.keys(d).forEach(x=>{!o.has(x)&&!(x in k)&&c.removeAttribute(x)}),Object.entries(k).forEach(([x,O])=>{o.has(x)||(O!=null?c.setAttribute(x,O):c.removeAttribute(x))}),f(k.src),d=k,!0},p=new Rd({element:c,editor:a,node:i,getPos:s,onResize:(y,S)=>{c.style.width=`${y}px`,c.style.height=`${S}px`},onCommit:(y,S)=>{let k=s();k!==void 0&&this.editor.chain().setNodeSelection(k).updateAttributes(this.name,{width:y,height:S}).run()},onUpdate:h,options:{directions:t,min:{width:e,height:n},preserveAspectRatio:r===!0}}),m=p.dom,g=()=>{m.style.visibility=\"\",m.style.pointerEvents=\"\"};return m.style.visibility=\"hidden\",m.style.pointerEvents=\"none\",c.complete&&c.naturalWidth>0?g():(c.onload=g,c.onerror=g),p}},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[Od({find:Pk,type:this.type,getAttributes:t=>{let[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}});var yl,bl;if(typeof WeakMap<\"u\"){let t=new WeakMap;yl=e=>t.get(e),bl=(e,n)=>(t.set(e,n),n)}else{let t=[],n=0;yl=r=>{for(let o=0;o<t.length;o+=2)if(t[o]==r)return t[o+1]},bl=(r,o)=>(n==10&&(n=0),t[n++]=r,t[n++]=o)}var J=class{constructor(t,e,n,r){this.width=t,this.height=e,this.map=n,this.problems=r}findCell(t){for(let e=0;e<this.map.length;e++){let n=this.map[e];if(n!=t)continue;let r=e%this.width,o=e/this.width|0,i=r+1,s=o+1;for(let l=1;i<this.width&&this.map[e+l]==n;l++)i++;for(let l=1;s<this.height&&this.map[e+this.width*l]==n;l++)s++;return{left:r,top:o,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){let{left:r,right:o,top:i,bottom:s}=this.findCell(t);return e==\"horiz\"?(n<0?r==0:o==this.width)?null:this.map[i*this.width+(n<0?r-1:o)]:(n<0?i==0:s==this.height)?null:this.map[r+this.width*(n<0?i-1:s)]}rectBetween(t,e){let{left:n,right:r,top:o,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(o,a),right:Math.max(r,l),bottom:Math.max(i,c)}}cellsInRect(t){let e=[],n={};for(let r=t.top;r<t.bottom;r++)for(let o=t.left;o<t.right;o++){let i=r*this.width+o,s=this.map[i];n[s]||(n[s]=!0,!(o==t.left&&o&&this.map[i-1]==s||r==t.top&&r&&this.map[i-this.width]==s)&&e.push(s))}return e}positionAt(t,e,n){for(let r=0,o=0;;r++){let i=o+n.child(r).nodeSize;if(r==t){let s=e+t*this.width,l=(t+1)*this.width;for(;s<l&&this.map[s]<o;)s++;return s==l?i-1:this.map[s]}o=i}}static get(t){return yl(t)||bl(t,Lk(t))}};function Lk(t){if(t.type.spec.tableRole!=\"table\")throw new RangeError(\"Not a table node: \"+t.type.name);let e=$k(t),n=t.childCount,r=[],o=0,i=null,s=[];for(let c=0,u=e*n;c<u;c++)r[c]=0;for(let c=0,u=0;c<n;c++){let d=t.child(c);u++;for(let p=0;;p++){for(;o<r.length&&r[o]!=0;)o++;if(p==d.childCount)break;let m=d.child(p),{colspan:g,rowspan:y,colwidth:S}=m.attrs;for(let k=0;k<y;k++){if(k+c>=n){(i||(i=[])).push({type:\"overlong_rowspan\",pos:u,n:y-k});break}let x=o+k*e;for(let O=0;O<g;O++){r[x+O]==0?r[x+O]=u:(i||(i=[])).push({type:\"collision\",row:c,pos:u,n:g-O});let H=S&&S[O];if(H){let T=(x+O)%e*2,I=s[T];I==null||I!=H&&s[T+1]==1?(s[T]=H,s[T+1]=1):I==H&&s[T+1]++}}}o+=g,u+=m.nodeSize}let f=(c+1)*e,h=0;for(;o<f;)r[o++]==0&&h++;h&&(i||(i=[])).push({type:\"missing\",row:c,n:h}),u++}(e===0||n===0)&&(i||(i=[])).push({type:\"zero_sized\"});let l=new J(e,n,r,i),a=!1;for(let c=0;!a&&c<s.length;c+=2)s[c]!=null&&s[c+1]<n&&(a=!0);return a&&zk(l,s,t),l}function $k(t){let e=-1,n=!1;for(let r=0;r<t.childCount;r++){let o=t.child(r),i=0;if(n)for(let s=0;s<r;s++){let l=t.child(s);for(let a=0;a<l.childCount;a++){let c=l.child(a);s+c.attrs.rowspan>r&&(i+=c.attrs.colspan)}}for(let s=0;s<o.childCount;s++){let l=o.child(s);i+=l.attrs.colspan,l.attrs.rowspan>1&&(n=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function zk(t,e,n){t.problems||(t.problems=[]);let r={};for(let o=0;o<t.map.length;o++){let i=t.map[o];if(r[i])continue;r[i]=!0;let s=n.nodeAt(i);if(!s)throw new RangeError(`No cell with offset ${i} found`);let l=null,a=s.attrs;for(let c=0;c<a.colspan;c++){let u=e[(o+c)%t.width*2];u!=null&&(!a.colwidth||a.colwidth[c]!=u)&&((l||(l=Bk(a)))[c]=u)}l&&t.problems.unshift({type:\"colwidth mismatch\",pos:i,colwidth:l})}}function Bk(t){if(t.colwidth)return t.colwidth.slice();let e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function ue(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(let n in t.nodes){let r=t.nodes[n],o=r.spec.tableRole;o&&(e[o]=r)}}return e}var yt=new P(\"selectingCells\");function _t(t){for(let e=t.depth-1;e>0;e--)if(t.node(e).type.spec.tableRole==\"row\")return t.node(0).resolve(t.before(e+1));return null}function Fk(t){for(let e=t.depth;e>0;e--){let n=t.node(e).type.spec.tableRole;if(n===\"cell\"||n===\"header_cell\")return t.node(e)}return null}function De(t){let e=t.selection.$head;for(let n=e.depth;n>0;n--)if(e.node(n).type.spec.tableRole==\"row\")return!0;return!1}function Xo(t){let 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&&e.node.type.spec.tableRole==\"cell\")return e.$anchor;let n=_t(e.$head)||Hk(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function Hk(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){let r=e.type.spec.tableRole;if(r==\"cell\"||r==\"header_cell\")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){let r=e.type.spec.tableRole;if(r==\"cell\"||r==\"header_cell\")return t.doc.resolve(n-e.nodeSize)}}function kl(t){return t.parent.type.spec.tableRole==\"row\"&&!!t.nodeAfter}function jk(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function xl(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function $f(t,e,n){let r=t.node(-1),o=J.get(r),i=t.start(-1),s=o.nextCell(t.pos-i,e,n);return s==null?null:t.node(0).resolve(i+s)}function Kt(t,e,n=1){let r={...t,colspan:t.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some(o=>o>0)||(r.colwidth=null)),r}function zf(t,e,n=1){let r={...t,colspan:t.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let o=0;o<n;o++)r.colwidth.splice(e,0,0)}return r}function Wk(t,e,n){let r=ue(e.type.schema).header_cell;for(let o=0;o<t.height;o++)if(e.nodeAt(t.map[n+o*t.width]).type!=r)return!1;return!0}var j=class ot extends E{constructor(e,n=e){let r=e.node(-1),o=J.get(r),i=e.start(-1),s=o.rectBetween(e.pos-i,n.pos-i),l=e.node(0),a=o.cellsInRect(s).filter(u=>u!=n.pos-i);a.unshift(n.pos-i);let c=a.map(u=>{let d=r.nodeAt(u);if(!d)throw new RangeError(`No cell with offset ${u} found`);let f=i+u+1;return new Zt(l.resolve(f),l.resolve(f+d.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=n}map(e,n){let r=e.resolve(n.map(this.$anchorCell.pos)),o=e.resolve(n.map(this.$headCell.pos));if(kl(r)&&kl(o)&&xl(r,o)){let i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?ot.rowSelection(r,o):i&&this.isColSelection()?ot.colSelection(r,o):new ot(r,o)}return M.between(r,o)}content(){let e=this.$anchorCell.node(-1),n=J.get(e),r=this.$anchorCell.start(-1),o=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},s=[];for(let a=o.top;a<o.bottom;a++){let c=[];for(let u=a*n.width+o.left,d=o.left;d<o.right;d++,u++){let f=n.map[u];if(i[f])continue;i[f]=!0;let h=n.findCell(f),p=e.nodeAt(f);if(!p)throw new RangeError(`No cell with offset ${f} found`);let m=o.left-h.left,g=h.right-o.right;if(m>0||g>0){let y=p.attrs;if(m>0&&(y=Kt(y,0,m)),g>0&&(y=Kt(y,y.colspan-g,g)),h.left<o.left){if(p=p.type.createAndFill(y),!p)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(y)}`)}else p=p.type.create(y,p.content)}if(h.top<o.top||h.bottom>o.bottom){let y={...p.attrs,rowspan:Math.min(h.bottom,o.bottom)-Math.max(h.top,o.top)};h.top<o.top?p=p.type.createAndFill(y):p=p.type.create(y,p.content)}c.push(p)}s.push(e.child(a).copy(b.from(c)))}let l=this.isColSelection()&&this.isRowSelection()?e:s;return new C(b.from(l),1,1)}replace(e,n=C.empty){let r=e.steps.length,o=this.ranges;for(let s=0;s<o.length;s++){let{$from:l,$to:a}=o[s],c=e.mapping.slice(r);e.replace(c.map(l.pos),c.map(a.pos),s?C.empty:n)}let i=E.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,n){this.replace(e,new C(b.from(n),0,0))}forEachCell(e){let n=this.$anchorCell.node(-1),r=J.get(n),o=this.$anchorCell.start(-1),i=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o));for(let s=0;s<i.length;s++)e(n.nodeAt(i[s]),o+i[s])}isColSelection(){let e=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(e,n)>0)return!1;let r=e+this.$anchorCell.nodeAfter.attrs.rowspan,o=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,o)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){let r=e.node(-1),o=J.get(r),i=e.start(-1),s=o.findCell(e.pos-i),l=o.findCell(n.pos-i),a=e.node(0);return s.top<=l.top?(s.top>0&&(e=a.resolve(i+o.map[s.left])),l.bottom<o.height&&(n=a.resolve(i+o.map[o.width*(o.height-1)+l.right-1]))):(l.top>0&&(n=a.resolve(i+o.map[l.left])),s.bottom<o.height&&(e=a.resolve(i+o.map[o.width*(o.height-1)+s.right-1]))),new ot(e,n)}isRowSelection(){let e=this.$anchorCell.node(-1),n=J.get(e),r=this.$anchorCell.start(-1),o=n.colCount(this.$anchorCell.pos-r),i=n.colCount(this.$headCell.pos-r);if(Math.min(o,i)>0)return!1;let s=o+this.$anchorCell.nodeAfter.attrs.colspan,l=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,l)==n.width}eq(e){return e instanceof ot&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){let r=e.node(-1),o=J.get(r),i=e.start(-1),s=o.findCell(e.pos-i),l=o.findCell(n.pos-i),a=e.node(0);return s.left<=l.left?(s.left>0&&(e=a.resolve(i+o.map[s.top*o.width])),l.right<o.width&&(n=a.resolve(i+o.map[o.width*(l.top+1)-1]))):(l.left>0&&(n=a.resolve(i+o.map[l.top*o.width])),s.right<o.width&&(e=a.resolve(i+o.map[o.width*(s.top+1)-1]))),new ot(e,n)}toJSON(){return{type:\"cell\",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new ot(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){return new ot(e.resolve(n),e.resolve(r))}getBookmark(){return new Vk(this.$anchorCell.pos,this.$headCell.pos)}};j.prototype.visible=!1;E.jsonID(\"cell\",j);var Vk=class Bf{constructor(e,n){this.anchor=e,this.head=n}map(e){return new Bf(e.map(this.anchor),e.map(this.head))}resolve(e){let n=e.resolve(this.anchor),r=e.resolve(this.head);return n.parent.type.spec.tableRole==\"row\"&&r.parent.type.spec.tableRole==\"row\"&&n.index()<n.parent.childCount&&r.index()<r.parent.childCount&&xl(n,r)?new j(n,r):E.near(r,1)}};function _k(t){if(!(t.selection instanceof j))return null;let e=[];return t.selection.forEachCell((n,r)=>{e.push(ee.node(r,r+n.nodeSize,{class:\"selectedCell\"}))}),z.create(t.doc,e)}function Kk({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let n=t.pos,r=e.pos,o=t.depth;for(;o>=0&&!(t.after(o+1)<t.end(o));o--,n++);for(let i=e.depth;i>=0&&!(e.before(i+1)>e.start(i));i--,r--);return n==r&&/row|table/.test(t.node(o).type.spec.tableRole)}function Uk({$from:t,$to:e}){let n,r;for(let o=t.depth;o>0;o--){let i=t.node(o);if(i.type.spec.tableRole===\"cell\"||i.type.spec.tableRole===\"header_cell\"){n=i;break}}for(let o=e.depth;o>0;o--){let i=e.node(o);if(i.type.spec.tableRole===\"cell\"||i.type.spec.tableRole===\"header_cell\"){r=i;break}}return n!==r&&e.parentOffset===0}function Jk(t,e,n){let r=(e||t).selection,o=(e||t).doc,i,s;if(r instanceof A&&(s=r.node.type.spec.tableRole)){if(s==\"cell\"||s==\"header_cell\")i=j.create(o,r.from);else if(s==\"row\"){let l=o.resolve(r.from+1);i=j.rowSelection(l,l)}else if(!n){let l=J.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];i=j.create(o,a+1,c)}}else r instanceof M&&Kk(r)?i=M.create(o,r.from):r instanceof M&&Uk(r)&&(i=M.create(o,r.$from.start(),r.$from.end()));return i&&(e||(e=t.tr)).setSelection(i),e}var qk=new P(\"fix-tables\");function Ff(t,e,n,r){let o=t.childCount,i=e.childCount;e:for(let s=0,l=0;s<i;s++){let a=e.child(s);for(let c=l,u=Math.min(o,s+3);c<u;c++)if(t.child(c)==a){l=c+1,n+=a.nodeSize;continue e}r(a,n),l<o&&t.child(l).sameMarkup(a)?Ff(t.child(l),a,n+1,r):a.nodesBetween(0,a.content.size,r,n+1),n+=a.nodeSize}}function Cl(t,e){let n,r=(o,i)=>{o.type.spec.tableRole==\"table\"&&(n=Gk(t,o,i,n))};return e?e.doc!=t.doc&&Ff(e.doc,t.doc,0,r):t.doc.descendants(r),n}function Gk(t,e,n,r){let o=J.get(e);if(!o.problems)return r;r||(r=t.tr);let i=[];for(let a=0;a<o.height;a++)i.push(0);for(let a=0;a<o.problems.length;a++){let c=o.problems[a];if(c.type==\"collision\"){let u=e.nodeAt(c.pos);if(!u)continue;let d=u.attrs;for(let f=0;f<d.rowspan;f++)i[c.row+f]+=c.n;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,Kt(d,d.colspan-c.n,c.n))}else if(c.type==\"missing\")i[c.row]+=c.n;else if(c.type==\"overlong_rowspan\"){let u=e.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...u.attrs,rowspan:u.attrs.rowspan-c.n})}else if(c.type==\"colwidth mismatch\"){let u=e.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...u.attrs,colwidth:c.colwidth})}else if(c.type==\"zero_sized\"){let u=r.mapping.map(n);r.delete(u,u+e.nodeSize)}}let s,l;for(let a=0;a<i.length;a++)i[a]&&(s==null&&(s=a),l=a);for(let a=0,c=n+1;a<o.height;a++){let u=e.child(a),d=c+u.nodeSize,f=i[a];if(f>0){let h=\"cell\";u.firstChild&&(h=u.firstChild.type.spec.tableRole);let p=[];for(let g=0;g<f;g++){let y=ue(t.schema)[h].createAndFill();y&&p.push(y)}let m=(a==0||s==a-1)&&l==a?c+1:d-1;r.insert(r.mapping.map(m),p)}c=d}return r.setMeta(qk,{fixTables:!0})}function He(t){let e=t.selection,n=Xo(t),r=n.node(-1),o=n.start(-1),i=J.get(r);return{...e instanceof j?i.rectBetween(e.$anchorCell.pos-o,e.$headCell.pos-o):i.findCell(n.pos-o),tableStart:o,map:i,table:r}}function Hf(t,{map:e,tableStart:n,table:r},o){let i=o>0?-1:0;Wk(e,r,o+i)&&(i=o==0||o==e.width?null:0);for(let s=0;s<e.height;s++){let l=s*e.width+o;if(o>0&&o<e.width&&e.map[l-1]==e.map[l]){let a=e.map[l],c=r.nodeAt(a);t.setNodeMarkup(t.mapping.map(n+a),null,zf(c.attrs,o-e.colCount(a))),s+=c.attrs.rowspan-1}else{let a=i==null?ue(r.type.schema).cell:r.nodeAt(e.map[l+i]).type,c=e.positionAt(s,o,r);t.insert(t.mapping.map(n+c),a.createAndFill())}}return t}function jf(t,e){if(!De(t))return!1;if(e){let n=He(t);e(Hf(t.tr,n,n.left))}return!0}function Wf(t,e){if(!De(t))return!1;if(e){let n=He(t);e(Hf(t.tr,n,n.right))}return!0}function Xk(t,{map:e,table:n,tableStart:r},o){let i=t.mapping.maps.length;for(let s=0;s<e.height;){let l=s*e.width+o,a=e.map[l],c=n.nodeAt(a),u=c.attrs;if(o>0&&e.map[l-1]==a||o<e.width-1&&e.map[l+1]==a)t.setNodeMarkup(t.mapping.slice(i).map(r+a),null,Kt(u,o-e.colCount(a)));else{let d=t.mapping.slice(i).map(r+a);t.delete(d,d+c.nodeSize)}s+=u.rowspan}}function Vf(t,e){if(!De(t))return!1;if(e){let n=He(t),r=t.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let o=n.right-1;Xk(r,n,o),o!=n.left;o--){let i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw new RangeError(\"No table found\");n.table=i,n.map=J.get(i)}e(r)}return!0}function Yk(t,e,n){var r;let o=ue(e.type.schema).header_cell;for(let i=0;i<t.width;i++)if(((r=e.nodeAt(t.map[i+n*t.width]))===null||r===void 0?void 0:r.type)!=o)return!1;return!0}function _f(t,{map:e,tableStart:n,table:r},o){let i=n;for(let c=0;c<o;c++)i+=r.child(c).nodeSize;let s=[],l=o>0?-1:0;Yk(e,r,o+l)&&(l=o==0||o==e.height?null:0);for(let c=0,u=e.width*o;c<e.width;c++,u++)if(o>0&&o<e.height&&e.map[u]==e.map[u-e.width]){let d=e.map[u],f=r.nodeAt(d).attrs;t.setNodeMarkup(n+d,null,{...f,rowspan:f.rowspan+1}),c+=f.colspan-1}else{var a;let d=l==null?ue(r.type.schema).cell:(a=r.nodeAt(e.map[u+l*e.width]))===null||a===void 0?void 0:a.type,f=d?.createAndFill();f&&s.push(f)}return t.insert(i,ue(r.type.schema).row.create(null,s)),t}function Kf(t,e){if(!De(t))return!1;if(e){let n=He(t);e(_f(t.tr,n,n.top))}return!0}function Uf(t,e){if(!De(t))return!1;if(e){let n=He(t);e(_f(t.tr,n,n.bottom))}return!0}function Qk(t,{map:e,table:n,tableStart:r},o){let i=0;for(let c=0;c<o;c++)i+=n.child(c).nodeSize;let s=i+n.child(o).nodeSize,l=t.mapping.maps.length;t.delete(i+r,s+r);let a=new Set;for(let c=0,u=o*e.width;c<e.width;c++,u++){let d=e.map[u];if(!a.has(d)){if(a.add(d),o>0&&d==e.map[u-e.width]){let f=n.nodeAt(d).attrs;t.setNodeMarkup(t.mapping.slice(l).map(d+r),null,{...f,rowspan:f.rowspan-1}),c+=f.colspan-1}else if(o<e.height&&d==e.map[u+e.width]){let f=n.nodeAt(d),h=f.attrs,p=f.type.create({...h,rowspan:f.attrs.rowspan-1},f.content),m=e.positionAt(o+1,c,n);t.insert(t.mapping.slice(l).map(r+m),p),c+=h.colspan-1}}}}function Jf(t,e){if(!De(t))return!1;if(e){let n=He(t),r=t.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let o=n.bottom-1;Qk(r,n,o),o!=n.top;o--){let i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw new RangeError(\"No table found\");n.table=i,n.map=J.get(n.table)}e(r)}return!0}function Af(t){let e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function Zk({width:t,height:e,map:n},r){let o=r.top*t+r.left,i=o,s=(r.bottom-1)*t+r.left,l=o+(r.right-r.left-1);for(let a=r.top;a<r.bottom;a++){if(r.left>0&&n[i]==n[i-1]||r.right<t&&n[l]==n[l+1])return!0;i+=t,l+=t}for(let a=r.left;a<r.right;a++){if(r.top>0&&n[o]==n[o-t]||r.bottom<e&&n[s]==n[s+t])return!0;o++,s++}return!1}function Ml(t,e){let n=t.selection;if(!(n instanceof j)||n.$anchorCell.pos==n.$headCell.pos)return!1;let r=He(t),{map:o}=r;if(Zk(o,r))return!1;if(e){let i=t.tr,s={},l=b.empty,a,c;for(let u=r.top;u<r.bottom;u++)for(let d=r.left;d<r.right;d++){let f=o.map[u*o.width+d],h=r.table.nodeAt(f);if(!(s[f]||!h))if(s[f]=!0,a==null)a=f,c=h;else{Af(h)||(l=l.append(h.content));let p=i.mapping.map(f+r.tableStart);i.delete(p,p+h.nodeSize)}}if(a==null||c==null)return!0;if(i.setNodeMarkup(a+r.tableStart,null,{...zf(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),l.size>0){let u=a+1+c.content.size,d=Af(c)?a+1:u;i.replaceWith(d+r.tableStart,u+r.tableStart,l)}i.setSelection(new j(i.doc.resolve(a+r.tableStart))),e(i)}return!0}function vl(t,e){let n=ue(t.schema);return e1(({node:r})=>n[r.type.spec.tableRole])(t,e)}function e1(t){return(e,n)=>{let r=e.selection,o,i;if(r instanceof j){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;o=r.$anchorCell.nodeAfter,i=r.$anchorCell.pos}else{var s;if(o=Fk(r.$from),!o)return!1;i=(s=_t(r.$from))===null||s===void 0?void 0:s.pos}if(o==null||i==null||o.attrs.colspan==1&&o.attrs.rowspan==1)return!1;if(n){let l=o.attrs,a=[],c=l.colwidth;l.rowspan>1&&(l={...l,rowspan:1}),l.colspan>1&&(l={...l,colspan:1});let u=He(e),d=e.tr;for(let h=0;h<u.right-u.left;h++)a.push(c?{...l,colwidth:c&&c[h]?[c[h]]:null}:l);let f;for(let h=u.top;h<u.bottom;h++){let p=u.map.positionAt(h,u.left,u.table);h==u.top&&(p+=o.nodeSize);for(let m=u.left,g=0;m<u.right;m++,g++)m==u.left&&h==u.top||d.insert(f=d.mapping.map(p+u.tableStart,1),t({node:o,row:h,col:m}).createAndFill(a[g]))}d.setNodeMarkup(i,t({node:o,row:u.top,col:u.left}),a[0]),r instanceof j&&d.setSelection(new j(d.doc.resolve(r.$anchorCell.pos),f?d.doc.resolve(f):void 0)),n(d)}return!0}}function qf(t,e){return function(n,r){if(!De(n))return!1;let o=Xo(n);if(o.nodeAfter.attrs[t]===e)return!1;if(r){let i=n.tr;n.selection instanceof j?n.selection.forEachCell((s,l)=>{s.attrs[t]!==e&&i.setNodeMarkup(l,null,{...s.attrs,[t]:e})}):i.setNodeMarkup(o.pos,null,{...o.nodeAfter.attrs,[t]:e}),r(i)}return!0}}function t1(t){return function(e,n){if(!De(e))return!1;if(n){let r=ue(e.schema),o=He(e),i=e.tr,s=o.map.cellsInRect(t==\"column\"?{left:o.left,top:0,right:o.right,bottom:o.map.height}:t==\"row\"?{left:0,top:o.top,right:o.map.width,bottom:o.bottom}:o),l=s.map(a=>o.table.nodeAt(a));for(let a=0;a<s.length;a++)l[a].type==r.header_cell&&i.setNodeMarkup(o.tableStart+s[a],r.cell,l[a].attrs);if(i.steps.length===0)for(let a=0;a<s.length;a++)i.setNodeMarkup(o.tableStart+s[a],r.header_cell,l[a].attrs);n(i)}return!0}}function Tf(t,e,n){let r=e.map.cellsInRect({left:0,top:0,right:t==\"row\"?e.map.width:1,bottom:t==\"column\"?e.map.height:1});for(let o=0;o<r.length;o++){let i=e.table.nodeAt(r[o]);if(i&&i.type!==n.header_cell)return!1}return!0}function Cn(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?t1(t):function(n,r){if(!De(n))return!1;if(r){let o=ue(n.schema),i=He(n),s=n.tr,l=Tf(\"row\",i,o),a=Tf(\"column\",i,o),c=(t===\"column\"?l:t===\"row\"&&a)?1:0,u=t==\"column\"?{left:0,top:c,right:1,bottom:i.map.height}:t==\"row\"?{left:c,top:0,right:i.map.width,bottom:1}:i,d=t==\"column\"?a?o.cell:o.header_cell:t==\"row\"?l?o.cell:o.header_cell:o.cell;i.map.cellsInRect(u).forEach(f=>{let h=f+i.tableStart,p=s.doc.nodeAt(h);p&&s.setNodeMarkup(h,d,p.attrs)}),r(s)}return!0}}var _x=Cn(\"row\",{useDeprecatedLogic:!0}),Kx=Cn(\"column\",{useDeprecatedLogic:!0}),Gf=Cn(\"cell\",{useDeprecatedLogic:!0});function n1(t,e){if(e<0){let n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let r=t.index(-1)-1,o=t.before();r>=0;r--){let i=t.node(-1).child(r),s=i.lastChild;if(s)return o-1-s.nodeSize;o-=i.nodeSize}}else{if(t.index()<t.parent.childCount-1)return t.pos+t.nodeAfter.nodeSize;let n=t.node(-1);for(let r=t.indexAfter(-1),o=t.after();r<n.childCount;r++){let i=n.child(r);if(i.childCount)return o+1;o+=i.nodeSize}}return null}function El(t){return function(e,n){if(!De(e))return!1;let r=n1(Xo(e),t);if(r==null)return!1;if(n){let o=e.doc.resolve(r);n(e.tr.setSelection(M.between(o,jk(o))).scrollIntoView())}return!0}}function Xf(t,e){let n=t.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole==\"table\")return e&&e(t.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function Ko(t,e){let n=t.selection;if(!(n instanceof j))return!1;if(e){let r=t.tr,o=ue(t.schema).cell.createAndFill().content;n.forEachCell((i,s)=>{i.content.eq(o)||r.replace(r.mapping.map(s+1),r.mapping.map(s+i.nodeSize-1),new C(o,0,0))}),r.docChanged&&e(r)}return!0}function r1(t){if(t.size===0)return null;let{content:e,openStart:n,openEnd:r}=t;for(;e.childCount==1&&(n>0&&r>0||e.child(0).type.spec.tableRole==\"table\");)n--,r--,e=e.child(0).content;let o=e.child(0),i=o.type.spec.tableRole,s=o.type.schema,l=[];if(i==\"row\")for(let a=0;a<e.childCount;a++){let c=e.child(a).content,u=a?0:Math.max(0,n-1),d=a<e.childCount-1?0:Math.max(0,r-1);(u||d)&&(c=wl(ue(s).row,new C(c,u,d)).content),l.push(c)}else if(i==\"cell\"||i==\"header_cell\")l.push(n||r?wl(ue(s).row,new C(e,n,r)).content:e);else return null;return o1(s,l)}function o1(t,e){let n=[];for(let o=0;o<e.length;o++){let i=e[o];for(let s=i.childCount-1;s>=0;s--){let{rowspan:l,colspan:a}=i.child(s).attrs;for(let c=o;c<o+l;c++)n[c]=(n[c]||0)+a}}let r=0;for(let o=0;o<n.length;o++)r=Math.max(r,n[o]);for(let o=0;o<n.length;o++)if(o>=e.length&&e.push(b.empty),n[o]<r){let i=ue(t).cell.createAndFill(),s=[];for(let l=n[o];l<r;l++)s.push(i);e[o]=e[o].append(b.from(s))}return{height:e.length,width:r,rows:e}}function wl(t,e){let n=t.createAndFill();return new st(n).replace(0,n.content.size,e).doc}function i1({width:t,height:e,rows:n},r,o){if(t!=r){let i=[],s=[];for(let l=0;l<n.length;l++){let a=n[l],c=[];for(let u=i[l]||0,d=0;u<r;d++){let f=a.child(d%a.childCount);u+f.attrs.colspan>r&&(f=f.type.createChecked(Kt(f.attrs,f.attrs.colspan,u+f.attrs.colspan-r),f.content)),c.push(f),u+=f.attrs.colspan;for(let h=1;h<f.attrs.rowspan;h++)i[l+h]=(i[l+h]||0)+f.attrs.colspan}s.push(b.from(c))}n=s,t=r}if(e!=o){let i=[];for(let s=0,l=0;s<o;s++,l++){let a=[],c=n[l%e];for(let u=0;u<c.childCount;u++){let d=c.child(u);s+d.attrs.rowspan>o&&(d=d.type.create({...d.attrs,rowspan:Math.max(1,o-d.attrs.rowspan)},d.content)),a.push(d)}i.push(b.from(a))}n=i,e=o}return{width:t,height:e,rows:n}}function s1(t,e,n,r,o,i,s){let l=t.doc.type.schema,a=ue(l),c,u;if(o>e.width)for(let d=0,f=0;d<e.height;d++){let h=n.child(d);f+=h.nodeSize;let p=[],m;h.lastChild==null||h.lastChild.type==a.cell?m=c||(c=a.cell.createAndFill()):m=u||(u=a.header_cell.createAndFill());for(let g=e.width;g<o;g++)p.push(m);t.insert(t.mapping.slice(s).map(f-1+r),p)}if(i>e.height){let d=[];for(let p=0,m=(e.height-1)*e.width;p<Math.max(e.width,o);p++){let g=p>=e.width?!1:n.nodeAt(e.map[m+p]).type==a.header_cell;d.push(g?u||(u=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}let f=a.row.create(null,b.from(d)),h=[];for(let p=e.height;p<i;p++)h.push(f);t.insert(t.mapping.slice(s).map(r+n.nodeSize-2),h)}return!!(c||u)}function Nf(t,e,n,r,o,i,s,l){if(s==0||s==e.height)return!1;let a=!1;for(let c=o;c<i;c++){let u=s*e.width+c,d=e.map[u];if(e.map[u-e.width]==d){a=!0;let f=n.nodeAt(d),{top:h,left:p}=e.findCell(d);t.setNodeMarkup(t.mapping.slice(l).map(d+r),null,{...f.attrs,rowspan:s-h}),t.insert(t.mapping.slice(l).map(e.positionAt(s,p,n)),f.type.createAndFill({...f.attrs,rowspan:h+f.attrs.rowspan-s})),c+=f.attrs.colspan-1}}return a}function Of(t,e,n,r,o,i,s,l){if(s==0||s==e.width)return!1;let a=!1;for(let c=o;c<i;c++){let u=c*e.width+s,d=e.map[u];if(e.map[u-1]==d){a=!0;let f=n.nodeAt(d),h=e.colCount(d),p=t.mapping.slice(l).map(d+r);t.setNodeMarkup(p,null,Kt(f.attrs,s-h,f.attrs.colspan-(s-h))),t.insert(p+f.nodeSize,f.type.createAndFill(Kt(f.attrs,0,s-h))),c+=f.attrs.rowspan-1}}return a}function Rf(t,e,n,r,o){let i=n?t.doc.nodeAt(n-1):t.doc;if(!i)throw new Error(\"No table found\");let s=J.get(i),{top:l,left:a}=r,c=a+o.width,u=l+o.height,d=t.tr,f=0;function h(){if(i=n?d.doc.nodeAt(n-1):d.doc,!i)throw new Error(\"No table found\");s=J.get(i),f=d.mapping.maps.length}s1(d,s,i,n,c,u,f)&&h(),Nf(d,s,i,n,a,c,l,f)&&h(),Nf(d,s,i,n,a,c,u,f)&&h(),Of(d,s,i,n,l,u,a,f)&&h(),Of(d,s,i,n,l,u,c,f)&&h();for(let p=l;p<u;p++){let m=s.positionAt(p,a,i),g=s.positionAt(p,c,i);d.replace(d.mapping.slice(f).map(m+n),d.mapping.slice(f).map(g+n),new C(o.rows[p-l],0,0))}h(),d.setSelection(new j(d.doc.resolve(n+s.positionAt(l,a,i)),d.doc.resolve(n+s.positionAt(u-1,c-1,i)))),e(d)}var l1=qn({ArrowLeft:Uo(\"horiz\",-1),ArrowRight:Uo(\"horiz\",1),ArrowUp:Uo(\"vert\",-1),ArrowDown:Uo(\"vert\",1),\"Shift-ArrowLeft\":Jo(\"horiz\",-1),\"Shift-ArrowRight\":Jo(\"horiz\",1),\"Shift-ArrowUp\":Jo(\"vert\",-1),\"Shift-ArrowDown\":Jo(\"vert\",1),Backspace:Ko,\"Mod-Backspace\":Ko,Delete:Ko,\"Mod-Delete\":Ko});function qo(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function Uo(t,e){return(n,r,o)=>{if(!o)return!1;let i=n.selection;if(i instanceof j)return qo(n,r,E.near(i.$headCell,e));if(t!=\"horiz\"&&!i.empty)return!1;let s=Yf(o,t,e);if(s==null)return!1;if(t==\"horiz\")return qo(n,r,E.near(n.doc.resolve(i.head+e),e));{let l=n.doc.resolve(s),a=$f(l,t,e),c;return a?c=E.near(a,1):e<0?c=E.near(n.doc.resolve(l.before(-1)),-1):c=E.near(n.doc.resolve(l.after(-1)),1),qo(n,r,c)}}}function Jo(t,e){return(n,r,o)=>{if(!o)return!1;let i=n.selection,s;if(i instanceof j)s=i;else{let a=Yf(o,t,e);if(a==null)return!1;s=new j(n.doc.resolve(a))}let l=$f(s.$headCell,t,e);return l?qo(n,r,new j(s.$anchorCell,l)):!1}}function a1(t,e){let n=t.state.doc,r=_t(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new j(r))),!0):!1}function c1(t,e,n){if(!De(t.state))return!1;let r=r1(n),o=t.state.selection;if(o instanceof j){r||(r={width:1,height:1,rows:[b.from(wl(ue(t.state.schema).cell,n))]});let i=o.$anchorCell.node(-1),s=o.$anchorCell.start(-1),l=J.get(i).rectBetween(o.$anchorCell.pos-s,o.$headCell.pos-s);return r=i1(r,l.right-l.left,l.bottom-l.top),Rf(t.state,t.dispatch,s,l,r),!0}else if(r){let i=Xo(t.state),s=i.start(-1);return Rf(t.state,t.dispatch,s,J.get(i.node(-1)).findCell(i.pos-s),r),!0}else return!1}function u1(t,e){var n;if(e.button!=0||e.ctrlKey||e.metaKey)return;let r=Df(t,e.target),o;if(e.shiftKey&&t.state.selection instanceof j)i(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(o=_t(t.state.selection.$anchor))!=null&&((n=gl(t,e))===null||n===void 0?void 0:n.pos)!=o.pos)i(o,e),e.preventDefault();else if(!r)return;function i(a,c){let u=gl(t,c),d=yt.getState(t.state)==null;if(!u||!xl(a,u))if(d)u=a;else return;let f=new j(a,u);if(d||!t.state.selection.eq(f)){let h=t.state.tr.setSelection(f);d&&h.setMeta(yt,a.pos),t.dispatch(h)}}function s(){t.root.removeEventListener(\"mouseup\",s),t.root.removeEventListener(\"dragstart\",s),t.root.removeEventListener(\"mousemove\",l),yt.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(yt,-1))}function l(a){let c=a,u=yt.getState(t.state),d;if(u!=null)d=t.state.doc.resolve(u);else if(Df(t,c.target)!=r&&(d=gl(t,e),!d))return s();d&&i(d,c)}t.root.addEventListener(\"mouseup\",s),t.root.addEventListener(\"dragstart\",s),t.root.addEventListener(\"mousemove\",l)}function Yf(t,e,n){if(!(t.state.selection instanceof M))return null;let{$head:r}=t.state.selection;for(let o=r.depth-1;o>=0;o--){let i=r.node(o);if((n<0?r.index(o):r.indexAfter(o))!=(n<0?0:i.childCount))return null;if(i.type.spec.tableRole==\"cell\"||i.type.spec.tableRole==\"header_cell\"){let s=r.before(o),l=e==\"vert\"?n>0?\"down\":\"up\":n>0?\"right\":\"left\";return t.endOfTextblock(l)?s:null}}return null}function Df(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName==\"TD\"||e.nodeName==\"TH\")return e;return null}function gl(t,e){let n=t.posAtCoords({left:e.clientX,top:e.clientY});if(!n)return null;let{inside:r,pos:o}=n;return r>=0&&_t(t.state.doc.resolve(r))||_t(t.state.doc.resolve(o))}var d1=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\")),Sl(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement(\"tbody\"))}update(t){return t.type!=this.node.type?!1:(this.node=t,Sl(t,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(t){return t.type==\"attributes\"&&(t.target==this.table||this.colgroup.contains(t.target))}};function Sl(t,e,n,r,o,i){let s=0,l=!0,a=e.firstChild,c=t.firstChild;if(c){for(let d=0,f=0;d<c.childCount;d++){let{colspan:h,colwidth:p}=c.child(d).attrs;for(let m=0;m<h;m++,f++){let g=o==f?i:p&&p[m],y=g?g+\"px\":\"\";if(s+=g||r,g||(l=!1),a)a.style.width!=y&&(a.style.width=y),a=a.nextSibling;else{let S=document.createElement(\"col\");S.style.width=y,e.appendChild(S)}}}for(;a;){var u;let d=a.nextSibling;(u=a.parentNode)===null||u===void 0||u.removeChild(a),a=d}l?(n.style.width=s+\"px\",n.style.minWidth=\"\"):(n.style.width=\"\",n.style.minWidth=s+\"px\")}}var Se=new P(\"tableColumnResizing\");function Qf({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:r=d1,lastColumnResizable:o=!0}={}){let i=new R({key:Se,state:{init(s,l){var a;let c=(a=i.spec)===null||a===void 0||(a=a.props)===null||a===void 0?void 0:a.nodeViews,u=ue(l.schema).table.name;return r&&c&&(c[u]=(d,f)=>new r(d,n,f)),new f1(-1,!1)},apply(s,l){return l.apply(s)}},props:{attributes:s=>{let l=Se.getState(s);return l&&l.activeHandle>-1?{class:\"resize-cursor\"}:{}},handleDOMEvents:{mousemove:(s,l)=>{h1(s,l,t,o)},mouseleave:s=>{p1(s)},mousedown:(s,l)=>{m1(s,l,e,n)}},decorations:s=>{let l=Se.getState(s);if(l&&l.activeHandle>-1)return w1(s,l.activeHandle)},nodeViews:{}}});return i}var f1=class Go{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){let n=this,r=e.getMeta(Se);if(r&&r.setHandle!=null)return new Go(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new Go(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let o=e.mapping.map(n.activeHandle,-1);return kl(e.doc.resolve(o))||(o=-1),new Go(o,n.dragging)}return n}};function h1(t,e,n,r){if(!t.editable)return;let o=Se.getState(t.state);if(o&&!o.dragging){let i=y1(e.target),s=-1;if(i){let{left:l,right:a}=i.getBoundingClientRect();e.clientX-l<=n?s=If(t,e,\"left\",n):a-e.clientX<=n&&(s=If(t,e,\"right\",n))}if(s!=o.activeHandle){if(!r&&s!==-1){let l=t.state.doc.resolve(s),a=l.node(-1),c=J.get(a),u=l.start(-1);if(c.colCount(l.pos-u)+l.nodeAfter.attrs.colspan-1==c.width-1)return}Zf(t,s)}}}function p1(t){if(!t.editable)return;let e=Se.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&Zf(t,-1)}function m1(t,e,n,r){var o;if(!t.editable)return!1;let i=(o=t.dom.ownerDocument.defaultView)!==null&&o!==void 0?o:window,s=Se.getState(t.state);if(!s||s.activeHandle==-1||s.dragging)return!1;let l=t.state.doc.nodeAt(s.activeHandle),a=g1(t,s.activeHandle,l.attrs);t.dispatch(t.state.tr.setMeta(Se,{setDragging:{startX:e.clientX,startWidth:a}}));function c(d){i.removeEventListener(\"mouseup\",c),i.removeEventListener(\"mousemove\",u);let f=Se.getState(t.state);f?.dragging&&(b1(t,f.activeHandle,Pf(f.dragging,d,n)),t.dispatch(t.state.tr.setMeta(Se,{setDragging:null})))}function u(d){if(!d.which)return c(d);let f=Se.getState(t.state);if(f&&f.dragging){let h=Pf(f.dragging,d,n);Lf(t,f.activeHandle,h,r)}}return Lf(t,s.activeHandle,a,r),i.addEventListener(\"mouseup\",c),i.addEventListener(\"mousemove\",u),e.preventDefault(),!0}function g1(t,e,{colspan:n,colwidth:r}){let o=r&&r[r.length-1];if(o)return o;let i=t.domAtPos(e),s=i.node.childNodes[i.offset].offsetWidth,l=n;if(r)for(let a=0;a<n;a++)r[a]&&(s-=r[a],l--);return s/l}function y1(t){for(;t&&t.nodeName!=\"TD\"&&t.nodeName!=\"TH\";)t=t.classList&&t.classList.contains(\"ProseMirror\")?null:t.parentNode;return t}function If(t,e,n,r){let o=n==\"right\"?-r:r,i=t.posAtCoords({left:e.clientX+o,top:e.clientY});if(!i)return-1;let{pos:s}=i,l=_t(t.state.doc.resolve(s));if(!l)return-1;if(n==\"right\")return l.pos;let a=J.get(l.node(-1)),c=l.start(-1),u=a.map.indexOf(l.pos-c);return u%a.width==0?-1:c+a.map[u-1]}function Pf(t,e,n){let r=e.clientX-t.startX;return Math.max(n,t.startWidth+r)}function Zf(t,e){t.dispatch(t.state.tr.setMeta(Se,{setHandle:e}))}function b1(t,e,n){let r=t.state.doc.resolve(e),o=r.node(-1),i=J.get(o),s=r.start(-1),l=i.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1,a=t.state.tr;for(let c=0;c<i.height;c++){let u=c*i.width+l;if(c&&i.map[u]==i.map[u-i.width])continue;let d=i.map[u],f=o.nodeAt(d).attrs,h=f.colspan==1?0:l-i.colCount(d);if(f.colwidth&&f.colwidth[h]==n)continue;let p=f.colwidth?f.colwidth.slice():k1(f.colspan);p[h]=n,a.setNodeMarkup(s+d,null,{...f,colwidth:p})}a.docChanged&&t.dispatch(a)}function Lf(t,e,n,r){let o=t.state.doc.resolve(e),i=o.node(-1),s=o.start(-1),l=J.get(i).colCount(o.pos-s)+o.nodeAfter.attrs.colspan-1,a=t.domAtPos(o.start(-1)).node;for(;a&&a.nodeName!=\"TABLE\";)a=a.parentNode;a&&Sl(i,a.firstChild,a,r,l,n)}function k1(t){return Array(t).fill(0)}function w1(t,e){let n=[],r=t.doc.resolve(e),o=r.node(-1);if(!o)return z.empty;let i=J.get(o),s=r.start(-1),l=i.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1;for(let c=0;c<i.height;c++){let u=l+c*i.width;if((l==i.width-1||i.map[u]!=i.map[u+1])&&(c==0||i.map[u]!=i.map[u-i.width])){var a;let d=i.map[u],f=s+d+o.nodeAt(d).nodeSize-1,h=document.createElement(\"div\");h.className=\"column-resize-handle\",!((a=Se.getState(t))===null||a===void 0)&&a.dragging&&n.push(ee.node(s+d,s+d+o.nodeAt(d).nodeSize,{class:\"column-resize-dragging\"})),n.push(ee.widget(f,h))}}return z.create(t.doc,n)}function eh({allowTableNodeSelection:t=!1}={}){return new R({key:yt,state:{init(){return null},apply(e,n){let r=e.getMeta(yt);if(r!=null)return r==-1?null:r;if(n==null||!e.docChanged)return n;let{deleted:o,pos:i}=e.mapping.mapResult(n);return o?null:i}},props:{decorations:_k,handleDOMEvents:{mousedown:u1},createSelectionBetween(e){return yt.getState(e.state)!=null?e.state.selection:null},handleTripleClick:a1,handleKeyDown:l1,handlePaste:c1},appendTransaction(e,n,r){return Jk(r,Cl(r,n),t)}})}function ar(t){return t===\"left\"||t===\"right\"||t===\"center\"?t:null}function S1(t){let e=(t.style.textAlign||\"\").trim().toLowerCase(),n=(t.getAttribute(\"align\")||\"\").trim().toLowerCase();return ar(e||n)}function x1(t){return ar(t?.align)}function ih(){return{default:null,parseHTML:t=>S1(t),renderHTML:t=>{let e=ar(t.align);return vd(e)?{style:`text-align: ${e}`}:{}}}}function C1(t){var e;let n=t.parentElement,r=t.closest(\"table\");if(!n||!r)return null;let o=Array.from(n.children).indexOf(t),i=(e=r.querySelectorAll(\"colgroup > col\")[o])===null||e===void 0?void 0:e.getAttribute(\"width\");return i?[parseInt(i,10)]:null}function sh(t){let e=t.getAttribute(\"colwidth\");return e?e.split(\",\").map(n=>parseInt(n,10)):C1(t)}var M1=/[ \\t\\r\\n\\f]+/g;function lh(t){var e;return t.children.length>0?!1:((e=t.textContent)!==null&&e!==void 0?e:\"\").replace(M1,\"\")===\"\"}function ah(t){let e=t.createAndFill();if(!e)throw new Error(`[tiptap error]: \"${t.name}\" has no default content to backfill.`);return e.content}function Qo(t,e,n){if(!(n in e))return;let r=e[n];(r===1||r===\"1\"||r===null||r===void 0)&&delete t[n]}var Tl=K.create({name:\"tableCell\",addOptions(){return{HTMLAttributes:{}}},content:\"block+\",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:sh},align:ih()}},tableRole:\"cell\",isolating:!0,parseHTML(){return[{tag:\"td\",getAttrs:t=>lh(t)?{}:!1,getContent:(t,e)=>ah(e.nodes[this.name])},{tag:\"td\"}]},renderHTML({HTMLAttributes:t}){let e=B(this.options.HTMLAttributes,t);return Qo(e,t,\"colspan\"),Qo(e,t,\"rowspan\"),[\"td\",e,0]}}),Nl=K.create({name:\"tableHeader\",addOptions(){return{HTMLAttributes:{}}},content:\"block+\",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:sh},align:ih()}},tableRole:\"header_cell\",isolating:!0,parseHTML(){return[{tag:\"th\",getAttrs:t=>lh(t)?{}:!1,getContent:(t,e)=>ah(e.nodes[this.name])},{tag:\"th\"}]},renderHTML({HTMLAttributes:t}){let e=B(this.options.HTMLAttributes,t);return Qo(e,t,\"colspan\"),Qo(e,t,\"rowspan\"),[\"th\",e,0]}}),Ol=K.create({name:\"tableRow\",addOptions(){return{HTMLAttributes:{}}},content:\"(tableCell | tableHeader)*\",tableRole:\"row\",parseHTML(){return[{tag:\"tr\"}]},renderHTML({HTMLAttributes:t}){return[\"tr\",B(this.options.HTMLAttributes,t),0]}});function Al(t,e){return e?[\"width\",`${Math.max(e,t)}px`]:[\"min-width\",`${t}px`]}function th(t,e,n,r,o,i){let s=0,l=!0,a=e.firstChild,c=t.firstChild;if(c!==null)for(let f=0,h=0;f<c.childCount;f+=1){let{colspan:p,colwidth:m}=c.child(f).attrs;for(let g=0;g<p;g+=1,h+=1){let y=o===h?i:m&&m[g],S=y?`${y}px`:\"\";if(s+=y||r,y||(l=!1),a){if(a.style.width!==S){let[k,x]=Al(r,y);a.style.setProperty(k,x)}a=a.nextSibling}else{let k=document.createElement(\"col\"),[x,O]=Al(r,y);k.style.setProperty(x,O),e.appendChild(k)}}}for(;a;){var u;let f=a.nextSibling;(u=a.parentNode)===null||u===void 0||u.removeChild(a),a=f}let d=t.attrs.style&&typeof t.attrs.style==\"string\"&&/\\bwidth\\s*:/i.test(t.attrs.style);l&&!d?(n.style.width=`${s}px`,n.style.minWidth=\"\"):(n.style.width=\"\",n.style.minWidth=`${s}px`)}var v1=class{constructor(t,e,n,r={}){this.node=t,this.cellMinWidth=e,this.dom=document.createElement(\"div\"),this.dom.className=\"tableWrapper\",this.table=this.dom.appendChild(document.createElement(\"table\"));for(let[o,i]of Object.entries(r))i!=null&&(o===\"style\"?this.table.style.cssText=String(i):this.table.setAttribute(o,String(i)));t.attrs.style&&(this.table.style.cssText=t.attrs.style),this.colgroup=this.table.appendChild(document.createElement(\"colgroup\")),th(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement(\"tbody\"))}update(t){return t.sameMarkup(this.node)?(this.node=t,th(t,this.colgroup,this.table,this.cellMinWidth),!0):!1}ignoreMutation(t){let e=t.target,n=this.dom.contains(e),r=this.contentDOM.contains(e);return!!(n&&!r&&(t.type===\"attributes\"||t.type===\"childList\"||t.type===\"characterData\"))}};function E1(t,e,n,r){let o=0,i=!0,s=[],l=t.firstChild;if(!l)return{};for(let u=0,d=0;u<l.childCount;u+=1){let{colspan:f,colwidth:h}=l.child(u).attrs;for(let p=0;p<f;p+=1,d+=1){let m=n===d?r:h&&h[p];o+=m||e,m||(i=!1);let[g,y]=Al(e,m);s.push([\"col\",{style:`${g}: ${y}`}])}}let a=i?`${o}px`:\"\",c=i?\"\":`${o}px`;return{colgroup:[\"colgroup\",{},...s],tableWidth:a,tableMinWidth:c}}function nh(t,e){return e?t.createChecked(null,e):t.createAndFill()}function A1(t){if(t.cached.tableNodeTypes)return t.cached.tableNodeTypes;let e={};return Object.keys(t.nodes).forEach(n=>{let r=t.nodes[n];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),t.cached.tableNodeTypes=e,e}function T1(t,e,n,r,o){let i=A1(t),s=[],l=[];for(let c=0;c<n;c+=1){let u=nh(i.cell,o);if(u&&l.push(u),r){let d=nh(i.header_cell,o);d&&s.push(d)}}let a=[];for(let c=0;c<e;c+=1)a.push(i.row.createChecked(null,r&&c===0?s:l));return i.table.createChecked(null,a)}function ch(t){return t instanceof j}var Yo=({editor:t})=>{let{selection:e}=t.state;if(!ch(e))return!1;let n=0,r=pn(e.ranges[0].$from,o=>o.type.name===\"table\");return r?.node.descendants(o=>{if(o.type.name===\"table\")return!1;[\"tableCell\",\"tableHeader\"].includes(o.type.name)&&(n+=1)}),n!==e.ranges.length?!1:(t.commands.deleteTable(),!0)};function rh(t,e){let n=t.mapping.map(e),r=pn(t.selection.$from,s=>s.type.name===\"table\");if(r?.pos===n)return;let o=t.doc.nodeAt(n);if(!o)return;let i=n+o.nodeSize-1;t.setSelection(M.near(t.doc.resolve(i),-1))}function N1(t){let e=\"\",n=0;for(;n<t.length;){if(t[n]===\"\\\\\"&&n+1<t.length){e+=t[n]+t[n+1],n+=2;continue}if(t[n]!==\"`\"){e+=t[n++];continue}let r=0;for(;n+r<t.length&&t[n+r]===\"`\";)r+=1;let o=n+r,i=!1;for(;o<t.length;){if(t[o]!==\"`\"){o+=1;continue}let s=0;for(;o+s<t.length&&t[o+s]===\"`\";)s+=1;if(s===r){let l=t.slice(n+r,o);e+=t.slice(n,n+r)+l.replace(/\\\\\\||\\|/g,a=>a===\"|\"?\"\\\\|\":a)+t.slice(o,o+r),n=o+r,i=!0;break}o+=s}i||(e+=t.slice(n,n+r),n+=r)}return e}function O1(t){return t.split(`\n`).map(e=>!e.includes(\"|\")||!e.includes(\"`\")?e:N1(e)).join(`\n`)}function R1(t){return(t||\"\").replaceAll(\"\u001f\",\" \").replace(/\\s+/g,\" \").trim()}function oh(t,e){return e?t.split(e).join(`\n`):t}function D1(t){return t.replace(/\\\\.|\\|/g,e=>e===\"|\"?\"\\\\|\":e)}function I1(t,e,n={}){if(!t||!t.content||t.content.length===0)return\"\";let r=[];t.content.forEach(f=>{let h=[];f.content&&f.content.forEach(p=>{let m=\"\";p.content&&Array.isArray(p.content)&&p.content.length>1?m=p.content.map(k=>oh(e.renderChildren(k),n.cellLineSeparator)).join(`\n`):m=oh(p.content?e.renderChildren(p.content):\"\",n.cellLineSeparator);let g=D1(R1(m.replace(/[ \\t]*\\r?\\n[ \\t]*/g,\"<br>\"))),y=p.type===\"tableHeader\",S=x1(p.attrs);h.push({text:g,isHeader:y,align:S})}),r.push(h)});let o=r.reduce((f,h)=>Math.max(f,h.length),0);if(o===0)return\"\";let i=Array.from({length:o}).fill(0);r.forEach(f=>{for(let p=0;p<o;p+=1){var h;let m=(((h=f[p])===null||h===void 0?void 0:h.text)||\"\").length;m>i[p]&&(i[p]=m),i[p]<3&&(i[p]=3)}});let s=(f,h)=>f+\" \".repeat(Math.max(0,h-f.length)),l=r[0],a=l.some(f=>f.isHeader),c=Array.from({length:o}).fill(null);r.forEach(f=>{for(let p=0;p<o;p+=1){var h;!c[p]&&(!((h=f[p])===null||h===void 0)&&h.align)&&(c[p]=f[p].align)}});let u=`\n`,d=Array.from({length:o}).map((f,h)=>a&&l[h]&&l[h].text||\"\");return u+=`| ${d.map((f,h)=>s(f,i[h])).join(\" | \")} |\n`,u+=`| ${i.map((f,h)=>{let p=Math.max(3,f),m=c[h];return m===\"left\"?`:${\"-\".repeat(p)}`:m===\"right\"?`${\"-\".repeat(p)}:`:m===\"center\"?`:${\"-\".repeat(p)}:`:\"-\".repeat(p)}).join(\" | \")} |\n`,(a?r.slice(1):r).forEach(f=>{u+=`| ${Array.from({length:o}).fill(0).map((h,p)=>s(f[p]&&f[p].text||\"\",i[p])).join(\" | \")} |\n`}),u}var P1=new P(\"preserveCellSelectionOnContextMenu\");function L1(t,e){let n=t.posAtCoords({left:e.clientX,top:e.clientY});if(n)return n.pos;if(!(e.target instanceof Node))return null;try{return t.posAtDOM(e.target,0)}catch{return null}}function $1(t,e){let n=!1;return t.forEachCell((r,o)=>{e>=o&&e<o+r.nodeSize&&(n=!0)}),n}function z1(){return new R({key:P1,props:{handleDOMEvents:{mousedown(t,e){if(e.button!==2)return!1;let{selection:n}=t.state;if(!ch(n)||n.ranges.length<2)return!1;let r=L1(t,e);return r==null||!$1(n,r)?!1:(e.preventDefault(),!0)}}}})}var Rl=K.create({name:\"table\",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:v1,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:\"tableRow+\",tableRole:\"table\",isolating:!0,group:\"block\",parseHTML(){return[{tag:\"table\"}]},renderHTML({node:t,HTMLAttributes:e}){let{colgroup:n,tableWidth:r,tableMinWidth:o}=E1(t,this.options.cellMinWidth),i=e.style;function s(){return i||(r?`width: ${r}`:`min-width: ${o}`)}let l=[\"table\",B(this.options.HTMLAttributes,e,{style:s()}),n,[\"tbody\",0]];return this.options.renderWrapper?[\"div\",{class:\"tableWrapper\"},l]:l},parseMarkdown:(t,e)=>{let n=[],r=Array.isArray(t.align)?t.align:[];if(t.header){let o=[];t.header.forEach((i,s)=>{var l;let a=ar((l=r[s])!==null&&l!==void 0?l:i.align),c=a?{align:a}:{};o.push(e.createNode(\"tableHeader\",c,[{type:\"paragraph\",content:e.parseInline(i.tokens)}]))}),n.push(e.createNode(\"tableRow\",{},o))}return t.rows&&t.rows.forEach(o=>{let i=[];o.forEach((s,l)=>{var a;let c=ar((a=r[l])!==null&&a!==void 0?a:s.align),u=c?{align:c}:{};i.push(e.createNode(\"tableCell\",u,[{type:\"paragraph\",content:e.parseInline(s.tokens)}]))}),n.push(e.createNode(\"tableRow\",{},i))}),e.createNode(\"table\",void 0,n)},renderMarkdown:(t,e)=>I1(t,e),markdownTokenizer:{name:\"table\",level:\"block\",start:t=>{let e=t.split(`\n`);if(e.length<2)return-1;let n=e[1];return!/^[ \\t|:]*-[ \\t|:-]*$/.test(n)||!n.includes(\"|\")?-1:e[0].includes(\"|\")?0:-1},tokenize(t,e,n){let r=t.indexOf(`\n\n`),o=r>=0?t.slice(0,r):t,i=o.split(`\n`);if(i.length<2)return;let s=i[1];if(!/^[ \\t|:]*-[ \\t|:-]*$/.test(s)||!s.includes(\"|\"))return;let l=O1(o);if(l===o)return;let a=n.blockTokens(l)[0];if(a?.type!==\"table\"||!a.raw)return;let c=a.raw.split(`\n`).length,u=t.split(`\n`).slice(0,c).join(`\n`);return{...a,raw:u}}},addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:o,editor:i})=>{let s=T1(i.schema,t,e,n);if(o){let l=r.selection.from+1;r.replaceSelectionWith(s).scrollIntoView().setSelection(M.near(r.doc.resolve(l)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>jf(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>Wf(t,e),deleteColumn:()=>({state:t,dispatch:e})=>{let n=pn(t.selection.$from,r=>r.type.name===\"table\");return Vf(t,e&&(r=>{n&&rh(r,n.pos),e(r)}))},addRowBefore:()=>({state:t,dispatch:e})=>Kf(t,e),addRowAfter:()=>({state:t,dispatch:e})=>Uf(t,e),deleteRow:()=>({state:t,dispatch:e})=>{let n=pn(t.selection.$from,r=>r.type.name===\"table\");return Jf(t,e&&(r=>{n&&rh(r,n.pos),e(r)}))},deleteTable:()=>({state:t,dispatch:e})=>Xf(t,e),mergeCells:()=>({state:t,dispatch:e})=>Ml(t,e),splitCell:()=>({state:t,dispatch:e})=>vl(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>Cn(\"column\")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>Cn(\"row\")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>Gf(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>Ml(t,e)?!0:vl(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>qf(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>El(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>El(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&Cl(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){let r=j.create(e.doc,t.anchorCell,t.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,\"Shift-Tab\":()=>this.editor.commands.goToPreviousCell(),Backspace:Yo,\"Mod-Backspace\":Yo,Delete:Yo,\"Mod-Delete\":Yo}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[Qf({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:null,lastColumnResizable:this.options.lastColumnResizable})]:[],eh({allowTableNodeSelection:this.options.allowTableNodeSelection}),z1()]},addNodeView(){let t=this.options.View;return t?({node:e,view:n,HTMLAttributes:r})=>{let o=B(this.options.HTMLAttributes,r);return new t(e,this.options.cellMinWidth,n,o)}:null},extendNodeSchema(t){let e={name:t.name,options:t.options,storage:t.storage};return{tableRole:L(v(t,\"tableRole\",e))}}}),eC=V.create({name:\"tableKit\",addExtensions(){let t=[];return this.options.table!==!1&&t.push(Rl.configure(this.options.table)),this.options.tableCell!==!1&&t.push(Tl.configure(this.options.tableCell)),this.options.tableHeader!==!1&&t.push(Nl.configure(this.options.tableHeader)),this.options.tableRow!==!1&&t.push(Ol.configure(this.options.tableRow)),t}});function uh(t={}){return new R({view(e){return new Dl(e,t)}})}var Dl=class{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||\"black\",this.class=n.class,this.handlers=[\"dragover\",\"dragend\",\"drop\",\"dragleave\"].map(o=>{let i=s=>{this[o](s)};return e.dom.addEventListener(o,i),{name:o,handler:i}})}destroy(){this.setCursor(null),this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){if(this.cursorPos!=null&&n.doc!=e.state.doc)if(this.lastDragEvent){let r=this.computeTarget(this.lastDragEvent);r==this.cursorPos?this.updateOverlay():this.setCursor(r)}else this.updateOverlay()}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,o=this.editorView.dom,i=o.getBoundingClientRect(),s=i.width/o.offsetWidth,l=i.height/o.offsetHeight;if(n){let d=e.nodeBefore,f=e.nodeAfter;if(d||f){let h=this.editorView.nodeDOM(this.cursorPos-(d?d.nodeSize:0));if(h){let p=h.getBoundingClientRect(),m=d?p.bottom:p.top;d&&f&&(m=(m+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let g=this.width/2*l;r={left:p.left,right:p.right,top:m-g,bottom:m+g}}}}if(!r){let d=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*s;r={left:d.left-f,right:d.left+f,top:d.top,bottom:d.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.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);let c,u;if(!a||a==document.body&&getComputedStyle(a).position==\"static\")c=-pageXOffset,u=-pageYOffset;else{let d=a.getBoundingClientRect(),f=d.width/a.offsetWidth,h=d.height/a.offsetHeight;c=d.left-a.scrollLeft*f,u=d.top-a.scrollTop*h}this.element.style.left=(r.left-c)/s+\"px\",this.element.style.top=(r.top-u)/l+\"px\",this.element.style.width=(r.right-r.left)/s+\"px\",this.element.style.height=(r.bottom-r.top)/l+\"px\"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}computeTarget(e){let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),o=r&&r.type.spec.disableDropCursor,i=typeof o==\"function\"?o(this.editorView,n,e):o;if(!n||i)return null;let s=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=Mr(this.editorView.state.doc,s,this.editorView.dragging.slice);l!=null&&(s=l)}return s}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let n=this.computeTarget(e);n!=null&&(this.setCursor(n),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}};var de=class t extends E{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return t.valid(r)?new t(r):E.near(r)}content(){return C.empty}eq(e){return e instanceof t&&e.head==this.head}toJSON(){return{type:\"gapcursor\",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!=\"number\")throw new RangeError(\"Invalid input for GapCursor.fromJSON\");return new t(e.resolve(n.pos))}getBookmark(){return new Il(this.anchor)}static valid(e){let n=e.parent;if(n.inlineContent||!B1(e)||!F1(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let o=n.contentMatchAt(e.index()).defaultType;return o&&o.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&t.valid(e))return e;let o=e.pos,i=null;for(let s=e.depth;;s--){let l=e.node(s);if(n>0?e.indexAfter(s)<l.childCount:e.index(s)>0){i=l.child(n>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;o+=n;let a=e.doc.resolve(o);if(t.valid(a))return a}for(;;){let s=n>0?i.firstChild:i.lastChild;if(!s){if(i.isAtom&&!i.isText&&!A.isSelectable(i)){e=e.doc.resolve(o+i.nodeSize*n),r=!1;continue e}break}i=s,o+=n;let l=e.doc.resolve(o);if(t.valid(l))return l}return null}}};de.prototype.visible=!1;de.findFrom=de.findGapCursorFrom;E.jsonID(\"gapcursor\",de);var Il=class t{constructor(e){this.pos=e}map(e){return new t(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return de.valid(n)?new de(n):E.near(n)}};function dh(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function B1(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(n-1);;o=o.lastChild){if(o.childCount==0&&!o.inlineContent||dh(o.type))return!0;if(o.inlineContent)return!1}}return!0}function F1(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(n);;o=o.firstChild){if(o.childCount==0&&!o.inlineContent||dh(o.type))return!0;if(o.inlineContent)return!1}}return!0}function fh(){return new R({props:{decorations:V1,createSelectionBetween(t,e,n){return e.pos==n.pos&&de.valid(n)?new de(n):null},handleClick:j1,handleKeyDown:H1,handleDOMEvents:{beforeinput:W1}}})}var H1=qn({ArrowLeft:Zo(\"horiz\",-1),ArrowRight:Zo(\"horiz\",1),ArrowUp:Zo(\"vert\",-1),ArrowDown:Zo(\"vert\",1)});function Zo(t,e){let n=t==\"vert\"?e>0?\"down\":\"up\":e>0?\"right\":\"left\";return function(r,o,i){let s=r.selection,l=e>0?s.$to:s.$from,a=s.empty;if(s instanceof M){if(!i.endOfTextblock(n)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=de.findGapCursorFrom(l,e,a);return c?(o&&o(r.tr.setSelection(new de(c))),!0):!1}}function j1(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!de.valid(r))return!1;let o=t.posAtCoords({left:n.clientX,top:n.clientY});return o&&o.inside>-1&&A.isSelectable(t.state.doc.nodeAt(o.inside))?!1:(t.dispatch(t.state.tr.setSelection(new de(r))),!0)}function W1(t,e){if(e.inputType!=\"insertCompositionText\"||!(t.state.selection instanceof de))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let o=b.empty;for(let s=r.length-1;s>=0;s--)o=b.from(r[s].createAndFill(null,o));let i=t.state.tr.replace(n.pos,n.pos,new C(o,0,0));return i.setSelection(M.near(i.doc.resolve(n.pos+1))),t.dispatch(i),!1}function V1(t){if(!(t.selection instanceof de))return null;let e=document.createElement(\"div\");return e.className=\"ProseMirror-gapcursor\",z.create(t.doc,[ee.widget(t.selection.head,e,{key:\"gapcursor\"})])}var SC=V.create({name:\"characterCount\",addOptions(){return{limit:null,autoTrim:!0,mode:\"textSize\",textCounter:t=>t.length,wordCounter:t=>t.split(\" \").filter(e=>e!==\"\").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{let e=t?.node||this.editor.state.doc;if((t?.mode||this.options.mode)===\"textSize\"){let n=e.textBetween(0,e.content.size,void 0,\" \");return this.options.textCounter(n)}return e.nodeSize},this.storage.words=t=>{let e=t?.node||this.editor.state.doc,n=e.textBetween(0,e.content.size,\" \",\" \");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new R({key:new P(\"characterCount\"),appendTransaction:(e,n,r)=>{if(t)return;let o=this.options.limit,i=this.options.autoTrim;if(o==null||o===0||i===!1){t=!0;return}let s=this.storage.characters({node:r.doc});if(s>o){let l=s-o,a=0,c=l;console.warn(`[CharacterCount] Initial content exceeded limit of ${o} characters. Content was automatically trimmed.`);let u=r.tr.deleteRange(a,c);return t=!0,u}t=!0},filterTransaction:(e,n)=>{let r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;let o=this.storage.characters({node:n.doc}),i=this.storage.characters({node:e.doc});if(i<=r||o>r&&i>r&&i<=o)return!0;if(o>r&&i>r&&i>o||!e.getMeta(\"paste\"))return!1;let s=e.selection.$head.pos,l=s-(i-r),a=s;return e.deleteRange(l,a),!(this.storage.characters({node:e.doc})>r)}})]}}),xC=V.create({name:\"dropCursor\",addOptions(){return{color:\"currentColor\",width:1,class:void 0}},addProseMirrorPlugins(){return[uh(this.options)]}}),CC=V.create({name:\"focus\",addOptions(){return{className:\"has-focus\",mode:\"all\"}},addProseMirrorPlugins(){return[new R({key:new P(\"focus\"),props:{decorations:({doc:t,selection:e})=>{let{isEditable:n,isFocused:r}=this.editor,{anchor:o}=e,i=[];if(!n||!r)return z.create(t,[]);let s=0;this.options.mode===\"deepest\"&&t.descendants((a,c)=>{if(!a.isText){if(!(o>=c&&o<=c+a.nodeSize-1))return!1;s+=1}});let l=0;return t.descendants((a,c)=>{if(a.isText||!(o>=c&&o<=c+a.nodeSize-1))return!1;if(l+=1,this.options.mode===\"deepest\"&&s-l>0||this.options.mode===\"shallowest\"&&l>1)return this.options.mode===\"deepest\";i.push(ee.node(c,c+a.nodeSize,{class:this.options.className}))}),z.create(t,i)}}})]}}),mh=V.create({name:\"gapCursor\",addProseMirrorPlugins(){return[fh()]},extendNodeSchema(t){var e;let n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=L(v(t,\"allowGapCursor\",n)))!==null&&e!==void 0?e:null}}}),gh=\"placeholder\",hh=new P(\"tiptap__placeholder\");function yh(t){let{editor:e,placeholder:n,dataAttribute:r,pos:o,node:i,isEmptyDoc:s,hasAnchor:l,classes:{emptyNode:a,emptyEditor:c}}=t,u=[a];return s&&u.push(c),ee.node(o,o+i.nodeSize,{class:u.join(\" \"),[r]:typeof n==\"function\"?n({editor:e,node:i,pos:o,hasAnchor:l}):n})}function bh(t,e){return typeof t==\"function\"?t(e):t}function kh({editor:t,options:e,dataAttribute:n,doc:r,selection:o,from:i,to:s}){let{anchor:l}=o,a=[],c=t.isEmpty;return r.nodesBetween(i,s,(u,d)=>{let f=l>=d&&l<=d+u.nodeSize,h=!u.isLeaf&&gn(u);return u.type.isTextblock&&(f||!e.showOnlyCurrent)&&h&&a.push(yh({editor:t,isEmptyDoc:c,dataAttribute:n,hasAnchor:f,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:bh(e.emptyNodeClass,{editor:t,node:u,pos:d,hasAnchor:f})},node:u,pos:d})),e.includeChildren}),a}function wh({editor:t,options:e,dataAttribute:n,doc:r,selection:o}){if(!(t.isEditable||!e.showOnlyWhenEditable))return null;let{anchor:i}=o,s=[],l=t.isEmpty;if(e.showOnlyCurrent&&!e.includeChildren){let a=r.resolve(i),c=a.depth>0?a.node(1):a.nodeAfter,u=a.depth>0?a.before(1):i;if(c&&c.type.isTextblock&&gn(c)){let d=i>=u&&i<=u+c.nodeSize;s.push(yh({editor:t,isEmptyDoc:l,dataAttribute:n,hasAnchor:d,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:bh(e.emptyNodeClass,{editor:t,node:c,pos:u,hasAnchor:d})},node:c,pos:u}))}}else s.push(...kh({editor:t,options:e,dataAttribute:n,doc:r,selection:o,from:0,to:r.content.size}));return z.create(r,s)}function cr(t,e){let n=t.resolve(e);if(n.depth===0){var r;let i=(r=n.nodeAfter)!==null&&r!==void 0?r:n.nodeBefore;if(!i)return{from:e,to:e};let s=n.nodeAfter?e:e-i.nodeSize;return{from:s,to:s+i.nodeSize}}let o=n.before(1);return{from:o,to:o+n.node(1).nodeSize}}function ur(t,e){return{from:Math.max(0,e.from-1),to:Math.min(t.content.size,e.to-1)}}function _1(t,e,n){let r=[];return t.forEach((o,i)=>{let s=i,l=s+o.nodeSize,a=s+1,c=l+1;a<n&&c>e&&r.push({from:s,to:l})}),r}function K1(t){if(t.length===0)return[];let e=[...t].sort((r,o)=>r.from-o.from),n=[{...e[0]}];for(let r=1;r<e.length;r+=1){let o=n[n.length-1],i=e[r];i.from<=o.to?o.to=Math.max(o.to,i.to):n.push({...i})}return n}function U1(t,e){let n=_1(t,e.from,e.to);return n.push(ur(t,cr(t,e.from))),e.to>e.from?n.push(ur(t,cr(t,Math.min(e.to,t.content.size+1)-1))):e.from<t.content.size+1&&n.push(ur(t,cr(t,Math.min(e.from+1,t.content.size)))),n}function J1(t,e,n){let r=[];if(t.docChanged){let o=mn(t);for(let i of o)r.push(...U1(n.doc,i.newRange))}return t.selectionSet&&(r.push(ur(n.doc,cr(n.doc,t.mapping.map(e.selection.anchor)))),r.push(ur(n.doc,cr(n.doc,n.selection.anchor)))),K1(r)}function q1(t,e,n){let r=Math.max(0,Math.min(t,n.content.size));return{from:r,to:Math.max(r,Math.min(e,n.content.size))}}function G1({decorations:t,ranges:e,editor:n,options:r,dataAttribute:o,doc:i,selection:s}){let l=t;for(let a of e){let{from:c,to:u}=q1(a.from,a.to,i),d=l.find(c,u).filter(h=>h.from>=c&&h.to<=u);d.length&&(l=l.remove(d));let f=kh({editor:n,options:r,dataAttribute:o,doc:i,selection:s,from:c,to:u});f.length&&(l=l.add(i,f))}return l}function X1({editor:t,options:e,dataAttribute:n}){return{init(r,o){let i=wh({editor:t,options:e,dataAttribute:n,doc:o.doc,selection:o.selection});return i??z.empty},apply(r,o,i,s){return!r.docChanged&&!r.selectionSet?o:G1({decorations:o.map(r.mapping,r.doc),ranges:J1(r,i,s),editor:t,options:e,dataAttribute:n,doc:s.doc,selection:s.selection})}}}function Y1(t){return t.replace(/\\s+/g,\"-\").replace(/[^a-zA-Z0-9-]/g,\"\").replace(/^[0-9-]+/,\"\").replace(/^-+/,\"\").toLowerCase()}function Q1({editor:t,options:e}){let n=e.dataAttribute?`data-${Y1(e.dataAttribute)}`:`data-${gh}`,r=e.showOnlyCurrent&&!e.includeChildren;return new R({key:hh,...r?{}:{state:X1({editor:t,options:e,dataAttribute:n})},props:{decorations:r?({doc:o,selection:i})=>wh({editor:t,options:e,dataAttribute:n,doc:o,selection:i}):o=>{var i;return e.showOnlyWhenEditable&&!t.isEditable?z.empty:(i=hh.getState(o))!==null&&i!==void 0?i:z.empty}}})}var Sh=V.create({name:\"placeholder\",addOptions(){return{emptyEditorClass:\"is-editor-empty\",emptyNodeClass:\"is-empty\",dataAttribute:gh,placeholder:\"Write something \\u2026\",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[Q1({editor:this.editor,options:this.options})]}});function Pl(t,e){return!t.selection.empty&&!hd(t.selection)&&e.isEditable}function Z1(t,e){return Pl(t,e)&&!e.isFocused&&!e.view.dragging}function ew(){var t;(t=window.getSelection())===null||t===void 0||t.removeAllRanges()}function tw(t){t.focus()}var MC=V.create({name:\"selection\",addOptions(){return{className:\"selection\"}},addProseMirrorPlugins(){let{editor:t,options:e}=this;return[new R({key:new P(\"selection\"),props:{decorations(n){return Z1(n,t)?z.create(n.doc,[ee.inline(n.selection.from,n.selection.to,{class:e.className})]):null},handleDOMEvents:{blur(n){return Pl(n.state,t)&&ew(),!1},focus(n){return Pl(n.state,t)&&requestAnimationFrame(()=>{!t.isDestroyed&&n.hasFocus()&&tw(n)}),!1}}}})]}});function ph({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var xh=V.create({name:\"trailingNode\",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;let e=new P(this.name),n=this.options.node||((t=this.editor.schema.topNodeType.contentMatch.defaultType)===null||t===void 0?void 0:t.name)||\"paragraph\",r=Object.entries(this.editor.schema.nodes).map(([,o])=>o).filter(o=>(this.options.notAfter||[]).concat(n).includes(o.name));return[new R({key:e,appendTransaction:(o,i,s)=>{let{doc:l,tr:a,schema:c}=s,u=e.getState(s),d=l.content.size,f=c.nodes[n];if(!o.some(h=>h.getMeta(\"skipTrailingNode\"))&&u)return a.insert(d,f.create())},state:{init:(o,i)=>{let s=i.tr.doc.lastChild;return!ph({node:s,types:r})},apply:(o,i)=>{if(!o.docChanged||o.getMeta(\"__uniqueIDTransaction\"))return i;let s=o.doc.lastChild;return!ph({node:s,types:r})}}})]}}),Ch=V.create({name:\"undoRedo\",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>ks(t,e),redo:()=>({state:t,dispatch:e})=>ws(t,e)}},addProseMirrorPlugins(){return[Mu(this.options)]},addKeyboardShortcuts(){return{\"Mod-z\":()=>this.editor.commands.undo(),\"Shift-Mod-z\":()=>this.editor.commands.redo(),\"Mod-y\":()=>this.editor.commands.redo(),\"Mod-\\u044F\":()=>this.editor.commands.undo(),\"Shift-Mod-\\u044F\":()=>this.editor.commands.redo()}}});var nw=/^(#{1,3})\\s+(.*)$/,rw=/^\\s*[-*]\\s+(.*)$/,ow=/^\\s*(\\d+)[.)]\\s+(.*)$/,Ll=/^\\s*\\|(.*)\\|\\s*$/,iw=/^\\s*\\|(?:\\s*:?-+:?\\s*\\|)+\\s*$/,sw=/^\\s*```+\\s*([^`]*)$/,lw=/^\\s*```+\\s*$/,aw=/^!\\[((?:[^\\]\\\\]|\\\\.)*)\\]\\(\\s*(\\S+?)(?:\\s+\"([^\"]*)\")?\\s*\\)$/,cw=Object.freeze([\"small\",\"medium\",\"large\",\"full\"]),uw=\"full\",dw=/^https?:\\/\\//i,fw=/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;function zl(t){return typeof t==\"string\"&&dw.test(t)}function hw(t){return typeof t!=\"string\"?!1:zl(t)||fw.test(t)}function vh(t){return cw.indexOf(t)===-1?uw:t}function Bl(t){return String(t||\"\").replace(/[\\r\\n]+/g,\" \").replace(/([\\\\\\]])/g,\"\\\\$1\").trim()}var pw=Bl;function Eh(t){return String(t||\"\").replace(/\\\\(.)/g,\"$1\")}var mw=Eh;function gw(t){let e=aw.exec(String(t??\"\").trim());return e?{src:hw(e[2])?e[2]:\"\",alt:mw(e[1]),size:vh(e[3])}:null}function Ah({src:t,alt:e,size:n}={}){let r=vh(n);return`![${pw(e)}](${String(t||\"\")} \"${r}\")`}var yw=/<[^>]*>/g,bw=/<\\/(?:p|div|h[1-6]|li|ul|ol|br)\\s*>|<br\\s*\\/?>/gi,kw={\"&amp;\":\"&\",\"&lt;\":\"<\",\"&gt;\":\">\",\"&quot;\":'\"',\"&#39;\":\"'\",\"&nbsp;\":\" \"};function ww(t){return typeof t==\"string\"&&/<[a-z!/][^>]*>/i.test(t)}function Sw(t){return typeof t!=\"string\"?\"\":ww(t)?t.replace(bw,`\n`).replace(yw,\"\").replace(/&[a-z#0-9]+;/gi,e=>kw[e.toLowerCase()]??e).replace(/\\n{3,}/g,`\n\n`).trim():t}function xw(t,e){let n=Ut(t).map(r=>({...r,text:Eh(r.text),href:e}));return n.some(r=>r.text)?n:[{text:e,href:e}]}var Cw=/[!-/:-@[-`{-~]/;function Mh(t){return t!==\"\"&&!/\\s/.test(t)&&!Cw.test(t)}function Mw(t,e,n,r,o){if(e===\"\"||/\\s/.test(e.charAt(0))||/\\s/.test(e.charAt(e.length-1)))return!1;if(t!==\"_\")return!0;let i=r>0?n.charAt(r-1):\"\",s=n.charAt(o);return!Mh(i)&&!Mh(s)}var vw=/(!?)\\[((?:[^\\]\\\\]|\\\\.)*)\\]\\(\\s*(\\S+?)\\s*\\)|(\\*\\*)(.+?)\\4|(`)([^`]+?)\\6|([*_])(.+?)\\8/g,Ew=/(!?)([^\\s\\S])([^\\s\\S])|(\\*\\*)(.+?)\\4|(`)([^`]+?)\\6|([*_])(.+?)\\8/g;function Aw(t){let e=[],n=(l,a)=>{a>l&&e.push({type:\"text\",start:l,end:a})},o=t.includes(\"](\")&&t.includes(\")\")?vw:Ew;o.lastIndex=0;let i=0,s=o.exec(t);for(;s;){n(i,s.index);let l=s.index+s[0].length;if(s[3]!==void 0)if(s[1])n(s.index,l);else{let a=s.index+1;e.push({type:\"link\",start:s.index,end:l,contentStart:a,contentEnd:a+s[2].length,href:s[3]})}else if(s[4]||s[8]){let a=s[4]||s[8],c=s[4]?s[5]:s[9];if(!Mw(a,c,t,s.index,l)){n(s.index,s.index+a.length),i=s.index+a.length,o.lastIndex=i,s=o.exec(t);continue}e.push({type:s[4]?\"bold\":\"italic\",start:s.index,end:l,contentStart:s.index+a.length,contentEnd:l-a.length})}else s[6]&&e.push({type:\"code\",start:s.index,end:l,contentStart:s.index+1,contentEnd:l-1});i=l,s=o.exec(t)}return n(i,t.length),e}function Ut(t){let e=typeof t==\"string\"?t:\"\",n=[];for(let o of Aw(e)){let i=e.slice(o.contentStart,o.contentEnd);o.type===\"text\"?n.push({text:e.slice(o.start,o.end)}):o.type===\"link\"?n.push(...xw(i,o.href)):n.push({text:i,[o.type]:!0})}if(n.length===0)return[{text:e}];let r=[];for(let o of n){let i=r[r.length-1],s=l=>!l.bold&&!l.italic&&!l.code&&!l.href;i&&s(i)&&s(o)?i.text+=o.text:r.push({...o})}return r}function $l(t){let e=[],n=\"\";for(let r=0;r<t.length;r+=1){let o=t.charAt(r);o===\"\\\\\"&&t.charAt(r+1)===\"|\"?(n+=\"|\",r+=1):o===\"|\"?(e.push(n),n=\"\"):n+=o}return e.push(n),e.map(r=>r.trim())}function Tw(t){let e=t.trim(),n=e.charAt(0)===\":\",r=e.length>1&&e.charAt(e.length-1)===\":\";return n&&r?\"center\":r?\"right\":n?\"left\":null}function Nw(t,e){let n=Ll.exec(t[e]);if(!n||!iw.test(t[e+1]||\"\"))return null;let r=Ll.exec(t[e+1]),o=$l(r[1]).map(Tw),i=[{header:!0,cells:$l(n[1]).map(l=>Ut(l))}],s=e+2;for(;s<t.length;){let l=Ll.exec(t[s]);if(!l)break;i.push({header:!1,cells:$l(l[1]).map(a=>Ut(a))}),s+=1}return{block:{type:\"table\",rows:i,align:o},next:s}}function Th(t,e){let r=e?.stripLegacyHtml!==!1?Sw(t):typeof t==\"string\"?t:\"\";if(!r.trim())return[];let o=[],i=[],s=()=>{i.length!==0&&(o.push({type:\"paragraph\",spans:Ut(i.join(\" \"))}),i=[])},l=r.split(/\\r?\\n/);for(let a=0;a<l.length;a+=1){let c=l[a].trimEnd(),u=sw.exec(c);if(u){s();let g=[],y=a+1;for(;y<l.length&&!lw.test(l[y]);)g.push(l[y]),y+=1;o.push({type:\"code\",text:g.join(`\n`),lang:u[1].trim()}),a=y;continue}if(!c.trim()){s();continue}let d=Nw(l,a);if(d){s(),o.push(d.block),a=d.next-1;continue}let f=gw(c);if(f){s(),o.push({type:\"image\",...f});continue}let h=nw.exec(c);if(h){s(),o.push({type:\"heading\",level:h[1].length,spans:Ut(h[2])});continue}let p=rw.exec(c);if(p){s(),o.push({type:\"bullet\",marker:\"\\u2022\",spans:Ut(p[1])});continue}let m=ow.exec(c);if(m){s(),o.push({type:\"ordered\",marker:`${m[1]}.`,spans:Ut(m[2])});continue}i.push(c.trim())}return s(),o}var Ow=(t,e)=>e.length>0?{type:\"text\",text:t,marks:e}:{type:\"text\",text:t};function Rh(t){let e=[];for(let n of t||[]){if(!n.text)continue;let r=[];n.bold&&r.push({type:\"bold\"}),n.italic&&r.push({type:\"italic\"}),n.code&&r.push({type:\"code\"}),n.href&&r.push({type:\"link\",attrs:{href:n.href}}),e.push(Ow(n.text,r))}return e}var Hl=t=>{let e=Rh(t);return e.length>0?{type:\"paragraph\",content:e}:{type:\"paragraph\"}};function Rw(t){let e=Math.max(1,...t.rows.map(o=>o.cells.length)),n=t.rows.map(o=>{let i=[];for(let s=0;s<e;s+=1)i.push({type:o.header?\"tableHeader\":\"tableCell\",content:[Hl(o.cells[s])]});return{type:\"tableRow\",content:i}}),r=[];for(let o=0;o<e;o+=1)r.push(t.align[o]||null);return{type:\"table\",attrs:{align:r},content:n}}var Dw=t=>Number.parseInt(t,10)||1;function jl(t,e){let n=[],r=null;for(let o of Th(t,e)){let i=o.type===\"bullet\"?\"bulletList\":o.type===\"ordered\"?\"orderedList\":null;if(i){(!r||r.type!==i)&&(r={type:i,content:[]},i===\"orderedList\"&&(r.attrs={start:Dw(o.marker)}),n.push(r)),r.content.push({type:\"listItem\",content:[Hl(o.spans)]});continue}r=null,o.type===\"heading\"?n.push({type:\"heading\",attrs:{level:o.level},content:Rh(o.spans)}):o.type===\"paragraph\"?n.push(Hl(o.spans)):o.type===\"table\"?n.push(Rw(o)):o.type===\"image\"?n.push({type:\"image\",attrs:{src:o.src,alt:o.alt,title:o.size}}):o.type===\"code\"&&n.push({type:\"codeBlock\",attrs:{language:o.lang||null},...o.text?{content:[{type:\"text\",text:o.text}]}:null})}return{type:\"doc\",content:n.length>0?n:[{type:\"paragraph\"}]}}var ei=(t,e)=>(t.marks||[]).find(n=>n.type===e);function Fl(t,e){let n=/^\\s*/.exec(t)[0],r=/\\s*$/.exec(t.slice(n.length))[0],o=t.slice(n.length,t.length-r.length);return o?`${n}${e}${o}${e}${r}`:t}function Nh(t,e){let n=t.text||\"\";return e&&(n=n.replace(/\\|/g,\"\\\\|\")),ei(t,\"code\")?Fl(n.replace(/`/g,\"'\"),\"`\"):ei(t,\"bold\")?Fl(n,\"**\"):ei(t,\"italic\")?Fl(n,\"*\"):n}var Iw=t=>String(t||\"\").replace(/[\\s|()<>]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase().padStart(2,\"0\")}`);function ti(t,e){let n=\"\",r=null,o=\"\",i=()=>{r&&(n+=`[${Bl(o)}](${Iw(r)})`),r=null,o=\"\"};for(let s of t||[]){if(s.type!==\"text\")continue;let l=ei(s,\"link\")?.attrs?.href||null;l!==r&&i(),l?(r=l,o+=Nh(s,e)):n+=Nh(s,e)}return i(),n.replace(/\\n/g,\" \")}var Pw=t=>(t.content||[]).map(e=>ti(e.content,!0)).join(\" \").trim();function Lw(t){return t===\"center\"?\":---:\":t===\"right\"?\"---:\":t===\"left\"?\":---\":\"---\"}function $w(t){let e=(t.content||[]).map(s=>(s.content||[]).map(Pw));if(e.length===0)return\"\";let n=e[0].length,r=t.attrs?.align||[],o=s=>`| ${s.join(\" | \")} |`,i=[];for(let s=0;s<n;s+=1)i.push(Lw(r[s]));return[o(e[0]),o(i),...e.slice(1).map(o)].join(`\n`)}var zw=t=>(t.content||[]).map(e=>ti(e.content,!1)).join(\" \").trim(),Oh=t=>(t.content||[]).map(zw).filter(e=>e!==\"\");function Bw(t){switch(t.type){case\"heading\":{let e=ti(t.content,!1).trim();return e?`${\"#\".repeat(t.attrs?.level||1)} ${e}`:\"\"}case\"paragraph\":return ti(t.content,!1);case\"bulletList\":return Oh(t).map(e=>`- ${e}`).join(`\n`);case\"orderedList\":{let e=t.attrs?.start||1;return Oh(t).map((n,r)=>`${e+r}. ${n}`).join(`\n`)}case\"table\":return $w(t);case\"image\":return t.attrs?.src?Ah({src:t.attrs.src,alt:t.attrs.alt,size:t.attrs.title}):\"\";case\"codeBlock\":{let e=(t.content||[]).map(n=>n.text||\"\").join(\"\");return`\\`\\`\\`${t.attrs?.language||\"\"}\n${e}\n\\`\\`\\``}default:return\"\"}}function Dh(t){return(t?.content||[]).map(Bw).filter(e=>e.trim()!==\"\").join(`\n\n`)}var Ih=/^\\s*(javascript|data|vbscript):/i,Fw=Ef.extend({renderHTML({node:t,HTMLAttributes:e}){return zl(t.attrs.src)?[\"img\",e]:[\"div\",{class:\"md-image-placeholder\"},t.attrs.alt||\"Image\"]}}),Hw=Rl.extend({addAttributes(){return{...this.parent?.(),align:{default:[],rendered:!1}}}}),Wl={content:\"paragraph\"};function jw(t){return[Id,Pd,Ld,Fd.extend({excludes:\"italic code\"}),Hd.extend({excludes:\"bold code\"}),jd,Wd.configure({levels:[1,2,3]}),Hs,Us,Vs.extend(Wl),Ks,Mf.configure({openOnClick:!1,autolink:!1,isAllowedUri:e=>!Ih.test(String(e)),HTMLAttributes:{target:null,rel:\"noopener noreferrer nofollow\"}}),vf,Fw.configure({inline:!1,allowBase64:!1}),Hw.configure({resizable:!1}),Ol,Nl.extend(Wl),Tl.extend(Wl),mh,xh,Ch,Sh.configure({placeholder:t||\"\"})]}var Ph={bold:t=>t.toggleBold(),italic:t=>t.toggleItalic(),code:t=>t.toggleCode(),heading2:t=>t.toggleHeading({level:2}),heading3:t=>t.toggleHeading({level:3}),bullet:t=>t.toggleBulletList(),ordered:t=>t.toggleOrderedList(),table:t=>t.insertTable({rows:3,cols:3,withHeaderRow:!0}),addRow:t=>t.addRowAfter(),addColumn:t=>t.addColumnAfter(),removeRow:t=>t.deleteRow(),removeColumn:t=>t.deleteColumn(),removeTable:t=>t.deleteTable(),undo:t=>t.undo(),redo:t=>t.redo(),link:(t,{label:e,target:n}={},r)=>{let o=String(n||\"\").trim();if(!o||Ih.test(o))return t;let i=String(e||\"\").trim(),{from:s,to:l,empty:a}=r.state.selection;return!a&&(!i||i===r.state.doc.textBetween(s,l,\" \").trim())?t.setLink({href:o}):t.insertContent({type:\"text\",text:i||o,marks:[{type:\"link\",attrs:{href:o}}]})}},KC=Object.freeze(Object.keys(Ph));function Lh({element:t,markdown:e,placeholder:n,label:r,onChange:o,onFocusChange:i,onState:s}){let l=typeof e==\"string\"?e:\"\",a=new Nd({element:t,extensions:jw(n),content:jl(l,{stripLegacyHtml:!1}),editorProps:{attributes:{role:\"textbox\",\"aria-multiline\":\"true\",...r?{\"aria-label\":r}:null}}});if(a.on(\"update\",({transaction:c})=>{if(!c.docChanged)return;let u=Dh(a.getJSON());u!==l&&(l=u,typeof o==\"function\"&&o(l))}),typeof s==\"function\"){let c=!1;a.on(\"transaction\",()=>{let u=a.isActive(\"table\");u!==c&&s({inTable:c=u})})}return typeof i==\"function\"&&(a.on(\"focus\",()=>i(!0)),a.on(\"blur\",()=>i(!1))),{setMarkdown(c){let u=typeof c==\"string\"?c:\"\";u!==l&&(l=u,a.commands.setContent(jl(u,{stripLegacyHtml:!1}),{emitUpdate:!1}))},command(c,u){let d=Ph[c];return d?d(a.chain().focus(),u,a).run():!1},selectedText(){let{from:c,to:u}=a.state.selection;return a.state.doc.textBetween(c,u,\" \")},focus(){a.commands.focus()},destroy(){a.destroy()},editor:a}}var Vl=t=>String(t??\"\").replace(/[{}<>;\\\\]/g,\"\"),q=t=>typeof t==\"number\"?`${t}px`:Vl(t),$h=t=>Vl(t)||\"system-ui, sans-serif\";function zh(t,e,{fontSize:n,minHeight:r,framed:o=!1}={}){let i=Object.fromEntries(Object.entries(t).map(([c,u])=>[c,typeof u==\"string\"?Vl(u):u])),s=n||i.bodySize,l=e;return`${o?`${l}{border:1px solid ${i.border};border-radius:${q(i.radius)};background-color:${i.surface}}\n${l}:focus-within{border-color:${i.accent}}\n`:\"\"}\n${l} .ProseMirror{outline:none;min-height:${q(r||0)};padding:${q(i.padding)};box-sizing:border-box;font-family:${$h(i.bodyFont)};font-size:${q(s)};line-height:${q(Math.round(s*1.6))};color:${i.color};white-space:pre-wrap;overflow-wrap:anywhere}\n${l} .ProseMirror>*:first-child{margin-top:0}\n${l} .ProseMirror>*:last-child{margin-bottom:0}\n${l} .ProseMirror p{margin:0 0 ${q(i.blockGap)}}\n${l} .ProseMirror h1,${l} .ProseMirror h2,${l} .ProseMirror h3{font-family:${$h(i.headingFont)};font-weight:700;margin:0 0 ${q(i.blockGap)}}\n${l} .ProseMirror h1{font-size:${q(i.headingSizes[1])};line-height:1.3}\n${l} .ProseMirror h2{font-size:${q(i.headingSizes[2])};line-height:1.3}\n${l} .ProseMirror h3{font-size:${q(i.headingSizes[3])};line-height:1.3}\n${l} .ProseMirror ul,${l} .ProseMirror ol{margin:0 0 ${q(i.blockGap)};padding-left:1.4em}\n${l} .ProseMirror li p{margin:0}\n${l} .ProseMirror code{font-family:ui-monospace,Menlo,monospace;font-size:${q(i.codeSize)};color:${i.mutedColor}}\n${l} .ProseMirror pre{margin:0 0 ${q(i.blockGap)};padding:${q(i.blockGap)};border:1px solid ${i.border};border-radius:${q(i.radius)};white-space:pre-wrap}\n${l} .ProseMirror a{color:${i.accent};text-decoration:underline}\n${l} .ProseMirror table{border-collapse:collapse;width:100%;margin:0 0 ${q(i.blockGap)};table-layout:fixed}\n${l} .ProseMirror th,${l} .ProseMirror td{border:1px solid ${i.border};padding:4px 8px;vertical-align:top;text-align:left}\n${l} .ProseMirror th{font-weight:700}\n${l} .ProseMirror .selectedCell{background:${i.border}}\n${l} .ProseMirror img{display:block;max-width:100%;height:auto;margin:0 0 ${q(i.blockGap)};border-radius:${q(i.radius)}}\n${l} .ProseMirror img.ProseMirror-selectednode{outline:2px solid ${i.accent}}\n${l} .ProseMirror .md-image-placeholder{margin:0 0 ${q(i.blockGap)};padding:${q(i.padding)};border:1px dashed ${i.border};border-radius:${q(i.radius)};color:${i.mutedColor}}\n${l} .ProseMirror p.is-editor-empty:first-child::before{content:attr(data-placeholder);color:${i.mutedColor};float:left;height:0;pointer-events:none}\n${l} .ProseMirror-gapcursor{display:none;pointer-events:none;position:absolute}\n${l} .ProseMirror-gapcursor:after{content:\"\";display:block;position:absolute;top:-2px;width:20px;border-top:1px solid ${i.color};animation:md-cursor-blink 1.1s steps(2,start) infinite}\n${l} .ProseMirror-focused .ProseMirror-gapcursor{display:block}\n@keyframes md-cursor-blink{to{visibility:hidden}}\n`}var Bh=\"#root\";function Mn(t){window.ReactNativeWebView&&window.ReactNativeWebView.postMessage(JSON.stringify(t))}var bt=null,Fh=document.createElement(\"style\");document.head.appendChild(Fh);function Hh({tokens:t,minHeight:e}){t&&typeof t==\"object\"&&(Fh.textContent=zh(t,Bh,{minHeight:e}))}function Ww(t){if(bt)return;let{markdown:e,placeholder:n,label:r}=t;Hh(t);let o=document.querySelector(Bh);bt=Lh({element:o,markdown:e,placeholder:n,label:r,onChange:s=>Mn({type:\"change\",markdown:s}),onFocusChange:s=>Mn({type:\"focus\",focused:s}),onState:s=>Mn({type:\"state\",inTable:s.inTable===!0})}),bt.editor.on(\"selectionUpdate\",()=>Mn({type:\"selection\",text:bt.selectedText()}));let i=0;new ResizeObserver(()=>{let s=Math.ceil(o.getBoundingClientRect().height);s!==i&&Mn({type:\"height\",height:i=s})}).observe(o)}window.mdEditor={receive(t){let e;try{e=JSON.parse(t)}catch{return}if(!(!e||typeof e!=\"object\"))if(e.type===\"init\")Ww(e);else if(e.type===\"style\")Hh(e);else if(bt)e.type===\"set\"?bt.setMarkdown(e.markdown):e.type===\"command\"?bt.command(e.name,e.args):e.type===\"focus\"&&bt.focus();else return}};Mn({type:\"ready\"});})();\n</script></body></html>";
4
+ export const MARKDOWN_EDITOR_HTML = "<!doctype html><html><head><meta charset=\"utf-8\"><meta name=\"viewport\" content=\"width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no\"><meta http-equiv=\"Content-Security-Policy\" content=\"default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; img-src https: http:\"><style>html,body{margin:0;padding:0;background:transparent;-webkit-text-size-adjust:100%}</style></head><body><div id=\"root\"></div><script>(()=>{var Gl=Object.defineProperty,Xl=(t,e)=>{let n={};for(var r in t)Gl(n,r,{get:t[r],enumerable:!0});return e||Gl(n,Symbol.toStringTag,{value:\"Module\"}),n};function se(t){this.content=t}se.prototype={constructor:se,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 e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,o=r.find(t),i=r.content.slice();return o==-1?i.push(n||t,e):(i[o+1]=e,n&&(i[o]=n)),new se(i)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new se(n)},addToStart:function(t,e){return new se([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new se(n)},addBefore:function(t,e,n){var r=this.remove(e),o=r.content.slice(),i=r.find(t);return o.splice(i==-1?o.length:i,0,e,n),new se(o)},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=se.from(t),t.size?new se(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=se.from(t),t.size?new se(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=se.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}};se.from=function(t){if(t instanceof se)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new se(e)};var ni=se;function la(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let o=t.child(r),i=e.child(r);if(o==i){n+=o.nodeSize;continue}if(!o.sameMarkup(i))return n;if(o.isText&&o.text!=i.text){let s=o.text,l=i.text,a=0;for(;s[a]==l[a];a++)n++;return a&&a<s.length&&a<l.length&&ua(s.charCodeAt(a-1))&&ca(s.charCodeAt(a))&&n--,n}if(o.content.size||i.content.size){let s=la(o.content,i.content,n+1);if(s!=null)return s}n+=o.nodeSize}}function aa(t,e,n,r){for(let o=t.childCount,i=e.childCount;;){if(o==0||i==0)return o==i?null:{a:n,b:r};let s=t.child(--o),l=e.child(--i),a=s.nodeSize;if(s==l){n-=a,r-=a;continue}if(!s.sameMarkup(l))return{a:n,b:r};if(s.isText&&s.text!=l.text){let c=s.text,u=l.text,d=c.length,f=u.length;for(;d>0&&f>0&&c[d-1]==u[f-1];)d--,f--,n--,r--;return d&&f&&d<c.length&&ua(c.charCodeAt(d-1))&&ca(c.charCodeAt(d))&&(n++,r++),{a:n,b:r}}if(s.content.size||l.content.size){let c=aa(s.content,l.content,n-1,r-1);if(c)return c}n-=a,r-=a}}function ca(t){return t>=56320&&t<57344}function ua(t){return t>=55296&&t<56320}var b=class t{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,o=0,i){for(let s=0,l=0;l<n;s++){let a=this.content[s],c=l+a.nodeSize;if(c>e&&r(a,o+l,i||null,s)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,n-u),r,o+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,o){let i=\"\",s=!0;return this.nodesBetween(e,n,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,n-a):l.isLeaf?o?typeof o==\"function\"?o(l):o:l.type.spec.leafText?l.type.spec.leafText(l):\"\":\"\";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(s?s=!1:i+=r),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,o=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(r)&&(o[o.length-1]=n.withText(n.text+r.text),i=1);i<e.content.length;i++)o.push(e.content[i]);return new t(o,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],o=0;if(n>e)for(let i=0,s=0;s<n;i++){let l=this.content[i],a=s+l.nodeSize;a>e&&((s<e||a>n)&&(l.isText?l=l.cut(Math.max(0,e-s),Math.min(l.text.length,n-s)):l=l.cut(Math.max(0,e-s-1),Math.min(l.content.size,n-s-1))),r.push(l),o+=l.nodeSize),s=a}return new t(r,o)}cutByIndex(e,n){return e==n?t.empty:e==0&&n==this.content.length?this:new t(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let o=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return o[e]=n,new t(o,i)}addToStart(e){return new t([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new t(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))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(e){let n=this.content[e];if(!n)throw new RangeError(\"Index \"+e+\" out of range for \"+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let o=this.content[n];e(o,r,n),r+=o.nodeSize}}findDiffStart(e,n=0){return la(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return aa(this,e,n,r)}findIndex(e){if(e==0)return hr(0,e);if(e==this.size)return hr(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let o=this.child(n),i=r+o.nodeSize;if(i>=e)return i==e?hr(n+1,i):hr(n,r);r=i}}toString(){return\"<\"+this.toStringInner()+\">\"}toStringInner(){return this.content.join(\", \")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return t.empty;if(!Array.isArray(n))throw new RangeError(\"Invalid input for Fragment.fromJSON\");return t.fromArray(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return t.empty;let n,r=0;for(let o=0;o<e.length;o++){let i=e[o];r+=i.nodeSize,o&&i.isText&&e[o-1].sameMarkup(i)?(n||(n=e.slice(0,o)),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new t(n||e,r)}static from(e){if(!e)return t.empty;if(e instanceof t)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new t([e],e.nodeSize);throw new RangeError(\"Can not convert \"+e+\" to a Fragment\"+(e.nodesBetween?\" (looks like multiple versions of prosemirror-model were loaded)\":\"\"))}};b.empty=new b([],0);var ri={index:0,offset:0};function hr(t,e){return ri.index=t,ri.offset=e,ri}function gr(t,e){if(t===e)return!0;if(!(t&&typeof t==\"object\")||!(e&&typeof e==\"object\"))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 r=0;r<t.length;r++)if(!gr(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!gr(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}var $=class t{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let o=0;o<e.length;o++){let i=e[o];if(this.eq(i))return e;if(this.type.excludes(i.type))n||(n=e.slice(0,o));else{if(i.type.excludes(this.type))return e;!r&&i.type.rank>this.type.rank&&(n||(n=e.slice(0,o)),n.push(this),r=!0),n&&n.push(i)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&gr(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError(\"Invalid input for Mark.fromJSON\");let r=e.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);return r.create(n.attrs)}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return t.none;if(e instanceof t)return[e];let n=e.slice();return n.sort((r,o)=>r.type.rank-o.type.rank),n}};$.none=[];var it=class extends Error{},C=class t{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=fa(this.content,e+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new t(r,this.openStart,this.openEnd)}removeBetween(e,n){return new t(da(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+\"(\"+this.openStart+\",\"+this.openEnd+\")\"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return t.empty;let r=n.openStart||0,o=n.openEnd||0;if(typeof r!=\"number\"||typeof o!=\"number\")throw new RangeError(\"Invalid input for Slice.fromJSON\");return new t(b.fromJSON(e,n.content),r,o)}static maxOpen(e,n=!0){let r=0,o=0;for(let i=e.firstChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.lastChild)o++;return new t(e,r,o)}};C.empty=new C(b.empty,0,0);function da(t,e,n){let{index:r,offset:o}=t.findIndex(e),i=t.maybeChild(r),{index:s,offset:l}=t.findIndex(n);if(o==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(r!=s)throw new RangeError(\"Removing non-flat range\");return t.replaceChild(r,i.copy(da(i.content,e-o-1,n-o-1)))}function fa(t,e,n,r,o,i){let{index:s,offset:l}=t.findIndex(e),a=t.maybeChild(s);if(l==e||a.isText)return i&&r<=0&&o<=0&&!i.canReplace(s,s,n)?null:t.cut(0,e).append(n).append(t.cut(e));let c=fa(a.content,e-l-1,n,s==0?r-1:0,s==t.childCount-1?o-1:0,a);return c&&t.replaceChild(s,a.copy(c))}function Kh(t,e,n){if(n.openStart>t.depth)throw new it(\"Inserted content deeper than insertion position\");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new it(\"Inconsistent open depths\");return ha(t,e,n,0)}function ha(t,e,n,r){let o=t.index(r),i=t.node(r);if(o==e.index(r)&&r<t.depth-n.openStart){let s=ha(t,e,n,r+1);return i.copy(i.content.replaceChild(o,s))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let s=t.parent,l=s.content;return xt(s,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:s,end:l}=Uh(n,t);return xt(i,ma(t,s,l,e,r))}else return xt(i,yr(t,e,r))}function pa(t,e){if(!e.type.compatibleContent(t.type))throw new it(\"Cannot join \"+e.type.name+\" onto \"+t.type.name)}function oi(t,e,n){let r=t.node(n);return pa(r,e.node(n)),r}function St(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 vn(t,e,n,r){let o=(e||t).node(n),i=0,s=e?e.index(n):o.childCount;t&&(i=t.index(n),t.depth>n?i++:t.textOffset&&(St(t.nodeAfter,r),i++));for(let l=i;l<s;l++)St(o.child(l),r);e&&e.depth==n&&e.textOffset&&St(e.nodeBefore,r)}function xt(t,e){if(!t.type.validContent(e))throw new it(\"Invalid content for node \"+t.type.name);return t.copy(e)}function ma(t,e,n,r,o){let i=t.depth>o&&oi(t,e,o+1),s=r.depth>o&&oi(n,r,o+1),l=[];return vn(null,t,o,l),i&&s&&e.index(o)==n.index(o)?(pa(i,s),St(xt(i,ma(t,e,n,r,o+1)),l)):(i&&St(xt(i,yr(t,e,o+1)),l),vn(e,n,o,l),s&&St(xt(s,yr(n,r,o+1)),l)),vn(r,null,o,l),new b(l)}function yr(t,e,n){let r=[];if(vn(null,t,n,r),t.depth>n){let o=oi(t,e,n+1);St(xt(o,yr(t,e,n+1)),r)}return vn(e,null,n,r),new b(r)}function Uh(t,e){let n=e.depth-t.openStart,o=e.node(n).copy(t.content);for(let i=n-1;i>=0;i--)o=e.node(i).copy(b.from(o));return{start:o.resolveNoCache(t.openStart+n),end:o.resolveNoCache(o.content.size-t.openEnd-n)}}var br=class t{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError(\"There is no position before the top-level node\");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError(\"There is no position after the top-level node\");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],o=e.child(n);return r?e.child(n).cut(r):o}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],o=n==0?0:this.path[n*3-1]+1;for(let i=0;i<e;i++)o+=r.child(i).nodeSize;return o}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return $.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),o=e.maybeChild(n);if(!r){let l=r;r=o,o=l}let i=r.marks;for(var s=0;s<i.length;s++)i[s].type.spec.inclusive===!1&&(!o||!i[s].isInSet(o.marks))&&(i=i[s--].removeFromSet(i));return i}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,o=e.parent.maybeChild(e.index());for(var i=0;i<r.length;i++)r[i].type.spec.inclusive===!1&&(!o||!r[i].isInSet(o.marks))&&(r=r[i--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new Ct(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e=\"\";for(let n=1;n<=this.depth;n++)e+=(e?\"/\":\"\")+this.node(n).type.name+\"_\"+this.index(n-1);return e+\":\"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError(\"Position \"+n+\" out of range\");let r=[],o=0,i=n;for(let s=e;;){let{index:l,offset:a}=s.content.findIndex(i),c=i-a;if(r.push(s,l,o+a),!c||(s=s.child(l),s.isText))break;i=c-1,o+=a+1}return new t(n,r,i)}static resolveCached(e,n){let r=Yl.get(e);if(r)for(let i=0;i<r.elts.length;i++){let s=r.elts[i];if(s.pos==n)return s}else Yl.set(e,r=new ii);let o=r.elts[r.i]=t.resolve(e,n);return r.i=(r.i+1)%Jh,o}},ii=class{constructor(){this.elts=[],this.i=0}},Jh=12,Yl=new WeakMap,Ct=class{constructor(e,n,r){this.$from=e,this.$to=n,this.depth=r}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)}},qh=Object.create(null),Te=class t{constructor(e,n,r,o=$.none){this.type=e,this.attrs=n,this.marks=o,this.content=r||b.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,n,r,o=0){this.content.nodesBetween(e,n,r,o,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,\"\")}textBetween(e,n,r,o){return this.content.textBetween(e,n,r,o)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,r){return this.type==e&&gr(this.attrs,n||e.defaultAttrs||qh)&&$.sameSet(this.marks,r||$.none)}copy(e=null){return e==this.content?this:new t(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new t(this.type,this.attrs,this.content,e)}cut(e,n=this.content.size){return e==0&&n==this.content.size?this:this.copy(this.content.cut(e,n))}slice(e,n=this.content.size,r=!1){if(e==n)return C.empty;let o=this.resolve(e),i=this.resolve(n),s=r?0:o.sharedDepth(n),l=o.start(s),c=o.node(s).content.cut(o.pos-l,i.pos-l);return new C(c,o.depth-s,i.depth-s)}replace(e,n,r){return Kh(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:o}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(o==e||n.isText)return n;e-=o+1}}childAfter(e){let{index:n,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(n),index:n,offset:r};let o=this.content.child(n-1);return{node:o,index:n-1,offset:r-o.nodeSize}}resolve(e){return br.resolveCached(this,e)}resolveNoCache(e){return br.resolve(this,e)}rangeHasMark(e,n,r){let o=!1;return n>e&&this.nodesBetween(e,n,i=>(r.isInSet(i.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 e=this.type.name;return this.content.size&&(e+=\"(\"+this.content.toStringInner()+\")\"),ga(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error(\"Called contentMatchAt on a node with invalid content\");return n}canReplace(e,n,r=b.empty,o=0,i=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,o,i),l=s&&s.matchFragment(this.content,n);if(!l||!l.validEnd)return!1;for(let a=o;a<i;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,n,r,o){if(o&&!this.type.allowsMarks(o))return!1;let i=this.contentMatchAt(e).matchType(r),s=i&&i.matchFragment(this.content,n);return s?s.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),Ql(this.type.attrs,this.attrs,\"node\",this.type.name);let e=$.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];Ql(r.type.attrs,r.attrs,\"mark\",r.type.name),e=r.addToSet(e)}if(!$.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError(\"Invalid input for Node.fromJSON\");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError(\"Invalid mark data for Node.fromJSON\");r=n.marks.map(e.markFromJSON)}if(n.type==\"text\"){if(typeof n.text!=\"string\")throw new RangeError(\"Invalid text node in JSON\");return e.text(n.text,r)}let o=b.fromJSON(e,n.content);return e.nodeType(n.type).create(n.attrs,o,r)}};Te.prototype.text=void 0;var si=class t extends Te{constructor(e,n,r,o){if(super(e,n,null,o),!r)throw new RangeError(\"Empty text nodes are not allowed\");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):ga(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new t(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new t(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function ga(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+\"(\"+e+\")\";return e}function Ql(t,e,n,r){for(let o in e)if(!(o in t))throw new RangeError(`Unsupported attribute ${o} for ${n} of type ${r}`);for(let o in t)t[o].validate&&t[o].validate(e[o])}var Mt=class t{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new li(e,n);if(r.next==null)return t.empty;let o=ya(r);r.next&&r.err(\"Unexpected trailing text\");let i=tp(ep(o));return np(i,r),i}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let o=this;for(let i=n;o&&i<r;i++)o=o.matchType(e.child(i).type);return o}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let o=[this];function i(s,l){let a=s.matchFragment(e,r);if(a&&(!n||a.validEnd))return b.from(l.map(c=>c.createAndFill()));for(let c=0;c<s.next.length;c++){let{type:u,next:d}=s.next[c];if(!(u.isText||u.hasRequiredAttrs())&&o.indexOf(d)==-1){o.push(d);let f=i(d,l.concat(u));if(f)return f}}return null}return i(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let o=r.shift(),i=o.match;if(i.matchType(e)){let s=[];for(let l=o;l.type;l=l.via)s.push(l.type);return s.reverse()}for(let s=0;s<i.next.length;s++){let{type:l,next:a}=i.next[s];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in n)&&(!o.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:o}),n[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let o=0;o<r.next.length;o++)e.indexOf(r.next[o].next)==-1&&n(r.next[o].next)}return n(this),e.map((r,o)=>{let i=o+(r.validEnd?\"*\":\" \")+\" \";for(let s=0;s<r.next.length;s++)i+=(s?\", \":\"\")+r.next[s].type.name+\"->\"+e.indexOf(r.next[s].next);return i}).join(`\n`)}};Mt.empty=new Mt(!0);var li=class{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.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(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+\" (in content expression '\"+this.string+\"')\")}};function ya(t){let e=[];do e.push(Gh(t));while(t.eat(\"|\"));return e.length==1?e[0]:{type:\"choice\",exprs:e}}function Gh(t){let e=[];do e.push(Xh(t));while(t.next&&t.next!=\")\"&&t.next!=\"|\");return e.length==1?e[0]:{type:\"seq\",exprs:e}}function Xh(t){let e=Zh(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(\"{\"))e=Yh(t,e);else break;return e}function Zl(t){/\\D/.test(t.next)&&t.err(\"Expected number, got '\"+t.next+\"'\");let e=Number(t.next);return t.pos++,e}function Yh(t,e){let n=Zl(t),r=n;return t.eat(\",\")&&(t.next!=\"}\"?r=Zl(t):r=-1),t.eat(\"}\")||t.err(\"Unclosed braced range\"),{type:\"range\",min:n,max:r,expr:e}}function Qh(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let o=[];for(let i in n){let s=n[i];s.isInGroup(e)&&o.push(s)}return o.length==0&&t.err(\"No node type or group '\"+e+\"' found\"),o}function Zh(t){if(t.eat(\"(\")){let e=ya(t);return t.eat(\")\")||t.err(\"Missing closing paren\"),e}else if(/\\W/.test(t.next))t.err(\"Unexpected token '\"+t.next+\"'\");else{let e=Qh(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err(\"Mixing inline and block content\"),{type:\"name\",value:n}));return t.pos++,e.length==1?e[0]:{type:\"choice\",exprs:e}}}function ep(t){let e=[[]];return o(i(t,0),n()),e;function n(){return e.push([])-1}function r(s,l,a){let c={term:a,to:l};return e[s].push(c),c}function o(s,l){s.forEach(a=>a.to=l)}function i(s,l){if(s.type==\"choice\")return s.exprs.reduce((a,c)=>a.concat(i(c,l)),[]);if(s.type==\"seq\")for(let a=0;;a++){let c=i(s.exprs[a],l);if(a==s.exprs.length-1)return c;o(c,l=n())}else if(s.type==\"star\"){let a=n();return r(l,a),o(i(s.expr,a),a),[r(a)]}else if(s.type==\"plus\"){let a=n();return o(i(s.expr,l),a),o(i(s.expr,a),a),[r(a)]}else{if(s.type==\"opt\")return[r(l)].concat(i(s.expr,l));if(s.type==\"range\"){let a=l;for(let c=0;c<s.min;c++){let u=n();o(i(s.expr,a),u),a=u}if(s.max==-1)o(i(s.expr,a),a);else for(let c=s.min;c<s.max;c++){let u=n();r(a,u),o(i(s.expr,a),u),a=u}return[r(a)]}else{if(s.type==\"name\")return[r(l,void 0,s.value)];throw new Error(\"Unknown expr type\")}}}}function ba(t,e){return e-t}function ea(t,e){let n=[];return r(e),n.sort(ba);function r(o){let i=t[o];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(o);for(let s=0;s<i.length;s++){let{term:l,to:a}=i[s];!l&&n.indexOf(a)==-1&&r(a)}}}function tp(t){let e=Object.create(null);return n(ea(t,0));function n(r){let o=[];r.forEach(s=>{t[s].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let u=0;u<o.length;u++)o[u][0]==l&&(c=o[u][1]);ea(t,a).forEach(u=>{c||o.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let i=e[r.join(\",\")]=new Mt(r.indexOf(t.length-1)>-1);for(let s=0;s<o.length;s++){let l=o[s][1].sort(ba);i.next.push({type:o[s][0],next:e[l.join(\",\")]||n(l)})}return i}}function np(t,e){for(let n=0,r=[t];n<r.length;n++){let o=r[n],i=!o.validEnd,s=[];for(let l=0;l<o.next.length;l++){let{type:a,next:c}=o.next[l];s.push(a.name),i&&!(a.isText||a.hasRequiredAttrs())&&(i=!1),r.indexOf(c)==-1&&r.push(c)}i&&e.err(\"Only non-generatable nodes (\"+s.join(\", \")+\") in a required position (see https://prosemirror.net/docs/guide/#generatable)\")}}function ka(t){let e=Object.create(null);for(let n in t){let r=t[n];if(!r.hasDefault)return null;e[n]=r.default}return e}function wa(t,e){let n=Object.create(null);for(let r in t){let o=t[r],i=e&&e[r];if(i===void 0)if(o.hasDefault)i=o.default;else throw new RangeError(\"No value supplied for attribute \"+r);else o.validate&&o.validate(i);n[r]=i}return n}function Sa(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new ai(t,r,e[r]);return n}var kr=class t{constructor(e,n,r){this.name=e,this.schema=n,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(\" \"):[],this.attrs=Sa(e,r.attrs),this.defaultAttrs=ka(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e==\"text\"),this.isText=e==\"text\"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Mt.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?\"pre\":\"normal\")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:wa(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error(\"NodeType.create can't construct text nodes\");return new Te(this,this.computeAttrs(e),b.from(n),$.setFrom(r))}createChecked(e=null,n,r){return n=b.from(n),this.checkContent(n),new Te(this,this.computeAttrs(e),n,$.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=b.from(n),n.size){let s=this.contentMatch.fillBefore(n);if(!s)return null;n=s.append(n)}let o=this.contentMatch.matchFragment(n),i=o&&o.fillBefore(b.empty,!0);return i?new Te(this,e,n.append(i),$.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;n<e.length;n++)if(!this.allowsMarkType(e[n].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let n;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?n&&n.push(e[r]):n||(n=e.slice(0,r));return n?n.length?n:$.none:e}static compile(e,n){let r=Object.create(null);e.forEach((i,s)=>r[i]=new t(i,n,s));let o=n.spec.topNode||\"doc\";if(!r[o])throw new RangeError(\"Schema is missing its top node type ('\"+o+\"')\");if(!r.text)throw new RangeError(\"Every schema needs a 'text' type\");for(let i in r.text.attrs)throw new RangeError(\"The text node type should not have attributes\");return r}};function rp(t,e,n){let r=n.split(\"|\");return o=>{let i=o===null?\"null\":typeof o;if(r.indexOf(i)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${i}`)}}var ai=class{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,\"default\"),this.default=r.default,this.validate=typeof r.validate==\"string\"?rp(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}},An=class t{constructor(e,n,r,o){this.name=e,this.rank=n,this.schema=r,this.spec=o,this.attrs=Sa(e,o.attrs),this.excluded=null;let i=ka(this.attrs);this.instance=i?new $(this,i):null}create(e=null){return!e&&this.instance?this.instance:new $(this,wa(this.attrs,e))}static compile(e,n){let r=Object.create(null),o=0;return e.forEach((i,s)=>r[i]=new t(i,o++,n,s)),r}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}excludes(e){return this.excluded.indexOf(e)>-1}},vt=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let o in e)n[o]=e[o];n.nodes=ni.from(e.nodes),n.marks=ni.from(e.marks||{}),this.nodes=kr.compile(this.spec.nodes,this),this.marks=An.compile(this.spec.marks,this);let r=Object.create(null);for(let o in this.nodes){if(o in this.marks)throw new RangeError(o+\" can not be both a node and a mark\");let i=this.nodes[o],s=i.spec.content||\"\",l=i.spec.marks;if(i.contentMatch=r[s]||(r[s]=Mt.parse(s,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError(\"Multiple linebreak nodes defined\");if(!i.isInline||!i.isLeaf)throw new RangeError(\"Linebreak replacement nodes must be inline leaf nodes\");this.linebreakReplacement=i}i.markSet=l==\"_\"?null:l?ta(this,l.split(\" \")):l==\"\"||!i.inlineContent?[]:null}for(let o in this.marks){let i=this.marks[o],s=i.spec.excludes;i.excluded=s==null?[i]:s==\"\"?[]:ta(this,s.split(\" \"))}this.nodeFromJSON=o=>Te.fromJSON(this,o),this.markFromJSON=o=>$.fromJSON(this,o),this.topNodeType=this.nodes[this.spec.topNode||\"doc\"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,o){if(typeof e==\"string\")e=this.nodeType(e);else if(e instanceof kr){if(e.schema!=this)throw new RangeError(\"Node type from different schema used (\"+e.name+\")\")}else throw new RangeError(\"Invalid node type: \"+e);return e.createChecked(n,r,o)}text(e,n){let r=this.nodes.text;return new si(r,r.defaultAttrs,e,$.setFrom(n))}mark(e,n){return typeof e==\"string\"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError(\"Unknown node type: \"+e);return n}};function ta(t,e){let n=[];for(let r=0;r<e.length;r++){let o=e[r],i=t.marks[o],s=i;if(i)n.push(i);else for(let l in t.marks){let a=t.marks[l];(o==\"_\"||a.spec.group&&a.spec.group.split(\" \").indexOf(o)>-1)&&n.push(s=a)}if(!s)throw new SyntaxError(\"Unknown mark type: '\"+e[r]+\"'\")}return n}function op(t){return t.tag!=null}function ip(t){return t.style!=null}var je=class t{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(o=>{if(op(o))this.tags.push(o);else if(ip(o)){let i=/[^=]*/.exec(o.style)[0];r.indexOf(i)<0&&r.push(i),this.styles.push(o)}}),this.normalizeLists=!this.tags.some(o=>{if(!/^(ul|ol)\\b/.test(o.tag)||!o.node)return!1;let i=e.nodes[o.node];return i.contentMatch.matchType(i)})}parse(e,n={}){let r=new wr(this,n,!1);return r.addAll(e,$.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new wr(this,n,!0);return r.addAll(e,$.none,n.from,n.to),C.maxOpen(r.finish())}matchTag(e,n,r){for(let o=r?this.tags.indexOf(r)+1:0;o<this.tags.length;o++){let i=this.tags[o];if(ap(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||n.matchesContext(i.context))){if(i.getAttrs){let s=i.getAttrs(e);if(s===!1)continue;i.attrs=s||void 0}return i}}}matchStyle(e,n,r,o){for(let i=o?this.styles.indexOf(o)+1:0;i<this.styles.length;i++){let s=this.styles[i],l=s.style;if(!(l.indexOf(e)!=0||s.context&&!r.matchesContext(s.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=n))){if(s.getAttrs){let a=s.getAttrs(n);if(a===!1)continue;s.attrs=a||void 0}return s}}}static schemaRules(e){let n=[];function r(o){let i=o.priority==null?50:o.priority,s=0;for(;s<n.length;s++){let l=n[s];if((l.priority==null?50:l.priority)<i)break}n.splice(s,0,o)}for(let o in e.marks){let i=e.marks[o].spec.parseDOM;i&&i.forEach(s=>{r(s=ra(s)),s.mark||s.ignore||s.clearMark||(s.mark=o)})}for(let o in e.nodes){let i=e.nodes[o].spec.parseDOM;i&&i.forEach(s=>{r(s=ra(s)),s.node||s.ignore||s.mark||(s.node=o)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new t(e,t.schemaRules(e)))}},xa={address:!0,article:!0,aside:!0,blockquote:!0,body:!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},sp={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Ca={ol:!0,ul:!0},Tn=1,ci=2,En=4;function na(t,e,n){return e!=null?(e?Tn:0)|(e===\"full\"?ci:0):t&&t.whitespace==\"pre\"?Tn|ci:n&~En}var Jt=class{constructor(e,n,r,o,i,s){this.type=e,this.attrs=n,this.marks=r,this.solid=o,this.options=s,this.content=[],this.activeMarks=$.none,this.match=i||(s&En?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(b.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,o;return(o=r.findWrapping(e.type))?(this.match=r,o):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Tn)){let r=this.content[this.content.length-1],o;if(r&&r.isText&&(o=/[ \\t\\r\\n\\u000c]+$/.exec(r.text))){let i=r;r.text.length==o[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-o[0].length))}}let n=b.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(b.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!xa.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},wr=class{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let o=n.topNode,i,s=na(null,n.preserveWhitespace,0)|(r?En:0);o?i=new Jt(o.type,o.attrs,$.none,!0,n.topMatch||o.type.contentMatch,s):r?i=new Jt(null,null,$.none,!0,null,s):i=new Jt(e.schema.topNodeType,null,$.none,!0,null,s),this.nodes=[i],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,o=this.top,i=o.options&ci?\"full\":this.localPreserveWS||(o.options&Tn)>0,{schema:s}=this.parser;if(i===\"full\"||o.inlineContext(e)||/[^ \\t\\r\\n\\u000c]/.test(r)){if(i)if(i===\"full\")r=r.replace(/\\r\\n?/g,`\n`);else if(s.linebreakReplacement&&/[\\r\\n]/.test(r)&&this.top.findWrapping(s.linebreakReplacement.create())){let l=r.split(/\\r?\\n|\\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(s.linebreakReplacement.create(),n,!0),l[a]&&this.insertNode(s.text(l[a]),n,!/\\S/.test(l[a]));r=\"\"}else r=r.replace(/\\r?\\n|\\r/g,\" \");else if(r=r.replace(/[ \\t\\r\\n\\u000c]+/g,\" \"),/^[ \\t\\r\\n\\u000c]/.test(r)&&this.open==this.nodes.length-1){let l=o.content[o.content.length-1],a=e.previousSibling;(!l||a&&a.nodeName==\"BR\"||l.isText&&/[ \\t\\r\\n\\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(s.text(r),n,!/\\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let o=this.localPreserveWS,i=this.top;(e.tagName==\"PRE\"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let s=e.nodeName.toLowerCase(),l;Ca.hasOwnProperty(s)&&this.parser.normalizeLists&&lp(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:sp.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,n);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,u=this.needsBlock;if(xa.hasOwnProperty(s))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),c=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let d=a&&a.skip?n:this.readStyles(e,n);d&&this.addAll(e,d),c&&this.sync(i),this.needsBlock=u}else{let c=this.readStyles(e,n);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=o}leafFallback(e,n){e.nodeName==\"BR\"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`\n`),n)}ignoreFallback(e,n){e.nodeName==\"BR\"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text(\"-\"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let o=0;o<this.parser.matchedStyles.length;o++){let i=this.parser.matchedStyles[o],s=r.getPropertyValue(i);if(s)for(let l=void 0;;){let a=this.parser.matchStyle(i,s,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?n=n.filter(c=>!a.clearMark(c)):n=n.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return n}addElementByRule(e,n,r,o){let i,s;if(n.node)if(s=this.parser.schema.nodes[n.node],s.isLeaf)this.insertNode(s.create(n.attrs),r,e.nodeName==\"BR\")||this.leafFallback(e,r);else{let a=this.enter(s,n.attrs||null,r,n.preserveWhitespace);a&&(i=!0,r=a)}else{let a=this.parser.schema.marks[n.mark];r=r.concat(a.create(n.attrs))}let l=this.top;if(s&&s.isLeaf)this.findInside(e);else if(o)this.addElement(e,r,o);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof n.contentElement==\"string\"?a=e.querySelector(n.contentElement):typeof n.contentElement==\"function\"?a=n.contentElement(e):n.contentElement&&(a=n.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}i&&this.sync(l)&&this.open--}addAll(e,n,r,o){let i=r||0;for(let s=r?e.childNodes[r]:e.firstChild,l=o==null?null:e.childNodes[o];s!=l;s=s.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(s,n);this.findAtPoint(e,i)}findPlace(e,n,r){let o,i;for(let s=this.open,l=0;s>=0;s--){let a=this.nodes[s],c=a.findWrapping(e);if(c&&(!o||o.length>c.length+l)&&(o=c,i=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!o)return null;this.sync(i);for(let s=0;s<o.length;s++)n=this.enterInner(o[s],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(n=this.enterInner(i,null,n))}let o=this.findPlace(e,n,r);if(o){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let s=$.none;for(let l of o.concat(e.marks))(i.type?i.type.allowsMarkType(l.type):oa(l.type,e.type))&&(s=l.addToSet(s));return i.content.push(e.mark(s)),!0}return!1}enter(e,n,r,o){let i=this.findPlace(e.create(n),r,!1);return i&&(i=this.enterInner(e,n,r,!0,o)),i}enterInner(e,n,r,o=!1,i){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(e);let l=na(e,i,s.options);s.options&En&&s.content.length==0&&(l|=En);let a=$.none;return r=r.filter(c=>(s.type?s.type.allowsMarkType(c.type):oa(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new Jt(e,n,a,o,null,l)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));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(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=Tn)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let o=r.length-1;o>=0;o--)e+=r[o].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let o=0;o<this.find.length;o++)this.find[o].pos==null&&e.nodeType==1&&e.contains(this.find[o].node)&&n.compareDocumentPosition(this.find[o].node)&(r?2:4)&&(this.find[o].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf(\"|\")>-1)return e.split(/\\s*\\|\\s*/).some(this.matchesContext,this);let n=e.split(\"/\"),r=this.options.context,o=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(o?0:1),s=(l,a)=>{for(;l>=0;l--){let c=n[l];if(c==\"\"){if(l==n.length-1||l==0)continue;for(;a>=i;a--)if(s(l-1,a))return!0;return!1}else{let u=a>0||a==0&&o?this.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;a--}}return!0};return s(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}};function lp(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Ca.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r==\"li\"?n=e:r&&(n=null)}}function ap(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function ra(t){let e={};for(let n in t)e[n]=t[n];return e}function oa(t,e){let n=e.schema.nodes;for(let r in n){let o=n[r];if(!o.allowsMarkType(t))continue;let i=[],s=l=>{i.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:u}=l.edge(a);if(c==e||i.indexOf(u)<0&&s(u))return!0}};if(s(o.contentMatch))return!0}}var We=class t{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=pr(n).createDocumentFragment());let o=r,i=[];return e.forEach(s=>{if(i.length||s.marks.length){let l=0,a=0;for(;l<i.length&&a<s.marks.length;){let c=s.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(i[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<i.length;)o=i.pop()[1];for(;a<s.marks.length;){let c=s.marks[a++],u=this.serializeMark(c,s.isInline,n);u&&(i.push([c,o]),o.appendChild(u.dom),o=u.contentDOM||u.dom)}}o.appendChild(this.serializeNodeInner(s,n))}),r}serializeNodeInner(e,n){if(e.isText)return pr(n).createTextNode(e.text);let{dom:r,contentDOM:o}=mr(pr(n),this.nodes[e.type.name](e),null,e.attrs);if(o){if(e.isLeaf)throw new RangeError(\"Content hole not allowed in a leaf node spec\");this.serializeFragment(e.content,n,o)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let o=e.marks.length-1;o>=0;o--){let i=this.serializeMark(e.marks[o],e.isInline,n);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,n,r={}){let o=this.marks[e.type.name];return o&&mr(pr(r),o(e,n),null,e.attrs)}static renderSpec(e,n,r=null,o){return typeof n==\"string\"?{dom:e.createTextNode(n)}:mr(e,n,r,o)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new t(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=ia(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return ia(e.marks)}};function ia(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function pr(t){return t.document||window.document}var sa=new WeakMap;function cp(t){let e=sa.get(t);return e===void 0&&sa.set(t,e=up(t)),e}function up(t){let e=null;function n(r){if(r&&typeof r==\"object\")if(Array.isArray(r))if(typeof r[0]==\"string\")e||(e=[]),e.push(r);else for(let o=0;o<r.length;o++)n(r[o]);else for(let o in r)n(r[o])}return n(t),e}function mr(t,e,n,r){if(e.nodeType==1)return{dom:e};if(e.dom&&e.dom.nodeType==1)return e;let o=e[0],i;if(typeof o!=\"string\")throw new RangeError(\"Invalid array passed to renderSpec\");if(r&&(i=cp(r))&&i.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=o.indexOf(\" \");s>0&&(n=o.slice(0,s),o=o.slice(s+1));let l,a=n?t.createElementNS(n,o):t.createElement(o),c=e[1],u=1;if(c&&typeof c==\"object\"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let d in c)if(c[d]!=null){let f=d.indexOf(\" \");f>0?a.setAttributeNS(d.slice(0,f),d.slice(f+1),c[d]):d==\"style\"&&a.style?a.style.cssText=c[d]:a.setAttribute(d,c[d])}}for(let d=u;d<e.length;d++){let f=e[d];if(f===0){if(d<e.length-1||d>u)throw new RangeError(\"Content hole must be the only child of its parent node\");return{dom:a,contentDOM:a}}else if(typeof f==\"string\")a.appendChild(t.createTextNode(f));else{let{dom:h,contentDOM:p}=mr(t,f,n,r);if(a.appendChild(h),p){if(l)throw new RangeError(\"Multiple content holes\");l=p}}}return{dom:a,contentDOM:l}}var Ta=65535,Na=Math.pow(2,16);function dp(t,e){return t+e*Na}function Ma(t){return t&Ta}function fp(t){return(t-(t&Ta))/Na}var Oa=1,Ra=2,Sr=4,Da=8,Rn=class{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&Da)>0}get deletedBefore(){return(this.delInfo&(Oa|Sr))>0}get deletedAfter(){return(this.delInfo&(Ra|Sr))>0}get deletedAcross(){return(this.delInfo&Sr)>0}},Ve=class t{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&t.empty)return t.empty}recover(e){let n=0,r=Ma(e);if(!this.inverted)for(let o=0;o<r;o++)n+=this.ranges[o*3+2]-this.ranges[o*3+1];return this.ranges[r*3]+n+fp(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let o=0,i=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?o:0);if(a>e)break;let c=this.ranges[l+i],u=this.ranges[l+s],d=a+c;if(e<=d){let f=c?e==a?-1:e==d?1:n:n,h=a+o+(f<0?0:u);if(r)return h;let p=e==(n<0?a:d)?null:dp(l/3,e-a),m=0;return c&&(m|=e==a?Ra:e==d?Oa:Sr,(n<0?e!=a:e!=d)&&(m|=Da)),new Rn(h,m,p)}o+=u-c}return r?e+o:new Rn(e+o,0,null)}touches(e,n){let r=0,o=Ma(n),i=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+i],u=a+c;if(e<=u&&l==o*3)return!0;r+=this.ranges[l+s]-c}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let o=0,i=0;o<this.ranges.length;o+=3){let s=this.ranges[o],l=s-(this.inverted?i:0),a=s+(this.inverted?0:i),c=this.ranges[o+n],u=this.ranges[o+r];e(l,l+c,a,a+u),i+=u-c}}invert(){return new t(this.ranges,!this.inverted)}toString(){return(this.inverted?\"-\":\"\")+JSON.stringify(this.ranges)}static offset(e){return e==0?t.empty:new t(e<0?[0,-e,0]:[0,0,e])}};Ve.empty=new Ve([]);var Dn=class t{constructor(e,n,r=0,o=e?e.length:0){this.mirror=n,this.from=r,this.to=o,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new t(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=0,r=this._maps.length;n<e._maps.length;n++){let o=e.getMirror(n);this.appendMap(e._maps[n],o!=null&&o<n?r+o:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,r=this._maps.length+e._maps.length;n>=0;n--){let o=e.getMirror(n);this.appendMap(e._maps[n].invert(),o!=null&&o>n?r-o-1:void 0)}}invert(){let e=new t;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let o=0;for(let i=this.from;i<this.to;i++){let s=this._maps[i],l=s.mapResult(e,n);if(l.recover!=null){let a=this.getMirror(i);if(a!=null&&a>i&&a<this.to){i=a,e=this._maps[a].recover(l.recover);continue}}o|=l.delInfo,e=l.pos}return r?e:new Rn(e,o,null)}},ui=Object.create(null),te=class{getMap(){return Ve.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError(\"Invalid input for Step.fromJSON\");let r=ui[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in ui)throw new RangeError(\"Duplicate use of step JSON ID \"+e);return ui[e]=n,n.prototype.jsonID=e,n}},ne=class t{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new t(e,null)}static fail(e){return new t(null,e)}static fromReplace(e,n,r,o){try{return t.ok(e.replace(n,r,o))}catch(i){if(i instanceof it)return t.fail(i.message);throw i}}};function pi(t,e,n){let r=[];for(let o=0;o<t.childCount;o++){let i=t.child(o);i.content.size&&(i=i.copy(pi(i.content,e,i))),i.isInline&&(i=e(i,n,o)),r.push(i)}return b.fromArray(r)}var In=class t extends te{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),o=r.node(r.sharedDepth(this.to)),i=new C(pi(n.content,(s,l)=>!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),o),n.openStart,n.openEnd);return ne.fromReplace(e,this.from,this.to,i)}invert(){return new _e(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new t(n.pos,r.pos,this.mark)}merge(e){return e instanceof t&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new t(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:\"addMark\",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!=\"number\"||typeof n.to!=\"number\")throw new RangeError(\"Invalid input for AddMarkStep.fromJSON\");return new t(n.from,n.to,e.markFromJSON(n.mark))}};te.jsonID(\"addMark\",In);var _e=class t extends te{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new C(pi(n.content,o=>o.mark(this.mark.removeFromSet(o.marks)),e),n.openStart,n.openEnd);return ne.fromReplace(e,this.from,this.to,r)}invert(){return new In(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new t(n.pos,r.pos,this.mark)}merge(e){return e instanceof t&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new t(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:\"removeMark\",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!=\"number\"||typeof n.to!=\"number\")throw new RangeError(\"Invalid input for RemoveMarkStep.fromJSON\");return new t(n.from,n.to,e.markFromJSON(n.mark))}};te.jsonID(\"removeMark\",_e);var Pn=class t extends te{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ne.fail(\"No node at mark step's position\");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return ne.fromReplace(e,this.pos,this.pos+1,new C(b.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let o=0;o<n.marks.length;o++)if(!n.marks[o].isInSet(r))return new t(this.pos,n.marks[o]);return new t(this.pos,this.mark)}}return new qt(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new t(n.pos,this.mark)}toJSON(){return{stepType:\"addNodeMark\",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!=\"number\")throw new RangeError(\"Invalid input for AddNodeMarkStep.fromJSON\");return new t(n.pos,e.markFromJSON(n.mark))}};te.jsonID(\"addNodeMark\",Pn);var qt=class t extends te{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ne.fail(\"No node at mark step's position\");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return ne.fromReplace(e,this.pos,this.pos+1,new C(b.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new Pn(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new t(n.pos,this.mark)}toJSON(){return{stepType:\"removeNodeMark\",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!=\"number\")throw new RangeError(\"Invalid input for RemoveNodeMarkStep.fromJSON\");return new t(n.pos,e.markFromJSON(n.mark))}};te.jsonID(\"removeNodeMark\",qt);var G=class t extends te{constructor(e,n,r,o=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=o}apply(e){return this.structure&&fi(e,this.from,this.to)?ne.fail(\"Structure replace would overwrite content\"):ne.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Ve([this.from,this.to-this.from,this.slice.size])}invert(e){return new t(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.to,-1),r=this.from==this.to&&t.MAP_BIAS<0?n:e.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new t(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(e){if(!(e instanceof t)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?C.empty:new C(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new t(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?C.empty:new C(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new t(e.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:\"replace\",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!=\"number\"||typeof n.to!=\"number\")throw new RangeError(\"Invalid input for ReplaceStep.fromJSON\");return new t(n.from,n.to,C.fromJSON(e,n.slice),!!n.structure)}};G.MAP_BIAS=1;te.jsonID(\"replace\",G);var X=class t extends te{constructor(e,n,r,o,i,s,l=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=o,this.slice=i,this.insert=s,this.structure=l}apply(e){if(this.structure&&(fi(e,this.from,this.gapFrom)||fi(e,this.gapTo,this.to)))return ne.fail(\"Structure gap-replace would overwrite content\");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return ne.fail(\"Gap is not a flat range\");let r=this.slice.insertAt(this.insert,n.content);return r?ne.fromReplace(e,this.from,this.to,r):ne.fail(\"Content does not fit in gap\")}getMap(){return new Ve([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new t(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),o=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||o<n.pos||i>r.pos?null:new t(n.pos,r.pos,o,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:\"replaceAround\",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!=\"number\"||typeof n.to!=\"number\"||typeof n.gapFrom!=\"number\"||typeof n.gapTo!=\"number\"||typeof n.insert!=\"number\")throw new RangeError(\"Invalid input for ReplaceAroundStep.fromJSON\");return new t(n.from,n.to,n.gapFrom,n.gapTo,C.fromJSON(e,n.slice),n.insert,!!n.structure)}};te.jsonID(\"replaceAround\",X);function fi(t,e,n){let r=t.resolve(e),o=n-e,i=r.depth;for(;o>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,o--;if(o>0){let s=r.node(i).maybeChild(r.indexAfter(i));for(;o>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,o--}}return!1}function hp(t,e,n,r){let o=[],i=[],s,l;t.doc.nodesBetween(e,n,(a,c,u)=>{if(!a.isInline)return;let d=a.marks;if(!r.isInSet(d)&&u.type.allowsMarkType(r.type)){let f=Math.max(c,e),h=Math.min(c+a.nodeSize,n),p=r.addToSet(d);for(let m=0;m<d.length;m++)d[m].isInSet(p)||(s&&s.to==f&&s.mark.eq(d[m])?s.to=h:o.push(s=new _e(f,h,d[m])));l&&l.to==f?l.to=h:i.push(l=new In(f,h,r))}}),o.forEach(a=>t.step(a)),i.forEach(a=>t.step(a))}function pp(t,e,n,r){let o=[],i=0;t.doc.nodesBetween(e,n,(s,l)=>{if(!s.isInline)return;i++;let a=null;if(r instanceof An){let c=s.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(s.marks)&&(a=[r]):a=s.marks;if(a&&a.length){let c=Math.min(l+s.nodeSize,n);for(let u=0;u<a.length;u++){let d=a[u],f;for(let h=0;h<o.length;h++){let p=o[h];p.step==i-1&&d.eq(o[h].style)&&(f=p)}f?(f.to=c,f.step=i):o.push({style:d,from:Math.max(l,e),to:c,step:i})}}}),o.forEach(s=>t.step(new _e(s.from,s.to,s.style)))}function mi(t,e,n,r=n.contentMatch,o=!0){let i=t.doc.nodeAt(e),s=[],l=e+1;for(let a=0;a<i.childCount;a++){let c=i.child(a),u=l+c.nodeSize,d=r.matchType(c.type);if(!d)s.push(new G(l,u,C.empty));else{r=d;for(let f=0;f<c.marks.length;f++)n.allowsMarkType(c.marks[f].type)||t.step(new _e(l,u,c.marks[f]));if(o&&c.isText&&n.whitespace!=\"pre\"){let f,h=/\\r?\\n|\\r/g,p;for(;f=h.exec(c.text);)p||(p=new C(b.from(n.schema.text(\" \",n.allowedMarks(c.marks))),0,0)),s.push(new G(l+f.index,l+f.index+f[0].length,p))}}l=u}if(!r.validEnd){let a=r.fillBefore(b.empty,!0);t.replace(l,l,new C(a,0,0))}for(let a=s.length-1;a>=0;a--)t.step(s[a])}function mp(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Ke(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,o=0,i=0;;--r){let s=t.$from.node(r),l=t.$from.index(r)+o,a=t.$to.indexAfter(r)-i;if(r<t.depth&&s.canReplace(l,a,n))return r;if(r==0||s.type.spec.isolating||!mp(s,l,a))break;l&&(o=1),a<s.childCount&&(i=1)}return null}function gp(t,e,n){let{$from:r,$to:o,depth:i}=e,s=r.before(i+1),l=o.after(i+1),a=s,c=l,u=b.empty,d=0;for(let p=i,m=!1;p>n;p--)m||r.index(p)>0?(m=!0,u=b.from(r.node(p).copy(u)),d++):a--;let f=b.empty,h=0;for(let p=i,m=!1;p>n;p--)m||o.after(p+1)<o.end(p)?(m=!0,f=b.from(o.node(p).copy(f)),h++):c++;t.step(new X(a,c,s,l,new C(u.append(f),d,h),u.size-d,!0))}function Xt(t,e,n=null,r=t){let o=yp(t,e),i=o&&bp(r,e);return i?o.map(va).concat({type:e,attrs:n}).concat(i.map(va)):null}function va(t){return{type:t,attrs:null}}function yp(t,e){let{parent:n,startIndex:r,endIndex:o}=t,i=n.contentMatchAt(r).findWrapping(e);if(!i)return null;let s=i.length?i[0]:e;return n.canReplaceWith(r,o,s)?i:null}function bp(t,e){let{parent:n,startIndex:r,endIndex:o}=t,i=n.child(r),s=e.contentMatch.findWrapping(i.type);if(!s)return null;let a=(s.length?s[s.length-1]:e).contentMatch;for(let c=r;a&&c<o;c++)a=a.matchType(n.child(c).type);return!a||!a.validEnd?null:s}function kp(t,e,n){let r=b.empty;for(let s=n.length-1;s>=0;s--){if(r.size){let l=n[s].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError(\"Wrapper type given to Transform.wrap does not form valid content of its parent wrapper\")}r=b.from(n[s].type.create(n[s].attrs,r))}let o=e.start,i=e.end;t.step(new X(o,i,o,i,new C(r,0,0),n.length,!0))}function wp(t,e,n,r,o){if(!r.isTextblock)throw new RangeError(\"Type given to setBlockType should be a textblock\");let i=t.steps.length;t.doc.nodesBetween(e,n,(s,l)=>{let a=typeof o==\"function\"?o(s):o;if(s.isTextblock&&!s.hasMarkup(r,a)&&Sp(t.doc,t.mapping.slice(i).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let h=r.whitespace==\"pre\",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!p?c=!1:!h&&p&&(c=!0)}c===!1&&Pa(t,s,l,i),mi(t,t.mapping.slice(i).map(l,1),r,void 0,c===null);let u=t.mapping.slice(i),d=u.map(l,1),f=u.map(l+s.nodeSize,1);return t.step(new X(d,f,d+1,f-1,new C(b.from(r.create(a,null,s.marks)),0,0),1,!0)),c===!0&&Ia(t,s,l,i),!1}})}function Ia(t,e,n,r){e.forEach((o,i)=>{if(o.isText){let s,l=/\\r?\\n|\\r/g;for(;s=l.exec(o.text);){let a=t.mapping.slice(r).map(n+1+i+s.index);t.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Pa(t,e,n,r){e.forEach((o,i)=>{if(o.type==o.type.schema.linebreakReplacement){let s=t.mapping.slice(r).map(n+1+i);t.replaceWith(s,s+1,e.type.schema.text(`\n`))}})}function Sp(t,e,n){let r=t.resolve(e),o=r.index();return r.parent.canReplaceWith(o,o+1,n)}function xp(t,e,n,r,o){let i=t.doc.nodeAt(e);if(!i)throw new RangeError(\"No node at given position\");n||(n=i.type);let s=n.create(r,null,o||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 X(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new C(b.from(s),0,0),1,!0))}function Ce(t,e,n=1,r){let o=t.resolve(e),i=o.depth-n,s=r&&r[r.length-1]||o.parent;if(i<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!s.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(let c=o.depth-1,u=n-2;c>i;c--,u--){let d=o.node(c),f=o.index(c);if(d.type.spec.isolating)return!1;let h=d.content.cutByIndex(f,d.childCount),p=r&&r[u+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let m=r&&r[u]||d;if(!d.canReplace(f+1,d.childCount)||!m.type.validContent(h))return!1}let l=o.indexAfter(i),a=r&&r[0];return o.node(i).canReplaceWith(l,l,a?a.type:o.node(i+1).type)}function Cp(t,e,n=1,r){let o=t.doc.resolve(e),i=b.empty,s=b.empty;for(let l=o.depth,a=o.depth-n,c=n-1;l>a;l--,c--){i=b.from(o.node(l).copy(i));let u=r&&r[c];s=b.from(u?u.type.create(u.attrs,s):o.node(l).copy(s))}t.step(new G(e,e,new C(i.append(s),n,n),!0))}function Ne(t,e){let n=t.resolve(e),r=n.index();return La(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function Mp(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let o=0;o<e.childCount;o++){let i=e.child(o),s=i.type==r?t.type.schema.nodes.text:i.type;if(n=n.matchType(s),!n||!t.type.allowsMarks(i.marks))return!1}return n.validEnd}function La(t,e){return!!(t&&e&&!t.isLeaf&&Mp(t,e))}function Yt(t,e,n=-1){let r=t.resolve(e);for(let o=r.depth;;o--){let i,s,l=r.index(o);if(o==r.depth?(i=r.nodeBefore,s=r.nodeAfter):n>0?(i=r.node(o+1),l++,s=r.node(o).maybeChild(l)):(i=r.node(o).maybeChild(l-1),s=r.node(o+1)),i&&!i.isTextblock&&La(i,s)&&r.node(o).canReplace(l,l+1))return e;if(o==0)break;e=n<0?r.before(o):r.after(o)}}function vp(t,e,n){let r=null,{linebreakReplacement:o}=t.doc.type.schema,i=t.doc.resolve(e-n),s=i.node().type;if(o&&s.inlineContent){let u=s.whitespace==\"pre\",d=!!s.contentMatch.matchType(o);u&&!d?r=!1:!u&&d&&(r=!0)}let l=t.steps.length;if(r===!1){let u=t.doc.resolve(e+n);Pa(t,u.node(),u.before(),l)}s.inlineContent&&mi(t,e+n-1,s,i.node().contentMatchAt(i.index()),r==null);let a=t.mapping.slice(l),c=a.map(e-n);if(t.step(new G(c,a.map(e+n,-1),C.empty,!0)),r===!0){let u=t.doc.resolve(c);Ia(t,u.node(),u.before(),t.steps.length)}return t}function Ep(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let o=r.depth-1;o>=0;o--){let i=r.index(o);if(r.node(o).canReplaceWith(i,i,n))return r.before(o+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let o=r.depth-1;o>=0;o--){let i=r.indexAfter(o);if(r.node(o).canReplaceWith(i,i,n))return r.after(o+1);if(i<r.node(o).childCount)return null}return null}function Mr(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let o=n.content;for(let i=0;i<n.openStart;i++)o=o.firstChild.content;for(let i=1;i<=(n.openStart==0&&n.size?2:1);i++)for(let s=r.depth;s>=0;s--){let l=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1,a=r.index(s)+(l>0?1:0),c=r.node(s),u=!1;if(i==1)u=c.canReplace(a,a,o);else{let d=c.contentMatchAt(a).findWrapping(o.firstChild.type);u=d&&c.canReplaceWith(a,a,d[0])}if(u)return l==0?r.pos:l<0?r.before(s+1):r.after(s+1)}return null}function Ln(t,e,n=e,r=C.empty){if(e==n&&!r.size)return null;let o=t.resolve(e),i=t.resolve(n);return $a(o,i,r)?new G(e,n,r):new hi(o,i,r).fit()}function $a(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}var hi=class{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=b.empty;for(let o=0;o<=e.depth;o++){let i=e.node(o);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(o))})}for(let o=e.depth;o>0;o--)this.placed=b.from(e.node(o).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,o=this.close(e<0?this.$to:r.doc.resolve(e));if(!o)return null;let i=this.placed,s=r.depth,l=o.depth;for(;s&&l&&i.childCount==1;)i=i.firstChild.content,s--,l--;let a=new C(i,s,l);return e>-1?new X(r.pos,e,this.$to.pos,this.$to.end(),a,n):a.size||r.pos!=this.$to.pos?new G(r.pos,o.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,o=this.unplaced.openEnd;r<e;r++){let i=n.firstChild;if(n.childCount>1&&(o=0),i.type.spec.isolating&&o<=r){e=r;break}n=i.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let o,i=null;r?(i=Ea(this.unplaced.content,r-1).firstChild,o=i.content):o=this.unplaced.content;let s=o.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],u,d=null;if(n==1&&(s?c.matchType(s.type)||(d=c.fillBefore(b.from(s),!1)):i&&a.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:l,parent:i,inject:d};if(n==2&&s&&(u=c.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:l,parent:i,wrap:u};if(i&&c.matchType(i.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced;return Aa(e,-1)<=n?!1:(this.unplaced.size>1&&Aa(e,1)>r&&r++,this.unplaced=new C(e,n+1,r),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,o=Ea(e,n);if(o.childCount<=1&&n>0){let i=e.size-n<=n+o.size;this.unplaced=new C(Nn(e,n-1,1),n-1,i?n-1:r)}else this.unplaced=new C(Nn(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:o,wrap:i}){for(;this.depth>n;)this.closeFrontierNode();if(i)for(let m=0;m<i.length;m++)this.openFrontierNode(i[m]);let s=this.unplaced,l=r?r.content:s.content,a=s.openStart-e,c=0,u=[],{match:d,type:f}=this.frontier[n];if(o){for(let m=0;m<o.childCount;m++)u.push(o.child(m));d=d.matchFragment(o)}let h=l.size+e-(s.content.size-s.openEnd);for(;c<l.childCount;){let m=l.child(c),g=d.matchType(m.type);if(!g)break;c++,(c>1||a==0||m.content.size)&&(d=g,u.push(za(m.mark(f.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?h:-1)))}let p=c==l.childCount;p||(h=-1),this.placed=On(this.placed,n,b.from(u)),this.frontier[n].match=d,p&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=l;m<h;m++){let y=g.lastChild;this.frontier.push({type:y.type,match:y.contentMatchAt(y.childCount)}),g=y.content}this.unplaced=p?e==0?C.empty:new C(Nn(s.content,e-1,1),e-1,h<0?s.openEnd:e-1):new C(Nn(s.content,e,c),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!di(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:r}=this.$to,o=this.$to.after(r);for(;r>1&&o==this.$to.end(--r);)++o;return o}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:o}=this.frontier[n],i=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),s=di(e,n,o,r,i);if(s){for(let l=n-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=di(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:n,fit:s,move:i?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=On(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let o=e.node(r),i=o.type.contentMatch.fillBefore(o.content,!0,e.index(r));this.openFrontierNode(o.type,o.attrs,i)}return e}openFrontierNode(e,n=null,r){let o=this.frontier[this.depth];o.match=o.match.matchType(e),this.placed=On(this.placed,this.depth,b.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(b.empty,!0);n.childCount&&(this.placed=On(this.placed,this.frontier.length,n))}};function Nn(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Nn(t.firstChild.content,e-1,n)))}function On(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(On(t.lastChild.content,e-1,n)))}function Ea(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function za(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,za(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(b.empty,!0)))),t.copy(r)}function di(t,e,n,r,o){let i=t.node(e),s=o?t.indexAfter(e):t.index(e);if(s==i.childCount&&!n.compatibleContent(i.type))return null;let l=r.fillBefore(i.content,!0,s);return l&&!Ap(n,i.content,s)?l:null}function Ap(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function Tp(t){return t.spec.defining||t.spec.definingForContent}function Aa(t,e){for(let n=0;;n++){let r=e<0?t.firstChild:t.lastChild;if(!r||r.isAtom)return n;t=r.content}}function Np(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let o=t.doc.resolve(e),i=t.doc.resolve(n);if($a(o,i,r))return t.step(new G(e,n,r));let s=Fa(o,i);s[s.length-1]==0&&s.pop();let l=-(o.depth+1);s.unshift(l);for(let f=o.depth,h=o.pos-1;f>0;f--,h--){let p=o.node(f).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;s.indexOf(f)>-1?l=f:o.before(f)==h&&s.splice(1,0,-f)}let a=s.indexOf(l),c=[],u=r.openStart;for(let f=r.content,h=0;;h++){let p=f.firstChild;if(c.push(p),h==r.openStart)break;f=p.content}for(let f=u-1;f>=0;f--){let h=c[f],p=Tp(h.type);if(p&&!h.sameMarkup(o.node(Math.abs(l)-1)))u=f;else if(p||!h.type.isTextblock)break}for(let f=r.openStart;f>=0;f--){let h=(f+u+1)%(r.openStart+1),p=c[h];if(p)for(let m=0;m<s.length;m++){let g=s[(m+a)%s.length],y=!0;g<0&&(y=!1,g=-g);let S=o.node(g-1),k=o.index(g-1);if(S.canReplaceWith(k,k,p.type,p.marks))return t.replace(o.before(g),y?i.after(g):n,new C(Ba(r.content,0,r.openStart,h),h,r.openEnd))}}let d=t.steps.length;for(let f=s.length-1;f>=0&&(t.replace(e,n,r),!(t.steps.length>d));f--){let h=s[f];h<0||(e=o.before(h),n=i.after(h))}}function Ba(t,e,n,r,o){if(e<n){let i=t.firstChild;t=t.replaceChild(0,i.copy(Ba(i.content,e+1,n,r,i)))}if(e>r){let i=o.contentMatchAt(0),s=i.fillBefore(t).append(t);t=s.append(i.matchFragment(s).fillBefore(b.empty,!0))}return t}function Op(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let o=Ep(t.doc,e,r.type);o!=null&&(e=n=o)}t.replaceRange(e,n,new C(b.from(r),0,0))}function Rp(t,e,n){let r=t.doc.resolve(e),o=t.doc.resolve(n);if(r.parent.isTextblock&&o.parent.isTextblock&&r.start()!=o.start()&&r.parentOffset==0&&o.parentOffset==0){let s=r.sharedDepth(n),l=!1;for(let a=r.depth;a>s;a--)r.node(a).type.spec.isolating&&(l=!0);for(let a=o.depth;a>s;a--)o.node(a).type.spec.isolating&&(l=!0);if(!l){for(let a=r.depth;a>0&&e==r.start(a);a--)e=r.before(a);for(let a=o.depth;a>0&&n==o.start(a);a--)n=o.before(a);r=t.doc.resolve(e),o=t.doc.resolve(n)}}let i=Fa(r,o);for(let s=0;s<i.length;s++){let l=i[s],a=s==i.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return t.delete(r.start(l),o.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),o.indexAfter(l-1))))return t.delete(r.before(l),o.after(l))}for(let s=1;s<=r.depth&&s<=o.depth;s++)if(e-r.start(s)==r.depth-s&&n>r.end(s)&&o.end(s)-n!=o.depth-s&&r.start(s-1)==o.start(s-1)&&r.node(s-1).canReplace(r.index(s-1),o.index(s-1)))return t.delete(r.before(s),n);t.delete(e,n)}function Fa(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let o=r;o>=0;o--){let i=t.start(o);if(i<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;(i==e.start(o)||o==t.depth&&o==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&o&&e.start(o-1)==i-1)&&n.push(o)}return n}var xr=class t extends te{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return ne.fail(\"No node at attribute step's position\");let r=Object.create(null);for(let i in n.attrs)r[i]=n.attrs[i];r[this.attr]=this.value;let o=n.type.create(r,null,n.marks);return ne.fromReplace(e,this.pos,this.pos+1,new C(b.from(o),0,n.isLeaf?0:1))}getMap(){return Ve.empty}invert(e){return new t(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new t(n.pos,this.attr,this.value)}toJSON(){return{stepType:\"attr\",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!=\"number\"||typeof n.attr!=\"string\")throw new RangeError(\"Invalid input for AttrStep.fromJSON\");return new t(n.pos,n.attr,n.value)}};te.jsonID(\"attr\",xr);var Cr=class t extends te{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let o in e.attrs)n[o]=e.attrs[o];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return ne.ok(r)}getMap(){return Ve.empty}invert(e){return new t(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:\"docAttr\",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!=\"string\")throw new RangeError(\"Invalid input for DocAttrStep.fromJSON\");return new t(n.attr,n.value)}};te.jsonID(\"docAttr\",Cr);var Gt=class extends Error{};Gt=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Gt.prototype=Object.create(Error.prototype);Gt.prototype.constructor=Gt;Gt.prototype.name=\"TransformError\";var st=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Dn}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new Gt(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,n=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let o=this.mapping.maps[r];r&&(e=o.map(e,1),n=o.map(n,-1)),o.forEach((i,s,l,a)=>{e=Math.min(e,l),n=Math.max(n,a)})}return e==1e9?null:{from:e,to:n}}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=C.empty){let o=Ln(this.doc,e,n,r);return o&&this.step(o),this}replaceWith(e,n,r){return this.replace(e,n,new C(b.from(r),0,0))}delete(e,n){return this.replace(e,n,C.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return Np(this,e,n,r),this}replaceRangeWith(e,n,r){return Op(this,e,n,r),this}deleteRange(e,n){return Rp(this,e,n),this}lift(e,n){return gp(this,e,n),this}join(e,n=1){return vp(this,e,n),this}wrap(e,n){return kp(this,e,n),this}setBlockType(e,n=e,r,o=null){return wp(this,e,n,r,o),this}setNodeMarkup(e,n,r=null,o){return xp(this,e,n,r,o),this}setNodeAttribute(e,n,r){return this.step(new xr(e,n,r)),this}setDocAttribute(e,n){return this.step(new Cr(e,n)),this}addNodeMark(e,n){return this.step(new Pn(e,n)),this}removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError(\"No node at position \"+e);if(n instanceof $)n.isInSet(r.marks)&&this.step(new qt(e,n));else{let o=r.marks,i,s=[];for(;i=n.isInSet(o);)s.push(new qt(e,i)),o=i.removeFromSet(o);for(let l=s.length-1;l>=0;l--)this.step(s[l])}return this}split(e,n=1,r){return Cp(this,e,n,r),this}addMark(e,n,r){return hp(this,e,n,r),this}removeMark(e,n,r){return pp(this,e,n,r),this}clearIncompatible(e,n,r){return mi(this,e,n,r),this}};var gi=Object.create(null),E=class{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new Zt(e.min(n),e.max(n))]}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 e=this.ranges;for(let n=0;n<e.length;n++)if(e[n].$from.pos!=e[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,n=C.empty){let r=n.content.lastChild,o=null;for(let l=0;l<n.openEnd;l++)o=r,r=r.lastChild;let i=e.steps.length,s=this.ranges;for(let l=0;l<s.length;l++){let{$from:a,$to:c}=s[l],u=e.mapping.slice(i);e.replaceRange(u.map(a.pos),u.map(c.pos),l?C.empty:n),l==0&&Wa(e,i,(r?r.isInline:o&&o.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,o=this.ranges;for(let i=0;i<o.length;i++){let{$from:s,$to:l}=o[i],a=e.mapping.slice(r),c=a.map(s.pos),u=a.map(l.pos);i?e.deleteRange(c,u):(e.replaceRangeWith(c,u,n),Wa(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let o=e.parent.inlineContent?new M(e):Qt(e.node(0),e.parent,e.pos,e.index(),n,r);if(o)return o;for(let i=e.depth-1;i>=0;i--){let s=n<0?Qt(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):Qt(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,n,r);if(s)return s}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new pe(e.node(0))}static atStart(e){return Qt(e,e,0,0,1)||new pe(e)}static atEnd(e){return Qt(e,e,e.content.size,e.childCount,-1)||new pe(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError(\"Invalid input for Selection.fromJSON\");let r=gi[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in gi)throw new RangeError(\"Duplicate use of selection JSON ID \"+e);return gi[e]=n,n.prototype.jsonID=e,n}getBookmark(){return M.between(this.$anchor,this.$head).getBookmark()}};E.prototype.visible=!0;var Zt=class{constructor(e,n){this.$from=e,this.$to=n}},Ha=!1;function ja(t){!Ha&&!t.parent.inlineContent&&(Ha=!0,console.warn(\"TextSelection endpoint not pointing into a node with inline content (\"+t.parent.type.name+\")\"))}var M=class t extends E{constructor(e,n=e){ja(e),ja(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return E.near(r);let o=e.resolve(n.map(this.anchor));return new t(o.parent.inlineContent?o:r,r)}replace(e,n=C.empty){if(super.replace(e,n),n==C.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof t&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Er(this.anchor,this.head)}toJSON(){return{type:\"text\",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!=\"number\"||typeof n.head!=\"number\")throw new RangeError(\"Invalid input for TextSelection.fromJSON\");return new t(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let o=e.resolve(n);return new this(o,r==n?o:e.resolve(r))}static between(e,n,r){let o=e.pos-n.pos;if((!r||o)&&(r=o>=0?1:-1),!n.parent.inlineContent){let i=E.findFrom(n,r,!0)||E.findFrom(n,-r,!0);if(i)n=i.$head;else return E.near(n,r)}return e.parent.inlineContent||(o==0?e=n:(e=(E.findFrom(e,-r,!0)||E.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=o<0&&(e=n))),new t(e,n)}};E.jsonID(\"text\",M);var Er=class t{constructor(e,n){this.anchor=e,this.head=n}map(e){return new t(e.map(this.anchor),e.map(this.head))}resolve(e){return M.between(e.resolve(this.anchor),e.resolve(this.head))}},A=class t extends E{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:o}=n.mapResult(this.anchor),i=e.resolve(o);return r?E.near(i):new t(i)}content(){return new C(b.from(this.node),0,0)}eq(e){return e instanceof t&&e.anchor==this.anchor}toJSON(){return{type:\"node\",anchor:this.anchor}}getBookmark(){return new bi(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!=\"number\")throw new RangeError(\"Invalid input for NodeSelection.fromJSON\");return new t(e.resolve(n.anchor))}static create(e,n){return new t(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}};A.prototype.visible=!1;E.jsonID(\"node\",A);var bi=class t{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new Er(r,r):new t(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&A.isSelectable(r)?new A(n):E.near(n)}},pe=class t extends E{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=C.empty){if(n==C.empty){e.delete(0,e.doc.content.size);let r=E.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:\"all\"}}static fromJSON(e){return new t(e)}map(e){return new t(e)}eq(e){return e instanceof t}getBookmark(){return Dp}};E.jsonID(\"all\",pe);var Dp={map(){return this},resolve(t){return new pe(t)}};function Qt(t,e,n,r,o,i=!1){if(e.inlineContent)return M.create(t,n);for(let s=r-(o>0?0:1);o>0?s<e.childCount:s>=0;s+=o){let l=e.child(s);if(l.isAtom){if(!i&&A.isSelectable(l))return A.create(t,n-(o<0?l.nodeSize:0))}else{let a=Qt(t,l,n+o,o<0?l.childCount:0,o,i);if(a)return a}n+=l.nodeSize*o}return null}function Wa(t,e,n){let r=t.steps.length-1;if(r<e)return;let o=t.steps[r];if(!(o instanceof G||o instanceof X))return;let i=t.mapping.maps[r],s;i.forEach((l,a,c,u)=>{s==null&&(s=u)}),t.setSelection(E.near(t.doc.resolve(s),n))}var Va=1,vr=2,_a=4,ki=class extends st{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.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(e){if(e.$from.doc!=this.doc)throw new RangeError(\"Selection passed to setSelection must point at the current document\");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|Va)&~vr,this.storedMarks=null,this}get selectionSet(){return(this.updated&Va)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=vr,this}ensureMarks(e){return $.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&vr)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~vr,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||$.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let o=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(o.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let i=this.storedMarks;if(!i){let s=this.doc.resolve(n);i=r==n?s.marks():s.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,o.text(e,i)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(E.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e==\"string\"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e==\"string\"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=_a,this}get scrolledIntoView(){return(this.updated&_a)>0}};function Ka(t,e){return!e||!t?t:t.bind(e)}var Et=class{constructor(e,n,r){this.name=e,this.init=Ka(n.init,r),this.apply=Ka(n.apply,r)}},Ip=[new Et(\"doc\",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Et(\"selection\",{init(t,e){return t.selection||E.atStart(e.doc)},apply(t){return t.selection}}),new Et(\"storedMarks\",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Et(\"scrollToSelection\",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})],$n=class{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Ip.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError(\"Adding different instances of a keyed plugin (\"+r.key+\")\");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Et(r.key,r.spec.state,r))})}},At=class t{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=n){let o=this.config.plugins[r];if(o.spec.filterTransaction&&!o.spec.filterTransaction.call(o,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),o=null;for(;;){let i=!1;for(let s=0;s<this.config.plugins.length;s++){let l=this.config.plugins[s];if(l.spec.appendTransaction){let a=o?o[s].n:0,c=o?o[s].state:this,u=a<n.length&&l.spec.appendTransaction.call(l,a?n.slice(a):n,c,r);if(u&&r.filterTransaction(u,s)){if(u.setMeta(\"appendedTransaction\",e),!o){o=[];for(let d=0;d<this.config.plugins.length;d++)o.push(d<s?{state:r,n:n.length}:{state:this,n:0})}n.push(u),r=r.applyInner(u),i=!0}o&&(o[s]={state:r,n:n.length})}}if(!i)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError(\"Applying a mismatched transaction\");let n=new t(this.config),r=this.config.fields;for(let o=0;o<r.length;o++){let i=r[o];n[i.name]=i.apply(e,this[i.name],this,n)}return n}get tr(){return new ki(this)}static create(e){let n=new $n(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new t(n);for(let o=0;o<n.fields.length;o++)r[n.fields[o].name]=n.fields[o].init(e,r);return r}reconfigure(e){let n=new $n(this.schema,e.plugins),r=n.fields,o=new t(n);for(let i=0;i<r.length;i++){let s=r[i].name;o[s]=this.hasOwnProperty(s)?this[s]:r[i].init(e,o)}return o}toJSON(e){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e==\"object\")for(let r in e){if(r==\"doc\"||r==\"selection\")throw new RangeError(\"The JSON fields `doc` and `selection` are reserved\");let o=e[r],i=o.spec.state;i&&i.toJSON&&(n[r]=i.toJSON.call(o,this[o.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError(\"Invalid input for EditorState.fromJSON\");if(!e.schema)throw new RangeError(\"Required config field 'schema' missing\");let o=new $n(e.schema,e.plugins),i=new t(o);return o.fields.forEach(s=>{if(s.name==\"doc\")i.doc=Te.fromJSON(e.schema,n.doc);else if(s.name==\"selection\")i.selection=E.fromJSON(i.doc,n.selection);else if(s.name==\"storedMarks\")n.storedMarks&&(i.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==s.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){i[s.name]=c.fromJSON.call(a,e,n[l],i);return}}i[s.name]=s.init(e,i)}}),i}};function Ua(t,e,n){for(let r in t){let o=t[r];o instanceof Function?o=o.bind(e):r==\"handleDOMEvents\"&&(o=Ua(o,e,{})),n[r]=o}return n}var R=class{constructor(e){this.spec=e,this.props={},e.props&&Ua(e.props,this,this.props),this.key=e.key?e.key.key:Ja(\"plugin\")}getState(e){return e[this.key]}},yi=Object.create(null);function Ja(t){return t in yi?t+\"$\"+ ++yi[t]:(yi[t]=0,t+\"$\")}var P=class{constructor(e=\"key\"){this.key=Ja(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}};var Ga=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function Xa(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock(\"backward\",t):n.parentOffset>0)?null:n}var Si=(t,e,n)=>{let r=Xa(t,n);if(!r)return!1;let o=Ci(r);if(!o){let s=r.blockRange(),l=s&&Ke(s);return l==null?!1:(e&&e(t.tr.lift(s,l).scrollIntoView()),!0)}let i=o.nodeBefore;if(rc(t,o,e,-1))return!0;if(r.parent.content.size==0&&(en(i,\"end\")||A.isSelectable(i)))for(let s=r.depth;;s--){let l=Ln(t.doc,r.before(s),r.after(s),C.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=t.tr.step(l);a.setSelection(en(i,\"end\")?E.findFrom(a.doc.resolve(a.mapping.map(o.pos,-1)),-1):A.create(a.doc,o.pos-i.nodeSize)),e(a.scrollIntoView())}return!0}if(s==1||r.node(s-1).childCount>1)break}return i.isAtom&&o.depth==r.depth-1?(e&&e(t.tr.delete(o.pos-i.nodeSize,o.pos).scrollIntoView()),!0):!1},Ar=(t,e,n)=>{let r=Xa(t,n);if(!r)return!1;let o=Ci(r);return o?Ya(t,o,e):!1},Tr=(t,e,n)=>{let r=Qa(t,n);if(!r)return!1;let o=Ei(r);return o?Ya(t,o,e):!1};function Ya(t,e,n){let r=e.nodeBefore,o=r,i=e.pos-1;for(;!o.isTextblock;i--){if(o.type.spec.isolating)return!1;let u=o.lastChild;if(!u)return!1;o=u}let s=e.nodeAfter,l=s,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let u=l.firstChild;if(!u)return!1;l=u}let c=Ln(t.doc,i,a,C.empty);if(!c||c.from!=i||c instanceof G&&c.slice.size>=a-i)return!1;if(n){let u=t.tr.step(c);u.setSelection(M.create(u.doc,i)),n(u.scrollIntoView())}return!0}function en(t,e,n=!1){for(let r=t;r;r=e==\"start\"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}var xi=(t,e,n)=>{let{$head:r,empty:o}=t.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock(\"backward\",t):r.parentOffset>0)return!1;i=Ci(r)}let s=i&&i.nodeBefore;return!s||!A.isSelectable(s)?!1:(e&&e(t.tr.setSelection(A.create(t.doc,i.pos-s.nodeSize)).scrollIntoView()),!0)};function Ci(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 Qa(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock(\"forward\",t):n.parentOffset<n.parent.content.size)?null:n}var Mi=(t,e,n)=>{let r=Qa(t,n);if(!r)return!1;let o=Ei(r);if(!o)return!1;let i=o.nodeAfter;if(rc(t,o,e,1))return!0;if(r.parent.content.size==0&&(en(i,\"start\")||A.isSelectable(i))){let s=Ln(t.doc,r.before(),r.after(),C.empty);if(s&&s.slice.size<s.to-s.from){if(e){let l=t.tr.step(s);l.setSelection(en(i,\"start\")?E.findFrom(l.doc.resolve(l.mapping.map(o.pos)),1):A.create(l.doc,l.mapping.map(o.pos))),e(l.scrollIntoView())}return!0}}return i.isAtom&&o.depth==r.depth-1?(e&&e(t.tr.delete(o.pos,o.pos+i.nodeSize).scrollIntoView()),!0):!1},vi=(t,e,n)=>{let{$head:r,empty:o}=t.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock(\"forward\",t):r.parentOffset<r.parent.content.size)return!1;i=Ei(r)}let s=i&&i.nodeAfter;return!s||!A.isSelectable(s)?!1:(e&&e(t.tr.setSelection(A.create(t.doc,i.pos)).scrollIntoView()),!0)};function Ei(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}var Za=(t,e)=>{let n=t.selection,r=n instanceof A,o;if(r){if(n.node.isTextblock||!Ne(t.doc,n.from))return!1;o=n.from}else if(o=Yt(t.doc,n.from,-1),o==null)return!1;if(e){let i=t.tr.join(o);r&&i.setSelection(A.create(i.doc,o-t.doc.resolve(o).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},ec=(t,e)=>{let n=t.selection,r;if(n instanceof A){if(n.node.isTextblock||!Ne(t.doc,n.to))return!1;r=n.to}else if(r=Yt(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},tc=(t,e)=>{let{$from:n,$to:r}=t.selection,o=n.blockRange(r),i=o&&Ke(o);return i==null?!1:(e&&e(t.tr.lift(o,i).scrollIntoView()),!0)},Ai=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`\n`).scrollIntoView()),!0)};function Ti(t){for(let e=0;e<t.edgeCount;e++){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}var Ni=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let o=n.node(-1),i=n.indexAfter(-1),s=Ti(o.contentMatchAt(i));if(!s||!o.canReplaceWith(i,i,s))return!1;if(e){let l=n.after(),a=t.tr.replaceWith(l,l,s.createAndFill());a.setSelection(E.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Oi=(t,e)=>{let n=t.selection,{$from:r,$to:o}=n;if(n instanceof pe||r.parent.inlineContent||o.parent.inlineContent)return!1;let i=Ti(o.parent.contentMatchAt(o.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let s=(!r.parentOffset&&o.index()<o.parent.childCount?r:o).pos,l=t.tr.insert(s,i.createAndFill());l.setSelection(M.create(l.doc,s+1)),e(l.scrollIntoView())}return!0},Ri=(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 i=n.before();if(Ce(t.doc,i))return e&&e(t.tr.split(i).scrollIntoView()),!0}let r=n.blockRange(),o=r&&Ke(r);return o==null?!1:(e&&e(t.tr.lift(r,o).scrollIntoView()),!0)};function Pp(t){return(e,n)=>{if(e.selection instanceof A&&e.selection.node.isBlock){let{$from:h}=e.selection;return!h.parentOffset||!Ce(e.doc,h.pos)?!1:(n&&n(e.tr.split(h.pos).scrollIntoView()),!0)}if(!e.selection.$from.depth)return!1;let r=e.tr;!e.selection.empty&&(e.selection instanceof M||e.selection instanceof pe)&&r.deleteSelection();let{$from:o}=r.selection,i=r.steps.length,s=[],l,a,c=!1,u=!1;for(let h=o.depth;;h--)if(o.node(h).isBlock){c=o.end(h)==o.pos+(o.depth-h),u=o.start(h)==o.pos-(o.depth-h),a=Ti(o.node(h-1).contentMatchAt(o.indexAfter(h-1)));let m=t&&t(o.parent,c,o);s.unshift(m||(c&&a?{type:a}:null)),l=h;break}else{if(h==1)return!1;s.unshift(null)}let d=o.pos,f=Ce(r.doc,d,s.length,s);if(f||(s[0]=a?{type:a}:null,f=Ce(r.doc,d,s.length,s)),!f)return!1;if(r.split(d,s.length,s),!c&&u&&o.node(l).type!=a){let h=r.mapping.slice(i),p=h.map(o.before(l)),m=r.doc.resolve(p);a&&o.node(l-1).canReplaceWith(m.index(),m.index()+1,a)&&r.setNodeMarkup(h.map(o.before(l)),a)}return n&&n(r.scrollIntoView()),!0}}var Lp=Pp();var nc=(t,e)=>{let{$from:n,to:r}=t.selection,o,i=n.sharedDepth(r);return i==0?!1:(o=n.before(i),e&&e(t.tr.setSelection(A.create(t.doc,o))),!0)},$p=(t,e)=>(e&&e(t.tr.setSelection(new pe(t.doc))),!0);function zp(t,e,n){let r=e.nodeBefore,o=e.nodeAfter,i=e.index();return!r||!o||!r.type.compatibleContent(o.type)?!1:!r.content.size&&e.parent.canReplace(i-1,i)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(o.isTextblock||Ne(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function rc(t,e,n,r){let o=e.nodeBefore,i=e.nodeAfter,s,l,a=o.type.spec.isolating||i.type.spec.isolating;if(!a&&zp(t,e,n))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(s=(l=o.contentMatchAt(o.childCount)).findWrapping(i.type))&&l.matchType(s[0]||i.type).validEnd){if(n){let h=e.pos+i.nodeSize,p=b.empty;for(let y=s.length-1;y>=0;y--)p=b.from(s[y].create(null,p));p=b.from(o.copy(p));let m=t.tr.step(new X(e.pos-1,h,e.pos,h,new C(p,1,0),s.length,!0)),g=m.doc.resolve(h+2*s.length);g.nodeAfter&&g.nodeAfter.type==o.type&&Ne(m.doc,g.pos)&&m.join(g.pos),n(m.scrollIntoView())}return!0}let u=i.type.spec.isolating||r>0&&a?null:E.findFrom(e,1),d=u&&u.$from.blockRange(u.$to),f=d&&Ke(d);if(f!=null&&f>=e.depth)return n&&n(t.tr.lift(d,f).scrollIntoView()),!0;if(c&&en(i,\"start\",!0)&&en(o,\"end\")){let h=o,p=[];for(;p.push(h),!h.isTextblock;)h=h.lastChild;let m=i,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(h.canReplace(h.childCount,h.childCount,m.content)){if(n){let y=b.empty;for(let k=p.length-1;k>=0;k--)y=b.from(p[k].copy(y));let S=t.tr.step(new X(e.pos-p.length,e.pos+i.nodeSize,e.pos+g,e.pos+i.nodeSize-g,new C(y,p.length,0),0,!0));n(S.scrollIntoView())}return!0}}return!1}function oc(t){return function(e,n){let r=e.selection,o=t<0?r.$from:r.$to,i=o.depth;for(;o.node(i).isInline;){if(!i)return!1;i--}return o.node(i).isTextblock?(n&&n(e.tr.setSelection(M.create(e.doc,t<0?o.start(i):o.end(i)))),!0):!1}}var Di=oc(-1),Ii=oc(1);function ic(t,e=null){return function(n,r){let{$from:o,$to:i}=n.selection,s=o.blockRange(i),l=s&&Xt(s,t,e);return l?(r&&r(n.tr.wrap(s,l).scrollIntoView()),!0):!1}}function Pi(t,e=null){return function(n,r){let o=!1;for(let i=0;i<n.selection.ranges.length&&!o;i++){let{$from:{pos:s},$to:{pos:l}}=n.selection.ranges[i];n.doc.nodesBetween(s,l,(a,c)=>{if(o)return!1;if(!(!a.isTextblock||a.hasMarkup(t,e)))if(a.type==t)o=!0;else{let u=n.doc.resolve(c),d=u.index();o=u.parent.canReplaceWith(d,d+1,t)}})}if(!o)return!1;if(r){let i=n.tr;for(let s=0;s<n.selection.ranges.length;s++){let{$from:{pos:l},$to:{pos:a}}=n.selection.ranges[s];i.setBlockType(l,a,t,e)}r(i.scrollIntoView())}return!0}}function Li(...t){return function(e,n,r){for(let o=0;o<t.length;o++)if(t[o](e,n,r))return!0;return!1}}var wi=Li(Ga,Si,xi),qa=Li(Ga,Mi,vi),lt={Enter:Li(Ai,Oi,Ri,Lp),\"Mod-Enter\":Ni,Backspace:wi,\"Mod-Backspace\":wi,\"Shift-Backspace\":wi,Delete:qa,\"Mod-Delete\":qa,\"Mod-a\":$p},Bp={\"Ctrl-h\":lt.Backspace,\"Alt-Backspace\":lt[\"Mod-Backspace\"],\"Ctrl-d\":lt.Delete,\"Ctrl-Alt-Backspace\":lt[\"Mod-Delete\"],\"Alt-Delete\":lt[\"Mod-Delete\"],\"Alt-d\":lt[\"Mod-Delete\"],\"Ctrl-a\":Di,\"Ctrl-e\":Ii};for(let t in lt)Bp[t]=lt[t];var oS=typeof navigator<\"u\"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<\"u\"&&os.platform?os.platform()==\"darwin\":!1;function sc(t,e=null){return function(n,r){let{$from:o,$to:i}=n.selection,s=o.blockRange(i);if(!s)return!1;let l=r?n.tr:null;return Fp(l,s,t,e)?(r&&r(l.scrollIntoView()),!0):!1}}function Fp(t,e,n,r=null){let o=!1,i=e,s=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=s.resolve(e.start-2);i=new Ct(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new Ct(e.$from,s.resolve(e.$to.end(e.depth)),e.depth)),o=!0}let l=Xt(i,n,r,e);return l?(t&&Hp(t,e,l,o,n),!0):!1}function Hp(t,e,n,r,o){let i=b.empty;for(let u=n.length-1;u>=0;u--)i=b.from(n[u].type.create(n[u].attrs,i));t.step(new X(e.start-(r?2:0),e.end,e.start,e.end,new C(i,0,0),n.length,!0));let s=0;for(let u=0;u<n.length;u++)n[u].type==o&&(s=u+1);let l=n.length-s,a=e.start+n.length-(r?2:0),c=e.parent;for(let u=e.startIndex,d=e.endIndex,f=!0;u<d;u++,f=!1)!f&&Ce(t.doc,a,l)&&(t.split(a,l),a+=2*l),a+=c.child(u).nodeSize;return t}function lc(t){return function(e,n){let{$from:r,$to:o}=e.selection,i=r.blockRange(o,s=>s.childCount>0&&s.firstChild.type==t);return i?n?r.node(i.depth-1).type==t?jp(e,n,t,i):Wp(e,n,i):!0:!1}}function jp(t,e,n,r){let o=t.tr,i=r.end,s=r.$to.end(r.depth);i<s&&(o.step(new X(i-1,s,i,s,new C(b.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new Ct(o.doc.resolve(r.$from.pos),o.doc.resolve(s),r.depth));let l=Ke(r);if(l==null)return!1;o.lift(r,l);let a=o.doc.resolve(o.mapping.map(i,-1)-1);return Ne(o.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&o.join(a.pos),e(o.scrollIntoView()),!0}function Wp(t,e,n){let r=t.tr,o=n.parent;for(let h=n.end,p=n.endIndex-1,m=n.startIndex;p>m;p--)h-=o.child(p).nodeSize,r.delete(h-1,h+1);let i=r.doc.resolve(n.start),s=i.nodeAfter;if(r.mapping.map(n.end)!=n.start+i.nodeAfter.nodeSize)return!1;let l=n.startIndex==0,a=n.endIndex==o.childCount,c=i.node(-1),u=i.index(-1);if(!c.canReplace(u+(l?0:1),u+1,s.content.append(a?b.empty:b.from(o))))return!1;let d=i.pos,f=d+s.nodeSize;return r.step(new X(d-(l?1:0),f+(a?1:0),d+1,f-1,new C((l?b.empty:b.from(o.copy(b.empty))).append(a?b.empty:b.from(o.copy(b.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function ac(t){return function(e,n){let{$from:r,$to:o}=e.selection,i=r.blockRange(o,c=>c.childCount>0&&c.firstChild.type==t);if(!i)return!1;let s=i.startIndex;if(s==0)return!1;let l=i.parent,a=l.child(s-1);if(a.type!=t)return!1;if(n){let c=a.lastChild&&a.lastChild.type==l.type,u=b.from(c?t.create():null),d=new C(b.from(t.create(null,b.from(l.type.create(null,u)))),c?3:1,0),f=i.start,h=i.end;n(e.tr.step(new X(f-(c?3:1),h,f,h,d,1,!0)).scrollIntoView())}return!0}}var re=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},on=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e},Hi=null,Je=function(t,e,n){let r=Hi||(Hi=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},Vp=function(){Hi=null},Lt=function(t,e,n,r){return n&&(cc(t,e,n,r,-1)||cc(t,e,n,r,1))},_p=/^(img|br|input|textarea|hr)$/i;function cc(t,e,n,r,o){for(var i;;){if(t==n&&e==r)return!0;if(e==(o<0?0:ae(t))){let s=t.parentNode;if(!s||!N(s)||Kn(t)||_p.test(t.nodeName)||t.contentEditable==\"false\")return!1;e=re(t)+(o<0?0:1),t=s}else if(N(t)){let s=t.childNodes[e+(o<0?-1:0)];if(N(s)&&s.contentEditable==\"false\")if(!((i=s.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)e+=o;else return!1;else t=s,e=o<0?ae(t):0}else return!1}}function ae(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function N(t){return t.nodeType==1}function Z(t){return t.nodeType==3}function $t(t,e){return e?t.contains(N(e)?e:e.parentNode):!1}function Kp(t,e){for(;;){if(Z(t)&&e)return t;if(N(t)&&e>0){if(t.contentEditable==\"false\")return null;t=t.childNodes[e-1],e=ae(t)}else if(t.parentNode&&!Kn(t))e=re(t),t=t.parentNode;else return null}}function Up(t,e){for(;;){if(Z(t)&&e<t.nodeValue.length)return t;if(N(t)&&e<t.childNodes.length){if(t.contentEditable==\"false\")return null;t=t.childNodes[e],e=0}else if(t.parentNode&&!Kn(t))e=re(t)+1,t=t.parentNode;else return null}}function Jp(t,e,n){for(let r=e==0,o=e==ae(t);r||o;){if(t==n)return!0;let i=re(t);if(t=t.parentNode,!t)return!1;r=r&&i==0,o=o&&i==ae(t)}}function Kn(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)}var Fr=function(t){return t.focusNode&&Lt(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Tt(t,e){let n=document.createEvent(\"Event\");return n.initEvent(\"keydown\",!0,!0),n.keyCode=t,n.key=n.code=e,n}function qp(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Gp(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(ae(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(ae(r.startContainer),r.startOffset)}}}var Ie=typeof navigator<\"u\"?navigator:null,uc=typeof document<\"u\"?document:null,ft=Ie&&Ie.userAgent||\"\",ji=/Edge\\/(\\d+)/.exec(ft),Fc=/MSIE \\d/.exec(ft),Wi=/Trident\\/(?:[7-9]|\\d{2,})\\..*rv:(\\d+)/.exec(ft),be=!!(Fc||Wi||ji),ut=Fc?document.documentMode:Wi?+Wi[1]:ji?+ji[1]:0,we=!be&&/gecko\\/(\\d+)/i.test(ft);we&&+(/Firefox\\/(\\d+)/.exec(ft)||[0,0])[1];var Vi=!be&&/Chrome\\/(\\d+)/.exec(ft),oe=!!Vi,Hc=Vi?+Vi[1]:0,ce=!be&&!!Ie&&/Apple Computer/.test(Ie.vendor),sn=ce&&(/Mobile\\/\\w+/.test(ft)||!!Ie&&Ie.maxTouchPoints>2),Me=sn||(Ie?/Mac/.test(Ie.platform):!1),jc=Ie?/Win/.test(Ie.platform):!1,qe=/Android \\d/.test(ft),Hr=!!uc&&\"webkitFontSmoothing\"in uc.documentElement.style,Xp=Hr?+(/\\bAppleWebKit\\/(\\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Yp(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 Ue(t,e){return typeof t==\"number\"?t:t[e]}function Qp(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function dc(t,e,n){if(!_i(e)&&e.left==0)return;let r=t.someProp(\"scrollThreshold\")||0,o=t.someProp(\"scrollMargin\")||5,i=t.dom.ownerDocument;for(let s=n||t.dom;s;){if(!N(s)){s=on(s);continue}let l=s==i.body,a=l?Yp(i):Qp(s),c=0,u=0;if(e.top<a.top+Ue(r,\"top\")?u=-(a.top-e.top+Ue(o,\"top\")):e.bottom>a.bottom-Ue(r,\"bottom\")&&(u=e.bottom-e.top>a.bottom-a.top?e.top+Ue(o,\"top\")-a.top:e.bottom-a.bottom+Ue(o,\"bottom\")),e.left<a.left+Ue(r,\"left\")?c=-(a.left-e.left+Ue(o,\"left\")):e.right>a.right-Ue(r,\"right\")&&(c=e.right-a.right+Ue(o,\"right\")),c||u)if(l)i.defaultView.scrollBy(c,u);else{let f=s.scrollLeft,h=s.scrollTop;u&&(s.scrollTop+=u),c&&(s.scrollLeft+=c);let p=s.scrollLeft-f,m=s.scrollTop-h;e={left:e.left-p,top:e.top-m,right:e.right-p,bottom:e.bottom-m}}let d=l?\"fixed\":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(d))break;s=d==\"absolute\"?s.offsetParent:on(s)}}function Zp(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,o;for(let i=(e.left+e.right)/2,s=n+1;s<Math.min(innerHeight,e.bottom);s+=5){let l=t.root.elementFromPoint(i,s);if(!l||l==t.dom||!t.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=n-20){r=l,o=a.top;break}}return{refDOM:r,refTop:o,stack:Wc(t.dom)}}function Wc(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=on(r));return e}function em({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;Vc(n,r==0?0:r-e)}function Vc(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:o,left:i}=t[n];r.scrollTop!=o+e&&(r.scrollTop=o+e),r.scrollLeft!=i&&(r.scrollLeft=i)}}var tn=null;function tm(t){if(t.setActive)return t.setActive();if(tn)return t.focus(tn);let e=Wc(t);t.focus(tn==null?{get preventScroll(){return tn={preventScroll:!0},!0}}:void 0),tn||(tn=!1,Vc(e,0))}function _c(t,e){let n,r=2e8,o,i=0,s=e.top,l=e.top,a,c;for(let u=t.firstChild,d=0;u;u=u.nextSibling,d++){let f;if(N(u))f=u.getClientRects();else if(Z(u))f=Je(u).getClientRects();else continue;for(let h=0;h<f.length;h++){let p=f[h];if(p.top<=s&&p.bottom>=l){s=Math.max(p.bottom,s),l=Math.min(p.top,l);let m=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(m<r){n=u,r=m,o=m&&Z(n)?{left:p.right<e.left?p.right:p.left,top:e.top}:e,N(u)&&m&&(i=d+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=u,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!n&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(i=d+1)}}return!n&&a&&(n=a,o=c,r=0),n&&Z(n)?nm(n,o):!n||r?{node:t,offset:i}:_c(n,o)}function nm(t,e){let n=t.nodeValue.length,r=document.createRange(),o;for(let i=0;i<n;i++){r.setEnd(t,i+1),r.setStart(t,i);let s=at(r,1);if(s.top!=s.bottom&&ls(e,s)){o={node:t,offset:i+(e.left>=(s.left+s.right)/2?1:0)};break}}return r.detach(),o||{node:t,offset:0}}function ls(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function rm(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function om(t,e,n){let{node:r,offset:o}=_c(e,n),i=-1;if(N(r)&&!r.firstChild){let s=r.getBoundingClientRect();i=s.left!=s.right&&n.left>(s.left+s.right)/2?1:-1}return t.docView.posFromDOM(r,o,i)}function im(t,e,n,r){let o=-1;for(let i=e,s=!1;i!=t.dom;){let l=t.docView.nearestDesc(i,!0),a;if(!l)return null;if(N(l.dom)&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!s&&a.left>r.left||a.top>r.top?o=l.posBefore:(!s&&a.right<r.left||a.bottom<r.top)&&(o=l.posAfter),s=!0),!l.contentDOM&&o<0&&!l.node.isText))return(l.node.isBlock?r.top<(a.top+a.bottom)/2:r.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;i=l.dom.parentNode}return o>-1?o:t.docView.posFromDOM(e,n,-1)}function Kc(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let o=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),i=o;;){let s=t.childNodes[i];if(N(s)){let l=s.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(ls(e,c))return Kc(s,e,c)}}if((i=(i+1)%r)==o)break}return t}function sm(t,e){let n=t.dom.ownerDocument,r,o=0,i=Gp(n,e.left,e.top);i&&({node:r,offset:o}=i);let s=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),l;if(!s||!t.dom.contains(s)){let c=t.dom.getBoundingClientRect();if(!ls(e,c)||(s=Kc(t.dom,e,c),!s))return null}if(ce)for(let c=s;r&&c;c=on(c))c.draggable&&(r=void 0);if(s=rm(s,e),r){if(we&&N(r)&&(o=Math.min(o,r.childNodes.length),o<r.childNodes.length)){let u=r.childNodes[o],d;u.nodeName==\"IMG\"&&(d=u.getBoundingClientRect()).right<=e.left&&d.bottom>e.top&&o++}let c;Hr&&o&&N(r)&&N(c=r.childNodes[o-1])&&c.contentEditable==\"false\"&&c.getBoundingClientRect().top>=e.top&&o--,r==t.dom&&o==r.childNodes.length-1&&N(r.lastChild)&&e.top>r.lastChild.getBoundingClientRect().bottom?l=t.state.doc.content.size:(o==0||!N(r)||r.childNodes[o-1].nodeName!=\"BR\")&&(l=im(t,r,o,e))}l==null&&(l=om(t,s,e));let a=t.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function _i(t){return t.top<t.bottom||t.left<t.right}function at(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(_i(r))return r}return Array.prototype.find.call(n,_i)||t.getBoundingClientRect()}var lm=/[\\u0590-\\u05f4\\u0600-\\u06ff\\u0700-\\u08ac]/;function Uc(t,e,n){let{node:r,offset:o,atom:i}=t.docView.domFromPos(e,n<0?-1:1),s=Hr||we;if(Z(r))if(s&&(lm.test(r.nodeValue)||(n<0?!o:o==r.nodeValue.length))){let a=at(Je(r,o,o),n);if(we&&o&&/\\s/.test(r.nodeValue[o-1])&&o<r.nodeValue.length){let c=at(Je(r,o-1,o-1),-1);if(c.top==a.top){let u=at(Je(r,o,o+1),-1);if(u.top!=a.top)return zn(u,u.left<c.left)}}return a}else{let a=o,c=o,u=n<0?1:-1;return n<0&&!o?(c++,u=-1):n>=0&&o==r.nodeValue.length?(a--,u=1):n<0?a--:c++,zn(at(Je(r,a,c),u),u<0)}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&o&&(n<0||o==ae(r))){let a=r.childNodes[o-1];if(N(a))return $i(a.getBoundingClientRect(),!1)}if(i==null&&o<ae(r)){let a=r.childNodes[o];if(N(a))return $i(a.getBoundingClientRect(),!0)}return $i(r.getBoundingClientRect(),n>=0)}if(i==null&&o&&(n<0||o==ae(r))){let a=r.childNodes[o-1],c=Z(a)?Je(a,ae(a)-(s?0:1)):N(a)&&(a.nodeName!=\"BR\"||!a.nextSibling)?a:null;if(c)return zn(at(c,1),!1)}if(i==null&&o<ae(r)){let a=r.childNodes[o];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?Z(a)?Je(a,0,s?0:1):N(a)?a:null:null;if(c)return zn(at(c,-1),!0)}return zn(at(Z(r)?Je(r):r,-n),n>=0)}function zn(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function $i(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function Jc(t,e,n){let r=t.state,o=t.root.activeElement;r!=e&&t.updateState(e),o!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),o!=t.dom&&o&&o.focus()}}function am(t,e,n){let r=e.selection,o=n==\"up\"?r.$from:r.$to;return Jc(t,e,()=>{let{node:i}=t.docView.domFromPos(o.pos,n==\"up\"?-1:1);for(;;){let l=t.docView.nearestDesc(i,!0);if(!l)break;if(l.node.isBlock){i=l.contentDOM||l.dom;break}i=l.dom.parentNode}let s=Uc(t,o.pos,1);for(let l=i.firstChild;l;l=l.nextSibling){let a;if(N(l))a=l.getClientRects();else if(Z(l))a=Je(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let u=a[c];if(u.bottom>u.top+1&&(n==\"up\"?s.top-u.top>(u.bottom-s.top)*2:u.bottom-s.bottom>(s.bottom-u.top)*2))return!1}}return!0})}var cm=/[\\u0590-\\u08ac]/;function um(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let o=r.parentOffset,i=!o,s=o==r.parent.content.size,l=t.domSelection();return l?!cm.test(r.parent.textContent)||!l.modify?n==\"left\"||n==\"backward\"?i:s:Jc(t,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:u,anchorOffset:d}=t.domSelectionRange(),f=l.caretBidiLevel;l.modify(\"move\",n,\"character\");let h=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:p,focusOffset:m}=t.domSelectionRange(),g=p&&!$t(h,p)||a==p&&c==m;try{l.collapse(u,d),a&&(a!=u||c!=d)&&l.extend&&l.extend(a,c)}catch{}return f!=null&&(l.caretBidiLevel=f),g}):r.pos==r.start()||r.pos==r.end()}var fc=null,hc=null,pc=!1;function dm(t,e,n){return fc==e&&hc==n?pc:(fc=e,hc=n,pc=n==\"up\"||n==\"down\"?am(t,e,n):um(t,e,n))}var ve=0,mc=1,Nt=2,Oe=3,zt=class{constructor(e,n,r,o){this.parent=e,this.children=n,this.dom=r,this.contentDOM=o,this.dirty=ve,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(e){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let n=0,r=this.posAtStart;;n++){let o=this.children[n];if(o==e)return r;r+=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(e,n,r){if(this.contentDOM&&$t(this.contentDOM,e))if(r<0){let i,s;if(e==this.contentDOM)i=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&!((s=i.pmViewDesc)&&s.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(s)+s.size:this.posAtStart}else{let i,s;if(e==this.contentDOM)i=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&!((s=i.pmViewDesc)&&s.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(s):this.posAtEnd}let o;if(e==this.dom&&this.contentDOM)o=n>re(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))o=!!(e.compareDocumentPosition(this.contentDOM)&4);else if(this.dom.firstChild){if(n==0)for(let i=e;;i=i.parentNode){if(i==this.dom){o=!1;break}if(i.previousSibling)break}if(o==null&&n==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){o=!0;break}if(i.nextSibling)break}}return o??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,o=e;o;o=o.parentNode){let i=this.getDesc(o),s;if(i&&(!n||i.node))if(r&&(s=i.nodeDOM)&&!(N(s)?$t(s,e):s==e))r=!1;else return i}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let o=e;o;o=o.parentNode){let i=this.getDesc(o);if(i)return i.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let o=this.children[n],i=r+o.size;if(r==e&&i!=r){for(;!o.border&&o.children.length;)for(let s=0;s<o.children.length;s++){let l=o.children[s];if(l.size){o=l;break}}return o}if(e<i)return o.descAt(e-r-o.border);r=i}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,o=0;for(let i=0;r<this.children.length;r++){let s=this.children[r],l=i+s.size;if(l>e){o=e-i;break}i=l}if(o)return this.children[r].domFromPos(o-this.children[r].border,n);for(;r>0;r--){let i=this.children[r-1];if(i.size||!(i instanceof Rr||i instanceof Nr&&i.side>=0))break}if(n<=0){let i,s=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,s=!1);return i&&n&&s&&!i.border&&!i.domAtom?i.domFromPos(i.size,n):{node:this.contentDOM,offset:i?re(i.dom)+1:0}}else{let i,s=!0;for(;i=r<this.children.length?this.children[r]:null,!(!i||i.dom.parentNode==this.contentDOM);r++,s=!1);return i&&s&&!i.border&&!i.domAtom?i.domFromPos(0,n):{node:this.contentDOM,offset:i?re(i.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let o=-1,i=-1;for(let s=r,l=0;;l++){let a=this.children[l],c=s+a.size;if(o==-1&&e<=c){let u=s+a.border;if(e>=u&&n<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,n,u);e=s;for(let d=l;d>0;d--){let f=this.children[d-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){o=re(f.dom)+1;break}e-=f.size}o==-1&&(o=0)}if(o>-1&&(c>n||l==this.children.length-1)){n=c;for(let u=l+1;u<this.children.length;u++){let d=this.children[u];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(-1)){i=re(d.dom);break}n+=d.size}i==-1&&(i=this.contentDOM.childNodes.length);break}s=c}return{node:this.contentDOM,from:e,to:n,fromOffset:o,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:r}=this.domFromPos(e,0);if(!N(n)||r==n.childNodes.length)throw new RangeError(\"No node after pos \"+e);return n.childNodes[r]}setSelection(e,n,r,o=!1){let i=Math.min(e,n),s=Math.max(e,n);for(let h=0,p=0;h<this.children.length;h++){let m=this.children[h],g=p+m.size;if(i>p&&s<g)return m.setSelection(e-p-m.border,n-p-m.border,r,o);p=g}let l=this.domFromPos(e,e?-1:1),a=n==e?l:this.domFromPos(n,n?-1:1),c=r.root.getSelection(),u=r.domSelectionRange(),d=!1;if((we||ce)&&e==n){let{node:h,offset:p}=l;if(Z(h)){if(d=!!(p&&h.nodeValue[p-1]==`\n`),d&&p==h.nodeValue.length)for(let m=h,g;m;m=m.parentNode){if(g=m.nextSibling){g.nodeName==\"BR\"&&(l=a={node:g.parentNode,offset:re(g)+1});break}let y=m.pmViewDesc;if(y&&y.node&&y.node.isBlock)break}}else{let m=h.childNodes[p-1];d=m&&(m.nodeName==\"BR\"||m.contentEditable==\"false\")}}if(we&&u.focusNode&&u.focusNode!=a.node&&N(u.focusNode)){let h=u.focusNode.childNodes[u.focusOffset];h&&h.contentEditable==\"false\"&&(o=!0)}if(!(o||d&&ce)&&Lt(l.node,l.offset,u.anchorNode,u.anchorOffset)&&Lt(a.node,a.offset,u.focusNode,u.focusOffset))return;let f=!1;if((c.extend||e==n)&&!(d&&we)){c.collapse(l.node,l.offset);try{e!=n&&c.extend(a.node,a.offset),f=!0}catch{}}if(!f){if(e>n){let p=l;l=a,a=p}let h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!=\"selection\"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,o=0;o<this.children.length;o++){let i=this.children[o],s=r+i.size;if(r==s?e<=s&&n>=r:e<s&&n>r){let l=r+i.border,a=s-i.border;if(e>=l&&n<=a){this.dirty=e==r||n==s?Nt:mc,e==l&&n==a&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=Oe:i.markDirty(e-l,n-l);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Nt:Oe}r=s}this.dirty=Nt}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Nt:mc;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},Nr=class extends zt{constructor(e,n,r,o){let i,s=n.type.toDOM;if(typeof s==\"function\"&&(s=s(r,()=>{if(!i)return o;if(i.parent)return i.parent.posBeforeChild(i)})),!n.type.spec.raw){let l=N(s)?s:document.createElement(\"span\");l!=s&&l.appendChild(s),l.hasAttribute(\"contenteditable\")||(l.contentEditable=\"false\"),l.classList.add(\"ProseMirror-widget\")}super(e,[],s,null),this.widget=n,this.widget=n,i=this}matchesWidget(e){return this.dirty==ve&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!=\"selection\"||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}},Ki=class extends zt{constructor(e,n,r,o){super(e,[],n,null),this.textDOM=r,this.text=o}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type===\"characterData\"&&e.target.nodeValue==e.oldValue}},Rt=class t extends zt{constructor(e,n,r,o,i){super(e,[],r,o),this.mark=n,this.spec=i}static create(e,n,r,o){let i=o.nodeViews[n.type.name],s=i&&i(n,o,r);return(!s||!s.dom)&&(s=We.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new t(e,n,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&Oe||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Oe&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=ve){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=ve}}slice(e,n,r){let o=t.create(this.parent,this.mark,!0,r),i=this.children,s=this.size;n<s&&(i=Gi(i,n,s,r)),e>0&&(i=Gi(i,0,e,r));for(let l=0;l<i.length;l++)i[l].parent=o;return o.children=i,o}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},dt=class t extends zt{constructor(e,n,r,o,i,s,l){super(e,[],i,s),this.node=n,this.outerDeco=r,this.innerDeco=o,this.nodeDOM=l}static create(e,n,r,o,i,s){let l=i.nodeViews[n.type.name],a,c=l&&l(n,i,()=>{if(!a)return s;if(a.parent)return a.parent.posBeforeChild(a)},r,o),u=c&&c.dom,d=c&&c.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(!Z(u))throw new RangeError(\"Text must be rendered as a DOM text node\")}else u||({dom:u,contentDOM:d}=We.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!d&&!n.isText&&u.nodeName!=\"BR\"&&(u.hasAttribute(\"contenteditable\")||(u.contentEditable=\"false\"),n.type.spec.draggable&&(u.draggable=!0));let f=u;return u=Xc(u,r,n),c?a=new Ui(e,n,r,o,u,d||null,f,c):n.isText?new Or(e,n,r,o,u,f):new t(e,n,r,o,u,d||null,f)}parseRule(e){if(this.node.type.spec.reparseInView)return null;let n={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace==\"pre\"&&(n.preserveWhitespace=\"full\"),!this.contentDOM)n.getContent=()=>this.node.content;else if(!this.contentLost)n.contentElement=this.contentDOM;else{for(let r=this.children.length-1;r>=0;r--){let o=this.children[r];if(this.dom.contains(o.dom.parentNode)){n.contentElement=o.dom.parentNode;break}}if(!n.contentElement){let r=e&&e.find(o=>N(o)&&e.indexOf(o.parentNode)<0&&this.dom.contains(o));r?n.contentElement=r:n.getContent=()=>b.empty}}return n}matchesNode(e,n,r){return this.dirty==ve&&e.eq(this.node)&&Dr(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,o=n,i=e.composing?this.localCompositionInfo(e,n):null,s=i&&i.pos>-1?i:null,l=i&&i.pos<0,a=new qi(this,s&&s.node,e),c=this.node.inlineContent,u=c&&this.node.isBlock;mm(this.node,this.innerDeco,(d,f,h)=>{d.spec.marks?a.syncToMarks(d.spec.marks,r,e,f):d.type.side>=0&&!h&&a.syncToMarks(f==this.node.childCount?$.none:this.node.child(f).marks,r,e,f),a.placeWidget(d,e,o)},(d,f,h,p)=>{a.syncToMarks(d.marks,r,e,p),u&&d.isAtom&&!d.isText&&a.addHackNode(\"IMG\",a.top);let m;a.findNodeMatch(d,f,h,p)||l&&e.state.selection.from>o&&e.state.selection.to<o+d.nodeSize&&(m=a.findIndexWithChild(i.node))>-1&&a.updateNodeAt(d,f,h,m,e)||a.updateNextNode(d,f,h,e,p,o)||a.addNode(d,f,h,e,o),o+=d.nodeSize,c&&(u=d.isAtom&&!d.isText)}),a.syncToMarks([],r,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==Nt)&&(s&&this.protectLocalComposition(e,s),qc(this.contentDOM,this.children,e),sn&&gm(this.dom))}localCompositionInfo(e,n){let{from:r,to:o}=e.state.selection;if(!(e.state.selection instanceof M)||r<n||o>n+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let s=i.nodeValue,l=ym(this.node.content,s,r-n,o-n);return l<0?null:{node:i,pos:l,text:s}}else return{node:i,pos:-1,text:\"\"}}protectLocalComposition(e,{node:n,pos:r,text:o}){if(this.getDesc(n))return;let i=n;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let s=new Ki(this,i,n,o);e.input.compositionNodes.push(s),this.children=Gi(this.children,r,r+o.length,e,s)}update(e,n,r,o){return this.dirty==Oe||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,o),!0)}updateInner(e,n,r,o){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(o,this.posAtStart),this.dirty=ve}updateOuterDeco(e){if(Dr(e,this.outerDeco))return;let n=!N(this.nodeDOM),r=this.dom;this.dom=Gc(this.dom,this.nodeDOM,Ji(this.outerDeco,this.node,n),Ji(e,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){N(this.nodeDOM)&&(this.nodeDOM.classList.add(\"ProseMirror-selectednode\"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){N(this.nodeDOM)&&(this.nodeDOM.classList.remove(\"ProseMirror-selectednode\"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute(\"draggable\"))}get domAtom(){return this.node.isAtom}};function gc(t,e,n,r,o){Xc(r,e,t);let i=new dt(void 0,t,e,n,r,r,r);return i.contentDOM&&i.updateChildren(o,0),i}var Or=class t extends dt{constructor(e,n,r,o,i,s){super(e,n,r,o,i,null,s)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,o){return this.dirty==Oe||this.dirty!=ve&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=ve||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,o.trackWrites==this.nodeDOM&&(o.trackWrites=null)),this.node=e,this.dirty=ve,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!=\"characterData\"&&e.type!=\"selection\"}slice(e,n,r){let o=this.node.cut(e,n),i=document.createTextNode(o.text);return new t(this.parent,o,this.outerDeco,this.innerDeco,i,i)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=Oe)}get domAtom(){return!1}isText(e){return this.node.text==e}},Rr=class extends zt{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==ve&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName==\"IMG\"}},Ui=class extends dt{constructor(e,n,r,o,i,s,l,a){super(e,n,r,o,i,s,l),this.spec=a}update(e,n,r,o){if(this.dirty==Oe)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,n,r);return i&&this.updateInner(e,n,r,o),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,o){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,o)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}};function qc(t,e,n){let r=t.firstChild,o=!1;for(let i=0;i<e.length;i++){let s=e[i],l=s.dom;if(l.parentNode==t){for(;l!=r;)r=yc(r),o=!0;r=r.nextSibling}else o=!0,t.insertBefore(l,r);if(s instanceof Rt){let a=r?r.previousSibling:t.lastChild;qc(s.contentDOM,s.children,n),r=a?a.nextSibling:t.firstChild}}for(;r;)r=yc(r),o=!0;o&&n.trackWrites==t&&(n.trackWrites=null)}var Fn=function(t){t&&(this.nodeName=t)};Fn.prototype=Object.create(null);var Ot=[new Fn];function Ji(t,e,n){if(t.length==0)return Ot;let r=n?Ot[0]:new Fn,o=[r];for(let i=0;i<t.length;i++){let s=t[i].type.attrs;if(s){s.nodeName&&o.push(r=new Fn(s.nodeName));for(let l in s){let a=s[l];a!=null&&(n&&o.length==1&&o.push(r=new Fn(e.isInline?\"span\":\"div\")),l==\"class\"?r.class=(r.class?r.class+\" \":\"\")+a:l==\"style\"?r.style=(r.style?r.style+\";\":\"\")+a:l!=\"nodeName\"&&(r[l]=a))}}}return o}function Gc(t,e,n,r){if(n==Ot&&r==Ot)return e;let o=e;for(let i=0;i<r.length;i++){let s=r[i],l=n[i];if(i){let a;l&&l.nodeName==s.nodeName&&o!=t&&(a=o.parentNode)&&a.nodeName.toLowerCase()==s.nodeName||(a=document.createElement(s.nodeName),a.pmIsDeco=!0,a.appendChild(o),l=Ot[0]),o=a}fm(o,l||Ot[0],s)}return o}function fm(t,e,n){for(let r in e)r!=\"class\"&&r!=\"style\"&&r!=\"nodeName\"&&!(r in n)&&t.removeAttribute(r);for(let r in n)r!=\"class\"&&r!=\"style\"&&r!=\"nodeName\"&&n[r]!=e[r]&&t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(\" \").filter(Boolean):[],o=n.class?n.class.split(\" \").filter(Boolean):[];for(let i=0;i<r.length;i++)o.indexOf(r[i])==-1&&t.classList.remove(r[i]);for(let i=0;i<o.length;i++)r.indexOf(o[i])==-1&&t.classList.add(o[i]);t.classList.length==0&&t.removeAttribute(\"class\")}if(e.style!=n.style){if(e.style){let r=/\\s*([\\w\\-\\xa1-\\uffff]+)\\s*:(?:\"(?:\\\\.|[^\"])*\"|'(?:\\\\.|[^'])*'|\\(.*?\\)|[^;])*/g,o;for(;o=r.exec(e.style);)t.style.removeProperty(o[1])}n.style&&(t.style.cssText+=n.style)}}function Xc(t,e,n){return Gc(t,t,Ot,Ji(e,n,!N(t)))}function Dr(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 yc(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}var qi=class{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=hm(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let r=e;r<n;r++)this.top.children[r].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,r,o){let i=0,s=this.stack.length>>1,l=Math.min(s,e.length);for(;i<l&&(i==s-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<s;)this.destroyRest(),this.top.dirty=ve,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let a=-1,c=this.top.children.length;o<this.preMatch.index&&(c=Math.min(this.index+3,c));for(let u=this.index;u<c;u++){let d=this.top.children[u];if(d.matchesMark(e[s])&&!this.isLocked(d.dom)){a=u;break}}if(a<0&&this.index<this.top.children.length){let u=this.top.children[this.index];u instanceof Rt&&u.dirty!=Oe&&u.mark.type==e[s].type&&u.spec.update&&!this.isLocked(u.dom)&&u.spec.update(e[s])&&(u.mark=e[s],a=this.index,this.changed=!0)}if(a>-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let u=Rt.create(this.top,e[s],n,r);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,s++}}findNodeMatch(e,n,r,o){let i=-1,s;if(o>=this.preMatch.index&&(s=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&s.matchesNode(e,n,r))i=this.top.children.indexOf(s,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,n,r)&&!this.preMatch.matched.has(c)){i=l;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,n,r,o,i){let s=this.top.children[o];return s.dirty==Oe&&s.dom==s.contentDOM&&(s.dirty=Nt),s.update(e,n,r,i)?(this.destroyBetween(this.index,o),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let o=this.index;o<this.top.children.length;o++)if(this.top.children[o]==r)return o}return-1}e=n}}updateNextNode(e,n,r,o,i,s){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof dt){let c=this.preMatch.matched.get(a);if(c!=null&&c!=i)return!1;let u=a.dom,d,f=this.isLocked(u)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=Oe&&Dr(n,a.outerDeco));if(!f&&a.update(e,n,r,o))return this.destroyBetween(this.index,l),a.dom!=u&&(this.changed=!0),this.index++,!0;if(!f&&(d=this.recreateWrapper(a,e,n,r,o,s)))return this.destroyBetween(this.index,l),this.top.children[this.index]=d,d.contentDOM&&(d.dirty=Nt,d.updateChildren(o,s+1),d.dirty=ve),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,o,i,s){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!Dr(r,e.outerDeco)||!o.eq(e.innerDeco))return null;let l=dt.create(this.top,n,r,o,i,s);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,n,r,o,i){let s=dt.create(this.top,e,n,r,o,i);s.contentDOM&&s.updateChildren(o,i+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(e,n,r){let o=this.index<this.top.children.length?this.top.children[this.index]:null;if(o&&o.matchesWidget(e)&&(e==o.widget||!o.widget.type.toDOM.parentNode))this.index++;else{let i=new Nr(this.top,e,n,r);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof Rt;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof Or)||/\\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\\s$/.test(e.node.text))&&((ce||oe)&&e&&e.dom.contentEditable==\"false\"&&this.addHackNode(\"IMG\",n),this.addHackNode(\"BR\",this.top))}addHackNode(e,n){if(n==this.top&&this.index<n.children.length&&n.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e==\"IMG\"&&(r.className=\"ProseMirror-separator\",r.alt=\"\"),e==\"BR\"&&(r.className=\"ProseMirror-trailingBreak\");let o=new Rr(this.top,[],r,null);n!=this.top?n.children.push(o):n.children.splice(this.index++,0,o),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||N(e)&&e.contains(this.lock.parentNode))}};function hm(t,e){let n=e,r=n.children.length,o=t.childCount,i=new Map,s=[];e:for(;o>0;){let l;for(;;)if(r){let c=n.children[r-1];if(c instanceof Rt)n=c,r=c.children.length;else{l=c,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let a=l.node;if(a){if(a!=t.child(o-1))break;--o,i.set(l,o),s.push(l)}}return{index:o,matched:i,matches:s.reverse()}}function pm(t,e){return t.type.side-e.type.side}function mm(t,e,n,r){let o=e.locals(t),i=0;if(o.length==0){for(let c=0;c<t.childCount;c++){let u=t.child(c);r(u,o,e.forChild(i,u),c),i+=u.nodeSize}return}let s=0,l=[],a=null;for(let c=0;;){let u,d;for(;s<o.length&&o[s].to==i;){let g=o[s++];g.widget&&(u?(d||(d=[u])).push(g):u=g)}if(u)if(d){d.sort(pm);for(let g=0;g<d.length;g++)n(d[g],c,!!a)}else n(u,c,!!a);let f,h;if(a)h=-1,f=a,a=null;else if(c<t.childCount)h=c,f=t.child(c++);else break;for(let g=0;g<l.length;g++)l[g].to<=i&&l.splice(g--,1);for(;s<o.length&&o[s].from<=i&&o[s].to>i;)l.push(o[s++]);let p=i+f.nodeSize;if(f.isText){let g=p;s<o.length&&o[s].from<g&&(g=o[s].from);for(let y=0;y<l.length;y++)l[y].to<g&&(g=l[y].to);g<p&&(a=f.cut(g-i),f=f.cut(0,g-i),p=g,h=-1)}else for(;s<o.length&&o[s].to<p;)s++;let m=f.isInline&&!f.isLeaf?l.filter(g=>!g.inline):l.slice();r(f,m,e.forChild(i,f),h),i=p}}function gm(t){if(t.nodeName==\"UL\"||t.nodeName==\"OL\"){let e=t.style.cssText;t.style.cssText=e+\"; list-style: square !important\",window.getComputedStyle(t).listStyle,t.style.cssText=e}}function ym(t,e,n,r){for(let o=0,i=0;o<t.childCount&&i<=r;){let s=t.child(o++),l=i;if(i+=s.nodeSize,!s.isText)continue;let a=s.text;for(;o<t.childCount;){let c=t.child(o++);if(i+=c.nodeSize,!c.isText)break;a+=c.text}if(i>=n){if(i>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l<r?a.lastIndexOf(e,r-l-1):-1;if(c>=0&&c+e.length+l>=n)return l+c;if(n==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function Gi(t,e,n,r,o){let i=[];for(let s=0,l=0;s<t.length;s++){let a=t[s],c=l,u=l+=a.size;c>=n||u<=e?i.push(a):(c<e&&i.push(a.slice(0,e-c,r)),o&&(i.push(o),o=void 0),u>n&&i.push(a.slice(n-c,a.size,r)))}return i}function as(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let o=t.docView.nearestDesc(n.focusNode),i=o&&o.size==0,s=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let l=r.resolve(s),a,c;if(Fr(n)){for(a=s;o&&!o.node;)o=o.parent;if(o&&o.node.isAtom&&A.isSelectable(o.node)&&o.parent&&!(o.node.isInline&&Jp(n.focusNode,n.focusOffset,o.dom))){let d=o.posBefore;c=new A(s==d?l:r.resolve(d))}else if(we&&e==\"key\"&&s>t.state.selection.to&&N(n.focusNode)&&n.focusOffset==n.focusNode.childNodes.length&&o&&o.posAtStart>t.state.selection.to)for(let d=n.focusNode;;d=d.parentNode){if(getComputedStyle(d).overflow!=\"visible\"){c=E.findFrom(r.resolve(o.posAtStart),1);break}if(d==o.dom||d.nextSibling||!d.parentNode||!N(d.parentNode))break}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let d=s,f=s;for(let h=0;h<n.rangeCount;h++){let p=n.getRangeAt(h);d=Math.min(d,t.docView.posFromDOM(p.startContainer,p.startOffset,1)),f=Math.max(f,t.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(d<0)return null;[a,s]=f==t.state.selection.anchor?[f,d]:[d,f],l=r.resolve(s)}else a=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(a<0)return null}let u=r.resolve(a);if(!c){let d=e==\"pointer\"||t.state.selection.head<l.pos&&!i?1:-1;c=cs(t,u,l,d)}return c}function Yc(t){return t.editable?t.hasFocus():Zc(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Xe(t,e=!1){let n=t.state.selection;if(Qc(t,n),!Yc(t))return;let r=t.input.mouseDown;if(!e&&oe&&r){let o=t.domSelectionRange(),i=t.domObserver.currentSelection;if(o.anchorNode&&i.anchorNode&&Lt(o.anchorNode,o.anchorOffset,i.anchorNode,i.anchorOffset)&&r.delaySelUpdate()){t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)km(t);else{let{anchor:o,head:i}=n,s,l;bc&&!(n instanceof M)&&(n.$from.parent.inlineContent||(s=kc(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(l=kc(t,n.to))),t.docView.setSelection(o,i,t,e),bc&&(s&&wc(s),l&&wc(l)),n.visible?t.dom.classList.remove(\"ProseMirror-hideselection\"):(t.dom.classList.add(\"ProseMirror-hideselection\"),\"onselectionchange\"in document&&bm(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}var bc=ce||oe&&Hc<63;function kc(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),o=r<n.childNodes.length?n.childNodes[r]:null,i=r?n.childNodes[r-1]:null;if(ce&&o&&o.contentEditable==\"false\")return zi(o);if((!o||o.contentEditable==\"false\")&&(!i||i.contentEditable==\"false\")){if(o)return zi(o);if(i)return zi(i)}}function zi(t){return t.contentEditable=\"true\",ce&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function wc(t){t.contentEditable=\"false\",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function bm(t){let e=t.dom.ownerDocument;e.removeEventListener(\"selectionchange\",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,o=n.anchorOffset;e.addEventListener(\"selectionchange\",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=o)&&(e.removeEventListener(\"selectionchange\",t.input.hideSelectionGuard),setTimeout(()=>{(!Yc(t)||t.state.selection.visible)&&t.dom.classList.remove(\"ProseMirror-hideselection\")},20))})}function km(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName==\"IMG\";r?e.collapse(n.parentNode,re(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&be&&ut<=11&&(n.disabled=!0,n.disabled=!1)}function Qc(t,e){if(e instanceof A){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(Sc(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else Sc(t)}function Sc(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function cs(t,e,n,r){return t.someProp(\"createSelectionBetween\",o=>o(t,e,n))||M.between(e,n,r)}function xc(t){return t.editable&&!t.hasFocus()?!1:Zc(t)}function Zc(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return $t(t.dom,e.anchorNode)&&(t.editable||$t(t.dom,e.focusNode))}catch{return!1}}function wm(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Lt(e.node,e.offset,n.anchorNode,n.anchorOffset)}function Xi(t,e){let{$anchor:n,$head:r}=t.selection,o=e>0?n.max(r):n.min(r),i=o.parent.inlineContent?o.depth?t.doc.resolve(e>0?o.after():o.before()):null:o;return i&&E.findFrom(i,e)}function ct(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function Cc(t,e,n){let r=t.state.selection;if(r instanceof M)if(n.indexOf(\"s\")>-1){let{$head:o}=r,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let s=t.state.doc.resolve(o.pos+i.nodeSize*(e<0?-1:1));return ct(t,new M(r.$anchor,s))}else if(r.empty){if(t.endOfTextblock(e>0?\"forward\":\"backward\")){let o=Xi(t.state,e);return o&&o instanceof A?ct(t,o):!1}else if(!(Me&&n.indexOf(\"m\")>-1)){let o=r.$head,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter,s;if(!i||i.isText)return!1;let l=e<0?o.pos-i.nodeSize:o.pos;return i.isAtom||(s=t.docView.descAt(l))&&!s.contentDOM?A.isSelectable(i)?ct(t,new A(e<0?t.state.doc.resolve(o.pos-i.nodeSize):o)):ct(t,new M(t.state.doc.resolve(e<0?l:l+i.nodeSize))):!1}}else return!1;else{if(r instanceof A&&r.node.isInline)return ct(t,new M(e>0?r.$to:r.$from));{let o=Xi(t.state,e);return o?ct(t,o):!1}}}function Hn(t,e){let n=t.pmViewDesc;return n?n.size==0&&(e<0||t.nextSibling||t.nodeName!=\"BR\"):N(t)&&t.contentEditable==\"false\"}function nn(t,e){return e<0?Sm(t):xm(t)}function Sm(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let o,i,s=!1;for(we&&N(n)&&r<ae(n)&&Hn(n.childNodes[r],-1)&&(s=!0);;)if(r>0){if(!N(n))break;let l=n.childNodes[r-1];if(Hn(l,-1))o=n,i=--r;else if(Z(l))n=l,r=n.nodeValue.length;else break}else{if(eu(n))break;{let l=n.previousSibling;for(;l&&Hn(l,-1);)o=n.parentNode,i=re(l),l=l.previousSibling;if(l)n=l,r=ae(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}s?Yi(t,n,r):o&&Yi(t,o,i)}function xm(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let o=ae(n),i,s;for(;;)if(r<o){if(!N(n))break;let l=n.childNodes[r];if(Hn(l,1))i=n,s=++r;else break}else{if(eu(n))break;{let l=n.nextSibling;for(;l&&Hn(l,1);)i=l.parentNode,s=re(l)+1,l=l.nextSibling;if(l)n=l,r=0,o=ae(n);else{if(n=n.parentNode,n==t.dom)break;r=o=0}}}i&&Yi(t,i,s)}function eu(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function Cm(t,e){for(;t&&e==t.childNodes.length&&!Kn(t);)e=re(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(Z(n))return n;if(N(n)&&n.contentEditable==\"false\")break;t=n,e=0}}function Mm(t,e){for(;t&&!e&&!Kn(t);)e=re(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(Z(n))return n;if(N(n)&&n.contentEditable==\"false\")break;t=n,e=t.childNodes.length}}function Yi(t,e,n){if(!Z(e)){let i,s;(s=Cm(e,n))?(e=s,n=0):(i=Mm(e,n))&&(e=i,n=i.nodeValue.length)}let r=t.domSelection();if(!r)return;if(Fr(r)){let i=document.createRange();i.setEnd(e,n),i.setStart(e,n),r.removeAllRanges(),r.addRange(i)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:o}=t;setTimeout(()=>{t.state==o&&Xe(t)},50)}function Mc(t,e){let n=t.state.doc.resolve(e);if(!(oe||jc)&&n.parent.inlineContent){let o=t.coordsAtPos(e);if(e>n.start()){let i=t.coordsAtPos(e-1),s=(i.top+i.bottom)/2;if(s>o.top&&s<o.bottom&&Math.abs(i.left-o.left)>1)return i.left<o.left?\"ltr\":\"rtl\"}if(e<n.end()){let i=t.coordsAtPos(e+1),s=(i.top+i.bottom)/2;if(s>o.top&&s<o.bottom&&Math.abs(i.left-o.left)>1)return i.left>o.left?\"ltr\":\"rtl\"}}return getComputedStyle(t.dom).direction==\"rtl\"?\"rtl\":\"ltr\"}function vc(t,e,n){let r=t.state.selection;if(r instanceof M&&!r.empty||n.indexOf(\"s\")>-1||Me&&n.indexOf(\"m\")>-1)return!1;let{$from:o,$to:i}=r;if(!o.parent.inlineContent||t.endOfTextblock(e<0?\"up\":\"down\")){let s=Xi(t.state,e);if(s&&s instanceof A)return ct(t,s)}if(!o.parent.inlineContent){let s=e<0?o:i,l=r instanceof pe?E.near(s,e):E.findFrom(s,e);return l?ct(t,l):!1}return!1}function Ec(t,e){if(!(t.state.selection instanceof M))return!0;let{$head:n,$anchor:r,empty:o}=t.state.selection;if(!n.sameParent(r))return!0;if(!o)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 s=t.state.tr;return e<0?s.delete(n.pos-i.nodeSize,n.pos):s.delete(n.pos,n.pos+i.nodeSize),t.dispatch(s),!0}return!1}function Ac(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function vm(t){if(!ce||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&N(e)&&n==0&&e.firstChild&&N(e.firstChild)&&e.firstChild.contentEditable==\"false\"){let r=e.firstChild;Ac(t,r,\"true\"),setTimeout(()=>Ac(t,r,\"false\"),20)}return!1}function Em(t){let e=\"\";return t.ctrlKey&&(e+=\"c\"),t.metaKey&&(e+=\"m\"),t.altKey&&(e+=\"a\"),t.shiftKey&&(e+=\"s\"),e}function Am(t,e){let n=e.keyCode,r=Em(e);if(n==8||Me&&n==72&&r==\"c\")return Ec(t,-1)||nn(t,-1);if(n==46&&!e.shiftKey||Me&&n==68&&r==\"c\")return Ec(t,1)||nn(t,1);if(n==13||n==27)return!0;if(n==37||Me&&n==66&&r==\"c\"){let o=n==37?Mc(t,t.state.selection.from)==\"ltr\"?-1:1:-1;return Cc(t,o,r)||nn(t,o)}else if(n==39||Me&&n==70&&r==\"c\"){let o=n==39?Mc(t,t.state.selection.from)==\"ltr\"?1:-1:1;return Cc(t,o,r)||nn(t,o)}else{if(n==38||Me&&n==80&&r==\"c\")return vc(t,-1,r)||nn(t,-1);if(n==40||Me&&n==78&&r==\"c\")return vm(t)||vc(t,1,r)||nn(t,1);if(r==(Me?\"m\":\"c\")&&(n==66||n==73||n==89||n==90))return!0}return!1}function us(t,e){t.someProp(\"transformCopied\",h=>{e=h(e,t)});let n=[],{content:r,openStart:o,openEnd:i}=e;for(;o>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){o--,i--;let h=r.firstChild;n.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let s=t.someProp(\"clipboardSerializer\")||We.fromSchema(t.state.schema),l=su(),a=l.createElement(\"div\");a.appendChild(s.serializeFragment(r,{document:l}));let c=a.firstChild,u,d=0;for(;c&&N(c)&&(u=iu[c.nodeName.toLowerCase()]);){for(let h=u.length-1;h>=0;h--){let p=l.createElement(u[h]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),d++}c=a.firstChild}c&&N(c)&&c.setAttribute(\"data-pm-slice\",`${o} ${i}${d?` -${d}`:\"\"} ${JSON.stringify(n)}`);let f=t.someProp(\"clipboardTextSerializer\",h=>h(e,t))||e.content.textBetween(0,e.content.size,`\n\n`);return{dom:a,text:f,slice:e}}function tu(t,e,n,r,o){let i=o.parent.type.spec.code,s,l;if(!n&&!e)return null;let a=!!e&&(r||i||!n);if(a){if(t.someProp(\"transformPastedText\",f=>{e=f(e,i||r,t)}),i)return l=new C(b.from(t.state.schema.text(e.replace(/\\r\\n?/g,`\n`))),0,0),t.someProp(\"transformPasted\",f=>{l=f(l,t,!0)}),l;let d=t.someProp(\"clipboardTextParser\",f=>f(e,o,r,t));if(d)l=d;else{let f=o.marks(),{schema:h}=t.state,p=We.fromSchema(h);s=document.createElement(\"div\"),e.split(/(?:\\r\\n?|\\n)+/).forEach(m=>{let g=s.appendChild(document.createElement(\"p\"));m&&g.appendChild(p.serializeNode(h.text(m,f)))})}}else t.someProp(\"transformPastedHTML\",d=>{n=d(n,t)}),s=Rm(n),Hr&&Dm(s);let c=s&&s.querySelector(\"[data-pm-slice]\"),u=c&&/^(\\d+) (\\d+)(?: -(\\d+))? (.*)/.exec(c.getAttribute(\"data-pm-slice\")||\"\");if(u&&u[3])for(let d=+u[3];d>0;d--){let f=s.firstChild;for(;f&&!N(f);)f=f.nextSibling;if(!f)break;s=f}if(l||(l=(t.someProp(\"clipboardParser\")||t.someProp(\"domParser\")||je.fromSchema(t.state.schema)).parseSlice(s,{preserveWhitespace:!!(a||u),context:o,ruleFromNode(f){return f.nodeName==\"BR\"&&!f.nextSibling&&f.parentNode&&!Tm.test(f.parentNode.nodeName)?{ignore:!0}:null}})),u)l=Im(Tc(l,+u[1],+u[2]),u[4]);else if(l=C.maxOpen(Nm(l.content,o),!0),l.openStart||l.openEnd){let d=0,f=0;for(let h=l.content.firstChild;d<l.openStart&&!h.type.spec.isolating;d++,h=h.firstChild);for(let h=l.content.lastChild;f<l.openEnd&&!h.type.spec.isolating;f++,h=h.lastChild);l=Tc(l,d,f)}return t.someProp(\"transformPasted\",d=>{l=d(l,t,a)}),l}var Tm=/^(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 Nm(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let o=e.node(n).contentMatchAt(e.index(n)),i,s=[];if(t.forEach(l=>{if(!s)return;let a=o.findWrapping(l.type),c;if(!a)return s=null;if(c=s.length&&i.length&&ru(a,i,l,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=ou(s[s.length-1],i.length));let u=nu(l,a);s.push(u),o=o.matchType(u.type),i=a}}),s)return b.from(s)}return t}function nu(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,b.from(t));return t}function ru(t,e,n,r,o){if(o<t.length&&o<e.length&&t[o]==e[o]){let i=ru(t,e,n,r.lastChild,o+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(o==t.length-1?n.type:t[o+1]))return r.copy(r.content.append(b.from(nu(n,t,o+1))))}}function ou(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,ou(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(b.empty,!0);return t.copy(n.append(r))}function Qi(t,e,n,r,o,i){let s=e<0?t.firstChild:t.lastChild,l=s.content;return t.childCount>1&&(i=0),o<r-1&&(l=Qi(l,e,n,r,o+1,i)),o>=n&&(l=e<0?s.contentMatchAt(0).fillBefore(l,i<=o).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(b.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,s.copy(l))}function Tc(t,e,n){return e<t.openStart&&(t=new C(Qi(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new C(Qi(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}var iu={thead:[\"table\"],tbody:[\"table\"],tfoot:[\"table\"],caption:[\"table\"],colgroup:[\"table\"],col:[\"table\",\"colgroup\"],tr:[\"table\",\"tbody\"],td:[\"table\",\"tbody\",\"tr\"],th:[\"table\",\"tbody\",\"tr\"]};function su(){return document.implementation.createHTMLDocument(\"title\")}var Bn=null;function Om(t){let e=window.trustedTypes;if(!e)return t;if(!Bn){if(Bn=e.defaultPolicy)try{return Bn.createHTML(t)}catch{}Bn=e.createPolicy(\"ProseMirrorClipboard\",{createHTML:n=>n})}return Bn.createHTML(t)}function Rm(t){let e=/^(\\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=su(),r=n.body,o=/<([a-z][^>\\s]+)/i.exec(t),i;if((i=o&&iu[o[1].toLowerCase()])&&(t=i.map(s=>\"<\"+s+\">\").join(\"\")+t+i.map(s=>\"</\"+s+\">\").reverse().join(\"\")),r.innerHTML=Om(t),i)for(let s=0;s<i.length;s++)r=r.querySelector(i[s])||r;for(let s=0;s<n.styleSheets.length;s++){let l=n.styleSheets[s];for(let a=0;a<l.rules.length;a++){let c=l.rules[a];if(c instanceof CSSStyleRule){let u=r.querySelectorAll(c.selectorText);for(let d=0;d<u.length;d++)u[d].style.cssText+=c.style.cssText}}}return r}function Dm(t){let e=t.querySelectorAll(oe?\"span:not([class]):not([style])\":\"span.Apple-converted-space\");for(let n=0;n<e.length;n++){let r=e[n];r.childNodes.length==1&&r.textContent==\"\\xA0\"&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(\" \"),r)}}function Im(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:o,openStart:i,openEnd:s}=t;for(let l=r.length-2;l>=0;l-=2){let a=n.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;try{o=b.from(a.create(r[l+1],o))}catch{break}i++,s++}return new C(o,i,s)}var me={},ge={},Pm={touchstart:!0,touchmove:!0},Zi=class{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.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function Lm(t){for(let e in me){let n=me[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{zm(t,r)&&!ds(t,r)&&(t.editable||!(r.type in ge))&&n(t,r)},Pm[e]?{passive:!0}:void 0)}ce&&t.dom.addEventListener(\"input\",()=>null),es(t)}function Ge(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function $m(t){t.input.mouseDown&&t.input.mouseDown.done(),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)}function es(t){t.someProp(\"handleDOMEvents\",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>ds(t,r))})}function ds(t,e){return t.someProp(\"handleDOMEvents\",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function zm(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||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function Bm(t,e){!ds(t,e)&&me[e.type]&&(t.editable||!(e.type in ge))&&me[e.type](t,e)}ge.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!cu(t)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(qe&&oe&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),sn&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp(\"handleKeyDown\",o=>o(t,Tt(13,\"Enter\"))),t.input.lastIOSEnter=0)},200)}else t.someProp(\"handleKeyDown\",r=>r(t,n))||Am(t,n)?n.preventDefault():Ge(t,\"key\")};ge.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};ge.keypress=(t,e)=>{let n=e;if(cu(t)||!n.charCode||n.ctrlKey&&!n.altKey||Me&&n.metaKey)return;if(t.someProp(\"handleKeyPress\",o=>o(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof M)||!r.$from.sameParent(r.$to)){let o=String.fromCharCode(n.charCode),i=()=>t.state.tr.insertText(o).scrollIntoView();!/[\\r\\n]/.test(o)&&!t.someProp(\"handleTextInput\",s=>s(t,r.$from.pos,r.$to.pos,o,i))&&t.dispatch(i()),n.preventDefault()}};function Un(t){return{left:t.clientX,top:t.clientY}}function Fm(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function fs(t,e,n,r,o){if(r==-1)return!1;let i=t.state.doc.resolve(r);for(let s=i.depth+1;s>0;s--)if(t.someProp(e,l=>s>i.depth?l(t,n,i.nodeAfter,i.before(s),o,!0):l(t,n,i.node(s),i.before(s),o,!1)))return!0;return!1}function Jn(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);r.setMeta(\"pointer\",!0),t.dispatch(r)}function Hm(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&A.isSelectable(r)?(Jn(t,new A(n)),!0):!1}function jm(t,e){if(e==-1)return!1;let n=t.state.selection,r,o;n instanceof A&&(r=n.node);let i=t.state.doc.resolve(e);for(let s=i.depth+1;s>0;s--){let l=s>i.depth?i.nodeAfter:i.node(s);if(A.isSelectable(l)){r&&n.$from.depth>0&&s>=n.$from.depth&&i.before(n.$from.depth+1)==n.$from.pos?o=i.before(n.$from.depth):o=i.before(s);break}}return o!=null?(Jn(t,A.create(t.state.doc,o)),!0):!1}function Wm(t,e,n,r,o){return fs(t,\"handleClickOn\",e,n,r)||t.someProp(\"handleClick\",i=>i(t,e,r))||(o?jm(t,n):Hm(t,n))}function Vm(t,e,n,r){return fs(t,\"handleDoubleClickOn\",e,n,r)||t.someProp(\"handleDoubleClick\",o=>o(t,e,r))}function _m(t,e,n,r){return fs(t,\"handleTripleClickOn\",e,n,r)||t.someProp(\"handleTripleClick\",o=>o(t,e,r))||Km(t,n,r)}function Km(t,e,n){if(n.button!=0)return!1;let r=lu(t,e,!0),o=t.state.doc;return r?(Jn(t,r),r instanceof M&&o.eq(t.state.doc)&&(t.input.mouseDown=new ns(t,r)),!0):!1}function lu(t,e,n){let r=t.state.doc;if(e==-1)return r.inlineContent?M.create(r,0,r.content.size):null;let o=r.resolve(e);for(let i=o.depth+1;i>0;i--){let s=i>o.depth?o.nodeAfter:o.node(i),l=o.before(i);if(s.inlineContent)return M.create(r,l+1,l+1+s.content.size);if(n&&A.isSelectable(s))return A.create(r,l)}return null}function hs(t){return Pr(t)}var au=Me?\"metaKey\":\"ctrlKey\";me.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=hs(t),o=Date.now(),i=\"singleClick\";o-t.input.lastClick.time<500&&Fm(n,t.input.lastClick)&&!n[au]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type==\"singleClick\"?i=\"doubleClick\":t.input.lastClick.type==\"doubleClick\"&&(i=\"tripleClick\")),t.input.lastClick={time:o,x:n.clientX,y:n.clientY,type:i,button:n.button},t.input.mouseDown&&t.input.mouseDown.done();let s=t.posAtCoords(Un(n));s&&(i==\"singleClick\"?t.input.mouseDown=new ts(t,s,n,!!r):(i==\"doubleClick\"?Vm:_m)(t,s.pos,s.inside,n)?n.preventDefault():Ge(t,\"pointer\"))};var Ir=class{constructor(e){this.view=e,this.mightDrag=null,e.root.addEventListener(\"mouseup\",this.up=this.up.bind(this)),e.root.addEventListener(\"mousemove\",this.move=this.move.bind(this))}up(e){this.done()}move(e){e.buttons==0&&this.done()}done(){this.view.root.removeEventListener(\"mouseup\",this.up),this.view.root.removeEventListener(\"mousemove\",this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null)}delaySelUpdate(){return!1}},ts=class extends Ir{constructor(e,n,r,o){super(e),this.pos=n,this.event=r,this.flushed=o,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!r[au],this.allowDefault=r.shiftKey;let i,s;if(n.inside>-1)i=e.state.doc.nodeAt(n.inside),s=n.inside;else{let u=e.state.doc.resolve(n.pos);i=u.parent,s=u.depth?u.before():0}let l=o?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&N(a.nodeDOM)?a.nodeDOM:null;let{selection:c}=e.state;r.button==0&&(i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof A&&c.from<=s&&c.to>s)&&(this.mightDrag={node:i,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&we&&!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()),Ge(e,\"pointer\")}done(){super.done(),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(()=>{this.view.isDestroyed||Xe(this.view)})}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(Un(e))),this.updateAllowDefault(e),this.allowDefault||!n?Ge(this.view,\"pointer\"):Wm(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ce&&this.mightDrag&&!this.mightDrag.node.isAtom||oe&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(Jn(this.view,E.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Ge(this.view,\"pointer\")}move(e){this.updateAllowDefault(e),Ge(this.view,\"pointer\"),super.move(e)}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return this.allowDefault?(this.delayedSelectionSync=!0,!0):!1}},ns=class extends Ir{constructor(e,n){super(e),this.startSelection=n,this.startDoc=e.state.doc}move(e){if(e.buttons==0||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc)){this.done();return}e.preventDefault(),Ge(this.view,\"pointer\");let n=this.view.posAtCoords(Un(e)),r=n&&lu(this.view,n.inside,!1);if(!r)return;let{doc:o}=this.view.state,i=this.startSelection,[s,l]=r.from<i.from?[i.to,r.from]:[i.from,r.to];Jn(this.view,M.create(o,s,l))}};me.touchstart=t=>{t.input.lastTouch=Date.now(),hs(t),Ge(t,\"pointer\")};me.touchmove=t=>{t.input.lastTouch=Date.now(),Ge(t,\"pointer\")};me.contextmenu=t=>hs(t);function cu(t,e){return t.composing?!0:ce&&Math.abs(Date.now()-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}var Um=qe?5e3:-1;ge.compositionstart=ge.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof M&&e.selection.empty&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||oe&&jc&&Jm(t)))t.markCursor=t.state.storedMarks||n.marks(),Pr(t,!0),t.markCursor=null;else if(Pr(t,!e.selection.empty),we&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let o=r.focusNode,i=r.focusOffset;o&&N(o)&&i!=0;){let s=i<0?o.lastChild:o.childNodes[i-1];if(!s)break;if(Z(s)){let l=t.domSelection();l&&l.collapse(s,s.nodeValue.length);break}else o=s,i=-1}}t.input.composing=!0}uu(t,Um)};function Jm(t){let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(!e||!N(e)||n>=e.childNodes.length)return!1;let r=e.childNodes[n];return N(r)&&r.contentEditable==\"false\"}ge.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Date.now(),t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.badSafariComposition?t.domObserver.forceFlush():t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,uu(t,20))};function uu(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>Pr(t),e))}function du(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Date.now());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function qm(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=Kp(e.focusNode,e.focusOffset),r=Up(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let o=r.pmViewDesc,i=t.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!o||!o.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let s=n.pmViewDesc;if(!(!s||!s.isText(n.nodeValue)))return r}}return n||r}function Pr(t,e=!1){if(!(qe&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),du(t),e||t.docView&&t.docView.dirty){let n=as(t),r=t.state.selection;return n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function Gm(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 r=getSelection(),o=document.createRange();o.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}var jn=be&&ut<15||sn&&Xp<604;me.copy=ge.cut=(t,e)=>{let n=e,r=t.state.selection,o=n.type==\"cut\";if(r.empty)return;let i=jn?null:n.clipboardData,s=r.content(),{dom:l,text:a}=us(t,s);i?(n.preventDefault(),i.clearData(),i.setData(\"text/html\",l.innerHTML),i.setData(\"text/plain\",a)):Gm(t,l),o&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta(\"uiEvent\",\"cut\"))};function Xm(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function Ym(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?\"textarea\":\"div\"));n||(r.contentEditable=\"true\"),r.style.cssText=\"position: fixed; left: -10000px; top: 10px\",r.focus();let o=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Wn(t,r.value,null,o,e):Wn(t,r.textContent,r.innerHTML,o,e)},50)}function Wn(t,e,n,r,o){let i=tu(t,e,n,r,t.state.selection.$from);if(t.someProp(\"handlePaste\",a=>a(t,o,i||C.empty)))return!0;if(!i)return!1;let s=Xm(i),l=s?t.state.tr.replaceSelectionWith(s,r):t.state.tr.replaceSelection(i);return t.dispatch(l.scrollIntoView().setMeta(\"paste\",!0).setMeta(\"uiEvent\",\"paste\")),!0}function fu(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,\" \"):\"\"}ge.paste=(t,e)=>{let n=e;if(t.composing&&!qe)return;let r=jn?null:n.clipboardData,o=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&Wn(t,fu(r),r.getData(\"text/html\"),o,n)?n.preventDefault():Ym(t,n)};var Lr=class{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}},Qm=Me?\"altKey\":\"ctrlKey\";function hu(t,e){let n;return t.someProp(\"dragCopies\",r=>{n=n||r(e)}),n!=null?!n:!e[Qm]}me.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let o=t.state.selection,i=o.empty?null:t.posAtCoords(Un(n)),s;if(!(i&&i.pos>=o.from&&i.pos<=(o instanceof A?o.to-1:o.to))){if(r&&r.mightDrag)s=A.create(t.state.doc,r.mightDrag.pos);else if(n.target&&N(n.target)){let d=t.docView.nearestDesc(n.target,!0);d&&d.node.type.spec.draggable&&d!=t.docView&&(s=A.create(t.state.doc,d.posBefore))}}let l=(s||t.state.selection).content(),{dom:a,text:c,slice:u}=us(t,l);(!n.dataTransfer.files.length||!oe||Hc>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(jn?\"Text\":\"text/html\",a.innerHTML),n.dataTransfer.effectAllowed=\"copyMove\",jn||n.dataTransfer.setData(\"text/plain\",c),t.dragging=new Lr(u,hu(t,n),s)};me.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};ge.dragover=ge.dragenter=(t,e)=>e.preventDefault();ge.drop=(t,e)=>{try{Zm(t,e,t.dragging)}finally{t.dragging=null}};function Zm(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(Un(e));if(!r)return;let o=t.state.doc.resolve(r.pos),i=n&&n.slice;i?t.someProp(\"transformPasted\",h=>{i=h(i,t,!1)}):i=tu(t,fu(e.dataTransfer),jn?null:e.dataTransfer.getData(\"text/html\"),!1,o);let s=!!(n&&hu(t,e));if(t.someProp(\"handleDrop\",h=>h(t,e,i||C.empty,s))){e.preventDefault();return}if(!i)return;e.preventDefault();let l=i?Mr(t.state.doc,o.pos,i):o.pos;l==null&&(l=o.pos);let a=t.state.tr;if(s){let{node:h}=n;h?h.replace(a):a.deleteSelection()}let c=a.mapping.map(l),u=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,d=a.doc;if(u?a.replaceRangeWith(c,c,i.content.firstChild):a.replaceRange(c,c,i),a.doc.eq(d))return;let f=a.doc.resolve(c);if(u&&A.isSelectable(i.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(i.content.firstChild))a.setSelection(new A(f));else{let h=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((p,m,g,y)=>h=y),a.setSelection(cs(t,f,a.doc.resolve(h)))}t.focus(),t.dispatch(a.setMeta(\"uiEvent\",\"drop\"))}me.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())&&Xe(t)},20))};me.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)};me.beforeinput=(t,e)=>{if(qe&&e.inputType==\"deleteContentBackward\"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp(\"handleKeyDown\",i=>i(t,Tt(8,\"Backspace\")))))return;let{$cursor:o}=t.state.selection;o&&o.pos>0&&t.dispatch(t.state.tr.delete(o.pos-1,o.pos).scrollIntoView())},50)}};for(let t in ge)me[t]=ge[t];function Vn(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}var $r=class t{constructor(e,n){this.toDOM=e,this.spec=n||It,this.side=this.spec.side||0}map(e,n,r,o){let{pos:i,deleted:s}=e.mapResult(n.from+o,this.side<0?-1:1);return s?null:new ee(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof t&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Vn(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},Dt=class t{constructor(e,n){this.attrs=e,this.spec=n||It}map(e,n,r,o){let i=e.map(n.from+o,this.spec.inclusiveStart?-1:1)-r,s=e.map(n.to+o,this.spec.inclusiveEnd?1:-1)-r;return i>=s?null:new ee(i,s,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof t&&Vn(this.attrs,e.attrs)&&Vn(this.spec,e.spec)}static is(e){return e.type instanceof t}destroy(){}},rs=class t{constructor(e,n){this.attrs=e,this.spec=n||It}map(e,n,r,o){let i=e.mapResult(n.from+o,1);if(i.deleted)return null;let s=e.mapResult(n.to+o,-1);return s.deleted||s.pos<=i.pos?null:new ee(i.pos-r,s.pos-r,this)}valid(e,n){let{index:r,offset:o}=e.content.findIndex(n.from),i;return o==n.from&&!(i=e.child(r)).isText&&o+i.nodeSize==n.to}eq(e){return this==e||e instanceof t&&Vn(this.attrs,e.attrs)&&Vn(this.spec,e.spec)}destroy(){}},ee=class t{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new t(e,n,this.type)}eq(e,n=0){return this.type.eq(e.type)&&this.from+n==e.from&&this.to+n==e.to}map(e,n,r){return this.type.map(e,this,n,r)}static widget(e,n,r){return new t(e,e,new $r(n,r))}static inline(e,n,r,o){return new t(e,n,new Dt(r,o))}static node(e,n,r,o){return new t(e,n,new rs(r,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof Dt}get widget(){return this.type instanceof $r}},rn=[],It={},z=class t{constructor(e,n){this.local=e.length?e:rn,this.children=n.length?n:rn}static create(e,n){return n.length?Br(n,e,0,It):le}find(e,n,r){let o=[];return this.findInner(e??0,n??1e9,o,0,r),o}findInner(e,n,r,o,i){for(let s=0;s<this.local.length;s++){let l=this.local[s];l.from<=n&&l.to>=e&&(!i||i(l.spec))&&r.push(l.copy(l.from+o,l.to+o))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<n&&this.children[s+1]>e){let l=this.children[s]+1;this.children[s+2].findInner(e-l,n-l,r,o+l,i)}}map(e,n,r){return this==le||e.maps.length==0?this:this.mapInner(e,n,0,0,r||It)}mapInner(e,n,r,o,i){let s;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,o);a&&a.type.valid(n,a)?(s||(s=[])).push(a):i.onRemove&&i.onRemove(this.local[l].spec)}return this.children.length?eg(this.children,s||[],e,n,r,o,i):s?new t(s.sort(Pt),rn):le}add(e,n){return n.length?this==le?t.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let o,i=0;e.forEach((l,a)=>{let c=a+r,u;if(u=mu(n,l,c)){for(o||(o=this.children.slice());i<o.length&&o[i]<a;)i+=3;o[i]==a?o[i+2]=o[i+2].addInner(l,u,c+1):o.splice(i,0,a,a+l.nodeSize,Br(u,l,c+1,It)),i+=3}});let s=pu(i?gu(n):n,-r);for(let l=0;l<s.length;l++)s[l].type.valid(e,s[l])||s.splice(l--,1);return new t(s.length?this.local.concat(s).sort(Pt):this.local,o||this.children)}remove(e){return e.length==0||this==le?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,o=this.local;for(let i=0;i<r.length;i+=3){let s,l=r[i]+n,a=r[i+1]+n;for(let u=0,d;u<e.length;u++)(d=e[u])&&d.from>l&&d.to<a&&(e[u]=null,(s||(s=[])).push(d));if(!s)continue;r==this.children&&(r=this.children.slice());let c=r[i+2].removeInner(s,l+1);c!=le?r[i+2]=c:(r.splice(i,3),i-=3)}if(o.length){for(let i=0,s;i<e.length;i++)if(s=e[i])for(let l=0;l<o.length;l++)o[l].eq(s,n)&&(o==this.local&&(o=this.local.slice()),o.splice(l--,1))}return r==this.children&&o==this.local?this:o.length||r.length?new t(o,r):le}forChild(e,n){if(this==le)return this;if(n.isLeaf)return t.empty;let r,o;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let i=e+1,s=i+n.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<s&&a.to>i&&a.type instanceof Dt){let c=Math.max(i,a.from)-i,u=Math.min(s,a.to)-i;c<u&&(o||(o=[])).push(a.copy(c,u))}}if(o){let l=new t(o.sort(Pt),rn);return r?new zr([l,r]):l}return r||le}eq(e){if(this==e)return!0;if(!(e instanceof t)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(e.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=e.children[n]||this.children[n+1]!=e.children[n+1]||!this.children[n+2].eq(e.children[n+2]))return!1;return!0}locals(e){return ps(this.localsInner(e))}localsInner(e){if(this==le)return rn;if(e.inlineContent||!this.local.some(Dt.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Dt||n.push(this.local[r]);return n}forEachSet(e){e(this)}};z.empty=new z([],[]);z.removeOverlap=ps;var le=z.empty,zr=class t{constructor(e){this.members=e}map(e,n){let r=this.members.map(o=>o.map(e,n,It));return t.from(r)}forChild(e,n){if(n.isLeaf)return z.empty;let r=[];for(let o=0;o<this.members.length;o++){let i=this.members[o].forChild(e,n);i!=le&&(i instanceof t?r=r.concat(i.members):r.push(i))}return t.from(r)}eq(e){if(!(e instanceof t)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let o=0;o<this.members.length;o++){let i=this.members[o].localsInner(e);if(i.length)if(!n)n=i;else{r&&(n=n.slice(),r=!1);for(let s=0;s<i.length;s++)n.push(i[s])}}return n?ps(r?n:n.sort(Pt)):rn}static from(e){switch(e.length){case 0:return le;case 1:return e[0];default:return new t(e.every(n=>n instanceof z)?e:e.reduce((n,r)=>n.concat(r instanceof z?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}};function eg(t,e,n,r,o,i,s){let l=t.slice();for(let c=0,u=i;c<n.maps.length;c++){let d=0;n.maps[c].forEach((f,h,p,m)=>{let g=m-p-(h-f);for(let y=0;y<l.length;y+=3){let S=l[y+1];if(S<0||f>S+u-d)continue;let k=l[y]+u-d;h>=k?l[y+1]=f<=k?-2:-1:f>=u&&g&&(l[y]+=g,l[y+1]+=g)}d+=g}),u=n.maps[c].map(u,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let u=n.map(t[c]+i),d=u-o;if(d<0||d>=r.content.size){a=!0;continue}let f=n.map(t[c+1]+i,-1),h=f-o,{index:p,offset:m}=r.content.findIndex(d),g=r.maybeChild(p);if(g&&m==d&&m+g.nodeSize==h){let y=l[c+2].mapInner(n,g,u+1,t[c]+i+1,s);y!=le?(l[c]=d,l[c+1]=h,l[c+2]=y):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=tg(l,t,e,n,o,i,s),u=Br(c,r,0,s);e=u.local;for(let d=0;d<l.length;d+=3)l[d+1]<0&&(l.splice(d,3),d-=3);for(let d=0,f=0;d<u.children.length;d+=3){let h=u.children[d];for(;f<l.length&&l[f]<h;)f+=3;l.splice(f,0,u.children[d],u.children[d+1],u.children[d+2])}}return new z(e.sort(Pt),l)}function pu(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let o=t[r];n.push(new ee(o.from+e,o.to+e,o.type))}return n}function tg(t,e,n,r,o,i,s){function l(a,c){for(let u=0;u<a.local.length;u++){let d=a.local[u].map(r,o,c);d?n.push(d):s.onRemove&&s.onRemove(a.local[u].spec)}for(let u=0;u<a.children.length;u+=3)l(a.children[u+2],a.children[u]+c+1)}for(let a=0;a<t.length;a+=3)t[a+1]==-1&&l(t[a+2],e[a]+i+1);return n}function mu(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,o=null;for(let i=0,s;i<t.length;i++)(s=t[i])&&s.from>n&&s.to<r&&((o||(o=[])).push(s),t[i]=null);return o}function gu(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function Br(t,e,n,r){let o=[],i=!1;e.forEach((l,a)=>{let c=mu(t,l,a+n);if(c){i=!0;let u=Br(c,l,n+a+1,r);u!=le&&o.push(a,a+l.nodeSize,u)}});let s=pu(i?gu(t):t,-n).sort(Pt);for(let l=0;l<s.length;l++)s[l].type.valid(e,s[l])||(r.onRemove&&r.onRemove(s[l].spec),s.splice(l--,1));return s.length||o.length?new z(s,o):le}function Pt(t,e){return t.from-e.from||t.to-e.to}function ps(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let o=n+1;o<e.length;o++){let i=e[o];if(i.from==r.from){i.to!=r.to&&(e==t&&(e=t.slice()),e[o]=i.copy(i.from,r.to),Nc(e,o+1,i.copy(r.to,i.to)));continue}else{i.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,i.from),Nc(e,o,r.copy(i.from,r.to)));break}}}return e}function Nc(t,e,n){for(;e<t.length&&Pt(n,t[e])>0;)e++;t.splice(e,0,n)}function Bi(t){let e=[];return t.someProp(\"decorations\",n=>{let r=n(t.state);r&&r!=le&&e.push(r)}),t.cursorWrapper&&e.push(z.create(t.state.doc,[t.cursorWrapper.deco])),zr.from(e)}var ng={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},rg=be&&ut<=11,is=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}},ss=class{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new is,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let o=0;o<r.length;o++)this.queue.push(r[o]);be&&ut<=11&&r.some(o=>o.type==\"childList\"&&o.removedNodes.length||o.type==\"characterData\"&&o.oldValue.length>o.target.nodeValue.length)?this.flushSoon():ce&&e.composing&&r.some(o=>o.type==\"childList\"&&o.target.nodeName==\"TR\")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),rg&&(this.onCharData=r=>{this.queue.push({target:r.target,type:\"characterData\",oldValue:r.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,ng)),this.onCharData&&this.view.dom.addEventListener(\"DOMCharacterDataModified\",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let n=0;n<e.length;n++)this.queue.push(e[n]);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(xc(this.view)){if(this.suppressingSelectionUpdates)return Xe(this.view);if(be&&ut<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Lt(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let i=e.focusNode;i;i=on(i))n.add(i);for(let i=e.anchorNode;i;i=on(i))if(n.has(i)){r=i;break}let o=r&&this.view.docView.nearestDesc(r);if(o&&o.ignoreMutation({type:\"selection\",target:Z(r)?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),o=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&xc(e)&&!this.ignoreSelectionChange(r),i=-1,s=-1,l=!1,a=[];if(e.editable)for(let u=0;u<n.length;u++){let d=this.registerMutation(n[u],a);d&&(i=i<0?d.from:Math.min(d.from,i),s=s<0?d.to:Math.max(d.to,s),d.typeOver&&(l=!0))}if(a.some(u=>u.nodeName==\"BR\")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46||oe&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&n.some(u=>u.type==\"childList\"&&u.removedNodes.length))){for(let u of a)if(u.nodeName==\"BR\"&&u.parentNode){let d=u.nextSibling;for(;d&&N(d);){if(d.contentEditable==\"false\"){u.parentNode.removeChild(u);break}d=d.firstChild}}}else if(we&&a.length){let u=a.filter(d=>d.nodeName==\"BR\");if(u.length==2){let[d,f]=u;d.parentNode&&d.parentNode.parentNode==f.parentNode?f.remove():d.remove()}else{let{focusNode:d}=this.currentSelection;for(let f of u){let h=f.parentNode;h&&h.nodeName==\"LI\"&&(!d||sg(e,d)!=h)&&f.remove()}}}let c=null;i<0&&o&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Fr(r)&&(c=as(e))&&c.eq(E.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Xe(e),this.currentSelection.set(r),e.scrollToSelection()):(i>-1||o)&&(i>-1&&(e.docView.markDirty(i,s),og(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,lg(e,a)),this.handleDOMChange(i,s,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Xe(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type==\"attributes\"&&(r==this.view.docView||e.attributeName==\"contenteditable\"||e.attributeName==\"style\"&&!e.oldValue&&!e.target.getAttribute(\"style\"))||!r||r.ignoreMutation(e))return null;if(e.type==\"childList\"){for(let u=0;u<e.addedNodes.length;u++){let d=e.addedNodes[u];n.push(d),Z(d)&&(this.lastChangedTextNode=d)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let o=e.previousSibling,i=e.nextSibling;if(be&&ut<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:d,nextSibling:f}=e.addedNodes[u];(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(o=d),(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(i=f)}let s=o&&o.parentNode==e.target?re(o)+1:0,l=r.localPosFromDOM(e.target,s,-1),a=i&&i.parentNode==e.target?re(i):e.target.childNodes.length,c=r.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type==\"attributes\"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}},Oc=new WeakMap,Rc=!1;function og(t){if(!Oc.has(t)&&(Oc.set(t,null),[\"normal\",\"nowrap\",\"pre-line\"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=we,Rc)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.\"),Rc=!0}}function Dc(t,e){let n=e.startContainer,r=e.startOffset,o=e.endContainer,i=e.endOffset,s=t.domAtPos(t.state.selection.anchor);return Lt(s.node,s.offset,o,i)&&([n,r,o,i]=[o,i,n,r]),{anchorNode:n,anchorOffset:r,focusNode:o,focusOffset:i}}function ig(t,e){if(e.getComposedRanges){let o=e.getComposedRanges(t.root)[0];if(o)return Dc(t,o)}let n;function r(o){o.preventDefault(),o.stopImmediatePropagation(),n=o.getTargetRanges()[0]}return t.dom.addEventListener(\"beforeinput\",r,!0),document.execCommand(\"indent\"),t.dom.removeEventListener(\"beforeinput\",r,!0),n?Dc(t,n):null}function sg(t,e){for(let n=e.parentNode;n&&n!=t.dom;n=n.parentNode){let r=t.docView.nearestDesc(n,!0);if(r&&r.node.isBlock)return n}return null}function lg(t,e){var n;let{focusNode:r,focusOffset:o}=t.domSelectionRange();for(let i of e)if(((n=i.parentNode)===null||n===void 0?void 0:n.nodeName)==\"TR\"){let s=i.nextSibling;for(;s&&s.nodeName!=\"TD\"&&s.nodeName!=\"TH\";)s=s.nextSibling;if(s){let l=s;for(;;){let a=l.firstChild;if(!a||!N(a)||a.contentEditable==\"false\"||/^(BR|IMG)$/.test(a.nodeName))break;l=a}l.insertBefore(i,l.firstChild),r==i&&t.domSelection().collapse(i,o)}else i.parentNode.removeChild(i)}}function ag(t,e,n,r){let{node:o,fromOffset:i,toOffset:s,from:l,to:a}=t.docView.parseRange(e,n),c=t.domSelectionRange(),u,d=c.anchorNode;if(d&&$t(t.dom,d)&&(u=[{node:d,offset:c.anchorOffset}],Fr(c)||u.push({node:c.focusNode,offset:c.focusOffset})),oe&&t.input.lastKeyCode===8)for(let y=s;y>i;y--){let S=o.childNodes[y-1],k=S.pmViewDesc;if(S.nodeName==\"BR\"&&!k){s=y;break}if(!k||k.size)break}let f=t.state.doc,h=t.someProp(\"domParser\")||je.fromSchema(t.state.schema),p=f.resolve(l),m=null,g=h.parse(o,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:s,preserveWhitespace:p.parent.type.whitespace==\"pre\"?\"full\":!0,findPositions:u,ruleFromNode:cg(r),context:p});if(u&&u[0].pos!=null){let y=u[0].pos,S=u[1]&&u[1].pos;S==null&&(S=y),m={anchor:y+l,head:S+l}}return{doc:g,sel:m,from:l,to:a}}var cg=t=>e=>{let n=e.pmViewDesc;if(n)return n.parseRule(t);if(e.nodeName==\"BR\"&&e.parentNode){if(ce&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let r=document.createElement(\"div\");return r.appendChild(document.createElement(\"li\")),{skip:r}}else if(e.parentNode.lastChild==e||ce&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName==\"IMG\"&&e.getAttribute(\"mark-placeholder\"))return{ignore:!0};return null},ug=/^(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 dg(t,e,n,r,o){let i=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let T=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,I=as(t,T);if(I&&!t.state.selection.eq(I)){if(oe&&qe&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp(\"handleKeyDown\",W=>W(t,Tt(13,\"Enter\"))))return;let F=t.state.tr.setSelection(I);T==\"pointer\"?F.setMeta(\"pointer\",!0):T==\"key\"&&F.scrollIntoView(),i&&F.setMeta(\"composition\",i),t.dispatch(F)}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=t.state.selection,c=ag(t,e,n,o),u=t.state.doc,d=u.slice(c.from,c.to),f,h;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(f=t.state.selection.to,h=\"end\"):(f=t.state.selection.from,h=\"start\"),t.input.lastKeyCode=null;let p=mg(d.content,c.doc.content,c.from,f,h);if(p&&t.input.domChangeCount++,(sn&&t.input.lastIOSEnter>Date.now()-225||qe)&&o.some(T=>N(T)&&!ug.test(T.nodeName))&&(!p||p.endA>=p.endB)&&t.someProp(\"handleKeyDown\",T=>T(t,Tt(13,\"Enter\")))){t.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof M&&!a.empty&&a.$head.sameParent(a.$anchor)&&!t.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let T=Ic(t,t.state.doc,c.sel);if(T&&!T.eq(t.state.selection)){let I=t.state.tr.setSelection(T);i&&I.setMeta(\"composition\",i),t.dispatch(I)}}return}t.state.selection.from<t.state.selection.to&&p.start==p.endB&&t.state.selection instanceof M&&(p.start>t.state.selection.from&&p.start<=t.state.selection.from+2&&t.state.selection.from>=c.from?p.start=t.state.selection.from:p.endA<t.state.selection.to&&p.endA>=t.state.selection.to-2&&t.state.selection.to<=c.to&&(p.endB+=t.state.selection.to-p.endA,p.endA=t.state.selection.to)),be&&ut<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)==\" \\xA0\"&&(p.start--,p.endA--,p.endB--);let m=c.doc.resolveNoCache(p.start-c.from),g=c.doc.resolveNoCache(p.endB-c.from),y=u.resolve(p.start),S=m.sameParent(g)&&m.parent.inlineContent&&y.end()>=p.endA;if((sn&&t.input.lastIOSEnter>Date.now()-225&&(!S||o.some(T=>T.nodeName==\"DIV\"||T.nodeName==\"P\"))||!S&&pg(c.doc,m.pos,g.pos))&&t.someProp(\"handleKeyDown\",T=>T(t,Tt(13,\"Enter\")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>p.start&&hg(u,p.start,p.endA,m,g)&&t.someProp(\"handleKeyDown\",T=>T(t,Tt(8,\"Backspace\")))){qe&&oe&&t.domObserver.suppressSelectionUpdates();return}oe&&p.endB==p.start&&(t.input.lastChromeDelete=Date.now()),qe&&!S&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,g=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{t.someProp(\"handleKeyDown\",function(T){return T(t,Tt(13,\"Enter\"))})},20));let k=p.start,x=p.endA,O=T=>{let I=T||t.state.tr.replace(k,x,c.doc.slice(p.start-c.from,p.endB-c.from));if(c.sel){let F=Ic(t,I.doc,c.sel);F&&!(oe&&t.composing&&F.empty&&(p.start!=p.endB||t.input.lastChromeDelete<Date.now()-100)&&(F.head==k||F.head==I.mapping.map(x)-1)||be&&F.empty&&F.head==k)&&I.setSelection(F)}return i&&I.setMeta(\"composition\",i),I.scrollIntoView()},H;if(S)if(m.pos==g.pos){be&&ut<=11&&m.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>Xe(t),20));let T=O(t.state.tr.delete(k,x)),I=u.resolve(p.start).marksAcross(u.resolve(p.endA));I&&T.ensureMarks(I),t.dispatch(T)}else if(p.endA==p.endB&&(H=fg(m.parent.content.cut(m.parentOffset,g.parentOffset),y.parent.content.cut(y.parentOffset,p.endA-y.start())))){let T=O(t.state.tr);H.type==\"add\"?T.addMark(k,x,H.mark):T.removeMark(k,x,H.mark),t.dispatch(T)}else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let T=m.parent.textBetween(m.parentOffset,g.parentOffset),I=()=>O(t.state.tr.insertText(T,k,x));t.someProp(\"handleTextInput\",F=>F(t,k,x,T,I))||t.dispatch(I())}else t.dispatch(O());else t.dispatch(O())}function Ic(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:cs(t,e.resolve(n.anchor),e.resolve(n.head))}function fg(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,o=n,i=r,s,l,a;for(let u=0;u<r.length;u++)o=r[u].removeFromSet(o);for(let u=0;u<n.length;u++)i=n[u].removeFromSet(i);if(o.length==1&&i.length==0)l=o[0],s=\"add\",a=u=>u.mark(l.addToSet(u.marks));else if(o.length==0&&i.length==1)l=i[0],s=\"remove\",a=u=>u.mark(l.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<e.childCount;u++)c.push(a(e.child(u)));if(b.from(c).eq(t))return{mark:l,type:s}}function hg(t,e,n,r,o){if(n-e<=o.pos-r.pos||Fi(r,!0,!1)<o.pos)return!1;let i=t.resolve(e);if(!r.parent.isTextblock){let l=i.nodeAfter;return l!=null&&n==e+l.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let s=t.resolve(Fi(i,!0,!0));return!s.parent.isTextblock||s.pos>n||Fi(s,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(s.parent.content)}function pg(t,e,n){let r=0,o=0;return t.nodesBetween(e,n,(i,s)=>{i.isTextblock&&s>=e&&s<n?r++:(i.isText?/\\S/.test(i.text.slice(Math.max(0,e-s),Math.min(i.nodeSize,n-s))):i.isLeaf)&&o++}),o==0&&r==1}function Fi(t,e,n){let r=t.depth,o=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,o++,e=!1;if(n){let i=t.node(r).maybeChild(t.indexAfter(r));for(;i&&!i.isLeaf;)i=i.firstChild,o++}return o}function mg(t,e,n,r,o){let i=t.findDiffStart(e,n),s=n+t.size,l=n+e.size;if(i==null)return null;let{a,b:c}=t.findDiffEnd(e,s,l);if(o==\"end\"){let u=Math.max(0,i-Math.min(a,c));r-=a+u-i}if(a<i&&s<l){let u=r<=i&&r>=a?i-r:0;i-=u,c=i+(c-a),a=i}else if(c<i){let u=r<=i&&r>=c?i-r:0;i-=u,a=i+(a-c),c=i}return{start:i,endA:a,endB:c}}var _n=class{constructor(e,n){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 Zi,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(Bc),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement(\"div\"),e&&(e.appendChild?e.appendChild(this.dom):typeof e==\"function\"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=$c(this),Lc(this),this.nodeViews=zc(this),this.docView=gc(this.state.doc,Pc(this),Bi(this),this.dom,this),this.domObserver=new ss(this,(r,o,i,s)=>dg(this,r,o,i,s)),this.domObserver.start(),Lm(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&es(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Bc),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let o=this.state,i=!1,s=!1;e.storedMarks&&this.composing&&(du(this),s=!0),this.state=e;let l=o.plugins!=e.plugins||this._props.plugins!=n.plugins;if(l||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let h=zc(this);yg(h,this.nodeViews)&&(this.nodeViews=h,i=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&es(this),this.editable=$c(this),Lc(this);let a=Bi(this),c=Pc(this),u=o.plugins!=e.plugins&&!o.doc.eq(e.doc)?\"reset\":e.scrollToSelection>o.scrollToSelection?\"to selection\":\"preserve\",d=i||!this.docView.matchesNode(e.doc,c,a);(d||!e.selection.eq(o.selection))&&(s=!0);let f=u==\"preserve\"&&s&&this.dom.style.overflowAnchor==null&&Zp(this);if(s){this.domObserver.stop();let h=d&&(be||oe)&&!this.composing&&!o.selection.empty&&!e.selection.empty&&gg(o.selection,e.selection);if(d){let m=oe?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=qm(this)),(i||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=gc(e.doc,c,a,this.dom,this)),m&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(h=!0)}let p=this.input.mouseDown;h||!(p&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&wm(this)&&p.delaySelUpdate())?Xe(this,h):(Qc(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(o),!((r=this.dragging)===null||r===void 0)&&r.node&&!o.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,o),u==\"reset\"?this.dom.scrollTop=0:u==\"to selection\"?this.scrollToSelection():f&&em(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!$t(this.dom,e))){if(!this.someProp(\"handleScrollToSelection\",n=>n(this)))if(this.state.selection instanceof A){let n=this.docView.domAfterPos(this.state.selection.from);N(n)&&dc(this,n.getBoundingClientRect(),e)}else dc(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n<this.directPlugins.length;n++){let r=this.directPlugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let r=this.state.plugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let r=this.pluginViews[n];r.update&&r.update(this,e)}}updateDraggedNode(e,n){let r=e.node,o=-1;if(r.from<this.state.doc.content.size&&this.state.doc.nodeAt(r.from)==r.node)o=r.from;else{let i=r.from+(this.state.doc.content.size-n.doc.content.size);(i>0&&i<this.state.doc.content.size&&this.state.doc.nodeAt(i))==r.node&&(o=i)}this.dragging=new Lr(e.slice,e.move,o<0?void 0:A.create(this.state.doc,o))}someProp(e,n){let r=this._props&&this._props[e],o;if(r!=null&&(o=n?n(r):r))return o;for(let s=0;s<this.directPlugins.length;s++){let l=this.directPlugins[s].props[e];if(l!=null&&(o=n?n(l):l))return o}let i=this.state.plugins;if(i)for(let s=0;s<i.length;s++){let l=i[s].props[e];if(l!=null&&(o=n?n(l):l))return o}}hasFocus(){if(be){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable==\"false\")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&tm(this.dom),Xe(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let n=this.dom.parentNode;n;n=n.parentNode)if(n.nodeType==9||n.nodeType==11&&n.host)return n.getSelection||(Object.getPrototypeOf(n).getSelection=()=>n.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return sm(this,e)}coordsAtPos(e,n=1){return Uc(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let o=this.docView.posFromDOM(e,n,r);if(o==null)throw new RangeError(\"DOM position not inside the editor\");return o}endOfTextblock(e,n){return dm(this,n||this.state,e)}pasteHTML(e,n){return Wn(this,\"\",e,!1,n||new ClipboardEvent(\"paste\"))}pasteText(e,n){return Wn(this,e,null,!0,n||new ClipboardEvent(\"paste\"))}serializeForClipboard(e){return us(this,e)}destroy(){this.docView&&($m(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Bi(this),this),this.dom.textContent=\"\"):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Vp())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Bm(this,e)}domSelectionRange(){let e=this.dom.isConnected!==!1&&this.domSelection();return e?ce&&this.root.nodeType===11&&qp(this.dom.ownerDocument)==this.dom&&ig(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};_n.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function Pc(t){let e=Object.create(null);return e.class=\"ProseMirror\",e.contenteditable=String(t.editable),t.someProp(\"attributes\",n=>{if(typeof n==\"function\"&&(n=n(t.state)),n)for(let r in n)r==\"class\"?e.class+=\" \"+n[r]:r==\"style\"?e.style=(e.style?e.style+\";\":\"\")+n[r]:!e[r]&&r!=\"contenteditable\"&&r!=\"nodeName\"&&(e[r]=String(n[r]))}),e.translate||(e.translate=\"no\"),[ee.node(0,t.state.doc.content.size,e)]}function Lc(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:ee.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function $c(t){return!t.someProp(\"editable\",e=>e(t.state)===!1)}function gg(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)}function zc(t){let e=Object.create(null);function n(r){for(let o in r)Object.prototype.hasOwnProperty.call(e,o)||(e[o]=r[o])}return t.someProp(\"nodeViews\",n),t.someProp(\"markViews\",n),e}function yg(t,e){let n=0,r=0;for(let o in t){if(t[o]!=e[o])return!0;n++}for(let o in e)r++;return n!=r}function Bc(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\")}var Ye={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:\"'\"},Wr={48:\")\",49:\"!\",50:\"@\",51:\"#\",52:\"$\",53:\"%\",54:\"^\",55:\"&\",56:\"*\",57:\"(\",59:\":\",61:\"+\",173:\"_\",186:\":\",187:\"+\",188:\"<\",189:\"_\",190:\">\",191:\"?\",192:\"~\",219:\"{\",220:\"|\",221:\"}\",222:'\"'},bg=typeof navigator<\"u\"&&/Mac/.test(navigator.platform),kg=typeof navigator<\"u\"&&/MSIE \\d|Trident\\/(?:[7-9]|\\d{2,})\\..*rv:(\\d+)/.exec(navigator.userAgent);for(Y=0;Y<10;Y++)Ye[48+Y]=Ye[96+Y]=String(Y);var Y;for(Y=1;Y<=24;Y++)Ye[Y+111]=\"F\"+Y;var Y;for(Y=65;Y<=90;Y++)Ye[Y]=String.fromCharCode(Y+32),Wr[Y]=String.fromCharCode(Y);var Y;for(jr in Ye)Wr.hasOwnProperty(jr)||(Wr[jr]=Ye[jr]);var jr;function yu(t){var e=bg&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||kg&&t.shiftKey&&t.key&&t.key.length==1||t.key==\"Unidentified\",n=!e&&t.key||(t.shiftKey?Wr:Ye)[t.keyCode]||t.key||\"Unidentified\";return n==\"Esc\"&&(n=\"Escape\"),n==\"Del\"&&(n=\"Delete\"),n==\"Left\"&&(n=\"ArrowLeft\"),n==\"Up\"&&(n=\"ArrowUp\"),n==\"Right\"&&(n=\"ArrowRight\"),n==\"Down\"&&(n=\"ArrowDown\"),n}var wg=typeof navigator<\"u\"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Sg=typeof navigator<\"u\"&&/Win/.test(navigator.platform);function xg(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n==\"Space\"&&(n=\" \");let r,o,i,s;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))s=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))o=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))wg?s=!0:o=!0;else throw new Error(\"Unrecognized modifier name: \"+a)}return r&&(n=\"Alt-\"+n),o&&(n=\"Ctrl-\"+n),s&&(n=\"Meta-\"+n),i&&(n=\"Shift-\"+n),n}function Cg(t){let e=Object.create(null);for(let n in t)e[xg(n)]=t[n];return e}function ms(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 bu(t){return new R({props:{handleKeyDown:qn(t)}})}function qn(t){let e=Cg(t);return function(n,r){let o=yu(r),i,s=e[ms(o,r)];if(s&&s(n.state,n.dispatch,n))return!0;if(o.length==1&&o!=\" \"){if(r.shiftKey){let l=e[ms(o,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(Sg&&r.ctrlKey&&r.altKey)&&(i=Ye[r.keyCode])&&i!=o){let l=e[ms(i,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var Vr=200,ie=function(){};ie.prototype.append=function(e){return e.length?(e=ie.from(e),!this.length&&e||e.length<Vr&&this.leafAppend(e)||this.length<Vr&&e.leafPrepend(this)||this.appendInner(e)):this};ie.prototype.prepend=function(e){return e.length?ie.from(e).append(this):this};ie.prototype.appendInner=function(e){return new Mg(this,e)};ie.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?ie.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};ie.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};ie.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)};ie.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var o=[];return this.forEach(function(i,s){return o.push(e(i,s))},n,r),o};ie.from=function(e){return e instanceof ie?e:e&&e.length?new ku(e):ie.empty};var ku=(function(t){function e(r){t.call(this),this.values=r}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(o,i){return o==0&&i==this.length?this:new e(this.values.slice(o,i))},e.prototype.getInner=function(o){return this.values[o]},e.prototype.forEachInner=function(o,i,s,l){for(var a=i;a<s;a++)if(o(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(o,i,s,l){for(var a=i-1;a>=s;a--)if(o(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(o){if(this.length+o.length<=Vr)return new e(this.values.concat(o.flatten()))},e.prototype.leafPrepend=function(o){if(this.length+o.length<=Vr)return new e(o.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(ie);ie.empty=new ku([]);var Mg=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.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(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,o,i,s){var l=this.left.length;if(o<l&&this.left.forEachInner(r,o,Math.min(i,l),s)===!1||i>l&&this.right.forEachInner(r,Math.max(o-l,0),Math.min(this.length,i)-l,s+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,o,i,s){var l=this.left.length;if(o>l&&this.right.forEachInvertedInner(r,o-l,Math.max(i,l)-l,s+l)===!1||i<l&&this.left.forEachInvertedInner(r,Math.min(o,l),i,s)===!1)return!1},e.prototype.sliceInner=function(r,o){if(r==0&&o==this.length)return this;var i=this.left.length;return o<=i?this.left.slice(r,o):r>=i?this.right.slice(r-i,o-i):this.left.slice(r,i).append(this.right.slice(0,o-i))},e.prototype.leafAppend=function(r){var o=this.right.leafAppend(r);if(o)return new e(this.left,o)},e.prototype.leafPrepend=function(r){var o=this.left.leafPrepend(r);if(o)return new e(o,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(ie),gs=ie;var vg=500,Bt=class t{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let o,i;n&&(o=this.remapping(r,this.items.length),i=o.maps.length);let s=e.tr,l,a,c=[],u=[];return this.items.forEach((d,f)=>{if(!d.step){o||(o=this.remapping(r,f+1),i=o.maps.length),i--,u.push(d);return}if(o){u.push(new Pe(d.map));let h=d.step.map(o.slice(i)),p;h&&s.maybeStep(h).doc&&(p=s.mapping.maps[s.mapping.maps.length-1],c.push(new Pe(p,void 0,void 0,c.length+u.length))),i--,p&&o.appendMap(p,i)}else s.maybeStep(d.step);if(d.selection)return l=o?d.selection.map(o.slice(i)):d.selection,a=new t(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:s,selection:l}}addTransform(e,n,r,o){let i=[],s=this.eventCount,l=this.items,a=!o&&l.length?l.get(l.length-1):null;for(let u=0;u<e.steps.length;u++){let d=e.steps[u].invert(e.docs[u]),f=new Pe(e.mapping.maps[u],d,n),h;(h=a&&a.merge(f))&&(f=h,u?i.pop():l=l.slice(0,l.length-1)),i.push(f),n&&(s++,n=void 0),o||(a=f)}let c=s-r.depth;return c>Ag&&(l=Eg(l,c),s-=c),new t(l.append(i),s)}remapping(e,n){let r=new Dn;return this.items.forEach((o,i)=>{let s=o.mirrorOffset!=null&&i-o.mirrorOffset>=e?r.maps.length-o.mirrorOffset:void 0;r.appendMap(o.map,s)},e,n),r}addMaps(e){return this.eventCount==0?this:new t(this.items.append(e.map(n=>new Pe(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;n=Math.min(this.items.length,n);let r=[],o=this.items.length-n,i=e.mapping,s=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},o);let a=n;this.items.forEach(f=>{let h=i.getMirror(--a);if(h==null)return;s=Math.min(s,h);let p=i.maps[h];if(f.step){let m=e.steps[h].invert(e.docs[h]),g=f.selection&&f.selection.map(i.slice(a+1,h));g&&l++,r.push(new Pe(p,m,g))}else r.push(new Pe(p))},o);let c=[];for(let f=n;f<s;f++)c.push(new Pe(i.maps[f]));let u=this.items.slice(0,o).append(c).append(r),d=new t(u,l);return d.emptyItemCount()>vg&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,o=[],i=0;return this.items.forEach((s,l)=>{if(l>=e)o.push(s),s.selection&&i++;else if(s.step){let a=s.step.map(n.slice(r)),c=a&&a.getMap();if(r--,c&&n.appendMap(c,r),a){let u=s.selection&&s.selection.map(n.slice(r));u&&i++;let d=new Pe(c.invert(),a,u),f,h=o.length-1;(f=o.length&&o[h].merge(d))?o[h]=f:o.push(d)}}else s.map&&r--},this.items.length,0),new t(gs.from(o.reverse()),i)}};Bt.empty=new Bt(gs.empty,0);function Eg(t,e){let n;return t.forEach((r,o)=>{if(r.selection&&e--==0)return n=o,!1}),t.slice(n)}var Pe=class t{constructor(e,n,r,o){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=o}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new t(n.getMap().invert(),n,this.selection)}}},Le=class{constructor(e,n,r,o,i){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=o,this.prevComposition=i}},Ag=20;function Tg(t,e,n,r){let o=n.getMeta(ht),i;if(o)return o.historyState;n.getMeta(Cu)&&(t=new Le(t.done,t.undone,null,0,-1));let s=n.getMeta(\"appendedTransaction\");if(n.steps.length==0)return t;if(s&&s.getMeta(ht))return s.getMeta(ht).redo?new Le(t.done.addTransform(n,void 0,r,_r(e)),t.undone,wu(n.mapping.maps),t.prevTime,t.prevComposition):new Le(t.done,t.undone.addTransform(n,void 0,r,_r(e)),null,t.prevTime,t.prevComposition);if(n.getMeta(\"addToHistory\")!==!1&&!(s&&s.getMeta(\"addToHistory\")===!1)){let l=n.getMeta(\"composition\"),a=t.prevTime==0||!s&&t.prevComposition!=l&&(t.prevTime<(n.time||0)-r.newGroupDelay||!Ng(n,t.prevRanges)),c=s?ys(t.prevRanges,n.mapping):wu(n.mapping.maps);return new Le(t.done.addTransform(n,a?e.selection.getBookmark():void 0,r,_r(e)),Bt.empty,c,n.time,l??t.prevComposition)}else return(i=n.getMeta(\"rebased\"))?new Le(t.done.rebased(n,i),t.undone.rebased(n,i),ys(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Le(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),ys(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function Ng(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,o)=>{for(let i=0;i<e.length;i+=2)r<=e[i+1]&&o>=e[i]&&(n=!0)}),n}function wu(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,o,i,s)=>e.push(i,s));return e}function ys(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let o=e.map(t[r],1),i=e.map(t[r+1],-1);o<=i&&n.push(o,i)}return n}function Og(t,e,n){let r=_r(e),o=ht.get(e).spec.config,i=(n?t.undone:t.done).popEvent(e,r);if(!i)return null;let s=i.selection.resolve(i.transform.doc),l=(n?t.done:t.undone).addTransform(i.transform,e.selection.getBookmark(),o,r),a=new Le(n?l:i.remaining,n?i.remaining:l,null,0,-1);return i.transform.setSelection(s).setMeta(ht,{redo:n,historyState:a})}var bs=!1,Su=null;function _r(t){let e=t.plugins;if(Su!=e){bs=!1,Su=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){bs=!0;break}}return bs}function xu(t){return t.setMeta(Cu,!0)}var ht=new P(\"history\"),Cu=new P(\"closeHistory\");function Mu(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new R({key:ht,state:{init(){return new Le(Bt.empty,Bt.empty,null,0,-1)},apply(e,n,r){return Tg(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,o=r==\"historyUndo\"?ks:r==\"historyRedo\"?ws:null;return!o||!e.editable?!1:(n.preventDefault(),o(e.state,e.dispatch))}}}})}function Kr(t,e){return(n,r)=>{let o=ht.getState(n);if(!o||(t?o.undone:o.done).eventCount==0)return!1;if(r){let i=Og(o,n,t);i&&r(e?i.scrollIntoView():i)}return!0}}var ks=Kr(!1,!0),ws=Kr(!0,!0),IS=Kr(!1,!1),PS=Kr(!0,!1);function vu(t){return t.getMeta(ht)!=null}function eo(t){let{state:e,transaction:n}=t,{selection:r}=n,{doc:o}=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 r},get doc(){return o},get tr(){return r=n.selection,o=n.doc,i=n.storedMarks,n}}}var dn=class Uu{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){let{rawCommands:e,editor:n,state:r}=this,{view:o}=n,{tr:i}=r,s=this.buildProps(i);return Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...u)=>{let d=a(...u)(s);return!i.getMeta(\"preventDispatch\")&&!this.hasCustomState&&o.dispatch(i),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,n=!0){let{rawCommands:r,editor:o,state:i}=this,{view:s}=o,l=[],a=!!e,c=e||i.tr,u=()=>(!a&&n&&!c.getMeta(\"preventDispatch\")&&!this.hasCustomState&&s.dispatch(c),l.every(f=>f===!0)),d={...Object.fromEntries(Object.entries(r).map(([f,h])=>[f,(...m)=>{let g=this.buildProps(c,n),y=h(...m)(g);return l.push(y),d}])),run:u};return d}static createFakeChain(){let e=new Proxy({},{get:(n,r)=>{if(r!==\"then\")return r===\"run\"?()=>!1:()=>e}});return e}createCan(e){let{rawCommands:n,state:r}=this,o=!1,i=e||r.tr,s=this.buildProps(i,o);return{...Object.fromEntries(Object.entries(n).map(([l,a])=>[l,(...c)=>a(...c)({...s,dispatch:void 0})])),chain:()=>this.createChain(i,o)}}static createFallbackCan(){let e=Uu.createFakeChain();return new Proxy({chain:()=>e},{get:(n,r)=>{if(r!==\"then\")return r===\"chain\"?n.chain:()=>!1}})}buildProps(e,n=!0){let{rawCommands:r,editor:o,state:i}=this,{view:s}=o,l={tr:e,editor:o,view:s,state:eo({state:i,transaction:e}),dispatch:n?()=>{}:void 0,chain:()=>this.createChain(e,n),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(r).map(([a,c])=>[a,(...u)=>c(...u)(l)]))}};return l}},Rg=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{if(!t.isDestroyed){var n;e.dom.blur(),(n=window)===null||n===void 0||(n=n.getSelection())===null||n===void 0||n.removeAllRanges()}}),!0),Dg=(t=!0)=>({commands:e})=>e.setContent(\"\",{emitUpdate:t}),Ig=()=>({state:t,tr:e,dispatch:n})=>{let{selection:r}=e,{ranges:o}=r;return n&&o.forEach(({$from:i,$to:s})=>{t.doc.nodesBetween(i.pos,s.pos,(l,a)=>{if(l.type.isText)return;let{doc:c,mapping:u}=e,d=c.resolve(u.map(a)),f=c.resolve(u.map(a+l.nodeSize)),h=d.blockRange(f);if(!h)return;let p=Ke(h);if(l.type.isTextblock){let{defaultType:m}=d.parent.contentMatchAt(d.index());e.setNodeMarkup(h.start,m)}(p||p===0)&&e.lift(h,p)})}),!0},Pg=t=>e=>t(e),Lg=()=>({state:t,dispatch:e})=>Oi(t,e),$g=(t,e)=>({editor:n,tr:r})=>{let{state:o}=n,i=o.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);let s=r.mapping.map(e);return r.insert(s,i.content),r.setSelection(new M(r.doc.resolve(Math.max(s-1,0)))),!0},zg=()=>({tr:t,dispatch:e})=>{let{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;let o=t.selection.$anchor;for(let i=o.depth;i>0;i-=1)if(o.node(i).type===r.type){if(e){let s=o.before(i),l=o.after(i);t.delete(s,l).scrollIntoView()}return!0}return!1};function Q(t,e){if(typeof t==\"string\"){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 Bg=t=>({tr:e,state:n,dispatch:r})=>{let o=Q(t,n.schema),i=e.selection.$anchor;for(let s=i.depth;s>0;s-=1)if(i.node(s).type===o){if(r){let l=i.before(s),a=i.after(s);e.delete(l,a).scrollIntoView()}return!0}return!1},Fg=t=>({tr:e,dispatch:n})=>{let{from:r,to:o}=t;return n&&e.delete(r,o),!0},Hg=t=>t.content?/^text(\\*|\\+)/.test(t.content):!1,Eu=(t,e,n)=>{if(!t.parent.isInline||n===\"left\"&&t.pos>t.start()||n===\"right\"&&t.pos<t.end())return t.pos;let r=e.nodes[t.parent.type.name].spec;return Hg(r)?n===\"left\"?t.start()-1:t.end()+1:t.pos},jg=(t,e,n)=>({from:Eu(t,n,\"left\"),to:Eu(e,n,\"right\")}),Wg=()=>({state:t,dispatch:e})=>{if(t.selection.empty)return!1;if(e){let n=t.tr,{ranges:r}=t.selection,o=t.selection instanceof M?t.selection.$from.marksAcross(t.selection.$to):null,i=n.steps.length;r.forEach(s=>{let l=n.mapping.slice(i),a=n.doc.resolve(l.map(s.$from.pos)),c=n.doc.resolve(l.map(s.$to.pos)),{from:u,to:d}=jg(a,c,t.schema);n.deleteRange(u,d)}),n.selection.empty||n.setSelection(M.near(n.doc.resolve(n.selection.from))),o&&n.ensureMarks(o),n.scrollIntoView(),e(n)}return!0},Vg=()=>({commands:t})=>t.keyboardShortcut(\"Enter\"),_g=()=>({state:t,dispatch:e})=>Ni(t,e);function vs(t){return Object.prototype.toString.call(t)===\"[object RegExp]\"}function Qr(t,e,n={strict:!0}){let r=Object.keys(e);return r.length?r.every(o=>n.strict?e[o]===t[o]:vs(e[o])?e[o].test(t[o]):e[o]===t[o]):!0}function Ju(t,e,n={}){return t.find(r=>r.type===e&&Qr(Object.fromEntries(Object.keys(n).map(o=>[o,r.attrs[o]])),n))}function Au(t,e,n={}){return!!Ju(t,e,n)}function Es(t,e,n){if(!t||!e)return;let r=t.parent.childAfter(t.parentOffset);if((!r.node||!r.node.marks.some(a=>a.type===e))&&(r=t.parent.childBefore(t.parentOffset)),!r.node||!r.node.marks.some(a=>a.type===e))return;if(!n){let a=r.node.marks.find(c=>c.type===e);a&&(n=a.attrs)}if(!Ju([...r.node.marks],e,n))return;let o=r.index,i=t.start()+r.offset,s=o+1,l=i+r.node.nodeSize;for(;o>0&&Au([...t.parent.child(o-1).marks],e,n);)o-=1,i-=t.parent.child(o).nodeSize;for(;s<t.parent.childCount&&Au([...t.parent.child(s).marks],e,n);)l+=t.parent.child(s).nodeSize,s+=1;return{from:i,to:l}}function Qe(t,e){if(typeof t==\"string\"){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 Kg=(t,e)=>({tr:n,state:r,dispatch:o})=>{let i=Qe(t,r.schema),{doc:s,selection:l}=n,{$from:a,from:c,to:u}=l;if(o){let d=Es(a,i,e);if(d&&d.from<=c&&d.to>=u){let f=M.create(s,d.from,d.to);n.setSelection(f)}}return!0},Ug=t=>e=>{let n=typeof t==\"function\"?t(e):t;for(let r=0;r<n.length;r+=1)if(n[r](e))return!0;return!1};function qu(t){return t instanceof M}function Ft(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function Ss(t,e=null){if(!e)return null;let n=E.atStart(t),r=E.atEnd(t);if(e===\"start\"||e===!0)return n;if(e===\"end\")return r;let o=n.from,i=r.to;return e===\"all\"?M.create(t,Ft(0,o,i),Ft(t.content.size,o,i)):M.create(t,Ft(e,o,i),Ft(e,o,i))}function Tu(){return[\"Android\"].includes(navigator.platform)||/android/i.test(navigator.userAgent)}function Zr(){return[\"iPad Simulator\",\"iPhone Simulator\",\"iPod Simulator\",\"iPad\",\"iPhone\",\"iPod\"].includes(navigator.platform)||navigator.userAgent.includes(\"Mac\")&&\"ontouchend\"in document}function Jg(){return typeof navigator<\"u\"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var qg=(t=null,e={})=>({editor:n,view:r,tr:o,dispatch:i})=>{e={scrollIntoView:!0,...e};let s=()=>{(Zr()||Tu())&&r.dom.focus(),Jg()&&!Zr()&&!Tu()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e?.scrollIntoView&&n.commands.scrollIntoView())})};try{if(r.hasFocus()&&t===null||t===!1)return!0}catch{return!1}if(i&&t===null&&!qu(n.state.selection))return s(),!0;let l=Ss(o.doc,t)||n.state.selection,a=n.state.selection.eq(l);return i&&(a||o.setSelection(l),a&&o.storedMarks&&o.setStoredMarks(o.storedMarks),s()),!0},Gg=(t,e)=>n=>t.every((r,o)=>e(r,{...n,index:o})),Xg=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),Gu=t=>{let e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){let r=e[n];r.nodeType===3&&r.nodeValue&&/^(\\n\\s\\s|\\n)$/.test(r.nodeValue)?t.removeChild(r):r.nodeType===1&&Gu(r)}return t};function Ur(t){if(typeof window>\"u\")throw new Error(\"[tiptap error]: there is no window object available, so this function cannot be used\");let e=`<body>${t}</body>`,n=new window.DOMParser().parseFromString(e,\"text/html\").body;return Gu(n)}function Xu(t){return typeof t?.nodesBetween==\"function\"}function fn(t,e,n){if(Xu(t))return t;let r=typeof t==\"object\"&&t!==null;n={slice:!0,parseOptions:{},...n};let o=typeof t==\"string\";if(r)try{if(Array.isArray(t)&&t.length>0)return b.fromArray(t.map(s=>e.nodeFromJSON(s)));let i=e.nodeFromJSON(t);return n.errorOnInvalidContent&&i.check(),i}catch(i){if(n.errorOnInvalidContent)throw new Error(\"[tiptap error]: Invalid JSON content\",{cause:i});return console.warn(\"[tiptap warn]: Invalid content.\",\"Passed value:\",t,\"Error:\",i),fn(\"\",e,n)}if(o){if(n.errorOnInvalidContent){let s=!1,l=\"\",a=new vt({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:c=>(s=!0,l=typeof c==\"string\"?c:c.outerHTML,null)}]}})});if(n.slice?je.fromSchema(a).parseSlice(Ur(t),n.parseOptions):je.fromSchema(a).parse(Ur(t),n.parseOptions),n.errorOnInvalidContent&&s)throw new Error(\"[tiptap error]: Invalid HTML content\",{cause:new Error(`Invalid element found: ${l}`)})}let i=je.fromSchema(e);return n.slice?i.parseSlice(Ur(t),n.parseOptions).content:i.parse(Ur(t),n.parseOptions)}return fn(\"\",e,n)}function Yu(t){return!(\"type\"in t)}function Qu(t,e,n){let r=t.steps.length-1;if(r<e)return;let o=t.steps[r];if(!(o instanceof G||o instanceof X))return;let i=t.mapping.maps[r],s=0;i.forEach((l,a,c,u)=>{s===0&&(s=u)}),t.setSelection(E.near(t.doc.resolve(s),n))}var Yg=(t,e,n)=>({tr:r,dispatch:o,editor:i})=>{if(o){n={parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let l,a=g=>{i.emit(\"contentError\",{editor:i,error:g,disableCollaboration:()=>{\"collaboration\"in i.storage&&typeof i.storage.collaboration==\"object\"&&i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:\"full\",...n.parseOptions};if(!n.errorOnInvalidContent&&!i.options.enableContentCheck&&i.options.emitContentError)try{fn(e,i.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(g){a(g)}try{var s;l=fn(e,i.schema,{parseOptions:c,errorOnInvalidContent:(s=n.errorOnInvalidContent)!==null&&s!==void 0?s:i.options.enableContentCheck})}catch(g){return a(g),!1}let{from:u,to:d}=typeof t==\"number\"?{from:t,to:t}:{from:t.from,to:t.to},f=!0,h=!0,p=Yu(l)?l.content:[l];if(p.forEach(g=>{g.check(),f=f?g.isText&&g.marks.length===0:!1,h=h?g.isBlock:!1}),u===d&&h){let{parent:g}=r.doc.resolve(u);g.isTextblock&&!g.type.spec.code&&!g.childCount&&(u-=1,d+=1)}let m;if(f)Array.isArray(e)?m=e.map(g=>g.text||\"\").join(\"\"):Xu(e)?m=p.map(g=>{var y;return(y=g.text)!==null&&y!==void 0?y:\"\"}).join(\"\"):typeof e==\"object\"&&e&&e.text?m=e.text:m=e,r.insertText(m,u,d);else{m=b.from(p);let g=r.doc.resolve(u),y=g.node(),S=g.parentOffset===0,k=y.isText||y.isTextblock,x=y.content.size>0;S&&k&&x&&h&&(u=Math.max(0,u-1)),r.replaceWith(u,d,p)}n.updateSelection&&Qu(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta(\"applyInputRules\",{from:u,text:m}),n.applyPasteRules&&r.setMeta(\"applyPasteRules\",{from:u,text:m})}return!0};function Zu(t){for(let e=0;e<t.edgeCount;e+=1){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}var Qg=(t={})=>({tr:e,dispatch:n,editor:r})=>{let{pos:o,attrs:i,content:s,updateSelection:l=!0}=t,a;typeof o==\"number\"?a=e.doc.resolve(o):o?a=o:a=e.selection.$from;let c=Zu(a.parent.contentMatchAt(a.index()));if(!c)return!1;let u=Object.keys(c.spec.attrs||{}),d=i?Object.fromEntries(Object.entries(i).filter(([h])=>u.includes(h))):{},f;if(s){let h=fn(s,r.schema);f=c.createAndFill(d,h)}else f=c.createAndFill(d);return f?(n&&(e.insert(a.pos,f),l&&Qu(e,e.steps.length-1,-1)),!0):!1},Zg=()=>({state:t,dispatch:e})=>Za(t,e),ey=()=>({state:t,dispatch:e})=>ec(t,e),ty=()=>({state:t,dispatch:e})=>Si(t,e),ny=()=>({state:t,dispatch:e})=>Mi(t,e),ed=(t,e)=>{let n=t.resolve(e),r=n.nodeBefore,o=n.nodeAfter;return!r||!o?!1:!r.type.spec.isolating&&!o.type.spec.isolating},ry=()=>({state:t,dispatch:e,tr:n})=>{try{let r=Yt(t.doc,t.selection.$from.pos,-1);return r==null||!ed(t.doc,r)?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},oy=()=>({state:t,dispatch:e,tr:n})=>{try{let r=Yt(t.doc,t.selection.$from.pos,1);return r==null||!ed(t.doc,r)?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},iy=()=>({state:t,dispatch:e})=>Ar(t,e),sy=()=>({state:t,dispatch:e})=>Tr(t,e);function td(){return typeof navigator<\"u\"?/Mac/.test(navigator.platform):!1}function ly(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n===\"Space\"&&(n=\" \");let r,o,i,s;for(let l=0;l<e.length-1;l+=1){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))s=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))o=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))Zr()||td()?s=!0:o=!0;else throw new Error(`Unrecognized modifier name: ${a}`)}return r&&(n=`Alt-${n}`),o&&(n=`Ctrl-${n}`),s&&(n=`Meta-${n}`),i&&(n=`Shift-${n}`),n}var ay=t=>({editor:e,view:n,tr:r,dispatch:o})=>{let i=ly(t).split(/-(?!$)/),s=i.find(c=>![\"Alt\",\"Ctrl\",\"Meta\",\"Shift\"].includes(c)),l=new KeyboardEvent(\"keydown\",{key:s===\"Space\"?\" \":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\",c=>c(n,l))});return a?.steps.forEach(c=>{let u=c.map(r.mapping);u&&o&&r.maybeStep(u)}),!0};function $e(t,e,n={}){let{from:r,to:o,empty:i}=t.selection,s=e?Q(e,t.schema):null,l=[];t.doc.nodesBetween(r,o,(u,d)=>{if(u.isText)return;let f=Math.max(r,d),h=Math.min(o,d+u.nodeSize);l.push({node:u,from:f,to:h})});let a=o-r,c=l.filter(u=>s?s.name===u.node.type.name:!0).filter(u=>Qr(u.node.attrs,n,{strict:!1}));return i?!!c.length:c.reduce((u,d)=>u+d.to-d.from,0)>=a}var cy=(t,e={})=>({state:n,dispatch:r})=>$e(n,Q(t,n.schema),e)?tc(n,r):!1,uy=()=>({state:t,dispatch:e})=>Ri(t,e),dy=t=>({state:e,dispatch:n})=>{let r=Q(t,e.schema);return lc(r)(e,n)},fy=()=>({state:t,dispatch:e})=>Ai(t,e);function to(t,e){return e.nodes[t]?\"node\":e.marks[t]?\"mark\":null}function Nu(t,e){let n=typeof e==\"string\"?[e]:e;return Object.keys(t).reduce((r,o)=>(n.includes(o)||(r[o]=t[o]),r),{})}var hy=(t,e)=>({tr:n,state:r,dispatch:o})=>{let i=null,s=null,l=to(typeof t==\"string\"?t:t.name,r.schema);if(!l)return!1;l===\"node\"&&(i=Q(t,r.schema)),l===\"mark\"&&(s=Qe(t,r.schema));let a=!1;return n.selection.ranges.forEach(c=>{r.doc.nodesBetween(c.$from.pos,c.$to.pos,(u,d)=>{i&&i===u.type&&(a=!0,o&&n.setNodeMarkup(d,void 0,Nu(u.attrs,e))),s&&u.marks.length&&u.marks.forEach(f=>{s===f.type&&(a=!0,o&&n.addMark(d,d+u.nodeSize,s.create(Nu(f.attrs,e))))})})}),a},py=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),my=()=>({tr:t,dispatch:e})=>{if(e){let n=new pe(t.doc);t.setSelection(n)}return!0},gy=()=>({state:t,dispatch:e})=>xi(t,e),yy=()=>({state:t,dispatch:e})=>vi(t,e),by=()=>({state:t,dispatch:e})=>nc(t,e),ky=()=>({state:t,dispatch:e})=>Ii(t,e),wy=()=>({state:t,dispatch:e})=>Di(t,e);function xs(t,e,n={},r={}){return fn(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var Sy=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:o,tr:i,dispatch:s,commands:l})=>{let{doc:a}=i;if(r.preserveWhitespace!==\"full\"){let c=xs(t,o.schema,r,{errorOnInvalidContent:e??o.options.enableContentCheck});if(s){let u=Yu(c)?c.content:[c];i.replaceWith(0,a.content.size,u).setMeta(\"preventUpdate\",!n)}return!0}return s&&i.setMeta(\"preventUpdate\",!n),l.insertContentAt({from:0,to:a.content.size},t,{parseOptions:r,errorOnInvalidContent:e??o.options.enableContentCheck})};function nd(t,e){let n=Qe(e,t.schema),{from:r,to:o,empty:i}=t.selection,s=[];i?(t.storedMarks&&s.push(...t.storedMarks),s.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,o,a=>{s.push(...a.marks)});let l=s.find(a=>a.type.name===n.name);return l?{...l.attrs}:{}}function As(t,e){let n=new st(t);return e.forEach(r=>{r.steps.forEach(o=>{n.step(o)})}),n}function rd(t,e,n){let r=[];return t.nodesBetween(e.from,e.to,(o,i)=>{n(o)&&r.push({node:o,pos:i})}),r}function pn(t,e){for(let n=t.depth;n>0;n-=1){let r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}function no(t){return e=>pn(e.$from,t)}function v(t,e,n){return t.config[e]===void 0&&t.parent?v(t.parent,e,n):typeof t.config[e]==\"function\"?t.config[e].bind({...n,parent:t.parent?v(t.parent,e,n):null}):t.config[e]}function Ts(t){return t.map(e=>{let n=v(e,\"addExtensions\",{name:e.name,options:e.options,storage:e.storage});return n?[e,...Ts(n())]:e}).flat(10)}function Ns(t,e){let n=We.fromSchema(e).serializeFragment(t),r=document.implementation.createHTMLDocument().createElement(\"div\");return r.appendChild(n),r.innerHTML}function od(t,e){let n=new Map;for(let o of t){var r;let i=(r=n.get(o.type))!==null&&r!==void 0?r:new Map;i.set(o.name,o),n.set(o.type,i)}return[...Object.values(e.nodes),...Object.values(e.marks)].flatMap(o=>{var i;return Object.entries((i=o.spec.attrs)!==null&&i!==void 0?i:{}).map(([s,l])=>{var a;let c=(a=n.get(o.name))===null||a===void 0?void 0:a.get(s),u=Object.hasOwn(l,\"default\");return{type:o.name,name:s,attribute:{rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,...c?.attribute,default:l.default,isRequired:!u,validate:l.validate}}})})}var xy={content:\"string\",marks:\"string\",group:\"string\",inline:\"boolean\",atom:\"boolean\",selectable:\"boolean\",draggable:\"boolean\",code:\"boolean\",whitespace:[\"pre\",\"normal\"],definingAsContext:\"boolean\",definingForContent:\"boolean\",defining:\"boolean\",isolating:\"boolean\",linebreakReplacement:\"boolean\"},Cy={inclusive:\"boolean\",excludes:\"string\",group:\"string\",spanning:\"boolean\",code:\"boolean\"};function My(t,e,n){return Object.fromEntries(Object.entries(e).flatMap(([r,o])=>{let i=t[r];if(i===void 0)return[];if(!(typeof o==\"string\"?typeof i===o:typeof i==\"string\"&&o.includes(i)))throw new RangeError(`Invalid schemaSpec field '${n}.${r}'`);return[[r,i]]}))}function Ou(t,e,n,r){return{...Object.fromEntries(Object.entries(e).filter(([o])=>o!==\"attrs\"&&!Object.hasOwn(r,o))),...My(n,r,t),attrs:n.attrs}}function Ru(t,e,n){for(let r of Object.keys(e))if(!Object.hasOwn(t,r))throw new RangeError(`schemaSpec requires a local ${n} extension named '${r}'`);for(let r of Object.keys(t))if(!Object.hasOwn(e,r))throw new RangeError(`Local ${n} extension '${r}' is not in schemaSpec`)}function vy(t,e){Ru(t.nodes,e.nodes,\"node\"),Ru(t.marks,e.marks,\"mark\");let n=e.spec.nodes,r=e.spec.marks;return e.spec.nodes.forEach((o,i)=>{n=n.update(o,Ou(o,t.nodes[o],i,xy))}),e.spec.marks.forEach((o,i)=>{r=r.update(o,Ou(o,t.marks[o],i,Cy))}),{topNode:e.topNodeType.name,nodes:n,marks:r}}function id(t){let e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function hn(t){return{baseExtensions:t.filter(e=>e.type===\"extension\"),nodeExtensions:t.filter(e=>e.type===\"node\"),markExtensions:t.filter(e=>e.type===\"mark\")}}function Os(t){let e=[],{nodeExtensions:n,markExtensions:r}=hn(t),o=[...n,...r],i={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},s=n.filter(c=>c.name!==\"text\").map(c=>c.name),l=r.map(c=>c.name),a=[...s,...l];return t.forEach(c=>{let u=v(c,\"addGlobalAttributes\",{name:c.name,options:c.options,storage:c.storage,extensions:o});u&&u().forEach(d=>{let f;Array.isArray(d.types)?f=d.types:d.types===\"*\"?f=a:d.types===\"nodes\"?f=s:d.types===\"marks\"?f=l:f=[],f.forEach(h=>{Object.entries(d.attributes).forEach(([p,m])=>{e.push({type:h,name:p,attribute:{...i,...m}})})})})}),o.forEach(c=>{let u=v(c,\"addAttributes\",{name:c.name,options:c.options,storage:c.storage});if(!u)return;let d=u();Object.entries(d).forEach(([f,h])=>{let p={...i,...h};typeof p?.default==\"function\"&&(p.default=p.default()),p?.isRequired&&p?.default===void 0&&delete p.default,e.push({type:c.name,name:f,attribute:p})})}),e}function Cs(t){return typeof t==\"function\"}function L(t,e=void 0,...n){return Cs(t)?e?t.bind(e)(...n):t(...n):t}function Ey(t={}){return Object.keys(t).length===0&&t.constructor===Object}function Ay(t){let e=[],n=\"\",r=!1,o=!1,i=0,s=t.length;for(let l=0;l<s;l+=1){let a=t[l];if(a===\"'\"&&!o){r=!r,n+=a;continue}if(a==='\"'&&!r){o=!o,n+=a;continue}if(!r&&!o){if(a===\"(\"){i+=1,n+=a;continue}if(a===\")\"&&i>0){i-=1,n+=a;continue}if(a===\";\"&&i===0){e.push(n),n=\"\";continue}}n+=a}return n&&e.push(n),e}function Du(t){let e=[],n=Ay(t||\"\"),r=n.length;for(let o=0;o<r;o+=1){let i=n[o],s=i.indexOf(\":\");if(s===-1)continue;let l=i.slice(0,s).trim(),a=i.slice(s+1).trim();l&&a&&e.push([l,a])}return e}function B(...t){return t.filter(e=>!!e).reduce((e,n)=>{let r={...e};return Object.entries(n).forEach(([o,i])=>{if(o===\"__proto__\"){Object.defineProperty(r,o,{configurable:!0,enumerable:!0,value:i,writable:!0});return}if(!r[o]){r[o]=i;return}if(o===\"class\"){let s=i?String(i).split(\" \"):[],l=r[o]?r[o].split(\" \"):[],a=s.filter(c=>!l.includes(c));r[o]=[...l,...a].join(\" \")}else if(o===\"style\"){let s=new Map([...Du(r[o]),...Du(i)]);r[o]=Array.from(s.entries()).map(([l,a])=>`${l}: ${a}`).join(\"; \")}else r[o]=i}),r},{})}function pt(t,e){return e.filter(n=>n.type===t.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(t.attrs)||{}:{[n.name]:t.attrs[n.name]}).reduce((n,r)=>B(n,r),{})}function Ty(t){return typeof t!=\"string\"?t:t.match(/^[+-]?(?:\\d*\\.)?\\d+$/)?Number(t):t===\"true\"?!0:t===\"false\"?!1:t}function Iu(t,e){return\"style\"in t?t:{...t,getAttrs:n=>{let r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;let o=e.reduce((i,s)=>{let l=s.attribute.parseHTML?s.attribute.parseHTML(n):Ty(n.getAttribute(s.name));return l==null?i:{...i,[s.name]:l}},{});return{...r,...o}}}}function Pu(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e===\"attrs\"&&Ey(n)?!1:n!=null))}function Lu(t){var e,n;let r={};return!(!(t==null||(e=t.attribute)===null||e===void 0)&&e.isRequired)&&\"default\"in(t?.attribute||{})&&(r.default=t.attribute.default),(t==null||(n=t.attribute)===null||n===void 0?void 0:n.validate)!==void 0&&(r.validate=t.attribute.validate),[t.name,r]}function $u(t,e,n=Os(t)){var r;let{nodeExtensions:o,markExtensions:i}=hn(t);return{topNode:(r=o.find(s=>v(s,\"topNode\")))===null||r===void 0?void 0:r.name,nodes:Object.fromEntries(o.map(s=>{let l=n.filter(h=>h.type===s.name),a={name:s.name,options:s.options,storage:s.storage,editor:e},c=Pu({...t.reduce((h,p)=>{let m=v(p,\"extendNodeSchema\",a);return{...h,...m?m(s):{}}},{}),content:L(v(s,\"content\",a)),marks:L(v(s,\"marks\",a)),group:L(v(s,\"group\",a)),inline:L(v(s,\"inline\",a)),atom:L(v(s,\"atom\",a)),selectable:L(v(s,\"selectable\",a)),draggable:L(v(s,\"draggable\",a)),code:L(v(s,\"code\",a)),whitespace:L(v(s,\"whitespace\",a)),linebreakReplacement:L(v(s,\"linebreakReplacement\",a)),defining:L(v(s,\"defining\",a)),isolating:L(v(s,\"isolating\",a)),attrs:Object.fromEntries(l.map(Lu))}),u=L(v(s,\"parseHTML\",a));u&&(c.parseDOM=u.map(h=>Iu(h,l)));let d=v(s,\"renderHTML\",a);d&&(c.toDOM=h=>d({node:h,HTMLAttributes:pt(h,l)}));let f=v(s,\"renderText\",a);return f&&(c.toText=f),[s.name,c]})),marks:Object.fromEntries(i.map(s=>{let l=n.filter(f=>f.type===s.name),a={name:s.name,options:s.options,storage:s.storage,editor:e},c=Pu({...t.reduce((f,h)=>{let p=v(h,\"extendMarkSchema\",a);return{...f,...p?p(s):{}}},{}),inclusive:L(v(s,\"inclusive\",a)),excludes:L(v(s,\"excludes\",a)),group:L(v(s,\"group\",a)),spanning:L(v(s,\"spanning\",a)),code:L(v(s,\"code\",a)),attrs:Object.fromEntries(l.map(Lu))}),u=L(v(s,\"parseHTML\",a));u&&(c.parseDOM=u.map(f=>Iu(f,l)));let d=v(s,\"renderHTML\",a);return d&&(c.toDOM=f=>d({mark:f,HTMLAttributes:pt(f,l)})),[s.name,c]}))}}function Ny(t,e,n){if(n===void 0)return new vt($u(t,e));let r=id(t.filter(s=>s.type!==\"extension\").map(s=>s.name));if(r.length)throw new RangeError(`Duplicate local schema types: ${r.join(\", \")}`);let o=new vt(n),i=$u(t,e,od(Os(t),o));return new vt(vy(i,o))}function Yn(t){return t.sort((n,r)=>{let o=v(n,\"priority\")||100,i=v(r,\"priority\")||100;return o>i?-1:o<i?1:0})}function sd(t){let e=Yn(Ts(t)),n=id(e.map(r=>r.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(r=>`'${r}'`).join(\", \")}]. This can lead to issues.`),e}function ld(t,e,n){let{from:r,to:o}=e,{blockSeparator:i=`\n\n`,textSerializers:s={}}=n||{},l=\"\";return t.nodesBetween(r,o,(a,c,u,d)=>{a.isBlock&&c>r&&(l+=i);let f=s?.[a.type.name];if(f)return u&&(l+=f({node:a,pos:c,parent:u,index:d,range:e})),!1;if(a.isText){var h;l+=a==null||(h=a.text)===null||h===void 0?void 0:h.slice(Math.max(r,c)-c,o-c)}}),l}function Oy(t,e){return ld(t,{from:0,to:t.content.size},e)}function ad(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function Ry(t,e){let n=Q(e,t.schema),{from:r,to:o}=t.selection,i=[];t.doc.nodesBetween(r,o,l=>{i.push(l)});let s=i.reverse().find(l=>l.type.name===n.name);return s?{...s.attrs}:{}}function Rs(t,e){let n=to(typeof e==\"string\"?e:e.name,t.schema);return n===\"node\"?Ry(t,e):n===\"mark\"?nd(t,e):{}}function Dy(t,e=JSON.stringify){let n={};return t.filter(r=>{let o=e(r);return Object.prototype.hasOwnProperty.call(n,o)?!1:n[o]=!0})}function Iy(t){let e=Dy(t);return e.length===1?e:e.filter((n,r)=>!e.filter((o,i)=>i!==r).some(o=>n.oldRange.from>=o.oldRange.from&&n.oldRange.to<=o.oldRange.to&&n.newRange.from>=o.newRange.from&&n.newRange.to<=o.newRange.to))}function mn(t){let{mapping:e,steps:n}=t,r=[],o=e.invert();return e.maps.forEach((i,s)=>{let l=[];if(i.ranges.length)i.forEach((c,u)=>{l.push({from:c,to:u})});else{let{from:c,to:u}=n[s];if(c===void 0||u===void 0)return;l.push({from:c,to:u})}let a=e.slice(s);l.forEach(({from:c,to:u})=>{let d=a.map(c,-1),f=a.map(u),h=o.map(d,-1),p=o.map(f);r.push({oldRange:{from:h,to:p},newRange:{from:d,to:f}})})}),Iy(r)}function Qn(t,e,n){let r=[];return t===e?n.resolve(t).marks().forEach(o=>{let i=Es(n.resolve(t),o.type);i&&r.push({mark:o,...i})}):n.nodesBetween(t,e,(o,i)=>{!o||o?.nodeSize===void 0||r.push(...o.marks.map(s=>({from:i,to:i+o.nodeSize,mark:s})))}),r}var cd=(t,e,n,r=20)=>{let o=t.doc.resolve(n),i=r,s=null;for(;i>0&&s===null;){let l=o.node(i);l?.type.name===e?s=l:i-=1}return[s,i]},ud=t=>{let e=t.depth-1;if(e<0)return null;let n=t.index(e);return n===0?null:t.node(e).child(n-1)};function ln(t,e){return e.nodes[t]||e.marks[t]||null}function Yr(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{let o=t.find(i=>i.type===e&&i.name===r);return o?o.attribute.keepOnSplit:!1}))}var Py=(t,e=500)=>{let n=\"\",r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(o,i,s,l)=>{var a,c;let u=((a=(c=o.type.spec).toText)===null||a===void 0?void 0:a.call(c,{node:o,pos:i,parent:s,index:l}))||o.textContent||\"%leaf%\";n+=o.isAtom&&!o.isText?u:u.slice(0,Math.max(0,r-i))}),n};function Ms(t,e,n={}){let{empty:r,ranges:o}=t.selection,i=e?Qe(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(u=>i?i.name===u.type.name:!0).find(u=>Qr(u.attrs,n,{strict:!1}));let s=0,l=[];if(o.forEach(({$from:u,$to:d})=>{let f=u.pos,h=d.pos;t.doc.nodesBetween(f,h,(p,m)=>{if(i&&p.inlineContent&&!p.type.allowsMarkType(i))return!1;if(!p.isText&&!p.marks.length)return;let g=Math.max(f,m),y=Math.min(h,m+p.nodeSize),S=y-g;s+=S,l.push(...p.marks.map(k=>({mark:k,from:g,to:y})))})}),s===0)return!1;let a=l.filter(u=>i?i.name===u.mark.type.name:!0).filter(u=>Qr(u.mark.attrs,n,{strict:!1})).reduce((u,d)=>u+d.to-d.from,0),c=l.filter(u=>i?u.mark.type!==i&&u.mark.type.excludes(i):!0).reduce((u,d)=>u+d.to-d.from,0);return(a>0?a+c:a)>=s}function Ly(t,e,n={}){if(!e)return $e(t,null,n)||Ms(t,null,n);let r=to(e,t.schema);return r===\"node\"?$e(t,e,n):r===\"mark\"?Ms(t,e,n):!1}var dd=(t,e)=>{let{$from:n,$to:r,$anchor:o}=t.selection;if(e){let i=no(l=>l.type.name===e)(t.selection);if(!i)return!1;let s=t.doc.resolve(i.pos+1);return o.pos+1===s.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},fd=t=>{let{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function zu(t,e){return Array.isArray(e)?e.some(n=>(typeof n==\"string\"?n:n.name)===t.name):e}function Gn(t,e){let{nodeExtensions:n}=hn(e),r=n.find(i=>i.name===t);if(!r)return!1;let o=L(v(r,\"group\",{name:r.name,options:r.options,storage:r.storage}));return typeof o!=\"string\"?!1:o.split(\" \").includes(\"list\")}function gn(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){if(n){if(t.type.name===\"hardBreak\")return!0;if(t.isText){var r;return!/\\S/.test((r=t.text)!==null&&r!==void 0?r:\"\")}}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let o=!0;return t.content.forEach(i=>{o!==!1&&(gn(i,{ignoreWhitespace:n,checkChildren:e})||(o=!1))}),o}return!1}function hd(t){return t instanceof A}function $y(t){if(t===null||typeof t!=\"object\")return!1;let e=t;return!(typeof e.apply!=\"function\"||typeof e.getMap!=\"function\"||typeof e.invert!=\"function\"||typeof e.map!=\"function\"||typeof e.merge!=\"function\"||typeof e.toJSON!=\"function\")}function zy(t){if(t===null||typeof t!=\"object\")return!1;let e=t;if(!$y(e))return!1;let n=e.toJSON();return!(n===null||typeof n!=\"object\"||n.stepType!==\"replace\")}var pd=class md{constructor(e){this.position=e}static fromJSON(e){return new md(e.position)}toJSON(){return{position:this.position}}};function By(t,e){let n=e.mapping.mapResult(t.position);return{position:new pd(n.pos),mapResult:n}}function Fy(t){return new pd(t)}function Hy(t,e,n){let{selection:r}=e,o=null;if(qu(r)&&(o=r.$cursor),o){var i;let l=(i=t.storedMarks)!==null&&i!==void 0?i:o.marks();return o.parent.type.allowsMarkType(n)&&(!!n.isInSet(l)||!l.some(a=>a.type.excludes(n)))}let{ranges:s}=r;return s.some(({$from:l,$to:a})=>{let c=l.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(l.pos,a.pos,(u,d,f)=>{if(c)return!1;if(u.isInline){let h=!f||f.type.allowsMarkType(n),p=!!n.isInSet(u.marks)||!u.marks.some(m=>m.type.excludes(n));c=h&&p}return!c}),c})}var jy=(t,e={})=>({tr:n,state:r,dispatch:o})=>{let{selection:i}=n,{empty:s,ranges:l}=i,a=Qe(t,r.schema);if(o)if(s){let c=nd(r,a);n.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{let u=c.$from.pos,d=c.$to.pos;r.doc.nodesBetween(u,d,(f,h)=>{let p=Math.max(h,u),m=Math.min(h+f.nodeSize,d);f.marks.find(g=>g.type===a)?f.marks.forEach(g=>{a===g.type&&n.addMark(p,m,a.create({...g.attrs,...e}))}):n.addMark(p,m,a.create(e))})});return Hy(r,n,a)},Wy=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),Vy=(t,e={})=>({state:n,dispatch:r,chain:o})=>{let i=Q(t,n.schema),s;return n.selection.$anchor.sameParent(n.selection.$head)&&(s=n.selection.$anchor.parent.attrs),i.isTextblock?o().command(({commands:l})=>Pi(i,{...s,...e})(n)?!0:l.clearNodes()).command(({state:l})=>Pi(i,{...s,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently \"setNode()\" only supports text block nodes.'),!1)},_y=t=>({tr:e,dispatch:n})=>{if(n){let{doc:r}=e,o=Ft(t,0,r.content.size),i=A.create(r,o);e.setSelection(i)}return!0},Ky=(t,e)=>({tr:n,state:r,dispatch:o})=>{let{selection:i}=r,s,l;return typeof e==\"number\"?(s=e,l=e):e&&\"from\"in e&&\"to\"in e?(s=e.from,l=e.to):(s=i.from,l=i.to),o&&n.doc.nodesBetween(s,l,(a,c)=>{a.isText||n.setNodeMarkup(c,void 0,{...a.attrs,dir:t})}),!0},Uy=t=>({tr:e,dispatch:n})=>{if(n){let{doc:r}=e,{from:o,to:i}=typeof t==\"number\"?{from:t,to:t}:t,s=M.atStart(r).from,l=M.atEnd(r).to,a=Ft(o,s,l),c=Ft(i,s,l),u=M.create(r,a,c);e.setSelection(u)}return!0},Jy=t=>({state:e,dispatch:n})=>{let r=Q(t,e.schema);return ac(r)(e,n)};function Bu(t,e){let n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){let r=n.filter(o=>e?.includes(o.type.name));t.tr.ensureMarks(r)}}var qy=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:o})=>{let{selection:i,doc:s}=e,{$from:l,$to:a}=i,c=o.extensionManager.attributes,u=Yr(c,l.node().type.name,l.node().attrs);if(i instanceof A&&i.node.isBlock)return!l.parentOffset||!Ce(s,l.pos)?!1:(r&&(t&&Bu(n,o.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;let d=a.parentOffset===a.parent.content.size,f=l.depth===0?void 0:Zu(l.node(-1).contentMatchAt(l.indexAfter(-1))),h=d&&f?[{type:f,attrs:u}]:void 0,p=i instanceof M&&!i.empty?At.create({doc:e.doc,selection:i}).tr.deleteSelection():null,m=p?p.doc:e.doc,g=p?p.mapping.map(l.pos):l.pos,y=Ce(m,g,1,h);if(!h&&!y&&Ce(m,g,1,f?[{type:f}]:void 0)&&(y=!0,h=f?[{type:f,attrs:u}]:void 0),r){if(y){let S=e.steps.length;if(i instanceof M&&e.deleteSelection(),e.split(e.mapping.slice(S).map(l.pos),1,h),f&&!d&&!l.parentOffset&&l.parent.type!==f){let k=e.mapping.slice(S).map(l.before()),x=e.doc.resolve(k);l.node(-1).canReplaceWith(x.index(),x.index()+1,f)&&e.setNodeMarkup(e.mapping.slice(S).map(l.before()),f)}}t&&Bu(n,o.extensionManager.splittableMarks),e.scrollIntoView()}return y},Gy=(t,e={})=>({tr:n,state:r,dispatch:o,editor:i})=>{let s=Q(t,r.schema),{$from:l,$to:a}=r.selection,c=r.selection.node;if(c&&c.isBlock||l.depth<2||!l.sameParent(a))return!1;let u=l.node(-1);if(u.type!==s)return!1;let d=i.extensionManager.attributes;if(l.parent.content.size===0&&l.node(-1).childCount===l.indexAfter(-1)){if(l.depth===2||l.node(-3).type!==s||l.index(-2)!==l.node(-2).childCount-1)return!1;if(o){var f;let x=b.empty,O=l.index(-1)?1:l.index(-2)?2:3;for(let xe=l.depth-O;xe>=l.depth-3;xe-=1)x=b.from(l.node(xe).copy(x));let H=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,T={...Yr(d,l.node().type.name,l.node().attrs),...e},I=((f=s.contentMatch.defaultType)===null||f===void 0?void 0:f.createAndFill(T))||void 0;x=x.append(b.from(s.createAndFill(null,I)||void 0));let F=l.before(l.depth-(O-1));n.replace(F,l.after(-H),new C(x,4-O,0));let W=-1;n.doc.nodesBetween(F,n.doc.content.size,(xe,kt)=>{if(W>-1)return!1;xe.isTextblock&&xe.content.size===0&&(W=kt+1)}),W>-1&&n.setSelection(M.near(n.doc.resolve(W))),n.scrollIntoView()}return!0}let h=a.pos===l.end()?u.contentMatchAt(0).defaultType:null,p={...Yr(d,u.type.name,u.attrs),...e},m={...Yr(d,l.node().type.name,l.node().attrs),...e},g=l.parentOffset===0&&l.index(-1)===0,y=l.before(-1);n.delete(l.pos,a.pos);let S=g?u.attrs:p,k=h?[{type:s,attrs:S},{type:h,attrs:m}]:[{type:s,attrs:S}];if(!Ce(n.doc,l.pos,2))return!1;if(o){let{selection:x,storedMarks:O}=r,{splittableMarks:H}=i.extensionManager,T=O||x.$to.parentOffset&&x.$from.marks();if(n.split(l.pos,2,k).scrollIntoView(),g&&n.setNodeMarkup(y,void 0,p),!T||!o)return!0;let I=T.filter(F=>H.includes(F.type.name));n.ensureMarks(I)}return!0};function gd(t,e,n){if(!t.validContent(e))return null;try{return t.create(n,e)}catch{return null}}function Ds(t,e){if(t.pendingContent.length===0)return!0;let n=gd(e,b.from(t.pendingContent));return n?(t.items.push(n),t.pendingContent=[],!0):!1}function Xy(t,e,n){return n.validContent(b.from([...e.pendingContent,t]))?(e.pendingContent.push(t),!0):!Ds(e,n)||!n.validContent(b.from(t))?!1:(e.pendingContent.push(t),!0)}function Yy(t,e,n,r){let o=r(t,n);if(!o)return!1;let i=gd(n.listType,b.from(o),t.attrs);return i?n.itemType.validContent(b.from([...e.pendingContent,i]))?(e.pendingContent.push(i),!0):Ds(e,n.itemType)?(e.items.push(...o),!0):!1:!1}function Qy(t,e,n){let r={items:[],pendingContent:[]};for(let o=0;o<t.childCount;o+=1){let i=t.child(o);if(!(e.isListNode(i)?Yy(i,r,e,n):Xy(i,r,e.itemType)))return null}return Ds(r,e.itemType)?r.items:null}function yd(t,e){let n=[];for(let r=0;r<t.childCount;r+=1){let o=Qy(t.child(r),e,yd);if(!o)return null;n.push(...o)}return n}function Fu(t,e){let n=null;return t.descendants((r,o)=>r!==e?!0:(n=o,!1)),n}function Hu(t){return!t||t===\"1\"?null:t}function bd(t,e){return Hu(t)===Hu(e)}var Jr=(t,e)=>{let n=no(i=>i.type===e)(t.selection);if(!n)return!0;let r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;let o=t.doc.nodeAt(r);return!(n.node.type===o?.type&&Ne(t.doc,n.pos))||!bd(n.node.attrs.type,o?.attrs.type)||t.join(n.pos),!0},qr=(t,e)=>{let n=no(i=>i.type===e)(t.selection);if(!n)return!0;let r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;let o=t.doc.nodeAt(r);return!(n.node.type===o?.type&&Ne(t.doc,r))||!bd(n.node.attrs.type,o?.attrs.type)||t.join(r),!0};function Zy(t){let e=t.doc,n=e.firstChild;if(!n)return null;let r=e.resolve(1),o=e.resolve(n.nodeSize-1);return M.between(r,o)}var e0=(t,e,n,r={})=>({editor:o,tr:i,state:s,dispatch:l,chain:a,commands:c,can:u})=>{let{extensions:d,splittableMarks:f}=o.extensionManager,h=Q(t,s.schema),p=Q(e,s.schema),{selection:m,storedMarks:g}=s,{$from:y,$to:S}=m,k=y.blockRange(S),x=g||m.$to.parentOffset&&m.$from.marks();if(!k)return!1;let O=no(fe=>Gn(fe.type.name,d))(m),H=m.from===0&&m.to===s.doc.content.size,T=s.doc.content.content,I=T.length===1?T[0]:null,F=H&&I&&Gn(I.type.name,d)?{node:I,pos:0,depth:0}:null,W=O??F,xe=!!O&&k.depth>=1&&k.depth-O.depth<=1,kt=!!F;if((xe||kt)&&W){if(W.node.type===h)return H&&kt?a().command(({tr:fe,dispatch:ye})=>{let he=Zy(fe);return he?(fe.setSelection(he),ye&&ye(fe),!0):!1}).liftListItem(p).run():c.liftListItem(p);if(Gn(W.node.type.name,d)&&h.validContent(W.node.content))return a().command(()=>(i.setNodeMarkup(W.pos,h),!0)).command(()=>Jr(i,h)).command(()=>qr(i,h)).run();if(Gn(W.node.type.name,d)){var wt;let fe=(wt=W.node.firstChild)===null||wt===void 0?void 0:wt.type;if(fe&&fe!==p){let ye=yd(W.node,{listType:h,itemType:p,isListNode:dr=>Gn(dr.type.name,d)}),he=ye?b.from(ye):null;return!he||!h.validContent(he)?!1:a().command(()=>{let{$anchor:dr,$head:_l}=i.selection,Kl=dr.parent,Ul=_l.parent,jh=dr.parentOffset,Wh=_l.parentOffset,fr;try{fr=h.create(r,he)}catch{return!1}if(i.replaceWith(W.pos,W.pos+W.node.nodeSize,fr),Kl.inlineContent&&Ul.inlineContent){let Jl=Fu(fr,Kl),ql=Fu(fr,Ul);if(Jl!==null&&ql!==null){let Vh=W.pos+Jl+2+jh,_h=W.pos+ql+2+Wh;i.setSelection(M.create(i.doc,Vh,_h))}}return!0}).command(()=>Jr(i,h)).command(()=>qr(i,h)).run()}}}return!n||!x||!l?a().command(()=>u().wrapInList(h,r)?!0:c.clearNodes()).wrapInList(h,r).command(()=>Jr(i,h)).command(()=>qr(i,h)).run():a().command(()=>{let fe=u().wrapInList(h,r),ye=x.filter(he=>f.includes(he.type.name));return i.ensureMarks(ye),fe?!0:c.clearNodes()}).wrapInList(h,r).command(()=>Jr(i,h)).command(()=>qr(i,h)).run()},t0=(t,e={},n={})=>({state:r,commands:o})=>{let{extendEmptyMarkRange:i=!1}=n,s=Qe(t,r.schema);return Ms(r,s,e)?o.unsetMark(s,{extendEmptyMarkRange:i}):o.setMark(s,e)},n0=(t,e,n={})=>({state:r,commands:o})=>{let i=Q(t,r.schema),s=Q(e,r.schema),l=$e(r,i,n),a;return r.selection.$anchor.sameParent(r.selection.$head)&&(a=r.selection.$anchor.parent.attrs),l?o.setNode(s,a):o.setNode(i,{...a,...n})},r0=(t,e={})=>({state:n,commands:r})=>{let o=Q(t,n.schema);return $e(n,o,e)?r.lift(o):r.wrapIn(o,e)},o0=()=>({state:t,dispatch:e})=>{let n=t.plugins;for(let r=0;r<n.length;r+=1){let o=n[r],i;if(o.spec.isInputRules&&(i=o.getState(t))){if(e){let s=t.tr,l=i.transform;for(let a=l.steps.length-1;a>=0;a-=1)s.step(l.steps[a].invert(l.docs[a]));if(i.text){let a=s.doc.resolve(i.from).marks();s.replaceWith(i.from,i.to,t.schema.text(i.text,a))}else s.delete(i.from,i.to)}return!0}}return!1},i0=(t={})=>({tr:e,dispatch:n,editor:r})=>{let{ignoreClearable:o=!1}=t,{selection:i}=e,{empty:s,ranges:l}=i;if(s)return!0;let{nonClearableMarks:a}=r.extensionManager;if(n){let c=Object.values(r.schema.marks).filter(u=>o||!a.includes(u.name));l.forEach(u=>{for(let d of c)e.removeMark(u.$from.pos,u.$to.pos,d)})}return!0},s0=(t,e={})=>({tr:n,state:r,dispatch:o})=>{let{extendEmptyMarkRange:i=!1}=e,{selection:s}=n,l=Qe(t,r.schema),{$from:a,empty:c,ranges:u}=s;if(!o)return!0;if(c&&i){var d;let{from:f,to:h}=s,p=Es(a,l,(d=a.marks().find(m=>m.type===l))===null||d===void 0?void 0:d.attrs);p&&(f=p.from,h=p.to),n.removeMark(f,h,l)}else u.forEach(f=>{n.removeMark(f.$from.pos,f.$to.pos,l)});return n.removeStoredMark(l),!0},l0=t=>({tr:e,state:n,dispatch:r})=>{let{selection:o}=n,i,s;return typeof t==\"number\"?(i=t,s=t):t&&\"from\"in t&&\"to\"in t?(i=t.from,s=t.to):(i=o.from,s=o.to),r&&e.doc.nodesBetween(i,s,(l,a)=>{if(l.isText)return;let c={...l.attrs};delete c.dir,e.setNodeMarkup(a,void 0,c)}),!0},a0=(t,e={})=>({tr:n,state:r,dispatch:o})=>{let i=null,s=null,l=to(typeof t==\"string\"?t:t.name,r.schema);if(!l)return!1;l===\"node\"&&(i=Q(t,r.schema)),l===\"mark\"&&(s=Qe(t,r.schema));let a=!1;return n.selection.ranges.forEach(c=>{let u=c.$from.pos,d=c.$to.pos,f,h,p,m;n.selection.empty?r.doc.nodesBetween(u,d,(g,y)=>{i&&i===g.type&&(a=!0,p=Math.max(y,u),m=Math.min(y+g.nodeSize,d),f=y,h=g)}):r.doc.nodesBetween(u,d,(g,y)=>{y<u&&i&&i===g.type&&(a=!0,p=Math.max(y,u),m=Math.min(y+g.nodeSize,d),f=y,h=g),y>=u&&y<=d&&(i&&i===g.type&&(a=!0,o&&n.setNodeMarkup(y,void 0,{...g.attrs,...e})),s&&g.marks.length&&g.marks.forEach(S=>{if(s===S.type&&(a=!0,o)){let k=Math.max(y,u),x=Math.min(y+g.nodeSize,d);n.addMark(k,x,s.create({...S.attrs,...e}))}}))}),h&&(f!==void 0&&o&&n.setNodeMarkup(f,void 0,{...h.attrs,...e}),s&&h.marks.length&&h.marks.forEach(g=>{s===g.type&&o&&n.addMark(p,m,s.create({...g.attrs,...e}))}))}),a},cn=new P(\"__tiptap_decorations__\"),c0=t=>({tr:e,dispatch:n})=>(n&&e.setMeta(cn,{type:\"force\",name:t}),!0),u0=(t,e={})=>({state:n,dispatch:r})=>{let o=Q(t,n.schema);return ic(o,e)(n,r)},d0=(t,e={})=>({state:n,dispatch:r})=>{let o=Q(t,n.schema);return sc(o,e)(n,r)},f0=Xl({blur:()=>Rg,clearContent:()=>Dg,clearNodes:()=>Ig,command:()=>Pg,createParagraphNear:()=>Lg,cut:()=>$g,deleteCurrentNode:()=>zg,deleteNode:()=>Bg,deleteRange:()=>Fg,deleteSelection:()=>Wg,enter:()=>Vg,exitCode:()=>_g,extendMarkRange:()=>Kg,first:()=>Ug,focus:()=>qg,forEach:()=>Gg,insertContent:()=>Xg,insertContentAt:()=>Yg,insertDefaultBlock:()=>Qg,joinBackward:()=>ty,joinDown:()=>ey,joinForward:()=>ny,joinItemBackward:()=>ry,joinItemForward:()=>oy,joinTextblockBackward:()=>iy,joinTextblockForward:()=>sy,joinUp:()=>Zg,keyboardShortcut:()=>ay,lift:()=>cy,liftEmptyBlock:()=>uy,liftListItem:()=>dy,newlineInCode:()=>fy,resetAttributes:()=>hy,scrollIntoView:()=>py,selectAll:()=>my,selectNodeBackward:()=>gy,selectNodeForward:()=>yy,selectParentNode:()=>by,selectTextblockEnd:()=>ky,selectTextblockStart:()=>wy,setContent:()=>Sy,setMark:()=>jy,setMeta:()=>Wy,setNode:()=>Vy,setNodeSelection:()=>_y,setTextDirection:()=>Ky,setTextSelection:()=>Uy,sinkListItem:()=>Jy,splitBlock:()=>qy,splitListItem:()=>Gy,toggleList:()=>e0,toggleMark:()=>t0,toggleNode:()=>n0,toggleWrap:()=>r0,undoInputRule:()=>o0,unsetAllMarks:()=>i0,unsetMark:()=>s0,unsetTextDirection:()=>l0,updateAttributes:()=>a0,updateDecorations:()=>c0,wrapIn:()=>u0,wrapInList:()=>d0}),un=new WeakMap;function h0(t,e){var n;un.set(t,((n=un.get(t))!==null&&n!==void 0?n:0)+1);try{return e()}finally{var r;let o=((r=un.get(t))!==null&&r!==void 0?r:1)-1;o>0?un.set(t,o):un.delete(t)}}function p0(t){return un.has(t)}var m0=class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){let n=this.callbacks[t];return n&&n.forEach(r=>r.apply(this,e)),this}off(t,e){let n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter(r=>r!==e):delete this.callbacks[t]),this}once(t,e){let n=(...r)=>{this.off(t,n),e.apply(this,r)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}},kd=typeof process<\"u\"&&!1;function g0(t){return t.kind===\"widget\"}function wd(t,e){let n=[],r=new Set;for(let o of t)o.kind===\"widget\"&&g0(o)&&r.add(o.key),n.push(o.toPMDecoration(e));return{decorations:n,widgetKeys:r}}function y0(t,e,n){let{decorations:r,widgetKeys:o}=wd(e,n);return{set:z.create(t,r),widgetKeys:o}}function Sd({position:t,from:e,to:n,docSize:r}){return t<e?!1:t<n?!0:t===n&&n===r}function b0({decorations:t,from:e,to:n,docSize:r,extensionName:o,warnedExtensions:i}){return t.filter(s=>Sd({position:s.anchor,from:e,to:n,docSize:r})?!0:(s.anchor===n||i.has(o)||(i.add(o),console.warn(`[tiptap warn]: Extension \"${o}\" returned a decoration outside the requested range [${e}, ${n}). It was ignored.`)),!1))}function xd(t){var e;let n=(e=t.spec)===null||e===void 0?void 0:e.key;return typeof n==\"string\"?n:void 0}function k0(t){let e=new Map,n=new Map;for(let s of t.find()){var r,o,i;let l=xd(s);if(!l)continue;let a=(r=s.spec.extensionName)!==null&&r!==void 0?r:\"unknown\",c=(o=e.get(l))!==null&&o!==void 0?o:new Set;c.add(a),e.set(l,c),n.set(l,((i=n.get(l))!==null&&i!==void 0?i:0)+1)}return Array.from(e,([s,l])=>({key:s,extensions:l})).filter(({key:s})=>{var l;return((l=n.get(s))!==null&&l!==void 0?l:0)>1})}function Cd(t){return t.jsonID===\"attr\"}function w0(t){let e=!1;if(t.getMap().forEach(()=>{e=!0}),e||Cd(t))return!0;let n=t;return typeof n.from==\"number\"&&typeof n.to==\"number\"}function S0(t,e){let n=null,r=0,o=0;for(let i=0;i<t.childCount&&!(o>e.to);i+=1){let s=o+t.child(i).nodeSize;s>=e.from&&(n===null&&(n=o),r=s),o=s}return n===null?null:{from:n,to:r}}function x0(t,e){if(t.steps.some(i=>!w0(i)))return{type:\"full\"};let n=mn(t).map(({newRange:i})=>i);t.steps.forEach((i,s)=>{if(!Cd(i))return;let l=t.mapping.slice(s);n.push({from:l.map(i.pos,-1),to:l.map(i.pos+1)})});let r=[];for(let i of n){let s=S0(e,i);s&&r.push(s)}r.sort((i,s)=>i.from-s.from);let o=[];for(let i of r){let s=o[o.length-1];s&&i.from<=s.to?s.to=Math.max(s.to,i.to):o.push({...i})}return{type:\"ranges\",ranges:o}}function Md(t,e,n,r){return t.map(e,n,{onRemove:o=>{let i=o?.key;typeof i==\"string\"&&r.delete(i)}})}function C0(t,e,n){var r,o;let i=(r=e.decorationSetsByExtension[t])!==null&&r!==void 0?r:z.empty,s=new Set((o=e.widgetKeysByExtension[t])!==null&&o!==void 0?o:[]);return{set:Md(i,n.mapping,n.doc,s),widgetKeys:s}}function ju(t,e){let n=Object.values(e).flatMap(r=>r.find());return z.create(t,n)}function Wu(t){let e=new Set;for(let n of Object.values(t))for(let r of n)e.add(r);return e}function M0(t,e){var n;switch((n=e.update)!==null&&n!==void 0?n:\"document\"){case\"document\":if(e.createInRange)throw new Error(`[tiptap error]: Extension \"${t}\" provides createInRange() but does not use the \"changedRanges\" decoration update strategy.`);return;case\"changedRanges\":if(!e.createInRange)throw new Error(`[tiptap error]: Extension \"${t}\" uses the \"changedRanges\" decoration update strategy but does not provide createInRange().`);return;case\"manual\":if(e.createInRange)throw new Error(`[tiptap error]: Extension \"${t}\" uses the \"manual\" decoration update strategy, which is not compatible with createInRange(). createInRange() requires the \"changedRanges\" strategy.`);if(e.shouldUpdate)throw new Error(`[tiptap error]: Extension \"${t}\" cannot combine the \"manual\" decoration update strategy with shouldUpdate().`);return;default:throw new Error(`[tiptap error]: Extension \"${t}\" uses an unknown decoration update strategy. Expected \"document\", \"changedRanges\", or \"manual\".`)}}function v0(t,e,n){return n?!0:t.update===\"manual\"?!1:t.shouldUpdate?t.shouldUpdate(e):e.tr.docChanged}var E0=new Set;var A0=class{constructor(t){this.warnedWidgetKeys=new Set,this.warnedOutOfRangeExtensions=new Set,this.handleBeforeTransaction=({nextState:e})=>{let n=cn.getState(e);n&&this.warnDuplicateWidgetKeys(n)},this.editor=t.editor,this.entries=this.resolveEntries(t.entries),this.entries.forEach(({name:e,spec:n})=>M0(e,n)),this.plugin=this.entries.length>0?this.createPlugin():null,this.editor.on(\"beforeTransaction\",this.handleBeforeTransaction)}destroy(){this.editor.off(\"beforeTransaction\",this.handleBeforeTransaction)}liveWidgetKeys(){var t,e;return(t=(e=cn.getState(this.editor.state))===null||e===void 0?void 0:e.widgetKeys)!==null&&t!==void 0?t:E0}get mountedView(){return this.editor.isDestroyed?null:this.editor.view}resolveEntries(t){let e=[];for(let{name:n,addDecorations:r}of t){let o=r();o&&e.push({name:n,spec:o})}return e}createPlugin(){let{editor:t,entries:e}=this;return new R({key:cn,state:{init:(n,r)=>{let o={},i={};for(let{name:l,spec:a}of e){let{set:c,widgetKeys:u}=this.buildFullSet(l,a,r);o[l]=c,i[l]=u}let s={decorationSetsByExtension:o,widgetKeysByExtension:i,mergedDecorationSet:this.buildMergedSet(r.doc,o),widgetKeys:Wu(i)};return this.warnDuplicateWidgetKeys(s),s},apply:(n,r,o,i)=>{let s=n.getMeta(cn),l=s?.type===\"force\"&&!s.name,a=s?.type===\"force\"?s.name:void 0,c={},u={},d=new Set;return h0(t,()=>{for(let{name:f,spec:h}of e){let p=l||a===f;if(v0(h,{editor:t,tr:n,oldState:o,newState:i},p))if(h.update===\"changedRanges\"&&n.docChanged&&!p){let m=this.applyChangedRangesRecompute(f,h,r,n,i);c[f]=m.set,u[f]=m.widgetKeys,d.add(f)}else{let{set:m,widgetKeys:g}=this.buildFullSet(f,h,i);c[f]=m,u[f]=g,d.add(f)}else{let m=C0(f,r,n);c[f]=m.set,u[f]=m.widgetKeys}}}),d.size===0&&!n.docChanged?r:{decorationSetsByExtension:c,widgetKeysByExtension:u,mergedDecorationSet:this.mergeAfterApply({entries:e,previous:r,tr:n,decorationSetsByExtension:c,recomputedNames:d}),widgetKeys:Wu(u)}}},props:{decorations(n){var r,o;return(r=(o=cn.getState(n))===null||o===void 0?void 0:o.mergedDecorationSet)!==null&&r!==void 0?r:z.empty}}})}applyChangedRangesRecompute(t,e,n,r,o){let i=x0(r,o.doc);return i.type===\"full\"?this.buildFullSet(t,e,o):this.rebuildRanges(t,e,n,r,o,i.ranges)}rebuildRanges(t,e,n,r,o,i){var s,l;let a=(s=n.decorationSetsByExtension[t])!==null&&s!==void 0?s:z.empty,c=new Set((l=n.widgetKeysByExtension[t])!==null&&l!==void 0?l:[]),u=Md(a,r.mapping,r.doc,c),d=o.doc.content.size;for(let{from:f,to:h}of i){let p=u.find(f,h).filter(y=>Sd({position:y.from,from:f,to:h,docSize:d}));for(let y of p){let S=xd(y);S&&c.delete(S)}u=u.remove(p);let{decorations:m,widgetKeys:g}=wd(b0({decorations:this.runCreate(t,\"createInRange\",()=>e.createInRange({editor:this.editor,state:o,view:this.mountedView,from:f,to:h})),from:f,to:h,docSize:d,extensionName:t,warnedExtensions:this.warnedOutOfRangeExtensions}),t);u=u.add(o.doc,m);for(let y of g)c.add(y)}return{set:u,widgetKeys:c}}buildFullSet(t,e,n){let r=this.runCreate(t,\"create\",()=>e.create({editor:this.editor,state:n,view:this.mountedView}));return y0(n.doc,r,t)}runCreate(t,e,n){try{return n()}catch(r){return console.error(`[tiptap error]: Extension \"${t}\" threw in \\`addDecorations().${e}()\\`. Its decorations were dropped for this update.`,r),[]}}warnDuplicateWidgetKeys(t){if(!kd)return;if(t.widgetKeys.size===0){this.warnedWidgetKeys.clear();return}let e=k0(t.mergedDecorationSet),n=new Set(e.map(({key:r})=>r));for(let{key:r,extensions:o}of e){if(this.warnedWidgetKeys.has(r))continue;let i=Array.from(o).map(s=>`\"${s}\"`).join(\", \");console.warn(`[tiptap warn]: Duplicate widget decoration key \"${r}\" in extension${o.size===1?\"\":\"s\"} ${i}. Widget decoration keys must be globally unique, otherwise ProseMirror misplaces the widget DOM. Use a stable, unique key (e.g. \\`comment-\\${id}\\`).`)}this.warnedWidgetKeys=n}buildMergedSet(t,e){let n=Object.keys(e);return n.length===1?e[n[0]]:ju(t,e)}mergeAfterApply({entries:t,previous:e,tr:n,decorationSetsByExtension:r,recomputedNames:o}){return t.length===1?r[t[0].name]:o.size===0?e.mergedDecorationSet.map(n.mapping,n.doc):ju(n.doc,r)}};function T0(t,e,n){let r=document.querySelector(`style[data-tiptap-style${n?`-${n}`:\"\"}]`);if(r!==null)return r;let o=document.createElement(\"style\");return e&&o.setAttribute(\"nonce\",e),o.setAttribute(`data-tiptap-style${n?`-${n}`:\"\"}`,\"\"),o.innerHTML=t,document.getElementsByTagName(\"head\")[0].appendChild(o),o}function N0(t){return typeof t==\"number\"}function O0(t){return Object.prototype.toString.call(t).slice(8,-1)}function Gr(t){return O0(t)!==\"Object\"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function vd(t){return typeof t==\"string\"&&t.trim().length>0&&!/[;{}]/.test(t)}function R0(t,e){return t.replace(/^[ \\t]*/,n=>{let o=0;for(let i of n)o+=i===\"\t\"?4-o%4:1;return\" \".repeat(Math.max(0,o-e))})}function D0(t,e){let n=`text\n${t}\n`,r=e(n)[0];return(r?.type===\"paragraph\"||r?.type===\"text\")&&r.raw===n}function I0(t,e,n){var r;let o=e.split(`\n`),i=(r=n.isParagraphContinuation)!==null&&r!==void 0?r:(l=>D0(l,n.blockTokens)),s=0;for(let l of o){if(!l.trim()||!i(l))break;s+=1}return{mainContent:[t,...o.slice(0,s).map(l=>l.trimStart())].join(`\n`),nestedContent:o.slice(s).join(`\n`)}}function Is(t,e,n){let r=t.split(`\n`),o=[],i=\"\",s=0,l=e.baseIndentSize||2;for(;s<r.length;){let u=r[s],d=u.match(e.itemPattern);if(!d){if(o.length>0)break;if(u.trim()===\"\"){s+=1,i=`${i}${u}\n`;continue}else return}let f=e.extractItemData(d),{indentLevel:h,mainContent:p}=f;i=`${i}${u}\n`;let m=[p];for(s+=1;s<r.length;){var a;let k=r[s];if(k.trim()===\"\"){var c;let x=r.slice(s+1).findIndex(O=>O.trim()!==\"\");if(x===-1)break;if((((c=r[s+1+x].match(/^(\\s*)/))===null||c===void 0||(c=c[1])===null||c===void 0?void 0:c.length)||0)>h){m.push(k),i=`${i}${k}\n`,s+=1;continue}else break}if((((a=k.match(/^(\\s*)/))===null||a===void 0||(a=a[1])===null||a===void 0?void 0:a.length)||0)>h)m.push(k),i=`${i}${k}\n`,s+=1;else break}let g,y=m.slice(1);if(y.length>0){let k=I0(p,y.map(O=>R0(O,h+l)).join(`\n`),n);f.mainContent=k.mainContent;let x=k.nestedContent;x.trim()&&(e.customNestedParser?g=e.customNestedParser(x):g=n.blockTokens(x))}let S=e.createToken(f,g);o.push(S)}if(o.length!==0)return{items:o,raw:i.slice(0,t.length)}}var Vu=4;function _u(t){let e=0;for(let n of t)e=n===\"\t\"?e+Vu-e%Vu:e+1;return e}function Ps(t,e,n,r,o){if(!t||!Array.isArray(t.content))return\"\";let i=typeof n==\"function\"?n(r):n,[s,...l]=t.content,a=e.renderChildren([s]),c=`${i}${o?.indentMainContent?a.split(`\n`).map((u,d)=>d===0?u:e.indent(u)).join(`\n`):a}`;return l&&l.length>0&&l.forEach((u,d)=>{var f,h;let p=(f=(h=e.renderChild)===null||h===void 0?void 0:h.call(e,u,d+1))!==null&&f!==void 0?f:e.renderChildren([u]);if(p!=null){let m=y=>{if(!o?.alignNestedToPrefix)return e.indent(y);let S=e.indent(\"\"),k=_u(i);return(_u(S)>=k?S:\" \".repeat(k))+y},g=p.split(`\n`).map(y=>m(y||\"\")).join(`\n`);c+=u.type===\"paragraph\"?`\n\n${g}`:`\n${g}`}}),c}function Ed(t,e){let n={...t};return Gr(t)&&Gr(e)&&Object.keys(e).forEach(r=>{Gr(e[r])&&Gr(t[r])?n[r]=Ed(t[r],e[r]):n[r]=e[r]}),n}function P0(t,e,n={}){let{state:r}=e,{doc:o,tr:i}=r,s=t;o.descendants((l,a)=>{let c=i.mapping.map(a),u=i.mapping.map(a)+l.nodeSize,d=null;if(l.marks.forEach(h=>{if(h!==s)return!1;d=h}),!d)return;let f=!1;if(Object.keys(n).forEach(h=>{n[h]!==d.attrs[h]&&(f=!0)}),f){let h=t.type.create({...t.attrs,...n});i.removeMark(c,u,t.type),i.addMark(c,u,h)}}),i.docChanged&&e.view.dispatch(i)}var yn=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!==null&&e!==void 0?e:!0}},L0=(t,e)=>{if(vs(e))return e.exec(t);let n=e(t);if(!n)return null;let r=[n.text];return r.index=n.index,r.input=t,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: \"inputRuleMatch.replaceWith\" must be part of \"inputRuleMatch.text\".'),r.push(n.replaceWith)),r};function $0(t){let{editor:e,from:n,to:r,text:o,insertText:i}=t;if(!i)return{inputTransaction:null,tr:e.view.state.tr};let s=e.view.state.tr.insertText(o,n,r);return{inputTransaction:s,tr:At.create({doc:s.doc,selection:s.selection,storedMarks:s.storedMarks}).tr}}function z0(t){let{editor:e,from:n,to:r,text:o,rule:i,match:s,plugin:l,insertText:a}=t,{view:c}=e,{inputTransaction:u,tr:d}=$0({editor:e,from:n,to:r,text:o,insertText:a}),f=u?n+o.length:r,h=eo({state:c.state,transaction:d}),p={from:n-(s[0].length-o.length),to:f},{commands:m,chain:g,can:y}=new dn({editor:e,state:h});return i.handler({state:h,range:p,match:s,commands:m,chain:g,can:y})===null||!d.steps.length?!1:(u&&(c.dispatch(u),!c.state.doc.eq(u.doc))||(xu(d),d.setMeta(\"inputRule\",!0),i.undoable&&d.setMeta(l,{transform:d,from:n,to:f,text:o}),c.dispatch(d)),!0)}function B0(t,e,n){let r=e[0].length-n.length;if(r<=0)return!0;let o=t.parentOffset-r;return o>=0&&t.parent.textBetween(o,t.parentOffset)===e[0].slice(0,r)}function Xr(t){var e;let{editor:n,from:r,to:o,text:i,rules:s,plugin:l,insertText:a}=t,{view:c}=n;if(c.composing)return!1;let u=c.state.doc.resolve(r);if(u.parent.type.spec.code||!((e=u.nodeBefore||u.nodeAfter)===null||e===void 0)&&e.marks.find(f=>f.type.spec.code))return!1;let d=Py(u)+i;for(let f of s){let h=L0(d,f.find);if(!(!h||!B0(u,h,i))&&z0({editor:n,from:r,to:o,text:i,rule:f,match:h,plugin:l,insertText:a}))return!0}return!1}function F0(t){let{editor:e,rules:n}=t,r=new R({state:{init(){return null},apply(o,i,s){let l=o.getMeta(r);if(l)return l;let a=o.getMeta(\"applyInputRules\");return a&&setTimeout(()=>{let{text:c}=a;typeof c==\"string\"?c=c:c=Ns(b.from(c),s.schema);let{from:u}=a,d=u+c.length;Xr({editor:e,from:u,to:d,text:c,rules:n,plugin:r})}),o.selectionSet||o.docChanged?null:i}},props:{handleTextInput(o,i,s,l){return Xr({editor:e,from:i,to:s,text:l,rules:n,plugin:r,insertText:!0})},handleDOMEvents:{compositionend:o=>(setTimeout(()=>{let{$cursor:i}=o.state.selection;i&&Xr({editor:e,from:i.pos,to:i.pos,text:\"\",rules:n,plugin:r})}),!1)},handleKeyDown(o,i){if(i.key!==\"Enter\")return!1;let{$cursor:s}=o.state.selection;return s?Xr({editor:e,from:s.pos,to:s.pos,text:`\n`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}var Ls=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{...L(v(this,\"addOptions\",{name:this.name}))}}get storage(){return{...L(v(this,\"addStorage\",{name:this.name,options:this.options}))}}configure(t={}){let e=this.extend({...this.config,addOptions:()=>Ed(this.options,t)});return e.name=this.name,e.parent=this.parent,this.child=null,e}extend(t={}){let 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}},Ze=class Ad extends Ls{constructor(...e){super(...e),this.type=\"mark\"}static create(e={}){let n=typeof e==\"function\"?e():e;return new Ad(n)}static handleExit({editor:e,mark:n}){let{tr:r}=e.state,o=e.state.selection.$from;if(o.pos===o.end()){let i=o.marks();if(!i.find(l=>l?.type.name===n.name))return!1;let s=i.find(l=>l?.type.name===n.name);return s&&r.removeStoredMark(s),r.insertText(\" \",o.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){let n=typeof e==\"function\"?e():e;return super.extend(n)}},$s=class{constructor(t){this.find=t.find,this.handler=t.handler}},H0=(t,e,n)=>{if(vs(e))return[...t.matchAll(e)];let r=e(t,n);return r?r.map(o=>{let i=[o.text];return i.index=o.index,i.input=t,i.data=o.data,o.replaceWith&&(o.text.includes(o.replaceWith)||console.warn('[tiptap warn]: \"pasteRuleMatch.replaceWith\" must be part of \"pasteRuleMatch.text\".'),i.push(o.replaceWith)),i}):[]};function j0(t){let{editor:e,state:n,from:r,to:o,rule:i,pasteEvent:s,dropEvent:l}=t,{commands:a,chain:c,can:u}=new dn({editor:e,state:n}),d=[];return n.doc.nodesBetween(r,o,(f,h)=>{var p,m,g,y;if(!((p=f.type)===null||p===void 0||(p=p.spec)===null||p===void 0)&&p.code||!(f.isText||f.isTextblock||f.isInline))return;let S=(m=(g=(y=f.content)===null||y===void 0?void 0:y.size)!==null&&g!==void 0?g:f.nodeSize)!==null&&m!==void 0?m:0,k=Math.max(r,h),x=Math.min(o,h+S);if(k>=x)return;let O=f.isText?f.text||\"\":f.textBetween(k-h,x-h,void 0,\"\\uFFFC\");H0(O,i.find,s).forEach(H=>{if(H.index===void 0)return;let T=k+H.index+1,I=T+H[0].length,F={from:n.tr.mapping.map(T),to:n.tr.mapping.map(I)},W=i.handler({state:n,range:F,match:H,commands:a,chain:c,can:u,pasteEvent:s,dropEvent:l});d.push(W)})}),d.every(f=>f!==null)}var an=null,W0=t=>{var e;let n=new ClipboardEvent(\"paste\",{clipboardData:new DataTransfer});return(e=n.clipboardData)===null||e===void 0||e.setData(\"text/html\",t),n};function V0(t){let{editor:e,rules:n}=t,r=null,o=!1,i=!1,s=typeof ClipboardEvent<\"u\"?new ClipboardEvent(\"paste\"):null,l;try{l=typeof DragEvent<\"u\"?new DragEvent(\"drop\"):null}catch{l=null}let a=({state:c,from:u,to:d,rule:f,pasteEvt:h})=>{let p=c.tr,m=eo({state:c,transaction:p});if(!(!j0({editor:e,state:m,from:Math.max(u-1,0),to:d.b-1,rule:f,pasteEvent:h,dropEvent:l})||!p.steps.length)){try{l=typeof DragEvent<\"u\"?new DragEvent(\"drop\"):null}catch{l=null}return s=typeof ClipboardEvent<\"u\"?new ClipboardEvent(\"paste\"):null,p}};return e.on(\"destroy\",()=>{an===e&&(an=null)}),n.map(c=>new R({view(u){let d=h=>{var p;r=!((p=u.dom.parentElement)===null||p===void 0)&&p.contains(h.target)?u.dom.parentElement:null,r&&(an=e)},f=()=>{an&&(an=null)};return window.addEventListener(\"dragstart\",d),window.addEventListener(\"dragend\",f),{destroy(){window.removeEventListener(\"dragstart\",d),window.removeEventListener(\"dragend\",f)}}},props:{handleDOMEvents:{drop:(u,d)=>{if(i=r===u.dom.parentElement,l=d,!i){let f=an;f?.isEditable&&setTimeout(()=>{if(f.isDestroyed)return;let h=f.state.selection;h&&f.commands.deleteRange({from:h.from,to:h.to})},10)}return!1},paste:(u,d)=>{var f;let h=(f=d.clipboardData)===null||f===void 0?void 0:f.getData(\"text/html\");return s=d,o=!!h?.includes(\"data-pm-slice\"),!1}}},appendTransaction:(u,d,f)=>{let h=u[0],p=h.getMeta(\"uiEvent\")===\"paste\"&&!o,m=h.getMeta(\"uiEvent\")===\"drop\"&&!i,g=h.getMeta(\"applyPasteRules\"),y=!!g;if(!p&&!m&&!y)return;if(y){let{text:x}=g;typeof x==\"string\"?x=x:x=Ns(b.from(x),f.schema);let{from:O}=g,H=O+x.length,T=W0(x);return a({rule:c,state:f,from:O,to:{b:H},pasteEvt:T})}let S=d.doc.content.findDiffStart(f.doc.content),k=d.doc.content.findDiffEnd(f.doc.content);if(!(!N0(S)||!k||S===k.b))return a({rule:c,state:f,from:S,to:k,pasteEvt:s})}}))}var ro=class{constructor(t,e){this.splittableMarks=[],this.nonClearableMarks=[],this.decorationManager=null,this.editor=e,this.baseExtensions=t,this.extensions=sd(t),this.hasSchemaSpec=e.options.schemaSpec!==void 0,this.schema=Ny(this.extensions,e,e.options.schemaSpec),this.setupExtensions()}get commands(){return this.extensions.reduce((t,e)=>{let n=v(e,\"addCommands\",{name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:ln(e.name,this.schema)});return n?{...t,...n()}:t},{})}get plugins(){let{editor:t}=this,e=Yn([...this.extensions].reverse()).flatMap(r=>{let o={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:ln(r.name,this.schema)},i=[],s=v(r,\"addKeyboardShortcuts\",o),l={};if(r.type===\"mark\"&&v(r,\"exitable\",o)&&(l.ArrowRight=()=>Ze.handleExit({editor:t,mark:r})),s){let f=Object.fromEntries(Object.entries(s()).map(([h,p])=>[h,()=>p({editor:t})]));l={...l,...f}}let a=bu(l);i.push(a);let c=v(r,\"addInputRules\",o);if(zu(r,t.options.enableInputRules)&&c){let f=c();if(f&&f.length){let h=F0({editor:t,rules:f}),p=Array.isArray(h)?h:[h];i.push(...p)}}let u=v(r,\"addPasteRules\",o);if(zu(r,t.options.enablePasteRules)&&u){let f=u();if(f&&f.length){let h=V0({editor:t,rules:f});i.push(...h)}}let d=v(r,\"addProseMirrorPlugins\",o);if(d){let f=d();i.push(...f)}return i}),n=this.createDecorationPlugin();return n&&e.push(n),e}createDecorationPlugin(){var t;let{editor:e}=this;(t=this.decorationManager)===null||t===void 0||t.destroy();let n=[];return this.extensions.forEach(r=>{let o=v(r,\"addDecorations\",{name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:e,type:ln(r.name,this.schema)});o&&n.push({name:r.name,addDecorations:o})}),this.decorationManager=new A0({editor:e,entries:n}),this.decorationManager.plugin}get attributes(){let t=Os(this.extensions);return this.hasSchemaSpec?od(t,this.schema):t}get nodeViews(){let{editor:t}=this,{nodeExtensions:e}=hn(this.extensions);return Object.fromEntries(e.filter(n=>!!v(n,\"addNodeView\")).map(n=>{let r=this.attributes.filter(l=>l.type===n.name),o=v(n,\"addNodeView\",{name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Q(n.name,this.schema)});if(!o)return[];let i=o();if(!i)return[];let s=(l,a,c,u,d)=>{let f=pt(l,r);return i({node:l,view:a,getPos:c,decorations:u,innerDecorations:d,editor:t,extension:n,HTMLAttributes:f})};return[n.name,s]}))}dispatchTransaction(t){let{editor:e}=this;return Yn([...this.extensions].reverse()).reduceRight((n,r)=>{let o={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:e,type:ln(r.name,this.schema)},i=v(r,\"dispatchTransaction\",o);return i?s=>{i.call(o,{transaction:s,next:n})}:n},t)}transformPastedHTML(t){let{editor:e}=this;return Yn([...this.extensions]).reduce((n,r)=>{let o={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:e,type:ln(r.name,this.schema)},i=v(r,\"transformPastedHTML\",o);return i?(s,l)=>{let a=n(s,l);return i.call(o,a)}:n},t||(n=>n))}get markViews(){let{editor:t}=this,{markExtensions:e}=hn(this.extensions);return Object.fromEntries(e.filter(n=>!!v(n,\"addMarkView\")).map(n=>{let r=this.attributes.filter(s=>s.type===n.name),o=v(n,\"addMarkView\",{name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Qe(n.name,this.schema)});if(!o)return[];let i=(s,l,a)=>{let c=pt(s,r);return o()({mark:s,view:l,inline:a,editor:t,extension:n,HTMLAttributes:c,updateAttributes:u=>{P0(s,t,u)}})};return[n.name,i]}))}destroy(){var t;(t=this.decorationManager)===null||t===void 0||t.destroy(),this.extensions.forEach(e=>{let n=e;for(;n.parent;){let r=n.parent;r.child===n&&(r.child=null),n=r}}),this.extensions=[],this.baseExtensions=[],this.decorationManager=null,this.schema=null,this.editor=null}setupExtensions(){let t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(e=>[e.name,e.storage])),t.forEach(e=>{let n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:ln(e.name,this.schema)};if(e.type===\"mark\"){var r,o;(!((r=L(v(e,\"keepOnSplit\",n)))!==null&&r!==void 0)||r)&&this.splittableMarks.push(e.name),!((o=L(v(e,\"clearable\",n)))!==null&&o!==void 0)||o||this.nonClearableMarks.push(e.name)}let i=v(e,\"onBeforeCreate\",n),s=v(e,\"onCreate\",n),l=v(e,\"onUpdate\",n),a=v(e,\"onSelectionUpdate\",n),c=v(e,\"onTransaction\",n),u=v(e,\"onFocus\",n),d=v(e,\"onBlur\",n),f=v(e,\"onDestroy\",n);i&&this.editor.on(\"beforeCreate\",i),s&&this.editor.on(\"create\",s),l&&this.editor.on(\"update\",l),a&&this.editor.on(\"selectionUpdate\",a),c&&this.editor.on(\"transaction\",c),u&&this.editor.on(\"focus\",u),d&&this.editor.on(\"blur\",d),f&&this.editor.on(\"destroy\",f)})}};ro.resolve=sd;ro.sort=Yn;ro.flatten=Ts;var V=class Td extends Ls{constructor(...e){super(...e),this.type=\"extension\"}static create(e={}){let n=typeof e==\"function\"?e():e;return new Td(n)}configure(e){return super.configure(e)}extend(e){let n=typeof e==\"function\"?e():e;return super.extend(n)}},_0=V.create({name:\"clipboardTextSerializer\",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new R({key:new P(\"clipboardTextSerializer\"),props:{clipboardTextSerializer:()=>{let{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:o}=e,i=ad(n),{blockSeparator:s}=this.options,l={...s!==void 0?{blockSeparator:s}:{},textSerializers:i};return[...o.ranges].sort((a,c)=>a.$from.pos-c.$from.pos).map(({$from:a,$to:c})=>ld(r,{from:a.pos,to:c.pos},l)).join(s??`\n\n`)}}})]}}),K0=V.create({name:\"commands\",addCommands(){return{...f0}}}),U0=V.create({name:\"delete\",onUpdate({transaction:t,appendedTransactions:e}){var n,r;let o=()=>{var i,s,l;if((i=(s=this.editor.options.coreExtensionOptions)===null||s===void 0||(s=s.delete)===null||s===void 0||(l=s.filterTransaction)===null||l===void 0?void 0:l.call(s,t))!==null&&i!==void 0?i:t.getMeta(\"y-sync$\"))return;let a=As(t.before,[t,...e]);mn(a).forEach(u=>{a.mapping.mapResult(u.oldRange.from).deletedAfter&&a.mapping.mapResult(u.oldRange.to).deletedBefore&&a.before.nodesBetween(u.oldRange.from,u.oldRange.to,(d,f)=>{let h=f+d.nodeSize-2,p=u.oldRange.from<=f&&h<=u.oldRange.to;this.editor.emit(\"delete\",{type:\"node\",node:d,from:f,to:h,newFrom:a.mapping.map(f),newTo:a.mapping.map(h),deletedRange:u.oldRange,newRange:u.newRange,partial:!p,editor:this.editor,transaction:t,combinedTransform:a})})});let c=a.mapping;a.steps.forEach((u,d)=>{if(u instanceof _e){var f,h;let p=c.slice(d).map(u.from,-1),m=c.slice(d).map(u.to),g=c.invert().map(p,-1),y=c.invert().map(m),S=p>0?(f=a.doc.nodeAt(p-1))===null||f===void 0?void 0:f.marks.some(x=>x.eq(u.mark)):!1,k=(h=a.doc.nodeAt(m))===null||h===void 0?void 0:h.marks.some(x=>x.eq(u.mark));this.editor.emit(\"delete\",{type:\"mark\",mark:u.mark,from:u.from,to:u.to,deletedRange:{from:g,to:y},newRange:{from:p,to:m},partial:!!(k||S),editor:this.editor,transaction:t,combinedTransform:a})}})};!((n=(r=this.editor.options.coreExtensionOptions)===null||r===void 0||(r=r.delete)===null||r===void 0?void 0:r.async)!==null&&n!==void 0)||n?setTimeout(o,0):o()}}),J0=V.create({name:\"drop\",addProseMirrorPlugins(){return[new R({key:new P(\"tiptapDrop\"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit(\"drop\",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),q0=V.create({name:\"editable\",addProseMirrorPlugins(){return[new R({key:new P(\"editable\"),props:{editable:()=>this.editor.options.editable}})]}}),G0=new P(\"focusEvents\"),X0=V.create({name:\"focusEvents\",addProseMirrorPlugins(){let{editor:t}=this;return[new R({key:G0,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;let r=t.state.tr.setMeta(\"focus\",{event:n}).setMeta(\"addToHistory\",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;let r=t.state.tr.setMeta(\"blur\",{event:n}).setMeta(\"addToHistory\",!1);return e.dispatch(r),!1}}}})]}}),Y0=V.create({name:\"keymap\",addKeyboardShortcuts(){let t=()=>this.editor.commands.first(({commands:s})=>[()=>s.undoInputRule(),()=>s.command(({tr:l})=>{let{selection:a,doc:c}=l,{empty:u,$anchor:d}=a,{pos:f,parent:h}=d,p=d.parent.isTextblock&&f>0?l.doc.resolve(f-1):d,m=p.parent.type.spec.isolating,g=d.pos-d.parentOffset,y=m&&p.parent.childCount===1?g===d.pos:E.atStart(c).from===f;return!u||!h.type.isTextblock||h.textContent.length||!y||y&&d.parent.type.name===\"paragraph\"?!1:s.clearNodes()}),()=>s.deleteSelection(),()=>s.joinBackward(),()=>s.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:s})=>[()=>s.deleteSelection(),()=>s.deleteCurrentNode(),()=>s.joinForward(),()=>s.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:s})=>[()=>s.newlineInCode(),()=>s.createParagraphNear(),()=>s.liftEmptyBlock(),()=>s.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={...r},i={...r,\"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 Zr()||td()?i:o},addProseMirrorPlugins(){return[new R({key:new P(\"clearDocument\"),appendTransaction:(t,e,n)=>{if(t.some(h=>h.getMeta(\"composition\")))return;let r=t.some(h=>h.docChanged)&&!e.doc.eq(n.doc),o=t.some(h=>h.getMeta(\"preventClearDocument\"));if(!r||o)return;let{empty:i,from:s,to:l}=e.selection,a=E.atStart(e.doc).from,c=E.atEnd(e.doc).to;if(i||!(s===a&&l===c)||!gn(n.doc))return;let u=n.tr,d=eo({state:n,transaction:u}),{commands:f}=new dn({editor:this.editor,state:d});if(f.clearNodes(),!!u.steps.length)return u}})]}}),Q0=V.create({name:\"paste\",addProseMirrorPlugins(){return[new R({key:new P(\"tiptapPaste\"),props:{handlePaste:(t,e,n)=>{this.editor.emit(\"paste\",{editor:this.editor,event:e,slice:n})}}})]}}),Z0=V.create({name:\"tabindex\",addOptions(){return{value:void 0}},addProseMirrorPlugins(){return[new R({key:new P(\"tabindex\"),props:{attributes:()=>{var t;return!this.editor.isEditable&&this.options.value===void 0?{}:{tabindex:(t=this.options.value)!==null&&t!==void 0?t:\"0\"}}}})]}}),eb=V.create({name:\"textDirection\",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];let{nodeExtensions:t}=hn(this.extensions);return[{types:t.filter(e=>e.name!==\"text\").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{let n=e.getAttribute(\"dir\");return n&&(n===\"ltr\"||n===\"rtl\"||n===\"auto\")?n:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new R({key:new P(\"textDirection\"),props:{attributes:()=>{let t=this.options.direction;return t?{dir:t}:{}}}})]}});var Ku=!1;function tb(t){if(Ku)return;Ku=!0;let e;try{let n=G.fromJSON(t,{from:0,to:0});if(!zy(n))return;e=n.slice.content}catch{return}e instanceof b||console.warn(\"[tiptap warn]: prosemirror-model is loaded more than once. Wrapping and splitting nodes will fail. Deduplicate it in your lock file, or alias it to a single copy in your bundler.\")}var nb=class Xn{get name(){return this.node.type.name}constructor(e,n,r=!1,o=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,this.currentNode=o}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!==null&&e!==void 0?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let n=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can\\u2019t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:n,to:r},e)}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(this.depth===0)return null;let e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new Xn(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 Xn(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 Xn(e,this.editor)}get children(){let e=[];return this.node.content.forEach((n,r)=>{let o=n.isBlock&&!n.isTextblock,i=n.isAtom&&!n.isText,s=n.isInline,l=this.pos+r+(i?0:1);if(l<0||l>this.resolvedPos.doc.nodeSize-2)return;let a=this.resolvedPos.doc.resolve(l);if(!o&&!s&&a.depth<=this.depth)return;let c=new Xn(a,this.editor,o,o||s?n:null);o&&(c.actualDepth=this.depth+1),e.push(c)}),e}get firstChild(){return this.children[0]||null}get lastChild(){let e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,o=this.parent;for(;o&&!r;){if(o.node.type.name===e)if(Object.keys(n).length>0){let i=o.node.attrs,s=Object.keys(n);for(let l=0;l<s.length;l+=1){let a=s[l];if(i[a]!==n[a])break}}else r=o;o=o.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let o=[];if(!this.children||this.children.length===0)return o;let i=Object.keys(n);return this.children.forEach(s=>{r&&o.length>0||(s.node.type.name===e&&i.every(l=>n[l]===s.node.attrs[l])&&o.push(s),!(r&&o.length>0)&&(o=o.concat(s.querySelectorAll(e,n,r))))}),o}setAttribute(e){let{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},rb=`.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}`,Nd=class extends m0{constructor(t={}){super(),this.css=null,this.className=\"tiptap\",this.editorView=null,this.isFocused=!1,this.destroyed=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.hasWarnedStaleDecorationRead=!1,this.options={element:typeof document<\"u\"?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:n})=>{throw n},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:By,createMappablePosition:Fy},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:n,slice:r,moved:o})=>this.options.onDrop(n,r,o)),this.on(\"paste\",({event:n,slice:r})=>this.options.onPaste(n,r)),this.on(\"delete\",this.options.onDelete);let e=this.createDoc();if(!this.editorState){let n=Ss(e,this.options.autofocus);this.editorState=At.create({doc:e,schema:this.schema,selection:n||void 0})}tb(this.schema),this.options.element&&this.mount(this.options.element)}mount(t){if(typeof document>\"u\")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||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit(\"create\",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){this.editorState=this.editorView.state;let t=this.editorView.dom;t?.editor&&delete t.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove==\"function\"?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?this.commandManager.chain():dn.createFakeChain()}can(){return this.commandManager?this.commandManager.can():dn.createFallbackCan()}injectCSS(){this.options.injectCSS&&typeof document<\"u\"&&(this.css=T0(rb,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,attributes:this.getEditorViewAttributes()}),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(e===\"state\")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 kd&&!this.hasWarnedStaleDecorationRead&&p0(this)&&(this.hasWarnedStaleDecorationRead=!0,console.warn(\"[tiptap warn]: `editor.state` was read while decoration `create()` was running. It returns the pre-transaction document. Use the `state` argument passed to `create()` instead. Helpers like `editor.isActive()` read `editor.state` too, so pass `state` to their standalone versions instead of calling them on the editor.\")),this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(t,e){let n=Cs(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(t){if(this.isDestroyed)return;let e=this.state.plugins,n=e;if([].concat(t).forEach(o=>{let i=typeof o==\"string\"?`${o}$`:o.key;n=n.filter(s=>!s.key.startsWith(i))}),e.length===n.length)return;let r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var t,e;let n=[...this.options.enableCoreExtensions?[q0,_0.configure({blockSeparator:(t=this.options.coreExtensionOptions)===null||t===void 0||(t=t.clipboardTextSerializer)===null||t===void 0?void 0:t.blockSeparator}),K0,X0,Y0,Z0.configure({value:(e=this.options.coreExtensionOptions)===null||e===void 0||(e=e.tabindex)===null||e===void 0?void 0:e.value}),J0,Q0,U0,eb.configure({direction:this.options.textDirection})].filter(r=>typeof this.options.enableCoreExtensions==\"object\"?this.options.enableCoreExtensions[r.name]!==!1:!0):[],...this.options.extensions].filter(r=>[\"extension\",\"node\",\"mark\"].includes(r?.type));this.extensionManager=new ro(n,this)}createCommandManager(){this.commandManager=new dn({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=xs(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;let n=xs(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1});return this.editorState=At.create({doc:n,schema:this.schema,selection:Ss(n,this.options.autofocus)||void 0}),this.emit(\"contentError\",{editor:this,error:e,disableCollaboration:()=>{\"collaboration\"in this.storage&&typeof this.storage.collaboration==\"object\"&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(r=>r.name!==\"collaboration\"),this.createExtensionManager()}}),this.editorState.doc}return t}getEditorViewAttributes(){var t;let e=(t=this.options.editorProps)===null||t===void 0?void 0:t.attributes;return Cs(e)?n=>({role:\"textbox\",...e(n)}):{role:\"textbox\",...e}}createView(t){let{editorProps:e,enableExtensionDispatchTransaction:n}=this.options,r=e.dispatchTransaction||this.dispatchTransaction.bind(this),o=n?this.extensionManager.dispatchTransaction(r):r,i=e.transformPastedHTML,s=this.extensionManager.transformPastedHTML(i);this.editorView=new _n(t,{...e,attributes:this.getEditorViewAttributes(),dispatchTransaction:o,transformPastedHTML:s,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});let l=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(l),this.prependClass(),this.injectCSS();let a=this.view.dom;a.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;let e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach(c=>{var u;return(u=this.capturedTransaction)===null||u===void 0?void 0:u.step(c)});return}let{state:e,transactions:n}=this.state.applyTransaction(t),r=!this.state.selection.eq(e.selection),o=n.includes(t),i=this.state;if(this.emit(\"beforeTransaction\",{editor:this,transaction:t,nextState:e}),!o)return;this.view.updateState(e),this.emit(\"transaction\",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),r&&this.emit(\"selectionUpdate\",{editor:this,transaction:t});let s=n.findLast(c=>c.getMeta(\"focus\")||c.getMeta(\"blur\")),l=s?.getMeta(\"focus\"),a=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(c=>c.docChanged)||i.doc.eq(e.doc))&&this.emit(\"update\",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return Rs(this.state,t)}isActive(t,e){let n=typeof t==\"string\"?t:null,r=typeof t==\"string\"?e:t;return Ly(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Ns(this.state.doc.content,this.schema)}getText(t){let{blockSeparator:e=`\n\n`,textSerializers:n={}}=t||{};return Oy(this.state.doc,{blockSeparator:e,textSerializers:{...ad(this.schema),...n}})}get isEmpty(){return gn(this.state.doc)}destroy(){this.destroyed||(this.destroyed=!0,this.emit(\"destroy\"),this.unmount(),this.removeAllListeners(),this.extensionManager.destroy(),this.extensionManager=null,this.schema=null,this.commandManager=null,this.extensionStorage={})}get isDestroyed(){var t,e;return(t=(e=this.editorView)===null||e===void 0?void 0:e.isDestroyed)!==null&&t!==void 0?t:!0}$node(t,e){var n;return((n=this.$doc)===null||n===void 0?void 0:n.querySelector(t,e))||null}$nodes(t,e){var n;return((n=this.$doc)===null||n===void 0?void 0:n.querySelectorAll(t,e))||null}$pos(t){let e=this.state.doc.resolve(t),n=t>0&&e.nodeAfter&&!e.nodeAfter.isText&&e.nodeAfter.isAtom?e.nodeAfter:null;return new nb(e,this,!1,n)}get $doc(){return this.$pos(0)}};function ze(t){return new yn({find:t.find,handler:({state:e,range:n,match:r})=>{let o=L(t.getAttributes,void 0,r);if(o===!1||o===null)return null;let{tr:i}=e,s=r[r.length-1],l=r[0];if(s){let a=l.search(/\\S/),c=n.from+l.indexOf(s),u=c+s.length;if(Qn(n.from,n.to,e.doc).filter(f=>f.mark.type.excluded.find(h=>h===t.type&&h!==f.mark.type)).filter(f=>f.to>c).length)return null;u<n.to&&i.delete(u,n.to),c>n.from&&i.delete(n.from+a,c);let d=n.from+a+s.length;i.addMark(n.from+a,d,t.type.create(o||{})),i.removeStoredMark(t.type)}},undoable:t.undoable})}function Od(t){return new yn({find:t.find,handler:({state:e,range:n,match:r})=>{let o=L(t.getAttributes,void 0,r)||{},{tr:i}=e,s=n.from,l=n.to,a=t.type.create(o);if(r[1]){let c=s+r[0].lastIndexOf(r[1]);c>l?c=l:l=c+r[1].length;let u=r[0][r[0].length-1];i.insertText(u,s+r[0].length-1),i.replaceWith(c,l,a)}else if(r[0]){let c=t.type.isInline?s:s-1;i.insert(c,t.type.create(o)).delete(i.mapping.map(s),i.mapping.map(l))}i.scrollIntoView()},undoable:t.undoable})}function Zn(t){return new yn({find:t.find,handler:({state:e,range:n,match:r})=>{let o=e.doc.resolve(n.from),i=L(t.getAttributes,void 0,r)||{};if(!o.node(-1).canReplaceWith(o.index(-1),o.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 bn(t){return new yn({find:t.find,handler:({state:e,range:n,match:r,chain:o})=>{let i=L(t.getAttributes,void 0,r)||{},s=e.tr.delete(n.from,n.to),l=s.doc.resolve(n.from).blockRange(),a=l&&Xt(l,t.type,i);if(!a)return null;if(s.wrap(l,a),t.keepMarks&&t.editor){let{selection:u,storedMarks:d}=e,{splittableMarks:f}=t.editor.extensionManager,h=d||u.$to.parentOffset&&u.$from.marks();if(h){let p=h.filter(m=>f.includes(m.type.name));s.ensureMarks(p)}}if(t.keepAttributes){let u=t.type.name===\"bulletList\"||t.type.name===\"orderedList\"?\"listItem\":\"taskList\";o().updateAttributes(u,i).run()}let c=s.doc.resolve(n.from-1).nodeBefore;c&&c.type===t.type&&Ne(s.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,c))&&s.join(n.from-1)},undoable:t.undoable})}var ob=t=>\"touches\"in t,Rd=class{constructor(t){var e,n,r,o,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=l=>{if(!this.isResizing||!this.activeHandle)return;let a=l.clientX-this.startX,c=l.clientY-this.startY;this.handleResize(a,c)},this.handleTouchMove=l=>{if(!this.isResizing||!this.activeHandle)return;let a=l.touches[0];if(!a)return;let c=a.clientX-this.startX,u=a.clientY-this.startY;this.handleResize(c,u)},this.handleMouseUp=()=>{if(!this.isResizing)return;let l=this.element.offsetWidth,a=this.element.offsetHeight;this.onCommit(l,a),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=l=>{l.key===\"Shift\"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=l=>{l.key===\"Shift\"&&(this.isShiftKeyPressed=!1)},this.node=t.node,this.editor=t.editor,this.element=t.element,this.element.draggable=!1,this.contentElement=t.contentElement,this.getPos=t.getPos,this.onResize=t.onResize,this.onCommit=t.onCommit,this.onUpdate=t.onUpdate,!((e=t.options)===null||e===void 0)&&e.min&&(this.minSize={...this.minSize,...t.options.min}),!((n=t.options)===null||n===void 0)&&n.max&&(this.maxSize=t.options.max),!(t==null||(r=t.options)===null||r===void 0)&&r.directions&&(this.directions=t.options.directions),!((o=t.options)===null||o===void 0)&&o.preserveAspectRatio&&(this.preserveAspectRatio=t.options.preserveAspectRatio),!((i=t.options)===null||i===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||\"\"}),!((s=t.options)===null||s===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(){var t;return(t=this.contentElement)!==null&&t!==void 0?t:null}handleEditorUpdate(){let t=this.editor.isEditable;t!==this.lastEditableState&&(this.lastEditableState=t,t?t&&this.handleMap.size===0&&this.attachHandles():this.removeHandles())}update(t,e,n){return t.type!==this.node.type?!1:(this.node=t,this.onUpdate?this.onUpdate(t,e,n):!0)}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(){let t=document.createElement(\"div\");return t.dataset.resizeContainer=\"\",t.dataset.node=this.node.type.name,t.style.display=this.node.type.isInline?\"inline-flex\":\"flex\",this.classNames.container&&(t.className=this.classNames.container),t.appendChild(this.wrapper),t}createWrapper(){let 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){let 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){let n=e.includes(\"top\"),r=e.includes(\"bottom\"),o=e.includes(\"left\"),i=e.includes(\"right\");n&&(t.style.top=\"0\"),r&&(t.style.bottom=\"0\"),o&&(t.style.left=\"0\"),i&&(t.style.right=\"0\"),(e===\"top\"||e===\"bottom\")&&(t.style.left=\"0\",t.style.right=\"0\"),(e===\"left\"||e===\"right\")&&(t.style.top=\"0\",t.style.bottom=\"0\")}attachHandles(){this.directions.forEach(t=>{let e;this.createCustomHandle?e=this.createCustomHandle(t):e=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\",n=>this.handleResizeStart(n,t)),e.addEventListener(\"touchstart\",n=>this.handleResizeStart(n,t)),this.handleMap.set(t,e),this.wrapper.appendChild(e)})}removeHandles(){this.handleMap.forEach(t=>t.remove()),this.handleMap.clear()}applyInitialSize(){let 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,ob(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;let n=this.preserveAspectRatio||this.isShiftKeyPressed,{width:r,height:o}=this.calculateNewDimensions(this.activeHandle,t,e),i=this.applyConstraints(r,o,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 r=this.startWidth,o=this.startHeight,i=t.includes(\"right\"),s=t.includes(\"left\"),l=t.includes(\"bottom\"),a=t.includes(\"top\");return i?r=this.startWidth+e:s&&(r=this.startWidth-e),l?o=this.startHeight+n:a&&(o=this.startHeight-n),(t===\"right\"||t===\"left\")&&(r=this.startWidth+(i?e:-e)),(t===\"top\"||t===\"bottom\")&&(o=this.startHeight+(l?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,o,t):{width:r,height:o}}applyConstraints(t,e,n){var r,o;if(!n){var i,s;let c=Math.max(this.minSize.width,t),u=Math.max(this.minSize.height,e);return!((i=this.maxSize)===null||i===void 0)&&i.width&&(c=Math.min(this.maxSize.width,c)),!((s=this.maxSize)===null||s===void 0)&&s.height&&(u=Math.min(this.maxSize.height,u)),{width:c,height:u}}let l=t,a=e;return l<this.minSize.width&&(l=this.minSize.width,a=l/this.aspectRatio),a<this.minSize.height&&(a=this.minSize.height,l=a*this.aspectRatio),!((r=this.maxSize)===null||r===void 0)&&r.width&&l>this.maxSize.width&&(l=this.maxSize.width,a=l/this.aspectRatio),!((o=this.maxSize)===null||o===void 0)&&o.height&&a>this.maxSize.height&&(a=this.maxSize.height,l=a*this.aspectRatio),{width:l,height:a}}applyAspectRatio(t,e,n){let r=n===\"left\"||n===\"right\",o=n===\"top\"||n===\"bottom\";return r?{width:t,height:t/this.aspectRatio}:o?{width:e*this.aspectRatio,height:e}:{width:t,height:t/this.aspectRatio}}};var K=class Dd extends Ls{constructor(...e){super(...e),this.type=\"node\"}static create(e={}){let n=typeof e==\"function\"?e():e;return new Dd(n)}configure(e){return super.configure(e)}extend(e){let n=typeof e==\"function\"?e():e;return super.extend(n)}};function Re(t){return new $s({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:o})=>{let i=L(t.getAttributes,void 0,r,o);if(i===!1||i===null)return null;let{tr:s}=e,l=r[r.length-1],a=r[0],c=n.to;if(l){let u=a.search(/\\S/),d=n.from+a.indexOf(l),f=d+l.length;if(Qn(n.from,n.to,e.doc).filter(h=>h.mark.type.excluded.find(p=>p===t.type&&p!==h.mark.type)).filter(h=>h.to>d).length)return null;f<n.to&&s.delete(f,n.to),d>n.from&&s.delete(n.from+u,d),c=n.from+u+l.length,s.addMark(n.from+u,c,t.type.create(i||{})),r.index!==void 0&&r.input!==void 0&&r.index+r[0].length>=r.input.length||s.removeStoredMark(t.type)}}})}var Id=K.create({name:\"doc\",topNode:!0,content:\"block+\",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`\n\n`):\"\"});var oo=\"&nbsp;\",zs=\"\\xA0\",Pd=K.create({name:\"paragraph\",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:\"block\",content:\"inline*\",parseHTML(){return[{tag:\"p\"}]},renderHTML({HTMLAttributes:t}){return[\"p\",B(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{let n=t.tokens||[];if(n.length===1&&n[0].type===\"image\")return e.parseChildren([n[0]]);let r=e.parseInline(n);return n.length===1&&n[0].type===\"text\"&&(n[0].raw===oo||n[0].text===oo||n[0].raw===zs||n[0].text===zs)&&r.length===1&&r[0].type===\"text\"&&(r[0].text===oo||r[0].text===zs)?e.createNode(\"paragraph\",void 0,[]):e.createNode(\"paragraph\",void 0,r)},renderMarkdown:(t,e,n)=>{if(!t)return\"\";let r=Array.isArray(t.content)?t.content:[];if(r.length===0){var o,i;let s=Array.isArray(n==null||(o=n.previousNode)===null||o===void 0?void 0:o.content)?n.previousNode.content:[];return(n==null||(i=n.previousNode)===null||i===void 0?void 0:i.type)===\"paragraph\"&&s.length===0?oo:\"\"}return e.renderChildren(r)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{\"Mod-Alt-0\":()=>this.editor.commands.setParagraph()}}});var Ld=K.create({name:\"text\",group:\"inline\",parseMarkdown:t=>({type:\"text\",text:t.text||\"\"}),renderMarkdown:t=>t.text||\"\"});var $d=new WeakSet,zd=new WeakSet;function Ht(t){let e=t;return $d.add(e),e}function Bs(t){return Array.isArray(t)&&$d.has(t)}function Bd(t){return t.flatMap(e=>e==null?[]:Array.isArray(e)&&zd.has(e)&&!Bs(e)?Bd(e):[e])}function ib(t,e){if(t===\"slot\")return 0;if(t instanceof Function){let o=t(e);return Array.isArray(o)&&!Bs(o)&&!zd.has(o)?Ht(o):o}let{children:n,...r}=e??{};if(t===\"svg\")throw new Error(\"SVG elements are not supported in the JSX syntax, use the array syntax instead\");if(Array.isArray(n)){if(Bs(n))return Ht([t,r,n]);if(n.length===0)return Ht([t,r]);let o=Bd(n);return o.length===0?Ht([t,r]):Ht([t,r,...o])}return n!=null?Ht([t,r,n]):Ht([t,r])}var Fs=(t,e)=>ib(t,e);var sb=/(?:^|\\s)(\\*\\*(?!\\s+\\*\\*)((?:[^*]+))\\*\\*(?!\\s+\\*\\*))$/,lb=/(?:^|\\s)(\\*\\*(?!\\s+\\*\\*)((?:[^*]+))\\*\\*(?!\\s+\\*\\*))/g,ab=/(?:^|\\s)(__(?!\\s+__)((?:[^_]+))__(?!\\s+__))$/,cb=/(?:^|\\s)(__(?!\\s+__)((?:[^_]+))__(?!\\s+__))/g,Fd=Ze.create({name:\"bold\",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:\"strong\"},{tag:\"b\",getAttrs:t=>t.style.fontWeight!==\"normal\"&&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 Fs(\"strong\",{...B(this.options.HTMLAttributes,t),children:Fs(\"slot\",{})})},markdownTokenName:\"strong\",parseMarkdown:(t,e)=>e.applyMark(\"bold\",e.parseInline(t.tokens||[])),markdownOptions:{htmlReopen:{open:\"<strong>\",close:\"</strong>\"}},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[ze({find:sb,type:this.type}),ze({find:ab,type:this.type})]},addPasteRules(){return[Re({find:lb,type:this.type}),Re({find:cb,type:this.type})]}});var ub=/(?:^|\\s)(\\*(?!\\s+\\*)((?:[^*]+))\\*(?!\\s+\\*))$/,db=/(?:^|\\s)(\\*(?!\\s+\\*)((?:[^*]+))\\*(?!\\s+\\*))/g,fb=/(?:^|\\s)(_(?!\\s+_)((?:[^_]+))_(?!\\s+_))$/,hb=/(?:^|\\s)(_(?!\\s+_)((?:[^_]+))_(?!\\s+_))/g,Hd=Ze.create({name:\"italic\",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:\"em\"},{tag:\"i\",getAttrs:t=>t.style.fontStyle!==\"normal\"&&null},{style:\"font-style=normal\",clearMark:t=>t.type.name===this.name},{style:\"font-style=italic\"}]},renderHTML({HTMLAttributes:t}){return[\"em\",B(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||[])),markdownOptions:{htmlReopen:{open:\"<em>\",close:\"</em>\"}},renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{\"Mod-i\":()=>this.editor.commands.toggleItalic(),\"Mod-I\":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[ze({find:ub,type:this.type}),ze({find:fb,type:this.type})]},addPasteRules(){return[Re({find:db,type:this.type}),Re({find:hb,type:this.type})]}});var pb=t=>{let e=/`([^`]+)`(?!`)$/.exec(t);return!e||e.index>0&&t[e.index-1]===\"`\"?null:{index:e.index,text:e[0],replaceWith:e[1]}},mb=t=>{let e=/`([^`]+)`(?!`)/g,n=[],r;for(;(r=e.exec(t))!==null;)r.index>0&&t[r.index-1]===\"`\"||n.push({index:r.index,text:r[0],replaceWith:r[1]});return n};function gb(t){let e=new Set((t.match(/`+/g)||[]).map(r=>r.length)),n=1;for(;e.has(n);)n+=1;return n}var jd=Ze.create({name:\"code\",addOptions(){return{HTMLAttributes:{}}},excludes:\"_\",code:!0,exitable:!0,parseHTML(){return[{tag:\"code\"}]},renderHTML({HTMLAttributes:t}){return[\"code\",B(this.options.HTMLAttributes,t),0]},markdownTokenName:\"codespan\",parseMarkdown:(t,e)=>e.applyMark(\"code\",[{type:\"text\",text:t.text||\"\"}]),renderMarkdown:(t,e,n)=>{var r;if(!t.content)return\"\";let o=typeof(n==null||(r=n.meta)===null||r===void 0?void 0:r.markText)==\"string\"?n.meta.markText:\"\",i=\"`\".repeat(gb(o)),s=o.startsWith(\"`\")||o.endsWith(\"`\")?\" \":\"\";return`${i}${s}${e.renderChildren(t.content)}${s}${i}`},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[ze({find:pb,type:this.type})]},addPasteRules(){return[Re({find:mb,type:this.type})]}});var Wd=K.create({name:\"heading\",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:\"inline*\",group:\"block\",defining:!0,addAttributes(){return{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]}`,B(this.options.HTMLAttributes,e),0]},parseMarkdown(t,e){let n=t.depth||1;return this.options.levels.includes(n)?e.createNode(\"heading\",{level:n},e.parseInline(t.tokens||[])):e.createNode(\"paragraph\",void 0,e.parseInline(t.tokens||[]))},renderMarkdown:(t,e)=>{var n;let r=!((n=t.attrs)===null||n===void 0)&&n.level?parseInt(t.attrs.level,10):1,o=\"#\".repeat(r);return t.content?`${o} ${e.renderChildren(t.content)}`:\"\"},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,\"paragraph\",t):!1}},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=>Zn({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\\\s$`),type:this.type,getAttributes:{level:t}}))}});var yb=\"listItem\",Vd=\"textStyle\",_d=/^\\s*([-+*])\\s$/,Hs=K.create({name:\"bulletList\",addOptions(){return{itemTypeName:\"listItem\",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:\"block list\",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:\"ul\"}]},renderHTML({HTMLAttributes:t}){return[\"ul\",B(this.options.HTMLAttributes,t),0]},markdownTokenName:\"list\",parseMarkdown:(t,e)=>t.type!==\"list\"||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(yb,this.editor.getAttributes(Vd)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{\"Mod-Shift-8\":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=bn({find:_d,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=bn({find:_d,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Vd),editor:this.editor})),[t]}}),bb=(t,e,n)=>{let{selection:r}=t;if(!r.empty)return null;let{$from:o}=r;if(!o.parent.isTextblock||o.parentOffset!==o.parent.content.size)return null;let i=-1;for(let h=o.depth;h>0;h-=1)if(o.node(h).type.name===e){i=h;break}if(i<0)return null;let s=o.node(i),l=o.index(i);if(l+1>=s.childCount)return null;let a=s.child(l+1);if(!n.includes(a.type.name))return null;let c=t.schema.nodes[e],u=!1;if(a.forEach(h=>{h.type===c&&h.childCount>1&&(u=!0)}),!u)return null;let d=t.doc.resolve(o.after()).nodeAfter;if(!d||!n.includes(d.type.name))return null;let f=[];return d.forEach(h=>{f.push(h)}),f.length===0?null:{listItemDepth:i,nestedList:d,nestedListPos:o.after(),insertPos:o.after(i),items:f}},kb=(t,e,n,r)=>{let o=bb(t,n,r);if(!o)return!1;let{selection:i}=t,{nestedList:s,nestedListPos:l,insertPos:a,items:c}=o,u=t.tr;u.delete(l,l+s.nodeSize);let d=u.mapping.map(a);return u.insert(d,b.from(c)),u.setSelection(i.map(u.doc,u.mapping)),e&&e(u),!0},wb=(t,e,n)=>kb(t.state,t.view.dispatch,e,n),Zd=(t,e)=>V.create({name:`${t}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){let n=()=>wb(this.editor,t,e);return{Delete:n,\"Mod-Delete\":n}}}),ef=[[1e3,\"m\"],[900,\"cm\"],[500,\"d\"],[400,\"cd\"],[100,\"c\"],[90,\"xc\"],[50,\"l\"],[40,\"xl\"],[10,\"x\"],[9,\"ix\"],[5,\"v\"],[4,\"iv\"],[1,\"i\"]],io=\"abcdefghijklmnopqrstuvwxyz\",tf=String.raw`\\d+|[ivxlcdmIVXLCDM]+|${\"[a-zA-Z]{1,2}\"}`;function ao(t){let e=t,n=\"\";for(let[r,o]of ef)for(;e>=r;)n+=o,e-=r;return n}function js(t){return ao(t).toUpperCase()}function nf(t){let e=t.toLowerCase(),n=0,r=0;for(;n<e.length;){let o=!1;for(let[i,s]of ef)if(e.startsWith(s,n)){r+=i,n+=s.length,o=!0;break}if(!o)return 0}return r}function Sb(t){if(!/^[ivxlcdmIVXLCDM]+$/.test(t))return!1;let e=nf(t);return e<=0?!1:(t===t.toLowerCase()?ao(e):js(e))===t}function xb(t){let e=t.toLowerCase();if(e.length===1)return e.charCodeAt(0)-97+1;if(e.length===2){let n=e.charCodeAt(0)-97,r=e.charCodeAt(1)-97;return(n+1)*26+r+1}return 0}function so(t){if(t<=26)return io[t-1];let e=Math.floor((t-1)/26)-1,n=(t-1)%26;return e<0?io[n]:io[e]+io[n]}function co(t){if(!(!t||/^\\d+$/.test(t))){if(Sb(t))return t===t.toLowerCase()?\"i\":\"I\";if(/^[a-z]{1,2}$/.test(t))return\"a\";if(/^[A-Z]{1,2}$/.test(t))return\"A\"}}function Ws(t){if(/^\\d+$/.test(t))return parseInt(t,10);let e=co(t);if(e===\"i\"||e===\"I\")return nf(t);if(e===\"a\"||e===\"A\"){let r=xb(t);return r>0?r:1}let n=parseInt(t,10);return Number.isNaN(n)?1:n}function Cb(t,e){if(t===\"numeric\")return String(e);switch(t){case\"a\":return so(e);case\"A\":return so(e).toUpperCase();case\"i\":return ao(e);case\"I\":return js(e);default:return String(e)}}function Mb(t){var e;if(t.length===0)return!1;let n=(e=co(t[0]))!==null&&e!==void 0?e:\"numeric\",r=Ws(t[0]);if(r<1)return!1;for(let o=0;o<t.length;o++){let i=Cb(n,r+o);if(t[o]!==i)return!1}return!0}function vb(t){return{type:co(t),start:Ws(t)}}function Eb(t){let{type:e,start:n}=vb(t),r={};return e&&(r.type=e),n!==1&&(r.start=n),r}function Ab(t,e,n=\". \"){let r=e+1;if(!t||t===\"1\")return`${r}${n}`;switch(t){case\"a\":return`${so(r)}${n}`;case\"A\":return`${so(r).toUpperCase()}${n}`;case\"i\":return`${ao(r)}${n}`;case\"I\":return`${js(r)}${n}`;default:return`${r}${n}`}}function Tb(t){return!t[0]||t[0].type===\"paragraph\"?t:[{type:\"paragraph\",content:[]},...t]}function Nb(t){var e,n;let r=(e=t.content)===null||e===void 0?void 0:e[0];return r?.type===\"paragraph\"&&!(!((n=r.content)===null||n===void 0)&&n.length)}var Ob=\"&nbsp;\",Kd=1,Rb=t=>{var e;return((e=t?.level)!==null&&e!==void 0?e:Kd)>Kd};function Db(t){var e,n;let r=(e=t.tokens)===null||e===void 0?void 0:e[0];return!!(t.text&&((n=t.tokens)===null||n===void 0?void 0:n.length)===1&&r?.type===\"list\"&&r.ordered&&r.raw===t.text)}function Ib(t,e){return e.tokenizeInline?e.parseInline(e.tokenizeInline(t)):e.parseInline([{type:\"text\",raw:t,text:t}])}var Vs=K.create({name:\"listItem\",addOptions(){return{HTMLAttributes:{},bulletListTypeName:\"bulletList\",orderedListTypeName:\"orderedList\"}},content:\"paragraph block*\",defining:!0,parseHTML(){return[{tag:\"li\"}]},renderHTML({HTMLAttributes:t}){return[\"li\",B(this.options.HTMLAttributes,t),0]},markdownTokenName:\"list_item\",parseMarkdown:(t,e)=>{var n;if(t.type!==\"list_item\")return[];let r=(n=e.parseBlockChildren)!==null&&n!==void 0?n:e.parseChildren,o=[];if(t.tokens&&t.tokens.length>0){if(Db(t))return{type:\"listItem\",content:[{type:\"paragraph\",content:Ib(t.text||\"\",e)}]};let[s,...l]=t.tokens;if(s.type===\"heading\"){var i;return{type:\"listItem\",content:[{type:\"paragraph\",content:e.parseInline((i=s.tokens)!==null&&i!==void 0?i:[])},...l.length>0?r(l):[]]}}if(t.tokens.some(a=>a.type===\"paragraph\"))o=r(t.tokens);else if(s.type===\"text\"&&s.tokens&&s.tokens.length>0){if(o=[{type:\"paragraph\",content:e.parseInline(s.tokens)}],t.tokens.length>1){let a=r(t.tokens.slice(1));o.push(...a)}}else o=r(t.tokens)}return o.length===0&&(o=[{type:\"paragraph\",content:[]}]),{type:\"listItem\",content:Tb(o)}},renderMarkdown:(t,e,n)=>{let r=s=>{if(s.parentType===\"bulletList\")return\"- \";if(s.parentType===\"orderedList\"){var l,a;let c=((l=s.meta)===null||l===void 0||(l=l.parentAttrs)===null||l===void 0?void 0:l.start)||1;return Ab((a=s.meta)===null||a===void 0||(a=a.parentAttrs)===null||a===void 0?void 0:a.type,c-1+(s.index||0),\". \")}return\"- \"},o=Ps(t,e,r,n,{alignNestedToPrefix:n?.parentType===\"orderedList\"});if(!Nb(t)||!Rb(n))return o;let i=r(n);return`${i}${Ob}${o.slice(i.length)}`},addExtensions(){return[Zd(this.name,[this.options.bulletListTypeName,this.options.orderedListTypeName])]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),\"Shift-Tab\":()=>this.editor.commands.liftListItem(this.name)}}}),_s=(t,e)=>{let{$from:n}=e.selection,r=Q(t,e.schema),o=null,i=n.depth,s=n.pos,l=null;for(;i>0&&l===null;)o=n.node(i),o.type===r?l=i:(i-=1,s-=1);return l===null?null:{$pos:e.doc.resolve(s),depth:l}},rf=(t,e)=>{let n=_s(t,e);if(!n)return!1;let[,r]=cd(e,t,n.$pos.pos+4);return r},Pb=(t,e,n)=>{let{$anchor:r}=t.selection,o=Math.max(0,r.pos-2),i=t.doc.resolve(o).node();return!(!i||!n.includes(i.type.name))},Ud=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!$e(t.state,e)&&Pb(t.state,e,n)){let{$anchor:i}=t.state.selection,s=t.state.doc.resolve(i.before()-1),l=[];s.node().descendants((u,d)=>{u.type.name===e&&l.push({node:u,pos:d})});let a=l.at(-1);if(!a)return!1;let c=t.state.doc.resolve(s.start()+a.pos+1);return t.chain().command(({tr:u})=>{let d=c.end();return u.delete(i.before(),i.after()).insert(d,i.parent),u.setSelection(M.create(u.doc,d+1)),!0}).command(({state:u,dispatch:d})=>(Ar(u,d),!0)).run()}if(!$e(t.state,e)||!fd(t.state))return!1;let{$from:r}=t.state.selection,o=r.depth-1;return r.node(o).type!==t.schema.nodes[e]||r.index(o)!==0?!1:t.chain().liftListItem(e).run()},Lb=(t,e)=>{let n=rf(t,e),r=_s(t,e);return!r||!n?!1:n>r.depth},$b=(t,e)=>{let n=rf(t,e),r=_s(t,e);return!r||!n?!1:n<r.depth},Jd=(t,e)=>!$e(t.state,e)||!dd(t.state,e)||!t.state.selection.empty?!1:Lb(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():$b(e,t.state)?t.commands.command(({state:n,dispatch:r})=>Tr(n,r)):t.commands.joinItemForward(),zb=(t,e,n)=>{let{state:r}=t,{selection:o}=r;if(!o.empty)return!1;let{$from:i}=o;if(i.parentOffset!==0||!i.parent.isTextblock||$e(r,e))return!1;let s=ud(i);if(!s||!n.includes(s.type.name))return!1;let l=s.lastChild;if(!l||l.type.name!==e)return!1;let a=i.parent;if(!l.canReplace(l.childCount,l.childCount,b.from(a)))return!1;let c=i.before(),u=i.after(),d=c-2;return t.commands.command(({tr:f,dispatch:h})=>(h&&(f.delete(c,u).insert(d,b.from(a)),f.setSelection(M.create(f.doc,d+1)),f.scrollIntoView()),!0))};var Ks=V.create({name:\"listKeymap\",addOptions(){return{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})=>{t.state.schema.nodes[n]!==void 0&&Jd(t,n)&&(e=!0)}),e},\"Mod-Delete\":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&Jd(t,n)&&(e=!0)}),e},Backspace:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&Ud(t,n,r)&&(e=!0)}),e},\"Mod-Backspace\":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&Ud(t,n,r)&&(e=!0)}),e},Tab:({editor:t})=>{for(let{itemName:e,wrapperNames:n}of this.options.listTypes)if(t.state.schema.nodes[e]!==void 0&&zb(t,e,n))return!0;return!1}}}}),lo=new RegExp(`^(\\\\s*)(${tf})([.)])\\\\s+(.*)$`),Bb=/^\\s/,kn={heading:/^#{1,6}(?:\\s|$)/,bulletItem:/^[-+*]\\s+/,codeFence:/^(?:```|~~~)/,blockMath:/^\\$\\$/,thematicBreak:/^(?:(?:-[ \\t]*){3,}|(?:_[ \\t]*){3,}|(?:\\*[ \\t]*){3,})$/};function Fb(t){return lo.test(t.trimStart())}function Hb(t){let e=t.trimStart();return kn.bulletItem.test(e)||Fb(e)||kn.heading.test(e)||kn.thematicBreak.test(e)&&!e.startsWith(\"-\")||/^>\\s?/.test(e)||kn.codeFence.test(e)||kn.blockMath.test(e)}function jb(t){return Object.values(kn).some(e=>e.test(t))}function Wb(t){let e=[],n=[],r=!1;return t.forEach(o=>{if(r){n.push(o);return}if(o.trim()===\"\"){r=!0,n.push(o);return}if(e.length>0&&Hb(o)){r=!0,n.push(o);return}e.push(o)}),{paragraphLines:e,blockLines:n}}function qd(t){let e=[],n=0,r=0;for(;n<t.length;){let o=t[n],i=o.match(lo);if(!i)break;let[,s,l,a,c]=i,u=s.length,d=parseInt(l,10),f=isNaN(d)?co(l):void 0,h=isNaN(d)?Ws(l):d,p=[c],m=n+1,g=[o],y=!1;for(;m<t.length;){let S=t[m];if(S.match(lo))break;if(S.trim()===\"\")g.push(S),p.push(\"\"),y=!0,m+=1;else if(S.match(Bb)){let k=S.length-S.trimStart().length,x=u+l.length+1;g.push(S),p.push(S.slice(Math.min(k,x))),m+=1}else{if(y||jb(S))break;g.push(S),p.push(S),m+=1}}e.push({indent:u,number:h,type:f,content:p.join(`\n`).trim(),contentLines:p,raw:g.join(`\n`)}),r=m,n=m}return[e,r]}var Vb=new RegExp(`^(${tf})([.)])\\\\s+(.+)$`);function _b(t){let e=t.split(`\n`).filter(r=>r.trim().length>0);if(e.length===0)return null;let n=[];for(let r of e){let o=r.trim().match(Vb);if(!o)return null;n.push({marker:o[1],content:o[3]})}return Mb(n.map(r=>r.marker))?{type:\"orderedList\",attrs:Eb(n[0].marker),content:n.map(r=>({type:\"listItem\",content:[{type:\"paragraph\",content:[{type:\"text\",text:r.content}]}]}))}:null}function of(t,e,n){let r=[],o=0;for(;o<t.length;){let i=t[o];if(i.indent===e){let{paragraphLines:s,blockLines:l}=Wb(i.contentLines),a=s.join(`\n`).trim(),c=[];a&&c.push({type:\"paragraph\",raw:a,tokens:n.inlineTokens(a)});let u=l.join(`\n`).trim();if(u){let h=n.blockTokens(u);c.push(...h)}let d=o+1,f=[];for(;d<t.length&&t[d].indent>e;)f.push(t[d]),d+=1;if(f.length>0){let h=of(f,Math.min(...f.map(p=>p.indent)),n);c.push({type:\"list\",ordered:!0,start:f[0].number,typeMarker:f[0].type,items:h,raw:f.map(p=>p.raw).join(`\n`)})}r.push({type:\"list_item\",raw:i.raw,tokens:c}),o=d}else o+=1}return r}function Kb(t,e){return t.map(n=>{if(n.type!==\"list_item\")return e.parseChildren([n])[0];let r=[];return n.tokens&&n.tokens.length>0&&n.tokens.forEach(o=>{if(o.type===\"paragraph\"||o.type===\"list\"||o.type===\"blockquote\"||o.type===\"code\")r.push(...e.parseChildren([o]));else if(o.type===\"text\"&&o.tokens){let i=e.parseChildren([o]);r.push({type:\"paragraph\",content:i})}else{let i=e.parseChildren([o]);i.length>0&&r.push(...i)}}),{type:\"listItem\",content:r}})}var Ub=64;function Gd(t,e){let n=[],r=0;for(;n.length<e;){let o=t.indexOf(`\n`,r);if(o===-1)return n.push(t.slice(r)),n;n.push(t.slice(r,o)),r=o+1}return n}function Jb(t){let e=t.indexOf(`\n`),n=e===-1?t:t.slice(0,e);if(!lo.test(n))return[[],0,[]];let r=Ub,o=Gd(t,r),i=qd(o);for(;i[1]===o.length&&o.length===r;)r*=2,o=Gd(t,r),i=qd(o);return[i[0],i[1],o]}var qb=\"listItem\",Xd=\"textStyle\",Yd=/^(\\d+)\\.\\s$/;function Qd(t){let e=t.match(/list-style-type\\s*:\\s*([^;]+)/i);if(!e)return null;switch(e[1].trim().toLowerCase()){case\"upper-roman\":return\"I\";case\"lower-roman\":return\"i\";case\"upper-alpha\":case\"upper-latin\":return\"A\";case\"lower-alpha\":case\"lower-latin\":return\"a\";default:return null}}var Us=K.create({name:\"orderedList\",addOptions(){return{itemTypeName:\"listItem\",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:\"block list\",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute(\"start\")?parseInt(t.getAttribute(\"start\")||\"\",10):1},type:{default:null,parseHTML:t=>{let e=t.getAttribute(\"type\");if(e)return e;let n=t.getAttribute(\"style\");if(n){let o=Qd(n);if(o)return o}let r=t.querySelector(\"li\");if(r){let o=r.getAttribute(\"style\");if(o){let i=Qd(o);if(i)return i}}return null}}}},parseHTML(){return[{tag:\"ol\"}]},renderHTML({HTMLAttributes:t}){let{start:e,type:n,...r}=t,o=B(this.options.HTMLAttributes,r);return e!==1&&(o.start=e),n&&n!==\"1\"&&(o.type=n),[\"ol\",o,0]},markdownTokenName:\"list\",parseMarkdown:(t,e)=>{if(t.type!==\"list\"||!t.ordered)return[];let n=t.start||1,r=t.typeMarker,o=t.items?Kb(t.items,e):[],i={};return n!==1&&(i.start=n),r&&(i.type=r),Object.keys(i).length>0?{type:\"orderedList\",attrs:i,content:o}:{type:\"orderedList\",content:o}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`\n`):\"\",markdownTokenizer:{name:\"orderedList\",level:\"block\",start:()=>-1,tokenize:(t,e,n)=>{var r,o;let[i,s,l]=Jb(t);if(i.length===0)return;let a=of(i,i[0].indent,n);if(a.length!==0)return{type:\"list\",ordered:!0,start:((r=i[0])===null||r===void 0?void 0:r.number)||1,typeMarker:(o=i[0])===null||o===void 0?void 0:o.type,items:a,raw:l.slice(0,s).join(`\n`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(qb,this.editor.getAttributes(Xd)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{\"Mod-Shift-7\":()=>this.editor.commands.toggleOrderedList()}},addProseMirrorPlugins(){return[new R({props:{handlePaste:(t,e)=>{var n,r;let o=(n=e.clipboardData)===null||n===void 0?void 0:n.getData(\"text/html\");if(o?.trim())return!1;let i=(r=e.clipboardData)===null||r===void 0?void 0:r.getData(\"text/plain\");if(!i)return!1;let s=_b(i);if(!s)return!1;try{let l=t.state.schema.nodeFromJSON(s),a=t.state.tr.replaceSelectionWith(l);return t.dispatch(a),!0}catch{return!1}}}})]},addInputRules(){let t=(n,r)=>(!r.attrs.type||r.attrs.type===\"1\")&&r.childCount+r.attrs.start===+n[1],e=bn({find:Yd,type:this.type,getAttributes:n=>({start:+n[1]}),joinPredicate:t});return(this.options.keepMarks||this.options.keepAttributes)&&(e=bn({find:Yd,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:n=>({start:+n[1],...this.editor.getAttributes(Xd)}),joinPredicate:t,editor:this.editor})),[e]}}),Gb=/^\\s*(\\[([( |x])?\\])\\s$/,Xb=\"position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0\",Yb=(t,e,n)=>{var r;return(n==null||(r=n.checkboxLabel)===null||r===void 0?void 0:r.call(n,t,e))||`Task item checkbox for ${t.textContent||\"empty task item\"}`},Qb=K.create({name:\"taskItem\",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:\"taskList\",a11y:void 0}},content(){return this.options.nested?\"paragraph block*\":\"paragraph+\"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:t=>{let e=t.getAttribute(\"data-checked\");return e===\"\"||e===\"true\"},renderHTML:t=>({\"data-checked\":t.checked})}}},parseHTML(){return[{tag:`li[data-type=\"${this.name}\"]`,priority:51,contentElement:t=>{var e;return(e=t.querySelector(\"div\"))!==null&&e!==void 0?e:t}}]},renderHTML({node:t,HTMLAttributes:e}){return[\"li\",B(this.options.HTMLAttributes,e,{\"data-type\":this.name}),[\"label\",[\"input\",{type:\"checkbox\",checked:t.attrs.checked?\"checked\":null}],[\"span\"]],[\"div\",0]]},parseMarkdown:(t,e)=>{let 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){let r=e.parseChildren(t.nestedTokens);n.push(...r)}return e.createNode(\"taskItem\",{checked:t.checked||!1},n)},renderMarkdown:(t,e)=>{var n;let r=`- [${!((n=t.attrs)===null||n===void 0)&&n.checked?\"x\":\" \"}] `;return Ps(t,e,r,void 0,{indentMainContent:!0})},addExtensions(){return this.options.nested?[Zd(this.name,[this.options.taskListTypeName])]:[]},addKeyboardShortcuts(){let 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:r})=>{let o=document.createElement(\"li\"),i=document.createElement(\"label\"),s=document.createElement(\"span\"),l=document.createElement(\"input\"),a=document.createElement(\"div\");s.style.cssText=Xb;let c=d=>{let f=Yb(d,d.attrs.checked,this.options.a11y);l.setAttribute(\"aria-label\",f),s.textContent=f};c(t),i.contentEditable=\"false\",l.type=\"checkbox\",l.addEventListener(\"mousedown\",d=>d.preventDefault()),l.addEventListener(\"change\",d=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}let{checked:f}=d.target;r.isEditable&&typeof n==\"function\"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:h})=>{let p=n();if(typeof p!=\"number\")return!1;let m=h.doc.nodeAt(p);return h.setNodeMarkup(p,void 0,{...m?.attrs,checked:f}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,f)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([d,f])=>{o.setAttribute(d,f)}),o.dataset.checked=t.attrs.checked,l.checked=t.attrs.checked,i.append(l,s),o.append(i,a),Object.entries(e).forEach(([d,f])=>{o.setAttribute(d,f)});let u=new Set(Object.keys(e));return{dom:o,contentDOM:a,update:d=>{if(d.type!==this.type)return!1;o.dataset.checked=d.attrs.checked,l.checked=d.attrs.checked,c(d);let f=r.extensionManager.attributes,h=pt(d,f),p=new Set(Object.keys(h)),m=this.options.HTMLAttributes;return u.forEach(g=>{p.has(g)||(g in m?o.setAttribute(g,m[g]):o.removeAttribute(g))}),Object.entries(h).forEach(([g,y])=>{y==null?g in m?o.setAttribute(g,m[g]):o.removeAttribute(g):o.setAttribute(g,y)}),u=p,!0}}}},addInputRules(){return[bn({find:Gb,type:this.type,getAttributes:t=>({checked:t[t.length-1]===\"x\"})})]}}),Zb=K.create({name:\"taskList\",addOptions(){return{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\",B(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;let n=(e=t.match(/^\\s*[-+*]\\s+\\[([ xX])\\]\\s+/))===null||e===void 0?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){let r=i=>{let s=Is(i,{itemPattern:/^(\\s*)([-+*])\\s+\\[([ xX])\\]\\s+(.*)$/,extractItemData:l=>({indentLevel:l[1].length,mainContent:l[4],checked:l[3].toLowerCase()===\"x\"}),createToken:(l,a)=>({type:\"taskItem\",raw:\"\",mainContent:l.mainContent,indentLevel:l.indentLevel,checked:l.checked,text:l.mainContent,tokens:n.inlineTokens(l.mainContent),nestedTokens:a}),customNestedParser:r},n);if(s){let l={type:\"taskList\",raw:s.raw,items:s.items},a=i.slice(s.raw.length);return a.trim()?[l,...n.blockTokens(a)]:[l]}return n.blockTokens(i)},o=Is(t,{itemPattern:/^(\\s*)([-+*])\\s+\\[([ xX])\\]\\s+(.*)$/,extractItemData:i=>({indentLevel:i[1].length,mainContent:i[4],checked:i[3].toLowerCase()===\"x\"}),createToken:(i,s)=>({type:\"taskItem\",raw:\"\",mainContent:i.mainContent,indentLevel:i.indentLevel,checked:i.checked,text:i.mainContent,tokens:n.inlineTokens(i.mainContent),nestedTokens:s}),customNestedParser:r},n);if(o)return{type:\"taskList\",raw:o.raw,items:o.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()}}}),vx=V.create({name:\"listKit\",addExtensions(){let t=[];return this.options.bulletList!==!1&&t.push(Hs.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(Vs.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(Ks.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(Us.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(Qb.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(Zb.configure(this.options.taskList)),t}});var ek=\"aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos6kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5m\\xF6gensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12b0cam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2\",tk=\"\\u03B5\\u03BB1\\u03C52\\u0431\\u04331\\u0435\\u043B3\\u0434\\u0435\\u0442\\u04384\\u0435\\u044E2\\u043A\\u0430\\u0442\\u043E\\u043B\\u0438\\u043A6\\u043E\\u043C3\\u043C\\u043A\\u04342\\u043E\\u043D1\\u0441\\u043A\\u0432\\u04306\\u043E\\u043D\\u043B\\u0430\\u0439\\u043D5\\u0440\\u04333\\u0440\\u0443\\u04412\\u04442\\u0441\\u0430\\u0439\\u04423\\u0440\\u04313\\u0443\\u043A\\u04403\\u049B\\u0430\\u04373\\u0570\\u0561\\u05753\\u05D9\\u05E9\\u05E8\\u05D0\\u05DC5\\u05E7\\u05D5\\u05DD3\\u0627\\u0628\\u0648\\u0638\\u0628\\u064A5\\u0631\\u0627\\u0645\\u0643\\u06485\\u0644\\u0627\\u0631\\u062F\\u06464\\u0628\\u062D\\u0631\\u064A\\u06465\\u062C\\u0632\\u0627\\u0626\\u06315\\u0633\\u0639\\u0648\\u062F\\u064A\\u06296\\u0639\\u0644\\u064A\\u0627\\u06465\\u0645\\u063A\\u0631\\u06285\\u0645\\u0627\\u0631\\u0627\\u062A5\\u06CC\\u0631\\u0627\\u06465\\u0628\\u0627\\u0631\\u062A2\\u0632\\u0627\\u06314\\u064A\\u062A\\u06433\\u06BE\\u0627\\u0631\\u062A5\\u062A\\u0648\\u0646\\u06334\\u0633\\u0648\\u062F\\u0627\\u06463\\u0631\\u064A\\u06295\\u0634\\u0628\\u0643\\u06294\\u0639\\u0631\\u0627\\u06422\\u06282\\u0645\\u0627\\u06464\\u0641\\u0644\\u0633\\u0637\\u064A\\u06466\\u0642\\u0637\\u06313\\u0643\\u0627\\u062B\\u0648\\u0644\\u064A\\u06436\\u0648\\u06453\\u0645\\u0635\\u06312\\u0644\\u064A\\u0633\\u064A\\u06275\\u0648\\u0631\\u064A\\u062A\\u0627\\u0646\\u064A\\u06277\\u0642\\u06394\\u0647\\u0645\\u0631\\u0627\\u06475\\u067E\\u0627\\u06A9\\u0633\\u062A\\u0627\\u06467\\u0680\\u0627\\u0631\\u062A4\\u0915\\u0949\\u092E3\\u0928\\u0947\\u091F3\\u092D\\u093E\\u0930\\u09240\\u092E\\u094D3\\u094B\\u09245\\u0938\\u0902\\u0917\\u0920\\u09285\\u09AC\\u09BE\\u0982\\u09B2\\u09BE5\\u09AD\\u09BE\\u09B0\\u09A42\\u09F0\\u09A44\\u0A2D\\u0A3E\\u0A30\\u0A244\\u0AAD\\u0ABE\\u0AB0\\u0AA44\\u0B2D\\u0B3E\\u0B30\\u0B244\\u0B87\\u0BA8\\u0BCD\\u0BA4\\u0BBF\\u0BAF\\u0BBE6\\u0BB2\\u0B99\\u0BCD\\u0B95\\u0BC86\\u0B9A\\u0BBF\\u0B99\\u0BCD\\u0B95\\u0BAA\\u0BCD\\u0BAA\\u0BC2\\u0BB0\\u0BCD11\\u0C2D\\u0C3E\\u0C30\\u0C24\\u0C4D5\\u0CAD\\u0CBE\\u0CB0\\u0CA44\\u0D2D\\u0D3E\\u0D30\\u0D24\\u0D025\\u0DBD\\u0D82\\u0D9A\\u0DCF4\\u0E04\\u0E2D\\u0E213\\u0E44\\u0E17\\u0E223\\u0EA5\\u0EB2\\u0EA73\\u10D2\\u10D42\\u307F\\u3093\\u306A3\\u30A2\\u30DE\\u30BE\\u30F34\\u30AF\\u30E9\\u30A6\\u30C94\\u30B0\\u30FC\\u30B0\\u30EB4\\u30B3\\u30E02\\u30B9\\u30C8\\u30A23\\u30BB\\u30FC\\u30EB3\\u30D5\\u30A1\\u30C3\\u30B7\\u30E7\\u30F36\\u30DD\\u30A4\\u30F3\\u30C84\\u4E16\\u754C2\\u4E2D\\u4FE11\\u56FD1\\u570B1\\u6587\\u7F513\\u4E9A\\u9A6C\\u900A3\\u4F01\\u4E1A2\\u4F5B\\u5C712\\u4FE1\\u606F2\\u5065\\u5EB72\\u516B\\u53662\\u516C\\u53F81\\u76CA2\\u53F0\\u6E7E1\\u70632\\u5546\\u57CE1\\u5E971\\u68072\\u5609\\u91CC0\\u5927\\u9152\\u5E975\\u5728\\u7EBF2\\u5927\\u62FF2\\u5929\\u4E3B\\u65593\\u5A31\\u4E502\\u5BB6\\u96FB2\\u5E7F\\u4E1C2\\u5FAE\\u535A2\\u6148\\u55842\\u6211\\u7231\\u4F603\\u624B\\u673A2\\u62DB\\u80582\\u653F\\u52A11\\u5E9C2\\u65B0\\u52A0\\u57612\\u95FB2\\u65F6\\u5C1A2\\u66F8\\u7C4D2\\u673A\\u67842\\u6DE1\\u9A6C\\u95213\\u6E38\\u620F2\\u6FB3\\u95802\\u70B9\\u770B2\\u79FB\\u52A82\\u7EC4\\u7EC7\\u673A\\u67844\\u7F51\\u57401\\u5E971\\u7AD91\\u7EDC2\\u8054\\u901A2\\u8C37\\u6B4C2\\u8D2D\\u72692\\u901A\\u8CA92\\u96C6\\u56E22\\u96FB\\u8A0A\\u76C8\\u79D14\\u98DE\\u5229\\u6D663\\u98DF\\u54C12\\u9910\\u53852\\u9999\\u683C\\u91CC\\u62C93\\u6E2F2\\uB2F7\\uB1371\\uCEF42\\uC0BC\\uC1312\\uD55C\\uAD6D2\",Qs=\"numeric\",Zs=\"ascii\",el=\"alpha\",tr=\"asciinumeric\",er=\"alphanumeric\",tl=\"domain\",df=\"emoji\",nk=\"scheme\",rk=\"slashscheme\",Js=\"whitespace\";function ok(t,e){return t in e||(e[t]=[]),e[t]}function Wt(t,e,n){e[Qs]&&(e[tr]=!0,e[er]=!0),e[Zs]&&(e[tr]=!0,e[el]=!0),e[tr]&&(e[er]=!0),e[el]&&(e[er]=!0),e[er]&&(e[tl]=!0),e[df]&&(e[tl]=!0);for(let r in e){let o=ok(r,n);o.indexOf(t)<0&&o.push(t)}}function ik(t,e){let n={};for(let r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function ke(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}ke.groups={};ke.prototype={accepts(){return!!this.t},go(t){let e=this,n=e.j[t];if(n)return n;for(let r=0;r<e.jr.length;r++){let o=e.jr[r][0],i=e.jr[r][1];if(i&&o.test(t))return i}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let o=0;o<t.length;o++)this.tt(t[o],e,n,r)},tr(t,e,n,r){r=r||ke.groups;let o;return e&&e.j?o=e:(o=new ke(e),n&&r&&Wt(e,n,r)),this.jr.push([t,o]),o},ts(t,e,n,r){let o=this,i=t.length;if(!i)return o;for(let s=0;s<i-1;s++)o=o.tt(t[s]);return o.tt(t[i-1],e,n,r)},tt(t,e,n,r){r=r||ke.groups;let o=this;if(e&&e.j)return o.j[t]=e,e;let i=e,s,l=o.go(t);if(l?(s=new ke,Object.assign(s.j,l.j),s.jr.push.apply(s.jr,l.jr),s.jd=l.jd,s.t=l.t):s=new ke,i){if(r)if(s.t&&typeof s.t==\"string\"){let a=Object.assign(ik(s.t,r),n);Wt(i,a,r)}else n&&Wt(i,n,r);s.t=i}return o.j[t]=s,s}};var D=(t,e,n,r,o)=>t.ta(e,n,r,o),U=(t,e,n,r,o)=>t.tr(e,n,r,o),sf=(t,e,n,r,o)=>t.ts(e,n,r,o),w=(t,e,n,r,o)=>t.tt(e,n,r,o),nt=\"WORD\",nl=\"UWORD\",ff=\"ASCIINUMERICAL\",hf=\"ALPHANUMERICAL\",sr=\"LOCALHOST\",rl=\"TLD\",ol=\"UTLD\",po=\"SCHEME\",wn=\"SLASH_SCHEME\",sl=\"NUM\",il=\"WS\",ll=\"NL\",nr=\"OPENBRACE\",rr=\"CLOSEBRACE\",go=\"OPENBRACKET\",yo=\"CLOSEBRACKET\",bo=\"OPENPAREN\",ko=\"CLOSEPAREN\",wo=\"OPENANGLEBRACKET\",So=\"CLOSEANGLEBRACKET\",xo=\"FULLWIDTHLEFTPAREN\",Co=\"FULLWIDTHRIGHTPAREN\",Mo=\"LEFTCORNERBRACKET\",vo=\"RIGHTCORNERBRACKET\",Eo=\"LEFTWHITECORNERBRACKET\",Ao=\"RIGHTWHITECORNERBRACKET\",To=\"FULLWIDTHLESSTHAN\",No=\"FULLWIDTHGREATERTHAN\",Oo=\"AMPERSAND\",Ro=\"APOSTROPHE\",Do=\"ASTERISK\",gt=\"AT\",Io=\"BACKSLASH\",Po=\"BACKTICK\",Lo=\"CARET\",Vt=\"COLON\",al=\"COMMA\",$o=\"DOLLAR\",Be=\"DOT\",zo=\"EQUALS\",cl=\"EXCLAMATION\",Ae=\"HYPHEN\",or=\"PERCENT\",Bo=\"PIPE\",Fo=\"PLUS\",xn=\"POUND\",jt=\"QUERY\",ul=\"QUOTE\",pf=\"FULLWIDTHMIDDLEDOT\",dl=\"SEMI\",Fe=\"SLASH\",ir=\"TILDE\",Ho=\"UNDERSCORE\",mf=\"EMOJI\",jo=\"SYM\",gf=Object.freeze({__proto__:null,ALPHANUMERICAL:hf,AMPERSAND:Oo,APOSTROPHE:Ro,ASCIINUMERICAL:ff,ASTERISK:Do,AT:gt,BACKSLASH:Io,BACKTICK:Po,CARET:Lo,CLOSEANGLEBRACKET:So,CLOSEBRACE:rr,CLOSEBRACKET:yo,CLOSEPAREN:ko,COLON:Vt,COMMA:al,DOLLAR:$o,DOT:Be,EMOJI:mf,EQUALS:zo,EXCLAMATION:cl,FULLWIDTHGREATERTHAN:No,FULLWIDTHLEFTPAREN:xo,FULLWIDTHLESSTHAN:To,FULLWIDTHMIDDLEDOT:pf,FULLWIDTHRIGHTPAREN:Co,HYPHEN:Ae,LEFTCORNERBRACKET:Mo,LEFTWHITECORNERBRACKET:Eo,LOCALHOST:sr,NL:ll,NUM:sl,OPENANGLEBRACKET:wo,OPENBRACE:nr,OPENBRACKET:go,OPENPAREN:bo,PERCENT:or,PIPE:Bo,PLUS:Fo,POUND:xn,QUERY:jt,QUOTE:ul,RIGHTCORNERBRACKET:vo,RIGHTWHITECORNERBRACKET:Ao,SCHEME:po,SEMI:dl,SLASH:Fe,SLASH_SCHEME:wn,SYM:jo,TILDE:ir,TLD:rl,UNDERSCORE:Ho,UTLD:ol,UWORD:nl,WORD:nt,WS:il}),et=/[a-z]/,Sn=/[a-z]/i,mo=/[\\u{1F000}-\\u{1FAFF}\\u{2600}-\\u{27BF}]|\\u{FE0F}/u;try{Sn=new RegExp(\"\\\\p{L}\",\"u\"),mo=new RegExp(\"\\\\p{Emoji}\",\"u\")}catch{}var tt=/\\d/,qs=/\\s/;var lf=\"\\r\",Gs=`\n`,sk=\"\\uFE0F\",lk=\"\\u200D\",Xs=\"\\uFFFC\",uo=null,fo=null;function ak(t=[]){let e={};ke.groups=e;let n=new ke;uo==null&&(uo=af(ek)),fo==null&&(fo=af(tk)),w(n,\"'\",Ro),w(n,\"{\",nr),w(n,\"}\",rr),w(n,\"[\",go),w(n,\"]\",yo),w(n,\"(\",bo),w(n,\")\",ko),w(n,\"<\",wo),w(n,\">\",So),w(n,\"\\uFF08\",xo),w(n,\"\\uFF09\",Co),w(n,\"\\u300C\",Mo),w(n,\"\\u300D\",vo),w(n,\"\\u300E\",Eo),w(n,\"\\u300F\",Ao),w(n,\"\\uFF1C\",To),w(n,\"\\uFF1E\",No),w(n,\"&\",Oo),w(n,\"*\",Do),w(n,\"@\",gt),w(n,\"`\",Po),w(n,\"^\",Lo),w(n,\":\",Vt),w(n,\",\",al),w(n,\"$\",$o),w(n,\".\",Be),w(n,\"=\",zo),w(n,\"!\",cl),w(n,\"-\",Ae),w(n,\"%\",or),w(n,\"|\",Bo),w(n,\"+\",Fo),w(n,\"#\",xn),w(n,\"?\",jt),w(n,'\"',ul),w(n,\"/\",Fe),w(n,\";\",dl),w(n,\"~\",ir),w(n,\"_\",Ho),w(n,\"\\\\\",Io),w(n,\"\\u30FB\",pf);let r=U(n,tt,sl,{[Qs]:!0});U(r,tt,r);let o=U(r,et,ff,{[tr]:!0}),i=U(r,Sn,hf,{[er]:!0}),s=U(n,et,nt,{[Zs]:!0});U(s,tt,o),U(s,et,s),U(o,tt,o),U(o,et,o);let l=U(n,Sn,nl,{[el]:!0});U(l,et),U(l,tt,i),U(l,Sn,l),U(i,tt,i),U(i,et),U(i,Sn,i);let a=w(n,Gs,ll,{[Js]:!0}),c=w(n,lf,il,{[Js]:!0}),u=U(n,qs,il,{[Js]:!0});w(n,Xs,u),w(c,Gs,a),w(c,Xs,u),U(c,qs,u),w(u,lf),w(u,Gs),U(u,qs,u),w(u,Xs,u);let d=U(n,mo,mf,{[df]:!0});w(d,\"#\"),U(d,mo,d),w(d,sk,d);let f=w(d,lk);w(f,\"#\"),U(f,mo,d);let h=[[et,s],[tt,o]],p=[[et,null],[Sn,l],[tt,i]];for(let m=0;m<uo.length;m++)mt(n,uo[m],rl,nt,h);for(let m=0;m<fo.length;m++)mt(n,fo[m],ol,nl,p);Wt(rl,{tld:!0,ascii:!0},e),Wt(ol,{utld:!0,alpha:!0},e),mt(n,\"file\",po,nt,h),mt(n,\"mailto\",po,nt,h),mt(n,\"http\",wn,nt,h),mt(n,\"https\",wn,nt,h),mt(n,\"ftp\",wn,nt,h),mt(n,\"ftps\",wn,nt,h),Wt(po,{scheme:!0,ascii:!0},e),Wt(wn,{slashscheme:!0,ascii:!0},e),t=t.sort((m,g)=>m[0]>g[0]?1:-1);for(let m=0;m<t.length;m++){let g=t[m][0],S=t[m][1]?{[nk]:!0}:{[rk]:!0};g.indexOf(\"-\")>=0?S[tl]=!0:et.test(g)?tt.test(g)?S[tr]=!0:S[Zs]=!0:S[Qs]=!0,sf(n,g,g,S)}return sf(n,\"localhost\",sr,{ascii:!0}),n.jd=new ke(jo),{start:n,tokens:Object.assign({groups:e},gf)}}function yf(t,e){let n=ck(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=n.length,o=[],i=0,s=0;for(;s<r;){let l=t,a=null,c=0,u=null,d=-1,f=-1;for(;s<r&&(a=l.go(n[s]));)l=a,l.accepts()?(d=0,f=0,u=l):d>=0&&(d+=n[s].length,f++),c+=n[s].length,i+=n[s].length,s++;i-=d,s-=f,c-=d,o.push({t:u.t,v:e.slice(i-c,i),s:i-c,e:i})}return o}function ck(t){let e=[],n=t.length,r=0;for(;r<n;){let o=t.charCodeAt(r),i,s=o<55296||o>56319||r+1===n||(i=t.charCodeAt(r+1))<56320||i>57343?t[r]:t.slice(r,r+2);e.push(s),r+=s.length}return e}function mt(t,e,n,r,o){let i,s=e.length;for(let l=0;l<s-1;l++){let a=e[l];t.j[a]?i=t.j[a]:(i=new ke(r),i.jr=o.slice(),t.j[a]=i),t=i}return i=new ke(n),i.jr=o.slice(),t.j[e[s-1]]=i,i}function af(t){let e=[],n=[],r=0,o=\"0123456789\";for(;r<t.length;){let i=0;for(;o.indexOf(t[r+i])>=0;)i++;if(i>0){e.push(n.join(\"\"));for(let s=parseInt(t.substring(r,r+i),10);s>0;s--)n.pop();r+=i}else n.push(t[r]),r++}return e}var lr={defaultProtocol:\"http\",events:null,format:cf,formatHref:cf,nl2br:!1,tagName:\"a\",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],ignoreClasses:[],render:null};function fl(t,e=null){let n=Object.assign({},lr);t&&(n=Object.assign(n,t instanceof fl?t.o:t));let r=n.ignoreTags,o=[];for(let i=0;i<r.length;i++)o.push(r[i].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=o,this.ignoreClasses=n.ignoreClasses.slice()}fl.prototype={o:lr,ignoreTags:[],ignoreClasses:[],isIgnoredClass(t){if(typeof t!=\"string\"||this.ignoreClasses.length===0)return!1;let e=t.split(/\\s+/);for(let n=0;n<e.length;n++)if(this.ignoreClasses.indexOf(e[n])>=0)return!0;return!1},defaultRender(t){return t},check(t){return this.get(\"validate\",t.toString(),t)},get(t,e,n){let r=e!=null,o=this.o[t];return o&&(typeof o==\"object\"?(o=n.t in o?o[n.t]:lr[t],typeof o==\"function\"&&r&&(o=o(e,n))):typeof o==\"function\"&&r&&(o=o(e,n.t,n)),o)},getObj(t,e,n){let r=this.o[t];return typeof r==\"function\"&&e!=null&&(r=r(e,n.t,n)),r},render(t){let e=t.render(this);return(this.get(\"render\",null,t)||this.defaultRender)(e,t.t,t)}};function cf(t){return t}function bf(t,e){this.t=\"token\",this.v=t,this.tk=e}bf.prototype={isLink:!1,toString(){return this.v},toHref(t){return this.toString()},toFormattedString(t){let e=this.toString(),n=t.get(\"truncate\",e,this),r=t.get(\"format\",e,this);return n&&r.length>n?r.substring(0,n)+\"\\u2026\":r},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=lr.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){let e=this,n=this.toHref(t.get(\"defaultProtocol\")),r=t.get(\"formatHref\",n,this),o=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),u=t.getObj(\"attributes\",n,e),d=t.getObj(\"events\",n,e);return s.href=r,l&&(s.class=l),a&&(s.target=a),c&&(s.rel=c),u&&Object.assign(s,u),{tagName:o,attributes:s,content:i,eventListeners:d}}};function Wo(t,e){class n extends bf{constructor(o,i){super(o,i),this.t=t}}for(let r in e)n.prototype[r]=e[r];return n.t=t,n}var uk=Wo(\"email\",{isLink:!0,toHref(){return\"mailto:\"+this.toString()}}),uf=Wo(\"text\"),dk=Wo(\"nl\"),ho=Wo(\"url\",{isLink:!0,toHref(t=lr.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){let t=this.tk;return t.length>=2&&t[0].t!==sr&&t[1].t===Vt}});var Ee=t=>new ke(t);function fk({groups:t}){let e=t.domain.concat([Oo,Do,gt,Io,Po,Lo,$o,zo,Ae,sl,or,Bo,Fo,xn,Fe,jo,ir,Ho]),n=[Ro,Vt,al,Be,cl,or,jt,ul,dl,wo,So,nr,rr,yo,go,bo,ko,xo,Co,Mo,vo,Eo,Ao,To,No],r=[Oo,Ro,Do,Io,Po,Lo,$o,zo,Ae,nr,rr,or,Bo,Fo,xn,jt,Fe,jo,ir,Ho],o=Ee(),i=w(o,ir);D(i,r,i),D(i,t.domain,i);let s=Ee(),l=Ee(),a=Ee();D(o,t.domain,s),D(o,t.scheme,l),D(o,t.slashscheme,a),D(s,r,i),D(s,t.domain,s);let c=w(s,gt);w(i,gt,c),w(l,gt,c),w(a,gt,c);let u=w(i,Be);D(u,r,i),D(u,t.domain,i);let d=Ee();D(c,t.domain,d),D(d,t.domain,d);let f=w(d,Be);D(f,t.domain,d);let h=Ee(uk);D(f,t.tld,h),D(f,t.utld,h),w(c,sr,h);let p=w(d,Ae);w(p,Ae,p),D(p,t.domain,d),D(h,t.domain,d),w(h,Be,f),w(h,Ae,p);let m=w(s,Ae),g=w(s,Be);w(m,Ae,m),D(m,t.domain,s),D(g,r,i),D(g,t.domain,s);let y=Ee(ho);D(g,t.tld,y),D(g,t.utld,y),D(y,t.domain,s),D(y,r,i),w(y,Be,g),w(y,Ae,m),w(y,gt,c);let S=w(y,Vt),k=Ee(ho);D(S,t.numeric,k);let x=Ee(ho),O=Ee();D(x,e,x),D(x,n,O),D(O,e,x),D(O,n,O),w(y,Fe,x),w(k,Fe,x),w(y,jt,O),w(y,xn,x),w(k,jt,O),w(k,xn,x);let H=w(l,Vt),T=w(a,Vt),I=w(T,Fe),F=w(I,Fe);D(l,t.domain,s),w(l,Be,g),w(l,Ae,m),D(a,t.domain,s),w(a,Be,g),w(a,Ae,m),D(H,t.domain,x),w(H,Fe,x),w(H,jt,x),D(F,t.domain,x),D(F,e,x),w(F,Fe,x);let W=[[nr,rr],[go,yo],[bo,ko],[wo,So],[xo,Co],[Mo,vo],[Eo,Ao],[To,No]];for(let xe=0;xe<W.length;xe++){let[kt,wt]=W[xe],fe=w(x,kt);w(O,kt,fe);let ye=Ee(ho);D(fe,e,ye);let he=Ee();D(fe,n,he),w(fe,wt,x),D(ye,e,ye),D(ye,n,he),D(he,e,ye),D(he,n,he),w(ye,wt,x),w(he,wt,x)}return w(o,sr,y),w(o,ll,dk),{start:o,tokens:gf}}function hk(t,e,n){let r=n.length,o=0,i=[],s=[],l=[];for(;o<r;){let a=t,c=null,u=null,d=0,f=null,h=-1,p=[];for(;o<r&&!(c=a.go(n[o].t));)s.push(n[o++]);for(;o<r&&(u=c||a.go(n[o].t));)if(c=null,a=u,o++,d++,a.accepts())h=0,f=a,p=[];else if(h>=0&&h++,p.push(a),l[o]&&l[o].has(a))break;for(let m=0,g=o-p.length+1;m<p.length;m++,g++)(l[g]||(l[g]=new Set)).add(p[m]);if(h<0)o-=d,o<r&&(s.push(n[o]),o++);else{s.length>0&&(i.push(Ys(uf,e,s)),s=[]),o-=h,d-=h;let m=f.t,g=n.slice(o-d,o);i.push(Ys(m,e,g))}}return s.length>0&&i.push(Ys(uf,e,s)),i}function Ys(t,e,n){let r=n[0].s,o=n[n.length-1].e,i=e.slice(r,o);return new t(i,n)}var pk=typeof console<\"u\"&&console&&console.warn||(()=>{}),mk=\"until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.\",_={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function kf(){return ke.groups={},_.scanner=null,_.parser=null,_.tokenQueue=[],_.pluginQueue=[],_.customSchemes=[],_.initialized=!1,_}function hl(t,e=!1){if(_.initialized&&pk(`linkifyjs: already initialized - will not register custom scheme \"${t}\" ${mk}`),!/^[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`);_.customSchemes.push([t,e])}function gk(){_.scanner=ak(_.customSchemes);for(let t=0;t<_.tokenQueue.length;t++)_.tokenQueue[t][1]({scanner:_.scanner});_.parser=fk(_.scanner.tokens);for(let t=0;t<_.pluginQueue.length;t++)_.pluginQueue[t][1]({scanner:_.scanner,parser:_.parser});return _.initialized=!0,_}function Vo(t){return _.initialized||gk(),hk(_.parser.start,t,yf(_.scanner.start,t))}Vo.scan=yf;function pl(t,e=null,n=null){if(e&&typeof e==\"object\"){if(n)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);n=e,e=null}let r=new fl(n),o=Vo(t),i=[];for(let s=0;s<o.length;s++){let l=o[s];l.isLink&&(!e||l.t===e)&&r.check(l)&&i.push(l.toFormattedObject(r))}return i}var _o=\"[\\0- \\xA0\\u1680\\u180E\\u2000-\\u2029\\u205F\\u3000]\",yk=new RegExp(_o),bk=new RegExp(`${_o}$`),kk=new RegExp(`${_o}+$`),wk=new RegExp(_o,\"g\");function Sk(t,e,n){var r,o;let i=t.doc.resolve(e.to);if(!(!((r=i.nodeBefore)===null||r===void 0)&&r.isText))return;let s=(o=t.doc.textBetween(e.from,e.to,\"\\uFFFC\",\"\\uFFFC\").match(kk))===null||o===void 0?void 0:o[0];if(!s)return;let l=e.to-s.length,a=Qn(l,e.to,t.doc).filter(d=>d.mark.type===n);if(!a.length)return;let{nodeAfter:c}=i;if(c&&a.some(d=>d.mark.isInSet(c.marks)))return;let u=t.storedMarks;t.removeMark(l,e.to,n),t.setStoredMarks(u),t.selection.empty&&t.selection.from===e.to&&t.removeStoredMark(n)}function xk(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?[\"()\",\"[]\"].includes(t[0].value+t[2].value):!1}function Ck(t){return new R({key:new P(\"autolink\"),appendTransaction:(e,n,r)=>{let o=e.some(a=>a.docChanged)&&!n.doc.eq(r.doc),i=e.some(a=>a.getMeta(\"preventAutolink\"));if(!o||i)return;let{tr:s}=r,l=As(n.doc,[...e]);if(!e.some(vu)){let a=[];l.steps.forEach((c,u)=>{if(!(c instanceof G)||!c.slice.size)return;let d=l.mapping.slice(u+1),f=d.map(c.from,1),h=d.map(c.from+c.slice.size,-1);f<h&&a.push({from:f,to:h})}),a.sort((c,u)=>u.to-c.to),a.forEach(c=>Sk(s,c,t.type))}if(mn(l).forEach(({newRange:a})=>{let c=rd(r.doc,a,f=>f.isTextblock),u,d;if(c.length>1)u=c[0],d=r.doc.textBetween(u.pos,u.pos+u.node.nodeSize,void 0,\" \");else if(c.length){let f=r.doc.textBetween(a.from,a.to,\" \",\" \");if(!bk.test(f))return;u=c[0],d=r.doc.textBetween(u.pos,a.to,void 0,\" \")}if(u&&d){let f=d.split(yk).filter(Boolean);if(f.length<=0)return!1;let h=f[f.length-1],p=u.pos+d.lastIndexOf(h);if(!h)return!1;let m=Vo(h).map(g=>g.toObject(t.defaultProtocol));if(!xk(m))return!1;m.filter(g=>g.isLink).map(g=>({...g,from:p+g.start+1,to:p+g.end+1})).filter(g=>r.schema.marks.code?!r.doc.rangeHasMark(g.from,g.to,r.schema.marks.code):!0).filter(g=>t.validate(g.value)).filter(g=>t.shouldAutoLink(g.value)).forEach(g=>{Qn(g.from,g.to,r.doc).some(y=>y.mark.type===t.type)||s.addMark(g.from,g.to,t.type.create({href:g.href}))})}}),!!s.steps.length)return s}})}function Mk(t){return new R({key:new P(\"handleClickLink\"),props:{handleClick:(e,n,r)=>{if(r.button!==0||!e.editable)return!1;let o=null;if(r.target instanceof HTMLAnchorElement)o=r.target;else{let a=r.target;if(!a)return!1;let c=t.editor.view.dom;o=a.closest(\"a\"),o&&!c.contains(o)&&(o=null)}if(!o)return!1;let i=!1;if(t.enableClickSelection&&(i=t.editor.commands.extendMarkRange(t.type.name)),t.openOnClick){var s,l;let a=Rs(e.state,t.type.name),c=(s=o.href)!==null&&s!==void 0?s:a.href,u=(l=o.target)!==null&&l!==void 0?l:a.target;c&&(window.open(c,u),i=!0)}return i}}})}var vk=/\\[([^[\\]]+)\\]\\(((?:[^\\s()]|\\([^\\s()]*\\))+)(?:\\s+(?:([\"'])(.*?)\\3|“(.*?)”|‘(.*?)’))?\\)$/,Ek=/\\[([^[\\]]+)\\]\\(((?:[^\\s()]|\\([^\\s()]*\\))+)(?:\\s+(?:([\"'])(.*?)\\3|“(.*?)”|‘(.*?)’))?\\)/g;function wf(t,e){let n=0;for(let r=e-1;r>=0&&t[r]===\"\\\\\";r-=1)n+=1;return n%2===1}function Ak(t,e){let n=0,r=0;for(;r<e;){if(t[r]!==\"`\"){r+=1;continue}if(n===0&&wf(t,r)){r+=1;continue}let o=0;for(;r<e&&t[r]===\"`\";)o+=1,r+=1;n===0?n=o:o===n&&(n=0)}return n>0}function Sf(t,e,n){var r,o;let[,i,s]=e;return(e.index?t[e.index-1]:void 0)===\"!\"||wf(t,(r=e.index)!==null&&r!==void 0?r:0)||Ak(t,(o=e.index)!==null&&o!==void 0?o:0)?!1:!!i.trim()&&n(s)}function xf(t){var e,n;let[r,o,i,,s,l,a]=t,c=(e=s??l)!==null&&e!==void 0?e:a;return{index:(n=t.index)!==null&&n!==void 0?n:0,text:r,replaceWith:o,data:{href:i,title:c||null,markdown:!0}}}function Tk(t,e){return t.index<e.index+e.text.length&&e.index<t.index+t.text.length}function Cf(t){var e,n,r;return{href:(e=t.data)===null||e===void 0?void 0:e.href,title:(n=(r=t.data)===null||r===void 0?void 0:r.title)!==null&&n!==void 0?n:null}}function Nk(t){let e=ze({find:n=>{let r=vk.exec(n);return!r||!Sf(n,r,t.isAllowedHref)?null:xf(r)},type:t.type,getAttributes:Cf});return new yn({find:e.find,handler:n=>{let r=e.handler(n);return r!==null&&n.state.tr.steps.length&&n.state.tr.setMeta(\"preventAutolink\",!0),r}})}function Ok(t){let e=Re({find:n=>{var r,o;let i=[];for(let l of n.matchAll(Ek))Sf(n,l,t.isAllowedHref)&&i.push(xf(l));let s=((r=(o=t.findPlainUrls)===null||o===void 0?void 0:o.call(t,n))!==null&&r!==void 0?r:[]).filter(l=>!i.some(a=>Tk(a,l)));return[...i,...s]},type:t.type,getAttributes:Cf});return new $s({find:e.find,handler:n=>{var r;let o=e.handler(n);return o!==null&&n.state.tr.steps.length&&(!((r=n.match.data)===null||r===void 0)&&r.markdown)&&n.state.tr.setMeta(\"preventAutolink\",!0),o}})}function Rk(t){return new R({key:new P(\"handlePasteLink\"),props:{handlePaste:(e,n,r)=>{let{shouldAutoLink:o}=t,{state:i}=e,{selection:s}=i,{empty:l}=s;if(l)return!1;let a=\"\";r.content.forEach(u=>{a+=u.textContent});let c=pl(a,{defaultProtocol:t.defaultProtocol}).find(u=>u.isLink&&u.value===a);return!a||!c||o!==void 0&&!o(c.value)?!1:t.editor.commands.setMark(t.type,{href:c.href})}}})}function rt(t,e){let n=[\"http\",\"https\",\"ftp\",\"ftps\",\"mailto\",\"tel\",\"callto\",\"sms\",\"cid\",\"xmpp\"];return e&&e.forEach(r=>{let o=typeof r==\"string\"?r:r.scheme;o&&n.push(o)}),!t||t.replace(wk,\"\").match(new RegExp(`^(?:(?:${n.map(r=>r.replace(/[-/\\\\^$*+?.()|[\\]{}]/g,\"\\\\$&\")).join(\"|\")}):|[^a-z]|[a-z0-9+.\\\\-]+(?:[^a-z+.\\\\-:]|$))`,\"i\"))}var Mf=Ze.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=>{if(typeof t==\"string\"){hl(t);return}hl(t.scheme,t.optionalSlashes)})},onDestroy(){kf()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,markdownLinks:!1,autolink:!0,protocols:[],defaultProtocol:\"http\",HTMLAttributes:{target:\"_blank\",rel:\"noopener noreferrer nofollow\",class:null},isAllowedUri:(t,e)=>!!rt(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>{let e=/^[a-z][a-z0-9+.-]*:\\/\\//i.test(t),n=/^[a-z][a-z0-9+.-]*:/i.test(t);if(e||n&&!t.includes(\"@\"))return!0;let r=(t.includes(\"@\")?t.split(\"@\").pop():t).split(/[/?#:]/)[0];return!(/^\\d{1,3}(\\.\\d{1,3}){3}$/.test(r)||!/\\./.test(r))}}},addAttributes(){var t,e,n;return{href:{default:null,parseHTML(r){return r.getAttribute(\"href\")}},target:{default:(t=this.options.HTMLAttributes.target)!==null&&t!==void 0?t:null},rel:{default:(e=this.options.HTMLAttributes.rel)!==null&&e!==void 0?e:null},class:{default:(n=this.options.HTMLAttributes.class)!==null&&n!==void 0?n:null},title:{default:null}}},parseHTML(){return[{tag:\"a[href]\",getAttrs:t=>{let e=t.getAttribute(\"href\");return!e||!this.options.isAllowedUri(e,{defaultValidate:n=>!!rt(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!rt(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?[\"a\",B(this.options.HTMLAttributes,t),0]:[\"a\",B(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,r,o,i;let s=(n=(r=t.attrs)===null||r===void 0?void 0:r.href)!==null&&n!==void 0?n:\"\",l=(o=(i=t.attrs)===null||i===void 0?void 0:i.title)!==null&&o!==void 0?o:\"\",a=e.renderChildren(t);return l?`[${a}](${s} \"${l}\")`:`[${a}](${s})`},addCommands(){return{setLink:t=>({chain:e})=>{let{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!rt(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,t).setMeta(\"preventAutolink\",!0).run():!1},toggleLink:t=>({chain:e})=>{let{href:n}=t||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:r=>!!rt(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta(\"preventAutolink\",!0).run()},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta(\"preventAutolink\",!0).run()}},addInputRules(){return this.options.markdownLinks?[Nk({type:this.type,isAllowedHref:t=>this.options.isAllowedUri(t,{defaultValidate:e=>!!rt(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})})]:[]},addPasteRules(){let t=e=>{let n=[];if(e){let{protocols:r,defaultProtocol:o}=this.options;pl(e).filter(i=>i.isLink&&this.options.isAllowedUri(i.value,{defaultValidate:s=>!!rt(s,r),protocols:r,defaultProtocol:o})).forEach(i=>{this.options.shouldAutoLink(i.value)&&n.push({text:i.value,data:{href:i.href},index:i.start})})}return n};return this.options.markdownLinks?[Ok({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:n=>!!rt(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}),findPlainUrls:t})]:[Re({find:t,type:this.type,getAttributes:e=>{var n;return{href:(n=e.data)===null||n===void 0?void 0:n.href}}})]},addProseMirrorPlugins(){let t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(Ck({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:o=>!!rt(o,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push(Mk({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick===\"whenNotEditable\"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(Rk({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}});var ml=4,Dk=/^```([a-z]+)?[\\s\\n]$/,Ik=/^~~~([a-z]+)?[\\s\\n]$/,vf=K.create({name:\"codeBlock\",addOptions(){return{languageClassPrefix:\"language-\",exitOnTripleEnter:!0,exitOnArrowDown:!0,exitOnArrowUp:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:ml,HTMLAttributes:{}}},content:\"text*\",marks:\"\",group:\"block\",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;let{languageClassPrefix:n}=this.options;if(!n)return null;let r=[...((e=t.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(o=>o.startsWith(n)).map(o=>o.replace(n,\"\"))[0];return r||null},rendered:!1}}},parseHTML(){return[{tag:\"pre\",preserveWhitespace:\"full\"}]},renderHTML({node:t,HTMLAttributes:e}){return[\"pre\",B(this.options.HTMLAttributes,e),[\"code\",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:\"code\",parseMarkdown:(t,e)=>{var n,r;return((n=t.raw)===null||n===void 0?void 0:n.startsWith(\"```\"))===!1&&((r=t.raw)===null||r===void 0?void 0:r.startsWith(\"~~~\"))===!1&&t.codeBlockStyle!==\"indented\"?[]:e.createNode(\"codeBlock\",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var n;let r=\"\",o=((n=t.attrs)===null||n===void 0?void 0:n.language)||\"\";return t.content?r=[`\\`\\`\\`${o}`,e.renderChildren(t.content),\"```\"].join(`\n`):r=`\\`\\`\\`${o}\n\n\\`\\`\\``,r},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:()=>{let{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;let n=(e=this.options.tabSize)!==null&&e!==void 0?e:ml,{state:r}=t,{selection:o}=r,{$from:i,empty:s}=o;if(i.parent.type!==this.type)return!1;let l=\" \".repeat(n);return s?t.commands.insertContent(l):t.commands.command(({tr:a})=>{let{from:c,to:u}=o,d=r.doc.textBetween(c,u,`\n`,`\n`).split(`\n`).map(f=>l+f).join(`\n`);return a.replaceWith(c,u,r.schema.text(d)),!0})},\"Shift-Tab\":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;let n=(e=this.options.tabSize)!==null&&e!==void 0?e:ml,{state:r}=t,{selection:o}=r,{$from:i,empty:s}=o;return i.parent.type!==this.type?!1:s?t.commands.command(({tr:l})=>{var a;let{pos:c}=i,u=i.start(),d=i.end(),f=r.doc.textBetween(u,d,`\n`,`\n`).split(`\n`),h=0,p=0,m=c-u;for(let k=0;k<f.length;k+=1){if(p+f[k].length>=m){h=k;break}p+=f[k].length+1}let g=((a=f[h].match(/^ */))===null||a===void 0?void 0:a[0])||\"\",y=Math.min(g.length,n);if(y===0)return!0;let S=u;for(let k=0;k<h;k+=1)S+=f[k].length+1;return l.delete(S,S+y),c-S<=y&&l.setSelection(M.create(l.doc,S)),!0}):t.commands.command(({tr:l})=>{let{from:a,to:c}=o,u=r.doc.textBetween(a,c,`\n`,`\n`).split(`\n`).map(d=>{var f;let h=((f=d.match(/^ */))===null||f===void 0?void 0:f[0])||\"\",p=Math.min(h.length,n);return d.slice(p)}).join(`\n`);return l.replaceWith(a,c,r.schema.text(u)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;let{state:e}=t,{selection:n}=e,{$from:r,empty:o}=n;if(!o||r.parent.type!==this.type)return!1;let i=r.parentOffset===r.parent.nodeSize-2,s=r.parent.textContent.endsWith(`\n\n`);return!i||!s?!1:t.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowUp:({editor:t})=>{if(!this.options.exitOnArrowUp)return!1;let{state:e}=t,{selection:n}=e,{$from:r,empty:o}=n;if(!o||r.parent.type!==this.type||r.parentOffset!==0)return!1;let i=r.before();return i>0?!1:t.commands.insertDefaultBlock({pos:i})},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;let{state:e}=t,{selection:n,doc:r}=e,{$from:o,empty:i}=n;if(!i||o.parent.type!==this.type||o.parentOffset!==o.parent.nodeSize-2)return!1;let s=o.after();return s===void 0?!1:r.nodeAt(s)?t.commands.command(({tr:l})=>(l.setSelection(E.near(r.resolve(s))),!0)):t.commands.exitCode()}}},addInputRules(){return[Zn({find:Dk,type:this.type,getAttributes:t=>({language:t[1]})}),Zn({find:Ik,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new R({key:new P(\"codeBlockVSCodeHandler\"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;let n=e.clipboardData.getData(\"text/plain\"),r=e.clipboardData.getData(\"vscode-editor-data\"),o=r?JSON.parse(r):void 0,i=o?.mode;if(!n||!i)return!1;let{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(M.near(s.doc.resolve(Math.max(0,s.selection.from-2)))),s.setMeta(\"paste\",!0),t.dispatch(s),!0}}})]}});var Pk=/(?:^|\\s)(!\\[(.+|:?)]\\((\\S+)(?:(?:\\s+)[\"'](\\S+)[\"'])?\\))$/,Ef=K.create({name:\"image\",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},inline(){return this.options.inline},group(){return this.options.inline?\"inline\":\"block\"},draggable:!0,addAttributes(){return{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\",B(this.options.HTMLAttributes,t)]},parseMarkdown:(t,e)=>e.createNode(\"image\",{src:t.href,title:t.title,alt:t.text}),renderMarkdown:t=>{var e,n,r,o,i,s;let l=(e=(n=t.attrs)===null||n===void 0?void 0:n.src)!==null&&e!==void 0?e:\"\",a=(r=(o=t.attrs)===null||o===void 0?void 0:o.alt)!==null&&r!==void 0?r:\"\",c=(i=(s=t.attrs)===null||s===void 0?void 0:s.title)!==null&&i!==void 0?i:\"\";return c?`![${a}](${l} \"${c}\")`:`![${a}](${l})`},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>\"u\")return null;let{directions:t,minWidth:e,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize,o=new Set([\"src\",\"width\",\"height\"]);return({node:i,getPos:s,HTMLAttributes:l,editor:a})=>{let c=document.createElement(\"img\");c.draggable=!1;let u=B(this.options.HTMLAttributes,l);Object.entries(u).forEach(([y,S])=>{if(S!=null)switch(y){case\"src\":case\"width\":case\"height\":break;default:c.setAttribute(y,S)}}),u.src!==null&&(c.src=u.src);let d={...l},f=y=>{if(typeof y==\"string\"&&y!==\"\"){c.getAttribute(\"src\")!==y&&(c.src=y);return}c.hasAttribute(\"src\")&&c.removeAttribute(\"src\"),c.src!==\"\"&&(c.src=\"\")};f(l.src);let h=y=>{if(y.type!==i.type)return!1;let S=a.extensionManager.attributes.filter(x=>x.type===y.type.name),k=pt(y,S);return Object.keys(d).forEach(x=>{!o.has(x)&&!(x in k)&&c.removeAttribute(x)}),Object.entries(k).forEach(([x,O])=>{o.has(x)||(O!=null?c.setAttribute(x,O):c.removeAttribute(x))}),f(k.src),d=k,!0},p=new Rd({element:c,editor:a,node:i,getPos:s,onResize:(y,S)=>{c.style.width=`${y}px`,c.style.height=`${S}px`},onCommit:(y,S)=>{let k=s();k!==void 0&&this.editor.chain().setNodeSelection(k).updateAttributes(this.name,{width:y,height:S}).run()},onUpdate:h,options:{directions:t,min:{width:e,height:n},preserveAspectRatio:r===!0}}),m=p.dom,g=()=>{m.style.visibility=\"\",m.style.pointerEvents=\"\"};return m.style.visibility=\"hidden\",m.style.pointerEvents=\"none\",c.complete&&c.naturalWidth>0?g():(c.onload=g,c.onerror=g),p}},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[Od({find:Pk,type:this.type,getAttributes:t=>{let[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}});var yl,bl;if(typeof WeakMap<\"u\"){let t=new WeakMap;yl=e=>t.get(e),bl=(e,n)=>(t.set(e,n),n)}else{let t=[],n=0;yl=r=>{for(let o=0;o<t.length;o+=2)if(t[o]==r)return t[o+1]},bl=(r,o)=>(n==10&&(n=0),t[n++]=r,t[n++]=o)}var J=class{constructor(t,e,n,r){this.width=t,this.height=e,this.map=n,this.problems=r}findCell(t){for(let e=0;e<this.map.length;e++){let n=this.map[e];if(n!=t)continue;let r=e%this.width,o=e/this.width|0,i=r+1,s=o+1;for(let l=1;i<this.width&&this.map[e+l]==n;l++)i++;for(let l=1;s<this.height&&this.map[e+this.width*l]==n;l++)s++;return{left:r,top:o,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){let{left:r,right:o,top:i,bottom:s}=this.findCell(t);return e==\"horiz\"?(n<0?r==0:o==this.width)?null:this.map[i*this.width+(n<0?r-1:o)]:(n<0?i==0:s==this.height)?null:this.map[r+this.width*(n<0?i-1:s)]}rectBetween(t,e){let{left:n,right:r,top:o,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(o,a),right:Math.max(r,l),bottom:Math.max(i,c)}}cellsInRect(t){let e=[],n={};for(let r=t.top;r<t.bottom;r++)for(let o=t.left;o<t.right;o++){let i=r*this.width+o,s=this.map[i];n[s]||(n[s]=!0,!(o==t.left&&o&&this.map[i-1]==s||r==t.top&&r&&this.map[i-this.width]==s)&&e.push(s))}return e}positionAt(t,e,n){for(let r=0,o=0;;r++){let i=o+n.child(r).nodeSize;if(r==t){let s=e+t*this.width,l=(t+1)*this.width;for(;s<l&&this.map[s]<o;)s++;return s==l?i-1:this.map[s]}o=i}}static get(t){return yl(t)||bl(t,Lk(t))}};function Lk(t){if(t.type.spec.tableRole!=\"table\")throw new RangeError(\"Not a table node: \"+t.type.name);let e=$k(t),n=t.childCount,r=[],o=0,i=null,s=[];for(let c=0,u=e*n;c<u;c++)r[c]=0;for(let c=0,u=0;c<n;c++){let d=t.child(c);u++;for(let p=0;;p++){for(;o<r.length&&r[o]!=0;)o++;if(p==d.childCount)break;let m=d.child(p),{colspan:g,rowspan:y,colwidth:S}=m.attrs;for(let k=0;k<y;k++){if(k+c>=n){(i||(i=[])).push({type:\"overlong_rowspan\",pos:u,n:y-k});break}let x=o+k*e;for(let O=0;O<g;O++){r[x+O]==0?r[x+O]=u:(i||(i=[])).push({type:\"collision\",row:c,pos:u,n:g-O});let H=S&&S[O];if(H){let T=(x+O)%e*2,I=s[T];I==null||I!=H&&s[T+1]==1?(s[T]=H,s[T+1]=1):I==H&&s[T+1]++}}}o+=g,u+=m.nodeSize}let f=(c+1)*e,h=0;for(;o<f;)r[o++]==0&&h++;h&&(i||(i=[])).push({type:\"missing\",row:c,n:h}),u++}(e===0||n===0)&&(i||(i=[])).push({type:\"zero_sized\"});let l=new J(e,n,r,i),a=!1;for(let c=0;!a&&c<s.length;c+=2)s[c]!=null&&s[c+1]<n&&(a=!0);return a&&zk(l,s,t),l}function $k(t){let e=-1,n=!1;for(let r=0;r<t.childCount;r++){let o=t.child(r),i=0;if(n)for(let s=0;s<r;s++){let l=t.child(s);for(let a=0;a<l.childCount;a++){let c=l.child(a);s+c.attrs.rowspan>r&&(i+=c.attrs.colspan)}}for(let s=0;s<o.childCount;s++){let l=o.child(s);i+=l.attrs.colspan,l.attrs.rowspan>1&&(n=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function zk(t,e,n){t.problems||(t.problems=[]);let r={};for(let o=0;o<t.map.length;o++){let i=t.map[o];if(r[i])continue;r[i]=!0;let s=n.nodeAt(i);if(!s)throw new RangeError(`No cell with offset ${i} found`);let l=null,a=s.attrs;for(let c=0;c<a.colspan;c++){let u=e[(o+c)%t.width*2];u!=null&&(!a.colwidth||a.colwidth[c]!=u)&&((l||(l=Bk(a)))[c]=u)}l&&t.problems.unshift({type:\"colwidth mismatch\",pos:i,colwidth:l})}}function Bk(t){if(t.colwidth)return t.colwidth.slice();let e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function ue(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(let n in t.nodes){let r=t.nodes[n],o=r.spec.tableRole;o&&(e[o]=r)}}return e}var yt=new P(\"selectingCells\");function _t(t){for(let e=t.depth-1;e>0;e--)if(t.node(e).type.spec.tableRole==\"row\")return t.node(0).resolve(t.before(e+1));return null}function Fk(t){for(let e=t.depth;e>0;e--){let n=t.node(e).type.spec.tableRole;if(n===\"cell\"||n===\"header_cell\")return t.node(e)}return null}function De(t){let e=t.selection.$head;for(let n=e.depth;n>0;n--)if(e.node(n).type.spec.tableRole==\"row\")return!0;return!1}function Xo(t){let 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&&e.node.type.spec.tableRole==\"cell\")return e.$anchor;let n=_t(e.$head)||Hk(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function Hk(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){let r=e.type.spec.tableRole;if(r==\"cell\"||r==\"header_cell\")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){let r=e.type.spec.tableRole;if(r==\"cell\"||r==\"header_cell\")return t.doc.resolve(n-e.nodeSize)}}function kl(t){return t.parent.type.spec.tableRole==\"row\"&&!!t.nodeAfter}function jk(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function xl(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function $f(t,e,n){let r=t.node(-1),o=J.get(r),i=t.start(-1),s=o.nextCell(t.pos-i,e,n);return s==null?null:t.node(0).resolve(i+s)}function Kt(t,e,n=1){let r={...t,colspan:t.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some(o=>o>0)||(r.colwidth=null)),r}function zf(t,e,n=1){let r={...t,colspan:t.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let o=0;o<n;o++)r.colwidth.splice(e,0,0)}return r}function Wk(t,e,n){let r=ue(e.type.schema).header_cell;for(let o=0;o<t.height;o++)if(e.nodeAt(t.map[n+o*t.width]).type!=r)return!1;return!0}var j=class ot extends E{constructor(e,n=e){let r=e.node(-1),o=J.get(r),i=e.start(-1),s=o.rectBetween(e.pos-i,n.pos-i),l=e.node(0),a=o.cellsInRect(s).filter(u=>u!=n.pos-i);a.unshift(n.pos-i);let c=a.map(u=>{let d=r.nodeAt(u);if(!d)throw new RangeError(`No cell with offset ${u} found`);let f=i+u+1;return new Zt(l.resolve(f),l.resolve(f+d.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=n}map(e,n){let r=e.resolve(n.map(this.$anchorCell.pos)),o=e.resolve(n.map(this.$headCell.pos));if(kl(r)&&kl(o)&&xl(r,o)){let i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?ot.rowSelection(r,o):i&&this.isColSelection()?ot.colSelection(r,o):new ot(r,o)}return M.between(r,o)}content(){let e=this.$anchorCell.node(-1),n=J.get(e),r=this.$anchorCell.start(-1),o=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},s=[];for(let a=o.top;a<o.bottom;a++){let c=[];for(let u=a*n.width+o.left,d=o.left;d<o.right;d++,u++){let f=n.map[u];if(i[f])continue;i[f]=!0;let h=n.findCell(f),p=e.nodeAt(f);if(!p)throw new RangeError(`No cell with offset ${f} found`);let m=o.left-h.left,g=h.right-o.right;if(m>0||g>0){let y=p.attrs;if(m>0&&(y=Kt(y,0,m)),g>0&&(y=Kt(y,y.colspan-g,g)),h.left<o.left){if(p=p.type.createAndFill(y),!p)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(y)}`)}else p=p.type.create(y,p.content)}if(h.top<o.top||h.bottom>o.bottom){let y={...p.attrs,rowspan:Math.min(h.bottom,o.bottom)-Math.max(h.top,o.top)};h.top<o.top?p=p.type.createAndFill(y):p=p.type.create(y,p.content)}c.push(p)}s.push(e.child(a).copy(b.from(c)))}let l=this.isColSelection()&&this.isRowSelection()?e:s;return new C(b.from(l),1,1)}replace(e,n=C.empty){let r=e.steps.length,o=this.ranges;for(let s=0;s<o.length;s++){let{$from:l,$to:a}=o[s],c=e.mapping.slice(r);e.replace(c.map(l.pos),c.map(a.pos),s?C.empty:n)}let i=E.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,n){this.replace(e,new C(b.from(n),0,0))}forEachCell(e){let n=this.$anchorCell.node(-1),r=J.get(n),o=this.$anchorCell.start(-1),i=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o));for(let s=0;s<i.length;s++)e(n.nodeAt(i[s]),o+i[s])}isColSelection(){let e=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(e,n)>0)return!1;let r=e+this.$anchorCell.nodeAfter.attrs.rowspan,o=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,o)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){let r=e.node(-1),o=J.get(r),i=e.start(-1),s=o.findCell(e.pos-i),l=o.findCell(n.pos-i),a=e.node(0);return s.top<=l.top?(s.top>0&&(e=a.resolve(i+o.map[s.left])),l.bottom<o.height&&(n=a.resolve(i+o.map[o.width*(o.height-1)+l.right-1]))):(l.top>0&&(n=a.resolve(i+o.map[l.left])),s.bottom<o.height&&(e=a.resolve(i+o.map[o.width*(o.height-1)+s.right-1]))),new ot(e,n)}isRowSelection(){let e=this.$anchorCell.node(-1),n=J.get(e),r=this.$anchorCell.start(-1),o=n.colCount(this.$anchorCell.pos-r),i=n.colCount(this.$headCell.pos-r);if(Math.min(o,i)>0)return!1;let s=o+this.$anchorCell.nodeAfter.attrs.colspan,l=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,l)==n.width}eq(e){return e instanceof ot&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){let r=e.node(-1),o=J.get(r),i=e.start(-1),s=o.findCell(e.pos-i),l=o.findCell(n.pos-i),a=e.node(0);return s.left<=l.left?(s.left>0&&(e=a.resolve(i+o.map[s.top*o.width])),l.right<o.width&&(n=a.resolve(i+o.map[o.width*(l.top+1)-1]))):(l.left>0&&(n=a.resolve(i+o.map[l.top*o.width])),s.right<o.width&&(e=a.resolve(i+o.map[o.width*(s.top+1)-1]))),new ot(e,n)}toJSON(){return{type:\"cell\",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new ot(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){return new ot(e.resolve(n),e.resolve(r))}getBookmark(){return new Vk(this.$anchorCell.pos,this.$headCell.pos)}};j.prototype.visible=!1;E.jsonID(\"cell\",j);var Vk=class Bf{constructor(e,n){this.anchor=e,this.head=n}map(e){return new Bf(e.map(this.anchor),e.map(this.head))}resolve(e){let n=e.resolve(this.anchor),r=e.resolve(this.head);return n.parent.type.spec.tableRole==\"row\"&&r.parent.type.spec.tableRole==\"row\"&&n.index()<n.parent.childCount&&r.index()<r.parent.childCount&&xl(n,r)?new j(n,r):E.near(r,1)}};function _k(t){if(!(t.selection instanceof j))return null;let e=[];return t.selection.forEachCell((n,r)=>{e.push(ee.node(r,r+n.nodeSize,{class:\"selectedCell\"}))}),z.create(t.doc,e)}function Kk({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let n=t.pos,r=e.pos,o=t.depth;for(;o>=0&&!(t.after(o+1)<t.end(o));o--,n++);for(let i=e.depth;i>=0&&!(e.before(i+1)>e.start(i));i--,r--);return n==r&&/row|table/.test(t.node(o).type.spec.tableRole)}function Uk({$from:t,$to:e}){let n,r;for(let o=t.depth;o>0;o--){let i=t.node(o);if(i.type.spec.tableRole===\"cell\"||i.type.spec.tableRole===\"header_cell\"){n=i;break}}for(let o=e.depth;o>0;o--){let i=e.node(o);if(i.type.spec.tableRole===\"cell\"||i.type.spec.tableRole===\"header_cell\"){r=i;break}}return n!==r&&e.parentOffset===0}function Jk(t,e,n){let r=(e||t).selection,o=(e||t).doc,i,s;if(r instanceof A&&(s=r.node.type.spec.tableRole)){if(s==\"cell\"||s==\"header_cell\")i=j.create(o,r.from);else if(s==\"row\"){let l=o.resolve(r.from+1);i=j.rowSelection(l,l)}else if(!n){let l=J.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];i=j.create(o,a+1,c)}}else r instanceof M&&Kk(r)?i=M.create(o,r.from):r instanceof M&&Uk(r)&&(i=M.create(o,r.$from.start(),r.$from.end()));return i&&(e||(e=t.tr)).setSelection(i),e}var qk=new P(\"fix-tables\");function Ff(t,e,n,r){let o=t.childCount,i=e.childCount;e:for(let s=0,l=0;s<i;s++){let a=e.child(s);for(let c=l,u=Math.min(o,s+3);c<u;c++)if(t.child(c)==a){l=c+1,n+=a.nodeSize;continue e}r(a,n),l<o&&t.child(l).sameMarkup(a)?Ff(t.child(l),a,n+1,r):a.nodesBetween(0,a.content.size,r,n+1),n+=a.nodeSize}}function Cl(t,e){let n,r=(o,i)=>{o.type.spec.tableRole==\"table\"&&(n=Gk(t,o,i,n))};return e?e.doc!=t.doc&&Ff(e.doc,t.doc,0,r):t.doc.descendants(r),n}function Gk(t,e,n,r){let o=J.get(e);if(!o.problems)return r;r||(r=t.tr);let i=[];for(let a=0;a<o.height;a++)i.push(0);for(let a=0;a<o.problems.length;a++){let c=o.problems[a];if(c.type==\"collision\"){let u=e.nodeAt(c.pos);if(!u)continue;let d=u.attrs;for(let f=0;f<d.rowspan;f++)i[c.row+f]+=c.n;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,Kt(d,d.colspan-c.n,c.n))}else if(c.type==\"missing\")i[c.row]+=c.n;else if(c.type==\"overlong_rowspan\"){let u=e.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...u.attrs,rowspan:u.attrs.rowspan-c.n})}else if(c.type==\"colwidth mismatch\"){let u=e.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...u.attrs,colwidth:c.colwidth})}else if(c.type==\"zero_sized\"){let u=r.mapping.map(n);r.delete(u,u+e.nodeSize)}}let s,l;for(let a=0;a<i.length;a++)i[a]&&(s==null&&(s=a),l=a);for(let a=0,c=n+1;a<o.height;a++){let u=e.child(a),d=c+u.nodeSize,f=i[a];if(f>0){let h=\"cell\";u.firstChild&&(h=u.firstChild.type.spec.tableRole);let p=[];for(let g=0;g<f;g++){let y=ue(t.schema)[h].createAndFill();y&&p.push(y)}let m=(a==0||s==a-1)&&l==a?c+1:d-1;r.insert(r.mapping.map(m),p)}c=d}return r.setMeta(qk,{fixTables:!0})}function He(t){let e=t.selection,n=Xo(t),r=n.node(-1),o=n.start(-1),i=J.get(r);return{...e instanceof j?i.rectBetween(e.$anchorCell.pos-o,e.$headCell.pos-o):i.findCell(n.pos-o),tableStart:o,map:i,table:r}}function Hf(t,{map:e,tableStart:n,table:r},o){let i=o>0?-1:0;Wk(e,r,o+i)&&(i=o==0||o==e.width?null:0);for(let s=0;s<e.height;s++){let l=s*e.width+o;if(o>0&&o<e.width&&e.map[l-1]==e.map[l]){let a=e.map[l],c=r.nodeAt(a);t.setNodeMarkup(t.mapping.map(n+a),null,zf(c.attrs,o-e.colCount(a))),s+=c.attrs.rowspan-1}else{let a=i==null?ue(r.type.schema).cell:r.nodeAt(e.map[l+i]).type,c=e.positionAt(s,o,r);t.insert(t.mapping.map(n+c),a.createAndFill())}}return t}function jf(t,e){if(!De(t))return!1;if(e){let n=He(t);e(Hf(t.tr,n,n.left))}return!0}function Wf(t,e){if(!De(t))return!1;if(e){let n=He(t);e(Hf(t.tr,n,n.right))}return!0}function Xk(t,{map:e,table:n,tableStart:r},o){let i=t.mapping.maps.length;for(let s=0;s<e.height;){let l=s*e.width+o,a=e.map[l],c=n.nodeAt(a),u=c.attrs;if(o>0&&e.map[l-1]==a||o<e.width-1&&e.map[l+1]==a)t.setNodeMarkup(t.mapping.slice(i).map(r+a),null,Kt(u,o-e.colCount(a)));else{let d=t.mapping.slice(i).map(r+a);t.delete(d,d+c.nodeSize)}s+=u.rowspan}}function Vf(t,e){if(!De(t))return!1;if(e){let n=He(t),r=t.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let o=n.right-1;Xk(r,n,o),o!=n.left;o--){let i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw new RangeError(\"No table found\");n.table=i,n.map=J.get(i)}e(r)}return!0}function Yk(t,e,n){var r;let o=ue(e.type.schema).header_cell;for(let i=0;i<t.width;i++)if(((r=e.nodeAt(t.map[i+n*t.width]))===null||r===void 0?void 0:r.type)!=o)return!1;return!0}function _f(t,{map:e,tableStart:n,table:r},o){let i=n;for(let c=0;c<o;c++)i+=r.child(c).nodeSize;let s=[],l=o>0?-1:0;Yk(e,r,o+l)&&(l=o==0||o==e.height?null:0);for(let c=0,u=e.width*o;c<e.width;c++,u++)if(o>0&&o<e.height&&e.map[u]==e.map[u-e.width]){let d=e.map[u],f=r.nodeAt(d).attrs;t.setNodeMarkup(n+d,null,{...f,rowspan:f.rowspan+1}),c+=f.colspan-1}else{var a;let d=l==null?ue(r.type.schema).cell:(a=r.nodeAt(e.map[u+l*e.width]))===null||a===void 0?void 0:a.type,f=d?.createAndFill();f&&s.push(f)}return t.insert(i,ue(r.type.schema).row.create(null,s)),t}function Kf(t,e){if(!De(t))return!1;if(e){let n=He(t);e(_f(t.tr,n,n.top))}return!0}function Uf(t,e){if(!De(t))return!1;if(e){let n=He(t);e(_f(t.tr,n,n.bottom))}return!0}function Qk(t,{map:e,table:n,tableStart:r},o){let i=0;for(let c=0;c<o;c++)i+=n.child(c).nodeSize;let s=i+n.child(o).nodeSize,l=t.mapping.maps.length;t.delete(i+r,s+r);let a=new Set;for(let c=0,u=o*e.width;c<e.width;c++,u++){let d=e.map[u];if(!a.has(d)){if(a.add(d),o>0&&d==e.map[u-e.width]){let f=n.nodeAt(d).attrs;t.setNodeMarkup(t.mapping.slice(l).map(d+r),null,{...f,rowspan:f.rowspan-1}),c+=f.colspan-1}else if(o<e.height&&d==e.map[u+e.width]){let f=n.nodeAt(d),h=f.attrs,p=f.type.create({...h,rowspan:f.attrs.rowspan-1},f.content),m=e.positionAt(o+1,c,n);t.insert(t.mapping.slice(l).map(r+m),p),c+=h.colspan-1}}}}function Jf(t,e){if(!De(t))return!1;if(e){let n=He(t),r=t.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let o=n.bottom-1;Qk(r,n,o),o!=n.top;o--){let i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw new RangeError(\"No table found\");n.table=i,n.map=J.get(n.table)}e(r)}return!0}function Af(t){let e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function Zk({width:t,height:e,map:n},r){let o=r.top*t+r.left,i=o,s=(r.bottom-1)*t+r.left,l=o+(r.right-r.left-1);for(let a=r.top;a<r.bottom;a++){if(r.left>0&&n[i]==n[i-1]||r.right<t&&n[l]==n[l+1])return!0;i+=t,l+=t}for(let a=r.left;a<r.right;a++){if(r.top>0&&n[o]==n[o-t]||r.bottom<e&&n[s]==n[s+t])return!0;o++,s++}return!1}function Ml(t,e){let n=t.selection;if(!(n instanceof j)||n.$anchorCell.pos==n.$headCell.pos)return!1;let r=He(t),{map:o}=r;if(Zk(o,r))return!1;if(e){let i=t.tr,s={},l=b.empty,a,c;for(let u=r.top;u<r.bottom;u++)for(let d=r.left;d<r.right;d++){let f=o.map[u*o.width+d],h=r.table.nodeAt(f);if(!(s[f]||!h))if(s[f]=!0,a==null)a=f,c=h;else{Af(h)||(l=l.append(h.content));let p=i.mapping.map(f+r.tableStart);i.delete(p,p+h.nodeSize)}}if(a==null||c==null)return!0;if(i.setNodeMarkup(a+r.tableStart,null,{...zf(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),l.size>0){let u=a+1+c.content.size,d=Af(c)?a+1:u;i.replaceWith(d+r.tableStart,u+r.tableStart,l)}i.setSelection(new j(i.doc.resolve(a+r.tableStart))),e(i)}return!0}function vl(t,e){let n=ue(t.schema);return e1(({node:r})=>n[r.type.spec.tableRole])(t,e)}function e1(t){return(e,n)=>{let r=e.selection,o,i;if(r instanceof j){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;o=r.$anchorCell.nodeAfter,i=r.$anchorCell.pos}else{var s;if(o=Fk(r.$from),!o)return!1;i=(s=_t(r.$from))===null||s===void 0?void 0:s.pos}if(o==null||i==null||o.attrs.colspan==1&&o.attrs.rowspan==1)return!1;if(n){let l=o.attrs,a=[],c=l.colwidth;l.rowspan>1&&(l={...l,rowspan:1}),l.colspan>1&&(l={...l,colspan:1});let u=He(e),d=e.tr;for(let h=0;h<u.right-u.left;h++)a.push(c?{...l,colwidth:c&&c[h]?[c[h]]:null}:l);let f;for(let h=u.top;h<u.bottom;h++){let p=u.map.positionAt(h,u.left,u.table);h==u.top&&(p+=o.nodeSize);for(let m=u.left,g=0;m<u.right;m++,g++)m==u.left&&h==u.top||d.insert(f=d.mapping.map(p+u.tableStart,1),t({node:o,row:h,col:m}).createAndFill(a[g]))}d.setNodeMarkup(i,t({node:o,row:u.top,col:u.left}),a[0]),r instanceof j&&d.setSelection(new j(d.doc.resolve(r.$anchorCell.pos),f?d.doc.resolve(f):void 0)),n(d)}return!0}}function qf(t,e){return function(n,r){if(!De(n))return!1;let o=Xo(n);if(o.nodeAfter.attrs[t]===e)return!1;if(r){let i=n.tr;n.selection instanceof j?n.selection.forEachCell((s,l)=>{s.attrs[t]!==e&&i.setNodeMarkup(l,null,{...s.attrs,[t]:e})}):i.setNodeMarkup(o.pos,null,{...o.nodeAfter.attrs,[t]:e}),r(i)}return!0}}function t1(t){return function(e,n){if(!De(e))return!1;if(n){let r=ue(e.schema),o=He(e),i=e.tr,s=o.map.cellsInRect(t==\"column\"?{left:o.left,top:0,right:o.right,bottom:o.map.height}:t==\"row\"?{left:0,top:o.top,right:o.map.width,bottom:o.bottom}:o),l=s.map(a=>o.table.nodeAt(a));for(let a=0;a<s.length;a++)l[a].type==r.header_cell&&i.setNodeMarkup(o.tableStart+s[a],r.cell,l[a].attrs);if(i.steps.length===0)for(let a=0;a<s.length;a++)i.setNodeMarkup(o.tableStart+s[a],r.header_cell,l[a].attrs);n(i)}return!0}}function Tf(t,e,n){let r=e.map.cellsInRect({left:0,top:0,right:t==\"row\"?e.map.width:1,bottom:t==\"column\"?e.map.height:1});for(let o=0;o<r.length;o++){let i=e.table.nodeAt(r[o]);if(i&&i.type!==n.header_cell)return!1}return!0}function Cn(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?t1(t):function(n,r){if(!De(n))return!1;if(r){let o=ue(n.schema),i=He(n),s=n.tr,l=Tf(\"row\",i,o),a=Tf(\"column\",i,o),c=(t===\"column\"?l:t===\"row\"&&a)?1:0,u=t==\"column\"?{left:0,top:c,right:1,bottom:i.map.height}:t==\"row\"?{left:c,top:0,right:i.map.width,bottom:1}:i,d=t==\"column\"?a?o.cell:o.header_cell:t==\"row\"?l?o.cell:o.header_cell:o.cell;i.map.cellsInRect(u).forEach(f=>{let h=f+i.tableStart,p=s.doc.nodeAt(h);p&&s.setNodeMarkup(h,d,p.attrs)}),r(s)}return!0}}var _x=Cn(\"row\",{useDeprecatedLogic:!0}),Kx=Cn(\"column\",{useDeprecatedLogic:!0}),Gf=Cn(\"cell\",{useDeprecatedLogic:!0});function n1(t,e){if(e<0){let n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let r=t.index(-1)-1,o=t.before();r>=0;r--){let i=t.node(-1).child(r),s=i.lastChild;if(s)return o-1-s.nodeSize;o-=i.nodeSize}}else{if(t.index()<t.parent.childCount-1)return t.pos+t.nodeAfter.nodeSize;let n=t.node(-1);for(let r=t.indexAfter(-1),o=t.after();r<n.childCount;r++){let i=n.child(r);if(i.childCount)return o+1;o+=i.nodeSize}}return null}function El(t){return function(e,n){if(!De(e))return!1;let r=n1(Xo(e),t);if(r==null)return!1;if(n){let o=e.doc.resolve(r);n(e.tr.setSelection(M.between(o,jk(o))).scrollIntoView())}return!0}}function Xf(t,e){let n=t.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole==\"table\")return e&&e(t.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function Ko(t,e){let n=t.selection;if(!(n instanceof j))return!1;if(e){let r=t.tr,o=ue(t.schema).cell.createAndFill().content;n.forEachCell((i,s)=>{i.content.eq(o)||r.replace(r.mapping.map(s+1),r.mapping.map(s+i.nodeSize-1),new C(o,0,0))}),r.docChanged&&e(r)}return!0}function r1(t){if(t.size===0)return null;let{content:e,openStart:n,openEnd:r}=t;for(;e.childCount==1&&(n>0&&r>0||e.child(0).type.spec.tableRole==\"table\");)n--,r--,e=e.child(0).content;let o=e.child(0),i=o.type.spec.tableRole,s=o.type.schema,l=[];if(i==\"row\")for(let a=0;a<e.childCount;a++){let c=e.child(a).content,u=a?0:Math.max(0,n-1),d=a<e.childCount-1?0:Math.max(0,r-1);(u||d)&&(c=wl(ue(s).row,new C(c,u,d)).content),l.push(c)}else if(i==\"cell\"||i==\"header_cell\")l.push(n||r?wl(ue(s).row,new C(e,n,r)).content:e);else return null;return o1(s,l)}function o1(t,e){let n=[];for(let o=0;o<e.length;o++){let i=e[o];for(let s=i.childCount-1;s>=0;s--){let{rowspan:l,colspan:a}=i.child(s).attrs;for(let c=o;c<o+l;c++)n[c]=(n[c]||0)+a}}let r=0;for(let o=0;o<n.length;o++)r=Math.max(r,n[o]);for(let o=0;o<n.length;o++)if(o>=e.length&&e.push(b.empty),n[o]<r){let i=ue(t).cell.createAndFill(),s=[];for(let l=n[o];l<r;l++)s.push(i);e[o]=e[o].append(b.from(s))}return{height:e.length,width:r,rows:e}}function wl(t,e){let n=t.createAndFill();return new st(n).replace(0,n.content.size,e).doc}function i1({width:t,height:e,rows:n},r,o){if(t!=r){let i=[],s=[];for(let l=0;l<n.length;l++){let a=n[l],c=[];for(let u=i[l]||0,d=0;u<r;d++){let f=a.child(d%a.childCount);u+f.attrs.colspan>r&&(f=f.type.createChecked(Kt(f.attrs,f.attrs.colspan,u+f.attrs.colspan-r),f.content)),c.push(f),u+=f.attrs.colspan;for(let h=1;h<f.attrs.rowspan;h++)i[l+h]=(i[l+h]||0)+f.attrs.colspan}s.push(b.from(c))}n=s,t=r}if(e!=o){let i=[];for(let s=0,l=0;s<o;s++,l++){let a=[],c=n[l%e];for(let u=0;u<c.childCount;u++){let d=c.child(u);s+d.attrs.rowspan>o&&(d=d.type.create({...d.attrs,rowspan:Math.max(1,o-d.attrs.rowspan)},d.content)),a.push(d)}i.push(b.from(a))}n=i,e=o}return{width:t,height:e,rows:n}}function s1(t,e,n,r,o,i,s){let l=t.doc.type.schema,a=ue(l),c,u;if(o>e.width)for(let d=0,f=0;d<e.height;d++){let h=n.child(d);f+=h.nodeSize;let p=[],m;h.lastChild==null||h.lastChild.type==a.cell?m=c||(c=a.cell.createAndFill()):m=u||(u=a.header_cell.createAndFill());for(let g=e.width;g<o;g++)p.push(m);t.insert(t.mapping.slice(s).map(f-1+r),p)}if(i>e.height){let d=[];for(let p=0,m=(e.height-1)*e.width;p<Math.max(e.width,o);p++){let g=p>=e.width?!1:n.nodeAt(e.map[m+p]).type==a.header_cell;d.push(g?u||(u=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}let f=a.row.create(null,b.from(d)),h=[];for(let p=e.height;p<i;p++)h.push(f);t.insert(t.mapping.slice(s).map(r+n.nodeSize-2),h)}return!!(c||u)}function Nf(t,e,n,r,o,i,s,l){if(s==0||s==e.height)return!1;let a=!1;for(let c=o;c<i;c++){let u=s*e.width+c,d=e.map[u];if(e.map[u-e.width]==d){a=!0;let f=n.nodeAt(d),{top:h,left:p}=e.findCell(d);t.setNodeMarkup(t.mapping.slice(l).map(d+r),null,{...f.attrs,rowspan:s-h}),t.insert(t.mapping.slice(l).map(e.positionAt(s,p,n)),f.type.createAndFill({...f.attrs,rowspan:h+f.attrs.rowspan-s})),c+=f.attrs.colspan-1}}return a}function Of(t,e,n,r,o,i,s,l){if(s==0||s==e.width)return!1;let a=!1;for(let c=o;c<i;c++){let u=c*e.width+s,d=e.map[u];if(e.map[u-1]==d){a=!0;let f=n.nodeAt(d),h=e.colCount(d),p=t.mapping.slice(l).map(d+r);t.setNodeMarkup(p,null,Kt(f.attrs,s-h,f.attrs.colspan-(s-h))),t.insert(p+f.nodeSize,f.type.createAndFill(Kt(f.attrs,0,s-h))),c+=f.attrs.rowspan-1}}return a}function Rf(t,e,n,r,o){let i=n?t.doc.nodeAt(n-1):t.doc;if(!i)throw new Error(\"No table found\");let s=J.get(i),{top:l,left:a}=r,c=a+o.width,u=l+o.height,d=t.tr,f=0;function h(){if(i=n?d.doc.nodeAt(n-1):d.doc,!i)throw new Error(\"No table found\");s=J.get(i),f=d.mapping.maps.length}s1(d,s,i,n,c,u,f)&&h(),Nf(d,s,i,n,a,c,l,f)&&h(),Nf(d,s,i,n,a,c,u,f)&&h(),Of(d,s,i,n,l,u,a,f)&&h(),Of(d,s,i,n,l,u,c,f)&&h();for(let p=l;p<u;p++){let m=s.positionAt(p,a,i),g=s.positionAt(p,c,i);d.replace(d.mapping.slice(f).map(m+n),d.mapping.slice(f).map(g+n),new C(o.rows[p-l],0,0))}h(),d.setSelection(new j(d.doc.resolve(n+s.positionAt(l,a,i)),d.doc.resolve(n+s.positionAt(u-1,c-1,i)))),e(d)}var l1=qn({ArrowLeft:Uo(\"horiz\",-1),ArrowRight:Uo(\"horiz\",1),ArrowUp:Uo(\"vert\",-1),ArrowDown:Uo(\"vert\",1),\"Shift-ArrowLeft\":Jo(\"horiz\",-1),\"Shift-ArrowRight\":Jo(\"horiz\",1),\"Shift-ArrowUp\":Jo(\"vert\",-1),\"Shift-ArrowDown\":Jo(\"vert\",1),Backspace:Ko,\"Mod-Backspace\":Ko,Delete:Ko,\"Mod-Delete\":Ko});function qo(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function Uo(t,e){return(n,r,o)=>{if(!o)return!1;let i=n.selection;if(i instanceof j)return qo(n,r,E.near(i.$headCell,e));if(t!=\"horiz\"&&!i.empty)return!1;let s=Yf(o,t,e);if(s==null)return!1;if(t==\"horiz\")return qo(n,r,E.near(n.doc.resolve(i.head+e),e));{let l=n.doc.resolve(s),a=$f(l,t,e),c;return a?c=E.near(a,1):e<0?c=E.near(n.doc.resolve(l.before(-1)),-1):c=E.near(n.doc.resolve(l.after(-1)),1),qo(n,r,c)}}}function Jo(t,e){return(n,r,o)=>{if(!o)return!1;let i=n.selection,s;if(i instanceof j)s=i;else{let a=Yf(o,t,e);if(a==null)return!1;s=new j(n.doc.resolve(a))}let l=$f(s.$headCell,t,e);return l?qo(n,r,new j(s.$anchorCell,l)):!1}}function a1(t,e){let n=t.state.doc,r=_t(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new j(r))),!0):!1}function c1(t,e,n){if(!De(t.state))return!1;let r=r1(n),o=t.state.selection;if(o instanceof j){r||(r={width:1,height:1,rows:[b.from(wl(ue(t.state.schema).cell,n))]});let i=o.$anchorCell.node(-1),s=o.$anchorCell.start(-1),l=J.get(i).rectBetween(o.$anchorCell.pos-s,o.$headCell.pos-s);return r=i1(r,l.right-l.left,l.bottom-l.top),Rf(t.state,t.dispatch,s,l,r),!0}else if(r){let i=Xo(t.state),s=i.start(-1);return Rf(t.state,t.dispatch,s,J.get(i.node(-1)).findCell(i.pos-s),r),!0}else return!1}function u1(t,e){var n;if(e.button!=0||e.ctrlKey||e.metaKey)return;let r=Df(t,e.target),o;if(e.shiftKey&&t.state.selection instanceof j)i(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(o=_t(t.state.selection.$anchor))!=null&&((n=gl(t,e))===null||n===void 0?void 0:n.pos)!=o.pos)i(o,e),e.preventDefault();else if(!r)return;function i(a,c){let u=gl(t,c),d=yt.getState(t.state)==null;if(!u||!xl(a,u))if(d)u=a;else return;let f=new j(a,u);if(d||!t.state.selection.eq(f)){let h=t.state.tr.setSelection(f);d&&h.setMeta(yt,a.pos),t.dispatch(h)}}function s(){t.root.removeEventListener(\"mouseup\",s),t.root.removeEventListener(\"dragstart\",s),t.root.removeEventListener(\"mousemove\",l),yt.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(yt,-1))}function l(a){let c=a,u=yt.getState(t.state),d;if(u!=null)d=t.state.doc.resolve(u);else if(Df(t,c.target)!=r&&(d=gl(t,e),!d))return s();d&&i(d,c)}t.root.addEventListener(\"mouseup\",s),t.root.addEventListener(\"dragstart\",s),t.root.addEventListener(\"mousemove\",l)}function Yf(t,e,n){if(!(t.state.selection instanceof M))return null;let{$head:r}=t.state.selection;for(let o=r.depth-1;o>=0;o--){let i=r.node(o);if((n<0?r.index(o):r.indexAfter(o))!=(n<0?0:i.childCount))return null;if(i.type.spec.tableRole==\"cell\"||i.type.spec.tableRole==\"header_cell\"){let s=r.before(o),l=e==\"vert\"?n>0?\"down\":\"up\":n>0?\"right\":\"left\";return t.endOfTextblock(l)?s:null}}return null}function Df(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName==\"TD\"||e.nodeName==\"TH\")return e;return null}function gl(t,e){let n=t.posAtCoords({left:e.clientX,top:e.clientY});if(!n)return null;let{inside:r,pos:o}=n;return r>=0&&_t(t.state.doc.resolve(r))||_t(t.state.doc.resolve(o))}var d1=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\")),Sl(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement(\"tbody\"))}update(t){return t.type!=this.node.type?!1:(this.node=t,Sl(t,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(t){return t.type==\"attributes\"&&(t.target==this.table||this.colgroup.contains(t.target))}};function Sl(t,e,n,r,o,i){let s=0,l=!0,a=e.firstChild,c=t.firstChild;if(c){for(let d=0,f=0;d<c.childCount;d++){let{colspan:h,colwidth:p}=c.child(d).attrs;for(let m=0;m<h;m++,f++){let g=o==f?i:p&&p[m],y=g?g+\"px\":\"\";if(s+=g||r,g||(l=!1),a)a.style.width!=y&&(a.style.width=y),a=a.nextSibling;else{let S=document.createElement(\"col\");S.style.width=y,e.appendChild(S)}}}for(;a;){var u;let d=a.nextSibling;(u=a.parentNode)===null||u===void 0||u.removeChild(a),a=d}l?(n.style.width=s+\"px\",n.style.minWidth=\"\"):(n.style.width=\"\",n.style.minWidth=s+\"px\")}}var Se=new P(\"tableColumnResizing\");function Qf({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:r=d1,lastColumnResizable:o=!0}={}){let i=new R({key:Se,state:{init(s,l){var a;let c=(a=i.spec)===null||a===void 0||(a=a.props)===null||a===void 0?void 0:a.nodeViews,u=ue(l.schema).table.name;return r&&c&&(c[u]=(d,f)=>new r(d,n,f)),new f1(-1,!1)},apply(s,l){return l.apply(s)}},props:{attributes:s=>{let l=Se.getState(s);return l&&l.activeHandle>-1?{class:\"resize-cursor\"}:{}},handleDOMEvents:{mousemove:(s,l)=>{h1(s,l,t,o)},mouseleave:s=>{p1(s)},mousedown:(s,l)=>{m1(s,l,e,n)}},decorations:s=>{let l=Se.getState(s);if(l&&l.activeHandle>-1)return w1(s,l.activeHandle)},nodeViews:{}}});return i}var f1=class Go{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){let n=this,r=e.getMeta(Se);if(r&&r.setHandle!=null)return new Go(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new Go(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let o=e.mapping.map(n.activeHandle,-1);return kl(e.doc.resolve(o))||(o=-1),new Go(o,n.dragging)}return n}};function h1(t,e,n,r){if(!t.editable)return;let o=Se.getState(t.state);if(o&&!o.dragging){let i=y1(e.target),s=-1;if(i){let{left:l,right:a}=i.getBoundingClientRect();e.clientX-l<=n?s=If(t,e,\"left\",n):a-e.clientX<=n&&(s=If(t,e,\"right\",n))}if(s!=o.activeHandle){if(!r&&s!==-1){let l=t.state.doc.resolve(s),a=l.node(-1),c=J.get(a),u=l.start(-1);if(c.colCount(l.pos-u)+l.nodeAfter.attrs.colspan-1==c.width-1)return}Zf(t,s)}}}function p1(t){if(!t.editable)return;let e=Se.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&Zf(t,-1)}function m1(t,e,n,r){var o;if(!t.editable)return!1;let i=(o=t.dom.ownerDocument.defaultView)!==null&&o!==void 0?o:window,s=Se.getState(t.state);if(!s||s.activeHandle==-1||s.dragging)return!1;let l=t.state.doc.nodeAt(s.activeHandle),a=g1(t,s.activeHandle,l.attrs);t.dispatch(t.state.tr.setMeta(Se,{setDragging:{startX:e.clientX,startWidth:a}}));function c(d){i.removeEventListener(\"mouseup\",c),i.removeEventListener(\"mousemove\",u);let f=Se.getState(t.state);f?.dragging&&(b1(t,f.activeHandle,Pf(f.dragging,d,n)),t.dispatch(t.state.tr.setMeta(Se,{setDragging:null})))}function u(d){if(!d.which)return c(d);let f=Se.getState(t.state);if(f&&f.dragging){let h=Pf(f.dragging,d,n);Lf(t,f.activeHandle,h,r)}}return Lf(t,s.activeHandle,a,r),i.addEventListener(\"mouseup\",c),i.addEventListener(\"mousemove\",u),e.preventDefault(),!0}function g1(t,e,{colspan:n,colwidth:r}){let o=r&&r[r.length-1];if(o)return o;let i=t.domAtPos(e),s=i.node.childNodes[i.offset].offsetWidth,l=n;if(r)for(let a=0;a<n;a++)r[a]&&(s-=r[a],l--);return s/l}function y1(t){for(;t&&t.nodeName!=\"TD\"&&t.nodeName!=\"TH\";)t=t.classList&&t.classList.contains(\"ProseMirror\")?null:t.parentNode;return t}function If(t,e,n,r){let o=n==\"right\"?-r:r,i=t.posAtCoords({left:e.clientX+o,top:e.clientY});if(!i)return-1;let{pos:s}=i,l=_t(t.state.doc.resolve(s));if(!l)return-1;if(n==\"right\")return l.pos;let a=J.get(l.node(-1)),c=l.start(-1),u=a.map.indexOf(l.pos-c);return u%a.width==0?-1:c+a.map[u-1]}function Pf(t,e,n){let r=e.clientX-t.startX;return Math.max(n,t.startWidth+r)}function Zf(t,e){t.dispatch(t.state.tr.setMeta(Se,{setHandle:e}))}function b1(t,e,n){let r=t.state.doc.resolve(e),o=r.node(-1),i=J.get(o),s=r.start(-1),l=i.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1,a=t.state.tr;for(let c=0;c<i.height;c++){let u=c*i.width+l;if(c&&i.map[u]==i.map[u-i.width])continue;let d=i.map[u],f=o.nodeAt(d).attrs,h=f.colspan==1?0:l-i.colCount(d);if(f.colwidth&&f.colwidth[h]==n)continue;let p=f.colwidth?f.colwidth.slice():k1(f.colspan);p[h]=n,a.setNodeMarkup(s+d,null,{...f,colwidth:p})}a.docChanged&&t.dispatch(a)}function Lf(t,e,n,r){let o=t.state.doc.resolve(e),i=o.node(-1),s=o.start(-1),l=J.get(i).colCount(o.pos-s)+o.nodeAfter.attrs.colspan-1,a=t.domAtPos(o.start(-1)).node;for(;a&&a.nodeName!=\"TABLE\";)a=a.parentNode;a&&Sl(i,a.firstChild,a,r,l,n)}function k1(t){return Array(t).fill(0)}function w1(t,e){let n=[],r=t.doc.resolve(e),o=r.node(-1);if(!o)return z.empty;let i=J.get(o),s=r.start(-1),l=i.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1;for(let c=0;c<i.height;c++){let u=l+c*i.width;if((l==i.width-1||i.map[u]!=i.map[u+1])&&(c==0||i.map[u]!=i.map[u-i.width])){var a;let d=i.map[u],f=s+d+o.nodeAt(d).nodeSize-1,h=document.createElement(\"div\");h.className=\"column-resize-handle\",!((a=Se.getState(t))===null||a===void 0)&&a.dragging&&n.push(ee.node(s+d,s+d+o.nodeAt(d).nodeSize,{class:\"column-resize-dragging\"})),n.push(ee.widget(f,h))}}return z.create(t.doc,n)}function eh({allowTableNodeSelection:t=!1}={}){return new R({key:yt,state:{init(){return null},apply(e,n){let r=e.getMeta(yt);if(r!=null)return r==-1?null:r;if(n==null||!e.docChanged)return n;let{deleted:o,pos:i}=e.mapping.mapResult(n);return o?null:i}},props:{decorations:_k,handleDOMEvents:{mousedown:u1},createSelectionBetween(e){return yt.getState(e.state)!=null?e.state.selection:null},handleTripleClick:a1,handleKeyDown:l1,handlePaste:c1},appendTransaction(e,n,r){return Jk(r,Cl(r,n),t)}})}function ar(t){return t===\"left\"||t===\"right\"||t===\"center\"?t:null}function S1(t){let e=(t.style.textAlign||\"\").trim().toLowerCase(),n=(t.getAttribute(\"align\")||\"\").trim().toLowerCase();return ar(e||n)}function x1(t){return ar(t?.align)}function ih(){return{default:null,parseHTML:t=>S1(t),renderHTML:t=>{let e=ar(t.align);return vd(e)?{style:`text-align: ${e}`}:{}}}}function C1(t){var e;let n=t.parentElement,r=t.closest(\"table\");if(!n||!r)return null;let o=Array.from(n.children).indexOf(t),i=(e=r.querySelectorAll(\"colgroup > col\")[o])===null||e===void 0?void 0:e.getAttribute(\"width\");return i?[parseInt(i,10)]:null}function sh(t){let e=t.getAttribute(\"colwidth\");return e?e.split(\",\").map(n=>parseInt(n,10)):C1(t)}var M1=/[ \\t\\r\\n\\f]+/g;function lh(t){var e;return t.children.length>0?!1:((e=t.textContent)!==null&&e!==void 0?e:\"\").replace(M1,\"\")===\"\"}function ah(t){let e=t.createAndFill();if(!e)throw new Error(`[tiptap error]: \"${t.name}\" has no default content to backfill.`);return e.content}function Qo(t,e,n){if(!(n in e))return;let r=e[n];(r===1||r===\"1\"||r===null||r===void 0)&&delete t[n]}var Tl=K.create({name:\"tableCell\",addOptions(){return{HTMLAttributes:{}}},content:\"block+\",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:sh},align:ih()}},tableRole:\"cell\",isolating:!0,parseHTML(){return[{tag:\"td\",getAttrs:t=>lh(t)?{}:!1,getContent:(t,e)=>ah(e.nodes[this.name])},{tag:\"td\"}]},renderHTML({HTMLAttributes:t}){let e=B(this.options.HTMLAttributes,t);return Qo(e,t,\"colspan\"),Qo(e,t,\"rowspan\"),[\"td\",e,0]}}),Nl=K.create({name:\"tableHeader\",addOptions(){return{HTMLAttributes:{}}},content:\"block+\",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:sh},align:ih()}},tableRole:\"header_cell\",isolating:!0,parseHTML(){return[{tag:\"th\",getAttrs:t=>lh(t)?{}:!1,getContent:(t,e)=>ah(e.nodes[this.name])},{tag:\"th\"}]},renderHTML({HTMLAttributes:t}){let e=B(this.options.HTMLAttributes,t);return Qo(e,t,\"colspan\"),Qo(e,t,\"rowspan\"),[\"th\",e,0]}}),Ol=K.create({name:\"tableRow\",addOptions(){return{HTMLAttributes:{}}},content:\"(tableCell | tableHeader)*\",tableRole:\"row\",parseHTML(){return[{tag:\"tr\"}]},renderHTML({HTMLAttributes:t}){return[\"tr\",B(this.options.HTMLAttributes,t),0]}});function Al(t,e){return e?[\"width\",`${Math.max(e,t)}px`]:[\"min-width\",`${t}px`]}function th(t,e,n,r,o,i){let s=0,l=!0,a=e.firstChild,c=t.firstChild;if(c!==null)for(let f=0,h=0;f<c.childCount;f+=1){let{colspan:p,colwidth:m}=c.child(f).attrs;for(let g=0;g<p;g+=1,h+=1){let y=o===h?i:m&&m[g],S=y?`${y}px`:\"\";if(s+=y||r,y||(l=!1),a){if(a.style.width!==S){let[k,x]=Al(r,y);a.style.setProperty(k,x)}a=a.nextSibling}else{let k=document.createElement(\"col\"),[x,O]=Al(r,y);k.style.setProperty(x,O),e.appendChild(k)}}}for(;a;){var u;let f=a.nextSibling;(u=a.parentNode)===null||u===void 0||u.removeChild(a),a=f}let d=t.attrs.style&&typeof t.attrs.style==\"string\"&&/\\bwidth\\s*:/i.test(t.attrs.style);l&&!d?(n.style.width=`${s}px`,n.style.minWidth=\"\"):(n.style.width=\"\",n.style.minWidth=`${s}px`)}var v1=class{constructor(t,e,n,r={}){this.node=t,this.cellMinWidth=e,this.dom=document.createElement(\"div\"),this.dom.className=\"tableWrapper\",this.table=this.dom.appendChild(document.createElement(\"table\"));for(let[o,i]of Object.entries(r))i!=null&&(o===\"style\"?this.table.style.cssText=String(i):this.table.setAttribute(o,String(i)));t.attrs.style&&(this.table.style.cssText=t.attrs.style),this.colgroup=this.table.appendChild(document.createElement(\"colgroup\")),th(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement(\"tbody\"))}update(t){return t.sameMarkup(this.node)?(this.node=t,th(t,this.colgroup,this.table,this.cellMinWidth),!0):!1}ignoreMutation(t){let e=t.target,n=this.dom.contains(e),r=this.contentDOM.contains(e);return!!(n&&!r&&(t.type===\"attributes\"||t.type===\"childList\"||t.type===\"characterData\"))}};function E1(t,e,n,r){let o=0,i=!0,s=[],l=t.firstChild;if(!l)return{};for(let u=0,d=0;u<l.childCount;u+=1){let{colspan:f,colwidth:h}=l.child(u).attrs;for(let p=0;p<f;p+=1,d+=1){let m=n===d?r:h&&h[p];o+=m||e,m||(i=!1);let[g,y]=Al(e,m);s.push([\"col\",{style:`${g}: ${y}`}])}}let a=i?`${o}px`:\"\",c=i?\"\":`${o}px`;return{colgroup:[\"colgroup\",{},...s],tableWidth:a,tableMinWidth:c}}function nh(t,e){return e?t.createChecked(null,e):t.createAndFill()}function A1(t){if(t.cached.tableNodeTypes)return t.cached.tableNodeTypes;let e={};return Object.keys(t.nodes).forEach(n=>{let r=t.nodes[n];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),t.cached.tableNodeTypes=e,e}function T1(t,e,n,r,o){let i=A1(t),s=[],l=[];for(let c=0;c<n;c+=1){let u=nh(i.cell,o);if(u&&l.push(u),r){let d=nh(i.header_cell,o);d&&s.push(d)}}let a=[];for(let c=0;c<e;c+=1)a.push(i.row.createChecked(null,r&&c===0?s:l));return i.table.createChecked(null,a)}function ch(t){return t instanceof j}var Yo=({editor:t})=>{let{selection:e}=t.state;if(!ch(e))return!1;let n=0,r=pn(e.ranges[0].$from,o=>o.type.name===\"table\");return r?.node.descendants(o=>{if(o.type.name===\"table\")return!1;[\"tableCell\",\"tableHeader\"].includes(o.type.name)&&(n+=1)}),n!==e.ranges.length?!1:(t.commands.deleteTable(),!0)};function rh(t,e){let n=t.mapping.map(e),r=pn(t.selection.$from,s=>s.type.name===\"table\");if(r?.pos===n)return;let o=t.doc.nodeAt(n);if(!o)return;let i=n+o.nodeSize-1;t.setSelection(M.near(t.doc.resolve(i),-1))}function N1(t){let e=\"\",n=0;for(;n<t.length;){if(t[n]===\"\\\\\"&&n+1<t.length){e+=t[n]+t[n+1],n+=2;continue}if(t[n]!==\"`\"){e+=t[n++];continue}let r=0;for(;n+r<t.length&&t[n+r]===\"`\";)r+=1;let o=n+r,i=!1;for(;o<t.length;){if(t[o]!==\"`\"){o+=1;continue}let s=0;for(;o+s<t.length&&t[o+s]===\"`\";)s+=1;if(s===r){let l=t.slice(n+r,o);e+=t.slice(n,n+r)+l.replace(/\\\\\\||\\|/g,a=>a===\"|\"?\"\\\\|\":a)+t.slice(o,o+r),n=o+r,i=!0;break}o+=s}i||(e+=t.slice(n,n+r),n+=r)}return e}function O1(t){return t.split(`\n`).map(e=>!e.includes(\"|\")||!e.includes(\"`\")?e:N1(e)).join(`\n`)}function R1(t){return(t||\"\").replaceAll(\"\u001f\",\" \").replace(/\\s+/g,\" \").trim()}function oh(t,e){return e?t.split(e).join(`\n`):t}function D1(t){return t.replace(/\\\\.|\\|/g,e=>e===\"|\"?\"\\\\|\":e)}function I1(t,e,n={}){if(!t||!t.content||t.content.length===0)return\"\";let r=[];t.content.forEach(f=>{let h=[];f.content&&f.content.forEach(p=>{let m=\"\";p.content&&Array.isArray(p.content)&&p.content.length>1?m=p.content.map(k=>oh(e.renderChildren(k),n.cellLineSeparator)).join(`\n`):m=oh(p.content?e.renderChildren(p.content):\"\",n.cellLineSeparator);let g=D1(R1(m.replace(/[ \\t]*\\r?\\n[ \\t]*/g,\"<br>\"))),y=p.type===\"tableHeader\",S=x1(p.attrs);h.push({text:g,isHeader:y,align:S})}),r.push(h)});let o=r.reduce((f,h)=>Math.max(f,h.length),0);if(o===0)return\"\";let i=Array.from({length:o}).fill(0);r.forEach(f=>{for(let p=0;p<o;p+=1){var h;let m=(((h=f[p])===null||h===void 0?void 0:h.text)||\"\").length;m>i[p]&&(i[p]=m),i[p]<3&&(i[p]=3)}});let s=(f,h)=>f+\" \".repeat(Math.max(0,h-f.length)),l=r[0],a=l.some(f=>f.isHeader),c=Array.from({length:o}).fill(null);r.forEach(f=>{for(let p=0;p<o;p+=1){var h;!c[p]&&(!((h=f[p])===null||h===void 0)&&h.align)&&(c[p]=f[p].align)}});let u=`\n`,d=Array.from({length:o}).map((f,h)=>a&&l[h]&&l[h].text||\"\");return u+=`| ${d.map((f,h)=>s(f,i[h])).join(\" | \")} |\n`,u+=`| ${i.map((f,h)=>{let p=Math.max(3,f),m=c[h];return m===\"left\"?`:${\"-\".repeat(p)}`:m===\"right\"?`${\"-\".repeat(p)}:`:m===\"center\"?`:${\"-\".repeat(p)}:`:\"-\".repeat(p)}).join(\" | \")} |\n`,(a?r.slice(1):r).forEach(f=>{u+=`| ${Array.from({length:o}).fill(0).map((h,p)=>s(f[p]&&f[p].text||\"\",i[p])).join(\" | \")} |\n`}),u}var P1=new P(\"preserveCellSelectionOnContextMenu\");function L1(t,e){let n=t.posAtCoords({left:e.clientX,top:e.clientY});if(n)return n.pos;if(!(e.target instanceof Node))return null;try{return t.posAtDOM(e.target,0)}catch{return null}}function $1(t,e){let n=!1;return t.forEachCell((r,o)=>{e>=o&&e<o+r.nodeSize&&(n=!0)}),n}function z1(){return new R({key:P1,props:{handleDOMEvents:{mousedown(t,e){if(e.button!==2)return!1;let{selection:n}=t.state;if(!ch(n)||n.ranges.length<2)return!1;let r=L1(t,e);return r==null||!$1(n,r)?!1:(e.preventDefault(),!0)}}}})}var Rl=K.create({name:\"table\",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:v1,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:\"tableRow+\",tableRole:\"table\",isolating:!0,group:\"block\",parseHTML(){return[{tag:\"table\"}]},renderHTML({node:t,HTMLAttributes:e}){let{colgroup:n,tableWidth:r,tableMinWidth:o}=E1(t,this.options.cellMinWidth),i=e.style;function s(){return i||(r?`width: ${r}`:`min-width: ${o}`)}let l=[\"table\",B(this.options.HTMLAttributes,e,{style:s()}),n,[\"tbody\",0]];return this.options.renderWrapper?[\"div\",{class:\"tableWrapper\"},l]:l},parseMarkdown:(t,e)=>{let n=[],r=Array.isArray(t.align)?t.align:[];if(t.header){let o=[];t.header.forEach((i,s)=>{var l;let a=ar((l=r[s])!==null&&l!==void 0?l:i.align),c=a?{align:a}:{};o.push(e.createNode(\"tableHeader\",c,[{type:\"paragraph\",content:e.parseInline(i.tokens)}]))}),n.push(e.createNode(\"tableRow\",{},o))}return t.rows&&t.rows.forEach(o=>{let i=[];o.forEach((s,l)=>{var a;let c=ar((a=r[l])!==null&&a!==void 0?a:s.align),u=c?{align:c}:{};i.push(e.createNode(\"tableCell\",u,[{type:\"paragraph\",content:e.parseInline(s.tokens)}]))}),n.push(e.createNode(\"tableRow\",{},i))}),e.createNode(\"table\",void 0,n)},renderMarkdown:(t,e)=>I1(t,e),markdownTokenizer:{name:\"table\",level:\"block\",start:t=>{let e=t.split(`\n`);if(e.length<2)return-1;let n=e[1];return!/^[ \\t|:]*-[ \\t|:-]*$/.test(n)||!n.includes(\"|\")?-1:e[0].includes(\"|\")?0:-1},tokenize(t,e,n){let r=t.indexOf(`\n\n`),o=r>=0?t.slice(0,r):t,i=o.split(`\n`);if(i.length<2)return;let s=i[1];if(!/^[ \\t|:]*-[ \\t|:-]*$/.test(s)||!s.includes(\"|\"))return;let l=O1(o);if(l===o)return;let a=n.blockTokens(l)[0];if(a?.type!==\"table\"||!a.raw)return;let c=a.raw.split(`\n`).length,u=t.split(`\n`).slice(0,c).join(`\n`);return{...a,raw:u}}},addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:o,editor:i})=>{let s=T1(i.schema,t,e,n);if(o){let l=r.selection.from+1;r.replaceSelectionWith(s).scrollIntoView().setSelection(M.near(r.doc.resolve(l)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>jf(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>Wf(t,e),deleteColumn:()=>({state:t,dispatch:e})=>{let n=pn(t.selection.$from,r=>r.type.name===\"table\");return Vf(t,e&&(r=>{n&&rh(r,n.pos),e(r)}))},addRowBefore:()=>({state:t,dispatch:e})=>Kf(t,e),addRowAfter:()=>({state:t,dispatch:e})=>Uf(t,e),deleteRow:()=>({state:t,dispatch:e})=>{let n=pn(t.selection.$from,r=>r.type.name===\"table\");return Jf(t,e&&(r=>{n&&rh(r,n.pos),e(r)}))},deleteTable:()=>({state:t,dispatch:e})=>Xf(t,e),mergeCells:()=>({state:t,dispatch:e})=>Ml(t,e),splitCell:()=>({state:t,dispatch:e})=>vl(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>Cn(\"column\")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>Cn(\"row\")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>Gf(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>Ml(t,e)?!0:vl(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>qf(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>El(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>El(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&Cl(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){let r=j.create(e.doc,t.anchorCell,t.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,\"Shift-Tab\":()=>this.editor.commands.goToPreviousCell(),Backspace:Yo,\"Mod-Backspace\":Yo,Delete:Yo,\"Mod-Delete\":Yo}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[Qf({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:null,lastColumnResizable:this.options.lastColumnResizable})]:[],eh({allowTableNodeSelection:this.options.allowTableNodeSelection}),z1()]},addNodeView(){let t=this.options.View;return t?({node:e,view:n,HTMLAttributes:r})=>{let o=B(this.options.HTMLAttributes,r);return new t(e,this.options.cellMinWidth,n,o)}:null},extendNodeSchema(t){let e={name:t.name,options:t.options,storage:t.storage};return{tableRole:L(v(t,\"tableRole\",e))}}}),eC=V.create({name:\"tableKit\",addExtensions(){let t=[];return this.options.table!==!1&&t.push(Rl.configure(this.options.table)),this.options.tableCell!==!1&&t.push(Tl.configure(this.options.tableCell)),this.options.tableHeader!==!1&&t.push(Nl.configure(this.options.tableHeader)),this.options.tableRow!==!1&&t.push(Ol.configure(this.options.tableRow)),t}});function uh(t={}){return new R({view(e){return new Dl(e,t)}})}var Dl=class{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||\"black\",this.class=n.class,this.handlers=[\"dragover\",\"dragend\",\"drop\",\"dragleave\"].map(o=>{let i=s=>{this[o](s)};return e.dom.addEventListener(o,i),{name:o,handler:i}})}destroy(){this.setCursor(null),this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){if(this.cursorPos!=null&&n.doc!=e.state.doc)if(this.lastDragEvent){let r=this.computeTarget(this.lastDragEvent);r==this.cursorPos?this.updateOverlay():this.setCursor(r)}else this.updateOverlay()}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,o=this.editorView.dom,i=o.getBoundingClientRect(),s=i.width/o.offsetWidth,l=i.height/o.offsetHeight;if(n){let d=e.nodeBefore,f=e.nodeAfter;if(d||f){let h=this.editorView.nodeDOM(this.cursorPos-(d?d.nodeSize:0));if(h){let p=h.getBoundingClientRect(),m=d?p.bottom:p.top;d&&f&&(m=(m+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let g=this.width/2*l;r={left:p.left,right:p.right,top:m-g,bottom:m+g}}}}if(!r){let d=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*s;r={left:d.left-f,right:d.left+f,top:d.top,bottom:d.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.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);let c,u;if(!a||a==document.body&&getComputedStyle(a).position==\"static\")c=-pageXOffset,u=-pageYOffset;else{let d=a.getBoundingClientRect(),f=d.width/a.offsetWidth,h=d.height/a.offsetHeight;c=d.left-a.scrollLeft*f,u=d.top-a.scrollTop*h}this.element.style.left=(r.left-c)/s+\"px\",this.element.style.top=(r.top-u)/l+\"px\",this.element.style.width=(r.right-r.left)/s+\"px\",this.element.style.height=(r.bottom-r.top)/l+\"px\"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}computeTarget(e){let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),o=r&&r.type.spec.disableDropCursor,i=typeof o==\"function\"?o(this.editorView,n,e):o;if(!n||i)return null;let s=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=Mr(this.editorView.state.doc,s,this.editorView.dragging.slice);l!=null&&(s=l)}return s}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let n=this.computeTarget(e);n!=null&&(this.setCursor(n),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}};var de=class t extends E{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return t.valid(r)?new t(r):E.near(r)}content(){return C.empty}eq(e){return e instanceof t&&e.head==this.head}toJSON(){return{type:\"gapcursor\",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!=\"number\")throw new RangeError(\"Invalid input for GapCursor.fromJSON\");return new t(e.resolve(n.pos))}getBookmark(){return new Il(this.anchor)}static valid(e){let n=e.parent;if(n.inlineContent||!B1(e)||!F1(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let o=n.contentMatchAt(e.index()).defaultType;return o&&o.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&t.valid(e))return e;let o=e.pos,i=null;for(let s=e.depth;;s--){let l=e.node(s);if(n>0?e.indexAfter(s)<l.childCount:e.index(s)>0){i=l.child(n>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;o+=n;let a=e.doc.resolve(o);if(t.valid(a))return a}for(;;){let s=n>0?i.firstChild:i.lastChild;if(!s){if(i.isAtom&&!i.isText&&!A.isSelectable(i)){e=e.doc.resolve(o+i.nodeSize*n),r=!1;continue e}break}i=s,o+=n;let l=e.doc.resolve(o);if(t.valid(l))return l}return null}}};de.prototype.visible=!1;de.findFrom=de.findGapCursorFrom;E.jsonID(\"gapcursor\",de);var Il=class t{constructor(e){this.pos=e}map(e){return new t(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return de.valid(n)?new de(n):E.near(n)}};function dh(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function B1(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(n-1);;o=o.lastChild){if(o.childCount==0&&!o.inlineContent||dh(o.type))return!0;if(o.inlineContent)return!1}}return!0}function F1(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(n);;o=o.firstChild){if(o.childCount==0&&!o.inlineContent||dh(o.type))return!0;if(o.inlineContent)return!1}}return!0}function fh(){return new R({props:{decorations:V1,createSelectionBetween(t,e,n){return e.pos==n.pos&&de.valid(n)?new de(n):null},handleClick:j1,handleKeyDown:H1,handleDOMEvents:{beforeinput:W1}}})}var H1=qn({ArrowLeft:Zo(\"horiz\",-1),ArrowRight:Zo(\"horiz\",1),ArrowUp:Zo(\"vert\",-1),ArrowDown:Zo(\"vert\",1)});function Zo(t,e){let n=t==\"vert\"?e>0?\"down\":\"up\":e>0?\"right\":\"left\";return function(r,o,i){let s=r.selection,l=e>0?s.$to:s.$from,a=s.empty;if(s instanceof M){if(!i.endOfTextblock(n)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=de.findGapCursorFrom(l,e,a);return c?(o&&o(r.tr.setSelection(new de(c))),!0):!1}}function j1(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!de.valid(r))return!1;let o=t.posAtCoords({left:n.clientX,top:n.clientY});return o&&o.inside>-1&&A.isSelectable(t.state.doc.nodeAt(o.inside))?!1:(t.dispatch(t.state.tr.setSelection(new de(r))),!0)}function W1(t,e){if(e.inputType!=\"insertCompositionText\"||!(t.state.selection instanceof de))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let o=b.empty;for(let s=r.length-1;s>=0;s--)o=b.from(r[s].createAndFill(null,o));let i=t.state.tr.replace(n.pos,n.pos,new C(o,0,0));return i.setSelection(M.near(i.doc.resolve(n.pos+1))),t.dispatch(i),!1}function V1(t){if(!(t.selection instanceof de))return null;let e=document.createElement(\"div\");return e.className=\"ProseMirror-gapcursor\",z.create(t.doc,[ee.widget(t.selection.head,e,{key:\"gapcursor\"})])}var SC=V.create({name:\"characterCount\",addOptions(){return{limit:null,autoTrim:!0,mode:\"textSize\",textCounter:t=>t.length,wordCounter:t=>t.split(\" \").filter(e=>e!==\"\").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{let e=t?.node||this.editor.state.doc;if((t?.mode||this.options.mode)===\"textSize\"){let n=e.textBetween(0,e.content.size,void 0,\" \");return this.options.textCounter(n)}return e.nodeSize},this.storage.words=t=>{let e=t?.node||this.editor.state.doc,n=e.textBetween(0,e.content.size,\" \",\" \");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new R({key:new P(\"characterCount\"),appendTransaction:(e,n,r)=>{if(t)return;let o=this.options.limit,i=this.options.autoTrim;if(o==null||o===0||i===!1){t=!0;return}let s=this.storage.characters({node:r.doc});if(s>o){let l=s-o,a=0,c=l;console.warn(`[CharacterCount] Initial content exceeded limit of ${o} characters. Content was automatically trimmed.`);let u=r.tr.deleteRange(a,c);return t=!0,u}t=!0},filterTransaction:(e,n)=>{let r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;let o=this.storage.characters({node:n.doc}),i=this.storage.characters({node:e.doc});if(i<=r||o>r&&i>r&&i<=o)return!0;if(o>r&&i>r&&i>o||!e.getMeta(\"paste\"))return!1;let s=e.selection.$head.pos,l=s-(i-r),a=s;return e.deleteRange(l,a),!(this.storage.characters({node:e.doc})>r)}})]}}),xC=V.create({name:\"dropCursor\",addOptions(){return{color:\"currentColor\",width:1,class:void 0}},addProseMirrorPlugins(){return[uh(this.options)]}}),CC=V.create({name:\"focus\",addOptions(){return{className:\"has-focus\",mode:\"all\"}},addProseMirrorPlugins(){return[new R({key:new P(\"focus\"),props:{decorations:({doc:t,selection:e})=>{let{isEditable:n,isFocused:r}=this.editor,{anchor:o}=e,i=[];if(!n||!r)return z.create(t,[]);let s=0;this.options.mode===\"deepest\"&&t.descendants((a,c)=>{if(!a.isText){if(!(o>=c&&o<=c+a.nodeSize-1))return!1;s+=1}});let l=0;return t.descendants((a,c)=>{if(a.isText||!(o>=c&&o<=c+a.nodeSize-1))return!1;if(l+=1,this.options.mode===\"deepest\"&&s-l>0||this.options.mode===\"shallowest\"&&l>1)return this.options.mode===\"deepest\";i.push(ee.node(c,c+a.nodeSize,{class:this.options.className}))}),z.create(t,i)}}})]}}),mh=V.create({name:\"gapCursor\",addProseMirrorPlugins(){return[fh()]},extendNodeSchema(t){var e;let n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=L(v(t,\"allowGapCursor\",n)))!==null&&e!==void 0?e:null}}}),gh=\"placeholder\",hh=new P(\"tiptap__placeholder\");function yh(t){let{editor:e,placeholder:n,dataAttribute:r,pos:o,node:i,isEmptyDoc:s,hasAnchor:l,classes:{emptyNode:a,emptyEditor:c}}=t,u=[a];return s&&u.push(c),ee.node(o,o+i.nodeSize,{class:u.join(\" \"),[r]:typeof n==\"function\"?n({editor:e,node:i,pos:o,hasAnchor:l}):n})}function bh(t,e){return typeof t==\"function\"?t(e):t}function kh({editor:t,options:e,dataAttribute:n,doc:r,selection:o,from:i,to:s}){let{anchor:l}=o,a=[],c=t.isEmpty;return r.nodesBetween(i,s,(u,d)=>{let f=l>=d&&l<=d+u.nodeSize,h=!u.isLeaf&&gn(u);return u.type.isTextblock&&(f||!e.showOnlyCurrent)&&h&&a.push(yh({editor:t,isEmptyDoc:c,dataAttribute:n,hasAnchor:f,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:bh(e.emptyNodeClass,{editor:t,node:u,pos:d,hasAnchor:f})},node:u,pos:d})),e.includeChildren}),a}function wh({editor:t,options:e,dataAttribute:n,doc:r,selection:o}){if(!(t.isEditable||!e.showOnlyWhenEditable))return null;let{anchor:i}=o,s=[],l=t.isEmpty;if(e.showOnlyCurrent&&!e.includeChildren){let a=r.resolve(i),c=a.depth>0?a.node(1):a.nodeAfter,u=a.depth>0?a.before(1):i;if(c&&c.type.isTextblock&&gn(c)){let d=i>=u&&i<=u+c.nodeSize;s.push(yh({editor:t,isEmptyDoc:l,dataAttribute:n,hasAnchor:d,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:bh(e.emptyNodeClass,{editor:t,node:c,pos:u,hasAnchor:d})},node:c,pos:u}))}}else s.push(...kh({editor:t,options:e,dataAttribute:n,doc:r,selection:o,from:0,to:r.content.size}));return z.create(r,s)}function cr(t,e){let n=t.resolve(e);if(n.depth===0){var r;let i=(r=n.nodeAfter)!==null&&r!==void 0?r:n.nodeBefore;if(!i)return{from:e,to:e};let s=n.nodeAfter?e:e-i.nodeSize;return{from:s,to:s+i.nodeSize}}let o=n.before(1);return{from:o,to:o+n.node(1).nodeSize}}function ur(t,e){return{from:Math.max(0,e.from-1),to:Math.min(t.content.size,e.to-1)}}function _1(t,e,n){let r=[];return t.forEach((o,i)=>{let s=i,l=s+o.nodeSize,a=s+1,c=l+1;a<n&&c>e&&r.push({from:s,to:l})}),r}function K1(t){if(t.length===0)return[];let e=[...t].sort((r,o)=>r.from-o.from),n=[{...e[0]}];for(let r=1;r<e.length;r+=1){let o=n[n.length-1],i=e[r];i.from<=o.to?o.to=Math.max(o.to,i.to):n.push({...i})}return n}function U1(t,e){let n=_1(t,e.from,e.to);return n.push(ur(t,cr(t,e.from))),e.to>e.from?n.push(ur(t,cr(t,Math.min(e.to,t.content.size+1)-1))):e.from<t.content.size+1&&n.push(ur(t,cr(t,Math.min(e.from+1,t.content.size)))),n}function J1(t,e,n){let r=[];if(t.docChanged){let o=mn(t);for(let i of o)r.push(...U1(n.doc,i.newRange))}return t.selectionSet&&(r.push(ur(n.doc,cr(n.doc,t.mapping.map(e.selection.anchor)))),r.push(ur(n.doc,cr(n.doc,n.selection.anchor)))),K1(r)}function q1(t,e,n){let r=Math.max(0,Math.min(t,n.content.size));return{from:r,to:Math.max(r,Math.min(e,n.content.size))}}function G1({decorations:t,ranges:e,editor:n,options:r,dataAttribute:o,doc:i,selection:s}){let l=t;for(let a of e){let{from:c,to:u}=q1(a.from,a.to,i),d=l.find(c,u).filter(h=>h.from>=c&&h.to<=u);d.length&&(l=l.remove(d));let f=kh({editor:n,options:r,dataAttribute:o,doc:i,selection:s,from:c,to:u});f.length&&(l=l.add(i,f))}return l}function X1({editor:t,options:e,dataAttribute:n}){return{init(r,o){let i=wh({editor:t,options:e,dataAttribute:n,doc:o.doc,selection:o.selection});return i??z.empty},apply(r,o,i,s){return!r.docChanged&&!r.selectionSet?o:G1({decorations:o.map(r.mapping,r.doc),ranges:J1(r,i,s),editor:t,options:e,dataAttribute:n,doc:s.doc,selection:s.selection})}}}function Y1(t){return t.replace(/\\s+/g,\"-\").replace(/[^a-zA-Z0-9-]/g,\"\").replace(/^[0-9-]+/,\"\").replace(/^-+/,\"\").toLowerCase()}function Q1({editor:t,options:e}){let n=e.dataAttribute?`data-${Y1(e.dataAttribute)}`:`data-${gh}`,r=e.showOnlyCurrent&&!e.includeChildren;return new R({key:hh,...r?{}:{state:X1({editor:t,options:e,dataAttribute:n})},props:{decorations:r?({doc:o,selection:i})=>wh({editor:t,options:e,dataAttribute:n,doc:o,selection:i}):o=>{var i;return e.showOnlyWhenEditable&&!t.isEditable?z.empty:(i=hh.getState(o))!==null&&i!==void 0?i:z.empty}}})}var Sh=V.create({name:\"placeholder\",addOptions(){return{emptyEditorClass:\"is-editor-empty\",emptyNodeClass:\"is-empty\",dataAttribute:gh,placeholder:\"Write something \\u2026\",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[Q1({editor:this.editor,options:this.options})]}});function Pl(t,e){return!t.selection.empty&&!hd(t.selection)&&e.isEditable}function Z1(t,e){return Pl(t,e)&&!e.isFocused&&!e.view.dragging}function ew(){var t;(t=window.getSelection())===null||t===void 0||t.removeAllRanges()}function tw(t){t.focus()}var MC=V.create({name:\"selection\",addOptions(){return{className:\"selection\"}},addProseMirrorPlugins(){let{editor:t,options:e}=this;return[new R({key:new P(\"selection\"),props:{decorations(n){return Z1(n,t)?z.create(n.doc,[ee.inline(n.selection.from,n.selection.to,{class:e.className})]):null},handleDOMEvents:{blur(n){return Pl(n.state,t)&&ew(),!1},focus(n){return Pl(n.state,t)&&requestAnimationFrame(()=>{!t.isDestroyed&&n.hasFocus()&&tw(n)}),!1}}}})]}});function ph({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var xh=V.create({name:\"trailingNode\",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;let e=new P(this.name),n=this.options.node||((t=this.editor.schema.topNodeType.contentMatch.defaultType)===null||t===void 0?void 0:t.name)||\"paragraph\",r=Object.entries(this.editor.schema.nodes).map(([,o])=>o).filter(o=>(this.options.notAfter||[]).concat(n).includes(o.name));return[new R({key:e,appendTransaction:(o,i,s)=>{let{doc:l,tr:a,schema:c}=s,u=e.getState(s),d=l.content.size,f=c.nodes[n];if(!o.some(h=>h.getMeta(\"skipTrailingNode\"))&&u)return a.insert(d,f.create())},state:{init:(o,i)=>{let s=i.tr.doc.lastChild;return!ph({node:s,types:r})},apply:(o,i)=>{if(!o.docChanged||o.getMeta(\"__uniqueIDTransaction\"))return i;let s=o.doc.lastChild;return!ph({node:s,types:r})}}})]}}),Ch=V.create({name:\"undoRedo\",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>ks(t,e),redo:()=>({state:t,dispatch:e})=>ws(t,e)}},addProseMirrorPlugins(){return[Mu(this.options)]},addKeyboardShortcuts(){return{\"Mod-z\":()=>this.editor.commands.undo(),\"Shift-Mod-z\":()=>this.editor.commands.redo(),\"Mod-y\":()=>this.editor.commands.redo(),\"Mod-\\u044F\":()=>this.editor.commands.undo(),\"Shift-Mod-\\u044F\":()=>this.editor.commands.redo()}}});var nw=/^(#{1,3})\\s+(.*)$/,rw=/^\\s*[-*]\\s+(.*)$/,ow=/^\\s*(\\d+)[.)]\\s+(.*)$/,Ll=/^\\s*\\|(.*)\\|\\s*$/,iw=/^\\s*\\|(?:\\s*:?-+:?\\s*\\|)+\\s*$/,sw=/^\\s*```+\\s*([^`]*)$/,lw=/^\\s*```+\\s*$/,aw=/^!\\[((?:[^\\]\\\\]|\\\\.)*)\\]\\(\\s*(\\S+?)(?:\\s+\"([^\"]*)\")?\\s*\\)$/,cw=Object.freeze([\"small\",\"medium\",\"large\",\"full\"]),uw=\"full\",dw=/^https?:\\/\\//i,fw=/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;function zl(t){return typeof t==\"string\"&&dw.test(t)}function hw(t){return typeof t!=\"string\"?!1:zl(t)||fw.test(t)}function vh(t){return cw.indexOf(t)===-1?uw:t}function Bl(t){return String(t||\"\").replace(/[\\r\\n]+/g,\" \").replace(/([\\\\\\]])/g,\"\\\\$1\").trim()}var pw=Bl;function Eh(t){return String(t||\"\").replace(/\\\\(.)/g,\"$1\")}var mw=Eh;function gw(t){let e=aw.exec(String(t??\"\").trim());return e?{src:hw(e[2])?e[2]:\"\",alt:mw(e[1]),size:vh(e[3])}:null}function Ah({src:t,alt:e,size:n}={}){let r=vh(n);return`![${pw(e)}](${String(t||\"\")} \"${r}\")`}var yw=/<[^>]*>/g,bw=/<\\/(?:p|div|h[1-6]|li|ul|ol|br)\\s*>|<br\\s*\\/?>/gi,kw={\"&amp;\":\"&\",\"&lt;\":\"<\",\"&gt;\":\">\",\"&quot;\":'\"',\"&#39;\":\"'\",\"&nbsp;\":\" \"};function ww(t){return typeof t==\"string\"&&/<[a-z!/][^>]*>/i.test(t)}function Sw(t){return typeof t!=\"string\"?\"\":ww(t)?t.replace(bw,`\n`).replace(yw,\"\").replace(/&[a-z#0-9]+;/gi,e=>kw[e.toLowerCase()]??e).replace(/\\n{3,}/g,`\n\n`).trim():t}function xw(t,e){let n=Ut(t).map(r=>({...r,text:Eh(r.text),href:e}));return n.some(r=>r.text)?n:[{text:e,href:e}]}var Cw=/[!-/:-@[-`{-~]/;function Mh(t){return t!==\"\"&&!/\\s/.test(t)&&!Cw.test(t)}function Mw(t,e,n,r,o){if(e===\"\"||/\\s/.test(e.charAt(0))||/\\s/.test(e.charAt(e.length-1)))return!1;if(t!==\"_\")return!0;let i=r>0?n.charAt(r-1):\"\",s=n.charAt(o);return!Mh(i)&&!Mh(s)}var vw=/(!?)\\[((?:[^\\]\\\\]|\\\\.)*)\\]\\(\\s*(\\S+?)\\s*\\)|(\\*\\*)(.+?)\\4|(`)([^`]+?)\\6|([*_])(.+?)\\8/g,Ew=/(!?)([^\\s\\S])([^\\s\\S])|(\\*\\*)(.+?)\\4|(`)([^`]+?)\\6|([*_])(.+?)\\8/g;function Aw(t){let e=[],n=(l,a)=>{a>l&&e.push({type:\"text\",start:l,end:a})},o=t.includes(\"](\")&&t.includes(\")\")?vw:Ew;o.lastIndex=0;let i=0,s=o.exec(t);for(;s;){n(i,s.index);let l=s.index+s[0].length;if(s[3]!==void 0)if(s[1])n(s.index,l);else{let a=s.index+1;e.push({type:\"link\",start:s.index,end:l,contentStart:a,contentEnd:a+s[2].length,href:s[3]})}else if(s[4]||s[8]){let a=s[4]||s[8],c=s[4]?s[5]:s[9];if(!Mw(a,c,t,s.index,l)){n(s.index,s.index+a.length),i=s.index+a.length,o.lastIndex=i,s=o.exec(t);continue}e.push({type:s[4]?\"bold\":\"italic\",start:s.index,end:l,contentStart:s.index+a.length,contentEnd:l-a.length})}else s[6]&&e.push({type:\"code\",start:s.index,end:l,contentStart:s.index+1,contentEnd:l-1});i=l,s=o.exec(t)}return n(i,t.length),e}function Ut(t){let e=typeof t==\"string\"?t:\"\",n=[];for(let o of Aw(e)){let i=e.slice(o.contentStart,o.contentEnd);o.type===\"text\"?n.push({text:e.slice(o.start,o.end)}):o.type===\"link\"?n.push(...xw(i,o.href)):n.push({text:i,[o.type]:!0})}if(n.length===0)return[{text:e}];let r=[];for(let o of n){let i=r[r.length-1],s=l=>!l.bold&&!l.italic&&!l.code&&!l.href;i&&s(i)&&s(o)?i.text+=o.text:r.push({...o})}return r}function $l(t){let e=[],n=\"\";for(let r=0;r<t.length;r+=1){let o=t.charAt(r);o===\"\\\\\"&&t.charAt(r+1)===\"|\"?(n+=\"|\",r+=1):o===\"|\"?(e.push(n),n=\"\"):n+=o}return e.push(n),e.map(r=>r.trim())}function Tw(t){let e=t.trim(),n=e.charAt(0)===\":\",r=e.length>1&&e.charAt(e.length-1)===\":\";return n&&r?\"center\":r?\"right\":n?\"left\":null}function Nw(t,e){let n=Ll.exec(t[e]);if(!n||!iw.test(t[e+1]||\"\"))return null;let r=Ll.exec(t[e+1]),o=$l(r[1]).map(Tw),i=[{header:!0,cells:$l(n[1]).map(l=>Ut(l))}],s=e+2;for(;s<t.length;){let l=Ll.exec(t[s]);if(!l)break;i.push({header:!1,cells:$l(l[1]).map(a=>Ut(a))}),s+=1}return{block:{type:\"table\",rows:i,align:o},next:s}}function Th(t,e){let r=e?.stripLegacyHtml!==!1?Sw(t):typeof t==\"string\"?t:\"\";if(!r.trim())return[];let o=[],i=[],s=()=>{i.length!==0&&(o.push({type:\"paragraph\",spans:Ut(i.join(\" \"))}),i=[])},l=r.split(/\\r?\\n/);for(let a=0;a<l.length;a+=1){let c=l[a].trimEnd(),u=sw.exec(c);if(u){s();let g=[],y=a+1;for(;y<l.length&&!lw.test(l[y]);)g.push(l[y]),y+=1;o.push({type:\"code\",text:g.join(`\n`),lang:u[1].trim()}),a=y;continue}if(!c.trim()){s();continue}let d=Nw(l,a);if(d){s(),o.push(d.block),a=d.next-1;continue}let f=gw(c);if(f){s(),o.push({type:\"image\",...f});continue}let h=nw.exec(c);if(h){s(),o.push({type:\"heading\",level:h[1].length,spans:Ut(h[2])});continue}let p=rw.exec(c);if(p){s(),o.push({type:\"bullet\",marker:\"\\u2022\",spans:Ut(p[1])});continue}let m=ow.exec(c);if(m){s(),o.push({type:\"ordered\",marker:`${m[1]}.`,spans:Ut(m[2])});continue}i.push(c.trim())}return s(),o}var Ow=(t,e)=>e.length>0?{type:\"text\",text:t,marks:e}:{type:\"text\",text:t};function Rh(t){let e=[];for(let n of t||[]){if(!n.text)continue;let r=[];n.bold&&r.push({type:\"bold\"}),n.italic&&r.push({type:\"italic\"}),n.code&&r.push({type:\"code\"}),n.href&&r.push({type:\"link\",attrs:{href:n.href}}),e.push(Ow(n.text,r))}return e}var Hl=t=>{let e=Rh(t);return e.length>0?{type:\"paragraph\",content:e}:{type:\"paragraph\"}};function Rw(t){let e=Math.max(1,...t.rows.map(o=>o.cells.length)),n=t.rows.map(o=>{let i=[];for(let s=0;s<e;s+=1)i.push({type:o.header?\"tableHeader\":\"tableCell\",content:[Hl(o.cells[s])]});return{type:\"tableRow\",content:i}}),r=[];for(let o=0;o<e;o+=1)r.push(t.align[o]||null);return{type:\"table\",attrs:{align:r},content:n}}var Dw=t=>Number.parseInt(t,10)||1;function jl(t,e){let n=[],r=null;for(let o of Th(t,e)){let i=o.type===\"bullet\"?\"bulletList\":o.type===\"ordered\"?\"orderedList\":null;if(i){(!r||r.type!==i)&&(r={type:i,content:[]},i===\"orderedList\"&&(r.attrs={start:Dw(o.marker)}),n.push(r)),r.content.push({type:\"listItem\",content:[Hl(o.spans)]});continue}r=null,o.type===\"heading\"?n.push({type:\"heading\",attrs:{level:o.level},content:Rh(o.spans)}):o.type===\"paragraph\"?n.push(Hl(o.spans)):o.type===\"table\"?n.push(Rw(o)):o.type===\"image\"?n.push({type:\"image\",attrs:{src:o.src,alt:o.alt,title:o.size}}):o.type===\"code\"&&n.push({type:\"codeBlock\",attrs:{language:o.lang||null},...o.text?{content:[{type:\"text\",text:o.text}]}:null})}return{type:\"doc\",content:n.length>0?n:[{type:\"paragraph\"}]}}var ei=(t,e)=>(t.marks||[]).find(n=>n.type===e);function Fl(t,e){let n=/^\\s*/.exec(t)[0],r=/\\s*$/.exec(t.slice(n.length))[0],o=t.slice(n.length,t.length-r.length);return o?`${n}${e}${o}${e}${r}`:t}function Nh(t,e){let n=t.text||\"\";return e&&(n=n.replace(/\\|/g,\"\\\\|\")),ei(t,\"code\")?Fl(n.replace(/`/g,\"'\"),\"`\"):ei(t,\"bold\")?Fl(n,\"**\"):ei(t,\"italic\")?Fl(n,\"*\"):n}var Iw=t=>String(t||\"\").replace(/[\\s|()<>]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase().padStart(2,\"0\")}`);function ti(t,e){let n=\"\",r=null,o=\"\",i=()=>{r&&(n+=`[${Bl(o)}](${Iw(r)})`),r=null,o=\"\"};for(let s of t||[]){if(s.type!==\"text\")continue;let l=ei(s,\"link\")?.attrs?.href||null;l!==r&&i(),l?(r=l,o+=Nh(s,e)):n+=Nh(s,e)}return i(),n.replace(/\\n/g,\" \")}var Pw=t=>(t.content||[]).map(e=>ti(e.content,!0)).join(\" \").trim();function Lw(t){return t===\"center\"?\":---:\":t===\"right\"?\"---:\":t===\"left\"?\":---\":\"---\"}function $w(t){let e=(t.content||[]).map(s=>(s.content||[]).map(Pw));if(e.length===0)return\"\";let n=e[0].length,r=t.attrs?.align||[],o=s=>`| ${s.join(\" | \")} |`,i=[];for(let s=0;s<n;s+=1)i.push(Lw(r[s]));return[o(e[0]),o(i),...e.slice(1).map(o)].join(`\n`)}var zw=t=>(t.content||[]).map(e=>ti(e.content,!1)).join(\" \").trim(),Oh=t=>(t.content||[]).map(zw).filter(e=>e!==\"\");function Bw(t){switch(t.type){case\"heading\":{let e=ti(t.content,!1).trim();return e?`${\"#\".repeat(t.attrs?.level||1)} ${e}`:\"\"}case\"paragraph\":return ti(t.content,!1);case\"bulletList\":return Oh(t).map(e=>`- ${e}`).join(`\n`);case\"orderedList\":{let e=t.attrs?.start||1;return Oh(t).map((n,r)=>`${e+r}. ${n}`).join(`\n`)}case\"table\":return $w(t);case\"image\":return t.attrs?.src?Ah({src:t.attrs.src,alt:t.attrs.alt,size:t.attrs.title}):\"\";case\"codeBlock\":{let e=(t.content||[]).map(n=>n.text||\"\").join(\"\");return`\\`\\`\\`${t.attrs?.language||\"\"}\n${e}\n\\`\\`\\``}default:return\"\"}}function Dh(t){return(t?.content||[]).map(Bw).filter(e=>e.trim()!==\"\").join(`\n\n`)}var Ih=/^\\s*(javascript|data|vbscript):/i,Fw=Ef.extend({renderHTML({node:t,HTMLAttributes:e}){return zl(t.attrs.src)?[\"img\",e]:[\"div\",{class:\"md-image-placeholder\"},t.attrs.alt||\"Image\"]}}),Hw=Rl.extend({addAttributes(){return{...this.parent?.(),align:{default:[],rendered:!1}}}}),Wl={content:\"paragraph\"};function jw(t){return[Id,Pd,Ld,Fd.extend({excludes:\"italic code\"}),Hd.extend({excludes:\"bold code\"}),jd,Wd.configure({levels:[1,2,3]}),Hs,Us,Vs.extend(Wl),Ks,Mf.configure({openOnClick:!1,autolink:!1,isAllowedUri:e=>!Ih.test(String(e)),HTMLAttributes:{target:null,rel:\"noopener noreferrer nofollow\"}}),vf,Fw.configure({inline:!1,allowBase64:!1}),Hw.configure({resizable:!1}),Ol,Nl.extend(Wl),Tl.extend(Wl),mh,xh,Ch,Sh.configure({placeholder:t||\"\"})]}var Ph={bold:t=>t.toggleBold(),italic:t=>t.toggleItalic(),code:t=>t.toggleCode(),heading2:t=>t.toggleHeading({level:2}),heading3:t=>t.toggleHeading({level:3}),bullet:t=>t.toggleBulletList(),ordered:t=>t.toggleOrderedList(),table:t=>t.insertTable({rows:3,cols:3,withHeaderRow:!0}),addRow:t=>t.addRowAfter(),addColumn:t=>t.addColumnAfter(),removeRow:t=>t.deleteRow(),removeColumn:t=>t.deleteColumn(),removeTable:t=>t.deleteTable(),undo:t=>t.undo(),redo:t=>t.redo(),link:(t,{label:e,target:n}={},r)=>{let o=String(n||\"\").trim();if(!o||Ih.test(o))return t;let i=String(e||\"\").trim(),{from:s,to:l,empty:a}=r.state.selection;return!a&&(!i||i===r.state.doc.textBetween(s,l,\" \").trim())?t.setLink({href:o}):t.insertContent({type:\"text\",text:i||o,marks:[{type:\"link\",attrs:{href:o}}]})}},KC=Object.freeze(Object.keys(Ph));function Lh({element:t,markdown:e,placeholder:n,label:r,onChange:o,onFocusChange:i,onState:s}){let l=typeof e==\"string\"?e:\"\",a=new Nd({element:t,extensions:jw(n),content:jl(l,{stripLegacyHtml:!1}),editorProps:{attributes:{role:\"textbox\",\"aria-multiline\":\"true\",...r?{\"aria-label\":r}:null}}});if(a.on(\"update\",({transaction:c})=>{if(!c.docChanged)return;let u=Dh(a.getJSON());u!==l&&(l=u,typeof o==\"function\"&&o(l))}),typeof s==\"function\"){let c=!1;a.on(\"transaction\",()=>{let u=a.isActive(\"table\");u!==c&&s({inTable:c=u})})}return typeof i==\"function\"&&(a.on(\"focus\",()=>i(!0)),a.on(\"blur\",()=>i(!1))),{setMarkdown(c){let u=typeof c==\"string\"?c:\"\";u!==l&&(l=u,a.commands.setContent(jl(u,{stripLegacyHtml:!1}),{emitUpdate:!1}))},command(c,u){let d=Ph[c];return d?d(a.chain().focus(),u,a).run():!1},selectedText(){let{from:c,to:u}=a.state.selection;return a.state.doc.textBetween(c,u,\" \")},focus(){a.commands.focus()},destroy(){a.destroy()},editor:a}}var Vl=t=>String(t??\"\").replace(/[{}<>;\\\\]/g,\"\"),q=t=>typeof t==\"number\"?`${t}px`:Vl(t),$h=t=>Vl(t)||\"system-ui, sans-serif\";function zh(t,e,{fontSize:n,minHeight:r,framed:o=!1}={}){let i=Object.fromEntries(Object.entries(t).map(([c,u])=>[c,typeof u==\"string\"?Vl(u):u])),s=n||i.bodySize,l=e;return`${o?`${l}{border:1px solid ${i.border};border-radius:${q(i.radius)};background-color:${i.surface}}\n${l}:focus-within{border-color:${i.accent}}\n`:\"\"}\n${l} .ProseMirror{outline:none;min-height:${q(r||0)};padding:${q(i.padding)};box-sizing:border-box;font-family:${$h(i.bodyFont)};font-size:${q(s)};line-height:${q(Math.round(s*1.6))};color:${i.color};white-space:pre-wrap;overflow-wrap:anywhere}\n${l} .ProseMirror>*:first-child{margin-top:0}\n${l} .ProseMirror>*:last-child{margin-bottom:0}\n${l} .ProseMirror p{margin:0 0 ${q(i.blockGap)}}\n${l} .ProseMirror h1,${l} .ProseMirror h2,${l} .ProseMirror h3{font-family:${$h(i.headingFont)};font-weight:700;margin:0 0 ${q(i.blockGap)}}\n${l} .ProseMirror h1{font-size:${q(i.headingSizes[1])};line-height:1.3}\n${l} .ProseMirror h2{font-size:${q(i.headingSizes[2])};line-height:1.3}\n${l} .ProseMirror h3{font-size:${q(i.headingSizes[3])};line-height:1.3}\n${l} .ProseMirror ul,${l} .ProseMirror ol{margin:0 0 ${q(i.blockGap)};padding-left:1.4em}\n${l} .ProseMirror ul{list-style-type:disc}\n${l} .ProseMirror ol{list-style-type:decimal}\n${l} .ProseMirror li p{margin:0}\n${l} .ProseMirror code{font-family:ui-monospace,Menlo,monospace;font-size:${q(i.codeSize)};color:${i.mutedColor}}\n${l} .ProseMirror pre{margin:0 0 ${q(i.blockGap)};padding:${q(i.blockGap)};border:1px solid ${i.border};border-radius:${q(i.radius)};white-space:pre-wrap}\n${l} .ProseMirror a{color:${i.accent};text-decoration:underline}\n${l} .ProseMirror table{border-collapse:collapse;width:100%;margin:0 0 ${q(i.blockGap)};table-layout:fixed}\n${l} .ProseMirror th,${l} .ProseMirror td{border:1px solid ${i.border};padding:4px 8px;vertical-align:top;text-align:left}\n${l} .ProseMirror th{font-weight:700}\n${l} .ProseMirror .selectedCell{background:${i.border}}\n${l} .ProseMirror img{display:block;max-width:100%;height:auto;margin:0 0 ${q(i.blockGap)};border-radius:${q(i.radius)}}\n${l} .ProseMirror img.ProseMirror-selectednode{outline:2px solid ${i.accent}}\n${l} .ProseMirror .md-image-placeholder{margin:0 0 ${q(i.blockGap)};padding:${q(i.padding)};border:1px dashed ${i.border};border-radius:${q(i.radius)};color:${i.mutedColor}}\n${l} .ProseMirror p.is-editor-empty:first-child::before{content:attr(data-placeholder);color:${i.mutedColor};float:left;height:0;pointer-events:none}\n${l} .ProseMirror-gapcursor{display:none;pointer-events:none;position:absolute}\n${l} .ProseMirror-gapcursor:after{content:\"\";display:block;position:absolute;top:-2px;width:20px;border-top:1px solid ${i.color};animation:md-cursor-blink 1.1s steps(2,start) infinite}\n${l} .ProseMirror-focused .ProseMirror-gapcursor{display:block}\n@keyframes md-cursor-blink{to{visibility:hidden}}\n`}var Bh=\"#root\";function Mn(t){window.ReactNativeWebView&&window.ReactNativeWebView.postMessage(JSON.stringify(t))}var bt=null,Fh=document.createElement(\"style\");document.head.appendChild(Fh);function Hh({tokens:t,minHeight:e}){t&&typeof t==\"object\"&&(Fh.textContent=zh(t,Bh,{minHeight:e}))}function Ww(t){if(bt)return;let{markdown:e,placeholder:n,label:r}=t;Hh(t);let o=document.querySelector(Bh);bt=Lh({element:o,markdown:e,placeholder:n,label:r,onChange:s=>Mn({type:\"change\",markdown:s}),onFocusChange:s=>Mn({type:\"focus\",focused:s}),onState:s=>Mn({type:\"state\",inTable:s.inTable===!0})}),bt.editor.on(\"selectionUpdate\",()=>Mn({type:\"selection\",text:bt.selectedText()}));let i=0;new ResizeObserver(()=>{let s=Math.ceil(o.getBoundingClientRect().height);s!==i&&Mn({type:\"height\",height:i=s})}).observe(o)}window.mdEditor={receive(t){let e;try{e=JSON.parse(t)}catch{return}if(!(!e||typeof e!=\"object\"))if(e.type===\"init\")Ww(e);else if(e.type===\"style\")Hh(e);else if(bt)e.type===\"set\"?bt.setMarkdown(e.markdown):e.type===\"command\"?bt.command(e.name,e.args):e.type===\"focus\"&&bt.focus();else return}};Mn({type:\"ready\"});})();\n</script></body></html>";