const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ace-editor-B1LNI9d2.js","./main-D6SjkSWq.js","./main-7yCn_uaK.css"])))=>i.map(i=>d[i]);
import{ak as ys,r as R,J as pn,j as y,a5 as er,Y as X,d as ge,a6 as tr,Q as j,T as O,a9 as me,D as nr,R as et,cT as Wc,cc as qc,t as tt,af as Kc,cU as Uc,ac as Vt,M as Ko,a0 as bs,a1 as xs,a2 as ks,a3 as ws,au as Uo,V as zn,aA as Jc,aE as Gc,P as Jo,z as Xc,ax as Yc}from"./main-D6SjkSWq.js";import{F as Zc,a as Qc,b as eu,c as tu,d as nu,C as Go,e as ru,f as su,g as iu,h as ou,i as lu,j as au,k as cu,L as uu,l as du,m as hu,U as fu,R as pu}from"./Undo-B6hEfmXr.js";import{C as mu}from"./color-picker-dialog-Bo1SRwnd.js";import{r as gu,w as yu}from"./traditional-GTMgz7Xu.js";import{g as Xo}from"./get-image-size-iUxUXrDd.js";import{u as bu}from"./use-active-upload-DElCZe_0.js";import{M as xu}from"./MoreVert-BtI38yN6.js";import{D as Ss}from"./dialog-footer-es-AfbvV.js";import{C as ku}from"./circle-alert-Doio2NC1.js";import{S as wu}from"./sticky-note-8BXAdCdJ.js";import{F as Su}from"./select-BkmhiFLy.js";import{D as Yo}from"./datatable-page-with-header-layout-BuTOEIJh.js";import"./ArrowBack-rzRCVnF5.js";import{F as Cu,u as vu}from"./file-upload-provider-C966C2x1.js";import{H as Zo,j as Mu,t as Tu,x as Eu,c as Au,p as Nu,s as Ou,b as Iu,r as Du,a as Ru,d as Lu,e as Pu}from"./core-DYU8gjYw.js";import{r as ri,t as zu,f as Qo,a as Bu}from"./linkify-Cbuu_PPG.js";import{E as ju}from"./Edit-Cysuqwzc.js";import{D as el}from"./dashboard-layout-context-C1ErlVWg.js";import{D as $u}from"./dashboard-sidenav-D2XZbk1n.js";/**
 * @license lucide-react v0.564.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Fu=[["path",{d:"M5 12h14",key:"1ays0h"}]],Hu=ys("minus",Fu);/**
 * @license lucide-react v0.564.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Vu=[["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}],["path",{d:"M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z",key:"kmsa83"}]],_u=ys("square-play",Vu);/**
 * @license lucide-react v0.564.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Wu=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],qu=ys("triangle-alert",Wu),tl=R.createContext(null);function te(){const t=R.useContext(tl);return t==null?void 0:t.editor}const mn={left:{icon:tu,label:pn("Align left")},center:{icon:eu,label:pn("Align center")},right:{icon:Qc,label:pn("Align right")},justify:{icon:Zc,label:pn("Justify")}};function Ku({size:t}){const e=te(),n=Object.keys(mn).find(s=>e==null?void 0:e.isActive({textAlign:s})),r=n?mn[n].icon:mn.left.icon;return y.jsxs(er,{floatingWidth:"auto",selectionMode:"single",selectedValue:n,onSelectionChange:s=>{e==null||e.commands.focus(),e==null||e.commands.setTextAlign(s)},children:[y.jsx(X,{size:t,disabled:!e,color:n?"primary":null,className:ge("flex-shrink-0"),children:y.jsx(r,{})}),y.jsx(tr,{children:Object.entries(mn).map(([s,i])=>{const o=i.icon;return y.jsx(j,{value:s,startIcon:y.jsx(o,{size:"md"}),capitalizeFirst:!0,children:y.jsx(O,{message:i.label.message})},s)})})]})}function Uu({size:t}){const e=te();return y.jsx(me,{label:y.jsx(O,{message:"Clear formatting"}),children:y.jsx(X,{disabled:!e,className:ge("flex-shrink-0"),size:t,onClick:()=>{e==null||e.chain().focus().clearNodes().unsetAllMarks().run()},children:y.jsx(nu,{})})})}function Ju({size:t}){const e=te(),n=(e==null?void 0:e.getAttributes("codeBlock").language)||"";return y.jsxs(er,{selectionMode:"single",selectedValue:n,onSelectionChange:r=>{e==null||e.commands.toggleCodeBlock({language:r})},children:[y.jsx(me,{label:y.jsx(O,{message:"Codeblock"}),children:y.jsx(X,{disabled:!e,className:ge("flex-shrink-0"),size:t,color:n?"primary":null,children:y.jsx(Go,{})})}),y.jsxs(tr,{children:[y.jsx(j,{value:"html",children:"HTML"}),y.jsx(j,{value:"javascript",children:"JavaScript"}),y.jsx(j,{value:"css",children:"CSS"}),y.jsx(j,{value:"php",children:"PHP"}),y.jsx(j,{value:"shell",children:"Shell"}),y.jsx(j,{value:"bash",children:"Bash"}),y.jsx(j,{value:"ruby",children:"Ruby"}),y.jsx(j,{value:"python",children:"Python"}),y.jsx(j,{value:"java",children:"Java"}),y.jsx(j,{value:"c++",children:"C++"})]})]})}function Gu({size:t}){const e=te(),[n,r]=R.useState(!1),s=e==null?void 0:e.getAttributes("textStyle").color,i=e==null?void 0:e.getAttributes("textStyle").backgroundColor;return y.jsxs(R.Fragment,{children:[y.jsxs("span",{className:ge("flex-shrink-0 whitespace-nowrap"),children:[y.jsx(X,{disabled:!e,size:t,color:s?"primary":null,onClick:()=>{r("text")},children:y.jsx(ru,{})}),y.jsx(X,{disabled:!e,size:t,color:i?"primary":null,onClick:()=>{r("bg")},children:y.jsx(su,{})})]}),y.jsx(nr,{defaultValue:n==="text"?"#000000":"#FFFFFF",type:"modal",isOpen:!!n,onClose:o=>{o&&(n==="text"?e==null||e.commands.setColor(o):e==null||e.commands.setBackgroundColor(o)),r(!1)},children:y.jsx(mu,{})})]})}function Mt(){return y.jsx("div",{className:"self-stretch mx-4 w-1 bg-divider flex-shrink-0"})}var nl=gu();function ne(t){this.content=t}ne.prototype={constructor:ne,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,s=r.find(t),i=r.content.slice();return s==-1?i.push(n||t,e):(i[s+1]=e,n&&(i[s]=n)),new ne(i)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new ne(n)},addToStart:function(t,e){return new ne([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new ne(n)},addBefore:function(t,e,n){var r=this.remove(e),s=r.content.slice(),i=r.find(t);return s.splice(i==-1?s.length:i,0,e,n),new ne(s)},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=ne.from(t),t.size?new ne(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=ne.from(t),t.size?new ne(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=ne.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}};ne.from=function(t){if(t instanceof ne)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new ne(e)};function rl(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let s=t.child(r),i=e.child(r);if(s==i){n+=s.nodeSize;continue}if(!s.sameMarkup(i))return n;if(s.isText&&s.text!=i.text){for(let o=0;s.text[o]==i.text[o];o++)n++;return n}if(s.content.size||i.content.size){let o=rl(s.content,i.content,n+1);if(o!=null)return o}n+=s.nodeSize}}function sl(t,e,n,r){for(let s=t.childCount,i=e.childCount;;){if(s==0||i==0)return s==i?null:{a:n,b:r};let o=t.child(--s),l=e.child(--i),a=o.nodeSize;if(o==l){n-=a,r-=a;continue}if(!o.sameMarkup(l))return{a:n,b:r};if(o.isText&&o.text!=l.text){let c=0,u=Math.min(o.text.length,l.text.length);for(;c<u&&o.text[o.text.length-c-1]==l.text[l.text.length-c-1];)c++,n--,r--;return{a:n,b:r}}if(o.content.size||l.content.size){let c=sl(o.content,l.content,n-1,r-1);if(c)return c}n-=a,r-=a}}class x{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,s=0,i){for(let o=0,l=0;l<n;o++){let a=this.content[o],c=l+a.nodeSize;if(c>e&&r(a,s+l,i||null,o)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,n-u),r,s+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,s){let i="",o=!0;return this.nodesBetween(e,n,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,n-a):l.isLeaf?s?typeof s=="function"?s(l):s:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(o?o=!1:i+=r),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,s=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(r)&&(s[s.length-1]=n.withText(n.text+r.text),i=1);i<e.content.length;i++)s.push(e.content[i]);return new x(s,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],s=0;if(n>e)for(let i=0,o=0;o<n;i++){let l=this.content[i],a=o+l.nodeSize;a>e&&((o<e||a>n)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,n-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,n-o-1))),r.push(l),s+=l.nodeSize),o=a}return new x(r,s)}cutByIndex(e,n){return e==n?x.empty:e==0&&n==this.content.length?this:new x(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let s=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return s[e]=n,new x(s,i)}addToStart(e){return new x([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new x(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let s=this.content[n];e(s,r,n),r+=s.nodeSize}}findDiffStart(e,n=0){return rl(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return sl(this,e,n,r)}findIndex(e){if(e==0)return gn(0,e);if(e==this.size)return gn(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let s=this.child(n),i=r+s.nodeSize;if(i>=e)return i==e?gn(n+1,i):gn(n,r);r=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return x.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new x(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return x.empty;let n,r=0;for(let s=0;s<e.length;s++){let i=e[s];r+=i.nodeSize,s&&i.isText&&e[s-1].sameMarkup(i)?(n||(n=e.slice(0,s)),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new x(n||e,r)}static from(e){if(!e)return x.empty;if(e instanceof x)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new x([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}x.empty=new x([],0);const kr={index:0,offset:0};function gn(t,e){return kr.index=t,kr.offset=e,kr}function Bn(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!Bn(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!Bn(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let F=class Hr{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let s=0;s<e.length;s++){let i=e[s];if(this.eq(i))return e;if(this.type.excludes(i.type))n||(n=e.slice(0,s));else{if(i.type.excludes(this.type))return e;!r&&i.type.rank>this.type.rank&&(n||(n=e.slice(0,s)),n.push(this),r=!0),n&&n.push(i)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Bn(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);let s=r.create(n.attrs);return r.checkAttrs(s.attrs),s}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return Hr.none;if(e instanceof Hr)return[e];let n=e.slice();return n.sort((r,s)=>r.type.rank-s.type.rank),n}};F.none=[];class jn extends Error{}class S{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=ol(this.content,e+this.openStart,n);return r&&new S(r,this.openStart,this.openEnd)}removeBetween(e,n){return new S(il(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return S.empty;let r=n.openStart||0,s=n.openEnd||0;if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new S(x.fromJSON(e,n.content),r,s)}static maxOpen(e,n=!0){let r=0,s=0;for(let i=e.firstChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.lastChild)s++;return new S(e,r,s)}}S.empty=new S(x.empty,0,0);function il(t,e,n){let{index:r,offset:s}=t.findIndex(e),i=t.maybeChild(r),{index:o,offset:l}=t.findIndex(n);if(s==e||i.isText){if(l!=n&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(r,i.copy(il(i.content,e-s-1,n-s-1)))}function ol(t,e,n,r){let{index:s,offset:i}=t.findIndex(e),o=t.maybeChild(s);if(i==e||o.isText)return r&&!r.canReplace(s,s,n)?null:t.cut(0,e).append(n).append(t.cut(e));let l=ol(o.content,e-i-1,n,o);return l&&t.replaceChild(s,o.copy(l))}function Xu(t,e,n){if(n.openStart>t.depth)throw new jn("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new jn("Inconsistent open depths");return ll(t,e,n,0)}function ll(t,e,n,r){let s=t.index(r),i=t.node(r);if(s==e.index(r)&&r<t.depth-n.openStart){let o=ll(t,e,n,r+1);return i.copy(i.content.replaceChild(s,o))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let o=t.parent,l=o.content;return ft(o,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=Yu(n,t);return ft(i,cl(t,o,l,e,r))}else return ft(i,$n(t,e,r))}function al(t,e){if(!e.type.compatibleContent(t.type))throw new jn("Cannot join "+e.type.name+" onto "+t.type.name)}function Vr(t,e,n){let r=t.node(n);return al(r,e.node(n)),r}function ht(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 Gt(t,e,n,r){let s=(e||t).node(n),i=0,o=e?e.index(n):s.childCount;t&&(i=t.index(n),t.depth>n?i++:t.textOffset&&(ht(t.nodeAfter,r),i++));for(let l=i;l<o;l++)ht(s.child(l),r);e&&e.depth==n&&e.textOffset&&ht(e.nodeBefore,r)}function ft(t,e){return t.type.checkContent(e),t.copy(e)}function cl(t,e,n,r,s){let i=t.depth>s&&Vr(t,e,s+1),o=r.depth>s&&Vr(n,r,s+1),l=[];return Gt(null,t,s,l),i&&o&&e.index(s)==n.index(s)?(al(i,o),ht(ft(i,cl(t,e,n,r,s+1)),l)):(i&&ht(ft(i,$n(t,e,s+1)),l),Gt(e,n,s,l),o&&ht(ft(o,$n(n,r,s+1)),l)),Gt(r,null,s,l),new x(l)}function $n(t,e,n){let r=[];if(Gt(null,t,n,r),t.depth>n){let s=Vr(t,e,n+1);ht(ft(s,$n(t,e,n+1)),r)}return Gt(e,null,n,r),new x(r)}function Yu(t,e){let n=e.depth-t.openStart,s=e.node(n).copy(t.content);for(let i=n-1;i>=0;i--)s=e.node(i).copy(x.from(s));return{start:s.resolveNoCache(t.openStart+n),end:s.resolveNoCache(s.content.size-t.openEnd-n)}}class Qt{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],s=e.child(n);return r?e.child(n).cut(r):s}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],s=n==0?0:this.path[n*3-1]+1;for(let i=0;i<e;i++)s+=r.child(i).nodeSize;return s}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return F.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),s=e.maybeChild(n);if(!r){let l=r;r=s,s=l}let i=r.marks;for(var o=0;o<i.length;o++)i[o].type.spec.inclusive===!1&&(!s||!i[o].isInSet(s.marks))&&(i=i[o--].removeFromSet(i));return i}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,s=e.parent.maybeChild(e.index());for(var i=0;i<r.length;i++)r[i].type.spec.inclusive===!1&&(!s||!r[i].isInSet(s.marks))&&(r=r[i--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new Fn(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],s=0,i=n;for(let o=e;;){let{index:l,offset:a}=o.content.findIndex(i),c=i-a;if(r.push(o,l,s+a),!c||(o=o.child(l),o.isText))break;i=c-1,s+=a+1}return new Qt(n,r,i)}static resolveCached(e,n){let r=si.get(e);if(r)for(let i=0;i<r.elts.length;i++){let o=r.elts[i];if(o.pos==n)return o}else si.set(e,r=new Zu);let s=r.elts[r.i]=Qt.resolve(e,n);return r.i=(r.i+1)%Qu,s}}class Zu{constructor(){this.elts=[],this.i=0}}const Qu=12,si=new WeakMap;class Fn{constructor(e,n,r){this.$from=e,this.$to=n,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const ed=Object.create(null);class ve{constructor(e,n,r,s=F.none){this.type=e,this.attrs=n,this.marks=s,this.content=r||x.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,n,r,s=0){this.content.nodesBetween(e,n,r,s,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,n,r,s){return this.content.textBetween(e,n,r,s)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,r){return this.type==e&&Bn(this.attrs,n||e.defaultAttrs||ed)&&F.sameSet(this.marks,r||F.none)}copy(e=null){return e==this.content?this:new ve(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new ve(this.type,this.attrs,this.content,e)}cut(e,n=this.content.size){return e==0&&n==this.content.size?this:this.copy(this.content.cut(e,n))}slice(e,n=this.content.size,r=!1){if(e==n)return S.empty;let s=this.resolve(e),i=this.resolve(n),o=r?0:s.sharedDepth(n),l=s.start(o),c=s.node(o).content.cut(s.pos-l,i.pos-l);return new S(c,s.depth-o,i.depth-o)}replace(e,n,r){return Xu(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:s}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(s==e||n.isText)return n;e-=s+1}}childAfter(e){let{index:n,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(n),index:n,offset:r};let s=this.content.child(n-1);return{node:s,index:n-1,offset:r-s.nodeSize}}resolve(e){return Qt.resolveCached(this,e)}resolveNoCache(e){return Qt.resolve(this,e)}rangeHasMark(e,n,r){let s=!1;return n>e&&this.nodesBetween(e,n,i=>(r.isInSet(i.marks)&&(s=!0),!s)),s}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),ul(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=x.empty,s=0,i=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,s,i),l=o&&o.matchFragment(this.content,n);if(!l||!l.validEnd)return!1;for(let a=s;a<i;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,n,r,s){if(s&&!this.type.allowsMarks(s))return!1;let i=this.contentMatchAt(e).matchType(r),o=i&&i.matchFragment(this.content,n);return o?o.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=F.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!F.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let s=x.fromJSON(e,n.content),i=e.nodeType(n.type).create(n.attrs,s,r);return i.type.checkAttrs(i.attrs),i}}ve.prototype.text=void 0;class Hn extends ve{constructor(e,n,r,s){if(super(e,n,null,s),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):ul(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new Hn(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Hn(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function ul(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class yt{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new td(e,n);if(r.next==null)return yt.empty;let s=dl(r);r.next&&r.err("Unexpected trailing text");let i=ad(ld(s));return cd(i,r),i}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let s=this;for(let i=n;s&&i<r;i++)s=s.matchType(e.child(i).type);return s}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let s=[this];function i(o,l){let a=o.matchFragment(e,r);if(a&&(!n||a.validEnd))return x.from(l.map(c=>c.createAndFill()));for(let c=0;c<o.next.length;c++){let{type:u,next:d}=o.next[c];if(!(u.isText||u.hasRequiredAttrs())&&s.indexOf(d)==-1){s.push(d);let h=i(d,l.concat(u));if(h)return h}}return null}return i(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let s=r.shift(),i=s.match;if(i.matchType(e)){let o=[];for(let l=s;l.type;l=l.via)o.push(l.type);return o.reverse()}for(let o=0;o<i.next.length;o++){let{type:l,next:a}=i.next[o];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in n)&&(!s.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:s}),n[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let s=0;s<r.next.length;s++)e.indexOf(r.next[s].next)==-1&&n(r.next[s].next)}return n(this),e.map((r,s)=>{let i=s+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)i+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return i}).join(`
`)}}yt.empty=new yt(!0);class td{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function dl(t){let e=[];do e.push(nd(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function nd(t){let e=[];do e.push(rd(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function rd(t){let e=od(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=sd(t,e);else break;return e}function ii(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function sd(t,e){let n=ii(t),r=n;return t.eat(",")&&(t.next!="}"?r=ii(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function id(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let s=[];for(let i in n){let o=n[i];o.isInGroup(e)&&s.push(o)}return s.length==0&&t.err("No node type or group '"+e+"' found"),s}function od(t){if(t.eat("(")){let e=dl(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=id(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function ld(t){let e=[[]];return s(i(t,0),n()),e;function n(){return e.push([])-1}function r(o,l,a){let c={term:a,to:l};return e[o].push(c),c}function s(o,l){o.forEach(a=>a.to=l)}function i(o,l){if(o.type=="choice")return o.exprs.reduce((a,c)=>a.concat(i(c,l)),[]);if(o.type=="seq")for(let a=0;;a++){let c=i(o.exprs[a],l);if(a==o.exprs.length-1)return c;s(c,l=n())}else if(o.type=="star"){let a=n();return r(l,a),s(i(o.expr,a),a),[r(a)]}else if(o.type=="plus"){let a=n();return s(i(o.expr,l),a),s(i(o.expr,a),a),[r(a)]}else{if(o.type=="opt")return[r(l)].concat(i(o.expr,l));if(o.type=="range"){let a=l;for(let c=0;c<o.min;c++){let u=n();s(i(o.expr,a),u),a=u}if(o.max==-1)s(i(o.expr,a),a);else for(let c=o.min;c<o.max;c++){let u=n();r(a,u),s(i(o.expr,a),u),a=u}return[r(a)]}else{if(o.type=="name")return[r(l,void 0,o.value)];throw new Error("Unknown expr type")}}}}function hl(t,e){return e-t}function oi(t,e){let n=[];return r(e),n.sort(hl);function r(s){let i=t[s];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(s);for(let o=0;o<i.length;o++){let{term:l,to:a}=i[o];!l&&n.indexOf(a)==-1&&r(a)}}}function ad(t){let e=Object.create(null);return n(oi(t,0));function n(r){let s=[];r.forEach(o=>{t[o].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let u=0;u<s.length;u++)s[u][0]==l&&(c=s[u][1]);oi(t,a).forEach(u=>{c||s.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let i=e[r.join(",")]=new yt(r.indexOf(t.length-1)>-1);for(let o=0;o<s.length;o++){let l=s[o][1].sort(hl);i.next.push({type:s[o][0],next:e[l.join(",")]||n(l)})}return i}}function cd(t,e){for(let n=0,r=[t];n<r.length;n++){let s=r[n],i=!s.validEnd,o=[];for(let l=0;l<s.next.length;l++){let{type:a,next:c}=s.next[l];o.push(a.name),i&&!(a.isText||a.hasRequiredAttrs())&&(i=!1),r.indexOf(c)==-1&&r.push(c)}i&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function fl(t){let e=Object.create(null);for(let n in t){let r=t[n];if(!r.hasDefault)return null;e[n]=r.default}return e}function pl(t,e){let n=Object.create(null);for(let r in t){let s=e&&e[r];if(s===void 0){let i=t[r];if(i.hasDefault)s=i.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=s}return n}function ml(t,e,n,r){for(let s in e)if(!(s in t))throw new RangeError(`Unsupported attribute ${s} for ${n} of type ${s}`);for(let s in t){let i=t[s];i.validate&&i.validate(e[s])}}function gl(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new dd(t,r,e[r]);return n}let li=class yl{constructor(e,n,r){this.name=e,this.schema=n,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=gl(e,r.attrs),this.defaultAttrs=fl(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==yt.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:pl(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new ve(this,this.computeAttrs(e),x.from(n),F.setFrom(r))}createChecked(e=null,n,r){return n=x.from(n),this.checkContent(n),new ve(this,this.computeAttrs(e),n,F.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=x.from(n),n.size){let o=this.contentMatch.fillBefore(n);if(!o)return null;n=o.append(n)}let s=this.contentMatch.matchFragment(n),i=s&&s.fillBefore(x.empty,!0);return i?new ve(this,e,n.append(i),F.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){ml(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;n<e.length;n++)if(!this.allowsMarkType(e[n].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let n;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?n&&n.push(e[r]):n||(n=e.slice(0,r));return n?n.length?n:F.none:e}static compile(e,n){let r=Object.create(null);e.forEach((i,o)=>r[i]=new yl(i,n,o));let s=n.spec.topNode||"doc";if(!r[s])throw new RangeError("Schema is missing its top node type ('"+s+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function ud(t,e,n){let r=n.split("|");return s=>{let i=s===null?"null":typeof s;if(r.indexOf(i)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${i}`)}}class dd{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?ud(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class rr{constructor(e,n,r,s){this.name=e,this.rank=n,this.schema=r,this.spec=s,this.attrs=gl(e,s.attrs),this.excluded=null;let i=fl(this.attrs);this.instance=i?new F(this,i):null}create(e=null){return!e&&this.instance?this.instance:new F(this,pl(this.attrs,e))}static compile(e,n){let r=Object.create(null),s=0;return e.forEach((i,o)=>r[i]=new rr(i,s++,n,o)),r}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}checkAttrs(e){ml(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class bl{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let s in e)n[s]=e[s];n.nodes=ne.from(e.nodes),n.marks=ne.from(e.marks||{}),this.nodes=li.compile(this.spec.nodes,this),this.marks=rr.compile(this.spec.marks,this);let r=Object.create(null);for(let s in this.nodes){if(s in this.marks)throw new RangeError(s+" can not be both a node and a mark");let i=this.nodes[s],o=i.spec.content||"",l=i.spec.marks;if(i.contentMatch=r[o]||(r[o]=yt.parse(o,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=l=="_"?null:l?ai(this,l.split(" ")):l==""||!i.inlineContent?[]:null}for(let s in this.marks){let i=this.marks[s],o=i.spec.excludes;i.excluded=o==null?[i]:o==""?[]:ai(this,o.split(" "))}this.nodeFromJSON=s=>ve.fromJSON(this,s),this.markFromJSON=s=>F.fromJSON(this,s),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,s){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof li){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,r,s)}text(e,n){let r=this.nodes.text;return new Hn(r,r.defaultAttrs,e,F.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}}function ai(t,e){let n=[];for(let r=0;r<e.length;r++){let s=e[r],i=t.marks[s],o=i;if(i)n.push(i);else for(let l in t.marks){let a=t.marks[l];(s=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(s)>-1)&&n.push(o=a)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function hd(t){return t.tag!=null}function fd(t){return t.style!=null}class Xe{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(s=>{if(hd(s))this.tags.push(s);else if(fd(s)){let i=/[^=]*/.exec(s.style)[0];r.indexOf(i)<0&&r.push(i),this.styles.push(s)}}),this.normalizeLists=!this.tags.some(s=>{if(!/^(ul|ol)\b/.test(s.tag)||!s.node)return!1;let i=e.nodes[s.node];return i.contentMatch.matchType(i)})}parse(e,n={}){let r=new ui(this,n,!1);return r.addAll(e,F.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new ui(this,n,!0);return r.addAll(e,F.none,n.from,n.to),S.maxOpen(r.finish())}matchTag(e,n,r){for(let s=r?this.tags.indexOf(r)+1:0;s<this.tags.length;s++){let i=this.tags[s];if(gd(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||n.matchesContext(i.context))){if(i.getAttrs){let o=i.getAttrs(e);if(o===!1)continue;i.attrs=o||void 0}return i}}}matchStyle(e,n,r,s){for(let i=s?this.styles.indexOf(s)+1:0;i<this.styles.length;i++){let o=this.styles[i],l=o.style;if(!(l.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=n))){if(o.getAttrs){let a=o.getAttrs(n);if(a===!1)continue;o.attrs=a||void 0}return o}}}static schemaRules(e){let n=[];function r(s){let i=s.priority==null?50:s.priority,o=0;for(;o<n.length;o++){let l=n[o];if((l.priority==null?50:l.priority)<i)break}n.splice(o,0,s)}for(let s in e.marks){let i=e.marks[s].spec.parseDOM;i&&i.forEach(o=>{r(o=di(o)),o.mark||o.ignore||o.clearMark||(o.mark=s)})}for(let s in e.nodes){let i=e.nodes[s].spec.parseDOM;i&&i.forEach(o=>{r(o=di(o)),o.node||o.ignore||o.mark||(o.node=s)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Xe(e,Xe.schemaRules(e)))}}const xl={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},pd={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},kl={ol:!0,ul:!0},en=1,_r=2,Xt=4;function ci(t,e,n){return e!=null?(e?en:0)|(e==="full"?_r:0):t&&t.whitespace=="pre"?en|_r:n&~Xt}class yn{constructor(e,n,r,s,i,o){this.type=e,this.attrs=n,this.marks=r,this.solid=s,this.options=o,this.content=[],this.activeMarks=F.none,this.match=i||(o&Xt?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(x.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,s;return(s=r.findWrapping(e.type))?(this.match=r,s):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&en)){let r=this.content[this.content.length-1],s;if(r&&r.isText&&(s=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-s[0].length))}}let n=x.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(x.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!xl.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class ui{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let s=n.topNode,i,o=ci(null,n.preserveWhitespace,0)|(r?Xt:0);s?i=new yn(s.type,s.attrs,F.none,!0,n.topMatch||s.type.contentMatch,o):r?i=new yn(null,null,F.none,!0,null,o):i=new yn(e.schema.topNodeType,null,F.none,!0,null,o),this.nodes=[i],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,s=this.top,i=s.options&_r?"full":this.localPreserveWS||(s.options&en)>0,{schema:o}=this.parser;if(i==="full"||s.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i)if(i==="full")r=r.replace(/\r\n?/g,`
`);else if(o.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(o.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(o.linebreakReplacement.create(),n,!0),l[a]&&this.insertNode(o.text(l[a]),n,!/\S/.test(l[a]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let l=s.content[s.content.length-1],a=e.previousSibling;(!l||a&&a.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(o.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let s=this.localPreserveWS,i=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),l;kl.hasOwnProperty(o)&&this.parser.normalizeLists&&md(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:pd.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,n);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,u=this.needsBlock;if(xl.hasOwnProperty(o))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),c=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let d=a&&a.skip?n:this.readStyles(e,n);d&&this.addAll(e,d),c&&this.sync(i),this.needsBlock=u}else{let c=this.readStyles(e,n);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=s}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
`),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let s=0;s<this.parser.matchedStyles.length;s++){let i=this.parser.matchedStyles[s],o=r.getPropertyValue(i);if(o)for(let l=void 0;;){let a=this.parser.matchStyle(i,o,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?n=n.filter(c=>!a.clearMark(c)):n=n.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return n}addElementByRule(e,n,r,s){let i,o;if(n.node)if(o=this.parser.schema.nodes[n.node],o.isLeaf)this.insertNode(o.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(o,n.attrs||null,r,n.preserveWhitespace);a&&(i=!0,r=a)}else{let a=this.parser.schema.marks[n.mark];r=r.concat(a.create(n.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(s)this.addElement(e,r,s);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof n.contentElement=="string"?a=e.querySelector(n.contentElement):typeof n.contentElement=="function"?a=n.contentElement(e):n.contentElement&&(a=n.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}i&&this.sync(l)&&this.open--}addAll(e,n,r,s){let i=r||0;for(let o=r?e.childNodes[r]:e.firstChild,l=s==null?null:e.childNodes[s];o!=l;o=o.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(o,n);this.findAtPoint(e,i)}findPlace(e,n,r){let s,i;for(let o=this.open,l=0;o>=0;o--){let a=this.nodes[o],c=a.findWrapping(e);if(c&&(!s||s.length>c.length+l)&&(s=c,i=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!s)return null;this.sync(i);for(let o=0;o<s.length;o++)n=this.enterInner(s[o],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(n=this.enterInner(i,null,n))}let s=this.findPlace(e,n,r);if(s){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let o=F.none;for(let l of s.concat(e.marks))(i.type?i.type.allowsMarkType(l.type):hi(l.type,e.type))&&(o=l.addToSet(o));return i.content.push(e.mark(o)),!0}return!1}enter(e,n,r,s){let i=this.findPlace(e.create(n),r,!1);return i&&(i=this.enterInner(e,n,r,!0,s)),i}enterInner(e,n,r,s=!1,i){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=ci(e,i,o.options);o.options&Xt&&o.content.length==0&&(l|=Xt);let a=F.none;return r=r.filter(c=>(o.type?o.type.allowsMarkType(c.type):hi(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new yn(e,n,a,s,null,l)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=en)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let s=r.length-1;s>=0;s--)e+=r[s].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let s=0;s<this.find.length;s++)this.find[s].pos==null&&e.nodeType==1&&e.contains(this.find[s].node)&&n.compareDocumentPosition(this.find[s].node)&(r?2:4)&&(this.find[s].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,s=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(s?0:1),o=(l,a)=>{for(;l>=0;l--){let c=n[l];if(c==""){if(l==n.length-1||l==0)continue;for(;a>=i;a--)if(o(l-1,a))return!0;return!1}else{let u=a>0||a==0&&s?this.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;a--}}return!0};return o(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function md(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&kl.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function gd(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function di(t){let e={};for(let n in t)e[n]=t[n];return e}function hi(t,e){let n=e.schema.nodes;for(let r in n){let s=n[r];if(!s.allowsMarkType(t))continue;let i=[],o=l=>{i.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:u}=l.edge(a);if(c==e||i.indexOf(u)<0&&o(u))return!0}};if(o(s.contentMatch))return!0}}class Ct{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=wr(n).createDocumentFragment());let s=r,i=[];return e.forEach(o=>{if(i.length||o.marks.length){let l=0,a=0;for(;l<i.length&&a<o.marks.length;){let c=o.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(i[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<i.length;)s=i.pop()[1];for(;a<o.marks.length;){let c=o.marks[a++],u=this.serializeMark(c,o.isInline,n);u&&(i.push([c,s]),s.appendChild(u.dom),s=u.contentDOM||u.dom)}}s.appendChild(this.serializeNodeInner(o,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:s}=On(wr(n),this.nodes[e.type.name](e),null,e.attrs);if(s){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,s)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let s=e.marks.length-1;s>=0;s--){let i=this.serializeMark(e.marks[s],e.isInline,n);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,n,r={}){let s=this.marks[e.type.name];return s&&On(wr(r),s(e,n),null,e.attrs)}static renderSpec(e,n,r=null,s){return On(e,n,r,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Ct(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=fi(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return fi(e.marks)}}function fi(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function wr(t){return t.document||window.document}const pi=new WeakMap;function yd(t){let e=pi.get(t);return e===void 0&&pi.set(t,e=bd(t)),e}function bd(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let s=0;s<r.length;s++)n(r[s]);else for(let s in r)n(r[s])}return n(t),e}function On(t,e,n,r){if(typeof e=="string")return{dom:t.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let s=e[0],i;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=yd(r))&&i.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=s.indexOf(" ");o>0&&(n=s.slice(0,o),s=s.slice(o+1));let l,a=n?t.createElementNS(n,s):t.createElement(s),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let d in c)if(c[d]!=null){let h=d.indexOf(" ");h>0?a.setAttributeNS(d.slice(0,h),d.slice(h+1),c[d]):d=="style"&&a.style?a.style.cssText=c[d]:a.setAttribute(d,c[d])}}for(let d=u;d<e.length;d++){let h=e[d];if(h===0){if(d<e.length-1||d>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:f,contentDOM:p}=On(t,h,n,r);if(a.appendChild(f),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}const wl=65535,Sl=Math.pow(2,16);function xd(t,e){return t+e*Sl}function mi(t){return t&wl}function kd(t){return(t-(t&wl))/Sl}const Cl=1,vl=2,In=4,Ml=8;class Wr{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&Ml)>0}get deletedBefore(){return(this.delInfo&(Cl|In))>0}get deletedAfter(){return(this.delInfo&(vl|In))>0}get deletedAcross(){return(this.delInfo&In)>0}}class fe{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&fe.empty)return fe.empty}recover(e){let n=0,r=mi(e);if(!this.inverted)for(let s=0;s<r;s++)n+=this.ranges[s*3+2]-this.ranges[s*3+1];return this.ranges[r*3]+n+kd(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let s=0,i=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?s:0);if(a>e)break;let c=this.ranges[l+i],u=this.ranges[l+o],d=a+c;if(e<=d){let h=c?e==a?-1:e==d?1:n:n,f=a+s+(h<0?0:u);if(r)return f;let p=e==(n<0?a:d)?null:xd(l/3,e-a),m=e==a?vl:e==d?Cl:In;return(n<0?e!=a:e!=d)&&(m|=Ml),new Wr(f,m,p)}s+=u-c}return r?e+s:new Wr(e+s,0,null)}touches(e,n){let r=0,s=mi(n),i=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+i],u=a+c;if(e<=u&&l==s*3)return!0;r+=this.ranges[l+o]-c}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let s=0,i=0;s<this.ranges.length;s+=3){let o=this.ranges[s],l=o-(this.inverted?i:0),a=o+(this.inverted?0:i),c=this.ranges[s+n],u=this.ranges[s+r];e(l,l+c,a,a+u),i+=u-c}}invert(){return new fe(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?fe.empty:new fe(e<0?[0,-e,0]:[0,0,e])}}fe.empty=new fe([]);class tn{constructor(e,n,r=0,s=e?e.length:0){this.mirror=n,this.from=r,this.to=s,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new tn(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=0,r=this._maps.length;n<e._maps.length;n++){let s=e.getMirror(n);this.appendMap(e._maps[n],s!=null&&s<n?r+s:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,r=this._maps.length+e._maps.length;n>=0;n--){let s=e.getMirror(n);this.appendMap(e._maps[n].invert(),s!=null&&s>n?r-s-1:void 0)}}invert(){let e=new tn;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let s=0;for(let i=this.from;i<this.to;i++){let o=this._maps[i],l=o.mapResult(e,n);if(l.recover!=null){let a=this.getMirror(i);if(a!=null&&a>i&&a<this.to){i=a,e=this._maps[a].recover(l.recover);continue}}s|=l.delInfo,e=l.pos}return r?e:new Wr(e,s,null)}}const Sr=Object.create(null);class ae{getMap(){return fe.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Sr[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Sr)throw new RangeError("Duplicate use of step JSON ID "+e);return Sr[e]=n,n.prototype.jsonID=e,n}}class K{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new K(e,null)}static fail(e){return new K(null,e)}static fromReplace(e,n,r,s){try{return K.ok(e.replace(n,r,s))}catch(i){if(i instanceof jn)return K.fail(i.message);throw i}}}function Cs(t,e,n){let r=[];for(let s=0;s<t.childCount;s++){let i=t.child(s);i.content.size&&(i=i.copy(Cs(i.content,e,i))),i.isInline&&(i=e(i,n,s)),r.push(i)}return x.fromArray(r)}class Ue extends ae{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),s=r.node(r.sharedDepth(this.to)),i=new S(Cs(n.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),s),n.openStart,n.openEnd);return K.fromReplace(e,this.from,this.to,i)}invert(){return new Ce(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Ue(n.pos,r.pos,this.mark)}merge(e){return e instanceof Ue&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ue(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Ue(n.from,n.to,e.markFromJSON(n.mark))}}ae.jsonID("addMark",Ue);class Ce extends ae{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new S(Cs(n.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),n.openStart,n.openEnd);return K.fromReplace(e,this.from,this.to,r)}invert(){return new Ue(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Ce(n.pos,r.pos,this.mark)}merge(e){return e instanceof Ce&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ce(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Ce(n.from,n.to,e.markFromJSON(n.mark))}}ae.jsonID("removeMark",Ce);class Je extends ae{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return K.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return K.fromReplace(e,this.pos,this.pos+1,new S(x.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let s=0;s<n.marks.length;s++)if(!n.marks[s].isInSet(r))return new Je(this.pos,n.marks[s]);return new Je(this.pos,this.mark)}}return new bt(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Je(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Je(n.pos,e.markFromJSON(n.mark))}}ae.jsonID("addNodeMark",Je);class bt extends ae{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return K.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return K.fromReplace(e,this.pos,this.pos+1,new S(x.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new Je(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new bt(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new bt(n.pos,e.markFromJSON(n.mark))}}ae.jsonID("removeNodeMark",bt);class Y extends ae{constructor(e,n,r,s=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=s}apply(e){return this.structure&&qr(e,this.from,this.to)?K.fail("Structure replace would overwrite content"):K.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new fe([this.from,this.to-this.from,this.slice.size])}invert(e){return new Y(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deletedAcross&&r.deletedAcross?null:new Y(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Y)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?S.empty:new S(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Y(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?S.empty:new S(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Y(e.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Y(n.from,n.to,S.fromJSON(e,n.slice),!!n.structure)}}ae.jsonID("replace",Y);class Q extends ae{constructor(e,n,r,s,i,o,l=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=s,this.slice=i,this.insert=o,this.structure=l}apply(e){if(this.structure&&(qr(e,this.from,this.gapFrom)||qr(e,this.gapTo,this.to)))return K.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return K.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?K.fromReplace(e,this.from,this.to,r):K.fail("Content does not fit in gap")}getMap(){return new fe([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new Q(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),s=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||s<n.pos||i>r.pos?null:new Q(n.pos,r.pos,s,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Q(n.from,n.to,n.gapFrom,n.gapTo,S.fromJSON(e,n.slice),n.insert,!!n.structure)}}ae.jsonID("replaceAround",Q);function qr(t,e,n){let r=t.resolve(e),s=n-e,i=r.depth;for(;s>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,s--;if(s>0){let o=r.node(i).maybeChild(r.indexAfter(i));for(;s>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,s--}}return!1}function wd(t,e,n,r){let s=[],i=[],o,l;t.doc.nodesBetween(e,n,(a,c,u)=>{if(!a.isInline)return;let d=a.marks;if(!r.isInSet(d)&&u.type.allowsMarkType(r.type)){let h=Math.max(c,e),f=Math.min(c+a.nodeSize,n),p=r.addToSet(d);for(let m=0;m<d.length;m++)d[m].isInSet(p)||(o&&o.to==h&&o.mark.eq(d[m])?o.to=f:s.push(o=new Ce(h,f,d[m])));l&&l.to==h?l.to=f:i.push(l=new Ue(h,f,r))}}),s.forEach(a=>t.step(a)),i.forEach(a=>t.step(a))}function Sd(t,e,n,r){let s=[],i=0;t.doc.nodesBetween(e,n,(o,l)=>{if(!o.isInline)return;i++;let a=null;if(r instanceof rr){let c=o.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(o.marks)&&(a=[r]):a=o.marks;if(a&&a.length){let c=Math.min(l+o.nodeSize,n);for(let u=0;u<a.length;u++){let d=a[u],h;for(let f=0;f<s.length;f++){let p=s[f];p.step==i-1&&d.eq(s[f].style)&&(h=p)}h?(h.to=c,h.step=i):s.push({style:d,from:Math.max(l,e),to:c,step:i})}}}),s.forEach(o=>t.step(new Ce(o.from,o.to,o.style)))}function vs(t,e,n,r=n.contentMatch,s=!0){let i=t.doc.nodeAt(e),o=[],l=e+1;for(let a=0;a<i.childCount;a++){let c=i.child(a),u=l+c.nodeSize,d=r.matchType(c.type);if(!d)o.push(new Y(l,u,S.empty));else{r=d;for(let h=0;h<c.marks.length;h++)n.allowsMarkType(c.marks[h].type)||t.step(new Ce(l,u,c.marks[h]));if(s&&c.isText&&n.whitespace!="pre"){let h,f=/\r?\n|\r/g,p;for(;h=f.exec(c.text);)p||(p=new S(x.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),o.push(new Y(l+h.index,l+h.index+h[0].length,p))}}l=u}if(!r.validEnd){let a=r.fillBefore(x.empty,!0);t.replace(l,l,new S(a,0,0))}for(let a=o.length-1;a>=0;a--)t.step(o[a])}function Cd(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Ft(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,s=0,i=0;;--r){let o=t.$from.node(r),l=t.$from.index(r)+s,a=t.$to.indexAfter(r)-i;if(r<t.depth&&o.canReplace(l,a,n))return r;if(r==0||o.type.spec.isolating||!Cd(o,l,a))break;l&&(s=1),a<o.childCount&&(i=1)}return null}function vd(t,e,n){let{$from:r,$to:s,depth:i}=e,o=r.before(i+1),l=s.after(i+1),a=o,c=l,u=x.empty,d=0;for(let p=i,m=!1;p>n;p--)m||r.index(p)>0?(m=!0,u=x.from(r.node(p).copy(u)),d++):a--;let h=x.empty,f=0;for(let p=i,m=!1;p>n;p--)m||s.after(p+1)<s.end(p)?(m=!0,h=x.from(s.node(p).copy(h)),f++):c++;t.step(new Q(a,c,o,l,new S(u.append(h),d,f),u.size-d,!0))}function Ms(t,e,n=null,r=t){let s=Md(t,e),i=s&&Td(r,e);return i?s.map(gi).concat({type:e,attrs:n}).concat(i.map(gi)):null}function gi(t){return{type:t,attrs:null}}function Md(t,e){let{parent:n,startIndex:r,endIndex:s}=t,i=n.contentMatchAt(r).findWrapping(e);if(!i)return null;let o=i.length?i[0]:e;return n.canReplaceWith(r,s,o)?i:null}function Td(t,e){let{parent:n,startIndex:r,endIndex:s}=t,i=n.child(r),o=e.contentMatch.findWrapping(i.type);if(!o)return null;let a=(o.length?o[o.length-1]:e).contentMatch;for(let c=r;a&&c<s;c++)a=a.matchType(n.child(c).type);return!a||!a.validEnd?null:o}function Ed(t,e,n){let r=x.empty;for(let o=n.length-1;o>=0;o--){if(r.size){let l=n[o].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=x.from(n[o].type.create(n[o].attrs,r))}let s=e.start,i=e.end;t.step(new Q(s,i,s,i,new S(r,0,0),n.length,!0))}function Ad(t,e,n,r,s){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=t.steps.length;t.doc.nodesBetween(e,n,(o,l)=>{let a=typeof s=="function"?s(o):s;if(o.isTextblock&&!o.hasMarkup(r,a)&&Nd(t.doc,t.mapping.slice(i).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let f=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);f&&!p?c=!1:!f&&p&&(c=!0)}c===!1&&El(t,o,l,i),vs(t,t.mapping.slice(i).map(l,1),r,void 0,c===null);let u=t.mapping.slice(i),d=u.map(l,1),h=u.map(l+o.nodeSize,1);return t.step(new Q(d,h,d+1,h-1,new S(x.from(r.create(a,null,o.marks)),0,0),1,!0)),c===!0&&Tl(t,o,l,i),!1}})}function Tl(t,e,n,r){e.forEach((s,i)=>{if(s.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(s.text);){let a=t.mapping.slice(r).map(n+1+i+o.index);t.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function El(t,e,n,r){e.forEach((s,i)=>{if(s.type==s.type.schema.linebreakReplacement){let o=t.mapping.slice(r).map(n+1+i);t.replaceWith(o,o+1,e.type.schema.text(`
`))}})}function Nd(t,e,n){let r=t.resolve(e),s=r.index();return r.parent.canReplaceWith(s,s+1,n)}function Od(t,e,n,r,s){let i=t.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");n||(n=i.type);let o=n.create(r,null,s||i.marks);if(i.isLeaf)return t.replaceWith(e,e+i.nodeSize,o);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new Q(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new S(x.from(o),0,0),1,!0))}function je(t,e,n=1,r){let s=t.resolve(e),i=s.depth-n,o=r&&r[r.length-1]||s.parent;if(i<0||s.parent.type.spec.isolating||!s.parent.canReplace(s.index(),s.parent.childCount)||!o.type.validContent(s.parent.content.cutByIndex(s.index(),s.parent.childCount)))return!1;for(let c=s.depth-1,u=n-2;c>i;c--,u--){let d=s.node(c),h=s.index(c);if(d.type.spec.isolating)return!1;let f=d.content.cutByIndex(h,d.childCount),p=r&&r[u+1];p&&(f=f.replaceChild(0,p.type.create(p.attrs)));let m=r&&r[u]||d;if(!d.canReplace(h+1,d.childCount)||!m.type.validContent(f))return!1}let l=s.indexAfter(i),a=r&&r[0];return s.node(i).canReplaceWith(l,l,a?a.type:s.node(i+1).type)}function Id(t,e,n=1,r){let s=t.doc.resolve(e),i=x.empty,o=x.empty;for(let l=s.depth,a=s.depth-n,c=n-1;l>a;l--,c--){i=x.from(s.node(l).copy(i));let u=r&&r[c];o=x.from(u?u.type.create(u.attrs,o):s.node(l).copy(o))}t.step(new Y(e,e,new S(i.append(o),n,n),!0))}function st(t,e){let n=t.resolve(e),r=n.index();return Al(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function Dd(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let s=0;s<e.childCount;s++){let i=e.child(s),o=i.type==r?t.type.schema.nodes.text:i.type;if(n=n.matchType(o),!n||!t.type.allowsMarks(i.marks))return!1}return n.validEnd}function Al(t,e){return!!(t&&e&&!t.isLeaf&&Dd(t,e))}function sr(t,e,n=-1){let r=t.resolve(e);for(let s=r.depth;;s--){let i,o,l=r.index(s);if(s==r.depth?(i=r.nodeBefore,o=r.nodeAfter):n>0?(i=r.node(s+1),l++,o=r.node(s).maybeChild(l)):(i=r.node(s).maybeChild(l-1),o=r.node(s+1)),i&&!i.isTextblock&&Al(i,o)&&r.node(s).canReplace(l,l+1))return e;if(s==0)break;e=n<0?r.before(s):r.after(s)}}function Rd(t,e,n){let r=null,{linebreakReplacement:s}=t.doc.type.schema,i=t.doc.resolve(e-n),o=i.node().type;if(s&&o.inlineContent){let u=o.whitespace=="pre",d=!!o.contentMatch.matchType(s);u&&!d?r=!1:!u&&d&&(r=!0)}let l=t.steps.length;if(r===!1){let u=t.doc.resolve(e+n);El(t,u.node(),u.before(),l)}o.inlineContent&&vs(t,e+n-1,o,i.node().contentMatchAt(i.index()),r==null);let a=t.mapping.slice(l),c=a.map(e-n);if(t.step(new Y(c,a.map(e+n,-1),S.empty,!0)),r===!0){let u=t.doc.resolve(c);Tl(t,u.node(),u.before(),t.steps.length)}return t}function Ld(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let s=r.depth-1;s>=0;s--){let i=r.index(s);if(r.node(s).canReplaceWith(i,i,n))return r.before(s+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let s=r.depth-1;s>=0;s--){let i=r.indexAfter(s);if(r.node(s).canReplaceWith(i,i,n))return r.after(s+1);if(i<r.node(s).childCount)return null}return null}function Nl(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let s=n.content;for(let i=0;i<n.openStart;i++)s=s.firstChild.content;for(let i=1;i<=(n.openStart==0&&n.size?2:1);i++)for(let o=r.depth;o>=0;o--){let l=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,a=r.index(o)+(l>0?1:0),c=r.node(o),u=!1;if(i==1)u=c.canReplace(a,a,s);else{let d=c.contentMatchAt(a).findWrapping(s.firstChild.type);u=d&&c.canReplaceWith(a,a,d[0])}if(u)return l==0?r.pos:l<0?r.before(o+1):r.after(o+1)}return null}function ir(t,e,n=e,r=S.empty){if(e==n&&!r.size)return null;let s=t.resolve(e),i=t.resolve(n);return Ol(s,i,r)?new Y(e,n,r):new Pd(s,i,r).fit()}function Ol(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class Pd{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=x.empty;for(let s=0;s<=e.depth;s++){let i=e.node(s);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(s))})}for(let s=e.depth;s>0;s--)this.placed=x.from(e.node(s).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,s=this.close(e<0?this.$to:r.doc.resolve(e));if(!s)return null;let i=this.placed,o=r.depth,l=s.depth;for(;o&&l&&i.childCount==1;)i=i.firstChild.content,o--,l--;let a=new S(i,o,l);return e>-1?new Q(r.pos,e,this.$to.pos,this.$to.end(),a,n):a.size||r.pos!=this.$to.pos?new Y(r.pos,s.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,s=this.unplaced.openEnd;r<e;r++){let i=n.firstChild;if(n.childCount>1&&(s=0),i.type.spec.isolating&&s<=r){e=r;break}n=i.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let s,i=null;r?(i=Cr(this.unplaced.content,r-1).firstChild,s=i.content):s=this.unplaced.content;let o=s.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],u,d=null;if(n==1&&(o?c.matchType(o.type)||(d=c.fillBefore(x.from(o),!1)):i&&a.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:l,parent:i,inject:d};if(n==2&&o&&(u=c.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:l,parent:i,wrap:u};if(i&&c.matchType(i.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,s=Cr(e,n);return!s.childCount||s.firstChild.isLeaf?!1:(this.unplaced=new S(e,n+1,Math.max(r,s.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,s=Cr(e,n);if(s.childCount<=1&&n>0){let i=e.size-n<=n+s.size;this.unplaced=new S(qt(e,n-1,1),n-1,i?n-1:r)}else this.unplaced=new S(qt(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:s,wrap:i}){for(;this.depth>n;)this.closeFrontierNode();if(i)for(let m=0;m<i.length;m++)this.openFrontierNode(i[m]);let o=this.unplaced,l=r?r.content:o.content,a=o.openStart-e,c=0,u=[],{match:d,type:h}=this.frontier[n];if(s){for(let m=0;m<s.childCount;m++)u.push(s.child(m));d=d.matchFragment(s)}let f=l.size+e-(o.content.size-o.openEnd);for(;c<l.childCount;){let m=l.child(c),g=d.matchType(m.type);if(!g)break;c++,(c>1||a==0||m.content.size)&&(d=g,u.push(Il(m.mark(h.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?f:-1)))}let p=c==l.childCount;p||(f=-1),this.placed=Kt(this.placed,n,x.from(u)),this.frontier[n].match=d,p&&f<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=l;m<f;m++){let b=g.lastChild;this.frontier.push({type:b.type,match:b.contentMatchAt(b.childCount)}),g=b.content}this.unplaced=p?e==0?S.empty:new S(qt(o.content,e-1,1),e-1,f<0?o.openEnd:e-1):new S(qt(o.content,e,c),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!vr(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:r}=this.$to,s=this.$to.after(r);for(;r>1&&s==this.$to.end(--r);)++s;return s}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:s}=this.frontier[n],i=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),o=vr(e,n,s,r,i);if(o){for(let l=n-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=vr(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:n,fit:o,move:i?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=Kt(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let s=e.node(r),i=s.type.contentMatch.fillBefore(s.content,!0,e.index(r));this.openFrontierNode(s.type,s.attrs,i)}return e}openFrontierNode(e,n=null,r){let s=this.frontier[this.depth];s.match=s.match.matchType(e),this.placed=Kt(this.placed,this.depth,x.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(x.empty,!0);n.childCount&&(this.placed=Kt(this.placed,this.frontier.length,n))}}function qt(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(qt(t.firstChild.content,e-1,n)))}function Kt(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Kt(t.lastChild.content,e-1,n)))}function Cr(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function Il(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,Il(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(x.empty,!0)))),t.copy(r)}function vr(t,e,n,r,s){let i=t.node(e),o=s?t.indexAfter(e):t.index(e);if(o==i.childCount&&!n.compatibleContent(i.type))return null;let l=r.fillBefore(i.content,!0,o);return l&&!zd(n,i.content,o)?l:null}function zd(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function Bd(t){return t.spec.defining||t.spec.definingForContent}function jd(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let s=t.doc.resolve(e),i=t.doc.resolve(n);if(Ol(s,i,r))return t.step(new Y(e,n,r));let o=Rl(s,i);o[o.length-1]==0&&o.pop();let l=-(s.depth+1);o.unshift(l);for(let h=s.depth,f=s.pos-1;h>0;h--,f--){let p=s.node(h).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;o.indexOf(h)>-1?l=h:s.before(h)==f&&o.splice(1,0,-h)}let a=o.indexOf(l),c=[],u=r.openStart;for(let h=r.content,f=0;;f++){let p=h.firstChild;if(c.push(p),f==r.openStart)break;h=p.content}for(let h=u-1;h>=0;h--){let f=c[h],p=Bd(f.type);if(p&&!f.sameMarkup(s.node(Math.abs(l)-1)))u=h;else if(p||!f.type.isTextblock)break}for(let h=r.openStart;h>=0;h--){let f=(h+u+1)%(r.openStart+1),p=c[f];if(p)for(let m=0;m<o.length;m++){let g=o[(m+a)%o.length],b=!0;g<0&&(b=!1,g=-g);let k=s.node(g-1),w=s.index(g-1);if(k.canReplaceWith(w,w,p.type,p.marks))return t.replace(s.before(g),b?i.after(g):n,new S(Dl(r.content,0,r.openStart,f),f,r.openEnd))}}let d=t.steps.length;for(let h=o.length-1;h>=0&&(t.replace(e,n,r),!(t.steps.length>d));h--){let f=o[h];f<0||(e=s.before(f),n=i.after(f))}}function Dl(t,e,n,r,s){if(e<n){let i=t.firstChild;t=t.replaceChild(0,i.copy(Dl(i.content,e+1,n,r,i)))}if(e>r){let i=s.contentMatchAt(0),o=i.fillBefore(t).append(t);t=o.append(i.matchFragment(o).fillBefore(x.empty,!0))}return t}function $d(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let s=Ld(t.doc,e,r.type);s!=null&&(e=n=s)}t.replaceRange(e,n,new S(x.from(r),0,0))}function Fd(t,e,n){let r=t.doc.resolve(e),s=t.doc.resolve(n),i=Rl(r,s);for(let o=0;o<i.length;o++){let l=i[o],a=o==i.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return t.delete(r.start(l),s.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),s.indexAfter(l-1))))return t.delete(r.before(l),s.after(l))}for(let o=1;o<=r.depth&&o<=s.depth;o++)if(e-r.start(o)==r.depth-o&&n>r.end(o)&&s.end(o)-n!=s.depth-o&&r.start(o-1)==s.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),s.index(o-1)))return t.delete(r.before(o),n);t.delete(e,n)}function Rl(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let s=r;s>=0;s--){let i=t.start(s);if(i<t.pos-(t.depth-s)||e.end(s)>e.pos+(e.depth-s)||t.node(s).type.spec.isolating||e.node(s).type.spec.isolating)break;(i==e.start(s)||s==t.depth&&s==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&s&&e.start(s-1)==i-1)&&n.push(s)}return n}class It extends ae{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return K.fail("No node at attribute step's position");let r=Object.create(null);for(let i in n.attrs)r[i]=n.attrs[i];r[this.attr]=this.value;let s=n.type.create(r,null,n.marks);return K.fromReplace(e,this.pos,this.pos+1,new S(x.from(s),0,n.isLeaf?0:1))}getMap(){return fe.empty}invert(e){return new It(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new It(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new It(n.pos,n.attr,n.value)}}ae.jsonID("attr",It);class nn extends ae{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let s in e.attrs)n[s]=e.attrs[s];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return K.ok(r)}getMap(){return fe.empty}invert(e){return new nn(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new nn(n.attr,n.value)}}ae.jsonID("docAttr",nn);let Rt=class extends Error{};Rt=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Rt.prototype=Object.create(Error.prototype);Rt.prototype.constructor=Rt;Rt.prototype.name="TransformError";class Ts{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new tn}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new Rt(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=S.empty){let s=ir(this.doc,e,n,r);return s&&this.step(s),this}replaceWith(e,n,r){return this.replace(e,n,new S(x.from(r),0,0))}delete(e,n){return this.replace(e,n,S.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return jd(this,e,n,r),this}replaceRangeWith(e,n,r){return $d(this,e,n,r),this}deleteRange(e,n){return Fd(this,e,n),this}lift(e,n){return vd(this,e,n),this}join(e,n=1){return Rd(this,e,n),this}wrap(e,n){return Ed(this,e,n),this}setBlockType(e,n=e,r,s=null){return Ad(this,e,n,r,s),this}setNodeMarkup(e,n,r=null,s){return Od(this,e,n,r,s),this}setNodeAttribute(e,n,r){return this.step(new It(e,n,r)),this}setDocAttribute(e,n){return this.step(new nn(e,n)),this}addNodeMark(e,n){return this.step(new Je(e,n)),this}removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n instanceof F)n.isInSet(r.marks)&&this.step(new bt(e,n));else{let s=r.marks,i,o=[];for(;i=n.isInSet(s);)o.push(new bt(e,i)),s=i.removeFromSet(s);for(let l=o.length-1;l>=0;l--)this.step(o[l])}return this}split(e,n=1,r){return Id(this,e,n,r),this}addMark(e,n,r){return wd(this,e,n,r),this}removeMark(e,n,r){return Sd(this,e,n,r),this}clearIncompatible(e,n,r){return vs(this,e,n,r),this}}const Mr=Object.create(null);class N{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new Ll(e.min(n),e.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let n=0;n<e.length;n++)if(e[n].$from.pos!=e[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,n=S.empty){let r=n.content.lastChild,s=null;for(let l=0;l<n.openEnd;l++)s=r,r=r.lastChild;let i=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:a,$to:c}=o[l],u=e.mapping.slice(i);e.replaceRange(u.map(a.pos),u.map(c.pos),l?S.empty:n),l==0&&xi(e,i,(r?r.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,s=this.ranges;for(let i=0;i<s.length;i++){let{$from:o,$to:l}=s[i],a=e.mapping.slice(r),c=a.map(o.pos),u=a.map(l.pos);i?e.deleteRange(c,u):(e.replaceRangeWith(c,u,n),xi(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let s=e.parent.inlineContent?new E(e):At(e.node(0),e.parent,e.pos,e.index(),n,r);if(s)return s;for(let i=e.depth-1;i>=0;i--){let o=n<0?At(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):At(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,n,r);if(o)return o}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new de(e.node(0))}static atStart(e){return At(e,e,0,0,1)||new de(e)}static atEnd(e){return At(e,e,e.content.size,e.childCount,-1)||new de(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Mr[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Mr)throw new RangeError("Duplicate use of selection JSON ID "+e);return Mr[e]=n,n.prototype.jsonID=e,n}getBookmark(){return E.between(this.$anchor,this.$head).getBookmark()}}N.prototype.visible=!0;class Ll{constructor(e,n){this.$from=e,this.$to=n}}let yi=!1;function bi(t){!yi&&!t.parent.inlineContent&&(yi=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class E extends N{constructor(e,n=e){bi(e),bi(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return N.near(r);let s=e.resolve(n.map(this.anchor));return new E(s.parent.inlineContent?s:r,r)}replace(e,n=S.empty){if(super.replace(e,n),n==S.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof E&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new or(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new E(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let s=e.resolve(n);return new this(s,r==n?s:e.resolve(r))}static between(e,n,r){let s=e.pos-n.pos;if((!r||s)&&(r=s>=0?1:-1),!n.parent.inlineContent){let i=N.findFrom(n,r,!0)||N.findFrom(n,-r,!0);if(i)n=i.$head;else return N.near(n,r)}return e.parent.inlineContent||(s==0?e=n:(e=(N.findFrom(e,-r,!0)||N.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=s<0&&(e=n))),new E(e,n)}}N.jsonID("text",E);class or{constructor(e,n){this.anchor=e,this.head=n}map(e){return new or(e.map(this.anchor),e.map(this.head))}resolve(e){return E.between(e.resolve(this.anchor),e.resolve(this.head))}}class A extends N{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:s}=n.mapResult(this.anchor),i=e.resolve(s);return r?N.near(i):new A(i)}content(){return new S(x.from(this.node),0,0)}eq(e){return e instanceof A&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Es(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new A(e.resolve(n.anchor))}static create(e,n){return new A(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}A.prototype.visible=!1;N.jsonID("node",A);class Es{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new or(r,r):new Es(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&A.isSelectable(r)?new A(n):N.near(n)}}class de extends N{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=S.empty){if(n==S.empty){e.delete(0,e.doc.content.size);let r=N.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new de(e)}map(e){return new de(e)}eq(e){return e instanceof de}getBookmark(){return Hd}}N.jsonID("all",de);const Hd={map(){return this},resolve(t){return new de(t)}};function At(t,e,n,r,s,i=!1){if(e.inlineContent)return E.create(t,n);for(let o=r-(s>0?0:1);s>0?o<e.childCount:o>=0;o+=s){let l=e.child(o);if(l.isAtom){if(!i&&A.isSelectable(l))return A.create(t,n-(s<0?l.nodeSize:0))}else{let a=At(t,l,n+s,s<0?l.childCount:0,s,i);if(a)return a}n+=l.nodeSize*s}return null}function xi(t,e,n){let r=t.steps.length-1;if(r<e)return;let s=t.steps[r];if(!(s instanceof Y||s instanceof Q))return;let i=t.mapping.maps[r],o;i.forEach((l,a,c,u)=>{o==null&&(o=u)}),t.setSelection(N.near(t.doc.resolve(o),n))}const ki=1,bn=2,wi=4;class Vd extends Ts{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|ki)&~bn,this.storedMarks=null,this}get selectionSet(){return(this.updated&ki)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=bn,this}ensureMarks(e){return F.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&bn)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~bn,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||F.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let s=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(s.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let i=this.storedMarks;if(!i){let o=this.doc.resolve(n);i=r==n?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,s.text(e,i)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(N.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=wi,this}get scrolledIntoView(){return(this.updated&wi)>0}}function Si(t,e){return!e||!t?t:t.bind(e)}class Ut{constructor(e,n,r){this.name=e,this.init=Si(n.init,r),this.apply=Si(n.apply,r)}}const _d=[new Ut("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Ut("selection",{init(t,e){return t.selection||N.atStart(e.doc)},apply(t){return t.selection}}),new Ut("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Ut("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class Tr{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=_d.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Ut(r.key,r.spec.state,r))})}}class Ot{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=n){let s=this.config.plugins[r];if(s.spec.filterTransaction&&!s.spec.filterTransaction.call(s,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),s=null;for(;;){let i=!1;for(let o=0;o<this.config.plugins.length;o++){let l=this.config.plugins[o];if(l.spec.appendTransaction){let a=s?s[o].n:0,c=s?s[o].state:this,u=a<n.length&&l.spec.appendTransaction.call(l,a?n.slice(a):n,c,r);if(u&&r.filterTransaction(u,o)){if(u.setMeta("appendedTransaction",e),!s){s=[];for(let d=0;d<this.config.plugins.length;d++)s.push(d<o?{state:r,n:n.length}:{state:this,n:0})}n.push(u),r=r.applyInner(u),i=!0}s&&(s[o]={state:r,n:n.length})}}if(!i)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new Ot(this.config),r=this.config.fields;for(let s=0;s<r.length;s++){let i=r[s];n[i.name]=i.apply(e,this[i.name],this,n)}return n}get tr(){return new Vd(this)}static create(e){let n=new Tr(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Ot(n);for(let s=0;s<n.fields.length;s++)r[n.fields[s].name]=n.fields[s].init(e,r);return r}reconfigure(e){let n=new Tr(this.schema,e.plugins),r=n.fields,s=new Ot(n);for(let i=0;i<r.length;i++){let o=r[i].name;s[o]=this.hasOwnProperty(o)?this[o]:r[i].init(e,s)}return s}toJSON(e){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let s=e[r],i=s.spec.state;i&&i.toJSON&&(n[r]=i.toJSON.call(s,this[s.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let s=new Tr(e.schema,e.plugins),i=new Ot(s);return s.fields.forEach(o=>{if(o.name=="doc")i.doc=ve.fromJSON(e.schema,n.doc);else if(o.name=="selection")i.selection=N.fromJSON(i.doc,n.selection);else if(o.name=="storedMarks")n.storedMarks&&(i.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==o.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){i[o.name]=c.fromJSON.call(a,e,n[l],i);return}}i[o.name]=o.init(e,i)}}),i}}function Pl(t,e,n){for(let r in t){let s=t[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=Pl(s,e,{})),n[r]=s}return n}class H{constructor(e){this.spec=e,this.props={},e.props&&Pl(e.props,this,this.props),this.key=e.key?e.key.key:zl("plugin")}getState(e){return e[this.key]}}const Er=Object.create(null);function zl(t){return t in Er?t+"$"+ ++Er[t]:(Er[t]=0,t+"$")}class _{constructor(e="key"){this.key=zl(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const As=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function Bl(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const jl=(t,e,n)=>{let r=Bl(t,n);if(!r)return!1;let s=Ns(r);if(!s){let o=r.blockRange(),l=o&&Ft(o);return l==null?!1:(e&&e(t.tr.lift(o,l).scrollIntoView()),!0)}let i=s.nodeBefore;if(Ul(t,s,e,-1))return!0;if(r.parent.content.size==0&&(Lt(i,"end")||A.isSelectable(i)))for(let o=r.depth;;o--){let l=ir(t.doc,r.before(o),r.after(o),S.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=t.tr.step(l);a.setSelection(Lt(i,"end")?N.findFrom(a.doc.resolve(a.mapping.map(s.pos,-1)),-1):A.create(a.doc,s.pos-i.nodeSize)),e(a.scrollIntoView())}return!0}if(o==1||r.node(o-1).childCount>1)break}return i.isAtom&&s.depth==r.depth-1?(e&&e(t.tr.delete(s.pos-i.nodeSize,s.pos).scrollIntoView()),!0):!1},Wd=(t,e,n)=>{let r=Bl(t,n);if(!r)return!1;let s=Ns(r);return s?$l(t,s,e):!1},qd=(t,e,n)=>{let r=Hl(t,n);if(!r)return!1;let s=Os(r);return s?$l(t,s,e):!1};function $l(t,e,n){let r=e.nodeBefore,s=r,i=e.pos-1;for(;!s.isTextblock;i--){if(s.type.spec.isolating)return!1;let u=s.lastChild;if(!u)return!1;s=u}let o=e.nodeAfter,l=o,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let u=l.firstChild;if(!u)return!1;l=u}let c=ir(t.doc,i,a,S.empty);if(!c||c.from!=i||c instanceof Y&&c.slice.size>=a-i)return!1;if(n){let u=t.tr.step(c);u.setSelection(E.create(u.doc,i)),n(u.scrollIntoView())}return!0}function Lt(t,e,n=!1){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}const Fl=(t,e,n)=>{let{$head:r,empty:s}=t.selection,i=r;if(!s)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;i=Ns(r)}let o=i&&i.nodeBefore;return!o||!A.isSelectable(o)?!1:(e&&e(t.tr.setSelection(A.create(t.doc,i.pos-o.nodeSize)).scrollIntoView()),!0)};function Ns(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 Hl(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const Vl=(t,e,n)=>{let r=Hl(t,n);if(!r)return!1;let s=Os(r);if(!s)return!1;let i=s.nodeAfter;if(Ul(t,s,e,1))return!0;if(r.parent.content.size==0&&(Lt(i,"start")||A.isSelectable(i))){let o=ir(t.doc,r.before(),r.after(),S.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=t.tr.step(o);l.setSelection(Lt(i,"start")?N.findFrom(l.doc.resolve(l.mapping.map(s.pos)),1):A.create(l.doc,l.mapping.map(s.pos))),e(l.scrollIntoView())}return!0}}return i.isAtom&&s.depth==r.depth-1?(e&&e(t.tr.delete(s.pos,s.pos+i.nodeSize).scrollIntoView()),!0):!1},_l=(t,e,n)=>{let{$head:r,empty:s}=t.selection,i=r;if(!s)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;i=Os(r)}let o=i&&i.nodeAfter;return!o||!A.isSelectable(o)?!1:(e&&e(t.tr.setSelection(A.create(t.doc,i.pos)).scrollIntoView()),!0)};function Os(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 Kd=(t,e)=>{let n=t.selection,r=n instanceof A,s;if(r){if(n.node.isTextblock||!st(t.doc,n.from))return!1;s=n.from}else if(s=sr(t.doc,n.from,-1),s==null)return!1;if(e){let i=t.tr.join(s);r&&i.setSelection(A.create(i.doc,s-t.doc.resolve(s).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},Ud=(t,e)=>{let n=t.selection,r;if(n instanceof A){if(n.node.isTextblock||!st(t.doc,n.to))return!1;r=n.to}else if(r=sr(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},Jd=(t,e)=>{let{$from:n,$to:r}=t.selection,s=n.blockRange(r),i=s&&Ft(s);return i==null?!1:(e&&e(t.tr.lift(s,i).scrollIntoView()),!0)},Wl=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
`).scrollIntoView()),!0)};function Is(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 Gd=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let s=n.node(-1),i=n.indexAfter(-1),o=Is(s.contentMatchAt(i));if(!o||!s.canReplaceWith(i,i,o))return!1;if(e){let l=n.after(),a=t.tr.replaceWith(l,l,o.createAndFill());a.setSelection(N.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},ql=(t,e)=>{let n=t.selection,{$from:r,$to:s}=n;if(n instanceof de||r.parent.inlineContent||s.parent.inlineContent)return!1;let i=Is(s.parent.contentMatchAt(s.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let o=(!r.parentOffset&&s.index()<s.parent.childCount?r:s).pos,l=t.tr.insert(o,i.createAndFill());l.setSelection(E.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},Kl=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let i=n.before();if(je(t.doc,i))return e&&e(t.tr.split(i).scrollIntoView()),!0}let r=n.blockRange(),s=r&&Ft(r);return s==null?!1:(e&&e(t.tr.lift(r,s).scrollIntoView()),!0)};function Xd(t){return(e,n)=>{let{$from:r,$to:s}=e.selection;if(e.selection instanceof A&&e.selection.node.isBlock)return!r.parentOffset||!je(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let i=[],o,l,a=!1,c=!1;for(let f=r.depth;;f--)if(r.node(f).isBlock){a=r.end(f)==r.pos+(r.depth-f),c=r.start(f)==r.pos-(r.depth-f),l=Is(r.node(f-1).contentMatchAt(r.indexAfter(f-1))),i.unshift(a&&l?{type:l}:null),o=f;break}else{if(f==1)return!1;i.unshift(null)}let u=e.tr;(e.selection instanceof E||e.selection instanceof de)&&u.deleteSelection();let d=u.mapping.map(r.pos),h=je(u.doc,d,i.length,i);if(h||(i[0]=l?{type:l}:null,h=je(u.doc,d,i.length,i)),!h)return!1;if(u.split(d,i.length,i),!a&&c&&r.node(o).type!=l){let f=u.mapping.map(r.before(o)),p=u.doc.resolve(f);l&&r.node(o-1).canReplaceWith(p.index(),p.index()+1,l)&&u.setNodeMarkup(u.mapping.map(r.before(o)),l)}return n&&n(u.scrollIntoView()),!0}}const Yd=Xd(),Zd=(t,e)=>{let{$from:n,to:r}=t.selection,s,i=n.sharedDepth(r);return i==0?!1:(s=n.before(i),e&&e(t.tr.setSelection(A.create(t.doc,s))),!0)};function Qd(t,e,n){let r=e.nodeBefore,s=e.nodeAfter,i=e.index();return!r||!s||!r.type.compatibleContent(s.type)?!1:!r.content.size&&e.parent.canReplace(i-1,i)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(s.isTextblock||st(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function Ul(t,e,n,r){let s=e.nodeBefore,i=e.nodeAfter,o,l,a=s.type.spec.isolating||i.type.spec.isolating;if(!a&&Qd(t,e,n))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(o=(l=s.contentMatchAt(s.childCount)).findWrapping(i.type))&&l.matchType(o[0]||i.type).validEnd){if(n){let f=e.pos+i.nodeSize,p=x.empty;for(let b=o.length-1;b>=0;b--)p=x.from(o[b].create(null,p));p=x.from(s.copy(p));let m=t.tr.step(new Q(e.pos-1,f,e.pos,f,new S(p,1,0),o.length,!0)),g=m.doc.resolve(f+2*o.length);g.nodeAfter&&g.nodeAfter.type==s.type&&st(m.doc,g.pos)&&m.join(g.pos),n(m.scrollIntoView())}return!0}let u=i.type.spec.isolating||r>0&&a?null:N.findFrom(e,1),d=u&&u.$from.blockRange(u.$to),h=d&&Ft(d);if(h!=null&&h>=e.depth)return n&&n(t.tr.lift(d,h).scrollIntoView()),!0;if(c&&Lt(i,"start",!0)&&Lt(s,"end")){let f=s,p=[];for(;p.push(f),!f.isTextblock;)f=f.lastChild;let m=i,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(f.canReplace(f.childCount,f.childCount,m.content)){if(n){let b=x.empty;for(let w=p.length-1;w>=0;w--)b=x.from(p[w].copy(b));let k=t.tr.step(new Q(e.pos-p.length,e.pos+i.nodeSize,e.pos+g,e.pos+i.nodeSize-g,new S(b,p.length,0),0,!0));n(k.scrollIntoView())}return!0}}return!1}function Jl(t){return function(e,n){let r=e.selection,s=t<0?r.$from:r.$to,i=s.depth;for(;s.node(i).isInline;){if(!i)return!1;i--}return s.node(i).isTextblock?(n&&n(e.tr.setSelection(E.create(e.doc,t<0?s.start(i):s.end(i)))),!0):!1}}const eh=Jl(-1),th=Jl(1);function nh(t,e=null){return function(n,r){let{$from:s,$to:i}=n.selection,o=s.blockRange(i),l=o&&Ms(o,t,e);return l?(r&&r(n.tr.wrap(o,l).scrollIntoView()),!0):!1}}function Ci(t,e=null){return function(n,r){let s=!1;for(let i=0;i<n.selection.ranges.length&&!s;i++){let{$from:{pos:o},$to:{pos:l}}=n.selection.ranges[i];n.doc.nodesBetween(o,l,(a,c)=>{if(s)return!1;if(!(!a.isTextblock||a.hasMarkup(t,e)))if(a.type==t)s=!0;else{let u=n.doc.resolve(c),d=u.index();s=u.parent.canReplaceWith(d,d+1,t)}})}if(!s)return!1;if(r){let i=n.tr;for(let o=0;o<n.selection.ranges.length;o++){let{$from:{pos:l},$to:{pos:a}}=n.selection.ranges[o];i.setBlockType(l,a,t,e)}r(i.scrollIntoView())}return!0}}function Ds(...t){return function(e,n,r){for(let s=0;s<t.length;s++)if(t[s](e,n,r))return!0;return!1}}Ds(As,jl,Fl);Ds(As,Vl,_l);Ds(Wl,ql,Kl,Yd);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function rh(t,e=null){return function(n,r){let{$from:s,$to:i}=n.selection,o=s.blockRange(i);if(!o)return!1;let l=r?n.tr:null;return sh(l,o,t,e)?(r&&r(l.scrollIntoView()),!0):!1}}function sh(t,e,n,r=null){let s=!1,i=e,o=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=o.resolve(e.start-2);i=new Fn(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new Fn(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),s=!0}let l=Ms(i,n,r,e);return l?(t&&ih(t,e,l,s,n),!0):!1}function ih(t,e,n,r,s){let i=x.empty;for(let u=n.length-1;u>=0;u--)i=x.from(n[u].type.create(n[u].attrs,i));t.step(new Q(e.start-(r?2:0),e.end,e.start,e.end,new S(i,0,0),n.length,!0));let o=0;for(let u=0;u<n.length;u++)n[u].type==s&&(o=u+1);let l=n.length-o,a=e.start+n.length-(r?2:0),c=e.parent;for(let u=e.startIndex,d=e.endIndex,h=!0;u<d;u++,h=!1)!h&&je(t.doc,a,l)&&(t.split(a,l),a+=2*l),a+=c.child(u).nodeSize;return t}function oh(t){return function(e,n){let{$from:r,$to:s}=e.selection,i=r.blockRange(s,o=>o.childCount>0&&o.firstChild.type==t);return i?n?r.node(i.depth-1).type==t?lh(e,n,t,i):ah(e,n,i):!0:!1}}function lh(t,e,n,r){let s=t.tr,i=r.end,o=r.$to.end(r.depth);i<o&&(s.step(new Q(i-1,o,i,o,new S(x.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new Fn(s.doc.resolve(r.$from.pos),s.doc.resolve(o),r.depth));const l=Ft(r);if(l==null)return!1;s.lift(r,l);let a=s.doc.resolve(s.mapping.map(i,-1)-1);return st(s.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&s.join(a.pos),e(s.scrollIntoView()),!0}function ah(t,e,n){let r=t.tr,s=n.parent;for(let f=n.end,p=n.endIndex-1,m=n.startIndex;p>m;p--)f-=s.child(p).nodeSize,r.delete(f-1,f+1);let i=r.doc.resolve(n.start),o=i.nodeAfter;if(r.mapping.map(n.end)!=n.start+i.nodeAfter.nodeSize)return!1;let l=n.startIndex==0,a=n.endIndex==s.childCount,c=i.node(-1),u=i.index(-1);if(!c.canReplace(u+(l?0:1),u+1,o.content.append(a?x.empty:x.from(s))))return!1;let d=i.pos,h=d+o.nodeSize;return r.step(new Q(d-(l?1:0),h+(a?1:0),d+1,h-1,new S((l?x.empty:x.from(s.copy(x.empty))).append(a?x.empty:x.from(s.copy(x.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function ch(t){return function(e,n){let{$from:r,$to:s}=e.selection,i=r.blockRange(s,c=>c.childCount>0&&c.firstChild.type==t);if(!i)return!1;let o=i.startIndex;if(o==0)return!1;let l=i.parent,a=l.child(o-1);if(a.type!=t)return!1;if(n){let c=a.lastChild&&a.lastChild.type==l.type,u=x.from(c?t.create():null),d=new S(x.from(t.create(null,x.from(l.type.create(null,u)))),c?3:1,0),h=i.start,f=i.end;n(e.tr.step(new Q(h-(c?3:1),f,h,f,d,1,!0)).scrollIntoView())}return!0}}const re=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Pt=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let Kr=null;const ze=function(t,e,n){let r=Kr||(Kr=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},uh=function(){Kr=null},xt=function(t,e,n,r){return n&&(vi(t,e,n,r,-1)||vi(t,e,n,r,1))},dh=/^(img|br|input|textarea|hr)$/i;function vi(t,e,n,r,s){for(var i;;){if(t==n&&e==r)return!0;if(e==(s<0?0:be(t))){let o=t.parentNode;if(!o||o.nodeType!=1||cn(t)||dh.test(t.nodeName)||t.contentEditable=="false")return!1;e=re(t)+(s<0?0:1),t=o}else if(t.nodeType==1){let o=t.childNodes[e+(s<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((i=o.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)e+=s;else return!1;else t=o,e=s<0?be(t):0}else return!1}}function be(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function hh(t,e){for(;;){if(t.nodeType==3&&e)return t;if(t.nodeType==1&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=be(t)}else if(t.parentNode&&!cn(t))e=re(t),t=t.parentNode;else return null}}function fh(t,e){for(;;){if(t.nodeType==3&&e<t.nodeValue.length)return t;if(t.nodeType==1&&e<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[e],e=0}else if(t.parentNode&&!cn(t))e=re(t)+1,t=t.parentNode;else return null}}function ph(t,e,n){for(let r=e==0,s=e==be(t);r||s;){if(t==n)return!0;let i=re(t);if(t=t.parentNode,!t)return!1;r=r&&i==0,s=s&&i==be(t)}}function cn(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 lr=function(t){return t.focusNode&&xt(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function at(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function mh(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function gh(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(be(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(be(r.startContainer),r.startOffset)}}}const Ae=typeof navigator<"u"?navigator:null,Mi=typeof document<"u"?document:null,it=Ae&&Ae.userAgent||"",Ur=/Edge\/(\d+)/.exec(it),Gl=/MSIE \d/.exec(it),Jr=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(it),he=!!(Gl||Jr||Ur),Ye=Gl?document.documentMode:Jr?+Jr[1]:Ur?+Ur[1]:0,xe=!he&&/gecko\/(\d+)/i.test(it);xe&&+(/Firefox\/(\d+)/.exec(it)||[0,0])[1];const Gr=!he&&/Chrome\/(\d+)/.exec(it),Z=!!Gr,Xl=Gr?+Gr[1]:0,oe=!he&&!!Ae&&/Apple Computer/.test(Ae.vendor),zt=oe&&(/Mobile\/\w+/.test(it)||!!Ae&&Ae.maxTouchPoints>2),ye=zt||(Ae?/Mac/.test(Ae.platform):!1),Yl=Ae?/Win/.test(Ae.platform):!1,Be=/Android \d/.test(it),un=!!Mi&&"webkitFontSmoothing"in Mi.documentElement.style,yh=un?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function bh(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 Le(t,e){return typeof t=="number"?t:t[e]}function xh(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function Ti(t,e,n){let r=t.someProp("scrollThreshold")||0,s=t.someProp("scrollMargin")||5,i=t.dom.ownerDocument;for(let o=n||t.dom;o;){if(o.nodeType!=1){o=Pt(o);continue}let l=o,a=l==i.body,c=a?bh(i):xh(l),u=0,d=0;if(e.top<c.top+Le(r,"top")?d=-(c.top-e.top+Le(s,"top")):e.bottom>c.bottom-Le(r,"bottom")&&(d=e.bottom-e.top>c.bottom-c.top?e.top+Le(s,"top")-c.top:e.bottom-c.bottom+Le(s,"bottom")),e.left<c.left+Le(r,"left")?u=-(c.left-e.left+Le(s,"left")):e.right>c.right-Le(r,"right")&&(u=e.right-c.right+Le(s,"right")),u||d)if(a)i.defaultView.scrollBy(u,d);else{let f=l.scrollLeft,p=l.scrollTop;d&&(l.scrollTop+=d),u&&(l.scrollLeft+=u);let m=l.scrollLeft-f,g=l.scrollTop-p;e={left:e.left-m,top:e.top-g,right:e.right-m,bottom:e.bottom-g}}let h=a?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(h))break;o=h=="absolute"?o.offsetParent:Pt(o)}}function kh(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,s;for(let i=(e.left+e.right)/2,o=n+1;o<Math.min(innerHeight,e.bottom);o+=5){let l=t.root.elementFromPoint(i,o);if(!l||l==t.dom||!t.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=n-20){r=l,s=a.top;break}}return{refDOM:r,refTop:s,stack:Zl(t.dom)}}function Zl(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=Pt(r));return e}function wh({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;Ql(n,r==0?0:r-e)}function Ql(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:s,left:i}=t[n];r.scrollTop!=s+e&&(r.scrollTop=s+e),r.scrollLeft!=i&&(r.scrollLeft=i)}}let Tt=null;function Sh(t){if(t.setActive)return t.setActive();if(Tt)return t.focus(Tt);let e=Zl(t);t.focus(Tt==null?{get preventScroll(){return Tt={preventScroll:!0},!0}}:void 0),Tt||(Tt=!1,Ql(e,0))}function ea(t,e){let n,r=2e8,s,i=0,o=e.top,l=e.top,a,c;for(let u=t.firstChild,d=0;u;u=u.nextSibling,d++){let h;if(u.nodeType==1)h=u.getClientRects();else if(u.nodeType==3)h=ze(u).getClientRects();else continue;for(let f=0;f<h.length;f++){let p=h[f];if(p.top<=o&&p.bottom>=l){o=Math.max(p.bottom,o),l=Math.min(p.top,l);let m=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(m<r){n=u,r=m,s=m&&n.nodeType==3?{left:p.right<e.left?p.right:p.left,top:e.top}:e,u.nodeType==1&&m&&(i=d+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=u,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!n&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(i=d+1)}}return!n&&a&&(n=a,s=c,r=0),n&&n.nodeType==3?Ch(n,s):!n||r&&n.nodeType==1?{node:t,offset:i}:ea(n,s)}function Ch(t,e){let n=t.nodeValue.length,r=document.createRange(),s;for(let i=0;i<n;i++){r.setEnd(t,i+1),r.setStart(t,i);let o=Ve(r,1);if(o.top!=o.bottom&&Rs(e,o)){s={node:t,offset:i+(e.left>=(o.left+o.right)/2?1:0)};break}}return r.detach(),s||{node:t,offset:0}}function Rs(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function vh(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function Mh(t,e,n){let{node:r,offset:s}=ea(e,n),i=-1;if(r.nodeType==1&&!r.firstChild){let o=r.getBoundingClientRect();i=o.left!=o.right&&n.left>(o.left+o.right)/2?1:-1}return t.docView.posFromDOM(r,s,i)}function Th(t,e,n,r){let s=-1;for(let i=e,o=!1;i!=t.dom;){let l=t.docView.nearestDesc(i,!0),a;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!o&&a.left>r.left||a.top>r.top?s=l.posBefore:(!o&&a.right<r.left||a.bottom<r.top)&&(s=l.posAfter),o=!0),!l.contentDOM&&s<0&&!l.node.isText))return(l.node.isBlock?r.top<(a.top+a.bottom)/2:r.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;i=l.dom.parentNode}return s>-1?s:t.docView.posFromDOM(e,n,-1)}function ta(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let s=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),i=s;;){let o=t.childNodes[i];if(o.nodeType==1){let l=o.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(Rs(e,c))return ta(o,e,c)}}if((i=(i+1)%r)==s)break}return t}function Eh(t,e){let n=t.dom.ownerDocument,r,s=0,i=gh(n,e.left,e.top);i&&({node:r,offset:s}=i);let o=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),l;if(!o||!t.dom.contains(o.nodeType!=1?o.parentNode:o)){let c=t.dom.getBoundingClientRect();if(!Rs(e,c)||(o=ta(t.dom,e,c),!o))return null}if(oe)for(let c=o;r&&c;c=Pt(c))c.draggable&&(r=void 0);if(o=vh(o,e),r){if(xe&&r.nodeType==1&&(s=Math.min(s,r.childNodes.length),s<r.childNodes.length)){let u=r.childNodes[s],d;u.nodeName=="IMG"&&(d=u.getBoundingClientRect()).right<=e.left&&d.bottom>e.top&&s++}let c;un&&s&&r.nodeType==1&&(c=r.childNodes[s-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&s--,r==t.dom&&s==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=t.state.doc.content.size:(s==0||r.nodeType!=1||r.childNodes[s-1].nodeName!="BR")&&(l=Th(t,r,s,e))}l==null&&(l=Mh(t,o,e));let a=t.docView.nearestDesc(o,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Ei(t){return t.top<t.bottom||t.left<t.right}function Ve(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(Ei(r))return r}return Array.prototype.find.call(n,Ei)||t.getBoundingClientRect()}const Ah=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function na(t,e,n){let{node:r,offset:s,atom:i}=t.docView.domFromPos(e,n<0?-1:1),o=un||xe;if(r.nodeType==3)if(o&&(Ah.test(r.nodeValue)||(n<0?!s:s==r.nodeValue.length))){let a=Ve(ze(r,s,s),n);if(xe&&s&&/\s/.test(r.nodeValue[s-1])&&s<r.nodeValue.length){let c=Ve(ze(r,s-1,s-1),-1);if(c.top==a.top){let u=Ve(ze(r,s,s+1),-1);if(u.top!=a.top)return _t(u,u.left<c.left)}}return a}else{let a=s,c=s,u=n<0?1:-1;return n<0&&!s?(c++,u=-1):n>=0&&s==r.nodeValue.length?(a--,u=1):n<0?a--:c++,_t(Ve(ze(r,a,c),u),u<0)}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&s&&(n<0||s==be(r))){let a=r.childNodes[s-1];if(a.nodeType==1)return Ar(a.getBoundingClientRect(),!1)}if(i==null&&s<be(r)){let a=r.childNodes[s];if(a.nodeType==1)return Ar(a.getBoundingClientRect(),!0)}return Ar(r.getBoundingClientRect(),n>=0)}if(i==null&&s&&(n<0||s==be(r))){let a=r.childNodes[s-1],c=a.nodeType==3?ze(a,be(a)-(o?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return _t(Ve(c,1),!1)}if(i==null&&s<be(r)){let a=r.childNodes[s];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?ze(a,0,o?0:1):a.nodeType==1?a:null:null;if(c)return _t(Ve(c,-1),!0)}return _t(Ve(r.nodeType==3?ze(r):r,-n),n>=0)}function _t(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function Ar(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function ra(t,e,n){let r=t.state,s=t.root.activeElement;r!=e&&t.updateState(e),s!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),s!=t.dom&&s&&s.focus()}}function Nh(t,e,n){let r=e.selection,s=n=="up"?r.$from:r.$to;return ra(t,e,()=>{let{node:i}=t.docView.domFromPos(s.pos,n=="up"?-1:1);for(;;){let l=t.docView.nearestDesc(i,!0);if(!l)break;if(l.node.isBlock){i=l.contentDOM||l.dom;break}i=l.dom.parentNode}let o=na(t,s.pos,1);for(let l=i.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=ze(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let u=a[c];if(u.bottom>u.top+1&&(n=="up"?o.top-u.top>(u.bottom-o.top)*2:u.bottom-o.bottom>(o.bottom-u.top)*2))return!1}}return!0})}const Oh=/[\u0590-\u08ac]/;function Ih(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let s=r.parentOffset,i=!s,o=s==r.parent.content.size,l=t.domSelection();return l?!Oh.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?i:o:ra(t,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:u,anchorOffset:d}=t.domSelectionRange(),h=l.caretBidiLevel;l.modify("move",n,"character");let f=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:p,focusOffset:m}=t.domSelectionRange(),g=p&&!f.contains(p.nodeType==1?p:p.parentNode)||a==p&&c==m;try{l.collapse(u,d),a&&(a!=u||c!=d)&&l.extend&&l.extend(a,c)}catch{}return h!=null&&(l.caretBidiLevel=h),g}):r.pos==r.start()||r.pos==r.end()}let Ai=null,Ni=null,Oi=!1;function Dh(t,e,n){return Ai==e&&Ni==n?Oi:(Ai=e,Ni=n,Oi=n=="up"||n=="down"?Nh(t,e,n):Ih(t,e,n))}const ke=0,Ii=1,ct=2,Ne=3;class dn{constructor(e,n,r,s){this.parent=e,this.children=n,this.dom=r,this.contentDOM=s,this.dirty=ke,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let n=0,r=this.posAtStart;;n++){let s=this.children[n];if(s==e)return r;r+=s.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,n,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let i,o;if(e==this.contentDOM)i=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&!((o=i.pmViewDesc)&&o.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(o)+o.size:this.posAtStart}else{let i,o;if(e==this.contentDOM)i=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&!((o=i.pmViewDesc)&&o.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(o):this.posAtEnd}let s;if(e==this.dom&&this.contentDOM)s=n>re(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))s=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!1;break}if(i.previousSibling)break}if(s==null&&n==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!0;break}if(i.nextSibling)break}}return s??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,s=e;s;s=s.parentNode){let i=this.getDesc(s),o;if(i&&(!n||i.node))if(r&&(o=i.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))r=!1;else return i}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let s=e;s;s=s.parentNode){let i=this.getDesc(s);if(i)return i.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let s=this.children[n],i=r+s.size;if(r==e&&i!=r){for(;!s.border&&s.children.length;)for(let o=0;o<s.children.length;o++){let l=s.children[o];if(l.size){s=l;break}}return s}if(e<i)return s.descAt(e-r-s.border);r=i}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,s=0;for(let i=0;r<this.children.length;r++){let o=this.children[r],l=i+o.size;if(l>e||o instanceof ia){s=e-i;break}i=l}if(s)return this.children[r].domFromPos(s-this.children[r].border,n);for(let i;r&&!(i=this.children[r-1]).size&&i instanceof sa&&i.side>=0;r--);if(n<=0){let i,o=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,o=!1);return i&&n&&o&&!i.border&&!i.domAtom?i.domFromPos(i.size,n):{node:this.contentDOM,offset:i?re(i.dom)+1:0}}else{let i,o=!0;for(;i=r<this.children.length?this.children[r]:null,!(!i||i.dom.parentNode==this.contentDOM);r++,o=!1);return i&&o&&!i.border&&!i.domAtom?i.domFromPos(0,n):{node:this.contentDOM,offset:i?re(i.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let s=-1,i=-1;for(let o=r,l=0;;l++){let a=this.children[l],c=o+a.size;if(s==-1&&e<=c){let u=o+a.border;if(e>=u&&n<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,n,u);e=o;for(let d=l;d>0;d--){let h=this.children[d-1];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(1)){s=re(h.dom)+1;break}e-=h.size}s==-1&&(s=0)}if(s>-1&&(c>n||l==this.children.length-1)){n=c;for(let u=l+1;u<this.children.length;u++){let d=this.children[u];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(-1)){i=re(d.dom);break}n+=d.size}i==-1&&(i=this.contentDOM.childNodes.length);break}o=c}return{node:this.contentDOM,from:e,to:n,fromOffset:s,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:r}=this.domFromPos(e,0);if(n.nodeType!=1||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}setSelection(e,n,r,s=!1){let i=Math.min(e,n),o=Math.max(e,n);for(let f=0,p=0;f<this.children.length;f++){let m=this.children[f],g=p+m.size;if(i>p&&o<g)return m.setSelection(e-p-m.border,n-p-m.border,r,s);p=g}let l=this.domFromPos(e,e?-1:1),a=n==e?l:this.domFromPos(n,n?-1:1),c=r.root.getSelection(),u=r.domSelectionRange(),d=!1;if((xe||oe)&&e==n){let{node:f,offset:p}=l;if(f.nodeType==3){if(d=!!(p&&f.nodeValue[p-1]==`
`),d&&p==f.nodeValue.length)for(let m=f,g;m;m=m.parentNode){if(g=m.nextSibling){g.nodeName=="BR"&&(l=a={node:g.parentNode,offset:re(g)+1});break}let b=m.pmViewDesc;if(b&&b.node&&b.node.isBlock)break}}else{let m=f.childNodes[p-1];d=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(xe&&u.focusNode&&u.focusNode!=a.node&&u.focusNode.nodeType==1){let f=u.focusNode.childNodes[u.focusOffset];f&&f.contentEditable=="false"&&(s=!0)}if(!(s||d&&oe)&&xt(l.node,l.offset,u.anchorNode,u.anchorOffset)&&xt(a.node,a.offset,u.focusNode,u.focusOffset))return;let h=!1;if((c.extend||e==n)&&!(d&&xe)){c.collapse(l.node,l.offset);try{e!=n&&c.extend(a.node,a.offset),h=!0}catch{}}if(!h){if(e>n){let p=l;l=a,a=p}let f=document.createRange();f.setEnd(a.node,a.offset),f.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(f)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,s=0;s<this.children.length;s++){let i=this.children[s],o=r+i.size;if(r==o?e<=o&&n>=r:e<o&&n>r){let l=r+i.border,a=o-i.border;if(e>=l&&n<=a){this.dirty=e==r||n==o?ct:Ii,e==l&&n==a&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=Ne:i.markDirty(e-l,n-l);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?ct:Ne}r=o}this.dirty=ct}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?ct:Ii;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class sa extends dn{constructor(e,n,r,s){let i,o=n.type.toDOM;if(typeof o=="function"&&(o=o(r,()=>{if(!i)return s;if(i.parent)return i.parent.posBeforeChild(i)})),!n.type.spec.raw){if(o.nodeType!=1){let l=document.createElement("span");l.appendChild(o),o=l}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=n,this.widget=n,i=this}matchesWidget(e){return this.dirty==ke&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class Rh extends dn{constructor(e,n,r,s){super(e,[],n,null),this.textDOM=r,this.text=s}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class kt extends dn{constructor(e,n,r,s,i){super(e,[],r,s),this.mark=n,this.spec=i}static create(e,n,r,s){let i=s.nodeViews[n.type.name],o=i&&i(n,s,r);return(!o||!o.dom)&&(o=Ct.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new kt(e,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&Ne||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Ne&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=ke){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=ke}}slice(e,n,r){let s=kt.create(this.parent,this.mark,!0,r),i=this.children,o=this.size;n<o&&(i=Yr(i,n,o,r)),e>0&&(i=Yr(i,0,e,r));for(let l=0;l<i.length;l++)i[l].parent=s;return s.children=i,s}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class Ze extends dn{constructor(e,n,r,s,i,o,l,a,c){super(e,[],i,o),this.node=n,this.outerDeco=r,this.innerDeco=s,this.nodeDOM=l}static create(e,n,r,s,i,o){let l=i.nodeViews[n.type.name],a,c=l&&l(n,i,()=>{if(!a)return o;if(a.parent)return a.parent.posBeforeChild(a)},r,s),u=c&&c.dom,d=c&&c.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:d}=Ct.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!d&&!n.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),n.type.spec.draggable&&(u.draggable=!0));let h=u;return u=aa(u,r,n),c?a=new Lh(e,n,r,s,u,d||null,h,c,i,o+1):n.isText?new ar(e,n,r,s,u,h,i):new Ze(e,n,r,s,u,d||null,h,i,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>x.empty)}return e}matchesNode(e,n,r){return this.dirty==ke&&e.eq(this.node)&&Vn(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,s=n,i=e.composing?this.localCompositionInfo(e,n):null,o=i&&i.pos>-1?i:null,l=i&&i.pos<0,a=new zh(this,o&&o.node,e);$h(this.node,this.innerDeco,(c,u,d)=>{c.spec.marks?a.syncToMarks(c.spec.marks,r,e):c.type.side>=0&&!d&&a.syncToMarks(u==this.node.childCount?F.none:this.node.child(u).marks,r,e),a.placeWidget(c,e,s)},(c,u,d,h)=>{a.syncToMarks(c.marks,r,e);let f;a.findNodeMatch(c,u,d,h)||l&&e.state.selection.from>s&&e.state.selection.to<s+c.nodeSize&&(f=a.findIndexWithChild(i.node))>-1&&a.updateNodeAt(c,u,d,f,e)||a.updateNextNode(c,u,d,e,h,s)||a.addNode(c,u,d,e,s),s+=c.nodeSize}),a.syncToMarks([],r,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==ct)&&(o&&this.protectLocalComposition(e,o),oa(this.contentDOM,this.children,e),zt&&Fh(this.dom))}localCompositionInfo(e,n){let{from:r,to:s}=e.state.selection;if(!(e.state.selection instanceof E)||r<n||s>n+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let o=i.nodeValue,l=Hh(this.node.content,o,r-n,s-n);return l<0?null:{node:i,pos:l,text:o}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:s}){if(this.getDesc(n))return;let i=n;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let o=new Rh(this,i,n,s);e.input.compositionNodes.push(o),this.children=Yr(this.children,r,r+s.length,e,o)}update(e,n,r,s){return this.dirty==Ne||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,s),!0)}updateInner(e,n,r,s){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(s,this.posAtStart),this.dirty=ke}updateOuterDeco(e){if(Vn(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=la(this.dom,this.nodeDOM,Xr(this.outerDeco,this.node,n),Xr(e,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function Di(t,e,n,r,s){aa(r,e,t);let i=new Ze(void 0,t,e,n,r,r,r,s,0);return i.contentDOM&&i.updateChildren(s,0),i}class ar extends Ze{constructor(e,n,r,s,i,o,l){super(e,n,r,s,i,null,o,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,s){return this.dirty==Ne||this.dirty!=ke&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=ke||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,s.trackWrites==this.nodeDOM&&(s.trackWrites=null)),this.node=e,this.dirty=ke,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let s=this.node.cut(e,n),i=document.createTextNode(s.text);return new ar(this.parent,s,this.outerDeco,this.innerDeco,i,i,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=Ne)}get domAtom(){return!1}isText(e){return this.node.text==e}}class ia extends dn{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==ke&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Lh extends Ze{constructor(e,n,r,s,i,o,l,a,c,u){super(e,n,r,s,i,o,l,c,u),this.spec=a}update(e,n,r,s){if(this.dirty==Ne)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,n,r);return i&&this.updateInner(e,n,r,s),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,s)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,s){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,s)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function oa(t,e,n){let r=t.firstChild,s=!1;for(let i=0;i<e.length;i++){let o=e[i],l=o.dom;if(l.parentNode==t){for(;l!=r;)r=Ri(r),s=!0;r=r.nextSibling}else s=!0,t.insertBefore(l,r);if(o instanceof kt){let a=r?r.previousSibling:t.lastChild;oa(o.contentDOM,o.children,n),r=a?a.nextSibling:t.firstChild}}for(;r;)r=Ri(r),s=!0;s&&n.trackWrites==t&&(n.trackWrites=null)}const Yt=function(t){t&&(this.nodeName=t)};Yt.prototype=Object.create(null);const ut=[new Yt];function Xr(t,e,n){if(t.length==0)return ut;let r=n?ut[0]:new Yt,s=[r];for(let i=0;i<t.length;i++){let o=t[i].type.attrs;if(o){o.nodeName&&s.push(r=new Yt(o.nodeName));for(let l in o){let a=o[l];a!=null&&(n&&s.length==1&&s.push(r=new Yt(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+a:l=="style"?r.style=(r.style?r.style+";":"")+a:l!="nodeName"&&(r[l]=a))}}}return s}function la(t,e,n,r){if(n==ut&&r==ut)return e;let s=e;for(let i=0;i<r.length;i++){let o=r[i],l=n[i];if(i){let a;l&&l.nodeName==o.nodeName&&s!=t&&(a=s.parentNode)&&a.nodeName.toLowerCase()==o.nodeName||(a=document.createElement(o.nodeName),a.pmIsDeco=!0,a.appendChild(s),l=ut[0]),s=a}Ph(s,l||ut[0],o)}return s}function Ph(t,e,n){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in n)&&t.removeAttribute(r);for(let r in n)r!="class"&&r!="style"&&r!="nodeName"&&n[r]!=e[r]&&t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(" ").filter(Boolean):[],s=n.class?n.class.split(" ").filter(Boolean):[];for(let i=0;i<r.length;i++)s.indexOf(r[i])==-1&&t.classList.remove(r[i]);for(let i=0;i<s.length;i++)r.indexOf(s[i])==-1&&t.classList.add(s[i]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,s;for(;s=r.exec(e.style);)t.style.removeProperty(s[1])}n.style&&(t.style.cssText+=n.style)}}function aa(t,e,n){return la(t,t,ut,Xr(e,n,t.nodeType!=1))}function Vn(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 Ri(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class zh{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Bh(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let r=e;r<n;r++)this.top.children[r].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,r){let s=0,i=this.stack.length>>1,o=Math.min(i,e.length);for(;s<o&&(s==i-1?this.top:this.stack[s+1<<1]).matchesMark(e[s])&&e[s].type.spec.spanning!==!1;)s++;for(;s<i;)this.destroyRest(),this.top.dirty=ke,this.index=this.stack.pop(),this.top=this.stack.pop(),i--;for(;i<e.length;){this.stack.push(this.top,this.index+1);let l=-1;for(let a=this.index;a<Math.min(this.index+3,this.top.children.length);a++){let c=this.top.children[a];if(c.matchesMark(e[i])&&!this.isLocked(c.dom)){l=a;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=kt.create(this.top,e[i],n,r);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,i++}}findNodeMatch(e,n,r,s){let i=-1,o;if(s>=this.preMatch.index&&(o=this.preMatch.matches[s-this.preMatch.index]).parent==this.top&&o.matchesNode(e,n,r))i=this.top.children.indexOf(o,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,n,r)&&!this.preMatch.matched.has(c)){i=l;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,n,r,s,i){let o=this.top.children[s];return o.dirty==Ne&&o.dom==o.contentDOM&&(o.dirty=ct),o.update(e,n,r,i)?(this.destroyBetween(this.index,s),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let s=this.index;s<this.top.children.length;s++)if(this.top.children[s]==r)return s}return-1}e=n}}updateNextNode(e,n,r,s,i,o){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof Ze){let c=this.preMatch.matched.get(a);if(c!=null&&c!=i)return!1;let u=a.dom,d,h=this.isLocked(u)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=Ne&&Vn(n,a.outerDeco));if(!h&&a.update(e,n,r,s))return this.destroyBetween(this.index,l),a.dom!=u&&(this.changed=!0),this.index++,!0;if(!h&&(d=this.recreateWrapper(a,e,n,r,s,o)))return this.destroyBetween(this.index,l),this.top.children[this.index]=d,d.contentDOM&&(d.dirty=ct,d.updateChildren(s,o+1),d.dirty=ke),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,s,i,o){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!Vn(r,e.outerDeco)||!s.eq(e.innerDeco))return null;let l=Ze.create(this.top,n,r,s,i,o);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,n,r,s,i){let o=Ze.create(this.top,e,n,r,s,i);o.contentDOM&&o.updateChildren(s,i+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,n,r){let s=this.index<this.top.children.length?this.top.children[this.index]:null;if(s&&s.matchesWidget(e)&&(e==s.widget||!s.widget.type.toDOM.parentNode))this.index++;else{let i=new sa(this.top,e,n,r);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof kt;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof ar)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((oe||Z)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",n),this.addHackNode("BR",this.top))}addHackNode(e,n){if(n==this.top&&this.index<n.children.length&&n.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let s=new ia(this.top,[],r,null);n!=this.top?n.children.push(s):n.children.splice(this.index++,0,s),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function Bh(t,e){let n=e,r=n.children.length,s=t.childCount,i=new Map,o=[];e:for(;s>0;){let l;for(;;)if(r){let c=n.children[r-1];if(c instanceof kt)n=c,r=c.children.length;else{l=c,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let a=l.node;if(a){if(a!=t.child(s-1))break;--s,i.set(l,s),o.push(l)}}return{index:s,matched:i,matches:o.reverse()}}function jh(t,e){return t.type.side-e.type.side}function $h(t,e,n,r){let s=e.locals(t),i=0;if(s.length==0){for(let c=0;c<t.childCount;c++){let u=t.child(c);r(u,s,e.forChild(i,u),c),i+=u.nodeSize}return}let o=0,l=[],a=null;for(let c=0;;){let u,d;for(;o<s.length&&s[o].to==i;){let g=s[o++];g.widget&&(u?(d||(d=[u])).push(g):u=g)}if(u)if(d){d.sort(jh);for(let g=0;g<d.length;g++)n(d[g],c,!!a)}else n(u,c,!!a);let h,f;if(a)f=-1,h=a,a=null;else if(c<t.childCount)f=c,h=t.child(c++);else break;for(let g=0;g<l.length;g++)l[g].to<=i&&l.splice(g--,1);for(;o<s.length&&s[o].from<=i&&s[o].to>i;)l.push(s[o++]);let p=i+h.nodeSize;if(h.isText){let g=p;o<s.length&&s[o].from<g&&(g=s[o].from);for(let b=0;b<l.length;b++)l[b].to<g&&(g=l[b].to);g<p&&(a=h.cut(g-i),h=h.cut(0,g-i),p=g,f=-1)}else for(;o<s.length&&s[o].to<p;)o++;let m=h.isInline&&!h.isLeaf?l.filter(g=>!g.inline):l.slice();r(h,m,e.forChild(i,h),f),i=p}}function Fh(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}function Hh(t,e,n,r){for(let s=0,i=0;s<t.childCount&&i<=r;){let o=t.child(s++),l=i;if(i+=o.nodeSize,!o.isText)continue;let a=o.text;for(;s<t.childCount;){let c=t.child(s++);if(i+=c.nodeSize,!c.isText)break;a+=c.text}if(i>=n){if(i>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l<r?a.lastIndexOf(e,r-l-1):-1;if(c>=0&&c+e.length+l>=n)return l+c;if(n==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function Yr(t,e,n,r,s){let i=[];for(let o=0,l=0;o<t.length;o++){let a=t[o],c=l,u=l+=a.size;c>=n||u<=e?i.push(a):(c<e&&i.push(a.slice(0,e-c,r)),s&&(i.push(s),s=void 0),u>n&&i.push(a.slice(n-c,a.size,r)))}return i}function Ls(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let s=t.docView.nearestDesc(n.focusNode),i=s&&s.size==0,o=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let l=r.resolve(o),a,c;if(lr(n)){for(a=o;s&&!s.node;)s=s.parent;let d=s.node;if(s&&d.isAtom&&A.isSelectable(d)&&s.parent&&!(d.isInline&&ph(n.focusNode,n.focusOffset,s.dom))){let h=s.posBefore;c=new A(o==h?l:r.resolve(h))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let d=o,h=o;for(let f=0;f<n.rangeCount;f++){let p=n.getRangeAt(f);d=Math.min(d,t.docView.posFromDOM(p.startContainer,p.startOffset,1)),h=Math.max(h,t.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(d<0)return null;[a,o]=h==t.state.selection.anchor?[h,d]:[d,h],l=r.resolve(o)}else a=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(a<0)return null}let u=r.resolve(a);if(!c){let d=e=="pointer"||t.state.selection.head<l.pos&&!i?1:-1;c=Ps(t,u,l,d)}return c}function ca(t){return t.editable?t.hasFocus():da(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function $e(t,e=!1){let n=t.state.selection;if(ua(t,n),!!ca(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&Z){let r=t.domSelectionRange(),s=t.domObserver.currentSelection;if(r.anchorNode&&s.anchorNode&&xt(r.anchorNode,r.anchorOffset,s.anchorNode,s.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)_h(t);else{let{anchor:r,head:s}=n,i,o;Li&&!(n instanceof E)&&(n.$from.parent.inlineContent||(i=Pi(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=Pi(t,n.to))),t.docView.setSelection(r,s,t,e),Li&&(i&&zi(i),o&&zi(o)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Vh(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const Li=oe||Z&&Xl<63;function Pi(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),s=r<n.childNodes.length?n.childNodes[r]:null,i=r?n.childNodes[r-1]:null;if(oe&&s&&s.contentEditable=="false")return Nr(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return Nr(s);if(i)return Nr(i)}}function Nr(t){return t.contentEditable="true",oe&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function zi(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function Vh(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,s=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=s)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!ca(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function _h(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,re(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&he&&Ye<=11&&(n.disabled=!0,n.disabled=!1)}function ua(t,e){if(e instanceof A){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(Bi(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else Bi(t)}function Bi(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Ps(t,e,n,r){return t.someProp("createSelectionBetween",s=>s(t,e,n))||E.between(e,n,r)}function ji(t){return t.editable&&!t.hasFocus()?!1:da(t)}function da(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function Wh(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return xt(e.node,e.offset,n.anchorNode,n.anchorOffset)}function Zr(t,e){let{$anchor:n,$head:r}=t.selection,s=e>0?n.max(r):n.min(r),i=s.parent.inlineContent?s.depth?t.doc.resolve(e>0?s.after():s.before()):null:s;return i&&N.findFrom(i,e)}function _e(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function $i(t,e,n){let r=t.state.selection;if(r instanceof E)if(n.indexOf("s")>-1){let{$head:s}=r,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let o=t.state.doc.resolve(s.pos+i.nodeSize*(e<0?-1:1));return _e(t,new E(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let s=Zr(t.state,e);return s&&s instanceof A?_e(t,s):!1}else if(!(ye&&n.indexOf("m")>-1)){let s=r.$head,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter,o;if(!i||i.isText)return!1;let l=e<0?s.pos-i.nodeSize:s.pos;return i.isAtom||(o=t.docView.descAt(l))&&!o.contentDOM?A.isSelectable(i)?_e(t,new A(e<0?t.state.doc.resolve(s.pos-i.nodeSize):s)):un?_e(t,new E(t.state.doc.resolve(e<0?l:l+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof A&&r.node.isInline)return _e(t,new E(e>0?r.$to:r.$from));{let s=Zr(t.state,e);return s?_e(t,s):!1}}}function _n(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Zt(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function Et(t,e){return e<0?qh(t):Kh(t)}function qh(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s,i,o=!1;for(xe&&n.nodeType==1&&r<_n(n)&&Zt(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(Zt(l,-1))s=n,i=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(ha(n))break;{let l=n.previousSibling;for(;l&&Zt(l,-1);)s=n.parentNode,i=re(l),l=l.previousSibling;if(l)n=l,r=_n(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?Qr(t,n,r):s&&Qr(t,s,i)}function Kh(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s=_n(n),i,o;for(;;)if(r<s){if(n.nodeType!=1)break;let l=n.childNodes[r];if(Zt(l,1))i=n,o=++r;else break}else{if(ha(n))break;{let l=n.nextSibling;for(;l&&Zt(l,1);)i=l.parentNode,o=re(l)+1,l=l.nextSibling;if(l)n=l,r=0,s=_n(n);else{if(n=n.parentNode,n==t.dom)break;r=s=0}}}i&&Qr(t,i,o)}function ha(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function Uh(t,e){for(;t&&e==t.childNodes.length&&!cn(t);)e=re(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=0}}function Jh(t,e){for(;t&&!e&&!cn(t);)e=re(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=t.childNodes.length}}function Qr(t,e,n){if(e.nodeType!=3){let i,o;(o=Uh(e,n))?(e=o,n=0):(i=Jh(e,n))&&(e=i,n=i.nodeValue.length)}let r=t.domSelection();if(!r)return;if(lr(r)){let i=document.createRange();i.setEnd(e,n),i.setStart(e,n),r.removeAllRanges(),r.addRange(i)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:s}=t;setTimeout(()=>{t.state==s&&$e(t)},50)}function Fi(t,e){let n=t.state.doc.resolve(e);if(!(Z||Yl)&&n.parent.inlineContent){let s=t.coordsAtPos(e);if(e>n.start()){let i=t.coordsAtPos(e-1),o=(i.top+i.bottom)/2;if(o>s.top&&o<s.bottom&&Math.abs(i.left-s.left)>1)return i.left<s.left?"ltr":"rtl"}if(e<n.end()){let i=t.coordsAtPos(e+1),o=(i.top+i.bottom)/2;if(o>s.top&&o<s.bottom&&Math.abs(i.left-s.left)>1)return i.left>s.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function Hi(t,e,n){let r=t.state.selection;if(r instanceof E&&!r.empty||n.indexOf("s")>-1||ye&&n.indexOf("m")>-1)return!1;let{$from:s,$to:i}=r;if(!s.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=Zr(t.state,e);if(o&&o instanceof A)return _e(t,o)}if(!s.parent.inlineContent){let o=e<0?s:i,l=r instanceof de?N.near(o,e):N.findFrom(o,e);return l?_e(t,l):!1}return!1}function Vi(t,e){if(!(t.state.selection instanceof E))return!0;let{$head:n,$anchor:r,empty:s}=t.state.selection;if(!n.sameParent(r))return!0;if(!s)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 _i(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function Gh(t){if(!oe||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;_i(t,r,"true"),setTimeout(()=>_i(t,r,"false"),20)}return!1}function Xh(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function Yh(t,e){let n=e.keyCode,r=Xh(e);if(n==8||ye&&n==72&&r=="c")return Vi(t,-1)||Et(t,-1);if(n==46&&!e.shiftKey||ye&&n==68&&r=="c")return Vi(t,1)||Et(t,1);if(n==13||n==27)return!0;if(n==37||ye&&n==66&&r=="c"){let s=n==37?Fi(t,t.state.selection.from)=="ltr"?-1:1:-1;return $i(t,s,r)||Et(t,s)}else if(n==39||ye&&n==70&&r=="c"){let s=n==39?Fi(t,t.state.selection.from)=="ltr"?1:-1:1;return $i(t,s,r)||Et(t,s)}else{if(n==38||ye&&n==80&&r=="c")return Hi(t,-1,r)||Et(t,-1);if(n==40||ye&&n==78&&r=="c")return Gh(t)||Hi(t,1,r)||Et(t,1);if(r==(ye?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function zs(t,e){t.someProp("transformCopied",f=>{e=f(e,t)});let n=[],{content:r,openStart:s,openEnd:i}=e;for(;s>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){s--,i--;let f=r.firstChild;n.push(f.type.name,f.attrs!=f.type.defaultAttrs?f.attrs:null),r=f.content}let o=t.someProp("clipboardSerializer")||Ct.fromSchema(t.state.schema),l=ba(),a=l.createElement("div");a.appendChild(o.serializeFragment(r,{document:l}));let c=a.firstChild,u,d=0;for(;c&&c.nodeType==1&&(u=ya[c.nodeName.toLowerCase()]);){for(let f=u.length-1;f>=0;f--){let p=l.createElement(u[f]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),d++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${s} ${i}${d?` -${d}`:""} ${JSON.stringify(n)}`);let h=t.someProp("clipboardTextSerializer",f=>f(e,t))||e.content.textBetween(0,e.content.size,`

`);return{dom:a,text:h,slice:e}}function fa(t,e,n,r,s){let i=s.parent.type.spec.code,o,l;if(!n&&!e)return null;let a=!!e&&(r||i||!n);if(a){if(t.someProp("transformPastedText",h=>{e=h(e,i||r,t)}),i)return l=new S(x.from(t.state.schema.text(e.replace(/\r\n?/g,`
`))),0,0),t.someProp("transformPasted",h=>{l=h(l,t,!0)}),l;let d=t.someProp("clipboardTextParser",h=>h(e,s,r,t));if(d)l=d;else{let h=s.marks(),{schema:f}=t.state,p=Ct.fromSchema(f);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=o.appendChild(document.createElement("p"));m&&g.appendChild(p.serializeNode(f.text(m,h)))})}}else t.someProp("transformPastedHTML",d=>{n=d(n,t)}),o=tf(n),un&&nf(o);let c=o&&o.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let d=+u[3];d>0;d--){let h=o.firstChild;for(;h&&h.nodeType!=1;)h=h.nextSibling;if(!h)break;o=h}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||Xe.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||u),context:s,ruleFromNode(h){return h.nodeName=="BR"&&!h.nextSibling&&h.parentNode&&!Zh.test(h.parentNode.nodeName)?{ignore:!0}:null}})),u)l=rf(Wi(l,+u[1],+u[2]),u[4]);else if(l=S.maxOpen(Qh(l.content,s),!0),l.openStart||l.openEnd){let d=0,h=0;for(let f=l.content.firstChild;d<l.openStart&&!f.type.spec.isolating;d++,f=f.firstChild);for(let f=l.content.lastChild;h<l.openEnd&&!f.type.spec.isolating;h++,f=f.lastChild);l=Wi(l,d,h)}return t.someProp("transformPasted",d=>{l=d(l,t,a)}),l}const Zh=/^(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 Qh(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let s=e.node(n).contentMatchAt(e.index(n)),i,o=[];if(t.forEach(l=>{if(!o)return;let a=s.findWrapping(l.type),c;if(!a)return o=null;if(c=o.length&&i.length&&ma(a,i,l,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=ga(o[o.length-1],i.length));let u=pa(l,a);o.push(u),s=s.matchType(u.type),i=a}}),o)return x.from(o)}return t}function pa(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,x.from(t));return t}function ma(t,e,n,r,s){if(s<t.length&&s<e.length&&t[s]==e[s]){let i=ma(t,e,n,r.lastChild,s+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(s==t.length-1?n.type:t[s+1]))return r.copy(r.content.append(x.from(pa(n,t,s+1))))}}function ga(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,ga(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(x.empty,!0);return t.copy(n.append(r))}function es(t,e,n,r,s,i){let o=e<0?t.firstChild:t.lastChild,l=o.content;return t.childCount>1&&(i=0),s<r-1&&(l=es(l,e,n,r,s+1,i)),s>=n&&(l=e<0?o.contentMatchAt(0).fillBefore(l,i<=s).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(x.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(l))}function Wi(t,e,n){return e<t.openStart&&(t=new S(es(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new S(es(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const ya={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 qi=null;function ba(){return qi||(qi=document.implementation.createHTMLDocument("title"))}let Or=null;function ef(t){let e=window.trustedTypes;return e?(Or||(Or=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),Or.createHTML(t)):t}function tf(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=ba().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),s;if((s=r&&ya[r[1].toLowerCase()])&&(t=s.map(i=>"<"+i+">").join("")+t+s.map(i=>"</"+i+">").reverse().join("")),n.innerHTML=ef(t),s)for(let i=0;i<s.length;i++)n=n.querySelector(s[i])||n;return n}function nf(t){let e=t.querySelectorAll(Z?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let r=e[n];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}function rf(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:s,openStart:i,openEnd:o}=t;for(let l=r.length-2;l>=0;l-=2){let a=n.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;s=x.from(a.create(r[l+1],s)),i++,o++}return new S(s,i,o)}const ce={},ue={},sf={touchstart:!0,touchmove:!0};class of{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function lf(t){for(let e in ce){let n=ce[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{cf(t,r)&&!Bs(t,r)&&(t.editable||!(r.type in ue))&&n(t,r)},sf[e]?{passive:!0}:void 0)}oe&&t.dom.addEventListener("input",()=>null),ts(t)}function Ge(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function af(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)}function ts(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>Bs(t,r))})}function Bs(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function cf(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function uf(t,e){!Bs(t,e)&&ce[e.type]&&(t.editable||!(e.type in ue))&&ce[e.type](t,e)}ue.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!ka(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Be&&Z&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),zt&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",s=>s(t,at(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||Yh(t,n)?n.preventDefault():Ge(t,"key")};ue.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};ue.keypress=(t,e)=>{let n=e;if(ka(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||ye&&n.metaKey)return;if(t.someProp("handleKeyPress",s=>s(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof E)||!r.$from.sameParent(r.$to)){let s=String.fromCharCode(n.charCode),i=()=>t.state.tr.insertText(s).scrollIntoView();!/[\r\n]/.test(s)&&!t.someProp("handleTextInput",o=>o(t,r.$from.pos,r.$to.pos,s,i))&&t.dispatch(i()),n.preventDefault()}};function cr(t){return{left:t.clientX,top:t.clientY}}function df(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function js(t,e,n,r,s){if(r==-1)return!1;let i=t.state.doc.resolve(r);for(let o=i.depth+1;o>0;o--)if(t.someProp(e,l=>o>i.depth?l(t,n,i.nodeAfter,i.before(o),s,!0):l(t,n,i.node(o),i.before(o),s,!1)))return!0;return!1}function Dt(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);r.setMeta("pointer",!0),t.dispatch(r)}function hf(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&A.isSelectable(r)?(Dt(t,new A(n)),!0):!1}function ff(t,e){if(e==-1)return!1;let n=t.state.selection,r,s;n instanceof A&&(r=n.node);let i=t.state.doc.resolve(e);for(let o=i.depth+1;o>0;o--){let l=o>i.depth?i.nodeAfter:i.node(o);if(A.isSelectable(l)){r&&n.$from.depth>0&&o>=n.$from.depth&&i.before(n.$from.depth+1)==n.$from.pos?s=i.before(n.$from.depth):s=i.before(o);break}}return s!=null?(Dt(t,A.create(t.state.doc,s)),!0):!1}function pf(t,e,n,r,s){return js(t,"handleClickOn",e,n,r)||t.someProp("handleClick",i=>i(t,e,r))||(s?ff(t,n):hf(t,n))}function mf(t,e,n,r){return js(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",s=>s(t,e,r))}function gf(t,e,n,r){return js(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",s=>s(t,e,r))||yf(t,n,r)}function yf(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(Dt(t,E.create(r,0,r.content.size)),!0):!1;let s=r.resolve(e);for(let i=s.depth+1;i>0;i--){let o=i>s.depth?s.nodeAfter:s.node(i),l=s.before(i);if(o.inlineContent)Dt(t,E.create(r,l+1,l+1+o.content.size));else if(A.isSelectable(o))Dt(t,A.create(r,l));else continue;return!0}}function $s(t){return Wn(t)}const xa=ye?"metaKey":"ctrlKey";ce.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=$s(t),s=Date.now(),i="singleClick";s-t.input.lastClick.time<500&&df(n,t.input.lastClick)&&!n[xa]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?i="doubleClick":t.input.lastClick.type=="doubleClick"&&(i="tripleClick")),t.input.lastClick={time:s,x:n.clientX,y:n.clientY,type:i,button:n.button};let o=t.posAtCoords(cr(n));o&&(i=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new bf(t,o,n,!!r)):(i=="doubleClick"?mf:gf)(t,o.pos,o.inside,n)?n.preventDefault():Ge(t,"pointer"))};class bf{constructor(e,n,r,s){this.view=e,this.pos=n,this.event=r,this.flushed=s,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[xa],this.allowDefault=r.shiftKey;let i,o;if(n.inside>-1)i=e.state.doc.nodeAt(n.inside),o=n.inside;else{let u=e.state.doc.resolve(n.pos);i=u.parent,o=u.depth?u.before():0}const l=s?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.nodeDOM.nodeType==1?a.nodeDOM:null;let{selection:c}=e.state;(r.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof A&&c.from<=o&&c.to>o)&&(this.mightDrag={node:i,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&xe&&!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()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),Ge(e,"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(()=>$e(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(cr(e))),this.updateAllowDefault(e),this.allowDefault||!n?Ge(this.view,"pointer"):pf(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||oe&&this.mightDrag&&!this.mightDrag.node.isAtom||Z&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(Dt(this.view,N.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Ge(this.view,"pointer")}move(e){this.updateAllowDefault(e),Ge(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}ce.touchstart=t=>{t.input.lastTouch=Date.now(),$s(t),Ge(t,"pointer")};ce.touchmove=t=>{t.input.lastTouch=Date.now(),Ge(t,"pointer")};ce.contextmenu=t=>$s(t);function ka(t,e){return t.composing?!0:oe&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const xf=Be?5e3:-1;ue.compositionstart=ue.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof E&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||Z&&Yl&&kf(t)))t.markCursor=t.state.storedMarks||n.marks(),Wn(t,!0),t.markCursor=null;else if(Wn(t,!e.selection.empty),xe&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let s=r.focusNode,i=r.focusOffset;s&&s.nodeType==1&&i!=0;){let o=i<0?s.lastChild:s.childNodes[i-1];if(!o)break;if(o.nodeType==3){let l=t.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else s=o,i=-1}}t.input.composing=!0}wa(t,xf)};function kf(t){let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(!e||e.nodeType!=1||n>=e.childNodes.length)return!1;let r=e.childNodes[n];return r.nodeType==1&&r.contentEditable=="false"}ue.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++,wa(t,20))};function wa(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>Wn(t),e))}function Sa(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Sf());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function wf(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=hh(e.focusNode,e.focusOffset),r=fh(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let s=r.pmViewDesc,i=t.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!s||!s.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let o=n.pmViewDesc;if(!(!o||!o.isText(n.nodeValue)))return r}}return n||r}function Sf(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function Wn(t,e=!1){if(!(Be&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),Sa(t),e||t.docView&&t.docView.dirty){let n=Ls(t),r=t.state.selection;return n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function Cf(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),s=document.createRange();s.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const rn=he&&Ye<15||zt&&yh<604;ce.copy=ue.cut=(t,e)=>{let n=e,r=t.state.selection,s=n.type=="cut";if(r.empty)return;let i=rn?null:n.clipboardData,o=r.content(),{dom:l,text:a}=zs(t,o);i?(n.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):Cf(t,l),s&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function vf(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function Mf(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let s=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?sn(t,r.value,null,s,e):sn(t,r.textContent,r.innerHTML,s,e)},50)}function sn(t,e,n,r,s){let i=fa(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",a=>a(t,s,i||S.empty)))return!0;if(!i)return!1;let o=vf(i),l=o?t.state.tr.replaceSelectionWith(o,r):t.state.tr.replaceSelection(i);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Ca(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," "):""}ue.paste=(t,e)=>{let n=e;if(t.composing&&!Be)return;let r=rn?null:n.clipboardData,s=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&sn(t,Ca(r),r.getData("text/html"),s,n)?n.preventDefault():Mf(t,n)};class va{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const Tf=ye?"altKey":"ctrlKey";function Ma(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[Tf]}ce.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let s=t.state.selection,i=s.empty?null:t.posAtCoords(cr(n)),o;if(!(i&&i.pos>=s.from&&i.pos<=(s instanceof A?s.to-1:s.to))){if(r&&r.mightDrag)o=A.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let d=t.docView.nearestDesc(n.target,!0);d&&d.node.type.spec.draggable&&d!=t.docView&&(o=A.create(t.state.doc,d.posBefore))}}let l=(o||t.state.selection).content(),{dom:a,text:c,slice:u}=zs(t,l);(!n.dataTransfer.files.length||!Z||Xl>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(rn?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",rn||n.dataTransfer.setData("text/plain",c),t.dragging=new va(u,Ma(t,n),o)};ce.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};ue.dragover=ue.dragenter=(t,e)=>e.preventDefault();ue.drop=(t,e)=>{try{Ef(t,e,t.dragging)}finally{t.dragging=null}};function Ef(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(cr(e));if(!r)return;let s=t.state.doc.resolve(r.pos),i=n&&n.slice;i?t.someProp("transformPasted",f=>{i=f(i,t,!1)}):i=fa(t,Ca(e.dataTransfer),rn?null:e.dataTransfer.getData("text/html"),!1,s);let o=!!(n&&Ma(t,e));if(t.someProp("handleDrop",f=>f(t,e,i||S.empty,o))){e.preventDefault();return}if(!i)return;e.preventDefault();let l=i?Nl(t.state.doc,s.pos,i):s.pos;l==null&&(l=s.pos);let a=t.state.tr;if(o){let{node:f}=n;f?f.replace(a):a.deleteSelection()}let c=a.mapping.map(l),u=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,d=a.doc;if(u?a.replaceRangeWith(c,c,i.content.firstChild):a.replaceRange(c,c,i),a.doc.eq(d))return;let h=a.doc.resolve(c);if(u&&A.isSelectable(i.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(i.content.firstChild))a.setSelection(new A(h));else{let f=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((p,m,g,b)=>f=b),a.setSelection(Ps(t,h,a.doc.resolve(f)))}t.focus(),t.dispatch(a.setMeta("uiEvent","drop"))}ce.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())&&$e(t)},20))};ce.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)};ce.beforeinput=(t,e)=>{if(Z&&Be&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",i=>i(t,at(8,"Backspace")))))return;let{$cursor:s}=t.state.selection;s&&s.pos>0&&t.dispatch(t.state.tr.delete(s.pos-1,s.pos).scrollIntoView())},50)}};for(let t in ue)ce[t]=ue[t];function on(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 qn{constructor(e,n){this.toDOM=e,this.spec=n||pt,this.side=this.spec.side||0}map(e,n,r,s){let{pos:i,deleted:o}=e.mapResult(n.from+s,this.side<0?-1:1);return o?null:new G(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof qn&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&on(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Qe{constructor(e,n){this.attrs=e,this.spec=n||pt}map(e,n,r,s){let i=e.map(n.from+s,this.spec.inclusiveStart?-1:1)-r,o=e.map(n.to+s,this.spec.inclusiveEnd?1:-1)-r;return i>=o?null:new G(i,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof Qe&&on(this.attrs,e.attrs)&&on(this.spec,e.spec)}static is(e){return e.type instanceof Qe}destroy(){}}class Fs{constructor(e,n){this.attrs=e,this.spec=n||pt}map(e,n,r,s){let i=e.mapResult(n.from+s,1);if(i.deleted)return null;let o=e.mapResult(n.to+s,-1);return o.deleted||o.pos<=i.pos?null:new G(i.pos-r,o.pos-r,this)}valid(e,n){let{index:r,offset:s}=e.content.findIndex(n.from),i;return s==n.from&&!(i=e.child(r)).isText&&s+i.nodeSize==n.to}eq(e){return this==e||e instanceof Fs&&on(this.attrs,e.attrs)&&on(this.spec,e.spec)}destroy(){}}class G{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new G(e,n,this.type)}eq(e,n=0){return this.type.eq(e.type)&&this.from+n==e.from&&this.to+n==e.to}map(e,n,r){return this.type.map(e,this,n,r)}static widget(e,n,r){return new G(e,e,new qn(n,r))}static inline(e,n,r,s){return new G(e,n,new Qe(r,s))}static node(e,n,r,s){return new G(e,n,new Fs(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof Qe}get widget(){return this.type instanceof qn}}const Nt=[],pt={};class ${constructor(e,n){this.local=e.length?e:Nt,this.children=n.length?n:Nt}static create(e,n){return n.length?Kn(n,e,0,pt):ie}find(e,n,r){let s=[];return this.findInner(e??0,n??1e9,s,0,r),s}findInner(e,n,r,s,i){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=n&&l.to>=e&&(!i||i(l.spec))&&r.push(l.copy(l.from+s,l.to+s))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<n&&this.children[o+1]>e){let l=this.children[o]+1;this.children[o+2].findInner(e-l,n-l,r,s+l,i)}}map(e,n,r){return this==ie||e.maps.length==0?this:this.mapInner(e,n,0,0,r||pt)}mapInner(e,n,r,s,i){let o;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,s);a&&a.type.valid(n,a)?(o||(o=[])).push(a):i.onRemove&&i.onRemove(this.local[l].spec)}return this.children.length?Af(this.children,o||[],e,n,r,s,i):o?new $(o.sort(mt),Nt):ie}add(e,n){return n.length?this==ie?$.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let s,i=0;e.forEach((l,a)=>{let c=a+r,u;if(u=Ea(n,l,c)){for(s||(s=this.children.slice());i<s.length&&s[i]<a;)i+=3;s[i]==a?s[i+2]=s[i+2].addInner(l,u,c+1):s.splice(i,0,a,a+l.nodeSize,Kn(u,l,c+1,pt)),i+=3}});let o=Ta(i?Aa(n):n,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new $(o.length?this.local.concat(o).sort(mt):this.local,s||this.children)}remove(e){return e.length==0||this==ie?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,s=this.local;for(let i=0;i<r.length;i+=3){let o,l=r[i]+n,a=r[i+1]+n;for(let u=0,d;u<e.length;u++)(d=e[u])&&d.from>l&&d.to<a&&(e[u]=null,(o||(o=[])).push(d));if(!o)continue;r==this.children&&(r=this.children.slice());let c=r[i+2].removeInner(o,l+1);c!=ie?r[i+2]=c:(r.splice(i,3),i-=3)}if(s.length){for(let i=0,o;i<e.length;i++)if(o=e[i])for(let l=0;l<s.length;l++)s[l].eq(o,n)&&(s==this.local&&(s=this.local.slice()),s.splice(l--,1))}return r==this.children&&s==this.local?this:s.length||r.length?new $(s,r):ie}forChild(e,n){if(this==ie)return this;if(n.isLeaf)return $.empty;let r,s;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let i=e+1,o=i+n.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<o&&a.to>i&&a.type instanceof Qe){let c=Math.max(i,a.from)-i,u=Math.min(o,a.to)-i;c<u&&(s||(s=[])).push(a.copy(c,u))}}if(s){let l=new $(s.sort(mt),Nt);return r?new qe([l,r]):l}return r||ie}eq(e){if(this==e)return!0;if(!(e instanceof $)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(e.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=e.children[n]||this.children[n+1]!=e.children[n+1]||!this.children[n+2].eq(e.children[n+2]))return!1;return!0}locals(e){return Hs(this.localsInner(e))}localsInner(e){if(this==ie)return Nt;if(e.inlineContent||!this.local.some(Qe.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Qe||n.push(this.local[r]);return n}forEachSet(e){e(this)}}$.empty=new $([],[]);$.removeOverlap=Hs;const ie=$.empty;class qe{constructor(e){this.members=e}map(e,n){const r=this.members.map(s=>s.map(e,n,pt));return qe.from(r)}forChild(e,n){if(n.isLeaf)return $.empty;let r=[];for(let s=0;s<this.members.length;s++){let i=this.members[s].forChild(e,n);i!=ie&&(i instanceof qe?r=r.concat(i.members):r.push(i))}return qe.from(r)}eq(e){if(!(e instanceof qe)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let s=0;s<this.members.length;s++){let i=this.members[s].localsInner(e);if(i.length)if(!n)n=i;else{r&&(n=n.slice(),r=!1);for(let o=0;o<i.length;o++)n.push(i[o])}}return n?Hs(r?n:n.sort(mt)):Nt}static from(e){switch(e.length){case 0:return ie;case 1:return e[0];default:return new qe(e.every(n=>n instanceof $)?e:e.reduce((n,r)=>n.concat(r instanceof $?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function Af(t,e,n,r,s,i,o){let l=t.slice();for(let c=0,u=i;c<n.maps.length;c++){let d=0;n.maps[c].forEach((h,f,p,m)=>{let g=m-p-(f-h);for(let b=0;b<l.length;b+=3){let k=l[b+1];if(k<0||h>k+u-d)continue;let w=l[b]+u-d;f>=w?l[b+1]=h<=w?-2:-1:h>=u&&g&&(l[b]+=g,l[b+1]+=g)}d+=g}),u=n.maps[c].map(u,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let u=n.map(t[c]+i),d=u-s;if(d<0||d>=r.content.size){a=!0;continue}let h=n.map(t[c+1]+i,-1),f=h-s,{index:p,offset:m}=r.content.findIndex(d),g=r.maybeChild(p);if(g&&m==d&&m+g.nodeSize==f){let b=l[c+2].mapInner(n,g,u+1,t[c]+i+1,o);b!=ie?(l[c]=d,l[c+1]=f,l[c+2]=b):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=Nf(l,t,e,n,s,i,o),u=Kn(c,r,0,o);e=u.local;for(let d=0;d<l.length;d+=3)l[d+1]<0&&(l.splice(d,3),d-=3);for(let d=0,h=0;d<u.children.length;d+=3){let f=u.children[d];for(;h<l.length&&l[h]<f;)h+=3;l.splice(h,0,u.children[d],u.children[d+1],u.children[d+2])}}return new $(e.sort(mt),l)}function Ta(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let s=t[r];n.push(new G(s.from+e,s.to+e,s.type))}return n}function Nf(t,e,n,r,s,i,o){function l(a,c){for(let u=0;u<a.local.length;u++){let d=a.local[u].map(r,s,c);d?n.push(d):o.onRemove&&o.onRemove(a.local[u].spec)}for(let u=0;u<a.children.length;u+=3)l(a.children[u+2],a.children[u]+c+1)}for(let a=0;a<t.length;a+=3)t[a+1]==-1&&l(t[a+2],e[a]+i+1);return n}function Ea(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,s=null;for(let i=0,o;i<t.length;i++)(o=t[i])&&o.from>n&&o.to<r&&((s||(s=[])).push(o),t[i]=null);return s}function Aa(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function Kn(t,e,n,r){let s=[],i=!1;e.forEach((l,a)=>{let c=Ea(t,l,a+n);if(c){i=!0;let u=Kn(c,l,n+a+1,r);u!=ie&&s.push(a,a+l.nodeSize,u)}});let o=Ta(i?Aa(t):t,-n).sort(mt);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||(r.onRemove&&r.onRemove(o[l].spec),o.splice(l--,1));return o.length||s.length?new $(o,s):ie}function mt(t,e){return t.from-e.from||t.to-e.to}function Hs(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let s=n+1;s<e.length;s++){let i=e[s];if(i.from==r.from){i.to!=r.to&&(e==t&&(e=t.slice()),e[s]=i.copy(i.from,r.to),Ki(e,s+1,i.copy(r.to,i.to)));continue}else{i.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,i.from),Ki(e,s,r.copy(i.from,r.to)));break}}}return e}function Ki(t,e,n){for(;e<t.length&&mt(n,t[e])>0;)e++;t.splice(e,0,n)}function Ir(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=ie&&e.push(r)}),t.cursorWrapper&&e.push($.create(t.state.doc,[t.cursorWrapper.deco])),qe.from(e)}const Of={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},If=he&&Ye<=11;class Df{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class Rf{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Df,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let s=0;s<r.length;s++)this.queue.push(r[s]);he&&Ye<=11&&r.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():this.flush()}),If&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Of)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let n=0;n<e.length;n++)this.queue.push(e[n]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(ji(this.view)){if(this.suppressingSelectionUpdates)return $e(this.view);if(he&&Ye<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&xt(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let i=e.focusNode;i;i=Pt(i))n.add(i);for(let i=e.anchorNode;i;i=Pt(i))if(n.has(i)){r=i;break}let s=r&&this.view.docView.nearestDesc(r);if(s&&s.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),s=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&ji(e)&&!this.ignoreSelectionChange(r),i=-1,o=-1,l=!1,a=[];if(e.editable)for(let u=0;u<n.length;u++){let d=this.registerMutation(n[u],a);d&&(i=i<0?d.from:Math.min(d.from,i),o=o<0?d.to:Math.max(d.to,o),d.typeOver&&(l=!0))}if(xe&&a.length){let u=a.filter(d=>d.nodeName=="BR");if(u.length==2){let[d,h]=u;d.parentNode&&d.parentNode.parentNode==h.parentNode?h.remove():d.remove()}else{let{focusNode:d}=this.currentSelection;for(let h of u){let f=h.parentNode;f&&f.nodeName=="LI"&&(!d||zf(e,d)!=f)&&h.remove()}}}else if((Z||oe)&&a.some(u=>u.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let u of a)if(u.nodeName=="BR"&&u.parentNode){let d=u.nextSibling;d&&d.nodeType==1&&d.contentEditable=="false"&&u.parentNode.removeChild(u)}}let c=null;i<0&&s&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&lr(r)&&(c=Ls(e))&&c.eq(N.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,$e(e),this.currentSelection.set(r),e.scrollToSelection()):(i>-1||s)&&(i>-1&&(e.docView.markDirty(i,o),Lf(e)),this.handleDOMChange(i,o,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||$e(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;u<e.addedNodes.length;u++){let d=e.addedNodes[u];n.push(d),d.nodeType==3&&(this.lastChangedTextNode=d)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let s=e.previousSibling,i=e.nextSibling;if(he&&Ye<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:d,nextSibling:h}=e.addedNodes[u];(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(s=d),(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(i=h)}let o=s&&s.parentNode==e.target?re(s)+1:0,l=r.localPosFromDOM(e.target,o,-1),a=i&&i.parentNode==e.target?re(i):e.target.childNodes.length,c=r.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let Ui=new WeakMap,Ji=!1;function Lf(t){if(!Ui.has(t)&&(Ui.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=xe,Ji)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."),Ji=!0}}function Gi(t,e){let n=e.startContainer,r=e.startOffset,s=e.endContainer,i=e.endOffset,o=t.domAtPos(t.state.selection.anchor);return xt(o.node,o.offset,s,i)&&([n,r,s,i]=[s,i,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:i}}function Pf(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return Gi(t,s)}let n;function r(s){s.preventDefault(),s.stopImmediatePropagation(),n=s.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",r,!0),n?Gi(t,n):null}function zf(t,e){for(let n=e.parentNode;n&&n!=t.dom;n=n.parentNode){let r=t.docView.nearestDesc(n,!0);if(r&&r.node.isBlock)return n}return null}function Bf(t,e,n){let{node:r,fromOffset:s,toOffset:i,from:o,to:l}=t.docView.parseRange(e,n),a=t.domSelectionRange(),c,u=a.anchorNode;if(u&&t.dom.contains(u.nodeType==1?u:u.parentNode)&&(c=[{node:u,offset:a.anchorOffset}],lr(a)||c.push({node:a.focusNode,offset:a.focusOffset})),Z&&t.input.lastKeyCode===8)for(let g=i;g>s;g--){let b=r.childNodes[g-1],k=b.pmViewDesc;if(b.nodeName=="BR"&&!k){i=g;break}if(!k||k.size)break}let d=t.state.doc,h=t.someProp("domParser")||Xe.fromSchema(t.state.schema),f=d.resolve(o),p=null,m=h.parse(r,{topNode:f.parent,topMatch:f.parent.contentMatchAt(f.index()),topOpen:!0,from:s,to:i,preserveWhitespace:f.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:jf,context:f});if(c&&c[0].pos!=null){let g=c[0].pos,b=c[1]&&c[1].pos;b==null&&(b=g),p={anchor:g+o,head:b+o}}return{doc:m,sel:p,from:o,to:l}}function jf(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(oe&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}else if(t.parentNode.lastChild==t||oe&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const $f=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Ff(t,e,n,r,s){let i=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let M=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,D=Ls(t,M);if(D&&!t.state.selection.eq(D)){if(Z&&Be&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",De=>De(t,at(13,"Enter"))))return;let B=t.state.tr.setSelection(D);M=="pointer"?B.setMeta("pointer",!0):M=="key"&&B.scrollIntoView(),i&&B.setMeta("composition",i),t.dispatch(B)}return}let o=t.state.doc.resolve(e),l=o.sharedDepth(n);e=o.before(l+1),n=t.state.doc.resolve(n).after(l+1);let a=t.state.selection,c=Bf(t,e,n),u=t.state.doc,d=u.slice(c.from,c.to),h,f;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(h=t.state.selection.to,f="end"):(h=t.state.selection.from,f="start"),t.input.lastKeyCode=null;let p=_f(d.content,c.doc.content,c.from,h,f);if(p&&t.input.domChangeCount++,(zt&&t.input.lastIOSEnter>Date.now()-225||Be)&&s.some(M=>M.nodeType==1&&!$f.test(M.nodeName))&&(!p||p.endA>=p.endB)&&t.someProp("handleKeyDown",M=>M(t,at(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof E&&!a.empty&&a.$head.sameParent(a.$anchor)&&!t.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let M=Xi(t,t.state.doc,c.sel);if(M&&!M.eq(t.state.selection)){let D=t.state.tr.setSelection(M);i&&D.setMeta("composition",i),t.dispatch(D)}}return}t.state.selection.from<t.state.selection.to&&p.start==p.endB&&t.state.selection instanceof E&&(p.start>t.state.selection.from&&p.start<=t.state.selection.from+2&&t.state.selection.from>=c.from?p.start=t.state.selection.from:p.endA<t.state.selection.to&&p.endA>=t.state.selection.to-2&&t.state.selection.to<=c.to&&(p.endB+=t.state.selection.to-p.endA,p.endA=t.state.selection.to)),he&&Ye<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)=="  "&&(p.start--,p.endA--,p.endB--);let m=c.doc.resolveNoCache(p.start-c.from),g=c.doc.resolveNoCache(p.endB-c.from),b=u.resolve(p.start),k=m.sameParent(g)&&m.parent.inlineContent&&b.end()>=p.endA;if((zt&&t.input.lastIOSEnter>Date.now()-225&&(!k||s.some(M=>M.nodeName=="DIV"||M.nodeName=="P"))||!k&&m.pos<c.doc.content.size&&(!m.sameParent(g)||!m.parent.inlineContent)&&m.pos<g.pos&&!/\S/.test(c.doc.textBetween(m.pos,g.pos,"","")))&&t.someProp("handleKeyDown",M=>M(t,at(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>p.start&&Vf(u,p.start,p.endA,m,g)&&t.someProp("handleKeyDown",M=>M(t,at(8,"Backspace")))){Be&&Z&&t.domObserver.suppressSelectionUpdates();return}Z&&p.endB==p.start&&(t.input.lastChromeDelete=Date.now()),Be&&!k&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,g=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{t.someProp("handleKeyDown",function(M){return M(t,at(13,"Enter"))})},20));let w=p.start,C=p.endA,v=M=>{let D=M||t.state.tr.replace(w,C,c.doc.slice(p.start-c.from,p.endB-c.from));if(c.sel){let B=Xi(t,D.doc,c.sel);B&&!(Z&&t.composing&&B.empty&&(p.start!=p.endB||t.input.lastChromeDelete<Date.now()-100)&&(B.head==w||B.head==D.mapping.map(C)-1)||he&&B.empty&&B.head==w)&&D.setSelection(B)}return i&&D.setMeta("composition",i),D.scrollIntoView()},I;if(k)if(m.pos==g.pos){he&&Ye<=11&&m.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>$e(t),20));let M=v(t.state.tr.delete(w,C)),D=u.resolve(p.start).marksAcross(u.resolve(p.endA));D&&M.ensureMarks(D),t.dispatch(M)}else if(p.endA==p.endB&&(I=Hf(m.parent.content.cut(m.parentOffset,g.parentOffset),b.parent.content.cut(b.parentOffset,p.endA-b.start())))){let M=v(t.state.tr);I.type=="add"?M.addMark(w,C,I.mark):M.removeMark(w,C,I.mark),t.dispatch(M)}else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let M=m.parent.textBetween(m.parentOffset,g.parentOffset),D=()=>v(t.state.tr.insertText(M,w,C));t.someProp("handleTextInput",B=>B(t,w,C,M,D))||t.dispatch(D())}else t.dispatch(v());else t.dispatch(v())}function Xi(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:Ps(t,e.resolve(n.anchor),e.resolve(n.head))}function Hf(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,s=n,i=r,o,l,a;for(let u=0;u<r.length;u++)s=r[u].removeFromSet(s);for(let u=0;u<n.length;u++)i=n[u].removeFromSet(i);if(s.length==1&&i.length==0)l=s[0],o="add",a=u=>u.mark(l.addToSet(u.marks));else if(s.length==0&&i.length==1)l=i[0],o="remove",a=u=>u.mark(l.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<e.childCount;u++)c.push(a(e.child(u)));if(x.from(c).eq(t))return{mark:l,type:o}}function Vf(t,e,n,r,s){if(n-e<=s.pos-r.pos||Dr(r,!0,!1)<s.pos)return!1;let i=t.resolve(e);if(!r.parent.isTextblock){let l=i.nodeAfter;return l!=null&&n==e+l.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let o=t.resolve(Dr(i,!0,!0));return!o.parent.isTextblock||o.pos>n||Dr(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function Dr(t,e,n){let r=t.depth,s=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,s++,e=!1;if(n){let i=t.node(r).maybeChild(t.indexAfter(r));for(;i&&!i.isLeaf;)i=i.firstChild,s++}return s}function _f(t,e,n,r,s){let i=t.findDiffStart(e,n);if(i==null)return null;let{a:o,b:l}=t.findDiffEnd(e,n+t.size,n+e.size);if(s=="end"){let a=Math.max(0,i-Math.min(o,l));r-=o+a-i}if(o<i&&t.size<e.size){let a=r<=i&&r>=o?i-r:0;i-=a,i&&i<e.size&&Yi(e.textBetween(i-1,i+1))&&(i+=a?1:-1),l=i+(l-o),o=i}else if(l<i){let a=r<=i&&r>=l?i-r:0;i-=a,i&&i<t.size&&Yi(t.textBetween(i-1,i+1))&&(i+=a?1:-1),o=i+(o-l),l=i}return{start:i,endA:o,endB:l}}function Yi(t){if(t.length!=2)return!1;let e=t.charCodeAt(0),n=t.charCodeAt(1);return e>=56320&&e<=57343&&n>=55296&&n<=56319}class Na{constructor(e,n){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new of,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(no),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=eo(this),Qi(this),this.nodeViews=to(this),this.docView=Di(this.state.doc,Zi(this),Ir(this),this.dom,this),this.domObserver=new Rf(this,(r,s,i,o)=>Ff(this,r,s,i,o)),this.domObserver.start(),lf(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&ts(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(no),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let s=this.state,i=!1,o=!1;e.storedMarks&&this.composing&&(Sa(this),o=!0),this.state=e;let l=s.plugins!=e.plugins||this._props.plugins!=n.plugins;if(l||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let f=to(this);qf(f,this.nodeViews)&&(this.nodeViews=f,i=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&ts(this),this.editable=eo(this),Qi(this);let a=Ir(this),c=Zi(this),u=s.plugins!=e.plugins&&!s.doc.eq(e.doc)?"reset":e.scrollToSelection>s.scrollToSelection?"to selection":"preserve",d=i||!this.docView.matchesNode(e.doc,c,a);(d||!e.selection.eq(s.selection))&&(o=!0);let h=u=="preserve"&&o&&this.dom.style.overflowAnchor==null&&kh(this);if(o){this.domObserver.stop();let f=d&&(he||Z)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&Wf(s.selection,e.selection);if(d){let p=Z?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=wf(this)),(i||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Di(e.doc,c,a,this.dom,this)),p&&!this.trackWrites&&(f=!0)}f||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Wh(this))?$e(this,f):(ua(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(s),!((r=this.dragging)===null||r===void 0)&&r.node&&!s.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,s),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():h&&wh(h)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof A){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&Ti(this,n.getBoundingClientRect(),e)}else Ti(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n<this.directPlugins.length;n++){let r=this.directPlugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let r=this.state.plugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let r=this.pluginViews[n];r.update&&r.update(this,e)}}updateDraggedNode(e,n){let r=e.node,s=-1;if(this.state.doc.nodeAt(r.from)==r.node)s=r.from;else{let i=r.from+(this.state.doc.content.size-n.doc.content.size);(i>0&&this.state.doc.nodeAt(i))==r.node&&(s=i)}this.dragging=new va(e.slice,e.move,s<0?void 0:A.create(this.state.doc,s))}someProp(e,n){let r=this._props&&this._props[e],s;if(r!=null&&(s=n?n(r):r))return s;for(let o=0;o<this.directPlugins.length;o++){let l=this.directPlugins[o].props[e];if(l!=null&&(s=n?n(l):l))return s}let i=this.state.plugins;if(i)for(let o=0;o<i.length;o++){let l=i[o].props[e];if(l!=null&&(s=n?n(l):l))return s}}hasFocus(){if(he){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&Sh(this.dom),$e(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let n=this.dom.parentNode;n;n=n.parentNode)if(n.nodeType==9||n.nodeType==11&&n.host)return n.getSelection||(Object.getPrototypeOf(n).getSelection=()=>n.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Eh(this,e)}coordsAtPos(e,n=1){return na(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let s=this.docView.posFromDOM(e,n,r);if(s==null)throw new RangeError("DOM position not inside the editor");return s}endOfTextblock(e,n){return Dh(this,n||this.state,e)}pasteHTML(e,n){return sn(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return sn(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return zs(this,e)}destroy(){this.docView&&(af(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Ir(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,uh())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return uf(this,e)}domSelectionRange(){let e=this.domSelection();return e?oe&&this.root.nodeType===11&&mh(this.dom.ownerDocument)==this.dom&&Pf(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}Na.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function Zi(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let r in n)r=="class"?e.class+=" "+n[r]:r=="style"?e.style=(e.style?e.style+";":"")+n[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(n[r]))}),e.translate||(e.translate="no"),[G.node(0,t.state.doc.content.size,e)]}function Qi(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:G.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function eo(t){return!t.someProp("editable",e=>e(t.state)===!1)}function Wf(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}function to(t){let e=Object.create(null);function n(r){for(let s in r)Object.prototype.hasOwnProperty.call(e,s)||(e[s]=r[s])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function qf(t,e){let n=0,r=0;for(let s in t){if(t[s]!=e[s])return!0;n++}for(let s in e)r++;return n!=r}function no(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var nt={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:"'"},Un={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Kf=typeof navigator<"u"&&/Mac/.test(navigator.platform),Uf=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var se=0;se<10;se++)nt[48+se]=nt[96+se]=String(se);for(var se=1;se<=24;se++)nt[se+111]="F"+se;for(var se=65;se<=90;se++)nt[se]=String.fromCharCode(se+32),Un[se]=String.fromCharCode(se);for(var Rr in nt)Un.hasOwnProperty(Rr)||(Un[Rr]=nt[Rr]);function Jf(t){var e=Kf&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||Uf&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Un:nt)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}const Gf=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Xf=typeof navigator<"u"&&/Win/.test(navigator.platform);function Yf(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,s,i,o;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))Gf?o=!0:s=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(n="Alt-"+n),s&&(n="Ctrl-"+n),o&&(n="Meta-"+n),i&&(n="Shift-"+n),n}function Zf(t){let e=Object.create(null);for(let n in t)e[Yf(n)]=t[n];return e}function Lr(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 Qf(t){return new H({props:{handleKeyDown:Vs(t)}})}function Vs(t){let e=Zf(t);return function(n,r){let s=Jf(r),i,o=e[Lr(s,r)];if(o&&o(n.state,n.dispatch,n))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let l=e[Lr(s,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(Xf&&r.ctrlKey&&r.altKey)&&(i=nt[r.keyCode])&&i!=s){let l=e[Lr(i,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var ep=Object.defineProperty,_s=(t,e)=>{for(var n in e)ep(t,n,{get:e[n],enumerable:!0})};function ur(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:s}=n,{storedMarks:i}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return i},get selection(){return r},get doc(){return s},get tr(){return r=n.selection,s=n.doc,i=n.storedMarks,n}}}var dr=class{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:r}=e,{tr:s}=n,i=this.buildProps(s);return Object.fromEntries(Object.entries(t).map(([o,l])=>[o,(...c)=>{const u=l(...c)(i);return!s.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(s),u}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:s}=this,{view:i}=r,o=[],l=!!t,a=t||s.tr,c=()=>(!l&&e&&!a.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(a),o.every(d=>d===!0)),u={...Object.fromEntries(Object.entries(n).map(([d,h])=>[d,(...p)=>{const m=this.buildProps(a,e),g=h(...p)(m);return o.push(g),u}])),run:c};return u}createCan(t){const{rawCommands:e,state:n}=this,r=!1,s=t||n.tr,i=this.buildProps(s,r);return{...Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...c)=>a(...c)({...i,dispatch:void 0})])),chain:()=>this.createChain(s,r)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:s}=this,{view:i}=r,o={tr:t,editor:r,view:i,state:ur({state:s,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map(([l,a])=>[l,(...c)=>a(...c)(o)]))}};return o}},Oa={};_s(Oa,{blur:()=>tp,clearContent:()=>np,clearNodes:()=>rp,command:()=>sp,createParagraphNear:()=>ip,cut:()=>op,deleteCurrentNode:()=>lp,deleteNode:()=>ap,deleteRange:()=>cp,deleteSelection:()=>up,enter:()=>dp,exitCode:()=>hp,extendMarkRange:()=>fp,first:()=>pp,focus:()=>gp,forEach:()=>yp,insertContent:()=>bp,insertContentAt:()=>wp,joinBackward:()=>vp,joinDown:()=>Cp,joinForward:()=>Mp,joinItemBackward:()=>Tp,joinItemForward:()=>Ep,joinTextblockBackward:()=>Ap,joinTextblockForward:()=>Np,joinUp:()=>Sp,keyboardShortcut:()=>Ip,lift:()=>Dp,liftEmptyBlock:()=>Rp,liftListItem:()=>Lp,newlineInCode:()=>Pp,resetAttributes:()=>zp,scrollIntoView:()=>Bp,selectAll:()=>jp,selectNodeBackward:()=>$p,selectNodeForward:()=>Fp,selectParentNode:()=>Hp,selectTextblockEnd:()=>Vp,selectTextblockStart:()=>_p,setContent:()=>Wp,setMark:()=>cm,setMeta:()=>um,setNode:()=>dm,setNodeSelection:()=>hm,setTextDirection:()=>fm,setTextSelection:()=>pm,sinkListItem:()=>mm,splitBlock:()=>gm,splitListItem:()=>ym,toggleList:()=>bm,toggleMark:()=>xm,toggleNode:()=>km,toggleWrap:()=>wm,undoInputRule:()=>Sm,unsetAllMarks:()=>Cm,unsetMark:()=>vm,unsetTextDirection:()=>Mm,updateAttributes:()=>Tm,wrapIn:()=>Em,wrapInList:()=>Am});var tp=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window==null?void 0:window.getSelection())==null||n.removeAllRanges())}),!0),np=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),rp=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:s}=r;return n&&s.forEach(({$from:i,$to:o})=>{t.doc.nodesBetween(i.pos,o.pos,(l,a)=>{if(l.type.isText)return;const{doc:c,mapping:u}=e,d=c.resolve(u.map(a)),h=c.resolve(u.map(a+l.nodeSize)),f=d.blockRange(h);if(!f)return;const p=Ft(f);if(l.type.isTextblock){const{defaultType:m}=d.parent.contentMatchAt(d.index());e.setNodeMarkup(f.start,m)}(p||p===0)&&e.lift(f,p)})}),!0},sp=t=>e=>t(e),ip=()=>({state:t,dispatch:e})=>ql(t,e),op=(t,e)=>({editor:n,tr:r})=>{const{state:s}=n,i=s.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const o=r.mapping.map(e);return r.insert(o,i.content),r.setSelection(new E(r.doc.resolve(Math.max(o-1,0)))),!0},lp=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const s=t.selection.$anchor;for(let i=s.depth;i>0;i-=1)if(s.node(i).type===r.type){if(e){const l=s.before(i),a=s.after(i);t.delete(l,a).scrollIntoView()}return!0}return!1};function U(t,e){if(typeof t=="string"){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}var ap=t=>({tr:e,state:n,dispatch:r})=>{const s=U(t,n.schema),i=e.selection.$anchor;for(let o=i.depth;o>0;o-=1)if(i.node(o).type===s){if(r){const a=i.before(o),c=i.after(o);e.delete(a,c).scrollIntoView()}return!0}return!1},cp=t=>({tr:e,dispatch:n})=>{const{from:r,to:s}=t;return n&&e.delete(r,s),!0},up=()=>({state:t,dispatch:e})=>As(t,e),dp=()=>({commands:t})=>t.keyboardShortcut("Enter"),hp=()=>({state:t,dispatch:e})=>Gd(t,e);function Ws(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function Jn(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(s=>n.strict?e[s]===t[s]:Ws(e[s])?e[s].test(t[s]):e[s]===t[s]):!0}function Ia(t,e,n={}){return t.find(r=>r.type===e&&Jn(Object.fromEntries(Object.keys(n).map(s=>[s,r.attrs[s]])),n))}function ro(t,e,n={}){return!!Ia(t,e,n)}function qs(t,e,n){var r;if(!t||!e)return;let s=t.parent.childAfter(t.parentOffset);if((!s.node||!s.node.marks.some(u=>u.type===e))&&(s=t.parent.childBefore(t.parentOffset)),!s.node||!s.node.marks.some(u=>u.type===e)||(n=n||((r=s.node.marks[0])==null?void 0:r.attrs),!Ia([...s.node.marks],e,n)))return;let o=s.index,l=t.start()+s.offset,a=o+1,c=l+s.node.nodeSize;for(;o>0&&ro([...t.parent.child(o-1).marks],e,n);)o-=1,l-=t.parent.child(o).nodeSize;for(;a<t.parent.childCount&&ro([...t.parent.child(a).marks],e,n);)c+=t.parent.child(a).nodeSize,a+=1;return{from:l,to:c}}function Fe(t,e){if(typeof t=="string"){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}var fp=(t,e={})=>({tr:n,state:r,dispatch:s})=>{const i=Fe(t,r.schema),{doc:o,selection:l}=n,{$from:a,from:c,to:u}=l;if(s){const d=qs(a,i,e);if(d&&d.from<=c&&d.to>=u){const h=E.create(o,d.from,d.to);n.setSelection(h)}}return!0},pp=t=>e=>{const n=typeof t=="function"?t(e):t;for(let r=0;r<n.length;r+=1)if(n[r](e))return!0;return!1};function Da(t){return t instanceof E}function dt(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function Ra(t,e=null){if(!e)return null;const n=N.atStart(t),r=N.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const s=n.from,i=r.to;return e==="all"?E.create(t,dt(0,s,i),dt(t.content.size,s,i)):E.create(t,dt(e,s,i),dt(e,s,i))}function so(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function Gn(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function mp(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var gp=(t=null,e={})=>({editor:n,view:r,tr:s,dispatch:i})=>{e={scrollIntoView:!0,...e};const o=()=>{(Gn()||so())&&r.dom.focus(),mp()&&!Gn()&&!so()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e!=null&&e.scrollIntoView&&n.commands.scrollIntoView())})};try{if(r.hasFocus()&&t===null||t===!1)return!0}catch{return!1}if(i&&t===null&&!Da(n.state.selection))return o(),!0;const l=Ra(s.doc,t)||n.state.selection,a=n.state.selection.eq(l);return i&&(a||s.setSelection(l),a&&s.storedMarks&&s.setStoredMarks(s.storedMarks),o()),!0},yp=(t,e)=>n=>t.every((r,s)=>e(r,{...n,index:s})),bp=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),La=t=>{const e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){const r=e[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?t.removeChild(r):r.nodeType===1&&La(r)}return t};function xn(t){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${t}</body>`,n=new window.DOMParser().parseFromString(e,"text/html").body;return La(n)}function ln(t,e,n){if(t instanceof ve||t instanceof x)return t;n={slice:!0,parseOptions:{},...n};const r=typeof t=="object"&&t!==null,s=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return x.fromArray(t.map(l=>e.nodeFromJSON(l)));const o=e.nodeFromJSON(t);return n.errorOnInvalidContent&&o.check(),o}catch(i){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:i});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",i),ln("",e,n)}if(s){if(n.errorOnInvalidContent){let o=!1,l="";const a=new bl({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(o=!0,l=typeof c=="string"?c:c.outerHTML,null)}]}})});if(n.slice?Xe.fromSchema(a).parseSlice(xn(t),n.parseOptions):Xe.fromSchema(a).parse(xn(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const i=Xe.fromSchema(e);return n.slice?i.parseSlice(xn(t),n.parseOptions).content:i.parse(xn(t),n.parseOptions)}return ln("",e,n)}function xp(t,e,n){const r=t.steps.length-1;if(r<e)return;const s=t.steps[r];if(!(s instanceof Y||s instanceof Q))return;const i=t.mapping.maps[r];let o=0;i.forEach((l,a,c,u)=>{o===0&&(o=u)}),t.setSelection(N.near(t.doc.resolve(o),n))}var kp=t=>!("type"in t),wp=(t,e,n)=>({tr:r,dispatch:s,editor:i})=>{var o;if(s){n={parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let l;const a=g=>{i.emit("contentError",{editor:i,error:g,disableCollaboration:()=>{"collaboration"in i.storage&&typeof i.storage.collaboration=="object"&&i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!i.options.enableContentCheck&&i.options.emitContentError)try{ln(e,i.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(g){a(g)}try{l=ln(e,i.schema,{parseOptions:c,errorOnInvalidContent:(o=n.errorOnInvalidContent)!=null?o:i.options.enableContentCheck})}catch(g){return a(g),!1}let{from:u,to:d}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},h=!0,f=!0;if((kp(l)?l:[l]).forEach(g=>{g.check(),h=h?g.isText&&g.marks.length===0:!1,f=f?g.isBlock:!1}),u===d&&f){const{parent:g}=r.doc.resolve(u);g.isTextblock&&!g.type.spec.code&&!g.childCount&&(u-=1,d+=1)}let m;if(h){if(Array.isArray(e))m=e.map(g=>g.text||"").join("");else if(e instanceof x){let g="";e.forEach(b=>{b.text&&(g+=b.text)}),m=g}else typeof e=="object"&&e&&e.text?m=e.text:m=e;r.insertText(m,u,d)}else{m=l;const g=r.doc.resolve(u),b=g.node(),k=g.parentOffset===0,w=b.isText||b.isTextblock,C=b.content.size>0;k&&w&&C&&(u=Math.max(0,u-1)),r.replaceWith(u,d,m)}n.updateSelection&&xp(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:u,text:m}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:u,text:m})}return!0},Sp=()=>({state:t,dispatch:e})=>Kd(t,e),Cp=()=>({state:t,dispatch:e})=>Ud(t,e),vp=()=>({state:t,dispatch:e})=>jl(t,e),Mp=()=>({state:t,dispatch:e})=>Vl(t,e),Tp=()=>({state:t,dispatch:e,tr:n})=>{try{const r=sr(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},Ep=()=>({state:t,dispatch:e,tr:n})=>{try{const r=sr(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},Ap=()=>({state:t,dispatch:e})=>Wd(t,e),Np=()=>({state:t,dispatch:e})=>qd(t,e);function Pa(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function Op(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,s,i,o;for(let l=0;l<e.length-1;l+=1){const a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))Gn()||Pa()?o=!0:s=!0;else throw new Error(`Unrecognized modifier name: ${a}`)}return r&&(n=`Alt-${n}`),s&&(n=`Ctrl-${n}`),o&&(n=`Meta-${n}`),i&&(n=`Shift-${n}`),n}var Ip=t=>({editor:e,view:n,tr:r,dispatch:s})=>{const i=Op(t).split(/-(?!$)/),o=i.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction(()=>{n.someProp("handleKeyDown",c=>c(n,l))});return a==null||a.steps.forEach(c=>{const u=c.map(r.mapping);u&&s&&r.maybeStep(u)}),!0};function rt(t,e,n={}){const{from:r,to:s,empty:i}=t.selection,o=e?U(e,t.schema):null,l=[];t.doc.nodesBetween(r,s,(d,h)=>{if(d.isText)return;const f=Math.max(r,h),p=Math.min(s,h+d.nodeSize);l.push({node:d,from:f,to:p})});const a=s-r,c=l.filter(d=>o?o.name===d.node.type.name:!0).filter(d=>Jn(d.node.attrs,n,{strict:!1}));return i?!!c.length:c.reduce((d,h)=>d+h.to-h.from,0)>=a}var Dp=(t,e={})=>({state:n,dispatch:r})=>{const s=U(t,n.schema);return rt(n,s,e)?Jd(n,r):!1},Rp=()=>({state:t,dispatch:e})=>Kl(t,e),Lp=t=>({state:e,dispatch:n})=>{const r=U(t,e.schema);return oh(r)(e,n)},Pp=()=>({state:t,dispatch:e})=>Wl(t,e);function hr(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function io(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,s)=>(n.includes(s)||(r[s]=t[s]),r),{})}var zp=(t,e)=>({tr:n,state:r,dispatch:s})=>{let i=null,o=null;const l=hr(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(i=U(t,r.schema)),l==="mark"&&(o=Fe(t,r.schema));let a=!1;return n.selection.ranges.forEach(c=>{r.doc.nodesBetween(c.$from.pos,c.$to.pos,(u,d)=>{i&&i===u.type&&(a=!0,s&&n.setNodeMarkup(d,void 0,io(u.attrs,e))),o&&u.marks.length&&u.marks.forEach(h=>{o===h.type&&(a=!0,s&&n.addMark(d,d+u.nodeSize,o.create(io(h.attrs,e))))})})}),a},Bp=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),jp=()=>({tr:t,dispatch:e})=>{if(e){const n=new de(t.doc);t.setSelection(n)}return!0},$p=()=>({state:t,dispatch:e})=>Fl(t,e),Fp=()=>({state:t,dispatch:e})=>_l(t,e),Hp=()=>({state:t,dispatch:e})=>Zd(t,e),Vp=()=>({state:t,dispatch:e})=>th(t,e),_p=()=>({state:t,dispatch:e})=>eh(t,e);function ns(t,e,n={},r={}){return ln(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var Wp=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:s,tr:i,dispatch:o,commands:l})=>{const{doc:a}=i;if(r.preserveWhitespace!=="full"){const c=ns(t,s.schema,r,{errorOnInvalidContent:e??s.options.enableContentCheck});return o&&i.replaceWith(0,a.content.size,c).setMeta("preventUpdate",!n),!0}return o&&i.setMeta("preventUpdate",!n),l.insertContentAt({from:0,to:a.content.size},t,{parseOptions:r,errorOnInvalidContent:e??s.options.enableContentCheck})};function za(t,e){const n=Fe(e,t.schema),{from:r,to:s,empty:i}=t.selection,o=[];i?(t.storedMarks&&o.push(...t.storedMarks),o.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,s,a=>{o.push(...a.marks)});const l=o.find(a=>a.type.name===n.name);return l?{...l.attrs}:{}}function Ba(t,e){const n=new Ts(t);return e.forEach(r=>{r.steps.forEach(s=>{n.step(s)})}),n}function qp(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}function rs(t,e){const n=[];return t.descendants((r,s)=>{e(r)&&n.push({node:r,pos:s})}),n}function Kp(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(s,i)=>{n(s)&&r.push({node:s,pos:i})}),r}function ja(t,e){for(let n=t.depth;n>0;n-=1){const r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}function fr(t){return e=>ja(e.$from,t)}function T(t,e,n){return t.config[e]===void 0&&t.parent?T(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?T(t.parent,e,n):null}):t.config[e]}function Ks(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=T(e,"addExtensions",n);return r?[e,...Ks(r())]:e}).flat(10)}function Us(t,e){const n=Ct.fromSchema(e).serializeFragment(t),s=document.implementation.createHTMLDocument().createElement("div");return s.appendChild(n),s.innerHTML}function $a(t){return typeof t=="function"}function P(t,e=void 0,...n){return $a(t)?e?t.bind(e)(...n):t(...n):t}function Up(t={}){return Object.keys(t).length===0&&t.constructor===Object}function Bt(t){const e=t.filter(s=>s.type==="extension"),n=t.filter(s=>s.type==="node"),r=t.filter(s=>s.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:r}}function Fa(t){const e=[],{nodeExtensions:n,markExtensions:r}=Bt(t),s=[...n,...r],i={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage,extensions:s},a=T(o,"addGlobalAttributes",l);if(!a)return;a().forEach(u=>{u.types.forEach(d=>{Object.entries(u.attributes).forEach(([h,f])=>{e.push({type:d,name:h,attribute:{...i,...f}})})})})}),s.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage},a=T(o,"addAttributes",l);if(!a)return;const c=a();Object.entries(c).forEach(([u,d])=>{const h={...i,...d};typeof(h==null?void 0:h.default)=="function"&&(h.default=h.default()),h!=null&&h.isRequired&&(h==null?void 0:h.default)===void 0&&delete h.default,e.push({type:o.name,name:u,attribute:h})})}),e}function z(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([s,i])=>{if(!r[s]){r[s]=i;return}if(s==="class"){const l=i?String(i).split(" "):[],a=r[s]?r[s].split(" "):[],c=l.filter(u=>!a.includes(u));r[s]=[...a,...c].join(" ")}else if(s==="style"){const l=i?i.split(";").map(u=>u.trim()).filter(Boolean):[],a=r[s]?r[s].split(";").map(u=>u.trim()).filter(Boolean):[],c=new Map;a.forEach(u=>{const[d,h]=u.split(":").map(f=>f.trim());c.set(d,h)}),l.forEach(u=>{const[d,h]=u.split(":").map(f=>f.trim());c.set(d,h)}),r[s]=Array.from(c.entries()).map(([u,d])=>`${u}: ${d}`).join("; ")}else r[s]=i}),r},{})}function Xn(t,e){return e.filter(n=>n.type===t.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(t.attrs)||{}:{[n.name]:t.attrs[n.name]}).reduce((n,r)=>z(n,r),{})}function Jp(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function oo(t,e){return"style"in t?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;const s=e.reduce((i,o)=>{const l=o.attribute.parseHTML?o.attribute.parseHTML(n):Jp(n.getAttribute(o.name));return l==null?i:{...i,[o.name]:l}},{});return{...r,...s}}}}function lo(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&Up(n)?!1:n!=null))}function ao(t){var e,n;const r={};return!((e=t==null?void 0:t.attribute)!=null&&e.isRequired)&&"default"in((t==null?void 0:t.attribute)||{})&&(r.default=t.attribute.default),((n=t==null?void 0:t.attribute)==null?void 0:n.validate)!==void 0&&(r.validate=t.attribute.validate),[t.name,r]}function Gp(t,e){var n;const r=Fa(t),{nodeExtensions:s,markExtensions:i}=Bt(t),o=(n=s.find(c=>T(c,"topNode")))==null?void 0:n.name,l=Object.fromEntries(s.map(c=>{const u=r.filter(b=>b.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},h=t.reduce((b,k)=>{const w=T(k,"extendNodeSchema",d);return{...b,...w?w(c):{}}},{}),f=lo({...h,content:P(T(c,"content",d)),marks:P(T(c,"marks",d)),group:P(T(c,"group",d)),inline:P(T(c,"inline",d)),atom:P(T(c,"atom",d)),selectable:P(T(c,"selectable",d)),draggable:P(T(c,"draggable",d)),code:P(T(c,"code",d)),whitespace:P(T(c,"whitespace",d)),linebreakReplacement:P(T(c,"linebreakReplacement",d)),defining:P(T(c,"defining",d)),isolating:P(T(c,"isolating",d)),attrs:Object.fromEntries(u.map(ao))}),p=P(T(c,"parseHTML",d));p&&(f.parseDOM=p.map(b=>oo(b,u)));const m=T(c,"renderHTML",d);m&&(f.toDOM=b=>m({node:b,HTMLAttributes:Xn(b,u)}));const g=T(c,"renderText",d);return g&&(f.toText=g),[c.name,f]})),a=Object.fromEntries(i.map(c=>{const u=r.filter(g=>g.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},h=t.reduce((g,b)=>{const k=T(b,"extendMarkSchema",d);return{...g,...k?k(c):{}}},{}),f=lo({...h,inclusive:P(T(c,"inclusive",d)),excludes:P(T(c,"excludes",d)),group:P(T(c,"group",d)),spanning:P(T(c,"spanning",d)),code:P(T(c,"code",d)),attrs:Object.fromEntries(u.map(ao))}),p=P(T(c,"parseHTML",d));p&&(f.parseDOM=p.map(g=>oo(g,u)));const m=T(c,"renderHTML",d);return m&&(f.toDOM=g=>m({mark:g,HTMLAttributes:Xn(g,u)})),[c.name,f]}));return new bl({topNode:o,nodes:l,marks:a})}function Xp(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function Yn(t){return t.sort((n,r)=>{const s=T(n,"priority")||100,i=T(r,"priority")||100;return s>i?-1:s<i?1:0})}function Ha(t){const e=Yn(Ks(t)),n=Xp(e.map(r=>r.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),e}function Va(t,e,n){const{from:r,to:s}=e,{blockSeparator:i=`

`,textSerializers:o={}}=n||{};let l="";return t.nodesBetween(r,s,(a,c,u,d)=>{var h;a.isBlock&&c>r&&(l+=i);const f=o==null?void 0:o[a.type.name];if(f)return u&&(l+=f({node:a,pos:c,parent:u,index:d,range:e})),!1;a.isText&&(l+=(h=a==null?void 0:a.text)==null?void 0:h.slice(Math.max(r,c)-c,s-c))}),l}function Yp(t,e){const n={from:0,to:t.content.size};return Va(t,n,e)}function _a(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function Zp(t,e){const n=U(e,t.schema),{from:r,to:s}=t.selection,i=[];t.doc.nodesBetween(r,s,l=>{i.push(l)});const o=i.reverse().find(l=>l.type.name===n.name);return o?{...o.attrs}:{}}function Wa(t,e){const n=hr(typeof e=="string"?e:e.name,t.schema);return n==="node"?Zp(t,e):n==="mark"?za(t,e):{}}function Qp(t,e=JSON.stringify){const n={};return t.filter(r=>{const s=e(r);return Object.prototype.hasOwnProperty.call(n,s)?!1:n[s]=!0})}function em(t){const e=Qp(t);return e.length===1?e:e.filter((n,r)=>!e.filter((i,o)=>o!==r).some(i=>n.oldRange.from>=i.oldRange.from&&n.oldRange.to<=i.oldRange.to&&n.newRange.from>=i.newRange.from&&n.newRange.to<=i.newRange.to))}function qa(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((s,i)=>{const o=[];if(s.ranges.length)s.forEach((l,a)=>{o.push({from:l,to:a})});else{const{from:l,to:a}=n[i];if(l===void 0||a===void 0)return;o.push({from:l,to:a})}o.forEach(({from:l,to:a})=>{const c=e.slice(i).map(l,-1),u=e.slice(i).map(a),d=e.invert().map(c,-1),h=e.invert().map(u);r.push({oldRange:{from:d,to:h},newRange:{from:c,to:u}})})}),em(r)}function Js(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(s=>{const i=n.resolve(t),o=qs(i,s.type);o&&r.push({mark:s,...o})}):n.nodesBetween(t,e,(s,i)=>{!s||(s==null?void 0:s.nodeSize)===void 0||r.push(...s.marks.map(o=>({from:i,to:i+s.nodeSize,mark:o})))}),r}var tm=(t,e,n,r=20)=>{const s=t.doc.resolve(n);let i=r,o=null;for(;i>0&&o===null;){const l=s.node(i);(l==null?void 0:l.type.name)===e?o=l:i-=1}return[o,i]};function kn(t,e){return e.nodes[t]||e.marks[t]||null}function Dn(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const s=t.find(i=>i.type===e&&i.name===r);return s?s.attribute.keepOnSplit:!1}))}var nm=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(s,i,o,l)=>{var a,c;const u=((c=(a=s.type.spec).toText)==null?void 0:c.call(a,{node:s,pos:i,parent:o,index:l}))||s.textContent||"%leaf%";n+=s.isAtom&&!s.isText?u:u.slice(0,Math.max(0,r-i))}),n};function ss(t,e,n={}){const{empty:r,ranges:s}=t.selection,i=e?Fe(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(d=>i?i.name===d.type.name:!0).find(d=>Jn(d.attrs,n,{strict:!1}));let o=0;const l=[];if(s.forEach(({$from:d,$to:h})=>{const f=d.pos,p=h.pos;t.doc.nodesBetween(f,p,(m,g)=>{if(!m.isText&&!m.marks.length)return;const b=Math.max(f,g),k=Math.min(p,g+m.nodeSize),w=k-b;o+=w,l.push(...m.marks.map(C=>({mark:C,from:b,to:k})))})}),o===0)return!1;const a=l.filter(d=>i?i.name===d.mark.type.name:!0).filter(d=>Jn(d.mark.attrs,n,{strict:!1})).reduce((d,h)=>d+h.to-h.from,0),c=l.filter(d=>i?d.mark.type!==i&&d.mark.type.excludes(i):!0).reduce((d,h)=>d+h.to-h.from,0);return(a>0?a+c:a)>=o}function rm(t,e,n={}){if(!e)return rt(t,null,n)||ss(t,null,n);const r=hr(e,t.schema);return r==="node"?rt(t,e,n):r==="mark"?ss(t,e,n):!1}var sm=(t,e)=>{const{$from:n,$to:r,$anchor:s}=t.selection;if(e){const i=fr(l=>l.type.name===e)(t.selection);if(!i)return!1;const o=t.doc.resolve(i.pos+1);return s.pos+1===o.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},im=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function co(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function uo(t,e){const{nodeExtensions:n}=Bt(e),r=n.find(o=>o.name===t);if(!r)return!1;const s={name:r.name,options:r.options,storage:r.storage},i=P(T(r,"group",s));return typeof i!="string"?!1:i.split(" ").includes("list")}function pr(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return/^\s*$/m.test((r=t.text)!=null?r:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let s=!0;return t.content.forEach(i=>{s!==!1&&(pr(i,{ignoreWhitespace:n,checkChildren:e})||(s=!1))}),s}return!1}function Ka(t){return t instanceof A}var Ua=class Ja{constructor(e){this.position=e}static fromJSON(e){return new Ja(e.position)}toJSON(){return{position:this.position}}};function om(t,e){const n=e.mapping.mapResult(t.position);return{position:new Ua(n.pos),mapResult:n}}function lm(t){return new Ua(t)}function am(t,e,n){var r;const{selection:s}=e;let i=null;if(Da(s)&&(i=s.$cursor),i){const l=(r=t.storedMarks)!=null?r:i.marks();return i.parent.type.allowsMarkType(n)&&(!!n.isInSet(l)||!l.some(c=>c.type.excludes(n)))}const{ranges:o}=s;return o.some(({$from:l,$to:a})=>{let c=l.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(l.pos,a.pos,(u,d,h)=>{if(c)return!1;if(u.isInline){const f=!h||h.type.allowsMarkType(n),p=!!n.isInSet(u.marks)||!u.marks.some(m=>m.type.excludes(n));c=f&&p}return!c}),c})}var cm=(t,e={})=>({tr:n,state:r,dispatch:s})=>{const{selection:i}=n,{empty:o,ranges:l}=i,a=Fe(t,r.schema);if(s)if(o){const c=za(r,a);n.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{const u=c.$from.pos,d=c.$to.pos;r.doc.nodesBetween(u,d,(h,f)=>{const p=Math.max(f,u),m=Math.min(f+h.nodeSize,d);h.marks.find(b=>b.type===a)?h.marks.forEach(b=>{a===b.type&&n.addMark(p,m,a.create({...b.attrs,...e}))}):n.addMark(p,m,a.create(e))})});return am(r,n,a)},um=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),dm=(t,e={})=>({state:n,dispatch:r,chain:s})=>{const i=U(t,n.schema);let o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),i.isTextblock?s().command(({commands:l})=>Ci(i,{...o,...e})(n)?!0:l.clearNodes()).command(({state:l})=>Ci(i,{...o,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},hm=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,s=dt(t,0,r.content.size),i=A.create(r,s);e.setSelection(i)}return!0},fm=(t,e)=>({tr:n,state:r,dispatch:s})=>{const{selection:i}=r;let o,l;return typeof e=="number"?(o=e,l=e):e&&"from"in e&&"to"in e?(o=e.from,l=e.to):(o=i.from,l=i.to),s&&n.doc.nodesBetween(o,l,(a,c)=>{a.isText||n.setNodeMarkup(c,void 0,{...a.attrs,dir:t})}),!0},pm=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:s,to:i}=typeof t=="number"?{from:t,to:t}:t,o=E.atStart(r).from,l=E.atEnd(r).to,a=dt(s,o,l),c=dt(i,o,l),u=E.create(r,a,c);e.setSelection(u)}return!0},mm=t=>({state:e,dispatch:n})=>{const r=U(t,e.schema);return ch(r)(e,n)};function ho(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter(s=>e==null?void 0:e.includes(s.type.name));t.tr.ensureMarks(r)}}var gm=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:s})=>{const{selection:i,doc:o}=e,{$from:l,$to:a}=i,c=s.extensionManager.attributes,u=Dn(c,l.node().type.name,l.node().attrs);if(i instanceof A&&i.node.isBlock)return!l.parentOffset||!je(o,l.pos)?!1:(r&&(t&&ho(n,s.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const d=a.parentOffset===a.parent.content.size,h=l.depth===0?void 0:qp(l.node(-1).contentMatchAt(l.indexAfter(-1)));let f=d&&h?[{type:h,attrs:u}]:void 0,p=je(e.doc,e.mapping.map(l.pos),1,f);if(!f&&!p&&je(e.doc,e.mapping.map(l.pos),1,h?[{type:h}]:void 0)&&(p=!0,f=h?[{type:h,attrs:u}]:void 0),r){if(p&&(i instanceof E&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,f),h&&!d&&!l.parentOffset&&l.parent.type!==h)){const m=e.mapping.map(l.before()),g=e.doc.resolve(m);l.node(-1).canReplaceWith(g.index(),g.index()+1,h)&&e.setNodeMarkup(e.mapping.map(l.before()),h)}t&&ho(n,s.extensionManager.splittableMarks),e.scrollIntoView()}return p},ym=(t,e={})=>({tr:n,state:r,dispatch:s,editor:i})=>{var o;const l=U(t,r.schema),{$from:a,$to:c}=r.selection,u=r.selection.node;if(u&&u.isBlock||a.depth<2||!a.sameParent(c))return!1;const d=a.node(-1);if(d.type!==l)return!1;const h=i.extensionManager.attributes;if(a.parent.content.size===0&&a.node(-1).childCount===a.indexAfter(-1)){if(a.depth===2||a.node(-3).type!==l||a.index(-2)!==a.node(-2).childCount-1)return!1;if(s){let b=x.empty;const k=a.index(-1)?1:a.index(-2)?2:3;for(let D=a.depth-k;D>=a.depth-3;D-=1)b=x.from(a.node(D).copy(b));const w=a.indexAfter(-1)<a.node(-2).childCount?1:a.indexAfter(-2)<a.node(-3).childCount?2:3,C={...Dn(h,a.node().type.name,a.node().attrs),...e},v=((o=l.contentMatch.defaultType)==null?void 0:o.createAndFill(C))||void 0;b=b.append(x.from(l.createAndFill(null,v)||void 0));const I=a.before(a.depth-(k-1));n.replace(I,a.after(-w),new S(b,4-k,0));let M=-1;n.doc.nodesBetween(I,n.doc.content.size,(D,B)=>{if(M>-1)return!1;D.isTextblock&&D.content.size===0&&(M=B+1)}),M>-1&&n.setSelection(E.near(n.doc.resolve(M))),n.scrollIntoView()}return!0}const f=c.pos===a.end()?d.contentMatchAt(0).defaultType:null,p={...Dn(h,d.type.name,d.attrs),...e},m={...Dn(h,a.node().type.name,a.node().attrs),...e};n.delete(a.pos,c.pos);const g=f?[{type:l,attrs:p},{type:f,attrs:m}]:[{type:l,attrs:p}];if(!je(n.doc,a.pos,2))return!1;if(s){const{selection:b,storedMarks:k}=r,{splittableMarks:w}=i.extensionManager,C=k||b.$to.parentOffset&&b.$from.marks();if(n.split(a.pos,2,g).scrollIntoView(),!C||!s)return!0;const v=C.filter(I=>w.includes(I.type.name));n.ensureMarks(v)}return!0},Pr=(t,e)=>{const n=fr(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;const s=t.doc.nodeAt(r);return n.node.type===(s==null?void 0:s.type)&&st(t.doc,n.pos)&&t.join(n.pos),!0},zr=(t,e)=>{const n=fr(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;const s=t.doc.nodeAt(r);return n.node.type===(s==null?void 0:s.type)&&st(t.doc,r)&&t.join(r),!0},bm=(t,e,n,r={})=>({editor:s,tr:i,state:o,dispatch:l,chain:a,commands:c,can:u})=>{const{extensions:d,splittableMarks:h}=s.extensionManager,f=U(t,o.schema),p=U(e,o.schema),{selection:m,storedMarks:g}=o,{$from:b,$to:k}=m,w=b.blockRange(k),C=g||m.$to.parentOffset&&m.$from.marks();if(!w)return!1;const v=fr(I=>uo(I.type.name,d))(m);if(w.depth>=1&&v&&w.depth-v.depth<=1){if(v.node.type===f)return c.liftListItem(p);if(uo(v.node.type.name,d)&&f.validContent(v.node.content)&&l)return a().command(()=>(i.setNodeMarkup(v.pos,f),!0)).command(()=>Pr(i,f)).command(()=>zr(i,f)).run()}return!n||!C||!l?a().command(()=>u().wrapInList(f,r)?!0:c.clearNodes()).wrapInList(f,r).command(()=>Pr(i,f)).command(()=>zr(i,f)).run():a().command(()=>{const I=u().wrapInList(f,r),M=C.filter(D=>h.includes(D.type.name));return i.ensureMarks(M),I?!0:c.clearNodes()}).wrapInList(f,r).command(()=>Pr(i,f)).command(()=>zr(i,f)).run()},xm=(t,e={},n={})=>({state:r,commands:s})=>{const{extendEmptyMarkRange:i=!1}=n,o=Fe(t,r.schema);return ss(r,o,e)?s.unsetMark(o,{extendEmptyMarkRange:i}):s.setMark(o,e)},km=(t,e,n={})=>({state:r,commands:s})=>{const i=U(t,r.schema),o=U(e,r.schema),l=rt(r,i,n);let a;return r.selection.$anchor.sameParent(r.selection.$head)&&(a=r.selection.$anchor.parent.attrs),l?s.setNode(o,a):s.setNode(i,{...a,...n})},wm=(t,e={})=>({state:n,commands:r})=>{const s=U(t,n.schema);return rt(n,s,e)?r.lift(s):r.wrapIn(s,e)},Sm=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const s=n[r];let i;if(s.spec.isInputRules&&(i=s.getState(t))){if(e){const o=t.tr,l=i.transform;for(let a=l.steps.length-1;a>=0;a-=1)o.step(l.steps[a].invert(l.docs[a]));if(i.text){const a=o.doc.resolve(i.from).marks();o.replaceWith(i.from,i.to,t.schema.text(i.text,a))}else o.delete(i.from,i.to)}return!0}}return!1},Cm=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:s}=n;return r||e&&s.forEach(i=>{t.removeMark(i.$from.pos,i.$to.pos)}),!0},vm=(t,e={})=>({tr:n,state:r,dispatch:s})=>{var i;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=n,a=Fe(t,r.schema),{$from:c,empty:u,ranges:d}=l;if(!s)return!0;if(u&&o){let{from:h,to:f}=l;const p=(i=c.marks().find(g=>g.type===a))==null?void 0:i.attrs,m=qs(c,a,p);m&&(h=m.from,f=m.to),n.removeMark(h,f,a)}else d.forEach(h=>{n.removeMark(h.$from.pos,h.$to.pos,a)});return n.removeStoredMark(a),!0},Mm=t=>({tr:e,state:n,dispatch:r})=>{const{selection:s}=n;let i,o;return typeof t=="number"?(i=t,o=t):t&&"from"in t&&"to"in t?(i=t.from,o=t.to):(i=s.from,o=s.to),r&&e.doc.nodesBetween(i,o,(l,a)=>{if(l.isText)return;const c={...l.attrs};delete c.dir,e.setNodeMarkup(a,void 0,c)}),!0},Tm=(t,e={})=>({tr:n,state:r,dispatch:s})=>{let i=null,o=null;const l=hr(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(i=U(t,r.schema)),l==="mark"&&(o=Fe(t,r.schema));let a=!1;return n.selection.ranges.forEach(c=>{const u=c.$from.pos,d=c.$to.pos;let h,f,p,m;n.selection.empty?r.doc.nodesBetween(u,d,(g,b)=>{i&&i===g.type&&(a=!0,p=Math.max(b,u),m=Math.min(b+g.nodeSize,d),h=b,f=g)}):r.doc.nodesBetween(u,d,(g,b)=>{b<u&&i&&i===g.type&&(a=!0,p=Math.max(b,u),m=Math.min(b+g.nodeSize,d),h=b,f=g),b>=u&&b<=d&&(i&&i===g.type&&(a=!0,s&&n.setNodeMarkup(b,void 0,{...g.attrs,...e})),o&&g.marks.length&&g.marks.forEach(k=>{if(o===k.type&&(a=!0,s)){const w=Math.max(b,u),C=Math.min(b+g.nodeSize,d);n.addMark(w,C,o.create({...k.attrs,...e}))}}))}),f&&(h!==void 0&&s&&n.setNodeMarkup(h,void 0,{...f.attrs,...e}),o&&f.marks.length&&f.marks.forEach(g=>{o===g.type&&s&&n.addMark(p,m,o.create({...g.attrs,...e}))}))}),a},Em=(t,e={})=>({state:n,dispatch:r})=>{const s=U(t,n.schema);return nh(s,e)(n,r)},Am=(t,e={})=>({state:n,dispatch:r})=>{const s=U(t,n.schema);return rh(s,e)(n,r)},Nm=class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const n=this.callbacks[t];return n&&n.forEach(r=>r.apply(this,e)),this}off(t,e){const n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter(r=>r!==e):delete this.callbacks[t]),this}once(t,e){const n=(...r)=>{this.off(t,n),e.apply(this,r)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}},mr=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},Om=(t,e)=>{if(Ws(e))return e.exec(t);const n=e(t);if(!n)return null;const r=[n.text];return r.index=n.index,r.input=t,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r};function wn(t){var e;const{editor:n,from:r,to:s,text:i,rules:o,plugin:l}=t,{view:a}=n;if(a.composing)return!1;const c=a.state.doc.resolve(r);if(c.parent.type.spec.code||(e=c.nodeBefore||c.nodeAfter)!=null&&e.marks.find(h=>h.type.spec.code))return!1;let u=!1;const d=nm(c)+i;return o.forEach(h=>{if(u)return;const f=Om(d,h.find);if(!f)return;const p=a.state.tr,m=ur({state:a.state,transaction:p}),g={from:r-(f[0].length-i.length),to:s},{commands:b,chain:k,can:w}=new dr({editor:n,state:m});h.handler({state:m,range:g,match:f,commands:b,chain:k,can:w})===null||!p.steps.length||(h.undoable&&p.setMeta(l,{transform:p,from:r,to:s,text:i}),a.dispatch(p),u=!0)}),u}function Im(t){const{editor:e,rules:n}=t,r=new H({state:{init(){return null},apply(s,i,o){const l=s.getMeta(r);if(l)return l;const a=s.getMeta("applyInputRules");return!!a&&setTimeout(()=>{let{text:u}=a;typeof u=="string"?u=u:u=Us(x.from(u),o.schema);const{from:d}=a,h=d+u.length;wn({editor:e,from:d,to:h,text:u,rules:n,plugin:r})}),s.selectionSet||s.docChanged?null:i}},props:{handleTextInput(s,i,o,l){return wn({editor:e,from:i,to:o,text:l,rules:n,plugin:r})},handleDOMEvents:{compositionend:s=>(setTimeout(()=>{const{$cursor:i}=s.state.selection;i&&wn({editor:e,from:i.pos,to:i.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(s,i){if(i.key!=="Enter")return!1;const{$cursor:o}=s.state.selection;return o?wn({editor:e,from:o.pos,to:o.pos,text:`
`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function Dm(t){return Object.prototype.toString.call(t).slice(8,-1)}function Sn(t){return Dm(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function Ga(t,e){const n={...t};return Sn(t)&&Sn(e)&&Object.keys(e).forEach(r=>{Sn(e[r])&&Sn(t[r])?n[r]=Ga(t[r],e[r]):n[r]=e[r]}),n}var Gs=class{constructor(t={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...t},this.name=this.config.name}get options(){return{...P(T(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...P(T(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>Ga(this.options,t)});return e.name=this.name,e.parent=this.parent,e}extend(t={}){const e=new this.constructor({...this.config,...t});return e.parent=this,this.child=e,e.name="name"in t?t.name:e.parent.name,e}},Oe=class Xa extends Gs{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new Xa(n)}static handleExit({editor:e,mark:n}){const{tr:r}=e.state,s=e.state.selection.$from;if(s.pos===s.end()){const o=s.marks();if(!!!o.find(c=>(c==null?void 0:c.type.name)===n.name))return!1;const a=o.find(c=>(c==null?void 0:c.type.name)===n.name);return a&&r.removeStoredMark(a),r.insertText(" ",s.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function Rm(t){return typeof t=="number"}var Lm=class{constructor(t){this.find=t.find,this.handler=t.handler}},Pm=(t,e,n)=>{if(Ws(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(s=>{const i=[s.text];return i.index=s.index,i.input=t,i.data=s.data,s.replaceWith&&(s.text.includes(s.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),i.push(s.replaceWith)),i}):[]};function zm(t){const{editor:e,state:n,from:r,to:s,rule:i,pasteEvent:o,dropEvent:l}=t,{commands:a,chain:c,can:u}=new dr({editor:e,state:n}),d=[];return n.doc.nodesBetween(r,s,(f,p)=>{var m,g,b,k,w;if((g=(m=f.type)==null?void 0:m.spec)!=null&&g.code||!(f.isText||f.isTextblock||f.isInline))return;const C=(w=(k=(b=f.content)==null?void 0:b.size)!=null?k:f.nodeSize)!=null?w:0,v=Math.max(r,p),I=Math.min(s,p+C);if(v>=I)return;const M=f.isText?f.text||"":f.textBetween(v-p,I-p,void 0,"￼");Pm(M,i.find,o).forEach(B=>{if(B.index===void 0)return;const De=v+B.index+1,br=De+B[0].length,fn={from:n.tr.mapping.map(De),to:n.tr.mapping.map(br)},xr=i.handler({state:n,range:fn,match:B,commands:a,chain:c,can:u,pasteEvent:o,dropEvent:l});d.push(xr)})}),d.every(f=>f!==null)}var Cn=null,Bm=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function jm(t){const{editor:e,rules:n}=t;let r=null,s=!1,i=!1,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}const a=({state:u,from:d,to:h,rule:f,pasteEvt:p})=>{const m=u.tr,g=ur({state:u,transaction:m});if(!(!zm({editor:e,state:g,from:Math.max(d-1,0),to:h.b-1,rule:f,pasteEvent:p,dropEvent:l})||!m.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,m}};return n.map(u=>new H({view(d){const h=p=>{var m;r=(m=d.dom.parentElement)!=null&&m.contains(p.target)?d.dom.parentElement:null,r&&(Cn=e)},f=()=>{Cn&&(Cn=null)};return window.addEventListener("dragstart",h),window.addEventListener("dragend",f),{destroy(){window.removeEventListener("dragstart",h),window.removeEventListener("dragend",f)}}},props:{handleDOMEvents:{drop:(d,h)=>{if(i=r===d.dom.parentElement,l=h,!i){const f=Cn;f!=null&&f.isEditable&&setTimeout(()=>{const p=f.state.selection;p&&f.commands.deleteRange({from:p.from,to:p.to})},10)}return!1},paste:(d,h)=>{var f;const p=(f=h.clipboardData)==null?void 0:f.getData("text/html");return o=h,s=!!(p!=null&&p.includes("data-pm-slice")),!1}}},appendTransaction:(d,h,f)=>{const p=d[0],m=p.getMeta("uiEvent")==="paste"&&!s,g=p.getMeta("uiEvent")==="drop"&&!i,b=p.getMeta("applyPasteRules"),k=!!b;if(!m&&!g&&!k)return;if(k){let{text:v}=b;typeof v=="string"?v=v:v=Us(x.from(v),f.schema);const{from:I}=b,M=I+v.length,D=Bm(v);return a({rule:u,state:f,from:I,to:{b:M},pasteEvt:D})}const w=h.doc.content.findDiffStart(f.doc.content),C=h.doc.content.findDiffEnd(f.doc.content);if(!(!Rm(w)||!C||w===C.b))return a({rule:u,state:f,from:w,to:C,pasteEvt:o})}}))}var gr=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=Ha(t),this.schema=Gp(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((t,e)=>{const n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:kn(e.name,this.schema)},r=T(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return Yn([...this.extensions].reverse()).flatMap(r=>{const s={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:kn(r.name,this.schema)},i=[],o=T(r,"addKeyboardShortcuts",s);let l={};if(r.type==="mark"&&T(r,"exitable",s)&&(l.ArrowRight=()=>Oe.handleExit({editor:t,mark:r})),o){const h=Object.fromEntries(Object.entries(o()).map(([f,p])=>[f,()=>p({editor:t})]));l={...l,...h}}const a=Qf(l);i.push(a);const c=T(r,"addInputRules",s);if(co(r,t.options.enableInputRules)&&c){const h=c();if(h&&h.length){const f=Im({editor:t,rules:h}),p=Array.isArray(f)?f:[f];i.push(...p)}}const u=T(r,"addPasteRules",s);if(co(r,t.options.enablePasteRules)&&u){const h=u();if(h&&h.length){const f=jm({editor:t,rules:h});i.push(...f)}}const d=T(r,"addProseMirrorPlugins",s);if(d){const h=d();i.push(...h)}return i})}get attributes(){return Fa(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=Bt(this.extensions);return Object.fromEntries(e.filter(n=>!!T(n,"addNodeView")).map(n=>{const r=this.attributes.filter(a=>a.type===n.name),s={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:U(n.name,this.schema)},i=T(n,"addNodeView",s);if(!i)return[];const o=i();if(!o)return[];const l=(a,c,u,d,h)=>{const f=Xn(a,r);return o({node:a,view:c,getPos:u,decorations:d,innerDecorations:h,editor:t,extension:n,HTMLAttributes:f})};return[n.name,l]}))}dispatchTransaction(t){const{editor:e}=this;return Yn([...this.extensions].reverse()).reduceRight((r,s)=>{const i={name:s.name,options:s.options,storage:this.editor.extensionStorage[s.name],editor:e,type:kn(s.name,this.schema)},o=T(s,"dispatchTransaction",i);return o?l=>{o.call(i,{transaction:l,next:r})}:r},t)}get markViews(){const{editor:t}=this,{markExtensions:e}=Bt(this.extensions);return Object.fromEntries(e.filter(n=>!!T(n,"addMarkView")).map(n=>{const r=this.attributes.filter(l=>l.type===n.name),s={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Fe(n.name,this.schema)},i=T(n,"addMarkView",s);if(!i)return[];const o=(l,a,c)=>{const u=Xn(l,r);return i()({mark:l,view:a,inline:c,editor:t,extension:n,HTMLAttributes:u,updateAttributes:d=>{Qm(l,t,d)}})};return[n.name,o]}))}setupExtensions(){const t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(e=>[e.name,e.storage])),t.forEach(e=>{var n;const r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:kn(e.name,this.schema)};e.type==="mark"&&((n=P(T(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const s=T(e,"onBeforeCreate",r),i=T(e,"onCreate",r),o=T(e,"onUpdate",r),l=T(e,"onSelectionUpdate",r),a=T(e,"onTransaction",r),c=T(e,"onFocus",r),u=T(e,"onBlur",r),d=T(e,"onDestroy",r);s&&this.editor.on("beforeCreate",s),i&&this.editor.on("create",i),o&&this.editor.on("update",o),l&&this.editor.on("selectionUpdate",l),a&&this.editor.on("transaction",a),c&&this.editor.on("focus",c),u&&this.editor.on("blur",u),d&&this.editor.on("destroy",d)})}};gr.resolve=Ha;gr.sort=Yn;gr.flatten=Ks;var $m={};_s($m,{ClipboardTextSerializer:()=>Za,Commands:()=>Qa,Delete:()=>ec,Drop:()=>tc,Editable:()=>nc,FocusEvents:()=>sc,Keymap:()=>ic,Paste:()=>oc,Tabindex:()=>lc,TextDirection:()=>ac,focusEventsPluginKey:()=>rc});var L=class Ya extends Gs{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new Ya(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},Za=L.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new H({key:new _("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:s}=e,{ranges:i}=s,o=Math.min(...i.map(u=>u.$from.pos)),l=Math.max(...i.map(u=>u.$to.pos)),a=_a(n);return Va(r,{from:o,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:a})}}})]}}),Qa=L.create({name:"commands",addCommands(){return{...Oa}}}),ec=L.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,s;const i=()=>{var o,l,a,c;if((c=(a=(l=(o=this.editor.options.coreExtensionOptions)==null?void 0:o.delete)==null?void 0:l.filterTransaction)==null?void 0:a.call(l,t))!=null?c:t.getMeta("y-sync$"))return;const u=Ba(t.before,[t,...e]);qa(u).forEach(f=>{u.mapping.mapResult(f.oldRange.from).deletedAfter&&u.mapping.mapResult(f.oldRange.to).deletedBefore&&u.before.nodesBetween(f.oldRange.from,f.oldRange.to,(p,m)=>{const g=m+p.nodeSize-2,b=f.oldRange.from<=m&&g<=f.oldRange.to;this.editor.emit("delete",{type:"node",node:p,from:m,to:g,newFrom:u.mapping.map(m),newTo:u.mapping.map(g),deletedRange:f.oldRange,newRange:f.newRange,partial:!b,editor:this.editor,transaction:t,combinedTransform:u})})});const h=u.mapping;u.steps.forEach((f,p)=>{var m,g;if(f instanceof Ce){const b=h.slice(p).map(f.from,-1),k=h.slice(p).map(f.to),w=h.invert().map(b,-1),C=h.invert().map(k),v=(m=u.doc.nodeAt(b-1))==null?void 0:m.marks.some(M=>M.eq(f.mark)),I=(g=u.doc.nodeAt(k))==null?void 0:g.marks.some(M=>M.eq(f.mark));this.editor.emit("delete",{type:"mark",mark:f.mark,from:f.from,to:f.to,deletedRange:{from:w,to:C},newRange:{from:b,to:k},partial:!!(I||v),editor:this.editor,transaction:t,combinedTransform:u})}})};(s=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||s?setTimeout(i,0):i()}}),tc=L.create({name:"drop",addProseMirrorPlugins(){return[new H({key:new _("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),nc=L.create({name:"editable",addProseMirrorPlugins(){return[new H({key:new _("editable"),props:{editable:()=>this.editor.options.editable}})]}}),rc=new _("focusEvents"),sc=L.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new H({key:rc,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const r=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;const r=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),ic=L.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:l})=>{const{selection:a,doc:c}=l,{empty:u,$anchor:d}=a,{pos:h,parent:f}=d,p=d.parent.isTextblock&&h>0?l.doc.resolve(h-1):d,m=p.parent.type.spec.isolating,g=d.pos-d.parentOffset,b=m&&p.parent.childCount===1?g===d.pos:N.atStart(c).from===h;return!u||!f.type.isTextblock||f.textContent.length||!b||b&&d.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.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()},s={...r},i={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Gn()||Pa()?i:s},addProseMirrorPlugins(){return[new H({key:new _("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(m=>m.getMeta("composition")))return;const r=t.some(m=>m.docChanged)&&!e.doc.eq(n.doc),s=t.some(m=>m.getMeta("preventClearDocument"));if(!r||s)return;const{empty:i,from:o,to:l}=e.selection,a=N.atStart(e.doc).from,c=N.atEnd(e.doc).to;if(i||!(o===a&&l===c)||!pr(n.doc))return;const h=n.tr,f=ur({state:n,transaction:h}),{commands:p}=new dr({editor:this.editor,state:f});if(p.clearNodes(),!!h.steps.length)return h}})]}}),oc=L.create({name:"paste",addProseMirrorPlugins(){return[new H({key:new _("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),lc=L.create({name:"tabindex",addProseMirrorPlugins(){return[new H({key:new _("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),ac=L.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=Bt(this.extensions);return[{types:t.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{const n=e.getAttribute("dir");return n&&(n==="ltr"||n==="rtl"||n==="auto")?n:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new H({key:new _("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),Fm=class Jt{constructor(e,n,r=!1,s=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,this.currentNode=s}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!=null?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let n=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:n,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new Jt(n,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new Jt(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new Jt(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const s=n.isBlock&&!n.isTextblock,i=n.isAtom&&!n.isText,o=n.isInline,l=this.pos+r+(i?0:1);if(l<0||l>this.resolvedPos.doc.nodeSize-2)return;const a=this.resolvedPos.doc.resolve(l);if(!s&&!o&&a.depth<=this.depth)return;const c=new Jt(a,this.editor,s,s||o?n:null);s&&(c.actualDepth=this.depth+1),e.push(c)}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,s=this.parent;for(;s&&!r;){if(s.node.type.name===e)if(Object.keys(n).length>0){const i=s.node.attrs,o=Object.keys(n);for(let l=0;l<o.length;l+=1){const a=o[l];if(i[a]!==n[a])break}}else r=s;s=s.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let s=[];if(!this.children||this.children.length===0)return s;const i=Object.keys(n);return this.children.forEach(o=>{r&&s.length>0||(o.node.type.name===e&&i.every(a=>n[a]===o.node.attrs[a])&&s.push(o),!(r&&s.length>0)&&(s=s.concat(o.querySelectorAll(e,n,r))))}),s}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},Hm=`.ProseMirror {
  position: relative;
}

.ProseMirror {
  word-wrap: break-word;
  white-space: pre-wrap;
  white-space: break-spaces;
  -webkit-font-variant-ligatures: none;
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
}

.ProseMirror [contenteditable="false"] {
  white-space: normal;
}

.ProseMirror [contenteditable="false"] [contenteditable="true"] {
  white-space: pre-wrap;
}

.ProseMirror pre {
  white-space: pre-wrap;
}

img.ProseMirror-separator {
  display: inline !important;
  border: none !important;
  margin: 0 !important;
  width: 0 !important;
  height: 0 !important;
}

.ProseMirror-gapcursor {
  display: none;
  pointer-events: none;
  position: absolute;
  margin: 0;
}

.ProseMirror-gapcursor:after {
  content: "";
  display: block;
  position: absolute;
  top: -2px;
  width: 20px;
  border-top: 1px solid black;
  animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
}

@keyframes ProseMirror-cursor-blink {
  to {
    visibility: hidden;
  }
}

.ProseMirror-hideselection *::selection {
  background: transparent;
}

.ProseMirror-hideselection *::-moz-selection {
  background: transparent;
}

.ProseMirror-hideselection * {
  caret-color: transparent;
}

.ProseMirror-focused .ProseMirror-gapcursor {
  display: block;
}`;function Vm(t,e,n){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const s=document.createElement("style");return e&&s.setAttribute("nonce",e),s.setAttribute("data-tiptap-style",""),s.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(s),s}var _m=class extends Nm{constructor(t={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:r})=>{throw r},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:om,createMappablePosition:lm},this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:r,slice:s,moved:i})=>this.options.onDrop(r,s,i)),this.on("paste",({event:r,slice:s})=>this.options.onPaste(r,s)),this.on("delete",this.options.onDelete);const e=this.createDoc(),n=Ra(e,this.options.autofocus);this.editorState=Ot.create({doc:e,schema:this.schema,selection:n||void 0}),this.options.element&&this.mount(this.options.element)}mount(t){if(typeof document>"u")throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(t),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){const t=this.editorView.dom;t!=null&&t.editor&&delete t.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove=="function"?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(t){console.warn("Failed to remove CSS element:",t)}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&typeof document<"u"&&(this.css=Vm(Hm,this.options.injectNonce))}setOptions(t={}){this.options={...this.options,...t},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(t,e=!0){this.setOptions({editable:t}),e&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:t=>{this.editorState=t},dispatch:t=>{this.dispatchTransaction(t)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(t,e)=>{if(this.editorView)return this.editorView[e];if(e==="state")return this.editorState;if(e in t)return Reflect.get(t,e);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${e}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(t,e){const n=$a(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(t){if(this.isDestroyed)return;const e=this.state.plugins;let n=e;if([].concat(t).forEach(s=>{const i=typeof s=="string"?`${s}$`:s.key;n=n.filter(o=>!o.key.startsWith(i))}),e.length===n.length)return;const r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var t,e;const r=[...this.options.enableCoreExtensions?[nc,Za.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),Qa,sc,ic,lc,tc,oc,ec,ac.configure({direction:this.options.textDirection})].filter(s=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[s.name]!==!1:!0):[],...this.options.extensions].filter(s=>["extension","node","mark"].includes(s==null?void 0:s.type));this.extensionManager=new gr(r,this)}createCommandManager(){this.commandManager=new dr({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=ns(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message))throw e;this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{"collaboration"in this.storage&&typeof this.storage.collaboration=="object"&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(n=>n.name!=="collaboration"),this.createExtensionManager()}}),t=ns(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){const{editorProps:e,enableExtensionDispatchTransaction:n}=this.options,r=e.dispatchTransaction||this.dispatchTransaction.bind(this),s=n?this.extensionManager.dispatchTransaction(r):r;this.editorView=new Na(t,{...e,attributes:{role:"textbox",...e==null?void 0:e.attributes},dispatchTransaction:s,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const i=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(i),this.prependClass(),this.injectCSS();const o=this.view.dom;o.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach(c=>{var u;return(u=this.capturedTransaction)==null?void 0:u.step(c)});return}const{state:e,transactions:n}=this.state.applyTransaction(t),r=!this.state.selection.eq(e.selection),s=n.includes(t),i=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!s)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:t});const o=n.findLast(c=>c.getMeta("focus")||c.getMeta("blur")),l=o==null?void 0:o.getMeta("focus"),a=o==null?void 0:o.getMeta("blur");l&&this.emit("focus",{editor:this,event:l.event,transaction:o}),a&&this.emit("blur",{editor:this,event:a.event,transaction:o}),!(t.getMeta("preventUpdate")||!n.some(c=>c.docChanged)||i.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return Wa(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return rm(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Us(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`

`,textSerializers:n={}}=t||{};return Yp(this.state.doc,{blockSeparator:e,textSerializers:{..._a(this.schema),...n}})}get isEmpty(){return pr(this.state.doc)}destroy(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}get isDestroyed(){var t,e;return(e=(t=this.editorView)==null?void 0:t.isDestroyed)!=null?e:!0}$node(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelector(t,e))||null}$nodes(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelectorAll(t,e))||null}$pos(t){const e=this.state.doc.resolve(t);return new Fm(e,this)}get $doc(){return this.$pos(0)}};function jt(t){return new mr({find:t.find,handler:({state:e,range:n,match:r})=>{const s=P(t.getAttributes,void 0,r);if(s===!1||s===null)return null;const{tr:i}=e,o=r[r.length-1],l=r[0];if(o){const a=l.search(/\S/),c=n.from+l.indexOf(o),u=c+o.length;if(Js(n.from,n.to,e.doc).filter(f=>f.mark.type.excluded.find(m=>m===t.type&&m!==f.mark.type)).filter(f=>f.to>c).length)return null;u<n.to&&i.delete(u,n.to),c>n.from&&i.delete(n.from+a,c);const h=n.from+a+o.length;i.addMark(n.from+a,h,t.type.create(s||{})),i.removeStoredMark(t.type)}},undoable:t.undoable})}function cc(t){return new mr({find:t.find,handler:({state:e,range:n,match:r})=>{const s=P(t.getAttributes,void 0,r)||{},{tr:i}=e,o=n.from;let l=n.to;const a=t.type.create(s);if(r[1]){const c=r[0].lastIndexOf(r[1]);let u=o+c;u>l?u=l:l=u+r[1].length;const d=r[0][r[0].length-1];i.insertText(d,o+r[0].length-1),i.replaceWith(u,l,a)}else if(r[0]){const c=t.type.isInline?o:o-1;i.insert(c,t.type.create(s)).delete(i.mapping.map(o),i.mapping.map(l))}i.scrollIntoView()},undoable:t.undoable})}function is(t){return new mr({find:t.find,handler:({state:e,range:n,match:r})=>{const s=e.doc.resolve(n.from),i=P(t.getAttributes,void 0,r)||{};if(!s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,i)},undoable:t.undoable})}function $t(t){return new mr({find:t.find,handler:({state:e,range:n,match:r,chain:s})=>{const i=P(t.getAttributes,void 0,r)||{},o=e.tr.delete(n.from,n.to),a=o.doc.resolve(n.from).blockRange(),c=a&&Ms(a,t.type,i);if(!c)return null;if(o.wrap(a,c),t.keepMarks&&t.editor){const{selection:d,storedMarks:h}=e,{splittableMarks:f}=t.editor.extensionManager,p=h||d.$to.parentOffset&&d.$from.marks();if(p){const m=p.filter(g=>f.includes(g.type.name));o.ensureMarks(m)}}if(t.keepAttributes){const d=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";s().updateAttributes(d,i).run()}const u=o.doc.resolve(n.from-1).nodeBefore;u&&u.type===t.type&&st(o.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,u))&&o.join(n.from-1)},undoable:t.undoable})}var Wm=t=>"touches"in t,qm=class{constructor(t){this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.lastEditableState=void 0,this.handleMap=new Map,this.handleMouseMove=l=>{if(!this.isResizing||!this.activeHandle)return;const a=l.clientX-this.startX,c=l.clientY-this.startY;this.handleResize(a,c)},this.handleTouchMove=l=>{if(!this.isResizing||!this.activeHandle)return;const a=l.touches[0];if(!a)return;const c=a.clientX-this.startX,u=a.clientY-this.startY;this.handleResize(c,u)},this.handleMouseUp=()=>{if(!this.isResizing)return;const l=this.element.offsetWidth,a=this.element.offsetHeight;this.onCommit(l,a),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)},this.handleKeyDown=l=>{l.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=l=>{l.key==="Shift"&&(this.isShiftKeyPressed=!1)};var e,n,r,s,i,o;this.node=t.node,this.editor=t.editor,this.element=t.element,this.contentElement=t.contentElement,this.getPos=t.getPos,this.onResize=t.onResize,this.onCommit=t.onCommit,this.onUpdate=t.onUpdate,(e=t.options)!=null&&e.min&&(this.minSize={...this.minSize,...t.options.min}),(n=t.options)!=null&&n.max&&(this.maxSize=t.options.max),(r=t==null?void 0:t.options)!=null&&r.directions&&(this.directions=t.options.directions),(s=t.options)!=null&&s.preserveAspectRatio&&(this.preserveAspectRatio=t.options.preserveAspectRatio),(i=t.options)!=null&&i.className&&(this.classNames={container:t.options.className.container||"",wrapper:t.options.className.wrapper||"",handle:t.options.className.handle||"",resizing:t.options.className.resizing||""}),(o=t.options)!=null&&o.createCustomHandle&&(this.createCustomHandle=t.options.createCustomHandle),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles(),this.editor.on("update",this.handleEditorUpdate.bind(this))}get dom(){return this.container}get contentDOM(){var t;return(t=this.contentElement)!=null?t:null}handleEditorUpdate(){const t=this.editor.isEditable;t!==this.lastEditableState&&(this.lastEditableState=t,t?t&&this.handleMap.size===0&&this.attachHandles():this.removeHandles())}update(t,e,n){return t.type!==this.node.type?!1:(this.node=t,this.onUpdate?this.onUpdate(t,e,n):!0)}destroy(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.editor.off("update",this.handleEditorUpdate.bind(this)),this.container.remove()}createContainer(){const t=document.createElement("div");return t.dataset.resizeContainer="",t.dataset.node=this.node.type.name,t.style.display="flex",this.classNames.container&&(t.className=this.classNames.container),t.appendChild(this.wrapper),t}createWrapper(){const t=document.createElement("div");return t.style.position="relative",t.style.display="block",t.dataset.resizeWrapper="",this.classNames.wrapper&&(t.className=this.classNames.wrapper),t.appendChild(this.element),t}createHandle(t){const e=document.createElement("div");return e.dataset.resizeHandle=t,e.style.position="absolute",this.classNames.handle&&(e.className=this.classNames.handle),e}positionHandle(t,e){const n=e.includes("top"),r=e.includes("bottom"),s=e.includes("left"),i=e.includes("right");n&&(t.style.top="0"),r&&(t.style.bottom="0"),s&&(t.style.left="0"),i&&(t.style.right="0"),(e==="top"||e==="bottom")&&(t.style.left="0",t.style.right="0"),(e==="left"||e==="right")&&(t.style.top="0",t.style.bottom="0")}attachHandles(){this.directions.forEach(t=>{let e;this.createCustomHandle?e=this.createCustomHandle(t):e=this.createHandle(t),e instanceof HTMLElement||(console.warn(`[ResizableNodeView] createCustomHandle("${t}") did not return an HTMLElement. Falling back to default handle.`),e=this.createHandle(t)),this.createCustomHandle||this.positionHandle(e,t),e.addEventListener("mousedown",n=>this.handleResizeStart(n,t)),e.addEventListener("touchstart",n=>this.handleResizeStart(n,t)),this.handleMap.set(t,e),this.wrapper.appendChild(e)})}removeHandles(){this.handleMap.forEach(t=>t.remove()),this.handleMap.clear()}applyInitialSize(){const t=this.node.attrs.width,e=this.node.attrs.height;t?(this.element.style.width=`${t}px`,this.initialWidth=t):this.initialWidth=this.element.offsetWidth,e?(this.element.style.height=`${e}px`,this.initialHeight=e):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(t,e){t.preventDefault(),t.stopPropagation(),this.isResizing=!0,this.activeHandle=e,Wm(t)?(this.startX=t.touches[0].clientX,this.startY=t.touches[0].clientY):(this.startX=t.clientX,this.startY=t.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}handleResize(t,e){if(!this.activeHandle)return;const n=this.preserveAspectRatio||this.isShiftKeyPressed,{width:r,height:s}=this.calculateNewDimensions(this.activeHandle,t,e),i=this.applyConstraints(r,s,n);this.element.style.width=`${i.width}px`,this.element.style.height=`${i.height}px`,this.onResize&&this.onResize(i.width,i.height)}calculateNewDimensions(t,e,n){let r=this.startWidth,s=this.startHeight;const i=t.includes("right"),o=t.includes("left"),l=t.includes("bottom"),a=t.includes("top");return i?r=this.startWidth+e:o&&(r=this.startWidth-e),l?s=this.startHeight+n:a&&(s=this.startHeight-n),(t==="right"||t==="left")&&(r=this.startWidth+(i?e:-e)),(t==="top"||t==="bottom")&&(s=this.startHeight+(l?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,s,t):{width:r,height:s}}applyConstraints(t,e,n){var r,s,i,o;if(!n){let c=Math.max(this.minSize.width,t),u=Math.max(this.minSize.height,e);return(r=this.maxSize)!=null&&r.width&&(c=Math.min(this.maxSize.width,c)),(s=this.maxSize)!=null&&s.height&&(u=Math.min(this.maxSize.height,u)),{width:c,height:u}}let l=t,a=e;return l<this.minSize.width&&(l=this.minSize.width,a=l/this.aspectRatio),a<this.minSize.height&&(a=this.minSize.height,l=a*this.aspectRatio),(i=this.maxSize)!=null&&i.width&&l>this.maxSize.width&&(l=this.maxSize.width,a=l/this.aspectRatio),(o=this.maxSize)!=null&&o.height&&a>this.maxSize.height&&(a=this.maxSize.height,l=a*this.aspectRatio),{width:l,height:a}}applyAspectRatio(t,e,n){const r=n==="left"||n==="right",s=n==="top"||n==="bottom";return r?{width:t,height:t/this.aspectRatio}:s?{width:e*this.aspectRatio,height:e}:{width:t,height:t/this.aspectRatio}}};function Km(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof A){const i=r.index();return r.parent.canReplaceWith(i,i+1,e)}let s=r.depth;for(;s>=0;){const i=r.index(s);if(r.node(s).contentMatchAt(i).matchType(e))return!0;s-=1}return!1}var Um={};_s(Um,{createAtomBlockMarkdownSpec:()=>Jm,createBlockMarkdownSpec:()=>Gm,createInlineMarkdownSpec:()=>Zm,parseAttributes:()=>Xs,parseIndentedBlocks:()=>ls,renderNestedMarkdownContent:()=>Zs,serializeAttributes:()=>Ys});function Xs(t){if(!(t!=null&&t.trim()))return{};const e={},n=[],r=t.replace(/["']([^"']*)["']/g,c=>(n.push(c),`__QUOTED_${n.length-1}__`)),s=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(s){const c=s.map(u=>u.trim().slice(1));e.class=c.join(" ")}const i=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);i&&(e.id=i[1]);const o=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(o)).forEach(([,c,u])=>{var d;const h=parseInt(((d=u.match(/__QUOTED_(\d+)__/))==null?void 0:d[1])||"0",10),f=n[h];f&&(e[c]=f.slice(1,-1))});const a=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return a&&a.split(/\s+/).filter(Boolean).forEach(u=>{u.match(/^[a-zA-Z][\w-]*$/)&&(e[u]=!0)}),e}function Ys(t){if(!t||Object.keys(t).length===0)return"";const e=[];return t.class&&String(t.class).split(/\s+/).filter(Boolean).forEach(r=>e.push(`.${r}`)),t.id&&e.push(`#${t.id}`),Object.entries(t).forEach(([n,r])=>{n==="class"||n==="id"||(r===!0?e.push(n):r!==!1&&r!=null&&e.push(`${n}="${String(r)}"`))}),e.join(" ")}function Jm(t){const{nodeName:e,name:n,parseAttributes:r=Xs,serializeAttributes:s=Ys,defaultAttributes:i={},requiredAttributes:o=[],allowedAttributes:l}=t,a=n||e,c=u=>{if(!l)return u;const d={};return l.forEach(h=>{h in u&&(d[h]=u[h])}),d};return{parseMarkdown:(u,d)=>{const h={...i,...u.attributes};return d.createNode(e,h,[])},markdownTokenizer:{name:e,level:"block",start(u){var d;const h=new RegExp(`^:::${a}(?:\\s|$)`,"m"),f=(d=u.match(h))==null?void 0:d.index;return f!==void 0?f:-1},tokenize(u,d,h){const f=new RegExp(`^:::${a}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),p=u.match(f);if(!p)return;const m=p[1]||"",g=r(m);if(!o.find(k=>!(k in g)))return{type:e,raw:p[0],attributes:g}}},renderMarkdown:u=>{const d=c(u.attrs||{}),h=s(d),f=h?` {${h}}`:"";return`:::${a}${f} :::`}}}function Gm(t){const{nodeName:e,name:n,getContent:r,parseAttributes:s=Xs,serializeAttributes:i=Ys,defaultAttributes:o={},content:l="block",allowedAttributes:a}=t,c=n||e,u=d=>{if(!a)return d;const h={};return a.forEach(f=>{f in d&&(h[f]=d[f])}),h};return{parseMarkdown:(d,h)=>{let f;if(r){const m=r(d);f=typeof m=="string"?[{type:"text",text:m}]:m}else l==="block"?f=h.parseChildren(d.tokens||[]):f=h.parseInline(d.tokens||[]);const p={...o,...d.attributes};return h.createNode(e,p,f)},markdownTokenizer:{name:e,level:"block",start(d){var h;const f=new RegExp(`^:::${c}`,"m"),p=(h=d.match(f))==null?void 0:h.index;return p!==void 0?p:-1},tokenize(d,h,f){var p;const m=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),g=d.match(m);if(!g)return;const[b,k=""]=g,w=s(k);let C=1;const v=b.length;let I="";const M=/^:::([\w-]*)(\s.*)?/gm,D=d.slice(v);for(M.lastIndex=0;;){const B=M.exec(D);if(B===null)break;const De=B.index,br=B[1];if(!((p=B[2])!=null&&p.endsWith(":::"))){if(br)C+=1;else if(C-=1,C===0){const fn=D.slice(0,De);I=fn.trim();const xr=d.slice(0,v+De+B[0].length);let He=[];if(I)if(l==="block")for(He=f.blockTokens(fn),He.forEach(Re=>{Re.text&&(!Re.tokens||Re.tokens.length===0)&&(Re.tokens=f.inlineTokens(Re.text))});He.length>0;){const Re=He[He.length-1];if(Re.type==="paragraph"&&(!Re.text||Re.text.trim()===""))He.pop();else break}else He=f.inlineTokens(I);return{type:e,raw:xr,attributes:w,content:I,tokens:He}}}}}},renderMarkdown:(d,h)=>{const f=u(d.attrs||{}),p=i(f),m=p?` {${p}}`:"",g=h.renderChildren(d.content||[],`

`);return`:::${c}${m}

${g}

:::`}}}function Xm(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);for(;r!==null;){const[,s,i,o]=r;e[s]=i||o,r=n.exec(t)}return e}function Ym(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function Zm(t){const{nodeName:e,name:n,getContent:r,parseAttributes:s=Xm,serializeAttributes:i=Ym,defaultAttributes:o={},selfClosing:l=!1,allowedAttributes:a}=t,c=n||e,u=h=>{if(!a)return h;const f={};return a.forEach(p=>{const m=typeof p=="string"?p:p.name,g=typeof p=="string"?void 0:p.skipIfDefault;if(m in h){const b=h[m];if(g!==void 0&&b===g)return;f[m]=b}}),f},d=c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(h,f)=>{const p={...o,...h.attributes};if(l)return f.createNode(e,p);const m=r?r(h):h.content||"";return m?f.createNode(e,p,[f.createTextNode(m)]):f.createNode(e,p,[])},markdownTokenizer:{name:e,level:"inline",start(h){const f=l?new RegExp(`\\[${d}\\s*[^\\]]*\\]`):new RegExp(`\\[${d}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${d}\\]`),p=h.match(f),m=p==null?void 0:p.index;return m!==void 0?m:-1},tokenize(h,f,p){const m=l?new RegExp(`^\\[${d}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${d}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${d}\\]`),g=h.match(m);if(!g)return;let b="",k="";if(l){const[,C]=g;k=C}else{const[,C,v]=g;k=C,b=v||""}const w=s(k.trim());return{type:e,raw:g[0],content:b.trim(),attributes:w}}},renderMarkdown:h=>{let f="";r?f=r(h):h.content&&h.content.length>0&&(f=h.content.filter(b=>b.type==="text").map(b=>b.text).join(""));const p=u(h.attrs||{}),m=i(p),g=m?` ${m}`:"";return l?`[${c}${g}]`:`[${c}${g}]${f}[/${c}]`}}}function ls(t,e,n){var r,s,i,o;const l=t.split(`
`),a=[];let c="",u=0;const d=e.baseIndentSize||2;for(;u<l.length;){const h=l[u],f=h.match(e.itemPattern);if(!f){if(a.length>0)break;if(h.trim()===""){u+=1,c=`${c}${h}
`;continue}else return}const p=e.extractItemData(f),{indentLevel:m,mainContent:g}=p;c=`${c}${h}
`;const b=[g];for(u+=1;u<l.length;){const v=l[u];if(v.trim()===""){const M=l.slice(u+1).findIndex(De=>De.trim()!=="");if(M===-1)break;if((((s=(r=l[u+1+M].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:s.length)||0)>m){b.push(v),c=`${c}${v}
`,u+=1;continue}else break}if((((o=(i=v.match(/^(\s*)/))==null?void 0:i[1])==null?void 0:o.length)||0)>m)b.push(v),c=`${c}${v}
`,u+=1;else break}let k;const w=b.slice(1);if(w.length>0){const v=w.map(I=>I.slice(m+d)).join(`
`);v.trim()&&(e.customNestedParser?k=e.customNestedParser(v):k=n.blockTokens(v))}const C=e.createToken(p,k);a.push(C)}if(a.length!==0)return{items:a,raw:c}}function Zs(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const s=typeof n=="function"?n(r):n,[i,...o]=t.content,l=e.renderChildren([i]),a=[`${s}${l}`];return o&&o.length>0&&o.forEach(c=>{const u=e.renderChildren([c]);if(u){const d=u.split(`
`).map(h=>h?e.indent(h):"").join(`
`);a.push(d)}}),a.join(`
`)}function Qm(t,e,n={}){const{state:r}=e,{doc:s,tr:i}=r,o=t;s.descendants((l,a)=>{const c=i.mapping.map(a),u=i.mapping.map(a)+l.nodeSize;let d=null;if(l.marks.forEach(f=>{if(f!==o)return!1;d=f}),!d)return;let h=!1;if(Object.keys(n).forEach(f=>{n[f]!==d.attrs[f]&&(h=!0)}),h){const f=t.type.create({...t.attrs,...n});i.removeMark(c,u,t.type),i.addMark(c,u,f)}}),i.docChanged&&e.view.dispatch(i)}var J=class uc extends Gs{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new uc(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function wt(t){return new Lm({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:s})=>{const i=P(t.getAttributes,void 0,r,s);if(i===!1||i===null)return null;const{tr:o}=e,l=r[r.length-1],a=r[0];let c=n.to;if(l){const u=a.search(/\S/),d=n.from+a.indexOf(l),h=d+l.length;if(Js(n.from,n.to,e.doc).filter(p=>p.mark.type.excluded.find(g=>g===t.type&&g!==p.mark.type)).filter(p=>p.to>d).length)return null;h<n.to&&o.delete(h,n.to),d>n.from&&o.delete(n.from+u,d),c=n.from+u+l.length,o.addMark(n.from+u,c,t.type.create(i||{})),o.removeStoredMark(t.type)}}})}const{getOwnPropertyNames:eg,getOwnPropertySymbols:tg}=Object,{hasOwnProperty:ng}=Object.prototype;function fo(t,e){return function(r,s,i){return t(r,s,i)&&e(r,s,i)}}function vn(t){return function(n,r,s){if(!n||!r||typeof n!="object"||typeof r!="object")return t(n,r,s);const{cache:i}=s,o=i.get(n),l=i.get(r);if(o&&l)return o===r&&l===n;i.set(n,r),i.set(r,n);const a=t(n,r,s);return i.delete(n),i.delete(r),a}}function rg(t){return t!=null?t[Symbol.toStringTag]:void 0}function po(t){return eg(t).concat(tg(t))}const sg=Object.hasOwn||((t,e)=>ng.call(t,e));function vt(t,e){return t===e||!t&&!e&&t!==t&&e!==e}const ig="__v",og="__o",lg="_owner",{getOwnPropertyDescriptor:mo,keys:go}=Object;function ag(t,e,n){let r=t.length;if(e.length!==r)return!1;for(;r-- >0;)if(!n.equals(t[r],e[r],r,r,t,e,n))return!1;return!0}function cg(t,e){return vt(t.getTime(),e.getTime())}function ug(t,e){return t.name===e.name&&t.message===e.message&&t.cause===e.cause&&t.stack===e.stack}function dg(t,e){return t===e}function yo(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const s=new Array(r),i=t.entries();let o,l,a=0;for(;(o=i.next())&&!o.done;){const c=e.entries();let u=!1,d=0;for(;(l=c.next())&&!l.done;){if(s[d]){d++;continue}const h=o.value,f=l.value;if(n.equals(h[0],f[0],a,d,t,e,n)&&n.equals(h[1],f[1],h[0],f[0],t,e,n)){u=s[d]=!0;break}d++}if(!u)return!1;a++}return!0}const hg=vt;function fg(t,e,n){const r=go(t);let s=r.length;if(go(e).length!==s)return!1;for(;s-- >0;)if(!dc(t,e,n,r[s]))return!1;return!0}function Wt(t,e,n){const r=po(t);let s=r.length;if(po(e).length!==s)return!1;let i,o,l;for(;s-- >0;)if(i=r[s],!dc(t,e,n,i)||(o=mo(t,i),l=mo(e,i),(o||l)&&(!o||!l||o.configurable!==l.configurable||o.enumerable!==l.enumerable||o.writable!==l.writable)))return!1;return!0}function pg(t,e){return vt(t.valueOf(),e.valueOf())}function mg(t,e){return t.source===e.source&&t.flags===e.flags}function bo(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const s=new Array(r),i=t.values();let o,l;for(;(o=i.next())&&!o.done;){const a=e.values();let c=!1,u=0;for(;(l=a.next())&&!l.done;){if(!s[u]&&n.equals(o.value,l.value,o.value,l.value,t,e,n)){c=s[u]=!0;break}u++}if(!c)return!1}return!0}function gg(t,e){let n=t.length;if(e.length!==n)return!1;for(;n-- >0;)if(t[n]!==e[n])return!1;return!0}function yg(t,e){return t.hostname===e.hostname&&t.pathname===e.pathname&&t.protocol===e.protocol&&t.port===e.port&&t.hash===e.hash&&t.username===e.username&&t.password===e.password}function dc(t,e,n,r){return(r===lg||r===og||r===ig)&&(t.$$typeof||e.$$typeof)?!0:sg(e,r)&&n.equals(t[r],e[r],r,r,t,e,n)}const bg="[object Arguments]",xg="[object Boolean]",kg="[object Date]",wg="[object Error]",Sg="[object Map]",Cg="[object Number]",vg="[object Object]",Mg="[object RegExp]",Tg="[object Set]",Eg="[object String]",Ag="[object URL]",{isArray:Ng}=Array,xo=typeof ArrayBuffer<"u"&&typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView:null,{assign:ko}=Object,Og=Object.prototype.toString.call.bind(Object.prototype.toString);function Ig({areArraysEqual:t,areDatesEqual:e,areErrorsEqual:n,areFunctionsEqual:r,areMapsEqual:s,areNumbersEqual:i,areObjectsEqual:o,arePrimitiveWrappersEqual:l,areRegExpsEqual:a,areSetsEqual:c,areTypedArraysEqual:u,areUrlsEqual:d,unknownTagComparators:h}){return function(p,m,g){if(p===m)return!0;if(p==null||m==null)return!1;const b=typeof p;if(b!==typeof m)return!1;if(b!=="object")return b==="number"?i(p,m,g):b==="function"?r(p,m,g):!1;const k=p.constructor;if(k!==m.constructor)return!1;if(k===Object)return o(p,m,g);if(Ng(p))return t(p,m,g);if(xo!=null&&xo(p))return u(p,m,g);if(k===Date)return e(p,m,g);if(k===RegExp)return a(p,m,g);if(k===Map)return s(p,m,g);if(k===Set)return c(p,m,g);const w=Og(p);if(w===kg)return e(p,m,g);if(w===Mg)return a(p,m,g);if(w===Sg)return s(p,m,g);if(w===Tg)return c(p,m,g);if(w===vg)return typeof p.then!="function"&&typeof m.then!="function"&&o(p,m,g);if(w===Ag)return d(p,m,g);if(w===wg)return n(p,m,g);if(w===bg)return o(p,m,g);if(w===xg||w===Cg||w===Eg)return l(p,m,g);if(h){let C=h[w];if(!C){const v=rg(p);v&&(C=h[v])}if(C)return C(p,m,g)}return!1}}function Dg({circular:t,createCustomConfig:e,strict:n}){let r={areArraysEqual:n?Wt:ag,areDatesEqual:cg,areErrorsEqual:ug,areFunctionsEqual:dg,areMapsEqual:n?fo(yo,Wt):yo,areNumbersEqual:hg,areObjectsEqual:n?Wt:fg,arePrimitiveWrappersEqual:pg,areRegExpsEqual:mg,areSetsEqual:n?fo(bo,Wt):bo,areTypedArraysEqual:n?Wt:gg,areUrlsEqual:yg,unknownTagComparators:void 0};if(e&&(r=ko({},r,e(r))),t){const s=vn(r.areArraysEqual),i=vn(r.areMapsEqual),o=vn(r.areObjectsEqual),l=vn(r.areSetsEqual);r=ko({},r,{areArraysEqual:s,areMapsEqual:i,areObjectsEqual:o,areSetsEqual:l})}return r}function Rg(t){return function(e,n,r,s,i,o,l){return t(e,n,l)}}function Lg({circular:t,comparator:e,createState:n,equals:r,strict:s}){if(n)return function(l,a){const{cache:c=t?new WeakMap:void 0,meta:u}=n();return e(l,a,{cache:c,equals:r,meta:u,strict:s})};if(t)return function(l,a){return e(l,a,{cache:new WeakMap,equals:r,meta:void 0,strict:s})};const i={cache:void 0,equals:r,meta:void 0,strict:s};return function(l,a){return e(l,a,i)}}const Pg=ot();ot({strict:!0});ot({circular:!0});ot({circular:!0,strict:!0});ot({createInternalComparator:()=>vt});ot({strict:!0,createInternalComparator:()=>vt});ot({circular:!0,createInternalComparator:()=>vt});ot({circular:!0,createInternalComparator:()=>vt,strict:!0});function ot(t={}){const{circular:e=!1,createInternalComparator:n,createState:r,strict:s=!1}=t,i=Dg(t),o=Ig(i),l=n?n(o):Rg(o);return Lg({circular:e,comparator:o,createState:r,equals:l,strict:s})}var zg=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},Bg=({contentComponent:t})=>{const e=nl.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return y.jsx(y.Fragment,{children:Object.values(e)})};function jg(){const t=new Set;let e={};return{subscribe(n){return t.add(n),()=>{t.delete(n)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(n,r){e={...e,[n]:Wc.createPortal(r.reactElement,r.element,n)},t.forEach(s=>s())},removeRenderer(n){const r={...e};delete r[n],e=r,t.forEach(s=>s())}}}var $g=class extends et.Component{constructor(t){var e;super(t),this.editorContentRef=et.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!((e=t.editor)!=null&&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.view.dom),t.setOptions({element:e}),t.contentComponent=jg(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=t.contentComponent.subscribe(()=>{this.setState(n=>n.hasContentComponentInitialized?n:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),t.createNodeViews(),this.initialized=!0}}componentWillUnmount(){var t;const e=this.props.editor;if(e){this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null;try{if(!((t=e.view.dom)!=null&&t.firstChild))return;const n=document.createElement("div");n.append(e.view.dom),e.setOptions({element:n})}catch{}}}render(){const{editor:t,innerRef:e,...n}=this.props;return y.jsxs(y.Fragment,{children:[y.jsx("div",{ref:zg(e,this.editorContentRef),...n}),(t==null?void 0:t.contentComponent)&&y.jsx(Bg,{contentComponent:t.contentComponent})]})}},Fg=R.forwardRef((t,e)=>{const n=et.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return et.createElement($g,{key:n,innerRef:e,...t})}),Hg=et.memo(Fg),Vg=typeof window<"u"?R.useLayoutEffect:R.useEffect,_g=class{constructor(t){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=t,this.lastSnapshot={editor:t,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(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 e=()=>{this.transactionNumber+=1,this.subscribers.forEach(r=>r())},n=this.editor;return n.on("transaction",e),()=>{n.off("transaction",e)}}}};function hc(t){var e;const[n]=R.useState(()=>new _g(t.editor)),r=yu.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:Pg);return Vg(()=>n.watch(t.editor),[t.editor,n]),R.useDebugValue(r),r}var Wg=!1,as=typeof window>"u",qg=as||!!(typeof window<"u"&&window.next),Kg=class fc{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,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(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(n=>n())}getInitialEditor(){return this.options.current.immediatelyRender===void 0?as||qg?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var s,i;return(i=(s=this.options.current).onBeforeCreate)==null?void 0:i.call(s,...r)},onBlur:(...r)=>{var s,i;return(i=(s=this.options.current).onBlur)==null?void 0:i.call(s,...r)},onCreate:(...r)=>{var s,i;return(i=(s=this.options.current).onCreate)==null?void 0:i.call(s,...r)},onDestroy:(...r)=>{var s,i;return(i=(s=this.options.current).onDestroy)==null?void 0:i.call(s,...r)},onFocus:(...r)=>{var s,i;return(i=(s=this.options.current).onFocus)==null?void 0:i.call(s,...r)},onSelectionUpdate:(...r)=>{var s,i;return(i=(s=this.options.current).onSelectionUpdate)==null?void 0:i.call(s,...r)},onTransaction:(...r)=>{var s,i;return(i=(s=this.options.current).onTransaction)==null?void 0:i.call(s,...r)},onUpdate:(...r)=>{var s,i;return(i=(s=this.options.current).onUpdate)==null?void 0:i.call(s,...r)},onContentError:(...r)=>{var s,i;return(i=(s=this.options.current).onContentError)==null?void 0:i.call(s,...r)},onDrop:(...r)=>{var s,i;return(i=(s=this.options.current).onDrop)==null?void 0:i.call(s,...r)},onPaste:(...r)=>{var s,i;return(i=(s=this.options.current).onPaste)==null?void 0:i.call(s,...r)},onDelete:(...r)=>{var s,i;return(i=(s=this.options.current).onDelete)==null?void 0:i.call(s,...r)}};return new _m(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,n){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&n.extensions?e.extensions.length!==n.extensions.length?!1:e.extensions.every((s,i)=>{var o;return s===((o=n.extensions)==null?void 0:o[i])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?fc.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((r,s)=>r===e[s]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,n=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){n&&n.setOptions(this.options.current);return}n&&!n.isDestroyed&&(n.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function Ug(t={},e=[]){const n=R.useRef(t);n.current=t;const[r]=R.useState(()=>new Kg(n)),s=nl.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return R.useDebugValue(s),R.useEffect(r.onRender(e)),hc({editor:s,selector:({transactionNumber:i})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&i===0?0:i+1}),s}var Jg=R.createContext({editor:null});Jg.Consumer;var Gg=R.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),Xg=()=>R.useContext(Gg);et.forwardRef((t,e)=>{const{onDragStart:n}=Xg(),r=t.as||"div";return y.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});et.createContext({markViewContentRef:()=>{}});function Yg({size:t}){const e=te(),n=hc({editor:e,selector:r=>{var s,i,o;return{isBoldActive:(s=r.editor)==null?void 0:s.isActive("bold"),isItalicActive:(i=r.editor)==null?void 0:i.isActive("italic"),isUnderlineActive:(o=r.editor)==null?void 0:o.isActive("underline")}}});return y.jsxs("span",{className:ge("flex-shrink-0 whitespace-nowrap"),children:[y.jsx(me,{label:y.jsx(O,{message:"Bold"}),children:y.jsx(X,{disabled:!e,size:t,color:n!=null&&n.isBoldActive?"primary":null,onClick:()=>{e==null||e.commands.focus(),e==null||e.commands.toggleBold()},children:y.jsx(iu,{})})}),y.jsx(me,{label:y.jsx(O,{message:"Italic"}),children:y.jsx(X,{size:t,disabled:!e,color:n!=null&&n.isItalicActive?"primary":null,onClick:()=>{e==null||e.commands.focus(),e==null||e.commands.toggleItalic()},children:y.jsx(ou,{})})}),y.jsx(me,{label:y.jsx(O,{message:"Underline"}),children:y.jsx(X,{size:t,disabled:!e,color:n!=null&&n.isUnderlineActive?"primary":null,onClick:()=>{e==null||e.commands.focus(),e==null||e.commands.toggleUnderline()},children:y.jsx(lu,{})})})]})}function Te({children:t,modifier:e,separator:n="+"}){const r=qc()?y.jsx("span",{className:"text-base align-middle",children:"⌘"}):"Ctrl";return y.jsxs("kbd",{className:"text-xs text-muted",children:[e&&y.jsxs(y.Fragment,{children:[r,n]}),t]})}function Zg({size:t}){const e=te();return y.jsxs(er,{floatingMinWidth:"w-256",onItemSelected:n=>{e==null||e.commands.focus(),typeof n=="string"&&n.startsWith("h")?e==null||e.commands.toggleHeading({level:parseInt(n.replace("h",""))}):n==="code"?e==null||e.commands.toggleCode():n==="strike"?e==null||e.commands.toggleStrike():n==="super"?e==null||e.commands.toggleSuperscript():n==="sub"?e==null||e.commands.toggleSubscript():n==="blockquote"?e==null||e.commands.toggleBlockquote():n==="paragraph"&&(e==null||e.commands.setParagraph())},children:[y.jsx(tt,{className:ge("flex-shrink-0"),variant:"text",size:t,endIcon:y.jsx(Kc,{}),disabled:!e,children:y.jsx(O,{message:"Format"})}),y.jsxs(tr,{children:[y.jsx(j,{value:"h1",endSection:y.jsx(Te,{modifier:!0,children:"Alt+1"}),children:y.jsx(O,{message:"Heading :number",values:{number:1}})}),y.jsx(j,{value:"h2",endSection:y.jsx(Te,{modifier:!0,children:"Alt+2"}),children:y.jsx(O,{message:"Heading :number",values:{number:2}})}),y.jsx(j,{value:"h3",endSection:y.jsx(Te,{modifier:!0,children:"Alt+3"}),children:y.jsx(O,{message:"Heading :number",values:{number:3}})}),y.jsx(j,{value:"h4",endSection:y.jsx(Te,{modifier:!0,children:"Alt+4"}),children:y.jsx(O,{message:"Heading :number",values:{number:4}})}),y.jsx(j,{value:"code",endSection:y.jsx(Te,{modifier:!0,children:"E"}),children:y.jsx(O,{message:"Code"})}),y.jsx(j,{value:"strike",endSection:y.jsx(Te,{modifier:!0,children:"Shift+X"}),children:y.jsx(O,{message:"Strikethrough"})}),y.jsx(j,{value:"super",endSection:y.jsx(Te,{modifier:!0,separator:" ",children:"."}),children:y.jsx(O,{message:"Superscript"})}),y.jsx(j,{value:"sub",endSection:y.jsx(Te,{modifier:!0,separator:" ",children:","}),children:y.jsx(O,{message:"Subscript"})}),y.jsx(j,{value:"blockquote",endSection:y.jsx(Te,{modifier:!0,children:"Shift+B"}),children:y.jsx(O,{message:"Blockquote"})}),y.jsx(j,{value:"paragraph",endSection:y.jsx(Te,{modifier:!0,children:"Alt+0"}),children:y.jsx(O,{message:"Paragraph"})})]})]})}const Qg=R.forwardRef((t,e)=>y.jsxs(Uc,{...t,ref:e,children:[y.jsx("path",{d:"M10.3 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10l-3.1-3.1a2 2 0 0 0-2.814.014L6 21"}),y.jsx("path",{d:"m14 19.5 3-3 3 3"}),y.jsx("path",{d:"M17 22v-5.5"}),y.jsx("circle",{cx:"9",cy:"9",r:"2"})]}));function ey({size:t,iconSize:e,uploadType:n}){const r=te(),{selectAndUploadFile:s}=bu(),i=()=>{s({uploadType:n,showToastOnRestrictionFail:!0,onSuccess:async(o,l)=>{if(!r)return;const a=await Xo(l.native);r.commands.focus(),r.commands.setImage({src:o.url,width:a.width,height:a.height})}})};return y.jsx(me,{label:y.jsx(O,{message:"Insert image"}),children:y.jsx(X,{size:t,iconSize:e,onClick:i,className:ge("flex-shrink-0"),disabled:!r,children:y.jsx(Qg,{})})})}function ty({size:t}){const e=te();return y.jsxs("span",{className:ge("flex-shrink-0","whitespace-nowrap"),children:[y.jsx(me,{label:y.jsx(O,{message:"Decrease indent"}),children:y.jsx(X,{size:t,disabled:!e,onClick:()=>{e==null||e.commands.focus(),e==null||e.commands.outdent()},children:y.jsx(au,{})})}),y.jsx(me,{label:y.jsx(O,{message:"Increase indent"}),children:y.jsx(X,{size:t,disabled:!e,onClick:()=>{e==null||e.commands.focus(),e==null||e.commands.indent()},children:y.jsx(cu,{})})})]})}function ny({size:t}){const e=te(),[n,r]=R.useState(!1);return y.jsxs(y.Fragment,{children:[y.jsxs(er,{onItemSelected:s=>{s==="hr"?(e==null||e.commands.focus(),e==null||e.commands.setHorizontalRule()):s==="embed"?r("embed"):(e==null||e.commands.focus(),e==null||e.commands.addInfo({type:s}))},children:[y.jsx(X,{variant:"text",size:t,className:ge("flex-shrink-0"),disabled:!e,children:y.jsx(xu,{})}),y.jsxs(tr,{children:[y.jsx(j,{value:"hr",startIcon:y.jsx(Vt,{icon:Hu,size:"xs"}),children:y.jsx(O,{message:"Horizontal rule"})}),y.jsx(j,{value:"embed",startIcon:y.jsx(Vt,{icon:_u,size:"xs"}),children:y.jsx(O,{message:"Embed"})}),y.jsx(j,{value:"important",startIcon:y.jsx(Vt,{icon:ku,size:"xs"}),children:y.jsx(O,{message:"Important"})}),y.jsx(j,{value:"warning",startIcon:y.jsx(Vt,{icon:qu,size:"xs"}),children:y.jsx(O,{message:"Warning"})}),y.jsx(j,{value:"success",startIcon:y.jsx(Vt,{icon:wu,size:"xs"}),children:y.jsx(O,{message:"Note"})})]})]}),y.jsx(nr,{type:"modal",isOpen:!!n,onClose:()=>{r(!1)},children:y.jsx(ry,{})})]})}function ry(){const t=te(),e=t==null?void 0:t.getAttributes("embed").src,n=Ko({defaultValues:{src:e}}),{formId:r,close:s}=bs();return y.jsxs(xs,{children:[y.jsx(ks,{children:y.jsx(O,{message:"Insert link"})}),y.jsx(ws,{children:y.jsx(Uo,{form:n,id:r,onSubmit:i=>{t==null||t.commands.setEmbed(i),s()},children:y.jsx(zn,{name:"src",label:y.jsx(O,{message:"Embed URL"}),autoFocus:!0,type:"url",required:!0})})}),y.jsxs(Ss,{children:[y.jsx(tt,{onClick:s,variant:"text",children:y.jsx(O,{message:"Cancel"})}),y.jsx(tt,{type:"submit",form:r,disabled:!n.formState.isValid,variant:"flat",color:"primary",children:y.jsx(O,{message:"Add"})})]})]})}function sy(t,{text:e,target:n,href:r}){t.state.selection.empty&&e?(t.commands.insertContent(`<a href="${r}" target="${n}">${e}</a>`),t.commands.focus()):t.state.selection.empty||(r?t.chain().focus().extendMarkRange("link").setLink({href:r,target:n}).run():t.chain().focus().extendMarkRange("link").unsetLink().run())}function iy({size:t}){const e=te();return y.jsxs(nr,{type:"modal",children:[y.jsx(me,{label:y.jsx(O,{message:"Insert link"}),children:y.jsx(X,{disabled:!e,size:t,className:ge("flex-shrink-0"),children:y.jsx(uu,{})})}),y.jsx(oy,{})]})}function oy(){const t=te(),e=t==null?void 0:t.getAttributes("link").href,n=t==null?void 0:t.state.doc.textBetween(t==null?void 0:t.state.selection.from,t==null?void 0:t.state.selection.to,""),r=Ko({defaultValues:{href:e,text:n,target:"_blank"}}),{formId:s,close:i}=bs();return y.jsxs(xs,{children:[y.jsx(ks,{children:y.jsx(O,{message:"Insert link"})}),y.jsx(ws,{children:y.jsxs(Uo,{form:r,id:s,onSubmit:o=>{sy(t,o),i()},children:[y.jsx(zn,{required:!0,name:"href",label:y.jsx(O,{message:"URL"}),autoFocus:!0,className:"mb-20"}),y.jsx(zn,{required:!0,name:"text",label:y.jsx(O,{message:"Text to display"}),className:"mb-20"}),y.jsxs(Su,{selectionMode:"single",name:"target",label:y.jsx(O,{message:"Open link in..."}),children:[y.jsx(j,{value:"_self",children:y.jsx(O,{message:"Current window"})}),y.jsx(j,{value:"_blank",children:y.jsx(O,{message:"New window"})})]})]})}),y.jsxs(Ss,{children:[y.jsx(tt,{onClick:i,variant:"text",children:y.jsx(O,{message:"Cancel"})}),y.jsx(tt,{type:"submit",form:s,variant:"flat",color:"primary",children:y.jsx(O,{message:"Save"})})]})]})}function ly({size:t}){const e=te(),n=e==null?void 0:e.isActive("bulletList"),r=e==null?void 0:e.isActive("orderedList");return y.jsxs("span",{className:ge("flex-shrink-0","whitespace-nowrap"),children:[y.jsx(me,{label:y.jsx(O,{message:"Bulleted list"}),children:y.jsx(X,{disabled:!e,size:t,color:n?"primary":null,onClick:()=>{e==null||e.commands.focus(),e==null||e.commands.toggleBulletList()},children:y.jsx(du,{})})}),y.jsx(me,{label:y.jsx(O,{message:"Numbered list"}),children:y.jsx(X,{disabled:!e,size:t,color:r?"primary":null,onClick:()=>{e==null||e.commands.focus(),e==null||e.commands.toggleOrderedList()},children:y.jsx(hu,{})})})]})}function ay({size:t="sm",justify:e="justify-center-safe",hideInsertButton:n=!1,imageUploadType:r}){return y.jsxs("div",{className:ge("hidden-scrollbar flex flex-shrink-0 items-center overflow-x-auto border-b px-4 py-2 text-muted",e),children:[y.jsx(Zg,{size:t}),y.jsx(Mt,{}),y.jsx(Yg,{size:t}),y.jsx(Mt,{}),y.jsx(Ku,{size:t}),y.jsx(ty,{size:t}),y.jsx(Mt,{}),y.jsx(ly,{size:t}),y.jsx(Mt,{}),y.jsx(iy,{size:t}),y.jsx(ey,{size:t,uploadType:r}),!n&&y.jsx(ny,{size:t}),y.jsx(Mt,{}),y.jsx(Gu,{size:t}),y.jsx(Mt,{}),y.jsx(Ju,{size:t}),y.jsx(Uu,{size:t})]})}function cy(){const t=te();return y.jsxs("span",{className:"flex items-center max-md:hidden",children:[y.jsx(X,{size:"md",disabled:!t||!t.can().undo(),onClick:()=>{t==null||t.commands.focus(),t==null||t.commands.undo()},children:y.jsx(fu,{})}),y.jsx(X,{size:"md",disabled:!t||!t.can().redo(),onClick:()=>{t==null||t.commands.focus(),t==null||t.commands.redo()},children:y.jsx(pu,{})})]})}const uy=et.lazy(()=>Gc(()=>import("./ace-editor-B1LNI9d2.js"),__vite__mapDeps([0,1,2]),import.meta.url));function dy({defaultValue:t,mode:e="html",title:n,onSave:r,isSaving:s,footerStartAction:i,beautify:o,editorRef:l}){const[a,c]=R.useState(t),[u,d]=R.useState(!0);return y.jsxs(xs,{size:"fullscreen",className:"h-full w-full",children:[y.jsx(ks,{children:n}),y.jsx(ws,{className:"relative flex-auto",padding:"p-0",children:y.jsx(R.Suspense,{fallback:y.jsx("div",{className:"flex h-400 w-full items-center justify-center",children:y.jsx(Jc,{"aria-label":"Loading editor...",isIndeterminate:!0,size:"md"})}),children:y.jsx(uy,{beautify:o,mode:e,onChange:h=>c(h),defaultValue:a||"",onIsValidChange:d,editorRef:l})})}),y.jsx(hy,{disabled:!u||s,value:a,onSave:r,startAction:i})]})}function hy({disabled:t,value:e,onSave:n,startAction:r}){const{close:s}=bs();return y.jsxs(Ss,{dividerTop:!0,startAction:r,children:[y.jsx(tt,{onClick:()=>s(),children:y.jsx(O,{message:"Cancel"})}),y.jsx(tt,{disabled:t,variant:"flat",color:"primary",onClick:()=>{n?n(e):s(e)},children:y.jsx(O,{message:"Save"})})]})}function fy(){const t=te();return y.jsxs(nr,{type:"modal",onClose:e=>{e!=null&&(t==null||t.commands.setContent(e))},children:[y.jsx(me,{label:y.jsx(O,{message:"Source code"}),children:y.jsx(X,{className:"text-muted max-md:hidden",variant:"text",disabled:!t,children:y.jsx(Go,{})})}),y.jsx(dy,{title:y.jsx(O,{message:"Source code"}),defaultValue:(t==null?void 0:t.getHTML())??""})]})}function py({children:t,onSave:e,saveButton:n,isSaving:r=!1,rightContent:s,showSidebarToggleButton:i=!0}){const o=te();return y.jsx(Yo,{showSidebarToggleButton:i,rightContent:y.jsxs(R.Fragment,{children:[y.jsx(cy,{}),y.jsx(fy,{}),e&&y.jsx(my,{onSave:()=>{e((o==null?void 0:o.getHTML())??"")},isLoading:r}),n,s]}),children:t})}function my({onSave:t,isLoading:e}){const n=te(),s=Jo().watch("title");return y.jsx(tt,{variant:"flat",size:"sm",color:"primary",className:"min-w-90",disabled:e||!s||!n,onClick:()=>t((n==null?void 0:n.getHTML())??""),children:y.jsx(O,{message:"Save"})})}var gy=20,pc=(t,e=0)=>{const n=[];return!t.children.length||e>gy||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...pc(r,e+1))}),n},yy=t=>{if(!t.children.length)return;const e=pc(t);e&&e.forEach(n=>{var r,s;const i=n.getAttribute("style"),o=(s=(r=n.parentElement)==null?void 0:r.closest("span"))==null?void 0:s.getAttribute("style");n.setAttribute("style",`${o};${i}`)})},mc=Oe.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&yy(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",z(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleTextStyle:t=>({commands:e})=>e.toggleMark(this.name,t),removeEmptyTextStyle:()=>({tr:t})=>{const{selection:e}=t;return t.doc.nodesBetween(e.from,e.to,(n,r)=>{if(n.isTextblock)return!0;n.marks.filter(s=>s.type===this.type).some(s=>Object.values(s.attrs).some(i=>!!i))||t.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),by=L.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(s=>s.trim()).filter(Boolean);for(let s=r.length-1;s>=0;s-=1){const i=r[s].split(":");if(i.length>=2){const o=i[0].trim().toLowerCase(),l=i.slice(1).join(":").trim();if(o==="background-color")return l.replace(/['"]+/g,"")}}}return(e=t.style.backgroundColor)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.backgroundColor?{style:`background-color: ${t.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:t=>({chain:e})=>e().setMark("textStyle",{backgroundColor:t}).run(),unsetBackgroundColor:()=>({chain:t})=>t().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),gc=L.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(s=>s.trim()).filter(Boolean);for(let s=r.length-1;s>=0;s-=1){const i=r[s].split(":");if(i.length>=2){const o=i[0].trim().toLowerCase(),l=i.slice(1).join(":").trim();if(o==="color")return l.replace(/['"]+/g,"")}}}return(e=t.style.color)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}}}}]},addCommands(){return{setColor:t=>({chain:e})=>e().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),xy=L.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:t=>t.style.fontFamily,renderHTML:t=>t.fontFamily?{style:`font-family: ${t.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:t=>({chain:e})=>e().setMark("textStyle",{fontFamily:t}).run(),unsetFontFamily:()=>({chain:t})=>t().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),ky=L.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:t=>t.style.fontSize,renderHTML:t=>t.fontSize?{style:`font-size: ${t.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:t=>({chain:e})=>e().setMark("textStyle",{fontSize:t}).run(),unsetFontSize:()=>({chain:t})=>t().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),wy=L.create({name:"lineHeight",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:t=>t.style.lineHeight,renderHTML:t=>t.lineHeight?{style:`line-height: ${t.lineHeight}`}:{}}}}]},addCommands(){return{setLineHeight:t=>({chain:e})=>e().setMark("textStyle",{lineHeight:t}).run(),unsetLineHeight:()=>({chain:t})=>t().setMark("textStyle",{lineHeight:null}).removeEmptyTextStyle().run()}}});L.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(by.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(gc.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(xy.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(ky.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(wy.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(mc.configure(this.options.textStyle)),t}});const Sy=L.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:t=>t.style.backgroundColor.replace(/['"]+/g,""),renderHTML:t=>t.backgroundColor?{style:`background-color: ${t.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:t=>({chain:e})=>e().setMark("textStyle",{backgroundColor:t}).run(),unsetBackgroundColor:()=>({chain:t})=>t().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),Cy=J.create({name:"embed",group:"block",atom:!0,addAttributes(){return{allowfullscreen:{default:null},allow:{default:"autoplay; fullscreen; picture-in-picture"},src:{default:null}}},parseHTML(){return[{tag:"iframe"}]},renderHTML({HTMLAttributes:t}){return["iframe",z(this.options.HTMLAttributes,t)]},addCommands(){return{setEmbed:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}}}),vy=L.create({name:"indent",addOptions:()=>({types:["listItem","paragraph"],minLevel:0,maxLevel:6}),addGlobalAttributes(){return[{types:this.options.types,attributes:{indent:{renderHTML:t=>(t==null?void 0:t.indent)>this.options.minLevel?{"data-indent":t.indent}:null,parseHTML:t=>{const e=Number(t.getAttribute("data-indent"));return e&&e>this.options.minLevel?e:null}}}}]},addCommands(){const t=(r,s,i)=>{var l;const o=(l=r==null?void 0:r.doc)==null?void 0:l.nodeAt(s);if(o){const a=(o.attrs.indent||0)+i,{minLevel:c,maxLevel:u}=this.options,d=a<c?c:a>u?u:a;if(d!==o.attrs.indent){const{indent:h,...f}=o.attrs,p=d>c?{...f,indent:d}:f;return r.setNodeMarkup(s,o.type,p,o.marks)}}return r},e=(r,s)=>{const{doc:i,selection:o}=r;if(i&&o&&(o instanceof E||o instanceof de)){const{from:l,to:a}=o;i.nodesBetween(l,a,(c,u)=>this.options.types.includes(c.type.name)?(r=t(r,u,s),!1):!0)}return r},n=r=>()=>({tr:s,state:i,dispatch:o})=>{const{selection:l}=i;return s=s.setSelection(l),s=e(s,r),s.docChanged?(o==null||o(s),!0):!1};return{indent:n(1),outdent:n(-1)}},addKeyboardShortcuts(){return{Tab:({editor:t})=>t.state.selection.to>t.state.selection.from?this.editor.commands.indent():!1,"Shift-Tab":({editor:t})=>t.state.selection.to>t.state.selection.from?this.editor.commands.outdent():!1}}}),My=J.create({name:"be-info-block",group:"block",content:"block+",defining:!0,addOptions(){return{types:["important","warning","success"],defaultType:"success"}},addAttributes(){return{type:{default:this.options.defaultType,parseHTML:t=>{for(const e of this.options.types)if(t.classList.contains(e))return e;return this.options.defaultType},renderHTML:t=>({class:t.type})}}},parseHTML(){return[{tag:"div",contentElement:"p",getAttrs:t=>t.classList.contains("info-block")&&null}]},renderHTML({HTMLAttributes:t}){return["div",z(t,{class:"info-block"}),0]},addCommands(){return{addInfo:t=>({commands:e})=>e.wrapIn(this.name,t)}}}),wo={},Ty="hljs-";function Ey(t){const e=Zo.newInstance();return{highlight:n,highlightAuto:r,listLanguages:s,register:i,registerAlias:o,registered:l};function n(a,c,u){const d=u||wo,h=typeof d.prefix=="string"?d.prefix:Ty;if(!e.getLanguage(a))throw new Error("Unknown language: `"+a+"` is not registered");e.configure({__emitter:Ay,classPrefix:h});const f=e.highlight(c,{ignoreIllegals:!0,language:a});if(f.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:f.errorRaised});const p=f._emitter.root,m=p.data;return m.language=f.language,m.relevance=f.relevance,p}function r(a,c){const d=(c||wo).subset||s();let h=-1,f=0,p;for(;++h<d.length;){const m=d[h];if(!e.getLanguage(m))continue;const g=n(m,a,c);g.data&&g.data.relevance!==void 0&&g.data.relevance>f&&(f=g.data.relevance,p=g)}return p||{type:"root",children:[],data:{language:void 0,relevance:f}}}function s(){return e.listLanguages()}function i(a,c){if(typeof a=="string")e.registerLanguage(a,c);else{let u;for(u in a)Object.hasOwn(a,u)&&e.registerLanguage(u,a[u])}}function o(a,c){if(typeof a=="string")e.registerAliases(typeof c=="string"?c:[...c],{languageName:a});else{let u;for(u in a)if(Object.hasOwn(a,u)){const d=a[u];e.registerAliases(typeof d=="string"?d:[...d],{languageName:u})}}}function l(a){return!!e.getLanguage(a)}}class Ay{constructor(e){this.options=e,this.root={type:"root",children:[],data:{language:void 0,relevance:0}},this.stack=[this.root]}addText(e){if(e==="")return;const n=this.stack[this.stack.length-1],r=n.children[n.children.length-1];r&&r.type==="text"?r.value+=e:n.children.push({type:"text",value:e})}startScope(e){this.openNode(String(e))}endScope(){this.closeNode()}__addSublanguage(e,n){const r=this.stack[this.stack.length-1],s=e.root.children;n?r.children.push({type:"element",tagName:"span",properties:{className:[n]},children:s}):r.children.push(...s)}openNode(e){const n=this,r=e.split(".").map(function(o,l){return l?o+"_".repeat(l):n.options.classPrefix+o}),s=this.stack[this.stack.length-1],i={type:"element",tagName:"span",properties:{className:r},children:[]};s.children.push(i),this.stack.push(i)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}const we=Ey();we.register("javascript",Mu);we.register("typescript",Tu);we.register("html",Eu);we.register("css",Au);we.register("php",Nu);we.register("shell",Ou);we.register("bash",Iu);we.register("ruby",Du);we.register("python",Ru);we.register("java",Lu);we.register("c",Pu);var Br=4,Ny=/^```([a-z]+)?[\s\n]$/,Oy=/^~~~([a-z]+)?[\s\n]$/,yc=J.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:Br,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options;if(!n)return null;const i=[...((e=t.firstElementChild)==null?void 0:e.classList)||[]].filter(o=>o.startsWith(n)).map(o=>o.replace(n,""))[0];return i||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",z(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var n;return((n=t.raw)==null?void 0:n.startsWith("```"))===!1&&t.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var n;let r="";const s=((n=t.attrs)==null?void 0:n.language)||"";return t.content?r=[`\`\`\`${s}`,e.renderChildren(t.content),"```"].join(`
`):r=`\`\`\`${s}

\`\`\``,r},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:Br,{state:r}=t,{selection:s}=r,{$from:i,empty:o}=s;if(i.parent.type!==this.type)return!1;const l=" ".repeat(n);return o?t.commands.insertContent(l):t.commands.command(({tr:a})=>{const{from:c,to:u}=s,f=r.doc.textBetween(c,u,`
`,`
`).split(`
`).map(p=>l+p).join(`
`);return a.replaceWith(c,u,r.schema.text(f)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:Br,{state:r}=t,{selection:s}=r,{$from:i,empty:o}=s;return i.parent.type!==this.type?!1:o?t.commands.command(({tr:l})=>{var a;const{pos:c}=i,u=i.start(),d=i.end(),f=r.doc.textBetween(u,d,`
`,`
`).split(`
`);let p=0,m=0;const g=c-u;for(let I=0;I<f.length;I+=1){if(m+f[I].length>=g){p=I;break}m+=f[I].length+1}const k=((a=f[p].match(/^ */))==null?void 0:a[0])||"",w=Math.min(k.length,n);if(w===0)return!0;let C=u;for(let I=0;I<p;I+=1)C+=f[I].length+1;return l.delete(C,C+w),c-C<=w&&l.setSelection(E.create(l.doc,C)),!0}):t.commands.command(({tr:l})=>{const{from:a,to:c}=s,h=r.doc.textBetween(a,c,`
`,`
`).split(`
`).map(f=>{var p;const m=((p=f.match(/^ */))==null?void 0:p[0])||"",g=Math.min(m.length,n);return f.slice(g)}).join(`
`);return l.replaceWith(a,c,r.schema.text(h)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:s}=n;if(!s||r.parent.type!==this.type)return!1;const i=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`

`);return!i||!o?!1:t.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:r}=e,{$from:s,empty:i}=n;if(!i||s.parent.type!==this.type||!(s.parentOffset===s.parent.nodeSize-2))return!1;const l=s.after();return l===void 0?!1:r.nodeAt(l)?t.commands.command(({tr:c})=>(c.setSelection(N.near(r.resolve(l))),!0)):t.commands.exitCode()}}},addInputRules(){return[is({find:Ny,type:this.type,getAttributes:t=>({language:t[1]})}),is({find:Oy,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new H({key:new _("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),s=r?JSON.parse(r):void 0,i=s==null?void 0:s.mode;if(!n||!i)return!1;const{tr:o,schema:l}=t.state,a=l.text(n.replace(/\r\n?/g,`
`));return o.replaceSelectionWith(this.type.create({language:i},a)),o.selection.$from.parent.type!==this.type&&o.setSelection(E.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}}),Iy=yc;function bc(t,e=[]){return t.flatMap(n=>{const r=[...e,...n.properties?n.properties.className:[]];return n.children?bc(n.children,r):{text:n.value,classes:r}})}function So(t){return t.value||t.children||[]}function Dy(t){return!!Zo.getLanguage(t)}function Co({doc:t,name:e,lowlight:n,defaultLanguage:r}){const s=[];return rs(t,i=>i.type.name===e).forEach(i=>{var o;let l=i.pos+1;const a=i.node.attrs.language||r,c=n.listLanguages(),u=a&&(c.includes(a)||Dy(a)||(o=n.registered)!=null&&o.call(n,a))?So(n.highlight(a,i.node.textContent)):So(n.highlightAuto(i.node.textContent));bc(u).forEach(d=>{const h=l+d.text.length;if(d.classes.length){const f=G.inline(l,h,{class:d.classes.join(" ")});s.push(f)}l=h})}),$.create(t,s)}function Ry(t){return typeof t=="function"}function Ly({name:t,lowlight:e,defaultLanguage:n}){if(!["highlight","highlightAuto","listLanguages"].every(s=>Ry(e[s])))throw Error("You should provide an instance of lowlight to use the code-block-lowlight extension");const r=new H({key:new _("lowlight"),state:{init:(s,{doc:i})=>Co({doc:i,name:t,lowlight:e,defaultLanguage:n}),apply:(s,i,o,l)=>{const a=o.selection.$head.parent.type.name,c=l.selection.$head.parent.type.name,u=rs(o.doc,h=>h.type.name===t),d=rs(l.doc,h=>h.type.name===t);return s.docChanged&&([a,c].includes(t)||d.length!==u.length||s.steps.some(h=>h.from!==void 0&&h.to!==void 0&&u.some(f=>f.pos>=h.from&&f.pos+f.node.nodeSize<=h.to)))?Co({doc:s.doc,name:t,lowlight:e,defaultLanguage:n}):i.map(s.mapping,s.doc)}},props:{decorations(s){return r.getState(s)}}});return r}var Py=Iy.extend({addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),lowlight:{},languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:4,HTMLAttributes:{}}},addProseMirrorPlugins(){var t;return[...((t=this.parent)==null?void 0:t.call(this))||[],Ly({name:this.name,lowlight:this.options.lowlight,defaultLanguage:this.options.defaultLanguage})]}}),zy=Py,By=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,jy=J.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:t}){return["img",z(this.options.HTMLAttributes,t)]},parseMarkdown:(t,e)=>e.createNode("image",{src:t.href,title:t.title,alt:t.text}),renderMarkdown:t=>{var e,n,r,s,i,o;const l=(n=(e=t.attrs)==null?void 0:e.src)!=null?n:"",a=(s=(r=t.attrs)==null?void 0:r.alt)!=null?s:"",c=(o=(i=t.attrs)==null?void 0:i.title)!=null?o:"";return c?`![${a}](${l} "${c}")`:`![${a}](${l})`},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>"u")return null;const{directions:t,minWidth:e,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize;return({node:s,getPos:i,HTMLAttributes:o,editor:l})=>{const a=document.createElement("img");Object.entries(o).forEach(([d,h])=>{if(h!=null)switch(d){case"width":case"height":break;default:a.setAttribute(d,h);break}}),a.src=o.src;const c=new qm({element:a,editor:l,node:s,getPos:i,onResize:(d,h)=>{a.style.width=`${d}px`,a.style.height=`${h}px`},onCommit:(d,h)=>{const f=i();f!==void 0&&this.editor.chain().setNodeSelection(f).updateAttributes(this.name,{width:d,height:h}).run()},onUpdate:(d,h,f)=>d.type===s.type,options:{directions:t,min:{width:e,height:n},preserveAspectRatio:r===!0}}),u=c.dom;return u.style.visibility="hidden",u.style.pointerEvents="none",a.onload=()=>{u.style.visibility="",u.style.pointerEvents=""},c}},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[cc({find:By,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),$y=jy,Fy=Oe.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(t){return t!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sub",z(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()}}}),Hy=Fy,Vy=Oe.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(t){return t!=="super"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sup",z(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()}}}),_y=Vy;let cs,us;if(typeof WeakMap<"u"){let t=new WeakMap;cs=e=>t.get(e),us=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;cs=r=>{for(let s=0;s<t.length;s+=2)if(t[s]==r)return t[s+1]},us=(r,s)=>(n==10&&(n=0),t[n++]=r,t[n++]=s)}var q=class{constructor(t,e,n,r){this.width=t,this.height=e,this.map=n,this.problems=r}findCell(t){for(let e=0;e<this.map.length;e++){const n=this.map[e];if(n!=t)continue;const r=e%this.width,s=e/this.width|0;let i=r+1,o=s+1;for(let l=1;i<this.width&&this.map[e+l]==n;l++)i++;for(let l=1;o<this.height&&this.map[e+this.width*l]==n;l++)o++;return{left:r,top:s,right:i,bottom:o}}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:r,right:s,top:i,bottom:o}=this.findCell(t);return e=="horiz"?(n<0?r==0:s==this.width)?null:this.map[i*this.width+(n<0?r-1:s)]:(n<0?i==0:o==this.height)?null:this.map[r+this.width*(n<0?i-1:o)]}rectBetween(t,e){const{left:n,right:r,top:s,bottom:i}=this.findCell(t),{left:o,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(n,o),top:Math.min(s,a),right:Math.max(r,l),bottom:Math.max(i,c)}}cellsInRect(t){const e=[],n={};for(let r=t.top;r<t.bottom;r++)for(let s=t.left;s<t.right;s++){const i=r*this.width+s,o=this.map[i];n[o]||(n[o]=!0,!(s==t.left&&s&&this.map[i-1]==o||r==t.top&&r&&this.map[i-this.width]==o)&&e.push(o))}return e}positionAt(t,e,n){for(let r=0,s=0;;r++){const i=s+n.child(r).nodeSize;if(r==t){let o=e+t*this.width;const l=(t+1)*this.width;for(;o<l&&this.map[o]<s;)o++;return o==l?i-1:this.map[o]}s=i}}static get(t){return cs(t)||us(t,Wy(t))}};function Wy(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=qy(t),n=t.childCount,r=[];let s=0,i=null;const o=[];for(let c=0,u=e*n;c<u;c++)r[c]=0;for(let c=0,u=0;c<n;c++){const d=t.child(c);u++;for(let p=0;;p++){for(;s<r.length&&r[s]!=0;)s++;if(p==d.childCount)break;const m=d.child(p),{colspan:g,rowspan:b,colwidth:k}=m.attrs;for(let w=0;w<b;w++){if(w+c>=n){(i||(i=[])).push({type:"overlong_rowspan",pos:u,n:b-w});break}const C=s+w*e;for(let v=0;v<g;v++){r[C+v]==0?r[C+v]=u:(i||(i=[])).push({type:"collision",row:c,pos:u,n:g-v});const I=k&&k[v];if(I){const M=(C+v)%e*2,D=o[M];D==null||D!=I&&o[M+1]==1?(o[M]=I,o[M+1]=1):D==I&&o[M+1]++}}}s+=g,u+=m.nodeSize}const h=(c+1)*e;let f=0;for(;s<h;)r[s++]==0&&f++;f&&(i||(i=[])).push({type:"missing",row:c,n:f}),u++}(e===0||n===0)&&(i||(i=[])).push({type:"zero_sized"});const l=new q(e,n,r,i);let a=!1;for(let c=0;!a&&c<o.length;c+=2)o[c]!=null&&o[c+1]<n&&(a=!0);return a&&Ky(l,o,t),l}function qy(t){let e=-1,n=!1;for(let r=0;r<t.childCount;r++){const s=t.child(r);let i=0;if(n)for(let o=0;o<r;o++){const l=t.child(o);for(let a=0;a<l.childCount;a++){const c=l.child(a);o+c.attrs.rowspan>r&&(i+=c.attrs.colspan)}}for(let o=0;o<s.childCount;o++){const l=s.child(o);i+=l.attrs.colspan,l.attrs.rowspan>1&&(n=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function Ky(t,e,n){t.problems||(t.problems=[]);const r={};for(let s=0;s<t.map.length;s++){const i=t.map[s];if(r[i])continue;r[i]=!0;const o=n.nodeAt(i);if(!o)throw new RangeError(`No cell with offset ${i} found`);let l=null;const a=o.attrs;for(let c=0;c<a.colspan;c++){const u=e[(s+c)%t.width*2];u!=null&&(!a.colwidth||a.colwidth[c]!=u)&&((l||(l=Uy(a)))[c]=u)}l&&t.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}function Uy(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function le(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const n in t.nodes){const r=t.nodes[n],s=r.spec.tableRole;s&&(e[s]=r)}}return e}const Ke=new _("selectingCells");function Ht(t){for(let e=t.depth-1;e>0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function Jy(t){for(let e=t.depth;e>0;e--){const n=t.node(e).type.spec.tableRole;if(n==="cell"||n==="header_cell")return t.node(e)}return null}function Me(t){const e=t.selection.$head;for(let n=e.depth;n>0;n--)if(e.node(n).type.spec.tableRole=="row")return!0;return!1}function yr(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&&e.node.type.spec.tableRole=="cell")return e.$anchor;const n=Ht(e.$head)||Gy(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function Gy(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function ds(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function Xy(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function Qs(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function xc(t,e,n){const r=t.node(-1),s=q.get(r),i=t.start(-1),o=s.nextCell(t.pos-i,e,n);return o==null?null:t.node(0).resolve(i+o)}function St(t,e,n=1){const r={...t,colspan:t.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some(s=>s>0)||(r.colwidth=null)),r}function kc(t,e,n=1){const r={...t,colspan:t.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let s=0;s<n;s++)r.colwidth.splice(e,0,0)}return r}function Yy(t,e,n){const r=le(e.type.schema).header_cell;for(let s=0;s<t.height;s++)if(e.nodeAt(t.map[n+s*t.width]).type!=r)return!1;return!0}var V=class Pe extends N{constructor(e,n=e){const r=e.node(-1),s=q.get(r),i=e.start(-1),o=s.rectBetween(e.pos-i,n.pos-i),l=e.node(0),a=s.cellsInRect(o).filter(u=>u!=n.pos-i);a.unshift(n.pos-i);const c=a.map(u=>{const d=r.nodeAt(u);if(!d)throw new RangeError(`No cell with offset ${u} found`);const h=i+u+1;return new Ll(l.resolve(h),l.resolve(h+d.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=n}map(e,n){const r=e.resolve(n.map(this.$anchorCell.pos)),s=e.resolve(n.map(this.$headCell.pos));if(ds(r)&&ds(s)&&Qs(r,s)){const i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?Pe.rowSelection(r,s):i&&this.isColSelection()?Pe.colSelection(r,s):new Pe(r,s)}return E.between(r,s)}content(){const e=this.$anchorCell.node(-1),n=q.get(e),r=this.$anchorCell.start(-1),s=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},o=[];for(let a=s.top;a<s.bottom;a++){const c=[];for(let u=a*n.width+s.left,d=s.left;d<s.right;d++,u++){const h=n.map[u];if(i[h])continue;i[h]=!0;const f=n.findCell(h);let p=e.nodeAt(h);if(!p)throw new RangeError(`No cell with offset ${h} found`);const m=s.left-f.left,g=f.right-s.right;if(m>0||g>0){let b=p.attrs;if(m>0&&(b=St(b,0,m)),g>0&&(b=St(b,b.colspan-g,g)),f.left<s.left){if(p=p.type.createAndFill(b),!p)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(b)}`)}else p=p.type.create(b,p.content)}if(f.top<s.top||f.bottom>s.bottom){const b={...p.attrs,rowspan:Math.min(f.bottom,s.bottom)-Math.max(f.top,s.top)};f.top<s.top?p=p.type.createAndFill(b):p=p.type.create(b,p.content)}c.push(p)}o.push(e.child(a).copy(x.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:o;return new S(x.from(l),1,1)}replace(e,n=S.empty){const r=e.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){const{$from:l,$to:a}=s[o],c=e.mapping.slice(r);e.replace(c.map(l.pos),c.map(a.pos),o?S.empty:n)}const i=N.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,n){this.replace(e,new S(x.from(n),0,0))}forEachCell(e){const n=this.$anchorCell.node(-1),r=q.get(n),s=this.$anchorCell.start(-1),i=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-s,this.$headCell.pos-s));for(let o=0;o<i.length;o++)e(n.nodeAt(i[o]),s+i[o])}isColSelection(){const e=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(e,n)>0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,s=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,s)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const r=e.node(-1),s=q.get(r),i=e.start(-1),o=s.findCell(e.pos-i),l=s.findCell(n.pos-i),a=e.node(0);return o.top<=l.top?(o.top>0&&(e=a.resolve(i+s.map[o.left])),l.bottom<s.height&&(n=a.resolve(i+s.map[s.width*(s.height-1)+l.right-1]))):(l.top>0&&(n=a.resolve(i+s.map[l.left])),o.bottom<s.height&&(e=a.resolve(i+s.map[s.width*(s.height-1)+o.right-1]))),new Pe(e,n)}isRowSelection(){const e=this.$anchorCell.node(-1),n=q.get(e),r=this.$anchorCell.start(-1),s=n.colCount(this.$anchorCell.pos-r),i=n.colCount(this.$headCell.pos-r);if(Math.min(s,i)>0)return!1;const o=s+this.$anchorCell.nodeAfter.attrs.colspan,l=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(o,l)==n.width}eq(e){return e instanceof Pe&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),s=q.get(r),i=e.start(-1),o=s.findCell(e.pos-i),l=s.findCell(n.pos-i),a=e.node(0);return o.left<=l.left?(o.left>0&&(e=a.resolve(i+s.map[o.top*s.width])),l.right<s.width&&(n=a.resolve(i+s.map[s.width*(l.top+1)-1]))):(l.left>0&&(n=a.resolve(i+s.map[l.top*s.width])),o.right<s.width&&(e=a.resolve(i+s.map[s.width*(o.top+1)-1]))),new Pe(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new Pe(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){return new Pe(e.resolve(n),e.resolve(r))}getBookmark(){return new Zy(this.$anchorCell.pos,this.$headCell.pos)}};V.prototype.visible=!1;N.jsonID("cell",V);var Zy=class wc{constructor(e,n){this.anchor=e,this.head=n}map(e){return new wc(e.map(this.anchor),e.map(this.head))}resolve(e){const n=e.resolve(this.anchor),r=e.resolve(this.head);return n.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&n.index()<n.parent.childCount&&r.index()<r.parent.childCount&&Qs(n,r)?new V(n,r):N.near(r,1)}};function Qy(t){if(!(t.selection instanceof V))return null;const e=[];return t.selection.forEachCell((n,r)=>{e.push(G.node(r,r+n.nodeSize,{class:"selectedCell"}))}),$.create(t.doc,e)}function eb({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let n=t.pos,r=e.pos,s=t.depth;for(;s>=0&&!(t.after(s+1)<t.end(s));s--,n++);for(let i=e.depth;i>=0&&!(e.before(i+1)>e.start(i));i--,r--);return n==r&&/row|table/.test(t.node(s).type.spec.tableRole)}function tb({$from:t,$to:e}){let n,r;for(let s=t.depth;s>0;s--){const i=t.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){n=i;break}}for(let s=e.depth;s>0;s--){const i=e.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){r=i;break}}return n!==r&&e.parentOffset===0}function nb(t,e,n){const r=(e||t).selection,s=(e||t).doc;let i,o;if(r instanceof A&&(o=r.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")i=V.create(s,r.from);else if(o=="row"){const l=s.resolve(r.from+1);i=V.rowSelection(l,l)}else if(!n){const l=q.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];i=V.create(s,a+1,c)}}else r instanceof E&&eb(r)?i=E.create(s,r.from):r instanceof E&&tb(r)&&(i=E.create(s,r.$from.start(),r.$from.end()));return i&&(e||(e=t.tr)).setSelection(i),e}const rb=new _("fix-tables");function Sc(t,e,n,r){const s=t.childCount,i=e.childCount;e:for(let o=0,l=0;o<i;o++){const a=e.child(o);for(let c=l,u=Math.min(s,o+3);c<u;c++)if(t.child(c)==a){l=c+1,n+=a.nodeSize;continue e}r(a,n),l<s&&t.child(l).sameMarkup(a)?Sc(t.child(l),a,n+1,r):a.nodesBetween(0,a.content.size,r,n+1),n+=a.nodeSize}}function Cc(t,e){let n;const r=(s,i)=>{s.type.spec.tableRole=="table"&&(n=sb(t,s,i,n))};return e?e.doc!=t.doc&&Sc(e.doc,t.doc,0,r):t.doc.descendants(r),n}function sb(t,e,n,r){const s=q.get(e);if(!s.problems)return r;r||(r=t.tr);const i=[];for(let a=0;a<s.height;a++)i.push(0);for(let a=0;a<s.problems.length;a++){const c=s.problems[a];if(c.type=="collision"){const u=e.nodeAt(c.pos);if(!u)continue;const d=u.attrs;for(let h=0;h<d.rowspan;h++)i[c.row+h]+=c.n;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,St(d,d.colspan-c.n,c.n))}else if(c.type=="missing")i[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const u=e.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...u.attrs,rowspan:u.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const u=e.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...u.attrs,colwidth:c.colwidth})}else if(c.type=="zero_sized"){const u=r.mapping.map(n);r.delete(u,u+e.nodeSize)}}let o,l;for(let a=0;a<i.length;a++)i[a]&&(o==null&&(o=a),l=a);for(let a=0,c=n+1;a<s.height;a++){const u=e.child(a),d=c+u.nodeSize,h=i[a];if(h>0){let f="cell";u.firstChild&&(f=u.firstChild.type.spec.tableRole);const p=[];for(let g=0;g<h;g++){const b=le(t.schema)[f].createAndFill();b&&p.push(b)}const m=(a==0||o==a-1)&&l==a?c+1:d-1;r.insert(r.mapping.map(m),p)}c=d}return r.setMeta(rb,{fixTables:!0})}function Ie(t){const e=t.selection,n=yr(t),r=n.node(-1),s=n.start(-1),i=q.get(r);return{...e instanceof V?i.rectBetween(e.$anchorCell.pos-s,e.$headCell.pos-s):i.findCell(n.pos-s),tableStart:s,map:i,table:r}}function vc(t,{map:e,tableStart:n,table:r},s){let i=s>0?-1:0;Yy(e,r,s+i)&&(i=s==0||s==e.width?null:0);for(let o=0;o<e.height;o++){const l=o*e.width+s;if(s>0&&s<e.width&&e.map[l-1]==e.map[l]){const a=e.map[l],c=r.nodeAt(a);t.setNodeMarkup(t.mapping.map(n+a),null,kc(c.attrs,s-e.colCount(a))),o+=c.attrs.rowspan-1}else{const a=i==null?le(r.type.schema).cell:r.nodeAt(e.map[l+i]).type,c=e.positionAt(o,s,r);t.insert(t.mapping.map(n+c),a.createAndFill())}}return t}function ib(t,e){if(!Me(t))return!1;if(e){const n=Ie(t);e(vc(t.tr,n,n.left))}return!0}function ob(t,e){if(!Me(t))return!1;if(e){const n=Ie(t);e(vc(t.tr,n,n.right))}return!0}function lb(t,{map:e,table:n,tableStart:r},s){const i=t.mapping.maps.length;for(let o=0;o<e.height;){const l=o*e.width+s,a=e.map[l],c=n.nodeAt(a),u=c.attrs;if(s>0&&e.map[l-1]==a||s<e.width-1&&e.map[l+1]==a)t.setNodeMarkup(t.mapping.slice(i).map(r+a),null,St(u,s-e.colCount(a)));else{const d=t.mapping.slice(i).map(r+a);t.delete(d,d+c.nodeSize)}o+=u.rowspan}}function ab(t,e){if(!Me(t))return!1;if(e){const n=Ie(t),r=t.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let s=n.right-1;lb(r,n,s),s!=n.left;s--){const i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=q.get(i)}e(r)}return!0}function cb(t,e,n){var r;const s=le(e.type.schema).header_cell;for(let i=0;i<t.width;i++)if(((r=e.nodeAt(t.map[i+n*t.width]))===null||r===void 0?void 0:r.type)!=s)return!1;return!0}function Mc(t,{map:e,tableStart:n,table:r},s){let i=n;for(let c=0;c<s;c++)i+=r.child(c).nodeSize;const o=[];let l=s>0?-1:0;cb(e,r,s+l)&&(l=s==0||s==e.height?null:0);for(let c=0,u=e.width*s;c<e.width;c++,u++)if(s>0&&s<e.height&&e.map[u]==e.map[u-e.width]){const d=e.map[u],h=r.nodeAt(d).attrs;t.setNodeMarkup(n+d,null,{...h,rowspan:h.rowspan+1}),c+=h.colspan-1}else{var a;const d=l==null?le(r.type.schema).cell:(a=r.nodeAt(e.map[u+l*e.width]))===null||a===void 0?void 0:a.type,h=d==null?void 0:d.createAndFill();h&&o.push(h)}return t.insert(i,le(r.type.schema).row.create(null,o)),t}function ub(t,e){if(!Me(t))return!1;if(e){const n=Ie(t);e(Mc(t.tr,n,n.top))}return!0}function db(t,e){if(!Me(t))return!1;if(e){const n=Ie(t);e(Mc(t.tr,n,n.bottom))}return!0}function hb(t,{map:e,table:n,tableStart:r},s){let i=0;for(let c=0;c<s;c++)i+=n.child(c).nodeSize;const o=i+n.child(s).nodeSize,l=t.mapping.maps.length;t.delete(i+r,o+r);const a=new Set;for(let c=0,u=s*e.width;c<e.width;c++,u++){const d=e.map[u];if(!a.has(d)){if(a.add(d),s>0&&d==e.map[u-e.width]){const h=n.nodeAt(d).attrs;t.setNodeMarkup(t.mapping.slice(l).map(d+r),null,{...h,rowspan:h.rowspan-1}),c+=h.colspan-1}else if(s<e.height&&d==e.map[u+e.width]){const h=n.nodeAt(d),f=h.attrs,p=h.type.create({...f,rowspan:h.attrs.rowspan-1},h.content),m=e.positionAt(s+1,c,n);t.insert(t.mapping.slice(l).map(r+m),p),c+=f.colspan-1}}}}function fb(t,e){if(!Me(t))return!1;if(e){const n=Ie(t),r=t.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let s=n.bottom-1;hb(r,n,s),s!=n.top;s--){const i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=q.get(n.table)}e(r)}return!0}function vo(t){const e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function pb({width:t,height:e,map:n},r){let s=r.top*t+r.left,i=s,o=(r.bottom-1)*t+r.left,l=s+(r.right-r.left-1);for(let a=r.top;a<r.bottom;a++){if(r.left>0&&n[i]==n[i-1]||r.right<t&&n[l]==n[l+1])return!0;i+=t,l+=t}for(let a=r.left;a<r.right;a++){if(r.top>0&&n[s]==n[s-t]||r.bottom<e&&n[o]==n[o+t])return!0;s++,o++}return!1}function Mo(t,e){const n=t.selection;if(!(n instanceof V)||n.$anchorCell.pos==n.$headCell.pos)return!1;const r=Ie(t),{map:s}=r;if(pb(s,r))return!1;if(e){const i=t.tr,o={};let l=x.empty,a,c;for(let u=r.top;u<r.bottom;u++)for(let d=r.left;d<r.right;d++){const h=s.map[u*s.width+d],f=r.table.nodeAt(h);if(!(o[h]||!f))if(o[h]=!0,a==null)a=h,c=f;else{vo(f)||(l=l.append(f.content));const p=i.mapping.map(h+r.tableStart);i.delete(p,p+f.nodeSize)}}if(a==null||c==null)return!0;if(i.setNodeMarkup(a+r.tableStart,null,{...kc(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),l.size>0){const u=a+1+c.content.size,d=vo(c)?a+1:u;i.replaceWith(d+r.tableStart,u+r.tableStart,l)}i.setSelection(new V(i.doc.resolve(a+r.tableStart))),e(i)}return!0}function To(t,e){const n=le(t.schema);return mb(({node:r})=>n[r.type.spec.tableRole])(t,e)}function mb(t){return(e,n)=>{const r=e.selection;let s,i;if(r instanceof V){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;s=r.$anchorCell.nodeAfter,i=r.$anchorCell.pos}else{var o;if(s=Jy(r.$from),!s)return!1;i=(o=Ht(r.$from))===null||o===void 0?void 0:o.pos}if(s==null||i==null||s.attrs.colspan==1&&s.attrs.rowspan==1)return!1;if(n){let l=s.attrs;const a=[],c=l.colwidth;l.rowspan>1&&(l={...l,rowspan:1}),l.colspan>1&&(l={...l,colspan:1});const u=Ie(e),d=e.tr;for(let f=0;f<u.right-u.left;f++)a.push(c?{...l,colwidth:c&&c[f]?[c[f]]:null}:l);let h;for(let f=u.top;f<u.bottom;f++){let p=u.map.positionAt(f,u.left,u.table);f==u.top&&(p+=s.nodeSize);for(let m=u.left,g=0;m<u.right;m++,g++)m==u.left&&f==u.top||d.insert(h=d.mapping.map(p+u.tableStart,1),t({node:s,row:f,col:m}).createAndFill(a[g]))}d.setNodeMarkup(i,t({node:s,row:u.top,col:u.left}),a[0]),r instanceof V&&d.setSelection(new V(d.doc.resolve(r.$anchorCell.pos),h?d.doc.resolve(h):void 0)),n(d)}return!0}}function gb(t,e){return function(n,r){if(!Me(n))return!1;const s=yr(n);if(s.nodeAfter.attrs[t]===e)return!1;if(r){const i=n.tr;n.selection instanceof V?n.selection.forEachCell((o,l)=>{o.attrs[t]!==e&&i.setNodeMarkup(l,null,{...o.attrs,[t]:e})}):i.setNodeMarkup(s.pos,null,{...s.nodeAfter.attrs,[t]:e}),r(i)}return!0}}function yb(t){return function(e,n){if(!Me(e))return!1;if(n){const r=le(e.schema),s=Ie(e),i=e.tr,o=s.map.cellsInRect(t=="column"?{left:s.left,top:0,right:s.right,bottom:s.map.height}:t=="row"?{left:0,top:s.top,right:s.map.width,bottom:s.bottom}:s),l=o.map(a=>s.table.nodeAt(a));for(let a=0;a<o.length;a++)l[a].type==r.header_cell&&i.setNodeMarkup(s.tableStart+o[a],r.cell,l[a].attrs);if(i.steps.length===0)for(let a=0;a<o.length;a++)i.setNodeMarkup(s.tableStart+o[a],r.header_cell,l[a].attrs);n(i)}return!0}}function Eo(t,e,n){const r=e.map.cellsInRect({left:0,top:0,right:t=="row"?e.map.width:1,bottom:t=="column"?e.map.height:1});for(let s=0;s<r.length;s++){const i=e.table.nodeAt(r[s]);if(i&&i.type!==n.header_cell)return!1}return!0}function an(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?yb(t):function(n,r){if(!Me(n))return!1;if(r){const s=le(n.schema),i=Ie(n),o=n.tr,l=Eo("row",i,s),a=Eo("column",i,s),c=(t==="column"?l:t==="row"&&a)?1:0,u=t=="column"?{left:0,top:c,right:1,bottom:i.map.height}:t=="row"?{left:c,top:0,right:i.map.width,bottom:1}:i,d=t=="column"?a?s.cell:s.header_cell:t=="row"?l?s.cell:s.header_cell:s.cell;i.map.cellsInRect(u).forEach(h=>{const f=h+i.tableStart,p=o.doc.nodeAt(f);p&&o.setNodeMarkup(f,d,p.attrs)}),r(o)}return!0}}an("row",{useDeprecatedLogic:!0});an("column",{useDeprecatedLogic:!0});const bb=an("cell",{useDeprecatedLogic:!0});function xb(t,e){if(e<0){const n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let r=t.index(-1)-1,s=t.before();r>=0;r--){const i=t.node(-1).child(r),o=i.lastChild;if(o)return s-1-o.nodeSize;s-=i.nodeSize}}else{if(t.index()<t.parent.childCount-1)return t.pos+t.nodeAfter.nodeSize;const n=t.node(-1);for(let r=t.indexAfter(-1),s=t.after();r<n.childCount;r++){const i=n.child(r);if(i.childCount)return s+1;s+=i.nodeSize}}return null}function Ao(t){return function(e,n){if(!Me(e))return!1;const r=xb(yr(e),t);if(r==null)return!1;if(n){const s=e.doc.resolve(r);n(e.tr.setSelection(E.between(s,Xy(s))).scrollIntoView())}return!0}}function kb(t,e){const n=t.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole=="table")return e&&e(t.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function Mn(t,e){const n=t.selection;if(!(n instanceof V))return!1;if(e){const r=t.tr,s=le(t.schema).cell.createAndFill().content;n.forEachCell((i,o)=>{i.content.eq(s)||r.replace(r.mapping.map(o+1),r.mapping.map(o+i.nodeSize-1),new S(s,0,0))}),r.docChanged&&e(r)}return!0}function wb(t){if(t.size===0)return null;let{content:e,openStart:n,openEnd:r}=t;for(;e.childCount==1&&(n>0&&r>0||e.child(0).type.spec.tableRole=="table");)n--,r--,e=e.child(0).content;const s=e.child(0),i=s.type.spec.tableRole,o=s.type.schema,l=[];if(i=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content;const u=a?0:Math.max(0,n-1),d=a<e.childCount-1?0:Math.max(0,r-1);(u||d)&&(c=hs(le(o).row,new S(c,u,d)).content),l.push(c)}else if(i=="cell"||i=="header_cell")l.push(n||r?hs(le(o).row,new S(e,n,r)).content:e);else return null;return Sb(o,l)}function Sb(t,e){const n=[];for(let s=0;s<e.length;s++){const i=e[s];for(let o=i.childCount-1;o>=0;o--){const{rowspan:l,colspan:a}=i.child(o).attrs;for(let c=s;c<s+l;c++)n[c]=(n[c]||0)+a}}let r=0;for(let s=0;s<n.length;s++)r=Math.max(r,n[s]);for(let s=0;s<n.length;s++)if(s>=e.length&&e.push(x.empty),n[s]<r){const i=le(t).cell.createAndFill(),o=[];for(let l=n[s];l<r;l++)o.push(i);e[s]=e[s].append(x.from(o))}return{height:e.length,width:r,rows:e}}function hs(t,e){const n=t.createAndFill();return new Ts(n).replace(0,n.content.size,e).doc}function Cb({width:t,height:e,rows:n},r,s){if(t!=r){const i=[],o=[];for(let l=0;l<n.length;l++){const a=n[l],c=[];for(let u=i[l]||0,d=0;u<r;d++){let h=a.child(d%a.childCount);u+h.attrs.colspan>r&&(h=h.type.createChecked(St(h.attrs,h.attrs.colspan,u+h.attrs.colspan-r),h.content)),c.push(h),u+=h.attrs.colspan;for(let f=1;f<h.attrs.rowspan;f++)i[l+f]=(i[l+f]||0)+h.attrs.colspan}o.push(x.from(c))}n=o,t=r}if(e!=s){const i=[];for(let o=0,l=0;o<s;o++,l++){const a=[],c=n[l%e];for(let u=0;u<c.childCount;u++){let d=c.child(u);o+d.attrs.rowspan>s&&(d=d.type.create({...d.attrs,rowspan:Math.max(1,s-d.attrs.rowspan)},d.content)),a.push(d)}i.push(x.from(a))}n=i,e=s}return{width:t,height:e,rows:n}}function vb(t,e,n,r,s,i,o){const l=t.doc.type.schema,a=le(l);let c,u;if(s>e.width)for(let d=0,h=0;d<e.height;d++){const f=n.child(d);h+=f.nodeSize;const p=[];let m;f.lastChild==null||f.lastChild.type==a.cell?m=c||(c=a.cell.createAndFill()):m=u||(u=a.header_cell.createAndFill());for(let g=e.width;g<s;g++)p.push(m);t.insert(t.mapping.slice(o).map(h-1+r),p)}if(i>e.height){const d=[];for(let p=0,m=(e.height-1)*e.width;p<Math.max(e.width,s);p++){const g=p>=e.width?!1:n.nodeAt(e.map[m+p]).type==a.header_cell;d.push(g?u||(u=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const h=a.row.create(null,x.from(d)),f=[];for(let p=e.height;p<i;p++)f.push(h);t.insert(t.mapping.slice(o).map(r+n.nodeSize-2),f)}return!!(c||u)}function No(t,e,n,r,s,i,o,l){if(o==0||o==e.height)return!1;let a=!1;for(let c=s;c<i;c++){const u=o*e.width+c,d=e.map[u];if(e.map[u-e.width]==d){a=!0;const h=n.nodeAt(d),{top:f,left:p}=e.findCell(d);t.setNodeMarkup(t.mapping.slice(l).map(d+r),null,{...h.attrs,rowspan:o-f}),t.insert(t.mapping.slice(l).map(e.positionAt(o,p,n)),h.type.createAndFill({...h.attrs,rowspan:f+h.attrs.rowspan-o})),c+=h.attrs.colspan-1}}return a}function Oo(t,e,n,r,s,i,o,l){if(o==0||o==e.width)return!1;let a=!1;for(let c=s;c<i;c++){const u=c*e.width+o,d=e.map[u];if(e.map[u-1]==d){a=!0;const h=n.nodeAt(d),f=e.colCount(d),p=t.mapping.slice(l).map(d+r);t.setNodeMarkup(p,null,St(h.attrs,o-f,h.attrs.colspan-(o-f))),t.insert(p+h.nodeSize,h.type.createAndFill(St(h.attrs,0,o-f))),c+=h.attrs.rowspan-1}}return a}function Io(t,e,n,r,s){let i=n?t.doc.nodeAt(n-1):t.doc;if(!i)throw new Error("No table found");let o=q.get(i);const{top:l,left:a}=r,c=a+s.width,u=l+s.height,d=t.tr;let h=0;function f(){if(i=n?d.doc.nodeAt(n-1):d.doc,!i)throw new Error("No table found");o=q.get(i),h=d.mapping.maps.length}vb(d,o,i,n,c,u,h)&&f(),No(d,o,i,n,a,c,l,h)&&f(),No(d,o,i,n,a,c,u,h)&&f(),Oo(d,o,i,n,l,u,a,h)&&f(),Oo(d,o,i,n,l,u,c,h)&&f();for(let p=l;p<u;p++){const m=o.positionAt(p,a,i),g=o.positionAt(p,c,i);d.replace(d.mapping.slice(h).map(m+n),d.mapping.slice(h).map(g+n),new S(s.rows[p-l],0,0))}f(),d.setSelection(new V(d.doc.resolve(n+o.positionAt(l,a,i)),d.doc.resolve(n+o.positionAt(u-1,c-1,i)))),e(d)}const Mb=Vs({ArrowLeft:Tn("horiz",-1),ArrowRight:Tn("horiz",1),ArrowUp:Tn("vert",-1),ArrowDown:Tn("vert",1),"Shift-ArrowLeft":En("horiz",-1),"Shift-ArrowRight":En("horiz",1),"Shift-ArrowUp":En("vert",-1),"Shift-ArrowDown":En("vert",1),Backspace:Mn,"Mod-Backspace":Mn,Delete:Mn,"Mod-Delete":Mn});function Rn(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function Tn(t,e){return(n,r,s)=>{if(!s)return!1;const i=n.selection;if(i instanceof V)return Rn(n,r,N.near(i.$headCell,e));if(t!="horiz"&&!i.empty)return!1;const o=Tc(s,t,e);if(o==null)return!1;if(t=="horiz")return Rn(n,r,N.near(n.doc.resolve(i.head+e),e));{const l=n.doc.resolve(o),a=xc(l,t,e);let c;return a?c=N.near(a,1):e<0?c=N.near(n.doc.resolve(l.before(-1)),-1):c=N.near(n.doc.resolve(l.after(-1)),1),Rn(n,r,c)}}}function En(t,e){return(n,r,s)=>{if(!s)return!1;const i=n.selection;let o;if(i instanceof V)o=i;else{const a=Tc(s,t,e);if(a==null)return!1;o=new V(n.doc.resolve(a))}const l=xc(o.$headCell,t,e);return l?Rn(n,r,new V(o.$anchorCell,l)):!1}}function Tb(t,e){const n=t.state.doc,r=Ht(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new V(r))),!0):!1}function Eb(t,e,n){if(!Me(t.state))return!1;let r=wb(n);const s=t.state.selection;if(s instanceof V){r||(r={width:1,height:1,rows:[x.from(hs(le(t.state.schema).cell,n))]});const i=s.$anchorCell.node(-1),o=s.$anchorCell.start(-1),l=q.get(i).rectBetween(s.$anchorCell.pos-o,s.$headCell.pos-o);return r=Cb(r,l.right-l.left,l.bottom-l.top),Io(t.state,t.dispatch,o,l,r),!0}else if(r){const i=yr(t.state),o=i.start(-1);return Io(t.state,t.dispatch,o,q.get(i.node(-1)).findCell(i.pos-o),r),!0}else return!1}function Ab(t,e){var n;if(e.ctrlKey||e.metaKey)return;const r=Do(t,e.target);let s;if(e.shiftKey&&t.state.selection instanceof V)i(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(s=Ht(t.state.selection.$anchor))!=null&&((n=jr(t,e))===null||n===void 0?void 0:n.pos)!=s.pos)i(s,e),e.preventDefault();else if(!r)return;function i(a,c){let u=jr(t,c);const d=Ke.getState(t.state)==null;if(!u||!Qs(a,u))if(d)u=a;else return;const h=new V(a,u);if(d||!t.state.selection.eq(h)){const f=t.state.tr.setSelection(h);d&&f.setMeta(Ke,a.pos),t.dispatch(f)}}function o(){t.root.removeEventListener("mouseup",o),t.root.removeEventListener("dragstart",o),t.root.removeEventListener("mousemove",l),Ke.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(Ke,-1))}function l(a){const c=a,u=Ke.getState(t.state);let d;if(u!=null)d=t.state.doc.resolve(u);else if(Do(t,c.target)!=r&&(d=jr(t,e),!d))return o();d&&i(d,c)}t.root.addEventListener("mouseup",o),t.root.addEventListener("dragstart",o),t.root.addEventListener("mousemove",l)}function Tc(t,e,n){if(!(t.state.selection instanceof E))return null;const{$head:r}=t.state.selection;for(let s=r.depth-1;s>=0;s--){const i=r.node(s);if((n<0?r.index(s):r.indexAfter(s))!=(n<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){const o=r.before(s),l=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(l)?o:null}}return null}function Do(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function jr(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});if(!n)return null;const r=n.inside>=0?n.inside:n.pos;return Ht(t.state.doc.resolve(r))}var Nb=class{constructor(e,n){this.node=e,this.defaultCellMinWidth=n,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",`${n}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),fs(e,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,fs(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function fs(t,e,n,r,s,i){let o=0,l=!0,a=e.firstChild;const c=t.firstChild;if(c){for(let d=0,h=0;d<c.childCount;d++){const{colspan:f,colwidth:p}=c.child(d).attrs;for(let m=0;m<f;m++,h++){const g=s==h?i:p&&p[m],b=g?g+"px":"";if(o+=g||r,g||(l=!1),a)a.style.width!=b&&(a.style.width=b),a=a.nextSibling;else{const k=document.createElement("col");k.style.width=b,e.appendChild(k)}}}for(;a;){var u;const d=a.nextSibling;(u=a.parentNode)===null||u===void 0||u.removeChild(a),a=d}l?(n.style.width=o+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=o+"px")}}const pe=new _("tableColumnResizing");function Ob({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:r=Nb,lastColumnResizable:s=!0}={}){const i=new H({key:pe,state:{init(o,l){var a;const c=(a=i.spec)===null||a===void 0||(a=a.props)===null||a===void 0?void 0:a.nodeViews,u=le(l.schema).table.name;return r&&c&&(c[u]=(d,h)=>new r(d,n,h)),new Ib(-1,!1)},apply(o,l){return l.apply(o)}},props:{attributes:o=>{const l=pe.getState(o);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(o,l)=>{Db(o,l,t,s)},mouseleave:o=>{Rb(o)},mousedown:(o,l)=>{Lb(o,l,e,n)}},decorations:o=>{const l=pe.getState(o);if(l&&l.activeHandle>-1)return $b(o,l.activeHandle)},nodeViews:{}}});return i}var Ib=class Ln{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,r=e.getMeta(pe);if(r&&r.setHandle!=null)return new Ln(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new Ln(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let s=e.mapping.map(n.activeHandle,-1);return ds(e.doc.resolve(s))||(s=-1),new Ln(s,n.dragging)}return n}};function Db(t,e,n,r){if(!t.editable)return;const s=pe.getState(t.state);if(s&&!s.dragging){const i=zb(e.target);let o=-1;if(i){const{left:l,right:a}=i.getBoundingClientRect();e.clientX-l<=n?o=Ro(t,e,"left",n):a-e.clientX<=n&&(o=Ro(t,e,"right",n))}if(o!=s.activeHandle){if(!r&&o!==-1){const l=t.state.doc.resolve(o),a=l.node(-1),c=q.get(a),u=l.start(-1);if(c.colCount(l.pos-u)+l.nodeAfter.attrs.colspan-1==c.width-1)return}Ec(t,o)}}}function Rb(t){if(!t.editable)return;const e=pe.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&Ec(t,-1)}function Lb(t,e,n,r){var s;if(!t.editable)return!1;const i=(s=t.dom.ownerDocument.defaultView)!==null&&s!==void 0?s:window,o=pe.getState(t.state);if(!o||o.activeHandle==-1||o.dragging)return!1;const l=t.state.doc.nodeAt(o.activeHandle),a=Pb(t,o.activeHandle,l.attrs);t.dispatch(t.state.tr.setMeta(pe,{setDragging:{startX:e.clientX,startWidth:a}}));function c(d){i.removeEventListener("mouseup",c),i.removeEventListener("mousemove",u);const h=pe.getState(t.state);h!=null&&h.dragging&&(Bb(t,h.activeHandle,Lo(h.dragging,d,n)),t.dispatch(t.state.tr.setMeta(pe,{setDragging:null})))}function u(d){if(!d.which)return c(d);const h=pe.getState(t.state);if(h&&h.dragging){const f=Lo(h.dragging,d,n);Po(t,h.activeHandle,f,r)}}return Po(t,o.activeHandle,a,r),i.addEventListener("mouseup",c),i.addEventListener("mousemove",u),e.preventDefault(),!0}function Pb(t,e,{colspan:n,colwidth:r}){const s=r&&r[r.length-1];if(s)return s;const i=t.domAtPos(e);let o=i.node.childNodes[i.offset].offsetWidth,l=n;if(r)for(let a=0;a<n;a++)r[a]&&(o-=r[a],l--);return o/l}function zb(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function Ro(t,e,n,r){const s=n=="right"?-r:r,i=t.posAtCoords({left:e.clientX+s,top:e.clientY});if(!i)return-1;const{pos:o}=i,l=Ht(t.state.doc.resolve(o));if(!l)return-1;if(n=="right")return l.pos;const a=q.get(l.node(-1)),c=l.start(-1),u=a.map.indexOf(l.pos-c);return u%a.width==0?-1:c+a.map[u-1]}function Lo(t,e,n){const r=e.clientX-t.startX;return Math.max(n,t.startWidth+r)}function Ec(t,e){t.dispatch(t.state.tr.setMeta(pe,{setHandle:e}))}function Bb(t,e,n){const r=t.state.doc.resolve(e),s=r.node(-1),i=q.get(s),o=r.start(-1),l=i.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1,a=t.state.tr;for(let c=0;c<i.height;c++){const u=c*i.width+l;if(c&&i.map[u]==i.map[u-i.width])continue;const d=i.map[u],h=s.nodeAt(d).attrs,f=h.colspan==1?0:l-i.colCount(d);if(h.colwidth&&h.colwidth[f]==n)continue;const p=h.colwidth?h.colwidth.slice():jb(h.colspan);p[f]=n,a.setNodeMarkup(o+d,null,{...h,colwidth:p})}a.docChanged&&t.dispatch(a)}function Po(t,e,n,r){const s=t.state.doc.resolve(e),i=s.node(-1),o=s.start(-1),l=q.get(i).colCount(s.pos-o)+s.nodeAfter.attrs.colspan-1;let a=t.domAtPos(s.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&fs(i,a.firstChild,a,r,l,n)}function jb(t){return Array(t).fill(0)}function $b(t,e){const n=[],r=t.doc.resolve(e),s=r.node(-1);if(!s)return $.empty;const i=q.get(s),o=r.start(-1),l=i.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1;for(let c=0;c<i.height;c++){const u=l+c*i.width;if((l==i.width-1||i.map[u]!=i.map[u+1])&&(c==0||i.map[u]!=i.map[u-i.width])){var a;const d=i.map[u],h=o+d+s.nodeAt(d).nodeSize-1,f=document.createElement("div");f.className="column-resize-handle",!((a=pe.getState(t))===null||a===void 0)&&a.dragging&&n.push(G.node(o+d,o+d+s.nodeAt(d).nodeSize,{class:"column-resize-dragging"})),n.push(G.widget(h,f))}}return $.create(t.doc,n)}function Fb({allowTableNodeSelection:t=!1}={}){return new H({key:Ke,state:{init(){return null},apply(e,n){const r=e.getMeta(Ke);if(r!=null)return r==-1?null:r;if(n==null||!e.docChanged)return n;const{deleted:s,pos:i}=e.mapping.mapResult(n);return s?null:i}},props:{decorations:Qy,handleDOMEvents:{mousedown:Ab},createSelectionBetween(e){return Ke.getState(e.state)!=null?e.state.selection:null},handleTripleClick:Tb,handleKeyDown:Mb,handlePaste:Eb},appendTransaction(e,n,r){return nb(r,Cc(r,n),t)}})}var Hb=J.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{var e,n;const r=t.getAttribute("colwidth"),s=r?r.split(",").map(i=>parseInt(i,10)):null;if(!s){const i=(e=t.closest("table"))==null?void 0:e.querySelectorAll("colgroup > col"),o=Array.from(((n=t.parentElement)==null?void 0:n.children)||[]).indexOf(t);if(o&&o>-1&&i&&i[o]){const l=i[o].getAttribute("width");return l?[parseInt(l,10)]:null}}return s}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",z(this.options.HTMLAttributes,t),0]}}),Vb=J.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",z(this.options.HTMLAttributes,t),0]}}),_b=J.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",z(this.options.HTMLAttributes,t),0]}});function ps(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function zo(t,e,n,r,s,i){var o;let l=0,a=!0,c=e.firstChild;const u=t.firstChild;if(u!==null)for(let h=0,f=0;h<u.childCount;h+=1){const{colspan:p,colwidth:m}=u.child(h).attrs;for(let g=0;g<p;g+=1,f+=1){const b=s===f?i:m&&m[g],k=b?`${b}px`:"";if(l+=b||r,b||(a=!1),c){if(c.style.width!==k){const[w,C]=ps(r,b);c.style.setProperty(w,C)}c=c.nextSibling}else{const w=document.createElement("col"),[C,v]=ps(r,b);w.style.setProperty(C,v),e.appendChild(w)}}}for(;c;){const h=c.nextSibling;(o=c.parentNode)==null||o.removeChild(c),c=h}const d=t.attrs.style&&typeof t.attrs.style=="string"&&/\bwidth\s*:/i.test(t.attrs.style);a&&!d?(n.style.width=`${l}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${l}px`)}var Wb=class{constructor(t,e){this.node=t,this.cellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),t.attrs.style&&(this.table.style.cssText=t.attrs.style),this.colgroup=this.table.appendChild(document.createElement("colgroup")),zo(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!==this.node.type?!1:(this.node=t,zo(t,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(t){const e=t.target,n=this.dom.contains(e),r=this.contentDOM.contains(e);return!!(n&&!r&&(t.type==="attributes"||t.type==="childList"||t.type==="characterData"))}};function qb(t,e,n,r){let s=0,i=!0;const o=[],l=t.firstChild;if(!l)return{};for(let d=0,h=0;d<l.childCount;d+=1){const{colspan:f,colwidth:p}=l.child(d).attrs;for(let m=0;m<f;m+=1,h+=1){const g=n===h?r:p&&p[m];s+=g||e,g||(i=!1);const[b,k]=ps(e,g);o.push(["col",{style:`${b}: ${k}`}])}}const a=i?`${s}px`:"",c=i?"":`${s}px`;return{colgroup:["colgroup",{},...o],tableWidth:a,tableMinWidth:c}}function Bo(t,e){return t.createAndFill()}function Kb(t){if(t.cached.tableNodeTypes)return t.cached.tableNodeTypes;const e={};return Object.keys(t.nodes).forEach(n=>{const r=t.nodes[n];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),t.cached.tableNodeTypes=e,e}function Ub(t,e,n,r,s){const i=Kb(t),o=[],l=[];for(let c=0;c<n;c+=1){const u=Bo(i.cell);if(u&&l.push(u),r){const d=Bo(i.header_cell);d&&o.push(d)}}const a=[];for(let c=0;c<e;c+=1)a.push(i.row.createChecked(null,r&&c===0?o:l));return i.table.createChecked(null,a)}function Jb(t){return t instanceof V}var An=({editor:t})=>{const{selection:e}=t.state;if(!Jb(e))return!1;let n=0;const r=ja(e.ranges[0].$from,i=>i.type.name==="table");return r==null||r.node.descendants(i=>{if(i.type.name==="table")return!1;["tableCell","tableHeader"].includes(i.type.name)&&(n+=1)}),n===e.ranges.length?(t.commands.deleteTable(),!0):!1},Gb="";function Xb(t){return(t||"").replace(/\s+/g," ").trim()}function Yb(t,e,n={}){var r;const s=(r=n.cellLineSeparator)!=null?r:Gb;if(!t||!t.content||t.content.length===0)return"";const i=[];t.content.forEach(p=>{const m=[];p.content&&p.content.forEach(g=>{let b="";g.content&&Array.isArray(g.content)&&g.content.length>1?b=g.content.map(v=>e.renderChildren(v)).join(s):b=g.content?e.renderChildren(g.content):"";const k=Xb(b),w=g.type==="tableHeader";m.push({text:k,isHeader:w})}),i.push(m)});const o=i.reduce((p,m)=>Math.max(p,m.length),0);if(o===0)return"";const l=new Array(o).fill(0);i.forEach(p=>{var m;for(let g=0;g<o;g+=1){const k=(((m=p[g])==null?void 0:m.text)||"").length;k>l[g]&&(l[g]=k),l[g]<3&&(l[g]=3)}});const a=(p,m)=>p+" ".repeat(Math.max(0,m-p.length)),c=i[0],u=c.some(p=>p.isHeader);let d=`
`;const h=new Array(o).fill(0).map((p,m)=>u&&c[m]&&c[m].text||"");return d+=`| ${h.map((p,m)=>a(p,l[m])).join(" | ")} |
`,d+=`| ${l.map(p=>"-".repeat(Math.max(3,p))).join(" | ")} |
`,(u?i.slice(1):i).forEach(p=>{d+=`| ${new Array(o).fill(0).map((m,g)=>a(p[g]&&p[g].text||"",l[g])).join(" | ")} |
`}),d}var Zb=Yb,Qb=J.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:Wb,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:t,HTMLAttributes:e}){const{colgroup:n,tableWidth:r,tableMinWidth:s}=qb(t,this.options.cellMinWidth),i=e.style;function o(){return i||(r?`width: ${r}`:`min-width: ${s}`)}const l=["table",z(this.options.HTMLAttributes,e,{style:o()}),n,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},l]:l},parseMarkdown:(t,e)=>{const n=[];if(t.header){const r=[];t.header.forEach(s=>{r.push(e.createNode("tableHeader",{},[{type:"paragraph",content:e.parseInline(s.tokens)}]))}),n.push(e.createNode("tableRow",{},r))}return t.rows&&t.rows.forEach(r=>{const s=[];r.forEach(i=>{s.push(e.createNode("tableCell",{},[{type:"paragraph",content:e.parseInline(i.tokens)}]))}),n.push(e.createNode("tableRow",{},s))}),e.createNode("table",void 0,n)},renderMarkdown:(t,e)=>Zb(t,e),addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:s,editor:i})=>{const o=Ub(i.schema,t,e,n);if(s){const l=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(E.near(r.doc.resolve(l)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>ib(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>ob(t,e),deleteColumn:()=>({state:t,dispatch:e})=>ab(t,e),addRowBefore:()=>({state:t,dispatch:e})=>ub(t,e),addRowAfter:()=>({state:t,dispatch:e})=>db(t,e),deleteRow:()=>({state:t,dispatch:e})=>fb(t,e),deleteTable:()=>({state:t,dispatch:e})=>kb(t,e),mergeCells:()=>({state:t,dispatch:e})=>Mo(t,e),splitCell:()=>({state:t,dispatch:e})=>To(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>an("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>an("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>bb(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>Mo(t,e)?!0:To(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>gb(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>Ao(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>Ao(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&Cc(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const r=V.create(e.doc,t.anchorCell,t.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:An,"Mod-Backspace":An,Delete:An,"Mod-Delete":An}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[Ob({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],Fb({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:P(T(t,"tableRole",e))}}}),ex=L.create({name:"tableKit",addExtensions(){const t=[];return this.options.table!==!1&&t.push(Qb.configure(this.options.table)),this.options.tableCell!==!1&&t.push(Hb.configure(this.options.tableCell)),this.options.tableHeader!==!1&&t.push(Vb.configure(this.options.tableHeader)),this.options.tableRow!==!1&&t.push(_b.configure(this.options.tableRow)),t}}),tx=L.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{const e=t.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:t=>t.textAlign?{style:`text-align: ${t.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>this.options.alignments.includes(t)?this.options.types.map(n=>e.updateAttributes(n,{textAlign:t})).some(n=>n):!1,unsetTextAlign:()=>({commands:t})=>this.options.types.map(e=>t.resetAttributes(e,"textAlign")).some(e=>e),toggleTextAlign:t=>({editor:e,commands:n})=>this.options.alignments.includes(t)?e.isActive({textAlign:t})?n.unsetTextAlign():n.setTextAlign(t):!1}},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")}}}),nx=tx;function rx(t={}){return new H({view(e){return new sx(e,t)}})}class sx{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(s=>{let i=o=>{this[s](o)};return e.dom.addEventListener(s,i),{name:s,handler:i}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,s=this.editorView.dom,i=s.getBoundingClientRect(),o=i.width/s.offsetWidth,l=i.height/s.offsetHeight;if(n){let d=e.nodeBefore,h=e.nodeAfter;if(d||h){let f=this.editorView.nodeDOM(this.cursorPos-(d?d.nodeSize:0));if(f){let p=f.getBoundingClientRect(),m=d?p.bottom:p.top;d&&h&&(m=(m+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let g=this.width/2*l;r={left:p.left,right:p.right,top:m-g,bottom:m+g}}}}if(!r){let d=this.editorView.coordsAtPos(this.cursorPos),h=this.width/2*o;r={left:d.left-h,right:d.left+h,top:d.top,bottom:d.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let c,u;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,u=-pageYOffset;else{let d=a.getBoundingClientRect(),h=d.width/a.offsetWidth,f=d.height/a.offsetHeight;c=d.left-a.scrollLeft*h,u=d.top-a.scrollTop*f}this.element.style.left=(r.left-c)/o+"px",this.element.style.top=(r.top-u)/l+"px",this.element.style.width=(r.right-r.left)/o+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),s=r&&r.type.spec.disableDropCursor,i=typeof s=="function"?s(this.editorView,n,e):s;if(n&&!i){let o=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=Nl(this.editorView.state.doc,o,this.editorView.dragging.slice);l!=null&&(o=l)}this.setCursor(o),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class W extends N{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return W.valid(r)?new W(r):N.near(r)}content(){return S.empty}eq(e){return e instanceof W&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new W(e.resolve(n.pos))}getBookmark(){return new ei(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!ix(e)||!ox(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let s=n.contentMatchAt(e.index()).defaultType;return s&&s.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&W.valid(e))return e;let s=e.pos,i=null;for(let o=e.depth;;o--){let l=e.node(o);if(n>0?e.indexAfter(o)<l.childCount:e.index(o)>0){i=l.child(n>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;s+=n;let a=e.doc.resolve(s);if(W.valid(a))return a}for(;;){let o=n>0?i.firstChild:i.lastChild;if(!o){if(i.isAtom&&!i.isText&&!A.isSelectable(i)){e=e.doc.resolve(s+i.nodeSize*n),r=!1;continue e}break}i=o,s+=n;let l=e.doc.resolve(s);if(W.valid(l))return l}return null}}}W.prototype.visible=!1;W.findFrom=W.findGapCursorFrom;N.jsonID("gapcursor",W);class ei{constructor(e){this.pos=e}map(e){return new ei(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return W.valid(n)?new W(n):N.near(n)}}function Ac(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function ix(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n-1);;s=s.lastChild){if(s.childCount==0&&!s.inlineContent||Ac(s.type))return!0;if(s.inlineContent)return!1}}return!0}function ox(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n);;s=s.firstChild){if(s.childCount==0&&!s.inlineContent||Ac(s.type))return!0;if(s.inlineContent)return!1}}return!0}function lx(){return new H({props:{decorations:dx,createSelectionBetween(t,e,n){return e.pos==n.pos&&W.valid(n)?new W(n):null},handleClick:cx,handleKeyDown:ax,handleDOMEvents:{beforeinput:ux}}})}const ax=Vs({ArrowLeft:Nn("horiz",-1),ArrowRight:Nn("horiz",1),ArrowUp:Nn("vert",-1),ArrowDown:Nn("vert",1)});function Nn(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,s,i){let o=r.selection,l=e>0?o.$to:o.$from,a=o.empty;if(o instanceof E){if(!i.endOfTextblock(n)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=W.findGapCursorFrom(l,e,a);return c?(s&&s(r.tr.setSelection(new W(c))),!0):!1}}function cx(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!W.valid(r))return!1;let s=t.posAtCoords({left:n.clientX,top:n.clientY});return s&&s.inside>-1&&A.isSelectable(t.state.doc.nodeAt(s.inside))?!1:(t.dispatch(t.state.tr.setSelection(new W(r))),!0)}function ux(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof W))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let s=x.empty;for(let o=r.length-1;o>=0;o--)s=x.from(r[o].createAndFill(null,s));let i=t.state.tr.replace(n.pos,n.pos,new S(s,0,0));return i.setSelection(E.near(i.doc.resolve(n.pos+1))),t.dispatch(i),!1}function dx(t){if(!(t.selection instanceof W))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",$.create(t.doc,[G.widget(t.selection.head,e,{key:"gapcursor"})])}var Zn=200,ee=function(){};ee.prototype.append=function(e){return e.length?(e=ee.from(e),!this.length&&e||e.length<Zn&&this.leafAppend(e)||this.length<Zn&&e.leafPrepend(this)||this.appendInner(e)):this};ee.prototype.prepend=function(e){return e.length?ee.from(e).append(this):this};ee.prototype.appendInner=function(e){return new hx(this,e)};ee.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?ee.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};ee.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};ee.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)};ee.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var s=[];return this.forEach(function(i,o){return s.push(e(i,o))},n,r),s};ee.from=function(e){return e instanceof ee?e:e&&e.length?new Nc(e):ee.empty};var Nc=(function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(s,i){return s==0&&i==this.length?this:new e(this.values.slice(s,i))},e.prototype.getInner=function(s){return this.values[s]},e.prototype.forEachInner=function(s,i,o,l){for(var a=i;a<o;a++)if(s(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(s,i,o,l){for(var a=i-1;a>=o;a--)if(s(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=Zn)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=Zn)return new e(s.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(ee);ee.empty=new Nc([]);var hx=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,s,i,o){var l=this.left.length;if(s<l&&this.left.forEachInner(r,s,Math.min(i,l),o)===!1||i>l&&this.right.forEachInner(r,Math.max(s-l,0),Math.min(this.length,i)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,i,o){var l=this.left.length;if(s>l&&this.right.forEachInvertedInner(r,s-l,Math.max(i,l)-l,o+l)===!1||i<l&&this.left.forEachInvertedInner(r,Math.min(s,l),i,o)===!1)return!1},e.prototype.sliceInner=function(r,s){if(r==0&&s==this.length)return this;var i=this.left.length;return s<=i?this.left.slice(r,s):r>=i?this.right.slice(r-i,s-i):this.left.slice(r,i).append(this.right.slice(0,s-i))},e.prototype.leafAppend=function(r){var s=this.right.leafAppend(r);if(s)return new e(this.left,s)},e.prototype.leafPrepend=function(r){var s=this.left.leafPrepend(r);if(s)return new e(s,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(ee);const fx=500;class Se{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let s,i;n&&(s=this.remapping(r,this.items.length),i=s.maps.length);let o=e.tr,l,a,c=[],u=[];return this.items.forEach((d,h)=>{if(!d.step){s||(s=this.remapping(r,h+1),i=s.maps.length),i--,u.push(d);return}if(s){u.push(new Ee(d.map));let f=d.step.map(s.slice(i)),p;f&&o.maybeStep(f).doc&&(p=o.mapping.maps[o.mapping.maps.length-1],c.push(new Ee(p,void 0,void 0,c.length+u.length))),i--,p&&s.appendMap(p,i)}else o.maybeStep(d.step);if(d.selection)return l=s?d.selection.map(s.slice(i)):d.selection,a=new Se(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:o,selection:l}}addTransform(e,n,r,s){let i=[],o=this.eventCount,l=this.items,a=!s&&l.length?l.get(l.length-1):null;for(let u=0;u<e.steps.length;u++){let d=e.steps[u].invert(e.docs[u]),h=new Ee(e.mapping.maps[u],d,n),f;(f=a&&a.merge(h))&&(h=f,u?i.pop():l=l.slice(0,l.length-1)),i.push(h),n&&(o++,n=void 0),s||(a=h)}let c=o-r.depth;return c>mx&&(l=px(l,c),o-=c),new Se(l.append(i),o)}remapping(e,n){let r=new tn;return this.items.forEach((s,i)=>{let o=s.mirrorOffset!=null&&i-s.mirrorOffset>=e?r.maps.length-s.mirrorOffset:void 0;r.appendMap(s.map,o)},e,n),r}addMaps(e){return this.eventCount==0?this:new Se(this.items.append(e.map(n=>new Ee(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-n),i=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(h=>{h.selection&&l--},s);let a=n;this.items.forEach(h=>{let f=i.getMirror(--a);if(f==null)return;o=Math.min(o,f);let p=i.maps[f];if(h.step){let m=e.steps[f].invert(e.docs[f]),g=h.selection&&h.selection.map(i.slice(a+1,f));g&&l++,r.push(new Ee(p,m,g))}else r.push(new Ee(p))},s);let c=[];for(let h=n;h<o;h++)c.push(new Ee(i.maps[h]));let u=this.items.slice(0,s).append(c).append(r),d=new Se(u,l);return d.emptyItemCount()>fx&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,s=[],i=0;return this.items.forEach((o,l)=>{if(l>=e)s.push(o),o.selection&&i++;else if(o.step){let a=o.step.map(n.slice(r)),c=a&&a.getMap();if(r--,c&&n.appendMap(c,r),a){let u=o.selection&&o.selection.map(n.slice(r));u&&i++;let d=new Ee(c.invert(),a,u),h,f=s.length-1;(h=s.length&&s[f].merge(d))?s[f]=h:s.push(d)}}else o.map&&r--},this.items.length,0),new Se(ee.from(s.reverse()),i)}}Se.empty=new Se(ee.empty,0);function px(t,e){let n;return t.forEach((r,s)=>{if(r.selection&&e--==0)return n=s,!1}),t.slice(n)}class Ee{constructor(e,n,r,s){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=s}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new Ee(n.getMap().invert(),n,this.selection)}}}class We{constructor(e,n,r,s,i){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=s,this.prevComposition=i}}const mx=20;function gx(t,e,n,r){let s=n.getMeta(gt),i;if(s)return s.historyState;n.getMeta(xx)&&(t=new We(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(gt))return o.getMeta(gt).redo?new We(t.done.addTransform(n,void 0,r,Pn(e)),t.undone,jo(n.mapping.maps),t.prevTime,t.prevComposition):new We(t.done,t.undone.addTransform(n,void 0,r,Pn(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let l=n.getMeta("composition"),a=t.prevTime==0||!o&&t.prevComposition!=l&&(t.prevTime<(n.time||0)-r.newGroupDelay||!yx(n,t.prevRanges)),c=o?$r(t.prevRanges,n.mapping):jo(n.mapping.maps);return new We(t.done.addTransform(n,a?e.selection.getBookmark():void 0,r,Pn(e)),Se.empty,c,n.time,l??t.prevComposition)}else return(i=n.getMeta("rebased"))?new We(t.done.rebased(n,i),t.undone.rebased(n,i),$r(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new We(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),$r(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function yx(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,s)=>{for(let i=0;i<e.length;i+=2)r<=e[i+1]&&s>=e[i]&&(n=!0)}),n}function jo(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,s,i,o)=>e.push(i,o));return e}function $r(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let s=e.map(t[r],1),i=e.map(t[r+1],-1);s<=i&&n.push(s,i)}return n}function bx(t,e,n){let r=Pn(e),s=gt.get(e).spec.config,i=(n?t.undone:t.done).popEvent(e,r);if(!i)return null;let o=i.selection.resolve(i.transform.doc),l=(n?t.done:t.undone).addTransform(i.transform,e.selection.getBookmark(),s,r),a=new We(n?l:i.remaining,n?i.remaining:l,null,0,-1);return i.transform.setSelection(o).setMeta(gt,{redo:n,historyState:a})}let Fr=!1,$o=null;function Pn(t){let e=t.plugins;if($o!=e){Fr=!1,$o=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){Fr=!0;break}}return Fr}const gt=new _("history"),xx=new _("closeHistory");function kx(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new H({key:gt,state:{init(){return new We(Se.empty,Se.empty,null,0,-1)},apply(e,n,r){return gx(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,s=r=="historyUndo"?Ic:r=="historyRedo"?Dc:null;return!s||!e.editable?!1:(n.preventDefault(),s(e.state,e.dispatch))}}}})}function Oc(t,e){return(n,r)=>{let s=gt.getState(n);if(!s||(t?s.undone:s.done).eventCount==0)return!1;if(r){let i=bx(s,n,t);i&&r(e?i.scrollIntoView():i)}return!0}}const Ic=Oc(!1,!0),Dc=Oc(!0,!0);L.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{const e=(t==null?void 0:t.node)||this.editor.state.doc;if(((t==null?void 0:t.mode)||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=t=>{const e=(t==null?void 0:t.node)||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new H({key:new _("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const s=this.options.limit;if(s==null||s===0){t=!0;return}const i=this.storage.characters({node:r.doc});if(i>s){const o=i-s,l=0,a=o;console.warn(`[CharacterCount] Initial content exceeded limit of ${s} characters. Content was automatically trimmed.`);const c=r.tr.deleteRange(l,a);return t=!0,c}t=!0},filterTransaction:(e,n)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const s=this.storage.characters({node:n.doc}),i=this.storage.characters({node:e.doc});if(i<=r||s>r&&i>r&&i<=s)return!0;if(s>r&&i>r&&i>s||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,a=i-r,c=l-a,u=l;return e.deleteRange(c,u),!(this.storage.characters({node:e.doc})>r)}})]}});var wx=L.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[rx(this.options)]}});L.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new H({key:new _("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:s}=e,i=[];if(!n||!r)return $.create(t,[]);let o=0;this.options.mode==="deepest"&&t.descendants((a,c)=>{if(a.isText)return;if(!(s>=c&&s<=c+a.nodeSize-1))return!1;o+=1});let l=0;return t.descendants((a,c)=>{if(a.isText||!(s>=c&&s<=c+a.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&o-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";i.push(G.node(c,c+a.nodeSize,{class:this.options.className}))}),$.create(t,i)}}})]}});var Sx=L.create({name:"gapCursor",addProseMirrorPlugins(){return[lx()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=P(T(t,"allowGapCursor",n)))!=null?e:null}}}),Cx=L.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new H({key:new _("placeholder"),props:{decorations:({doc:t,selection:e})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,s=[];if(!n)return null;const i=this.editor.isEmpty;return t.descendants((o,l)=>{const a=r>=l&&r<=l+o.nodeSize,c=!o.isLeaf&&pr(o);if((a||!this.options.showOnlyCurrent)&&c){const u=[this.options.emptyNodeClass];i&&u.push(this.options.emptyEditorClass);const d=G.node(l,l+o.nodeSize,{class:u.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:o,pos:l,hasAnchor:a}):this.options.placeholder});s.push(d)}return this.options.includeChildren}),$.create(t,s)}}})]}});L.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new H({key:new _("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||Ka(n.selection)||t.view.dragging?null:$.create(n.doc,[G.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function Fo({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||(e==null?void 0:e.type)===t}var vx=L.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new _(this.name),n=this.options.node||((t=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:t.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,s])=>s).filter(s=>(this.options.notAfter||[]).concat(n).includes(s.name));return[new H({key:e,appendTransaction:(s,i,o)=>{const{doc:l,tr:a,schema:c}=o,u=e.getState(o),d=l.content.size,h=c.nodes[n];if(u)return a.insert(d,h.create())},state:{init:(s,i)=>{const o=i.tr.doc.lastChild;return!Fo({node:o,types:r})},apply:(s,i)=>{if(!s.docChanged||s.getMeta("__uniqueIDTransaction"))return i;const o=s.doc.lastChild;return!Fo({node:o,types:r})}}})]}}),Mx=L.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>Ic(t,e),redo:()=>({state:t,dispatch:e})=>Dc(t,e)}},addProseMirrorPlugins(){return[kx(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()}}}),Qn=(t,e)=>{if(t==="slot")return 0;if(t instanceof Function)return t(e);const{children:n,...r}=e??{};if(t==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[t,r,n]},Tx=/^\s*>\s$/,Ex=J.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return Qn("blockquote",{...z(this.options.HTMLAttributes,t),children:Qn("slot",{})})},parseMarkdown:(t,e)=>e.createNode("blockquote",void 0,e.parseChildren(t.tokens||[])),renderMarkdown:(t,e)=>{if(!t.content)return"";const n=">",r=[];return t.content.forEach(s=>{const l=e.renderChildren([s]).split(`
`).map(a=>a.trim()===""?n:`${n} ${a}`);r.push(l.join(`
`))}),r.join(`
${n}
`)},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[$t({find:Tx,type:this.type})]}}),Ax=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Nx=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Ox=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Ix=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Dx=Oe.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return Qn("strong",{...z(this.options.HTMLAttributes,t),children:Qn("slot",{})})},markdownTokenName:"strong",parseMarkdown:(t,e)=>e.applyMark("bold",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`**${e.renderChildren(t)}**`,addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[jt({find:Ax,type:this.type}),jt({find:Ox,type:this.type})]},addPasteRules(){return[wt({find:Nx,type:this.type}),wt({find:Ix,type:this.type})]}}),Rx=/(^|[^`])`([^`]+)`(?!`)$/,Lx=/(^|[^`])`([^`]+)`(?!`)/g,Px=Oe.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",z(this.options.HTMLAttributes,t),0]},markdownTokenName:"codespan",parseMarkdown:(t,e)=>e.applyMark("code",[{type:"text",text:t.text||""}]),renderMarkdown:(t,e)=>t.content?`\`${e.renderChildren(t.content)}\``:"",addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[jt({find:Rx,type:this.type})]},addPasteRules(){return[wt({find:Lx,type:this.type})]}}),zx=J.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`

`):""}),Bx=J.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",z(this.options.HTMLAttributes,t)]},renderText(){return`
`},renderMarkdown:()=>`  
`,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:s,storedMarks:i}=n;if(s.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:l}=r.extensionManager,a=i||s.$to.parentOffset&&s.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:u})=>{if(u&&a&&o){const d=a.filter(h=>l.includes(h.type.name));c.ensureMarks(d)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),jx=J.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,z(this.options.HTMLAttributes,e),0]},parseMarkdown:(t,e)=>e.createNode("heading",{level:t.depth||1},e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>{var n;const r=(n=t.attrs)!=null&&n.level?parseInt(t.attrs.level,10):1,s="#".repeat(r);return t.content?`${s} ${e.renderChildren(t.content)}`:""},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>is({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),$x=J.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",z(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!Km(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,s=t();return Ka(n)?s.insertContentAt(r.pos,{type:this.name}):s.insertContent({type:this.name}),s.command(({state:i,tr:o,dispatch:l})=>{if(l){const{$to:a}=o.selection,c=a.end();if(a.nodeAfter)a.nodeAfter.isTextblock?o.setSelection(E.create(o.doc,a.pos+1)):a.nodeAfter.isBlock?o.setSelection(A.create(o.doc,a.pos)):o.setSelection(E.create(o.doc,a.pos));else{const u=i.schema.nodes[this.options.nextNodeType]||a.parent.type.contentMatch.defaultType,d=u==null?void 0:u.create();d&&(o.insert(c,d),o.setSelection(E.create(o.doc,c+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[cc({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),Fx=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Hx=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Vx=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,_x=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Wx=Oe.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",z(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(t,e)=>e.applyMark("italic",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[jt({find:Fx,type:this.type}),jt({find:Vx,type:this.type})]},addPasteRules(){return[wt({find:Hx,type:this.type}),wt({find:_x,type:this.type})]}}),ti="[\0-   ᠎ -\u2029 　]",qx=new RegExp(ti),Kx=new RegExp(`${ti}$`),Ux=new RegExp(ti,"g");function Jx(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function Gx(t){return new H({key:new _("autolink"),appendTransaction:(e,n,r)=>{const s=e.some(c=>c.docChanged)&&!n.doc.eq(r.doc),i=e.some(c=>c.getMeta("preventAutolink"));if(!s||i)return;const{tr:o}=r,l=Ba(n.doc,[...e]);if(qa(l).forEach(({newRange:c})=>{const u=Kp(r.doc,c,f=>f.isTextblock);let d,h;if(u.length>1)d=u[0],h=r.doc.textBetween(d.pos,d.pos+d.node.nodeSize,void 0," ");else if(u.length){const f=r.doc.textBetween(c.from,c.to," "," ");if(!Kx.test(f))return;d=u[0],h=r.doc.textBetween(d.pos,c.to,void 0," ")}if(d&&h){const f=h.split(qx).filter(Boolean);if(f.length<=0)return!1;const p=f[f.length-1],m=d.pos+h.lastIndexOf(p);if(!p)return!1;const g=zu(p).map(b=>b.toObject(t.defaultProtocol));if(!Jx(g))return!1;g.filter(b=>b.isLink).map(b=>({...b,from:m+b.start+1,to:m+b.end+1})).filter(b=>r.schema.marks.code?!r.doc.rangeHasMark(b.from,b.to,r.schema.marks.code):!0).filter(b=>t.validate(b.value)).filter(b=>t.shouldAutoLink(b.value)).forEach(b=>{Js(b.from,b.to,r.doc).some(k=>k.mark.type===t.type)||o.addMark(b.from,b.to,t.type.create({href:b.href}))})}}),!!o.steps.length)return o}})}function Xx(t){return new H({key:new _("handleClickLink"),props:{handleClick:(e,n,r)=>{var s,i;if(r.button!==0||!e.editable)return!1;let o=!1;if(t.enableClickSelection&&(o=t.editor.commands.extendMarkRange(t.type.name)),t.openOnClick){let l=null;if(r.target instanceof HTMLAnchorElement)l=r.target;else{let d=r.target;const h=[];for(;d.nodeName!=="DIV";)h.push(d),d=d.parentNode;l=h.find(f=>f.nodeName==="A")}if(!l)return o;const a=Wa(e.state,t.type.name),c=(s=l==null?void 0:l.href)!=null?s:a.href,u=(i=l==null?void 0:l.target)!=null?i:a.target;l&&c&&(window.open(c,u),o=!0)}return o}}})}function Yx(t){return new H({key:new _("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:s}=t,{state:i}=e,{selection:o}=i,{empty:l}=o;if(l)return!1;let a="";r.content.forEach(u=>{a+=u.textContent});const c=Qo(a,{defaultProtocol:t.defaultProtocol}).find(u=>u.isLink&&u.value===a);return!a||!c||s!==void 0&&!s(c.href)?!1:t.editor.commands.setMark(t.type,{href:c.href})}}})}function lt(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const s=typeof r=="string"?r:r.scheme;s&&n.push(s)}),!t||t.replace(Ux,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var Zx=Oe.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(t=>{if(typeof t=="string"){ri(t);return}ri(t.scheme,t.optionalSlashes)})},onDestroy(){Bu()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!lt(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>!!t}},addAttributes(){return{href:{default:null,parseHTML(t){return t.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:n=>!!lt(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!lt(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",z(this.options.HTMLAttributes,t),0]:["a",z(this.options.HTMLAttributes,{...t,href:""}),0]},markdownTokenName:"link",parseMarkdown:(t,e)=>e.applyMark("link",e.parseInline(t.tokens||[]),{href:t.href,title:t.title||null}),renderMarkdown:(t,e)=>{var n;const r=((n=t.attrs)==null?void 0:n.href)||"";return`[${e.renderChildren(t)}](${r})`},addCommands(){return{setLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!lt(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,t).setMeta("preventAutolink",!0).run():!1},toggleLink:t=>({chain:e})=>{const{href:n}=t||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:r=>!!lt(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[wt({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,s=Qo(t).filter(i=>i.isLink&&this.options.isAllowedUri(i.value,{defaultValidate:o=>!!lt(o,n),protocols:n,defaultProtocol:r}));s.length&&s.forEach(i=>{this.options.shouldAutoLink(i.value)&&e.push({text:i.value,data:{href:i.href},index:i.start})})}return e},type:this.type,getAttributes:t=>{var e;return{href:(e=t.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(Gx({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:s=>!!lt(s,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push(Xx({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(Yx({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),Qx=Object.defineProperty,e0=(t,e)=>{for(var n in e)Qx(t,n,{get:e[n],enumerable:!0})},t0="listItem",Ho="textStyle",Vo=/^\s*([-+*])\s$/,Rc=J.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",z(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>t.type!=="list"||t.ordered?[]:{type:"bulletList",content:t.items?e.parseChildren(t.items):[]},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
`):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(t0,this.editor.getAttributes(Ho)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=$t({find:Vo,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=$t({find:Vo,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Ho),editor:this.editor})),[t]}}),Lc=J.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",z(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:(t,e)=>{if(t.type!=="list_item")return[];let n=[];if(t.tokens&&t.tokens.length>0)if(t.tokens.some(s=>s.type==="paragraph"))n=e.parseChildren(t.tokens);else{const s=t.tokens[0];if(s&&s.type==="text"&&s.tokens&&s.tokens.length>0){if(n=[{type:"paragraph",content:e.parseInline(s.tokens)}],t.tokens.length>1){const o=t.tokens.slice(1),l=e.parseChildren(o);n.push(...l)}}else n=e.parseChildren(t.tokens)}return n.length===0&&(n=[{type:"paragraph",content:[]}]),{type:"listItem",content:n}},renderMarkdown:(t,e,n)=>Zs(t,e,r=>r.parentType==="bulletList"?"- ":r.parentType==="orderedList"?`${r.index+1}. `:"- ",n),addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),n0={};e0(n0,{findListItemPos:()=>hn,getNextListDepth:()=>ni,handleBackspace:()=>ms,handleDelete:()=>gs,hasListBefore:()=>Pc,hasListItemAfter:()=>r0,hasListItemBefore:()=>zc,listItemHasSubList:()=>Bc,nextListIsDeeper:()=>jc,nextListIsHigher:()=>$c});var hn=(t,e)=>{const{$from:n}=e.selection,r=U(t,e.schema);let s=null,i=n.depth,o=n.pos,l=null;for(;i>0&&l===null;)s=n.node(i),s.type===r?l=i:(i-=1,o-=1);return l===null?null:{$pos:e.doc.resolve(o),depth:l}},ni=(t,e)=>{const n=hn(t,e);if(!n)return!1;const[,r]=tm(e,t,n.$pos.pos+4);return r},Pc=(t,e,n)=>{const{$anchor:r}=t.selection,s=Math.max(0,r.pos-2),i=t.doc.resolve(s).node();return!(!i||!n.includes(i.type.name))},zc=(t,e)=>{var n;const{$anchor:r}=e.selection,s=e.doc.resolve(r.pos-2);return!(s.index()===0||((n=s.nodeBefore)==null?void 0:n.type.name)!==t)},Bc=(t,e,n)=>{if(!n)return!1;const r=U(t,e.schema);let s=!1;return n.descendants(i=>{i.type===r&&(s=!0)}),s},ms=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!rt(t.state,e)&&Pc(t.state,e,n)){const{$anchor:l}=t.state.selection,a=t.state.doc.resolve(l.before()-1),c=[];a.node().descendants((h,f)=>{h.type.name===e&&c.push({node:h,pos:f})});const u=c.at(-1);if(!u)return!1;const d=t.state.doc.resolve(a.start()+u.pos+1);return t.chain().cut({from:l.start()-1,to:l.end()+1},d.end()).joinForward().run()}if(!rt(t.state,e)||!im(t.state))return!1;const r=hn(e,t.state);if(!r)return!1;const i=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),o=Bc(e,t.state,i);return zc(e,t.state)&&!o?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},jc=(t,e)=>{const n=ni(t,e),r=hn(t,e);return!r||!n?!1:n>r.depth},$c=(t,e)=>{const n=ni(t,e),r=hn(t,e);return!r||!n?!1:n<r.depth},gs=(t,e)=>{if(!rt(t.state,e)||!sm(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:s}=n;return!n.empty&&r.sameParent(s)?!1:jc(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():$c(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},r0=(t,e)=>{var n;const{$anchor:r}=e.selection,s=e.doc.resolve(r.pos-r.parentOffset-2);return!(s.index()===s.parent.childCount-1||((n=s.nodeAfter)==null?void 0:n.type.name)!==t)},Fc=L.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&gs(t,n)&&(e=!0)}),e},"Mod-Delete":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&gs(t,n)&&(e=!0)}),e},Backspace:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&ms(t,n,r)&&(e=!0)}),e},"Mod-Backspace":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&ms(t,n,r)&&(e=!0)}),e}}}}),_o=/^(\s*)(\d+)\.\s+(.*)$/,s0=/^\s/;function i0(t){const e=[];let n=0,r=0;for(;n<t.length;){const s=t[n],i=s.match(_o);if(!i)break;const[,o,l,a]=i,c=o.length;let u=a,d=n+1;const h=[s];for(;d<t.length;){const f=t[d];if(f.match(_o))break;if(f.trim()==="")h.push(f),u+=`
`,d+=1;else if(f.match(s0))h.push(f),u+=`
${f.slice(c+2)}`,d+=1;else break}e.push({indent:c,number:parseInt(l,10),content:u.trim(),raw:h.join(`
`)}),r=d,n=d}return[e,r]}function Hc(t,e,n){var r;const s=[];let i=0;for(;i<t.length;){const o=t[i];if(o.indent===e){const l=o.content.split(`
`),a=((r=l[0])==null?void 0:r.trim())||"",c=[];a&&c.push({type:"paragraph",raw:a,tokens:n.inlineTokens(a)});const u=l.slice(1).join(`
`).trim();if(u){const f=n.blockTokens(u);c.push(...f)}let d=i+1;const h=[];for(;d<t.length&&t[d].indent>e;)h.push(t[d]),d+=1;if(h.length>0){const f=Math.min(...h.map(m=>m.indent)),p=Hc(h,f,n);c.push({type:"list",ordered:!0,start:h[0].number,items:p,raw:h.map(m=>m.raw).join(`
`)})}s.push({type:"list_item",raw:o.raw,tokens:c}),i=d}else i+=1}return s}function o0(t,e){return t.map(n=>{if(n.type!=="list_item")return e.parseChildren([n])[0];const r=[];return n.tokens&&n.tokens.length>0&&n.tokens.forEach(s=>{if(s.type==="paragraph"||s.type==="list"||s.type==="blockquote"||s.type==="code")r.push(...e.parseChildren([s]));else if(s.type==="text"&&s.tokens){const i=e.parseChildren([s]);r.push({type:"paragraph",content:i})}else{const i=e.parseChildren([s]);i.length>0&&r.push(...i)}}),{type:"listItem",content:r}})}var l0="listItem",Wo="textStyle",qo=/^(\d+)\.\s$/,Vc=J.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>t.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return e===1?["ol",z(this.options.HTMLAttributes,n),0]:["ol",z(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>{if(t.type!=="list"||!t.ordered)return[];const n=t.start||1,r=t.items?o0(t.items,e):[];return n!==1?{type:"orderedList",attrs:{start:n},content:r}:{type:"orderedList",content:r}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
`):"",markdownTokenizer:{name:"orderedList",level:"block",start:t=>{const e=t.match(/^(\s*)(\d+)\.\s+/),n=e==null?void 0:e.index;return n!==void 0?n:-1},tokenize:(t,e,n)=>{var r;const s=t.split(`
`),[i,o]=i0(s);if(i.length===0)return;const l=Hc(i,0,n);return l.length===0?void 0:{type:"list",ordered:!0,start:((r=i[0])==null?void 0:r.number)||1,items:l,raw:s.slice(0,o).join(`
`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(l0,this.editor.getAttributes(Wo)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=$t({find:qo,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=$t({find:qo,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Wo)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),a0=/^\s*(\[([( |x])?\])\s$/,c0=J.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:t=>{const e=t.getAttribute("data-checked");return e===""||e==="true"},renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:t,HTMLAttributes:e}){return["li",z(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(t,e)=>{const n=[];if(t.tokens&&t.tokens.length>0?n.push(e.createNode("paragraph",{},e.parseInline(t.tokens))):t.text?n.push(e.createNode("paragraph",{},[e.createNode("text",{text:t.text})])):n.push(e.createNode("paragraph",{},[])),t.nestedTokens&&t.nestedTokens.length>0){const r=e.parseChildren(t.nestedTokens);n.push(...r)}return e.createNode("taskItem",{checked:t.checked||!1},n)},renderMarkdown:(t,e)=>{var n;const s=`- [${(n=t.attrs)!=null&&n.checked?"x":" "}] `;return Zs(t,e,s)},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{const s=document.createElement("li"),i=document.createElement("label"),o=document.createElement("span"),l=document.createElement("input"),a=document.createElement("div"),c=u=>{var d,h;l.ariaLabel=((h=(d=this.options.a11y)==null?void 0:d.checkboxLabel)==null?void 0:h.call(d,u,l.checked))||`Task item checkbox for ${u.textContent||"empty task item"}`};return c(t),i.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",u=>u.preventDefault()),l.addEventListener("change",u=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}const{checked:d}=u.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:h})=>{const f=n();if(typeof f!="number")return!1;const p=h.doc.nodeAt(f);return h.setNodeMarkup(f,void 0,{...p==null?void 0:p.attrs,checked:d}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,d)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([u,d])=>{s.setAttribute(u,d)}),s.dataset.checked=t.attrs.checked,l.checked=t.attrs.checked,i.append(l,o),s.append(i,a),Object.entries(e).forEach(([u,d])=>{s.setAttribute(u,d)}),{dom:s,contentDOM:a,update:u=>u.type!==this.type?!1:(s.dataset.checked=u.attrs.checked,l.checked=u.attrs.checked,c(u),!0)}}},addInputRules(){return[$t({find:a0,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),u0=J.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",z(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
`):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){const r=i=>{const o=ls(i,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:l=>({indentLevel:l[1].length,mainContent:l[4],checked:l[3].toLowerCase()==="x"}),createToken:(l,a)=>({type:"taskItem",raw:"",mainContent:l.mainContent,indentLevel:l.indentLevel,checked:l.checked,text:l.mainContent,tokens:n.inlineTokens(l.mainContent),nestedTokens:a}),customNestedParser:r},n);return o?[{type:"taskList",raw:o.raw,items:o.items}]:n.blockTokens(i)},s=ls(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:i=>({indentLevel:i[1].length,mainContent:i[4],checked:i[3].toLowerCase()==="x"}),createToken:(i,o)=>({type:"taskItem",raw:"",mainContent:i.mainContent,indentLevel:i.indentLevel,checked:i.checked,text:i.mainContent,tokens:n.inlineTokens(i.mainContent),nestedTokens:o}),customNestedParser:r},n);if(s)return{type:"taskList",raw:s.raw,items:s.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});L.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(Rc.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(Lc.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(Fc.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(Vc.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(c0.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(u0.configure(this.options.taskList)),t}});var d0=J.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",z(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{const n=t.tokens||[];return n.length===1&&n[0].type==="image"?e.parseChildren([n[0]]):e.createNode("paragraph",void 0,e.parseInline(n))},renderMarkdown:(t,e)=>!t||!Array.isArray(t.content)?"":e.renderChildren(t.content),addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),h0=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,f0=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,p0=Oe.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",z(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:(t,e)=>e.applyMark("strike",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`~~${e.renderChildren(t)}~~`,addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[jt({find:h0,type:this.type})]},addPasteRules(){return[wt({find:f0,type:this.type})]}}),m0=J.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),g0=Oe.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",z(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,n){const s=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!s)return;const i=s[2].trim();return{type:"underline",raw:s[0],text:i,tokens:n.inlineTokens(i)}}},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()}}}),y0=L.create({name:"starterKit",addExtensions(){var t,e,n,r;const s=[];return this.options.bold!==!1&&s.push(Dx.configure(this.options.bold)),this.options.blockquote!==!1&&s.push(Ex.configure(this.options.blockquote)),this.options.bulletList!==!1&&s.push(Rc.configure(this.options.bulletList)),this.options.code!==!1&&s.push(Px.configure(this.options.code)),this.options.codeBlock!==!1&&s.push(yc.configure(this.options.codeBlock)),this.options.document!==!1&&s.push(zx.configure(this.options.document)),this.options.dropcursor!==!1&&s.push(wx.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&s.push(Sx.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&s.push(Bx.configure(this.options.hardBreak)),this.options.heading!==!1&&s.push(jx.configure(this.options.heading)),this.options.undoRedo!==!1&&s.push(Mx.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&s.push($x.configure(this.options.horizontalRule)),this.options.italic!==!1&&s.push(Wx.configure(this.options.italic)),this.options.listItem!==!1&&s.push(Lc.configure(this.options.listItem)),this.options.listKeymap!==!1&&s.push(Fc.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&s.push(Zx.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&s.push(Vc.configure(this.options.orderedList)),this.options.paragraph!==!1&&s.push(d0.configure(this.options.paragraph)),this.options.strike!==!1&&s.push(p0.configure(this.options.strike)),this.options.text!==!1&&s.push(m0.configure(this.options.text)),this.options.underline!==!1&&s.push(g0.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&s.push(vx.configure((r=this.options)==null?void 0:r.trailingNode)),s}}),b0=y0;const x0=[b0.configure({codeBlock:!1,link:{shouldAutoLink:t=>/^https?:\/\//.test(t)}}),ex.configure({table:{resizable:!0}}),Cx.configure({placeholder:"Write something..."}),$y,_y,Hy,mc,gc,Sy,vy,zy.configure({lowlight:we}),nx.configure({types:["heading","paragraph"]}),My,Cy];function k0(){const[t,e]=R.useState(!1),{trans:n}=Xc(),s=Jo().watch("title"),i=n({message:"Title"}),o=t?y.jsx(zn,{placeholder:i,autoFocus:!0,className:"mb-30",onBlur:()=>{e(!1)},name:"title",required:!0}):y.jsxs("h1",{tabIndex:0,onClick:()=>{e(!0)},onFocus:()=>{e(!0)},className:ge("cursor-pointer rounded hover:bg-primary/focus",!s&&"text-muted"),children:[s||i,y.jsx(ju,{className:"mx-8 mt-8 align-top text-muted icon-sm"})]});return y.jsx("div",{className:"prose mx-auto my-48 w-full flex-shrink-0 px-24 dark:prose-invert",children:o})}function w0({className:t="contents"}){const e=te();return y.jsx(Hg,{editor:e,className:t})}function S0({extensions:t,autoFocus:e,initialContent:n,contentClassName:r,onChange:s,onBlur:i,onFocus:o,changesAsText:l,onSubmit:a,onCreate:c,submitToClosestForm:u,preventNewLine:d}){const h=R.useRef(a);h.current=a??u?C0:void 0;const f=R.useRef(s);f.current=s;const p=R.useMemo(()=>{const b=[...t],k={};if(h.current&&(k["Cmd-Enter"]=w=>{var C;return(C=h.current)==null||C.call(h,w),!0},k["Ctrl-Enter"]=w=>{var C;return(C=h.current)==null||C.call(h,w),!0}),d&&(k.Enter=w=>(h.current&&h.current(w),!0)),Object.keys(k).length>0){const w=L.create({addKeyboardShortcuts:()=>k});b.push(w)}return b},[t]),m=R.useMemo(()=>({attributes:{class:r||""}}),[r]),g=R.useCallback(b=>{var w;let k=l?b.editor.getText():b.editor.getHTML();k==="<p></p>"&&(k=""),(w=f.current)==null||w.call(f,k)},[]);return Ug({extensions:p,autofocus:e,content:n,shouldRerenderOnTransaction:!1,editorProps:m,onUpdate:g,onBlur:i,onFocus:o,onCreate:c})}function C0({editor:t}){const e=t.$doc.element.closest("form");let n=e==null?void 0:e.querySelector('button[type="submit"]');!n&&(e!=null&&e.id)&&(n=document.querySelector(`button[type="submit"][form="${e.id}"]`)),e&&n&&!n.disabled&&e.requestSubmit(n)}function v0({children:t,ref:e,...n}){const r=S0(n),s=R.useMemo(()=>({editor:r}),[r]);return R.useImperativeHandle(e,()=>({clearContents:()=>r==null?void 0:r.commands.clearContent(),getEditor:()=>r})),y.jsx(tl.Provider,{value:s,children:t})}const M0=Yc(y.jsx("path",{d:"M14 2H2C1.45 2 1 2.45 1 3V13C1 13.55 1.45 14 2 14H14C14.55 14 15 13.55 15 13V3C15 2.45 14.55 2 14 2ZM2.7 3.7H10V12.3H2.7V3.7Z"}),"ToggleRightSidebarIcon","0 0 16 16");function _c(){const{rightSidenavStatus:t,setRightSidenavStatus:e}=R.useContext(el);return y.jsx(me,{label:y.jsx(O,{message:"Toggle sidebar"}),children:y.jsx(X,{size:"xs",onClick:()=>e(t==="open"?"closed":"open"),children:y.jsx(M0,{})})})}var T0=({key:t,editor:e,onPaste:n,onDrop:r,allowedMimeTypes:s})=>new H({key:t||new _("fileHandler"),props:{handleDrop(i,o){var l;if(!r||!((l=o.dataTransfer)!=null&&l.files.length))return!1;const a=i.posAtCoords({left:o.clientX,top:o.clientY});let c=Array.from(o.dataTransfer.files);return s&&(c=c.filter(u=>s.includes(u.type))),c.length===0?!1:(o.preventDefault(),o.stopPropagation(),r(e,c,(a==null?void 0:a.pos)||0),!0)},handlePaste(i,o){var l;if(!n||!((l=o.clipboardData)!=null&&l.files.length))return!1;let a=Array.from(o.clipboardData.files);const c=o.clipboardData.getData("text/html");return s&&(a=a.filter(u=>s.includes(u.type))),!(a.length===0||(o.preventDefault(),o.stopPropagation(),n(e,a,c),c.length>0))}}}),E0=L.create({name:"fileHandler",addOptions(){return{onPaste:void 0,onDrop:void 0,allowedMimeTypes:void 0}},addProseMirrorPlugins(){return[T0({key:new _(this.name),editor:this.editor,allowedMimeTypes:this.options.allowedMimeTypes,onDrop:this.options.onDrop,onPaste:this.options.onPaste})]}}),A0=E0;function Z0(t){return y.jsx(O0,{children:y.jsx(N0,{...t})})}function N0({imageUploadType:t,initialContent:e,onChange:n,saveButton:r,title:s,aside:i}){const{rightSidenavStatus:o}=R.useContext(el),l=vu(c=>c.uploadMultiple),a=R.useMemo(()=>{const c=(u,d,h)=>{l(u,{uploadType:t,showToastOnRestrictionFail:!0,onSuccess:async(f,p)=>{const m=await Xo(p.native);d.chain().insertContentAt(h??d.state.selection.anchor,{type:"image",attrs:{src:f.url,width:m.width,height:m.height}}).focus().run()}})};return[...x0,A0.configure({onDrop:(u,d,h)=>{c(d,u,h)},onPaste:(u,d)=>{c(d,u)}})]},[l,t]);return y.jsxs(v0,{extensions:a,initialContent:e,onChange:n,children:[y.jsxs("section",{className:"dashboard-grid-content dashboard-rounded-panel flex h-full min-h-0 min-w-0 flex-col",children:[y.jsx(py,{saveButton:r,rightContent:o==="closed"?y.jsx(_c,{}):null,children:s}),y.jsx(ay,{imageUploadType:t}),y.jsxs("div",{className:"flex-auto overflow-y-auto",children:[y.jsx(k0,{}),y.jsx(w0,{className:"prose mx-auto flex-auto px-24 dark:prose-invert"})]})]}),i&&y.jsx($u,{position:"right",size:"w-[350px]",className:"dashboard-rounded-panel flex-shrink-0 flex-col lg:ml-8",children:y.jsx(I0,{children:i})})]})}function O0({children:t}){return y.jsx(Cu,{children:t})}function I0({children:t}){return y.jsxs(R.Fragment,{children:[y.jsx(Yo,{rightContent:y.jsx(_c,{}),children:y.jsx(O,{message:"Details"})}),y.jsx("div",{className:"flex-auto overflow-y-auto p-24",children:t})]})}export{Z0 as A};
