| `))),0,0),n.someProp("transformPasted",h=>{l=h(l,n,!0)}),l;let u=n.someProp("clipboardTextParser",h=>h(e,i,r,n));if(u)l=u;else{let h=i.marks(),{schema:d}=n.state,p=ie.fromSchema(d);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=o.appendChild(document.createElement("p"));m&&g.appendChild(p.serializeNode(d.text(m,h)))})}}else n.someProp("transformPastedHTML",u=>{t=u(t,n)}),o=xu(t),on&&bu(o);let c=o&&o.querySelector("[data-pm-slice]"),f=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(f&&f[3])for(let u=+f[3];u>0;u--){let h=o.firstChild;for(;h&&h.nodeType!=1;)h=h.nextSibling;if(!h)break;o=h}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Bt.fromSchema(n.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||f),context:i,ruleFromNode(h){return h.nodeName=="BR"&&!h.nextSibling&&h.parentNode&&!gu.test(h.parentNode.nodeName)?{ignore:!0}:null}})),f)l=Su(Ko(l,+f[1],+f[2]),f[4]);else if(l=x.maxOpen(yu(l.content,i),!0),l.openStart||l.openEnd){let u=0,h=0;for(let d=l.content.firstChild;u<l.openStart&&!d.type.spec.isolating;u++,d=d.firstChild);for(let d=l.content.lastChild;h<l.openEnd&&!d.type.spec.isolating;h++,d=d.lastChild);l=Ko(l,u,h)}return n.someProp("transformPasted",u=>{l=u(l,n,a)}),l}var gu=/^(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 yu(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let i=e.node(t).contentMatchAt(e.index(t)),s,o=[];if(n.forEach(l=>{if(!o)return;let a=i.findWrapping(l.type),c;if(!a)return o=null;if(c=o.length&&s.length&&kl(a,s,l,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=xl(o[o.length-1],s.length));let f=yl(l,a);o.push(f),i=i.matchType(f.type),s=a}}),o)return y.from(o)}return n}function yl(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,y.from(n));return n}function kl(n,e,t,r,i){if(i<n.length&&i<e.length&&n[i]==e[i]){let s=kl(n,e,t,r.lastChild,i+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(i==n.length-1?t.type:n[i+1]))return r.copy(r.content.append(y.from(yl(t,n,i+1))))}}function xl(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,xl(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(y.empty,!0);return n.copy(t.append(r))}function ai(n,e,t,r,i,s){let o=e<0?n.firstChild:n.lastChild,l=o.content;return n.childCount>1&&(s=0),i<r-1&&(l=ai(l,e,t,r,i+1,s)),i>=t&&(l=e<0?o.contentMatchAt(0).fillBefore(l,s<=i).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(y.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,o.copy(l))}function Ko(n,e,t){return e<n.openStart&&(n=new x(ai(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new x(ai(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}var bl={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};function Sl(){return document.implementation.createHTMLDocument("title")}var Xt=null;function ku(n){let e=window.trustedTypes;if(!e)return n;if(!Xt){if(Xt=e.defaultPolicy)try{return Xt.createHTML(n)}catch{}Xt=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})}return Xt.createHTML(n)}function xu(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Sl(),r=t.body,i=/<([a-z][^>\s]+)/i.exec(n),s;if((s=i&&bl[i[1].toLowerCase()])&&(n=s.map(o=>"<"+o+">").join("")+n+s.map(o=>"</"+o+">").reverse().join("")),r.innerHTML=ku(n),s)for(let o=0;o<s.length;o++)r=r.querySelector(s[o])||r;for(let o=0;o<t.styleSheets.length;o++){let l=t.styleSheets[o];for(let a=0;a<l.rules.length;a++){let c=l.rules[a];if(c instanceof CSSStyleRule){let f=r.querySelectorAll(c.selectorText);for(let u=0;u<f.length;u++)f[u].style.cssText+=c.style.cssText}}}return r}function bu(n){let e=n.querySelectorAll(F?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent=="\xA0"&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function Su(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:i,openStart:s,openEnd:o}=n;for(let l=r.length-2;l>=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;try{a.checkAttrs(r[l+1])}catch{break}i=y.from(a.create(r[l+1],i)),s++,o++}return new x(i,s,o)}var H={},_={},wu={touchstart:!0,touchmove:!0},ci=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function Cu(n){for(let e in H){let t=H[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{Ou(n,r)&&!bi(n,r)&&(n.editable||!(r.type in _))&&t(n,r)},wu[e]?{passive:!0}:void 0)}K&&n.dom.addEventListener("input",()=>null),fi(n)}function Me(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function Mu(n){n.input.mouseDown&&n.input.mouseDown.done(),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 fi(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>bi(n,r))})}function bi(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function Ou(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 Du(n,e){!bi(n,e)&&H[e.type]&&(n.editable||!(e.type in _))&&H[e.type](n,e)}_.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!Ml(n)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(Ce&&F&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),wt&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",i=>i(n,Ye(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||mu(n,t)?t.preventDefault():Me(n,"key")};_.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};_.keypress=(n,e)=>{let t=e;if(Ml(n)||!t.charCode||t.ctrlKey&&!t.altKey||ee&&t.metaKey)return;if(n.someProp("handleKeyPress",i=>i(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof S)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(t.charCode),s=()=>n.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!n.someProp("handleTextInput",o=>o(n,r.$from.pos,r.$to.pos,i,s))&&n.dispatch(s()),t.preventDefault()}};function ln(n){return{left:n.clientX,top:n.clientY}}function Tu(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function Si(n,e,t,r,i){if(r==-1)return!1;let s=n.state.doc.resolve(r);for(let o=s.depth+1;o>0;o--)if(n.someProp(e,l=>o>s.depth?l(n,t,s.nodeAfter,s.before(o),i,!0):l(n,t,s.node(o),s.before(o),i,!1)))return!0;return!1}function an(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);t=="pointer"&&r.setMeta("pointer",!0),n.dispatch(r)}function Nu(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&b.isSelectable(r)?(an(n,new b(t),"pointer"),!0):!1}function Eu(n,e){if(e==-1)return!1;let t=n.state.selection,r,i;t instanceof b&&(r=t.node);let s=n.state.doc.resolve(e);for(let o=s.depth+1;o>0;o--){let l=o>s.depth?s.nodeAfter:s.node(o);if(b.isSelectable(l)){r&&t.$from.depth>0&&o>=t.$from.depth&&s.before(t.$from.depth+1)==t.$from.pos?i=s.before(t.$from.depth):i=s.before(o);break}}return i!=null?(an(n,b.create(n.state.doc,i),"pointer"),!0):!1}function Au(n,e,t,r,i){return Si(n,"handleClickOn",e,t,r)||n.someProp("handleClick",s=>s(n,e,r))||(i?Eu(n,t):Nu(n,t))}function vu(n,e,t,r){return Si(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",i=>i(n,e,r))}function Iu(n,e,t,r){return Si(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",i=>i(n,e,r))||Ru(n,t,r)}function Ru(n,e,t){if(t.button!=0)return!1;let r=wl(n,e,!0),i=n.state.doc;return r?(an(n,r,"pointer"),r instanceof S&&i.eq(n.state.doc)&&(n.input.mouseDown=new hi(n,r)),!0):!1}function wl(n,e,t){let r=n.state.doc;if(e==-1)return r.inlineContent?S.create(r,0,r.content.size):null;let i=r.resolve(e);for(let s=i.depth+1;s>0;s--){let o=s>i.depth?i.nodeAfter:i.node(s),l=i.before(s);if(o.inlineContent)return S.create(r,l+1,l+1+o.content.size);if(t&&b.isSelectable(o))return b.create(r,l)}return null}function wi(n){return Un(n)}var Cl=ee?"metaKey":"ctrlKey";H.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=wi(n),i=Date.now(),s="singleClick";i-n.input.lastClick.time<500&&Tu(t,n.input.lastClick)&&!t[Cl]&&n.input.lastClick.button==t.button&&(n.input.lastClick.type=="singleClick"?s="doubleClick":n.input.lastClick.type=="doubleClick"&&(s="tripleClick")),n.input.lastClick={time:i,x:t.clientX,y:t.clientY,type:s,button:t.button},n.input.mouseDown&&n.input.mouseDown.done();let o=n.posAtCoords(ln(t));o&&(s=="singleClick"?n.input.mouseDown=new ui(n,o,t,!!r):(s=="doubleClick"?vu:Iu)(n,o.pos,o.inside,t)?t.preventDefault():Me(n,"pointer"))};var _n=class{constructor(e){this.view=e,this.mightDrag=null,e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this))}up(e){this.done()}move(e){e.buttons==0&&this.done()}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null)}delaySelUpdate(){return!1}},ui=class extends _n{constructor(e,t,r,i){super(e),this.pos=t,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!r[Cl],this.allowDefault=r.shiftKey;let s,o;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),o=t.inside;else{let f=e.state.doc.resolve(t.pos);s=f.parent,o=f.depth?f.before():0}let l=i?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.nodeDOM.nodeType==1?a.nodeDOM:null;let{selection:c}=e.state;r.button==0&&(s.type.spec.draggable&&s.type.spec.selectable!==!1||c instanceof b&&c.from<=o&&c.to>o)&&(this.mightDrag={node:s,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&ne&&!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()),Me(e,"pointer")}done(){super.done(),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>{this.view.isDestroyed||Oe(this.view)})}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(ln(e))),this.updateAllowDefault(e),this.allowDefault||!t?Me(this.view,"pointer"):Au(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||K&&this.mightDrag&&!this.mightDrag.node.isAtom||F&&!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)?(an(this.view,w.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):Me(this.view,"pointer")}move(e){this.updateAllowDefault(e),Me(this.view,"pointer"),super.move(e)}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return this.allowDefault?(this.delayedSelectionSync=!0,!0):!1}},hi=class extends _n{constructor(e,t){super(e),this.startSelection=t,this.startDoc=e.state.doc}move(e){if(e.buttons==0||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc)){this.done();return}e.preventDefault(),Me(this.view,"pointer");let t=this.view.posAtCoords(ln(e)),r=t&&wl(this.view,t.inside,!1);if(!r)return;let{doc:i}=this.view.state,s=this.startSelection,[o,l]=r.from<s.from?[s.to,r.from]:[s.from,r.to];an(this.view,S.create(i,o,l),"pointer")}};H.touchstart=n=>{n.input.lastTouch=Date.now(),wi(n),Me(n,"pointer")};H.touchmove=n=>{n.input.lastTouch=Date.now(),Me(n,"pointer")};H.contextmenu=n=>wi(n);function Ml(n,e){return n.composing?!0:K&&Math.abs(Date.now()-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}var Pu=Ce?5e3:-1;_.compositionstart=_.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof S&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||F&&nl&&Bu(n)))n.markCursor=n.state.storedMarks||t.marks(),Un(n,!0),n.markCursor=null;else if(Un(n,!e.selection.empty),ne&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let i=r.focusNode,s=r.focusOffset;i&&i.nodeType==1&&s!=0;){let o=s<0?i.lastChild:i.childNodes[s-1];if(!o)break;if(o.nodeType==3){let l=n.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else i=o,s=-1}}n.input.composing=!0}Ol(n,Pu)};function Bu(n){let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(!e||e.nodeType!=1||t>=e.childNodes.length)return!1;let r=e.childNodes[t];return r.nodeType==1&&r.contentEditable=="false"}_.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Date.now(),n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.badSafariComposition?n.domObserver.forceFlush():n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,Ol(n,20))};function Ol(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Un(n),e))}function Dl(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Date.now());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function zu(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=Rf(e.focusNode,e.focusOffset),r=Pf(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let i=r.pmViewDesc,s=n.domObserver.lastChangedTextNode;if(t==s||r==s)return s;if(!i||!i.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let o=t.pmViewDesc;if(!(!o||!o.isText(t.nodeValue)))return r}}return t||r}function Un(n,e=!1){if(!(Ce&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Dl(n),e||n.docView&&n.docView.dirty){let t=yi(n),r=n.state.selection;return t&&!t.eq(r)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function Lu(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 r=getSelection(),i=document.createRange();i.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}var en=Y&&Re<15||wt&&$f<604;H.copy=_.cut=(n,e)=>{let t=e,r=n.state.selection,i=t.type=="cut";if(r.empty)return;let s=en?null:t.clipboardData,o=r.content(),{dom:l,text:a}=xi(n,o);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):Lu(n,l),i&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function $u(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function Fu(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?tn(n,r.value,null,i,e):tn(n,r.textContent,r.innerHTML,i,e)},50)}function tn(n,e,t,r,i){let s=gl(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,i,s||x.empty)))return!0;if(!s)return!1;let o=$u(s),l=o?n.state.tr.replaceSelectionWith(o,r):n.state.tr.replaceSelection(s);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Tl(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," "):""}_.paste=(n,e)=>{let t=e;if(n.composing&&!Ce)return;let r=en?null:t.clipboardData,i=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&tn(n,Tl(r),r.getData("text/html"),i,t)?t.preventDefault():Fu(n,t)};var Gn=class{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}},Vu=ee?"altKey":"ctrlKey";function Nl(n,e){let t;return n.someProp("dragCopies",r=>{t=t||r(e)}),t!=null?!t:!e[Vu]}H.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let i=n.state.selection,s=i.empty?null:n.posAtCoords(ln(t)),o;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof b?i.to-1:i.to))){if(r&&r.mightDrag)o=b.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let u=n.docView.nearestDesc(t.target,!0);u&&u.node.type.spec.draggable&&u!=n.docView&&(o=b.create(n.state.doc,u.posBefore))}}let l=(o||n.state.selection).content(),{dom:a,text:c,slice:f}=xi(n,l);(!t.dataTransfer.files.length||!F||tl>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(en?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",en||t.dataTransfer.setData("text/plain",c),n.dragging=new Gn(f,Nl(n,t),o)};H.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};_.dragover=_.dragenter=(n,e)=>e.preventDefault();_.drop=(n,e)=>{try{Wu(n,e,n.dragging)}finally{n.dragging=null}};function Wu(n,e,t){if(!e.dataTransfer)return;let r=n.posAtCoords(ln(e));if(!r)return;let i=n.state.doc.resolve(r.pos),s=t&&t.slice;s?n.someProp("transformPasted",d=>{s=d(s,n,!1)}):s=gl(n,Tl(e.dataTransfer),en?null:e.dataTransfer.getData("text/html"),!1,i);let o=!!(t&&Nl(n,e));if(n.someProp("handleDrop",d=>d(n,e,s||x.empty,o))){e.preventDefault();return}if(!s)return;e.preventDefault();let l=s?Ln(n.state.doc,i.pos,s):i.pos;l==null&&(l=i.pos);let a=n.state.tr;if(o){let{node:d}=t;d?d.replace(a):a.deleteSelection()}let c=a.mapping.map(l),f=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,u=a.doc;if(f?a.replaceRangeWith(c,c,s.content.firstChild):a.replaceRange(c,c,s),a.doc.eq(u))return;let h=a.doc.resolve(c);if(f&&b.isSelectable(s.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(s.content.firstChild))a.setSelection(new b(h));else{let d=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((p,m,g,k)=>d=k),a.setSelection(ki(n,h,a.doc.resolve(d)))}n.focus(),n.dispatch(a.setMeta("uiEvent","drop"))}H.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())&&Oe(n)},20))};H.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)};H.beforeinput=(n,e)=>{if(Ce&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",s=>s(n,Ye(8,"Backspace")))))return;let{$cursor:i}=n.state.selection;i&&i.pos>0&&n.dispatch(n.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let n in _)H[n]=_[n];function nn(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}var Yn=class n{constructor(e,t){this.toDOM=e,this.spec=t||tt,this.side=this.spec.side||0}map(e,t,r,i){let{pos:s,deleted:o}=e.mapResult(t.from+i,this.side<0?-1:1);return o?null:new E(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof n&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&nn(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},et=class n{constructor(e,t){this.attrs=e,this.spec=t||tt}map(e,t,r,i){let s=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-r,o=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-r;return s>=o?null:new E(s,o,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof n&&nn(this.attrs,e.attrs)&&nn(this.spec,e.spec)}static is(e){return e.type instanceof n}destroy(){}},di=class n{constructor(e,t){this.attrs=e,this.spec=t||tt}map(e,t,r,i){let s=e.mapResult(t.from+i,1);if(s.deleted)return null;let o=e.mapResult(t.to+i,-1);return o.deleted||o.pos<=s.pos?null:new E(s.pos-r,o.pos-r,this)}valid(e,t){let{index:r,offset:i}=e.content.findIndex(t.from),s;return i==t.from&&!(s=e.child(r)).isText&&i+s.nodeSize==t.to}eq(e){return this==e||e instanceof n&&nn(this.attrs,e.attrs)&&nn(this.spec,e.spec)}destroy(){}},E=class n{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new n(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,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new n(e,e,new Yn(t,r))}static inline(e,t,r,i){return new n(e,t,new et(r,i))}static node(e,t,r,i){return new n(e,t,new di(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof et}get widget(){return this.type instanceof Yn}},bt=[],tt={},N=class n{constructor(e,t){this.local=e.length?e:bt,this.children=t.length?t:bt}static create(e,t){return t.length?Qn(t,e,0,tt):q}find(e,t,r){let i=[];return this.findInner(e??0,t??1e9,i,0,r),i}findInner(e,t,r,i,s){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=t&&l.to>=e&&(!s||s(l.spec))&&r.push(l.copy(l.from+i,l.to+i))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<t&&this.children[o+1]>e){let l=this.children[o]+1;this.children[o+2].findInner(e-l,t-l,r,i+l,s)}}map(e,t,r){return this==q||e.maps.length==0?this:this.mapInner(e,t,0,0,r||tt)}mapInner(e,t,r,i,s){let o;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,i);a&&a.type.valid(t,a)?(o||(o=[])).push(a):s.onRemove&&s.onRemove(this.local[l].spec)}return this.children.length?qu(this.children,o||[],e,t,r,i,s):o?new n(o.sort(nt),bt):q}add(e,t){return t.length?this==q?n.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let i,s=0;e.forEach((l,a)=>{let c=a+r,f;if(f=Al(t,l,c)){for(i||(i=this.children.slice());s<i.length&&i[s]<a;)s+=3;i[s]==a?i[s+2]=i[s+2].addInner(l,f,c+1):i.splice(s,0,a,a+l.nodeSize,Qn(f,l,c+1,tt)),s+=3}});let o=El(s?vl(t):t,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new n(o.length?this.local.concat(o).sort(nt):this.local,i||this.children)}remove(e){return e.length==0||this==q?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,i=this.local;for(let s=0;s<r.length;s+=3){let o,l=r[s]+t,a=r[s+1]+t;for(let f=0,u;f<e.length;f++)(u=e[f])&&u.from>l&&u.to<a&&(e[f]=null,(o||(o=[])).push(u));if(!o)continue;r==this.children&&(r=this.children.slice());let c=r[s+2].removeInner(o,l+1);c!=q?r[s+2]=c:(r.splice(s,3),s-=3)}if(i.length){for(let s=0,o;s<e.length;s++)if(o=e[s])for(let l=0;l<i.length;l++)i[l].eq(o,t)&&(i==this.local&&(i=this.local.slice()),i.splice(l--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new n(i,r):q}forChild(e,t){if(this==q)return this;if(t.isLeaf)return n.empty;let r,i;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let s=e+1,o=s+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<o&&a.to>s&&a.type instanceof et){let c=Math.max(s,a.from)-s,f=Math.min(o,a.to)-s;c<f&&(i||(i=[])).push(a.copy(c,f))}}if(i){let l=new n(i.sort(nt),bt);return r?new Xn([l,r]):l}return r||q}eq(e){if(this==e)return!0;if(!(e instanceof n)||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 Ci(this.localsInner(e))}localsInner(e){if(this==q)return bt;if(e.inlineContent||!this.local.some(et.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof et||t.push(this.local[r]);return t}forEachSet(e){e(this)}};N.empty=new N([],[]);N.removeOverlap=Ci;var q=N.empty,Xn=class n{constructor(e){this.members=e}map(e,t){let r=this.members.map(i=>i.map(e,t,tt));return n.from(r)}forChild(e,t){if(t.isLeaf)return N.empty;let r=[];for(let i=0;i<this.members.length;i++){let s=this.members[i].forChild(e,t);s!=q&&(s instanceof n?r=r.concat(s.members):r.push(s))}return n.from(r)}eq(e){if(!(e instanceof n)||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,r=!0;for(let i=0;i<this.members.length;i++){let s=this.members[i].localsInner(e);if(s.length)if(!t)t=s;else{r&&(t=t.slice(),r=!1);for(let o=0;o<s.length;o++)t.push(s[o])}}return t?Ci(r?t:t.sort(nt)):bt}static from(e){switch(e.length){case 0:return q;case 1:return e[0];default:return new n(e.every(t=>t instanceof N)?e:e.reduce((t,r)=>t.concat(r instanceof N?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function qu(n,e,t,r,i,s,o){let l=n.slice();for(let c=0,f=s;c<t.maps.length;c++){let u=0;t.maps[c].forEach((h,d,p,m)=>{let g=m-p-(d-h);for(let k=0;k<l.length;k+=3){let T=l[k+1];if(T<0||h>T+f-u)continue;let O=l[k]+f-u;d>=O?l[k+1]=h<=O?-2:-1:h>=f&&g&&(l[k]+=g,l[k+1]+=g)}u+=g}),f=t.maps[c].map(f,-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 f=t.map(n[c]+s),u=f-i;if(u<0||u>=r.content.size){a=!0;continue}let h=t.map(n[c+1]+s,-1),d=h-i,{index:p,offset:m}=r.content.findIndex(u),g=r.maybeChild(p);if(g&&m==u&&m+g.nodeSize==d){let k=l[c+2].mapInner(t,g,f+1,n[c]+s+1,o);k!=q?(l[c]=u,l[c+1]=d,l[c+2]=k):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=Ku(l,n,e,t,i,s,o),f=Qn(c,r,0,o);e=f.local;for(let u=0;u<l.length;u+=3)l[u+1]<0&&(l.splice(u,3),u-=3);for(let u=0,h=0;u<f.children.length;u+=3){let d=f.children[u];for(;h<l.length&&l[h]<d;)h+=3;l.splice(h,0,f.children[u],f.children[u+1],f.children[u+2])}}return new N(e.sort(nt),l)}function El(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let i=n[r];t.push(new E(i.from+e,i.to+e,i.type))}return t}function Ku(n,e,t,r,i,s,o){function l(a,c){for(let f=0;f<a.local.length;f++){let u=a.local[f].map(r,i,c);u?t.push(u):o.onRemove&&o.onRemove(a.local[f].spec)}for(let f=0;f<a.children.length;f+=3)l(a.children[f+2],a.children[f]+c+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+s+1);return t}function Al(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,i=null;for(let s=0,o;s<n.length;s++)(o=n[s])&&o.from>t&&o.to<r&&((i||(i=[])).push(o),n[s]=null);return i}function vl(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function Qn(n,e,t,r){let i=[],s=!1;e.forEach((l,a)=>{let c=Al(n,l,a+t);if(c){s=!0;let f=Qn(c,l,t+a+1,r);f!=q&&i.push(a,a+l.nodeSize,f)}});let o=El(s?vl(n):n,-t).sort(nt);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||(r.onRemove&&r.onRemove(o[l].spec),o.splice(l--,1));return o.length||i.length?new N(o,i):q}function nt(n,e){return n.from-e.from||n.to-e.to}function Ci(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let i=t+1;i<e.length;i++){let s=e[i];if(s.from==r.from){s.to!=r.to&&(e==n&&(e=n.slice()),e[i]=s.copy(s.from,r.to),Jo(e,i+1,s.copy(r.to,s.to)));continue}else{s.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,s.from),Jo(e,i,r.copy(s.from,r.to)));break}}}return e}function Jo(n,e,t){for(;e<n.length&&nt(t,n[e])>0;)e++;n.splice(e,0,t)}function Ur(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=q&&e.push(r)}),n.cursorWrapper&&e.push(N.create(n.state.doc,[n.cursorWrapper.deco])),Xn.from(e)}var Ju={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},ju=Y&&Re<=11,pi=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}},mi=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new pi,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;i<r.length;i++)this.queue.push(r[i]);Y&&Re<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():K&&e.composing&&r.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),ju&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Ju)),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(Lo(this.view)){if(this.suppressingSelectionUpdates)return Oe(this.view);if(Y&&Re<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&rt(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,r;for(let s=e.focusNode;s;s=St(s))t.add(s);for(let s=e.anchorNode;s;s=St(s))if(t.has(s)){r=s;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&Lo(e)&&!this.ignoreSelectionChange(r),s=-1,o=-1,l=!1,a=[];if(e.editable)for(let f=0;f<t.length;f++){let u=this.registerMutation(t[f],a);u&&(s=s<0?u.from:Math.min(u.from,s),o=o<0?u.to:Math.max(u.to,o),u.typeOver&&(l=!0))}if(a.some(f=>f.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46||F&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&t.some(f=>f.type=="childList"&&f.removedNodes.length))){for(let f of a)if(f.nodeName=="BR"&&f.parentNode){let u=f.nextSibling;for(;u&&u.nodeType==1;){if(u.contentEditable=="false"){f.parentNode.removeChild(f);break}u=u.firstChild}}}else if(ne&&a.length){let f=a.filter(u=>u.nodeName=="BR");if(f.length==2){let[u,h]=f;u.parentNode&&u.parentNode.parentNode==h.parentNode?h.remove():u.remove()}else{let{focusNode:u}=this.currentSelection;for(let h of f){let d=h.parentNode;d&&d.nodeName=="LI"&&(!u||Uu(e,u)!=d)&&h.remove()}}}let c=null;s<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Zn(r)&&(c=yi(e))&&c.eq(w.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Oe(e),this.currentSelection.set(r),e.scrollToSelection()):(s>-1||i)&&(s>-1&&(e.docView.markDirty(s,o),Hu(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,Gu(e,a)),this.handleDOMChange(s,o,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Oe(e),this.currentSelection.set(r))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let f=0;f<e.addedNodes.length;f++){let u=e.addedNodes[f];t.push(u),u.nodeType==3&&(this.lastChangedTextNode=u)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,s=e.nextSibling;if(Y&&Re<=11&&e.addedNodes.length)for(let f=0;f<e.addedNodes.length;f++){let{previousSibling:u,nextSibling:h}=e.addedNodes[f];(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(i=u),(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(s=h)}let o=i&&i.parentNode==e.target?$(i)+1:0,l=r.localPosFromDOM(e.target,o,-1),a=s&&s.parentNode==e.target?$(s):e.target.childNodes.length,c=r.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}},jo=new WeakMap,Ho=!1;function Hu(n){if(!jo.has(n)&&(jo.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=ne,Ho)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."),Ho=!0}}function _o(n,e){let t=e.startContainer,r=e.startOffset,i=e.endContainer,s=e.endOffset,o=n.domAtPos(n.state.selection.anchor);return rt(o.node,o.offset,i,s)&&([t,r,i,s]=[i,s,t,r]),{anchorNode:t,anchorOffset:r,focusNode:i,focusOffset:s}}function _u(n,e){if(e.getComposedRanges){let i=e.getComposedRanges(n.root)[0];if(i)return _o(n,i)}let t;function r(i){i.preventDefault(),i.stopImmediatePropagation(),t=i.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",r,!0),t?_o(n,t):null}function Uu(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let r=n.docView.nearestDesc(t,!0);if(r&&r.node.isBlock)return t}return null}function Gu(n,e){var t;let{focusNode:r,focusOffset:i}=n.domSelectionRange();for(let s of e)if(((t=s.parentNode)===null||t===void 0?void 0:t.nodeName)=="TR"){let o=s.nextSibling;for(;o&&o.nodeName!="TD"&&o.nodeName!="TH";)o=o.nextSibling;if(o){let l=o;for(;;){let a=l.firstChild;if(!a||a.nodeType!=1||a.contentEditable=="false"||/^(BR|IMG)$/.test(a.nodeName))break;l=a}l.insertBefore(s,l.firstChild),r==s&&n.domSelection().collapse(s,i)}else s.parentNode.removeChild(s)}}function Yu(n,e,t,r){let{node:i,fromOffset:s,toOffset:o,from:l,to:a}=n.docView.parseRange(e,t),c=n.domSelectionRange(),f,u=c.anchorNode;if(u&&n.dom.contains(u.nodeType==1?u:u.parentNode)&&(f=[{node:u,offset:c.anchorOffset}],Zn(c)||f.push({node:c.focusNode,offset:c.focusOffset})),F&&n.input.lastKeyCode===8)for(let k=o;k>s;k--){let T=i.childNodes[k-1],O=T.pmViewDesc;if(T.nodeName=="BR"&&!O){o=k;break}if(!O||O.size)break}let h=n.state.doc,d=n.someProp("domParser")||Bt.fromSchema(n.state.schema),p=h.resolve(l),m=null,g=d.parse(i,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:s,to:o,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:f,ruleFromNode:Xu(r),context:p});if(f&&f[0].pos!=null){let k=f[0].pos,T=f[1]&&f[1].pos;T==null&&(T=k),m={anchor:k+l,head:T+l}}return{doc:g,sel:m,from:l,to:a}}var Xu=n=>e=>{let t=e.pmViewDesc;if(t)return t.parseRule(n);if(e.nodeName=="BR"&&e.parentNode){if(K&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let r=document.createElement("div");return r.appendChild(document.createElement("li")),{skip:r}}else if(e.parentNode.lastChild==e||K&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName=="IMG"&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null},Qu=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Zu(n,e,t,r,i){let s=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let D=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,I=yi(n,D);if(I&&!n.state.selection.eq(I)){if(F&&Ce&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",nc=>nc(n,Ye(13,"Enter"))))return;let U=n.state.tr.setSelection(I);D=="pointer"?U.setMeta("pointer",!0):D=="key"&&U.scrollIntoView(),s&&U.setMeta("composition",s),n.dispatch(U)}return}let o=n.state.doc.resolve(e),l=o.sharedDepth(t);e=o.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,c=Yu(n,e,t,i),f=n.state.doc,u=f.slice(c.from,c.to),h,d;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(h=n.state.selection.to,d="end"):(h=n.state.selection.from,d="start"),n.input.lastKeyCode=null;let p=nh(u.content,c.doc.content,c.from,h,d);if(p&&n.input.domChangeCount++,(wt&&n.input.lastIOSEnter>Date.now()-225||Ce)&&i.some(D=>D.nodeType==1&&!Qu.test(D.nodeName))&&(!p||p.endA>=p.endB)&&n.someProp("handleKeyDown",D=>D(n,Ye(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof S&&!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 D=Uo(n,n.state.doc,c.sel);if(D&&!D.eq(n.state.selection)){let I=n.state.tr.setSelection(D);s&&I.setMeta("composition",s),n.dispatch(I)}}return}n.state.selection.from<n.state.selection.to&&p.start==p.endB&&n.state.selection instanceof S&&(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)),Y&&Re<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)==" \xA0"&&(p.start--,p.endA--,p.endB--);let m=c.doc.resolveNoCache(p.start-c.from),g=c.doc.resolveNoCache(p.endB-c.from),k=f.resolve(p.start),T=m.sameParent(g)&&m.parent.inlineContent&&k.end()>=p.endA;if((wt&&n.input.lastIOSEnter>Date.now()-225&&(!T||i.some(D=>D.nodeName=="DIV"||D.nodeName=="P"))||!T&&m.pos<c.doc.content.size&&(!m.sameParent(g)||!m.parent.inlineContent)&&m.pos<g.pos&&!/\S/.test(c.doc.textBetween(m.pos,g.pos,"","")))&&n.someProp("handleKeyDown",D=>D(n,Ye(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>p.start&&th(f,p.start,p.endA,m,g)&&n.someProp("handleKeyDown",D=>D(n,Ye(8,"Backspace")))){Ce&&F&&n.domObserver.suppressSelectionUpdates();return}F&&p.endB==p.start&&(n.input.lastChromeDelete=Date.now()),Ce&&!T&&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(D){return D(n,Ye(13,"Enter"))})},20));let O=p.start,fe=p.endA,Ve=D=>{let I=D||n.state.tr.replace(O,fe,c.doc.slice(p.start-c.from,p.endB-c.from));if(c.sel){let U=Uo(n,I.doc,c.sel);U&&!(F&&n.composing&&U.empty&&(p.start!=p.endB||n.input.lastChromeDelete<Date.now()-100)&&(U.head==O||U.head==I.mapping.map(fe)-1)||Y&&U.empty&&U.head==O)&&I.setSelection(U)}return s&&I.setMeta("composition",s),I.scrollIntoView()},pn;if(T)if(m.pos==g.pos){Y&&Re<=11&&m.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>Oe(n),20));let D=Ve(n.state.tr.delete(O,fe)),I=f.resolve(p.start).marksAcross(f.resolve(p.endA));I&&D.ensureMarks(I),n.dispatch(D)}else if(p.endA==p.endB&&(pn=eh(m.parent.content.cut(m.parentOffset,g.parentOffset),k.parent.content.cut(k.parentOffset,p.endA-k.start())))){let D=Ve(n.state.tr);pn.type=="add"?D.addMark(O,fe,pn.mark):D.removeMark(O,fe,pn.mark),n.dispatch(D)}else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let D=m.parent.textBetween(m.parentOffset,g.parentOffset),I=()=>Ve(n.state.tr.insertText(D,O,fe));n.someProp("handleTextInput",U=>U(n,O,fe,D,I))||n.dispatch(I())}else n.dispatch(Ve());else n.dispatch(Ve())}function Uo(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:ki(n,e.resolve(t.anchor),e.resolve(t.head))}function eh(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,i=t,s=r,o,l,a;for(let f=0;f<r.length;f++)i=r[f].removeFromSet(i);for(let f=0;f<t.length;f++)s=t[f].removeFromSet(s);if(i.length==1&&s.length==0)l=i[0],o="add",a=f=>f.mark(l.addToSet(f.marks));else if(i.length==0&&s.length==1)l=s[0],o="remove",a=f=>f.mark(l.removeFromSet(f.marks));else return null;let c=[];for(let f=0;f<e.childCount;f++)c.push(a(e.child(f)));if(y.from(c).eq(n))return{mark:l,type:o}}function th(n,e,t,r,i){if(t-e<=i.pos-r.pos||Gr(r,!0,!1)<i.pos)return!1;let s=n.resolve(e);if(!r.parent.isTextblock){let l=s.nodeAfter;return l!=null&&t==e+l.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let o=n.resolve(Gr(s,!0,!0));return!o.parent.isTextblock||o.pos>t||Gr(o,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function Gr(n,e,t){let r=n.depth,i=e?n.end():n.pos;for(;r>0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,i++,e=!1;if(t){let s=n.node(r).maybeChild(n.indexAfter(r));for(;s&&!s.isLeaf;)s=s.firstChild,i++}return i}function nh(n,e,t,r,i){let s=n.findDiffStart(e,t),o=t+n.size,l=t+e.size;if(s==null)return null;let{a,b:c}=n.findDiffEnd(e,o,l);if(i=="end"){let f=Math.max(0,s-Math.min(a,c));r-=a+f-s}if(a<s&&o<l){let f=r<=s&&r>=a?s-r:0;s-=f,c=s+(c-a),a=s}else if(c<s){let f=r<=s&&r>=c?s-r:0;s-=f,a=s+(a-c),c=s}return{start:s,endA:a,endB:c}}var rn=class{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 ci,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Zo),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=Xo(this),Yo(this),this.nodeViews=Qo(this),this.docView=vo(this.state.doc,Go(this),Ur(this),this.dom,this),this.domObserver=new mi(this,(r,i,s,o)=>Zu(this,r,i,s,o)),this.domObserver.start(),Cu(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&&fi(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Zo),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let i=this.state,s=!1,o=!1;e.storedMarks&&this.composing&&(Dl(this),o=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let d=Qo(this);ih(d,this.nodeViews)&&(this.nodeViews=d,s=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&fi(this),this.editable=Xo(this),Yo(this);let a=Ur(this),c=Go(this),f=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",u=s||!this.docView.matchesNode(e.doc,c,a);(u||!e.selection.eq(i.selection))&&(o=!0);let h=f=="preserve"&&o&&this.dom.style.overflowAnchor==null&&Wf(this);if(o){this.domObserver.stop();let d=u&&(Y||F)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&rh(i.selection,e.selection);if(u){let m=F?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=zu(this)),(s||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=vo(e.doc,c,a,this.dom,this)),m&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(d=!0)}let p=this.input.mouseDown;d||!(p&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&au(this)&&p.delaySelUpdate())?Oe(this,d):(dl(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),f=="reset"?this.dom.scrollTop=0:f=="to selection"?this.scrollToSelection():h&&qf(h)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof b){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Do(this,t.getBoundingClientRect(),e)}else Do(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 r=this.directPlugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let r=this.state.plugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let r=this.pluginViews[t];r.update&&r.update(this,e)}}updateDraggedNode(e,t){let r=e.node,i=-1;if(r.from<this.state.doc.content.size&&this.state.doc.nodeAt(r.from)==r.node)i=r.from;else{let s=r.from+(this.state.doc.content.size-t.doc.content.size);(s>0&&s<this.state.doc.content.size&&this.state.doc.nodeAt(s))==r.node&&(i=s)}this.dragging=new Gn(e.slice,e.move,i<0?void 0:b.create(this.state.doc,i))}someProp(e,t){let r=this._props&&this._props[e],i;if(r!=null&&(i=t?t(r):r))return i;for(let o=0;o<this.directPlugins.length;o++){let l=this.directPlugins[o].props[e];if(l!=null&&(i=t?t(l):l))return i}let s=this.state.plugins;if(s)for(let o=0;o<s.length;o++){let l=s[o].props[e];if(l!=null&&(i=t?t(l):l))return i}}hasFocus(){if(Y){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&&Kf(this.dom),Oe(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 Uf(this,e)}coordsAtPos(e,t=1){return ll(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,r=-1){let i=this.docView.posFromDOM(e,t,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,t){return Zf(this,t||this.state,e)}pasteHTML(e,t){return tn(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return tn(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return xi(this,e)}destroy(){this.docView&&(Mu(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Ur(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,vf())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Du(this,e)}domSelectionRange(){let e=this.domSelection();return e?K&&this.root.nodeType===11&&zf(this.dom.ownerDocument)==this.dom&&_u(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};rn.prototype.dispatch=function(n){let e=this._props.dispatchTransaction;e?e.call(this,n):this.updateState(this.state.apply(n))};function Go(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 r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[E.node(0,n.state.doc.content.size,e)]}function Yo(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:E.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function Xo(n){return!n.someProp("editable",e=>e(n.state)===!1)}function rh(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 Qo(n){let e=Object.create(null);function t(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function ih(n,e){let t=0,r=0;for(let i in n){if(n[i]!=e[i])return!0;t++}for(let i in e)r++;return t!=r}function Zo(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")}function Il(n={}){return new C({view(e){return new Mi(e,n)}})}var Mi=class{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let s=o=>{this[i](o)};return e.dom.addEventListener(i,s),{name:i,handler:s}})}destroy(){this.setCursor(null),this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){if(this.cursorPos!=null&&t.doc!=e.state.doc)if(this.lastDragEvent){let r=this.computeTarget(this.lastDragEvent);r==this.cursorPos?this.updateOverlay():this.setCursor(r)}else this.updateOverlay()}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,r,i=this.editorView.dom,s=i.getBoundingClientRect(),o=s.width/i.offsetWidth,l=s.height/i.offsetHeight;if(t){let u=e.nodeBefore,h=e.nodeAfter;if(u||h){let d=this.editorView.nodeDOM(this.cursorPos-(u?u.nodeSize:0));if(d){let p=d.getBoundingClientRect(),m=u?p.bottom:p.top;u&&h&&(m=(m+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let g=this.width/2*l;r={left:p.left,right:p.right,top:m-g,bottom:m+g}}}}if(!r){let u=this.editorView.coordsAtPos(this.cursorPos),h=this.width/2*o;r={left:u.left-h,right:u.left+h,top:u.top,bottom:u.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let c,f;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,f=-pageYOffset;else{let u=a.getBoundingClientRect(),h=u.width/a.offsetWidth,d=u.height/a.offsetHeight;c=u.left-a.scrollLeft*h,f=u.top-a.scrollTop*d}this.element.style.left=(r.left-c)/o+"px",this.element.style.top=(r.top-f)/l+"px",this.element.style.width=(r.right-r.left)/o+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}computeTarget(e){let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),i=r&&r.type.spec.disableDropCursor,s=typeof i=="function"?i(this.editorView,t,e):i;if(!t||s)return null;let o=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=Ln(this.editorView.state.doc,o,this.editorView.dragging.slice);l!=null&&(o=l)}return o}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let t=this.computeTarget(e);t!=null&&(this.setCursor(t),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}};var De={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},tr={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},sh=typeof navigator<"u"&&/Mac/.test(navigator.platform),oh=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(A=0;A<10;A++)De[48+A]=De[96+A]=String(A);var A;for(A=1;A<=24;A++)De[A+111]="F"+A;var A;for(A=65;A<=90;A++)De[A]=String.fromCharCode(A+32),tr[A]=String.fromCharCode(A);var A;for(er in De)tr.hasOwnProperty(er)||(tr[er]=De[er]);var er;function Rl(n){var e=sh&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||oh&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?tr:De)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}var lh=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),ah=typeof navigator<"u"&&/Win/.test(navigator.platform);function ch(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,i,s,o;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))i=!0;else if(/^s(hift)?$/i.test(a))s=!0;else if(/^mod$/i.test(a))lh?o=!0:i=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(t="Alt-"+t),i&&(t="Ctrl-"+t),o&&(t="Meta-"+t),s&&(t="Shift-"+t),t}function fh(n){let e=Object.create(null);for(let t in n)e[ch(t)]=n[t];return e}function Oi(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function Di(n){return new C({props:{handleKeyDown:Ti(n)}})}function Ti(n){let e=fh(n);return function(t,r){let i=Rl(r),s,o=e[Oi(i,r)];if(o&&o(t.state,t.dispatch,t))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let l=e[Oi(i,r,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(ah&&r.ctrlKey&&r.altKey)&&(s=De[r.keyCode])&&s!=i){let l=e[Oi(s,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}var J=class n extends w{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return n.valid(r)?new n(r):w.near(r)}content(){return x.empty}eq(e){return e instanceof n&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new n(e.resolve(t.pos))}getBookmark(){return new Ni(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!uh(e)||!hh(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let i=t.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&n.valid(e))return e;let i=e.pos,s=null;for(let o=e.depth;;o--){let l=e.node(o);if(t>0?e.indexAfter(o)<l.childCount:e.index(o)>0){s=l.child(t>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;i+=t;let a=e.doc.resolve(i);if(n.valid(a))return a}for(;;){let o=t>0?s.firstChild:s.lastChild;if(!o){if(s.isAtom&&!s.isText&&!b.isSelectable(s)){e=e.doc.resolve(i+s.nodeSize*t),r=!1;continue e}break}s=o,i+=t;let l=e.doc.resolve(i);if(n.valid(l))return l}return null}}};J.prototype.visible=!1;J.findFrom=J.findGapCursorFrom;w.jsonID("gapcursor",J);var Ni=class n{constructor(e){this.pos=e}map(e){return new n(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return J.valid(t)?new J(t):w.near(t)}};function Pl(n){return n.isAtom||n.spec.isolating||n.spec.createGapCursor}function uh(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(t-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||Pl(i.type))return!0;if(i.inlineContent)return!1}}return!0}function hh(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(t);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||Pl(i.type))return!0;if(i.inlineContent)return!1}}return!0}function Bl(){return new C({props:{decorations:gh,createSelectionBetween(n,e,t){return e.pos==t.pos&&J.valid(t)?new J(t):null},handleClick:ph,handleKeyDown:dh,handleDOMEvents:{beforeinput:mh}}})}var dh=Ti({ArrowLeft:nr("horiz",-1),ArrowRight:nr("horiz",1),ArrowUp:nr("vert",-1),ArrowDown:nr("vert",1)});function nr(n,e){let t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,s){let o=r.selection,l=e>0?o.$to:o.$from,a=o.empty;if(o instanceof S){if(!s.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=J.findGapCursorFrom(l,e,a);return c?(i&&i(r.tr.setSelection(new J(c))),!0):!1}}function ph(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!J.valid(r))return!1;let i=n.posAtCoords({left:t.clientX,top:t.clientY});return i&&i.inside>-1&&b.isSelectable(n.state.doc.nodeAt(i.inside))?!1:(n.dispatch(n.state.tr.setSelection(new J(r))),!0)}function mh(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof J))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let i=y.empty;for(let o=r.length-1;o>=0;o--)i=y.from(r[o].createAndFill(null,i));let s=n.state.tr.replace(t.pos,t.pos,new x(i,0,0));return s.setSelection(S.near(s.doc.resolve(t.pos+1))),n.dispatch(s),!1}function gh(n){if(!(n.selection instanceof J))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",N.create(n.doc,[E.widget(n.selection.head,e,{key:"gapcursor"})])}function cn(n,e,t){return Ct(n,oe(e),t)}function Ct(n,e,t={}){let r=t.origin??(()=>null),i=[];for(let o=0;o<e.length;){if(e[o].kind===v){let[l,a]=bh(n,e,o,r);i.push(...l),o=a;continue}i.push(yh(n,e[o],r(o))),o++}let s=i[i.length-1];return t.trailing!==!1&&(!s||s.type!==n.nodes.paragraph)&&i.push(n.nodes.paragraph.create()),n.nodes.doc.create(null,i)}function yh(n,e,t){let r=e.marker||null,i=Ir(e);switch(e.kind){case xe:return n.nodes.heading.create({origin:t,marker:r,level:e.level,source:e.source},rr(n,i));case he:return kh(n,e,i,t);case de:return n.nodes.horizontal_rule.create({origin:t,source:e.source});case X:return n.nodes.blockquote.create({marker:r,prefix:xh(e.source)},n.nodes.paragraph.create({origin:t},rr(n,i)))}return n.nodes.paragraph.create({origin:t,marker:r},rr(n,i))}function kh(n,e,t,r){let i=e.source.split(` |