1||l==0||g.content.size)&&(d=m,u.push(yd(g.mark(f.allowedMarks(g.marks)),c==1?l:0,c==a.childCount?p:-1)))}let h=c==a.childCount;h||(p=-1),this.placed=ci(this.placed,n,T.from(u)),this.frontier[n].match=d,h&&p<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let g=0,m=a;g1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:i}=this.frontier[n],o=n=0;a--){let{match:l,type:c}=this.frontier[a],u=ya(e,a,c,l,!0);if(!u||u.childCount)continue e}return{depth:n,fit:s,move:o?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=ci(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let i=e.node(r),o=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,o)}return e}openFrontierNode(e,n=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=ci(this.placed,this.depth,T.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(T.empty,!0);n.childCount&&(this.placed=ci(this.placed,this.frontier.length,n))}};function li(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(li(t.firstChild.content,e-1,n)))}function ci(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(ci(t.lastChild.content,e-1,n)))}function ba(t,e){for(let n=0;n1&&(r=r.replaceChild(0,yd(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(T.empty,!0)))),t.copy(r)}function ya(t,e,n,r,i){let o=t.node(e),s=i?t.indexAfter(e):t.index(e);if(s==o.childCount&&!n.compatibleContent(o.type))return null;let a=r.fillBefore(o.content,!0,s);return a&&!By(n,o.content,s)?a:null}function By(t,e,n){for(let r=n;r0;f--,p--){let h=i.node(f).type.spec;if(h.defining||h.definingAsContext||h.isolating)break;s.indexOf(f)>-1?a=f:i.before(f)==p&&s.splice(1,0,-f)}let l=s.indexOf(a),c=[],u=r.openStart;for(let f=r.content,p=0;;p++){let h=f.firstChild;if(c.push(h),p==r.openStart)break;f=h.content}for(let f=u-1;f>=0;f--){let p=c[f],h=Fy(p.type);if(h&&!p.sameMarkup(i.node(Math.abs(a)-1)))u=f;else if(h||!p.type.isTextblock)break}for(let f=r.openStart;f>=0;f--){let p=(f+u+1)%(r.openStart+1),h=c[p];if(h)for(let g=0;g=0&&(t.replace(e,n,r),!(t.steps.length>d));f--){let p=s[f];p<0||(e=i.before(p),n=o.after(p))}}function Ed(t,e,n,r,i){if(er){let o=i.contentMatchAt(0),s=o.fillBefore(t).append(t);t=s.append(o.matchFragment(s).fillBefore(T.empty,!0))}return t}function zy(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=Py(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new D(T.from(r),0,0))}function $y(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),o=wd(r,i);for(let s=0;s0&&(l||r.node(a-1).canReplace(r.index(a-1),i.indexAfter(a-1))))return t.delete(r.before(a),i.after(a))}for(let s=1;s<=r.depth&&s<=i.depth;s++)if(e-r.start(s)==r.depth-s&&n>r.end(s)&&i.end(s)-n!=i.depth-s)return t.delete(r.before(s),n);t.delete(e,n)}function wd(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let i=r;i>=0;i--){let o=t.start(i);if(oe.pos+(e.depth-i)||t.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(o==e.start(i)||i==t.depth&&i==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==o-1)&&n.push(i)}return n}var co=class t extends ze{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return Ge.fail("No node at attribute step's position");let r=Object.create(null);for(let o in n.attrs)r[o]=n.attrs[o];r[this.attr]=this.value;let i=n.type.create(r,null,n.marks);return Ge.fromReplace(e,this.pos,this.pos+1,new D(T.from(i),0,n.isLeaf?0:1))}getMap(){return nn.empty}invert(e){return new t(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new t(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new t(n.pos,n.attr,n.value)}};ze.jsonID("attr",co);var uo=class t extends ze{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let i in e.attrs)n[i]=e.attrs[i];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return Ge.ok(r)}getMap(){return nn.empty}invert(e){return new t(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new t(n.attr,n.value)}};ze.jsonID("docAttr",uo);var kr=class extends Error{};kr=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};kr.prototype=Object.create(Error.prototype);kr.prototype.constructor=kr;kr.prototype.name="TransformError";var mn=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new di}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new kr(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=D.empty){let i=po(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new D(T.from(r),0,0))}delete(e,n){return this.replace(e,n,D.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return Hy(this,e,n,r),this}replaceRangeWith(e,n,r){return zy(this,e,n,r),this}deleteRange(e,n){return $y(this,e,n),this}lift(e,n){return Ty(this,e,n),this}join(e,n=1){return Ly(this,e,n),this}wrap(e,n){return Oy(this,e,n),this}setBlockType(e,n=e,r,i=null){return Ay(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return Iy(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new co(e,n,r)),this}setDocAttribute(e,n){return this.step(new uo(e,n)),this}addNodeMark(e,n){return this.step(new pi(e,n)),this}removeNodeMark(e,n){if(!(n instanceof me)){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n=n.isInSet(r.marks),!n)return this}return this.step(new hi(e,n)),this}split(e,n=1,r){return Dy(this,e,n,r),this}addMark(e,n,r){return xy(this,e,n,r),this}removeMark(e,n,r){return ky(this,e,n,r),this}clearIncompatible(e,n,r){return My(this,e,n,r),this}};var Sa=Object.create(null),V=class{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new gi(e.min(n),e.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let n=0;n=0;o--){let s=n<0?Tr(e.node(0),e.node(o),e.before(o+1),e.index(o),n,r):Tr(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,n,r);if(s)return s}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new wt(e.node(0))}static atStart(e){return Tr(e,e,0,0,1)||new wt(e)}static atEnd(e){return Tr(e,e,e.content.size,e.childCount,-1)||new wt(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Sa[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Sa)throw new RangeError("Duplicate use of selection JSON ID "+e);return Sa[e]=n,n.prototype.jsonID=e,n}getBookmark(){return K.between(this.$anchor,this.$head).getBookmark()}};V.prototype.visible=!0;var gi=class{constructor(e,n){this.$from=e,this.$to=n}},vd=!1;function Sd(t){!vd&&!t.parent.inlineContent&&(vd=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}var K=class t extends V{constructor(e,n=e){Sd(e),Sd(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return V.near(r);let i=e.resolve(n.map(this.anchor));return new t(i.parent.inlineContent?i:r,r)}replace(e,n=D.empty){if(super.replace(e,n),n==D.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof t&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new mo(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new t(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let i=e.resolve(n);return new this(i,r==n?i:e.resolve(r))}static between(e,n,r){let i=e.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let o=V.findFrom(n,r,!0)||V.findFrom(n,-r,!0);if(o)n=o.$head;else return V.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(V.findFrom(e,-r,!0)||V.findFrom(e,r,!0)).$anchor,e.pos0?0:1);i>0?s=0;s+=i){let a=e.child(s);if(a.isAtom){if(!o&&Y.isSelectable(a))return Y.create(t,n-(i<0?a.nodeSize:0))}else{let l=Tr(t,a,n+i,i<0?a.childCount:0,i,o);if(l)return l}n+=a.nodeSize*i}return null}function xd(t,e,n){let r=t.steps.length-1;if(r{s==null&&(s=u)}),t.setSelection(V.near(t.doc.resolve(s),n))}var kd=1,ho=2,Md=4,Ma=class extends mn{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor0}setStoredMarks(e){return this.storedMarks=e,this.updated|=ho,this}ensureMarks(e){return me.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&ho)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~ho,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||me.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let i=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),r=r??n,!e)return this.deleteRange(n,r);let o=this.storedMarks;if(!o){let s=this.doc.resolve(n);o=r==n?s.marks():s.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,i.text(e,o)),this.selection.empty||this.setSelection(V.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=Md,this}get scrolledIntoView(){return(this.updated&Md)>0}};function Nd(t,e){return!e||!t?t:t.bind(e)}var Kn=class{constructor(e,n,r){this.name=e,this.init=Nd(n.init,r),this.apply=Nd(n.apply,r)}},Ky=[new Kn("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Kn("selection",{init(t,e){return t.selection||V.atStart(e.doc)},apply(t){return t.selection}}),new Kn("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Kn("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})],mi=class{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Ky.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Kn(r.key,r.spec.state,r))})}},go=class t{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;rr.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],o=i.spec.state;o&&o.toJSON&&(n[r]=o.toJSON.call(i,this[i.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new mi(e.schema,e.plugins),o=new t(i);return i.fields.forEach(s=>{if(s.name=="doc")o.doc=It.fromJSON(e.schema,n.doc);else if(s.name=="selection")o.selection=V.fromJSON(o.doc,n.selection);else if(s.name=="storedMarks")n.storedMarks&&(o.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let a in r){let l=r[a],c=l.spec.state;if(l.key==s.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(n,a)){o[s.name]=c.fromJSON.call(l,e,n[a],o);return}}o[s.name]=s.init(e,o)}}),o}};function Td(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=Td(i,e,{})),n[r]=i}return n}var ge=class{constructor(e){this.spec=e,this.props={},e.props&&Td(e.props,this,this.props),this.key=e.key?e.key.key:_d("plugin")}getState(e){return e[this.key]}},xa=Object.create(null);function _d(t){return t in xa?t+"$"+ ++xa[t]:(xa[t]=0,t+"$")}var ve=class{constructor(e="key"){this.key=_d(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}};var at=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},wi=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e},Cd=null,sn=function(t,e,n){let r=Cd||(Cd=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},Xn=function(t,e,n,r){return n&&(Od(t,e,n,r,-1)||Od(t,e,n,r,1))},Wy=/^(img|br|input|textarea|hr)$/i;function Od(t,e,n,r,i){for(;;){if(t==n&&e==r)return!0;if(e==(i<0?0:Wt(t))){let o=t.parentNode;if(!o||o.nodeType!=1||Ya(t)||Wy.test(t.nodeName)||t.contentEditable=="false")return!1;e=at(t)+(i<0?0:1),t=o}else if(t.nodeType==1){if(t=t.childNodes[e+(i<0?-1:0)],t.contentEditable=="false")return!1;e=i<0?Wt(t):0}else return!1}}function Wt(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Vy(t,e,n){for(let r=e==0,i=e==Wt(t);r||i;){if(t==n)return!0;let o=at(t);if(t=t.parentNode,!t)return!1;r=r&&o==0,i=i&&o==Wt(t)}}function Ya(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}var No=function(t){return t.focusNode&&Xn(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Wn(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function Gy(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function qy(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:r.offset}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:r.startOffset}}}var Vt=typeof navigator<"u"?navigator:null,Ad=typeof document<"u"?document:null,wn=Vt&&Vt.userAgent||"",Oa=/Edge\/(\d+)/.exec(wn),lf=/MSIE \d/.exec(wn),Aa=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(wn),pt=!!(lf||Aa||Oa),yn=lf?document.documentMode:Aa?+Aa[1]:Oa?+Oa[1]:0,Pt=!pt&&/gecko\/(\d+)/i.test(wn);Pt&&+(/Firefox\/(\d+)/.exec(wn)||[0,0])[1];var Ra=!pt&&/Chrome\/(\d+)/.exec(wn),Qe=!!Ra,jy=Ra?+Ra[1]:0,lt=!pt&&!!Vt&&/Apple Computer/.test(Vt.vendor),Rr=lt&&(/Mobile\/\w+/.test(wn)||!!Vt&&Vt.maxTouchPoints>2),xt=Rr||(Vt?/Mac/.test(Vt.platform):!1),Yy=Vt?/Win/.test(Vt.platform):!1,Lt=/Android \d/.test(wn),xi=!!Ad&&"webkitFontSmoothing"in Ad.documentElement.style,Jy=xi?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Xy(t){return{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function on(t,e){return typeof t=="number"?t:t[e]}function Zy(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function Rd(t,e,n){let r=t.someProp("scrollThreshold")||0,i=t.someProp("scrollMargin")||5,o=t.dom.ownerDocument;for(let s=n||t.dom;s;s=wi(s)){if(s.nodeType!=1)continue;let a=s,l=a==o.body,c=l?Xy(o):Zy(a),u=0,d=0;if(e.topc.bottom-on(r,"bottom")&&(d=e.bottom-e.top>c.bottom-c.top?e.top+on(i,"top")-c.top:e.bottom-c.bottom+on(i,"bottom")),e.leftc.right-on(r,"right")&&(u=e.right-c.right+on(i,"right")),u||d)if(l)o.defaultView.scrollBy(u,d);else{let f=a.scrollLeft,p=a.scrollTop;d&&(a.scrollTop+=d),u&&(a.scrollLeft+=u);let h=a.scrollLeft-f,g=a.scrollTop-p;e={left:e.left-h,top:e.top-g,right:e.right-h,bottom:e.bottom-g}}if(l||/^(fixed|sticky)$/.test(getComputedStyle(s).position))break}}function Qy(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,i;for(let o=(e.left+e.right)/2,s=n+1;s=n-20){r=a,i=l.top;break}}return{refDOM:r,refTop:i,stack:cf(t.dom)}}function cf(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=wi(r));return e}function eE({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;uf(n,r==0?0:r-e)}function uf(t,e){for(let n=0;n=a){s=Math.max(h.bottom,s),a=Math.min(h.top,a);let g=h.left>e.left?h.left-e.left:h.right=(h.left+h.right)/2?1:0));continue}}else h.top>e.top&&!l&&h.left<=e.left&&h.right>=e.left&&(l=u,c={left:Math.max(h.left,Math.min(h.right,e.left)),top:h.top});!n&&(e.left>=h.right&&e.top>=h.top||e.left>=h.left&&e.top>=h.bottom)&&(o=d+1)}}return!n&&l&&(n=l,i=c,r=0),n&&n.nodeType==3?nE(n,i):!n||r&&n.nodeType==1?{node:t,offset:o}:df(n,i)}function nE(t,e){let n=t.nodeValue.length,r=document.createRange();for(let i=0;i=(o.left+o.right)/2?1:0)}}return{node:t,offset:0}}function Ja(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function rE(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left(s.left+s.right)/2?1:-1}return t.docView.posFromDOM(r,i,o)}function oE(t,e,n,r){let i=-1;for(let o=e,s=!1;o!=t.dom;){let a=t.docView.nearestDesc(o,!0);if(!a)return null;if(a.dom.nodeType==1&&(a.node.isBlock&&a.parent&&!s||!a.contentDOM)){let l=a.dom.getBoundingClientRect();if(a.node.isBlock&&a.parent&&!s&&(s=!0,l.left>r.left||l.top>r.top?i=a.posBefore:(l.right-1?i:t.docView.posFromDOM(e,n,-1)}function ff(t,e,n){let r=t.childNodes.length;if(r&&n.tope.top&&i++}let c;xi&&i&&r.nodeType==1&&(c=r.childNodes[i-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&i--,r==t.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?a=t.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(a=oE(t,r,i,e))}a==null&&(a=iE(t,s,e));let l=t.docView.nearestDesc(s,!0);return{pos:a,inside:l?l.posAtStart-l.border:-1}}function Id(t){return t.top=0&&i==r.nodeValue.length?(l--,u=1):n<0?l--:c++,bi(gn(sn(r,l,c),u),u<0)}if(!t.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&i&&(n<0||i==Wt(r))){let l=r.childNodes[i-1];if(l.nodeType==1)return Na(l.getBoundingClientRect(),!1)}if(o==null&&i=0)}if(o==null&&i&&(n<0||i==Wt(r))){let l=r.childNodes[i-1],c=l.nodeType==3?sn(l,Wt(l)-(s?0:1)):l.nodeType==1&&(l.nodeName!="BR"||!l.nextSibling)?l:null;if(c)return bi(gn(c,1),!1)}if(o==null&&i=0)}function bi(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function Na(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function hf(t,e,n){let r=t.state,i=t.root.activeElement;r!=e&&t.updateState(e),i!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),i!=t.dom&&i&&i.focus()}}function lE(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return hf(t,e,()=>{let{node:o}=t.docView.domFromPos(i.pos,n=="up"?-1:1);for(;;){let a=t.docView.nearestDesc(o,!0);if(!a)break;if(a.node.isBlock){o=a.contentDOM||a.dom;break}o=a.dom.parentNode}let s=pf(t,i.pos,1);for(let a=o.firstChild;a;a=a.nextSibling){let l;if(a.nodeType==1)l=a.getClientRects();else if(a.nodeType==3)l=sn(a,0,a.nodeValue.length).getClientRects();else continue;for(let c=0;cu.top+1&&(n=="up"?s.top-u.top>(u.bottom-s.top)*2:u.bottom-s.bottom>(s.bottom-u.top)*2))return!1}}return!0})}var cE=/[\u0590-\u08ac]/;function uE(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,o=!i,s=i==r.parent.content.size,a=t.domSelection();return!cE.test(r.parent.textContent)||!a.modify?n=="left"||n=="backward"?o:s:hf(t,e,()=>{let{focusNode:l,focusOffset:c,anchorNode:u,anchorOffset:d}=t.domSelectionRange(),f=a.caretBidiLevel;a.modify("move",n,"character");let p=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:h,focusOffset:g}=t.domSelectionRange(),m=h&&!p.contains(h.nodeType==1?h:h.parentNode)||l==h&&c==g;try{a.collapse(u,d),l&&(l!=u||c!=d)&&a.extend&&a.extend(l,c)}catch{}return f!=null&&(a.caretBidiLevel=f),m})}var Dd=null,Ld=null,Pd=!1;function dE(t,e,n){return Dd==e&&Ld==n?Pd:(Dd=e,Ld=n,Pd=n=="up"||n=="down"?lE(t,e,n):uE(t,e,n))}var kt=0,Bd=1,Gn=2,Gt=3,Zn=class{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=kt,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;nat(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!1;break}if(o.previousSibling)break}if(i==null&&n==e.childNodes.length)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!0;break}if(o.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,i=e;i;i=i.parentNode){let o=this.getDesc(i),s;if(o&&(!n||o.node))if(r&&(s=o.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==e))r=!1;else return o}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let i=e;i;i=i.parentNode){let o=this.getDesc(i);if(o)return o.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;ne||s instanceof Eo){i=e-o;break}o=a}if(i)return this.children[r].domFromPos(i-this.children[r].border,n);for(let o;r&&!(o=this.children[r-1]).size&&o instanceof bo&&o.side>=0;r--);if(n<=0){let o,s=!0;for(;o=r?this.children[r-1]:null,!(!o||o.dom.parentNode==this.contentDOM);r--,s=!1);return o&&n&&s&&!o.border&&!o.domAtom?o.domFromPos(o.size,n):{node:this.contentDOM,offset:o?at(o.dom)+1:0}}else{let o,s=!0;for(;o=r=u&&n<=c-l.border&&l.node&&l.contentDOM&&this.contentDOM.contains(l.contentDOM))return l.parseRange(e,n,u);e=s;for(let d=a;d>0;d--){let f=this.children[d-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){i=at(f.dom)+1;break}e-=f.size}i==-1&&(i=0)}if(i>-1&&(c>n||a==this.children.length-1)){n=c;for(let u=a+1;up&&sn){let p=a;a=l,l=p}let f=document.createRange();f.setEnd(l.node,l.offset),f.setStart(a.node,a.offset),c.removeAllRanges(),c.addRange(f)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,i=0;i=r:er){let a=r+o.border,l=s-o.border;if(e>=a&&n<=l){this.dirty=e==r||n==s?Gn:Bd,e==a&&n==l&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=Gt:o.markDirty(e-a,n-a);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?Gn:Gt}r=s}this.dirty=Gn}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Gn:Bd;n.dirty{if(!o)return i;if(o.parent)return o.parent.posBeforeChild(o)})),!n.type.spec.raw){if(s.nodeType!=1){let a=document.createElement("span");a.appendChild(s),s=a}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=n,this.widget=n,o=this}matchesWidget(e){return this.dirty==kt&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}},Ia=class extends Zn{constructor(e,n,r,i){super(e,[],n,null),this.textDOM=r,this.text=i}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}},Ir=class t extends Zn{constructor(e,n,r,i){super(e,[],r,i),this.mark=n}static create(e,n,r,i){let o=i.nodeViews[n.type.name],s=o&&o(n,i,r);return(!s||!s.dom)&&(s=tn.renderSpec(document,n.type.spec.toDOM(n,r))),new t(e,n,s.dom,s.contentDOM||s.dom)}parseRule(){return this.dirty&Gt||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Gt&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=kt){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty0&&(o=Fa(o,0,e,r));for(let a=0;a{if(!l)return s;if(l.parent)return l.parent.posBeforeChild(l)},r,i),u=c&&c.dom,d=c&&c.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:d}=tn.renderSpec(document,n.type.spec.toDOM(n)));!d&&!n.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),n.type.spec.draggable&&(u.draggable=!0));let f=u;return u=bf(u,r,n),c?l=new Da(e,n,r,i,u,d||null,f,c,o,s+1):n.isText?new yo(e,n,r,i,u,f,o):new t(e,n,r,i,u,d||null,f,o,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>T.empty)}return e}matchesNode(e,n,r){return this.dirty==kt&&e.eq(this.node)&&Pa(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,i=n,o=e.composing?this.localCompositionInfo(e,n):null,s=o&&o.pos>-1?o:null,a=o&&o.pos<0,l=new Ba(this,s&&s.node,e);mE(this.node,this.innerDeco,(c,u,d)=>{c.spec.marks?l.syncToMarks(c.spec.marks,r,e):c.type.side>=0&&!d&&l.syncToMarks(u==this.node.childCount?me.none:this.node.child(u).marks,r,e),l.placeWidget(c,e,i)},(c,u,d,f)=>{l.syncToMarks(c.marks,r,e);let p;l.findNodeMatch(c,u,d,f)||a&&e.state.selection.from>i&&e.state.selection.to-1&&l.updateNodeAt(c,u,d,p,e)||l.updateNextNode(c,u,d,e,f,i)||l.addNode(c,u,d,e,i),i+=c.nodeSize}),l.syncToMarks([],r,e),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||this.dirty==Gn)&&(s&&this.protectLocalComposition(e,s),mf(this.contentDOM,this.children,e),Rr&&gE(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof K)||rn+this.node.content.size)return null;let o=e.domSelectionRange(),s=bE(o.focusNode,o.focusOffset);if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let a=s.nodeValue,l=yE(this.node.content,a,r-n,i-n);return l<0?null:{node:s,pos:l,text:a}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:i}){if(this.getDesc(n))return;let o=n;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let s=new Ia(this,o,n,i);e.input.compositionNodes.push(s),this.children=Fa(this.children,r,r+i.length,e,s)}update(e,n,r,i){return this.dirty==Gt||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,i),!0)}updateInner(e,n,r,i){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=kt}updateOuterDeco(e){if(Pa(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=gf(this.dom,this.nodeDOM,La(this.outerDeco,this.node,n),La(e,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable")}get domAtom(){return this.node.isAtom}};function Fd(t,e,n,r,i){bf(r,e,t);let o=new En(void 0,t,e,n,r,r,r,i,0);return o.contentDOM&&o.updateChildren(i,0),o}var yo=class t extends En{constructor(e,n,r,i,o,s,a){super(e,n,r,i,o,null,s,a,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,i){return this.dirty==Gt||this.dirty!=kt&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=kt||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=kt,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let i=this.node.cut(e,n),o=document.createTextNode(i.text);return new t(this.parent,i,this.outerDeco,this.innerDeco,o,o,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=Gt)}get domAtom(){return!1}},Eo=class extends Zn{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==kt&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},Da=class extends En{constructor(e,n,r,i,o,s,a,l,c,u){super(e,n,r,i,o,s,a,c,u),this.spec=l}update(e,n,r,i){if(this.dirty==Gt)return!1;if(this.spec.update){let o=this.spec.update(e,n,r);return o&&this.updateInner(e,n,r,i),o}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,i){this.spec.setSelection?this.spec.setSelection(e,n,r):super.setSelection(e,n,r,i)}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 mf(t,e,n){let r=t.firstChild,i=!1;for(let o=0;o>1,s=Math.min(o,e.length);for(;i-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let l=Ir.create(this.top,e[o],n,r);this.top.children.splice(this.index,0,l),this.top=l,this.changed=!0}this.index=0,o++}}findNodeMatch(e,n,r,i){let o=-1,s;if(i>=this.preMatch.index&&(s=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&s.matchesNode(e,n,r))o=this.top.children.indexOf(s,this.index);else for(let a=this.index,l=Math.min(this.top.children.length,a+5);a0;){let a;for(;;)if(r){let c=n.children[r-1];if(c instanceof Ir)n=c,r=c.children.length;else{a=c,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let l=a.node;if(l){if(l!=t.child(i-1))break;--i,o.set(a,i),s.push(a)}}return{index:i,matched:o,matches:s.reverse()}}function hE(t,e){return t.type.side-e.type.side}function mE(t,e,n,r){let i=e.locals(t),o=0;if(i.length==0){for(let c=0;co;)a.push(i[s++]);let h=o+f.nodeSize;if(f.isText){let m=h;s!m.inline):a.slice();r(f,g,e.forChild(o,f),p),o=h}}function gE(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}function bE(t,e){for(;;){if(t.nodeType==3)return t;if(t.nodeType==1&&e>0){if(t.childNodes.length>e&&t.childNodes[e].nodeType==3)return t.childNodes[e];t=t.childNodes[e-1],e=Wt(t)}else if(t.nodeType==1&&e=n){if(o>=r&&l.slice(r-e.length-a,r-a)==e)return r-e.length;let c=a=0&&c+e.length+a>=n)return a+c;if(n==r&&l.length>=r+e.length-a&&l.slice(r-a,r-a+e.length)==e)return r}}return-1}function Fa(t,e,n,r,i){let o=[];for(let s=0,a=0;s=n||u<=e?o.push(l):(cn&&o.push(l.slice(n-c,l.size,r)))}return o}function Xa(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let i=t.docView.nearestDesc(n.focusNode),o=i&&i.size==0,s=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let a=r.resolve(s),l,c;if(No(n)){for(l=a;i&&!i.node;)i=i.parent;let u=i.node;if(i&&u.isAtom&&Y.isSelectable(u)&&i.parent&&!(u.isInline&&Vy(n.focusNode,n.focusOffset,i.dom))){let d=i.posBefore;c=new Y(s==d?a:r.resolve(d))}}else{let u=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(u<0)return null;l=r.resolve(u)}if(!c){let u=e=="pointer"||t.state.selection.head{(n.anchorNode!=r||n.anchorOffset!=i)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!yf(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function wE(t){let e=t.domSelection(),n=document.createRange(),r=t.cursorWrapper.dom,i=r.nodeName=="IMG";i?n.setEnd(r.parentNode,at(r)+1):n.setEnd(r,0),n.collapse(!1),e.removeAllRanges(),e.addRange(n),!i&&!t.state.selection.visible&&pt&&yn<=11&&(r.disabled=!0,r.disabled=!1)}function Ef(t,e){if(e instanceof Y){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(Kd(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else Kd(t)}function Kd(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Za(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||K.between(e,n,r)}function Wd(t){return t.editable&&!t.hasFocus()?!1:wf(t)}function wf(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function vE(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Xn(e.node,e.offset,n.anchorNode,n.anchorOffset)}function Ha(t,e){let{$anchor:n,$head:r}=t.selection,i=e>0?n.max(r):n.min(r),o=i.parent.inlineContent?i.depth?t.doc.resolve(e>0?i.after():i.before()):null:i;return o&&V.findFrom(o,e)}function Vn(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function Vd(t,e,n){let r=t.state.selection;if(r instanceof K){if(!r.empty||n.indexOf("s")>-1)return!1;if(t.endOfTextblock(e>0?"forward":"backward")){let i=Ha(t.state,e);return i&&i instanceof Y?Vn(t,i):!1}else if(!(xt&&n.indexOf("m")>-1)){let i=r.$head,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,s;if(!o||o.isText)return!1;let a=e<0?i.pos-o.nodeSize:i.pos;return o.isAtom||(s=t.docView.descAt(a))&&!s.contentDOM?Y.isSelectable(o)?Vn(t,new Y(e<0?t.state.doc.resolve(i.pos-o.nodeSize):i)):xi?Vn(t,new K(t.state.doc.resolve(e<0?a:a+o.nodeSize))):!1:!1}}else{if(r instanceof Y&&r.node.isInline)return Vn(t,new K(e>0?r.$to:r.$from));{let i=Ha(t.state,e);return i?Vn(t,i):!1}}}function wo(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Ei(t,e){if(t.contentEditable=="false")return!0;let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function Cr(t,e){return e<0?SE(t):xE(t)}function SE(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,o,s=!1;for(Pt&&n.nodeType==1&&r0){if(n.nodeType!=1)break;{let a=n.childNodes[r-1];if(Ei(a,-1))i=n,o=--r;else if(a.nodeType==3)n=a,r=n.nodeValue.length;else break}}else{if(vf(n))break;{let a=n.previousSibling;for(;a&&Ei(a,-1);)i=n.parentNode,o=at(a),a=a.previousSibling;if(a)n=a,r=wo(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}s?za(t,n,r):i&&za(t,i,o)}function xE(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=wo(n),o,s;for(;;)if(r{t.state==i&&an(t)},50)}function Gd(t,e){let n=t.state.doc.resolve(e);if(!(Qe||Yy)&&n.parent.inlineContent){let i=t.coordsAtPos(e);if(e>n.start()){let o=t.coordsAtPos(e-1),s=(o.top+o.bottom)/2;if(s>i.top&&s1)return o.lefti.top&&s1)return o.left>i.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function qd(t,e,n){let r=t.state.selection;if(r instanceof K&&!r.empty||n.indexOf("s")>-1||xt&&n.indexOf("m")>-1)return!1;let{$from:i,$to:o}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let s=Ha(t.state,e);if(s&&s instanceof Y)return Vn(t,s)}if(!i.parent.inlineContent){let s=e<0?i:o,a=r instanceof wt?V.near(s,e):V.findFrom(s,e);return a?Vn(t,a):!1}return!1}function jd(t,e){if(!(t.state.selection instanceof K))return!0;let{$head:n,$anchor:r,empty:i}=t.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let o=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(o&&!o.isText){let s=t.state.tr;return e<0?s.delete(n.pos-o.nodeSize,n.pos):s.delete(n.pos,n.pos+o.nodeSize),t.dispatch(s),!0}return!1}function Yd(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function NE(t){if(!lt||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Yd(t,r,"true"),setTimeout(()=>Yd(t,r,"false"),20)}return!1}function TE(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function _E(t,e){let n=e.keyCode,r=TE(e);if(n==8||xt&&n==72&&r=="c")return jd(t,-1)||Cr(t,-1);if(n==46&&!e.shiftKey||xt&&n==68&&r=="c")return jd(t,1)||Cr(t,1);if(n==13||n==27)return!0;if(n==37||xt&&n==66&&r=="c"){let i=n==37?Gd(t,t.state.selection.from)=="ltr"?-1:1:-1;return Vd(t,i,r)||Cr(t,i)}else if(n==39||xt&&n==70&&r=="c"){let i=n==39?Gd(t,t.state.selection.from)=="ltr"?1:-1:1;return Vd(t,i,r)||Cr(t,i)}else{if(n==38||xt&&n==80&&r=="c")return qd(t,-1,r)||Cr(t,-1);if(n==40||xt&&n==78&&r=="c")return NE(t)||qd(t,1,r)||Cr(t,1);if(r==(xt?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function Sf(t,e){t.someProp("transformCopied",p=>{e=p(e,t)});let n=[],{content:r,openStart:i,openEnd:o}=e;for(;i>1&&o>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,o--;let p=r.firstChild;n.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),r=p.content}let s=t.someProp("clipboardSerializer")||tn.fromSchema(t.state.schema),a=_f(),l=a.createElement("div");l.appendChild(s.serializeFragment(r,{document:a}));let c=l.firstChild,u,d=0;for(;c&&c.nodeType==1&&(u=Tf[c.nodeName.toLowerCase()]);){for(let p=u.length-1;p>=0;p--){let h=a.createElement(u[p]);for(;l.firstChild;)h.appendChild(l.firstChild);l.appendChild(h),d++}c=l.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${i} ${o}${d?` -${d}`:""} ${JSON.stringify(n)}`);let f=t.someProp("clipboardTextSerializer",p=>p(e,t))||e.content.textBetween(0,e.content.size,`
+
+`);return{dom:l,text:f}}function xf(t,e,n,r,i){let o=i.parent.type.spec.code,s,a;if(!n&&!e)return null;let l=e&&(r||o||!n);if(l){if(t.someProp("transformPastedText",f=>{e=f(e,o||r,t)}),o)return e?new D(T.from(t.state.schema.text(e.replace(/\r\n?/g,`
+`))),0,0):D.empty;let d=t.someProp("clipboardTextParser",f=>f(e,i,r,t));if(d)a=d;else{let f=i.marks(),{schema:p}=t.state,h=tn.fromSchema(p);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(g=>{let m=s.appendChild(document.createElement("p"));g&&m.appendChild(h.serializeNode(p.text(g,f)))})}}else t.someProp("transformPastedHTML",d=>{n=d(n,t)}),s=AE(n),xi&&RE(s);let c=s&&s.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let d=+u[3];d>0;d--){let f=s.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;s=f}if(a||(a=(t.someProp("clipboardParser")||t.someProp("domParser")||$n.fromSchema(t.state.schema)).parseSlice(s,{preserveWhitespace:!!(l||u),context:i,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!CE.test(f.parentNode.nodeName)?{ignore:!0}:null}})),u)a=IE(Jd(a,+u[1],+u[2]),u[4]);else if(a=D.maxOpen(OE(a.content,i),!0),a.openStart||a.openEnd){let d=0,f=0;for(let p=a.content.firstChild;d{a=d(a,t)}),a}var CE=/^(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 OE(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let i=e.node(n).contentMatchAt(e.index(n)),o,s=[];if(t.forEach(a=>{if(!s)return;let l=i.findWrapping(a.type),c;if(!l)return s=null;if(c=s.length&&o.length&&Mf(l,o,a,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=Nf(s[s.length-1],o.length));let u=kf(a,l);s.push(u),i=i.matchType(u.type),o=l}}),s)return T.from(s)}return t}function kf(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,T.from(t));return t}function Mf(t,e,n,r,i){if(i1&&(o=0),i=n&&(a=e<0?s.contentMatchAt(0).fillBefore(a,o<=i).append(a):a.append(s.contentMatchAt(s.childCount).fillBefore(T.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,s.copy(a))}function Jd(t,e,n){return e]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=_f().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&Tf[r[1].toLowerCase()])&&(t=i.map(o=>"<"+o+">").join("")+t+i.map(o=>""+o+">").reverse().join("")),n.innerHTML=t,i)for(let o=0;o=0;a-=2){let l=n.nodes[r[a]];if(!l||l.hasRequiredAttrs())break;i=T.from(l.create(r[a+1],i)),o++,s++}return new D(i,o,s)}var ct={},ut={},DE={touchstart:!0,touchmove:!0},Ua=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastAndroidDelete=0,this.composing=!1,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function LE(t){for(let e in ct){let n=ct[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{BE(t,r)&&!Qa(t,r)&&(t.editable||!(r.type in ut))&&n(t,r)},DE[e]?{passive:!0}:void 0)}lt&&t.dom.addEventListener("input",()=>null),Ka(t)}function bn(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function PE(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function Ka(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>Qa(t,r))})}function Qa(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function BE(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function FE(t,e){!Qa(t,e)&&ct[e.type]&&(t.editable||!(e.type in ut))&&ct[e.type](t,e)}ut.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!Of(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Lt&&Qe&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),Rr&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",i=>i(t,Wn(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||_E(t,n)?n.preventDefault():bn(t,"key")};ut.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};ut.keypress=(t,e)=>{let n=e;if(Of(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||xt&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof K)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(n.charCode);!/[\r\n]/.test(i)&&!t.someProp("handleTextInput",o=>o(t,r.$from.pos,r.$to.pos,i))&&t.dispatch(t.state.tr.insertText(i).scrollIntoView()),n.preventDefault()}};function To(t){return{left:t.clientX,top:t.clientY}}function HE(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function el(t,e,n,r,i){if(r==-1)return!1;let o=t.state.doc.resolve(r);for(let s=o.depth+1;s>0;s--)if(t.someProp(e,a=>s>o.depth?a(t,n,o.nodeAfter,o.before(s),i,!0):a(t,n,o.node(s),o.before(s),i,!1)))return!0;return!1}function Ar(t,e,n){t.focused||t.focus();let r=t.state.tr.setSelection(e);n=="pointer"&&r.setMeta("pointer",!0),t.dispatch(r)}function zE(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&Y.isSelectable(r)?(Ar(t,new Y(n),"pointer"),!0):!1}function $E(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof Y&&(r=n.node);let o=t.state.doc.resolve(e);for(let s=o.depth+1;s>0;s--){let a=s>o.depth?o.nodeAfter:o.node(s);if(Y.isSelectable(a)){r&&n.$from.depth>0&&s>=n.$from.depth&&o.before(n.$from.depth+1)==n.$from.pos?i=o.before(n.$from.depth):i=o.before(s);break}}return i!=null?(Ar(t,Y.create(t.state.doc,i),"pointer"),!0):!1}function UE(t,e,n,r,i){return el(t,"handleClickOn",e,n,r)||t.someProp("handleClick",o=>o(t,e,r))||(i?$E(t,n):zE(t,n))}function KE(t,e,n,r){return el(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function WE(t,e,n,r){return el(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||VE(t,n,r)}function VE(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(Ar(t,K.create(r,0,r.content.size),"pointer"),!0):!1;let i=r.resolve(e);for(let o=i.depth+1;o>0;o--){let s=o>i.depth?i.nodeAfter:i.node(o),a=i.before(o);if(s.inlineContent)Ar(t,K.create(r,a+1,a+1+s.content.size),"pointer");else if(Y.isSelectable(s))Ar(t,Y.create(r,a),"pointer");else continue;return!0}}function tl(t){return vo(t)}var Cf=xt?"metaKey":"ctrlKey";ct.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=tl(t),i=Date.now(),o="singleClick";i-t.input.lastClick.time<500&&HE(n,t.input.lastClick)&&!n[Cf]&&(t.input.lastClick.type=="singleClick"?o="doubleClick":t.input.lastClick.type=="doubleClick"&&(o="tripleClick")),t.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:o};let s=t.posAtCoords(To(n));s&&(o=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new Wa(t,s,n,!!r)):(o=="doubleClick"?KE:WE)(t,s.pos,s.inside,n)?n.preventDefault():bn(t,"pointer"))};var Wa=class{constructor(e,n,r,i){this.view=e,this.pos=n,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[Cf],this.allowDefault=r.shiftKey;let o,s;if(n.inside>-1)o=e.state.doc.nodeAt(n.inside),s=n.inside;else{let u=e.state.doc.resolve(n.pos);o=u.parent,s=u.depth?u.before():0}let a=i?null:r.target,l=a?e.docView.nearestDesc(a,!0):null;this.target=l?l.dom:null;let{selection:c}=e.state;(r.button==0&&o.type.spec.draggable&&o.type.spec.selectable!==!1||c instanceof Y&&c.from<=s&&c.to>s)&&(this.mightDrag={node:o,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Pt&&!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)),bn(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(()=>an(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(To(e))),this.updateAllowDefault(e),this.allowDefault||!n?bn(this.view,"pointer"):UE(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||lt&&this.mightDrag&&!this.mightDrag.node.isAtom||Qe&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(Ar(this.view,V.near(this.view.state.doc.resolve(n.pos)),"pointer"),e.preventDefault()):bn(this.view,"pointer")}move(e){this.updateAllowDefault(e),bn(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)}};ct.touchstart=t=>{t.input.lastTouch=Date.now(),tl(t),bn(t,"pointer")};ct.touchmove=t=>{t.input.lastTouch=Date.now(),bn(t,"pointer")};ct.contextmenu=t=>tl(t);function Of(t,e){return t.composing?!0:lt&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}var GE=Lt?5e3:-1;ut.compositionstart=ut.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$from;if(e.selection.empty&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))t.markCursor=t.state.storedMarks||n.marks(),vo(t,!0),t.markCursor=null;else if(vo(t),Pt&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let i=r.focusNode,o=r.focusOffset;i&&i.nodeType==1&&o!=0;){let s=o<0?i.lastChild:i.childNodes[o-1];if(!s)break;if(s.nodeType==3){t.domSelection().collapse(s,s.nodeValue.length);break}else i=s,o=-1}}t.input.composing=!0}Af(t,GE)};ut.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,Af(t,20))};function Af(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>vo(t),e))}function Rf(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=qE());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function qE(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function vo(t,e=!1){if(!(Lt&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),Rf(t),e||t.docView&&t.docView.dirty){let n=Xa(t);return n&&!n.eq(t.state.selection)?t.dispatch(t.state.tr.setSelection(n)):t.updateState(t.state),!0}return!1}}function jE(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}var Dr=pt&&yn<15||Rr&&Jy<604;ct.copy=ut.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let o=Dr?null:n.clipboardData,s=r.content(),{dom:a,text:l}=Sf(t,s);o?(n.preventDefault(),o.clearData(),o.setData("text/html",a.innerHTML),o.setData("text/plain",l)):jE(t,a),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function YE(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function JE(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?vi(t,r.value,null,i,e):vi(t,r.textContent,r.innerHTML,i,e)},50)}function vi(t,e,n,r,i){let o=xf(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",l=>l(t,i,o||D.empty)))return!0;if(!o)return!1;let s=YE(o),a=s?t.state.tr.replaceSelectionWith(s,r):t.state.tr.replaceSelection(o);return t.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}ut.paste=(t,e)=>{let n=e;if(t.composing&&!Lt)return;let r=Dr?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&vi(t,r.getData("text/plain"),r.getData("text/html"),i,n)?n.preventDefault():JE(t,n)};var Va=class{constructor(e,n){this.slice=e,this.move=n}},If=xt?"altKey":"ctrlKey";ct.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=t.state.selection,o=i.empty?null:t.posAtCoords(To(n));if(!(o&&o.pos>=i.from&&o.pos<=(i instanceof Y?i.to-1:i.to))){if(r&&r.mightDrag)t.dispatch(t.state.tr.setSelection(Y.create(t.state.doc,r.mightDrag.pos)));else if(n.target&&n.target.nodeType==1){let c=t.docView.nearestDesc(n.target,!0);c&&c.node.type.spec.draggable&&c!=t.docView&&t.dispatch(t.state.tr.setSelection(Y.create(t.state.doc,c.posBefore)))}}let s=t.state.selection.content(),{dom:a,text:l}=Sf(t,s);n.dataTransfer.clearData(),n.dataTransfer.setData(Dr?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",Dr||n.dataTransfer.setData("text/plain",l),t.dragging=new Va(s,!n[If])};ct.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};ut.dragover=ut.dragenter=(t,e)=>e.preventDefault();ut.drop=(t,e)=>{let n=e,r=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let i=t.posAtCoords(To(n));if(!i)return;let o=t.state.doc.resolve(i.pos),s=r&&r.slice;s?t.someProp("transformPasted",h=>{s=h(s,t)}):s=xf(t,n.dataTransfer.getData(Dr?"Text":"text/plain"),Dr?null:n.dataTransfer.getData("text/html"),!1,o);let a=!!(r&&!n[If]);if(t.someProp("handleDrop",h=>h(t,n,s||D.empty,a))){n.preventDefault();return}if(!s)return;n.preventDefault();let l=s?fo(t.state.doc,o.pos,s):o.pos;l==null&&(l=o.pos);let c=t.state.tr;a&&c.deleteSelection();let u=c.mapping.map(l),d=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,f=c.doc;if(d?c.replaceRangeWith(u,u,s.content.firstChild):c.replaceRange(u,u,s),c.doc.eq(f))return;let p=c.doc.resolve(u);if(d&&Y.isSelectable(s.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(s.content.firstChild))c.setSelection(new Y(p));else{let h=c.mapping.map(l);c.mapping.maps[c.mapping.maps.length-1].forEach((g,m,y,M)=>h=M),c.setSelection(Za(t,p,c.doc.resolve(h)))}t.focus(),t.dispatch(c.setMeta("uiEvent","drop"))};ct.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&an(t)},20))};ct.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};ct.beforeinput=(t,e)=>{if(Qe&&Lt&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",o=>o(t,Wn(8,"Backspace")))))return;let{$cursor:i}=t.state.selection;i&&i.pos>0&&t.dispatch(t.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let t in ut)ct[t]=ut[t];function Si(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}var So=class t{constructor(e,n){this.toDOM=e,this.spec=n||Yn,this.side=this.spec.side||0}map(e,n,r,i){let{pos:o,deleted:s}=e.mapResult(n.from+i,this.side<0?-1:1);return s?null:new et(o-r,o-r,this)}valid(){return!0}eq(e){return this==e||e instanceof t&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Si(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},jn=class t{constructor(e,n){this.attrs=e,this.spec=n||Yn}map(e,n,r,i){let o=e.map(n.from+i,this.spec.inclusiveStart?-1:1)-r,s=e.map(n.to+i,this.spec.inclusiveEnd?1:-1)-r;return o>=s?null:new et(o,s,this)}valid(e,n){return n.from=e&&(!o||o(a.spec))&&r.push(a.copy(a.from+i,a.to+i))}for(let s=0;se){let a=this.children[s]+1;this.children[s+2].findInner(e-a,n-a,r,i+a,o)}}map(e,n,r){return this==Ze||e.maps.length==0?this:this.mapInner(e,n,0,0,r||Yn)}mapInner(e,n,r,i,o){let s;for(let a=0;a{let c=l+r,u;if(u=Lf(n,a,c)){for(i||(i=this.children.slice());oa&&d.to=e){this.children[a]==e&&(r=this.children[a+2]);break}let o=e+1,s=o+n.content.size;for(let a=0;ao&&l.type instanceof jn){let c=Math.max(o,l.from)-o,u=Math.min(s,l.to)-o;ci.map(e,n,Yn));return t.from(r)}forChild(e,n){if(n.isLeaf)return Ce.empty;let r=[];for(let i=0;in instanceof Ce)?e:e.reduce((n,r)=>n.concat(r instanceof Ce?r:r.members),[]))}}};function XE(t,e,n,r,i,o,s){let a=t.slice();for(let c=0,u=o;c{let m=g-h-(p-f);for(let y=0;yM+u-d)continue;let x=a[y]+u-d;p>=x?a[y+1]=f<=x?-2:-1:h>=i&&m&&(a[y]+=m,a[y+1]+=m)}d+=m}),u=n.maps[c].map(u,-1)}let l=!1;for(let c=0;c=r.content.size){l=!0;continue}let f=n.map(t[c+1]+o,-1),p=f-i,{index:h,offset:g}=r.content.findIndex(d),m=r.maybeChild(h);if(m&&g==d&&g+m.nodeSize==p){let y=a[c+2].mapInner(n,m,u+1,t[c]+o+1,s);y!=Ze?(a[c]=d,a[c+1]=p,a[c+2]=y):(a[c+1]=-2,l=!0)}else l=!0}if(l){let c=ZE(a,t,e,n,i,o,s),u=ko(c,r,0,s);e=u.local;for(let d=0;dn&&s.to{let c=Lf(t,a,l+n);if(c){o=!0;let u=ko(c,a,n+l+1,r);u!=Ze&&i.push(l,l+a.nodeSize,u)}});let s=Df(o?Pf(t):t,-n).sort(Jn);for(let a=0;a0;)e++;t.splice(e,0,n)}function _a(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=Ze&&e.push(r)}),t.cursorWrapper&&e.push(Ce.create(t.state.doc,[t.cursorWrapper.deco])),xo.from(e)}var QE={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},e0=pt&&yn<=11,qa=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}},ja=class{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new qa,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;ii.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),e0&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,QE)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let n=0;nthis.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(Wd(this.view)){if(this.suppressingSelectionUpdates)return an(this.view);if(pt&&yn<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Xn(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let o=e.focusNode;o;o=wi(o))n.add(o);for(let o=e.anchorNode;o;o=wi(o))if(n.has(o)){r=o;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&Wd(e)&&!this.ignoreSelectionChange(r),o=-1,s=-1,a=!1,l=[];if(e.editable)for(let u=0;u1){let u=l.filter(d=>d.nodeName=="BR");if(u.length==2){let d=u[0],f=u[1];d.parentNode&&d.parentNode.parentNode==f.parentNode?f.remove():d.remove()}}let c=null;o<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)-1||i)&&(o>-1&&(e.docView.markDirty(o,s),t0(e)),this.handleDOMChange(o,s,a,l),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||an(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;ui;m--){let y=r.childNodes[m-1],M=y.pmViewDesc;if(y.nodeName=="BR"&&!M){o=m;break}if(!M||M.size)break}let d=t.state.doc,f=t.someProp("domParser")||$n.fromSchema(t.state.schema),p=d.resolve(s),h=null,g=f.parse(r,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:o,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:i0,context:p});if(c&&c[0].pos!=null){let m=c[0].pos,y=c[1]&&c[1].pos;y==null&&(y=m),h={anchor:m+s,head:y+s}}return{doc:g,sel:h,from:s,to:a}}function i0(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(lt&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}else if(t.parentNode.lastChild==t||lt&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}var o0=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function s0(t,e,n,r,i){let o=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let O=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,J=Xa(t,O);if(J&&!t.state.selection.eq(J)){if(Qe&&Lt&&t.input.lastKeyCode===13&&Date.now()-100ie(t,Wn(13,"Enter"))))return;let ne=t.state.tr.setSelection(J);O=="pointer"?ne.setMeta("pointer",!0):O=="key"&&ne.scrollIntoView(),o&&ne.setMeta("composition",o),t.dispatch(ne)}return}let s=t.state.doc.resolve(e),a=s.sharedDepth(n);e=s.before(a+1),n=t.state.doc.resolve(n).after(a+1);let l=t.state.selection,c=r0(t,e,n),u=t.state.doc,d=u.slice(c.from,c.to),f,p;t.input.lastKeyCode===8&&Date.now()-100Date.now()-225||Lt)&&i.some(O=>O.nodeType==1&&!o0.test(O.nodeName))&&(!h||h.endA>=h.endB)&&t.someProp("handleKeyDown",O=>O(t,Wn(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!h)if(r&&l instanceof K&&!l.empty&&l.$head.sameParent(l.$anchor)&&!t.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))h={start:l.from,endA:l.to,endB:l.to};else{if(c.sel){let O=tf(t,t.state.doc,c.sel);if(O&&!O.eq(t.state.selection)){let J=t.state.tr.setSelection(O);o&&J.setMeta("composition",o),t.dispatch(J)}}return}if(Qe&&t.cursorWrapper&&c.sel&&c.sel.anchor==t.cursorWrapper.deco.from&&c.sel.head==c.sel.anchor){let O=h.endB-h.start;c.sel={anchor:c.sel.anchor+O,head:c.sel.anchor+O}}t.input.domChangeCount++,t.state.selection.fromt.state.selection.from&&h.start<=t.state.selection.from+2&&t.state.selection.from>=c.from?h.start=t.state.selection.from:h.endA=t.state.selection.to-2&&t.state.selection.to<=c.to&&(h.endB+=t.state.selection.to-h.endA,h.endA=t.state.selection.to)),pt&&yn<=11&&h.endB==h.start+1&&h.endA==h.start&&h.start>c.from&&c.doc.textBetween(h.start-c.from-1,h.start-c.from+1)==" \xA0"&&(h.start--,h.endA--,h.endB--);let g=c.doc.resolveNoCache(h.start-c.from),m=c.doc.resolveNoCache(h.endB-c.from),y=u.resolve(h.start),M=g.sameParent(m)&&g.parent.inlineContent&&y.end()>=h.endA,x;if((Rr&&t.input.lastIOSEnter>Date.now()-225&&(!M||i.some(O=>O.nodeName=="DIV"||O.nodeName=="P"))||!M&&g.posO(t,Wn(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>h.start&&l0(u,h.start,h.endA,g,m)&&t.someProp("handleKeyDown",O=>O(t,Wn(8,"Backspace")))){Lt&&Qe&&t.domObserver.suppressSelectionUpdates();return}Qe&&Lt&&h.endB==h.start&&(t.input.lastAndroidDelete=Date.now()),Lt&&!M&&g.start()!=m.start()&&m.parentOffset==0&&g.depth==m.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==h.endA&&(h.endB-=2,m=c.doc.resolveNoCache(h.endB-c.from),setTimeout(()=>{t.someProp("handleKeyDown",function(O){return O(t,Wn(13,"Enter"))})},20));let b=h.start,_=h.endA,w,I,U;if(M){if(g.pos==m.pos)pt&&yn<=11&&g.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>an(t),20)),w=t.state.tr.delete(b,_),I=u.resolve(h.start).marksAcross(u.resolve(h.endA));else if(h.endA==h.endB&&(U=a0(g.parent.content.cut(g.parentOffset,m.parentOffset),y.parent.content.cut(y.parentOffset,h.endA-y.start()))))w=t.state.tr,U.type=="add"?w.addMark(b,_,U.mark):w.removeMark(b,_,U.mark);else if(g.parent.child(g.index()).isText&&g.index()==m.index()-(m.textOffset?0:1)){let O=g.parent.textBetween(g.parentOffset,m.parentOffset);if(t.someProp("handleTextInput",J=>J(t,b,_,O)))return;w=t.state.tr.insertText(O,b,_)}}if(w||(w=t.state.tr.replace(b,_,c.doc.slice(h.start-c.from,h.endB-c.from))),c.sel){let O=tf(t,w.doc,c.sel);O&&!(Qe&&Lt&&t.composing&&O.empty&&(h.start!=h.endB||t.input.lastAndroidDeletee.content.size?null:Za(t,e.resolve(n.anchor),e.resolve(n.head))}function a0(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,i=n,o=r,s,a,l;for(let u=0;uu.mark(a.addToSet(u.marks));else if(i.length==0&&o.length==1)a=o[0],s="remove",l=u=>u.mark(a.removeFromSet(u.marks));else return null;let c=[];for(let u=0;un||Ca(s,!0,!1)0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,i++,e=!1;if(n){let o=t.node(r).maybeChild(t.indexAfter(r));for(;o&&!o.isLeaf;)o=o.firstChild,i++}return i}function c0(t,e,n,r,i){let o=t.findDiffStart(e,n);if(o==null)return null;let{a:s,b:a}=t.findDiffEnd(e,n+t.size,n+e.size);if(i=="end"){let l=Math.max(0,o-Math.min(s,a));r-=s+l-o}if(s=s?o-r:0;o-=l,a=o+(a-s),s=o}else if(a=a?o-r:0;o-=l,s=o+(s-a),a=o}return{start:o,endA:s,endB:a}}var Mo=class{constructor(e,n){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new Ua,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(af),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=of(this),rf(this),this.nodeViews=sf(this),this.docView=Fd(this.state.doc,nf(this),_a(this),this.dom,this),this.domObserver=new ja(this,(r,i,o,s)=>s0(this,r,i,o,s)),this.domObserver.start(),LE(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Ka(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(af),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){let r=this.state,i=!1,o=!1;e.storedMarks&&this.composing&&(Rf(this),o=!0),this.state=e;let s=r.plugins!=e.plugins||this._props.plugins!=n.plugins;if(s||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let f=sf(this);d0(f,this.nodeViews)&&(this.nodeViews=f,i=!0)}(s||n.handleDOMEvents!=this._props.handleDOMEvents)&&Ka(this),this.editable=of(this),rf(this);let a=_a(this),l=nf(this),c=r.plugins!=e.plugins&&!r.doc.eq(e.doc)?"reset":e.scrollToSelection>r.scrollToSelection?"to selection":"preserve",u=i||!this.docView.matchesNode(e.doc,l,a);(u||!e.selection.eq(r.selection))&&(o=!0);let d=c=="preserve"&&o&&this.dom.style.overflowAnchor==null&&Qy(this);if(o){this.domObserver.stop();let f=u&&(pt||Qe)&&!this.composing&&!r.selection.empty&&!e.selection.empty&&u0(r.selection,e.selection);if(u){let p=Qe?this.trackWrites=this.domSelectionRange().focusNode:null;(i||!this.docView.update(e.doc,l,a,this))&&(this.docView.updateOuterDeco([]),this.docView.destroy(),this.docView=Fd(e.doc,l,a,this.dom,this)),p&&!this.trackWrites&&(f=!0)}f||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&vE(this))?an(this,f):(Ef(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(r),c=="reset"?this.dom.scrollTop=0:c=="to selection"?this.scrollToSelection():d&&eE(d)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof Y){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&Rd(this,n.getBoundingClientRect(),e)}else Rd(this,this.coordsAtPos(this.state.selection.head,1),e)}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;nn.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return sE(this,e)}coordsAtPos(e,n=1){return pf(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let i=this.docView.posFromDOM(e,n,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,n){return dE(this,n||this.state,e)}pasteHTML(e,n){return vi(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return vi(this,e,null,!0,n||new ClipboardEvent("paste"))}destroy(){this.docView&&(PE(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],_a(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null)}get isDestroyed(){return this.docView==null}dispatchEvent(e){return FE(this,e)}dispatch(e){let n=this._props.dispatchTransaction;n?n.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){return lt&&this.root.nodeType===11&&Gy(this.dom.ownerDocument)==this.dom?n0(this):this.domSelection()}domSelection(){return this.root.getSelection()}};function nf(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let r in n)r=="class"?e.class+=" "+n[r]:r=="style"?e.style=(e.style?e.style+";":"")+n[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(n[r]))}),e.translate||(e.translate="no"),[et.node(0,t.state.doc.content.size,e)]}function rf(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:et.widget(t.state.selection.head,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function of(t){return!t.someProp("editable",e=>e(t.state)===!1)}function u0(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}function sf(t){let e=Object.create(null);function n(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function d0(t,e){let n=0,r=0;for(let i in t){if(t[i]!=e[i])return!0;n++}for(let i in e)r++;return n!=r}function af(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var ln={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Co={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},f0=typeof navigator<"u"&&/Mac/.test(navigator.platform),p0=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(De=0;De<10;De++)ln[48+De]=ln[96+De]=String(De);var De;for(De=1;De<=24;De++)ln[De+111]="F"+De;var De;for(De=65;De<=90;De++)ln[De]=String.fromCharCode(De+32),Co[De]=String.fromCharCode(De);var De;for(_o in ln)Co.hasOwnProperty(_o)||(Co[_o]=ln[_o]);var _o;function Bf(t){var e=f0&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||p0&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Co:ln)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}var h0=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function m0(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,i,o,s;for(let a=0;a127)&&(o=ln[r.keyCode])&&o!=i){let a=e[rl(o,r)];if(a&&a(n.state,n.dispatch,n))return!0}}return!1}}var Oo=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function b0(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}var ol=(t,e,n)=>{let r=b0(t,n);if(!r)return!1;let i=zf(r);if(!i){let s=r.blockRange(),a=s&&rn(s);return a==null?!1:(e&&e(t.tr.lift(s,a).scrollIntoView()),!0)}let o=i.nodeBefore;if(!o.type.spec.isolating&&Gf(t,i,e))return!0;if(r.parent.content.size==0&&(Lr(o,"end")||Y.isSelectable(o))){let s=po(t.doc,r.before(),r.after(),D.empty);if(s&&s.slice.size{let{$head:r,empty:i}=t.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;o=zf(r)}let s=o&&o.nodeBefore;return!s||!Y.isSelectable(s)?!1:(e&&e(t.tr.setSelection(Y.create(t.doc,o.pos-s.nodeSize)).scrollIntoView()),!0)};function zf(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function y0(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset{let r=y0(t,n);if(!r)return!1;let i=$f(r);if(!i)return!1;let o=i.nodeAfter;if(Gf(t,i,e))return!0;if(r.parent.content.size==0&&(Lr(o,"start")||Y.isSelectable(o))){let s=po(t.doc,r.before(),r.after(),D.empty);if(s&&s.slice.size{let{$head:r,empty:i}=t.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset=0;e--){let n=t.node(e);if(t.index(e)+1{let n=t.selection,r=n instanceof Y,i;if(r){if(n.node.isTextblock||!Dt(t.doc,n.from))return!1;i=n.from}else if(i=Nr(t.doc,n.from,-1),i==null)return!1;if(e){let o=t.tr.join(i);r&&o.setSelection(Y.create(o.doc,i-t.doc.resolve(i).nodeBefore.nodeSize)),e(o.scrollIntoView())}return!0},Kf=(t,e)=>{let n=t.selection,r;if(n instanceof Y){if(n.node.isTextblock||!Dt(t.doc,n.to))return!1;r=n.to}else if(r=Nr(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},Wf=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),o=i&&rn(i);return o==null?!1:(e&&e(t.tr.lift(i,o).scrollIntoView()),!0)},cl=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
+`).scrollIntoView()),!0)};function ul(t){for(let e=0;e{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),o=n.indexAfter(-1),s=ul(i.contentMatchAt(o));if(!s||!i.canReplaceWith(o,o,s))return!1;if(e){let a=n.after(),l=t.tr.replaceWith(a,a,s.createAndFill());l.setSelection(V.near(l.doc.resolve(a),1)),e(l.scrollIntoView())}return!0},fl=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof wt||r.parent.inlineContent||i.parent.inlineContent)return!1;let o=ul(i.parent.contentMatchAt(i.indexAfter()));if(!o||!o.isTextblock)return!1;if(e){let s=(!r.parentOffset&&i.index(){let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let o=n.before();if(St(t.doc,o))return e&&e(t.tr.split(o).scrollIntoView()),!0}let r=n.blockRange(),i=r&&rn(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function E0(t){return(e,n)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof Y&&e.selection.node.isBlock)return!r.parentOffset||!St(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.parent.isBlock)return!1;if(n){let o=i.parentOffset==i.parent.content.size,s=e.tr;(e.selection instanceof K||e.selection instanceof wt)&&s.deleteSelection();let a=r.depth==0?null:ul(r.node(-1).contentMatchAt(r.indexAfter(-1))),l=t&&t(i.parent,o),c=l?[l]:o&&a?[{type:a}]:void 0,u=St(s.doc,s.mapping.map(r.pos),1,c);if(!c&&!u&&St(s.doc,s.mapping.map(r.pos),1,a?[{type:a}]:void 0)&&(a&&(c=[{type:a}]),u=!0),u&&(s.split(s.mapping.map(r.pos),1,c),!o&&!r.parentOffset&&r.parent.type!=a)){let d=s.mapping.map(r.before()),f=s.doc.resolve(d);a&&r.node(-1).canReplaceWith(f.index(),f.index()+1,a)&&s.setNodeMarkup(s.mapping.map(r.before()),a)}n(s.scrollIntoView())}return!0}}var w0=E0();var Vf=(t,e)=>{let{$from:n,to:r}=t.selection,i,o=n.sharedDepth(r);return o==0?!1:(i=n.before(o),e&&e(t.tr.setSelection(Y.create(t.doc,i))),!0)},v0=(t,e)=>(e&&e(t.tr.setSelection(new wt(t.doc))),!0);function S0(t,e,n){let r=e.nodeBefore,i=e.nodeAfter,o=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(o-1,o)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(o,o+1)||!(i.isTextblock||Dt(t.doc,e.pos))?!1:(n&&n(t.tr.clearIncompatible(e.pos,r.type,r.contentMatchAt(r.childCount)).join(e.pos).scrollIntoView()),!0)}function Gf(t,e,n){let r=e.nodeBefore,i=e.nodeAfter,o,s;if(r.type.spec.isolating||i.type.spec.isolating)return!1;if(S0(t,e,n))return!0;let a=e.parent.canReplace(e.index(),e.index()+1);if(a&&(o=(s=r.contentMatchAt(r.childCount)).findWrapping(i.type))&&s.matchType(o[0]||i.type).validEnd){if(n){let d=e.pos+i.nodeSize,f=T.empty;for(let g=o.length-1;g>=0;g--)f=T.from(o[g].create(null,f));f=T.from(r.copy(f));let p=t.tr.step(new Ie(e.pos-1,d,e.pos,d,new D(f,1,0),o.length,!0)),h=d+2*o.length;Dt(p.doc,h)&&p.join(h),n(p.scrollIntoView())}return!0}let l=V.findFrom(e,1),c=l&&l.$from.blockRange(l.$to),u=c&&rn(c);if(u!=null&&u>=e.depth)return n&&n(t.tr.lift(c,u).scrollIntoView()),!0;if(a&&Lr(i,"start",!0)&&Lr(r,"end")){let d=r,f=[];for(;f.push(d),!d.isTextblock;)d=d.lastChild;let p=i,h=1;for(;!p.isTextblock;p=p.firstChild)h++;if(d.canReplace(d.childCount,d.childCount,p.content)){if(n){let g=T.empty;for(let y=f.length-1;y>=0;y--)g=T.from(f[y].copy(g));let m=t.tr.step(new Ie(e.pos-f.length,e.pos+i.nodeSize,e.pos+h,e.pos+i.nodeSize-h,new D(g,f.length,0),0,!0));n(m.scrollIntoView())}return!0}}return!1}function qf(t){return function(e,n){let r=e.selection,i=t<0?r.$from:r.$to,o=i.depth;for(;i.node(o).isInline;){if(!o)return!1;o--}return i.node(o).isTextblock?(n&&n(e.tr.setSelection(K.create(e.doc,t<0?i.start(o):i.end(o)))),!0):!1}}var hl=qf(-1),ml=qf(1);function jf(t,e=null){return function(n,r){let{$from:i,$to:o}=n.selection,s=i.blockRange(o),a=s&&Mr(s,t,e);return a?(r&&r(n.tr.wrap(s,a).scrollIntoView()),!0):!1}}function gl(t,e=null){return function(n,r){let i=!1;for(let o=0;o{if(i)return!1;if(!(!l.isTextblock||l.hasMarkup(t,e)))if(l.type==t)i=!0;else{let u=n.doc.resolve(c),d=u.index();i=u.parent.canReplaceWith(d,d+1,t)}})}if(!i)return!1;if(r){let o=n.tr;for(let s=0;s=2&&i.node(s.depth-1).type.compatibleContent(t)&&s.startIndex==0){if(i.index(s.depth-1)==0)return!1;let u=n.doc.resolve(s.start-2);l=new Hn(u,u,s.depth),s.endIndex=0;u--)o=T.from(n[u].type.create(n[u].attrs,o));t.step(new Ie(e.start-(r?2:0),e.end,e.start,e.end,new D(o,0,0),n.length,!0));let s=0;for(let u=0;us.childCount>0&&s.firstChild.type==t);return o?n?r.node(o.depth-1).type==t?M0(e,n,t,o):N0(e,n,o):!0:!1}}function M0(t,e,n,r){let i=t.tr,o=r.end,s=r.$to.end(r.depth);og;h--)p-=i.child(h).nodeSize,r.delete(p-1,p+1);let o=r.doc.resolve(n.start),s=o.nodeAfter;if(r.mapping.map(n.end)!=n.start+o.nodeAfter.nodeSize)return!1;let a=n.startIndex==0,l=n.endIndex==i.childCount,c=o.node(-1),u=o.index(-1);if(!c.canReplace(u+(a?0:1),u+1,s.content.append(l?T.empty:T.from(i))))return!1;let d=o.pos,f=d+s.nodeSize;return r.step(new Ie(d-(a?1:0),f+(l?1:0),d+1,f-1,new D((a?T.empty:T.from(i.copy(T.empty))).append(l?T.empty:T.from(i.copy(T.empty))),a?0:1,l?0:1),a?0:1)),e(r.scrollIntoView()),!0}function Xf(t){return function(e,n){let{$from:r,$to:i}=e.selection,o=r.blockRange(i,c=>c.childCount>0&&c.firstChild.type==t);if(!o)return!1;let s=o.startIndex;if(s==0)return!1;let a=o.parent,l=a.child(s-1);if(l.type!=t)return!1;if(n){let c=l.lastChild&&l.lastChild.type==a.type,u=T.from(c?t.create():null),d=new D(T.from(t.create(null,T.from(a.type.create(null,u)))),c?3:1,0),f=o.start,p=o.end;n(e.tr.step(new Ie(f-(c?3:1),p,f,p,d,1,!0)).scrollIntoView())}return!0}}function Lo(t){let{state:e,transaction:n}=t,{selection:r}=n,{doc:i}=n,{storedMarks:o}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),filterTransaction:e.filterTransaction,plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return o},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,o=n.storedMarks,n}}}var Pr=class{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){let{rawCommands:e,editor:n,state:r}=this,{view:i}=n,{tr:o}=r,s=this.buildProps(o);return Object.fromEntries(Object.entries(e).map(([a,l])=>[a,(...u)=>{let d=l(...u)(s);return!o.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(o),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,n=!0){let{rawCommands:r,editor:i,state:o}=this,{view:s}=i,a=[],l=!!e,c=e||o.tr,u=()=>(!l&&n&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(c),a.every(f=>f===!0)),d={...Object.fromEntries(Object.entries(r).map(([f,p])=>[f,(...g)=>{let m=this.buildProps(c,n),y=p(...g)(m);return a.push(y),d}])),run:u};return d}createCan(e){let{rawCommands:n,state:r}=this,i=!1,o=e||r.tr,s=this.buildProps(o,i);return{...Object.fromEntries(Object.entries(n).map(([l,c])=>[l,(...u)=>c(...u)({...s,dispatch:void 0})])),chain:()=>this.createChain(o,i)}}buildProps(e,n=!0){let{rawCommands:r,editor:i,state:o}=this,{view:s}=i,a={tr:e,editor:i,view:s,state:Lo({state:o,transaction:e}),dispatch:n?()=>{}:void 0,chain:()=>this.createChain(e,n),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(r).map(([l,c])=>[l,(...u)=>c(...u)(a)]))}};return a}},xl=class{constructor(){this.callbacks={}}on(e,n){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(n),this}emit(e,...n){let r=this.callbacks[e];return r&&r.forEach(i=>i.apply(this,n)),this}off(e,n){let r=this.callbacks[e];return r&&(n?this.callbacks[e]=r.filter(i=>i!==n):delete this.callbacks[e]),this}removeAllListeners(){this.callbacks={}}};function F(t,e,n){return t.config[e]===void 0&&t.parent?F(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?F(t.parent,e,n):null}):t.config[e]}function Po(t){let e=t.filter(i=>i.type==="extension"),n=t.filter(i=>i.type==="node"),r=t.filter(i=>i.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:r}}function op(t){let e=[],{nodeExtensions:n,markExtensions:r}=Po(t),i=[...n,...r],o={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach(s=>{let a={name:s.name,options:s.options,storage:s.storage},l=F(s,"addGlobalAttributes",a);if(!l)return;l().forEach(u=>{u.types.forEach(d=>{Object.entries(u.attributes).forEach(([f,p])=>{e.push({type:d,name:f,attribute:{...o,...p}})})})})}),i.forEach(s=>{let a={name:s.name,options:s.options,storage:s.storage},l=F(s,"addAttributes",a);if(!l)return;let c=l();Object.entries(c).forEach(([u,d])=>{let f={...o,...d};typeof f?.default=="function"&&(f.default=f.default()),f?.isRequired&&f?.default===void 0&&delete f.default,e.push({type:s.name,name:u,attribute:f})})}),e}function $e(t,e){if(typeof t=="string"){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}function B(...t){return t.filter(e=>!!e).reduce((e,n)=>{let r={...e};return Object.entries(n).forEach(([i,o])=>{if(!r[i]){r[i]=o;return}if(i==="class"){let a=o?o.split(" "):[],l=r[i]?r[i].split(" "):[],c=a.filter(u=>!l.includes(u));r[i]=[...l,...c].join(" ")}else i==="style"?r[i]=[r[i],o].join("; "):r[i]=o}),r},{})}function kl(t,e){return e.filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(t.attrs)||{}:{[n.name]:t.attrs[n.name]}).reduce((n,r)=>B(n,r),{})}function sp(t){return typeof t=="function"}function ee(t,e=void 0,...n){return sp(t)?e?t.bind(e)(...n):t(...n):t}function T0(t={}){return Object.keys(t).length===0&&t.constructor===Object}function _0(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function Zf(t,e){return t.style?t:{...t,getAttrs:n=>{let r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;let i=e.reduce((o,s)=>{let a=s.attribute.parseHTML?s.attribute.parseHTML(n):_0(n.getAttribute(s.name));return a==null?o:{...o,[s.name]:a}},{});return{...r,...i}}}}function Qf(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&T0(n)?!1:n!=null))}function C0(t,e){var n;let r=op(t),{nodeExtensions:i,markExtensions:o}=Po(t),s=(n=i.find(c=>F(c,"topNode")))===null||n===void 0?void 0:n.name,a=Object.fromEntries(i.map(c=>{let u=r.filter(y=>y.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},f=t.reduce((y,M)=>{let x=F(M,"extendNodeSchema",d);return{...y,...x?x(c):{}}},{}),p=Qf({...f,content:ee(F(c,"content",d)),marks:ee(F(c,"marks",d)),group:ee(F(c,"group",d)),inline:ee(F(c,"inline",d)),atom:ee(F(c,"atom",d)),selectable:ee(F(c,"selectable",d)),draggable:ee(F(c,"draggable",d)),code:ee(F(c,"code",d)),defining:ee(F(c,"defining",d)),isolating:ee(F(c,"isolating",d)),attrs:Object.fromEntries(u.map(y=>{var M;return[y.name,{default:(M=y?.attribute)===null||M===void 0?void 0:M.default}]}))}),h=ee(F(c,"parseHTML",d));h&&(p.parseDOM=h.map(y=>Zf(y,u)));let g=F(c,"renderHTML",d);g&&(p.toDOM=y=>g({node:y,HTMLAttributes:kl(y,u)}));let m=F(c,"renderText",d);return m&&(p.toText=m),[c.name,p]})),l=Object.fromEntries(o.map(c=>{let u=r.filter(m=>m.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},f=t.reduce((m,y)=>{let M=F(y,"extendMarkSchema",d);return{...m,...M?M(c):{}}},{}),p=Qf({...f,inclusive:ee(F(c,"inclusive",d)),excludes:ee(F(c,"excludes",d)),group:ee(F(c,"group",d)),spanning:ee(F(c,"spanning",d)),code:ee(F(c,"code",d)),attrs:Object.fromEntries(u.map(m=>{var y;return[m.name,{default:(y=m?.attribute)===null||y===void 0?void 0:y.default}]}))}),h=ee(F(c,"parseHTML",d));h&&(p.parseDOM=h.map(m=>Zf(m,u)));let g=F(c,"renderHTML",d);return g&&(p.toDOM=m=>g({mark:m,HTMLAttributes:kl(m,u)})),[c.name,p]}));return new io({topNode:s,nodes:a,marks:l})}function yl(t,e){return e.nodes[t]||e.marks[t]||null}function ep(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}var O0=(t,e=500)=>{let n="",r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(i,o,s,a)=>{var l,c;let u=((c=(l=i.type.spec).toText)===null||c===void 0?void 0:c.call(l,{node:i,pos:o,parent:s,index:a}))||i.textContent||"%leaf%";n+=u.slice(0,Math.max(0,r-o))}),n};function Cl(t){return Object.prototype.toString.call(t)==="[object RegExp]"}var Br=class{constructor(e){this.find=e.find,this.handler=e.handler}},A0=(t,e)=>{if(Cl(e))return e.exec(t);let n=e(t);if(!n)return null;let r=[n.text];return r.index=n.index,r.input=t,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r};function El(t){var e;let{editor:n,from:r,to:i,text:o,rules:s,plugin:a}=t,{view:l}=n;if(l.composing)return!1;let c=l.state.doc.resolve(r);if(c.parent.type.spec.code||!((e=c.nodeBefore||c.nodeAfter)===null||e===void 0)&&e.marks.find(f=>f.type.spec.code))return!1;let u=!1,d=O0(c)+o;return s.forEach(f=>{if(u)return;let p=A0(d,f.find);if(!p)return;let h=l.state.tr,g=Lo({state:l.state,transaction:h}),m={from:r-(p[0].length-o.length),to:i},{commands:y,chain:M,can:x}=new Pr({editor:n,state:g});f.handler({state:g,range:m,match:p,commands:y,chain:M,can:x})===null||!h.steps.length||(h.setMeta(a,{transform:h,from:r,to:i,text:o}),l.dispatch(h),u=!0)}),u}function R0(t){let{editor:e,rules:n}=t,r=new ge({state:{init(){return null},apply(i,o){let s=i.getMeta(r);return s||(i.selectionSet||i.docChanged?null:o)}},props:{handleTextInput(i,o,s,a){return El({editor:e,from:o,to:s,text:a,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{let{$cursor:o}=i.state.selection;o&&El({editor:e,from:o.pos,to:o.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(i,o){if(o.key!=="Enter")return!1;let{$cursor:s}=i.state.selection;return s?El({editor:e,from:s.pos,to:s.pos,text:`
+`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function I0(t){return typeof t=="number"}var Ml=class{constructor(e){this.find=e.find,this.handler=e.handler}},D0=(t,e)=>{if(Cl(e))return[...t.matchAll(e)];let n=e(t);return n?n.map(r=>{let i=[r.text];return i.index=r.index,i.input=t,i.data=r.data,r.replaceWith&&(r.text.includes(r.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),i.push(r.replaceWith)),i}):[]};function L0(t){let{editor:e,state:n,from:r,to:i,rule:o,pasteEvent:s,dropEvent:a}=t,{commands:l,chain:c,can:u}=new Pr({editor:e,state:n}),d=[];return n.doc.nodesBetween(r,i,(p,h)=>{if(!p.isTextblock||p.type.spec.code)return;let g=Math.max(r,h),m=Math.min(i,h+p.content.size),y=p.textBetween(g-h,m-h,void 0,"\uFFFC");D0(y,o.find).forEach(x=>{if(x.index===void 0)return;let b=g+x.index+1,_=b+x[0].length,w={from:n.tr.mapping.map(b),to:n.tr.mapping.map(_)},I=o.handler({state:n,range:w,match:x,commands:l,chain:c,can:u,pasteEvent:s,dropEvent:a});d.push(I)})}),d.every(p=>p!==null)}function P0(t){let{editor:e,rules:n}=t,r=null,i=!1,o=!1,s=new ClipboardEvent("paste"),a=new DragEvent("drop");return n.map(c=>new ge({view(u){let d=f=>{var p;r=!((p=u.dom.parentElement)===null||p===void 0)&&p.contains(f.target)?u.dom.parentElement:null};return window.addEventListener("dragstart",d),{destroy(){window.removeEventListener("dragstart",d)}}},props:{handleDOMEvents:{drop:(u,d)=>(o=r===u.dom.parentElement,a=d,!1),paste:(u,d)=>{var f;let p=(f=d.clipboardData)===null||f===void 0?void 0:f.getData("text/html");return s=d,i=!!p?.includes("data-pm-slice"),!1}}},appendTransaction:(u,d,f)=>{let p=u[0],h=p.getMeta("uiEvent")==="paste"&&!i,g=p.getMeta("uiEvent")==="drop"&&!o;if(!h&&!g)return;let m=d.doc.content.findDiffStart(f.doc.content),y=d.doc.content.findDiffEnd(f.doc.content);if(!I0(m)||!y||m===y.b)return;let M=f.tr,x=Lo({state:f,transaction:M});if(!(!L0({editor:e,state:x,from:Math.max(m-1,0),to:y.b-1,rule:c,pasteEvent:s,dropEvent:a})||!M.steps.length))return a=new DragEvent("drop"),s=new ClipboardEvent("paste"),M}}))}function B0(t){let e=t.filter((n,r)=>t.indexOf(n)!==r);return[...new Set(e)]}var Nl=class t{constructor(e,n){this.splittableMarks=[],this.editor=n,this.extensions=t.resolve(e),this.schema=C0(this.extensions,n),this.extensions.forEach(r=>{var i;this.editor.extensionStorage[r.name]=r.storage;let o={name:r.name,options:r.options,storage:r.storage,editor:this.editor,type:yl(r.name,this.schema)};r.type==="mark"&&(!((i=ee(F(r,"keepOnSplit",o)))!==null&&i!==void 0)||i)&&this.splittableMarks.push(r.name);let s=F(r,"onBeforeCreate",o);s&&this.editor.on("beforeCreate",s);let a=F(r,"onCreate",o);a&&this.editor.on("create",a);let l=F(r,"onUpdate",o);l&&this.editor.on("update",l);let c=F(r,"onSelectionUpdate",o);c&&this.editor.on("selectionUpdate",c);let u=F(r,"onTransaction",o);u&&this.editor.on("transaction",u);let d=F(r,"onFocus",o);d&&this.editor.on("focus",d);let f=F(r,"onBlur",o);f&&this.editor.on("blur",f);let p=F(r,"onDestroy",o);p&&this.editor.on("destroy",p)})}static resolve(e){let n=t.sort(t.flatten(e)),r=B0(n.map(i=>i.name));return r.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${r.map(i=>`'${i}'`).join(", ")}]. This can lead to issues.`),n}static flatten(e){return e.map(n=>{let r={name:n.name,options:n.options,storage:n.storage},i=F(n,"addExtensions",r);return i?[n,...this.flatten(i())]:n}).flat(10)}static sort(e){return e.sort((r,i)=>{let o=F(r,"priority")||100,s=F(i,"priority")||100;return o>s?-1:o{let r={name:n.name,options:n.options,storage:n.storage,editor:this.editor,type:yl(n.name,this.schema)},i=F(n,"addCommands",r);return i?{...e,...i()}:e},{})}get plugins(){let{editor:e}=this,n=t.sort([...this.extensions].reverse()),r=[],i=[],o=n.map(s=>{let a={name:s.name,options:s.options,storage:s.storage,editor:e,type:yl(s.name,this.schema)},l=[],c=F(s,"addKeyboardShortcuts",a),u={};if(s.type==="mark"&&s.config.exitable&&(u.ArrowRight=()=>we.handleExit({editor:e,mark:s})),c){let g=Object.fromEntries(Object.entries(c()).map(([m,y])=>[m,()=>y({editor:e})]));u={...u,...g}}let d=Ff(u);l.push(d);let f=F(s,"addInputRules",a);ep(s,e.options.enableInputRules)&&f&&r.push(...f());let p=F(s,"addPasteRules",a);ep(s,e.options.enablePasteRules)&&p&&i.push(...p());let h=F(s,"addProseMirrorPlugins",a);if(h){let g=h();l.push(...g)}return l}).flat();return[R0({editor:e,rules:r}),...P0({editor:e,rules:i}),...o]}get attributes(){return op(this.extensions)}get nodeViews(){let{editor:e}=this,{nodeExtensions:n}=Po(this.extensions);return Object.fromEntries(n.filter(r=>!!F(r,"addNodeView")).map(r=>{let i=this.attributes.filter(l=>l.type===r.name),o={name:r.name,options:r.options,storage:r.storage,editor:e,type:$e(r.name,this.schema)},s=F(r,"addNodeView",o);if(!s)return[];let a=(l,c,u,d)=>{let f=kl(l,i);return s()({editor:e,node:l,getPos:u,decorations:d,HTMLAttributes:f,extension:r})};return[r.name,a]}))}};function F0(t){return Object.prototype.toString.call(t).slice(8,-1)}function wl(t){return F0(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function Bo(t,e){let n={...t};return wl(t)&&wl(e)&&Object.keys(e).forEach(r=>{wl(e[r])?r in t?n[r]=Bo(t[r],e[r]):Object.assign(n,{[r]:e[r]}):Object.assign(n,{[r]:e[r]})}),n}var Ne=class t{constructor(e={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=ee(F(this,"addOptions",{name:this.name}))),this.storage=ee(F(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new t(e)}configure(e={}){let n=this.extend();return n.options=Bo(this.options,e),n.storage=ee(F(n,"addStorage",{name:n.name,options:n.options})),n}extend(e={}){let n=new t(e);return n.parent=this,this.child=n,n.name=e.name?e.name:n.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=ee(F(n,"addOptions",{name:n.name})),n.storage=ee(F(n,"addStorage",{name:n.name,options:n.options})),n}};function ap(t,e,n){let{from:r,to:i}=e,{blockSeparator:o=`
+
+`,textSerializers:s={}}=n||{},a="",l=!0;return t.nodesBetween(r,i,(c,u,d,f)=>{var p;let h=s?.[c.type.name];h?(c.isBlock&&!l&&(a+=o,l=!0),d&&(a+=h({node:c,pos:u,parent:d,index:f,range:e}))):c.isText?(a+=(p=c?.text)===null||p===void 0?void 0:p.slice(Math.max(r,u)-u,i-u),l=!1):c.isBlock&&!l&&(a+=o,l=!0)}),a}function lp(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}var H0=Ne.create({name:"clipboardTextSerializer",addProseMirrorPlugins(){return[new ge({key:new ve("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{let{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:i}=e,{ranges:o}=i,s=Math.min(...o.map(u=>u.$from.pos)),a=Math.max(...o.map(u=>u.$to.pos)),l=lp(n);return ap(r,{from:s,to:a},{textSerializers:l})}}})]}}),z0=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())===null||n===void 0||n.removeAllRanges())}),!0),$0=(t=!1)=>({commands:e})=>e.setContent("",t),U0=()=>({state:t,tr:e,dispatch:n})=>{let{selection:r}=e,{ranges:i}=r;return n&&i.forEach(({$from:o,$to:s})=>{t.doc.nodesBetween(o.pos,s.pos,(a,l)=>{if(a.type.isText)return;let{doc:c,mapping:u}=e,d=c.resolve(u.map(l)),f=c.resolve(u.map(l+a.nodeSize)),p=d.blockRange(f);if(!p)return;let h=rn(p);if(a.type.isTextblock){let{defaultType:g}=d.parent.contentMatchAt(d.index());e.setNodeMarkup(p.start,g)}(h||h===0)&&e.lift(p,h)})}),!0},K0=t=>e=>t(e),W0=()=>({state:t,dispatch:e})=>fl(t,e),V0=(t,e)=>({editor:n,tr:r})=>{let{state:i}=n,o=i.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);let s=r.mapping.map(e);return r.insert(s,o.content),r.setSelection(new K(r.doc.resolve(s-1))),!0},G0=()=>({tr:t,dispatch:e})=>{let{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;let i=t.selection.$anchor;for(let o=i.depth;o>0;o-=1)if(i.node(o).type===r.type){if(e){let a=i.before(o),l=i.after(o);t.delete(a,l).scrollIntoView()}return!0}return!1},q0=t=>({tr:e,state:n,dispatch:r})=>{let i=$e(t,n.schema),o=e.selection.$anchor;for(let s=o.depth;s>0;s-=1)if(o.node(s).type===i){if(r){let l=o.before(s),c=o.after(s);e.delete(l,c).scrollIntoView()}return!0}return!1},j0=t=>({tr:e,dispatch:n})=>{let{from:r,to:i}=t;return n&&e.delete(r,i),!0},Y0=()=>({state:t,dispatch:e})=>Oo(t,e),J0=()=>({commands:t})=>t.keyboardShortcut("Enter"),X0=()=>({state:t,dispatch:e})=>dl(t,e);function Ro(t,e,n={strict:!0}){let r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:Cl(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function Tl(t,e,n={}){return t.find(r=>r.type===e&&Ro(r.attrs,n))}function Z0(t,e,n={}){return!!Tl(t,e,n)}function Ol(t,e,n={}){if(!t||!e)return;let r=t.parent.childAfter(t.parentOffset);if(t.parentOffset===r.offset&&r.offset!==0&&(r=t.parent.childBefore(t.parentOffset)),!r.node)return;let i=Tl([...r.node.marks],e,n);if(!i)return;let o=r.index,s=t.start()+r.offset,a=o+1,l=s+r.node.nodeSize;for(Tl([...r.node.marks],e,n);o>0&&i.isInSet(t.parent.child(o-1).marks);)o-=1,s-=t.parent.child(o).nodeSize;for(;a({tr:n,state:r,dispatch:i})=>{let o=Sn(t,r.schema),{doc:s,selection:a}=n,{$from:l,from:c,to:u}=a;if(i){let d=Ol(l,o,e);if(d&&d.from<=c&&d.to>=u){let f=K.create(s,d.from,d.to);n.setSelection(f)}}return!0},ew=t=>e=>{let n=typeof t=="function"?t(e):t;for(let r=0;r({editor:n,view:r,tr:i,dispatch:o})=>{e={scrollIntoView:!0,...e};let s=()=>{Al()&&r.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e?.scrollIntoView&&n.commands.scrollIntoView())})};if(r.hasFocus()&&t===null||t===!1)return!0;if(o&&t===null&&!Fo(n.state.selection))return s(),!0;let a=cp(i.doc,t)||n.state.selection,l=n.state.selection.eq(a);return o&&(l||i.setSelection(a),l&&i.storedMarks&&i.setStoredMarks(i.storedMarks),s()),!0},nw=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),rw=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e);function tp(t){let e=`${t}`;return new window.DOMParser().parseFromString(e,"text/html").body}function Io(t,e,n){if(n={slice:!0,parseOptions:{},...n},typeof t=="object"&&t!==null)try{return Array.isArray(t)&&t.length>0?T.fromArray(t.map(r=>e.nodeFromJSON(r))):e.nodeFromJSON(t)}catch(r){return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",r),Io("",e,n)}if(typeof t=="string"){let r=$n.fromSchema(e);return n.slice?r.parseSlice(tp(t),n.parseOptions).content:r.parse(tp(t),n.parseOptions)}return Io("",e,n)}function iw(t,e,n){let r=t.steps.length-1;if(r{s===0&&(s=u)}),t.setSelection(V.near(t.doc.resolve(s),n))}var ow=t=>t.toString().startsWith("<"),sw=(t,e,n)=>({tr:r,dispatch:i,editor:o})=>{if(i){n={parseOptions:{},updateSelection:!0,...n};let s=Io(e,o.schema,{parseOptions:{preserveWhitespace:"full",...n.parseOptions}});if(s.toString()==="<>")return!0;let{from:a,to:l}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},c=!0,u=!0;if((ow(s)?s:[s]).forEach(f=>{f.check(),c=c?f.isText&&f.marks.length===0:!1,u=u?f.isBlock:!1}),a===l&&u){let{parent:f}=r.doc.resolve(a);f.isTextblock&&!f.type.spec.code&&!f.childCount&&(a-=1,l+=1)}c?Array.isArray(e)?r.insertText(e.map(f=>f.text||"").join(""),a,l):typeof e=="object"&&e&&e.text?r.insertText(e.text,a,l):r.insertText(e,a,l):r.replaceWith(a,l,s),n.updateSelection&&iw(r,r.steps.length-1,-1)}return!0},aw=()=>({state:t,dispatch:e})=>Uf(t,e),lw=()=>({state:t,dispatch:e})=>Kf(t,e),cw=()=>({state:t,dispatch:e})=>ol(t,e),uw=()=>({state:t,dispatch:e})=>al(t,e),dw=()=>({tr:t,state:e,dispatch:n})=>{try{let r=Nr(e.doc,e.selection.$from.pos,-1);return r==null?!1:(t.join(r,2),n&&n(t),!0)}catch{return!1}},fw=()=>({state:t,dispatch:e,tr:n})=>{try{let r=Nr(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}};function Ho(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function pw(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n==="Space"&&(n=" ");let r,i,o,s;for(let a=0;a({editor:e,view:n,tr:r,dispatch:i})=>{let o=pw(t).split(/-(?!$)/),s=o.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),a=new KeyboardEvent("keydown",{key:s==="Space"?" ":s,altKey:o.includes("Alt"),ctrlKey:o.includes("Ctrl"),metaKey:o.includes("Meta"),shiftKey:o.includes("Shift"),bubbles:!0,cancelable:!0}),l=e.captureTransaction(()=>{n.someProp("handleKeyDown",c=>c(n,a))});return l?.steps.forEach(c=>{let u=c.map(r.mapping);u&&i&&r.maybeStep(u)}),!0};function Mi(t,e,n={}){let{from:r,to:i,empty:o}=t.selection,s=e?$e(e,t.schema):null,a=[];t.doc.nodesBetween(r,i,(d,f)=>{if(d.isText)return;let p=Math.max(r,f),h=Math.min(i,f+d.nodeSize);a.push({node:d,from:p,to:h})});let l=i-r,c=a.filter(d=>s?s.name===d.node.type.name:!0).filter(d=>Ro(d.node.attrs,n,{strict:!1}));return o?!!c.length:c.reduce((d,f)=>d+f.to-f.from,0)>=l}var mw=(t,e={})=>({state:n,dispatch:r})=>{let i=$e(t,n.schema);return Mi(n,i,e)?Wf(n,r):!1},gw=()=>({state:t,dispatch:e})=>pl(t,e),bw=t=>({state:e,dispatch:n})=>{let r=$e(t,e.schema);return Jf(r)(e,n)},yw=()=>({state:t,dispatch:e})=>cl(t,e);function zo(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function np(t,e){let n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,i)=>(n.includes(i)||(r[i]=t[i]),r),{})}var Ew=(t,e)=>({tr:n,state:r,dispatch:i})=>{let o=null,s=null,a=zo(typeof t=="string"?t:t.name,r.schema);return a?(a==="node"&&(o=$e(t,r.schema)),a==="mark"&&(s=Sn(t,r.schema)),i&&n.selection.ranges.forEach(l=>{r.doc.nodesBetween(l.$from.pos,l.$to.pos,(c,u)=>{o&&o===c.type&&n.setNodeMarkup(u,void 0,np(c.attrs,e)),s&&c.marks.length&&c.marks.forEach(d=>{s===d.type&&n.addMark(u,u+c.nodeSize,s.create(np(d.attrs,e)))})})}),!0):!1},ww=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),vw=()=>({tr:t,commands:e})=>e.setTextSelection({from:0,to:t.doc.content.size}),Sw=()=>({state:t,dispatch:e})=>sl(t,e),xw=()=>({state:t,dispatch:e})=>ll(t,e),kw=()=>({state:t,dispatch:e})=>Vf(t,e),Mw=()=>({state:t,dispatch:e})=>ml(t,e),Nw=()=>({state:t,dispatch:e})=>hl(t,e);function up(t,e,n={}){return Io(t,e,{slice:!1,parseOptions:n})}var Tw=(t,e=!1,n={})=>({tr:r,editor:i,dispatch:o})=>{let{doc:s}=r,a=up(t,i.schema,n);return o&&r.replaceWith(0,s.content.size,a).setMeta("preventUpdate",!e),!0};function xn(t,e){let n=Sn(e,t.schema),{from:r,to:i,empty:o}=t.selection,s=[];o?(t.storedMarks&&s.push(...t.storedMarks),s.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,i,l=>{s.push(...l.marks)});let a=s.find(l=>l.type.name===n.name);return a?{...a.attrs}:{}}function dp(t,e){let n=new mn(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function Rl(t){for(let e=0;e{e(r)&&n.push({node:r,pos:i})}),n}function fp(t,e,n){let r=[];return t.nodesBetween(e.from,e.to,(i,o)=>{n(i)&&r.push({node:i,pos:o})}),r}function Il(t,e){for(let n=t.depth;n>0;n-=1){let r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}function er(t){return e=>Il(e.$from,t)}function _w(t,e){let n=tn.fromSchema(e).serializeFragment(t),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}function Cw(t,e){let n={from:0,to:t.content.size};return ap(t,n,e)}function Ow(t,e){let n=$e(e,t.schema),{from:r,to:i}=t.selection,o=[];t.doc.nodesBetween(r,i,a=>{o.push(a)});let s=o.reverse().find(a=>a.type.name===n.name);return s?{...s.attrs}:{}}function Dl(t,e){let n=zo(typeof e=="string"?e:e.name,t.schema);return n==="node"?Ow(t,e):n==="mark"?xn(t,e):{}}function Aw(t,e=JSON.stringify){let n={};return t.filter(r=>{let i=e(r);return Object.prototype.hasOwnProperty.call(n,i)?!1:n[i]=!0})}function Rw(t){let e=Aw(t);return e.length===1?e:e.filter((n,r)=>!e.filter((o,s)=>s!==r).some(o=>n.oldRange.from>=o.oldRange.from&&n.oldRange.to<=o.oldRange.to&&n.newRange.from>=o.newRange.from&&n.newRange.to<=o.newRange.to))}function pp(t){let{mapping:e,steps:n}=t,r=[];return e.maps.forEach((i,o)=>{let s=[];if(i.ranges.length)i.forEach((a,l)=>{s.push({from:a,to:l})});else{let{from:a,to:l}=n[o];if(a===void 0||l===void 0)return;s.push({from:a,to:l})}s.forEach(({from:a,to:l})=>{let c=e.slice(o).map(a,-1),u=e.slice(o).map(l),d=e.invert().map(c,-1),f=e.invert().map(u);r.push({oldRange:{from:d,to:f},newRange:{from:c,to:u}})})}),Rw(r)}function $o(t,e,n){let r=[];return t===e?n.resolve(t).marks().forEach(i=>{let o=n.resolve(t-1),s=Ol(o,i.type);s&&r.push({mark:i,...s})}):n.nodesBetween(t,e,(i,o)=>{r.push(...i.marks.map(s=>({from:o,to:o+i.nodeSize,mark:s})))}),r}function Ao(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{let i=t.find(o=>o.type===e&&o.name===r);return i?i.attribute.keepOnSplit:!1}))}function _l(t,e,n={}){let{empty:r,ranges:i}=t.selection,o=e?Sn(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(d=>o?o.name===d.type.name:!0).find(d=>Ro(d.attrs,n,{strict:!1}));let s=0,a=[];if(i.forEach(({$from:d,$to:f})=>{let p=d.pos,h=f.pos;t.doc.nodesBetween(p,h,(g,m)=>{if(!g.isText&&!g.marks.length)return;let y=Math.max(p,m),M=Math.min(h,m+g.nodeSize),x=M-y;s+=x,a.push(...g.marks.map(b=>({mark:b,from:y,to:M})))})}),s===0)return!1;let l=a.filter(d=>o?o.name===d.mark.type.name:!0).filter(d=>Ro(d.mark.attrs,n,{strict:!1})).reduce((d,f)=>d+f.to-f.from,0),c=a.filter(d=>o?d.mark.type!==o&&d.mark.type.excludes(o):!0).reduce((d,f)=>d+f.to-f.from,0);return(l>0?l+c:l)>=s}function Bt(t,e,n={}){if(!e)return Mi(t,null,n)||_l(t,null,n);let r=zo(e,t.schema);return r==="node"?Mi(t,e,n):r==="mark"?_l(t,e,n):!1}function rp(t,e){let{nodeExtensions:n}=Po(e),r=n.find(s=>s.name===t);if(!r)return!1;let i={name:r.name,options:r.options,storage:r.storage},o=ee(F(r,"group",i));return typeof o!="string"?!1:o.split(" ").includes("list")}function Iw(t){var e;let n=(e=t.type.createAndFill())===null||e===void 0?void 0:e.toJSON(),r=t.toJSON();return JSON.stringify(n)===JSON.stringify(r)}function hp(t){return t instanceof Y}function Uo(t,e,n){let i=t.state.doc.content.size,o=cn(e,0,i),s=cn(n,0,i),a=t.coordsAtPos(o),l=t.coordsAtPos(s,-1),c=Math.min(a.top,l.top),u=Math.max(a.bottom,l.bottom),d=Math.min(a.left,l.left),f=Math.max(a.right,l.right),p=f-d,h=u-c,y={top:c,bottom:u,left:d,right:f,width:p,height:h,x:d,y:c};return{...y,toJSON:()=>y}}function Dw(t,e,n){var r;let{selection:i}=e,o=null;if(Fo(i)&&(o=i.$cursor),o){let a=(r=t.storedMarks)!==null&&r!==void 0?r:o.marks();return!!n.isInSet(a)||!a.some(l=>l.type.excludes(n))}let{ranges:s}=i;return s.some(({$from:a,$to:l})=>{let c=a.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(a.pos,l.pos,(u,d,f)=>{if(c)return!1;if(u.isInline){let p=!f||f.type.allowsMarkType(n),h=!!n.isInSet(u.marks)||!u.marks.some(g=>g.type.excludes(n));c=p&&h}return!c}),c})}var Lw=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let{selection:o}=n,{empty:s,ranges:a}=o,l=Sn(t,r.schema);if(i)if(s){let c=xn(r,l);n.addStoredMark(l.create({...c,...e}))}else a.forEach(c=>{let u=c.$from.pos,d=c.$to.pos;r.doc.nodesBetween(u,d,(f,p)=>{let h=Math.max(p,u),g=Math.min(p+f.nodeSize,d);f.marks.find(y=>y.type===l)?f.marks.forEach(y=>{l===y.type&&n.addMark(h,g,l.create({...y.attrs,...e}))}):n.addMark(h,g,l.create(e))})});return Dw(r,n,l)},Pw=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),Bw=(t,e={})=>({state:n,dispatch:r,chain:i})=>{let o=$e(t,n.schema);return o.isTextblock?i().command(({commands:s})=>gl(o,e)(n)?!0:s.clearNodes()).command(({state:s})=>gl(o,e)(s,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},Fw=t=>({tr:e,dispatch:n})=>{if(n){let{doc:r}=e,i=cn(t,0,r.content.size),o=Y.create(r,i);e.setSelection(o)}return!0},Hw=t=>({tr:e,dispatch:n})=>{if(n){let{doc:r}=e,{from:i,to:o}=typeof t=="number"?{from:t,to:t}:t,s=K.atStart(r).from,a=K.atEnd(r).to,l=cn(i,s,a),c=cn(o,s,a),u=K.create(r,l,c);e.setSelection(u)}return!0},zw=t=>({state:e,dispatch:n})=>{let r=$e(t,e.schema);return Xf(r)(e,n)};function ip(t,e){let n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){let r=n.filter(i=>e?.includes(i.type.name));t.tr.ensureMarks(r)}}var $w=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:i})=>{let{selection:o,doc:s}=e,{$from:a,$to:l}=o,c=i.extensionManager.attributes,u=Ao(c,a.node().type.name,a.node().attrs);if(o instanceof Y&&o.node.isBlock)return!a.parentOffset||!St(s,a.pos)?!1:(r&&(t&&ip(n,i.extensionManager.splittableMarks),e.split(a.pos).scrollIntoView()),!0);if(!a.parent.isBlock)return!1;if(r){let d=l.parentOffset===l.parent.content.size;o instanceof K&&e.deleteSelection();let f=a.depth===0?void 0:Rl(a.node(-1).contentMatchAt(a.indexAfter(-1))),p=d&&f?[{type:f,attrs:u}]:void 0,h=St(e.doc,e.mapping.map(a.pos),1,p);if(!p&&!h&&St(e.doc,e.mapping.map(a.pos),1,f?[{type:f}]:void 0)&&(h=!0,p=f?[{type:f,attrs:u}]:void 0),h&&(e.split(e.mapping.map(a.pos),1,p),f&&!d&&!a.parentOffset&&a.parent.type!==f)){let g=e.mapping.map(a.before()),m=e.doc.resolve(g);a.node(-1).canReplaceWith(m.index(),m.index()+1,f)&&e.setNodeMarkup(e.mapping.map(a.before()),f)}t&&ip(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return!0},Uw=t=>({tr:e,state:n,dispatch:r,editor:i})=>{var o;let s=$e(t,n.schema),{$from:a,$to:l}=n.selection,c=n.selection.node;if(c&&c.isBlock||a.depth<2||!a.sameParent(l))return!1;let u=a.node(-1);if(u.type!==s)return!1;let d=i.extensionManager.attributes;if(a.parent.content.size===0&&a.node(-1).childCount===a.indexAfter(-1)){if(a.depth===2||a.node(-3).type!==s||a.index(-2)!==a.node(-2).childCount-1)return!1;if(r){let m=T.empty,y=a.index(-1)?1:a.index(-2)?2:3;for(let I=a.depth-y;I>=a.depth-3;I-=1)m=T.from(a.node(I).copy(m));let M=a.indexAfter(-1){if(w>-1)return!1;I.isTextblock&&I.content.size===0&&(w=U+1)}),w>-1&&e.setSelection(K.near(e.doc.resolve(w))),e.scrollIntoView()}return!0}let f=l.pos===a.end()?u.contentMatchAt(0).defaultType:null,p=Ao(d,u.type.name,u.attrs),h=Ao(d,a.node().type.name,a.node().attrs);e.delete(a.pos,l.pos);let g=f?[{type:s,attrs:p},{type:f,attrs:h}]:[{type:s,attrs:p}];if(!St(e.doc,a.pos,2))return!1;if(r){let{selection:m,storedMarks:y}=n,{splittableMarks:M}=i.extensionManager,x=y||m.$to.parentOffset&&m.$from.marks();if(e.split(a.pos,2,g).scrollIntoView(),!x||!r)return!0;let b=x.filter(_=>M.includes(_.type.name));e.ensureMarks(b)}return!0},vl=(t,e)=>{let n=er(s=>s.type===e)(t.selection);if(!n)return!0;let r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;let i=t.doc.nodeAt(r);return n.node.type===i?.type&&Dt(t.doc,n.pos)&&t.join(n.pos),!0},Sl=(t,e)=>{let n=er(s=>s.type===e)(t.selection);if(!n)return!0;let r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;let i=t.doc.nodeAt(r);return n.node.type===i?.type&&Dt(t.doc,r)&&t.join(r),!0},Kw=(t,e,n,r={})=>({editor:i,tr:o,state:s,dispatch:a,chain:l,commands:c,can:u})=>{let{extensions:d,splittableMarks:f}=i.extensionManager,p=$e(t,s.schema),h=$e(e,s.schema),{selection:g,storedMarks:m}=s,{$from:y,$to:M}=g,x=y.blockRange(M),b=m||g.$to.parentOffset&&g.$from.marks();if(!x)return!1;let _=er(w=>rp(w.type.name,d))(g);if(x.depth>=1&&_&&x.depth-_.depth<=1){if(_.node.type===p)return c.liftListItem(h);if(rp(_.node.type.name,d)&&p.validContent(_.node.content)&&a)return l().command(()=>(o.setNodeMarkup(_.pos,p),!0)).command(()=>vl(o,p)).command(()=>Sl(o,p)).run()}return!n||!b||!a?l().command(()=>u().wrapInList(p,r)?!0:c.clearNodes()).wrapInList(p,r).command(()=>vl(o,p)).command(()=>Sl(o,p)).run():l().command(()=>{let w=u().wrapInList(p,r),I=b.filter(U=>f.includes(U.type.name));return o.ensureMarks(I),w?!0:c.clearNodes()}).wrapInList(p,r).command(()=>vl(o,p)).command(()=>Sl(o,p)).run()},Ww=(t,e={},n={})=>({state:r,commands:i})=>{let{extendEmptyMarkRange:o=!1}=n,s=Sn(t,r.schema);return _l(r,s,e)?i.unsetMark(s,{extendEmptyMarkRange:o}):i.setMark(s,e)},Vw=(t,e,n={})=>({state:r,commands:i})=>{let o=$e(t,r.schema),s=$e(e,r.schema);return Mi(r,o,n)?i.setNode(s):i.setNode(o,n)},Gw=(t,e={})=>({state:n,commands:r})=>{let i=$e(t,n.schema);return Mi(n,i,e)?r.lift(i):r.wrapIn(i,e)},qw=()=>({state:t,dispatch:e})=>{let n=t.plugins;for(let r=0;r=0;l-=1)s.step(a.steps[l].invert(a.docs[l]));if(o.text){let l=s.doc.resolve(o.from).marks();s.replaceWith(o.from,o.to,t.schema.text(o.text,l))}else s.delete(o.from,o.to)}return!0}}return!1},jw=()=>({tr:t,dispatch:e})=>{let{selection:n}=t,{empty:r,ranges:i}=n;return r||e&&i.forEach(o=>{t.removeMark(o.$from.pos,o.$to.pos)}),!0},Yw=(t,e={})=>({tr:n,state:r,dispatch:i})=>{var o;let{extendEmptyMarkRange:s=!1}=e,{selection:a}=n,l=Sn(t,r.schema),{$from:c,empty:u,ranges:d}=a;if(!i)return!0;if(u&&s){let{from:f,to:p}=a,h=(o=c.marks().find(m=>m.type===l))===null||o===void 0?void 0:o.attrs,g=Ol(c,l,h);g&&(f=g.from,p=g.to),n.removeMark(f,p,l)}else d.forEach(f=>{n.removeMark(f.$from.pos,f.$to.pos,l)});return n.removeStoredMark(l),!0},Jw=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let o=null,s=null,a=zo(typeof t=="string"?t:t.name,r.schema);return a?(a==="node"&&(o=$e(t,r.schema)),a==="mark"&&(s=Sn(t,r.schema)),i&&n.selection.ranges.forEach(l=>{let c=l.$from.pos,u=l.$to.pos;r.doc.nodesBetween(c,u,(d,f)=>{o&&o===d.type&&n.setNodeMarkup(f,void 0,{...d.attrs,...e}),s&&d.marks.length&&d.marks.forEach(p=>{if(s===p.type){let h=Math.max(f,c),g=Math.min(f+d.nodeSize,u);n.addMark(h,g,s.create({...p.attrs,...e}))}})})}),!0):!1},Xw=(t,e={})=>({state:n,dispatch:r})=>{let i=$e(t,n.schema);return jf(i,e)(n,r)},Zw=(t,e={})=>({state:n,dispatch:r})=>{let i=$e(t,n.schema);return Yf(i,e)(n,r)},Qw=Object.freeze({__proto__:null,blur:z0,clearContent:$0,clearNodes:U0,command:K0,createParagraphNear:W0,cut:V0,deleteCurrentNode:G0,deleteNode:q0,deleteRange:j0,deleteSelection:Y0,enter:J0,exitCode:X0,extendMarkRange:Q0,first:ew,focus:tw,forEach:nw,insertContent:rw,insertContentAt:sw,joinUp:aw,joinDown:lw,joinBackward:cw,joinForward:uw,joinItemBackward:dw,joinItemForward:fw,keyboardShortcut:hw,lift:mw,liftEmptyBlock:gw,liftListItem:bw,newlineInCode:yw,resetAttributes:Ew,scrollIntoView:ww,selectAll:vw,selectNodeBackward:Sw,selectNodeForward:xw,selectParentNode:kw,selectTextblockEnd:Mw,selectTextblockStart:Nw,setContent:Tw,setMark:Lw,setMeta:Pw,setNode:Bw,setNodeSelection:Fw,setTextSelection:Hw,sinkListItem:zw,splitBlock:$w,splitListItem:Uw,toggleList:Kw,toggleMark:Ww,toggleNode:Vw,toggleWrap:Gw,undoInputRule:qw,unsetAllMarks:jw,unsetMark:Yw,updateAttributes:Jw,wrapIn:Xw,wrapInList:Zw}),ev=Ne.create({name:"commands",addCommands(){return{...Qw}}}),tv=Ne.create({name:"editable",addProseMirrorPlugins(){return[new ge({key:new ve("editable"),props:{editable:()=>this.editor.options.editable}})]}}),nv=Ne.create({name:"focusEvents",addProseMirrorPlugins(){let{editor:t}=this;return[new ge({key:new ve("focusEvents"),props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;let r=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;let r=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),rv=Ne.create({name:"keymap",addKeyboardShortcuts(){let t=()=>this.editor.commands.first(({commands:s})=>[()=>s.undoInputRule(),()=>s.command(({tr:a})=>{let{selection:l,doc:c}=a,{empty:u,$anchor:d}=l,{pos:f,parent:p}=d,h=d.parent.isTextblock?a.doc.resolve(f-1):d,g=h.parent.type.spec.isolating,m=d.pos-d.parentOffset,y=g&&h.parent.childCount===1?m===d.pos:V.atStart(c).from===f;return!u||!y||!p.type.isTextblock||p.textContent.length?!1:s.clearNodes()}),()=>s.deleteSelection(),()=>s.joinBackward(),()=>s.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:s})=>[()=>s.deleteSelection(),()=>s.deleteCurrentNode(),()=>s.joinForward(),()=>s.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:s})=>[()=>s.newlineInCode(),()=>s.createParagraphNear(),()=>s.liftEmptyBlock(),()=>s.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...r},o={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Al()||Ho()?o:i},addProseMirrorPlugins(){return[new ge({key:new ve("clearDocument"),appendTransaction:(t,e,n)=>{if(!(t.some(h=>h.docChanged)&&!e.doc.eq(n.doc)))return;let{empty:i,from:o,to:s}=e.selection,a=V.atStart(e.doc).from,l=V.atEnd(e.doc).to;if(i||!(o===a&&s===l)||!(n.doc.textBetween(0,n.doc.content.size," "," ").length===0))return;let d=n.tr,f=Lo({state:n,transaction:d}),{commands:p}=new Pr({editor:this.editor,state:f});if(p.clearNodes(),!!d.steps.length)return d}})]}}),iv=Ne.create({name:"tabindex",addProseMirrorPlugins(){return[new ge({key:new ve("tabindex"),props:{attributes:this.editor.isEditable?{tabindex:"0"}:{}}})]}}),ov=Object.freeze({__proto__:null,ClipboardTextSerializer:H0,Commands:ev,Editable:tv,FocusEvents:nv,Keymap:rv,Tabindex:iv}),sv=`.ProseMirror {
position: relative;
}
@@ -84,17 +84,17 @@ img.ProseMirror-separator {
.tippy-box[data-animation=fade][data-state=hidden] {
opacity: 0
-}`;function ov(t,e,n){let r=document.querySelector(`style[data-tiptap-style${n?`-${n}`:""}]`);if(r!==null)return r;let i=document.createElement("style");return e&&i.setAttribute("nonce",e),i.setAttribute(`data-tiptap-style${n?`-${n}`:""}`,""),i.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(i),i}var zo=class extends Tl{constructor(e={}){super(),this.isFocused=!1,this.extensionStorage={},this.options={element:document.createElement("div"),content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.createView(),this.injectCSS(),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),window.setTimeout(()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}))},0)}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&document&&(this.css=ov(iv,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},!(!this.view||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(e,n=!0){this.setOptions({editable:e}),n&&this.emit("update",{editor:this,transaction:this.state.tr})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get state(){return this.view.state}registerPlugin(e,n){let r=sp(n)?n(e,[...this.state.plugins]):[...this.state.plugins,e],i=this.state.reconfigure({plugins:r});this.view.updateState(i)}unregisterPlugin(e){if(this.isDestroyed)return;let n=typeof e=="string"?`${e}$`:e.key,r=this.state.reconfigure({plugins:this.state.plugins.filter(i=>!i.key.startsWith(n))});this.view.updateState(r)}createExtensionManager(){let n=[...this.options.enableCoreExtensions?Object.values(rv):[],...this.options.extensions].filter(r=>["extension","node","mark"].includes(r?.type));this.extensionManager=new Ln(n,this)}createCommandManager(){this.commandManager=new jr({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){let e=dp(this.options.content,this.schema,this.options.parseOptions),n=cp(e,this.options.autofocus);this.view=new Oo(this.options.element,{...this.options.editorProps,dispatchTransaction:this.dispatchTransaction.bind(this),state:mn.create({doc:e,selection:n||void 0})});let r=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(r),this.createNodeViews();let i=this.view.dom;i.editor=this}createNodeViews(){this.view.setProps({nodeViews:this.extensionManager.nodeViews})}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;let n=this.capturedTransaction;return this.capturedTransaction=null,n}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(s=>{var a;return(a=this.capturedTransaction)===null||a===void 0?void 0:a.step(s)});return}let n=this.state.apply(e),r=!this.state.selection.eq(n.selection);this.view.updateState(n),this.emit("transaction",{editor:this,transaction:e}),r&&this.emit("selectionUpdate",{editor:this,transaction:e});let i=e.getMeta("focus"),o=e.getMeta("blur");i&&this.emit("focus",{editor:this,event:i.event,transaction:e}),o&&this.emit("blur",{editor:this,event:o.event,transaction:e}),!(!e.docChanged||e.getMeta("preventUpdate"))&&this.emit("update",{editor:this,transaction:e})}getAttributes(e){return Pl(this.state,e)}isActive(e,n){let r=typeof e=="string"?e:null,i=typeof e=="string"?n:e;return $t(this.state,r,i)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Tw(this.state.doc.content,this.schema)}getText(e){let{blockSeparator:n=`
+}`;function av(t,e,n){let r=document.querySelector(`style[data-tiptap-style${n?`-${n}`:""}]`);if(r!==null)return r;let i=document.createElement("style");return e&&i.setAttribute("nonce",e),i.setAttribute(`data-tiptap-style${n?`-${n}`:""}`,""),i.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(i),i}var Do=class extends xl{constructor(e={}){super(),this.isFocused=!1,this.extensionStorage={},this.options={element:document.createElement("div"),content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.createView(),this.injectCSS(),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),window.setTimeout(()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}))},0)}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&document&&(this.css=av(sv,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},!(!this.view||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(e,n=!0){this.setOptions({editable:e}),n&&this.emit("update",{editor:this,transaction:this.state.tr})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get state(){return this.view.state}registerPlugin(e,n){let r=sp(n)?n(e,[...this.state.plugins]):[...this.state.plugins,e],i=this.state.reconfigure({plugins:r});this.view.updateState(i)}unregisterPlugin(e){if(this.isDestroyed)return;let n=typeof e=="string"?`${e}$`:e.key,r=this.state.reconfigure({plugins:this.state.plugins.filter(i=>!i.key.startsWith(n))});this.view.updateState(r)}createExtensionManager(){let n=[...this.options.enableCoreExtensions?Object.values(ov):[],...this.options.extensions].filter(r=>["extension","node","mark"].includes(r?.type));this.extensionManager=new Nl(n,this)}createCommandManager(){this.commandManager=new Pr({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){let e=up(this.options.content,this.schema,this.options.parseOptions),n=cp(e,this.options.autofocus);this.view=new Mo(this.options.element,{...this.options.editorProps,dispatchTransaction:this.dispatchTransaction.bind(this),state:go.create({doc:e,selection:n||void 0})});let r=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(r),this.createNodeViews(),this.prependClass();let i=this.view.dom;i.editor=this}createNodeViews(){this.view.setProps({nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`tiptap ${this.view.dom.className}`}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;let n=this.capturedTransaction;return this.capturedTransaction=null,n}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(s=>{var a;return(a=this.capturedTransaction)===null||a===void 0?void 0:a.step(s)});return}let n=this.state.apply(e),r=!this.state.selection.eq(n.selection);this.view.updateState(n),this.emit("transaction",{editor:this,transaction:e}),r&&this.emit("selectionUpdate",{editor:this,transaction:e});let i=e.getMeta("focus"),o=e.getMeta("blur");i&&this.emit("focus",{editor:this,event:i.event,transaction:e}),o&&this.emit("blur",{editor:this,event:o.event,transaction:e}),!(!e.docChanged||e.getMeta("preventUpdate"))&&this.emit("update",{editor:this,transaction:e})}getAttributes(e){return Dl(this.state,e)}isActive(e,n){let r=typeof e=="string"?e:null,i=typeof e=="string"?n:e;return Bt(this.state,r,i)}getJSON(){return this.state.doc.toJSON()}getHTML(){return _w(this.state.doc.content,this.schema)}getText(e){let{blockSeparator:n=`
-`,textSerializers:r={}}=e||{};return Nw(this.state.doc,{blockSeparator:n,textSerializers:{...lp(this.schema),...r}})}get isEmpty(){return Aw(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){this.emit("destroy"),this.view&&this.view.destroy(),this.removeAllListeners()}get isDestroyed(){var e;return!(!((e=this.view)===null||e===void 0)&&e.docView)}};function Ot(t){return new Yr({find:t.find,handler:({state:e,range:n,match:r})=>{let i=ee(t.getAttributes,void 0,r);if(i===!1||i===null)return null;let{tr:o}=e,s=r[r.length-1],a=r[0],l=n.to;if(s){let c=a.search(/\S/),u=n.from+a.indexOf(s),d=u+s.length;if(Pi(n.from,n.to,e.doc).filter(p=>p.mark.type.excluded.find(m=>m===t.type&&m!==p.mark.type)).filter(p=>p.to>u).length)return null;dn.from&&o.delete(n.from+c,u),l=n.from+c+s.length,o.addMark(n.from+c,l,t.type.create(i||{})),o.removeStoredMark(t.type)}}})}function qo(t){return new Yr({find:t.find,handler:({state:e,range:n,match:r})=>{let i=ee(t.getAttributes,void 0,r)||{},{tr:o}=e,s=n.from,a=n.to;if(r[1]){let l=r[0].lastIndexOf(r[1]),c=s+l;c>a?c=a:a=c+r[1].length;let u=r[0][r[0].length-1];o.insertText(u,s+r[0].length-1),o.replaceWith(c,a,t.type.create(i))}else r[0]&&o.replaceWith(s,a,t.type.create(i))}})}function Bi(t){return new Yr({find:t.find,handler:({state:e,range:n,match:r})=>{let i=e.doc.resolve(n.from),o=ee(t.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,o)}})}function Hn(t){return new Yr({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{let o=ee(t.getAttributes,void 0,r)||{},s=e.tr.delete(n.from,n.to),l=s.doc.resolve(n.from).blockRange(),c=l&&Hr(l,t.type,o);if(!c)return null;if(s.wrap(l,c),t.keepMarks&&t.editor){let{selection:d,storedMarks:f}=e,{splittableMarks:p}=t.editor.extensionManager,h=f||d.$to.parentOffset&&d.$from.marks();if(h){let m=h.filter(g=>p.includes(g.type.name));s.ensureMarks(m)}}if(t.keepAttributes){let d=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(d,o).run()}let u=s.doc.resolve(n.from-1).nodeBefore;u&&u.type===t.type&&Ft(s.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,u))&&s.join(n.from-1)}})}var be=class{constructor(e={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=ee(H(this,"addOptions",{name:this.name}))),this.storage=ee(H(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new be(e)}configure(e={}){let n=this.extend();return n.options=Ko(this.options,e),n.storage=ee(H(n,"addStorage",{name:n.name,options:n.options})),n}extend(e={}){let n=new be(e);return n.parent=this,this.child=n,n.name=e.name?e.name:n.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=ee(H(n,"addOptions",{name:n.name})),n.storage=ee(H(n,"addStorage",{name:n.name,options:n.options})),n}static handleExit({editor:e,mark:n}){let{tr:r}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){let s=i.marks();if(!!!s.find(c=>c?.type.name===n.name))return!1;let l=s.find(c=>c?.type.name===n.name);return l&&r.removeStoredMark(l),r.insertText(" ",i.pos),e.view.dispatch(r),!0}return!1}},z=class{constructor(e={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=ee(H(this,"addOptions",{name:this.name}))),this.storage=ee(H(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new z(e)}configure(e={}){let n=this.extend();return n.options=Ko(this.options,e),n.storage=ee(H(n,"addStorage",{name:n.name,options:n.options})),n}extend(e={}){let n=new z(e);return n.parent=this,this.child=n,n.name=e.name?e.name:n.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=ee(H(n,"addOptions",{name:n.name})),n.storage=ee(H(n,"addStorage",{name:n.name,options:n.options})),n}};function yt(t){return new _l({find:t.find,handler:({state:e,range:n,match:r})=>{let i=ee(t.getAttributes,void 0,r);if(i===!1||i===null)return null;let{tr:o}=e,s=r[r.length-1],a=r[0],l=n.to;if(s){let c=a.search(/\S/),u=n.from+a.indexOf(s),d=u+s.length;if(Pi(n.from,n.to,e.doc).filter(p=>p.mark.type.excluded.find(m=>m===t.type&&m!==p.mark.type)).filter(p=>p.to>u).length)return null;dn.from&&o.delete(n.from+c,u),l=n.from+c+s.length,o.addMark(n.from+c,l,t.type.create(i||{})),o.removeStoredMark(t.type)}}})}var sv=/^\s*>\s$/,gp=z.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return["blockquote",B(this.options.HTMLAttributes,t),0]},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[Hn({find:sv,type:this.type})]}});var av=/(?:^|\s)((?:\*\*)((?:[^*]+))(?:\*\*))$/,lv=/(?:^|\s)((?:\*\*)((?:[^*]+))(?:\*\*))/g,cv=/(?:^|\s)((?:__)((?:[^__]+))(?:__))$/,uv=/(?:^|\s)((?:__)((?:[^__]+))(?:__))/g,bp=be.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return["strong",B(this.options.HTMLAttributes,t),0]},addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Ot({find:av,type:this.type}),Ot({find:cv,type:this.type})]},addPasteRules(){return[yt({find:lv,type:this.type}),yt({find:uv,type:this.type})]}});var dv=z.create({name:"listItem",addOptions(){return{HTMLAttributes:{}}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",B(this.options.HTMLAttributes,t),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),yp=be.create({name:"textStyle",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"span",getAttrs:t=>t.hasAttribute("style")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["span",B(this.options.HTMLAttributes,t),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:t,commands:e})=>{let n=Bn(t,this.type);return Object.entries(n).some(([,i])=>!!i)?!0:e.unsetMark(this.name)}}}}),Ep=/^\s*([-+*])\s$/,wp=z.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",B(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(dv.name,this.editor.getAttributes(yp.name)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=Hn({find:Ep,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Hn({find:Ep,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(yp.name),editor:this.editor})),[t]}});var fv=/(?:^|\s)((?:`)((?:[^`]+))(?:`))$/,pv=/(?:^|\s)((?:`)((?:[^`]+))(?:`))/g,vp=be.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",B(this.options.HTMLAttributes,t),0]},addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Ot({find:fv,type:this.type})]},addPasteRules(){return[yt({find:pv,type:this.type})]}});var Sp=be.create({name:"textStyle",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"span",getAttrs:t=>t.hasAttribute("style")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["span",B(this.options.HTMLAttributes,t),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:t,commands:e})=>{let n=Bn(t,this.type);return Object.entries(n).some(([,i])=>!!i)?!0:e.unsetMark(this.name)}}}});var xp=Me.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;return(e=t.style.color)===null||e===void 0?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}}}}]},addCommands(){return{setColor:t=>({chain:e})=>e().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}});var kp=z.create({name:"doc",topNode:!0,content:"block+"});function Mp(t={}){return new me({view(e){return new Bl(e,t)}})}var Bl=class{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let o=s=>{this[i](s)};return e.dom.addEventListener(i,o),{name:i,handler:o}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r;if(n){let a=e.nodeBefore,l=e.nodeAfter;if(a||l){let c=this.editorView.nodeDOM(this.cursorPos-(a?a.nodeSize:0));if(c){let u=c.getBoundingClientRect(),d=a?u.bottom:u.top;a&&l&&(d=(d+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2),r={left:u.left,right:u.right,top:d-this.width/2,bottom:d+this.width/2}}}}if(!r){let a=this.editorView.coordsAtPos(this.cursorPos);r={left:a.left-this.width/2,right:a.left+this.width/2,top:a.top,bottom:a.bottom}}let i=this.editorView.dom.offsetParent;this.element||(this.element=i.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let o,s;if(!i||i==document.body&&getComputedStyle(i).position=="static")o=-pageXOffset,s=-pageYOffset;else{let a=i.getBoundingClientRect();o=a.left-i.scrollLeft,s=a.top-i.scrollTop}this.element.style.left=r.left-o+"px",this.element.style.top=r.top-s+"px",this.element.style.width=r.right-r.left+"px",this.element.style.height=r.bottom-r.top+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),i=r&&r.type.spec.disableDropCursor,o=typeof i=="function"?i(this.editorView,n,e):i;if(n&&!o){let s=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let a=So(this.editorView.state.doc,s,this.editorView.dragging.slice);a!=null&&(s=a)}this.setCursor(s),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){(e.target==this.editorView.dom||!this.editorView.dom.contains(e.relatedTarget))&&this.setCursor(null)}};var Tp=Me.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[Mp(this.options)]}});var Ne=class extends V{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return Ne.valid(r)?new Ne(r):V.near(r)}content(){return R.empty}eq(e){return e instanceof Ne&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new Ne(e.resolve(n.pos))}getBookmark(){return new Hi(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!hv(e)||!mv(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let i=n.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&Ne.valid(e))return e;let i=e.pos,o=null;for(let s=e.depth;;s--){let a=e.node(s);if(n>0?e.indexAfter(s)0){o=a.child(n>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;i+=n;let l=e.doc.resolve(i);if(Ne.valid(l))return l}for(;;){let s=n>0?o.firstChild:o.lastChild;if(!s){if(o.isAtom&&!o.isText&&!G.isSelectable(o)){e=e.doc.resolve(i+o.nodeSize*n),r=!1;continue e}break}o=s,i+=n;let a=e.doc.resolve(i);if(Ne.valid(a))return a}return null}}};Ne.prototype.visible=!1;Ne.findFrom=Ne.findGapCursorFrom;V.jsonID("gapcursor",Ne);var Hi=class{constructor(e){this.pos=e}map(e){return new Hi(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return Ne.valid(n)?new Ne(n):V.near(n)}};function hv(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(n-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||i.isAtom||i.type.spec.isolating)return!0;if(i.inlineContent)return!1}}return!0}function mv(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(n);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||i.isAtom||i.type.spec.isolating)return!0;if(i.inlineContent)return!1}}return!0}function Np(){return new me({props:{decorations:Ev,createSelectionBetween(t,e,n){return e.pos==n.pos&&Ne.valid(n)?new Ne(n):null},handleClick:bv,handleKeyDown:gv,handleDOMEvents:{beforeinput:yv}}})}var gv=Di({ArrowLeft:jo("horiz",-1),ArrowRight:jo("horiz",1),ArrowUp:jo("vert",-1),ArrowDown:jo("vert",1)});function jo(t,e){let n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,o){let s=r.selection,a=e>0?s.$to:s.$from,l=s.empty;if(s instanceof $){if(!o.endOfTextblock(n)||a.depth==0)return!1;l=!1,a=r.doc.resolve(e>0?a.after():a.before())}let c=Ne.findGapCursorFrom(a,e,l);return c?(i&&i(r.tr.setSelection(new Ne(c))),!0):!1}}function bv(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!Ne.valid(r))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&G.isSelectable(t.state.doc.nodeAt(i.inside))?!1:(t.dispatch(t.state.tr.setSelection(new Ne(r))),!0)}function yv(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof Ne))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let i=k.empty;for(let s=r.length-1;s>=0;s--)i=k.from(r[s].createAndFill(null,i));let o=t.state.tr.replace(n.pos,n.pos,new R(i,0,0));return o.setSelection($.near(o.doc.resolve(n.pos+1))),t.dispatch(o),!1}function Ev(t){if(!(t.selection instanceof Ne))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",Se.create(t.doc,[De.widget(t.selection.head,e,{key:"gapcursor"})])}var _p=Me.create({name:"gapCursor",addProseMirrorPlugins(){return[Np()]},extendNodeSchema(t){var e;let n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=ee(H(t,"allowGapCursor",n)))!==null&&e!==void 0?e:null}}});var Cp=z.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",B(this.options.HTMLAttributes,t)]},renderText(){return`
-`},addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{let{selection:i,storedMarks:o}=n;if(i.$from.parent.type.spec.isolating)return!1;let{keepMarks:s}=this.options,{splittableMarks:a}=r.extensionManager,l=o||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:u})=>{if(u&&l&&s){let d=l.filter(f=>a.includes(f.type.name));c.ensureMarks(d)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}});var Op=z.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,B(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>Bi({find:new RegExp(`^(#{1,${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}});var Yo=200,Je=function(){};Je.prototype.append=function(e){return e.length?(e=Je.from(e),!this.length&&e||e.length=n?Je.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};Je.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Je.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)};Je.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(o,s){return i.push(e(o,s))},n,r),i};Je.from=function(e){return e instanceof Je?e:e&&e.length?new Ap(e):Je.empty};var Ap=function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,o){return i==0&&o==this.length?this:new e(this.values.slice(i,o))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,o,s,a){for(var l=o;l=s;l--)if(i(this.values[l],a+l)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=Yo)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=Yo)return new e(i.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e}(Je);Je.empty=new Ap([]);var wv=function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return ra&&this.right.forEachInner(r,Math.max(i-a,0),Math.min(this.length,o)-a,s+a)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,o,s){var a=this.left.length;if(i>a&&this.right.forEachInvertedInner(r,i-a,Math.max(o,a)-a,s+a)===!1||o=o?this.right.slice(r-o,i-o):this.left.slice(r,o).append(this.right.slice(0,i-o))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e}(Je),Hl=Je;var vv=500,kt=class{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,o;n&&(i=this.remapping(r,this.items.length),o=i.maps.length);let s=e.tr,a,l,c=[],u=[];return this.items.forEach((d,f)=>{if(!d.step){i||(i=this.remapping(r,f+1),o=i.maps.length),o--,u.push(d);return}if(i){u.push(new At(d.map));let p=d.step.map(i.slice(o)),h;p&&s.maybeStep(p).doc&&(h=s.mapping.maps[s.mapping.maps.length-1],c.push(new At(h,void 0,void 0,c.length+u.length))),o--,h&&i.appendMap(h,o)}else s.maybeStep(d.step);if(d.selection)return a=i?d.selection.map(i.slice(o)):d.selection,l=new kt(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:l,transform:s,selection:a}}addTransform(e,n,r,i){let o=[],s=this.eventCount,a=this.items,l=!i&&a.length?a.get(a.length-1):null;for(let u=0;uxv&&(a=Sv(a,c),s-=c),new kt(a.append(o),s)}remapping(e,n){let r=new pn;return this.items.forEach((i,o)=>{let s=i.mirrorOffset!=null&&o-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,s)},e,n),r}addMaps(e){return this.eventCount==0?this:new kt(this.items.append(e.map(n=>new At(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),o=e.mapping,s=e.steps.length,a=this.eventCount;this.items.forEach(f=>{f.selection&&a--},i);let l=n;this.items.forEach(f=>{let p=o.getMirror(--l);if(p==null)return;s=Math.min(s,p);let h=o.maps[p];if(f.step){let m=e.steps[p].invert(e.docs[p]),g=f.selection&&f.selection.map(o.slice(l+1,p));g&&a++,r.push(new At(h,m,g))}else r.push(new At(h))},i);let c=[];for(let f=n;fvv&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,i=[],o=0;return this.items.forEach((s,a)=>{if(a>=e)i.push(s),s.selection&&o++;else if(s.step){let l=s.step.map(n.slice(r)),c=l&&l.getMap();if(r--,c&&n.appendMap(c,r),l){let u=s.selection&&s.selection.map(n.slice(r));u&&o++;let d=new At(c.invert(),l,u),f,p=i.length-1;(f=i.length&&i[p].merge(d))?i[p]=f:i.push(d)}}else s.map&&r--},this.items.length,0),new kt(Hl.from(i.reverse()),o)}};kt.empty=new kt(Hl.empty,0);function Sv(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}var At=class{constructor(e,n,r,i){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new At(n.getMap().invert(),n,this.selection)}}},on=class{constructor(e,n,r,i,o){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=o}},xv=20;function kv(t,e,n,r){let i=n.getMeta(Fn),o;if(i)return i.historyState;n.getMeta(Tv)&&(t=new on(t.done,t.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(s&&s.getMeta(Fn))return s.getMeta(Fn).redo?new on(t.done.addTransform(n,void 0,r,Jo(e)),t.undone,Rp(n.mapping.maps[n.steps.length-1]),t.prevTime,t.prevComposition):new on(t.done,t.undone.addTransform(n,void 0,r,Jo(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let a=n.getMeta("composition"),l=t.prevTime==0||!s&&t.prevComposition!=a&&(t.prevTime<(n.time||0)-r.newGroupDelay||!Mv(n,t.prevRanges)),c=s?Fl(t.prevRanges,n.mapping):Rp(n.mapping.maps[n.steps.length-1]);return new on(t.done.addTransform(n,l?e.selection.getBookmark():void 0,r,Jo(e)),kt.empty,c,n.time,a??t.prevComposition)}else return(o=n.getMeta("rebased"))?new on(t.done.rebased(n,o),t.undone.rebased(n,o),Fl(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new on(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Fl(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function Mv(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,i)=>{for(let o=0;o=e[o]&&(n=!0)}),n}function Rp(t){let e=[];return t.forEach((n,r,i,o)=>e.push(i,o)),e}function Fl(t,e){if(!t)return null;let n=[];for(let r=0;r{let n=Fn.getState(t);return!n||n.done.eventCount==0?!1:(e&&Dp(n,t,e,!1),!0)},$l=(t,e)=>{let n=Fn.getState(t);return!n||n.undone.eventCount==0?!1:(e&&Dp(n,t,e,!0),!0)};var Pp=Me.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>Ul(t,e),redo:()=>({state:t,dispatch:e})=>$l(t,e)}},addProseMirrorPlugins(){return[Lp(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Mod-y":()=>this.editor.commands.redo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-\u044F":()=>this.editor.commands.undo(),"Shift-Mod-\u044F":()=>this.editor.commands.redo()}}});var Bp=z.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",B(this.options.HTMLAttributes,t)]},addCommands(){return{setHorizontalRule:()=>({chain:t})=>t().insertContent({type:this.name}).command(({tr:e,dispatch:n})=>{var r;if(n){let{$to:i}=e.selection,o=i.end();if(i.nodeAfter)e.setSelection($.create(e.doc,i.pos));else{let s=(r=i.parent.type.contentMatch.defaultType)===null||r===void 0?void 0:r.create();s&&(e.insert(o,s),e.setSelection($.create(e.doc,o)))}e.scrollIntoView()}return!0}).run()}},addInputRules(){return[qo({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}});var Nv=/(?:^|\s)((?:\*)((?:[^*]+))(?:\*))$/,_v=/(?:^|\s)((?:\*)((?:[^*]+))(?:\*))/g,Cv=/(?:^|\s)((?:_)((?:[^_]+))(?:_))$/,Ov=/(?:^|\s)((?:_)((?:[^_]+))(?:_))/g,Hp=be.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",B(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Ot({find:Nv,type:this.type}),Ot({find:Cv,type:this.type})]},addPasteRules(){return[yt({find:_v,type:this.type}),yt({find:Ov,type:this.type})]}});var Kl=z.create({name:"listItem",addOptions(){return{HTMLAttributes:{}}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",B(this.options.HTMLAttributes,t),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}});var Av=z.create({name:"listItem",addOptions(){return{HTMLAttributes:{}}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",B(this.options.HTMLAttributes,t),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),Fp=be.create({name:"textStyle",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"span",getAttrs:t=>t.hasAttribute("style")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["span",B(this.options.HTMLAttributes,t),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:t,commands:e})=>{let n=Bn(t,this.type);return Object.entries(n).some(([,i])=>!!i)?!0:e.unsetMark(this.name)}}}}),zp=/^(\d+)\.\s$/,Up=z.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){let{start:e,...n}=t;return e===1?["ol",B(this.options.HTMLAttributes,n),0]:["ol",B(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Av.name,this.editor.getAttributes(Fp.name)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=Hn({find:zp,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Hn({find:zp,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Fp.name)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}});var Rv=/(?:^|\s)((?:~~)((?:[^~]+))(?:~~))$/,Iv=/(?:^|\s)((?:~~)((?:[^~]+))(?:~~))/g,$p=be.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",B(this.options.HTMLAttributes,t),0]},addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-x":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Ot({find:Rv,type:this.type})]},addPasteRules(){return[yt({find:Iv,type:this.type})]}});var Kp=be.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(t){return t!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sub",B(this.options.HTMLAttributes,t),0]},addCommands(){return{setSubscript:()=>({commands:t})=>t.setMark(this.name),toggleSubscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSubscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}});var Wp=be.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(t){return t!=="super"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sup",B(this.options.HTMLAttributes,t),0]},addCommands(){return{setSuperscript:()=>({commands:t})=>t.setMark(this.name),toggleSuperscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSuperscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}});var Vl,Gl;if(typeof WeakMap<"u"){let t=new WeakMap;Vl=e=>t.get(e),Gl=(e,n)=>(t.set(e,n),n)}else{let t=[],n=0;Vl=r=>{for(let i=0;i(n==10&&(n=0),t[n++]=r,t[n++]=i)}var Ae=class{constructor(t,e,n,r){this.width=t,this.height=e,this.map=n,this.problems=r}findCell(t){for(let e=0;e=n){(o||(o=[])).push({type:"overlong_rowspan",pos:u,n:y-M});break}let b=i+M*e;for(let _=0;_r&&(o+=c.attrs.colspan)}}for(let s=0;s1&&(n=!0)}e==-1?e=o:e!=o&&(e=Math.max(e,o))}return e}function Pv(t,e,n){t.problems||(t.problems=[]);let r={};for(let i=0;i0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function Hv(t){for(let e=t.depth;e>0;e--){let n=t.node(e).type.spec.tableRole;if(n==="cell"||n==="header_cell")return t.node(e)}return null}function Kt(t){let e=t.selection.$head;for(let n=e.depth;n>0;n--)if(e.node(n).type.spec.tableRole=="row")return!0;return!1}function ns(t){let e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;let n=Jr(e.$head)||Fv(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function Fv(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function ql(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function zv(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function Jl(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function Qp(t,e,n){let r=t.node(-1),i=Ae.get(r),o=t.start(-1),s=i.nextCell(t.pos-o,e,n);return s==null?null:t.node(0).resolve(o+s)}function pr(t,e,n=1){let r={...t,colspan:t.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some(i=>i>0)||(r.colwidth=null)),r}function eh(t,e,n=1){let r={...t,colspan:t.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let i=0;ic!=e.pos-i);a.unshift(e.pos-i);let l=a.map(c=>{let u=n.nodeAt(c);if(!u)throw RangeError(`No cell with offset ${c} found`);let d=i+c+1;return new xi(s.resolve(d),s.resolve(d+u.content.size))});super(l[0].$from,l[0].$to,l),this.$anchorCell=t,this.$headCell=e}map(t,e){let n=t.resolve(e.map(this.$anchorCell.pos)),r=t.resolve(e.map(this.$headCell.pos));if(ql(n)&&ql(r)&&Jl(n,r)){let i=this.$anchorCell.node(-1)!=n.node(-1);return i&&this.isRowSelection()?pe.rowSelection(n,r):i&&this.isColSelection()?pe.colSelection(n,r):new pe(n,r)}return $.between(n,r)}content(){let t=this.$anchorCell.node(-1),e=Ae.get(t),n=this.$anchorCell.start(-1),r=e.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),i={},o=[];for(let a=r.top;a0||m>0){let g=p.attrs;if(h>0&&(g=pr(g,0,h)),m>0&&(g=pr(g,g.colspan-m,m)),f.leftr.bottom){let g={...p.attrs,rowspan:Math.min(f.bottom,r.bottom)-Math.max(f.top,r.top)};f.top0)return!1;let n=t+this.$anchorCell.nodeAfter.attrs.rowspan,r=e+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,r)==this.$headCell.node(-1).childCount}static colSelection(t,e=t){let n=t.node(-1),r=Ae.get(n),i=t.start(-1),o=r.findCell(t.pos-i),s=r.findCell(e.pos-i),a=t.node(0);return o.top<=s.top?(o.top>0&&(t=a.resolve(i+r.map[o.left])),s.bottom0&&(e=a.resolve(i+r.map[s.left])),o.bottom0)return!1;let o=r+this.$anchorCell.nodeAfter.attrs.colspan,s=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(o,s)==e.width}eq(t){return t instanceof pe&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,e=t){let n=t.node(-1),r=Ae.get(n),i=t.start(-1),o=r.findCell(t.pos-i),s=r.findCell(e.pos-i),a=t.node(0);return o.left<=s.left?(o.left>0&&(t=a.resolve(i+r.map[o.top*r.width])),s.right0&&(e=a.resolve(i+r.map[s.top*r.width])),o.right{e.push(De.node(r,r+n.nodeSize,{class:"selectedCell"}))}),Se.create(t.doc,e)}function Kv({$from:t,$to:e}){if(t.pos==e.pos||t.pos=0&&!(t.after(i+1)=0&&!(e.before(o+1)>e.start(o));o--,r--);return n==r&&/row|table/.test(t.node(i).type.spec.tableRole)}function Wv({$from:t,$to:e}){let n,r;for(let i=t.depth;i>0;i--){let o=t.node(i);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){n=o;break}}for(let i=e.depth;i>0;i--){let o=e.node(i);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){r=o;break}}return n!==r&&e.parentOffset===0}function Vv(t,e,n){let r=(e||t).selection,i=(e||t).doc,o,s;if(r instanceof G&&(s=r.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")o=pe.create(i,r.from);else if(s=="row"){let a=i.resolve(r.from+1);o=pe.rowSelection(a,a)}else if(!n){let a=Ae.get(r.node),l=r.from+1,c=l+a.map[a.width*a.height-1];o=pe.create(i,l+1,c)}}else r instanceof $&&Kv(r)?o=$.create(i,r.from):r instanceof $&&Wv(r)&&(o=$.create(i,r.$from.start(),r.$from.end()));return o&&(e||(e=t.tr)).setSelection(o),e}var Gv=new ve("fix-tables");function nh(t,e,n,r){let i=t.childCount,o=e.childCount;e:for(let s=0,a=0;s{i.type.spec.tableRole=="table"&&(n=qv(t,i,o,n))};return e?e.doc!=t.doc&&nh(e.doc,t.doc,0,r):t.doc.descendants(r),n}function qv(t,e,n,r){let i=Ae.get(e);if(!i.problems)return r;r||(r=t.tr);let o=[];for(let l=0;l0){let p="cell";u.firstChild&&(p=u.firstChild.type.spec.tableRole);let h=[];for(let g=0;g0&&r>0||e.child(0).type.spec.tableRole=="table");)n--,r--,e=e.child(0).content;let i=e.child(0),o=i.type.spec.tableRole,s=i.type.schema,a=[];if(o=="row")for(let l=0;l=0;s--){let{rowspan:a,colspan:l}=o.child(s).attrs;for(let c=i;c=e.length&&e.push(k.empty),n[i]r&&(f=f.type.createChecked(pr(f.attrs,f.attrs.colspan,u+f.attrs.colspan-r),f.content)),c.push(f),u+=f.attrs.colspan;for(let p=1;pi&&(d=d.type.create({...d.attrs,rowspan:Math.max(1,i-d.attrs.rowspan)},d.content)),l.push(d)}o.push(k.from(l))}n=o,e=i}return{width:t,height:e,rows:n}}function Xv(t,e,n,r,i,o,s){let a=t.doc.type.schema,l=it(a),c,u;if(i>e.width)for(let d=0,f=0;de.height){let d=[];for(let h=0,m=(e.height-1)*e.width;h=e.width?!1:n.nodeAt(e.map[m+h]).type==l.header_cell;d.push(g?u||(u=l.header_cell.createAndFill()):c||(c=l.cell.createAndFill()))}let f=l.row.create(null,k.from(d)),p=[];for(let h=e.height;h{if(!i)return!1;let o=n.selection;if(o instanceof pe)return es(n,r,V.near(o.$headCell,e));if(t!="horiz"&&!o.empty)return!1;let s=rh(i,t,e);if(s==null)return!1;if(t=="horiz")return es(n,r,V.near(n.doc.resolve(o.head+e),e));{let a=n.doc.resolve(s),l=Qp(a,t,e),c;return l?c=V.near(l,1):e<0?c=V.near(n.doc.resolve(a.before(-1)),-1):c=V.near(n.doc.resolve(a.after(-1)),1),es(n,r,c)}}}function Zo(t,e){return(n,r,i)=>{if(!i)return!1;let o=n.selection,s;if(o instanceof pe)s=o;else{let l=rh(i,t,e);if(l==null)return!1;s=new pe(n.doc.resolve(l))}let a=Qp(s.$headCell,t,e);return a?es(n,r,new pe(s.$anchorCell,a)):!1}}function Qo(t,e){let n=t.selection;if(!(n instanceof pe))return!1;if(e){let r=t.tr,i=it(t.schema).cell.createAndFill().content;n.forEachCell((o,s)=>{o.content.eq(i)||r.replace(r.mapping.map(s+1),r.mapping.map(s+o.nodeSize-1),new R(i,0,0))}),r.docChanged&&e(r)}return!0}function Qv(t,e){let n=t.state.doc,r=Jr(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new pe(r))),!0):!1}function eS(t,e,n){if(!Kt(t.state))return!1;let r=jv(n),i=t.state.selection;if(i instanceof pe){r||(r={width:1,height:1,rows:[k.from(jl(it(t.state.schema).cell,n))]});let o=i.$anchorCell.node(-1),s=i.$anchorCell.start(-1),a=Ae.get(o).rectBetween(i.$anchorCell.pos-s,i.$headCell.pos-s);return r=Jv(r,a.right-a.left,a.bottom-a.top),qp(t.state,t.dispatch,s,a,r),!0}else if(r){let o=ns(t.state),s=o.start(-1);return qp(t.state,t.dispatch,s,Ae.get(o.node(-1)).findCell(o.pos-s),r),!0}else return!1}function tS(t,e){var n;if(e.ctrlKey||e.metaKey)return;let r=jp(t,e.target),i;if(e.shiftKey&&t.state.selection instanceof pe)o(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(i=Jr(t.state.selection.$anchor))!=null&&((n=Wl(t,e))==null?void 0:n.pos)!=i.pos)o(i,e),e.preventDefault();else if(!r)return;function o(l,c){let u=Wl(t,c),d=zn.getState(t.state)==null;if(!u||!Jl(l,u))if(d)u=l;else return;let f=new pe(l,u);if(d||!t.state.selection.eq(f)){let p=t.state.tr.setSelection(f);d&&p.setMeta(zn,l.pos),t.dispatch(p)}}function s(){t.root.removeEventListener("mouseup",s),t.root.removeEventListener("dragstart",s),t.root.removeEventListener("mousemove",a),zn.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(zn,-1))}function a(l){let c=l,u=zn.getState(t.state),d;if(u!=null)d=t.state.doc.resolve(u);else if(jp(t,c.target)!=r&&(d=Wl(t,e),!d))return s();d&&o(d,c)}t.root.addEventListener("mouseup",s),t.root.addEventListener("dragstart",s),t.root.addEventListener("mousemove",a)}function rh(t,e,n){if(!(t.state.selection instanceof $))return null;let{$head:r}=t.state.selection;for(let i=r.depth-1;i>=0;i--){let o=r.node(i);if((n<0?r.index(i):r.indexAfter(i))!=(n<0?0:o.childCount))return null;if(o.type.spec.tableRole=="cell"||o.type.spec.tableRole=="header_cell"){let a=r.before(i),l=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(l)?a:null}}return null}function jp(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Wl(t,e){let n=t.posAtCoords({left:e.clientX,top:e.clientY});return n&&n?Jr(t.state.doc.resolve(n.pos)):null}var nS=class{constructor(t,e){this.node=t,this.cellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Yl(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!=this.node.type?!1:(this.node=t,Yl(t,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(t){return t.type=="attributes"&&(t.target==this.table||this.colgroup.contains(t.target))}};function Yl(t,e,n,r,i,o){var s;let a=0,l=!0,c=e.firstChild,u=t.firstChild;if(u){for(let d=0,f=0;dnew n(a,e,l),new ts(-1,!1)},apply(o,s){return s.apply(o)}},props:{attributes:o=>{let s=Rt.getState(o);return s&&s.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(o,s)=>{rS(o,s,t,e,r)},mouseleave:o=>{iS(o)},mousedown:(o,s)=>{oS(o,s,e)}},decorations:o=>{let s=Rt.getState(o);if(s&&s.activeHandle>-1)return dS(o,s.activeHandle)},nodeViews:{}}});return i}var ts=class{constructor(t,e){this.activeHandle=t,this.dragging=e}apply(t){let e=this,n=t.getMeta(Rt);if(n&&n.setHandle!=null)return new ts(n.setHandle,!1);if(n&&n.setDragging!==void 0)return new ts(e.activeHandle,n.setDragging);if(e.activeHandle>-1&&t.docChanged){let r=t.mapping.map(e.activeHandle,-1);return ql(t.doc.resolve(r))||(r=-1),new ts(r,e.dragging)}return e}};function rS(t,e,n,r,i){let o=Rt.getState(t.state);if(o&&!o.dragging){let s=aS(e.target),a=-1;if(s){let{left:l,right:c}=s.getBoundingClientRect();e.clientX-l<=n?a=Yp(t,e,"left",n):c-e.clientX<=n&&(a=Yp(t,e,"right",n))}if(a!=o.activeHandle){if(!i&&a!==-1){let l=t.state.doc.resolve(a),c=l.node(-1),u=Ae.get(c),d=l.start(-1);if(u.colCount(l.pos-d)+l.nodeAfter.attrs.colspan-1==u.width-1)return}oh(t,a)}}}function iS(t){let e=Rt.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&oh(t,-1)}function oS(t,e,n){let r=Rt.getState(t.state);if(!r||r.activeHandle==-1||r.dragging)return!1;let i=t.state.doc.nodeAt(r.activeHandle),o=sS(t,r.activeHandle,i.attrs);t.dispatch(t.state.tr.setMeta(Rt,{setDragging:{startX:e.clientX,startWidth:o}}));function s(l){window.removeEventListener("mouseup",s),window.removeEventListener("mousemove",a);let c=Rt.getState(t.state);c?.dragging&&(lS(t,c.activeHandle,Jp(c.dragging,l,n)),t.dispatch(t.state.tr.setMeta(Rt,{setDragging:null})))}function a(l){if(!l.which)return s(l);let c=Rt.getState(t.state);if(c&&c.dragging){let u=Jp(c.dragging,l,n);cS(t,c.activeHandle,u,n)}}return window.addEventListener("mouseup",s),window.addEventListener("mousemove",a),e.preventDefault(),!0}function sS(t,e,{colspan:n,colwidth:r}){let i=r&&r[r.length-1];if(i)return i;let o=t.domAtPos(e),a=o.node.childNodes[o.offset].offsetWidth,l=n;if(r)for(let c=0;c0?-1:0;Uv(e,r,i+o)&&(o=i==0||i==e.width?null:0);for(let s=0;s0&&i0&&e.map[a-1]==l||i0?-1:0;pS(e,r,i+l)&&(l=i==0||i==e.height?null:0);for(let c=0,u=e.width*i;c0&&i0&&u==e.map[c-e.width]){let d=n.nodeAt(u).attrs;t.setNodeMarkup(t.mapping.slice(a).map(u+r),null,{...d,rowspan:d.rowspan-1}),l+=d.colspan-1}else if(i0&&n[o]==n[o-1]||r.right0&&n[i]==n[i-t]||r.bottomn[r.type.spec.tableRole])(t,e)}function gS(t){return(e,n)=>{var r;let i=e.selection,o,s;if(i instanceof pe){if(i.$anchorCell.pos!=i.$headCell.pos)return!1;o=i.$anchorCell.nodeAfter,s=i.$anchorCell.pos}else{if(o=Hv(i.$from),!o)return!1;s=(r=Jr(i.$from))==null?void 0:r.pos}if(o==null||s==null||o.attrs.colspan==1&&o.attrs.rowspan==1)return!1;if(n){let a=o.attrs,l=[],c=a.colwidth;a.rowspan>1&&(a={...a,rowspan:1}),a.colspan>1&&(a={...a,colspan:1});let u=sn(e),d=e.tr;for(let p=0;p{s.attrs[t]!==e&&o.setNodeMarkup(a,null,{...s.attrs,[t]:e})}):o.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[t]:e}),r(o)}return!0}}function bS(t){return function(e,n){if(!Kt(e))return!1;if(n){let r=it(e.schema),i=sn(e),o=e.tr,s=i.map.cellsInRect(t=="column"?{left:i.left,top:0,right:i.right,bottom:i.map.height}:t=="row"?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),a=s.map(l=>i.table.nodeAt(l));for(let l=0;l{let h=p+o.tableStart,m=s.doc.nodeAt(h);m&&s.setNodeMarkup(h,f,m.attrs)}),r(s)}return!0}}var W_=Xr("row",{useDeprecatedLogic:!0}),V_=Xr("column",{useDeprecatedLogic:!0}),mh=Xr("cell",{useDeprecatedLogic:!0});function yS(t,e){if(e<0){let n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let r=t.index(-1)-1,i=t.before();r>=0;r--){let o=t.node(-1).child(r),s=o.lastChild;if(s)return i-1-s.nodeSize;i-=o.nodeSize}}else{if(t.index()0;r--)if(n.node(r).type.spec.tableRole=="table")return e&&e(t.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function bh({allowTableNodeSelection:t=!1}={}){return new me({key:zn,state:{init(){return null},apply(e,n){let r=e.getMeta(zn);if(r!=null)return r==-1?null:r;if(n==null||!e.docChanged)return n;let{deleted:i,pos:o}=e.mapping.mapResult(n);return i?null:o}},props:{decorations:$v,handleDOMEvents:{mousedown:tS},createSelectionBetween(e){return zn.getState(e.state)!=null?e.state.selection:null},handleTripleClick:Qv,handleKeyDown:Zv,handlePaste:eS},appendTransaction(e,n,r){return Vv(r,Xl(r,n),t)}})}function yh(t,e,n,r,i,o){let s=0,a=!0,l=e.firstChild,c=t.firstChild;for(let u=0,d=0;u{let r=t.nodes[n];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),t.cached.tableNodeTypes=e,e}function wS(t,e,n,r,i){let o=ES(t),s=[],a=[];for(let c=0;c{let{selection:e}=t.state;if(!vS(e))return!1;let n=0,r=Ll(e.ranges[0].$from,o=>o.type.name==="table");return r?.node.descendants(o=>{if(o.type.name==="table")return!1;["tableCell","tableHeader"].includes(o.type.name)&&(n+=1)}),n===e.ranges.length?(t.commands.deleteTable(),!0):!1},wh=z.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,handleWidth:5,cellMinWidth:25,View:tc,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({HTMLAttributes:t}){return["table",B(this.options.HTMLAttributes,t),["tbody",0]]},addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:i,editor:o})=>{let s=wS(o.schema,t,e,n);if(i){let a=r.selection.anchor+1;r.replaceSelectionWith(s).scrollIntoView().setSelection($.near(r.doc.resolve(a)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>ah(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>lh(t,e),deleteColumn:()=>({state:t,dispatch:e})=>ch(t,e),addRowBefore:()=>({state:t,dispatch:e})=>dh(t,e),addRowAfter:()=>({state:t,dispatch:e})=>fh(t,e),deleteRow:()=>({state:t,dispatch:e})=>ph(t,e),deleteTable:()=>({state:t,dispatch:e})=>gh(t,e),mergeCells:()=>({state:t,dispatch:e})=>Zl(t,e),splitCell:()=>({state:t,dispatch:e})=>Ql(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>Xr("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>Xr("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>mh(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>Zl(t,e)?!0:Ql(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>hh(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>ec(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>ec(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&Xl(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){let r=pe.create(e.doc,t.anchorCell,t.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:rs,"Mod-Backspace":rs,Delete:rs,"Mod-Delete":rs}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[ih({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],bh({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){let e={name:t.name,options:t.options,storage:t.storage};return{tableRole:ee(H(t,"tableRole",e))}}});var vh=z.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{let e=t.getAttribute("colwidth");return e?[parseInt(e,10)]:null}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",B(this.options.HTMLAttributes,t),0]}});var Sh=z.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{let e=t.getAttribute("colwidth");return e?[parseInt(e,10)]:null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",B(this.options.HTMLAttributes,t),0]}});var xh=z.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",B(this.options.HTMLAttributes,t),0]}});var kh=z.create({name:"text",group:"inline"});var Mh=be.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",B(this.options.HTMLAttributes,t),0]},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});var SS=/(?:^|\s)((?:==)((?:[^~=]+))(?:==))$/,xS=/(?:^|\s)((?:==)((?:[^~=]+))(?:==))/g,Th=be.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:t=>t.getAttribute("data-color")||t.style.backgroundColor,renderHTML:t=>t.color?{"data-color":t.color,style:`background-color: ${t.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:t}){return["mark",B(this.options.HTMLAttributes,t),0]},addCommands(){return{setHighlight:t=>({commands:e})=>e.setMark(this.name,t),toggleHighlight:t=>({commands:e})=>e.toggleMark(this.name,t),unsetHighlight:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[Ot({find:SS,type:this.type})]},addPasteRules(){return[yt({find:xS,type:this.type})]}});var nc=z.create({name:"checkedList",priority:50,addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{class:"checked-list"}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul",getAttrs:t=>t.classList.contains("checked-list"),priority:1e3}]},renderHTML({HTMLAttributes:t}){return["ul",B(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleCheckedList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}}});var rc=z.create({name:"lead",group:"block",content:"block+",addOptions(){return{HTMLAttributes:{class:"lead"}}},parseHTML(){return[{tag:"div",getAttrs:t=>t.classList.contains("lead")}]},renderHTML({node:t,HTMLAttributes:e}){return["div",B(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleLead:()=>({commands:t})=>t.toggleWrap(this.name)}}});var kS="aaa1rp3barth4b0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0faromeo7ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4vianca6w0s2x0a2z0ure5ba0by2idu3namex3narepublic11d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2ntley5rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re2s2c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y0eats7k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0cast4mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking0channel11l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dabur3d1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t0isalat7u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0at2delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d0network8tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntdoor4ier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0ardian6cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5gtv3iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0eles2s3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6logistics9properties14fh2g1h1i0a1ds2m1nder2le4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3ncaster5ia3d0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4de2k2psy3ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0cys3drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7serati6ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic3tual5v1w1x1y1z2na0b1goya4me2tura4vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rthwesternmutual14on4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9dnavy5lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3ssagens7y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0america6xi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cher3ks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0a1b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp2w2ell3ia1ksha5oes2p0ping5uji3w0time7i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ffany5ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0channel7ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5m\xF6gensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lkswagen7vo3te1ing3o2yage5u0elos6wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4finity6ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",MS="\u03B5\u03BB1\u03C52\u0431\u04331\u0435\u043B3\u0434\u0435\u0442\u04384\u0435\u044E2\u043A\u0430\u0442\u043E\u043B\u0438\u043A6\u043E\u043C3\u043C\u043A\u04342\u043E\u043D1\u0441\u043A\u0432\u04306\u043E\u043D\u043B\u0430\u0439\u043D5\u0440\u04333\u0440\u0443\u04412\u04442\u0441\u0430\u0439\u04423\u0440\u04313\u0443\u043A\u04403\u049B\u0430\u04373\u0570\u0561\u05753\u05D9\u05E9\u05E8\u05D0\u05DC5\u05E7\u05D5\u05DD3\u0627\u0628\u0648\u0638\u0628\u064A5\u062A\u0635\u0627\u0644\u0627\u062A6\u0631\u0627\u0645\u0643\u06485\u0644\u0627\u0631\u062F\u06464\u0628\u062D\u0631\u064A\u06465\u062C\u0632\u0627\u0626\u06315\u0633\u0639\u0648\u062F\u064A\u06296\u0639\u0644\u064A\u0627\u06465\u0645\u063A\u0631\u06285\u0645\u0627\u0631\u0627\u062A5\u06CC\u0631\u0627\u06465\u0628\u0627\u0631\u062A2\u0632\u0627\u06314\u064A\u062A\u06433\u06BE\u0627\u0631\u062A5\u062A\u0648\u0646\u06334\u0633\u0648\u062F\u0627\u06463\u0631\u064A\u06295\u0634\u0628\u0643\u06294\u0639\u0631\u0627\u06422\u06282\u0645\u0627\u06464\u0641\u0644\u0633\u0637\u064A\u06466\u0642\u0637\u06313\u0643\u0627\u062B\u0648\u0644\u064A\u06436\u0648\u06453\u0645\u0635\u06312\u0644\u064A\u0633\u064A\u06275\u0648\u0631\u064A\u062A\u0627\u0646\u064A\u06277\u0642\u06394\u0647\u0645\u0631\u0627\u06475\u067E\u0627\u06A9\u0633\u062A\u0627\u06467\u0680\u0627\u0631\u062A4\u0915\u0949\u092E3\u0928\u0947\u091F3\u092D\u093E\u0930\u09240\u092E\u094D3\u094B\u09245\u0938\u0902\u0917\u0920\u09285\u09AC\u09BE\u0982\u09B2\u09BE5\u09AD\u09BE\u09B0\u09A42\u09F0\u09A44\u0A2D\u0A3E\u0A30\u0A244\u0AAD\u0ABE\u0AB0\u0AA44\u0B2D\u0B3E\u0B30\u0B244\u0B87\u0BA8\u0BCD\u0BA4\u0BBF\u0BAF\u0BBE6\u0BB2\u0B99\u0BCD\u0B95\u0BC86\u0B9A\u0BBF\u0B99\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0BC2\u0BB0\u0BCD11\u0C2D\u0C3E\u0C30\u0C24\u0C4D5\u0CAD\u0CBE\u0CB0\u0CA44\u0D2D\u0D3E\u0D30\u0D24\u0D025\u0DBD\u0D82\u0D9A\u0DCF4\u0E04\u0E2D\u0E213\u0E44\u0E17\u0E223\u0EA5\u0EB2\u0EA73\u10D2\u10D42\u307F\u3093\u306A3\u30A2\u30DE\u30BE\u30F34\u30AF\u30E9\u30A6\u30C94\u30B0\u30FC\u30B0\u30EB4\u30B3\u30E02\u30B9\u30C8\u30A23\u30BB\u30FC\u30EB3\u30D5\u30A1\u30C3\u30B7\u30E7\u30F36\u30DD\u30A4\u30F3\u30C84\u4E16\u754C2\u4E2D\u4FE11\u56FD1\u570B1\u6587\u7F513\u4E9A\u9A6C\u900A3\u4F01\u4E1A2\u4F5B\u5C712\u4FE1\u606F2\u5065\u5EB72\u516B\u53662\u516C\u53F81\u76CA2\u53F0\u6E7E1\u70632\u5546\u57CE1\u5E971\u68072\u5609\u91CC0\u5927\u9152\u5E975\u5728\u7EBF2\u5927\u62FF2\u5929\u4E3B\u65593\u5A31\u4E502\u5BB6\u96FB2\u5E7F\u4E1C2\u5FAE\u535A2\u6148\u55842\u6211\u7231\u4F603\u624B\u673A2\u62DB\u80582\u653F\u52A11\u5E9C2\u65B0\u52A0\u57612\u95FB2\u65F6\u5C1A2\u66F8\u7C4D2\u673A\u67842\u6DE1\u9A6C\u95213\u6E38\u620F2\u6FB3\u95802\u70B9\u770B2\u79FB\u52A82\u7EC4\u7EC7\u673A\u67844\u7F51\u57401\u5E971\u7AD91\u7EDC2\u8054\u901A2\u8C37\u6B4C2\u8D2D\u72692\u901A\u8CA92\u96C6\u56E22\u96FB\u8A0A\u76C8\u79D14\u98DE\u5229\u6D663\u98DF\u54C12\u9910\u53852\u9999\u683C\u91CC\u62C93\u6E2F2\uB2F7\uB1371\uCEF42\uC0BC\uC1312\uD55C\uAD6D2",ri=(t,e)=>{for(let n in e)t[n]=e[n];return t},lc="numeric",cc="ascii",uc="alpha",ls="asciinumeric",is="alphanumeric",dc="domain",Lh="emoji",TS="scheme",NS="slashscheme",Nh="whitespace";function _S(t,e){return t in e||(e[t]=[]),e[t]}function br(t,e,n){e[lc]&&(e[ls]=!0,e[is]=!0),e[cc]&&(e[ls]=!0,e[uc]=!0),e[ls]&&(e[is]=!0),e[uc]&&(e[is]=!0),e[is]&&(e[dc]=!0),e[Lh]&&(e[dc]=!0);for(let r in e){let i=_S(r,n);i.indexOf(t)<0&&i.push(t)}}function CS(t,e){let n={};for(let r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function Et(t){t===void 0&&(t=null),this.j={},this.jr=[],this.jd=null,this.t=t}Et.groups={};Et.prototype={accepts(){return!!this.t},go(t){let e=this,n=e.j[t];if(n)return n;for(let r=0;rt.ta(e,n,r,i),It=(t,e,n,r,i)=>t.tr(e,n,r,i),_h=(t,e,n,r,i)=>t.ts(e,n,r,i),I=(t,e,n,r,i)=>t.tt(e,n,r,i),Sn="WORD",fc="UWORD",Ki="LOCALHOST",pc="TLD",hc="UTLD",cs="SCHEME",Qr="SLASH_SCHEME",mc="NUM",Ph="WS",gc="NL",ei="OPENBRACE",Fi="OPENBRACKET",zi="OPENANGLEBRACKET",Ui="OPENPAREN",mr="CLOSEBRACE",ti="CLOSEBRACKET",ni="CLOSEANGLEBRACKET",gr="CLOSEPAREN",us="AMPERSAND",ds="APOSTROPHE",fs="ASTERISK",$n="AT",ps="BACKSLASH",hs="BACKTICK",ms="CARET",Kn="COLON",bc="COMMA",gs="DOLLAR",an="DOT",bs="EQUALS",yc="EXCLAMATION",ln="HYPHEN",ys="PERCENT",Es="PIPE",ws="PLUS",vs="POUND",Ss="QUERY",Ec="QUOTE",wc="SEMI",cn="SLASH",$i="TILDE",xs="UNDERSCORE",Bh="EMOJI",ks="SYM",Hh=Object.freeze({__proto__:null,WORD:Sn,UWORD:fc,LOCALHOST:Ki,TLD:pc,UTLD:hc,SCHEME:cs,SLASH_SCHEME:Qr,NUM:mc,WS:Ph,NL:gc,OPENBRACE:ei,OPENBRACKET:Fi,OPENANGLEBRACKET:zi,OPENPAREN:Ui,CLOSEBRACE:mr,CLOSEBRACKET:ti,CLOSEANGLEBRACKET:ni,CLOSEPAREN:gr,AMPERSAND:us,APOSTROPHE:ds,ASTERISK:fs,AT:$n,BACKSLASH:ps,BACKTICK:hs,CARET:ms,COLON:Kn,COMMA:bc,DOLLAR:gs,DOT:an,EQUALS:bs,EXCLAMATION:yc,HYPHEN:ln,PERCENT:ys,PIPE:Es,PLUS:ws,POUND:vs,QUERY:Ss,QUOTE:Ec,SEMI:wc,SLASH:cn,TILDE:$i,UNDERSCORE:xs,EMOJI:Bh,SYM:ks}),Zr=/[a-z]/,ic=/\p{L}/u,oc=/\p{Emoji}/u;var sc=/\d/,Ch=/\s/;var Oh=`
-`,OS="\uFE0F",AS="\u200D",ss=null,as=null;function RS(t){t===void 0&&(t=[]);let e={};Et.groups=e;let n=new Et;ss==null&&(ss=Ah(kS)),as==null&&(as=Ah(MS)),I(n,"'",ds),I(n,"{",ei),I(n,"[",Fi),I(n,"<",zi),I(n,"(",Ui),I(n,"}",mr),I(n,"]",ti),I(n,">",ni),I(n,")",gr),I(n,"&",us),I(n,"*",fs),I(n,"@",$n),I(n,"`",hs),I(n,"^",ms),I(n,":",Kn),I(n,",",bc),I(n,"$",gs),I(n,".",an),I(n,"=",bs),I(n,"!",yc),I(n,"-",ln),I(n,"%",ys),I(n,"|",Es),I(n,"+",ws),I(n,"#",vs),I(n,"?",Ss),I(n,'"',Ec),I(n,"/",cn),I(n,";",wc),I(n,"~",$i),I(n,"_",xs),I(n,"\\",ps);let r=It(n,sc,mc,{[lc]:!0});It(r,sc,r);let i=It(n,Zr,Sn,{[cc]:!0});It(i,Zr,i);let o=It(n,ic,fc,{[uc]:!0});It(o,Zr),It(o,ic,o);let s=It(n,Ch,Ph,{[Nh]:!0});I(n,Oh,gc,{[Nh]:!0}),I(s,Oh),It(s,Ch,s);let a=It(n,oc,Bh,{[Lh]:!0});It(a,oc,a),I(a,OS,a);let l=I(a,AS);It(l,oc,a);let c=[[Zr,i]],u=[[Zr,null],[ic,o]];for(let d=0;dd[0]>f[0]?1:-1);for(let d=0;d=0?h[dc]=!0:Zr.test(f)?sc.test(f)?h[ls]=!0:h[cc]=!0:h[lc]=!0,_h(n,f,f,h)}return _h(n,"localhost",Ki,{ascii:!0}),n.jd=new Et(ks),{start:n,tokens:ri({groups:e},Hh)}}function IS(t,e){let n=DS(e.replace(/[A-Z]/g,a=>a.toLowerCase())),r=n.length,i=[],o=0,s=0;for(;s=0&&(d+=n[s].length,f++),c+=n[s].length,o+=n[s].length,s++;o-=d,s-=f,c-=d,i.push({t:u.t,v:e.slice(o-c,o),s:o-c,e:o})}return i}function DS(t){let e=[],n=t.length,r=0;for(;r56319||r+1===n||(o=t.charCodeAt(r+1))<56320||o>57343?t[r]:t.slice(r,r+2);e.push(s),r+=s.length}return e}function Un(t,e,n,r,i){let o,s=e.length;for(let a=0;a=0;)o++;if(o>0){e.push(n.join(""));for(let s=parseInt(t.substring(r,r+o),10);s>0;s--)n.pop();r+=o}else n.push(t[r]),r++}return e}var Wi={defaultProtocol:"http",events:null,format:Rh,formatHref:Rh,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function vc(t,e){e===void 0&&(e=null);let n=ri({},Wi);t&&(n=ri(n,t instanceof vc?t.o:t));let r=n.ignoreTags,i=[];for(let o=0;on?r.substring(0,n)+"\u2026":r},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t){return t===void 0&&(t=Wi.defaultProtocol),{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){let e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),i=t.get("tagName",n,e),o=this.toFormattedString(t),s={},a=t.get("className",n,e),l=t.get("target",n,e),c=t.get("rel",n,e),u=t.getObj("attributes",n,e),d=t.getObj("events",n,e);return s.href=r,a&&(s.class=a),l&&(s.target=l),c&&(s.rel=c),u&&ri(s,u),{tagName:i,attributes:s,content:o,eventListeners:d}}};function Ms(t,e){class n extends Fh{constructor(i,o){super(i,o),this.t=t}}for(let r in e)n.prototype[r]=e[r];return n.t=t,n}var Ih=Ms("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Dh=Ms("text"),LS=Ms("nl"),hr=Ms("url",{isLink:!0,toHref(t){return t===void 0&&(t=Wi.defaultProtocol),this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){let t=this.tk;return t.length>=2&&t[0].t!==Ki&&t[1].t===Kn}});var Ve=t=>new Et(t);function PS(t){let{groups:e}=t,n=e.domain.concat([us,fs,$n,ps,hs,ms,gs,bs,ln,mc,ys,Es,ws,vs,cn,ks,$i,xs]),r=[ds,ni,mr,ti,gr,Kn,bc,an,yc,zi,ei,Fi,Ui,Ss,Ec,wc],i=[us,ds,fs,ps,hs,ms,mr,gs,bs,ln,ei,ys,Es,ws,vs,Ss,cn,ks,$i,xs],o=Ve(),s=I(o,$i);j(s,i,s),j(s,e.domain,s);let a=Ve(),l=Ve(),c=Ve();j(o,e.domain,a),j(o,e.scheme,l),j(o,e.slashscheme,c),j(a,i,s),j(a,e.domain,a);let u=I(a,$n);I(s,$n,u),I(l,$n,u),I(c,$n,u);let d=I(s,an);j(d,i,s),j(d,e.domain,s);let f=Ve();j(u,e.domain,f),j(f,e.domain,f);let p=I(f,an);j(p,e.domain,f);let h=Ve(Ih);j(p,e.tld,h),j(p,e.utld,h),I(u,Ki,h);let m=I(f,ln);j(m,e.domain,f),j(h,e.domain,f),I(h,an,p),I(h,ln,m);let g=I(h,Kn);j(g,e.numeric,Ih);let y=I(a,ln),S=I(a,an);j(y,e.domain,a),j(S,i,s),j(S,e.domain,a);let M=Ve(hr);j(S,e.tld,M),j(S,e.utld,M),j(M,e.domain,a),j(M,i,s),I(M,an,S),I(M,ln,y),I(M,$n,u);let b=I(M,Kn),_=Ve(hr);j(b,e.numeric,_);let w=Ve(hr),D=Ve();j(w,n,w),j(w,r,D),j(D,n,w),j(D,r,D),I(M,cn,w),I(_,cn,w);let K=I(l,Kn),O=I(c,Kn),J=I(O,cn),ne=I(J,cn);j(l,e.domain,a),I(l,an,S),I(l,ln,y),j(c,e.domain,a),I(c,an,S),I(c,ln,y),j(K,e.domain,w),I(K,cn,w),j(ne,e.domain,w),j(ne,n,w),I(ne,cn,w);let ie=I(w,ei),Z=I(w,Fi),re=I(w,zi),ce=I(w,Ui);I(D,ei,ie),I(D,Fi,Z),I(D,zi,re),I(D,Ui,ce),I(ie,mr,w),I(Z,ti,w),I(re,ni,w),I(ce,gr,w),I(ie,mr,w);let N=Ve(hr),E=Ve(hr),v=Ve(hr),C=Ve(hr);j(ie,n,N),j(Z,n,E),j(re,n,v),j(ce,n,C);let P=Ve(),Y=Ve(),Q=Ve(),he=Ve();return j(ie,r),j(Z,r),j(re,r),j(ce,r),j(N,n,N),j(E,n,E),j(v,n,v),j(C,n,C),j(N,r,N),j(E,r,E),j(v,r,v),j(C,r,C),j(P,n,P),j(Y,n,E),j(Q,n,v),j(he,n,C),j(P,r,P),j(Y,r,Y),j(Q,r,Q),j(he,r,he),I(E,ti,w),I(v,ni,w),I(C,gr,w),I(N,mr,w),I(Y,ti,w),I(Q,ni,w),I(he,gr,w),I(P,gr,w),I(o,Ki,M),I(o,gc,LS),{start:o,tokens:Hh}}function BS(t,e,n){let r=n.length,i=0,o=[],s=[];for(;i=0&&f++,i++,u++;if(f<0)i-=u,i0&&(o.push(ac(Dh,e,s)),s=[]),i-=f,u-=f;let p=d.t,h=n.slice(i-u,i);o.push(ac(p,e,h))}}return s.length>0&&o.push(ac(Dh,e,s)),o}function ac(t,e,n){let r=n[0].s,i=n[n.length-1].e,o=e.slice(r,i);return new t(o,n)}var HS=typeof console<"u"&&console&&console.warn||(()=>{}),FS="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",Ce={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function zh(){Et.groups={},Ce.scanner=null,Ce.parser=null,Ce.tokenQueue=[],Ce.pluginQueue=[],Ce.customSchemes=[],Ce.initialized=!1}function Sc(t,e){if(e===void 0&&(e=!1),Ce.initialized&&HS(`linkifyjs: already initialized - will not register custom scheme "${t}" ${FS}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
+`,textSerializers:r={}}=e||{};return Cw(this.state.doc,{blockSeparator:n,textSerializers:{...lp(this.schema),...r}})}get isEmpty(){return Iw(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){this.emit("destroy"),this.view&&this.view.destroy(),this.removeAllListeners()}get isDestroyed(){var e;return!(!((e=this.view)===null||e===void 0)&&e.docView)}};function Mt(t){return new Br({find:t.find,handler:({state:e,range:n,match:r})=>{let i=ee(t.getAttributes,void 0,r);if(i===!1||i===null)return null;let{tr:o}=e,s=r[r.length-1],a=r[0];if(s){let l=a.search(/\S/),c=n.from+a.indexOf(s),u=c+s.length;if($o(n.from,n.to,e.doc).filter(p=>p.mark.type.excluded.find(g=>g===t.type&&g!==p.mark.type)).filter(p=>p.to>c).length)return null;un.from&&o.delete(n.from+l,c);let f=n.from+l+s.length;o.addMark(n.from+l,f,t.type.create(i||{})),o.removeStoredMark(t.type)}}})}function Ko(t){return new Br({find:t.find,handler:({state:e,range:n,match:r})=>{let i=ee(t.getAttributes,void 0,r)||{},{tr:o}=e,s=n.from,a=n.to,l=t.type.create(i);if(r[1]){let c=r[0].lastIndexOf(r[1]),u=s+c;u>a?u=a:a=u+r[1].length;let d=r[0][r[0].length-1];o.insertText(d,s+r[0].length-1),o.replaceWith(u,a,l)}else r[0]&&o.insert(s-1,t.type.create(i)).delete(o.mapping.map(s),o.mapping.map(a));o.scrollIntoView()}})}function Ni(t){return new Br({find:t.find,handler:({state:e,range:n,match:r})=>{let i=e.doc.resolve(n.from),o=ee(t.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,o)}})}function kn(t){return new Br({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{let o=ee(t.getAttributes,void 0,r)||{},s=e.tr.delete(n.from,n.to),l=s.doc.resolve(n.from).blockRange(),c=l&&Mr(l,t.type,o);if(!c)return null;if(s.wrap(l,c),t.keepMarks&&t.editor){let{selection:d,storedMarks:f}=e,{splittableMarks:p}=t.editor.extensionManager,h=f||d.$to.parentOffset&&d.$from.marks();if(h){let g=h.filter(m=>p.includes(m.type.name));s.ensureMarks(g)}}if(t.keepAttributes){let d=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(d,o).run()}let u=s.doc.resolve(n.from-1).nodeBefore;u&&u.type===t.type&&Dt(s.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,u))&&s.join(n.from-1)}})}var we=class t{constructor(e={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=ee(F(this,"addOptions",{name:this.name}))),this.storage=ee(F(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new t(e)}configure(e={}){let n=this.extend();return n.options=Bo(this.options,e),n.storage=ee(F(n,"addStorage",{name:n.name,options:n.options})),n}extend(e={}){let n=new t(e);return n.parent=this,this.child=n,n.name=e.name?e.name:n.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=ee(F(n,"addOptions",{name:n.name})),n.storage=ee(F(n,"addStorage",{name:n.name,options:n.options})),n}static handleExit({editor:e,mark:n}){let{tr:r}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){let s=i.marks();if(!!!s.find(c=>c?.type.name===n.name))return!1;let l=s.find(c=>c?.type.name===n.name);return l&&r.removeStoredMark(l),r.insertText(" ",i.pos),e.view.dispatch(r),!0}return!1}},$=class t{constructor(e={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=ee(F(this,"addOptions",{name:this.name}))),this.storage=ee(F(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new t(e)}configure(e={}){let n=this.extend();return n.options=Bo(this.options,e),n.storage=ee(F(n,"addStorage",{name:n.name,options:n.options})),n}extend(e={}){let n=new t(e);return n.parent=this,this.child=n,n.name=e.name?e.name:n.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=ee(F(n,"addOptions",{name:n.name})),n.storage=ee(F(n,"addStorage",{name:n.name,options:n.options})),n}};function ht(t){return new Ml({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{let o=ee(t.getAttributes,void 0,r,i);if(o===!1||o===null)return null;let{tr:s}=e,a=r[r.length-1],l=r[0],c=n.to;if(a){let u=l.search(/\S/),d=n.from+l.indexOf(a),f=d+a.length;if($o(n.from,n.to,e.doc).filter(h=>h.mark.type.excluded.find(m=>m===t.type&&m!==h.mark.type)).filter(h=>h.to>d).length)return null;fn.from&&s.delete(n.from+u,d),c=n.from+u+a.length,s.addMark(n.from+u,c,t.type.create(o||{})),s.removeStoredMark(t.type)}}})}var lv=/^\s*>\s$/,mp=$.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return["blockquote",B(this.options.HTMLAttributes,t),0]},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[kn({find:lv,type:this.type})]}});var cv=/(?:^|\s)((?:\*\*)((?:[^*]+))(?:\*\*))$/,uv=/(?:^|\s)((?:\*\*)((?:[^*]+))(?:\*\*))/g,dv=/(?:^|\s)((?:__)((?:[^__]+))(?:__))$/,fv=/(?:^|\s)((?:__)((?:[^__]+))(?:__))/g,gp=we.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return["strong",B(this.options.HTMLAttributes,t),0]},addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Mt({find:cv,type:this.type}),Mt({find:dv,type:this.type})]},addPasteRules(){return[ht({find:uv,type:this.type}),ht({find:fv,type:this.type})]}});var pv=$.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",B(this.options.HTMLAttributes,t),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),bp=we.create({name:"textStyle",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"span",getAttrs:t=>t.hasAttribute("style")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["span",B(this.options.HTMLAttributes,t),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:t,commands:e})=>{let n=xn(t,this.type);return Object.entries(n).some(([,i])=>!!i)?!0:e.unsetMark(this.name)}}}}),yp=/^\s*([-+*])\s$/,Ep=$.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",B(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(pv.name,this.editor.getAttributes(bp.name)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=kn({find:yp,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=kn({find:yp,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(bp.name),editor:this.editor})),[t]}});var hv=/(?:^|\s)((?:`)((?:[^`]+))(?:`))$/,mv=/(?:^|\s)((?:`)((?:[^`]+))(?:`))/g,wp=we.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",B(this.options.HTMLAttributes,t),0]},addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Mt({find:hv,type:this.type})]},addPasteRules(){return[ht({find:mv,type:this.type})]}});var vp=we.create({name:"textStyle",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"span",getAttrs:t=>t.hasAttribute("style")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["span",B(this.options.HTMLAttributes,t),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:t,commands:e})=>{let n=xn(t,this.type);return Object.entries(n).some(([,i])=>!!i)?!0:e.unsetMark(this.name)}}}});var Sp=Ne.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;return(e=t.style.color)===null||e===void 0?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}}}}]},addCommands(){return{setColor:t=>({chain:e})=>e().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}});var xp=$.create({name:"doc",topNode:!0,content:"block+"});function kp(t={}){return new ge({view(e){return new Ll(e,t)}})}var Ll=class{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let o=s=>{this[i](s)};return e.dom.addEventListener(i,o),{name:i,handler:o}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r;if(n){let a=e.nodeBefore,l=e.nodeAfter;if(a||l){let c=this.editorView.nodeDOM(this.cursorPos-(a?a.nodeSize:0));if(c){let u=c.getBoundingClientRect(),d=a?u.bottom:u.top;a&&l&&(d=(d+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2),r={left:u.left,right:u.right,top:d-this.width/2,bottom:d+this.width/2}}}}if(!r){let a=this.editorView.coordsAtPos(this.cursorPos);r={left:a.left-this.width/2,right:a.left+this.width/2,top:a.top,bottom:a.bottom}}let i=this.editorView.dom.offsetParent;this.element||(this.element=i.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let o,s;if(!i||i==document.body&&getComputedStyle(i).position=="static")o=-pageXOffset,s=-pageYOffset;else{let a=i.getBoundingClientRect();o=a.left-i.scrollLeft,s=a.top-i.scrollTop}this.element.style.left=r.left-o+"px",this.element.style.top=r.top-s+"px",this.element.style.width=r.right-r.left+"px",this.element.style.height=r.bottom-r.top+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),i=r&&r.type.spec.disableDropCursor,o=typeof i=="function"?i(this.editorView,n,e):i;if(n&&!o){let s=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let a=fo(this.editorView.state.doc,s,this.editorView.dragging.slice);a!=null&&(s=a)}this.setCursor(s),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){(e.target==this.editorView.dom||!this.editorView.dom.contains(e.relatedTarget))&&this.setCursor(null)}};var Mp=Ne.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[kp(this.options)]}});var tt=class t extends V{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return t.valid(r)?new t(r):V.near(r)}content(){return D.empty}eq(e){return e instanceof t&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new t(e.resolve(n.pos))}getBookmark(){return new Pl(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!gv(e)||!bv(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let i=n.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&t.valid(e))return e;let i=e.pos,o=null;for(let s=e.depth;;s--){let a=e.node(s);if(n>0?e.indexAfter(s)0){o=a.child(n>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;i+=n;let l=e.doc.resolve(i);if(t.valid(l))return l}for(;;){let s=n>0?o.firstChild:o.lastChild;if(!s){if(o.isAtom&&!o.isText&&!Y.isSelectable(o)){e=e.doc.resolve(i+o.nodeSize*n),r=!1;continue e}break}o=s,i+=n;let a=e.doc.resolve(i);if(t.valid(a))return a}return null}}};tt.prototype.visible=!1;tt.findFrom=tt.findGapCursorFrom;V.jsonID("gapcursor",tt);var Pl=class t{constructor(e){this.pos=e}map(e){return new t(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return tt.valid(n)?new tt(n):V.near(n)}};function gv(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(n-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||i.isAtom||i.type.spec.isolating)return!0;if(i.inlineContent)return!1}}return!0}function bv(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(n);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||i.isAtom||i.type.spec.isolating)return!0;if(i.inlineContent)return!1}}return!0}function Np(){return new ge({props:{decorations:vv,createSelectionBetween(t,e,n){return e.pos==n.pos&&tt.valid(n)?new tt(n):null},handleClick:Ev,handleKeyDown:yv,handleDOMEvents:{beforeinput:wv}}})}var yv=ki({ArrowLeft:Wo("horiz",-1),ArrowRight:Wo("horiz",1),ArrowUp:Wo("vert",-1),ArrowDown:Wo("vert",1)});function Wo(t,e){let n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,o){let s=r.selection,a=e>0?s.$to:s.$from,l=s.empty;if(s instanceof K){if(!o.endOfTextblock(n)||a.depth==0)return!1;l=!1,a=r.doc.resolve(e>0?a.after():a.before())}let c=tt.findGapCursorFrom(a,e,l);return c?(i&&i(r.tr.setSelection(new tt(c))),!0):!1}}function Ev(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!tt.valid(r))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&Y.isSelectable(t.state.doc.nodeAt(i.inside))?!1:(t.dispatch(t.state.tr.setSelection(new tt(r))),!0)}function wv(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof tt))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let i=T.empty;for(let s=r.length-1;s>=0;s--)i=T.from(r[s].createAndFill(null,i));let o=t.state.tr.replace(n.pos,n.pos,new D(i,0,0));return o.setSelection(K.near(o.doc.resolve(n.pos+1))),t.dispatch(o),!1}function vv(t){if(!(t.selection instanceof tt))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",Ce.create(t.doc,[et.widget(t.selection.head,e,{key:"gapcursor"})])}var Tp=Ne.create({name:"gapCursor",addProseMirrorPlugins(){return[Np()]},extendNodeSchema(t){var e;let n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=ee(F(t,"allowGapCursor",n)))!==null&&e!==void 0?e:null}}});var _p=$.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",B(this.options.HTMLAttributes,t)]},renderText(){return`
+`},addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{let{selection:i,storedMarks:o}=n;if(i.$from.parent.type.spec.isolating)return!1;let{keepMarks:s}=this.options,{splittableMarks:a}=r.extensionManager,l=o||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:u})=>{if(u&&l&&s){let d=l.filter(f=>a.includes(f.type.name));c.ensureMarks(d)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}});var Cp=$.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,B(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>Ni({find:new RegExp(`^(#{1,${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}});var Vo=200,qe=function(){};qe.prototype.append=function(e){return e.length?(e=qe.from(e),!this.length&&e||e.length=n?qe.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};qe.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};qe.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)};qe.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(o,s){return i.push(e(o,s))},n,r),i};qe.from=function(e){return e instanceof qe?e:e&&e.length?new Op(e):qe.empty};var Op=function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,o){return i==0&&o==this.length?this:new e(this.values.slice(i,o))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,o,s,a){for(var l=o;l=s;l--)if(i(this.values[l],a+l)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=Vo)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=Vo)return new e(i.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e}(qe);qe.empty=new Op([]);var Sv=function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return ra&&this.right.forEachInner(r,Math.max(i-a,0),Math.min(this.length,o)-a,s+a)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,o,s){var a=this.left.length;if(i>a&&this.right.forEachInvertedInner(r,i-a,Math.max(o,a)-a,s+a)===!1||o=o?this.right.slice(r-o,i-o):this.left.slice(r,o).append(this.right.slice(0,i-o))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e}(qe),Bl=qe;var xv=500,tr=class t{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,o;n&&(i=this.remapping(r,this.items.length),o=i.maps.length);let s=e.tr,a,l,c=[],u=[];return this.items.forEach((d,f)=>{if(!d.step){i||(i=this.remapping(r,f+1),o=i.maps.length),o--,u.push(d);return}if(i){u.push(new qt(d.map));let p=d.step.map(i.slice(o)),h;p&&s.maybeStep(p).doc&&(h=s.mapping.maps[s.mapping.maps.length-1],c.push(new qt(h,void 0,void 0,c.length+u.length))),o--,h&&i.appendMap(h,o)}else s.maybeStep(d.step);if(d.selection)return a=i?d.selection.map(i.slice(o)):d.selection,l=new t(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:l,transform:s,selection:a}}addTransform(e,n,r,i){let o=[],s=this.eventCount,a=this.items,l=!i&&a.length?a.get(a.length-1):null;for(let u=0;uMv&&(a=kv(a,c),s-=c),new t(a.append(o),s)}remapping(e,n){let r=new di;return this.items.forEach((i,o)=>{let s=i.mirrorOffset!=null&&o-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,s)},e,n),r}addMaps(e){return this.eventCount==0?this:new t(this.items.append(e.map(n=>new qt(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),o=e.mapping,s=e.steps.length,a=this.eventCount;this.items.forEach(f=>{f.selection&&a--},i);let l=n;this.items.forEach(f=>{let p=o.getMirror(--l);if(p==null)return;s=Math.min(s,p);let h=o.maps[p];if(f.step){let g=e.steps[p].invert(e.docs[p]),m=f.selection&&f.selection.map(o.slice(l+1,p));m&&a++,r.push(new qt(h,g,m))}else r.push(new qt(h))},i);let c=[];for(let f=n;fxv&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,i=[],o=0;return this.items.forEach((s,a)=>{if(a>=e)i.push(s),s.selection&&o++;else if(s.step){let l=s.step.map(n.slice(r)),c=l&&l.getMap();if(r--,c&&n.appendMap(c,r),l){let u=s.selection&&s.selection.map(n.slice(r));u&&o++;let d=new qt(c.invert(),l,u),f,p=i.length-1;(f=i.length&&i[p].merge(d))?i[p]=f:i.push(d)}}else s.map&&r--},this.items.length,0),new t(Bl.from(i.reverse()),o)}};tr.empty=new tr(Bl.empty,0);function kv(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}var qt=class t{constructor(e,n,r,i){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new t(n.getMap().invert(),n,this.selection)}}},jt=class{constructor(e,n,r,i,o){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=o}},Mv=20;function Nv(t,e,n,r){let i=n.getMeta(Mn),o;if(i)return i.historyState;n.getMeta(_v)&&(t=new jt(t.done,t.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(s&&s.getMeta(Mn))return s.getMeta(Mn).redo?new jt(t.done.addTransform(n,void 0,r,Go(e)),t.undone,Ap(n.mapping.maps[n.steps.length-1]),t.prevTime,t.prevComposition):new jt(t.done,t.undone.addTransform(n,void 0,r,Go(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let a=n.getMeta("composition"),l=t.prevTime==0||!s&&t.prevComposition!=a&&(t.prevTime<(n.time||0)-r.newGroupDelay||!Tv(n,t.prevRanges)),c=s?Fl(t.prevRanges,n.mapping):Ap(n.mapping.maps[n.steps.length-1]);return new jt(t.done.addTransform(n,l?e.selection.getBookmark():void 0,r,Go(e)),tr.empty,c,n.time,a??t.prevComposition)}else return(o=n.getMeta("rebased"))?new jt(t.done.rebased(n,o),t.undone.rebased(n,o),Fl(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new jt(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Fl(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function Tv(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,i)=>{for(let o=0;o=e[o]&&(n=!0)}),n}function Ap(t){let e=[];return t.forEach((n,r,i,o)=>e.push(i,o)),e}function Fl(t,e){if(!t)return null;let n=[];for(let r=0;r{let n=Mn.getState(t);return!n||n.done.eventCount==0?!1:(e&&Ip(n,t,e,!1),!0)},$l=(t,e)=>{let n=Mn.getState(t);return!n||n.undone.eventCount==0?!1:(e&&Ip(n,t,e,!0),!0)};var Lp=Ne.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>zl(t,e),redo:()=>({state:t,dispatch:e})=>$l(t,e)}},addProseMirrorPlugins(){return[Dp(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Mod-Z":()=>this.editor.commands.undo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-Y":()=>this.editor.commands.redo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Shift-Mod-Z":()=>this.editor.commands.redo(),"Mod-\u044F":()=>this.editor.commands.undo(),"Shift-Mod-\u044F":()=>this.editor.commands.redo()}}});var Pp=$.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",B(this.options.HTMLAttributes,t)]},addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{let{$to:n}=e.selection,r=t();return n.parentOffset===0?r.insertContentAt(Math.max(n.pos-2,0),{type:this.name}):r.insertContent({type:this.name}),r.command(({tr:i,dispatch:o})=>{var s;if(o){let{$to:a}=i.selection,l=a.end();if(a.nodeAfter)a.nodeAfter.isTextblock?i.setSelection(K.create(i.doc,a.pos+1)):a.nodeAfter.isBlock?i.setSelection(Y.create(i.doc,a.pos)):i.setSelection(K.create(i.doc,a.pos));else{let c=(s=a.parent.type.contentMatch.defaultType)===null||s===void 0?void 0:s.create();c&&(i.insert(l,c),i.setSelection(K.create(i.doc,l+1)))}i.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Ko({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}});var Cv=/(?:^|\s)((?:\*)((?:[^*]+))(?:\*))$/,Ov=/(?:^|\s)((?:\*)((?:[^*]+))(?:\*))/g,Av=/(?:^|\s)((?:_)((?:[^_]+))(?:_))$/,Rv=/(?:^|\s)((?:_)((?:[^_]+))(?:_))/g,Bp=we.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",B(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Mt({find:Cv,type:this.type}),Mt({find:Av,type:this.type})]},addPasteRules(){return[ht({find:Ov,type:this.type}),ht({find:Rv,type:this.type})]}});var Ul=$.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",B(this.options.HTMLAttributes,t),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}});var Iv=$.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",B(this.options.HTMLAttributes,t),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),Fp=we.create({name:"textStyle",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"span",getAttrs:t=>t.hasAttribute("style")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["span",B(this.options.HTMLAttributes,t),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:t,commands:e})=>{let n=xn(t,this.type);return Object.entries(n).some(([,i])=>!!i)?!0:e.unsetMark(this.name)}}}}),Hp=/^(\d+)\.\s$/,zp=$.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){let{start:e,...n}=t;return e===1?["ol",B(this.options.HTMLAttributes,n),0]:["ol",B(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Iv.name,this.editor.getAttributes(Fp.name)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=kn({find:Hp,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=kn({find:Hp,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Fp.name)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}});var Dv=/(?:^|\s)((?:~~)((?:[^~]+))(?:~~))$/,Lv=/(?:^|\s)((?:~~)((?:[^~]+))(?:~~))/g,$p=we.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",B(this.options.HTMLAttributes,t),0]},addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){let t={};return Ho()?t["Mod-Shift-s"]=()=>this.editor.commands.toggleStrike():t["Ctrl-Shift-s"]=()=>this.editor.commands.toggleStrike(),t},addInputRules(){return[Mt({find:Dv,type:this.type})]},addPasteRules(){return[ht({find:Lv,type:this.type})]}});var Up=we.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(t){return t!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sub",B(this.options.HTMLAttributes,t),0]},addCommands(){return{setSubscript:()=>({commands:t})=>t.setMark(this.name),toggleSubscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSubscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}});var Kp=we.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(t){return t!=="super"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sup",B(this.options.HTMLAttributes,t),0]},addCommands(){return{setSuperscript:()=>({commands:t})=>t.setMark(this.name),toggleSuperscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSuperscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}});var Wl,Vl;if(typeof WeakMap<"u"){let t=new WeakMap;Wl=e=>t.get(e),Vl=(e,n)=>(t.set(e,n),n)}else{let t=[],n=0;Wl=r=>{for(let i=0;i(n==10&&(n=0),t[n++]=r,t[n++]=i)}var Te=class{constructor(t,e,n,r){this.width=t,this.height=e,this.map=n,this.problems=r}findCell(t){for(let e=0;e=n){(o||(o=[])).push({type:"overlong_rowspan",pos:u,n:y-x});break}let b=i+x*e;for(let _=0;_r&&(o+=c.attrs.colspan)}}for(let s=0;s1&&(n=!0)}e==-1?e=o:e!=o&&(e=Math.max(e,o))}return e}function Fv(t,e,n){t.problems||(t.problems=[]);let r={};for(let i=0;i0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function zv(t){for(let e=t.depth;e>0;e--){let n=t.node(e).type.spec.tableRole;if(n==="cell"||n==="header_cell")return t.node(e)}return null}function Ft(t){let e=t.selection.$head;for(let n=e.depth;n>0;n--)if(e.node(n).type.spec.tableRole=="row")return!0;return!1}function Zo(t){let e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;let n=Fr(e.$head)||$v(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function $v(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function Gl(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function Uv(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function Yl(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function Zp(t,e,n){let r=t.node(-1),i=Te.get(r),o=t.start(-1),s=i.nextCell(t.pos-o,e,n);return s==null?null:t.node(0).resolve(o+s)}function nr(t,e,n=1){let r={...t,colspan:t.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some(i=>i>0)||(r.colwidth=null)),r}function Qp(t,e,n=1){let r={...t,colspan:t.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let i=0;ic!=e.pos-i);a.unshift(e.pos-i);let l=a.map(c=>{let u=n.nodeAt(c);if(!u)throw RangeError(`No cell with offset ${c} found`);let d=i+c+1;return new gi(s.resolve(d),s.resolve(d+u.content.size))});super(l[0].$from,l[0].$to,l),this.$anchorCell=t,this.$headCell=e}map(t,e){let n=t.resolve(e.map(this.$anchorCell.pos)),r=t.resolve(e.map(this.$headCell.pos));if(Gl(n)&&Gl(r)&&Yl(n,r)){let i=this.$anchorCell.node(-1)!=n.node(-1);return i&&this.isRowSelection()?fe.rowSelection(n,r):i&&this.isColSelection()?fe.colSelection(n,r):new fe(n,r)}return K.between(n,r)}content(){let t=this.$anchorCell.node(-1),e=Te.get(t),n=this.$anchorCell.start(-1),r=e.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),i={},o=[];for(let a=r.top;a0||g>0){let m=p.attrs;if(h>0&&(m=nr(m,0,h)),g>0&&(m=nr(m,m.colspan-g,g)),f.leftr.bottom){let m={...p.attrs,rowspan:Math.min(f.bottom,r.bottom)-Math.max(f.top,r.top)};f.top0)return!1;let n=t+this.$anchorCell.nodeAfter.attrs.rowspan,r=e+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,r)==this.$headCell.node(-1).childCount}static colSelection(t,e=t){let n=t.node(-1),r=Te.get(n),i=t.start(-1),o=r.findCell(t.pos-i),s=r.findCell(e.pos-i),a=t.node(0);return o.top<=s.top?(o.top>0&&(t=a.resolve(i+r.map[o.left])),s.bottom0&&(e=a.resolve(i+r.map[s.left])),o.bottom0)return!1;let o=r+this.$anchorCell.nodeAfter.attrs.colspan,s=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(o,s)==e.width}eq(t){return t instanceof fe&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,e=t){let n=t.node(-1),r=Te.get(n),i=t.start(-1),o=r.findCell(t.pos-i),s=r.findCell(e.pos-i),a=t.node(0);return o.left<=s.left?(o.left>0&&(t=a.resolve(i+r.map[o.top*r.width])),s.right0&&(e=a.resolve(i+r.map[s.top*r.width])),o.right{e.push(et.node(r,r+n.nodeSize,{class:"selectedCell"}))}),Ce.create(t.doc,e)}function Vv({$from:t,$to:e}){if(t.pos==e.pos||t.pos=0&&!(t.after(i+1)=0&&!(e.before(o+1)>e.start(o));o--,r--);return n==r&&/row|table/.test(t.node(i).type.spec.tableRole)}function Gv({$from:t,$to:e}){let n,r;for(let i=t.depth;i>0;i--){let o=t.node(i);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){n=o;break}}for(let i=e.depth;i>0;i--){let o=e.node(i);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){r=o;break}}return n!==r&&e.parentOffset===0}function qv(t,e,n){let r=(e||t).selection,i=(e||t).doc,o,s;if(r instanceof Y&&(s=r.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")o=fe.create(i,r.from);else if(s=="row"){let a=i.resolve(r.from+1);o=fe.rowSelection(a,a)}else if(!n){let a=Te.get(r.node),l=r.from+1,c=l+a.map[a.width*a.height-1];o=fe.create(i,l+1,c)}}else r instanceof K&&Vv(r)?o=K.create(i,r.from):r instanceof K&&Gv(r)&&(o=K.create(i,r.$from.start(),r.$from.end()));return o&&(e||(e=t.tr)).setSelection(o),e}var jv=new ve("fix-tables");function th(t,e,n,r){let i=t.childCount,o=e.childCount;e:for(let s=0,a=0;s{i.type.spec.tableRole=="table"&&(n=Yv(t,i,o,n))};return e?e.doc!=t.doc&&th(e.doc,t.doc,0,r):t.doc.descendants(r),n}function Yv(t,e,n,r){let i=Te.get(e);if(!i.problems)return r;r||(r=t.tr);let o=[];for(let l=0;l0){let p="cell";u.firstChild&&(p=u.firstChild.type.spec.tableRole);let h=[];for(let m=0;m0&&r>0||e.child(0).type.spec.tableRole=="table");)n--,r--,e=e.child(0).content;let i=e.child(0),o=i.type.spec.tableRole,s=i.type.schema,a=[];if(o=="row")for(let l=0;l=0;s--){let{rowspan:a,colspan:l}=o.child(s).attrs;for(let c=i;c=e.length&&e.push(T.empty),n[i]r&&(f=f.type.createChecked(nr(f.attrs,f.attrs.colspan,u+f.attrs.colspan-r),f.content)),c.push(f),u+=f.attrs.colspan;for(let p=1;pi&&(d=d.type.create({...d.attrs,rowspan:Math.max(1,i-d.attrs.rowspan)},d.content)),l.push(d)}o.push(T.from(l))}n=o,e=i}return{width:t,height:e,rows:n}}function Qv(t,e,n,r,i,o,s){let a=t.doc.type.schema,l=nt(a),c,u;if(i>e.width)for(let d=0,f=0;d