zt-react-milkdown 0.1.3 → 0.1.5
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/README.md +2 -0
- package/dist/{dist-CZTw9GLV.js → dist-BjfIurm0.js} +1 -1
- package/dist/{dist-ZPtYoqTI.cjs → dist-D7LE16E1.cjs} +1 -1
- package/dist/floating-ui.dom-B_oXwL6O.cjs +1 -0
- package/dist/floating-ui.dom-Cm9Ov61_.js +883 -0
- package/dist/index.cjs +66 -22
- package/dist/index.mjs +4636 -2719
- package/dist/{lib-D_0WAhKU.js → lib-5lx86j_L.js} +1 -1
- package/dist/{lib-Bhr5EVOu.js → lib-72N1aRae.js} +19 -19
- package/dist/{lib-DVE2k9i1.js → lib-BIxqp3lX.js} +43 -43
- package/dist/{lib-DzY83R_P.cjs → lib-BLTQkf4j.cjs} +1 -1
- package/dist/{lib-De0djIEV.cjs → lib-BzlEyehQ.cjs} +1 -1
- package/dist/{lib-F08NY8fk.cjs → lib-C61-3fwS.cjs} +1 -1
- package/dist/{lib-5pUyY-Tl.cjs → lib-C82poHMJ.cjs} +1 -1
- package/dist/{lib-bsXGz3fj.js → lib-CDhjYvDm.js} +2 -2
- package/dist/{lib-Dplx6t-N.cjs → lib-CHQUpMrL.cjs} +1 -1
- package/dist/{lib-DmD940Fq.js → lib-CYWwNE4c.js} +1527 -1530
- package/dist/{lib-C1A-pN4b.js → lib-Cixz93sP.js} +4 -4
- package/dist/{lib-DIx8C5AZ.cjs → lib-CqJFV3ME.cjs} +1 -1
- package/dist/{lib-CVebEyb8.cjs → lib-D7VWCO2M.cjs} +1 -1
- package/dist/{lib-_NDReOAt.js → lib-DaPs62nF.js} +1 -1
- package/dist/{lib-DgEwQN1U.cjs → lib-Dka_BhhQ.cjs} +1 -1
- package/dist/{lib-BmAQCwSQ.cjs → lib-DrllUeuK.cjs} +1 -1
- package/dist/{lib-Dd20rlmV.js → lib-wpjVX5Vf.js} +1 -1
- package/dist/{lib-ChwoE6v5.js → lib-z6CKD87x.js} +2 -2
- package/dist/{schema-list-D9Q6QKgo.cjs → schema-list-CFEw5DQ8.cjs} +1 -1
- package/dist/{schema-list-DooYP5HM.js → schema-list-CiFfAlj-.js} +1 -1
- package/dist/src/lib/global-scroll-listener.d.ts +1 -1
- package/dist/src/lib/global-scroll-listener.d.ts.map +1 -1
- package/dist/src/plugins/custom/code-block/code-block-language-picker.d.ts.map +1 -1
- package/dist/src/react/hooks/useCloseOnGlobalScroll.d.ts +1 -1
- package/dist/src/react/hooks/useCloseOnGlobalScroll.d.ts.map +1 -1
- package/package.json +3 -2
- package/dist/floating-ui.dom-CV-TLBRq.cjs +0 -1
- package/dist/floating-ui.dom-CoOubeUs.js +0 -762
|
@@ -36,4 +36,4 @@ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=
|
|
|
36
36
|
`),u&&t==e.nodeValue.length)for(let t=e,n;t;t=t.parentNode){if(n=t.nextSibling){n.nodeName==`BR`&&(o=s={node:n.parentNode,offset:V(n)+1});break}let e=t.pmViewDesc;if(e&&e.node&&e.node.isBlock)break}}else{let n=e.childNodes[t-1];u=n&&(n.nodeName==`BR`||n.contentEditable==`false`)}}if(W&&l.focusNode&&l.focusNode!=s.node&&l.focusNode.nodeType==1){let e=l.focusNode.childNodes[l.focusOffset];e&&e.contentEditable==`false`&&(r=!0)}if(!(r||u&&K)&&Ro(o.node,o.offset,l.anchorNode,l.anchorOffset)&&Ro(s.node,s.offset,l.focusNode,l.focusOffset))return;let d=!1;if((c.extend||e==t)&&!(u&&W)){c.collapse(o.node,o.offset);try{e!=t&&c.extend(s.node,s.offset),d=!0}catch{}}if(!d){if(e>t){let e=o;o=s,s=e}let n=document.createRange();n.setEnd(s.node,s.offset),n.setStart(o.node,o.offset),c.removeAllRanges(),c.addRange(n)}}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 n=0,r=0;r<this.children.length;r++){let i=this.children[r],a=n+i.size;if(n==a?e<=a&&t>=n:e<a&&t>n){let r=n+i.border,o=a-i.border;if(e>=r&&t<=o){this.dirty=e==n||t==a?Hs:Vs,e==r&&t==o&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=Us:i.markDirty(e-r,t-r);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Hs:Us}n=a}this.dirty=Hs}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=e==1?Hs:Vs;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},Gs=class extends Ws{constructor(e,t,n,r){let i,a=t.type.toDOM;if(typeof a==`function`&&(a=a(n,()=>{if(!i)return r;if(i.parent)return i.parent.posBeforeChild(i)})),!t.type.spec.raw){if(a.nodeType!=1){let e=document.createElement(`span`);e.appendChild(a),a=e}a.contentEditable=`false`,a.classList.add(`ProseMirror-widget`)}super(e,[],a,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return this.dirty==J&&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 ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}},Ks=class extends Ws{constructor(e,t,n,r){super(e,[],t,null),this.textDOM=n,this.text=r}get size(){return this.text.length}localPosFromDOM(e,t){return e==this.textDOM?this.posAtStart+t:this.posAtStart+(t?this.size:0)}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type===`characterData`&&e.target.nodeValue==e.oldValue}},qs=class e extends Ws{constructor(e,t,n,r,i){super(e,[],n,r),this.mark=t,this.spec=i}static create(t,n,r,i){let a=i.nodeViews[n.type.name],o=a&&a(n,i,r);return(!o||!o.dom)&&(o=u.C.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new e(t,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&Us||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Us&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=J){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty<this.dirty&&(e.dirty=this.dirty),this.dirty=J}}slice(t,n,r){let i=e.create(this.parent,this.mark,!0,r),a=this.children,o=this.size;n<o&&(a=mc(a,n,o,r)),t>0&&(a=mc(a,0,t,r));for(let e=0;e<a.length;e++)a[e].parent=i;return i.children=a,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},Js=class e extends Ws{constructor(e,t,n,r,i,a,o,s,c){super(e,[],i,a),this.node=t,this.outerDeco=n,this.innerDeco=r,this.nodeDOM=o}static create(t,n,r,i,a,o){let s=a.nodeViews[n.type.name],c,l=s&&s(n,a,()=>{if(!c)return o;if(c.parent)return c.parent.posBeforeChild(c)},r,i),d=l&&l.dom,f=l&&l.contentDOM;if(n.isText){if(!d)d=document.createTextNode(n.text);else if(d.nodeType!=3)throw RangeError(`Text must be rendered as a DOM text node`)}else if(!d){let e=u.C.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs);({dom:d,contentDOM:f}=e)}!f&&!n.isText&&d.nodeName!=`BR`&&(d.hasAttribute(`contenteditable`)||(d.contentEditable=`false`),n.type.spec.draggable&&(d.draggable=!0));let p=d;return d=ac(d,r,n),l?c=new Qs(t,n,r,i,d,f||null,p,l,a,o+1):n.isText?new Xs(t,n,r,i,d,p,a):new e(t,n,r,i,d,f||null,p,a,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace==`pre`&&(e.preserveWhitespace=`full`),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let n=this.children[t];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}e.contentElement||(e.getContent=()=>u.w.empty)}return e}matchesNode(e,t,n){return this.dirty==J&&e.eq(this.node)&&oc(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return+!this.node.isLeaf}updateChildren(e,t){let n=this.node.inlineContent,r=t,i=e.composing?this.localCompositionInfo(e,t):null,a=i&&i.pos>-1?i:null,o=i&&i.pos<0,s=new cc(this,a&&a.node,e);dc(this.node,this.innerDeco,(t,i,a)=>{t.spec.marks?s.syncToMarks(t.spec.marks,n,e,i):t.type.side>=0&&!a&&s.syncToMarks(i==this.node.childCount?u.T.none:this.node.child(i).marks,n,e,i),s.placeWidget(t,e,r)},(t,a,c,l)=>{s.syncToMarks(t.marks,n,e,l);let u;s.findNodeMatch(t,a,c,l)||o&&e.state.selection.from>r&&e.state.selection.to<r+t.nodeSize&&(u=s.findIndexWithChild(i.node))>-1&&s.updateNodeAt(t,a,c,u,e)||s.updateNextNode(t,a,c,e,l,r)||s.addNode(t,a,c,e,r),r+=t.nodeSize}),s.syncToMarks([],n,e,0),this.node.isTextblock&&s.addTextblockHacks(),s.destroyRest(),(s.changed||this.dirty==Hs)&&(a&&this.protectLocalComposition(e,a),$s(this.contentDOM,this.children,e),is&&fc(this.dom))}localCompositionInfo(e,t){let{from:n,to:r}=e.state.selection;if(!(e.state.selection instanceof u.c)||n<t||r>t+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let e=i.nodeValue,a=pc(this.node.content,e,n-t,r-t);return a<0?null:{node:i,pos:a,text:e}}else return{node:i,pos:-1,text:``}}protectLocalComposition(e,{node:t,pos:n,text:r}){if(this.getDesc(t))return;let i=t;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&=void 0}let a=new Ks(this,i,t,r);e.input.compositionNodes.push(a),this.children=mc(this.children,n,n+r.length,e,a)}update(e,t,n,r){return this.dirty==Us||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,n,r),!0)}updateInner(e,t,n,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=J}updateOuterDeco(e){if(oc(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=rc(this.dom,this.nodeDOM,nc(this.outerDeco,this.node,t),nc(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add(`ProseMirror-selectednode`),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove(`ProseMirror-selectednode`),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute(`draggable`))}get domAtom(){return this.node.isAtom}};function Ys(e,t,n,r,i){ac(r,t,e);let a=new Js(void 0,e,t,n,r,r,r,i,0);return a.contentDOM&&a.updateChildren(i,0),a}var Xs=class e extends Js{constructor(e,t,n,r,i,a,o){super(e,t,n,r,i,null,a,o,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,r){return this.dirty==Us||this.dirty!=J&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=J||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=J,!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,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return e.type!=`characterData`&&e.type!=`selection`}slice(t,n,r){let i=this.node.cut(t,n),a=document.createTextNode(i.text);return new e(this.parent,i,this.outerDeco,this.innerDeco,a,a,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Us)}get domAtom(){return!1}isText(e){return this.node.text==e}},Zs=class extends Ws{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==J&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName==`IMG`}},Qs=class extends Js{constructor(e,t,n,r,i,a,o,s,c,l){super(e,t,n,r,i,a,o,c,l),this.spec=s}update(e,t,n,r){if(this.dirty==Us)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,t,n);return i&&this.updateInner(e,t,n,r),i}else if(!this.contentDOM&&!e.isLeaf)return!1;else return super.update(e,t,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,r){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,r)}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 $s(e,t,n){let r=e.firstChild,i=!1;for(let a=0;a<t.length;a++){let o=t[a],s=o.dom;if(s.parentNode==e){for(;s!=r;)r=sc(r),i=!0;r=r.nextSibling}else i=!0,e.insertBefore(s,r);if(o instanceof qs){let t=r?r.previousSibling:e.lastChild;$s(o.contentDOM,o.children,n),r=t?t.nextSibling:e.firstChild}}for(;r;)r=sc(r),i=!0;i&&n.trackWrites==e&&(n.trackWrites=null)}var ec=function(e){e&&(this.nodeName=e)};ec.prototype=Object.create(null);var tc=[new ec];function nc(e,t,n){if(e.length==0)return tc;let r=n?tc[0]:new ec,i=[r];for(let a=0;a<e.length;a++){let o=e[a].type.attrs;if(o){o.nodeName&&i.push(r=new ec(o.nodeName));for(let e in o){let a=o[e];a!=null&&(n&&i.length==1&&i.push(r=new ec(t.isInline?`span`:`div`)),e==`class`?r.class=(r.class?r.class+` `:``)+a:e==`style`?r.style=(r.style?r.style+`;`:``)+a:e!=`nodeName`&&(r[e]=a))}}}return i}function rc(e,t,n,r){if(n==tc&&r==tc)return t;let i=t;for(let t=0;t<r.length;t++){let a=r[t],o=n[t];if(t){let t;o&&o.nodeName==a.nodeName&&i!=e&&(t=i.parentNode)&&t.nodeName.toLowerCase()==a.nodeName?i=t:(t=document.createElement(a.nodeName),t.pmIsDeco=!0,t.appendChild(i),o=tc[0],i=t)}ic(i,o||tc[0],a)}return i}function ic(e,t,n){for(let r in t)r!=`class`&&r!=`style`&&r!=`nodeName`&&!(r in n)&&e.removeAttribute(r);for(let r in n)r!=`class`&&r!=`style`&&r!=`nodeName`&&n[r]!=t[r]&&e.setAttribute(r,n[r]);if(t.class!=n.class){let r=t.class?t.class.split(` `).filter(Boolean):[],i=n.class?n.class.split(` `).filter(Boolean):[];for(let t=0;t<r.length;t++)i.indexOf(r[t])==-1&&e.classList.remove(r[t]);for(let t=0;t<i.length;t++)r.indexOf(i[t])==-1&&e.classList.add(i[t]);e.classList.length==0&&e.removeAttribute(`class`)}if(t.style!=n.style){if(t.style){let n=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,r;for(;r=n.exec(t.style);)e.style.removeProperty(r[1])}n.style&&(e.style.cssText+=n.style)}}function ac(e,t,n){return rc(e,e,tc,nc(t,n,e.nodeType!=1))}function oc(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function sc(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}var cc=class{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=lc(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n,r){let i=0,a=this.stack.length>>1,o=Math.min(a,e.length);for(;i<o&&(i==a-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<a;)this.destroyRest(),this.top.dirty=J,this.index=this.stack.pop(),this.top=this.stack.pop(),a--;for(;a<e.length;){this.stack.push(this.top,this.index+1);let i=-1,o=this.top.children.length;r<this.preMatch.index&&(o=Math.min(this.index+3,o));for(let t=this.index;t<o;t++){let n=this.top.children[t];if(n.matchesMark(e[a])&&!this.isLocked(n.dom)){i=t;break}}if(i>-1)i>this.index&&(this.changed=!0,this.destroyBetween(this.index,i)),this.top=this.top.children[this.index];else{let r=qs.create(this.top,e[a],t,n);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,a++}}findNodeMatch(e,t,n,r){let i=-1,a;if(r>=this.preMatch.index&&(a=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&a.matchesNode(e,t,n))i=this.top.children.indexOf(a,this.index);else for(let r=this.index,a=Math.min(this.top.children.length,r+5);r<a;r++){let a=this.top.children[r];if(a.matchesNode(e,t,n)&&!this.preMatch.matched.has(a)){i=r;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,n,r,i){let a=this.top.children[r];return a.dirty==Us&&a.dom==a.contentDOM&&(a.dirty=Hs),a.update(e,t,n,i)?(this.destroyBetween(this.index,r),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let t=e.pmViewDesc;if(t){for(let e=this.index;e<this.top.children.length;e++)if(this.top.children[e]==t)return e}return-1}e=t}}updateNextNode(e,t,n,r,i,a){for(let o=this.index;o<this.top.children.length;o++){let s=this.top.children[o];if(s instanceof Js){let c=this.preMatch.matched.get(s);if(c!=null&&c!=i)return!1;let l=s.dom,u,d=this.isLocked(l)&&!(e.isText&&s.node&&s.node.isText&&s.nodeDOM.nodeValue==e.text&&s.dirty!=Us&&oc(t,s.outerDeco));if(!d&&s.update(e,t,n,r))return this.destroyBetween(this.index,o),s.dom!=l&&(this.changed=!0),this.index++,!0;if(!d&&(u=this.recreateWrapper(s,e,t,n,r,a)))return this.destroyBetween(this.index,o),this.top.children[this.index]=u,u.contentDOM&&(u.dirty=Hs,u.updateChildren(r,a+1),u.dirty=J),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,r,i,a){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!oc(n,e.outerDeco)||!r.eq(e.innerDeco))return null;let o=Js.create(this.top,t,n,r,i,a);if(o.contentDOM){o.children=e.children,e.children=[];for(let e of o.children)e.parent=o}return e.destroy(),o}addNode(e,t,n,r,i){let a=Js.create(this.top,e,t,n,r,i);a.contentDOM&&a.updateChildren(r,i+1),this.top.children.splice(this.index++,0,a),this.changed=!0}placeWidget(e,t,n){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(r&&r.matchesWidget(e)&&(e==r.widget||!r.widget.type.toDOM.parentNode))this.index++;else{let r=new Gs(this.top,e,t,n);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 qs;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Xs)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((K||G)&&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 n=document.createElement(e);e==`IMG`&&(n.className=`ProseMirror-separator`,n.alt=``),e==`BR`&&(n.className=`ProseMirror-trailingBreak`);let r=new Zs(this.top,[],n,null);t==this.top?t.children.splice(this.index++,0,r):t.children.push(r),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}};function lc(e,t){let n=t,r=n.children.length,i=e.childCount,a=new Map,o=[];outer:for(;i>0;){let s;for(;;)if(r){let e=n.children[r-1];if(e instanceof qs)n=e,r=e.children.length;else{s=e,r--;break}}else if(n==t)break outer;else r=n.parent.children.indexOf(n),n=n.parent;let c=s.node;if(c){if(c!=e.child(i-1))break;--i,a.set(s,i),o.push(s)}}return{index:i,matched:a,matches:o.reverse()}}function uc(e,t){return e.type.side-t.type.side}function dc(e,t,n,r){let i=t.locals(e),a=0;if(i.length==0){for(let n=0;n<e.childCount;n++){let o=e.child(n);r(o,i,t.forChild(a,o),n),a+=o.nodeSize}return}let o=0,s=[],c=null;for(let l=0;;){let u,d;for(;o<i.length&&i[o].to==a;){let e=i[o++];e.widget&&(u?(d||=[u]).push(e):u=e)}if(u)if(d){d.sort(uc);for(let e=0;e<d.length;e++)n(d[e],l,!!c)}else n(u,l,!!c);let f,p;if(c)p=-1,f=c,c=null;else if(l<e.childCount)p=l,f=e.child(l++);else break;for(let e=0;e<s.length;e++)s[e].to<=a&&s.splice(e--,1);for(;o<i.length&&i[o].from<=a&&i[o].to>a;)s.push(i[o++]);let m=a+f.nodeSize;if(f.isText){let e=m;o<i.length&&i[o].from<e&&(e=i[o].from);for(let t=0;t<s.length;t++)s[t].to<e&&(e=s[t].to);e<m&&(c=f.cut(e-a),f=f.cut(0,e-a),m=e,p=-1)}else for(;o<i.length&&i[o].to<m;)o++;let h=f.isInline&&!f.isLeaf?s.filter(e=>!e.inline):s.slice();r(f,h,t.forChild(a,f),p),a=m}}function fc(e){if(e.nodeName==`UL`||e.nodeName==`OL`){let t=e.style.cssText;e.style.cssText=t+`; list-style: square !important`,window.getComputedStyle(e).listStyle,e.style.cssText=t}}function pc(e,t,n,r){for(let i=0,a=0;i<e.childCount&&a<=r;){let o=e.child(i++),s=a;if(a+=o.nodeSize,!o.isText)continue;let c=o.text;for(;i<e.childCount;){let t=e.child(i++);if(a+=t.nodeSize,!t.isText)break;c+=t.text}if(a>=n){if(a>=r&&c.slice(r-t.length-s,r-s)==t)return r-t.length;let e=s<r?c.lastIndexOf(t,r-s-1):-1;if(e>=0&&e+t.length+s>=n)return s+e;if(n==r&&c.length>=r+t.length-s&&c.slice(r-s,r-s+t.length)==t)return r}}return-1}function mc(e,t,n,r,i){let a=[];for(let o=0,s=0;o<e.length;o++){let c=e[o],l=s,u=s+=c.size;l>=n||u<=t?a.push(c):(l<t&&a.push(c.slice(0,t-l,r)),i&&=(a.push(i),void 0),u>n&&a.push(c.slice(n-l,c.size,r)))}return a}function hc(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let i=e.docView.nearestDesc(n.focusNode),a=i&&i.size==0,o=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let s=r.resolve(o),c,l;if(Go(n)){for(c=o;i&&!i.node;)i=i.parent;let e=i.node;if(i&&e.isAtom&&u.r.isSelectable(e)&&i.parent&&!(e.isInline&&Uo(n.focusNode,n.focusOffset,i.dom))){let e=i.posBefore;l=new u.r(o==e?s:r.resolve(e))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let t=o,i=o;for(let r=0;r<n.rangeCount;r++){let a=n.getRangeAt(r);t=Math.min(t,e.docView.posFromDOM(a.startContainer,a.startOffset,1)),i=Math.max(i,e.docView.posFromDOM(a.endContainer,a.endOffset,-1))}if(t<0)return null;[c,o]=i==e.state.selection.anchor?[i,t]:[t,i],s=r.resolve(o)}else c=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(c<0)return null}let d=r.resolve(c);if(!l){let n=t==`pointer`||e.state.selection.head<s.pos&&!a?1:-1;l=Ec(e,d,s,n)}return l}function gc(e){return e.editable?e.hasFocus():Oc(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function _c(e,t=!1){let n=e.state.selection;if(wc(e,n),gc(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&G){let t=e.domSelectionRange(),n=e.domObserver.currentSelection;if(t.anchorNode&&n.anchorNode&&Ro(t.anchorNode,t.anchorOffset,n.anchorNode,n.anchorOffset)){e.input.mouseDown.delayedSelectionSync=!0,e.domObserver.setCurSelection();return}}if(e.domObserver.disconnectSelection(),e.cursorWrapper)Cc(e);else{let{anchor:r,head:i}=n,a,o;vc&&!(n instanceof u.c)&&(n.$from.parent.inlineContent||(a=yc(e,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=yc(e,n.to))),e.docView.setSelection(r,i,e,t),vc&&(a&&xc(a),o&&xc(o)),n.visible?e.dom.classList.remove(`ProseMirror-hideselection`):(e.dom.classList.add(`ProseMirror-hideselection`),`onselectionchange`in document&&Sc(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}var vc=K||G&&rs<63;function yc(e,t){let{node:n,offset:r}=e.docView.domFromPos(t,0),i=r<n.childNodes.length?n.childNodes[r]:null,a=r?n.childNodes[r-1]:null;if(K&&i&&i.contentEditable==`false`)return bc(i);if((!i||i.contentEditable==`false`)&&(!a||a.contentEditable==`false`)){if(i)return bc(i);if(a)return bc(a)}}function bc(e){return e.contentEditable=`true`,K&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function xc(e){e.contentEditable=`false`,e.wasDraggable&&=(e.draggable=!0,null)}function Sc(e){let t=e.dom.ownerDocument;t.removeEventListener(`selectionchange`,e.input.hideSelectionGuard);let n=e.domSelectionRange(),r=n.anchorNode,i=n.anchorOffset;t.addEventListener(`selectionchange`,e.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=i)&&(t.removeEventListener(`selectionchange`,e.input.hideSelectionGuard),setTimeout(()=>{(!gc(e)||e.state.selection.visible)&&e.dom.classList.remove(`ProseMirror-hideselection`)},20))})}function Cc(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,r=n.nodeName==`IMG`;r?t.collapse(n.parentNode,V(n)+1):t.collapse(n,0),!r&&!e.state.selection.visible&&U&&ts<=11&&(n.disabled=!0,n.disabled=!1)}function wc(e,t){if(t instanceof u.r){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(Tc(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else Tc(e)}function Tc(e){e.lastSelectedViewDesc&&=(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),void 0)}function Ec(e,t,n,r){return e.someProp(`createSelectionBetween`,r=>r(e,t,n))||u.c.between(t,n,r)}function Dc(e){return e.editable&&!e.hasFocus()?!1:Oc(e)}function Oc(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(t.anchorNode.nodeType==3?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(t.focusNode.nodeType==3?t.focusNode.parentNode:t.focusNode))}catch{return!1}}function kc(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return Ro(t.node,t.offset,n.anchorNode,n.anchorOffset)}function Ac(e,t){let{$anchor:n,$head:r}=e.selection,i=t>0?n.max(r):n.min(r),a=i.parent.inlineContent?i.depth?e.doc.resolve(t>0?i.after():i.before()):null:i;return a&&u.o.findFrom(a,t)}function jc(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function Mc(e,t,n){let r=e.state.selection;if(r instanceof u.c){if(n.indexOf(`s`)>-1){let{$head:n}=r,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let a=e.state.doc.resolve(n.pos+i.nodeSize*(t<0?-1:1));return jc(e,new u.c(r.$anchor,a))}else if(!r.empty)return!1;else if(e.endOfTextblock(t>0?`forward`:`backward`)){let n=Ac(e.state,t);return n&&n instanceof u.r?jc(e,n):!1}else if(!(q&&n.indexOf(`m`)>-1)){let n=r.$head,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter,a;if(!i||i.isText)return!1;let o=t<0?n.pos-i.nodeSize:n.pos;return i.isAtom||(a=e.docView.descAt(o))&&!a.contentDOM?u.r.isSelectable(i)?jc(e,new u.r(t<0?e.state.doc.resolve(n.pos-i.nodeSize):n)):ss?jc(e,new u.c(e.state.doc.resolve(t<0?o:o+i.nodeSize))):!1:!1}}else if(r instanceof u.r&&r.node.isInline)return jc(e,new u.c(t>0?r.$to:r.$from));else{let n=Ac(e.state,t);return n?jc(e,n):!1}}function Nc(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function Pc(e,t){let n=e.pmViewDesc;return n&&n.size==0&&(t<0||e.nextSibling||e.nodeName!=`BR`)}function Fc(e,t){return t<0?Ic(e):Lc(e)}function Ic(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i,a,o=!1;for(W&&n.nodeType==1&&r<Nc(n)&&Pc(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let e=n.childNodes[r-1];if(Pc(e,-1))i=n,a=--r;else if(e.nodeType==3)n=e,r=n.nodeValue.length;else break}}else if(Rc(n))break;else{let t=n.previousSibling;for(;t&&Pc(t,-1);)i=n.parentNode,a=V(t),t=t.previousSibling;if(t)n=t,r=Nc(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}o?Vc(e,n,r):i&&Vc(e,i,a)}function Lc(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i=Nc(n),a,o;for(;;)if(r<i){if(n.nodeType!=1)break;let e=n.childNodes[r];if(Pc(e,1))a=n,o=++r;else break}else if(Rc(n))break;else{let t=n.nextSibling;for(;t&&Pc(t,1);)a=t.parentNode,o=V(t)+1,t=t.nextSibling;if(t)n=t,r=0,i=Nc(n);else{if(n=n.parentNode,n==e.dom)break;r=i=0}}a&&Vc(e,a,o)}function Rc(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function zc(e,t){for(;e&&t==e.childNodes.length&&!Wo(e);)t=V(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable==`false`)break;e=n,t=0}}function Bc(e,t){for(;e&&!t&&!Wo(e);)t=V(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable==`false`)break;e=n,t=e.childNodes.length}}function Vc(e,t,n){if(t.nodeType!=3){let e,r;(r=zc(t,n))?(t=r,n=0):(e=Bc(t,n))&&(t=e,n=e.nodeValue.length)}let r=e.domSelection();if(!r)return;if(Go(r)){let e=document.createRange();e.setEnd(t,n),e.setStart(t,n),r.removeAllRanges(),r.addRange(e)}else r.extend&&r.extend(t,n);e.domObserver.setCurSelection();let{state:i}=e;setTimeout(()=>{e.state==i&&_c(e)},50)}function Hc(e,t){let n=e.state.doc.resolve(t);if(!(G||as)&&n.parent.inlineContent){let r=e.coordsAtPos(t);if(t>n.start()){let n=e.coordsAtPos(t-1),i=(n.top+n.bottom)/2;if(i>r.top&&i<r.bottom&&Math.abs(n.left-r.left)>1)return n.left<r.left?`ltr`:`rtl`}if(t<n.end()){let n=e.coordsAtPos(t+1),i=(n.top+n.bottom)/2;if(i>r.top&&i<r.bottom&&Math.abs(n.left-r.left)>1)return n.left>r.left?`ltr`:`rtl`}}return getComputedStyle(e.dom).direction==`rtl`?`rtl`:`ltr`}function Uc(e,t,n){let r=e.state.selection;if(r instanceof u.c&&!r.empty||n.indexOf(`s`)>-1||q&&n.indexOf(`m`)>-1)return!1;let{$from:i,$to:a}=r;if(!i.parent.inlineContent||e.endOfTextblock(t<0?`up`:`down`)){let n=Ac(e.state,t);if(n&&n instanceof u.r)return jc(e,n)}if(!i.parent.inlineContent){let n=t<0?i:a,o=r instanceof u.t?u.o.near(n,t):u.o.findFrom(n,t);return o?jc(e,o):!1}return!1}function Wc(e,t){if(!(e.state.selection instanceof u.c))return!0;let{$head:n,$anchor:r,empty:i}=e.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(e.endOfTextblock(t>0?`forward`:`backward`))return!0;let a=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(a&&!a.isText){let r=e.state.tr;return t<0?r.delete(n.pos-a.nodeSize,n.pos):r.delete(n.pos,n.pos+a.nodeSize),e.dispatch(r),!0}return!1}function Gc(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function Kc(e){if(!K||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&t.nodeType==1&&n==0&&t.firstChild&&t.firstChild.contentEditable==`false`){let n=t.firstChild;Gc(e,n,`true`),setTimeout(()=>Gc(e,n,`false`),20)}return!1}function qc(e){let t=``;return e.ctrlKey&&(t+=`c`),e.metaKey&&(t+=`m`),e.altKey&&(t+=`a`),e.shiftKey&&(t+=`s`),t}function Jc(e,t){let n=t.keyCode,r=qc(t);if(n==8||q&&n==72&&r==`c`)return Wc(e,-1)||Fc(e,-1);if(n==46&&!t.shiftKey||q&&n==68&&r==`c`)return Wc(e,1)||Fc(e,1);if(n==13||n==27)return!0;if(n==37||q&&n==66&&r==`c`){let t=n==37?Hc(e,e.state.selection.from)==`ltr`?-1:1:-1;return Mc(e,t,r)||Fc(e,t)}else if(n==39||q&&n==70&&r==`c`){let t=n==39?Hc(e,e.state.selection.from)==`ltr`?1:-1:1;return Mc(e,t,r)||Fc(e,t)}else if(n==38||q&&n==80&&r==`c`)return Uc(e,-1,r)||Fc(e,-1);else if(n==40||q&&n==78&&r==`c`)return Kc(e)||Uc(e,1,r)||Fc(e,1);else if(r==(q?`m`:`c`)&&(n==66||n==73||n==89||n==90))return!0;return!1}function Yc(e,t){e.someProp(`transformCopied`,n=>{t=n(t,e)});let n=[],{content:r,openStart:i,openEnd:a}=t;for(;i>1&&a>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,a--;let e=r.firstChild;n.push(e.type.name,e.attrs==e.type.defaultAttrs?null:e.attrs),r=e.content}let o=e.someProp(`clipboardSerializer`)||u.C.fromSchema(e.state.schema),s=ol(),c=s.createElement(`div`);c.appendChild(o.serializeFragment(r,{document:s}));let l=c.firstChild,d,f=0;for(;l&&l.nodeType==1&&(d=il[l.nodeName.toLowerCase()]);){for(let e=d.length-1;e>=0;e--){let t=s.createElement(d[e]);for(;c.firstChild;)t.appendChild(c.firstChild);c.appendChild(t),f++}l=c.firstChild}return l&&l.nodeType==1&&l.setAttribute(`data-pm-slice`,`${i} ${a}${f?` -${f}`:``} ${JSON.stringify(n)}`),{dom:c,text:e.someProp(`clipboardTextSerializer`,n=>n(t,e))||t.content.textBetween(0,t.content.size,`
|
|
37
37
|
|
|
38
38
|
`),slice:t}}function Xc(e,t,n,r,i){let a=i.parent.type.spec.code,o,s;if(!n&&!t)return null;let c=!!t&&(r||a||!n);if(c){if(e.someProp(`transformPastedText`,n=>{t=n(t,a||r,e)}),a)return s=new u.A(u.w.from(e.state.schema.text(t.replace(/\r\n?/g,`
|
|
39
|
-
`))),0,0),e.someProp(`transformPasted`,t=>{s=t(s,e,!0)}),s;let n=e.someProp(`clipboardTextParser`,n=>n(t,i,r,e));if(n)s=n;else{let n=i.marks(),{schema:r}=e.state,a=u.C.fromSchema(r);o=document.createElement(`div`),t.split(/(?:\r\n?|\n)+/).forEach(e=>{let t=o.appendChild(document.createElement(`p`));e&&t.appendChild(a.serializeNode(r.text(e,n)))})}}else e.someProp(`transformPastedHTML`,t=>{n=t(n,e)}),o=ll(n),ss&&ul(o);let l=o&&o.querySelector(`[data-pm-slice]`),d=l&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(l.getAttribute(`data-pm-slice`)||``);if(d&&d[3])for(let e=+d[3];e>0;e--){let e=o.firstChild;for(;e&&e.nodeType!=1;)e=e.nextSibling;if(!e)break;o=e}if(s||=(e.someProp(`clipboardParser`)||e.someProp(`domParser`)||u.S.fromSchema(e.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||d),context:i,ruleFromNode(e){return e.nodeName==`BR`&&!e.nextSibling&&e.parentNode&&!Zc.test(e.parentNode.nodeName)?{ignore:!0}:null}}),d)s=dl(rl(s,+d[1],+d[2]),d[4]);else if(s=u.A.maxOpen(Qc(s.content,i),!0),s.openStart||s.openEnd){let e=0,t=0;for(let t=s.content.firstChild;e<s.openStart&&!t.type.spec.isolating;e++,t=t.firstChild);for(let e=s.content.lastChild;t<s.openEnd&&!e.type.spec.isolating;t++,e=e.lastChild);s=rl(s,e,t)}return e.someProp(`transformPasted`,t=>{s=t(s,e,c)}),s}var Zc=/^(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 Qc(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let r=t.node(n).contentMatchAt(t.index(n)),i,a=[];if(e.forEach(e=>{if(!a)return;let t=r.findWrapping(e.type),n;if(!t)return a=null;if(n=a.length&&i.length&&el(t,i,e,a[a.length-1],0))a[a.length-1]=n;else{a.length&&(a[a.length-1]=tl(a[a.length-1],i.length));let n=$c(e,t);a.push(n),r=r.matchType(n.type),i=t}}),a)return u.w.from(a)}return e}function $c(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,u.w.from(e));return e}function el(e,t,n,r,i){if(i<e.length&&i<t.length&&e[i]==t[i]){let a=el(e,t,n,r.lastChild,i+1);if(a)return r.copy(r.content.replaceChild(r.childCount-1,a));if(r.contentMatchAt(r.childCount).matchType(i==e.length-1?n.type:e[i+1]))return r.copy(r.content.append(u.w.from($c(n,e,i+1))))}}function tl(e,t){if(t==0)return e;let n=e.content.replaceChild(e.childCount-1,tl(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(u.w.empty,!0);return e.copy(n.append(r))}function nl(e,t,n,r,i,a){let o=t<0?e.firstChild:e.lastChild,s=o.content;return e.childCount>1&&(a=0),i<r-1&&(s=nl(s,t,n,r,i+1,a)),i>=n&&(s=t<0?o.contentMatchAt(0).fillBefore(s,a<=i).append(s):s.append(o.contentMatchAt(o.childCount).fillBefore(u.w.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,o.copy(s))}function rl(e,t,n){return t<e.openStart&&(e=new u.A(nl(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new u.A(nl(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}var il={thead:[`table`],tbody:[`table`],tfoot:[`table`],caption:[`table`],colgroup:[`table`],col:[`table`,`colgroup`],tr:[`table`,`tbody`],td:[`table`,`tbody`,`tr`],th:[`table`,`tbody`,`tr`]},al=null;function ol(){return al||=document.implementation.createHTMLDocument(`title`)}var sl=null;function cl(e){let t=window.trustedTypes;return t?(sl||=t.defaultPolicy||t.createPolicy(`ProseMirrorClipboard`,{createHTML:e=>e}),sl.createHTML(e)):e}function ll(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=ol().createElement(`div`),r=/<([a-z][^>\s]+)/i.exec(e),i;if((i=r&&il[r[1].toLowerCase()])&&(e=i.map(e=>`<`+e+`>`).join(``)+e+i.map(e=>`</`+e+`>`).reverse().join(``)),n.innerHTML=cl(e),i)for(let e=0;e<i.length;e++)n=n.querySelector(i[e])||n;return n}function ul(e){let t=e.querySelectorAll(G?`span:not([class]):not([style])`:`span.Apple-converted-space`);for(let n=0;n<t.length;n++){let r=t[n];r.childNodes.length==1&&r.textContent==`\xA0`&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(` `),r)}}function dl(e,t){if(!e.size)return e;let n=e.content.firstChild.type.schema,r;try{r=JSON.parse(t)}catch{return e}let{content:i,openStart:a,openEnd:o}=e;for(let e=r.length-2;e>=0;e-=2){let t=n.nodes[r[e]];if(!t||t.hasRequiredAttrs())break;i=u.w.from(t.create(r[e+1],i)),a++,o++}return new u.A(i,a,o)}var Y={},X={},fl={touchstart:!0,touchmove:!0},pl=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 ml(e){for(let t in Y){let n=Y[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{yl(e,t)&&!vl(e,t)&&(e.editable||!(t.type in X))&&n(e,t)},fl[t]?{passive:!0}:void 0)}K&&e.dom.addEventListener(`input`,()=>null),_l(e)}function hl(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function gl(e){e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}function _l(e){e.someProp(`handleDOMEvents`,t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>vl(e,t))})}function vl(e,t){return e.someProp(`handleDOMEvents`,n=>{let r=n[t.type];return r?r(e,t)||t.defaultPrevented:!1})}function yl(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function bl(e,t){!vl(e,t)&&Y[t.type]&&(e.editable||!(t.type in X))&&Y[t.type](e,t)}X.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,!Pl(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!(os&&G&&n.keyCode==13)))if(n.keyCode!=229&&e.domObserver.forceFlush(),is&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==t&&(e.someProp(`handleKeyDown`,t=>t(e,Ko(13,`Enter`))),e.input.lastIOSEnter=0)},200)}else e.someProp(`handleKeyDown`,t=>t(e,n))||Jc(e,n)?n.preventDefault():hl(e,`key`)},X.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)},X.keypress=(e,t)=>{let n=t;if(Pl(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||q&&n.metaKey)return;if(e.someProp(`handleKeyPress`,t=>t(e,n))){n.preventDefault();return}let r=e.state.selection;if(!(r instanceof u.c)||!r.$from.sameParent(r.$to)){let t=String.fromCharCode(n.charCode),i=()=>e.state.tr.insertText(t).scrollIntoView();!/[\r\n]/.test(t)&&!e.someProp(`handleTextInput`,n=>n(e,r.$from.pos,r.$to.pos,t,i))&&e.dispatch(i()),n.preventDefault()}};function xl(e){return{left:e.clientX,top:e.clientY}}function Sl(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}function Cl(e,t,n,r,i){if(r==-1)return!1;let a=e.state.doc.resolve(r);for(let r=a.depth+1;r>0;r--)if(e.someProp(t,t=>r>a.depth?t(e,n,a.nodeAfter,a.before(r),i,!0):t(e,n,a.node(r),a.before(r),i,!1)))return!0;return!1}function wl(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);n==`pointer`&&r.setMeta(`pointer`,!0),e.dispatch(r)}function Tl(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return r&&r.isAtom&&u.r.isSelectable(r)?(wl(e,new u.r(n),`pointer`),!0):!1}function El(e,t){if(t==-1)return!1;let n=e.state.selection,r,i;n instanceof u.r&&(r=n.node);let a=e.state.doc.resolve(t);for(let e=a.depth+1;e>0;e--){let t=e>a.depth?a.nodeAfter:a.node(e);if(u.r.isSelectable(t)){i=r&&n.$from.depth>0&&e>=n.$from.depth&&a.before(n.$from.depth+1)==n.$from.pos?a.before(n.$from.depth):a.before(e);break}}return i==null?!1:(wl(e,u.r.create(e.state.doc,i),`pointer`),!0)}function Dl(e,t,n,r,i){return Cl(e,`handleClickOn`,t,n,r)||e.someProp(`handleClick`,n=>n(e,t,r))||(i?El(e,n):Tl(e,n))}function Ol(e,t,n,r){return Cl(e,`handleDoubleClickOn`,t,n,r)||e.someProp(`handleDoubleClick`,n=>n(e,t,r))}function kl(e,t,n,r){return Cl(e,`handleTripleClickOn`,t,n,r)||e.someProp(`handleTripleClick`,n=>n(e,t,r))||Al(e,n,r)}function Al(e,t,n){if(n.button!=0)return!1;let r=e.state.doc;if(t==-1)return r.inlineContent?(wl(e,u.c.create(r,0,r.content.size),`pointer`),!0):!1;let i=r.resolve(t);for(let t=i.depth+1;t>0;t--){let n=t>i.depth?i.nodeAfter:i.node(t),a=i.before(t);if(n.inlineContent)wl(e,u.c.create(r,a+1,a+1+n.content.size),`pointer`);else if(u.r.isSelectable(n))wl(e,u.r.create(r,a),`pointer`);else continue;return!0}}function jl(e){return Vl(e)}var Ml=q?`metaKey`:`ctrlKey`;Y.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=jl(e),i=Date.now(),a=`singleClick`;i-e.input.lastClick.time<500&&Sl(n,e.input.lastClick)&&!n[Ml]&&e.input.lastClick.button==n.button&&(e.input.lastClick.type==`singleClick`?a=`doubleClick`:e.input.lastClick.type==`doubleClick`&&(a=`tripleClick`)),e.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:a,button:n.button};let o=e.posAtCoords(xl(n));o&&(a==`singleClick`?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new Nl(e,o,n,!!r)):(a==`doubleClick`?Ol:kl)(e,o.pos,o.inside,n)?n.preventDefault():hl(e,`pointer`))};var Nl=class{constructor(e,t,n,r){this.view=e,this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[Ml],this.allowDefault=n.shiftKey;let i,a;if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),a=t.inside;else{let n=e.state.doc.resolve(t.pos);i=n.parent,a=n.depth?n.before():0}let o=r?null:n.target,s=o?e.docView.nearestDesc(o,!0):null;this.target=s&&s.nodeDOM.nodeType==1?s.nodeDOM:null;let{selection:c}=e.state;n.button==0&&(i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof u.r&&c.from<=a&&c.to>a)&&(this.mightDrag={node:i,pos:a,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&W&&!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)),hl(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(()=>_c(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(xl(e))),this.updateAllowDefault(e),this.allowDefault||!t?hl(this.view,`pointer`):Dl(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||K&&this.mightDrag&&!this.mightDrag.node.isAtom||G&&!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)?(wl(this.view,u.o.near(this.view.state.doc.resolve(t.pos)),`pointer`),e.preventDefault()):hl(this.view,`pointer`)}move(e){this.updateAllowDefault(e),hl(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)}};Y.touchstart=e=>{e.input.lastTouch=Date.now(),jl(e),hl(e,`pointer`)},Y.touchmove=e=>{e.input.lastTouch=Date.now(),hl(e,`pointer`)},Y.contextmenu=e=>jl(e);function Pl(e,t){return e.composing?!0:K&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}var Fl=os?5e3:-1;X.compositionstart=X.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof u.c&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>e.type.spec.inclusive===!1)||G&&as&&Il(e)))e.markCursor=e.state.storedMarks||n.marks(),Vl(e,!0),e.markCursor=null;else if(Vl(e,!t.selection.empty),W&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,r=t.focusOffset;n&&n.nodeType==1&&r!=0;){let t=r<0?n.lastChild:n.childNodes[r-1];if(!t)break;if(t.nodeType==3){let n=e.domSelection();n&&n.collapse(t,t.nodeValue.length);break}else n=t,r=-1}}e.input.composing=!0}Ll(e,Fl)};function Il(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||t.nodeType!=1||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return r.nodeType==1&&r.contentEditable==`false`}X.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,Ll(e,20))};function Ll(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>Vl(e),t))}function Rl(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Bl());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function zl(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=Vo(t.focusNode,t.focusOffset),r=Ho(t.focusNode,t.focusOffset);if(n&&r&&n!=r){let t=r.pmViewDesc,i=e.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!t||!t.isText(r.nodeValue))return r;if(e.input.compositionNode==r){let e=n.pmViewDesc;if(!(!e||!e.isText(n.nodeValue)))return r}}return n||r}function Bl(){let e=document.createEvent(`Event`);return e.initEvent(`event`,!0,!0),e.timeStamp}function Vl(e,t=!1){if(!(os&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),Rl(e),t||e.docView&&e.docView.dirty){let n=hc(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):(e.markCursor||t)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.dispatch(e.state.tr.deleteSelection()):e.updateState(e.state),!0}return!1}}function Hl(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement(`div`));n.appendChild(t),n.style.cssText=`position: fixed; left: -10000px; top: 10px`;let r=getSelection(),i=document.createRange();i.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}var Ul=U&&ts<15||is&&cs<604;Y.copy=X.cut=(e,t)=>{let n=t,r=e.state.selection,i=n.type==`cut`;if(r.empty)return;let a=Ul?null:n.clipboardData,{dom:o,text:s}=Yc(e,r.content());a?(n.preventDefault(),a.clearData(),a.setData(`text/html`,o.innerHTML),a.setData(`text/plain`,s)):Hl(e,o),i&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta(`uiEvent`,`cut`))};function Wl(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function Gl(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?`textarea`:`div`));n||(r.contentEditable=`true`),r.style.cssText=`position: fixed; left: -10000px; top: 10px`,r.focus();let i=e.input.shiftKey&&e.input.lastKeyCode!=45;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Kl(e,r.value,null,i,t):Kl(e,r.textContent,r.innerHTML,i,t)},50)}function Kl(e,t,n,r,i){let a=Xc(e,t,n,r,e.state.selection.$from);if(e.someProp(`handlePaste`,t=>t(e,i,a||u.A.empty)))return!0;if(!a)return!1;let o=Wl(a),s=o?e.state.tr.replaceSelectionWith(o,r):e.state.tr.replaceSelection(a);return e.dispatch(s.scrollIntoView().setMeta(`paste`,!0).setMeta(`uiEvent`,`paste`)),!0}function ql(e){let t=e.getData(`text/plain`)||e.getData(`Text`);if(t)return t;let n=e.getData(`text/uri-list`);return n?n.replace(/\r?\n/g,` `):``}X.paste=(e,t)=>{let n=t;if(e.composing&&!os)return;let r=Ul?null:n.clipboardData,i=e.input.shiftKey&&e.input.lastKeyCode!=45;r&&Kl(e,ql(r),r.getData(`text/html`),i,n)?n.preventDefault():Gl(e,n)};var Jl=class{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}},Yl=q?`altKey`:`ctrlKey`;function Xl(e,t){let n;return e.someProp(`dragCopies`,e=>{n||=e(t)}),n==null?!t[Yl]:!n}Y.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=e.state.selection,a=i.empty?null:e.posAtCoords(xl(n)),o;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof u.r?i.to-1:i.to))){if(r&&r.mightDrag)o=u.r.create(e.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&(o=u.r.create(e.state.doc,t.posBefore))}}let{dom:s,text:c,slice:l}=Yc(e,(o||e.state.selection).content());(!n.dataTransfer.files.length||!G||rs>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Ul?`Text`:`text/html`,s.innerHTML),n.dataTransfer.effectAllowed=`copyMove`,Ul||n.dataTransfer.setData(`text/plain`,c),e.dragging=new Jl(l,Xl(e,n),o)},Y.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},X.dragover=X.dragenter=(e,t)=>t.preventDefault(),X.drop=(e,t)=>{try{Zl(e,t,e.dragging)}finally{e.dragging=null}};function Zl(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(xl(t));if(!r)return;let i=e.state.doc.resolve(r.pos),a=n&&n.slice;a?e.someProp(`transformPasted`,t=>{a=t(a,e,!1)}):a=Xc(e,ql(t.dataTransfer),Ul?null:t.dataTransfer.getData(`text/html`),!1,i);let o=!!(n&&Xl(e,t));if(e.someProp(`handleDrop`,n=>n(e,t,a||u.A.empty,o))){t.preventDefault();return}if(!a)return;t.preventDefault();let s=a?u._(e.state.doc,i.pos,a):i.pos;s??=i.pos;let c=e.state.tr;if(o){let{node:e}=n;e?e.replace(c):c.deleteSelection()}let l=c.mapping.map(s),d=a.openStart==0&&a.openEnd==0&&a.content.childCount==1,f=c.doc;if(d?c.replaceRangeWith(l,l,a.content.firstChild):c.replaceRange(l,l,a),c.doc.eq(f))return;let p=c.doc.resolve(l);if(d&&u.r.isSelectable(a.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(a.content.firstChild))c.setSelection(new u.r(p));else{let t=c.mapping.map(s);c.mapping.maps[c.mapping.maps.length-1].forEach((e,n,r,i)=>t=i),c.setSelection(Ec(e,p,c.doc.resolve(t)))}e.focus(),e.dispatch(c.setMeta(`uiEvent`,`drop`))}Y.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add(`ProseMirror-focused`),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&_c(e)},20))},Y.blur=(e,t)=>{let n=t;e.focused&&=(e.domObserver.stop(),e.dom.classList.remove(`ProseMirror-focused`),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),!1)},Y.beforeinput=(e,t)=>{if(G&&os&&t.inputType==`deleteContentBackward`){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=t||(e.dom.blur(),e.focus(),e.someProp(`handleKeyDown`,t=>t(e,Ko(8,`Backspace`)))))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())},50)}};for(let e in X)Y[e]=X[e];function Ql(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}var $l=class e{constructor(e,t){this.toDOM=e,this.spec=t||iu,this.side=this.spec.side||0}map(e,t,n,r){let{pos:i,deleted:a}=e.mapResult(t.from+r,this.side<0?-1:1);return a?null:new nu(i-n,i-n,this)}valid(){return!0}eq(t){return this==t||t instanceof e&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&Ql(this.spec,t.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},eu=class e{constructor(e,t){this.attrs=e,this.spec=t||iu}map(e,t,n,r){let i=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,a=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return i>=a?null:new nu(i,a,this)}valid(e,t){return t.from<t.to}eq(t){return this==t||t instanceof e&&Ql(this.attrs,t.attrs)&&Ql(this.spec,t.spec)}static is(t){return t.type instanceof e}destroy(){}},tu=class e{constructor(e,t){this.attrs=e,this.spec=t||iu}map(e,t,n,r){let i=e.mapResult(t.from+r,1);if(i.deleted)return null;let a=e.mapResult(t.to+r,-1);return a.deleted||a.pos<=i.pos?null:new nu(i.pos-n,a.pos-n,this)}valid(e,t){let{index:n,offset:r}=e.content.findIndex(t.from),i;return r==t.from&&!(i=e.child(n)).isText&&r+i.nodeSize==t.to}eq(t){return this==t||t instanceof e&&Ql(this.attrs,t.attrs)&&Ql(this.spec,t.spec)}destroy(){}},nu=class e{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(t,n){return new e(t,n,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,n){return this.type.map(e,this,t,n)}static widget(t,n,r){return new e(t,t,new $l(n,r))}static inline(t,n,r,i){return new e(t,n,new eu(r,i))}static node(t,n,r,i){return new e(t,n,new tu(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof eu}get widget(){return this.type instanceof $l}},ru=[],iu={},au=class e{constructor(e,t){this.local=e.length?e:ru,this.children=t.length?t:ru}static create(e,t){return t.length?fu(t,e,0,iu):Z}find(e,t,n){let r=[];return this.findInner(e??0,t??1e9,r,0,n),r}findInner(e,t,n,r,i){for(let a=0;a<this.local.length;a++){let o=this.local[a];o.from<=t&&o.to>=e&&(!i||i(o.spec))&&n.push(o.copy(o.from+r,o.to+r))}for(let a=0;a<this.children.length;a+=3)if(this.children[a]<t&&this.children[a+1]>e){let o=this.children[a]+1;this.children[a+2].findInner(e-o,t-o,n,r+o,i)}}map(e,t,n){return this==Z||e.maps.length==0?this:this.mapInner(e,t,0,0,n||iu)}mapInner(t,n,r,i,a){let o;for(let e=0;e<this.local.length;e++){let s=this.local[e].map(t,r,i);s&&s.type.valid(n,s)?(o||=[]).push(s):a.onRemove&&a.onRemove(this.local[e].spec)}return this.children.length?su(this.children,o||[],t,n,r,i,a):o?new e(o.sort(pu),ru):Z}add(t,n){return n.length?this==Z?e.create(t,n):this.addInner(t,n,0):this}addInner(t,n,r){let i,a=0;t.forEach((e,t)=>{let o=t+r,s;if(s=uu(n,e,o)){for(i||=this.children.slice();a<i.length&&i[a]<t;)a+=3;i[a]==t?i[a+2]=i[a+2].addInner(e,s,o+1):i.splice(a,0,t,t+e.nodeSize,fu(s,e,o+1,iu)),a+=3}});let o=cu(a?du(n):n,-r);for(let e=0;e<o.length;e++)o[e].type.valid(t,o[e])||o.splice(e--,1);return new e(o.length?this.local.concat(o).sort(pu):this.local,i||this.children)}remove(e){return e.length==0||this==Z?this:this.removeInner(e,0)}removeInner(t,n){let r=this.children,i=this.local;for(let e=0;e<r.length;e+=3){let i,a=r[e]+n,o=r[e+1]+n;for(let e=0,n;e<t.length;e++)(n=t[e])&&n.from>a&&n.to<o&&(t[e]=null,(i||=[]).push(n));if(!i)continue;r==this.children&&(r=this.children.slice());let s=r[e+2].removeInner(i,a+1);s==Z?(r.splice(e,3),e-=3):r[e+2]=s}if(i.length){for(let e=0,r;e<t.length;e++)if(r=t[e])for(let e=0;e<i.length;e++)i[e].eq(r,n)&&(i==this.local&&(i=this.local.slice()),i.splice(e--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new e(i,r):Z}forChild(t,n){if(this==Z)return this;if(n.isLeaf)return e.empty;let r,i;for(let e=0;e<this.children.length;e+=3)if(this.children[e]>=t){this.children[e]==t&&(r=this.children[e+2]);break}let a=t+1,o=a+n.content.size;for(let e=0;e<this.local.length;e++){let t=this.local[e];if(t.from<o&&t.to>a&&t.type instanceof eu){let e=Math.max(a,t.from)-a,n=Math.min(o,t.to)-a;e<n&&(i||=[]).push(t.copy(e,n))}}if(i){let t=new e(i.sort(pu),ru);return r?new ou([t,r]):t}return r||Z}eq(t){if(this==t)return!0;if(!(t instanceof e)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(let e=0;e<this.local.length;e++)if(!this.local[e].eq(t.local[e]))return!1;for(let e=0;e<this.children.length;e+=3)if(this.children[e]!=t.children[e]||this.children[e+1]!=t.children[e+1]||!this.children[e+2].eq(t.children[e+2]))return!1;return!0}locals(e){return mu(this.localsInner(e))}localsInner(e){if(this==Z)return ru;if(e.inlineContent||!this.local.some(eu.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof eu||t.push(this.local[e]);return t}forEachSet(e){e(this)}};au.empty=new au([],[]),au.removeOverlap=mu;var Z=au.empty,ou=class e{constructor(e){this.members=e}map(t,n){let r=this.members.map(e=>e.map(t,n,iu));return e.from(r)}forChild(t,n){if(n.isLeaf)return au.empty;let r=[];for(let i=0;i<this.members.length;i++){let a=this.members[i].forChild(t,n);a!=Z&&(a instanceof e?r=r.concat(a.members):r.push(a))}return e.from(r)}eq(t){if(!(t instanceof e)||t.members.length!=this.members.length)return!1;for(let e=0;e<this.members.length;e++)if(!this.members[e].eq(t.members[e]))return!1;return!0}locals(e){let t,n=!0;for(let r=0;r<this.members.length;r++){let i=this.members[r].localsInner(e);if(i.length)if(!t)t=i;else{n&&=(t=t.slice(),!1);for(let e=0;e<i.length;e++)t.push(i[e])}}return t?mu(n?t:t.sort(pu)):ru}static from(t){switch(t.length){case 0:return Z;case 1:return t[0];default:return new e(t.every(e=>e instanceof au)?t:t.reduce((e,t)=>e.concat(t instanceof au?t:t.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function su(e,t,n,r,i,a,o){let s=e.slice();for(let e=0,t=a;e<n.maps.length;e++){let r=0;n.maps[e].forEach((e,n,i,a)=>{let o=a-i-(n-e);for(let i=0;i<s.length;i+=3){let a=s[i+1];if(a<0||e>a+t-r)continue;let c=s[i]+t-r;n>=c?s[i+1]=e<=c?-2:-1:e>=t&&o&&(s[i]+=o,s[i+1]+=o)}r+=o}),t=n.maps[e].map(t,-1)}let c=!1;for(let t=0;t<s.length;t+=3)if(s[t+1]<0){if(s[t+1]==-2){c=!0,s[t+1]=-1;continue}let l=n.map(e[t]+a),u=l-i;if(u<0||u>=r.content.size){c=!0;continue}let d=n.map(e[t+1]+a,-1)-i,{index:f,offset:p}=r.content.findIndex(u),m=r.maybeChild(f);if(m&&p==u&&p+m.nodeSize==d){let r=s[t+2].mapInner(n,m,l+1,e[t]+a+1,o);r==Z?(s[t+1]=-2,c=!0):(s[t]=u,s[t+1]=d,s[t+2]=r)}else c=!0}if(c){let c=fu(lu(s,e,t,n,i,a,o),r,0,o);t=c.local;for(let e=0;e<s.length;e+=3)s[e+1]<0&&(s.splice(e,3),e-=3);for(let e=0,t=0;e<c.children.length;e+=3){let n=c.children[e];for(;t<s.length&&s[t]<n;)t+=3;s.splice(t,0,c.children[e],c.children[e+1],c.children[e+2])}}return new au(t.sort(pu),s)}function cu(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let i=e[r];n.push(new nu(i.from+t,i.to+t,i.type))}return n}function lu(e,t,n,r,i,a,o){function s(e,t){for(let a=0;a<e.local.length;a++){let s=e.local[a].map(r,i,t);s?n.push(s):o.onRemove&&o.onRemove(e.local[a].spec)}for(let n=0;n<e.children.length;n+=3)s(e.children[n+2],e.children[n]+t+1)}for(let n=0;n<e.length;n+=3)e[n+1]==-1&&s(e[n+2],t[n]+a+1);return n}function uu(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,i=null;for(let t=0,a;t<e.length;t++)(a=e[t])&&a.from>n&&a.to<r&&((i||=[]).push(a),e[t]=null);return i}function du(e){let t=[];for(let n=0;n<e.length;n++)e[n]!=null&&t.push(e[n]);return t}function fu(e,t,n,r){let i=[],a=!1;t.forEach((t,o)=>{let s=uu(e,t,o+n);if(s){a=!0;let e=fu(s,t,n+o+1,r);e!=Z&&i.push(o,o+t.nodeSize,e)}});let o=cu(a?du(e):e,-n).sort(pu);for(let e=0;e<o.length;e++)o[e].type.valid(t,o[e])||(r.onRemove&&r.onRemove(o[e].spec),o.splice(e--,1));return o.length||i.length?new au(o,i):Z}function pu(e,t){return e.from-t.from||e.to-t.to}function mu(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let i=n+1;i<t.length;i++){let a=t[i];if(a.from==r.from){a.to!=r.to&&(t==e&&(t=e.slice()),t[i]=a.copy(a.from,r.to),hu(t,i+1,a.copy(r.to,a.to)));continue}else{a.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,a.from),hu(t,i,r.copy(a.from,r.to)));break}}}return t}function hu(e,t,n){for(;t<e.length&&pu(n,e[t])>0;)t++;e.splice(t,0,n)}function gu(e){let t=[];return e.someProp(`decorations`,n=>{let r=n(e.state);r&&r!=Z&&t.push(r)}),e.cursorWrapper&&t.push(au.create(e.state.doc,[e.cursorWrapper.deco])),ou.from(t)}var _u={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},vu=U&&ts<=11,yu=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}},bu=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new yu,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);U&&ts<=11&&t.some(e=>e.type==`childList`&&e.removedNodes.length||e.type==`characterData`&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():K&&e.composing&&t.some(e=>e.type==`childList`&&e.target.nodeName==`TR`)?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),vu&&(this.onCharData=e=>{this.queue.push({target:e.target,type:`characterData`,oldValue:e.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,_u)),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(Dc(this.view)){if(this.suppressingSelectionUpdates)return _c(this.view);if(U&&ts<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Ro(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,n;for(let n=e.focusNode;n;n=Po(n))t.add(n);for(let r=e.anchorNode;r;r=Po(r))if(t.has(r)){n=r;break}let r=n&&this.view.docView.nearestDesc(n);if(r&&r.ignoreMutation({type:`selection`,target:n.nodeType==3?n.parentNode:n}))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 n=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&Dc(e)&&!this.ignoreSelectionChange(n),i=-1,a=-1,o=!1,s=[];if(e.editable)for(let e=0;e<t.length;e++){let n=this.registerMutation(t[e],s);n&&(i=i<0?n.from:Math.min(n.from,i),a=a<0?n.to:Math.max(n.to,a),n.typeOver&&(o=!0))}if(s.some(e=>e.nodeName==`BR`)&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let e of s)if(e.nodeName==`BR`&&e.parentNode){let t=e.nextSibling;for(;t&&t.nodeType==1;){if(t.contentEditable==`false`){e.parentNode.removeChild(e);break}t=t.firstChild}}}else if(W&&s.length){let t=s.filter(e=>e.nodeName==`BR`);if(t.length==2){let[e,n]=t;e.parentNode&&e.parentNode.parentNode==n.parentNode?n.remove():e.remove()}else{let{focusNode:n}=this.currentSelection;for(let r of t){let t=r.parentNode;t&&t.nodeName==`LI`&&(!n||Eu(e,n)!=t)&&r.remove()}}}let c=null;i<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Go(n)&&(c=hc(e))&&c.eq(u.o.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,_c(e),this.currentSelection.set(n),e.scrollToSelection()):(i>-1||r)&&(i>-1&&(e.docView.markDirty(i,a),Cu(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,Du(e,s)),this.handleDOMChange(i,a,o,s),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||_c(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if(e.type==`attributes`&&(n==this.view.docView||e.attributeName==`contenteditable`||e.attributeName==`style`&&!e.oldValue&&!e.target.getAttribute(`style`))||!n||n.ignoreMutation(e))return null;if(e.type==`childList`){for(let n=0;n<e.addedNodes.length;n++){let r=e.addedNodes[n];t.push(r),r.nodeType==3&&(this.lastChangedTextNode=r)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let r=e.previousSibling,i=e.nextSibling;if(U&&ts<=11&&e.addedNodes.length)for(let t=0;t<e.addedNodes.length;t++){let{previousSibling:n,nextSibling:a}=e.addedNodes[t];(!n||Array.prototype.indexOf.call(e.addedNodes,n)<0)&&(r=n),(!a||Array.prototype.indexOf.call(e.addedNodes,a)<0)&&(i=a)}let a=r&&r.parentNode==e.target?V(r)+1:0,o=n.localPosFromDOM(e.target,a,-1),s=i&&i.parentNode==e.target?V(i):e.target.childNodes.length;return{from:o,to:n.localPosFromDOM(e.target,s,1)}}else if(e.type==`attributes`)return{from:n.posAtStart-n.border,to:n.posAtEnd+n.border};else return this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}}},xu=new WeakMap,Su=!1;function Cu(e){if(!xu.has(e)&&(xu.set(e,null),[`normal`,`nowrap`,`pre-line`].indexOf(getComputedStyle(e.dom).whiteSpace)!==-1)){if(e.requiresGeckoHackNode=W,Su)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.`),Su=!0}}function wu(e,t){let n=t.startContainer,r=t.startOffset,i=t.endContainer,a=t.endOffset,o=e.domAtPos(e.state.selection.anchor);return Ro(o.node,o.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function Tu(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return wu(e,n)}let n;function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.dom.addEventListener(`beforeinput`,r,!0),document.execCommand(`indent`),e.dom.removeEventListener(`beforeinput`,r,!0),n?wu(e,n):null}function Eu(e,t){for(let n=t.parentNode;n&&n!=e.dom;n=n.parentNode){let t=e.docView.nearestDesc(n,!0);if(t&&t.node.isBlock)return n}return null}function Du(e,t){let{focusNode:n,focusOffset:r}=e.domSelectionRange();for(let i of t)if(i.parentNode?.nodeName==`TR`){let t=i.nextSibling;for(;t&&t.nodeName!=`TD`&&t.nodeName!=`TH`;)t=t.nextSibling;if(t){let a=t;for(;;){let e=a.firstChild;if(!e||e.nodeType!=1||e.contentEditable==`false`||/^(BR|IMG)$/.test(e.nodeName))break;a=e}a.insertBefore(i,a.firstChild),n==i&&e.domSelection().collapse(i,r)}else i.parentNode.removeChild(i)}}function Ou(e,t,n){let{node:r,fromOffset:i,toOffset:a,from:o,to:s}=e.docView.parseRange(t,n),c=e.domSelectionRange(),l,d=c.anchorNode;if(d&&e.dom.contains(d.nodeType==1?d:d.parentNode)&&(l=[{node:d,offset:c.anchorOffset}],Go(c)||l.push({node:c.focusNode,offset:c.focusOffset})),G&&e.input.lastKeyCode===8)for(let e=a;e>i;e--){let t=r.childNodes[e-1],n=t.pmViewDesc;if(t.nodeName==`BR`&&!n){a=e;break}if(!n||n.size)break}let f=e.state.doc,p=e.someProp(`domParser`)||u.S.fromSchema(e.state.schema),m=f.resolve(o),h=null,g=p.parse(r,{topNode:m.parent,topMatch:m.parent.contentMatchAt(m.index()),topOpen:!0,from:i,to:a,preserveWhitespace:m.parent.type.whitespace==`pre`?`full`:!0,findPositions:l,ruleFromNode:ku,context:m});if(l&&l[0].pos!=null){let e=l[0].pos,t=l[1]&&l[1].pos;t??=e,h={anchor:e+o,head:t+o}}return{doc:g,sel:h,from:o,to:s}}function ku(e){let t=e.pmViewDesc;if(t)return t.parseRule();if(e.nodeName==`BR`&&e.parentNode){if(K&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let e=document.createElement(`div`);return e.appendChild(document.createElement(`li`)),{skip:e}}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}var Au=/^(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 ju(e,t,n,r,i){let a=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=hc(e,t);if(n&&!e.state.selection.eq(n)){if(G&&os&&e.input.lastKeyCode===13&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp(`handleKeyDown`,t=>t(e,Ko(13,`Enter`))))return;let r=e.state.tr.setSelection(n);t==`pointer`?r.setMeta(`pointer`,!0):t==`key`&&r.scrollIntoView(),a&&r.setMeta(`composition`,a),e.dispatch(r)}return}let o=e.state.doc.resolve(t),s=o.sharedDepth(n);t=o.before(s+1),n=e.state.doc.resolve(n).after(s+1);let c=e.state.selection,l=Ou(e,t,n),d=e.state.doc,f=d.slice(l.from,l.to),p,m;e.input.lastKeyCode===8&&Date.now()-100<e.input.lastKeyCodeTime?(p=e.state.selection.to,m=`end`):(p=e.state.selection.from,m=`start`),e.input.lastKeyCode=null;let h=Iu(f.content,l.doc.content,l.from,p,m);if(h&&e.input.domChangeCount++,(is&&e.input.lastIOSEnter>Date.now()-225||os)&&i.some(e=>e.nodeType==1&&!Au.test(e.nodeName))&&(!h||h.endA>=h.endB)&&e.someProp(`handleKeyDown`,t=>t(e,Ko(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(!h)if(r&&c instanceof u.c&&!c.empty&&c.$head.sameParent(c.$anchor)&&!e.composing&&!(l.sel&&l.sel.anchor!=l.sel.head))h={start:c.from,endA:c.to,endB:c.to};else{if(l.sel){let t=Mu(e,e.state.doc,l.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);a&&n.setMeta(`composition`,a),e.dispatch(n)}}return}e.state.selection.from<e.state.selection.to&&h.start==h.endB&&e.state.selection instanceof u.c&&(h.start>e.state.selection.from&&h.start<=e.state.selection.from+2&&e.state.selection.from>=l.from?h.start=e.state.selection.from:h.endA<e.state.selection.to&&h.endA>=e.state.selection.to-2&&e.state.selection.to<=l.to&&(h.endB+=e.state.selection.to-h.endA,h.endA=e.state.selection.to)),U&&ts<=11&&h.endB==h.start+1&&h.endA==h.start&&h.start>l.from&&l.doc.textBetween(h.start-l.from-1,h.start-l.from+1)==` \xA0`&&(h.start--,h.endA--,h.endB--);let g=l.doc.resolveNoCache(h.start-l.from),_=l.doc.resolveNoCache(h.endB-l.from),v=d.resolve(h.start),y=g.sameParent(_)&&g.parent.inlineContent&&v.end()>=h.endA;if((is&&e.input.lastIOSEnter>Date.now()-225&&(!y||i.some(e=>e.nodeName==`DIV`||e.nodeName==`P`))||!y&&g.pos<l.doc.content.size&&(!g.sameParent(_)||!g.parent.inlineContent)&&g.pos<_.pos&&!/\S/.test(l.doc.textBetween(g.pos,_.pos,``,``)))&&e.someProp(`handleKeyDown`,t=>t(e,Ko(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>h.start&&Pu(d,h.start,h.endA,g,_)&&e.someProp(`handleKeyDown`,t=>t(e,Ko(8,`Backspace`)))){os&&G&&e.domObserver.suppressSelectionUpdates();return}G&&h.endB==h.start&&(e.input.lastChromeDelete=Date.now()),os&&!y&&g.start()!=_.start()&&_.parentOffset==0&&g.depth==_.depth&&l.sel&&l.sel.anchor==l.sel.head&&l.sel.head==h.endA&&(h.endB-=2,_=l.doc.resolveNoCache(h.endB-l.from),setTimeout(()=>{e.someProp(`handleKeyDown`,function(t){return t(e,Ko(13,`Enter`))})},20));let b=h.start,x=h.endA,S=t=>{let n=t||e.state.tr.replace(b,x,l.doc.slice(h.start-l.from,h.endB-l.from));if(l.sel){let t=Mu(e,n.doc,l.sel);t&&!(G&&e.composing&&t.empty&&(h.start!=h.endB||e.input.lastChromeDelete<Date.now()-100)&&(t.head==b||t.head==n.mapping.map(x)-1)||U&&t.empty&&t.head==b)&&n.setSelection(t)}return a&&n.setMeta(`composition`,a),n.scrollIntoView()},C;if(y)if(g.pos==_.pos){U&&ts<=11&&g.parentOffset==0&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>_c(e),20));let t=S(e.state.tr.delete(b,x)),n=d.resolve(h.start).marksAcross(d.resolve(h.endA));n&&t.ensureMarks(n),e.dispatch(t)}else if(h.endA==h.endB&&(C=Nu(g.parent.content.cut(g.parentOffset,_.parentOffset),v.parent.content.cut(v.parentOffset,h.endA-v.start())))){let t=S(e.state.tr);C.type==`add`?t.addMark(b,x,C.mark):t.removeMark(b,x,C.mark),e.dispatch(t)}else if(g.parent.child(g.index()).isText&&g.index()==_.index()-+!_.textOffset){let t=g.parent.textBetween(g.parentOffset,_.parentOffset),n=()=>S(e.state.tr.insertText(t,b,x));e.someProp(`handleTextInput`,r=>r(e,b,x,t,n))||e.dispatch(n())}else e.dispatch(S());else e.dispatch(S())}function Mu(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:Ec(e,t.resolve(n.anchor),t.resolve(n.head))}function Nu(e,t){let n=e.firstChild.marks,r=t.firstChild.marks,i=n,a=r,o,s,c;for(let e=0;e<r.length;e++)i=r[e].removeFromSet(i);for(let e=0;e<n.length;e++)a=n[e].removeFromSet(a);if(i.length==1&&a.length==0)s=i[0],o=`add`,c=e=>e.mark(s.addToSet(e.marks));else if(i.length==0&&a.length==1)s=a[0],o=`remove`,c=e=>e.mark(s.removeFromSet(e.marks));else return null;let l=[];for(let e=0;e<t.childCount;e++)l.push(c(t.child(e)));if(u.w.from(l).eq(e))return{mark:s,type:o}}function Pu(e,t,n,r,i){if(n-t<=i.pos-r.pos||Fu(r,!0,!1)<i.pos)return!1;let a=e.resolve(t);if(!r.parent.isTextblock){let e=a.nodeAfter;return e!=null&&n==t+e.nodeSize}if(a.parentOffset<a.parent.content.size||!a.parent.isTextblock)return!1;let o=e.resolve(Fu(a,!0,!0));return!o.parent.isTextblock||o.pos>n||Fu(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function Fu(e,t,n){let r=e.depth,i=t?e.end():e.pos;for(;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,i++,t=!1;if(n){let t=e.node(r).maybeChild(e.indexAfter(r));for(;t&&!t.isLeaf;)t=t.firstChild,i++}return i}function Iu(e,t,n,r,i){let a=e.findDiffStart(t,n);if(a==null)return null;let{a:o,b:s}=e.findDiffEnd(t,n+e.size,n+t.size);if(i==`end`){let e=Math.max(0,a-Math.min(o,s));r-=o+e-a}if(o<a&&e.size<t.size){let e=r<=a&&r>=o?a-r:0;a-=e,a&&a<t.size&&Lu(t.textBetween(a-1,a+1))&&(a+=e?1:-1),s=a+(s-o),o=a}else if(s<a){let t=r<=a&&r>=s?a-r:0;a-=t,a&&a<e.size&&Lu(e.textBetween(a-1,a+1))&&(a+=t?1:-1),o=a+(o-s),s=a}return{start:a,endA:o,endB:s}}function Lu(e){if(e.length!=2)return!1;let t=e.charCodeAt(0),n=e.charCodeAt(1);return t>=56320&&t<=57343&&n>=55296&&n<=56319}var Ru=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 pl,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Gu),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=Vu(this),Bu(this),this.nodeViews=Uu(this),this.docView=Ys(this.state.doc,zu(this),gu(this),this.dom,this),this.domObserver=new bu(this,(e,t,n,r)=>ju(this,e,t,n,r)),this.domObserver.start(),ml(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&&_l(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Gu),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){let n=this.state,r=!1,i=!1;e.storedMarks&&this.composing&&(Rl(this),i=!0),this.state=e;let a=n.plugins!=e.plugins||this._props.plugins!=t.plugins;if(a||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=Uu(this);Wu(e,this.nodeViews)&&(this.nodeViews=e,r=!0)}(a||t.handleDOMEvents!=this._props.handleDOMEvents)&&_l(this),this.editable=Vu(this),Bu(this);let o=gu(this),s=zu(this),c=n.plugins!=e.plugins&&!n.doc.eq(e.doc)?`reset`:e.scrollToSelection>n.scrollToSelection?`to selection`:`preserve`,l=r||!this.docView.matchesNode(e.doc,s,o);(l||!e.selection.eq(n.selection))&&(i=!0);let u=c==`preserve`&&i&&this.dom.style.overflowAnchor==null&&ps(this);if(i){this.domObserver.stop();let t=l&&(U||G)&&!this.composing&&!n.selection.empty&&!e.selection.empty&&Hu(n.selection,e.selection);if(l){let n=G?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=zl(this)),(r||!this.docView.update(e.doc,s,o,this))&&(this.docView.updateOuterDeco(s),this.docView.destroy(),this.docView=Ys(e.doc,s,o,this.dom,this)),n&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(t=!0)}t||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&kc(this))?_c(this,t):(wc(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(n),this.dragging?.node&&!n.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,n),c==`reset`?this.dom.scrollTop=0:c==`to selection`?this.scrollToSelection():u&&hs(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))&&!this.someProp(`handleScrollToSelection`,e=>e(this)))if(this.state.selection instanceof u.r){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&fs(this,t.getBoundingClientRect(),e)}else fs(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 e=0;e<this.directPlugins.length;e++){let t=this.directPlugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let t=this.state.plugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}}updateDraggedNode(e,t){let n=e.node,r=-1;if(n.from<this.state.doc.content.size&&this.state.doc.nodeAt(n.from)==n.node)r=n.from;else{let e=n.from+(this.state.doc.content.size-t.doc.content.size);(e>0&&e<this.state.doc.content.size&&this.state.doc.nodeAt(e))==n.node&&(r=e)}this.dragging=new Jl(e.slice,e.move,r<0?void 0:u.r.create(this.state.doc,r))}someProp(e,t){let n=this._props&&this._props[e],r;if(n!=null&&(r=t?t(n):n))return r;for(let n=0;n<this.directPlugins.length;n++){let i=this.directPlugins[n].props[e];if(i!=null&&(r=t?t(i):i))return r}let i=this.state.plugins;if(i)for(let n=0;n<i.length;n++){let a=i[n].props[e];if(a!=null&&(r=t?t(a):a))return r}}hasFocus(){if(U){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&&vs(this.dom),_c(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let e=this.dom.parentNode;e;e=e.parentNode)if(e.nodeType==9||e.nodeType==11&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=()=>e.ownerDocument.getSelection()),this._root=e}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Es(this,e)}coordsAtPos(e,t=1){return As(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,n=-1){let r=this.docView.posFromDOM(e,t,n);if(r==null)throw RangeError(`DOM position not inside the editor`);return r}endOfTextblock(e,t){return Bs(this,t||this.state,e)}pasteHTML(e,t){return Kl(this,``,e,!1,t||new ClipboardEvent(`paste`))}pasteText(e,t){return Kl(this,e,null,!0,t||new ClipboardEvent(`paste`))}serializeForClipboard(e){return Yc(this,e)}destroy(){this.docView&&(gl(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],gu(this),this),this.dom.textContent=``):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Lo())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return bl(this,e)}domSelectionRange(){let e=this.domSelection();return e?K&&this.root.nodeType===11&&qo(this.dom.ownerDocument)==this.dom&&Tu(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};Ru.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};function zu(e){let t=Object.create(null);return t.class=`ProseMirror`,t.contenteditable=String(e.editable),e.someProp(`attributes`,n=>{if(typeof n==`function`&&(n=n(e.state)),n)for(let e in n)e==`class`?t.class+=` `+n[e]:e==`style`?t.style=(t.style?t.style+`;`:``)+n[e]:!t[e]&&e!=`contenteditable`&&e!=`nodeName`&&(t[e]=String(n[e]))}),t.translate||=`no`,[nu.node(0,e.state.doc.content.size,t)]}function Bu(e){if(e.markCursor){let t=document.createElement(`img`);t.className=`ProseMirror-separator`,t.setAttribute(`mark-placeholder`,`true`),t.setAttribute(`alt`,``),e.cursorWrapper={dom:t,deco:nu.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function Vu(e){return!e.someProp(`editable`,t=>t(e.state)===!1)}function Hu(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}function Uu(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp(`nodeViews`,n),e.someProp(`markViews`,n),t}function Wu(e,t){let n=0,r=0;for(let r in e){if(e[r]!=t[r])return!0;n++}for(let e in t)r++;return n!=r}function Gu(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw RangeError(`Plugins passed directly to the view must not have a state component`)}var Ku=s({CommandManager:()=>gd,CommandsReady:()=>bd,ConfigReady:()=>od,Editor:()=>of,EditorStateReady:()=>Vd,EditorStatus:()=>$,EditorViewReady:()=>Yd,InitReady:()=>cd,KeymapManager:()=>Cd,KeymapReady:()=>Ed,ParserReady:()=>Od,PasteRulesReady:()=>qd,SchemaReady:()=>Q,SerializerReady:()=>Nd,commands:()=>xd,commandsCtx:()=>vd,commandsTimerCtx:()=>yd,config:()=>sd,createCmdKey:()=>_d,defaultValueCtx:()=>Rd,editorCtx:()=>Qu,editorState:()=>Wd,editorStateCtx:()=>Xu,editorStateOptionsCtx:()=>zd,editorStateTimerCtx:()=>Bd,editorView:()=>af,editorViewCtx:()=>Yu,editorViewOptionsCtx:()=>Zd,editorViewTimerCtx:()=>Xd,getDoc:()=>Hd,init:()=>ld,initTimerCtx:()=>Zu,inputRulesCtx:()=>$u,keymap:()=>Dd,keymapCtx:()=>wd,keymapTimerCtx:()=>Td,markViewCtx:()=>rd,marksCtx:()=>pd,nodeViewCtx:()=>nd,nodesCtx:()=>fd,parser:()=>Md,parserCtx:()=>Ad,parserTimerCtx:()=>jd,pasteRule:()=>Jd,pasteRulesCtx:()=>Gd,pasteRulesTimerCtx:()=>Kd,prosePluginsCtx:()=>ed,remarkCtx:()=>id,remarkPluginsCtx:()=>td,remarkStringifyOptionsCtx:()=>ad,rootAttrsCtx:()=>ef,rootCtx:()=>Qd,rootDOMCtx:()=>$d,schema:()=>hd,schemaCtx:()=>dd,schemaTimerCtx:()=>ud,serializer:()=>Ld,serializerCtx:()=>Id,serializerTimerCtx:()=>Pd});function qu(e,t){return e.meta={package:`@milkdown/core`,group:`System`,...t},e}var Ju={text:(e,t,n,r)=>{let i=e.value;return/^[^*_\\]*\s+$/.test(i)?i:n.safe(i,{...r,encode:[]})},strong:(e,t,n,r)=>{let i=e.marker||n.options.strong||`*`,a=n.enter(`strong`),o=n.createTracker(r),s=o.move(i+i);return s+=o.move(n.containerPhrasing(e,{before:s,after:i,...o.current()})),s+=o.move(i+i),a(),s},emphasis:(e,t,n,r)=>{let i=e.marker||n.options.emphasis||`*`,a=n.enter(`emphasis`),o=n.createTracker(r),s=o.move(i);return s+=o.move(n.containerPhrasing(e,{before:s,after:i,...o.current()})),s+=o.move(i),a(),s}},Yu=D({},`editorView`),Xu=D({},`editorState`),Zu=D([],`initTimer`),Qu=D({},`editor`),$u=D([],`inputRules`),ed=D([],`prosePlugins`),td=D([],`remarkPlugins`),nd=D([],`nodeView`),rd=D([],`markView`),id=D(ga().use(ar).use(Hi),`remark`),ad=D({handlers:Ju,encode:[]},`remarkStringifyOptions`),od=k(`ConfigReady`);function sd(e){let t=t=>(t.record(od),async()=>(await e(t),t.done(od),()=>{t.clearTimer(od)}));return qu(t,{displayName:`Config`}),t}var cd=k(`InitReady`);function ld(e){let t=t=>(t.inject(Qu,e).inject(ed,[]).inject(td,[]).inject($u,[]).inject(nd,[]).inject(rd,[]).inject(ad,{handlers:Ju,encode:[]}).inject(id,ga().use(ar).use(Hi)).inject(Zu,[od]).record(cd),async()=>{await t.waitTimers(Zu);let e=t.get(ad);return t.set(id,ga().use(ar).use(Hi,e)),t.done(cd),()=>{t.remove(Qu).remove(ed).remove(td).remove($u).remove(nd).remove(rd).remove(ad).remove(id).remove(Zu).clearTimer(cd)}});return qu(t,{displayName:`Init`}),t}var Q=k(`SchemaReady`),ud=D([],`schemaTimer`),dd=D({},`schema`),fd=D([],`nodes`),pd=D([],`marks`);function md(e){return{...e,parseDOM:e.parseDOM?.map(t=>({priority:e.priority,...t}))}}var hd=e=>(e.inject(dd,{}).inject(fd,[]).inject(pd,[]).inject(ud,[cd]).record(Q),async()=>{await e.waitTimers(ud);let t=e.get(id),n=e.get(td).reduce((e,t)=>e.use(t.plugin,t.options),t);e.set(id,n);let r=new u.k({nodes:Object.fromEntries(e.get(fd).map(([e,t])=>[e,md(t)])),marks:Object.fromEntries(e.get(pd).map(([e,t])=>[e,md(t)]))});return e.set(dd,r),e.done(Q),()=>{e.remove(dd).remove(fd).remove(pd).remove(ud).clearTimer(Q)}});qu(hd,{displayName:`Schema`});var gd=class{constructor(){this.#e=new ne,this.#t=null,this.setCtx=e=>{this.#t=e},this.chain=()=>{if(this.#t==null)throw T();let e=this.#t,t=[],n=this.get.bind(this),r={run:()=>{let n=d.r(...t),r=e.get(Yu);return n(r.state,r.dispatch,r)},inline:e=>(t.push(e),r),pipe:i.bind(this)};function i(e,i){let a=n(e);return t.push(a(i)),r}return r}}#e;#t;get ctx(){return this.#t}create(e,t){let n=e.create(this.#e.sliceMap);return n.set(t),n}get(e){return this.#e.get(e).get()}remove(e){return this.#e.remove(e)}call(e,t){if(this.#t==null)throw T();let n=this.get(e)(t),r=this.#t.get(Yu);return n(r.state,r.dispatch,r)}inline(e){if(this.#t==null)throw T();let t=this.#t.get(Yu);return e(t.state,t.dispatch,t)}};function _d(e=`cmdKey`){return D((()=>()=>!1),e)}var vd=D(new gd,`commands`),yd=D([Q],`commandsTimer`),bd=k(`CommandsReady`),xd=e=>{let t=new gd;return t.setCtx(e),e.inject(vd,t).inject(yd,[Q]).record(bd),async()=>(await e.waitTimers(yd),e.done(bd),()=>{e.remove(vd).remove(yd).clearTimer(bd)})};qu(xd,{displayName:`Commands`});function Sd(e){return e.Backspace=d.r(Oa,d.a,d.u,d.y),e}var Cd=class{constructor(){this.#e=null,this.#t=[],this.setCtx=e=>{this.#e=e},this.add=e=>(this.#t.push(e),()=>{this.#t=this.#t.filter(t=>t!==e)}),this.addObjectKeymap=e=>{let t=[];return Object.entries(e).forEach(([e,n])=>{if(typeof n==`function`){let r={key:e,onRun:()=>n};this.#t.push(r),t.push(()=>{this.#t=this.#t.filter(e=>e!==r)})}else this.#t.push(n),t.push(()=>{this.#t=this.#t.filter(e=>e!==n)})}),()=>{t.forEach(e=>e())}},this.addBaseKeymap=()=>{let e=Sd(d.n);return this.addObjectKeymap(e)},this.build=()=>{let e={};return this.#t.forEach(t=>{e[t.key]=[...e[t.key]||[],t]}),Object.fromEntries(Object.entries(e).map(([e,t])=>{let n=t.sort((e,t)=>(t.priority??50)-(e.priority??50));return[e,(e,t,r)=>{let i=this.#e;if(i==null)throw y();return d.r(...n.map(e=>e.onRun(i)))(e,t,r)}]}))}}#e;#t;get ctx(){return this.#e}},wd=D(new Cd,`keymap`),Td=D([Q],`keymapTimer`),Ed=k(`KeymapReady`),Dd=e=>{let t=new Cd;return t.setCtx(e),e.inject(wd,t).inject(Td,[Q]).record(Ed),async()=>(await e.waitTimers(Td),e.done(Ed),()=>{e.remove(wd).remove(Td).clearTimer(Ed)})},Od=k(`ParserReady`),kd=(()=>{throw y()}),Ad=D(kd,`parser`),jd=D([],`parserTimer`),Md=e=>(e.inject(Ad,kd).inject(jd,[Q]).record(Od),async()=>{await e.waitTimers(jd);let t=e.get(id),n=e.get(dd);return e.set(Ad,Ao.create(n,t)),e.done(Od),()=>{e.remove(Ad).remove(jd).clearTimer(Od)}});qu(Md,{displayName:`Parser`});var Nd=k(`SerializerReady`),Pd=D([],`serializerTimer`),Fd=(()=>{throw y()}),Id=D(Fd,`serializer`),Ld=e=>(e.inject(Id,Fd).inject(Pd,[Q]).record(Nd),async()=>{await e.waitTimers(Pd);let t=e.get(id),n=e.get(dd);return e.set(Id,No.create(n,t)),e.done(Nd),()=>{e.remove(Id).remove(Pd).clearTimer(Nd)}});qu(Ld,{displayName:`Serializer`});var Rd=D(``,`defaultValue`),zd=D(e=>e,`stateOptions`),Bd=D([],`editorStateTimer`),Vd=k(`EditorStateReady`);function Hd(e,t,n){if(typeof e==`string`)return t(e);if(e.type===`html`)return u.S.fromSchema(n).parse(e.dom);if(e.type===`json`)return u.E.fromJSON(n,e.value);throw g(e)}var Ud=new u.a(`MILKDOWN_STATE_TRACKER`),Wd=e=>(e.inject(Rd,``).inject(Xu,{}).inject(zd,e=>e).inject(Bd,[Od,Nd,bd,Ed]).record(Vd),async()=>{await e.waitTimers(Bd);let t=e.get(dd),n=e.get(Ad),r=e.get($u),i=e.get(zd),a=e.get(ed),o=Hd(e.get(Rd),n,t),s=e.get(wd),c=s.addBaseKeymap(),l=[...a,new u.i({key:Ud,state:{init:()=>{},apply:(t,n,r,i)=>{e.set(Xu,i)}}}),Ua({rules:r}),To(s.build())];e.set(ed,l);let d=i({schema:t,doc:o,plugins:l}),f=u.n.create(d);return e.set(Xu,f),e.done(Vd),()=>{c(),e.remove(Rd).remove(Xu).remove(zd).remove(Bd).clearTimer(Vd)}});qu(Wd,{displayName:`EditorState`});var Gd=D([],`pasteRule`),Kd=D([Q],`pasteRuleTimer`),qd=k(`PasteRuleReady`),Jd=e=>(e.inject(Gd,[]).inject(Kd,[Q]).record(qd),async()=>(await e.waitTimers(Kd),e.done(qd),()=>{e.remove(Gd).remove(Kd).clearTimer(qd)}));qu(Jd,{displayName:`PasteRule`});var Yd=k(`EditorViewReady`),Xd=D([],`editorViewTimer`),Zd=D({},`editorViewOptions`),Qd=D(null,`root`),$d=D(null,`rootDOM`),ef=D({},`rootAttrs`);function tf(e,t){let n=document.createElement(`div`);n.className=`milkdown`,e.appendChild(n),t.set($d,n);let r=t.get(ef);return Object.entries(r).forEach(([e,t])=>n.setAttribute(e,t)),n}function nf(e){e.classList.add(`editor`),e.setAttribute(`role`,`textbox`)}var rf=new u.a(`MILKDOWN_VIEW_CLEAR`),af=e=>(e.inject(Qd,document.body).inject(Yu,{}).inject(Zd,{}).inject($d,null).inject(ef,{}).inject(Xd,[Vd,qd]).record(Yd),async()=>{await e.wait(cd);let t=e.get(Qd)||document.body,n=typeof t==`string`?document.querySelector(t):t;e.update(ed,t=>[new u.i({key:rf,view:t=>{let r=n?tf(n,e):void 0;return(()=>{if(r&&n){let e=t.dom;n.replaceChild(r,e),r.appendChild(e)}})(),{destroy:()=>{r?.parentNode&&r?.parentNode.replaceChild(t.dom,r),r?.remove()}}}}),...t]),await e.waitTimers(Xd);let r=e.get(Xu),i=e.get(Zd),a=new Ru(n,{state:r,nodeViews:Object.fromEntries(e.get(nd)),markViews:Object.fromEntries(e.get(rd)),transformPasted:(t,n,r)=>(e.get(Gd).sort((e,t)=>(t.priority??50)-(e.priority??50)).map(e=>e.run).forEach(e=>{t=e(t,n,r)}),t),...i});return nf(a.dom),e.set(Yu,a),e.done(Yd),()=>{a?.destroy(),e.remove(Qd).remove(Yu).remove(Zd).remove($d).remove(ef).remove(Xd).clearTimer(Yd)}});qu(af,{displayName:`EditorView`});var $=function(e){return e.Idle=`Idle`,e.OnCreate=`OnCreate`,e.Created=`Created`,e.OnDestroy=`OnDestroy`,e.Destroyed=`Destroyed`,e}({}),of=class e{constructor(){this.#e=!1,this.#t=$.Idle,this.#n=[],this.#r=()=>void 0,this.#i=new ne,this.#a=new oe,this.#o=new Map,this.#s=new Map,this.#c=new ae(this.#i,this.#a),this.#l=()=>{let e=sd(async e=>{await Promise.all(this.#n.map(t=>Promise.resolve(t(e))))}),t=[hd,Md,Ld,xd,Dd,Jd,Wd,af,ld(this),e];this.#u(t,this.#s)},this.#u=(e,t)=>{e.forEach(e=>{let n=this.#c.produce(this.#e?e.meta:void 0),r=e(n);t.set(e,{ctx:n,handler:r,cleanup:void 0})})},this.#d=(e,t=!1)=>Promise.all([e].flat().map(async e=>{let n=this.#o.get(e)?.cleanup;return t?this.#o.delete(e):this.#o.set(e,{ctx:void 0,handler:void 0,cleanup:void 0}),typeof n==`function`?n():n})),this.#f=async()=>{await Promise.all([...this.#s.entries()].map(async([e,{cleanup:t}])=>typeof t==`function`?t():t)),this.#s.clear()},this.#p=e=>{this.#t=e,this.#r(e)},this.#m=e=>[...e.entries()].map(async([t,n])=>{let{ctx:r,handler:i}=n;if(!i)return;let a=await i();e.set(t,{ctx:r,handler:i,cleanup:a})}),this.enableInspector=(e=!0)=>(this.#e=e,this),this.onStatusChange=e=>(this.#r=e,this),this.config=e=>(this.#n.push(e),this),this.removeConfig=e=>(this.#n=this.#n.filter(t=>t!==e),this),this.use=e=>{let t=[e].flat();return t.flat().forEach(e=>{this.#o.set(e,{ctx:void 0,handler:void 0,cleanup:void 0})}),this.#t===$.Created&&this.#u(t,this.#o),this},this.remove=async e=>this.#t===$.OnCreate?(console.warn(`[Milkdown]: You are trying to remove plugins when the editor is creating, this is not recommended, please check your code.`),new Promise(t=>{setTimeout(()=>{t(this.remove(e))},50)})):(await this.#d([e].flat(),!0),this),this.create=async()=>this.#t===$.OnCreate?this:(this.#t===$.Created&&await this.destroy(),this.#p($.OnCreate),this.#l(),this.#u([...this.#o.keys()],this.#o),await Promise.all([this.#m(this.#s),this.#m(this.#o)].flat()),this.#p($.Created),this),this.destroy=async(e=!1)=>this.#t===$.Destroyed||this.#t===$.OnDestroy?this:this.#t===$.OnCreate?new Promise(t=>{setTimeout(()=>{t(this.destroy(e))},50)}):(e&&(this.#n=[]),this.#p($.OnDestroy),await this.#d([...this.#o.keys()],e),await this.#f(),this.#p($.Destroyed),this),this.action=e=>e(this.#c),this.inspect=()=>this.#e?[...this.#s.values(),...this.#o.values()].map(({ctx:e})=>e?.inspector?.read()).filter(e=>!!e):(console.warn("[Milkdown]: You are trying to collect inspection when inspector is disabled, please enable inspector by `editor.enableInspector()` first."),[])}static make(){return new e}#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m;get ctx(){return this.#c}get status(){return this.#t}};Object.defineProperty(exports,"$",{enumerable:!0,get:function(){return _r}}),Object.defineProperty(exports,"A",{enumerable:!0,get:function(){return Id}}),Object.defineProperty(exports,"B",{enumerable:!0,get:function(){return lo}}),Object.defineProperty(exports,"C",{enumerable:!0,get:function(){return Gd}}),Object.defineProperty(exports,"Ct",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"D",{enumerable:!0,get:function(){return ad}}),Object.defineProperty(exports,"E",{enumerable:!0,get:function(){return td}}),Object.defineProperty(exports,"F",{enumerable:!0,get:function(){return oo}}),Object.defineProperty(exports,"G",{enumerable:!0,get:function(){return Aa}}),Object.defineProperty(exports,"H",{enumerable:!0,get:function(){return Wa}}),Object.defineProperty(exports,"I",{enumerable:!0,get:function(){return po}}),Object.defineProperty(exports,"J",{enumerable:!0,get:function(){return yi}}),Object.defineProperty(exports,"K",{enumerable:!0,get:function(){return ka}}),Object.defineProperty(exports,"L",{enumerable:!0,get:function(){return uo}}),Object.defineProperty(exports,"M",{enumerable:!0,get:function(){return au}}),Object.defineProperty(exports,"N",{enumerable:!0,get:function(){return Eo}}),Object.defineProperty(exports,"O",{enumerable:!0,get:function(){return dd}}),Object.defineProperty(exports,"P",{enumerable:!0,get:function(){return no}}),Object.defineProperty(exports,"Q",{enumerable:!0,get:function(){return kr}}),Object.defineProperty(exports,"R",{enumerable:!0,get:function(){return co}}),Object.defineProperty(exports,"S",{enumerable:!0,get:function(){return Ad}}),Object.defineProperty(exports,"St",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"T",{enumerable:!0,get:function(){return ed}}),Object.defineProperty(exports,"U",{enumerable:!0,get:function(){return to}}),Object.defineProperty(exports,"V",{enumerable:!0,get:function(){return io}}),Object.defineProperty(exports,"W",{enumerable:!0,get:function(){return Ea}}),Object.defineProperty(exports,"X",{enumerable:!0,get:function(){return Rr}}),Object.defineProperty(exports,"Y",{enumerable:!0,get:function(){return Vr}}),Object.defineProperty(exports,"Z",{enumerable:!0,get:function(){return zr}}),Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return Ku}}),Object.defineProperty(exports,"_t",{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(exports,"at",{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return nd}}),Object.defineProperty(exports,"bt",{enumerable:!0,get:function(){return te}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return yd}}),Object.defineProperty(exports,"ct",{enumerable:!0,get:function(){return F}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return Bd}}),Object.defineProperty(exports,"dt",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(exports,"et",{enumerable:!0,get:function(){return We}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return Yu}}),Object.defineProperty(exports,"ft",{enumerable:!0,get:function(){return xe}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return wd}}),Object.defineProperty(exports,"gt",{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return $u}}),Object.defineProperty(exports,"ht",{enumerable:!0,get:function(){return he}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return Ed}}),Object.defineProperty(exports,"it",{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,"j",{enumerable:!0,get:function(){return nu}}),Object.defineProperty(exports,"k",{enumerable:!0,get:function(){return ud}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return _d}}),Object.defineProperty(exports,"lt",{enumerable:!0,get:function(){return I}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return Xd}}),Object.defineProperty(exports,"mt",{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return Yd}}),Object.defineProperty(exports,"nt",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return Nd}}),Object.defineProperty(exports,"ot",{enumerable:!0,get:function(){return Ce}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return Zd}}),Object.defineProperty(exports,"pt",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(exports,"q",{enumerable:!0,get:function(){return Gi}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return cd}}),Object.defineProperty(exports,"rt",{enumerable:!0,get:function(){return L}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return vd}}),Object.defineProperty(exports,"st",{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return bd}}),Object.defineProperty(exports,"tt",{enumerable:!0,get:function(){return Le}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return zd}}),Object.defineProperty(exports,"ut",{enumerable:!0,get:function(){return De}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return rd}}),Object.defineProperty(exports,"vt",{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,"w",{enumerable:!0,get:function(){return Kd}}),Object.defineProperty(exports,"x",{enumerable:!0,get:function(){return fd}}),Object.defineProperty(exports,"xt",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return pd}}),Object.defineProperty(exports,"yt",{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,"z",{enumerable:!0,get:function(){return fo}});
|
|
39
|
+
`))),0,0),e.someProp(`transformPasted`,t=>{s=t(s,e,!0)}),s;let n=e.someProp(`clipboardTextParser`,n=>n(t,i,r,e));if(n)s=n;else{let n=i.marks(),{schema:r}=e.state,a=u.C.fromSchema(r);o=document.createElement(`div`),t.split(/(?:\r\n?|\n)+/).forEach(e=>{let t=o.appendChild(document.createElement(`p`));e&&t.appendChild(a.serializeNode(r.text(e,n)))})}}else e.someProp(`transformPastedHTML`,t=>{n=t(n,e)}),o=ll(n),ss&&ul(o);let l=o&&o.querySelector(`[data-pm-slice]`),d=l&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(l.getAttribute(`data-pm-slice`)||``);if(d&&d[3])for(let e=+d[3];e>0;e--){let e=o.firstChild;for(;e&&e.nodeType!=1;)e=e.nextSibling;if(!e)break;o=e}if(s||=(e.someProp(`clipboardParser`)||e.someProp(`domParser`)||u.S.fromSchema(e.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||d),context:i,ruleFromNode(e){return e.nodeName==`BR`&&!e.nextSibling&&e.parentNode&&!Zc.test(e.parentNode.nodeName)?{ignore:!0}:null}}),d)s=dl(rl(s,+d[1],+d[2]),d[4]);else if(s=u.A.maxOpen(Qc(s.content,i),!0),s.openStart||s.openEnd){let e=0,t=0;for(let t=s.content.firstChild;e<s.openStart&&!t.type.spec.isolating;e++,t=t.firstChild);for(let e=s.content.lastChild;t<s.openEnd&&!e.type.spec.isolating;t++,e=e.lastChild);s=rl(s,e,t)}return e.someProp(`transformPasted`,t=>{s=t(s,e,c)}),s}var Zc=/^(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 Qc(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let r=t.node(n).contentMatchAt(t.index(n)),i,a=[];if(e.forEach(e=>{if(!a)return;let t=r.findWrapping(e.type),n;if(!t)return a=null;if(n=a.length&&i.length&&el(t,i,e,a[a.length-1],0))a[a.length-1]=n;else{a.length&&(a[a.length-1]=tl(a[a.length-1],i.length));let n=$c(e,t);a.push(n),r=r.matchType(n.type),i=t}}),a)return u.w.from(a)}return e}function $c(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,u.w.from(e));return e}function el(e,t,n,r,i){if(i<e.length&&i<t.length&&e[i]==t[i]){let a=el(e,t,n,r.lastChild,i+1);if(a)return r.copy(r.content.replaceChild(r.childCount-1,a));if(r.contentMatchAt(r.childCount).matchType(i==e.length-1?n.type:e[i+1]))return r.copy(r.content.append(u.w.from($c(n,e,i+1))))}}function tl(e,t){if(t==0)return e;let n=e.content.replaceChild(e.childCount-1,tl(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(u.w.empty,!0);return e.copy(n.append(r))}function nl(e,t,n,r,i,a){let o=t<0?e.firstChild:e.lastChild,s=o.content;return e.childCount>1&&(a=0),i<r-1&&(s=nl(s,t,n,r,i+1,a)),i>=n&&(s=t<0?o.contentMatchAt(0).fillBefore(s,a<=i).append(s):s.append(o.contentMatchAt(o.childCount).fillBefore(u.w.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,o.copy(s))}function rl(e,t,n){return t<e.openStart&&(e=new u.A(nl(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new u.A(nl(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}var il={thead:[`table`],tbody:[`table`],tfoot:[`table`],caption:[`table`],colgroup:[`table`],col:[`table`,`colgroup`],tr:[`table`,`tbody`],td:[`table`,`tbody`,`tr`],th:[`table`,`tbody`,`tr`]},al=null;function ol(){return al||=document.implementation.createHTMLDocument(`title`)}var sl=null;function cl(e){let t=window.trustedTypes;return t?(sl||=t.defaultPolicy||t.createPolicy(`ProseMirrorClipboard`,{createHTML:e=>e}),sl.createHTML(e)):e}function ll(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=ol().createElement(`div`),r=/<([a-z][^>\s]+)/i.exec(e),i;if((i=r&&il[r[1].toLowerCase()])&&(e=i.map(e=>`<`+e+`>`).join(``)+e+i.map(e=>`</`+e+`>`).reverse().join(``)),n.innerHTML=cl(e),i)for(let e=0;e<i.length;e++)n=n.querySelector(i[e])||n;return n}function ul(e){let t=e.querySelectorAll(G?`span:not([class]):not([style])`:`span.Apple-converted-space`);for(let n=0;n<t.length;n++){let r=t[n];r.childNodes.length==1&&r.textContent==`\xA0`&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(` `),r)}}function dl(e,t){if(!e.size)return e;let n=e.content.firstChild.type.schema,r;try{r=JSON.parse(t)}catch{return e}let{content:i,openStart:a,openEnd:o}=e;for(let e=r.length-2;e>=0;e-=2){let t=n.nodes[r[e]];if(!t||t.hasRequiredAttrs())break;i=u.w.from(t.create(r[e+1],i)),a++,o++}return new u.A(i,a,o)}var Y={},X={},fl={touchstart:!0,touchmove:!0},pl=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 ml(e){for(let t in Y){let n=Y[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{yl(e,t)&&!vl(e,t)&&(e.editable||!(t.type in X))&&n(e,t)},fl[t]?{passive:!0}:void 0)}K&&e.dom.addEventListener(`input`,()=>null),_l(e)}function hl(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function gl(e){e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}function _l(e){e.someProp(`handleDOMEvents`,t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>vl(e,t))})}function vl(e,t){return e.someProp(`handleDOMEvents`,n=>{let r=n[t.type];return r?r(e,t)||t.defaultPrevented:!1})}function yl(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function bl(e,t){!vl(e,t)&&Y[t.type]&&(e.editable||!(t.type in X))&&Y[t.type](e,t)}X.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,!Pl(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!(os&&G&&n.keyCode==13)))if(n.keyCode!=229&&e.domObserver.forceFlush(),is&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==t&&(e.someProp(`handleKeyDown`,t=>t(e,Ko(13,`Enter`))),e.input.lastIOSEnter=0)},200)}else e.someProp(`handleKeyDown`,t=>t(e,n))||Jc(e,n)?n.preventDefault():hl(e,`key`)},X.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)},X.keypress=(e,t)=>{let n=t;if(Pl(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||q&&n.metaKey)return;if(e.someProp(`handleKeyPress`,t=>t(e,n))){n.preventDefault();return}let r=e.state.selection;if(!(r instanceof u.c)||!r.$from.sameParent(r.$to)){let t=String.fromCharCode(n.charCode),i=()=>e.state.tr.insertText(t).scrollIntoView();!/[\r\n]/.test(t)&&!e.someProp(`handleTextInput`,n=>n(e,r.$from.pos,r.$to.pos,t,i))&&e.dispatch(i()),n.preventDefault()}};function xl(e){return{left:e.clientX,top:e.clientY}}function Sl(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}function Cl(e,t,n,r,i){if(r==-1)return!1;let a=e.state.doc.resolve(r);for(let r=a.depth+1;r>0;r--)if(e.someProp(t,t=>r>a.depth?t(e,n,a.nodeAfter,a.before(r),i,!0):t(e,n,a.node(r),a.before(r),i,!1)))return!0;return!1}function wl(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);n==`pointer`&&r.setMeta(`pointer`,!0),e.dispatch(r)}function Tl(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return r&&r.isAtom&&u.r.isSelectable(r)?(wl(e,new u.r(n),`pointer`),!0):!1}function El(e,t){if(t==-1)return!1;let n=e.state.selection,r,i;n instanceof u.r&&(r=n.node);let a=e.state.doc.resolve(t);for(let e=a.depth+1;e>0;e--){let t=e>a.depth?a.nodeAfter:a.node(e);if(u.r.isSelectable(t)){i=r&&n.$from.depth>0&&e>=n.$from.depth&&a.before(n.$from.depth+1)==n.$from.pos?a.before(n.$from.depth):a.before(e);break}}return i==null?!1:(wl(e,u.r.create(e.state.doc,i),`pointer`),!0)}function Dl(e,t,n,r,i){return Cl(e,`handleClickOn`,t,n,r)||e.someProp(`handleClick`,n=>n(e,t,r))||(i?El(e,n):Tl(e,n))}function Ol(e,t,n,r){return Cl(e,`handleDoubleClickOn`,t,n,r)||e.someProp(`handleDoubleClick`,n=>n(e,t,r))}function kl(e,t,n,r){return Cl(e,`handleTripleClickOn`,t,n,r)||e.someProp(`handleTripleClick`,n=>n(e,t,r))||Al(e,n,r)}function Al(e,t,n){if(n.button!=0)return!1;let r=e.state.doc;if(t==-1)return r.inlineContent?(wl(e,u.c.create(r,0,r.content.size),`pointer`),!0):!1;let i=r.resolve(t);for(let t=i.depth+1;t>0;t--){let n=t>i.depth?i.nodeAfter:i.node(t),a=i.before(t);if(n.inlineContent)wl(e,u.c.create(r,a+1,a+1+n.content.size),`pointer`);else if(u.r.isSelectable(n))wl(e,u.r.create(r,a),`pointer`);else continue;return!0}}function jl(e){return Vl(e)}var Ml=q?`metaKey`:`ctrlKey`;Y.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=jl(e),i=Date.now(),a=`singleClick`;i-e.input.lastClick.time<500&&Sl(n,e.input.lastClick)&&!n[Ml]&&e.input.lastClick.button==n.button&&(e.input.lastClick.type==`singleClick`?a=`doubleClick`:e.input.lastClick.type==`doubleClick`&&(a=`tripleClick`)),e.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:a,button:n.button};let o=e.posAtCoords(xl(n));o&&(a==`singleClick`?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new Nl(e,o,n,!!r)):(a==`doubleClick`?Ol:kl)(e,o.pos,o.inside,n)?n.preventDefault():hl(e,`pointer`))};var Nl=class{constructor(e,t,n,r){this.view=e,this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[Ml],this.allowDefault=n.shiftKey;let i,a;if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),a=t.inside;else{let n=e.state.doc.resolve(t.pos);i=n.parent,a=n.depth?n.before():0}let o=r?null:n.target,s=o?e.docView.nearestDesc(o,!0):null;this.target=s&&s.nodeDOM.nodeType==1?s.nodeDOM:null;let{selection:c}=e.state;n.button==0&&(i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof u.r&&c.from<=a&&c.to>a)&&(this.mightDrag={node:i,pos:a,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&W&&!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)),hl(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(()=>_c(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(xl(e))),this.updateAllowDefault(e),this.allowDefault||!t?hl(this.view,`pointer`):Dl(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||K&&this.mightDrag&&!this.mightDrag.node.isAtom||G&&!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)?(wl(this.view,u.o.near(this.view.state.doc.resolve(t.pos)),`pointer`),e.preventDefault()):hl(this.view,`pointer`)}move(e){this.updateAllowDefault(e),hl(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)}};Y.touchstart=e=>{e.input.lastTouch=Date.now(),jl(e),hl(e,`pointer`)},Y.touchmove=e=>{e.input.lastTouch=Date.now(),hl(e,`pointer`)},Y.contextmenu=e=>jl(e);function Pl(e,t){return e.composing?!0:K&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}var Fl=os?5e3:-1;X.compositionstart=X.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof u.c&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>e.type.spec.inclusive===!1)||G&&as&&Il(e)))e.markCursor=e.state.storedMarks||n.marks(),Vl(e,!0),e.markCursor=null;else if(Vl(e,!t.selection.empty),W&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,r=t.focusOffset;n&&n.nodeType==1&&r!=0;){let t=r<0?n.lastChild:n.childNodes[r-1];if(!t)break;if(t.nodeType==3){let n=e.domSelection();n&&n.collapse(t,t.nodeValue.length);break}else n=t,r=-1}}e.input.composing=!0}Ll(e,Fl)};function Il(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||t.nodeType!=1||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return r.nodeType==1&&r.contentEditable==`false`}X.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,Ll(e,20))};function Ll(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>Vl(e),t))}function Rl(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Bl());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function zl(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=Vo(t.focusNode,t.focusOffset),r=Ho(t.focusNode,t.focusOffset);if(n&&r&&n!=r){let t=r.pmViewDesc,i=e.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!t||!t.isText(r.nodeValue))return r;if(e.input.compositionNode==r){let e=n.pmViewDesc;if(!(!e||!e.isText(n.nodeValue)))return r}}return n||r}function Bl(){let e=document.createEvent(`Event`);return e.initEvent(`event`,!0,!0),e.timeStamp}function Vl(e,t=!1){if(!(os&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),Rl(e),t||e.docView&&e.docView.dirty){let n=hc(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):(e.markCursor||t)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.dispatch(e.state.tr.deleteSelection()):e.updateState(e.state),!0}return!1}}function Hl(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement(`div`));n.appendChild(t),n.style.cssText=`position: fixed; left: -10000px; top: 10px`;let r=getSelection(),i=document.createRange();i.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}var Ul=U&&ts<15||is&&cs<604;Y.copy=X.cut=(e,t)=>{let n=t,r=e.state.selection,i=n.type==`cut`;if(r.empty)return;let a=Ul?null:n.clipboardData,{dom:o,text:s}=Yc(e,r.content());a?(n.preventDefault(),a.clearData(),a.setData(`text/html`,o.innerHTML),a.setData(`text/plain`,s)):Hl(e,o),i&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta(`uiEvent`,`cut`))};function Wl(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function Gl(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?`textarea`:`div`));n||(r.contentEditable=`true`),r.style.cssText=`position: fixed; left: -10000px; top: 10px`,r.focus();let i=e.input.shiftKey&&e.input.lastKeyCode!=45;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Kl(e,r.value,null,i,t):Kl(e,r.textContent,r.innerHTML,i,t)},50)}function Kl(e,t,n,r,i){let a=Xc(e,t,n,r,e.state.selection.$from);if(e.someProp(`handlePaste`,t=>t(e,i,a||u.A.empty)))return!0;if(!a)return!1;let o=Wl(a),s=o?e.state.tr.replaceSelectionWith(o,r):e.state.tr.replaceSelection(a);return e.dispatch(s.scrollIntoView().setMeta(`paste`,!0).setMeta(`uiEvent`,`paste`)),!0}function ql(e){let t=e.getData(`text/plain`)||e.getData(`Text`);if(t)return t;let n=e.getData(`text/uri-list`);return n?n.replace(/\r?\n/g,` `):``}X.paste=(e,t)=>{let n=t;if(e.composing&&!os)return;let r=Ul?null:n.clipboardData,i=e.input.shiftKey&&e.input.lastKeyCode!=45;r&&Kl(e,ql(r),r.getData(`text/html`),i,n)?n.preventDefault():Gl(e,n)};var Jl=class{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}},Yl=q?`altKey`:`ctrlKey`;function Xl(e,t){let n;return e.someProp(`dragCopies`,e=>{n||=e(t)}),n==null?!t[Yl]:!n}Y.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=e.state.selection,a=i.empty?null:e.posAtCoords(xl(n)),o;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof u.r?i.to-1:i.to))){if(r&&r.mightDrag)o=u.r.create(e.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&(o=u.r.create(e.state.doc,t.posBefore))}}let{dom:s,text:c,slice:l}=Yc(e,(o||e.state.selection).content());(!n.dataTransfer.files.length||!G||rs>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Ul?`Text`:`text/html`,s.innerHTML),n.dataTransfer.effectAllowed=`copyMove`,Ul||n.dataTransfer.setData(`text/plain`,c),e.dragging=new Jl(l,Xl(e,n),o)},Y.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},X.dragover=X.dragenter=(e,t)=>t.preventDefault(),X.drop=(e,t)=>{try{Zl(e,t,e.dragging)}finally{e.dragging=null}};function Zl(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(xl(t));if(!r)return;let i=e.state.doc.resolve(r.pos),a=n&&n.slice;a?e.someProp(`transformPasted`,t=>{a=t(a,e,!1)}):a=Xc(e,ql(t.dataTransfer),Ul?null:t.dataTransfer.getData(`text/html`),!1,i);let o=!!(n&&Xl(e,t));if(e.someProp(`handleDrop`,n=>n(e,t,a||u.A.empty,o))){t.preventDefault();return}if(!a)return;t.preventDefault();let s=a?u._(e.state.doc,i.pos,a):i.pos;s??=i.pos;let c=e.state.tr;if(o){let{node:e}=n;e?e.replace(c):c.deleteSelection()}let l=c.mapping.map(s),d=a.openStart==0&&a.openEnd==0&&a.content.childCount==1,f=c.doc;if(d?c.replaceRangeWith(l,l,a.content.firstChild):c.replaceRange(l,l,a),c.doc.eq(f))return;let p=c.doc.resolve(l);if(d&&u.r.isSelectable(a.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(a.content.firstChild))c.setSelection(new u.r(p));else{let t=c.mapping.map(s);c.mapping.maps[c.mapping.maps.length-1].forEach((e,n,r,i)=>t=i),c.setSelection(Ec(e,p,c.doc.resolve(t)))}e.focus(),e.dispatch(c.setMeta(`uiEvent`,`drop`))}Y.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add(`ProseMirror-focused`),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&_c(e)},20))},Y.blur=(e,t)=>{let n=t;e.focused&&=(e.domObserver.stop(),e.dom.classList.remove(`ProseMirror-focused`),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),!1)},Y.beforeinput=(e,t)=>{if(G&&os&&t.inputType==`deleteContentBackward`){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=t||(e.dom.blur(),e.focus(),e.someProp(`handleKeyDown`,t=>t(e,Ko(8,`Backspace`)))))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())},50)}};for(let e in X)Y[e]=X[e];function Ql(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}var $l=class e{constructor(e,t){this.toDOM=e,this.spec=t||iu,this.side=this.spec.side||0}map(e,t,n,r){let{pos:i,deleted:a}=e.mapResult(t.from+r,this.side<0?-1:1);return a?null:new nu(i-n,i-n,this)}valid(){return!0}eq(t){return this==t||t instanceof e&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&Ql(this.spec,t.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},eu=class e{constructor(e,t){this.attrs=e,this.spec=t||iu}map(e,t,n,r){let i=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,a=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return i>=a?null:new nu(i,a,this)}valid(e,t){return t.from<t.to}eq(t){return this==t||t instanceof e&&Ql(this.attrs,t.attrs)&&Ql(this.spec,t.spec)}static is(t){return t.type instanceof e}destroy(){}},tu=class e{constructor(e,t){this.attrs=e,this.spec=t||iu}map(e,t,n,r){let i=e.mapResult(t.from+r,1);if(i.deleted)return null;let a=e.mapResult(t.to+r,-1);return a.deleted||a.pos<=i.pos?null:new nu(i.pos-n,a.pos-n,this)}valid(e,t){let{index:n,offset:r}=e.content.findIndex(t.from),i;return r==t.from&&!(i=e.child(n)).isText&&r+i.nodeSize==t.to}eq(t){return this==t||t instanceof e&&Ql(this.attrs,t.attrs)&&Ql(this.spec,t.spec)}destroy(){}},nu=class e{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(t,n){return new e(t,n,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,n){return this.type.map(e,this,t,n)}static widget(t,n,r){return new e(t,t,new $l(n,r))}static inline(t,n,r,i){return new e(t,n,new eu(r,i))}static node(t,n,r,i){return new e(t,n,new tu(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof eu}get widget(){return this.type instanceof $l}},ru=[],iu={},au=class e{constructor(e,t){this.local=e.length?e:ru,this.children=t.length?t:ru}static create(e,t){return t.length?fu(t,e,0,iu):Z}find(e,t,n){let r=[];return this.findInner(e??0,t??1e9,r,0,n),r}findInner(e,t,n,r,i){for(let a=0;a<this.local.length;a++){let o=this.local[a];o.from<=t&&o.to>=e&&(!i||i(o.spec))&&n.push(o.copy(o.from+r,o.to+r))}for(let a=0;a<this.children.length;a+=3)if(this.children[a]<t&&this.children[a+1]>e){let o=this.children[a]+1;this.children[a+2].findInner(e-o,t-o,n,r+o,i)}}map(e,t,n){return this==Z||e.maps.length==0?this:this.mapInner(e,t,0,0,n||iu)}mapInner(t,n,r,i,a){let o;for(let e=0;e<this.local.length;e++){let s=this.local[e].map(t,r,i);s&&s.type.valid(n,s)?(o||=[]).push(s):a.onRemove&&a.onRemove(this.local[e].spec)}return this.children.length?su(this.children,o||[],t,n,r,i,a):o?new e(o.sort(pu),ru):Z}add(t,n){return n.length?this==Z?e.create(t,n):this.addInner(t,n,0):this}addInner(t,n,r){let i,a=0;t.forEach((e,t)=>{let o=t+r,s;if(s=uu(n,e,o)){for(i||=this.children.slice();a<i.length&&i[a]<t;)a+=3;i[a]==t?i[a+2]=i[a+2].addInner(e,s,o+1):i.splice(a,0,t,t+e.nodeSize,fu(s,e,o+1,iu)),a+=3}});let o=cu(a?du(n):n,-r);for(let e=0;e<o.length;e++)o[e].type.valid(t,o[e])||o.splice(e--,1);return new e(o.length?this.local.concat(o).sort(pu):this.local,i||this.children)}remove(e){return e.length==0||this==Z?this:this.removeInner(e,0)}removeInner(t,n){let r=this.children,i=this.local;for(let e=0;e<r.length;e+=3){let i,a=r[e]+n,o=r[e+1]+n;for(let e=0,n;e<t.length;e++)(n=t[e])&&n.from>a&&n.to<o&&(t[e]=null,(i||=[]).push(n));if(!i)continue;r==this.children&&(r=this.children.slice());let s=r[e+2].removeInner(i,a+1);s==Z?(r.splice(e,3),e-=3):r[e+2]=s}if(i.length){for(let e=0,r;e<t.length;e++)if(r=t[e])for(let e=0;e<i.length;e++)i[e].eq(r,n)&&(i==this.local&&(i=this.local.slice()),i.splice(e--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new e(i,r):Z}forChild(t,n){if(this==Z)return this;if(n.isLeaf)return e.empty;let r,i;for(let e=0;e<this.children.length;e+=3)if(this.children[e]>=t){this.children[e]==t&&(r=this.children[e+2]);break}let a=t+1,o=a+n.content.size;for(let e=0;e<this.local.length;e++){let t=this.local[e];if(t.from<o&&t.to>a&&t.type instanceof eu){let e=Math.max(a,t.from)-a,n=Math.min(o,t.to)-a;e<n&&(i||=[]).push(t.copy(e,n))}}if(i){let t=new e(i.sort(pu),ru);return r?new ou([t,r]):t}return r||Z}eq(t){if(this==t)return!0;if(!(t instanceof e)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(let e=0;e<this.local.length;e++)if(!this.local[e].eq(t.local[e]))return!1;for(let e=0;e<this.children.length;e+=3)if(this.children[e]!=t.children[e]||this.children[e+1]!=t.children[e+1]||!this.children[e+2].eq(t.children[e+2]))return!1;return!0}locals(e){return mu(this.localsInner(e))}localsInner(e){if(this==Z)return ru;if(e.inlineContent||!this.local.some(eu.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof eu||t.push(this.local[e]);return t}forEachSet(e){e(this)}};au.empty=new au([],[]),au.removeOverlap=mu;var Z=au.empty,ou=class e{constructor(e){this.members=e}map(t,n){let r=this.members.map(e=>e.map(t,n,iu));return e.from(r)}forChild(t,n){if(n.isLeaf)return au.empty;let r=[];for(let i=0;i<this.members.length;i++){let a=this.members[i].forChild(t,n);a!=Z&&(a instanceof e?r=r.concat(a.members):r.push(a))}return e.from(r)}eq(t){if(!(t instanceof e)||t.members.length!=this.members.length)return!1;for(let e=0;e<this.members.length;e++)if(!this.members[e].eq(t.members[e]))return!1;return!0}locals(e){let t,n=!0;for(let r=0;r<this.members.length;r++){let i=this.members[r].localsInner(e);if(i.length)if(!t)t=i;else{n&&=(t=t.slice(),!1);for(let e=0;e<i.length;e++)t.push(i[e])}}return t?mu(n?t:t.sort(pu)):ru}static from(t){switch(t.length){case 0:return Z;case 1:return t[0];default:return new e(t.every(e=>e instanceof au)?t:t.reduce((e,t)=>e.concat(t instanceof au?t:t.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function su(e,t,n,r,i,a,o){let s=e.slice();for(let e=0,t=a;e<n.maps.length;e++){let r=0;n.maps[e].forEach((e,n,i,a)=>{let o=a-i-(n-e);for(let i=0;i<s.length;i+=3){let a=s[i+1];if(a<0||e>a+t-r)continue;let c=s[i]+t-r;n>=c?s[i+1]=e<=c?-2:-1:e>=t&&o&&(s[i]+=o,s[i+1]+=o)}r+=o}),t=n.maps[e].map(t,-1)}let c=!1;for(let t=0;t<s.length;t+=3)if(s[t+1]<0){if(s[t+1]==-2){c=!0,s[t+1]=-1;continue}let l=n.map(e[t]+a),u=l-i;if(u<0||u>=r.content.size){c=!0;continue}let d=n.map(e[t+1]+a,-1)-i,{index:f,offset:p}=r.content.findIndex(u),m=r.maybeChild(f);if(m&&p==u&&p+m.nodeSize==d){let r=s[t+2].mapInner(n,m,l+1,e[t]+a+1,o);r==Z?(s[t+1]=-2,c=!0):(s[t]=u,s[t+1]=d,s[t+2]=r)}else c=!0}if(c){let c=fu(lu(s,e,t,n,i,a,o),r,0,o);t=c.local;for(let e=0;e<s.length;e+=3)s[e+1]<0&&(s.splice(e,3),e-=3);for(let e=0,t=0;e<c.children.length;e+=3){let n=c.children[e];for(;t<s.length&&s[t]<n;)t+=3;s.splice(t,0,c.children[e],c.children[e+1],c.children[e+2])}}return new au(t.sort(pu),s)}function cu(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let i=e[r];n.push(new nu(i.from+t,i.to+t,i.type))}return n}function lu(e,t,n,r,i,a,o){function s(e,t){for(let a=0;a<e.local.length;a++){let s=e.local[a].map(r,i,t);s?n.push(s):o.onRemove&&o.onRemove(e.local[a].spec)}for(let n=0;n<e.children.length;n+=3)s(e.children[n+2],e.children[n]+t+1)}for(let n=0;n<e.length;n+=3)e[n+1]==-1&&s(e[n+2],t[n]+a+1);return n}function uu(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,i=null;for(let t=0,a;t<e.length;t++)(a=e[t])&&a.from>n&&a.to<r&&((i||=[]).push(a),e[t]=null);return i}function du(e){let t=[];for(let n=0;n<e.length;n++)e[n]!=null&&t.push(e[n]);return t}function fu(e,t,n,r){let i=[],a=!1;t.forEach((t,o)=>{let s=uu(e,t,o+n);if(s){a=!0;let e=fu(s,t,n+o+1,r);e!=Z&&i.push(o,o+t.nodeSize,e)}});let o=cu(a?du(e):e,-n).sort(pu);for(let e=0;e<o.length;e++)o[e].type.valid(t,o[e])||(r.onRemove&&r.onRemove(o[e].spec),o.splice(e--,1));return o.length||i.length?new au(o,i):Z}function pu(e,t){return e.from-t.from||e.to-t.to}function mu(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let i=n+1;i<t.length;i++){let a=t[i];if(a.from==r.from){a.to!=r.to&&(t==e&&(t=e.slice()),t[i]=a.copy(a.from,r.to),hu(t,i+1,a.copy(r.to,a.to)));continue}else{a.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,a.from),hu(t,i,r.copy(a.from,r.to)));break}}}return t}function hu(e,t,n){for(;t<e.length&&pu(n,e[t])>0;)t++;e.splice(t,0,n)}function gu(e){let t=[];return e.someProp(`decorations`,n=>{let r=n(e.state);r&&r!=Z&&t.push(r)}),e.cursorWrapper&&t.push(au.create(e.state.doc,[e.cursorWrapper.deco])),ou.from(t)}var _u={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},vu=U&&ts<=11,yu=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}},bu=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new yu,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);U&&ts<=11&&t.some(e=>e.type==`childList`&&e.removedNodes.length||e.type==`characterData`&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():K&&e.composing&&t.some(e=>e.type==`childList`&&e.target.nodeName==`TR`)?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),vu&&(this.onCharData=e=>{this.queue.push({target:e.target,type:`characterData`,oldValue:e.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,_u)),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(Dc(this.view)){if(this.suppressingSelectionUpdates)return _c(this.view);if(U&&ts<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Ro(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,n;for(let n=e.focusNode;n;n=Po(n))t.add(n);for(let r=e.anchorNode;r;r=Po(r))if(t.has(r)){n=r;break}let r=n&&this.view.docView.nearestDesc(n);if(r&&r.ignoreMutation({type:`selection`,target:n.nodeType==3?n.parentNode:n}))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 n=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&Dc(e)&&!this.ignoreSelectionChange(n),i=-1,a=-1,o=!1,s=[];if(e.editable)for(let e=0;e<t.length;e++){let n=this.registerMutation(t[e],s);n&&(i=i<0?n.from:Math.min(n.from,i),a=a<0?n.to:Math.max(n.to,a),n.typeOver&&(o=!0))}if(s.some(e=>e.nodeName==`BR`)&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let e of s)if(e.nodeName==`BR`&&e.parentNode){let t=e.nextSibling;for(;t&&t.nodeType==1;){if(t.contentEditable==`false`){e.parentNode.removeChild(e);break}t=t.firstChild}}}else if(W&&s.length){let t=s.filter(e=>e.nodeName==`BR`);if(t.length==2){let[e,n]=t;e.parentNode&&e.parentNode.parentNode==n.parentNode?n.remove():e.remove()}else{let{focusNode:n}=this.currentSelection;for(let r of t){let t=r.parentNode;t&&t.nodeName==`LI`&&(!n||Eu(e,n)!=t)&&r.remove()}}}let c=null;i<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Go(n)&&(c=hc(e))&&c.eq(u.o.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,_c(e),this.currentSelection.set(n),e.scrollToSelection()):(i>-1||r)&&(i>-1&&(e.docView.markDirty(i,a),Cu(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,Du(e,s)),this.handleDOMChange(i,a,o,s),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||_c(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if(e.type==`attributes`&&(n==this.view.docView||e.attributeName==`contenteditable`||e.attributeName==`style`&&!e.oldValue&&!e.target.getAttribute(`style`))||!n||n.ignoreMutation(e))return null;if(e.type==`childList`){for(let n=0;n<e.addedNodes.length;n++){let r=e.addedNodes[n];t.push(r),r.nodeType==3&&(this.lastChangedTextNode=r)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let r=e.previousSibling,i=e.nextSibling;if(U&&ts<=11&&e.addedNodes.length)for(let t=0;t<e.addedNodes.length;t++){let{previousSibling:n,nextSibling:a}=e.addedNodes[t];(!n||Array.prototype.indexOf.call(e.addedNodes,n)<0)&&(r=n),(!a||Array.prototype.indexOf.call(e.addedNodes,a)<0)&&(i=a)}let a=r&&r.parentNode==e.target?V(r)+1:0,o=n.localPosFromDOM(e.target,a,-1),s=i&&i.parentNode==e.target?V(i):e.target.childNodes.length;return{from:o,to:n.localPosFromDOM(e.target,s,1)}}else if(e.type==`attributes`)return{from:n.posAtStart-n.border,to:n.posAtEnd+n.border};else return this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}}},xu=new WeakMap,Su=!1;function Cu(e){if(!xu.has(e)&&(xu.set(e,null),[`normal`,`nowrap`,`pre-line`].indexOf(getComputedStyle(e.dom).whiteSpace)!==-1)){if(e.requiresGeckoHackNode=W,Su)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.`),Su=!0}}function wu(e,t){let n=t.startContainer,r=t.startOffset,i=t.endContainer,a=t.endOffset,o=e.domAtPos(e.state.selection.anchor);return Ro(o.node,o.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function Tu(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return wu(e,n)}let n;function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.dom.addEventListener(`beforeinput`,r,!0),document.execCommand(`indent`),e.dom.removeEventListener(`beforeinput`,r,!0),n?wu(e,n):null}function Eu(e,t){for(let n=t.parentNode;n&&n!=e.dom;n=n.parentNode){let t=e.docView.nearestDesc(n,!0);if(t&&t.node.isBlock)return n}return null}function Du(e,t){let{focusNode:n,focusOffset:r}=e.domSelectionRange();for(let i of t)if(i.parentNode?.nodeName==`TR`){let t=i.nextSibling;for(;t&&t.nodeName!=`TD`&&t.nodeName!=`TH`;)t=t.nextSibling;if(t){let a=t;for(;;){let e=a.firstChild;if(!e||e.nodeType!=1||e.contentEditable==`false`||/^(BR|IMG)$/.test(e.nodeName))break;a=e}a.insertBefore(i,a.firstChild),n==i&&e.domSelection().collapse(i,r)}else i.parentNode.removeChild(i)}}function Ou(e,t,n){let{node:r,fromOffset:i,toOffset:a,from:o,to:s}=e.docView.parseRange(t,n),c=e.domSelectionRange(),l,d=c.anchorNode;if(d&&e.dom.contains(d.nodeType==1?d:d.parentNode)&&(l=[{node:d,offset:c.anchorOffset}],Go(c)||l.push({node:c.focusNode,offset:c.focusOffset})),G&&e.input.lastKeyCode===8)for(let e=a;e>i;e--){let t=r.childNodes[e-1],n=t.pmViewDesc;if(t.nodeName==`BR`&&!n){a=e;break}if(!n||n.size)break}let f=e.state.doc,p=e.someProp(`domParser`)||u.S.fromSchema(e.state.schema),m=f.resolve(o),h=null,g=p.parse(r,{topNode:m.parent,topMatch:m.parent.contentMatchAt(m.index()),topOpen:!0,from:i,to:a,preserveWhitespace:m.parent.type.whitespace==`pre`?`full`:!0,findPositions:l,ruleFromNode:ku,context:m});if(l&&l[0].pos!=null){let e=l[0].pos,t=l[1]&&l[1].pos;t??=e,h={anchor:e+o,head:t+o}}return{doc:g,sel:h,from:o,to:s}}function ku(e){let t=e.pmViewDesc;if(t)return t.parseRule();if(e.nodeName==`BR`&&e.parentNode){if(K&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let e=document.createElement(`div`);return e.appendChild(document.createElement(`li`)),{skip:e}}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}var Au=/^(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 ju(e,t,n,r,i){let a=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=hc(e,t);if(n&&!e.state.selection.eq(n)){if(G&&os&&e.input.lastKeyCode===13&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp(`handleKeyDown`,t=>t(e,Ko(13,`Enter`))))return;let r=e.state.tr.setSelection(n);t==`pointer`?r.setMeta(`pointer`,!0):t==`key`&&r.scrollIntoView(),a&&r.setMeta(`composition`,a),e.dispatch(r)}return}let o=e.state.doc.resolve(t),s=o.sharedDepth(n);t=o.before(s+1),n=e.state.doc.resolve(n).after(s+1);let c=e.state.selection,l=Ou(e,t,n),d=e.state.doc,f=d.slice(l.from,l.to),p,m;e.input.lastKeyCode===8&&Date.now()-100<e.input.lastKeyCodeTime?(p=e.state.selection.to,m=`end`):(p=e.state.selection.from,m=`start`),e.input.lastKeyCode=null;let h=Iu(f.content,l.doc.content,l.from,p,m);if(h&&e.input.domChangeCount++,(is&&e.input.lastIOSEnter>Date.now()-225||os)&&i.some(e=>e.nodeType==1&&!Au.test(e.nodeName))&&(!h||h.endA>=h.endB)&&e.someProp(`handleKeyDown`,t=>t(e,Ko(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(!h)if(r&&c instanceof u.c&&!c.empty&&c.$head.sameParent(c.$anchor)&&!e.composing&&!(l.sel&&l.sel.anchor!=l.sel.head))h={start:c.from,endA:c.to,endB:c.to};else{if(l.sel){let t=Mu(e,e.state.doc,l.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);a&&n.setMeta(`composition`,a),e.dispatch(n)}}return}e.state.selection.from<e.state.selection.to&&h.start==h.endB&&e.state.selection instanceof u.c&&(h.start>e.state.selection.from&&h.start<=e.state.selection.from+2&&e.state.selection.from>=l.from?h.start=e.state.selection.from:h.endA<e.state.selection.to&&h.endA>=e.state.selection.to-2&&e.state.selection.to<=l.to&&(h.endB+=e.state.selection.to-h.endA,h.endA=e.state.selection.to)),U&&ts<=11&&h.endB==h.start+1&&h.endA==h.start&&h.start>l.from&&l.doc.textBetween(h.start-l.from-1,h.start-l.from+1)==` \xA0`&&(h.start--,h.endA--,h.endB--);let g=l.doc.resolveNoCache(h.start-l.from),_=l.doc.resolveNoCache(h.endB-l.from),v=d.resolve(h.start),y=g.sameParent(_)&&g.parent.inlineContent&&v.end()>=h.endA;if((is&&e.input.lastIOSEnter>Date.now()-225&&(!y||i.some(e=>e.nodeName==`DIV`||e.nodeName==`P`))||!y&&g.pos<l.doc.content.size&&(!g.sameParent(_)||!g.parent.inlineContent)&&g.pos<_.pos&&!/\S/.test(l.doc.textBetween(g.pos,_.pos,``,``)))&&e.someProp(`handleKeyDown`,t=>t(e,Ko(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>h.start&&Pu(d,h.start,h.endA,g,_)&&e.someProp(`handleKeyDown`,t=>t(e,Ko(8,`Backspace`)))){os&&G&&e.domObserver.suppressSelectionUpdates();return}G&&h.endB==h.start&&(e.input.lastChromeDelete=Date.now()),os&&!y&&g.start()!=_.start()&&_.parentOffset==0&&g.depth==_.depth&&l.sel&&l.sel.anchor==l.sel.head&&l.sel.head==h.endA&&(h.endB-=2,_=l.doc.resolveNoCache(h.endB-l.from),setTimeout(()=>{e.someProp(`handleKeyDown`,function(t){return t(e,Ko(13,`Enter`))})},20));let b=h.start,x=h.endA,S=t=>{let n=t||e.state.tr.replace(b,x,l.doc.slice(h.start-l.from,h.endB-l.from));if(l.sel){let t=Mu(e,n.doc,l.sel);t&&!(G&&e.composing&&t.empty&&(h.start!=h.endB||e.input.lastChromeDelete<Date.now()-100)&&(t.head==b||t.head==n.mapping.map(x)-1)||U&&t.empty&&t.head==b)&&n.setSelection(t)}return a&&n.setMeta(`composition`,a),n.scrollIntoView()},C;if(y)if(g.pos==_.pos){U&&ts<=11&&g.parentOffset==0&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>_c(e),20));let t=S(e.state.tr.delete(b,x)),n=d.resolve(h.start).marksAcross(d.resolve(h.endA));n&&t.ensureMarks(n),e.dispatch(t)}else if(h.endA==h.endB&&(C=Nu(g.parent.content.cut(g.parentOffset,_.parentOffset),v.parent.content.cut(v.parentOffset,h.endA-v.start())))){let t=S(e.state.tr);C.type==`add`?t.addMark(b,x,C.mark):t.removeMark(b,x,C.mark),e.dispatch(t)}else if(g.parent.child(g.index()).isText&&g.index()==_.index()-+!_.textOffset){let t=g.parent.textBetween(g.parentOffset,_.parentOffset),n=()=>S(e.state.tr.insertText(t,b,x));e.someProp(`handleTextInput`,r=>r(e,b,x,t,n))||e.dispatch(n())}else e.dispatch(S());else e.dispatch(S())}function Mu(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:Ec(e,t.resolve(n.anchor),t.resolve(n.head))}function Nu(e,t){let n=e.firstChild.marks,r=t.firstChild.marks,i=n,a=r,o,s,c;for(let e=0;e<r.length;e++)i=r[e].removeFromSet(i);for(let e=0;e<n.length;e++)a=n[e].removeFromSet(a);if(i.length==1&&a.length==0)s=i[0],o=`add`,c=e=>e.mark(s.addToSet(e.marks));else if(i.length==0&&a.length==1)s=a[0],o=`remove`,c=e=>e.mark(s.removeFromSet(e.marks));else return null;let l=[];for(let e=0;e<t.childCount;e++)l.push(c(t.child(e)));if(u.w.from(l).eq(e))return{mark:s,type:o}}function Pu(e,t,n,r,i){if(n-t<=i.pos-r.pos||Fu(r,!0,!1)<i.pos)return!1;let a=e.resolve(t);if(!r.parent.isTextblock){let e=a.nodeAfter;return e!=null&&n==t+e.nodeSize}if(a.parentOffset<a.parent.content.size||!a.parent.isTextblock)return!1;let o=e.resolve(Fu(a,!0,!0));return!o.parent.isTextblock||o.pos>n||Fu(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function Fu(e,t,n){let r=e.depth,i=t?e.end():e.pos;for(;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,i++,t=!1;if(n){let t=e.node(r).maybeChild(e.indexAfter(r));for(;t&&!t.isLeaf;)t=t.firstChild,i++}return i}function Iu(e,t,n,r,i){let a=e.findDiffStart(t,n);if(a==null)return null;let{a:o,b:s}=e.findDiffEnd(t,n+e.size,n+t.size);if(i==`end`){let e=Math.max(0,a-Math.min(o,s));r-=o+e-a}if(o<a&&e.size<t.size){let e=r<=a&&r>=o?a-r:0;a-=e,a&&a<t.size&&Lu(t.textBetween(a-1,a+1))&&(a+=e?1:-1),s=a+(s-o),o=a}else if(s<a){let t=r<=a&&r>=s?a-r:0;a-=t,a&&a<e.size&&Lu(e.textBetween(a-1,a+1))&&(a+=t?1:-1),o=a+(o-s),s=a}return{start:a,endA:o,endB:s}}function Lu(e){if(e.length!=2)return!1;let t=e.charCodeAt(0),n=e.charCodeAt(1);return t>=56320&&t<=57343&&n>=55296&&n<=56319}var Ru=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 pl,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Gu),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=Vu(this),Bu(this),this.nodeViews=Uu(this),this.docView=Ys(this.state.doc,zu(this),gu(this),this.dom,this),this.domObserver=new bu(this,(e,t,n,r)=>ju(this,e,t,n,r)),this.domObserver.start(),ml(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&&_l(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Gu),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){let n=this.state,r=!1,i=!1;e.storedMarks&&this.composing&&(Rl(this),i=!0),this.state=e;let a=n.plugins!=e.plugins||this._props.plugins!=t.plugins;if(a||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=Uu(this);Wu(e,this.nodeViews)&&(this.nodeViews=e,r=!0)}(a||t.handleDOMEvents!=this._props.handleDOMEvents)&&_l(this),this.editable=Vu(this),Bu(this);let o=gu(this),s=zu(this),c=n.plugins!=e.plugins&&!n.doc.eq(e.doc)?`reset`:e.scrollToSelection>n.scrollToSelection?`to selection`:`preserve`,l=r||!this.docView.matchesNode(e.doc,s,o);(l||!e.selection.eq(n.selection))&&(i=!0);let u=c==`preserve`&&i&&this.dom.style.overflowAnchor==null&&ps(this);if(i){this.domObserver.stop();let t=l&&(U||G)&&!this.composing&&!n.selection.empty&&!e.selection.empty&&Hu(n.selection,e.selection);if(l){let n=G?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=zl(this)),(r||!this.docView.update(e.doc,s,o,this))&&(this.docView.updateOuterDeco(s),this.docView.destroy(),this.docView=Ys(e.doc,s,o,this.dom,this)),n&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(t=!0)}t||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&kc(this))?_c(this,t):(wc(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(n),this.dragging?.node&&!n.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,n),c==`reset`?this.dom.scrollTop=0:c==`to selection`?this.scrollToSelection():u&&hs(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))&&!this.someProp(`handleScrollToSelection`,e=>e(this)))if(this.state.selection instanceof u.r){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&fs(this,t.getBoundingClientRect(),e)}else fs(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 e=0;e<this.directPlugins.length;e++){let t=this.directPlugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let t=this.state.plugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}}updateDraggedNode(e,t){let n=e.node,r=-1;if(n.from<this.state.doc.content.size&&this.state.doc.nodeAt(n.from)==n.node)r=n.from;else{let e=n.from+(this.state.doc.content.size-t.doc.content.size);(e>0&&e<this.state.doc.content.size&&this.state.doc.nodeAt(e))==n.node&&(r=e)}this.dragging=new Jl(e.slice,e.move,r<0?void 0:u.r.create(this.state.doc,r))}someProp(e,t){let n=this._props&&this._props[e],r;if(n!=null&&(r=t?t(n):n))return r;for(let n=0;n<this.directPlugins.length;n++){let i=this.directPlugins[n].props[e];if(i!=null&&(r=t?t(i):i))return r}let i=this.state.plugins;if(i)for(let n=0;n<i.length;n++){let a=i[n].props[e];if(a!=null&&(r=t?t(a):a))return r}}hasFocus(){if(U){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&&vs(this.dom),_c(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let e=this.dom.parentNode;e;e=e.parentNode)if(e.nodeType==9||e.nodeType==11&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=()=>e.ownerDocument.getSelection()),this._root=e}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Es(this,e)}coordsAtPos(e,t=1){return As(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,n=-1){let r=this.docView.posFromDOM(e,t,n);if(r==null)throw RangeError(`DOM position not inside the editor`);return r}endOfTextblock(e,t){return Bs(this,t||this.state,e)}pasteHTML(e,t){return Kl(this,``,e,!1,t||new ClipboardEvent(`paste`))}pasteText(e,t){return Kl(this,e,null,!0,t||new ClipboardEvent(`paste`))}serializeForClipboard(e){return Yc(this,e)}destroy(){this.docView&&(gl(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],gu(this),this),this.dom.textContent=``):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Lo())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return bl(this,e)}domSelectionRange(){let e=this.domSelection();return e?K&&this.root.nodeType===11&&qo(this.dom.ownerDocument)==this.dom&&Tu(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};Ru.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};function zu(e){let t=Object.create(null);return t.class=`ProseMirror`,t.contenteditable=String(e.editable),e.someProp(`attributes`,n=>{if(typeof n==`function`&&(n=n(e.state)),n)for(let e in n)e==`class`?t.class+=` `+n[e]:e==`style`?t.style=(t.style?t.style+`;`:``)+n[e]:!t[e]&&e!=`contenteditable`&&e!=`nodeName`&&(t[e]=String(n[e]))}),t.translate||=`no`,[nu.node(0,e.state.doc.content.size,t)]}function Bu(e){if(e.markCursor){let t=document.createElement(`img`);t.className=`ProseMirror-separator`,t.setAttribute(`mark-placeholder`,`true`),t.setAttribute(`alt`,``),e.cursorWrapper={dom:t,deco:nu.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function Vu(e){return!e.someProp(`editable`,t=>t(e.state)===!1)}function Hu(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}function Uu(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp(`nodeViews`,n),e.someProp(`markViews`,n),t}function Wu(e,t){let n=0,r=0;for(let r in e){if(e[r]!=t[r])return!0;n++}for(let e in t)r++;return n!=r}function Gu(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw RangeError(`Plugins passed directly to the view must not have a state component`)}var Ku=s({CommandManager:()=>gd,CommandsReady:()=>bd,ConfigReady:()=>od,Editor:()=>of,EditorStateReady:()=>Vd,EditorStatus:()=>$,EditorViewReady:()=>Yd,InitReady:()=>cd,KeymapManager:()=>Cd,KeymapReady:()=>Ed,ParserReady:()=>Od,PasteRulesReady:()=>qd,SchemaReady:()=>Q,SerializerReady:()=>Nd,commands:()=>xd,commandsCtx:()=>vd,commandsTimerCtx:()=>yd,config:()=>sd,createCmdKey:()=>_d,defaultValueCtx:()=>Rd,editorCtx:()=>Qu,editorState:()=>Wd,editorStateCtx:()=>Xu,editorStateOptionsCtx:()=>zd,editorStateTimerCtx:()=>Bd,editorView:()=>af,editorViewCtx:()=>Yu,editorViewOptionsCtx:()=>Zd,editorViewTimerCtx:()=>Xd,getDoc:()=>Hd,init:()=>ld,initTimerCtx:()=>Zu,inputRulesCtx:()=>$u,keymap:()=>Dd,keymapCtx:()=>wd,keymapTimerCtx:()=>Td,markViewCtx:()=>rd,marksCtx:()=>pd,nodeViewCtx:()=>nd,nodesCtx:()=>fd,parser:()=>Md,parserCtx:()=>Ad,parserTimerCtx:()=>jd,pasteRule:()=>Jd,pasteRulesCtx:()=>Gd,pasteRulesTimerCtx:()=>Kd,prosePluginsCtx:()=>ed,remarkCtx:()=>id,remarkPluginsCtx:()=>td,remarkStringifyOptionsCtx:()=>ad,rootAttrsCtx:()=>ef,rootCtx:()=>Qd,rootDOMCtx:()=>$d,schema:()=>hd,schemaCtx:()=>dd,schemaTimerCtx:()=>ud,serializer:()=>Ld,serializerCtx:()=>Id,serializerTimerCtx:()=>Pd});function qu(e,t){return e.meta={package:`@milkdown/core`,group:`System`,...t},e}var Ju={text:(e,t,n,r)=>{let i=e.value;return/^[^*_\\]*\s+$/.test(i)?i:n.safe(i,{...r,encode:[]})},strong:(e,t,n,r)=>{let i=e.marker||n.options.strong||`*`,a=n.enter(`strong`),o=n.createTracker(r),s=o.move(i+i);return s+=o.move(n.containerPhrasing(e,{before:s,after:i,...o.current()})),s+=o.move(i+i),a(),s},emphasis:(e,t,n,r)=>{let i=e.marker||n.options.emphasis||`*`,a=n.enter(`emphasis`),o=n.createTracker(r),s=o.move(i);return s+=o.move(n.containerPhrasing(e,{before:s,after:i,...o.current()})),s+=o.move(i),a(),s}},Yu=D({},`editorView`),Xu=D({},`editorState`),Zu=D([],`initTimer`),Qu=D({},`editor`),$u=D([],`inputRules`),ed=D([],`prosePlugins`),td=D([],`remarkPlugins`),nd=D([],`nodeView`),rd=D([],`markView`),id=D(ga().use(ar).use(Hi),`remark`),ad=D({handlers:Ju,encode:[]},`remarkStringifyOptions`),od=k(`ConfigReady`);function sd(e){let t=t=>(t.record(od),async()=>(await e(t),t.done(od),()=>{t.clearTimer(od)}));return qu(t,{displayName:`Config`}),t}var cd=k(`InitReady`);function ld(e){let t=t=>(t.inject(Qu,e).inject(ed,[]).inject(td,[]).inject($u,[]).inject(nd,[]).inject(rd,[]).inject(ad,{handlers:Ju,encode:[]}).inject(id,ga().use(ar).use(Hi)).inject(Zu,[od]).record(cd),async()=>{await t.waitTimers(Zu);let e=t.get(ad);return t.set(id,ga().use(ar).use(Hi,e)),t.done(cd),()=>{t.remove(Qu).remove(ed).remove(td).remove($u).remove(nd).remove(rd).remove(ad).remove(id).remove(Zu).clearTimer(cd)}});return qu(t,{displayName:`Init`}),t}var Q=k(`SchemaReady`),ud=D([],`schemaTimer`),dd=D({},`schema`),fd=D([],`nodes`),pd=D([],`marks`);function md(e){return{...e,parseDOM:e.parseDOM?.map(t=>({priority:e.priority,...t}))}}var hd=e=>(e.inject(dd,{}).inject(fd,[]).inject(pd,[]).inject(ud,[cd]).record(Q),async()=>{await e.waitTimers(ud);let t=e.get(id),n=e.get(td).reduce((e,t)=>e.use(t.plugin,t.options),t);e.set(id,n);let r=new u.k({nodes:Object.fromEntries(e.get(fd).map(([e,t])=>[e,md(t)])),marks:Object.fromEntries(e.get(pd).map(([e,t])=>[e,md(t)]))});return e.set(dd,r),e.done(Q),()=>{e.remove(dd).remove(fd).remove(pd).remove(ud).clearTimer(Q)}});qu(hd,{displayName:`Schema`});var gd=class{constructor(){this.#e=new ne,this.#t=null,this.setCtx=e=>{this.#t=e},this.chain=()=>{if(this.#t==null)throw T();let e=this.#t,t=[],n=this.get.bind(this),r={run:()=>{let n=d.r(...t),r=e.get(Yu);return n(r.state,r.dispatch,r)},inline:e=>(t.push(e),r),pipe:i.bind(this)};function i(e,i){let a=n(e);return t.push(a(i)),r}return r}}#e;#t;get ctx(){return this.#t}create(e,t){let n=e.create(this.#e.sliceMap);return n.set(t),n}get(e){return this.#e.get(e).get()}remove(e){return this.#e.remove(e)}call(e,t){if(this.#t==null)throw T();let n=this.get(e)(t),r=this.#t.get(Yu);return n(r.state,r.dispatch,r)}inline(e){if(this.#t==null)throw T();let t=this.#t.get(Yu);return e(t.state,t.dispatch,t)}};function _d(e=`cmdKey`){return D((()=>()=>!1),e)}var vd=D(new gd,`commands`),yd=D([Q],`commandsTimer`),bd=k(`CommandsReady`),xd=e=>{let t=new gd;return t.setCtx(e),e.inject(vd,t).inject(yd,[Q]).record(bd),async()=>(await e.waitTimers(yd),e.done(bd),()=>{e.remove(vd).remove(yd).clearTimer(bd)})};qu(xd,{displayName:`Commands`});function Sd(e){return e.Backspace=d.r(Oa,d.a,d.u,d.y),e}var Cd=class{constructor(){this.#e=null,this.#t=[],this.setCtx=e=>{this.#e=e},this.add=e=>(this.#t.push(e),()=>{this.#t=this.#t.filter(t=>t!==e)}),this.addObjectKeymap=e=>{let t=[];return Object.entries(e).forEach(([e,n])=>{if(typeof n==`function`){let r={key:e,onRun:()=>n};this.#t.push(r),t.push(()=>{this.#t=this.#t.filter(e=>e!==r)})}else this.#t.push(n),t.push(()=>{this.#t=this.#t.filter(e=>e!==n)})}),()=>{t.forEach(e=>e())}},this.addBaseKeymap=()=>{let e=Sd(d.n);return this.addObjectKeymap(e)},this.build=()=>{let e={};return this.#t.forEach(t=>{e[t.key]=[...e[t.key]||[],t]}),Object.fromEntries(Object.entries(e).map(([e,t])=>{let n=t.sort((e,t)=>(t.priority??50)-(e.priority??50));return[e,(e,t,r)=>{let i=this.#e;if(i==null)throw y();return d.r(...n.map(e=>e.onRun(i)))(e,t,r)}]}))}}#e;#t;get ctx(){return this.#e}},wd=D(new Cd,`keymap`),Td=D([Q],`keymapTimer`),Ed=k(`KeymapReady`),Dd=e=>{let t=new Cd;return t.setCtx(e),e.inject(wd,t).inject(Td,[Q]).record(Ed),async()=>(await e.waitTimers(Td),e.done(Ed),()=>{e.remove(wd).remove(Td).clearTimer(Ed)})},Od=k(`ParserReady`),kd=(()=>{throw y()}),Ad=D(kd,`parser`),jd=D([],`parserTimer`),Md=e=>(e.inject(Ad,kd).inject(jd,[Q]).record(Od),async()=>{await e.waitTimers(jd);let t=e.get(id),n=e.get(dd);return e.set(Ad,Ao.create(n,t)),e.done(Od),()=>{e.remove(Ad).remove(jd).clearTimer(Od)}});qu(Md,{displayName:`Parser`});var Nd=k(`SerializerReady`),Pd=D([],`serializerTimer`),Fd=(()=>{throw y()}),Id=D(Fd,`serializer`),Ld=e=>(e.inject(Id,Fd).inject(Pd,[Q]).record(Nd),async()=>{await e.waitTimers(Pd);let t=e.get(id),n=e.get(dd);return e.set(Id,No.create(n,t)),e.done(Nd),()=>{e.remove(Id).remove(Pd).clearTimer(Nd)}});qu(Ld,{displayName:`Serializer`});var Rd=D(``,`defaultValue`),zd=D(e=>e,`stateOptions`),Bd=D([],`editorStateTimer`),Vd=k(`EditorStateReady`);function Hd(e,t,n){if(typeof e==`string`)return t(e);if(e.type===`html`)return u.S.fromSchema(n).parse(e.dom);if(e.type===`json`)return u.E.fromJSON(n,e.value);throw g(e)}var Ud=new u.a(`MILKDOWN_STATE_TRACKER`),Wd=e=>(e.inject(Rd,``).inject(Xu,{}).inject(zd,e=>e).inject(Bd,[Od,Nd,bd,Ed]).record(Vd),async()=>{await e.waitTimers(Bd);let t=e.get(dd),n=e.get(Ad),r=e.get($u),i=e.get(zd),a=e.get(ed),o=Hd(e.get(Rd),n,t),s=e.get(wd),c=s.addBaseKeymap(),l=[...a,new u.i({key:Ud,state:{init:()=>{},apply:(t,n,r,i)=>{e.set(Xu,i)}}}),Ua({rules:r}),To(s.build())];e.set(ed,l);let d=i({schema:t,doc:o,plugins:l}),f=u.n.create(d);return e.set(Xu,f),e.done(Vd),()=>{c(),e.remove(Rd).remove(Xu).remove(zd).remove(Bd).clearTimer(Vd)}});qu(Wd,{displayName:`EditorState`});var Gd=D([],`pasteRule`),Kd=D([Q],`pasteRuleTimer`),qd=k(`PasteRuleReady`),Jd=e=>(e.inject(Gd,[]).inject(Kd,[Q]).record(qd),async()=>(await e.waitTimers(Kd),e.done(qd),()=>{e.remove(Gd).remove(Kd).clearTimer(qd)}));qu(Jd,{displayName:`PasteRule`});var Yd=k(`EditorViewReady`),Xd=D([],`editorViewTimer`),Zd=D({},`editorViewOptions`),Qd=D(null,`root`),$d=D(null,`rootDOM`),ef=D({},`rootAttrs`);function tf(e,t){let n=document.createElement(`div`);n.className=`milkdown`,e.appendChild(n),t.set($d,n);let r=t.get(ef);return Object.entries(r).forEach(([e,t])=>n.setAttribute(e,t)),n}function nf(e){e.classList.add(`editor`),e.setAttribute(`role`,`textbox`)}var rf=new u.a(`MILKDOWN_VIEW_CLEAR`),af=e=>(e.inject(Qd,document.body).inject(Yu,{}).inject(Zd,{}).inject($d,null).inject(ef,{}).inject(Xd,[Vd,qd]).record(Yd),async()=>{await e.wait(cd);let t=e.get(Qd)||document.body,n=typeof t==`string`?document.querySelector(t):t;e.update(ed,t=>[new u.i({key:rf,view:t=>{let r=n?tf(n,e):void 0;return(()=>{if(r&&n){let e=t.dom;n.replaceChild(r,e),r.appendChild(e)}})(),{destroy:()=>{r?.parentNode&&r?.parentNode.replaceChild(t.dom,r),r?.remove()}}}}),...t]),await e.waitTimers(Xd);let r=e.get(Xu),i=e.get(Zd),a=new Ru(n,{state:r,nodeViews:Object.fromEntries(e.get(nd)),markViews:Object.fromEntries(e.get(rd)),transformPasted:(t,n,r)=>(e.get(Gd).sort((e,t)=>(t.priority??50)-(e.priority??50)).map(e=>e.run).forEach(e=>{t=e(t,n,r)}),t),...i});return nf(a.dom),e.set(Yu,a),e.done(Yd),()=>{a?.destroy(),e.remove(Qd).remove(Yu).remove(Zd).remove($d).remove(ef).remove(Xd).clearTimer(Yd)}});qu(af,{displayName:`EditorView`});var $=function(e){return e.Idle=`Idle`,e.OnCreate=`OnCreate`,e.Created=`Created`,e.OnDestroy=`OnDestroy`,e.Destroyed=`Destroyed`,e}({}),of=class e{constructor(){this.#e=!1,this.#t=$.Idle,this.#n=[],this.#r=()=>void 0,this.#i=new ne,this.#a=new oe,this.#o=new Map,this.#s=new Map,this.#c=new ae(this.#i,this.#a),this.#l=()=>{let e=sd(async e=>{await Promise.all(this.#n.map(t=>Promise.resolve(t(e))))}),t=[hd,Md,Ld,xd,Dd,Jd,Wd,af,ld(this),e];this.#u(t,this.#s)},this.#u=(e,t)=>{e.forEach(e=>{let n=this.#c.produce(this.#e?e.meta:void 0),r=e(n);t.set(e,{ctx:n,handler:r,cleanup:void 0})})},this.#d=(e,t=!1)=>Promise.all([e].flat().map(async e=>{let n=this.#o.get(e)?.cleanup;return t?this.#o.delete(e):this.#o.set(e,{ctx:void 0,handler:void 0,cleanup:void 0}),typeof n==`function`?n():n})),this.#f=async()=>{await Promise.all([...this.#s.entries()].map(async([e,{cleanup:t}])=>typeof t==`function`?t():t)),this.#s.clear()},this.#p=e=>{this.#t=e,this.#r(e)},this.#m=e=>[...e.entries()].map(async([t,n])=>{let{ctx:r,handler:i}=n;if(!i)return;let a=await i();e.set(t,{ctx:r,handler:i,cleanup:a})}),this.enableInspector=(e=!0)=>(this.#e=e,this),this.onStatusChange=e=>(this.#r=e,this),this.config=e=>(this.#n.push(e),this),this.removeConfig=e=>(this.#n=this.#n.filter(t=>t!==e),this),this.use=e=>{let t=[e].flat();return t.flat().forEach(e=>{this.#o.set(e,{ctx:void 0,handler:void 0,cleanup:void 0})}),this.#t===$.Created&&this.#u(t,this.#o),this},this.remove=async e=>this.#t===$.OnCreate?(console.warn(`[Milkdown]: You are trying to remove plugins when the editor is creating, this is not recommended, please check your code.`),new Promise(t=>{setTimeout(()=>{t(this.remove(e))},50)})):(await this.#d([e].flat(),!0),this),this.create=async()=>this.#t===$.OnCreate?this:(this.#t===$.Created&&await this.destroy(),this.#p($.OnCreate),this.#l(),this.#u([...this.#o.keys()],this.#o),await Promise.all([this.#m(this.#s),this.#m(this.#o)].flat()),this.#p($.Created),this),this.destroy=async(e=!1)=>this.#t===$.Destroyed||this.#t===$.OnDestroy?this:this.#t===$.OnCreate?new Promise(t=>{setTimeout(()=>{t(this.destroy(e))},50)}):(e&&(this.#n=[]),this.#p($.OnDestroy),await this.#d([...this.#o.keys()],e),await this.#f(),this.#p($.Destroyed),this),this.action=e=>e(this.#c),this.inspect=()=>this.#e?[...this.#s.values(),...this.#o.values()].map(({ctx:e})=>e?.inspector?.read()).filter(e=>!!e):(console.warn("[Milkdown]: You are trying to collect inspection when inspector is disabled, please enable inspector by `editor.enableInspector()` first."),[])}static make(){return new e}#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m;get ctx(){return this.#c}get status(){return this.#t}};Object.defineProperty(exports,"$",{enumerable:!0,get:function(){return _r}}),Object.defineProperty(exports,"A",{enumerable:!0,get:function(){return Id}}),Object.defineProperty(exports,"B",{enumerable:!0,get:function(){return lo}}),Object.defineProperty(exports,"C",{enumerable:!0,get:function(){return Gd}}),Object.defineProperty(exports,"D",{enumerable:!0,get:function(){return ad}}),Object.defineProperty(exports,"E",{enumerable:!0,get:function(){return td}}),Object.defineProperty(exports,"F",{enumerable:!0,get:function(){return oo}}),Object.defineProperty(exports,"G",{enumerable:!0,get:function(){return Aa}}),Object.defineProperty(exports,"H",{enumerable:!0,get:function(){return Wa}}),Object.defineProperty(exports,"I",{enumerable:!0,get:function(){return po}}),Object.defineProperty(exports,"J",{enumerable:!0,get:function(){return yi}}),Object.defineProperty(exports,"K",{enumerable:!0,get:function(){return ka}}),Object.defineProperty(exports,"L",{enumerable:!0,get:function(){return uo}}),Object.defineProperty(exports,"M",{enumerable:!0,get:function(){return au}}),Object.defineProperty(exports,"N",{enumerable:!0,get:function(){return Eo}}),Object.defineProperty(exports,"O",{enumerable:!0,get:function(){return dd}}),Object.defineProperty(exports,"P",{enumerable:!0,get:function(){return no}}),Object.defineProperty(exports,"Q",{enumerable:!0,get:function(){return kr}}),Object.defineProperty(exports,"R",{enumerable:!0,get:function(){return co}}),Object.defineProperty(exports,"S",{enumerable:!0,get:function(){return Ad}}),Object.defineProperty(exports,"St",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"T",{enumerable:!0,get:function(){return ed}}),Object.defineProperty(exports,"U",{enumerable:!0,get:function(){return to}}),Object.defineProperty(exports,"V",{enumerable:!0,get:function(){return io}}),Object.defineProperty(exports,"W",{enumerable:!0,get:function(){return Ea}}),Object.defineProperty(exports,"X",{enumerable:!0,get:function(){return Rr}}),Object.defineProperty(exports,"Y",{enumerable:!0,get:function(){return Vr}}),Object.defineProperty(exports,"Z",{enumerable:!0,get:function(){return zr}}),Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return Ku}}),Object.defineProperty(exports,"_t",{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(exports,"at",{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return nd}}),Object.defineProperty(exports,"bt",{enumerable:!0,get:function(){return te}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return yd}}),Object.defineProperty(exports,"ct",{enumerable:!0,get:function(){return F}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return Bd}}),Object.defineProperty(exports,"dt",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(exports,"et",{enumerable:!0,get:function(){return We}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return Yu}}),Object.defineProperty(exports,"ft",{enumerable:!0,get:function(){return xe}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return wd}}),Object.defineProperty(exports,"gt",{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return $u}}),Object.defineProperty(exports,"ht",{enumerable:!0,get:function(){return he}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return Ed}}),Object.defineProperty(exports,"it",{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,"j",{enumerable:!0,get:function(){return nu}}),Object.defineProperty(exports,"k",{enumerable:!0,get:function(){return ud}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return _d}}),Object.defineProperty(exports,"lt",{enumerable:!0,get:function(){return I}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return Xd}}),Object.defineProperty(exports,"mt",{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return Yd}}),Object.defineProperty(exports,"nt",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return Nd}}),Object.defineProperty(exports,"ot",{enumerable:!0,get:function(){return Ce}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return Zd}}),Object.defineProperty(exports,"pt",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(exports,"q",{enumerable:!0,get:function(){return Gi}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return cd}}),Object.defineProperty(exports,"rt",{enumerable:!0,get:function(){return L}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return vd}}),Object.defineProperty(exports,"st",{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return bd}}),Object.defineProperty(exports,"tt",{enumerable:!0,get:function(){return Le}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return zd}}),Object.defineProperty(exports,"ut",{enumerable:!0,get:function(){return De}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return rd}}),Object.defineProperty(exports,"vt",{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,"w",{enumerable:!0,get:function(){return Kd}}),Object.defineProperty(exports,"x",{enumerable:!0,get:function(){return fd}}),Object.defineProperty(exports,"xt",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return pd}}),Object.defineProperty(exports,"yt",{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,"z",{enumerable:!0,get:function(){return fo}});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./lib-
|
|
1
|
+
const e=require("./lib-BLTQkf4j.cjs"),t=require("./dist-DQnWlYyo.cjs"),n=require("./commands-CM7IuhpT.cjs"),r=require("./lib-CqJFV3ME.cjs"),i=require("./lib-CHQUpMrL.cjs"),a=require("./dist-D7LE16E1.cjs");var o=typeof navigator<`u`?navigator:null,s=o&&o.userAgent||``,c=/Edge\/(\d+)/.exec(s),l=/MSIE \d/.exec(s),u=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(s),d=!(l||u||c)&&!!o&&/Apple Computer/.test(o.vendor),f=new t.a(`safari-ime-span`),p=!1,m={key:f,props:{decorations:h,handleDOMEvents:{compositionstart:()=>{p=!0},compositionend:()=>{p=!1}}}};function h(t){let{$from:n,$to:r,to:i}=t.selection;if(p&&n.sameParent(r)){let n=e.j.widget(i,ee,{ignoreSelection:!0,key:`safari-ime-span`});return e.M.create(t.doc,[n])}}function ee(e){let t=e.dom.ownerDocument.createElement(`span`);return t.className=`ProseMirror-safari-ime-span`,t}var g=new t.i(d?m:{key:f});function _(e,t){let n=String(e);if(typeof t!=`string`)throw TypeError(`Expected character`);let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function v(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function te(t,n,r){let i=e.Q((r||{}).ignore||[]),a=y(n),o=-1;for(;++o<a.length;)e.Z(t,`text`,s);function s(e,t){let n=-1,r;for(;++n<t.length;){let e=t[n],a=r?r.children:void 0;if(i(e,a?a.indexOf(e):void 0,r))return;r=e}if(r)return c(e,t)}function c(e,t){let n=t[t.length-1],r=a[o][0],i=a[o][1],s=0,c=n.children.indexOf(e),l=!1,u=[];r.lastIndex=0;let d=r.exec(e.value);for(;d;){let n=d.index,a={index:d.index,input:d.input,stack:[...t,e]},o=i(...d,a);if(typeof o==`string`&&(o=o.length>0?{type:`text`,value:o}:void 0),o===!1?r.lastIndex=n+1:(s!==n&&u.push({type:`text`,value:e.value.slice(s,n)}),Array.isArray(o)?u.push(...o):o&&u.push(o),s=n+d[0].length,l=!0),!r.global)break;d=r.exec(e.value)}return l?(s<e.value.length&&u.push({type:`text`,value:e.value.slice(s)}),n.children.splice(c,1,...u)):u=[e],c+u.length}}function y(e){let t=[];if(!Array.isArray(e))throw TypeError(`Expected find and replace tuple or list of tuples`);let n=!e[0]||Array.isArray(e[0])?e:[e],r=-1;for(;++r<n.length;){let e=n[r];t.push([b(e[0]),ne(e[1])])}return t}function b(e){return typeof e==`string`?new RegExp(v(e),`g`):e}function ne(e){return typeof e==`function`?e:function(){return e}}var x=`phrasing`,S=[`autolink`,`link`,`image`,`label`];function re(){return{transforms:[de],enter:{literalAutolink:ae,literalAutolinkEmail:oe,literalAutolinkHttp:oe,literalAutolinkWww:oe},exit:{literalAutolink:ue,literalAutolinkEmail:le,literalAutolinkHttp:se,literalAutolinkWww:ce}}}function ie(){return{unsafe:[{character:`@`,before:`[+\\-.\\w]`,after:`[\\-.\\w]`,inConstruct:x,notInConstruct:S},{character:`.`,before:`[Ww]`,after:`[\\-.\\w]`,inConstruct:x,notInConstruct:S},{character:`:`,before:`[ps]`,after:`\\/`,inConstruct:x,notInConstruct:S}]}}function ae(e){this.enter({type:`link`,title:null,url:``,children:[]},e)}function oe(e){this.config.enter.autolinkProtocol.call(this,e)}function se(e){this.config.exit.autolinkProtocol.call(this,e)}function ce(e){this.config.exit.data.call(this,e);let t=this.stack[this.stack.length-1];t.type,t.url=`http://`+this.sliceSerialize(e)}function le(e){this.config.exit.autolinkEmail.call(this,e)}function ue(e){this.exit(e)}function de(e){te(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,fe],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,pe]],{ignore:[`link`,`linkReference`]})}function fe(e,t,n,r,i){let a=``;if(!ge(i)||(/^w/i.test(t)&&(n=t+n,t=``,a=`http://`),!me(n)))return!1;let o=he(n+r);if(!o[0])return!1;let s={type:`link`,title:null,url:a+t+o[0],children:[{type:`text`,value:t+o[0]}]};return o[1]?[s,{type:`text`,value:o[1]}]:s}function pe(e,t,n,r){return!ge(r,!0)||/[-\d_]$/.test(n)?!1:{type:`link`,title:null,url:`mailto:`+t+`@`+n,children:[{type:`text`,value:t+`@`+n}]}}function me(e){let t=e.split(`.`);return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function he(e){let t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(`)`),i=_(e,`(`),a=_(e,`)`);for(;r!==-1&&i>a;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(`)`),a++;return[e,n]}function ge(t,n){let r=t.input.charCodeAt(t.index-1);return(t.index===0||e.dt(r)||e.ut(r))&&(!n||r!==47)}Ee.peek=Te;function _e(){this.buffer()}function ve(e){this.enter({type:`footnoteReference`,identifier:``,label:``},e)}function ye(){this.buffer()}function be(e){this.enter({type:`footnoteDefinition`,identifier:``,label:``,children:[]},e)}function xe(t){let n=this.resume(),r=this.stack[this.stack.length-1];r.type,r.identifier=e.ft(this.sliceSerialize(t)).toLowerCase(),r.label=n}function Se(e){this.exit(e)}function Ce(t){let n=this.resume(),r=this.stack[this.stack.length-1];r.type,r.identifier=e.ft(this.sliceSerialize(t)).toLowerCase(),r.label=n}function we(e){this.exit(e)}function Te(){return`[`}function Ee(e,t,n,r){let i=n.createTracker(r),a=i.move(`[^`),o=n.enter(`footnoteReference`),s=n.enter(`reference`);return a+=i.move(n.safe(n.associationId(e),{after:`]`,before:a})),s(),o(),a+=i.move(`]`),a}function De(){return{enter:{gfmFootnoteCallString:_e,gfmFootnoteCall:ve,gfmFootnoteDefinitionLabelString:ye,gfmFootnoteDefinition:be},exit:{gfmFootnoteCallString:xe,gfmFootnoteCall:Se,gfmFootnoteDefinitionLabelString:Ce,gfmFootnoteDefinition:we}}}function Oe(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:Ee},unsafe:[{character:`[`,inConstruct:[`label`,`phrasing`,`reference`]}]};function n(e,n,r,i){let a=r.createTracker(i),o=a.move(`[^`),s=r.enter(`footnoteDefinition`),c=r.enter(`label`);return o+=a.move(r.safe(r.associationId(e),{before:o,after:`]`})),c(),o+=a.move(`]:`),e.children&&e.children.length>0&&(a.shift(4),o+=a.move((t?`
|
|
2
2
|
`:` `)+r.indentLines(r.containerFlow(e,a.current()),t?Ae:ke))),s(),o}}function ke(e,t,n){return t===0?e:Ae(e,t,n)}function Ae(e,t,n){return(n?``:` `)+e}var je=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`];Ie.peek=Le;function Me(){return{canContainEols:[`delete`],enter:{strikethrough:Pe},exit:{strikethrough:Fe}}}function Ne(){return{unsafe:[{character:`~`,inConstruct:`phrasing`,notInConstruct:je}],handlers:{delete:Ie}}}function Pe(e){this.enter({type:`delete`,children:[]},e)}function Fe(e){this.exit(e)}function Ie(e,t,n,r){let i=n.createTracker(r),a=n.enter(`strikethrough`),o=i.move(`~~`);return o+=n.containerPhrasing(e,{...i.current(),before:o,after:`~`}),o+=i.move(`~~`),a(),o}function Le(){return`~`}function Re(e){return e.length}function ze(e,t){let n=t||{},r=(n.align||[]).concat(),i=n.stringLength||Re,a=[],o=[],s=[],c=[],l=0,u=-1;for(;++u<e.length;){let t=[],r=[],a=-1;for(e[u].length>l&&(l=e[u].length);++a<e[u].length;){let o=Be(e[u][a]);if(n.alignDelimiters!==!1){let e=i(o);r[a]=e,(c[a]===void 0||e>c[a])&&(c[a]=e)}t.push(o)}o[u]=t,s[u]=r}let d=-1;if(typeof r==`object`&&`length`in r)for(;++d<l;)a[d]=Ve(r[d]);else{let e=Ve(r);for(;++d<l;)a[d]=e}d=-1;let f=[],p=[];for(;++d<l;){let e=a[d],t=``,r=``;e===99?(t=`:`,r=`:`):e===108?t=`:`:e===114&&(r=`:`);let i=n.alignDelimiters===!1?1:Math.max(1,c[d]-t.length-r.length),o=t+`-`.repeat(i)+r;n.alignDelimiters!==!1&&(i=t.length+i+r.length,i>c[d]&&(c[d]=i),p[d]=i),f[d]=o}o.splice(1,0,f),s.splice(1,0,p),u=-1;let m=[];for(;++u<o.length;){let e=o[u],t=s[u];d=-1;let r=[];for(;++d<l;){let i=e[d]||``,o=``,s=``;if(n.alignDelimiters!==!1){let e=c[d]-(t[d]||0),n=a[d];n===114?o=` `.repeat(e):n===99?e%2?(o=` `.repeat(e/2+.5),s=` `.repeat(e/2-.5)):(o=` `.repeat(e/2),s=o):s=` `.repeat(e)}n.delimiterStart!==!1&&!d&&r.push(`|`),n.padding!==!1&&!(n.alignDelimiters===!1&&i===``)&&(n.delimiterStart!==!1||d)&&r.push(` `),n.alignDelimiters!==!1&&r.push(o),r.push(i),n.alignDelimiters!==!1&&r.push(s),n.padding!==!1&&r.push(` `),(n.delimiterEnd!==!1||d!==l-1)&&r.push(`|`)}m.push(n.delimiterEnd===!1?r.join(``).replace(/ +$/,``):r.join(``))}return m.join(`
|
|
3
3
|
`)}function Be(e){return e==null?``:String(e)}function Ve(e){let t=typeof e==`string`?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function He(){return{enter:{table:Ue,tableData:Ke,tableHeader:Ke,tableRow:Ge},exit:{codeText:qe,table:We,tableData:C,tableHeader:C,tableRow:C}}}function Ue(e){let t=e._align;this.enter({type:`table`,align:t.map(function(e){return e===`none`?null:e}),children:[]},e),this.data.inTable=!0}function We(e){this.exit(e),this.data.inTable=void 0}function Ge(e){this.enter({type:`tableRow`,children:[]},e)}function C(e){this.exit(e)}function Ke(e){this.enter({type:`tableCell`,children:[]},e)}function qe(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,Je));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function Je(e,t){return t===`|`?t:e}function Ye(t){let n=t||{},r=n.tableCellPadding,i=n.tablePipeAlign,a=n.stringLength,o=r?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
|
|
4
4
|
`,inConstruct:`tableCell`},{atBreak:!0,character:`|`,after:`[ :-]`},{character:`|`,inConstruct:`tableCell`},{atBreak:!0,character:`:`,after:`-`},{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{inlineCode:p,table:s,tableCell:l,tableRow:c}};function s(e,t,n,r){return u(d(e,n,r),e.align)}function c(e,t,n,r){let i=u([f(e,n,r)]);return i.slice(0,i.indexOf(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require("./lib-
|
|
1
|
+
const e=require("./lib-BLTQkf4j.cjs"),t=require("./dist-DQnWlYyo.cjs"),n=require("./debounce-C_TNzOFT.cjs");var r=class{constructor(){this.beforeMountedListeners=[],this.mountedListeners=[],this.updatedListeners=[],this.selectionUpdatedListeners=[],this.markdownUpdatedListeners=[],this.blurListeners=[],this.focusListeners=[],this.destroyListeners=[],this.beforeMount=e=>(this.beforeMountedListeners.push(e),this),this.mounted=e=>(this.mountedListeners.push(e),this),this.updated=e=>(this.updatedListeners.push(e),this)}get listeners(){return{beforeMount:this.beforeMountedListeners,mounted:this.mountedListeners,updated:this.updatedListeners,markdownUpdated:this.markdownUpdatedListeners,blur:this.blurListeners,focus:this.focusListeners,destroy:this.destroyListeners,selectionUpdated:this.selectionUpdatedListeners}}markdownUpdated(e){return this.markdownUpdatedListeners.push(e),this}blur(e){return this.blurListeners.push(e),this}focus(e){return this.focusListeners.push(e),this}destroy(e){return this.destroyListeners.push(e),this}selectionUpdated(e){return this.selectionUpdatedListeners.push(e),this}},i=e.gt(new r,`listener`),a=new t.a(`MILKDOWN_LISTENER`),o=o=>(o.inject(i,new r),async()=>{await o.wait(e.r);let{listeners:r}=o.get(i);r.beforeMount.forEach(e=>e(o)),await o.wait(e.o);let s=o.get(e.A),c=null,l=null,u=null,d=null,f=n.t(()=>{if(!d)return;let{doc:e}=d;if(r.updated.length>0&&c&&!c.eq(e)&&r.updated.forEach(t=>{t(o,e,c)}),r.markdownUpdated.length>0&&c&&!c.eq(e)){let t=s(e);r.markdownUpdated.forEach(e=>{e(o,t,l)}),l=t}c=e,d=null},200),p=new t.i({key:a,view:()=>({destroy:()=>{r.destroy.forEach(e=>e(o))}}),props:{handleDOMEvents:{focus:()=>(r.focus.forEach(e=>e(o)),!1),blur:()=>(r.blur.forEach(e=>e(o)),!1)}},state:{init:(e,t)=>{c=t.doc,l=s(t.doc)},apply:e=>{let t=e.selection;(!u&&t||u&&!t.eq(u))&&(r.selectionUpdated.forEach(e=>{e(o,t,u)}),u=t),!(!(e.docChanged||e.storedMarksSet)||e.getMeta(`addToHistory`)===!1)&&(d=e,f())}}});o.update(e.T,e=>e.concat(p)),await o.wait(e.n),r.mounted.forEach(e=>e(o))});o.meta={package:`@milkdown/plugin-listener`,displayName:`Listener`},exports.ListenerManager=r,exports.key=a,exports.listener=o,exports.listenerCtx=i;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require("./dist-DQnWlYyo.cjs"),t=require("./lib-
|
|
1
|
+
const e=require("./dist-DQnWlYyo.cjs"),t=require("./lib-CqJFV3ME.cjs");function n(t,n){let{doc:r,selection:i}=t;if(!r||!i||!(i instanceof e.c||i instanceof e.t))return t;let{to:a}=i,o=n.type===`space`?Array(n.size).fill(` `).join(``):` `;return t.insertText(o,a)}var r=t.n({type:`space`,size:2},`indentConfig`);r.meta={package:`@milkdown/plugin-indent`,displayName:`Ctx<indentConfig>`};var i=t.f(e=>({Tab:(t,i)=>{let a=e.get(r.key),{tr:o}=t,s=n(o,a);return s.docChanged?(i?.(s),!0):!1}}));i.meta={package:`@milkdown/plugin-indent`,displayName:`Shortcut<indent>`};var a=[r,i];exports.indent=a,exports.indentConfig=r,exports.indentPlugin=i;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { A as e, B as t, O as n, S as r, V as i, p as a } from "./lib-
|
|
1
|
+
import { A as e, B as t, O as n, S as r, V as i, p as a } from "./lib-CYWwNE4c.js";
|
|
2
2
|
import { C as o, S as s, a as c, c as l, i as u } from "./dist-CLTsQjPD.js";
|
|
3
|
-
import { u as d } from "./lib-
|
|
3
|
+
import { u as d } from "./lib-BIxqp3lX.js";
|
|
4
4
|
//#region node_modules/.pnpm/@milkdown+plugin-clipboard@7.21.1/node_modules/@milkdown/plugin-clipboard/lib/index.js
|
|
5
5
|
function f(e) {
|
|
6
6
|
if (!e) return !1;
|