1||a==0||g.content.size)&&(d=m,c.push(a2(g.mark(h.allowedMarks(g.marks)),u==1?a:0,u==l.childCount?p:-1)))}let f=u==l.childCount;f||(p=-1),this.placed=Wu(this.placed,n,J.from(c)),this.frontier[n].match=d,f&&p<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let g=0,m=l;g1&&o==this.$to.end(--r);)++o;return o}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:o}=this.frontier[n],i=n=0;l--){let{match:a,type:u}=this.frontier[l],c=i1(e,l,u,a,!0);if(!c||c.childCount)continue e}return{depth:n,fit:s,move:i?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=Wu(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let o=e.node(r),i=o.type.contentMatch.fillBefore(o.content,!0,e.index(r));this.openFrontierNode(o.type,o.attrs,i)}return e}openFrontierNode(e,n=null,r){let o=this.frontier[this.depth];o.match=o.match.matchType(e),this.placed=Wu(this.placed,this.depth,J.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(J.empty,!0);n.childCount&&(this.placed=Wu(this.placed,this.frontier.length,n))}}function Uu(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Uu(t.firstChild.content,e-1,n)))}function Wu(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Wu(t.lastChild.content,e-1,n)))}function o1(t,e){for(let n=0;n1&&(r=r.replaceChild(0,a2(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(J.empty,!0)))),t.copy(r)}function i1(t,e,n,r,o){let i=t.node(e),s=o?t.indexAfter(e):t.index(e);if(s==i.childCount&&!n.compatibleContent(i.type))return null;let l=r.fillBefore(i.content,!0,s);return l&&!$P(n,i.content,s)?l:null}function $P(t,e,n){for(let r=n;r0;h--,p--){let f=o.node(h).type.spec;if(f.defining||f.definingAsContext||f.isolating)break;s.indexOf(h)>-1?l=h:o.before(h)==p&&s.splice(1,0,-h)}let a=s.indexOf(l),u=[],c=r.openStart;for(let h=r.content,p=0;;p++){let f=h.firstChild;if(u.push(f),p==r.openStart)break;h=f.content}for(let h=c-1;h>=0;h--){let p=u[h],f=DP(p.type);if(f&&!p.sameMarkup(o.node(Math.abs(l)-1)))c=h;else if(f||!p.type.isTextblock)break}for(let h=r.openStart;h>=0;h--){let p=(h+c+1)%(r.openStart+1),f=u[p];if(f)for(let g=0;g=0&&(t.replace(e,n,r),!(t.steps.length>d));h--){let p=s[h];p<0||(e=o.before(p),n=i.after(p))}}function l2(t,e,n,r,o){if(er){let i=o.contentMatchAt(0),s=i.fillBefore(t).append(t);t=s.append(i.matchFragment(s).fillBefore(J.empty,!0))}return t}function zP(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let o=i2(t.doc,e,r.type);o!=null&&(e=n=o)}t.replaceRange(e,n,new ae(J.from(r),0,0))}function FP(t,e,n){let r=t.doc.resolve(e),o=t.doc.resolve(n),i=c2(r,o);for(let s=0;s0&&(a||r.node(l-1).canReplace(r.index(l-1),o.indexAfter(l-1))))return t.delete(r.before(l),o.after(l))}for(let s=1;s<=r.depth&&s<=o.depth;s++)if(e-r.start(s)==r.depth-s&&n>r.end(s)&&o.end(s)-n!=o.depth-s)return t.delete(r.before(s),n);t.delete(e,n)}function c2(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let o=r;o>=0;o--){let i=t.start(o);if(ie.pos+(e.depth-o)||t.node(o).type.spec.isolating||e.node(o).type.spec.isolating)break;(i==e.start(o)||o==t.depth&&o==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&o&&e.start(o-1)==i-1)&&n.push(o)}return n}class yc extends cn{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 Kt.fail("No node at attribute step's position");let r=Object.create(null);for(let i in n.attrs)r[i]=n.attrs[i];r[this.attr]=this.value;let o=n.type.create(r,null,n.marks);return Kt.fromReplace(e,this.pos,this.pos+1,new ae(J.from(o),0,n.isLeaf?0:1))}getMap(){return Ur.empty}invert(e){return new yc(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 yc(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 yc(n.pos,n.attr,n.value)}}cn.jsonID("attr",yc);class Gd extends cn{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let o in e.attrs)n[o]=e.attrs[o];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return Kt.ok(r)}getMap(){return Ur.empty}invert(e){return new Gd(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 Gd(n.attr,n.value)}}cn.jsonID("docAttr",Gd);let $c=class extends Error{};$c=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};$c.prototype=Object.create(Error.prototype);$c.prototype.constructor=$c;$c.prototype.name="TransformError";class BP{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new mc}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new $c(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=ae.empty){let o=_b(this.doc,e,n,r);return o&&this.step(o),this}replaceWith(e,n,r){return this.replace(e,n,new ae(J.from(r),0,0))}delete(e,n){return this.replace(e,n,ae.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return PP(this,e,n,r),this}replaceRangeWith(e,n,r){return zP(this,e,n,r),this}deleteRange(e,n){return FP(this,e,n),this}lift(e,n){return EP(this,e,n),this}join(e,n=1){return IP(this,e,n),this}wrap(e,n){return TP(this,e,n),this}setBlockType(e,n=e,r,o=null){return AP(this,e,n,r,o),this}setNodeMarkup(e,n,r=null,o){return RP(this,e,n,r,o),this}setNodeAttribute(e,n,r){return this.step(new yc(e,n,r)),this}setDocAttribute(e,n){return this.step(new Gd(e,n)),this}addNodeMark(e,n){return this.step(new ks(e,n)),this}removeNodeMark(e,n){if(!(n instanceof je)){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 Nc(e,n)),this}split(e,n=1,r){return MP(this,e,n,r),this}addMark(e,n,r){return bP(this,e,n,r),this}removeMark(e,n,r){return wP(this,e,n,r),this}clearIncompatible(e,n,r){return xP(this,e,n,r),this}}const s1=Object.create(null);class Be{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new HP(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;i--){let s=n<0?Gl(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):Gl(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,n,r);if(s)return s}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new rr(e.node(0))}static atStart(e){return Gl(e,e,0,0,1)||new rr(e)}static atEnd(e){return Gl(e,e,e.content.size,e.childCount,-1)||new rr(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=s1[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 s1)throw new RangeError("Duplicate use of selection JSON ID "+e);return s1[e]=n,n.prototype.jsonID=e,n}getBookmark(){return Me.between(this.$anchor,this.$head).getBookmark()}}Be.prototype.visible=!0;class HP{constructor(e,n){this.$from=e,this.$to=n}}let RS=!1;function MS(t){!RS&&!t.parent.inlineContent&&(RS=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class Me extends Be{constructor(e,n=e){MS(e),MS(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 Be.near(r);let o=e.resolve(n.map(this.anchor));return new Me(o.parent.inlineContent?o:r,r)}replace(e,n=ae.empty){if(super.replace(e,n),n==ae.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof Me&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new fm(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 Me(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let o=e.resolve(n);return new this(o,r==n?o:e.resolve(r))}static between(e,n,r){let o=e.pos-n.pos;if((!r||o)&&(r=o>=0?1:-1),!n.parent.inlineContent){let i=Be.findFrom(n,r,!0)||Be.findFrom(n,-r,!0);if(i)n=i.$head;else return Be.near(n,r)}return e.parent.inlineContent||(o==0?e=n:(e=(Be.findFrom(e,-r,!0)||Be.findFrom(e,r,!0)).$anchor,e.pos0?0:1);o>0?s=0;s+=o){let l=e.child(s);if(l.isAtom){if(!i&&Oe.isSelectable(l))return Oe.create(t,n-(o<0?l.nodeSize:0))}else{let a=Gl(t,l,n+o,o<0?l.childCount:0,o,i);if(a)return a}n+=l.nodeSize*o}return null}function OS(t,e,n){let r=t.steps.length-1;if(r{s==null&&(s=c)}),t.setSelection(Be.near(t.doc.resolve(s),n))}const IS=1,Np=2,LS=4;class WP extends BP{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|=Np,this}ensureMarks(e){return je.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&Np)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~Np,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)||je.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let o=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(o.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),r=r??n,!e)return this.deleteRange(n,r);let i=this.storedMarks;if(!i){let s=this.doc.resolve(n);i=r==n?s.marks():s.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,o.text(e,i)),this.selection.empty||this.setSelection(Be.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|=LS,this}get scrolledIntoView(){return(this.updated&LS)>0}}function NS(t,e){return!e||!t?t:t.bind(e)}class Vu{constructor(e,n,r){this.name=e,this.init=NS(n.init,r),this.apply=NS(n.apply,r)}}const VP=[new Vu("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Vu("selection",{init(t,e){return t.selection||Be.atStart(e.doc)},apply(t){return t.selection}}),new Vu("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Vu("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class a1{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=VP.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 Vu(r.key,r.spec.state,r))})}}class Na{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 o=e[r],i=o.spec.state;i&&i.toJSON&&(n[r]=i.toJSON.call(o,this[o.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 o=new a1(e.schema,e.plugins),i=new Na(o);return o.fields.forEach(s=>{if(s.name=="doc")i.doc=As.fromJSON(e.schema,n.doc);else if(s.name=="selection")i.selection=Be.fromJSON(i.doc,n.selection);else if(s.name=="storedMarks")n.storedMarks&&(i.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],u=a.spec.state;if(a.key==s.name&&u&&u.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){i[s.name]=u.fromJSON.call(a,e,n[l],i);return}}i[s.name]=s.init(e,i)}}),i}}function u2(t,e,n){for(let r in t){let o=t[r];o instanceof Function?o=o.bind(e):r=="handleDOMEvents"&&(o=u2(o,e,{})),n[r]=o}return n}class mi{constructor(e){this.spec=e,this.props={},e.props&&u2(e.props,this,this.props),this.key=e.key?e.key.key:d2("plugin")}getState(e){return e[this.key]}}const l1=Object.create(null);function d2(t){return t in l1?t+"$"+ ++l1[t]:(l1[t]=0,t+"$")}class vl{constructor(e="key"){this.key=d2(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}var jP=/[A-Z]/g,GP=/^ms-/,c1={};function KP(t){return"-"+t.toLowerCase()}function YP(t){if(c1.hasOwnProperty(t))return c1[t];var e=t.replace(jP,KP);return c1[t]=GP.test(e)?"-"+e:e}function XP(t){return YP(t)}function qP(t,e){return XP(t)+":"+e}function ZP(t){var e="";for(var n in t){var r=t[n];typeof r!="string"&&typeof r!="number"||(e&&(e+=";"),e+=qP(n,r))}return e}function h2(){return typeof document<"u"?document:null}function p2(t,e){if(typeof t!="string")return[t];var n=[t];typeof e=="string"||Array.isArray(e)?e={brackets:e}:e||(e={});var r=e.brackets?Array.isArray(e.brackets)?e.brackets:[e.brackets]:["{}","[]","()"],o=e.escape||"___",i=!!e.flat;r.forEach(function(a){var u=new RegExp(["\\",a[0],"[^\\",a[0],"\\",a[1],"]*\\",a[1]].join("")),c=[];function d(h,p,f){var g=n.push(h.slice(a[0].length,-a[1].length))-1;return c.push(g),o+g+o}n.forEach(function(h,p){for(var f,g=0;h!=f;)if(f=h,h=h.replace(u,d),g++>1e4)throw Error("References have circular dependency. Please, check them.");n[p]=h}),c=c.reverse(),n=n.map(function(h){return c.forEach(function(p){h=h.replace(new RegExp("(\\"+o+p+"\\"+o+")","g"),a[0]+"$1"+a[1])}),h})});var s=new RegExp("\\"+o+"([0-9]+)\\"+o);function l(a,u,c){for(var d=[],h,p=0;h=s.exec(a);){if(p++>1e4)throw Error("Circular references in parenthesis");d.push(a.slice(0,h.index)),d.push(l(u[h[1]],u)),a=a.slice(h.index+h[0].length)}return d.push(a),d}return i?n:l(n[0],n)}function f2(t,e){if(e&&e.flat){var n=e&&e.escape||"___",r=t[0],o;if(!r)return"";for(var i=new RegExp("\\"+n+"([0-9]+)\\"+n),s=0;r!=o;){if(s++>1e4)throw Error("Circular references in "+t);o=r,r=r.replace(i,l)}return r}return t.reduce(function a(u,c){return Array.isArray(c)&&(c=c.reduce(a,"")),u+c},"");function l(a,u){if(t[u]==null)throw Error("Reference "+u+"is undefined");return t[u]}}function g2(t,e){return Array.isArray(t)?f2(t,e):p2(t,e)}g2.parse=p2;g2.stringify=f2;const JP={id:"extension.command.copy.label",message:"Copy",comment:"Label for copy command."},QP={id:"extension.command.copy.description",message:"Copy the selected text",comment:"Description for copy command."},e5={id:"extension.command.cut.label",message:"Cut",comment:"Label for cut command."},t5={id:"extension.command.cut.description",message:"Cut the selected text",comment:"Description for cut command."},n5={id:"extension.command.paste.label",message:"Paste",comment:"Label for paste command."},r5={id:"extension.command.paste.description",message:"Paste content into the editor",comment:"Description for paste command."},o5={id:"extension.command.select-all.label",message:"Select all",comment:"Label for select all command."},i5={id:"extension.command.select-all.description",message:"Select all content within the editor",comment:"Description for select all command."};var Ws=Object.freeze({__proto__:null,COPY_DESCRIPTION:QP,COPY_LABEL:JP,CUT_DESCRIPTION:t5,CUT_LABEL:e5,PASTE_DESCRIPTION:r5,PASTE_LABEL:n5,SELECT_ALL_DESCRIPTION:i5,SELECT_ALL_LABEL:o5});const s5={id:"keyboard.shortcut.escape",message:"Enter",comment:"Label for escape key in shortcuts."},a5={id:"keyboard.shortcut.command",message:"Command",comment:"Label for command key in shortcuts."},l5={id:"keyboard.shortcut.control",message:"Control",comment:"Label for control key in shortcuts."},c5={id:"keyboard.shortcut.enter",message:"Enter",comment:"Label for enter key in shortcuts."},u5={id:"keyboard.shortcut.shift",message:"Shift",comment:"Label for shift key in shortcuts."},d5={id:"keyboard.shortcut.alt",message:"Alt",comment:"Label for alt key in shortcuts."},h5={id:"keyboard.shortcut.capsLock",message:"Caps Lock",comment:"Label for caps lock key in shortcuts."},p5={id:"keyboard.shortcut.backspace",message:"Backspace",comment:"Label for backspace key in shortcuts."},f5={id:"keyboard.shortcut.tab",message:"Tab",comment:"Label for tab key in shortcuts."},g5={id:"keyboard.shortcut.space",message:"Space",comment:"Label for space key in shortcuts."},m5={id:"keyboard.shortcut.delete",message:"Delete",comment:"Label for delete key in shortcuts."},v5={id:"keyboard.shortcut.pageUp",message:"Page Up",comment:"Label for page up key in shortcuts."},y5={id:"keyboard.shortcut.pageDown",message:"Page Down",comment:"Label for page down key in shortcuts."},b5={id:"keyboard.shortcut.home",message:"Home",comment:"Label for home key in shortcuts."},w5={id:"keyboard.shortcut.end",message:"End",comment:"Label for end key in shortcuts."},x5={id:"keyboard.shortcut.arrowLeft",message:"Arrow Left",comment:"Label for arrow left key in shortcuts."},k5={id:"keyboard.shortcut.arrowRight",message:"Arrow Right",comment:"Label for arrow right key in shortcuts."},E5={id:"keyboard.shortcut.arrowUp",message:"Arrow Up",comment:"Label for arrow up key in shortcuts."},S5={id:"keyboard.shortcut.arrowDown",message:"Arrow Down",comment:"Label for arrowDown key in shortcuts."};var nn=Object.freeze({__proto__:null,ALT_KEY:d5,ARROW_DOWN_KEY:S5,ARROW_LEFT_KEY:x5,ARROW_RIGHT_KEY:k5,ARROW_UP_KEY:E5,BACKSPACE_KEY:p5,CAPS_LOCK_KEY:h5,COMMAND_KEY:a5,CONTROL_KEY:l5,DELETE_KEY:m5,END_KEY:w5,ENTER_KEY:c5,ESCAPE_KEY:s5,HOME_KEY:b5,PAGE_DOWN_KEY:y5,PAGE_UP_KEY:v5,SHIFT_KEY:u5,SPACE_KEY:g5,TAB_KEY:f5});const C5={id:"extension.command.toggle-blockquote.label",message:"Blockquote",comment:"Label for blockquote formatting command."},T5={id:"extension.command.toggle-blockquote.description",message:"Add blockquote formatting to the selected text",comment:"Description for blockquote formatting command."};var $S=Object.freeze({__proto__:null,DESCRIPTION:T5,LABEL:C5});const A5={id:"extension.command.toggle-bold.label",message:"Bold",comment:"Label for bold formatting command."},_5={id:"extension.command.toggle-bold.description",message:"Add bold formatting to the selected text",comment:"Description for bold formatting command."};var DS=Object.freeze({__proto__:null,DESCRIPTION:_5,LABEL:A5});const R5={id:"extension.command.toggle-code-block.label",message:"Codeblock",comment:"Label for the code block command."},M5={id:"extension.command.toggle-code-block.description",message:"Add a code block",comment:"Description for the code block command."};var O5=Object.freeze({__proto__:null,DESCRIPTION:M5,LABEL:R5});const I5={id:"extension.command.toggle-code.label",message:"Code",comment:"Label for the inline code formatting."},L5={id:"extension.command.toggle-code.description",message:"Add inline code formatting to the selected text",comment:"Description for the inline code formatting command."};var N5=Object.freeze({__proto__:null,DESCRIPTION:L5,LABEL:I5});const $5={id:"extension.command.toggle-heading.label",message:`{level, select, 1 {Heading 1}
+`:"";return`${r}${o}For more information visit ${PS}#${t.toLowerCase()}`}var zS=class extends mS.BaseError{constructor({code:t,message:e,disableLogging:n=!1}={}){const r=f4(t)?t:re.CUSTOM;super(g4(r,e)),this.errorCode=r,this.url=`${PS}#${r.toLowerCase()}`,n||console.error(this.message)}static create(t={}){return new zS(t)}};function be(t,e){if(!t)throw zS.create(e)}function Ap(t){if(typeof t!="object"||t===null)return t;const e=Symbol.toStringTag in t&&t[Symbol.toStringTag]==="Module"?t.default??t:t;return e&&typeof t=="object"&&"__esModule"in e&&e.__esModule&&e.default!==void 0?e.default:e}function ha(t,e={}){return t}function An(t){this.content=t}An.prototype={constructor:An,find:function(t){for(var e=0;e>1}},An.from=function(t){if(t instanceof An)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new An(e)};function FS(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let o=t.child(r),i=e.child(r);if(o==i){n+=o.nodeSize;continue}if(!o.sameMarkup(i))return n;if(o.isText&&o.text!=i.text){for(let s=0;o.text[s]==i.text[s];s++)n++;return n}if(o.content.size||i.content.size){let s=FS(o.content,i.content,n+1);if(s!=null)return s}n+=o.nodeSize}}function BS(t,e,n,r){for(let o=t.childCount,i=e.childCount;;){if(o==0||i==0)return o==i?null:{a:n,b:r};let s=t.child(--o),l=e.child(--i),a=s.nodeSize;if(s==l){n-=a,r-=a;continue}if(!s.sameMarkup(l))return{a:n,b:r};if(s.isText&&s.text!=l.text){let u=0,c=Math.min(s.text.length,l.text.length);for(;ue&&r(a,o+l,i||null,s)!==!1&&a.content.size){let c=l+1;a.nodesBetween(Math.max(0,e-c),Math.min(a.content.size,n-c),r,o+c)}l=u}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,o){let i="",s=!0;return this.nodesBetween(e,n,(l,a)=>{l.isText?(i+=l.text.slice(Math.max(e,a)-a,n-a),s=!r):l.isLeaf?(o?i+=typeof o=="function"?o(l):o:l.type.spec.leafText&&(i+=l.type.spec.leafText(l)),s=!r):!s&&l.isBlock&&(i+=r,s=!0)},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,o=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(r)&&(o[o.length-1]=n.withText(n.text+r.text),i=1);ie)for(let i=0,s=0;se&&((sn)&&(l.isText?l=l.cut(Math.max(0,e-s),Math.min(l.text.length,n-s)):l=l.cut(Math.max(0,e-s-1),Math.min(l.content.size,n-s-1))),r.push(l),o+=l.nodeSize),s=a}return new J(r,o)}cutByIndex(e,n){return e==n?J.empty:e==0&&n==this.content.length?this:new J(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let o=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return o[e]=n,new J(o,i)}addToStart(e){return new J([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new J(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;nthis.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let r=0,o=0;;r++){let i=this.child(r),s=o+i.nodeSize;if(s>=e)return s==e||n>0?_p(r+1,s):_p(r,o);o=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return J.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new J(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return J.empty;let n,r=0;for(let o=0;othis.type.rank&&(n||(n=e.slice(0,o)),n.push(this),r=!0),n&&n.push(i)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;nr.type.rank-o.type.rank),n}}Ge.none=[];class Mp extends Error{}class ae{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=US(this.content,e+this.openStart,n);return r&&new ae(r,this.openStart,this.openEnd)}removeBetween(e,n){return new ae(HS(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return ae.empty;let r=n.openStart||0,o=n.openEnd||0;if(typeof r!="number"||typeof o!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new ae(J.fromJSON(e,n.content),r,o)}static maxOpen(e,n=!0){let r=0,o=0;for(let i=e.firstChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.lastChild)o++;return new ae(e,r,o)}}ae.empty=new ae(J.empty,0,0);function HS(t,e,n){let{index:r,offset:o}=t.findIndex(e),i=t.maybeChild(r),{index:s,offset:l}=t.findIndex(n);if(o==e||i.isText){if(l!=n&&!t.child(s).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=s)throw new RangeError("Removing non-flat range");return t.replaceChild(r,i.copy(HS(i.content,e-o-1,n-o-1)))}function US(t,e,n,r){let{index:o,offset:i}=t.findIndex(e),s=t.maybeChild(o);if(i==e||s.isText)return r&&!r.canReplace(o,o,n)?null:t.cut(0,e).append(n).append(t.cut(e));let l=US(s.content,e-i-1,n);return l&&t.replaceChild(o,s.copy(l))}function m4(t,e,n){if(n.openStart>t.depth)throw new Mp("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new Mp("Inconsistent open depths");return WS(t,e,n,0)}function WS(t,e,n,r){let o=t.index(r),i=t.node(r);if(o==e.index(r)&&r=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function Ru(t,e,n,r){let o=(e||t).node(n),i=0,s=e?e.index(n):o.childCount;t&&(i=t.index(n),t.depth>n?i++:t.textOffset&&(pa(t.nodeAfter,r),i++));for(let l=i;lo&&s1(t,e,o+1),s=r.depth>o&&s1(n,r,o+1),l=[];return Ru(null,t,o,l),i&&s&&e.index(o)==n.index(o)?(VS(i,s),pa(fa(i,jS(t,e,n,r,o+1)),l)):(i&&pa(fa(i,Op(t,e,o+1)),l),Ru(e,n,o,l),s&&pa(fa(s,Op(n,r,o+1)),l)),Ru(r,null,o,l),new J(l)}function Op(t,e,n){let r=[];if(Ru(null,t,n,r),t.depth>n){let o=s1(t,e,n+1);pa(fa(o,Op(t,e,n+1)),r)}return Ru(e,null,n,r),new J(r)}function v4(t,e){let n=e.depth-t.openStart,o=e.node(n).copy(t.content);for(let i=n-1;i>=0;i--)o=e.node(i).copy(J.from(o));return{start:o.resolveNoCache(t.openStart+n),end:o.resolveNoCache(o.content.size-t.openEnd-n)}}class $l{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],o=e.child(n);return r?e.child(n).cut(r):o}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],o=n==0?0:this.path[n*3-1]+1;for(let i=0;i0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new ga(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],o=0,i=n;for(let s=e;;){let{index:l,offset:a}=s.content.findIndex(i),u=i-a;if(r.push(s,l,o+a),!u||(s=s.child(l),s.isText))break;i=u-1,o+=a+1}return new $l(n,r,i)}static resolveCached(e,n){for(let o=0;oe&&this.nodesBetween(e,n,i=>(r.isInSet(i.marks)&&(o=!0),!o)),o}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),GS(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=J.empty,o=0,i=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,o,i),l=s&&s.matchFragment(this.content,n);if(!l||!l.validEnd)return!1;for(let a=o;an.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r=null;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let o=J.fromJSON(e,n.content);return e.nodeType(n.type).create(n.attrs,o,r)}};as.prototype.text=void 0;class Ip extends as{constructor(e,n,r,o){if(super(e,n,null,o),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):GS(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new Ip(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Ip(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function GS(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class ma{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new x4(e,n);if(r.next==null)return ma.empty;let o=KS(r);r.next&&r.err("Unexpected trailing text");let i=A4(T4(o));return _4(i,r),i}matchType(e){for(let n=0;nu.createAndFill()));for(let u=0;u=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let o=0;o{let i=o+(r.validEnd?"*":" ")+" ";for(let s=0;s"+e.indexOf(r.next[s].next);return i}).join(`
+`)}}ma.empty=new ma(!0);class x4{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function KS(t){let e=[];do e.push(w4(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function w4(t){let e=[];do e.push(k4(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function k4(t){let e=C4(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=E4(t,e);else break;return e}function YS(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function E4(t,e){let n=YS(t),r=n;return t.eat(",")&&(t.next!="}"?r=YS(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function S4(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let o=[];for(let i in n){let s=n[i];s.groups.indexOf(e)>-1&&o.push(s)}return o.length==0&&t.err("No node type or group '"+e+"' found"),o}function C4(t){if(t.eat("(")){let e=KS(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=S4(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function T4(t){let e=[[]];return o(i(t,0),n()),e;function n(){return e.push([])-1}function r(s,l,a){let u={term:a,to:l};return e[s].push(u),u}function o(s,l){s.forEach(a=>a.to=l)}function i(s,l){if(s.type=="choice")return s.exprs.reduce((a,u)=>a.concat(i(u,l)),[]);if(s.type=="seq")for(let a=0;;a++){let u=i(s.exprs[a],l);if(a==s.exprs.length-1)return u;o(u,l=n())}else if(s.type=="star"){let a=n();return r(l,a),o(i(s.expr,a),a),[r(a)]}else if(s.type=="plus"){let a=n();return o(i(s.expr,l),a),o(i(s.expr,a),a),[r(a)]}else{if(s.type=="opt")return[r(l)].concat(i(s.expr,l));if(s.type=="range"){let a=l;for(let u=0;u{t[s].forEach(({term:l,to:a})=>{if(!l)return;let u;for(let c=0;c{u||o.push([l,u=[]]),u.indexOf(c)==-1&&u.push(c)})})});let i=e[r.join(",")]=new ma(r.indexOf(t.length-1)>-1);for(let s=0;s-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;nr[i]=new nD(i,n,s));let o=n.spec.topNode||"doc";if(!r[o])throw new RangeError("Schema is missing its top node type ('"+o+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};class R4{constructor(e){this.hasDefault=Object.prototype.hasOwnProperty.call(e,"default"),this.default=e.default}get isRequired(){return!this.hasDefault}}class Mu{constructor(e,n,r,o){this.name=e,this.rank=n,this.schema=r,this.spec=o,this.attrs=QS(o.attrs),this.excluded=null;let i=ZS(this.attrs);this.instance=i?new Ge(this,i):null}create(e=null){return!e&&this.instance?this.instance:new Ge(this,JS(this.attrs,e))}static compile(e,n){let r=Object.create(null),o=0;return e.forEach((i,s)=>r[i]=new Mu(i,o++,n,s)),r}removeFromSet(e){for(var n=0;n-1}}let M4=class{constructor(e){this.cached=Object.create(null);let n=this.spec={};for(let o in e)n[o]=e[o];n.nodes=An.from(e.nodes),n.marks=An.from(e.marks||{}),this.nodes=c1.compile(this.spec.nodes,this),this.marks=Mu.compile(this.spec.marks,this);let r=Object.create(null);for(let o in this.nodes){if(o in this.marks)throw new RangeError(o+" can not be both a node and a mark");let i=this.nodes[o],s=i.spec.content||"",l=i.spec.marks;i.contentMatch=r[s]||(r[s]=ma.parse(s,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.markSet=l=="_"?null:l?eC(this,l.split(" ")):l==""||!i.inlineContent?[]:null}for(let o in this.marks){let i=this.marks[o],s=i.spec.excludes;i.excluded=s==null?[i]:s==""?[]:eC(this,s.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,o){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof c1){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,r,o)}text(e,n){let r=this.nodes.text;return new Ip(r,r.defaultAttrs,e,Ge.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeFromJSON(e){return as.fromJSON(this,e)}markFromJSON(e){return Ge.fromJSON(this,e)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}};function eC(t,e){let n=[];for(let r=0;r-1)&&n.push(s=a)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}class va{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[],n.forEach(r=>{r.tag?this.tags.push(r):r.style&&this.styles.push(r)}),this.normalizeLists=!this.tags.some(r=>{if(!/^(ul|ol)\b/.test(r.tag)||!r.node)return!1;let o=e.nodes[r.node];return o.contentMatch.matchType(o)})}parse(e,n={}){let r=new oC(this,n,!1);return r.addAll(e,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new oC(this,n,!0);return r.addAll(e,n.from,n.to),ae.maxOpen(r.finish())}matchTag(e,n,r){for(let o=r?this.tags.indexOf(r)+1:0;oe.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=n))){if(s.getAttrs){let a=s.getAttrs(n);if(a===!1)continue;s.attrs=a||void 0}return s}}}static schemaRules(e){let n=[];function r(o){let i=o.priority==null?50:o.priority,s=0;for(;s{r(s=iC(s)),s.mark||s.ignore||s.clearMark||(s.mark=o)})}for(let o in e.nodes){let i=e.nodes[o].spec.parseDOM;i&&i.forEach(s=>{r(s=iC(s)),s.node||s.ignore||s.mark||(s.node=o)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new va(e,va.schemaRules(e)))}}const tC={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},O4={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},nC={ol:!0,ul:!0},Lp=1,Np=2,Ou=4;function rC(t,e,n){return e!=null?(e?Lp:0)|(e==="full"?Np:0):t&&t.whitespace=="pre"?Lp|Np:n&~Ou}class $p{constructor(e,n,r,o,i,s,l){this.type=e,this.attrs=n,this.marks=r,this.pendingMarks=o,this.solid=i,this.options=l,this.content=[],this.activeMarks=Ge.none,this.stashMarks=[],this.match=s||(l&Ou?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(J.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,o;return(o=r.findWrapping(e.type))?(this.match=r,o):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Lp)){let r=this.content[this.content.length-1],o;if(r&&r.isText&&(o=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==o[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-o[0].length))}}let n=J.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(J.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}popFromStashMark(e){for(let n=this.stashMarks.length-1;n>=0;n--)if(e.eq(this.stashMarks[n]))return this.stashMarks.splice(n,1)[0]}applyPending(e){for(let n=0,r=this.pendingMarks;nthis.addAll(e)),s&&this.sync(l),this.needsBlock=a}else this.withStyleRules(e,()=>{this.addElementByRule(e,i,i.consuming===!1?o:void 0)})}leafFallback(e){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
+`))}ignoreFallback(e){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"))}readStyles(e){let n=Ge.none,r=Ge.none;for(let o=0;o{s.clearMark(l)&&(r=l.addToSet(r))}):n=this.parser.schema.marks[s.mark].create(s.attrs).addToSet(n),s.consuming===!1)i=s;else break}return[n,r]}addElementByRule(e,n,r){let o,i,s;n.node?(i=this.parser.schema.nodes[n.node],i.isLeaf?this.insertNode(i.create(n.attrs))||this.leafFallback(e):o=this.enter(i,n.attrs||null,n.preserveWhitespace)):(s=this.parser.schema.marks[n.mark].create(n.attrs),this.addPendingMark(s));let l=this.top;if(i&&i.isLeaf)this.findInside(e);else if(r)this.addElement(e,r);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a));else{let a=e;typeof n.contentElement=="string"?a=e.querySelector(n.contentElement):typeof n.contentElement=="function"?a=n.contentElement(e):n.contentElement&&(a=n.contentElement),this.findAround(e,a,!0),this.addAll(a)}o&&this.sync(l)&&this.open--,s&&this.removePendingMark(s,l)}addAll(e,n,r){let o=n||0;for(let i=n?e.childNodes[n]:e.firstChild,s=r==null?null:e.childNodes[r];i!=s;i=i.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(i);this.findAtPoint(e,o)}findPlace(e){let n,r;for(let o=this.open;o>=0;o--){let i=this.nodes[o],s=i.findWrapping(e);if(s&&(!n||n.length>s.length)&&(n=s,r=i,!s.length)||i.solid)break}if(!n)return!1;this.sync(r);for(let o=0;othis.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)}sync(e){for(let n=this.open;n>=0;n--)if(this.nodes[n]==e)return this.open=n,!0;return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let o=r.length-1;o>=0;o--)e+=r[o].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,o=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(o?0:1),s=(l,a)=>{for(;l>=0;l--){let u=n[l];if(u==""){if(l==n.length-1||l==0)continue;for(;a>=i;a--)if(s(l-1,a))return!0;return!1}else{let c=a>0||a==0&&o?this.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!c||c.name!=u&&c.groups.indexOf(u)==-1)return!1;a--}}return!0};return s(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}addPendingMark(e){let n=D4(e,this.top.pendingMarks);n&&this.top.stashMarks.push(n),this.top.pendingMarks=e.addToSet(this.top.pendingMarks)}removePendingMark(e,n){for(let r=this.open;r>=0;r--){let o=this.nodes[r];if(o.pendingMarks.lastIndexOf(e)>-1)o.pendingMarks=e.removeFromSet(o.pendingMarks);else{o.activeMarks=e.removeFromSet(o.activeMarks);let s=o.popFromStashMark(e);s&&o.type&&o.type.allowsMarkType(s.type)&&(o.activeMarks=s.addToSet(o.activeMarks))}if(o==n)break}}}function I4(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&nC.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function L4(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function N4(t){let e=/\s*([\w-]+)\s*:\s*([^;]+)/g,n,r=[];for(;n=e.exec(t);)r.push(n[1],n[2].trim());return r}function iC(t){let e={};for(let n in t)e[n]=t[n];return e}function $4(t,e){let n=e.schema.nodes;for(let r in n){let o=n[r];if(!o.allowsMarkType(t))continue;let i=[],s=l=>{i.push(l);for(let a=0;a{if(i.length||s.marks.length){let l=0,a=0;for(;l=0;o--){let i=this.serializeMark(e.marks[o],e.isInline,n);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,n,r={}){let o=this.marks[e.type.name];return o&&Dr.renderSpec(u1(r),o(e,n))}static renderSpec(e,n,r=null){if(typeof n=="string")return{dom:e.createTextNode(n)};if(n.nodeType!=null)return{dom:n};if(n.dom&&n.dom.nodeType!=null)return n;let o=n[0],i=o.indexOf(" ");i>0&&(r=o.slice(0,i),o=o.slice(i+1));let s,l=r?e.createElementNS(r,o):e.createElement(o),a=n[1],u=1;if(a&&typeof a=="object"&&a.nodeType==null&&!Array.isArray(a)){u=2;for(let c in a)if(a[c]!=null){let d=c.indexOf(" ");d>0?l.setAttributeNS(c.slice(0,d),c.slice(d+1),a[c]):l.setAttribute(c,a[c])}}for(let c=u;cu)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:h,contentDOM:p}=Dr.renderSpec(e,d,r);if(l.appendChild(h),p){if(s)throw new RangeError("Multiple content holes");s=p}}}return{dom:l,contentDOM:s}}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Dr(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=sC(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return sC(e.marks)}}function sC(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function u1(t){return t.document||window.document}const aC=65535,lC=Math.pow(2,16);function P4(t,e){return t+e*lC}function cC(t){return t&aC}function z4(t){return(t-(t&aC))/lC}const uC=1,dC=2,Dp=4,hC=8;class d1{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&hC)>0}get deletedBefore(){return(this.delInfo&(uC|Dp))>0}get deletedAfter(){return(this.delInfo&(dC|Dp))>0}get deletedAcross(){return(this.delInfo&Dp)>0}}class Pr{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Pr.empty)return Pr.empty}recover(e){let n=0,r=cC(e);if(!this.inverted)for(let o=0;oe)break;let u=this.ranges[l+i],c=this.ranges[l+s],d=a+u;if(e<=d){let h=u?e==a?-1:e==d?1:n:n,p=a+o+(h<0?0:c);if(r)return p;let f=e==(n<0?a:d)?null:P4(l/3,e-a),g=e==a?dC:e==d?uC:Dp;return(n<0?e!=a:e!=d)&&(g|=hC),new d1(p,g,f)}o+=c-u}return r?e+o:new d1(e+o,0,null)}touches(e,n){let r=0,o=cC(n),i=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;le)break;let u=this.ranges[l+i],c=a+u;if(e<=c&&l==o*3)return!0;r+=this.ranges[l+s]-u}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let o=0,i=0;o=0;n--){let o=e.getMirror(n);this.appendMap(e.maps[n].invert(),o!=null&&o>n?r-o-1:void 0)}}invert(){let e=new Dl;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;ri&&a!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),o),n.openStart,n.openEnd);return jt.fromReplace(e,this.from,this.to,i)}invert(){return new _o(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new wi(n.pos,r.pos,this.mark)}merge(e){return e instanceof wi&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new wi(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new wi(n.from,n.to,e.markFromJSON(n.mark))}}rn.jsonID("addMark",wi);class _o extends rn{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new ae(p1(n.content,o=>o.mark(this.mark.removeFromSet(o.marks)),e),n.openStart,n.openEnd);return jt.fromReplace(e,this.from,this.to,r)}invert(){return new wi(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new _o(n.pos,r.pos,this.mark)}merge(e){return e instanceof _o&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new _o(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new _o(n.from,n.to,e.markFromJSON(n.mark))}}rn.jsonID("removeMark",_o);class ls extends rn{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return jt.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return jt.fromReplace(e,this.pos,this.pos+1,new ae(J.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let o=0;or.pos?null:new Gt(n.pos,r.pos,o,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Gt(n.from,n.to,n.gapFrom,n.gapTo,ae.fromJSON(e,n.slice),n.insert,!!n.structure)}}rn.jsonID("replaceAround",Gt);function f1(t,e,n){let r=t.resolve(e),o=n-e,i=r.depth;for(;o>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,o--;if(o>0){let s=r.node(i).maybeChild(r.indexAfter(i));for(;o>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,o--}}return!1}function F4(t,e,n,r){let o=[],i=[],s,l;t.doc.nodesBetween(e,n,(a,u,c)=>{if(!a.isInline)return;let d=a.marks;if(!r.isInSet(d)&&c.type.allowsMarkType(r.type)){let h=Math.max(u,e),p=Math.min(u+a.nodeSize,n),f=r.addToSet(d);for(let g=0;gt.step(a)),i.forEach(a=>t.step(a))}function B4(t,e,n,r){let o=[],i=0;t.doc.nodesBetween(e,n,(s,l)=>{if(!s.isInline)return;i++;let a=null;if(r instanceof Mu){let u=s.marks,c;for(;c=r.isInSet(u);)(a||(a=[])).push(c),u=c.removeFromSet(u)}else r?r.isInSet(s.marks)&&(a=[r]):a=s.marks;if(a&&a.length){let u=Math.min(l+s.nodeSize,n);for(let c=0;ct.step(new _o(s.from,s.to,s.style)))}function H4(t,e,n,r=n.contentMatch){let o=t.doc.nodeAt(e),i=[],s=e+1;for(let l=0;l=0;l--)t.step(i[l])}function U4(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function zl(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth;;--r){let o=t.$from.node(r),i=t.$from.index(r),s=t.$to.indexAfter(r);if(rn;f--)g||r.index(f)>0?(g=!0,c=J.from(r.node(f).copy(c)),d++):a--;let h=J.empty,p=0;for(let f=i,g=!1;f>n;f--)g||o.after(f+1)=0;s--){if(r.size){let l=n[s].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=J.from(n[s].type.create(n[s].attrs,r))}let o=e.start,i=e.end;t.step(new Gt(o,i,o,i,new ae(r,0,0),n.length,!0))}function K4(t,e,n,r,o){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=t.steps.length;t.doc.nodesBetween(e,n,(s,l)=>{if(s.isTextblock&&!s.hasMarkup(r,o)&&Y4(t.doc,t.mapping.slice(i).map(l),r)){t.clearIncompatible(t.mapping.slice(i).map(l,1),r);let a=t.mapping.slice(i),u=a.map(l,1),c=a.map(l+s.nodeSize,1);return t.step(new Gt(u,c,u+1,c-1,new ae(J.from(r.create(o,null,s.marks)),0,0),1,!0)),!1}})}function Y4(t,e,n){let r=t.resolve(e),o=r.index();return r.parent.canReplaceWith(o,o+1,n)}function X4(t,e,n,r,o){let i=t.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");n||(n=i.type);let s=n.create(r,null,o||i.marks);if(i.isLeaf)return t.replaceWith(e,e+i.nodeSize,s);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new Gt(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new ae(J.from(s),0,0),1,!0))}function Fl(t,e,n=1,r){let o=t.resolve(e),i=o.depth-n,s=r&&r[r.length-1]||o.parent;if(i<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!s.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(let u=o.depth-1,c=n-2;u>i;u--,c--){let d=o.node(u),h=o.index(u);if(d.type.spec.isolating)return!1;let p=d.content.cutByIndex(h,d.childCount),f=r&&r[c+1];f&&(p=p.replaceChild(0,f.type.create(f.attrs)));let g=r&&r[c]||d;if(!d.canReplace(h+1,d.childCount)||!g.type.validContent(p))return!1}let l=o.indexAfter(i),a=r&&r[0];return o.node(i).canReplaceWith(l,l,a?a.type:o.node(i+1).type)}function q4(t,e,n=1,r){let o=t.doc.resolve(e),i=J.empty,s=J.empty;for(let l=o.depth,a=o.depth-n,u=n-1;l>a;l--,u--){i=J.from(o.node(l).copy(i));let c=r&&r[u];s=J.from(c?c.type.create(c.attrs,s):o.node(l).copy(s))}t.step(new pn(e,e,new ae(i.append(s),n,n),!0))}function Iu(t,e){let n=t.resolve(e),r=n.index();return Z4(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function Z4(t,e){return!!(t&&e&&!t.isLeaf&&t.canAppend(e))}function J4(t,e,n){let r=new pn(e-n,e+n,ae.empty,!0);t.step(r)}function fC(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let o=r.depth-1;o>=0;o--){let i=r.index(o);if(r.node(o).canReplaceWith(i,i,n))return r.before(o+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let o=r.depth-1;o>=0;o--){let i=r.indexAfter(o);if(r.node(o).canReplaceWith(i,i,n))return r.after(o+1);if(i=0;s--){let l=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1,a=r.index(s)+(l>0?1:0),u=r.node(s),c=!1;if(i==1)c=u.canReplace(a,a,o);else{let d=u.contentMatchAt(a).findWrapping(o.firstChild.type);c=d&&u.canReplaceWith(a,a,d[0])}if(c)return l==0?r.pos:l<0?r.before(s+1):r.after(s+1)}return null}function m1(t,e,n=e,r=ae.empty){if(e==n&&!r.size)return null;let o=t.resolve(e),i=t.resolve(n);return gC(o,i,r)?new pn(e,n,r):new eP(o,i,r).fit()}function gC(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class eP{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=J.empty;for(let o=0;o<=e.depth;o++){let i=e.node(o);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(o))})}for(let o=e.depth;o>0;o--)this.placed=J.from(e.node(o).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let u=this.findFittable();u?this.placeNodes(u):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,o=this.close(e<0?this.$to:r.doc.resolve(e));if(!o)return null;let i=this.placed,s=r.depth,l=o.depth;for(;s&&l&&i.childCount==1;)i=i.firstChild.content,s--,l--;let a=new ae(i,s,l);return e>-1?new Gt(r.pos,e,this.$to.pos,this.$to.end(),a,n):a.size||r.pos!=this.$to.pos?new pn(r.pos,o.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,o=this.unplaced.openEnd;r1&&(o=0),i.type.spec.isolating&&o<=r){e=r;break}n=i.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let o,i=null;r?(i=v1(this.unplaced.content,r-1).firstChild,o=i.content):o=this.unplaced.content;let s=o.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:u}=this.frontier[l],c,d=null;if(n==1&&(s?u.matchType(s.type)||(d=u.fillBefore(J.from(s),!1)):i&&a.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:l,parent:i,inject:d};if(n==2&&s&&(c=u.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:l,parent:i,wrap:c};if(i&&u.matchType(i.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,o=v1(e,n);return!o.childCount||o.firstChild.isLeaf?!1:(this.unplaced=new ae(e,n+1,Math.max(r,o.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,o=v1(e,n);if(o.childCount<=1&&n>0){let i=e.size-n<=n+o.size;this.unplaced=new ae(Lu(e,n-1,1),n-1,i?n-1:r)}else this.unplaced=new ae(Lu(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:o,wrap:i}){for(;this.depth>n;)this.closeFrontierNode();if(i)for(let g=0;g1||a==0||g.content.size)&&(d=m,c.push(mC(g.mark(h.allowedMarks(g.marks)),u==1?a:0,u==l.childCount?p:-1)))}let f=u==l.childCount;f||(p=-1),this.placed=Nu(this.placed,n,J.from(c)),this.frontier[n].match=d,f&&p<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let g=0,m=l;g1&&o==this.$to.end(--r);)++o;return o}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:o}=this.frontier[n],i=n=0;l--){let{match:a,type:u}=this.frontier[l],c=y1(e,l,u,a,!0);if(!c||c.childCount)continue e}return{depth:n,fit:s,move:i?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=Nu(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let o=e.node(r),i=o.type.contentMatch.fillBefore(o.content,!0,e.index(r));this.openFrontierNode(o.type,o.attrs,i)}return e}openFrontierNode(e,n=null,r){let o=this.frontier[this.depth];o.match=o.match.matchType(e),this.placed=Nu(this.placed,this.depth,J.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(J.empty,!0);n.childCount&&(this.placed=Nu(this.placed,this.frontier.length,n))}}function Lu(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Lu(t.firstChild.content,e-1,n)))}function Nu(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Nu(t.lastChild.content,e-1,n)))}function v1(t,e){for(let n=0;n1&&(r=r.replaceChild(0,mC(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(J.empty,!0)))),t.copy(r)}function y1(t,e,n,r,o){let i=t.node(e),s=o?t.indexAfter(e):t.index(e);if(s==i.childCount&&!n.compatibleContent(i.type))return null;let l=r.fillBefore(i.content,!0,s);return l&&!tP(n,i.content,s)?l:null}function tP(t,e,n){for(let r=n;r0;h--,p--){let f=o.node(h).type.spec;if(f.defining||f.definingAsContext||f.isolating)break;s.indexOf(h)>-1?l=h:o.before(h)==p&&s.splice(1,0,-h)}let a=s.indexOf(l),u=[],c=r.openStart;for(let h=r.content,p=0;;p++){let f=h.firstChild;if(u.push(f),p==r.openStart)break;h=f.content}for(let h=c-1;h>=0;h--){let p=u[h],f=nP(p.type);if(f&&!p.sameMarkup(o.node(Math.abs(l)-1)))c=h;else if(f||!p.type.isTextblock)break}for(let h=r.openStart;h>=0;h--){let p=(h+c+1)%(r.openStart+1),f=u[p];if(f)for(let g=0;g=0&&(t.replace(e,n,r),!(t.steps.length>d));h--){let p=s[h];p<0||(e=o.before(p),n=i.after(p))}}function vC(t,e,n,r,o){if(er){let i=o.contentMatchAt(0),s=i.fillBefore(t).append(t);t=s.append(i.matchFragment(s).fillBefore(J.empty,!0))}return t}function oP(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let o=fC(t.doc,e,r.type);o!=null&&(e=n=o)}t.replaceRange(e,n,new ae(J.from(r),0,0))}function iP(t,e,n){let r=t.doc.resolve(e),o=t.doc.resolve(n),i=yC(r,o);for(let s=0;s0&&(a||r.node(l-1).canReplace(r.index(l-1),o.indexAfter(l-1))))return t.delete(r.before(l),o.after(l))}for(let s=1;s<=r.depth&&s<=o.depth;s++)if(e-r.start(s)==r.depth-s&&n>r.end(s)&&o.end(s)-n!=o.depth-s)return t.delete(r.before(s),n);t.delete(e,n)}function yC(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let o=r;o>=0;o--){let i=t.start(o);if(ie.pos+(e.depth-o)||t.node(o).type.spec.isolating||e.node(o).type.spec.isolating)break;(i==e.start(o)||o==t.depth&&o==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&o&&e.start(o-1)==i-1)&&n.push(o)}return n}class Bl extends rn{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 jt.fail("No node at attribute step's position");let r=Object.create(null);for(let i in n.attrs)r[i]=n.attrs[i];r[this.attr]=this.value;let o=n.type.create(r,null,n.marks);return jt.fromReplace(e,this.pos,this.pos+1,new ae(J.from(o),0,n.isLeaf?0:1))}getMap(){return Pr.empty}invert(e){return new Bl(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 Bl(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 Bl(n.pos,n.attr,n.value)}}rn.jsonID("attr",Bl);class $u extends rn{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let o in e.attrs)n[o]=e.attrs[o];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return jt.ok(r)}getMap(){return Pr.empty}invert(e){return new $u(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 $u(n.attr,n.value)}}rn.jsonID("docAttr",$u);let Hl=class extends Error{};Hl=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n},Hl.prototype=Object.create(Error.prototype),Hl.prototype.constructor=Hl,Hl.prototype.name="TransformError";class sP{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Dl}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new Hl(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=ae.empty){let o=m1(this.doc,e,n,r);return o&&this.step(o),this}replaceWith(e,n,r){return this.replace(e,n,new ae(J.from(r),0,0))}delete(e,n){return this.replace(e,n,ae.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return rP(this,e,n,r),this}replaceRangeWith(e,n,r){return oP(this,e,n,r),this}deleteRange(e,n){return iP(this,e,n),this}lift(e,n){return W4(this,e,n),this}join(e,n=1){return J4(this,e,n),this}wrap(e,n){return G4(this,e,n),this}setBlockType(e,n=e,r,o=null){return K4(this,e,n,r,o),this}setNodeMarkup(e,n,r=null,o){return X4(this,e,n,r,o),this}setNodeAttribute(e,n,r){return this.step(new Bl(e,n,r)),this}setDocAttribute(e,n){return this.step(new $u(e,n)),this}addNodeMark(e,n){return this.step(new ls(e,n)),this}removeNodeMark(e,n){if(!(n instanceof Ge)){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 Pl(e,n)),this}split(e,n=1,r){return q4(this,e,n,r),this}addMark(e,n,r){return F4(this,e,n,r),this}removeMark(e,n,r){return B4(this,e,n,r),this}clearIncompatible(e,n,r){return H4(this,e,n,r),this}}const b1=Object.create(null);class He{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new aP(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;i--){let s=n<0?Ul(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):Ul(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,n,r);if(s)return s}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new Qn(e.node(0))}static atStart(e){return Ul(e,e,0,0,1)||new Qn(e)}static atEnd(e){return Ul(e,e,e.content.size,e.childCount,-1)||new Qn(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=b1[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 b1)throw new RangeError("Duplicate use of selection JSON ID "+e);return b1[e]=n,n.prototype.jsonID=e,n}getBookmark(){return Me.between(this.$anchor,this.$head).getBookmark()}}He.prototype.visible=!0;class aP{constructor(e,n){this.$from=e,this.$to=n}}let bC=!1;function xC(t){!bC&&!t.parent.inlineContent&&(bC=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class Me extends He{constructor(e,n=e){xC(e),xC(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 He.near(r);let o=e.resolve(n.map(this.anchor));return new Me(o.parent.inlineContent?o:r,r)}replace(e,n=ae.empty){if(super.replace(e,n),n==ae.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof Me&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Pp(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 Me(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let o=e.resolve(n);return new this(o,r==n?o:e.resolve(r))}static between(e,n,r){let o=e.pos-n.pos;if((!r||o)&&(r=o>=0?1:-1),!n.parent.inlineContent){let i=He.findFrom(n,r,!0)||He.findFrom(n,-r,!0);if(i)n=i.$head;else return He.near(n,r)}return e.parent.inlineContent||(o==0?e=n:(e=(He.findFrom(e,-r,!0)||He.findFrom(e,r,!0)).$anchor,e.pos0?0:1);o>0?s=0;s+=o){let l=e.child(s);if(l.isAtom){if(!i&&Oe.isSelectable(l))return Oe.create(t,n-(o<0?l.nodeSize:0))}else{let a=Ul(t,l,n+o,o<0?l.childCount:0,o,i);if(a)return a}n+=l.nodeSize*o}return null}function wC(t,e,n){let r=t.steps.length-1;if(r{s==null&&(s=c)}),t.setSelection(He.near(t.doc.resolve(s),n))}const kC=1,zp=2,EC=4;class cP extends sP{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|=zp,this}ensureMarks(e){return Ge.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&zp)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~zp,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)||Ge.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let o=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(o.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),r=r??n,!e)return this.deleteRange(n,r);let i=this.storedMarks;if(!i){let s=this.doc.resolve(n);i=r==n?s.marks():s.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,o.text(e,i)),this.selection.empty||this.setSelection(He.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|=EC,this}get scrolledIntoView(){return(this.updated&EC)>0}}function SC(t,e){return!e||!t?t:t.bind(e)}class Du{constructor(e,n,r){this.name=e,this.init=SC(n.init,r),this.apply=SC(n.apply,r)}}const uP=[new Du("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Du("selection",{init(t,e){return t.selection||He.atStart(e.doc)},apply(t){return t.selection}}),new Du("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Du("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class w1{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=uP.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 Du(r.key,r.spec.state,r))})}}class ya{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 o=e[r],i=o.spec.state;i&&i.toJSON&&(n[r]=i.toJSON.call(o,this[o.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 o=new w1(e.schema,e.plugins),i=new ya(o);return o.fields.forEach(s=>{if(s.name=="doc")i.doc=as.fromJSON(e.schema,n.doc);else if(s.name=="selection")i.selection=He.fromJSON(i.doc,n.selection);else if(s.name=="storedMarks")n.storedMarks&&(i.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],u=a.spec.state;if(a.key==s.name&&u&&u.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){i[s.name]=u.fromJSON.call(a,e,n[l],i);return}}i[s.name]=s.init(e,i)}}),i}}function CC(t,e,n){for(let r in t){let o=t[r];o instanceof Function?o=o.bind(e):r=="handleDOMEvents"&&(o=CC(o,e,{})),n[r]=o}return n}class Xo{constructor(e){this.spec=e,this.props={},e.props&&CC(e.props,this,this.props),this.key=e.key?e.key.key:TC("plugin")}getState(e){return e[this.key]}}const k1=Object.create(null);function TC(t){return t in k1?t+"$"+ ++k1[t]:(k1[t]=0,t+"$")}class ba{constructor(e="key"){this.key=TC(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}var dP=/[A-Z]/g,hP=/^ms-/,E1={};function pP(t){return"-"+t.toLowerCase()}function fP(t){if(E1.hasOwnProperty(t))return E1[t];var e=t.replace(dP,pP);return E1[t]=hP.test(e)?"-"+e:e}function gP(t){return fP(t)}function mP(t,e){return gP(t)+":"+e}function vP(t){var e="";for(var n in t){var r=t[n];typeof r!="string"&&typeof r!="number"||(e&&(e+=";"),e+=mP(n,r))}return e}function AC(){return typeof document<"u"?document:null}function _C(t,e){if(typeof t!="string")return[t];var n=[t];typeof e=="string"||Array.isArray(e)?e={brackets:e}:e||(e={});var r=e.brackets?Array.isArray(e.brackets)?e.brackets:[e.brackets]:["{}","[]","()"],o=e.escape||"___",i=!!e.flat;r.forEach(function(a){var u=new RegExp(["\\",a[0],"[^\\",a[0],"\\",a[1],"]*\\",a[1]].join("")),c=[];function d(h,p,f){var g=n.push(h.slice(a[0].length,-a[1].length))-1;return c.push(g),o+g+o}n.forEach(function(h,p){for(var f,g=0;h!=f;)if(f=h,h=h.replace(u,d),g++>1e4)throw Error("References have circular dependency. Please, check them.");n[p]=h}),c=c.reverse(),n=n.map(function(h){return c.forEach(function(p){h=h.replace(new RegExp("(\\"+o+p+"\\"+o+")","g"),a[0]+"$1"+a[1])}),h})});var s=new RegExp("\\"+o+"([0-9]+)\\"+o);function l(a,u,c){for(var d=[],h,p=0;h=s.exec(a);){if(p++>1e4)throw Error("Circular references in parenthesis");d.push(a.slice(0,h.index)),d.push(l(u[h[1]],u)),a=a.slice(h.index+h[0].length)}return d.push(a),d}return i?n:l(n[0],n)}function RC(t,e){if(e&&e.flat){var n=e&&e.escape||"___",r=t[0],o;if(!r)return"";for(var i=new RegExp("\\"+n+"([0-9]+)\\"+n),s=0;r!=o;){if(s++>1e4)throw Error("Circular references in "+t);o=r,r=r.replace(i,l)}return r}return t.reduce(function a(u,c){return Array.isArray(c)&&(c=c.reduce(a,"")),u+c},"");function l(a,u){if(t[u]==null)throw Error("Reference "+u+"is undefined");return t[u]}}function MC(t,e){return Array.isArray(t)?RC(t,e):_C(t,e)}MC.parse=_C,MC.stringify=RC;var cs=Object.freeze({__proto__:null,COPY_DESCRIPTION:{id:"extension.command.copy.description",message:"Copy the selected text",comment:"Description for copy command."},COPY_LABEL:{id:"extension.command.copy.label",message:"Copy",comment:"Label for copy command."},CUT_DESCRIPTION:{id:"extension.command.cut.description",message:"Cut the selected text",comment:"Description for cut command."},CUT_LABEL:{id:"extension.command.cut.label",message:"Cut",comment:"Label for cut command."},PASTE_DESCRIPTION:{id:"extension.command.paste.description",message:"Paste content into the editor",comment:"Description for paste command."},PASTE_LABEL:{id:"extension.command.paste.label",message:"Paste",comment:"Label for paste command."},SELECT_ALL_DESCRIPTION:{id:"extension.command.select-all.description",message:"Select all content within the editor",comment:"Description for select all command."},SELECT_ALL_LABEL:{id:"extension.command.select-all.label",message:"Select all",comment:"Label for select all command."}}),on=Object.freeze({__proto__:null,ALT_KEY:{id:"keyboard.shortcut.alt",message:"Alt",comment:"Label for alt key in shortcuts."},ARROW_DOWN_KEY:{id:"keyboard.shortcut.arrowDown",message:"Arrow Down",comment:"Label for arrowDown key in shortcuts."},ARROW_LEFT_KEY:{id:"keyboard.shortcut.arrowLeft",message:"Arrow Left",comment:"Label for arrow left key in shortcuts."},ARROW_RIGHT_KEY:{id:"keyboard.shortcut.arrowRight",message:"Arrow Right",comment:"Label for arrow right key in shortcuts."},ARROW_UP_KEY:{id:"keyboard.shortcut.arrowUp",message:"Arrow Up",comment:"Label for arrow up key in shortcuts."},BACKSPACE_KEY:{id:"keyboard.shortcut.backspace",message:"Backspace",comment:"Label for backspace key in shortcuts."},CAPS_LOCK_KEY:{id:"keyboard.shortcut.capsLock",message:"Caps Lock",comment:"Label for caps lock key in shortcuts."},COMMAND_KEY:{id:"keyboard.shortcut.command",message:"Command",comment:"Label for command key in shortcuts."},CONTROL_KEY:{id:"keyboard.shortcut.control",message:"Control",comment:"Label for control key in shortcuts."},DELETE_KEY:{id:"keyboard.shortcut.delete",message:"Delete",comment:"Label for delete key in shortcuts."},END_KEY:{id:"keyboard.shortcut.end",message:"End",comment:"Label for end key in shortcuts."},ENTER_KEY:{id:"keyboard.shortcut.enter",message:"Enter",comment:"Label for enter key in shortcuts."},ESCAPE_KEY:{id:"keyboard.shortcut.escape",message:"Enter",comment:"Label for escape key in shortcuts."},HOME_KEY:{id:"keyboard.shortcut.home",message:"Home",comment:"Label for home key in shortcuts."},PAGE_DOWN_KEY:{id:"keyboard.shortcut.pageDown",message:"Page Down",comment:"Label for page down key in shortcuts."},PAGE_UP_KEY:{id:"keyboard.shortcut.pageUp",message:"Page Up",comment:"Label for page up key in shortcuts."},SHIFT_KEY:{id:"keyboard.shortcut.shift",message:"Shift",comment:"Label for shift key in shortcuts."},SPACE_KEY:{id:"keyboard.shortcut.space",message:"Space",comment:"Label for space key in shortcuts."},TAB_KEY:{id:"keyboard.shortcut.tab",message:"Tab",comment:"Label for tab key in shortcuts."}}),OC=Object.freeze({__proto__:null,DESCRIPTION:{id:"extension.command.toggle-blockquote.description",message:"Add blockquote formatting to the selected text",comment:"Description for blockquote formatting command."},LABEL:{id:"extension.command.toggle-blockquote.label",message:"Blockquote",comment:"Label for blockquote formatting command."}}),IC=Object.freeze({__proto__:null,DESCRIPTION:{id:"extension.command.toggle-bold.description",message:"Add bold formatting to the selected text",comment:"Description for bold formatting command."},LABEL:{id:"extension.command.toggle-bold.label",message:"Bold",comment:"Label for bold formatting command."}}),yP=Object.freeze({__proto__:null,DESCRIPTION:{id:"extension.command.toggle-code-block.description",message:"Add a code block",comment:"Description for the code block command."},LABEL:{id:"extension.command.toggle-code-block.label",message:"Codeblock",comment:"Label for the code block command."}}),bP=Object.freeze({__proto__:null,DESCRIPTION:{id:"extension.command.toggle-code.description",message:"Add inline code formatting to the selected text",comment:"Description for the inline code formatting command."},LABEL:{id:"extension.command.toggle-code.label",message:"Code",comment:"Label for the inline code formatting."}}),xP=Object.freeze({__proto__:null,LABEL:{id:"extension.command.toggle-heading.label",message:`{level, select, 1 {Heading 1}
2 {Heading 2}
3 {Heading 3}
4 {Heading 4}
5 {Heading 5}
6 {Heading 6}
-other {Heading}}`,comment:"Label for heading command with support for levels."};var D5=Object.freeze({__proto__:null,LABEL:$5});const P5={id:"extension.command.undo.label",message:"Undo",comment:"Label for undo."},z5={id:"extension.command.undo.description",message:"Undo the most recent action",comment:"Description for undo."},F5={id:"extension.command.redo.label",message:"Redo",comment:"Label for redo."},B5={id:"extension.command.redo.description",message:"Redo the most recent action",comment:"Description for redo."};var tg=Object.freeze({__proto__:null,REDO_DESCRIPTION:B5,REDO_LABEL:F5,UNDO_DESCRIPTION:z5,UNDO_LABEL:P5});const H5={id:"extension.command.insert-horizontal-rule.label",message:"Divider",comment:"Label for inserting a horizontal rule (divider) command."},U5={id:"extension.command.insert-horizontal-rule.description",message:"Separate content with a diving horizontal line",comment:"Description for inserting a horizontal rule (divider) command."};var PS=Object.freeze({__proto__:null,DESCRIPTION:U5,LABEL:H5});const W5={id:"extension.command.toggle-italic.label",message:"Italic",comment:"Label for italic formatting command."},V5={id:"extension.command.toggle-italic.description",message:"Italicize the selected text",comment:"Description for italic formatting command."};var zS=Object.freeze({__proto__:null,DESCRIPTION:V5,LABEL:W5});const j5={id:"extension.command.toggle-ordered-list.label",message:"Ordered list",comment:"Label for inserting an ordered list into the editor."},G5={id:"extension.command.toggle-bullet-list.description",message:"Bulleted list",comment:"Description for inserting a bullet list into the editor."},K5={id:"extension.command.toggle-task-list.description",message:"Tasked list",comment:"Description for inserting a task list into the editor."};var Mb=Object.freeze({__proto__:null,BULLET_LIST_LABEL:G5,ORDERED_LIST_LABEL:j5,TASK_LIST_LABEL:K5});const Y5={id:"extension.command.insert-paragraph.label",message:"Insert Paragraph",comment:"Label for inserting a paragraph."},X5={id:"extension.command.insert-paragraph.description",message:"Insert a new paragraph",comment:"Description for inserting a paragraph."},q5={id:"extension.command.convert-paragraph.label",message:"Convert Paragraph",comment:"Label for converting the current node into a paragraph."},Z5={id:"extension.command.convert-paragraph.description",message:"Convert current block into a paragraph block.",comment:"Description for converting a paragraph."};var ng=Object.freeze({__proto__:null,CONVERT_DESCRIPTION:Z5,CONVERT_LABEL:q5,INSERT_DESCRIPTION:X5,INSERT_LABEL:Y5});const J5={id:"extension.command.toggle-strike.label",message:"Strikethrough",comment:"Label for strike formatting command."},Q5={id:"extension.command.toggle-strike.description",message:"Strikethrough the selected text",comment:"Description for strike formatting command."};var FS=Object.freeze({__proto__:null,DESCRIPTION:Q5,LABEL:J5});const e3={id:"extension.command.toggle-underline.label",message:"Underline",comment:"Label for underline formatting command."},t3={id:"extension.command.toggle-underline.description",message:"Underline the selected text",comment:"Description for underline formatting command."};var BS=Object.freeze({__proto__:null,DESCRIPTION:t3,LABEL:e3});class yl{constructor(e,n){this.match=e,this.match=e,this.handler=typeof n=="string"?n3(n):n}}function n3(t){return function(e,n,r,o){let i=t;if(n[1]){let s=n[0].lastIndexOf(n[1]);i+=n[0].slice(s+n[1].length),r+=s;let l=r-o;l>0&&(i=n[0].slice(s-l,s)+i,r=o)}return e.tr.insertText(i,r,o)}}const r3=500;function o3({rules:t}){let e=new mi({state:{init(){return null},apply(n,r){let o=n.getMeta(this);return o||(n.selectionSet||n.docChanged?null:r)}},props:{handleTextInput(n,r,o,i){return HS(n,r,o,i,t,e)},handleDOMEvents:{compositionend:n=>{setTimeout(()=>{let{$cursor:r}=n.state.selection;r&&HS(n,r.pos,r.pos,"",t,e)})}}},isInputRules:!0});return e}function HS(t,e,n,r,o,i){if(t.composing)return!1;let s=t.state,l=s.doc.resolve(e);if(l.parent.type.spec.code)return!1;let a=l.parent.textBetween(Math.max(0,l.parentOffset-r3),l.parentOffset,null,"")+r;for(let u=0;u{let n=t.plugins;for(let r=0;r=0;a--)s.step(l.steps[a].invert(l.docs[a]));if(i.text){let a=s.doc.resolve(i.from).marks();s.replaceWith(i.from,i.to,t.schema.text(i.text,a))}else s.delete(i.from,i.to);e(s)}return!0}}return!1};function gm(t,e,n=null,r){return new yl(t,(o,i,s,l)=>{let a=n instanceof Function?n(i):n,u=o.tr.delete(s,l),c=u.doc.resolve(s),d=c.blockRange(),h=d&&Ab(d,e,a);if(!h)return null;u.wrap(d,h);let p=u.doc.resolve(s-1).nodeBefore;return p&&p.type==e&&jh(u.doc,s-1)&&(!r||r(i,p))&&u.join(s-1),u})}function s3(t,e,n=null){return new yl(t,(r,o,i,s)=>{let l=r.doc.resolve(i),a=n instanceof Function?n(o):n;return l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),e)?r.tr.delete(i,s).setBlockType(i,i,e,a):null})}const tr=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Kd=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let US=null;const Ai=function(t,e,n){let r=US||(US=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},Ja=function(t,e,n,r){return n&&(WS(t,e,n,r,-1)||WS(t,e,n,r,1))},a3=/^(img|br|input|textarea|hr)$/i;function WS(t,e,n,r,o){for(;;){if(t==n&&e==r)return!0;if(e==(o<0?0:ei(t))){let i=t.parentNode;if(!i||i.nodeType!=1||Ob(t)||a3.test(t.nodeName)||t.contentEditable=="false")return!1;e=tr(t)+(o<0?0:1),t=i}else if(t.nodeType==1){if(t=t.childNodes[e+(o<0?-1:0)],t.contentEditable=="false")return!1;e=o<0?ei(t):0}else return!1}}function ei(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function l3(t,e,n){for(let r=e==0,o=e==ei(t);r||o;){if(t==n)return!0;let i=tr(t);if(t=t.parentNode,!t)return!1;r=r&&i==0,o=o&&i==ei(t)}}function Ob(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const mm=function(t){return t.focusNode&&Ja(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Ia(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function c3(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function u3(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}}}const di=typeof navigator<"u"?navigator:null,VS=typeof document<"u"?document:null,ea=di&&di.userAgent||"",_0=/Edge\/(\d+)/.exec(ea),m2=/MSIE \d/.exec(ea),R0=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ea),kr=!!(m2||R0||_0),_s=m2?document.documentMode:R0?+R0[1]:_0?+_0[1]:0,Uo=!kr&&/gecko\/(\d+)/i.test(ea);Uo&&+(/Firefox\/(\d+)/.exec(ea)||[0,0])[1];const M0=!kr&&/Chrome\/(\d+)/.exec(ea),Gn=!!M0,d3=M0?+M0[1]:0,sr=!kr&&!!di&&/Apple Computer/.test(di.vendor),Dc=sr&&(/Mobile\/\w+/.test(ea)||!!di&&di.maxTouchPoints>2),ao=Dc||(di?/Mac/.test(di.platform):!1),h3=di?/Win/.test(di.platform):!1,No=/Android \d/.test(ea),Gh=!!VS&&"webkitFontSmoothing"in VS.documentElement.style,p3=Gh?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function f3(t){return{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function wi(t,e){return typeof t=="number"?t:t[e]}function g3(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 jS(t,e,n){let r=t.someProp("scrollThreshold")||0,o=t.someProp("scrollMargin")||5,i=t.dom.ownerDocument;for(let s=n||t.dom;s;s=Kd(s)){if(s.nodeType!=1)continue;let l=s,a=l==i.body,u=a?f3(i):g3(l),c=0,d=0;if(e.topu.bottom-wi(r,"bottom")&&(d=e.bottom-e.top>u.bottom-u.top?e.top+wi(o,"top")-u.top:e.bottom-u.bottom+wi(o,"bottom")),e.leftu.right-wi(r,"right")&&(c=e.right-u.right+wi(o,"right")),c||d)if(a)i.defaultView.scrollBy(c,d);else{let h=l.scrollLeft,p=l.scrollTop;d&&(l.scrollTop+=d),c&&(l.scrollLeft+=c);let f=l.scrollLeft-h,g=l.scrollTop-p;e={left:e.left-f,top:e.top-g,right:e.right-f,bottom:e.bottom-g}}if(a||/^(fixed|sticky)$/.test(getComputedStyle(s).position))break}}function m3(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,o;for(let i=(e.left+e.right)/2,s=n+1;s=n-20){r=l,o=a.top;break}}return{refDOM:r,refTop:o,stack:v2(t.dom)}}function v2(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=Kd(r));return e}function v3({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;y2(n,r==0?0:r-e)}function y2(t,e){for(let n=0;n=l){s=Math.max(f.bottom,s),l=Math.min(f.top,l);let g=f.left>e.left?f.left-e.left:f.right=(f.left+f.right)/2?1:0));continue}}else f.top>e.top&&!a&&f.left<=e.left&&f.right>=e.left&&(a=c,u={left:Math.max(f.left,Math.min(f.right,e.left)),top:f.top});!n&&(e.left>=f.right&&e.top>=f.top||e.left>=f.left&&e.top>=f.bottom)&&(i=d+1)}}return!n&&a&&(n=a,o=u,r=0),n&&n.nodeType==3?b3(n,o):!n||r&&n.nodeType==1?{node:t,offset:i}:b2(n,o)}function b3(t,e){let n=t.nodeValue.length,r=document.createRange();for(let o=0;o=(i.left+i.right)/2?1:0)}}return{node:t,offset:0}}function Ib(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function w3(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,o,i)}function k3(t,e,n,r){let o=-1;for(let i=e,s=!1;i!=t.dom;){let l=t.docView.nearestDesc(i,!0);if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent&&!s||!l.contentDOM)){let a=l.dom.getBoundingClientRect();if(l.node.isBlock&&l.parent&&!s&&(s=!0,a.left>r.left||a.top>r.top?o=l.posBefore:(a.right-1?o:t.docView.posFromDOM(e,n,-1)}function w2(t,e,n){let r=t.childNodes.length;if(r&&n.tope.top&&o++}let u;Gh&&o&&r.nodeType==1&&(u=r.childNodes[o-1]).nodeType==1&&u.contentEditable=="false"&&u.getBoundingClientRect().top>=e.top&&o--,r==t.dom&&o==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=t.state.doc.content.size:(o==0||r.nodeType!=1||r.childNodes[o-1].nodeName!="BR")&&(l=k3(t,r,o,e))}l==null&&(l=x3(t,s,e));let a=t.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function GS(t){return t.top=0&&o==r.nodeValue.length?(a--,c=1):n<0?a--:u++,Cu(ls(Ai(r,a,u),c),c<0)}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&o&&(n<0||o==ei(r))){let a=r.childNodes[o-1];if(a.nodeType==1)return u1(a.getBoundingClientRect(),!1)}if(i==null&&o=0)}if(i==null&&o&&(n<0||o==ei(r))){let a=r.childNodes[o-1],u=a.nodeType==3?Ai(a,ei(a)-(s?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(u)return Cu(ls(u,1),!1)}if(i==null&&o=0)}function Cu(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 u1(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 k2(t,e,n){let r=t.state,o=t.root.activeElement;r!=e&&t.updateState(e),o!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),o!=t.dom&&o&&o.focus()}}function C3(t,e,n){let r=e.selection,o=n=="up"?r.$from:r.$to;return k2(t,e,()=>{let{node:i}=t.docView.domFromPos(o.pos,n=="up"?-1:1);for(;;){let l=t.docView.nearestDesc(i,!0);if(!l)break;if(l.node.isBlock){i=l.contentDOM||l.dom;break}i=l.dom.parentNode}let s=x2(t,o.pos,1);for(let l=i.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=Ai(l,0,l.nodeValue.length).getClientRects();else continue;for(let u=0;uc.top+1&&(n=="up"?s.top-c.top>(c.bottom-s.top)*2:c.bottom-s.bottom>(s.bottom-c.top)*2))return!1}}return!0})}const T3=/[\u0590-\u08ac]/;function A3(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let o=r.parentOffset,i=!o,s=o==r.parent.content.size,l=t.domSelection();return!T3.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?i:s:k2(t,e,()=>{let{focusNode:a,focusOffset:u,anchorNode:c,anchorOffset:d}=t.domSelectionRange(),h=l.caretBidiLevel;l.modify("move",n,"character");let p=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:f,focusOffset:g}=t.domSelectionRange(),m=f&&!p.contains(f.nodeType==1?f:f.parentNode)||a==f&&u==g;try{l.collapse(c,d),a&&(a!=c||u!=d)&&l.extend&&l.extend(a,u)}catch{}return h!=null&&(l.caretBidiLevel=h),m})}let KS=null,YS=null,XS=!1;function _3(t,e,n){return KS==e&&YS==n?XS:(KS=e,YS=n,XS=n=="up"||n=="down"?C3(t,e,n):A3(t,e,n))}const po=0,qS=1,$a=2,hi=3;class Kh{constructor(e,n,r,o){this.parent=e,this.children=n,this.dom=r,this.contentDOM=o,this.dirty=po,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;ntr(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))o=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let i=e;;i=i.parentNode){if(i==this.dom){o=!1;break}if(i.previousSibling)break}if(o==null&&n==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){o=!0;break}if(i.nextSibling)break}}return o??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,o=e;o;o=o.parentNode){let i=this.getDesc(o),s;if(i&&(!n||i.node))if(r&&(s=i.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==e))r=!1;else return i}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let o=e;o;o=o.parentNode){let i=this.getDesc(o);if(i)return i.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;ne||s instanceof S2){o=e-i;break}i=l}if(o)return this.children[r].domFromPos(o-this.children[r].border,n);for(let i;r&&!(i=this.children[r-1]).size&&i instanceof E2&&i.side>=0;r--);if(n<=0){let i,s=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,s=!1);return i&&n&&s&&!i.border&&!i.domAtom?i.domFromPos(i.size,n):{node:this.contentDOM,offset:i?tr(i.dom)+1:0}}else{let i,s=!0;for(;i=r=c&&n<=u-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,n,c);e=s;for(let d=l;d>0;d--){let h=this.children[d-1];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(1)){o=tr(h.dom)+1;break}e-=h.size}o==-1&&(o=0)}if(o>-1&&(u>n||l==this.children.length-1)){n=u;for(let c=l+1;cp&&sn){let p=l;l=a,a=p}let h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),u.removeAllRanges(),u.addRange(h)}}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,o=0;o=r:er){let l=r+i.border,a=s-i.border;if(e>=l&&n<=a){this.dirty=e==r||n==s?$a:qS,e==l&&n==a&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=hi:i.markDirty(e-l,n-l);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?$a:hi}r=s}this.dirty=$a}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?$a:qS;n.dirty{if(!i)return o;if(i.parent)return i.parent.posBeforeChild(i)})),!n.type.spec.raw){if(s.nodeType!=1){let l=document.createElement("span");l.appendChild(s),s=l}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=n,this.widget=n,i=this}matchesWidget(e){return this.dirty==po&&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}}class R3 extends Kh{constructor(e,n,r,o){super(e,[],n,null),this.textDOM=r,this.text=o}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class Qa extends Kh{constructor(e,n,r,o){super(e,[],r,o),this.mark=n}static create(e,n,r,o){let i=o.nodeViews[n.type.name],s=i&&i(n,o,r);return(!s||!s.dom)&&(s=Vr.renderSpec(document,n.type.spec.toDOM(n,r))),new Qa(e,n,s.dom,s.contentDOM||s.dom)}parseRule(){return this.dirty&hi||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=hi&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=po){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty0&&(i=L0(i,0,e,r));for(let l=0;l{if(!a)return s;if(a.parent)return a.parent.posBeforeChild(a)},r,o),c=u&&u.dom,d=u&&u.contentDOM;if(n.isText){if(!c)c=document.createTextNode(n.text);else if(c.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else c||({dom:c,contentDOM:d}=Vr.renderSpec(document,n.type.spec.toDOM(n)));!d&&!n.isText&&c.nodeName!="BR"&&(c.hasAttribute("contenteditable")||(c.contentEditable="false"),n.type.spec.draggable&&(c.draggable=!0));let h=c;return c=A2(c,r,n),u?a=new M3(e,n,r,o,c,d||null,h,u,i,s+1):n.isText?new vm(e,n,r,o,c,h,i):new Rs(e,n,r,o,c,d||null,h,i,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=()=>J.empty)}return e}matchesNode(e,n,r){return this.dirty==po&&e.eq(this.node)&&I0(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,o=n,i=e.composing?this.localCompositionInfo(e,n):null,s=i&&i.pos>-1?i:null,l=i&&i.pos<0,a=new I3(this,s&&s.node,e);$3(this.node,this.innerDeco,(u,c,d)=>{u.spec.marks?a.syncToMarks(u.spec.marks,r,e):u.type.side>=0&&!d&&a.syncToMarks(c==this.node.childCount?je.none:this.node.child(c).marks,r,e),a.placeWidget(u,e,o)},(u,c,d,h)=>{a.syncToMarks(u.marks,r,e);let p;a.findNodeMatch(u,c,d,h)||l&&e.state.selection.from>o&&e.state.selection.to-1&&a.updateNodeAt(u,c,d,p,e)||a.updateNextNode(u,c,d,e,h,o)||a.addNode(u,c,d,e,o),o+=u.nodeSize}),a.syncToMarks([],r,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==$a)&&(s&&this.protectLocalComposition(e,s),C2(this.contentDOM,this.children,e),Dc&&D3(this.dom))}localCompositionInfo(e,n){let{from:r,to:o}=e.state.selection;if(!(e.state.selection instanceof Me)||rn+this.node.content.size)return null;let i=e.domSelectionRange(),s=P3(i.focusNode,i.focusOffset);if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let l=s.nodeValue,a=z3(this.node.content,l,r-n,o-n);return a<0?null:{node:s,pos:a,text:l}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:o}){if(this.getDesc(n))return;let i=n;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let s=new R3(this,i,n,o);e.input.compositionNodes.push(s),this.children=L0(this.children,r,r+o.length,e,s)}update(e,n,r,o){return this.dirty==hi||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,o),!0)}updateInner(e,n,r,o){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(o,this.posAtStart),this.dirty=po}updateOuterDeco(e){if(I0(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=T2(this.dom,this.nodeDOM,O0(this.outerDeco,this.node,n),O0(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 ZS(t,e,n,r,o){A2(r,e,t);let i=new Rs(void 0,t,e,n,r,r,r,o,0);return i.contentDOM&&i.updateChildren(o,0),i}class vm extends Rs{constructor(e,n,r,o,i,s,l){super(e,n,r,o,i,null,s,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,o){return this.dirty==hi||this.dirty!=po&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=po||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,o.trackWrites==this.nodeDOM&&(o.trackWrites=null)),this.node=e,this.dirty=po,!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 o=this.node.cut(e,n),i=document.createTextNode(o.text);return new vm(this.parent,o,this.outerDeco,this.innerDeco,i,i,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=hi)}get domAtom(){return!1}}class S2 extends Kh{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==po&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class M3 extends Rs{constructor(e,n,r,o,i,s,l,a,u,c){super(e,n,r,o,i,s,l,u,c),this.spec=a}update(e,n,r,o){if(this.dirty==hi)return!1;if(this.spec.update){let i=this.spec.update(e,n,r);return i&&this.updateInner(e,n,r,o),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,o){this.spec.setSelection?this.spec.setSelection(e,n,r):super.setSelection(e,n,r,o)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function C2(t,e,n){let r=t.firstChild,o=!1;for(let i=0;i>1,s=Math.min(i,e.length);for(;o-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=Qa.create(this.top,e[i],n,r);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,i++}}findNodeMatch(e,n,r,o){let i=-1,s;if(o>=this.preMatch.index&&(s=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&s.matchesNode(e,n,r))i=this.top.children.indexOf(s,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l0;){let l;for(;;)if(r){let u=n.children[r-1];if(u instanceof Qa)n=u,r=u.children.length;else{l=u,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let a=l.node;if(a){if(a!=t.child(o-1))break;--o,i.set(l,o),s.push(l)}}return{index:o,matched:i,matches:s.reverse()}}function N3(t,e){return t.type.side-e.type.side}function $3(t,e,n,r){let o=e.locals(t),i=0;if(o.length==0){for(let u=0;ui;)l.push(o[s++]);let f=i+h.nodeSize;if(h.isText){let m=f;s!m.inline):l.slice();r(h,g,e.forChild(i,h),p),i=f}}function D3(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 P3(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=ei(t)}else if(t.nodeType==1&&e=n){if(i>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let u=l=0&&u+e.length+l>=n)return l+u;if(n==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function L0(t,e,n,r,o){let i=[];for(let s=0,l=0;s=n||c<=e?i.push(a):(un&&i.push(a.slice(n-u,a.size,r)))}return i}function Lb(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let o=t.docView.nearestDesc(n.focusNode),i=o&&o.size==0,s=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let l=r.resolve(s),a,u;if(mm(n)){for(a=l;o&&!o.node;)o=o.parent;let c=o.node;if(o&&c.isAtom&&Oe.isSelectable(c)&&o.parent&&!(c.isInline&&l3(n.focusNode,n.focusOffset,o.dom))){let d=o.posBefore;u=new Oe(s==d?l:r.resolve(d))}}else{let c=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(c<0)return null;a=r.resolve(c)}if(!u){let c=e=="pointer"||t.state.selection.head{(n.anchorNode!=r||n.anchorOffset!=o)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!_2(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function B3(t){let e=t.domSelection(),n=document.createRange(),r=t.cursorWrapper.dom,o=r.nodeName=="IMG";o?n.setEnd(r.parentNode,tr(r)+1):n.setEnd(r,0),n.collapse(!1),e.removeAllRanges(),e.addRange(n),!o&&!t.state.selection.visible&&kr&&_s<=11&&(r.disabled=!0,r.disabled=!1)}function R2(t,e){if(e instanceof Oe){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(nC(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else nC(t)}function nC(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Nb(t,e,n,r){return t.someProp("createSelectionBetween",o=>o(t,e,n))||Me.between(e,n,r)}function rC(t){return t.editable&&!t.hasFocus()?!1:M2(t)}function M2(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 H3(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Ja(e.node,e.offset,n.anchorNode,n.anchorOffset)}function N0(t,e){let{$anchor:n,$head:r}=t.selection,o=e>0?n.max(r):n.min(r),i=o.parent.inlineContent?o.depth?t.doc.resolve(e>0?o.after():o.before()):null:o;return i&&Be.findFrom(i,e)}function fs(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function oC(t,e,n){let r=t.state.selection;if(r instanceof Me)if(n.indexOf("s")>-1){let{$head:o}=r,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let s=t.state.doc.resolve(o.pos+i.nodeSize*(e<0?-1:1));return fs(t,new Me(r.$anchor,s))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let o=N0(t.state,e);return o&&o instanceof Oe?fs(t,o):!1}else if(!(ao&&n.indexOf("m")>-1)){let o=r.$head,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter,s;if(!i||i.isText)return!1;let l=e<0?o.pos-i.nodeSize:o.pos;return i.isAtom||(s=t.docView.descAt(l))&&!s.contentDOM?Oe.isSelectable(i)?fs(t,new Oe(e<0?t.state.doc.resolve(o.pos-i.nodeSize):o)):Gh?fs(t,new Me(t.state.doc.resolve(e<0?l:l+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof Oe&&r.node.isInline)return fs(t,new Me(e>0?r.$to:r.$from));{let o=N0(t.state,e);return o?fs(t,o):!1}}}function rg(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Td(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function $l(t,e){return e<0?U3(t):W3(t)}function U3(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let o,i,s=!1;for(Uo&&n.nodeType==1&&r0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(Td(l,-1))o=n,i=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(O2(n))break;{let l=n.previousSibling;for(;l&&Td(l,-1);)o=n.parentNode,i=tr(l),l=l.previousSibling;if(l)n=l,r=rg(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}s?$0(t,n,r):o&&$0(t,o,i)}function W3(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let o=rg(n),i,s;for(;;)if(r{t.state==o&&zi(t)},50)}function iC(t,e){let n=t.state.doc.resolve(e);if(!(Gn||h3)&&n.parent.inlineContent){let o=t.coordsAtPos(e);if(e>n.start()){let i=t.coordsAtPos(e-1),s=(i.top+i.bottom)/2;if(s>o.top&&s1)return i.lefto.top&&s1)return i.left>o.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function sC(t,e,n){let r=t.state.selection;if(r instanceof Me&&!r.empty||n.indexOf("s")>-1||ao&&n.indexOf("m")>-1)return!1;let{$from:o,$to:i}=r;if(!o.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let s=N0(t.state,e);if(s&&s instanceof Oe)return fs(t,s)}if(!o.parent.inlineContent){let s=e<0?o:i,l=r instanceof rr?Be.near(s,e):Be.findFrom(s,e);return l?fs(t,l):!1}return!1}function aC(t,e){if(!(t.state.selection instanceof Me))return!0;let{$head:n,$anchor:r,empty:o}=t.state.selection;if(!n.sameParent(r))return!0;if(!o)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let s=t.state.tr;return e<0?s.delete(n.pos-i.nodeSize,n.pos):s.delete(n.pos,n.pos+i.nodeSize),t.dispatch(s),!0}return!1}function lC(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function G3(t){if(!sr||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;lC(t,r,"true"),setTimeout(()=>lC(t,r,"false"),20)}return!1}function K3(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function Y3(t,e){let n=e.keyCode,r=K3(e);if(n==8||ao&&n==72&&r=="c")return aC(t,-1)||$l(t,-1);if(n==46&&!e.shiftKey||ao&&n==68&&r=="c")return aC(t,1)||$l(t,1);if(n==13||n==27)return!0;if(n==37||ao&&n==66&&r=="c"){let o=n==37?iC(t,t.state.selection.from)=="ltr"?-1:1:-1;return oC(t,o,r)||$l(t,o)}else if(n==39||ao&&n==70&&r=="c"){let o=n==39?iC(t,t.state.selection.from)=="ltr"?1:-1:1;return oC(t,o,r)||$l(t,o)}else{if(n==38||ao&&n==80&&r=="c")return sC(t,-1,r)||$l(t,-1);if(n==40||ao&&n==78&&r=="c")return G3(t)||sC(t,1,r)||$l(t,1);if(r==(ao?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function I2(t,e){t.someProp("transformCopied",p=>{e=p(e,t)});let n=[],{content:r,openStart:o,openEnd:i}=e;for(;o>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){o--,i--;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")||Vr.fromSchema(t.state.schema),l=z2(),a=l.createElement("div");a.appendChild(s.serializeFragment(r,{document:l}));let u=a.firstChild,c,d=0;for(;u&&u.nodeType==1&&(c=P2[u.nodeName.toLowerCase()]);){for(let p=c.length-1;p>=0;p--){let f=l.createElement(c[p]);for(;a.firstChild;)f.appendChild(a.firstChild);a.appendChild(f),d++}u=a.firstChild}u&&u.nodeType==1&&u.setAttribute("data-pm-slice",`${o} ${i}${d?` -${d}`:""} ${JSON.stringify(n)}`);let h=t.someProp("clipboardTextSerializer",p=>p(e,t))||e.content.textBetween(0,e.content.size,`
+other {Heading}}`,comment:"Label for heading command with support for levels."}}),Fp=Object.freeze({__proto__:null,REDO_DESCRIPTION:{id:"extension.command.redo.description",message:"Redo the most recent action",comment:"Description for redo."},REDO_LABEL:{id:"extension.command.redo.label",message:"Redo",comment:"Label for redo."},UNDO_DESCRIPTION:{id:"extension.command.undo.description",message:"Undo the most recent action",comment:"Description for undo."},UNDO_LABEL:{id:"extension.command.undo.label",message:"Undo",comment:"Label for undo."}}),LC=Object.freeze({__proto__:null,DESCRIPTION:{id:"extension.command.insert-horizontal-rule.description",message:"Separate content with a diving horizontal line",comment:"Description for inserting a horizontal rule (divider) command."},LABEL:{id:"extension.command.insert-horizontal-rule.label",message:"Divider",comment:"Label for inserting a horizontal rule (divider) command."}}),NC=Object.freeze({__proto__:null,DESCRIPTION:{id:"extension.command.toggle-italic.description",message:"Italicize the selected text",comment:"Description for italic formatting command."},LABEL:{id:"extension.command.toggle-italic.label",message:"Italic",comment:"Label for italic formatting command."}}),S1=Object.freeze({__proto__:null,BULLET_LIST_LABEL:{id:"extension.command.toggle-bullet-list.description",message:"Bulleted list",comment:"Description for inserting a bullet list into the editor."},ORDERED_LIST_LABEL:{id:"extension.command.toggle-ordered-list.label",message:"Ordered list",comment:"Label for inserting an ordered list into the editor."},TASK_LIST_LABEL:{id:"extension.command.toggle-task-list.description",message:"Tasked list",comment:"Description for inserting a task list into the editor."}}),Bp=Object.freeze({__proto__:null,CONVERT_DESCRIPTION:{id:"extension.command.convert-paragraph.description",message:"Convert current block into a paragraph block.",comment:"Description for converting a paragraph."},CONVERT_LABEL:{id:"extension.command.convert-paragraph.label",message:"Convert Paragraph",comment:"Label for converting the current node into a paragraph."},INSERT_DESCRIPTION:{id:"extension.command.insert-paragraph.description",message:"Insert a new paragraph",comment:"Description for inserting a paragraph."},INSERT_LABEL:{id:"extension.command.insert-paragraph.label",message:"Insert Paragraph",comment:"Label for inserting a paragraph."}}),$C=Object.freeze({__proto__:null,DESCRIPTION:{id:"extension.command.toggle-strike.description",message:"Strikethrough the selected text",comment:"Description for strike formatting command."},LABEL:{id:"extension.command.toggle-strike.label",message:"Strikethrough",comment:"Label for strike formatting command."}}),DC=Object.freeze({__proto__:null,DESCRIPTION:{id:"extension.command.toggle-underline.description",message:"Underline the selected text",comment:"Description for underline formatting command."},LABEL:{id:"extension.command.toggle-underline.label",message:"Underline",comment:"Label for underline formatting command."}});class xa{constructor(e,n){this.match=e,this.match=e,this.handler=typeof n=="string"?wP(n):n}}function wP(t){return function(e,n,r,o){let i=t;if(n[1]){let s=n[0].lastIndexOf(n[1]);i+=n[0].slice(s+n[1].length),r+=s;let l=r-o;l>0&&(i=n[0].slice(s-l,s)+i,r=o)}return e.tr.insertText(i,r,o)}}const kP=500;function EP({rules:t}){let e=new Xo({state:{init(){return null},apply(n,r){let o=n.getMeta(this);return o||(n.selectionSet||n.docChanged?null:r)}},props:{handleTextInput(n,r,o,i){return PC(n,r,o,i,t,e)},handleDOMEvents:{compositionend:n=>{setTimeout(()=>{let{$cursor:r}=n.state.selection;r&&PC(n,r.pos,r.pos,"",t,e)})}}},isInputRules:!0});return e}function PC(t,e,n,r,o,i){if(t.composing)return!1;let s=t.state,l=s.doc.resolve(e);if(l.parent.type.spec.code)return!1;let a=l.parent.textBetween(Math.max(0,l.parentOffset-kP),l.parentOffset,null,"")+r;for(let u=0;u{let n=t.plugins;for(let r=0;r=0;a--)s.step(l.steps[a].invert(l.docs[a]));if(i.text){let a=s.doc.resolve(i.from).marks();s.replaceWith(i.from,i.to,t.schema.text(i.text,a))}else s.delete(i.from,i.to);e(s)}return!0}}return!1};function Hp(t,e,n=null,r){return new xa(t,(o,i,s,l)=>{let a=n instanceof Function?n(i):n,u=o.tr.delete(s,l),c=u.doc.resolve(s),d=c.blockRange(),h=d&&g1(d,e,a);if(!h)return null;u.wrap(d,h);let p=u.doc.resolve(s-1).nodeBefore;return p&&p.type==e&&Iu(u.doc,s-1)&&(!r||r(i,p))&&u.join(s-1),u})}function CP(t,e,n=null){return new xa(t,(r,o,i,s)=>{let l=r.doc.resolve(i),a=n instanceof Function?n(o):n;return l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),e)?r.tr.delete(i,s).setBlockType(i,i,e,a):null})}const er=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Pu=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let zC=null;const ki=function(t,e,n){let r=zC||(zC=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},wa=function(t,e,n,r){return n&&(FC(t,e,n,r,-1)||FC(t,e,n,r,1))},TP=/^(img|br|input|textarea|hr)$/i;function FC(t,e,n,r,o){for(;;){if(t==n&&e==r)return!0;if(e==(o<0?0:qo(t))){let i=t.parentNode;if(!i||i.nodeType!=1||C1(t)||TP.test(t.nodeName)||t.contentEditable=="false")return!1;e=er(t)+(o<0?0:1),t=i}else if(t.nodeType==1){if(t=t.childNodes[e+(o<0?-1:0)],t.contentEditable=="false")return!1;e=o<0?qo(t):0}else return!1}}function qo(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function AP(t,e,n){for(let r=e==0,o=e==qo(t);r||o;){if(t==n)return!0;let i=er(t);if(t=t.parentNode,!t)return!1;r=r&&i==0,o=o&&i==qo(t)}}function C1(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const Up=function(t){return t.focusNode&&wa(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function ka(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function _P(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function RP(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}}}const Zo=typeof navigator<"u"?navigator:null,BC=typeof document<"u"?document:null,us=Zo&&Zo.userAgent||"",T1=/Edge\/(\d+)/.exec(us),HC=/MSIE \d/.exec(us),A1=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(us),vr=!!(HC||A1||T1),ds=HC?document.documentMode:A1?+A1[1]:T1?+T1[1]:0,Ro=!vr&&/gecko\/(\d+)/i.test(us);Ro&&+(/Firefox\/(\d+)/.exec(us)||[0,0])[1];const _1=!vr&&/Chrome\/(\d+)/.exec(us),Bn=!!_1,MP=_1?+_1[1]:0,tr=!vr&&!!Zo&&/Apple Computer/.test(Zo.vendor),Wl=tr&&(/Mobile\/\w+/.test(us)||!!Zo&&Zo.maxTouchPoints>2),so=Wl||(Zo?/Mac/.test(Zo.platform):!1),OP=Zo?/Win/.test(Zo.platform):!1,Mo=/Android \d/.test(us),zu=!!BC&&"webkitFontSmoothing"in BC.documentElement.style,IP=zu?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function LP(t){return{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function Ei(t,e){return typeof t=="number"?t:t[e]}function NP(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 UC(t,e,n){let r=t.someProp("scrollThreshold")||0,o=t.someProp("scrollMargin")||5,i=t.dom.ownerDocument;for(let s=n||t.dom;s;s=Pu(s)){if(s.nodeType!=1)continue;let l=s,a=l==i.body,u=a?LP(i):NP(l),c=0,d=0;if(e.topu.bottom-Ei(r,"bottom")&&(d=e.bottom-e.top>u.bottom-u.top?e.top+Ei(o,"top")-u.top:e.bottom-u.bottom+Ei(o,"bottom")),e.leftu.right-Ei(r,"right")&&(c=e.right-u.right+Ei(o,"right")),c||d)if(a)i.defaultView.scrollBy(c,d);else{let h=l.scrollLeft,p=l.scrollTop;d&&(l.scrollTop+=d),c&&(l.scrollLeft+=c);let f=l.scrollLeft-h,g=l.scrollTop-p;e={left:e.left-f,top:e.top-g,right:e.right-f,bottom:e.bottom-g}}if(a||/^(fixed|sticky)$/.test(getComputedStyle(s).position))break}}function $P(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,o;for(let i=(e.left+e.right)/2,s=n+1;s=n-20){r=l,o=a.top;break}}return{refDOM:r,refTop:o,stack:WC(t.dom)}}function WC(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=Pu(r));return e}function DP({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;VC(n,r==0?0:r-e)}function VC(t,e){for(let n=0;n=l){s=Math.max(f.bottom,s),l=Math.min(f.top,l);let g=f.left>e.left?f.left-e.left:f.right=(f.left+f.right)/2?1:0));continue}}else f.top>e.top&&!a&&f.left<=e.left&&f.right>=e.left&&(a=c,u={left:Math.max(f.left,Math.min(f.right,e.left)),top:f.top});!n&&(e.left>=f.right&&e.top>=f.top||e.left>=f.left&&e.top>=f.bottom)&&(i=d+1)}}return!n&&a&&(n=a,o=u,r=0),n&&n.nodeType==3?zP(n,o):!n||r&&n.nodeType==1?{node:t,offset:i}:jC(n,o)}function zP(t,e){let n=t.nodeValue.length,r=document.createRange();for(let o=0;o=(i.left+i.right)/2?1:0)}}return{node:t,offset:0}}function R1(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function FP(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,o,i)}function HP(t,e,n,r){let o=-1;for(let i=e,s=!1;i!=t.dom;){let l=t.docView.nearestDesc(i,!0);if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent&&!s||!l.contentDOM)){let a=l.dom.getBoundingClientRect();if(l.node.isBlock&&l.parent&&!s&&(s=!0,a.left>r.left||a.top>r.top?o=l.posBefore:(a.right-1?o:t.docView.posFromDOM(e,n,-1)}function GC(t,e,n){let r=t.childNodes.length;if(r&&n.tope.top&&o++}let u;zu&&o&&r.nodeType==1&&(u=r.childNodes[o-1]).nodeType==1&&u.contentEditable=="false"&&u.getBoundingClientRect().top>=e.top&&o--,r==t.dom&&o==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=t.state.doc.content.size:(o==0||r.nodeType!=1||r.childNodes[o-1].nodeName!="BR")&&(l=HP(t,r,o,e))}l==null&&(l=BP(t,s,e));let a=t.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function KC(t){return t.top=0&&o==r.nodeValue.length?(a--,c=1):n<0?a--:u++,Fu(hs(ki(r,a,u),c),c<0)}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&o&&(n<0||o==qo(r))){let a=r.childNodes[o-1];if(a.nodeType==1)return M1(a.getBoundingClientRect(),!1)}if(i==null&&o=0)}if(i==null&&o&&(n<0||o==qo(r))){let a=r.childNodes[o-1],u=a.nodeType==3?ki(a,qo(a)-(s?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(u)return Fu(hs(u,1),!1)}if(i==null&&o=0)}function Fu(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 M1(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 XC(t,e,n){let r=t.state,o=t.root.activeElement;r!=e&&t.updateState(e),o!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),o!=t.dom&&o&&o.focus()}}function VP(t,e,n){let r=e.selection,o=n=="up"?r.$from:r.$to;return XC(t,e,()=>{let{node:i}=t.docView.domFromPos(o.pos,n=="up"?-1:1);for(;;){let l=t.docView.nearestDesc(i,!0);if(!l)break;if(l.node.isBlock){i=l.contentDOM||l.dom;break}i=l.dom.parentNode}let s=YC(t,o.pos,1);for(let l=i.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=ki(l,0,l.nodeValue.length).getClientRects();else continue;for(let u=0;uc.top+1&&(n=="up"?s.top-c.top>(c.bottom-s.top)*2:c.bottom-s.bottom>(s.bottom-c.top)*2))return!1}}return!0})}const jP=/[\u0590-\u08ac]/;function GP(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let o=r.parentOffset,i=!o,s=o==r.parent.content.size,l=t.domSelection();return!jP.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?i:s:XC(t,e,()=>{let{focusNode:a,focusOffset:u,anchorNode:c,anchorOffset:d}=t.domSelectionRange(),h=l.caretBidiLevel;l.modify("move",n,"character");let p=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:f,focusOffset:g}=t.domSelectionRange(),m=f&&!p.contains(f.nodeType==1?f:f.parentNode)||a==f&&u==g;try{l.collapse(c,d),a&&(a!=c||u!=d)&&l.extend&&l.extend(a,u)}catch{}return h!=null&&(l.caretBidiLevel=h),m})}let qC=null,ZC=null,JC=!1;function KP(t,e,n){return qC==e&&ZC==n?JC:(qC=e,ZC=n,JC=n=="up"||n=="down"?VP(t,e,n):GP(t,e,n))}const ao=0,QC=1,Ea=2,Jo=3;class Bu{constructor(e,n,r,o){this.parent=e,this.children=n,this.dom=r,this.contentDOM=o,this.dirty=ao,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;ner(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))o=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let i=e;;i=i.parentNode){if(i==this.dom){o=!1;break}if(i.previousSibling)break}if(o==null&&n==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){o=!0;break}if(i.nextSibling)break}}return o??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,o=e;o;o=o.parentNode){let i=this.getDesc(o),s;if(i&&(!n||i.node))if(r&&(s=i.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==e))r=!1;else return i}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let o=e;o;o=o.parentNode){let i=this.getDesc(o);if(i)return i.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;ne||s instanceof nT){o=e-i;break}i=l}if(o)return this.children[r].domFromPos(o-this.children[r].border,n);for(let i;r&&!(i=this.children[r-1]).size&&i instanceof eT&&i.side>=0;r--);if(n<=0){let i,s=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,s=!1);return i&&n&&s&&!i.border&&!i.domAtom?i.domFromPos(i.size,n):{node:this.contentDOM,offset:i?er(i.dom)+1:0}}else{let i,s=!0;for(;i=r=c&&n<=u-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,n,c);e=s;for(let d=l;d>0;d--){let h=this.children[d-1];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(1)){o=er(h.dom)+1;break}e-=h.size}o==-1&&(o=0)}if(o>-1&&(u>n||l==this.children.length-1)){n=u;for(let c=l+1;cp&&sn){let p=l;l=a,a=p}let h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),u.removeAllRanges(),u.addRange(h)}}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,o=0;o=r:er){let l=r+i.border,a=s-i.border;if(e>=l&&n<=a){this.dirty=e==r||n==s?Ea:QC,e==l&&n==a&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=Jo:i.markDirty(e-l,n-l);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Ea:Jo}r=s}this.dirty=Ea}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Ea:QC;n.dirty{if(!i)return o;if(i.parent)return i.parent.posBeforeChild(i)})),!n.type.spec.raw){if(s.nodeType!=1){let l=document.createElement("span");l.appendChild(s),s=l}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=n,this.widget=n,i=this}matchesWidget(e){return this.dirty==ao&&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}}class YP extends Bu{constructor(e,n,r,o){super(e,[],n,null),this.textDOM=r,this.text=o}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class Sa extends Bu{constructor(e,n,r,o){super(e,[],r,o),this.mark=n}static create(e,n,r,o){let i=o.nodeViews[n.type.name],s=i&&i(n,o,r);return(!s||!s.dom)&&(s=Dr.renderSpec(document,n.type.spec.toDOM(n,r))),new Sa(e,n,s.dom,s.contentDOM||s.dom)}parseRule(){return this.dirty&Jo||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Jo&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=ao){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty0&&(i=L1(i,0,e,r));for(let l=0;l{if(!a)return s;if(a.parent)return a.parent.posBeforeChild(a)},r,o),c=u&&u.dom,d=u&&u.contentDOM;if(n.isText){if(!c)c=document.createTextNode(n.text);else if(c.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else c||({dom:c,contentDOM:d}=Dr.renderSpec(document,n.type.spec.toDOM(n)));!d&&!n.isText&&c.nodeName!="BR"&&(c.hasAttribute("contenteditable")||(c.contentEditable="false"),n.type.spec.draggable&&(c.draggable=!0));let h=c;return c=iT(c,r,n),u?a=new XP(e,n,r,o,c,d||null,h,u,i,s+1):n.isText?new Wp(e,n,r,o,c,h,i):new ps(e,n,r,o,c,d||null,h,i,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=()=>J.empty)}return e}matchesNode(e,n,r){return this.dirty==ao&&e.eq(this.node)&&I1(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,o=n,i=e.composing?this.localCompositionInfo(e,n):null,s=i&&i.pos>-1?i:null,l=i&&i.pos<0,a=new ZP(this,s&&s.node,e);e5(this.node,this.innerDeco,(u,c,d)=>{u.spec.marks?a.syncToMarks(u.spec.marks,r,e):u.type.side>=0&&!d&&a.syncToMarks(c==this.node.childCount?Ge.none:this.node.child(c).marks,r,e),a.placeWidget(u,e,o)},(u,c,d,h)=>{a.syncToMarks(u.marks,r,e);let p;a.findNodeMatch(u,c,d,h)||l&&e.state.selection.from>o&&e.state.selection.to-1&&a.updateNodeAt(u,c,d,p,e)||a.updateNextNode(u,c,d,e,h,o)||a.addNode(u,c,d,e,o),o+=u.nodeSize}),a.syncToMarks([],r,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==Ea)&&(s&&this.protectLocalComposition(e,s),rT(this.contentDOM,this.children,e),Wl&&t5(this.dom))}localCompositionInfo(e,n){let{from:r,to:o}=e.state.selection;if(!(e.state.selection instanceof Me)||rn+this.node.content.size)return null;let i=e.domSelectionRange(),s=n5(i.focusNode,i.focusOffset);if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let l=s.nodeValue,a=r5(this.node.content,l,r-n,o-n);return a<0?null:{node:s,pos:a,text:l}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:o}){if(this.getDesc(n))return;let i=n;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let s=new YP(this,i,n,o);e.input.compositionNodes.push(s),this.children=L1(this.children,r,r+o.length,e,s)}update(e,n,r,o){return this.dirty==Jo||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,o),!0)}updateInner(e,n,r,o){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(o,this.posAtStart),this.dirty=ao}updateOuterDeco(e){if(I1(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=oT(this.dom,this.nodeDOM,O1(this.outerDeco,this.node,n),O1(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 tT(t,e,n,r,o){iT(r,e,t);let i=new ps(void 0,t,e,n,r,r,r,o,0);return i.contentDOM&&i.updateChildren(o,0),i}class Wp extends ps{constructor(e,n,r,o,i,s,l){super(e,n,r,o,i,null,s,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,o){return this.dirty==Jo||this.dirty!=ao&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=ao||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,o.trackWrites==this.nodeDOM&&(o.trackWrites=null)),this.node=e,this.dirty=ao,!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 o=this.node.cut(e,n),i=document.createTextNode(o.text);return new Wp(this.parent,o,this.outerDeco,this.innerDeco,i,i,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=Jo)}get domAtom(){return!1}}class nT extends Bu{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==ao&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class XP extends ps{constructor(e,n,r,o,i,s,l,a,u,c){super(e,n,r,o,i,s,l,u,c),this.spec=a}update(e,n,r,o){if(this.dirty==Jo)return!1;if(this.spec.update){let i=this.spec.update(e,n,r);return i&&this.updateInner(e,n,r,o),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,o){this.spec.setSelection?this.spec.setSelection(e,n,r):super.setSelection(e,n,r,o)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function rT(t,e,n){let r=t.firstChild,o=!1;for(let i=0;i>1,s=Math.min(i,e.length);for(;o-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=Sa.create(this.top,e[i],n,r);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,i++}}findNodeMatch(e,n,r,o){let i=-1,s;if(o>=this.preMatch.index&&(s=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&s.matchesNode(e,n,r))i=this.top.children.indexOf(s,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l0;){let l;for(;;)if(r){let u=n.children[r-1];if(u instanceof Sa)n=u,r=u.children.length;else{l=u,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let a=l.node;if(a){if(a!=t.child(o-1))break;--o,i.set(l,o),s.push(l)}}return{index:o,matched:i,matches:s.reverse()}}function QP(t,e){return t.type.side-e.type.side}function e5(t,e,n,r){let o=e.locals(t),i=0;if(o.length==0){for(let u=0;ui;)l.push(o[s++]);let f=i+h.nodeSize;if(h.isText){let m=f;s!m.inline):l.slice();r(h,g,e.forChild(i,h),p),i=f}}function t5(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 n5(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=qo(t)}else if(t.nodeType==1&&e=n){if(i>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let u=l=0&&u+e.length+l>=n)return l+u;if(n==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function L1(t,e,n,r,o){let i=[];for(let s=0,l=0;s=n||c<=e?i.push(a):(un&&i.push(a.slice(n-u,a.size,r)))}return i}function N1(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let o=t.docView.nearestDesc(n.focusNode),i=o&&o.size==0,s=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let l=r.resolve(s),a,u;if(Up(n)){for(a=l;o&&!o.node;)o=o.parent;let c=o.node;if(o&&c.isAtom&&Oe.isSelectable(c)&&o.parent&&!(c.isInline&&AP(n.focusNode,n.focusOffset,o.dom))){let d=o.posBefore;u=new Oe(s==d?l:r.resolve(d))}}else{let c=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(c<0)return null;a=r.resolve(c)}if(!u){let c=e=="pointer"||t.state.selection.head{(n.anchorNode!=r||n.anchorOffset!=o)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!aT(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function i5(t){let e=t.domSelection(),n=document.createRange(),r=t.cursorWrapper.dom,o=r.nodeName=="IMG";o?n.setEnd(r.parentNode,er(r)+1):n.setEnd(r,0),n.collapse(!1),e.removeAllRanges(),e.addRange(n),!o&&!t.state.selection.visible&&vr&&ds<=11&&(r.disabled=!0,r.disabled=!1)}function dT(t,e){if(e instanceof Oe){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(hT(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else hT(t)}function hT(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function D1(t,e,n,r){return t.someProp("createSelectionBetween",o=>o(t,e,n))||Me.between(e,n,r)}function pT(t){return t.editable&&!t.hasFocus()?!1:fT(t)}function fT(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 s5(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return wa(e.node,e.offset,n.anchorNode,n.anchorOffset)}function P1(t,e){let{$anchor:n,$head:r}=t.selection,o=e>0?n.max(r):n.min(r),i=o.parent.inlineContent?o.depth?t.doc.resolve(e>0?o.after():o.before()):null:o;return i&&He.findFrom(i,e)}function fs(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function gT(t,e,n){let r=t.state.selection;if(r instanceof Me)if(n.indexOf("s")>-1){let{$head:o}=r,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let s=t.state.doc.resolve(o.pos+i.nodeSize*(e<0?-1:1));return fs(t,new Me(r.$anchor,s))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let o=P1(t.state,e);return o&&o instanceof Oe?fs(t,o):!1}else if(!(so&&n.indexOf("m")>-1)){let o=r.$head,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter,s;if(!i||i.isText)return!1;let l=e<0?o.pos-i.nodeSize:o.pos;return i.isAtom||(s=t.docView.descAt(l))&&!s.contentDOM?Oe.isSelectable(i)?fs(t,new Oe(e<0?t.state.doc.resolve(o.pos-i.nodeSize):o)):zu?fs(t,new Me(t.state.doc.resolve(e<0?l:l+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof Oe&&r.node.isInline)return fs(t,new Me(e>0?r.$to:r.$from));{let o=P1(t.state,e);return o?fs(t,o):!1}}}function Vp(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Uu(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function jl(t,e){return e<0?a5(t):l5(t)}function a5(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let o,i,s=!1;for(Ro&&n.nodeType==1&&r0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(Uu(l,-1))o=n,i=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(mT(n))break;{let l=n.previousSibling;for(;l&&Uu(l,-1);)o=n.parentNode,i=er(l),l=l.previousSibling;if(l)n=l,r=Vp(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}s?z1(t,n,r):o&&z1(t,o,i)}function l5(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let o=Vp(n),i,s;for(;;)if(r{t.state==o&&Si(t)},50)}function vT(t,e){let n=t.state.doc.resolve(e);if(!(Bn||OP)&&n.parent.inlineContent){let o=t.coordsAtPos(e);if(e>n.start()){let i=t.coordsAtPos(e-1),s=(i.top+i.bottom)/2;if(s>o.top&&s1)return i.lefto.top&&s1)return i.left>o.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function yT(t,e,n){let r=t.state.selection;if(r instanceof Me&&!r.empty||n.indexOf("s")>-1||so&&n.indexOf("m")>-1)return!1;let{$from:o,$to:i}=r;if(!o.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let s=P1(t.state,e);if(s&&s instanceof Oe)return fs(t,s)}if(!o.parent.inlineContent){let s=e<0?o:i,l=r instanceof Qn?He.near(s,e):He.findFrom(s,e);return l?fs(t,l):!1}return!1}function bT(t,e){if(!(t.state.selection instanceof Me))return!0;let{$head:n,$anchor:r,empty:o}=t.state.selection;if(!n.sameParent(r))return!0;if(!o)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let s=t.state.tr;return e<0?s.delete(n.pos-i.nodeSize,n.pos):s.delete(n.pos,n.pos+i.nodeSize),t.dispatch(s),!0}return!1}function xT(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function d5(t){if(!tr||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;xT(t,r,"true"),setTimeout(()=>xT(t,r,"false"),20)}return!1}function h5(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function p5(t,e){let n=e.keyCode,r=h5(e);if(n==8||so&&n==72&&r=="c")return bT(t,-1)||jl(t,-1);if(n==46&&!e.shiftKey||so&&n==68&&r=="c")return bT(t,1)||jl(t,1);if(n==13||n==27)return!0;if(n==37||so&&n==66&&r=="c"){let o=n==37?vT(t,t.state.selection.from)=="ltr"?-1:1:-1;return gT(t,o,r)||jl(t,o)}else if(n==39||so&&n==70&&r=="c"){let o=n==39?vT(t,t.state.selection.from)=="ltr"?1:-1:1;return gT(t,o,r)||jl(t,o)}else{if(n==38||so&&n==80&&r=="c")return yT(t,-1,r)||jl(t,-1);if(n==40||so&&n==78&&r=="c")return d5(t)||yT(t,1,r)||jl(t,1);if(r==(so?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function wT(t,e){t.someProp("transformCopied",p=>{e=p(e,t)});let n=[],{content:r,openStart:o,openEnd:i}=e;for(;o>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){o--,i--;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")||Dr.fromSchema(t.state.schema),l=RT(),a=l.createElement("div");a.appendChild(s.serializeFragment(r,{document:l}));let u=a.firstChild,c,d=0;for(;u&&u.nodeType==1&&(c=AT[u.nodeName.toLowerCase()]);){for(let p=c.length-1;p>=0;p--){let f=l.createElement(c[p]);for(;a.firstChild;)f.appendChild(a.firstChild);a.appendChild(f),d++}u=a.firstChild}u&&u.nodeType==1&&u.setAttribute("data-pm-slice",`${o} ${i}${d?` -${d}`:""} ${JSON.stringify(n)}`);let h=t.someProp("clipboardTextSerializer",p=>p(e,t))||e.content.textBetween(0,e.content.size,`
-`);return{dom:a,text:h}}function L2(t,e,n,r,o){let i=o.parent.type.spec.code,s,l;if(!n&&!e)return null;let a=e&&(r||i||!n);if(a){if(t.someProp("transformPastedText",h=>{e=h(e,i||r,t)}),i)return e?new ae(J.from(t.state.schema.text(e.replace(/\r\n?/g,`
-`))),0,0):ae.empty;let d=t.someProp("clipboardTextParser",h=>h(e,o,r,t));if(d)l=d;else{let h=o.marks(),{schema:p}=t.state,f=Vr.fromSchema(p);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(g=>{let m=s.appendChild(document.createElement("p"));g&&m.appendChild(f.serializeNode(p.text(g,h)))})}}else t.someProp("transformPastedHTML",d=>{n=d(n,t)}),s=Z3(n),Gh&&J3(s);let u=s&&s.querySelector("[data-pm-slice]"),c=u&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(u.getAttribute("data-pm-slice")||"");if(c&&c[3])for(let d=+c[3];d>0;d--){let h=s.firstChild;for(;h&&h.nodeType!=1;)h=h.nextSibling;if(!h)break;s=h}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||Za.fromSchema(t.state.schema)).parseSlice(s,{preserveWhitespace:!!(a||c),context:o,ruleFromNode(h){return h.nodeName=="BR"&&!h.nextSibling&&h.parentNode&&!X3.test(h.parentNode.nodeName)?{ignore:!0}:null}})),c)l=Q3(cC(l,+c[1],+c[2]),c[4]);else if(l=ae.maxOpen(q3(l.content,o),!0),l.openStart||l.openEnd){let d=0,h=0;for(let p=l.content.firstChild;d{l=d(l,t)}),l}const X3=/^(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 q3(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let o=e.node(n).contentMatchAt(e.index(n)),i,s=[];if(t.forEach(l=>{if(!s)return;let a=o.findWrapping(l.type),u;if(!a)return s=null;if(u=s.length&&i.length&&$2(a,i,l,s[s.length-1],0))s[s.length-1]=u;else{s.length&&(s[s.length-1]=D2(s[s.length-1],i.length));let c=N2(l,a);s.push(c),o=o.matchType(c.type),i=a}}),s)return J.from(s)}return t}function N2(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,J.from(t));return t}function $2(t,e,n,r,o){if(o1&&(i=0),o=n&&(l=e<0?s.contentMatchAt(0).fillBefore(l,i<=o).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(J.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,s.copy(l))}function cC(t,e,n){return e]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=z2().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),o;if((o=r&&P2[r[1].toLowerCase()])&&(t=o.map(i=>"<"+i+">").join("")+t+o.map(i=>""+i+">").reverse().join("")),n.innerHTML=t,o)for(let i=0;i=0;l-=2){let a=n.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;o=J.from(a.create(r[l+1],o)),i++,s++}return new ae(o,i,s)}const ar={},lr={},ez={touchstart:!0,touchmove:!0};class tz{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 nz(t){for(let e in ar){let n=ar[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{oz(t,r)&&!$b(t,r)&&(t.editable||!(r.type in lr))&&n(t,r)},ez[e]?{passive:!0}:void 0)}sr&&t.dom.addEventListener("input",()=>null),P0(t)}function Es(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function rz(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 P0(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>$b(t,r))})}function $b(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function oz(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 iz(t,e){!$b(t,e)&&ar[e.type]&&(t.editable||!(e.type in lr))&&ar[e.type](t,e)}lr.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!B2(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(No&&Gn&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),Dc&&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",o=>o(t,Ia(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||Y3(t,n)?n.preventDefault():Es(t,"key")};lr.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};lr.keypress=(t,e)=>{let n=e;if(B2(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||ao&&n.metaKey)return;if(t.someProp("handleKeyPress",o=>o(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof Me)||!r.$from.sameParent(r.$to)){let o=String.fromCharCode(n.charCode);!/[\r\n]/.test(o)&&!t.someProp("handleTextInput",i=>i(t,r.$from.pos,r.$to.pos,o))&&t.dispatch(t.state.tr.insertText(o).scrollIntoView()),n.preventDefault()}};function ym(t){return{left:t.clientX,top:t.clientY}}function sz(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function Db(t,e,n,r,o){if(r==-1)return!1;let i=t.state.doc.resolve(r);for(let s=i.depth+1;s>0;s--)if(t.someProp(e,l=>s>i.depth?l(t,n,i.nodeAfter,i.before(s),o,!0):l(t,n,i.node(s),i.before(s),o,!1)))return!0;return!1}function bc(t,e,n){t.focused||t.focus();let r=t.state.tr.setSelection(e);n=="pointer"&&r.setMeta("pointer",!0),t.dispatch(r)}function az(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&Oe.isSelectable(r)?(bc(t,new Oe(n),"pointer"),!0):!1}function lz(t,e){if(e==-1)return!1;let n=t.state.selection,r,o;n instanceof Oe&&(r=n.node);let i=t.state.doc.resolve(e);for(let s=i.depth+1;s>0;s--){let l=s>i.depth?i.nodeAfter:i.node(s);if(Oe.isSelectable(l)){r&&n.$from.depth>0&&s>=n.$from.depth&&i.before(n.$from.depth+1)==n.$from.pos?o=i.before(n.$from.depth):o=i.before(s);break}}return o!=null?(bc(t,Oe.create(t.state.doc,o),"pointer"),!0):!1}function cz(t,e,n,r,o){return Db(t,"handleClickOn",e,n,r)||t.someProp("handleClick",i=>i(t,e,r))||(o?lz(t,n):az(t,n))}function uz(t,e,n,r){return Db(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",o=>o(t,e,r))}function dz(t,e,n,r){return Db(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",o=>o(t,e,r))||hz(t,n,r)}function hz(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(bc(t,Me.create(r,0,r.content.size),"pointer"),!0):!1;let o=r.resolve(e);for(let i=o.depth+1;i>0;i--){let s=i>o.depth?o.nodeAfter:o.node(i),l=o.before(i);if(s.inlineContent)bc(t,Me.create(r,l+1,l+1+s.content.size),"pointer");else if(Oe.isSelectable(s))bc(t,Oe.create(r,l),"pointer");else continue;return!0}}function Pb(t){return og(t)}const F2=ao?"metaKey":"ctrlKey";ar.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=Pb(t),o=Date.now(),i="singleClick";o-t.input.lastClick.time<500&&sz(n,t.input.lastClick)&&!n[F2]&&(t.input.lastClick.type=="singleClick"?i="doubleClick":t.input.lastClick.type=="doubleClick"&&(i="tripleClick")),t.input.lastClick={time:o,x:n.clientX,y:n.clientY,type:i};let s=t.posAtCoords(ym(n));s&&(i=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new pz(t,s,n,!!r)):(i=="doubleClick"?uz:dz)(t,s.pos,s.inside,n)?n.preventDefault():Es(t,"pointer"))};class pz{constructor(e,n,r,o){this.view=e,this.pos=n,this.event=r,this.flushed=o,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[F2],this.allowDefault=r.shiftKey;let i,s;if(n.inside>-1)i=e.state.doc.nodeAt(n.inside),s=n.inside;else{let c=e.state.doc.resolve(n.pos);i=c.parent,s=c.depth?c.before():0}const l=o?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a?a.dom:null;let{selection:u}=e.state;(r.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||u instanceof Oe&&u.from<=s&&u.to>s)&&(this.mightDrag={node:i,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Uo&&!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)),Es(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(()=>zi(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(ym(e))),this.updateAllowDefault(e),this.allowDefault||!n?Es(this.view,"pointer"):cz(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||sr&&this.mightDrag&&!this.mightDrag.node.isAtom||Gn&&!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)?(bc(this.view,Be.near(this.view.state.doc.resolve(n.pos)),"pointer"),e.preventDefault()):Es(this.view,"pointer")}move(e){this.updateAllowDefault(e),Es(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)}}ar.touchstart=t=>{t.input.lastTouch=Date.now(),Pb(t),Es(t,"pointer")};ar.touchmove=t=>{t.input.lastTouch=Date.now(),Es(t,"pointer")};ar.contextmenu=t=>Pb(t);function B2(t,e){return t.composing?!0:sr&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const fz=No?5e3:-1;lr.compositionstart=lr.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(),og(t,!0),t.markCursor=null;else if(og(t),Uo&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let o=r.focusNode,i=r.focusOffset;o&&o.nodeType==1&&i!=0;){let s=i<0?o.lastChild:o.childNodes[i-1];if(!s)break;if(s.nodeType==3){t.domSelection().collapse(s,s.nodeValue.length);break}else o=s,i=-1}}t.input.composing=!0}H2(t,fz)};lr.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++,H2(t,20))};function H2(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>og(t),e))}function U2(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=gz());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function gz(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function og(t,e=!1){if(!(No&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),U2(t),e||t.docView&&t.docView.dirty){let n=Lb(t);return n&&!n.eq(t.state.selection)?t.dispatch(t.state.tr.setSelection(n)):t.updateState(t.state),!0}return!1}}function mz(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(),o=document.createRange();o.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const Pc=kr&&_s<15||Dc&&p3<604;ar.copy=lr.cut=(t,e)=>{let n=e,r=t.state.selection,o=n.type=="cut";if(r.empty)return;let i=Pc?null:n.clipboardData,s=r.content(),{dom:l,text:a}=I2(t,s);i?(n.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):mz(t,l),o&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function vz(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function yz(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 o=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Yd(t,r.value,null,o,e):Yd(t,r.textContent,r.innerHTML,o,e)},50)}function Yd(t,e,n,r,o){let i=L2(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",a=>a(t,o,i||ae.empty)))return!0;if(!i)return!1;let s=vz(i),l=s?t.state.tr.replaceSelectionWith(s,r):t.state.tr.replaceSelection(i);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}lr.paste=(t,e)=>{let n=e;if(t.composing&&!No)return;let r=Pc?null:n.clipboardData,o=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&Yd(t,r.getData("text/plain"),r.getData("text/html"),o,n)?n.preventDefault():yz(t,n)};class bz{constructor(e,n){this.slice=e,this.move=n}}const W2=ao?"altKey":"ctrlKey";ar.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let o=t.state.selection,i=o.empty?null:t.posAtCoords(ym(n));if(!(i&&i.pos>=o.from&&i.pos<=(o instanceof Oe?o.to-1:o.to))){if(r&&r.mightDrag)t.dispatch(t.state.tr.setSelection(Oe.create(t.state.doc,r.mightDrag.pos)));else if(n.target&&n.target.nodeType==1){let u=t.docView.nearestDesc(n.target,!0);u&&u.node.type.spec.draggable&&u!=t.docView&&t.dispatch(t.state.tr.setSelection(Oe.create(t.state.doc,u.posBefore)))}}let s=t.state.selection.content(),{dom:l,text:a}=I2(t,s);n.dataTransfer.clearData(),n.dataTransfer.setData(Pc?"Text":"text/html",l.innerHTML),n.dataTransfer.effectAllowed="copyMove",Pc||n.dataTransfer.setData("text/plain",a),t.dragging=new bz(s,!n[W2])};ar.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};lr.dragover=lr.dragenter=(t,e)=>e.preventDefault();lr.drop=(t,e)=>{let n=e,r=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let o=t.posAtCoords(ym(n));if(!o)return;let i=t.state.doc.resolve(o.pos),s=r&&r.slice;s?t.someProp("transformPasted",f=>{s=f(s,t)}):s=L2(t,n.dataTransfer.getData(Pc?"Text":"text/plain"),Pc?null:n.dataTransfer.getData("text/html"),!1,i);let l=!!(r&&!n[W2]);if(t.someProp("handleDrop",f=>f(t,n,s||ae.empty,l))){n.preventDefault();return}if(!s)return;n.preventDefault();let a=s?LP(t.state.doc,i.pos,s):i.pos;a==null&&(a=i.pos);let u=t.state.tr;l&&u.deleteSelection();let c=u.mapping.map(a),d=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,h=u.doc;if(d?u.replaceRangeWith(c,c,s.content.firstChild):u.replaceRange(c,c,s),u.doc.eq(h))return;let p=u.doc.resolve(c);if(d&&Oe.isSelectable(s.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(s.content.firstChild))u.setSelection(new Oe(p));else{let f=u.mapping.map(a);u.mapping.maps[u.mapping.maps.length-1].forEach((g,m,v,y)=>f=y),u.setSelection(Nb(t,p,u.doc.resolve(f)))}t.focus(),t.dispatch(u.setMeta("uiEvent","drop"))};ar.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())&&zi(t)},20))};ar.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)};ar.beforeinput=(t,e)=>{if(Gn&&No&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",i=>i(t,Ia(8,"Backspace")))))return;let{$cursor:o}=t.state.selection;o&&o.pos>0&&t.dispatch(t.state.tr.delete(o.pos-1,o.pos).scrollIntoView())},50)}};for(let t in lr)ar[t]=lr[t];function Xd(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class ig{constructor(e,n){this.toDOM=e,this.spec=n||Va,this.side=this.spec.side||0}map(e,n,r,o){let{pos:i,deleted:s}=e.mapResult(n.from+o,this.side<0?-1:1);return s?null:new vt(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof ig&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Xd(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Ms{constructor(e,n){this.attrs=e,this.spec=n||Va}map(e,n,r,o){let i=e.map(n.from+o,this.spec.inclusiveStart?-1:1)-r,s=e.map(n.to+o,this.spec.inclusiveEnd?1:-1)-r;return i>=s?null:new vt(i,s,this)}valid(e,n){return n.from=e&&(!i||i(l.spec))&&r.push(l.copy(l.from+o,l.to+o))}for(let s=0;se){let l=this.children[s]+1;this.children[s+2].findInner(e-l,n-l,r,o+l,i)}}map(e,n,r){return this==Wn||e.maps.length==0?this:this.mapInner(e,n,0,0,r||Va)}mapInner(e,n,r,o,i){let s;for(let l=0;l{let u=a+r,c;if(c=j2(n,l,u)){for(o||(o=this.children.slice());il&&d.to=e){this.children[l]==e&&(r=this.children[l+2]);break}let i=e+1,s=i+n.content.size;for(let l=0;li&&a.type instanceof Ms){let u=Math.max(i,a.from)-i,c=Math.min(s,a.to)-i;uo.map(e,n,Va));return ys.from(r)}forChild(e,n){if(n.isLeaf)return He.empty;let r=[];for(let o=0;on instanceof He)?e:e.reduce((n,r)=>n.concat(r instanceof He?r:r.members),[]))}}}function wz(t,e,n,r,o,i,s){let l=t.slice();for(let u=0,c=i;u{let m=g-f-(p-h);for(let v=0;vy+c-d)continue;let b=l[v]+c-d;p>=b?l[v+1]=h<=b?-2:-1:f>=o&&m&&(l[v]+=m,l[v+1]+=m)}d+=m}),c=n.maps[u].map(c,-1)}let a=!1;for(let u=0;u=r.content.size){a=!0;continue}let h=n.map(t[u+1]+i,-1),p=h-o,{index:f,offset:g}=r.content.findIndex(d),m=r.maybeChild(f);if(m&&g==d&&g+m.nodeSize==p){let v=l[u+2].mapInner(n,m,c+1,t[u]+i+1,s);v!=Wn?(l[u]=d,l[u+1]=p,l[u+2]=v):(l[u+1]=-2,a=!0)}else a=!0}if(a){let u=xz(l,t,e,n,o,i,s),c=sg(u,r,0,s);e=c.local;for(let d=0;dn&&s.to{let u=j2(t,l,a+n);if(u){i=!0;let c=sg(u,l,n+a+1,r);c!=Wn&&o.push(a,a+l.nodeSize,c)}});let s=V2(i?G2(t):t,-n).sort(ja);for(let l=0;l0;)e++;t.splice(e,0,n)}function h1(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=Wn&&e.push(r)}),t.cursorWrapper&&e.push(He.create(t.state.doc,[t.cursorWrapper.deco])),ys.from(e)}const kz={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Ez=kr&&_s<=11;class Sz{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class Cz{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Sz,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let o=0;oo.type=="childList"&&o.removedNodes.length||o.type=="characterData"&&o.oldValue.length>o.target.nodeValue.length)?this.flushSoon():this.flush()}),Ez&&(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,kz)),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(rC(this.view)){if(this.suppressingSelectionUpdates)return zi(this.view);if(kr&&_s<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Ja(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let i=e.focusNode;i;i=Kd(i))n.add(i);for(let i=e.anchorNode;i;i=Kd(i))if(n.has(i)){r=i;break}let o=r&&this.view.docView.nearestDesc(r);if(o&&o.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(),o=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&rC(e)&&!this.ignoreSelectionChange(r),i=-1,s=-1,l=!1,a=[];if(e.editable)for(let c=0;c1){let c=a.filter(d=>d.nodeName=="BR");if(c.length==2){let d=c[0],h=c[1];d.parentNode&&d.parentNode.parentNode==h.parentNode?h.remove():d.remove()}}let u=null;i<0&&o&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)-1||o)&&(i>-1&&(e.docView.markDirty(i,s),Tz(e)),this.handleDOMChange(i,s,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||zi(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 c=0;co;m--){let v=r.childNodes[m-1],y=v.pmViewDesc;if(v.nodeName=="BR"&&!y){i=m;break}if(!y||y.size)break}let d=t.state.doc,h=t.someProp("domParser")||Za.fromSchema(t.state.schema),p=d.resolve(s),f=null,g=h.parse(r,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:o,to:i,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:Rz,context:p});if(u&&u[0].pos!=null){let m=u[0].pos,v=u[1]&&u[1].pos;v==null&&(v=m),f={anchor:m+s,head:v+s}}return{doc:g,sel:f,from:s,to:l}}function Rz(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(sr&&/^(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||sr&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const Mz=/^(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 Oz(t,e,n,r,o){let i=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let C=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,O=Lb(t,C);if(O&&!t.state.selection.eq(O)){if(Gn&&No&&t.input.lastKeyCode===13&&Date.now()-100_(t,Ia(13,"Enter"))))return;let R=t.state.tr.setSelection(O);C=="pointer"?R.setMeta("pointer",!0):C=="key"&&R.scrollIntoView(),i&&R.setMeta("composition",i),t.dispatch(R)}return}let s=t.state.doc.resolve(e),l=s.sharedDepth(n);e=s.before(l+1),n=t.state.doc.resolve(n).after(l+1);let a=t.state.selection,u=_z(t,e,n),c=t.state.doc,d=c.slice(u.from,u.to),h,p;t.input.lastKeyCode===8&&Date.now()-100Date.now()-225||No)&&o.some(C=>C.nodeType==1&&!Mz.test(C.nodeName))&&(!f||f.endA>=f.endB)&&t.someProp("handleKeyDown",C=>C(t,Ia(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!f)if(r&&a instanceof Me&&!a.empty&&a.$head.sameParent(a.$anchor)&&!t.composing&&!(u.sel&&u.sel.anchor!=u.sel.head))f={start:a.from,endA:a.to,endB:a.to};else{if(u.sel){let C=fC(t,t.state.doc,u.sel);if(C&&!C.eq(t.state.selection)){let O=t.state.tr.setSelection(C);i&&O.setMeta("composition",i),t.dispatch(O)}}return}if(Gn&&t.cursorWrapper&&u.sel&&u.sel.anchor==t.cursorWrapper.deco.from&&u.sel.head==u.sel.anchor){let C=f.endB-f.start;u.sel={anchor:u.sel.anchor+C,head:u.sel.anchor+C}}t.input.domChangeCount++,t.state.selection.fromt.state.selection.from&&f.start<=t.state.selection.from+2&&t.state.selection.from>=u.from?f.start=t.state.selection.from:f.endA=t.state.selection.to-2&&t.state.selection.to<=u.to&&(f.endB+=t.state.selection.to-f.endA,f.endA=t.state.selection.to)),kr&&_s<=11&&f.endB==f.start+1&&f.endA==f.start&&f.start>u.from&&u.doc.textBetween(f.start-u.from-1,f.start-u.from+1)==" "&&(f.start--,f.endA--,f.endB--);let g=u.doc.resolveNoCache(f.start-u.from),m=u.doc.resolveNoCache(f.endB-u.from),v=c.resolve(f.start),y=g.sameParent(m)&&g.parent.inlineContent&&v.end()>=f.endA,b;if((Dc&&t.input.lastIOSEnter>Date.now()-225&&(!y||o.some(C=>C.nodeName=="DIV"||C.nodeName=="P"))||!y&&g.posC(t,Ia(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>f.start&&Lz(c,f.start,f.endA,g,m)&&t.someProp("handleKeyDown",C=>C(t,Ia(8,"Backspace")))){No&&Gn&&t.domObserver.suppressSelectionUpdates();return}Gn&&No&&f.endB==f.start&&(t.input.lastAndroidDelete=Date.now()),No&&!y&&g.start()!=m.start()&&m.parentOffset==0&&g.depth==m.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==f.endA&&(f.endB-=2,m=u.doc.resolveNoCache(f.endB-u.from),setTimeout(()=>{t.someProp("handleKeyDown",function(C){return C(t,Ia(13,"Enter"))})},20));let w=f.start,k=f.endA,x,S,A;if(y){if(g.pos==m.pos)kr&&_s<=11&&g.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>zi(t),20)),x=t.state.tr.delete(w,k),S=c.resolve(f.start).marksAcross(c.resolve(f.endA));else if(f.endA==f.endB&&(A=Iz(g.parent.content.cut(g.parentOffset,m.parentOffset),v.parent.content.cut(v.parentOffset,f.endA-v.start()))))x=t.state.tr,A.type=="add"?x.addMark(w,k,A.mark):x.removeMark(w,k,A.mark);else if(g.parent.child(g.index()).isText&&g.index()==m.index()-(m.textOffset?0:1)){let C=g.parent.textBetween(g.parentOffset,m.parentOffset);if(t.someProp("handleTextInput",O=>O(t,w,k,C)))return;x=t.state.tr.insertText(C,w,k)}}if(x||(x=t.state.tr.replace(w,k,u.doc.slice(f.start-u.from,f.endB-u.from))),u.sel){let C=fC(t,x.doc,u.sel);C&&!(Gn&&No&&t.composing&&C.empty&&(f.start!=f.endB||t.input.lastAndroidDeletee.content.size?null:Nb(t,e.resolve(n.anchor),e.resolve(n.head))}function Iz(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,o=n,i=r,s,l,a;for(let c=0;cc.mark(l.addToSet(c.marks));else if(o.length==0&&i.length==1)l=i[0],s="remove",a=c=>c.mark(l.removeFromSet(c.marks));else return null;let u=[];for(let c=0;cn||p1(s,!0,!1)