dash_mantine_components 1.3.0 → 2.0.0

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 +1 @@
1
- "use strict";(self.webpackChunkdash_mantine_components=self.webpackChunkdash_mantine_components||[]).push([[330],{4417:t=>{t.exports=function(t,e){return e||(e={}),t?(t=String(t.__esModule?t.default:t),/^['"].*['"]$/.test(t)&&(t=t.slice(1,-1)),e.hash&&(t+=e.hash),/["'() \t\n]|(%20)/.test(t)||e.needQuotes?'"'.concat(t.replace(/"/g,'\\"').replace(/\n/g,"\\n"),'"'):t):t}},34985:t=>{t.exports="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCAxMCA3Ij48cGF0aCBmaWxsPSIjZmZmIiBkPSJNNCA0LjU4NkwxLjcwNyAyLjI5M0ExIDEgMCAxMC4yOTMgMy43MDdsMyAzYS45OTcuOTk3IDAgMDAxLjQxNCAwbDUtNUExIDEgMCAxMDguMjkzLjI5M0w0IDQuNTg2eiIvPjwvc3ZnPg=="},86389:(t,e,n)=>{n.r(e),n.d(e,{default:()=>gf});var o=n(31635);function r(t){this.content=t}r.prototype={constructor:r,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return-1==e?void 0:this.content[e+1]},update:function(t,e,n){var o=n&&n!=t?this.remove(n):this,i=o.find(t),s=o.content.slice();return-1==i?s.push(n||t,e):(s[i+1]=e,n&&(s[i]=n)),new r(s)},remove:function(t){var e=this.find(t);if(-1==e)return this;var n=this.content.slice();return n.splice(e,2),new r(n)},addToStart:function(t,e){return new r([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new r(n)},addBefore:function(t,e,n){var o=this.remove(e),i=o.content.slice(),s=o.find(t);return i.splice(-1==s?i.length:s,0,e,n),new r(i)},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=r.from(t)).size?new r(t.content.concat(this.subtract(t).content)):this},append:function(t){return(t=r.from(t)).size?new r(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=r.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}},r.from=function(t){if(t instanceof r)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new r(e)};const i=r;function s(t,e,n){for(let o=0;;o++){if(o==t.childCount||o==e.childCount)return t.childCount==e.childCount?null:n;let r=t.child(o),i=e.child(o);if(r!=i){if(!r.sameMarkup(i))return n;if(r.isText&&r.text!=i.text){for(let t=0;r.text[t]==i.text[t];t++)n++;return n}if(r.content.size||i.content.size){let t=s(r.content,i.content,n+1);if(null!=t)return t}n+=r.nodeSize}else n+=r.nodeSize}}function l(t,e,n,o){for(let r=t.childCount,i=e.childCount;;){if(0==r||0==i)return r==i?null:{a:n,b:o};let s=t.child(--r),a=e.child(--i),c=s.nodeSize;if(s!=a){if(!s.sameMarkup(a))return{a:n,b:o};if(s.isText&&s.text!=a.text){let t=0,e=Math.min(s.text.length,a.text.length);for(;t<e&&s.text[s.text.length-t-1]==a.text[a.text.length-t-1];)t++,n--,o--;return{a:n,b:o}}if(s.content.size||a.content.size){let t=l(s.content,a.content,n-1,o-1);if(t)return t}n-=c,o-=c}else n-=c,o-=c}}class a{constructor(t,e){if(this.content=t,this.size=e||0,null==e)for(let e=0;e<t.length;e++)this.size+=t[e].nodeSize}nodesBetween(t,e,n,o=0,r){for(let i=0,s=0;s<e;i++){let l=this.content[i],a=s+l.nodeSize;if(a>t&&!1!==n(l,o+s,r||null,i)&&l.content.size){let r=s+1;l.nodesBetween(Math.max(0,t-r),Math.min(l.content.size,e-r),n,o+r)}s=a}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,e,n,o){let r="",i=!0;return this.nodesBetween(t,e,((s,l)=>{let a=s.isText?s.text.slice(Math.max(t,l)-l,e-l):s.isLeaf?o?"function"==typeof o?o(s):o:s.type.spec.leafText?s.type.spec.leafText(s):"":"";s.isBlock&&(s.isLeaf&&a||s.isTextblock)&&n&&(i?i=!1:r+=n),r+=a}),0),r}append(t){if(!t.size)return this;if(!this.size)return t;let e=this.lastChild,n=t.firstChild,o=this.content.slice(),r=0;for(e.isText&&e.sameMarkup(n)&&(o[o.length-1]=e.withText(e.text+n.text),r=1);r<t.content.length;r++)o.push(t.content[r]);return new a(o,this.size+t.size)}cut(t,e=this.size){if(0==t&&e==this.size)return this;let n=[],o=0;if(e>t)for(let r=0,i=0;i<e;r++){let s=this.content[r],l=i+s.nodeSize;l>t&&((i<t||l>e)&&(s=s.isText?s.cut(Math.max(0,t-i),Math.min(s.text.length,e-i)):s.cut(Math.max(0,t-i-1),Math.min(s.content.size,e-i-1))),n.push(s),o+=s.nodeSize),i=l}return new a(n,o)}cutByIndex(t,e){return t==e?a.empty:0==t&&e==this.content.length?this:new a(this.content.slice(t,e))}replaceChild(t,e){let n=this.content[t];if(n==e)return this;let o=this.content.slice(),r=this.size+e.nodeSize-n.nodeSize;return o[t]=e,new a(o,r)}addToStart(t){return new a([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new a(this.content.concat(t),this.size+t.nodeSize)}eq(t){if(this.content.length!=t.content.length)return!1;for(let e=0;e<this.content.length;e++)if(!this.content[e].eq(t.content[e]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(t){let e=this.content[t];if(!e)throw new RangeError("Index "+t+" out of range for "+this);return e}maybeChild(t){return this.content[t]||null}forEach(t){for(let e=0,n=0;e<this.content.length;e++){let o=this.content[e];t(o,n,e),n+=o.nodeSize}}findDiffStart(t,e=0){return s(this,t,e)}findDiffEnd(t,e=this.size,n=t.size){return l(this,t,e,n)}findIndex(t,e=-1){if(0==t)return d(0,t);if(t==this.size)return d(this.content.length,t);if(t>this.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let n=0,o=0;;n++){let r=o+this.child(n).nodeSize;if(r>=t)return r==t||e>0?d(n+1,r):d(n,o);o=r}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map((t=>t.toJSON())):null}static fromJSON(t,e){if(!e)return a.empty;if(!Array.isArray(e))throw new RangeError("Invalid input for Fragment.fromJSON");return new a(e.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return a.empty;let e,n=0;for(let o=0;o<t.length;o++){let r=t[o];n+=r.nodeSize,o&&r.isText&&t[o-1].sameMarkup(r)?(e||(e=t.slice(0,o)),e[e.length-1]=r.withText(e[e.length-1].text+r.text)):e&&e.push(r)}return new a(e||t,n)}static from(t){if(!t)return a.empty;if(t instanceof a)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new a([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}a.empty=new a([],0);const c={index:0,offset:0};function d(t,e){return c.index=t,c.offset=e,c}function h(t,e){if(t===e)return!0;if(!t||"object"!=typeof t||!e||"object"!=typeof e)return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!h(t[n],e[n]))return!1}else{for(let n in t)if(!(n in e)||!h(t[n],e[n]))return!1;for(let n in e)if(!(n in t))return!1}return!0}class p{constructor(t,e){this.type=t,this.attrs=e}addToSet(t){let e,n=!1;for(let o=0;o<t.length;o++){let r=t[o];if(this.eq(r))return t;if(this.type.excludes(r.type))e||(e=t.slice(0,o));else{if(r.type.excludes(this.type))return t;!n&&r.type.rank>this.type.rank&&(e||(e=t.slice(0,o)),e.push(this),n=!0),e&&e.push(r)}}return e||(e=t.slice()),n||e.push(this),e}removeFromSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return t.slice(0,e).concat(t.slice(e+1));return t}isInSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return!0;return!1}eq(t){return this==t||this.type==t.type&&h(this.attrs,t.attrs)}toJSON(){let t={type:this.type.name};for(let e in this.attrs){t.attrs=this.attrs;break}return t}static fromJSON(t,e){if(!e)throw new RangeError("Invalid input for Mark.fromJSON");let n=t.marks[e.type];if(!n)throw new RangeError(`There is no mark type ${e.type} in this schema`);let o=n.create(e.attrs);return n.checkAttrs(o.attrs),o}static sameSet(t,e){if(t==e)return!0;if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].eq(e[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&0==t.length)return p.none;if(t instanceof p)return[t];let e=t.slice();return e.sort(((t,e)=>t.type.rank-e.type.rank)),e}}p.none=[];class u extends Error{}class f{constructor(t,e,n){this.content=t,this.openStart=e,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,e){let n=g(this.content,t+this.openStart,e);return n&&new f(n,this.openStart,this.openEnd)}removeBetween(t,e){return new f(m(this.content,t+this.openStart,e+this.openStart),this.openStart,this.openEnd)}eq(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let t={content:this.content.toJSON()};return this.openStart>0&&(t.openStart=this.openStart),this.openEnd>0&&(t.openEnd=this.openEnd),t}static fromJSON(t,e){if(!e)return f.empty;let n=e.openStart||0,o=e.openEnd||0;if("number"!=typeof n||"number"!=typeof o)throw new RangeError("Invalid input for Slice.fromJSON");return new f(a.fromJSON(t,e.content),n,o)}static maxOpen(t,e=!0){let n=0,o=0;for(let o=t.firstChild;o&&!o.isLeaf&&(e||!o.type.spec.isolating);o=o.firstChild)n++;for(let n=t.lastChild;n&&!n.isLeaf&&(e||!n.type.spec.isolating);n=n.lastChild)o++;return new f(t,n,o)}}function m(t,e,n){let{index:o,offset:r}=t.findIndex(e),i=t.maybeChild(o),{index:s,offset:l}=t.findIndex(n);if(r==e||i.isText){if(l!=n&&!t.child(s).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(o!=s)throw new RangeError("Removing non-flat range");return t.replaceChild(o,i.copy(m(i.content,e-r-1,n-r-1)))}function g(t,e,n,o){let{index:r,offset:i}=t.findIndex(e),s=t.maybeChild(r);if(i==e||s.isText)return o&&!o.canReplace(r,r,n)?null:t.cut(0,e).append(n).append(t.cut(e));let l=g(s.content,e-i-1,n);return l&&t.replaceChild(r,s.copy(l))}function y(t,e,n){if(n.openStart>t.depth)throw new u("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new u("Inconsistent open depths");return b(t,e,n,0)}function b(t,e,n,o){let r=t.index(o),i=t.node(o);if(r==e.index(o)&&o<t.depth-n.openStart){let s=b(t,e,n,o+1);return i.copy(i.content.replaceChild(r,s))}if(n.content.size){if(n.openStart||n.openEnd||t.depth!=o||e.depth!=o){let{start:r,end:s}=function(t,e){let n=e.depth-t.openStart,o=e.node(n).copy(t.content);for(let t=n-1;t>=0;t--)o=e.node(t).copy(a.from(o));return{start:o.resolveNoCache(t.openStart+n),end:o.resolveNoCache(o.content.size-t.openEnd-n)}}(n,t);return M(i,C(t,r,s,e,o))}{let o=t.parent,r=o.content;return M(o,r.cut(0,t.parentOffset).append(n.content).append(r.cut(e.parentOffset)))}}return M(i,S(t,e,o))}function v(t,e){if(!e.type.compatibleContent(t.type))throw new u("Cannot join "+e.type.name+" onto "+t.type.name)}function w(t,e,n){let o=t.node(n);return v(o,e.node(n)),o}function k(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 x(t,e,n,o){let r=(e||t).node(n),i=0,s=e?e.index(n):r.childCount;t&&(i=t.index(n),t.depth>n?i++:t.textOffset&&(k(t.nodeAfter,o),i++));for(let t=i;t<s;t++)k(r.child(t),o);e&&e.depth==n&&e.textOffset&&k(e.nodeBefore,o)}function M(t,e){return t.type.checkContent(e),t.copy(e)}function C(t,e,n,o,r){let i=t.depth>r&&w(t,e,r+1),s=o.depth>r&&w(n,o,r+1),l=[];return x(null,t,r,l),i&&s&&e.index(r)==n.index(r)?(v(i,s),k(M(i,C(t,e,n,o,r+1)),l)):(i&&k(M(i,S(t,e,r+1)),l),x(e,n,r,l),s&&k(M(s,S(n,o,r+1)),l)),x(o,null,r,l),new a(l)}function S(t,e,n){let o=[];return x(null,t,n,o),t.depth>n&&k(M(w(t,e,n+1),S(t,e,n+1)),o),x(e,null,n,o),new a(o)}f.empty=new f(a.empty,0,0);class T{constructor(t,e,n){this.pos=t,this.path=e,this.parentOffset=n,this.depth=e.length/3-1}resolveDepth(t){return null==t?this.depth:t<0?this.depth+t:t}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(t){return this.path[3*this.resolveDepth(t)]}index(t){return this.path[3*this.resolveDepth(t)+1]}indexAfter(t){return t=this.resolveDepth(t),this.index(t)+(t!=this.depth||this.textOffset?1:0)}start(t){return 0==(t=this.resolveDepth(t))?0:this.path[3*t-1]+1}end(t){return t=this.resolveDepth(t),this.start(t)+this.node(t).content.size}before(t){if(!(t=this.resolveDepth(t)))throw new RangeError("There is no position before the top-level node");return t==this.depth+1?this.pos:this.path[3*t-1]}after(t){if(!(t=this.resolveDepth(t)))throw new RangeError("There is no position after the top-level node");return t==this.depth+1?this.pos:this.path[3*t-1]+this.path[3*t].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let t=this.parent,e=this.index(this.depth);if(e==t.childCount)return null;let n=this.pos-this.path[this.path.length-1],o=t.child(e);return n?t.child(e).cut(n):o}get nodeBefore(){let t=this.index(this.depth),e=this.pos-this.path[this.path.length-1];return e?this.parent.child(t).cut(0,e):0==t?null:this.parent.child(t-1)}posAtIndex(t,e){e=this.resolveDepth(e);let n=this.path[3*e],o=0==e?0:this.path[3*e-1]+1;for(let e=0;e<t;e++)o+=n.child(e).nodeSize;return o}marks(){let t=this.parent,e=this.index();if(0==t.content.size)return p.none;if(this.textOffset)return t.child(e).marks;let n=t.maybeChild(e-1),o=t.maybeChild(e);if(!n){let t=n;n=o,o=t}let r=n.marks;for(var i=0;i<r.length;i++)!1!==r[i].type.spec.inclusive||o&&r[i].isInSet(o.marks)||(r=r[i--].removeFromSet(r));return r}marksAcross(t){let e=this.parent.maybeChild(this.index());if(!e||!e.isInline)return null;let n=e.marks,o=t.parent.maybeChild(t.index());for(var r=0;r<n.length;r++)!1!==n[r].type.spec.inclusive||o&&n[r].isInSet(o.marks)||(n=n[r--].removeFromSet(n));return n}sharedDepth(t){for(let e=this.depth;e>0;e--)if(this.start(e)<=t&&this.end(e)>=t)return e;return 0}blockRange(t=this,e){if(t.pos<this.pos)return t.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==t.pos?1:0);n>=0;n--)if(t.pos<=this.end(n)&&(!e||e(this.node(n))))return new N(this,t,n);return null}sameParent(t){return this.pos-this.parentOffset==t.pos-t.parentOffset}max(t){return t.pos>this.pos?t:this}min(t){return t.pos<this.pos?t:this}toString(){let t="";for(let e=1;e<=this.depth;e++)t+=(t?"/":"")+this.node(e).type.name+"_"+this.index(e-1);return t+":"+this.parentOffset}static resolve(t,e){if(!(e>=0&&e<=t.content.size))throw new RangeError("Position "+e+" out of range");let n=[],o=0,r=e;for(let e=t;;){let{index:t,offset:i}=e.content.findIndex(r),s=r-i;if(n.push(e,t,o+i),!s)break;if(e=e.child(t),e.isText)break;r=s-1,o+=i+1}return new T(e,n,r)}static resolveCached(t,e){let n=E.get(t);if(n)for(let t=0;t<n.elts.length;t++){let o=n.elts[t];if(o.pos==e)return o}else E.set(t,n=new A);let o=n.elts[n.i]=T.resolve(t,e);return n.i=(n.i+1)%O,o}}class A{constructor(){this.elts=[],this.i=0}}const O=12,E=new WeakMap;class N{constructor(t,e,n){this.$from=t,this.$to=e,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const D=Object.create(null);class R{constructor(t,e,n,o=p.none){this.type=t,this.attrs=e,this.marks=o,this.content=n||a.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(t){return this.content.child(t)}maybeChild(t){return this.content.maybeChild(t)}forEach(t){this.content.forEach(t)}nodesBetween(t,e,n,o=0){this.content.nodesBetween(t,e,n,o,this)}descendants(t){this.nodesBetween(0,this.content.size,t)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(t,e,n,o){return this.content.textBetween(t,e,n,o)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(t){return this==t||this.sameMarkup(t)&&this.content.eq(t.content)}sameMarkup(t){return this.hasMarkup(t.type,t.attrs,t.marks)}hasMarkup(t,e,n){return this.type==t&&h(this.attrs,e||t.defaultAttrs||D)&&p.sameSet(this.marks,n||p.none)}copy(t=null){return t==this.content?this:new R(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new R(this.type,this.attrs,this.content,t)}cut(t,e=this.content.size){return 0==t&&e==this.content.size?this:this.copy(this.content.cut(t,e))}slice(t,e=this.content.size,n=!1){if(t==e)return f.empty;let o=this.resolve(t),r=this.resolve(e),i=n?0:o.sharedDepth(e),s=o.start(i),l=o.node(i).content.cut(o.pos-s,r.pos-s);return new f(l,o.depth-i,r.depth-i)}replace(t,e,n){return y(this.resolve(t),this.resolve(e),n)}nodeAt(t){for(let e=this;;){let{index:n,offset:o}=e.content.findIndex(t);if(e=e.maybeChild(n),!e)return null;if(o==t||e.isText)return e;t-=o+1}}childAfter(t){let{index:e,offset:n}=this.content.findIndex(t);return{node:this.content.maybeChild(e),index:e,offset:n}}childBefore(t){if(0==t)return{node:null,index:0,offset:0};let{index:e,offset:n}=this.content.findIndex(t);if(n<t)return{node:this.content.child(e),index:e,offset:n};let o=this.content.child(e-1);return{node:o,index:e-1,offset:n-o.nodeSize}}resolve(t){return T.resolveCached(this,t)}resolveNoCache(t){return T.resolve(this,t)}rangeHasMark(t,e,n){let o=!1;return e>t&&this.nodesBetween(t,e,(t=>(n.isInSet(t.marks)&&(o=!0),!o))),o}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let t=this.type.name;return this.content.size&&(t+="("+this.content.toStringInner()+")"),L(this.marks,t)}contentMatchAt(t){let e=this.type.contentMatch.matchFragment(this.content,0,t);if(!e)throw new Error("Called contentMatchAt on a node with invalid content");return e}canReplace(t,e,n=a.empty,o=0,r=n.childCount){let i=this.contentMatchAt(t).matchFragment(n,o,r),s=i&&i.matchFragment(this.content,e);if(!s||!s.validEnd)return!1;for(let t=o;t<r;t++)if(!this.type.allowsMarks(n.child(t).marks))return!1;return!0}canReplaceWith(t,e,n,o){if(o&&!this.type.allowsMarks(o))return!1;let r=this.contentMatchAt(t).matchType(n),i=r&&r.matchFragment(this.content,e);return!!i&&i.validEnd}canAppend(t){return t.content.size?this.canReplace(this.childCount,this.childCount,t.content):this.type.compatibleContent(t.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let t=p.none;for(let e=0;e<this.marks.length;e++){let n=this.marks[e];n.type.checkAttrs(n.attrs),t=n.addToSet(t)}if(!p.sameSet(t,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map((t=>t.type.name))}`);this.content.forEach((t=>t.check()))}toJSON(){let t={type:this.type.name};for(let e in this.attrs){t.attrs=this.attrs;break}return this.content.size&&(t.content=this.content.toJSON()),this.marks.length&&(t.marks=this.marks.map((t=>t.toJSON()))),t}static fromJSON(t,e){if(!e)throw new RangeError("Invalid input for Node.fromJSON");let n;if(e.marks){if(!Array.isArray(e.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=e.marks.map(t.markFromJSON)}if("text"==e.type){if("string"!=typeof e.text)throw new RangeError("Invalid text node in JSON");return t.text(e.text,n)}let o=a.fromJSON(t,e.content),r=t.nodeType(e.type).create(e.attrs,o,n);return r.type.checkAttrs(r.attrs),r}}R.prototype.text=void 0;class j extends R{constructor(t,e,n,o){if(super(t,e,null,o),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):L(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(t,e){return this.text.slice(t,e)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new j(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new j(this.type,this.attrs,t,this.marks)}cut(t=0,e=this.text.length){return 0==t&&e==this.text.length?this:this.withText(this.text.slice(t,e))}eq(t){return this.sameMarkup(t)&&this.text==t.text}toJSON(){let t=super.toJSON();return t.text=this.text,t}}function L(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class I{constructor(t){this.validEnd=t,this.next=[],this.wrapCache=[]}static parse(t,e){let n=new P(t,e);if(null==n.next)return I.empty;let o=z(n);n.next&&n.err("Unexpected trailing text");let r=function(t){let e=Object.create(null);return function n(o){let r=[];o.forEach((e=>{t[e].forEach((({term:e,to:n})=>{if(!e)return;let o;for(let t=0;t<r.length;t++)r[t][0]==e&&(o=r[t][1]);V(t,n).forEach((t=>{o||r.push([e,o=[]]),-1==o.indexOf(t)&&o.push(t)}))}))}));let i=e[o.join(",")]=new I(o.indexOf(t.length-1)>-1);for(let t=0;t<r.length;t++){let o=r[t][1].sort(F);i.next.push({type:r[t][0],next:e[o.join(",")]||n(o)})}return i}(V(t,0))}(function(t){let e=[[]];return r(function t(e,i){if("choice"==e.type)return e.exprs.reduce(((e,n)=>e.concat(t(n,i))),[]);if("seq"!=e.type){if("star"==e.type){let s=n();return o(i,s),r(t(e.expr,s),s),[o(s)]}if("plus"==e.type){let s=n();return r(t(e.expr,i),s),r(t(e.expr,s),s),[o(s)]}if("opt"==e.type)return[o(i)].concat(t(e.expr,i));if("range"==e.type){let s=i;for(let o=0;o<e.min;o++){let o=n();r(t(e.expr,s),o),s=o}if(-1==e.max)r(t(e.expr,s),s);else for(let i=e.min;i<e.max;i++){let i=n();o(s,i),r(t(e.expr,s),i),s=i}return[o(s)]}if("name"==e.type)return[o(i,void 0,e.value)];throw new Error("Unknown expr type")}for(let o=0;;o++){let s=t(e.exprs[o],i);if(o==e.exprs.length-1)return s;r(s,i=n())}}(t,0),n()),e;function n(){return e.push([])-1}function o(t,n,o){let r={term:o,to:n};return e[t].push(r),r}function r(t,e){t.forEach((t=>t.to=e))}}(o));return function(t,e){for(let n=0,o=[t];n<o.length;n++){let t=o[n],r=!t.validEnd,i=[];for(let e=0;e<t.next.length;e++){let{type:n,next:s}=t.next[e];i.push(n.name),!r||n.isText||n.hasRequiredAttrs()||(r=!1),-1==o.indexOf(s)&&o.push(s)}r&&e.err("Only non-generatable nodes ("+i.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(r,n),r}matchType(t){for(let e=0;e<this.next.length;e++)if(this.next[e].type==t)return this.next[e].next;return null}matchFragment(t,e=0,n=t.childCount){let o=this;for(let r=e;o&&r<n;r++)o=o.matchType(t.child(r).type);return o}get inlineContent(){return 0!=this.next.length&&this.next[0].type.isInline}get defaultType(){for(let t=0;t<this.next.length;t++){let{type:e}=this.next[t];if(!e.isText&&!e.hasRequiredAttrs())return e}return null}compatible(t){for(let e=0;e<this.next.length;e++)for(let n=0;n<t.next.length;n++)if(this.next[e].type==t.next[n].type)return!0;return!1}fillBefore(t,e=!1,n=0){let o=[this];return function r(i,s){let l=i.matchFragment(t,n);if(l&&(!e||l.validEnd))return a.from(s.map((t=>t.createAndFill())));for(let t=0;t<i.next.length;t++){let{type:e,next:n}=i.next[t];if(!e.isText&&!e.hasRequiredAttrs()&&-1==o.indexOf(n)){o.push(n);let t=r(n,s.concat(e));if(t)return t}}return null}(this,[])}findWrapping(t){for(let e=0;e<this.wrapCache.length;e+=2)if(this.wrapCache[e]==t)return this.wrapCache[e+1];let e=this.computeWrapping(t);return this.wrapCache.push(t,e),e}computeWrapping(t){let e=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let o=n.shift(),r=o.match;if(r.matchType(t)){let t=[];for(let e=o;e.type;e=e.via)t.push(e.type);return t.reverse()}for(let t=0;t<r.next.length;t++){let{type:i,next:s}=r.next[t];i.isLeaf||i.hasRequiredAttrs()||i.name in e||o.type&&!s.validEnd||(n.push({match:i.contentMatch,type:i,via:o}),e[i.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(t){if(t>=this.next.length)throw new RangeError(`There's no ${t}th edge in this content match`);return this.next[t]}toString(){let t=[];return function e(n){t.push(n);for(let o=0;o<n.next.length;o++)-1==t.indexOf(n.next[o].next)&&e(n.next[o].next)}(this),t.map(((e,n)=>{let o=n+(e.validEnd?"*":" ")+" ";for(let n=0;n<e.next.length;n++)o+=(n?", ":"")+e.next[n].type.name+"->"+t.indexOf(e.next[n].next);return o})).join("\n")}}I.empty=new I(!0);class P{constructor(t,e){this.string=t,this.nodeTypes=e,this.inline=null,this.pos=0,this.tokens=t.split(/\s*(?=\b|\W|$)/),""==this.tokens[this.tokens.length-1]&&this.tokens.pop(),""==this.tokens[0]&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(t){return this.next==t&&(this.pos++||!0)}err(t){throw new SyntaxError(t+" (in content expression '"+this.string+"')")}}function z(t){let e=[];do{e.push($(t))}while(t.eat("|"));return 1==e.length?e[0]:{type:"choice",exprs:e}}function $(t){let e=[];do{e.push(H(t))}while(t.next&&")"!=t.next&&"|"!=t.next);return 1==e.length?e[0]:{type:"seq",exprs:e}}function H(t){let e=function(t){if(t.eat("(")){let e=z(t);return t.eat(")")||t.err("Missing closing paren"),e}if(!/\W/.test(t.next)){let e=function(t,e){let n=t.nodeTypes,o=n[e];if(o)return[o];let r=[];for(let t in n){let o=n[t];o.isInGroup(e)&&r.push(o)}return 0==r.length&&t.err("No node type or group '"+e+"' found"),r}(t,t.next).map((e=>(null==t.inline?t.inline=e.isInline:t.inline!=e.isInline&&t.err("Mixing inline and block content"),{type:"name",value:e})));return t.pos++,1==e.length?e[0]:{type:"choice",exprs:e}}t.err("Unexpected token '"+t.next+"'")}(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else{if(!t.eat("{"))break;e=_(t,e)}return e}function B(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function _(t,e){let n=B(t),o=n;return t.eat(",")&&(o="}"!=t.next?B(t):-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:o,expr:e}}function F(t,e){return e-t}function V(t,e){let n=[];return function e(o){let r=t[o];if(1==r.length&&!r[0].term)return e(r[0].to);n.push(o);for(let t=0;t<r.length;t++){let{term:o,to:i}=r[t];o||-1!=n.indexOf(i)||e(i)}}(e),n.sort(F)}function W(t){let e=Object.create(null);for(let n in t){let o=t[n];if(!o.hasDefault)return null;e[n]=o.default}return e}function q(t,e){let n=Object.create(null);for(let o in t){let r=e&&e[o];if(void 0===r){let e=t[o];if(!e.hasDefault)throw new RangeError("No value supplied for attribute "+o);r=e.default}n[o]=r}return n}function K(t,e,n,o){for(let o in e)if(!(o in t))throw new RangeError(`Unsupported attribute ${o} for ${n} of type ${o}`);for(let n in t){let o=t[n];o.validate&&o.validate(e[n])}}function J(t,e){let n=Object.create(null);if(e)for(let o in e)n[o]=new G(t,o,e[o]);return n}class U{constructor(t,e,n){this.name=t,this.schema=e,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(" "):[],this.attrs=J(t,n.attrs),this.defaultAttrs=W(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||"text"==t),this.isText="text"==t}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==I.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(t){return this.groups.indexOf(t)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let t in this.attrs)if(this.attrs[t].isRequired)return!0;return!1}compatibleContent(t){return this==t||this.contentMatch.compatible(t.contentMatch)}computeAttrs(t){return!t&&this.defaultAttrs?this.defaultAttrs:q(this.attrs,t)}create(t=null,e,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new R(this,this.computeAttrs(t),a.from(e),p.setFrom(n))}createChecked(t=null,e,n){return e=a.from(e),this.checkContent(e),new R(this,this.computeAttrs(t),e,p.setFrom(n))}createAndFill(t=null,e,n){if(t=this.computeAttrs(t),(e=a.from(e)).size){let t=this.contentMatch.fillBefore(e);if(!t)return null;e=t.append(e)}let o=this.contentMatch.matchFragment(e),r=o&&o.fillBefore(a.empty,!0);return r?new R(this,t,e.append(r),p.setFrom(n)):null}validContent(t){let e=this.contentMatch.matchFragment(t);if(!e||!e.validEnd)return!1;for(let e=0;e<t.childCount;e++)if(!this.allowsMarks(t.child(e).marks))return!1;return!0}checkContent(t){if(!this.validContent(t))throw new RangeError(`Invalid content for node ${this.name}: ${t.toString().slice(0,50)}`)}checkAttrs(t){K(this.attrs,t,"node",this.name)}allowsMarkType(t){return null==this.markSet||this.markSet.indexOf(t)>-1}allowsMarks(t){if(null==this.markSet)return!0;for(let e=0;e<t.length;e++)if(!this.allowsMarkType(t[e].type))return!1;return!0}allowedMarks(t){if(null==this.markSet)return t;let e;for(let n=0;n<t.length;n++)this.allowsMarkType(t[n].type)?e&&e.push(t[n]):e||(e=t.slice(0,n));return e?e.length?e:p.none:t}static compile(t,e){let n=Object.create(null);t.forEach(((t,o)=>n[t]=new U(t,e,o)));let o=e.spec.topNode||"doc";if(!n[o])throw new RangeError("Schema is missing its top node type ('"+o+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(let t in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n}}class G{constructor(t,e,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate="string"==typeof n.validate?function(t,e,n){let o=n.split("|");return n=>{let r=null===n?"null":typeof n;if(o.indexOf(r)<0)throw new RangeError(`Expected value of type ${o} for attribute ${e} on type ${t}, got ${r}`)}}(t,e,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class Y{constructor(t,e,n,o){this.name=t,this.rank=e,this.schema=n,this.spec=o,this.attrs=J(t,o.attrs),this.excluded=null;let r=W(this.attrs);this.instance=r?new p(this,r):null}create(t=null){return!t&&this.instance?this.instance:new p(this,q(this.attrs,t))}static compile(t,e){let n=Object.create(null),o=0;return t.forEach(((t,r)=>n[t]=new Y(t,o++,e,r))),n}removeFromSet(t){for(var e=0;e<t.length;e++)t[e].type==this&&(t=t.slice(0,e).concat(t.slice(e+1)),e--);return t}isInSet(t){for(let e=0;e<t.length;e++)if(t[e].type==this)return t[e]}checkAttrs(t){K(this.attrs,t,"mark",this.name)}excludes(t){return this.excluded.indexOf(t)>-1}}class X{constructor(t){this.linebreakReplacement=null,this.cached=Object.create(null);let e=this.spec={};for(let n in t)e[n]=t[n];e.nodes=i.from(t.nodes),e.marks=i.from(t.marks||{}),this.nodes=U.compile(this.spec.nodes,this),this.marks=Y.compile(this.spec.marks,this);let n=Object.create(null);for(let t in this.nodes){if(t in this.marks)throw new RangeError(t+" can not be both a node and a mark");let e=this.nodes[t],o=e.spec.content||"",r=e.spec.marks;if(e.contentMatch=n[o]||(n[o]=I.parse(o,this.nodes)),e.inlineContent=e.contentMatch.inlineContent,e.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!e.isInline||!e.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=e}e.markSet="_"==r?null:r?Q(this,r.split(" ")):""!=r&&e.inlineContent?null:[]}for(let t in this.marks){let e=this.marks[t],n=e.spec.excludes;e.excluded=null==n?[e]:""==n?[]:Q(this,n.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(t,e=null,n,o){if("string"==typeof t)t=this.nodeType(t);else{if(!(t instanceof U))throw new RangeError("Invalid node type: "+t);if(t.schema!=this)throw new RangeError("Node type from different schema used ("+t.name+")")}return t.createChecked(e,n,o)}text(t,e){let n=this.nodes.text;return new j(n,n.defaultAttrs,t,p.setFrom(e))}mark(t,e){return"string"==typeof t&&(t=this.marks[t]),t.create(e)}nodeFromJSON(t){return R.fromJSON(this,t)}markFromJSON(t){return p.fromJSON(this,t)}nodeType(t){let e=this.nodes[t];if(!e)throw new RangeError("Unknown node type: "+t);return e}}function Q(t,e){let n=[];for(let o=0;o<e.length;o++){let r=e[o],i=t.marks[r],s=i;if(i)n.push(i);else for(let e in t.marks){let o=t.marks[e];("_"==r||o.spec.group&&o.spec.group.split(" ").indexOf(r)>-1)&&n.push(s=o)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[o]+"'")}return n}class Z{constructor(t,e){this.schema=t,this.rules=e,this.tags=[],this.styles=[];let n=this.matchedStyles=[];e.forEach((t=>{if(function(t){return null!=t.tag}(t))this.tags.push(t);else if(function(t){return null!=t.style}(t)){let e=/[^=]*/.exec(t.style)[0];n.indexOf(e)<0&&n.push(e),this.styles.push(t)}})),this.normalizeLists=!this.tags.some((e=>{if(!/^(ul|ol)\b/.test(e.tag)||!e.node)return!1;let n=t.nodes[e.node];return n.contentMatch.matchType(n)}))}parse(t,e={}){let n=new it(this,e,!1);return n.addAll(t,p.none,e.from,e.to),n.finish()}parseSlice(t,e={}){let n=new it(this,e,!0);return n.addAll(t,p.none,e.from,e.to),f.maxOpen(n.finish())}matchTag(t,e,n){for(let o=n?this.tags.indexOf(n)+1:0;o<this.tags.length;o++){let n=this.tags[o];if(st(t,n.tag)&&(void 0===n.namespace||t.namespaceURI==n.namespace)&&(!n.context||e.matchesContext(n.context))){if(n.getAttrs){let e=n.getAttrs(t);if(!1===e)continue;n.attrs=e||void 0}return n}}}matchStyle(t,e,n,o){for(let r=o?this.styles.indexOf(o)+1:0;r<this.styles.length;r++){let o=this.styles[r],i=o.style;if(!(0!=i.indexOf(t)||o.context&&!n.matchesContext(o.context)||i.length>t.length&&(61!=i.charCodeAt(t.length)||i.slice(t.length+1)!=e))){if(o.getAttrs){let t=o.getAttrs(e);if(!1===t)continue;o.attrs=t||void 0}return o}}}static schemaRules(t){let e=[];function n(t){let n=null==t.priority?50:t.priority,o=0;for(;o<e.length;o++){let t=e[o];if((null==t.priority?50:t.priority)<n)break}e.splice(o,0,t)}for(let e in t.marks){let o=t.marks[e].spec.parseDOM;o&&o.forEach((t=>{n(t=lt(t)),t.mark||t.ignore||t.clearMark||(t.mark=e)}))}for(let e in t.nodes){let o=t.nodes[e].spec.parseDOM;o&&o.forEach((t=>{n(t=lt(t)),t.node||t.ignore||t.mark||(t.node=e)}))}return e}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new Z(t,Z.schemaRules(t)))}}const tt={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},et={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},nt={ol:!0,ul:!0};function ot(t,e,n){return null!=e?(e?1:0)|("full"===e?2:0):t&&"pre"==t.whitespace?3:-5&n}class rt{constructor(t,e,n,o,r,i){this.type=t,this.attrs=e,this.marks=n,this.solid=o,this.options=i,this.content=[],this.activeMarks=p.none,this.match=r||(4&i?null:t.contentMatch)}findWrapping(t){if(!this.match){if(!this.type)return[];let e=this.type.contentMatch.fillBefore(a.from(t));if(!e){let e,n=this.type.contentMatch;return(e=n.findWrapping(t.type))?(this.match=n,e):null}this.match=this.type.contentMatch.matchFragment(e)}return this.match.findWrapping(t.type)}finish(t){if(!(1&this.options)){let t,e=this.content[this.content.length-1];if(e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))){let n=e;e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-t[0].length))}}let e=a.from(this.content);return!t&&this.match&&(e=e.append(this.match.fillBefore(a.empty,!0))),this.type?this.type.create(this.attrs,e,this.marks):e}inlineContext(t){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:t.parentNode&&!tt.hasOwnProperty(t.parentNode.nodeName.toLowerCase())}}class it{constructor(t,e,n){this.parser=t,this.options=e,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let o,r=e.topNode,i=ot(null,e.preserveWhitespace,0)|(n?4:0);o=r?new rt(r.type,r.attrs,p.none,!0,e.topMatch||r.type.contentMatch,i):new rt(n?null:t.schema.topNodeType,null,p.none,!0,null,i),this.nodes=[o],this.find=e.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(t,e){3==t.nodeType?this.addTextNode(t,e):1==t.nodeType&&this.addElement(t,e)}addTextNode(t,e){let n=t.nodeValue,o=this.top,r=2&o.options?"full":this.localPreserveWS||(1&o.options)>0;if("full"===r||o.inlineContext(t)||/[^ \t\r\n\u000c]/.test(n)){if(r)n="full"!==r?n.replace(/\r?\n|\r/g," "):n.replace(/\r\n?/g,"\n");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let e=o.content[o.content.length-1],r=t.previousSibling;(!e||r&&"BR"==r.nodeName||e.isText&&/[ \t\r\n\u000c]$/.test(e.text))&&(n=n.slice(1))}n&&this.insertNode(this.parser.schema.text(n),e),this.findInText(t)}else this.findInside(t)}addElement(t,e,n){let o=this.localPreserveWS,r=this.top;("PRE"==t.tagName||/pre/.test(t.style&&t.style.whiteSpace))&&(this.localPreserveWS=!0);let i,s=t.nodeName.toLowerCase();nt.hasOwnProperty(s)&&this.parser.normalizeLists&&function(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let t=1==e.nodeType?e.nodeName.toLowerCase():null;t&&nt.hasOwnProperty(t)&&n?(n.appendChild(e),e=n):"li"==t?n=e:t&&(n=null)}}(t);let l=this.options.ruleFromNode&&this.options.ruleFromNode(t)||(i=this.parser.matchTag(t,this,n));t:if(l?l.ignore:et.hasOwnProperty(s))this.findInside(t),this.ignoreFallback(t,e);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(t=l.skip);let n,o=this.needsBlock;if(tt.hasOwnProperty(s))r.content.length&&r.content[0].isInline&&this.open&&(this.open--,r=this.top),n=!0,r.type||(this.needsBlock=!0);else if(!t.firstChild){this.leafFallback(t,e);break t}let i=l&&l.skip?e:this.readStyles(t,e);i&&this.addAll(t,i),n&&this.sync(r),this.needsBlock=o}else{let n=this.readStyles(t,e);n&&this.addElementByRule(t,l,n,!1===l.consuming?i:void 0)}this.localPreserveWS=o}leafFallback(t,e){"BR"==t.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(t.ownerDocument.createTextNode("\n"),e)}ignoreFallback(t,e){"BR"!=t.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"),e)}readStyles(t,e){let n=t.style;if(n&&n.length)for(let t=0;t<this.parser.matchedStyles.length;t++){let o=this.parser.matchedStyles[t],r=n.getPropertyValue(o);if(r)for(let t;;){let n=this.parser.matchStyle(o,r,this,t);if(!n)break;if(n.ignore)return null;if(e=n.clearMark?e.filter((t=>!n.clearMark(t))):e.concat(this.parser.schema.marks[n.mark].create(n.attrs)),!1!==n.consuming)break;t=n}}return e}addElementByRule(t,e,n,o){let r,i;if(e.node)if(i=this.parser.schema.nodes[e.node],i.isLeaf)this.insertNode(i.create(e.attrs),n)||this.leafFallback(t,n);else{let t=this.enter(i,e.attrs||null,n,e.preserveWhitespace);t&&(r=!0,n=t)}else{let t=this.parser.schema.marks[e.mark];n=n.concat(t.create(e.attrs))}let s=this.top;if(i&&i.isLeaf)this.findInside(t);else if(o)this.addElement(t,n,o);else if(e.getContent)this.findInside(t),e.getContent(t,this.parser.schema).forEach((t=>this.insertNode(t,n)));else{let o=t;"string"==typeof e.contentElement?o=t.querySelector(e.contentElement):"function"==typeof e.contentElement?o=e.contentElement(t):e.contentElement&&(o=e.contentElement),this.findAround(t,o,!0),this.addAll(o,n),this.findAround(t,o,!1)}r&&this.sync(s)&&this.open--}addAll(t,e,n,o){let r=n||0;for(let i=n?t.childNodes[n]:t.firstChild,s=null==o?null:t.childNodes[o];i!=s;i=i.nextSibling,++r)this.findAtPoint(t,r),this.addDOM(i,e);this.findAtPoint(t,r)}findPlace(t,e){let n,o;for(let e=this.open;e>=0;e--){let r=this.nodes[e],i=r.findWrapping(t);if(i&&(!n||n.length>i.length)&&(n=i,o=r,!i.length))break;if(r.solid)break}if(!n)return null;this.sync(o);for(let t=0;t<n.length;t++)e=this.enterInner(n[t],null,e,!1);return e}insertNode(t,e){if(t.isInline&&this.needsBlock&&!this.top.type){let t=this.textblockFromContext();t&&(e=this.enterInner(t,null,e))}let n=this.findPlace(t,e);if(n){this.closeExtra();let e=this.top;e.match&&(e.match=e.match.matchType(t.type));let o=p.none;for(let r of n.concat(t.marks))(e.type?e.type.allowsMarkType(r.type):at(r.type,t.type))&&(o=r.addToSet(o));return e.content.push(t.mark(o)),!0}return!1}enter(t,e,n,o){let r=this.findPlace(t.create(e),n);return r&&(r=this.enterInner(t,e,n,!0,o)),r}enterInner(t,e,n,o=!1,r){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(t);let s=ot(t,r,i.options);4&i.options&&0==i.content.length&&(s|=4);let l=p.none;return n=n.filter((e=>!(i.type?i.type.allowsMarkType(e.type):at(e.type,t))||(l=e.addToSet(l),!1))),this.nodes.push(new rt(t,e,l,o,null,s)),this.open++,n}closeExtra(t=!1){let e=this.nodes.length-1;if(e>this.open){for(;e>this.open;e--)this.nodes[e-1].content.push(this.nodes[e].finish(t));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!(!this.isOpen&&!this.options.topOpen))}sync(t){for(let e=this.open;e>=0;e--){if(this.nodes[e]==t)return this.open=e,!0;this.localPreserveWS&&(this.nodes[e].options|=1)}return!1}get currentPos(){this.closeExtra();let t=0;for(let e=this.open;e>=0;e--){let n=this.nodes[e].content;for(let e=n.length-1;e>=0;e--)t+=n[e].nodeSize;e&&t++}return t}findAtPoint(t,e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==t&&this.find[n].offset==e&&(this.find[n].pos=this.currentPos)}findInside(t){if(this.find)for(let e=0;e<this.find.length;e++)null==this.find[e].pos&&1==t.nodeType&&t.contains(this.find[e].node)&&(this.find[e].pos=this.currentPos)}findAround(t,e,n){if(t!=e&&this.find)for(let o=0;o<this.find.length;o++)null==this.find[o].pos&&1==t.nodeType&&t.contains(this.find[o].node)&&e.compareDocumentPosition(this.find[o].node)&(n?2:4)&&(this.find[o].pos=this.currentPos)}findInText(t){if(this.find)for(let e=0;e<this.find.length;e++)this.find[e].node==t&&(this.find[e].pos=this.currentPos-(t.nodeValue.length-this.find[e].offset))}matchesContext(t){if(t.indexOf("|")>-1)return t.split(/\s*\|\s*/).some(this.matchesContext,this);let e=t.split("/"),n=this.options.context,o=!(this.isOpen||n&&n.parent.type!=this.nodes[0].type),r=-(n?n.depth+1:0)+(o?0:1),i=(t,s)=>{for(;t>=0;t--){let l=e[t];if(""==l){if(t==e.length-1||0==t)continue;for(;s>=r;s--)if(i(t-1,s))return!0;return!1}{let t=s>0||0==s&&o?this.nodes[s].type:n&&s>=r?n.node(s-r).type:null;if(!t||t.name!=l&&!t.isInGroup(l))return!1;s--}}return!0};return i(e.length-1,this.open)}textblockFromContext(){let t=this.options.context;if(t)for(let e=t.depth;e>=0;e--){let n=t.node(e).contentMatchAt(t.indexAfter(e)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let t in this.parser.schema.nodes){let e=this.parser.schema.nodes[t];if(e.isTextblock&&e.defaultAttrs)return e}}}function st(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function lt(t){let e={};for(let n in t)e[n]=t[n];return e}function at(t,e){let n=e.schema.nodes;for(let o in n){let r=n[o];if(!r.allowsMarkType(t))continue;let i=[],s=t=>{i.push(t);for(let n=0;n<t.edgeCount;n++){let{type:o,next:r}=t.edge(n);if(o==e)return!0;if(i.indexOf(r)<0&&s(r))return!0}};if(s(r.contentMatch))return!0}}class ct{constructor(t,e){this.nodes=t,this.marks=e}serializeFragment(t,e={},n){n||(n=ht(e).createDocumentFragment());let o=n,r=[];return t.forEach((t=>{if(r.length||t.marks.length){let n=0,i=0;for(;n<r.length&&i<t.marks.length;){let e=t.marks[i];if(this.marks[e.type.name]){if(!e.eq(r[n][0])||!1===e.type.spec.spanning)break;n++,i++}else i++}for(;n<r.length;)o=r.pop()[1];for(;i<t.marks.length;){let n=t.marks[i++],s=this.serializeMark(n,t.isInline,e);s&&(r.push([n,o]),o.appendChild(s.dom),o=s.contentDOM||s.dom)}}o.appendChild(this.serializeNodeInner(t,e))})),n}serializeNodeInner(t,e){let{dom:n,contentDOM:o}=ut(ht(e),this.nodes[t.type.name](t),null,t.attrs);if(o){if(t.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(t.content,e,o)}return n}serializeNode(t,e={}){let n=this.serializeNodeInner(t,e);for(let o=t.marks.length-1;o>=0;o--){let r=this.serializeMark(t.marks[o],t.isInline,e);r&&((r.contentDOM||r.dom).appendChild(n),n=r.dom)}return n}serializeMark(t,e,n={}){let o=this.marks[t.type.name];return o&&ut(ht(n),o(t,e),null,t.attrs)}static renderSpec(t,e,n=null,o){return ut(t,e,n,o)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new ct(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(t){let e=dt(t.nodes);return e.text||(e.text=t=>t.text),e}static marksFromSchema(t){return dt(t.marks)}}function dt(t){let e={};for(let n in t){let o=t[n].spec.toDOM;o&&(e[n]=o)}return e}function ht(t){return t.document||window.document}const pt=new WeakMap;function ut(t,e,n,o){if("string"==typeof e)return{dom:t.createTextNode(e)};if(null!=e.nodeType)return{dom:e};if(e.dom&&null!=e.dom.nodeType)return e;let r,i=e[0];if("string"!=typeof i)throw new RangeError("Invalid array passed to renderSpec");if(o&&(r=function(t){let e=pt.get(t);return void 0===e&&pt.set(t,e=function(t){let e=null;return function t(n){if(n&&"object"==typeof n)if(Array.isArray(n))if("string"==typeof n[0])e||(e=[]),e.push(n);else for(let e=0;e<n.length;e++)t(n[e]);else for(let e in n)t(n[e])}(t),e}(t)),e}(o))&&r.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let s,l=i.indexOf(" ");l>0&&(n=i.slice(0,l),i=i.slice(l+1));let a=n?t.createElementNS(n,i):t.createElement(i),c=e[1],d=1;if(c&&"object"==typeof c&&null==c.nodeType&&!Array.isArray(c)){d=2;for(let t in c)if(null!=c[t]){let e=t.indexOf(" ");e>0?a.setAttributeNS(t.slice(0,e),t.slice(e+1),c[t]):a.setAttribute(t,c[t])}}for(let r=d;r<e.length;r++){let i=e[r];if(0===i){if(r<e.length-1||r>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}{let{dom:e,contentDOM:r}=ut(t,i,n,o);if(a.appendChild(e),r){if(s)throw new RangeError("Multiple content holes");s=r}}}return{dom:a,contentDOM:s}}const ft=Math.pow(2,16);function mt(t){return 65535&t}class gt{constructor(t,e,n){this.pos=t,this.delInfo=e,this.recover=n}get deleted(){return(8&this.delInfo)>0}get deletedBefore(){return(5&this.delInfo)>0}get deletedAfter(){return(6&this.delInfo)>0}get deletedAcross(){return(4&this.delInfo)>0}}class yt{constructor(t,e=!1){if(this.ranges=t,this.inverted=e,!t.length&&yt.empty)return yt.empty}recover(t){let e=0,n=mt(t);if(!this.inverted)for(let t=0;t<n;t++)e+=this.ranges[3*t+2]-this.ranges[3*t+1];return this.ranges[3*n]+e+function(t){return(t-(65535&t))/ft}(t)}mapResult(t,e=1){return this._map(t,e,!1)}map(t,e=1){return this._map(t,e,!0)}_map(t,e,n){let o=0,r=this.inverted?2:1,i=this.inverted?1:2;for(let s=0;s<this.ranges.length;s+=3){let l=this.ranges[s]-(this.inverted?o:0);if(l>t)break;let a=this.ranges[s+r],c=this.ranges[s+i],d=l+a;if(t<=d){let r=l+o+((a?t==l?-1:t==d?1:e:e)<0?0:c);if(n)return r;let i=t==(e<0?l:d)?null:s/3+(t-l)*ft,h=t==l?2:t==d?1:4;return(e<0?t!=l:t!=d)&&(h|=8),new gt(r,h,i)}o+=c-a}return n?t+o:new gt(t+o,0,null)}touches(t,e){let n=0,o=mt(e),r=this.inverted?2:1,i=this.inverted?1:2;for(let e=0;e<this.ranges.length;e+=3){let s=this.ranges[e]-(this.inverted?n:0);if(s>t)break;let l=this.ranges[e+r];if(t<=s+l&&e==3*o)return!0;n+=this.ranges[e+i]-l}return!1}forEach(t){let e=this.inverted?2:1,n=this.inverted?1:2;for(let o=0,r=0;o<this.ranges.length;o+=3){let i=this.ranges[o],s=i-(this.inverted?r:0),l=i+(this.inverted?0:r),a=this.ranges[o+e],c=this.ranges[o+n];t(s,s+a,l,l+c),r+=c-a}}invert(){return new yt(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(t){return 0==t?yt.empty:new yt(t<0?[0,-t,0]:[0,0,t])}}yt.empty=new yt([]);class bt{constructor(t,e,n=0,o=(t?t.length:0)){this.mirror=e,this.from=n,this.to=o,this._maps=t||[],this.ownData=!(t||e)}get maps(){return this._maps}slice(t=0,e=this.maps.length){return new bt(this._maps,this.mirror,t,e)}appendMap(t,e){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(t),null!=e&&this.setMirror(this._maps.length-1,e)}appendMapping(t){for(let e=0,n=this._maps.length;e<t._maps.length;e++){let o=t.getMirror(e);this.appendMap(t._maps[e],null!=o&&o<e?n+o:void 0)}}getMirror(t){if(this.mirror)for(let e=0;e<this.mirror.length;e++)if(this.mirror[e]==t)return this.mirror[e+(e%2?-1:1)]}setMirror(t,e){this.mirror||(this.mirror=[]),this.mirror.push(t,e)}appendMappingInverted(t){for(let e=t.maps.length-1,n=this._maps.length+t._maps.length;e>=0;e--){let o=t.getMirror(e);this.appendMap(t._maps[e].invert(),null!=o&&o>e?n-o-1:void 0)}}invert(){let t=new bt;return t.appendMappingInverted(this),t}map(t,e=1){if(this.mirror)return this._map(t,e,!0);for(let n=this.from;n<this.to;n++)t=this._maps[n].map(t,e);return t}mapResult(t,e=1){return this._map(t,e,!1)}_map(t,e,n){let o=0;for(let n=this.from;n<this.to;n++){let r=this._maps[n].mapResult(t,e);if(null!=r.recover){let e=this.getMirror(n);if(null!=e&&e>n&&e<this.to){n=e,t=this._maps[e].recover(r.recover);continue}}o|=r.delInfo,t=r.pos}return n?t:new gt(t,o,null)}}const vt=Object.create(null);class wt{getMap(){return yt.empty}merge(t){return null}static fromJSON(t,e){if(!e||!e.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=vt[e.stepType];if(!n)throw new RangeError(`No step type ${e.stepType} defined`);return n.fromJSON(t,e)}static jsonID(t,e){if(t in vt)throw new RangeError("Duplicate use of step JSON ID "+t);return vt[t]=e,e.prototype.jsonID=t,e}}class kt{constructor(t,e){this.doc=t,this.failed=e}static ok(t){return new kt(t,null)}static fail(t){return new kt(null,t)}static fromReplace(t,e,n,o){try{return kt.ok(t.replace(e,n,o))}catch(t){if(t instanceof u)return kt.fail(t.message);throw t}}}function xt(t,e,n){let o=[];for(let r=0;r<t.childCount;r++){let i=t.child(r);i.content.size&&(i=i.copy(xt(i.content,e,i))),i.isInline&&(i=e(i,n,r)),o.push(i)}return a.fromArray(o)}class Mt extends wt{constructor(t,e,n){super(),this.from=t,this.to=e,this.mark=n}apply(t){let e=t.slice(this.from,this.to),n=t.resolve(this.from),o=n.node(n.sharedDepth(this.to)),r=new f(xt(e.content,((t,e)=>t.isAtom&&e.type.allowsMarkType(this.mark.type)?t.mark(this.mark.addToSet(t.marks)):t),o),e.openStart,e.openEnd);return kt.fromReplace(t,this.from,this.to,r)}invert(){return new Ct(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),n=t.mapResult(this.to,-1);return e.deleted&&n.deleted||e.pos>=n.pos?null:new Mt(e.pos,n.pos,this.mark)}merge(t){return t instanceof Mt&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new Mt(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,e){if("number"!=typeof e.from||"number"!=typeof e.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Mt(e.from,e.to,t.markFromJSON(e.mark))}}wt.jsonID("addMark",Mt);class Ct extends wt{constructor(t,e,n){super(),this.from=t,this.to=e,this.mark=n}apply(t){let e=t.slice(this.from,this.to),n=new f(xt(e.content,(t=>t.mark(this.mark.removeFromSet(t.marks))),t),e.openStart,e.openEnd);return kt.fromReplace(t,this.from,this.to,n)}invert(){return new Mt(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),n=t.mapResult(this.to,-1);return e.deleted&&n.deleted||e.pos>=n.pos?null:new Ct(e.pos,n.pos,this.mark)}merge(t){return t instanceof Ct&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new Ct(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,e){if("number"!=typeof e.from||"number"!=typeof e.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Ct(e.from,e.to,t.markFromJSON(e.mark))}}wt.jsonID("removeMark",Ct);class St extends wt{constructor(t,e){super(),this.pos=t,this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return kt.fail("No node at mark step's position");let n=e.type.create(e.attrs,null,this.mark.addToSet(e.marks));return kt.fromReplace(t,this.pos,this.pos+1,new f(a.from(n),0,e.isLeaf?0:1))}invert(t){let e=t.nodeAt(this.pos);if(e){let t=this.mark.addToSet(e.marks);if(t.length==e.marks.length){for(let n=0;n<e.marks.length;n++)if(!e.marks[n].isInSet(t))return new St(this.pos,e.marks[n]);return new St(this.pos,this.mark)}}return new Tt(this.pos,this.mark)}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new St(e.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,e){if("number"!=typeof e.pos)throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new St(e.pos,t.markFromJSON(e.mark))}}wt.jsonID("addNodeMark",St);class Tt extends wt{constructor(t,e){super(),this.pos=t,this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return kt.fail("No node at mark step's position");let n=e.type.create(e.attrs,null,this.mark.removeFromSet(e.marks));return kt.fromReplace(t,this.pos,this.pos+1,new f(a.from(n),0,e.isLeaf?0:1))}invert(t){let e=t.nodeAt(this.pos);return e&&this.mark.isInSet(e.marks)?new St(this.pos,this.mark):this}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new Tt(e.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,e){if("number"!=typeof e.pos)throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Tt(e.pos,t.markFromJSON(e.mark))}}wt.jsonID("removeNodeMark",Tt);class At extends wt{constructor(t,e,n,o=!1){super(),this.from=t,this.to=e,this.slice=n,this.structure=o}apply(t){return this.structure&&Et(t,this.from,this.to)?kt.fail("Structure replace would overwrite content"):kt.fromReplace(t,this.from,this.to,this.slice)}getMap(){return new yt([this.from,this.to-this.from,this.slice.size])}invert(t){return new At(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let e=t.mapResult(this.from,1),n=t.mapResult(this.to,-1);return e.deletedAcross&&n.deletedAcross?null:new At(e.pos,Math.max(e.pos,n.pos),this.slice)}merge(t){if(!(t instanceof At)||t.structure||this.structure)return null;if(this.from+this.slice.size!=t.from||this.slice.openEnd||t.slice.openStart){if(t.to!=this.from||this.slice.openStart||t.slice.openEnd)return null;{let e=this.slice.size+t.slice.size==0?f.empty:new f(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new At(t.from,this.to,e,this.structure)}}{let e=this.slice.size+t.slice.size==0?f.empty:new f(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new At(this.from,this.to+(t.to-t.from),e,this.structure)}}toJSON(){let t={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,e){if("number"!=typeof e.from||"number"!=typeof e.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new At(e.from,e.to,f.fromJSON(t,e.slice),!!e.structure)}}wt.jsonID("replace",At);class Ot extends wt{constructor(t,e,n,o,r,i,s=!1){super(),this.from=t,this.to=e,this.gapFrom=n,this.gapTo=o,this.slice=r,this.insert=i,this.structure=s}apply(t){if(this.structure&&(Et(t,this.from,this.gapFrom)||Et(t,this.gapTo,this.to)))return kt.fail("Structure gap-replace would overwrite content");let e=t.slice(this.gapFrom,this.gapTo);if(e.openStart||e.openEnd)return kt.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,e.content);return n?kt.fromReplace(t,this.from,this.to,n):kt.fail("Content does not fit in gap")}getMap(){return new yt([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let e=this.gapTo-this.gapFrom;return new Ot(this.from,this.from+this.slice.size+e,this.from+this.insert,this.from+this.insert+e,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let e=t.mapResult(this.from,1),n=t.mapResult(this.to,-1),o=this.from==this.gapFrom?e.pos:t.map(this.gapFrom,-1),r=this.to==this.gapTo?n.pos:t.map(this.gapTo,1);return e.deletedAcross&&n.deletedAcross||o<e.pos||r>n.pos?null:new Ot(e.pos,n.pos,o,r,this.slice,this.insert,this.structure)}toJSON(){let t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,e){if("number"!=typeof e.from||"number"!=typeof e.to||"number"!=typeof e.gapFrom||"number"!=typeof e.gapTo||"number"!=typeof e.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Ot(e.from,e.to,e.gapFrom,e.gapTo,f.fromJSON(t,e.slice),e.insert,!!e.structure)}}function Et(t,e,n){let o=t.resolve(e),r=n-e,i=o.depth;for(;r>0&&i>0&&o.indexAfter(i)==o.node(i).childCount;)i--,r--;if(r>0){let t=o.node(i).maybeChild(o.indexAfter(i));for(;r>0;){if(!t||t.isLeaf)return!0;t=t.firstChild,r--}}return!1}function Nt(t,e,n,o=n.contentMatch,r=!0){let i=t.doc.nodeAt(e),s=[],l=e+1;for(let e=0;e<i.childCount;e++){let c=i.child(e),d=l+c.nodeSize,h=o.matchType(c.type);if(h){o=h;for(let e=0;e<c.marks.length;e++)n.allowsMarkType(c.marks[e].type)||t.step(new Ct(l,d,c.marks[e]));if(r&&c.isText&&"pre"!=n.whitespace){let t,e,o=/\r?\n|\r/g;for(;t=o.exec(c.text);)e||(e=new f(a.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),s.push(new At(l+t.index,l+t.index+t[0].length,e))}}else s.push(new At(l,d,f.empty));l=d}if(!o.validEnd){let e=o.fillBefore(a.empty,!0);t.replace(l,l,new f(e,0,0))}for(let e=s.length-1;e>=0;e--)t.step(s[e])}function Dt(t,e,n){return(0==e||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Rt(t){let e=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let n=t.depth;;--n){let o=t.$from.node(n),r=t.$from.index(n),i=t.$to.indexAfter(n);if(n<t.depth&&o.canReplace(r,i,e))return n;if(0==n||o.type.spec.isolating||!Dt(o,r,i))break}return null}function jt(t,e,n=null,o=t){let r=function(t,e){let{parent:n,startIndex:o,endIndex:r}=t,i=n.contentMatchAt(o).findWrapping(e);if(!i)return null;let s=i.length?i[0]:e;return n.canReplaceWith(o,r,s)?i:null}(t,e),i=r&&function(t,e){let{parent:n,startIndex:o,endIndex:r}=t,i=n.child(o),s=e.contentMatch.findWrapping(i.type);if(!s)return null;let l=(s.length?s[s.length-1]:e).contentMatch;for(let t=o;l&&t<r;t++)l=l.matchType(n.child(t).type);return l&&l.validEnd?s:null}(o,e);return i?r.map(Lt).concat({type:e,attrs:n}).concat(i.map(Lt)):null}function Lt(t){return{type:t,attrs:null}}function It(t,e,n,o){e.forEach(((r,i)=>{if(r.isText){let s,l=/\r?\n|\r/g;for(;s=l.exec(r.text);){let r=t.mapping.slice(o).map(n+1+i+s.index);t.replaceWith(r,r+1,e.type.schema.linebreakReplacement.create())}}}))}function Pt(t,e,n,o){e.forEach(((r,i)=>{if(r.type==r.type.schema.linebreakReplacement){let r=t.mapping.slice(o).map(n+1+i);t.replaceWith(r,r+1,e.type.schema.text("\n"))}}))}function zt(t,e,n=1,o){let r=t.resolve(e),i=r.depth-n,s=o&&o[o.length-1]||r.parent;if(i<0||r.parent.type.spec.isolating||!r.parent.canReplace(r.index(),r.parent.childCount)||!s.type.validContent(r.parent.content.cutByIndex(r.index(),r.parent.childCount)))return!1;for(let t=r.depth-1,e=n-2;t>i;t--,e--){let n=r.node(t),i=r.index(t);if(n.type.spec.isolating)return!1;let s=n.content.cutByIndex(i,n.childCount),l=o&&o[e+1];l&&(s=s.replaceChild(0,l.type.create(l.attrs)));let a=o&&o[e]||n;if(!n.canReplace(i+1,n.childCount)||!a.type.validContent(s))return!1}let l=r.indexAfter(i),a=o&&o[0];return r.node(i).canReplaceWith(l,l,a?a.type:r.node(i+1).type)}function $t(t,e){let n=t.resolve(e),o=n.index();return Ht(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(o,o+1)}function Ht(t,e){return!(!t||!e||t.isLeaf||!function(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:o}=t.type.schema;for(let r=0;r<e.childCount;r++){let i=e.child(r),s=i.type==o?t.type.schema.nodes.text:i.type;if(n=n.matchType(s),!n)return!1;if(!t.type.allowsMarks(i.marks))return!1}return n.validEnd}(t,e))}function Bt(t,e,n=-1){let o=t.resolve(e);for(let t=o.depth;;t--){let r,i,s=o.index(t);if(t==o.depth?(r=o.nodeBefore,i=o.nodeAfter):n>0?(r=o.node(t+1),s++,i=o.node(t).maybeChild(s)):(r=o.node(t).maybeChild(s-1),i=o.node(t+1)),r&&!r.isTextblock&&Ht(r,i)&&o.node(t).canReplace(s,s+1))return e;if(0==t)break;e=n<0?o.before(t):o.after(t)}}function _t(t,e,n){let o=t.resolve(e);if(!n.content.size)return e;let r=n.content;for(let t=0;t<n.openStart;t++)r=r.firstChild.content;for(let t=1;t<=(0==n.openStart&&n.size?2:1);t++)for(let e=o.depth;e>=0;e--){let n=e==o.depth?0:o.pos<=(o.start(e+1)+o.end(e+1))/2?-1:1,i=o.index(e)+(n>0?1:0),s=o.node(e),l=!1;if(1==t)l=s.canReplace(i,i,r);else{let t=s.contentMatchAt(i).findWrapping(r.firstChild.type);l=t&&s.canReplaceWith(i,i,t[0])}if(l)return 0==n?o.pos:n<0?o.before(e+1):o.after(e+1)}return null}function Ft(t,e,n=e,o=f.empty){if(e==n&&!o.size)return null;let r=t.resolve(e),i=t.resolve(n);return Vt(r,i,o)?new At(e,n,o):new Wt(r,i,o).fit()}function Vt(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}wt.jsonID("replaceAround",Ot);class Wt{constructor(t,e,n){this.$from=t,this.$to=e,this.unplaced=n,this.frontier=[],this.placed=a.empty;for(let e=0;e<=t.depth;e++){let n=t.node(e);this.frontier.push({type:n.type,match:n.contentMatchAt(t.indexAfter(e))})}for(let e=t.depth;e>0;e--)this.placed=a.from(t.node(e).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let t=this.findFittable();t?this.placeNodes(t):this.openMore()||this.dropNode()}let t=this.mustMoveInline(),e=this.placed.size-this.depth-this.$from.depth,n=this.$from,o=this.close(t<0?this.$to:n.doc.resolve(t));if(!o)return null;let r=this.placed,i=n.depth,s=o.depth;for(;i&&s&&1==r.childCount;)r=r.firstChild.content,i--,s--;let l=new f(r,i,s);return t>-1?new Ot(n.pos,t,this.$to.pos,this.$to.end(),l,e):l.size||n.pos!=this.$to.pos?new At(n.pos,o.pos,l):null}findFittable(){let t=this.unplaced.openStart;for(let e=this.unplaced.content,n=0,o=this.unplaced.openEnd;n<t;n++){let r=e.firstChild;if(e.childCount>1&&(o=0),r.type.spec.isolating&&o<=n){t=n;break}e=r.content}for(let e=1;e<=2;e++)for(let n=1==e?t:this.unplaced.openStart;n>=0;n--){let t,o=null;n?(o=Jt(this.unplaced.content,n-1).firstChild,t=o.content):t=this.unplaced.content;let r=t.firstChild;for(let t=this.depth;t>=0;t--){let i,{type:s,match:l}=this.frontier[t],c=null;if(1==e&&(r?l.matchType(r.type)||(c=l.fillBefore(a.from(r),!1)):o&&s.compatibleContent(o.type)))return{sliceDepth:n,frontierDepth:t,parent:o,inject:c};if(2==e&&r&&(i=l.findWrapping(r.type)))return{sliceDepth:n,frontierDepth:t,parent:o,wrap:i};if(o&&l.matchType(o.type))break}}}openMore(){let{content:t,openStart:e,openEnd:n}=this.unplaced,o=Jt(t,e);return!(!o.childCount||o.firstChild.isLeaf||(this.unplaced=new f(t,e+1,Math.max(n,o.size+e>=t.size-n?e+1:0)),0))}dropNode(){let{content:t,openStart:e,openEnd:n}=this.unplaced,o=Jt(t,e);if(o.childCount<=1&&e>0){let r=t.size-e<=e+o.size;this.unplaced=new f(qt(t,e-1,1),e-1,r?e-1:n)}else this.unplaced=new f(qt(t,e,1),e,n)}placeNodes({sliceDepth:t,frontierDepth:e,parent:n,inject:o,wrap:r}){for(;this.depth>e;)this.closeFrontierNode();if(r)for(let t=0;t<r.length;t++)this.openFrontierNode(r[t]);let i=this.unplaced,s=n?n.content:i.content,l=i.openStart-t,c=0,d=[],{match:h,type:p}=this.frontier[e];if(o){for(let t=0;t<o.childCount;t++)d.push(o.child(t));h=h.matchFragment(o)}let u=s.size+t-(i.content.size-i.openEnd);for(;c<s.childCount;){let t=s.child(c),e=h.matchType(t.type);if(!e)break;c++,(c>1||0==l||t.content.size)&&(h=e,d.push(Ut(t.mark(p.allowedMarks(t.marks)),1==c?l:0,c==s.childCount?u:-1)))}let m=c==s.childCount;m||(u=-1),this.placed=Kt(this.placed,e,a.from(d)),this.frontier[e].match=h,m&&u<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let t=0,e=s;t<u;t++){let t=e.lastChild;this.frontier.push({type:t.type,match:t.contentMatchAt(t.childCount)}),e=t.content}this.unplaced=m?0==t?f.empty:new f(qt(i.content,t-1,1),t-1,u<0?i.openEnd:t-1):new f(qt(i.content,t,c),i.openStart,i.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let t,e=this.frontier[this.depth];if(!e.type.isTextblock||!Gt(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:n}=this.$to,o=this.$to.after(n);for(;n>1&&o==this.$to.end(--n);)++o;return o}findCloseLevel(t){t:for(let e=Math.min(this.depth,t.depth);e>=0;e--){let{match:n,type:o}=this.frontier[e],r=e<t.depth&&t.end(e+1)==t.pos+(t.depth-(e+1)),i=Gt(t,e,o,n,r);if(i){for(let n=e-1;n>=0;n--){let{match:e,type:o}=this.frontier[n],r=Gt(t,n,o,e,!0);if(!r||r.childCount)continue t}return{depth:e,fit:i,move:r?t.doc.resolve(t.after(e+1)):t}}}}close(t){let e=this.findCloseLevel(t);if(!e)return null;for(;this.depth>e.depth;)this.closeFrontierNode();e.fit.childCount&&(this.placed=Kt(this.placed,e.depth,e.fit)),t=e.move;for(let n=e.depth+1;n<=t.depth;n++){let e=t.node(n),o=e.type.contentMatch.fillBefore(e.content,!0,t.index(n));this.openFrontierNode(e.type,e.attrs,o)}return t}openFrontierNode(t,e=null,n){let o=this.frontier[this.depth];o.match=o.match.matchType(t),this.placed=Kt(this.placed,this.depth,a.from(t.create(e,n))),this.frontier.push({type:t,match:t.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(a.empty,!0);t.childCount&&(this.placed=Kt(this.placed,this.frontier.length,t))}}function qt(t,e,n){return 0==e?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(qt(t.firstChild.content,e-1,n)))}function Kt(t,e,n){return 0==e?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Kt(t.lastChild.content,e-1,n)))}function Jt(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function Ut(t,e,n){if(e<=0)return t;let o=t.content;return e>1&&(o=o.replaceChild(0,Ut(o.firstChild,e-1,1==o.childCount?n-1:0))),e>0&&(o=t.type.contentMatch.fillBefore(o).append(o),n<=0&&(o=o.append(t.type.contentMatch.matchFragment(o).fillBefore(a.empty,!0)))),t.copy(o)}function Gt(t,e,n,o,r){let i=t.node(e),s=r?t.indexAfter(e):t.index(e);if(s==i.childCount&&!n.compatibleContent(i.type))return null;let l=o.fillBefore(i.content,!0,s);return l&&!function(t,e,n){for(let o=n;o<e.childCount;o++)if(!t.allowsMarks(e.child(o).marks))return!0;return!1}(n,i.content,s)?l:null}function Yt(t,e,n,o,r){if(e<n){let r=t.firstChild;t=t.replaceChild(0,r.copy(Yt(r.content,e+1,n,o,r)))}if(e>o){let e=r.contentMatchAt(0),n=e.fillBefore(t).append(t);t=n.append(e.matchFragment(n).fillBefore(a.empty,!0))}return t}function Xt(t,e){let n=[];for(let o=Math.min(t.depth,e.depth);o>=0;o--){let r=t.start(o);if(r<t.pos-(t.depth-o)||e.end(o)>e.pos+(e.depth-o)||t.node(o).type.spec.isolating||e.node(o).type.spec.isolating)break;(r==e.start(o)||o==t.depth&&o==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&o&&e.start(o-1)==r-1)&&n.push(o)}return n}class Qt extends wt{constructor(t,e,n){super(),this.pos=t,this.attr=e,this.value=n}apply(t){let e=t.nodeAt(this.pos);if(!e)return kt.fail("No node at attribute step's position");let n=Object.create(null);for(let t in e.attrs)n[t]=e.attrs[t];n[this.attr]=this.value;let o=e.type.create(n,null,e.marks);return kt.fromReplace(t,this.pos,this.pos+1,new f(a.from(o),0,e.isLeaf?0:1))}getMap(){return yt.empty}invert(t){return new Qt(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new Qt(e.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,e){if("number"!=typeof e.pos||"string"!=typeof e.attr)throw new RangeError("Invalid input for AttrStep.fromJSON");return new Qt(e.pos,e.attr,e.value)}}wt.jsonID("attr",Qt);class Zt extends wt{constructor(t,e){super(),this.attr=t,this.value=e}apply(t){let e=Object.create(null);for(let n in t.attrs)e[n]=t.attrs[n];e[this.attr]=this.value;let n=t.type.create(e,t.content,t.marks);return kt.ok(n)}getMap(){return yt.empty}invert(t){return new Zt(this.attr,t.attrs[this.attr])}map(t){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(t,e){if("string"!=typeof e.attr)throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Zt(e.attr,e.value)}}wt.jsonID("docAttr",Zt);let te=class extends Error{};te=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n},(te.prototype=Object.create(Error.prototype)).constructor=te,te.prototype.name="TransformError";class ee{constructor(t){this.doc=t,this.steps=[],this.docs=[],this.mapping=new bt}get before(){return this.docs.length?this.docs[0]:this.doc}step(t){let e=this.maybeStep(t);if(e.failed)throw new te(e.failed);return this}maybeStep(t){let e=t.apply(this.doc);return e.failed||this.addStep(t,e.doc),e}get docChanged(){return this.steps.length>0}addStep(t,e){this.docs.push(this.doc),this.steps.push(t),this.mapping.appendMap(t.getMap()),this.doc=e}replace(t,e=t,n=f.empty){let o=Ft(this.doc,t,e,n);return o&&this.step(o),this}replaceWith(t,e,n){return this.replace(t,e,new f(a.from(n),0,0))}delete(t,e){return this.replace(t,e,f.empty)}insert(t,e){return this.replaceWith(t,t,e)}replaceRange(t,e,n){return function(t,e,n,o){if(!o.size)return t.deleteRange(e,n);let r=t.doc.resolve(e),i=t.doc.resolve(n);if(Vt(r,i,o))return t.step(new At(e,n,o));let s=Xt(r,t.doc.resolve(n));0==s[s.length-1]&&s.pop();let l=-(r.depth+1);s.unshift(l);for(let t=r.depth,e=r.pos-1;t>0;t--,e--){let n=r.node(t).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;s.indexOf(t)>-1?l=t:r.before(t)==e&&s.splice(1,0,-t)}let a=s.indexOf(l),c=[],d=o.openStart;for(let t=o.content,e=0;;e++){let n=t.firstChild;if(c.push(n),e==o.openStart)break;t=n.content}for(let t=d-1;t>=0;t--){let e=c[t],n=(h=e.type).spec.defining||h.spec.definingForContent;if(n&&!e.sameMarkup(r.node(Math.abs(l)-1)))d=t;else if(n||!e.type.isTextblock)break}var h;for(let e=o.openStart;e>=0;e--){let l=(e+d+1)%(o.openStart+1),h=c[l];if(h)for(let e=0;e<s.length;e++){let c=s[(e+a)%s.length],d=!0;c<0&&(d=!1,c=-c);let p=r.node(c-1),u=r.index(c-1);if(p.canReplaceWith(u,u,h.type,h.marks))return t.replace(r.before(c),d?i.after(c):n,new f(Yt(o.content,0,o.openStart,l),l,o.openEnd))}}let p=t.steps.length;for(let l=s.length-1;l>=0&&(t.replace(e,n,o),!(t.steps.length>p));l--){let t=s[l];t<0||(e=r.before(t),n=i.after(t))}}(this,t,e,n),this}replaceRangeWith(t,e,n){return function(t,e,n,o){if(!o.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let r=function(t,e,n){let o=t.resolve(e);if(o.parent.canReplaceWith(o.index(),o.index(),n))return e;if(0==o.parentOffset)for(let t=o.depth-1;t>=0;t--){let e=o.index(t);if(o.node(t).canReplaceWith(e,e,n))return o.before(t+1);if(e>0)return null}if(o.parentOffset==o.parent.content.size)for(let t=o.depth-1;t>=0;t--){let e=o.indexAfter(t);if(o.node(t).canReplaceWith(e,e,n))return o.after(t+1);if(e<o.node(t).childCount)return null}return null}(t.doc,e,o.type);null!=r&&(e=n=r)}t.replaceRange(e,n,new f(a.from(o),0,0))}(this,t,e,n),this}deleteRange(t,e){return function(t,e,n){let o=t.doc.resolve(e),r=t.doc.resolve(n),i=Xt(o,r);for(let e=0;e<i.length;e++){let n=i[e],s=e==i.length-1;if(s&&0==n||o.node(n).type.contentMatch.validEnd)return t.delete(o.start(n),r.end(n));if(n>0&&(s||o.node(n-1).canReplace(o.index(n-1),r.indexAfter(n-1))))return t.delete(o.before(n),r.after(n))}for(let i=1;i<=o.depth&&i<=r.depth;i++)if(e-o.start(i)==o.depth-i&&n>o.end(i)&&r.end(i)-n!=r.depth-i&&o.start(i-1)==r.start(i-1)&&o.node(i-1).canReplace(o.index(i-1),r.index(i-1)))return t.delete(o.before(i),n);t.delete(e,n)}(this,t,e),this}lift(t,e){return function(t,e,n){let{$from:o,$to:r,depth:i}=e,s=o.before(i+1),l=r.after(i+1),c=s,d=l,h=a.empty,p=0;for(let t=i,e=!1;t>n;t--)e||o.index(t)>0?(e=!0,h=a.from(o.node(t).copy(h)),p++):c--;let u=a.empty,m=0;for(let t=i,e=!1;t>n;t--)e||r.after(t+1)<r.end(t)?(e=!0,u=a.from(r.node(t).copy(u)),m++):d++;t.step(new Ot(c,d,s,l,new f(h.append(u),p,m),h.size-p,!0))}(this,t,e),this}join(t,e=1){return function(t,e,n){let o=null,{linebreakReplacement:r}=t.doc.type.schema,i=t.doc.resolve(e-n),s=i.node().type;if(r&&s.inlineContent){let t="pre"==s.whitespace,e=!!s.contentMatch.matchType(r);t&&!e?o=!1:!t&&e&&(o=!0)}let l=t.steps.length;if(!1===o){let o=t.doc.resolve(e+n);Pt(t,o.node(),o.before(),l)}s.inlineContent&&Nt(t,e+n-1,s,i.node().contentMatchAt(i.index()),null==o);let a=t.mapping.slice(l),c=a.map(e-n);if(t.step(new At(c,a.map(e+n,-1),f.empty,!0)),!0===o){let e=t.doc.resolve(c);It(t,e.node(),e.before(),t.steps.length)}}(this,t,e),this}wrap(t,e){return function(t,e,n){let o=a.empty;for(let t=n.length-1;t>=0;t--){if(o.size){let e=n[t].type.contentMatch.matchFragment(o);if(!e||!e.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}o=a.from(n[t].type.create(n[t].attrs,o))}let r=e.start,i=e.end;t.step(new Ot(r,i,r,i,new f(o,0,0),n.length,!0))}(this,t,e),this}setBlockType(t,e=t,n,o=null){return function(t,e,n,o,r){if(!o.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=t.steps.length;t.doc.nodesBetween(e,n,((e,n)=>{let s="function"==typeof r?r(e):r;if(e.isTextblock&&!e.hasMarkup(o,s)&&function(t,e,n){let o=t.resolve(e),r=o.index();return o.parent.canReplaceWith(r,r+1,n)}(t.doc,t.mapping.slice(i).map(n),o)){let r=null;if(o.schema.linebreakReplacement){let t="pre"==o.whitespace,e=!!o.contentMatch.matchType(o.schema.linebreakReplacement);t&&!e?r=!1:!t&&e&&(r=!0)}!1===r&&Pt(t,e,n,i),Nt(t,t.mapping.slice(i).map(n,1),o,void 0,null===r);let l=t.mapping.slice(i),c=l.map(n,1),d=l.map(n+e.nodeSize,1);return t.step(new Ot(c,d,c+1,d-1,new f(a.from(o.create(s,null,e.marks)),0,0),1,!0)),!0===r&&It(t,e,n,i),!1}}))}(this,t,e,n,o),this}setNodeMarkup(t,e,n=null,o){return function(t,e,n,o,r){let i=t.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");n||(n=i.type);let s=n.create(o,null,r||i.marks);if(i.isLeaf)return t.replaceWith(e,e+i.nodeSize,s);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new Ot(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new f(a.from(s),0,0),1,!0))}(this,t,e,n,o),this}setNodeAttribute(t,e,n){return this.step(new Qt(t,e,n)),this}setDocAttribute(t,e){return this.step(new Zt(t,e)),this}addNodeMark(t,e){return this.step(new St(t,e)),this}removeNodeMark(t,e){if(!(e instanceof p)){let n=this.doc.nodeAt(t);if(!n)throw new RangeError("No node at position "+t);if(!(e=e.isInSet(n.marks)))return this}return this.step(new Tt(t,e)),this}split(t,e=1,n){return function(t,e,n=1,o){let r=t.doc.resolve(e),i=a.empty,s=a.empty;for(let t=r.depth,e=r.depth-n,l=n-1;t>e;t--,l--){i=a.from(r.node(t).copy(i));let e=o&&o[l];s=a.from(e?e.type.create(e.attrs,s):r.node(t).copy(s))}t.step(new At(e,e,new f(i.append(s),n,n),!0))}(this,t,e,n),this}addMark(t,e,n){return function(t,e,n,o){let r,i,s=[],l=[];t.doc.nodesBetween(e,n,((t,a,c)=>{if(!t.isInline)return;let d=t.marks;if(!o.isInSet(d)&&c.type.allowsMarkType(o.type)){let c=Math.max(a,e),h=Math.min(a+t.nodeSize,n),p=o.addToSet(d);for(let t=0;t<d.length;t++)d[t].isInSet(p)||(r&&r.to==c&&r.mark.eq(d[t])?r.to=h:s.push(r=new Ct(c,h,d[t])));i&&i.to==c?i.to=h:l.push(i=new Mt(c,h,o))}})),s.forEach((e=>t.step(e))),l.forEach((e=>t.step(e)))}(this,t,e,n),this}removeMark(t,e,n){return function(t,e,n,o){let r=[],i=0;t.doc.nodesBetween(e,n,((t,s)=>{if(!t.isInline)return;i++;let l=null;if(o instanceof Y){let e,n=t.marks;for(;e=o.isInSet(n);)(l||(l=[])).push(e),n=e.removeFromSet(n)}else o?o.isInSet(t.marks)&&(l=[o]):l=t.marks;if(l&&l.length){let o=Math.min(s+t.nodeSize,n);for(let t=0;t<l.length;t++){let n,a=l[t];for(let t=0;t<r.length;t++){let e=r[t];e.step==i-1&&a.eq(r[t].style)&&(n=e)}n?(n.to=o,n.step=i):r.push({style:a,from:Math.max(s,e),to:o,step:i})}}})),r.forEach((e=>t.step(new Ct(e.from,e.to,e.style))))}(this,t,e,n),this}clearIncompatible(t,e,n){return Nt(this,t,e,n),this}}const ne=Object.create(null);class oe{constructor(t,e,n){this.$anchor=t,this.$head=e,this.ranges=n||[new re(t.min(e),t.max(e))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let t=this.ranges;for(let e=0;e<t.length;e++)if(t[e].$from.pos!=t[e].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(t,e=f.empty){let n=e.content.lastChild,o=null;for(let t=0;t<e.openEnd;t++)o=n,n=n.lastChild;let r=t.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:l,$to:a}=i[s],c=t.mapping.slice(r);t.replaceRange(c.map(l.pos),c.map(a.pos),s?f.empty:e),0==s&&fe(t,r,(n?n.isInline:o&&o.isTextblock)?-1:1)}}replaceWith(t,e){let n=t.steps.length,o=this.ranges;for(let r=0;r<o.length;r++){let{$from:i,$to:s}=o[r],l=t.mapping.slice(n),a=l.map(i.pos),c=l.map(s.pos);r?t.deleteRange(a,c):(t.replaceRangeWith(a,c,e),fe(t,n,e.isInline?-1:1))}}static findFrom(t,e,n=!1){let o=t.parent.inlineContent?new le(t):ue(t.node(0),t.parent,t.pos,t.index(),e,n);if(o)return o;for(let o=t.depth-1;o>=0;o--){let r=e<0?ue(t.node(0),t.node(o),t.before(o+1),t.index(o),e,n):ue(t.node(0),t.node(o),t.after(o+1),t.index(o)+1,e,n);if(r)return r}return null}static near(t,e=1){return this.findFrom(t,e)||this.findFrom(t,-e)||new he(t.node(0))}static atStart(t){return ue(t,t,0,0,1)||new he(t)}static atEnd(t){return ue(t,t,t.content.size,t.childCount,-1)||new he(t)}static fromJSON(t,e){if(!e||!e.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=ne[e.type];if(!n)throw new RangeError(`No selection type ${e.type} defined`);return n.fromJSON(t,e)}static jsonID(t,e){if(t in ne)throw new RangeError("Duplicate use of selection JSON ID "+t);return ne[t]=e,e.prototype.jsonID=t,e}getBookmark(){return le.between(this.$anchor,this.$head).getBookmark()}}oe.prototype.visible=!0;class re{constructor(t,e){this.$from=t,this.$to=e}}let ie=!1;function se(t){ie||t.parent.inlineContent||(ie=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class le extends oe{constructor(t,e=t){se(t),se(e),super(t,e)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,e){let n=t.resolve(e.map(this.head));if(!n.parent.inlineContent)return oe.near(n);let o=t.resolve(e.map(this.anchor));return new le(o.parent.inlineContent?o:n,n)}replace(t,e=f.empty){if(super.replace(t,e),e==f.empty){let e=this.$from.marksAcross(this.$to);e&&t.ensureMarks(e)}}eq(t){return t instanceof le&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new ae(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(t,e){if("number"!=typeof e.anchor||"number"!=typeof e.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new le(t.resolve(e.anchor),t.resolve(e.head))}static create(t,e,n=e){let o=t.resolve(e);return new this(o,n==e?o:t.resolve(n))}static between(t,e,n){let o=t.pos-e.pos;if(n&&!o||(n=o>=0?1:-1),!e.parent.inlineContent){let t=oe.findFrom(e,n,!0)||oe.findFrom(e,-n,!0);if(!t)return oe.near(e,n);e=t.$head}return t.parent.inlineContent||(0==o||(t=(oe.findFrom(t,-n,!0)||oe.findFrom(t,n,!0)).$anchor).pos<e.pos!=o<0)&&(t=e),new le(t,e)}}oe.jsonID("text",le);class ae{constructor(t,e){this.anchor=t,this.head=e}map(t){return new ae(t.map(this.anchor),t.map(this.head))}resolve(t){return le.between(t.resolve(this.anchor),t.resolve(this.head))}}class ce extends oe{constructor(t){let e=t.nodeAfter,n=t.node(0).resolve(t.pos+e.nodeSize);super(t,n),this.node=e}map(t,e){let{deleted:n,pos:o}=e.mapResult(this.anchor),r=t.resolve(o);return n?oe.near(r):new ce(r)}content(){return new f(a.from(this.node),0,0)}eq(t){return t instanceof ce&&t.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new de(this.anchor)}static fromJSON(t,e){if("number"!=typeof e.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new ce(t.resolve(e.anchor))}static create(t,e){return new ce(t.resolve(e))}static isSelectable(t){return!t.isText&&!1!==t.type.spec.selectable}}ce.prototype.visible=!1,oe.jsonID("node",ce);class de{constructor(t){this.anchor=t}map(t){let{deleted:e,pos:n}=t.mapResult(this.anchor);return e?new ae(n,n):new de(n)}resolve(t){let e=t.resolve(this.anchor),n=e.nodeAfter;return n&&ce.isSelectable(n)?new ce(e):oe.near(e)}}class he extends oe{constructor(t){super(t.resolve(0),t.resolve(t.content.size))}replace(t,e=f.empty){if(e==f.empty){t.delete(0,t.doc.content.size);let e=oe.atStart(t.doc);e.eq(t.selection)||t.setSelection(e)}else super.replace(t,e)}toJSON(){return{type:"all"}}static fromJSON(t){return new he(t)}map(t){return new he(t)}eq(t){return t instanceof he}getBookmark(){return pe}}oe.jsonID("all",he);const pe={map(){return this},resolve:t=>new he(t)};function ue(t,e,n,o,r,i=!1){if(e.inlineContent)return le.create(t,n);for(let s=o-(r>0?0:1);r>0?s<e.childCount:s>=0;s+=r){let o=e.child(s);if(o.isAtom){if(!i&&ce.isSelectable(o))return ce.create(t,n-(r<0?o.nodeSize:0))}else{let e=ue(t,o,n+r,r<0?o.childCount:0,r,i);if(e)return e}n+=o.nodeSize*r}return null}function fe(t,e,n){let o=t.steps.length-1;if(o<e)return;let r,i=t.steps[o];(i instanceof At||i instanceof Ot)&&(t.mapping.maps[o].forEach(((t,e,n,o)=>{null==r&&(r=o)})),t.setSelection(oe.near(t.doc.resolve(r),n)))}class me extends ee{constructor(t){super(t.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=t.selection,this.storedMarks=t.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(t){if(t.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=t,this.curSelectionFor=this.steps.length,this.updated=-3&this.updated|1,this.storedMarks=null,this}get selectionSet(){return(1&this.updated)>0}setStoredMarks(t){return this.storedMarks=t,this.updated|=2,this}ensureMarks(t){return p.sameSet(this.storedMarks||this.selection.$from.marks(),t)||this.setStoredMarks(t),this}addStoredMark(t){return this.ensureMarks(t.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(t){return this.ensureMarks(t.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(2&this.updated)>0}addStep(t,e){super.addStep(t,e),this.updated=-3&this.updated,this.storedMarks=null}setTime(t){return this.time=t,this}replaceSelection(t){return this.selection.replace(this,t),this}replaceSelectionWith(t,e=!0){let n=this.selection;return e&&(t=t.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||p.none))),n.replaceWith(this,t),this}deleteSelection(){return this.selection.replace(this),this}insertText(t,e,n){let o=this.doc.type.schema;if(null==e)return t?this.replaceSelectionWith(o.text(t),!0):this.deleteSelection();{if(null==n&&(n=e),n=null==n?e:n,!t)return this.deleteRange(e,n);let r=this.storedMarks;if(!r){let t=this.doc.resolve(e);r=n==e?t.marks():t.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(e,n,o.text(t,r)),this.selection.empty||this.setSelection(oe.near(this.selection.$to)),this}}setMeta(t,e){return this.meta["string"==typeof t?t:t.key]=e,this}getMeta(t){return this.meta["string"==typeof t?t:t.key]}get isGeneric(){for(let t in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=4,this}get scrolledIntoView(){return(4&this.updated)>0}}function ge(t,e){return e&&t?t.bind(e):t}class ye{constructor(t,e,n){this.name=t,this.init=ge(e.init,n),this.apply=ge(e.apply,n)}}const be=[new ye("doc",{init:t=>t.doc||t.schema.topNodeType.createAndFill(),apply:t=>t.doc}),new ye("selection",{init:(t,e)=>t.selection||oe.atStart(e.doc),apply:t=>t.selection}),new ye("storedMarks",{init:t=>t.storedMarks||null,apply:(t,e,n,o)=>o.selection.$cursor?t.storedMarks:null}),new ye("scrollToSelection",{init:()=>0,apply:(t,e)=>t.scrolledIntoView?e+1:e})];class ve{constructor(t,e){this.schema=t,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=be.slice(),e&&e.forEach((t=>{if(this.pluginsByKey[t.key])throw new RangeError("Adding different instances of a keyed plugin ("+t.key+")");this.plugins.push(t),this.pluginsByKey[t.key]=t,t.spec.state&&this.fields.push(new ye(t.key,t.spec.state,t))}))}}class we{constructor(t){this.config=t}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(t){return this.applyTransaction(t).state}filterTransaction(t,e=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=e){let e=this.config.plugins[n];if(e.spec.filterTransaction&&!e.spec.filterTransaction.call(e,t,this))return!1}return!0}applyTransaction(t){if(!this.filterTransaction(t))return{state:this,transactions:[]};let e=[t],n=this.applyInner(t),o=null;for(;;){let r=!1;for(let i=0;i<this.config.plugins.length;i++){let s=this.config.plugins[i];if(s.spec.appendTransaction){let l=o?o[i].n:0,a=o?o[i].state:this,c=l<e.length&&s.spec.appendTransaction.call(s,l?e.slice(l):e,a,n);if(c&&n.filterTransaction(c,i)){if(c.setMeta("appendedTransaction",t),!o){o=[];for(let t=0;t<this.config.plugins.length;t++)o.push(t<i?{state:n,n:e.length}:{state:this,n:0})}e.push(c),n=n.applyInner(c),r=!0}o&&(o[i]={state:n,n:e.length})}}if(!r)return{state:n,transactions:e}}}applyInner(t){if(!t.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let e=new we(this.config),n=this.config.fields;for(let o=0;o<n.length;o++){let r=n[o];e[r.name]=r.apply(t,this[r.name],this,e)}return e}get tr(){return new me(this)}static create(t){let e=new ve(t.doc?t.doc.type.schema:t.schema,t.plugins),n=new we(e);for(let o=0;o<e.fields.length;o++)n[e.fields[o].name]=e.fields[o].init(t,n);return n}reconfigure(t){let e=new ve(this.schema,t.plugins),n=e.fields,o=new we(e);for(let e=0;e<n.length;e++){let r=n[e].name;o[r]=this.hasOwnProperty(r)?this[r]:n[e].init(t,o)}return o}toJSON(t){let e={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(e.storedMarks=this.storedMarks.map((t=>t.toJSON()))),t&&"object"==typeof t)for(let n in t){if("doc"==n||"selection"==n)throw new RangeError("The JSON fields `doc` and `selection` are reserved");let o=t[n],r=o.spec.state;r&&r.toJSON&&(e[n]=r.toJSON.call(o,this[o.key]))}return e}static fromJSON(t,e,n){if(!e)throw new RangeError("Invalid input for EditorState.fromJSON");if(!t.schema)throw new RangeError("Required config field 'schema' missing");let o=new ve(t.schema,t.plugins),r=new we(o);return o.fields.forEach((o=>{if("doc"==o.name)r.doc=R.fromJSON(t.schema,e.doc);else if("selection"==o.name)r.selection=oe.fromJSON(r.doc,e.selection);else if("storedMarks"==o.name)e.storedMarks&&(r.storedMarks=e.storedMarks.map(t.schema.markFromJSON));else{if(n)for(let i in n){let s=n[i],l=s.spec.state;if(s.key==o.name&&l&&l.fromJSON&&Object.prototype.hasOwnProperty.call(e,i))return void(r[o.name]=l.fromJSON.call(s,t,e[i],r))}r[o.name]=o.init(t,r)}})),r}}function ke(t,e,n){for(let o in t){let r=t[o];r instanceof Function?r=r.bind(e):"handleDOMEvents"==o&&(r=ke(r,e,{})),n[o]=r}return n}class xe{constructor(t){this.spec=t,this.props={},t.props&&ke(t.props,this,this.props),this.key=t.key?t.key.key:Ce("plugin")}getState(t){return t[this.key]}}const Me=Object.create(null);function Ce(t){return t in Me?t+"$"+ ++Me[t]:(Me[t]=0,t+"$")}class Se{constructor(t="key"){this.key=Ce(t)}get(t){return t.config.pluginsByKey[this.key]}getState(t){return t[this.key]}}const Te=function(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e},Ae=function(t){let e=t.assignedSlot||t.parentNode;return e&&11==e.nodeType?e.host:e};let Oe=null;const Ee=function(t,e,n){let o=Oe||(Oe=document.createRange());return o.setEnd(t,null==n?t.nodeValue.length:n),o.setStart(t,e||0),o},Ne=function(t,e,n,o){return n&&(Re(t,e,n,o,-1)||Re(t,e,n,o,1))},De=/^(img|br|input|textarea|hr)$/i;function Re(t,e,n,o,r){for(;;){if(t==n&&e==o)return!0;if(e==(r<0?0:je(t))){let n=t.parentNode;if(!n||1!=n.nodeType||Le(t)||De.test(t.nodeName)||"false"==t.contentEditable)return!1;e=Te(t)+(r<0?0:1),t=n}else{if(1!=t.nodeType)return!1;if("false"==(t=t.childNodes[e+(r<0?-1:0)]).contentEditable)return!1;e=r<0?je(t):0}}}function je(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function Le(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const Ie=function(t){return t.focusNode&&Ne(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Pe(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}const ze="undefined"!=typeof navigator?navigator:null,$e="undefined"!=typeof document?document:null,He=ze&&ze.userAgent||"",Be=/Edge\/(\d+)/.exec(He),_e=/MSIE \d/.exec(He),Fe=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(He),Ve=!!(_e||Fe||Be),We=_e?document.documentMode:Fe?+Fe[1]:Be?+Be[1]:0,qe=!Ve&&/gecko\/(\d+)/i.test(He);qe&&(/Firefox\/(\d+)/.exec(He)||[0,0])[1];const Ke=!Ve&&/Chrome\/(\d+)/.exec(He),Je=!!Ke,Ue=Ke?+Ke[1]:0,Ge=!Ve&&!!ze&&/Apple Computer/.test(ze.vendor),Ye=Ge&&(/Mobile\/\w+/.test(He)||!!ze&&ze.maxTouchPoints>2),Xe=Ye||!!ze&&/Mac/.test(ze.platform),Qe=!!ze&&/Win/.test(ze.platform),Ze=/Android \d/.test(He),tn=!!$e&&"webkitFontSmoothing"in $e.documentElement.style,en=tn?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function nn(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 on(t,e){return"number"==typeof t?t:t[e]}function rn(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,o=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*o}}function sn(t,e,n){let o=t.someProp("scrollThreshold")||0,r=t.someProp("scrollMargin")||5,i=t.dom.ownerDocument;for(let s=n||t.dom;s;){if(1!=s.nodeType){s=Ae(s);continue}let t=s,n=t==i.body,l=n?nn(i):rn(t),a=0,c=0;if(e.top<l.top+on(o,"top")?c=-(l.top-e.top+on(r,"top")):e.bottom>l.bottom-on(o,"bottom")&&(c=e.bottom-e.top>l.bottom-l.top?e.top+on(r,"top")-l.top:e.bottom-l.bottom+on(r,"bottom")),e.left<l.left+on(o,"left")?a=-(l.left-e.left+on(r,"left")):e.right>l.right-on(o,"right")&&(a=e.right-l.right+on(r,"right")),a||c)if(n)i.defaultView.scrollBy(a,c);else{let n=t.scrollLeft,o=t.scrollTop;c&&(t.scrollTop+=c),a&&(t.scrollLeft+=a);let r=t.scrollLeft-n,i=t.scrollTop-o;e={left:e.left-r,top:e.top-i,right:e.right-r,bottom:e.bottom-i}}let d=n?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(d))break;s="absolute"==d?s.offsetParent:Ae(s)}}function ln(t){let e=[],n=t.ownerDocument;for(let o=t;o&&(e.push({dom:o,top:o.scrollTop,left:o.scrollLeft}),t!=n);o=Ae(o));return e}function an(t,e){for(let n=0;n<t.length;n++){let{dom:o,top:r,left:i}=t[n];o.scrollTop!=r+e&&(o.scrollTop=r+e),o.scrollLeft!=i&&(o.scrollLeft=i)}}let cn=null;function dn(t,e){let n,o,r,i,s=2e8,l=0,a=e.top,c=e.top;for(let d=t.firstChild,h=0;d;d=d.nextSibling,h++){let t;if(1==d.nodeType)t=d.getClientRects();else{if(3!=d.nodeType)continue;t=Ee(d).getClientRects()}for(let p=0;p<t.length;p++){let u=t[p];if(u.top<=a&&u.bottom>=c){a=Math.max(u.bottom,a),c=Math.min(u.top,c);let t=u.left>e.left?u.left-e.left:u.right<e.left?e.left-u.right:0;if(t<s){n=d,s=t,o=t&&3==n.nodeType?{left:u.right<e.left?u.right:u.left,top:e.top}:e,1==d.nodeType&&t&&(l=h+(e.left>=(u.left+u.right)/2?1:0));continue}}else u.top>e.top&&!r&&u.left<=e.left&&u.right>=e.left&&(r=d,i={left:Math.max(u.left,Math.min(u.right,e.left)),top:u.top});!n&&(e.left>=u.right&&e.top>=u.top||e.left>=u.left&&e.top>=u.bottom)&&(l=h+1)}}return!n&&r&&(n=r,o=i,s=0),n&&3==n.nodeType?function(t,e){let n=t.nodeValue.length,o=document.createRange();for(let r=0;r<n;r++){o.setEnd(t,r+1),o.setStart(t,r);let n=mn(o,1);if(n.top!=n.bottom&&hn(e,n))return{node:t,offset:r+(e.left>=(n.left+n.right)/2?1:0)}}return{node:t,offset:0}}(n,o):!n||s&&1==n.nodeType?{node:t,offset:l}:dn(n,o)}function hn(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function pn(t,e,n){let o=t.childNodes.length;if(o&&n.top<n.bottom)for(let r=Math.max(0,Math.min(o-1,Math.floor(o*(e.top-n.top)/(n.bottom-n.top))-2)),i=r;;){let n=t.childNodes[i];if(1==n.nodeType){let t=n.getClientRects();for(let o=0;o<t.length;o++){let r=t[o];if(hn(e,r))return pn(n,e,r)}}if((i=(i+1)%o)==r)break}return t}function un(t,e){let n,o=t.dom.ownerDocument,r=0,i=function(t,e,n){if(t.caretPositionFromPoint)try{let o=t.caretPositionFromPoint(e,n);if(o)return{node:o.offsetNode,offset:Math.min(je(o.offsetNode),o.offset)}}catch(t){}if(t.caretRangeFromPoint){let o=t.caretRangeFromPoint(e,n);if(o)return{node:o.startContainer,offset:Math.min(je(o.startContainer),o.startOffset)}}}(o,e.left,e.top);i&&({node:n,offset:r}=i);let s,l=(t.root.elementFromPoint?t.root:o).elementFromPoint(e.left,e.top);if(!l||!t.dom.contains(1!=l.nodeType?l.parentNode:l)){let n=t.dom.getBoundingClientRect();if(!hn(e,n))return null;if(l=pn(t.dom,e,n),!l)return null}if(Ge)for(let t=l;n&&t;t=Ae(t))t.draggable&&(n=void 0);if(l=function(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}(l,e),n){if(qe&&1==n.nodeType&&(r=Math.min(r,n.childNodes.length),r<n.childNodes.length)){let t,o=n.childNodes[r];"IMG"==o.nodeName&&(t=o.getBoundingClientRect()).right<=e.left&&t.bottom>e.top&&r++}let o;tn&&r&&1==n.nodeType&&1==(o=n.childNodes[r-1]).nodeType&&"false"==o.contentEditable&&o.getBoundingClientRect().top>=e.top&&r--,n==t.dom&&r==n.childNodes.length-1&&1==n.lastChild.nodeType&&e.top>n.lastChild.getBoundingClientRect().bottom?s=t.state.doc.content.size:0!=r&&1==n.nodeType&&"BR"==n.childNodes[r-1].nodeName||(s=function(t,e,n,o){let r=-1;for(let n=e,i=!1;n!=t.dom;){let e,s=t.docView.nearestDesc(n,!0);if(!s)return null;if(1==s.dom.nodeType&&(s.node.isBlock&&s.parent||!s.contentDOM)&&((e=s.dom.getBoundingClientRect()).width||e.height)&&(s.node.isBlock&&s.parent&&(!i&&e.left>o.left||e.top>o.top?r=s.posBefore:(!i&&e.right<o.left||e.bottom<o.top)&&(r=s.posAfter),i=!0),!s.contentDOM&&r<0&&!s.node.isText))return(s.node.isBlock?o.top<(e.top+e.bottom)/2:o.left<(e.left+e.right)/2)?s.posBefore:s.posAfter;n=s.dom.parentNode}return r>-1?r:t.docView.posFromDOM(e,n,-1)}(t,n,r,e))}null==s&&(s=function(t,e,n){let{node:o,offset:r}=dn(e,n),i=-1;if(1==o.nodeType&&!o.firstChild){let t=o.getBoundingClientRect();i=t.left!=t.right&&n.left>(t.left+t.right)/2?1:-1}return t.docView.posFromDOM(o,r,i)}(t,l,e));let a=t.docView.nearestDesc(l,!0);return{pos:s,inside:a?a.posAtStart-a.border:-1}}function fn(t){return t.top<t.bottom||t.left<t.right}function mn(t,e){let n=t.getClientRects();if(n.length){let t=n[e<0?0:n.length-1];if(fn(t))return t}return Array.prototype.find.call(n,fn)||t.getBoundingClientRect()}const gn=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function yn(t,e,n){let{node:o,offset:r,atom:i}=t.docView.domFromPos(e,n<0?-1:1),s=tn||qe;if(3==o.nodeType){if(!s||!gn.test(o.nodeValue)&&(n<0?r:r!=o.nodeValue.length)){let t=r,e=r,i=n<0?1:-1;return n<0&&!r?(e++,i=-1):n>=0&&r==o.nodeValue.length?(t--,i=1):n<0?t--:e++,bn(mn(Ee(o,t,e),i),i<0)}{let t=mn(Ee(o,r,r),n);if(qe&&r&&/\s/.test(o.nodeValue[r-1])&&r<o.nodeValue.length){let e=mn(Ee(o,r-1,r-1),-1);if(e.top==t.top){let n=mn(Ee(o,r,r+1),-1);if(n.top!=t.top)return bn(n,n.left<e.left)}}return t}}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(null==i&&r&&(n<0||r==je(o))){let t=o.childNodes[r-1];if(1==t.nodeType)return vn(t.getBoundingClientRect(),!1)}if(null==i&&r<je(o)){let t=o.childNodes[r];if(1==t.nodeType)return vn(t.getBoundingClientRect(),!0)}return vn(o.getBoundingClientRect(),n>=0)}if(null==i&&r&&(n<0||r==je(o))){let t=o.childNodes[r-1],e=3==t.nodeType?Ee(t,je(t)-(s?0:1)):1!=t.nodeType||"BR"==t.nodeName&&t.nextSibling?null:t;if(e)return bn(mn(e,1),!1)}if(null==i&&r<je(o)){let t=o.childNodes[r];for(;t.pmViewDesc&&t.pmViewDesc.ignoreForCoords;)t=t.nextSibling;let e=t?3==t.nodeType?Ee(t,0,s?0:1):1==t.nodeType?t:null:null;if(e)return bn(mn(e,-1),!0)}return bn(mn(3==o.nodeType?Ee(o):o,-n),n>=0)}function bn(t,e){if(0==t.width)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function vn(t,e){if(0==t.height)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function wn(t,e,n){let o=t.state,r=t.root.activeElement;o!=e&&t.updateState(e),r!=t.dom&&t.focus();try{return n()}finally{o!=e&&t.updateState(o),r!=t.dom&&r&&r.focus()}}const kn=/[\u0590-\u08ac]/;let xn=null,Mn=null,Cn=!1;class Sn{constructor(t,e,n,o){this.parent=t,this.children=e,this.dom=n,this.contentDOM=o,this.dirty=0,n.pmViewDesc=this}matchesWidget(t){return!1}matchesMark(t){return!1}matchesNode(t,e,n){return!1}matchesHack(t){return!1}parseRule(){return null}stopEvent(t){return!1}get size(){let t=0;for(let e=0;e<this.children.length;e++)t+=this.children[e].size;return t}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let t=0;t<this.children.length;t++)this.children[t].destroy()}posBeforeChild(t){for(let e=0,n=this.posAtStart;;e++){let o=this.children[e];if(o==t)return n;n+=o.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(t,e,n){if(this.contentDOM&&this.contentDOM.contains(1==t.nodeType?t:t.parentNode)){if(n<0){let n,o;if(t==this.contentDOM)n=t.childNodes[e-1];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;n=t.previousSibling}for(;n&&(!(o=n.pmViewDesc)||o.parent!=this);)n=n.previousSibling;return n?this.posBeforeChild(o)+o.size:this.posAtStart}{let n,o;if(t==this.contentDOM)n=t.childNodes[e];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;n=t.nextSibling}for(;n&&(!(o=n.pmViewDesc)||o.parent!=this);)n=n.nextSibling;return n?this.posBeforeChild(o):this.posAtEnd}}let o;if(t==this.dom&&this.contentDOM)o=e>Te(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))o=2&t.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==e)for(let e=t;;e=e.parentNode){if(e==this.dom){o=!1;break}if(e.previousSibling)break}if(null==o&&e==t.childNodes.length)for(let e=t;;e=e.parentNode){if(e==this.dom){o=!0;break}if(e.nextSibling)break}}return(null==o?n>0:o)?this.posAtEnd:this.posAtStart}nearestDesc(t,e=!1){for(let n=!0,o=t;o;o=o.parentNode){let r,i=this.getDesc(o);if(i&&(!e||i.node)){if(!n||!(r=i.nodeDOM)||(1==r.nodeType?r.contains(1==t.nodeType?t:t.parentNode):r==t))return i;n=!1}}}getDesc(t){let e=t.pmViewDesc;for(let t=e;t;t=t.parent)if(t==this)return e}posFromDOM(t,e,n){for(let o=t;o;o=o.parentNode){let r=this.getDesc(o);if(r)return r.localPosFromDOM(t,e,n)}return-1}descAt(t){for(let e=0,n=0;e<this.children.length;e++){let o=this.children[e],r=n+o.size;if(n==t&&r!=n){for(;!o.border&&o.children.length;)for(let t=0;t<o.children.length;t++){let e=o.children[t];if(e.size){o=e;break}}return o}if(t<r)return o.descAt(t-n-o.border);n=r}}domFromPos(t,e){if(!this.contentDOM)return{node:this.dom,offset:0,atom:t+1};let n=0,o=0;for(let e=0;n<this.children.length;n++){let r=this.children[n],i=e+r.size;if(i>t||r instanceof Rn){o=t-e;break}e=i}if(o)return this.children[n].domFromPos(o-this.children[n].border,e);for(let t;n&&!(t=this.children[n-1]).size&&t instanceof Tn&&t.side>=0;n--);if(e<=0){let t,o=!0;for(;t=n?this.children[n-1]:null,t&&t.dom.parentNode!=this.contentDOM;n--,o=!1);return t&&e&&o&&!t.border&&!t.domAtom?t.domFromPos(t.size,e):{node:this.contentDOM,offset:t?Te(t.dom)+1:0}}{let t,o=!0;for(;t=n<this.children.length?this.children[n]:null,t&&t.dom.parentNode!=this.contentDOM;n++,o=!1);return t&&o&&!t.border&&!t.domAtom?t.domFromPos(0,e):{node:this.contentDOM,offset:t?Te(t.dom):this.contentDOM.childNodes.length}}}parseRange(t,e,n=0){if(0==this.children.length)return{node:this.contentDOM,from:t,to:e,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let o=-1,r=-1;for(let i=n,s=0;;s++){let n=this.children[s],l=i+n.size;if(-1==o&&t<=l){let r=i+n.border;if(t>=r&&e<=l-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(t,e,r);t=i;for(let e=s;e>0;e--){let n=this.children[e-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){o=Te(n.dom)+1;break}t-=n.size}-1==o&&(o=0)}if(o>-1&&(l>e||s==this.children.length-1)){e=l;for(let t=s+1;t<this.children.length;t++){let n=this.children[t];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(-1)){r=Te(n.dom);break}e+=n.size}-1==r&&(r=this.contentDOM.childNodes.length);break}i=l}return{node:this.contentDOM,from:t,to:e,fromOffset:o,toOffset:r}}emptyChildAt(t){if(this.border||!this.contentDOM||!this.children.length)return!1;let e=this.children[t<0?0:this.children.length-1];return 0==e.size||e.emptyChildAt(t)}domAfterPos(t){let{node:e,offset:n}=this.domFromPos(t,0);if(1!=e.nodeType||n==e.childNodes.length)throw new RangeError("No node after pos "+t);return e.childNodes[n]}setSelection(t,e,n,o=!1){let r=Math.min(t,e),i=Math.max(t,e);for(let s=0,l=0;s<this.children.length;s++){let a=this.children[s],c=l+a.size;if(r>l&&i<c)return a.setSelection(t-l-a.border,e-l-a.border,n,o);l=c}let s=this.domFromPos(t,t?-1:1),l=e==t?s:this.domFromPos(e,e?-1:1),a=n.root.getSelection(),c=n.domSelectionRange(),d=!1;if((qe||Ge)&&t==e){let{node:t,offset:e}=s;if(3==t.nodeType){if(d=!(!e||"\n"!=t.nodeValue[e-1]),d&&e==t.nodeValue.length)for(let e,n=t;n;n=n.parentNode){if(e=n.nextSibling){"BR"==e.nodeName&&(s=l={node:e.parentNode,offset:Te(e)+1});break}let t=n.pmViewDesc;if(t&&t.node&&t.node.isBlock)break}}else{let n=t.childNodes[e-1];d=n&&("BR"==n.nodeName||"false"==n.contentEditable)}}if(qe&&c.focusNode&&c.focusNode!=l.node&&1==c.focusNode.nodeType){let t=c.focusNode.childNodes[c.focusOffset];t&&"false"==t.contentEditable&&(o=!0)}if(!(o||d&&Ge)&&Ne(s.node,s.offset,c.anchorNode,c.anchorOffset)&&Ne(l.node,l.offset,c.focusNode,c.focusOffset))return;let h=!1;if((a.extend||t==e)&&!d){a.collapse(s.node,s.offset);try{t!=e&&a.extend(l.node,l.offset),h=!0}catch(t){}}if(!h){if(t>e){let t=s;s=l,l=t}let n=document.createRange();n.setEnd(l.node,l.offset),n.setStart(s.node,s.offset),a.removeAllRanges(),a.addRange(n)}}ignoreMutation(t){return!this.contentDOM&&"selection"!=t.type}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(t,e){for(let n=0,o=0;o<this.children.length;o++){let r=this.children[o],i=n+r.size;if(n==i?t<=i&&e>=n:t<i&&e>n){let o=n+r.border,s=i-r.border;if(t>=o&&e<=s)return this.dirty=t==n||e==i?2:1,void(t!=o||e!=s||!r.contentLost&&r.dom.parentNode==this.contentDOM?r.markDirty(t-o,e-o):r.dirty=3);r.dirty=r.dom!=r.contentDOM||r.dom.parentNode!=this.contentDOM||r.children.length?3:2}n=i}this.dirty=2}markParentsDirty(){let t=1;for(let e=this.parent;e;e=e.parent,t++){let n=1==t?2:1;e.dirty<n&&(e.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(t){return!1}}class Tn extends Sn{constructor(t,e,n,o){let r,i=e.type.toDOM;if("function"==typeof i&&(i=i(n,(()=>r?r.parent?r.parent.posBeforeChild(r):void 0:o))),!e.type.spec.raw){if(1!=i.nodeType){let t=document.createElement("span");t.appendChild(i),i=t}i.contentEditable="false",i.classList.add("ProseMirror-widget")}super(t,[],i,null),this.widget=e,this.widget=e,r=this}matchesWidget(t){return 0==this.dirty&&t.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(t){let e=this.widget.spec.stopEvent;return!!e&&e(t)}ignoreMutation(t){return"selection"!=t.type||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}}class An extends Sn{constructor(t,e,n,o){super(t,[],e,null),this.textDOM=n,this.text=o}get size(){return this.text.length}localPosFromDOM(t,e){return t!=this.textDOM?this.posAtStart+(e?this.size:0):this.posAtStart+e}domFromPos(t){return{node:this.textDOM,offset:t}}ignoreMutation(t){return"characterData"===t.type&&t.target.nodeValue==t.oldValue}}class On extends Sn{constructor(t,e,n,o,r){super(t,[],n,o),this.mark=e,this.spec=r}static create(t,e,n,o){let r=o.nodeViews[e.type.name],i=r&&r(e,o,n);return i&&i.dom||(i=ct.renderSpec(document,e.type.spec.toDOM(e,n),null,e.attrs)),new On(t,e,i.dom,i.contentDOM||i.dom,i)}parseRule(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(t){return 3!=this.dirty&&this.mark.eq(t)}markDirty(t,e){if(super.markDirty(t,e),0!=this.dirty){let t=this.parent;for(;!t.node;)t=t.parent;t.dirty<this.dirty&&(t.dirty=this.dirty),this.dirty=0}}slice(t,e,n){let o=On.create(this.parent,this.mark,!0,n),r=this.children,i=this.size;e<i&&(r=qn(r,e,i,n)),t>0&&(r=qn(r,0,t,n));for(let t=0;t<r.length;t++)r[t].parent=o;return o.children=r,o}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class En extends Sn{constructor(t,e,n,o,r,i,s,l,a){super(t,[],r,i),this.node=e,this.outerDeco=n,this.innerDeco=o,this.nodeDOM=s}static create(t,e,n,o,r,i){let s,l=r.nodeViews[e.type.name],a=l&&l(e,r,(()=>s?s.parent?s.parent.posBeforeChild(s):void 0:i),n,o),c=a&&a.dom,d=a&&a.contentDOM;if(e.isText)if(c){if(3!=c.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else c=document.createTextNode(e.text);else if(!c){let t=ct.renderSpec(document,e.type.spec.toDOM(e),null,e.attrs);({dom:c,contentDOM:d}=t)}d||e.isText||"BR"==c.nodeName||(c.hasAttribute("contenteditable")||(c.contentEditable="false"),e.type.spec.draggable&&(c.draggable=!0));let h=c;return c=Bn(c,n,e),a?s=new jn(t,e,n,o,c,d||null,h,a,r,i+1):e.isText?new Dn(t,e,n,o,c,h,r):new En(t,e,n,o,c,d||null,h,r,i+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(t.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(let e=this.children.length-1;e>=0;e--){let n=this.children[e];if(this.dom.contains(n.dom.parentNode)){t.contentElement=n.dom.parentNode;break}}t.contentElement||(t.getContent=()=>a.empty)}else t.contentElement=this.contentDOM;else t.getContent=()=>this.node.content;return t}matchesNode(t,e,n){return 0==this.dirty&&t.eq(this.node)&&_n(e,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(t,e){let n=this.node.inlineContent,o=e,r=t.composing?this.localCompositionInfo(t,e):null,i=r&&r.pos>-1?r:null,s=r&&r.pos<0,l=new Vn(this,i&&i.node,t);!function(t,e,n,o){let r=e.locals(t),i=0;if(0==r.length){for(let n=0;n<t.childCount;n++){let s=t.child(n);o(s,r,e.forChild(i,s),n),i+=s.nodeSize}return}let s=0,l=[],a=null;for(let c=0;;){let d,h,p,u;for(;s<r.length&&r[s].to==i;){let t=r[s++];t.widget&&(d?(h||(h=[d])).push(t):d=t)}if(d)if(h){h.sort(Wn);for(let t=0;t<h.length;t++)n(h[t],c,!!a)}else n(d,c,!!a);if(a)u=-1,p=a,a=null;else{if(!(c<t.childCount))break;u=c,p=t.child(c++)}for(let t=0;t<l.length;t++)l[t].to<=i&&l.splice(t--,1);for(;s<r.length&&r[s].from<=i&&r[s].to>i;)l.push(r[s++]);let f=i+p.nodeSize;if(p.isText){let t=f;s<r.length&&r[s].from<t&&(t=r[s].from);for(let e=0;e<l.length;e++)l[e].to<t&&(t=l[e].to);t<f&&(a=p.cut(t-i),p=p.cut(0,t-i),f=t,u=-1)}else for(;s<r.length&&r[s].to<f;)s++;o(p,p.isInline&&!p.isLeaf?l.filter((t=>!t.inline)):l.slice(),e.forChild(i,p),u),i=f}}(this.node,this.innerDeco,((e,r,i)=>{e.spec.marks?l.syncToMarks(e.spec.marks,n,t):e.type.side>=0&&!i&&l.syncToMarks(r==this.node.childCount?p.none:this.node.child(r).marks,n,t),l.placeWidget(e,t,o)}),((e,i,a,c)=>{let d;l.syncToMarks(e.marks,n,t),l.findNodeMatch(e,i,a,c)||s&&t.state.selection.from>o&&t.state.selection.to<o+e.nodeSize&&(d=l.findIndexWithChild(r.node))>-1&&l.updateNodeAt(e,i,a,d,t)||l.updateNextNode(e,i,a,t,c,o)||l.addNode(e,i,a,t,o),o+=e.nodeSize})),l.syncToMarks([],n,t),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||2==this.dirty)&&(i&&this.protectLocalComposition(t,i),Ln(this.contentDOM,this.children,t),Ye&&function(t){if("UL"==t.nodeName||"OL"==t.nodeName){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}(this.dom))}localCompositionInfo(t,e){let{from:n,to:o}=t.state.selection;if(!(t.state.selection instanceof le)||n<e||o>e+this.node.content.size)return null;let r=t.input.compositionNode;if(!r||!this.dom.contains(r.parentNode))return null;if(this.node.inlineContent){let t=r.nodeValue,i=function(t,e,n,o){for(let r=0,i=0;r<t.childCount&&i<=o;){let s=t.child(r++),l=i;if(i+=s.nodeSize,!s.isText)continue;let a=s.text;for(;r<t.childCount;){let e=t.child(r++);if(i+=e.nodeSize,!e.isText)break;a+=e.text}if(i>=n){if(i>=o&&a.slice(o-e.length-l,o-l)==e)return o-e.length;let t=l<o?a.lastIndexOf(e,o-l-1):-1;if(t>=0&&t+e.length+l>=n)return l+t;if(n==o&&a.length>=o+e.length-l&&a.slice(o-l,o-l+e.length)==e)return o}}return-1}(this.node.content,t,n-e,o-e);return i<0?null:{node:r,pos:i,text:t}}return{node:r,pos:-1,text:""}}protectLocalComposition(t,{node:e,pos:n,text:o}){if(this.getDesc(e))return;let r=e;for(;r.parentNode!=this.contentDOM;r=r.parentNode){for(;r.previousSibling;)r.parentNode.removeChild(r.previousSibling);for(;r.nextSibling;)r.parentNode.removeChild(r.nextSibling);r.pmViewDesc&&(r.pmViewDesc=void 0)}let i=new An(this,r,e,o);t.input.compositionNodes.push(i),this.children=qn(this.children,n,n+o.length,t,i)}update(t,e,n,o){return!(3==this.dirty||!t.sameMarkup(this.node)||(this.updateInner(t,e,n,o),0))}updateInner(t,e,n,o){this.updateOuterDeco(e),this.node=t,this.innerDeco=n,this.contentDOM&&this.updateChildren(o,this.posAtStart),this.dirty=0}updateOuterDeco(t){if(_n(t,this.outerDeco))return;let e=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=$n(this.dom,this.nodeDOM,zn(this.outerDeco,this.node,e),zn(t,this.node,e)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=t}selectNode(){1==this.nodeDOM.nodeType&&this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.dom.draggable=!0)}deselectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function Nn(t,e,n,o,r){Bn(o,e,t);let i=new En(void 0,t,e,n,o,o,o,r,0);return i.contentDOM&&i.updateChildren(r,0),i}class Dn extends En{constructor(t,e,n,o,r,i,s){super(t,e,n,o,r,null,i,s,0)}parseRule(){let t=this.nodeDOM.parentNode;for(;t&&t!=this.dom&&!t.pmIsDeco;)t=t.parentNode;return{skip:t||!0}}update(t,e,n,o){return!(3==this.dirty||0!=this.dirty&&!this.inParent()||!t.sameMarkup(this.node)||(this.updateOuterDeco(e),0==this.dirty&&t.text==this.node.text||t.text==this.nodeDOM.nodeValue||(this.nodeDOM.nodeValue=t.text,o.trackWrites==this.nodeDOM&&(o.trackWrites=null)),this.node=t,this.dirty=0,0))}inParent(){let t=this.parent.contentDOM;for(let e=this.nodeDOM;e;e=e.parentNode)if(e==t)return!0;return!1}domFromPos(t){return{node:this.nodeDOM,offset:t}}localPosFromDOM(t,e,n){return t==this.nodeDOM?this.posAtStart+Math.min(e,this.node.text.length):super.localPosFromDOM(t,e,n)}ignoreMutation(t){return"characterData"!=t.type&&"selection"!=t.type}slice(t,e,n){let o=this.node.cut(t,e),r=document.createTextNode(o.text);return new Dn(this.parent,o,this.outerDeco,this.innerDeco,r,r,n)}markDirty(t,e){super.markDirty(t,e),this.dom==this.nodeDOM||0!=t&&e!=this.nodeDOM.nodeValue.length||(this.dirty=3)}get domAtom(){return!1}isText(t){return this.node.text==t}}class Rn extends Sn{parseRule(){return{ignore:!0}}matchesHack(t){return 0==this.dirty&&this.dom.nodeName==t}get domAtom(){return!0}get ignoreForCoords(){return"IMG"==this.dom.nodeName}}class jn extends En{constructor(t,e,n,o,r,i,s,l,a,c){super(t,e,n,o,r,i,s,a,c),this.spec=l}update(t,e,n,o){if(3==this.dirty)return!1;if(this.spec.update&&(this.node.type==t.type||this.spec.multiType)){let r=this.spec.update(t,e,n);return r&&this.updateInner(t,e,n,o),r}return!(!this.contentDOM&&!t.isLeaf)&&super.update(t,e,n,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(t,e,n,o){this.spec.setSelection?this.spec.setSelection(t,e,n.root):super.setSelection(t,e,n,o)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(t){return!!this.spec.stopEvent&&this.spec.stopEvent(t)}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}}function Ln(t,e,n){let o=t.firstChild,r=!1;for(let i=0;i<e.length;i++){let s=e[i],l=s.dom;if(l.parentNode==t){for(;l!=o;)o=Fn(o),r=!0;o=o.nextSibling}else r=!0,t.insertBefore(l,o);if(s instanceof On){let e=o?o.previousSibling:t.lastChild;Ln(s.contentDOM,s.children,n),o=e?e.nextSibling:t.firstChild}}for(;o;)o=Fn(o),r=!0;r&&n.trackWrites==t&&(n.trackWrites=null)}const In=function(t){t&&(this.nodeName=t)};In.prototype=Object.create(null);const Pn=[new In];function zn(t,e,n){if(0==t.length)return Pn;let o=n?Pn[0]:new In,r=[o];for(let i=0;i<t.length;i++){let s=t[i].type.attrs;if(s){s.nodeName&&r.push(o=new In(s.nodeName));for(let t in s){let i=s[t];null!=i&&(n&&1==r.length&&r.push(o=new In(e.isInline?"span":"div")),"class"==t?o.class=(o.class?o.class+" ":"")+i:"style"==t?o.style=(o.style?o.style+";":"")+i:"nodeName"!=t&&(o[t]=i))}}}return r}function $n(t,e,n,o){if(n==Pn&&o==Pn)return e;let r=e;for(let e=0;e<o.length;e++){let i=o[e],s=n[e];if(e){let e;s&&s.nodeName==i.nodeName&&r!=t&&(e=r.parentNode)&&e.nodeName.toLowerCase()==i.nodeName||(e=document.createElement(i.nodeName),e.pmIsDeco=!0,e.appendChild(r),s=Pn[0]),r=e}Hn(r,s||Pn[0],i)}return r}function Hn(t,e,n){for(let o in e)"class"==o||"style"==o||"nodeName"==o||o in n||t.removeAttribute(o);for(let o in n)"class"!=o&&"style"!=o&&"nodeName"!=o&&n[o]!=e[o]&&t.setAttribute(o,n[o]);if(e.class!=n.class){let o=e.class?e.class.split(" ").filter(Boolean):[],r=n.class?n.class.split(" ").filter(Boolean):[];for(let e=0;e<o.length;e++)-1==r.indexOf(o[e])&&t.classList.remove(o[e]);for(let e=0;e<r.length;e++)-1==o.indexOf(r[e])&&t.classList.add(r[e]);0==t.classList.length&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let n,o=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;for(;n=o.exec(e.style);)t.style.removeProperty(n[1])}n.style&&(t.style.cssText+=n.style)}}function Bn(t,e,n){return $n(t,t,Pn,zn(e,n,1!=t.nodeType))}function _n(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 Fn(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class Vn{constructor(t,e,n){this.lock=e,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=t,this.preMatch=function(t,e){let n=e,o=n.children.length,r=t.childCount,i=new Map,s=[];t:for(;r>0;){let l;for(;;)if(o){let t=n.children[o-1];if(!(t instanceof On)){l=t,o--;break}n=t,o=t.children.length}else{if(n==e)break t;o=n.parent.children.indexOf(n),n=n.parent}let a=l.node;if(a){if(a!=t.child(r-1))break;--r,i.set(l,r),s.push(l)}}return{index:r,matched:i,matches:s.reverse()}}(t.node.content,t)}destroyBetween(t,e){if(t!=e){for(let n=t;n<e;n++)this.top.children[n].destroy();this.top.children.splice(t,e-t),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(t,e,n){let o=0,r=this.stack.length>>1,i=Math.min(r,t.length);for(;o<i&&(o==r-1?this.top:this.stack[o+1<<1]).matchesMark(t[o])&&!1!==t[o].type.spec.spanning;)o++;for(;o<r;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),r--;for(;r<t.length;){this.stack.push(this.top,this.index+1);let o=-1;for(let e=this.index;e<Math.min(this.index+3,this.top.children.length);e++){let n=this.top.children[e];if(n.matchesMark(t[r])&&!this.isLocked(n.dom)){o=e;break}}if(o>-1)o>this.index&&(this.changed=!0,this.destroyBetween(this.index,o)),this.top=this.top.children[this.index];else{let o=On.create(this.top,t[r],e,n);this.top.children.splice(this.index,0,o),this.top=o,this.changed=!0}this.index=0,r++}}findNodeMatch(t,e,n,o){let r,i=-1;if(o>=this.preMatch.index&&(r=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&r.matchesNode(t,e,n))i=this.top.children.indexOf(r,this.index);else for(let o=this.index,r=Math.min(this.top.children.length,o+5);o<r;o++){let r=this.top.children[o];if(r.matchesNode(t,e,n)&&!this.preMatch.matched.has(r)){i=o;break}}return!(i<0||(this.destroyBetween(this.index,i),this.index++,0))}updateNodeAt(t,e,n,o,r){let i=this.top.children[o];return 3==i.dirty&&i.dom==i.contentDOM&&(i.dirty=2),!!i.update(t,e,n,r)&&(this.destroyBetween(this.index,o),this.index++,!0)}findIndexWithChild(t){for(;;){let e=t.parentNode;if(!e)return-1;if(e==this.top.contentDOM){let e=t.pmViewDesc;if(e)for(let t=this.index;t<this.top.children.length;t++)if(this.top.children[t]==e)return t;return-1}t=e}}updateNextNode(t,e,n,o,r,i){for(let s=this.index;s<this.top.children.length;s++){let l=this.top.children[s];if(l instanceof En){let a=this.preMatch.matched.get(l);if(null!=a&&a!=r)return!1;let c,d=l.dom,h=this.isLocked(d)&&!(t.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==t.text&&3!=l.dirty&&_n(e,l.outerDeco));if(!h&&l.update(t,e,n,o))return this.destroyBetween(this.index,s),l.dom!=d&&(this.changed=!0),this.index++,!0;if(!h&&(c=this.recreateWrapper(l,t,e,n,o,i)))return this.destroyBetween(this.index,s),this.top.children[this.index]=c,c.contentDOM&&(c.dirty=2,c.updateChildren(o,i+1),c.dirty=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(t,e,n,o,r,i){if(t.dirty||e.isAtom||!t.children.length||!t.node.content.eq(e.content)||!_n(n,t.outerDeco)||!o.eq(t.innerDeco))return null;let s=En.create(this.top,e,n,o,r,i);if(s.contentDOM){s.children=t.children,t.children=[];for(let t of s.children)t.parent=s}return t.destroy(),s}addNode(t,e,n,o,r){let i=En.create(this.top,t,e,n,o,r);i.contentDOM&&i.updateChildren(o,r+1),this.top.children.splice(this.index++,0,i),this.changed=!0}placeWidget(t,e,n){let o=this.index<this.top.children.length?this.top.children[this.index]:null;if(!o||!o.matchesWidget(t)||t!=o.widget&&o.widget.type.toDOM.parentNode){let o=new Tn(this.top,t,e,n);this.top.children.splice(this.index++,0,o),this.changed=!0}else this.index++}addTextblockHacks(){let t=this.top.children[this.index-1],e=this.top;for(;t instanceof On;)e=t,t=e.children[e.children.length-1];(!t||!(t instanceof Dn)||/\n$/.test(t.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(t.node.text))&&((Ge||Je)&&t&&"false"==t.dom.contentEditable&&this.addHackNode("IMG",e),this.addHackNode("BR",this.top))}addHackNode(t,e){if(e==this.top&&this.index<e.children.length&&e.children[this.index].matchesHack(t))this.index++;else{let n=document.createElement(t);"IMG"==t&&(n.className="ProseMirror-separator",n.alt=""),"BR"==t&&(n.className="ProseMirror-trailingBreak");let o=new Rn(this.top,[],n,null);e!=this.top?e.children.push(o):e.children.splice(this.index++,0,o),this.changed=!0}}isLocked(t){return this.lock&&(t==this.lock||1==t.nodeType&&t.contains(this.lock.parentNode))}}function Wn(t,e){return t.type.side-e.type.side}function qn(t,e,n,o,r){let i=[];for(let s=0,l=0;s<t.length;s++){let a=t[s],c=l,d=l+=a.size;c>=n||d<=e?i.push(a):(c<e&&i.push(a.slice(0,e-c,o)),r&&(i.push(r),r=void 0),d>n&&i.push(a.slice(n-c,a.size,o)))}return i}function Kn(t,e=null){let n=t.domSelectionRange(),o=t.state.doc;if(!n.focusNode)return null;let r=t.docView.nearestDesc(n.focusNode),i=r&&0==r.size,s=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let l,a,c=o.resolve(s);if(Ie(n)){for(l=s;r&&!r.node;)r=r.parent;let t=r.node;if(r&&t.isAtom&&ce.isSelectable(t)&&r.parent&&(!t.isInline||!function(t,e,n){for(let o=0==e,r=e==je(t);o||r;){if(t==n)return!0;let e=Te(t);if(!(t=t.parentNode))return!1;o=o&&0==e,r=r&&e==je(t)}}(n.focusNode,n.focusOffset,r.dom))){let t=r.posBefore;a=new ce(s==t?c:o.resolve(t))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let e=s,r=s;for(let o=0;o<n.rangeCount;o++){let i=n.getRangeAt(o);e=Math.min(e,t.docView.posFromDOM(i.startContainer,i.startOffset,1)),r=Math.max(r,t.docView.posFromDOM(i.endContainer,i.endOffset,-1))}if(e<0)return null;[l,s]=r==t.state.selection.anchor?[r,e]:[e,r],c=o.resolve(s)}else l=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(l<0)return null}let d=o.resolve(l);return a||(a=eo(t,d,c,"pointer"==e||t.state.selection.head<c.pos&&!i?1:-1)),a}function Jn(t){return t.editable?t.hasFocus():oo(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Un(t,e=!1){let n=t.state.selection;if(Zn(t,n),Jn(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&Je){let e=t.domSelectionRange(),n=t.domObserver.currentSelection;if(e.anchorNode&&n.anchorNode&&Ne(e.anchorNode,e.anchorOffset,n.anchorNode,n.anchorOffset))return t.input.mouseDown.delayedSelectionSync=!0,void t.domObserver.setCurSelection()}if(t.domObserver.disconnectSelection(),t.cursorWrapper)!function(t){let e=t.domSelection(),n=document.createRange();if(!e)return;let o=t.cursorWrapper.dom,r="IMG"==o.nodeName;r?n.setStart(o.parentNode,Te(o)+1):n.setStart(o,0),n.collapse(!0),e.removeAllRanges(),e.addRange(n),!r&&!t.state.selection.visible&&Ve&&We<=11&&(o.disabled=!0,o.disabled=!1)}(t);else{let o,r,{anchor:i,head:s}=n;!Gn||n instanceof le||(n.$from.parent.inlineContent||(o=Yn(t,n.from)),n.empty||n.$from.parent.inlineContent||(r=Yn(t,n.to))),t.docView.setSelection(i,s,t,e),Gn&&(o&&Qn(o),r&&Qn(r)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),o=n.anchorNode,r=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{n.anchorNode==o&&n.anchorOffset==r||(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout((()=>{Jn(t)&&!t.state.selection.visible||t.dom.classList.remove("ProseMirror-hideselection")}),20))})}(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const Gn=Ge||Je&&Ue<63;function Yn(t,e){let{node:n,offset:o}=t.docView.domFromPos(e,0),r=o<n.childNodes.length?n.childNodes[o]:null,i=o?n.childNodes[o-1]:null;if(Ge&&r&&"false"==r.contentEditable)return Xn(r);if(!(r&&"false"!=r.contentEditable||i&&"false"!=i.contentEditable)){if(r)return Xn(r);if(i)return Xn(i)}}function Xn(t){return t.contentEditable="true",Ge&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function Qn(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function Zn(t,e){if(e instanceof ce){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(to(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else to(t)}function to(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function eo(t,e,n,o){return t.someProp("createSelectionBetween",(o=>o(t,e,n)))||le.between(e,n,o)}function no(t){return!(t.editable&&!t.hasFocus())&&oo(t)}function oo(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(3==e.anchorNode.nodeType?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(3==e.focusNode.nodeType?e.focusNode.parentNode:e.focusNode))}catch(t){return!1}}function ro(t,e){let{$anchor:n,$head:o}=t.selection,r=e>0?n.max(o):n.min(o),i=r.parent.inlineContent?r.depth?t.doc.resolve(e>0?r.after():r.before()):null:r;return i&&oe.findFrom(i,e)}function io(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function so(t,e,n){let o=t.state.selection;if(!(o instanceof le)){if(o instanceof ce&&o.node.isInline)return io(t,new le(e>0?o.$to:o.$from));{let n=ro(t.state,e);return!!n&&io(t,n)}}if(n.indexOf("s")>-1){let{$head:n}=o,r=n.textOffset?null:e<0?n.nodeBefore:n.nodeAfter;if(!r||r.isText||!r.isLeaf)return!1;let i=t.state.doc.resolve(n.pos+r.nodeSize*(e<0?-1:1));return io(t,new le(o.$anchor,i))}if(!o.empty)return!1;if(t.endOfTextblock(e>0?"forward":"backward")){let n=ro(t.state,e);return!!(n&&n instanceof ce)&&io(t,n)}if(!(Xe&&n.indexOf("m")>-1)){let n,r=o.$head,i=r.textOffset?null:e<0?r.nodeBefore:r.nodeAfter;if(!i||i.isText)return!1;let s=e<0?r.pos-i.nodeSize:r.pos;return!!(i.isAtom||(n=t.docView.descAt(s))&&!n.contentDOM)&&(ce.isSelectable(i)?io(t,new ce(e<0?t.state.doc.resolve(r.pos-i.nodeSize):r)):!!tn&&io(t,new le(t.state.doc.resolve(e<0?s:s+i.nodeSize))))}}function lo(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function ao(t,e){let n=t.pmViewDesc;return n&&0==n.size&&(e<0||t.nextSibling||"BR"!=t.nodeName)}function co(t,e){return e<0?function(t){let e=t.domSelectionRange(),n=e.focusNode,o=e.focusOffset;if(!n)return;let r,i,s=!1;for(qe&&1==n.nodeType&&o<lo(n)&&ao(n.childNodes[o],-1)&&(s=!0);;)if(o>0){if(1!=n.nodeType)break;{let t=n.childNodes[o-1];if(ao(t,-1))r=n,i=--o;else{if(3!=t.nodeType)break;n=t,o=n.nodeValue.length}}}else{if(ho(n))break;{let e=n.previousSibling;for(;e&&ao(e,-1);)r=n.parentNode,i=Te(e),e=e.previousSibling;if(e)n=e,o=lo(n);else{if(n=n.parentNode,n==t.dom)break;o=0}}}s?po(t,n,o):r&&po(t,r,i)}(t):function(t){let e=t.domSelectionRange(),n=e.focusNode,o=e.focusOffset;if(!n)return;let r,i,s=lo(n);for(;;)if(o<s){if(1!=n.nodeType)break;if(!ao(n.childNodes[o],1))break;r=n,i=++o}else{if(ho(n))break;{let e=n.nextSibling;for(;e&&ao(e,1);)r=e.parentNode,i=Te(e)+1,e=e.nextSibling;if(e)n=e,o=0,s=lo(n);else{if(n=n.parentNode,n==t.dom)break;o=s=0}}}r&&po(t,r,i)}(t)}function ho(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function po(t,e,n){if(3!=e.nodeType){let t,o;(o=function(t,e){for(;t&&e==t.childNodes.length&&!Le(t);)e=Te(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;t=n,e=0}}(e,n))?(e=o,n=0):(t=function(t,e){for(;t&&!e&&!Le(t);)e=Te(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;e=(t=n).childNodes.length}}(e,n))&&(e=t,n=t.nodeValue.length)}let o=t.domSelection();if(!o)return;if(Ie(o)){let t=document.createRange();t.setEnd(e,n),t.setStart(e,n),o.removeAllRanges(),o.addRange(t)}else o.extend&&o.extend(e,n);t.domObserver.setCurSelection();let{state:r}=t;setTimeout((()=>{t.state==r&&Un(t)}),50)}function uo(t,e){let n=t.state.doc.resolve(e);if(!Je&&!Qe&&n.parent.inlineContent){let o=t.coordsAtPos(e);if(e>n.start()){let n=t.coordsAtPos(e-1),r=(n.top+n.bottom)/2;if(r>o.top&&r<o.bottom&&Math.abs(n.left-o.left)>1)return n.left<o.left?"ltr":"rtl"}if(e<n.end()){let n=t.coordsAtPos(e+1),r=(n.top+n.bottom)/2;if(r>o.top&&r<o.bottom&&Math.abs(n.left-o.left)>1)return n.left>o.left?"ltr":"rtl"}}return"rtl"==getComputedStyle(t.dom).direction?"rtl":"ltr"}function fo(t,e,n){let o=t.state.selection;if(o instanceof le&&!o.empty||n.indexOf("s")>-1)return!1;if(Xe&&n.indexOf("m")>-1)return!1;let{$from:r,$to:i}=o;if(!r.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let n=ro(t.state,e);if(n&&n instanceof ce)return io(t,n)}if(!r.parent.inlineContent){let n=e<0?r:i,s=o instanceof he?oe.near(n,e):oe.findFrom(n,e);return!!s&&io(t,s)}return!1}function mo(t,e){if(!(t.state.selection instanceof le))return!0;let{$head:n,$anchor:o,empty:r}=t.state.selection;if(!n.sameParent(o))return!0;if(!r)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let o=t.state.tr;return e<0?o.delete(n.pos-i.nodeSize,n.pos):o.delete(n.pos,n.pos+i.nodeSize),t.dispatch(o),!0}return!1}function go(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function yo(t,e){t.someProp("transformCopied",(n=>{e=n(e,t)}));let n=[],{content:o,openStart:r,openEnd:i}=e;for(;r>1&&i>1&&1==o.childCount&&1==o.firstChild.childCount;){r--,i--;let t=o.firstChild;n.push(t.type.name,t.attrs!=t.type.defaultAttrs?t.attrs:null),o=t.content}let s=t.someProp("clipboardSerializer")||ct.fromSchema(t.state.schema),l=Ao(),a=l.createElement("div");a.appendChild(s.serializeFragment(o,{document:l}));let c,d=a.firstChild,h=0;for(;d&&1==d.nodeType&&(c=So[d.nodeName.toLowerCase()]);){for(let t=c.length-1;t>=0;t--){let e=l.createElement(c[t]);for(;a.firstChild;)e.appendChild(a.firstChild);a.appendChild(e),h++}d=a.firstChild}return d&&1==d.nodeType&&d.setAttribute("data-pm-slice",`${r} ${i}${h?` -${h}`:""} ${JSON.stringify(n)}`),{dom:a,text:t.someProp("clipboardTextSerializer",(n=>n(e,t)))||e.content.textBetween(0,e.content.size,"\n\n"),slice:e}}function bo(t,e,n,o,r){let i,s,l=r.parent.type.spec.code;if(!n&&!e)return null;let c=e&&(o||l||!n);if(c){if(t.someProp("transformPastedText",(n=>{e=n(e,l||o,t)})),l)return e?new f(a.from(t.state.schema.text(e.replace(/\r\n?/g,"\n"))),0,0):f.empty;let n=t.someProp("clipboardTextParser",(n=>n(e,r,o,t)));if(n)s=n;else{let n=r.marks(),{schema:o}=t.state,s=ct.fromSchema(o);i=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach((t=>{let e=i.appendChild(document.createElement("p"));t&&e.appendChild(s.serializeNode(o.text(t,n)))}))}}else t.someProp("transformPastedHTML",(e=>{n=e(n,t)})),i=function(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n,o=Ao().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t);if((n=r&&So[r[1].toLowerCase()])&&(t=n.map((t=>"<"+t+">")).join("")+t+n.map((t=>"</"+t+">")).reverse().join("")),o.innerHTML=function(t){let e=window.trustedTypes;return e?(Oo||(Oo=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),Oo.createHTML(t)):t}(t),n)for(let t=0;t<n.length;t++)o=o.querySelector(n[t])||o;return o}(n),tn&&function(t){let e=t.querySelectorAll(Je?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let o=e[n];1==o.childNodes.length&&" "==o.textContent&&o.parentNode&&o.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),o)}}(i);let d=i&&i.querySelector("[data-pm-slice]"),h=d&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(d.getAttribute("data-pm-slice")||"");if(h&&h[3])for(let t=+h[3];t>0;t--){let t=i.firstChild;for(;t&&1!=t.nodeType;)t=t.nextSibling;if(!t)break;i=t}if(!s){let e=t.someProp("clipboardParser")||t.someProp("domParser")||Z.fromSchema(t.state.schema);s=e.parseSlice(i,{preserveWhitespace:!(!c&&!h),context:r,ruleFromNode:t=>"BR"!=t.nodeName||t.nextSibling||!t.parentNode||vo.test(t.parentNode.nodeName)?null:{ignore:!0}})}if(h)s=function(t,e){if(!t.size)return t;let n,o=t.content.firstChild.type.schema;try{n=JSON.parse(e)}catch(e){return t}let{content:r,openStart:i,openEnd:s}=t;for(let t=n.length-2;t>=0;t-=2){let e=o.nodes[n[t]];if(!e||e.hasRequiredAttrs())break;r=a.from(e.create(n[t+1],r)),i++,s++}return new f(r,i,s)}(Co(s,+h[1],+h[2]),h[4]);else if(s=f.maxOpen(function(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let o,r=e.node(n).contentMatchAt(e.index(n)),i=[];if(t.forEach((t=>{if(!i)return;let e,n=r.findWrapping(t.type);if(!n)return i=null;if(e=i.length&&o.length&&ko(n,o,t,i[i.length-1],0))i[i.length-1]=e;else{i.length&&(i[i.length-1]=xo(i[i.length-1],o.length));let e=wo(t,n);i.push(e),r=r.matchType(e.type),o=n}})),i)return a.from(i)}return t}(s.content,r),!0),s.openStart||s.openEnd){let t=0,e=0;for(let e=s.content.firstChild;t<s.openStart&&!e.type.spec.isolating;t++,e=e.firstChild);for(let t=s.content.lastChild;e<s.openEnd&&!t.type.spec.isolating;e++,t=t.lastChild);s=Co(s,t,e)}return t.someProp("transformPasted",(e=>{s=e(s,t)})),s}const vo=/^(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 wo(t,e,n=0){for(let o=e.length-1;o>=n;o--)t=e[o].create(null,a.from(t));return t}function ko(t,e,n,o,r){if(r<t.length&&r<e.length&&t[r]==e[r]){let i=ko(t,e,n,o.lastChild,r+1);if(i)return o.copy(o.content.replaceChild(o.childCount-1,i));if(o.contentMatchAt(o.childCount).matchType(r==t.length-1?n.type:t[r+1]))return o.copy(o.content.append(a.from(wo(n,t,r+1))))}}function xo(t,e){if(0==e)return t;let n=t.content.replaceChild(t.childCount-1,xo(t.lastChild,e-1)),o=t.contentMatchAt(t.childCount).fillBefore(a.empty,!0);return t.copy(n.append(o))}function Mo(t,e,n,o,r,i){let s=e<0?t.firstChild:t.lastChild,l=s.content;return t.childCount>1&&(i=0),r<o-1&&(l=Mo(l,e,n,o,r+1,i)),r>=n&&(l=e<0?s.contentMatchAt(0).fillBefore(l,i<=r).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(a.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,s.copy(l))}function Co(t,e,n){return e<t.openStart&&(t=new f(Mo(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new f(Mo(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const So={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let To=null;function Ao(){return To||(To=document.implementation.createHTMLDocument("title"))}let Oo=null;const Eo={},No={},Do={touchstart:!0,touchmove:!0};class Ro{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function jo(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function Lo(t){t.someProp("handleDOMEvents",(e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=e=>Io(t,e))}))}function Io(t,e){return t.someProp("handleDOMEvents",(n=>{let o=n[e.type];return!!o&&(o(t,e)||e.defaultPrevented)}))}function Po(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function zo(t){return{left:t.clientX,top:t.clientY}}function $o(t,e,n,o,r){if(-1==o)return!1;let i=t.state.doc.resolve(o);for(let o=i.depth+1;o>0;o--)if(t.someProp(e,(e=>o>i.depth?e(t,n,i.nodeAfter,i.before(o),r,!0):e(t,n,i.node(o),i.before(o),r,!1))))return!0;return!1}function Ho(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let o=t.state.tr.setSelection(e);"pointer"==n&&o.setMeta("pointer",!0),t.dispatch(o)}function Bo(t,e,n,o){return $o(t,"handleDoubleClickOn",e,n,o)||t.someProp("handleDoubleClick",(n=>n(t,e,o)))}function _o(t,e,n,o){return $o(t,"handleTripleClickOn",e,n,o)||t.someProp("handleTripleClick",(n=>n(t,e,o)))||function(t,e,n){if(0!=n.button)return!1;let o=t.state.doc;if(-1==e)return!!o.inlineContent&&(Ho(t,le.create(o,0,o.content.size),"pointer"),!0);let r=o.resolve(e);for(let e=r.depth+1;e>0;e--){let n=e>r.depth?r.nodeAfter:r.node(e),i=r.before(e);if(n.inlineContent)Ho(t,le.create(o,i+1,i+1+n.content.size),"pointer");else{if(!ce.isSelectable(n))continue;Ho(t,ce.create(o,i),"pointer")}return!0}}(t,n,o)}function Fo(t){return Go(t)}No.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=16==n.keyCode||n.shiftKey,!qo(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!Ze||!Je||13!=n.keyCode))if(229!=n.keyCode&&t.domObserver.forceFlush(),!Ye||13!=n.keyCode||n.ctrlKey||n.altKey||n.metaKey)t.someProp("handleKeyDown",(e=>e(t,n)))||function(t,e){let n=e.keyCode,o=function(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}(e);if(8==n||Xe&&72==n&&"c"==o)return mo(t,-1)||co(t,-1);if(46==n&&!e.shiftKey||Xe&&68==n&&"c"==o)return mo(t,1)||co(t,1);if(13==n||27==n)return!0;if(37==n||Xe&&66==n&&"c"==o){let e=37==n?"ltr"==uo(t,t.state.selection.from)?-1:1:-1;return so(t,e,o)||co(t,e)}if(39==n||Xe&&70==n&&"c"==o){let e=39==n?"ltr"==uo(t,t.state.selection.from)?1:-1:1;return so(t,e,o)||co(t,e)}return 38==n||Xe&&80==n&&"c"==o?fo(t,-1,o)||co(t,-1):40==n||Xe&&78==n&&"c"==o?function(t){if(!Ge||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&1==e.nodeType&&0==n&&e.firstChild&&"false"==e.firstChild.contentEditable){let n=e.firstChild;go(t,n,"true"),setTimeout((()=>go(t,n,"false")),20)}return!1}(t)||fo(t,1,o)||co(t,1):o==(Xe?"m":"c")&&(66==n||73==n||89==n||90==n)}(t,n)?n.preventDefault():jo(t,"key");else{let e=Date.now();t.input.lastIOSEnter=e,t.input.lastIOSEnterFallbackTimeout=setTimeout((()=>{t.input.lastIOSEnter==e&&(t.someProp("handleKeyDown",(e=>e(t,Pe(13,"Enter")))),t.input.lastIOSEnter=0)}),200)}},No.keyup=(t,e)=>{16==e.keyCode&&(t.input.shiftKey=!1)},No.keypress=(t,e)=>{let n=e;if(qo(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Xe&&n.metaKey)return;if(t.someProp("handleKeyPress",(e=>e(t,n))))return void n.preventDefault();let o=t.state.selection;if(!(o instanceof le&&o.$from.sameParent(o.$to))){let e=String.fromCharCode(n.charCode);/[\r\n]/.test(e)||t.someProp("handleTextInput",(n=>n(t,o.$from.pos,o.$to.pos,e)))||t.dispatch(t.state.tr.insertText(e).scrollIntoView()),n.preventDefault()}};const Vo=Xe?"metaKey":"ctrlKey";Eo.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let o=Fo(t),r=Date.now(),i="singleClick";r-t.input.lastClick.time<500&&function(t,e){let n=e.x-t.clientX,o=e.y-t.clientY;return n*n+o*o<100}(n,t.input.lastClick)&&!n[Vo]&&("singleClick"==t.input.lastClick.type?i="doubleClick":"doubleClick"==t.input.lastClick.type&&(i="tripleClick")),t.input.lastClick={time:r,x:n.clientX,y:n.clientY,type:i};let s=t.posAtCoords(zo(n));s&&("singleClick"==i?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new Wo(t,s,n,!!o)):("doubleClick"==i?Bo:_o)(t,s.pos,s.inside,n)?n.preventDefault():jo(t,"pointer"))};class Wo{constructor(t,e,n,o){let r,i;if(this.view=t,this.pos=e,this.event=n,this.flushed=o,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=t.state.doc,this.selectNode=!!n[Vo],this.allowDefault=n.shiftKey,e.inside>-1)r=t.state.doc.nodeAt(e.inside),i=e.inside;else{let n=t.state.doc.resolve(e.pos);r=n.parent,i=n.depth?n.before():0}const s=o?null:n.target,l=s?t.docView.nearestDesc(s,!0):null;this.target=l&&1==l.dom.nodeType?l.dom:null;let{selection:a}=t.state;(0==n.button&&r.type.spec.draggable&&!1!==r.type.spec.selectable||a instanceof ce&&a.from<=i&&a.to>i)&&(this.mightDrag={node:r,pos:i,addAttr:!(!this.target||this.target.draggable),setUneditable:!(!this.target||!qe||this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout((()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")}),20),this.view.domObserver.start()),t.root.addEventListener("mouseup",this.up=this.up.bind(this)),t.root.addEventListener("mousemove",this.move=this.move.bind(this)),jo(t,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout((()=>Un(this.view))),this.view.input.mouseDown=null}up(t){if(this.done(),!this.view.dom.contains(t.target))return;let e=this.pos;this.view.state.doc!=this.startDoc&&(e=this.view.posAtCoords(zo(t))),this.updateAllowDefault(t),this.allowDefault||!e?jo(this.view,"pointer"):function(t,e,n,o,r){return $o(t,"handleClickOn",e,n,o)||t.someProp("handleClick",(n=>n(t,e,o)))||(r?function(t,e){if(-1==e)return!1;let n,o,r=t.state.selection;r instanceof ce&&(n=r.node);let i=t.state.doc.resolve(e);for(let t=i.depth+1;t>0;t--){let e=t>i.depth?i.nodeAfter:i.node(t);if(ce.isSelectable(e)){o=n&&r.$from.depth>0&&t>=r.$from.depth&&i.before(r.$from.depth+1)==r.$from.pos?i.before(r.$from.depth):i.before(t);break}}return null!=o&&(Ho(t,ce.create(t.state.doc,o),"pointer"),!0)}(t,n):function(t,e){if(-1==e)return!1;let n=t.state.doc.resolve(e),o=n.nodeAfter;return!!(o&&o.isAtom&&ce.isSelectable(o))&&(Ho(t,new ce(n),"pointer"),!0)}(t,n))}(this.view,e.pos,e.inside,t,this.selectNode)?t.preventDefault():0==t.button&&(this.flushed||Ge&&this.mightDrag&&!this.mightDrag.node.isAtom||Je&&!this.view.state.selection.visible&&Math.min(Math.abs(e.pos-this.view.state.selection.from),Math.abs(e.pos-this.view.state.selection.to))<=2)?(Ho(this.view,oe.near(this.view.state.doc.resolve(e.pos)),"pointer"),t.preventDefault()):jo(this.view,"pointer")}move(t){this.updateAllowDefault(t),jo(this.view,"pointer"),0==t.buttons&&this.done()}updateAllowDefault(t){!this.allowDefault&&(Math.abs(this.event.x-t.clientX)>4||Math.abs(this.event.y-t.clientY)>4)&&(this.allowDefault=!0)}}function qo(t,e){return!!t.composing||!!(Ge&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500)&&(t.input.compositionEndedAt=-2e8,!0)}Eo.touchstart=t=>{t.input.lastTouch=Date.now(),Fo(t),jo(t,"pointer")},Eo.touchmove=t=>{t.input.lastTouch=Date.now(),jo(t,"pointer")},Eo.contextmenu=t=>Fo(t);const Ko=Ze?5e3:-1;function Jo(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout((()=>Go(t)),e))}function Uo(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=function(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function Go(t,e=!1){if(!(Ze&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),Uo(t),e||t.docView&&t.docView.dirty){let n=Kn(t);return n&&!n.eq(t.state.selection)?t.dispatch(t.state.tr.setSelection(n)):!t.markCursor&&!e||t.state.selection.empty?t.updateState(t.state):t.dispatch(t.state.tr.deleteSelection()),!0}return!1}}No.compositionstart=No.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof le&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some((t=>!1===t.type.spec.inclusive))))t.markCursor=t.state.storedMarks||n.marks(),Go(t,!0),t.markCursor=null;else if(Go(t,!e.selection.empty),qe&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let e=t.domSelectionRange();for(let n=e.focusNode,o=e.focusOffset;n&&1==n.nodeType&&0!=o;){let e=o<0?n.lastChild:n.childNodes[o-1];if(!e)break;if(3==e.nodeType){let n=t.domSelection();n&&n.collapse(e,e.nodeValue.length);break}n=e,o=-1}}t.input.composing=!0}Jo(t,Ko)},No.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.compositionPendingChanges&&Promise.resolve().then((()=>t.domObserver.flush())),t.input.compositionID++,Jo(t,20))};const Yo=Ve&&We<15||Ye&&en<604;function Xo(t,e,n,o,r){let i=bo(t,e,n,o,t.state.selection.$from);if(t.someProp("handlePaste",(e=>e(t,r,i||f.empty))))return!0;if(!i)return!1;let s=function(t){return 0==t.openStart&&0==t.openEnd&&1==t.content.childCount?t.content.firstChild:null}(i),l=s?t.state.tr.replaceSelectionWith(s,o):t.state.tr.replaceSelection(i);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Qo(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," "):""}Eo.copy=No.cut=(t,e)=>{let n=e,o=t.state.selection,r="cut"==n.type;if(o.empty)return;let i=Yo?null:n.clipboardData,s=o.content(),{dom:l,text:a}=yo(t,s);i?(n.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):function(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let o=getSelection(),r=document.createRange();r.selectNodeContents(e),t.dom.blur(),o.removeAllRanges(),o.addRange(r),setTimeout((()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()}),50)}(t,l),r&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},No.paste=(t,e)=>{let n=e;if(t.composing&&!Ze)return;let o=Yo?null:n.clipboardData,r=t.input.shiftKey&&45!=t.input.lastKeyCode;o&&Xo(t,Qo(o),o.getData("text/html"),r,n)?n.preventDefault():function(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,o=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(o.contentEditable="true"),o.style.cssText="position: fixed; left: -10000px; top: 10px",o.focus();let r=t.input.shiftKey&&45!=t.input.lastKeyCode;setTimeout((()=>{t.focus(),o.parentNode&&o.parentNode.removeChild(o),n?Xo(t,o.value,null,r,e):Xo(t,o.textContent,o.innerHTML,r,e)}),50)}(t,n)};class Zo{constructor(t,e,n){this.slice=t,this.move=e,this.node=n}}const tr=Xe?"altKey":"ctrlKey";Eo.dragstart=(t,e)=>{let n=e,o=t.input.mouseDown;if(o&&o.done(),!n.dataTransfer)return;let r,i=t.state.selection,s=i.empty?null:t.posAtCoords(zo(n));if(s&&s.pos>=i.from&&s.pos<=(i instanceof ce?i.to-1:i.to));else if(o&&o.mightDrag)r=ce.create(t.state.doc,o.mightDrag.pos);else if(n.target&&1==n.target.nodeType){let e=t.docView.nearestDesc(n.target,!0);e&&e.node.type.spec.draggable&&e!=t.docView&&(r=ce.create(t.state.doc,e.posBefore))}let l=(r||t.state.selection).content(),{dom:a,text:c,slice:d}=yo(t,l);(!n.dataTransfer.files.length||!Je||Ue>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Yo?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",Yo||n.dataTransfer.setData("text/plain",c),t.dragging=new Zo(d,!n[tr],r)},Eo.dragend=t=>{let e=t.dragging;window.setTimeout((()=>{t.dragging==e&&(t.dragging=null)}),50)},No.dragover=No.dragenter=(t,e)=>e.preventDefault(),No.drop=(t,e)=>{let n=e,o=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let r=t.posAtCoords(zo(n));if(!r)return;let i=t.state.doc.resolve(r.pos),s=o&&o.slice;s?t.someProp("transformPasted",(e=>{s=e(s,t)})):s=bo(t,Qo(n.dataTransfer),Yo?null:n.dataTransfer.getData("text/html"),!1,i);let l=!(!o||n[tr]);if(t.someProp("handleDrop",(e=>e(t,n,s||f.empty,l))))return void n.preventDefault();if(!s)return;n.preventDefault();let a=s?_t(t.state.doc,i.pos,s):i.pos;null==a&&(a=i.pos);let c=t.state.tr;if(l){let{node:t}=o;t?t.replace(c):c.deleteSelection()}let d=c.mapping.map(a),h=0==s.openStart&&0==s.openEnd&&1==s.content.childCount,p=c.doc;if(h?c.replaceRangeWith(d,d,s.content.firstChild):c.replaceRange(d,d,s),c.doc.eq(p))return;let u=c.doc.resolve(d);if(h&&ce.isSelectable(s.content.firstChild)&&u.nodeAfter&&u.nodeAfter.sameMarkup(s.content.firstChild))c.setSelection(new ce(u));else{let e=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach(((t,n,o,r)=>e=r)),c.setSelection(eo(t,u,c.doc.resolve(e)))}t.focus(),t.dispatch(c.setMeta("uiEvent","drop"))},Eo.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())&&Un(t)}),20))},Eo.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)},Eo.beforeinput=(t,e)=>{if(Je&&Ze&&"deleteContentBackward"==e.inputType){t.domObserver.flushSoon();let{domChangeCount:e}=t.input;setTimeout((()=>{if(t.input.domChangeCount!=e)return;if(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",(e=>e(t,Pe(8,"Backspace")))))return;let{$cursor:n}=t.state.selection;n&&n.pos>0&&t.dispatch(t.state.tr.delete(n.pos-1,n.pos).scrollIntoView())}),50)}};for(let t in No)Eo[t]=No[t];function er(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class nr{constructor(t,e){this.toDOM=t,this.spec=e||lr,this.side=this.spec.side||0}map(t,e,n,o){let{pos:r,deleted:i}=t.mapResult(e.from+o,this.side<0?-1:1);return i?null:new ir(r-n,r-n,this)}valid(){return!0}eq(t){return this==t||t instanceof nr&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&er(this.spec,t.spec))}destroy(t){this.spec.destroy&&this.spec.destroy(t)}}class or{constructor(t,e){this.attrs=t,this.spec=e||lr}map(t,e,n,o){let r=t.map(e.from+o,this.spec.inclusiveStart?-1:1)-n,i=t.map(e.to+o,this.spec.inclusiveEnd?1:-1)-n;return r>=i?null:new ir(r,i,this)}valid(t,e){return e.from<e.to}eq(t){return this==t||t instanceof or&&er(this.attrs,t.attrs)&&er(this.spec,t.spec)}static is(t){return t.type instanceof or}destroy(){}}class rr{constructor(t,e){this.attrs=t,this.spec=e||lr}map(t,e,n,o){let r=t.mapResult(e.from+o,1);if(r.deleted)return null;let i=t.mapResult(e.to+o,-1);return i.deleted||i.pos<=r.pos?null:new ir(r.pos-n,i.pos-n,this)}valid(t,e){let n,{index:o,offset:r}=t.content.findIndex(e.from);return r==e.from&&!(n=t.child(o)).isText&&r+n.nodeSize==e.to}eq(t){return this==t||t instanceof rr&&er(this.attrs,t.attrs)&&er(this.spec,t.spec)}destroy(){}}class ir{constructor(t,e,n){this.from=t,this.to=e,this.type=n}copy(t,e){return new ir(t,e,this.type)}eq(t,e=0){return this.type.eq(t.type)&&this.from+e==t.from&&this.to+e==t.to}map(t,e,n){return this.type.map(t,this,e,n)}static widget(t,e,n){return new ir(t,t,new nr(e,n))}static inline(t,e,n,o){return new ir(t,e,new or(n,o))}static node(t,e,n,o){return new ir(t,e,new rr(n,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof or}get widget(){return this.type instanceof nr}}const sr=[],lr={};class ar{constructor(t,e){this.local=t.length?t:sr,this.children=e.length?e:sr}static create(t,e){return e.length?fr(e,t,0,lr):cr}find(t,e,n){let o=[];return this.findInner(null==t?0:t,null==e?1e9:e,o,0,n),o}findInner(t,e,n,o,r){for(let i=0;i<this.local.length;i++){let s=this.local[i];s.from<=e&&s.to>=t&&(!r||r(s.spec))&&n.push(s.copy(s.from+o,s.to+o))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<e&&this.children[i+1]>t){let s=this.children[i]+1;this.children[i+2].findInner(t-s,e-s,n,o+s,r)}}map(t,e,n){return this==cr||0==t.maps.length?this:this.mapInner(t,e,0,0,n||lr)}mapInner(t,e,n,o,r){let i;for(let s=0;s<this.local.length;s++){let l=this.local[s].map(t,n,o);l&&l.type.valid(e,l)?(i||(i=[])).push(l):r.onRemove&&r.onRemove(this.local[s].spec)}return this.children.length?function(t,e,n,o,r,i,s){let l=t.slice();for(let t=0,e=i;t<n.maps.length;t++){let o=0;n.maps[t].forEach(((t,n,r,i)=>{let s=i-r-(n-t);for(let r=0;r<l.length;r+=3){let i=l[r+1];if(i<0||t>i+e-o)continue;let a=l[r]+e-o;n>=a?l[r+1]=t<=a?-2:-1:t>=e&&s&&(l[r]+=s,l[r+1]+=s)}o+=s})),e=n.maps[t].map(e,-1)}let a=!1;for(let e=0;e<l.length;e+=3)if(l[e+1]<0){if(-2==l[e+1]){a=!0,l[e+1]=-1;continue}let c=n.map(t[e]+i),d=c-r;if(d<0||d>=o.content.size){a=!0;continue}let h=n.map(t[e+1]+i,-1)-r,{index:p,offset:u}=o.content.findIndex(d),f=o.maybeChild(p);if(f&&u==d&&u+f.nodeSize==h){let o=l[e+2].mapInner(n,f,c+1,t[e]+i+1,s);o!=cr?(l[e]=d,l[e+1]=h,l[e+2]=o):(l[e+1]=-2,a=!0)}else a=!0}if(a){let a=function(t,e,n,o,r,i,s){function l(t,e){for(let i=0;i<t.local.length;i++){let l=t.local[i].map(o,r,e);l?n.push(l):s.onRemove&&s.onRemove(t.local[i].spec)}for(let n=0;n<t.children.length;n+=3)l(t.children[n+2],t.children[n]+e+1)}for(let n=0;n<t.length;n+=3)-1==t[n+1]&&l(t[n+2],e[n]+i+1);return n}(l,t,e,n,r,i,s),c=fr(a,o,0,s);e=c.local;for(let t=0;t<l.length;t+=3)l[t+1]<0&&(l.splice(t,3),t-=3);for(let t=0,e=0;t<c.children.length;t+=3){let n=c.children[t];for(;e<l.length&&l[e]<n;)e+=3;l.splice(e,0,c.children[t],c.children[t+1],c.children[t+2])}}return new ar(e.sort(mr),l)}(this.children,i||[],t,e,n,o,r):i?new ar(i.sort(mr),sr):cr}add(t,e){return e.length?this==cr?ar.create(t,e):this.addInner(t,e,0):this}addInner(t,e,n){let o,r=0;t.forEach(((t,i)=>{let s,l=i+n;if(s=pr(e,t,l)){for(o||(o=this.children.slice());r<o.length&&o[r]<i;)r+=3;o[r]==i?o[r+2]=o[r+2].addInner(t,s,l+1):o.splice(r,0,i,i+t.nodeSize,fr(s,t,l+1,lr)),r+=3}}));let i=hr(r?ur(e):e,-n);for(let e=0;e<i.length;e++)i[e].type.valid(t,i[e])||i.splice(e--,1);return new ar(i.length?this.local.concat(i).sort(mr):this.local,o||this.children)}remove(t){return 0==t.length||this==cr?this:this.removeInner(t,0)}removeInner(t,e){let n=this.children,o=this.local;for(let o=0;o<n.length;o+=3){let r,i=n[o]+e,s=n[o+1]+e;for(let e,n=0;n<t.length;n++)(e=t[n])&&e.from>i&&e.to<s&&(t[n]=null,(r||(r=[])).push(e));if(!r)continue;n==this.children&&(n=this.children.slice());let l=n[o+2].removeInner(r,i+1);l!=cr?n[o+2]=l:(n.splice(o,3),o-=3)}if(o.length)for(let n,r=0;r<t.length;r++)if(n=t[r])for(let t=0;t<o.length;t++)o[t].eq(n,e)&&(o==this.local&&(o=this.local.slice()),o.splice(t--,1));return n==this.children&&o==this.local?this:o.length||n.length?new ar(o,n):cr}forChild(t,e){if(this==cr)return this;if(e.isLeaf)return ar.empty;let n,o;for(let e=0;e<this.children.length;e+=3)if(this.children[e]>=t){this.children[e]==t&&(n=this.children[e+2]);break}let r=t+1,i=r+e.content.size;for(let t=0;t<this.local.length;t++){let e=this.local[t];if(e.from<i&&e.to>r&&e.type instanceof or){let t=Math.max(r,e.from)-r,n=Math.min(i,e.to)-r;t<n&&(o||(o=[])).push(e.copy(t,n))}}if(o){let t=new ar(o.sort(mr),sr);return n?new dr([t,n]):t}return n||cr}eq(t){if(this==t)return!0;if(!(t instanceof ar)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(let e=0;e<this.local.length;e++)if(!this.local[e].eq(t.local[e]))return!1;for(let e=0;e<this.children.length;e+=3)if(this.children[e]!=t.children[e]||this.children[e+1]!=t.children[e+1]||!this.children[e+2].eq(t.children[e+2]))return!1;return!0}locals(t){return gr(this.localsInner(t))}localsInner(t){if(this==cr)return sr;if(t.inlineContent||!this.local.some(or.is))return this.local;let e=[];for(let t=0;t<this.local.length;t++)this.local[t].type instanceof or||e.push(this.local[t]);return e}forEachSet(t){t(this)}}ar.empty=new ar([],[]),ar.removeOverlap=gr;const cr=ar.empty;class dr{constructor(t){this.members=t}map(t,e){const n=this.members.map((n=>n.map(t,e,lr)));return dr.from(n)}forChild(t,e){if(e.isLeaf)return ar.empty;let n=[];for(let o=0;o<this.members.length;o++){let r=this.members[o].forChild(t,e);r!=cr&&(r instanceof dr?n=n.concat(r.members):n.push(r))}return dr.from(n)}eq(t){if(!(t instanceof dr)||t.members.length!=this.members.length)return!1;for(let e=0;e<this.members.length;e++)if(!this.members[e].eq(t.members[e]))return!1;return!0}locals(t){let e,n=!0;for(let o=0;o<this.members.length;o++){let r=this.members[o].localsInner(t);if(r.length)if(e){n&&(e=e.slice(),n=!1);for(let t=0;t<r.length;t++)e.push(r[t])}else e=r}return e?gr(n?e:e.sort(mr)):sr}static from(t){switch(t.length){case 0:return cr;case 1:return t[0];default:return new dr(t.every((t=>t instanceof ar))?t:t.reduce(((t,e)=>t.concat(e instanceof ar?e:e.members)),[]))}}forEachSet(t){for(let e=0;e<this.members.length;e++)this.members[e].forEachSet(t)}}function hr(t,e){if(!e||!t.length)return t;let n=[];for(let o=0;o<t.length;o++){let r=t[o];n.push(new ir(r.from+e,r.to+e,r.type))}return n}function pr(t,e,n){if(e.isLeaf)return null;let o=n+e.nodeSize,r=null;for(let e,i=0;i<t.length;i++)(e=t[i])&&e.from>n&&e.to<o&&((r||(r=[])).push(e),t[i]=null);return r}function ur(t){let e=[];for(let n=0;n<t.length;n++)null!=t[n]&&e.push(t[n]);return e}function fr(t,e,n,o){let r=[],i=!1;e.forEach(((e,s)=>{let l=pr(t,e,s+n);if(l){i=!0;let t=fr(l,e,n+s+1,o);t!=cr&&r.push(s,s+e.nodeSize,t)}}));let s=hr(i?ur(t):t,-n).sort(mr);for(let t=0;t<s.length;t++)s[t].type.valid(e,s[t])||(o.onRemove&&o.onRemove(s[t].spec),s.splice(t--,1));return s.length||r.length?new ar(s,r):cr}function mr(t,e){return t.from-e.from||t.to-e.to}function gr(t){let e=t;for(let n=0;n<e.length-1;n++){let o=e[n];if(o.from!=o.to)for(let r=n+1;r<e.length;r++){let i=e[r];if(i.from!=o.from){i.from<o.to&&(e==t&&(e=t.slice()),e[n]=o.copy(o.from,i.from),yr(e,r,o.copy(i.from,o.to)));break}i.to!=o.to&&(e==t&&(e=t.slice()),e[r]=i.copy(i.from,o.to),yr(e,r+1,i.copy(o.to,i.to)))}}return e}function yr(t,e,n){for(;e<t.length&&mr(n,t[e])>0;)e++;t.splice(e,0,n)}function br(t){let e=[];return t.someProp("decorations",(n=>{let o=n(t.state);o&&o!=cr&&e.push(o)})),t.cursorWrapper&&e.push(ar.create(t.state.doc,[t.cursorWrapper.deco])),dr.from(e)}const vr={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},wr=Ve&&We<=11;class kr{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(t){this.anchorNode=t.anchorNode,this.anchorOffset=t.anchorOffset,this.focusNode=t.focusNode,this.focusOffset=t.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(t){return t.anchorNode==this.anchorNode&&t.anchorOffset==this.anchorOffset&&t.focusNode==this.focusNode&&t.focusOffset==this.focusOffset}}class xr{constructor(t,e){this.view=t,this.handleDOMChange=e,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new kr,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver((t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);Ve&&We<=11&&t.some((t=>"childList"==t.type&&t.removedNodes.length||"characterData"==t.type&&t.oldValue.length>t.target.nodeValue.length))?this.flushSoon():this.flush()})),wr&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout((()=>{this.flushingSoon=-1,this.flush()}),20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,vr)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let t=this.observer.takeRecords();if(t.length){for(let e=0;e<t.length;e++)this.queue.push(t[e]);window.setTimeout((()=>this.flush()),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout((()=>this.suppressingSelectionUpdates=!1),50)}onSelectionChange(){if(no(this.view)){if(this.suppressingSelectionUpdates)return Un(this.view);if(Ve&&We<=11&&!this.view.state.selection.empty){let t=this.view.domSelectionRange();if(t.focusNode&&Ne(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(t){if(!t.focusNode)return!0;let e,n=new Set;for(let e=t.focusNode;e;e=Ae(e))n.add(e);for(let o=t.anchorNode;o;o=Ae(o))if(n.has(o)){e=o;break}let o=e&&this.view.docView.nearestDesc(e);return o&&o.ignoreMutation({type:"selection",target:3==e.nodeType?e.parentNode:e})?(this.setCurSelection(),!0):void 0}pendingRecords(){if(this.observer)for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}flush(){let{view:t}=this;if(!t.docView||this.flushingSoon>-1)return;let e=this.pendingRecords();e.length&&(this.queue=[]);let n=t.domSelectionRange(),o=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&no(t)&&!this.ignoreSelectionChange(n),r=-1,i=-1,s=!1,l=[];if(t.editable)for(let t=0;t<e.length;t++){let n=this.registerMutation(e[t],l);n&&(r=r<0?n.from:Math.min(n.from,r),i=i<0?n.to:Math.max(n.to,i),n.typeOver&&(s=!0))}if(qe&&l.length){let e=l.filter((t=>"BR"==t.nodeName));if(2==e.length){let[t,n]=e;t.parentNode&&t.parentNode.parentNode==n.parentNode?n.remove():t.remove()}else{let{focusNode:n}=this.currentSelection;for(let o of e){let e=o.parentNode;!e||"LI"!=e.nodeName||n&&Tr(t,n)==e||o.remove()}}}let a=null;r<0&&o&&t.input.lastFocus>Date.now()-200&&Math.max(t.input.lastTouch,t.input.lastClick.time)<Date.now()-300&&Ie(n)&&(a=Kn(t))&&a.eq(oe.near(t.state.doc.resolve(0),1))?(t.input.lastFocus=0,Un(t),this.currentSelection.set(n),t.scrollToSelection()):(r>-1||o)&&(r>-1&&(t.docView.markDirty(r,i),function(t){if(!Mr.has(t)&&(Mr.set(t,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace))){if(t.requiresGeckoHackNode=qe,Cr)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."),Cr=!0}}(t)),this.handleDOMChange(r,i,s,l),t.docView&&t.docView.dirty?t.updateState(t.state):this.currentSelection.eq(n)||Un(t),this.currentSelection.set(n))}registerMutation(t,e){if(e.indexOf(t.target)>-1)return null;let n=this.view.docView.nearestDesc(t.target);if("attributes"==t.type&&(n==this.view.docView||"contenteditable"==t.attributeName||"style"==t.attributeName&&!t.oldValue&&!t.target.getAttribute("style")))return null;if(!n||n.ignoreMutation(t))return null;if("childList"==t.type){for(let n=0;n<t.addedNodes.length;n++){let o=t.addedNodes[n];e.push(o),3==o.nodeType&&(this.lastChangedTextNode=o)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(t.target))return{from:n.posBefore,to:n.posAfter};let o=t.previousSibling,r=t.nextSibling;if(Ve&&We<=11&&t.addedNodes.length)for(let e=0;e<t.addedNodes.length;e++){let{previousSibling:n,nextSibling:i}=t.addedNodes[e];(!n||Array.prototype.indexOf.call(t.addedNodes,n)<0)&&(o=n),(!i||Array.prototype.indexOf.call(t.addedNodes,i)<0)&&(r=i)}let i=o&&o.parentNode==t.target?Te(o)+1:0,s=n.localPosFromDOM(t.target,i,-1),l=r&&r.parentNode==t.target?Te(r):t.target.childNodes.length;return{from:s,to:n.localPosFromDOM(t.target,l,1)}}return"attributes"==t.type?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:(this.lastChangedTextNode=t.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:t.target.nodeValue==t.oldValue})}}let Mr=new WeakMap,Cr=!1;function Sr(t,e){let n=e.startContainer,o=e.startOffset,r=e.endContainer,i=e.endOffset,s=t.domAtPos(t.state.selection.anchor);return Ne(s.node,s.offset,r,i)&&([n,o,r,i]=[r,i,n,o]),{anchorNode:n,anchorOffset:o,focusNode:r,focusOffset:i}}function Tr(t,e){for(let n=e.parentNode;n&&n!=t.dom;n=n.parentNode){let e=t.docView.nearestDesc(n,!0);if(e&&e.node.isBlock)return n}return null}function Ar(t){let e=t.pmViewDesc;if(e)return e.parseRule();if("BR"==t.nodeName&&t.parentNode){if(Ge&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}if(t.parentNode.lastChild==t||Ge&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if("IMG"==t.nodeName&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const Or=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Er(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:eo(t,e.resolve(n.anchor),e.resolve(n.head))}function Nr(t,e,n){let o=t.depth,r=e?t.end():t.pos;for(;o>0&&(e||t.indexAfter(o)==t.node(o).childCount);)o--,r++,e=!1;if(n){let e=t.node(o).maybeChild(t.indexAfter(o));for(;e&&!e.isLeaf;)e=e.firstChild,r++}return r}function Dr(t){if(2!=t.length)return!1;let e=t.charCodeAt(0),n=t.charCodeAt(1);return e>=56320&&e<=57343&&n>=55296&&n<=56319}class Rr{constructor(t,e){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new Ro,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=e,this.state=e.state,this.directPlugins=e.plugins||[],this.directPlugins.forEach(zr),this.dispatch=this.dispatch.bind(this),this.dom=t&&t.mount||document.createElement("div"),t&&(t.appendChild?t.appendChild(this.dom):"function"==typeof t?t(this.dom):t.mount&&(this.mounted=!0)),this.editable=Ir(this),Lr(this),this.nodeViews=Pr(this),this.docView=Nn(this.state.doc,jr(this),br(this),this.dom,this),this.domObserver=new xr(this,((t,e,n,o)=>function(t,e,n,o,r){let i=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let e=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,n=Kn(t,e);if(n&&!t.state.selection.eq(n)){if(Je&&Ze&&13===t.input.lastKeyCode&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",(e=>e(t,Pe(13,"Enter")))))return;let o=t.state.tr.setSelection(n);"pointer"==e?o.setMeta("pointer",!0):"key"==e&&o.scrollIntoView(),i&&o.setMeta("composition",i),t.dispatch(o)}return}let s=t.state.doc.resolve(e),l=s.sharedDepth(n);e=s.before(l+1),n=t.state.doc.resolve(n).after(l+1);let c,d,h=t.state.selection,p=function(t,e,n){let o,{node:r,fromOffset:i,toOffset:s,from:l,to:a}=t.docView.parseRange(e,n),c=t.domSelectionRange(),d=c.anchorNode;if(d&&t.dom.contains(1==d.nodeType?d:d.parentNode)&&(o=[{node:d,offset:c.anchorOffset}],Ie(c)||o.push({node:c.focusNode,offset:c.focusOffset})),Je&&8===t.input.lastKeyCode)for(let t=s;t>i;t--){let e=r.childNodes[t-1],n=e.pmViewDesc;if("BR"==e.nodeName&&!n){s=t;break}if(!n||n.size)break}let h=t.state.doc,p=t.someProp("domParser")||Z.fromSchema(t.state.schema),u=h.resolve(l),f=null,m=p.parse(r,{topNode:u.parent,topMatch:u.parent.contentMatchAt(u.index()),topOpen:!0,from:i,to:s,preserveWhitespace:"pre"!=u.parent.type.whitespace||"full",findPositions:o,ruleFromNode:Ar,context:u});if(o&&null!=o[0].pos){let t=o[0].pos,e=o[1]&&o[1].pos;null==e&&(e=t),f={anchor:t+l,head:e+l}}return{doc:m,sel:f,from:l,to:a}}(t,e,n),u=t.state.doc,f=u.slice(p.from,p.to);8===t.input.lastKeyCode&&Date.now()-100<t.input.lastKeyCodeTime?(c=t.state.selection.to,d="end"):(c=t.state.selection.from,d="start"),t.input.lastKeyCode=null;let m=function(t,e,n,o,r){let i=t.findDiffStart(e,n);if(null==i)return null;let{a:s,b:l}=t.findDiffEnd(e,n+t.size,n+e.size);if("end"==r&&(o-=s+Math.max(0,i-Math.min(s,l))-i),s<i&&t.size<e.size){let t=o<=i&&o>=s?i-o:0;i-=t,i&&i<e.size&&Dr(e.textBetween(i-1,i+1))&&(i+=t?1:-1),l=i+(l-s),s=i}else if(l<i){let e=o<=i&&o>=l?i-o:0;i-=e,i&&i<t.size&&Dr(t.textBetween(i-1,i+1))&&(i+=e?1:-1),s=i+(s-l),l=i}return{start:i,endA:s,endB:l}}(f.content,p.doc.content,p.from,c,d);if(m&&t.input.domChangeCount++,(Ye&&t.input.lastIOSEnter>Date.now()-225||Ze)&&r.some((t=>1==t.nodeType&&!Or.test(t.nodeName)))&&(!m||m.endA>=m.endB)&&t.someProp("handleKeyDown",(e=>e(t,Pe(13,"Enter")))))return void(t.input.lastIOSEnter=0);if(!m){if(!(o&&h instanceof le&&!h.empty&&h.$head.sameParent(h.$anchor))||t.composing||p.sel&&p.sel.anchor!=p.sel.head){if(p.sel){let e=Er(t,t.state.doc,p.sel);if(e&&!e.eq(t.state.selection)){let n=t.state.tr.setSelection(e);i&&n.setMeta("composition",i),t.dispatch(n)}}return}m={start:h.from,endA:h.to,endB:h.to}}t.state.selection.from<t.state.selection.to&&m.start==m.endB&&t.state.selection instanceof le&&(m.start>t.state.selection.from&&m.start<=t.state.selection.from+2&&t.state.selection.from>=p.from?m.start=t.state.selection.from:m.endA<t.state.selection.to&&m.endA>=t.state.selection.to-2&&t.state.selection.to<=p.to&&(m.endB+=t.state.selection.to-m.endA,m.endA=t.state.selection.to)),Ve&&We<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>p.from&&"  "==p.doc.textBetween(m.start-p.from-1,m.start-p.from+1)&&(m.start--,m.endA--,m.endB--);let g,y=p.doc.resolveNoCache(m.start-p.from),b=p.doc.resolveNoCache(m.endB-p.from),v=u.resolve(m.start),w=y.sameParent(b)&&y.parent.inlineContent&&v.end()>=m.endA;if((Ye&&t.input.lastIOSEnter>Date.now()-225&&(!w||r.some((t=>"DIV"==t.nodeName||"P"==t.nodeName)))||!w&&y.pos<p.doc.content.size&&!y.sameParent(b)&&(g=oe.findFrom(p.doc.resolve(y.pos+1),1,!0))&&g.head==b.pos)&&t.someProp("handleKeyDown",(e=>e(t,Pe(13,"Enter")))))return void(t.input.lastIOSEnter=0);if(t.state.selection.anchor>m.start&&function(t,e,n,o,r){if(n-e<=r.pos-o.pos||Nr(o,!0,!1)<r.pos)return!1;let i=t.resolve(e);if(!o.parent.isTextblock){let t=i.nodeAfter;return null!=t&&n==e+t.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let s=t.resolve(Nr(i,!0,!0));return!(!s.parent.isTextblock||s.pos>n||Nr(s,!0,!1)<n)&&o.parent.content.cut(o.parentOffset).eq(s.parent.content)}(u,m.start,m.endA,y,b)&&t.someProp("handleKeyDown",(e=>e(t,Pe(8,"Backspace")))))return void(Ze&&Je&&t.domObserver.suppressSelectionUpdates());Je&&m.endB==m.start&&(t.input.lastChromeDelete=Date.now()),Ze&&!w&&y.start()!=b.start()&&0==b.parentOffset&&y.depth==b.depth&&p.sel&&p.sel.anchor==p.sel.head&&p.sel.head==m.endA&&(m.endB-=2,b=p.doc.resolveNoCache(m.endB-p.from),setTimeout((()=>{t.someProp("handleKeyDown",(function(e){return e(t,Pe(13,"Enter"))}))}),20));let k,x,M,C=m.start,S=m.endA;if(w)if(y.pos==b.pos)Ve&&We<=11&&0==y.parentOffset&&(t.domObserver.suppressSelectionUpdates(),setTimeout((()=>Un(t)),20)),k=t.state.tr.delete(C,S),x=u.resolve(m.start).marksAcross(u.resolve(m.endA));else if(m.endA==m.endB&&(M=function(t,e){let n,o,r,i=t.firstChild.marks,s=e.firstChild.marks,l=i,c=s;for(let t=0;t<s.length;t++)l=s[t].removeFromSet(l);for(let t=0;t<i.length;t++)c=i[t].removeFromSet(c);if(1==l.length&&0==c.length)o=l[0],n="add",r=t=>t.mark(o.addToSet(t.marks));else{if(0!=l.length||1!=c.length)return null;o=c[0],n="remove",r=t=>t.mark(o.removeFromSet(t.marks))}let d=[];for(let t=0;t<e.childCount;t++)d.push(r(e.child(t)));if(a.from(d).eq(t))return{mark:o,type:n}}(y.parent.content.cut(y.parentOffset,b.parentOffset),v.parent.content.cut(v.parentOffset,m.endA-v.start()))))k=t.state.tr,"add"==M.type?k.addMark(C,S,M.mark):k.removeMark(C,S,M.mark);else if(y.parent.child(y.index()).isText&&y.index()==b.index()-(b.textOffset?0:1)){let e=y.parent.textBetween(y.parentOffset,b.parentOffset);if(t.someProp("handleTextInput",(n=>n(t,C,S,e))))return;k=t.state.tr.insertText(e,C,S)}if(k||(k=t.state.tr.replace(C,S,p.doc.slice(m.start-p.from,m.endB-p.from))),p.sel){let e=Er(t,k.doc,p.sel);e&&!(Je&&t.composing&&e.empty&&(m.start!=m.endB||t.input.lastChromeDelete<Date.now()-100)&&(e.head==C||e.head==k.mapping.map(S)-1)||Ve&&e.empty&&e.head==C)&&k.setSelection(e)}x&&k.ensureMarks(x),i&&k.setMeta("composition",i),t.dispatch(k.scrollIntoView())}(this,t,e,n,o))),this.domObserver.start(),function(t){for(let e in Eo){let n=Eo[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=e=>{!Po(t,e)||Io(t,e)||!t.editable&&e.type in No||n(t,e)},Do[e]?{passive:!0}:void 0)}Ge&&t.dom.addEventListener("input",(()=>null)),Lo(t)}(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let t=this._props;this._props={};for(let e in t)this._props[e]=t[e];this._props.state=this.state}return this._props}update(t){t.handleDOMEvents!=this._props.handleDOMEvents&&Lo(this);let e=this._props;this._props=t,t.plugins&&(t.plugins.forEach(zr),this.directPlugins=t.plugins),this.updateStateInner(t.state,e)}setProps(t){let e={};for(let t in this._props)e[t]=this._props[t];e.state=this.state;for(let n in t)e[n]=t[n];this.update(e)}updateState(t){this.updateStateInner(t,this._props)}updateStateInner(t,e){var n;let o=this.state,r=!1,i=!1;t.storedMarks&&this.composing&&(Uo(this),i=!0),this.state=t;let s=o.plugins!=t.plugins||this._props.plugins!=e.plugins;if(s||this._props.plugins!=e.plugins||this._props.nodeViews!=e.nodeViews){let t=Pr(this);(function(t,e){let n=0,o=0;for(let o in t){if(t[o]!=e[o])return!0;n++}for(let t in e)o++;return n!=o})(t,this.nodeViews)&&(this.nodeViews=t,r=!0)}(s||e.handleDOMEvents!=this._props.handleDOMEvents)&&Lo(this),this.editable=Ir(this),Lr(this);let l=br(this),a=jr(this),c=o.plugins==t.plugins||o.doc.eq(t.doc)?t.scrollToSelection>o.scrollToSelection?"to selection":"preserve":"reset",d=r||!this.docView.matchesNode(t.doc,a,l);!d&&t.selection.eq(o.selection)||(i=!0);let h="preserve"==c&&i&&null==this.dom.style.overflowAnchor&&function(t){let e,n,o=t.dom.getBoundingClientRect(),r=Math.max(0,o.top);for(let i=(o.left+o.right)/2,s=r+1;s<Math.min(innerHeight,o.bottom);s+=5){let o=t.root.elementFromPoint(i,s);if(!o||o==t.dom||!t.dom.contains(o))continue;let l=o.getBoundingClientRect();if(l.top>=r-20){e=o,n=l.top;break}}return{refDOM:e,refTop:n,stack:ln(t.dom)}}(this);if(i){this.domObserver.stop();let e=d&&(Ve||Je)&&!this.composing&&!o.selection.empty&&!t.selection.empty&&function(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}(o.selection,t.selection);if(d){let n=Je?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=function(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=function(t,e){for(;;){if(3==t.nodeType&&e)return t;if(1==t.nodeType&&e>0){if("false"==t.contentEditable)return null;e=je(t=t.childNodes[e-1])}else{if(!t.parentNode||Le(t))return null;e=Te(t),t=t.parentNode}}}(e.focusNode,e.focusOffset),o=function(t,e){for(;;){if(3==t.nodeType&&e<t.nodeValue.length)return t;if(1==t.nodeType&&e<t.childNodes.length){if("false"==t.contentEditable)return null;t=t.childNodes[e],e=0}else{if(!t.parentNode||Le(t))return null;e=Te(t)+1,t=t.parentNode}}}(e.focusNode,e.focusOffset);if(n&&o&&n!=o){let e=o.pmViewDesc,r=t.domObserver.lastChangedTextNode;if(n==r||o==r)return r;if(!e||!e.isText(o.nodeValue))return o;if(t.input.compositionNode==o){let t=n.pmViewDesc;if(t&&t.isText(n.nodeValue))return o}}return n||o}(this)),!r&&this.docView.update(t.doc,a,l,this)||(this.docView.updateOuterDeco(a),this.docView.destroy(),this.docView=Nn(t.doc,a,l,this.dom,this)),n&&!this.trackWrites&&(e=!0)}e||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&function(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Ne(e.node,e.offset,n.anchorNode,n.anchorOffset)}(this))?Un(this,e):(Zn(this,t.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(o),(null===(n=this.dragging)||void 0===n?void 0:n.node)&&!o.doc.eq(t.doc)&&this.updateDraggedNode(this.dragging,o),"reset"==c?this.dom.scrollTop=0:"to selection"==c?this.scrollToSelection():h&&function({refDOM:t,refTop:e,stack:n}){let o=t?t.getBoundingClientRect().top:0;an(n,0==o?0:o-e)}(h)}scrollToSelection(){let t=this.domSelectionRange().focusNode;if(t&&this.dom.contains(1==t.nodeType?t:t.parentNode))if(this.someProp("handleScrollToSelection",(t=>t(this))));else if(this.state.selection instanceof ce){let e=this.docView.domAfterPos(this.state.selection.from);1==e.nodeType&&sn(this,e.getBoundingClientRect(),t)}else sn(this,this.coordsAtPos(this.state.selection.head,1),t)}destroyPluginViews(){let t;for(;t=this.pluginViews.pop();)t.destroy&&t.destroy()}updatePluginViews(t){if(t&&t.plugins==this.state.plugins&&this.directPlugins==this.prevDirectPlugins)for(let e=0;e<this.pluginViews.length;e++){let n=this.pluginViews[e];n.update&&n.update(this,t)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let e=this.directPlugins[t];e.spec.view&&this.pluginViews.push(e.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let e=this.state.plugins[t];e.spec.view&&this.pluginViews.push(e.spec.view(this))}}}updateDraggedNode(t,e){let n=t.node,o=-1;if(this.state.doc.nodeAt(n.from)==n.node)o=n.from;else{let t=n.from+(this.state.doc.content.size-e.doc.content.size);(t>0&&this.state.doc.nodeAt(t))==n.node&&(o=t)}this.dragging=new Zo(t.slice,t.move,o<0?void 0:ce.create(this.state.doc,o))}someProp(t,e){let n,o=this._props&&this._props[t];if(null!=o&&(n=e?e(o):o))return n;for(let o=0;o<this.directPlugins.length;o++){let r=this.directPlugins[o].props[t];if(null!=r&&(n=e?e(r):r))return n}let r=this.state.plugins;if(r)for(let o=0;o<r.length;o++){let i=r[o].props[t];if(null!=i&&(n=e?e(i):i))return n}}hasFocus(){if(Ve){let t=this.root.activeElement;if(t==this.dom)return!0;if(!t||!this.dom.contains(t))return!1;for(;t&&this.dom!=t&&this.dom.contains(t);){if("false"==t.contentEditable)return!1;t=t.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&function(t){if(t.setActive)return t.setActive();if(cn)return t.focus(cn);let e=ln(t);t.focus(null==cn?{get preventScroll(){return cn={preventScroll:!0},!0}}:void 0),cn||(cn=!1,an(e,0))}(this.dom),Un(this),this.domObserver.start()}get root(){let t=this._root;if(null==t)for(let t=this.dom.parentNode;t;t=t.parentNode)if(9==t.nodeType||11==t.nodeType&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t;return t||document}updateRoot(){this._root=null}posAtCoords(t){return un(this,t)}coordsAtPos(t,e=1){return yn(this,t,e)}domAtPos(t,e=0){return this.docView.domFromPos(t,e)}nodeDOM(t){let e=this.docView.descAt(t);return e?e.nodeDOM:null}posAtDOM(t,e,n=-1){let o=this.docView.posFromDOM(t,e,n);if(null==o)throw new RangeError("DOM position not inside the editor");return o}endOfTextblock(t,e){return function(t,e,n){return xn==e&&Mn==n?Cn:(xn=e,Mn=n,Cn="up"==n||"down"==n?function(t,e,n){let o=e.selection,r="up"==n?o.$from:o.$to;return wn(t,e,(()=>{let{node:e}=t.docView.domFromPos(r.pos,"up"==n?-1:1);for(;;){let n=t.docView.nearestDesc(e,!0);if(!n)break;if(n.node.isBlock){e=n.contentDOM||n.dom;break}e=n.dom.parentNode}let o=yn(t,r.pos,1);for(let t=e.firstChild;t;t=t.nextSibling){let e;if(1==t.nodeType)e=t.getClientRects();else{if(3!=t.nodeType)continue;e=Ee(t,0,t.nodeValue.length).getClientRects()}for(let t=0;t<e.length;t++){let r=e[t];if(r.bottom>r.top+1&&("up"==n?o.top-r.top>2*(r.bottom-o.top):r.bottom-o.bottom>2*(o.bottom-r.top)))return!1}}return!0}))}(t,e,n):function(t,e,n){let{$head:o}=e.selection;if(!o.parent.isTextblock)return!1;let r=o.parentOffset,i=!r,s=r==o.parent.content.size,l=t.domSelection();return l?kn.test(o.parent.textContent)&&l.modify?wn(t,e,(()=>{let{focusNode:e,focusOffset:r,anchorNode:i,anchorOffset:s}=t.domSelectionRange(),a=l.caretBidiLevel;l.modify("move",n,"character");let c=o.depth?t.docView.domAfterPos(o.before()):t.dom,{focusNode:d,focusOffset:h}=t.domSelectionRange(),p=d&&!c.contains(1==d.nodeType?d:d.parentNode)||e==d&&r==h;try{l.collapse(i,s),e&&(e!=i||r!=s)&&l.extend&&l.extend(e,r)}catch(t){}return null!=a&&(l.caretBidiLevel=a),p})):"left"==n||"backward"==n?i:s:o.pos==o.start()||o.pos==o.end()}(t,e,n))}(this,e||this.state,t)}pasteHTML(t,e){return Xo(this,"",t,!1,e||new ClipboardEvent("paste"))}pasteText(t,e){return Xo(this,t,null,!0,e||new ClipboardEvent("paste"))}serializeForClipboard(t){return yo(this,t)}destroy(){this.docView&&(function(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],br(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Oe=null)}get isDestroyed(){return null==this.docView}dispatchEvent(t){return function(t,e){Io(t,e)||!Eo[e.type]||!t.editable&&e.type in No||Eo[e.type](t,e)}(this,t)}dispatch(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))}domSelectionRange(){let t=this.domSelection();return t?Ge&&11===this.root.nodeType&&function(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}(this.dom.ownerDocument)==this.dom&&function(t,e){if(e.getComposedRanges){let n=e.getComposedRanges(t.root)[0];if(n)return Sr(t,n)}let n;function o(t){t.preventDefault(),t.stopImmediatePropagation(),n=t.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",o,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",o,!0),n?Sr(t,n):null}(this,t)||t:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function jr(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",(n=>{if("function"==typeof n&&(n=n(t.state)),n)for(let t in n)"class"==t?e.class+=" "+n[t]:"style"==t?e.style=(e.style?e.style+";":"")+n[t]:e[t]||"contenteditable"==t||"nodeName"==t||(e[t]=String(n[t]))})),e.translate||(e.translate="no"),[ir.node(0,t.state.doc.content.size,e)]}function Lr(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:ir.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function Ir(t){return!t.someProp("editable",(e=>!1===e(t.state)))}function Pr(t){let e=Object.create(null);function n(t){for(let n in t)Object.prototype.hasOwnProperty.call(e,n)||(e[n]=t[n])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function zr(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}for(var $r={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:"'"},Hr={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Br="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),_r="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Fr=0;Fr<10;Fr++)$r[48+Fr]=$r[96+Fr]=String(Fr);for(Fr=1;Fr<=24;Fr++)$r[Fr+111]="F"+Fr;for(Fr=65;Fr<=90;Fr++)$r[Fr]=String.fromCharCode(Fr+32),Hr[Fr]=String.fromCharCode(Fr);for(var Vr in $r)Hr.hasOwnProperty(Vr)||(Hr[Vr]=$r[Vr]);const Wr="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform);function qr(t){let e,n,o,r,i=t.split(/-(?!$)/),s=i[i.length-1];"Space"==s&&(s=" ");for(let t=0;t<i.length-1;t++){let s=i[t];if(/^(cmd|meta|m)$/i.test(s))r=!0;else if(/^a(lt)?$/i.test(s))e=!0;else if(/^(c|ctrl|control)$/i.test(s))n=!0;else if(/^s(hift)?$/i.test(s))o=!0;else{if(!/^mod$/i.test(s))throw new Error("Unrecognized modifier name: "+s);Wr?r=!0:n=!0}}return e&&(s="Alt-"+s),n&&(s="Ctrl-"+s),r&&(s="Meta-"+s),o&&(s="Shift-"+s),s}function Kr(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 Jr(t){let e=function(t){let e=Object.create(null);for(let n in t)e[qr(n)]=t[n];return e}(t);return function(t,n){let o,r=function(t){var e=!(Br&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||_r&&t.shiftKey&&t.key&&1==t.key.length||"Unidentified"==t.key)&&t.key||(t.shiftKey?Hr:$r)[t.keyCode]||t.key||"Unidentified";return"Esc"==e&&(e="Escape"),"Del"==e&&(e="Delete"),"Left"==e&&(e="ArrowLeft"),"Up"==e&&(e="ArrowUp"),"Right"==e&&(e="ArrowRight"),"Down"==e&&(e="ArrowDown"),e}(n),i=e[Kr(r,n)];if(i&&i(t.state,t.dispatch,t))return!0;if(1==r.length&&" "!=r){if(n.shiftKey){let o=e[Kr(r,n,!1)];if(o&&o(t.state,t.dispatch,t))return!0}if((n.shiftKey||n.altKey||n.metaKey||r.charCodeAt(0)>127)&&(o=$r[n.keyCode])&&o!=r){let r=e[Kr(o,n)];if(r&&r(t.state,t.dispatch,t))return!0}}return!1}}const Ur=(t,e)=>!t.selection.empty&&(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function Gr(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const Yr=(t,e,n)=>{let o=Gr(t,n);if(!o)return!1;let r=ti(o);if(!r){let n=o.blockRange(),r=n&&Rt(n);return null!=r&&(e&&e(t.tr.lift(n,r).scrollIntoView()),!0)}let i=r.nodeBefore;if(hi(t,r,e,-1))return!0;if(0==o.parent.content.size&&(Qr(i,"end")||ce.isSelectable(i)))for(let n=o.depth;;n--){let s=Ft(t.doc,o.before(n),o.after(n),f.empty);if(s&&s.slice.size<s.to-s.from){if(e){let n=t.tr.step(s);n.setSelection(Qr(i,"end")?oe.findFrom(n.doc.resolve(n.mapping.map(r.pos,-1)),-1):ce.create(n.doc,r.pos-i.nodeSize)),e(n.scrollIntoView())}return!0}if(1==n||o.node(n-1).childCount>1)break}return!(!i.isAtom||r.depth!=o.depth-1||(e&&e(t.tr.delete(r.pos-i.nodeSize,r.pos).scrollIntoView()),0))};function Xr(t,e,n){let o=e.nodeBefore,r=e.pos-1;for(;!o.isTextblock;r--){if(o.type.spec.isolating)return!1;let t=o.lastChild;if(!t)return!1;o=t}let i=e.nodeAfter,s=e.pos+1;for(;!i.isTextblock;s++){if(i.type.spec.isolating)return!1;let t=i.firstChild;if(!t)return!1;i=t}let l=Ft(t.doc,r,s,f.empty);if(!l||l.from!=r||l instanceof At&&l.slice.size>=s-r)return!1;if(n){let e=t.tr.step(l);e.setSelection(le.create(e.doc,r)),n(e.scrollIntoView())}return!0}function Qr(t,e,n=!1){for(let o=t;o;o="start"==e?o.firstChild:o.lastChild){if(o.isTextblock)return!0;if(n&&1!=o.childCount)return!1}return!1}const Zr=(t,e,n)=>{let{$head:o,empty:r}=t.selection,i=o;if(!r)return!1;if(o.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):o.parentOffset>0)return!1;i=ti(o)}let s=i&&i.nodeBefore;return!(!s||!ce.isSelectable(s)||(e&&e(t.tr.setSelection(ce.create(t.doc,i.pos-s.nodeSize)).scrollIntoView()),0))};function ti(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 ei(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const ni=(t,e,n)=>{let o=ei(t,n);if(!o)return!1;let r=ri(o);if(!r)return!1;let i=r.nodeAfter;if(hi(t,r,e,1))return!0;if(0==o.parent.content.size&&(Qr(i,"start")||ce.isSelectable(i))){let n=Ft(t.doc,o.before(),o.after(),f.empty);if(n&&n.slice.size<n.to-n.from){if(e){let o=t.tr.step(n);o.setSelection(Qr(i,"start")?oe.findFrom(o.doc.resolve(o.mapping.map(r.pos)),1):ce.create(o.doc,o.mapping.map(r.pos))),e(o.scrollIntoView())}return!0}}return!(!i.isAtom||r.depth!=o.depth-1||(e&&e(t.tr.delete(r.pos,r.pos+i.nodeSize).scrollIntoView()),0))},oi=(t,e,n)=>{let{$head:o,empty:r}=t.selection,i=o;if(!r)return!1;if(o.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):o.parentOffset<o.parent.content.size)return!1;i=ri(o)}let s=i&&i.nodeAfter;return!(!s||!ce.isSelectable(s)||(e&&e(t.tr.setSelection(ce.create(t.doc,i.pos)).scrollIntoView()),0))};function ri(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let n=t.node(e);if(t.index(e)+1<n.childCount)return t.doc.resolve(t.after(e+1));if(n.type.spec.isolating)break}return null}const ii=(t,e)=>{let{$head:n,$anchor:o}=t.selection;return!(!n.parent.type.spec.code||!n.sameParent(o)||(e&&e(t.tr.insertText("\n").scrollIntoView()),0))};function si(t){for(let e=0;e<t.edgeCount;e++){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const li=(t,e)=>{let{$head:n,$anchor:o}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(o))return!1;let r=n.node(-1),i=n.indexAfter(-1),s=si(r.contentMatchAt(i));if(!s||!r.canReplaceWith(i,i,s))return!1;if(e){let o=n.after(),r=t.tr.replaceWith(o,o,s.createAndFill());r.setSelection(oe.near(r.doc.resolve(o),1)),e(r.scrollIntoView())}return!0},ai=(t,e)=>{let n=t.selection,{$from:o,$to:r}=n;if(n instanceof he||o.parent.inlineContent||r.parent.inlineContent)return!1;let i=si(r.parent.contentMatchAt(r.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let n=(!o.parentOffset&&r.index()<r.parent.childCount?o:r).pos,s=t.tr.insert(n,i.createAndFill());s.setSelection(le.create(s.doc,n+1)),e(s.scrollIntoView())}return!0},ci=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let o=n.before();if(zt(t.doc,o))return e&&e(t.tr.split(o).scrollIntoView()),!0}let o=n.blockRange(),r=o&&Rt(o);return null!=r&&(e&&e(t.tr.lift(o,r).scrollIntoView()),!0)};var di;function hi(t,e,n,o){let r,i,s=e.nodeBefore,l=e.nodeAfter,c=s.type.spec.isolating||l.type.spec.isolating;if(!c&&function(t,e,n){let o=e.nodeBefore,r=e.nodeAfter,i=e.index();return!(!(o&&r&&o.type.compatibleContent(r.type))||(!o.content.size&&e.parent.canReplace(i-1,i)?(n&&n(t.tr.delete(e.pos-o.nodeSize,e.pos).scrollIntoView()),0):!e.parent.canReplace(i,i+1)||!r.isTextblock&&!$t(t.doc,e.pos)||(n&&n(t.tr.join(e.pos).scrollIntoView()),0)))}(t,e,n))return!0;let d=!c&&e.parent.canReplace(e.index(),e.index()+1);if(d&&(r=(i=s.contentMatchAt(s.childCount)).findWrapping(l.type))&&i.matchType(r[0]||l.type).validEnd){if(n){let o=e.pos+l.nodeSize,i=a.empty;for(let t=r.length-1;t>=0;t--)i=a.from(r[t].create(null,i));i=a.from(s.copy(i));let c=t.tr.step(new Ot(e.pos-1,o,e.pos,o,new f(i,1,0),r.length,!0)),d=c.doc.resolve(o+2*r.length);d.nodeAfter&&d.nodeAfter.type==s.type&&$t(c.doc,d.pos)&&c.join(d.pos),n(c.scrollIntoView())}return!0}let h=l.type.spec.isolating||o>0&&c?null:oe.findFrom(e,1),p=h&&h.$from.blockRange(h.$to),u=p&&Rt(p);if(null!=u&&u>=e.depth)return n&&n(t.tr.lift(p,u).scrollIntoView()),!0;if(d&&Qr(l,"start",!0)&&Qr(s,"end")){let o=s,r=[];for(;r.push(o),!o.isTextblock;)o=o.lastChild;let i=l,c=1;for(;!i.isTextblock;i=i.firstChild)c++;if(o.canReplace(o.childCount,o.childCount,i.content)){if(n){let o=a.empty;for(let t=r.length-1;t>=0;t--)o=a.from(r[t].copy(o));n(t.tr.step(new Ot(e.pos-r.length,e.pos+l.nodeSize,e.pos+c,e.pos+l.nodeSize-c,new f(o,r.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function pi(t){return function(e,n){let o=e.selection,r=t<0?o.$from:o.$to,i=r.depth;for(;r.node(i).isInline;){if(!i)return!1;i--}return!!r.node(i).isTextblock&&(n&&n(e.tr.setSelection(le.create(e.doc,t<0?r.start(i):r.end(i)))),!0)}}const ui=pi(-1),fi=pi(1);function mi(t,e=null){return function(n,o){let r=!1;for(let o=0;o<n.selection.ranges.length&&!r;o++){let{$from:{pos:i},$to:{pos:s}}=n.selection.ranges[o];n.doc.nodesBetween(i,s,((o,i)=>{if(r)return!1;if(o.isTextblock&&!o.hasMarkup(t,e))if(o.type==t)r=!0;else{let e=n.doc.resolve(i),o=e.index();r=e.parent.canReplaceWith(o,o+1,t)}}))}if(!r)return!1;if(o){let r=n.tr;for(let o=0;o<n.selection.ranges.length;o++){let{$from:{pos:i},$to:{pos:s}}=n.selection.ranges[o];r.setBlockType(i,s,t,e)}o(r.scrollIntoView())}return!0}}function gi(...t){return function(e,n,o){for(let r=0;r<t.length;r++)if(t[r](e,n,o))return!0;return!1}}let yi=gi(Ur,Yr,Zr),bi=gi(Ur,ni,oi);const vi={Enter:gi(ii,ai,ci,((t,e)=>{let{$from:n,$to:o}=t.selection;if(t.selection instanceof ce&&t.selection.node.isBlock)return!(!n.parentOffset||!zt(t.doc,n.pos)||(e&&e(t.tr.split(n.pos).scrollIntoView()),0));if(!n.depth)return!1;let r,i,s=[],l=!1,a=!1;for(let t=n.depth;;t--){if(n.node(t).isBlock){l=n.end(t)==n.pos+(n.depth-t),a=n.start(t)==n.pos-(n.depth-t),i=si(n.node(t-1).contentMatchAt(n.indexAfter(t-1)));let e=di;s.unshift(e||(l&&i?{type:i}:null)),r=t;break}if(1==t)return!1;s.unshift(null)}let c=t.tr;(t.selection instanceof le||t.selection instanceof he)&&c.deleteSelection();let d=c.mapping.map(n.pos),h=zt(c.doc,d,s.length,s);if(h||(s[0]=i?{type:i}:null,h=zt(c.doc,d,s.length,s)),c.split(d,s.length,s),!l&&a&&n.node(r).type!=i){let t=c.mapping.map(n.before(r)),e=c.doc.resolve(t);i&&n.node(r-1).canReplaceWith(e.index(),e.index()+1,i)&&c.setNodeMarkup(c.mapping.map(n.before(r)),i)}return e&&e(c.scrollIntoView()),!0})),"Mod-Enter":li,Backspace:yi,"Mod-Backspace":yi,"Shift-Backspace":yi,Delete:bi,"Mod-Delete":bi,"Mod-a":(t,e)=>(e&&e(t.tr.setSelection(new he(t.doc))),!0)},wi={"Ctrl-h":vi.Backspace,"Alt-Backspace":vi["Mod-Backspace"],"Ctrl-d":vi.Delete,"Ctrl-Alt-Backspace":vi["Mod-Delete"],"Alt-Delete":vi["Mod-Delete"],"Alt-d":vi["Mod-Delete"],"Ctrl-a":ui,"Ctrl-e":fi};for(let t in vi)wi[t]=vi[t];function ki(t){const{state:e,transaction:n}=t;let{selection:o}=n,{doc:r}=n,{storedMarks:i}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return i},get selection(){return o},get doc(){return r},get tr(){return o=n.selection,r=n.doc,i=n.storedMarks,n}}}"undefined"!=typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):"undefined"!=typeof os&&os.platform&&os.platform();class xi{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:o}=e,{tr:r}=n,i=this.buildProps(r);return Object.fromEntries(Object.entries(t).map((([t,e])=>[t,(...t)=>{const n=e(...t)(i);return r.getMeta("preventDispatch")||this.hasCustomState||o.dispatch(r),n}])))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:o,state:r}=this,{view:i}=o,s=[],l=!!t,a=t||r.tr,c={...Object.fromEntries(Object.entries(n).map((([t,n])=>[t,(...t)=>{const o=this.buildProps(a,e),r=n(...t)(o);return s.push(r),c}]))),run:()=>(l||!e||a.getMeta("preventDispatch")||this.hasCustomState||i.dispatch(a),s.every((t=>!0===t)))};return c}createCan(t){const{rawCommands:e,state:n}=this,o=!1,r=t||n.tr,i=this.buildProps(r,o);return{...Object.fromEntries(Object.entries(e).map((([t,e])=>[t,(...t)=>e(...t)({...i,dispatch:void 0})]))),chain:()=>this.createChain(r,o)}}buildProps(t,e=!0){const{rawCommands:n,editor:o,state:r}=this,{view:i}=o,s={tr:t,editor:o,view:i,state:ki({state:r,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map((([t,e])=>[t,(...t)=>e(...t)(s)])))}};return s}}class Mi{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const n=this.callbacks[t];return n&&n.forEach((t=>t.apply(this,e))),this}off(t,e){const n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter((t=>t!==e)):delete this.callbacks[t]),this}once(t,e){const n=(...o)=>{this.off(t,n),e.apply(this,o)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}}function Ci(t,e,n){return void 0===t.config[e]&&t.parent?Ci(t.parent,e,n):"function"==typeof t.config[e]?t.config[e].bind({...n,parent:t.parent?Ci(t.parent,e,n):null}):t.config[e]}function Si(t){return{baseExtensions:t.filter((t=>"extension"===t.type)),nodeExtensions:t.filter((t=>"node"===t.type)),markExtensions:t.filter((t=>"mark"===t.type))}}function Ti(t){const e=[],{nodeExtensions:n,markExtensions:o}=Si(t),r=[...n,...o],i={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach((t=>{const n=Ci(t,"addGlobalAttributes",{name:t.name,options:t.options,storage:t.storage,extensions:r});n&&n().forEach((t=>{t.types.forEach((n=>{Object.entries(t.attributes).forEach((([t,o])=>{e.push({type:n,name:t,attribute:{...i,...o}})}))}))}))})),r.forEach((t=>{const n={name:t.name,options:t.options,storage:t.storage},o=Ci(t,"addAttributes",n);if(!o)return;const r=o();Object.entries(r).forEach((([n,o])=>{const r={...i,...o};"function"==typeof(null==r?void 0:r.default)&&(r.default=r.default()),(null==r?void 0:r.isRequired)&&void 0===(null==r?void 0:r.default)&&delete r.default,e.push({type:t.name,name:n,attribute:r})}))})),e}function Ai(t,e){if("string"==typeof t){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}function Oi(...t){return t.filter((t=>!!t)).reduce(((t,e)=>{const n={...t};return Object.entries(e).forEach((([t,e])=>{if(n[t])if("class"===t){const o=e?String(e).split(" "):[],r=n[t]?n[t].split(" "):[],i=o.filter((t=>!r.includes(t)));n[t]=[...r,...i].join(" ")}else if("style"===t){const o=e?e.split(";").map((t=>t.trim())).filter(Boolean):[],r=n[t]?n[t].split(";").map((t=>t.trim())).filter(Boolean):[],i=new Map;r.forEach((t=>{const[e,n]=t.split(":").map((t=>t.trim()));i.set(e,n)})),o.forEach((t=>{const[e,n]=t.split(":").map((t=>t.trim()));i.set(e,n)})),n[t]=Array.from(i.entries()).map((([t,e])=>`${t}: ${e}`)).join("; ")}else n[t]=e;else n[t]=e})),n}),{})}function Ei(t,e){return e.filter((e=>e.type===t.type.name)).filter((t=>t.attribute.rendered)).map((e=>e.attribute.renderHTML?e.attribute.renderHTML(t.attrs)||{}:{[e.name]:t.attrs[e.name]})).reduce(((t,e)=>Oi(t,e)),{})}function Ni(t){return"function"==typeof t}function Di(t,e=void 0,...n){return Ni(t)?e?t.bind(e)(...n):t(...n):t}function Ri(t,e){return"style"in t?t:{...t,getAttrs:n=>{const o=t.getAttrs?t.getAttrs(n):t.attrs;if(!1===o)return!1;const r=e.reduce(((t,e)=>{const o=e.attribute.parseHTML?e.attribute.parseHTML(n):function(t){return"string"!=typeof t?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):"true"===t||"false"!==t&&t}(n.getAttribute(e.name));return null==o?t:{...t,[e.name]:o}}),{});return{...o,...r}}}}function ji(t){return Object.fromEntries(Object.entries(t).filter((([t,e])=>("attrs"!==t||!function(t={}){return 0===Object.keys(t).length&&t.constructor===Object}(e))&&null!=e)))}function Li(t,e){return e.nodes[t]||e.marks[t]||null}function Ii(t,e){return Array.isArray(e)?e.some((e=>("string"==typeof e?e:e.name)===t.name)):e}function Pi(t,e){const n=ct.fromSchema(e).serializeFragment(t),o=document.implementation.createHTMLDocument().createElement("div");return o.appendChild(n),o.innerHTML}function zi(t){return"[object RegExp]"===Object.prototype.toString.call(t)}class $i{constructor(t){this.find=t.find,this.handler=t.handler}}function Hi(t){var e;const{editor:n,from:o,to:r,text:i,rules:s,plugin:l}=t,{view:a}=n;if(a.composing)return!1;const c=a.state.doc.resolve(o);if(c.parent.type.spec.code||(null===(e=c.nodeBefore||c.nodeAfter)||void 0===e?void 0:e.marks.find((t=>t.type.spec.code))))return!1;let d=!1;const h=((t,e=500)=>{let n="";const o=t.parentOffset;return t.parent.nodesBetween(Math.max(0,o-e),o,((t,e,r,i)=>{var s,l;const a=(null===(l=(s=t.type.spec).toText)||void 0===l?void 0:l.call(s,{node:t,pos:e,parent:r,index:i}))||t.textContent||"%leaf%";n+=t.isAtom&&!t.isText?a:a.slice(0,Math.max(0,o-e))})),n})(c)+i;return s.forEach((t=>{if(d)return;const e=((t,e)=>{if(zi(e))return e.exec(t);const n=e(t);if(!n)return null;const o=[n.text];return o.index=n.index,o.input=t,o.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),o.push(n.replaceWith)),o})(h,t.find);if(!e)return;const s=a.state.tr,c=ki({state:a.state,transaction:s}),p={from:o-(e[0].length-i.length),to:r},{commands:u,chain:f,can:m}=new xi({editor:n,state:c});null!==t.handler({state:c,range:p,match:e,commands:u,chain:f,can:m})&&s.steps.length&&(s.setMeta(l,{transform:s,from:o,to:r,text:i}),a.dispatch(s),d=!0)})),d}function Bi(t){const{editor:e,rules:n}=t,o=new xe({state:{init:()=>null,apply(t,r,i){const s=t.getMeta(o);if(s)return s;const l=t.getMeta("applyInputRules");return!!l&&setTimeout((()=>{let{text:t}=l;"string"==typeof t||(t=Pi(a.from(t),i.schema));const{from:r}=l,s=r+t.length;Hi({editor:e,from:r,to:s,text:t,rules:n,plugin:o})})),t.selectionSet||t.docChanged?null:r}},props:{handleTextInput:(t,r,i,s)=>Hi({editor:e,from:r,to:i,text:s,rules:n,plugin:o}),handleDOMEvents:{compositionend:t=>(setTimeout((()=>{const{$cursor:r}=t.state.selection;r&&Hi({editor:e,from:r.pos,to:r.pos,text:"",rules:n,plugin:o})})),!1)},handleKeyDown(t,r){if("Enter"!==r.key)return!1;const{$cursor:i}=t.state.selection;return!!i&&Hi({editor:e,from:i.pos,to:i.pos,text:"\n",rules:n,plugin:o})}},isInputRules:!0});return o}function _i(t){return"Object"===function(t){return Object.prototype.toString.call(t).slice(8,-1)}(t)&&t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function Fi(t,e){const n={...t};return _i(t)&&_i(e)&&Object.keys(e).forEach((o=>{_i(e[o])&&_i(t[o])?n[o]=Fi(t[o],e[o]):n[o]=e[o]})),n}class Vi{constructor(t={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...t},this.name=this.config.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=Di(Ci(this,"addOptions",{name:this.name}))),this.storage=Di(Ci(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t={}){return new Vi(t)}configure(t={}){const e=this.extend({...this.config,addOptions:()=>Fi(this.options,t)});return e.name=this.name,e.parent=this.parent,e}extend(t={}){const e=new Vi(t);return e.parent=this,this.child=e,e.name=t.name?t.name:e.parent.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${e.name}".`),e.options=Di(Ci(e,"addOptions",{name:e.name})),e.storage=Di(Ci(e,"addStorage",{name:e.name,options:e.options})),e}static handleExit({editor:t,mark:e}){const{tr:n}=t.state,o=t.state.selection.$from;if(o.pos===o.end()){const r=o.marks();if(!r.find((t=>(null==t?void 0:t.type.name)===e.name)))return!1;const i=r.find((t=>(null==t?void 0:t.type.name)===e.name));return i&&n.removeStoredMark(i),n.insertText(" ",o.pos),t.view.dispatch(n),!0}return!1}}class Wi{constructor(t){this.find=t.find,this.handler=t.handler}}let qi=null;function Ki(t){const{editor:e,rules:n}=t;let o,r=null,i=!1,s=!1,l="undefined"!=typeof ClipboardEvent?new ClipboardEvent("paste"):null;try{o="undefined"!=typeof DragEvent?new DragEvent("drop"):null}catch{o=null}const c=({state:t,from:n,to:r,rule:i,pasteEvt:s})=>{const a=t.tr,c=ki({state:t,transaction:a});if(function(t){const{editor:e,state:n,from:o,to:r,rule:i,pasteEvent:s,dropEvent:l}=t,{commands:a,chain:c,can:d}=new xi({editor:e,state:n}),h=[];return n.doc.nodesBetween(o,r,((t,e)=>{if(!t.isTextblock||t.type.spec.code)return;const p=Math.max(o,e),u=Math.min(r,e+t.content.size),f=((t,e,n)=>{if(zi(e))return[...t.matchAll(e)];const o=e(t,n);return o?o.map((e=>{const n=[e.text];return n.index=e.index,n.input=t,n.data=e.data,e.replaceWith&&(e.text.includes(e.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),n.push(e.replaceWith)),n})):[]})(t.textBetween(p-e,u-e,void 0,""),i.find,s);f.forEach((t=>{if(void 0===t.index)return;const e=p+t.index+1,o=e+t[0].length,r={from:n.tr.mapping.map(e),to:n.tr.mapping.map(o)},u=i.handler({state:n,range:r,match:t,commands:a,chain:c,can:d,pasteEvent:s,dropEvent:l});h.push(u)}))})),h.every((t=>null!==t))}({editor:e,state:c,from:Math.max(n-1,0),to:r.b-1,rule:i,pasteEvent:s,dropEvent:o})&&a.steps.length){try{o="undefined"!=typeof DragEvent?new DragEvent("drop"):null}catch{o=null}return l="undefined"!=typeof ClipboardEvent?new ClipboardEvent("paste"):null,a}};return n.map((t=>new xe({view(t){const n=n=>{var o;r=(null===(o=t.dom.parentElement)||void 0===o?void 0:o.contains(n.target))?t.dom.parentElement:null,r&&(qi=e)},o=()=>{qi&&(qi=null)};return window.addEventListener("dragstart",n),window.addEventListener("dragend",o),{destroy(){window.removeEventListener("dragstart",n),window.removeEventListener("dragend",o)}}},props:{handleDOMEvents:{drop:(t,e)=>{if(s=r===t.dom.parentElement,o=e,!s){const t=qi;t&&setTimeout((()=>{const e=t.state.selection;e&&t.commands.deleteRange({from:e.from,to:e.to})}),10)}return!1},paste:(t,e)=>{var n;const o=null===(n=e.clipboardData)||void 0===n?void 0:n.getData("text/html");return l=e,i=!!(null==o?void 0:o.includes("data-pm-slice")),!1}}},appendTransaction:(e,n,o)=>{const r=e[0],d="paste"===r.getMeta("uiEvent")&&!i,h="drop"===r.getMeta("uiEvent")&&!s,p=r.getMeta("applyPasteRules"),u=!!p;if(!d&&!h&&!u)return;if(u){let{text:e}=p;"string"==typeof e||(e=Pi(a.from(e),o.schema));const{from:n}=p,r=n+e.length,i=(t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return null===(e=n.clipboardData)||void 0===e||e.setData("text/html",t),n})(e);return c({rule:t,state:o,from:n,to:{b:r},pasteEvt:i})}const f=n.doc.content.findDiffStart(o.doc.content),m=n.doc.content.findDiffEnd(o.doc.content);return"number"==typeof f&&m&&f!==m.b?c({rule:t,state:o,from:f,to:m,pasteEvt:l}):void 0}})))}class Ji{constructor(t,e){this.splittableMarks=[],this.editor=e,this.extensions=Ji.resolve(t),this.schema=function(t,e){var n;const o=Ti(t),{nodeExtensions:r,markExtensions:i}=Si(t),s=null===(n=r.find((t=>Ci(t,"topNode"))))||void 0===n?void 0:n.name,l=Object.fromEntries(r.map((n=>{const r=o.filter((t=>t.type===n.name)),i={name:n.name,options:n.options,storage:n.storage,editor:e},s=ji({...t.reduce(((t,e)=>{const o=Ci(e,"extendNodeSchema",i);return{...t,...o?o(n):{}}}),{}),content:Di(Ci(n,"content",i)),marks:Di(Ci(n,"marks",i)),group:Di(Ci(n,"group",i)),inline:Di(Ci(n,"inline",i)),atom:Di(Ci(n,"atom",i)),selectable:Di(Ci(n,"selectable",i)),draggable:Di(Ci(n,"draggable",i)),code:Di(Ci(n,"code",i)),whitespace:Di(Ci(n,"whitespace",i)),linebreakReplacement:Di(Ci(n,"linebreakReplacement",i)),defining:Di(Ci(n,"defining",i)),isolating:Di(Ci(n,"isolating",i)),attrs:Object.fromEntries(r.map((t=>{var e;return[t.name,{default:null===(e=null==t?void 0:t.attribute)||void 0===e?void 0:e.default}]})))}),l=Di(Ci(n,"parseHTML",i));l&&(s.parseDOM=l.map((t=>Ri(t,r))));const a=Ci(n,"renderHTML",i);a&&(s.toDOM=t=>a({node:t,HTMLAttributes:Ei(t,r)}));const c=Ci(n,"renderText",i);return c&&(s.toText=c),[n.name,s]}))),a=Object.fromEntries(i.map((n=>{const r=o.filter((t=>t.type===n.name)),i={name:n.name,options:n.options,storage:n.storage,editor:e},s=ji({...t.reduce(((t,e)=>{const o=Ci(e,"extendMarkSchema",i);return{...t,...o?o(n):{}}}),{}),inclusive:Di(Ci(n,"inclusive",i)),excludes:Di(Ci(n,"excludes",i)),group:Di(Ci(n,"group",i)),spanning:Di(Ci(n,"spanning",i)),code:Di(Ci(n,"code",i)),attrs:Object.fromEntries(r.map((t=>{var e;return[t.name,{default:null===(e=null==t?void 0:t.attribute)||void 0===e?void 0:e.default}]})))}),l=Di(Ci(n,"parseHTML",i));l&&(s.parseDOM=l.map((t=>Ri(t,r))));const a=Ci(n,"renderHTML",i);return a&&(s.toDOM=t=>a({mark:t,HTMLAttributes:Ei(t,r)})),[n.name,s]})));return new X({topNode:s,nodes:l,marks:a})}(this.extensions,e),this.setupExtensions()}static resolve(t){const e=Ji.sort(Ji.flatten(t)),n=function(t){const e=t.filter(((e,n)=>t.indexOf(e)!==n));return Array.from(new Set(e))}(e.map((t=>t.name)));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map((t=>`'${t}'`)).join(", ")}]. This can lead to issues.`),e}static flatten(t){return t.map((t=>{const e=Ci(t,"addExtensions",{name:t.name,options:t.options,storage:t.storage});return e?[t,...this.flatten(e())]:t})).flat(10)}static sort(t){return t.sort(((t,e)=>{const n=Ci(t,"priority")||100,o=Ci(e,"priority")||100;return n>o?-1:n<o?1:0}))}get commands(){return this.extensions.reduce(((t,e)=>{const n=Ci(e,"addCommands",{name:e.name,options:e.options,storage:e.storage,editor:this.editor,type:Li(e.name,this.schema)});return n?{...t,...n()}:t}),{})}get plugins(){const{editor:t}=this,e=Ji.sort([...this.extensions].reverse()),n=[],o=[],r=e.map((e=>{const r={name:e.name,options:e.options,storage:e.storage,editor:t,type:Li(e.name,this.schema)},i=[],s=Ci(e,"addKeyboardShortcuts",r);let l={};if("mark"===e.type&&Ci(e,"exitable",r)&&(l.ArrowRight=()=>Vi.handleExit({editor:t,mark:e})),s){const e=Object.fromEntries(Object.entries(s()).map((([e,n])=>[e,()=>n({editor:t})])));l={...l,...e}}const a=new xe({props:{handleKeyDown:Jr(l)}});i.push(a);const c=Ci(e,"addInputRules",r);Ii(e,t.options.enableInputRules)&&c&&n.push(...c());const d=Ci(e,"addPasteRules",r);Ii(e,t.options.enablePasteRules)&&d&&o.push(...d());const h=Ci(e,"addProseMirrorPlugins",r);if(h){const t=h();i.push(...t)}return i})).flat();return[Bi({editor:t,rules:n}),...Ki({editor:t,rules:o}),...r]}get attributes(){return Ti(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=Si(this.extensions);return Object.fromEntries(e.filter((t=>!!Ci(t,"addNodeView"))).map((e=>{const n=this.attributes.filter((t=>t.type===e.name)),o={name:e.name,options:e.options,storage:e.storage,editor:t,type:Ai(e.name,this.schema)},r=Ci(e,"addNodeView",o);return r?[e.name,(o,i,s,l,a)=>{const c=Ei(o,n);return r()({node:o,view:i,getPos:s,decorations:l,innerDecorations:a,editor:t,extension:e,HTMLAttributes:c})}]:[]})))}setupExtensions(){this.extensions.forEach((t=>{var e;this.editor.extensionStorage[t.name]=t.storage;const n={name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:Li(t.name,this.schema)};"mark"===t.type&&(null===(e=Di(Ci(t,"keepOnSplit",n)))||void 0===e||e)&&this.splittableMarks.push(t.name);const o=Ci(t,"onBeforeCreate",n),r=Ci(t,"onCreate",n),i=Ci(t,"onUpdate",n),s=Ci(t,"onSelectionUpdate",n),l=Ci(t,"onTransaction",n),a=Ci(t,"onFocus",n),c=Ci(t,"onBlur",n),d=Ci(t,"onDestroy",n);o&&this.editor.on("beforeCreate",o),r&&this.editor.on("create",r),i&&this.editor.on("update",i),s&&this.editor.on("selectionUpdate",s),l&&this.editor.on("transaction",l),a&&this.editor.on("focus",a),c&&this.editor.on("blur",c),d&&this.editor.on("destroy",d)}))}}class Ui{constructor(t={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...t},this.name=this.config.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=Di(Ci(this,"addOptions",{name:this.name}))),this.storage=Di(Ci(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t={}){return new Ui(t)}configure(t={}){const e=this.extend({...this.config,addOptions:()=>Fi(this.options,t)});return e.name=this.name,e.parent=this.parent,e}extend(t={}){const e=new Ui({...this.config,...t});return e.parent=this,this.child=e,e.name=t.name?t.name:e.parent.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${e.name}".`),e.options=Di(Ci(e,"addOptions",{name:e.name})),e.storage=Di(Ci(e,"addStorage",{name:e.name,options:e.options})),e}}function Gi(t,e,n){const{from:o,to:r}=e,{blockSeparator:i="\n\n",textSerializers:s={}}=n||{};let l="";return t.nodesBetween(o,r,((t,n,a,c)=>{var d;t.isBlock&&n>o&&(l+=i);const h=null==s?void 0:s[t.type.name];if(h)return a&&(l+=h({node:t,pos:n,parent:a,index:c,range:e})),!1;t.isText&&(l+=null===(d=null==t?void 0:t.text)||void 0===d?void 0:d.slice(Math.max(o,n)-n,r-n))})),l}function Yi(t){return Object.fromEntries(Object.entries(t.nodes).filter((([,t])=>t.spec.toText)).map((([t,e])=>[t,e.spec.toText])))}const Xi=Ui.create({name:"clipboardTextSerializer",addOptions:()=>({blockSeparator:void 0}),addProseMirrorPlugins(){return[new xe({key:new Se("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:o,selection:r}=e,{ranges:i}=r,s=Math.min(...i.map((t=>t.$from.pos))),l=Math.max(...i.map((t=>t.$to.pos))),a=Yi(n);return Gi(o,{from:s,to:l},{...void 0!==this.options.blockSeparator?{blockSeparator:this.options.blockSeparator}:{},textSerializers:a})}}})]}});function Qi(t,e,n={strict:!0}){const o=Object.keys(e);return!o.length||o.every((o=>n.strict?e[o]===t[o]:zi(e[o])?e[o].test(t[o]):e[o]===t[o]))}function Zi(t,e,n={}){return t.find((t=>t.type===e&&Qi(Object.fromEntries(Object.keys(n).map((e=>[e,t.attrs[e]]))),n)))}function ts(t,e,n={}){return!!Zi(t,e,n)}function es(t,e,n){var o;if(!t||!e)return;let r=t.parent.childAfter(t.parentOffset);if(r.node&&r.node.marks.some((t=>t.type===e))||(r=t.parent.childBefore(t.parentOffset)),!r.node||!r.node.marks.some((t=>t.type===e)))return;if(n=n||(null===(o=r.node.marks[0])||void 0===o?void 0:o.attrs),!Zi([...r.node.marks],e,n))return;let i=r.index,s=t.start()+r.offset,l=i+1,a=s+r.node.nodeSize;for(;i>0&&ts([...t.parent.child(i-1).marks],e,n);)i-=1,s-=t.parent.child(i).nodeSize;for(;l<t.parent.childCount&&ts([...t.parent.child(l).marks],e,n);)a+=t.parent.child(l).nodeSize,l+=1;return{from:s,to:a}}function ns(t,e){if("string"==typeof t){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}function rs(t){return t instanceof le}function is(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function ss(t,e=null){if(!e)return null;const n=oe.atStart(t),o=oe.atEnd(t);if("start"===e||!0===e)return n;if("end"===e)return o;const r=n.from,i=o.to;return"all"===e?le.create(t,is(0,r,i),is(t.content.size,r,i)):le.create(t,is(e,r,i),is(e,r,i))}function ls(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}const as=t=>{const e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){const o=e[n];3===o.nodeType&&o.nodeValue&&/^(\n\s\s|\n)$/.test(o.nodeValue)?t.removeChild(o):1===o.nodeType&&as(o)}return t};function cs(t){const e=`<body>${t}</body>`,n=(new window.DOMParser).parseFromString(e,"text/html").body;return as(n)}function ds(t,e,n){if(t instanceof R||t instanceof a)return t;n={slice:!0,parseOptions:{},...n};const o="string"==typeof t;if("object"==typeof t&&null!==t)try{if(Array.isArray(t)&&t.length>0)return a.fromArray(t.map((t=>e.nodeFromJSON(t))));const o=e.nodeFromJSON(t);return n.errorOnInvalidContent&&o.check(),o}catch(o){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:o});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",o),ds("",e,n)}if(o){if(n.errorOnInvalidContent){let o=!1,r="";const i=new X({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:t=>(o=!0,r="string"==typeof t?t:t.outerHTML,null)}]}})});if(n.slice?Z.fromSchema(i).parseSlice(cs(t),n.parseOptions):Z.fromSchema(i).parse(cs(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${r}`)})}const o=Z.fromSchema(e);return n.slice?o.parseSlice(cs(t),n.parseOptions).content:o.parse(cs(t),n.parseOptions)}return ds("",e,n)}function hs(){return"undefined"!=typeof navigator&&/Mac/.test(navigator.platform)}function ps(t,e,n={}){const{from:o,to:r,empty:i}=t.selection,s=e?Ai(e,t.schema):null,l=[];t.doc.nodesBetween(o,r,((t,e)=>{if(t.isText)return;const n=Math.max(o,e),i=Math.min(r,e+t.nodeSize);l.push({node:t,from:n,to:i})}));const a=r-o,c=l.filter((t=>!s||s.name===t.node.type.name)).filter((t=>Qi(t.node.attrs,n,{strict:!1})));return i?!!c.length:c.reduce(((t,e)=>t+e.to-e.from),0)>=a}function us(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function fs(t,e){const n="string"==typeof e?[e]:e;return Object.keys(t).reduce(((e,o)=>(n.includes(o)||(e[o]=t[o]),e)),{})}function ms(t,e,n={},o={}){return ds(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:o.errorOnInvalidContent})}function gs(t,e){const n=ns(e,t.schema),{from:o,to:r,empty:i}=t.selection,s=[];i?(t.storedMarks&&s.push(...t.storedMarks),s.push(...t.selection.$head.marks())):t.doc.nodesBetween(o,r,(t=>{s.push(...t.marks)}));const l=s.find((t=>t.type.name===n.name));return l?{...l.attrs}:{}}function ys(t,e){for(let n=t.depth;n>0;n-=1){const o=t.node(n);if(e(o))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:o}}}function bs(t){return e=>ys(e.$from,t)}function vs(t,e){const n=us("string"==typeof e?e:e.name,t.schema);return"node"===n?function(t,e){const n=Ai(e,t.schema),{from:o,to:r}=t.selection,i=[];t.doc.nodesBetween(o,r,(t=>{i.push(t)}));const s=i.reverse().find((t=>t.type.name===n.name));return s?{...s.attrs}:{}}(t,e):"mark"===n?gs(t,e):{}}function ws(t,e,n){const o=[];return t===e?n.resolve(t).marks().forEach((e=>{const r=es(n.resolve(t),e.type);r&&o.push({mark:e,...r})})):n.nodesBetween(t,e,((t,e)=>{t&&void 0!==(null==t?void 0:t.nodeSize)&&o.push(...t.marks.map((n=>({from:e,to:e+t.nodeSize,mark:n}))))})),o}function ks(t,e,n){return Object.fromEntries(Object.entries(n).filter((([n])=>{const o=t.find((t=>t.type===e&&t.name===n));return!!o&&o.attribute.keepOnSplit})))}function xs(t,e,n={}){const{empty:o,ranges:r}=t.selection,i=e?ns(e,t.schema):null;if(o)return!!(t.storedMarks||t.selection.$from.marks()).filter((t=>!i||i.name===t.type.name)).find((t=>Qi(t.attrs,n,{strict:!1})));let s=0;const l=[];if(r.forEach((({$from:e,$to:n})=>{const o=e.pos,r=n.pos;t.doc.nodesBetween(o,r,((t,e)=>{if(!t.isText&&!t.marks.length)return;const n=Math.max(o,e),i=Math.min(r,e+t.nodeSize);s+=i-n,l.push(...t.marks.map((t=>({mark:t,from:n,to:i}))))}))})),0===s)return!1;const a=l.filter((t=>!i||i.name===t.mark.type.name)).filter((t=>Qi(t.mark.attrs,n,{strict:!1}))).reduce(((t,e)=>t+e.to-e.from),0),c=l.filter((t=>!i||t.mark.type!==i&&t.mark.type.excludes(i))).reduce(((t,e)=>t+e.to-e.from),0);return(a>0?a+c:a)>=s}function Ms(t,e){const{nodeExtensions:n}=Si(e),o=n.find((e=>e.name===t));if(!o)return!1;const r=Di(Ci(o,"group",{name:o.name,options:o.options,storage:o.storage}));return"string"==typeof r&&r.split(" ").includes("list")}function Cs(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var o;if(n){if("hardBreak"===t.type.name)return!0;if(t.isText)return/^\s*$/m.test(null!==(o=t.text)&&void 0!==o?o:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(0===t.content.childCount)return!0;if(e){let o=!0;return t.content.forEach((t=>{!1!==o&&(Cs(t,{ignoreWhitespace:n,checkChildren:e})||(o=!1))})),o}return!1}function Ss(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const o=n.filter((t=>null==e?void 0:e.includes(t.type.name)));t.tr.ensureMarks(o)}}const Ts=(t,e)=>{const n=bs((t=>t.type===e))(t.selection);if(!n)return!0;const o=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(void 0===o)return!0;const r=t.doc.nodeAt(o);return n.node.type!==(null==r?void 0:r.type)||!$t(t.doc,n.pos)||(t.join(n.pos),!0)},As=(t,e)=>{const n=bs((t=>t.type===e))(t.selection);if(!n)return!0;const o=t.doc.resolve(n.start).after(n.depth);if(void 0===o)return!0;const r=t.doc.nodeAt(o);return n.node.type!==(null==r?void 0:r.type)||!$t(t.doc,o)||(t.join(o),!0)};var Os=Object.freeze({__proto__:null,blur:()=>({editor:t,view:e})=>(requestAnimationFrame((()=>{var n;t.isDestroyed||(e.dom.blur(),null===(n=null===window||void 0===window?void 0:window.getSelection())||void 0===n||n.removeAllRanges())})),!0),clearContent:(t=!1)=>({commands:e})=>e.setContent("",t),clearNodes:()=>({state:t,tr:e,dispatch:n})=>{const{selection:o}=e,{ranges:r}=o;return!n||(r.forEach((({$from:n,$to:o})=>{t.doc.nodesBetween(n.pos,o.pos,((t,n)=>{if(t.type.isText)return;const{doc:o,mapping:r}=e,i=o.resolve(r.map(n)),s=o.resolve(r.map(n+t.nodeSize)),l=i.blockRange(s);if(!l)return;const a=Rt(l);if(t.type.isTextblock){const{defaultType:t}=i.parent.contentMatchAt(i.index());e.setNodeMarkup(l.start,t)}(a||0===a)&&e.lift(l,a)}))})),!0)},command:t=>e=>t(e),createParagraphNear:()=>({state:t,dispatch:e})=>ai(t,e),cut:(t,e)=>({editor:n,tr:o})=>{const{state:r}=n,i=r.doc.slice(t.from,t.to);o.deleteRange(t.from,t.to);const s=o.mapping.map(e);return o.insert(s,i.content),o.setSelection(new le(o.doc.resolve(s-1))),!0},deleteCurrentNode:()=>({tr:t,dispatch:e})=>{const{selection:n}=t,o=n.$anchor.node();if(o.content.size>0)return!1;const r=t.selection.$anchor;for(let n=r.depth;n>0;n-=1)if(r.node(n).type===o.type){if(e){const e=r.before(n),o=r.after(n);t.delete(e,o).scrollIntoView()}return!0}return!1},deleteNode:t=>({tr:e,state:n,dispatch:o})=>{const r=Ai(t,n.schema),i=e.selection.$anchor;for(let t=i.depth;t>0;t-=1)if(i.node(t).type===r){if(o){const n=i.before(t),o=i.after(t);e.delete(n,o).scrollIntoView()}return!0}return!1},deleteRange:t=>({tr:e,dispatch:n})=>{const{from:o,to:r}=t;return n&&e.delete(o,r),!0},deleteSelection:()=>({state:t,dispatch:e})=>Ur(t,e),enter:()=>({commands:t})=>t.keyboardShortcut("Enter"),exitCode:()=>({state:t,dispatch:e})=>li(t,e),extendMarkRange:(t,e={})=>({tr:n,state:o,dispatch:r})=>{const i=ns(t,o.schema),{doc:s,selection:l}=n,{$from:a,from:c,to:d}=l;if(r){const t=es(a,i,e);if(t&&t.from<=c&&t.to>=d){const e=le.create(s,t.from,t.to);n.setSelection(e)}}return!0},first:t=>e=>{const n="function"==typeof t?t(e):t;for(let t=0;t<n.length;t+=1)if(n[t](e))return!0;return!1},focus:(t=null,e={})=>({editor:n,view:o,tr:r,dispatch:i})=>{e={scrollIntoView:!0,...e};const s=()=>{(ls()||"Android"===navigator.platform||/android/i.test(navigator.userAgent))&&o.dom.focus(),requestAnimationFrame((()=>{n.isDestroyed||(o.focus(),(null==e?void 0:e.scrollIntoView)&&n.commands.scrollIntoView())}))};if(o.hasFocus()&&null===t||!1===t)return!0;if(i&&null===t&&!rs(n.state.selection))return s(),!0;const l=ss(r.doc,t)||n.state.selection,a=n.state.selection.eq(l);return i&&(a||r.setSelection(l),a&&r.storedMarks&&r.setStoredMarks(r.storedMarks),s()),!0},forEach:(t,e)=>n=>t.every(((t,o)=>e(t,{...n,index:o}))),insertContent:(t,e)=>({tr:n,commands:o})=>o.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),insertContentAt:(t,e,n)=>({tr:o,dispatch:r,editor:i})=>{var s;if(r){let r;n={parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};try{r=ds(e,i.schema,{parseOptions:{preserveWhitespace:"full",...n.parseOptions},errorOnInvalidContent:null!==(s=n.errorOnInvalidContent)&&void 0!==s?s:i.options.enableContentCheck})}catch(t){return i.emit("contentError",{editor:i,error:t,disableCollaboration:()=>{i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}}),!1}let l,{from:c,to:d}="number"==typeof t?{from:t,to:t}:{from:t.from,to:t.to},h=!0,p=!0;if(("type"in r?[r]:r).forEach((t=>{t.check(),h=!!h&&t.isText&&0===t.marks.length,p=!!p&&t.isBlock})),c===d&&p){const{parent:t}=o.doc.resolve(c);t.isTextblock&&!t.type.spec.code&&!t.childCount&&(c-=1,d+=1)}if(h){if(Array.isArray(e))l=e.map((t=>t.text||"")).join("");else if(e instanceof a){let t="";e.forEach((e=>{e.text&&(t+=e.text)})),l=t}else l="object"==typeof e&&e&&e.text?e.text:e;o.insertText(l,c,d)}else l=r,o.replaceWith(c,d,l);n.updateSelection&&function(t,e){const n=t.steps.length-1;if(n<e)return;const o=t.steps[n];if(!(o instanceof At||o instanceof Ot))return;const r=t.mapping.maps[n];let i=0;r.forEach(((t,e,n,o)=>{0===i&&(i=o)})),t.setSelection(oe.near(t.doc.resolve(i),-1))}(o,o.steps.length-1),n.applyInputRules&&o.setMeta("applyInputRules",{from:c,text:l}),n.applyPasteRules&&o.setMeta("applyPasteRules",{from:c,text:l})}return!0},joinBackward:()=>({state:t,dispatch:e})=>Yr(t,e),joinDown:()=>({state:t,dispatch:e})=>((t,e)=>{let n,o=t.selection;if(o instanceof ce){if(o.node.isTextblock||!$t(t.doc,o.to))return!1;n=o.to}else if(n=Bt(t.doc,o.to,1),null==n)return!1;return e&&e(t.tr.join(n).scrollIntoView()),!0})(t,e),joinForward:()=>({state:t,dispatch:e})=>ni(t,e),joinItemBackward:()=>({state:t,dispatch:e,tr:n})=>{try{const o=Bt(t.doc,t.selection.$from.pos,-1);return null!=o&&(n.join(o,2),e&&e(n),!0)}catch{return!1}},joinItemForward:()=>({state:t,dispatch:e,tr:n})=>{try{const o=Bt(t.doc,t.selection.$from.pos,1);return null!=o&&(n.join(o,2),e&&e(n),!0)}catch{return!1}},joinTextblockBackward:()=>({state:t,dispatch:e})=>((t,e)=>{let n=Gr(t,void 0);if(!n)return!1;let o=ti(n);return!!o&&Xr(t,o,e)})(t,e),joinTextblockForward:()=>({state:t,dispatch:e})=>((t,e)=>{let n=ei(t,void 0);if(!n)return!1;let o=ri(n);return!!o&&Xr(t,o,e)})(t,e),joinUp:()=>({state:t,dispatch:e})=>((t,e)=>{let n,o=t.selection,r=o instanceof ce;if(r){if(o.node.isTextblock||!$t(t.doc,o.from))return!1;n=o.from}else if(n=Bt(t.doc,o.from,-1),null==n)return!1;if(e){let o=t.tr.join(n);r&&o.setSelection(ce.create(o.doc,n-t.doc.resolve(n).nodeBefore.nodeSize)),e(o.scrollIntoView())}return!0})(t,e),keyboardShortcut:t=>({editor:e,view:n,tr:o,dispatch:r})=>{const i=function(t){const e=t.split(/-(?!$)/);let n,o,r,i,s=e[e.length-1];"Space"===s&&(s=" ");for(let t=0;t<e.length-1;t+=1){const s=e[t];if(/^(cmd|meta|m)$/i.test(s))i=!0;else if(/^a(lt)?$/i.test(s))n=!0;else if(/^(c|ctrl|control)$/i.test(s))o=!0;else if(/^s(hift)?$/i.test(s))r=!0;else{if(!/^mod$/i.test(s))throw new Error(`Unrecognized modifier name: ${s}`);ls()||hs()?i=!0:o=!0}}return n&&(s=`Alt-${s}`),o&&(s=`Ctrl-${s}`),i&&(s=`Meta-${s}`),r&&(s=`Shift-${s}`),s}(t).split(/-(?!$)/),s=i.find((t=>!["Alt","Ctrl","Meta","Shift"].includes(t))),l=new KeyboardEvent("keydown",{key:"Space"===s?" ":s,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction((()=>{n.someProp("handleKeyDown",(t=>t(n,l)))}));return null==a||a.steps.forEach((t=>{const e=t.map(o.mapping);e&&r&&o.maybeStep(e)})),!0},lift:(t,e={})=>({state:n,dispatch:o})=>!!ps(n,Ai(t,n.schema),e)&&((t,e)=>{let{$from:n,$to:o}=t.selection,r=n.blockRange(o),i=r&&Rt(r);return null!=i&&(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)})(n,o),liftEmptyBlock:()=>({state:t,dispatch:e})=>ci(t,e),liftListItem:t=>({state:e,dispatch:n})=>{return(o=Ai(t,e.schema),function(t,e){let{$from:n,$to:r}=t.selection,i=n.blockRange(r,(t=>t.childCount>0&&t.firstChild.type==o));return!!i&&(!e||(n.node(i.depth-1).type==o?function(t,e,n,o){let r=t.tr,i=o.end,s=o.$to.end(o.depth);i<s&&(r.step(new Ot(i-1,s,i,s,new f(a.from(n.create(null,o.parent.copy())),1,0),1,!0)),o=new N(r.doc.resolve(o.$from.pos),r.doc.resolve(s),o.depth));const l=Rt(o);if(null==l)return!1;r.lift(o,l);let c=r.doc.resolve(r.mapping.map(i,-1)-1);return $t(r.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&r.join(c.pos),e(r.scrollIntoView()),!0}(t,e,o,i):function(t,e,n){let o=t.tr,r=n.parent;for(let t=n.end,e=n.endIndex-1,i=n.startIndex;e>i;e--)t-=r.child(e).nodeSize,o.delete(t-1,t+1);let i=o.doc.resolve(n.start),s=i.nodeAfter;if(o.mapping.map(n.end)!=n.start+i.nodeAfter.nodeSize)return!1;let l=0==n.startIndex,c=n.endIndex==r.childCount,d=i.node(-1),h=i.index(-1);if(!d.canReplace(h+(l?0:1),h+1,s.content.append(c?a.empty:a.from(r))))return!1;let p=i.pos,u=p+s.nodeSize;return o.step(new Ot(p-(l?1:0),u+(c?1:0),p+1,u-1,new f((l?a.empty:a.from(r.copy(a.empty))).append(c?a.empty:a.from(r.copy(a.empty))),l?0:1,c?0:1),l?0:1)),e(o.scrollIntoView()),!0}(t,e,i)))})(e,n);var o},newlineInCode:()=>({state:t,dispatch:e})=>ii(t,e),resetAttributes:(t,e)=>({tr:n,state:o,dispatch:r})=>{let i=null,s=null;const l=us("string"==typeof t?t:t.name,o.schema);return!!l&&("node"===l&&(i=Ai(t,o.schema)),"mark"===l&&(s=ns(t,o.schema)),r&&n.selection.ranges.forEach((t=>{o.doc.nodesBetween(t.$from.pos,t.$to.pos,((t,o)=>{i&&i===t.type&&n.setNodeMarkup(o,void 0,fs(t.attrs,e)),s&&t.marks.length&&t.marks.forEach((r=>{s===r.type&&n.addMark(o,o+t.nodeSize,s.create(fs(r.attrs,e)))}))}))})),!0)},scrollIntoView:()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),selectAll:()=>({tr:t,dispatch:e})=>{if(e){const e=new he(t.doc);t.setSelection(e)}return!0},selectNodeBackward:()=>({state:t,dispatch:e})=>Zr(t,e),selectNodeForward:()=>({state:t,dispatch:e})=>oi(t,e),selectParentNode:()=>({state:t,dispatch:e})=>((t,e)=>{let n,{$from:o,to:r}=t.selection,i=o.sharedDepth(r);return 0!=i&&(n=o.before(i),e&&e(t.tr.setSelection(ce.create(t.doc,n))),!0)})(t,e),selectTextblockEnd:()=>({state:t,dispatch:e})=>fi(t,e),selectTextblockStart:()=>({state:t,dispatch:e})=>ui(t,e),setContent:(t,e=!1,n={},o={})=>({editor:r,tr:i,dispatch:s,commands:l})=>{var a,c;const{doc:d}=i;if("full"!==n.preserveWhitespace){const l=ms(t,r.schema,n,{errorOnInvalidContent:null!==(a=o.errorOnInvalidContent)&&void 0!==a?a:r.options.enableContentCheck});return s&&i.replaceWith(0,d.content.size,l).setMeta("preventUpdate",!e),!0}return s&&i.setMeta("preventUpdate",!e),l.insertContentAt({from:0,to:d.content.size},t,{parseOptions:n,errorOnInvalidContent:null!==(c=o.errorOnInvalidContent)&&void 0!==c?c:r.options.enableContentCheck})},setMark:(t,e={})=>({tr:n,state:o,dispatch:r})=>{const{selection:i}=n,{empty:s,ranges:l}=i,a=ns(t,o.schema);if(r)if(s){const t=gs(o,a);n.addStoredMark(a.create({...t,...e}))}else l.forEach((t=>{const r=t.$from.pos,i=t.$to.pos;o.doc.nodesBetween(r,i,((t,o)=>{const s=Math.max(o,r),l=Math.min(o+t.nodeSize,i);t.marks.find((t=>t.type===a))?t.marks.forEach((t=>{a===t.type&&n.addMark(s,l,a.create({...t.attrs,...e}))})):n.addMark(s,l,a.create(e))}))}));return function(t,e,n){var o;const{selection:r}=e;let i=null;if(rs(r)&&(i=r.$cursor),i){const e=null!==(o=t.storedMarks)&&void 0!==o?o:i.marks();return!!n.isInSet(e)||!e.some((t=>t.type.excludes(n)))}const{ranges:s}=r;return s.some((({$from:e,$to:o})=>{let r=0===e.depth&&t.doc.inlineContent&&t.doc.type.allowsMarkType(n);return t.doc.nodesBetween(e.pos,o.pos,((t,e,o)=>{if(r)return!1;if(t.isInline){const e=!o||o.type.allowsMarkType(n),i=!!n.isInSet(t.marks)||!t.marks.some((t=>t.type.excludes(n)));r=e&&i}return!r})),r}))}(o,n,a)},setMeta:(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),setNode:(t,e={})=>({state:n,dispatch:o,chain:r})=>{const i=Ai(t,n.schema);let s;return n.selection.$anchor.sameParent(n.selection.$head)&&(s=n.selection.$anchor.parent.attrs),i.isTextblock?r().command((({commands:t})=>!!mi(i,{...s,...e})(n)||t.clearNodes())).command((({state:t})=>mi(i,{...s,...e})(t,o))).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},setNodeSelection:t=>({tr:e,dispatch:n})=>{if(n){const{doc:n}=e,o=is(t,0,n.content.size),r=ce.create(n,o);e.setSelection(r)}return!0},setTextSelection:t=>({tr:e,dispatch:n})=>{if(n){const{doc:n}=e,{from:o,to:r}="number"==typeof t?{from:t,to:t}:t,i=le.atStart(n).from,s=le.atEnd(n).to,l=is(o,i,s),a=is(r,i,s),c=le.create(n,l,a);e.setSelection(c)}return!0},sinkListItem:t=>({state:e,dispatch:n})=>{const o=Ai(t,e.schema);return(r=o,function(t,e){let{$from:n,$to:o}=t.selection,i=n.blockRange(o,(t=>t.childCount>0&&t.firstChild.type==r));if(!i)return!1;let s=i.startIndex;if(0==s)return!1;let l=i.parent,c=l.child(s-1);if(c.type!=r)return!1;if(e){let n=c.lastChild&&c.lastChild.type==l.type,o=a.from(n?r.create():null),s=new f(a.from(r.create(null,a.from(l.type.create(null,o)))),n?3:1,0),d=i.start,h=i.end;e(t.tr.step(new Ot(d-(n?3:1),h,d,h,s,1,!0)).scrollIntoView())}return!0})(e,n);var r},splitBlock:({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:o,editor:r})=>{const{selection:i,doc:s}=e,{$from:l,$to:a}=i,c=ks(r.extensionManager.attributes,l.node().type.name,l.node().attrs);if(i instanceof ce&&i.node.isBlock)return!(!l.parentOffset||!zt(s,l.pos)||(o&&(t&&Ss(n,r.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),0));if(!l.parent.isBlock)return!1;const d=a.parentOffset===a.parent.content.size,h=0===l.depth?void 0:function(t){for(let e=0;e<t.edgeCount;e+=1){const{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}(l.node(-1).contentMatchAt(l.indexAfter(-1)));let p=d&&h?[{type:h,attrs:c}]:void 0,u=zt(e.doc,e.mapping.map(l.pos),1,p);if(p||u||!zt(e.doc,e.mapping.map(l.pos),1,h?[{type:h}]:void 0)||(u=!0,p=h?[{type:h,attrs:c}]:void 0),o){if(u&&(i instanceof le&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,p),h&&!d&&!l.parentOffset&&l.parent.type!==h)){const t=e.mapping.map(l.before()),n=e.doc.resolve(t);l.node(-1).canReplaceWith(n.index(),n.index()+1,h)&&e.setNodeMarkup(e.mapping.map(l.before()),h)}t&&Ss(n,r.extensionManager.splittableMarks),e.scrollIntoView()}return u},splitListItem:(t,e={})=>({tr:n,state:o,dispatch:r,editor:i})=>{var s;const l=Ai(t,o.schema),{$from:c,$to:d}=o.selection,h=o.selection.node;if(h&&h.isBlock||c.depth<2||!c.sameParent(d))return!1;const p=c.node(-1);if(p.type!==l)return!1;const u=i.extensionManager.attributes;if(0===c.parent.content.size&&c.node(-1).childCount===c.indexAfter(-1)){if(2===c.depth||c.node(-3).type!==l||c.index(-2)!==c.node(-2).childCount-1)return!1;if(r){let t=a.empty;const o=c.index(-1)?1:c.index(-2)?2:3;for(let e=c.depth-o;e>=c.depth-3;e-=1)t=a.from(c.node(e).copy(t));const r=c.indexAfter(-1)<c.node(-2).childCount?1:c.indexAfter(-2)<c.node(-3).childCount?2:3,i={...ks(u,c.node().type.name,c.node().attrs),...e},d=(null===(s=l.contentMatch.defaultType)||void 0===s?void 0:s.createAndFill(i))||void 0;t=t.append(a.from(l.createAndFill(null,d)||void 0));const h=c.before(c.depth-(o-1));n.replace(h,c.after(-r),new f(t,4-o,0));let p=-1;n.doc.nodesBetween(h,n.doc.content.size,((t,e)=>{if(p>-1)return!1;t.isTextblock&&0===t.content.size&&(p=e+1)})),p>-1&&n.setSelection(le.near(n.doc.resolve(p))),n.scrollIntoView()}return!0}const m=d.pos===c.end()?p.contentMatchAt(0).defaultType:null,g={...ks(u,p.type.name,p.attrs),...e},y={...ks(u,c.node().type.name,c.node().attrs),...e};n.delete(c.pos,d.pos);const b=m?[{type:l,attrs:g},{type:m,attrs:y}]:[{type:l,attrs:g}];if(!zt(n.doc,c.pos,2))return!1;if(r){const{selection:t,storedMarks:e}=o,{splittableMarks:s}=i.extensionManager,l=e||t.$to.parentOffset&&t.$from.marks();if(n.split(c.pos,2,b).scrollIntoView(),!l||!r)return!0;const a=l.filter((t=>s.includes(t.type.name)));n.ensureMarks(a)}return!0},toggleList:(t,e,n,o={})=>({editor:r,tr:i,state:s,dispatch:l,chain:a,commands:c,can:d})=>{const{extensions:h,splittableMarks:p}=r.extensionManager,u=Ai(t,s.schema),f=Ai(e,s.schema),{selection:m,storedMarks:g}=s,{$from:y,$to:b}=m,v=y.blockRange(b),w=g||m.$to.parentOffset&&m.$from.marks();if(!v)return!1;const k=bs((t=>Ms(t.type.name,h)))(m);if(v.depth>=1&&k&&v.depth-k.depth<=1){if(k.node.type===u)return c.liftListItem(f);if(Ms(k.node.type.name,h)&&u.validContent(k.node.content)&&l)return a().command((()=>(i.setNodeMarkup(k.pos,u),!0))).command((()=>Ts(i,u))).command((()=>As(i,u))).run()}return n&&w&&l?a().command((()=>{const t=d().wrapInList(u,o),e=w.filter((t=>p.includes(t.type.name)));return i.ensureMarks(e),!!t||c.clearNodes()})).wrapInList(u,o).command((()=>Ts(i,u))).command((()=>As(i,u))).run():a().command((()=>!!d().wrapInList(u,o)||c.clearNodes())).wrapInList(u,o).command((()=>Ts(i,u))).command((()=>As(i,u))).run()},toggleMark:(t,e={},n={})=>({state:o,commands:r})=>{const{extendEmptyMarkRange:i=!1}=n,s=ns(t,o.schema);return xs(o,s,e)?r.unsetMark(s,{extendEmptyMarkRange:i}):r.setMark(s,e)},toggleNode:(t,e,n={})=>({state:o,commands:r})=>{const i=Ai(t,o.schema),s=Ai(e,o.schema),l=ps(o,i,n);let a;return o.selection.$anchor.sameParent(o.selection.$head)&&(a=o.selection.$anchor.parent.attrs),l?r.setNode(s,a):r.setNode(i,{...a,...n})},toggleWrap:(t,e={})=>({state:n,commands:o})=>{const r=Ai(t,n.schema);return ps(n,r,e)?o.lift(r):o.wrapIn(r,e)},undoInputRule:()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let o=0;o<n.length;o+=1){const r=n[o];let i;if(r.spec.isInputRules&&(i=r.getState(t))){if(e){const e=t.tr,n=i.transform;for(let t=n.steps.length-1;t>=0;t-=1)e.step(n.steps[t].invert(n.docs[t]));if(i.text){const n=e.doc.resolve(i.from).marks();e.replaceWith(i.from,i.to,t.schema.text(i.text,n))}else e.delete(i.from,i.to)}return!0}}return!1},unsetAllMarks:()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:o,ranges:r}=n;return o||e&&r.forEach((e=>{t.removeMark(e.$from.pos,e.$to.pos)})),!0},unsetMark:(t,e={})=>({tr:n,state:o,dispatch:r})=>{var i;const{extendEmptyMarkRange:s=!1}=e,{selection:l}=n,a=ns(t,o.schema),{$from:c,empty:d,ranges:h}=l;if(!r)return!0;if(d&&s){let{from:t,to:e}=l;const o=null===(i=c.marks().find((t=>t.type===a)))||void 0===i?void 0:i.attrs,r=es(c,a,o);r&&(t=r.from,e=r.to),n.removeMark(t,e,a)}else h.forEach((t=>{n.removeMark(t.$from.pos,t.$to.pos,a)}));return n.removeStoredMark(a),!0},updateAttributes:(t,e={})=>({tr:n,state:o,dispatch:r})=>{let i=null,s=null;const l=us("string"==typeof t?t:t.name,o.schema);return!!l&&("node"===l&&(i=Ai(t,o.schema)),"mark"===l&&(s=ns(t,o.schema)),r&&n.selection.ranges.forEach((t=>{const r=t.$from.pos,l=t.$to.pos;let a,c,d,h;n.selection.empty?o.doc.nodesBetween(r,l,((t,e)=>{i&&i===t.type&&(d=Math.max(e,r),h=Math.min(e+t.nodeSize,l),a=e,c=t)})):o.doc.nodesBetween(r,l,((t,o)=>{o<r&&i&&i===t.type&&(d=Math.max(o,r),h=Math.min(o+t.nodeSize,l),a=o,c=t),o>=r&&o<=l&&(i&&i===t.type&&n.setNodeMarkup(o,void 0,{...t.attrs,...e}),s&&t.marks.length&&t.marks.forEach((i=>{if(s===i.type){const a=Math.max(o,r),c=Math.min(o+t.nodeSize,l);n.addMark(a,c,s.create({...i.attrs,...e}))}})))})),c&&(void 0!==a&&n.setNodeMarkup(a,void 0,{...c.attrs,...e}),s&&c.marks.length&&c.marks.forEach((t=>{s===t.type&&n.addMark(d,h,s.create({...t.attrs,...e}))})))})),!0)},wrapIn:(t,e={})=>({state:n,dispatch:o})=>function(t,e=null){return function(n,o){let{$from:r,$to:i}=n.selection,s=r.blockRange(i),l=s&&jt(s,t,e);return!!l&&(o&&o(n.tr.wrap(s,l).scrollIntoView()),!0)}}(Ai(t,n.schema),e)(n,o),wrapInList:(t,e={})=>({state:n,dispatch:o})=>function(t,e=null){return function(n,o){let{$from:r,$to:i}=n.selection,s=r.blockRange(i);if(!s)return!1;let l=o?n.tr:null;return!!function(t,e,n,o=null){let r=!1,i=e,s=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&0==e.startIndex){if(0==e.$from.index(e.depth-1))return!1;let t=s.resolve(e.start-2);i=new N(t,t,e.depth),e.endIndex<e.parent.childCount&&(e=new N(e.$from,s.resolve(e.$to.end(e.depth)),e.depth)),r=!0}let l=jt(i,n,o,e);return!!l&&(t&&function(t,e,n,o,r){let i=a.empty;for(let t=n.length-1;t>=0;t--)i=a.from(n[t].type.create(n[t].attrs,i));t.step(new Ot(e.start-(o?2:0),e.end,e.start,e.end,new f(i,0,0),n.length,!0));let s=0;for(let t=0;t<n.length;t++)n[t].type==r&&(s=t+1);let l=n.length-s,c=e.start+n.length-(o?2:0),d=e.parent;for(let n=e.startIndex,o=e.endIndex,r=!0;n<o;n++,r=!1)!r&&zt(t.doc,c,l)&&(t.split(c,l),c+=2*l),c+=d.child(n).nodeSize}(t,e,l,r,n),!0)}(l,s,t,e)&&(o&&o(l.scrollIntoView()),!0)}}(Ai(t,n.schema),e)(n,o)});const Es=Ui.create({name:"commands",addCommands:()=>({...Os})}),Ns=Ui.create({name:"drop",addProseMirrorPlugins(){return[new xe({key:new Se("tiptapDrop"),props:{handleDrop:(t,e,n,o)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:o})}}})]}}),Ds=Ui.create({name:"editable",addProseMirrorPlugins(){return[new xe({key:new Se("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Rs=Ui.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new xe({key:new Se("focusEvents"),props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const o=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(o),!1},blur:(e,n)=>{t.isFocused=!1;const o=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(o),!1}}}})]}}),js=Ui.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first((({commands:t})=>[()=>t.undoInputRule(),()=>t.command((({tr:e})=>{const{selection:n,doc:o}=e,{empty:r,$anchor:i}=n,{pos:s,parent:l}=i,a=i.parent.isTextblock&&s>0?e.doc.resolve(s-1):i,c=a.parent.type.spec.isolating,d=i.pos-i.parentOffset,h=c&&1===a.parent.childCount?d===i.pos:oe.atStart(o).from===s;return!(!r||!l.type.isTextblock||l.textContent.length||!h||h&&"paragraph"===i.parent.type.name)&&t.clearNodes()})),()=>t.deleteSelection(),()=>t.joinBackward(),()=>t.selectNodeBackward()])),e=()=>this.editor.commands.first((({commands:t})=>[()=>t.deleteSelection(),()=>t.deleteCurrentNode(),()=>t.joinForward(),()=>t.selectNodeForward()])),n={Enter:()=>this.editor.commands.first((({commands:t})=>[()=>t.newlineInCode(),()=>t.createParagraphNear(),()=>t.liftEmptyBlock(),()=>t.splitBlock()])),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},o={...n},r={...n,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return ls()||hs()?r:o},addProseMirrorPlugins(){return[new xe({key:new Se("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some((t=>t.getMeta("composition"))))return;const o=t.some((t=>t.docChanged))&&!e.doc.eq(n.doc),r=t.some((t=>t.getMeta("preventClearDocument")));if(!o||r)return;const{empty:i,from:s,to:l}=e.selection,a=oe.atStart(e.doc).from,c=oe.atEnd(e.doc).to;if(i||s!==a||l!==c)return;if(!Cs(n.doc))return;const d=n.tr,h=ki({state:n,transaction:d}),{commands:p}=new xi({editor:this.editor,state:h});return p.clearNodes(),d.steps.length?d:void 0}})]}}),Ls=Ui.create({name:"paste",addProseMirrorPlugins(){return[new xe({key:new Se("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),Is=Ui.create({name:"tabindex",addProseMirrorPlugins(){return[new xe({key:new Se("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});class Ps{get name(){return this.node.type.name}constructor(t,e,n=!1,o=null){this.currentNode=null,this.actualDepth=null,this.isBlock=n,this.resolvedPos=t,this.editor=e,this.currentNode=o}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var t;return null!==(t=this.actualDepth)&&void 0!==t?t:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(t){let e=this.from,n=this.to;if(this.isBlock){if(0===this.content.size)return void console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);e=this.from+1,n=this.to-1}this.editor.commands.insertContentAt({from:e,to:n},t)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(0===this.depth)return null;const t=this.resolvedPos.start(this.resolvedPos.depth-1),e=this.resolvedPos.doc.resolve(t);return new Ps(e,this.editor)}get before(){let t=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.from-3)),new Ps(t,this.editor)}get after(){let t=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.to+3)),new Ps(t,this.editor)}get children(){const t=[];return this.node.content.forEach(((e,n)=>{const o=e.isBlock&&!e.isTextblock,r=e.isAtom&&!e.isText,i=this.pos+n+(r?0:1),s=this.resolvedPos.doc.resolve(i);if(!o&&s.depth<=this.depth)return;const l=new Ps(s,this.editor,o,o?e:null);o&&(l.actualDepth=this.depth+1),t.push(new Ps(s,this.editor,o,o?e:null))})),t}get firstChild(){return this.children[0]||null}get lastChild(){const t=this.children;return t[t.length-1]||null}closest(t,e={}){let n=null,o=this.parent;for(;o&&!n;){if(o.node.type.name===t)if(Object.keys(e).length>0){const t=o.node.attrs,n=Object.keys(e);for(let o=0;o<n.length;o+=1){const r=n[o];if(t[r]!==e[r])break}}else n=o;o=o.parent}return n}querySelector(t,e={}){return this.querySelectorAll(t,e,!0)[0]||null}querySelectorAll(t,e={},n=!1){let o=[];if(!this.children||0===this.children.length)return o;const r=Object.keys(e);return this.children.forEach((i=>{n&&o.length>0||(i.node.type.name===t&&r.every((t=>e[t]===i.node.attrs[t]))&&o.push(i),n&&o.length>0||(o=o.concat(i.querySelectorAll(t,e,n))))})),o}setAttribute(t){const{tr:e}=this.editor.state;e.setNodeMarkup(this.from,void 0,{...this.node.attrs,...t}),this.editor.view.dispatch(e)}}class zs extends Mi{constructor(t={}){super(),this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.options={element:document.createElement("div"),content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:t})=>{throw t},onPaste:()=>null,onDrop:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("contentError",this.options.onContentError),this.createView(),this.injectCSS(),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",(({event:t,slice:e,moved:n})=>this.options.onDrop(t,e,n))),this.on("paste",(({event:t,slice:e})=>this.options.onPaste(t,e))),window.setTimeout((()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)}),0)}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&document&&(this.css=function(t,e){const n=document.querySelector("style[data-tiptap-style]");if(null!==n)return n;const o=document.createElement("style");return e&&o.setAttribute("nonce",e),o.setAttribute("data-tiptap-style",""),o.innerHTML='.ProseMirror {\n position: relative;\n}\n\n.ProseMirror {\n word-wrap: break-word;\n white-space: pre-wrap;\n white-space: break-spaces;\n -webkit-font-variant-ligatures: none;\n font-variant-ligatures: none;\n font-feature-settings: "liga" 0; /* the above doesn\'t seem to work in Edge */\n}\n\n.ProseMirror [contenteditable="false"] {\n white-space: normal;\n}\n\n.ProseMirror [contenteditable="false"] [contenteditable="true"] {\n white-space: pre-wrap;\n}\n\n.ProseMirror pre {\n white-space: pre-wrap;\n}\n\nimg.ProseMirror-separator {\n display: inline !important;\n border: none !important;\n margin: 0 !important;\n width: 0 !important;\n height: 0 !important;\n}\n\n.ProseMirror-gapcursor {\n display: none;\n pointer-events: none;\n position: absolute;\n margin: 0;\n}\n\n.ProseMirror-gapcursor:after {\n content: "";\n display: block;\n position: absolute;\n top: -2px;\n width: 20px;\n border-top: 1px solid black;\n animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;\n}\n\n@keyframes ProseMirror-cursor-blink {\n to {\n visibility: hidden;\n }\n}\n\n.ProseMirror-hideselection *::selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection *::-moz-selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection * {\n caret-color: transparent;\n}\n\n.ProseMirror-focused .ProseMirror-gapcursor {\n display: block;\n}\n\n.tippy-box[data-animation=fade][data-state=hidden] {\n opacity: 0\n}',document.getElementsByTagName("head")[0].appendChild(o),o}(0,this.options.injectNonce))}setOptions(t={}){this.options={...this.options,...t},this.view&&this.state&&!this.isDestroyed&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(t,e=!0){this.setOptions({editable:t}),e&&this.emit("update",{editor:this,transaction:this.state.tr})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get state(){return this.view.state}registerPlugin(t,e){const n=Ni(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],o=this.state.reconfigure({plugins:n});return this.view.updateState(o),o}unregisterPlugin(t){if(this.isDestroyed)return;const e=this.state.plugins;let n=e;if([].concat(t).forEach((t=>{const o="string"==typeof t?`${t}$`:t.key;n=e.filter((t=>!t.key.startsWith(o)))})),e.length===n.length)return;const o=this.state.reconfigure({plugins:n});return this.view.updateState(o),o}createExtensionManager(){var t,e;const n=[...this.options.enableCoreExtensions?[Ds,Xi.configure({blockSeparator:null===(e=null===(t=this.options.coreExtensionOptions)||void 0===t?void 0:t.clipboardTextSerializer)||void 0===e?void 0:e.blockSeparator}),Es,Rs,js,Is,Ns,Ls].filter((t=>"object"!=typeof this.options.enableCoreExtensions||!1!==this.options.enableCoreExtensions[t.name])):[],...this.options.extensions].filter((t=>["extension","node","mark"].includes(null==t?void 0:t.type)));this.extensionManager=new Ji(n,this)}createCommandManager(){this.commandManager=new xi({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){var t;let e;try{e=ms(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(t){if(!(t instanceof Error&&["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(t.message)))throw t;this.emit("contentError",{editor:this,error:t,disableCollaboration:()=>{this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter((t=>"collaboration"!==t.name)),this.createExtensionManager()}}),e=ms(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}const n=ss(e,this.options.autofocus);this.view=new Rr(this.options.element,{...this.options.editorProps,attributes:{role:"textbox",...null===(t=this.options.editorProps)||void 0===t?void 0:t.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:we.create({doc:e,selection:n||void 0})});const o=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(o),this.createNodeViews(),this.prependClass(),this.view.dom.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`tiptap ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction)return this.capturedTransaction?void t.steps.forEach((t=>{var e;return null===(e=this.capturedTransaction)||void 0===e?void 0:e.step(t)})):void(this.capturedTransaction=t);const e=this.state.apply(t),n=!this.state.selection.eq(e.selection);this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t}),n&&this.emit("selectionUpdate",{editor:this,transaction:t});const o=t.getMeta("focus"),r=t.getMeta("blur");o&&this.emit("focus",{editor:this,event:o.event,transaction:t}),r&&this.emit("blur",{editor:this,event:r.event,transaction:t}),t.docChanged&&!t.getMeta("preventUpdate")&&this.emit("update",{editor:this,transaction:t})}getAttributes(t){return vs(this.state,t)}isActive(t,e){const n="string"==typeof t?t:null,o="string"==typeof t?e:t;return function(t,e,n={}){if(!e)return ps(t,null,n)||xs(t,null,n);const o=us(e,t.schema);return"node"===o?ps(t,e,n):"mark"===o&&xs(t,e,n)}(this.state,n,o)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Pi(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e="\n\n",textSerializers:n={}}=t||{};return function(t,e){return Gi(t,{from:0,to:t.content.size},e)}(this.state.doc,{blockSeparator:e,textSerializers:{...Yi(this.schema),...n}})}get isEmpty(){return Cs(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){if(this.emit("destroy"),this.view){const t=this.view.dom;t&&t.editor&&delete t.editor,this.view.destroy()}this.removeAllListeners()}get isDestroyed(){var t;return!(null===(t=this.view)||void 0===t?void 0:t.docView)}$node(t,e){var n;return(null===(n=this.$doc)||void 0===n?void 0:n.querySelector(t,e))||null}$nodes(t,e){var n;return(null===(n=this.$doc)||void 0===n?void 0:n.querySelectorAll(t,e))||null}$pos(t){const e=this.state.doc.resolve(t);return new Ps(e,this)}get $doc(){return this.$pos(0)}}function $s(t){return new $i({find:t.find,handler:({state:e,range:n,match:o})=>{const r=Di(t.getAttributes,void 0,o);if(!1===r||null===r)return null;const{tr:i}=e,s=o[o.length-1],l=o[0];if(s){const o=l.search(/\S/),a=n.from+l.indexOf(s),c=a+s.length;if(ws(n.from,n.to,e.doc).filter((e=>e.mark.type.excluded.find((n=>n===t.type&&n!==e.mark.type)))).filter((t=>t.to>a)).length)return null;c<n.to&&i.delete(c,n.to),a>n.from&&i.delete(n.from+o,a);const d=n.from+o+s.length;i.addMark(n.from+o,d,t.type.create(r||{})),i.removeStoredMark(t.type)}}})}function Hs(t){return new $i({find:t.find,handler:({state:e,range:n,match:o})=>{const r=Di(t.getAttributes,void 0,o)||{},{tr:i}=e,s=n.from;let l=n.to;const a=t.type.create(r);if(o[1]){let t=s+o[0].lastIndexOf(o[1]);t>l?t=l:l=t+o[1].length;const e=o[0][o[0].length-1];i.insertText(e,s+o[0].length-1),i.replaceWith(t,l,a)}else if(o[0]){const e=t.type.isInline?s:s-1;i.insert(e,t.type.create(r)).delete(i.mapping.map(s),i.mapping.map(l))}i.scrollIntoView()}})}function Bs(t){return new $i({find:t.find,handler:({state:e,range:n,match:o})=>{const r=e.doc.resolve(n.from),i=Di(t.getAttributes,void 0,o)||{};if(!r.node(-1).canReplaceWith(r.index(-1),r.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,i)}})}function _s(t){return new $i({find:t.find,handler:({state:e,range:n,match:o,chain:r})=>{const i=Di(t.getAttributes,void 0,o)||{},s=e.tr.delete(n.from,n.to),l=s.doc.resolve(n.from).blockRange(),a=l&&jt(l,t.type,i);if(!a)return null;if(s.wrap(l,a),t.keepMarks&&t.editor){const{selection:n,storedMarks:o}=e,{splittableMarks:r}=t.editor.extensionManager,i=o||n.$to.parentOffset&&n.$from.marks();if(i){const t=i.filter((t=>r.includes(t.type.name)));s.ensureMarks(t)}}if(t.keepAttributes){const e="bulletList"===t.type.name||"orderedList"===t.type.name?"listItem":"taskList";r().updateAttributes(e,i).run()}const c=s.doc.resolve(n.from-1).nodeBefore;c&&c.type===t.type&&$t(s.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(o,c))&&s.join(n.from-1)}})}class Fs{constructor(t={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...t},this.name=this.config.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=Di(Ci(this,"addOptions",{name:this.name}))),this.storage=Di(Ci(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t={}){return new Fs(t)}configure(t={}){const e=this.extend({...this.config,addOptions:()=>Fi(this.options,t)});return e.name=this.name,e.parent=this.parent,e}extend(t={}){const e=new Fs(t);return e.parent=this,this.child=e,e.name=t.name?t.name:e.parent.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${e.name}".`),e.options=Di(Ci(e,"addOptions",{name:e.name})),e.storage=Di(Ci(e,"addStorage",{name:e.name,options:e.options})),e}}function Vs(t){return new Wi({find:t.find,handler:({state:e,range:n,match:o,pasteEvent:r})=>{const i=Di(t.getAttributes,void 0,o,r);if(!1===i||null===i)return null;const{tr:s}=e,l=o[o.length-1],a=o[0];let c=n.to;if(l){const o=a.search(/\S/),r=n.from+a.indexOf(l),d=r+l.length;if(ws(n.from,n.to,e.doc).filter((e=>e.mark.type.excluded.find((n=>n===t.type&&n!==e.mark.type)))).filter((t=>t.to>r)).length)return null;d<n.to&&s.delete(d,n.to),r>n.from&&s.delete(n.from+o,r),c=n.from+o+l.length,s.addMark(n.from+o,c,t.type.create(i||{})),s.removeStoredMark(t.type)}}})}const Ws=(t,e)=>{for(const n in e)t[n]=e[n];return t},qs="numeric",Ks="ascii",Js="alpha",Us="asciinumeric",Gs="alphanumeric",Ys="domain",Xs="emoji",Qs="scheme",Zs="slashscheme",tl="whitespace";function el(t,e){return t in e||(e[t]=[]),e[t]}function nl(t,e,n){e[qs]&&(e[Us]=!0,e[Gs]=!0),e[Ks]&&(e[Us]=!0,e[Js]=!0),e[Us]&&(e[Gs]=!0),e[Js]&&(e[Gs]=!0),e[Gs]&&(e[Ys]=!0),e[Xs]&&(e[Ys]=!0);for(const o in e){const e=el(o,n);e.indexOf(t)<0&&e.push(t)}}function ol(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}ol.groups={},ol.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let n=0;n<e.jr.length;n++){const o=e.jr[n][0],r=e.jr[n][1];if(r&&o.test(t))return r}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,o){for(let r=0;r<t.length;r++)this.tt(t[r],e,n,o)},tr(t,e,n,o){let r;return o=o||ol.groups,e&&e.j?r=e:(r=new ol(e),n&&o&&nl(e,n,o)),this.jr.push([t,r]),r},ts(t,e,n,o){let r=this;const i=t.length;if(!i)return r;for(let e=0;e<i-1;e++)r=r.tt(t[e]);return r.tt(t[i-1],e,n,o)},tt(t,e,n,o){o=o||ol.groups;const r=this;if(e&&e.j)return r.j[t]=e,e;const i=e;let s,l=r.go(t);if(l?(s=new ol,Ws(s.j,l.j),s.jr.push.apply(s.jr,l.jr),s.jd=l.jd,s.t=l.t):s=new ol,i){if(o)if(s.t&&"string"==typeof s.t){const t=Ws(function(t,e){const n={};for(const o in e)e[o].indexOf(t)>=0&&(n[o]=!0);return n}(s.t,o),n);nl(i,t,o)}else n&&nl(i,n,o);s.t=i}return r.j[t]=s,s}};const rl=(t,e,n,o,r)=>t.ta(e,n,o,r),il=(t,e,n,o,r)=>t.tr(e,n,o,r),sl=(t,e,n,o,r)=>t.ts(e,n,o,r),ll=(t,e,n,o,r)=>t.tt(e,n,o,r),al="WORD",cl="UWORD",dl="ASCIINUMERICAL",hl="ALPHANUMERICAL",pl="LOCALHOST",ul="TLD",fl="UTLD",ml="SCHEME",gl="SLASH_SCHEME",yl="NUM",bl="WS",vl="NL",wl="OPENBRACE",kl="CLOSEBRACE",xl="OPENBRACKET",Ml="CLOSEBRACKET",Cl="OPENPAREN",Sl="CLOSEPAREN",Tl="OPENANGLEBRACKET",Al="CLOSEANGLEBRACKET",Ol="FULLWIDTHLEFTPAREN",El="FULLWIDTHRIGHTPAREN",Nl="LEFTCORNERBRACKET",Dl="RIGHTCORNERBRACKET",Rl="LEFTWHITECORNERBRACKET",jl="RIGHTWHITECORNERBRACKET",Ll="FULLWIDTHLESSTHAN",Il="FULLWIDTHGREATERTHAN",Pl="AMPERSAND",zl="APOSTROPHE",$l="ASTERISK",Hl="AT",Bl="BACKSLASH",_l="BACKTICK",Fl="CARET",Vl="COLON",Wl="COMMA",ql="DOLLAR",Kl="DOT",Jl="EQUALS",Ul="EXCLAMATION",Gl="HYPHEN",Yl="PERCENT",Xl="PIPE",Ql="PLUS",Zl="POUND",ta="QUERY",ea="QUOTE",na="FULLWIDTHMIDDLEDOT",oa="SEMI",ra="SLASH",ia="TILDE",sa="UNDERSCORE",la="EMOJI",aa="SYM";var ca=Object.freeze({__proto__:null,WORD:al,UWORD:cl,ASCIINUMERICAL:dl,ALPHANUMERICAL:hl,LOCALHOST:pl,TLD:ul,UTLD:fl,SCHEME:ml,SLASH_SCHEME:gl,NUM:yl,WS:bl,NL:vl,OPENBRACE:wl,CLOSEBRACE:kl,OPENBRACKET:xl,CLOSEBRACKET:Ml,OPENPAREN:Cl,CLOSEPAREN:Sl,OPENANGLEBRACKET:Tl,CLOSEANGLEBRACKET:Al,FULLWIDTHLEFTPAREN:Ol,FULLWIDTHRIGHTPAREN:El,LEFTCORNERBRACKET:Nl,RIGHTCORNERBRACKET:Dl,LEFTWHITECORNERBRACKET:Rl,RIGHTWHITECORNERBRACKET:jl,FULLWIDTHLESSTHAN:Ll,FULLWIDTHGREATERTHAN:Il,AMPERSAND:Pl,APOSTROPHE:zl,ASTERISK:$l,AT:Hl,BACKSLASH:Bl,BACKTICK:_l,CARET:Fl,COLON:Vl,COMMA:Wl,DOLLAR:ql,DOT:Kl,EQUALS:Jl,EXCLAMATION:Ul,HYPHEN:Gl,PERCENT:Yl,PIPE:Xl,PLUS:Ql,POUND:Zl,QUERY:ta,QUOTE:ea,FULLWIDTHMIDDLEDOT:na,SEMI:oa,SLASH:ra,TILDE:ia,UNDERSCORE:sa,EMOJI:la,SYM:aa});const da=/[a-z]/,ha=/\p{L}/u,pa=/\p{Emoji}/u,ua=/\d/,fa=/\s/;let ma=null,ga=null;function ya(t,e){const n=function(t){const e=[],n=t.length;let o=0;for(;o<n;){let r,i=t.charCodeAt(o),s=i<55296||i>56319||o+1===n||(r=t.charCodeAt(o+1))<56320||r>57343?t[o]:t.slice(o,o+2);e.push(s),o+=s.length}return e}(e.replace(/[A-Z]/g,(t=>t.toLowerCase()))),o=n.length,r=[];let i=0,s=0;for(;s<o;){let l=t,a=null,c=0,d=null,h=-1,p=-1;for(;s<o&&(a=l.go(n[s]));)l=a,l.accepts()?(h=0,p=0,d=l):h>=0&&(h+=n[s].length,p++),c+=n[s].length,i+=n[s].length,s++;i-=h,s-=p,c-=h,r.push({t:d.t,v:e.slice(i-c,i),s:i-c,e:i})}return r}function ba(t,e,n,o,r){let i;const s=e.length;for(let n=0;n<s-1;n++){const s=e[n];t.j[s]?i=t.j[s]:(i=new ol(o),i.jr=r.slice(),t.j[s]=i),t=i}return i=new ol(n),i.jr=r.slice(),t.j[e[s-1]]=i,i}function va(t){const e=[],n=[];let o=0;for(;o<t.length;){let r=0;for(;"0123456789".indexOf(t[o+r])>=0;)r++;if(r>0){e.push(n.join(""));for(let e=parseInt(t.substring(o,o+r),10);e>0;e--)n.pop();o+=r}else n.push(t[o]),o++}return e}const wa={defaultProtocol:"http",events:null,format:xa,formatHref:xa,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function ka(t,e=null){let n=Ws({},wa);t&&(n=Ws(n,t instanceof ka?t.o:t));const o=n.ignoreTags,r=[];for(let t=0;t<o.length;t++)r.push(o[t].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=r}function xa(t){return t}function Ma(t,e){this.t="token",this.v=t,this.tk=e}function Ca(t,e){class n extends Ma{constructor(e,n){super(e,n),this.t=t}}for(const t in e)n.prototype[t]=e[t];return n.t=t,n}ka.prototype={o:wa,ignoreTags:[],defaultRender:t=>t,check(t){return this.get("validate",t.toString(),t)},get(t,e,n){const o=null!=e;let r=this.o[t];return r?("object"==typeof r?(r=n.t in r?r[n.t]:wa[t],"function"==typeof r&&o&&(r=r(e,n))):"function"==typeof r&&o&&(r=r(e,n.t,n)),r):r},getObj(t,e,n){let o=this.o[t];return"function"==typeof o&&null!=e&&(o=o(e,n.t,n)),o},render(t){const e=t.render(this);return(this.get("render",null,t)||this.defaultRender)(e,t.t,t)}},Ma.prototype={isLink:!1,toString(){return this.v},toHref(t){return this.toString()},toFormattedString(t){const e=this.toString(),n=t.get("truncate",e,this),o=t.get("format",e,this);return n&&o.length>n?o.substring(0,n)+"…":o},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t=wa.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,n=this.toHref(t.get("defaultProtocol")),o=t.get("formatHref",n,this),r=t.get("tagName",n,e),i=this.toFormattedString(t),s={},l=t.get("className",n,e),a=t.get("target",n,e),c=t.get("rel",n,e),d=t.getObj("attributes",n,e),h=t.getObj("events",n,e);return s.href=o,l&&(s.class=l),a&&(s.target=a),c&&(s.rel=c),d&&Ws(s,d),{tagName:r,attributes:s,content:i,eventListeners:h}}};const Sa=Ca("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Ta=Ca("text"),Aa=Ca("nl"),Oa=Ca("url",{isLink:!0,toHref(t=wa.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==pl&&t[1].t===Vl}}),Ea=t=>new ol(t);function Na(t,e,n){const o=n[0].s,r=n[n.length-1].e;return new t(e.slice(o,r),n)}const Da="undefined"!=typeof console&&console&&console.warn||(()=>{}),Ra={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function ja(t,e=!1){if(Ra.initialized&&Da(`linkifyjs: already initialized - will not register custom scheme "${t}" until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error('linkifyjs: incorrect scheme format.\n1. Must only contain digits, lowercase ASCII letters or "-"\n2. Cannot start or end with "-"\n3. "-" cannot repeat');Ra.customSchemes.push([t,e])}function La(t){return Ra.initialized||function(){Ra.scanner=function(t=[]){const e={};ol.groups=e;const n=new ol;null==ma&&(ma=va("aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2ntley5rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6logistics9properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3ncaster6d0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2psy3ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0america6xi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2")),null==ga&&(ga=va("ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2")),ll(n,"'",zl),ll(n,"{",wl),ll(n,"}",kl),ll(n,"[",xl),ll(n,"]",Ml),ll(n,"(",Cl),ll(n,")",Sl),ll(n,"<",Tl),ll(n,">",Al),ll(n,"(",Ol),ll(n,")",El),ll(n,"「",Nl),ll(n,"」",Dl),ll(n,"『",Rl),ll(n,"』",jl),ll(n,"<",Ll),ll(n,">",Il),ll(n,"&",Pl),ll(n,"*",$l),ll(n,"@",Hl),ll(n,"`",_l),ll(n,"^",Fl),ll(n,":",Vl),ll(n,",",Wl),ll(n,"$",ql),ll(n,".",Kl),ll(n,"=",Jl),ll(n,"!",Ul),ll(n,"-",Gl),ll(n,"%",Yl),ll(n,"|",Xl),ll(n,"+",Ql),ll(n,"#",Zl),ll(n,"?",ta),ll(n,'"',ea),ll(n,"/",ra),ll(n,";",oa),ll(n,"~",ia),ll(n,"_",sa),ll(n,"\\",Bl),ll(n,"・",na);const o=il(n,ua,yl,{[qs]:!0});il(o,ua,o);const r=il(o,da,dl,{[Us]:!0}),i=il(o,ha,hl,{[Gs]:!0}),s=il(n,da,al,{[Ks]:!0});il(s,ua,r),il(s,da,s),il(r,ua,r),il(r,da,r);const l=il(n,ha,cl,{[Js]:!0});il(l,da),il(l,ua,i),il(l,ha,l),il(i,ua,i),il(i,da),il(i,ha,i);const a=ll(n,"\n",vl,{[tl]:!0}),c=ll(n,"\r",bl,{[tl]:!0}),d=il(n,fa,bl,{[tl]:!0});ll(n,"",d),ll(c,"\n",a),ll(c,"",d),il(c,fa,d),ll(d,"\r"),ll(d,"\n"),il(d,fa,d),ll(d,"",d);const h=il(n,pa,la,{[Xs]:!0});ll(h,"#"),il(h,pa,h),ll(h,"️",h);const p=ll(h,"‍");ll(p,"#"),il(p,pa,h);const u=[[da,s],[ua,r]],f=[[da,null],[ha,l],[ua,i]];for(let t=0;t<ma.length;t++)ba(n,ma[t],ul,al,u);for(let t=0;t<ga.length;t++)ba(n,ga[t],fl,cl,f);nl(ul,{tld:!0,ascii:!0},e),nl(fl,{utld:!0,alpha:!0},e),ba(n,"file",ml,al,u),ba(n,"mailto",ml,al,u),ba(n,"http",gl,al,u),ba(n,"https",gl,al,u),ba(n,"ftp",gl,al,u),ba(n,"ftps",gl,al,u),nl(ml,{scheme:!0,ascii:!0},e),nl(gl,{slashscheme:!0,ascii:!0},e),t=t.sort(((t,e)=>t[0]>e[0]?1:-1));for(let e=0;e<t.length;e++){const o=t[e][0],r=t[e][1]?{[Qs]:!0}:{[Zs]:!0};o.indexOf("-")>=0?r[Ys]=!0:da.test(o)?ua.test(o)?r[Us]=!0:r[Ks]=!0:r[qs]=!0,sl(n,o,o,r)}return sl(n,"localhost",pl,{ascii:!0}),n.jd=new ol(aa),{start:n,tokens:Ws({groups:e},ca)}}(Ra.customSchemes);for(let t=0;t<Ra.tokenQueue.length;t++)Ra.tokenQueue[t][1]({scanner:Ra.scanner});Ra.parser=function({groups:t}){const e=t.domain.concat([Pl,$l,Hl,Bl,_l,Fl,ql,Jl,Gl,yl,Yl,Xl,Ql,Zl,ra,aa,ia,sa]),n=[Vl,Wl,Kl,Ul,Yl,ta,ea,oa,Tl,Al,wl,kl,Ml,xl,Cl,Sl,Ol,El,Nl,Dl,Rl,jl,Ll,Il],o=[Pl,zl,$l,Bl,_l,Fl,ql,Jl,Gl,wl,kl,Yl,Xl,Ql,Zl,ta,ra,aa,ia,sa],r=Ea(),i=ll(r,ia);rl(i,o,i),rl(i,t.domain,i);const s=Ea(),l=Ea(),a=Ea();rl(r,t.domain,s),rl(r,t.scheme,l),rl(r,t.slashscheme,a),rl(s,o,i),rl(s,t.domain,s);const c=ll(s,Hl);ll(i,Hl,c),ll(l,Hl,c),ll(a,Hl,c);const d=ll(i,Kl);rl(d,o,i),rl(d,t.domain,i);const h=Ea();rl(c,t.domain,h),rl(h,t.domain,h);const p=ll(h,Kl);rl(p,t.domain,h);const u=Ea(Sa);rl(p,t.tld,u),rl(p,t.utld,u),ll(c,pl,u);const f=ll(h,Gl);ll(f,Gl,f),rl(f,t.domain,h),rl(u,t.domain,h),ll(u,Kl,p),ll(u,Gl,f);const m=ll(u,Vl);rl(m,t.numeric,Sa);const g=ll(s,Gl),y=ll(s,Kl);ll(g,Gl,g),rl(g,t.domain,s),rl(y,o,i),rl(y,t.domain,s);const b=Ea(Oa);rl(y,t.tld,b),rl(y,t.utld,b),rl(b,t.domain,s),rl(b,o,i),ll(b,Kl,y),ll(b,Gl,g),ll(b,Hl,c);const v=ll(b,Vl),w=Ea(Oa);rl(v,t.numeric,w);const k=Ea(Oa),x=Ea();rl(k,e,k),rl(k,n,x),rl(x,e,k),rl(x,n,x),ll(b,ra,k),ll(w,ra,k);const M=ll(l,Vl),C=ll(a,Vl),S=ll(C,ra),T=ll(S,ra);rl(l,t.domain,s),ll(l,Kl,y),ll(l,Gl,g),rl(a,t.domain,s),ll(a,Kl,y),ll(a,Gl,g),rl(M,t.domain,k),ll(M,ra,k),ll(M,ta,k),rl(T,t.domain,k),rl(T,e,k),ll(T,ra,k);const A=[[wl,kl],[xl,Ml],[Cl,Sl],[Tl,Al],[Ol,El],[Nl,Dl],[Rl,jl],[Ll,Il]];for(let t=0;t<A.length;t++){const[o,r]=A[t],i=ll(k,o);ll(x,o,i),ll(i,r,k);const s=Ea(Oa);rl(i,e,s);const l=Ea();rl(i,n),rl(s,e,s),rl(s,n,l),rl(l,e,s),rl(l,n,l),ll(s,r,k),ll(l,r,k)}return ll(r,pl,b),ll(r,vl,Aa),{start:r,tokens:ca}}(Ra.scanner.tokens);for(let t=0;t<Ra.pluginQueue.length;t++)Ra.pluginQueue[t][1]({scanner:Ra.scanner,parser:Ra.parser});Ra.initialized=!0}(),function(t,e,n){let o=n.length,r=0,i=[],s=[];for(;r<o;){let l=t,a=null,c=null,d=0,h=null,p=-1;for(;r<o&&!(a=l.go(n[r].t));)s.push(n[r++]);for(;r<o&&(c=a||l.go(n[r].t));)a=null,l=c,l.accepts()?(p=0,h=l):p>=0&&p++,r++,d++;if(p<0)r-=d,r<o&&(s.push(n[r]),r++);else{s.length>0&&(i.push(Na(Ta,e,s)),s=[]),r-=p,d-=p;const t=h.t,o=n.slice(r-d,r);i.push(Na(t,e,o))}}return s.length>0&&i.push(Na(Ta,e,s)),i}(Ra.parser.start,t,ya(Ra.scanner.start,t))}function Ia(t,e=null,n=null){if(e&&"object"==typeof e){if(n)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);n=e,e=null}const o=new ka(n),r=La(t),i=[];for(let t=0;t<r.length;t++){const n=r[t];!n.isLink||e&&n.t!==e||!o.check(n)||i.push(n.toFormattedObject(o))}return i}function Pa(t){return new xe({key:new Se("autolink"),appendTransaction:(e,n,o)=>{const r=e.some((t=>t.docChanged))&&!n.doc.eq(o.doc),i=e.some((t=>t.getMeta("preventAutolink")));if(!r||i)return;const{tr:s}=o,l=function(t,e){const n=new ee(t);return e.forEach((t=>{t.steps.forEach((t=>{n.step(t)}))})),n}(n.doc,[...e]),a=function(t){const{mapping:e,steps:n}=t,o=[];return e.maps.forEach(((t,r)=>{const i=[];if(t.ranges.length)t.forEach(((t,e)=>{i.push({from:t,to:e})}));else{const{from:t,to:e}=n[r];if(void 0===t||void 0===e)return;i.push({from:t,to:e})}i.forEach((({from:t,to:n})=>{const i=e.slice(r).map(t,-1),s=e.slice(r).map(n),l=e.invert().map(i,-1),a=e.invert().map(s);o.push({oldRange:{from:l,to:a},newRange:{from:i,to:s}})}))})),function(t){const e=function(t,e=JSON.stringify){const n={};return t.filter((t=>{const o=e(t);return!Object.prototype.hasOwnProperty.call(n,o)&&(n[o]=!0)}))}(t);return 1===e.length?e:e.filter(((t,n)=>{const o=e.filter(((t,e)=>e!==n));return!o.some((e=>t.oldRange.from>=e.oldRange.from&&t.oldRange.to<=e.oldRange.to&&t.newRange.from>=e.newRange.from&&t.newRange.to<=e.newRange.to))}))}(o)}(l);return a.forEach((({newRange:e})=>{const n=function(t,e){const n=[];return t.nodesBetween(e.from,e.to,((t,e)=>{(t=>t.isTextblock)(t)&&n.push({node:t,pos:e})})),n}(o.doc,e);let r,i;if(n.length>1?(r=n[0],i=o.doc.textBetween(r.pos,r.pos+r.node.nodeSize,void 0," ")):n.length&&o.doc.textBetween(e.from,e.to," "," ").endsWith(" ")&&(r=n[0],i=o.doc.textBetween(r.pos,e.to,void 0," ")),r&&i){const e=i.split(" ").filter((t=>""!==t));if(e.length<=0)return!1;const n=e[e.length-1],a=r.pos+i.lastIndexOf(n);if(!n)return!1;const c=La(n).map((e=>e.toObject(t.defaultProtocol)));if(!(1===(l=c).length?l[0].isLink:3===l.length&&l[1].isLink&&["()","[]"].includes(l[0].value+l[2].value)))return!1;c.filter((t=>t.isLink)).map((t=>({...t,from:a+t.start+1,to:a+t.end+1}))).filter((t=>!o.schema.marks.code||!o.doc.rangeHasMark(t.from,t.to,o.schema.marks.code))).filter((e=>t.validate(e.value))).forEach((e=>{ws(e.from,e.to,o.doc).some((e=>e.mark.type===t.type))||s.addMark(e.from,e.to,t.type.create({href:e.href}))}))}var l})),s.steps.length?s:void 0}})}La.scan=ya;const za=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g;function $a(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach((t=>{const e="string"==typeof t?t:t.scheme;e&&n.push(e)})),!t||t.replace(za,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z+.-]+(?:[^a-z+.-:]|$))`,"i"))}const Ha=Vi.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.protocols.forEach((t=>{"string"!=typeof t?ja(t.scheme,t.optionalSlashes):ja(t)}))},onDestroy(){ol.groups={},Ra.scanner=null,Ra.parser=null,Ra.tokenQueue=[],Ra.pluginQueue=[],Ra.customSchemes=[],Ra.initialized=!1},inclusive(){return this.options.autolink},addOptions:()=>({openOnClick:!0,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},validate:t=>!!t}),addAttributes(){return{href:{default:null,parseHTML:t=>t.getAttribute("href")},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const e=t.getAttribute("href");return!(!e||!$a(e,this.options.protocols))&&null}}]},renderHTML({HTMLAttributes:t}){return $a(t.href,this.options.protocols)?["a",Oi(this.options.HTMLAttributes,t),0]:["a",Oi(this.options.HTMLAttributes,{...t,href:""}),0]},addCommands(){return{setLink:t=>({chain:e})=>e().setMark(this.name,t).setMeta("preventAutolink",!0).run(),toggleLink:t=>({chain:e})=>e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run(),unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[Vs({find:t=>{const e=[];if(t){const{validate:n}=this.options,o=Ia(t).filter((t=>t.isLink&&n(t.value)));o.length&&o.forEach((t=>e.push({text:t.value,data:{href:t.href},index:t.start})))}return e},type:this.type,getAttributes:t=>{var e;return{href:null===(e=t.data)||void 0===e?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[];return this.options.autolink&&t.push(Pa({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:this.options.validate})),!0===this.options.openOnClick&&t.push((e={type:this.type},new xe({key:new Se("handleClickLink"),props:{handleClick:(t,n,o)=>{var r,i;if(0!==o.button)return!1;if(!t.editable)return!1;let s=o.target;const l=[];for(;"DIV"!==s.nodeName;)l.push(s),s=s.parentNode;if(!l.find((t=>"A"===t.nodeName)))return!1;const a=vs(t.state,e.type.name),c=o.target,d=null!==(r=null==c?void 0:c.href)&&void 0!==r?r:a.href,h=null!==(i=null==c?void 0:c.target)&&void 0!==i?i:a.target;return!(!c||!d||(window.open(d,h),0))}}}))),this.options.linkOnPaste&&t.push(function(t){return new xe({key:new Se("handlePasteLink"),props:{handlePaste:(e,n,o)=>{const{state:r}=e,{selection:i}=r,{empty:s}=i;if(s)return!1;let l="";o.content.forEach((t=>{l+=t.textContent}));const a=Ia(l,{defaultProtocol:t.defaultProtocol}).find((t=>t.isLink&&t.value===l));return!(!l||!a||(t.editor.commands.setMark(t.type,{href:a.href}),0))}}})}({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),t;var e}}),Ba=Ha.extend({addKeyboardShortcuts:()=>({"Mod-k":()=>(window.dispatchEvent(new Event("edit-link")),!0)})}).configure({openOnClick:!1});var _a=n(74848),Fa=n(40295),Va=n.n(Fa),Wa=n(2412),qa=n(46100),Ka=n(52837),Ja=n(14791);const Ua={linkControlLabel:"Link",colorPickerControlLabel:"Text color",highlightControlLabel:"Highlight text",colorControlLabel:t=>`Set text color ${t}`,boldControlLabel:"Bold",italicControlLabel:"Italic",underlineControlLabel:"Underline",strikeControlLabel:"Strikethrough",clearFormattingControlLabel:"Clear formatting",unlinkControlLabel:"Remove link",bulletListControlLabel:"Bullet list",orderedListControlLabel:"Ordered list",h1ControlLabel:"Heading 1",h2ControlLabel:"Heading 2",h3ControlLabel:"Heading 3",h4ControlLabel:"Heading 4",h5ControlLabel:"Heading 5",h6ControlLabel:"Heading 6",blockquoteControlLabel:"Blockquote",alignLeftControlLabel:"Align text: left",alignCenterControlLabel:"Align text: center",alignRightControlLabel:"Align text: right",alignJustifyControlLabel:"Align text: justify",codeControlLabel:"Code",codeBlockControlLabel:"Code block",subscriptControlLabel:"Subscript",superscriptControlLabel:"Superscript",unsetColorControlLabel:"Unset color",hrControlLabel:"Horizontal line",undoControlLabel:"Undo",redoControlLabel:"Redo",tasksControlLabel:"Task list",tasksSinkLabel:"Decrease task level",tasksLiftLabel:"Increase task level",linkEditorInputLabel:"Enter URL",linkEditorInputPlaceholder:"https://example.com/",linkEditorExternalLink:"Open link in a new tab",linkEditorInternalLink:"Open link in the same tab",linkEditorSave:"Save",colorPickerCancel:"Cancel",colorPickerClear:"Clear color",colorPickerColorPicker:"Color picker",colorPickerPalette:"Color palette",colorPickerSave:"Save",colorPickerColorLabel:t=>`Set text color ${t}`};var Ga=n(46798);const[Ya,Xa]=(0,Ga.F)("RichTextEditor component was not found in tree");var Qa=n(23775);function Za(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var tc,ec={exports:{}},nc={};ec.exports=function(){if(tc)return nc;tc=1;var t=Fa,e="function"==typeof Object.is?Object.is:function(t,e){return t===e&&(0!==t||1/t==1/e)||t!=t&&e!=e},n=t.useState,o=t.useEffect,r=t.useLayoutEffect,i=t.useDebugValue;function s(t){var n=t.getSnapshot;t=t.value;try{var o=n();return!e(t,o)}catch(t){return!0}}var l="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(t,e){return e()}:function(t,e){var l=e(),a=n({inst:{value:l,getSnapshot:e}}),c=a[0].inst,d=a[1];return r((function(){c.value=l,c.getSnapshot=e,s(c)&&d({inst:c})}),[t,l,e]),o((function(){return s(c)&&d({inst:c}),t((function(){s(c)&&d({inst:c})}))}),[t]),i(l),l};return nc.useSyncExternalStore=void 0!==t.useSyncExternalStore?t.useSyncExternalStore:l,nc}();var oc=ec.exports;const rc=(...t)=>e=>{t.forEach((t=>{"function"==typeof t?t(e):t&&(t.current=e)}))},ic=({contentComponent:t})=>{const e=oc.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return Fa.createElement(Fa.Fragment,null,Object.values(e))};class sc extends Fa.Component{constructor(t){var e;super(t),this.editorContentRef=Fa.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:Boolean(null===(e=t.editor)||void 0===e?void 0:e.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){const t=this.props.editor;if(t&&!t.isDestroyed&&t.options.element){if(t.contentComponent)return;const e=this.editorContentRef.current;e.append(...t.options.element.childNodes),t.setOptions({element:e}),t.contentComponent=function(){const t=new Set;let e={};return{subscribe:e=>(t.add(e),()=>{t.delete(e)}),getSnapshot:()=>e,getServerSnapshot:()=>e,setRenderer(n,o){e={...e,[n]:Qa.createPortal(o.reactElement,o.element,n)},t.forEach((t=>t()))},removeRenderer(n){const o={...e};delete o[n],e=o,t.forEach((t=>t()))}}}(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=t.contentComponent.subscribe((()=>{this.setState((t=>t.hasContentComponentInitialized?t:{hasContentComponentInitialized:!0})),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()}))),t.createNodeViews(),this.initialized=!0}}componentWillUnmount(){const t=this.props.editor;if(!t)return;if(this.initialized=!1,t.isDestroyed||t.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),t.contentComponent=null,!t.options.element.firstChild)return;const e=document.createElement("div");e.append(...t.options.element.childNodes),t.setOptions({element:e})}render(){const{editor:t,innerRef:e,...n}=this.props;return Fa.createElement(Fa.Fragment,null,Fa.createElement("div",{ref:rc(e,this.editorContentRef),...n}),(null==t?void 0:t.contentComponent)&&Fa.createElement(ic,{contentComponent:t.contentComponent}))}}const lc=(0,Fa.forwardRef)(((t,e)=>{const n=Fa.useMemo((()=>Math.floor(4294967295*Math.random()).toString()),[t.editor]);return Fa.createElement(sc,{key:n,innerRef:e,...t})})),ac=Fa.memo(lc);var cc,dc=function t(e,n){if(e===n)return!0;if(e&&n&&"object"==typeof e&&"object"==typeof n){if(e.constructor!==n.constructor)return!1;var o,r,i;if(Array.isArray(e)){if((o=e.length)!=n.length)return!1;for(r=o;0!=r--;)if(!t(e[r],n[r]))return!1;return!0}if(e instanceof Map&&n instanceof Map){if(e.size!==n.size)return!1;for(r of e.entries())if(!n.has(r[0]))return!1;for(r of e.entries())if(!t(r[1],n.get(r[0])))return!1;return!0}if(e instanceof Set&&n instanceof Set){if(e.size!==n.size)return!1;for(r of e.entries())if(!n.has(r[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(n)){if((o=e.length)!=n.length)return!1;for(r=o;0!=r--;)if(e[r]!==n[r])return!1;return!0}if(e.constructor===RegExp)return e.source===n.source&&e.flags===n.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===n.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===n.toString();if((o=(i=Object.keys(e)).length)!==Object.keys(n).length)return!1;for(r=o;0!=r--;)if(!Object.prototype.hasOwnProperty.call(n,i[r]))return!1;for(r=o;0!=r--;){var s=i[r];if(!("_owner"===s&&e.$$typeof||t(e[s],n[s])))return!1}return!0}return e!=e&&n!=n},hc=Za(dc),pc={exports:{}},uc={};pc.exports=function(){if(cc)return uc;cc=1;var t=Fa,e=oc,n="function"==typeof Object.is?Object.is:function(t,e){return t===e&&(0!==t||1/t==1/e)||t!=t&&e!=e},o=e.useSyncExternalStore,r=t.useRef,i=t.useEffect,s=t.useMemo,l=t.useDebugValue;return uc.useSyncExternalStoreWithSelector=function(t,e,a,c,d){var h=r(null);if(null===h.current){var p={hasValue:!1,value:null};h.current=p}else p=h.current;h=s((function(){function t(t){if(!i){if(i=!0,o=t,t=c(t),void 0!==d&&p.hasValue){var e=p.value;if(d(e,t))return r=e}return r=t}if(e=r,n(o,t))return e;var s=c(t);return void 0!==d&&d(e,s)?e:(o=t,r=s)}var o,r,i=!1,s=void 0===a?null:a;return[function(){return t(e())},null===s?void 0:function(){return t(s())}]}),[e,a,c,d]);var u=o(t,h[0],h[1]);return i((function(){p.hasValue=!0,p.value=u}),[u]),l(u),u},uc}();var fc=pc.exports;class mc{constructor(t){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=t,this.lastSnapshot={editor:t,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber||(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber}),this.lastSnapshot}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}watch(t){if(this.editor=t,this.editor){const t=()=>{this.transactionNumber+=1,this.subscribers.forEach((t=>t()))},e=this.editor;return e.on("transaction",t),()=>{e.off("transaction",t)}}}}const gc="undefined"==typeof window,yc=gc||Boolean("undefined"!=typeof window&&window.next);class bc{constructor(t){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=t,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(t){this.editor=t,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach((t=>t()))}getInitialEditor(){return void 0===this.options.current.immediatelyRender?gc||yc?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const t={...this.options.current,onBeforeCreate:(...t)=>{var e,n;return null===(n=(e=this.options.current).onBeforeCreate)||void 0===n?void 0:n.call(e,...t)},onBlur:(...t)=>{var e,n;return null===(n=(e=this.options.current).onBlur)||void 0===n?void 0:n.call(e,...t)},onCreate:(...t)=>{var e,n;return null===(n=(e=this.options.current).onCreate)||void 0===n?void 0:n.call(e,...t)},onDestroy:(...t)=>{var e,n;return null===(n=(e=this.options.current).onDestroy)||void 0===n?void 0:n.call(e,...t)},onFocus:(...t)=>{var e,n;return null===(n=(e=this.options.current).onFocus)||void 0===n?void 0:n.call(e,...t)},onSelectionUpdate:(...t)=>{var e,n;return null===(n=(e=this.options.current).onSelectionUpdate)||void 0===n?void 0:n.call(e,...t)},onTransaction:(...t)=>{var e,n;return null===(n=(e=this.options.current).onTransaction)||void 0===n?void 0:n.call(e,...t)},onUpdate:(...t)=>{var e,n;return null===(n=(e=this.options.current).onUpdate)||void 0===n?void 0:n.call(e,...t)},onContentError:(...t)=>{var e,n;return null===(n=(e=this.options.current).onContentError)||void 0===n?void 0:n.call(e,...t)},onDrop:(...t)=>{var e,n;return null===(n=(e=this.options.current).onDrop)||void 0===n?void 0:n.call(e,...t)},onPaste:(...t)=>{var e,n;return null===(n=(e=this.options.current).onPaste)||void 0===n?void 0:n.call(e,...t)}};return new zs(t)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(t){return this.subscriptions.add(t),()=>{this.subscriptions.delete(t)}}onRender(t){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&0===t.length?this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(t),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(t){if(this.editor&&!this.editor.isDestroyed){if(null===this.previousDeps)return void(this.previousDeps=t);if(this.previousDeps.length===t.length&&this.previousDeps.every(((e,n)=>e===t[n])))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=t}scheduleDestroy(){const t=this.instanceId,e=this.editor;this.scheduledDestructionTimeout=setTimeout((()=>{this.isComponentMounted&&this.instanceId===t?e&&e.setOptions(this.options.current):e&&!e.isDestroyed&&(e.destroy(),this.instanceId===t&&this.setEditor(null))}),1)}}(0,Fa.createContext)({editor:null}).Consumer;const vc=(0,Fa.createContext)({onDragStart:void 0});Fa.forwardRef(((t,e)=>{const{onDragStart:n}=(0,Fa.useContext)(vc),o=t.as||"div";return Fa.createElement(o,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})}));var wc=n(3669),kc={root:"m_dd3f7539",typographyStylesProvider:"m_d37966d9",content:"m_c2204cc2",linkEditorDropdown:"m_8a991b4f",control:"m_c2207da6",controlIcon:"m_9cdfeb3f",controlsGroup:"m_2ab47ef2",linkEditor:"m_b67b711e",linkEditorInput:"m_296cf94c",linkEditorExternalControl:"m_cfef614",linkEditorSave:"m_3b28e7bb",toolbar:"m_4574a3c4",taskList:"m_8b44009a"};const xc={},Mc=(0,Wa.P9)(((t,e)=>{const n=(0,qa.Y)("RichTextEditorContent",xc,t),{classNames:o,className:r,style:i,styles:s,vars:l,...a}=n,c=Xa();return c.withTypographyStyles?(0,_a.jsx)(wc.Z,{...c.getStyles("typographyStylesProvider",{className:r,style:i,styles:s,classNames:o}),unstyled:c.unstyled,ref:e,children:(0,_a.jsx)(Ja.a,{component:ac,editor:c.editor,...c.getStyles("content",{classNames:o,styles:s}),...a})}):(0,_a.jsx)(Ja.a,{component:ac,editor:c.editor,...c.getStyles("content",{classNames:o,styles:s,className:r,style:i}),...a})}));function Cc(t){return(0,_a.jsx)("svg",{...t,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})}function Sc(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M7 5h6a3.5 3.5 0 0 1 0 7h-6z"}),(0,_a.jsx)("path",{d:"M13 12h1a3.5 3.5 0 0 1 0 7h-7v-7"})]})}function Tc(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M11 5l6 0"}),(0,_a.jsx)("path",{d:"M7 19l6 0"}),(0,_a.jsx)("path",{d:"M14 5l-4 14"})]})}function Ac(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M7 5v5a5 5 0 0 0 10 0v-5"}),(0,_a.jsx)("path",{d:"M5 19h14"})]})}function Oc(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M5 12l14 0"}),(0,_a.jsx)("path",{d:"M16 6.5a4 2 0 0 0 -4 -1.5h-1a3.5 3.5 0 0 0 0 7h2a3.5 3.5 0 0 1 0 7h-1.5a4 2 0 0 1 -4 -1.5"})]})}function Ec(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M17 15l4 4m0 -4l-4 4"}),(0,_a.jsx)("path",{d:"M7 6v-1h11v1"}),(0,_a.jsx)("path",{d:"M7 19l4 0"}),(0,_a.jsx)("path",{d:"M13 5l-4 14"})]})}function Nc(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M19 18v-8l-2 2"}),(0,_a.jsx)("path",{d:"M4 6v12"}),(0,_a.jsx)("path",{d:"M12 6v12"}),(0,_a.jsx)("path",{d:"M11 18h2"}),(0,_a.jsx)("path",{d:"M3 18h2"}),(0,_a.jsx)("path",{d:"M4 12h8"}),(0,_a.jsx)("path",{d:"M3 6h2"}),(0,_a.jsx)("path",{d:"M11 6h2"})]})}function Dc(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M17 12a2 2 0 1 1 4 0c0 .591 -.417 1.318 -.816 1.858l-3.184 4.143l4 0"}),(0,_a.jsx)("path",{d:"M4 6v12"}),(0,_a.jsx)("path",{d:"M12 6v12"}),(0,_a.jsx)("path",{d:"M11 18h2"}),(0,_a.jsx)("path",{d:"M3 18h2"}),(0,_a.jsx)("path",{d:"M4 12h8"}),(0,_a.jsx)("path",{d:"M3 6h2"}),(0,_a.jsx)("path",{d:"M11 6h2"})]})}function Rc(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M19 14a2 2 0 1 0 -2 -2"}),(0,_a.jsx)("path",{d:"M17 16a2 2 0 1 0 2 -2"}),(0,_a.jsx)("path",{d:"M4 6v12"}),(0,_a.jsx)("path",{d:"M12 6v12"}),(0,_a.jsx)("path",{d:"M11 18h2"}),(0,_a.jsx)("path",{d:"M3 18h2"}),(0,_a.jsx)("path",{d:"M4 12h8"}),(0,_a.jsx)("path",{d:"M3 6h2"}),(0,_a.jsx)("path",{d:"M11 6h2"})]})}function jc(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M20 18v-8l-4 6h5"}),(0,_a.jsx)("path",{d:"M4 6v12"}),(0,_a.jsx)("path",{d:"M12 6v12"}),(0,_a.jsx)("path",{d:"M11 18h2"}),(0,_a.jsx)("path",{d:"M3 18h2"}),(0,_a.jsx)("path",{d:"M4 12h8"}),(0,_a.jsx)("path",{d:"M3 6h2"}),(0,_a.jsx)("path",{d:"M11 6h2"})]})}function Lc(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M17 18h2a2 2 0 1 0 0 -4h-2v-4h4"}),(0,_a.jsx)("path",{d:"M4 6v12"}),(0,_a.jsx)("path",{d:"M12 6v12"}),(0,_a.jsx)("path",{d:"M11 18h2"}),(0,_a.jsx)("path",{d:"M3 18h2"}),(0,_a.jsx)("path",{d:"M4 12h8"}),(0,_a.jsx)("path",{d:"M3 6h2"}),(0,_a.jsx)("path",{d:"M11 6h2"})]})}function Ic(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M19 14a2 2 0 1 0 0 4a2 2 0 0 0 0 -4z"}),(0,_a.jsx)("path",{d:"M21 12a2 2 0 1 0 -4 0v4"}),(0,_a.jsx)("path",{d:"M4 6v12"}),(0,_a.jsx)("path",{d:"M12 6v12"}),(0,_a.jsx)("path",{d:"M11 18h2"}),(0,_a.jsx)("path",{d:"M3 18h2"}),(0,_a.jsx)("path",{d:"M4 12h8"}),(0,_a.jsx)("path",{d:"M3 6h2"}),(0,_a.jsx)("path",{d:"M11 6h2"})]})}function Pc(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M9 6l11 0"}),(0,_a.jsx)("path",{d:"M9 12l11 0"}),(0,_a.jsx)("path",{d:"M9 18l11 0"}),(0,_a.jsx)("path",{d:"M5 6l0 .01"}),(0,_a.jsx)("path",{d:"M5 12l0 .01"}),(0,_a.jsx)("path",{d:"M5 18l0 .01"})]})}function zc(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M11 6h9"}),(0,_a.jsx)("path",{d:"M11 12h9"}),(0,_a.jsx)("path",{d:"M12 18h8"}),(0,_a.jsx)("path",{d:"M4 16a2 2 0 1 1 4 0c0 .591 -.5 1 -1 1.5l-3 2.5h4"}),(0,_a.jsx)("path",{d:"M6 10v-6l-2 2"})]})}function $c(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M17 22v-2"}),(0,_a.jsx)("path",{d:"M9 15l6 -6"}),(0,_a.jsx)("path",{d:"M11 6l.463 -.536a5 5 0 0 1 7.071 7.072l-.534 .464"}),(0,_a.jsx)("path",{d:"M13 18l-.397 .534a5.068 5.068 0 0 1 -7.127 0a4.972 4.972 0 0 1 0 -7.071l.524 -.463"}),(0,_a.jsx)("path",{d:"M20 17h2"}),(0,_a.jsx)("path",{d:"M2 7h2"}),(0,_a.jsx)("path",{d:"M7 2v2"})]})}function Hc(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M6 15h15"}),(0,_a.jsx)("path",{d:"M21 19h-15"}),(0,_a.jsx)("path",{d:"M15 11h6"}),(0,_a.jsx)("path",{d:"M21 7h-6"}),(0,_a.jsx)("path",{d:"M9 9h1a1 1 0 1 1 -1 1v-2.5a2 2 0 0 1 2 -2"}),(0,_a.jsx)("path",{d:"M3 9h1a1 1 0 1 1 -1 1v-2.5a2 2 0 0 1 2 -2"})]})}function Bc(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M4 6l16 0"}),(0,_a.jsx)("path",{d:"M4 12l10 0"}),(0,_a.jsx)("path",{d:"M4 18l14 0"})]})}function _c(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M4 6l16 0"}),(0,_a.jsx)("path",{d:"M10 12l10 0"}),(0,_a.jsx)("path",{d:"M6 18l14 0"})]})}function Fc(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M4 6l16 0"}),(0,_a.jsx)("path",{d:"M8 12l8 0"}),(0,_a.jsx)("path",{d:"M6 18l12 0"})]})}function Vc(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M4 6l16 0"}),(0,_a.jsx)("path",{d:"M4 12l16 0"}),(0,_a.jsx)("path",{d:"M4 18l12 0"})]})}function Wc(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M5 7l8 10m-8 0l8 -10"}),(0,_a.jsx)("path",{d:"M21 20h-4l3.5 -4a1.73 1.73 0 0 0 -3.5 -2"})]})}function qc(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M5 7l8 10m-8 0l8 -10"}),(0,_a.jsx)("path",{d:"M21 11h-4l3.5 -4a1.73 1.73 0 0 0 -3.5 -2"})]})}function Kc(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M7 8l-4 4l4 4"}),(0,_a.jsx)("path",{d:"M17 8l4 4l-4 4"}),(0,_a.jsx)("path",{d:"M14 4l-4 16"})]})}function Jc(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M3 19h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4"}),(0,_a.jsx)("path",{d:"M12.5 5.5l4 4"}),(0,_a.jsx)("path",{d:"M4.5 13.5l4 4"}),(0,_a.jsx)("path",{d:"M21 15v4h-8l4 -4z"})]})}function Uc(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M5 12h2"}),(0,_a.jsx)("path",{d:"M17 12h2"}),(0,_a.jsx)("path",{d:"M11 12h2"})]})}function Gc(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M20.042 16.045a9 9 0 0 0 -12.087 -12.087m-2.318 1.677a9 9 0 1 0 12.725 12.73"}),(0,_a.jsx)("path",{d:"M3 3l18 18"})]})}function Yc(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M11 7l6 6"}),(0,_a.jsx)("path",{d:"M4 16l11.7 -11.7a1 1 0 0 1 1.4 0l2.6 2.6a1 1 0 0 1 0 1.4l-11.7 11.7h-4v-4z"})]})}function Xc(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M18 6l-12 12"}),(0,_a.jsx)("path",{d:"M6 6l12 12"})]})}function Qc(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M12 21a9 9 0 0 1 0 -18c4.97 0 9 3.582 9 8c0 1.06 -.474 2.078 -1.318 2.828c-.844 .75 -1.989 1.172 -3.182 1.172h-2.5a2 2 0 0 0 -1 3.75a1.3 1.3 0 0 1 -1 2.25"}),(0,_a.jsx)("path",{d:"M8.5 10.5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"}),(0,_a.jsx)("path",{d:"M12.5 7.5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"}),(0,_a.jsx)("path",{d:"M16.5 10.5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"})]})}function Zc(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M5 12l5 5l10 -10"})]})}function td(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M9 15l6 -6"}),(0,_a.jsx)("path",{d:"M11 6l.463 -.536a5 5 0 0 1 7.071 7.072l-.534 .464"}),(0,_a.jsx)("path",{d:"M13 18l-.397 .534a5.068 5.068 0 0 1 -7.127 0a4.972 4.972 0 0 1 0 -7.071l.524 -.463"})]})}function ed(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M12 6h-6a2 2 0 0 0 -2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-6"}),(0,_a.jsx)("path",{d:"M11 13l9 -9"}),(0,_a.jsx)("path",{d:"M15 4h5v5"})]})}function nd(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M9 14l-4 -4l4 -4"}),(0,_a.jsx)("path",{d:"M5 10h11a4 4 0 1 1 0 8h-1"})]})}function od(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M15 14l4 -4l-4 -4"}),(0,_a.jsx)("path",{d:"M19 10h-11a4 4 0 1 0 0 8h1"})]})}function rd(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M3.5 5.5l1.5 1.5l2.5 -2.5"}),(0,_a.jsx)("path",{d:"M3.5 11.5l1.5 1.5l2.5 -2.5"}),(0,_a.jsx)("path",{d:"M3.5 17.5l1.5 1.5l2.5 -2.5"}),(0,_a.jsx)("path",{d:"M11 6l9 0"}),(0,_a.jsx)("path",{d:"M11 12l9 0"}),(0,_a.jsx)("path",{d:"M11 18l9 0"})]})}function id(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M20 6l-11 0"}),(0,_a.jsx)("path",{d:"M20 12l-7 0"}),(0,_a.jsx)("path",{d:"M20 18l-11 0"}),(0,_a.jsx)("path",{d:"M4 8l4 4l-4 4"})]})}function sd(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M20 6l-7 0"}),(0,_a.jsx)("path",{d:"M20 12l-9 0"}),(0,_a.jsx)("path",{d:"M20 18l-7 0"}),(0,_a.jsx)("path",{d:"M8 8l-4 4l4 4"})]})}Mc.classes=kc,Mc.displayName="@mantine/tiptap/RichTextEditorContent";var ld=n(46076);const ad={interactive:!0},cd=(0,Wa.P9)(((t,e)=>{const n=(0,qa.Y)("RichTextEditorControl",ad,t),{classNames:o,className:r,style:i,styles:s,vars:l,interactive:a,active:c,onMouseDown:d,disabled:h,...p}=n,u=Xa();return(0,_a.jsx)(ld.N,{...p,...u.getStyles("control",{className:r,style:i,classNames:o,styles:s}),disabled:h,"data-rich-text-editor-control":!0,tabIndex:a?0:-1,"data-interactive":a||void 0,"data-disabled":h||void 0,"data-active":c||void 0,"aria-pressed":c&&a||void 0,"aria-hidden":!a||void 0,ref:e,unstyled:u.unstyled,variant:u.variant||"default",onMouseDown:t=>{t.preventDefault(),d?.(t)}})}));cd.classes=kc,cd.displayName="@mantine/tiptap/RichTextEditorControl";const dd=(0,Fa.forwardRef)((({className:t,icon:e,...n},o)=>{const r=Xa();return(0,_a.jsx)(cd,{ref:o,...n,children:(0,_a.jsx)(e,{...r.getStyles("controlIcon")})})}));function hd({label:t,isActive:e,operation:n,icon:o,isDisabled:r}){const i=(0,Fa.forwardRef)(((i,s)=>{const{editor:l,labels:a}=Xa(),c=a[t];return(0,_a.jsx)(dd,{...i,"aria-label":c,title:c,active:!!e?.name&&l?.isActive(e.name,e.attributes),ref:s,onClick:()=>l?.chain().focus()[n.name](n.attributes).run(),icon:i.icon||o,disabled:r?.(l)||!1})}));return i.displayName=`@mantine/tiptap/${t}`,i}dd.displayName="@mantine/tiptap/RichTextEditorControlBase";const pd=hd({label:"boldControlLabel",icon:t=>(0,_a.jsx)(Sc,{...t}),isActive:{name:"bold"},operation:{name:"toggleBold"}}),ud=hd({label:"italicControlLabel",icon:t=>(0,_a.jsx)(Tc,{...t}),isActive:{name:"italic"},operation:{name:"toggleItalic"}}),fd=hd({label:"underlineControlLabel",icon:t=>(0,_a.jsx)(Ac,{...t}),isActive:{name:"underline"},operation:{name:"toggleUnderline"}}),md=hd({label:"strikeControlLabel",icon:t=>(0,_a.jsx)(Oc,{...t}),isActive:{name:"strike"},operation:{name:"toggleStrike"}}),gd=hd({label:"clearFormattingControlLabel",icon:t=>(0,_a.jsx)(Ec,{...t}),operation:{name:"unsetAllMarks"}}),yd=hd({label:"unlinkControlLabel",icon:t=>(0,_a.jsx)($c,{...t}),operation:{name:"unsetLink"}}),bd=hd({label:"bulletListControlLabel",icon:t=>(0,_a.jsx)(Pc,{...t}),isActive:{name:"bulletList"},operation:{name:"toggleBulletList"}}),vd=hd({label:"orderedListControlLabel",icon:t=>(0,_a.jsx)(zc,{...t}),isActive:{name:"orderedList"},operation:{name:"toggleOrderedList"}}),wd=hd({label:"h1ControlLabel",icon:t=>(0,_a.jsx)(Nc,{...t}),isActive:{name:"heading",attributes:{level:1}},operation:{name:"toggleHeading",attributes:{level:1}}}),kd=hd({label:"h2ControlLabel",icon:t=>(0,_a.jsx)(Dc,{...t}),isActive:{name:"heading",attributes:{level:2}},operation:{name:"toggleHeading",attributes:{level:2}}}),xd=hd({label:"h3ControlLabel",icon:t=>(0,_a.jsx)(Rc,{...t}),isActive:{name:"heading",attributes:{level:3}},operation:{name:"toggleHeading",attributes:{level:3}}}),Md=hd({label:"h4ControlLabel",icon:t=>(0,_a.jsx)(jc,{...t}),isActive:{name:"heading",attributes:{level:4}},operation:{name:"toggleHeading",attributes:{level:4}}}),Cd=hd({label:"h5ControlLabel",icon:t=>(0,_a.jsx)(Lc,{...t}),isActive:{name:"heading",attributes:{level:5}},operation:{name:"toggleHeading",attributes:{level:5}}}),Sd=hd({label:"h6ControlLabel",icon:t=>(0,_a.jsx)(Ic,{...t}),isActive:{name:"heading",attributes:{level:6}},operation:{name:"toggleHeading",attributes:{level:6}}}),Td=hd({label:"blockquoteControlLabel",icon:t=>(0,_a.jsx)(Hc,{...t}),isActive:{name:"blockquote"},operation:{name:"toggleBlockquote"}}),Ad=hd({label:"alignLeftControlLabel",icon:t=>(0,_a.jsx)(Bc,{...t}),operation:{name:"setTextAlign",attributes:"left"}}),Od=hd({label:"alignRightControlLabel",icon:t=>(0,_a.jsx)(_c,{...t}),operation:{name:"setTextAlign",attributes:"right"}}),Ed=hd({label:"alignCenterControlLabel",icon:t=>(0,_a.jsx)(Fc,{...t}),operation:{name:"setTextAlign",attributes:"center"}}),Nd=hd({label:"alignJustifyControlLabel",icon:t=>(0,_a.jsx)(Vc,{...t}),operation:{name:"setTextAlign",attributes:"justify"}}),Dd=hd({label:"subscriptControlLabel",icon:t=>(0,_a.jsx)(Wc,{...t}),isActive:{name:"subscript"},operation:{name:"toggleSubscript"}}),Rd=hd({label:"superscriptControlLabel",icon:t=>(0,_a.jsx)(qc,{...t}),isActive:{name:"superscript"},operation:{name:"toggleSuperscript"}}),jd=hd({label:"codeControlLabel",icon:t=>(0,_a.jsx)(Kc,{...t}),isActive:{name:"code"},operation:{name:"toggleCode"}}),Ld=hd({label:"codeBlockControlLabel",icon:t=>(0,_a.jsx)(Kc,{...t}),isActive:{name:"codeBlock"},operation:{name:"toggleCodeBlock"}}),Id=hd({label:"highlightControlLabel",icon:t=>(0,_a.jsx)(Jc,{...t}),isActive:{name:"highlight"},operation:{name:"toggleHighlight"}}),Pd=hd({label:"hrControlLabel",icon:t=>(0,_a.jsx)(Uc,{...t}),operation:{name:"setHorizontalRule"}}),zd=hd({label:"unsetColorControlLabel",icon:t=>(0,_a.jsx)(Gc,{...t}),operation:{name:"unsetColor"}}),$d=hd({label:"undoControlLabel",icon:t=>(0,_a.jsx)(nd,{...t}),isDisabled:t=>!t?.can().undo(),operation:{name:"undo"}}),Hd=hd({label:"redoControlLabel",icon:t=>(0,_a.jsx)(od,{...t}),isDisabled:t=>!t?.can().redo(),operation:{name:"redo"}}),Bd=hd({label:"tasksControlLabel",icon:t=>(0,_a.jsx)(rd,{...t}),isActive:{name:"taskList"},operation:{name:"toggleTaskList"}}),_d=hd({label:"tasksSinkLabel",icon:t=>(0,_a.jsx)(id,{...t}),operation:{name:"sinkListItem",attributes:"taskItem"},isDisabled:t=>!t?.can().sinkListItem("taskItem")}),Fd=hd({label:"tasksLiftLabel",icon:t=>(0,_a.jsx)(sd,{...t}),operation:{name:"liftListItem",attributes:"taskItem"},isDisabled:t=>!t?.can().liftListItem("taskItem")});var Vd=n(99274),Wd=n(25172),qd=n(57193),Kd=n(12335),Jd=n(88149),Ud=n(5055);function Gd(t){return e=>{if(e)if("function"==typeof e)t(e);else if("object"==typeof e&&"nativeEvent"in e){const{currentTarget:n}=e;"checkbox"===n.type?t(n.checked):t(n.value)}else t(e);else t(e)}}var Yd=n(13489),Xd=n(60977);const Qd=t=>(0,_a.jsx)(td,{...t}),Zd={},th=(0,Wa.P9)(((t,e)=>{const n=(0,qa.Y)("RichTextEditorLinkControl",Zd,t),{classNames:o,className:r,style:i,styles:s,vars:l,icon:a,popoverProps:c,disableTooltips:d,initialExternal:h,...p}=n,u=Xa(),f={classNames:o,styles:s},[m,g]=function(){const[t,e]=(0,Fa.useState)("");return[t,Gd(e)]}(),[y,b]=(0,Fa.useState)(h),[v,{open:w,close:k}]=(0,Yd.j)(!1),x=()=>{w();const t=u.editor?.getAttributes("link");g(t?.href||""),b(t?.href?"_blank"===t?.target:h)},M=()=>{k(),g(""),b(h)},C=()=>{M(),""===m?u.editor?.chain().focus().extendMarkRange("link").unsetLink().run():u.editor?.chain().focus().extendMarkRange("link").setLink({href:m,target:y?"_blank":null}).run()};(0,Xd.M)("edit-link",x,!1);const{resolvedClassNames:S,resolvedStyles:T}=(0,Vd.Y)({classNames:o,styles:s,props:n});return(0,_a.jsxs)(Wd.A,{trapFocus:!0,shadow:"md",withinPortal:!0,opened:v,onChange:t=>!t&&M(),offset:-44,zIndex:1e4,...c,children:[(0,_a.jsx)(Wd.A.Target,{children:(0,_a.jsx)(dd,{icon:a||Qd,...p,"aria-label":u.labels.linkControlLabel,title:u.labels.linkControlLabel,onClick:x,active:u.editor?.isActive("link"),ref:e,classNames:S,styles:T,className:r,style:i,variant:u.variant})}),(0,_a.jsx)(Wd.A.Dropdown,{...u.getStyles("linkEditorDropdown",f),children:(0,_a.jsxs)("div",{...u.getStyles("linkEditor",f),children:[(0,_a.jsx)(qd.k,{placeholder:u.labels.linkEditorInputPlaceholder,"aria-label":u.labels.linkEditorInputLabel,type:"url",value:m,onChange:g,classNames:{input:u.getStyles("linkEditorInput",f).className},onKeyDown:t=>{"Enter"===t.key&&(t.preventDefault(),C())},rightSection:(0,_a.jsx)(Kd.m,{label:y?u.labels.linkEditorExternalLink:u.labels.linkEditorInternalLink,events:{hover:!0,focus:!0,touch:!0},withinPortal:!0,withArrow:!0,disabled:d,zIndex:1e4,children:(0,_a.jsx)(ld.N,{onClick:()=>b((t=>!t)),"data-active":y||void 0,...u.getStyles("linkEditorExternalControl",f),children:(0,_a.jsx)(ed,{style:{width:(0,Jd.D)(14),height:(0,Jd.D)(14)}})})})}),(0,_a.jsx)(Ud.$,{variant:"default",onClick:C,...u.getStyles("linkEditorSave",f),children:u.labels.linkEditorSave})]})})]})}));th.classes=kc,th.displayName="@mantine/tiptap/RichTextEditorLinkControl";var eh=n(59731),nh=n(29277),oh=n(22865),rh=n(64999),ih=n(48324);const sh={},lh=(0,Fa.forwardRef)(((t,e)=>{const{popoverProps:n,colors:o,colorPickerProps:r,...i}=(0,qa.Y)("RichTextEditorColorPickerControl",sh,t),{editor:s,labels:l,getStyles:a,variant:c}=Xa(),[d,{toggle:h,close:p}]=(0,Yd.j)(!1),[u,f]=(0,Fa.useState)("palette"),m=s?.getAttributes("textStyle").color||"var(--mantine-color-text)",g=(t,e=!0)=>{(s?.chain()).focus().setColor(t).run(),e&&p()},y=o.map(((t,e)=>(0,_a.jsx)(eh.q,{component:"button",color:t,onClick:()=>g(t),size:26,radius:"xs",style:{cursor:"pointer"},title:l.colorPickerColorLabel(t),"aria-label":l.colorPickerColorLabel(t)},e)));return(0,_a.jsxs)(Wd.A,{opened:d,withinPortal:!0,trapFocus:!0,onChange:t=>!t&&p(),...n,children:[(0,_a.jsx)(Wd.A.Target,{children:(0,_a.jsx)(cd,{...i,variant:c,"aria-label":l.colorPickerControlLabel,title:l.colorPickerControlLabel,ref:e,onClick:h,children:(0,_a.jsx)(eh.q,{color:m,size:14})})}),(0,_a.jsxs)(Wd.A.Dropdown,{...a("linkEditorDropdown"),children:["palette"===u&&(0,_a.jsx)(nh.r,{cols:7,spacing:2,children:y}),"colorPicker"===u&&(0,_a.jsx)(oh.s,{defaultValue:m,onChange:t=>g(t,!1),...r}),(0,_a.jsx)(Kd.m.Group,{closeDelay:200,children:(0,_a.jsxs)(rh.Y,{justify:"flex-end",gap:"xs",mt:"sm",children:["palette"===u&&(0,_a.jsx)(ih.M,{variant:"default",onClick:p,title:l.colorPickerCancel,"aria-label":l.colorPickerCancel,children:(0,_a.jsx)(Xc,{style:{width:(0,Jd.D)(16),height:(0,Jd.D)(16)}})}),(0,_a.jsx)(ih.M,{variant:"default",onClick:()=>{(s?.chain()).focus().unsetColor().run(),p()},title:l.colorPickerClear,"aria-label":l.colorPickerClear,children:(0,_a.jsx)(Gc,{style:{width:(0,Jd.D)(16),height:(0,Jd.D)(16)}})}),"palette"===u?(0,_a.jsx)(ih.M,{variant:"default",onClick:()=>f("colorPicker"),title:l.colorPickerColorPicker,"aria-label":l.colorPickerColorPicker,children:(0,_a.jsx)(Yc,{style:{width:(0,Jd.D)(16),height:(0,Jd.D)(16)}})}):(0,_a.jsx)(ih.M,{variant:"default",onClick:()=>f("palette"),"aria-label":l.colorPickerPalette,title:l.colorPickerPalette,children:(0,_a.jsx)(Qc,{style:{width:(0,Jd.D)(16),height:(0,Jd.D)(16)}})}),"colorPicker"===u&&(0,_a.jsx)(ih.M,{variant:"default",onClick:p,title:l.colorPickerSave,"aria-label":l.colorPickerSave,children:(0,_a.jsx)(Zc,{style:{width:(0,Jd.D)(16),height:(0,Jd.D)(16)}})})]})})]})]})}));lh.displayName="@mantine/tiptap/ColorPickerControl";const ah={},ch=(0,Fa.forwardRef)(((t,e)=>{const{color:n,...o}=(0,qa.Y)("RichTextEditorColorControl",ah,t),{editor:r,labels:i,variant:s}=Xa(),l=r?.getAttributes("textStyle").color||null,a=i.colorControlLabel(n);return(0,_a.jsx)(cd,{...o,variant:s,active:l===n,"aria-label":a,title:a,onClick:()=>(r?.chain()).focus().setColor(n).run(),ref:e,children:(0,_a.jsx)(eh.q,{color:n,size:14})})}));ch.displayName="@mantine/tiptap/RichTextEditorColorControl";const dh={},hh=(0,Wa.P9)(((t,e)=>{const n=(0,qa.Y)("RichTextEditorControlsGroup",dh,t),{classNames:o,className:r,style:i,styles:s,vars:l,variant:a,...c}=n,d=Xa();return(0,_a.jsx)(Ja.a,{ref:e,variant:a||d.variant,...d.getStyles("controlsGroup",{className:r,style:i,styles:s,classNames:o}),...c})}));hh.classes=kc,hh.displayName="@mantine/tiptap/RichTextEditorControlsGroup";const ph={},uh=(0,Wa.P9)(((t,e)=>{const n=(0,qa.Y)("RichTextEditorToolbar",ph,t),{classNames:o,className:r,style:i,styles:s,vars:l,sticky:a,stickyOffset:c,mod:d,variant:h,...p}=n,u=Xa();return(0,_a.jsx)(Ja.a,{ref:e,mod:[{sticky:a},d],variant:h||u.variant,...u.getStyles("toolbar",{className:r,style:i,styles:s,classNames:o}),...p,__vars:{"--rte-sticky-offset":(0,Jd.D)(c)}})}));uh.classes=kc,uh.displayName="@mantine/tiptap/RichTextEditorToolbar";const fh={withCodeHighlightStyles:!0,withTypographyStyles:!0,variant:"default"},mh=(0,Wa.P9)(((t,e)=>{const n=(0,qa.Y)("RichTextEditor",fh,t),{classNames:o,className:r,style:i,styles:s,unstyled:l,vars:a,editor:c,withCodeHighlightStyles:d,withTypographyStyles:h,labels:p,children:u,variant:f,...m}=n,g=(0,Ka.I)({name:"RichTextEditor",classes:kc,props:n,className:r,style:i,classNames:o,styles:s,unstyled:l,vars:a}),y=(0,Fa.useMemo)((()=>({...Ua,...p})),[p]);return(0,_a.jsx)(Ya,{value:{editor:c,getStyles:g,labels:y,withCodeHighlightStyles:d,withTypographyStyles:h,unstyled:l,variant:f},children:(0,_a.jsx)(Ja.a,{...g("root"),...m,ref:e,children:u})})}));mh.classes=kc,mh.displayName="@mantine/tiptap/RichTextEditor",mh.Content=Mc,mh.Control=cd,mh.Toolbar=uh,mh.ControlsGroup=hh,mh.Bold=pd,mh.Italic=ud,mh.Strikethrough=md,mh.Underline=fd,mh.ClearFormatting=gd,mh.H1=wd,mh.H2=kd,mh.H3=xd,mh.H4=Md,mh.H5=Cd,mh.H6=Sd,mh.BulletList=bd,mh.OrderedList=vd,mh.Link=th,mh.Unlink=yd,mh.Blockquote=Td,mh.AlignLeft=Ad,mh.AlignRight=Od,mh.AlignCenter=Ed,mh.AlignJustify=Nd,mh.Superscript=Rd,mh.Subscript=Dd,mh.Code=jd,mh.CodeBlock=Ld,mh.ColorPicker=lh,mh.Color=ch,mh.Highlight=Id,mh.Hr=Pd,mh.UnsetColor=zd,mh.Undo=$d,mh.Redo=Hd,mh.TaskList=Bd,mh.TaskListSink=_d,mh.TaskListLift=Fd;var gh=n(85072),yh=n.n(gh),bh=n(97825),vh=n.n(bh),wh=n(55056),kh=n.n(wh),xh=n(10540),Mh=n.n(xh),Ch=n(41113),Sh=n.n(Ch),Th=n(96541),Ah={};Ah.styleTagTransform=Sh(),Ah.setAttributes=kh(),Ah.insert=function(t){var e=document.querySelector("head"),n=window._lastElementInsertedByStyleLoader;n?n.nextSibling?e.insertBefore(t,n.nextSibling):e.appendChild(t):e.insertBefore(t,e.firstChild),window._lastElementInsertedByStyleLoader=t},Ah.domAPI=vh(),Ah.insertStyleElement=Mh(),yh()(Th.A,Ah),Th.A&&Th.A.locals&&Th.A.locals;var Oh=n(84193),Eh=n(297);const Nh=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,Dh=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,Rh=Vi.create({name:"highlight",addOptions:()=>({multicolor:!1,HTMLAttributes:{}}),addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:t=>t.getAttribute("data-color")||t.style.backgroundColor,renderHTML:t=>t.color?{"data-color":t.color,style:`background-color: ${t.color}; color: inherit`}:{}}}:{}},parseHTML:()=>[{tag:"mark"}],renderHTML({HTMLAttributes:t}){return["mark",Oi(this.options.HTMLAttributes,t),0]},addCommands(){return{setHighlight:t=>({commands:e})=>e.setMark(this.name,t),toggleHighlight:t=>({commands:e})=>e.toggleMark(this.name,t),unsetHighlight:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[$s({find:Nh,type:this.type})]},addPasteRules(){return[Vs({find:Dh,type:this.type})]}}),jh=/^\s*>\s$/,Lh=Fs.create({name:"blockquote",addOptions:()=>({HTMLAttributes:{}}),content:"block+",group:"block",defining:!0,parseHTML:()=>[{tag:"blockquote"}],renderHTML({HTMLAttributes:t}){return["blockquote",Oi(this.options.HTMLAttributes,t),0]},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[_s({find:jh,type:this.type})]}}),Ih=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Ph=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,zh=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,$h=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Hh=Vi.create({name:"bold",addOptions:()=>({HTMLAttributes:{}}),parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>"normal"!==t.style.fontWeight&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return["strong",Oi(this.options.HTMLAttributes,t),0]},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[$s({find:Ih,type:this.type}),$s({find:zh,type:this.type})]},addPasteRules(){return[Vs({find:Ph,type:this.type}),Vs({find:$h,type:this.type})]}}),Bh="textStyle",_h=/^\s*([-+*])\s$/,Fh=Fs.create({name:"bulletList",addOptions:()=>({itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}),group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML:()=>[{tag:"ul"}],renderHTML({HTMLAttributes:t}){return["ul",Oi(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes("listItem",this.editor.getAttributes(Bh)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=_s({find:_h,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=_s({find:_h,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Bh),editor:this.editor})),[t]}}),Vh=/(^|[^`])`([^`]+)`(?!`)/,Wh=/(^|[^`])`([^`]+)`(?!`)/g,qh=Vi.create({name:"code",addOptions:()=>({HTMLAttributes:{}}),excludes:"_",code:!0,exitable:!0,parseHTML:()=>[{tag:"code"}],renderHTML({HTMLAttributes:t}){return["code",Oi(this.options.HTMLAttributes,t),0]},addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[$s({find:Vh,type:this.type})]},addPasteRules(){return[Vs({find:Wh,type:this.type})]}}),Kh=/^```([a-z]+)?[\s\n]$/,Jh=/^~~~([a-z]+)?[\s\n]$/,Uh=Fs.create({name:"codeBlock",addOptions:()=>({languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,HTMLAttributes:{}}),content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options;return[...(null===(e=t.firstElementChild)||void 0===e?void 0:e.classList)||[]].filter((t=>t.startsWith(n))).map((t=>t.replace(n,"")))[0]||null},rendered:!1}}},parseHTML:()=>[{tag:"pre",preserveWhitespace:"full"}],renderHTML({node:t,HTMLAttributes:e}){return["pre",Oi(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=1===e.pos;return!(!t||e.parent.type.name!==this.name)&&!(!n&&e.parent.textContent.length)&&this.editor.commands.clearNodes()},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:o,empty:r}=n;if(!r||o.parent.type!==this.type)return!1;const i=o.parentOffset===o.parent.nodeSize-2,s=o.parent.textContent.endsWith("\n\n");return!(!i||!s)&&t.chain().command((({tr:t})=>(t.delete(o.pos-2,o.pos),!0))).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:o}=e,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;if(r.parentOffset!==r.parent.nodeSize-2)return!1;const s=r.after();return void 0!==s&&(o.nodeAt(s)?t.commands.command((({tr:t})=>(t.setSelection(oe.near(o.resolve(s))),!0))):t.commands.exitCode())}}},addInputRules(){return[Bs({find:Kh,type:this.type,getAttributes:t=>({language:t[1]})}),Bs({find:Jh,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new xe({key:new Se("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData)return!1;if(this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),o=e.clipboardData.getData("vscode-editor-data"),r=o?JSON.parse(o):void 0,i=null==r?void 0:r.mode;if(!n||!i)return!1;const{tr:s,schema:l}=t.state,a=l.text(n.replace(/\r\n?/g,"\n"));return s.replaceSelectionWith(this.type.create({language:i},a)),s.selection.$from.parent.type!==this.type&&s.setSelection(le.near(s.doc.resolve(Math.max(0,s.selection.from-2)))),s.setMeta("paste",!0),t.dispatch(s),!0}}})]}}),Gh=Fs.create({name:"doc",topNode:!0,content:"block+"});function Yh(t={}){return new xe({view:e=>new Xh(e,t)})}class Xh{constructor(t,e){var n;this.editorView=t,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=null!==(n=e.width)&&void 0!==n?n:1,this.color=!1===e.color?void 0:e.color||"black",this.class=e.class,this.handlers=["dragover","dragend","drop","dragleave"].map((e=>{let n=t=>{this[e](t)};return t.dom.addEventListener(e,n),{name:e,handler:n}}))}destroy(){this.handlers.forEach((({name:t,handler:e})=>this.editorView.dom.removeEventListener(t,e)))}update(t,e){null!=this.cursorPos&&e.doc!=t.state.doc&&(this.cursorPos>t.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(t){t!=this.cursorPos&&(this.cursorPos=t,null==t?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let t,e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent;if(n){let n=e.nodeBefore,o=e.nodeAfter;if(n||o){let e=this.editorView.nodeDOM(this.cursorPos-(n?n.nodeSize:0));if(e){let r=e.getBoundingClientRect(),i=n?r.bottom:r.top;n&&o&&(i=(i+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2),t={left:r.left,right:r.right,top:i-this.width/2,bottom:i+this.width/2}}}}if(!t){let e=this.editorView.coordsAtPos(this.cursorPos);t={left:e.left-this.width/2,right:e.left+this.width/2,top:e.top,bottom:e.bottom}}let o,r,i=this.editorView.dom.offsetParent;if(this.element||(this.element=i.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),!i||i==document.body&&"static"==getComputedStyle(i).position)o=-pageXOffset,r=-pageYOffset;else{let t=i.getBoundingClientRect();o=t.left-i.scrollLeft,r=t.top-i.scrollTop}this.element.style.left=t.left-o+"px",this.element.style.top=t.top-r+"px",this.element.style.width=t.right-t.left+"px",this.element.style.height=t.bottom-t.top+"px"}scheduleRemoval(t){clearTimeout(this.timeout),this.timeout=setTimeout((()=>this.setCursor(null)),t)}dragover(t){if(!this.editorView.editable)return;let e=this.editorView.posAtCoords({left:t.clientX,top:t.clientY}),n=e&&e.inside>=0&&this.editorView.state.doc.nodeAt(e.inside),o=n&&n.type.spec.disableDropCursor,r="function"==typeof o?o(this.editorView,e,t):o;if(e&&!r){let t=e.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let e=_t(this.editorView.state.doc,t,this.editorView.dragging.slice);null!=e&&(t=e)}this.setCursor(t),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(t){t.target!=this.editorView.dom&&this.editorView.dom.contains(t.relatedTarget)||this.setCursor(null)}}const Qh=Ui.create({name:"dropCursor",addOptions:()=>({color:"currentColor",width:1,class:void 0}),addProseMirrorPlugins(){return[Yh(this.options)]}});class Zh extends oe{constructor(t){super(t,t)}map(t,e){let n=t.resolve(e.map(this.head));return Zh.valid(n)?new Zh(n):oe.near(n)}content(){return f.empty}eq(t){return t instanceof Zh&&t.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(t,e){if("number"!=typeof e.pos)throw new RangeError("Invalid input for GapCursor.fromJSON");return new Zh(t.resolve(e.pos))}getBookmark(){return new tp(this.anchor)}static valid(t){let e=t.parent;if(e.isTextblock||!function(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),o=t.node(e);if(0!=n)for(let t=o.child(n-1);;t=t.lastChild){if(0==t.childCount&&!t.inlineContent||t.isAtom||t.type.spec.isolating)return!0;if(t.inlineContent)return!1}else if(o.type.spec.isolating)return!0}return!0}(t)||!function(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),o=t.node(e);if(n!=o.childCount)for(let t=o.child(n);;t=t.firstChild){if(0==t.childCount&&!t.inlineContent||t.isAtom||t.type.spec.isolating)return!0;if(t.inlineContent)return!1}else if(o.type.spec.isolating)return!0}return!0}(t))return!1;let n=e.type.spec.allowGapCursor;if(null!=n)return n;let o=e.contentMatchAt(t.index()).defaultType;return o&&o.isTextblock}static findGapCursorFrom(t,e,n=!1){t:for(;;){if(!n&&Zh.valid(t))return t;let o=t.pos,r=null;for(let n=t.depth;;n--){let i=t.node(n);if(e>0?t.indexAfter(n)<i.childCount:t.index(n)>0){r=i.child(e>0?t.indexAfter(n):t.index(n)-1);break}if(0==n)return null;o+=e;let s=t.doc.resolve(o);if(Zh.valid(s))return s}for(;;){let i=e>0?r.firstChild:r.lastChild;if(!i){if(r.isAtom&&!r.isText&&!ce.isSelectable(r)){t=t.doc.resolve(o+r.nodeSize*e),n=!1;continue t}break}r=i,o+=e;let s=t.doc.resolve(o);if(Zh.valid(s))return s}return null}}}Zh.prototype.visible=!1,Zh.findFrom=Zh.findGapCursorFrom,oe.jsonID("gapcursor",Zh);class tp{constructor(t){this.pos=t}map(t){return new tp(t.map(this.pos))}resolve(t){let e=t.resolve(this.pos);return Zh.valid(e)?new Zh(e):oe.near(e)}}const ep=Jr({ArrowLeft:np("horiz",-1),ArrowRight:np("horiz",1),ArrowUp:np("vert",-1),ArrowDown:np("vert",1)});function np(t,e){const n="vert"==t?e>0?"down":"up":e>0?"right":"left";return function(t,o,r){let i=t.selection,s=e>0?i.$to:i.$from,l=i.empty;if(i instanceof le){if(!r.endOfTextblock(n)||0==s.depth)return!1;l=!1,s=t.doc.resolve(e>0?s.after():s.before())}let a=Zh.findGapCursorFrom(s,e,l);return!!a&&(o&&o(t.tr.setSelection(new Zh(a))),!0)}}function op(t,e,n){if(!t||!t.editable)return!1;let o=t.state.doc.resolve(e);if(!Zh.valid(o))return!1;let r=t.posAtCoords({left:n.clientX,top:n.clientY});return!(r&&r.inside>-1&&ce.isSelectable(t.state.doc.nodeAt(r.inside))||(t.dispatch(t.state.tr.setSelection(new Zh(o))),0))}function rp(t,e){if("insertCompositionText"!=e.inputType||!(t.state.selection instanceof Zh))return!1;let{$from:n}=t.state.selection,o=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!o)return!1;let r=a.empty;for(let t=o.length-1;t>=0;t--)r=a.from(o[t].createAndFill(null,r));let i=t.state.tr.replace(n.pos,n.pos,new f(r,0,0));return i.setSelection(le.near(i.doc.resolve(n.pos+1))),t.dispatch(i),!1}function ip(t){if(!(t.selection instanceof Zh))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",ar.create(t.doc,[ir.widget(t.selection.head,e,{key:"gapcursor"})])}const sp=Ui.create({name:"gapCursor",addProseMirrorPlugins:()=>[new xe({props:{decorations:ip,createSelectionBetween:(t,e,n)=>e.pos==n.pos&&Zh.valid(n)?new Zh(n):null,handleClick:op,handleKeyDown:ep,handleDOMEvents:{beforeinput:rp}}})],extendNodeSchema(t){var e;return{allowGapCursor:null!==(e=Di(Ci(t,"allowGapCursor",{name:t.name,options:t.options,storage:t.storage})))&&void 0!==e?e:null}}}),lp=Fs.create({name:"hardBreak",addOptions:()=>({keepMarks:!0,HTMLAttributes:{}}),inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML:()=>[{tag:"br"}],renderHTML({HTMLAttributes:t}){return["br",Oi(this.options.HTMLAttributes,t)]},renderText:()=>"\n",addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:o})=>t.first([()=>t.exitCode(),()=>t.command((()=>{const{selection:t,storedMarks:r}=n;if(t.$from.parent.type.spec.isolating)return!1;const{keepMarks:i}=this.options,{splittableMarks:s}=o.extensionManager,l=r||t.$to.parentOffset&&t.$from.marks();return e().insertContent({type:this.name}).command((({tr:t,dispatch:e})=>{if(e&&l&&i){const e=l.filter((t=>s.includes(t.type.name)));t.ensureMarks(e)}return!0})).run()}))])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),ap=Fs.create({name:"heading",addOptions:()=>({levels:[1,2,3,4,5,6],HTMLAttributes:{}}),content:"inline*",group:"block",defining:!0,addAttributes:()=>({level:{default:1,rendered:!1}}),parseHTML(){return this.options.levels.map((t=>({tag:`h${t}`,attrs:{level:t}})))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,Oi(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:t=>({commands:e})=>!!this.options.levels.includes(t.level)&&e.setNode(this.name,t),toggleHeading:t=>({commands:e})=>!!this.options.levels.includes(t.level)&&e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return this.options.levels.reduce(((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})})),{})},addInputRules(){return this.options.levels.map((t=>Bs({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}})))}});var cp=200,dp=function(){};dp.prototype.append=function(t){return t.length?(t=dp.from(t),!this.length&&t||t.length<cp&&this.leafAppend(t)||this.length<cp&&t.leafPrepend(this)||this.appendInner(t)):this},dp.prototype.prepend=function(t){return t.length?dp.from(t).append(this):this},dp.prototype.appendInner=function(t){return new pp(this,t)},dp.prototype.slice=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=this.length),t>=e?dp.empty:this.sliceInner(Math.max(0,t),Math.min(this.length,e))},dp.prototype.get=function(t){if(!(t<0||t>=this.length))return this.getInner(t)},dp.prototype.forEach=function(t,e,n){void 0===e&&(e=0),void 0===n&&(n=this.length),e<=n?this.forEachInner(t,e,n,0):this.forEachInvertedInner(t,e,n,0)},dp.prototype.map=function(t,e,n){void 0===e&&(e=0),void 0===n&&(n=this.length);var o=[];return this.forEach((function(e,n){return o.push(t(e,n))}),e,n),o},dp.from=function(t){return t instanceof dp?t:t&&t.length?new hp(t):dp.empty};var hp=function(t){function e(e){t.call(this),this.values=e}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(t,n){return 0==t&&n==this.length?this:new e(this.values.slice(t,n))},e.prototype.getInner=function(t){return this.values[t]},e.prototype.forEachInner=function(t,e,n,o){for(var r=e;r<n;r++)if(!1===t(this.values[r],o+r))return!1},e.prototype.forEachInvertedInner=function(t,e,n,o){for(var r=e-1;r>=n;r--)if(!1===t(this.values[r],o+r))return!1},e.prototype.leafAppend=function(t){if(this.length+t.length<=cp)return new e(this.values.concat(t.flatten()))},e.prototype.leafPrepend=function(t){if(this.length+t.length<=cp)return new e(t.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e}(dp);dp.empty=new hp([]);var pp=function(t){function e(e,n){t.call(this),this.left=e,this.right=n,this.length=e.length+n.length,this.depth=Math.max(e.depth,n.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(t){return t<this.left.length?this.left.get(t):this.right.get(t-this.left.length)},e.prototype.forEachInner=function(t,e,n,o){var r=this.left.length;return!(e<r&&!1===this.left.forEachInner(t,e,Math.min(n,r),o))&&!(n>r&&!1===this.right.forEachInner(t,Math.max(e-r,0),Math.min(this.length,n)-r,o+r))&&void 0},e.prototype.forEachInvertedInner=function(t,e,n,o){var r=this.left.length;return!(e>r&&!1===this.right.forEachInvertedInner(t,e-r,Math.max(n,r)-r,o+r))&&!(n<r&&!1===this.left.forEachInvertedInner(t,Math.min(e,r),n,o))&&void 0},e.prototype.sliceInner=function(t,e){if(0==t&&e==this.length)return this;var n=this.left.length;return e<=n?this.left.slice(t,e):t>=n?this.right.slice(t-n,e-n):this.left.slice(t,n).append(this.right.slice(0,e-n))},e.prototype.leafAppend=function(t){var n=this.right.leafAppend(t);if(n)return new e(this.left,n)},e.prototype.leafPrepend=function(t){var n=this.left.leafPrepend(t);if(n)return new e(n,this.right)},e.prototype.appendInner=function(t){return this.left.depth>=Math.max(this.right.depth,t.depth)+1?new e(this.left,new e(this.right,t)):new e(this,t)},e}(dp);const up=dp;class fp{constructor(t,e){this.items=t,this.eventCount=e}popEvent(t,e){if(0==this.eventCount)return null;let n,o,r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}e&&(n=this.remapping(r,this.items.length),o=n.maps.length);let i,s,l=t.tr,a=[],c=[];return this.items.forEach(((t,e)=>{if(!t.step)return n||(n=this.remapping(r,e+1),o=n.maps.length),o--,void c.push(t);if(n){c.push(new mp(t.map));let e,r=t.step.map(n.slice(o));r&&l.maybeStep(r).doc&&(e=l.mapping.maps[l.mapping.maps.length-1],a.push(new mp(e,void 0,void 0,a.length+c.length))),o--,e&&n.appendMap(e,o)}else l.maybeStep(t.step);return t.selection?(i=n?t.selection.map(n.slice(o)):t.selection,s=new fp(this.items.slice(0,r).append(c.reverse().concat(a)),this.eventCount-1),!1):void 0}),this.items.length,0),{remaining:s,transform:l,selection:i}}addTransform(t,e,n,o){let r=[],i=this.eventCount,s=this.items,l=!o&&s.length?s.get(s.length-1):null;for(let n=0;n<t.steps.length;n++){let a,c=t.steps[n].invert(t.docs[n]),d=new mp(t.mapping.maps[n],c,e);(a=l&&l.merge(d))&&(d=a,n?r.pop():s=s.slice(0,s.length-1)),r.push(d),e&&(i++,e=void 0),o||(l=d)}let a=i-n.depth;return a>yp&&(s=function(t,e){let n;return t.forEach(((t,o)=>{if(t.selection&&0==e--)return n=o,!1})),t.slice(n)}(s,a),i-=a),new fp(s.append(r),i)}remapping(t,e){let n=new bt;return this.items.forEach(((e,o)=>{let r=null!=e.mirrorOffset&&o-e.mirrorOffset>=t?n.maps.length-e.mirrorOffset:void 0;n.appendMap(e.map,r)}),t,e),n}addMaps(t){return 0==this.eventCount?this:new fp(this.items.append(t.map((t=>new mp(t)))),this.eventCount)}rebased(t,e){if(!this.eventCount)return this;let n=[],o=Math.max(0,this.items.length-e),r=t.mapping,i=t.steps.length,s=this.eventCount;this.items.forEach((t=>{t.selection&&s--}),o);let l=e;this.items.forEach((e=>{let o=r.getMirror(--l);if(null==o)return;i=Math.min(i,o);let a=r.maps[o];if(e.step){let i=t.steps[o].invert(t.docs[o]),c=e.selection&&e.selection.map(r.slice(l+1,o));c&&s++,n.push(new mp(a,i,c))}else n.push(new mp(a))}),o);let a=[];for(let t=e;t<i;t++)a.push(new mp(r.maps[t]));let c=this.items.slice(0,o).append(a).append(n),d=new fp(c,s);return d.emptyItemCount()>500&&(d=d.compress(this.items.length-n.length)),d}emptyItemCount(){let t=0;return this.items.forEach((e=>{e.step||t++})),t}compress(t=this.items.length){let e=this.remapping(0,t),n=e.maps.length,o=[],r=0;return this.items.forEach(((i,s)=>{if(s>=t)o.push(i),i.selection&&r++;else if(i.step){let t=i.step.map(e.slice(n)),s=t&&t.getMap();if(n--,s&&e.appendMap(s,n),t){let l=i.selection&&i.selection.map(e.slice(n));l&&r++;let a,c=new mp(s.invert(),t,l),d=o.length-1;(a=o.length&&o[d].merge(c))?o[d]=a:o.push(c)}}else i.map&&n--}),this.items.length,0),new fp(up.from(o.reverse()),r)}}fp.empty=new fp(up.empty,0);class mp{constructor(t,e,n,o){this.map=t,this.step=e,this.selection=n,this.mirrorOffset=o}merge(t){if(this.step&&t.step&&!t.selection){let e=t.step.merge(this.step);if(e)return new mp(e.getMap().invert(),e,this.selection)}}}class gp{constructor(t,e,n,o,r){this.done=t,this.undone=e,this.prevRanges=n,this.prevTime=o,this.prevComposition=r}}const yp=20;function bp(t){let e=[];for(let n=t.length-1;n>=0&&0==e.length;n--)t[n].forEach(((t,n,o,r)=>e.push(o,r)));return e}function vp(t,e){if(!t)return null;let n=[];for(let o=0;o<t.length;o+=2){let r=e.map(t[o],1),i=e.map(t[o+1],-1);r<=i&&n.push(r,i)}return n}let wp=!1,kp=null;function xp(t){let e=t.plugins;if(kp!=e){wp=!1,kp=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){wp=!0;break}}return wp}const Mp=new Se("history"),Cp=new Se("closeHistory");function Sp(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new xe({key:Mp,state:{init:()=>new gp(fp.empty,fp.empty,null,0,-1),apply:(e,n,o)=>function(t,e,n,o){let r,i=n.getMeta(Mp);if(i)return i.historyState;n.getMeta(Cp)&&(t=new gp(t.done,t.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(0==n.steps.length)return t;if(s&&s.getMeta(Mp))return s.getMeta(Mp).redo?new gp(t.done.addTransform(n,void 0,o,xp(e)),t.undone,bp(n.mapping.maps),t.prevTime,t.prevComposition):new gp(t.done,t.undone.addTransform(n,void 0,o,xp(e)),null,t.prevTime,t.prevComposition);if(!1===n.getMeta("addToHistory")||s&&!1===s.getMeta("addToHistory"))return(r=n.getMeta("rebased"))?new gp(t.done.rebased(n,r),t.undone.rebased(n,r),vp(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new gp(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),vp(t.prevRanges,n.mapping),t.prevTime,t.prevComposition);{let r=n.getMeta("composition"),i=0==t.prevTime||!s&&t.prevComposition!=r&&(t.prevTime<(n.time||0)-o.newGroupDelay||!function(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach(((t,o)=>{for(let r=0;r<e.length;r+=2)t<=e[r+1]&&o>=e[r]&&(n=!0)})),n}(n,t.prevRanges)),l=s?vp(t.prevRanges,n.mapping):bp(n.mapping.maps);return new gp(t.done.addTransform(n,i?e.selection.getBookmark():void 0,o,xp(e)),fp.empty,l,n.time,null==r?t.prevComposition:r)}}(n,o,e,t)},config:t,props:{handleDOMEvents:{beforeinput(t,e){let n=e.inputType,o="historyUndo"==n?Ap:"historyRedo"==n?Op:null;return!!o&&(e.preventDefault(),o(t.state,t.dispatch))}}}})}function Tp(t,e){return(n,o)=>{let r=Mp.getState(n);if(!r||0==(t?r.undone:r.done).eventCount)return!1;if(o){let i=function(t,e,n){let o=xp(e),r=Mp.get(e).spec.config,i=(n?t.undone:t.done).popEvent(e,o);if(!i)return null;let s=i.selection.resolve(i.transform.doc),l=(n?t.done:t.undone).addTransform(i.transform,e.selection.getBookmark(),r,o),a=new gp(n?l:i.remaining,n?i.remaining:l,null,0,-1);return i.transform.setSelection(s).setMeta(Mp,{redo:n,historyState:a})}(r,n,t);i&&o(e?i.scrollIntoView():i)}return!0}}const Ap=Tp(!1,!0),Op=Tp(!0,!0);Tp(!1,!1),Tp(!0,!1);const Ep=Ui.create({name:"history",addOptions:()=>({depth:100,newGroupDelay:500}),addCommands:()=>({undo:()=>({state:t,dispatch:e})=>Ap(t,e),redo:()=>({state:t,dispatch:e})=>Op(t,e)}),addProseMirrorPlugins(){return[Sp(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),Np=Fs.create({name:"horizontalRule",addOptions:()=>({HTMLAttributes:{}}),group:"block",parseHTML:()=>[{tag:"hr"}],renderHTML({HTMLAttributes:t}){return["hr",Oi(this.options.HTMLAttributes,t)]},addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{const{selection:n}=e,{$from:o,$to:r}=n,i=t();return 0===o.parentOffset?i.insertContentAt({from:Math.max(o.pos-1,0),to:r.pos},{type:this.name}):n instanceof ce?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command((({tr:t,dispatch:e})=>{var n;if(e){const{$to:e}=t.selection,o=e.end();if(e.nodeAfter)e.nodeAfter.isTextblock?t.setSelection(le.create(t.doc,e.pos+1)):e.nodeAfter.isBlock?t.setSelection(ce.create(t.doc,e.pos)):t.setSelection(le.create(t.doc,e.pos));else{const r=null===(n=e.parent.type.contentMatch.defaultType)||void 0===n?void 0:n.create();r&&(t.insert(o,r),t.setSelection(le.create(t.doc,o+1)))}t.scrollIntoView()}return!0})).run()}}},addInputRules(){return[Hs({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),Dp=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Rp=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,jp=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Lp=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Ip=Vi.create({name:"italic",addOptions:()=>({HTMLAttributes:{}}),parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>"normal"!==t.style.fontStyle&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",Oi(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[$s({find:Dp,type:this.type}),$s({find:jp,type:this.type})]},addPasteRules(){return[Vs({find:Rp,type:this.type}),Vs({find:Lp,type:this.type})]}}),Pp=Fs.create({name:"listItem",addOptions:()=>({HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}),content:"paragraph block*",defining:!0,parseHTML:()=>[{tag:"li"}],renderHTML({HTMLAttributes:t}){return["li",Oi(this.options.HTMLAttributes,t),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),zp="textStyle",$p=/^(\d+)\.\s$/,Hp=Fs.create({name:"orderedList",addOptions:()=>({itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}),group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes:()=>({start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:void 0,parseHTML:t=>t.getAttribute("type")}}),parseHTML:()=>[{tag:"ol"}],renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return 1===e?["ol",Oi(this.options.HTMLAttributes,n),0]:["ol",Oi(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes("listItem",this.editor.getAttributes(zp)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=_s({find:$p,type:this.type,getAttributes:t=>({start:+t[1]}),joinPredicate:(t,e)=>e.childCount+e.attrs.start===+t[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=_s({find:$p,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:t=>({start:+t[1],...this.editor.getAttributes(zp)}),joinPredicate:(t,e)=>e.childCount+e.attrs.start===+t[1],editor:this.editor})),[t]}}),Bp=Fs.create({name:"paragraph",priority:1e3,addOptions:()=>({HTMLAttributes:{}}),group:"block",content:"inline*",parseHTML:()=>[{tag:"p"}],renderHTML({HTMLAttributes:t}){return["p",Oi(this.options.HTMLAttributes,t),0]},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),_p=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Fp=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Vp=Vi.create({name:"strike",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>!!t.includes("line-through")&&{}}],renderHTML({HTMLAttributes:t}){return["s",Oi(this.options.HTMLAttributes,t),0]},addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[$s({find:_p,type:this.type})]},addPasteRules(){return[Vs({find:Fp,type:this.type})]}}),Wp=Fs.create({name:"text",group:"inline"}),qp=Ui.create({name:"starterKit",addExtensions(){var t,e,n,o,r,i,s,l,a,c,d,h,p,u,f,m,g,y;const b=[];return!1!==this.options.bold&&b.push(Hh.configure(null===(t=this.options)||void 0===t?void 0:t.bold)),!1!==this.options.blockquote&&b.push(Lh.configure(null===(e=this.options)||void 0===e?void 0:e.blockquote)),!1!==this.options.bulletList&&b.push(Fh.configure(null===(n=this.options)||void 0===n?void 0:n.bulletList)),!1!==this.options.code&&b.push(qh.configure(null===(o=this.options)||void 0===o?void 0:o.code)),!1!==this.options.codeBlock&&b.push(Uh.configure(null===(r=this.options)||void 0===r?void 0:r.codeBlock)),!1!==this.options.document&&b.push(Gh.configure(null===(i=this.options)||void 0===i?void 0:i.document)),!1!==this.options.dropcursor&&b.push(Qh.configure(null===(s=this.options)||void 0===s?void 0:s.dropcursor)),!1!==this.options.gapcursor&&b.push(sp.configure(null===(l=this.options)||void 0===l?void 0:l.gapcursor)),!1!==this.options.hardBreak&&b.push(lp.configure(null===(a=this.options)||void 0===a?void 0:a.hardBreak)),!1!==this.options.heading&&b.push(ap.configure(null===(c=this.options)||void 0===c?void 0:c.heading)),!1!==this.options.history&&b.push(Ep.configure(null===(d=this.options)||void 0===d?void 0:d.history)),!1!==this.options.horizontalRule&&b.push(Np.configure(null===(h=this.options)||void 0===h?void 0:h.horizontalRule)),!1!==this.options.italic&&b.push(Ip.configure(null===(p=this.options)||void 0===p?void 0:p.italic)),!1!==this.options.listItem&&b.push(Pp.configure(null===(u=this.options)||void 0===u?void 0:u.listItem)),!1!==this.options.orderedList&&b.push(Hp.configure(null===(f=this.options)||void 0===f?void 0:f.orderedList)),!1!==this.options.paragraph&&b.push(Bp.configure(null===(m=this.options)||void 0===m?void 0:m.paragraph)),!1!==this.options.strike&&b.push(Vp.configure(null===(g=this.options)||void 0===g?void 0:g.strike)),!1!==this.options.text&&b.push(Wp.configure(null===(y=this.options)||void 0===y?void 0:y.text)),b}}),Kp=Vi.create({name:"underline",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>!!t.includes("underline")&&{}}],renderHTML({HTMLAttributes:t}){return["u",Oi(this.options.HTMLAttributes,t),0]},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),Jp=Ui.create({name:"textAlign",addOptions:()=>({types:[],alignments:["left","center","right","justify"],defaultAlignment:"left"}),addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{const e=t.style.textAlign||this.options.defaultAlignment;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:t=>t.textAlign===this.options.defaultAlignment?{}:{style:`text-align: ${t.textAlign}`}}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>!!this.options.alignments.includes(t)&&this.options.types.map((n=>e.updateAttributes(n,{textAlign:t}))).every((t=>t)),unsetTextAlign:()=>({commands:t})=>this.options.types.map((e=>t.resetAttributes(e,"textAlign"))).every((t=>t))}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),Up=Vi.create({name:"superscript",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"sup"},{style:"vertical-align",getAttrs:t=>"super"===t&&null}],renderHTML({HTMLAttributes:t}){return["sup",Oi(this.options.HTMLAttributes,t),0]},addCommands(){return{setSuperscript:()=>({commands:t})=>t.setMark(this.name),toggleSuperscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSuperscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}}),Gp=Vi.create({name:"subscript",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"sub"},{style:"vertical-align",getAttrs:t=>"sub"===t&&null}],renderHTML({HTMLAttributes:t}){return["sub",Oi(this.options.HTMLAttributes,t),0]},addCommands(){return{setSubscript:()=>({commands:t})=>t.setMark(this.name),toggleSubscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSubscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}});var Yp,Xp;if("undefined"!=typeof WeakMap){let t=new WeakMap;Yp=e=>t.get(e),Xp=(e,n)=>(t.set(e,n),n)}else{const t=[],e=10;let n=0;Yp=e=>{for(let n=0;n<t.length;n+=2)if(t[n]==e)return t[n+1]},Xp=(o,r)=>(n==e&&(n=0),t[n++]=o,t[n++]=r)}var Qp=class{constructor(t,e,n,o){this.width=t,this.height=e,this.map=n,this.problems=o}findCell(t){for(let e=0;e<this.map.length;e++){const n=this.map[e];if(n!=t)continue;const o=e%this.width,r=e/this.width|0;let i=o+1,s=r+1;for(let t=1;i<this.width&&this.map[e+t]==n;t++)i++;for(let t=1;s<this.height&&this.map[e+this.width*t]==n;t++)s++;return{left:o,top:r,right:i,bottom:s}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let e=0;e<this.map.length;e++)if(this.map[e]==t)return e%this.width;throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,e,n){const{left:o,right:r,top:i,bottom:s}=this.findCell(t);return"horiz"==e?(n<0?0==o:r==this.width)?null:this.map[i*this.width+(n<0?o-1:r)]:(n<0?0==i:s==this.height)?null:this.map[o+this.width*(n<0?i-1:s)]}rectBetween(t,e){const{left:n,right:o,top:r,bottom:i}=this.findCell(t),{left:s,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(n,s),top:Math.min(r,a),right:Math.max(o,l),bottom:Math.max(i,c)}}cellsInRect(t){const e=[],n={};for(let o=t.top;o<t.bottom;o++)for(let r=t.left;r<t.right;r++){const i=o*this.width+r,s=this.map[i];n[s]||(n[s]=!0,r==t.left&&r&&this.map[i-1]==s||o==t.top&&o&&this.map[i-this.width]==s||e.push(s))}return e}positionAt(t,e,n){for(let o=0,r=0;;o++){const i=r+n.child(o).nodeSize;if(o==t){let n=e+t*this.width;const o=(t+1)*this.width;for(;n<o&&this.map[n]<r;)n++;return n==o?i-1:this.map[n]}r=i}}static get(t){return Yp(t)||Xp(t,function(t){if("table"!=t.type.spec.tableRole)throw new RangeError("Not a table node: "+t.type.name);const e=function(t){let e=-1,n=!1;for(let o=0;o<t.childCount;o++){const r=t.child(o);let i=0;if(n)for(let e=0;e<o;e++){const n=t.child(e);for(let t=0;t<n.childCount;t++){const r=n.child(t);e+r.attrs.rowspan>o&&(i+=r.attrs.colspan)}}for(let t=0;t<r.childCount;t++){const e=r.child(t);i+=e.attrs.colspan,e.attrs.rowspan>1&&(n=!0)}-1==e?e=i:e!=i&&(e=Math.max(e,i))}return e}(t),n=t.childCount,o=[];let r=0,i=null;const s=[];for(let t=0,r=e*n;t<r;t++)o[t]=0;for(let l=0,a=0;l<n;l++){const c=t.child(l);a++;for(let t=0;;t++){for(;r<o.length&&0!=o[r];)r++;if(t==c.childCount)break;const d=c.child(t),{colspan:h,rowspan:p,colwidth:u}=d.attrs;for(let t=0;t<p;t++){if(t+l>=n){(i||(i=[])).push({type:"overlong_rowspan",pos:a,n:p-t});break}const c=r+t*e;for(let t=0;t<h;t++){0==o[c+t]?o[c+t]=a:(i||(i=[])).push({type:"collision",row:l,pos:a,n:h-t});const n=u&&u[t];if(n){const o=(c+t)%e*2,r=s[o];null==r||r!=n&&1==s[o+1]?(s[o]=n,s[o+1]=1):r==n&&s[o+1]++}}}r+=h,a+=d.nodeSize}const d=(l+1)*e;let h=0;for(;r<d;)0==o[r++]&&h++;h&&(i||(i=[])).push({type:"missing",row:l,n:h}),a++}0!==e&&0!==n||(i||(i=[])).push({type:"zero_sized"});const l=new Qp(e,n,o,i);let a=!1;for(let t=0;!a&&t<s.length;t+=2)null!=s[t]&&s[t+1]<n&&(a=!0);return a&&function(t,e,n){t.problems||(t.problems=[]);const o={};for(let r=0;r<t.map.length;r++){const i=t.map[r];if(o[i])continue;o[i]=!0;const s=n.nodeAt(i);if(!s)throw new RangeError(`No cell with offset ${i} found`);let l=null;const a=s.attrs;for(let n=0;n<a.colspan;n++){const o=e[(r+n)%t.width*2];null==o||a.colwidth&&a.colwidth[n]==o||((l||(l=Zp(a)))[n]=o)}l&&t.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}(l,s,t),l}(t))}};function Zp(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function tu(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const n in t.nodes){const o=t.nodes[n],r=o.spec.tableRole;r&&(e[r]=o)}}return e}var eu=new Se("selectingCells");function nu(t){for(let e=t.depth-1;e>0;e--)if("row"==t.node(e).type.spec.tableRole)return t.node(0).resolve(t.before(e+1));return null}function ou(t){const e=t.selection.$head;for(let t=e.depth;t>0;t--)if("row"==e.node(t).type.spec.tableRole)return!0;return!1}function ru(t){const e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&"cell"==e.node.type.spec.tableRole)return e.$anchor;const n=nu(e.$head)||function(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){const o=e.type.spec.tableRole;if("cell"==o||"header_cell"==o)return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){const o=e.type.spec.tableRole;if("cell"==o||"header_cell"==o)return t.doc.resolve(n-e.nodeSize)}}(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function iu(t){return"row"==t.parent.type.spec.tableRole&&!!t.nodeAfter}function su(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function lu(t,e,n){const o=t.node(-1),r=Qp.get(o),i=t.start(-1),s=r.nextCell(t.pos-i,e,n);return null==s?null:t.node(0).resolve(i+s)}function au(t,e,n=1){const o={...t,colspan:t.colspan-n};return o.colwidth&&(o.colwidth=o.colwidth.slice(),o.colwidth.splice(e,n),o.colwidth.some((t=>t>0))||(o.colwidth=null)),o}function cu(t,e,n=1){const o={...t,colspan:t.colspan+n};if(o.colwidth){o.colwidth=o.colwidth.slice();for(let t=0;t<n;t++)o.colwidth.splice(e,0,0)}return o}var du=class t extends oe{constructor(t,e=t){const n=t.node(-1),o=Qp.get(n),r=t.start(-1),i=o.rectBetween(t.pos-r,e.pos-r),s=t.node(0),l=o.cellsInRect(i).filter((t=>t!=e.pos-r));l.unshift(e.pos-r);const a=l.map((t=>{const e=n.nodeAt(t);if(!e)throw RangeError(`No cell with offset ${t} found`);const o=r+t+1;return new re(s.resolve(o),s.resolve(o+e.content.size))}));super(a[0].$from,a[0].$to,a),this.$anchorCell=t,this.$headCell=e}map(e,n){const o=e.resolve(n.map(this.$anchorCell.pos)),r=e.resolve(n.map(this.$headCell.pos));if(iu(o)&&iu(r)&&su(o,r)){const e=this.$anchorCell.node(-1)!=o.node(-1);return e&&this.isRowSelection()?t.rowSelection(o,r):e&&this.isColSelection()?t.colSelection(o,r):new t(o,r)}return le.between(o,r)}content(){const t=this.$anchorCell.node(-1),e=Qp.get(t),n=this.$anchorCell.start(-1),o=e.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),r={},i=[];for(let n=o.top;n<o.bottom;n++){const s=[];for(let i=n*e.width+o.left,l=o.left;l<o.right;l++,i++){const n=e.map[i];if(r[n])continue;r[n]=!0;const l=e.findCell(n);let a=t.nodeAt(n);if(!a)throw RangeError(`No cell with offset ${n} found`);const c=o.left-l.left,d=l.right-o.right;if(c>0||d>0){let t=a.attrs;if(c>0&&(t=au(t,0,c)),d>0&&(t=au(t,t.colspan-d,d)),l.left<o.left){if(a=a.type.createAndFill(t),!a)throw RangeError(`Could not create cell with attrs ${JSON.stringify(t)}`)}else a=a.type.create(t,a.content)}if(l.top<o.top||l.bottom>o.bottom){const t={...a.attrs,rowspan:Math.min(l.bottom,o.bottom)-Math.max(l.top,o.top)};a=l.top<o.top?a.type.createAndFill(t):a.type.create(t,a.content)}s.push(a)}i.push(t.child(n).copy(a.from(s)))}const s=this.isColSelection()&&this.isRowSelection()?t:i;return new f(a.from(s),1,1)}replace(t,e=f.empty){const n=t.steps.length,o=this.ranges;for(let r=0;r<o.length;r++){const{$from:i,$to:s}=o[r],l=t.mapping.slice(n);t.replace(l.map(i.pos),l.map(s.pos),r?f.empty:e)}const r=oe.findFrom(t.doc.resolve(t.mapping.slice(n).map(this.to)),-1);r&&t.setSelection(r)}replaceWith(t,e){this.replace(t,new f(a.from(e),0,0))}forEachCell(t){const e=this.$anchorCell.node(-1),n=Qp.get(e),o=this.$anchorCell.start(-1),r=n.cellsInRect(n.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o));for(let n=0;n<r.length;n++)t(e.nodeAt(r[n]),o+r[n])}isColSelection(){const t=this.$anchorCell.index(-1),e=this.$headCell.index(-1);if(Math.min(t,e)>0)return!1;const n=t+this.$anchorCell.nodeAfter.attrs.rowspan,o=e+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,o)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const o=e.node(-1),r=Qp.get(o),i=e.start(-1),s=r.findCell(e.pos-i),l=r.findCell(n.pos-i),a=e.node(0);return s.top<=l.top?(s.top>0&&(e=a.resolve(i+r.map[s.left])),l.bottom<r.height&&(n=a.resolve(i+r.map[r.width*(r.height-1)+l.right-1]))):(l.top>0&&(n=a.resolve(i+r.map[l.left])),s.bottom<r.height&&(e=a.resolve(i+r.map[r.width*(r.height-1)+s.right-1]))),new t(e,n)}isRowSelection(){const t=this.$anchorCell.node(-1),e=Qp.get(t),n=this.$anchorCell.start(-1),o=e.colCount(this.$anchorCell.pos-n),r=e.colCount(this.$headCell.pos-n);if(Math.min(o,r)>0)return!1;const i=o+this.$anchorCell.nodeAfter.attrs.colspan,s=r+this.$headCell.nodeAfter.attrs.colspan;return Math.max(i,s)==e.width}eq(e){return e instanceof t&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const o=e.node(-1),r=Qp.get(o),i=e.start(-1),s=r.findCell(e.pos-i),l=r.findCell(n.pos-i),a=e.node(0);return s.left<=l.left?(s.left>0&&(e=a.resolve(i+r.map[s.top*r.width])),l.right<r.width&&(n=a.resolve(i+r.map[r.width*(l.top+1)-1]))):(l.left>0&&(n=a.resolve(i+r.map[l.top*r.width])),s.right<r.width&&(e=a.resolve(i+r.map[r.width*(s.top+1)-1]))),new t(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new t(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,o=n){return new t(e.resolve(n),e.resolve(o))}getBookmark(){return new hu(this.$anchorCell.pos,this.$headCell.pos)}};du.prototype.visible=!1,oe.jsonID("cell",du);var hu=class t{constructor(t,e){this.anchor=t,this.head=e}map(e){return new t(e.map(this.anchor),e.map(this.head))}resolve(t){const e=t.resolve(this.anchor),n=t.resolve(this.head);return"row"==e.parent.type.spec.tableRole&&"row"==n.parent.type.spec.tableRole&&e.index()<e.parent.childCount&&n.index()<n.parent.childCount&&su(e,n)?new du(e,n):oe.near(n,1)}};function pu(t){if(!(t.selection instanceof du))return null;const e=[];return t.selection.forEachCell(((t,n)=>{e.push(ir.node(n,n+t.nodeSize,{class:"selectedCell"}))})),ar.create(t.doc,e)}var uu=new Se("fix-tables");function fu(t,e,n,o){const r=t.childCount,i=e.childCount;t:for(let s=0,l=0;s<i;s++){const i=e.child(s);for(let e=l,o=Math.min(r,s+3);e<o;e++)if(t.child(e)==i){l=e+1,n+=i.nodeSize;continue t}o(i,n),l<r&&t.child(l).sameMarkup(i)?fu(t.child(l),i,n+1,o):i.nodesBetween(0,i.content.size,o,n+1),n+=i.nodeSize}}function mu(t,e){let n;const o=(e,o)=>{"table"==e.type.spec.tableRole&&(n=function(t,e,n,o){const r=Qp.get(e);if(!r.problems)return o;o||(o=t.tr);const i=[];for(let t=0;t<r.height;t++)i.push(0);for(let t=0;t<r.problems.length;t++){const s=r.problems[t];if("collision"==s.type){const t=e.nodeAt(s.pos);if(!t)continue;const r=t.attrs;for(let t=0;t<r.rowspan;t++)i[s.row+t]+=s.n;o.setNodeMarkup(o.mapping.map(n+1+s.pos),null,au(r,r.colspan-s.n,s.n))}else if("missing"==s.type)i[s.row]+=s.n;else if("overlong_rowspan"==s.type){const t=e.nodeAt(s.pos);if(!t)continue;o.setNodeMarkup(o.mapping.map(n+1+s.pos),null,{...t.attrs,rowspan:t.attrs.rowspan-s.n})}else if("colwidth mismatch"==s.type){const t=e.nodeAt(s.pos);if(!t)continue;o.setNodeMarkup(o.mapping.map(n+1+s.pos),null,{...t.attrs,colwidth:s.colwidth})}else if("zero_sized"==s.type){const t=o.mapping.map(n);o.delete(t,t+e.nodeSize)}}let s,l;for(let t=0;t<i.length;t++)i[t]&&(null==s&&(s=t),l=t);for(let a=0,c=n+1;a<r.height;a++){const n=e.child(a),r=c+n.nodeSize,d=i[a];if(d>0){let e="cell";n.firstChild&&(e=n.firstChild.type.spec.tableRole);const i=[];for(let n=0;n<d;n++){const n=tu(t.schema)[e].createAndFill();n&&i.push(n)}const h=0!=a&&s!=a-1||l!=a?r-1:c+1;o.insert(o.mapping.map(h),i)}c=r}return o.setMeta(uu,{fixTables:!0})}(t,e,o,n))};return e?e.doc!=t.doc&&fu(e.doc,t.doc,0,o):t.doc.descendants(o),n}function gu(t){const e=t.selection,n=ru(t),o=n.node(-1),r=n.start(-1),i=Qp.get(o);return{...e instanceof du?i.rectBetween(e.$anchorCell.pos-r,e.$headCell.pos-r):i.findCell(n.pos-r),tableStart:r,map:i,table:o}}function yu(t,{map:e,tableStart:n,table:o},r){let i=r>0?-1:0;(function(t,e,n){const o=tu(e.type.schema).header_cell;for(let r=0;r<t.height;r++)if(e.nodeAt(t.map[n+r*t.width]).type!=o)return!1;return!0})(e,o,r+i)&&(i=0==r||r==e.width?null:0);for(let s=0;s<e.height;s++){const l=s*e.width+r;if(r>0&&r<e.width&&e.map[l-1]==e.map[l]){const i=e.map[l],a=o.nodeAt(i);t.setNodeMarkup(t.mapping.map(n+i),null,cu(a.attrs,r-e.colCount(i))),s+=a.attrs.rowspan-1}else{const a=null==i?tu(o.type.schema).cell:o.nodeAt(e.map[l+i]).type,c=e.positionAt(s,r,o);t.insert(t.mapping.map(n+c),a.createAndFill())}}return t}function bu(t,{map:e,table:n,tableStart:o},r){const i=t.mapping.maps.length;for(let s=0;s<e.height;){const l=s*e.width+r,a=e.map[l],c=n.nodeAt(a),d=c.attrs;if(r>0&&e.map[l-1]==a||r<e.width-1&&e.map[l+1]==a)t.setNodeMarkup(t.mapping.slice(i).map(o+a),null,au(d,r-e.colCount(a)));else{const e=t.mapping.slice(i).map(o+a);t.delete(e,e+c.nodeSize)}s+=d.rowspan}}function vu(t,{map:e,tableStart:n,table:o},r){var i;let s=n;for(let t=0;t<r;t++)s+=o.child(t).nodeSize;const l=[];let a=r>0?-1:0;(function(t,e,n){var o;const r=tu(e.type.schema).header_cell;for(let i=0;i<t.width;i++)if((null==(o=e.nodeAt(t.map[i+n*t.width]))?void 0:o.type)!=r)return!1;return!0})(e,o,r+a)&&(a=0==r||r==e.height?null:0);for(let s=0,c=e.width*r;s<e.width;s++,c++)if(r>0&&r<e.height&&e.map[c]==e.map[c-e.width]){const r=e.map[c],i=o.nodeAt(r).attrs;t.setNodeMarkup(n+r,null,{...i,rowspan:i.rowspan+1}),s+=i.colspan-1}else{const t=null==a?tu(o.type.schema).cell:null==(i=o.nodeAt(e.map[c+a*e.width]))?void 0:i.type,n=null==t?void 0:t.createAndFill();n&&l.push(n)}return t.insert(s,tu(o.type.schema).row.create(null,l)),t}function wu(t,{map:e,table:n,tableStart:o},r){let i=0;for(let t=0;t<r;t++)i+=n.child(t).nodeSize;const s=i+n.child(r).nodeSize,l=t.mapping.maps.length;t.delete(i+o,s+o);const a=new Set;for(let i=0,s=r*e.width;i<e.width;i++,s++){const c=e.map[s];if(!a.has(c))if(a.add(c),r>0&&c==e.map[s-e.width]){const e=n.nodeAt(c).attrs;t.setNodeMarkup(t.mapping.slice(l).map(c+o),null,{...e,rowspan:e.rowspan-1}),i+=e.colspan-1}else if(r<e.height&&c==e.map[s+e.width]){const s=n.nodeAt(c),a=s.attrs,d=s.type.create({...a,rowspan:s.attrs.rowspan-1},s.content),h=e.positionAt(r+1,i,n);t.insert(t.mapping.slice(l).map(o+h),d),i+=a.colspan-1}}}function ku(t){const e=t.content;return 1==e.childCount&&e.child(0).isTextblock&&0==e.child(0).childCount}function xu(t,e){const n=t.selection;if(!(n instanceof du)||n.$anchorCell.pos==n.$headCell.pos)return!1;const o=gu(t),{map:r}=o;if(function({width:t,height:e,map:n},o){let r=o.top*t+o.left,i=r,s=(o.bottom-1)*t+o.left,l=r+(o.right-o.left-1);for(let e=o.top;e<o.bottom;e++){if(o.left>0&&n[i]==n[i-1]||o.right<t&&n[l]==n[l+1])return!0;i+=t,l+=t}for(let i=o.left;i<o.right;i++){if(o.top>0&&n[r]==n[r-t]||o.bottom<e&&n[s]==n[s+t])return!0;r++,s++}return!1}(r,o))return!1;if(e){const n=t.tr,i={};let s,l,c=a.empty;for(let t=o.top;t<o.bottom;t++)for(let e=o.left;e<o.right;e++){const a=r.map[t*r.width+e],d=o.table.nodeAt(a);if(!i[a]&&d)if(i[a]=!0,null==s)s=a,l=d;else{ku(d)||(c=c.append(d.content));const t=n.mapping.map(a+o.tableStart);n.delete(t,t+d.nodeSize)}}if(null==s||null==l)return!0;if(n.setNodeMarkup(s+o.tableStart,null,{...cu(l.attrs,l.attrs.colspan,o.right-o.left-l.attrs.colspan),rowspan:o.bottom-o.top}),c.size){const t=s+1+l.content.size,e=ku(l)?s+1:t;n.replaceWith(e+o.tableStart,t+o.tableStart,c)}n.setSelection(new du(n.doc.resolve(s+o.tableStart))),e(n)}return!0}function Mu(t,e){const n=tu(t.schema);return(o=({node:t})=>n[t.type.spec.tableRole],(t,e)=>{var n;const r=t.selection;let i,s;if(r instanceof du){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;i=r.$anchorCell.nodeAfter,s=r.$anchorCell.pos}else{if(i=function(t){for(let e=t.depth;e>0;e--){const n=t.node(e).type.spec.tableRole;if("cell"===n||"header_cell"===n)return t.node(e)}return null}(r.$from),!i)return!1;s=null==(n=nu(r.$from))?void 0:n.pos}if(null==i||null==s)return!1;if(1==i.attrs.colspan&&1==i.attrs.rowspan)return!1;if(e){let n=i.attrs;const l=[],a=n.colwidth;n.rowspan>1&&(n={...n,rowspan:1}),n.colspan>1&&(n={...n,colspan:1});const c=gu(t),d=t.tr;for(let t=0;t<c.right-c.left;t++)l.push(a?{...n,colwidth:a&&a[t]?[a[t]]:null}:n);let h;for(let t=c.top;t<c.bottom;t++){let e=c.map.positionAt(t,c.left,c.table);t==c.top&&(e+=i.nodeSize);for(let n=c.left,r=0;n<c.right;n++,r++)n==c.left&&t==c.top||d.insert(h=d.mapping.map(e+c.tableStart,1),o({node:i,row:t,col:n}).createAndFill(l[r]))}d.setNodeMarkup(s,o({node:i,row:c.top,col:c.left}),l[0]),r instanceof du&&d.setSelection(new du(d.doc.resolve(r.$anchorCell.pos),h?d.doc.resolve(h):void 0)),e(d)}return!0})(t,e);var o}function Cu(t,e,n){const o=e.map.cellsInRect({left:0,top:0,right:"row"==t?e.map.width:1,bottom:"column"==t?e.map.height:1});for(let t=0;t<o.length;t++){const r=e.table.nodeAt(o[t]);if(r&&r.type!==n.header_cell)return!1}return!0}function Su(t,e){return(e=e||{useDeprecatedLogic:!1}).useDeprecatedLogic?function(t){return function(e,n){if(!ou(e))return!1;if(n){const o=tu(e.schema),r=gu(e),i=e.tr,s=r.map.cellsInRect("column"==t?{left:r.left,top:0,right:r.right,bottom:r.map.height}:"row"==t?{left:0,top:r.top,right:r.map.width,bottom:r.bottom}:r),l=s.map((t=>r.table.nodeAt(t)));for(let t=0;t<s.length;t++)l[t].type==o.header_cell&&i.setNodeMarkup(r.tableStart+s[t],o.cell,l[t].attrs);if(0==i.steps.length)for(let t=0;t<s.length;t++)i.setNodeMarkup(r.tableStart+s[t],o.header_cell,l[t].attrs);n(i)}return!0}}(t):function(e,n){if(!ou(e))return!1;if(n){const o=tu(e.schema),r=gu(e),i=e.tr,s=Cu("row",r,o),l=Cu("column",r,o),a=("column"===t?s:"row"===t&&l)?1:0,c="column"==t?{left:0,top:a,right:1,bottom:r.map.height}:"row"==t?{left:a,top:0,right:r.map.width,bottom:1}:r,d="column"==t?l?o.cell:o.header_cell:"row"==t?s?o.cell:o.header_cell:o.cell;r.map.cellsInRect(c).forEach((t=>{const e=t+r.tableStart,n=i.doc.nodeAt(e);n&&i.setNodeMarkup(e,d,n.attrs)})),n(i)}return!0}}Su("row",{useDeprecatedLogic:!0}),Su("column",{useDeprecatedLogic:!0});var Tu=Su("cell",{useDeprecatedLogic:!0});function Au(t){return function(e,n){if(!ou(e))return!1;const o=function(t,e){if(e<0){const e=t.nodeBefore;if(e)return t.pos-e.nodeSize;for(let e=t.index(-1)-1,n=t.before();e>=0;e--){const o=t.node(-1).child(e),r=o.lastChild;if(r)return n-1-r.nodeSize;n-=o.nodeSize}}else{if(t.index()<t.parent.childCount-1)return t.pos+t.nodeAfter.nodeSize;const e=t.node(-1);for(let n=t.indexAfter(-1),o=t.after();n<e.childCount;n++){const t=e.child(n);if(t.childCount)return o+1;o+=t.nodeSize}}return null}(ru(e),t);if(null==o)return!1;if(n){const t=e.doc.resolve(o);n(e.tr.setSelection(le.between(t,(r=t,r.node(0).resolve(r.pos+r.nodeAfter.nodeSize)))).scrollIntoView())}var r;return!0}}function Ou(t,e){const n=t.selection;if(!(n instanceof du))return!1;if(e){const o=t.tr,r=tu(t.schema).cell.createAndFill().content;n.forEachCell(((t,e)=>{t.content.eq(r)||o.replace(o.mapping.map(e+1),o.mapping.map(e+t.nodeSize-1),new f(r,0,0))})),o.docChanged&&e(o)}return!0}function Eu(t,e){const n=t.createAndFill();return new ee(n).replace(0,n.content.size,e).doc}function Nu(t,e,n,o,r,i,s,l){if(0==s||s==e.height)return!1;let a=!1;for(let c=r;c<i;c++){const r=s*e.width+c,i=e.map[r];if(e.map[r-e.width]==i){a=!0;const r=n.nodeAt(i),{top:d,left:h}=e.findCell(i);t.setNodeMarkup(t.mapping.slice(l).map(i+o),null,{...r.attrs,rowspan:s-d}),t.insert(t.mapping.slice(l).map(e.positionAt(s,h,n)),r.type.createAndFill({...r.attrs,rowspan:d+r.attrs.rowspan-s})),c+=r.attrs.colspan-1}}return a}function Du(t,e,n,o,r,i,s,l){if(0==s||s==e.width)return!1;let a=!1;for(let c=r;c<i;c++){const r=c*e.width+s,i=e.map[r];if(e.map[r-1]==i){a=!0;const r=n.nodeAt(i),d=e.colCount(i),h=t.mapping.slice(l).map(i+o);t.setNodeMarkup(h,null,au(r.attrs,s-d,r.attrs.colspan-(s-d))),t.insert(h+r.nodeSize,r.type.createAndFill(au(r.attrs,0,s-d))),c+=r.attrs.rowspan-1}}return a}function Ru(t,e,n,o,r){let i=n?t.doc.nodeAt(n-1):t.doc;if(!i)throw new Error("No table found");let s=Qp.get(i);const{top:l,left:c}=o,d=c+r.width,h=l+r.height,p=t.tr;let u=0;function m(){if(i=n?p.doc.nodeAt(n-1):p.doc,!i)throw new Error("No table found");s=Qp.get(i),u=p.mapping.maps.length}(function(t,e,n,o,r,i,s){const l=tu(t.doc.type.schema);let c,d;if(r>e.width)for(let i=0,a=0;i<e.height;i++){const h=n.child(i);a+=h.nodeSize;const p=[];let u;u=null==h.lastChild||h.lastChild.type==l.cell?c||(c=l.cell.createAndFill()):d||(d=l.header_cell.createAndFill());for(let t=e.width;t<r;t++)p.push(u);t.insert(t.mapping.slice(s).map(a-1+o),p)}if(i>e.height){const h=[];for(let t=0,o=(e.height-1)*e.width;t<Math.max(e.width,r);t++){const r=!(t>=e.width)&&n.nodeAt(e.map[o+t]).type==l.header_cell;h.push(r?d||(d=l.header_cell.createAndFill()):c||(c=l.cell.createAndFill()))}const p=l.row.create(null,a.from(h)),u=[];for(let t=e.height;t<i;t++)u.push(p);t.insert(t.mapping.slice(s).map(o+n.nodeSize-2),u)}return!(!c&&!d)})(p,s,i,n,d,h,u)&&m(),Nu(p,s,i,n,c,d,l,u)&&m(),Nu(p,s,i,n,c,d,h,u)&&m(),Du(p,s,i,n,l,h,c,u)&&m(),Du(p,s,i,n,l,h,d,u)&&m();for(let t=l;t<h;t++){const e=s.positionAt(t,c,i),o=s.positionAt(t,d,i);p.replace(p.mapping.slice(u).map(e+n),p.mapping.slice(u).map(o+n),new f(r.rows[t-l],0,0))}m(),p.setSelection(new du(p.doc.resolve(n+s.positionAt(l,c,i)),p.doc.resolve(n+s.positionAt(h-1,d-1,i)))),e(p)}var ju=Jr({ArrowLeft:Iu("horiz",-1),ArrowRight:Iu("horiz",1),ArrowUp:Iu("vert",-1),ArrowDown:Iu("vert",1),"Shift-ArrowLeft":Pu("horiz",-1),"Shift-ArrowRight":Pu("horiz",1),"Shift-ArrowUp":Pu("vert",-1),"Shift-ArrowDown":Pu("vert",1),Backspace:Ou,"Mod-Backspace":Ou,Delete:Ou,"Mod-Delete":Ou});function Lu(t,e,n){return!n.eq(t.selection)&&(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function Iu(t,e){return(n,o,r)=>{if(!r)return!1;const i=n.selection;if(i instanceof du)return Lu(n,o,oe.near(i.$headCell,e));if("horiz"!=t&&!i.empty)return!1;const s=Bu(r,t,e);if(null==s)return!1;if("horiz"==t)return Lu(n,o,oe.near(n.doc.resolve(i.head+e),e));{const r=n.doc.resolve(s),i=lu(r,t,e);let l;return l=i?oe.near(i,1):e<0?oe.near(n.doc.resolve(r.before(-1)),-1):oe.near(n.doc.resolve(r.after(-1)),1),Lu(n,o,l)}}}function Pu(t,e){return(n,o,r)=>{if(!r)return!1;const i=n.selection;let s;if(i instanceof du)s=i;else{const o=Bu(r,t,e);if(null==o)return!1;s=new du(n.doc.resolve(o))}const l=lu(s.$headCell,t,e);return!!l&&Lu(n,o,new du(s.$anchorCell,l))}}function zu(t,e){const n=nu(t.state.doc.resolve(e));return!!n&&(t.dispatch(t.state.tr.setSelection(new du(n))),!0)}function $u(t,e,n){if(!ou(t.state))return!1;let o=function(t){if(!t.size)return null;let{content:e,openStart:n,openEnd:o}=t;for(;1==e.childCount&&(n>0&&o>0||"table"==e.child(0).type.spec.tableRole);)n--,o--,e=e.child(0).content;const r=e.child(0),i=r.type.spec.tableRole,s=r.type.schema,l=[];if("row"==i)for(let t=0;t<e.childCount;t++){let r=e.child(t).content;const i=t?0:Math.max(0,n-1),a=t<e.childCount-1?0:Math.max(0,o-1);(i||a)&&(r=Eu(tu(s).row,new f(r,i,a)).content),l.push(r)}else{if("cell"!=i&&"header_cell"!=i)return null;l.push(n||o?Eu(tu(s).row,new f(e,n,o)).content:e)}return function(t,e){const n=[];for(let t=0;t<e.length;t++){const o=e[t];for(let e=o.childCount-1;e>=0;e--){const{rowspan:r,colspan:i}=o.child(e).attrs;for(let e=t;e<t+r;e++)n[e]=(n[e]||0)+i}}let o=0;for(let t=0;t<n.length;t++)o=Math.max(o,n[t]);for(let r=0;r<n.length;r++)if(r>=e.length&&e.push(a.empty),n[r]<o){const i=tu(t).cell.createAndFill(),s=[];for(let t=n[r];t<o;t++)s.push(i);e[r]=e[r].append(a.from(s))}return{height:e.length,width:o,rows:e}}(s,l)}(n);const r=t.state.selection;if(r instanceof du){o||(o={width:1,height:1,rows:[a.from(Eu(tu(t.state.schema).cell,n))]});const e=r.$anchorCell.node(-1),i=r.$anchorCell.start(-1),s=Qp.get(e).rectBetween(r.$anchorCell.pos-i,r.$headCell.pos-i);return o=function({width:t,height:e,rows:n},o,r){if(t!=o){const e=[],r=[];for(let t=0;t<n.length;t++){const i=n[t],s=[];for(let n=e[t]||0,r=0;n<o;r++){let l=i.child(r%i.childCount);n+l.attrs.colspan>o&&(l=l.type.createChecked(au(l.attrs,l.attrs.colspan,n+l.attrs.colspan-o),l.content)),s.push(l),n+=l.attrs.colspan;for(let n=1;n<l.attrs.rowspan;n++)e[t+n]=(e[t+n]||0)+l.attrs.colspan}r.push(a.from(s))}n=r,t=o}if(e!=r){const t=[];for(let o=0,i=0;o<r;o++,i++){const s=[],l=n[i%e];for(let t=0;t<l.childCount;t++){let e=l.child(t);o+e.attrs.rowspan>r&&(e=e.type.create({...e.attrs,rowspan:Math.max(1,r-e.attrs.rowspan)},e.content)),s.push(e)}t.push(a.from(s))}n=t,e=r}return{width:t,height:e,rows:n}}(o,s.right-s.left,s.bottom-s.top),Ru(t.state,t.dispatch,i,s,o),!0}if(o){const e=ru(t.state),n=e.start(-1);return Ru(t.state,t.dispatch,n,Qp.get(e.node(-1)).findCell(e.pos-n),o),!0}return!1}function Hu(t,e){var n;if(e.ctrlKey||e.metaKey)return;const o=_u(t,e.target);let r;if(e.shiftKey&&t.state.selection instanceof du)i(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&o&&null!=(r=nu(t.state.selection.$anchor))&&(null==(n=Fu(t,e))?void 0:n.pos)!=r.pos)i(r,e),e.preventDefault();else if(!o)return;function i(e,n){let o=Fu(t,n);const r=null==eu.getState(t.state);if(!o||!su(e,o)){if(!r)return;o=e}const i=new du(e,o);if(r||!t.state.selection.eq(i)){const n=t.state.tr.setSelection(i);r&&n.setMeta(eu,e.pos),t.dispatch(n)}}function s(){t.root.removeEventListener("mouseup",s),t.root.removeEventListener("dragstart",s),t.root.removeEventListener("mousemove",l),null!=eu.getState(t.state)&&t.dispatch(t.state.tr.setMeta(eu,-1))}function l(n){const r=n,l=eu.getState(t.state);let a;if(null!=l)a=t.state.doc.resolve(l);else if(_u(t,r.target)!=o&&(a=Fu(t,e),!a))return s();a&&i(a,r)}t.root.addEventListener("mouseup",s),t.root.addEventListener("dragstart",s),t.root.addEventListener("mousemove",l)}function Bu(t,e,n){if(!(t.state.selection instanceof le))return null;const{$head:o}=t.state.selection;for(let r=o.depth-1;r>=0;r--){const i=o.node(r);if((n<0?o.index(r):o.indexAfter(r))!=(n<0?0:i.childCount))return null;if("cell"==i.type.spec.tableRole||"header_cell"==i.type.spec.tableRole){const i=o.before(r),s="vert"==e?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(s)?i:null}}return null}function _u(t,e){for(;e&&e!=t.dom;e=e.parentNode)if("TD"==e.nodeName||"TH"==e.nodeName)return e;return null}function Fu(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});return n&&n?nu(t.state.doc.resolve(n.pos)):null}var Vu=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")),Wu(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type==this.node.type&&(this.node=t,Wu(t,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(t){return"attributes"==t.type&&(t.target==this.table||this.colgroup.contains(t.target))}};function Wu(t,e,n,o,r,i){var s;let l=0,a=!0,c=e.firstChild;const d=t.firstChild;if(d){for(let t=0,n=0;t<d.childCount;t++){const{colspan:s,colwidth:h}=d.child(t).attrs;for(let t=0;t<s;t++,n++){const s=r==n?i:h&&h[t],d=s?s+"px":"";if(l+=s||o,s||(a=!1),c)c.style.width!=d&&(c.style.width=d),c=c.nextSibling;else{const t=document.createElement("col");t.style.width=d,e.appendChild(t)}}}for(;c;){const t=c.nextSibling;null==(s=c.parentNode)||s.removeChild(c),c=t}a?(n.style.width=l+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=l+"px")}}var qu=new Se("tableColumnResizing");function Ku({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:o=Vu,lastColumnResizable:r=!0}={}){const i=new xe({key:qu,state:{init(t,e){var r,s;const l=null==(s=null==(r=i.spec)?void 0:r.props)?void 0:s.nodeViews,a=tu(e.schema).table.name;return o&&l&&(l[a]=(t,e)=>new o(t,n,e)),new Ju(-1,!1)},apply:(t,e)=>e.apply(t)},props:{attributes:t=>{const e=qu.getState(t);return e&&e.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(e,n)=>{!function(t,e,n,o){if(!t.editable)return;const r=qu.getState(t.state);if(r&&!r.dragging){const i=function(t){for(;t&&"TD"!=t.nodeName&&"TH"!=t.nodeName;)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}(e.target);let s=-1;if(i){const{left:o,right:r}=i.getBoundingClientRect();e.clientX-o<=n?s=Uu(t,e,"left",n):r-e.clientX<=n&&(s=Uu(t,e,"right",n))}if(s!=r.activeHandle){if(!o&&-1!==s){const e=t.state.doc.resolve(s),n=e.node(-1),o=Qp.get(n),r=e.start(-1);if(o.colCount(e.pos-r)+e.nodeAfter.attrs.colspan-1==o.width-1)return}Yu(t,s)}}}(e,n,t,r)},mouseleave:t=>{!function(t){if(!t.editable)return;const e=qu.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&Yu(t,-1)}(t)},mousedown:(t,o)=>{!function(t,e,n,o){var r;if(!t.editable)return!1;const i=null!=(r=t.dom.ownerDocument.defaultView)?r:window,s=qu.getState(t.state);if(!s||-1==s.activeHandle||s.dragging)return!1;const l=t.state.doc.nodeAt(s.activeHandle),a=function(t,e,{colspan:n,colwidth:o}){const r=o&&o[o.length-1];if(r)return r;const i=t.domAtPos(e);let s=i.node.childNodes[i.offset].offsetWidth,l=n;if(o)for(let t=0;t<n;t++)o[t]&&(s-=o[t],l--);return s/l}(t,s.activeHandle,l.attrs);function c(e){i.removeEventListener("mouseup",c),i.removeEventListener("mousemove",d);const o=qu.getState(t.state);(null==o?void 0:o.dragging)&&(function(t,e,n){const o=t.state.doc.resolve(e),r=o.node(-1),i=Qp.get(r),s=o.start(-1),l=i.colCount(o.pos-s)+o.nodeAfter.attrs.colspan-1,a=t.state.tr;for(let t=0;t<i.height;t++){const e=t*i.width+l;if(t&&i.map[e]==i.map[e-i.width])continue;const o=i.map[e],d=r.nodeAt(o).attrs,h=1==d.colspan?0:l-i.colCount(o);if(d.colwidth&&d.colwidth[h]==n)continue;const p=d.colwidth?d.colwidth.slice():(c=d.colspan,Array(c).fill(0));p[h]=n,a.setNodeMarkup(s+o,null,{...d,colwidth:p})}var c;a.docChanged&&t.dispatch(a)}(t,o.activeHandle,Gu(o.dragging,e,n)),t.dispatch(t.state.tr.setMeta(qu,{setDragging:null})))}function d(e){if(!e.which)return c(e);const r=qu.getState(t.state);if(r&&r.dragging){const i=Gu(r.dragging,e,n);Xu(t,r.activeHandle,i,o)}}t.dispatch(t.state.tr.setMeta(qu,{setDragging:{startX:e.clientX,startWidth:a}})),Xu(t,s.activeHandle,a,o),i.addEventListener("mouseup",c),i.addEventListener("mousemove",d),e.preventDefault()}(t,o,e,n)}},decorations:t=>{const e=qu.getState(t);if(e&&e.activeHandle>-1)return function(t,e){var n;const o=[],r=t.doc.resolve(e),i=r.node(-1);if(!i)return ar.empty;const s=Qp.get(i),l=r.start(-1),a=s.colCount(r.pos-l)+r.nodeAfter.attrs.colspan-1;for(let e=0;e<s.height;e++){const r=a+e*s.width;if(!(a!=s.width-1&&s.map[r]==s.map[r+1]||0!=e&&s.map[r]==s.map[r-s.width])){const e=s.map[r],a=l+e+i.nodeAt(e).nodeSize-1,c=document.createElement("div");c.className="column-resize-handle",(null==(n=qu.getState(t))?void 0:n.dragging)&&o.push(ir.node(l+e,l+e+i.nodeAt(e).nodeSize,{class:"column-resize-dragging"})),o.push(ir.widget(a,c))}}return ar.create(t.doc,o)}(t,e.activeHandle)},nodeViews:{}}});return i}var Ju=class t{constructor(t,e){this.activeHandle=t,this.dragging=e}apply(e){const n=this,o=e.getMeta(qu);if(o&&null!=o.setHandle)return new t(o.setHandle,!1);if(o&&void 0!==o.setDragging)return new t(n.activeHandle,o.setDragging);if(n.activeHandle>-1&&e.docChanged){let o=e.mapping.map(n.activeHandle,-1);return iu(e.doc.resolve(o))||(o=-1),new t(o,n.dragging)}return n}};function Uu(t,e,n,o){const r="right"==n?-o:o,i=t.posAtCoords({left:e.clientX+r,top:e.clientY});if(!i)return-1;const{pos:s}=i,l=nu(t.state.doc.resolve(s));if(!l)return-1;if("right"==n)return l.pos;const a=Qp.get(l.node(-1)),c=l.start(-1),d=a.map.indexOf(l.pos-c);return d%a.width==0?-1:c+a.map[d-1]}function Gu(t,e,n){const o=e.clientX-t.startX;return Math.max(n,t.startWidth+o)}function Yu(t,e){t.dispatch(t.state.tr.setMeta(qu,{setHandle:e}))}function Xu(t,e,n,o){const r=t.state.doc.resolve(e),i=r.node(-1),s=r.start(-1),l=Qp.get(i).colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1;let a=t.domAtPos(r.start(-1)).node;for(;a&&"TABLE"!=a.nodeName;)a=a.parentNode;a&&Wu(i,a.firstChild,a,o,l,n)}function Qu({allowTableNodeSelection:t=!1}={}){return new xe({key:eu,state:{init:()=>null,apply(t,e){const n=t.getMeta(eu);if(null!=n)return-1==n?null:n;if(null==e||!t.docChanged)return e;const{deleted:o,pos:r}=t.mapping.mapResult(e);return o?null:r}},props:{decorations:pu,handleDOMEvents:{mousedown:Hu},createSelectionBetween:t=>null!=eu.getState(t.state)?t.state.selection:null,handleTripleClick:zu,handleKeyDown:ju,handlePaste:$u},appendTransaction:(e,n,o)=>function(t,e,n){const o=(e||t).selection,r=(e||t).doc;let i,s;if(o instanceof ce&&(s=o.node.type.spec.tableRole)){if("cell"==s||"header_cell"==s)i=du.create(r,o.from);else if("row"==s){const t=r.resolve(o.from+1);i=du.rowSelection(t,t)}else if(!n){const t=Qp.get(o.node),e=o.from+1,n=e+t.map[t.width*t.height-1];i=du.create(r,e+1,n)}}else o instanceof le&&function({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let n=t.pos,o=e.pos,r=t.depth;for(;r>=0&&!(t.after(r+1)<t.end(r));r--,n++);for(let t=e.depth;t>=0&&!(e.before(t+1)>e.start(t));t--,o--);return n==o&&/row|table/.test(t.node(r).type.spec.tableRole)}(o)?i=le.create(r,o.from):o instanceof le&&function({$from:t,$to:e}){let n,o;for(let e=t.depth;e>0;e--){const o=t.node(e);if("cell"===o.type.spec.tableRole||"header_cell"===o.type.spec.tableRole){n=o;break}}for(let t=e.depth;t>0;t--){const n=e.node(t);if("cell"===n.type.spec.tableRole||"header_cell"===n.type.spec.tableRole){o=n;break}}return n!==o&&0===e.parentOffset}(o)&&(i=le.create(r,o.$from.start(),o.$from.end()));return i&&(e||(e=t.tr)).setSelection(i),e}(o,mu(o,n),t)})}function Zu(t,e,n,o,r,i){let s=0,l=!0,a=e.firstChild;const c=t.firstChild;for(let t=0,n=0;t<c.childCount;t+=1){const{colspan:d,colwidth:h}=c.child(t).attrs;for(let t=0;t<d;t+=1,n+=1){const c=r===n?i:h&&h[t],d=c?`${c}px`:"";s+=c||o,c||(l=!1),a?(a.style.width!==d&&(a.style.width=d),a=a.nextSibling):e.appendChild(document.createElement("col")).style.width=d}}for(;a;){const t=a.nextSibling;a.parentNode.removeChild(a),a=t}l?(n.style.width=`${s}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${s}px`)}class tf{constructor(t,e){this.node=t,this.cellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Zu(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type===this.node.type&&(this.node=t,Zu(t,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(t){return"attributes"===t.type&&(t.target===this.table||this.colgroup.contains(t.target))}}function ef(t,e){return e?t.createChecked(null,e):t.createAndFill()}const nf=({editor:t})=>{const{selection:e}=t.state;if(!(e instanceof du))return!1;let n=0;const o=ys(e.ranges[0].$from,(t=>"table"===t.type.name));return null==o||o.node.descendants((t=>{if("table"===t.type.name)return!1;["tableCell","tableHeader"].includes(t.type.name)&&(n+=1)})),n===e.ranges.length&&(t.commands.deleteTable(),!0)},of=Fs.create({name:"table",addOptions:()=>({HTMLAttributes:{},resizable:!1,handleWidth:5,cellMinWidth:25,View:tf,lastColumnResizable:!0,allowTableNodeSelection:!1}),content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML:()=>[{tag:"table"}],renderHTML({node:t,HTMLAttributes:e}){const{colgroup:n,tableWidth:o,tableMinWidth:r}=function(t,e){let n=0,o=!0;const r=[],i=t.firstChild;if(!i)return{};for(let t=0,s=0;t<i.childCount;t+=1){const{colspan:l,colwidth:a}=i.child(t).attrs;for(let t=0;t<l;t+=1,s+=1){const i=undefined===s?undefined:a&&a[t],l=i?`${i}px`:"";n+=i||e,i||(o=!1),r.push(["col",l?{style:`width: ${l}`}:{}])}}const s=o?`${n}px`:"",l=o?"":`${n}px`;return{colgroup:["colgroup",{},...r],tableWidth:s,tableMinWidth:l}}(t,this.options.cellMinWidth);return["table",Oi(this.options.HTMLAttributes,e,{style:o?`width: ${o}`:`min-width: ${r}`}),n,["tbody",0]]},addCommands:()=>({insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:o,dispatch:r,editor:i})=>{const s=function(t,e,n,o,r){const i=function(t){if(t.cached.tableNodeTypes)return t.cached.tableNodeTypes;const e={};return Object.keys(t.nodes).forEach((n=>{const o=t.nodes[n];o.spec.tableRole&&(e[o.spec.tableRole]=o)})),t.cached.tableNodeTypes=e,e}(t),s=[],l=[];for(let t=0;t<n;t+=1){const t=ef(i.cell,r);if(t&&l.push(t),o){const t=ef(i.header_cell,r);t&&s.push(t)}}const a=[];for(let t=0;t<e;t+=1)a.push(i.row.createChecked(null,o&&0===t?s:l));return i.table.createChecked(null,a)}(i.schema,t,e,n);if(r){const t=o.selection.from+1;o.replaceSelectionWith(s).scrollIntoView().setSelection(le.near(o.doc.resolve(t)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>function(t,e){if(!ou(t))return!1;if(e){const n=gu(t);e(yu(t.tr,n,n.left))}return!0}(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>function(t,e){if(!ou(t))return!1;if(e){const n=gu(t);e(yu(t.tr,n,n.right))}return!0}(t,e),deleteColumn:()=>({state:t,dispatch:e})=>function(t,e){if(!ou(t))return!1;if(e){const n=gu(t),o=t.tr;if(0==n.left&&n.right==n.map.width)return!1;for(let t=n.right-1;bu(o,n,t),t!=n.left;t--){const t=n.tableStart?o.doc.nodeAt(n.tableStart-1):o.doc;if(!t)throw RangeError("No table found");n.table=t,n.map=Qp.get(t)}e(o)}return!0}(t,e),addRowBefore:()=>({state:t,dispatch:e})=>function(t,e){if(!ou(t))return!1;if(e){const n=gu(t);e(vu(t.tr,n,n.top))}return!0}(t,e),addRowAfter:()=>({state:t,dispatch:e})=>function(t,e){if(!ou(t))return!1;if(e){const n=gu(t);e(vu(t.tr,n,n.bottom))}return!0}(t,e),deleteRow:()=>({state:t,dispatch:e})=>function(t,e){if(!ou(t))return!1;if(e){const n=gu(t),o=t.tr;if(0==n.top&&n.bottom==n.map.height)return!1;for(let t=n.bottom-1;wu(o,n,t),t!=n.top;t--){const t=n.tableStart?o.doc.nodeAt(n.tableStart-1):o.doc;if(!t)throw RangeError("No table found");n.table=t,n.map=Qp.get(n.table)}e(o)}return!0}(t,e),deleteTable:()=>({state:t,dispatch:e})=>function(t,e){const n=t.selection.$anchor;for(let o=n.depth;o>0;o--)if("table"==n.node(o).type.spec.tableRole)return e&&e(t.tr.delete(n.before(o),n.after(o)).scrollIntoView()),!0;return!1}(t,e),mergeCells:()=>({state:t,dispatch:e})=>xu(t,e),splitCell:()=>({state:t,dispatch:e})=>Mu(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>Su("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>Su("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>Tu(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>!!xu(t,e)||Mu(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:o})=>function(t,e){return function(n,o){if(!ou(n))return!1;const r=ru(n);if(r.nodeAfter.attrs[t]===e)return!1;if(o){const i=n.tr;n.selection instanceof du?n.selection.forEachCell(((n,o)=>{n.attrs[t]!==e&&i.setNodeMarkup(o,null,{...n.attrs,[t]:e})})):i.setNodeMarkup(r.pos,null,{...r.nodeAfter.attrs,[t]:e}),o(i)}return!0}}(t,e)(n,o),goToNextCell:()=>({state:t,dispatch:e})=>Au(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>Au(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&mu(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const n=du.create(e.doc,t.anchorCell,t.headCell);e.setSelection(n)}return!0}}),addKeyboardShortcuts(){return{Tab:()=>!!this.editor.commands.goToNextCell()||!!this.editor.can().addRowAfter()&&this.editor.chain().addRowAfter().goToNextCell().run(),"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:nf,"Mod-Backspace":nf,Delete:nf,"Mod-Delete":nf}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[Ku({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],Qu({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema:t=>({tableRole:Di(Ci(t,"tableRole",{name:t.name,options:t.options,storage:t.storage}))})}),rf=Fs.create({name:"tableCell",addOptions:()=>({HTMLAttributes:{}}),content:"block+",addAttributes:()=>({colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map((t=>parseInt(t,10))):null}}}),tableRole:"cell",isolating:!0,parseHTML:()=>[{tag:"td"}],renderHTML({HTMLAttributes:t}){return["td",Oi(this.options.HTMLAttributes,t),0]}}),sf=Fs.create({name:"tableHeader",addOptions:()=>({HTMLAttributes:{}}),content:"block+",addAttributes:()=>({colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map((t=>parseInt(t,10))):null}}}),tableRole:"header_cell",isolating:!0,parseHTML:()=>[{tag:"th"}],renderHTML({HTMLAttributes:t}){return["th",Oi(this.options.HTMLAttributes,t),0]}}),lf=Fs.create({name:"tableRow",addOptions:()=>({HTMLAttributes:{}}),content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML:()=>[{tag:"tr"}],renderHTML({HTMLAttributes:t}){return["tr",Oi(this.options.HTMLAttributes,t),0]}}),af=Ui.create({name:"placeholder",addOptions:()=>({emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}),addProseMirrorPlugins(){return[new xe({key:new Se("placeholder"),props:{decorations:({doc:t,selection:e})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:o}=e,r=[];if(!n)return null;const i=this.editor.isEmpty;return t.descendants(((t,e)=>{const n=o>=e&&o<=e+t.nodeSize,s=!t.isLeaf&&Cs(t);if((n||!this.options.showOnlyCurrent)&&s){const o=[this.options.emptyNodeClass];i&&o.push(this.options.emptyEditorClass);const s=ir.node(e,e+t.nodeSize,{class:o.join(" "),"data-placeholder":"function"==typeof this.options.placeholder?this.options.placeholder({editor:this.editor,node:t,pos:e,hasAnchor:n}):this.options.placeholder});r.push(s)}return this.options.includeChildren})),ar.create(t,r)}}})]}}),cf=Vi.create({name:"textStyle",priority:101,addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"span",getAttrs:t=>!!t.hasAttribute("style")&&{}}],renderHTML({HTMLAttributes:t}){return["span",Oi(this.options.HTMLAttributes,t),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:t,commands:e})=>{const n=gs(t,this.type);return!!Object.entries(n).some((([,t])=>!!t))||e.unsetMark(this.name)}}}}),df=Ui.create({name:"color",addOptions:()=>({types:["textStyle"]}),addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;return null===(e=t.style.color)||void 0===e?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}}}}]},addCommands:()=>({setColor:t=>({chain:e})=>e().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()})}),hf=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,pf=Fs.create({name:"image",addOptions:()=>({inline:!1,allowBase64:!1,HTMLAttributes:{}}),inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes:()=>({src:{default:null},alt:{default:null},title:{default:null}}),parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:t}){return["img",Oi(this.options.HTMLAttributes,t)]},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[Hs({find:hf,type:this.type,getAttributes:t=>{const[,,e,n,o]=t;return{src:n,alt:e,title:o}}})]}});var uf=n(57479),ff={StarterKit:qp,Underline:Kp,Link:Ba,Superscript:Up,Subscript:Gp,Highlight:Rh,Table:of,TableCell:rf,TableHeader:sf,TableRow:lf,TextAlign:Jp,Placeholder:af,Color:df,TextStyle:cf,Image:pf},mf=function(t){var e=t.setProps,n=t.loading_state,r=(t.persistence,t.persisted_props,t.persistence_type,t.html),i=t.json,s=t.variant,l=t.extensions,a=void 0===l?["StarterKit","Underline","Link","Superscript","Subscript","Highlight","Table","TableCell","TableHeader","TableRow",{Placeholder:{placeholder:"Write or paste content here..."}},{TextAlign:{types:["heading","paragraph"]}},"Color","TextStyle","Image"]:l,c=t.toolbar,d=t.debounce,h=void 0===d?100:d,p=t.n_blur,u=void 0===p?0:p,f=(t.selected,t.labels),m=(0,o.Tt)(t,["setProps","loading_state","persistence","persisted_props","persistence_type","html","json","variant","extensions","toolbar","debounce","n_blur","selected","labels"]),g=function(t){void 0===t&&(t={}),O&&e((0,o.Cl)({html:O.getHTML(),json:O.getJSON()},t))},y=(0,Fa.useState)(""),b=y[0],v=y[1],w="number"==typeof h?h:0,k=(0,Oh.o)(b,w)[0];(0,Eh.C)((function(){"number"!=typeof h&&!1!==h||g()}),[k]),(0,Eh.C)((function(){O&&O.getHTML()!==r&&(O.commands.setContent(r),g())}),[r]),(0,Eh.C)((function(){O&&JSON.stringify(O.getJSON())!==JSON.stringify(i)&&(O.commands.setContent(i),g())}),[i]);var x=(0,Fa.useState)(""),M=x[0],C=x[1],S=(0,Oh.o)(M,w)[0];(0,Eh.C)((function(){"number"!=typeof h&&!1!==h||e({selected:S})}),[S]);var T=f&&(0,o.Cl)((0,o.Cl)((0,o.Cl)({},f),f.colorControlLabel&&{colorControlLabel:function(t){return f.colorControlLabel.replace("{color}",t)}}),f.colorPickerColorLabel&&{colorPickerColorLabel:function(t){return f.colorPickerColorLabel.replace("{color}",t)}}),A=void 0;void 0!==c&&(A=Va().createElement(mh.Toolbar,{sticky:c.sticky,stickyOffset:c.stickyOffset},c.controlsGroups.map((function(t,e){return Va().createElement(mh.ControlsGroup,{key:e},t.map((function(t,e){var n="string"==typeof t?t:Object.keys(t)[0],r="string"==typeof t?{}:t[n];return Va().createElement(mh[n],(0,o.Cl)({key:e},r))})))}))));var O=function(t={},e=[]){const n=(0,Fa.useRef)(t);n.current=t;const[o]=(0,Fa.useState)((()=>new bc(n))),r=oc.useSyncExternalStore(o.subscribe,o.getEditor,o.getServerSnapshot);return(0,Fa.useDebugValue)(r),(0,Fa.useEffect)(o.onRender(e)),function(t){var e;const[n]=(0,Fa.useState)((()=>new mc(t.editor))),o=fc.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,null!==(e=t.equalityFn)&&void 0!==e?e:hc);(0,Fa.useEffect)((()=>n.watch(t.editor)),[t.editor,n]),(0,Fa.useDebugValue)(o)}({editor:r,selector:({transactionNumber:e})=>!1===t.shouldRerenderOnTransaction?null:t.immediatelyRender&&0===e?0:e+1}),r}({extensions:a.map((function(t){if("string"==typeof t)return ff[t];var e=Object.keys(t)[0];return ff[e].configure(t[e])})),content:i||r,onUpdate:function(t){var e=t.editor;v(e.getJSON())},onBlur:function(){O&&!0===h&&g({n_blur:u+1,selected:M})},onSelectionUpdate:function(t){var e=t.editor;if(e){var n=e.state.selection,o=n.from,r=n.to,i=e.state.doc.textBetween(o,r," ");C(i)}},onCreate:g});return Va().createElement(mh,(0,o.Cl)({variant:s,editor:O,"data-dash-is-loading":(0,uf.A_)(n)||void 0,labels:T},m),A,Va().createElement(mh.Content,null))};(0,uf.oM)(mf,["html","json"]);const gf=mf},96541:(t,e,n)=>{n.d(e,{A:()=>p});var o=n(31601),r=n.n(o),i=n(76314),s=n.n(i),l=n(4417),a=n.n(l),c=new URL(n(34985),n.b),d=s()(r()),h=a()(c);d.push([t.id,`.m_dd3f7539 {\n position: relative;\n border: calc(0.0625rem * var(--mantine-scale)) solid;\n border-radius: var(--mantine-radius-default);\n}\n\n :where([data-mantine-color-scheme='light']) .m_dd3f7539 {\n border-color: var(--mantine-color-gray-4);\n}\n\n :where([data-mantine-color-scheme='dark']) .m_dd3f7539 {\n border-color: var(--mantine-color-dark-4);\n}\n\n.m_d37966d9 {\n padding: 0;\n margin: 0;\n}\n\n.m_d37966d9 li > p {\n margin: 0;\n }\n\n.m_d37966d9 ul li,\n .m_d37966d9 ol li {\n margin-top: calc(0.125rem * var(--mantine-scale));\n }\n\n.m_d37966d9 p {\n margin-bottom: calc(0.4375rem * var(--mantine-scale));\n }\n\n.m_d37966d9 h1,\n .m_d37966d9 h2,\n .m_d37966d9 h3,\n .m_d37966d9 h4,\n .m_d37966d9 h5,\n .m_d37966d9 h6,\n .m_d37966d9 p {\n margin-top: 0;\n }\n\n.m_c2204cc2 {\n background-color: var(--mantine-color-body);\n border-radius: var(--mantine-radius-default);\n}\n\n.m_c2204cc2 .ProseMirror {\n outline: 0;\n padding: var(--mantine-spacing-md);\n }\n\n.m_c2204cc2 .ProseMirror > *:last-child {\n margin-bottom: 0;\n }\n\n.m_c2204cc2 .ProseMirror p.is-editor-empty:first-of-type::before {\n content: attr(data-placeholder);\n pointer-events: none;\n user-select: none;\n float: left;\n height: 0;\n color: var(--mantine-color-placeholder);\n }\n\n.m_c2204cc2 pre {\n font-family: var(--mantine-font-family-monospace);\n border-radius: var(--mantine-radius-default);\n padding: var(--mantine-spacing-sm) var(--mantine-spacing-md);\n }\n\n:where([data-mantine-color-scheme='light']) .m_c2204cc2 pre {\n background-color: var(--mantine-color-gray-0);\n color: var(--mantine-color-gray-9);\n --code-color-comment: var(--mantine-color-gray-5);\n --code-color-var: var(--mantine-color-red-7);\n --code-color-number: var(--mantine-color-blue-7);\n --code-color-title: var(--mantine-color-pink-7);\n --code-color-keyword: var(--mantine-color-violet-7);\n}\n\n:where([data-mantine-color-scheme='dark']) .m_c2204cc2 pre {\n background-color: var(--mantine-color-dark-8);\n color: var(--mantine-color-dark-1);\n --code-color-comment: var(--mantine-color-dark-2);\n --code-color-var: var(--mantine-color-red-5);\n --code-color-number: var(--mantine-color-cyan-5);\n --code-color-title: var(--mantine-color-yellow-5);\n --code-color-keyword: var(--mantine-color-violet-3);\n}\n\n.m_c2204cc2 pre code {\n background: none !important;\n color: inherit;\n font-size: var(--mantine-font-size-sm);\n padding: 0;\n }\n\n.m_c2204cc2 pre .hljs-comment,\n .m_c2204cc2 pre .hljs-quote {\n color: var(--code-color-comment);\n }\n\n.m_c2204cc2 pre .hljs-variable,\n .m_c2204cc2 pre .hljs-template-variable,\n .m_c2204cc2 pre .hljs-attribute,\n .m_c2204cc2 pre .hljs-tag,\n .m_c2204cc2 pre .hljs-regexp,\n .m_c2204cc2 pre .hljs-link,\n .m_c2204cc2 pre .hljs-name,\n .m_c2204cc2 pre .hljs-selector-id,\n .m_c2204cc2 pre .hljs-selector-class {\n color: var(--code-color-var);\n }\n\n.m_c2204cc2 pre .hljs-number,\n .m_c2204cc2 pre .hljs-meta,\n .m_c2204cc2 pre .hljs-built_in,\n .m_c2204cc2 pre .hljs-builtin-name,\n .m_c2204cc2 pre .hljs-literal,\n .m_c2204cc2 pre .hljs-type,\n .m_c2204cc2 pre .hljs-params {\n color: var(--code-color-number);\n }\n\n.m_c2204cc2 pre .hljs-string,\n .m_c2204cc2 pre .hljs-symbol,\n .m_c2204cc2 pre .hljs-bullet {\n color: var(--code-color-var);\n }\n\n.m_c2204cc2 pre .hljs-title,\n .m_c2204cc2 pre .hljs-section {\n color: var(--code-color-title);\n }\n\n.m_c2204cc2 pre .hljs-keyword,\n .m_c2204cc2 pre .hljs-selector-tag {\n color: var(--code-color-keyword);\n }\n\n.m_c2204cc2 pre .hljs-emphasis {\n font-style: italic;\n }\n\n.m_c2204cc2 pre .hljs-strong {\n font-weight: 700;\n }\n\n.m_8a991b4f {\n background-color: var(--mantine-color-body);\n}\n\n.m_c2207da6 {\n display: flex;\n justify-content: center;\n align-items: center;\n border-radius: var(--mantine-radius-default);\n cursor: default;\n}\n\n.m_c2207da6:where([data-variant='default']) {\n border: calc(0.0625rem * var(--mantine-scale)) solid;\n min-width: calc(1.625rem * var(--mantine-scale));\n height: calc(1.625rem * var(--mantine-scale));\n }\n\n.m_c2207da6:where([data-variant='subtle']) {\n --control-icon-size: calc(1.25rem * var(--mantine-scale));\n min-width: calc(2rem * var(--mantine-scale));\n height: calc(2rem * var(--mantine-scale));\n }\n\n:where([data-mantine-color-scheme='light']) .m_c2207da6 {\n background-color: var(--mantine-color-white);\n border-color: var(--mantine-color-gray-4);\n color: var(--mantine-color-gray-7);\n}\n\n:where([data-mantine-color-scheme='dark']) .m_c2207da6 {\n border-color: var(--mantine-color-dark-4);\n color: var(--mantine-color-dark-1);\n}\n\n:where([data-mantine-color-scheme='dark']) .m_c2207da6:where([data-variant='default']) {\n background-color: var(--mantine-color-dark-6);\n }\n\n:where([data-mantine-color-scheme='dark']) .m_c2207da6:where([data-variant='subtle']) {\n background-color: var(--mantine-color-dark-7);\n }\n\n.m_c2207da6:where([data-disabled]) {\n cursor: not-allowed;\n }\n\n:where([data-mantine-color-scheme='light']) .m_c2207da6:where([data-disabled]) {\n background-color: var(--mantine-color-gray-1);\n color: var(--mantine-color-gray-5);\n}\n\n:where([data-mantine-color-scheme='dark']) .m_c2207da6:where([data-disabled]) {\n background-color: var(--mantine-color-dark-5);\n color: var(--mantine-color-dark-3);\n}\n\n.m_c2207da6:where([data-interactive]:not([data-disabled])) {\n cursor: pointer;\n }\n\n@media (hover: hover) {\n\n .m_c2207da6:where([data-interactive]:not([data-disabled])):hover {\n color: var(--mantine-color-bright);\n }\n :where([data-mantine-color-scheme='light']) .m_c2207da6:where([data-interactive]:not([data-disabled])):hover:where([data-variant='default']) {\n background-color: var(--mantine-color-gray-0);\n }\n\n :where([data-mantine-color-scheme='light']) .m_c2207da6:where([data-interactive]:not([data-disabled])):hover:where([data-variant='subtle']) {\n background-color: var(--mantine-color-gray-1);\n }\n\n :where([data-mantine-color-scheme='dark']) .m_c2207da6:where([data-interactive]:not([data-disabled])):hover {\n background-color: var(--mantine-color-dark-5);\n }\n}\n\n@media (hover: none) {\n\n .m_c2207da6:where([data-interactive]:not([data-disabled])):active {\n color: var(--mantine-color-bright);\n }\n :where([data-mantine-color-scheme='light']) .m_c2207da6:where([data-interactive]:not([data-disabled])):active:where([data-variant='default']) {\n background-color: var(--mantine-color-gray-0);\n }\n\n :where([data-mantine-color-scheme='light']) .m_c2207da6:where([data-interactive]:not([data-disabled])):active:where([data-variant='subtle']) {\n background-color: var(--mantine-color-gray-1);\n }\n\n :where([data-mantine-color-scheme='dark']) .m_c2207da6:where([data-interactive]:not([data-disabled])):active {\n background-color: var(--mantine-color-dark-5);\n }\n}\n\n.m_c2207da6:where([data-active]) {\n background-color: var(--mantine-primary-color-light);\n color: var(--mantine-primary-color-light-color);\n }\n\n@media (hover: hover) {\n\n .m_c2207da6:where([data-active]):hover {\n background-color: var(--mantine-primary-color-light-hover);\n }\n}\n\n@media (hover: none) {\n\n .m_c2207da6:where([data-active]):active {\n background-color: var(--mantine-primary-color-light-hover);\n }\n}\n\n.m_9cdfeb3f {\n width: var(--control-icon-size, 16px);\n height: var(--control-icon-size, 16px);\n}\n\n.m_2ab47ef2 {\n display: flex;\n background-color: var(--mantine-color-body);\n}\n\n.m_2ab47ef2:where([data-variant='default']) :where([data-rich-text-editor-control]) {\n border-radius: 0;\n }\n\n.m_2ab47ef2:where([data-variant='default']) :where([data-rich-text-editor-control]):where(:not(:last-of-type)) {\n border-inline-end-width: 0;\n }\n\n.m_2ab47ef2:where([data-variant='default']) :where([data-rich-text-editor-control]):where(:last-of-type) {\n border-start-end-radius: var(--mantine-radius-default);\n border-end-end-radius: var(--mantine-radius-default);\n }\n\n.m_2ab47ef2:where([data-variant='default']) :where([data-rich-text-editor-control]):where(:first-of-type) {\n border-start-start-radius: var(--mantine-radius-default);\n border-end-start-radius: var(--mantine-radius-default);\n }\n\n.m_b67b711e {\n display: flex;\n}\n\n.m_296cf94c {\n border-start-end-radius: 0;\n border-end-end-radius: 0;\n border-inline-end: 0;\n}\n\n.m_cfef614 {\n border: calc(0.0625rem * var(--mantine-scale)) solid;\n color: var(--mantine-color-text);\n height: calc(1.5rem * var(--mantine-scale));\n width: calc(1.5rem * var(--mantine-scale));\n display: flex;\n justify-content: center;\n align-items: center;\n border-radius: var(--mantine-radius-default);\n}\n\n:where([data-mantine-color-scheme='light']) .m_cfef614 {\n background-color: var(--mantine-color-white);\n border-color: var(--mantine-color-gray-4);\n}\n\n:where([data-mantine-color-scheme='dark']) .m_cfef614 {\n background-color: var(--mantine-color-dark-7);\n border-color: var(--mantine-color-dark-4);\n}\n\n.m_cfef614:where([data-active]) {\n background-color: var(--mantine-primary-color-light);\n color: var(--mantine-primary-color-filled);\n }\n\n@media (hover: hover) {\n\n .m_cfef614:where([data-active]):hover {\n background-color: var(--mantine-primary-color-light-hover);\n }\n}\n\n@media (hover: none) {\n\n .m_cfef614:where([data-active]):active {\n background-color: var(--mantine-primary-color-light-hover);\n }\n}\n\n.m_3b28e7bb {\n border-start-start-radius: 0;\n border-end-start-radius: 0;\n}\n\n.m_4574a3c4 {\n display: flex;\n align-items: center;\n flex-wrap: wrap;\n gap: var(--mantine-spacing-sm);\n top: var(--rte-sticky-offset, 0px);\n background-color: var(--mantine-color-body);\n z-index: 1;\n border-start-end-radius: var(--mantine-radius-default);\n border-start-start-radius: var(--mantine-radius-default);\n border-bottom: calc(0.0625rem * var(--mantine-scale)) solid;\n}\n\n.m_4574a3c4:where([data-variant='default']) {\n padding: var(--mantine-spacing-xs) var(--mantine-spacing-md);\n }\n\n.m_4574a3c4:where([data-variant='subtle']) {\n padding: calc(0.25rem * var(--mantine-scale));\n row-gap: 0;\n }\n\n:where([data-mantine-color-scheme='light']) .m_4574a3c4 {\n border-color: var(--mantine-color-gray-4);\n}\n\n:where([data-mantine-color-scheme='dark']) .m_4574a3c4 {\n border-color: var(--mantine-color-dark-4);\n}\n\n.m_4574a3c4:where([data-sticky]) {\n position: sticky;\n }\n\n.m_8b44009a {\n list-style-type: none;\n padding: 0;\n padding-inline-start: 0;\n}\n\n.m_8b44009a :where(li) {\n margin: 0;\n padding: 0;\n display: flex;\n }\n\n.m_8b44009a :where(ul) {\n margin-top: calc(0.3125rem * var(--mantine-scale));\n }\n\n.m_8b44009a p {\n margin: 0;\n padding: 0;\n }\n\n.m_8b44009a :where(label) {\n display: inline-block;\n }\n\n.m_8b44009a :where(input) {\n cursor: pointer;\n appearance: none;\n width: calc(1.125rem * var(--mantine-scale));\n height: calc(1.125rem * var(--mantine-scale));\n border: calc(0.0625rem * var(--mantine-scale)) solid;\n border-radius: var(--mantine-radius-default);\n vertical-align: middle;\n position: relative;\n }\n\n:where([data-mantine-color-scheme='light']) .m_8b44009a :where(input) {\n background-color: var(--mantine-color-white);\n border-color: var(--mantine-color-gray-4);\n}\n\n:where([data-mantine-color-scheme='dark']) .m_8b44009a :where(input) {\n background-color: var(--mantine-color-dark-6);\n border-color: var(--mantine-color-dark-4);\n}\n\n.m_8b44009a :where(input):checked {\n background-color: var(--mantine-primary-color-filled);\n border-color: var(--mantine-primary-color-filled);\n }\n\n.m_8b44009a :where(input):checked::before {\n position: absolute;\n content: '';\n inset: 0;\n background-image: url(${h});\n background-repeat: no-repeat;\n background-size: calc(0.625rem * var(--mantine-scale));\n background-position: center;\n }\n\n.m_8b44009a :where(li > label) {\n margin-inline-end: var(--mantine-spacing-sm);\n }\n`,""]);const p=d}}]);
1
+ "use strict";(self.webpackChunkdash_mantine_components=self.webpackChunkdash_mantine_components||[]).push([[330],{4417:t=>{t.exports=function(t,e){return e||(e={}),t?(t=String(t.__esModule?t.default:t),/^['"].*['"]$/.test(t)&&(t=t.slice(1,-1)),e.hash&&(t+=e.hash),/["'() \t\n]|(%20)/.test(t)||e.needQuotes?'"'.concat(t.replace(/"/g,'\\"').replace(/\n/g,"\\n"),'"'):t):t}},4985:t=>{t.exports="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCAxMCA3Ij48cGF0aCBmaWxsPSIjZmZmIiBkPSJNNCA0LjU4NkwxLjcwNyAyLjI5M0ExIDEgMCAxMC4yOTMgMy43MDdsMyAzYS45OTcuOTk3IDAgMDAxLjQxNCAwbDUtNUExIDEgMCAxMDguMjkzLjI5M0w0IDQuNTg2eiIvPjwvc3ZnPg=="},6389:(t,e,n)=>{n.r(e),n.d(e,{default:()=>gf});var o=n(1635);function r(t){this.content=t}r.prototype={constructor:r,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return-1==e?void 0:this.content[e+1]},update:function(t,e,n){var o=n&&n!=t?this.remove(n):this,i=o.find(t),s=o.content.slice();return-1==i?s.push(n||t,e):(s[i+1]=e,n&&(s[i]=n)),new r(s)},remove:function(t){var e=this.find(t);if(-1==e)return this;var n=this.content.slice();return n.splice(e,2),new r(n)},addToStart:function(t,e){return new r([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new r(n)},addBefore:function(t,e,n){var o=this.remove(e),i=o.content.slice(),s=o.find(t);return i.splice(-1==s?i.length:s,0,e,n),new r(i)},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=r.from(t)).size?new r(t.content.concat(this.subtract(t).content)):this},append:function(t){return(t=r.from(t)).size?new r(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=r.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}},r.from=function(t){if(t instanceof r)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new r(e)};const i=r;function s(t,e,n){for(let o=0;;o++){if(o==t.childCount||o==e.childCount)return t.childCount==e.childCount?null:n;let r=t.child(o),i=e.child(o);if(r!=i){if(!r.sameMarkup(i))return n;if(r.isText&&r.text!=i.text){for(let t=0;r.text[t]==i.text[t];t++)n++;return n}if(r.content.size||i.content.size){let t=s(r.content,i.content,n+1);if(null!=t)return t}n+=r.nodeSize}else n+=r.nodeSize}}function l(t,e,n,o){for(let r=t.childCount,i=e.childCount;;){if(0==r||0==i)return r==i?null:{a:n,b:o};let s=t.child(--r),a=e.child(--i),c=s.nodeSize;if(s!=a){if(!s.sameMarkup(a))return{a:n,b:o};if(s.isText&&s.text!=a.text){let t=0,e=Math.min(s.text.length,a.text.length);for(;t<e&&s.text[s.text.length-t-1]==a.text[a.text.length-t-1];)t++,n--,o--;return{a:n,b:o}}if(s.content.size||a.content.size){let t=l(s.content,a.content,n-1,o-1);if(t)return t}n-=c,o-=c}else n-=c,o-=c}}class a{constructor(t,e){if(this.content=t,this.size=e||0,null==e)for(let e=0;e<t.length;e++)this.size+=t[e].nodeSize}nodesBetween(t,e,n,o=0,r){for(let i=0,s=0;s<e;i++){let l=this.content[i],a=s+l.nodeSize;if(a>t&&!1!==n(l,o+s,r||null,i)&&l.content.size){let r=s+1;l.nodesBetween(Math.max(0,t-r),Math.min(l.content.size,e-r),n,o+r)}s=a}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,e,n,o){let r="",i=!0;return this.nodesBetween(t,e,((s,l)=>{let a=s.isText?s.text.slice(Math.max(t,l)-l,e-l):s.isLeaf?o?"function"==typeof o?o(s):o:s.type.spec.leafText?s.type.spec.leafText(s):"":"";s.isBlock&&(s.isLeaf&&a||s.isTextblock)&&n&&(i?i=!1:r+=n),r+=a}),0),r}append(t){if(!t.size)return this;if(!this.size)return t;let e=this.lastChild,n=t.firstChild,o=this.content.slice(),r=0;for(e.isText&&e.sameMarkup(n)&&(o[o.length-1]=e.withText(e.text+n.text),r=1);r<t.content.length;r++)o.push(t.content[r]);return new a(o,this.size+t.size)}cut(t,e=this.size){if(0==t&&e==this.size)return this;let n=[],o=0;if(e>t)for(let r=0,i=0;i<e;r++){let s=this.content[r],l=i+s.nodeSize;l>t&&((i<t||l>e)&&(s=s.isText?s.cut(Math.max(0,t-i),Math.min(s.text.length,e-i)):s.cut(Math.max(0,t-i-1),Math.min(s.content.size,e-i-1))),n.push(s),o+=s.nodeSize),i=l}return new a(n,o)}cutByIndex(t,e){return t==e?a.empty:0==t&&e==this.content.length?this:new a(this.content.slice(t,e))}replaceChild(t,e){let n=this.content[t];if(n==e)return this;let o=this.content.slice(),r=this.size+e.nodeSize-n.nodeSize;return o[t]=e,new a(o,r)}addToStart(t){return new a([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new a(this.content.concat(t),this.size+t.nodeSize)}eq(t){if(this.content.length!=t.content.length)return!1;for(let e=0;e<this.content.length;e++)if(!this.content[e].eq(t.content[e]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(t){let e=this.content[t];if(!e)throw new RangeError("Index "+t+" out of range for "+this);return e}maybeChild(t){return this.content[t]||null}forEach(t){for(let e=0,n=0;e<this.content.length;e++){let o=this.content[e];t(o,n,e),n+=o.nodeSize}}findDiffStart(t,e=0){return s(this,t,e)}findDiffEnd(t,e=this.size,n=t.size){return l(this,t,e,n)}findIndex(t,e=-1){if(0==t)return d(0,t);if(t==this.size)return d(this.content.length,t);if(t>this.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let n=0,o=0;;n++){let r=o+this.child(n).nodeSize;if(r>=t)return r==t||e>0?d(n+1,r):d(n,o);o=r}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map((t=>t.toJSON())):null}static fromJSON(t,e){if(!e)return a.empty;if(!Array.isArray(e))throw new RangeError("Invalid input for Fragment.fromJSON");return new a(e.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return a.empty;let e,n=0;for(let o=0;o<t.length;o++){let r=t[o];n+=r.nodeSize,o&&r.isText&&t[o-1].sameMarkup(r)?(e||(e=t.slice(0,o)),e[e.length-1]=r.withText(e[e.length-1].text+r.text)):e&&e.push(r)}return new a(e||t,n)}static from(t){if(!t)return a.empty;if(t instanceof a)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new a([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}a.empty=new a([],0);const c={index:0,offset:0};function d(t,e){return c.index=t,c.offset=e,c}function h(t,e){if(t===e)return!0;if(!t||"object"!=typeof t||!e||"object"!=typeof e)return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!h(t[n],e[n]))return!1}else{for(let n in t)if(!(n in e)||!h(t[n],e[n]))return!1;for(let n in e)if(!(n in t))return!1}return!0}class p{constructor(t,e){this.type=t,this.attrs=e}addToSet(t){let e,n=!1;for(let o=0;o<t.length;o++){let r=t[o];if(this.eq(r))return t;if(this.type.excludes(r.type))e||(e=t.slice(0,o));else{if(r.type.excludes(this.type))return t;!n&&r.type.rank>this.type.rank&&(e||(e=t.slice(0,o)),e.push(this),n=!0),e&&e.push(r)}}return e||(e=t.slice()),n||e.push(this),e}removeFromSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return t.slice(0,e).concat(t.slice(e+1));return t}isInSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return!0;return!1}eq(t){return this==t||this.type==t.type&&h(this.attrs,t.attrs)}toJSON(){let t={type:this.type.name};for(let e in this.attrs){t.attrs=this.attrs;break}return t}static fromJSON(t,e){if(!e)throw new RangeError("Invalid input for Mark.fromJSON");let n=t.marks[e.type];if(!n)throw new RangeError(`There is no mark type ${e.type} in this schema`);let o=n.create(e.attrs);return n.checkAttrs(o.attrs),o}static sameSet(t,e){if(t==e)return!0;if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].eq(e[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&0==t.length)return p.none;if(t instanceof p)return[t];let e=t.slice();return e.sort(((t,e)=>t.type.rank-e.type.rank)),e}}p.none=[];class u extends Error{}class f{constructor(t,e,n){this.content=t,this.openStart=e,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,e){let n=g(this.content,t+this.openStart,e);return n&&new f(n,this.openStart,this.openEnd)}removeBetween(t,e){return new f(m(this.content,t+this.openStart,e+this.openStart),this.openStart,this.openEnd)}eq(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let t={content:this.content.toJSON()};return this.openStart>0&&(t.openStart=this.openStart),this.openEnd>0&&(t.openEnd=this.openEnd),t}static fromJSON(t,e){if(!e)return f.empty;let n=e.openStart||0,o=e.openEnd||0;if("number"!=typeof n||"number"!=typeof o)throw new RangeError("Invalid input for Slice.fromJSON");return new f(a.fromJSON(t,e.content),n,o)}static maxOpen(t,e=!0){let n=0,o=0;for(let o=t.firstChild;o&&!o.isLeaf&&(e||!o.type.spec.isolating);o=o.firstChild)n++;for(let n=t.lastChild;n&&!n.isLeaf&&(e||!n.type.spec.isolating);n=n.lastChild)o++;return new f(t,n,o)}}function m(t,e,n){let{index:o,offset:r}=t.findIndex(e),i=t.maybeChild(o),{index:s,offset:l}=t.findIndex(n);if(r==e||i.isText){if(l!=n&&!t.child(s).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(o!=s)throw new RangeError("Removing non-flat range");return t.replaceChild(o,i.copy(m(i.content,e-r-1,n-r-1)))}function g(t,e,n,o){let{index:r,offset:i}=t.findIndex(e),s=t.maybeChild(r);if(i==e||s.isText)return o&&!o.canReplace(r,r,n)?null:t.cut(0,e).append(n).append(t.cut(e));let l=g(s.content,e-i-1,n);return l&&t.replaceChild(r,s.copy(l))}function y(t,e,n){if(n.openStart>t.depth)throw new u("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new u("Inconsistent open depths");return b(t,e,n,0)}function b(t,e,n,o){let r=t.index(o),i=t.node(o);if(r==e.index(o)&&o<t.depth-n.openStart){let s=b(t,e,n,o+1);return i.copy(i.content.replaceChild(r,s))}if(n.content.size){if(n.openStart||n.openEnd||t.depth!=o||e.depth!=o){let{start:r,end:s}=function(t,e){let n=e.depth-t.openStart,o=e.node(n).copy(t.content);for(let t=n-1;t>=0;t--)o=e.node(t).copy(a.from(o));return{start:o.resolveNoCache(t.openStart+n),end:o.resolveNoCache(o.content.size-t.openEnd-n)}}(n,t);return M(i,C(t,r,s,e,o))}{let o=t.parent,r=o.content;return M(o,r.cut(0,t.parentOffset).append(n.content).append(r.cut(e.parentOffset)))}}return M(i,S(t,e,o))}function v(t,e){if(!e.type.compatibleContent(t.type))throw new u("Cannot join "+e.type.name+" onto "+t.type.name)}function w(t,e,n){let o=t.node(n);return v(o,e.node(n)),o}function k(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 x(t,e,n,o){let r=(e||t).node(n),i=0,s=e?e.index(n):r.childCount;t&&(i=t.index(n),t.depth>n?i++:t.textOffset&&(k(t.nodeAfter,o),i++));for(let t=i;t<s;t++)k(r.child(t),o);e&&e.depth==n&&e.textOffset&&k(e.nodeBefore,o)}function M(t,e){return t.type.checkContent(e),t.copy(e)}function C(t,e,n,o,r){let i=t.depth>r&&w(t,e,r+1),s=o.depth>r&&w(n,o,r+1),l=[];return x(null,t,r,l),i&&s&&e.index(r)==n.index(r)?(v(i,s),k(M(i,C(t,e,n,o,r+1)),l)):(i&&k(M(i,S(t,e,r+1)),l),x(e,n,r,l),s&&k(M(s,S(n,o,r+1)),l)),x(o,null,r,l),new a(l)}function S(t,e,n){let o=[];return x(null,t,n,o),t.depth>n&&k(M(w(t,e,n+1),S(t,e,n+1)),o),x(e,null,n,o),new a(o)}f.empty=new f(a.empty,0,0);class T{constructor(t,e,n){this.pos=t,this.path=e,this.parentOffset=n,this.depth=e.length/3-1}resolveDepth(t){return null==t?this.depth:t<0?this.depth+t:t}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(t){return this.path[3*this.resolveDepth(t)]}index(t){return this.path[3*this.resolveDepth(t)+1]}indexAfter(t){return t=this.resolveDepth(t),this.index(t)+(t!=this.depth||this.textOffset?1:0)}start(t){return 0==(t=this.resolveDepth(t))?0:this.path[3*t-1]+1}end(t){return t=this.resolveDepth(t),this.start(t)+this.node(t).content.size}before(t){if(!(t=this.resolveDepth(t)))throw new RangeError("There is no position before the top-level node");return t==this.depth+1?this.pos:this.path[3*t-1]}after(t){if(!(t=this.resolveDepth(t)))throw new RangeError("There is no position after the top-level node");return t==this.depth+1?this.pos:this.path[3*t-1]+this.path[3*t].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let t=this.parent,e=this.index(this.depth);if(e==t.childCount)return null;let n=this.pos-this.path[this.path.length-1],o=t.child(e);return n?t.child(e).cut(n):o}get nodeBefore(){let t=this.index(this.depth),e=this.pos-this.path[this.path.length-1];return e?this.parent.child(t).cut(0,e):0==t?null:this.parent.child(t-1)}posAtIndex(t,e){e=this.resolveDepth(e);let n=this.path[3*e],o=0==e?0:this.path[3*e-1]+1;for(let e=0;e<t;e++)o+=n.child(e).nodeSize;return o}marks(){let t=this.parent,e=this.index();if(0==t.content.size)return p.none;if(this.textOffset)return t.child(e).marks;let n=t.maybeChild(e-1),o=t.maybeChild(e);if(!n){let t=n;n=o,o=t}let r=n.marks;for(var i=0;i<r.length;i++)!1!==r[i].type.spec.inclusive||o&&r[i].isInSet(o.marks)||(r=r[i--].removeFromSet(r));return r}marksAcross(t){let e=this.parent.maybeChild(this.index());if(!e||!e.isInline)return null;let n=e.marks,o=t.parent.maybeChild(t.index());for(var r=0;r<n.length;r++)!1!==n[r].type.spec.inclusive||o&&n[r].isInSet(o.marks)||(n=n[r--].removeFromSet(n));return n}sharedDepth(t){for(let e=this.depth;e>0;e--)if(this.start(e)<=t&&this.end(e)>=t)return e;return 0}blockRange(t=this,e){if(t.pos<this.pos)return t.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==t.pos?1:0);n>=0;n--)if(t.pos<=this.end(n)&&(!e||e(this.node(n))))return new N(this,t,n);return null}sameParent(t){return this.pos-this.parentOffset==t.pos-t.parentOffset}max(t){return t.pos>this.pos?t:this}min(t){return t.pos<this.pos?t:this}toString(){let t="";for(let e=1;e<=this.depth;e++)t+=(t?"/":"")+this.node(e).type.name+"_"+this.index(e-1);return t+":"+this.parentOffset}static resolve(t,e){if(!(e>=0&&e<=t.content.size))throw new RangeError("Position "+e+" out of range");let n=[],o=0,r=e;for(let e=t;;){let{index:t,offset:i}=e.content.findIndex(r),s=r-i;if(n.push(e,t,o+i),!s)break;if(e=e.child(t),e.isText)break;r=s-1,o+=i+1}return new T(e,n,r)}static resolveCached(t,e){let n=E.get(t);if(n)for(let t=0;t<n.elts.length;t++){let o=n.elts[t];if(o.pos==e)return o}else E.set(t,n=new A);let o=n.elts[n.i]=T.resolve(t,e);return n.i=(n.i+1)%O,o}}class A{constructor(){this.elts=[],this.i=0}}const O=12,E=new WeakMap;class N{constructor(t,e,n){this.$from=t,this.$to=e,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const D=Object.create(null);class R{constructor(t,e,n,o=p.none){this.type=t,this.attrs=e,this.marks=o,this.content=n||a.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(t){return this.content.child(t)}maybeChild(t){return this.content.maybeChild(t)}forEach(t){this.content.forEach(t)}nodesBetween(t,e,n,o=0){this.content.nodesBetween(t,e,n,o,this)}descendants(t){this.nodesBetween(0,this.content.size,t)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(t,e,n,o){return this.content.textBetween(t,e,n,o)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(t){return this==t||this.sameMarkup(t)&&this.content.eq(t.content)}sameMarkup(t){return this.hasMarkup(t.type,t.attrs,t.marks)}hasMarkup(t,e,n){return this.type==t&&h(this.attrs,e||t.defaultAttrs||D)&&p.sameSet(this.marks,n||p.none)}copy(t=null){return t==this.content?this:new R(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new R(this.type,this.attrs,this.content,t)}cut(t,e=this.content.size){return 0==t&&e==this.content.size?this:this.copy(this.content.cut(t,e))}slice(t,e=this.content.size,n=!1){if(t==e)return f.empty;let o=this.resolve(t),r=this.resolve(e),i=n?0:o.sharedDepth(e),s=o.start(i),l=o.node(i).content.cut(o.pos-s,r.pos-s);return new f(l,o.depth-i,r.depth-i)}replace(t,e,n){return y(this.resolve(t),this.resolve(e),n)}nodeAt(t){for(let e=this;;){let{index:n,offset:o}=e.content.findIndex(t);if(e=e.maybeChild(n),!e)return null;if(o==t||e.isText)return e;t-=o+1}}childAfter(t){let{index:e,offset:n}=this.content.findIndex(t);return{node:this.content.maybeChild(e),index:e,offset:n}}childBefore(t){if(0==t)return{node:null,index:0,offset:0};let{index:e,offset:n}=this.content.findIndex(t);if(n<t)return{node:this.content.child(e),index:e,offset:n};let o=this.content.child(e-1);return{node:o,index:e-1,offset:n-o.nodeSize}}resolve(t){return T.resolveCached(this,t)}resolveNoCache(t){return T.resolve(this,t)}rangeHasMark(t,e,n){let o=!1;return e>t&&this.nodesBetween(t,e,(t=>(n.isInSet(t.marks)&&(o=!0),!o))),o}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let t=this.type.name;return this.content.size&&(t+="("+this.content.toStringInner()+")"),L(this.marks,t)}contentMatchAt(t){let e=this.type.contentMatch.matchFragment(this.content,0,t);if(!e)throw new Error("Called contentMatchAt on a node with invalid content");return e}canReplace(t,e,n=a.empty,o=0,r=n.childCount){let i=this.contentMatchAt(t).matchFragment(n,o,r),s=i&&i.matchFragment(this.content,e);if(!s||!s.validEnd)return!1;for(let t=o;t<r;t++)if(!this.type.allowsMarks(n.child(t).marks))return!1;return!0}canReplaceWith(t,e,n,o){if(o&&!this.type.allowsMarks(o))return!1;let r=this.contentMatchAt(t).matchType(n),i=r&&r.matchFragment(this.content,e);return!!i&&i.validEnd}canAppend(t){return t.content.size?this.canReplace(this.childCount,this.childCount,t.content):this.type.compatibleContent(t.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let t=p.none;for(let e=0;e<this.marks.length;e++){let n=this.marks[e];n.type.checkAttrs(n.attrs),t=n.addToSet(t)}if(!p.sameSet(t,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map((t=>t.type.name))}`);this.content.forEach((t=>t.check()))}toJSON(){let t={type:this.type.name};for(let e in this.attrs){t.attrs=this.attrs;break}return this.content.size&&(t.content=this.content.toJSON()),this.marks.length&&(t.marks=this.marks.map((t=>t.toJSON()))),t}static fromJSON(t,e){if(!e)throw new RangeError("Invalid input for Node.fromJSON");let n;if(e.marks){if(!Array.isArray(e.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=e.marks.map(t.markFromJSON)}if("text"==e.type){if("string"!=typeof e.text)throw new RangeError("Invalid text node in JSON");return t.text(e.text,n)}let o=a.fromJSON(t,e.content),r=t.nodeType(e.type).create(e.attrs,o,n);return r.type.checkAttrs(r.attrs),r}}R.prototype.text=void 0;class j extends R{constructor(t,e,n,o){if(super(t,e,null,o),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):L(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(t,e){return this.text.slice(t,e)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new j(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new j(this.type,this.attrs,t,this.marks)}cut(t=0,e=this.text.length){return 0==t&&e==this.text.length?this:this.withText(this.text.slice(t,e))}eq(t){return this.sameMarkup(t)&&this.text==t.text}toJSON(){let t=super.toJSON();return t.text=this.text,t}}function L(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class I{constructor(t){this.validEnd=t,this.next=[],this.wrapCache=[]}static parse(t,e){let n=new P(t,e);if(null==n.next)return I.empty;let o=z(n);n.next&&n.err("Unexpected trailing text");let r=function(t){let e=Object.create(null);return function n(o){let r=[];o.forEach((e=>{t[e].forEach((({term:e,to:n})=>{if(!e)return;let o;for(let t=0;t<r.length;t++)r[t][0]==e&&(o=r[t][1]);V(t,n).forEach((t=>{o||r.push([e,o=[]]),-1==o.indexOf(t)&&o.push(t)}))}))}));let i=e[o.join(",")]=new I(o.indexOf(t.length-1)>-1);for(let t=0;t<r.length;t++){let o=r[t][1].sort(F);i.next.push({type:r[t][0],next:e[o.join(",")]||n(o)})}return i}(V(t,0))}(function(t){let e=[[]];return r(function t(e,i){if("choice"==e.type)return e.exprs.reduce(((e,n)=>e.concat(t(n,i))),[]);if("seq"!=e.type){if("star"==e.type){let s=n();return o(i,s),r(t(e.expr,s),s),[o(s)]}if("plus"==e.type){let s=n();return r(t(e.expr,i),s),r(t(e.expr,s),s),[o(s)]}if("opt"==e.type)return[o(i)].concat(t(e.expr,i));if("range"==e.type){let s=i;for(let o=0;o<e.min;o++){let o=n();r(t(e.expr,s),o),s=o}if(-1==e.max)r(t(e.expr,s),s);else for(let i=e.min;i<e.max;i++){let i=n();o(s,i),r(t(e.expr,s),i),s=i}return[o(s)]}if("name"==e.type)return[o(i,void 0,e.value)];throw new Error("Unknown expr type")}for(let o=0;;o++){let s=t(e.exprs[o],i);if(o==e.exprs.length-1)return s;r(s,i=n())}}(t,0),n()),e;function n(){return e.push([])-1}function o(t,n,o){let r={term:o,to:n};return e[t].push(r),r}function r(t,e){t.forEach((t=>t.to=e))}}(o));return function(t,e){for(let n=0,o=[t];n<o.length;n++){let t=o[n],r=!t.validEnd,i=[];for(let e=0;e<t.next.length;e++){let{type:n,next:s}=t.next[e];i.push(n.name),!r||n.isText||n.hasRequiredAttrs()||(r=!1),-1==o.indexOf(s)&&o.push(s)}r&&e.err("Only non-generatable nodes ("+i.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(r,n),r}matchType(t){for(let e=0;e<this.next.length;e++)if(this.next[e].type==t)return this.next[e].next;return null}matchFragment(t,e=0,n=t.childCount){let o=this;for(let r=e;o&&r<n;r++)o=o.matchType(t.child(r).type);return o}get inlineContent(){return 0!=this.next.length&&this.next[0].type.isInline}get defaultType(){for(let t=0;t<this.next.length;t++){let{type:e}=this.next[t];if(!e.isText&&!e.hasRequiredAttrs())return e}return null}compatible(t){for(let e=0;e<this.next.length;e++)for(let n=0;n<t.next.length;n++)if(this.next[e].type==t.next[n].type)return!0;return!1}fillBefore(t,e=!1,n=0){let o=[this];return function r(i,s){let l=i.matchFragment(t,n);if(l&&(!e||l.validEnd))return a.from(s.map((t=>t.createAndFill())));for(let t=0;t<i.next.length;t++){let{type:e,next:n}=i.next[t];if(!e.isText&&!e.hasRequiredAttrs()&&-1==o.indexOf(n)){o.push(n);let t=r(n,s.concat(e));if(t)return t}}return null}(this,[])}findWrapping(t){for(let e=0;e<this.wrapCache.length;e+=2)if(this.wrapCache[e]==t)return this.wrapCache[e+1];let e=this.computeWrapping(t);return this.wrapCache.push(t,e),e}computeWrapping(t){let e=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let o=n.shift(),r=o.match;if(r.matchType(t)){let t=[];for(let e=o;e.type;e=e.via)t.push(e.type);return t.reverse()}for(let t=0;t<r.next.length;t++){let{type:i,next:s}=r.next[t];i.isLeaf||i.hasRequiredAttrs()||i.name in e||o.type&&!s.validEnd||(n.push({match:i.contentMatch,type:i,via:o}),e[i.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(t){if(t>=this.next.length)throw new RangeError(`There's no ${t}th edge in this content match`);return this.next[t]}toString(){let t=[];return function e(n){t.push(n);for(let o=0;o<n.next.length;o++)-1==t.indexOf(n.next[o].next)&&e(n.next[o].next)}(this),t.map(((e,n)=>{let o=n+(e.validEnd?"*":" ")+" ";for(let n=0;n<e.next.length;n++)o+=(n?", ":"")+e.next[n].type.name+"->"+t.indexOf(e.next[n].next);return o})).join("\n")}}I.empty=new I(!0);class P{constructor(t,e){this.string=t,this.nodeTypes=e,this.inline=null,this.pos=0,this.tokens=t.split(/\s*(?=\b|\W|$)/),""==this.tokens[this.tokens.length-1]&&this.tokens.pop(),""==this.tokens[0]&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(t){return this.next==t&&(this.pos++||!0)}err(t){throw new SyntaxError(t+" (in content expression '"+this.string+"')")}}function z(t){let e=[];do{e.push($(t))}while(t.eat("|"));return 1==e.length?e[0]:{type:"choice",exprs:e}}function $(t){let e=[];do{e.push(H(t))}while(t.next&&")"!=t.next&&"|"!=t.next);return 1==e.length?e[0]:{type:"seq",exprs:e}}function H(t){let e=function(t){if(t.eat("(")){let e=z(t);return t.eat(")")||t.err("Missing closing paren"),e}if(!/\W/.test(t.next)){let e=function(t,e){let n=t.nodeTypes,o=n[e];if(o)return[o];let r=[];for(let t in n){let o=n[t];o.isInGroup(e)&&r.push(o)}return 0==r.length&&t.err("No node type or group '"+e+"' found"),r}(t,t.next).map((e=>(null==t.inline?t.inline=e.isInline:t.inline!=e.isInline&&t.err("Mixing inline and block content"),{type:"name",value:e})));return t.pos++,1==e.length?e[0]:{type:"choice",exprs:e}}t.err("Unexpected token '"+t.next+"'")}(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else{if(!t.eat("{"))break;e=_(t,e)}return e}function B(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function _(t,e){let n=B(t),o=n;return t.eat(",")&&(o="}"!=t.next?B(t):-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:o,expr:e}}function F(t,e){return e-t}function V(t,e){let n=[];return function e(o){let r=t[o];if(1==r.length&&!r[0].term)return e(r[0].to);n.push(o);for(let t=0;t<r.length;t++){let{term:o,to:i}=r[t];o||-1!=n.indexOf(i)||e(i)}}(e),n.sort(F)}function W(t){let e=Object.create(null);for(let n in t){let o=t[n];if(!o.hasDefault)return null;e[n]=o.default}return e}function q(t,e){let n=Object.create(null);for(let o in t){let r=e&&e[o];if(void 0===r){let e=t[o];if(!e.hasDefault)throw new RangeError("No value supplied for attribute "+o);r=e.default}n[o]=r}return n}function K(t,e,n,o){for(let o in e)if(!(o in t))throw new RangeError(`Unsupported attribute ${o} for ${n} of type ${o}`);for(let n in t){let o=t[n];o.validate&&o.validate(e[n])}}function J(t,e){let n=Object.create(null);if(e)for(let o in e)n[o]=new G(t,o,e[o]);return n}class U{constructor(t,e,n){this.name=t,this.schema=e,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(" "):[],this.attrs=J(t,n.attrs),this.defaultAttrs=W(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||"text"==t),this.isText="text"==t}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==I.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(t){return this.groups.indexOf(t)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let t in this.attrs)if(this.attrs[t].isRequired)return!0;return!1}compatibleContent(t){return this==t||this.contentMatch.compatible(t.contentMatch)}computeAttrs(t){return!t&&this.defaultAttrs?this.defaultAttrs:q(this.attrs,t)}create(t=null,e,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new R(this,this.computeAttrs(t),a.from(e),p.setFrom(n))}createChecked(t=null,e,n){return e=a.from(e),this.checkContent(e),new R(this,this.computeAttrs(t),e,p.setFrom(n))}createAndFill(t=null,e,n){if(t=this.computeAttrs(t),(e=a.from(e)).size){let t=this.contentMatch.fillBefore(e);if(!t)return null;e=t.append(e)}let o=this.contentMatch.matchFragment(e),r=o&&o.fillBefore(a.empty,!0);return r?new R(this,t,e.append(r),p.setFrom(n)):null}validContent(t){let e=this.contentMatch.matchFragment(t);if(!e||!e.validEnd)return!1;for(let e=0;e<t.childCount;e++)if(!this.allowsMarks(t.child(e).marks))return!1;return!0}checkContent(t){if(!this.validContent(t))throw new RangeError(`Invalid content for node ${this.name}: ${t.toString().slice(0,50)}`)}checkAttrs(t){K(this.attrs,t,"node",this.name)}allowsMarkType(t){return null==this.markSet||this.markSet.indexOf(t)>-1}allowsMarks(t){if(null==this.markSet)return!0;for(let e=0;e<t.length;e++)if(!this.allowsMarkType(t[e].type))return!1;return!0}allowedMarks(t){if(null==this.markSet)return t;let e;for(let n=0;n<t.length;n++)this.allowsMarkType(t[n].type)?e&&e.push(t[n]):e||(e=t.slice(0,n));return e?e.length?e:p.none:t}static compile(t,e){let n=Object.create(null);t.forEach(((t,o)=>n[t]=new U(t,e,o)));let o=e.spec.topNode||"doc";if(!n[o])throw new RangeError("Schema is missing its top node type ('"+o+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(let t in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n}}class G{constructor(t,e,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate="string"==typeof n.validate?function(t,e,n){let o=n.split("|");return n=>{let r=null===n?"null":typeof n;if(o.indexOf(r)<0)throw new RangeError(`Expected value of type ${o} for attribute ${e} on type ${t}, got ${r}`)}}(t,e,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class Y{constructor(t,e,n,o){this.name=t,this.rank=e,this.schema=n,this.spec=o,this.attrs=J(t,o.attrs),this.excluded=null;let r=W(this.attrs);this.instance=r?new p(this,r):null}create(t=null){return!t&&this.instance?this.instance:new p(this,q(this.attrs,t))}static compile(t,e){let n=Object.create(null),o=0;return t.forEach(((t,r)=>n[t]=new Y(t,o++,e,r))),n}removeFromSet(t){for(var e=0;e<t.length;e++)t[e].type==this&&(t=t.slice(0,e).concat(t.slice(e+1)),e--);return t}isInSet(t){for(let e=0;e<t.length;e++)if(t[e].type==this)return t[e]}checkAttrs(t){K(this.attrs,t,"mark",this.name)}excludes(t){return this.excluded.indexOf(t)>-1}}class X{constructor(t){this.linebreakReplacement=null,this.cached=Object.create(null);let e=this.spec={};for(let n in t)e[n]=t[n];e.nodes=i.from(t.nodes),e.marks=i.from(t.marks||{}),this.nodes=U.compile(this.spec.nodes,this),this.marks=Y.compile(this.spec.marks,this);let n=Object.create(null);for(let t in this.nodes){if(t in this.marks)throw new RangeError(t+" can not be both a node and a mark");let e=this.nodes[t],o=e.spec.content||"",r=e.spec.marks;if(e.contentMatch=n[o]||(n[o]=I.parse(o,this.nodes)),e.inlineContent=e.contentMatch.inlineContent,e.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!e.isInline||!e.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=e}e.markSet="_"==r?null:r?Q(this,r.split(" ")):""!=r&&e.inlineContent?null:[]}for(let t in this.marks){let e=this.marks[t],n=e.spec.excludes;e.excluded=null==n?[e]:""==n?[]:Q(this,n.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(t,e=null,n,o){if("string"==typeof t)t=this.nodeType(t);else{if(!(t instanceof U))throw new RangeError("Invalid node type: "+t);if(t.schema!=this)throw new RangeError("Node type from different schema used ("+t.name+")")}return t.createChecked(e,n,o)}text(t,e){let n=this.nodes.text;return new j(n,n.defaultAttrs,t,p.setFrom(e))}mark(t,e){return"string"==typeof t&&(t=this.marks[t]),t.create(e)}nodeFromJSON(t){return R.fromJSON(this,t)}markFromJSON(t){return p.fromJSON(this,t)}nodeType(t){let e=this.nodes[t];if(!e)throw new RangeError("Unknown node type: "+t);return e}}function Q(t,e){let n=[];for(let o=0;o<e.length;o++){let r=e[o],i=t.marks[r],s=i;if(i)n.push(i);else for(let e in t.marks){let o=t.marks[e];("_"==r||o.spec.group&&o.spec.group.split(" ").indexOf(r)>-1)&&n.push(s=o)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[o]+"'")}return n}class Z{constructor(t,e){this.schema=t,this.rules=e,this.tags=[],this.styles=[];let n=this.matchedStyles=[];e.forEach((t=>{if(function(t){return null!=t.tag}(t))this.tags.push(t);else if(function(t){return null!=t.style}(t)){let e=/[^=]*/.exec(t.style)[0];n.indexOf(e)<0&&n.push(e),this.styles.push(t)}})),this.normalizeLists=!this.tags.some((e=>{if(!/^(ul|ol)\b/.test(e.tag)||!e.node)return!1;let n=t.nodes[e.node];return n.contentMatch.matchType(n)}))}parse(t,e={}){let n=new it(this,e,!1);return n.addAll(t,p.none,e.from,e.to),n.finish()}parseSlice(t,e={}){let n=new it(this,e,!0);return n.addAll(t,p.none,e.from,e.to),f.maxOpen(n.finish())}matchTag(t,e,n){for(let o=n?this.tags.indexOf(n)+1:0;o<this.tags.length;o++){let n=this.tags[o];if(st(t,n.tag)&&(void 0===n.namespace||t.namespaceURI==n.namespace)&&(!n.context||e.matchesContext(n.context))){if(n.getAttrs){let e=n.getAttrs(t);if(!1===e)continue;n.attrs=e||void 0}return n}}}matchStyle(t,e,n,o){for(let r=o?this.styles.indexOf(o)+1:0;r<this.styles.length;r++){let o=this.styles[r],i=o.style;if(!(0!=i.indexOf(t)||o.context&&!n.matchesContext(o.context)||i.length>t.length&&(61!=i.charCodeAt(t.length)||i.slice(t.length+1)!=e))){if(o.getAttrs){let t=o.getAttrs(e);if(!1===t)continue;o.attrs=t||void 0}return o}}}static schemaRules(t){let e=[];function n(t){let n=null==t.priority?50:t.priority,o=0;for(;o<e.length;o++){let t=e[o];if((null==t.priority?50:t.priority)<n)break}e.splice(o,0,t)}for(let e in t.marks){let o=t.marks[e].spec.parseDOM;o&&o.forEach((t=>{n(t=lt(t)),t.mark||t.ignore||t.clearMark||(t.mark=e)}))}for(let e in t.nodes){let o=t.nodes[e].spec.parseDOM;o&&o.forEach((t=>{n(t=lt(t)),t.node||t.ignore||t.mark||(t.node=e)}))}return e}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new Z(t,Z.schemaRules(t)))}}const tt={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},et={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},nt={ol:!0,ul:!0};function ot(t,e,n){return null!=e?(e?1:0)|("full"===e?2:0):t&&"pre"==t.whitespace?3:-5&n}class rt{constructor(t,e,n,o,r,i){this.type=t,this.attrs=e,this.marks=n,this.solid=o,this.options=i,this.content=[],this.activeMarks=p.none,this.match=r||(4&i?null:t.contentMatch)}findWrapping(t){if(!this.match){if(!this.type)return[];let e=this.type.contentMatch.fillBefore(a.from(t));if(!e){let e,n=this.type.contentMatch;return(e=n.findWrapping(t.type))?(this.match=n,e):null}this.match=this.type.contentMatch.matchFragment(e)}return this.match.findWrapping(t.type)}finish(t){if(!(1&this.options)){let t,e=this.content[this.content.length-1];if(e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))){let n=e;e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-t[0].length))}}let e=a.from(this.content);return!t&&this.match&&(e=e.append(this.match.fillBefore(a.empty,!0))),this.type?this.type.create(this.attrs,e,this.marks):e}inlineContext(t){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:t.parentNode&&!tt.hasOwnProperty(t.parentNode.nodeName.toLowerCase())}}class it{constructor(t,e,n){this.parser=t,this.options=e,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let o,r=e.topNode,i=ot(null,e.preserveWhitespace,0)|(n?4:0);o=r?new rt(r.type,r.attrs,p.none,!0,e.topMatch||r.type.contentMatch,i):new rt(n?null:t.schema.topNodeType,null,p.none,!0,null,i),this.nodes=[o],this.find=e.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(t,e){3==t.nodeType?this.addTextNode(t,e):1==t.nodeType&&this.addElement(t,e)}addTextNode(t,e){let n=t.nodeValue,o=this.top,r=2&o.options?"full":this.localPreserveWS||(1&o.options)>0;if("full"===r||o.inlineContext(t)||/[^ \t\r\n\u000c]/.test(n)){if(r)n="full"!==r?n.replace(/\r?\n|\r/g," "):n.replace(/\r\n?/g,"\n");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let e=o.content[o.content.length-1],r=t.previousSibling;(!e||r&&"BR"==r.nodeName||e.isText&&/[ \t\r\n\u000c]$/.test(e.text))&&(n=n.slice(1))}n&&this.insertNode(this.parser.schema.text(n),e),this.findInText(t)}else this.findInside(t)}addElement(t,e,n){let o=this.localPreserveWS,r=this.top;("PRE"==t.tagName||/pre/.test(t.style&&t.style.whiteSpace))&&(this.localPreserveWS=!0);let i,s=t.nodeName.toLowerCase();nt.hasOwnProperty(s)&&this.parser.normalizeLists&&function(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let t=1==e.nodeType?e.nodeName.toLowerCase():null;t&&nt.hasOwnProperty(t)&&n?(n.appendChild(e),e=n):"li"==t?n=e:t&&(n=null)}}(t);let l=this.options.ruleFromNode&&this.options.ruleFromNode(t)||(i=this.parser.matchTag(t,this,n));t:if(l?l.ignore:et.hasOwnProperty(s))this.findInside(t),this.ignoreFallback(t,e);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(t=l.skip);let n,o=this.needsBlock;if(tt.hasOwnProperty(s))r.content.length&&r.content[0].isInline&&this.open&&(this.open--,r=this.top),n=!0,r.type||(this.needsBlock=!0);else if(!t.firstChild){this.leafFallback(t,e);break t}let i=l&&l.skip?e:this.readStyles(t,e);i&&this.addAll(t,i),n&&this.sync(r),this.needsBlock=o}else{let n=this.readStyles(t,e);n&&this.addElementByRule(t,l,n,!1===l.consuming?i:void 0)}this.localPreserveWS=o}leafFallback(t,e){"BR"==t.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(t.ownerDocument.createTextNode("\n"),e)}ignoreFallback(t,e){"BR"!=t.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"),e)}readStyles(t,e){let n=t.style;if(n&&n.length)for(let t=0;t<this.parser.matchedStyles.length;t++){let o=this.parser.matchedStyles[t],r=n.getPropertyValue(o);if(r)for(let t;;){let n=this.parser.matchStyle(o,r,this,t);if(!n)break;if(n.ignore)return null;if(e=n.clearMark?e.filter((t=>!n.clearMark(t))):e.concat(this.parser.schema.marks[n.mark].create(n.attrs)),!1!==n.consuming)break;t=n}}return e}addElementByRule(t,e,n,o){let r,i;if(e.node)if(i=this.parser.schema.nodes[e.node],i.isLeaf)this.insertNode(i.create(e.attrs),n)||this.leafFallback(t,n);else{let t=this.enter(i,e.attrs||null,n,e.preserveWhitespace);t&&(r=!0,n=t)}else{let t=this.parser.schema.marks[e.mark];n=n.concat(t.create(e.attrs))}let s=this.top;if(i&&i.isLeaf)this.findInside(t);else if(o)this.addElement(t,n,o);else if(e.getContent)this.findInside(t),e.getContent(t,this.parser.schema).forEach((t=>this.insertNode(t,n)));else{let o=t;"string"==typeof e.contentElement?o=t.querySelector(e.contentElement):"function"==typeof e.contentElement?o=e.contentElement(t):e.contentElement&&(o=e.contentElement),this.findAround(t,o,!0),this.addAll(o,n),this.findAround(t,o,!1)}r&&this.sync(s)&&this.open--}addAll(t,e,n,o){let r=n||0;for(let i=n?t.childNodes[n]:t.firstChild,s=null==o?null:t.childNodes[o];i!=s;i=i.nextSibling,++r)this.findAtPoint(t,r),this.addDOM(i,e);this.findAtPoint(t,r)}findPlace(t,e){let n,o;for(let e=this.open;e>=0;e--){let r=this.nodes[e],i=r.findWrapping(t);if(i&&(!n||n.length>i.length)&&(n=i,o=r,!i.length))break;if(r.solid)break}if(!n)return null;this.sync(o);for(let t=0;t<n.length;t++)e=this.enterInner(n[t],null,e,!1);return e}insertNode(t,e){if(t.isInline&&this.needsBlock&&!this.top.type){let t=this.textblockFromContext();t&&(e=this.enterInner(t,null,e))}let n=this.findPlace(t,e);if(n){this.closeExtra();let e=this.top;e.match&&(e.match=e.match.matchType(t.type));let o=p.none;for(let r of n.concat(t.marks))(e.type?e.type.allowsMarkType(r.type):at(r.type,t.type))&&(o=r.addToSet(o));return e.content.push(t.mark(o)),!0}return!1}enter(t,e,n,o){let r=this.findPlace(t.create(e),n);return r&&(r=this.enterInner(t,e,n,!0,o)),r}enterInner(t,e,n,o=!1,r){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(t);let s=ot(t,r,i.options);4&i.options&&0==i.content.length&&(s|=4);let l=p.none;return n=n.filter((e=>!(i.type?i.type.allowsMarkType(e.type):at(e.type,t))||(l=e.addToSet(l),!1))),this.nodes.push(new rt(t,e,l,o,null,s)),this.open++,n}closeExtra(t=!1){let e=this.nodes.length-1;if(e>this.open){for(;e>this.open;e--)this.nodes[e-1].content.push(this.nodes[e].finish(t));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!(!this.isOpen&&!this.options.topOpen))}sync(t){for(let e=this.open;e>=0;e--){if(this.nodes[e]==t)return this.open=e,!0;this.localPreserveWS&&(this.nodes[e].options|=1)}return!1}get currentPos(){this.closeExtra();let t=0;for(let e=this.open;e>=0;e--){let n=this.nodes[e].content;for(let e=n.length-1;e>=0;e--)t+=n[e].nodeSize;e&&t++}return t}findAtPoint(t,e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==t&&this.find[n].offset==e&&(this.find[n].pos=this.currentPos)}findInside(t){if(this.find)for(let e=0;e<this.find.length;e++)null==this.find[e].pos&&1==t.nodeType&&t.contains(this.find[e].node)&&(this.find[e].pos=this.currentPos)}findAround(t,e,n){if(t!=e&&this.find)for(let o=0;o<this.find.length;o++)null==this.find[o].pos&&1==t.nodeType&&t.contains(this.find[o].node)&&e.compareDocumentPosition(this.find[o].node)&(n?2:4)&&(this.find[o].pos=this.currentPos)}findInText(t){if(this.find)for(let e=0;e<this.find.length;e++)this.find[e].node==t&&(this.find[e].pos=this.currentPos-(t.nodeValue.length-this.find[e].offset))}matchesContext(t){if(t.indexOf("|")>-1)return t.split(/\s*\|\s*/).some(this.matchesContext,this);let e=t.split("/"),n=this.options.context,o=!(this.isOpen||n&&n.parent.type!=this.nodes[0].type),r=-(n?n.depth+1:0)+(o?0:1),i=(t,s)=>{for(;t>=0;t--){let l=e[t];if(""==l){if(t==e.length-1||0==t)continue;for(;s>=r;s--)if(i(t-1,s))return!0;return!1}{let t=s>0||0==s&&o?this.nodes[s].type:n&&s>=r?n.node(s-r).type:null;if(!t||t.name!=l&&!t.isInGroup(l))return!1;s--}}return!0};return i(e.length-1,this.open)}textblockFromContext(){let t=this.options.context;if(t)for(let e=t.depth;e>=0;e--){let n=t.node(e).contentMatchAt(t.indexAfter(e)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let t in this.parser.schema.nodes){let e=this.parser.schema.nodes[t];if(e.isTextblock&&e.defaultAttrs)return e}}}function st(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function lt(t){let e={};for(let n in t)e[n]=t[n];return e}function at(t,e){let n=e.schema.nodes;for(let o in n){let r=n[o];if(!r.allowsMarkType(t))continue;let i=[],s=t=>{i.push(t);for(let n=0;n<t.edgeCount;n++){let{type:o,next:r}=t.edge(n);if(o==e)return!0;if(i.indexOf(r)<0&&s(r))return!0}};if(s(r.contentMatch))return!0}}class ct{constructor(t,e){this.nodes=t,this.marks=e}serializeFragment(t,e={},n){n||(n=ht(e).createDocumentFragment());let o=n,r=[];return t.forEach((t=>{if(r.length||t.marks.length){let n=0,i=0;for(;n<r.length&&i<t.marks.length;){let e=t.marks[i];if(this.marks[e.type.name]){if(!e.eq(r[n][0])||!1===e.type.spec.spanning)break;n++,i++}else i++}for(;n<r.length;)o=r.pop()[1];for(;i<t.marks.length;){let n=t.marks[i++],s=this.serializeMark(n,t.isInline,e);s&&(r.push([n,o]),o.appendChild(s.dom),o=s.contentDOM||s.dom)}}o.appendChild(this.serializeNodeInner(t,e))})),n}serializeNodeInner(t,e){let{dom:n,contentDOM:o}=ut(ht(e),this.nodes[t.type.name](t),null,t.attrs);if(o){if(t.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(t.content,e,o)}return n}serializeNode(t,e={}){let n=this.serializeNodeInner(t,e);for(let o=t.marks.length-1;o>=0;o--){let r=this.serializeMark(t.marks[o],t.isInline,e);r&&((r.contentDOM||r.dom).appendChild(n),n=r.dom)}return n}serializeMark(t,e,n={}){let o=this.marks[t.type.name];return o&&ut(ht(n),o(t,e),null,t.attrs)}static renderSpec(t,e,n=null,o){return ut(t,e,n,o)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new ct(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(t){let e=dt(t.nodes);return e.text||(e.text=t=>t.text),e}static marksFromSchema(t){return dt(t.marks)}}function dt(t){let e={};for(let n in t){let o=t[n].spec.toDOM;o&&(e[n]=o)}return e}function ht(t){return t.document||window.document}const pt=new WeakMap;function ut(t,e,n,o){if("string"==typeof e)return{dom:t.createTextNode(e)};if(null!=e.nodeType)return{dom:e};if(e.dom&&null!=e.dom.nodeType)return e;let r,i=e[0];if("string"!=typeof i)throw new RangeError("Invalid array passed to renderSpec");if(o&&(r=function(t){let e=pt.get(t);return void 0===e&&pt.set(t,e=function(t){let e=null;return function t(n){if(n&&"object"==typeof n)if(Array.isArray(n))if("string"==typeof n[0])e||(e=[]),e.push(n);else for(let e=0;e<n.length;e++)t(n[e]);else for(let e in n)t(n[e])}(t),e}(t)),e}(o))&&r.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let s,l=i.indexOf(" ");l>0&&(n=i.slice(0,l),i=i.slice(l+1));let a=n?t.createElementNS(n,i):t.createElement(i),c=e[1],d=1;if(c&&"object"==typeof c&&null==c.nodeType&&!Array.isArray(c)){d=2;for(let t in c)if(null!=c[t]){let e=t.indexOf(" ");e>0?a.setAttributeNS(t.slice(0,e),t.slice(e+1),c[t]):a.setAttribute(t,c[t])}}for(let r=d;r<e.length;r++){let i=e[r];if(0===i){if(r<e.length-1||r>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}{let{dom:e,contentDOM:r}=ut(t,i,n,o);if(a.appendChild(e),r){if(s)throw new RangeError("Multiple content holes");s=r}}}return{dom:a,contentDOM:s}}const ft=Math.pow(2,16);function mt(t){return 65535&t}class gt{constructor(t,e,n){this.pos=t,this.delInfo=e,this.recover=n}get deleted(){return(8&this.delInfo)>0}get deletedBefore(){return(5&this.delInfo)>0}get deletedAfter(){return(6&this.delInfo)>0}get deletedAcross(){return(4&this.delInfo)>0}}class yt{constructor(t,e=!1){if(this.ranges=t,this.inverted=e,!t.length&&yt.empty)return yt.empty}recover(t){let e=0,n=mt(t);if(!this.inverted)for(let t=0;t<n;t++)e+=this.ranges[3*t+2]-this.ranges[3*t+1];return this.ranges[3*n]+e+function(t){return(t-(65535&t))/ft}(t)}mapResult(t,e=1){return this._map(t,e,!1)}map(t,e=1){return this._map(t,e,!0)}_map(t,e,n){let o=0,r=this.inverted?2:1,i=this.inverted?1:2;for(let s=0;s<this.ranges.length;s+=3){let l=this.ranges[s]-(this.inverted?o:0);if(l>t)break;let a=this.ranges[s+r],c=this.ranges[s+i],d=l+a;if(t<=d){let r=l+o+((a?t==l?-1:t==d?1:e:e)<0?0:c);if(n)return r;let i=t==(e<0?l:d)?null:s/3+(t-l)*ft,h=t==l?2:t==d?1:4;return(e<0?t!=l:t!=d)&&(h|=8),new gt(r,h,i)}o+=c-a}return n?t+o:new gt(t+o,0,null)}touches(t,e){let n=0,o=mt(e),r=this.inverted?2:1,i=this.inverted?1:2;for(let e=0;e<this.ranges.length;e+=3){let s=this.ranges[e]-(this.inverted?n:0);if(s>t)break;let l=this.ranges[e+r];if(t<=s+l&&e==3*o)return!0;n+=this.ranges[e+i]-l}return!1}forEach(t){let e=this.inverted?2:1,n=this.inverted?1:2;for(let o=0,r=0;o<this.ranges.length;o+=3){let i=this.ranges[o],s=i-(this.inverted?r:0),l=i+(this.inverted?0:r),a=this.ranges[o+e],c=this.ranges[o+n];t(s,s+a,l,l+c),r+=c-a}}invert(){return new yt(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(t){return 0==t?yt.empty:new yt(t<0?[0,-t,0]:[0,0,t])}}yt.empty=new yt([]);class bt{constructor(t,e,n=0,o=(t?t.length:0)){this.mirror=e,this.from=n,this.to=o,this._maps=t||[],this.ownData=!(t||e)}get maps(){return this._maps}slice(t=0,e=this.maps.length){return new bt(this._maps,this.mirror,t,e)}appendMap(t,e){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(t),null!=e&&this.setMirror(this._maps.length-1,e)}appendMapping(t){for(let e=0,n=this._maps.length;e<t._maps.length;e++){let o=t.getMirror(e);this.appendMap(t._maps[e],null!=o&&o<e?n+o:void 0)}}getMirror(t){if(this.mirror)for(let e=0;e<this.mirror.length;e++)if(this.mirror[e]==t)return this.mirror[e+(e%2?-1:1)]}setMirror(t,e){this.mirror||(this.mirror=[]),this.mirror.push(t,e)}appendMappingInverted(t){for(let e=t.maps.length-1,n=this._maps.length+t._maps.length;e>=0;e--){let o=t.getMirror(e);this.appendMap(t._maps[e].invert(),null!=o&&o>e?n-o-1:void 0)}}invert(){let t=new bt;return t.appendMappingInverted(this),t}map(t,e=1){if(this.mirror)return this._map(t,e,!0);for(let n=this.from;n<this.to;n++)t=this._maps[n].map(t,e);return t}mapResult(t,e=1){return this._map(t,e,!1)}_map(t,e,n){let o=0;for(let n=this.from;n<this.to;n++){let r=this._maps[n].mapResult(t,e);if(null!=r.recover){let e=this.getMirror(n);if(null!=e&&e>n&&e<this.to){n=e,t=this._maps[e].recover(r.recover);continue}}o|=r.delInfo,t=r.pos}return n?t:new gt(t,o,null)}}const vt=Object.create(null);class wt{getMap(){return yt.empty}merge(t){return null}static fromJSON(t,e){if(!e||!e.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=vt[e.stepType];if(!n)throw new RangeError(`No step type ${e.stepType} defined`);return n.fromJSON(t,e)}static jsonID(t,e){if(t in vt)throw new RangeError("Duplicate use of step JSON ID "+t);return vt[t]=e,e.prototype.jsonID=t,e}}class kt{constructor(t,e){this.doc=t,this.failed=e}static ok(t){return new kt(t,null)}static fail(t){return new kt(null,t)}static fromReplace(t,e,n,o){try{return kt.ok(t.replace(e,n,o))}catch(t){if(t instanceof u)return kt.fail(t.message);throw t}}}function xt(t,e,n){let o=[];for(let r=0;r<t.childCount;r++){let i=t.child(r);i.content.size&&(i=i.copy(xt(i.content,e,i))),i.isInline&&(i=e(i,n,r)),o.push(i)}return a.fromArray(o)}class Mt extends wt{constructor(t,e,n){super(),this.from=t,this.to=e,this.mark=n}apply(t){let e=t.slice(this.from,this.to),n=t.resolve(this.from),o=n.node(n.sharedDepth(this.to)),r=new f(xt(e.content,((t,e)=>t.isAtom&&e.type.allowsMarkType(this.mark.type)?t.mark(this.mark.addToSet(t.marks)):t),o),e.openStart,e.openEnd);return kt.fromReplace(t,this.from,this.to,r)}invert(){return new Ct(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),n=t.mapResult(this.to,-1);return e.deleted&&n.deleted||e.pos>=n.pos?null:new Mt(e.pos,n.pos,this.mark)}merge(t){return t instanceof Mt&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new Mt(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,e){if("number"!=typeof e.from||"number"!=typeof e.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Mt(e.from,e.to,t.markFromJSON(e.mark))}}wt.jsonID("addMark",Mt);class Ct extends wt{constructor(t,e,n){super(),this.from=t,this.to=e,this.mark=n}apply(t){let e=t.slice(this.from,this.to),n=new f(xt(e.content,(t=>t.mark(this.mark.removeFromSet(t.marks))),t),e.openStart,e.openEnd);return kt.fromReplace(t,this.from,this.to,n)}invert(){return new Mt(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),n=t.mapResult(this.to,-1);return e.deleted&&n.deleted||e.pos>=n.pos?null:new Ct(e.pos,n.pos,this.mark)}merge(t){return t instanceof Ct&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new Ct(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,e){if("number"!=typeof e.from||"number"!=typeof e.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Ct(e.from,e.to,t.markFromJSON(e.mark))}}wt.jsonID("removeMark",Ct);class St extends wt{constructor(t,e){super(),this.pos=t,this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return kt.fail("No node at mark step's position");let n=e.type.create(e.attrs,null,this.mark.addToSet(e.marks));return kt.fromReplace(t,this.pos,this.pos+1,new f(a.from(n),0,e.isLeaf?0:1))}invert(t){let e=t.nodeAt(this.pos);if(e){let t=this.mark.addToSet(e.marks);if(t.length==e.marks.length){for(let n=0;n<e.marks.length;n++)if(!e.marks[n].isInSet(t))return new St(this.pos,e.marks[n]);return new St(this.pos,this.mark)}}return new Tt(this.pos,this.mark)}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new St(e.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,e){if("number"!=typeof e.pos)throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new St(e.pos,t.markFromJSON(e.mark))}}wt.jsonID("addNodeMark",St);class Tt extends wt{constructor(t,e){super(),this.pos=t,this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return kt.fail("No node at mark step's position");let n=e.type.create(e.attrs,null,this.mark.removeFromSet(e.marks));return kt.fromReplace(t,this.pos,this.pos+1,new f(a.from(n),0,e.isLeaf?0:1))}invert(t){let e=t.nodeAt(this.pos);return e&&this.mark.isInSet(e.marks)?new St(this.pos,this.mark):this}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new Tt(e.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,e){if("number"!=typeof e.pos)throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Tt(e.pos,t.markFromJSON(e.mark))}}wt.jsonID("removeNodeMark",Tt);class At extends wt{constructor(t,e,n,o=!1){super(),this.from=t,this.to=e,this.slice=n,this.structure=o}apply(t){return this.structure&&Et(t,this.from,this.to)?kt.fail("Structure replace would overwrite content"):kt.fromReplace(t,this.from,this.to,this.slice)}getMap(){return new yt([this.from,this.to-this.from,this.slice.size])}invert(t){return new At(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let e=t.mapResult(this.from,1),n=t.mapResult(this.to,-1);return e.deletedAcross&&n.deletedAcross?null:new At(e.pos,Math.max(e.pos,n.pos),this.slice)}merge(t){if(!(t instanceof At)||t.structure||this.structure)return null;if(this.from+this.slice.size!=t.from||this.slice.openEnd||t.slice.openStart){if(t.to!=this.from||this.slice.openStart||t.slice.openEnd)return null;{let e=this.slice.size+t.slice.size==0?f.empty:new f(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new At(t.from,this.to,e,this.structure)}}{let e=this.slice.size+t.slice.size==0?f.empty:new f(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new At(this.from,this.to+(t.to-t.from),e,this.structure)}}toJSON(){let t={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,e){if("number"!=typeof e.from||"number"!=typeof e.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new At(e.from,e.to,f.fromJSON(t,e.slice),!!e.structure)}}wt.jsonID("replace",At);class Ot extends wt{constructor(t,e,n,o,r,i,s=!1){super(),this.from=t,this.to=e,this.gapFrom=n,this.gapTo=o,this.slice=r,this.insert=i,this.structure=s}apply(t){if(this.structure&&(Et(t,this.from,this.gapFrom)||Et(t,this.gapTo,this.to)))return kt.fail("Structure gap-replace would overwrite content");let e=t.slice(this.gapFrom,this.gapTo);if(e.openStart||e.openEnd)return kt.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,e.content);return n?kt.fromReplace(t,this.from,this.to,n):kt.fail("Content does not fit in gap")}getMap(){return new yt([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let e=this.gapTo-this.gapFrom;return new Ot(this.from,this.from+this.slice.size+e,this.from+this.insert,this.from+this.insert+e,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let e=t.mapResult(this.from,1),n=t.mapResult(this.to,-1),o=this.from==this.gapFrom?e.pos:t.map(this.gapFrom,-1),r=this.to==this.gapTo?n.pos:t.map(this.gapTo,1);return e.deletedAcross&&n.deletedAcross||o<e.pos||r>n.pos?null:new Ot(e.pos,n.pos,o,r,this.slice,this.insert,this.structure)}toJSON(){let t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,e){if("number"!=typeof e.from||"number"!=typeof e.to||"number"!=typeof e.gapFrom||"number"!=typeof e.gapTo||"number"!=typeof e.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Ot(e.from,e.to,e.gapFrom,e.gapTo,f.fromJSON(t,e.slice),e.insert,!!e.structure)}}function Et(t,e,n){let o=t.resolve(e),r=n-e,i=o.depth;for(;r>0&&i>0&&o.indexAfter(i)==o.node(i).childCount;)i--,r--;if(r>0){let t=o.node(i).maybeChild(o.indexAfter(i));for(;r>0;){if(!t||t.isLeaf)return!0;t=t.firstChild,r--}}return!1}function Nt(t,e,n,o=n.contentMatch,r=!0){let i=t.doc.nodeAt(e),s=[],l=e+1;for(let e=0;e<i.childCount;e++){let c=i.child(e),d=l+c.nodeSize,h=o.matchType(c.type);if(h){o=h;for(let e=0;e<c.marks.length;e++)n.allowsMarkType(c.marks[e].type)||t.step(new Ct(l,d,c.marks[e]));if(r&&c.isText&&"pre"!=n.whitespace){let t,e,o=/\r?\n|\r/g;for(;t=o.exec(c.text);)e||(e=new f(a.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),s.push(new At(l+t.index,l+t.index+t[0].length,e))}}else s.push(new At(l,d,f.empty));l=d}if(!o.validEnd){let e=o.fillBefore(a.empty,!0);t.replace(l,l,new f(e,0,0))}for(let e=s.length-1;e>=0;e--)t.step(s[e])}function Dt(t,e,n){return(0==e||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Rt(t){let e=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let n=t.depth;;--n){let o=t.$from.node(n),r=t.$from.index(n),i=t.$to.indexAfter(n);if(n<t.depth&&o.canReplace(r,i,e))return n;if(0==n||o.type.spec.isolating||!Dt(o,r,i))break}return null}function jt(t,e,n=null,o=t){let r=function(t,e){let{parent:n,startIndex:o,endIndex:r}=t,i=n.contentMatchAt(o).findWrapping(e);if(!i)return null;let s=i.length?i[0]:e;return n.canReplaceWith(o,r,s)?i:null}(t,e),i=r&&function(t,e){let{parent:n,startIndex:o,endIndex:r}=t,i=n.child(o),s=e.contentMatch.findWrapping(i.type);if(!s)return null;let l=(s.length?s[s.length-1]:e).contentMatch;for(let t=o;l&&t<r;t++)l=l.matchType(n.child(t).type);return l&&l.validEnd?s:null}(o,e);return i?r.map(Lt).concat({type:e,attrs:n}).concat(i.map(Lt)):null}function Lt(t){return{type:t,attrs:null}}function It(t,e,n,o){e.forEach(((r,i)=>{if(r.isText){let s,l=/\r?\n|\r/g;for(;s=l.exec(r.text);){let r=t.mapping.slice(o).map(n+1+i+s.index);t.replaceWith(r,r+1,e.type.schema.linebreakReplacement.create())}}}))}function Pt(t,e,n,o){e.forEach(((r,i)=>{if(r.type==r.type.schema.linebreakReplacement){let r=t.mapping.slice(o).map(n+1+i);t.replaceWith(r,r+1,e.type.schema.text("\n"))}}))}function zt(t,e,n=1,o){let r=t.resolve(e),i=r.depth-n,s=o&&o[o.length-1]||r.parent;if(i<0||r.parent.type.spec.isolating||!r.parent.canReplace(r.index(),r.parent.childCount)||!s.type.validContent(r.parent.content.cutByIndex(r.index(),r.parent.childCount)))return!1;for(let t=r.depth-1,e=n-2;t>i;t--,e--){let n=r.node(t),i=r.index(t);if(n.type.spec.isolating)return!1;let s=n.content.cutByIndex(i,n.childCount),l=o&&o[e+1];l&&(s=s.replaceChild(0,l.type.create(l.attrs)));let a=o&&o[e]||n;if(!n.canReplace(i+1,n.childCount)||!a.type.validContent(s))return!1}let l=r.indexAfter(i),a=o&&o[0];return r.node(i).canReplaceWith(l,l,a?a.type:r.node(i+1).type)}function $t(t,e){let n=t.resolve(e),o=n.index();return Ht(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(o,o+1)}function Ht(t,e){return!(!t||!e||t.isLeaf||!function(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:o}=t.type.schema;for(let r=0;r<e.childCount;r++){let i=e.child(r),s=i.type==o?t.type.schema.nodes.text:i.type;if(n=n.matchType(s),!n)return!1;if(!t.type.allowsMarks(i.marks))return!1}return n.validEnd}(t,e))}function Bt(t,e,n=-1){let o=t.resolve(e);for(let t=o.depth;;t--){let r,i,s=o.index(t);if(t==o.depth?(r=o.nodeBefore,i=o.nodeAfter):n>0?(r=o.node(t+1),s++,i=o.node(t).maybeChild(s)):(r=o.node(t).maybeChild(s-1),i=o.node(t+1)),r&&!r.isTextblock&&Ht(r,i)&&o.node(t).canReplace(s,s+1))return e;if(0==t)break;e=n<0?o.before(t):o.after(t)}}function _t(t,e,n){let o=t.resolve(e);if(!n.content.size)return e;let r=n.content;for(let t=0;t<n.openStart;t++)r=r.firstChild.content;for(let t=1;t<=(0==n.openStart&&n.size?2:1);t++)for(let e=o.depth;e>=0;e--){let n=e==o.depth?0:o.pos<=(o.start(e+1)+o.end(e+1))/2?-1:1,i=o.index(e)+(n>0?1:0),s=o.node(e),l=!1;if(1==t)l=s.canReplace(i,i,r);else{let t=s.contentMatchAt(i).findWrapping(r.firstChild.type);l=t&&s.canReplaceWith(i,i,t[0])}if(l)return 0==n?o.pos:n<0?o.before(e+1):o.after(e+1)}return null}function Ft(t,e,n=e,o=f.empty){if(e==n&&!o.size)return null;let r=t.resolve(e),i=t.resolve(n);return Vt(r,i,o)?new At(e,n,o):new Wt(r,i,o).fit()}function Vt(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}wt.jsonID("replaceAround",Ot);class Wt{constructor(t,e,n){this.$from=t,this.$to=e,this.unplaced=n,this.frontier=[],this.placed=a.empty;for(let e=0;e<=t.depth;e++){let n=t.node(e);this.frontier.push({type:n.type,match:n.contentMatchAt(t.indexAfter(e))})}for(let e=t.depth;e>0;e--)this.placed=a.from(t.node(e).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let t=this.findFittable();t?this.placeNodes(t):this.openMore()||this.dropNode()}let t=this.mustMoveInline(),e=this.placed.size-this.depth-this.$from.depth,n=this.$from,o=this.close(t<0?this.$to:n.doc.resolve(t));if(!o)return null;let r=this.placed,i=n.depth,s=o.depth;for(;i&&s&&1==r.childCount;)r=r.firstChild.content,i--,s--;let l=new f(r,i,s);return t>-1?new Ot(n.pos,t,this.$to.pos,this.$to.end(),l,e):l.size||n.pos!=this.$to.pos?new At(n.pos,o.pos,l):null}findFittable(){let t=this.unplaced.openStart;for(let e=this.unplaced.content,n=0,o=this.unplaced.openEnd;n<t;n++){let r=e.firstChild;if(e.childCount>1&&(o=0),r.type.spec.isolating&&o<=n){t=n;break}e=r.content}for(let e=1;e<=2;e++)for(let n=1==e?t:this.unplaced.openStart;n>=0;n--){let t,o=null;n?(o=Jt(this.unplaced.content,n-1).firstChild,t=o.content):t=this.unplaced.content;let r=t.firstChild;for(let t=this.depth;t>=0;t--){let i,{type:s,match:l}=this.frontier[t],c=null;if(1==e&&(r?l.matchType(r.type)||(c=l.fillBefore(a.from(r),!1)):o&&s.compatibleContent(o.type)))return{sliceDepth:n,frontierDepth:t,parent:o,inject:c};if(2==e&&r&&(i=l.findWrapping(r.type)))return{sliceDepth:n,frontierDepth:t,parent:o,wrap:i};if(o&&l.matchType(o.type))break}}}openMore(){let{content:t,openStart:e,openEnd:n}=this.unplaced,o=Jt(t,e);return!(!o.childCount||o.firstChild.isLeaf||(this.unplaced=new f(t,e+1,Math.max(n,o.size+e>=t.size-n?e+1:0)),0))}dropNode(){let{content:t,openStart:e,openEnd:n}=this.unplaced,o=Jt(t,e);if(o.childCount<=1&&e>0){let r=t.size-e<=e+o.size;this.unplaced=new f(qt(t,e-1,1),e-1,r?e-1:n)}else this.unplaced=new f(qt(t,e,1),e,n)}placeNodes({sliceDepth:t,frontierDepth:e,parent:n,inject:o,wrap:r}){for(;this.depth>e;)this.closeFrontierNode();if(r)for(let t=0;t<r.length;t++)this.openFrontierNode(r[t]);let i=this.unplaced,s=n?n.content:i.content,l=i.openStart-t,c=0,d=[],{match:h,type:p}=this.frontier[e];if(o){for(let t=0;t<o.childCount;t++)d.push(o.child(t));h=h.matchFragment(o)}let u=s.size+t-(i.content.size-i.openEnd);for(;c<s.childCount;){let t=s.child(c),e=h.matchType(t.type);if(!e)break;c++,(c>1||0==l||t.content.size)&&(h=e,d.push(Ut(t.mark(p.allowedMarks(t.marks)),1==c?l:0,c==s.childCount?u:-1)))}let m=c==s.childCount;m||(u=-1),this.placed=Kt(this.placed,e,a.from(d)),this.frontier[e].match=h,m&&u<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let t=0,e=s;t<u;t++){let t=e.lastChild;this.frontier.push({type:t.type,match:t.contentMatchAt(t.childCount)}),e=t.content}this.unplaced=m?0==t?f.empty:new f(qt(i.content,t-1,1),t-1,u<0?i.openEnd:t-1):new f(qt(i.content,t,c),i.openStart,i.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let t,e=this.frontier[this.depth];if(!e.type.isTextblock||!Gt(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:n}=this.$to,o=this.$to.after(n);for(;n>1&&o==this.$to.end(--n);)++o;return o}findCloseLevel(t){t:for(let e=Math.min(this.depth,t.depth);e>=0;e--){let{match:n,type:o}=this.frontier[e],r=e<t.depth&&t.end(e+1)==t.pos+(t.depth-(e+1)),i=Gt(t,e,o,n,r);if(i){for(let n=e-1;n>=0;n--){let{match:e,type:o}=this.frontier[n],r=Gt(t,n,o,e,!0);if(!r||r.childCount)continue t}return{depth:e,fit:i,move:r?t.doc.resolve(t.after(e+1)):t}}}}close(t){let e=this.findCloseLevel(t);if(!e)return null;for(;this.depth>e.depth;)this.closeFrontierNode();e.fit.childCount&&(this.placed=Kt(this.placed,e.depth,e.fit)),t=e.move;for(let n=e.depth+1;n<=t.depth;n++){let e=t.node(n),o=e.type.contentMatch.fillBefore(e.content,!0,t.index(n));this.openFrontierNode(e.type,e.attrs,o)}return t}openFrontierNode(t,e=null,n){let o=this.frontier[this.depth];o.match=o.match.matchType(t),this.placed=Kt(this.placed,this.depth,a.from(t.create(e,n))),this.frontier.push({type:t,match:t.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(a.empty,!0);t.childCount&&(this.placed=Kt(this.placed,this.frontier.length,t))}}function qt(t,e,n){return 0==e?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(qt(t.firstChild.content,e-1,n)))}function Kt(t,e,n){return 0==e?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Kt(t.lastChild.content,e-1,n)))}function Jt(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function Ut(t,e,n){if(e<=0)return t;let o=t.content;return e>1&&(o=o.replaceChild(0,Ut(o.firstChild,e-1,1==o.childCount?n-1:0))),e>0&&(o=t.type.contentMatch.fillBefore(o).append(o),n<=0&&(o=o.append(t.type.contentMatch.matchFragment(o).fillBefore(a.empty,!0)))),t.copy(o)}function Gt(t,e,n,o,r){let i=t.node(e),s=r?t.indexAfter(e):t.index(e);if(s==i.childCount&&!n.compatibleContent(i.type))return null;let l=o.fillBefore(i.content,!0,s);return l&&!function(t,e,n){for(let o=n;o<e.childCount;o++)if(!t.allowsMarks(e.child(o).marks))return!0;return!1}(n,i.content,s)?l:null}function Yt(t,e,n,o,r){if(e<n){let r=t.firstChild;t=t.replaceChild(0,r.copy(Yt(r.content,e+1,n,o,r)))}if(e>o){let e=r.contentMatchAt(0),n=e.fillBefore(t).append(t);t=n.append(e.matchFragment(n).fillBefore(a.empty,!0))}return t}function Xt(t,e){let n=[];for(let o=Math.min(t.depth,e.depth);o>=0;o--){let r=t.start(o);if(r<t.pos-(t.depth-o)||e.end(o)>e.pos+(e.depth-o)||t.node(o).type.spec.isolating||e.node(o).type.spec.isolating)break;(r==e.start(o)||o==t.depth&&o==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&o&&e.start(o-1)==r-1)&&n.push(o)}return n}class Qt extends wt{constructor(t,e,n){super(),this.pos=t,this.attr=e,this.value=n}apply(t){let e=t.nodeAt(this.pos);if(!e)return kt.fail("No node at attribute step's position");let n=Object.create(null);for(let t in e.attrs)n[t]=e.attrs[t];n[this.attr]=this.value;let o=e.type.create(n,null,e.marks);return kt.fromReplace(t,this.pos,this.pos+1,new f(a.from(o),0,e.isLeaf?0:1))}getMap(){return yt.empty}invert(t){return new Qt(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new Qt(e.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,e){if("number"!=typeof e.pos||"string"!=typeof e.attr)throw new RangeError("Invalid input for AttrStep.fromJSON");return new Qt(e.pos,e.attr,e.value)}}wt.jsonID("attr",Qt);class Zt extends wt{constructor(t,e){super(),this.attr=t,this.value=e}apply(t){let e=Object.create(null);for(let n in t.attrs)e[n]=t.attrs[n];e[this.attr]=this.value;let n=t.type.create(e,t.content,t.marks);return kt.ok(n)}getMap(){return yt.empty}invert(t){return new Zt(this.attr,t.attrs[this.attr])}map(t){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(t,e){if("string"!=typeof e.attr)throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Zt(e.attr,e.value)}}wt.jsonID("docAttr",Zt);let te=class extends Error{};te=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n},(te.prototype=Object.create(Error.prototype)).constructor=te,te.prototype.name="TransformError";class ee{constructor(t){this.doc=t,this.steps=[],this.docs=[],this.mapping=new bt}get before(){return this.docs.length?this.docs[0]:this.doc}step(t){let e=this.maybeStep(t);if(e.failed)throw new te(e.failed);return this}maybeStep(t){let e=t.apply(this.doc);return e.failed||this.addStep(t,e.doc),e}get docChanged(){return this.steps.length>0}addStep(t,e){this.docs.push(this.doc),this.steps.push(t),this.mapping.appendMap(t.getMap()),this.doc=e}replace(t,e=t,n=f.empty){let o=Ft(this.doc,t,e,n);return o&&this.step(o),this}replaceWith(t,e,n){return this.replace(t,e,new f(a.from(n),0,0))}delete(t,e){return this.replace(t,e,f.empty)}insert(t,e){return this.replaceWith(t,t,e)}replaceRange(t,e,n){return function(t,e,n,o){if(!o.size)return t.deleteRange(e,n);let r=t.doc.resolve(e),i=t.doc.resolve(n);if(Vt(r,i,o))return t.step(new At(e,n,o));let s=Xt(r,t.doc.resolve(n));0==s[s.length-1]&&s.pop();let l=-(r.depth+1);s.unshift(l);for(let t=r.depth,e=r.pos-1;t>0;t--,e--){let n=r.node(t).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;s.indexOf(t)>-1?l=t:r.before(t)==e&&s.splice(1,0,-t)}let a=s.indexOf(l),c=[],d=o.openStart;for(let t=o.content,e=0;;e++){let n=t.firstChild;if(c.push(n),e==o.openStart)break;t=n.content}for(let t=d-1;t>=0;t--){let e=c[t],n=(h=e.type).spec.defining||h.spec.definingForContent;if(n&&!e.sameMarkup(r.node(Math.abs(l)-1)))d=t;else if(n||!e.type.isTextblock)break}var h;for(let e=o.openStart;e>=0;e--){let l=(e+d+1)%(o.openStart+1),h=c[l];if(h)for(let e=0;e<s.length;e++){let c=s[(e+a)%s.length],d=!0;c<0&&(d=!1,c=-c);let p=r.node(c-1),u=r.index(c-1);if(p.canReplaceWith(u,u,h.type,h.marks))return t.replace(r.before(c),d?i.after(c):n,new f(Yt(o.content,0,o.openStart,l),l,o.openEnd))}}let p=t.steps.length;for(let l=s.length-1;l>=0&&(t.replace(e,n,o),!(t.steps.length>p));l--){let t=s[l];t<0||(e=r.before(t),n=i.after(t))}}(this,t,e,n),this}replaceRangeWith(t,e,n){return function(t,e,n,o){if(!o.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let r=function(t,e,n){let o=t.resolve(e);if(o.parent.canReplaceWith(o.index(),o.index(),n))return e;if(0==o.parentOffset)for(let t=o.depth-1;t>=0;t--){let e=o.index(t);if(o.node(t).canReplaceWith(e,e,n))return o.before(t+1);if(e>0)return null}if(o.parentOffset==o.parent.content.size)for(let t=o.depth-1;t>=0;t--){let e=o.indexAfter(t);if(o.node(t).canReplaceWith(e,e,n))return o.after(t+1);if(e<o.node(t).childCount)return null}return null}(t.doc,e,o.type);null!=r&&(e=n=r)}t.replaceRange(e,n,new f(a.from(o),0,0))}(this,t,e,n),this}deleteRange(t,e){return function(t,e,n){let o=t.doc.resolve(e),r=t.doc.resolve(n),i=Xt(o,r);for(let e=0;e<i.length;e++){let n=i[e],s=e==i.length-1;if(s&&0==n||o.node(n).type.contentMatch.validEnd)return t.delete(o.start(n),r.end(n));if(n>0&&(s||o.node(n-1).canReplace(o.index(n-1),r.indexAfter(n-1))))return t.delete(o.before(n),r.after(n))}for(let i=1;i<=o.depth&&i<=r.depth;i++)if(e-o.start(i)==o.depth-i&&n>o.end(i)&&r.end(i)-n!=r.depth-i&&o.start(i-1)==r.start(i-1)&&o.node(i-1).canReplace(o.index(i-1),r.index(i-1)))return t.delete(o.before(i),n);t.delete(e,n)}(this,t,e),this}lift(t,e){return function(t,e,n){let{$from:o,$to:r,depth:i}=e,s=o.before(i+1),l=r.after(i+1),c=s,d=l,h=a.empty,p=0;for(let t=i,e=!1;t>n;t--)e||o.index(t)>0?(e=!0,h=a.from(o.node(t).copy(h)),p++):c--;let u=a.empty,m=0;for(let t=i,e=!1;t>n;t--)e||r.after(t+1)<r.end(t)?(e=!0,u=a.from(r.node(t).copy(u)),m++):d++;t.step(new Ot(c,d,s,l,new f(h.append(u),p,m),h.size-p,!0))}(this,t,e),this}join(t,e=1){return function(t,e,n){let o=null,{linebreakReplacement:r}=t.doc.type.schema,i=t.doc.resolve(e-n),s=i.node().type;if(r&&s.inlineContent){let t="pre"==s.whitespace,e=!!s.contentMatch.matchType(r);t&&!e?o=!1:!t&&e&&(o=!0)}let l=t.steps.length;if(!1===o){let o=t.doc.resolve(e+n);Pt(t,o.node(),o.before(),l)}s.inlineContent&&Nt(t,e+n-1,s,i.node().contentMatchAt(i.index()),null==o);let a=t.mapping.slice(l),c=a.map(e-n);if(t.step(new At(c,a.map(e+n,-1),f.empty,!0)),!0===o){let e=t.doc.resolve(c);It(t,e.node(),e.before(),t.steps.length)}}(this,t,e),this}wrap(t,e){return function(t,e,n){let o=a.empty;for(let t=n.length-1;t>=0;t--){if(o.size){let e=n[t].type.contentMatch.matchFragment(o);if(!e||!e.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}o=a.from(n[t].type.create(n[t].attrs,o))}let r=e.start,i=e.end;t.step(new Ot(r,i,r,i,new f(o,0,0),n.length,!0))}(this,t,e),this}setBlockType(t,e=t,n,o=null){return function(t,e,n,o,r){if(!o.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=t.steps.length;t.doc.nodesBetween(e,n,((e,n)=>{let s="function"==typeof r?r(e):r;if(e.isTextblock&&!e.hasMarkup(o,s)&&function(t,e,n){let o=t.resolve(e),r=o.index();return o.parent.canReplaceWith(r,r+1,n)}(t.doc,t.mapping.slice(i).map(n),o)){let r=null;if(o.schema.linebreakReplacement){let t="pre"==o.whitespace,e=!!o.contentMatch.matchType(o.schema.linebreakReplacement);t&&!e?r=!1:!t&&e&&(r=!0)}!1===r&&Pt(t,e,n,i),Nt(t,t.mapping.slice(i).map(n,1),o,void 0,null===r);let l=t.mapping.slice(i),c=l.map(n,1),d=l.map(n+e.nodeSize,1);return t.step(new Ot(c,d,c+1,d-1,new f(a.from(o.create(s,null,e.marks)),0,0),1,!0)),!0===r&&It(t,e,n,i),!1}}))}(this,t,e,n,o),this}setNodeMarkup(t,e,n=null,o){return function(t,e,n,o,r){let i=t.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");n||(n=i.type);let s=n.create(o,null,r||i.marks);if(i.isLeaf)return t.replaceWith(e,e+i.nodeSize,s);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new Ot(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new f(a.from(s),0,0),1,!0))}(this,t,e,n,o),this}setNodeAttribute(t,e,n){return this.step(new Qt(t,e,n)),this}setDocAttribute(t,e){return this.step(new Zt(t,e)),this}addNodeMark(t,e){return this.step(new St(t,e)),this}removeNodeMark(t,e){if(!(e instanceof p)){let n=this.doc.nodeAt(t);if(!n)throw new RangeError("No node at position "+t);if(!(e=e.isInSet(n.marks)))return this}return this.step(new Tt(t,e)),this}split(t,e=1,n){return function(t,e,n=1,o){let r=t.doc.resolve(e),i=a.empty,s=a.empty;for(let t=r.depth,e=r.depth-n,l=n-1;t>e;t--,l--){i=a.from(r.node(t).copy(i));let e=o&&o[l];s=a.from(e?e.type.create(e.attrs,s):r.node(t).copy(s))}t.step(new At(e,e,new f(i.append(s),n,n),!0))}(this,t,e,n),this}addMark(t,e,n){return function(t,e,n,o){let r,i,s=[],l=[];t.doc.nodesBetween(e,n,((t,a,c)=>{if(!t.isInline)return;let d=t.marks;if(!o.isInSet(d)&&c.type.allowsMarkType(o.type)){let c=Math.max(a,e),h=Math.min(a+t.nodeSize,n),p=o.addToSet(d);for(let t=0;t<d.length;t++)d[t].isInSet(p)||(r&&r.to==c&&r.mark.eq(d[t])?r.to=h:s.push(r=new Ct(c,h,d[t])));i&&i.to==c?i.to=h:l.push(i=new Mt(c,h,o))}})),s.forEach((e=>t.step(e))),l.forEach((e=>t.step(e)))}(this,t,e,n),this}removeMark(t,e,n){return function(t,e,n,o){let r=[],i=0;t.doc.nodesBetween(e,n,((t,s)=>{if(!t.isInline)return;i++;let l=null;if(o instanceof Y){let e,n=t.marks;for(;e=o.isInSet(n);)(l||(l=[])).push(e),n=e.removeFromSet(n)}else o?o.isInSet(t.marks)&&(l=[o]):l=t.marks;if(l&&l.length){let o=Math.min(s+t.nodeSize,n);for(let t=0;t<l.length;t++){let n,a=l[t];for(let t=0;t<r.length;t++){let e=r[t];e.step==i-1&&a.eq(r[t].style)&&(n=e)}n?(n.to=o,n.step=i):r.push({style:a,from:Math.max(s,e),to:o,step:i})}}})),r.forEach((e=>t.step(new Ct(e.from,e.to,e.style))))}(this,t,e,n),this}clearIncompatible(t,e,n){return Nt(this,t,e,n),this}}const ne=Object.create(null);class oe{constructor(t,e,n){this.$anchor=t,this.$head=e,this.ranges=n||[new re(t.min(e),t.max(e))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let t=this.ranges;for(let e=0;e<t.length;e++)if(t[e].$from.pos!=t[e].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(t,e=f.empty){let n=e.content.lastChild,o=null;for(let t=0;t<e.openEnd;t++)o=n,n=n.lastChild;let r=t.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:l,$to:a}=i[s],c=t.mapping.slice(r);t.replaceRange(c.map(l.pos),c.map(a.pos),s?f.empty:e),0==s&&fe(t,r,(n?n.isInline:o&&o.isTextblock)?-1:1)}}replaceWith(t,e){let n=t.steps.length,o=this.ranges;for(let r=0;r<o.length;r++){let{$from:i,$to:s}=o[r],l=t.mapping.slice(n),a=l.map(i.pos),c=l.map(s.pos);r?t.deleteRange(a,c):(t.replaceRangeWith(a,c,e),fe(t,n,e.isInline?-1:1))}}static findFrom(t,e,n=!1){let o=t.parent.inlineContent?new le(t):ue(t.node(0),t.parent,t.pos,t.index(),e,n);if(o)return o;for(let o=t.depth-1;o>=0;o--){let r=e<0?ue(t.node(0),t.node(o),t.before(o+1),t.index(o),e,n):ue(t.node(0),t.node(o),t.after(o+1),t.index(o)+1,e,n);if(r)return r}return null}static near(t,e=1){return this.findFrom(t,e)||this.findFrom(t,-e)||new he(t.node(0))}static atStart(t){return ue(t,t,0,0,1)||new he(t)}static atEnd(t){return ue(t,t,t.content.size,t.childCount,-1)||new he(t)}static fromJSON(t,e){if(!e||!e.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=ne[e.type];if(!n)throw new RangeError(`No selection type ${e.type} defined`);return n.fromJSON(t,e)}static jsonID(t,e){if(t in ne)throw new RangeError("Duplicate use of selection JSON ID "+t);return ne[t]=e,e.prototype.jsonID=t,e}getBookmark(){return le.between(this.$anchor,this.$head).getBookmark()}}oe.prototype.visible=!0;class re{constructor(t,e){this.$from=t,this.$to=e}}let ie=!1;function se(t){ie||t.parent.inlineContent||(ie=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class le extends oe{constructor(t,e=t){se(t),se(e),super(t,e)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,e){let n=t.resolve(e.map(this.head));if(!n.parent.inlineContent)return oe.near(n);let o=t.resolve(e.map(this.anchor));return new le(o.parent.inlineContent?o:n,n)}replace(t,e=f.empty){if(super.replace(t,e),e==f.empty){let e=this.$from.marksAcross(this.$to);e&&t.ensureMarks(e)}}eq(t){return t instanceof le&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new ae(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(t,e){if("number"!=typeof e.anchor||"number"!=typeof e.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new le(t.resolve(e.anchor),t.resolve(e.head))}static create(t,e,n=e){let o=t.resolve(e);return new this(o,n==e?o:t.resolve(n))}static between(t,e,n){let o=t.pos-e.pos;if(n&&!o||(n=o>=0?1:-1),!e.parent.inlineContent){let t=oe.findFrom(e,n,!0)||oe.findFrom(e,-n,!0);if(!t)return oe.near(e,n);e=t.$head}return t.parent.inlineContent||(0==o||(t=(oe.findFrom(t,-n,!0)||oe.findFrom(t,n,!0)).$anchor).pos<e.pos!=o<0)&&(t=e),new le(t,e)}}oe.jsonID("text",le);class ae{constructor(t,e){this.anchor=t,this.head=e}map(t){return new ae(t.map(this.anchor),t.map(this.head))}resolve(t){return le.between(t.resolve(this.anchor),t.resolve(this.head))}}class ce extends oe{constructor(t){let e=t.nodeAfter,n=t.node(0).resolve(t.pos+e.nodeSize);super(t,n),this.node=e}map(t,e){let{deleted:n,pos:o}=e.mapResult(this.anchor),r=t.resolve(o);return n?oe.near(r):new ce(r)}content(){return new f(a.from(this.node),0,0)}eq(t){return t instanceof ce&&t.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new de(this.anchor)}static fromJSON(t,e){if("number"!=typeof e.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new ce(t.resolve(e.anchor))}static create(t,e){return new ce(t.resolve(e))}static isSelectable(t){return!t.isText&&!1!==t.type.spec.selectable}}ce.prototype.visible=!1,oe.jsonID("node",ce);class de{constructor(t){this.anchor=t}map(t){let{deleted:e,pos:n}=t.mapResult(this.anchor);return e?new ae(n,n):new de(n)}resolve(t){let e=t.resolve(this.anchor),n=e.nodeAfter;return n&&ce.isSelectable(n)?new ce(e):oe.near(e)}}class he extends oe{constructor(t){super(t.resolve(0),t.resolve(t.content.size))}replace(t,e=f.empty){if(e==f.empty){t.delete(0,t.doc.content.size);let e=oe.atStart(t.doc);e.eq(t.selection)||t.setSelection(e)}else super.replace(t,e)}toJSON(){return{type:"all"}}static fromJSON(t){return new he(t)}map(t){return new he(t)}eq(t){return t instanceof he}getBookmark(){return pe}}oe.jsonID("all",he);const pe={map(){return this},resolve:t=>new he(t)};function ue(t,e,n,o,r,i=!1){if(e.inlineContent)return le.create(t,n);for(let s=o-(r>0?0:1);r>0?s<e.childCount:s>=0;s+=r){let o=e.child(s);if(o.isAtom){if(!i&&ce.isSelectable(o))return ce.create(t,n-(r<0?o.nodeSize:0))}else{let e=ue(t,o,n+r,r<0?o.childCount:0,r,i);if(e)return e}n+=o.nodeSize*r}return null}function fe(t,e,n){let o=t.steps.length-1;if(o<e)return;let r,i=t.steps[o];(i instanceof At||i instanceof Ot)&&(t.mapping.maps[o].forEach(((t,e,n,o)=>{null==r&&(r=o)})),t.setSelection(oe.near(t.doc.resolve(r),n)))}class me extends ee{constructor(t){super(t.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=t.selection,this.storedMarks=t.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(t){if(t.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=t,this.curSelectionFor=this.steps.length,this.updated=-3&this.updated|1,this.storedMarks=null,this}get selectionSet(){return(1&this.updated)>0}setStoredMarks(t){return this.storedMarks=t,this.updated|=2,this}ensureMarks(t){return p.sameSet(this.storedMarks||this.selection.$from.marks(),t)||this.setStoredMarks(t),this}addStoredMark(t){return this.ensureMarks(t.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(t){return this.ensureMarks(t.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(2&this.updated)>0}addStep(t,e){super.addStep(t,e),this.updated=-3&this.updated,this.storedMarks=null}setTime(t){return this.time=t,this}replaceSelection(t){return this.selection.replace(this,t),this}replaceSelectionWith(t,e=!0){let n=this.selection;return e&&(t=t.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||p.none))),n.replaceWith(this,t),this}deleteSelection(){return this.selection.replace(this),this}insertText(t,e,n){let o=this.doc.type.schema;if(null==e)return t?this.replaceSelectionWith(o.text(t),!0):this.deleteSelection();{if(null==n&&(n=e),n=null==n?e:n,!t)return this.deleteRange(e,n);let r=this.storedMarks;if(!r){let t=this.doc.resolve(e);r=n==e?t.marks():t.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(e,n,o.text(t,r)),this.selection.empty||this.setSelection(oe.near(this.selection.$to)),this}}setMeta(t,e){return this.meta["string"==typeof t?t:t.key]=e,this}getMeta(t){return this.meta["string"==typeof t?t:t.key]}get isGeneric(){for(let t in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=4,this}get scrolledIntoView(){return(4&this.updated)>0}}function ge(t,e){return e&&t?t.bind(e):t}class ye{constructor(t,e,n){this.name=t,this.init=ge(e.init,n),this.apply=ge(e.apply,n)}}const be=[new ye("doc",{init:t=>t.doc||t.schema.topNodeType.createAndFill(),apply:t=>t.doc}),new ye("selection",{init:(t,e)=>t.selection||oe.atStart(e.doc),apply:t=>t.selection}),new ye("storedMarks",{init:t=>t.storedMarks||null,apply:(t,e,n,o)=>o.selection.$cursor?t.storedMarks:null}),new ye("scrollToSelection",{init:()=>0,apply:(t,e)=>t.scrolledIntoView?e+1:e})];class ve{constructor(t,e){this.schema=t,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=be.slice(),e&&e.forEach((t=>{if(this.pluginsByKey[t.key])throw new RangeError("Adding different instances of a keyed plugin ("+t.key+")");this.plugins.push(t),this.pluginsByKey[t.key]=t,t.spec.state&&this.fields.push(new ye(t.key,t.spec.state,t))}))}}class we{constructor(t){this.config=t}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(t){return this.applyTransaction(t).state}filterTransaction(t,e=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=e){let e=this.config.plugins[n];if(e.spec.filterTransaction&&!e.spec.filterTransaction.call(e,t,this))return!1}return!0}applyTransaction(t){if(!this.filterTransaction(t))return{state:this,transactions:[]};let e=[t],n=this.applyInner(t),o=null;for(;;){let r=!1;for(let i=0;i<this.config.plugins.length;i++){let s=this.config.plugins[i];if(s.spec.appendTransaction){let l=o?o[i].n:0,a=o?o[i].state:this,c=l<e.length&&s.spec.appendTransaction.call(s,l?e.slice(l):e,a,n);if(c&&n.filterTransaction(c,i)){if(c.setMeta("appendedTransaction",t),!o){o=[];for(let t=0;t<this.config.plugins.length;t++)o.push(t<i?{state:n,n:e.length}:{state:this,n:0})}e.push(c),n=n.applyInner(c),r=!0}o&&(o[i]={state:n,n:e.length})}}if(!r)return{state:n,transactions:e}}}applyInner(t){if(!t.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let e=new we(this.config),n=this.config.fields;for(let o=0;o<n.length;o++){let r=n[o];e[r.name]=r.apply(t,this[r.name],this,e)}return e}get tr(){return new me(this)}static create(t){let e=new ve(t.doc?t.doc.type.schema:t.schema,t.plugins),n=new we(e);for(let o=0;o<e.fields.length;o++)n[e.fields[o].name]=e.fields[o].init(t,n);return n}reconfigure(t){let e=new ve(this.schema,t.plugins),n=e.fields,o=new we(e);for(let e=0;e<n.length;e++){let r=n[e].name;o[r]=this.hasOwnProperty(r)?this[r]:n[e].init(t,o)}return o}toJSON(t){let e={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(e.storedMarks=this.storedMarks.map((t=>t.toJSON()))),t&&"object"==typeof t)for(let n in t){if("doc"==n||"selection"==n)throw new RangeError("The JSON fields `doc` and `selection` are reserved");let o=t[n],r=o.spec.state;r&&r.toJSON&&(e[n]=r.toJSON.call(o,this[o.key]))}return e}static fromJSON(t,e,n){if(!e)throw new RangeError("Invalid input for EditorState.fromJSON");if(!t.schema)throw new RangeError("Required config field 'schema' missing");let o=new ve(t.schema,t.plugins),r=new we(o);return o.fields.forEach((o=>{if("doc"==o.name)r.doc=R.fromJSON(t.schema,e.doc);else if("selection"==o.name)r.selection=oe.fromJSON(r.doc,e.selection);else if("storedMarks"==o.name)e.storedMarks&&(r.storedMarks=e.storedMarks.map(t.schema.markFromJSON));else{if(n)for(let i in n){let s=n[i],l=s.spec.state;if(s.key==o.name&&l&&l.fromJSON&&Object.prototype.hasOwnProperty.call(e,i))return void(r[o.name]=l.fromJSON.call(s,t,e[i],r))}r[o.name]=o.init(t,r)}})),r}}function ke(t,e,n){for(let o in t){let r=t[o];r instanceof Function?r=r.bind(e):"handleDOMEvents"==o&&(r=ke(r,e,{})),n[o]=r}return n}class xe{constructor(t){this.spec=t,this.props={},t.props&&ke(t.props,this,this.props),this.key=t.key?t.key.key:Ce("plugin")}getState(t){return t[this.key]}}const Me=Object.create(null);function Ce(t){return t in Me?t+"$"+ ++Me[t]:(Me[t]=0,t+"$")}class Se{constructor(t="key"){this.key=Ce(t)}get(t){return t.config.pluginsByKey[this.key]}getState(t){return t[this.key]}}const Te=function(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e},Ae=function(t){let e=t.assignedSlot||t.parentNode;return e&&11==e.nodeType?e.host:e};let Oe=null;const Ee=function(t,e,n){let o=Oe||(Oe=document.createRange());return o.setEnd(t,null==n?t.nodeValue.length:n),o.setStart(t,e||0),o},Ne=function(t,e,n,o){return n&&(Re(t,e,n,o,-1)||Re(t,e,n,o,1))},De=/^(img|br|input|textarea|hr)$/i;function Re(t,e,n,o,r){for(;;){if(t==n&&e==o)return!0;if(e==(r<0?0:je(t))){let n=t.parentNode;if(!n||1!=n.nodeType||Le(t)||De.test(t.nodeName)||"false"==t.contentEditable)return!1;e=Te(t)+(r<0?0:1),t=n}else{if(1!=t.nodeType)return!1;if("false"==(t=t.childNodes[e+(r<0?-1:0)]).contentEditable)return!1;e=r<0?je(t):0}}}function je(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function Le(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const Ie=function(t){return t.focusNode&&Ne(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Pe(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}const ze="undefined"!=typeof navigator?navigator:null,$e="undefined"!=typeof document?document:null,He=ze&&ze.userAgent||"",Be=/Edge\/(\d+)/.exec(He),_e=/MSIE \d/.exec(He),Fe=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(He),Ve=!!(_e||Fe||Be),We=_e?document.documentMode:Fe?+Fe[1]:Be?+Be[1]:0,qe=!Ve&&/gecko\/(\d+)/i.test(He);qe&&(/Firefox\/(\d+)/.exec(He)||[0,0])[1];const Ke=!Ve&&/Chrome\/(\d+)/.exec(He),Je=!!Ke,Ue=Ke?+Ke[1]:0,Ge=!Ve&&!!ze&&/Apple Computer/.test(ze.vendor),Ye=Ge&&(/Mobile\/\w+/.test(He)||!!ze&&ze.maxTouchPoints>2),Xe=Ye||!!ze&&/Mac/.test(ze.platform),Qe=!!ze&&/Win/.test(ze.platform),Ze=/Android \d/.test(He),tn=!!$e&&"webkitFontSmoothing"in $e.documentElement.style,en=tn?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function nn(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 on(t,e){return"number"==typeof t?t:t[e]}function rn(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,o=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*o}}function sn(t,e,n){let o=t.someProp("scrollThreshold")||0,r=t.someProp("scrollMargin")||5,i=t.dom.ownerDocument;for(let s=n||t.dom;s;){if(1!=s.nodeType){s=Ae(s);continue}let t=s,n=t==i.body,l=n?nn(i):rn(t),a=0,c=0;if(e.top<l.top+on(o,"top")?c=-(l.top-e.top+on(r,"top")):e.bottom>l.bottom-on(o,"bottom")&&(c=e.bottom-e.top>l.bottom-l.top?e.top+on(r,"top")-l.top:e.bottom-l.bottom+on(r,"bottom")),e.left<l.left+on(o,"left")?a=-(l.left-e.left+on(r,"left")):e.right>l.right-on(o,"right")&&(a=e.right-l.right+on(r,"right")),a||c)if(n)i.defaultView.scrollBy(a,c);else{let n=t.scrollLeft,o=t.scrollTop;c&&(t.scrollTop+=c),a&&(t.scrollLeft+=a);let r=t.scrollLeft-n,i=t.scrollTop-o;e={left:e.left-r,top:e.top-i,right:e.right-r,bottom:e.bottom-i}}let d=n?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(d))break;s="absolute"==d?s.offsetParent:Ae(s)}}function ln(t){let e=[],n=t.ownerDocument;for(let o=t;o&&(e.push({dom:o,top:o.scrollTop,left:o.scrollLeft}),t!=n);o=Ae(o));return e}function an(t,e){for(let n=0;n<t.length;n++){let{dom:o,top:r,left:i}=t[n];o.scrollTop!=r+e&&(o.scrollTop=r+e),o.scrollLeft!=i&&(o.scrollLeft=i)}}let cn=null;function dn(t,e){let n,o,r,i,s=2e8,l=0,a=e.top,c=e.top;for(let d=t.firstChild,h=0;d;d=d.nextSibling,h++){let t;if(1==d.nodeType)t=d.getClientRects();else{if(3!=d.nodeType)continue;t=Ee(d).getClientRects()}for(let p=0;p<t.length;p++){let u=t[p];if(u.top<=a&&u.bottom>=c){a=Math.max(u.bottom,a),c=Math.min(u.top,c);let t=u.left>e.left?u.left-e.left:u.right<e.left?e.left-u.right:0;if(t<s){n=d,s=t,o=t&&3==n.nodeType?{left:u.right<e.left?u.right:u.left,top:e.top}:e,1==d.nodeType&&t&&(l=h+(e.left>=(u.left+u.right)/2?1:0));continue}}else u.top>e.top&&!r&&u.left<=e.left&&u.right>=e.left&&(r=d,i={left:Math.max(u.left,Math.min(u.right,e.left)),top:u.top});!n&&(e.left>=u.right&&e.top>=u.top||e.left>=u.left&&e.top>=u.bottom)&&(l=h+1)}}return!n&&r&&(n=r,o=i,s=0),n&&3==n.nodeType?function(t,e){let n=t.nodeValue.length,o=document.createRange();for(let r=0;r<n;r++){o.setEnd(t,r+1),o.setStart(t,r);let n=mn(o,1);if(n.top!=n.bottom&&hn(e,n))return{node:t,offset:r+(e.left>=(n.left+n.right)/2?1:0)}}return{node:t,offset:0}}(n,o):!n||s&&1==n.nodeType?{node:t,offset:l}:dn(n,o)}function hn(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function pn(t,e,n){let o=t.childNodes.length;if(o&&n.top<n.bottom)for(let r=Math.max(0,Math.min(o-1,Math.floor(o*(e.top-n.top)/(n.bottom-n.top))-2)),i=r;;){let n=t.childNodes[i];if(1==n.nodeType){let t=n.getClientRects();for(let o=0;o<t.length;o++){let r=t[o];if(hn(e,r))return pn(n,e,r)}}if((i=(i+1)%o)==r)break}return t}function un(t,e){let n,o=t.dom.ownerDocument,r=0,i=function(t,e,n){if(t.caretPositionFromPoint)try{let o=t.caretPositionFromPoint(e,n);if(o)return{node:o.offsetNode,offset:Math.min(je(o.offsetNode),o.offset)}}catch(t){}if(t.caretRangeFromPoint){let o=t.caretRangeFromPoint(e,n);if(o)return{node:o.startContainer,offset:Math.min(je(o.startContainer),o.startOffset)}}}(o,e.left,e.top);i&&({node:n,offset:r}=i);let s,l=(t.root.elementFromPoint?t.root:o).elementFromPoint(e.left,e.top);if(!l||!t.dom.contains(1!=l.nodeType?l.parentNode:l)){let n=t.dom.getBoundingClientRect();if(!hn(e,n))return null;if(l=pn(t.dom,e,n),!l)return null}if(Ge)for(let t=l;n&&t;t=Ae(t))t.draggable&&(n=void 0);if(l=function(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}(l,e),n){if(qe&&1==n.nodeType&&(r=Math.min(r,n.childNodes.length),r<n.childNodes.length)){let t,o=n.childNodes[r];"IMG"==o.nodeName&&(t=o.getBoundingClientRect()).right<=e.left&&t.bottom>e.top&&r++}let o;tn&&r&&1==n.nodeType&&1==(o=n.childNodes[r-1]).nodeType&&"false"==o.contentEditable&&o.getBoundingClientRect().top>=e.top&&r--,n==t.dom&&r==n.childNodes.length-1&&1==n.lastChild.nodeType&&e.top>n.lastChild.getBoundingClientRect().bottom?s=t.state.doc.content.size:0!=r&&1==n.nodeType&&"BR"==n.childNodes[r-1].nodeName||(s=function(t,e,n,o){let r=-1;for(let n=e,i=!1;n!=t.dom;){let e,s=t.docView.nearestDesc(n,!0);if(!s)return null;if(1==s.dom.nodeType&&(s.node.isBlock&&s.parent||!s.contentDOM)&&((e=s.dom.getBoundingClientRect()).width||e.height)&&(s.node.isBlock&&s.parent&&(!i&&e.left>o.left||e.top>o.top?r=s.posBefore:(!i&&e.right<o.left||e.bottom<o.top)&&(r=s.posAfter),i=!0),!s.contentDOM&&r<0&&!s.node.isText))return(s.node.isBlock?o.top<(e.top+e.bottom)/2:o.left<(e.left+e.right)/2)?s.posBefore:s.posAfter;n=s.dom.parentNode}return r>-1?r:t.docView.posFromDOM(e,n,-1)}(t,n,r,e))}null==s&&(s=function(t,e,n){let{node:o,offset:r}=dn(e,n),i=-1;if(1==o.nodeType&&!o.firstChild){let t=o.getBoundingClientRect();i=t.left!=t.right&&n.left>(t.left+t.right)/2?1:-1}return t.docView.posFromDOM(o,r,i)}(t,l,e));let a=t.docView.nearestDesc(l,!0);return{pos:s,inside:a?a.posAtStart-a.border:-1}}function fn(t){return t.top<t.bottom||t.left<t.right}function mn(t,e){let n=t.getClientRects();if(n.length){let t=n[e<0?0:n.length-1];if(fn(t))return t}return Array.prototype.find.call(n,fn)||t.getBoundingClientRect()}const gn=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function yn(t,e,n){let{node:o,offset:r,atom:i}=t.docView.domFromPos(e,n<0?-1:1),s=tn||qe;if(3==o.nodeType){if(!s||!gn.test(o.nodeValue)&&(n<0?r:r!=o.nodeValue.length)){let t=r,e=r,i=n<0?1:-1;return n<0&&!r?(e++,i=-1):n>=0&&r==o.nodeValue.length?(t--,i=1):n<0?t--:e++,bn(mn(Ee(o,t,e),i),i<0)}{let t=mn(Ee(o,r,r),n);if(qe&&r&&/\s/.test(o.nodeValue[r-1])&&r<o.nodeValue.length){let e=mn(Ee(o,r-1,r-1),-1);if(e.top==t.top){let n=mn(Ee(o,r,r+1),-1);if(n.top!=t.top)return bn(n,n.left<e.left)}}return t}}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(null==i&&r&&(n<0||r==je(o))){let t=o.childNodes[r-1];if(1==t.nodeType)return vn(t.getBoundingClientRect(),!1)}if(null==i&&r<je(o)){let t=o.childNodes[r];if(1==t.nodeType)return vn(t.getBoundingClientRect(),!0)}return vn(o.getBoundingClientRect(),n>=0)}if(null==i&&r&&(n<0||r==je(o))){let t=o.childNodes[r-1],e=3==t.nodeType?Ee(t,je(t)-(s?0:1)):1!=t.nodeType||"BR"==t.nodeName&&t.nextSibling?null:t;if(e)return bn(mn(e,1),!1)}if(null==i&&r<je(o)){let t=o.childNodes[r];for(;t.pmViewDesc&&t.pmViewDesc.ignoreForCoords;)t=t.nextSibling;let e=t?3==t.nodeType?Ee(t,0,s?0:1):1==t.nodeType?t:null:null;if(e)return bn(mn(e,-1),!0)}return bn(mn(3==o.nodeType?Ee(o):o,-n),n>=0)}function bn(t,e){if(0==t.width)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function vn(t,e){if(0==t.height)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function wn(t,e,n){let o=t.state,r=t.root.activeElement;o!=e&&t.updateState(e),r!=t.dom&&t.focus();try{return n()}finally{o!=e&&t.updateState(o),r!=t.dom&&r&&r.focus()}}const kn=/[\u0590-\u08ac]/;let xn=null,Mn=null,Cn=!1;class Sn{constructor(t,e,n,o){this.parent=t,this.children=e,this.dom=n,this.contentDOM=o,this.dirty=0,n.pmViewDesc=this}matchesWidget(t){return!1}matchesMark(t){return!1}matchesNode(t,e,n){return!1}matchesHack(t){return!1}parseRule(){return null}stopEvent(t){return!1}get size(){let t=0;for(let e=0;e<this.children.length;e++)t+=this.children[e].size;return t}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let t=0;t<this.children.length;t++)this.children[t].destroy()}posBeforeChild(t){for(let e=0,n=this.posAtStart;;e++){let o=this.children[e];if(o==t)return n;n+=o.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(t,e,n){if(this.contentDOM&&this.contentDOM.contains(1==t.nodeType?t:t.parentNode)){if(n<0){let n,o;if(t==this.contentDOM)n=t.childNodes[e-1];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;n=t.previousSibling}for(;n&&(!(o=n.pmViewDesc)||o.parent!=this);)n=n.previousSibling;return n?this.posBeforeChild(o)+o.size:this.posAtStart}{let n,o;if(t==this.contentDOM)n=t.childNodes[e];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;n=t.nextSibling}for(;n&&(!(o=n.pmViewDesc)||o.parent!=this);)n=n.nextSibling;return n?this.posBeforeChild(o):this.posAtEnd}}let o;if(t==this.dom&&this.contentDOM)o=e>Te(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))o=2&t.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==e)for(let e=t;;e=e.parentNode){if(e==this.dom){o=!1;break}if(e.previousSibling)break}if(null==o&&e==t.childNodes.length)for(let e=t;;e=e.parentNode){if(e==this.dom){o=!0;break}if(e.nextSibling)break}}return(null==o?n>0:o)?this.posAtEnd:this.posAtStart}nearestDesc(t,e=!1){for(let n=!0,o=t;o;o=o.parentNode){let r,i=this.getDesc(o);if(i&&(!e||i.node)){if(!n||!(r=i.nodeDOM)||(1==r.nodeType?r.contains(1==t.nodeType?t:t.parentNode):r==t))return i;n=!1}}}getDesc(t){let e=t.pmViewDesc;for(let t=e;t;t=t.parent)if(t==this)return e}posFromDOM(t,e,n){for(let o=t;o;o=o.parentNode){let r=this.getDesc(o);if(r)return r.localPosFromDOM(t,e,n)}return-1}descAt(t){for(let e=0,n=0;e<this.children.length;e++){let o=this.children[e],r=n+o.size;if(n==t&&r!=n){for(;!o.border&&o.children.length;)for(let t=0;t<o.children.length;t++){let e=o.children[t];if(e.size){o=e;break}}return o}if(t<r)return o.descAt(t-n-o.border);n=r}}domFromPos(t,e){if(!this.contentDOM)return{node:this.dom,offset:0,atom:t+1};let n=0,o=0;for(let e=0;n<this.children.length;n++){let r=this.children[n],i=e+r.size;if(i>t||r instanceof Rn){o=t-e;break}e=i}if(o)return this.children[n].domFromPos(o-this.children[n].border,e);for(let t;n&&!(t=this.children[n-1]).size&&t instanceof Tn&&t.side>=0;n--);if(e<=0){let t,o=!0;for(;t=n?this.children[n-1]:null,t&&t.dom.parentNode!=this.contentDOM;n--,o=!1);return t&&e&&o&&!t.border&&!t.domAtom?t.domFromPos(t.size,e):{node:this.contentDOM,offset:t?Te(t.dom)+1:0}}{let t,o=!0;for(;t=n<this.children.length?this.children[n]:null,t&&t.dom.parentNode!=this.contentDOM;n++,o=!1);return t&&o&&!t.border&&!t.domAtom?t.domFromPos(0,e):{node:this.contentDOM,offset:t?Te(t.dom):this.contentDOM.childNodes.length}}}parseRange(t,e,n=0){if(0==this.children.length)return{node:this.contentDOM,from:t,to:e,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let o=-1,r=-1;for(let i=n,s=0;;s++){let n=this.children[s],l=i+n.size;if(-1==o&&t<=l){let r=i+n.border;if(t>=r&&e<=l-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(t,e,r);t=i;for(let e=s;e>0;e--){let n=this.children[e-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){o=Te(n.dom)+1;break}t-=n.size}-1==o&&(o=0)}if(o>-1&&(l>e||s==this.children.length-1)){e=l;for(let t=s+1;t<this.children.length;t++){let n=this.children[t];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(-1)){r=Te(n.dom);break}e+=n.size}-1==r&&(r=this.contentDOM.childNodes.length);break}i=l}return{node:this.contentDOM,from:t,to:e,fromOffset:o,toOffset:r}}emptyChildAt(t){if(this.border||!this.contentDOM||!this.children.length)return!1;let e=this.children[t<0?0:this.children.length-1];return 0==e.size||e.emptyChildAt(t)}domAfterPos(t){let{node:e,offset:n}=this.domFromPos(t,0);if(1!=e.nodeType||n==e.childNodes.length)throw new RangeError("No node after pos "+t);return e.childNodes[n]}setSelection(t,e,n,o=!1){let r=Math.min(t,e),i=Math.max(t,e);for(let s=0,l=0;s<this.children.length;s++){let a=this.children[s],c=l+a.size;if(r>l&&i<c)return a.setSelection(t-l-a.border,e-l-a.border,n,o);l=c}let s=this.domFromPos(t,t?-1:1),l=e==t?s:this.domFromPos(e,e?-1:1),a=n.root.getSelection(),c=n.domSelectionRange(),d=!1;if((qe||Ge)&&t==e){let{node:t,offset:e}=s;if(3==t.nodeType){if(d=!(!e||"\n"!=t.nodeValue[e-1]),d&&e==t.nodeValue.length)for(let e,n=t;n;n=n.parentNode){if(e=n.nextSibling){"BR"==e.nodeName&&(s=l={node:e.parentNode,offset:Te(e)+1});break}let t=n.pmViewDesc;if(t&&t.node&&t.node.isBlock)break}}else{let n=t.childNodes[e-1];d=n&&("BR"==n.nodeName||"false"==n.contentEditable)}}if(qe&&c.focusNode&&c.focusNode!=l.node&&1==c.focusNode.nodeType){let t=c.focusNode.childNodes[c.focusOffset];t&&"false"==t.contentEditable&&(o=!0)}if(!(o||d&&Ge)&&Ne(s.node,s.offset,c.anchorNode,c.anchorOffset)&&Ne(l.node,l.offset,c.focusNode,c.focusOffset))return;let h=!1;if((a.extend||t==e)&&!d){a.collapse(s.node,s.offset);try{t!=e&&a.extend(l.node,l.offset),h=!0}catch(t){}}if(!h){if(t>e){let t=s;s=l,l=t}let n=document.createRange();n.setEnd(l.node,l.offset),n.setStart(s.node,s.offset),a.removeAllRanges(),a.addRange(n)}}ignoreMutation(t){return!this.contentDOM&&"selection"!=t.type}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(t,e){for(let n=0,o=0;o<this.children.length;o++){let r=this.children[o],i=n+r.size;if(n==i?t<=i&&e>=n:t<i&&e>n){let o=n+r.border,s=i-r.border;if(t>=o&&e<=s)return this.dirty=t==n||e==i?2:1,void(t!=o||e!=s||!r.contentLost&&r.dom.parentNode==this.contentDOM?r.markDirty(t-o,e-o):r.dirty=3);r.dirty=r.dom!=r.contentDOM||r.dom.parentNode!=this.contentDOM||r.children.length?3:2}n=i}this.dirty=2}markParentsDirty(){let t=1;for(let e=this.parent;e;e=e.parent,t++){let n=1==t?2:1;e.dirty<n&&(e.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(t){return!1}}class Tn extends Sn{constructor(t,e,n,o){let r,i=e.type.toDOM;if("function"==typeof i&&(i=i(n,(()=>r?r.parent?r.parent.posBeforeChild(r):void 0:o))),!e.type.spec.raw){if(1!=i.nodeType){let t=document.createElement("span");t.appendChild(i),i=t}i.contentEditable="false",i.classList.add("ProseMirror-widget")}super(t,[],i,null),this.widget=e,this.widget=e,r=this}matchesWidget(t){return 0==this.dirty&&t.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(t){let e=this.widget.spec.stopEvent;return!!e&&e(t)}ignoreMutation(t){return"selection"!=t.type||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}}class An extends Sn{constructor(t,e,n,o){super(t,[],e,null),this.textDOM=n,this.text=o}get size(){return this.text.length}localPosFromDOM(t,e){return t!=this.textDOM?this.posAtStart+(e?this.size:0):this.posAtStart+e}domFromPos(t){return{node:this.textDOM,offset:t}}ignoreMutation(t){return"characterData"===t.type&&t.target.nodeValue==t.oldValue}}class On extends Sn{constructor(t,e,n,o,r){super(t,[],n,o),this.mark=e,this.spec=r}static create(t,e,n,o){let r=o.nodeViews[e.type.name],i=r&&r(e,o,n);return i&&i.dom||(i=ct.renderSpec(document,e.type.spec.toDOM(e,n),null,e.attrs)),new On(t,e,i.dom,i.contentDOM||i.dom,i)}parseRule(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(t){return 3!=this.dirty&&this.mark.eq(t)}markDirty(t,e){if(super.markDirty(t,e),0!=this.dirty){let t=this.parent;for(;!t.node;)t=t.parent;t.dirty<this.dirty&&(t.dirty=this.dirty),this.dirty=0}}slice(t,e,n){let o=On.create(this.parent,this.mark,!0,n),r=this.children,i=this.size;e<i&&(r=qn(r,e,i,n)),t>0&&(r=qn(r,0,t,n));for(let t=0;t<r.length;t++)r[t].parent=o;return o.children=r,o}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class En extends Sn{constructor(t,e,n,o,r,i,s,l,a){super(t,[],r,i),this.node=e,this.outerDeco=n,this.innerDeco=o,this.nodeDOM=s}static create(t,e,n,o,r,i){let s,l=r.nodeViews[e.type.name],a=l&&l(e,r,(()=>s?s.parent?s.parent.posBeforeChild(s):void 0:i),n,o),c=a&&a.dom,d=a&&a.contentDOM;if(e.isText)if(c){if(3!=c.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else c=document.createTextNode(e.text);else if(!c){let t=ct.renderSpec(document,e.type.spec.toDOM(e),null,e.attrs);({dom:c,contentDOM:d}=t)}d||e.isText||"BR"==c.nodeName||(c.hasAttribute("contenteditable")||(c.contentEditable="false"),e.type.spec.draggable&&(c.draggable=!0));let h=c;return c=Bn(c,n,e),a?s=new jn(t,e,n,o,c,d||null,h,a,r,i+1):e.isText?new Dn(t,e,n,o,c,h,r):new En(t,e,n,o,c,d||null,h,r,i+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(t.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(let e=this.children.length-1;e>=0;e--){let n=this.children[e];if(this.dom.contains(n.dom.parentNode)){t.contentElement=n.dom.parentNode;break}}t.contentElement||(t.getContent=()=>a.empty)}else t.contentElement=this.contentDOM;else t.getContent=()=>this.node.content;return t}matchesNode(t,e,n){return 0==this.dirty&&t.eq(this.node)&&_n(e,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(t,e){let n=this.node.inlineContent,o=e,r=t.composing?this.localCompositionInfo(t,e):null,i=r&&r.pos>-1?r:null,s=r&&r.pos<0,l=new Vn(this,i&&i.node,t);!function(t,e,n,o){let r=e.locals(t),i=0;if(0==r.length){for(let n=0;n<t.childCount;n++){let s=t.child(n);o(s,r,e.forChild(i,s),n),i+=s.nodeSize}return}let s=0,l=[],a=null;for(let c=0;;){let d,h,p,u;for(;s<r.length&&r[s].to==i;){let t=r[s++];t.widget&&(d?(h||(h=[d])).push(t):d=t)}if(d)if(h){h.sort(Wn);for(let t=0;t<h.length;t++)n(h[t],c,!!a)}else n(d,c,!!a);if(a)u=-1,p=a,a=null;else{if(!(c<t.childCount))break;u=c,p=t.child(c++)}for(let t=0;t<l.length;t++)l[t].to<=i&&l.splice(t--,1);for(;s<r.length&&r[s].from<=i&&r[s].to>i;)l.push(r[s++]);let f=i+p.nodeSize;if(p.isText){let t=f;s<r.length&&r[s].from<t&&(t=r[s].from);for(let e=0;e<l.length;e++)l[e].to<t&&(t=l[e].to);t<f&&(a=p.cut(t-i),p=p.cut(0,t-i),f=t,u=-1)}else for(;s<r.length&&r[s].to<f;)s++;o(p,p.isInline&&!p.isLeaf?l.filter((t=>!t.inline)):l.slice(),e.forChild(i,p),u),i=f}}(this.node,this.innerDeco,((e,r,i)=>{e.spec.marks?l.syncToMarks(e.spec.marks,n,t):e.type.side>=0&&!i&&l.syncToMarks(r==this.node.childCount?p.none:this.node.child(r).marks,n,t),l.placeWidget(e,t,o)}),((e,i,a,c)=>{let d;l.syncToMarks(e.marks,n,t),l.findNodeMatch(e,i,a,c)||s&&t.state.selection.from>o&&t.state.selection.to<o+e.nodeSize&&(d=l.findIndexWithChild(r.node))>-1&&l.updateNodeAt(e,i,a,d,t)||l.updateNextNode(e,i,a,t,c,o)||l.addNode(e,i,a,t,o),o+=e.nodeSize})),l.syncToMarks([],n,t),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||2==this.dirty)&&(i&&this.protectLocalComposition(t,i),Ln(this.contentDOM,this.children,t),Ye&&function(t){if("UL"==t.nodeName||"OL"==t.nodeName){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}(this.dom))}localCompositionInfo(t,e){let{from:n,to:o}=t.state.selection;if(!(t.state.selection instanceof le)||n<e||o>e+this.node.content.size)return null;let r=t.input.compositionNode;if(!r||!this.dom.contains(r.parentNode))return null;if(this.node.inlineContent){let t=r.nodeValue,i=function(t,e,n,o){for(let r=0,i=0;r<t.childCount&&i<=o;){let s=t.child(r++),l=i;if(i+=s.nodeSize,!s.isText)continue;let a=s.text;for(;r<t.childCount;){let e=t.child(r++);if(i+=e.nodeSize,!e.isText)break;a+=e.text}if(i>=n){if(i>=o&&a.slice(o-e.length-l,o-l)==e)return o-e.length;let t=l<o?a.lastIndexOf(e,o-l-1):-1;if(t>=0&&t+e.length+l>=n)return l+t;if(n==o&&a.length>=o+e.length-l&&a.slice(o-l,o-l+e.length)==e)return o}}return-1}(this.node.content,t,n-e,o-e);return i<0?null:{node:r,pos:i,text:t}}return{node:r,pos:-1,text:""}}protectLocalComposition(t,{node:e,pos:n,text:o}){if(this.getDesc(e))return;let r=e;for(;r.parentNode!=this.contentDOM;r=r.parentNode){for(;r.previousSibling;)r.parentNode.removeChild(r.previousSibling);for(;r.nextSibling;)r.parentNode.removeChild(r.nextSibling);r.pmViewDesc&&(r.pmViewDesc=void 0)}let i=new An(this,r,e,o);t.input.compositionNodes.push(i),this.children=qn(this.children,n,n+o.length,t,i)}update(t,e,n,o){return!(3==this.dirty||!t.sameMarkup(this.node)||(this.updateInner(t,e,n,o),0))}updateInner(t,e,n,o){this.updateOuterDeco(e),this.node=t,this.innerDeco=n,this.contentDOM&&this.updateChildren(o,this.posAtStart),this.dirty=0}updateOuterDeco(t){if(_n(t,this.outerDeco))return;let e=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=$n(this.dom,this.nodeDOM,zn(this.outerDeco,this.node,e),zn(t,this.node,e)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=t}selectNode(){1==this.nodeDOM.nodeType&&this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.dom.draggable=!0)}deselectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function Nn(t,e,n,o,r){Bn(o,e,t);let i=new En(void 0,t,e,n,o,o,o,r,0);return i.contentDOM&&i.updateChildren(r,0),i}class Dn extends En{constructor(t,e,n,o,r,i,s){super(t,e,n,o,r,null,i,s,0)}parseRule(){let t=this.nodeDOM.parentNode;for(;t&&t!=this.dom&&!t.pmIsDeco;)t=t.parentNode;return{skip:t||!0}}update(t,e,n,o){return!(3==this.dirty||0!=this.dirty&&!this.inParent()||!t.sameMarkup(this.node)||(this.updateOuterDeco(e),0==this.dirty&&t.text==this.node.text||t.text==this.nodeDOM.nodeValue||(this.nodeDOM.nodeValue=t.text,o.trackWrites==this.nodeDOM&&(o.trackWrites=null)),this.node=t,this.dirty=0,0))}inParent(){let t=this.parent.contentDOM;for(let e=this.nodeDOM;e;e=e.parentNode)if(e==t)return!0;return!1}domFromPos(t){return{node:this.nodeDOM,offset:t}}localPosFromDOM(t,e,n){return t==this.nodeDOM?this.posAtStart+Math.min(e,this.node.text.length):super.localPosFromDOM(t,e,n)}ignoreMutation(t){return"characterData"!=t.type&&"selection"!=t.type}slice(t,e,n){let o=this.node.cut(t,e),r=document.createTextNode(o.text);return new Dn(this.parent,o,this.outerDeco,this.innerDeco,r,r,n)}markDirty(t,e){super.markDirty(t,e),this.dom==this.nodeDOM||0!=t&&e!=this.nodeDOM.nodeValue.length||(this.dirty=3)}get domAtom(){return!1}isText(t){return this.node.text==t}}class Rn extends Sn{parseRule(){return{ignore:!0}}matchesHack(t){return 0==this.dirty&&this.dom.nodeName==t}get domAtom(){return!0}get ignoreForCoords(){return"IMG"==this.dom.nodeName}}class jn extends En{constructor(t,e,n,o,r,i,s,l,a,c){super(t,e,n,o,r,i,s,a,c),this.spec=l}update(t,e,n,o){if(3==this.dirty)return!1;if(this.spec.update&&(this.node.type==t.type||this.spec.multiType)){let r=this.spec.update(t,e,n);return r&&this.updateInner(t,e,n,o),r}return!(!this.contentDOM&&!t.isLeaf)&&super.update(t,e,n,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(t,e,n,o){this.spec.setSelection?this.spec.setSelection(t,e,n.root):super.setSelection(t,e,n,o)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(t){return!!this.spec.stopEvent&&this.spec.stopEvent(t)}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}}function Ln(t,e,n){let o=t.firstChild,r=!1;for(let i=0;i<e.length;i++){let s=e[i],l=s.dom;if(l.parentNode==t){for(;l!=o;)o=Fn(o),r=!0;o=o.nextSibling}else r=!0,t.insertBefore(l,o);if(s instanceof On){let e=o?o.previousSibling:t.lastChild;Ln(s.contentDOM,s.children,n),o=e?e.nextSibling:t.firstChild}}for(;o;)o=Fn(o),r=!0;r&&n.trackWrites==t&&(n.trackWrites=null)}const In=function(t){t&&(this.nodeName=t)};In.prototype=Object.create(null);const Pn=[new In];function zn(t,e,n){if(0==t.length)return Pn;let o=n?Pn[0]:new In,r=[o];for(let i=0;i<t.length;i++){let s=t[i].type.attrs;if(s){s.nodeName&&r.push(o=new In(s.nodeName));for(let t in s){let i=s[t];null!=i&&(n&&1==r.length&&r.push(o=new In(e.isInline?"span":"div")),"class"==t?o.class=(o.class?o.class+" ":"")+i:"style"==t?o.style=(o.style?o.style+";":"")+i:"nodeName"!=t&&(o[t]=i))}}}return r}function $n(t,e,n,o){if(n==Pn&&o==Pn)return e;let r=e;for(let e=0;e<o.length;e++){let i=o[e],s=n[e];if(e){let e;s&&s.nodeName==i.nodeName&&r!=t&&(e=r.parentNode)&&e.nodeName.toLowerCase()==i.nodeName||(e=document.createElement(i.nodeName),e.pmIsDeco=!0,e.appendChild(r),s=Pn[0]),r=e}Hn(r,s||Pn[0],i)}return r}function Hn(t,e,n){for(let o in e)"class"==o||"style"==o||"nodeName"==o||o in n||t.removeAttribute(o);for(let o in n)"class"!=o&&"style"!=o&&"nodeName"!=o&&n[o]!=e[o]&&t.setAttribute(o,n[o]);if(e.class!=n.class){let o=e.class?e.class.split(" ").filter(Boolean):[],r=n.class?n.class.split(" ").filter(Boolean):[];for(let e=0;e<o.length;e++)-1==r.indexOf(o[e])&&t.classList.remove(o[e]);for(let e=0;e<r.length;e++)-1==o.indexOf(r[e])&&t.classList.add(r[e]);0==t.classList.length&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let n,o=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;for(;n=o.exec(e.style);)t.style.removeProperty(n[1])}n.style&&(t.style.cssText+=n.style)}}function Bn(t,e,n){return $n(t,t,Pn,zn(e,n,1!=t.nodeType))}function _n(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 Fn(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class Vn{constructor(t,e,n){this.lock=e,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=t,this.preMatch=function(t,e){let n=e,o=n.children.length,r=t.childCount,i=new Map,s=[];t:for(;r>0;){let l;for(;;)if(o){let t=n.children[o-1];if(!(t instanceof On)){l=t,o--;break}n=t,o=t.children.length}else{if(n==e)break t;o=n.parent.children.indexOf(n),n=n.parent}let a=l.node;if(a){if(a!=t.child(r-1))break;--r,i.set(l,r),s.push(l)}}return{index:r,matched:i,matches:s.reverse()}}(t.node.content,t)}destroyBetween(t,e){if(t!=e){for(let n=t;n<e;n++)this.top.children[n].destroy();this.top.children.splice(t,e-t),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(t,e,n){let o=0,r=this.stack.length>>1,i=Math.min(r,t.length);for(;o<i&&(o==r-1?this.top:this.stack[o+1<<1]).matchesMark(t[o])&&!1!==t[o].type.spec.spanning;)o++;for(;o<r;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),r--;for(;r<t.length;){this.stack.push(this.top,this.index+1);let o=-1;for(let e=this.index;e<Math.min(this.index+3,this.top.children.length);e++){let n=this.top.children[e];if(n.matchesMark(t[r])&&!this.isLocked(n.dom)){o=e;break}}if(o>-1)o>this.index&&(this.changed=!0,this.destroyBetween(this.index,o)),this.top=this.top.children[this.index];else{let o=On.create(this.top,t[r],e,n);this.top.children.splice(this.index,0,o),this.top=o,this.changed=!0}this.index=0,r++}}findNodeMatch(t,e,n,o){let r,i=-1;if(o>=this.preMatch.index&&(r=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&r.matchesNode(t,e,n))i=this.top.children.indexOf(r,this.index);else for(let o=this.index,r=Math.min(this.top.children.length,o+5);o<r;o++){let r=this.top.children[o];if(r.matchesNode(t,e,n)&&!this.preMatch.matched.has(r)){i=o;break}}return!(i<0||(this.destroyBetween(this.index,i),this.index++,0))}updateNodeAt(t,e,n,o,r){let i=this.top.children[o];return 3==i.dirty&&i.dom==i.contentDOM&&(i.dirty=2),!!i.update(t,e,n,r)&&(this.destroyBetween(this.index,o),this.index++,!0)}findIndexWithChild(t){for(;;){let e=t.parentNode;if(!e)return-1;if(e==this.top.contentDOM){let e=t.pmViewDesc;if(e)for(let t=this.index;t<this.top.children.length;t++)if(this.top.children[t]==e)return t;return-1}t=e}}updateNextNode(t,e,n,o,r,i){for(let s=this.index;s<this.top.children.length;s++){let l=this.top.children[s];if(l instanceof En){let a=this.preMatch.matched.get(l);if(null!=a&&a!=r)return!1;let c,d=l.dom,h=this.isLocked(d)&&!(t.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==t.text&&3!=l.dirty&&_n(e,l.outerDeco));if(!h&&l.update(t,e,n,o))return this.destroyBetween(this.index,s),l.dom!=d&&(this.changed=!0),this.index++,!0;if(!h&&(c=this.recreateWrapper(l,t,e,n,o,i)))return this.destroyBetween(this.index,s),this.top.children[this.index]=c,c.contentDOM&&(c.dirty=2,c.updateChildren(o,i+1),c.dirty=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(t,e,n,o,r,i){if(t.dirty||e.isAtom||!t.children.length||!t.node.content.eq(e.content)||!_n(n,t.outerDeco)||!o.eq(t.innerDeco))return null;let s=En.create(this.top,e,n,o,r,i);if(s.contentDOM){s.children=t.children,t.children=[];for(let t of s.children)t.parent=s}return t.destroy(),s}addNode(t,e,n,o,r){let i=En.create(this.top,t,e,n,o,r);i.contentDOM&&i.updateChildren(o,r+1),this.top.children.splice(this.index++,0,i),this.changed=!0}placeWidget(t,e,n){let o=this.index<this.top.children.length?this.top.children[this.index]:null;if(!o||!o.matchesWidget(t)||t!=o.widget&&o.widget.type.toDOM.parentNode){let o=new Tn(this.top,t,e,n);this.top.children.splice(this.index++,0,o),this.changed=!0}else this.index++}addTextblockHacks(){let t=this.top.children[this.index-1],e=this.top;for(;t instanceof On;)e=t,t=e.children[e.children.length-1];(!t||!(t instanceof Dn)||/\n$/.test(t.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(t.node.text))&&((Ge||Je)&&t&&"false"==t.dom.contentEditable&&this.addHackNode("IMG",e),this.addHackNode("BR",this.top))}addHackNode(t,e){if(e==this.top&&this.index<e.children.length&&e.children[this.index].matchesHack(t))this.index++;else{let n=document.createElement(t);"IMG"==t&&(n.className="ProseMirror-separator",n.alt=""),"BR"==t&&(n.className="ProseMirror-trailingBreak");let o=new Rn(this.top,[],n,null);e!=this.top?e.children.push(o):e.children.splice(this.index++,0,o),this.changed=!0}}isLocked(t){return this.lock&&(t==this.lock||1==t.nodeType&&t.contains(this.lock.parentNode))}}function Wn(t,e){return t.type.side-e.type.side}function qn(t,e,n,o,r){let i=[];for(let s=0,l=0;s<t.length;s++){let a=t[s],c=l,d=l+=a.size;c>=n||d<=e?i.push(a):(c<e&&i.push(a.slice(0,e-c,o)),r&&(i.push(r),r=void 0),d>n&&i.push(a.slice(n-c,a.size,o)))}return i}function Kn(t,e=null){let n=t.domSelectionRange(),o=t.state.doc;if(!n.focusNode)return null;let r=t.docView.nearestDesc(n.focusNode),i=r&&0==r.size,s=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let l,a,c=o.resolve(s);if(Ie(n)){for(l=s;r&&!r.node;)r=r.parent;let t=r.node;if(r&&t.isAtom&&ce.isSelectable(t)&&r.parent&&(!t.isInline||!function(t,e,n){for(let o=0==e,r=e==je(t);o||r;){if(t==n)return!0;let e=Te(t);if(!(t=t.parentNode))return!1;o=o&&0==e,r=r&&e==je(t)}}(n.focusNode,n.focusOffset,r.dom))){let t=r.posBefore;a=new ce(s==t?c:o.resolve(t))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let e=s,r=s;for(let o=0;o<n.rangeCount;o++){let i=n.getRangeAt(o);e=Math.min(e,t.docView.posFromDOM(i.startContainer,i.startOffset,1)),r=Math.max(r,t.docView.posFromDOM(i.endContainer,i.endOffset,-1))}if(e<0)return null;[l,s]=r==t.state.selection.anchor?[r,e]:[e,r],c=o.resolve(s)}else l=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(l<0)return null}let d=o.resolve(l);return a||(a=eo(t,d,c,"pointer"==e||t.state.selection.head<c.pos&&!i?1:-1)),a}function Jn(t){return t.editable?t.hasFocus():oo(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Un(t,e=!1){let n=t.state.selection;if(Zn(t,n),Jn(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&Je){let e=t.domSelectionRange(),n=t.domObserver.currentSelection;if(e.anchorNode&&n.anchorNode&&Ne(e.anchorNode,e.anchorOffset,n.anchorNode,n.anchorOffset))return t.input.mouseDown.delayedSelectionSync=!0,void t.domObserver.setCurSelection()}if(t.domObserver.disconnectSelection(),t.cursorWrapper)!function(t){let e=t.domSelection(),n=document.createRange();if(!e)return;let o=t.cursorWrapper.dom,r="IMG"==o.nodeName;r?n.setStart(o.parentNode,Te(o)+1):n.setStart(o,0),n.collapse(!0),e.removeAllRanges(),e.addRange(n),!r&&!t.state.selection.visible&&Ve&&We<=11&&(o.disabled=!0,o.disabled=!1)}(t);else{let o,r,{anchor:i,head:s}=n;!Gn||n instanceof le||(n.$from.parent.inlineContent||(o=Yn(t,n.from)),n.empty||n.$from.parent.inlineContent||(r=Yn(t,n.to))),t.docView.setSelection(i,s,t,e),Gn&&(o&&Qn(o),r&&Qn(r)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),o=n.anchorNode,r=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{n.anchorNode==o&&n.anchorOffset==r||(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout((()=>{Jn(t)&&!t.state.selection.visible||t.dom.classList.remove("ProseMirror-hideselection")}),20))})}(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const Gn=Ge||Je&&Ue<63;function Yn(t,e){let{node:n,offset:o}=t.docView.domFromPos(e,0),r=o<n.childNodes.length?n.childNodes[o]:null,i=o?n.childNodes[o-1]:null;if(Ge&&r&&"false"==r.contentEditable)return Xn(r);if(!(r&&"false"!=r.contentEditable||i&&"false"!=i.contentEditable)){if(r)return Xn(r);if(i)return Xn(i)}}function Xn(t){return t.contentEditable="true",Ge&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function Qn(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function Zn(t,e){if(e instanceof ce){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(to(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else to(t)}function to(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function eo(t,e,n,o){return t.someProp("createSelectionBetween",(o=>o(t,e,n)))||le.between(e,n,o)}function no(t){return!(t.editable&&!t.hasFocus())&&oo(t)}function oo(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(3==e.anchorNode.nodeType?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(3==e.focusNode.nodeType?e.focusNode.parentNode:e.focusNode))}catch(t){return!1}}function ro(t,e){let{$anchor:n,$head:o}=t.selection,r=e>0?n.max(o):n.min(o),i=r.parent.inlineContent?r.depth?t.doc.resolve(e>0?r.after():r.before()):null:r;return i&&oe.findFrom(i,e)}function io(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function so(t,e,n){let o=t.state.selection;if(!(o instanceof le)){if(o instanceof ce&&o.node.isInline)return io(t,new le(e>0?o.$to:o.$from));{let n=ro(t.state,e);return!!n&&io(t,n)}}if(n.indexOf("s")>-1){let{$head:n}=o,r=n.textOffset?null:e<0?n.nodeBefore:n.nodeAfter;if(!r||r.isText||!r.isLeaf)return!1;let i=t.state.doc.resolve(n.pos+r.nodeSize*(e<0?-1:1));return io(t,new le(o.$anchor,i))}if(!o.empty)return!1;if(t.endOfTextblock(e>0?"forward":"backward")){let n=ro(t.state,e);return!!(n&&n instanceof ce)&&io(t,n)}if(!(Xe&&n.indexOf("m")>-1)){let n,r=o.$head,i=r.textOffset?null:e<0?r.nodeBefore:r.nodeAfter;if(!i||i.isText)return!1;let s=e<0?r.pos-i.nodeSize:r.pos;return!!(i.isAtom||(n=t.docView.descAt(s))&&!n.contentDOM)&&(ce.isSelectable(i)?io(t,new ce(e<0?t.state.doc.resolve(r.pos-i.nodeSize):r)):!!tn&&io(t,new le(t.state.doc.resolve(e<0?s:s+i.nodeSize))))}}function lo(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function ao(t,e){let n=t.pmViewDesc;return n&&0==n.size&&(e<0||t.nextSibling||"BR"!=t.nodeName)}function co(t,e){return e<0?function(t){let e=t.domSelectionRange(),n=e.focusNode,o=e.focusOffset;if(!n)return;let r,i,s=!1;for(qe&&1==n.nodeType&&o<lo(n)&&ao(n.childNodes[o],-1)&&(s=!0);;)if(o>0){if(1!=n.nodeType)break;{let t=n.childNodes[o-1];if(ao(t,-1))r=n,i=--o;else{if(3!=t.nodeType)break;n=t,o=n.nodeValue.length}}}else{if(ho(n))break;{let e=n.previousSibling;for(;e&&ao(e,-1);)r=n.parentNode,i=Te(e),e=e.previousSibling;if(e)n=e,o=lo(n);else{if(n=n.parentNode,n==t.dom)break;o=0}}}s?po(t,n,o):r&&po(t,r,i)}(t):function(t){let e=t.domSelectionRange(),n=e.focusNode,o=e.focusOffset;if(!n)return;let r,i,s=lo(n);for(;;)if(o<s){if(1!=n.nodeType)break;if(!ao(n.childNodes[o],1))break;r=n,i=++o}else{if(ho(n))break;{let e=n.nextSibling;for(;e&&ao(e,1);)r=e.parentNode,i=Te(e)+1,e=e.nextSibling;if(e)n=e,o=0,s=lo(n);else{if(n=n.parentNode,n==t.dom)break;o=s=0}}}r&&po(t,r,i)}(t)}function ho(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function po(t,e,n){if(3!=e.nodeType){let t,o;(o=function(t,e){for(;t&&e==t.childNodes.length&&!Le(t);)e=Te(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;t=n,e=0}}(e,n))?(e=o,n=0):(t=function(t,e){for(;t&&!e&&!Le(t);)e=Te(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;e=(t=n).childNodes.length}}(e,n))&&(e=t,n=t.nodeValue.length)}let o=t.domSelection();if(!o)return;if(Ie(o)){let t=document.createRange();t.setEnd(e,n),t.setStart(e,n),o.removeAllRanges(),o.addRange(t)}else o.extend&&o.extend(e,n);t.domObserver.setCurSelection();let{state:r}=t;setTimeout((()=>{t.state==r&&Un(t)}),50)}function uo(t,e){let n=t.state.doc.resolve(e);if(!Je&&!Qe&&n.parent.inlineContent){let o=t.coordsAtPos(e);if(e>n.start()){let n=t.coordsAtPos(e-1),r=(n.top+n.bottom)/2;if(r>o.top&&r<o.bottom&&Math.abs(n.left-o.left)>1)return n.left<o.left?"ltr":"rtl"}if(e<n.end()){let n=t.coordsAtPos(e+1),r=(n.top+n.bottom)/2;if(r>o.top&&r<o.bottom&&Math.abs(n.left-o.left)>1)return n.left>o.left?"ltr":"rtl"}}return"rtl"==getComputedStyle(t.dom).direction?"rtl":"ltr"}function fo(t,e,n){let o=t.state.selection;if(o instanceof le&&!o.empty||n.indexOf("s")>-1)return!1;if(Xe&&n.indexOf("m")>-1)return!1;let{$from:r,$to:i}=o;if(!r.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let n=ro(t.state,e);if(n&&n instanceof ce)return io(t,n)}if(!r.parent.inlineContent){let n=e<0?r:i,s=o instanceof he?oe.near(n,e):oe.findFrom(n,e);return!!s&&io(t,s)}return!1}function mo(t,e){if(!(t.state.selection instanceof le))return!0;let{$head:n,$anchor:o,empty:r}=t.state.selection;if(!n.sameParent(o))return!0;if(!r)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let o=t.state.tr;return e<0?o.delete(n.pos-i.nodeSize,n.pos):o.delete(n.pos,n.pos+i.nodeSize),t.dispatch(o),!0}return!1}function go(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function yo(t,e){t.someProp("transformCopied",(n=>{e=n(e,t)}));let n=[],{content:o,openStart:r,openEnd:i}=e;for(;r>1&&i>1&&1==o.childCount&&1==o.firstChild.childCount;){r--,i--;let t=o.firstChild;n.push(t.type.name,t.attrs!=t.type.defaultAttrs?t.attrs:null),o=t.content}let s=t.someProp("clipboardSerializer")||ct.fromSchema(t.state.schema),l=Ao(),a=l.createElement("div");a.appendChild(s.serializeFragment(o,{document:l}));let c,d=a.firstChild,h=0;for(;d&&1==d.nodeType&&(c=So[d.nodeName.toLowerCase()]);){for(let t=c.length-1;t>=0;t--){let e=l.createElement(c[t]);for(;a.firstChild;)e.appendChild(a.firstChild);a.appendChild(e),h++}d=a.firstChild}return d&&1==d.nodeType&&d.setAttribute("data-pm-slice",`${r} ${i}${h?` -${h}`:""} ${JSON.stringify(n)}`),{dom:a,text:t.someProp("clipboardTextSerializer",(n=>n(e,t)))||e.content.textBetween(0,e.content.size,"\n\n"),slice:e}}function bo(t,e,n,o,r){let i,s,l=r.parent.type.spec.code;if(!n&&!e)return null;let c=e&&(o||l||!n);if(c){if(t.someProp("transformPastedText",(n=>{e=n(e,l||o,t)})),l)return e?new f(a.from(t.state.schema.text(e.replace(/\r\n?/g,"\n"))),0,0):f.empty;let n=t.someProp("clipboardTextParser",(n=>n(e,r,o,t)));if(n)s=n;else{let n=r.marks(),{schema:o}=t.state,s=ct.fromSchema(o);i=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach((t=>{let e=i.appendChild(document.createElement("p"));t&&e.appendChild(s.serializeNode(o.text(t,n)))}))}}else t.someProp("transformPastedHTML",(e=>{n=e(n,t)})),i=function(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n,o=Ao().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t);if((n=r&&So[r[1].toLowerCase()])&&(t=n.map((t=>"<"+t+">")).join("")+t+n.map((t=>"</"+t+">")).reverse().join("")),o.innerHTML=function(t){let e=window.trustedTypes;return e?(Oo||(Oo=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),Oo.createHTML(t)):t}(t),n)for(let t=0;t<n.length;t++)o=o.querySelector(n[t])||o;return o}(n),tn&&function(t){let e=t.querySelectorAll(Je?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let o=e[n];1==o.childNodes.length&&" "==o.textContent&&o.parentNode&&o.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),o)}}(i);let d=i&&i.querySelector("[data-pm-slice]"),h=d&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(d.getAttribute("data-pm-slice")||"");if(h&&h[3])for(let t=+h[3];t>0;t--){let t=i.firstChild;for(;t&&1!=t.nodeType;)t=t.nextSibling;if(!t)break;i=t}if(!s){let e=t.someProp("clipboardParser")||t.someProp("domParser")||Z.fromSchema(t.state.schema);s=e.parseSlice(i,{preserveWhitespace:!(!c&&!h),context:r,ruleFromNode:t=>"BR"!=t.nodeName||t.nextSibling||!t.parentNode||vo.test(t.parentNode.nodeName)?null:{ignore:!0}})}if(h)s=function(t,e){if(!t.size)return t;let n,o=t.content.firstChild.type.schema;try{n=JSON.parse(e)}catch(e){return t}let{content:r,openStart:i,openEnd:s}=t;for(let t=n.length-2;t>=0;t-=2){let e=o.nodes[n[t]];if(!e||e.hasRequiredAttrs())break;r=a.from(e.create(n[t+1],r)),i++,s++}return new f(r,i,s)}(Co(s,+h[1],+h[2]),h[4]);else if(s=f.maxOpen(function(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let o,r=e.node(n).contentMatchAt(e.index(n)),i=[];if(t.forEach((t=>{if(!i)return;let e,n=r.findWrapping(t.type);if(!n)return i=null;if(e=i.length&&o.length&&ko(n,o,t,i[i.length-1],0))i[i.length-1]=e;else{i.length&&(i[i.length-1]=xo(i[i.length-1],o.length));let e=wo(t,n);i.push(e),r=r.matchType(e.type),o=n}})),i)return a.from(i)}return t}(s.content,r),!0),s.openStart||s.openEnd){let t=0,e=0;for(let e=s.content.firstChild;t<s.openStart&&!e.type.spec.isolating;t++,e=e.firstChild);for(let t=s.content.lastChild;e<s.openEnd&&!t.type.spec.isolating;e++,t=t.lastChild);s=Co(s,t,e)}return t.someProp("transformPasted",(e=>{s=e(s,t)})),s}const vo=/^(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 wo(t,e,n=0){for(let o=e.length-1;o>=n;o--)t=e[o].create(null,a.from(t));return t}function ko(t,e,n,o,r){if(r<t.length&&r<e.length&&t[r]==e[r]){let i=ko(t,e,n,o.lastChild,r+1);if(i)return o.copy(o.content.replaceChild(o.childCount-1,i));if(o.contentMatchAt(o.childCount).matchType(r==t.length-1?n.type:t[r+1]))return o.copy(o.content.append(a.from(wo(n,t,r+1))))}}function xo(t,e){if(0==e)return t;let n=t.content.replaceChild(t.childCount-1,xo(t.lastChild,e-1)),o=t.contentMatchAt(t.childCount).fillBefore(a.empty,!0);return t.copy(n.append(o))}function Mo(t,e,n,o,r,i){let s=e<0?t.firstChild:t.lastChild,l=s.content;return t.childCount>1&&(i=0),r<o-1&&(l=Mo(l,e,n,o,r+1,i)),r>=n&&(l=e<0?s.contentMatchAt(0).fillBefore(l,i<=r).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(a.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,s.copy(l))}function Co(t,e,n){return e<t.openStart&&(t=new f(Mo(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new f(Mo(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const So={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let To=null;function Ao(){return To||(To=document.implementation.createHTMLDocument("title"))}let Oo=null;const Eo={},No={},Do={touchstart:!0,touchmove:!0};class Ro{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function jo(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function Lo(t){t.someProp("handleDOMEvents",(e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=e=>Io(t,e))}))}function Io(t,e){return t.someProp("handleDOMEvents",(n=>{let o=n[e.type];return!!o&&(o(t,e)||e.defaultPrevented)}))}function Po(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function zo(t){return{left:t.clientX,top:t.clientY}}function $o(t,e,n,o,r){if(-1==o)return!1;let i=t.state.doc.resolve(o);for(let o=i.depth+1;o>0;o--)if(t.someProp(e,(e=>o>i.depth?e(t,n,i.nodeAfter,i.before(o),r,!0):e(t,n,i.node(o),i.before(o),r,!1))))return!0;return!1}function Ho(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let o=t.state.tr.setSelection(e);"pointer"==n&&o.setMeta("pointer",!0),t.dispatch(o)}function Bo(t,e,n,o){return $o(t,"handleDoubleClickOn",e,n,o)||t.someProp("handleDoubleClick",(n=>n(t,e,o)))}function _o(t,e,n,o){return $o(t,"handleTripleClickOn",e,n,o)||t.someProp("handleTripleClick",(n=>n(t,e,o)))||function(t,e,n){if(0!=n.button)return!1;let o=t.state.doc;if(-1==e)return!!o.inlineContent&&(Ho(t,le.create(o,0,o.content.size),"pointer"),!0);let r=o.resolve(e);for(let e=r.depth+1;e>0;e--){let n=e>r.depth?r.nodeAfter:r.node(e),i=r.before(e);if(n.inlineContent)Ho(t,le.create(o,i+1,i+1+n.content.size),"pointer");else{if(!ce.isSelectable(n))continue;Ho(t,ce.create(o,i),"pointer")}return!0}}(t,n,o)}function Fo(t){return Go(t)}No.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=16==n.keyCode||n.shiftKey,!qo(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!Ze||!Je||13!=n.keyCode))if(229!=n.keyCode&&t.domObserver.forceFlush(),!Ye||13!=n.keyCode||n.ctrlKey||n.altKey||n.metaKey)t.someProp("handleKeyDown",(e=>e(t,n)))||function(t,e){let n=e.keyCode,o=function(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}(e);if(8==n||Xe&&72==n&&"c"==o)return mo(t,-1)||co(t,-1);if(46==n&&!e.shiftKey||Xe&&68==n&&"c"==o)return mo(t,1)||co(t,1);if(13==n||27==n)return!0;if(37==n||Xe&&66==n&&"c"==o){let e=37==n?"ltr"==uo(t,t.state.selection.from)?-1:1:-1;return so(t,e,o)||co(t,e)}if(39==n||Xe&&70==n&&"c"==o){let e=39==n?"ltr"==uo(t,t.state.selection.from)?1:-1:1;return so(t,e,o)||co(t,e)}return 38==n||Xe&&80==n&&"c"==o?fo(t,-1,o)||co(t,-1):40==n||Xe&&78==n&&"c"==o?function(t){if(!Ge||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&1==e.nodeType&&0==n&&e.firstChild&&"false"==e.firstChild.contentEditable){let n=e.firstChild;go(t,n,"true"),setTimeout((()=>go(t,n,"false")),20)}return!1}(t)||fo(t,1,o)||co(t,1):o==(Xe?"m":"c")&&(66==n||73==n||89==n||90==n)}(t,n)?n.preventDefault():jo(t,"key");else{let e=Date.now();t.input.lastIOSEnter=e,t.input.lastIOSEnterFallbackTimeout=setTimeout((()=>{t.input.lastIOSEnter==e&&(t.someProp("handleKeyDown",(e=>e(t,Pe(13,"Enter")))),t.input.lastIOSEnter=0)}),200)}},No.keyup=(t,e)=>{16==e.keyCode&&(t.input.shiftKey=!1)},No.keypress=(t,e)=>{let n=e;if(qo(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Xe&&n.metaKey)return;if(t.someProp("handleKeyPress",(e=>e(t,n))))return void n.preventDefault();let o=t.state.selection;if(!(o instanceof le&&o.$from.sameParent(o.$to))){let e=String.fromCharCode(n.charCode);/[\r\n]/.test(e)||t.someProp("handleTextInput",(n=>n(t,o.$from.pos,o.$to.pos,e)))||t.dispatch(t.state.tr.insertText(e).scrollIntoView()),n.preventDefault()}};const Vo=Xe?"metaKey":"ctrlKey";Eo.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let o=Fo(t),r=Date.now(),i="singleClick";r-t.input.lastClick.time<500&&function(t,e){let n=e.x-t.clientX,o=e.y-t.clientY;return n*n+o*o<100}(n,t.input.lastClick)&&!n[Vo]&&("singleClick"==t.input.lastClick.type?i="doubleClick":"doubleClick"==t.input.lastClick.type&&(i="tripleClick")),t.input.lastClick={time:r,x:n.clientX,y:n.clientY,type:i};let s=t.posAtCoords(zo(n));s&&("singleClick"==i?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new Wo(t,s,n,!!o)):("doubleClick"==i?Bo:_o)(t,s.pos,s.inside,n)?n.preventDefault():jo(t,"pointer"))};class Wo{constructor(t,e,n,o){let r,i;if(this.view=t,this.pos=e,this.event=n,this.flushed=o,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=t.state.doc,this.selectNode=!!n[Vo],this.allowDefault=n.shiftKey,e.inside>-1)r=t.state.doc.nodeAt(e.inside),i=e.inside;else{let n=t.state.doc.resolve(e.pos);r=n.parent,i=n.depth?n.before():0}const s=o?null:n.target,l=s?t.docView.nearestDesc(s,!0):null;this.target=l&&1==l.dom.nodeType?l.dom:null;let{selection:a}=t.state;(0==n.button&&r.type.spec.draggable&&!1!==r.type.spec.selectable||a instanceof ce&&a.from<=i&&a.to>i)&&(this.mightDrag={node:r,pos:i,addAttr:!(!this.target||this.target.draggable),setUneditable:!(!this.target||!qe||this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout((()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")}),20),this.view.domObserver.start()),t.root.addEventListener("mouseup",this.up=this.up.bind(this)),t.root.addEventListener("mousemove",this.move=this.move.bind(this)),jo(t,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout((()=>Un(this.view))),this.view.input.mouseDown=null}up(t){if(this.done(),!this.view.dom.contains(t.target))return;let e=this.pos;this.view.state.doc!=this.startDoc&&(e=this.view.posAtCoords(zo(t))),this.updateAllowDefault(t),this.allowDefault||!e?jo(this.view,"pointer"):function(t,e,n,o,r){return $o(t,"handleClickOn",e,n,o)||t.someProp("handleClick",(n=>n(t,e,o)))||(r?function(t,e){if(-1==e)return!1;let n,o,r=t.state.selection;r instanceof ce&&(n=r.node);let i=t.state.doc.resolve(e);for(let t=i.depth+1;t>0;t--){let e=t>i.depth?i.nodeAfter:i.node(t);if(ce.isSelectable(e)){o=n&&r.$from.depth>0&&t>=r.$from.depth&&i.before(r.$from.depth+1)==r.$from.pos?i.before(r.$from.depth):i.before(t);break}}return null!=o&&(Ho(t,ce.create(t.state.doc,o),"pointer"),!0)}(t,n):function(t,e){if(-1==e)return!1;let n=t.state.doc.resolve(e),o=n.nodeAfter;return!!(o&&o.isAtom&&ce.isSelectable(o))&&(Ho(t,new ce(n),"pointer"),!0)}(t,n))}(this.view,e.pos,e.inside,t,this.selectNode)?t.preventDefault():0==t.button&&(this.flushed||Ge&&this.mightDrag&&!this.mightDrag.node.isAtom||Je&&!this.view.state.selection.visible&&Math.min(Math.abs(e.pos-this.view.state.selection.from),Math.abs(e.pos-this.view.state.selection.to))<=2)?(Ho(this.view,oe.near(this.view.state.doc.resolve(e.pos)),"pointer"),t.preventDefault()):jo(this.view,"pointer")}move(t){this.updateAllowDefault(t),jo(this.view,"pointer"),0==t.buttons&&this.done()}updateAllowDefault(t){!this.allowDefault&&(Math.abs(this.event.x-t.clientX)>4||Math.abs(this.event.y-t.clientY)>4)&&(this.allowDefault=!0)}}function qo(t,e){return!!t.composing||!!(Ge&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500)&&(t.input.compositionEndedAt=-2e8,!0)}Eo.touchstart=t=>{t.input.lastTouch=Date.now(),Fo(t),jo(t,"pointer")},Eo.touchmove=t=>{t.input.lastTouch=Date.now(),jo(t,"pointer")},Eo.contextmenu=t=>Fo(t);const Ko=Ze?5e3:-1;function Jo(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout((()=>Go(t)),e))}function Uo(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=function(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function Go(t,e=!1){if(!(Ze&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),Uo(t),e||t.docView&&t.docView.dirty){let n=Kn(t);return n&&!n.eq(t.state.selection)?t.dispatch(t.state.tr.setSelection(n)):!t.markCursor&&!e||t.state.selection.empty?t.updateState(t.state):t.dispatch(t.state.tr.deleteSelection()),!0}return!1}}No.compositionstart=No.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof le&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some((t=>!1===t.type.spec.inclusive))))t.markCursor=t.state.storedMarks||n.marks(),Go(t,!0),t.markCursor=null;else if(Go(t,!e.selection.empty),qe&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let e=t.domSelectionRange();for(let n=e.focusNode,o=e.focusOffset;n&&1==n.nodeType&&0!=o;){let e=o<0?n.lastChild:n.childNodes[o-1];if(!e)break;if(3==e.nodeType){let n=t.domSelection();n&&n.collapse(e,e.nodeValue.length);break}n=e,o=-1}}t.input.composing=!0}Jo(t,Ko)},No.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.compositionPendingChanges&&Promise.resolve().then((()=>t.domObserver.flush())),t.input.compositionID++,Jo(t,20))};const Yo=Ve&&We<15||Ye&&en<604;function Xo(t,e,n,o,r){let i=bo(t,e,n,o,t.state.selection.$from);if(t.someProp("handlePaste",(e=>e(t,r,i||f.empty))))return!0;if(!i)return!1;let s=function(t){return 0==t.openStart&&0==t.openEnd&&1==t.content.childCount?t.content.firstChild:null}(i),l=s?t.state.tr.replaceSelectionWith(s,o):t.state.tr.replaceSelection(i);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Qo(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," "):""}Eo.copy=No.cut=(t,e)=>{let n=e,o=t.state.selection,r="cut"==n.type;if(o.empty)return;let i=Yo?null:n.clipboardData,s=o.content(),{dom:l,text:a}=yo(t,s);i?(n.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):function(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let o=getSelection(),r=document.createRange();r.selectNodeContents(e),t.dom.blur(),o.removeAllRanges(),o.addRange(r),setTimeout((()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()}),50)}(t,l),r&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},No.paste=(t,e)=>{let n=e;if(t.composing&&!Ze)return;let o=Yo?null:n.clipboardData,r=t.input.shiftKey&&45!=t.input.lastKeyCode;o&&Xo(t,Qo(o),o.getData("text/html"),r,n)?n.preventDefault():function(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,o=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(o.contentEditable="true"),o.style.cssText="position: fixed; left: -10000px; top: 10px",o.focus();let r=t.input.shiftKey&&45!=t.input.lastKeyCode;setTimeout((()=>{t.focus(),o.parentNode&&o.parentNode.removeChild(o),n?Xo(t,o.value,null,r,e):Xo(t,o.textContent,o.innerHTML,r,e)}),50)}(t,n)};class Zo{constructor(t,e,n){this.slice=t,this.move=e,this.node=n}}const tr=Xe?"altKey":"ctrlKey";Eo.dragstart=(t,e)=>{let n=e,o=t.input.mouseDown;if(o&&o.done(),!n.dataTransfer)return;let r,i=t.state.selection,s=i.empty?null:t.posAtCoords(zo(n));if(s&&s.pos>=i.from&&s.pos<=(i instanceof ce?i.to-1:i.to));else if(o&&o.mightDrag)r=ce.create(t.state.doc,o.mightDrag.pos);else if(n.target&&1==n.target.nodeType){let e=t.docView.nearestDesc(n.target,!0);e&&e.node.type.spec.draggable&&e!=t.docView&&(r=ce.create(t.state.doc,e.posBefore))}let l=(r||t.state.selection).content(),{dom:a,text:c,slice:d}=yo(t,l);(!n.dataTransfer.files.length||!Je||Ue>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Yo?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",Yo||n.dataTransfer.setData("text/plain",c),t.dragging=new Zo(d,!n[tr],r)},Eo.dragend=t=>{let e=t.dragging;window.setTimeout((()=>{t.dragging==e&&(t.dragging=null)}),50)},No.dragover=No.dragenter=(t,e)=>e.preventDefault(),No.drop=(t,e)=>{let n=e,o=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let r=t.posAtCoords(zo(n));if(!r)return;let i=t.state.doc.resolve(r.pos),s=o&&o.slice;s?t.someProp("transformPasted",(e=>{s=e(s,t)})):s=bo(t,Qo(n.dataTransfer),Yo?null:n.dataTransfer.getData("text/html"),!1,i);let l=!(!o||n[tr]);if(t.someProp("handleDrop",(e=>e(t,n,s||f.empty,l))))return void n.preventDefault();if(!s)return;n.preventDefault();let a=s?_t(t.state.doc,i.pos,s):i.pos;null==a&&(a=i.pos);let c=t.state.tr;if(l){let{node:t}=o;t?t.replace(c):c.deleteSelection()}let d=c.mapping.map(a),h=0==s.openStart&&0==s.openEnd&&1==s.content.childCount,p=c.doc;if(h?c.replaceRangeWith(d,d,s.content.firstChild):c.replaceRange(d,d,s),c.doc.eq(p))return;let u=c.doc.resolve(d);if(h&&ce.isSelectable(s.content.firstChild)&&u.nodeAfter&&u.nodeAfter.sameMarkup(s.content.firstChild))c.setSelection(new ce(u));else{let e=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach(((t,n,o,r)=>e=r)),c.setSelection(eo(t,u,c.doc.resolve(e)))}t.focus(),t.dispatch(c.setMeta("uiEvent","drop"))},Eo.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())&&Un(t)}),20))},Eo.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)},Eo.beforeinput=(t,e)=>{if(Je&&Ze&&"deleteContentBackward"==e.inputType){t.domObserver.flushSoon();let{domChangeCount:e}=t.input;setTimeout((()=>{if(t.input.domChangeCount!=e)return;if(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",(e=>e(t,Pe(8,"Backspace")))))return;let{$cursor:n}=t.state.selection;n&&n.pos>0&&t.dispatch(t.state.tr.delete(n.pos-1,n.pos).scrollIntoView())}),50)}};for(let t in No)Eo[t]=No[t];function er(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class nr{constructor(t,e){this.toDOM=t,this.spec=e||lr,this.side=this.spec.side||0}map(t,e,n,o){let{pos:r,deleted:i}=t.mapResult(e.from+o,this.side<0?-1:1);return i?null:new ir(r-n,r-n,this)}valid(){return!0}eq(t){return this==t||t instanceof nr&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&er(this.spec,t.spec))}destroy(t){this.spec.destroy&&this.spec.destroy(t)}}class or{constructor(t,e){this.attrs=t,this.spec=e||lr}map(t,e,n,o){let r=t.map(e.from+o,this.spec.inclusiveStart?-1:1)-n,i=t.map(e.to+o,this.spec.inclusiveEnd?1:-1)-n;return r>=i?null:new ir(r,i,this)}valid(t,e){return e.from<e.to}eq(t){return this==t||t instanceof or&&er(this.attrs,t.attrs)&&er(this.spec,t.spec)}static is(t){return t.type instanceof or}destroy(){}}class rr{constructor(t,e){this.attrs=t,this.spec=e||lr}map(t,e,n,o){let r=t.mapResult(e.from+o,1);if(r.deleted)return null;let i=t.mapResult(e.to+o,-1);return i.deleted||i.pos<=r.pos?null:new ir(r.pos-n,i.pos-n,this)}valid(t,e){let n,{index:o,offset:r}=t.content.findIndex(e.from);return r==e.from&&!(n=t.child(o)).isText&&r+n.nodeSize==e.to}eq(t){return this==t||t instanceof rr&&er(this.attrs,t.attrs)&&er(this.spec,t.spec)}destroy(){}}class ir{constructor(t,e,n){this.from=t,this.to=e,this.type=n}copy(t,e){return new ir(t,e,this.type)}eq(t,e=0){return this.type.eq(t.type)&&this.from+e==t.from&&this.to+e==t.to}map(t,e,n){return this.type.map(t,this,e,n)}static widget(t,e,n){return new ir(t,t,new nr(e,n))}static inline(t,e,n,o){return new ir(t,e,new or(n,o))}static node(t,e,n,o){return new ir(t,e,new rr(n,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof or}get widget(){return this.type instanceof nr}}const sr=[],lr={};class ar{constructor(t,e){this.local=t.length?t:sr,this.children=e.length?e:sr}static create(t,e){return e.length?fr(e,t,0,lr):cr}find(t,e,n){let o=[];return this.findInner(null==t?0:t,null==e?1e9:e,o,0,n),o}findInner(t,e,n,o,r){for(let i=0;i<this.local.length;i++){let s=this.local[i];s.from<=e&&s.to>=t&&(!r||r(s.spec))&&n.push(s.copy(s.from+o,s.to+o))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<e&&this.children[i+1]>t){let s=this.children[i]+1;this.children[i+2].findInner(t-s,e-s,n,o+s,r)}}map(t,e,n){return this==cr||0==t.maps.length?this:this.mapInner(t,e,0,0,n||lr)}mapInner(t,e,n,o,r){let i;for(let s=0;s<this.local.length;s++){let l=this.local[s].map(t,n,o);l&&l.type.valid(e,l)?(i||(i=[])).push(l):r.onRemove&&r.onRemove(this.local[s].spec)}return this.children.length?function(t,e,n,o,r,i,s){let l=t.slice();for(let t=0,e=i;t<n.maps.length;t++){let o=0;n.maps[t].forEach(((t,n,r,i)=>{let s=i-r-(n-t);for(let r=0;r<l.length;r+=3){let i=l[r+1];if(i<0||t>i+e-o)continue;let a=l[r]+e-o;n>=a?l[r+1]=t<=a?-2:-1:t>=e&&s&&(l[r]+=s,l[r+1]+=s)}o+=s})),e=n.maps[t].map(e,-1)}let a=!1;for(let e=0;e<l.length;e+=3)if(l[e+1]<0){if(-2==l[e+1]){a=!0,l[e+1]=-1;continue}let c=n.map(t[e]+i),d=c-r;if(d<0||d>=o.content.size){a=!0;continue}let h=n.map(t[e+1]+i,-1)-r,{index:p,offset:u}=o.content.findIndex(d),f=o.maybeChild(p);if(f&&u==d&&u+f.nodeSize==h){let o=l[e+2].mapInner(n,f,c+1,t[e]+i+1,s);o!=cr?(l[e]=d,l[e+1]=h,l[e+2]=o):(l[e+1]=-2,a=!0)}else a=!0}if(a){let a=function(t,e,n,o,r,i,s){function l(t,e){for(let i=0;i<t.local.length;i++){let l=t.local[i].map(o,r,e);l?n.push(l):s.onRemove&&s.onRemove(t.local[i].spec)}for(let n=0;n<t.children.length;n+=3)l(t.children[n+2],t.children[n]+e+1)}for(let n=0;n<t.length;n+=3)-1==t[n+1]&&l(t[n+2],e[n]+i+1);return n}(l,t,e,n,r,i,s),c=fr(a,o,0,s);e=c.local;for(let t=0;t<l.length;t+=3)l[t+1]<0&&(l.splice(t,3),t-=3);for(let t=0,e=0;t<c.children.length;t+=3){let n=c.children[t];for(;e<l.length&&l[e]<n;)e+=3;l.splice(e,0,c.children[t],c.children[t+1],c.children[t+2])}}return new ar(e.sort(mr),l)}(this.children,i||[],t,e,n,o,r):i?new ar(i.sort(mr),sr):cr}add(t,e){return e.length?this==cr?ar.create(t,e):this.addInner(t,e,0):this}addInner(t,e,n){let o,r=0;t.forEach(((t,i)=>{let s,l=i+n;if(s=pr(e,t,l)){for(o||(o=this.children.slice());r<o.length&&o[r]<i;)r+=3;o[r]==i?o[r+2]=o[r+2].addInner(t,s,l+1):o.splice(r,0,i,i+t.nodeSize,fr(s,t,l+1,lr)),r+=3}}));let i=hr(r?ur(e):e,-n);for(let e=0;e<i.length;e++)i[e].type.valid(t,i[e])||i.splice(e--,1);return new ar(i.length?this.local.concat(i).sort(mr):this.local,o||this.children)}remove(t){return 0==t.length||this==cr?this:this.removeInner(t,0)}removeInner(t,e){let n=this.children,o=this.local;for(let o=0;o<n.length;o+=3){let r,i=n[o]+e,s=n[o+1]+e;for(let e,n=0;n<t.length;n++)(e=t[n])&&e.from>i&&e.to<s&&(t[n]=null,(r||(r=[])).push(e));if(!r)continue;n==this.children&&(n=this.children.slice());let l=n[o+2].removeInner(r,i+1);l!=cr?n[o+2]=l:(n.splice(o,3),o-=3)}if(o.length)for(let n,r=0;r<t.length;r++)if(n=t[r])for(let t=0;t<o.length;t++)o[t].eq(n,e)&&(o==this.local&&(o=this.local.slice()),o.splice(t--,1));return n==this.children&&o==this.local?this:o.length||n.length?new ar(o,n):cr}forChild(t,e){if(this==cr)return this;if(e.isLeaf)return ar.empty;let n,o;for(let e=0;e<this.children.length;e+=3)if(this.children[e]>=t){this.children[e]==t&&(n=this.children[e+2]);break}let r=t+1,i=r+e.content.size;for(let t=0;t<this.local.length;t++){let e=this.local[t];if(e.from<i&&e.to>r&&e.type instanceof or){let t=Math.max(r,e.from)-r,n=Math.min(i,e.to)-r;t<n&&(o||(o=[])).push(e.copy(t,n))}}if(o){let t=new ar(o.sort(mr),sr);return n?new dr([t,n]):t}return n||cr}eq(t){if(this==t)return!0;if(!(t instanceof ar)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(let e=0;e<this.local.length;e++)if(!this.local[e].eq(t.local[e]))return!1;for(let e=0;e<this.children.length;e+=3)if(this.children[e]!=t.children[e]||this.children[e+1]!=t.children[e+1]||!this.children[e+2].eq(t.children[e+2]))return!1;return!0}locals(t){return gr(this.localsInner(t))}localsInner(t){if(this==cr)return sr;if(t.inlineContent||!this.local.some(or.is))return this.local;let e=[];for(let t=0;t<this.local.length;t++)this.local[t].type instanceof or||e.push(this.local[t]);return e}forEachSet(t){t(this)}}ar.empty=new ar([],[]),ar.removeOverlap=gr;const cr=ar.empty;class dr{constructor(t){this.members=t}map(t,e){const n=this.members.map((n=>n.map(t,e,lr)));return dr.from(n)}forChild(t,e){if(e.isLeaf)return ar.empty;let n=[];for(let o=0;o<this.members.length;o++){let r=this.members[o].forChild(t,e);r!=cr&&(r instanceof dr?n=n.concat(r.members):n.push(r))}return dr.from(n)}eq(t){if(!(t instanceof dr)||t.members.length!=this.members.length)return!1;for(let e=0;e<this.members.length;e++)if(!this.members[e].eq(t.members[e]))return!1;return!0}locals(t){let e,n=!0;for(let o=0;o<this.members.length;o++){let r=this.members[o].localsInner(t);if(r.length)if(e){n&&(e=e.slice(),n=!1);for(let t=0;t<r.length;t++)e.push(r[t])}else e=r}return e?gr(n?e:e.sort(mr)):sr}static from(t){switch(t.length){case 0:return cr;case 1:return t[0];default:return new dr(t.every((t=>t instanceof ar))?t:t.reduce(((t,e)=>t.concat(e instanceof ar?e:e.members)),[]))}}forEachSet(t){for(let e=0;e<this.members.length;e++)this.members[e].forEachSet(t)}}function hr(t,e){if(!e||!t.length)return t;let n=[];for(let o=0;o<t.length;o++){let r=t[o];n.push(new ir(r.from+e,r.to+e,r.type))}return n}function pr(t,e,n){if(e.isLeaf)return null;let o=n+e.nodeSize,r=null;for(let e,i=0;i<t.length;i++)(e=t[i])&&e.from>n&&e.to<o&&((r||(r=[])).push(e),t[i]=null);return r}function ur(t){let e=[];for(let n=0;n<t.length;n++)null!=t[n]&&e.push(t[n]);return e}function fr(t,e,n,o){let r=[],i=!1;e.forEach(((e,s)=>{let l=pr(t,e,s+n);if(l){i=!0;let t=fr(l,e,n+s+1,o);t!=cr&&r.push(s,s+e.nodeSize,t)}}));let s=hr(i?ur(t):t,-n).sort(mr);for(let t=0;t<s.length;t++)s[t].type.valid(e,s[t])||(o.onRemove&&o.onRemove(s[t].spec),s.splice(t--,1));return s.length||r.length?new ar(s,r):cr}function mr(t,e){return t.from-e.from||t.to-e.to}function gr(t){let e=t;for(let n=0;n<e.length-1;n++){let o=e[n];if(o.from!=o.to)for(let r=n+1;r<e.length;r++){let i=e[r];if(i.from!=o.from){i.from<o.to&&(e==t&&(e=t.slice()),e[n]=o.copy(o.from,i.from),yr(e,r,o.copy(i.from,o.to)));break}i.to!=o.to&&(e==t&&(e=t.slice()),e[r]=i.copy(i.from,o.to),yr(e,r+1,i.copy(o.to,i.to)))}}return e}function yr(t,e,n){for(;e<t.length&&mr(n,t[e])>0;)e++;t.splice(e,0,n)}function br(t){let e=[];return t.someProp("decorations",(n=>{let o=n(t.state);o&&o!=cr&&e.push(o)})),t.cursorWrapper&&e.push(ar.create(t.state.doc,[t.cursorWrapper.deco])),dr.from(e)}const vr={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},wr=Ve&&We<=11;class kr{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(t){this.anchorNode=t.anchorNode,this.anchorOffset=t.anchorOffset,this.focusNode=t.focusNode,this.focusOffset=t.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(t){return t.anchorNode==this.anchorNode&&t.anchorOffset==this.anchorOffset&&t.focusNode==this.focusNode&&t.focusOffset==this.focusOffset}}class xr{constructor(t,e){this.view=t,this.handleDOMChange=e,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new kr,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver((t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);Ve&&We<=11&&t.some((t=>"childList"==t.type&&t.removedNodes.length||"characterData"==t.type&&t.oldValue.length>t.target.nodeValue.length))?this.flushSoon():this.flush()})),wr&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout((()=>{this.flushingSoon=-1,this.flush()}),20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,vr)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let t=this.observer.takeRecords();if(t.length){for(let e=0;e<t.length;e++)this.queue.push(t[e]);window.setTimeout((()=>this.flush()),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout((()=>this.suppressingSelectionUpdates=!1),50)}onSelectionChange(){if(no(this.view)){if(this.suppressingSelectionUpdates)return Un(this.view);if(Ve&&We<=11&&!this.view.state.selection.empty){let t=this.view.domSelectionRange();if(t.focusNode&&Ne(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(t){if(!t.focusNode)return!0;let e,n=new Set;for(let e=t.focusNode;e;e=Ae(e))n.add(e);for(let o=t.anchorNode;o;o=Ae(o))if(n.has(o)){e=o;break}let o=e&&this.view.docView.nearestDesc(e);return o&&o.ignoreMutation({type:"selection",target:3==e.nodeType?e.parentNode:e})?(this.setCurSelection(),!0):void 0}pendingRecords(){if(this.observer)for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}flush(){let{view:t}=this;if(!t.docView||this.flushingSoon>-1)return;let e=this.pendingRecords();e.length&&(this.queue=[]);let n=t.domSelectionRange(),o=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&no(t)&&!this.ignoreSelectionChange(n),r=-1,i=-1,s=!1,l=[];if(t.editable)for(let t=0;t<e.length;t++){let n=this.registerMutation(e[t],l);n&&(r=r<0?n.from:Math.min(n.from,r),i=i<0?n.to:Math.max(n.to,i),n.typeOver&&(s=!0))}if(qe&&l.length){let e=l.filter((t=>"BR"==t.nodeName));if(2==e.length){let[t,n]=e;t.parentNode&&t.parentNode.parentNode==n.parentNode?n.remove():t.remove()}else{let{focusNode:n}=this.currentSelection;for(let o of e){let e=o.parentNode;!e||"LI"!=e.nodeName||n&&Tr(t,n)==e||o.remove()}}}let a=null;r<0&&o&&t.input.lastFocus>Date.now()-200&&Math.max(t.input.lastTouch,t.input.lastClick.time)<Date.now()-300&&Ie(n)&&(a=Kn(t))&&a.eq(oe.near(t.state.doc.resolve(0),1))?(t.input.lastFocus=0,Un(t),this.currentSelection.set(n),t.scrollToSelection()):(r>-1||o)&&(r>-1&&(t.docView.markDirty(r,i),function(t){if(!Mr.has(t)&&(Mr.set(t,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace))){if(t.requiresGeckoHackNode=qe,Cr)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."),Cr=!0}}(t)),this.handleDOMChange(r,i,s,l),t.docView&&t.docView.dirty?t.updateState(t.state):this.currentSelection.eq(n)||Un(t),this.currentSelection.set(n))}registerMutation(t,e){if(e.indexOf(t.target)>-1)return null;let n=this.view.docView.nearestDesc(t.target);if("attributes"==t.type&&(n==this.view.docView||"contenteditable"==t.attributeName||"style"==t.attributeName&&!t.oldValue&&!t.target.getAttribute("style")))return null;if(!n||n.ignoreMutation(t))return null;if("childList"==t.type){for(let n=0;n<t.addedNodes.length;n++){let o=t.addedNodes[n];e.push(o),3==o.nodeType&&(this.lastChangedTextNode=o)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(t.target))return{from:n.posBefore,to:n.posAfter};let o=t.previousSibling,r=t.nextSibling;if(Ve&&We<=11&&t.addedNodes.length)for(let e=0;e<t.addedNodes.length;e++){let{previousSibling:n,nextSibling:i}=t.addedNodes[e];(!n||Array.prototype.indexOf.call(t.addedNodes,n)<0)&&(o=n),(!i||Array.prototype.indexOf.call(t.addedNodes,i)<0)&&(r=i)}let i=o&&o.parentNode==t.target?Te(o)+1:0,s=n.localPosFromDOM(t.target,i,-1),l=r&&r.parentNode==t.target?Te(r):t.target.childNodes.length;return{from:s,to:n.localPosFromDOM(t.target,l,1)}}return"attributes"==t.type?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:(this.lastChangedTextNode=t.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:t.target.nodeValue==t.oldValue})}}let Mr=new WeakMap,Cr=!1;function Sr(t,e){let n=e.startContainer,o=e.startOffset,r=e.endContainer,i=e.endOffset,s=t.domAtPos(t.state.selection.anchor);return Ne(s.node,s.offset,r,i)&&([n,o,r,i]=[r,i,n,o]),{anchorNode:n,anchorOffset:o,focusNode:r,focusOffset:i}}function Tr(t,e){for(let n=e.parentNode;n&&n!=t.dom;n=n.parentNode){let e=t.docView.nearestDesc(n,!0);if(e&&e.node.isBlock)return n}return null}function Ar(t){let e=t.pmViewDesc;if(e)return e.parseRule();if("BR"==t.nodeName&&t.parentNode){if(Ge&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}if(t.parentNode.lastChild==t||Ge&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if("IMG"==t.nodeName&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const Or=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Er(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:eo(t,e.resolve(n.anchor),e.resolve(n.head))}function Nr(t,e,n){let o=t.depth,r=e?t.end():t.pos;for(;o>0&&(e||t.indexAfter(o)==t.node(o).childCount);)o--,r++,e=!1;if(n){let e=t.node(o).maybeChild(t.indexAfter(o));for(;e&&!e.isLeaf;)e=e.firstChild,r++}return r}function Dr(t){if(2!=t.length)return!1;let e=t.charCodeAt(0),n=t.charCodeAt(1);return e>=56320&&e<=57343&&n>=55296&&n<=56319}class Rr{constructor(t,e){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new Ro,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=e,this.state=e.state,this.directPlugins=e.plugins||[],this.directPlugins.forEach(zr),this.dispatch=this.dispatch.bind(this),this.dom=t&&t.mount||document.createElement("div"),t&&(t.appendChild?t.appendChild(this.dom):"function"==typeof t?t(this.dom):t.mount&&(this.mounted=!0)),this.editable=Ir(this),Lr(this),this.nodeViews=Pr(this),this.docView=Nn(this.state.doc,jr(this),br(this),this.dom,this),this.domObserver=new xr(this,((t,e,n,o)=>function(t,e,n,o,r){let i=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let e=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,n=Kn(t,e);if(n&&!t.state.selection.eq(n)){if(Je&&Ze&&13===t.input.lastKeyCode&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",(e=>e(t,Pe(13,"Enter")))))return;let o=t.state.tr.setSelection(n);"pointer"==e?o.setMeta("pointer",!0):"key"==e&&o.scrollIntoView(),i&&o.setMeta("composition",i),t.dispatch(o)}return}let s=t.state.doc.resolve(e),l=s.sharedDepth(n);e=s.before(l+1),n=t.state.doc.resolve(n).after(l+1);let c,d,h=t.state.selection,p=function(t,e,n){let o,{node:r,fromOffset:i,toOffset:s,from:l,to:a}=t.docView.parseRange(e,n),c=t.domSelectionRange(),d=c.anchorNode;if(d&&t.dom.contains(1==d.nodeType?d:d.parentNode)&&(o=[{node:d,offset:c.anchorOffset}],Ie(c)||o.push({node:c.focusNode,offset:c.focusOffset})),Je&&8===t.input.lastKeyCode)for(let t=s;t>i;t--){let e=r.childNodes[t-1],n=e.pmViewDesc;if("BR"==e.nodeName&&!n){s=t;break}if(!n||n.size)break}let h=t.state.doc,p=t.someProp("domParser")||Z.fromSchema(t.state.schema),u=h.resolve(l),f=null,m=p.parse(r,{topNode:u.parent,topMatch:u.parent.contentMatchAt(u.index()),topOpen:!0,from:i,to:s,preserveWhitespace:"pre"!=u.parent.type.whitespace||"full",findPositions:o,ruleFromNode:Ar,context:u});if(o&&null!=o[0].pos){let t=o[0].pos,e=o[1]&&o[1].pos;null==e&&(e=t),f={anchor:t+l,head:e+l}}return{doc:m,sel:f,from:l,to:a}}(t,e,n),u=t.state.doc,f=u.slice(p.from,p.to);8===t.input.lastKeyCode&&Date.now()-100<t.input.lastKeyCodeTime?(c=t.state.selection.to,d="end"):(c=t.state.selection.from,d="start"),t.input.lastKeyCode=null;let m=function(t,e,n,o,r){let i=t.findDiffStart(e,n);if(null==i)return null;let{a:s,b:l}=t.findDiffEnd(e,n+t.size,n+e.size);if("end"==r&&(o-=s+Math.max(0,i-Math.min(s,l))-i),s<i&&t.size<e.size){let t=o<=i&&o>=s?i-o:0;i-=t,i&&i<e.size&&Dr(e.textBetween(i-1,i+1))&&(i+=t?1:-1),l=i+(l-s),s=i}else if(l<i){let e=o<=i&&o>=l?i-o:0;i-=e,i&&i<t.size&&Dr(t.textBetween(i-1,i+1))&&(i+=e?1:-1),s=i+(s-l),l=i}return{start:i,endA:s,endB:l}}(f.content,p.doc.content,p.from,c,d);if(m&&t.input.domChangeCount++,(Ye&&t.input.lastIOSEnter>Date.now()-225||Ze)&&r.some((t=>1==t.nodeType&&!Or.test(t.nodeName)))&&(!m||m.endA>=m.endB)&&t.someProp("handleKeyDown",(e=>e(t,Pe(13,"Enter")))))return void(t.input.lastIOSEnter=0);if(!m){if(!(o&&h instanceof le&&!h.empty&&h.$head.sameParent(h.$anchor))||t.composing||p.sel&&p.sel.anchor!=p.sel.head){if(p.sel){let e=Er(t,t.state.doc,p.sel);if(e&&!e.eq(t.state.selection)){let n=t.state.tr.setSelection(e);i&&n.setMeta("composition",i),t.dispatch(n)}}return}m={start:h.from,endA:h.to,endB:h.to}}t.state.selection.from<t.state.selection.to&&m.start==m.endB&&t.state.selection instanceof le&&(m.start>t.state.selection.from&&m.start<=t.state.selection.from+2&&t.state.selection.from>=p.from?m.start=t.state.selection.from:m.endA<t.state.selection.to&&m.endA>=t.state.selection.to-2&&t.state.selection.to<=p.to&&(m.endB+=t.state.selection.to-m.endA,m.endA=t.state.selection.to)),Ve&&We<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>p.from&&"  "==p.doc.textBetween(m.start-p.from-1,m.start-p.from+1)&&(m.start--,m.endA--,m.endB--);let g,y=p.doc.resolveNoCache(m.start-p.from),b=p.doc.resolveNoCache(m.endB-p.from),v=u.resolve(m.start),w=y.sameParent(b)&&y.parent.inlineContent&&v.end()>=m.endA;if((Ye&&t.input.lastIOSEnter>Date.now()-225&&(!w||r.some((t=>"DIV"==t.nodeName||"P"==t.nodeName)))||!w&&y.pos<p.doc.content.size&&!y.sameParent(b)&&(g=oe.findFrom(p.doc.resolve(y.pos+1),1,!0))&&g.head==b.pos)&&t.someProp("handleKeyDown",(e=>e(t,Pe(13,"Enter")))))return void(t.input.lastIOSEnter=0);if(t.state.selection.anchor>m.start&&function(t,e,n,o,r){if(n-e<=r.pos-o.pos||Nr(o,!0,!1)<r.pos)return!1;let i=t.resolve(e);if(!o.parent.isTextblock){let t=i.nodeAfter;return null!=t&&n==e+t.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let s=t.resolve(Nr(i,!0,!0));return!(!s.parent.isTextblock||s.pos>n||Nr(s,!0,!1)<n)&&o.parent.content.cut(o.parentOffset).eq(s.parent.content)}(u,m.start,m.endA,y,b)&&t.someProp("handleKeyDown",(e=>e(t,Pe(8,"Backspace")))))return void(Ze&&Je&&t.domObserver.suppressSelectionUpdates());Je&&m.endB==m.start&&(t.input.lastChromeDelete=Date.now()),Ze&&!w&&y.start()!=b.start()&&0==b.parentOffset&&y.depth==b.depth&&p.sel&&p.sel.anchor==p.sel.head&&p.sel.head==m.endA&&(m.endB-=2,b=p.doc.resolveNoCache(m.endB-p.from),setTimeout((()=>{t.someProp("handleKeyDown",(function(e){return e(t,Pe(13,"Enter"))}))}),20));let k,x,M,C=m.start,S=m.endA;if(w)if(y.pos==b.pos)Ve&&We<=11&&0==y.parentOffset&&(t.domObserver.suppressSelectionUpdates(),setTimeout((()=>Un(t)),20)),k=t.state.tr.delete(C,S),x=u.resolve(m.start).marksAcross(u.resolve(m.endA));else if(m.endA==m.endB&&(M=function(t,e){let n,o,r,i=t.firstChild.marks,s=e.firstChild.marks,l=i,c=s;for(let t=0;t<s.length;t++)l=s[t].removeFromSet(l);for(let t=0;t<i.length;t++)c=i[t].removeFromSet(c);if(1==l.length&&0==c.length)o=l[0],n="add",r=t=>t.mark(o.addToSet(t.marks));else{if(0!=l.length||1!=c.length)return null;o=c[0],n="remove",r=t=>t.mark(o.removeFromSet(t.marks))}let d=[];for(let t=0;t<e.childCount;t++)d.push(r(e.child(t)));if(a.from(d).eq(t))return{mark:o,type:n}}(y.parent.content.cut(y.parentOffset,b.parentOffset),v.parent.content.cut(v.parentOffset,m.endA-v.start()))))k=t.state.tr,"add"==M.type?k.addMark(C,S,M.mark):k.removeMark(C,S,M.mark);else if(y.parent.child(y.index()).isText&&y.index()==b.index()-(b.textOffset?0:1)){let e=y.parent.textBetween(y.parentOffset,b.parentOffset);if(t.someProp("handleTextInput",(n=>n(t,C,S,e))))return;k=t.state.tr.insertText(e,C,S)}if(k||(k=t.state.tr.replace(C,S,p.doc.slice(m.start-p.from,m.endB-p.from))),p.sel){let e=Er(t,k.doc,p.sel);e&&!(Je&&t.composing&&e.empty&&(m.start!=m.endB||t.input.lastChromeDelete<Date.now()-100)&&(e.head==C||e.head==k.mapping.map(S)-1)||Ve&&e.empty&&e.head==C)&&k.setSelection(e)}x&&k.ensureMarks(x),i&&k.setMeta("composition",i),t.dispatch(k.scrollIntoView())}(this,t,e,n,o))),this.domObserver.start(),function(t){for(let e in Eo){let n=Eo[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=e=>{!Po(t,e)||Io(t,e)||!t.editable&&e.type in No||n(t,e)},Do[e]?{passive:!0}:void 0)}Ge&&t.dom.addEventListener("input",(()=>null)),Lo(t)}(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let t=this._props;this._props={};for(let e in t)this._props[e]=t[e];this._props.state=this.state}return this._props}update(t){t.handleDOMEvents!=this._props.handleDOMEvents&&Lo(this);let e=this._props;this._props=t,t.plugins&&(t.plugins.forEach(zr),this.directPlugins=t.plugins),this.updateStateInner(t.state,e)}setProps(t){let e={};for(let t in this._props)e[t]=this._props[t];e.state=this.state;for(let n in t)e[n]=t[n];this.update(e)}updateState(t){this.updateStateInner(t,this._props)}updateStateInner(t,e){var n;let o=this.state,r=!1,i=!1;t.storedMarks&&this.composing&&(Uo(this),i=!0),this.state=t;let s=o.plugins!=t.plugins||this._props.plugins!=e.plugins;if(s||this._props.plugins!=e.plugins||this._props.nodeViews!=e.nodeViews){let t=Pr(this);(function(t,e){let n=0,o=0;for(let o in t){if(t[o]!=e[o])return!0;n++}for(let t in e)o++;return n!=o})(t,this.nodeViews)&&(this.nodeViews=t,r=!0)}(s||e.handleDOMEvents!=this._props.handleDOMEvents)&&Lo(this),this.editable=Ir(this),Lr(this);let l=br(this),a=jr(this),c=o.plugins==t.plugins||o.doc.eq(t.doc)?t.scrollToSelection>o.scrollToSelection?"to selection":"preserve":"reset",d=r||!this.docView.matchesNode(t.doc,a,l);!d&&t.selection.eq(o.selection)||(i=!0);let h="preserve"==c&&i&&null==this.dom.style.overflowAnchor&&function(t){let e,n,o=t.dom.getBoundingClientRect(),r=Math.max(0,o.top);for(let i=(o.left+o.right)/2,s=r+1;s<Math.min(innerHeight,o.bottom);s+=5){let o=t.root.elementFromPoint(i,s);if(!o||o==t.dom||!t.dom.contains(o))continue;let l=o.getBoundingClientRect();if(l.top>=r-20){e=o,n=l.top;break}}return{refDOM:e,refTop:n,stack:ln(t.dom)}}(this);if(i){this.domObserver.stop();let e=d&&(Ve||Je)&&!this.composing&&!o.selection.empty&&!t.selection.empty&&function(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}(o.selection,t.selection);if(d){let n=Je?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=function(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=function(t,e){for(;;){if(3==t.nodeType&&e)return t;if(1==t.nodeType&&e>0){if("false"==t.contentEditable)return null;e=je(t=t.childNodes[e-1])}else{if(!t.parentNode||Le(t))return null;e=Te(t),t=t.parentNode}}}(e.focusNode,e.focusOffset),o=function(t,e){for(;;){if(3==t.nodeType&&e<t.nodeValue.length)return t;if(1==t.nodeType&&e<t.childNodes.length){if("false"==t.contentEditable)return null;t=t.childNodes[e],e=0}else{if(!t.parentNode||Le(t))return null;e=Te(t)+1,t=t.parentNode}}}(e.focusNode,e.focusOffset);if(n&&o&&n!=o){let e=o.pmViewDesc,r=t.domObserver.lastChangedTextNode;if(n==r||o==r)return r;if(!e||!e.isText(o.nodeValue))return o;if(t.input.compositionNode==o){let t=n.pmViewDesc;if(t&&t.isText(n.nodeValue))return o}}return n||o}(this)),!r&&this.docView.update(t.doc,a,l,this)||(this.docView.updateOuterDeco(a),this.docView.destroy(),this.docView=Nn(t.doc,a,l,this.dom,this)),n&&!this.trackWrites&&(e=!0)}e||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&function(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Ne(e.node,e.offset,n.anchorNode,n.anchorOffset)}(this))?Un(this,e):(Zn(this,t.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(o),(null===(n=this.dragging)||void 0===n?void 0:n.node)&&!o.doc.eq(t.doc)&&this.updateDraggedNode(this.dragging,o),"reset"==c?this.dom.scrollTop=0:"to selection"==c?this.scrollToSelection():h&&function({refDOM:t,refTop:e,stack:n}){let o=t?t.getBoundingClientRect().top:0;an(n,0==o?0:o-e)}(h)}scrollToSelection(){let t=this.domSelectionRange().focusNode;if(t&&this.dom.contains(1==t.nodeType?t:t.parentNode))if(this.someProp("handleScrollToSelection",(t=>t(this))));else if(this.state.selection instanceof ce){let e=this.docView.domAfterPos(this.state.selection.from);1==e.nodeType&&sn(this,e.getBoundingClientRect(),t)}else sn(this,this.coordsAtPos(this.state.selection.head,1),t)}destroyPluginViews(){let t;for(;t=this.pluginViews.pop();)t.destroy&&t.destroy()}updatePluginViews(t){if(t&&t.plugins==this.state.plugins&&this.directPlugins==this.prevDirectPlugins)for(let e=0;e<this.pluginViews.length;e++){let n=this.pluginViews[e];n.update&&n.update(this,t)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let e=this.directPlugins[t];e.spec.view&&this.pluginViews.push(e.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let e=this.state.plugins[t];e.spec.view&&this.pluginViews.push(e.spec.view(this))}}}updateDraggedNode(t,e){let n=t.node,o=-1;if(this.state.doc.nodeAt(n.from)==n.node)o=n.from;else{let t=n.from+(this.state.doc.content.size-e.doc.content.size);(t>0&&this.state.doc.nodeAt(t))==n.node&&(o=t)}this.dragging=new Zo(t.slice,t.move,o<0?void 0:ce.create(this.state.doc,o))}someProp(t,e){let n,o=this._props&&this._props[t];if(null!=o&&(n=e?e(o):o))return n;for(let o=0;o<this.directPlugins.length;o++){let r=this.directPlugins[o].props[t];if(null!=r&&(n=e?e(r):r))return n}let r=this.state.plugins;if(r)for(let o=0;o<r.length;o++){let i=r[o].props[t];if(null!=i&&(n=e?e(i):i))return n}}hasFocus(){if(Ve){let t=this.root.activeElement;if(t==this.dom)return!0;if(!t||!this.dom.contains(t))return!1;for(;t&&this.dom!=t&&this.dom.contains(t);){if("false"==t.contentEditable)return!1;t=t.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&function(t){if(t.setActive)return t.setActive();if(cn)return t.focus(cn);let e=ln(t);t.focus(null==cn?{get preventScroll(){return cn={preventScroll:!0},!0}}:void 0),cn||(cn=!1,an(e,0))}(this.dom),Un(this),this.domObserver.start()}get root(){let t=this._root;if(null==t)for(let t=this.dom.parentNode;t;t=t.parentNode)if(9==t.nodeType||11==t.nodeType&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t;return t||document}updateRoot(){this._root=null}posAtCoords(t){return un(this,t)}coordsAtPos(t,e=1){return yn(this,t,e)}domAtPos(t,e=0){return this.docView.domFromPos(t,e)}nodeDOM(t){let e=this.docView.descAt(t);return e?e.nodeDOM:null}posAtDOM(t,e,n=-1){let o=this.docView.posFromDOM(t,e,n);if(null==o)throw new RangeError("DOM position not inside the editor");return o}endOfTextblock(t,e){return function(t,e,n){return xn==e&&Mn==n?Cn:(xn=e,Mn=n,Cn="up"==n||"down"==n?function(t,e,n){let o=e.selection,r="up"==n?o.$from:o.$to;return wn(t,e,(()=>{let{node:e}=t.docView.domFromPos(r.pos,"up"==n?-1:1);for(;;){let n=t.docView.nearestDesc(e,!0);if(!n)break;if(n.node.isBlock){e=n.contentDOM||n.dom;break}e=n.dom.parentNode}let o=yn(t,r.pos,1);for(let t=e.firstChild;t;t=t.nextSibling){let e;if(1==t.nodeType)e=t.getClientRects();else{if(3!=t.nodeType)continue;e=Ee(t,0,t.nodeValue.length).getClientRects()}for(let t=0;t<e.length;t++){let r=e[t];if(r.bottom>r.top+1&&("up"==n?o.top-r.top>2*(r.bottom-o.top):r.bottom-o.bottom>2*(o.bottom-r.top)))return!1}}return!0}))}(t,e,n):function(t,e,n){let{$head:o}=e.selection;if(!o.parent.isTextblock)return!1;let r=o.parentOffset,i=!r,s=r==o.parent.content.size,l=t.domSelection();return l?kn.test(o.parent.textContent)&&l.modify?wn(t,e,(()=>{let{focusNode:e,focusOffset:r,anchorNode:i,anchorOffset:s}=t.domSelectionRange(),a=l.caretBidiLevel;l.modify("move",n,"character");let c=o.depth?t.docView.domAfterPos(o.before()):t.dom,{focusNode:d,focusOffset:h}=t.domSelectionRange(),p=d&&!c.contains(1==d.nodeType?d:d.parentNode)||e==d&&r==h;try{l.collapse(i,s),e&&(e!=i||r!=s)&&l.extend&&l.extend(e,r)}catch(t){}return null!=a&&(l.caretBidiLevel=a),p})):"left"==n||"backward"==n?i:s:o.pos==o.start()||o.pos==o.end()}(t,e,n))}(this,e||this.state,t)}pasteHTML(t,e){return Xo(this,"",t,!1,e||new ClipboardEvent("paste"))}pasteText(t,e){return Xo(this,t,null,!0,e||new ClipboardEvent("paste"))}serializeForClipboard(t){return yo(this,t)}destroy(){this.docView&&(function(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],br(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Oe=null)}get isDestroyed(){return null==this.docView}dispatchEvent(t){return function(t,e){Io(t,e)||!Eo[e.type]||!t.editable&&e.type in No||Eo[e.type](t,e)}(this,t)}dispatch(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))}domSelectionRange(){let t=this.domSelection();return t?Ge&&11===this.root.nodeType&&function(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}(this.dom.ownerDocument)==this.dom&&function(t,e){if(e.getComposedRanges){let n=e.getComposedRanges(t.root)[0];if(n)return Sr(t,n)}let n;function o(t){t.preventDefault(),t.stopImmediatePropagation(),n=t.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",o,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",o,!0),n?Sr(t,n):null}(this,t)||t:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function jr(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",(n=>{if("function"==typeof n&&(n=n(t.state)),n)for(let t in n)"class"==t?e.class+=" "+n[t]:"style"==t?e.style=(e.style?e.style+";":"")+n[t]:e[t]||"contenteditable"==t||"nodeName"==t||(e[t]=String(n[t]))})),e.translate||(e.translate="no"),[ir.node(0,t.state.doc.content.size,e)]}function Lr(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:ir.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function Ir(t){return!t.someProp("editable",(e=>!1===e(t.state)))}function Pr(t){let e=Object.create(null);function n(t){for(let n in t)Object.prototype.hasOwnProperty.call(e,n)||(e[n]=t[n])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function zr(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}for(var $r={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:"'"},Hr={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Br="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),_r="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Fr=0;Fr<10;Fr++)$r[48+Fr]=$r[96+Fr]=String(Fr);for(Fr=1;Fr<=24;Fr++)$r[Fr+111]="F"+Fr;for(Fr=65;Fr<=90;Fr++)$r[Fr]=String.fromCharCode(Fr+32),Hr[Fr]=String.fromCharCode(Fr);for(var Vr in $r)Hr.hasOwnProperty(Vr)||(Hr[Vr]=$r[Vr]);const Wr="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform);function qr(t){let e,n,o,r,i=t.split(/-(?!$)/),s=i[i.length-1];"Space"==s&&(s=" ");for(let t=0;t<i.length-1;t++){let s=i[t];if(/^(cmd|meta|m)$/i.test(s))r=!0;else if(/^a(lt)?$/i.test(s))e=!0;else if(/^(c|ctrl|control)$/i.test(s))n=!0;else if(/^s(hift)?$/i.test(s))o=!0;else{if(!/^mod$/i.test(s))throw new Error("Unrecognized modifier name: "+s);Wr?r=!0:n=!0}}return e&&(s="Alt-"+s),n&&(s="Ctrl-"+s),r&&(s="Meta-"+s),o&&(s="Shift-"+s),s}function Kr(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 Jr(t){let e=function(t){let e=Object.create(null);for(let n in t)e[qr(n)]=t[n];return e}(t);return function(t,n){let o,r=function(t){var e=!(Br&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||_r&&t.shiftKey&&t.key&&1==t.key.length||"Unidentified"==t.key)&&t.key||(t.shiftKey?Hr:$r)[t.keyCode]||t.key||"Unidentified";return"Esc"==e&&(e="Escape"),"Del"==e&&(e="Delete"),"Left"==e&&(e="ArrowLeft"),"Up"==e&&(e="ArrowUp"),"Right"==e&&(e="ArrowRight"),"Down"==e&&(e="ArrowDown"),e}(n),i=e[Kr(r,n)];if(i&&i(t.state,t.dispatch,t))return!0;if(1==r.length&&" "!=r){if(n.shiftKey){let o=e[Kr(r,n,!1)];if(o&&o(t.state,t.dispatch,t))return!0}if((n.shiftKey||n.altKey||n.metaKey||r.charCodeAt(0)>127)&&(o=$r[n.keyCode])&&o!=r){let r=e[Kr(o,n)];if(r&&r(t.state,t.dispatch,t))return!0}}return!1}}const Ur=(t,e)=>!t.selection.empty&&(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function Gr(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const Yr=(t,e,n)=>{let o=Gr(t,n);if(!o)return!1;let r=ti(o);if(!r){let n=o.blockRange(),r=n&&Rt(n);return null!=r&&(e&&e(t.tr.lift(n,r).scrollIntoView()),!0)}let i=r.nodeBefore;if(hi(t,r,e,-1))return!0;if(0==o.parent.content.size&&(Qr(i,"end")||ce.isSelectable(i)))for(let n=o.depth;;n--){let s=Ft(t.doc,o.before(n),o.after(n),f.empty);if(s&&s.slice.size<s.to-s.from){if(e){let n=t.tr.step(s);n.setSelection(Qr(i,"end")?oe.findFrom(n.doc.resolve(n.mapping.map(r.pos,-1)),-1):ce.create(n.doc,r.pos-i.nodeSize)),e(n.scrollIntoView())}return!0}if(1==n||o.node(n-1).childCount>1)break}return!(!i.isAtom||r.depth!=o.depth-1||(e&&e(t.tr.delete(r.pos-i.nodeSize,r.pos).scrollIntoView()),0))};function Xr(t,e,n){let o=e.nodeBefore,r=e.pos-1;for(;!o.isTextblock;r--){if(o.type.spec.isolating)return!1;let t=o.lastChild;if(!t)return!1;o=t}let i=e.nodeAfter,s=e.pos+1;for(;!i.isTextblock;s++){if(i.type.spec.isolating)return!1;let t=i.firstChild;if(!t)return!1;i=t}let l=Ft(t.doc,r,s,f.empty);if(!l||l.from!=r||l instanceof At&&l.slice.size>=s-r)return!1;if(n){let e=t.tr.step(l);e.setSelection(le.create(e.doc,r)),n(e.scrollIntoView())}return!0}function Qr(t,e,n=!1){for(let o=t;o;o="start"==e?o.firstChild:o.lastChild){if(o.isTextblock)return!0;if(n&&1!=o.childCount)return!1}return!1}const Zr=(t,e,n)=>{let{$head:o,empty:r}=t.selection,i=o;if(!r)return!1;if(o.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):o.parentOffset>0)return!1;i=ti(o)}let s=i&&i.nodeBefore;return!(!s||!ce.isSelectable(s)||(e&&e(t.tr.setSelection(ce.create(t.doc,i.pos-s.nodeSize)).scrollIntoView()),0))};function ti(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 ei(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const ni=(t,e,n)=>{let o=ei(t,n);if(!o)return!1;let r=ri(o);if(!r)return!1;let i=r.nodeAfter;if(hi(t,r,e,1))return!0;if(0==o.parent.content.size&&(Qr(i,"start")||ce.isSelectable(i))){let n=Ft(t.doc,o.before(),o.after(),f.empty);if(n&&n.slice.size<n.to-n.from){if(e){let o=t.tr.step(n);o.setSelection(Qr(i,"start")?oe.findFrom(o.doc.resolve(o.mapping.map(r.pos)),1):ce.create(o.doc,o.mapping.map(r.pos))),e(o.scrollIntoView())}return!0}}return!(!i.isAtom||r.depth!=o.depth-1||(e&&e(t.tr.delete(r.pos,r.pos+i.nodeSize).scrollIntoView()),0))},oi=(t,e,n)=>{let{$head:o,empty:r}=t.selection,i=o;if(!r)return!1;if(o.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):o.parentOffset<o.parent.content.size)return!1;i=ri(o)}let s=i&&i.nodeAfter;return!(!s||!ce.isSelectable(s)||(e&&e(t.tr.setSelection(ce.create(t.doc,i.pos)).scrollIntoView()),0))};function ri(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let n=t.node(e);if(t.index(e)+1<n.childCount)return t.doc.resolve(t.after(e+1));if(n.type.spec.isolating)break}return null}const ii=(t,e)=>{let{$head:n,$anchor:o}=t.selection;return!(!n.parent.type.spec.code||!n.sameParent(o)||(e&&e(t.tr.insertText("\n").scrollIntoView()),0))};function si(t){for(let e=0;e<t.edgeCount;e++){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const li=(t,e)=>{let{$head:n,$anchor:o}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(o))return!1;let r=n.node(-1),i=n.indexAfter(-1),s=si(r.contentMatchAt(i));if(!s||!r.canReplaceWith(i,i,s))return!1;if(e){let o=n.after(),r=t.tr.replaceWith(o,o,s.createAndFill());r.setSelection(oe.near(r.doc.resolve(o),1)),e(r.scrollIntoView())}return!0},ai=(t,e)=>{let n=t.selection,{$from:o,$to:r}=n;if(n instanceof he||o.parent.inlineContent||r.parent.inlineContent)return!1;let i=si(r.parent.contentMatchAt(r.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let n=(!o.parentOffset&&r.index()<r.parent.childCount?o:r).pos,s=t.tr.insert(n,i.createAndFill());s.setSelection(le.create(s.doc,n+1)),e(s.scrollIntoView())}return!0},ci=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let o=n.before();if(zt(t.doc,o))return e&&e(t.tr.split(o).scrollIntoView()),!0}let o=n.blockRange(),r=o&&Rt(o);return null!=r&&(e&&e(t.tr.lift(o,r).scrollIntoView()),!0)};var di;function hi(t,e,n,o){let r,i,s=e.nodeBefore,l=e.nodeAfter,c=s.type.spec.isolating||l.type.spec.isolating;if(!c&&function(t,e,n){let o=e.nodeBefore,r=e.nodeAfter,i=e.index();return!(!(o&&r&&o.type.compatibleContent(r.type))||(!o.content.size&&e.parent.canReplace(i-1,i)?(n&&n(t.tr.delete(e.pos-o.nodeSize,e.pos).scrollIntoView()),0):!e.parent.canReplace(i,i+1)||!r.isTextblock&&!$t(t.doc,e.pos)||(n&&n(t.tr.join(e.pos).scrollIntoView()),0)))}(t,e,n))return!0;let d=!c&&e.parent.canReplace(e.index(),e.index()+1);if(d&&(r=(i=s.contentMatchAt(s.childCount)).findWrapping(l.type))&&i.matchType(r[0]||l.type).validEnd){if(n){let o=e.pos+l.nodeSize,i=a.empty;for(let t=r.length-1;t>=0;t--)i=a.from(r[t].create(null,i));i=a.from(s.copy(i));let c=t.tr.step(new Ot(e.pos-1,o,e.pos,o,new f(i,1,0),r.length,!0)),d=c.doc.resolve(o+2*r.length);d.nodeAfter&&d.nodeAfter.type==s.type&&$t(c.doc,d.pos)&&c.join(d.pos),n(c.scrollIntoView())}return!0}let h=l.type.spec.isolating||o>0&&c?null:oe.findFrom(e,1),p=h&&h.$from.blockRange(h.$to),u=p&&Rt(p);if(null!=u&&u>=e.depth)return n&&n(t.tr.lift(p,u).scrollIntoView()),!0;if(d&&Qr(l,"start",!0)&&Qr(s,"end")){let o=s,r=[];for(;r.push(o),!o.isTextblock;)o=o.lastChild;let i=l,c=1;for(;!i.isTextblock;i=i.firstChild)c++;if(o.canReplace(o.childCount,o.childCount,i.content)){if(n){let o=a.empty;for(let t=r.length-1;t>=0;t--)o=a.from(r[t].copy(o));n(t.tr.step(new Ot(e.pos-r.length,e.pos+l.nodeSize,e.pos+c,e.pos+l.nodeSize-c,new f(o,r.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function pi(t){return function(e,n){let o=e.selection,r=t<0?o.$from:o.$to,i=r.depth;for(;r.node(i).isInline;){if(!i)return!1;i--}return!!r.node(i).isTextblock&&(n&&n(e.tr.setSelection(le.create(e.doc,t<0?r.start(i):r.end(i)))),!0)}}const ui=pi(-1),fi=pi(1);function mi(t,e=null){return function(n,o){let r=!1;for(let o=0;o<n.selection.ranges.length&&!r;o++){let{$from:{pos:i},$to:{pos:s}}=n.selection.ranges[o];n.doc.nodesBetween(i,s,((o,i)=>{if(r)return!1;if(o.isTextblock&&!o.hasMarkup(t,e))if(o.type==t)r=!0;else{let e=n.doc.resolve(i),o=e.index();r=e.parent.canReplaceWith(o,o+1,t)}}))}if(!r)return!1;if(o){let r=n.tr;for(let o=0;o<n.selection.ranges.length;o++){let{$from:{pos:i},$to:{pos:s}}=n.selection.ranges[o];r.setBlockType(i,s,t,e)}o(r.scrollIntoView())}return!0}}function gi(...t){return function(e,n,o){for(let r=0;r<t.length;r++)if(t[r](e,n,o))return!0;return!1}}let yi=gi(Ur,Yr,Zr),bi=gi(Ur,ni,oi);const vi={Enter:gi(ii,ai,ci,((t,e)=>{let{$from:n,$to:o}=t.selection;if(t.selection instanceof ce&&t.selection.node.isBlock)return!(!n.parentOffset||!zt(t.doc,n.pos)||(e&&e(t.tr.split(n.pos).scrollIntoView()),0));if(!n.depth)return!1;let r,i,s=[],l=!1,a=!1;for(let t=n.depth;;t--){if(n.node(t).isBlock){l=n.end(t)==n.pos+(n.depth-t),a=n.start(t)==n.pos-(n.depth-t),i=si(n.node(t-1).contentMatchAt(n.indexAfter(t-1)));let e=di;s.unshift(e||(l&&i?{type:i}:null)),r=t;break}if(1==t)return!1;s.unshift(null)}let c=t.tr;(t.selection instanceof le||t.selection instanceof he)&&c.deleteSelection();let d=c.mapping.map(n.pos),h=zt(c.doc,d,s.length,s);if(h||(s[0]=i?{type:i}:null,h=zt(c.doc,d,s.length,s)),c.split(d,s.length,s),!l&&a&&n.node(r).type!=i){let t=c.mapping.map(n.before(r)),e=c.doc.resolve(t);i&&n.node(r-1).canReplaceWith(e.index(),e.index()+1,i)&&c.setNodeMarkup(c.mapping.map(n.before(r)),i)}return e&&e(c.scrollIntoView()),!0})),"Mod-Enter":li,Backspace:yi,"Mod-Backspace":yi,"Shift-Backspace":yi,Delete:bi,"Mod-Delete":bi,"Mod-a":(t,e)=>(e&&e(t.tr.setSelection(new he(t.doc))),!0)},wi={"Ctrl-h":vi.Backspace,"Alt-Backspace":vi["Mod-Backspace"],"Ctrl-d":vi.Delete,"Ctrl-Alt-Backspace":vi["Mod-Delete"],"Alt-Delete":vi["Mod-Delete"],"Alt-d":vi["Mod-Delete"],"Ctrl-a":ui,"Ctrl-e":fi};for(let t in vi)wi[t]=vi[t];function ki(t){const{state:e,transaction:n}=t;let{selection:o}=n,{doc:r}=n,{storedMarks:i}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return i},get selection(){return o},get doc(){return r},get tr(){return o=n.selection,r=n.doc,i=n.storedMarks,n}}}"undefined"!=typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):"undefined"!=typeof os&&os.platform&&os.platform();class xi{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:o}=e,{tr:r}=n,i=this.buildProps(r);return Object.fromEntries(Object.entries(t).map((([t,e])=>[t,(...t)=>{const n=e(...t)(i);return r.getMeta("preventDispatch")||this.hasCustomState||o.dispatch(r),n}])))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:o,state:r}=this,{view:i}=o,s=[],l=!!t,a=t||r.tr,c={...Object.fromEntries(Object.entries(n).map((([t,n])=>[t,(...t)=>{const o=this.buildProps(a,e),r=n(...t)(o);return s.push(r),c}]))),run:()=>(l||!e||a.getMeta("preventDispatch")||this.hasCustomState||i.dispatch(a),s.every((t=>!0===t)))};return c}createCan(t){const{rawCommands:e,state:n}=this,o=!1,r=t||n.tr,i=this.buildProps(r,o);return{...Object.fromEntries(Object.entries(e).map((([t,e])=>[t,(...t)=>e(...t)({...i,dispatch:void 0})]))),chain:()=>this.createChain(r,o)}}buildProps(t,e=!0){const{rawCommands:n,editor:o,state:r}=this,{view:i}=o,s={tr:t,editor:o,view:i,state:ki({state:r,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map((([t,e])=>[t,(...t)=>e(...t)(s)])))}};return s}}class Mi{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const n=this.callbacks[t];return n&&n.forEach((t=>t.apply(this,e))),this}off(t,e){const n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter((t=>t!==e)):delete this.callbacks[t]),this}once(t,e){const n=(...o)=>{this.off(t,n),e.apply(this,o)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}}function Ci(t,e,n){return void 0===t.config[e]&&t.parent?Ci(t.parent,e,n):"function"==typeof t.config[e]?t.config[e].bind({...n,parent:t.parent?Ci(t.parent,e,n):null}):t.config[e]}function Si(t){return{baseExtensions:t.filter((t=>"extension"===t.type)),nodeExtensions:t.filter((t=>"node"===t.type)),markExtensions:t.filter((t=>"mark"===t.type))}}function Ti(t){const e=[],{nodeExtensions:n,markExtensions:o}=Si(t),r=[...n,...o],i={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach((t=>{const n=Ci(t,"addGlobalAttributes",{name:t.name,options:t.options,storage:t.storage,extensions:r});n&&n().forEach((t=>{t.types.forEach((n=>{Object.entries(t.attributes).forEach((([t,o])=>{e.push({type:n,name:t,attribute:{...i,...o}})}))}))}))})),r.forEach((t=>{const n={name:t.name,options:t.options,storage:t.storage},o=Ci(t,"addAttributes",n);if(!o)return;const r=o();Object.entries(r).forEach((([n,o])=>{const r={...i,...o};"function"==typeof(null==r?void 0:r.default)&&(r.default=r.default()),(null==r?void 0:r.isRequired)&&void 0===(null==r?void 0:r.default)&&delete r.default,e.push({type:t.name,name:n,attribute:r})}))})),e}function Ai(t,e){if("string"==typeof t){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}function Oi(...t){return t.filter((t=>!!t)).reduce(((t,e)=>{const n={...t};return Object.entries(e).forEach((([t,e])=>{if(n[t])if("class"===t){const o=e?String(e).split(" "):[],r=n[t]?n[t].split(" "):[],i=o.filter((t=>!r.includes(t)));n[t]=[...r,...i].join(" ")}else if("style"===t){const o=e?e.split(";").map((t=>t.trim())).filter(Boolean):[],r=n[t]?n[t].split(";").map((t=>t.trim())).filter(Boolean):[],i=new Map;r.forEach((t=>{const[e,n]=t.split(":").map((t=>t.trim()));i.set(e,n)})),o.forEach((t=>{const[e,n]=t.split(":").map((t=>t.trim()));i.set(e,n)})),n[t]=Array.from(i.entries()).map((([t,e])=>`${t}: ${e}`)).join("; ")}else n[t]=e;else n[t]=e})),n}),{})}function Ei(t,e){return e.filter((e=>e.type===t.type.name)).filter((t=>t.attribute.rendered)).map((e=>e.attribute.renderHTML?e.attribute.renderHTML(t.attrs)||{}:{[e.name]:t.attrs[e.name]})).reduce(((t,e)=>Oi(t,e)),{})}function Ni(t){return"function"==typeof t}function Di(t,e=void 0,...n){return Ni(t)?e?t.bind(e)(...n):t(...n):t}function Ri(t,e){return"style"in t?t:{...t,getAttrs:n=>{const o=t.getAttrs?t.getAttrs(n):t.attrs;if(!1===o)return!1;const r=e.reduce(((t,e)=>{const o=e.attribute.parseHTML?e.attribute.parseHTML(n):function(t){return"string"!=typeof t?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):"true"===t||"false"!==t&&t}(n.getAttribute(e.name));return null==o?t:{...t,[e.name]:o}}),{});return{...o,...r}}}}function ji(t){return Object.fromEntries(Object.entries(t).filter((([t,e])=>("attrs"!==t||!function(t={}){return 0===Object.keys(t).length&&t.constructor===Object}(e))&&null!=e)))}function Li(t,e){return e.nodes[t]||e.marks[t]||null}function Ii(t,e){return Array.isArray(e)?e.some((e=>("string"==typeof e?e:e.name)===t.name)):e}function Pi(t,e){const n=ct.fromSchema(e).serializeFragment(t),o=document.implementation.createHTMLDocument().createElement("div");return o.appendChild(n),o.innerHTML}function zi(t){return"[object RegExp]"===Object.prototype.toString.call(t)}class $i{constructor(t){this.find=t.find,this.handler=t.handler}}function Hi(t){var e;const{editor:n,from:o,to:r,text:i,rules:s,plugin:l}=t,{view:a}=n;if(a.composing)return!1;const c=a.state.doc.resolve(o);if(c.parent.type.spec.code||(null===(e=c.nodeBefore||c.nodeAfter)||void 0===e?void 0:e.marks.find((t=>t.type.spec.code))))return!1;let d=!1;const h=((t,e=500)=>{let n="";const o=t.parentOffset;return t.parent.nodesBetween(Math.max(0,o-e),o,((t,e,r,i)=>{var s,l;const a=(null===(l=(s=t.type.spec).toText)||void 0===l?void 0:l.call(s,{node:t,pos:e,parent:r,index:i}))||t.textContent||"%leaf%";n+=t.isAtom&&!t.isText?a:a.slice(0,Math.max(0,o-e))})),n})(c)+i;return s.forEach((t=>{if(d)return;const e=((t,e)=>{if(zi(e))return e.exec(t);const n=e(t);if(!n)return null;const o=[n.text];return o.index=n.index,o.input=t,o.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),o.push(n.replaceWith)),o})(h,t.find);if(!e)return;const s=a.state.tr,c=ki({state:a.state,transaction:s}),p={from:o-(e[0].length-i.length),to:r},{commands:u,chain:f,can:m}=new xi({editor:n,state:c});null!==t.handler({state:c,range:p,match:e,commands:u,chain:f,can:m})&&s.steps.length&&(s.setMeta(l,{transform:s,from:o,to:r,text:i}),a.dispatch(s),d=!0)})),d}function Bi(t){const{editor:e,rules:n}=t,o=new xe({state:{init:()=>null,apply(t,r,i){const s=t.getMeta(o);if(s)return s;const l=t.getMeta("applyInputRules");return!!l&&setTimeout((()=>{let{text:t}=l;"string"==typeof t||(t=Pi(a.from(t),i.schema));const{from:r}=l,s=r+t.length;Hi({editor:e,from:r,to:s,text:t,rules:n,plugin:o})})),t.selectionSet||t.docChanged?null:r}},props:{handleTextInput:(t,r,i,s)=>Hi({editor:e,from:r,to:i,text:s,rules:n,plugin:o}),handleDOMEvents:{compositionend:t=>(setTimeout((()=>{const{$cursor:r}=t.state.selection;r&&Hi({editor:e,from:r.pos,to:r.pos,text:"",rules:n,plugin:o})})),!1)},handleKeyDown(t,r){if("Enter"!==r.key)return!1;const{$cursor:i}=t.state.selection;return!!i&&Hi({editor:e,from:i.pos,to:i.pos,text:"\n",rules:n,plugin:o})}},isInputRules:!0});return o}function _i(t){return"Object"===function(t){return Object.prototype.toString.call(t).slice(8,-1)}(t)&&t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function Fi(t,e){const n={...t};return _i(t)&&_i(e)&&Object.keys(e).forEach((o=>{_i(e[o])&&_i(t[o])?n[o]=Fi(t[o],e[o]):n[o]=e[o]})),n}class Vi{constructor(t={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...t},this.name=this.config.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=Di(Ci(this,"addOptions",{name:this.name}))),this.storage=Di(Ci(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t={}){return new Vi(t)}configure(t={}){const e=this.extend({...this.config,addOptions:()=>Fi(this.options,t)});return e.name=this.name,e.parent=this.parent,e}extend(t={}){const e=new Vi(t);return e.parent=this,this.child=e,e.name=t.name?t.name:e.parent.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${e.name}".`),e.options=Di(Ci(e,"addOptions",{name:e.name})),e.storage=Di(Ci(e,"addStorage",{name:e.name,options:e.options})),e}static handleExit({editor:t,mark:e}){const{tr:n}=t.state,o=t.state.selection.$from;if(o.pos===o.end()){const r=o.marks();if(!r.find((t=>(null==t?void 0:t.type.name)===e.name)))return!1;const i=r.find((t=>(null==t?void 0:t.type.name)===e.name));return i&&n.removeStoredMark(i),n.insertText(" ",o.pos),t.view.dispatch(n),!0}return!1}}class Wi{constructor(t){this.find=t.find,this.handler=t.handler}}let qi=null;function Ki(t){const{editor:e,rules:n}=t;let o,r=null,i=!1,s=!1,l="undefined"!=typeof ClipboardEvent?new ClipboardEvent("paste"):null;try{o="undefined"!=typeof DragEvent?new DragEvent("drop"):null}catch{o=null}const c=({state:t,from:n,to:r,rule:i,pasteEvt:s})=>{const a=t.tr,c=ki({state:t,transaction:a});if(function(t){const{editor:e,state:n,from:o,to:r,rule:i,pasteEvent:s,dropEvent:l}=t,{commands:a,chain:c,can:d}=new xi({editor:e,state:n}),h=[];return n.doc.nodesBetween(o,r,((t,e)=>{if(!t.isTextblock||t.type.spec.code)return;const p=Math.max(o,e),u=Math.min(r,e+t.content.size),f=((t,e,n)=>{if(zi(e))return[...t.matchAll(e)];const o=e(t,n);return o?o.map((e=>{const n=[e.text];return n.index=e.index,n.input=t,n.data=e.data,e.replaceWith&&(e.text.includes(e.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),n.push(e.replaceWith)),n})):[]})(t.textBetween(p-e,u-e,void 0,""),i.find,s);f.forEach((t=>{if(void 0===t.index)return;const e=p+t.index+1,o=e+t[0].length,r={from:n.tr.mapping.map(e),to:n.tr.mapping.map(o)},u=i.handler({state:n,range:r,match:t,commands:a,chain:c,can:d,pasteEvent:s,dropEvent:l});h.push(u)}))})),h.every((t=>null!==t))}({editor:e,state:c,from:Math.max(n-1,0),to:r.b-1,rule:i,pasteEvent:s,dropEvent:o})&&a.steps.length){try{o="undefined"!=typeof DragEvent?new DragEvent("drop"):null}catch{o=null}return l="undefined"!=typeof ClipboardEvent?new ClipboardEvent("paste"):null,a}};return n.map((t=>new xe({view(t){const n=n=>{var o;r=(null===(o=t.dom.parentElement)||void 0===o?void 0:o.contains(n.target))?t.dom.parentElement:null,r&&(qi=e)},o=()=>{qi&&(qi=null)};return window.addEventListener("dragstart",n),window.addEventListener("dragend",o),{destroy(){window.removeEventListener("dragstart",n),window.removeEventListener("dragend",o)}}},props:{handleDOMEvents:{drop:(t,e)=>{if(s=r===t.dom.parentElement,o=e,!s){const t=qi;t&&setTimeout((()=>{const e=t.state.selection;e&&t.commands.deleteRange({from:e.from,to:e.to})}),10)}return!1},paste:(t,e)=>{var n;const o=null===(n=e.clipboardData)||void 0===n?void 0:n.getData("text/html");return l=e,i=!!(null==o?void 0:o.includes("data-pm-slice")),!1}}},appendTransaction:(e,n,o)=>{const r=e[0],d="paste"===r.getMeta("uiEvent")&&!i,h="drop"===r.getMeta("uiEvent")&&!s,p=r.getMeta("applyPasteRules"),u=!!p;if(!d&&!h&&!u)return;if(u){let{text:e}=p;"string"==typeof e||(e=Pi(a.from(e),o.schema));const{from:n}=p,r=n+e.length,i=(t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return null===(e=n.clipboardData)||void 0===e||e.setData("text/html",t),n})(e);return c({rule:t,state:o,from:n,to:{b:r},pasteEvt:i})}const f=n.doc.content.findDiffStart(o.doc.content),m=n.doc.content.findDiffEnd(o.doc.content);return"number"==typeof f&&m&&f!==m.b?c({rule:t,state:o,from:f,to:m,pasteEvt:l}):void 0}})))}class Ji{constructor(t,e){this.splittableMarks=[],this.editor=e,this.extensions=Ji.resolve(t),this.schema=function(t,e){var n;const o=Ti(t),{nodeExtensions:r,markExtensions:i}=Si(t),s=null===(n=r.find((t=>Ci(t,"topNode"))))||void 0===n?void 0:n.name,l=Object.fromEntries(r.map((n=>{const r=o.filter((t=>t.type===n.name)),i={name:n.name,options:n.options,storage:n.storage,editor:e},s=ji({...t.reduce(((t,e)=>{const o=Ci(e,"extendNodeSchema",i);return{...t,...o?o(n):{}}}),{}),content:Di(Ci(n,"content",i)),marks:Di(Ci(n,"marks",i)),group:Di(Ci(n,"group",i)),inline:Di(Ci(n,"inline",i)),atom:Di(Ci(n,"atom",i)),selectable:Di(Ci(n,"selectable",i)),draggable:Di(Ci(n,"draggable",i)),code:Di(Ci(n,"code",i)),whitespace:Di(Ci(n,"whitespace",i)),linebreakReplacement:Di(Ci(n,"linebreakReplacement",i)),defining:Di(Ci(n,"defining",i)),isolating:Di(Ci(n,"isolating",i)),attrs:Object.fromEntries(r.map((t=>{var e;return[t.name,{default:null===(e=null==t?void 0:t.attribute)||void 0===e?void 0:e.default}]})))}),l=Di(Ci(n,"parseHTML",i));l&&(s.parseDOM=l.map((t=>Ri(t,r))));const a=Ci(n,"renderHTML",i);a&&(s.toDOM=t=>a({node:t,HTMLAttributes:Ei(t,r)}));const c=Ci(n,"renderText",i);return c&&(s.toText=c),[n.name,s]}))),a=Object.fromEntries(i.map((n=>{const r=o.filter((t=>t.type===n.name)),i={name:n.name,options:n.options,storage:n.storage,editor:e},s=ji({...t.reduce(((t,e)=>{const o=Ci(e,"extendMarkSchema",i);return{...t,...o?o(n):{}}}),{}),inclusive:Di(Ci(n,"inclusive",i)),excludes:Di(Ci(n,"excludes",i)),group:Di(Ci(n,"group",i)),spanning:Di(Ci(n,"spanning",i)),code:Di(Ci(n,"code",i)),attrs:Object.fromEntries(r.map((t=>{var e;return[t.name,{default:null===(e=null==t?void 0:t.attribute)||void 0===e?void 0:e.default}]})))}),l=Di(Ci(n,"parseHTML",i));l&&(s.parseDOM=l.map((t=>Ri(t,r))));const a=Ci(n,"renderHTML",i);return a&&(s.toDOM=t=>a({mark:t,HTMLAttributes:Ei(t,r)})),[n.name,s]})));return new X({topNode:s,nodes:l,marks:a})}(this.extensions,e),this.setupExtensions()}static resolve(t){const e=Ji.sort(Ji.flatten(t)),n=function(t){const e=t.filter(((e,n)=>t.indexOf(e)!==n));return Array.from(new Set(e))}(e.map((t=>t.name)));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map((t=>`'${t}'`)).join(", ")}]. This can lead to issues.`),e}static flatten(t){return t.map((t=>{const e=Ci(t,"addExtensions",{name:t.name,options:t.options,storage:t.storage});return e?[t,...this.flatten(e())]:t})).flat(10)}static sort(t){return t.sort(((t,e)=>{const n=Ci(t,"priority")||100,o=Ci(e,"priority")||100;return n>o?-1:n<o?1:0}))}get commands(){return this.extensions.reduce(((t,e)=>{const n=Ci(e,"addCommands",{name:e.name,options:e.options,storage:e.storage,editor:this.editor,type:Li(e.name,this.schema)});return n?{...t,...n()}:t}),{})}get plugins(){const{editor:t}=this,e=Ji.sort([...this.extensions].reverse()),n=[],o=[],r=e.map((e=>{const r={name:e.name,options:e.options,storage:e.storage,editor:t,type:Li(e.name,this.schema)},i=[],s=Ci(e,"addKeyboardShortcuts",r);let l={};if("mark"===e.type&&Ci(e,"exitable",r)&&(l.ArrowRight=()=>Vi.handleExit({editor:t,mark:e})),s){const e=Object.fromEntries(Object.entries(s()).map((([e,n])=>[e,()=>n({editor:t})])));l={...l,...e}}const a=new xe({props:{handleKeyDown:Jr(l)}});i.push(a);const c=Ci(e,"addInputRules",r);Ii(e,t.options.enableInputRules)&&c&&n.push(...c());const d=Ci(e,"addPasteRules",r);Ii(e,t.options.enablePasteRules)&&d&&o.push(...d());const h=Ci(e,"addProseMirrorPlugins",r);if(h){const t=h();i.push(...t)}return i})).flat();return[Bi({editor:t,rules:n}),...Ki({editor:t,rules:o}),...r]}get attributes(){return Ti(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=Si(this.extensions);return Object.fromEntries(e.filter((t=>!!Ci(t,"addNodeView"))).map((e=>{const n=this.attributes.filter((t=>t.type===e.name)),o={name:e.name,options:e.options,storage:e.storage,editor:t,type:Ai(e.name,this.schema)},r=Ci(e,"addNodeView",o);return r?[e.name,(o,i,s,l,a)=>{const c=Ei(o,n);return r()({node:o,view:i,getPos:s,decorations:l,innerDecorations:a,editor:t,extension:e,HTMLAttributes:c})}]:[]})))}setupExtensions(){this.extensions.forEach((t=>{var e;this.editor.extensionStorage[t.name]=t.storage;const n={name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:Li(t.name,this.schema)};"mark"===t.type&&(null===(e=Di(Ci(t,"keepOnSplit",n)))||void 0===e||e)&&this.splittableMarks.push(t.name);const o=Ci(t,"onBeforeCreate",n),r=Ci(t,"onCreate",n),i=Ci(t,"onUpdate",n),s=Ci(t,"onSelectionUpdate",n),l=Ci(t,"onTransaction",n),a=Ci(t,"onFocus",n),c=Ci(t,"onBlur",n),d=Ci(t,"onDestroy",n);o&&this.editor.on("beforeCreate",o),r&&this.editor.on("create",r),i&&this.editor.on("update",i),s&&this.editor.on("selectionUpdate",s),l&&this.editor.on("transaction",l),a&&this.editor.on("focus",a),c&&this.editor.on("blur",c),d&&this.editor.on("destroy",d)}))}}class Ui{constructor(t={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...t},this.name=this.config.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=Di(Ci(this,"addOptions",{name:this.name}))),this.storage=Di(Ci(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t={}){return new Ui(t)}configure(t={}){const e=this.extend({...this.config,addOptions:()=>Fi(this.options,t)});return e.name=this.name,e.parent=this.parent,e}extend(t={}){const e=new Ui({...this.config,...t});return e.parent=this,this.child=e,e.name=t.name?t.name:e.parent.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${e.name}".`),e.options=Di(Ci(e,"addOptions",{name:e.name})),e.storage=Di(Ci(e,"addStorage",{name:e.name,options:e.options})),e}}function Gi(t,e,n){const{from:o,to:r}=e,{blockSeparator:i="\n\n",textSerializers:s={}}=n||{};let l="";return t.nodesBetween(o,r,((t,n,a,c)=>{var d;t.isBlock&&n>o&&(l+=i);const h=null==s?void 0:s[t.type.name];if(h)return a&&(l+=h({node:t,pos:n,parent:a,index:c,range:e})),!1;t.isText&&(l+=null===(d=null==t?void 0:t.text)||void 0===d?void 0:d.slice(Math.max(o,n)-n,r-n))})),l}function Yi(t){return Object.fromEntries(Object.entries(t.nodes).filter((([,t])=>t.spec.toText)).map((([t,e])=>[t,e.spec.toText])))}const Xi=Ui.create({name:"clipboardTextSerializer",addOptions:()=>({blockSeparator:void 0}),addProseMirrorPlugins(){return[new xe({key:new Se("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:o,selection:r}=e,{ranges:i}=r,s=Math.min(...i.map((t=>t.$from.pos))),l=Math.max(...i.map((t=>t.$to.pos))),a=Yi(n);return Gi(o,{from:s,to:l},{...void 0!==this.options.blockSeparator?{blockSeparator:this.options.blockSeparator}:{},textSerializers:a})}}})]}});function Qi(t,e,n={strict:!0}){const o=Object.keys(e);return!o.length||o.every((o=>n.strict?e[o]===t[o]:zi(e[o])?e[o].test(t[o]):e[o]===t[o]))}function Zi(t,e,n={}){return t.find((t=>t.type===e&&Qi(Object.fromEntries(Object.keys(n).map((e=>[e,t.attrs[e]]))),n)))}function ts(t,e,n={}){return!!Zi(t,e,n)}function es(t,e,n){var o;if(!t||!e)return;let r=t.parent.childAfter(t.parentOffset);if(r.node&&r.node.marks.some((t=>t.type===e))||(r=t.parent.childBefore(t.parentOffset)),!r.node||!r.node.marks.some((t=>t.type===e)))return;if(n=n||(null===(o=r.node.marks[0])||void 0===o?void 0:o.attrs),!Zi([...r.node.marks],e,n))return;let i=r.index,s=t.start()+r.offset,l=i+1,a=s+r.node.nodeSize;for(;i>0&&ts([...t.parent.child(i-1).marks],e,n);)i-=1,s-=t.parent.child(i).nodeSize;for(;l<t.parent.childCount&&ts([...t.parent.child(l).marks],e,n);)a+=t.parent.child(l).nodeSize,l+=1;return{from:s,to:a}}function ns(t,e){if("string"==typeof t){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}function rs(t){return t instanceof le}function is(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function ss(t,e=null){if(!e)return null;const n=oe.atStart(t),o=oe.atEnd(t);if("start"===e||!0===e)return n;if("end"===e)return o;const r=n.from,i=o.to;return"all"===e?le.create(t,is(0,r,i),is(t.content.size,r,i)):le.create(t,is(e,r,i),is(e,r,i))}function ls(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}const as=t=>{const e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){const o=e[n];3===o.nodeType&&o.nodeValue&&/^(\n\s\s|\n)$/.test(o.nodeValue)?t.removeChild(o):1===o.nodeType&&as(o)}return t};function cs(t){const e=`<body>${t}</body>`,n=(new window.DOMParser).parseFromString(e,"text/html").body;return as(n)}function ds(t,e,n){if(t instanceof R||t instanceof a)return t;n={slice:!0,parseOptions:{},...n};const o="string"==typeof t;if("object"==typeof t&&null!==t)try{if(Array.isArray(t)&&t.length>0)return a.fromArray(t.map((t=>e.nodeFromJSON(t))));const o=e.nodeFromJSON(t);return n.errorOnInvalidContent&&o.check(),o}catch(o){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:o});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",o),ds("",e,n)}if(o){if(n.errorOnInvalidContent){let o=!1,r="";const i=new X({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:t=>(o=!0,r="string"==typeof t?t:t.outerHTML,null)}]}})});if(n.slice?Z.fromSchema(i).parseSlice(cs(t),n.parseOptions):Z.fromSchema(i).parse(cs(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${r}`)})}const o=Z.fromSchema(e);return n.slice?o.parseSlice(cs(t),n.parseOptions).content:o.parse(cs(t),n.parseOptions)}return ds("",e,n)}function hs(){return"undefined"!=typeof navigator&&/Mac/.test(navigator.platform)}function ps(t,e,n={}){const{from:o,to:r,empty:i}=t.selection,s=e?Ai(e,t.schema):null,l=[];t.doc.nodesBetween(o,r,((t,e)=>{if(t.isText)return;const n=Math.max(o,e),i=Math.min(r,e+t.nodeSize);l.push({node:t,from:n,to:i})}));const a=r-o,c=l.filter((t=>!s||s.name===t.node.type.name)).filter((t=>Qi(t.node.attrs,n,{strict:!1})));return i?!!c.length:c.reduce(((t,e)=>t+e.to-e.from),0)>=a}function us(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function fs(t,e){const n="string"==typeof e?[e]:e;return Object.keys(t).reduce(((e,o)=>(n.includes(o)||(e[o]=t[o]),e)),{})}function ms(t,e,n={},o={}){return ds(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:o.errorOnInvalidContent})}function gs(t,e){const n=ns(e,t.schema),{from:o,to:r,empty:i}=t.selection,s=[];i?(t.storedMarks&&s.push(...t.storedMarks),s.push(...t.selection.$head.marks())):t.doc.nodesBetween(o,r,(t=>{s.push(...t.marks)}));const l=s.find((t=>t.type.name===n.name));return l?{...l.attrs}:{}}function ys(t,e){for(let n=t.depth;n>0;n-=1){const o=t.node(n);if(e(o))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:o}}}function bs(t){return e=>ys(e.$from,t)}function vs(t,e){const n=us("string"==typeof e?e:e.name,t.schema);return"node"===n?function(t,e){const n=Ai(e,t.schema),{from:o,to:r}=t.selection,i=[];t.doc.nodesBetween(o,r,(t=>{i.push(t)}));const s=i.reverse().find((t=>t.type.name===n.name));return s?{...s.attrs}:{}}(t,e):"mark"===n?gs(t,e):{}}function ws(t,e,n){const o=[];return t===e?n.resolve(t).marks().forEach((e=>{const r=es(n.resolve(t),e.type);r&&o.push({mark:e,...r})})):n.nodesBetween(t,e,((t,e)=>{t&&void 0!==(null==t?void 0:t.nodeSize)&&o.push(...t.marks.map((n=>({from:e,to:e+t.nodeSize,mark:n}))))})),o}function ks(t,e,n){return Object.fromEntries(Object.entries(n).filter((([n])=>{const o=t.find((t=>t.type===e&&t.name===n));return!!o&&o.attribute.keepOnSplit})))}function xs(t,e,n={}){const{empty:o,ranges:r}=t.selection,i=e?ns(e,t.schema):null;if(o)return!!(t.storedMarks||t.selection.$from.marks()).filter((t=>!i||i.name===t.type.name)).find((t=>Qi(t.attrs,n,{strict:!1})));let s=0;const l=[];if(r.forEach((({$from:e,$to:n})=>{const o=e.pos,r=n.pos;t.doc.nodesBetween(o,r,((t,e)=>{if(!t.isText&&!t.marks.length)return;const n=Math.max(o,e),i=Math.min(r,e+t.nodeSize);s+=i-n,l.push(...t.marks.map((t=>({mark:t,from:n,to:i}))))}))})),0===s)return!1;const a=l.filter((t=>!i||i.name===t.mark.type.name)).filter((t=>Qi(t.mark.attrs,n,{strict:!1}))).reduce(((t,e)=>t+e.to-e.from),0),c=l.filter((t=>!i||t.mark.type!==i&&t.mark.type.excludes(i))).reduce(((t,e)=>t+e.to-e.from),0);return(a>0?a+c:a)>=s}function Ms(t,e){const{nodeExtensions:n}=Si(e),o=n.find((e=>e.name===t));if(!o)return!1;const r=Di(Ci(o,"group",{name:o.name,options:o.options,storage:o.storage}));return"string"==typeof r&&r.split(" ").includes("list")}function Cs(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var o;if(n){if("hardBreak"===t.type.name)return!0;if(t.isText)return/^\s*$/m.test(null!==(o=t.text)&&void 0!==o?o:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(0===t.content.childCount)return!0;if(e){let o=!0;return t.content.forEach((t=>{!1!==o&&(Cs(t,{ignoreWhitespace:n,checkChildren:e})||(o=!1))})),o}return!1}function Ss(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const o=n.filter((t=>null==e?void 0:e.includes(t.type.name)));t.tr.ensureMarks(o)}}const Ts=(t,e)=>{const n=bs((t=>t.type===e))(t.selection);if(!n)return!0;const o=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(void 0===o)return!0;const r=t.doc.nodeAt(o);return n.node.type!==(null==r?void 0:r.type)||!$t(t.doc,n.pos)||(t.join(n.pos),!0)},As=(t,e)=>{const n=bs((t=>t.type===e))(t.selection);if(!n)return!0;const o=t.doc.resolve(n.start).after(n.depth);if(void 0===o)return!0;const r=t.doc.nodeAt(o);return n.node.type!==(null==r?void 0:r.type)||!$t(t.doc,o)||(t.join(o),!0)};var Os=Object.freeze({__proto__:null,blur:()=>({editor:t,view:e})=>(requestAnimationFrame((()=>{var n;t.isDestroyed||(e.dom.blur(),null===(n=null===window||void 0===window?void 0:window.getSelection())||void 0===n||n.removeAllRanges())})),!0),clearContent:(t=!1)=>({commands:e})=>e.setContent("",t),clearNodes:()=>({state:t,tr:e,dispatch:n})=>{const{selection:o}=e,{ranges:r}=o;return!n||(r.forEach((({$from:n,$to:o})=>{t.doc.nodesBetween(n.pos,o.pos,((t,n)=>{if(t.type.isText)return;const{doc:o,mapping:r}=e,i=o.resolve(r.map(n)),s=o.resolve(r.map(n+t.nodeSize)),l=i.blockRange(s);if(!l)return;const a=Rt(l);if(t.type.isTextblock){const{defaultType:t}=i.parent.contentMatchAt(i.index());e.setNodeMarkup(l.start,t)}(a||0===a)&&e.lift(l,a)}))})),!0)},command:t=>e=>t(e),createParagraphNear:()=>({state:t,dispatch:e})=>ai(t,e),cut:(t,e)=>({editor:n,tr:o})=>{const{state:r}=n,i=r.doc.slice(t.from,t.to);o.deleteRange(t.from,t.to);const s=o.mapping.map(e);return o.insert(s,i.content),o.setSelection(new le(o.doc.resolve(s-1))),!0},deleteCurrentNode:()=>({tr:t,dispatch:e})=>{const{selection:n}=t,o=n.$anchor.node();if(o.content.size>0)return!1;const r=t.selection.$anchor;for(let n=r.depth;n>0;n-=1)if(r.node(n).type===o.type){if(e){const e=r.before(n),o=r.after(n);t.delete(e,o).scrollIntoView()}return!0}return!1},deleteNode:t=>({tr:e,state:n,dispatch:o})=>{const r=Ai(t,n.schema),i=e.selection.$anchor;for(let t=i.depth;t>0;t-=1)if(i.node(t).type===r){if(o){const n=i.before(t),o=i.after(t);e.delete(n,o).scrollIntoView()}return!0}return!1},deleteRange:t=>({tr:e,dispatch:n})=>{const{from:o,to:r}=t;return n&&e.delete(o,r),!0},deleteSelection:()=>({state:t,dispatch:e})=>Ur(t,e),enter:()=>({commands:t})=>t.keyboardShortcut("Enter"),exitCode:()=>({state:t,dispatch:e})=>li(t,e),extendMarkRange:(t,e={})=>({tr:n,state:o,dispatch:r})=>{const i=ns(t,o.schema),{doc:s,selection:l}=n,{$from:a,from:c,to:d}=l;if(r){const t=es(a,i,e);if(t&&t.from<=c&&t.to>=d){const e=le.create(s,t.from,t.to);n.setSelection(e)}}return!0},first:t=>e=>{const n="function"==typeof t?t(e):t;for(let t=0;t<n.length;t+=1)if(n[t](e))return!0;return!1},focus:(t=null,e={})=>({editor:n,view:o,tr:r,dispatch:i})=>{e={scrollIntoView:!0,...e};const s=()=>{(ls()||"Android"===navigator.platform||/android/i.test(navigator.userAgent))&&o.dom.focus(),requestAnimationFrame((()=>{n.isDestroyed||(o.focus(),(null==e?void 0:e.scrollIntoView)&&n.commands.scrollIntoView())}))};if(o.hasFocus()&&null===t||!1===t)return!0;if(i&&null===t&&!rs(n.state.selection))return s(),!0;const l=ss(r.doc,t)||n.state.selection,a=n.state.selection.eq(l);return i&&(a||r.setSelection(l),a&&r.storedMarks&&r.setStoredMarks(r.storedMarks),s()),!0},forEach:(t,e)=>n=>t.every(((t,o)=>e(t,{...n,index:o}))),insertContent:(t,e)=>({tr:n,commands:o})=>o.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),insertContentAt:(t,e,n)=>({tr:o,dispatch:r,editor:i})=>{var s;if(r){let r;n={parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};try{r=ds(e,i.schema,{parseOptions:{preserveWhitespace:"full",...n.parseOptions},errorOnInvalidContent:null!==(s=n.errorOnInvalidContent)&&void 0!==s?s:i.options.enableContentCheck})}catch(t){return i.emit("contentError",{editor:i,error:t,disableCollaboration:()=>{i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}}),!1}let l,{from:c,to:d}="number"==typeof t?{from:t,to:t}:{from:t.from,to:t.to},h=!0,p=!0;if(("type"in r?[r]:r).forEach((t=>{t.check(),h=!!h&&t.isText&&0===t.marks.length,p=!!p&&t.isBlock})),c===d&&p){const{parent:t}=o.doc.resolve(c);t.isTextblock&&!t.type.spec.code&&!t.childCount&&(c-=1,d+=1)}if(h){if(Array.isArray(e))l=e.map((t=>t.text||"")).join("");else if(e instanceof a){let t="";e.forEach((e=>{e.text&&(t+=e.text)})),l=t}else l="object"==typeof e&&e&&e.text?e.text:e;o.insertText(l,c,d)}else l=r,o.replaceWith(c,d,l);n.updateSelection&&function(t,e){const n=t.steps.length-1;if(n<e)return;const o=t.steps[n];if(!(o instanceof At||o instanceof Ot))return;const r=t.mapping.maps[n];let i=0;r.forEach(((t,e,n,o)=>{0===i&&(i=o)})),t.setSelection(oe.near(t.doc.resolve(i),-1))}(o,o.steps.length-1),n.applyInputRules&&o.setMeta("applyInputRules",{from:c,text:l}),n.applyPasteRules&&o.setMeta("applyPasteRules",{from:c,text:l})}return!0},joinBackward:()=>({state:t,dispatch:e})=>Yr(t,e),joinDown:()=>({state:t,dispatch:e})=>((t,e)=>{let n,o=t.selection;if(o instanceof ce){if(o.node.isTextblock||!$t(t.doc,o.to))return!1;n=o.to}else if(n=Bt(t.doc,o.to,1),null==n)return!1;return e&&e(t.tr.join(n).scrollIntoView()),!0})(t,e),joinForward:()=>({state:t,dispatch:e})=>ni(t,e),joinItemBackward:()=>({state:t,dispatch:e,tr:n})=>{try{const o=Bt(t.doc,t.selection.$from.pos,-1);return null!=o&&(n.join(o,2),e&&e(n),!0)}catch{return!1}},joinItemForward:()=>({state:t,dispatch:e,tr:n})=>{try{const o=Bt(t.doc,t.selection.$from.pos,1);return null!=o&&(n.join(o,2),e&&e(n),!0)}catch{return!1}},joinTextblockBackward:()=>({state:t,dispatch:e})=>((t,e)=>{let n=Gr(t,void 0);if(!n)return!1;let o=ti(n);return!!o&&Xr(t,o,e)})(t,e),joinTextblockForward:()=>({state:t,dispatch:e})=>((t,e)=>{let n=ei(t,void 0);if(!n)return!1;let o=ri(n);return!!o&&Xr(t,o,e)})(t,e),joinUp:()=>({state:t,dispatch:e})=>((t,e)=>{let n,o=t.selection,r=o instanceof ce;if(r){if(o.node.isTextblock||!$t(t.doc,o.from))return!1;n=o.from}else if(n=Bt(t.doc,o.from,-1),null==n)return!1;if(e){let o=t.tr.join(n);r&&o.setSelection(ce.create(o.doc,n-t.doc.resolve(n).nodeBefore.nodeSize)),e(o.scrollIntoView())}return!0})(t,e),keyboardShortcut:t=>({editor:e,view:n,tr:o,dispatch:r})=>{const i=function(t){const e=t.split(/-(?!$)/);let n,o,r,i,s=e[e.length-1];"Space"===s&&(s=" ");for(let t=0;t<e.length-1;t+=1){const s=e[t];if(/^(cmd|meta|m)$/i.test(s))i=!0;else if(/^a(lt)?$/i.test(s))n=!0;else if(/^(c|ctrl|control)$/i.test(s))o=!0;else if(/^s(hift)?$/i.test(s))r=!0;else{if(!/^mod$/i.test(s))throw new Error(`Unrecognized modifier name: ${s}`);ls()||hs()?i=!0:o=!0}}return n&&(s=`Alt-${s}`),o&&(s=`Ctrl-${s}`),i&&(s=`Meta-${s}`),r&&(s=`Shift-${s}`),s}(t).split(/-(?!$)/),s=i.find((t=>!["Alt","Ctrl","Meta","Shift"].includes(t))),l=new KeyboardEvent("keydown",{key:"Space"===s?" ":s,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction((()=>{n.someProp("handleKeyDown",(t=>t(n,l)))}));return null==a||a.steps.forEach((t=>{const e=t.map(o.mapping);e&&r&&o.maybeStep(e)})),!0},lift:(t,e={})=>({state:n,dispatch:o})=>!!ps(n,Ai(t,n.schema),e)&&((t,e)=>{let{$from:n,$to:o}=t.selection,r=n.blockRange(o),i=r&&Rt(r);return null!=i&&(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)})(n,o),liftEmptyBlock:()=>({state:t,dispatch:e})=>ci(t,e),liftListItem:t=>({state:e,dispatch:n})=>{return(o=Ai(t,e.schema),function(t,e){let{$from:n,$to:r}=t.selection,i=n.blockRange(r,(t=>t.childCount>0&&t.firstChild.type==o));return!!i&&(!e||(n.node(i.depth-1).type==o?function(t,e,n,o){let r=t.tr,i=o.end,s=o.$to.end(o.depth);i<s&&(r.step(new Ot(i-1,s,i,s,new f(a.from(n.create(null,o.parent.copy())),1,0),1,!0)),o=new N(r.doc.resolve(o.$from.pos),r.doc.resolve(s),o.depth));const l=Rt(o);if(null==l)return!1;r.lift(o,l);let c=r.doc.resolve(r.mapping.map(i,-1)-1);return $t(r.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&r.join(c.pos),e(r.scrollIntoView()),!0}(t,e,o,i):function(t,e,n){let o=t.tr,r=n.parent;for(let t=n.end,e=n.endIndex-1,i=n.startIndex;e>i;e--)t-=r.child(e).nodeSize,o.delete(t-1,t+1);let i=o.doc.resolve(n.start),s=i.nodeAfter;if(o.mapping.map(n.end)!=n.start+i.nodeAfter.nodeSize)return!1;let l=0==n.startIndex,c=n.endIndex==r.childCount,d=i.node(-1),h=i.index(-1);if(!d.canReplace(h+(l?0:1),h+1,s.content.append(c?a.empty:a.from(r))))return!1;let p=i.pos,u=p+s.nodeSize;return o.step(new Ot(p-(l?1:0),u+(c?1:0),p+1,u-1,new f((l?a.empty:a.from(r.copy(a.empty))).append(c?a.empty:a.from(r.copy(a.empty))),l?0:1,c?0:1),l?0:1)),e(o.scrollIntoView()),!0}(t,e,i)))})(e,n);var o},newlineInCode:()=>({state:t,dispatch:e})=>ii(t,e),resetAttributes:(t,e)=>({tr:n,state:o,dispatch:r})=>{let i=null,s=null;const l=us("string"==typeof t?t:t.name,o.schema);return!!l&&("node"===l&&(i=Ai(t,o.schema)),"mark"===l&&(s=ns(t,o.schema)),r&&n.selection.ranges.forEach((t=>{o.doc.nodesBetween(t.$from.pos,t.$to.pos,((t,o)=>{i&&i===t.type&&n.setNodeMarkup(o,void 0,fs(t.attrs,e)),s&&t.marks.length&&t.marks.forEach((r=>{s===r.type&&n.addMark(o,o+t.nodeSize,s.create(fs(r.attrs,e)))}))}))})),!0)},scrollIntoView:()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),selectAll:()=>({tr:t,dispatch:e})=>{if(e){const e=new he(t.doc);t.setSelection(e)}return!0},selectNodeBackward:()=>({state:t,dispatch:e})=>Zr(t,e),selectNodeForward:()=>({state:t,dispatch:e})=>oi(t,e),selectParentNode:()=>({state:t,dispatch:e})=>((t,e)=>{let n,{$from:o,to:r}=t.selection,i=o.sharedDepth(r);return 0!=i&&(n=o.before(i),e&&e(t.tr.setSelection(ce.create(t.doc,n))),!0)})(t,e),selectTextblockEnd:()=>({state:t,dispatch:e})=>fi(t,e),selectTextblockStart:()=>({state:t,dispatch:e})=>ui(t,e),setContent:(t,e=!1,n={},o={})=>({editor:r,tr:i,dispatch:s,commands:l})=>{var a,c;const{doc:d}=i;if("full"!==n.preserveWhitespace){const l=ms(t,r.schema,n,{errorOnInvalidContent:null!==(a=o.errorOnInvalidContent)&&void 0!==a?a:r.options.enableContentCheck});return s&&i.replaceWith(0,d.content.size,l).setMeta("preventUpdate",!e),!0}return s&&i.setMeta("preventUpdate",!e),l.insertContentAt({from:0,to:d.content.size},t,{parseOptions:n,errorOnInvalidContent:null!==(c=o.errorOnInvalidContent)&&void 0!==c?c:r.options.enableContentCheck})},setMark:(t,e={})=>({tr:n,state:o,dispatch:r})=>{const{selection:i}=n,{empty:s,ranges:l}=i,a=ns(t,o.schema);if(r)if(s){const t=gs(o,a);n.addStoredMark(a.create({...t,...e}))}else l.forEach((t=>{const r=t.$from.pos,i=t.$to.pos;o.doc.nodesBetween(r,i,((t,o)=>{const s=Math.max(o,r),l=Math.min(o+t.nodeSize,i);t.marks.find((t=>t.type===a))?t.marks.forEach((t=>{a===t.type&&n.addMark(s,l,a.create({...t.attrs,...e}))})):n.addMark(s,l,a.create(e))}))}));return function(t,e,n){var o;const{selection:r}=e;let i=null;if(rs(r)&&(i=r.$cursor),i){const e=null!==(o=t.storedMarks)&&void 0!==o?o:i.marks();return!!n.isInSet(e)||!e.some((t=>t.type.excludes(n)))}const{ranges:s}=r;return s.some((({$from:e,$to:o})=>{let r=0===e.depth&&t.doc.inlineContent&&t.doc.type.allowsMarkType(n);return t.doc.nodesBetween(e.pos,o.pos,((t,e,o)=>{if(r)return!1;if(t.isInline){const e=!o||o.type.allowsMarkType(n),i=!!n.isInSet(t.marks)||!t.marks.some((t=>t.type.excludes(n)));r=e&&i}return!r})),r}))}(o,n,a)},setMeta:(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),setNode:(t,e={})=>({state:n,dispatch:o,chain:r})=>{const i=Ai(t,n.schema);let s;return n.selection.$anchor.sameParent(n.selection.$head)&&(s=n.selection.$anchor.parent.attrs),i.isTextblock?r().command((({commands:t})=>!!mi(i,{...s,...e})(n)||t.clearNodes())).command((({state:t})=>mi(i,{...s,...e})(t,o))).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},setNodeSelection:t=>({tr:e,dispatch:n})=>{if(n){const{doc:n}=e,o=is(t,0,n.content.size),r=ce.create(n,o);e.setSelection(r)}return!0},setTextSelection:t=>({tr:e,dispatch:n})=>{if(n){const{doc:n}=e,{from:o,to:r}="number"==typeof t?{from:t,to:t}:t,i=le.atStart(n).from,s=le.atEnd(n).to,l=is(o,i,s),a=is(r,i,s),c=le.create(n,l,a);e.setSelection(c)}return!0},sinkListItem:t=>({state:e,dispatch:n})=>{const o=Ai(t,e.schema);return(r=o,function(t,e){let{$from:n,$to:o}=t.selection,i=n.blockRange(o,(t=>t.childCount>0&&t.firstChild.type==r));if(!i)return!1;let s=i.startIndex;if(0==s)return!1;let l=i.parent,c=l.child(s-1);if(c.type!=r)return!1;if(e){let n=c.lastChild&&c.lastChild.type==l.type,o=a.from(n?r.create():null),s=new f(a.from(r.create(null,a.from(l.type.create(null,o)))),n?3:1,0),d=i.start,h=i.end;e(t.tr.step(new Ot(d-(n?3:1),h,d,h,s,1,!0)).scrollIntoView())}return!0})(e,n);var r},splitBlock:({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:o,editor:r})=>{const{selection:i,doc:s}=e,{$from:l,$to:a}=i,c=ks(r.extensionManager.attributes,l.node().type.name,l.node().attrs);if(i instanceof ce&&i.node.isBlock)return!(!l.parentOffset||!zt(s,l.pos)||(o&&(t&&Ss(n,r.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),0));if(!l.parent.isBlock)return!1;const d=a.parentOffset===a.parent.content.size,h=0===l.depth?void 0:function(t){for(let e=0;e<t.edgeCount;e+=1){const{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}(l.node(-1).contentMatchAt(l.indexAfter(-1)));let p=d&&h?[{type:h,attrs:c}]:void 0,u=zt(e.doc,e.mapping.map(l.pos),1,p);if(p||u||!zt(e.doc,e.mapping.map(l.pos),1,h?[{type:h}]:void 0)||(u=!0,p=h?[{type:h,attrs:c}]:void 0),o){if(u&&(i instanceof le&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,p),h&&!d&&!l.parentOffset&&l.parent.type!==h)){const t=e.mapping.map(l.before()),n=e.doc.resolve(t);l.node(-1).canReplaceWith(n.index(),n.index()+1,h)&&e.setNodeMarkup(e.mapping.map(l.before()),h)}t&&Ss(n,r.extensionManager.splittableMarks),e.scrollIntoView()}return u},splitListItem:(t,e={})=>({tr:n,state:o,dispatch:r,editor:i})=>{var s;const l=Ai(t,o.schema),{$from:c,$to:d}=o.selection,h=o.selection.node;if(h&&h.isBlock||c.depth<2||!c.sameParent(d))return!1;const p=c.node(-1);if(p.type!==l)return!1;const u=i.extensionManager.attributes;if(0===c.parent.content.size&&c.node(-1).childCount===c.indexAfter(-1)){if(2===c.depth||c.node(-3).type!==l||c.index(-2)!==c.node(-2).childCount-1)return!1;if(r){let t=a.empty;const o=c.index(-1)?1:c.index(-2)?2:3;for(let e=c.depth-o;e>=c.depth-3;e-=1)t=a.from(c.node(e).copy(t));const r=c.indexAfter(-1)<c.node(-2).childCount?1:c.indexAfter(-2)<c.node(-3).childCount?2:3,i={...ks(u,c.node().type.name,c.node().attrs),...e},d=(null===(s=l.contentMatch.defaultType)||void 0===s?void 0:s.createAndFill(i))||void 0;t=t.append(a.from(l.createAndFill(null,d)||void 0));const h=c.before(c.depth-(o-1));n.replace(h,c.after(-r),new f(t,4-o,0));let p=-1;n.doc.nodesBetween(h,n.doc.content.size,((t,e)=>{if(p>-1)return!1;t.isTextblock&&0===t.content.size&&(p=e+1)})),p>-1&&n.setSelection(le.near(n.doc.resolve(p))),n.scrollIntoView()}return!0}const m=d.pos===c.end()?p.contentMatchAt(0).defaultType:null,g={...ks(u,p.type.name,p.attrs),...e},y={...ks(u,c.node().type.name,c.node().attrs),...e};n.delete(c.pos,d.pos);const b=m?[{type:l,attrs:g},{type:m,attrs:y}]:[{type:l,attrs:g}];if(!zt(n.doc,c.pos,2))return!1;if(r){const{selection:t,storedMarks:e}=o,{splittableMarks:s}=i.extensionManager,l=e||t.$to.parentOffset&&t.$from.marks();if(n.split(c.pos,2,b).scrollIntoView(),!l||!r)return!0;const a=l.filter((t=>s.includes(t.type.name)));n.ensureMarks(a)}return!0},toggleList:(t,e,n,o={})=>({editor:r,tr:i,state:s,dispatch:l,chain:a,commands:c,can:d})=>{const{extensions:h,splittableMarks:p}=r.extensionManager,u=Ai(t,s.schema),f=Ai(e,s.schema),{selection:m,storedMarks:g}=s,{$from:y,$to:b}=m,v=y.blockRange(b),w=g||m.$to.parentOffset&&m.$from.marks();if(!v)return!1;const k=bs((t=>Ms(t.type.name,h)))(m);if(v.depth>=1&&k&&v.depth-k.depth<=1){if(k.node.type===u)return c.liftListItem(f);if(Ms(k.node.type.name,h)&&u.validContent(k.node.content)&&l)return a().command((()=>(i.setNodeMarkup(k.pos,u),!0))).command((()=>Ts(i,u))).command((()=>As(i,u))).run()}return n&&w&&l?a().command((()=>{const t=d().wrapInList(u,o),e=w.filter((t=>p.includes(t.type.name)));return i.ensureMarks(e),!!t||c.clearNodes()})).wrapInList(u,o).command((()=>Ts(i,u))).command((()=>As(i,u))).run():a().command((()=>!!d().wrapInList(u,o)||c.clearNodes())).wrapInList(u,o).command((()=>Ts(i,u))).command((()=>As(i,u))).run()},toggleMark:(t,e={},n={})=>({state:o,commands:r})=>{const{extendEmptyMarkRange:i=!1}=n,s=ns(t,o.schema);return xs(o,s,e)?r.unsetMark(s,{extendEmptyMarkRange:i}):r.setMark(s,e)},toggleNode:(t,e,n={})=>({state:o,commands:r})=>{const i=Ai(t,o.schema),s=Ai(e,o.schema),l=ps(o,i,n);let a;return o.selection.$anchor.sameParent(o.selection.$head)&&(a=o.selection.$anchor.parent.attrs),l?r.setNode(s,a):r.setNode(i,{...a,...n})},toggleWrap:(t,e={})=>({state:n,commands:o})=>{const r=Ai(t,n.schema);return ps(n,r,e)?o.lift(r):o.wrapIn(r,e)},undoInputRule:()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let o=0;o<n.length;o+=1){const r=n[o];let i;if(r.spec.isInputRules&&(i=r.getState(t))){if(e){const e=t.tr,n=i.transform;for(let t=n.steps.length-1;t>=0;t-=1)e.step(n.steps[t].invert(n.docs[t]));if(i.text){const n=e.doc.resolve(i.from).marks();e.replaceWith(i.from,i.to,t.schema.text(i.text,n))}else e.delete(i.from,i.to)}return!0}}return!1},unsetAllMarks:()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:o,ranges:r}=n;return o||e&&r.forEach((e=>{t.removeMark(e.$from.pos,e.$to.pos)})),!0},unsetMark:(t,e={})=>({tr:n,state:o,dispatch:r})=>{var i;const{extendEmptyMarkRange:s=!1}=e,{selection:l}=n,a=ns(t,o.schema),{$from:c,empty:d,ranges:h}=l;if(!r)return!0;if(d&&s){let{from:t,to:e}=l;const o=null===(i=c.marks().find((t=>t.type===a)))||void 0===i?void 0:i.attrs,r=es(c,a,o);r&&(t=r.from,e=r.to),n.removeMark(t,e,a)}else h.forEach((t=>{n.removeMark(t.$from.pos,t.$to.pos,a)}));return n.removeStoredMark(a),!0},updateAttributes:(t,e={})=>({tr:n,state:o,dispatch:r})=>{let i=null,s=null;const l=us("string"==typeof t?t:t.name,o.schema);return!!l&&("node"===l&&(i=Ai(t,o.schema)),"mark"===l&&(s=ns(t,o.schema)),r&&n.selection.ranges.forEach((t=>{const r=t.$from.pos,l=t.$to.pos;let a,c,d,h;n.selection.empty?o.doc.nodesBetween(r,l,((t,e)=>{i&&i===t.type&&(d=Math.max(e,r),h=Math.min(e+t.nodeSize,l),a=e,c=t)})):o.doc.nodesBetween(r,l,((t,o)=>{o<r&&i&&i===t.type&&(d=Math.max(o,r),h=Math.min(o+t.nodeSize,l),a=o,c=t),o>=r&&o<=l&&(i&&i===t.type&&n.setNodeMarkup(o,void 0,{...t.attrs,...e}),s&&t.marks.length&&t.marks.forEach((i=>{if(s===i.type){const a=Math.max(o,r),c=Math.min(o+t.nodeSize,l);n.addMark(a,c,s.create({...i.attrs,...e}))}})))})),c&&(void 0!==a&&n.setNodeMarkup(a,void 0,{...c.attrs,...e}),s&&c.marks.length&&c.marks.forEach((t=>{s===t.type&&n.addMark(d,h,s.create({...t.attrs,...e}))})))})),!0)},wrapIn:(t,e={})=>({state:n,dispatch:o})=>function(t,e=null){return function(n,o){let{$from:r,$to:i}=n.selection,s=r.blockRange(i),l=s&&jt(s,t,e);return!!l&&(o&&o(n.tr.wrap(s,l).scrollIntoView()),!0)}}(Ai(t,n.schema),e)(n,o),wrapInList:(t,e={})=>({state:n,dispatch:o})=>function(t,e=null){return function(n,o){let{$from:r,$to:i}=n.selection,s=r.blockRange(i);if(!s)return!1;let l=o?n.tr:null;return!!function(t,e,n,o=null){let r=!1,i=e,s=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&0==e.startIndex){if(0==e.$from.index(e.depth-1))return!1;let t=s.resolve(e.start-2);i=new N(t,t,e.depth),e.endIndex<e.parent.childCount&&(e=new N(e.$from,s.resolve(e.$to.end(e.depth)),e.depth)),r=!0}let l=jt(i,n,o,e);return!!l&&(t&&function(t,e,n,o,r){let i=a.empty;for(let t=n.length-1;t>=0;t--)i=a.from(n[t].type.create(n[t].attrs,i));t.step(new Ot(e.start-(o?2:0),e.end,e.start,e.end,new f(i,0,0),n.length,!0));let s=0;for(let t=0;t<n.length;t++)n[t].type==r&&(s=t+1);let l=n.length-s,c=e.start+n.length-(o?2:0),d=e.parent;for(let n=e.startIndex,o=e.endIndex,r=!0;n<o;n++,r=!1)!r&&zt(t.doc,c,l)&&(t.split(c,l),c+=2*l),c+=d.child(n).nodeSize}(t,e,l,r,n),!0)}(l,s,t,e)&&(o&&o(l.scrollIntoView()),!0)}}(Ai(t,n.schema),e)(n,o)});const Es=Ui.create({name:"commands",addCommands:()=>({...Os})}),Ns=Ui.create({name:"drop",addProseMirrorPlugins(){return[new xe({key:new Se("tiptapDrop"),props:{handleDrop:(t,e,n,o)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:o})}}})]}}),Ds=Ui.create({name:"editable",addProseMirrorPlugins(){return[new xe({key:new Se("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Rs=Ui.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new xe({key:new Se("focusEvents"),props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const o=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(o),!1},blur:(e,n)=>{t.isFocused=!1;const o=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(o),!1}}}})]}}),js=Ui.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first((({commands:t})=>[()=>t.undoInputRule(),()=>t.command((({tr:e})=>{const{selection:n,doc:o}=e,{empty:r,$anchor:i}=n,{pos:s,parent:l}=i,a=i.parent.isTextblock&&s>0?e.doc.resolve(s-1):i,c=a.parent.type.spec.isolating,d=i.pos-i.parentOffset,h=c&&1===a.parent.childCount?d===i.pos:oe.atStart(o).from===s;return!(!r||!l.type.isTextblock||l.textContent.length||!h||h&&"paragraph"===i.parent.type.name)&&t.clearNodes()})),()=>t.deleteSelection(),()=>t.joinBackward(),()=>t.selectNodeBackward()])),e=()=>this.editor.commands.first((({commands:t})=>[()=>t.deleteSelection(),()=>t.deleteCurrentNode(),()=>t.joinForward(),()=>t.selectNodeForward()])),n={Enter:()=>this.editor.commands.first((({commands:t})=>[()=>t.newlineInCode(),()=>t.createParagraphNear(),()=>t.liftEmptyBlock(),()=>t.splitBlock()])),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},o={...n},r={...n,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return ls()||hs()?r:o},addProseMirrorPlugins(){return[new xe({key:new Se("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some((t=>t.getMeta("composition"))))return;const o=t.some((t=>t.docChanged))&&!e.doc.eq(n.doc),r=t.some((t=>t.getMeta("preventClearDocument")));if(!o||r)return;const{empty:i,from:s,to:l}=e.selection,a=oe.atStart(e.doc).from,c=oe.atEnd(e.doc).to;if(i||s!==a||l!==c)return;if(!Cs(n.doc))return;const d=n.tr,h=ki({state:n,transaction:d}),{commands:p}=new xi({editor:this.editor,state:h});return p.clearNodes(),d.steps.length?d:void 0}})]}}),Ls=Ui.create({name:"paste",addProseMirrorPlugins(){return[new xe({key:new Se("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),Is=Ui.create({name:"tabindex",addProseMirrorPlugins(){return[new xe({key:new Se("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});class Ps{get name(){return this.node.type.name}constructor(t,e,n=!1,o=null){this.currentNode=null,this.actualDepth=null,this.isBlock=n,this.resolvedPos=t,this.editor=e,this.currentNode=o}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var t;return null!==(t=this.actualDepth)&&void 0!==t?t:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(t){let e=this.from,n=this.to;if(this.isBlock){if(0===this.content.size)return void console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);e=this.from+1,n=this.to-1}this.editor.commands.insertContentAt({from:e,to:n},t)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(0===this.depth)return null;const t=this.resolvedPos.start(this.resolvedPos.depth-1),e=this.resolvedPos.doc.resolve(t);return new Ps(e,this.editor)}get before(){let t=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.from-3)),new Ps(t,this.editor)}get after(){let t=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.to+3)),new Ps(t,this.editor)}get children(){const t=[];return this.node.content.forEach(((e,n)=>{const o=e.isBlock&&!e.isTextblock,r=e.isAtom&&!e.isText,i=this.pos+n+(r?0:1),s=this.resolvedPos.doc.resolve(i);if(!o&&s.depth<=this.depth)return;const l=new Ps(s,this.editor,o,o?e:null);o&&(l.actualDepth=this.depth+1),t.push(new Ps(s,this.editor,o,o?e:null))})),t}get firstChild(){return this.children[0]||null}get lastChild(){const t=this.children;return t[t.length-1]||null}closest(t,e={}){let n=null,o=this.parent;for(;o&&!n;){if(o.node.type.name===t)if(Object.keys(e).length>0){const t=o.node.attrs,n=Object.keys(e);for(let o=0;o<n.length;o+=1){const r=n[o];if(t[r]!==e[r])break}}else n=o;o=o.parent}return n}querySelector(t,e={}){return this.querySelectorAll(t,e,!0)[0]||null}querySelectorAll(t,e={},n=!1){let o=[];if(!this.children||0===this.children.length)return o;const r=Object.keys(e);return this.children.forEach((i=>{n&&o.length>0||(i.node.type.name===t&&r.every((t=>e[t]===i.node.attrs[t]))&&o.push(i),n&&o.length>0||(o=o.concat(i.querySelectorAll(t,e,n))))})),o}setAttribute(t){const{tr:e}=this.editor.state;e.setNodeMarkup(this.from,void 0,{...this.node.attrs,...t}),this.editor.view.dispatch(e)}}class zs extends Mi{constructor(t={}){super(),this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.options={element:document.createElement("div"),content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:t})=>{throw t},onPaste:()=>null,onDrop:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("contentError",this.options.onContentError),this.createView(),this.injectCSS(),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",(({event:t,slice:e,moved:n})=>this.options.onDrop(t,e,n))),this.on("paste",(({event:t,slice:e})=>this.options.onPaste(t,e))),window.setTimeout((()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)}),0)}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&document&&(this.css=function(t,e){const n=document.querySelector("style[data-tiptap-style]");if(null!==n)return n;const o=document.createElement("style");return e&&o.setAttribute("nonce",e),o.setAttribute("data-tiptap-style",""),o.innerHTML='.ProseMirror {\n position: relative;\n}\n\n.ProseMirror {\n word-wrap: break-word;\n white-space: pre-wrap;\n white-space: break-spaces;\n -webkit-font-variant-ligatures: none;\n font-variant-ligatures: none;\n font-feature-settings: "liga" 0; /* the above doesn\'t seem to work in Edge */\n}\n\n.ProseMirror [contenteditable="false"] {\n white-space: normal;\n}\n\n.ProseMirror [contenteditable="false"] [contenteditable="true"] {\n white-space: pre-wrap;\n}\n\n.ProseMirror pre {\n white-space: pre-wrap;\n}\n\nimg.ProseMirror-separator {\n display: inline !important;\n border: none !important;\n margin: 0 !important;\n width: 0 !important;\n height: 0 !important;\n}\n\n.ProseMirror-gapcursor {\n display: none;\n pointer-events: none;\n position: absolute;\n margin: 0;\n}\n\n.ProseMirror-gapcursor:after {\n content: "";\n display: block;\n position: absolute;\n top: -2px;\n width: 20px;\n border-top: 1px solid black;\n animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;\n}\n\n@keyframes ProseMirror-cursor-blink {\n to {\n visibility: hidden;\n }\n}\n\n.ProseMirror-hideselection *::selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection *::-moz-selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection * {\n caret-color: transparent;\n}\n\n.ProseMirror-focused .ProseMirror-gapcursor {\n display: block;\n}\n\n.tippy-box[data-animation=fade][data-state=hidden] {\n opacity: 0\n}',document.getElementsByTagName("head")[0].appendChild(o),o}(0,this.options.injectNonce))}setOptions(t={}){this.options={...this.options,...t},this.view&&this.state&&!this.isDestroyed&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(t,e=!0){this.setOptions({editable:t}),e&&this.emit("update",{editor:this,transaction:this.state.tr})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get state(){return this.view.state}registerPlugin(t,e){const n=Ni(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],o=this.state.reconfigure({plugins:n});return this.view.updateState(o),o}unregisterPlugin(t){if(this.isDestroyed)return;const e=this.state.plugins;let n=e;if([].concat(t).forEach((t=>{const o="string"==typeof t?`${t}$`:t.key;n=e.filter((t=>!t.key.startsWith(o)))})),e.length===n.length)return;const o=this.state.reconfigure({plugins:n});return this.view.updateState(o),o}createExtensionManager(){var t,e;const n=[...this.options.enableCoreExtensions?[Ds,Xi.configure({blockSeparator:null===(e=null===(t=this.options.coreExtensionOptions)||void 0===t?void 0:t.clipboardTextSerializer)||void 0===e?void 0:e.blockSeparator}),Es,Rs,js,Is,Ns,Ls].filter((t=>"object"!=typeof this.options.enableCoreExtensions||!1!==this.options.enableCoreExtensions[t.name])):[],...this.options.extensions].filter((t=>["extension","node","mark"].includes(null==t?void 0:t.type)));this.extensionManager=new Ji(n,this)}createCommandManager(){this.commandManager=new xi({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){var t;let e;try{e=ms(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(t){if(!(t instanceof Error&&["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(t.message)))throw t;this.emit("contentError",{editor:this,error:t,disableCollaboration:()=>{this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter((t=>"collaboration"!==t.name)),this.createExtensionManager()}}),e=ms(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}const n=ss(e,this.options.autofocus);this.view=new Rr(this.options.element,{...this.options.editorProps,attributes:{role:"textbox",...null===(t=this.options.editorProps)||void 0===t?void 0:t.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:we.create({doc:e,selection:n||void 0})});const o=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(o),this.createNodeViews(),this.prependClass(),this.view.dom.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`tiptap ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction)return this.capturedTransaction?void t.steps.forEach((t=>{var e;return null===(e=this.capturedTransaction)||void 0===e?void 0:e.step(t)})):void(this.capturedTransaction=t);const e=this.state.apply(t),n=!this.state.selection.eq(e.selection);this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t}),n&&this.emit("selectionUpdate",{editor:this,transaction:t});const o=t.getMeta("focus"),r=t.getMeta("blur");o&&this.emit("focus",{editor:this,event:o.event,transaction:t}),r&&this.emit("blur",{editor:this,event:r.event,transaction:t}),t.docChanged&&!t.getMeta("preventUpdate")&&this.emit("update",{editor:this,transaction:t})}getAttributes(t){return vs(this.state,t)}isActive(t,e){const n="string"==typeof t?t:null,o="string"==typeof t?e:t;return function(t,e,n={}){if(!e)return ps(t,null,n)||xs(t,null,n);const o=us(e,t.schema);return"node"===o?ps(t,e,n):"mark"===o&&xs(t,e,n)}(this.state,n,o)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Pi(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e="\n\n",textSerializers:n={}}=t||{};return function(t,e){return Gi(t,{from:0,to:t.content.size},e)}(this.state.doc,{blockSeparator:e,textSerializers:{...Yi(this.schema),...n}})}get isEmpty(){return Cs(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){if(this.emit("destroy"),this.view){const t=this.view.dom;t&&t.editor&&delete t.editor,this.view.destroy()}this.removeAllListeners()}get isDestroyed(){var t;return!(null===(t=this.view)||void 0===t?void 0:t.docView)}$node(t,e){var n;return(null===(n=this.$doc)||void 0===n?void 0:n.querySelector(t,e))||null}$nodes(t,e){var n;return(null===(n=this.$doc)||void 0===n?void 0:n.querySelectorAll(t,e))||null}$pos(t){const e=this.state.doc.resolve(t);return new Ps(e,this)}get $doc(){return this.$pos(0)}}function $s(t){return new $i({find:t.find,handler:({state:e,range:n,match:o})=>{const r=Di(t.getAttributes,void 0,o);if(!1===r||null===r)return null;const{tr:i}=e,s=o[o.length-1],l=o[0];if(s){const o=l.search(/\S/),a=n.from+l.indexOf(s),c=a+s.length;if(ws(n.from,n.to,e.doc).filter((e=>e.mark.type.excluded.find((n=>n===t.type&&n!==e.mark.type)))).filter((t=>t.to>a)).length)return null;c<n.to&&i.delete(c,n.to),a>n.from&&i.delete(n.from+o,a);const d=n.from+o+s.length;i.addMark(n.from+o,d,t.type.create(r||{})),i.removeStoredMark(t.type)}}})}function Hs(t){return new $i({find:t.find,handler:({state:e,range:n,match:o})=>{const r=Di(t.getAttributes,void 0,o)||{},{tr:i}=e,s=n.from;let l=n.to;const a=t.type.create(r);if(o[1]){let t=s+o[0].lastIndexOf(o[1]);t>l?t=l:l=t+o[1].length;const e=o[0][o[0].length-1];i.insertText(e,s+o[0].length-1),i.replaceWith(t,l,a)}else if(o[0]){const e=t.type.isInline?s:s-1;i.insert(e,t.type.create(r)).delete(i.mapping.map(s),i.mapping.map(l))}i.scrollIntoView()}})}function Bs(t){return new $i({find:t.find,handler:({state:e,range:n,match:o})=>{const r=e.doc.resolve(n.from),i=Di(t.getAttributes,void 0,o)||{};if(!r.node(-1).canReplaceWith(r.index(-1),r.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,i)}})}function _s(t){return new $i({find:t.find,handler:({state:e,range:n,match:o,chain:r})=>{const i=Di(t.getAttributes,void 0,o)||{},s=e.tr.delete(n.from,n.to),l=s.doc.resolve(n.from).blockRange(),a=l&&jt(l,t.type,i);if(!a)return null;if(s.wrap(l,a),t.keepMarks&&t.editor){const{selection:n,storedMarks:o}=e,{splittableMarks:r}=t.editor.extensionManager,i=o||n.$to.parentOffset&&n.$from.marks();if(i){const t=i.filter((t=>r.includes(t.type.name)));s.ensureMarks(t)}}if(t.keepAttributes){const e="bulletList"===t.type.name||"orderedList"===t.type.name?"listItem":"taskList";r().updateAttributes(e,i).run()}const c=s.doc.resolve(n.from-1).nodeBefore;c&&c.type===t.type&&$t(s.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(o,c))&&s.join(n.from-1)}})}class Fs{constructor(t={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...t},this.name=this.config.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=Di(Ci(this,"addOptions",{name:this.name}))),this.storage=Di(Ci(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t={}){return new Fs(t)}configure(t={}){const e=this.extend({...this.config,addOptions:()=>Fi(this.options,t)});return e.name=this.name,e.parent=this.parent,e}extend(t={}){const e=new Fs(t);return e.parent=this,this.child=e,e.name=t.name?t.name:e.parent.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${e.name}".`),e.options=Di(Ci(e,"addOptions",{name:e.name})),e.storage=Di(Ci(e,"addStorage",{name:e.name,options:e.options})),e}}function Vs(t){return new Wi({find:t.find,handler:({state:e,range:n,match:o,pasteEvent:r})=>{const i=Di(t.getAttributes,void 0,o,r);if(!1===i||null===i)return null;const{tr:s}=e,l=o[o.length-1],a=o[0];let c=n.to;if(l){const o=a.search(/\S/),r=n.from+a.indexOf(l),d=r+l.length;if(ws(n.from,n.to,e.doc).filter((e=>e.mark.type.excluded.find((n=>n===t.type&&n!==e.mark.type)))).filter((t=>t.to>r)).length)return null;d<n.to&&s.delete(d,n.to),r>n.from&&s.delete(n.from+o,r),c=n.from+o+l.length,s.addMark(n.from+o,c,t.type.create(i||{})),s.removeStoredMark(t.type)}}})}const Ws=(t,e)=>{for(const n in e)t[n]=e[n];return t},qs="numeric",Ks="ascii",Js="alpha",Us="asciinumeric",Gs="alphanumeric",Ys="domain",Xs="emoji",Qs="scheme",Zs="slashscheme",tl="whitespace";function el(t,e){return t in e||(e[t]=[]),e[t]}function nl(t,e,n){e[qs]&&(e[Us]=!0,e[Gs]=!0),e[Ks]&&(e[Us]=!0,e[Js]=!0),e[Us]&&(e[Gs]=!0),e[Js]&&(e[Gs]=!0),e[Gs]&&(e[Ys]=!0),e[Xs]&&(e[Ys]=!0);for(const o in e){const e=el(o,n);e.indexOf(t)<0&&e.push(t)}}function ol(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}ol.groups={},ol.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let n=0;n<e.jr.length;n++){const o=e.jr[n][0],r=e.jr[n][1];if(r&&o.test(t))return r}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,o){for(let r=0;r<t.length;r++)this.tt(t[r],e,n,o)},tr(t,e,n,o){let r;return o=o||ol.groups,e&&e.j?r=e:(r=new ol(e),n&&o&&nl(e,n,o)),this.jr.push([t,r]),r},ts(t,e,n,o){let r=this;const i=t.length;if(!i)return r;for(let e=0;e<i-1;e++)r=r.tt(t[e]);return r.tt(t[i-1],e,n,o)},tt(t,e,n,o){o=o||ol.groups;const r=this;if(e&&e.j)return r.j[t]=e,e;const i=e;let s,l=r.go(t);if(l?(s=new ol,Ws(s.j,l.j),s.jr.push.apply(s.jr,l.jr),s.jd=l.jd,s.t=l.t):s=new ol,i){if(o)if(s.t&&"string"==typeof s.t){const t=Ws(function(t,e){const n={};for(const o in e)e[o].indexOf(t)>=0&&(n[o]=!0);return n}(s.t,o),n);nl(i,t,o)}else n&&nl(i,n,o);s.t=i}return r.j[t]=s,s}};const rl=(t,e,n,o,r)=>t.ta(e,n,o,r),il=(t,e,n,o,r)=>t.tr(e,n,o,r),sl=(t,e,n,o,r)=>t.ts(e,n,o,r),ll=(t,e,n,o,r)=>t.tt(e,n,o,r),al="WORD",cl="UWORD",dl="ASCIINUMERICAL",hl="ALPHANUMERICAL",pl="LOCALHOST",ul="TLD",fl="UTLD",ml="SCHEME",gl="SLASH_SCHEME",yl="NUM",bl="WS",vl="NL",wl="OPENBRACE",kl="CLOSEBRACE",xl="OPENBRACKET",Ml="CLOSEBRACKET",Cl="OPENPAREN",Sl="CLOSEPAREN",Tl="OPENANGLEBRACKET",Al="CLOSEANGLEBRACKET",Ol="FULLWIDTHLEFTPAREN",El="FULLWIDTHRIGHTPAREN",Nl="LEFTCORNERBRACKET",Dl="RIGHTCORNERBRACKET",Rl="LEFTWHITECORNERBRACKET",jl="RIGHTWHITECORNERBRACKET",Ll="FULLWIDTHLESSTHAN",Il="FULLWIDTHGREATERTHAN",Pl="AMPERSAND",zl="APOSTROPHE",$l="ASTERISK",Hl="AT",Bl="BACKSLASH",_l="BACKTICK",Fl="CARET",Vl="COLON",Wl="COMMA",ql="DOLLAR",Kl="DOT",Jl="EQUALS",Ul="EXCLAMATION",Gl="HYPHEN",Yl="PERCENT",Xl="PIPE",Ql="PLUS",Zl="POUND",ta="QUERY",ea="QUOTE",na="FULLWIDTHMIDDLEDOT",oa="SEMI",ra="SLASH",ia="TILDE",sa="UNDERSCORE",la="EMOJI",aa="SYM";var ca=Object.freeze({__proto__:null,WORD:al,UWORD:cl,ASCIINUMERICAL:dl,ALPHANUMERICAL:hl,LOCALHOST:pl,TLD:ul,UTLD:fl,SCHEME:ml,SLASH_SCHEME:gl,NUM:yl,WS:bl,NL:vl,OPENBRACE:wl,CLOSEBRACE:kl,OPENBRACKET:xl,CLOSEBRACKET:Ml,OPENPAREN:Cl,CLOSEPAREN:Sl,OPENANGLEBRACKET:Tl,CLOSEANGLEBRACKET:Al,FULLWIDTHLEFTPAREN:Ol,FULLWIDTHRIGHTPAREN:El,LEFTCORNERBRACKET:Nl,RIGHTCORNERBRACKET:Dl,LEFTWHITECORNERBRACKET:Rl,RIGHTWHITECORNERBRACKET:jl,FULLWIDTHLESSTHAN:Ll,FULLWIDTHGREATERTHAN:Il,AMPERSAND:Pl,APOSTROPHE:zl,ASTERISK:$l,AT:Hl,BACKSLASH:Bl,BACKTICK:_l,CARET:Fl,COLON:Vl,COMMA:Wl,DOLLAR:ql,DOT:Kl,EQUALS:Jl,EXCLAMATION:Ul,HYPHEN:Gl,PERCENT:Yl,PIPE:Xl,PLUS:Ql,POUND:Zl,QUERY:ta,QUOTE:ea,FULLWIDTHMIDDLEDOT:na,SEMI:oa,SLASH:ra,TILDE:ia,UNDERSCORE:sa,EMOJI:la,SYM:aa});const da=/[a-z]/,ha=/\p{L}/u,pa=/\p{Emoji}/u,ua=/\d/,fa=/\s/;let ma=null,ga=null;function ya(t,e){const n=function(t){const e=[],n=t.length;let o=0;for(;o<n;){let r,i=t.charCodeAt(o),s=i<55296||i>56319||o+1===n||(r=t.charCodeAt(o+1))<56320||r>57343?t[o]:t.slice(o,o+2);e.push(s),o+=s.length}return e}(e.replace(/[A-Z]/g,(t=>t.toLowerCase()))),o=n.length,r=[];let i=0,s=0;for(;s<o;){let l=t,a=null,c=0,d=null,h=-1,p=-1;for(;s<o&&(a=l.go(n[s]));)l=a,l.accepts()?(h=0,p=0,d=l):h>=0&&(h+=n[s].length,p++),c+=n[s].length,i+=n[s].length,s++;i-=h,s-=p,c-=h,r.push({t:d.t,v:e.slice(i-c,i),s:i-c,e:i})}return r}function ba(t,e,n,o,r){let i;const s=e.length;for(let n=0;n<s-1;n++){const s=e[n];t.j[s]?i=t.j[s]:(i=new ol(o),i.jr=r.slice(),t.j[s]=i),t=i}return i=new ol(n),i.jr=r.slice(),t.j[e[s-1]]=i,i}function va(t){const e=[],n=[];let o=0;for(;o<t.length;){let r=0;for(;"0123456789".indexOf(t[o+r])>=0;)r++;if(r>0){e.push(n.join(""));for(let e=parseInt(t.substring(o,o+r),10);e>0;e--)n.pop();o+=r}else n.push(t[o]),o++}return e}const wa={defaultProtocol:"http",events:null,format:xa,formatHref:xa,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function ka(t,e=null){let n=Ws({},wa);t&&(n=Ws(n,t instanceof ka?t.o:t));const o=n.ignoreTags,r=[];for(let t=0;t<o.length;t++)r.push(o[t].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=r}function xa(t){return t}function Ma(t,e){this.t="token",this.v=t,this.tk=e}function Ca(t,e){class n extends Ma{constructor(e,n){super(e,n),this.t=t}}for(const t in e)n.prototype[t]=e[t];return n.t=t,n}ka.prototype={o:wa,ignoreTags:[],defaultRender:t=>t,check(t){return this.get("validate",t.toString(),t)},get(t,e,n){const o=null!=e;let r=this.o[t];return r?("object"==typeof r?(r=n.t in r?r[n.t]:wa[t],"function"==typeof r&&o&&(r=r(e,n))):"function"==typeof r&&o&&(r=r(e,n.t,n)),r):r},getObj(t,e,n){let o=this.o[t];return"function"==typeof o&&null!=e&&(o=o(e,n.t,n)),o},render(t){const e=t.render(this);return(this.get("render",null,t)||this.defaultRender)(e,t.t,t)}},Ma.prototype={isLink:!1,toString(){return this.v},toHref(t){return this.toString()},toFormattedString(t){const e=this.toString(),n=t.get("truncate",e,this),o=t.get("format",e,this);return n&&o.length>n?o.substring(0,n)+"…":o},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t=wa.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,n=this.toHref(t.get("defaultProtocol")),o=t.get("formatHref",n,this),r=t.get("tagName",n,e),i=this.toFormattedString(t),s={},l=t.get("className",n,e),a=t.get("target",n,e),c=t.get("rel",n,e),d=t.getObj("attributes",n,e),h=t.getObj("events",n,e);return s.href=o,l&&(s.class=l),a&&(s.target=a),c&&(s.rel=c),d&&Ws(s,d),{tagName:r,attributes:s,content:i,eventListeners:h}}};const Sa=Ca("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Ta=Ca("text"),Aa=Ca("nl"),Oa=Ca("url",{isLink:!0,toHref(t=wa.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==pl&&t[1].t===Vl}}),Ea=t=>new ol(t);function Na(t,e,n){const o=n[0].s,r=n[n.length-1].e;return new t(e.slice(o,r),n)}const Da="undefined"!=typeof console&&console&&console.warn||(()=>{}),Ra={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function ja(t,e=!1){if(Ra.initialized&&Da(`linkifyjs: already initialized - will not register custom scheme "${t}" until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error('linkifyjs: incorrect scheme format.\n1. Must only contain digits, lowercase ASCII letters or "-"\n2. Cannot start or end with "-"\n3. "-" cannot repeat');Ra.customSchemes.push([t,e])}function La(t){return Ra.initialized||function(){Ra.scanner=function(t=[]){const e={};ol.groups=e;const n=new ol;null==ma&&(ma=va("aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2ntley5rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6logistics9properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3ncaster6d0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2psy3ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0america6xi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2")),null==ga&&(ga=va("ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2")),ll(n,"'",zl),ll(n,"{",wl),ll(n,"}",kl),ll(n,"[",xl),ll(n,"]",Ml),ll(n,"(",Cl),ll(n,")",Sl),ll(n,"<",Tl),ll(n,">",Al),ll(n,"(",Ol),ll(n,")",El),ll(n,"「",Nl),ll(n,"」",Dl),ll(n,"『",Rl),ll(n,"』",jl),ll(n,"<",Ll),ll(n,">",Il),ll(n,"&",Pl),ll(n,"*",$l),ll(n,"@",Hl),ll(n,"`",_l),ll(n,"^",Fl),ll(n,":",Vl),ll(n,",",Wl),ll(n,"$",ql),ll(n,".",Kl),ll(n,"=",Jl),ll(n,"!",Ul),ll(n,"-",Gl),ll(n,"%",Yl),ll(n,"|",Xl),ll(n,"+",Ql),ll(n,"#",Zl),ll(n,"?",ta),ll(n,'"',ea),ll(n,"/",ra),ll(n,";",oa),ll(n,"~",ia),ll(n,"_",sa),ll(n,"\\",Bl),ll(n,"・",na);const o=il(n,ua,yl,{[qs]:!0});il(o,ua,o);const r=il(o,da,dl,{[Us]:!0}),i=il(o,ha,hl,{[Gs]:!0}),s=il(n,da,al,{[Ks]:!0});il(s,ua,r),il(s,da,s),il(r,ua,r),il(r,da,r);const l=il(n,ha,cl,{[Js]:!0});il(l,da),il(l,ua,i),il(l,ha,l),il(i,ua,i),il(i,da),il(i,ha,i);const a=ll(n,"\n",vl,{[tl]:!0}),c=ll(n,"\r",bl,{[tl]:!0}),d=il(n,fa,bl,{[tl]:!0});ll(n,"",d),ll(c,"\n",a),ll(c,"",d),il(c,fa,d),ll(d,"\r"),ll(d,"\n"),il(d,fa,d),ll(d,"",d);const h=il(n,pa,la,{[Xs]:!0});ll(h,"#"),il(h,pa,h),ll(h,"️",h);const p=ll(h,"‍");ll(p,"#"),il(p,pa,h);const u=[[da,s],[ua,r]],f=[[da,null],[ha,l],[ua,i]];for(let t=0;t<ma.length;t++)ba(n,ma[t],ul,al,u);for(let t=0;t<ga.length;t++)ba(n,ga[t],fl,cl,f);nl(ul,{tld:!0,ascii:!0},e),nl(fl,{utld:!0,alpha:!0},e),ba(n,"file",ml,al,u),ba(n,"mailto",ml,al,u),ba(n,"http",gl,al,u),ba(n,"https",gl,al,u),ba(n,"ftp",gl,al,u),ba(n,"ftps",gl,al,u),nl(ml,{scheme:!0,ascii:!0},e),nl(gl,{slashscheme:!0,ascii:!0},e),t=t.sort(((t,e)=>t[0]>e[0]?1:-1));for(let e=0;e<t.length;e++){const o=t[e][0],r=t[e][1]?{[Qs]:!0}:{[Zs]:!0};o.indexOf("-")>=0?r[Ys]=!0:da.test(o)?ua.test(o)?r[Us]=!0:r[Ks]=!0:r[qs]=!0,sl(n,o,o,r)}return sl(n,"localhost",pl,{ascii:!0}),n.jd=new ol(aa),{start:n,tokens:Ws({groups:e},ca)}}(Ra.customSchemes);for(let t=0;t<Ra.tokenQueue.length;t++)Ra.tokenQueue[t][1]({scanner:Ra.scanner});Ra.parser=function({groups:t}){const e=t.domain.concat([Pl,$l,Hl,Bl,_l,Fl,ql,Jl,Gl,yl,Yl,Xl,Ql,Zl,ra,aa,ia,sa]),n=[Vl,Wl,Kl,Ul,Yl,ta,ea,oa,Tl,Al,wl,kl,Ml,xl,Cl,Sl,Ol,El,Nl,Dl,Rl,jl,Ll,Il],o=[Pl,zl,$l,Bl,_l,Fl,ql,Jl,Gl,wl,kl,Yl,Xl,Ql,Zl,ta,ra,aa,ia,sa],r=Ea(),i=ll(r,ia);rl(i,o,i),rl(i,t.domain,i);const s=Ea(),l=Ea(),a=Ea();rl(r,t.domain,s),rl(r,t.scheme,l),rl(r,t.slashscheme,a),rl(s,o,i),rl(s,t.domain,s);const c=ll(s,Hl);ll(i,Hl,c),ll(l,Hl,c),ll(a,Hl,c);const d=ll(i,Kl);rl(d,o,i),rl(d,t.domain,i);const h=Ea();rl(c,t.domain,h),rl(h,t.domain,h);const p=ll(h,Kl);rl(p,t.domain,h);const u=Ea(Sa);rl(p,t.tld,u),rl(p,t.utld,u),ll(c,pl,u);const f=ll(h,Gl);ll(f,Gl,f),rl(f,t.domain,h),rl(u,t.domain,h),ll(u,Kl,p),ll(u,Gl,f);const m=ll(u,Vl);rl(m,t.numeric,Sa);const g=ll(s,Gl),y=ll(s,Kl);ll(g,Gl,g),rl(g,t.domain,s),rl(y,o,i),rl(y,t.domain,s);const b=Ea(Oa);rl(y,t.tld,b),rl(y,t.utld,b),rl(b,t.domain,s),rl(b,o,i),ll(b,Kl,y),ll(b,Gl,g),ll(b,Hl,c);const v=ll(b,Vl),w=Ea(Oa);rl(v,t.numeric,w);const k=Ea(Oa),x=Ea();rl(k,e,k),rl(k,n,x),rl(x,e,k),rl(x,n,x),ll(b,ra,k),ll(w,ra,k);const M=ll(l,Vl),C=ll(a,Vl),S=ll(C,ra),T=ll(S,ra);rl(l,t.domain,s),ll(l,Kl,y),ll(l,Gl,g),rl(a,t.domain,s),ll(a,Kl,y),ll(a,Gl,g),rl(M,t.domain,k),ll(M,ra,k),ll(M,ta,k),rl(T,t.domain,k),rl(T,e,k),ll(T,ra,k);const A=[[wl,kl],[xl,Ml],[Cl,Sl],[Tl,Al],[Ol,El],[Nl,Dl],[Rl,jl],[Ll,Il]];for(let t=0;t<A.length;t++){const[o,r]=A[t],i=ll(k,o);ll(x,o,i),ll(i,r,k);const s=Ea(Oa);rl(i,e,s);const l=Ea();rl(i,n),rl(s,e,s),rl(s,n,l),rl(l,e,s),rl(l,n,l),ll(s,r,k),ll(l,r,k)}return ll(r,pl,b),ll(r,vl,Aa),{start:r,tokens:ca}}(Ra.scanner.tokens);for(let t=0;t<Ra.pluginQueue.length;t++)Ra.pluginQueue[t][1]({scanner:Ra.scanner,parser:Ra.parser});Ra.initialized=!0}(),function(t,e,n){let o=n.length,r=0,i=[],s=[];for(;r<o;){let l=t,a=null,c=null,d=0,h=null,p=-1;for(;r<o&&!(a=l.go(n[r].t));)s.push(n[r++]);for(;r<o&&(c=a||l.go(n[r].t));)a=null,l=c,l.accepts()?(p=0,h=l):p>=0&&p++,r++,d++;if(p<0)r-=d,r<o&&(s.push(n[r]),r++);else{s.length>0&&(i.push(Na(Ta,e,s)),s=[]),r-=p,d-=p;const t=h.t,o=n.slice(r-d,r);i.push(Na(t,e,o))}}return s.length>0&&i.push(Na(Ta,e,s)),i}(Ra.parser.start,t,ya(Ra.scanner.start,t))}function Ia(t,e=null,n=null){if(e&&"object"==typeof e){if(n)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);n=e,e=null}const o=new ka(n),r=La(t),i=[];for(let t=0;t<r.length;t++){const n=r[t];!n.isLink||e&&n.t!==e||!o.check(n)||i.push(n.toFormattedObject(o))}return i}function Pa(t){return new xe({key:new Se("autolink"),appendTransaction:(e,n,o)=>{const r=e.some((t=>t.docChanged))&&!n.doc.eq(o.doc),i=e.some((t=>t.getMeta("preventAutolink")));if(!r||i)return;const{tr:s}=o,l=function(t,e){const n=new ee(t);return e.forEach((t=>{t.steps.forEach((t=>{n.step(t)}))})),n}(n.doc,[...e]),a=function(t){const{mapping:e,steps:n}=t,o=[];return e.maps.forEach(((t,r)=>{const i=[];if(t.ranges.length)t.forEach(((t,e)=>{i.push({from:t,to:e})}));else{const{from:t,to:e}=n[r];if(void 0===t||void 0===e)return;i.push({from:t,to:e})}i.forEach((({from:t,to:n})=>{const i=e.slice(r).map(t,-1),s=e.slice(r).map(n),l=e.invert().map(i,-1),a=e.invert().map(s);o.push({oldRange:{from:l,to:a},newRange:{from:i,to:s}})}))})),function(t){const e=function(t,e=JSON.stringify){const n={};return t.filter((t=>{const o=e(t);return!Object.prototype.hasOwnProperty.call(n,o)&&(n[o]=!0)}))}(t);return 1===e.length?e:e.filter(((t,n)=>{const o=e.filter(((t,e)=>e!==n));return!o.some((e=>t.oldRange.from>=e.oldRange.from&&t.oldRange.to<=e.oldRange.to&&t.newRange.from>=e.newRange.from&&t.newRange.to<=e.newRange.to))}))}(o)}(l);return a.forEach((({newRange:e})=>{const n=function(t,e){const n=[];return t.nodesBetween(e.from,e.to,((t,e)=>{(t=>t.isTextblock)(t)&&n.push({node:t,pos:e})})),n}(o.doc,e);let r,i;if(n.length>1?(r=n[0],i=o.doc.textBetween(r.pos,r.pos+r.node.nodeSize,void 0," ")):n.length&&o.doc.textBetween(e.from,e.to," "," ").endsWith(" ")&&(r=n[0],i=o.doc.textBetween(r.pos,e.to,void 0," ")),r&&i){const e=i.split(" ").filter((t=>""!==t));if(e.length<=0)return!1;const n=e[e.length-1],a=r.pos+i.lastIndexOf(n);if(!n)return!1;const c=La(n).map((e=>e.toObject(t.defaultProtocol)));if(!(1===(l=c).length?l[0].isLink:3===l.length&&l[1].isLink&&["()","[]"].includes(l[0].value+l[2].value)))return!1;c.filter((t=>t.isLink)).map((t=>({...t,from:a+t.start+1,to:a+t.end+1}))).filter((t=>!o.schema.marks.code||!o.doc.rangeHasMark(t.from,t.to,o.schema.marks.code))).filter((e=>t.validate(e.value))).forEach((e=>{ws(e.from,e.to,o.doc).some((e=>e.mark.type===t.type))||s.addMark(e.from,e.to,t.type.create({href:e.href}))}))}var l})),s.steps.length?s:void 0}})}La.scan=ya;const za=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g;function $a(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach((t=>{const e="string"==typeof t?t:t.scheme;e&&n.push(e)})),!t||t.replace(za,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z+.-]+(?:[^a-z+.-:]|$))`,"i"))}const Ha=Vi.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.protocols.forEach((t=>{"string"!=typeof t?ja(t.scheme,t.optionalSlashes):ja(t)}))},onDestroy(){ol.groups={},Ra.scanner=null,Ra.parser=null,Ra.tokenQueue=[],Ra.pluginQueue=[],Ra.customSchemes=[],Ra.initialized=!1},inclusive(){return this.options.autolink},addOptions:()=>({openOnClick:!0,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},validate:t=>!!t}),addAttributes(){return{href:{default:null,parseHTML:t=>t.getAttribute("href")},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const e=t.getAttribute("href");return!(!e||!$a(e,this.options.protocols))&&null}}]},renderHTML({HTMLAttributes:t}){return $a(t.href,this.options.protocols)?["a",Oi(this.options.HTMLAttributes,t),0]:["a",Oi(this.options.HTMLAttributes,{...t,href:""}),0]},addCommands(){return{setLink:t=>({chain:e})=>e().setMark(this.name,t).setMeta("preventAutolink",!0).run(),toggleLink:t=>({chain:e})=>e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run(),unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[Vs({find:t=>{const e=[];if(t){const{validate:n}=this.options,o=Ia(t).filter((t=>t.isLink&&n(t.value)));o.length&&o.forEach((t=>e.push({text:t.value,data:{href:t.href},index:t.start})))}return e},type:this.type,getAttributes:t=>{var e;return{href:null===(e=t.data)||void 0===e?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[];return this.options.autolink&&t.push(Pa({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:this.options.validate})),!0===this.options.openOnClick&&t.push((e={type:this.type},new xe({key:new Se("handleClickLink"),props:{handleClick:(t,n,o)=>{var r,i;if(0!==o.button)return!1;if(!t.editable)return!1;let s=o.target;const l=[];for(;"DIV"!==s.nodeName;)l.push(s),s=s.parentNode;if(!l.find((t=>"A"===t.nodeName)))return!1;const a=vs(t.state,e.type.name),c=o.target,d=null!==(r=null==c?void 0:c.href)&&void 0!==r?r:a.href,h=null!==(i=null==c?void 0:c.target)&&void 0!==i?i:a.target;return!(!c||!d||(window.open(d,h),0))}}}))),this.options.linkOnPaste&&t.push(function(t){return new xe({key:new Se("handlePasteLink"),props:{handlePaste:(e,n,o)=>{const{state:r}=e,{selection:i}=r,{empty:s}=i;if(s)return!1;let l="";o.content.forEach((t=>{l+=t.textContent}));const a=Ia(l,{defaultProtocol:t.defaultProtocol}).find((t=>t.isLink&&t.value===l));return!(!l||!a||(t.editor.commands.setMark(t.type,{href:a.href}),0))}}})}({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),t;var e}}),Ba=Ha.extend({addKeyboardShortcuts:()=>({"Mod-k":()=>(window.dispatchEvent(new Event("edit-link")),!0)})}).configure({openOnClick:!1});var _a=n(4848),Fa=n(295),Va=n.n(Fa),Wa=n(2412),qa=n(6100),Ka=n(2837),Ja=n(4791);const Ua={linkControlLabel:"Link",colorPickerControlLabel:"Text color",highlightControlLabel:"Highlight text",colorControlLabel:t=>`Set text color ${t}`,boldControlLabel:"Bold",italicControlLabel:"Italic",underlineControlLabel:"Underline",strikeControlLabel:"Strikethrough",clearFormattingControlLabel:"Clear formatting",unlinkControlLabel:"Remove link",bulletListControlLabel:"Bullet list",orderedListControlLabel:"Ordered list",h1ControlLabel:"Heading 1",h2ControlLabel:"Heading 2",h3ControlLabel:"Heading 3",h4ControlLabel:"Heading 4",h5ControlLabel:"Heading 5",h6ControlLabel:"Heading 6",blockquoteControlLabel:"Blockquote",alignLeftControlLabel:"Align text: left",alignCenterControlLabel:"Align text: center",alignRightControlLabel:"Align text: right",alignJustifyControlLabel:"Align text: justify",codeControlLabel:"Code",codeBlockControlLabel:"Code block",subscriptControlLabel:"Subscript",superscriptControlLabel:"Superscript",unsetColorControlLabel:"Unset color",hrControlLabel:"Horizontal line",undoControlLabel:"Undo",redoControlLabel:"Redo",tasksControlLabel:"Task list",tasksSinkLabel:"Decrease task level",tasksLiftLabel:"Increase task level",linkEditorInputLabel:"Enter URL",linkEditorInputPlaceholder:"https://example.com/",linkEditorExternalLink:"Open link in a new tab",linkEditorInternalLink:"Open link in the same tab",linkEditorSave:"Save",colorPickerCancel:"Cancel",colorPickerClear:"Clear color",colorPickerColorPicker:"Color picker",colorPickerPalette:"Color palette",colorPickerSave:"Save",colorPickerColorLabel:t=>`Set text color ${t}`};var Ga=n(6798);const[Ya,Xa]=(0,Ga.F)("RichTextEditor component was not found in tree");var Qa=n(3775);function Za(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var tc,ec={exports:{}},nc={};ec.exports=function(){if(tc)return nc;tc=1;var t=Fa,e="function"==typeof Object.is?Object.is:function(t,e){return t===e&&(0!==t||1/t==1/e)||t!=t&&e!=e},n=t.useState,o=t.useEffect,r=t.useLayoutEffect,i=t.useDebugValue;function s(t){var n=t.getSnapshot;t=t.value;try{var o=n();return!e(t,o)}catch(t){return!0}}var l="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(t,e){return e()}:function(t,e){var l=e(),a=n({inst:{value:l,getSnapshot:e}}),c=a[0].inst,d=a[1];return r((function(){c.value=l,c.getSnapshot=e,s(c)&&d({inst:c})}),[t,l,e]),o((function(){return s(c)&&d({inst:c}),t((function(){s(c)&&d({inst:c})}))}),[t]),i(l),l};return nc.useSyncExternalStore=void 0!==t.useSyncExternalStore?t.useSyncExternalStore:l,nc}();var oc=ec.exports;const rc=(...t)=>e=>{t.forEach((t=>{"function"==typeof t?t(e):t&&(t.current=e)}))},ic=({contentComponent:t})=>{const e=oc.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return Fa.createElement(Fa.Fragment,null,Object.values(e))};class sc extends Fa.Component{constructor(t){var e;super(t),this.editorContentRef=Fa.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:Boolean(null===(e=t.editor)||void 0===e?void 0:e.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){const t=this.props.editor;if(t&&!t.isDestroyed&&t.options.element){if(t.contentComponent)return;const e=this.editorContentRef.current;e.append(...t.options.element.childNodes),t.setOptions({element:e}),t.contentComponent=function(){const t=new Set;let e={};return{subscribe:e=>(t.add(e),()=>{t.delete(e)}),getSnapshot:()=>e,getServerSnapshot:()=>e,setRenderer(n,o){e={...e,[n]:Qa.createPortal(o.reactElement,o.element,n)},t.forEach((t=>t()))},removeRenderer(n){const o={...e};delete o[n],e=o,t.forEach((t=>t()))}}}(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=t.contentComponent.subscribe((()=>{this.setState((t=>t.hasContentComponentInitialized?t:{hasContentComponentInitialized:!0})),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()}))),t.createNodeViews(),this.initialized=!0}}componentWillUnmount(){const t=this.props.editor;if(!t)return;if(this.initialized=!1,t.isDestroyed||t.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),t.contentComponent=null,!t.options.element.firstChild)return;const e=document.createElement("div");e.append(...t.options.element.childNodes),t.setOptions({element:e})}render(){const{editor:t,innerRef:e,...n}=this.props;return Fa.createElement(Fa.Fragment,null,Fa.createElement("div",{ref:rc(e,this.editorContentRef),...n}),(null==t?void 0:t.contentComponent)&&Fa.createElement(ic,{contentComponent:t.contentComponent}))}}const lc=(0,Fa.forwardRef)(((t,e)=>{const n=Fa.useMemo((()=>Math.floor(4294967295*Math.random()).toString()),[t.editor]);return Fa.createElement(sc,{key:n,innerRef:e,...t})})),ac=Fa.memo(lc);var cc,dc=function t(e,n){if(e===n)return!0;if(e&&n&&"object"==typeof e&&"object"==typeof n){if(e.constructor!==n.constructor)return!1;var o,r,i;if(Array.isArray(e)){if((o=e.length)!=n.length)return!1;for(r=o;0!=r--;)if(!t(e[r],n[r]))return!1;return!0}if(e instanceof Map&&n instanceof Map){if(e.size!==n.size)return!1;for(r of e.entries())if(!n.has(r[0]))return!1;for(r of e.entries())if(!t(r[1],n.get(r[0])))return!1;return!0}if(e instanceof Set&&n instanceof Set){if(e.size!==n.size)return!1;for(r of e.entries())if(!n.has(r[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(n)){if((o=e.length)!=n.length)return!1;for(r=o;0!=r--;)if(e[r]!==n[r])return!1;return!0}if(e.constructor===RegExp)return e.source===n.source&&e.flags===n.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===n.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===n.toString();if((o=(i=Object.keys(e)).length)!==Object.keys(n).length)return!1;for(r=o;0!=r--;)if(!Object.prototype.hasOwnProperty.call(n,i[r]))return!1;for(r=o;0!=r--;){var s=i[r];if(!("_owner"===s&&e.$$typeof||t(e[s],n[s])))return!1}return!0}return e!=e&&n!=n},hc=Za(dc),pc={exports:{}},uc={};pc.exports=function(){if(cc)return uc;cc=1;var t=Fa,e=oc,n="function"==typeof Object.is?Object.is:function(t,e){return t===e&&(0!==t||1/t==1/e)||t!=t&&e!=e},o=e.useSyncExternalStore,r=t.useRef,i=t.useEffect,s=t.useMemo,l=t.useDebugValue;return uc.useSyncExternalStoreWithSelector=function(t,e,a,c,d){var h=r(null);if(null===h.current){var p={hasValue:!1,value:null};h.current=p}else p=h.current;h=s((function(){function t(t){if(!i){if(i=!0,o=t,t=c(t),void 0!==d&&p.hasValue){var e=p.value;if(d(e,t))return r=e}return r=t}if(e=r,n(o,t))return e;var s=c(t);return void 0!==d&&d(e,s)?e:(o=t,r=s)}var o,r,i=!1,s=void 0===a?null:a;return[function(){return t(e())},null===s?void 0:function(){return t(s())}]}),[e,a,c,d]);var u=o(t,h[0],h[1]);return i((function(){p.hasValue=!0,p.value=u}),[u]),l(u),u},uc}();var fc=pc.exports;class mc{constructor(t){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=t,this.lastSnapshot={editor:t,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber||(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber}),this.lastSnapshot}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}watch(t){if(this.editor=t,this.editor){const t=()=>{this.transactionNumber+=1,this.subscribers.forEach((t=>t()))},e=this.editor;return e.on("transaction",t),()=>{e.off("transaction",t)}}}}const gc="undefined"==typeof window,yc=gc||Boolean("undefined"!=typeof window&&window.next);class bc{constructor(t){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=t,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(t){this.editor=t,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach((t=>t()))}getInitialEditor(){return void 0===this.options.current.immediatelyRender?gc||yc?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const t={...this.options.current,onBeforeCreate:(...t)=>{var e,n;return null===(n=(e=this.options.current).onBeforeCreate)||void 0===n?void 0:n.call(e,...t)},onBlur:(...t)=>{var e,n;return null===(n=(e=this.options.current).onBlur)||void 0===n?void 0:n.call(e,...t)},onCreate:(...t)=>{var e,n;return null===(n=(e=this.options.current).onCreate)||void 0===n?void 0:n.call(e,...t)},onDestroy:(...t)=>{var e,n;return null===(n=(e=this.options.current).onDestroy)||void 0===n?void 0:n.call(e,...t)},onFocus:(...t)=>{var e,n;return null===(n=(e=this.options.current).onFocus)||void 0===n?void 0:n.call(e,...t)},onSelectionUpdate:(...t)=>{var e,n;return null===(n=(e=this.options.current).onSelectionUpdate)||void 0===n?void 0:n.call(e,...t)},onTransaction:(...t)=>{var e,n;return null===(n=(e=this.options.current).onTransaction)||void 0===n?void 0:n.call(e,...t)},onUpdate:(...t)=>{var e,n;return null===(n=(e=this.options.current).onUpdate)||void 0===n?void 0:n.call(e,...t)},onContentError:(...t)=>{var e,n;return null===(n=(e=this.options.current).onContentError)||void 0===n?void 0:n.call(e,...t)},onDrop:(...t)=>{var e,n;return null===(n=(e=this.options.current).onDrop)||void 0===n?void 0:n.call(e,...t)},onPaste:(...t)=>{var e,n;return null===(n=(e=this.options.current).onPaste)||void 0===n?void 0:n.call(e,...t)}};return new zs(t)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(t){return this.subscriptions.add(t),()=>{this.subscriptions.delete(t)}}onRender(t){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&0===t.length?this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(t),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(t){if(this.editor&&!this.editor.isDestroyed){if(null===this.previousDeps)return void(this.previousDeps=t);if(this.previousDeps.length===t.length&&this.previousDeps.every(((e,n)=>e===t[n])))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=t}scheduleDestroy(){const t=this.instanceId,e=this.editor;this.scheduledDestructionTimeout=setTimeout((()=>{this.isComponentMounted&&this.instanceId===t?e&&e.setOptions(this.options.current):e&&!e.isDestroyed&&(e.destroy(),this.instanceId===t&&this.setEditor(null))}),1)}}(0,Fa.createContext)({editor:null}).Consumer;const vc=(0,Fa.createContext)({onDragStart:void 0});Fa.forwardRef(((t,e)=>{const{onDragStart:n}=(0,Fa.useContext)(vc),o=t.as||"div";return Fa.createElement(o,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})}));var wc=n(3669),kc={root:"m_dd3f7539",typographyStylesProvider:"m_d37966d9",content:"m_c2204cc2",linkEditorDropdown:"m_8a991b4f",control:"m_c2207da6",controlIcon:"m_9cdfeb3f",controlsGroup:"m_2ab47ef2",linkEditor:"m_b67b711e",linkEditorInput:"m_296cf94c",linkEditorExternalControl:"m_cfef614",linkEditorSave:"m_3b28e7bb",toolbar:"m_4574a3c4",taskList:"m_8b44009a"};const xc={},Mc=(0,Wa.P9)(((t,e)=>{const n=(0,qa.Y)("RichTextEditorContent",xc,t),{classNames:o,className:r,style:i,styles:s,vars:l,...a}=n,c=Xa();return c.withTypographyStyles?(0,_a.jsx)(wc.Z,{...c.getStyles("typographyStylesProvider",{className:r,style:i,styles:s,classNames:o}),unstyled:c.unstyled,ref:e,children:(0,_a.jsx)(Ja.a,{component:ac,editor:c.editor,...c.getStyles("content",{classNames:o,styles:s}),...a})}):(0,_a.jsx)(Ja.a,{component:ac,editor:c.editor,...c.getStyles("content",{classNames:o,styles:s,className:r,style:i}),...a})}));function Cc(t){return(0,_a.jsx)("svg",{...t,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})}function Sc(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M7 5h6a3.5 3.5 0 0 1 0 7h-6z"}),(0,_a.jsx)("path",{d:"M13 12h1a3.5 3.5 0 0 1 0 7h-7v-7"})]})}function Tc(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M11 5l6 0"}),(0,_a.jsx)("path",{d:"M7 19l6 0"}),(0,_a.jsx)("path",{d:"M14 5l-4 14"})]})}function Ac(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M7 5v5a5 5 0 0 0 10 0v-5"}),(0,_a.jsx)("path",{d:"M5 19h14"})]})}function Oc(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M5 12l14 0"}),(0,_a.jsx)("path",{d:"M16 6.5a4 2 0 0 0 -4 -1.5h-1a3.5 3.5 0 0 0 0 7h2a3.5 3.5 0 0 1 0 7h-1.5a4 2 0 0 1 -4 -1.5"})]})}function Ec(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M17 15l4 4m0 -4l-4 4"}),(0,_a.jsx)("path",{d:"M7 6v-1h11v1"}),(0,_a.jsx)("path",{d:"M7 19l4 0"}),(0,_a.jsx)("path",{d:"M13 5l-4 14"})]})}function Nc(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M19 18v-8l-2 2"}),(0,_a.jsx)("path",{d:"M4 6v12"}),(0,_a.jsx)("path",{d:"M12 6v12"}),(0,_a.jsx)("path",{d:"M11 18h2"}),(0,_a.jsx)("path",{d:"M3 18h2"}),(0,_a.jsx)("path",{d:"M4 12h8"}),(0,_a.jsx)("path",{d:"M3 6h2"}),(0,_a.jsx)("path",{d:"M11 6h2"})]})}function Dc(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M17 12a2 2 0 1 1 4 0c0 .591 -.417 1.318 -.816 1.858l-3.184 4.143l4 0"}),(0,_a.jsx)("path",{d:"M4 6v12"}),(0,_a.jsx)("path",{d:"M12 6v12"}),(0,_a.jsx)("path",{d:"M11 18h2"}),(0,_a.jsx)("path",{d:"M3 18h2"}),(0,_a.jsx)("path",{d:"M4 12h8"}),(0,_a.jsx)("path",{d:"M3 6h2"}),(0,_a.jsx)("path",{d:"M11 6h2"})]})}function Rc(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M19 14a2 2 0 1 0 -2 -2"}),(0,_a.jsx)("path",{d:"M17 16a2 2 0 1 0 2 -2"}),(0,_a.jsx)("path",{d:"M4 6v12"}),(0,_a.jsx)("path",{d:"M12 6v12"}),(0,_a.jsx)("path",{d:"M11 18h2"}),(0,_a.jsx)("path",{d:"M3 18h2"}),(0,_a.jsx)("path",{d:"M4 12h8"}),(0,_a.jsx)("path",{d:"M3 6h2"}),(0,_a.jsx)("path",{d:"M11 6h2"})]})}function jc(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M20 18v-8l-4 6h5"}),(0,_a.jsx)("path",{d:"M4 6v12"}),(0,_a.jsx)("path",{d:"M12 6v12"}),(0,_a.jsx)("path",{d:"M11 18h2"}),(0,_a.jsx)("path",{d:"M3 18h2"}),(0,_a.jsx)("path",{d:"M4 12h8"}),(0,_a.jsx)("path",{d:"M3 6h2"}),(0,_a.jsx)("path",{d:"M11 6h2"})]})}function Lc(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M17 18h2a2 2 0 1 0 0 -4h-2v-4h4"}),(0,_a.jsx)("path",{d:"M4 6v12"}),(0,_a.jsx)("path",{d:"M12 6v12"}),(0,_a.jsx)("path",{d:"M11 18h2"}),(0,_a.jsx)("path",{d:"M3 18h2"}),(0,_a.jsx)("path",{d:"M4 12h8"}),(0,_a.jsx)("path",{d:"M3 6h2"}),(0,_a.jsx)("path",{d:"M11 6h2"})]})}function Ic(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M19 14a2 2 0 1 0 0 4a2 2 0 0 0 0 -4z"}),(0,_a.jsx)("path",{d:"M21 12a2 2 0 1 0 -4 0v4"}),(0,_a.jsx)("path",{d:"M4 6v12"}),(0,_a.jsx)("path",{d:"M12 6v12"}),(0,_a.jsx)("path",{d:"M11 18h2"}),(0,_a.jsx)("path",{d:"M3 18h2"}),(0,_a.jsx)("path",{d:"M4 12h8"}),(0,_a.jsx)("path",{d:"M3 6h2"}),(0,_a.jsx)("path",{d:"M11 6h2"})]})}function Pc(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M9 6l11 0"}),(0,_a.jsx)("path",{d:"M9 12l11 0"}),(0,_a.jsx)("path",{d:"M9 18l11 0"}),(0,_a.jsx)("path",{d:"M5 6l0 .01"}),(0,_a.jsx)("path",{d:"M5 12l0 .01"}),(0,_a.jsx)("path",{d:"M5 18l0 .01"})]})}function zc(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M11 6h9"}),(0,_a.jsx)("path",{d:"M11 12h9"}),(0,_a.jsx)("path",{d:"M12 18h8"}),(0,_a.jsx)("path",{d:"M4 16a2 2 0 1 1 4 0c0 .591 -.5 1 -1 1.5l-3 2.5h4"}),(0,_a.jsx)("path",{d:"M6 10v-6l-2 2"})]})}function $c(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M17 22v-2"}),(0,_a.jsx)("path",{d:"M9 15l6 -6"}),(0,_a.jsx)("path",{d:"M11 6l.463 -.536a5 5 0 0 1 7.071 7.072l-.534 .464"}),(0,_a.jsx)("path",{d:"M13 18l-.397 .534a5.068 5.068 0 0 1 -7.127 0a4.972 4.972 0 0 1 0 -7.071l.524 -.463"}),(0,_a.jsx)("path",{d:"M20 17h2"}),(0,_a.jsx)("path",{d:"M2 7h2"}),(0,_a.jsx)("path",{d:"M7 2v2"})]})}function Hc(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M6 15h15"}),(0,_a.jsx)("path",{d:"M21 19h-15"}),(0,_a.jsx)("path",{d:"M15 11h6"}),(0,_a.jsx)("path",{d:"M21 7h-6"}),(0,_a.jsx)("path",{d:"M9 9h1a1 1 0 1 1 -1 1v-2.5a2 2 0 0 1 2 -2"}),(0,_a.jsx)("path",{d:"M3 9h1a1 1 0 1 1 -1 1v-2.5a2 2 0 0 1 2 -2"})]})}function Bc(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M4 6l16 0"}),(0,_a.jsx)("path",{d:"M4 12l10 0"}),(0,_a.jsx)("path",{d:"M4 18l14 0"})]})}function _c(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M4 6l16 0"}),(0,_a.jsx)("path",{d:"M10 12l10 0"}),(0,_a.jsx)("path",{d:"M6 18l14 0"})]})}function Fc(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M4 6l16 0"}),(0,_a.jsx)("path",{d:"M8 12l8 0"}),(0,_a.jsx)("path",{d:"M6 18l12 0"})]})}function Vc(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M4 6l16 0"}),(0,_a.jsx)("path",{d:"M4 12l16 0"}),(0,_a.jsx)("path",{d:"M4 18l12 0"})]})}function Wc(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M5 7l8 10m-8 0l8 -10"}),(0,_a.jsx)("path",{d:"M21 20h-4l3.5 -4a1.73 1.73 0 0 0 -3.5 -2"})]})}function qc(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M5 7l8 10m-8 0l8 -10"}),(0,_a.jsx)("path",{d:"M21 11h-4l3.5 -4a1.73 1.73 0 0 0 -3.5 -2"})]})}function Kc(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M7 8l-4 4l4 4"}),(0,_a.jsx)("path",{d:"M17 8l4 4l-4 4"}),(0,_a.jsx)("path",{d:"M14 4l-4 16"})]})}function Jc(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M3 19h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4"}),(0,_a.jsx)("path",{d:"M12.5 5.5l4 4"}),(0,_a.jsx)("path",{d:"M4.5 13.5l4 4"}),(0,_a.jsx)("path",{d:"M21 15v4h-8l4 -4z"})]})}function Uc(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M5 12h2"}),(0,_a.jsx)("path",{d:"M17 12h2"}),(0,_a.jsx)("path",{d:"M11 12h2"})]})}function Gc(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M20.042 16.045a9 9 0 0 0 -12.087 -12.087m-2.318 1.677a9 9 0 1 0 12.725 12.73"}),(0,_a.jsx)("path",{d:"M3 3l18 18"})]})}function Yc(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M11 7l6 6"}),(0,_a.jsx)("path",{d:"M4 16l11.7 -11.7a1 1 0 0 1 1.4 0l2.6 2.6a1 1 0 0 1 0 1.4l-11.7 11.7h-4v-4z"})]})}function Xc(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M18 6l-12 12"}),(0,_a.jsx)("path",{d:"M6 6l12 12"})]})}function Qc(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M12 21a9 9 0 0 1 0 -18c4.97 0 9 3.582 9 8c0 1.06 -.474 2.078 -1.318 2.828c-.844 .75 -1.989 1.172 -3.182 1.172h-2.5a2 2 0 0 0 -1 3.75a1.3 1.3 0 0 1 -1 2.25"}),(0,_a.jsx)("path",{d:"M8.5 10.5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"}),(0,_a.jsx)("path",{d:"M12.5 7.5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"}),(0,_a.jsx)("path",{d:"M16.5 10.5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"})]})}function Zc(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M5 12l5 5l10 -10"})]})}function td(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M9 15l6 -6"}),(0,_a.jsx)("path",{d:"M11 6l.463 -.536a5 5 0 0 1 7.071 7.072l-.534 .464"}),(0,_a.jsx)("path",{d:"M13 18l-.397 .534a5.068 5.068 0 0 1 -7.127 0a4.972 4.972 0 0 1 0 -7.071l.524 -.463"})]})}function ed(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M12 6h-6a2 2 0 0 0 -2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-6"}),(0,_a.jsx)("path",{d:"M11 13l9 -9"}),(0,_a.jsx)("path",{d:"M15 4h5v5"})]})}function nd(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M9 14l-4 -4l4 -4"}),(0,_a.jsx)("path",{d:"M5 10h11a4 4 0 1 1 0 8h-1"})]})}function od(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M15 14l4 -4l-4 -4"}),(0,_a.jsx)("path",{d:"M19 10h-11a4 4 0 1 0 0 8h1"})]})}function rd(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M3.5 5.5l1.5 1.5l2.5 -2.5"}),(0,_a.jsx)("path",{d:"M3.5 11.5l1.5 1.5l2.5 -2.5"}),(0,_a.jsx)("path",{d:"M3.5 17.5l1.5 1.5l2.5 -2.5"}),(0,_a.jsx)("path",{d:"M11 6l9 0"}),(0,_a.jsx)("path",{d:"M11 12l9 0"}),(0,_a.jsx)("path",{d:"M11 18l9 0"})]})}function id(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M20 6l-11 0"}),(0,_a.jsx)("path",{d:"M20 12l-7 0"}),(0,_a.jsx)("path",{d:"M20 18l-11 0"}),(0,_a.jsx)("path",{d:"M4 8l4 4l-4 4"})]})}function sd(t){return(0,_a.jsxs)(Cc,{...t,children:[(0,_a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,_a.jsx)("path",{d:"M20 6l-7 0"}),(0,_a.jsx)("path",{d:"M20 12l-9 0"}),(0,_a.jsx)("path",{d:"M20 18l-7 0"}),(0,_a.jsx)("path",{d:"M8 8l-4 4l4 4"})]})}Mc.classes=kc,Mc.displayName="@mantine/tiptap/RichTextEditorContent";var ld=n(6076);const ad={interactive:!0},cd=(0,Wa.P9)(((t,e)=>{const n=(0,qa.Y)("RichTextEditorControl",ad,t),{classNames:o,className:r,style:i,styles:s,vars:l,interactive:a,active:c,onMouseDown:d,disabled:h,...p}=n,u=Xa();return(0,_a.jsx)(ld.N,{...p,...u.getStyles("control",{className:r,style:i,classNames:o,styles:s}),disabled:h,"data-rich-text-editor-control":!0,tabIndex:a?0:-1,"data-interactive":a||void 0,"data-disabled":h||void 0,"data-active":c||void 0,"aria-pressed":c&&a||void 0,"aria-hidden":!a||void 0,ref:e,unstyled:u.unstyled,variant:u.variant||"default",onMouseDown:t=>{t.preventDefault(),d?.(t)}})}));cd.classes=kc,cd.displayName="@mantine/tiptap/RichTextEditorControl";const dd=(0,Fa.forwardRef)((({className:t,icon:e,...n},o)=>{const r=Xa();return(0,_a.jsx)(cd,{ref:o,...n,children:(0,_a.jsx)(e,{...r.getStyles("controlIcon")})})}));function hd({label:t,isActive:e,operation:n,icon:o,isDisabled:r}){const i=(0,Fa.forwardRef)(((i,s)=>{const{editor:l,labels:a}=Xa(),c=a[t];return(0,_a.jsx)(dd,{...i,"aria-label":c,title:c,active:!!e?.name&&l?.isActive(e.name,e.attributes),ref:s,onClick:()=>l?.chain().focus()[n.name](n.attributes).run(),icon:i.icon||o,disabled:r?.(l)||!1})}));return i.displayName=`@mantine/tiptap/${t}`,i}dd.displayName="@mantine/tiptap/RichTextEditorControlBase";const pd=hd({label:"boldControlLabel",icon:t=>(0,_a.jsx)(Sc,{...t}),isActive:{name:"bold"},operation:{name:"toggleBold"}}),ud=hd({label:"italicControlLabel",icon:t=>(0,_a.jsx)(Tc,{...t}),isActive:{name:"italic"},operation:{name:"toggleItalic"}}),fd=hd({label:"underlineControlLabel",icon:t=>(0,_a.jsx)(Ac,{...t}),isActive:{name:"underline"},operation:{name:"toggleUnderline"}}),md=hd({label:"strikeControlLabel",icon:t=>(0,_a.jsx)(Oc,{...t}),isActive:{name:"strike"},operation:{name:"toggleStrike"}}),gd=hd({label:"clearFormattingControlLabel",icon:t=>(0,_a.jsx)(Ec,{...t}),operation:{name:"unsetAllMarks"}}),yd=hd({label:"unlinkControlLabel",icon:t=>(0,_a.jsx)($c,{...t}),operation:{name:"unsetLink"}}),bd=hd({label:"bulletListControlLabel",icon:t=>(0,_a.jsx)(Pc,{...t}),isActive:{name:"bulletList"},operation:{name:"toggleBulletList"}}),vd=hd({label:"orderedListControlLabel",icon:t=>(0,_a.jsx)(zc,{...t}),isActive:{name:"orderedList"},operation:{name:"toggleOrderedList"}}),wd=hd({label:"h1ControlLabel",icon:t=>(0,_a.jsx)(Nc,{...t}),isActive:{name:"heading",attributes:{level:1}},operation:{name:"toggleHeading",attributes:{level:1}}}),kd=hd({label:"h2ControlLabel",icon:t=>(0,_a.jsx)(Dc,{...t}),isActive:{name:"heading",attributes:{level:2}},operation:{name:"toggleHeading",attributes:{level:2}}}),xd=hd({label:"h3ControlLabel",icon:t=>(0,_a.jsx)(Rc,{...t}),isActive:{name:"heading",attributes:{level:3}},operation:{name:"toggleHeading",attributes:{level:3}}}),Md=hd({label:"h4ControlLabel",icon:t=>(0,_a.jsx)(jc,{...t}),isActive:{name:"heading",attributes:{level:4}},operation:{name:"toggleHeading",attributes:{level:4}}}),Cd=hd({label:"h5ControlLabel",icon:t=>(0,_a.jsx)(Lc,{...t}),isActive:{name:"heading",attributes:{level:5}},operation:{name:"toggleHeading",attributes:{level:5}}}),Sd=hd({label:"h6ControlLabel",icon:t=>(0,_a.jsx)(Ic,{...t}),isActive:{name:"heading",attributes:{level:6}},operation:{name:"toggleHeading",attributes:{level:6}}}),Td=hd({label:"blockquoteControlLabel",icon:t=>(0,_a.jsx)(Hc,{...t}),isActive:{name:"blockquote"},operation:{name:"toggleBlockquote"}}),Ad=hd({label:"alignLeftControlLabel",icon:t=>(0,_a.jsx)(Bc,{...t}),operation:{name:"setTextAlign",attributes:"left"}}),Od=hd({label:"alignRightControlLabel",icon:t=>(0,_a.jsx)(_c,{...t}),operation:{name:"setTextAlign",attributes:"right"}}),Ed=hd({label:"alignCenterControlLabel",icon:t=>(0,_a.jsx)(Fc,{...t}),operation:{name:"setTextAlign",attributes:"center"}}),Nd=hd({label:"alignJustifyControlLabel",icon:t=>(0,_a.jsx)(Vc,{...t}),operation:{name:"setTextAlign",attributes:"justify"}}),Dd=hd({label:"subscriptControlLabel",icon:t=>(0,_a.jsx)(Wc,{...t}),isActive:{name:"subscript"},operation:{name:"toggleSubscript"}}),Rd=hd({label:"superscriptControlLabel",icon:t=>(0,_a.jsx)(qc,{...t}),isActive:{name:"superscript"},operation:{name:"toggleSuperscript"}}),jd=hd({label:"codeControlLabel",icon:t=>(0,_a.jsx)(Kc,{...t}),isActive:{name:"code"},operation:{name:"toggleCode"}}),Ld=hd({label:"codeBlockControlLabel",icon:t=>(0,_a.jsx)(Kc,{...t}),isActive:{name:"codeBlock"},operation:{name:"toggleCodeBlock"}}),Id=hd({label:"highlightControlLabel",icon:t=>(0,_a.jsx)(Jc,{...t}),isActive:{name:"highlight"},operation:{name:"toggleHighlight"}}),Pd=hd({label:"hrControlLabel",icon:t=>(0,_a.jsx)(Uc,{...t}),operation:{name:"setHorizontalRule"}}),zd=hd({label:"unsetColorControlLabel",icon:t=>(0,_a.jsx)(Gc,{...t}),operation:{name:"unsetColor"}}),$d=hd({label:"undoControlLabel",icon:t=>(0,_a.jsx)(nd,{...t}),isDisabled:t=>!t?.can().undo(),operation:{name:"undo"}}),Hd=hd({label:"redoControlLabel",icon:t=>(0,_a.jsx)(od,{...t}),isDisabled:t=>!t?.can().redo(),operation:{name:"redo"}}),Bd=hd({label:"tasksControlLabel",icon:t=>(0,_a.jsx)(rd,{...t}),isActive:{name:"taskList"},operation:{name:"toggleTaskList"}}),_d=hd({label:"tasksSinkLabel",icon:t=>(0,_a.jsx)(id,{...t}),operation:{name:"sinkListItem",attributes:"taskItem"},isDisabled:t=>!t?.can().sinkListItem("taskItem")}),Fd=hd({label:"tasksLiftLabel",icon:t=>(0,_a.jsx)(sd,{...t}),operation:{name:"liftListItem",attributes:"taskItem"},isDisabled:t=>!t?.can().liftListItem("taskItem")});var Vd=n(9274),Wd=n(5172),qd=n(7193),Kd=n(2335),Jd=n(8149),Ud=n(5055);function Gd(t){return e=>{if(e)if("function"==typeof e)t(e);else if("object"==typeof e&&"nativeEvent"in e){const{currentTarget:n}=e;"checkbox"===n.type?t(n.checked):t(n.value)}else t(e);else t(e)}}var Yd=n(3489),Xd=n(977);const Qd=t=>(0,_a.jsx)(td,{...t}),Zd={},th=(0,Wa.P9)(((t,e)=>{const n=(0,qa.Y)("RichTextEditorLinkControl",Zd,t),{classNames:o,className:r,style:i,styles:s,vars:l,icon:a,popoverProps:c,disableTooltips:d,initialExternal:h,...p}=n,u=Xa(),f={classNames:o,styles:s},[m,g]=function(){const[t,e]=(0,Fa.useState)("");return[t,Gd(e)]}(),[y,b]=(0,Fa.useState)(h),[v,{open:w,close:k}]=(0,Yd.j)(!1),x=()=>{w();const t=u.editor?.getAttributes("link");g(t?.href||""),b(t?.href?"_blank"===t?.target:h)},M=()=>{k(),g(""),b(h)},C=()=>{M(),""===m?u.editor?.chain().focus().extendMarkRange("link").unsetLink().run():u.editor?.chain().focus().extendMarkRange("link").setLink({href:m,target:y?"_blank":null}).run()};(0,Xd.M)("edit-link",x,!1);const{resolvedClassNames:S,resolvedStyles:T}=(0,Vd.Y)({classNames:o,styles:s,props:n});return(0,_a.jsxs)(Wd.A,{trapFocus:!0,shadow:"md",withinPortal:!0,opened:v,onChange:t=>!t&&M(),offset:-44,zIndex:1e4,...c,children:[(0,_a.jsx)(Wd.A.Target,{children:(0,_a.jsx)(dd,{icon:a||Qd,...p,"aria-label":u.labels.linkControlLabel,title:u.labels.linkControlLabel,onClick:x,active:u.editor?.isActive("link"),ref:e,classNames:S,styles:T,className:r,style:i,variant:u.variant})}),(0,_a.jsx)(Wd.A.Dropdown,{...u.getStyles("linkEditorDropdown",f),children:(0,_a.jsxs)("div",{...u.getStyles("linkEditor",f),children:[(0,_a.jsx)(qd.k,{placeholder:u.labels.linkEditorInputPlaceholder,"aria-label":u.labels.linkEditorInputLabel,type:"url",value:m,onChange:g,classNames:{input:u.getStyles("linkEditorInput",f).className},onKeyDown:t=>{"Enter"===t.key&&(t.preventDefault(),C())},rightSection:(0,_a.jsx)(Kd.m,{label:y?u.labels.linkEditorExternalLink:u.labels.linkEditorInternalLink,events:{hover:!0,focus:!0,touch:!0},withinPortal:!0,withArrow:!0,disabled:d,zIndex:1e4,children:(0,_a.jsx)(ld.N,{onClick:()=>b((t=>!t)),"data-active":y||void 0,...u.getStyles("linkEditorExternalControl",f),children:(0,_a.jsx)(ed,{style:{width:(0,Jd.D)(14),height:(0,Jd.D)(14)}})})})}),(0,_a.jsx)(Ud.$,{variant:"default",onClick:C,...u.getStyles("linkEditorSave",f),children:u.labels.linkEditorSave})]})})]})}));th.classes=kc,th.displayName="@mantine/tiptap/RichTextEditorLinkControl";var eh=n(9731),nh=n(9277),oh=n(2865),rh=n(4999),ih=n(8324);const sh={},lh=(0,Fa.forwardRef)(((t,e)=>{const{popoverProps:n,colors:o,colorPickerProps:r,...i}=(0,qa.Y)("RichTextEditorColorPickerControl",sh,t),{editor:s,labels:l,getStyles:a,variant:c}=Xa(),[d,{toggle:h,close:p}]=(0,Yd.j)(!1),[u,f]=(0,Fa.useState)("palette"),m=s?.getAttributes("textStyle").color||"var(--mantine-color-text)",g=(t,e=!0)=>{(s?.chain()).focus().setColor(t).run(),e&&p()},y=o.map(((t,e)=>(0,_a.jsx)(eh.q,{component:"button",color:t,onClick:()=>g(t),size:26,radius:"xs",style:{cursor:"pointer"},title:l.colorPickerColorLabel(t),"aria-label":l.colorPickerColorLabel(t)},e)));return(0,_a.jsxs)(Wd.A,{opened:d,withinPortal:!0,trapFocus:!0,onChange:t=>!t&&p(),...n,children:[(0,_a.jsx)(Wd.A.Target,{children:(0,_a.jsx)(cd,{...i,variant:c,"aria-label":l.colorPickerControlLabel,title:l.colorPickerControlLabel,ref:e,onClick:h,children:(0,_a.jsx)(eh.q,{color:m,size:14})})}),(0,_a.jsxs)(Wd.A.Dropdown,{...a("linkEditorDropdown"),children:["palette"===u&&(0,_a.jsx)(nh.r,{cols:7,spacing:2,children:y}),"colorPicker"===u&&(0,_a.jsx)(oh.s,{defaultValue:m,onChange:t=>g(t,!1),...r}),(0,_a.jsx)(Kd.m.Group,{closeDelay:200,children:(0,_a.jsxs)(rh.Y,{justify:"flex-end",gap:"xs",mt:"sm",children:["palette"===u&&(0,_a.jsx)(ih.M,{variant:"default",onClick:p,title:l.colorPickerCancel,"aria-label":l.colorPickerCancel,children:(0,_a.jsx)(Xc,{style:{width:(0,Jd.D)(16),height:(0,Jd.D)(16)}})}),(0,_a.jsx)(ih.M,{variant:"default",onClick:()=>{(s?.chain()).focus().unsetColor().run(),p()},title:l.colorPickerClear,"aria-label":l.colorPickerClear,children:(0,_a.jsx)(Gc,{style:{width:(0,Jd.D)(16),height:(0,Jd.D)(16)}})}),"palette"===u?(0,_a.jsx)(ih.M,{variant:"default",onClick:()=>f("colorPicker"),title:l.colorPickerColorPicker,"aria-label":l.colorPickerColorPicker,children:(0,_a.jsx)(Yc,{style:{width:(0,Jd.D)(16),height:(0,Jd.D)(16)}})}):(0,_a.jsx)(ih.M,{variant:"default",onClick:()=>f("palette"),"aria-label":l.colorPickerPalette,title:l.colorPickerPalette,children:(0,_a.jsx)(Qc,{style:{width:(0,Jd.D)(16),height:(0,Jd.D)(16)}})}),"colorPicker"===u&&(0,_a.jsx)(ih.M,{variant:"default",onClick:p,title:l.colorPickerSave,"aria-label":l.colorPickerSave,children:(0,_a.jsx)(Zc,{style:{width:(0,Jd.D)(16),height:(0,Jd.D)(16)}})})]})})]})]})}));lh.displayName="@mantine/tiptap/ColorPickerControl";const ah={},ch=(0,Fa.forwardRef)(((t,e)=>{const{color:n,...o}=(0,qa.Y)("RichTextEditorColorControl",ah,t),{editor:r,labels:i,variant:s}=Xa(),l=r?.getAttributes("textStyle").color||null,a=i.colorControlLabel(n);return(0,_a.jsx)(cd,{...o,variant:s,active:l===n,"aria-label":a,title:a,onClick:()=>(r?.chain()).focus().setColor(n).run(),ref:e,children:(0,_a.jsx)(eh.q,{color:n,size:14})})}));ch.displayName="@mantine/tiptap/RichTextEditorColorControl";const dh={},hh=(0,Wa.P9)(((t,e)=>{const n=(0,qa.Y)("RichTextEditorControlsGroup",dh,t),{classNames:o,className:r,style:i,styles:s,vars:l,variant:a,...c}=n,d=Xa();return(0,_a.jsx)(Ja.a,{ref:e,variant:a||d.variant,...d.getStyles("controlsGroup",{className:r,style:i,styles:s,classNames:o}),...c})}));hh.classes=kc,hh.displayName="@mantine/tiptap/RichTextEditorControlsGroup";const ph={},uh=(0,Wa.P9)(((t,e)=>{const n=(0,qa.Y)("RichTextEditorToolbar",ph,t),{classNames:o,className:r,style:i,styles:s,vars:l,sticky:a,stickyOffset:c,mod:d,variant:h,...p}=n,u=Xa();return(0,_a.jsx)(Ja.a,{ref:e,mod:[{sticky:a},d],variant:h||u.variant,...u.getStyles("toolbar",{className:r,style:i,styles:s,classNames:o}),...p,__vars:{"--rte-sticky-offset":(0,Jd.D)(c)}})}));uh.classes=kc,uh.displayName="@mantine/tiptap/RichTextEditorToolbar";const fh={withCodeHighlightStyles:!0,withTypographyStyles:!0,variant:"default"},mh=(0,Wa.P9)(((t,e)=>{const n=(0,qa.Y)("RichTextEditor",fh,t),{classNames:o,className:r,style:i,styles:s,unstyled:l,vars:a,editor:c,withCodeHighlightStyles:d,withTypographyStyles:h,labels:p,children:u,variant:f,...m}=n,g=(0,Ka.I)({name:"RichTextEditor",classes:kc,props:n,className:r,style:i,classNames:o,styles:s,unstyled:l,vars:a}),y=(0,Fa.useMemo)((()=>({...Ua,...p})),[p]);return(0,_a.jsx)(Ya,{value:{editor:c,getStyles:g,labels:y,withCodeHighlightStyles:d,withTypographyStyles:h,unstyled:l,variant:f},children:(0,_a.jsx)(Ja.a,{...g("root"),...m,ref:e,children:u})})}));mh.classes=kc,mh.displayName="@mantine/tiptap/RichTextEditor",mh.Content=Mc,mh.Control=cd,mh.Toolbar=uh,mh.ControlsGroup=hh,mh.Bold=pd,mh.Italic=ud,mh.Strikethrough=md,mh.Underline=fd,mh.ClearFormatting=gd,mh.H1=wd,mh.H2=kd,mh.H3=xd,mh.H4=Md,mh.H5=Cd,mh.H6=Sd,mh.BulletList=bd,mh.OrderedList=vd,mh.Link=th,mh.Unlink=yd,mh.Blockquote=Td,mh.AlignLeft=Ad,mh.AlignRight=Od,mh.AlignCenter=Ed,mh.AlignJustify=Nd,mh.Superscript=Rd,mh.Subscript=Dd,mh.Code=jd,mh.CodeBlock=Ld,mh.ColorPicker=lh,mh.Color=ch,mh.Highlight=Id,mh.Hr=Pd,mh.UnsetColor=zd,mh.Undo=$d,mh.Redo=Hd,mh.TaskList=Bd,mh.TaskListSink=_d,mh.TaskListLift=Fd;var gh=n(5072),yh=n.n(gh),bh=n(7825),vh=n.n(bh),wh=n(5056),kh=n.n(wh),xh=n(540),Mh=n.n(xh),Ch=n(1113),Sh=n.n(Ch),Th=n(6541),Ah={};Ah.styleTagTransform=Sh(),Ah.setAttributes=kh(),Ah.insert=function(t){var e=document.querySelector("head"),n=window._lastElementInsertedByStyleLoader;n?n.nextSibling?e.insertBefore(t,n.nextSibling):e.appendChild(t):e.insertBefore(t,e.firstChild),window._lastElementInsertedByStyleLoader=t},Ah.domAPI=vh(),Ah.insertStyleElement=Mh(),yh()(Th.A,Ah),Th.A&&Th.A.locals&&Th.A.locals;var Oh=n(4193),Eh=n(297);const Nh=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,Dh=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,Rh=Vi.create({name:"highlight",addOptions:()=>({multicolor:!1,HTMLAttributes:{}}),addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:t=>t.getAttribute("data-color")||t.style.backgroundColor,renderHTML:t=>t.color?{"data-color":t.color,style:`background-color: ${t.color}; color: inherit`}:{}}}:{}},parseHTML:()=>[{tag:"mark"}],renderHTML({HTMLAttributes:t}){return["mark",Oi(this.options.HTMLAttributes,t),0]},addCommands(){return{setHighlight:t=>({commands:e})=>e.setMark(this.name,t),toggleHighlight:t=>({commands:e})=>e.toggleMark(this.name,t),unsetHighlight:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[$s({find:Nh,type:this.type})]},addPasteRules(){return[Vs({find:Dh,type:this.type})]}}),jh=/^\s*>\s$/,Lh=Fs.create({name:"blockquote",addOptions:()=>({HTMLAttributes:{}}),content:"block+",group:"block",defining:!0,parseHTML:()=>[{tag:"blockquote"}],renderHTML({HTMLAttributes:t}){return["blockquote",Oi(this.options.HTMLAttributes,t),0]},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[_s({find:jh,type:this.type})]}}),Ih=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Ph=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,zh=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,$h=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Hh=Vi.create({name:"bold",addOptions:()=>({HTMLAttributes:{}}),parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>"normal"!==t.style.fontWeight&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return["strong",Oi(this.options.HTMLAttributes,t),0]},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[$s({find:Ih,type:this.type}),$s({find:zh,type:this.type})]},addPasteRules(){return[Vs({find:Ph,type:this.type}),Vs({find:$h,type:this.type})]}}),Bh="textStyle",_h=/^\s*([-+*])\s$/,Fh=Fs.create({name:"bulletList",addOptions:()=>({itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}),group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML:()=>[{tag:"ul"}],renderHTML({HTMLAttributes:t}){return["ul",Oi(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes("listItem",this.editor.getAttributes(Bh)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=_s({find:_h,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=_s({find:_h,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Bh),editor:this.editor})),[t]}}),Vh=/(^|[^`])`([^`]+)`(?!`)/,Wh=/(^|[^`])`([^`]+)`(?!`)/g,qh=Vi.create({name:"code",addOptions:()=>({HTMLAttributes:{}}),excludes:"_",code:!0,exitable:!0,parseHTML:()=>[{tag:"code"}],renderHTML({HTMLAttributes:t}){return["code",Oi(this.options.HTMLAttributes,t),0]},addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[$s({find:Vh,type:this.type})]},addPasteRules(){return[Vs({find:Wh,type:this.type})]}}),Kh=/^```([a-z]+)?[\s\n]$/,Jh=/^~~~([a-z]+)?[\s\n]$/,Uh=Fs.create({name:"codeBlock",addOptions:()=>({languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,HTMLAttributes:{}}),content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options;return[...(null===(e=t.firstElementChild)||void 0===e?void 0:e.classList)||[]].filter((t=>t.startsWith(n))).map((t=>t.replace(n,"")))[0]||null},rendered:!1}}},parseHTML:()=>[{tag:"pre",preserveWhitespace:"full"}],renderHTML({node:t,HTMLAttributes:e}){return["pre",Oi(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=1===e.pos;return!(!t||e.parent.type.name!==this.name)&&!(!n&&e.parent.textContent.length)&&this.editor.commands.clearNodes()},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:o,empty:r}=n;if(!r||o.parent.type!==this.type)return!1;const i=o.parentOffset===o.parent.nodeSize-2,s=o.parent.textContent.endsWith("\n\n");return!(!i||!s)&&t.chain().command((({tr:t})=>(t.delete(o.pos-2,o.pos),!0))).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:o}=e,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;if(r.parentOffset!==r.parent.nodeSize-2)return!1;const s=r.after();return void 0!==s&&(o.nodeAt(s)?t.commands.command((({tr:t})=>(t.setSelection(oe.near(o.resolve(s))),!0))):t.commands.exitCode())}}},addInputRules(){return[Bs({find:Kh,type:this.type,getAttributes:t=>({language:t[1]})}),Bs({find:Jh,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new xe({key:new Se("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData)return!1;if(this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),o=e.clipboardData.getData("vscode-editor-data"),r=o?JSON.parse(o):void 0,i=null==r?void 0:r.mode;if(!n||!i)return!1;const{tr:s,schema:l}=t.state,a=l.text(n.replace(/\r\n?/g,"\n"));return s.replaceSelectionWith(this.type.create({language:i},a)),s.selection.$from.parent.type!==this.type&&s.setSelection(le.near(s.doc.resolve(Math.max(0,s.selection.from-2)))),s.setMeta("paste",!0),t.dispatch(s),!0}}})]}}),Gh=Fs.create({name:"doc",topNode:!0,content:"block+"});function Yh(t={}){return new xe({view:e=>new Xh(e,t)})}class Xh{constructor(t,e){var n;this.editorView=t,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=null!==(n=e.width)&&void 0!==n?n:1,this.color=!1===e.color?void 0:e.color||"black",this.class=e.class,this.handlers=["dragover","dragend","drop","dragleave"].map((e=>{let n=t=>{this[e](t)};return t.dom.addEventListener(e,n),{name:e,handler:n}}))}destroy(){this.handlers.forEach((({name:t,handler:e})=>this.editorView.dom.removeEventListener(t,e)))}update(t,e){null!=this.cursorPos&&e.doc!=t.state.doc&&(this.cursorPos>t.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(t){t!=this.cursorPos&&(this.cursorPos=t,null==t?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let t,e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent;if(n){let n=e.nodeBefore,o=e.nodeAfter;if(n||o){let e=this.editorView.nodeDOM(this.cursorPos-(n?n.nodeSize:0));if(e){let r=e.getBoundingClientRect(),i=n?r.bottom:r.top;n&&o&&(i=(i+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2),t={left:r.left,right:r.right,top:i-this.width/2,bottom:i+this.width/2}}}}if(!t){let e=this.editorView.coordsAtPos(this.cursorPos);t={left:e.left-this.width/2,right:e.left+this.width/2,top:e.top,bottom:e.bottom}}let o,r,i=this.editorView.dom.offsetParent;if(this.element||(this.element=i.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),!i||i==document.body&&"static"==getComputedStyle(i).position)o=-pageXOffset,r=-pageYOffset;else{let t=i.getBoundingClientRect();o=t.left-i.scrollLeft,r=t.top-i.scrollTop}this.element.style.left=t.left-o+"px",this.element.style.top=t.top-r+"px",this.element.style.width=t.right-t.left+"px",this.element.style.height=t.bottom-t.top+"px"}scheduleRemoval(t){clearTimeout(this.timeout),this.timeout=setTimeout((()=>this.setCursor(null)),t)}dragover(t){if(!this.editorView.editable)return;let e=this.editorView.posAtCoords({left:t.clientX,top:t.clientY}),n=e&&e.inside>=0&&this.editorView.state.doc.nodeAt(e.inside),o=n&&n.type.spec.disableDropCursor,r="function"==typeof o?o(this.editorView,e,t):o;if(e&&!r){let t=e.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let e=_t(this.editorView.state.doc,t,this.editorView.dragging.slice);null!=e&&(t=e)}this.setCursor(t),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(t){t.target!=this.editorView.dom&&this.editorView.dom.contains(t.relatedTarget)||this.setCursor(null)}}const Qh=Ui.create({name:"dropCursor",addOptions:()=>({color:"currentColor",width:1,class:void 0}),addProseMirrorPlugins(){return[Yh(this.options)]}});class Zh extends oe{constructor(t){super(t,t)}map(t,e){let n=t.resolve(e.map(this.head));return Zh.valid(n)?new Zh(n):oe.near(n)}content(){return f.empty}eq(t){return t instanceof Zh&&t.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(t,e){if("number"!=typeof e.pos)throw new RangeError("Invalid input for GapCursor.fromJSON");return new Zh(t.resolve(e.pos))}getBookmark(){return new tp(this.anchor)}static valid(t){let e=t.parent;if(e.isTextblock||!function(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),o=t.node(e);if(0!=n)for(let t=o.child(n-1);;t=t.lastChild){if(0==t.childCount&&!t.inlineContent||t.isAtom||t.type.spec.isolating)return!0;if(t.inlineContent)return!1}else if(o.type.spec.isolating)return!0}return!0}(t)||!function(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),o=t.node(e);if(n!=o.childCount)for(let t=o.child(n);;t=t.firstChild){if(0==t.childCount&&!t.inlineContent||t.isAtom||t.type.spec.isolating)return!0;if(t.inlineContent)return!1}else if(o.type.spec.isolating)return!0}return!0}(t))return!1;let n=e.type.spec.allowGapCursor;if(null!=n)return n;let o=e.contentMatchAt(t.index()).defaultType;return o&&o.isTextblock}static findGapCursorFrom(t,e,n=!1){t:for(;;){if(!n&&Zh.valid(t))return t;let o=t.pos,r=null;for(let n=t.depth;;n--){let i=t.node(n);if(e>0?t.indexAfter(n)<i.childCount:t.index(n)>0){r=i.child(e>0?t.indexAfter(n):t.index(n)-1);break}if(0==n)return null;o+=e;let s=t.doc.resolve(o);if(Zh.valid(s))return s}for(;;){let i=e>0?r.firstChild:r.lastChild;if(!i){if(r.isAtom&&!r.isText&&!ce.isSelectable(r)){t=t.doc.resolve(o+r.nodeSize*e),n=!1;continue t}break}r=i,o+=e;let s=t.doc.resolve(o);if(Zh.valid(s))return s}return null}}}Zh.prototype.visible=!1,Zh.findFrom=Zh.findGapCursorFrom,oe.jsonID("gapcursor",Zh);class tp{constructor(t){this.pos=t}map(t){return new tp(t.map(this.pos))}resolve(t){let e=t.resolve(this.pos);return Zh.valid(e)?new Zh(e):oe.near(e)}}const ep=Jr({ArrowLeft:np("horiz",-1),ArrowRight:np("horiz",1),ArrowUp:np("vert",-1),ArrowDown:np("vert",1)});function np(t,e){const n="vert"==t?e>0?"down":"up":e>0?"right":"left";return function(t,o,r){let i=t.selection,s=e>0?i.$to:i.$from,l=i.empty;if(i instanceof le){if(!r.endOfTextblock(n)||0==s.depth)return!1;l=!1,s=t.doc.resolve(e>0?s.after():s.before())}let a=Zh.findGapCursorFrom(s,e,l);return!!a&&(o&&o(t.tr.setSelection(new Zh(a))),!0)}}function op(t,e,n){if(!t||!t.editable)return!1;let o=t.state.doc.resolve(e);if(!Zh.valid(o))return!1;let r=t.posAtCoords({left:n.clientX,top:n.clientY});return!(r&&r.inside>-1&&ce.isSelectable(t.state.doc.nodeAt(r.inside))||(t.dispatch(t.state.tr.setSelection(new Zh(o))),0))}function rp(t,e){if("insertCompositionText"!=e.inputType||!(t.state.selection instanceof Zh))return!1;let{$from:n}=t.state.selection,o=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!o)return!1;let r=a.empty;for(let t=o.length-1;t>=0;t--)r=a.from(o[t].createAndFill(null,r));let i=t.state.tr.replace(n.pos,n.pos,new f(r,0,0));return i.setSelection(le.near(i.doc.resolve(n.pos+1))),t.dispatch(i),!1}function ip(t){if(!(t.selection instanceof Zh))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",ar.create(t.doc,[ir.widget(t.selection.head,e,{key:"gapcursor"})])}const sp=Ui.create({name:"gapCursor",addProseMirrorPlugins:()=>[new xe({props:{decorations:ip,createSelectionBetween:(t,e,n)=>e.pos==n.pos&&Zh.valid(n)?new Zh(n):null,handleClick:op,handleKeyDown:ep,handleDOMEvents:{beforeinput:rp}}})],extendNodeSchema(t){var e;return{allowGapCursor:null!==(e=Di(Ci(t,"allowGapCursor",{name:t.name,options:t.options,storage:t.storage})))&&void 0!==e?e:null}}}),lp=Fs.create({name:"hardBreak",addOptions:()=>({keepMarks:!0,HTMLAttributes:{}}),inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML:()=>[{tag:"br"}],renderHTML({HTMLAttributes:t}){return["br",Oi(this.options.HTMLAttributes,t)]},renderText:()=>"\n",addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:o})=>t.first([()=>t.exitCode(),()=>t.command((()=>{const{selection:t,storedMarks:r}=n;if(t.$from.parent.type.spec.isolating)return!1;const{keepMarks:i}=this.options,{splittableMarks:s}=o.extensionManager,l=r||t.$to.parentOffset&&t.$from.marks();return e().insertContent({type:this.name}).command((({tr:t,dispatch:e})=>{if(e&&l&&i){const e=l.filter((t=>s.includes(t.type.name)));t.ensureMarks(e)}return!0})).run()}))])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),ap=Fs.create({name:"heading",addOptions:()=>({levels:[1,2,3,4,5,6],HTMLAttributes:{}}),content:"inline*",group:"block",defining:!0,addAttributes:()=>({level:{default:1,rendered:!1}}),parseHTML(){return this.options.levels.map((t=>({tag:`h${t}`,attrs:{level:t}})))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,Oi(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:t=>({commands:e})=>!!this.options.levels.includes(t.level)&&e.setNode(this.name,t),toggleHeading:t=>({commands:e})=>!!this.options.levels.includes(t.level)&&e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return this.options.levels.reduce(((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})})),{})},addInputRules(){return this.options.levels.map((t=>Bs({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}})))}});var cp=200,dp=function(){};dp.prototype.append=function(t){return t.length?(t=dp.from(t),!this.length&&t||t.length<cp&&this.leafAppend(t)||this.length<cp&&t.leafPrepend(this)||this.appendInner(t)):this},dp.prototype.prepend=function(t){return t.length?dp.from(t).append(this):this},dp.prototype.appendInner=function(t){return new pp(this,t)},dp.prototype.slice=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=this.length),t>=e?dp.empty:this.sliceInner(Math.max(0,t),Math.min(this.length,e))},dp.prototype.get=function(t){if(!(t<0||t>=this.length))return this.getInner(t)},dp.prototype.forEach=function(t,e,n){void 0===e&&(e=0),void 0===n&&(n=this.length),e<=n?this.forEachInner(t,e,n,0):this.forEachInvertedInner(t,e,n,0)},dp.prototype.map=function(t,e,n){void 0===e&&(e=0),void 0===n&&(n=this.length);var o=[];return this.forEach((function(e,n){return o.push(t(e,n))}),e,n),o},dp.from=function(t){return t instanceof dp?t:t&&t.length?new hp(t):dp.empty};var hp=function(t){function e(e){t.call(this),this.values=e}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(t,n){return 0==t&&n==this.length?this:new e(this.values.slice(t,n))},e.prototype.getInner=function(t){return this.values[t]},e.prototype.forEachInner=function(t,e,n,o){for(var r=e;r<n;r++)if(!1===t(this.values[r],o+r))return!1},e.prototype.forEachInvertedInner=function(t,e,n,o){for(var r=e-1;r>=n;r--)if(!1===t(this.values[r],o+r))return!1},e.prototype.leafAppend=function(t){if(this.length+t.length<=cp)return new e(this.values.concat(t.flatten()))},e.prototype.leafPrepend=function(t){if(this.length+t.length<=cp)return new e(t.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e}(dp);dp.empty=new hp([]);var pp=function(t){function e(e,n){t.call(this),this.left=e,this.right=n,this.length=e.length+n.length,this.depth=Math.max(e.depth,n.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(t){return t<this.left.length?this.left.get(t):this.right.get(t-this.left.length)},e.prototype.forEachInner=function(t,e,n,o){var r=this.left.length;return!(e<r&&!1===this.left.forEachInner(t,e,Math.min(n,r),o))&&!(n>r&&!1===this.right.forEachInner(t,Math.max(e-r,0),Math.min(this.length,n)-r,o+r))&&void 0},e.prototype.forEachInvertedInner=function(t,e,n,o){var r=this.left.length;return!(e>r&&!1===this.right.forEachInvertedInner(t,e-r,Math.max(n,r)-r,o+r))&&!(n<r&&!1===this.left.forEachInvertedInner(t,Math.min(e,r),n,o))&&void 0},e.prototype.sliceInner=function(t,e){if(0==t&&e==this.length)return this;var n=this.left.length;return e<=n?this.left.slice(t,e):t>=n?this.right.slice(t-n,e-n):this.left.slice(t,n).append(this.right.slice(0,e-n))},e.prototype.leafAppend=function(t){var n=this.right.leafAppend(t);if(n)return new e(this.left,n)},e.prototype.leafPrepend=function(t){var n=this.left.leafPrepend(t);if(n)return new e(n,this.right)},e.prototype.appendInner=function(t){return this.left.depth>=Math.max(this.right.depth,t.depth)+1?new e(this.left,new e(this.right,t)):new e(this,t)},e}(dp);const up=dp;class fp{constructor(t,e){this.items=t,this.eventCount=e}popEvent(t,e){if(0==this.eventCount)return null;let n,o,r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}e&&(n=this.remapping(r,this.items.length),o=n.maps.length);let i,s,l=t.tr,a=[],c=[];return this.items.forEach(((t,e)=>{if(!t.step)return n||(n=this.remapping(r,e+1),o=n.maps.length),o--,void c.push(t);if(n){c.push(new mp(t.map));let e,r=t.step.map(n.slice(o));r&&l.maybeStep(r).doc&&(e=l.mapping.maps[l.mapping.maps.length-1],a.push(new mp(e,void 0,void 0,a.length+c.length))),o--,e&&n.appendMap(e,o)}else l.maybeStep(t.step);return t.selection?(i=n?t.selection.map(n.slice(o)):t.selection,s=new fp(this.items.slice(0,r).append(c.reverse().concat(a)),this.eventCount-1),!1):void 0}),this.items.length,0),{remaining:s,transform:l,selection:i}}addTransform(t,e,n,o){let r=[],i=this.eventCount,s=this.items,l=!o&&s.length?s.get(s.length-1):null;for(let n=0;n<t.steps.length;n++){let a,c=t.steps[n].invert(t.docs[n]),d=new mp(t.mapping.maps[n],c,e);(a=l&&l.merge(d))&&(d=a,n?r.pop():s=s.slice(0,s.length-1)),r.push(d),e&&(i++,e=void 0),o||(l=d)}let a=i-n.depth;return a>yp&&(s=function(t,e){let n;return t.forEach(((t,o)=>{if(t.selection&&0==e--)return n=o,!1})),t.slice(n)}(s,a),i-=a),new fp(s.append(r),i)}remapping(t,e){let n=new bt;return this.items.forEach(((e,o)=>{let r=null!=e.mirrorOffset&&o-e.mirrorOffset>=t?n.maps.length-e.mirrorOffset:void 0;n.appendMap(e.map,r)}),t,e),n}addMaps(t){return 0==this.eventCount?this:new fp(this.items.append(t.map((t=>new mp(t)))),this.eventCount)}rebased(t,e){if(!this.eventCount)return this;let n=[],o=Math.max(0,this.items.length-e),r=t.mapping,i=t.steps.length,s=this.eventCount;this.items.forEach((t=>{t.selection&&s--}),o);let l=e;this.items.forEach((e=>{let o=r.getMirror(--l);if(null==o)return;i=Math.min(i,o);let a=r.maps[o];if(e.step){let i=t.steps[o].invert(t.docs[o]),c=e.selection&&e.selection.map(r.slice(l+1,o));c&&s++,n.push(new mp(a,i,c))}else n.push(new mp(a))}),o);let a=[];for(let t=e;t<i;t++)a.push(new mp(r.maps[t]));let c=this.items.slice(0,o).append(a).append(n),d=new fp(c,s);return d.emptyItemCount()>500&&(d=d.compress(this.items.length-n.length)),d}emptyItemCount(){let t=0;return this.items.forEach((e=>{e.step||t++})),t}compress(t=this.items.length){let e=this.remapping(0,t),n=e.maps.length,o=[],r=0;return this.items.forEach(((i,s)=>{if(s>=t)o.push(i),i.selection&&r++;else if(i.step){let t=i.step.map(e.slice(n)),s=t&&t.getMap();if(n--,s&&e.appendMap(s,n),t){let l=i.selection&&i.selection.map(e.slice(n));l&&r++;let a,c=new mp(s.invert(),t,l),d=o.length-1;(a=o.length&&o[d].merge(c))?o[d]=a:o.push(c)}}else i.map&&n--}),this.items.length,0),new fp(up.from(o.reverse()),r)}}fp.empty=new fp(up.empty,0);class mp{constructor(t,e,n,o){this.map=t,this.step=e,this.selection=n,this.mirrorOffset=o}merge(t){if(this.step&&t.step&&!t.selection){let e=t.step.merge(this.step);if(e)return new mp(e.getMap().invert(),e,this.selection)}}}class gp{constructor(t,e,n,o,r){this.done=t,this.undone=e,this.prevRanges=n,this.prevTime=o,this.prevComposition=r}}const yp=20;function bp(t){let e=[];for(let n=t.length-1;n>=0&&0==e.length;n--)t[n].forEach(((t,n,o,r)=>e.push(o,r)));return e}function vp(t,e){if(!t)return null;let n=[];for(let o=0;o<t.length;o+=2){let r=e.map(t[o],1),i=e.map(t[o+1],-1);r<=i&&n.push(r,i)}return n}let wp=!1,kp=null;function xp(t){let e=t.plugins;if(kp!=e){wp=!1,kp=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){wp=!0;break}}return wp}const Mp=new Se("history"),Cp=new Se("closeHistory");function Sp(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new xe({key:Mp,state:{init:()=>new gp(fp.empty,fp.empty,null,0,-1),apply:(e,n,o)=>function(t,e,n,o){let r,i=n.getMeta(Mp);if(i)return i.historyState;n.getMeta(Cp)&&(t=new gp(t.done,t.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(0==n.steps.length)return t;if(s&&s.getMeta(Mp))return s.getMeta(Mp).redo?new gp(t.done.addTransform(n,void 0,o,xp(e)),t.undone,bp(n.mapping.maps),t.prevTime,t.prevComposition):new gp(t.done,t.undone.addTransform(n,void 0,o,xp(e)),null,t.prevTime,t.prevComposition);if(!1===n.getMeta("addToHistory")||s&&!1===s.getMeta("addToHistory"))return(r=n.getMeta("rebased"))?new gp(t.done.rebased(n,r),t.undone.rebased(n,r),vp(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new gp(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),vp(t.prevRanges,n.mapping),t.prevTime,t.prevComposition);{let r=n.getMeta("composition"),i=0==t.prevTime||!s&&t.prevComposition!=r&&(t.prevTime<(n.time||0)-o.newGroupDelay||!function(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach(((t,o)=>{for(let r=0;r<e.length;r+=2)t<=e[r+1]&&o>=e[r]&&(n=!0)})),n}(n,t.prevRanges)),l=s?vp(t.prevRanges,n.mapping):bp(n.mapping.maps);return new gp(t.done.addTransform(n,i?e.selection.getBookmark():void 0,o,xp(e)),fp.empty,l,n.time,null==r?t.prevComposition:r)}}(n,o,e,t)},config:t,props:{handleDOMEvents:{beforeinput(t,e){let n=e.inputType,o="historyUndo"==n?Ap:"historyRedo"==n?Op:null;return!!o&&(e.preventDefault(),o(t.state,t.dispatch))}}}})}function Tp(t,e){return(n,o)=>{let r=Mp.getState(n);if(!r||0==(t?r.undone:r.done).eventCount)return!1;if(o){let i=function(t,e,n){let o=xp(e),r=Mp.get(e).spec.config,i=(n?t.undone:t.done).popEvent(e,o);if(!i)return null;let s=i.selection.resolve(i.transform.doc),l=(n?t.done:t.undone).addTransform(i.transform,e.selection.getBookmark(),r,o),a=new gp(n?l:i.remaining,n?i.remaining:l,null,0,-1);return i.transform.setSelection(s).setMeta(Mp,{redo:n,historyState:a})}(r,n,t);i&&o(e?i.scrollIntoView():i)}return!0}}const Ap=Tp(!1,!0),Op=Tp(!0,!0);Tp(!1,!1),Tp(!0,!1);const Ep=Ui.create({name:"history",addOptions:()=>({depth:100,newGroupDelay:500}),addCommands:()=>({undo:()=>({state:t,dispatch:e})=>Ap(t,e),redo:()=>({state:t,dispatch:e})=>Op(t,e)}),addProseMirrorPlugins(){return[Sp(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),Np=Fs.create({name:"horizontalRule",addOptions:()=>({HTMLAttributes:{}}),group:"block",parseHTML:()=>[{tag:"hr"}],renderHTML({HTMLAttributes:t}){return["hr",Oi(this.options.HTMLAttributes,t)]},addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{const{selection:n}=e,{$from:o,$to:r}=n,i=t();return 0===o.parentOffset?i.insertContentAt({from:Math.max(o.pos-1,0),to:r.pos},{type:this.name}):n instanceof ce?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command((({tr:t,dispatch:e})=>{var n;if(e){const{$to:e}=t.selection,o=e.end();if(e.nodeAfter)e.nodeAfter.isTextblock?t.setSelection(le.create(t.doc,e.pos+1)):e.nodeAfter.isBlock?t.setSelection(ce.create(t.doc,e.pos)):t.setSelection(le.create(t.doc,e.pos));else{const r=null===(n=e.parent.type.contentMatch.defaultType)||void 0===n?void 0:n.create();r&&(t.insert(o,r),t.setSelection(le.create(t.doc,o+1)))}t.scrollIntoView()}return!0})).run()}}},addInputRules(){return[Hs({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),Dp=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Rp=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,jp=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Lp=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Ip=Vi.create({name:"italic",addOptions:()=>({HTMLAttributes:{}}),parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>"normal"!==t.style.fontStyle&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",Oi(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[$s({find:Dp,type:this.type}),$s({find:jp,type:this.type})]},addPasteRules(){return[Vs({find:Rp,type:this.type}),Vs({find:Lp,type:this.type})]}}),Pp=Fs.create({name:"listItem",addOptions:()=>({HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}),content:"paragraph block*",defining:!0,parseHTML:()=>[{tag:"li"}],renderHTML({HTMLAttributes:t}){return["li",Oi(this.options.HTMLAttributes,t),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),zp="textStyle",$p=/^(\d+)\.\s$/,Hp=Fs.create({name:"orderedList",addOptions:()=>({itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}),group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes:()=>({start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:void 0,parseHTML:t=>t.getAttribute("type")}}),parseHTML:()=>[{tag:"ol"}],renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return 1===e?["ol",Oi(this.options.HTMLAttributes,n),0]:["ol",Oi(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes("listItem",this.editor.getAttributes(zp)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=_s({find:$p,type:this.type,getAttributes:t=>({start:+t[1]}),joinPredicate:(t,e)=>e.childCount+e.attrs.start===+t[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=_s({find:$p,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:t=>({start:+t[1],...this.editor.getAttributes(zp)}),joinPredicate:(t,e)=>e.childCount+e.attrs.start===+t[1],editor:this.editor})),[t]}}),Bp=Fs.create({name:"paragraph",priority:1e3,addOptions:()=>({HTMLAttributes:{}}),group:"block",content:"inline*",parseHTML:()=>[{tag:"p"}],renderHTML({HTMLAttributes:t}){return["p",Oi(this.options.HTMLAttributes,t),0]},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),_p=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Fp=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Vp=Vi.create({name:"strike",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>!!t.includes("line-through")&&{}}],renderHTML({HTMLAttributes:t}){return["s",Oi(this.options.HTMLAttributes,t),0]},addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[$s({find:_p,type:this.type})]},addPasteRules(){return[Vs({find:Fp,type:this.type})]}}),Wp=Fs.create({name:"text",group:"inline"}),qp=Ui.create({name:"starterKit",addExtensions(){var t,e,n,o,r,i,s,l,a,c,d,h,p,u,f,m,g,y;const b=[];return!1!==this.options.bold&&b.push(Hh.configure(null===(t=this.options)||void 0===t?void 0:t.bold)),!1!==this.options.blockquote&&b.push(Lh.configure(null===(e=this.options)||void 0===e?void 0:e.blockquote)),!1!==this.options.bulletList&&b.push(Fh.configure(null===(n=this.options)||void 0===n?void 0:n.bulletList)),!1!==this.options.code&&b.push(qh.configure(null===(o=this.options)||void 0===o?void 0:o.code)),!1!==this.options.codeBlock&&b.push(Uh.configure(null===(r=this.options)||void 0===r?void 0:r.codeBlock)),!1!==this.options.document&&b.push(Gh.configure(null===(i=this.options)||void 0===i?void 0:i.document)),!1!==this.options.dropcursor&&b.push(Qh.configure(null===(s=this.options)||void 0===s?void 0:s.dropcursor)),!1!==this.options.gapcursor&&b.push(sp.configure(null===(l=this.options)||void 0===l?void 0:l.gapcursor)),!1!==this.options.hardBreak&&b.push(lp.configure(null===(a=this.options)||void 0===a?void 0:a.hardBreak)),!1!==this.options.heading&&b.push(ap.configure(null===(c=this.options)||void 0===c?void 0:c.heading)),!1!==this.options.history&&b.push(Ep.configure(null===(d=this.options)||void 0===d?void 0:d.history)),!1!==this.options.horizontalRule&&b.push(Np.configure(null===(h=this.options)||void 0===h?void 0:h.horizontalRule)),!1!==this.options.italic&&b.push(Ip.configure(null===(p=this.options)||void 0===p?void 0:p.italic)),!1!==this.options.listItem&&b.push(Pp.configure(null===(u=this.options)||void 0===u?void 0:u.listItem)),!1!==this.options.orderedList&&b.push(Hp.configure(null===(f=this.options)||void 0===f?void 0:f.orderedList)),!1!==this.options.paragraph&&b.push(Bp.configure(null===(m=this.options)||void 0===m?void 0:m.paragraph)),!1!==this.options.strike&&b.push(Vp.configure(null===(g=this.options)||void 0===g?void 0:g.strike)),!1!==this.options.text&&b.push(Wp.configure(null===(y=this.options)||void 0===y?void 0:y.text)),b}}),Kp=Vi.create({name:"underline",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>!!t.includes("underline")&&{}}],renderHTML({HTMLAttributes:t}){return["u",Oi(this.options.HTMLAttributes,t),0]},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),Jp=Ui.create({name:"textAlign",addOptions:()=>({types:[],alignments:["left","center","right","justify"],defaultAlignment:"left"}),addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{const e=t.style.textAlign||this.options.defaultAlignment;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:t=>t.textAlign===this.options.defaultAlignment?{}:{style:`text-align: ${t.textAlign}`}}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>!!this.options.alignments.includes(t)&&this.options.types.map((n=>e.updateAttributes(n,{textAlign:t}))).every((t=>t)),unsetTextAlign:()=>({commands:t})=>this.options.types.map((e=>t.resetAttributes(e,"textAlign"))).every((t=>t))}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),Up=Vi.create({name:"superscript",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"sup"},{style:"vertical-align",getAttrs:t=>"super"===t&&null}],renderHTML({HTMLAttributes:t}){return["sup",Oi(this.options.HTMLAttributes,t),0]},addCommands(){return{setSuperscript:()=>({commands:t})=>t.setMark(this.name),toggleSuperscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSuperscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}}),Gp=Vi.create({name:"subscript",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"sub"},{style:"vertical-align",getAttrs:t=>"sub"===t&&null}],renderHTML({HTMLAttributes:t}){return["sub",Oi(this.options.HTMLAttributes,t),0]},addCommands(){return{setSubscript:()=>({commands:t})=>t.setMark(this.name),toggleSubscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSubscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}});var Yp,Xp;if("undefined"!=typeof WeakMap){let t=new WeakMap;Yp=e=>t.get(e),Xp=(e,n)=>(t.set(e,n),n)}else{const t=[],e=10;let n=0;Yp=e=>{for(let n=0;n<t.length;n+=2)if(t[n]==e)return t[n+1]},Xp=(o,r)=>(n==e&&(n=0),t[n++]=o,t[n++]=r)}var Qp=class{constructor(t,e,n,o){this.width=t,this.height=e,this.map=n,this.problems=o}findCell(t){for(let e=0;e<this.map.length;e++){const n=this.map[e];if(n!=t)continue;const o=e%this.width,r=e/this.width|0;let i=o+1,s=r+1;for(let t=1;i<this.width&&this.map[e+t]==n;t++)i++;for(let t=1;s<this.height&&this.map[e+this.width*t]==n;t++)s++;return{left:o,top:r,right:i,bottom:s}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let e=0;e<this.map.length;e++)if(this.map[e]==t)return e%this.width;throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,e,n){const{left:o,right:r,top:i,bottom:s}=this.findCell(t);return"horiz"==e?(n<0?0==o:r==this.width)?null:this.map[i*this.width+(n<0?o-1:r)]:(n<0?0==i:s==this.height)?null:this.map[o+this.width*(n<0?i-1:s)]}rectBetween(t,e){const{left:n,right:o,top:r,bottom:i}=this.findCell(t),{left:s,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(n,s),top:Math.min(r,a),right:Math.max(o,l),bottom:Math.max(i,c)}}cellsInRect(t){const e=[],n={};for(let o=t.top;o<t.bottom;o++)for(let r=t.left;r<t.right;r++){const i=o*this.width+r,s=this.map[i];n[s]||(n[s]=!0,r==t.left&&r&&this.map[i-1]==s||o==t.top&&o&&this.map[i-this.width]==s||e.push(s))}return e}positionAt(t,e,n){for(let o=0,r=0;;o++){const i=r+n.child(o).nodeSize;if(o==t){let n=e+t*this.width;const o=(t+1)*this.width;for(;n<o&&this.map[n]<r;)n++;return n==o?i-1:this.map[n]}r=i}}static get(t){return Yp(t)||Xp(t,function(t){if("table"!=t.type.spec.tableRole)throw new RangeError("Not a table node: "+t.type.name);const e=function(t){let e=-1,n=!1;for(let o=0;o<t.childCount;o++){const r=t.child(o);let i=0;if(n)for(let e=0;e<o;e++){const n=t.child(e);for(let t=0;t<n.childCount;t++){const r=n.child(t);e+r.attrs.rowspan>o&&(i+=r.attrs.colspan)}}for(let t=0;t<r.childCount;t++){const e=r.child(t);i+=e.attrs.colspan,e.attrs.rowspan>1&&(n=!0)}-1==e?e=i:e!=i&&(e=Math.max(e,i))}return e}(t),n=t.childCount,o=[];let r=0,i=null;const s=[];for(let t=0,r=e*n;t<r;t++)o[t]=0;for(let l=0,a=0;l<n;l++){const c=t.child(l);a++;for(let t=0;;t++){for(;r<o.length&&0!=o[r];)r++;if(t==c.childCount)break;const d=c.child(t),{colspan:h,rowspan:p,colwidth:u}=d.attrs;for(let t=0;t<p;t++){if(t+l>=n){(i||(i=[])).push({type:"overlong_rowspan",pos:a,n:p-t});break}const c=r+t*e;for(let t=0;t<h;t++){0==o[c+t]?o[c+t]=a:(i||(i=[])).push({type:"collision",row:l,pos:a,n:h-t});const n=u&&u[t];if(n){const o=(c+t)%e*2,r=s[o];null==r||r!=n&&1==s[o+1]?(s[o]=n,s[o+1]=1):r==n&&s[o+1]++}}}r+=h,a+=d.nodeSize}const d=(l+1)*e;let h=0;for(;r<d;)0==o[r++]&&h++;h&&(i||(i=[])).push({type:"missing",row:l,n:h}),a++}0!==e&&0!==n||(i||(i=[])).push({type:"zero_sized"});const l=new Qp(e,n,o,i);let a=!1;for(let t=0;!a&&t<s.length;t+=2)null!=s[t]&&s[t+1]<n&&(a=!0);return a&&function(t,e,n){t.problems||(t.problems=[]);const o={};for(let r=0;r<t.map.length;r++){const i=t.map[r];if(o[i])continue;o[i]=!0;const s=n.nodeAt(i);if(!s)throw new RangeError(`No cell with offset ${i} found`);let l=null;const a=s.attrs;for(let n=0;n<a.colspan;n++){const o=e[(r+n)%t.width*2];null==o||a.colwidth&&a.colwidth[n]==o||((l||(l=Zp(a)))[n]=o)}l&&t.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}(l,s,t),l}(t))}};function Zp(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function tu(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const n in t.nodes){const o=t.nodes[n],r=o.spec.tableRole;r&&(e[r]=o)}}return e}var eu=new Se("selectingCells");function nu(t){for(let e=t.depth-1;e>0;e--)if("row"==t.node(e).type.spec.tableRole)return t.node(0).resolve(t.before(e+1));return null}function ou(t){const e=t.selection.$head;for(let t=e.depth;t>0;t--)if("row"==e.node(t).type.spec.tableRole)return!0;return!1}function ru(t){const e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&"cell"==e.node.type.spec.tableRole)return e.$anchor;const n=nu(e.$head)||function(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){const o=e.type.spec.tableRole;if("cell"==o||"header_cell"==o)return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){const o=e.type.spec.tableRole;if("cell"==o||"header_cell"==o)return t.doc.resolve(n-e.nodeSize)}}(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function iu(t){return"row"==t.parent.type.spec.tableRole&&!!t.nodeAfter}function su(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function lu(t,e,n){const o=t.node(-1),r=Qp.get(o),i=t.start(-1),s=r.nextCell(t.pos-i,e,n);return null==s?null:t.node(0).resolve(i+s)}function au(t,e,n=1){const o={...t,colspan:t.colspan-n};return o.colwidth&&(o.colwidth=o.colwidth.slice(),o.colwidth.splice(e,n),o.colwidth.some((t=>t>0))||(o.colwidth=null)),o}function cu(t,e,n=1){const o={...t,colspan:t.colspan+n};if(o.colwidth){o.colwidth=o.colwidth.slice();for(let t=0;t<n;t++)o.colwidth.splice(e,0,0)}return o}var du=class t extends oe{constructor(t,e=t){const n=t.node(-1),o=Qp.get(n),r=t.start(-1),i=o.rectBetween(t.pos-r,e.pos-r),s=t.node(0),l=o.cellsInRect(i).filter((t=>t!=e.pos-r));l.unshift(e.pos-r);const a=l.map((t=>{const e=n.nodeAt(t);if(!e)throw RangeError(`No cell with offset ${t} found`);const o=r+t+1;return new re(s.resolve(o),s.resolve(o+e.content.size))}));super(a[0].$from,a[0].$to,a),this.$anchorCell=t,this.$headCell=e}map(e,n){const o=e.resolve(n.map(this.$anchorCell.pos)),r=e.resolve(n.map(this.$headCell.pos));if(iu(o)&&iu(r)&&su(o,r)){const e=this.$anchorCell.node(-1)!=o.node(-1);return e&&this.isRowSelection()?t.rowSelection(o,r):e&&this.isColSelection()?t.colSelection(o,r):new t(o,r)}return le.between(o,r)}content(){const t=this.$anchorCell.node(-1),e=Qp.get(t),n=this.$anchorCell.start(-1),o=e.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),r={},i=[];for(let n=o.top;n<o.bottom;n++){const s=[];for(let i=n*e.width+o.left,l=o.left;l<o.right;l++,i++){const n=e.map[i];if(r[n])continue;r[n]=!0;const l=e.findCell(n);let a=t.nodeAt(n);if(!a)throw RangeError(`No cell with offset ${n} found`);const c=o.left-l.left,d=l.right-o.right;if(c>0||d>0){let t=a.attrs;if(c>0&&(t=au(t,0,c)),d>0&&(t=au(t,t.colspan-d,d)),l.left<o.left){if(a=a.type.createAndFill(t),!a)throw RangeError(`Could not create cell with attrs ${JSON.stringify(t)}`)}else a=a.type.create(t,a.content)}if(l.top<o.top||l.bottom>o.bottom){const t={...a.attrs,rowspan:Math.min(l.bottom,o.bottom)-Math.max(l.top,o.top)};a=l.top<o.top?a.type.createAndFill(t):a.type.create(t,a.content)}s.push(a)}i.push(t.child(n).copy(a.from(s)))}const s=this.isColSelection()&&this.isRowSelection()?t:i;return new f(a.from(s),1,1)}replace(t,e=f.empty){const n=t.steps.length,o=this.ranges;for(let r=0;r<o.length;r++){const{$from:i,$to:s}=o[r],l=t.mapping.slice(n);t.replace(l.map(i.pos),l.map(s.pos),r?f.empty:e)}const r=oe.findFrom(t.doc.resolve(t.mapping.slice(n).map(this.to)),-1);r&&t.setSelection(r)}replaceWith(t,e){this.replace(t,new f(a.from(e),0,0))}forEachCell(t){const e=this.$anchorCell.node(-1),n=Qp.get(e),o=this.$anchorCell.start(-1),r=n.cellsInRect(n.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o));for(let n=0;n<r.length;n++)t(e.nodeAt(r[n]),o+r[n])}isColSelection(){const t=this.$anchorCell.index(-1),e=this.$headCell.index(-1);if(Math.min(t,e)>0)return!1;const n=t+this.$anchorCell.nodeAfter.attrs.rowspan,o=e+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,o)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const o=e.node(-1),r=Qp.get(o),i=e.start(-1),s=r.findCell(e.pos-i),l=r.findCell(n.pos-i),a=e.node(0);return s.top<=l.top?(s.top>0&&(e=a.resolve(i+r.map[s.left])),l.bottom<r.height&&(n=a.resolve(i+r.map[r.width*(r.height-1)+l.right-1]))):(l.top>0&&(n=a.resolve(i+r.map[l.left])),s.bottom<r.height&&(e=a.resolve(i+r.map[r.width*(r.height-1)+s.right-1]))),new t(e,n)}isRowSelection(){const t=this.$anchorCell.node(-1),e=Qp.get(t),n=this.$anchorCell.start(-1),o=e.colCount(this.$anchorCell.pos-n),r=e.colCount(this.$headCell.pos-n);if(Math.min(o,r)>0)return!1;const i=o+this.$anchorCell.nodeAfter.attrs.colspan,s=r+this.$headCell.nodeAfter.attrs.colspan;return Math.max(i,s)==e.width}eq(e){return e instanceof t&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const o=e.node(-1),r=Qp.get(o),i=e.start(-1),s=r.findCell(e.pos-i),l=r.findCell(n.pos-i),a=e.node(0);return s.left<=l.left?(s.left>0&&(e=a.resolve(i+r.map[s.top*r.width])),l.right<r.width&&(n=a.resolve(i+r.map[r.width*(l.top+1)-1]))):(l.left>0&&(n=a.resolve(i+r.map[l.top*r.width])),s.right<r.width&&(e=a.resolve(i+r.map[r.width*(s.top+1)-1]))),new t(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new t(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,o=n){return new t(e.resolve(n),e.resolve(o))}getBookmark(){return new hu(this.$anchorCell.pos,this.$headCell.pos)}};du.prototype.visible=!1,oe.jsonID("cell",du);var hu=class t{constructor(t,e){this.anchor=t,this.head=e}map(e){return new t(e.map(this.anchor),e.map(this.head))}resolve(t){const e=t.resolve(this.anchor),n=t.resolve(this.head);return"row"==e.parent.type.spec.tableRole&&"row"==n.parent.type.spec.tableRole&&e.index()<e.parent.childCount&&n.index()<n.parent.childCount&&su(e,n)?new du(e,n):oe.near(n,1)}};function pu(t){if(!(t.selection instanceof du))return null;const e=[];return t.selection.forEachCell(((t,n)=>{e.push(ir.node(n,n+t.nodeSize,{class:"selectedCell"}))})),ar.create(t.doc,e)}var uu=new Se("fix-tables");function fu(t,e,n,o){const r=t.childCount,i=e.childCount;t:for(let s=0,l=0;s<i;s++){const i=e.child(s);for(let e=l,o=Math.min(r,s+3);e<o;e++)if(t.child(e)==i){l=e+1,n+=i.nodeSize;continue t}o(i,n),l<r&&t.child(l).sameMarkup(i)?fu(t.child(l),i,n+1,o):i.nodesBetween(0,i.content.size,o,n+1),n+=i.nodeSize}}function mu(t,e){let n;const o=(e,o)=>{"table"==e.type.spec.tableRole&&(n=function(t,e,n,o){const r=Qp.get(e);if(!r.problems)return o;o||(o=t.tr);const i=[];for(let t=0;t<r.height;t++)i.push(0);for(let t=0;t<r.problems.length;t++){const s=r.problems[t];if("collision"==s.type){const t=e.nodeAt(s.pos);if(!t)continue;const r=t.attrs;for(let t=0;t<r.rowspan;t++)i[s.row+t]+=s.n;o.setNodeMarkup(o.mapping.map(n+1+s.pos),null,au(r,r.colspan-s.n,s.n))}else if("missing"==s.type)i[s.row]+=s.n;else if("overlong_rowspan"==s.type){const t=e.nodeAt(s.pos);if(!t)continue;o.setNodeMarkup(o.mapping.map(n+1+s.pos),null,{...t.attrs,rowspan:t.attrs.rowspan-s.n})}else if("colwidth mismatch"==s.type){const t=e.nodeAt(s.pos);if(!t)continue;o.setNodeMarkup(o.mapping.map(n+1+s.pos),null,{...t.attrs,colwidth:s.colwidth})}else if("zero_sized"==s.type){const t=o.mapping.map(n);o.delete(t,t+e.nodeSize)}}let s,l;for(let t=0;t<i.length;t++)i[t]&&(null==s&&(s=t),l=t);for(let a=0,c=n+1;a<r.height;a++){const n=e.child(a),r=c+n.nodeSize,d=i[a];if(d>0){let e="cell";n.firstChild&&(e=n.firstChild.type.spec.tableRole);const i=[];for(let n=0;n<d;n++){const n=tu(t.schema)[e].createAndFill();n&&i.push(n)}const h=0!=a&&s!=a-1||l!=a?r-1:c+1;o.insert(o.mapping.map(h),i)}c=r}return o.setMeta(uu,{fixTables:!0})}(t,e,o,n))};return e?e.doc!=t.doc&&fu(e.doc,t.doc,0,o):t.doc.descendants(o),n}function gu(t){const e=t.selection,n=ru(t),o=n.node(-1),r=n.start(-1),i=Qp.get(o);return{...e instanceof du?i.rectBetween(e.$anchorCell.pos-r,e.$headCell.pos-r):i.findCell(n.pos-r),tableStart:r,map:i,table:o}}function yu(t,{map:e,tableStart:n,table:o},r){let i=r>0?-1:0;(function(t,e,n){const o=tu(e.type.schema).header_cell;for(let r=0;r<t.height;r++)if(e.nodeAt(t.map[n+r*t.width]).type!=o)return!1;return!0})(e,o,r+i)&&(i=0==r||r==e.width?null:0);for(let s=0;s<e.height;s++){const l=s*e.width+r;if(r>0&&r<e.width&&e.map[l-1]==e.map[l]){const i=e.map[l],a=o.nodeAt(i);t.setNodeMarkup(t.mapping.map(n+i),null,cu(a.attrs,r-e.colCount(i))),s+=a.attrs.rowspan-1}else{const a=null==i?tu(o.type.schema).cell:o.nodeAt(e.map[l+i]).type,c=e.positionAt(s,r,o);t.insert(t.mapping.map(n+c),a.createAndFill())}}return t}function bu(t,{map:e,table:n,tableStart:o},r){const i=t.mapping.maps.length;for(let s=0;s<e.height;){const l=s*e.width+r,a=e.map[l],c=n.nodeAt(a),d=c.attrs;if(r>0&&e.map[l-1]==a||r<e.width-1&&e.map[l+1]==a)t.setNodeMarkup(t.mapping.slice(i).map(o+a),null,au(d,r-e.colCount(a)));else{const e=t.mapping.slice(i).map(o+a);t.delete(e,e+c.nodeSize)}s+=d.rowspan}}function vu(t,{map:e,tableStart:n,table:o},r){var i;let s=n;for(let t=0;t<r;t++)s+=o.child(t).nodeSize;const l=[];let a=r>0?-1:0;(function(t,e,n){var o;const r=tu(e.type.schema).header_cell;for(let i=0;i<t.width;i++)if((null==(o=e.nodeAt(t.map[i+n*t.width]))?void 0:o.type)!=r)return!1;return!0})(e,o,r+a)&&(a=0==r||r==e.height?null:0);for(let s=0,c=e.width*r;s<e.width;s++,c++)if(r>0&&r<e.height&&e.map[c]==e.map[c-e.width]){const r=e.map[c],i=o.nodeAt(r).attrs;t.setNodeMarkup(n+r,null,{...i,rowspan:i.rowspan+1}),s+=i.colspan-1}else{const t=null==a?tu(o.type.schema).cell:null==(i=o.nodeAt(e.map[c+a*e.width]))?void 0:i.type,n=null==t?void 0:t.createAndFill();n&&l.push(n)}return t.insert(s,tu(o.type.schema).row.create(null,l)),t}function wu(t,{map:e,table:n,tableStart:o},r){let i=0;for(let t=0;t<r;t++)i+=n.child(t).nodeSize;const s=i+n.child(r).nodeSize,l=t.mapping.maps.length;t.delete(i+o,s+o);const a=new Set;for(let i=0,s=r*e.width;i<e.width;i++,s++){const c=e.map[s];if(!a.has(c))if(a.add(c),r>0&&c==e.map[s-e.width]){const e=n.nodeAt(c).attrs;t.setNodeMarkup(t.mapping.slice(l).map(c+o),null,{...e,rowspan:e.rowspan-1}),i+=e.colspan-1}else if(r<e.height&&c==e.map[s+e.width]){const s=n.nodeAt(c),a=s.attrs,d=s.type.create({...a,rowspan:s.attrs.rowspan-1},s.content),h=e.positionAt(r+1,i,n);t.insert(t.mapping.slice(l).map(o+h),d),i+=a.colspan-1}}}function ku(t){const e=t.content;return 1==e.childCount&&e.child(0).isTextblock&&0==e.child(0).childCount}function xu(t,e){const n=t.selection;if(!(n instanceof du)||n.$anchorCell.pos==n.$headCell.pos)return!1;const o=gu(t),{map:r}=o;if(function({width:t,height:e,map:n},o){let r=o.top*t+o.left,i=r,s=(o.bottom-1)*t+o.left,l=r+(o.right-o.left-1);for(let e=o.top;e<o.bottom;e++){if(o.left>0&&n[i]==n[i-1]||o.right<t&&n[l]==n[l+1])return!0;i+=t,l+=t}for(let i=o.left;i<o.right;i++){if(o.top>0&&n[r]==n[r-t]||o.bottom<e&&n[s]==n[s+t])return!0;r++,s++}return!1}(r,o))return!1;if(e){const n=t.tr,i={};let s,l,c=a.empty;for(let t=o.top;t<o.bottom;t++)for(let e=o.left;e<o.right;e++){const a=r.map[t*r.width+e],d=o.table.nodeAt(a);if(!i[a]&&d)if(i[a]=!0,null==s)s=a,l=d;else{ku(d)||(c=c.append(d.content));const t=n.mapping.map(a+o.tableStart);n.delete(t,t+d.nodeSize)}}if(null==s||null==l)return!0;if(n.setNodeMarkup(s+o.tableStart,null,{...cu(l.attrs,l.attrs.colspan,o.right-o.left-l.attrs.colspan),rowspan:o.bottom-o.top}),c.size){const t=s+1+l.content.size,e=ku(l)?s+1:t;n.replaceWith(e+o.tableStart,t+o.tableStart,c)}n.setSelection(new du(n.doc.resolve(s+o.tableStart))),e(n)}return!0}function Mu(t,e){const n=tu(t.schema);return(o=({node:t})=>n[t.type.spec.tableRole],(t,e)=>{var n;const r=t.selection;let i,s;if(r instanceof du){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;i=r.$anchorCell.nodeAfter,s=r.$anchorCell.pos}else{if(i=function(t){for(let e=t.depth;e>0;e--){const n=t.node(e).type.spec.tableRole;if("cell"===n||"header_cell"===n)return t.node(e)}return null}(r.$from),!i)return!1;s=null==(n=nu(r.$from))?void 0:n.pos}if(null==i||null==s)return!1;if(1==i.attrs.colspan&&1==i.attrs.rowspan)return!1;if(e){let n=i.attrs;const l=[],a=n.colwidth;n.rowspan>1&&(n={...n,rowspan:1}),n.colspan>1&&(n={...n,colspan:1});const c=gu(t),d=t.tr;for(let t=0;t<c.right-c.left;t++)l.push(a?{...n,colwidth:a&&a[t]?[a[t]]:null}:n);let h;for(let t=c.top;t<c.bottom;t++){let e=c.map.positionAt(t,c.left,c.table);t==c.top&&(e+=i.nodeSize);for(let n=c.left,r=0;n<c.right;n++,r++)n==c.left&&t==c.top||d.insert(h=d.mapping.map(e+c.tableStart,1),o({node:i,row:t,col:n}).createAndFill(l[r]))}d.setNodeMarkup(s,o({node:i,row:c.top,col:c.left}),l[0]),r instanceof du&&d.setSelection(new du(d.doc.resolve(r.$anchorCell.pos),h?d.doc.resolve(h):void 0)),e(d)}return!0})(t,e);var o}function Cu(t,e,n){const o=e.map.cellsInRect({left:0,top:0,right:"row"==t?e.map.width:1,bottom:"column"==t?e.map.height:1});for(let t=0;t<o.length;t++){const r=e.table.nodeAt(o[t]);if(r&&r.type!==n.header_cell)return!1}return!0}function Su(t,e){return(e=e||{useDeprecatedLogic:!1}).useDeprecatedLogic?function(t){return function(e,n){if(!ou(e))return!1;if(n){const o=tu(e.schema),r=gu(e),i=e.tr,s=r.map.cellsInRect("column"==t?{left:r.left,top:0,right:r.right,bottom:r.map.height}:"row"==t?{left:0,top:r.top,right:r.map.width,bottom:r.bottom}:r),l=s.map((t=>r.table.nodeAt(t)));for(let t=0;t<s.length;t++)l[t].type==o.header_cell&&i.setNodeMarkup(r.tableStart+s[t],o.cell,l[t].attrs);if(0==i.steps.length)for(let t=0;t<s.length;t++)i.setNodeMarkup(r.tableStart+s[t],o.header_cell,l[t].attrs);n(i)}return!0}}(t):function(e,n){if(!ou(e))return!1;if(n){const o=tu(e.schema),r=gu(e),i=e.tr,s=Cu("row",r,o),l=Cu("column",r,o),a=("column"===t?s:"row"===t&&l)?1:0,c="column"==t?{left:0,top:a,right:1,bottom:r.map.height}:"row"==t?{left:a,top:0,right:r.map.width,bottom:1}:r,d="column"==t?l?o.cell:o.header_cell:"row"==t?s?o.cell:o.header_cell:o.cell;r.map.cellsInRect(c).forEach((t=>{const e=t+r.tableStart,n=i.doc.nodeAt(e);n&&i.setNodeMarkup(e,d,n.attrs)})),n(i)}return!0}}Su("row",{useDeprecatedLogic:!0}),Su("column",{useDeprecatedLogic:!0});var Tu=Su("cell",{useDeprecatedLogic:!0});function Au(t){return function(e,n){if(!ou(e))return!1;const o=function(t,e){if(e<0){const e=t.nodeBefore;if(e)return t.pos-e.nodeSize;for(let e=t.index(-1)-1,n=t.before();e>=0;e--){const o=t.node(-1).child(e),r=o.lastChild;if(r)return n-1-r.nodeSize;n-=o.nodeSize}}else{if(t.index()<t.parent.childCount-1)return t.pos+t.nodeAfter.nodeSize;const e=t.node(-1);for(let n=t.indexAfter(-1),o=t.after();n<e.childCount;n++){const t=e.child(n);if(t.childCount)return o+1;o+=t.nodeSize}}return null}(ru(e),t);if(null==o)return!1;if(n){const t=e.doc.resolve(o);n(e.tr.setSelection(le.between(t,(r=t,r.node(0).resolve(r.pos+r.nodeAfter.nodeSize)))).scrollIntoView())}var r;return!0}}function Ou(t,e){const n=t.selection;if(!(n instanceof du))return!1;if(e){const o=t.tr,r=tu(t.schema).cell.createAndFill().content;n.forEachCell(((t,e)=>{t.content.eq(r)||o.replace(o.mapping.map(e+1),o.mapping.map(e+t.nodeSize-1),new f(r,0,0))})),o.docChanged&&e(o)}return!0}function Eu(t,e){const n=t.createAndFill();return new ee(n).replace(0,n.content.size,e).doc}function Nu(t,e,n,o,r,i,s,l){if(0==s||s==e.height)return!1;let a=!1;for(let c=r;c<i;c++){const r=s*e.width+c,i=e.map[r];if(e.map[r-e.width]==i){a=!0;const r=n.nodeAt(i),{top:d,left:h}=e.findCell(i);t.setNodeMarkup(t.mapping.slice(l).map(i+o),null,{...r.attrs,rowspan:s-d}),t.insert(t.mapping.slice(l).map(e.positionAt(s,h,n)),r.type.createAndFill({...r.attrs,rowspan:d+r.attrs.rowspan-s})),c+=r.attrs.colspan-1}}return a}function Du(t,e,n,o,r,i,s,l){if(0==s||s==e.width)return!1;let a=!1;for(let c=r;c<i;c++){const r=c*e.width+s,i=e.map[r];if(e.map[r-1]==i){a=!0;const r=n.nodeAt(i),d=e.colCount(i),h=t.mapping.slice(l).map(i+o);t.setNodeMarkup(h,null,au(r.attrs,s-d,r.attrs.colspan-(s-d))),t.insert(h+r.nodeSize,r.type.createAndFill(au(r.attrs,0,s-d))),c+=r.attrs.rowspan-1}}return a}function Ru(t,e,n,o,r){let i=n?t.doc.nodeAt(n-1):t.doc;if(!i)throw new Error("No table found");let s=Qp.get(i);const{top:l,left:c}=o,d=c+r.width,h=l+r.height,p=t.tr;let u=0;function m(){if(i=n?p.doc.nodeAt(n-1):p.doc,!i)throw new Error("No table found");s=Qp.get(i),u=p.mapping.maps.length}(function(t,e,n,o,r,i,s){const l=tu(t.doc.type.schema);let c,d;if(r>e.width)for(let i=0,a=0;i<e.height;i++){const h=n.child(i);a+=h.nodeSize;const p=[];let u;u=null==h.lastChild||h.lastChild.type==l.cell?c||(c=l.cell.createAndFill()):d||(d=l.header_cell.createAndFill());for(let t=e.width;t<r;t++)p.push(u);t.insert(t.mapping.slice(s).map(a-1+o),p)}if(i>e.height){const h=[];for(let t=0,o=(e.height-1)*e.width;t<Math.max(e.width,r);t++){const r=!(t>=e.width)&&n.nodeAt(e.map[o+t]).type==l.header_cell;h.push(r?d||(d=l.header_cell.createAndFill()):c||(c=l.cell.createAndFill()))}const p=l.row.create(null,a.from(h)),u=[];for(let t=e.height;t<i;t++)u.push(p);t.insert(t.mapping.slice(s).map(o+n.nodeSize-2),u)}return!(!c&&!d)})(p,s,i,n,d,h,u)&&m(),Nu(p,s,i,n,c,d,l,u)&&m(),Nu(p,s,i,n,c,d,h,u)&&m(),Du(p,s,i,n,l,h,c,u)&&m(),Du(p,s,i,n,l,h,d,u)&&m();for(let t=l;t<h;t++){const e=s.positionAt(t,c,i),o=s.positionAt(t,d,i);p.replace(p.mapping.slice(u).map(e+n),p.mapping.slice(u).map(o+n),new f(r.rows[t-l],0,0))}m(),p.setSelection(new du(p.doc.resolve(n+s.positionAt(l,c,i)),p.doc.resolve(n+s.positionAt(h-1,d-1,i)))),e(p)}var ju=Jr({ArrowLeft:Iu("horiz",-1),ArrowRight:Iu("horiz",1),ArrowUp:Iu("vert",-1),ArrowDown:Iu("vert",1),"Shift-ArrowLeft":Pu("horiz",-1),"Shift-ArrowRight":Pu("horiz",1),"Shift-ArrowUp":Pu("vert",-1),"Shift-ArrowDown":Pu("vert",1),Backspace:Ou,"Mod-Backspace":Ou,Delete:Ou,"Mod-Delete":Ou});function Lu(t,e,n){return!n.eq(t.selection)&&(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function Iu(t,e){return(n,o,r)=>{if(!r)return!1;const i=n.selection;if(i instanceof du)return Lu(n,o,oe.near(i.$headCell,e));if("horiz"!=t&&!i.empty)return!1;const s=Bu(r,t,e);if(null==s)return!1;if("horiz"==t)return Lu(n,o,oe.near(n.doc.resolve(i.head+e),e));{const r=n.doc.resolve(s),i=lu(r,t,e);let l;return l=i?oe.near(i,1):e<0?oe.near(n.doc.resolve(r.before(-1)),-1):oe.near(n.doc.resolve(r.after(-1)),1),Lu(n,o,l)}}}function Pu(t,e){return(n,o,r)=>{if(!r)return!1;const i=n.selection;let s;if(i instanceof du)s=i;else{const o=Bu(r,t,e);if(null==o)return!1;s=new du(n.doc.resolve(o))}const l=lu(s.$headCell,t,e);return!!l&&Lu(n,o,new du(s.$anchorCell,l))}}function zu(t,e){const n=nu(t.state.doc.resolve(e));return!!n&&(t.dispatch(t.state.tr.setSelection(new du(n))),!0)}function $u(t,e,n){if(!ou(t.state))return!1;let o=function(t){if(!t.size)return null;let{content:e,openStart:n,openEnd:o}=t;for(;1==e.childCount&&(n>0&&o>0||"table"==e.child(0).type.spec.tableRole);)n--,o--,e=e.child(0).content;const r=e.child(0),i=r.type.spec.tableRole,s=r.type.schema,l=[];if("row"==i)for(let t=0;t<e.childCount;t++){let r=e.child(t).content;const i=t?0:Math.max(0,n-1),a=t<e.childCount-1?0:Math.max(0,o-1);(i||a)&&(r=Eu(tu(s).row,new f(r,i,a)).content),l.push(r)}else{if("cell"!=i&&"header_cell"!=i)return null;l.push(n||o?Eu(tu(s).row,new f(e,n,o)).content:e)}return function(t,e){const n=[];for(let t=0;t<e.length;t++){const o=e[t];for(let e=o.childCount-1;e>=0;e--){const{rowspan:r,colspan:i}=o.child(e).attrs;for(let e=t;e<t+r;e++)n[e]=(n[e]||0)+i}}let o=0;for(let t=0;t<n.length;t++)o=Math.max(o,n[t]);for(let r=0;r<n.length;r++)if(r>=e.length&&e.push(a.empty),n[r]<o){const i=tu(t).cell.createAndFill(),s=[];for(let t=n[r];t<o;t++)s.push(i);e[r]=e[r].append(a.from(s))}return{height:e.length,width:o,rows:e}}(s,l)}(n);const r=t.state.selection;if(r instanceof du){o||(o={width:1,height:1,rows:[a.from(Eu(tu(t.state.schema).cell,n))]});const e=r.$anchorCell.node(-1),i=r.$anchorCell.start(-1),s=Qp.get(e).rectBetween(r.$anchorCell.pos-i,r.$headCell.pos-i);return o=function({width:t,height:e,rows:n},o,r){if(t!=o){const e=[],r=[];for(let t=0;t<n.length;t++){const i=n[t],s=[];for(let n=e[t]||0,r=0;n<o;r++){let l=i.child(r%i.childCount);n+l.attrs.colspan>o&&(l=l.type.createChecked(au(l.attrs,l.attrs.colspan,n+l.attrs.colspan-o),l.content)),s.push(l),n+=l.attrs.colspan;for(let n=1;n<l.attrs.rowspan;n++)e[t+n]=(e[t+n]||0)+l.attrs.colspan}r.push(a.from(s))}n=r,t=o}if(e!=r){const t=[];for(let o=0,i=0;o<r;o++,i++){const s=[],l=n[i%e];for(let t=0;t<l.childCount;t++){let e=l.child(t);o+e.attrs.rowspan>r&&(e=e.type.create({...e.attrs,rowspan:Math.max(1,r-e.attrs.rowspan)},e.content)),s.push(e)}t.push(a.from(s))}n=t,e=r}return{width:t,height:e,rows:n}}(o,s.right-s.left,s.bottom-s.top),Ru(t.state,t.dispatch,i,s,o),!0}if(o){const e=ru(t.state),n=e.start(-1);return Ru(t.state,t.dispatch,n,Qp.get(e.node(-1)).findCell(e.pos-n),o),!0}return!1}function Hu(t,e){var n;if(e.ctrlKey||e.metaKey)return;const o=_u(t,e.target);let r;if(e.shiftKey&&t.state.selection instanceof du)i(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&o&&null!=(r=nu(t.state.selection.$anchor))&&(null==(n=Fu(t,e))?void 0:n.pos)!=r.pos)i(r,e),e.preventDefault();else if(!o)return;function i(e,n){let o=Fu(t,n);const r=null==eu.getState(t.state);if(!o||!su(e,o)){if(!r)return;o=e}const i=new du(e,o);if(r||!t.state.selection.eq(i)){const n=t.state.tr.setSelection(i);r&&n.setMeta(eu,e.pos),t.dispatch(n)}}function s(){t.root.removeEventListener("mouseup",s),t.root.removeEventListener("dragstart",s),t.root.removeEventListener("mousemove",l),null!=eu.getState(t.state)&&t.dispatch(t.state.tr.setMeta(eu,-1))}function l(n){const r=n,l=eu.getState(t.state);let a;if(null!=l)a=t.state.doc.resolve(l);else if(_u(t,r.target)!=o&&(a=Fu(t,e),!a))return s();a&&i(a,r)}t.root.addEventListener("mouseup",s),t.root.addEventListener("dragstart",s),t.root.addEventListener("mousemove",l)}function Bu(t,e,n){if(!(t.state.selection instanceof le))return null;const{$head:o}=t.state.selection;for(let r=o.depth-1;r>=0;r--){const i=o.node(r);if((n<0?o.index(r):o.indexAfter(r))!=(n<0?0:i.childCount))return null;if("cell"==i.type.spec.tableRole||"header_cell"==i.type.spec.tableRole){const i=o.before(r),s="vert"==e?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(s)?i:null}}return null}function _u(t,e){for(;e&&e!=t.dom;e=e.parentNode)if("TD"==e.nodeName||"TH"==e.nodeName)return e;return null}function Fu(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});return n&&n?nu(t.state.doc.resolve(n.pos)):null}var Vu=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")),Wu(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type==this.node.type&&(this.node=t,Wu(t,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(t){return"attributes"==t.type&&(t.target==this.table||this.colgroup.contains(t.target))}};function Wu(t,e,n,o,r,i){var s;let l=0,a=!0,c=e.firstChild;const d=t.firstChild;if(d){for(let t=0,n=0;t<d.childCount;t++){const{colspan:s,colwidth:h}=d.child(t).attrs;for(let t=0;t<s;t++,n++){const s=r==n?i:h&&h[t],d=s?s+"px":"";if(l+=s||o,s||(a=!1),c)c.style.width!=d&&(c.style.width=d),c=c.nextSibling;else{const t=document.createElement("col");t.style.width=d,e.appendChild(t)}}}for(;c;){const t=c.nextSibling;null==(s=c.parentNode)||s.removeChild(c),c=t}a?(n.style.width=l+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=l+"px")}}var qu=new Se("tableColumnResizing");function Ku({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:o=Vu,lastColumnResizable:r=!0}={}){const i=new xe({key:qu,state:{init(t,e){var r,s;const l=null==(s=null==(r=i.spec)?void 0:r.props)?void 0:s.nodeViews,a=tu(e.schema).table.name;return o&&l&&(l[a]=(t,e)=>new o(t,n,e)),new Ju(-1,!1)},apply:(t,e)=>e.apply(t)},props:{attributes:t=>{const e=qu.getState(t);return e&&e.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(e,n)=>{!function(t,e,n,o){if(!t.editable)return;const r=qu.getState(t.state);if(r&&!r.dragging){const i=function(t){for(;t&&"TD"!=t.nodeName&&"TH"!=t.nodeName;)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}(e.target);let s=-1;if(i){const{left:o,right:r}=i.getBoundingClientRect();e.clientX-o<=n?s=Uu(t,e,"left",n):r-e.clientX<=n&&(s=Uu(t,e,"right",n))}if(s!=r.activeHandle){if(!o&&-1!==s){const e=t.state.doc.resolve(s),n=e.node(-1),o=Qp.get(n),r=e.start(-1);if(o.colCount(e.pos-r)+e.nodeAfter.attrs.colspan-1==o.width-1)return}Yu(t,s)}}}(e,n,t,r)},mouseleave:t=>{!function(t){if(!t.editable)return;const e=qu.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&Yu(t,-1)}(t)},mousedown:(t,o)=>{!function(t,e,n,o){var r;if(!t.editable)return!1;const i=null!=(r=t.dom.ownerDocument.defaultView)?r:window,s=qu.getState(t.state);if(!s||-1==s.activeHandle||s.dragging)return!1;const l=t.state.doc.nodeAt(s.activeHandle),a=function(t,e,{colspan:n,colwidth:o}){const r=o&&o[o.length-1];if(r)return r;const i=t.domAtPos(e);let s=i.node.childNodes[i.offset].offsetWidth,l=n;if(o)for(let t=0;t<n;t++)o[t]&&(s-=o[t],l--);return s/l}(t,s.activeHandle,l.attrs);function c(e){i.removeEventListener("mouseup",c),i.removeEventListener("mousemove",d);const o=qu.getState(t.state);(null==o?void 0:o.dragging)&&(function(t,e,n){const o=t.state.doc.resolve(e),r=o.node(-1),i=Qp.get(r),s=o.start(-1),l=i.colCount(o.pos-s)+o.nodeAfter.attrs.colspan-1,a=t.state.tr;for(let t=0;t<i.height;t++){const e=t*i.width+l;if(t&&i.map[e]==i.map[e-i.width])continue;const o=i.map[e],d=r.nodeAt(o).attrs,h=1==d.colspan?0:l-i.colCount(o);if(d.colwidth&&d.colwidth[h]==n)continue;const p=d.colwidth?d.colwidth.slice():(c=d.colspan,Array(c).fill(0));p[h]=n,a.setNodeMarkup(s+o,null,{...d,colwidth:p})}var c;a.docChanged&&t.dispatch(a)}(t,o.activeHandle,Gu(o.dragging,e,n)),t.dispatch(t.state.tr.setMeta(qu,{setDragging:null})))}function d(e){if(!e.which)return c(e);const r=qu.getState(t.state);if(r&&r.dragging){const i=Gu(r.dragging,e,n);Xu(t,r.activeHandle,i,o)}}t.dispatch(t.state.tr.setMeta(qu,{setDragging:{startX:e.clientX,startWidth:a}})),Xu(t,s.activeHandle,a,o),i.addEventListener("mouseup",c),i.addEventListener("mousemove",d),e.preventDefault()}(t,o,e,n)}},decorations:t=>{const e=qu.getState(t);if(e&&e.activeHandle>-1)return function(t,e){var n;const o=[],r=t.doc.resolve(e),i=r.node(-1);if(!i)return ar.empty;const s=Qp.get(i),l=r.start(-1),a=s.colCount(r.pos-l)+r.nodeAfter.attrs.colspan-1;for(let e=0;e<s.height;e++){const r=a+e*s.width;if(!(a!=s.width-1&&s.map[r]==s.map[r+1]||0!=e&&s.map[r]==s.map[r-s.width])){const e=s.map[r],a=l+e+i.nodeAt(e).nodeSize-1,c=document.createElement("div");c.className="column-resize-handle",(null==(n=qu.getState(t))?void 0:n.dragging)&&o.push(ir.node(l+e,l+e+i.nodeAt(e).nodeSize,{class:"column-resize-dragging"})),o.push(ir.widget(a,c))}}return ar.create(t.doc,o)}(t,e.activeHandle)},nodeViews:{}}});return i}var Ju=class t{constructor(t,e){this.activeHandle=t,this.dragging=e}apply(e){const n=this,o=e.getMeta(qu);if(o&&null!=o.setHandle)return new t(o.setHandle,!1);if(o&&void 0!==o.setDragging)return new t(n.activeHandle,o.setDragging);if(n.activeHandle>-1&&e.docChanged){let o=e.mapping.map(n.activeHandle,-1);return iu(e.doc.resolve(o))||(o=-1),new t(o,n.dragging)}return n}};function Uu(t,e,n,o){const r="right"==n?-o:o,i=t.posAtCoords({left:e.clientX+r,top:e.clientY});if(!i)return-1;const{pos:s}=i,l=nu(t.state.doc.resolve(s));if(!l)return-1;if("right"==n)return l.pos;const a=Qp.get(l.node(-1)),c=l.start(-1),d=a.map.indexOf(l.pos-c);return d%a.width==0?-1:c+a.map[d-1]}function Gu(t,e,n){const o=e.clientX-t.startX;return Math.max(n,t.startWidth+o)}function Yu(t,e){t.dispatch(t.state.tr.setMeta(qu,{setHandle:e}))}function Xu(t,e,n,o){const r=t.state.doc.resolve(e),i=r.node(-1),s=r.start(-1),l=Qp.get(i).colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1;let a=t.domAtPos(r.start(-1)).node;for(;a&&"TABLE"!=a.nodeName;)a=a.parentNode;a&&Wu(i,a.firstChild,a,o,l,n)}function Qu({allowTableNodeSelection:t=!1}={}){return new xe({key:eu,state:{init:()=>null,apply(t,e){const n=t.getMeta(eu);if(null!=n)return-1==n?null:n;if(null==e||!t.docChanged)return e;const{deleted:o,pos:r}=t.mapping.mapResult(e);return o?null:r}},props:{decorations:pu,handleDOMEvents:{mousedown:Hu},createSelectionBetween:t=>null!=eu.getState(t.state)?t.state.selection:null,handleTripleClick:zu,handleKeyDown:ju,handlePaste:$u},appendTransaction:(e,n,o)=>function(t,e,n){const o=(e||t).selection,r=(e||t).doc;let i,s;if(o instanceof ce&&(s=o.node.type.spec.tableRole)){if("cell"==s||"header_cell"==s)i=du.create(r,o.from);else if("row"==s){const t=r.resolve(o.from+1);i=du.rowSelection(t,t)}else if(!n){const t=Qp.get(o.node),e=o.from+1,n=e+t.map[t.width*t.height-1];i=du.create(r,e+1,n)}}else o instanceof le&&function({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let n=t.pos,o=e.pos,r=t.depth;for(;r>=0&&!(t.after(r+1)<t.end(r));r--,n++);for(let t=e.depth;t>=0&&!(e.before(t+1)>e.start(t));t--,o--);return n==o&&/row|table/.test(t.node(r).type.spec.tableRole)}(o)?i=le.create(r,o.from):o instanceof le&&function({$from:t,$to:e}){let n,o;for(let e=t.depth;e>0;e--){const o=t.node(e);if("cell"===o.type.spec.tableRole||"header_cell"===o.type.spec.tableRole){n=o;break}}for(let t=e.depth;t>0;t--){const n=e.node(t);if("cell"===n.type.spec.tableRole||"header_cell"===n.type.spec.tableRole){o=n;break}}return n!==o&&0===e.parentOffset}(o)&&(i=le.create(r,o.$from.start(),o.$from.end()));return i&&(e||(e=t.tr)).setSelection(i),e}(o,mu(o,n),t)})}function Zu(t,e,n,o,r,i){let s=0,l=!0,a=e.firstChild;const c=t.firstChild;for(let t=0,n=0;t<c.childCount;t+=1){const{colspan:d,colwidth:h}=c.child(t).attrs;for(let t=0;t<d;t+=1,n+=1){const c=r===n?i:h&&h[t],d=c?`${c}px`:"";s+=c||o,c||(l=!1),a?(a.style.width!==d&&(a.style.width=d),a=a.nextSibling):e.appendChild(document.createElement("col")).style.width=d}}for(;a;){const t=a.nextSibling;a.parentNode.removeChild(a),a=t}l?(n.style.width=`${s}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${s}px`)}class tf{constructor(t,e){this.node=t,this.cellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Zu(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type===this.node.type&&(this.node=t,Zu(t,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(t){return"attributes"===t.type&&(t.target===this.table||this.colgroup.contains(t.target))}}function ef(t,e){return e?t.createChecked(null,e):t.createAndFill()}const nf=({editor:t})=>{const{selection:e}=t.state;if(!(e instanceof du))return!1;let n=0;const o=ys(e.ranges[0].$from,(t=>"table"===t.type.name));return null==o||o.node.descendants((t=>{if("table"===t.type.name)return!1;["tableCell","tableHeader"].includes(t.type.name)&&(n+=1)})),n===e.ranges.length&&(t.commands.deleteTable(),!0)},of=Fs.create({name:"table",addOptions:()=>({HTMLAttributes:{},resizable:!1,handleWidth:5,cellMinWidth:25,View:tf,lastColumnResizable:!0,allowTableNodeSelection:!1}),content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML:()=>[{tag:"table"}],renderHTML({node:t,HTMLAttributes:e}){const{colgroup:n,tableWidth:o,tableMinWidth:r}=function(t,e){let n=0,o=!0;const r=[],i=t.firstChild;if(!i)return{};for(let t=0,s=0;t<i.childCount;t+=1){const{colspan:l,colwidth:a}=i.child(t).attrs;for(let t=0;t<l;t+=1,s+=1){const i=undefined===s?undefined:a&&a[t],l=i?`${i}px`:"";n+=i||e,i||(o=!1),r.push(["col",l?{style:`width: ${l}`}:{}])}}const s=o?`${n}px`:"",l=o?"":`${n}px`;return{colgroup:["colgroup",{},...r],tableWidth:s,tableMinWidth:l}}(t,this.options.cellMinWidth);return["table",Oi(this.options.HTMLAttributes,e,{style:o?`width: ${o}`:`min-width: ${r}`}),n,["tbody",0]]},addCommands:()=>({insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:o,dispatch:r,editor:i})=>{const s=function(t,e,n,o,r){const i=function(t){if(t.cached.tableNodeTypes)return t.cached.tableNodeTypes;const e={};return Object.keys(t.nodes).forEach((n=>{const o=t.nodes[n];o.spec.tableRole&&(e[o.spec.tableRole]=o)})),t.cached.tableNodeTypes=e,e}(t),s=[],l=[];for(let t=0;t<n;t+=1){const t=ef(i.cell,r);if(t&&l.push(t),o){const t=ef(i.header_cell,r);t&&s.push(t)}}const a=[];for(let t=0;t<e;t+=1)a.push(i.row.createChecked(null,o&&0===t?s:l));return i.table.createChecked(null,a)}(i.schema,t,e,n);if(r){const t=o.selection.from+1;o.replaceSelectionWith(s).scrollIntoView().setSelection(le.near(o.doc.resolve(t)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>function(t,e){if(!ou(t))return!1;if(e){const n=gu(t);e(yu(t.tr,n,n.left))}return!0}(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>function(t,e){if(!ou(t))return!1;if(e){const n=gu(t);e(yu(t.tr,n,n.right))}return!0}(t,e),deleteColumn:()=>({state:t,dispatch:e})=>function(t,e){if(!ou(t))return!1;if(e){const n=gu(t),o=t.tr;if(0==n.left&&n.right==n.map.width)return!1;for(let t=n.right-1;bu(o,n,t),t!=n.left;t--){const t=n.tableStart?o.doc.nodeAt(n.tableStart-1):o.doc;if(!t)throw RangeError("No table found");n.table=t,n.map=Qp.get(t)}e(o)}return!0}(t,e),addRowBefore:()=>({state:t,dispatch:e})=>function(t,e){if(!ou(t))return!1;if(e){const n=gu(t);e(vu(t.tr,n,n.top))}return!0}(t,e),addRowAfter:()=>({state:t,dispatch:e})=>function(t,e){if(!ou(t))return!1;if(e){const n=gu(t);e(vu(t.tr,n,n.bottom))}return!0}(t,e),deleteRow:()=>({state:t,dispatch:e})=>function(t,e){if(!ou(t))return!1;if(e){const n=gu(t),o=t.tr;if(0==n.top&&n.bottom==n.map.height)return!1;for(let t=n.bottom-1;wu(o,n,t),t!=n.top;t--){const t=n.tableStart?o.doc.nodeAt(n.tableStart-1):o.doc;if(!t)throw RangeError("No table found");n.table=t,n.map=Qp.get(n.table)}e(o)}return!0}(t,e),deleteTable:()=>({state:t,dispatch:e})=>function(t,e){const n=t.selection.$anchor;for(let o=n.depth;o>0;o--)if("table"==n.node(o).type.spec.tableRole)return e&&e(t.tr.delete(n.before(o),n.after(o)).scrollIntoView()),!0;return!1}(t,e),mergeCells:()=>({state:t,dispatch:e})=>xu(t,e),splitCell:()=>({state:t,dispatch:e})=>Mu(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>Su("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>Su("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>Tu(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>!!xu(t,e)||Mu(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:o})=>function(t,e){return function(n,o){if(!ou(n))return!1;const r=ru(n);if(r.nodeAfter.attrs[t]===e)return!1;if(o){const i=n.tr;n.selection instanceof du?n.selection.forEachCell(((n,o)=>{n.attrs[t]!==e&&i.setNodeMarkup(o,null,{...n.attrs,[t]:e})})):i.setNodeMarkup(r.pos,null,{...r.nodeAfter.attrs,[t]:e}),o(i)}return!0}}(t,e)(n,o),goToNextCell:()=>({state:t,dispatch:e})=>Au(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>Au(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&mu(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const n=du.create(e.doc,t.anchorCell,t.headCell);e.setSelection(n)}return!0}}),addKeyboardShortcuts(){return{Tab:()=>!!this.editor.commands.goToNextCell()||!!this.editor.can().addRowAfter()&&this.editor.chain().addRowAfter().goToNextCell().run(),"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:nf,"Mod-Backspace":nf,Delete:nf,"Mod-Delete":nf}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[Ku({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],Qu({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema:t=>({tableRole:Di(Ci(t,"tableRole",{name:t.name,options:t.options,storage:t.storage}))})}),rf=Fs.create({name:"tableCell",addOptions:()=>({HTMLAttributes:{}}),content:"block+",addAttributes:()=>({colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map((t=>parseInt(t,10))):null}}}),tableRole:"cell",isolating:!0,parseHTML:()=>[{tag:"td"}],renderHTML({HTMLAttributes:t}){return["td",Oi(this.options.HTMLAttributes,t),0]}}),sf=Fs.create({name:"tableHeader",addOptions:()=>({HTMLAttributes:{}}),content:"block+",addAttributes:()=>({colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map((t=>parseInt(t,10))):null}}}),tableRole:"header_cell",isolating:!0,parseHTML:()=>[{tag:"th"}],renderHTML({HTMLAttributes:t}){return["th",Oi(this.options.HTMLAttributes,t),0]}}),lf=Fs.create({name:"tableRow",addOptions:()=>({HTMLAttributes:{}}),content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML:()=>[{tag:"tr"}],renderHTML({HTMLAttributes:t}){return["tr",Oi(this.options.HTMLAttributes,t),0]}}),af=Ui.create({name:"placeholder",addOptions:()=>({emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}),addProseMirrorPlugins(){return[new xe({key:new Se("placeholder"),props:{decorations:({doc:t,selection:e})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:o}=e,r=[];if(!n)return null;const i=this.editor.isEmpty;return t.descendants(((t,e)=>{const n=o>=e&&o<=e+t.nodeSize,s=!t.isLeaf&&Cs(t);if((n||!this.options.showOnlyCurrent)&&s){const o=[this.options.emptyNodeClass];i&&o.push(this.options.emptyEditorClass);const s=ir.node(e,e+t.nodeSize,{class:o.join(" "),"data-placeholder":"function"==typeof this.options.placeholder?this.options.placeholder({editor:this.editor,node:t,pos:e,hasAnchor:n}):this.options.placeholder});r.push(s)}return this.options.includeChildren})),ar.create(t,r)}}})]}}),cf=Vi.create({name:"textStyle",priority:101,addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"span",getAttrs:t=>!!t.hasAttribute("style")&&{}}],renderHTML({HTMLAttributes:t}){return["span",Oi(this.options.HTMLAttributes,t),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:t,commands:e})=>{const n=gs(t,this.type);return!!Object.entries(n).some((([,t])=>!!t))||e.unsetMark(this.name)}}}}),df=Ui.create({name:"color",addOptions:()=>({types:["textStyle"]}),addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;return null===(e=t.style.color)||void 0===e?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}}}}]},addCommands:()=>({setColor:t=>({chain:e})=>e().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()})}),hf=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,pf=Fs.create({name:"image",addOptions:()=>({inline:!1,allowBase64:!1,HTMLAttributes:{}}),inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes:()=>({src:{default:null},alt:{default:null},title:{default:null}}),parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:t}){return["img",Oi(this.options.HTMLAttributes,t)]},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[Hs({find:hf,type:this.type,getAttributes:t=>{const[,,e,n,o]=t;return{src:n,alt:e,title:o}}})]}});var uf=n(7479),ff={StarterKit:qp,Underline:Kp,Link:Ba,Superscript:Up,Subscript:Gp,Highlight:Rh,Table:of,TableCell:rf,TableHeader:sf,TableRow:lf,TextAlign:Jp,Placeholder:af,Color:df,TextStyle:cf,Image:pf},mf=function(t){var e=t.setProps,n=t.loading_state,r=(t.persistence,t.persisted_props,t.persistence_type,t.html),i=t.json,s=t.variant,l=t.extensions,a=void 0===l?["StarterKit","Underline","Link","Superscript","Subscript","Highlight","Table","TableCell","TableHeader","TableRow",{Placeholder:{placeholder:"Write or paste content here..."}},{TextAlign:{types:["heading","paragraph"]}},"Color","TextStyle","Image"]:l,c=t.toolbar,d=t.debounce,h=void 0===d?100:d,p=t.n_blur,u=void 0===p?0:p,f=(t.selected,t.labels),m=(0,o.Tt)(t,["setProps","loading_state","persistence","persisted_props","persistence_type","html","json","variant","extensions","toolbar","debounce","n_blur","selected","labels"]),g=function(t){void 0===t&&(t={}),O&&e((0,o.Cl)({html:O.getHTML(),json:O.getJSON()},t))},y=(0,Fa.useState)(""),b=y[0],v=y[1],w="number"==typeof h?h:0,k=(0,Oh.o)(b,w)[0];(0,Eh.C)((function(){"number"!=typeof h&&!1!==h||g()}),[k]),(0,Eh.C)((function(){O&&O.getHTML()!==r&&(O.commands.setContent(r),g())}),[r]),(0,Eh.C)((function(){O&&JSON.stringify(O.getJSON())!==JSON.stringify(i)&&(O.commands.setContent(i),g())}),[i]);var x=(0,Fa.useState)(""),M=x[0],C=x[1],S=(0,Oh.o)(M,w)[0];(0,Eh.C)((function(){"number"!=typeof h&&!1!==h||e({selected:S})}),[S]);var T=f&&(0,o.Cl)((0,o.Cl)((0,o.Cl)({},f),f.colorControlLabel&&{colorControlLabel:function(t){return f.colorControlLabel.replace("{color}",t)}}),f.colorPickerColorLabel&&{colorPickerColorLabel:function(t){return f.colorPickerColorLabel.replace("{color}",t)}}),A=void 0;void 0!==c&&(A=Va().createElement(mh.Toolbar,{sticky:c.sticky,stickyOffset:c.stickyOffset},c.controlsGroups.map((function(t,e){return Va().createElement(mh.ControlsGroup,{key:e},t.map((function(t,e){var n="string"==typeof t?t:Object.keys(t)[0],r="string"==typeof t?{}:t[n];return Va().createElement(mh[n],(0,o.Cl)({key:e},r))})))}))));var O=function(t={},e=[]){const n=(0,Fa.useRef)(t);n.current=t;const[o]=(0,Fa.useState)((()=>new bc(n))),r=oc.useSyncExternalStore(o.subscribe,o.getEditor,o.getServerSnapshot);return(0,Fa.useDebugValue)(r),(0,Fa.useEffect)(o.onRender(e)),function(t){var e;const[n]=(0,Fa.useState)((()=>new mc(t.editor))),o=fc.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,null!==(e=t.equalityFn)&&void 0!==e?e:hc);(0,Fa.useEffect)((()=>n.watch(t.editor)),[t.editor,n]),(0,Fa.useDebugValue)(o)}({editor:r,selector:({transactionNumber:e})=>!1===t.shouldRerenderOnTransaction?null:t.immediatelyRender&&0===e?0:e+1}),r}({extensions:a.map((function(t){if("string"==typeof t)return ff[t];var e=Object.keys(t)[0];return ff[e].configure(t[e])})),content:i||r,onUpdate:function(t){var e=t.editor;v(e.getJSON())},onBlur:function(){O&&!0===h&&g({n_blur:u+1,selected:M})},onSelectionUpdate:function(t){var e=t.editor;if(e){var n=e.state.selection,o=n.from,r=n.to,i=e.state.doc.textBetween(o,r," ");C(i)}},onCreate:g});return Va().createElement(mh,(0,o.Cl)({variant:s,editor:O,"data-dash-is-loading":(0,uf.A_)(n)||void 0,labels:T},m),A,Va().createElement(mh.Content,null))};(0,uf.oM)(mf,["html","json"]);const gf=mf},6541:(t,e,n)=>{n.d(e,{A:()=>p});var o=n(1601),r=n.n(o),i=n(6314),s=n.n(i),l=n(4417),a=n.n(l),c=new URL(n(4985),n.b),d=s()(r()),h=a()(c);d.push([t.id,`.m_dd3f7539 {\n position: relative;\n border: calc(0.0625rem * var(--mantine-scale)) solid;\n border-radius: var(--mantine-radius-default);\n}\n\n :where([data-mantine-color-scheme='light']) .m_dd3f7539 {\n border-color: var(--mantine-color-gray-4);\n}\n\n :where([data-mantine-color-scheme='dark']) .m_dd3f7539 {\n border-color: var(--mantine-color-dark-4);\n}\n\n.m_d37966d9 {\n padding: 0;\n margin: 0;\n}\n\n.m_d37966d9 li > p {\n margin: 0;\n }\n\n.m_d37966d9 ul li,\n .m_d37966d9 ol li {\n margin-top: calc(0.125rem * var(--mantine-scale));\n }\n\n.m_d37966d9 p {\n margin-bottom: calc(0.4375rem * var(--mantine-scale));\n }\n\n.m_d37966d9 h1,\n .m_d37966d9 h2,\n .m_d37966d9 h3,\n .m_d37966d9 h4,\n .m_d37966d9 h5,\n .m_d37966d9 h6,\n .m_d37966d9 p {\n margin-top: 0;\n }\n\n.m_c2204cc2 {\n background-color: var(--mantine-color-body);\n border-radius: var(--mantine-radius-default);\n}\n\n.m_c2204cc2 .ProseMirror {\n outline: 0;\n padding: var(--mantine-spacing-md);\n }\n\n.m_c2204cc2 .ProseMirror > *:last-child {\n margin-bottom: 0;\n }\n\n.m_c2204cc2 .ProseMirror p.is-editor-empty:first-of-type::before {\n content: attr(data-placeholder);\n pointer-events: none;\n user-select: none;\n float: left;\n height: 0;\n color: var(--mantine-color-placeholder);\n }\n\n.m_c2204cc2 pre {\n font-family: var(--mantine-font-family-monospace);\n border-radius: var(--mantine-radius-default);\n padding: var(--mantine-spacing-sm) var(--mantine-spacing-md);\n }\n\n:where([data-mantine-color-scheme='light']) .m_c2204cc2 pre {\n background-color: var(--mantine-color-gray-0);\n color: var(--mantine-color-gray-9);\n --code-color-comment: var(--mantine-color-gray-5);\n --code-color-var: var(--mantine-color-red-7);\n --code-color-number: var(--mantine-color-blue-7);\n --code-color-title: var(--mantine-color-pink-7);\n --code-color-keyword: var(--mantine-color-violet-7);\n}\n\n:where([data-mantine-color-scheme='dark']) .m_c2204cc2 pre {\n background-color: var(--mantine-color-dark-8);\n color: var(--mantine-color-dark-1);\n --code-color-comment: var(--mantine-color-dark-2);\n --code-color-var: var(--mantine-color-red-5);\n --code-color-number: var(--mantine-color-cyan-5);\n --code-color-title: var(--mantine-color-yellow-5);\n --code-color-keyword: var(--mantine-color-violet-3);\n}\n\n.m_c2204cc2 pre code {\n background: none !important;\n color: inherit;\n font-size: var(--mantine-font-size-sm);\n padding: 0;\n }\n\n.m_c2204cc2 pre .hljs-comment,\n .m_c2204cc2 pre .hljs-quote {\n color: var(--code-color-comment);\n }\n\n.m_c2204cc2 pre .hljs-variable,\n .m_c2204cc2 pre .hljs-template-variable,\n .m_c2204cc2 pre .hljs-attribute,\n .m_c2204cc2 pre .hljs-tag,\n .m_c2204cc2 pre .hljs-regexp,\n .m_c2204cc2 pre .hljs-link,\n .m_c2204cc2 pre .hljs-name,\n .m_c2204cc2 pre .hljs-selector-id,\n .m_c2204cc2 pre .hljs-selector-class {\n color: var(--code-color-var);\n }\n\n.m_c2204cc2 pre .hljs-number,\n .m_c2204cc2 pre .hljs-meta,\n .m_c2204cc2 pre .hljs-built_in,\n .m_c2204cc2 pre .hljs-builtin-name,\n .m_c2204cc2 pre .hljs-literal,\n .m_c2204cc2 pre .hljs-type,\n .m_c2204cc2 pre .hljs-params {\n color: var(--code-color-number);\n }\n\n.m_c2204cc2 pre .hljs-string,\n .m_c2204cc2 pre .hljs-symbol,\n .m_c2204cc2 pre .hljs-bullet {\n color: var(--code-color-var);\n }\n\n.m_c2204cc2 pre .hljs-title,\n .m_c2204cc2 pre .hljs-section {\n color: var(--code-color-title);\n }\n\n.m_c2204cc2 pre .hljs-keyword,\n .m_c2204cc2 pre .hljs-selector-tag {\n color: var(--code-color-keyword);\n }\n\n.m_c2204cc2 pre .hljs-emphasis {\n font-style: italic;\n }\n\n.m_c2204cc2 pre .hljs-strong {\n font-weight: 700;\n }\n\n.m_8a991b4f {\n background-color: var(--mantine-color-body);\n}\n\n.m_c2207da6 {\n display: flex;\n justify-content: center;\n align-items: center;\n border-radius: var(--mantine-radius-default);\n cursor: default;\n}\n\n.m_c2207da6:where([data-variant='default']) {\n border: calc(0.0625rem * var(--mantine-scale)) solid;\n min-width: calc(1.625rem * var(--mantine-scale));\n height: calc(1.625rem * var(--mantine-scale));\n }\n\n.m_c2207da6:where([data-variant='subtle']) {\n --control-icon-size: calc(1.25rem * var(--mantine-scale));\n min-width: calc(2rem * var(--mantine-scale));\n height: calc(2rem * var(--mantine-scale));\n }\n\n:where([data-mantine-color-scheme='light']) .m_c2207da6 {\n background-color: var(--mantine-color-white);\n border-color: var(--mantine-color-gray-4);\n color: var(--mantine-color-gray-7);\n}\n\n:where([data-mantine-color-scheme='dark']) .m_c2207da6 {\n border-color: var(--mantine-color-dark-4);\n color: var(--mantine-color-dark-1);\n}\n\n:where([data-mantine-color-scheme='dark']) .m_c2207da6:where([data-variant='default']) {\n background-color: var(--mantine-color-dark-6);\n }\n\n:where([data-mantine-color-scheme='dark']) .m_c2207da6:where([data-variant='subtle']) {\n background-color: var(--mantine-color-dark-7);\n }\n\n.m_c2207da6:where([data-disabled]) {\n cursor: not-allowed;\n color: var(--mantine-color-disabled-color);\n background-color: var(--mantine-color-disabled);\n }\n\n.m_c2207da6:where([data-interactive]:not([data-disabled])) {\n cursor: pointer;\n }\n\n@media (hover: hover) {\n\n .m_c2207da6:where([data-interactive]:not([data-disabled])):hover {\n color: var(--mantine-color-bright);\n }\n :where([data-mantine-color-scheme='light']) .m_c2207da6:where([data-interactive]:not([data-disabled])):hover:where([data-variant='default']) {\n background-color: var(--mantine-color-gray-0);\n }\n\n :where([data-mantine-color-scheme='light']) .m_c2207da6:where([data-interactive]:not([data-disabled])):hover:where([data-variant='subtle']) {\n background-color: var(--mantine-color-gray-1);\n }\n\n :where([data-mantine-color-scheme='dark']) .m_c2207da6:where([data-interactive]:not([data-disabled])):hover {\n background-color: var(--mantine-color-dark-5);\n }\n}\n\n@media (hover: none) {\n\n .m_c2207da6:where([data-interactive]:not([data-disabled])):active {\n color: var(--mantine-color-bright);\n }\n :where([data-mantine-color-scheme='light']) .m_c2207da6:where([data-interactive]:not([data-disabled])):active:where([data-variant='default']) {\n background-color: var(--mantine-color-gray-0);\n }\n\n :where([data-mantine-color-scheme='light']) .m_c2207da6:where([data-interactive]:not([data-disabled])):active:where([data-variant='subtle']) {\n background-color: var(--mantine-color-gray-1);\n }\n\n :where([data-mantine-color-scheme='dark']) .m_c2207da6:where([data-interactive]:not([data-disabled])):active {\n background-color: var(--mantine-color-dark-5);\n }\n}\n\n.m_c2207da6:where([data-active]) {\n background-color: var(--mantine-primary-color-light);\n color: var(--mantine-primary-color-light-color);\n }\n\n@media (hover: hover) {\n\n .m_c2207da6:where([data-active]):hover {\n background-color: var(--mantine-primary-color-light-hover);\n }\n}\n\n@media (hover: none) {\n\n .m_c2207da6:where([data-active]):active {\n background-color: var(--mantine-primary-color-light-hover);\n }\n}\n\n.m_9cdfeb3f {\n width: var(--control-icon-size, 16px);\n height: var(--control-icon-size, 16px);\n}\n\n.m_2ab47ef2 {\n display: flex;\n background-color: var(--mantine-color-body);\n}\n\n.m_2ab47ef2:where([data-variant='default']) :where([data-rich-text-editor-control]) {\n border-radius: 0;\n }\n\n.m_2ab47ef2:where([data-variant='default']) :where([data-rich-text-editor-control]):where(:not(:last-of-type)) {\n border-inline-end-width: 0;\n }\n\n.m_2ab47ef2:where([data-variant='default']) :where([data-rich-text-editor-control]):where(:last-of-type) {\n border-start-end-radius: var(--mantine-radius-default);\n border-end-end-radius: var(--mantine-radius-default);\n }\n\n.m_2ab47ef2:where([data-variant='default']) :where([data-rich-text-editor-control]):where(:first-of-type) {\n border-start-start-radius: var(--mantine-radius-default);\n border-end-start-radius: var(--mantine-radius-default);\n }\n\n.m_b67b711e {\n display: flex;\n}\n\n.m_296cf94c {\n border-start-end-radius: 0;\n border-end-end-radius: 0;\n border-inline-end: 0;\n}\n\n.m_cfef614 {\n border: calc(0.0625rem * var(--mantine-scale)) solid;\n color: var(--mantine-color-text);\n height: calc(1.5rem * var(--mantine-scale));\n width: calc(1.5rem * var(--mantine-scale));\n display: flex;\n justify-content: center;\n align-items: center;\n border-radius: var(--mantine-radius-default);\n}\n\n:where([data-mantine-color-scheme='light']) .m_cfef614 {\n background-color: var(--mantine-color-white);\n border-color: var(--mantine-color-gray-4);\n}\n\n:where([data-mantine-color-scheme='dark']) .m_cfef614 {\n background-color: var(--mantine-color-dark-7);\n border-color: var(--mantine-color-dark-4);\n}\n\n.m_cfef614:where([data-active]) {\n background-color: var(--mantine-primary-color-light);\n color: var(--mantine-primary-color-filled);\n }\n\n@media (hover: hover) {\n\n .m_cfef614:where([data-active]):hover {\n background-color: var(--mantine-primary-color-light-hover);\n }\n}\n\n@media (hover: none) {\n\n .m_cfef614:where([data-active]):active {\n background-color: var(--mantine-primary-color-light-hover);\n }\n}\n\n.m_3b28e7bb {\n border-start-start-radius: 0;\n border-end-start-radius: 0;\n}\n\n.m_4574a3c4 {\n display: flex;\n align-items: center;\n flex-wrap: wrap;\n gap: var(--mantine-spacing-sm);\n top: var(--rte-sticky-offset, 0px);\n background-color: var(--mantine-color-body);\n z-index: 1;\n border-start-end-radius: var(--mantine-radius-default);\n border-start-start-radius: var(--mantine-radius-default);\n border-bottom: calc(0.0625rem * var(--mantine-scale)) solid;\n}\n\n.m_4574a3c4:where([data-variant='default']) {\n padding: var(--mantine-spacing-xs) var(--mantine-spacing-md);\n }\n\n.m_4574a3c4:where([data-variant='subtle']) {\n padding: calc(0.25rem * var(--mantine-scale));\n row-gap: 0;\n }\n\n:where([data-mantine-color-scheme='light']) .m_4574a3c4 {\n border-color: var(--mantine-color-gray-4);\n}\n\n:where([data-mantine-color-scheme='dark']) .m_4574a3c4 {\n border-color: var(--mantine-color-dark-4);\n}\n\n.m_4574a3c4:where([data-sticky]) {\n position: sticky;\n }\n\n.m_8b44009a {\n list-style-type: none;\n padding: 0;\n padding-inline-start: 0;\n}\n\n.m_8b44009a :where(li) {\n margin: 0;\n padding: 0;\n display: flex;\n }\n\n.m_8b44009a :where(ul) {\n margin-top: calc(0.3125rem * var(--mantine-scale));\n }\n\n.m_8b44009a p {\n margin: 0;\n padding: 0;\n }\n\n.m_8b44009a :where(label) {\n display: inline-block;\n }\n\n.m_8b44009a :where(input) {\n cursor: pointer;\n appearance: none;\n width: calc(1.125rem * var(--mantine-scale));\n height: calc(1.125rem * var(--mantine-scale));\n border: calc(0.0625rem * var(--mantine-scale)) solid;\n border-radius: var(--mantine-radius-default);\n vertical-align: middle;\n position: relative;\n }\n\n:where([data-mantine-color-scheme='light']) .m_8b44009a :where(input) {\n background-color: var(--mantine-color-white);\n border-color: var(--mantine-color-gray-4);\n}\n\n:where([data-mantine-color-scheme='dark']) .m_8b44009a :where(input) {\n background-color: var(--mantine-color-dark-6);\n border-color: var(--mantine-color-dark-4);\n}\n\n.m_8b44009a :where(input):checked {\n background-color: var(--mantine-primary-color-filled);\n border-color: var(--mantine-primary-color-filled);\n }\n\n.m_8b44009a :where(input):checked::before {\n position: absolute;\n content: '';\n inset: 0;\n background-image: url(${h});\n background-repeat: no-repeat;\n background-size: calc(0.625rem * var(--mantine-scale));\n background-position: center;\n }\n\n.m_8b44009a :where(li > label) {\n margin-inline-end: var(--mantine-spacing-sm);\n }\n`,""]);const p=d}}]);