@grapesjs/studio-sdk-plugins 1.0.13 → 1.0.14-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +280 -269
- package/dist/index.umd.js +1 -1
- package/dist/youtubeAssetProvider/index.cjs.js +1 -1
- package/dist/youtubeAssetProvider/index.es.js +79 -68
- package/dist/youtubeAssetProvider/index.umd.js +1 -1
- package/dist/youtubeAssetProvider/locale/en.d.ts +7 -0
- package/dist/youtubeAssetProvider/types.d.ts +2 -0
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -126,4 +126,4 @@
|
|
|
126
126
|
`),h&&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:q(g)+1});break}let y=m.pmViewDesc;if(y&&y.node&&y.node.isBlock)break}}else{let m=f.childNodes[p-1];h=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(we&&d.focusNode&&d.focusNode!=a.node&&d.focusNode.nodeType==1){let f=d.focusNode.childNodes[d.focusOffset];f&&f.contentEditable=="false"&&(o=!0)}if(!(o||h&&te)&&yt(l.node,l.offset,d.anchorNode,d.anchorOffset)&&yt(a.node,a.offset,d.focusNode,d.focusOffset))return;let u=!1;if((c.extend||e==t)&&!h){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),u=!0}catch{}}if(!u){if(e>t){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,t){for(let i=0,o=0;o<this.children.length;o++){let r=this.children[o],s=i+r.size;if(i==s?e<=s&&t>=i:e<s&&t>i){let l=i+r.border,a=s-r.border;if(e>=l&&t<=a){this.dirty=e==i||t==s?st:Ur,e==l&&t==a&&(r.contentLost||r.dom.parentNode!=this.contentDOM)?r.dirty=ke:r.markDirty(e-l,t-l);return}else r.dirty=r.dom==r.contentDOM&&r.dom.parentNode==this.contentDOM&&!r.children.length?st:ke}i=s}this.dirty=st}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let i=e==1?st:Ur;t.dirty<i&&(t.dirty=i)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(e){return!1}}class ma extends Sn{constructor(e,t,i,o){let r,s=t.type.toDOM;if(typeof s=="function"&&(s=s(i,()=>{if(!r)return o;if(r.parent)return r.parent.posBeforeChild(r)})),!t.type.spec.raw){if(s.nodeType!=1){let l=document.createElement("span");l.appendChild(s),s=l}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=t,this.widget=t,r=this}matchesWidget(e){return this.dirty==pe&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(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 side(){return this.widget.type.side}}class Yu extends Sn{constructor(e,t,i,o){super(e,[],t,null),this.textDOM=i,this.text=o}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class bt extends Sn{constructor(e,t,i,o,r){super(e,[],i,o),this.mark=t,this.spec=r}static create(e,t,i,o){let r=o.nodeViews[t.type.name],s=r&&r(t,o,i);return(!s||!s.dom)&&(s=wt.renderSpec(document,t.type.spec.toDOM(t,i),null,t.attrs)),new bt(e,t,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&ke||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=ke&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=pe){let i=this.parent;for(;!i.node;)i=i.parent;i.dirty<this.dirty&&(i.dirty=this.dirty),this.dirty=pe}}slice(e,t,i){let o=bt.create(this.parent,this.mark,!0,i),r=this.children,s=this.size;t<s&&(r=po(r,t,s,i)),e>0&&(r=po(r,0,e,i));for(let l=0;l<r.length;l++)r[l].parent=o;return o.children=r,o}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class Ge extends Sn{constructor(e,t,i,o,r,s,l,a,c){super(e,[],r,s),this.node=t,this.outerDeco=i,this.innerDeco=o,this.nodeDOM=l}static create(e,t,i,o,r,s){let l=r.nodeViews[t.type.name],a,c=l&&l(t,r,()=>{if(!a)return s;if(a.parent)return a.parent.posBeforeChild(a)},i,o),d=c&&c.dom,h=c&&c.contentDOM;if(t.isText){if(!d)d=document.createTextNode(t.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:h}=wt.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!h&&!t.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),t.type.spec.draggable&&(d.draggable=!0));let u=d;return d=wa(d,i,t),c?a=new Xu(e,t,i,o,d,h||null,u,c,r,s+1):t.isText?new gi(e,t,i,o,d,u,r):new Ge(e,t,i,o,d,h||null,u,r,s+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 t=this.children.length-1;t>=0;t--){let i=this.children[t];if(this.dom.contains(i.dom.parentNode)){e.contentElement=i.dom.parentNode;break}}e.contentElement||(e.getContent=()=>w.empty)}return e}matchesNode(e,t,i){return this.dirty==pe&&e.eq(this.node)&&ii(t,this.outerDeco)&&i.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let i=this.node.inlineContent,o=t,r=e.composing?this.localCompositionInfo(e,t):null,s=r&&r.pos>-1?r:null,l=r&&r.pos<0,a=new ef(this,s&&s.node,e);of(this.node,this.innerDeco,(c,d,h)=>{c.spec.marks?a.syncToMarks(c.spec.marks,i,e):c.type.side>=0&&!h&&a.syncToMarks(d==this.node.childCount?I.none:this.node.child(d).marks,i,e),a.placeWidget(c,e,o)},(c,d,h,u)=>{a.syncToMarks(c.marks,i,e);let f;a.findNodeMatch(c,d,h,u)||l&&e.state.selection.from>o&&e.state.selection.to<o+c.nodeSize&&(f=a.findIndexWithChild(r.node))>-1&&a.updateNodeAt(c,d,h,f,e)||a.updateNextNode(c,d,h,e,u,o)||a.addNode(c,d,h,e,o),o+=c.nodeSize}),a.syncToMarks([],i,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==st)&&(s&&this.protectLocalComposition(e,s),ya(this.contentDOM,this.children,e),_t&&rf(this.dom))}localCompositionInfo(e,t){let{from:i,to:o}=e.state.selection;if(!(e.state.selection instanceof N)||i<t||o>t+this.node.content.size)return null;let r=e.input.compositionNode;if(!r||!this.dom.contains(r.parentNode))return null;if(this.node.inlineContent){let s=r.nodeValue,l=sf(this.node.content,s,i-t,o-t);return l<0?null:{node:r,pos:l,text:s}}else return{node:r,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:i,text:o}){if(this.getDesc(t))return;let r=t;for(;r.parentNode!=this.contentDOM;r=r.parentNode){for(;r.previousSibling;)r.parentNode.removeChild(r.previousSibling);for(;r.nextSibling;)r.parentNode.removeChild(r.nextSibling);r.pmViewDesc&&(r.pmViewDesc=void 0)}let s=new Yu(this,r,t,o);e.input.compositionNodes.push(s),this.children=po(this.children,i,i+o.length,e,s)}update(e,t,i,o){return this.dirty==ke||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,i,o),!0)}updateInner(e,t,i,o){this.updateOuterDeco(t),this.node=e,this.innerDeco=i,this.contentDOM&&this.updateChildren(o,this.posAtStart),this.dirty=pe}updateOuterDeco(e){if(ii(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,i=this.dom;this.dom=ba(this.dom,this.nodeDOM,fo(this.outerDeco,this.node,t),fo(e,this.node,t)),this.dom!=i&&(i.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.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function Zr(n,e,t,i,o){wa(i,e,n);let r=new Ge(void 0,n,e,t,i,i,i,o,0);return r.contentDOM&&r.updateChildren(o,0),r}class gi extends Ge{constructor(e,t,i,o,r,s,l){super(e,t,i,o,r,null,s,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,i,o){return this.dirty==ke||this.dirty!=pe&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=pe||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,o.trackWrites==this.nodeDOM&&(o.trackWrites=null)),this.node=e,this.dirty=pe,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,i){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,i)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,i){let o=this.node.cut(e,t),r=document.createTextNode(o.text);return new gi(this.parent,o,this.outerDeco,this.innerDeco,r,r,i)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=ke)}get domAtom(){return!1}isText(e){return this.node.text==e}}class ga extends Sn{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==pe&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Xu extends Ge{constructor(e,t,i,o,r,s,l,a,c,d){super(e,t,i,o,r,s,l,c,d),this.spec=a}update(e,t,i,o){if(this.dirty==ke)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let r=this.spec.update(e,t,i);return r&&this.updateInner(e,t,i,o),r}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,i,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,i,o){this.spec.setSelection?this.spec.setSelection(e,t,i.root):super.setSelection(e,t,i,o)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function ya(n,e,t){let i=n.firstChild,o=!1;for(let r=0;r<e.length;r++){let s=e[r],l=s.dom;if(l.parentNode==n){for(;l!=i;)i=Yr(i),o=!0;i=i.nextSibling}else o=!0,n.insertBefore(l,i);if(s instanceof bt){let a=i?i.previousSibling:n.lastChild;ya(s.contentDOM,s.children,t),i=a?a.nextSibling:n.firstChild}}for(;i;)i=Yr(i),o=!0;o&&t.trackWrites==n&&(t.trackWrites=null)}const rn=function(n){n&&(this.nodeName=n)};rn.prototype=Object.create(null);const lt=[new rn];function fo(n,e,t){if(n.length==0)return lt;let i=t?lt[0]:new rn,o=[i];for(let r=0;r<n.length;r++){let s=n[r].type.attrs;if(s){s.nodeName&&o.push(i=new rn(s.nodeName));for(let l in s){let a=s[l];a!=null&&(t&&o.length==1&&o.push(i=new rn(e.isInline?"span":"div")),l=="class"?i.class=(i.class?i.class+" ":"")+a:l=="style"?i.style=(i.style?i.style+";":"")+a:l!="nodeName"&&(i[l]=a))}}}return o}function ba(n,e,t,i){if(t==lt&&i==lt)return e;let o=e;for(let r=0;r<i.length;r++){let s=i[r],l=t[r];if(r){let a;l&&l.nodeName==s.nodeName&&o!=n&&(a=o.parentNode)&&a.nodeName.toLowerCase()==s.nodeName||(a=document.createElement(s.nodeName),a.pmIsDeco=!0,a.appendChild(o),l=lt[0]),o=a}Qu(o,l||lt[0],s)}return o}function Qu(n,e,t){for(let i in e)i!="class"&&i!="style"&&i!="nodeName"&&!(i in t)&&n.removeAttribute(i);for(let i in t)i!="class"&&i!="style"&&i!="nodeName"&&t[i]!=e[i]&&n.setAttribute(i,t[i]);if(e.class!=t.class){let i=e.class?e.class.split(" ").filter(Boolean):[],o=t.class?t.class.split(" ").filter(Boolean):[];for(let r=0;r<i.length;r++)o.indexOf(i[r])==-1&&n.classList.remove(i[r]);for(let r=0;r<o.length;r++)i.indexOf(o[r])==-1&&n.classList.add(o[r]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let i=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,o;for(;o=i.exec(e.style);)n.style.removeProperty(o[1])}t.style&&(n.style.cssText+=t.style)}}function wa(n,e,t){return ba(n,n,lt,fo(e,t,n.nodeType!=1))}function ii(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function Yr(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class ef{constructor(e,t,i){this.lock=t,this.view=i,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=tf(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let i=e;i<t;i++)this.top.children[i].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,i){let o=0,r=this.stack.length>>1,s=Math.min(r,e.length);for(;o<s&&(o==r-1?this.top:this.stack[o+1<<1]).matchesMark(e[o])&&e[o].type.spec.spanning!==!1;)o++;for(;o<r;)this.destroyRest(),this.top.dirty=pe,this.index=this.stack.pop(),this.top=this.stack.pop(),r--;for(;r<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[r])&&!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=bt.create(this.top,e[r],t,i);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,r++}}findNodeMatch(e,t,i,o){let r=-1,s;if(o>=this.preMatch.index&&(s=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&s.matchesNode(e,t,i))r=this.top.children.indexOf(s,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,t,i)&&!this.preMatch.matched.has(c)){r=l;break}}return r<0?!1:(this.destroyBetween(this.index,r),this.index++,!0)}updateNodeAt(e,t,i,o,r){let s=this.top.children[o];return s.dirty==ke&&s.dom==s.contentDOM&&(s.dirty=st),s.update(e,t,i,r)?(this.destroyBetween(this.index,o),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let i=e.pmViewDesc;if(i){for(let o=this.index;o<this.top.children.length;o++)if(this.top.children[o]==i)return o}return-1}e=t}}updateNextNode(e,t,i,o,r,s){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof Ge){let c=this.preMatch.matched.get(a);if(c!=null&&c!=r)return!1;let d=a.dom,h,u=this.isLocked(d)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=ke&&ii(t,a.outerDeco));if(!u&&a.update(e,t,i,o))return this.destroyBetween(this.index,l),a.dom!=d&&(this.changed=!0),this.index++,!0;if(!u&&(h=this.recreateWrapper(a,e,t,i,o,s)))return this.destroyBetween(this.index,l),this.top.children[this.index]=h,h.contentDOM&&(h.dirty=st,h.updateChildren(o,s+1),h.dirty=pe),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,i,o,r,s){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!ii(i,e.outerDeco)||!o.eq(e.innerDeco))return null;let l=Ge.create(this.top,t,i,o,r,s);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,t,i,o,r){let s=Ge.create(this.top,e,t,i,o,r);s.contentDOM&&s.updateChildren(o,r+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(e,t,i){let o=this.index<this.top.children.length?this.top.children[this.index]:null;if(o&&o.matchesWidget(e)&&(e==o.widget||!o.widget.type.toDOM.parentNode))this.index++;else{let r=new ma(this.top,e,t,i);this.top.children.splice(this.index++,0,r),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof bt;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof gi)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((te||Z)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let i=document.createElement(e);e=="IMG"&&(i.className="ProseMirror-separator",i.alt=""),e=="BR"&&(i.className="ProseMirror-trailingBreak");let o=new ga(this.top,[],i,null);t!=this.top?t.children.push(o):t.children.splice(this.index++,0,o),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function tf(n,e){let t=e,i=t.children.length,o=n.childCount,r=new Map,s=[];e:for(;o>0;){let l;for(;;)if(i){let c=t.children[i-1];if(c instanceof bt)t=c,i=c.children.length;else{l=c,i--;break}}else{if(t==e)break e;i=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(o-1))break;--o,r.set(l,o),s.push(l)}}return{index:o,matched:r,matches:s.reverse()}}function nf(n,e){return n.type.side-e.type.side}function of(n,e,t,i){let o=e.locals(n),r=0;if(o.length==0){for(let c=0;c<n.childCount;c++){let d=n.child(c);i(d,o,e.forChild(r,d),c),r+=d.nodeSize}return}let s=0,l=[],a=null;for(let c=0;;){let d,h;for(;s<o.length&&o[s].to==r;){let g=o[s++];g.widget&&(d?(h||(h=[d])).push(g):d=g)}if(d)if(h){h.sort(nf);for(let g=0;g<h.length;g++)t(h[g],c,!!a)}else t(d,c,!!a);let u,f;if(a)f=-1,u=a,a=null;else if(c<n.childCount)f=c,u=n.child(c++);else break;for(let g=0;g<l.length;g++)l[g].to<=r&&l.splice(g--,1);for(;s<o.length&&o[s].from<=r&&o[s].to>r;)l.push(o[s++]);let p=r+u.nodeSize;if(u.isText){let g=p;s<o.length&&o[s].from<g&&(g=o[s].from);for(let y=0;y<l.length;y++)l[y].to<g&&(g=l[y].to);g<p&&(a=u.cut(g-r),u=u.cut(0,g-r),p=g,f=-1)}else for(;s<o.length&&o[s].to<p;)s++;let m=u.isInline&&!u.isLeaf?l.filter(g=>!g.inline):l.slice();i(u,m,e.forChild(r,u),f),r=p}}function rf(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function sf(n,e,t,i){for(let o=0,r=0;o<n.childCount&&r<=i;){let s=n.child(o++),l=r;if(r+=s.nodeSize,!s.isText)continue;let a=s.text;for(;o<n.childCount;){let c=n.child(o++);if(r+=c.nodeSize,!c.isText)break;a+=c.text}if(r>=t){if(r>=i&&a.slice(i-e.length-l,i-l)==e)return i-e.length;let c=l<i?a.lastIndexOf(e,i-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==i&&a.length>=i+e.length-l&&a.slice(i-l,i-l+e.length)==e)return i}}return-1}function po(n,e,t,i,o){let r=[];for(let s=0,l=0;s<n.length;s++){let a=n[s],c=l,d=l+=a.size;c>=t||d<=e?r.push(a):(c<e&&r.push(a.slice(0,e-c,i)),o&&(r.push(o),o=void 0),d>t&&r.push(a.slice(t-c,a.size,i)))}return r}function Lo(n,e=null){let t=n.domSelectionRange(),i=n.state.doc;if(!t.focusNode)return null;let o=n.docView.nearestDesc(t.focusNode),r=o&&o.size==0,s=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(s<0)return null;let l=i.resolve(s),a,c;if(mi(t)){for(a=s;o&&!o.node;)o=o.parent;let h=o.node;if(o&&h.isAtom&&O.isSelectable(h)&&o.parent&&!(h.isInline&&Du(t.focusNode,t.focusOffset,o.dom))){let u=o.posBefore;c=new O(s==u?l:i.resolve(u))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let h=s,u=s;for(let f=0;f<t.rangeCount;f++){let p=t.getRangeAt(f);h=Math.min(h,n.docView.posFromDOM(p.startContainer,p.startOffset,1)),u=Math.max(u,n.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(h<0)return null;[a,s]=u==n.state.selection.anchor?[u,h]:[h,u],l=i.resolve(s)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let d=i.resolve(a);if(!c){let h=e=="pointer"||n.state.selection.head<l.pos&&!r?1:-1;c=zo(n,d,l,h)}return c}function Sa(n){return n.editable?n.hasFocus():xa(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function Re(n,e=!1){let t=n.state.selection;if(va(n,t),!!Sa(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&Z){let i=n.domSelectionRange(),o=n.domObserver.currentSelection;if(i.anchorNode&&o.anchorNode&&yt(i.anchorNode,i.anchorOffset,o.anchorNode,o.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)af(n);else{let{anchor:i,head:o}=t,r,s;Xr&&!(t instanceof N)&&(t.$from.parent.inlineContent||(r=Qr(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(s=Qr(n,t.to))),n.docView.setSelection(i,o,n,e),Xr&&(r&&es(r),s&&es(s)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&lf(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const Xr=te||Z&&aa<63;function Qr(n,e){let{node:t,offset:i}=n.docView.domFromPos(e,0),o=i<t.childNodes.length?t.childNodes[i]:null,r=i?t.childNodes[i-1]:null;if(te&&o&&o.contentEditable=="false")return Wi(o);if((!o||o.contentEditable=="false")&&(!r||r.contentEditable=="false")){if(o)return Wi(o);if(r)return Wi(r)}}function Wi(n){return n.contentEditable="true",te&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function es(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function lf(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),i=t.anchorNode,o=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=i||t.anchorOffset!=o)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!Sa(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function af(n){let e=n.domSelection(),t=document.createRange();if(!e)return;let i=n.cursorWrapper.dom,o=i.nodeName=="IMG";o?t.setStart(i.parentNode,q(i)+1):t.setStart(i,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!o&&!n.state.selection.visible&&re&&Je<=11&&(i.disabled=!0,i.disabled=!1)}function va(n,e){if(e instanceof O){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(ts(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else ts(n)}function ts(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function zo(n,e,t,i){return n.someProp("createSelectionBetween",o=>o(n,e,t))||N.between(e,t,i)}function ns(n){return n.editable&&!n.hasFocus()?!1:xa(n)}function xa(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function cf(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return yt(e.node,e.offset,t.anchorNode,t.anchorOffset)}function mo(n,e){let{$anchor:t,$head:i}=n.selection,o=e>0?t.max(i):t.min(i),r=o.parent.inlineContent?o.depth?n.doc.resolve(e>0?o.after():o.before()):null:o;return r&&E.findFrom(r,e)}function Fe(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function is(n,e,t){let i=n.state.selection;if(i instanceof N)if(t.indexOf("s")>-1){let{$head:o}=i,r=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter;if(!r||r.isText||!r.isLeaf)return!1;let s=n.state.doc.resolve(o.pos+r.nodeSize*(e<0?-1:1));return Fe(n,new N(i.$anchor,s))}else if(i.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let o=mo(n.state,e);return o&&o instanceof O?Fe(n,o):!1}else if(!(ue&&t.indexOf("m")>-1)){let o=i.$head,r=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter,s;if(!r||r.isText)return!1;let l=e<0?o.pos-r.nodeSize:o.pos;return r.isAtom||(s=n.docView.descAt(l))&&!s.contentDOM?O.isSelectable(r)?Fe(n,new O(e<0?n.state.doc.resolve(o.pos-r.nodeSize):o)):wn?Fe(n,new N(n.state.doc.resolve(e<0?l:l+r.nodeSize))):!1:!1}}else return!1;else{if(i instanceof O&&i.node.isInline)return Fe(n,new N(e>0?i.$to:i.$from));{let o=mo(n.state,e);return o?Fe(n,o):!1}}}function oi(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function sn(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function Tt(n,e){return e<0?df(n):hf(n)}function df(n){let e=n.domSelectionRange(),t=e.focusNode,i=e.focusOffset;if(!t)return;let o,r,s=!1;for(we&&t.nodeType==1&&i<oi(t)&&sn(t.childNodes[i],-1)&&(s=!0);;)if(i>0){if(t.nodeType!=1)break;{let l=t.childNodes[i-1];if(sn(l,-1))o=t,r=--i;else if(l.nodeType==3)t=l,i=t.nodeValue.length;else break}}else{if(Ca(t))break;{let l=t.previousSibling;for(;l&&sn(l,-1);)o=t.parentNode,r=q(l),l=l.previousSibling;if(l)t=l,i=oi(t);else{if(t=t.parentNode,t==n.dom)break;i=0}}}s?go(n,t,i):o&&go(n,o,r)}function hf(n){let e=n.domSelectionRange(),t=e.focusNode,i=e.focusOffset;if(!t)return;let o=oi(t),r,s;for(;;)if(i<o){if(t.nodeType!=1)break;let l=t.childNodes[i];if(sn(l,1))r=t,s=++i;else break}else{if(Ca(t))break;{let l=t.nextSibling;for(;l&&sn(l,1);)r=l.parentNode,s=q(l)+1,l=l.nextSibling;if(l)t=l,i=0,o=oi(t);else{if(t=t.parentNode,t==n.dom)break;i=o=0}}}r&&go(n,r,s)}function Ca(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function uf(n,e){for(;n&&e==n.childNodes.length&&!bn(n);)e=q(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function ff(n,e){for(;n&&!e&&!bn(n);)e=q(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function go(n,e,t){if(e.nodeType!=3){let r,s;(s=uf(e,t))?(e=s,t=0):(r=ff(e,t))&&(e=r,t=r.nodeValue.length)}let i=n.domSelection();if(!i)return;if(mi(i)){let r=document.createRange();r.setEnd(e,t),r.setStart(e,t),i.removeAllRanges(),i.addRange(r)}else i.extend&&i.extend(e,t);n.domObserver.setCurSelection();let{state:o}=n;setTimeout(()=>{n.state==o&&Re(n)},50)}function rs(n,e){let t=n.state.doc.resolve(e);if(!(Z||Ru)&&t.parent.inlineContent){let o=n.coordsAtPos(e);if(e>t.start()){let r=n.coordsAtPos(e-1),s=(r.top+r.bottom)/2;if(s>o.top&&s<o.bottom&&Math.abs(r.left-o.left)>1)return r.left<o.left?"ltr":"rtl"}if(e<t.end()){let r=n.coordsAtPos(e+1),s=(r.top+r.bottom)/2;if(s>o.top&&s<o.bottom&&Math.abs(r.left-o.left)>1)return r.left>o.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function ss(n,e,t){let i=n.state.selection;if(i instanceof N&&!i.empty||t.indexOf("s")>-1||ue&&t.indexOf("m")>-1)return!1;let{$from:o,$to:r}=i;if(!o.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let s=mo(n.state,e);if(s&&s instanceof O)return Fe(n,s)}if(!o.parent.inlineContent){let s=e<0?o:r,l=i instanceof ce?E.near(s,e):E.findFrom(s,e);return l?Fe(n,l):!1}return!1}function ls(n,e){if(!(n.state.selection instanceof N))return!0;let{$head:t,$anchor:i,empty:o}=n.state.selection;if(!t.sameParent(i))return!0;if(!o)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let r=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(r&&!r.isText){let s=n.state.tr;return e<0?s.delete(t.pos-r.nodeSize,t.pos):s.delete(t.pos,t.pos+r.nodeSize),n.dispatch(s),!0}return!1}function as(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function pf(n){if(!te||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let i=e.firstChild;as(n,i,"true"),setTimeout(()=>as(n,i,"false"),20)}return!1}function mf(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function gf(n,e){let t=e.keyCode,i=mf(e);if(t==8||ue&&t==72&&i=="c")return ls(n,-1)||Tt(n,-1);if(t==46&&!e.shiftKey||ue&&t==68&&i=="c")return ls(n,1)||Tt(n,1);if(t==13||t==27)return!0;if(t==37||ue&&t==66&&i=="c"){let o=t==37?rs(n,n.state.selection.from)=="ltr"?-1:1:-1;return is(n,o,i)||Tt(n,o)}else if(t==39||ue&&t==70&&i=="c"){let o=t==39?rs(n,n.state.selection.from)=="ltr"?1:-1:1;return is(n,o,i)||Tt(n,o)}else{if(t==38||ue&&t==80&&i=="c")return ss(n,-1,i)||Tt(n,-1);if(t==40||ue&&t==78&&i=="c")return pf(n)||ss(n,1,i)||Tt(n,1);if(i==(ue?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function ka(n,e){n.someProp("transformCopied",f=>{e=f(e,n)});let t=[],{content:i,openStart:o,openEnd:r}=e;for(;o>1&&r>1&&i.childCount==1&&i.firstChild.childCount==1;){o--,r--;let f=i.firstChild;t.push(f.type.name,f.attrs!=f.type.defaultAttrs?f.attrs:null),i=f.content}let s=n.someProp("clipboardSerializer")||wt.fromSchema(n.state.schema),l=Na(),a=l.createElement("div");a.appendChild(s.serializeFragment(i,{document:l}));let c=a.firstChild,d,h=0;for(;c&&c.nodeType==1&&(d=Ea[c.nodeName.toLowerCase()]);){for(let f=d.length-1;f>=0;f--){let p=l.createElement(d[f]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),h++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${o} ${r}${h?` -${h}`:""} ${JSON.stringify(t)}`);let u=n.someProp("clipboardTextSerializer",f=>f(e,n))||e.content.textBetween(0,e.content.size,`
|
|
127
127
|
|
|
128
128
|
`);return{dom:a,text:u,slice:e}}function Ta(n,e,t,i,o){let r=o.parent.type.spec.code,s,l;if(!t&&!e)return null;let a=e&&(i||r||!t);if(a){if(n.someProp("transformPastedText",u=>{e=u(e,r||i,n)}),r)return e?new C(w.from(n.state.schema.text(e.replace(/\r\n?/g,`
|
|
129
|
-
`))),0,0):C.empty;let h=n.someProp("clipboardTextParser",u=>u(e,o,i,n));if(h)l=h;else{let u=o.marks(),{schema:f}=n.state,p=wt.fromSchema(f);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=s.appendChild(document.createElement("p"));m&&g.appendChild(p.serializeNode(f.text(m,u)))})}}else n.someProp("transformPastedHTML",h=>{t=h(t,n)}),s=Sf(t),wn&&vf(s);let c=s&&s.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let h=+d[3];h>0;h--){let u=s.firstChild;for(;u&&u.nodeType!=1;)u=u.nextSibling;if(!u)break;s=u}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Ht.fromSchema(n.state.schema)).parseSlice(s,{preserveWhitespace:!!(a||d),context:o,ruleFromNode(u){return u.nodeName=="BR"&&!u.nextSibling&&u.parentNode&&!yf.test(u.parentNode.nodeName)?{ignore:!0}:null}})),d)l=xf(cs(l,+d[1],+d[2]),d[4]);else if(l=C.maxOpen(bf(l.content,o),!0),l.openStart||l.openEnd){let h=0,u=0;for(let f=l.content.firstChild;h<l.openStart&&!f.type.spec.isolating;h++,f=f.firstChild);for(let f=l.content.lastChild;u<l.openEnd&&!f.type.spec.isolating;u++,f=f.lastChild);l=cs(l,h,u)}return n.someProp("transformPasted",h=>{l=h(l,n)}),l}const yf=/^(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 bf(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let o=e.node(t).contentMatchAt(e.index(t)),r,s=[];if(n.forEach(l=>{if(!s)return;let a=o.findWrapping(l.type),c;if(!a)return s=null;if(c=s.length&&r.length&&Aa(a,r,l,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=Oa(s[s.length-1],r.length));let d=Ma(l,a);s.push(d),o=o.matchType(d.type),r=a}}),s)return w.from(s)}return n}function Ma(n,e,t=0){for(let i=e.length-1;i>=t;i--)n=e[i].create(null,w.from(n));return n}function Aa(n,e,t,i,o){if(o<n.length&&o<e.length&&n[o]==e[o]){let r=Aa(n,e,t,i.lastChild,o+1);if(r)return i.copy(i.content.replaceChild(i.childCount-1,r));if(i.contentMatchAt(i.childCount).matchType(o==n.length-1?t.type:n[o+1]))return i.copy(i.content.append(w.from(Ma(t,n,o+1))))}}function Oa(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,Oa(n.lastChild,e-1)),i=n.contentMatchAt(n.childCount).fillBefore(w.empty,!0);return n.copy(t.append(i))}function yo(n,e,t,i,o,r){let s=e<0?n.firstChild:n.lastChild,l=s.content;return n.childCount>1&&(r=0),o<i-1&&(l=yo(l,e,t,i,o+1,r)),o>=t&&(l=e<0?s.contentMatchAt(0).fillBefore(l,r<=o).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(w.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,s.copy(l))}function cs(n,e,t){return e<n.openStart&&(n=new C(yo(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new C(yo(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const Ea={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 ds=null;function Na(){return ds||(ds=document.implementation.createHTMLDocument("title"))}let _i=null;function wf(n){let e=window.trustedTypes;return e?(_i||(_i=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),_i.createHTML(n)):n}function Sf(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Na().createElement("div"),i=/<([a-z][^>\s]+)/i.exec(n),o;if((o=i&&Ea[i[1].toLowerCase()])&&(n=o.map(r=>"<"+r+">").join("")+n+o.map(r=>"</"+r+">").reverse().join("")),t.innerHTML=wf(n),o)for(let r=0;r<o.length;r++)t=t.querySelector(o[r])||t;return t}function vf(n){let e=n.querySelectorAll(Z?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let i=e[t];i.childNodes.length==1&&i.textContent==" "&&i.parentNode&&i.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),i)}}function xf(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,i;try{i=JSON.parse(e)}catch{return n}let{content:o,openStart:r,openEnd:s}=n;for(let l=i.length-2;l>=0;l-=2){let a=t.nodes[i[l]];if(!a||a.hasRequiredAttrs())break;o=w.from(a.create(i[l+1],o)),r++,s++}return new C(o,r,s)}const ne={},ie={},Cf={touchstart:!0,touchmove:!0};class kf{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastAndroidDelete=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 Tf(n){for(let e in ne){let t=ne[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=i=>{Af(n,i)&&!Bo(n,i)&&(n.editable||!(i.type in ie))&&t(n,i)},Cf[e]?{passive:!0}:void 0)}te&&n.dom.addEventListener("input",()=>null),bo(n)}function je(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function Mf(n){n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function bo(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=i=>Bo(n,i))})}function Bo(n,e){return n.someProp("handleDOMEvents",t=>{let i=t[e.type];return i?i(n,e)||e.defaultPrevented:!1})}function Af(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function Of(n,e){!Bo(n,e)&&ne[e.type]&&(n.editable||!(e.type in ie))&&ne[e.type](n,e)}ie.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!Ia(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(ge&&Z&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),_t&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let i=Date.now();n.input.lastIOSEnter=i,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==i&&(n.someProp("handleKeyDown",o=>o(n,ot(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",i=>i(n,t))||gf(n,t)?t.preventDefault():je(n,"key")};ie.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};ie.keypress=(n,e)=>{let t=e;if(Ia(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||ue&&t.metaKey)return;if(n.someProp("handleKeyPress",o=>o(n,t))){t.preventDefault();return}let i=n.state.selection;if(!(i instanceof N)||!i.$from.sameParent(i.$to)){let o=String.fromCharCode(t.charCode);!/[\r\n]/.test(o)&&!n.someProp("handleTextInput",r=>r(n,i.$from.pos,i.$to.pos,o))&&n.dispatch(n.state.tr.insertText(o).scrollIntoView()),t.preventDefault()}};function yi(n){return{left:n.clientX,top:n.clientY}}function Ef(n,e){let t=e.x-n.clientX,i=e.y-n.clientY;return t*t+i*i<100}function Ho(n,e,t,i,o){if(i==-1)return!1;let r=n.state.doc.resolve(i);for(let s=r.depth+1;s>0;s--)if(n.someProp(e,l=>s>r.depth?l(n,t,r.nodeAfter,r.before(s),o,!0):l(n,t,r.node(s),r.before(s),o,!1)))return!0;return!1}function zt(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let i=n.state.tr.setSelection(e);i.setMeta("pointer",!0),n.dispatch(i)}function Nf(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),i=t.nodeAfter;return i&&i.isAtom&&O.isSelectable(i)?(zt(n,new O(t)),!0):!1}function Df(n,e){if(e==-1)return!1;let t=n.state.selection,i,o;t instanceof O&&(i=t.node);let r=n.state.doc.resolve(e);for(let s=r.depth+1;s>0;s--){let l=s>r.depth?r.nodeAfter:r.node(s);if(O.isSelectable(l)){i&&t.$from.depth>0&&s>=t.$from.depth&&r.before(t.$from.depth+1)==t.$from.pos?o=r.before(t.$from.depth):o=r.before(s);break}}return o!=null?(zt(n,O.create(n.state.doc,o)),!0):!1}function If(n,e,t,i,o){return Ho(n,"handleClickOn",e,t,i)||n.someProp("handleClick",r=>r(n,e,i))||(o?Df(n,t):Nf(n,t))}function Pf(n,e,t,i){return Ho(n,"handleDoubleClickOn",e,t,i)||n.someProp("handleDoubleClick",o=>o(n,e,i))}function Rf(n,e,t,i){return Ho(n,"handleTripleClickOn",e,t,i)||n.someProp("handleTripleClick",o=>o(n,e,i))||Vf(n,t,i)}function Vf(n,e,t){if(t.button!=0)return!1;let i=n.state.doc;if(e==-1)return i.inlineContent?(zt(n,N.create(i,0,i.content.size)),!0):!1;let o=i.resolve(e);for(let r=o.depth+1;r>0;r--){let s=r>o.depth?o.nodeAfter:o.node(r),l=o.before(r);if(s.inlineContent)zt(n,N.create(i,l+1,l+1+s.content.size));else if(O.isSelectable(s))zt(n,O.create(i,l));else continue;return!0}}function Fo(n){return ri(n)}const Da=ue?"metaKey":"ctrlKey";ne.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let i=Fo(n),o=Date.now(),r="singleClick";o-n.input.lastClick.time<500&&Ef(t,n.input.lastClick)&&!t[Da]&&(n.input.lastClick.type=="singleClick"?r="doubleClick":n.input.lastClick.type=="doubleClick"&&(r="tripleClick")),n.input.lastClick={time:o,x:t.clientX,y:t.clientY,type:r};let s=n.posAtCoords(yi(t));s&&(r=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new Lf(n,s,t,!!i)):(r=="doubleClick"?Pf:Rf)(n,s.pos,s.inside,t)?t.preventDefault():je(n,"pointer"))};class Lf{constructor(e,t,i,o){this.view=e,this.pos=t,this.event=i,this.flushed=o,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!i[Da],this.allowDefault=i.shiftKey;let r,s;if(t.inside>-1)r=e.state.doc.nodeAt(t.inside),s=t.inside;else{let d=e.state.doc.resolve(t.pos);r=d.parent,s=d.depth?d.before():0}const l=o?null:i.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.dom.nodeType==1?a.dom:null;let{selection:c}=e.state;(i.button==0&&r.type.spec.draggable&&r.type.spec.selectable!==!1||c instanceof O&&c.from<=s&&c.to>s)&&(this.mightDrag={node:r,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&we&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),je(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(()=>Re(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(yi(e))),this.updateAllowDefault(e),this.allowDefault||!t?je(this.view,"pointer"):If(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||te&&this.mightDrag&&!this.mightDrag.node.isAtom||Z&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(zt(this.view,E.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):je(this.view,"pointer")}move(e){this.updateAllowDefault(e),je(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)}}ne.touchstart=n=>{n.input.lastTouch=Date.now(),Fo(n),je(n,"pointer")};ne.touchmove=n=>{n.input.lastTouch=Date.now(),je(n,"pointer")};ne.contextmenu=n=>Fo(n);function Ia(n,e){return n.composing?!0:te&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const zf=ge?5e3:-1;ie.compositionstart=ie.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof N&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(i=>i.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),ri(n,!0),n.markCursor=null;else if(ri(n,!e.selection.empty),we&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let i=n.domSelectionRange();for(let o=i.focusNode,r=i.focusOffset;o&&o.nodeType==1&&r!=0;){let s=r<0?o.lastChild:o.childNodes[r-1];if(!s)break;if(s.nodeType==3){let l=n.domSelection();l&&l.collapse(s,s.nodeValue.length);break}else o=s,r=-1}}n.input.composing=!0}Pa(n,zf)};ie.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,Pa(n,20))};function Pa(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>ri(n),e))}function Ra(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Hf());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function Bf(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=Eu(e.focusNode,e.focusOffset),i=Nu(e.focusNode,e.focusOffset);if(t&&i&&t!=i){let o=i.pmViewDesc,r=n.domObserver.lastChangedTextNode;if(t==r||i==r)return r;if(!o||!o.isText(i.nodeValue))return i;if(n.input.compositionNode==i){let s=t.pmViewDesc;if(!(!s||!s.isText(t.nodeValue)))return i}}return t||i}function Hf(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function ri(n,e=!1){if(!(ge&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Ra(n),e||n.docView&&n.docView.dirty){let t=Lo(n);return t&&!t.eq(n.state.selection)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!n.state.selection.empty?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function Ff(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let i=getSelection(),o=document.createRange();o.selectNodeContents(e),n.dom.blur(),i.removeAllRanges(),i.addRange(o),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const fn=re&&Je<15||_t&&Vu<604;ne.copy=ie.cut=(n,e)=>{let t=e,i=n.state.selection,o=t.type=="cut";if(i.empty)return;let r=fn?null:t.clipboardData,s=i.content(),{dom:l,text:a}=ka(n,s);r?(t.preventDefault(),r.clearData(),r.setData("text/html",l.innerHTML),r.setData("text/plain",a)):Ff(n,l),o&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function $f(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function Wf(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,i=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(i.contentEditable="true"),i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus();let o=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),i.parentNode&&i.parentNode.removeChild(i),t?pn(n,i.value,null,o,e):pn(n,i.textContent,i.innerHTML,o,e)},50)}function pn(n,e,t,i,o){let r=Ta(n,e,t,i,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,o,r||C.empty)))return!0;if(!r)return!1;let s=$f(r),l=s?n.state.tr.replaceSelectionWith(s,i):n.state.tr.replaceSelection(r);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Va(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}ie.paste=(n,e)=>{let t=e;if(n.composing&&!ge)return;let i=fn?null:t.clipboardData,o=n.input.shiftKey&&n.input.lastKeyCode!=45;i&&pn(n,Va(i),i.getData("text/html"),o,t)?t.preventDefault():Wf(n,t)};class La{constructor(e,t,i){this.slice=e,this.move=t,this.node=i}}const za=ue?"altKey":"ctrlKey";ne.dragstart=(n,e)=>{let t=e,i=n.input.mouseDown;if(i&&i.done(),!t.dataTransfer)return;let o=n.state.selection,r=o.empty?null:n.posAtCoords(yi(t)),s;if(!(r&&r.pos>=o.from&&r.pos<=(o instanceof O?o.to-1:o.to))){if(i&&i.mightDrag)s=O.create(n.state.doc,i.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let h=n.docView.nearestDesc(t.target,!0);h&&h.node.type.spec.draggable&&h!=n.docView&&(s=O.create(n.state.doc,h.posBefore))}}let l=(s||n.state.selection).content(),{dom:a,text:c,slice:d}=ka(n,l);(!t.dataTransfer.files.length||!Z||aa>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(fn?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",fn||t.dataTransfer.setData("text/plain",c),n.dragging=new La(d,!t[za],s)};ne.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};ie.dragover=ie.dragenter=(n,e)=>e.preventDefault();ie.drop=(n,e)=>{let t=e,i=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let o=n.posAtCoords(yi(t));if(!o)return;let r=n.state.doc.resolve(o.pos),s=i&&i.slice;s?n.someProp("transformPasted",p=>{s=p(s,n)}):s=Ta(n,Va(t.dataTransfer),fn?null:t.dataTransfer.getData("text/html"),!1,r);let l=!!(i&&!t[za]);if(n.someProp("handleDrop",p=>p(n,t,s||C.empty,l))){t.preventDefault();return}if(!s)return;t.preventDefault();let a=s?Vh(n.state.doc,r.pos,s):r.pos;a==null&&(a=r.pos);let c=n.state.tr;if(l){let{node:p}=i;p?p.replace(c):c.deleteSelection()}let d=c.mapping.map(a),h=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,u=c.doc;if(h?c.replaceRangeWith(d,d,s.content.firstChild):c.replaceRange(d,d,s),c.doc.eq(u))return;let f=c.doc.resolve(d);if(h&&O.isSelectable(s.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(s.content.firstChild))c.setSelection(new O(f));else{let p=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((m,g,y,x)=>p=x),c.setSelection(zo(n,f,c.doc.resolve(p)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))};ne.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&Re(n)},20))};ne.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)};ne.beforeinput=(n,e)=>{if(Z&&ge&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:i}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=i||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",r=>r(n,ot(8,"Backspace")))))return;let{$cursor:o}=n.state.selection;o&&o.pos>0&&n.dispatch(n.state.tr.delete(o.pos-1,o.pos).scrollIntoView())},50)}};for(let n in ie)ne[n]=ie[n];function mn(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class si{constructor(e,t){this.toDOM=e,this.spec=t||ft,this.side=this.spec.side||0}map(e,t,i,o){let{pos:r,deleted:s}=e.mapResult(t.from+o,this.side<0?-1:1);return s?null:new oe(r-i,r-i,this)}valid(){return!0}eq(e){return this==e||e instanceof si&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&mn(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Ue{constructor(e,t){this.attrs=e,this.spec=t||ft}map(e,t,i,o){let r=e.map(t.from+o,this.spec.inclusiveStart?-1:1)-i,s=e.map(t.to+o,this.spec.inclusiveEnd?1:-1)-i;return r>=s?null:new oe(r,s,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Ue&&mn(this.attrs,e.attrs)&&mn(this.spec,e.spec)}static is(e){return e.type instanceof Ue}destroy(){}}class $o{constructor(e,t){this.attrs=e,this.spec=t||ft}map(e,t,i,o){let r=e.mapResult(t.from+o,1);if(r.deleted)return null;let s=e.mapResult(t.to+o,-1);return s.deleted||s.pos<=r.pos?null:new oe(r.pos-i,s.pos-i,this)}valid(e,t){let{index:i,offset:o}=e.content.findIndex(t.from),r;return o==t.from&&!(r=e.child(i)).isText&&o+r.nodeSize==t.to}eq(e){return this==e||e instanceof $o&&mn(this.attrs,e.attrs)&&mn(this.spec,e.spec)}destroy(){}}class oe{constructor(e,t,i){this.from=e,this.to=t,this.type=i}copy(e,t){return new oe(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,i){return this.type.map(e,this,t,i)}static widget(e,t,i){return new oe(e,e,new si(t,i))}static inline(e,t,i,o){return new oe(e,t,new Ue(i,o))}static node(e,t,i,o){return new oe(e,t,new $o(i,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof Ue}get widget(){return this.type instanceof si}}const Ot=[],ft={};class z{constructor(e,t){this.local=e.length?e:Ot,this.children=t.length?t:Ot}static create(e,t){return t.length?li(t,e,0,ft):G}find(e,t,i){let o=[];return this.findInner(e??0,t??1e9,o,0,i),o}findInner(e,t,i,o,r){for(let s=0;s<this.local.length;s++){let l=this.local[s];l.from<=t&&l.to>=e&&(!r||r(l.spec))&&i.push(l.copy(l.from+o,l.to+o))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<t&&this.children[s+1]>e){let l=this.children[s]+1;this.children[s+2].findInner(e-l,t-l,i,o+l,r)}}map(e,t,i){return this==G||e.maps.length==0?this:this.mapInner(e,t,0,0,i||ft)}mapInner(e,t,i,o,r){let s;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,i,o);a&&a.type.valid(t,a)?(s||(s=[])).push(a):r.onRemove&&r.onRemove(this.local[l].spec)}return this.children.length?_f(this.children,s||[],e,t,i,o,r):s?new z(s.sort(pt),Ot):G}add(e,t){return t.length?this==G?z.create(e,t):this.addInner(e,t,0):this}addInner(e,t,i){let o,r=0;e.forEach((l,a)=>{let c=a+i,d;if(d=Ha(t,l,c)){for(o||(o=this.children.slice());r<o.length&&o[r]<a;)r+=3;o[r]==a?o[r+2]=o[r+2].addInner(l,d,c+1):o.splice(r,0,a,a+l.nodeSize,li(d,l,c+1,ft)),r+=3}});let s=Ba(r?Fa(t):t,-i);for(let l=0;l<s.length;l++)s[l].type.valid(e,s[l])||s.splice(l--,1);return new z(s.length?this.local.concat(s).sort(pt):this.local,o||this.children)}remove(e){return e.length==0||this==G?this:this.removeInner(e,0)}removeInner(e,t){let i=this.children,o=this.local;for(let r=0;r<i.length;r+=3){let s,l=i[r]+t,a=i[r+1]+t;for(let d=0,h;d<e.length;d++)(h=e[d])&&h.from>l&&h.to<a&&(e[d]=null,(s||(s=[])).push(h));if(!s)continue;i==this.children&&(i=this.children.slice());let c=i[r+2].removeInner(s,l+1);c!=G?i[r+2]=c:(i.splice(r,3),r-=3)}if(o.length){for(let r=0,s;r<e.length;r++)if(s=e[r])for(let l=0;l<o.length;l++)o[l].eq(s,t)&&(o==this.local&&(o=this.local.slice()),o.splice(l--,1))}return i==this.children&&o==this.local?this:o.length||i.length?new z(o,i):G}forChild(e,t){if(this==G)return this;if(t.isLeaf)return z.empty;let i,o;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(i=this.children[l+2]);break}let r=e+1,s=r+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<s&&a.to>r&&a.type instanceof Ue){let c=Math.max(r,a.from)-r,d=Math.min(s,a.to)-r;c<d&&(o||(o=[])).push(a.copy(c,d))}}if(o){let l=new z(o.sort(pt),Ot);return i?new We([l,i]):l}return i||G}eq(e){if(this==e)return!0;if(!(e instanceof z)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return Wo(this.localsInner(e))}localsInner(e){if(this==G)return Ot;if(e.inlineContent||!this.local.some(Ue.is))return this.local;let t=[];for(let i=0;i<this.local.length;i++)this.local[i].type instanceof Ue||t.push(this.local[i]);return t}forEachSet(e){e(this)}}z.empty=new z([],[]);z.removeOverlap=Wo;const G=z.empty;class We{constructor(e){this.members=e}map(e,t){const i=this.members.map(o=>o.map(e,t,ft));return We.from(i)}forChild(e,t){if(t.isLeaf)return z.empty;let i=[];for(let o=0;o<this.members.length;o++){let r=this.members[o].forChild(e,t);r!=G&&(r instanceof We?i=i.concat(r.members):i.push(r))}return We.from(i)}eq(e){if(!(e instanceof We)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,i=!0;for(let o=0;o<this.members.length;o++){let r=this.members[o].localsInner(e);if(r.length)if(!t)t=r;else{i&&(t=t.slice(),i=!1);for(let s=0;s<r.length;s++)t.push(r[s])}}return t?Wo(i?t:t.sort(pt)):Ot}static from(e){switch(e.length){case 0:return G;case 1:return e[0];default:return new We(e.every(t=>t instanceof z)?e:e.reduce((t,i)=>t.concat(i instanceof z?i:i.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function _f(n,e,t,i,o,r,s){let l=n.slice();for(let c=0,d=r;c<t.maps.length;c++){let h=0;t.maps[c].forEach((u,f,p,m)=>{let g=m-p-(f-u);for(let y=0;y<l.length;y+=3){let x=l[y+1];if(x<0||u>x+d-h)continue;let b=l[y]+d-h;f>=b?l[y+1]=u<=b?-2:-1:u>=d&&g&&(l[y]+=g,l[y+1]+=g)}h+=g}),d=t.maps[c].map(d,-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 d=t.map(n[c]+r),h=d-o;if(h<0||h>=i.content.size){a=!0;continue}let u=t.map(n[c+1]+r,-1),f=u-o,{index:p,offset:m}=i.content.findIndex(h),g=i.maybeChild(p);if(g&&m==h&&m+g.nodeSize==f){let y=l[c+2].mapInner(t,g,d+1,n[c]+r+1,s);y!=G?(l[c]=h,l[c+1]=f,l[c+2]=y):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=Kf(l,n,e,t,o,r,s),d=li(c,i,0,s);e=d.local;for(let h=0;h<l.length;h+=3)l[h+1]<0&&(l.splice(h,3),h-=3);for(let h=0,u=0;h<d.children.length;h+=3){let f=d.children[h];for(;u<l.length&&l[u]<f;)u+=3;l.splice(u,0,d.children[h],d.children[h+1],d.children[h+2])}}return new z(e.sort(pt),l)}function Ba(n,e){if(!e||!n.length)return n;let t=[];for(let i=0;i<n.length;i++){let o=n[i];t.push(new oe(o.from+e,o.to+e,o.type))}return t}function Kf(n,e,t,i,o,r,s){function l(a,c){for(let d=0;d<a.local.length;d++){let h=a.local[d].map(i,o,c);h?t.push(h):s.onRemove&&s.onRemove(a.local[d].spec)}for(let d=0;d<a.children.length;d+=3)l(a.children[d+2],a.children[d]+c+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+r+1);return t}function Ha(n,e,t){if(e.isLeaf)return null;let i=t+e.nodeSize,o=null;for(let r=0,s;r<n.length;r++)(s=n[r])&&s.from>t&&s.to<i&&((o||(o=[])).push(s),n[r]=null);return o}function Fa(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function li(n,e,t,i){let o=[],r=!1;e.forEach((l,a)=>{let c=Ha(n,l,a+t);if(c){r=!0;let d=li(c,l,t+a+1,i);d!=G&&o.push(a,a+l.nodeSize,d)}});let s=Ba(r?Fa(n):n,-t).sort(pt);for(let l=0;l<s.length;l++)s[l].type.valid(e,s[l])||(i.onRemove&&i.onRemove(s[l].spec),s.splice(l--,1));return s.length||o.length?new z(s,o):G}function pt(n,e){return n.from-e.from||n.to-e.to}function Wo(n){let e=n;for(let t=0;t<e.length-1;t++){let i=e[t];if(i.from!=i.to)for(let o=t+1;o<e.length;o++){let r=e[o];if(r.from==i.from){r.to!=i.to&&(e==n&&(e=n.slice()),e[o]=r.copy(r.from,i.to),hs(e,o+1,r.copy(i.to,r.to)));continue}else{r.from<i.to&&(e==n&&(e=n.slice()),e[t]=i.copy(i.from,r.from),hs(e,o,i.copy(r.from,i.to)));break}}}return e}function hs(n,e,t){for(;e<n.length&&pt(t,n[e])>0;)e++;n.splice(e,0,t)}function Ki(n){let e=[];return n.someProp("decorations",t=>{let i=t(n.state);i&&i!=G&&e.push(i)}),n.cursorWrapper&&e.push(z.create(n.state.doc,[n.cursorWrapper.deco])),We.from(e)}const qf={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},jf=re&&Je<=11;class Jf{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 Gf{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Jf,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(i=>{for(let o=0;o<i.length;o++)this.queue.push(i[o]);re&&Je<=11&&i.some(o=>o.type=="childList"&&o.removedNodes.length||o.type=="characterData"&&o.oldValue.length>o.target.nodeValue.length)?this.flushSoon():this.flush()}),jf&&(this.onCharData=i=>{this.queue.push({target:i.target,type:"characterData",oldValue:i.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,qf)),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 t=0;t<e.length;t++)this.queue.push(e[t]);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(ns(this.view)){if(this.suppressingSelectionUpdates)return Re(this.view);if(re&&Je<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&yt(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 t=new Set,i;for(let r=e.focusNode;r;r=un(r))t.add(r);for(let r=e.anchorNode;r;r=un(r))if(t.has(r)){i=r;break}let o=i&&this.view.docView.nearestDesc(i);if(o&&o.ignoreMutation({type:"selection",target:i.nodeType==3?i.parentNode:i}))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 t=this.pendingRecords();t.length&&(this.queue=[]);let i=e.domSelectionRange(),o=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(i)&&ns(e)&&!this.ignoreSelectionChange(i),r=-1,s=-1,l=!1,a=[];if(e.editable)for(let d=0;d<t.length;d++){let h=this.registerMutation(t[d],a);h&&(r=r<0?h.from:Math.min(h.from,r),s=s<0?h.to:Math.max(h.to,s),h.typeOver&&(l=!0))}if(we&&a.length){let d=a.filter(h=>h.nodeName=="BR");if(d.length==2){let[h,u]=d;h.parentNode&&h.parentNode.parentNode==u.parentNode?u.remove():h.remove()}else{let{focusNode:h}=this.currentSelection;for(let u of d){let f=u.parentNode;f&&f.nodeName=="LI"&&(!h||Yf(e,h)!=f)&&u.remove()}}}let c=null;r<0&&o&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&mi(i)&&(c=Lo(e))&&c.eq(E.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Re(e),this.currentSelection.set(i),e.scrollToSelection()):(r>-1||o)&&(r>-1&&(e.docView.markDirty(r,s),Uf(e)),this.handleDOMChange(r,s,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(i)||Re(e),this.currentSelection.set(i))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let i=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(i==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!i||i.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let h=e.addedNodes[d];t.push(h),h.nodeType==3&&(this.lastChangedTextNode=h)}if(i.contentDOM&&i.contentDOM!=i.dom&&!i.contentDOM.contains(e.target))return{from:i.posBefore,to:i.posAfter};let o=e.previousSibling,r=e.nextSibling;if(re&&Je<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:h,nextSibling:u}=e.addedNodes[d];(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(o=h),(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(r=u)}let s=o&&o.parentNode==e.target?q(o)+1:0,l=i.localPosFromDOM(e.target,s,-1),a=r&&r.parentNode==e.target?q(r):e.target.childNodes.length,c=i.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:i.posAtStart-i.border,to:i.posAtEnd+i.border}:(this.lastChangedTextNode=e.target,{from:i.posAtStart,to:i.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let us=new WeakMap,fs=!1;function Uf(n){if(!us.has(n)&&(us.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=we,fs)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."),fs=!0}}function ps(n,e){let t=e.startContainer,i=e.startOffset,o=e.endContainer,r=e.endOffset,s=n.domAtPos(n.state.selection.anchor);return yt(s.node,s.offset,o,r)&&([t,i,o,r]=[o,r,t,i]),{anchorNode:t,anchorOffset:i,focusNode:o,focusOffset:r}}function Zf(n,e){if(e.getComposedRanges){let o=e.getComposedRanges(n.root)[0];if(o)return ps(n,o)}let t;function i(o){o.preventDefault(),o.stopImmediatePropagation(),t=o.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",i,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",i,!0),t?ps(n,t):null}function Yf(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let i=n.docView.nearestDesc(t,!0);if(i&&i.node.isBlock)return t}return null}function Xf(n,e,t){let{node:i,fromOffset:o,toOffset:r,from:s,to:l}=n.docView.parseRange(e,t),a=n.domSelectionRange(),c,d=a.anchorNode;if(d&&n.dom.contains(d.nodeType==1?d:d.parentNode)&&(c=[{node:d,offset:a.anchorOffset}],mi(a)||c.push({node:a.focusNode,offset:a.focusOffset})),Z&&n.input.lastKeyCode===8)for(let g=r;g>o;g--){let y=i.childNodes[g-1],x=y.pmViewDesc;if(y.nodeName=="BR"&&!x){r=g;break}if(!x||x.size)break}let h=n.state.doc,u=n.someProp("domParser")||Ht.fromSchema(n.state.schema),f=h.resolve(s),p=null,m=u.parse(i,{topNode:f.parent,topMatch:f.parent.contentMatchAt(f.index()),topOpen:!0,from:o,to:r,preserveWhitespace:f.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:Qf,context:f});if(c&&c[0].pos!=null){let g=c[0].pos,y=c[1]&&c[1].pos;y==null&&(y=g),p={anchor:g+s,head:y+s}}return{doc:m,sel:p,from:s,to:l}}function Qf(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(te&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||te&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}const ep=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function tp(n,e,t,i,o){let r=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let M=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,R=Lo(n,M);if(R&&!n.state.selection.eq(R)){if(Z&&ge&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",V=>V(n,ot(13,"Enter"))))return;let P=n.state.tr.setSelection(R);M=="pointer"?P.setMeta("pointer",!0):M=="key"&&P.scrollIntoView(),r&&P.setMeta("composition",r),n.dispatch(P)}return}let s=n.state.doc.resolve(e),l=s.sharedDepth(t);e=s.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,c=Xf(n,e,t),d=n.state.doc,h=d.slice(c.from,c.to),u,f;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(u=n.state.selection.to,f="end"):(u=n.state.selection.from,f="start"),n.input.lastKeyCode=null;let p=op(h.content,c.doc.content,c.from,u,f);if(p&&n.input.domChangeCount++,(_t&&n.input.lastIOSEnter>Date.now()-225||ge)&&o.some(M=>M.nodeType==1&&!ep.test(M.nodeName))&&(!p||p.endA>=p.endB)&&n.someProp("handleKeyDown",M=>M(n,ot(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!p)if(i&&a instanceof N&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.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=ms(n,n.state.doc,c.sel);if(M&&!M.eq(n.state.selection)){let R=n.state.tr.setSelection(M);r&&R.setMeta("composition",r),n.dispatch(R)}}return}n.state.selection.from<n.state.selection.to&&p.start==p.endB&&n.state.selection instanceof N&&(p.start>n.state.selection.from&&p.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?p.start=n.state.selection.from:p.endA<n.state.selection.to&&p.endA>=n.state.selection.to-2&&n.state.selection.to<=c.to&&(p.endB+=n.state.selection.to-p.endA,p.endA=n.state.selection.to)),re&&Je<=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),y=d.resolve(p.start),x=m.sameParent(g)&&m.parent.inlineContent&&y.end()>=p.endA,b;if((_t&&n.input.lastIOSEnter>Date.now()-225&&(!x||o.some(M=>M.nodeName=="DIV"||M.nodeName=="P"))||!x&&m.pos<c.doc.content.size&&!m.sameParent(g)&&(b=E.findFrom(c.doc.resolve(m.pos+1),1,!0))&&b.head==g.pos)&&n.someProp("handleKeyDown",M=>M(n,ot(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>p.start&&ip(d,p.start,p.endA,m,g)&&n.someProp("handleKeyDown",M=>M(n,ot(8,"Backspace")))){ge&&Z&&n.domObserver.suppressSelectionUpdates();return}Z&&ge&&p.endB==p.start&&(n.input.lastAndroidDelete=Date.now()),ge&&!x&&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(()=>{n.someProp("handleKeyDown",function(M){return M(n,ot(13,"Enter"))})},20));let S=p.start,v=p.endA,k,A,L;if(x){if(m.pos==g.pos)re&&Je<=11&&m.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>Re(n),20)),k=n.state.tr.delete(S,v),A=d.resolve(p.start).marksAcross(d.resolve(p.endA));else if(p.endA==p.endB&&(L=np(m.parent.content.cut(m.parentOffset,g.parentOffset),y.parent.content.cut(y.parentOffset,p.endA-y.start()))))k=n.state.tr,L.type=="add"?k.addMark(S,v,L.mark):k.removeMark(S,v,L.mark);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);if(n.someProp("handleTextInput",R=>R(n,S,v,M)))return;k=n.state.tr.insertText(M,S,v)}}if(k||(k=n.state.tr.replace(S,v,c.doc.slice(p.start-c.from,p.endB-c.from))),c.sel){let M=ms(n,k.doc,c.sel);M&&!(Z&&ge&&n.composing&&M.empty&&(p.start!=p.endB||n.input.lastAndroidDelete<Date.now()-100)&&(M.head==S||M.head==k.mapping.map(v)-1)||re&&M.empty&&M.head==S)&&k.setSelection(M)}A&&k.ensureMarks(A),r&&k.setMeta("composition",r),n.dispatch(k.scrollIntoView())}function ms(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:zo(n,e.resolve(t.anchor),e.resolve(t.head))}function np(n,e){let t=n.firstChild.marks,i=e.firstChild.marks,o=t,r=i,s,l,a;for(let d=0;d<i.length;d++)o=i[d].removeFromSet(o);for(let d=0;d<t.length;d++)r=t[d].removeFromSet(r);if(o.length==1&&r.length==0)l=o[0],s="add",a=d=>d.mark(l.addToSet(d.marks));else if(o.length==0&&r.length==1)l=r[0],s="remove",a=d=>d.mark(l.removeFromSet(d.marks));else return null;let c=[];for(let d=0;d<e.childCount;d++)c.push(a(e.child(d)));if(w.from(c).eq(n))return{mark:l,type:s}}function ip(n,e,t,i,o){if(t-e<=o.pos-i.pos||qi(i,!0,!1)<o.pos)return!1;let r=n.resolve(e);if(!i.parent.isTextblock){let l=r.nodeAfter;return l!=null&&t==e+l.nodeSize}if(r.parentOffset<r.parent.content.size||!r.parent.isTextblock)return!1;let s=n.resolve(qi(r,!0,!0));return!s.parent.isTextblock||s.pos>t||qi(s,!0,!1)<t?!1:i.parent.content.cut(i.parentOffset).eq(s.parent.content)}function qi(n,e,t){let i=n.depth,o=e?n.end():n.pos;for(;i>0&&(e||n.indexAfter(i)==n.node(i).childCount);)i--,o++,e=!1;if(t){let r=n.node(i).maybeChild(n.indexAfter(i));for(;r&&!r.isLeaf;)r=r.firstChild,o++}return o}function op(n,e,t,i,o){let r=n.findDiffStart(e,t);if(r==null)return null;let{a:s,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(o=="end"){let a=Math.max(0,r-Math.min(s,l));i-=s+a-r}if(s<r&&n.size<e.size){let a=i<=r&&i>=s?r-i:0;r-=a,r&&r<e.size&&gs(e.textBetween(r-1,r+1))&&(r+=a?1:-1),l=r+(l-s),s=r}else if(l<r){let a=i<=r&&i>=l?r-i:0;r-=a,r&&r<n.size&&gs(n.textBetween(r-1,r+1))&&(r+=a?1:-1),s=r+(s-l),l=r}return{start:r,endA:s,endB:l}}function gs(n){if(n.length!=2)return!1;let e=n.charCodeAt(0),t=n.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}class rp{constructor(e,t){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 kf,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(vs),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=ws(this),bs(this),this.nodeViews=Ss(this),this.docView=Zr(this.state.doc,ys(this),Ki(this),this.dom,this),this.domObserver=new Gf(this,(i,o,r,s)=>tp(this,i,o,r,s)),this.domObserver.start(),Tf(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 t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&bo(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(vs),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let i in this._props)t[i]=this._props[i];t.state=this.state;for(let i in e)t[i]=e[i];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var i;let o=this.state,r=!1,s=!1;e.storedMarks&&this.composing&&(Ra(this),s=!0),this.state=e;let l=o.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let f=Ss(this);lp(f,this.nodeViews)&&(this.nodeViews=f,r=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&bo(this),this.editable=ws(this),bs(this);let a=Ki(this),c=ys(this),d=o.plugins!=e.plugins&&!o.doc.eq(e.doc)?"reset":e.scrollToSelection>o.scrollToSelection?"to selection":"preserve",h=r||!this.docView.matchesNode(e.doc,c,a);(h||!e.selection.eq(o.selection))&&(s=!0);let u=d=="preserve"&&s&&this.dom.style.overflowAnchor==null&&Bu(this);if(s){this.domObserver.stop();let f=h&&(re||Z)&&!this.composing&&!o.selection.empty&&!e.selection.empty&&sp(o.selection,e.selection);if(h){let p=Z?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Bf(this)),(r||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Zr(e.doc,c,a,this.dom,this)),p&&!this.trackWrites&&(f=!0)}f||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&cf(this))?Re(this,f):(va(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(o),!((i=this.dragging)===null||i===void 0)&&i.node&&!o.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,o),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():u&&Hu(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof O){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Kr(this,t.getBoundingClientRect(),e)}else Kr(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 t=0;t<this.directPlugins.length;t++){let i=this.directPlugins[t];i.spec.view&&this.pluginViews.push(i.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let i=this.state.plugins[t];i.spec.view&&this.pluginViews.push(i.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let i=this.pluginViews[t];i.update&&i.update(this,e)}}updateDraggedNode(e,t){let i=e.node,o=-1;if(this.state.doc.nodeAt(i.from)==i.node)o=i.from;else{let r=i.from+(this.state.doc.content.size-t.doc.content.size);(r>0&&this.state.doc.nodeAt(r))==i.node&&(o=r)}this.dragging=new La(e.slice,e.move,o<0?void 0:O.create(this.state.doc,o))}someProp(e,t){let i=this._props&&this._props[e],o;if(i!=null&&(o=t?t(i):i))return o;for(let s=0;s<this.directPlugins.length;s++){let l=this.directPlugins[s].props[e];if(l!=null&&(o=t?t(l):l))return o}let r=this.state.plugins;if(r)for(let s=0;s<r.length;s++){let l=r[s].props[e];if(l!=null&&(o=t?t(l):l))return o}}hasFocus(){if(re){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&&Fu(this.dom),Re(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return qu(this,e)}coordsAtPos(e,t=1){return fa(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,i=-1){let o=this.docView.posFromDOM(e,t,i);if(o==null)throw new RangeError("DOM position not inside the editor");return o}endOfTextblock(e,t){return Zu(this,t||this.state,e)}pasteHTML(e,t){return pn(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return pn(this,e,null,!0,t||new ClipboardEvent("paste"))}destroy(){this.docView&&(Mf(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Ki(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Au())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Of(this,e)}dispatch(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){let e=this.domSelection();return e?te&&this.root.nodeType===11&&Iu(this.dom.ownerDocument)==this.dom&&Zf(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function ys(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let i in t)i=="class"?e.class+=" "+t[i]:i=="style"?e.style=(e.style?e.style+";":"")+t[i]:!e[i]&&i!="contenteditable"&&i!="nodeName"&&(e[i]=String(t[i]))}),e.translate||(e.translate="no"),[oe.node(0,n.state.doc.content.size,e)]}function bs(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:oe.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function ws(n){return!n.someProp("editable",e=>e(n.state)===!1)}function sp(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function Ss(n){let e=Object.create(null);function t(i){for(let o in i)Object.prototype.hasOwnProperty.call(e,o)||(e[o]=i[o])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function lp(n,e){let t=0,i=0;for(let o in n){if(n[o]!=e[o])return!0;t++}for(let o in e)i++;return t!=i}function vs(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var wo,So;if(typeof WeakMap<"u"){let n=new WeakMap;wo=e=>n.get(e),So=(e,t)=>(n.set(e,t),t)}else{const n=[];let t=0;wo=i=>{for(let o=0;o<n.length;o+=2)if(n[o]==i)return n[o+1]},So=(i,o)=>(t==10&&(t=0),n[t++]=i,n[t++]=o)}var H=class{constructor(n,e,t,i){this.width=n,this.height=e,this.map=t,this.problems=i}findCell(n){for(let e=0;e<this.map.length;e++){const t=this.map[e];if(t!=n)continue;const i=e%this.width,o=e/this.width|0;let r=i+1,s=o+1;for(let l=1;r<this.width&&this.map[e+l]==t;l++)r++;for(let l=1;s<this.height&&this.map[e+this.width*l]==t;l++)s++;return{left:i,top:o,right:r,bottom:s}}throw new RangeError(`No cell with offset ${n} found`)}colCount(n){for(let e=0;e<this.map.length;e++)if(this.map[e]==n)return e%this.width;throw new RangeError(`No cell with offset ${n} found`)}nextCell(n,e,t){const{left:i,right:o,top:r,bottom:s}=this.findCell(n);return e=="horiz"?(t<0?i==0:o==this.width)?null:this.map[r*this.width+(t<0?i-1:o)]:(t<0?r==0:s==this.height)?null:this.map[i+this.width*(t<0?r-1:s)]}rectBetween(n,e){const{left:t,right:i,top:o,bottom:r}=this.findCell(n),{left:s,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(t,s),top:Math.min(o,a),right:Math.max(i,l),bottom:Math.max(r,c)}}cellsInRect(n){const e=[],t={};for(let i=n.top;i<n.bottom;i++)for(let o=n.left;o<n.right;o++){const r=i*this.width+o,s=this.map[r];t[s]||(t[s]=!0,!(o==n.left&&o&&this.map[r-1]==s||i==n.top&&i&&this.map[r-this.width]==s)&&e.push(s))}return e}positionAt(n,e,t){for(let i=0,o=0;;i++){const r=o+t.child(i).nodeSize;if(i==n){let s=e+n*this.width;const l=(n+1)*this.width;for(;s<l&&this.map[s]<o;)s++;return s==l?r-1:this.map[s]}o=r}}static get(n){return wo(n)||So(n,ap(n))}};function ap(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);const e=cp(n),t=n.childCount,i=[];let o=0,r=null;const s=[];for(let c=0,d=e*t;c<d;c++)i[c]=0;for(let c=0,d=0;c<t;c++){const h=n.child(c);d++;for(let p=0;;p++){for(;o<i.length&&i[o]!=0;)o++;if(p==h.childCount)break;const m=h.child(p),{colspan:g,rowspan:y,colwidth:x}=m.attrs;for(let b=0;b<y;b++){if(b+c>=t){(r||(r=[])).push({type:"overlong_rowspan",pos:d,n:y-b});break}const S=o+b*e;for(let v=0;v<g;v++){i[S+v]==0?i[S+v]=d:(r||(r=[])).push({type:"collision",row:c,pos:d,n:g-v});const k=x&&x[v];if(k){const A=(S+v)%e*2,L=s[A];L==null||L!=k&&s[A+1]==1?(s[A]=k,s[A+1]=1):L==k&&s[A+1]++}}}o+=g,d+=m.nodeSize}const u=(c+1)*e;let f=0;for(;o<u;)i[o++]==0&&f++;f&&(r||(r=[])).push({type:"missing",row:c,n:f}),d++}const l=new H(e,t,i,r);let a=!1;for(let c=0;!a&&c<s.length;c+=2)s[c]!=null&&s[c+1]<t&&(a=!0);return a&&dp(l,s,n),l}function cp(n){let e=-1,t=!1;for(let i=0;i<n.childCount;i++){const o=n.child(i);let r=0;if(t)for(let s=0;s<i;s++){const l=n.child(s);for(let a=0;a<l.childCount;a++){const c=l.child(a);s+c.attrs.rowspan>i&&(r+=c.attrs.colspan)}}for(let s=0;s<o.childCount;s++){const l=o.child(s);r+=l.attrs.colspan,l.attrs.rowspan>1&&(t=!0)}e==-1?e=r:e!=r&&(e=Math.max(e,r))}return e}function dp(n,e,t){n.problems||(n.problems=[]);const i={};for(let o=0;o<n.map.length;o++){const r=n.map[o];if(i[r])continue;i[r]=!0;const s=t.nodeAt(r);if(!s)throw new RangeError(`No cell with offset ${r} found`);let l=null;const a=s.attrs;for(let c=0;c<a.colspan;c++){const d=(o+c)%n.width,h=e[d*2];h!=null&&(!a.colwidth||a.colwidth[c]!=h)&&((l||(l=hp(a)))[c]=h)}l&&n.problems.unshift({type:"colwidth mismatch",pos:r,colwidth:l})}}function hp(n){if(n.colwidth)return n.colwidth.slice();const e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function xs(n,e){if(typeof n=="string")return{};const t=n.getAttribute("data-colwidth"),i=t&&/^\d+(,\d+)*$/.test(t)?t.split(",").map(s=>Number(s)):null,o=Number(n.getAttribute("colspan")||1),r={colspan:o,rowspan:Number(n.getAttribute("rowspan")||1),colwidth:i&&i.length==o?i:null};for(const s in e){const l=e[s].getFromDOM,a=l&&l(n);a!=null&&(r[s]=a)}return r}function Cs(n,e){const t={};n.attrs.colspan!=1&&(t.colspan=n.attrs.colspan),n.attrs.rowspan!=1&&(t.rowspan=n.attrs.rowspan),n.attrs.colwidth&&(t["data-colwidth"]=n.attrs.colwidth.join(","));for(const i in e){const o=e[i].setDOMAttr;o&&o(n.attrs[i],t)}return t}function up(n){const e=n.cellAttributes||{},t={colspan:{default:1},rowspan:{default:1},colwidth:{default:null}};for(const i in e)t[i]={default:e[i].default};return{table:{content:"table_row+",tableRole:"table",isolating:!0,group:n.tableGroup,parseDOM:[{tag:"table"}],toDOM(){return["table",["tbody",0]]}},table_row:{content:"(table_cell | table_header)*",tableRole:"row",parseDOM:[{tag:"tr"}],toDOM(){return["tr",0]}},table_cell:{content:n.cellContent,attrs:t,tableRole:"cell",isolating:!0,parseDOM:[{tag:"td",getAttrs:i=>xs(i,e)}],toDOM(i){return["td",Cs(i,e),0]}},table_header:{content:n.cellContent,attrs:t,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:i=>xs(i,e)}],toDOM(i){return["th",Cs(i,e),0]}}}}function Te(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(const t in n.nodes){const i=n.nodes[t],o=i.spec.tableRole;o&&(e[o]=i)}}return e}var _e=new yn("selectingCells");function vn(n){for(let e=n.depth-1;e>0;e--)if(n.node(e).type.spec.tableRole=="row")return n.node(0).resolve(n.before(e+1));return null}function bi(n){const e=n.selection.$head;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return!0;return!1}function _o(n){const e=n.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 t=vn(e.$head)||fp(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function fp(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){const i=e.type.spec.tableRole;if(i=="cell"||i=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){const i=e.type.spec.tableRole;if(i=="cell"||i=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function vo(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function pp(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function Ko(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function $a(n,e,t){const i=n.node(-1),o=H.get(i),r=n.start(-1),s=o.nextCell(n.pos-r,e,t);return s==null?null:n.node(0).resolve(r+s)}function Kt(n,e,t=1){const i={...n,colspan:n.colspan-t};return i.colwidth&&(i.colwidth=i.colwidth.slice(),i.colwidth.splice(e,t),i.colwidth.some(o=>o>0)||(i.colwidth=null)),i}var W=class De extends E{constructor(e,t=e){const i=e.node(-1),o=H.get(i),r=e.start(-1),s=o.rectBetween(e.pos-r,t.pos-r),l=e.node(0),a=o.cellsInRect(s).filter(d=>d!=t.pos-r);a.unshift(t.pos-r);const c=a.map(d=>{const h=i.nodeAt(d);if(!h)throw RangeError(`No cell with offset ${d} found`);const u=r+d+1;return new Kl(l.resolve(u),l.resolve(u+h.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){const i=e.resolve(t.map(this.$anchorCell.pos)),o=e.resolve(t.map(this.$headCell.pos));if(vo(i)&&vo(o)&&Ko(i,o)){const r=this.$anchorCell.node(-1)!=i.node(-1);return r&&this.isRowSelection()?De.rowSelection(i,o):r&&this.isColSelection()?De.colSelection(i,o):new De(i,o)}return N.between(i,o)}content(){const e=this.$anchorCell.node(-1),t=H.get(e),i=this.$anchorCell.start(-1),o=t.rectBetween(this.$anchorCell.pos-i,this.$headCell.pos-i),r={},s=[];for(let a=o.top;a<o.bottom;a++){const c=[];for(let d=a*t.width+o.left,h=o.left;h<o.right;h++,d++){const u=t.map[d];if(r[u])continue;r[u]=!0;const f=t.findCell(u);let p=e.nodeAt(u);if(!p)throw RangeError(`No cell with offset ${u} found`);const m=o.left-f.left,g=f.right-o.right;if(m>0||g>0){let y=p.attrs;if(m>0&&(y=Kt(y,0,m)),g>0&&(y=Kt(y,y.colspan-g,g)),f.left<o.left){if(p=p.type.createAndFill(y),!p)throw RangeError(`Could not create cell with attrs ${JSON.stringify(y)}`)}else p=p.type.create(y,p.content)}if(f.top<o.top||f.bottom>o.bottom){const y={...p.attrs,rowspan:Math.min(f.bottom,o.bottom)-Math.max(f.top,o.top)};f.top<o.top?p=p.type.createAndFill(y):p=p.type.create(y,p.content)}c.push(p)}s.push(e.child(a).copy(w.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:s;return new C(w.from(l),1,1)}replace(e,t=C.empty){const i=e.steps.length,o=this.ranges;for(let s=0;s<o.length;s++){const{$from:l,$to:a}=o[s],c=e.mapping.slice(i);e.replace(c.map(l.pos),c.map(a.pos),s?C.empty:t)}const r=E.findFrom(e.doc.resolve(e.mapping.slice(i).map(this.to)),-1);r&&e.setSelection(r)}replaceWith(e,t){this.replace(e,new C(w.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),i=H.get(t),o=this.$anchorCell.start(-1),r=i.cellsInRect(i.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o));for(let s=0;s<r.length;s++)e(t.nodeAt(r[s]),o+r[s])}isColSelection(){const e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;const i=e+this.$anchorCell.nodeAfter.attrs.rowspan,o=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(i,o)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){const i=e.node(-1),o=H.get(i),r=e.start(-1),s=o.findCell(e.pos-r),l=o.findCell(t.pos-r),a=e.node(0);return s.top<=l.top?(s.top>0&&(e=a.resolve(r+o.map[s.left])),l.bottom<o.height&&(t=a.resolve(r+o.map[o.width*(o.height-1)+l.right-1]))):(l.top>0&&(t=a.resolve(r+o.map[l.left])),s.bottom<o.height&&(e=a.resolve(r+o.map[o.width*(o.height-1)+s.right-1]))),new De(e,t)}isRowSelection(){const e=this.$anchorCell.node(-1),t=H.get(e),i=this.$anchorCell.start(-1),o=t.colCount(this.$anchorCell.pos-i),r=t.colCount(this.$headCell.pos-i);if(Math.min(o,r)>0)return!1;const s=o+this.$anchorCell.nodeAfter.attrs.colspan,l=r+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,l)==t.width}eq(e){return e instanceof De&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const i=e.node(-1),o=H.get(i),r=e.start(-1),s=o.findCell(e.pos-r),l=o.findCell(t.pos-r),a=e.node(0);return s.left<=l.left?(s.left>0&&(e=a.resolve(r+o.map[s.top*o.width])),l.right<o.width&&(t=a.resolve(r+o.map[o.width*(l.top+1)-1]))):(l.left>0&&(t=a.resolve(r+o.map[l.top*o.width])),s.right<o.width&&(e=a.resolve(r+o.map[o.width*(s.top+1)-1]))),new De(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new De(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,i=t){return new De(e.resolve(t),e.resolve(i))}getBookmark(){return new mp(this.$anchorCell.pos,this.$headCell.pos)}};W.prototype.visible=!1;E.jsonID("cell",W);var mp=class Wa{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Wa(e.map(this.anchor),e.map(this.head))}resolve(e){const t=e.resolve(this.anchor),i=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&i.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&i.index()<i.parent.childCount&&Ko(t,i)?new W(t,i):E.near(i,1)}};function gp(n){if(!(n.selection instanceof W))return null;const e=[];return n.selection.forEachCell((t,i)=>{e.push(oe.node(i,i+t.nodeSize,{class:"selectedCell"}))}),z.create(n.doc,e)}function yp({$from:n,$to:e}){if(n.pos==e.pos||n.pos<e.pos-6)return!1;let t=n.pos,i=e.pos,o=n.depth;for(;o>=0&&!(n.after(o+1)<n.end(o));o--,t++);for(let r=e.depth;r>=0&&!(e.before(r+1)>e.start(r));r--,i--);return t==i&&/row|table/.test(n.node(o).type.spec.tableRole)}function bp({$from:n,$to:e}){let t,i;for(let o=n.depth;o>0;o--){const r=n.node(o);if(r.type.spec.tableRole==="cell"||r.type.spec.tableRole==="header_cell"){t=r;break}}for(let o=e.depth;o>0;o--){const r=e.node(o);if(r.type.spec.tableRole==="cell"||r.type.spec.tableRole==="header_cell"){i=r;break}}return t!==i&&e.parentOffset===0}function wp(n,e,t){const i=(e||n).selection,o=(e||n).doc;let r,s;if(i instanceof O&&(s=i.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")r=W.create(o,i.from);else if(s=="row"){const l=o.resolve(i.from+1);r=W.rowSelection(l,l)}else if(!t){const l=H.get(i.node),a=i.from+1,c=a+l.map[l.width*l.height-1];r=W.create(o,a+1,c)}}else i instanceof N&&yp(i)?r=N.create(o,i.from):i instanceof N&&bp(i)&&(r=N.create(o,i.$from.start(),i.$from.end()));return r&&(e||(e=n.tr)).setSelection(r),e}var Sp=new yn("fix-tables");function _a(n,e,t,i){const o=n.childCount,r=e.childCount;e:for(let s=0,l=0;s<r;s++){const a=e.child(s);for(let c=l,d=Math.min(o,s+3);c<d;c++)if(n.child(c)==a){l=c+1,t+=a.nodeSize;continue e}i(a,t),l<o&&n.child(l).sameMarkup(a)?_a(n.child(l),a,t+1,i):a.nodesBetween(0,a.content.size,i,t+1),t+=a.nodeSize}}function vp(n,e){let t;const i=(o,r)=>{o.type.spec.tableRole=="table"&&(t=xp(n,o,r,t))};return e?e.doc!=n.doc&&_a(e.doc,n.doc,0,i):n.doc.descendants(i),t}function xp(n,e,t,i){const o=H.get(e);if(!o.problems)return i;i||(i=n.tr);const r=[];for(let a=0;a<o.height;a++)r.push(0);for(let a=0;a<o.problems.length;a++){const c=o.problems[a];if(c.type=="collision"){const d=e.nodeAt(c.pos);if(!d)continue;const h=d.attrs;for(let u=0;u<h.rowspan;u++)r[c.row+u]+=c.n;i.setNodeMarkup(i.mapping.map(t+1+c.pos),null,Kt(h,h.colspan-c.n,c.n))}else if(c.type=="missing")r[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const d=e.nodeAt(c.pos);if(!d)continue;i.setNodeMarkup(i.mapping.map(t+1+c.pos),null,{...d.attrs,rowspan:d.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const d=e.nodeAt(c.pos);if(!d)continue;i.setNodeMarkup(i.mapping.map(t+1+c.pos),null,{...d.attrs,colwidth:c.colwidth})}}let s,l;for(let a=0;a<r.length;a++)r[a]&&(s==null&&(s=a),l=a);for(let a=0,c=t+1;a<o.height;a++){const d=e.child(a),h=c+d.nodeSize,u=r[a];if(u>0){let f="cell";d.firstChild&&(f=d.firstChild.type.spec.tableRole);const p=[];for(let g=0;g<u;g++){const y=Te(n.schema)[f].createAndFill();y&&p.push(y)}const m=(a==0||s==a-1)&&l==a?c+1:h-1;i.insert(i.mapping.map(m),p)}c=h}return i.setMeta(Sp,{fixTables:!0})}function Ka(n){const e=n.selection,t=_o(n),i=t.node(-1),o=t.start(-1),r=H.get(i);return{...e instanceof W?r.rectBetween(e.$anchorCell.pos-o,e.$headCell.pos-o):r.findCell(t.pos-o),tableStart:o,map:r,table:i}}function Cp(n){return function(e,t){if(!bi(e))return!1;if(t){const i=Te(e.schema),o=Ka(e),r=e.tr,s=o.map.cellsInRect(n=="column"?{left:o.left,top:0,right:o.right,bottom:o.map.height}:n=="row"?{left:0,top:o.top,right:o.map.width,bottom:o.bottom}:o),l=s.map(a=>o.table.nodeAt(a));for(let a=0;a<s.length;a++)l[a].type==i.header_cell&&r.setNodeMarkup(o.tableStart+s[a],i.cell,l[a].attrs);if(r.steps.length==0)for(let a=0;a<s.length;a++)r.setNodeMarkup(o.tableStart+s[a],i.header_cell,l[a].attrs);t(r)}return!0}}function ks(n,e,t){const i=e.map.cellsInRect({left:0,top:0,right:n=="row"?e.map.width:1,bottom:n=="column"?e.map.height:1});for(let o=0;o<i.length;o++){const r=e.table.nodeAt(i[o]);if(r&&r.type!==t.header_cell)return!1}return!0}function qo(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?Cp(n):function(t,i){if(!bi(t))return!1;if(i){const o=Te(t.schema),r=Ka(t),s=t.tr,l=ks("row",r,o),a=ks("column",r,o),d=(n==="column"?l:n==="row"?a:!1)?1:0,h=n=="column"?{left:0,top:d,right:1,bottom:r.map.height}:n=="row"?{left:d,top:0,right:r.map.width,bottom:1}:r,u=n=="column"?a?o.cell:o.header_cell:n=="row"?l?o.cell:o.header_cell:o.cell;r.map.cellsInRect(h).forEach(f=>{const p=f+r.tableStart,m=s.doc.nodeAt(p);m&&s.setNodeMarkup(p,u,m.attrs)}),i(s)}return!0}}qo("row",{useDeprecatedLogic:!0});qo("column",{useDeprecatedLogic:!0});qo("cell",{useDeprecatedLogic:!0});function kp(n,e){if(e<0){const t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let i=n.index(-1)-1,o=n.before();i>=0;i--){const r=n.node(-1).child(i),s=r.lastChild;if(s)return o-1-s.nodeSize;o-=r.nodeSize}}else{if(n.index()<n.parent.childCount-1)return n.pos+n.nodeAfter.nodeSize;const t=n.node(-1);for(let i=n.indexAfter(-1),o=n.after();i<t.childCount;i++){const r=t.child(i);if(r.childCount)return o+1;o+=r.nodeSize}}return null}function Ts(n){return function(e,t){if(!bi(e))return!1;const i=kp(_o(e),n);if(i==null)return!1;if(t){const o=e.doc.resolve(i);t(e.tr.setSelection(N.between(o,pp(o))).scrollIntoView())}return!0}}function Rn(n,e){const t=n.selection;if(!(t instanceof W))return!1;if(e){const i=n.tr,o=Te(n.schema).cell.createAndFill().content;t.forEachCell((r,s)=>{r.content.eq(o)||i.replace(i.mapping.map(s+1),i.mapping.map(s+r.nodeSize-1),new C(o,0,0))}),i.docChanged&&e(i)}return!0}function Tp(n){if(!n.size)return null;let{content:e,openStart:t,openEnd:i}=n;for(;e.childCount==1&&(t>0&&i>0||e.child(0).type.spec.tableRole=="table");)t--,i--,e=e.child(0).content;const o=e.child(0),r=o.type.spec.tableRole,s=o.type.schema,l=[];if(r=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content;const d=a?0:Math.max(0,t-1),h=a<e.childCount-1?0:Math.max(0,i-1);(d||h)&&(c=xo(Te(s).row,new C(c,d,h)).content),l.push(c)}else if(r=="cell"||r=="header_cell")l.push(t||i?xo(Te(s).row,new C(e,t,i)).content:e);else return null;return Mp(s,l)}function Mp(n,e){const t=[];for(let o=0;o<e.length;o++){const r=e[o];for(let s=r.childCount-1;s>=0;s--){const{rowspan:l,colspan:a}=r.child(s).attrs;for(let c=o;c<o+l;c++)t[c]=(t[c]||0)+a}}let i=0;for(let o=0;o<t.length;o++)i=Math.max(i,t[o]);for(let o=0;o<t.length;o++)if(o>=e.length&&e.push(w.empty),t[o]<i){const r=Te(n).cell.createAndFill(),s=[];for(let l=t[o];l<i;l++)s.push(r);e[o]=e[o].append(w.from(s))}return{height:e.length,width:i,rows:e}}function xo(n,e){const t=n.createAndFill();return new _l(t).replace(0,t.content.size,e).doc}function Ap({width:n,height:e,rows:t},i,o){if(n!=i){const r=[],s=[];for(let l=0;l<t.length;l++){const a=t[l],c=[];for(let d=r[l]||0,h=0;d<i;h++){let u=a.child(h%a.childCount);d+u.attrs.colspan>i&&(u=u.type.createChecked(Kt(u.attrs,u.attrs.colspan,d+u.attrs.colspan-i),u.content)),c.push(u),d+=u.attrs.colspan;for(let f=1;f<u.attrs.rowspan;f++)r[l+f]=(r[l+f]||0)+u.attrs.colspan}s.push(w.from(c))}t=s,n=i}if(e!=o){const r=[];for(let s=0,l=0;s<o;s++,l++){const a=[],c=t[l%e];for(let d=0;d<c.childCount;d++){let h=c.child(d);s+h.attrs.rowspan>o&&(h=h.type.create({...h.attrs,rowspan:Math.max(1,o-h.attrs.rowspan)},h.content)),a.push(h)}r.push(w.from(a))}t=r,e=o}return{width:n,height:e,rows:t}}function Op(n,e,t,i,o,r,s){const l=n.doc.type.schema,a=Te(l);let c,d;if(o>e.width)for(let h=0,u=0;h<e.height;h++){const f=t.child(h);u+=f.nodeSize;const p=[];let m;f.lastChild==null||f.lastChild.type==a.cell?m=c||(c=a.cell.createAndFill()):m=d||(d=a.header_cell.createAndFill());for(let g=e.width;g<o;g++)p.push(m);n.insert(n.mapping.slice(s).map(u-1+i),p)}if(r>e.height){const h=[];for(let p=0,m=(e.height-1)*e.width;p<Math.max(e.width,o);p++){const g=p>=e.width?!1:t.nodeAt(e.map[m+p]).type==a.header_cell;h.push(g?d||(d=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const u=a.row.create(null,w.from(h)),f=[];for(let p=e.height;p<r;p++)f.push(u);n.insert(n.mapping.slice(s).map(i+t.nodeSize-2),f)}return!!(c||d)}function Ms(n,e,t,i,o,r,s,l){if(s==0||s==e.height)return!1;let a=!1;for(let c=o;c<r;c++){const d=s*e.width+c,h=e.map[d];if(e.map[d-e.width]==h){a=!0;const u=t.nodeAt(h),{top:f,left:p}=e.findCell(h);n.setNodeMarkup(n.mapping.slice(l).map(h+i),null,{...u.attrs,rowspan:s-f}),n.insert(n.mapping.slice(l).map(e.positionAt(s,p,t)),u.type.createAndFill({...u.attrs,rowspan:f+u.attrs.rowspan-s})),c+=u.attrs.colspan-1}}return a}function As(n,e,t,i,o,r,s,l){if(s==0||s==e.width)return!1;let a=!1;for(let c=o;c<r;c++){const d=c*e.width+s,h=e.map[d];if(e.map[d-1]==h){a=!0;const u=t.nodeAt(h),f=e.colCount(h),p=n.mapping.slice(l).map(h+i);n.setNodeMarkup(p,null,Kt(u.attrs,s-f,u.attrs.colspan-(s-f))),n.insert(p+u.nodeSize,u.type.createAndFill(Kt(u.attrs,0,s-f))),c+=u.attrs.rowspan-1}}return a}function Os(n,e,t,i,o){let r=t?n.doc.nodeAt(t-1):n.doc;if(!r)throw new Error("No table found");let s=H.get(r);const{top:l,left:a}=i,c=a+o.width,d=l+o.height,h=n.tr;let u=0;function f(){if(r=t?h.doc.nodeAt(t-1):h.doc,!r)throw new Error("No table found");s=H.get(r),u=h.mapping.maps.length}Op(h,s,r,t,c,d,u)&&f(),Ms(h,s,r,t,a,c,l,u)&&f(),Ms(h,s,r,t,a,c,d,u)&&f(),As(h,s,r,t,l,d,a,u)&&f(),As(h,s,r,t,l,d,c,u)&&f();for(let p=l;p<d;p++){const m=s.positionAt(p,a,r),g=s.positionAt(p,c,r);h.replace(h.mapping.slice(u).map(m+t),h.mapping.slice(u).map(g+t),new C(o.rows[p-l],0,0))}f(),h.setSelection(new W(h.doc.resolve(t+s.positionAt(l,a,r)),h.doc.resolve(t+s.positionAt(d-1,c-1,r)))),e(h)}var Ep=sa({ArrowLeft:Vn("horiz",-1),ArrowRight:Vn("horiz",1),ArrowUp:Vn("vert",-1),ArrowDown:Vn("vert",1),"Shift-ArrowLeft":Ln("horiz",-1),"Shift-ArrowRight":Ln("horiz",1),"Shift-ArrowUp":Ln("vert",-1),"Shift-ArrowDown":Ln("vert",1),Backspace:Rn,"Mod-Backspace":Rn,Delete:Rn,"Mod-Delete":Rn});function _n(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function Vn(n,e){return(t,i,o)=>{if(!o)return!1;const r=t.selection;if(r instanceof W)return _n(t,i,E.near(r.$headCell,e));if(n!="horiz"&&!r.empty)return!1;const s=qa(o,n,e);if(s==null)return!1;if(n=="horiz")return _n(t,i,E.near(t.doc.resolve(r.head+e),e));{const l=t.doc.resolve(s),a=$a(l,n,e);let c;return a?c=E.near(a,1):e<0?c=E.near(t.doc.resolve(l.before(-1)),-1):c=E.near(t.doc.resolve(l.after(-1)),1),_n(t,i,c)}}}function Ln(n,e){return(t,i,o)=>{if(!o)return!1;const r=t.selection;let s;if(r instanceof W)s=r;else{const a=qa(o,n,e);if(a==null)return!1;s=new W(t.doc.resolve(a))}const l=$a(s.$headCell,n,e);return l?_n(t,i,new W(s.$anchorCell,l)):!1}}function Np(n,e){const t=n.state.doc,i=vn(t.resolve(e));return i?(n.dispatch(n.state.tr.setSelection(new W(i))),!0):!1}function Dp(n,e,t){if(!bi(n.state))return!1;let i=Tp(t);const o=n.state.selection;if(o instanceof W){i||(i={width:1,height:1,rows:[w.from(xo(Te(n.state.schema).cell,t))]});const r=o.$anchorCell.node(-1),s=o.$anchorCell.start(-1),l=H.get(r).rectBetween(o.$anchorCell.pos-s,o.$headCell.pos-s);return i=Ap(i,l.right-l.left,l.bottom-l.top),Os(n.state,n.dispatch,s,l,i),!0}else if(i){const r=_o(n.state),s=r.start(-1);return Os(n.state,n.dispatch,s,H.get(r.node(-1)).findCell(r.pos-s),i),!0}else return!1}function Ip(n,e){var t;if(e.ctrlKey||e.metaKey)return;const i=Es(n,e.target);let o;if(e.shiftKey&&n.state.selection instanceof W)r(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&i&&(o=vn(n.state.selection.$anchor))!=null&&((t=ji(n,e))==null?void 0:t.pos)!=o.pos)r(o,e),e.preventDefault();else if(!i)return;function r(a,c){let d=ji(n,c);const h=_e.getState(n.state)==null;if(!d||!Ko(a,d))if(h)d=a;else return;const u=new W(a,d);if(h||!n.state.selection.eq(u)){const f=n.state.tr.setSelection(u);h&&f.setMeta(_e,a.pos),n.dispatch(f)}}function s(){n.root.removeEventListener("mouseup",s),n.root.removeEventListener("dragstart",s),n.root.removeEventListener("mousemove",l),_e.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(_e,-1))}function l(a){const c=a,d=_e.getState(n.state);let h;if(d!=null)h=n.state.doc.resolve(d);else if(Es(n,c.target)!=i&&(h=ji(n,e),!h))return s();h&&r(h,c)}n.root.addEventListener("mouseup",s),n.root.addEventListener("dragstart",s),n.root.addEventListener("mousemove",l)}function qa(n,e,t){if(!(n.state.selection instanceof N))return null;const{$head:i}=n.state.selection;for(let o=i.depth-1;o>=0;o--){const r=i.node(o);if((t<0?i.index(o):i.indexAfter(o))!=(t<0?0:r.childCount))return null;if(r.type.spec.tableRole=="cell"||r.type.spec.tableRole=="header_cell"){const l=i.before(o),a=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(a)?l:null}}return null}function Es(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function ji(n,e){const t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?vn(n.state.doc.resolve(t.pos)):null}var Pp=class{constructor(n,e){this.node=n,this.defaultCellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${e}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Co(n,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(n){return n.type!=this.node.type?!1:(this.node=n,Co(n,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(n){return n.type=="attributes"&&(n.target==this.table||this.colgroup.contains(n.target))}};function Co(n,e,t,i,o,r){var s;let l=0,a=!0,c=e.firstChild;const d=n.firstChild;if(d){for(let h=0,u=0;h<d.childCount;h++){const{colspan:f,colwidth:p}=d.child(h).attrs;for(let m=0;m<f;m++,u++){const g=o==u?r:p&&p[m],y=g?g+"px":"";if(l+=g||i,g||(a=!1),c)c.style.width!=y&&(c.style.width=y),c=c.nextSibling;else{const x=document.createElement("col");x.style.width=y,e.appendChild(x)}}}for(;c;){const h=c.nextSibling;(s=c.parentNode)==null||s.removeChild(c),c=h}a?(t.style.width=l+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=l+"px")}}var ae=new yn("tableColumnResizing");function Rp({handleWidth:n=5,cellMinWidth:e=25,defaultCellMinWidth:t=100,View:i=Pp,lastColumnResizable:o=!0}={}){const r=new gn({key:ae,state:{init(s,l){var a,c;const d=(c=(a=r.spec)==null?void 0:a.props)==null?void 0:c.nodeViews,h=Te(l.schema).table.name;return i&&d&&(d[h]=(u,f)=>new i(u,t,f)),new Vp(-1,!1)},apply(s,l){return l.apply(s)}},props:{attributes:s=>{const l=ae.getState(s);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(s,l)=>{Lp(s,l,n,o)},mouseleave:s=>{zp(s)},mousedown:(s,l)=>{Bp(s,l,e,t)}},decorations:s=>{const l=ae.getState(s);if(l&&l.activeHandle>-1)return _p(s,l.activeHandle)},nodeViews:{}}});return r}var Vp=class Kn{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){const t=this,i=e.getMeta(ae);if(i&&i.setHandle!=null)return new Kn(i.setHandle,!1);if(i&&i.setDragging!==void 0)return new Kn(t.activeHandle,i.setDragging);if(t.activeHandle>-1&&e.docChanged){let o=e.mapping.map(t.activeHandle,-1);return vo(e.doc.resolve(o))||(o=-1),new Kn(o,t.dragging)}return t}};function Lp(n,e,t,i){const o=ae.getState(n.state);if(o&&!o.dragging){const r=Fp(e.target);let s=-1;if(r){const{left:l,right:a}=r.getBoundingClientRect();e.clientX-l<=t?s=Ns(n,e,"left",t):a-e.clientX<=t&&(s=Ns(n,e,"right",t))}if(s!=o.activeHandle){if(!i&&s!==-1){const l=n.state.doc.resolve(s),a=l.node(-1),c=H.get(a),d=l.start(-1);if(c.colCount(l.pos-d)+l.nodeAfter.attrs.colspan-1==c.width-1)return}ja(n,s)}}}function zp(n){const e=ae.getState(n.state);e&&e.activeHandle>-1&&!e.dragging&&ja(n,-1)}function Bp(n,e,t,i){var o;const r=(o=n.dom.ownerDocument.defaultView)!=null?o:window,s=ae.getState(n.state);if(!s||s.activeHandle==-1||s.dragging)return!1;const l=n.state.doc.nodeAt(s.activeHandle),a=Hp(n,s.activeHandle,l.attrs);n.dispatch(n.state.tr.setMeta(ae,{setDragging:{startX:e.clientX,startWidth:a}}));function c(h){r.removeEventListener("mouseup",c),r.removeEventListener("mousemove",d);const u=ae.getState(n.state);u!=null&&u.dragging&&($p(n,u.activeHandle,Ds(u.dragging,h,t)),n.dispatch(n.state.tr.setMeta(ae,{setDragging:null})))}function d(h){if(!h.which)return c(h);const u=ae.getState(n.state);if(u&&u.dragging){const f=Ds(u.dragging,h,t);Is(n,u.activeHandle,f,i)}}return Is(n,s.activeHandle,a,i),r.addEventListener("mouseup",c),r.addEventListener("mousemove",d),e.preventDefault(),!0}function Hp(n,e,{colspan:t,colwidth:i}){const o=i&&i[i.length-1];if(o)return o;const r=n.domAtPos(e);let l=r.node.childNodes[r.offset].offsetWidth,a=t;if(i)for(let c=0;c<t;c++)i[c]&&(l-=i[c],a--);return l/a}function Fp(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList&&n.classList.contains("ProseMirror")?null:n.parentNode;return n}function Ns(n,e,t,i){const o=t=="right"?-i:i,r=n.posAtCoords({left:e.clientX+o,top:e.clientY});if(!r)return-1;const{pos:s}=r,l=vn(n.state.doc.resolve(s));if(!l)return-1;if(t=="right")return l.pos;const a=H.get(l.node(-1)),c=l.start(-1),d=a.map.indexOf(l.pos-c);return d%a.width==0?-1:c+a.map[d-1]}function Ds(n,e,t){const i=e.clientX-n.startX;return Math.max(t,n.startWidth+i)}function ja(n,e){n.dispatch(n.state.tr.setMeta(ae,{setHandle:e}))}function $p(n,e,t){const i=n.state.doc.resolve(e),o=i.node(-1),r=H.get(o),s=i.start(-1),l=r.colCount(i.pos-s)+i.nodeAfter.attrs.colspan-1,a=n.state.tr;for(let c=0;c<r.height;c++){const d=c*r.width+l;if(c&&r.map[d]==r.map[d-r.width])continue;const h=r.map[d],u=o.nodeAt(h).attrs,f=u.colspan==1?0:l-r.colCount(h);if(u.colwidth&&u.colwidth[f]==t)continue;const p=u.colwidth?u.colwidth.slice():Wp(u.colspan);p[f]=t,a.setNodeMarkup(s+h,null,{...u,colwidth:p})}a.docChanged&&n.dispatch(a)}function Is(n,e,t,i){const o=n.state.doc.resolve(e),r=o.node(-1),s=o.start(-1),l=H.get(r).colCount(o.pos-s)+o.nodeAfter.attrs.colspan-1;let a=n.domAtPos(o.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&Co(r,a.firstChild,a,i,l,t)}function Wp(n){return Array(n).fill(0)}function _p(n,e){var t;const i=[],o=n.doc.resolve(e),r=o.node(-1);if(!r)return z.empty;const s=H.get(r),l=o.start(-1),a=s.colCount(o.pos-l)+o.nodeAfter.attrs.colspan-1;for(let c=0;c<s.height;c++){const d=a+c*s.width;if((a==s.width-1||s.map[d]!=s.map[d+1])&&(c==0||s.map[d]!=s.map[d-s.width])){const h=s.map[d],u=l+h+r.nodeAt(h).nodeSize-1,f=document.createElement("div");f.className="column-resize-handle",(t=ae.getState(n))!=null&&t.dragging&&i.push(oe.node(l+h,l+h+r.nodeAt(h).nodeSize,{class:"column-resize-dragging"})),i.push(oe.widget(u,f))}}return z.create(n.doc,i)}function Kp({allowTableNodeSelection:n=!1}={}){return new gn({key:_e,state:{init(){return null},apply(e,t){const i=e.getMeta(_e);if(i!=null)return i==-1?null:i;if(t==null||!e.docChanged)return t;const{deleted:o,pos:r}=e.mapping.mapResult(t);return o?null:r}},props:{decorations:gp,handleDOMEvents:{mousedown:Ip},createSelectionBetween(e){return _e.getState(e.state)!=null?e.state.selection:null},handleTripleClick:Np,handleKeyDown:Ep,handlePaste:Dp},appendTransaction(e,t,i){return wp(i,vp(i,t),n)}})}const ln=n=>{const e=Object.fromEntries(Array.from(n.attributes).map(t=>[t.name,t.value]));return delete e.draggable,e},Ps="data-gs-mrk-fs",Rs="data-gs-ib",ai="data-gs-ifrg",Ve="attrs",Ja={[Ve]:{default:"{}"}},Ee={[Ve]:{default:{}}},Ga=n=>({[Ve]:JSON.stringify(ln(n))}),Ne=n=>({attrs:ln(n)}),Ut=n=>e=>[n,e.attrs.attrs,0],$e=n=>n.attrs[Ve]?JSON.parse(n.attrs[Ve]):{},qp={doc:{content:"block+"},text:{group:"inline",inline:!0},inlineFragment:{group:"block",content:"inline*",isTextBlock:!0,parseDOM:[{tag:`span[${ai}]`,getAttrs:Ne}],toDOM:()=>["span",{[ai]:""},0]},div:{group:"block",content:"inline*",attrs:Ee,parseDOM:[{tag:"div",getAttrs:Ne}],toDOM:Ut("div")},paragraph:{group:"block",content:"inline*",attrs:Ee,parseDOM:[{tag:"p",getAttrs:Ne}],toDOM:Ut("p")},orderedList:{group:"block",content:"listItem+",attrs:Ee,parseDOM:[{tag:"ol",getAttrs:Ne}],toDOM:Ut("ol")},bulletList:{group:"block",content:"listItem+",attrs:Ee,parseDOM:[{tag:"ul",getAttrs:Ne}],toDOM:Ut("ul")},listItem:{content:"block*",group:"block",attrs:Ee,parseDOM:[{tag:"li",getAttrs:Ne}],toDOM:Ut("li"),defining:!0},codeBlock:{group:"block",content:"text*",marks:"",attrs:Ee,parseDOM:[{tag:"pre",getAttrs:Ne}],toDOM:n=>["pre",n.attrs.attrs,["code",0]]},image:{inline:!0,group:"inline",selectable:!0,attrs:Ee,parseDOM:[{tag:"img[src]",getAttrs:Ne}],toDOM:n=>["img",n.attrs.attrs]},inlineBreak:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:`br[${Rs}]`}],toDOM(){return["br",{[Rs]:""}]}},hardBreak:{inline:!1,group:"block",selectable:!1,attrs:Ee,parseDOM:[{tag:"br",getAttrs:Ne}],toDOM:n=>["br",{...n.attrs.attrs}]},heading:{group:"block",content:"inline*",attrs:{level:{default:1},attrs:{default:{}}},defining:!0,parseDOM:Array.from({length:6},(n,e)=>({tag:`h${e+1}`,getAttrs:t=>({level:e+1,attrs:ln(t)})})),toDOM({attrs:n}){const{level:e}=n;return[e?`h${e}`:"div",n.attrs,0]}},...up({tableGroup:"block",cellContent:"block+",cellAttributes:{[Ve]:{default:Ee[Ve].default,getFromDOM:ln,setDOMAttr:(n,e)=>{n&&Object.assign(e,n)}},background:{default:null,getFromDOM(n){return n.style.backgroundColor||null},setDOMAttr(n,e){n&&(e.style=(e.style||"")+`background-color: ${n};`)}}}}),nonTextNode:{group:"block",content:"block*",attrs:{tagName:{default:"span"},attrs:{default:{}}},parseDOM:[{tag:"*:not(tbody)",getAttrs:n=>({tagName:n.tagName.toLowerCase(),attrs:ln(n)}),priority:0}],toDOM(n){const{tagName:e,attrs:t}=n.attrs;return[e,t,0]}}},Zt=(n,e)=>({attrs:Ja,parseDOM:n.map(t=>({tag:t,getAttrs:Ga})),toDOM:e}),jp={strong:Zt(["strong","b"],n=>["b",$e(n)]),link:Zt(["a"],n=>["a",$e(n),0]),em:Zt(["em","i"],n=>["em",$e(n)]),underline:Zt(["u"],n=>["u",$e(n),0]),strikethrough:Zt(["s"],n=>["s",$e(n),0]),font_size:{attrs:{...Ja,size:{default:null}},parseDOM:[{tag:`span[${Ps}]`,getAttrs:n=>({...Ga(n),size:n.style.fontSize})}],toDOM(n){const{size:e}=n.attrs,t={...$e(n),[Ps]:!0};return e&&(t.style=`font-size: ${e}`),["span",t,0]}}},Vs=new dh({nodes:qp,marks:jp}),wi=new WeakMap,jo=new WeakMap,Jp=(n,e)=>{wi.set(n,e),jo.set(e,n)},Gp=(n,e)=>{wi.delete(n),jo.delete(e)},Ji=n=>wi.get(n),Up=n=>jo.get(n),Ls=n=>{var t;const e=Up(n);return(t=e==null?void 0:e.__gjsv)==null?void 0:t.model},Zp=n=>n.dispatchEvent(new CustomEvent("input"));function Yp(n){const e=t=>{if(t.tagName==="SPAN"&&t.hasAttribute(ai)){if(t.getAttribute("style")){t.removeAttribute(ai);return}const i=t.parentElement;if(i){for(;t.firstChild;)i.insertBefore(t.firstChild,t);i.removeChild(t)}}else Array.from(t.children).forEach(i=>e(i))};e(n)}function Xp(n,e={}){if(!e.enableOnClick)return()=>{};const t=n.Components.events,i=d=>n.getSelectedAll().includes(d),o=d=>d.isInstanceOf("text")&&!d.isChildOf("text"),r=d=>d.isChildOf("text"),s=d=>n.getEditing()===d,l=(d,h={})=>{d.trigger("focus",h.event)},a=(d,h)=>{i(d)&&o(d)&&!s(d)&&l(d,h)},c=(d,h)=>{if(i(d)&&!o(d)&&r(d)){const u=d.parents().find(f=>f.isInstanceOf("text"));u&&(l(u,h),setTimeout(()=>n.select(u),0))}};return n.on(t.select,a),n.on(t.selectBefore,c),()=>{n.off(t.select,a),n.off(t.selectBefore,c)}}const Qp=(n,e)=>{const t=em(n);return t&&cm(t)?tm(n,e):t?Xl(()=>({type:n.schema.nodes.div}))(n,e):!1};function em(n){const e=n.selection.$from;if(e.node(e.depth).type===n.schema.nodes.inlineFragment){const t=e.depth-1;return e.node(t)}return e.node(e.depth)}function tm(n,e){const{selection:t,schema:i,tr:o}=n;o.split(t.from,1);const r=t.from+1,s=o.doc.nodeAt(r),l={...s.attrs.attrs,id:void 0},a=s.textContent.length>0,c=s.textContent.length||0,d=s.textContent||" ",h=i.text(d),u=i.nodes.div.create(l,a?h:[],[]);return o.replaceRangeWith(r,r+c+2,u),o.setSelection(N.create(o.doc,r+1)),e==null||e(o.scrollIntoView()),!0}function nm(n,e,t){const{state:i,dispatch:o}=n,{selection:r,tr:s}=i,l=(a,c,d)=>{const h={};return a.split(";").forEach(u=>{const[f,p]=u.split(":").map(m=>m.trim());f&&(h[f]=p)}),h[c]=d,Object.entries(h).map(([u,f])=>`${u}: ${f}`).join("; ")};if(!r.empty||t)s.doc.nodesBetween(r.from,r.to,(a,c)=>{var d,h;if(a.type===i.schema.nodes.image){const u=l(((d=a.attrs.attrs)==null?void 0:d.style)||"","float",e);s.setNodeMarkup(c,void 0,{...a.attrs,attrs:{...a.attrs.attrs,style:u}})}else if(a.type.isBlock){const u=l(((h=a.attrs.attrs)==null?void 0:h.style)||"","text-align",e);Ua(a)?s.setBlockType(r.from,void 0,i.schema.nodes.div,{attrs:{style:u}}):s.setNodeMarkup(c,void 0,{...a.attrs,attrs:{...a.attrs.attrs,style:u}})}});else{const a=i.doc.resolve(r.from),c=a.start(a.depth),d=i.doc.nodeAt(c);if(d!=null&&d.type.isBlock){const h=l(d.attrs.style||"","text-align",e);s.setNodeMarkup(c,void 0,{...d.attrs,style:h})}}s.docChanged&&o(s.scrollIntoView())}const Yt=(n,e)=>{const{from:t,to:i}=n.selection;let o=!1;return n.doc.nodesBetween(t,i,r=>{if(o)return!1;r.marks.some(s=>s.type===e)&&(o=!0)}),o};function im(n,e,t="_blank"){const{state:i,dispatch:o}=n,{schema:r,selection:s,tr:l}=i,a=r.marks.link;try{const c=a.create({[Ve]:JSON.stringify({href:e,target:t})});l.addMark(s.from,s.to,c),o(l.scrollIntoView())}catch(c){console.error("Error applying link mark:",c)}}function om(n,e){const{state:t,dispatch:i}=n,{selection:o,tr:r}=t;if(o.empty)return;const s=t.schema.marks.font_size;if(!s){console.error("Font size mark is not defined in the schema.");return}r.addMark(o.from,o.to,s.create({size:e})),i(r.scrollIntoView())}const at=(n,e)=>{const{doc:t,selection:i}=n.state,o=t.resolve(i.from);for(let r=o.depth;r>0;r--){const s=o.node(r);if(e(s))return{pos:r>0?o.before(r):0,start:o.start(r),depth:r,node:s}}},rm=n=>(n||"").split(";").map(e=>e.split(":")).reduce((e,[t,i])=>(t=t.replace(/-./g,o=>o.toUpperCase()[1]).trim(),e[t]=`${i}`.trim(),e),{});function sm(...n){return(e,t)=>{const i=s=>{e=e.apply(s),t==null||t(s)},o=n.pop();return n.reduce((s,l)=>s||l(e,i),!1)&&o!==void 0&&o(e,t)}}const lm=(n,e)=>{const{state:t,dispatch:i}=n;if(e!=null&&e.event){const{event:o}=e,r=n.posAtCoords({left:o.clientX,top:o.clientY});r!=null&&r.pos&&i(t.tr.setSelection(N.create(t.doc,r.pos)))}else Ql(t,i);setTimeout(()=>setTimeout(()=>n.focus()))},ko=n=>n.isBlock,Ua=n=>n.type.name==="inlineFragment",am=n=>ko(n)&&!Ua(n),Za=n=>n.type.name==="bulletList",Ya=n=>n.type.name==="orderedList",cm=n=>n.type.name==="heading",dm=n=>Za(n)||Ya(n),zs=(n,e)=>{var r,s;const t=(r=at(n,l=>l.type===e))==null?void 0:r.node,i=n.state.schema.nodes.listItem;let o;return t?o=lo(i):(s=at(n,dm))!=null&&s.node?o=sm(lo(i),$r(e)):o=$r(e),o(n.state,n.dispatch)},Xa=(n,e)=>{const{selection:t}=n.state;return[...t.$from.marks(),...t.$to.marks()].find(i=>i.type.name===e)},hm=n=>{var s;const{view:e,prop:t,editor:i,propCSS:o}=n,r=(s=at(e,am))==null?void 0:s.node;if(r){const l=r.attrs.attrs||{},a=rm(l.style);if(t in a)return a[t]||"";if(l.id){const c=i.Components.getById(l.id);return((c==null?void 0:c.getStyle())||{})[o]||""}}return""},um=n=>{const{view:e,prop:t,markName:i,editor:o,propCSS:r}=n,s=Xa(e,i);if(s){const l=s.attrs;if(l[t])return l[t];if(l[Ve]){const a=$e(s).id;if(a){const c=o.Components.getById(a);return((c==null?void 0:c.getStyle())||{})[r]||""}}}return""},Qa=(n,e)=>{const{dispatch:t}=n,{nodes:i,marks:o}=n.state.schema;return{text:{selected:()=>{const{selection:r,doc:s}=n.state;return s.textBetween(r.from,r.to," ")},replace:(r,s={})=>{const{state:l}=n,{from:a}=l.selection;let c=l.tr.replaceSelectionWith(l.schema.text(r));s.select&&(c=c.setSelection(N.create(c.doc,a,a+r.length))),t==null||t(c)}},bold:{toggle:()=>it(o.strong)(n.state,t),isActive:()=>Yt(n.state,o.strong)},italic:{toggle:()=>it(o.em)(n.state,t),isActive:()=>Yt(n.state,o.em)},underline:{toggle:()=>it(o.underline)(n.state,t),isActive:()=>Yt(n.state,o.underline)},strikethrough:{toggle:()=>it(o.strikethrough)(n.state,t),isActive:()=>Yt(n.state,o.strikethrough)},link:{get:()=>{const r=Ls(n);if(r!=null&&r.is("link"))return r.getAttributes();{const s=Xa(n,"link");return s?$e(s):{}}},toggle:()=>it(o.link)(n.state,t),isActive:()=>Yt(n.state,o.link),create:r=>{const s=Ls(n);s!=null&&s.is("link")?(s.addAttributes({href:r.url,target:r.target}),n.focus()):im(n,r.url,r.target)}},alignText:{get:()=>hm({view:n,editor:e,prop:"textAlign",propCSS:"text-align"}),set:r=>nm(n,r.value,!0)},fontSize:{get:()=>um({view:n,editor:e,markName:"font_size",prop:"size",propCSS:"font-size"}),set:r=>om(n,r.value)},image:{open(){const r="assetLayout",{state:s,dispatch:l}=n,{selection:a,doc:c}=s,d=c.textBetween(a.from,a.to," "),h={id:r,disablePropagation:!0,placer:{type:"dialog",title:"Select image",size:"l"},header:!1,layout:{type:"panelAssets",onSelect:u=>{const f={alt:d,src:u.asset.getSrc()};l(s.tr.replaceSelectionWith(i.image.createAndFill({attrs:f})))}}};e.runCommand(Y.layoutToggle,h)}},heading:{get:()=>{var s;const r=(s=at(n,ko))==null?void 0:s.node;return`${(r==null?void 0:r.attrs.level)||""}`},set:({value:r})=>{var a;const{state:s}=n,l=(a=at(n,ko))==null?void 0:a.node;iu(s.schema.nodes.heading,{attrs:l==null?void 0:l.attrs.attrs,level:r?parseInt(r,10):0})(s,t)}},listBullet:{isActive:()=>{var r;return!!((r=at(n,Za))!=null&&r.node)},toggle:()=>zs(n,i.bulletList)},listOrdered:{isActive:()=>{var r;return!!((r=at(n,Ya))!=null&&r.node)},toggle:()=>zs(n,i.orderedList)}}},me="rte:selectionchange",he={bold:'<svg viewBox="0 0 24 24"><path d="M13.5,15.5H10V12.5H13.5A1.5,1.5 0 0,1 15,14A1.5,1.5 0 0,1 13.5,15.5M10,6.5H13A1.5,1.5 0 0,1 14.5,8A1.5,1.5 0 0,1 13,9.5H10M15.6,10.79C16.57,10.11 17.25,9 17.25,8C17.25,5.74 15.5,4 13.25,4H7V18H14.04C16.14,18 17.75,16.3 17.75,14.21C17.75,12.69 16.89,11.39 15.6,10.79Z" /></svg>',italic:'<svg viewBox="0 0 24 24"><path d="M10,4V7H12.21L8.79,15H6V18H14V15H11.79L15.21,7H18V4H10Z" /></svg>',underline:'<svg viewBox="0 0 24 24"><path d="M5,21H19V19H5V21M12,17A6,6 0 0,0 18,11V3H15.5V11A3.5,3.5 0 0,1 12,14.5A3.5,3.5 0 0,1 8.5,11V3H6V11A6,6 0 0,0 12,17Z" /></svg>',strikethrough:'<svg viewBox="0 0 24 24"><path d="M7.2 9.8c-1.2-2.3.5-5 2.9-5.5 3.1-1 7.6.4 7.5 4.2h-3l-.1-.8c-.2-.6-.6-.9-1.2-1.1-.8-.3-2.1-.2-2.8.3C9 8.2 10.4 9.5 12 10H7.4l-.2-.2M21 13v-2H3v2h9.6l.6.2c.6.3 1.1.5 1.3 1.1.1.4.2.9 0 1.3-.2.5-.6.7-1.1.9-1.8.5-4-.2-3.9-2.4h-3c-.1 2.6 2.1 4.4 4.5 4.7 3.8.8 8.3-1.6 6.3-5.9l3.7.1Z"/></svg>',link:'<svg viewBox="0 0 24 24"><path d="M3.9,12C3.9,10.29 5.29,8.9 7,8.9H11V7H7A5,5 0 0,0 2,12A5,5 0 0,0 7,17H11V15.1H7C5.29,15.1 3.9,13.71 3.9,12M8,13H16V11H8V13M17,7H13V8.9H17C18.71,8.9 20.1,10.29 20.1,12C20.1,13.71 18.71,15.1 17,15.1H13V17H17A5,5 0 0,0 22,12A5,5 0 0,0 17,7Z" /></svg>',image:'<svg viewBox="0 0 24 24"><path d="M19,19H5V5H19M19,3H5A2,2 0 0,0 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5A2,2 0 0,0 19,3M13.96,12.29L11.21,15.83L9.25,13.47L6.5,17H17.5L13.96,12.29Z"></path></svg>',listBullet:'<svg viewBox="0 0 24 24"><path d="M7 5h14v2H7V5m0 8v-2h14v2H7M4 4.5A1.5 1.5 0 0 1 5.5 6 1.5 1.5 0 0 1 4 7.5 1.5 1.5 0 0 1 2.5 6 1.5 1.5 0 0 1 4 4.5m0 6A1.5 1.5 0 0 1 5.5 12 1.5 1.5 0 0 1 4 13.5 1.5 1.5 0 0 1 2.5 12 1.5 1.5 0 0 1 4 10.5M7 19v-2h14v2H7m-3-2.5A1.5 1.5 0 0 1 5.5 18 1.5 1.5 0 0 1 4 19.5 1.5 1.5 0 0 1 2.5 18 1.5 1.5 0 0 1 4 16.5Z"/></svg>',listOrdered:'<svg viewBox="0 0 24 24"><path d="M7 13v-2h14v2H7m0 6v-2h14v2H7M7 7V5h14v2H7M3 8V5H2V4h2v4H3m-1 9v-1h3v4H2v-1h2v-.5H3v-1h1V17H2m2.3-7a.8.8 0 0 1 .7.8c0 .1 0 .3-.2.5L3 13h2v1H2v-1l2-2H2v-1h2.3Z"/></svg>',alignTextLeft:'<svg viewBox="0 0 24 24"><path d="M3,3H21V5H3V3M3,7H15V9H3V7M3,11H21V13H3V11M3,15H15V17H3V15M3,19H21V21H3V19Z" /></svg>',alignTextCenter:'<svg viewBox="0 0 24 24"><path d="M3,3H21V5H3V3M7,7H17V9H7V7M3,11H21V13H3V11M7,15H17V17H7V15M3,19H21V21H3V19Z" /></svg>',alignTextRight:'<svg viewBox="0 0 24 24"><path d="M3,3H21V5H3V3M9,7H21V9H9V7M3,11H21V13H3V11M9,15H21V17H9V15M3,19H21V21H3V19Z" /></svg>',alignTextJustify:'<svg viewBox="0 0 24 24"><path d="M3,3H21V5H3V3M3,7H21V9H3V7M3,11H21V13H3V11M3,15H21V17H3V15M3,19H21V21H3V19Z" /></svg>'},fm=(n,e)=>{var a;const{editor:t,el:i}=n,o=wi.get(i),r=Qa(o,t),s={separator:{type:"column",style:{borderRightWidth:"1px",borderRightStyle:"solid",alignSelf:"stretch",margin:3}},bold:{id:"bold",icon:he.bold,size:"s",type:"button",editorEvents:{[me]:({setState:c})=>{c({active:r.bold.isActive()})}},onClick:({setState:c})=>{r.bold.toggle(),c({active:r.bold.isActive()})}},italic:{id:"italic",icon:he.italic,size:"s",type:"button",editorEvents:{[me]:({setState:c})=>{c({active:r.italic.isActive()})}},onClick:({setState:c})=>{r.italic.toggle(),c({active:r.italic.isActive()})}},underline:{id:"underline",icon:he.underline,size:"s",type:"button",editorEvents:{[me]:({setState:c})=>{c({active:r.underline.isActive()})}},onClick:({setState:c})=>{r.underline.toggle(),c({active:r.underline.isActive()})}},strikethrough:{id:"strikethrough",icon:he.strikethrough,size:"s",type:"button",editorEvents:{[me]:({setState:c})=>{c({active:r.strikethrough.isActive()})}},onClick:({setState:c})=>{r.strikethrough.toggle(),c({active:r.strikethrough.isActive()})}},image:{id:"image",icon:he.image,size:"s",type:"button",onClick:()=>r.image.open()},link:{id:"link",icon:he.link,size:"s",type:"button",editorEvents:{[me]:({setState:c})=>{c({active:r.link.isActive(),disabled:o.state.selection.empty})}},onClick:({event:c})=>{const d=c.currentTarget||c.target,{x:h,y:u,width:f,height:p}=d.getBoundingClientRect(),m="linkLayout",g=()=>t.runCommand(Y.layoutRemove,{id:m}),y=r.link.get(),x={id:m,style:{width:240},disablePropagation:!0,placer:{type:"popover",closeOnClickAway:!0,x:h,y:u,w:f,h:p},header:{label:"Link"},layout:{type:"column",as:"form",style:{padding:"0 10px 15px",gap:10},onSubmit:b=>{b.preventDefault();const S=new FormData(b.currentTarget);r.link.create({url:S.get("url"),target:S.get("target")}),g()},children:[{type:"inputField",name:"url",label:"URL",placeholder:"eg. https://google.com",required:!0,value:(y==null?void 0:y.href)||"",onChange:({value:b,setState:S})=>S({value:b})},{type:"selectField",name:"target",label:"Open link in",emptyState:"Current window",value:(y==null?void 0:y.target)||"",options:[{id:"",label:"Current window"},{id:"_blank",label:"New window"}],onChange:({value:b,setState:S})=>S({value:b})},{type:"row",style:{gap:10,justifyContent:"end"},children:[r.link.isActive()&&{type:"button",label:"Clear",buttonType:"button",onClick:()=>{r.link.toggle(),g()}},{type:"button",variant:"primary",label:"Submit",buttonType:"submit"}]}]}};t.runCommand(Y.layoutToggle,x)}},alignText:{id:"alignText",type:"buttonGroupField",size:"s",value:"",options:[{id:"left",icon:he.alignTextLeft},{id:"center",icon:he.alignTextCenter},{id:"right",icon:he.alignTextRight},{id:"justify",icon:he.alignTextJustify}],editorEvents:{[me]:({setState:c})=>{c({value:r.alignText.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),r.alignText.set({value:c})}},listBullet:{id:"listBullet",icon:he.listBullet,size:"s",type:"button",editorEvents:{[me]:({setState:c})=>{c({active:r.listBullet.isActive()})}},onClick:({setState:c})=>{r.listBullet.toggle(),c({active:r.listBullet.isActive()})}},listOrdered:{id:"listOrdered",icon:he.listOrdered,size:"s",type:"button",editorEvents:{[me]:({setState:c})=>{c({active:r.listOrdered.isActive()})}},onClick:({setState:c})=>{r.listOrdered.toggle(),c({active:r.listOrdered.isActive()})}},heading:{id:"heading",type:"selectField",size:"s",value:"",emptyState:"Heading",options:[{id:"",label:"Normal"},{id:"1",label:"Heading 1"},{id:"2",label:"Heading 2"},{id:"3",label:"Heading 3"},{id:"4",label:"Heading 4"},{id:"5",label:"Heading 5"},{id:"6",label:"Heading 6"}],editorEvents:{[me]:({setState:c})=>{c({value:r.heading.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),r.heading.set({value:c}),o.focus()}},fontSize:{id:"fontSize",type:"selectField",size:"s",value:"",emptyState:"Font size",options:[{id:"8pt",label:"8pt"},{id:"10pt",label:"10pt"},{id:"12pt",label:"12pt"},{id:"14pt",label:"14pt"},{id:"18pt",label:"18pt"},{id:"24pt",label:"24pt"},{id:"36pt",label:"36pt"}],editorEvents:{[me]:({setState:c})=>{c({value:r.fontSize.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),r.fontSize.set({value:c}),o.focus()}}},l=[s.bold,s.italic,s.underline,s.strikethrough,s.image,s.link,s.listBullet,s.listOrdered,s.alignText,s.heading,s.fontSize];return((a=e.toolbar)==null?void 0:a.call(e,{...n,commands:r,layouts:s,proseMirror:{view:o},items:l}))||l};class pm{constructor(e,t,i){this.editor=i,this.node=e,this.dom=document.createElement("img"),this.view=t,Object.keys(e.attrs.attrs).forEach(o=>{this.dom.setAttribute(o,e.attrs.attrs[o])}),this.dom.addEventListener("dblclick",o=>this.handleDoubleClick(o))}handleDoubleClick(e){const{editor:t,view:i}=this;Qa(i,t).image.open(),e.preventDefault()}update(e){return e.type!==this.node.type?!1:(this.node=e,Object.keys(e.attrs.attrs).forEach(t=>{this.dom.setAttribute(t,e.attrs.attrs[t])}),!0)}selectNode(){this.dom.style.outline="2px solid #ffca6f"}deselectNode(){this.dom.style.outline=""}}class Xe{constructor(e,t,i={}){this.match=e,this.match=e,this.handler=typeof t=="string"?mm(t):t,this.undoable=i.undoable!==!1,this.inCode=i.inCode||!1}}function mm(n){return function(e,t,i,o){let r=n;if(t[1]){let s=t[0].lastIndexOf(t[1]);r+=t[0].slice(s+t[1].length),i+=s;let l=i-o;l>0&&(r=t[0].slice(s-l,s)+r,i=o)}return e.tr.insertText(r,i,o)}}const gm=500;function ym({rules:n}){let e=new gn({state:{init(){return null},apply(t,i){let o=t.getMeta(this);return o||(t.selectionSet||t.docChanged?null:i)}},props:{handleTextInput(t,i,o,r){return Bs(t,i,o,r,n,e)},handleDOMEvents:{compositionend:t=>{setTimeout(()=>{let{$cursor:i}=t.state.selection;i&&Bs(t,i.pos,i.pos,"",n,e)})}}},isInputRules:!0});return e}function Bs(n,e,t,i,o,r){if(n.composing)return!1;let s=n.state,l=s.doc.resolve(e),a=l.parent.textBetween(Math.max(0,l.parentOffset-gm),l.parentOffset,null,"")+i;for(let c=0;c<o.length;c++){let d=o[c];if(l.parent.type.spec.code){if(!d.inCode)continue}else if(d.inCode==="only")continue;let h=d.match.exec(a),u=h&&d.handler(s,h,e-(h[0].length-i.length),t);if(u)return d.undoable&&u.setMeta(r,{transform:u,from:e,to:t,text:i}),n.dispatch(u),!0}return!1}const bm=new Xe(/--$/,"—"),wm=new Xe(/\.\.\.$/,"…"),Sm=new Xe(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“"),vm=new Xe(/"$/,"”"),xm=new Xe(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘"),Cm=new Xe(/'$/,"’"),km=[Sm,vm,xm,Cm];function Jo(n,e,t=null,i){return new Xe(n,(o,r,s,l)=>{let a=t instanceof Function?t(r):t,c=o.tr.delete(s,l),d=c.doc.resolve(s),h=d.blockRange(),u=h&&Ll(h,e,a);if(!u)return null;c.wrap(h,u);let f=c.doc.resolve(s-1).nodeBefore;return f&&f.type==e&&fi(c.doc,s-1)&&(!i||i(r,f))&&c.join(s-1),c})}function ec(n,e,t=null){return new Xe(n,(i,o,r,s)=>{let l=i.doc.resolve(r),a=t instanceof Function?t(o):t;return l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),e)?i.tr.delete(r,s).setBlockType(r,r,e,a):null})}function Tm(n){return Jo(/^\s*>\s$/,n)}function Mm(n){return Jo(/^(\d+)\.\s$/,n,e=>({order:+e[1]}),(e,t)=>t.childCount+t.attrs.order==+e[1])}function Am(n){return Jo(/^\s*([-+*])\s$/,n)}function Om(n){return ec(/^```$/,n)}function Em(n,e){return ec(new RegExp("^(#{1,"+e+"})\\s$"),n,t=>({level:t[1].length}))}function Nm(n){const e=km.concat(wm,bm);let t;return(t=n.nodes.blockquote)&&e.push(Tm(t)),(t=n.nodes.orderedList)&&e.push(Mm(t)),(t=n.nodes.bulletList)&&e.push(Am(t)),(t=n.nodes.codeBlock)&&e.push(Om(t)),(t=n.nodes.heading)&&e.push(Em(t,6)),ym({rules:e})}const Dm="rteProseMirror",Im=function(n,e={}){const t={plugins:s=>s.plugins,...e},i=(s,l)=>{var p,m;const a=((p=t.schema)==null?void 0:p.call(t,{editor:n,schema:Vs}))||Vs,{nodes:c,marks:d}=a,h=Ht.fromSchema(a).parse(s),u=Nt.create({doc:h,schema:a,plugins:(m=t.plugins)==null?void 0:m.call(t,{editor:n,plugins:[Rp(),Kp(),Nm(a),mu(),Fi({Tab:Ts(1),"Shift-Tab":Ts(-1)}),Fi({Enter:hn(Yl,Cu(c.listItem),Qp),"Shift-Enter":hn(Zl,(g,y)=>(y&&y(g.tr.replaceSelectionWith(c.inlineBreak.create()).scrollIntoView()),!0)),"Mod-z":ra,"Mod-y":so,"Mod-Shift-z":so,"Mod-b":it(d.strong),"Mod-i":it(d.em),"Shift-Tab":lo(c.listItem),Tab:Mu(c.listItem)}),Fi(su)]})}),f=new rp({mount:s},{state:u,dispatchTransaction(g){var v;const{state:y}=f,x=y.apply(g),b=!y.doc.eq(x.doc);f.updateState(x);const S=!y.selection.eq(x.selection);b&&(Zp(((v=l==null?void 0:l.view)==null?void 0:v.el)||s),f.focus()),(S||b)&&n.trigger(me)}});return s.__rteView=f,f.setProps({nodeViews:{image(g){return new pm(g,f,n)}}}),f},o=s=>fm(s,t);n.setCustomRte({toolbar:o,parseContent:!0,async enable(s,l,a){const c=Ji(s);if(c)return c;const d=i(s,a);return Jp(s,d),lm(d,a),d},disable(s){const l=Ji(s);if(l)return Gp(s,l),l.destroy(),{forceSync:!0}},getContent(s){const l=Ji(s);if(l){const{schema:a,doc:c}=l.state,d=document.createElement("div"),h=wt.fromSchema(a).serializeFragment(c.content);return h.childNodes.forEach(u=>{u.nodeType===Node.ELEMENT_NODE&&u.innerHTML===""&&(u.innerHTML="<br/>")}),d.appendChild(h),Yp(d),s.classList.remove("ProseMirror-focused"),d.innerHTML}return s.innerHTML}});const r=Xp(n,t);Ae({editor:n,licenseKey:t.licenseKey,plan:ee.free,pluginName:Dm,cleanup:()=>{n.RichTextEditor.customRte=void 0,r()}})},Pm=Me(Im),Rm=n=>{const e={};for(const t of Object.keys(n)){let i=n[t];i&&(Array.isArray(i)?i=i.map(o=>o.toString()).join(","):i=i.toString(),e[t]=i)}return new URLSearchParams(e)},Vm=n=>{const{apiKey:e,searchParams:t,thumbnailQuality:i="high"}=n,o=(l={})=>{const c="https://www.googleapis.com/youtube/v3/search",d=Rm(l);return`${c}?${d}`},r=l=>{var a,c,d;return((a=l[i])==null?void 0:a.url)||((c=l.high)==null?void 0:c.url)||((d=l.medium)==null?void 0:d.url)||l.default.url},s=l=>{const a=r(l.snippet.thumbnails);return{id:l.id.videoId,src:`https://www.youtube.com/watch?v=${l.id.videoId}`,name:l.snippet.title,customData:{thumbnailUrl:a,videoItem:l}}};return{id:"youtube",types:["youtube-video"],label:"YouTube Videos",search:{reloadOnInput:!0,debounceMs:1e3},async onLoad({searchValue:l,pageCustomData:a}){var m;const c={maxResults:25,q:l,pageToken:a==null?void 0:a.token,type:["video"],key:e},d=t==null?void 0:t({searchValue:l}),h={...c,...d};h.part?h.part.includes("snippet")||h.part.push("snippet"):h.part=["snippet"];const f=await(await fetch(o(h))).json();return(m=f.items)!=null&&m.length?{items:f.items.map(s),nextPageCustomData:{token:f.nextPageToken},isLastPage:!f.nextPageToken}:{items:[],isLastPage:!0}},itemLayout:({assetProps:l,onSelect:a})=>({type:"column",onClick:()=>a(l),htmlAttrs:{title:l.name},style:{border:"1px solid gray",borderRadius:8,overflow:"hidden",cursor:"pointer"},children:[{type:"custom",render:()=>{var c;return`<img src="${(c=l.customData)==null?void 0:c.thumbnailUrl}" alt="${l.name}" style="width: 100%; height: 100px; object-fit: cover">`}},{type:"text",content:l.name,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",paddingLeft:8,paddingRight:8}}]})}},Lm="youtubeAssetProvider",zm=function(n,e){const{skipVideoComponent:t}=e,i=Vm(e);n.runCommand(Y.assetProviderAdd,{provider:i});const o="search-on-youtube",r="video";if(!t){const s=n.Components.getType(r).model.prototype;n.Components.addType(r,{model:{getYoutubeTraits(){const[l,...a]=s.getYoutubeTraits.apply(this);return[l,{id:o,type:"button",label:n.I18n.t("youtube.searchBtn"),command:()=>{n.AssetManager.open({select:c=>{n.Assets.close(),this.set({videoId:c.attributes.id})},content:{header:{addUrl:!1,upload:!1}}})}},...a]}}})}Ae({editor:n,licenseKey:e.licenseKey,plan:ee.startup,pluginName:Lm,cleanup:()=>{if(n.runCommand(Y.assetProviderRemove,{id:i.id}),!t){const s=n.Components.getType(r).model.prototype;n.Components.addType(r,{model:{getYoutubeTraits(){return s.getYoutubeTraits.apply(this).filter(l=>l.id!==o)}}})}}})},Bm=Me(zm);exports.dialogComponent=gc;exports.fsLightboxComponent=fd;exports.iconifyComponent=Dc;exports.lightGalleryComponent=Cd;exports.listPagesComponent=cd;exports.rteProseMirror=Pm;exports.rteTinyMce=Jd;exports.swiperComponent=Bd;exports.tableComponent=nd;exports.youtubeAssetProvider=Bm;
|
|
129
|
+
`))),0,0):C.empty;let h=n.someProp("clipboardTextParser",u=>u(e,o,i,n));if(h)l=h;else{let u=o.marks(),{schema:f}=n.state,p=wt.fromSchema(f);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=s.appendChild(document.createElement("p"));m&&g.appendChild(p.serializeNode(f.text(m,u)))})}}else n.someProp("transformPastedHTML",h=>{t=h(t,n)}),s=Sf(t),wn&&vf(s);let c=s&&s.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let h=+d[3];h>0;h--){let u=s.firstChild;for(;u&&u.nodeType!=1;)u=u.nextSibling;if(!u)break;s=u}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Ht.fromSchema(n.state.schema)).parseSlice(s,{preserveWhitespace:!!(a||d),context:o,ruleFromNode(u){return u.nodeName=="BR"&&!u.nextSibling&&u.parentNode&&!yf.test(u.parentNode.nodeName)?{ignore:!0}:null}})),d)l=xf(cs(l,+d[1],+d[2]),d[4]);else if(l=C.maxOpen(bf(l.content,o),!0),l.openStart||l.openEnd){let h=0,u=0;for(let f=l.content.firstChild;h<l.openStart&&!f.type.spec.isolating;h++,f=f.firstChild);for(let f=l.content.lastChild;u<l.openEnd&&!f.type.spec.isolating;u++,f=f.lastChild);l=cs(l,h,u)}return n.someProp("transformPasted",h=>{l=h(l,n)}),l}const yf=/^(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 bf(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let o=e.node(t).contentMatchAt(e.index(t)),r,s=[];if(n.forEach(l=>{if(!s)return;let a=o.findWrapping(l.type),c;if(!a)return s=null;if(c=s.length&&r.length&&Aa(a,r,l,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=Oa(s[s.length-1],r.length));let d=Ma(l,a);s.push(d),o=o.matchType(d.type),r=a}}),s)return w.from(s)}return n}function Ma(n,e,t=0){for(let i=e.length-1;i>=t;i--)n=e[i].create(null,w.from(n));return n}function Aa(n,e,t,i,o){if(o<n.length&&o<e.length&&n[o]==e[o]){let r=Aa(n,e,t,i.lastChild,o+1);if(r)return i.copy(i.content.replaceChild(i.childCount-1,r));if(i.contentMatchAt(i.childCount).matchType(o==n.length-1?t.type:n[o+1]))return i.copy(i.content.append(w.from(Ma(t,n,o+1))))}}function Oa(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,Oa(n.lastChild,e-1)),i=n.contentMatchAt(n.childCount).fillBefore(w.empty,!0);return n.copy(t.append(i))}function yo(n,e,t,i,o,r){let s=e<0?n.firstChild:n.lastChild,l=s.content;return n.childCount>1&&(r=0),o<i-1&&(l=yo(l,e,t,i,o+1,r)),o>=t&&(l=e<0?s.contentMatchAt(0).fillBefore(l,r<=o).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(w.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,s.copy(l))}function cs(n,e,t){return e<n.openStart&&(n=new C(yo(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new C(yo(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const Ea={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 ds=null;function Na(){return ds||(ds=document.implementation.createHTMLDocument("title"))}let _i=null;function wf(n){let e=window.trustedTypes;return e?(_i||(_i=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),_i.createHTML(n)):n}function Sf(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Na().createElement("div"),i=/<([a-z][^>\s]+)/i.exec(n),o;if((o=i&&Ea[i[1].toLowerCase()])&&(n=o.map(r=>"<"+r+">").join("")+n+o.map(r=>"</"+r+">").reverse().join("")),t.innerHTML=wf(n),o)for(let r=0;r<o.length;r++)t=t.querySelector(o[r])||t;return t}function vf(n){let e=n.querySelectorAll(Z?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let i=e[t];i.childNodes.length==1&&i.textContent==" "&&i.parentNode&&i.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),i)}}function xf(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,i;try{i=JSON.parse(e)}catch{return n}let{content:o,openStart:r,openEnd:s}=n;for(let l=i.length-2;l>=0;l-=2){let a=t.nodes[i[l]];if(!a||a.hasRequiredAttrs())break;o=w.from(a.create(i[l+1],o)),r++,s++}return new C(o,r,s)}const ne={},ie={},Cf={touchstart:!0,touchmove:!0};class kf{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastAndroidDelete=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 Tf(n){for(let e in ne){let t=ne[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=i=>{Af(n,i)&&!Bo(n,i)&&(n.editable||!(i.type in ie))&&t(n,i)},Cf[e]?{passive:!0}:void 0)}te&&n.dom.addEventListener("input",()=>null),bo(n)}function je(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function Mf(n){n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function bo(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=i=>Bo(n,i))})}function Bo(n,e){return n.someProp("handleDOMEvents",t=>{let i=t[e.type];return i?i(n,e)||e.defaultPrevented:!1})}function Af(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function Of(n,e){!Bo(n,e)&&ne[e.type]&&(n.editable||!(e.type in ie))&&ne[e.type](n,e)}ie.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!Ia(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(ge&&Z&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),_t&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let i=Date.now();n.input.lastIOSEnter=i,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==i&&(n.someProp("handleKeyDown",o=>o(n,ot(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",i=>i(n,t))||gf(n,t)?t.preventDefault():je(n,"key")};ie.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};ie.keypress=(n,e)=>{let t=e;if(Ia(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||ue&&t.metaKey)return;if(n.someProp("handleKeyPress",o=>o(n,t))){t.preventDefault();return}let i=n.state.selection;if(!(i instanceof N)||!i.$from.sameParent(i.$to)){let o=String.fromCharCode(t.charCode);!/[\r\n]/.test(o)&&!n.someProp("handleTextInput",r=>r(n,i.$from.pos,i.$to.pos,o))&&n.dispatch(n.state.tr.insertText(o).scrollIntoView()),t.preventDefault()}};function yi(n){return{left:n.clientX,top:n.clientY}}function Ef(n,e){let t=e.x-n.clientX,i=e.y-n.clientY;return t*t+i*i<100}function Ho(n,e,t,i,o){if(i==-1)return!1;let r=n.state.doc.resolve(i);for(let s=r.depth+1;s>0;s--)if(n.someProp(e,l=>s>r.depth?l(n,t,r.nodeAfter,r.before(s),o,!0):l(n,t,r.node(s),r.before(s),o,!1)))return!0;return!1}function zt(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let i=n.state.tr.setSelection(e);i.setMeta("pointer",!0),n.dispatch(i)}function Nf(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),i=t.nodeAfter;return i&&i.isAtom&&O.isSelectable(i)?(zt(n,new O(t)),!0):!1}function Df(n,e){if(e==-1)return!1;let t=n.state.selection,i,o;t instanceof O&&(i=t.node);let r=n.state.doc.resolve(e);for(let s=r.depth+1;s>0;s--){let l=s>r.depth?r.nodeAfter:r.node(s);if(O.isSelectable(l)){i&&t.$from.depth>0&&s>=t.$from.depth&&r.before(t.$from.depth+1)==t.$from.pos?o=r.before(t.$from.depth):o=r.before(s);break}}return o!=null?(zt(n,O.create(n.state.doc,o)),!0):!1}function If(n,e,t,i,o){return Ho(n,"handleClickOn",e,t,i)||n.someProp("handleClick",r=>r(n,e,i))||(o?Df(n,t):Nf(n,t))}function Pf(n,e,t,i){return Ho(n,"handleDoubleClickOn",e,t,i)||n.someProp("handleDoubleClick",o=>o(n,e,i))}function Rf(n,e,t,i){return Ho(n,"handleTripleClickOn",e,t,i)||n.someProp("handleTripleClick",o=>o(n,e,i))||Vf(n,t,i)}function Vf(n,e,t){if(t.button!=0)return!1;let i=n.state.doc;if(e==-1)return i.inlineContent?(zt(n,N.create(i,0,i.content.size)),!0):!1;let o=i.resolve(e);for(let r=o.depth+1;r>0;r--){let s=r>o.depth?o.nodeAfter:o.node(r),l=o.before(r);if(s.inlineContent)zt(n,N.create(i,l+1,l+1+s.content.size));else if(O.isSelectable(s))zt(n,O.create(i,l));else continue;return!0}}function Fo(n){return ri(n)}const Da=ue?"metaKey":"ctrlKey";ne.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let i=Fo(n),o=Date.now(),r="singleClick";o-n.input.lastClick.time<500&&Ef(t,n.input.lastClick)&&!t[Da]&&(n.input.lastClick.type=="singleClick"?r="doubleClick":n.input.lastClick.type=="doubleClick"&&(r="tripleClick")),n.input.lastClick={time:o,x:t.clientX,y:t.clientY,type:r};let s=n.posAtCoords(yi(t));s&&(r=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new Lf(n,s,t,!!i)):(r=="doubleClick"?Pf:Rf)(n,s.pos,s.inside,t)?t.preventDefault():je(n,"pointer"))};class Lf{constructor(e,t,i,o){this.view=e,this.pos=t,this.event=i,this.flushed=o,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!i[Da],this.allowDefault=i.shiftKey;let r,s;if(t.inside>-1)r=e.state.doc.nodeAt(t.inside),s=t.inside;else{let d=e.state.doc.resolve(t.pos);r=d.parent,s=d.depth?d.before():0}const l=o?null:i.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.dom.nodeType==1?a.dom:null;let{selection:c}=e.state;(i.button==0&&r.type.spec.draggable&&r.type.spec.selectable!==!1||c instanceof O&&c.from<=s&&c.to>s)&&(this.mightDrag={node:r,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&we&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),je(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(()=>Re(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(yi(e))),this.updateAllowDefault(e),this.allowDefault||!t?je(this.view,"pointer"):If(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||te&&this.mightDrag&&!this.mightDrag.node.isAtom||Z&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(zt(this.view,E.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):je(this.view,"pointer")}move(e){this.updateAllowDefault(e),je(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)}}ne.touchstart=n=>{n.input.lastTouch=Date.now(),Fo(n),je(n,"pointer")};ne.touchmove=n=>{n.input.lastTouch=Date.now(),je(n,"pointer")};ne.contextmenu=n=>Fo(n);function Ia(n,e){return n.composing?!0:te&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const zf=ge?5e3:-1;ie.compositionstart=ie.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof N&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(i=>i.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),ri(n,!0),n.markCursor=null;else if(ri(n,!e.selection.empty),we&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let i=n.domSelectionRange();for(let o=i.focusNode,r=i.focusOffset;o&&o.nodeType==1&&r!=0;){let s=r<0?o.lastChild:o.childNodes[r-1];if(!s)break;if(s.nodeType==3){let l=n.domSelection();l&&l.collapse(s,s.nodeValue.length);break}else o=s,r=-1}}n.input.composing=!0}Pa(n,zf)};ie.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,Pa(n,20))};function Pa(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>ri(n),e))}function Ra(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Hf());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function Bf(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=Eu(e.focusNode,e.focusOffset),i=Nu(e.focusNode,e.focusOffset);if(t&&i&&t!=i){let o=i.pmViewDesc,r=n.domObserver.lastChangedTextNode;if(t==r||i==r)return r;if(!o||!o.isText(i.nodeValue))return i;if(n.input.compositionNode==i){let s=t.pmViewDesc;if(!(!s||!s.isText(t.nodeValue)))return i}}return t||i}function Hf(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function ri(n,e=!1){if(!(ge&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Ra(n),e||n.docView&&n.docView.dirty){let t=Lo(n);return t&&!t.eq(n.state.selection)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!n.state.selection.empty?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function Ff(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let i=getSelection(),o=document.createRange();o.selectNodeContents(e),n.dom.blur(),i.removeAllRanges(),i.addRange(o),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const fn=re&&Je<15||_t&&Vu<604;ne.copy=ie.cut=(n,e)=>{let t=e,i=n.state.selection,o=t.type=="cut";if(i.empty)return;let r=fn?null:t.clipboardData,s=i.content(),{dom:l,text:a}=ka(n,s);r?(t.preventDefault(),r.clearData(),r.setData("text/html",l.innerHTML),r.setData("text/plain",a)):Ff(n,l),o&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function $f(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function Wf(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,i=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(i.contentEditable="true"),i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus();let o=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),i.parentNode&&i.parentNode.removeChild(i),t?pn(n,i.value,null,o,e):pn(n,i.textContent,i.innerHTML,o,e)},50)}function pn(n,e,t,i,o){let r=Ta(n,e,t,i,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,o,r||C.empty)))return!0;if(!r)return!1;let s=$f(r),l=s?n.state.tr.replaceSelectionWith(s,i):n.state.tr.replaceSelection(r);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Va(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}ie.paste=(n,e)=>{let t=e;if(n.composing&&!ge)return;let i=fn?null:t.clipboardData,o=n.input.shiftKey&&n.input.lastKeyCode!=45;i&&pn(n,Va(i),i.getData("text/html"),o,t)?t.preventDefault():Wf(n,t)};class La{constructor(e,t,i){this.slice=e,this.move=t,this.node=i}}const za=ue?"altKey":"ctrlKey";ne.dragstart=(n,e)=>{let t=e,i=n.input.mouseDown;if(i&&i.done(),!t.dataTransfer)return;let o=n.state.selection,r=o.empty?null:n.posAtCoords(yi(t)),s;if(!(r&&r.pos>=o.from&&r.pos<=(o instanceof O?o.to-1:o.to))){if(i&&i.mightDrag)s=O.create(n.state.doc,i.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let h=n.docView.nearestDesc(t.target,!0);h&&h.node.type.spec.draggable&&h!=n.docView&&(s=O.create(n.state.doc,h.posBefore))}}let l=(s||n.state.selection).content(),{dom:a,text:c,slice:d}=ka(n,l);(!t.dataTransfer.files.length||!Z||aa>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(fn?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",fn||t.dataTransfer.setData("text/plain",c),n.dragging=new La(d,!t[za],s)};ne.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};ie.dragover=ie.dragenter=(n,e)=>e.preventDefault();ie.drop=(n,e)=>{let t=e,i=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let o=n.posAtCoords(yi(t));if(!o)return;let r=n.state.doc.resolve(o.pos),s=i&&i.slice;s?n.someProp("transformPasted",p=>{s=p(s,n)}):s=Ta(n,Va(t.dataTransfer),fn?null:t.dataTransfer.getData("text/html"),!1,r);let l=!!(i&&!t[za]);if(n.someProp("handleDrop",p=>p(n,t,s||C.empty,l))){t.preventDefault();return}if(!s)return;t.preventDefault();let a=s?Vh(n.state.doc,r.pos,s):r.pos;a==null&&(a=r.pos);let c=n.state.tr;if(l){let{node:p}=i;p?p.replace(c):c.deleteSelection()}let d=c.mapping.map(a),h=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,u=c.doc;if(h?c.replaceRangeWith(d,d,s.content.firstChild):c.replaceRange(d,d,s),c.doc.eq(u))return;let f=c.doc.resolve(d);if(h&&O.isSelectable(s.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(s.content.firstChild))c.setSelection(new O(f));else{let p=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((m,g,y,x)=>p=x),c.setSelection(zo(n,f,c.doc.resolve(p)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))};ne.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&Re(n)},20))};ne.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)};ne.beforeinput=(n,e)=>{if(Z&&ge&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:i}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=i||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",r=>r(n,ot(8,"Backspace")))))return;let{$cursor:o}=n.state.selection;o&&o.pos>0&&n.dispatch(n.state.tr.delete(o.pos-1,o.pos).scrollIntoView())},50)}};for(let n in ie)ne[n]=ie[n];function mn(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class si{constructor(e,t){this.toDOM=e,this.spec=t||ft,this.side=this.spec.side||0}map(e,t,i,o){let{pos:r,deleted:s}=e.mapResult(t.from+o,this.side<0?-1:1);return s?null:new oe(r-i,r-i,this)}valid(){return!0}eq(e){return this==e||e instanceof si&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&mn(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Ue{constructor(e,t){this.attrs=e,this.spec=t||ft}map(e,t,i,o){let r=e.map(t.from+o,this.spec.inclusiveStart?-1:1)-i,s=e.map(t.to+o,this.spec.inclusiveEnd?1:-1)-i;return r>=s?null:new oe(r,s,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Ue&&mn(this.attrs,e.attrs)&&mn(this.spec,e.spec)}static is(e){return e.type instanceof Ue}destroy(){}}class $o{constructor(e,t){this.attrs=e,this.spec=t||ft}map(e,t,i,o){let r=e.mapResult(t.from+o,1);if(r.deleted)return null;let s=e.mapResult(t.to+o,-1);return s.deleted||s.pos<=r.pos?null:new oe(r.pos-i,s.pos-i,this)}valid(e,t){let{index:i,offset:o}=e.content.findIndex(t.from),r;return o==t.from&&!(r=e.child(i)).isText&&o+r.nodeSize==t.to}eq(e){return this==e||e instanceof $o&&mn(this.attrs,e.attrs)&&mn(this.spec,e.spec)}destroy(){}}class oe{constructor(e,t,i){this.from=e,this.to=t,this.type=i}copy(e,t){return new oe(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,i){return this.type.map(e,this,t,i)}static widget(e,t,i){return new oe(e,e,new si(t,i))}static inline(e,t,i,o){return new oe(e,t,new Ue(i,o))}static node(e,t,i,o){return new oe(e,t,new $o(i,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof Ue}get widget(){return this.type instanceof si}}const Ot=[],ft={};class z{constructor(e,t){this.local=e.length?e:Ot,this.children=t.length?t:Ot}static create(e,t){return t.length?li(t,e,0,ft):G}find(e,t,i){let o=[];return this.findInner(e??0,t??1e9,o,0,i),o}findInner(e,t,i,o,r){for(let s=0;s<this.local.length;s++){let l=this.local[s];l.from<=t&&l.to>=e&&(!r||r(l.spec))&&i.push(l.copy(l.from+o,l.to+o))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<t&&this.children[s+1]>e){let l=this.children[s]+1;this.children[s+2].findInner(e-l,t-l,i,o+l,r)}}map(e,t,i){return this==G||e.maps.length==0?this:this.mapInner(e,t,0,0,i||ft)}mapInner(e,t,i,o,r){let s;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,i,o);a&&a.type.valid(t,a)?(s||(s=[])).push(a):r.onRemove&&r.onRemove(this.local[l].spec)}return this.children.length?_f(this.children,s||[],e,t,i,o,r):s?new z(s.sort(pt),Ot):G}add(e,t){return t.length?this==G?z.create(e,t):this.addInner(e,t,0):this}addInner(e,t,i){let o,r=0;e.forEach((l,a)=>{let c=a+i,d;if(d=Ha(t,l,c)){for(o||(o=this.children.slice());r<o.length&&o[r]<a;)r+=3;o[r]==a?o[r+2]=o[r+2].addInner(l,d,c+1):o.splice(r,0,a,a+l.nodeSize,li(d,l,c+1,ft)),r+=3}});let s=Ba(r?Fa(t):t,-i);for(let l=0;l<s.length;l++)s[l].type.valid(e,s[l])||s.splice(l--,1);return new z(s.length?this.local.concat(s).sort(pt):this.local,o||this.children)}remove(e){return e.length==0||this==G?this:this.removeInner(e,0)}removeInner(e,t){let i=this.children,o=this.local;for(let r=0;r<i.length;r+=3){let s,l=i[r]+t,a=i[r+1]+t;for(let d=0,h;d<e.length;d++)(h=e[d])&&h.from>l&&h.to<a&&(e[d]=null,(s||(s=[])).push(h));if(!s)continue;i==this.children&&(i=this.children.slice());let c=i[r+2].removeInner(s,l+1);c!=G?i[r+2]=c:(i.splice(r,3),r-=3)}if(o.length){for(let r=0,s;r<e.length;r++)if(s=e[r])for(let l=0;l<o.length;l++)o[l].eq(s,t)&&(o==this.local&&(o=this.local.slice()),o.splice(l--,1))}return i==this.children&&o==this.local?this:o.length||i.length?new z(o,i):G}forChild(e,t){if(this==G)return this;if(t.isLeaf)return z.empty;let i,o;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(i=this.children[l+2]);break}let r=e+1,s=r+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<s&&a.to>r&&a.type instanceof Ue){let c=Math.max(r,a.from)-r,d=Math.min(s,a.to)-r;c<d&&(o||(o=[])).push(a.copy(c,d))}}if(o){let l=new z(o.sort(pt),Ot);return i?new We([l,i]):l}return i||G}eq(e){if(this==e)return!0;if(!(e instanceof z)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return Wo(this.localsInner(e))}localsInner(e){if(this==G)return Ot;if(e.inlineContent||!this.local.some(Ue.is))return this.local;let t=[];for(let i=0;i<this.local.length;i++)this.local[i].type instanceof Ue||t.push(this.local[i]);return t}forEachSet(e){e(this)}}z.empty=new z([],[]);z.removeOverlap=Wo;const G=z.empty;class We{constructor(e){this.members=e}map(e,t){const i=this.members.map(o=>o.map(e,t,ft));return We.from(i)}forChild(e,t){if(t.isLeaf)return z.empty;let i=[];for(let o=0;o<this.members.length;o++){let r=this.members[o].forChild(e,t);r!=G&&(r instanceof We?i=i.concat(r.members):i.push(r))}return We.from(i)}eq(e){if(!(e instanceof We)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,i=!0;for(let o=0;o<this.members.length;o++){let r=this.members[o].localsInner(e);if(r.length)if(!t)t=r;else{i&&(t=t.slice(),i=!1);for(let s=0;s<r.length;s++)t.push(r[s])}}return t?Wo(i?t:t.sort(pt)):Ot}static from(e){switch(e.length){case 0:return G;case 1:return e[0];default:return new We(e.every(t=>t instanceof z)?e:e.reduce((t,i)=>t.concat(i instanceof z?i:i.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function _f(n,e,t,i,o,r,s){let l=n.slice();for(let c=0,d=r;c<t.maps.length;c++){let h=0;t.maps[c].forEach((u,f,p,m)=>{let g=m-p-(f-u);for(let y=0;y<l.length;y+=3){let x=l[y+1];if(x<0||u>x+d-h)continue;let b=l[y]+d-h;f>=b?l[y+1]=u<=b?-2:-1:u>=d&&g&&(l[y]+=g,l[y+1]+=g)}h+=g}),d=t.maps[c].map(d,-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 d=t.map(n[c]+r),h=d-o;if(h<0||h>=i.content.size){a=!0;continue}let u=t.map(n[c+1]+r,-1),f=u-o,{index:p,offset:m}=i.content.findIndex(h),g=i.maybeChild(p);if(g&&m==h&&m+g.nodeSize==f){let y=l[c+2].mapInner(t,g,d+1,n[c]+r+1,s);y!=G?(l[c]=h,l[c+1]=f,l[c+2]=y):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=Kf(l,n,e,t,o,r,s),d=li(c,i,0,s);e=d.local;for(let h=0;h<l.length;h+=3)l[h+1]<0&&(l.splice(h,3),h-=3);for(let h=0,u=0;h<d.children.length;h+=3){let f=d.children[h];for(;u<l.length&&l[u]<f;)u+=3;l.splice(u,0,d.children[h],d.children[h+1],d.children[h+2])}}return new z(e.sort(pt),l)}function Ba(n,e){if(!e||!n.length)return n;let t=[];for(let i=0;i<n.length;i++){let o=n[i];t.push(new oe(o.from+e,o.to+e,o.type))}return t}function Kf(n,e,t,i,o,r,s){function l(a,c){for(let d=0;d<a.local.length;d++){let h=a.local[d].map(i,o,c);h?t.push(h):s.onRemove&&s.onRemove(a.local[d].spec)}for(let d=0;d<a.children.length;d+=3)l(a.children[d+2],a.children[d]+c+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+r+1);return t}function Ha(n,e,t){if(e.isLeaf)return null;let i=t+e.nodeSize,o=null;for(let r=0,s;r<n.length;r++)(s=n[r])&&s.from>t&&s.to<i&&((o||(o=[])).push(s),n[r]=null);return o}function Fa(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function li(n,e,t,i){let o=[],r=!1;e.forEach((l,a)=>{let c=Ha(n,l,a+t);if(c){r=!0;let d=li(c,l,t+a+1,i);d!=G&&o.push(a,a+l.nodeSize,d)}});let s=Ba(r?Fa(n):n,-t).sort(pt);for(let l=0;l<s.length;l++)s[l].type.valid(e,s[l])||(i.onRemove&&i.onRemove(s[l].spec),s.splice(l--,1));return s.length||o.length?new z(s,o):G}function pt(n,e){return n.from-e.from||n.to-e.to}function Wo(n){let e=n;for(let t=0;t<e.length-1;t++){let i=e[t];if(i.from!=i.to)for(let o=t+1;o<e.length;o++){let r=e[o];if(r.from==i.from){r.to!=i.to&&(e==n&&(e=n.slice()),e[o]=r.copy(r.from,i.to),hs(e,o+1,r.copy(i.to,r.to)));continue}else{r.from<i.to&&(e==n&&(e=n.slice()),e[t]=i.copy(i.from,r.from),hs(e,o,i.copy(r.from,i.to)));break}}}return e}function hs(n,e,t){for(;e<n.length&&pt(t,n[e])>0;)e++;n.splice(e,0,t)}function Ki(n){let e=[];return n.someProp("decorations",t=>{let i=t(n.state);i&&i!=G&&e.push(i)}),n.cursorWrapper&&e.push(z.create(n.state.doc,[n.cursorWrapper.deco])),We.from(e)}const qf={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},jf=re&&Je<=11;class Jf{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 Gf{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Jf,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(i=>{for(let o=0;o<i.length;o++)this.queue.push(i[o]);re&&Je<=11&&i.some(o=>o.type=="childList"&&o.removedNodes.length||o.type=="characterData"&&o.oldValue.length>o.target.nodeValue.length)?this.flushSoon():this.flush()}),jf&&(this.onCharData=i=>{this.queue.push({target:i.target,type:"characterData",oldValue:i.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,qf)),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 t=0;t<e.length;t++)this.queue.push(e[t]);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(ns(this.view)){if(this.suppressingSelectionUpdates)return Re(this.view);if(re&&Je<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&yt(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 t=new Set,i;for(let r=e.focusNode;r;r=un(r))t.add(r);for(let r=e.anchorNode;r;r=un(r))if(t.has(r)){i=r;break}let o=i&&this.view.docView.nearestDesc(i);if(o&&o.ignoreMutation({type:"selection",target:i.nodeType==3?i.parentNode:i}))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 t=this.pendingRecords();t.length&&(this.queue=[]);let i=e.domSelectionRange(),o=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(i)&&ns(e)&&!this.ignoreSelectionChange(i),r=-1,s=-1,l=!1,a=[];if(e.editable)for(let d=0;d<t.length;d++){let h=this.registerMutation(t[d],a);h&&(r=r<0?h.from:Math.min(h.from,r),s=s<0?h.to:Math.max(h.to,s),h.typeOver&&(l=!0))}if(we&&a.length){let d=a.filter(h=>h.nodeName=="BR");if(d.length==2){let[h,u]=d;h.parentNode&&h.parentNode.parentNode==u.parentNode?u.remove():h.remove()}else{let{focusNode:h}=this.currentSelection;for(let u of d){let f=u.parentNode;f&&f.nodeName=="LI"&&(!h||Yf(e,h)!=f)&&u.remove()}}}let c=null;r<0&&o&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&mi(i)&&(c=Lo(e))&&c.eq(E.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Re(e),this.currentSelection.set(i),e.scrollToSelection()):(r>-1||o)&&(r>-1&&(e.docView.markDirty(r,s),Uf(e)),this.handleDOMChange(r,s,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(i)||Re(e),this.currentSelection.set(i))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let i=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(i==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!i||i.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let h=e.addedNodes[d];t.push(h),h.nodeType==3&&(this.lastChangedTextNode=h)}if(i.contentDOM&&i.contentDOM!=i.dom&&!i.contentDOM.contains(e.target))return{from:i.posBefore,to:i.posAfter};let o=e.previousSibling,r=e.nextSibling;if(re&&Je<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:h,nextSibling:u}=e.addedNodes[d];(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(o=h),(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(r=u)}let s=o&&o.parentNode==e.target?q(o)+1:0,l=i.localPosFromDOM(e.target,s,-1),a=r&&r.parentNode==e.target?q(r):e.target.childNodes.length,c=i.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:i.posAtStart-i.border,to:i.posAtEnd+i.border}:(this.lastChangedTextNode=e.target,{from:i.posAtStart,to:i.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let us=new WeakMap,fs=!1;function Uf(n){if(!us.has(n)&&(us.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=we,fs)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."),fs=!0}}function ps(n,e){let t=e.startContainer,i=e.startOffset,o=e.endContainer,r=e.endOffset,s=n.domAtPos(n.state.selection.anchor);return yt(s.node,s.offset,o,r)&&([t,i,o,r]=[o,r,t,i]),{anchorNode:t,anchorOffset:i,focusNode:o,focusOffset:r}}function Zf(n,e){if(e.getComposedRanges){let o=e.getComposedRanges(n.root)[0];if(o)return ps(n,o)}let t;function i(o){o.preventDefault(),o.stopImmediatePropagation(),t=o.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",i,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",i,!0),t?ps(n,t):null}function Yf(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let i=n.docView.nearestDesc(t,!0);if(i&&i.node.isBlock)return t}return null}function Xf(n,e,t){let{node:i,fromOffset:o,toOffset:r,from:s,to:l}=n.docView.parseRange(e,t),a=n.domSelectionRange(),c,d=a.anchorNode;if(d&&n.dom.contains(d.nodeType==1?d:d.parentNode)&&(c=[{node:d,offset:a.anchorOffset}],mi(a)||c.push({node:a.focusNode,offset:a.focusOffset})),Z&&n.input.lastKeyCode===8)for(let g=r;g>o;g--){let y=i.childNodes[g-1],x=y.pmViewDesc;if(y.nodeName=="BR"&&!x){r=g;break}if(!x||x.size)break}let h=n.state.doc,u=n.someProp("domParser")||Ht.fromSchema(n.state.schema),f=h.resolve(s),p=null,m=u.parse(i,{topNode:f.parent,topMatch:f.parent.contentMatchAt(f.index()),topOpen:!0,from:o,to:r,preserveWhitespace:f.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:Qf,context:f});if(c&&c[0].pos!=null){let g=c[0].pos,y=c[1]&&c[1].pos;y==null&&(y=g),p={anchor:g+s,head:y+s}}return{doc:m,sel:p,from:s,to:l}}function Qf(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(te&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||te&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}const ep=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function tp(n,e,t,i,o){let r=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let M=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,R=Lo(n,M);if(R&&!n.state.selection.eq(R)){if(Z&&ge&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",V=>V(n,ot(13,"Enter"))))return;let P=n.state.tr.setSelection(R);M=="pointer"?P.setMeta("pointer",!0):M=="key"&&P.scrollIntoView(),r&&P.setMeta("composition",r),n.dispatch(P)}return}let s=n.state.doc.resolve(e),l=s.sharedDepth(t);e=s.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,c=Xf(n,e,t),d=n.state.doc,h=d.slice(c.from,c.to),u,f;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(u=n.state.selection.to,f="end"):(u=n.state.selection.from,f="start"),n.input.lastKeyCode=null;let p=op(h.content,c.doc.content,c.from,u,f);if(p&&n.input.domChangeCount++,(_t&&n.input.lastIOSEnter>Date.now()-225||ge)&&o.some(M=>M.nodeType==1&&!ep.test(M.nodeName))&&(!p||p.endA>=p.endB)&&n.someProp("handleKeyDown",M=>M(n,ot(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!p)if(i&&a instanceof N&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.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=ms(n,n.state.doc,c.sel);if(M&&!M.eq(n.state.selection)){let R=n.state.tr.setSelection(M);r&&R.setMeta("composition",r),n.dispatch(R)}}return}n.state.selection.from<n.state.selection.to&&p.start==p.endB&&n.state.selection instanceof N&&(p.start>n.state.selection.from&&p.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?p.start=n.state.selection.from:p.endA<n.state.selection.to&&p.endA>=n.state.selection.to-2&&n.state.selection.to<=c.to&&(p.endB+=n.state.selection.to-p.endA,p.endA=n.state.selection.to)),re&&Je<=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),y=d.resolve(p.start),x=m.sameParent(g)&&m.parent.inlineContent&&y.end()>=p.endA,b;if((_t&&n.input.lastIOSEnter>Date.now()-225&&(!x||o.some(M=>M.nodeName=="DIV"||M.nodeName=="P"))||!x&&m.pos<c.doc.content.size&&!m.sameParent(g)&&(b=E.findFrom(c.doc.resolve(m.pos+1),1,!0))&&b.head==g.pos)&&n.someProp("handleKeyDown",M=>M(n,ot(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>p.start&&ip(d,p.start,p.endA,m,g)&&n.someProp("handleKeyDown",M=>M(n,ot(8,"Backspace")))){ge&&Z&&n.domObserver.suppressSelectionUpdates();return}Z&&ge&&p.endB==p.start&&(n.input.lastAndroidDelete=Date.now()),ge&&!x&&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(()=>{n.someProp("handleKeyDown",function(M){return M(n,ot(13,"Enter"))})},20));let S=p.start,v=p.endA,k,A,L;if(x){if(m.pos==g.pos)re&&Je<=11&&m.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>Re(n),20)),k=n.state.tr.delete(S,v),A=d.resolve(p.start).marksAcross(d.resolve(p.endA));else if(p.endA==p.endB&&(L=np(m.parent.content.cut(m.parentOffset,g.parentOffset),y.parent.content.cut(y.parentOffset,p.endA-y.start()))))k=n.state.tr,L.type=="add"?k.addMark(S,v,L.mark):k.removeMark(S,v,L.mark);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);if(n.someProp("handleTextInput",R=>R(n,S,v,M)))return;k=n.state.tr.insertText(M,S,v)}}if(k||(k=n.state.tr.replace(S,v,c.doc.slice(p.start-c.from,p.endB-c.from))),c.sel){let M=ms(n,k.doc,c.sel);M&&!(Z&&ge&&n.composing&&M.empty&&(p.start!=p.endB||n.input.lastAndroidDelete<Date.now()-100)&&(M.head==S||M.head==k.mapping.map(v)-1)||re&&M.empty&&M.head==S)&&k.setSelection(M)}A&&k.ensureMarks(A),r&&k.setMeta("composition",r),n.dispatch(k.scrollIntoView())}function ms(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:zo(n,e.resolve(t.anchor),e.resolve(t.head))}function np(n,e){let t=n.firstChild.marks,i=e.firstChild.marks,o=t,r=i,s,l,a;for(let d=0;d<i.length;d++)o=i[d].removeFromSet(o);for(let d=0;d<t.length;d++)r=t[d].removeFromSet(r);if(o.length==1&&r.length==0)l=o[0],s="add",a=d=>d.mark(l.addToSet(d.marks));else if(o.length==0&&r.length==1)l=r[0],s="remove",a=d=>d.mark(l.removeFromSet(d.marks));else return null;let c=[];for(let d=0;d<e.childCount;d++)c.push(a(e.child(d)));if(w.from(c).eq(n))return{mark:l,type:s}}function ip(n,e,t,i,o){if(t-e<=o.pos-i.pos||qi(i,!0,!1)<o.pos)return!1;let r=n.resolve(e);if(!i.parent.isTextblock){let l=r.nodeAfter;return l!=null&&t==e+l.nodeSize}if(r.parentOffset<r.parent.content.size||!r.parent.isTextblock)return!1;let s=n.resolve(qi(r,!0,!0));return!s.parent.isTextblock||s.pos>t||qi(s,!0,!1)<t?!1:i.parent.content.cut(i.parentOffset).eq(s.parent.content)}function qi(n,e,t){let i=n.depth,o=e?n.end():n.pos;for(;i>0&&(e||n.indexAfter(i)==n.node(i).childCount);)i--,o++,e=!1;if(t){let r=n.node(i).maybeChild(n.indexAfter(i));for(;r&&!r.isLeaf;)r=r.firstChild,o++}return o}function op(n,e,t,i,o){let r=n.findDiffStart(e,t);if(r==null)return null;let{a:s,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(o=="end"){let a=Math.max(0,r-Math.min(s,l));i-=s+a-r}if(s<r&&n.size<e.size){let a=i<=r&&i>=s?r-i:0;r-=a,r&&r<e.size&&gs(e.textBetween(r-1,r+1))&&(r+=a?1:-1),l=r+(l-s),s=r}else if(l<r){let a=i<=r&&i>=l?r-i:0;r-=a,r&&r<n.size&&gs(n.textBetween(r-1,r+1))&&(r+=a?1:-1),s=r+(s-l),l=r}return{start:r,endA:s,endB:l}}function gs(n){if(n.length!=2)return!1;let e=n.charCodeAt(0),t=n.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}class rp{constructor(e,t){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 kf,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(vs),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=ws(this),bs(this),this.nodeViews=Ss(this),this.docView=Zr(this.state.doc,ys(this),Ki(this),this.dom,this),this.domObserver=new Gf(this,(i,o,r,s)=>tp(this,i,o,r,s)),this.domObserver.start(),Tf(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 t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&bo(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(vs),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let i in this._props)t[i]=this._props[i];t.state=this.state;for(let i in e)t[i]=e[i];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var i;let o=this.state,r=!1,s=!1;e.storedMarks&&this.composing&&(Ra(this),s=!0),this.state=e;let l=o.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let f=Ss(this);lp(f,this.nodeViews)&&(this.nodeViews=f,r=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&bo(this),this.editable=ws(this),bs(this);let a=Ki(this),c=ys(this),d=o.plugins!=e.plugins&&!o.doc.eq(e.doc)?"reset":e.scrollToSelection>o.scrollToSelection?"to selection":"preserve",h=r||!this.docView.matchesNode(e.doc,c,a);(h||!e.selection.eq(o.selection))&&(s=!0);let u=d=="preserve"&&s&&this.dom.style.overflowAnchor==null&&Bu(this);if(s){this.domObserver.stop();let f=h&&(re||Z)&&!this.composing&&!o.selection.empty&&!e.selection.empty&&sp(o.selection,e.selection);if(h){let p=Z?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Bf(this)),(r||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Zr(e.doc,c,a,this.dom,this)),p&&!this.trackWrites&&(f=!0)}f||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&cf(this))?Re(this,f):(va(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(o),!((i=this.dragging)===null||i===void 0)&&i.node&&!o.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,o),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():u&&Hu(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof O){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Kr(this,t.getBoundingClientRect(),e)}else Kr(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 t=0;t<this.directPlugins.length;t++){let i=this.directPlugins[t];i.spec.view&&this.pluginViews.push(i.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let i=this.state.plugins[t];i.spec.view&&this.pluginViews.push(i.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let i=this.pluginViews[t];i.update&&i.update(this,e)}}updateDraggedNode(e,t){let i=e.node,o=-1;if(this.state.doc.nodeAt(i.from)==i.node)o=i.from;else{let r=i.from+(this.state.doc.content.size-t.doc.content.size);(r>0&&this.state.doc.nodeAt(r))==i.node&&(o=r)}this.dragging=new La(e.slice,e.move,o<0?void 0:O.create(this.state.doc,o))}someProp(e,t){let i=this._props&&this._props[e],o;if(i!=null&&(o=t?t(i):i))return o;for(let s=0;s<this.directPlugins.length;s++){let l=this.directPlugins[s].props[e];if(l!=null&&(o=t?t(l):l))return o}let r=this.state.plugins;if(r)for(let s=0;s<r.length;s++){let l=r[s].props[e];if(l!=null&&(o=t?t(l):l))return o}}hasFocus(){if(re){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&&Fu(this.dom),Re(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return qu(this,e)}coordsAtPos(e,t=1){return fa(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,i=-1){let o=this.docView.posFromDOM(e,t,i);if(o==null)throw new RangeError("DOM position not inside the editor");return o}endOfTextblock(e,t){return Zu(this,t||this.state,e)}pasteHTML(e,t){return pn(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return pn(this,e,null,!0,t||new ClipboardEvent("paste"))}destroy(){this.docView&&(Mf(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Ki(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Au())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Of(this,e)}dispatch(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){let e=this.domSelection();return e?te&&this.root.nodeType===11&&Iu(this.dom.ownerDocument)==this.dom&&Zf(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function ys(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let i in t)i=="class"?e.class+=" "+t[i]:i=="style"?e.style=(e.style?e.style+";":"")+t[i]:!e[i]&&i!="contenteditable"&&i!="nodeName"&&(e[i]=String(t[i]))}),e.translate||(e.translate="no"),[oe.node(0,n.state.doc.content.size,e)]}function bs(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:oe.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function ws(n){return!n.someProp("editable",e=>e(n.state)===!1)}function sp(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function Ss(n){let e=Object.create(null);function t(i){for(let o in i)Object.prototype.hasOwnProperty.call(e,o)||(e[o]=i[o])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function lp(n,e){let t=0,i=0;for(let o in n){if(n[o]!=e[o])return!0;t++}for(let o in e)i++;return t!=i}function vs(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var wo,So;if(typeof WeakMap<"u"){let n=new WeakMap;wo=e=>n.get(e),So=(e,t)=>(n.set(e,t),t)}else{const n=[];let t=0;wo=i=>{for(let o=0;o<n.length;o+=2)if(n[o]==i)return n[o+1]},So=(i,o)=>(t==10&&(t=0),n[t++]=i,n[t++]=o)}var H=class{constructor(n,e,t,i){this.width=n,this.height=e,this.map=t,this.problems=i}findCell(n){for(let e=0;e<this.map.length;e++){const t=this.map[e];if(t!=n)continue;const i=e%this.width,o=e/this.width|0;let r=i+1,s=o+1;for(let l=1;r<this.width&&this.map[e+l]==t;l++)r++;for(let l=1;s<this.height&&this.map[e+this.width*l]==t;l++)s++;return{left:i,top:o,right:r,bottom:s}}throw new RangeError(`No cell with offset ${n} found`)}colCount(n){for(let e=0;e<this.map.length;e++)if(this.map[e]==n)return e%this.width;throw new RangeError(`No cell with offset ${n} found`)}nextCell(n,e,t){const{left:i,right:o,top:r,bottom:s}=this.findCell(n);return e=="horiz"?(t<0?i==0:o==this.width)?null:this.map[r*this.width+(t<0?i-1:o)]:(t<0?r==0:s==this.height)?null:this.map[i+this.width*(t<0?r-1:s)]}rectBetween(n,e){const{left:t,right:i,top:o,bottom:r}=this.findCell(n),{left:s,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(t,s),top:Math.min(o,a),right:Math.max(i,l),bottom:Math.max(r,c)}}cellsInRect(n){const e=[],t={};for(let i=n.top;i<n.bottom;i++)for(let o=n.left;o<n.right;o++){const r=i*this.width+o,s=this.map[r];t[s]||(t[s]=!0,!(o==n.left&&o&&this.map[r-1]==s||i==n.top&&i&&this.map[r-this.width]==s)&&e.push(s))}return e}positionAt(n,e,t){for(let i=0,o=0;;i++){const r=o+t.child(i).nodeSize;if(i==n){let s=e+n*this.width;const l=(n+1)*this.width;for(;s<l&&this.map[s]<o;)s++;return s==l?r-1:this.map[s]}o=r}}static get(n){return wo(n)||So(n,ap(n))}};function ap(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);const e=cp(n),t=n.childCount,i=[];let o=0,r=null;const s=[];for(let c=0,d=e*t;c<d;c++)i[c]=0;for(let c=0,d=0;c<t;c++){const h=n.child(c);d++;for(let p=0;;p++){for(;o<i.length&&i[o]!=0;)o++;if(p==h.childCount)break;const m=h.child(p),{colspan:g,rowspan:y,colwidth:x}=m.attrs;for(let b=0;b<y;b++){if(b+c>=t){(r||(r=[])).push({type:"overlong_rowspan",pos:d,n:y-b});break}const S=o+b*e;for(let v=0;v<g;v++){i[S+v]==0?i[S+v]=d:(r||(r=[])).push({type:"collision",row:c,pos:d,n:g-v});const k=x&&x[v];if(k){const A=(S+v)%e*2,L=s[A];L==null||L!=k&&s[A+1]==1?(s[A]=k,s[A+1]=1):L==k&&s[A+1]++}}}o+=g,d+=m.nodeSize}const u=(c+1)*e;let f=0;for(;o<u;)i[o++]==0&&f++;f&&(r||(r=[])).push({type:"missing",row:c,n:f}),d++}const l=new H(e,t,i,r);let a=!1;for(let c=0;!a&&c<s.length;c+=2)s[c]!=null&&s[c+1]<t&&(a=!0);return a&&dp(l,s,n),l}function cp(n){let e=-1,t=!1;for(let i=0;i<n.childCount;i++){const o=n.child(i);let r=0;if(t)for(let s=0;s<i;s++){const l=n.child(s);for(let a=0;a<l.childCount;a++){const c=l.child(a);s+c.attrs.rowspan>i&&(r+=c.attrs.colspan)}}for(let s=0;s<o.childCount;s++){const l=o.child(s);r+=l.attrs.colspan,l.attrs.rowspan>1&&(t=!0)}e==-1?e=r:e!=r&&(e=Math.max(e,r))}return e}function dp(n,e,t){n.problems||(n.problems=[]);const i={};for(let o=0;o<n.map.length;o++){const r=n.map[o];if(i[r])continue;i[r]=!0;const s=t.nodeAt(r);if(!s)throw new RangeError(`No cell with offset ${r} found`);let l=null;const a=s.attrs;for(let c=0;c<a.colspan;c++){const d=(o+c)%n.width,h=e[d*2];h!=null&&(!a.colwidth||a.colwidth[c]!=h)&&((l||(l=hp(a)))[c]=h)}l&&n.problems.unshift({type:"colwidth mismatch",pos:r,colwidth:l})}}function hp(n){if(n.colwidth)return n.colwidth.slice();const e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function xs(n,e){if(typeof n=="string")return{};const t=n.getAttribute("data-colwidth"),i=t&&/^\d+(,\d+)*$/.test(t)?t.split(",").map(s=>Number(s)):null,o=Number(n.getAttribute("colspan")||1),r={colspan:o,rowspan:Number(n.getAttribute("rowspan")||1),colwidth:i&&i.length==o?i:null};for(const s in e){const l=e[s].getFromDOM,a=l&&l(n);a!=null&&(r[s]=a)}return r}function Cs(n,e){const t={};n.attrs.colspan!=1&&(t.colspan=n.attrs.colspan),n.attrs.rowspan!=1&&(t.rowspan=n.attrs.rowspan),n.attrs.colwidth&&(t["data-colwidth"]=n.attrs.colwidth.join(","));for(const i in e){const o=e[i].setDOMAttr;o&&o(n.attrs[i],t)}return t}function up(n){const e=n.cellAttributes||{},t={colspan:{default:1},rowspan:{default:1},colwidth:{default:null}};for(const i in e)t[i]={default:e[i].default};return{table:{content:"table_row+",tableRole:"table",isolating:!0,group:n.tableGroup,parseDOM:[{tag:"table"}],toDOM(){return["table",["tbody",0]]}},table_row:{content:"(table_cell | table_header)*",tableRole:"row",parseDOM:[{tag:"tr"}],toDOM(){return["tr",0]}},table_cell:{content:n.cellContent,attrs:t,tableRole:"cell",isolating:!0,parseDOM:[{tag:"td",getAttrs:i=>xs(i,e)}],toDOM(i){return["td",Cs(i,e),0]}},table_header:{content:n.cellContent,attrs:t,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:i=>xs(i,e)}],toDOM(i){return["th",Cs(i,e),0]}}}}function Te(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(const t in n.nodes){const i=n.nodes[t],o=i.spec.tableRole;o&&(e[o]=i)}}return e}var _e=new yn("selectingCells");function vn(n){for(let e=n.depth-1;e>0;e--)if(n.node(e).type.spec.tableRole=="row")return n.node(0).resolve(n.before(e+1));return null}function bi(n){const e=n.selection.$head;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return!0;return!1}function _o(n){const e=n.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 t=vn(e.$head)||fp(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function fp(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){const i=e.type.spec.tableRole;if(i=="cell"||i=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){const i=e.type.spec.tableRole;if(i=="cell"||i=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function vo(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function pp(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function Ko(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function $a(n,e,t){const i=n.node(-1),o=H.get(i),r=n.start(-1),s=o.nextCell(n.pos-r,e,t);return s==null?null:n.node(0).resolve(r+s)}function Kt(n,e,t=1){const i={...n,colspan:n.colspan-t};return i.colwidth&&(i.colwidth=i.colwidth.slice(),i.colwidth.splice(e,t),i.colwidth.some(o=>o>0)||(i.colwidth=null)),i}var W=class De extends E{constructor(e,t=e){const i=e.node(-1),o=H.get(i),r=e.start(-1),s=o.rectBetween(e.pos-r,t.pos-r),l=e.node(0),a=o.cellsInRect(s).filter(d=>d!=t.pos-r);a.unshift(t.pos-r);const c=a.map(d=>{const h=i.nodeAt(d);if(!h)throw RangeError(`No cell with offset ${d} found`);const u=r+d+1;return new Kl(l.resolve(u),l.resolve(u+h.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){const i=e.resolve(t.map(this.$anchorCell.pos)),o=e.resolve(t.map(this.$headCell.pos));if(vo(i)&&vo(o)&&Ko(i,o)){const r=this.$anchorCell.node(-1)!=i.node(-1);return r&&this.isRowSelection()?De.rowSelection(i,o):r&&this.isColSelection()?De.colSelection(i,o):new De(i,o)}return N.between(i,o)}content(){const e=this.$anchorCell.node(-1),t=H.get(e),i=this.$anchorCell.start(-1),o=t.rectBetween(this.$anchorCell.pos-i,this.$headCell.pos-i),r={},s=[];for(let a=o.top;a<o.bottom;a++){const c=[];for(let d=a*t.width+o.left,h=o.left;h<o.right;h++,d++){const u=t.map[d];if(r[u])continue;r[u]=!0;const f=t.findCell(u);let p=e.nodeAt(u);if(!p)throw RangeError(`No cell with offset ${u} found`);const m=o.left-f.left,g=f.right-o.right;if(m>0||g>0){let y=p.attrs;if(m>0&&(y=Kt(y,0,m)),g>0&&(y=Kt(y,y.colspan-g,g)),f.left<o.left){if(p=p.type.createAndFill(y),!p)throw RangeError(`Could not create cell with attrs ${JSON.stringify(y)}`)}else p=p.type.create(y,p.content)}if(f.top<o.top||f.bottom>o.bottom){const y={...p.attrs,rowspan:Math.min(f.bottom,o.bottom)-Math.max(f.top,o.top)};f.top<o.top?p=p.type.createAndFill(y):p=p.type.create(y,p.content)}c.push(p)}s.push(e.child(a).copy(w.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:s;return new C(w.from(l),1,1)}replace(e,t=C.empty){const i=e.steps.length,o=this.ranges;for(let s=0;s<o.length;s++){const{$from:l,$to:a}=o[s],c=e.mapping.slice(i);e.replace(c.map(l.pos),c.map(a.pos),s?C.empty:t)}const r=E.findFrom(e.doc.resolve(e.mapping.slice(i).map(this.to)),-1);r&&e.setSelection(r)}replaceWith(e,t){this.replace(e,new C(w.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),i=H.get(t),o=this.$anchorCell.start(-1),r=i.cellsInRect(i.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o));for(let s=0;s<r.length;s++)e(t.nodeAt(r[s]),o+r[s])}isColSelection(){const e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;const i=e+this.$anchorCell.nodeAfter.attrs.rowspan,o=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(i,o)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){const i=e.node(-1),o=H.get(i),r=e.start(-1),s=o.findCell(e.pos-r),l=o.findCell(t.pos-r),a=e.node(0);return s.top<=l.top?(s.top>0&&(e=a.resolve(r+o.map[s.left])),l.bottom<o.height&&(t=a.resolve(r+o.map[o.width*(o.height-1)+l.right-1]))):(l.top>0&&(t=a.resolve(r+o.map[l.left])),s.bottom<o.height&&(e=a.resolve(r+o.map[o.width*(o.height-1)+s.right-1]))),new De(e,t)}isRowSelection(){const e=this.$anchorCell.node(-1),t=H.get(e),i=this.$anchorCell.start(-1),o=t.colCount(this.$anchorCell.pos-i),r=t.colCount(this.$headCell.pos-i);if(Math.min(o,r)>0)return!1;const s=o+this.$anchorCell.nodeAfter.attrs.colspan,l=r+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,l)==t.width}eq(e){return e instanceof De&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const i=e.node(-1),o=H.get(i),r=e.start(-1),s=o.findCell(e.pos-r),l=o.findCell(t.pos-r),a=e.node(0);return s.left<=l.left?(s.left>0&&(e=a.resolve(r+o.map[s.top*o.width])),l.right<o.width&&(t=a.resolve(r+o.map[o.width*(l.top+1)-1]))):(l.left>0&&(t=a.resolve(r+o.map[l.top*o.width])),s.right<o.width&&(e=a.resolve(r+o.map[o.width*(s.top+1)-1]))),new De(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new De(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,i=t){return new De(e.resolve(t),e.resolve(i))}getBookmark(){return new mp(this.$anchorCell.pos,this.$headCell.pos)}};W.prototype.visible=!1;E.jsonID("cell",W);var mp=class Wa{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Wa(e.map(this.anchor),e.map(this.head))}resolve(e){const t=e.resolve(this.anchor),i=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&i.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&i.index()<i.parent.childCount&&Ko(t,i)?new W(t,i):E.near(i,1)}};function gp(n){if(!(n.selection instanceof W))return null;const e=[];return n.selection.forEachCell((t,i)=>{e.push(oe.node(i,i+t.nodeSize,{class:"selectedCell"}))}),z.create(n.doc,e)}function yp({$from:n,$to:e}){if(n.pos==e.pos||n.pos<e.pos-6)return!1;let t=n.pos,i=e.pos,o=n.depth;for(;o>=0&&!(n.after(o+1)<n.end(o));o--,t++);for(let r=e.depth;r>=0&&!(e.before(r+1)>e.start(r));r--,i--);return t==i&&/row|table/.test(n.node(o).type.spec.tableRole)}function bp({$from:n,$to:e}){let t,i;for(let o=n.depth;o>0;o--){const r=n.node(o);if(r.type.spec.tableRole==="cell"||r.type.spec.tableRole==="header_cell"){t=r;break}}for(let o=e.depth;o>0;o--){const r=e.node(o);if(r.type.spec.tableRole==="cell"||r.type.spec.tableRole==="header_cell"){i=r;break}}return t!==i&&e.parentOffset===0}function wp(n,e,t){const i=(e||n).selection,o=(e||n).doc;let r,s;if(i instanceof O&&(s=i.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")r=W.create(o,i.from);else if(s=="row"){const l=o.resolve(i.from+1);r=W.rowSelection(l,l)}else if(!t){const l=H.get(i.node),a=i.from+1,c=a+l.map[l.width*l.height-1];r=W.create(o,a+1,c)}}else i instanceof N&&yp(i)?r=N.create(o,i.from):i instanceof N&&bp(i)&&(r=N.create(o,i.$from.start(),i.$from.end()));return r&&(e||(e=n.tr)).setSelection(r),e}var Sp=new yn("fix-tables");function _a(n,e,t,i){const o=n.childCount,r=e.childCount;e:for(let s=0,l=0;s<r;s++){const a=e.child(s);for(let c=l,d=Math.min(o,s+3);c<d;c++)if(n.child(c)==a){l=c+1,t+=a.nodeSize;continue e}i(a,t),l<o&&n.child(l).sameMarkup(a)?_a(n.child(l),a,t+1,i):a.nodesBetween(0,a.content.size,i,t+1),t+=a.nodeSize}}function vp(n,e){let t;const i=(o,r)=>{o.type.spec.tableRole=="table"&&(t=xp(n,o,r,t))};return e?e.doc!=n.doc&&_a(e.doc,n.doc,0,i):n.doc.descendants(i),t}function xp(n,e,t,i){const o=H.get(e);if(!o.problems)return i;i||(i=n.tr);const r=[];for(let a=0;a<o.height;a++)r.push(0);for(let a=0;a<o.problems.length;a++){const c=o.problems[a];if(c.type=="collision"){const d=e.nodeAt(c.pos);if(!d)continue;const h=d.attrs;for(let u=0;u<h.rowspan;u++)r[c.row+u]+=c.n;i.setNodeMarkup(i.mapping.map(t+1+c.pos),null,Kt(h,h.colspan-c.n,c.n))}else if(c.type=="missing")r[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const d=e.nodeAt(c.pos);if(!d)continue;i.setNodeMarkup(i.mapping.map(t+1+c.pos),null,{...d.attrs,rowspan:d.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const d=e.nodeAt(c.pos);if(!d)continue;i.setNodeMarkup(i.mapping.map(t+1+c.pos),null,{...d.attrs,colwidth:c.colwidth})}}let s,l;for(let a=0;a<r.length;a++)r[a]&&(s==null&&(s=a),l=a);for(let a=0,c=t+1;a<o.height;a++){const d=e.child(a),h=c+d.nodeSize,u=r[a];if(u>0){let f="cell";d.firstChild&&(f=d.firstChild.type.spec.tableRole);const p=[];for(let g=0;g<u;g++){const y=Te(n.schema)[f].createAndFill();y&&p.push(y)}const m=(a==0||s==a-1)&&l==a?c+1:h-1;i.insert(i.mapping.map(m),p)}c=h}return i.setMeta(Sp,{fixTables:!0})}function Ka(n){const e=n.selection,t=_o(n),i=t.node(-1),o=t.start(-1),r=H.get(i);return{...e instanceof W?r.rectBetween(e.$anchorCell.pos-o,e.$headCell.pos-o):r.findCell(t.pos-o),tableStart:o,map:r,table:i}}function Cp(n){return function(e,t){if(!bi(e))return!1;if(t){const i=Te(e.schema),o=Ka(e),r=e.tr,s=o.map.cellsInRect(n=="column"?{left:o.left,top:0,right:o.right,bottom:o.map.height}:n=="row"?{left:0,top:o.top,right:o.map.width,bottom:o.bottom}:o),l=s.map(a=>o.table.nodeAt(a));for(let a=0;a<s.length;a++)l[a].type==i.header_cell&&r.setNodeMarkup(o.tableStart+s[a],i.cell,l[a].attrs);if(r.steps.length==0)for(let a=0;a<s.length;a++)r.setNodeMarkup(o.tableStart+s[a],i.header_cell,l[a].attrs);t(r)}return!0}}function ks(n,e,t){const i=e.map.cellsInRect({left:0,top:0,right:n=="row"?e.map.width:1,bottom:n=="column"?e.map.height:1});for(let o=0;o<i.length;o++){const r=e.table.nodeAt(i[o]);if(r&&r.type!==t.header_cell)return!1}return!0}function qo(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?Cp(n):function(t,i){if(!bi(t))return!1;if(i){const o=Te(t.schema),r=Ka(t),s=t.tr,l=ks("row",r,o),a=ks("column",r,o),d=(n==="column"?l:n==="row"?a:!1)?1:0,h=n=="column"?{left:0,top:d,right:1,bottom:r.map.height}:n=="row"?{left:d,top:0,right:r.map.width,bottom:1}:r,u=n=="column"?a?o.cell:o.header_cell:n=="row"?l?o.cell:o.header_cell:o.cell;r.map.cellsInRect(h).forEach(f=>{const p=f+r.tableStart,m=s.doc.nodeAt(p);m&&s.setNodeMarkup(p,u,m.attrs)}),i(s)}return!0}}qo("row",{useDeprecatedLogic:!0});qo("column",{useDeprecatedLogic:!0});qo("cell",{useDeprecatedLogic:!0});function kp(n,e){if(e<0){const t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let i=n.index(-1)-1,o=n.before();i>=0;i--){const r=n.node(-1).child(i),s=r.lastChild;if(s)return o-1-s.nodeSize;o-=r.nodeSize}}else{if(n.index()<n.parent.childCount-1)return n.pos+n.nodeAfter.nodeSize;const t=n.node(-1);for(let i=n.indexAfter(-1),o=n.after();i<t.childCount;i++){const r=t.child(i);if(r.childCount)return o+1;o+=r.nodeSize}}return null}function Ts(n){return function(e,t){if(!bi(e))return!1;const i=kp(_o(e),n);if(i==null)return!1;if(t){const o=e.doc.resolve(i);t(e.tr.setSelection(N.between(o,pp(o))).scrollIntoView())}return!0}}function Rn(n,e){const t=n.selection;if(!(t instanceof W))return!1;if(e){const i=n.tr,o=Te(n.schema).cell.createAndFill().content;t.forEachCell((r,s)=>{r.content.eq(o)||i.replace(i.mapping.map(s+1),i.mapping.map(s+r.nodeSize-1),new C(o,0,0))}),i.docChanged&&e(i)}return!0}function Tp(n){if(!n.size)return null;let{content:e,openStart:t,openEnd:i}=n;for(;e.childCount==1&&(t>0&&i>0||e.child(0).type.spec.tableRole=="table");)t--,i--,e=e.child(0).content;const o=e.child(0),r=o.type.spec.tableRole,s=o.type.schema,l=[];if(r=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content;const d=a?0:Math.max(0,t-1),h=a<e.childCount-1?0:Math.max(0,i-1);(d||h)&&(c=xo(Te(s).row,new C(c,d,h)).content),l.push(c)}else if(r=="cell"||r=="header_cell")l.push(t||i?xo(Te(s).row,new C(e,t,i)).content:e);else return null;return Mp(s,l)}function Mp(n,e){const t=[];for(let o=0;o<e.length;o++){const r=e[o];for(let s=r.childCount-1;s>=0;s--){const{rowspan:l,colspan:a}=r.child(s).attrs;for(let c=o;c<o+l;c++)t[c]=(t[c]||0)+a}}let i=0;for(let o=0;o<t.length;o++)i=Math.max(i,t[o]);for(let o=0;o<t.length;o++)if(o>=e.length&&e.push(w.empty),t[o]<i){const r=Te(n).cell.createAndFill(),s=[];for(let l=t[o];l<i;l++)s.push(r);e[o]=e[o].append(w.from(s))}return{height:e.length,width:i,rows:e}}function xo(n,e){const t=n.createAndFill();return new _l(t).replace(0,t.content.size,e).doc}function Ap({width:n,height:e,rows:t},i,o){if(n!=i){const r=[],s=[];for(let l=0;l<t.length;l++){const a=t[l],c=[];for(let d=r[l]||0,h=0;d<i;h++){let u=a.child(h%a.childCount);d+u.attrs.colspan>i&&(u=u.type.createChecked(Kt(u.attrs,u.attrs.colspan,d+u.attrs.colspan-i),u.content)),c.push(u),d+=u.attrs.colspan;for(let f=1;f<u.attrs.rowspan;f++)r[l+f]=(r[l+f]||0)+u.attrs.colspan}s.push(w.from(c))}t=s,n=i}if(e!=o){const r=[];for(let s=0,l=0;s<o;s++,l++){const a=[],c=t[l%e];for(let d=0;d<c.childCount;d++){let h=c.child(d);s+h.attrs.rowspan>o&&(h=h.type.create({...h.attrs,rowspan:Math.max(1,o-h.attrs.rowspan)},h.content)),a.push(h)}r.push(w.from(a))}t=r,e=o}return{width:n,height:e,rows:t}}function Op(n,e,t,i,o,r,s){const l=n.doc.type.schema,a=Te(l);let c,d;if(o>e.width)for(let h=0,u=0;h<e.height;h++){const f=t.child(h);u+=f.nodeSize;const p=[];let m;f.lastChild==null||f.lastChild.type==a.cell?m=c||(c=a.cell.createAndFill()):m=d||(d=a.header_cell.createAndFill());for(let g=e.width;g<o;g++)p.push(m);n.insert(n.mapping.slice(s).map(u-1+i),p)}if(r>e.height){const h=[];for(let p=0,m=(e.height-1)*e.width;p<Math.max(e.width,o);p++){const g=p>=e.width?!1:t.nodeAt(e.map[m+p]).type==a.header_cell;h.push(g?d||(d=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const u=a.row.create(null,w.from(h)),f=[];for(let p=e.height;p<r;p++)f.push(u);n.insert(n.mapping.slice(s).map(i+t.nodeSize-2),f)}return!!(c||d)}function Ms(n,e,t,i,o,r,s,l){if(s==0||s==e.height)return!1;let a=!1;for(let c=o;c<r;c++){const d=s*e.width+c,h=e.map[d];if(e.map[d-e.width]==h){a=!0;const u=t.nodeAt(h),{top:f,left:p}=e.findCell(h);n.setNodeMarkup(n.mapping.slice(l).map(h+i),null,{...u.attrs,rowspan:s-f}),n.insert(n.mapping.slice(l).map(e.positionAt(s,p,t)),u.type.createAndFill({...u.attrs,rowspan:f+u.attrs.rowspan-s})),c+=u.attrs.colspan-1}}return a}function As(n,e,t,i,o,r,s,l){if(s==0||s==e.width)return!1;let a=!1;for(let c=o;c<r;c++){const d=c*e.width+s,h=e.map[d];if(e.map[d-1]==h){a=!0;const u=t.nodeAt(h),f=e.colCount(h),p=n.mapping.slice(l).map(h+i);n.setNodeMarkup(p,null,Kt(u.attrs,s-f,u.attrs.colspan-(s-f))),n.insert(p+u.nodeSize,u.type.createAndFill(Kt(u.attrs,0,s-f))),c+=u.attrs.rowspan-1}}return a}function Os(n,e,t,i,o){let r=t?n.doc.nodeAt(t-1):n.doc;if(!r)throw new Error("No table found");let s=H.get(r);const{top:l,left:a}=i,c=a+o.width,d=l+o.height,h=n.tr;let u=0;function f(){if(r=t?h.doc.nodeAt(t-1):h.doc,!r)throw new Error("No table found");s=H.get(r),u=h.mapping.maps.length}Op(h,s,r,t,c,d,u)&&f(),Ms(h,s,r,t,a,c,l,u)&&f(),Ms(h,s,r,t,a,c,d,u)&&f(),As(h,s,r,t,l,d,a,u)&&f(),As(h,s,r,t,l,d,c,u)&&f();for(let p=l;p<d;p++){const m=s.positionAt(p,a,r),g=s.positionAt(p,c,r);h.replace(h.mapping.slice(u).map(m+t),h.mapping.slice(u).map(g+t),new C(o.rows[p-l],0,0))}f(),h.setSelection(new W(h.doc.resolve(t+s.positionAt(l,a,r)),h.doc.resolve(t+s.positionAt(d-1,c-1,r)))),e(h)}var Ep=sa({ArrowLeft:Vn("horiz",-1),ArrowRight:Vn("horiz",1),ArrowUp:Vn("vert",-1),ArrowDown:Vn("vert",1),"Shift-ArrowLeft":Ln("horiz",-1),"Shift-ArrowRight":Ln("horiz",1),"Shift-ArrowUp":Ln("vert",-1),"Shift-ArrowDown":Ln("vert",1),Backspace:Rn,"Mod-Backspace":Rn,Delete:Rn,"Mod-Delete":Rn});function _n(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function Vn(n,e){return(t,i,o)=>{if(!o)return!1;const r=t.selection;if(r instanceof W)return _n(t,i,E.near(r.$headCell,e));if(n!="horiz"&&!r.empty)return!1;const s=qa(o,n,e);if(s==null)return!1;if(n=="horiz")return _n(t,i,E.near(t.doc.resolve(r.head+e),e));{const l=t.doc.resolve(s),a=$a(l,n,e);let c;return a?c=E.near(a,1):e<0?c=E.near(t.doc.resolve(l.before(-1)),-1):c=E.near(t.doc.resolve(l.after(-1)),1),_n(t,i,c)}}}function Ln(n,e){return(t,i,o)=>{if(!o)return!1;const r=t.selection;let s;if(r instanceof W)s=r;else{const a=qa(o,n,e);if(a==null)return!1;s=new W(t.doc.resolve(a))}const l=$a(s.$headCell,n,e);return l?_n(t,i,new W(s.$anchorCell,l)):!1}}function Np(n,e){const t=n.state.doc,i=vn(t.resolve(e));return i?(n.dispatch(n.state.tr.setSelection(new W(i))),!0):!1}function Dp(n,e,t){if(!bi(n.state))return!1;let i=Tp(t);const o=n.state.selection;if(o instanceof W){i||(i={width:1,height:1,rows:[w.from(xo(Te(n.state.schema).cell,t))]});const r=o.$anchorCell.node(-1),s=o.$anchorCell.start(-1),l=H.get(r).rectBetween(o.$anchorCell.pos-s,o.$headCell.pos-s);return i=Ap(i,l.right-l.left,l.bottom-l.top),Os(n.state,n.dispatch,s,l,i),!0}else if(i){const r=_o(n.state),s=r.start(-1);return Os(n.state,n.dispatch,s,H.get(r.node(-1)).findCell(r.pos-s),i),!0}else return!1}function Ip(n,e){var t;if(e.ctrlKey||e.metaKey)return;const i=Es(n,e.target);let o;if(e.shiftKey&&n.state.selection instanceof W)r(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&i&&(o=vn(n.state.selection.$anchor))!=null&&((t=ji(n,e))==null?void 0:t.pos)!=o.pos)r(o,e),e.preventDefault();else if(!i)return;function r(a,c){let d=ji(n,c);const h=_e.getState(n.state)==null;if(!d||!Ko(a,d))if(h)d=a;else return;const u=new W(a,d);if(h||!n.state.selection.eq(u)){const f=n.state.tr.setSelection(u);h&&f.setMeta(_e,a.pos),n.dispatch(f)}}function s(){n.root.removeEventListener("mouseup",s),n.root.removeEventListener("dragstart",s),n.root.removeEventListener("mousemove",l),_e.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(_e,-1))}function l(a){const c=a,d=_e.getState(n.state);let h;if(d!=null)h=n.state.doc.resolve(d);else if(Es(n,c.target)!=i&&(h=ji(n,e),!h))return s();h&&r(h,c)}n.root.addEventListener("mouseup",s),n.root.addEventListener("dragstart",s),n.root.addEventListener("mousemove",l)}function qa(n,e,t){if(!(n.state.selection instanceof N))return null;const{$head:i}=n.state.selection;for(let o=i.depth-1;o>=0;o--){const r=i.node(o);if((t<0?i.index(o):i.indexAfter(o))!=(t<0?0:r.childCount))return null;if(r.type.spec.tableRole=="cell"||r.type.spec.tableRole=="header_cell"){const l=i.before(o),a=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(a)?l:null}}return null}function Es(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function ji(n,e){const t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?vn(n.state.doc.resolve(t.pos)):null}var Pp=class{constructor(n,e){this.node=n,this.defaultCellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${e}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Co(n,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(n){return n.type!=this.node.type?!1:(this.node=n,Co(n,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(n){return n.type=="attributes"&&(n.target==this.table||this.colgroup.contains(n.target))}};function Co(n,e,t,i,o,r){var s;let l=0,a=!0,c=e.firstChild;const d=n.firstChild;if(d){for(let h=0,u=0;h<d.childCount;h++){const{colspan:f,colwidth:p}=d.child(h).attrs;for(let m=0;m<f;m++,u++){const g=o==u?r:p&&p[m],y=g?g+"px":"";if(l+=g||i,g||(a=!1),c)c.style.width!=y&&(c.style.width=y),c=c.nextSibling;else{const x=document.createElement("col");x.style.width=y,e.appendChild(x)}}}for(;c;){const h=c.nextSibling;(s=c.parentNode)==null||s.removeChild(c),c=h}a?(t.style.width=l+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=l+"px")}}var ae=new yn("tableColumnResizing");function Rp({handleWidth:n=5,cellMinWidth:e=25,defaultCellMinWidth:t=100,View:i=Pp,lastColumnResizable:o=!0}={}){const r=new gn({key:ae,state:{init(s,l){var a,c;const d=(c=(a=r.spec)==null?void 0:a.props)==null?void 0:c.nodeViews,h=Te(l.schema).table.name;return i&&d&&(d[h]=(u,f)=>new i(u,t,f)),new Vp(-1,!1)},apply(s,l){return l.apply(s)}},props:{attributes:s=>{const l=ae.getState(s);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(s,l)=>{Lp(s,l,n,o)},mouseleave:s=>{zp(s)},mousedown:(s,l)=>{Bp(s,l,e,t)}},decorations:s=>{const l=ae.getState(s);if(l&&l.activeHandle>-1)return _p(s,l.activeHandle)},nodeViews:{}}});return r}var Vp=class Kn{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){const t=this,i=e.getMeta(ae);if(i&&i.setHandle!=null)return new Kn(i.setHandle,!1);if(i&&i.setDragging!==void 0)return new Kn(t.activeHandle,i.setDragging);if(t.activeHandle>-1&&e.docChanged){let o=e.mapping.map(t.activeHandle,-1);return vo(e.doc.resolve(o))||(o=-1),new Kn(o,t.dragging)}return t}};function Lp(n,e,t,i){const o=ae.getState(n.state);if(o&&!o.dragging){const r=Fp(e.target);let s=-1;if(r){const{left:l,right:a}=r.getBoundingClientRect();e.clientX-l<=t?s=Ns(n,e,"left",t):a-e.clientX<=t&&(s=Ns(n,e,"right",t))}if(s!=o.activeHandle){if(!i&&s!==-1){const l=n.state.doc.resolve(s),a=l.node(-1),c=H.get(a),d=l.start(-1);if(c.colCount(l.pos-d)+l.nodeAfter.attrs.colspan-1==c.width-1)return}ja(n,s)}}}function zp(n){const e=ae.getState(n.state);e&&e.activeHandle>-1&&!e.dragging&&ja(n,-1)}function Bp(n,e,t,i){var o;const r=(o=n.dom.ownerDocument.defaultView)!=null?o:window,s=ae.getState(n.state);if(!s||s.activeHandle==-1||s.dragging)return!1;const l=n.state.doc.nodeAt(s.activeHandle),a=Hp(n,s.activeHandle,l.attrs);n.dispatch(n.state.tr.setMeta(ae,{setDragging:{startX:e.clientX,startWidth:a}}));function c(h){r.removeEventListener("mouseup",c),r.removeEventListener("mousemove",d);const u=ae.getState(n.state);u!=null&&u.dragging&&($p(n,u.activeHandle,Ds(u.dragging,h,t)),n.dispatch(n.state.tr.setMeta(ae,{setDragging:null})))}function d(h){if(!h.which)return c(h);const u=ae.getState(n.state);if(u&&u.dragging){const f=Ds(u.dragging,h,t);Is(n,u.activeHandle,f,i)}}return Is(n,s.activeHandle,a,i),r.addEventListener("mouseup",c),r.addEventListener("mousemove",d),e.preventDefault(),!0}function Hp(n,e,{colspan:t,colwidth:i}){const o=i&&i[i.length-1];if(o)return o;const r=n.domAtPos(e);let l=r.node.childNodes[r.offset].offsetWidth,a=t;if(i)for(let c=0;c<t;c++)i[c]&&(l-=i[c],a--);return l/a}function Fp(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList&&n.classList.contains("ProseMirror")?null:n.parentNode;return n}function Ns(n,e,t,i){const o=t=="right"?-i:i,r=n.posAtCoords({left:e.clientX+o,top:e.clientY});if(!r)return-1;const{pos:s}=r,l=vn(n.state.doc.resolve(s));if(!l)return-1;if(t=="right")return l.pos;const a=H.get(l.node(-1)),c=l.start(-1),d=a.map.indexOf(l.pos-c);return d%a.width==0?-1:c+a.map[d-1]}function Ds(n,e,t){const i=e.clientX-n.startX;return Math.max(t,n.startWidth+i)}function ja(n,e){n.dispatch(n.state.tr.setMeta(ae,{setHandle:e}))}function $p(n,e,t){const i=n.state.doc.resolve(e),o=i.node(-1),r=H.get(o),s=i.start(-1),l=r.colCount(i.pos-s)+i.nodeAfter.attrs.colspan-1,a=n.state.tr;for(let c=0;c<r.height;c++){const d=c*r.width+l;if(c&&r.map[d]==r.map[d-r.width])continue;const h=r.map[d],u=o.nodeAt(h).attrs,f=u.colspan==1?0:l-r.colCount(h);if(u.colwidth&&u.colwidth[f]==t)continue;const p=u.colwidth?u.colwidth.slice():Wp(u.colspan);p[f]=t,a.setNodeMarkup(s+h,null,{...u,colwidth:p})}a.docChanged&&n.dispatch(a)}function Is(n,e,t,i){const o=n.state.doc.resolve(e),r=o.node(-1),s=o.start(-1),l=H.get(r).colCount(o.pos-s)+o.nodeAfter.attrs.colspan-1;let a=n.domAtPos(o.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&Co(r,a.firstChild,a,i,l,t)}function Wp(n){return Array(n).fill(0)}function _p(n,e){var t;const i=[],o=n.doc.resolve(e),r=o.node(-1);if(!r)return z.empty;const s=H.get(r),l=o.start(-1),a=s.colCount(o.pos-l)+o.nodeAfter.attrs.colspan-1;for(let c=0;c<s.height;c++){const d=a+c*s.width;if((a==s.width-1||s.map[d]!=s.map[d+1])&&(c==0||s.map[d]!=s.map[d-s.width])){const h=s.map[d],u=l+h+r.nodeAt(h).nodeSize-1,f=document.createElement("div");f.className="column-resize-handle",(t=ae.getState(n))!=null&&t.dragging&&i.push(oe.node(l+h,l+h+r.nodeAt(h).nodeSize,{class:"column-resize-dragging"})),i.push(oe.widget(u,f))}}return z.create(n.doc,i)}function Kp({allowTableNodeSelection:n=!1}={}){return new gn({key:_e,state:{init(){return null},apply(e,t){const i=e.getMeta(_e);if(i!=null)return i==-1?null:i;if(t==null||!e.docChanged)return t;const{deleted:o,pos:r}=e.mapping.mapResult(t);return o?null:r}},props:{decorations:gp,handleDOMEvents:{mousedown:Ip},createSelectionBetween(e){return _e.getState(e.state)!=null?e.state.selection:null},handleTripleClick:Np,handleKeyDown:Ep,handlePaste:Dp},appendTransaction(e,t,i){return wp(i,vp(i,t),n)}})}const ln=n=>{const e=Object.fromEntries(Array.from(n.attributes).map(t=>[t.name,t.value]));return delete e.draggable,e},Ps="data-gs-mrk-fs",Rs="data-gs-ib",ai="data-gs-ifrg",Ve="attrs",Ja={[Ve]:{default:"{}"}},Ee={[Ve]:{default:{}}},Ga=n=>({[Ve]:JSON.stringify(ln(n))}),Ne=n=>({attrs:ln(n)}),Ut=n=>e=>[n,e.attrs.attrs,0],$e=n=>n.attrs[Ve]?JSON.parse(n.attrs[Ve]):{},qp={doc:{content:"block+"},text:{group:"inline",inline:!0},inlineFragment:{group:"block",content:"inline*",isTextBlock:!0,parseDOM:[{tag:`span[${ai}]`,getAttrs:Ne}],toDOM:()=>["span",{[ai]:""},0]},div:{group:"block",content:"inline*",attrs:Ee,parseDOM:[{tag:"div",getAttrs:Ne}],toDOM:Ut("div")},paragraph:{group:"block",content:"inline*",attrs:Ee,parseDOM:[{tag:"p",getAttrs:Ne}],toDOM:Ut("p")},orderedList:{group:"block",content:"listItem+",attrs:Ee,parseDOM:[{tag:"ol",getAttrs:Ne}],toDOM:Ut("ol")},bulletList:{group:"block",content:"listItem+",attrs:Ee,parseDOM:[{tag:"ul",getAttrs:Ne}],toDOM:Ut("ul")},listItem:{content:"block*",group:"block",attrs:Ee,parseDOM:[{tag:"li",getAttrs:Ne}],toDOM:Ut("li"),defining:!0},codeBlock:{group:"block",content:"text*",marks:"",attrs:Ee,parseDOM:[{tag:"pre",getAttrs:Ne}],toDOM:n=>["pre",n.attrs.attrs,["code",0]]},image:{inline:!0,group:"inline",selectable:!0,attrs:Ee,parseDOM:[{tag:"img[src]",getAttrs:Ne}],toDOM:n=>["img",n.attrs.attrs]},inlineBreak:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:`br[${Rs}]`}],toDOM(){return["br",{[Rs]:""}]}},hardBreak:{inline:!1,group:"block",selectable:!1,attrs:Ee,parseDOM:[{tag:"br",getAttrs:Ne}],toDOM:n=>["br",{...n.attrs.attrs}]},heading:{group:"block",content:"inline*",attrs:{level:{default:1},attrs:{default:{}}},defining:!0,parseDOM:Array.from({length:6},(n,e)=>({tag:`h${e+1}`,getAttrs:t=>({level:e+1,attrs:ln(t)})})),toDOM({attrs:n}){const{level:e}=n;return[e?`h${e}`:"div",n.attrs,0]}},...up({tableGroup:"block",cellContent:"block+",cellAttributes:{[Ve]:{default:Ee[Ve].default,getFromDOM:ln,setDOMAttr:(n,e)=>{n&&Object.assign(e,n)}},background:{default:null,getFromDOM(n){return n.style.backgroundColor||null},setDOMAttr(n,e){n&&(e.style=(e.style||"")+`background-color: ${n};`)}}}}),nonTextNode:{group:"block",content:"block*",attrs:{tagName:{default:"span"},attrs:{default:{}}},parseDOM:[{tag:"*:not(tbody)",getAttrs:n=>({tagName:n.tagName.toLowerCase(),attrs:ln(n)}),priority:0}],toDOM(n){const{tagName:e,attrs:t}=n.attrs;return[e,t,0]}}},Zt=(n,e)=>({attrs:Ja,parseDOM:n.map(t=>({tag:t,getAttrs:Ga})),toDOM:e}),jp={strong:Zt(["strong","b"],n=>["b",$e(n)]),link:Zt(["a"],n=>["a",$e(n),0]),em:Zt(["em","i"],n=>["em",$e(n)]),underline:Zt(["u"],n=>["u",$e(n),0]),strikethrough:Zt(["s"],n=>["s",$e(n),0]),font_size:{attrs:{...Ja,size:{default:null}},parseDOM:[{tag:`span[${Ps}]`,getAttrs:n=>({...Ga(n),size:n.style.fontSize})}],toDOM(n){const{size:e}=n.attrs,t={...$e(n),[Ps]:!0};return e&&(t.style=`font-size: ${e}`),["span",t,0]}}},Vs=new dh({nodes:qp,marks:jp}),wi=new WeakMap,jo=new WeakMap,Jp=(n,e)=>{wi.set(n,e),jo.set(e,n)},Gp=(n,e)=>{wi.delete(n),jo.delete(e)},Ji=n=>wi.get(n),Up=n=>jo.get(n),Ls=n=>{var t;const e=Up(n);return(t=e==null?void 0:e.__gjsv)==null?void 0:t.model},Zp=n=>n.dispatchEvent(new CustomEvent("input"));function Yp(n){const e=t=>{if(t.tagName==="SPAN"&&t.hasAttribute(ai)){if(t.getAttribute("style")){t.removeAttribute(ai);return}const i=t.parentElement;if(i){for(;t.firstChild;)i.insertBefore(t.firstChild,t);i.removeChild(t)}}else Array.from(t.children).forEach(i=>e(i))};e(n)}function Xp(n,e={}){if(!e.enableOnClick)return()=>{};const t=n.Components.events,i=d=>n.getSelectedAll().includes(d),o=d=>d.isInstanceOf("text")&&!d.isChildOf("text"),r=d=>d.isChildOf("text"),s=d=>n.getEditing()===d,l=(d,h={})=>{d.trigger("focus",h.event)},a=(d,h)=>{i(d)&&o(d)&&!s(d)&&l(d,h)},c=(d,h)=>{if(i(d)&&!o(d)&&r(d)){const u=d.parents().find(f=>f.isInstanceOf("text"));u&&(l(u,h),setTimeout(()=>n.select(u),0))}};return n.on(t.select,a),n.on(t.selectBefore,c),()=>{n.off(t.select,a),n.off(t.selectBefore,c)}}const Qp=(n,e)=>{const t=em(n);return t&&cm(t)?tm(n,e):t?Xl(()=>({type:n.schema.nodes.div}))(n,e):!1};function em(n){const e=n.selection.$from;if(e.node(e.depth).type===n.schema.nodes.inlineFragment){const t=e.depth-1;return e.node(t)}return e.node(e.depth)}function tm(n,e){const{selection:t,schema:i,tr:o}=n;o.split(t.from,1);const r=t.from+1,s=o.doc.nodeAt(r),l={...s.attrs.attrs,id:void 0},a=s.textContent.length>0,c=s.textContent.length||0,d=s.textContent||" ",h=i.text(d),u=i.nodes.div.create(l,a?h:[],[]);return o.replaceRangeWith(r,r+c+2,u),o.setSelection(N.create(o.doc,r+1)),e==null||e(o.scrollIntoView()),!0}function nm(n,e,t){const{state:i,dispatch:o}=n,{selection:r,tr:s}=i,l=(a,c,d)=>{const h={};return a.split(";").forEach(u=>{const[f,p]=u.split(":").map(m=>m.trim());f&&(h[f]=p)}),h[c]=d,Object.entries(h).map(([u,f])=>`${u}: ${f}`).join("; ")};if(!r.empty||t)s.doc.nodesBetween(r.from,r.to,(a,c)=>{var d,h;if(a.type===i.schema.nodes.image){const u=l(((d=a.attrs.attrs)==null?void 0:d.style)||"","float",e);s.setNodeMarkup(c,void 0,{...a.attrs,attrs:{...a.attrs.attrs,style:u}})}else if(a.type.isBlock){const u=l(((h=a.attrs.attrs)==null?void 0:h.style)||"","text-align",e);Ua(a)?s.setBlockType(r.from,void 0,i.schema.nodes.div,{attrs:{style:u}}):s.setNodeMarkup(c,void 0,{...a.attrs,attrs:{...a.attrs.attrs,style:u}})}});else{const a=i.doc.resolve(r.from),c=a.start(a.depth),d=i.doc.nodeAt(c);if(d!=null&&d.type.isBlock){const h=l(d.attrs.style||"","text-align",e);s.setNodeMarkup(c,void 0,{...d.attrs,style:h})}}s.docChanged&&o(s.scrollIntoView())}const Yt=(n,e)=>{const{from:t,to:i}=n.selection;let o=!1;return n.doc.nodesBetween(t,i,r=>{if(o)return!1;r.marks.some(s=>s.type===e)&&(o=!0)}),o};function im(n,e,t="_blank"){const{state:i,dispatch:o}=n,{schema:r,selection:s,tr:l}=i,a=r.marks.link;try{const c=a.create({[Ve]:JSON.stringify({href:e,target:t})});l.addMark(s.from,s.to,c),o(l.scrollIntoView())}catch(c){console.error("Error applying link mark:",c)}}function om(n,e){const{state:t,dispatch:i}=n,{selection:o,tr:r}=t;if(o.empty)return;const s=t.schema.marks.font_size;if(!s){console.error("Font size mark is not defined in the schema.");return}r.addMark(o.from,o.to,s.create({size:e})),i(r.scrollIntoView())}const at=(n,e)=>{const{doc:t,selection:i}=n.state,o=t.resolve(i.from);for(let r=o.depth;r>0;r--){const s=o.node(r);if(e(s))return{pos:r>0?o.before(r):0,start:o.start(r),depth:r,node:s}}},rm=n=>(n||"").split(";").map(e=>e.split(":")).reduce((e,[t,i])=>(t=t.replace(/-./g,o=>o.toUpperCase()[1]).trim(),e[t]=`${i}`.trim(),e),{});function sm(...n){return(e,t)=>{const i=s=>{e=e.apply(s),t==null||t(s)},o=n.pop();return n.reduce((s,l)=>s||l(e,i),!1)&&o!==void 0&&o(e,t)}}const lm=(n,e)=>{const{state:t,dispatch:i}=n;if(e!=null&&e.event){const{event:o}=e,r=n.posAtCoords({left:o.clientX,top:o.clientY});r!=null&&r.pos&&i(t.tr.setSelection(N.create(t.doc,r.pos)))}else Ql(t,i);setTimeout(()=>setTimeout(()=>n.focus()))},ko=n=>n.isBlock,Ua=n=>n.type.name==="inlineFragment",am=n=>ko(n)&&!Ua(n),Za=n=>n.type.name==="bulletList",Ya=n=>n.type.name==="orderedList",cm=n=>n.type.name==="heading",dm=n=>Za(n)||Ya(n),zs=(n,e)=>{var r,s;const t=(r=at(n,l=>l.type===e))==null?void 0:r.node,i=n.state.schema.nodes.listItem;let o;return t?o=lo(i):(s=at(n,dm))!=null&&s.node?o=sm(lo(i),$r(e)):o=$r(e),o(n.state,n.dispatch)},Xa=(n,e)=>{const{selection:t}=n.state;return[...t.$from.marks(),...t.$to.marks()].find(i=>i.type.name===e)},hm=n=>{var s;const{view:e,prop:t,editor:i,propCSS:o}=n,r=(s=at(e,am))==null?void 0:s.node;if(r){const l=r.attrs.attrs||{},a=rm(l.style);if(t in a)return a[t]||"";if(l.id){const c=i.Components.getById(l.id);return((c==null?void 0:c.getStyle())||{})[o]||""}}return""},um=n=>{const{view:e,prop:t,markName:i,editor:o,propCSS:r}=n,s=Xa(e,i);if(s){const l=s.attrs;if(l[t])return l[t];if(l[Ve]){const a=$e(s).id;if(a){const c=o.Components.getById(a);return((c==null?void 0:c.getStyle())||{})[r]||""}}}return""},Qa=(n,e)=>{const{dispatch:t}=n,{nodes:i,marks:o}=n.state.schema;return{text:{selected:()=>{const{selection:r,doc:s}=n.state;return s.textBetween(r.from,r.to," ")},replace:(r,s={})=>{const{state:l}=n,{from:a}=l.selection;let c=l.tr.replaceSelectionWith(l.schema.text(r));s.select&&(c=c.setSelection(N.create(c.doc,a,a+r.length))),t==null||t(c)}},bold:{toggle:()=>it(o.strong)(n.state,t),isActive:()=>Yt(n.state,o.strong)},italic:{toggle:()=>it(o.em)(n.state,t),isActive:()=>Yt(n.state,o.em)},underline:{toggle:()=>it(o.underline)(n.state,t),isActive:()=>Yt(n.state,o.underline)},strikethrough:{toggle:()=>it(o.strikethrough)(n.state,t),isActive:()=>Yt(n.state,o.strikethrough)},link:{get:()=>{const r=Ls(n);if(r!=null&&r.is("link"))return r.getAttributes();{const s=Xa(n,"link");return s?$e(s):{}}},toggle:()=>it(o.link)(n.state,t),isActive:()=>Yt(n.state,o.link),create:r=>{const s=Ls(n);s!=null&&s.is("link")?(s.addAttributes({href:r.url,target:r.target}),n.focus()):im(n,r.url,r.target)}},alignText:{get:()=>hm({view:n,editor:e,prop:"textAlign",propCSS:"text-align"}),set:r=>nm(n,r.value,!0)},fontSize:{get:()=>um({view:n,editor:e,markName:"font_size",prop:"size",propCSS:"font-size"}),set:r=>om(n,r.value)},image:{open(){const r="assetLayout",{state:s,dispatch:l}=n,{selection:a,doc:c}=s,d=c.textBetween(a.from,a.to," "),h={id:r,disablePropagation:!0,placer:{type:"dialog",title:"Select image",size:"l"},header:!1,layout:{type:"panelAssets",onSelect:u=>{const f={alt:d,src:u.asset.getSrc()};l(s.tr.replaceSelectionWith(i.image.createAndFill({attrs:f})))}}};e.runCommand(Y.layoutToggle,h)}},heading:{get:()=>{var s;const r=(s=at(n,ko))==null?void 0:s.node;return`${(r==null?void 0:r.attrs.level)||""}`},set:({value:r})=>{var a;const{state:s}=n,l=(a=at(n,ko))==null?void 0:a.node;iu(s.schema.nodes.heading,{attrs:l==null?void 0:l.attrs.attrs,level:r?parseInt(r,10):0})(s,t)}},listBullet:{isActive:()=>{var r;return!!((r=at(n,Za))!=null&&r.node)},toggle:()=>zs(n,i.bulletList)},listOrdered:{isActive:()=>{var r;return!!((r=at(n,Ya))!=null&&r.node)},toggle:()=>zs(n,i.orderedList)}}},me="rte:selectionchange",he={bold:'<svg viewBox="0 0 24 24"><path d="M13.5,15.5H10V12.5H13.5A1.5,1.5 0 0,1 15,14A1.5,1.5 0 0,1 13.5,15.5M10,6.5H13A1.5,1.5 0 0,1 14.5,8A1.5,1.5 0 0,1 13,9.5H10M15.6,10.79C16.57,10.11 17.25,9 17.25,8C17.25,5.74 15.5,4 13.25,4H7V18H14.04C16.14,18 17.75,16.3 17.75,14.21C17.75,12.69 16.89,11.39 15.6,10.79Z" /></svg>',italic:'<svg viewBox="0 0 24 24"><path d="M10,4V7H12.21L8.79,15H6V18H14V15H11.79L15.21,7H18V4H10Z" /></svg>',underline:'<svg viewBox="0 0 24 24"><path d="M5,21H19V19H5V21M12,17A6,6 0 0,0 18,11V3H15.5V11A3.5,3.5 0 0,1 12,14.5A3.5,3.5 0 0,1 8.5,11V3H6V11A6,6 0 0,0 12,17Z" /></svg>',strikethrough:'<svg viewBox="0 0 24 24"><path d="M7.2 9.8c-1.2-2.3.5-5 2.9-5.5 3.1-1 7.6.4 7.5 4.2h-3l-.1-.8c-.2-.6-.6-.9-1.2-1.1-.8-.3-2.1-.2-2.8.3C9 8.2 10.4 9.5 12 10H7.4l-.2-.2M21 13v-2H3v2h9.6l.6.2c.6.3 1.1.5 1.3 1.1.1.4.2.9 0 1.3-.2.5-.6.7-1.1.9-1.8.5-4-.2-3.9-2.4h-3c-.1 2.6 2.1 4.4 4.5 4.7 3.8.8 8.3-1.6 6.3-5.9l3.7.1Z"/></svg>',link:'<svg viewBox="0 0 24 24"><path d="M3.9,12C3.9,10.29 5.29,8.9 7,8.9H11V7H7A5,5 0 0,0 2,12A5,5 0 0,0 7,17H11V15.1H7C5.29,15.1 3.9,13.71 3.9,12M8,13H16V11H8V13M17,7H13V8.9H17C18.71,8.9 20.1,10.29 20.1,12C20.1,13.71 18.71,15.1 17,15.1H13V17H17A5,5 0 0,0 22,12A5,5 0 0,0 17,7Z" /></svg>',image:'<svg viewBox="0 0 24 24"><path d="M19,19H5V5H19M19,3H5A2,2 0 0,0 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5A2,2 0 0,0 19,3M13.96,12.29L11.21,15.83L9.25,13.47L6.5,17H17.5L13.96,12.29Z"></path></svg>',listBullet:'<svg viewBox="0 0 24 24"><path d="M7 5h14v2H7V5m0 8v-2h14v2H7M4 4.5A1.5 1.5 0 0 1 5.5 6 1.5 1.5 0 0 1 4 7.5 1.5 1.5 0 0 1 2.5 6 1.5 1.5 0 0 1 4 4.5m0 6A1.5 1.5 0 0 1 5.5 12 1.5 1.5 0 0 1 4 13.5 1.5 1.5 0 0 1 2.5 12 1.5 1.5 0 0 1 4 10.5M7 19v-2h14v2H7m-3-2.5A1.5 1.5 0 0 1 5.5 18 1.5 1.5 0 0 1 4 19.5 1.5 1.5 0 0 1 2.5 18 1.5 1.5 0 0 1 4 16.5Z"/></svg>',listOrdered:'<svg viewBox="0 0 24 24"><path d="M7 13v-2h14v2H7m0 6v-2h14v2H7M7 7V5h14v2H7M3 8V5H2V4h2v4H3m-1 9v-1h3v4H2v-1h2v-.5H3v-1h1V17H2m2.3-7a.8.8 0 0 1 .7.8c0 .1 0 .3-.2.5L3 13h2v1H2v-1l2-2H2v-1h2.3Z"/></svg>',alignTextLeft:'<svg viewBox="0 0 24 24"><path d="M3,3H21V5H3V3M3,7H15V9H3V7M3,11H21V13H3V11M3,15H15V17H3V15M3,19H21V21H3V19Z" /></svg>',alignTextCenter:'<svg viewBox="0 0 24 24"><path d="M3,3H21V5H3V3M7,7H17V9H7V7M3,11H21V13H3V11M7,15H17V17H7V15M3,19H21V21H3V19Z" /></svg>',alignTextRight:'<svg viewBox="0 0 24 24"><path d="M3,3H21V5H3V3M9,7H21V9H9V7M3,11H21V13H3V11M9,15H21V17H9V15M3,19H21V21H3V19Z" /></svg>',alignTextJustify:'<svg viewBox="0 0 24 24"><path d="M3,3H21V5H3V3M3,7H21V9H3V7M3,11H21V13H3V11M3,15H21V17H3V15M3,19H21V21H3V19Z" /></svg>'},fm=(n,e)=>{var a;const{editor:t,el:i}=n,o=wi.get(i),r=Qa(o,t),s={separator:{type:"column",style:{borderRightWidth:"1px",borderRightStyle:"solid",alignSelf:"stretch",margin:3}},bold:{id:"bold",icon:he.bold,size:"s",type:"button",editorEvents:{[me]:({setState:c})=>{c({active:r.bold.isActive()})}},onClick:({setState:c})=>{r.bold.toggle(),c({active:r.bold.isActive()})}},italic:{id:"italic",icon:he.italic,size:"s",type:"button",editorEvents:{[me]:({setState:c})=>{c({active:r.italic.isActive()})}},onClick:({setState:c})=>{r.italic.toggle(),c({active:r.italic.isActive()})}},underline:{id:"underline",icon:he.underline,size:"s",type:"button",editorEvents:{[me]:({setState:c})=>{c({active:r.underline.isActive()})}},onClick:({setState:c})=>{r.underline.toggle(),c({active:r.underline.isActive()})}},strikethrough:{id:"strikethrough",icon:he.strikethrough,size:"s",type:"button",editorEvents:{[me]:({setState:c})=>{c({active:r.strikethrough.isActive()})}},onClick:({setState:c})=>{r.strikethrough.toggle(),c({active:r.strikethrough.isActive()})}},image:{id:"image",icon:he.image,size:"s",type:"button",onClick:()=>r.image.open()},link:{id:"link",icon:he.link,size:"s",type:"button",editorEvents:{[me]:({setState:c})=>{c({active:r.link.isActive(),disabled:o.state.selection.empty})}},onClick:({event:c})=>{const d=c.currentTarget||c.target,{x:h,y:u,width:f,height:p}=d.getBoundingClientRect(),m="linkLayout",g=()=>t.runCommand(Y.layoutRemove,{id:m}),y=r.link.get(),x={id:m,style:{width:240},disablePropagation:!0,placer:{type:"popover",closeOnClickAway:!0,x:h,y:u,w:f,h:p},header:{label:"Link"},layout:{type:"column",as:"form",style:{padding:"0 10px 15px",gap:10},onSubmit:b=>{b.preventDefault();const S=new FormData(b.currentTarget);r.link.create({url:S.get("url"),target:S.get("target")}),g()},children:[{type:"inputField",name:"url",label:"URL",placeholder:"eg. https://google.com",required:!0,value:(y==null?void 0:y.href)||"",onChange:({value:b,setState:S})=>S({value:b})},{type:"selectField",name:"target",label:"Open link in",emptyState:"Current window",value:(y==null?void 0:y.target)||"",options:[{id:"",label:"Current window"},{id:"_blank",label:"New window"}],onChange:({value:b,setState:S})=>S({value:b})},{type:"row",style:{gap:10,justifyContent:"end"},children:[r.link.isActive()&&{type:"button",label:"Clear",buttonType:"button",onClick:()=>{r.link.toggle(),g()}},{type:"button",variant:"primary",label:"Submit",buttonType:"submit"}]}]}};t.runCommand(Y.layoutToggle,x)}},alignText:{id:"alignText",type:"buttonGroupField",size:"s",value:"",options:[{id:"left",icon:he.alignTextLeft},{id:"center",icon:he.alignTextCenter},{id:"right",icon:he.alignTextRight},{id:"justify",icon:he.alignTextJustify}],editorEvents:{[me]:({setState:c})=>{c({value:r.alignText.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),r.alignText.set({value:c})}},listBullet:{id:"listBullet",icon:he.listBullet,size:"s",type:"button",editorEvents:{[me]:({setState:c})=>{c({active:r.listBullet.isActive()})}},onClick:({setState:c})=>{r.listBullet.toggle(),c({active:r.listBullet.isActive()})}},listOrdered:{id:"listOrdered",icon:he.listOrdered,size:"s",type:"button",editorEvents:{[me]:({setState:c})=>{c({active:r.listOrdered.isActive()})}},onClick:({setState:c})=>{r.listOrdered.toggle(),c({active:r.listOrdered.isActive()})}},heading:{id:"heading",type:"selectField",size:"s",value:"",emptyState:"Heading",options:[{id:"",label:"Normal"},{id:"1",label:"Heading 1"},{id:"2",label:"Heading 2"},{id:"3",label:"Heading 3"},{id:"4",label:"Heading 4"},{id:"5",label:"Heading 5"},{id:"6",label:"Heading 6"}],editorEvents:{[me]:({setState:c})=>{c({value:r.heading.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),r.heading.set({value:c}),o.focus()}},fontSize:{id:"fontSize",type:"selectField",size:"s",value:"",emptyState:"Font size",options:[{id:"8pt",label:"8pt"},{id:"10pt",label:"10pt"},{id:"12pt",label:"12pt"},{id:"14pt",label:"14pt"},{id:"18pt",label:"18pt"},{id:"24pt",label:"24pt"},{id:"36pt",label:"36pt"}],editorEvents:{[me]:({setState:c})=>{c({value:r.fontSize.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),r.fontSize.set({value:c}),o.focus()}}},l=[s.bold,s.italic,s.underline,s.strikethrough,s.image,s.link,s.listBullet,s.listOrdered,s.alignText,s.heading,s.fontSize];return((a=e.toolbar)==null?void 0:a.call(e,{...n,commands:r,layouts:s,proseMirror:{view:o},items:l}))||l};class pm{constructor(e,t,i){this.editor=i,this.node=e,this.dom=document.createElement("img"),this.view=t,Object.keys(e.attrs.attrs).forEach(o=>{this.dom.setAttribute(o,e.attrs.attrs[o])}),this.dom.addEventListener("dblclick",o=>this.handleDoubleClick(o))}handleDoubleClick(e){const{editor:t,view:i}=this;Qa(i,t).image.open(),e.preventDefault()}update(e){return e.type!==this.node.type?!1:(this.node=e,Object.keys(e.attrs.attrs).forEach(t=>{this.dom.setAttribute(t,e.attrs.attrs[t])}),!0)}selectNode(){this.dom.style.outline="2px solid #ffca6f"}deselectNode(){this.dom.style.outline=""}}class Xe{constructor(e,t,i={}){this.match=e,this.match=e,this.handler=typeof t=="string"?mm(t):t,this.undoable=i.undoable!==!1,this.inCode=i.inCode||!1}}function mm(n){return function(e,t,i,o){let r=n;if(t[1]){let s=t[0].lastIndexOf(t[1]);r+=t[0].slice(s+t[1].length),i+=s;let l=i-o;l>0&&(r=t[0].slice(s-l,s)+r,i=o)}return e.tr.insertText(r,i,o)}}const gm=500;function ym({rules:n}){let e=new gn({state:{init(){return null},apply(t,i){let o=t.getMeta(this);return o||(t.selectionSet||t.docChanged?null:i)}},props:{handleTextInput(t,i,o,r){return Bs(t,i,o,r,n,e)},handleDOMEvents:{compositionend:t=>{setTimeout(()=>{let{$cursor:i}=t.state.selection;i&&Bs(t,i.pos,i.pos,"",n,e)})}}},isInputRules:!0});return e}function Bs(n,e,t,i,o,r){if(n.composing)return!1;let s=n.state,l=s.doc.resolve(e),a=l.parent.textBetween(Math.max(0,l.parentOffset-gm),l.parentOffset,null,"")+i;for(let c=0;c<o.length;c++){let d=o[c];if(l.parent.type.spec.code){if(!d.inCode)continue}else if(d.inCode==="only")continue;let h=d.match.exec(a),u=h&&d.handler(s,h,e-(h[0].length-i.length),t);if(u)return d.undoable&&u.setMeta(r,{transform:u,from:e,to:t,text:i}),n.dispatch(u),!0}return!1}const bm=new Xe(/--$/,"—"),wm=new Xe(/\.\.\.$/,"…"),Sm=new Xe(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“"),vm=new Xe(/"$/,"”"),xm=new Xe(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘"),Cm=new Xe(/'$/,"’"),km=[Sm,vm,xm,Cm];function Jo(n,e,t=null,i){return new Xe(n,(o,r,s,l)=>{let a=t instanceof Function?t(r):t,c=o.tr.delete(s,l),d=c.doc.resolve(s),h=d.blockRange(),u=h&&Ll(h,e,a);if(!u)return null;c.wrap(h,u);let f=c.doc.resolve(s-1).nodeBefore;return f&&f.type==e&&fi(c.doc,s-1)&&(!i||i(r,f))&&c.join(s-1),c})}function ec(n,e,t=null){return new Xe(n,(i,o,r,s)=>{let l=i.doc.resolve(r),a=t instanceof Function?t(o):t;return l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),e)?i.tr.delete(r,s).setBlockType(r,r,e,a):null})}function Tm(n){return Jo(/^\s*>\s$/,n)}function Mm(n){return Jo(/^(\d+)\.\s$/,n,e=>({order:+e[1]}),(e,t)=>t.childCount+t.attrs.order==+e[1])}function Am(n){return Jo(/^\s*([-+*])\s$/,n)}function Om(n){return ec(/^```$/,n)}function Em(n,e){return ec(new RegExp("^(#{1,"+e+"})\\s$"),n,t=>({level:t[1].length}))}function Nm(n){const e=km.concat(wm,bm);let t;return(t=n.nodes.blockquote)&&e.push(Tm(t)),(t=n.nodes.orderedList)&&e.push(Mm(t)),(t=n.nodes.bulletList)&&e.push(Am(t)),(t=n.nodes.codeBlock)&&e.push(Om(t)),(t=n.nodes.heading)&&e.push(Em(t,6)),ym({rules:e})}const Dm="rteProseMirror",Im=function(n,e={}){const t={plugins:s=>s.plugins,...e},i=(s,l)=>{var p,m;const a=((p=t.schema)==null?void 0:p.call(t,{editor:n,schema:Vs}))||Vs,{nodes:c,marks:d}=a,h=Ht.fromSchema(a).parse(s),u=Nt.create({doc:h,schema:a,plugins:(m=t.plugins)==null?void 0:m.call(t,{editor:n,plugins:[Rp(),Kp(),Nm(a),mu(),Fi({Tab:Ts(1),"Shift-Tab":Ts(-1)}),Fi({Enter:hn(Yl,Cu(c.listItem),Qp),"Shift-Enter":hn(Zl,(g,y)=>(y&&y(g.tr.replaceSelectionWith(c.inlineBreak.create()).scrollIntoView()),!0)),"Mod-z":ra,"Mod-y":so,"Mod-Shift-z":so,"Mod-b":it(d.strong),"Mod-i":it(d.em),"Shift-Tab":lo(c.listItem),Tab:Mu(c.listItem)}),Fi(su)]})}),f=new rp({mount:s},{state:u,dispatchTransaction(g){var v;const{state:y}=f,x=y.apply(g),b=!y.doc.eq(x.doc);f.updateState(x);const S=!y.selection.eq(x.selection);b&&(Zp(((v=l==null?void 0:l.view)==null?void 0:v.el)||s),f.focus()),(S||b)&&n.trigger(me)}});return s.__rteView=f,f.setProps({nodeViews:{image(g){return new pm(g,f,n)}}}),f},o=s=>fm(s,t);n.setCustomRte({toolbar:o,parseContent:!0,async enable(s,l,a){const c=Ji(s);if(c)return c;const d=i(s,a);return Jp(s,d),lm(d,a),d},disable(s){const l=Ji(s);if(l)return Gp(s,l),l.destroy(),{forceSync:!0}},getContent(s){const l=Ji(s);if(l){const{schema:a,doc:c}=l.state,d=document.createElement("div"),h=wt.fromSchema(a).serializeFragment(c.content);return h.childNodes.forEach(u=>{u.nodeType===Node.ELEMENT_NODE&&u.innerHTML===""&&(u.innerHTML="<br/>")}),d.appendChild(h),Yp(d),s.classList.remove("ProseMirror-focused"),d.innerHTML}return s.innerHTML}});const r=Xp(n,t);Ae({editor:n,licenseKey:t.licenseKey,plan:ee.free,pluginName:Dm,cleanup:()=>{n.RichTextEditor.customRte=void 0,r()}})},Pm=Me(Im),Rm=n=>{const e={};for(const t of Object.keys(n)){let i=n[t];i&&(Array.isArray(i)?i=i.map(o=>o.toString()).join(","):i=i.toString(),e[t]=i)}return new URLSearchParams(e)},Vm=n=>{const{apiKey:e,searchParams:t,thumbnailQuality:i="high"}=n,o=(l={})=>{const c="https://www.googleapis.com/youtube/v3/search",d=Rm(l);return`${c}?${d}`},r=l=>{var a,c,d;return((a=l[i])==null?void 0:a.url)||((c=l.high)==null?void 0:c.url)||((d=l.medium)==null?void 0:d.url)||l.default.url},s=l=>{const a=r(l.snippet.thumbnails);return{id:l.id.videoId,src:`https://www.youtube.com/watch?v=${l.id.videoId}`,name:l.snippet.title,customData:{thumbnailUrl:a,videoItem:l}}};return{id:"youtube",types:["youtube-video"],label:({editor:l})=>l.I18n.t("youtubeAssetProvider.providerLabel"),search:{reloadOnInput:!0,debounceMs:1e3},async onLoad({searchValue:l,pageCustomData:a}){var m;const c={maxResults:25,q:l,pageToken:a==null?void 0:a.token,type:["video"],key:e},d=t==null?void 0:t({searchValue:l}),h={...c,...d};h.part?h.part.includes("snippet")||h.part.push("snippet"):h.part=["snippet"];const f=await(await fetch(o(h))).json();return(m=f.items)!=null&&m.length?{items:f.items.map(s),nextPageCustomData:{token:f.nextPageToken},isLastPage:!f.nextPageToken}:{items:[],isLastPage:!0}},itemLayout:({assetProps:l,onSelect:a})=>({type:"column",onClick:()=>a(l),htmlAttrs:{title:l.name},style:{border:"1px solid gray",borderRadius:8,overflow:"hidden",cursor:"pointer"},children:[{type:"custom",render:()=>{var c;return`<img src="${(c=l.customData)==null?void 0:c.thumbnailUrl}" alt="${l.name}" style="width: 100%; height: 100px; object-fit: cover">`}},{type:"text",content:l.name,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",paddingLeft:8,paddingRight:8}}]})}},Lm={youtubeAssetProvider:{searchBtn:"Search on YouTube",providerLabel:"YouTube Videos"}},zm="youtubeAssetProvider",Bm=function(n,e){const{skipVideoComponent:t,i18n:i={}}=e,o=Vm(e);n.runCommand(Y.assetProviderAdd,{provider:o});const r="search-on-youtube",s="video";if(!t){const l=n.Components.getType(s).model.prototype;n.Components.addType(s,{model:{getYoutubeTraits(){const[a,...c]=l.getYoutubeTraits.apply(this);return[a,{id:r,type:"button",label:n.I18n.t("youtubeAssetProvider.searchBtn"),command:()=>{n.AssetManager.open({providerId:o.id,providers:[],types:[],select:d=>{n.Assets.close(),this.set({videoId:d.attributes.id})},content:{header:{addUrl:!1,upload:!1}}})}},...c]}}})}n.I18n.addMessages({en:Lm,...i}),Ae({editor:n,licenseKey:e.licenseKey,plan:ee.startup,pluginName:zm,cleanup:()=>{if(n.runCommand(Y.assetProviderRemove,{id:o.id}),!t){const l=n.Components.getType(s).model.prototype;n.Components.addType(s,{model:{getYoutubeTraits(){return l.getYoutubeTraits.apply(this).filter(a=>a.id!==r)}}})}}})},Hm=Me(Bm);exports.dialogComponent=gc;exports.fsLightboxComponent=fd;exports.iconifyComponent=Dc;exports.lightGalleryComponent=Cd;exports.listPagesComponent=cd;exports.rteProseMirror=Pm;exports.rteTinyMce=Jd;exports.swiperComponent=Bd;exports.tableComponent=nd;exports.youtubeAssetProvider=Hm;
|