snow-cms 1.4.3 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/milkdown.js CHANGED
@@ -1,44 +1,46 @@
1
- function xl(n){var e,t,r="";if(typeof n=="string"||typeof n=="number")r+=n;else if(typeof n=="object")if(Array.isArray(n)){var i=n.length;for(e=0;e<i;e++)n[e]&&(t=xl(n[e]))&&(r&&(r+=" "),r+=t)}else for(t in n)n[t]&&(r&&(r+=" "),r+=t);return r}function $u(){for(var n,e,t=0,r="",i=arguments.length;t<i;t++)(n=arguments[t])&&(e=xl(n))&&(r&&(r+=" "),r+=e);return r}function qu(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Se=(n=>(n.docTypeError="docTypeError",n.contextNotFound="contextNotFound",n.timerNotFound="timerNotFound",n.ctxCallOutOfScope="ctxCallOutOfScope",n.createNodeInParserFail="createNodeInParserFail",n.stackOverFlow="stackOverFlow",n.parserMatchError="parserMatchError",n.serializerMatchError="serializerMatchError",n.getAtomFromSchemaFail="getAtomFromSchemaFail",n.expectDomTypeError="expectDomTypeError",n.callCommandBeforeEditorView="callCommandBeforeEditorView",n.missingRootElement="missingRootElement",n.missingNodeInSchema="missingNodeInSchema",n.missingMarkInSchema="missingMarkInSchema",n.ctxNotBind="ctxNotBind",n.missingYjsDoc="missingYjsDoc",n))(Se||{});class Oe extends Error{constructor(e,t){super(t),this.name="MilkdownError",this.code=e}}const Wu=(n,e)=>typeof e=="function"?"[Function]":e,Cr=n=>JSON.stringify(n,Wu);function ju(n){return new Oe(Se.docTypeError,`Doc type error, unsupported type: ${Cr(n)}`)}function Ju(n){return new Oe(Se.contextNotFound,`Context "${n}" not found, do you forget to inject it?`)}function Hu(n){return new Oe(Se.timerNotFound,`Timer "${n}" not found, do you forget to record it?`)}function Tr(){return new Oe(Se.ctxCallOutOfScope,"Should not call a context out of the plugin.")}function Ku(n,e,t){const i=`Cannot create node for ${"name"in n?n.name:n}`,s=c=>{if(c==null)return"null";if(Array.isArray(c))return`[${c.map(s).join(", ")}]`;if(typeof c=="object")return"toJSON"in c&&typeof c.toJSON=="function"?JSON.stringify(c.toJSON()):"spec"in c?JSON.stringify(c.spec):JSON.stringify(c);if(typeof c=="string"||typeof c=="number"||typeof c=="boolean")return JSON.stringify(c);if(typeof c=="function")return`[Function: ${c.name||"anonymous"}]`;try{return String(c)}catch{return"[Unserializable]"}},o=["[Description]",i],l=["[Attributes]",e],a=["[Content]",(t??[]).map(c=>c?typeof c=="object"&&"type"in c?`${c}`:s(c):"null")],u=[o,l,a].reduce((c,[h,d])=>{const f=`${h}: ${s(d)}.`;return c.concat(f)},[]);return new Oe(Se.createNodeInParserFail,u.join(`
2
- `))}function bl(){return new Oe(Se.stackOverFlow,"Stack over flow, cannot pop on an empty stack.")}function Uu(n){return new Oe(Se.parserMatchError,`Cannot match target parser for node: ${Cr(n)}.`)}function Yu(n){return new Oe(Se.serializerMatchError,`Cannot match target serializer for node: ${Cr(n)}.`)}function dy(n){return new Oe(Se.expectDomTypeError,`Expect to be a dom, but get: ${Cr(n)}.`)}function Pr(){return new Oe(Se.callCommandBeforeEditorView,"You're trying to call a command before editor view initialized, make sure to get commandManager from ctx after editor view has been initialized")}function py(n){return new Oe(Se.missingNodeInSchema,`Missing node in schema, milkdown cannot find "${n}" in schema.`)}function my(n){return new Oe(Se.missingMarkInSchema,`Missing mark in schema, milkdown cannot find "${n}" in schema.`)}class Sl{constructor(){this.sliceMap=new Map,this.get=e=>{const t=typeof e=="string"?[...this.sliceMap.values()].find(r=>r.type.name===e):this.sliceMap.get(e.id);if(!t){const r=typeof e=="string"?e:e.name;throw Ju(r)}return t},this.remove=e=>{const t=typeof e=="string"?[...this.sliceMap.values()].find(r=>r.type.name===e):this.sliceMap.get(e.id);t&&this.sliceMap.delete(t.type.id)},this.has=e=>typeof e=="string"?[...this.sliceMap.values()].some(t=>t.type.name===e):this.sliceMap.has(e.id)}}let Qu=class{constructor(e,t,r){this.#t=[],this.#r=()=>{this.#t.forEach(i=>i(this.#e))},this.set=i=>{this.#e=i,this.#r()},this.get=()=>this.#e,this.update=i=>{this.#e=i(this.#e),this.#r()},this.type=r,this.#e=t,e.set(r.id,this)}#t;#e;#r;on(e){return this.#t.push(e),()=>{this.#t=this.#t.filter(t=>t!==e)}}once(e){const t=this.on(r=>{e(r),t()});return t}off(e){this.#t=this.#t.filter(t=>t!==e)}offAll(){this.#t=[]}};class Gu{constructor(e,t){this.id=Symbol(`Context-${t}`),this.name=t,this._defaultValue=e,this._typeInfo=()=>{throw Tr()}}create(e,t=this._defaultValue){return new Qu(e,t,this)}}const V=(n,e)=>new Gu(n,e);class Xu{constructor(e,t,r){this.#n=new Set,this.#o=new Set,this.#s=new Map,this.#i=new Map,this.read=()=>({metadata:this.#t,injectedSlices:[...this.#n].map(i=>({name:typeof i=="string"?i:i.name,value:this.#l(i)})),consumedSlices:[...this.#o].map(i=>({name:typeof i=="string"?i:i.name,value:this.#l(i)})),recordedTimers:[...this.#s].map(([i,{duration:s}])=>({name:i.name,duration:s,status:this.#a(i)})),waitTimers:[...this.#i].map(([i,{duration:s}])=>({name:i.name,duration:s,status:this.#a(i)}))}),this.onRecord=i=>{this.#s.set(i,{start:Date.now(),duration:0})},this.onClear=i=>{this.#s.delete(i)},this.onDone=i=>{const s=this.#s.get(i);s&&(s.duration=Date.now()-s.start)},this.onWait=(i,s)=>{const o=Date.now();s.finally(()=>{this.#i.set(i,{duration:Date.now()-o})}).catch(console.error)},this.onInject=i=>{this.#n.add(i)},this.onRemove=i=>{this.#n.delete(i)},this.onUse=i=>{this.#o.add(i)},this.#l=i=>this.#e.get(i).get(),this.#a=i=>this.#r.get(i).status,this.#e=e,this.#r=t,this.#t=r}#t;#e;#r;#n;#o;#s;#i;#l;#a}class cs{constructor(e,t,r){this.produce=i=>i&&Object.keys(i).length?new cs(this.#t,this.#e,{...i}):this,this.inject=(i,s)=>{const o=i.create(this.#t.sliceMap);return s!=null&&o.set(s),this.#n?.onInject(i),this},this.remove=i=>(this.#t.remove(i),this.#n?.onRemove(i),this),this.record=i=>(i.create(this.#e.store),this.#n?.onRecord(i),this),this.clearTimer=i=>(this.#e.remove(i),this.#n?.onClear(i),this),this.isInjected=i=>this.#t.has(i),this.isRecorded=i=>this.#e.has(i),this.use=i=>(this.#n?.onUse(i),this.#t.get(i)),this.get=i=>this.use(i).get(),this.set=(i,s)=>this.use(i).set(s),this.update=(i,s)=>this.use(i).update(s),this.timer=i=>this.#e.get(i),this.done=i=>{this.timer(i).done(),this.#n?.onDone(i)},this.wait=i=>{const s=this.timer(i).start();return this.#n?.onWait(i,s),s},this.waitTimers=async i=>{await Promise.all(this.get(i).map(s=>this.wait(s)))},this.#t=e,this.#e=t,this.#r=r,r&&(this.#n=new Xu(e,t,r))}#t;#e;#r;#n;get meta(){return this.#r}get inspector(){return this.#n}}class Zu{constructor(){this.store=new Map,this.get=e=>{const t=this.store.get(e.id);if(!t)throw Hu(e.name);return t},this.remove=e=>{this.store.delete(e.id)},this.has=e=>this.store.has(e.id)}}class ec{constructor(e,t){this.#t=null,this.#e=null,this.#n="pending",this.start=()=>(this.#t??=new Promise((r,i)=>{this.#e=s=>{s instanceof CustomEvent&&s.detail.id===this.#r&&(this.#n="resolved",this.#o(),s.stopImmediatePropagation(),r())},this.#s(()=>{this.#n==="pending"&&(this.#n="rejected"),this.#o(),i(new Error(`Timing ${this.type.name} timeout.`))}),this.#n="pending",addEventListener(this.type.name,this.#e)}),this.#t),this.done=()=>{const r=new CustomEvent(this.type.name,{detail:{id:this.#r}});dispatchEvent(r)},this.#o=()=>{this.#e&&removeEventListener(this.type.name,this.#e)},this.#s=r=>{setTimeout(()=>{r()},this.type.timeout)},this.#r=Symbol(t.name),this.type=t,e.set(t.id,this)}#t;#e;#r;#n;get status(){return this.#n}#o;#s}class tc{constructor(e,t=3e3){this.create=r=>new ec(r,this),this.id=Symbol(`Timer-${e}`),this.name=e,this.timeout=t}}const We=(n,e=3e3)=>new tc(n,e);function re(n){this.content=n}re.prototype={constructor:re,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,i=r.find(n),s=r.content.slice();return i==-1?s.push(t||n,e):(s[i+1]=e,t&&(s[i]=t)),new re(s)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new re(t)},addToStart:function(n,e){return new re([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new re(t)},addBefore:function(n,e,t){var r=this.remove(e),i=r.content.slice(),s=r.find(n);return i.splice(s==-1?i.length:s,0,e,t),new re(i)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=re.from(n),n.size?new re(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=re.from(n),n.size?new re(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=re.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}};re.from=function(n){if(n instanceof re)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new re(e)};function wl(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let i=n.child(r),s=e.child(r);if(i==s){t+=i.nodeSize;continue}if(!i.sameMarkup(s))return t;if(i.isText&&i.text!=s.text){for(let o=0;i.text[o]==s.text[o];o++)t++;return t}if(i.content.size||s.content.size){let o=wl(i.content,s.content,t+1);if(o!=null)return o}t+=i.nodeSize}}function Cl(n,e,t,r){for(let i=n.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:t,b:r};let o=n.child(--i),l=e.child(--s),a=o.nodeSize;if(o==l){t-=a,r-=a;continue}if(!o.sameMarkup(l))return{a:t,b:r};if(o.isText&&o.text!=l.text){let u=0,c=Math.min(o.text.length,l.text.length);for(;u<c&&o.text[o.text.length-u-1]==l.text[l.text.length-u-1];)u++,t--,r--;return{a:t,b:r}}if(o.content.size||l.content.size){let u=Cl(o.content,l.content,t-1,r-1);if(u)return u}t-=a,r-=a}}class T{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,i=0,s){for(let o=0,l=0;l<t;o++){let a=this.content[o],u=l+a.nodeSize;if(u>e&&r(a,i+l,s||null,o)!==!1&&a.content.size){let c=l+1;a.nodesBetween(Math.max(0,e-c),Math.min(a.content.size,t-c),r,i+c)}l=u}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,i){let s="",o=!0;return this.nodesBetween(e,t,(l,a)=>{let u=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&u||l.isTextblock)&&r&&(o?o=!1:s+=r),s+=u},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,i=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(r)&&(i[i.length-1]=t.withText(t.text+r.text),s=1);s<e.content.length;s++)i.push(e.content[s]);return new T(i,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],i=0;if(t>e)for(let s=0,o=0;o<t;s++){let l=this.content[s],a=o+l.nodeSize;a>e&&((o<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,t-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,t-o-1))),r.push(l),i+=l.nodeSize),o=a}return new T(r,i)}cutByIndex(e,t){return e==t?T.empty:e==0&&t==this.content.length?this:new T(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let i=this.content.slice(),s=this.size+t.nodeSize-r.nodeSize;return i[e]=t,new T(i,s)}addToStart(e){return new T([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new T(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let i=this.content[t];e(i,r,t),r+=i.nodeSize}}findDiffStart(e,t=0){return wl(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return Cl(this,e,t,r)}findIndex(e){if(e==0)return Ln(0,e);if(e==this.size)return Ln(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,r=0;;t++){let i=this.child(t),s=r+i.nodeSize;if(s>=e)return s==e?Ln(t+1,s):Ln(t,r);r=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,t){if(!t)return T.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new T(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return T.empty;let t,r=0;for(let i=0;i<e.length;i++){let s=e[i];r+=s.nodeSize,i&&s.isText&&e[i-1].sameMarkup(s)?(t||(t=e.slice(0,i)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new T(t||e,r)}static from(e){if(!e)return T.empty;if(e instanceof T)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new T([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}T.empty=new T([],0);const Fr={index:0,offset:0};function Ln(n,e){return Fr.index=n,Fr.offset=e,Fr}function cr(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!cr(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!cr(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}class L{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let i=0;i<e.length;i++){let s=e[i];if(this.eq(s))return e;if(this.type.excludes(s.type))t||(t=e.slice(0,i));else{if(s.type.excludes(this.type))return e;!r&&s.type.rank>this.type.rank&&(t||(t=e.slice(0,i)),t.push(this),r=!0),t&&t.push(s)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&cr(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);let i=r.create(t.attrs);return r.checkAttrs(i.attrs),i}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return L.none;if(e instanceof L)return[e];let t=e.slice();return t.sort((r,i)=>r.type.rank-i.type.rank),t}}L.none=[];class hr extends Error{}class M{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=Ml(this.content,e+this.openStart,t);return r&&new M(r,this.openStart,this.openEnd)}removeBetween(e,t){return new M(Tl(this.content,e+this.openStart,t+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,t){if(!t)return M.empty;let r=t.openStart||0,i=t.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new M(T.fromJSON(e,t.content),r,i)}static maxOpen(e,t=!0){let r=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)i++;return new M(e,r,i)}}M.empty=new M(T.empty,0,0);function Tl(n,e,t){let{index:r,offset:i}=n.findIndex(e),s=n.maybeChild(r),{index:o,offset:l}=n.findIndex(t);if(i==e||s.isText){if(l!=t&&!n.child(o).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=o)throw new RangeError("Removing non-flat range");return n.replaceChild(r,s.copy(Tl(s.content,e-i-1,t-i-1)))}function Ml(n,e,t,r){let{index:i,offset:s}=n.findIndex(e),o=n.maybeChild(i);if(s==e||o.isText)return r&&!r.canReplace(i,i,t)?null:n.cut(0,e).append(t).append(n.cut(e));let l=Ml(o.content,e-s-1,t,o);return l&&n.replaceChild(i,o.copy(l))}function nc(n,e,t){if(t.openStart>n.depth)throw new hr("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new hr("Inconsistent open depths");return Nl(n,e,t,0)}function Nl(n,e,t,r){let i=n.index(r),s=n.node(r);if(i==e.index(r)&&r<n.depth-t.openStart){let o=Nl(n,e,t,r+1);return s.copy(s.content.replaceChild(i,o))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let o=n.parent,l=o.content;return Nt(o,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=rc(t,n);return Nt(s,El(n,o,l,e,r))}else return Nt(s,fr(n,e,r))}function Ol(n,e){if(!e.type.compatibleContent(n.type))throw new hr("Cannot join "+e.type.name+" onto "+n.type.name)}function Mi(n,e,t){let r=n.node(t);return Ol(r,e.node(t)),r}function Mt(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function xn(n,e,t,r){let i=(e||n).node(t),s=0,o=e?e.index(t):i.childCount;n&&(s=n.index(t),n.depth>t?s++:n.textOffset&&(Mt(n.nodeAfter,r),s++));for(let l=s;l<o;l++)Mt(i.child(l),r);e&&e.depth==t&&e.textOffset&&Mt(e.nodeBefore,r)}function Nt(n,e){return n.type.checkContent(e),n.copy(e)}function El(n,e,t,r,i){let s=n.depth>i&&Mi(n,e,i+1),o=r.depth>i&&Mi(t,r,i+1),l=[];return xn(null,n,i,l),s&&o&&e.index(i)==t.index(i)?(Ol(s,o),Mt(Nt(s,El(n,e,t,r,i+1)),l)):(s&&Mt(Nt(s,fr(n,e,i+1)),l),xn(e,t,i,l),o&&Mt(Nt(o,fr(t,r,i+1)),l)),xn(r,null,i,l),new T(l)}function fr(n,e,t){let r=[];if(xn(null,n,t,r),n.depth>t){let i=Mi(n,e,t+1);Mt(Nt(i,fr(n,e,t+1)),r)}return xn(e,null,t,r),new T(r)}function rc(n,e){let t=e.depth-n.openStart,i=e.node(t).copy(n.content);for(let s=t-1;s>=0;s--)i=e.node(s).copy(T.from(i));return{start:i.resolveNoCache(n.openStart+t),end:i.resolveNoCache(i.content.size-n.openEnd-t)}}class Nn{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.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,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(t);return r?e.child(t).cut(r):i}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],i=t==0?0:this.path[t*3-1]+1;for(let s=0;s<e;s++)i+=r.child(s).nodeSize;return i}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return L.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),i=e.maybeChild(t);if(!r){let l=r;r=i,i=l}let s=r.marks;for(var o=0;o<s.length;o++)s[o].type.spec.inclusive===!1&&(!i||!s[o].isInSet(i.marks))&&(s=s[o--].removeFromSet(s));return s}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,i=e.parent.maybeChild(e.index());for(var s=0;s<r.length;s++)r[s].type.spec.inclusive===!1&&(!i||!r[s].isInSet(i.marks))&&(r=r[s--].removeFromSet(r));return r}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new oc(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<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],i=0,s=t;for(let o=e;;){let{index:l,offset:a}=o.content.findIndex(s),u=s-a;if(r.push(o,l,i+a),!u||(o=o.child(l),o.isText))break;s=u-1,i+=a+1}return new Nn(t,r,s)}static resolveCached(e,t){let r=js.get(e);if(r)for(let s=0;s<r.elts.length;s++){let o=r.elts[s];if(o.pos==t)return o}else js.set(e,r=new ic);let i=r.elts[r.i]=Nn.resolve(e,t);return r.i=(r.i+1)%sc,i}}class ic{constructor(){this.elts=[],this.i=0}}const sc=12,js=new WeakMap;class oc{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const lc=Object.create(null);class Pe{constructor(e,t,r,i=L.none){this.type=e,this.attrs=t,this.marks=i,this.content=r||T.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,r,i=0){this.content.nodesBetween(e,t,r,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,r,i){return this.content.textBetween(e,t,r,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,r){return this.type==e&&cr(this.attrs,t||e.defaultAttrs||lc)&&L.sameSet(this.marks,r||L.none)}copy(e=null){return e==this.content?this:new Pe(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Pe(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,r=!1){if(e==t)return M.empty;let i=this.resolve(e),s=this.resolve(t),o=r?0:i.sharedDepth(t),l=i.start(o),u=i.node(o).content.cut(i.pos-l,s.pos-l);return new M(u,i.depth-o,s.depth-o)}replace(e,t,r){return nc(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:i}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(i==e||t.isText)return t;e-=i+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let i=this.content.child(t-1);return{node:i,index:t-1,offset:r-i.nodeSize}}resolve(e){return Nn.resolveCached(this,e)}resolveNoCache(e){return Nn.resolve(this,e)}rangeHasMark(e,t,r){let i=!1;return t>e&&this.nodesBetween(e,t,s=>(r.isInSet(s.marks)&&(i=!0),!i)),i}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()+")"),Il(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=T.empty,i=0,s=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,i,s),l=o&&o.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=i;a<s;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,t,r,i){if(i&&!this.type.allowsMarks(i))return!1;let s=this.contentMatchAt(e).matchType(r),o=s&&s.matchFragment(this.content,t);return o?o.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=L.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!L.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t 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(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let i=T.fromJSON(e,t.content),s=e.nodeType(t.type).create(t.attrs,i,r);return s.type.checkAttrs(s.attrs),s}}Pe.prototype.text=void 0;class dr extends Pe{constructor(e,t,r,i){if(super(e,t,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Il(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new dr(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new dr(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function Il(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class At{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new ac(e,t);if(r.next==null)return At.empty;let i=Al(r);r.next&&r.err("Unexpected trailing text");let s=mc(pc(i));return gc(s,r),s}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,r=e.childCount){let i=this;for(let s=t;i&&s<r;s++)i=i.matchType(e.child(s).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let i=[this];function s(o,l){let a=o.matchFragment(e,r);if(a&&(!t||a.validEnd))return T.from(l.map(u=>u.createAndFill()));for(let u=0;u<o.next.length;u++){let{type:c,next:h}=o.next[u];if(!(c.isText||c.hasRequiredAttrs())&&i.indexOf(h)==-1){i.push(h);let d=s(h,l.concat(c));if(d)return d}}return null}return s(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),s=i.match;if(s.matchType(e)){let o=[];for(let l=i;l.type;l=l.via)o.push(l.type);return o.reverse()}for(let o=0;o<s.next.length;o++){let{type:l,next:a}=s.next[o];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!i.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:i}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&t(r.next[i].next)}return t(this),e.map((r,i)=>{let s=i+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)s+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return s}).join(`
3
- `)}}At.empty=new At(!0);class ac{constructor(e,t){this.string=e,this.nodeTypes=t,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 Al(n){let e=[];do e.push(uc(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function uc(n){let e=[];do e.push(cc(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function cc(n){let e=dc(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=hc(n,e);else break;return e}function Js(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function hc(n,e){let t=Js(n),r=t;return n.eat(",")&&(n.next!="}"?r=Js(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function fc(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let i=[];for(let s in t){let o=t[s];o.isInGroup(e)&&i.push(o)}return i.length==0&&n.err("No node type or group '"+e+"' found"),i}function dc(n){if(n.eat("(")){let e=Al(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=fc(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function pc(n){let e=[[]];return i(s(n,0),t()),e;function t(){return e.push([])-1}function r(o,l,a){let u={term:a,to:l};return e[o].push(u),u}function i(o,l){o.forEach(a=>a.to=l)}function s(o,l){if(o.type=="choice")return o.exprs.reduce((a,u)=>a.concat(s(u,l)),[]);if(o.type=="seq")for(let a=0;;a++){let u=s(o.exprs[a],l);if(a==o.exprs.length-1)return u;i(u,l=t())}else if(o.type=="star"){let a=t();return r(l,a),i(s(o.expr,a),a),[r(a)]}else if(o.type=="plus"){let a=t();return i(s(o.expr,l),a),i(s(o.expr,a),a),[r(a)]}else{if(o.type=="opt")return[r(l)].concat(s(o.expr,l));if(o.type=="range"){let a=l;for(let u=0;u<o.min;u++){let c=t();i(s(o.expr,a),c),a=c}if(o.max==-1)i(s(o.expr,a),a);else for(let u=o.min;u<o.max;u++){let c=t();r(a,c),i(s(o.expr,a),c),a=c}return[r(a)]}else{if(o.type=="name")return[r(l,void 0,o.value)];throw new Error("Unknown expr type")}}}}function Dl(n,e){return e-n}function Hs(n,e){let t=[];return r(e),t.sort(Dl);function r(i){let s=n[i];if(s.length==1&&!s[0].term)return r(s[0].to);t.push(i);for(let o=0;o<s.length;o++){let{term:l,to:a}=s[o];!l&&t.indexOf(a)==-1&&r(a)}}}function mc(n){let e=Object.create(null);return t(Hs(n,0));function t(r){let i=[];r.forEach(o=>{n[o].forEach(({term:l,to:a})=>{if(!l)return;let u;for(let c=0;c<i.length;c++)i[c][0]==l&&(u=i[c][1]);Hs(n,a).forEach(c=>{u||i.push([l,u=[]]),u.indexOf(c)==-1&&u.push(c)})})});let s=e[r.join(",")]=new At(r.indexOf(n.length-1)>-1);for(let o=0;o<i.length;o++){let l=i[o][1].sort(Dl);s.next.push({type:i[o][0],next:e[l.join(",")]||t(l)})}return s}}function gc(n,e){for(let t=0,r=[n];t<r.length;t++){let i=r[t],s=!i.validEnd,o=[];for(let l=0;l<i.next.length;l++){let{type:a,next:u}=i.next[l];o.push(a.name),s&&!(a.isText||a.hasRequiredAttrs())&&(s=!1),r.indexOf(u)==-1&&r.push(u)}s&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Rl(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function zl(n,e){let t=Object.create(null);for(let r in n){let i=e&&e[r];if(i===void 0){let s=n[r];if(s.hasDefault)i=s.default;else throw new RangeError("No value supplied for attribute "+r)}t[r]=i}return t}function Pl(n,e,t,r){for(let i in e)if(!(i in n))throw new RangeError(`Unsupported attribute ${i} for ${t} of type ${i}`);for(let i in n){let s=n[i];s.validate&&s.validate(e[i])}}function Fl(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new kc(n,r,e[r]);return t}let Ks=class Bl{constructor(e,t,r){this.name=e,this.schema=t,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=Fl(e,r.attrs),this.defaultAttrs=Rl(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==At.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:zl(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Pe(this,this.computeAttrs(e),T.from(t),L.setFrom(r))}createChecked(e=null,t,r){return t=T.from(t),this.checkContent(t),new Pe(this,this.computeAttrs(e),t,L.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=T.from(t),t.size){let o=this.contentMatch.fillBefore(t);if(!o)return null;t=o.append(t)}let i=this.contentMatch.matchFragment(t),s=i&&i.fillBefore(T.empty,!0);return s?new Pe(this,e,t.append(s),L.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){Pl(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?t&&t.push(e[r]):t||(t=e.slice(0,r));return t?t.length?t:L.none:e}static compile(e,t){let r=Object.create(null);e.forEach((s,o)=>r[s]=new Bl(s,t,o));let i=t.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let s in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function yc(n,e,t){let r=t.split("|");return i=>{let s=i===null?"null":typeof i;if(r.indexOf(s)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${s}`)}}class kc{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?yc(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Mr{constructor(e,t,r,i){this.name=e,this.rank=t,this.schema=r,this.spec=i,this.attrs=Fl(e,i.attrs),this.excluded=null;let s=Rl(this.attrs);this.instance=s?new L(this,s):null}create(e=null){return!e&&this.instance?this.instance:new L(this,zl(this.attrs,e))}static compile(e,t){let r=Object.create(null),i=0;return e.forEach((s,o)=>r[s]=new Mr(s,i++,t,o)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){Pl(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class xc{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let i in e)t[i]=e[i];t.nodes=re.from(e.nodes),t.marks=re.from(e.marks||{}),this.nodes=Ks.compile(this.spec.nodes,this),this.marks=Mr.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let s=this.nodes[i],o=s.spec.content||"",l=s.spec.marks;if(s.contentMatch=r[o]||(r[o]=At.parse(o,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=l=="_"?null:l?Us(this,l.split(" ")):l==""||!s.inlineContent?[]:null}for(let i in this.marks){let s=this.marks[i],o=s.spec.excludes;s.excluded=o==null?[s]:o==""?[]:Us(this,o.split(" "))}this.nodeFromJSON=i=>Pe.fromJSON(this,i),this.markFromJSON=i=>L.fromJSON(this,i),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Ks){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(t,r,i)}text(e,t){let r=this.nodes.text;return new dr(r,r.defaultAttrs,e,L.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function Us(n,e){let t=[];for(let r=0;r<e.length;r++){let i=e[r],s=n.marks[i],o=s;if(s)t.push(s);else for(let l in n.marks){let a=n.marks[l];(i=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(i)>-1)&&t.push(o=a)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function bc(n){return n.tag!=null}function Sc(n){return n.style!=null}class Yt{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(i=>{if(bc(i))this.tags.push(i);else if(Sc(i)){let s=/[^=]*/.exec(i.style)[0];r.indexOf(s)<0&&r.push(s),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let s=e.nodes[i.node];return s.contentMatch.matchType(s)})}parse(e,t={}){let r=new Qs(this,t,!1);return r.addAll(e,L.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new Qs(this,t,!0);return r.addAll(e,L.none,t.from,t.to),M.maxOpen(r.finish())}matchTag(e,t,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let s=this.tags[i];if(Tc(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||t.matchesContext(s.context))){if(s.getAttrs){let o=s.getAttrs(e);if(o===!1)continue;s.attrs=o||void 0}return s}}}matchStyle(e,t,r,i){for(let s=i?this.styles.indexOf(i)+1:0;s<this.styles.length;s++){let o=this.styles[s],l=o.style;if(!(l.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(o.getAttrs){let a=o.getAttrs(t);if(a===!1)continue;o.attrs=a||void 0}return o}}}static schemaRules(e){let t=[];function r(i){let s=i.priority==null?50:i.priority,o=0;for(;o<t.length;o++){let l=t[o];if((l.priority==null?50:l.priority)<s)break}t.splice(o,0,i)}for(let i in e.marks){let s=e.marks[i].spec.parseDOM;s&&s.forEach(o=>{r(o=Gs(o)),o.mark||o.ignore||o.clearMark||(o.mark=i)})}for(let i in e.nodes){let s=e.nodes[i].spec.parseDOM;s&&s.forEach(o=>{r(o=Gs(o)),o.node||o.ignore||o.mark||(o.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Yt(e,Yt.schemaRules(e)))}}const vl={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},wc={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Ll={ol:!0,ul:!0},On=1,Ni=2,bn=4;function Ys(n,e,t){return e!=null?(e?On:0)|(e==="full"?Ni:0):n&&n.whitespace=="pre"?On|Ni:t&~bn}class Vn{constructor(e,t,r,i,s,o){this.type=e,this.attrs=t,this.marks=r,this.solid=i,this.options=o,this.content=[],this.activeMarks=L.none,this.match=s||(o&bn?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(T.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&On)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let s=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-i[0].length))}}let t=T.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(T.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!vl.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Qs{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=t.topNode,s,o=Ys(null,t.preserveWhitespace,0)|(r?bn:0);i?s=new Vn(i.type,i.attrs,L.none,!0,t.topMatch||i.type.contentMatch,o):r?s=new Vn(null,null,L.none,!0,null,o):s=new Vn(e.schema.topNodeType,null,L.none,!0,null,o),this.nodes=[s],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let r=e.nodeValue,i=this.top,s=i.options&Ni?"full":this.localPreserveWS||(i.options&On)>0,{schema:o}=this.parser;if(s==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(s)if(s==="full")r=r.replace(/\r\n?/g,`
4
- `);else if(o.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(o.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(o.linebreakReplacement.create(),t,!0),l[a]&&this.insertNode(o.text(l[a]),t,!/\S/.test(l[a]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let l=i.content[i.content.length-1],a=e.previousSibling;(!l||a&&a.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(o.text(r),t,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,t,r){let i=this.localPreserveWS,s=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),l;Ll.hasOwnProperty(o)&&this.parser.normalizeLists&&Cc(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:wc.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let u,c=this.needsBlock;if(vl.hasOwnProperty(o))s.content.length&&s.content[0].isInline&&this.open&&(this.open--,s=this.top),u=!0,s.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let h=a&&a.skip?t:this.readStyles(e,t);h&&this.addAll(e,h),u&&this.sync(s),this.needsBlock=c}else{let u=this.readStyles(e,t);u&&this.addElementByRule(e,a,u,a.consuming===!1?l:void 0)}this.localPreserveWS=i}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
5
- `),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let r=e.style;if(r&&r.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let s=this.parser.matchedStyles[i],o=r.getPropertyValue(s);if(o)for(let l=void 0;;){let a=this.parser.matchStyle(s,o,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(u=>!a.clearMark(u)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,r,i){let s,o;if(t.node)if(o=this.parser.schema.nodes[t.node],o.isLeaf)this.insertNode(o.create(t.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(o,t.attrs||null,r,t.preserveWhitespace);a&&(s=!0,r=a)}else{let a=this.parser.schema.marks[t.mark];r=r.concat(a.create(t.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}s&&this.sync(l)&&this.open--}addAll(e,t,r,i){let s=r||0;for(let o=r?e.childNodes[r]:e.firstChild,l=i==null?null:e.childNodes[i];o!=l;o=o.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(o,t);this.findAtPoint(e,s)}findPlace(e,t,r){let i,s;for(let o=this.open,l=0;o>=0;o--){let a=this.nodes[o],u=a.findWrapping(e);if(u&&(!i||i.length>u.length+l)&&(i=u,s=a,!u.length))break;if(a.solid){if(r)break;l+=2}}if(!i)return null;this.sync(s);for(let o=0;o<i.length;o++)t=this.enterInner(i[o],null,t,!1);return t}insertNode(e,t,r){if(e.isInline&&this.needsBlock&&!this.top.type){let s=this.textblockFromContext();s&&(t=this.enterInner(s,null,t))}let i=this.findPlace(e,t,r);if(i){this.closeExtra();let s=this.top;s.match&&(s.match=s.match.matchType(e.type));let o=L.none;for(let l of i.concat(e.marks))(s.type?s.type.allowsMarkType(l.type):Xs(l.type,e.type))&&(o=l.addToSet(o));return s.content.push(e.mark(o)),!0}return!1}enter(e,t,r,i){let s=this.findPlace(e.create(t),r,!1);return s&&(s=this.enterInner(e,t,r,!0,i)),s}enterInner(e,t,r,i=!1,s){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=Ys(e,s,o.options);o.options&bn&&o.content.length==0&&(l|=bn);let a=L.none;return r=r.filter(u=>(o.type?o.type.allowsMarkType(u.type):Xs(u.type,e))?(a=u.addToSet(a),!1):!0),this.nodes.push(new Vn(e,t,a,i,null,l)),this.open++,r}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].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 t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=On)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,r){if(e!=t&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&t.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),s=-(r?r.depth+1:0)+(i?0:1),o=(l,a)=>{for(;l>=0;l--){let u=t[l];if(u==""){if(l==t.length-1||l==0)continue;for(;a>=s;a--)if(o(l-1,a))return!0;return!1}else{let c=a>0||a==0&&i?this.nodes[a].type:r&&a>=s?r.node(a-s).type:null;if(!c||c.name!=u&&!c.isInGroup(u))return!1;a--}}return!0};return o(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}}function Cc(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Ll.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function Tc(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function Gs(n){let e={};for(let t in n)e[t]=n[t];return e}function Xs(n,e){let t=e.schema.nodes;for(let r in t){let i=t[r];if(!i.allowsMarkType(n))continue;let s=[],o=l=>{s.push(l);for(let a=0;a<l.edgeCount;a++){let{type:u,next:c}=l.edge(a);if(u==e||s.indexOf(c)<0&&o(c))return!0}};if(o(i.contentMatch))return!0}}class en{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=Br(t).createDocumentFragment());let i=r,s=[];return e.forEach(o=>{if(s.length||o.marks.length){let l=0,a=0;for(;l<s.length&&a<o.marks.length;){let u=o.marks[a];if(!this.marks[u.type.name]){a++;continue}if(!u.eq(s[l][0])||u.type.spec.spanning===!1)break;l++,a++}for(;l<s.length;)i=s.pop()[1];for(;a<o.marks.length;){let u=o.marks[a++],c=this.serializeMark(u,o.isInline,t);c&&(s.push([u,i]),i.appendChild(c.dom),i=c.contentDOM||c.dom)}}i.appendChild(this.serializeNodeInner(o,t))}),r}serializeNodeInner(e,t){let{dom:r,contentDOM:i}=qn(Br(t),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,i)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let i=e.marks.length-1;i>=0;i--){let s=this.serializeMark(e.marks[i],e.isInline,t);s&&((s.contentDOM||s.dom).appendChild(r),r=s.dom)}return r}serializeMark(e,t,r={}){let i=this.marks[e.type.name];return i&&qn(Br(r),i(e,t),null,e.attrs)}static renderSpec(e,t,r=null,i){return qn(e,t,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new en(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Zs(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return Zs(e.marks)}}function Zs(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function Br(n){return n.document||window.document}const eo=new WeakMap;function Mc(n){let e=eo.get(n);return e===void 0&&eo.set(n,e=Nc(n)),e}function Nc(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let i=0;i<r.length;i++)t(r[i]);else for(let i in r)t(r[i])}return t(n),e}function qn(n,e,t,r){if(typeof e=="string")return{dom:n.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let i=e[0],s;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(s=Mc(r))&&s.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=i.indexOf(" ");o>0&&(t=i.slice(0,o),i=i.slice(o+1));let l,a=t?n.createElementNS(t,i):n.createElement(i),u=e[1],c=1;if(u&&typeof u=="object"&&u.nodeType==null&&!Array.isArray(u)){c=2;for(let h in u)if(u[h]!=null){let d=h.indexOf(" ");d>0?a.setAttributeNS(h.slice(0,d),h.slice(d+1),u[h]):h=="style"&&a.style?a.style.cssText=u[h]:a.setAttribute(h,u[h])}}for(let h=c;h<e.length;h++){let d=e[h];if(d===0){if(h<e.length-1||h>c)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:f,contentDOM:p}=qn(n,d,t,r);if(a.appendChild(f),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}const Oc={};function hs(n,e){const t=Oc,r=typeof t.includeImageAlt=="boolean"?t.includeImageAlt:!0,i=typeof t.includeHtml=="boolean"?t.includeHtml:!0;return Vl(n,r,i)}function Vl(n,e,t){if(Ec(n)){if("value"in n)return n.type==="html"&&!t?"":n.value;if(e&&"alt"in n&&n.alt)return n.alt;if("children"in n)return to(n.children,e,t)}return Array.isArray(n)?to(n,e,t):""}function to(n,e,t){const r=[];let i=-1;for(;++i<n.length;)r[i]=Vl(n[i],e,t);return r.join("")}function Ec(n){return!!(n&&typeof n=="object")}const no=document.createElement("i");function fs(n){const e="&"+n+";";no.innerHTML=e;const t=no.textContent;return t.charCodeAt(t.length-1)===59&&n!=="semi"||t===e?!1:t}function _e(n,e,t,r){const i=n.length;let s=0,o;if(e<0?e=-e>i?0:i+e:e=e>i?i:e,t=t>0?t:0,r.length<1e4)o=Array.from(r),o.unshift(e,t),n.splice(...o);else for(t&&n.splice(e,t);s<r.length;)o=r.slice(s,s+1e4),o.unshift(e,0),n.splice(...o),s+=1e4,e+=1e4}function Ce(n,e){return n.length>0?(_e(n,n.length,0,e),n):e}const ro={}.hasOwnProperty;function Ic(n){const e={};let t=-1;for(;++t<n.length;)Ac(e,n[t]);return e}function Ac(n,e){let t;for(t in e){const i=(ro.call(n,t)?n[t]:void 0)||(n[t]={}),s=e[t];let o;if(s)for(o in s){ro.call(i,o)||(i[o]=[]);const l=s[o];Dc(i[o],Array.isArray(l)?l:l?[l]:[])}}}function Dc(n,e){let t=-1;const r=[];for(;++t<e.length;)(e[t].add==="after"?n:r).push(e[t]);_e(n,0,0,r)}function _l(n,e){const t=Number.parseInt(n,e);return t<9||t===11||t>13&&t<32||t>126&&t<160||t>55295&&t<57344||t>64975&&t<65008||(t&65535)===65535||(t&65535)===65534||t>1114111?"�":String.fromCodePoint(t)}function jt(n){return n.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Le=gt(/[A-Za-z]/),Re=gt(/[\dA-Za-z]/),Rc=gt(/[#-'*+\--9=?A-Z^-~]/);function Oi(n){return n!==null&&(n<32||n===127)}const Ei=gt(/\d/),zc=gt(/[\dA-Fa-f]/),Pc=gt(/[!-/:-@[-`{-~]/);function A(n){return n!==null&&n<-2}function pe(n){return n!==null&&(n<0||n===32)}function q(n){return n===-2||n===-1||n===32}const Fc=gt(new RegExp("\\p{P}|\\p{S}","u")),Bc=gt(/\s/);function gt(n){return e;function e(t){return t!==null&&t>-1&&n.test(String.fromCharCode(t))}}function K(n,e,t,r){const i=r?r-1:Number.POSITIVE_INFINITY;let s=0;return o;function o(a){return q(a)?(n.enter(t),l(a)):e(a)}function l(a){return q(a)&&s++<i?(n.consume(a),l):(n.exit(t),e(a))}}const vc={tokenize:Lc};function Lc(n){const e=n.attempt(this.parser.constructs.contentInitial,r,i);let t;return e;function r(l){if(l===null){n.consume(l);return}return n.enter("lineEnding"),n.consume(l),n.exit("lineEnding"),K(n,e,"linePrefix")}function i(l){return n.enter("paragraph"),s(l)}function s(l){const a=n.enter("chunkText",{contentType:"text",previous:t});return t&&(t.next=a),t=a,o(l)}function o(l){if(l===null){n.exit("chunkText"),n.exit("paragraph"),n.consume(l);return}return A(l)?(n.consume(l),n.exit("chunkText"),s):(n.consume(l),o)}}const Vc={tokenize:_c},io={tokenize:$c};function _c(n){const e=this,t=[];let r=0,i,s,o;return l;function l(C){if(r<t.length){const B=t[r];return e.containerState=B[1],n.attempt(B[0].continuation,a,u)(C)}return u(C)}function a(C){if(r++,e.containerState._closeFlow){e.containerState._closeFlow=void 0,i&&I();const B=e.events.length;let $=B,S;for(;$--;)if(e.events[$][0]==="exit"&&e.events[$][1].type==="chunkFlow"){S=e.events[$][1].end;break}k(r);let N=B;for(;N<e.events.length;)e.events[N][1].end={...S},N++;return _e(e.events,$+1,0,e.events.slice(B)),e.events.length=N,u(C)}return l(C)}function u(C){if(r===t.length){if(!i)return d(C);if(i.currentConstruct&&i.currentConstruct.concrete)return p(C);e.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return e.containerState={},n.check(io,c,h)(C)}function c(C){return i&&I(),k(r),d(C)}function h(C){return e.parser.lazy[e.now().line]=r!==t.length,o=e.now().offset,p(C)}function d(C){return e.containerState={},n.attempt(io,f,p)(C)}function f(C){return r++,t.push([e.currentConstruct,e.containerState]),d(C)}function p(C){if(C===null){i&&I(),k(0),n.consume(C);return}return i=i||e.parser.flow(e.now()),n.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:s}),y(C)}function y(C){if(C===null){x(n.exit("chunkFlow"),!0),k(0),n.consume(C);return}return A(C)?(n.consume(C),x(n.exit("chunkFlow")),r=0,e.interrupt=void 0,l):(n.consume(C),y)}function x(C,B){const $=e.sliceStream(C);if(B&&$.push(null),C.previous=s,s&&(s.next=C),s=C,i.defineSkip(C.start),i.write($),e.parser.lazy[C.start.line]){let S=i.events.length;for(;S--;)if(i.events[S][1].start.offset<o&&(!i.events[S][1].end||i.events[S][1].end.offset>o))return;const N=e.events.length;let P=N,z,J;for(;P--;)if(e.events[P][0]==="exit"&&e.events[P][1].type==="chunkFlow"){if(z){J=e.events[P][1].end;break}z=!0}for(k(r),S=N;S<e.events.length;)e.events[S][1].end={...J},S++;_e(e.events,P+1,0,e.events.slice(N)),e.events.length=S}}function k(C){let B=t.length;for(;B-- >C;){const $=t[B];e.containerState=$[1],$[0].exit.call(e,n)}t.length=C}function I(){i.write([null]),s=void 0,i=void 0,e.containerState._closeFlow=void 0}}function $c(n,e,t){return K(n,n.attempt(this.parser.constructs.document,e,t),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function pr(n){if(n===null||pe(n)||Bc(n))return 1;if(Fc(n))return 2}function ds(n,e,t){const r=[];let i=-1;for(;++i<n.length;){const s=n[i].resolveAll;s&&!r.includes(s)&&(e=s(e,t),r.push(s))}return e}const Ii={name:"attention",resolveAll:qc,tokenize:Wc};function qc(n,e){let t=-1,r,i,s,o,l,a,u,c;for(;++t<n.length;)if(n[t][0]==="enter"&&n[t][1].type==="attentionSequence"&&n[t][1]._close){for(r=t;r--;)if(n[r][0]==="exit"&&n[r][1].type==="attentionSequence"&&n[r][1]._open&&e.sliceSerialize(n[r][1]).charCodeAt(0)===e.sliceSerialize(n[t][1]).charCodeAt(0)){if((n[r][1]._close||n[t][1]._open)&&(n[t][1].end.offset-n[t][1].start.offset)%3&&!((n[r][1].end.offset-n[r][1].start.offset+n[t][1].end.offset-n[t][1].start.offset)%3))continue;a=n[r][1].end.offset-n[r][1].start.offset>1&&n[t][1].end.offset-n[t][1].start.offset>1?2:1;const h={...n[r][1].end},d={...n[t][1].start};so(h,-a),so(d,a),o={type:a>1?"strongSequence":"emphasisSequence",start:h,end:{...n[r][1].end}},l={type:a>1?"strongSequence":"emphasisSequence",start:{...n[t][1].start},end:d},s={type:a>1?"strongText":"emphasisText",start:{...n[r][1].end},end:{...n[t][1].start}},i={type:a>1?"strong":"emphasis",start:{...o.start},end:{...l.end}},n[r][1].end={...o.start},n[t][1].start={...l.end},u=[],n[r][1].end.offset-n[r][1].start.offset&&(u=Ce(u,[["enter",n[r][1],e],["exit",n[r][1],e]])),u=Ce(u,[["enter",i,e],["enter",o,e],["exit",o,e],["enter",s,e]]),u=Ce(u,ds(e.parser.constructs.insideSpan.null,n.slice(r+1,t),e)),u=Ce(u,[["exit",s,e],["enter",l,e],["exit",l,e],["exit",i,e]]),n[t][1].end.offset-n[t][1].start.offset?(c=2,u=Ce(u,[["enter",n[t][1],e],["exit",n[t][1],e]])):c=0,_e(n,r-1,t-r+3,u),t=r+u.length-c-2;break}}for(t=-1;++t<n.length;)n[t][1].type==="attentionSequence"&&(n[t][1].type="data");return n}function Wc(n,e){const t=this.parser.constructs.attentionMarkers.null,r=this.previous,i=pr(r);let s;return o;function o(a){return s=a,n.enter("attentionSequence"),l(a)}function l(a){if(a===s)return n.consume(a),l;const u=n.exit("attentionSequence"),c=pr(a),h=!c||c===2&&i||t.includes(a),d=!i||i===2&&c||t.includes(r);return u._open=!!(s===42?h:h&&(i||!d)),u._close=!!(s===42?d:d&&(c||!h)),e(a)}}function so(n,e){n.column+=e,n.offset+=e,n._bufferIndex+=e}const jc={name:"autolink",tokenize:Jc};function Jc(n,e,t){let r=0;return i;function i(f){return n.enter("autolink"),n.enter("autolinkMarker"),n.consume(f),n.exit("autolinkMarker"),n.enter("autolinkProtocol"),s}function s(f){return Le(f)?(n.consume(f),o):f===64?t(f):u(f)}function o(f){return f===43||f===45||f===46||Re(f)?(r=1,l(f)):u(f)}function l(f){return f===58?(n.consume(f),r=0,a):(f===43||f===45||f===46||Re(f))&&r++<32?(n.consume(f),l):(r=0,u(f))}function a(f){return f===62?(n.exit("autolinkProtocol"),n.enter("autolinkMarker"),n.consume(f),n.exit("autolinkMarker"),n.exit("autolink"),e):f===null||f===32||f===60||Oi(f)?t(f):(n.consume(f),a)}function u(f){return f===64?(n.consume(f),c):Rc(f)?(n.consume(f),u):t(f)}function c(f){return Re(f)?h(f):t(f)}function h(f){return f===46?(n.consume(f),r=0,c):f===62?(n.exit("autolinkProtocol").type="autolinkEmail",n.enter("autolinkMarker"),n.consume(f),n.exit("autolinkMarker"),n.exit("autolink"),e):d(f)}function d(f){if((f===45||Re(f))&&r++<63){const p=f===45?d:h;return n.consume(f),p}return t(f)}}const Nr={partial:!0,tokenize:Hc};function Hc(n,e,t){return r;function r(s){return q(s)?K(n,i,"linePrefix")(s):i(s)}function i(s){return s===null||A(s)?e(s):t(s)}}const $l={continuation:{tokenize:Uc},exit:Yc,name:"blockQuote",tokenize:Kc};function Kc(n,e,t){const r=this;return i;function i(o){if(o===62){const l=r.containerState;return l.open||(n.enter("blockQuote",{_container:!0}),l.open=!0),n.enter("blockQuotePrefix"),n.enter("blockQuoteMarker"),n.consume(o),n.exit("blockQuoteMarker"),s}return t(o)}function s(o){return q(o)?(n.enter("blockQuotePrefixWhitespace"),n.consume(o),n.exit("blockQuotePrefixWhitespace"),n.exit("blockQuotePrefix"),e):(n.exit("blockQuotePrefix"),e(o))}}function Uc(n,e,t){const r=this;return i;function i(o){return q(o)?K(n,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):s(o)}function s(o){return n.attempt($l,e,t)(o)}}function Yc(n){n.exit("blockQuote")}const ql={name:"characterEscape",tokenize:Qc};function Qc(n,e,t){return r;function r(s){return n.enter("characterEscape"),n.enter("escapeMarker"),n.consume(s),n.exit("escapeMarker"),i}function i(s){return Pc(s)?(n.enter("characterEscapeValue"),n.consume(s),n.exit("characterEscapeValue"),n.exit("characterEscape"),e):t(s)}}const Wl={name:"characterReference",tokenize:Gc};function Gc(n,e,t){const r=this;let i=0,s,o;return l;function l(h){return n.enter("characterReference"),n.enter("characterReferenceMarker"),n.consume(h),n.exit("characterReferenceMarker"),a}function a(h){return h===35?(n.enter("characterReferenceMarkerNumeric"),n.consume(h),n.exit("characterReferenceMarkerNumeric"),u):(n.enter("characterReferenceValue"),s=31,o=Re,c(h))}function u(h){return h===88||h===120?(n.enter("characterReferenceMarkerHexadecimal"),n.consume(h),n.exit("characterReferenceMarkerHexadecimal"),n.enter("characterReferenceValue"),s=6,o=zc,c):(n.enter("characterReferenceValue"),s=7,o=Ei,c(h))}function c(h){if(h===59&&i){const d=n.exit("characterReferenceValue");return o===Re&&!fs(r.sliceSerialize(d))?t(h):(n.enter("characterReferenceMarker"),n.consume(h),n.exit("characterReferenceMarker"),n.exit("characterReference"),e)}return o(h)&&i++<s?(n.consume(h),c):t(h)}}const oo={partial:!0,tokenize:Zc},lo={concrete:!0,name:"codeFenced",tokenize:Xc};function Xc(n,e,t){const r=this,i={partial:!0,tokenize:$};let s=0,o=0,l;return a;function a(S){return u(S)}function u(S){const N=r.events[r.events.length-1];return s=N&&N[1].type==="linePrefix"?N[2].sliceSerialize(N[1],!0).length:0,l=S,n.enter("codeFenced"),n.enter("codeFencedFence"),n.enter("codeFencedFenceSequence"),c(S)}function c(S){return S===l?(o++,n.consume(S),c):o<3?t(S):(n.exit("codeFencedFenceSequence"),q(S)?K(n,h,"whitespace")(S):h(S))}function h(S){return S===null||A(S)?(n.exit("codeFencedFence"),r.interrupt?e(S):n.check(oo,y,B)(S)):(n.enter("codeFencedFenceInfo"),n.enter("chunkString",{contentType:"string"}),d(S))}function d(S){return S===null||A(S)?(n.exit("chunkString"),n.exit("codeFencedFenceInfo"),h(S)):q(S)?(n.exit("chunkString"),n.exit("codeFencedFenceInfo"),K(n,f,"whitespace")(S)):S===96&&S===l?t(S):(n.consume(S),d)}function f(S){return S===null||A(S)?h(S):(n.enter("codeFencedFenceMeta"),n.enter("chunkString",{contentType:"string"}),p(S))}function p(S){return S===null||A(S)?(n.exit("chunkString"),n.exit("codeFencedFenceMeta"),h(S)):S===96&&S===l?t(S):(n.consume(S),p)}function y(S){return n.attempt(i,B,x)(S)}function x(S){return n.enter("lineEnding"),n.consume(S),n.exit("lineEnding"),k}function k(S){return s>0&&q(S)?K(n,I,"linePrefix",s+1)(S):I(S)}function I(S){return S===null||A(S)?n.check(oo,y,B)(S):(n.enter("codeFlowValue"),C(S))}function C(S){return S===null||A(S)?(n.exit("codeFlowValue"),I(S)):(n.consume(S),C)}function B(S){return n.exit("codeFenced"),e(S)}function $(S,N,P){let z=0;return J;function J(_){return S.enter("lineEnding"),S.consume(_),S.exit("lineEnding"),E}function E(_){return S.enter("codeFencedFence"),q(_)?K(S,O,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(_):O(_)}function O(_){return _===l?(S.enter("codeFencedFenceSequence"),Y(_)):P(_)}function Y(_){return _===l?(z++,S.consume(_),Y):z>=o?(S.exit("codeFencedFenceSequence"),q(_)?K(S,Q,"whitespace")(_):Q(_)):P(_)}function Q(_){return _===null||A(_)?(S.exit("codeFencedFence"),N(_)):P(_)}}}function Zc(n,e,t){const r=this;return i;function i(o){return o===null?t(o):(n.enter("lineEnding"),n.consume(o),n.exit("lineEnding"),s)}function s(o){return r.parser.lazy[r.now().line]?t(o):e(o)}}const vr={name:"codeIndented",tokenize:th},eh={partial:!0,tokenize:nh};function th(n,e,t){const r=this;return i;function i(u){return n.enter("codeIndented"),K(n,s,"linePrefix",5)(u)}function s(u){const c=r.events[r.events.length-1];return c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?o(u):t(u)}function o(u){return u===null?a(u):A(u)?n.attempt(eh,o,a)(u):(n.enter("codeFlowValue"),l(u))}function l(u){return u===null||A(u)?(n.exit("codeFlowValue"),o(u)):(n.consume(u),l)}function a(u){return n.exit("codeIndented"),e(u)}}function nh(n,e,t){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?t(o):A(o)?(n.enter("lineEnding"),n.consume(o),n.exit("lineEnding"),i):K(n,s,"linePrefix",5)(o)}function s(o){const l=r.events[r.events.length-1];return l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?e(o):A(o)?i(o):t(o)}}const rh={name:"codeText",previous:sh,resolve:ih,tokenize:oh};function ih(n){let e=n.length-4,t=3,r,i;if((n[t][1].type==="lineEnding"||n[t][1].type==="space")&&(n[e][1].type==="lineEnding"||n[e][1].type==="space")){for(r=t;++r<e;)if(n[r][1].type==="codeTextData"){n[t][1].type="codeTextPadding",n[e][1].type="codeTextPadding",t+=2,e-=2;break}}for(r=t-1,e++;++r<=e;)i===void 0?r!==e&&n[r][1].type!=="lineEnding"&&(i=r):(r===e||n[r][1].type==="lineEnding")&&(n[i][1].type="codeTextData",r!==i+2&&(n[i][1].end=n[r-1][1].end,n.splice(i+2,r-i-2),e-=r-i-2,r=i+2),i=void 0);return n}function sh(n){return n!==96||this.events[this.events.length-1][1].type==="characterEscape"}function oh(n,e,t){let r=0,i,s;return o;function o(h){return n.enter("codeText"),n.enter("codeTextSequence"),l(h)}function l(h){return h===96?(n.consume(h),r++,l):(n.exit("codeTextSequence"),a(h))}function a(h){return h===null?t(h):h===32?(n.enter("space"),n.consume(h),n.exit("space"),a):h===96?(s=n.enter("codeTextSequence"),i=0,c(h)):A(h)?(n.enter("lineEnding"),n.consume(h),n.exit("lineEnding"),a):(n.enter("codeTextData"),u(h))}function u(h){return h===null||h===32||h===96||A(h)?(n.exit("codeTextData"),a(h)):(n.consume(h),u)}function c(h){return h===96?(n.consume(h),i++,c):i===r?(n.exit("codeTextSequence"),n.exit("codeText"),e(h)):(s.type="codeTextData",u(h))}}class lh{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){const r=t??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(e,r):e>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(e,t,r){const i=t||0;this.setCursor(Math.trunc(e));const s=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&on(this.left,r),s.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(e){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(e)}pushMany(e){this.setCursor(Number.POSITIVE_INFINITY),on(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),on(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e<this.left.length){const t=this.left.splice(e,Number.POSITIVE_INFINITY);on(this.right,t.reverse())}else{const t=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);on(this.left,t.reverse())}}}function on(n,e){let t=0;if(e.length<1e4)n.push(...e);else for(;t<e.length;)n.push(...e.slice(t,t+1e4)),t+=1e4}function jl(n){const e={};let t=-1,r,i,s,o,l,a,u;const c=new lh(n);for(;++t<c.length;){for(;t in e;)t=e[t];if(r=c.get(t),t&&r[1].type==="chunkFlow"&&c.get(t-1)[1].type==="listItemPrefix"&&(a=r[1]._tokenizer.events,s=0,s<a.length&&a[s][1].type==="lineEndingBlank"&&(s+=2),s<a.length&&a[s][1].type==="content"))for(;++s<a.length&&a[s][1].type!=="content";)a[s][1].type==="chunkText"&&(a[s][1]._isInFirstContentOfListItem=!0,s++);if(r[0]==="enter")r[1].contentType&&(Object.assign(e,ah(c,t)),t=e[t],u=!0);else if(r[1]._container){for(s=t,i=void 0;s--;)if(o=c.get(s),o[1].type==="lineEnding"||o[1].type==="lineEndingBlank")o[0]==="enter"&&(i&&(c.get(i)[1].type="lineEndingBlank"),o[1].type="lineEnding",i=s);else if(!(o[1].type==="linePrefix"||o[1].type==="listItemIndent"))break;i&&(r[1].end={...c.get(i)[1].start},l=c.slice(i,t),l.unshift(r),c.splice(i,t-i+1,l))}}return _e(n,0,Number.POSITIVE_INFINITY,c.slice(0)),!u}function ah(n,e){const t=n.get(e)[1],r=n.get(e)[2];let i=e-1;const s=[];let o=t._tokenizer;o||(o=r.parser[t.contentType](t.start),t._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const l=o.events,a=[],u={};let c,h,d=-1,f=t,p=0,y=0;const x=[y];for(;f;){for(;n.get(++i)[1]!==f;);s.push(i),f._tokenizer||(c=r.sliceStream(f),f.next||c.push(null),h&&o.defineSkip(f.start),f._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(c),f._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),h=f,f=f.next}for(f=t;++d<l.length;)l[d][0]==="exit"&&l[d-1][0]==="enter"&&l[d][1].type===l[d-1][1].type&&l[d][1].start.line!==l[d][1].end.line&&(y=d+1,x.push(y),f._tokenizer=void 0,f.previous=void 0,f=f.next);for(o.events=[],f?(f._tokenizer=void 0,f.previous=void 0):x.pop(),d=x.length;d--;){const k=l.slice(x[d],x[d+1]),I=s.pop();a.push([I,I+k.length-1]),n.splice(I,2,k)}for(a.reverse(),d=-1;++d<a.length;)u[p+a[d][0]]=p+a[d][1],p+=a[d][1]-a[d][0]-1;return u}const uh={resolve:hh,tokenize:fh},ch={partial:!0,tokenize:dh};function hh(n){return jl(n),n}function fh(n,e){let t;return r;function r(l){return n.enter("content"),t=n.enter("chunkContent",{contentType:"content"}),i(l)}function i(l){return l===null?s(l):A(l)?n.check(ch,o,s)(l):(n.consume(l),i)}function s(l){return n.exit("chunkContent"),n.exit("content"),e(l)}function o(l){return n.consume(l),n.exit("chunkContent"),t.next=n.enter("chunkContent",{contentType:"content",previous:t}),t=t.next,i}}function dh(n,e,t){const r=this;return i;function i(o){return n.exit("chunkContent"),n.enter("lineEnding"),n.consume(o),n.exit("lineEnding"),K(n,s,"linePrefix")}function s(o){if(o===null||A(o))return t(o);const l=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?e(o):n.interrupt(r.parser.constructs.flow,t,e)(o)}}function Jl(n,e,t,r,i,s,o,l,a){const u=a||Number.POSITIVE_INFINITY;let c=0;return h;function h(k){return k===60?(n.enter(r),n.enter(i),n.enter(s),n.consume(k),n.exit(s),d):k===null||k===32||k===41||Oi(k)?t(k):(n.enter(r),n.enter(o),n.enter(l),n.enter("chunkString",{contentType:"string"}),y(k))}function d(k){return k===62?(n.enter(s),n.consume(k),n.exit(s),n.exit(i),n.exit(r),e):(n.enter(l),n.enter("chunkString",{contentType:"string"}),f(k))}function f(k){return k===62?(n.exit("chunkString"),n.exit(l),d(k)):k===null||k===60||A(k)?t(k):(n.consume(k),k===92?p:f)}function p(k){return k===60||k===62||k===92?(n.consume(k),f):f(k)}function y(k){return!c&&(k===null||k===41||pe(k))?(n.exit("chunkString"),n.exit(l),n.exit(o),n.exit(r),e(k)):c<u&&k===40?(n.consume(k),c++,y):k===41?(n.consume(k),c--,y):k===null||k===32||k===40||Oi(k)?t(k):(n.consume(k),k===92?x:y)}function x(k){return k===40||k===41||k===92?(n.consume(k),y):y(k)}}function Hl(n,e,t,r,i,s){const o=this;let l=0,a;return u;function u(f){return n.enter(r),n.enter(i),n.consume(f),n.exit(i),n.enter(s),c}function c(f){return l>999||f===null||f===91||f===93&&!a||f===94&&!l&&"_hiddenFootnoteSupport"in o.parser.constructs?t(f):f===93?(n.exit(s),n.enter(i),n.consume(f),n.exit(i),n.exit(r),e):A(f)?(n.enter("lineEnding"),n.consume(f),n.exit("lineEnding"),c):(n.enter("chunkString",{contentType:"string"}),h(f))}function h(f){return f===null||f===91||f===93||A(f)||l++>999?(n.exit("chunkString"),c(f)):(n.consume(f),a||(a=!q(f)),f===92?d:h)}function d(f){return f===91||f===92||f===93?(n.consume(f),l++,h):h(f)}}function Kl(n,e,t,r,i,s){let o;return l;function l(d){return d===34||d===39||d===40?(n.enter(r),n.enter(i),n.consume(d),n.exit(i),o=d===40?41:d,a):t(d)}function a(d){return d===o?(n.enter(i),n.consume(d),n.exit(i),n.exit(r),e):(n.enter(s),u(d))}function u(d){return d===o?(n.exit(s),a(o)):d===null?t(d):A(d)?(n.enter("lineEnding"),n.consume(d),n.exit("lineEnding"),K(n,u,"linePrefix")):(n.enter("chunkString",{contentType:"string"}),c(d))}function c(d){return d===o||d===null||A(d)?(n.exit("chunkString"),u(d)):(n.consume(d),d===92?h:c)}function h(d){return d===o||d===92?(n.consume(d),c):c(d)}}function Sn(n,e){let t;return r;function r(i){return A(i)?(n.enter("lineEnding"),n.consume(i),n.exit("lineEnding"),t=!0,r):q(i)?K(n,r,t?"linePrefix":"lineSuffix")(i):e(i)}}const ph={name:"definition",tokenize:gh},mh={partial:!0,tokenize:yh};function gh(n,e,t){const r=this;let i;return s;function s(f){return n.enter("definition"),o(f)}function o(f){return Hl.call(r,n,l,t,"definitionLabel","definitionLabelMarker","definitionLabelString")(f)}function l(f){return i=jt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),f===58?(n.enter("definitionMarker"),n.consume(f),n.exit("definitionMarker"),a):t(f)}function a(f){return pe(f)?Sn(n,u)(f):u(f)}function u(f){return Jl(n,c,t,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(f)}function c(f){return n.attempt(mh,h,h)(f)}function h(f){return q(f)?K(n,d,"whitespace")(f):d(f)}function d(f){return f===null||A(f)?(n.exit("definition"),r.parser.defined.push(i),e(f)):t(f)}}function yh(n,e,t){return r;function r(l){return pe(l)?Sn(n,i)(l):t(l)}function i(l){return Kl(n,s,t,"definitionTitle","definitionTitleMarker","definitionTitleString")(l)}function s(l){return q(l)?K(n,o,"whitespace")(l):o(l)}function o(l){return l===null||A(l)?e(l):t(l)}}const kh={name:"hardBreakEscape",tokenize:xh};function xh(n,e,t){return r;function r(s){return n.enter("hardBreakEscape"),n.consume(s),i}function i(s){return A(s)?(n.exit("hardBreakEscape"),e(s)):t(s)}}const bh={name:"headingAtx",resolve:Sh,tokenize:wh};function Sh(n,e){let t=n.length-2,r=3,i,s;return n[r][1].type==="whitespace"&&(r+=2),t-2>r&&n[t][1].type==="whitespace"&&(t-=2),n[t][1].type==="atxHeadingSequence"&&(r===t-1||t-4>r&&n[t-2][1].type==="whitespace")&&(t-=r+1===t?2:4),t>r&&(i={type:"atxHeadingText",start:n[r][1].start,end:n[t][1].end},s={type:"chunkText",start:n[r][1].start,end:n[t][1].end,contentType:"text"},_e(n,r,t-r+1,[["enter",i,e],["enter",s,e],["exit",s,e],["exit",i,e]])),n}function wh(n,e,t){let r=0;return i;function i(c){return n.enter("atxHeading"),s(c)}function s(c){return n.enter("atxHeadingSequence"),o(c)}function o(c){return c===35&&r++<6?(n.consume(c),o):c===null||pe(c)?(n.exit("atxHeadingSequence"),l(c)):t(c)}function l(c){return c===35?(n.enter("atxHeadingSequence"),a(c)):c===null||A(c)?(n.exit("atxHeading"),e(c)):q(c)?K(n,l,"whitespace")(c):(n.enter("atxHeadingText"),u(c))}function a(c){return c===35?(n.consume(c),a):(n.exit("atxHeadingSequence"),l(c))}function u(c){return c===null||c===35||pe(c)?(n.exit("atxHeadingText"),l(c)):(n.consume(c),u)}}const Ch=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],ao=["pre","script","style","textarea"],Th={concrete:!0,name:"htmlFlow",resolveTo:Oh,tokenize:Eh},Mh={partial:!0,tokenize:Ah},Nh={partial:!0,tokenize:Ih};function Oh(n){let e=n.length;for(;e--&&!(n[e][0]==="enter"&&n[e][1].type==="htmlFlow"););return e>1&&n[e-2][1].type==="linePrefix"&&(n[e][1].start=n[e-2][1].start,n[e+1][1].start=n[e-2][1].start,n.splice(e-2,2)),n}function Eh(n,e,t){const r=this;let i,s,o,l,a;return u;function u(g){return c(g)}function c(g){return n.enter("htmlFlow"),n.enter("htmlFlowData"),n.consume(g),h}function h(g){return g===33?(n.consume(g),d):g===47?(n.consume(g),s=!0,y):g===63?(n.consume(g),i=3,r.interrupt?e:m):Le(g)?(n.consume(g),o=String.fromCharCode(g),x):t(g)}function d(g){return g===45?(n.consume(g),i=2,f):g===91?(n.consume(g),i=5,l=0,p):Le(g)?(n.consume(g),i=4,r.interrupt?e:m):t(g)}function f(g){return g===45?(n.consume(g),r.interrupt?e:m):t(g)}function p(g){const Ae="CDATA[";return g===Ae.charCodeAt(l++)?(n.consume(g),l===Ae.length?r.interrupt?e:O:p):t(g)}function y(g){return Le(g)?(n.consume(g),o=String.fromCharCode(g),x):t(g)}function x(g){if(g===null||g===47||g===62||pe(g)){const Ae=g===47,kt=o.toLowerCase();return!Ae&&!s&&ao.includes(kt)?(i=1,r.interrupt?e(g):O(g)):Ch.includes(o.toLowerCase())?(i=6,Ae?(n.consume(g),k):r.interrupt?e(g):O(g)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?t(g):s?I(g):C(g))}return g===45||Re(g)?(n.consume(g),o+=String.fromCharCode(g),x):t(g)}function k(g){return g===62?(n.consume(g),r.interrupt?e:O):t(g)}function I(g){return q(g)?(n.consume(g),I):J(g)}function C(g){return g===47?(n.consume(g),J):g===58||g===95||Le(g)?(n.consume(g),B):q(g)?(n.consume(g),C):J(g)}function B(g){return g===45||g===46||g===58||g===95||Re(g)?(n.consume(g),B):$(g)}function $(g){return g===61?(n.consume(g),S):q(g)?(n.consume(g),$):C(g)}function S(g){return g===null||g===60||g===61||g===62||g===96?t(g):g===34||g===39?(n.consume(g),a=g,N):q(g)?(n.consume(g),S):P(g)}function N(g){return g===a?(n.consume(g),a=null,z):g===null||A(g)?t(g):(n.consume(g),N)}function P(g){return g===null||g===34||g===39||g===47||g===60||g===61||g===62||g===96||pe(g)?$(g):(n.consume(g),P)}function z(g){return g===47||g===62||q(g)?C(g):t(g)}function J(g){return g===62?(n.consume(g),E):t(g)}function E(g){return g===null||A(g)?O(g):q(g)?(n.consume(g),E):t(g)}function O(g){return g===45&&i===2?(n.consume(g),ae):g===60&&i===1?(n.consume(g),te):g===62&&i===4?(n.consume(g),Ie):g===63&&i===3?(n.consume(g),m):g===93&&i===5?(n.consume(g),je):A(g)&&(i===6||i===7)?(n.exit("htmlFlowData"),n.check(Mh,Je,Y)(g)):g===null||A(g)?(n.exit("htmlFlowData"),Y(g)):(n.consume(g),O)}function Y(g){return n.check(Nh,Q,Je)(g)}function Q(g){return n.enter("lineEnding"),n.consume(g),n.exit("lineEnding"),_}function _(g){return g===null||A(g)?Y(g):(n.enter("htmlFlowData"),O(g))}function ae(g){return g===45?(n.consume(g),m):O(g)}function te(g){return g===47?(n.consume(g),o="",Ee):O(g)}function Ee(g){if(g===62){const Ae=o.toLowerCase();return ao.includes(Ae)?(n.consume(g),Ie):O(g)}return Le(g)&&o.length<8?(n.consume(g),o+=String.fromCharCode(g),Ee):O(g)}function je(g){return g===93?(n.consume(g),m):O(g)}function m(g){return g===62?(n.consume(g),Ie):g===45&&i===2?(n.consume(g),m):O(g)}function Ie(g){return g===null||A(g)?(n.exit("htmlFlowData"),Je(g)):(n.consume(g),Ie)}function Je(g){return n.exit("htmlFlow"),e(g)}}function Ih(n,e,t){const r=this;return i;function i(o){return A(o)?(n.enter("lineEnding"),n.consume(o),n.exit("lineEnding"),s):t(o)}function s(o){return r.parser.lazy[r.now().line]?t(o):e(o)}}function Ah(n,e,t){return r;function r(i){return n.enter("lineEnding"),n.consume(i),n.exit("lineEnding"),n.attempt(Nr,e,t)}}const Dh={name:"htmlText",tokenize:Rh};function Rh(n,e,t){const r=this;let i,s,o;return l;function l(m){return n.enter("htmlText"),n.enter("htmlTextData"),n.consume(m),a}function a(m){return m===33?(n.consume(m),u):m===47?(n.consume(m),$):m===63?(n.consume(m),C):Le(m)?(n.consume(m),P):t(m)}function u(m){return m===45?(n.consume(m),c):m===91?(n.consume(m),s=0,p):Le(m)?(n.consume(m),I):t(m)}function c(m){return m===45?(n.consume(m),f):t(m)}function h(m){return m===null?t(m):m===45?(n.consume(m),d):A(m)?(o=h,te(m)):(n.consume(m),h)}function d(m){return m===45?(n.consume(m),f):h(m)}function f(m){return m===62?ae(m):m===45?d(m):h(m)}function p(m){const Ie="CDATA[";return m===Ie.charCodeAt(s++)?(n.consume(m),s===Ie.length?y:p):t(m)}function y(m){return m===null?t(m):m===93?(n.consume(m),x):A(m)?(o=y,te(m)):(n.consume(m),y)}function x(m){return m===93?(n.consume(m),k):y(m)}function k(m){return m===62?ae(m):m===93?(n.consume(m),k):y(m)}function I(m){return m===null||m===62?ae(m):A(m)?(o=I,te(m)):(n.consume(m),I)}function C(m){return m===null?t(m):m===63?(n.consume(m),B):A(m)?(o=C,te(m)):(n.consume(m),C)}function B(m){return m===62?ae(m):C(m)}function $(m){return Le(m)?(n.consume(m),S):t(m)}function S(m){return m===45||Re(m)?(n.consume(m),S):N(m)}function N(m){return A(m)?(o=N,te(m)):q(m)?(n.consume(m),N):ae(m)}function P(m){return m===45||Re(m)?(n.consume(m),P):m===47||m===62||pe(m)?z(m):t(m)}function z(m){return m===47?(n.consume(m),ae):m===58||m===95||Le(m)?(n.consume(m),J):A(m)?(o=z,te(m)):q(m)?(n.consume(m),z):ae(m)}function J(m){return m===45||m===46||m===58||m===95||Re(m)?(n.consume(m),J):E(m)}function E(m){return m===61?(n.consume(m),O):A(m)?(o=E,te(m)):q(m)?(n.consume(m),E):z(m)}function O(m){return m===null||m===60||m===61||m===62||m===96?t(m):m===34||m===39?(n.consume(m),i=m,Y):A(m)?(o=O,te(m)):q(m)?(n.consume(m),O):(n.consume(m),Q)}function Y(m){return m===i?(n.consume(m),i=void 0,_):m===null?t(m):A(m)?(o=Y,te(m)):(n.consume(m),Y)}function Q(m){return m===null||m===34||m===39||m===60||m===61||m===96?t(m):m===47||m===62||pe(m)?z(m):(n.consume(m),Q)}function _(m){return m===47||m===62||pe(m)?z(m):t(m)}function ae(m){return m===62?(n.consume(m),n.exit("htmlTextData"),n.exit("htmlText"),e):t(m)}function te(m){return n.exit("htmlTextData"),n.enter("lineEnding"),n.consume(m),n.exit("lineEnding"),Ee}function Ee(m){return q(m)?K(n,je,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(m):je(m)}function je(m){return n.enter("htmlTextData"),o(m)}}const ps={name:"labelEnd",resolveAll:Bh,resolveTo:vh,tokenize:Lh},zh={tokenize:Vh},Ph={tokenize:_h},Fh={tokenize:$h};function Bh(n){let e=-1;const t=[];for(;++e<n.length;){const r=n[e][1];if(t.push(n[e]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const i=r.type==="labelImage"?4:2;r.type="data",e+=i}}return n.length!==t.length&&_e(n,0,n.length,t),n}function vh(n,e){let t=n.length,r=0,i,s,o,l;for(;t--;)if(i=n[t][1],s){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;n[t][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(o){if(n[t][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(s=t,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(o=t);const a={type:n[s][1].type==="labelLink"?"link":"image",start:{...n[s][1].start},end:{...n[n.length-1][1].end}},u={type:"label",start:{...n[s][1].start},end:{...n[o][1].end}},c={type:"labelText",start:{...n[s+r+2][1].end},end:{...n[o-2][1].start}};return l=[["enter",a,e],["enter",u,e]],l=Ce(l,n.slice(s+1,s+r+3)),l=Ce(l,[["enter",c,e]]),l=Ce(l,ds(e.parser.constructs.insideSpan.null,n.slice(s+r+4,o-3),e)),l=Ce(l,[["exit",c,e],n[o-2],n[o-1],["exit",u,e]]),l=Ce(l,n.slice(o+1)),l=Ce(l,[["exit",a,e]]),_e(n,s,n.length,l),n}function Lh(n,e,t){const r=this;let i=r.events.length,s,o;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){s=r.events[i][1];break}return l;function l(d){return s?s._inactive?h(d):(o=r.parser.defined.includes(jt(r.sliceSerialize({start:s.end,end:r.now()}))),n.enter("labelEnd"),n.enter("labelMarker"),n.consume(d),n.exit("labelMarker"),n.exit("labelEnd"),a):t(d)}function a(d){return d===40?n.attempt(zh,c,o?c:h)(d):d===91?n.attempt(Ph,c,o?u:h)(d):o?c(d):h(d)}function u(d){return n.attempt(Fh,c,h)(d)}function c(d){return e(d)}function h(d){return s._balanced=!0,t(d)}}function Vh(n,e,t){return r;function r(h){return n.enter("resource"),n.enter("resourceMarker"),n.consume(h),n.exit("resourceMarker"),i}function i(h){return pe(h)?Sn(n,s)(h):s(h)}function s(h){return h===41?c(h):Jl(n,o,l,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(h)}function o(h){return pe(h)?Sn(n,a)(h):c(h)}function l(h){return t(h)}function a(h){return h===34||h===39||h===40?Kl(n,u,t,"resourceTitle","resourceTitleMarker","resourceTitleString")(h):c(h)}function u(h){return pe(h)?Sn(n,c)(h):c(h)}function c(h){return h===41?(n.enter("resourceMarker"),n.consume(h),n.exit("resourceMarker"),n.exit("resource"),e):t(h)}}function _h(n,e,t){const r=this;return i;function i(l){return Hl.call(r,n,s,o,"reference","referenceMarker","referenceString")(l)}function s(l){return r.parser.defined.includes(jt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?e(l):t(l)}function o(l){return t(l)}}function $h(n,e,t){return r;function r(s){return n.enter("reference"),n.enter("referenceMarker"),n.consume(s),n.exit("referenceMarker"),i}function i(s){return s===93?(n.enter("referenceMarker"),n.consume(s),n.exit("referenceMarker"),n.exit("reference"),e):t(s)}}const qh={name:"labelStartImage",resolveAll:ps.resolveAll,tokenize:Wh};function Wh(n,e,t){const r=this;return i;function i(l){return n.enter("labelImage"),n.enter("labelImageMarker"),n.consume(l),n.exit("labelImageMarker"),s}function s(l){return l===91?(n.enter("labelMarker"),n.consume(l),n.exit("labelMarker"),n.exit("labelImage"),o):t(l)}function o(l){return l===94&&"_hiddenFootnoteSupport"in r.parser.constructs?t(l):e(l)}}const jh={name:"labelStartLink",resolveAll:ps.resolveAll,tokenize:Jh};function Jh(n,e,t){const r=this;return i;function i(o){return n.enter("labelLink"),n.enter("labelMarker"),n.consume(o),n.exit("labelMarker"),n.exit("labelLink"),s}function s(o){return o===94&&"_hiddenFootnoteSupport"in r.parser.constructs?t(o):e(o)}}const Lr={name:"lineEnding",tokenize:Hh};function Hh(n,e){return t;function t(r){return n.enter("lineEnding"),n.consume(r),n.exit("lineEnding"),K(n,e,"linePrefix")}}const Wn={name:"thematicBreak",tokenize:Kh};function Kh(n,e,t){let r=0,i;return s;function s(u){return n.enter("thematicBreak"),o(u)}function o(u){return i=u,l(u)}function l(u){return u===i?(n.enter("thematicBreakSequence"),a(u)):r>=3&&(u===null||A(u))?(n.exit("thematicBreak"),e(u)):t(u)}function a(u){return u===i?(n.consume(u),r++,a):(n.exit("thematicBreakSequence"),q(u)?K(n,l,"whitespace")(u):l(u))}}const de={continuation:{tokenize:Gh},exit:Zh,name:"list",tokenize:Qh},Uh={partial:!0,tokenize:ef},Yh={partial:!0,tokenize:Xh};function Qh(n,e,t){const r=this,i=r.events[r.events.length-1];let s=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,o=0;return l;function l(f){const p=r.containerState.type||(f===42||f===43||f===45?"listUnordered":"listOrdered");if(p==="listUnordered"?!r.containerState.marker||f===r.containerState.marker:Ei(f)){if(r.containerState.type||(r.containerState.type=p,n.enter(p,{_container:!0})),p==="listUnordered")return n.enter("listItemPrefix"),f===42||f===45?n.check(Wn,t,u)(f):u(f);if(!r.interrupt||f===49)return n.enter("listItemPrefix"),n.enter("listItemValue"),a(f)}return t(f)}function a(f){return Ei(f)&&++o<10?(n.consume(f),a):(!r.interrupt||o<2)&&(r.containerState.marker?f===r.containerState.marker:f===41||f===46)?(n.exit("listItemValue"),u(f)):t(f)}function u(f){return n.enter("listItemMarker"),n.consume(f),n.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||f,n.check(Nr,r.interrupt?t:c,n.attempt(Uh,d,h))}function c(f){return r.containerState.initialBlankLine=!0,s++,d(f)}function h(f){return q(f)?(n.enter("listItemPrefixWhitespace"),n.consume(f),n.exit("listItemPrefixWhitespace"),d):t(f)}function d(f){return r.containerState.size=s+r.sliceSerialize(n.exit("listItemPrefix"),!0).length,e(f)}}function Gh(n,e,t){const r=this;return r.containerState._closeFlow=void 0,n.check(Nr,i,s);function i(l){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,K(n,e,"listItemIndent",r.containerState.size+1)(l)}function s(l){return r.containerState.furtherBlankLines||!q(l)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(l)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,n.attempt(Yh,e,o)(l))}function o(l){return r.containerState._closeFlow=!0,r.interrupt=void 0,K(n,n.attempt(de,e,t),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l)}}function Xh(n,e,t){const r=this;return K(n,i,"listItemIndent",r.containerState.size+1);function i(s){const o=r.events[r.events.length-1];return o&&o[1].type==="listItemIndent"&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?e(s):t(s)}}function Zh(n){n.exit(this.containerState.type)}function ef(n,e,t){const r=this;return K(n,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(s){const o=r.events[r.events.length-1];return!q(s)&&o&&o[1].type==="listItemPrefixWhitespace"?e(s):t(s)}}const uo={name:"setextUnderline",resolveTo:tf,tokenize:nf};function tf(n,e){let t=n.length,r,i,s;for(;t--;)if(n[t][0]==="enter"){if(n[t][1].type==="content"){r=t;break}n[t][1].type==="paragraph"&&(i=t)}else n[t][1].type==="content"&&n.splice(t,1),!s&&n[t][1].type==="definition"&&(s=t);const o={type:"setextHeading",start:{...n[r][1].start},end:{...n[n.length-1][1].end}};return n[i][1].type="setextHeadingText",s?(n.splice(i,0,["enter",o,e]),n.splice(s+1,0,["exit",n[r][1],e]),n[r][1].end={...n[s][1].end}):n[r][1]=o,n.push(["exit",o,e]),n}function nf(n,e,t){const r=this;let i;return s;function s(u){let c=r.events.length,h;for(;c--;)if(r.events[c][1].type!=="lineEnding"&&r.events[c][1].type!=="linePrefix"&&r.events[c][1].type!=="content"){h=r.events[c][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||h)?(n.enter("setextHeadingLine"),i=u,o(u)):t(u)}function o(u){return n.enter("setextHeadingLineSequence"),l(u)}function l(u){return u===i?(n.consume(u),l):(n.exit("setextHeadingLineSequence"),q(u)?K(n,a,"lineSuffix")(u):a(u))}function a(u){return u===null||A(u)?(n.exit("setextHeadingLine"),e(u)):t(u)}}const rf={tokenize:sf};function sf(n){const e=this,t=n.attempt(Nr,r,n.attempt(this.parser.constructs.flowInitial,i,K(n,n.attempt(this.parser.constructs.flow,i,n.attempt(uh,i)),"linePrefix")));return t;function r(s){if(s===null){n.consume(s);return}return n.enter("lineEndingBlank"),n.consume(s),n.exit("lineEndingBlank"),e.currentConstruct=void 0,t}function i(s){if(s===null){n.consume(s);return}return n.enter("lineEnding"),n.consume(s),n.exit("lineEnding"),e.currentConstruct=void 0,t}}const of={resolveAll:Yl()},lf=Ul("string"),af=Ul("text");function Ul(n){return{resolveAll:Yl(n==="text"?uf:void 0),tokenize:e};function e(t){const r=this,i=this.parser.constructs[n],s=t.attempt(i,o,l);return o;function o(c){return u(c)?s(c):l(c)}function l(c){if(c===null){t.consume(c);return}return t.enter("data"),t.consume(c),a}function a(c){return u(c)?(t.exit("data"),s(c)):(t.consume(c),a)}function u(c){if(c===null)return!0;const h=i[c];let d=-1;if(h)for(;++d<h.length;){const f=h[d];if(!f.previous||f.previous.call(r,r.previous))return!0}return!1}}}function Yl(n){return e;function e(t,r){let i=-1,s;for(;++i<=t.length;)s===void 0?t[i]&&t[i][1].type==="data"&&(s=i,i++):(!t[i]||t[i][1].type!=="data")&&(i!==s+2&&(t[s][1].end=t[i-1][1].end,t.splice(s+2,i-s-2),i=s+2),s=void 0);return n?n(t,r):t}}function uf(n,e){let t=0;for(;++t<=n.length;)if((t===n.length||n[t][1].type==="lineEnding")&&n[t-1][1].type==="data"){const r=n[t-1][1],i=e.sliceStream(r);let s=i.length,o=-1,l=0,a;for(;s--;){const u=i[s];if(typeof u=="string"){for(o=u.length;u.charCodeAt(o-1)===32;)l++,o--;if(o)break;o=-1}else if(u===-2)a=!0,l++;else if(u!==-1){s++;break}}if(e._contentTypeTextTrailing&&t===n.length&&(l=0),l){const u={type:t===n.length||a||l<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:s?o:r.start._bufferIndex+o,_index:r.start._index+s,line:r.end.line,column:r.end.column-l,offset:r.end.offset-l},end:{...r.end}};r.end={...u.start},r.start.offset===r.end.offset?Object.assign(r,u):(n.splice(t,0,["enter",u,e],["exit",u,e]),t+=2)}t++}return n}const cf={42:de,43:de,45:de,48:de,49:de,50:de,51:de,52:de,53:de,54:de,55:de,56:de,57:de,62:$l},hf={91:ph},ff={[-2]:vr,[-1]:vr,32:vr},df={35:bh,42:Wn,45:[uo,Wn],60:Th,61:uo,95:Wn,96:lo,126:lo},pf={38:Wl,92:ql},mf={[-5]:Lr,[-4]:Lr,[-3]:Lr,33:qh,38:Wl,42:Ii,60:[jc,Dh],91:jh,92:[kh,ql],93:ps,95:Ii,96:rh},gf={null:[Ii,of]},yf={null:[42,95]},kf={null:[]},xf=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:yf,contentInitial:hf,disable:kf,document:cf,flow:df,flowInitial:ff,insideSpan:gf,string:pf,text:mf},Symbol.toStringTag,{value:"Module"}));function bf(n,e,t){let r={_bufferIndex:-1,_index:0,line:t&&t.line||1,column:t&&t.column||1,offset:t&&t.offset||0};const i={},s=[];let o=[],l=[];const a={attempt:N($),check:N(S),consume:I,enter:C,exit:B,interrupt:N(S,{interrupt:!0})},u={code:null,containerState:{},defineSkip:y,events:[],now:p,parser:n,previous:null,sliceSerialize:d,sliceStream:f,write:h};let c=e.tokenize.call(u,a);return e.resolveAll&&s.push(e),u;function h(E){return o=Ce(o,E),x(),o[o.length-1]!==null?[]:(P(e,0),u.events=ds(s,u.events,u),u.events)}function d(E,O){return wf(f(E),O)}function f(E){return Sf(o,E)}function p(){const{_bufferIndex:E,_index:O,line:Y,column:Q,offset:_}=r;return{_bufferIndex:E,_index:O,line:Y,column:Q,offset:_}}function y(E){i[E.line]=E.column,J()}function x(){let E;for(;r._index<o.length;){const O=o[r._index];if(typeof O=="string")for(E=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===E&&r._bufferIndex<O.length;)k(O.charCodeAt(r._bufferIndex));else k(O)}}function k(E){c=c(E)}function I(E){A(E)?(r.line++,r.column=1,r.offset+=E===-3?2:1,J()):E!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),u.previous=E}function C(E,O){const Y=O||{};return Y.type=E,Y.start=p(),u.events.push(["enter",Y,u]),l.push(Y),Y}function B(E){const O=l.pop();return O.end=p(),u.events.push(["exit",O,u]),O}function $(E,O){P(E,O.from)}function S(E,O){O.restore()}function N(E,O){return Y;function Y(Q,_,ae){let te,Ee,je,m;return Array.isArray(Q)?Je(Q):"tokenize"in Q?Je([Q]):Ie(Q);function Ie(ne){return nn;function nn(nt){const Ft=nt!==null&&ne[nt],Bt=nt!==null&&ne.null,vn=[...Array.isArray(Ft)?Ft:Ft?[Ft]:[],...Array.isArray(Bt)?Bt:Bt?[Bt]:[]];return Je(vn)(nt)}}function Je(ne){return te=ne,Ee=0,ne.length===0?ae:g(ne[Ee])}function g(ne){return nn;function nn(nt){return m=z(),je=ne,ne.partial||(u.currentConstruct=ne),ne.name&&u.parser.constructs.disable.null.includes(ne.name)?kt():ne.tokenize.call(O?Object.assign(Object.create(u),O):u,a,Ae,kt)(nt)}}function Ae(ne){return E(je,m),_}function kt(ne){return m.restore(),++Ee<te.length?g(te[Ee]):ae}}}function P(E,O){E.resolveAll&&!s.includes(E)&&s.push(E),E.resolve&&_e(u.events,O,u.events.length-O,E.resolve(u.events.slice(O),u)),E.resolveTo&&(u.events=E.resolveTo(u.events,u))}function z(){const E=p(),O=u.previous,Y=u.currentConstruct,Q=u.events.length,_=Array.from(l);return{from:Q,restore:ae};function ae(){r=E,u.previous=O,u.currentConstruct=Y,u.events.length=Q,l=_,J()}}function J(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function Sf(n,e){const t=e.start._index,r=e.start._bufferIndex,i=e.end._index,s=e.end._bufferIndex;let o;if(t===i)o=[n[t].slice(r,s)];else{if(o=n.slice(t,i),r>-1){const l=o[0];typeof l=="string"?o[0]=l.slice(r):o.shift()}s>0&&o.push(n[i].slice(0,s))}return o}function wf(n,e){let t=-1;const r=[];let i;for(;++t<n.length;){const s=n[t];let o;if(typeof s=="string")o=s;else switch(s){case-5:{o="\r";break}case-4:{o=`
6
- `;break}case-3:{o=`\r
7
- `;break}case-2:{o=e?" ":" ";break}case-1:{if(!e&&i)continue;o=" ";break}default:o=String.fromCharCode(s)}i=s===-2,r.push(o)}return r.join("")}function Cf(n){const r={constructs:Ic([xf,...(n||{}).extensions||[]]),content:i(vc),defined:[],document:i(Vc),flow:i(rf),lazy:{},string:i(lf),text:i(af)};return r;function i(s){return o;function o(l){return bf(r,s,l)}}}function Tf(n){for(;!jl(n););return n}const co=/[\0\t\n\r]/g;function Mf(){let n=1,e="",t=!0,r;return i;function i(s,o,l){const a=[];let u,c,h,d,f;for(s=e+(typeof s=="string"?s.toString():new TextDecoder(o||void 0).decode(s)),h=0,e="",t&&(s.charCodeAt(0)===65279&&h++,t=void 0);h<s.length;){if(co.lastIndex=h,u=co.exec(s),d=u&&u.index!==void 0?u.index:s.length,f=s.charCodeAt(d),!u){e=s.slice(h);break}if(f===10&&h===d&&r)a.push(-3),r=void 0;else switch(r&&(a.push(-5),r=void 0),h<d&&(a.push(s.slice(h,d)),n+=d-h),f){case 0:{a.push(65533),n++;break}case 9:{for(c=Math.ceil(n/4)*4,a.push(-2);n++<c;)a.push(-1);break}case 10:{a.push(-4),n=1;break}default:r=!0,n=1}h=d+1}return l&&(r&&a.push(-5),e&&a.push(e),a.push(null)),a}}const Nf=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Ql(n){return n.replace(Nf,Of)}function Of(n,e,t){if(e)return e;if(t.charCodeAt(0)===35){const i=t.charCodeAt(1),s=i===120||i===88;return _l(t.slice(s?2:1),s?16:10)}return fs(t)||n}function wn(n){return!n||typeof n!="object"?"":"position"in n||"type"in n?ho(n.position):"start"in n||"end"in n?ho(n):"line"in n||"column"in n?Ai(n):""}function Ai(n){return fo(n&&n.line)+":"+fo(n&&n.column)}function ho(n){return Ai(n&&n.start)+"-"+Ai(n&&n.end)}function fo(n){return n&&typeof n=="number"?n:1}const Gl={}.hasOwnProperty;function Ef(n,e,t){return typeof e!="string"&&(t=e,e=void 0),If(t)(Tf(Cf(t).document().write(Mf()(n,e,!0))))}function If(n){const e={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(qs),autolinkProtocol:z,autolinkEmail:z,atxHeading:s(Vs),blockQuote:s(Bt),characterEscape:z,characterReference:z,codeFenced:s(vn),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:s(vn,o),codeText:s(Ru,o),codeTextData:z,data:z,codeFlowValue:z,definition:s(zu),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:s(Pu),hardBreakEscape:s(_s),hardBreakTrailing:s(_s),htmlFlow:s($s,o),htmlFlowData:z,htmlText:s($s,o),htmlTextData:z,image:s(Fu),label:o,link:s(qs),listItem:s(Bu),listItemValue:d,listOrdered:s(Ws,h),listUnordered:s(Ws),paragraph:s(vu),reference:g,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:s(Vs),strong:s(Lu),thematicBreak:s(_u)},exit:{atxHeading:a(),atxHeadingSequence:$,autolink:a(),autolinkEmail:Ft,autolinkProtocol:nt,blockQuote:a(),characterEscapeValue:J,characterReferenceMarkerHexadecimal:kt,characterReferenceMarkerNumeric:kt,characterReferenceValue:ne,characterReference:nn,codeFenced:a(x),codeFencedFence:y,codeFencedFenceInfo:f,codeFencedFenceMeta:p,codeFlowValue:J,codeIndented:a(k),codeText:a(_),codeTextData:J,data:J,definition:a(),definitionDestinationString:B,definitionLabelString:I,definitionTitleString:C,emphasis:a(),hardBreakEscape:a(O),hardBreakTrailing:a(O),htmlFlow:a(Y),htmlFlowData:J,htmlText:a(Q),htmlTextData:J,image:a(te),label:je,labelText:Ee,lineEnding:E,link:a(ae),listItem:a(),listOrdered:a(),listUnordered:a(),paragraph:a(),referenceString:Ae,resourceDestinationString:m,resourceTitleString:Ie,resource:Je,setextHeading:a(P),setextHeadingLineSequence:N,setextHeadingText:S,strong:a(),thematicBreak:a()}};Xl(e,(n||{}).mdastExtensions||[]);const t={};return r;function r(b){let w={type:"root",children:[]};const R={stack:[w],tokenStack:[],config:e,enter:l,exit:u,buffer:o,resume:c,data:t},v=[];let H=-1;for(;++H<b.length;)if(b[H][1].type==="listOrdered"||b[H][1].type==="listUnordered")if(b[H][0]==="enter")v.push(H);else{const De=v.pop();H=i(b,De,H)}for(H=-1;++H<b.length;){const De=e[b[H][0]];Gl.call(De,b[H][1].type)&&De[b[H][1].type].call(Object.assign({sliceSerialize:b[H][2].sliceSerialize},R),b[H][1])}if(R.tokenStack.length>0){const De=R.tokenStack[R.tokenStack.length-1];(De[1]||po).call(R,void 0,De[0])}for(w.position={start:rt(b.length>0?b[0][1].start:{line:1,column:1,offset:0}),end:rt(b.length>0?b[b.length-2][1].end:{line:1,column:1,offset:0})},H=-1;++H<e.transforms.length;)w=e.transforms[H](w)||w;return w}function i(b,w,R){let v=w-1,H=-1,De=!1,xt,He,rn,sn;for(;++v<=R;){const ye=b[v];switch(ye[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{ye[0]==="enter"?H++:H--,sn=void 0;break}case"lineEndingBlank":{ye[0]==="enter"&&(xt&&!sn&&!H&&!rn&&(rn=v),sn=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:sn=void 0}if(!H&&ye[0]==="enter"&&ye[1].type==="listItemPrefix"||H===-1&&ye[0]==="exit"&&(ye[1].type==="listUnordered"||ye[1].type==="listOrdered")){if(xt){let vt=v;for(He=void 0;vt--;){const Ke=b[vt];if(Ke[1].type==="lineEnding"||Ke[1].type==="lineEndingBlank"){if(Ke[0]==="exit")continue;He&&(b[He][1].type="lineEndingBlank",De=!0),Ke[1].type="lineEnding",He=vt}else if(!(Ke[1].type==="linePrefix"||Ke[1].type==="blockQuotePrefix"||Ke[1].type==="blockQuotePrefixWhitespace"||Ke[1].type==="blockQuoteMarker"||Ke[1].type==="listItemIndent"))break}rn&&(!He||rn<He)&&(xt._spread=!0),xt.end=Object.assign({},He?b[He][1].start:ye[1].end),b.splice(He||v,0,["exit",xt,ye[2]]),v++,R++}if(ye[1].type==="listItemPrefix"){const vt={type:"listItem",_spread:!1,start:Object.assign({},ye[1].start),end:void 0};xt=vt,b.splice(v,0,["enter",vt,ye[2]]),v++,R++,rn=void 0,sn=!0}}}return b[w][1]._spread=De,R}function s(b,w){return R;function R(v){l.call(this,b(v),v),w&&w.call(this,v)}}function o(){this.stack.push({type:"fragment",children:[]})}function l(b,w,R){this.stack[this.stack.length-1].children.push(b),this.stack.push(b),this.tokenStack.push([w,R||void 0]),b.position={start:rt(w.start),end:void 0}}function a(b){return w;function w(R){b&&b.call(this,R),u.call(this,R)}}function u(b,w){const R=this.stack.pop(),v=this.tokenStack.pop();if(v)v[0].type!==b.type&&(w?w.call(this,b,v[0]):(v[1]||po).call(this,b,v[0]));else throw new Error("Cannot close `"+b.type+"` ("+wn({start:b.start,end:b.end})+"): it’s not open");R.position.end=rt(b.end)}function c(){return hs(this.stack.pop())}function h(){this.data.expectingFirstListItemValue=!0}function d(b){if(this.data.expectingFirstListItemValue){const w=this.stack[this.stack.length-2];w.start=Number.parseInt(this.sliceSerialize(b),10),this.data.expectingFirstListItemValue=void 0}}function f(){const b=this.resume(),w=this.stack[this.stack.length-1];w.lang=b}function p(){const b=this.resume(),w=this.stack[this.stack.length-1];w.meta=b}function y(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function x(){const b=this.resume(),w=this.stack[this.stack.length-1];w.value=b.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function k(){const b=this.resume(),w=this.stack[this.stack.length-1];w.value=b.replace(/(\r?\n|\r)$/g,"")}function I(b){const w=this.resume(),R=this.stack[this.stack.length-1];R.label=w,R.identifier=jt(this.sliceSerialize(b)).toLowerCase()}function C(){const b=this.resume(),w=this.stack[this.stack.length-1];w.title=b}function B(){const b=this.resume(),w=this.stack[this.stack.length-1];w.url=b}function $(b){const w=this.stack[this.stack.length-1];if(!w.depth){const R=this.sliceSerialize(b).length;w.depth=R}}function S(){this.data.setextHeadingSlurpLineEnding=!0}function N(b){const w=this.stack[this.stack.length-1];w.depth=this.sliceSerialize(b).codePointAt(0)===61?1:2}function P(){this.data.setextHeadingSlurpLineEnding=void 0}function z(b){const R=this.stack[this.stack.length-1].children;let v=R[R.length-1];(!v||v.type!=="text")&&(v=Vu(),v.position={start:rt(b.start),end:void 0},R.push(v)),this.stack.push(v)}function J(b){const w=this.stack.pop();w.value+=this.sliceSerialize(b),w.position.end=rt(b.end)}function E(b){const w=this.stack[this.stack.length-1];if(this.data.atHardBreak){const R=w.children[w.children.length-1];R.position.end=rt(b.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&e.canContainEols.includes(w.type)&&(z.call(this,b),J.call(this,b))}function O(){this.data.atHardBreak=!0}function Y(){const b=this.resume(),w=this.stack[this.stack.length-1];w.value=b}function Q(){const b=this.resume(),w=this.stack[this.stack.length-1];w.value=b}function _(){const b=this.resume(),w=this.stack[this.stack.length-1];w.value=b}function ae(){const b=this.stack[this.stack.length-1];if(this.data.inReference){const w=this.data.referenceType||"shortcut";b.type+="Reference",b.referenceType=w,delete b.url,delete b.title}else delete b.identifier,delete b.label;this.data.referenceType=void 0}function te(){const b=this.stack[this.stack.length-1];if(this.data.inReference){const w=this.data.referenceType||"shortcut";b.type+="Reference",b.referenceType=w,delete b.url,delete b.title}else delete b.identifier,delete b.label;this.data.referenceType=void 0}function Ee(b){const w=this.sliceSerialize(b),R=this.stack[this.stack.length-2];R.label=Ql(w),R.identifier=jt(w).toLowerCase()}function je(){const b=this.stack[this.stack.length-1],w=this.resume(),R=this.stack[this.stack.length-1];if(this.data.inReference=!0,R.type==="link"){const v=b.children;R.children=v}else R.alt=w}function m(){const b=this.resume(),w=this.stack[this.stack.length-1];w.url=b}function Ie(){const b=this.resume(),w=this.stack[this.stack.length-1];w.title=b}function Je(){this.data.inReference=void 0}function g(){this.data.referenceType="collapsed"}function Ae(b){const w=this.resume(),R=this.stack[this.stack.length-1];R.label=w,R.identifier=jt(this.sliceSerialize(b)).toLowerCase(),this.data.referenceType="full"}function kt(b){this.data.characterReferenceType=b.type}function ne(b){const w=this.sliceSerialize(b),R=this.data.characterReferenceType;let v;R?(v=_l(w,R==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):v=fs(w);const H=this.stack[this.stack.length-1];H.value+=v}function nn(b){const w=this.stack.pop();w.position.end=rt(b.end)}function nt(b){J.call(this,b);const w=this.stack[this.stack.length-1];w.url=this.sliceSerialize(b)}function Ft(b){J.call(this,b);const w=this.stack[this.stack.length-1];w.url="mailto:"+this.sliceSerialize(b)}function Bt(){return{type:"blockquote",children:[]}}function vn(){return{type:"code",lang:null,meta:null,value:""}}function Ru(){return{type:"inlineCode",value:""}}function zu(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Pu(){return{type:"emphasis",children:[]}}function Vs(){return{type:"heading",depth:0,children:[]}}function _s(){return{type:"break"}}function $s(){return{type:"html",value:""}}function Fu(){return{type:"image",title:null,url:"",alt:null}}function qs(){return{type:"link",title:null,url:"",children:[]}}function Ws(b){return{type:"list",ordered:b.type==="listOrdered",start:null,spread:b._spread,children:[]}}function Bu(b){return{type:"listItem",spread:b._spread,checked:null,children:[]}}function vu(){return{type:"paragraph",children:[]}}function Lu(){return{type:"strong",children:[]}}function Vu(){return{type:"text",value:""}}function _u(){return{type:"thematicBreak"}}}function rt(n){return{line:n.line,column:n.column,offset:n.offset}}function Xl(n,e){let t=-1;for(;++t<e.length;){const r=e[t];Array.isArray(r)?Xl(n,r):Af(n,r)}}function Af(n,e){let t;for(t in e)if(Gl.call(e,t))switch(t){case"canContainEols":{const r=e[t];r&&n[t].push(...r);break}case"transforms":{const r=e[t];r&&n[t].push(...r);break}case"enter":case"exit":{const r=e[t];r&&Object.assign(n[t],r);break}}}function po(n,e){throw n?new Error("Cannot close `"+n.type+"` ("+wn({start:n.start,end:n.end})+"): a different token (`"+e.type+"`, "+wn({start:e.start,end:e.end})+") is open"):new Error("Cannot close document, a token (`"+e.type+"`, "+wn({start:e.start,end:e.end})+") is still open")}function Di(n){const e=this;e.parser=t;function t(r){return Ef(r,{...e.data("settings"),...n,extensions:e.data("micromarkExtensions")||[],mdastExtensions:e.data("fromMarkdownExtensions")||[]})}}const mo={}.hasOwnProperty;function Df(n,e){const t=e||{};function r(i,...s){let o=r.invalid;const l=r.handlers;if(i&&mo.call(i,n)){const a=String(i[n]);o=mo.call(l,a)?l[a]:r.unknown}if(o)return o.call(this,i,...s)}return r.handlers=t.handlers||{},r.invalid=t.invalid,r.unknown=t.unknown,r}const Rf={}.hasOwnProperty;function Zl(n,e){let t=-1,r;if(e.extensions)for(;++t<e.extensions.length;)Zl(n,e.extensions[t]);for(r in e)if(Rf.call(e,r))switch(r){case"extensions":break;case"unsafe":{go(n[r],e[r]);break}case"join":{go(n[r],e[r]);break}case"handlers":{zf(n[r],e[r]);break}default:n.options[r]=e[r]}return n}function go(n,e){e&&n.push(...e)}function zf(n,e){e&&Object.assign(n,e)}function Pf(n,e,t,r){const i=t.enter("blockquote"),s=t.createTracker(r);s.move("> "),s.shift(2);const o=t.indentLines(t.containerFlow(n,s.current()),Ff);return i(),o}function Ff(n,e,t){return">"+(t?"":" ")+n}function ea(n,e){return yo(n,e.inConstruct,!0)&&!yo(n,e.notInConstruct,!1)}function yo(n,e,t){if(typeof e=="string"&&(e=[e]),!e||e.length===0)return t;let r=-1;for(;++r<e.length;)if(n.includes(e[r]))return!0;return!1}function ko(n,e,t,r){let i=-1;for(;++i<t.unsafe.length;)if(t.unsafe[i].character===`
8
- `&&ea(t.stack,t.unsafe[i]))return/[ \t]/.test(r.before)?"":" ";return`\\
9
- `}function Bf(n,e){const t=String(n);let r=t.indexOf(e),i=r,s=0,o=0;if(typeof e!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===i?++s>o&&(o=s):s=1,i=r+e.length,r=t.indexOf(e,i);return o}function Ri(n,e){return!!(e.options.fences===!1&&n.value&&!n.lang&&/[^ \r\n]/.test(n.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(n.value))}function vf(n){const e=n.options.fence||"`";if(e!=="`"&&e!=="~")throw new Error("Cannot serialize code with `"+e+"` for `options.fence`, expected `` ` `` or `~`");return e}function Lf(n,e,t,r){const i=vf(t),s=n.value||"",o=i==="`"?"GraveAccent":"Tilde";if(Ri(n,t)){const h=t.enter("codeIndented"),d=t.indentLines(s,Vf);return h(),d}const l=t.createTracker(r),a=i.repeat(Math.max(Bf(s,i)+1,3)),u=t.enter("codeFenced");let c=l.move(a);if(n.lang){const h=t.enter(`codeFencedLang${o}`);c+=l.move(t.safe(n.lang,{before:c,after:" ",encode:["`"],...l.current()})),h()}if(n.lang&&n.meta){const h=t.enter(`codeFencedMeta${o}`);c+=l.move(" "),c+=l.move(t.safe(n.meta,{before:c,after:`
10
- `,encode:["`"],...l.current()})),h()}return c+=l.move(`
11
- `),s&&(c+=l.move(s+`
12
- `)),c+=l.move(a),u(),c}function Vf(n,e,t){return(t?"":" ")+n}function ms(n){const e=n.options.quote||'"';if(e!=='"'&&e!=="'")throw new Error("Cannot serialize title with `"+e+"` for `options.quote`, expected `\"`, or `'`");return e}function _f(n,e,t,r){const i=ms(t),s=i==='"'?"Quote":"Apostrophe",o=t.enter("definition");let l=t.enter("label");const a=t.createTracker(r);let u=a.move("[");return u+=a.move(t.safe(t.associationId(n),{before:u,after:"]",...a.current()})),u+=a.move("]: "),l(),!n.url||/[\0- \u007F]/.test(n.url)?(l=t.enter("destinationLiteral"),u+=a.move("<"),u+=a.move(t.safe(n.url,{before:u,after:">",...a.current()})),u+=a.move(">")):(l=t.enter("destinationRaw"),u+=a.move(t.safe(n.url,{before:u,after:n.title?" ":`
13
- `,...a.current()}))),l(),n.title&&(l=t.enter(`title${s}`),u+=a.move(" "+i),u+=a.move(t.safe(n.title,{before:u,after:i,...a.current()})),u+=a.move(i),l()),o(),u}function $f(n){const e=n.options.emphasis||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize emphasis with `"+e+"` for `options.emphasis`, expected `*`, or `_`");return e}function dt(n){return"&#x"+n.toString(16).toUpperCase()+";"}function mr(n,e,t){const r=pr(n),i=pr(e);return r===void 0?i===void 0?t==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}ta.peek=qf;function ta(n,e,t,r){const i=$f(t),s=t.enter("emphasis"),o=t.createTracker(r),l=o.move(i);let a=o.move(t.containerPhrasing(n,{after:i,before:l,...o.current()}));const u=a.charCodeAt(0),c=mr(r.before.charCodeAt(r.before.length-1),u,i);c.inside&&(a=dt(u)+a.slice(1));const h=a.charCodeAt(a.length-1),d=mr(r.after.charCodeAt(0),h,i);d.inside&&(a=a.slice(0,-1)+dt(h));const f=o.move(i);return s(),t.attentionEncodeSurroundingInfo={after:d.outside,before:c.outside},l+a+f}function qf(n,e,t){return t.options.emphasis||"*"}const gs=(function(n){if(n==null)return Hf;if(typeof n=="function")return Or(n);if(typeof n=="object")return Array.isArray(n)?Wf(n):jf(n);if(typeof n=="string")return Jf(n);throw new Error("Expected function, string, or object as test")});function Wf(n){const e=[];let t=-1;for(;++t<n.length;)e[t]=gs(n[t]);return Or(r);function r(...i){let s=-1;for(;++s<e.length;)if(e[s].apply(this,i))return!0;return!1}}function jf(n){const e=n;return Or(t);function t(r){const i=r;let s;for(s in n)if(i[s]!==e[s])return!1;return!0}}function Jf(n){return Or(e);function e(t){return t&&t.type===n}}function Or(n){return e;function e(t,r,i){return!!(Kf(t)&&n.call(this,t,typeof r=="number"?r:void 0,i||void 0))}}function Hf(){return!0}function Kf(n){return n!==null&&typeof n=="object"&&"type"in n}const na=[],Uf=!0,zi=!1,Yf="skip";function Qf(n,e,t,r){let i;typeof e=="function"&&typeof t!="function"?(r=t,t=e):i=e;const s=gs(i),o=r?-1:1;l(n,void 0,[])();function l(a,u,c){const h=a&&typeof a=="object"?a:{};if(typeof h.type=="string"){const f=typeof h.tagName=="string"?h.tagName:typeof h.name=="string"?h.name:void 0;Object.defineProperty(d,"name",{value:"node ("+(a.type+(f?"<"+f+">":""))+")"})}return d;function d(){let f=na,p,y,x;if((!e||s(a,u,c[c.length-1]||void 0))&&(f=Gf(t(a,c)),f[0]===zi))return f;if("children"in a&&a.children){const k=a;if(k.children&&f[0]!==Yf)for(y=(r?k.children.length:-1)+o,x=c.concat(k);y>-1&&y<k.children.length;){const I=k.children[y];if(p=l(I,y,x)(),p[0]===zi)return p;y=typeof p[1]=="number"?p[1]:y+o}}return f}}}function Gf(n){return Array.isArray(n)?n:typeof n=="number"?[Uf,n]:n==null?na:[n]}function Xf(n,e,t,r){let i,s,o;typeof e=="function"&&typeof t!="function"?(s=void 0,o=e,i=t):(s=e,o=t,i=r),Qf(n,s,l,i);function l(a,u){const c=u[u.length-1],h=c?c.children.indexOf(a):void 0;return o(a,h,c)}}function ra(n,e){let t=!1;return Xf(n,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return t=!0,zi}),!!((!n.depth||n.depth<3)&&hs(n)&&(e.options.setext||t))}function Zf(n,e,t,r){const i=Math.max(Math.min(6,n.depth||1),1),s=t.createTracker(r);if(ra(n,t)){const c=t.enter("headingSetext"),h=t.enter("phrasing"),d=t.containerPhrasing(n,{...s.current(),before:`
1
+ import{n as e,r as t,t as n}from"./rolldown-runtime.js";function r(e){var t,n,i=``;if(typeof e==`string`||typeof e==`number`)i+=e;else if(typeof e==`object`)if(Array.isArray(e)){var a=e.length;for(t=0;t<a;t++)e[t]&&(n=r(e[t]))&&(i&&(i+=` `),i+=n)}else for(n in e)e[n]&&(i&&(i+=` `),i+=n);return i}function i(){for(var e,t,n=0,i=``,a=arguments.length;n<a;n++)(e=arguments[n])&&(t=r(e))&&(i&&(i+=` `),i+=t);return i}var a=function(e){return e.docTypeError=`docTypeError`,e.contextNotFound=`contextNotFound`,e.timerNotFound=`timerNotFound`,e.ctxCallOutOfScope=`ctxCallOutOfScope`,e.createNodeInParserFail=`createNodeInParserFail`,e.stackOverFlow=`stackOverFlow`,e.parserMatchError=`parserMatchError`,e.serializerMatchError=`serializerMatchError`,e.getAtomFromSchemaFail=`getAtomFromSchemaFail`,e.expectDomTypeError=`expectDomTypeError`,e.callCommandBeforeEditorView=`callCommandBeforeEditorView`,e.missingRootElement=`missingRootElement`,e.missingNodeInSchema=`missingNodeInSchema`,e.missingMarkInSchema=`missingMarkInSchema`,e.ctxNotBind=`ctxNotBind`,e.missingYjsDoc=`missingYjsDoc`,e}({}),o=class extends Error{constructor(e,t){super(t),this.name=`MilkdownError`,this.code=e}},s=(e,t)=>typeof t==`function`?`[Function]`:t,c=e=>JSON.stringify(e,s);function l(e){return new o(a.docTypeError,`Doc type error, unsupported type: ${c(e)}`)}function u(e){return new o(a.contextNotFound,`Context "${e}" not found, do you forget to inject it?`)}function d(e){return new o(a.timerNotFound,`Timer "${e}" not found, do you forget to record it?`)}function f(){return new o(a.ctxCallOutOfScope,`Should not call a context out of the plugin.`)}function p(e,t,n){let r=`Cannot create node for ${`name`in e?e.name:e}`,i=e=>{if(e==null)return`null`;if(Array.isArray(e))return`[${e.map(i).join(`, `)}]`;if(typeof e==`object`)return`toJSON`in e&&typeof e.toJSON==`function`?JSON.stringify(e.toJSON()):`spec`in e?JSON.stringify(e.spec):JSON.stringify(e);if(typeof e==`string`||typeof e==`number`||typeof e==`boolean`)return JSON.stringify(e);if(typeof e==`function`)return`[Function: ${e.name||`anonymous`}]`;try{return String(e)}catch{return`[Unserializable]`}},s=[[`[Description]`,r],[`[Attributes]`,t],[`[Content]`,(n??[]).map(e=>e?typeof e==`object`&&`type`in e?`${e}`:i(e):`null`)]].reduce((e,[t,n])=>{let r=`${t}: ${i(n)}.`;return e.concat(r)},[]);return new o(a.createNodeInParserFail,s.join(`
2
+ `))}function m(){return new o(a.stackOverFlow,`Stack over flow, cannot pop on an empty stack.`)}function h(e){return new o(a.parserMatchError,`Cannot match target parser for node: ${c(e)}.`)}function g(e){return new o(a.serializerMatchError,`Cannot match target serializer for node: ${c(e)}.`)}function _(e){return new o(a.expectDomTypeError,`Expect to be a dom, but get: ${c(e)}.`)}function v(){return new o(a.callCommandBeforeEditorView,`You're trying to call a command before editor view initialized, make sure to get commandManager from ctx after editor view has been initialized`)}function y(e){return new o(a.missingNodeInSchema,`Missing node in schema, milkdown cannot find "${e}" in schema.`)}function b(e){return new o(a.missingMarkInSchema,`Missing mark in schema, milkdown cannot find "${e}" in schema.`)}var x=class{constructor(){this.sliceMap=new Map,this.get=e=>{let t=typeof e==`string`?[...this.sliceMap.values()].find(t=>t.type.name===e):this.sliceMap.get(e.id);if(!t)throw u(typeof e==`string`?e:e.name);return t},this.remove=e=>{let t=typeof e==`string`?[...this.sliceMap.values()].find(t=>t.type.name===e):this.sliceMap.get(e.id);t&&this.sliceMap.delete(t.type.id)},this.has=e=>typeof e==`string`?[...this.sliceMap.values()].some(t=>t.type.name===e):this.sliceMap.has(e.id)}},ee=class{#e=[];#t;#n=()=>{this.#e.forEach(e=>e(this.#t))};constructor(e,t,n){this.set=e=>{this.#t=e,this.#n()},this.get=()=>this.#t,this.update=e=>{this.#t=e(this.#t),this.#n()},this.type=n,this.#t=t,e.set(n.id,this)}on(e){return this.#e.push(e),()=>{this.#e=this.#e.filter(t=>t!==e)}}once(e){let t=this.on(n=>{e(n),t()});return t}off(e){this.#e=this.#e.filter(t=>t!==e)}offAll(){this.#e=[]}},te=class{constructor(e,t){this.id=Symbol(`Context-${t}`),this.name=t,this._defaultValue=e,this._typeInfo=()=>{throw f()}}create(e,t=this._defaultValue){return new ee(e,t,this)}},S=(e,t)=>new te(e,t),C=class{#e;#t;#n;#r=new Set;#i=new Set;#a=new Map;#o=new Map;constructor(e,t,n){this.read=()=>({metadata:this.#e,injectedSlices:[...this.#r].map(e=>({name:typeof e==`string`?e:e.name,value:this.#s(e)})),consumedSlices:[...this.#i].map(e=>({name:typeof e==`string`?e:e.name,value:this.#s(e)})),recordedTimers:[...this.#a].map(([e,{duration:t}])=>({name:e.name,duration:t,status:this.#c(e)})),waitTimers:[...this.#o].map(([e,{duration:t}])=>({name:e.name,duration:t,status:this.#c(e)}))}),this.onRecord=e=>{this.#a.set(e,{start:Date.now(),duration:0})},this.onClear=e=>{this.#a.delete(e)},this.onDone=e=>{let t=this.#a.get(e);t&&(t.duration=Date.now()-t.start)},this.onWait=(e,t)=>{let n=Date.now();t.finally(()=>{this.#o.set(e,{duration:Date.now()-n})}).catch(console.error)},this.onInject=e=>{this.#r.add(e)},this.onRemove=e=>{this.#r.delete(e)},this.onUse=e=>{this.#i.add(e)},this.#t=e,this.#n=t,this.#e=n}#s=e=>this.#t.get(e).get();#c=e=>this.#n.get(e).status},w=class e{#e;#t;#n;#r;constructor(t,n,r){this.produce=t=>t&&Object.keys(t).length?new e(this.#e,this.#t,{...t}):this,this.inject=(e,t)=>{let n=e.create(this.#e.sliceMap);return t!=null&&n.set(t),this.#r?.onInject(e),this},this.remove=e=>(this.#e.remove(e),this.#r?.onRemove(e),this),this.record=e=>(e.create(this.#t.store),this.#r?.onRecord(e),this),this.clearTimer=e=>(this.#t.remove(e),this.#r?.onClear(e),this),this.isInjected=e=>this.#e.has(e),this.isRecorded=e=>this.#t.has(e),this.use=e=>(this.#r?.onUse(e),this.#e.get(e)),this.get=e=>this.use(e).get(),this.set=(e,t)=>this.use(e).set(t),this.update=(e,t)=>this.use(e).update(t),this.timer=e=>this.#t.get(e),this.done=e=>{this.timer(e).done(),this.#r?.onDone(e)},this.wait=e=>{let t=this.timer(e).start();return this.#r?.onWait(e,t),t},this.waitTimers=async e=>{await Promise.all(this.get(e).map(e=>this.wait(e)))},this.#e=t,this.#t=n,this.#n=r,r&&(this.#r=new C(t,n,r))}get meta(){return this.#n}get inspector(){return this.#r}},ne=class{constructor(){this.store=new Map,this.get=e=>{let t=this.store.get(e.id);if(!t)throw d(e.name);return t},this.remove=e=>{this.store.delete(e.id)},this.has=e=>this.store.has(e.id)}},T=class{#e=null;#t=null;#n;#r=`pending`;constructor(e,t){this.start=()=>(this.#e??=new Promise((e,t)=>{this.#t=t=>{t instanceof CustomEvent&&t.detail.id===this.#n&&(this.#r=`resolved`,this.#i(),t.stopImmediatePropagation(),e())},this.#a(()=>{this.#r===`pending`&&(this.#r=`rejected`),this.#i(),t(Error(`Timing ${this.type.name} timeout.`))}),this.#r=`pending`,addEventListener(this.type.name,this.#t)}),this.#e),this.done=()=>{let e=new CustomEvent(this.type.name,{detail:{id:this.#n}});dispatchEvent(e)},this.#n=Symbol(t.name),this.type=t,e.set(t.id,this)}get status(){return this.#r}#i=()=>{this.#t&&removeEventListener(this.type.name,this.#t)};#a=e=>{setTimeout(()=>{e()},this.type.timeout)}},re=class{constructor(e,t=3e3){this.create=e=>new T(e,this),this.id=Symbol(`Timer-${e}`),this.name=e,this.timeout=t}},E=(e,t=3e3)=>new re(e,t),ie={};function ae(e,t){let n=t||ie;return oe(e,typeof n.includeImageAlt==`boolean`?n.includeImageAlt:!0,typeof n.includeHtml==`boolean`?n.includeHtml:!0)}function oe(e,t,n){if(ce(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return se(e.children,t,n)}return Array.isArray(e)?se(e,t,n):``}function se(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=oe(e[i],t,n);return r.join(``)}function ce(e){return!!(e&&typeof e==`object`)}var le=document.createElement(`i`);function ue(e){let t=`&`+e+`;`;le.innerHTML=t;let n=le.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`||n===t?!1:n}function D(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function de(e,t){return e.length>0?(D(e,e.length,0,t),e):t}var fe={}.hasOwnProperty;function pe(e){let t={},n=-1;for(;++n<e.length;)me(t,e[n]);return t}function me(e,t){let n;for(n in t){let r=(fe.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){fe.call(r,a)||(r[a]=[]);let e=i[a];he(r[a],Array.isArray(e)?e:e?[e]:[])}}}function he(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);D(e,0,0,r)}function ge(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)==65535||(n&65535)==65534||n>1114111?`�`:String.fromCodePoint(n)}function _e(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var ve=De(/[A-Za-z]/),ye=De(/[\dA-Za-z]/),be=De(/[#-'*+\--9=?A-Z^-~]/);function xe(e){return e!==null&&(e<32||e===127)}var Se=De(/\d/),Ce=De(/[\dA-Fa-f]/),we=De(/[!-/:-@[-`{-~]/);function O(e){return e!==null&&e<-2}function k(e){return e!==null&&(e<0||e===32)}function A(e){return e===-2||e===-1||e===32}var Te=De(/\p{P}|\p{S}/u),Ee=De(/\s/);function De(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function j(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return A(r)?(e.enter(n),s(r)):t(r)}function s(r){return A(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var Oe={tokenize:ke};function ke(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null){e.consume(n);return}return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),j(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null){e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);return}return O(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var Ae={tokenize:Me},je={tokenize:Ne};function Me(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;return D(t.events,a+1,0,t.events.slice(n)),t.events.length=s,l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(je,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(je,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null){i&&v(),_(0),e.consume(n);return}return i||=t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null){g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);return}return O(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;D(t.events,a+1,0,t.events.slice(n)),t.events.length=e}}function _(r){let i=n.length;for(;i-- >r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function Ne(e,t,n){return j(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function Pe(e){if(e===null||k(e)||Ee(e))return 1;if(Te(e))return 2}function Fe(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}var Ie={name:`attention`,resolveAll:Le,tokenize:Re};function Le(e,t){let n=-1,r,i,a,o,s,c,l,u;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===`exit`&&e[r][1].type===`attentionSequence`&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},f={...e[n][1].start};ze(d,-c),ze(f,c),o={type:c>1?`strongSequence`:`emphasisSequence`,start:d,end:{...e[r][1].end}},s={type:c>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:f},a={type:c>1?`strongText`:`emphasisText`,start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?`strong`:`emphasis`,start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=de(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=de(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=de(l,Fe(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=de(l,[[`exit`,a,t],[`enter`,s,t],[`exit`,s,t],[`exit`,i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,l=de(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,D(e,r-1,n-r+3,l),n=r+l.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function Re(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Pe(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=Pe(o),u=!l||l===2&&i||n.includes(o),d=!i||i===2&&l||n.includes(r);return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function ze(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var Be={name:`autolink`,tokenize:Ve};function Ve(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return ve(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||ye(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||ye(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||xe(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):be(t)?(e.consume(t),l):n(t)}function u(e){return ye(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||ye(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var He={partial:!0,tokenize:Ue};function Ue(e,t,n){return r;function r(t){return A(t)?j(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||O(e)?t(e):n(e)}}var We={continuation:{tokenize:Ke},exit:qe,name:`blockQuote`,tokenize:Ge};function Ge(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return A(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function Ke(e,t,n){let r=this;return i;function i(t){return A(t)?j(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(We,t,n)(r)}}function qe(e){e.exit(`blockQuote`)}var Je={name:`characterEscape`,tokenize:Ye};function Ye(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return we(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var Xe={name:`characterReference`,tokenize:Ze};function Ze(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=ye,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=Ce,u):(e.enter(`characterReferenceValue`),a=7,o=Se,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===ye&&!ue(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}var Qe={partial:!0,tokenize:tt},$e={concrete:!0,name:`codeFenced`,tokenize:et};function et(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),A(t)?j(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||O(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(Qe,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||O(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):A(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),j(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||O(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||O(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&A(t)?j(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||O(t)?e.check(Qe,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||O(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),A(t)?j(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),A(t)?j(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||O(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function tt(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var nt={name:`codeIndented`,tokenize:it},rt={partial:!0,tokenize:at};function it(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),j(e,a,`linePrefix`,5)(t)}function a(e){let t=r.events[r.events.length-1];return t&&t[1].type===`linePrefix`&&t[2].sliceSerialize(t[1],!0).length>=4?o(e):n(e)}function o(t){return t===null?c(t):O(t)?e.attempt(rt,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||O(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function at(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):O(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):j(e,a,`linePrefix`,5)(t)}function a(e){let a=r.events[r.events.length-1];return a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):O(e)?i(e):n(e)}}var ot={name:`codeText`,previous:ct,resolve:st,tokenize:lt};function st(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function ct(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function lt(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):O(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||O(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var ut=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&dt(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),dt(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),dt(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e<this.left.length){let t=this.left.splice(e,1/0);dt(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);dt(this.left,t.reverse())}}};function dt(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function ft(e){let t={},n=-1,r,i,a,o,s,c,l,u=new ut(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,pt(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(!(o[1].type===`linePrefix`||o[1].type===`listItemIndent`))break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return D(e,0,1/0,u.slice(0)),!l}function pt(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}var mt={resolve:gt,tokenize:_t},ht={partial:!0,tokenize:vt};function gt(e){return ft(e),e}function _t(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):O(t)?e.check(ht,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function vt(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),j(e,a,`linePrefix`)}function a(i){if(i===null||O(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function yt(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||xe(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||O(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||k(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||xe(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function bt(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):O(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||O(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!A(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function xt(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):O(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),j(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||O(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function St(e,t){let n;return r;function r(i){return O(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):A(i)?j(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var Ct={name:`definition`,tokenize:Tt},wt={partial:!0,tokenize:Et};function Tt(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return bt.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=_e(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return k(t)?St(e,l)(t):l(t)}function l(t){return yt(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(wt,d,d)(t)}function d(t){return A(t)?j(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||O(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function Et(e,t,n){return r;function r(t){return k(t)?St(e,i)(t):n(t)}function i(t){return xt(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return A(t)?j(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||O(e)?t(e):n(e)}}var Dt={name:`hardBreakEscape`,tokenize:Ot};function Ot(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return O(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var kt={name:`headingAtx`,resolve:At,tokenize:jt};function At(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type===`whitespace`&&(r+=2),n-2>r&&e[n][1].type===`whitespace`&&(n-=2),e[n][1].type===`atxHeadingSequence`&&(r===n-1||n-4>r&&e[n-2][1].type===`whitespace`)&&(n-=r+1===n?2:4),n>r&&(i={type:`atxHeadingText`,start:e[r][1].start,end:e[n][1].end},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`},D(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function jt(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||k(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||O(n)?(e.exit(`atxHeading`),t(n)):A(n)?j(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||k(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var Mt=`address.article.aside.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),Nt=[`pre`,`script`,`style`,`textarea`],Pt={concrete:!0,name:`htmlFlow`,resolveTo:Lt,tokenize:Rt},Ft={partial:!0,tokenize:Bt},It={partial:!0,tokenize:zt};function Lt(e){let t=e.length;for(;t--&&!(e[t][0]===`enter`&&e[t][1].type===`htmlFlow`););return t>1&&e[t-2][1].type===`linePrefix`&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function Rt(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:le):ve(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):ve(a)?(e.consume(a),i=4,r.interrupt?t:le):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:le):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:T:m):n(i)}function h(t){return ve(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||k(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&Nt.includes(l)?(i=1,r.interrupt?t(s):T(s)):Mt.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):T(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||ye(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:T):n(i)}function v(t){return A(t)?(e.consume(t),v):w(t)}function y(t){return t===47?(e.consume(t),w):t===58||t===95||ve(t)?(e.consume(t),b):A(t)?(e.consume(t),y):w(t)}function b(t){return t===45||t===46||t===58||t===95||ye(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),ee):A(t)?(e.consume(t),x):y(t)}function ee(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,te):A(t)?(e.consume(t),ee):S(t)}function te(t){return t===c?(e.consume(t),c=null,C):t===null||O(t)?n(t):(e.consume(t),te)}function S(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||k(t)?x(t):(e.consume(t),S)}function C(e){return e===47||e===62||A(e)?y(e):n(e)}function w(t){return t===62?(e.consume(t),ne):n(t)}function ne(t){return t===null||O(t)?T(t):A(t)?(e.consume(t),ne):n(t)}function T(t){return t===45&&i===2?(e.consume(t),ae):t===60&&i===1?(e.consume(t),oe):t===62&&i===4?(e.consume(t),ue):t===63&&i===3?(e.consume(t),le):t===93&&i===5?(e.consume(t),ce):O(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(Ft,D,re)(t)):t===null||O(t)?(e.exit(`htmlFlowData`),re(t)):(e.consume(t),T)}function re(t){return e.check(It,E,D)(t)}function E(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),ie}function ie(t){return t===null||O(t)?re(t):(e.enter(`htmlFlowData`),T(t))}function ae(t){return t===45?(e.consume(t),le):T(t)}function oe(t){return t===47?(e.consume(t),o=``,se):T(t)}function se(t){if(t===62){let n=o.toLowerCase();return Nt.includes(n)?(e.consume(t),ue):T(t)}return ve(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),se):T(t)}function ce(t){return t===93?(e.consume(t),le):T(t)}function le(t){return t===62?(e.consume(t),ue):t===45&&i===2?(e.consume(t),le):T(t)}function ue(t){return t===null||O(t)?(e.exit(`htmlFlowData`),D(t)):(e.consume(t),ue)}function D(n){return e.exit(`htmlFlow`),t(n)}}function zt(e,t,n){let r=this;return i;function i(t){return O(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a):n(t)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function Bt(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(He,t,n)}}var Vt={name:`htmlText`,tokenize:Ht};function Ht(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):ve(t)?(e.consume(t),S):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):ve(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):O(t)?(o=d,oe(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?ae(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):O(t)?(o=h,oe(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?ae(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?ae(t):O(t)?(o=v,oe(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):O(t)?(o=y,oe(t)):(e.consume(t),y)}function b(e){return e===62?ae(e):y(e)}function x(t){return ve(t)?(e.consume(t),ee):n(t)}function ee(t){return t===45||ye(t)?(e.consume(t),ee):te(t)}function te(t){return O(t)?(o=te,oe(t)):A(t)?(e.consume(t),te):ae(t)}function S(t){return t===45||ye(t)?(e.consume(t),S):t===47||t===62||k(t)?C(t):n(t)}function C(t){return t===47?(e.consume(t),ae):t===58||t===95||ve(t)?(e.consume(t),w):O(t)?(o=C,oe(t)):A(t)?(e.consume(t),C):ae(t)}function w(t){return t===45||t===46||t===58||t===95||ye(t)?(e.consume(t),w):ne(t)}function ne(t){return t===61?(e.consume(t),T):O(t)?(o=ne,oe(t)):A(t)?(e.consume(t),ne):C(t)}function T(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,re):O(t)?(o=T,oe(t)):A(t)?(e.consume(t),T):(e.consume(t),E)}function re(t){return t===i?(e.consume(t),i=void 0,ie):t===null?n(t):O(t)?(o=re,oe(t)):(e.consume(t),re)}function E(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||k(t)?C(t):(e.consume(t),E)}function ie(e){return e===47||e===62||k(e)?C(e):n(e)}function ae(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function oe(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),se}function se(t){return A(t)?j(e,ce,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):ce(t)}function ce(t){return e.enter(`htmlTextData`),o(t)}}var Ut={name:`labelEnd`,resolveAll:qt,resolveTo:Jt,tokenize:Yt},Wt={tokenize:Xt},Gt={tokenize:Zt},Kt={tokenize:Qt};function qt(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&D(e,0,e.length,n),e}function Jt(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type===`link`||i.type===`labelLink`&&i._inactive)break;e[n][0]===`enter`&&i.type===`labelLink`&&(i._inactive=!0)}else if(o){if(e[n][0]===`enter`&&(i.type===`labelImage`||i.type===`labelLink`)&&!i._balanced&&(a=n,i.type!==`labelLink`)){r=2;break}}else i.type===`labelEnd`&&(o=n);let c={type:e[a][1].type===`labelLink`?`link`:`image`,start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:`label`,start:{...e[a][1].start},end:{...e[o][1].end}},u={type:`labelText`,start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[`enter`,c,t],[`enter`,l,t]],s=de(s,e.slice(a+1,a+r+3)),s=de(s,[[`enter`,u,t]]),s=de(s,Fe(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=de(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=de(s,e.slice(o+1)),s=de(s,[[`exit`,c,t]]),D(e,a,e.length,s),e}function Yt(e,t,n){let r=this,i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type===`labelImage`||r.events[i][1].type===`labelLink`)&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(_e(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(Wt,u,o?u:d)(t):t===91?e.attempt(Gt,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(Kt,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function Xt(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return k(t)?St(e,a)(t):a(t)}function a(t){return t===41?u(t):yt(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return k(t)?St(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?xt(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return k(t)?St(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function Zt(e,t,n){let r=this;return i;function i(t){return bt.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(_e(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function Qt(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}var $t={name:`labelStartImage`,resolveAll:Ut.resolveAll,tokenize:en};function en(e,t,n){let r=this;return i;function i(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),a}function a(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelImage`),o):n(t)}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var tn={name:`labelStartLink`,resolveAll:Ut.resolveAll,tokenize:nn};function nn(e,t,n){let r=this;return i;function i(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelLink`),a}function a(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var rn={name:`lineEnding`,tokenize:an};function an(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),j(e,t,`linePrefix`)}}var on={name:`thematicBreak`,tokenize:sn};function sn(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||O(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),A(t)?j(e,s,`whitespace`)(t):s(t))}}var M={continuation:{tokenize:dn},exit:pn,name:`list`,tokenize:un},cn={partial:!0,tokenize:mn},ln={partial:!0,tokenize:fn};function un(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:Se(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(on,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return Se(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check(He,r.interrupt?n:u,e.attempt(cn,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return A(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function dn(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(He,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,j(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!A(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(ln,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,j(e,e.attempt(M,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function fn(e,t,n){let r=this;return j(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function pn(e){e.exit(this.containerState.type)}function mn(e,t,n){let r=this;return j(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!A(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var hn={name:`setextUnderline`,resolveTo:gn,tokenize:_n};function gn(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]===`enter`){if(e[n][1].type===`content`){r=n;break}e[n][1].type===`paragraph`&&(i=n)}else e[n][1].type===`content`&&e.splice(n,1),!a&&e[n][1].type===`definition`&&(a=n);let o={type:`setextHeading`,start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=`setextHeadingText`,a?(e.splice(i,0,[`enter`,o,t]),e.splice(a+1,0,[`exit`,e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push([`exit`,o,t]),e}function _n(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),A(t)?j(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||O(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var vn={tokenize:yn};function yn(e){let t=this,n=e.attempt(He,r,e.attempt(this.parser.constructs.flowInitial,i,j(e,e.attempt(this.parser.constructs.flow,i,e.attempt(mt,i)),`linePrefix`)));return n;function r(r){if(r===null){e.consume(r);return}return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null){e.consume(r);return}return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var bn={resolveAll:wn()},xn=Cn(`string`),Sn=Cn(`text`);function Cn(e){return{resolveAll:wn(e===`text`?Tn:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null){t.consume(e);return}return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function wn(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):(!t[r]||t[r][1].type!==`data`)&&(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function Tn(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===`lineEnding`)&&e[n-1][1].type===`data`){let r=e[n-1][1],i=t.sliceStream(r),a=i.length,o=-1,s=0,c;for(;a--;){let e=i[a];if(typeof e==`string`){for(o=e.length;e.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(e===-2)c=!0,s++;else if(e!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){let i={type:n===e.length||c||s<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...i.start},r.start.offset===r.end.offset?Object.assign(r,i):(e.splice(n,0,[`enter`,i,t],[`exit`,i,t]),n+=2)}n++}return e}var En=e({attentionMarkers:()=>Pn,contentInitial:()=>On,disable:()=>Fn,document:()=>Dn,flow:()=>An,flowInitial:()=>kn,insideSpan:()=>Nn,string:()=>jn,text:()=>Mn}),Dn={42:M,43:M,45:M,48:M,49:M,50:M,51:M,52:M,53:M,54:M,55:M,56:M,57:M,62:We},On={91:Ct},kn={[-2]:nt,[-1]:nt,32:nt},An={35:kt,42:on,45:[hn,on],60:Pt,61:hn,95:on,96:$e,126:$e},jn={38:Xe,92:Je},Mn={[-5]:rn,[-4]:rn,[-3]:rn,33:$t,38:Xe,42:Ie,60:[Be,Vt],91:tn,92:[Dt,Je],93:Ut,95:Ie,96:ot},Nn={null:[Ie,bn]},Pn={null:[42,95]},Fn={null:[]};function In(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:te(x),check:te(ee),consume:v,enter:y,exit:b,interrupt:te(ee,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=de(o,e),g(),o[o.length-1]===null?(S(t,0),l.events=Fe(a,l.events,l),l.events):[]}function f(e,t){return Rn(p(e),t)}function p(e){return Ln(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,w()}function g(){let e;for(;r._index<o.length;){let t=o[r._index];if(typeof t==`string`)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)_(t.charCodeAt(r._bufferIndex));else _(t)}}function _(e){u=u(e)}function v(e){O(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,w()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){S(e,t.from)}function ee(e,t){t.restore()}function te(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=C(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function S(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&D(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function C(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,w()}}function w(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function Ln(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function Rn(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\r`;break;case-4:o=`
3
+ `;break;case-3:o=`\r
4
+ `;break;case-2:o=t?` `:` `;break;case-1:if(!t&&i)continue;o=` `;break;default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(``)}function zn(e){let t={constructs:pe([En,...(e||{}).extensions||[]]),content:n(Oe),defined:[],document:n(Ae),flow:n(vn),lazy:{},string:n(xn),text:n(Sn)};return t;function n(e){return n;function n(n){return In(t,e,n)}}}function Bn(e){for(;!ft(e););return e}var Vn=/[\0\t\n\r]/g;function Hn(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){let s=[],c,l,u,d,f;for(i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i)),u=0,t=``,n&&=(i.charCodeAt(0)===65279&&u++,void 0);u<i.length;){if(Vn.lastIndex=u,c=Vn.exec(i),d=c&&c.index!==void 0?c.index:i.length,f=i.charCodeAt(d),!c){t=i.slice(u);break}if(f===10&&u===d&&r)s.push(-3),r=void 0;else switch(r&&=(s.push(-5),void 0),u<d&&(s.push(i.slice(u,d)),e+=d-u),f){case 0:s.push(65533),e++;break;case 9:for(l=Math.ceil(e/4)*4,s.push(-2);e++<l;)s.push(-1);break;case 10:s.push(-4),e=1;break;default:r=!0,e=1}u=d+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}var Un=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Wn(e){return e.replace(Un,Gn)}function Gn(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return ge(n.slice(t?2:1),t?16:10)}return ue(n)||e}function Kn(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?Jn(e.position):`start`in e||`end`in e?Jn(e):`line`in e||`column`in e?qn(e):``}function qn(e){return Yn(e&&e.line)+`:`+Yn(e&&e.column)}function Jn(e){return qn(e&&e.start)+`-`+qn(e&&e.end)}function Yn(e){return e&&typeof e==`number`?e:1}var Xn={}.hasOwnProperty;function Zn(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),Qn(n)(Bn(zn(n).document().write(Hn()(e,t,!0))))}function Qn(e){let t={transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:a(j),autolinkProtocol:C,autolinkEmail:C,atxHeading:a(A),blockQuote:a(Se),characterEscape:C,characterReference:C,codeFenced:a(Ce),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(Ce,o),codeText:a(we,o),codeTextData:C,data:C,codeFlowValue:C,definition:a(O),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(k),hardBreakEscape:a(Te),hardBreakTrailing:a(Te),htmlFlow:a(Ee,o),htmlFlowData:C,htmlText:a(Ee,o),htmlTextData:C,image:a(De),label:o,link:a(j),listItem:a(ke),listItemValue:f,listOrdered:a(Oe,d),listUnordered:a(Oe),paragraph:a(Ae),reference:pe,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(A),strong:a(je),thematicBreak:a(Ne)},exit:{atxHeading:c(),atxHeadingSequence:x,autolink:c(),autolinkEmail:xe,autolinkProtocol:be,blockQuote:c(),characterEscapeValue:w,characterReferenceMarkerHexadecimal:he,characterReferenceMarkerNumeric:he,characterReferenceValue:ve,characterReference:ye,codeFenced:c(g),codeFencedFence:h,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:w,codeIndented:c(_),codeText:c(ie),codeTextData:w,data:w,definition:c(),definitionDestinationString:b,definitionLabelString:v,definitionTitleString:y,emphasis:c(),hardBreakEscape:c(T),hardBreakTrailing:c(T),htmlFlow:c(re),htmlFlowData:w,htmlText:c(E),htmlTextData:w,image:c(se),label:le,labelText:ce,lineEnding:ne,link:c(oe),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:me,resourceDestinationString:D,resourceTitleString:de,resource:fe,setextHeading:c(S),setextHeadingLineSequence:te,setextHeadingText:ee,strong:c(),thematicBreak:c()}};er(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(e){let r={type:`root`,children:[]},a={stack:[r],tokenStack:[],config:t,enter:s,exit:l,buffer:o,resume:u,data:n},c=[],d=-1;for(;++d<e.length;)(e[d][1].type===`listOrdered`||e[d][1].type===`listUnordered`)&&(e[d][0]===`enter`?c.push(d):d=i(e,c.pop(),d));for(d=-1;++d<e.length;){let n=t[e[d][0]];Xn.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},a),e[d][1])}if(a.tokenStack.length>0){let e=a.tokenStack[a.tokenStack.length-1];(e[1]||nr).call(a,void 0,e[0])}for(r.position={start:$n(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:$n(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)r=t.transforms[d](r)||r;return r}function i(e,t,n){let r=t-1,i=-1,a=!1,o,s,c,l;for(;++r<=n;){let t=e[r];switch(t[1].type){case`listUnordered`:case`listOrdered`:case`blockQuote`:t[0]===`enter`?i++:i--,l=void 0;break;case`lineEndingBlank`:t[0]===`enter`&&(o&&!l&&!i&&!c&&(c=r),l=void 0);break;case`linePrefix`:case`listItemValue`:case`listItemMarker`:case`listItemPrefix`:case`listItemPrefixWhitespace`:break;default:l=void 0}if(!i&&t[0]===`enter`&&t[1].type===`listItemPrefix`||i===-1&&t[0]===`exit`&&(t[1].type===`listUnordered`||t[1].type===`listOrdered`)){if(o){let i=r;for(s=void 0;i--;){let t=e[i];if(t[1].type===`lineEnding`||t[1].type===`lineEndingBlank`){if(t[0]===`exit`)continue;s&&(e[s][1].type=`lineEndingBlank`,a=!0),t[1].type=`lineEnding`,s=i}else if(!(t[1].type===`linePrefix`||t[1].type===`blockQuotePrefix`||t[1].type===`blockQuotePrefixWhitespace`||t[1].type===`blockQuoteMarker`||t[1].type===`listItemIndent`))break}c&&(!s||c<s)&&(o._spread=!0),o.end=Object.assign({},s?e[s][1].start:t[1].end),e.splice(s||r,0,[`exit`,o,t[2]]),r++,n++}if(t[1].type===`listItemPrefix`){let i={type:`listItem`,_spread:!1,start:Object.assign({},t[1].start),end:void 0};o=i,e.splice(r,0,[`enter`,i,t[2]]),r++,n++,c=void 0,l=!0}}}return e[t][1]._spread=a,n}function a(e,t){return n;function n(n){s.call(this,e(n),n),t&&t.call(this,n)}}function o(){this.stack.push({type:`fragment`,children:[]})}function s(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:$n(t.start),end:void 0}}function c(e){return t;function t(t){e&&e.call(this,t),l.call(this,t)}}function l(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||nr).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+Kn({start:e.start,end:e.end})+`): it’s not open`);n.position.end=$n(e.end)}function u(){return ae(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(e){if(this.data.expectingFirstListItemValue){let t=this.stack[this.stack.length-2];t.start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function p(){let e=this.resume(),t=this.stack[this.stack.length-1];t.lang=e}function m(){let e=this.resume(),t=this.stack[this.stack.length-1];t.meta=e}function h(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``),this.data.flowCodeInside=void 0}function _(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/(\r?\n|\r)$/g,``)}function v(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=_e(this.sliceSerialize(e)).toLowerCase()}function y(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function b(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function x(e){let t=this.stack[this.stack.length-1];t.depth||=this.sliceSerialize(e).length}function ee(){this.data.setextHeadingSlurpLineEnding=!0}function te(e){let t=this.stack[this.stack.length-1];t.depth=this.sliceSerialize(e).codePointAt(0)===61?1:2}function S(){this.data.setextHeadingSlurpLineEnding=void 0}function C(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];(!n||n.type!==`text`)&&(n=Me(),n.position={start:$n(e.start),end:void 0},t.push(n)),this.stack.push(n)}function w(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=$n(e.end)}function ne(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){let t=n.children[n.children.length-1];t.position.end=$n(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(C.call(this,e),w.call(this,e))}function T(){this.data.atHardBreak=!0}function re(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function E(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function ie(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function oe(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function se(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function ce(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=Wn(t),n.identifier=_e(t).toLowerCase()}function le(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,n.type===`link`?n.children=e.children:n.alt=t}function D(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function de(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function fe(){this.data.inReference=void 0}function pe(){this.data.referenceType=`collapsed`}function me(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=_e(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function he(e){this.data.characterReferenceType=e.type}function ve(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=ge(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=ue(t);let i=this.stack[this.stack.length-1];i.value+=r}function ye(e){let t=this.stack.pop();t.position.end=$n(e.end)}function be(e){w.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function xe(e){w.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function Se(){return{type:`blockquote`,children:[]}}function Ce(){return{type:`code`,lang:null,meta:null,value:``}}function we(){return{type:`inlineCode`,value:``}}function O(){return{type:`definition`,identifier:``,label:null,title:null,url:``}}function k(){return{type:`emphasis`,children:[]}}function A(){return{type:`heading`,depth:0,children:[]}}function Te(){return{type:`break`}}function Ee(){return{type:`html`,value:``}}function De(){return{type:`image`,title:null,url:``,alt:null}}function j(){return{type:`link`,title:null,url:``,children:[]}}function Oe(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[]}}function ke(e){return{type:`listItem`,spread:e._spread,checked:null,children:[]}}function Ae(){return{type:`paragraph`,children:[]}}function je(){return{type:`strong`,children:[]}}function Me(){return{type:`text`,value:``}}function Ne(){return{type:`thematicBreak`}}}function $n(e){return{line:e.line,column:e.column,offset:e.offset}}function er(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?er(e,r):tr(e,r)}}function tr(e,t){let n;for(n in t)if(Xn.call(t,n))switch(n){case`canContainEols`:{let r=t[n];r&&e[n].push(...r);break}case`transforms`:{let r=t[n];r&&e[n].push(...r);break}case`enter`:case`exit`:{let r=t[n];r&&Object.assign(e[n],r);break}}}function nr(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+Kn({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Kn({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+Kn({start:t.start,end:t.end})+`) is still open`)}function rr(e){let t=this;t.parser=n;function n(n){return Zn(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}var ir={}.hasOwnProperty;function ar(e,t){let n=t||{};function r(t,...n){let i=r.invalid,a=r.handlers;if(t&&ir.call(t,e)){let n=String(t[e]);i=ir.call(a,n)?a[n]:r.unknown}if(i)return i.call(this,t,...n)}return r.handlers=n.handlers||{},r.invalid=n.invalid,r.unknown=n.unknown,r}var or={}.hasOwnProperty;function sr(e,t){let n=-1,r;if(t.extensions)for(;++n<t.extensions.length;)sr(e,t.extensions[n]);for(r in t)if(or.call(t,r))switch(r){case`extensions`:break;case`unsafe`:cr(e[r],t[r]);break;case`join`:cr(e[r],t[r]);break;case`handlers`:lr(e[r],t[r]);break;default:e.options[r]=t[r]}return e}function cr(e,t){t&&e.push(...t)}function lr(e,t){t&&Object.assign(e,t)}function ur(e,t,n,r){let i=n.enter(`blockquote`),a=n.createTracker(r);a.move(`> `),a.shift(2);let o=n.indentLines(n.containerFlow(e,a.current()),dr);return i(),o}function dr(e,t,n){return`>`+(n?``:` `)+e}function fr(e,t){return pr(e,t.inConstruct,!0)&&!pr(e,t.notInConstruct,!1)}function pr(e,t,n){if(typeof t==`string`&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function mr(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
5
+ `&&fr(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?``:` `;return`\\
6
+ `}function hr(e,t){let n=String(e),r=n.indexOf(t),i=r,a=0,o=0;if(typeof t!=`string`)throw TypeError(`Expected substring`);for(;r!==-1;)r===i?++a>o&&(o=a):a=1,i=r+t.length,r=n.indexOf(t,i);return o}function gr(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function _r(e){let t=e.options.fence||"`";if(t!=="`"&&t!==`~`)throw Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function vr(e,t,n,r){let i=_r(n),a=e.value||``,o=i==="`"?`GraveAccent`:`Tilde`;if(gr(e,n)){let e=n.enter(`codeIndented`),t=n.indentLines(a,yr);return e(),t}let s=n.createTracker(r),c=i.repeat(Math.max(hr(a,i)+1,3)),l=n.enter(`codeFenced`),u=s.move(c);if(e.lang){let t=n.enter(`codeFencedLang${o}`);u+=s.move(n.safe(e.lang,{before:u,after:` `,encode:["`"],...s.current()})),t()}if(e.lang&&e.meta){let t=n.enter(`codeFencedMeta${o}`);u+=s.move(` `),u+=s.move(n.safe(e.meta,{before:u,after:`
7
+ `,encode:["`"],...s.current()})),t()}return u+=s.move(`
8
+ `),a&&(u+=s.move(a+`
9
+ `)),u+=s.move(c),l(),u}function yr(e,t,n){return(n?``:` `)+e}function br(e){let t=e.options.quote||`"`;if(t!==`"`&&t!==`'`)throw Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function xr(e,t,n,r){let i=br(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`definition`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`[`);return l+=c.move(n.safe(n.associationId(e),{before:l,after:`]`,...c.current()})),l+=c.move(`]: `),s(),!e.url||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`
10
+ `,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),o(),l}function Sr(e){let t=e.options.emphasis||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function Cr(e){return`&#x`+e.toString(16).toUpperCase()+`;`}function wr(e,t,n){let r=Pe(e),i=Pe(t);return r===void 0?i===void 0?n===`_`?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}Tr.peek=Er;function Tr(e,t,n,r){let i=Sr(n),a=n.enter(`emphasis`),o=n.createTracker(r),s=o.move(i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=wr(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=Cr(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=wr(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+Cr(d));let p=o.move(i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function Er(e,t,n){return n.options.emphasis||`*`}var Dr=(function(e){if(e==null)return Mr;if(typeof e==`function`)return jr(e);if(typeof e==`object`)return Array.isArray(e)?Or(e):kr(e);if(typeof e==`string`)return Ar(e);throw Error(`Expected function, string, or object as test`)});function Or(e){let t=[],n=-1;for(;++n<e.length;)t[n]=Dr(e[n]);return jr(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function kr(e){let t=e;return jr(n);function n(n){let r=n,i;for(i in e)if(r[i]!==t[i])return!1;return!0}}function Ar(e){return jr(t);function t(t){return t&&t.type===e}}function jr(e){return t;function t(t,n,r){return!!(Nr(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function Mr(){return!0}function Nr(e){return typeof e==`object`&&!!e&&`type`in e}function Pr(e){return e}var Fr=[],Ir=`skip`;function Lr(e,t,n,r){let i;typeof t==`function`&&typeof n!=`function`?(r=n,n=t):i=t;let a=Dr(i),o=r?-1:1;s(e,void 0,[])();function s(e,i,c){let l=e&&typeof e==`object`?e:{};if(typeof l.type==`string`){let t=typeof l.tagName==`string`?l.tagName:typeof l.name==`string`?l.name:void 0;Object.defineProperty(u,`name`,{value:`node (`+Pr(e.type+(t?`<`+t+`>`:``))+`)`})}return u;function u(){let l=Fr,u,d,f;if((!t||a(e,i,c[c.length-1]||void 0))&&(l=Rr(n(e,c)),l[0]===!1))return l;if(`children`in e&&e.children){let t=e;if(t.children&&l[0]!==`skip`)for(d=(r?t.children.length:-1)+o,f=c.concat(t);d>-1&&d<t.children.length;){let e=t.children[d];if(u=s(e,d,f)(),u[0]===!1)return u;d=typeof u[1]==`number`?u[1]:d+o}}return l}}}function Rr(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:e==null?Fr:[e]}function zr(e,t,n,r){let i,a,o;typeof t==`function`&&typeof n!=`function`?(a=void 0,o=t,i=n):(a=t,o=n,i=r),Lr(e,a,s,i);function s(e,t){let n=t[t.length-1],r=n?n.children.indexOf(e):void 0;return o(e,r,n)}}function Br(e,t){let n=!1;return zr(e,function(e){if(`value`in e&&/\r?\n|\r/.test(e.value)||e.type===`break`)return n=!0,!1}),!!((!e.depth||e.depth<3)&&ae(e)&&(t.options.setext||n))}function Vr(e,t,n,r){let i=Math.max(Math.min(6,e.depth||1),1),a=n.createTracker(r);if(Br(e,n)){let t=n.enter(`headingSetext`),r=n.enter(`phrasing`),o=n.containerPhrasing(e,{...a.current(),before:`
14
11
  `,after:`
15
- `});return h(),c(),d+`
16
- `+(i===1?"=":"-").repeat(d.length-(Math.max(d.lastIndexOf("\r"),d.lastIndexOf(`
17
- `))+1))}const o="#".repeat(i),l=t.enter("headingAtx"),a=t.enter("phrasing");s.move(o+" ");let u=t.containerPhrasing(n,{before:"# ",after:`
18
- `,...s.current()});return/^[\t ]/.test(u)&&(u=dt(u.charCodeAt(0))+u.slice(1)),u=u?o+" "+u:o,t.options.closeAtx&&(u+=" "+o),a(),l(),u}ia.peek=ed;function ia(n){return n.value||""}function ed(){return"<"}sa.peek=td;function sa(n,e,t,r){const i=ms(t),s=i==='"'?"Quote":"Apostrophe",o=t.enter("image");let l=t.enter("label");const a=t.createTracker(r);let u=a.move("![");return u+=a.move(t.safe(n.alt,{before:u,after:"]",...a.current()})),u+=a.move("]("),l(),!n.url&&n.title||/[\0- \u007F]/.test(n.url)?(l=t.enter("destinationLiteral"),u+=a.move("<"),u+=a.move(t.safe(n.url,{before:u,after:">",...a.current()})),u+=a.move(">")):(l=t.enter("destinationRaw"),u+=a.move(t.safe(n.url,{before:u,after:n.title?" ":")",...a.current()}))),l(),n.title&&(l=t.enter(`title${s}`),u+=a.move(" "+i),u+=a.move(t.safe(n.title,{before:u,after:i,...a.current()})),u+=a.move(i),l()),u+=a.move(")"),o(),u}function td(){return"!"}oa.peek=nd;function oa(n,e,t,r){const i=n.referenceType,s=t.enter("imageReference");let o=t.enter("label");const l=t.createTracker(r);let a=l.move("![");const u=t.safe(n.alt,{before:a,after:"]",...l.current()});a+=l.move(u+"]["),o();const c=t.stack;t.stack=[],o=t.enter("reference");const h=t.safe(t.associationId(n),{before:a,after:"]",...l.current()});return o(),t.stack=c,s(),i==="full"||!u||u!==h?a+=l.move(h+"]"):i==="shortcut"?a=a.slice(0,-1):a+=l.move("]"),a}function nd(){return"!"}la.peek=rd;function la(n,e,t){let r=n.value||"",i="`",s=-1;for(;new RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++s<t.unsafe.length;){const o=t.unsafe[s],l=t.compilePattern(o);let a;if(o.atBreak)for(;a=l.exec(r);){let u=a.index;r.charCodeAt(u)===10&&r.charCodeAt(u-1)===13&&u--,r=r.slice(0,u)+" "+r.slice(a.index+1)}}return i+r+i}function rd(){return"`"}function aa(n,e){const t=hs(n);return!!(!e.options.resourceLink&&n.url&&!n.title&&n.children&&n.children.length===1&&n.children[0].type==="text"&&(t===n.url||"mailto:"+t===n.url)&&/^[a-z][a-z+.-]+:/i.test(n.url)&&!/[\0- <>\u007F]/.test(n.url))}ua.peek=id;function ua(n,e,t,r){const i=ms(t),s=i==='"'?"Quote":"Apostrophe",o=t.createTracker(r);let l,a;if(aa(n,t)){const c=t.stack;t.stack=[],l=t.enter("autolink");let h=o.move("<");return h+=o.move(t.containerPhrasing(n,{before:h,after:">",...o.current()})),h+=o.move(">"),l(),t.stack=c,h}l=t.enter("link"),a=t.enter("label");let u=o.move("[");return u+=o.move(t.containerPhrasing(n,{before:u,after:"](",...o.current()})),u+=o.move("]("),a(),!n.url&&n.title||/[\0- \u007F]/.test(n.url)?(a=t.enter("destinationLiteral"),u+=o.move("<"),u+=o.move(t.safe(n.url,{before:u,after:">",...o.current()})),u+=o.move(">")):(a=t.enter("destinationRaw"),u+=o.move(t.safe(n.url,{before:u,after:n.title?" ":")",...o.current()}))),a(),n.title&&(a=t.enter(`title${s}`),u+=o.move(" "+i),u+=o.move(t.safe(n.title,{before:u,after:i,...o.current()})),u+=o.move(i),a()),u+=o.move(")"),l(),u}function id(n,e,t){return aa(n,t)?"<":"["}ca.peek=sd;function ca(n,e,t,r){const i=n.referenceType,s=t.enter("linkReference");let o=t.enter("label");const l=t.createTracker(r);let a=l.move("[");const u=t.containerPhrasing(n,{before:a,after:"]",...l.current()});a+=l.move(u+"]["),o();const c=t.stack;t.stack=[],o=t.enter("reference");const h=t.safe(t.associationId(n),{before:a,after:"]",...l.current()});return o(),t.stack=c,s(),i==="full"||!u||u!==h?a+=l.move(h+"]"):i==="shortcut"?a=a.slice(0,-1):a+=l.move("]"),a}function sd(){return"["}function ys(n){const e=n.options.bullet||"*";if(e!=="*"&&e!=="+"&&e!=="-")throw new Error("Cannot serialize items with `"+e+"` for `options.bullet`, expected `*`, `+`, or `-`");return e}function od(n){const e=ys(n),t=n.options.bulletOther;if(!t)return e==="*"?"-":"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(t===e)throw new Error("Expected `bullet` (`"+e+"`) and `bulletOther` (`"+t+"`) to be different");return t}function ld(n){const e=n.options.bulletOrdered||".";if(e!=="."&&e!==")")throw new Error("Cannot serialize items with `"+e+"` for `options.bulletOrdered`, expected `.` or `)`");return e}function ha(n){const e=n.options.rule||"*";if(e!=="*"&&e!=="-"&&e!=="_")throw new Error("Cannot serialize rules with `"+e+"` for `options.rule`, expected `*`, `-`, or `_`");return e}function ad(n,e,t,r){const i=t.enter("list"),s=t.bulletCurrent;let o=n.ordered?ld(t):ys(t);const l=n.ordered?o==="."?")":".":od(t);let a=e&&t.bulletLastUsed?o===t.bulletLastUsed:!1;if(!n.ordered){const c=n.children?n.children[0]:void 0;if((o==="*"||o==="-")&&c&&(!c.children||!c.children[0])&&t.stack[t.stack.length-1]==="list"&&t.stack[t.stack.length-2]==="listItem"&&t.stack[t.stack.length-3]==="list"&&t.stack[t.stack.length-4]==="listItem"&&t.indexStack[t.indexStack.length-1]===0&&t.indexStack[t.indexStack.length-2]===0&&t.indexStack[t.indexStack.length-3]===0&&(a=!0),ha(t)===o&&c){let h=-1;for(;++h<n.children.length;){const d=n.children[h];if(d&&d.type==="listItem"&&d.children&&d.children[0]&&d.children[0].type==="thematicBreak"){a=!0;break}}}}a&&(o=l),t.bulletCurrent=o;const u=t.containerFlow(n,r);return t.bulletLastUsed=o,t.bulletCurrent=s,i(),u}function ud(n){const e=n.options.listItemIndent||"one";if(e!=="tab"&&e!=="one"&&e!=="mixed")throw new Error("Cannot serialize items with `"+e+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return e}function cd(n,e,t,r){const i=ud(t);let s=t.bulletCurrent||ys(t);e&&e.type==="list"&&e.ordered&&(s=(typeof e.start=="number"&&e.start>-1?e.start:1)+(t.options.incrementListMarker===!1?0:e.children.indexOf(n))+s);let o=s.length+1;(i==="tab"||i==="mixed"&&(e&&e.type==="list"&&e.spread||n.spread))&&(o=Math.ceil(o/4)*4);const l=t.createTracker(r);l.move(s+" ".repeat(o-s.length)),l.shift(o);const a=t.enter("listItem"),u=t.indentLines(t.containerFlow(n,l.current()),c);return a(),u;function c(h,d,f){return d?(f?"":" ".repeat(o))+h:(f?s:s+" ".repeat(o-s.length))+h}}function hd(n,e,t,r){const i=t.enter("paragraph"),s=t.enter("phrasing"),o=t.containerPhrasing(n,r);return s(),i(),o}const fd=gs(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function dd(n,e,t,r){return(n.children.some(function(o){return fd(o)})?t.containerPhrasing:t.containerFlow).call(t,n,r)}function pd(n){const e=n.options.strong||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize strong with `"+e+"` for `options.strong`, expected `*`, or `_`");return e}fa.peek=md;function fa(n,e,t,r){const i=pd(t),s=t.enter("strong"),o=t.createTracker(r),l=o.move(i+i);let a=o.move(t.containerPhrasing(n,{after:i,before:l,...o.current()}));const u=a.charCodeAt(0),c=mr(r.before.charCodeAt(r.before.length-1),u,i);c.inside&&(a=dt(u)+a.slice(1));const h=a.charCodeAt(a.length-1),d=mr(r.after.charCodeAt(0),h,i);d.inside&&(a=a.slice(0,-1)+dt(h));const f=o.move(i+i);return s(),t.attentionEncodeSurroundingInfo={after:d.outside,before:c.outside},l+a+f}function md(n,e,t){return t.options.strong||"*"}function gd(n,e,t,r){return t.safe(n.value,r)}function yd(n){const e=n.options.ruleRepetition||3;if(e<3)throw new Error("Cannot serialize rules with repetition `"+e+"` for `options.ruleRepetition`, expected `3` or more");return e}function kd(n,e,t){const r=(ha(t)+(t.options.ruleSpaces?" ":"")).repeat(yd(t));return t.options.ruleSpaces?r.slice(0,-1):r}const xd={blockquote:Pf,break:ko,code:Lf,definition:_f,emphasis:ta,hardBreak:ko,heading:Zf,html:ia,image:sa,imageReference:oa,inlineCode:la,link:ua,linkReference:ca,list:ad,listItem:cd,paragraph:hd,root:dd,strong:fa,text:gd,thematicBreak:kd},bd=[Sd];function Sd(n,e,t,r){if(e.type==="code"&&Ri(e,r)&&(n.type==="list"||n.type===e.type&&Ri(n,r)))return!1;if("spread"in t&&typeof t.spread=="boolean")return n.type==="paragraph"&&(n.type===e.type||e.type==="definition"||e.type==="heading"&&ra(e,r))?void 0:t.spread?1:0}const bt=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"],wd=[{character:" ",after:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",before:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde"]},{character:"\r",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde","codeFencedMetaGraveAccent","codeFencedMetaTilde","destinationLiteral","headingAtx"]},{character:`
19
- `,inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde","codeFencedMetaGraveAccent","codeFencedMetaTilde","destinationLiteral","headingAtx"]},{character:" ",after:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",before:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde"]},{character:"!",after:"\\[",inConstruct:"phrasing",notInConstruct:bt},{character:'"',inConstruct:"titleQuote"},{atBreak:!0,character:"#"},{character:"#",inConstruct:"headingAtx",after:`(?:[\r
20
- ]|$)`},{character:"&",after:"[#A-Za-z]",inConstruct:"phrasing"},{character:"'",inConstruct:"titleApostrophe"},{character:"(",inConstruct:"destinationRaw"},{before:"\\]",character:"(",inConstruct:"phrasing",notInConstruct:bt},{atBreak:!0,before:"\\d+",character:")"},{character:")",inConstruct:"destinationRaw"},{atBreak:!0,character:"*",after:`(?:[ \r
21
- *])`},{character:"*",inConstruct:"phrasing",notInConstruct:bt},{atBreak:!0,character:"+",after:`(?:[ \r
22
- ])`},{atBreak:!0,character:"-",after:`(?:[ \r
23
- -])`},{atBreak:!0,before:"\\d+",character:".",after:`(?:[ \r
24
- ]|$)`},{atBreak:!0,character:"<",after:"[!/?A-Za-z]"},{character:"<",after:"[!/?A-Za-z]",inConstruct:"phrasing",notInConstruct:bt},{character:"<",inConstruct:"destinationLiteral"},{atBreak:!0,character:"="},{atBreak:!0,character:">"},{character:">",inConstruct:"destinationLiteral"},{atBreak:!0,character:"["},{character:"[",inConstruct:"phrasing",notInConstruct:bt},{character:"[",inConstruct:["label","reference"]},{character:"\\",after:"[\\r\\n]",inConstruct:"phrasing"},{character:"]",inConstruct:["label","reference"]},{atBreak:!0,character:"_"},{character:"_",inConstruct:"phrasing",notInConstruct:bt},{atBreak:!0,character:"`"},{character:"`",inConstruct:["codeFencedLangGraveAccent","codeFencedMetaGraveAccent"]},{character:"`",inConstruct:"phrasing",notInConstruct:bt},{atBreak:!0,character:"~"}];function Cd(n){return n.label||!n.identifier?n.label||"":Ql(n.identifier)}function Td(n){if(!n._compiled){const e=(n.atBreak?"[\\r\\n][\\t ]*":"")+(n.before?"(?:"+n.before+")":"");n._compiled=new RegExp((e?"("+e+")":"")+(/[|\\{}()[\]^$+*?.-]/.test(n.character)?"\\":"")+n.character+(n.after?"(?:"+n.after+")":""),"g")}return n._compiled}function Md(n,e,t){const r=e.indexStack,i=n.children||[],s=[];let o=-1,l=t.before,a;r.push(-1);let u=e.createTracker(t);for(;++o<i.length;){const c=i[o];let h;if(r[r.length-1]=o,o+1<i.length){let p=e.handle.handlers[i[o+1].type];p&&p.peek&&(p=p.peek),h=p?p(i[o+1],n,e,{before:"",after:"",...u.current()}).charAt(0):""}else h=t.after;s.length>0&&(l==="\r"||l===`
25
- `)&&c.type==="html"&&(s[s.length-1]=s[s.length-1].replace(/(\r?\n|\r)$/," "),l=" ",u=e.createTracker(t),u.move(s.join("")));let d=e.handle(c,n,e,{...u.current(),after:h,before:l});a&&a===d.slice(0,1)&&(d=dt(a.charCodeAt(0))+d.slice(1));const f=e.attentionEncodeSurroundingInfo;e.attentionEncodeSurroundingInfo=void 0,a=void 0,f&&(s.length>0&&f.before&&l===s[s.length-1].slice(-1)&&(s[s.length-1]=s[s.length-1].slice(0,-1)+dt(l.charCodeAt(0))),f.after&&(a=h)),u.move(d),s.push(d),l=d.slice(-1)}return r.pop(),s.join("")}function Nd(n,e,t){const r=e.indexStack,i=n.children||[],s=e.createTracker(t),o=[];let l=-1;for(r.push(-1);++l<i.length;){const a=i[l];r[r.length-1]=l,o.push(s.move(e.handle(a,n,e,{before:`
12
+ `});return r(),t(),o+`
13
+ `+(i===1?`=`:`-`).repeat(o.length-(Math.max(o.lastIndexOf(`\r`),o.lastIndexOf(`
14
+ `))+1))}let o=`#`.repeat(i),s=n.enter(`headingAtx`),c=n.enter(`phrasing`);a.move(o+` `);let l=n.containerPhrasing(e,{before:`# `,after:`
15
+ `,...a.current()});return/^[\t ]/.test(l)&&(l=Cr(l.charCodeAt(0))+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}Hr.peek=Ur;function Hr(e){return e.value||``}function Ur(){return`<`}Wr.peek=Gr;function Wr(e,t,n,r){let i=br(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`image`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`![`);return l+=c.move(n.safe(e.alt,{before:l,after:`]`,...c.current()})),l+=c.move(`](`),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),l+=c.move(`)`),o(),l}function Gr(){return`!`}Kr.peek=qr;function Kr(e,t,n,r){let i=e.referenceType,a=n.enter(`imageReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`![`),l=n.safe(e.alt,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function qr(){return`!`}Jr.peek=Yr;function Jr(e,t,n){let r=e.value||``,i="`",a=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=` `+r+` `);++a<n.unsafe.length;){let e=n.unsafe[a],t=n.compilePattern(e),i;if(e.atBreak)for(;i=t.exec(r);){let e=i.index;r.charCodeAt(e)===10&&r.charCodeAt(e-1)===13&&e--,r=r.slice(0,e)+` `+r.slice(i.index+1)}}return i+r+i}function Yr(){return"`"}function Xr(e,t){let n=ae(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type===`text`&&(n===e.url||`mailto:`+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}Zr.peek=Qr;function Zr(e,t,n,r){let i=br(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r),s,c;if(Xr(e,n)){let t=n.stack;n.stack=[],s=n.enter(`autolink`);let r=o.move(`<`);return r+=o.move(n.containerPhrasing(e,{before:r,after:`>`,...o.current()})),r+=o.move(`>`),s(),n.stack=t,r}s=n.enter(`link`),c=n.enter(`label`);let l=o.move(`[`);return l+=o.move(n.containerPhrasing(e,{before:l,after:`](`,...o.current()})),l+=o.move(`](`),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter(`destinationLiteral`),l+=o.move(`<`),l+=o.move(n.safe(e.url,{before:l,after:`>`,...o.current()})),l+=o.move(`>`)):(c=n.enter(`destinationRaw`),l+=o.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...o.current()}))),c(),e.title&&(c=n.enter(`title${a}`),l+=o.move(` `+i),l+=o.move(n.safe(e.title,{before:l,after:i,...o.current()})),l+=o.move(i),c()),l+=o.move(`)`),s(),l}function Qr(e,t,n){return Xr(e,n)?`<`:`[`}$r.peek=ei;function $r(e,t,n,r){let i=e.referenceType,a=n.enter(`linkReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`[`),l=n.containerPhrasing(e,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function ei(){return`[`}function ti(e){let t=e.options.bullet||`*`;if(t!==`*`&&t!==`+`&&t!==`-`)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function ni(e){let t=ti(e),n=e.options.bulletOther;if(!n)return t===`*`?`-`:`*`;if(n!==`*`&&n!==`+`&&n!==`-`)throw Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function ri(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function ii(e){let t=e.options.rule||`*`;if(t!==`*`&&t!==`-`&&t!==`_`)throw Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function ai(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?ri(n):ti(n),s=e.ordered?o===`.`?`)`:`.`:ni(n),c=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){let t=e.children?e.children[0]:void 0;if((o===`*`||o===`-`)&&t&&(!t.children||!t.children[0])&&n.stack[n.stack.length-1]===`list`&&n.stack[n.stack.length-2]===`listItem`&&n.stack[n.stack.length-3]===`list`&&n.stack[n.stack.length-4]===`listItem`&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),ii(n)===o&&t){let t=-1;for(;++t<e.children.length;){let n=e.children[t];if(n&&n.type===`listItem`&&n.children&&n.children[0]&&n.children[0].type===`thematicBreak`){c=!0;break}}}}c&&(o=s),n.bulletCurrent=o;let l=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),l}function oi(e){let t=e.options.listItemIndent||`one`;if(t!==`tab`&&t!==`one`&&t!==`mixed`)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function si(e,t,n,r){let i=oi(n),a=n.bulletCurrent||ti(n);t&&t.type===`list`&&t.ordered&&(a=(typeof t.start==`number`&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i===`tab`||i===`mixed`&&(t&&t.type===`list`&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);let s=n.createTracker(r);s.move(a+` `.repeat(o-a.length)),s.shift(o);let c=n.enter(`listItem`),l=n.indentLines(n.containerFlow(e,s.current()),u);return c(),l;function u(e,t,n){return t?(n?``:` `.repeat(o))+e:(n?a:a+` `.repeat(o-a.length))+e}}function ci(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}var li=Dr([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]);function ui(e,t,n,r){return(e.children.some(function(e){return li(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function di(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}fi.peek=pi;function fi(e,t,n,r){let i=di(n),a=n.enter(`strong`),o=n.createTracker(r),s=o.move(i+i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=wr(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=Cr(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=wr(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+Cr(d));let p=o.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function pi(e,t,n){return n.options.strong||`*`}function mi(e,t,n,r){return n.safe(e.value,r)}function hi(e){let t=e.options.ruleRepetition||3;if(t<3)throw Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function gi(e,t,n){let r=(ii(n)+(n.options.ruleSpaces?` `:``)).repeat(hi(n));return n.options.ruleSpaces?r.slice(0,-1):r}var _i={blockquote:ur,break:mr,code:vr,definition:xr,emphasis:Tr,hardBreak:mr,heading:Vr,html:Hr,image:Wr,imageReference:Kr,inlineCode:Jr,link:Zr,linkReference:$r,list:ai,listItem:si,paragraph:ci,root:ui,strong:fi,text:mi,thematicBreak:gi},vi=[yi];function yi(e,t,n,r){if(t.type===`code`&&gr(t,r)&&(e.type===`list`||e.type===t.type&&gr(e,r)))return!1;if(`spread`in n&&typeof n.spread==`boolean`)return e.type===`paragraph`&&(e.type===t.type||t.type===`definition`||t.type===`heading`&&Br(t,r))?void 0:n.spread?1:0}var bi=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`],xi=[{character:` `,after:`[\\r\\n]`,inConstruct:`phrasing`},{character:` `,before:`[\\r\\n]`,inConstruct:`phrasing`},{character:` `,inConstruct:[`codeFencedLangGraveAccent`,`codeFencedLangTilde`]},{character:`\r`,inConstruct:[`codeFencedLangGraveAccent`,`codeFencedLangTilde`,`codeFencedMetaGraveAccent`,`codeFencedMetaTilde`,`destinationLiteral`,`headingAtx`]},{character:`
16
+ `,inConstruct:[`codeFencedLangGraveAccent`,`codeFencedLangTilde`,`codeFencedMetaGraveAccent`,`codeFencedMetaTilde`,`destinationLiteral`,`headingAtx`]},{character:` `,after:`[\\r\\n]`,inConstruct:`phrasing`},{character:` `,before:`[\\r\\n]`,inConstruct:`phrasing`},{character:` `,inConstruct:[`codeFencedLangGraveAccent`,`codeFencedLangTilde`]},{character:`!`,after:`\\[`,inConstruct:`phrasing`,notInConstruct:bi},{character:`"`,inConstruct:`titleQuote`},{atBreak:!0,character:`#`},{character:`#`,inConstruct:`headingAtx`,after:`(?:[\r
17
+ ]|$)`},{character:`&`,after:`[#A-Za-z]`,inConstruct:`phrasing`},{character:`'`,inConstruct:`titleApostrophe`},{character:`(`,inConstruct:`destinationRaw`},{before:`\\]`,character:`(`,inConstruct:`phrasing`,notInConstruct:bi},{atBreak:!0,before:`\\d+`,character:`)`},{character:`)`,inConstruct:`destinationRaw`},{atBreak:!0,character:`*`,after:`(?:[ \r
18
+ *])`},{character:`*`,inConstruct:`phrasing`,notInConstruct:bi},{atBreak:!0,character:`+`,after:`(?:[ \r
19
+ ])`},{atBreak:!0,character:`-`,after:`(?:[ \r
20
+ -])`},{atBreak:!0,before:`\\d+`,character:`.`,after:`(?:[ \r
21
+ ]|$)`},{atBreak:!0,character:`<`,after:`[!/?A-Za-z]`},{character:`<`,after:`[!/?A-Za-z]`,inConstruct:`phrasing`,notInConstruct:bi},{character:`<`,inConstruct:`destinationLiteral`},{atBreak:!0,character:`=`},{atBreak:!0,character:`>`},{character:`>`,inConstruct:`destinationLiteral`},{atBreak:!0,character:`[`},{character:`[`,inConstruct:`phrasing`,notInConstruct:bi},{character:`[`,inConstruct:[`label`,`reference`]},{character:`\\`,after:`[\\r\\n]`,inConstruct:`phrasing`},{character:`]`,inConstruct:[`label`,`reference`]},{atBreak:!0,character:`_`},{character:`_`,inConstruct:`phrasing`,notInConstruct:bi},{atBreak:!0,character:"`"},{character:"`",inConstruct:[`codeFencedLangGraveAccent`,`codeFencedMetaGraveAccent`]},{character:"`",inConstruct:`phrasing`,notInConstruct:bi},{atBreak:!0,character:`~`}];function Si(e){return e.label||!e.identifier?e.label||``:Wn(e.identifier)}function Ci(e){if(!e._compiled){let t=(e.atBreak?`[\\r\\n][\\t ]*`:``)+(e.before?`(?:`+e.before+`)`:``);e._compiled=RegExp((t?`(`+t+`)`:``)+(/[|\\{}()[\]^$+*?.-]/.test(e.character)?`\\`:``)+e.character+(e.after?`(?:`+e.after+`)`:``),`g`)}return e._compiled}function wi(e,t,n){let r=t.indexStack,i=e.children||[],a=[],o=-1,s=n.before,c;r.push(-1);let l=t.createTracker(n);for(;++o<i.length;){let u=i[o],d;if(r[r.length-1]=o,o+1<i.length){let n=t.handle.handlers[i[o+1].type];n&&n.peek&&(n=n.peek),d=n?n(i[o+1],e,t,{before:``,after:``,...l.current()}).charAt(0):``}else d=n.after;a.length>0&&(s===`\r`||s===`
22
+ `)&&u.type===`html`&&(a[a.length-1]=a[a.length-1].replace(/(\r?\n|\r)$/,` `),s=` `,l=t.createTracker(n),l.move(a.join(``)));let f=t.handle(u,e,t,{...l.current(),after:d,before:s});c&&c===f.slice(0,1)&&(f=Cr(c.charCodeAt(0))+f.slice(1));let p=t.attentionEncodeSurroundingInfo;t.attentionEncodeSurroundingInfo=void 0,c=void 0,p&&(a.length>0&&p.before&&s===a[a.length-1].slice(-1)&&(a[a.length-1]=a[a.length-1].slice(0,-1)+Cr(s.charCodeAt(0))),p.after&&(c=d)),l.move(f),a.push(f),s=f.slice(-1)}return r.pop(),a.join(``)}function Ti(e,t,n){let r=t.indexStack,i=e.children||[],a=t.createTracker(n),o=[],s=-1;for(r.push(-1);++s<i.length;){let n=i[s];r[r.length-1]=s,o.push(a.move(t.handle(n,e,t,{before:`
26
23
  `,after:`
27
- `,...s.current()}))),a.type!=="list"&&(e.bulletLastUsed=void 0),l<i.length-1&&o.push(s.move(Od(a,i[l+1],n,e)))}return r.pop(),o.join("")}function Od(n,e,t,r){let i=r.join.length;for(;i--;){const s=r.join[i](n,e,t,r);if(s===!0||s===1)break;if(typeof s=="number")return`
28
- `.repeat(1+s);if(s===!1)return`
24
+ `,...a.current()}))),n.type!==`list`&&(t.bulletLastUsed=void 0),s<i.length-1&&o.push(a.move(Ei(n,i[s+1],e,t)))}return r.pop(),o.join(``)}function Ei(e,t,n,r){let i=r.join.length;for(;i--;){let a=r.join[i](e,t,n,r);if(a===!0||a===1)break;if(typeof a==`number`)return`
25
+ `.repeat(1+a);if(a===!1)return`
29
26
 
30
27
  <!---->
31
28
 
32
29
  `}return`
33
30
 
34
- `}const Ed=/\r?\n|\r/g;function Id(n,e){const t=[];let r=0,i=0,s;for(;s=Ed.exec(n);)o(n.slice(r,s.index)),t.push(s[0]),r=s.index+s[0].length,i++;return o(n.slice(r)),t.join("");function o(l){t.push(e(l,i,!l))}}function Ad(n,e,t){const r=(t.before||"")+(e||"")+(t.after||""),i=[],s=[],o={};let l=-1;for(;++l<n.unsafe.length;){const c=n.unsafe[l];if(!ea(n.stack,c))continue;const h=n.compilePattern(c);let d;for(;d=h.exec(r);){const f="before"in c||!!c.atBreak,p="after"in c,y=d.index+(f?d[1].length:0);i.includes(y)?(o[y].before&&!f&&(o[y].before=!1),o[y].after&&!p&&(o[y].after=!1)):(i.push(y),o[y]={before:f,after:p})}}i.sort(Dd);let a=t.before?t.before.length:0;const u=r.length-(t.after?t.after.length:0);for(l=-1;++l<i.length;){const c=i[l];c<a||c>=u||c+1<u&&i[l+1]===c+1&&o[c].after&&!o[c+1].before&&!o[c+1].after||i[l-1]===c-1&&o[c].before&&!o[c-1].before&&!o[c-1].after||(a!==c&&s.push(xo(r.slice(a,c),"\\")),a=c,/[!-/:-@[-`{-~]/.test(r.charAt(c))&&(!t.encode||!t.encode.includes(r.charAt(c)))?s.push("\\"):(s.push(dt(r.charCodeAt(c))),a++))}return s.push(xo(r.slice(a,u),t.after)),s.join("")}function Dd(n,e){return n-e}function xo(n,e){const t=/\\(?=[!-/:-@[-`{-~])/g,r=[],i=[],s=n+e;let o=-1,l=0,a;for(;a=t.exec(s);)r.push(a.index);for(;++o<r.length;)l!==r[o]&&i.push(n.slice(l,r[o])),i.push("\\"),l=r[o];return i.push(n.slice(l)),i.join("")}function Rd(n){const e=n||{},t=e.now||{};let r=e.lineShift||0,i=t.line||1,s=t.column||1;return{move:a,current:o,shift:l};function o(){return{now:{line:i,column:s},lineShift:r}}function l(u){r+=u}function a(u){const c=u||"",h=c.split(/\r?\n|\r/g),d=h[h.length-1];return i+=h.length-1,s=h.length===1?s+d.length:1+d.length+r,c}}function zd(n,e){const t=e||{},r={associationId:Cd,containerPhrasing:vd,containerFlow:Ld,createTracker:Rd,compilePattern:Td,enter:s,handlers:{...xd},handle:void 0,indentLines:Id,indexStack:[],join:[...bd],options:{},safe:Vd,stack:[],unsafe:[...wd]};Zl(r,t),r.options.tightDefinitions&&r.join.push(Bd),r.handle=Df("type",{invalid:Pd,unknown:Fd,handlers:r.handlers});let i=r.handle(n,void 0,r,{before:`
31
+ `}var Di=/\r?\n|\r/g;function Oi(e,t){let n=[],r=0,i=0,a;for(;a=Di.exec(e);)o(e.slice(r,a.index)),n.push(a[0]),r=a.index+a[0].length,i++;return o(e.slice(r)),n.join(``);function o(e){n.push(t(e,i,!e))}}function ki(e,t,n){let r=(n.before||``)+(t||``)+(n.after||``),i=[],a=[],o={},s=-1;for(;++s<e.unsafe.length;){let t=e.unsafe[s];if(!fr(e.stack,t))continue;let n=e.compilePattern(t),a;for(;a=n.exec(r);){let e=`before`in t||!!t.atBreak,n=`after`in t,r=a.index+(e?a[1].length:0);i.includes(r)?(o[r].before&&!e&&(o[r].before=!1),o[r].after&&!n&&(o[r].after=!1)):(i.push(r),o[r]={before:e,after:n})}}i.sort(Ai);let c=n.before?n.before.length:0,l=r.length-(n.after?n.after.length:0);for(s=-1;++s<i.length;){let e=i[s];e<c||e>=l||e+1<l&&i[s+1]===e+1&&o[e].after&&!o[e+1].before&&!o[e+1].after||i[s-1]===e-1&&o[e].before&&!o[e-1].before&&!o[e-1].after||(c!==e&&a.push(ji(r.slice(c,e),`\\`)),c=e,/[!-/:-@[-`{-~]/.test(r.charAt(e))&&(!n.encode||!n.encode.includes(r.charAt(e)))?a.push(`\\`):(a.push(Cr(r.charCodeAt(e))),c++))}return a.push(ji(r.slice(c,l),n.after)),a.join(``)}function Ai(e,t){return e-t}function ji(e,t){let n=/\\(?=[!-/:-@[-`{-~])/g,r=[],i=[],a=e+t,o=-1,s=0,c;for(;c=n.exec(a);)r.push(c.index);for(;++o<r.length;)s!==r[o]&&i.push(e.slice(s,r[o])),i.push(`\\`),s=r[o];return i.push(e.slice(s)),i.join(``)}function Mi(e){let t=e||{},n=t.now||{},r=t.lineShift||0,i=n.line||1,a=n.column||1;return{move:c,current:o,shift:s};function o(){return{now:{line:i,column:a},lineShift:r}}function s(e){r+=e}function c(e){let t=e||``,n=t.split(/\r?\n|\r/g),o=n[n.length-1];return i+=n.length-1,a=n.length===1?a+o.length:1+o.length+r,t}}function Ni(e,t){let n=t||{},r={associationId:Si,containerPhrasing:Li,containerFlow:Ri,createTracker:Mi,compilePattern:Ci,enter:a,handlers:{..._i},handle:void 0,indentLines:Oi,indexStack:[],join:[...vi],options:{},safe:zi,stack:[],unsafe:[...xi]};sr(r,n),r.options.tightDefinitions&&r.join.push(Ii),r.handle=ar(`type`,{invalid:Pi,unknown:Fi,handlers:r.handlers});let i=r.handle(e,void 0,r,{before:`
35
32
  `,after:`
36
33
  `,now:{line:1,column:1},lineShift:0});return i&&i.charCodeAt(i.length-1)!==10&&i.charCodeAt(i.length-1)!==13&&(i+=`
37
- `),i;function s(o){return r.stack.push(o),l;function l(){r.stack.pop()}}}function Pd(n){throw new Error("Cannot handle value `"+n+"`, expected node")}function Fd(n){const e=n;throw new Error("Cannot handle unknown node `"+e.type+"`")}function Bd(n,e){if(n.type==="definition"&&n.type===e.type)return 0}function vd(n,e){return Md(n,this,e)}function Ld(n,e){return Nd(n,this,e)}function Vd(n,e){return Ad(this,n,e)}function Pi(n){const e=this;e.compiler=t;function t(r){return zd(r,{...e.data("settings"),...n,extensions:e.data("toMarkdownExtensions")||[]})}}function bo(n){if(n)throw n}var Vr,So;function _d(){if(So)return Vr;So=1;var n=Object.prototype.hasOwnProperty,e=Object.prototype.toString,t=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=function(u){return typeof Array.isArray=="function"?Array.isArray(u):e.call(u)==="[object Array]"},s=function(u){if(!u||e.call(u)!=="[object Object]")return!1;var c=n.call(u,"constructor"),h=u.constructor&&u.constructor.prototype&&n.call(u.constructor.prototype,"isPrototypeOf");if(u.constructor&&!c&&!h)return!1;var d;for(d in u);return typeof d>"u"||n.call(u,d)},o=function(u,c){t&&c.name==="__proto__"?t(u,c.name,{enumerable:!0,configurable:!0,value:c.newValue,writable:!0}):u[c.name]=c.newValue},l=function(u,c){if(c==="__proto__")if(n.call(u,c)){if(r)return r(u,c).value}else return;return u[c]};return Vr=function a(){var u,c,h,d,f,p,y=arguments[0],x=1,k=arguments.length,I=!1;for(typeof y=="boolean"&&(I=y,y=arguments[1]||{},x=2),(y==null||typeof y!="object"&&typeof y!="function")&&(y={});x<k;++x)if(u=arguments[x],u!=null)for(c in u)h=l(y,c),d=l(u,c),y!==d&&(I&&d&&(s(d)||(f=i(d)))?(f?(f=!1,p=h&&i(h)?h:[]):p=h&&s(h)?h:{},o(y,{name:c,newValue:a(I,p,d)})):typeof d<"u"&&o(y,{name:c,newValue:d}));return y},Vr}var $d=_d();const _r=qu($d);function Fi(n){if(typeof n!="object"||n===null)return!1;const e=Object.getPrototypeOf(n);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in n)&&!(Symbol.iterator in n)}function qd(){const n=[],e={run:t,use:r};return e;function t(...i){let s=-1;const o=i.pop();if(typeof o!="function")throw new TypeError("Expected function as last argument, not "+o);l(null,...i);function l(a,...u){const c=n[++s];let h=-1;if(a){o(a);return}for(;++h<i.length;)(u[h]===null||u[h]===void 0)&&(u[h]=i[h]);i=u,c?Wd(c,l)(...u):o(null,...u)}}function r(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return n.push(i),e}}function Wd(n,e){let t;return r;function r(...o){const l=n.length>o.length;let a;l&&o.push(i);try{a=n.apply(this,o)}catch(u){const c=u;if(l&&t)throw c;return i(c)}l||(a&&a.then&&typeof a.then=="function"?a.then(s,i):a instanceof Error?i(a):s(a))}function i(o,...l){t||(t=!0,e(o,...l))}function s(o){i(null,o)}}class ge extends Error{constructor(e,t,r){super(),typeof t=="string"&&(r=t,t=void 0);let i="",s={},o=!1;if(t&&("line"in t&&"column"in t?s={place:t}:"start"in t&&"end"in t?s={place:t}:"type"in t?s={ancestors:[t],place:t.position}:s={...t}),typeof e=="string"?i=e:!s.cause&&e&&(o=!0,i=e.message,s.cause=e),!s.ruleId&&!s.source&&typeof r=="string"){const a=r.indexOf(":");a===-1?s.ruleId=r:(s.source=r.slice(0,a),s.ruleId=r.slice(a+1))}if(!s.place&&s.ancestors&&s.ancestors){const a=s.ancestors[s.ancestors.length-1];a&&(s.place=a.position)}const l=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=l?l.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=l?l.line:void 0,this.name=wn(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=o&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}ge.prototype.file="";ge.prototype.name="";ge.prototype.reason="";ge.prototype.message="";ge.prototype.stack="";ge.prototype.column=void 0;ge.prototype.line=void 0;ge.prototype.ancestors=void 0;ge.prototype.cause=void 0;ge.prototype.fatal=void 0;ge.prototype.place=void 0;ge.prototype.ruleId=void 0;ge.prototype.source=void 0;const ve={basename:jd,dirname:Jd,extname:Hd,join:Kd,sep:"/"};function jd(n,e){if(e!==void 0&&typeof e!="string")throw new TypeError('"ext" argument must be a string');zn(n);let t=0,r=-1,i=n.length,s;if(e===void 0||e.length===0||e.length>n.length){for(;i--;)if(n.codePointAt(i)===47){if(s){t=i+1;break}}else r<0&&(s=!0,r=i+1);return r<0?"":n.slice(t,r)}if(e===n)return"";let o=-1,l=e.length-1;for(;i--;)if(n.codePointAt(i)===47){if(s){t=i+1;break}}else o<0&&(s=!0,o=i+1),l>-1&&(n.codePointAt(i)===e.codePointAt(l--)?l<0&&(r=i):(l=-1,r=o));return t===r?r=o:r<0&&(r=n.length),n.slice(t,r)}function Jd(n){if(zn(n),n.length===0)return".";let e=-1,t=n.length,r;for(;--t;)if(n.codePointAt(t)===47){if(r){e=t;break}}else r||(r=!0);return e<0?n.codePointAt(0)===47?"/":".":e===1&&n.codePointAt(0)===47?"//":n.slice(0,e)}function Hd(n){zn(n);let e=n.length,t=-1,r=0,i=-1,s=0,o;for(;e--;){const l=n.codePointAt(e);if(l===47){if(o){r=e+1;break}continue}t<0&&(o=!0,t=e+1),l===46?i<0?i=e:s!==1&&(s=1):i>-1&&(s=-1)}return i<0||t<0||s===0||s===1&&i===t-1&&i===r+1?"":n.slice(i,t)}function Kd(...n){let e=-1,t;for(;++e<n.length;)zn(n[e]),n[e]&&(t=t===void 0?n[e]:t+"/"+n[e]);return t===void 0?".":Ud(t)}function Ud(n){zn(n);const e=n.codePointAt(0)===47;let t=Yd(n,!e);return t.length===0&&!e&&(t="."),t.length>0&&n.codePointAt(n.length-1)===47&&(t+="/"),e?"/"+t:t}function Yd(n,e){let t="",r=0,i=-1,s=0,o=-1,l,a;for(;++o<=n.length;){if(o<n.length)l=n.codePointAt(o);else{if(l===47)break;l=47}if(l===47){if(!(i===o-1||s===1))if(i!==o-1&&s===2){if(t.length<2||r!==2||t.codePointAt(t.length-1)!==46||t.codePointAt(t.length-2)!==46){if(t.length>2){if(a=t.lastIndexOf("/"),a!==t.length-1){a<0?(t="",r=0):(t=t.slice(0,a),r=t.length-1-t.lastIndexOf("/")),i=o,s=0;continue}}else if(t.length>0){t="",r=0,i=o,s=0;continue}}e&&(t=t.length>0?t+"/..":"..",r=2)}else t.length>0?t+="/"+n.slice(i+1,o):t=n.slice(i+1,o),r=o-i-1;i=o,s=0}else l===46&&s>-1?s++:s=-1}return t}function zn(n){if(typeof n!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(n))}const Qd={cwd:Gd};function Gd(){return"/"}function Bi(n){return!!(n!==null&&typeof n=="object"&&"href"in n&&n.href&&"protocol"in n&&n.protocol&&n.auth===void 0)}function Xd(n){if(typeof n=="string")n=new URL(n);else if(!Bi(n)){const e=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+n+"`");throw e.code="ERR_INVALID_ARG_TYPE",e}if(n.protocol!=="file:"){const e=new TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return Zd(n)}function Zd(n){if(n.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const e=n.pathname;let t=-1;for(;++t<e.length;)if(e.codePointAt(t)===37&&e.codePointAt(t+1)===50){const r=e.codePointAt(t+2);if(r===70||r===102){const i=new TypeError("File URL path must not include encoded / characters");throw i.code="ERR_INVALID_FILE_URL_PATH",i}}return decodeURIComponent(e)}const $r=["history","path","basename","stem","extname","dirname"];class ep{constructor(e){let t;e?Bi(e)?t={path:e}:typeof e=="string"||tp(e)?t={value:e}:t=e:t={},this.cwd="cwd"in t?"":Qd.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<$r.length;){const s=$r[r];s in t&&t[s]!==void 0&&t[s]!==null&&(this[s]=s==="history"?[...t[s]]:t[s])}let i;for(i in t)$r.includes(i)||(this[i]=t[i])}get basename(){return typeof this.path=="string"?ve.basename(this.path):void 0}set basename(e){Wr(e,"basename"),qr(e,"basename"),this.path=ve.join(this.dirname||"",e)}get dirname(){return typeof this.path=="string"?ve.dirname(this.path):void 0}set dirname(e){wo(this.basename,"dirname"),this.path=ve.join(e||"",this.basename)}get extname(){return typeof this.path=="string"?ve.extname(this.path):void 0}set extname(e){if(qr(e,"extname"),wo(this.dirname,"extname"),e){if(e.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(e.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=ve.join(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){Bi(e)&&(e=Xd(e)),Wr(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path=="string"?ve.basename(this.path,this.extname):void 0}set stem(e){Wr(e,"stem"),qr(e,"stem"),this.path=ve.join(this.dirname||"",e+(this.extname||""))}fail(e,t,r){const i=this.message(e,t,r);throw i.fatal=!0,i}info(e,t,r){const i=this.message(e,t,r);return i.fatal=void 0,i}message(e,t,r){const i=new ge(e,t,r);return this.path&&(i.name=this.path+":"+i.name,i.file=this.path),i.fatal=!1,this.messages.push(i),i}toString(e){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(e||void 0).decode(this.value)}}function qr(n,e){if(n&&n.includes(ve.sep))throw new Error("`"+e+"` cannot be a path: did not expect `"+ve.sep+"`")}function Wr(n,e){if(!n)throw new Error("`"+e+"` cannot be empty")}function wo(n,e){if(!n)throw new Error("Setting `"+e+"` requires `path` to be set too")}function tp(n){return!!(n&&typeof n=="object"&&"byteLength"in n&&"byteOffset"in n)}const np=(function(n){const r=this.constructor.prototype,i=r[n],s=function(){return i.apply(s,arguments)};return Object.setPrototypeOf(s,r),s}),rp={}.hasOwnProperty;class ks extends np{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=qd()}copy(){const e=new ks;let t=-1;for(;++t<this.attachers.length;){const r=this.attachers[t];e.use(...r)}return e.data(_r(!0,{},this.namespace)),e}data(e,t){return typeof e=="string"?arguments.length===2?(Hr("data",this.frozen),this.namespace[e]=t,this):rp.call(this.namespace,e)&&this.namespace[e]||void 0:e?(Hr("data",this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;const e=this;for(;++this.freezeIndex<this.attachers.length;){const[t,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);const i=t.call(e,...r);typeof i=="function"&&this.transformers.use(i)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(e){this.freeze();const t=_n(e),r=this.parser||this.Parser;return jr("parse",r),r(String(t),t)}process(e,t){const r=this;return this.freeze(),jr("process",this.parser||this.Parser),Jr("process",this.compiler||this.Compiler),t?i(void 0,t):new Promise(i);function i(s,o){const l=_n(e),a=r.parse(l);r.run(a,l,function(c,h,d){if(c||!h||!d)return u(c);const f=h,p=r.stringify(f,d);sp(p)?d.value=p:d.result=p,u(c,d)});function u(c,h){c||!h?o(c):s?s(h):t(void 0,h)}}}processSync(e){let t=!1,r;return this.freeze(),jr("processSync",this.parser||this.Parser),Jr("processSync",this.compiler||this.Compiler),this.process(e,i),To("processSync","process",t),r;function i(s,o){t=!0,bo(s),r=o}}run(e,t,r){Co(e),this.freeze();const i=this.transformers;return!r&&typeof t=="function"&&(r=t,t=void 0),r?s(void 0,r):new Promise(s);function s(o,l){const a=_n(t);i.run(e,a,u);function u(c,h,d){const f=h||e;c?l(c):o?o(f):r(void 0,f,d)}}}runSync(e,t){let r=!1,i;return this.run(e,t,s),To("runSync","run",r),i;function s(o,l){bo(o),i=l,r=!0}}stringify(e,t){this.freeze();const r=_n(t),i=this.compiler||this.Compiler;return Jr("stringify",i),Co(e),i(e,r)}use(e,...t){const r=this.attachers,i=this.namespace;if(Hr("use",this.frozen),e!=null)if(typeof e=="function")a(e,t);else if(typeof e=="object")Array.isArray(e)?l(e):o(e);else throw new TypeError("Expected usable value, not `"+e+"`");return this;function s(u){if(typeof u=="function")a(u,[]);else if(typeof u=="object")if(Array.isArray(u)){const[c,...h]=u;a(c,h)}else o(u);else throw new TypeError("Expected usable value, not `"+u+"`")}function o(u){if(!("plugins"in u)&&!("settings"in u))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");l(u.plugins),u.settings&&(i.settings=_r(!0,i.settings,u.settings))}function l(u){let c=-1;if(u!=null)if(Array.isArray(u))for(;++c<u.length;){const h=u[c];s(h)}else throw new TypeError("Expected a list of plugins, not `"+u+"`")}function a(u,c){let h=-1,d=-1;for(;++h<r.length;)if(r[h][0]===u){d=h;break}if(d===-1)r.push([u,...c]);else if(c.length>0){let[f,...p]=c;const y=r[d][1];Fi(y)&&Fi(f)&&(f=_r(!0,y,f)),r[d]=[u,f,...p]}}}}const vi=new ks().freeze();function jr(n,e){if(typeof e!="function")throw new TypeError("Cannot `"+n+"` without `parser`")}function Jr(n,e){if(typeof e!="function")throw new TypeError("Cannot `"+n+"` without `compiler`")}function Hr(n,e){if(e)throw new Error("Cannot call `"+n+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function Co(n){if(!Fi(n)||typeof n.type!="string")throw new TypeError("Expected node, got `"+n+"`")}function To(n,e,t){if(!t)throw new Error("`"+n+"` finished async. Use `"+e+"` instead")}function _n(n){return ip(n)?n:new ep(n)}function ip(n){return!!(n&&typeof n=="object"&&"message"in n&&"messages"in n)}function sp(n){return typeof n=="string"||op(n)}function op(n){return!!(n&&typeof n=="object"&&"byteLength"in n&&"byteOffset"in n)}var da=n=>{throw TypeError(n)},pa=(n,e,t)=>e.has(n)||da("Cannot "+t),F=(n,e,t)=>(pa(n,e,"read from private field"),t?t.call(n):e.get(n)),G=(n,e,t)=>e.has(n)?da("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),U=(n,e,t,r)=>(pa(n,e,"write to private field"),e.set(n,t),t),Be,an,jn,Jn,Hn,un,cn,Ye,hn,Kn,Un,fn,Yn,dn,Qn,Gn,_t,St,Xn,pn;class ma{}class ga{constructor(){this.elements=[],this.size=()=>this.elements.length,this.top=()=>this.elements.at(-1),this.push=e=>{this.top()?.push(e)},this.open=e=>{this.elements.push(e)},this.close=()=>{const e=this.elements.pop();if(!e)throw bl();return e}}}class xs extends ma{constructor(e,t,r){super(),this.type=e,this.content=t,this.attrs=r}push(e,...t){this.content.push(e,...t)}pop(){return this.content.pop()}static create(e,t,r){return new xs(e,t,r)}}const Li=class extends ga{constructor(e){super(),G(this,Be),G(this,an),G(this,jn),G(this,Jn),G(this,Hn),G(this,un),G(this,cn),U(this,Be,L.none),U(this,an,t=>t.isText),U(this,jn,(t,r)=>{if(F(this,an).call(this,t)&&F(this,an).call(this,r)&&L.sameSet(t.marks,r.marks))return this.schema.text(t.text+r.text,t.marks)}),U(this,Jn,t=>{const r=Object.values({...this.schema.nodes,...this.schema.marks}).find(i=>i.spec.parseMarkdown.match(t));if(!r)throw Uu(t);return r}),U(this,Hn,t=>{const r=F(this,Jn).call(this,t);r.spec.parseMarkdown.runner(this,t,r)}),this.injectRoot=(t,r,i)=>(this.openNode(r,i),this.next(t.children),this),this.openNode=(t,r)=>(this.open(xs.create(t,[],r)),this),U(this,un,()=>{U(this,Be,L.none);const t=this.close();return F(this,cn).call(this,t.type,t.attrs,t.content)}),this.closeNode=()=>{try{F(this,un).call(this)}catch(t){console.error(t)}return this},U(this,cn,(t,r,i)=>{const s=t.createAndFill(r,i,F(this,Be));if(!s)throw Ku(t,r,i);return this.push(s),s}),this.addNode=(t,r,i)=>{try{F(this,cn).call(this,t,r,i)}catch(s){console.error(s)}return this},this.openMark=(t,r)=>{const i=t.create(r);return U(this,Be,i.addToSet(F(this,Be))),this},this.closeMark=t=>(U(this,Be,t.removeFromSet(F(this,Be))),this),this.addText=t=>{try{const r=this.top();if(!r)throw bl();const i=r.pop(),s=this.schema.text(t,F(this,Be));if(!i)return r.push(s),this;const o=F(this,jn).call(this,i,s);return o?(r.push(o),this):(r.push(i,s),this)}catch(r){return console.error(r),this}},this.build=()=>{let t;do t=F(this,un).call(this);while(this.size());return t},this.next=(t=[])=>([t].flat().forEach(r=>F(this,Hn).call(this,r)),this),this.toDoc=()=>this.build(),this.run=(t,r)=>{const i=t.runSync(t.parse(r),r);return this.next(i),this},this.schema=e}};Be=new WeakMap;an=new WeakMap;jn=new WeakMap;Jn=new WeakMap;Hn=new WeakMap;un=new WeakMap;cn=new WeakMap;Li.create=(n,e)=>{const t=new Li(n);return r=>(t.run(e,r),t.toDoc())};let lp=Li;const Vi=class extends ma{constructor(e,t,r,i={}){super(),this.type=e,this.children=t,this.value=r,this.props=i,this.push=(s,...o)=>{this.children||(this.children=[]),this.children.push(s,...o)},this.pop=()=>this.children?.pop()}};Vi.create=(n,e,t,r={})=>new Vi(n,e,t,r);let Mo=Vi;const ap=n=>Object.prototype.hasOwnProperty.call(n,"size"),_i=class extends ga{constructor(e){super(),G(this,Ye),G(this,hn),G(this,Kn),G(this,Un),G(this,fn),G(this,Yn),G(this,dn),G(this,Qn),G(this,Gn),G(this,_t),G(this,St),G(this,Xn),G(this,pn),U(this,Ye,L.none),U(this,hn,t=>{const r=Object.values({...this.schema.nodes,...this.schema.marks}).find(i=>i.spec.toMarkdown.match(t));if(!r)throw Yu(t.type);return r}),U(this,Kn,t=>F(this,hn).call(this,t).spec.toMarkdown.runner(this,t)),U(this,Un,(t,r)=>F(this,hn).call(this,t).spec.toMarkdown.runner(this,t,r)),U(this,fn,t=>{const{marks:r}=t,i=l=>l.type.spec.priority??50;[...r].sort((l,a)=>i(l)-i(a)).every(l=>!F(this,Un).call(this,l,t))&&F(this,Kn).call(this,t),r.forEach(l=>F(this,pn).call(this,l))}),U(this,Yn,(t,r)=>{if(t.type===r||t.children?.length!==1)return t;const i=a=>{if(a.type===r)return a;if(a.children?.length!==1)return null;const[u]=a.children;return u?i(u):null},s=i(t);if(!s)return t;const o=s.children?[...s.children]:void 0,l={...t,children:o};return l.children=o,s.children=[l],s}),U(this,dn,t=>{const{children:r}=t;return r&&(t.children=r.reduce((i,s,o)=>{if(o===0)return[s];const l=i.at(-1);if(l&&l.isMark&&s.isMark){s=F(this,Yn).call(this,s,l.type);const{children:a,...u}=s,{children:c,...h}=l;if(s.type===l.type&&a&&c&&JSON.stringify(u)===JSON.stringify(h)){const d={...h,children:[...c,...a]};return i.slice(0,-1).concat(F(this,dn).call(this,d))}}return i.concat(s)},[])),t}),U(this,Qn,t=>{const r={...t.props,type:t.type};return t.children&&(r.children=t.children),t.value&&(r.value=t.value),r}),this.openNode=(t,r,i)=>(this.open(Mo.create(t,void 0,r,i)),this),U(this,Gn,(t,r)=>{let i="",s="";const o=t.children;let l=-1,a=-1;const u=h=>{h&&h.forEach((d,f)=>{d.type==="text"&&d.value&&(l<0&&(l=f),a=f)})};if(o){u(o);const h=o?.[a],d=o?.[l];if(h&&h.value.endsWith(" ")){const f=h.value,p=f.trimEnd();s=f.slice(p.length),h.value=p}if(d&&d.value.startsWith(" ")){const f=d.value,p=f.trimStart();i=f.slice(0,f.length-p.length),d.value=p}}i.length&&F(this,St).call(this,"text",void 0,i);const c=r();return s.length&&F(this,St).call(this,"text",void 0,s),c}),U(this,_t,(t=!1)=>{const r=this.close(),i=()=>F(this,St).call(this,r.type,r.children,r.value,r.props);return t?F(this,Gn).call(this,r,i):i()}),this.closeNode=()=>(F(this,_t).call(this),this),U(this,St,(t,r,i,s)=>{const o=Mo.create(t,r,i,s),l=F(this,dn).call(this,F(this,Qn).call(this,o));return this.push(l),l}),this.addNode=(t,r,i,s)=>(F(this,St).call(this,t,r,i,s),this),U(this,Xn,(t,r,i,s)=>t.isInSet(F(this,Ye))?this:(U(this,Ye,t.addToSet(F(this,Ye))),this.openNode(r,i,{...s,isMark:!0}))),U(this,pn,t=>{t.isInSet(F(this,Ye))&&(U(this,Ye,t.type.removeFromSet(F(this,Ye))),F(this,_t).call(this,!0))}),this.withMark=(t,r,i,s)=>(F(this,Xn).call(this,t,r,i,s),this),this.closeMark=t=>(F(this,pn).call(this,t),this),this.build=()=>{let t=null;do t=F(this,_t).call(this);while(this.size());return t},this.next=t=>ap(t)?(t.forEach(r=>{F(this,fn).call(this,r)}),this):(F(this,fn).call(this,t),this),this.toString=t=>t.stringify(this.build()),this.run=t=>(this.next(t),this),this.schema=e}};Ye=new WeakMap;hn=new WeakMap;Kn=new WeakMap;Un=new WeakMap;fn=new WeakMap;Yn=new WeakMap;dn=new WeakMap;Qn=new WeakMap;Gn=new WeakMap;_t=new WeakMap;St=new WeakMap;Xn=new WeakMap;pn=new WeakMap;_i.create=(n,e)=>{const t=new _i(n);return r=>(t.run(r),t.toString(e))};let up=_i;const ya=65535,ka=Math.pow(2,16);function cp(n,e){return n+e*ka}function No(n){return n&ya}function hp(n){return(n-(n&ya))/ka}const xa=1,ba=2,Zn=4,Sa=8;class $i{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&Sa)>0}get deletedBefore(){return(this.delInfo&(xa|Zn))>0}get deletedAfter(){return(this.delInfo&(ba|Zn))>0}get deletedAcross(){return(this.delInfo&Zn)>0}}class ke{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&ke.empty)return ke.empty}recover(e){let t=0,r=No(e);if(!this.inverted)for(let i=0;i<r;i++)t+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[r*3]+t+hp(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let i=0,s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?i:0);if(a>e)break;let u=this.ranges[l+s],c=this.ranges[l+o],h=a+u;if(e<=h){let d=u?e==a?-1:e==h?1:t:t,f=a+i+(d<0?0:c);if(r)return f;let p=e==(t<0?a:h)?null:cp(l/3,e-a),y=e==a?ba:e==h?xa:Zn;return(t<0?e!=a:e!=h)&&(y|=Sa),new $i(f,y,p)}i+=c-u}return r?e+i:new $i(e+i,0,null)}touches(e,t){let r=0,i=No(t),s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let u=this.ranges[l+s],c=a+u;if(e<=c&&l==i*3)return!0;r+=this.ranges[l+o]-u}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,s=0;i<this.ranges.length;i+=3){let o=this.ranges[i],l=o-(this.inverted?s:0),a=o+(this.inverted?0:s),u=this.ranges[i+t],c=this.ranges[i+r];e(l,l+u,a,a+c),s+=c-u}}invert(){return new ke(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?ke.empty:new ke(e<0?[0,-e,0]:[0,0,e])}}ke.empty=new ke([]);class gr{constructor(e,t,r=0,i=e?e.length:0){this.mirror=t,this.from=r,this.to=i,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new gr(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,r=this._maps.length;t<e._maps.length;t++){let i=e.getMirror(t);this.appendMap(e._maps[t],i!=null&&i<t?r+i:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,r=this._maps.length+e._maps.length;t>=0;t--){let i=e.getMirror(t);this.appendMap(e._maps[t].invert(),i!=null&&i>t?r-i-1:void 0)}}invert(){let e=new gr;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let i=0;for(let s=this.from;s<this.to;s++){let o=this._maps[s],l=o.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(s);if(a!=null&&a>s&&a<this.to){s=a,e=this._maps[a].recover(l.recover);continue}}i|=l.delInfo,e=l.pos}return r?e:new $i(e,i,null)}}const Kr=Object.create(null);class ce{getMap(){return ke.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Kr[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Kr)throw new RangeError("Duplicate use of step JSON ID "+e);return Kr[e]=t,t.prototype.jsonID=e,t}}class X{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new X(e,null)}static fail(e){return new X(null,e)}static fromReplace(e,t,r,i){try{return X.ok(e.replace(t,r,i))}catch(s){if(s instanceof hr)return X.fail(s.message);throw s}}}function bs(n,e,t){let r=[];for(let i=0;i<n.childCount;i++){let s=n.child(i);s.content.size&&(s=s.copy(bs(s.content,e,s))),s.isInline&&(s=e(s,t,i)),r.push(s)}return T.fromArray(r)}class lt extends ce{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),s=new M(bs(t.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),i),t.openStart,t.openEnd);return X.fromReplace(e,this.from,this.to,s)}invert(){return new Ve(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new lt(t.pos,r.pos,this.mark)}merge(e){return e instanceof lt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new lt(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,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new lt(t.from,t.to,e.markFromJSON(t.mark))}}ce.jsonID("addMark",lt);class Ve extends ce{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new M(bs(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return X.fromReplace(e,this.from,this.to,r)}invert(){return new lt(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new Ve(t.pos,r.pos,this.mark)}merge(e){return e instanceof Ve&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ve(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,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Ve(t.from,t.to,e.markFromJSON(t.mark))}}ce.jsonID("removeMark",Ve);class at extends ce{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return X.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return X.fromReplace(e,this.pos,this.pos+1,new M(T.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let i=0;i<t.marks.length;i++)if(!t.marks[i].isInSet(r))return new at(this.pos,t.marks[i]);return new at(this.pos,this.mark)}}return new Dt(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new at(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new at(t.pos,e.markFromJSON(t.mark))}}ce.jsonID("addNodeMark",at);class Dt extends ce{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return X.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return X.fromReplace(e,this.pos,this.pos+1,new M(T.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new at(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Dt(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Dt(t.pos,e.markFromJSON(t.mark))}}ce.jsonID("removeNodeMark",Dt);class ie extends ce{constructor(e,t,r,i=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=i}apply(e){return this.structure&&qi(e,this.from,this.to)?X.fail("Structure replace would overwrite content"):X.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new ke([this.from,this.to-this.from,this.slice.size])}invert(e){return new ie(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deletedAcross&&r.deletedAcross?null:new ie(t.pos,Math.max(t.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof ie)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?M.empty:new M(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new ie(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?M.empty:new M(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new ie(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new ie(t.from,t.to,M.fromJSON(e,t.slice),!!t.structure)}}ce.jsonID("replace",ie);class xe extends ce{constructor(e,t,r,i,s,o,l=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=i,this.slice=s,this.insert=o,this.structure=l}apply(e){if(this.structure&&(qi(e,this.from,this.gapFrom)||qi(e,this.gapTo,this.to)))return X.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return X.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?X.fromReplace(e,this.from,this.to,r):X.fail("Content does not fit in gap")}getMap(){return new ke([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new xe(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||i<t.pos||s>r.pos?null:new xe(t.pos,r.pos,i,s,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,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new xe(t.from,t.to,t.gapFrom,t.gapTo,M.fromJSON(e,t.slice),t.insert,!!t.structure)}}ce.jsonID("replaceAround",xe);function qi(n,e,t){let r=n.resolve(e),i=t-e,s=r.depth;for(;i>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,i--;if(i>0){let o=r.node(s).maybeChild(r.indexAfter(s));for(;i>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,i--}}return!1}function fp(n,e,t,r){let i=[],s=[],o,l;n.doc.nodesBetween(e,t,(a,u,c)=>{if(!a.isInline)return;let h=a.marks;if(!r.isInSet(h)&&c.type.allowsMarkType(r.type)){let d=Math.max(u,e),f=Math.min(u+a.nodeSize,t),p=r.addToSet(h);for(let y=0;y<h.length;y++)h[y].isInSet(p)||(o&&o.to==d&&o.mark.eq(h[y])?o.to=f:i.push(o=new Ve(d,f,h[y])));l&&l.to==d?l.to=f:s.push(l=new lt(d,f,r))}}),i.forEach(a=>n.step(a)),s.forEach(a=>n.step(a))}function dp(n,e,t,r){let i=[],s=0;n.doc.nodesBetween(e,t,(o,l)=>{if(!o.isInline)return;s++;let a=null;if(r instanceof Mr){let u=o.marks,c;for(;c=r.isInSet(u);)(a||(a=[])).push(c),u=c.removeFromSet(u)}else r?r.isInSet(o.marks)&&(a=[r]):a=o.marks;if(a&&a.length){let u=Math.min(l+o.nodeSize,t);for(let c=0;c<a.length;c++){let h=a[c],d;for(let f=0;f<i.length;f++){let p=i[f];p.step==s-1&&h.eq(i[f].style)&&(d=p)}d?(d.to=u,d.step=s):i.push({style:h,from:Math.max(l,e),to:u,step:s})}}}),i.forEach(o=>n.step(new Ve(o.from,o.to,o.style)))}function Ss(n,e,t,r=t.contentMatch,i=!0){let s=n.doc.nodeAt(e),o=[],l=e+1;for(let a=0;a<s.childCount;a++){let u=s.child(a),c=l+u.nodeSize,h=r.matchType(u.type);if(!h)o.push(new ie(l,c,M.empty));else{r=h;for(let d=0;d<u.marks.length;d++)t.allowsMarkType(u.marks[d].type)||n.step(new Ve(l,c,u.marks[d]));if(i&&u.isText&&t.whitespace!="pre"){let d,f=/\r?\n|\r/g,p;for(;d=f.exec(u.text);)p||(p=new M(T.from(t.schema.text(" ",t.allowedMarks(u.marks))),0,0)),o.push(new ie(l+d.index,l+d.index+d[0].length,p))}}l=c}if(!r.validEnd){let a=r.fillBefore(T.empty,!0);n.replace(l,l,new M(a,0,0))}for(let a=o.length-1;a>=0;a--)n.step(o[a])}function pp(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function ws(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth,i=0,s=0;;--r){let o=n.$from.node(r),l=n.$from.index(r)+i,a=n.$to.indexAfter(r)-s;if(r<n.depth&&o.canReplace(l,a,t))return r;if(r==0||o.type.spec.isolating||!pp(o,l,a))break;l&&(i=1),a<o.childCount&&(s=1)}return null}function mp(n,e,t){let{$from:r,$to:i,depth:s}=e,o=r.before(s+1),l=i.after(s+1),a=o,u=l,c=T.empty,h=0;for(let p=s,y=!1;p>t;p--)y||r.index(p)>0?(y=!0,c=T.from(r.node(p).copy(c)),h++):a--;let d=T.empty,f=0;for(let p=s,y=!1;p>t;p--)y||i.after(p+1)<i.end(p)?(y=!0,d=T.from(i.node(p).copy(d)),f++):u++;n.step(new xe(a,u,o,l,new M(c.append(d),h,f),c.size-h,!0))}function wa(n,e,t=null,r=n){let i=gp(n,e),s=i&&yp(r,e);return s?i.map(Oo).concat({type:e,attrs:t}).concat(s.map(Oo)):null}function Oo(n){return{type:n,attrs:null}}function gp(n,e){let{parent:t,startIndex:r,endIndex:i}=n,s=t.contentMatchAt(r).findWrapping(e);if(!s)return null;let o=s.length?s[0]:e;return t.canReplaceWith(r,i,o)?s:null}function yp(n,e){let{parent:t,startIndex:r,endIndex:i}=n,s=t.child(r),o=e.contentMatch.findWrapping(s.type);if(!o)return null;let a=(o.length?o[o.length-1]:e).contentMatch;for(let u=r;a&&u<i;u++)a=a.matchType(t.child(u).type);return!a||!a.validEnd?null:o}function kp(n,e,t){let r=T.empty;for(let o=t.length-1;o>=0;o--){if(r.size){let l=t[o].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=T.from(t[o].type.create(t[o].attrs,r))}let i=e.start,s=e.end;n.step(new xe(i,s,i,s,new M(r,0,0),t.length,!0))}function xp(n,e,t,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=n.steps.length;n.doc.nodesBetween(e,t,(o,l)=>{let a=typeof i=="function"?i(o):i;if(o.isTextblock&&!o.hasMarkup(r,a)&&bp(n.doc,n.mapping.slice(s).map(l),r)){let u=null;if(r.schema.linebreakReplacement){let f=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);f&&!p?u=!1:!f&&p&&(u=!0)}u===!1&&Ta(n,o,l,s),Ss(n,n.mapping.slice(s).map(l,1),r,void 0,u===null);let c=n.mapping.slice(s),h=c.map(l,1),d=c.map(l+o.nodeSize,1);return n.step(new xe(h,d,h+1,d-1,new M(T.from(r.create(a,null,o.marks)),0,0),1,!0)),u===!0&&Ca(n,o,l,s),!1}})}function Ca(n,e,t,r){e.forEach((i,s)=>{if(i.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(i.text);){let a=n.mapping.slice(r).map(t+1+s+o.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Ta(n,e,t,r){e.forEach((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let o=n.mapping.slice(r).map(t+1+s);n.replaceWith(o,o+1,e.type.schema.text(`
38
- `))}})}function bp(n,e,t){let r=n.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,t)}function Sp(n,e,t,r,i){let s=n.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");t||(t=s.type);let o=t.create(r,null,i||s.marks);if(s.isLeaf)return n.replaceWith(e,e+s.nodeSize,o);if(!t.validContent(s.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new xe(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new M(T.from(o),0,0),1,!0))}function er(n,e,t=1,r){let i=n.resolve(e),s=i.depth-t,o=r&&r[r.length-1]||i.parent;if(s<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let u=i.depth-1,c=t-2;u>s;u--,c--){let h=i.node(u),d=i.index(u);if(h.type.spec.isolating)return!1;let f=h.content.cutByIndex(d,h.childCount),p=r&&r[c+1];p&&(f=f.replaceChild(0,p.type.create(p.attrs)));let y=r&&r[c]||h;if(!h.canReplace(d+1,h.childCount)||!y.type.validContent(f))return!1}let l=i.indexAfter(s),a=r&&r[0];return i.node(s).canReplaceWith(l,l,a?a.type:i.node(s+1).type)}function wp(n,e,t=1,r){let i=n.doc.resolve(e),s=T.empty,o=T.empty;for(let l=i.depth,a=i.depth-t,u=t-1;l>a;l--,u--){s=T.from(i.node(l).copy(s));let c=r&&r[u];o=T.from(c?c.type.create(c.attrs,o):i.node(l).copy(o))}n.step(new ie(e,e,new M(s.append(o),t,t),!0))}function Cs(n,e){let t=n.resolve(e),r=t.index();return Tp(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function Cp(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let i=0;i<e.childCount;i++){let s=e.child(i),o=s.type==r?n.type.schema.nodes.text:s.type;if(t=t.matchType(o),!t||!n.type.allowsMarks(s.marks))return!1}return t.validEnd}function Tp(n,e){return!!(n&&e&&!n.isLeaf&&Cp(n,e))}function Mp(n,e,t){let r=null,{linebreakReplacement:i}=n.doc.type.schema,s=n.doc.resolve(e-t),o=s.node().type;if(i&&o.inlineContent){let c=o.whitespace=="pre",h=!!o.contentMatch.matchType(i);c&&!h?r=!1:!c&&h&&(r=!0)}let l=n.steps.length;if(r===!1){let c=n.doc.resolve(e+t);Ta(n,c.node(),c.before(),l)}o.inlineContent&&Ss(n,e+t-1,o,s.node().contentMatchAt(s.index()),r==null);let a=n.mapping.slice(l),u=a.map(e-t);if(n.step(new ie(u,a.map(e+t,-1),M.empty,!0)),r===!0){let c=n.doc.resolve(u);Ca(n,c.node(),c.before(),n.steps.length)}return n}function Np(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let s=r.index(i);if(r.node(i).canReplaceWith(s,s,t))return r.before(i+1);if(s>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let s=r.indexAfter(i);if(r.node(i).canReplaceWith(s,s,t))return r.after(i+1);if(s<r.node(i).childCount)return null}return null}function Op(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let i=t.content;for(let s=0;s<t.openStart;s++)i=i.firstChild.content;for(let s=1;s<=(t.openStart==0&&t.size?2:1);s++)for(let o=r.depth;o>=0;o--){let l=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,a=r.index(o)+(l>0?1:0),u=r.node(o),c=!1;if(s==1)c=u.canReplace(a,a,i);else{let h=u.contentMatchAt(a).findWrapping(i.firstChild.type);c=h&&u.canReplaceWith(a,a,h[0])}if(c)return l==0?r.pos:l<0?r.before(o+1):r.after(o+1)}return null}function Er(n,e,t=e,r=M.empty){if(e==t&&!r.size)return null;let i=n.resolve(e),s=n.resolve(t);return Ma(i,s,r)?new ie(e,t,r):new Ep(i,s,r).fit()}function Ma(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class Ep{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=T.empty;for(let i=0;i<=e.depth;i++){let s=e.node(i);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=T.from(e.node(i).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(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let s=this.placed,o=r.depth,l=i.depth;for(;o&&l&&s.childCount==1;)s=s.firstChild.content,o--,l--;let a=new M(s,o,l);return e>-1?new xe(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new ie(r.pos,i.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<e;r++){let s=t.firstChild;if(t.childCount>1&&(i=0),s.type.spec.isolating&&i<=r){e=r;break}t=s.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let i,s=null;r?(s=Ur(this.unplaced.content,r-1).firstChild,i=s.content):i=this.unplaced.content;let o=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:u}=this.frontier[l],c,h=null;if(t==1&&(o?u.matchType(o.type)||(h=u.fillBefore(T.from(o),!1)):s&&a.compatibleContent(s.type)))return{sliceDepth:r,frontierDepth:l,parent:s,inject:h};if(t==2&&o&&(c=u.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:l,parent:s,wrap:c};if(s&&u.matchType(s.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=Ur(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new M(e,t+1,Math.max(r,i.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=Ur(e,t);if(i.childCount<=1&&t>0){let s=e.size-t<=t+i.size;this.unplaced=new M(mn(e,t-1,1),t-1,s?t-1:r)}else this.unplaced=new M(mn(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:i,wrap:s}){for(;this.depth>t;)this.closeFrontierNode();if(s)for(let y=0;y<s.length;y++)this.openFrontierNode(s[y]);let o=this.unplaced,l=r?r.content:o.content,a=o.openStart-e,u=0,c=[],{match:h,type:d}=this.frontier[t];if(i){for(let y=0;y<i.childCount;y++)c.push(i.child(y));h=h.matchFragment(i)}let f=l.size+e-(o.content.size-o.openEnd);for(;u<l.childCount;){let y=l.child(u),x=h.matchType(y.type);if(!x)break;u++,(u>1||a==0||y.content.size)&&(h=x,c.push(Na(y.mark(d.allowedMarks(y.marks)),u==1?a:0,u==l.childCount?f:-1)))}let p=u==l.childCount;p||(f=-1),this.placed=gn(this.placed,t,T.from(c)),this.frontier[t].match=h,p&&f<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let y=0,x=l;y<f;y++){let k=x.lastChild;this.frontier.push({type:k.type,match:k.contentMatchAt(k.childCount)}),x=k.content}this.unplaced=p?e==0?M.empty:new M(mn(o.content,e-1,1),e-1,f<0?o.openEnd:e-1):new M(mn(o.content,e,u),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!Yr(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:r}=this.$to,i=this.$to.after(r);for(;r>1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:i}=this.frontier[t],s=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),o=Yr(e,t,i,r,s);if(o){for(let l=t-1;l>=0;l--){let{match:a,type:u}=this.frontier[l],c=Yr(e,l,u,a,!0);if(!c||c.childCount)continue e}return{depth:t,fit:o,move:s?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=gn(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let i=e.node(r),s=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,s)}return e}openFrontierNode(e,t=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=gn(this.placed,this.depth,T.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(T.empty,!0);t.childCount&&(this.placed=gn(this.placed,this.frontier.length,t))}}function mn(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(mn(n.firstChild.content,e-1,t)))}function gn(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(gn(n.lastChild.content,e-1,t)))}function Ur(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function Na(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,Na(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(T.empty,!0)))),n.copy(r)}function Yr(n,e,t,r,i){let s=n.node(e),o=i?n.indexAfter(e):n.index(e);if(o==s.childCount&&!t.compatibleContent(s.type))return null;let l=r.fillBefore(s.content,!0,o);return l&&!Ip(t,s.content,o)?l:null}function Ip(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function Ap(n){return n.spec.defining||n.spec.definingForContent}function Dp(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let i=n.doc.resolve(e),s=n.doc.resolve(t);if(Ma(i,s,r))return n.step(new ie(e,t,r));let o=Ea(i,s);o[o.length-1]==0&&o.pop();let l=-(i.depth+1);o.unshift(l);for(let d=i.depth,f=i.pos-1;d>0;d--,f--){let p=i.node(d).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;o.indexOf(d)>-1?l=d:i.before(d)==f&&o.splice(1,0,-d)}let a=o.indexOf(l),u=[],c=r.openStart;for(let d=r.content,f=0;;f++){let p=d.firstChild;if(u.push(p),f==r.openStart)break;d=p.content}for(let d=c-1;d>=0;d--){let f=u[d],p=Ap(f.type);if(p&&!f.sameMarkup(i.node(Math.abs(l)-1)))c=d;else if(p||!f.type.isTextblock)break}for(let d=r.openStart;d>=0;d--){let f=(d+c+1)%(r.openStart+1),p=u[f];if(p)for(let y=0;y<o.length;y++){let x=o[(y+a)%o.length],k=!0;x<0&&(k=!1,x=-x);let I=i.node(x-1),C=i.index(x-1);if(I.canReplaceWith(C,C,p.type,p.marks))return n.replace(i.before(x),k?s.after(x):t,new M(Oa(r.content,0,r.openStart,f),f,r.openEnd))}}let h=n.steps.length;for(let d=o.length-1;d>=0&&(n.replace(e,t,r),!(n.steps.length>h));d--){let f=o[d];f<0||(e=i.before(f),t=s.after(f))}}function Oa(n,e,t,r,i){if(e<t){let s=n.firstChild;n=n.replaceChild(0,s.copy(Oa(s.content,e+1,t,r,s)))}if(e>r){let s=i.contentMatchAt(0),o=s.fillBefore(n).append(n);n=o.append(s.matchFragment(o).fillBefore(T.empty,!0))}return n}function Rp(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=Np(n.doc,e,r.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new M(T.from(r),0,0))}function zp(n,e,t){let r=n.doc.resolve(e),i=n.doc.resolve(t),s=Ea(r,i);for(let o=0;o<s.length;o++){let l=s[o],a=o==s.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return n.delete(r.start(l),i.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),i.indexAfter(l-1))))return n.delete(r.before(l),i.after(l))}for(let o=1;o<=r.depth&&o<=i.depth;o++)if(e-r.start(o)==r.depth-o&&t>r.end(o)&&i.end(o)-t!=i.depth-o&&r.start(o-1)==i.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),i.index(o-1)))return n.delete(r.before(o),t);n.delete(e,t)}function Ea(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let i=r;i>=0;i--){let s=n.start(i);if(s<n.pos-(n.depth-i)||e.end(i)>e.pos+(e.depth-i)||n.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(s==e.start(i)||i==n.depth&&i==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==s-1)&&t.push(i)}return t}class Jt extends ce{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return X.fail("No node at attribute step's position");let r=Object.create(null);for(let s in t.attrs)r[s]=t.attrs[s];r[this.attr]=this.value;let i=t.type.create(r,null,t.marks);return X.fromReplace(e,this.pos,this.pos+1,new M(T.from(i),0,t.isLeaf?0:1))}getMap(){return ke.empty}invert(e){return new Jt(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Jt(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Jt(t.pos,t.attr,t.value)}}ce.jsonID("attr",Jt);class En extends ce{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return X.ok(r)}getMap(){return ke.empty}invert(e){return new En(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new En(t.attr,t.value)}}ce.jsonID("docAttr",En);let Qt=class extends Error{};Qt=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};Qt.prototype=Object.create(Error.prototype);Qt.prototype.constructor=Qt;Qt.prototype.name="TransformError";class Pp{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new gr}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Qt(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let i=this.mapping.maps[r];r&&(e=i.map(e,1),t=i.map(t,-1)),i.forEach((s,o,l,a)=>{e=Math.min(e,l),t=Math.max(t,a)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,r=M.empty){let i=Er(this.doc,e,t,r);return i&&this.step(i),this}replaceWith(e,t,r){return this.replace(e,t,new M(T.from(r),0,0))}delete(e,t){return this.replace(e,t,M.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return Dp(this,e,t,r),this}replaceRangeWith(e,t,r){return Rp(this,e,t,r),this}deleteRange(e,t){return zp(this,e,t),this}lift(e,t){return mp(this,e,t),this}join(e,t=1){return Mp(this,e,t),this}wrap(e,t){return kp(this,e,t),this}setBlockType(e,t=e,r,i=null){return xp(this,e,t,r,i),this}setNodeMarkup(e,t,r=null,i){return Sp(this,e,t,r,i),this}setNodeAttribute(e,t,r){return this.step(new Jt(e,t,r)),this}setDocAttribute(e,t){return this.step(new En(e,t)),this}addNodeMark(e,t){return this.step(new at(e,t)),this}removeNodeMark(e,t){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t instanceof L)t.isInSet(r.marks)&&this.step(new Dt(e,t));else{let i=r.marks,s,o=[];for(;s=t.isInSet(i);)o.push(new Dt(e,s)),i=s.removeFromSet(i);for(let l=o.length-1;l>=0;l--)this.step(o[l])}return this}split(e,t=1,r){return wp(this,e,t,r),this}addMark(e,t,r){return fp(this,e,t,r),this}removeMark(e,t,r){return dp(this,e,t,r),this}clearIncompatible(e,t,r){return Ss(this,e,t,r),this}}const Qr=Object.create(null);class W{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new Fp(e.min(t),e.max(t))]}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 t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=M.empty){let r=t.content.lastChild,i=null;for(let l=0;l<t.openEnd;l++)i=r,r=r.lastChild;let s=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:a,$to:u}=o[l],c=e.mapping.slice(s);e.replaceRange(c.map(a.pos),c.map(u.pos),l?M.empty:t),l==0&&Ao(e,s,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:o,$to:l}=i[s],a=e.mapping.slice(r),u=a.map(o.pos),c=a.map(l.pos);s?e.deleteRange(u,c):(e.replaceRangeWith(u,c,t),Ao(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let i=e.parent.inlineContent?new j(e):$t(e.node(0),e.parent,e.pos,e.index(),t,r);if(i)return i;for(let s=e.depth-1;s>=0;s--){let o=t<0?$t(e.node(0),e.node(s),e.before(s+1),e.index(s),t,r):$t(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,r);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new be(e.node(0))}static atStart(e){return $t(e,e,0,0,1)||new be(e)}static atEnd(e){return $t(e,e,e.content.size,e.childCount,-1)||new be(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Qr[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Qr)throw new RangeError("Duplicate use of selection JSON ID "+e);return Qr[e]=t,t.prototype.jsonID=e,t}getBookmark(){return j.between(this.$anchor,this.$head).getBookmark()}}W.prototype.visible=!0;class Fp{constructor(e,t){this.$from=e,this.$to=t}}let Eo=!1;function Io(n){!Eo&&!n.parent.inlineContent&&(Eo=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class j extends W{constructor(e,t=e){Io(e),Io(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return W.near(r);let i=e.resolve(t.map(this.anchor));return new j(i.parent.inlineContent?i:r,r)}replace(e,t=M.empty){if(super.replace(e,t),t==M.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof j&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Ir(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new j(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let i=e.resolve(t);return new this(i,r==t?i:e.resolve(r))}static between(e,t,r){let i=e.pos-t.pos;if((!r||i)&&(r=i>=0?1:-1),!t.parent.inlineContent){let s=W.findFrom(t,r,!0)||W.findFrom(t,-r,!0);if(s)t=s.$head;else return W.near(t,r)}return e.parent.inlineContent||(i==0?e=t:(e=(W.findFrom(e,-r,!0)||W.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=i<0&&(e=t))),new j(e,t)}}W.jsonID("text",j);class Ir{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Ir(e.map(this.anchor),e.map(this.head))}resolve(e){return j.between(e.resolve(this.anchor),e.resolve(this.head))}}class D extends W{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:i}=t.mapResult(this.anchor),s=e.resolve(i);return r?W.near(s):new D(s)}content(){return new M(T.from(this.node),0,0)}eq(e){return e instanceof D&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Ts(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new D(e.resolve(t.anchor))}static create(e,t){return new D(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}D.prototype.visible=!1;W.jsonID("node",D);class Ts{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new Ir(r,r):new Ts(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&D.isSelectable(r)?new D(t):W.near(t)}}class be extends W{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=M.empty){if(t==M.empty){e.delete(0,e.doc.content.size);let r=W.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new be(e)}map(e){return new be(e)}eq(e){return e instanceof be}getBookmark(){return Bp}}W.jsonID("all",be);const Bp={map(){return this},resolve(n){return new be(n)}};function $t(n,e,t,r,i,s=!1){if(e.inlineContent)return j.create(n,t);for(let o=r-(i>0?0:1);i>0?o<e.childCount:o>=0;o+=i){let l=e.child(o);if(l.isAtom){if(!s&&D.isSelectable(l))return D.create(n,t-(i<0?l.nodeSize:0))}else{let a=$t(n,l,t+i,i<0?l.childCount:0,i,s);if(a)return a}t+=l.nodeSize*i}return null}function Ao(n,e,t){let r=n.steps.length-1;if(r<e)return;let i=n.steps[r];if(!(i instanceof ie||i instanceof xe))return;let s=n.mapping.maps[r],o;s.forEach((l,a,u,c)=>{o==null&&(o=c)}),n.setSelection(W.near(n.doc.resolve(o),t))}const Do=1,$n=2,Ro=4;class vp extends Pp{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.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|Do)&~$n,this.storedMarks=null,this}get selectionSet(){return(this.updated&Do)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=$n,this}ensureMarks(e){return L.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&$n)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~$n,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||L.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let i=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),!e)return this.deleteRange(t,r);let s=this.storedMarks;if(!s){let o=this.doc.resolve(t);s=r==t?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,i.text(e,s)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(W.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,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|=Ro,this}get scrolledIntoView(){return(this.updated&Ro)>0}}function zo(n,e){return!e||!n?n:n.bind(e)}class yn{constructor(e,t,r){this.name=e,this.init=zo(t.init,r),this.apply=zo(t.apply,r)}}const Lp=[new yn("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new yn("selection",{init(n,e){return n.selection||W.atStart(e.doc)},apply(n){return n.selection}}),new yn("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new yn("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class Gr{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Lp.slice(),t&&t.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 yn(r.key,r.spec.state,r))})}}class Wt{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,t=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=t){let i=this.config.plugins[r];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],r=this.applyInner(e),i=null;for(;;){let s=!1;for(let o=0;o<this.config.plugins.length;o++){let l=this.config.plugins[o];if(l.spec.appendTransaction){let a=i?i[o].n:0,u=i?i[o].state:this,c=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,u,r);if(c&&r.filterTransaction(c,o)){if(c.setMeta("appendedTransaction",e),!i){i=[];for(let h=0;h<this.config.plugins.length;h++)i.push(h<o?{state:r,n:t.length}:{state:this,n:0})}t.push(c),r=r.applyInner(c),s=!0}i&&(i[o]={state:r,n:t.length})}}if(!s)return{state:r,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new Wt(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let s=r[i];t[s.name]=s.apply(e,this[s.name],this,t)}return t}get tr(){return new vp(this)}static create(e){let t=new Gr(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Wt(t);for(let i=0;i<t.fields.length;i++)r[t.fields[i].name]=t.fields[i].init(e,r);return r}reconfigure(e){let t=new Gr(this.schema,e.plugins),r=t.fields,i=new Wt(t);for(let s=0;s<r.length;s++){let o=r[s].name;i[o]=this.hasOwnProperty(o)?this[o]:r[s].init(e,i)}return i}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],s=i.spec.state;s&&s.toJSON&&(t[r]=s.toJSON.call(i,this[i.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new Gr(e.schema,e.plugins),s=new Wt(i);return i.fields.forEach(o=>{if(o.name=="doc")s.doc=Pe.fromJSON(e.schema,t.doc);else if(o.name=="selection")s.selection=W.fromJSON(s.doc,t.selection);else if(o.name=="storedMarks")t.storedMarks&&(s.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],u=a.spec.state;if(a.key==o.name&&u&&u.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){s[o.name]=u.fromJSON.call(a,e,t[l],s);return}}s[o.name]=o.init(e,s)}}),s}}function Ia(n,e,t){for(let r in n){let i=n[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=Ia(i,e,{})),t[r]=i}return t}class Ar{constructor(e){this.spec=e,this.props={},e.props&&Ia(e.props,this,this.props),this.key=e.key?e.key.key:Aa("plugin")}getState(e){return e[this.key]}}const Xr=Object.create(null);function Aa(n){return n in Xr?n+"$"+ ++Xr[n]:(Xr[n]=0,n+"$")}class Ms{constructor(e="key"){this.key=Aa(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Ns=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function Da(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const Vp=(n,e,t)=>{let r=Da(n,t);if(!r)return!1;let i=Os(r);if(!i){let o=r.blockRange(),l=o&&ws(o);return l==null?!1:(e&&e(n.tr.lift(o,l).scrollIntoView()),!0)}let s=i.nodeBefore;if(Pa(n,i,e,-1))return!0;if(r.parent.content.size==0&&(Gt(s,"end")||D.isSelectable(s)))for(let o=r.depth;;o--){let l=Er(n.doc,r.before(o),r.after(o),M.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(Gt(s,"end")?W.findFrom(a.doc.resolve(a.mapping.map(i.pos,-1)),-1):D.create(a.doc,i.pos-s.nodeSize)),e(a.scrollIntoView())}return!0}if(o==1||r.node(o-1).childCount>1)break}return s.isAtom&&i.depth==r.depth-1?(e&&e(n.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),!0):!1},_p=(n,e,t)=>{let r=Da(n,t);if(!r)return!1;let i=Os(r);return i?$p(n,i,e):!1};function $p(n,e,t){let r=e.nodeBefore,i=r,s=e.pos-1;for(;!i.isTextblock;s--){if(i.type.spec.isolating)return!1;let c=i.lastChild;if(!c)return!1;i=c}let o=e.nodeAfter,l=o,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let c=l.firstChild;if(!c)return!1;l=c}let u=Er(n.doc,s,a,M.empty);if(!u||u.from!=s||u instanceof ie&&u.slice.size>=a-s)return!1;if(t){let c=n.tr.step(u);c.setSelection(j.create(c.doc,s)),t(c.scrollIntoView())}return!0}function Gt(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}const Ra=(n,e,t)=>{let{$head:r,empty:i}=n.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;s=Os(r)}let o=s&&s.nodeBefore;return!o||!D.isSelectable(o)?!1:(e&&e(n.tr.setSelection(D.create(n.doc,s.pos-o.nodeSize)).scrollIntoView()),!0)};function Os(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function qp(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const Wp=(n,e,t)=>{let r=qp(n,t);if(!r)return!1;let i=za(r);if(!i)return!1;let s=i.nodeAfter;if(Pa(n,i,e,1))return!0;if(r.parent.content.size==0&&(Gt(s,"start")||D.isSelectable(s))){let o=Er(n.doc,r.before(),r.after(),M.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=n.tr.step(o);l.setSelection(Gt(s,"start")?W.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):D.create(l.doc,l.mapping.map(i.pos))),e(l.scrollIntoView())}return!0}}return s.isAtom&&i.depth==r.depth-1?(e&&e(n.tr.delete(i.pos,i.pos+s.nodeSize).scrollIntoView()),!0):!1},jp=(n,e,t)=>{let{$head:r,empty:i}=n.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset<r.parent.content.size)return!1;s=za(r)}let o=s&&s.nodeAfter;return!o||!D.isSelectable(o)?!1:(e&&e(n.tr.setSelection(D.create(n.doc,s.pos)).scrollIntoView()),!0)};function za(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){let t=n.node(e);if(n.index(e)+1<t.childCount)return n.doc.resolve(n.after(e+1));if(t.type.spec.isolating)break}return null}const Jp=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(`
39
- `).scrollIntoView()),!0)};function Es(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const Hp=(n,e)=>{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let i=t.node(-1),s=t.indexAfter(-1),o=Es(i.contentMatchAt(s));if(!o||!i.canReplaceWith(s,s,o))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,o.createAndFill());a.setSelection(W.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Kp=(n,e)=>{let t=n.selection,{$from:r,$to:i}=t;if(t instanceof be||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=Es(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let o=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,l=n.tr.insert(o,s.createAndFill());l.setSelection(j.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},Up=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let s=t.before();if(er(n.doc,s))return e&&e(n.tr.split(s).scrollIntoView()),!0}let r=t.blockRange(),i=r&&ws(r);return i==null?!1:(e&&e(n.tr.lift(r,i).scrollIntoView()),!0)};function Yp(n){return(e,t)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof D&&e.selection.node.isBlock)return!r.parentOffset||!er(e.doc,r.pos)?!1:(t&&t(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let s=[],o,l,a=!1,u=!1;for(let f=r.depth;;f--)if(r.node(f).isBlock){a=r.end(f)==r.pos+(r.depth-f),u=r.start(f)==r.pos-(r.depth-f),l=Es(r.node(f-1).contentMatchAt(r.indexAfter(f-1))),s.unshift(a&&l?{type:l}:null),o=f;break}else{if(f==1)return!1;s.unshift(null)}let c=e.tr;(e.selection instanceof j||e.selection instanceof be)&&c.deleteSelection();let h=c.mapping.map(r.pos),d=er(c.doc,h,s.length,s);if(d||(s[0]=l?{type:l}:null,d=er(c.doc,h,s.length,s)),!d)return!1;if(c.split(h,s.length,s),!a&&u&&r.node(o).type!=l){let f=c.mapping.map(r.before(o)),p=c.doc.resolve(f);l&&r.node(o-1).canReplaceWith(p.index(),p.index()+1,l)&&c.setNodeMarkup(c.mapping.map(r.before(o)),l)}return t&&t(c.scrollIntoView()),!0}}const Qp=Yp(),Gp=(n,e)=>(e&&e(n.tr.setSelection(new be(n.doc))),!0);function Xp(n,e,t){let r=e.nodeBefore,i=e.nodeAfter,s=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(s-1,s)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(i.isTextblock||Cs(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function Pa(n,e,t,r){let i=e.nodeBefore,s=e.nodeAfter,o,l,a=i.type.spec.isolating||s.type.spec.isolating;if(!a&&Xp(n,e,t))return!0;let u=!a&&e.parent.canReplace(e.index(),e.index()+1);if(u&&(o=(l=i.contentMatchAt(i.childCount)).findWrapping(s.type))&&l.matchType(o[0]||s.type).validEnd){if(t){let f=e.pos+s.nodeSize,p=T.empty;for(let k=o.length-1;k>=0;k--)p=T.from(o[k].create(null,p));p=T.from(i.copy(p));let y=n.tr.step(new xe(e.pos-1,f,e.pos,f,new M(p,1,0),o.length,!0)),x=y.doc.resolve(f+2*o.length);x.nodeAfter&&x.nodeAfter.type==i.type&&Cs(y.doc,x.pos)&&y.join(x.pos),t(y.scrollIntoView())}return!0}let c=s.type.spec.isolating||r>0&&a?null:W.findFrom(e,1),h=c&&c.$from.blockRange(c.$to),d=h&&ws(h);if(d!=null&&d>=e.depth)return t&&t(n.tr.lift(h,d).scrollIntoView()),!0;if(u&&Gt(s,"start",!0)&&Gt(i,"end")){let f=i,p=[];for(;p.push(f),!f.isTextblock;)f=f.lastChild;let y=s,x=1;for(;!y.isTextblock;y=y.firstChild)x++;if(f.canReplace(f.childCount,f.childCount,y.content)){if(t){let k=T.empty;for(let C=p.length-1;C>=0;C--)k=T.from(p[C].copy(k));let I=n.tr.step(new xe(e.pos-p.length,e.pos+s.nodeSize,e.pos+x,e.pos+s.nodeSize-x,new M(k,p.length,0),0,!0));t(I.scrollIntoView())}return!0}}return!1}function Fa(n){return function(e,t){let r=e.selection,i=n<0?r.$from:r.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return i.node(s).isTextblock?(t&&t(e.tr.setSelection(j.create(e.doc,n<0?i.start(s):i.end(s)))),!0):!1}}const Zp=Fa(-1),em=Fa(1);function by(n,e=null){return function(t,r){let{$from:i,$to:s}=t.selection,o=i.blockRange(s),l=o&&wa(o,n,e);return l?(r&&r(t.tr.wrap(o,l).scrollIntoView()),!0):!1}}function Sy(n,e=null){return function(t,r){let i=!1;for(let s=0;s<t.selection.ranges.length&&!i;s++){let{$from:{pos:o},$to:{pos:l}}=t.selection.ranges[s];t.doc.nodesBetween(o,l,(a,u)=>{if(i)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)i=!0;else{let c=t.doc.resolve(u),h=c.index();i=c.parent.canReplaceWith(h,h+1,n)}})}if(!i)return!1;if(r){let s=t.tr;for(let o=0;o<t.selection.ranges.length;o++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[o];s.setBlockType(l,a,n,e)}r(s.scrollIntoView())}return!0}}function tm(n,e,t,r){for(let i=0;i<e.length;i++){let{$from:s,$to:o}=e[i],l=s.depth==0?n.inlineContent&&n.type.allowsMarkType(t):!1;if(n.nodesBetween(s.pos,o.pos,(a,u)=>{if(l)return!1;l=a.inlineContent&&a.type.allowsMarkType(t)}),l)return!0}return!1}function wy(n,e=null,t){return function(r,i){let{empty:s,$cursor:o,ranges:l}=r.selection;if(s&&!o||!tm(r.doc,l,n))return!1;if(i)if(o)n.isInSet(r.storedMarks||o.marks())?i(r.tr.removeStoredMark(n)):i(r.tr.addStoredMark(n.create(e)));else{let a,u=r.tr;a=!l.some(c=>r.doc.rangeHasMark(c.$from.pos,c.$to.pos,n));for(let c=0;c<l.length;c++){let{$from:h,$to:d}=l[c];if(!a)u.removeMark(h.pos,d.pos,n);else{let f=h.pos,p=d.pos,y=h.nodeAfter,x=d.nodeBefore,k=y&&y.isText?/^\s*/.exec(y.text)[0].length:0,I=x&&x.isText?/\s*$/.exec(x.text)[0].length:0;f+k<p&&(f+=k,p-=I),u.addMark(f,p,n.create(e))}}i(u.scrollIntoView())}return!0}}function tn(...n){return function(e,t,r){for(let i=0;i<n.length;i++)if(n[i](e,t,r))return!0;return!1}}let Zr=tn(Ns,Vp,Ra),Po=tn(Ns,Wp,jp);const Ge={Enter:tn(Jp,Kp,Up,Qp),"Mod-Enter":Hp,Backspace:Zr,"Mod-Backspace":Zr,"Shift-Backspace":Zr,Delete:Po,"Mod-Delete":Po,"Mod-a":Gp},Ba={"Ctrl-h":Ge.Backspace,"Alt-Backspace":Ge["Mod-Backspace"],"Ctrl-d":Ge.Delete,"Ctrl-Alt-Backspace":Ge["Mod-Delete"],"Alt-Delete":Ge["Mod-Delete"],"Alt-d":Ge["Mod-Delete"],"Ctrl-a":Zp,"Ctrl-e":em};for(let n in Ge)Ba[n]=Ge[n];const nm=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,rm=nm?Ba:Ge;class et{constructor(e,t,r={}){this.match=e,this.match=e,this.handler=typeof t=="string"?im(t):t,this.undoable=r.undoable!==!1,this.inCode=r.inCode||!1,this.inCodeMark=r.inCodeMark!==!1}}function im(n){return function(e,t,r,i){let s=n;if(t[1]){let o=t[0].lastIndexOf(t[1]);s+=t[0].slice(o+t[1].length),r+=o;let l=r-i;l>0&&(s=t[0].slice(o-l,o)+s,r=i)}return e.tr.insertText(s,r,i)}}const sm=(n,e)=>{let t=n.plugins;for(let r=0;r<t.length;r++){let i=t[r],s;if(i.spec.isInputRules&&(s=i.getState(n))){if(e){let o=n.tr,l=s.transform;for(let a=l.steps.length-1;a>=0;a--)o.step(l.steps[a].invert(l.docs[a]));if(s.text){let a=o.doc.resolve(s.from).marks();o.replaceWith(s.from,s.to,n.schema.text(s.text,a))}else o.delete(s.from,s.to);e(o)}return!0}}return!1};new et(/--$/,"—",{inCodeMark:!1});new et(/\.\.\.$/,"…",{inCodeMark:!1});new et(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“",{inCodeMark:!1});new et(/"$/,"”",{inCodeMark:!1});new et(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘",{inCodeMark:!1});new et(/'$/,"’",{inCodeMark:!1});function Cy(n,e,t=null,r){return new et(n,(i,s,o,l)=>{let a=t instanceof Function?t(s):t,u=i.tr.delete(o,l),c=u.doc.resolve(o),h=c.blockRange(),d=h&&wa(h,e,a);if(!d)return null;u.wrap(h,d);let f=u.doc.resolve(o-1).nodeBefore;return f&&f.type==e&&Cs(u.doc,o-1)&&(!r||r(s,f))&&u.join(o-1),u})}function Ty(n,e,t=null){return new et(n,(r,i,s,o)=>{let l=r.doc.resolve(s),a=t instanceof Function?t(i):t;return l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),e)?r.tr.delete(s,o).setBlockType(s,s,e,a):null})}const pt=typeof navigator<"u"?navigator:null,Fo=typeof document<"u"?document:null,Pt=pt&&pt.userAgent||"",Wi=/Edge\/(\d+)/.exec(Pt),va=/MSIE \d/.exec(Pt),ji=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Pt),Is=!!(va||ji||Wi);va?document.documentMode:ji?+ji[1]:Wi&&+Wi[1];const om=!Is&&/gecko\/(\d+)/i.test(Pt);om&&+(/Firefox\/(\d+)/.exec(Pt)||[0,0])[1];const Bo=!Is&&/Chrome\/(\d+)/.exec(Pt);Bo&&+Bo[1];const lm=!Is&&!!pt&&/Apple Computer/.test(pt.vendor),am=lm&&(/Mobile\/\w+/.test(Pt)||!!pt&&pt.maxTouchPoints>2);am||pt&&/Mac/.test(pt.platform);const um=!!Fo&&"webkitFontSmoothing"in Fo.documentElement.style;um&&+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1];function ei(n,e,t,r,i,s){if(n.composing)return!1;const o=n.state,l=o.doc.resolve(e);if(l.parent.type.spec.code)return!1;const a=l.parent.textBetween(Math.max(0,l.parentOffset-500),l.parentOffset,void 0,"")+r;for(let u of i){const c=u,h=c.match.exec(a),d=h&&h[0]&&c.handler(o,h,e-(h[0].length-r.length),t);if(d)return c.undoable!==!1&&d.setMeta(s,{transform:d,from:e,to:t,text:r}),n.dispatch(d),!0}return!1}const cm=new Ms("MILKDOWN_CUSTOM_INPUTRULES");function hm({rules:n}){const e=new Ar({key:cm,isInputRules:!0,state:{init(){return null},apply(t,r){const i=t.getMeta(this);return i||(t.selectionSet||t.docChanged?null:r)}},props:{handleTextInput(t,r,i,s){return ei(t,r,i,s,n,e)},handleDOMEvents:{compositionend:t=>(setTimeout(()=>{const{$cursor:r}=t.state.selection;r&&ei(t,r.pos,r.pos,"",n,e)}),!1)},handleKeyDown(t,r){if(r.key!=="Enter")return!1;const{$cursor:i}=t.state.selection;return i?ei(t,i.pos,i.pos,`
40
- `,n,e):!1}}});return e}function My(n,e,t={}){return new et(n,(r,i,s,o)=>{var l,a,u,c;const{tr:h}=r,d=i.length;let f=i[d-1],p=i[0],y=[],x=o;const k={group:f,fullMatch:p,start:s,end:o},I=(l=t.updateCaptured)==null?void 0:l.call(t,k);if(Object.assign(k,I),{group:f,fullMatch:p,start:s,end:o}=k,p===null||f?.trim()==="")return null;if(f){const C=p.search(/\S/),B=s+p.indexOf(f),$=B+f.length;y=(a=h.storedMarks)!=null?a:[],$<o&&h.delete($,o),B>s&&h.delete(s+C,B),x=s+C+f.length;const S=(u=t.getAttr)==null?void 0:u.call(t,i);h.addMark(s,x,e.create(S)),h.setStoredMarks(y),(c=t.beforeDispatch)==null||c.call(t,{match:i,start:s,end:o,tr:h})}return h})}function fm(n,e){return Array.isArray(n)&&n.includes(e.type)||e.type===n}function Ny(n,e){if(!(n instanceof D))return;const{node:t,$from:r}=n;if(fm(e,t))return{node:t,pos:r.pos,start:r.start(r.depth),depth:r.depth}}const Oy=(n,e)=>{const{selection:t,doc:r}=n;if(t instanceof D)return{hasNode:t.node.type===e,pos:t.from,target:t.node};const{from:i,to:s}=t;let o=!1,l=-1,a=null;return r.nodesBetween(i,s,(u,c)=>a?!1:u.type===e?(o=!0,l=c,a=u,!1):!0),{hasNode:o,pos:l,target:a}};var mt={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},yr={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},dm=typeof navigator<"u"&&/Mac/.test(navigator.platform),pm=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var se=0;se<10;se++)mt[48+se]=mt[96+se]=String(se);for(var se=1;se<=24;se++)mt[se+111]="F"+se;for(var se=65;se<=90;se++)mt[se]=String.fromCharCode(se+32),yr[se]=String.fromCharCode(se);for(var ti in mt)yr.hasOwnProperty(ti)||(yr[ti]=mt[ti]);function mm(n){var e=dm&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||pm&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?yr:mt)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}const gm=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),ym=typeof navigator<"u"&&/Win/.test(navigator.platform);function km(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,i,s,o;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))i=!0;else if(/^s(hift)?$/i.test(a))s=!0;else if(/^mod$/i.test(a))gm?o=!0:i=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(t="Alt-"+t),i&&(t="Ctrl-"+t),o&&(t="Meta-"+t),s&&(t="Shift-"+t),t}function xm(n){let e=Object.create(null);for(let t in n)e[km(t)]=n[t];return e}function ni(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function bm(n){return new Ar({props:{handleKeyDown:Sm(n)}})}function Sm(n){let e=xm(n);return function(t,r){let i=mm(r),s,o=e[ni(i,r)];if(o&&o(t.state,t.dispatch,t))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let l=e[ni(i,r,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(ym&&r.ctrlKey&&r.altKey)&&(s=mt[r.keyCode])&&s!=i){let l=e[ni(s,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}const oe=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Xt=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let Ji=null;const Qe=function(n,e,t){let r=Ji||(Ji=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},wm=function(){Ji=null},Rt=function(n,e,t,r){return t&&(vo(n,e,t,r,-1)||vo(n,e,t,r,1))},Cm=/^(img|br|input|textarea|hr)$/i;function vo(n,e,t,r,i){for(var s;;){if(n==t&&e==r)return!0;if(e==(i<0?0:Te(n))){let o=n.parentNode;if(!o||o.nodeType!=1||Pn(n)||Cm.test(n.nodeName)||n.contentEditable=="false")return!1;e=oe(n)+(i<0?0:1),n=o}else if(n.nodeType==1){let o=n.childNodes[e+(i<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((s=o.pmViewDesc)===null||s===void 0)&&s.ignoreForSelection)e+=i;else return!1;else n=o,e=i<0?Te(n):0}else return!1}}function Te(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Tm(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=Te(n)}else if(n.parentNode&&!Pn(n))e=oe(n),n=n.parentNode;else return null}}function Mm(n,e){for(;;){if(n.nodeType==3&&e<n.nodeValue.length)return n;if(n.nodeType==1&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!Pn(n))e=oe(n)+1,n=n.parentNode;else return null}}function Nm(n,e,t){for(let r=e==0,i=e==Te(n);r||i;){if(n==t)return!0;let s=oe(n);if(n=n.parentNode,!n)return!1;r=r&&s==0,i=i&&s==Te(n)}}function Pn(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const Dr=function(n){return n.focusNode&&Rt(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function wt(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function Om(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Em(n,e,t){if(n.caretPositionFromPoint)try{let r=n.caretPositionFromPoint(e,t);if(r)return{node:r.offsetNode,offset:Math.min(Te(r.offsetNode),r.offset)}}catch{}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);if(r)return{node:r.startContainer,offset:Math.min(Te(r.startContainer),r.startOffset)}}}const $e=typeof navigator<"u"?navigator:null,Lo=typeof document<"u"?document:null,yt=$e&&$e.userAgent||"",Hi=/Edge\/(\d+)/.exec(yt),La=/MSIE \d/.exec(yt),Ki=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(yt),me=!!(La||Ki||Hi),ct=La?document.documentMode:Ki?+Ki[1]:Hi?+Hi[1]:0,Me=!me&&/gecko\/(\d+)/i.test(yt);Me&&+(/Firefox\/(\d+)/.exec(yt)||[0,0])[1];const Ui=!me&&/Chrome\/(\d+)/.exec(yt),ee=!!Ui,Va=Ui?+Ui[1]:0,le=!me&&!!$e&&/Apple Computer/.test($e.vendor),Zt=le&&(/Mobile\/\w+/.test(yt)||!!$e&&$e.maxTouchPoints>2),we=Zt||($e?/Mac/.test($e.platform):!1),_a=$e?/Win/.test($e.platform):!1,Xe=/Android \d/.test(yt),Fn=!!Lo&&"webkitFontSmoothing"in Lo.documentElement.style,Im=Fn?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Am(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function Ue(n,e){return typeof n=="number"?n:n[e]}function Dm(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function Vo(n,e,t){let r=n.someProp("scrollThreshold")||0,i=n.someProp("scrollMargin")||5,s=n.dom.ownerDocument;for(let o=t||n.dom;o;){if(o.nodeType!=1){o=Xt(o);continue}let l=o,a=l==s.body,u=a?Am(s):Dm(l),c=0,h=0;if(e.top<u.top+Ue(r,"top")?h=-(u.top-e.top+Ue(i,"top")):e.bottom>u.bottom-Ue(r,"bottom")&&(h=e.bottom-e.top>u.bottom-u.top?e.top+Ue(i,"top")-u.top:e.bottom-u.bottom+Ue(i,"bottom")),e.left<u.left+Ue(r,"left")?c=-(u.left-e.left+Ue(i,"left")):e.right>u.right-Ue(r,"right")&&(c=e.right-u.right+Ue(i,"right")),c||h)if(a)s.defaultView.scrollBy(c,h);else{let f=l.scrollLeft,p=l.scrollTop;h&&(l.scrollTop+=h),c&&(l.scrollLeft+=c);let y=l.scrollLeft-f,x=l.scrollTop-p;e={left:e.left-y,top:e.top-x,right:e.right-y,bottom:e.bottom-x}}let d=a?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(d))break;o=d=="absolute"?o.offsetParent:Xt(o)}}function Rm(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,i;for(let s=(e.left+e.right)/2,o=t+1;o<Math.min(innerHeight,e.bottom);o+=5){let l=n.root.elementFromPoint(s,o);if(!l||l==n.dom||!n.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){r=l,i=a.top;break}}return{refDOM:r,refTop:i,stack:$a(n.dom)}}function $a(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=Xt(r));return e}function zm({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;qa(t,r==0?0:r-e)}function qa(n,e){for(let t=0;t<n.length;t++){let{dom:r,top:i,left:s}=n[t];r.scrollTop!=i+e&&(r.scrollTop=i+e),r.scrollLeft!=s&&(r.scrollLeft=s)}}let Lt=null;function Pm(n){if(n.setActive)return n.setActive();if(Lt)return n.focus(Lt);let e=$a(n);n.focus(Lt==null?{get preventScroll(){return Lt={preventScroll:!0},!0}}:void 0),Lt||(Lt=!1,qa(e,0))}function Wa(n,e){let t,r=2e8,i,s=0,o=e.top,l=e.top,a,u;for(let c=n.firstChild,h=0;c;c=c.nextSibling,h++){let d;if(c.nodeType==1)d=c.getClientRects();else if(c.nodeType==3)d=Qe(c).getClientRects();else continue;for(let f=0;f<d.length;f++){let p=d[f];if(p.top<=o&&p.bottom>=l){o=Math.max(p.bottom,o),l=Math.min(p.top,l);let y=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(y<r){t=c,r=y,i=y&&t.nodeType==3?{left:p.right<e.left?p.right:p.left,top:e.top}:e,c.nodeType==1&&y&&(s=h+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=c,u={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!t&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(s=h+1)}}return!t&&a&&(t=a,i=u,r=0),t&&t.nodeType==3?Fm(t,i):!t||r&&t.nodeType==1?{node:n,offset:s}:Wa(t,i)}function Fm(n,e){let t=n.nodeValue.length,r=document.createRange(),i;for(let s=0;s<t;s++){r.setEnd(n,s+1),r.setStart(n,s);let o=it(r,1);if(o.top!=o.bottom&&As(e,o)){i={node:n,offset:s+(e.left>=(o.left+o.right)/2?1:0)};break}}return r.detach(),i||{node:n,offset:0}}function As(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function Bm(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function vm(n,e,t){let{node:r,offset:i}=Wa(e,t),s=-1;if(r.nodeType==1&&!r.firstChild){let o=r.getBoundingClientRect();s=o.left!=o.right&&t.left>(o.left+o.right)/2?1:-1}return n.docView.posFromDOM(r,i,s)}function Lm(n,e,t,r){let i=-1;for(let s=e,o=!1;s!=n.dom;){let l=n.docView.nearestDesc(s,!0),a;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!o&&a.left>r.left||a.top>r.top?i=l.posBefore:(!o&&a.right<r.left||a.bottom<r.top)&&(i=l.posAfter),o=!0),!l.contentDOM&&i<0&&!l.node.isText))return(l.node.isBlock?r.top<(a.top+a.bottom)/2:r.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;s=l.dom.parentNode}return i>-1?i:n.docView.posFromDOM(e,t,-1)}function ja(n,e,t){let r=n.childNodes.length;if(r&&t.top<t.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-t.top)/(t.bottom-t.top))-2)),s=i;;){let o=n.childNodes[s];if(o.nodeType==1){let l=o.getClientRects();for(let a=0;a<l.length;a++){let u=l[a];if(As(e,u))return ja(o,e,u)}}if((s=(s+1)%r)==i)break}return n}function Vm(n,e){let t=n.dom.ownerDocument,r,i=0,s=Em(t,e.left,e.top);s&&({node:r,offset:i}=s);let o=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!o||!n.dom.contains(o.nodeType!=1?o.parentNode:o)){let u=n.dom.getBoundingClientRect();if(!As(e,u)||(o=ja(n.dom,e,u),!o))return null}if(le)for(let u=o;r&&u;u=Xt(u))u.draggable&&(r=void 0);if(o=Bm(o,e),r){if(Me&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let c=r.childNodes[i],h;c.nodeName=="IMG"&&(h=c.getBoundingClientRect()).right<=e.left&&h.bottom>e.top&&i++}let u;Fn&&i&&r.nodeType==1&&(u=r.childNodes[i-1]).nodeType==1&&u.contentEditable=="false"&&u.getBoundingClientRect().top>=e.top&&i--,r==n.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(l=Lm(n,r,i,e))}l==null&&(l=vm(n,o,e));let a=n.docView.nearestDesc(o,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function _o(n){return n.top<n.bottom||n.left<n.right}function it(n,e){let t=n.getClientRects();if(t.length){let r=t[e<0?0:t.length-1];if(_o(r))return r}return Array.prototype.find.call(t,_o)||n.getBoundingClientRect()}const _m=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Ja(n,e,t){let{node:r,offset:i,atom:s}=n.docView.domFromPos(e,t<0?-1:1),o=Fn||Me;if(r.nodeType==3)if(o&&(_m.test(r.nodeValue)||(t<0?!i:i==r.nodeValue.length))){let a=it(Qe(r,i,i),t);if(Me&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let u=it(Qe(r,i-1,i-1),-1);if(u.top==a.top){let c=it(Qe(r,i,i+1),-1);if(c.top!=a.top)return ln(c,c.left<u.left)}}return a}else{let a=i,u=i,c=t<0?1:-1;return t<0&&!i?(u++,c=-1):t>=0&&i==r.nodeValue.length?(a--,c=1):t<0?a--:u++,ln(it(Qe(r,a,u),c),c<0)}if(!n.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&i&&(t<0||i==Te(r))){let a=r.childNodes[i-1];if(a.nodeType==1)return ri(a.getBoundingClientRect(),!1)}if(s==null&&i<Te(r)){let a=r.childNodes[i];if(a.nodeType==1)return ri(a.getBoundingClientRect(),!0)}return ri(r.getBoundingClientRect(),t>=0)}if(s==null&&i&&(t<0||i==Te(r))){let a=r.childNodes[i-1],u=a.nodeType==3?Qe(a,Te(a)-(o?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(u)return ln(it(u,1),!1)}if(s==null&&i<Te(r)){let a=r.childNodes[i];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let u=a?a.nodeType==3?Qe(a,0,o?0:1):a.nodeType==1?a:null:null;if(u)return ln(it(u,-1),!0)}return ln(it(r.nodeType==3?Qe(r):r,-t),t>=0)}function ln(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function ri(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function Ha(n,e,t){let r=n.state,i=n.root.activeElement;r!=e&&n.updateState(e),i!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),i!=n.dom&&i&&i.focus()}}function $m(n,e,t){let r=e.selection,i=t=="up"?r.$from:r.$to;return Ha(n,e,()=>{let{node:s}=n.docView.domFromPos(i.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(s,!0);if(!l)break;if(l.node.isBlock){s=l.contentDOM||l.dom;break}s=l.dom.parentNode}let o=Ja(n,i.pos,1);for(let l=s.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=Qe(l,0,l.nodeValue.length).getClientRects();else continue;for(let u=0;u<a.length;u++){let c=a[u];if(c.bottom>c.top+1&&(t=="up"?o.top-c.top>(c.bottom-o.top)*2:c.bottom-o.bottom>(o.bottom-c.top)*2))return!1}}return!0})}const qm=/[\u0590-\u08ac]/;function Wm(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,s=!i,o=i==r.parent.content.size,l=n.domSelection();return l?!qm.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?s:o:Ha(n,e,()=>{let{focusNode:a,focusOffset:u,anchorNode:c,anchorOffset:h}=n.domSelectionRange(),d=l.caretBidiLevel;l.modify("move",t,"character");let f=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:p,focusOffset:y}=n.domSelectionRange(),x=p&&!f.contains(p.nodeType==1?p:p.parentNode)||a==p&&u==y;try{l.collapse(c,h),a&&(a!=c||u!=h)&&l.extend&&l.extend(a,u)}catch{}return d!=null&&(l.caretBidiLevel=d),x}):r.pos==r.start()||r.pos==r.end()}let $o=null,qo=null,Wo=!1;function jm(n,e,t){return $o==e&&qo==t?Wo:($o=e,qo=t,Wo=t=="up"||t=="down"?$m(n,e,t):Wm(n,e,t))}const Ne=0,jo=1,Ct=2,qe=3;class Bn{constructor(e,t,r,i){this.parent=e,this.children=t,this.dom=r,this.contentDOM=i,this.dirty=Ne,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,r=this.posAtStart;;t++){let i=this.children[t];if(i==e)return r;r+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let s,o;if(e==this.contentDOM)s=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.previousSibling}for(;s&&!((o=s.pmViewDesc)&&o.parent==this);)s=s.previousSibling;return s?this.posBeforeChild(o)+o.size:this.posAtStart}else{let s,o;if(e==this.contentDOM)s=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.nextSibling}for(;s&&!((o=s.pmViewDesc)&&o.parent==this);)s=s.nextSibling;return s?this.posBeforeChild(o):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=t>oe(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!1;break}if(s.previousSibling)break}if(i==null&&t==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!0;break}if(s.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,i=e;i;i=i.parentNode){let s=this.getDesc(i),o;if(s&&(!t||s.node))if(r&&(o=s.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))r=!1;else return s}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let i=e;i;i=i.parentNode){let s=this.getDesc(i);if(s)return s.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;t<this.children.length;t++){let i=this.children[t],s=r+i.size;if(r==e&&s!=r){for(;!i.border&&i.children.length;)for(let o=0;o<i.children.length;o++){let l=i.children[o];if(l.size){i=l;break}}return i}if(e<s)return i.descAt(e-r-i.border);r=s}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,i=0;for(let s=0;r<this.children.length;r++){let o=this.children[r],l=s+o.size;if(l>e||o instanceof Ua){i=e-s;break}s=l}if(i)return this.children[r].domFromPos(i-this.children[r].border,t);for(let s;r&&!(s=this.children[r-1]).size&&s instanceof Ka&&s.side>=0;r--);if(t<=0){let s,o=!0;for(;s=r?this.children[r-1]:null,!(!s||s.dom.parentNode==this.contentDOM);r--,o=!1);return s&&t&&o&&!s.border&&!s.domAtom?s.domFromPos(s.size,t):{node:this.contentDOM,offset:s?oe(s.dom)+1:0}}else{let s,o=!0;for(;s=r<this.children.length?this.children[r]:null,!(!s||s.dom.parentNode==this.contentDOM);r++,o=!1);return s&&o&&!s.border&&!s.domAtom?s.domFromPos(0,t):{node:this.contentDOM,offset:s?oe(s.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,s=-1;for(let o=r,l=0;;l++){let a=this.children[l],u=o+a.size;if(i==-1&&e<=u){let c=o+a.border;if(e>=c&&t<=u-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,c);e=o;for(let h=l;h>0;h--){let d=this.children[h-1];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(1)){i=oe(d.dom)+1;break}e-=d.size}i==-1&&(i=0)}if(i>-1&&(u>t||l==this.children.length-1)){t=u;for(let c=l+1;c<this.children.length;c++){let h=this.children[c];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(-1)){s=oe(h.dom);break}t+=h.size}s==-1&&(s=this.contentDOM.childNodes.length);break}o=u}return{node:this.contentDOM,from:e,to:t,fromOffset:i,toOffset:s}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:r}=this.domFromPos(e,0);if(t.nodeType!=1||r==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[r]}setSelection(e,t,r,i=!1){let s=Math.min(e,t),o=Math.max(e,t);for(let f=0,p=0;f<this.children.length;f++){let y=this.children[f],x=p+y.size;if(s>p&&o<x)return y.setSelection(e-p-y.border,t-p-y.border,r,i);p=x}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),u=r.root.getSelection(),c=r.domSelectionRange(),h=!1;if((Me||le)&&e==t){let{node:f,offset:p}=l;if(f.nodeType==3){if(h=!!(p&&f.nodeValue[p-1]==`
41
- `),h&&p==f.nodeValue.length)for(let y=f,x;y;y=y.parentNode){if(x=y.nextSibling){x.nodeName=="BR"&&(l=a={node:x.parentNode,offset:oe(x)+1});break}let k=y.pmViewDesc;if(k&&k.node&&k.node.isBlock)break}}else{let y=f.childNodes[p-1];h=y&&(y.nodeName=="BR"||y.contentEditable=="false")}}if(Me&&c.focusNode&&c.focusNode!=a.node&&c.focusNode.nodeType==1){let f=c.focusNode.childNodes[c.focusOffset];f&&f.contentEditable=="false"&&(i=!0)}if(!(i||h&&le)&&Rt(l.node,l.offset,c.anchorNode,c.anchorOffset)&&Rt(a.node,a.offset,c.focusNode,c.focusOffset))return;let d=!1;if((u.extend||e==t)&&!(h&&Me)){u.collapse(l.node,l.offset);try{e!=t&&u.extend(a.node,a.offset),d=!0}catch{}}if(!d){if(e>t){let p=l;l=a,a=p}let f=document.createRange();f.setEnd(a.node,a.offset),f.setStart(l.node,l.offset),u.removeAllRanges(),u.addRange(f)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let r=0,i=0;i<this.children.length;i++){let s=this.children[i],o=r+s.size;if(r==o?e<=o&&t>=r:e<o&&t>r){let l=r+s.border,a=o-s.border;if(e>=l&&t<=a){this.dirty=e==r||t==o?Ct:jo,e==l&&t==a&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=qe:s.markDirty(e-l,t-l);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?Ct:qe}r=o}this.dirty=Ct}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?Ct:jo;t.dirty<r&&(t.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class Ka extends Bn{constructor(e,t,r,i){let s,o=t.type.toDOM;if(typeof o=="function"&&(o=o(r,()=>{if(!s)return i;if(s.parent)return s.parent.posBeforeChild(s)})),!t.type.spec.raw){if(o.nodeType!=1){let l=document.createElement("span");l.appendChild(o),o=l}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=t,this.widget=t,s=this}matchesWidget(e){return this.dirty==Ne&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class Jm extends Bn{constructor(e,t,r,i){super(e,[],t,null),this.textDOM=r,this.text=i}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class zt extends Bn{constructor(e,t,r,i,s){super(e,[],r,i),this.mark=t,this.spec=s}static create(e,t,r,i){let s=i.nodeViews[t.type.name],o=s&&s(t,i,r);return(!o||!o.dom)&&(o=en.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new zt(e,t,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&qe||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=qe&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Ne){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Ne}}slice(e,t,r){let i=zt.create(this.parent,this.mark,!0,r),s=this.children,o=this.size;t<o&&(s=Qi(s,t,o,r)),e>0&&(s=Qi(s,0,e,r));for(let l=0;l<s.length;l++)s[l].parent=i;return i.children=s,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class ht extends Bn{constructor(e,t,r,i,s,o,l,a,u){super(e,[],s,o),this.node=t,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=l}static create(e,t,r,i,s,o){let l=s.nodeViews[t.type.name],a,u=l&&l(t,s,()=>{if(!a)return o;if(a.parent)return a.parent.posBeforeChild(a)},r,i),c=u&&u.dom,h=u&&u.contentDOM;if(t.isText){if(!c)c=document.createTextNode(t.text);else if(c.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else c||({dom:c,contentDOM:h}=en.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!h&&!t.isText&&c.nodeName!="BR"&&(c.hasAttribute("contenteditable")||(c.contentEditable="false"),t.type.spec.draggable&&(c.draggable=!0));let d=c;return c=Ga(c,r,t),u?a=new Hm(e,t,r,i,c,h||null,d,u,s,o+1):t.isText?new Rr(e,t,r,i,c,d,s):new ht(e,t,r,i,c,h||null,d,s,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let r=this.children[t];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>T.empty)}return e}matchesNode(e,t,r){return this.dirty==Ne&&e.eq(this.node)&&kr(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,i=t,s=e.composing?this.localCompositionInfo(e,t):null,o=s&&s.pos>-1?s:null,l=s&&s.pos<0,a=new Um(this,o&&o.node,e);Gm(this.node,this.innerDeco,(u,c,h)=>{u.spec.marks?a.syncToMarks(u.spec.marks,r,e,c):u.type.side>=0&&!h&&a.syncToMarks(c==this.node.childCount?L.none:this.node.child(c).marks,r,e,c),a.placeWidget(u,e,i)},(u,c,h,d)=>{a.syncToMarks(u.marks,r,e,d);let f;a.findNodeMatch(u,c,h,d)||l&&e.state.selection.from>i&&e.state.selection.to<i+u.nodeSize&&(f=a.findIndexWithChild(s.node))>-1&&a.updateNodeAt(u,c,h,f,e)||a.updateNextNode(u,c,h,e,d,i)||a.addNode(u,c,h,e,i),i+=u.nodeSize}),a.syncToMarks([],r,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==Ct)&&(o&&this.protectLocalComposition(e,o),Ya(this.contentDOM,this.children,e),Zt&&Xm(this.dom))}localCompositionInfo(e,t){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof j)||r<t||i>t+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let o=s.nodeValue,l=Zm(this.node.content,o,r-t,i-t);return l<0?null:{node:s,pos:l,text:o}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:i}){if(this.getDesc(t))return;let s=t;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let o=new Jm(this,s,t,i);e.input.compositionNodes.push(o),this.children=Qi(this.children,r,r+i.length,e,o)}update(e,t,r,i){return this.dirty==qe||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,i),!0)}updateInner(e,t,r,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=Ne}updateOuterDeco(e){if(kr(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Qa(this.dom,this.nodeDOM,Yi(this.outerDeco,this.node,t),Yi(e,this.node,t)),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.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function Jo(n,e,t,r,i){Ga(r,e,n);let s=new ht(void 0,n,e,t,r,r,r,i,0);return s.contentDOM&&s.updateChildren(i,0),s}class Rr extends ht{constructor(e,t,r,i,s,o,l){super(e,t,r,i,s,null,o,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,i){return this.dirty==qe||this.dirty!=Ne&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Ne||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=Ne,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,r){let i=this.node.cut(e,t),s=document.createTextNode(i.text);return new Rr(this.parent,i,this.outerDeco,this.innerDeco,s,s,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=qe)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Ua extends Bn{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Ne&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Hm extends ht{constructor(e,t,r,i,s,o,l,a,u,c){super(e,t,r,i,s,o,l,u,c),this.spec=a}update(e,t,r,i){if(this.dirty==qe)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,t,r);return s&&this.updateInner(e,t,r,i),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,i){this.spec.setSelection?this.spec.setSelection(e,t,r.root):super.setSelection(e,t,r,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function Ya(n,e,t){let r=n.firstChild,i=!1;for(let s=0;s<e.length;s++){let o=e[s],l=o.dom;if(l.parentNode==n){for(;l!=r;)r=Ho(r),i=!0;r=r.nextSibling}else i=!0,n.insertBefore(l,r);if(o instanceof zt){let a=r?r.previousSibling:n.lastChild;Ya(o.contentDOM,o.children,t),r=a?a.nextSibling:n.firstChild}}for(;r;)r=Ho(r),i=!0;i&&t.trackWrites==n&&(t.trackWrites=null)}const Cn=function(n){n&&(this.nodeName=n)};Cn.prototype=Object.create(null);const Tt=[new Cn];function Yi(n,e,t){if(n.length==0)return Tt;let r=t?Tt[0]:new Cn,i=[r];for(let s=0;s<n.length;s++){let o=n[s].type.attrs;if(o){o.nodeName&&i.push(r=new Cn(o.nodeName));for(let l in o){let a=o[l];a!=null&&(t&&i.length==1&&i.push(r=new Cn(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+a:l=="style"?r.style=(r.style?r.style+";":"")+a:l!="nodeName"&&(r[l]=a))}}}return i}function Qa(n,e,t,r){if(t==Tt&&r==Tt)return e;let i=e;for(let s=0;s<r.length;s++){let o=r[s],l=t[s];if(s){let a;l&&l.nodeName==o.nodeName&&i!=n&&(a=i.parentNode)&&a.nodeName.toLowerCase()==o.nodeName||(a=document.createElement(o.nodeName),a.pmIsDeco=!0,a.appendChild(i),l=Tt[0]),i=a}Km(i,l||Tt[0],o)}return i}function Km(n,e,t){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in t)&&n.removeAttribute(r);for(let r in t)r!="class"&&r!="style"&&r!="nodeName"&&t[r]!=e[r]&&n.setAttribute(r,t[r]);if(e.class!=t.class){let r=e.class?e.class.split(" ").filter(Boolean):[],i=t.class?t.class.split(" ").filter(Boolean):[];for(let s=0;s<r.length;s++)i.indexOf(r[s])==-1&&n.classList.remove(r[s]);for(let s=0;s<i.length;s++)r.indexOf(i[s])==-1&&n.classList.add(i[s]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=r.exec(e.style);)n.style.removeProperty(i[1])}t.style&&(n.style.cssText+=t.style)}}function Ga(n,e,t){return Qa(n,n,Tt,Yi(e,t,n.nodeType!=1))}function kr(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function Ho(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class Um{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Ym(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let r=e;r<t;r++)this.top.children[r].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,r,i){let s=0,o=this.stack.length>>1,l=Math.min(o,e.length);for(;s<l&&(s==o-1?this.top:this.stack[s+1<<1]).matchesMark(e[s])&&e[s].type.spec.spanning!==!1;)s++;for(;s<o;)this.destroyRest(),this.top.dirty=Ne,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<e.length;){this.stack.push(this.top,this.index+1);let a=-1,u=this.top.children.length;i<this.preMatch.index&&(u=Math.min(this.index+3,u));for(let c=this.index;c<u;c++){let h=this.top.children[c];if(h.matchesMark(e[o])&&!this.isLocked(h.dom)){a=c;break}}if(a>-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let c=zt.create(this.top,e[o],t,r);this.top.children.splice(this.index,0,c),this.top=c,this.changed=!0}this.index=0,o++}}findNodeMatch(e,t,r,i){let s=-1,o;if(i>=this.preMatch.index&&(o=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,r))s=this.top.children.indexOf(o,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let u=this.top.children[l];if(u.matchesNode(e,t,r)&&!this.preMatch.matched.has(u)){s=l;break}}return s<0?!1:(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,t,r,i,s){let o=this.top.children[i];return o.dirty==qe&&o.dom==o.contentDOM&&(o.dirty=Ct),o.update(e,t,r,s)?(this.destroyBetween(this.index,i),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==r)return i}return-1}e=t}}updateNextNode(e,t,r,i,s,o){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof ht){let u=this.preMatch.matched.get(a);if(u!=null&&u!=s)return!1;let c=a.dom,h,d=this.isLocked(c)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=qe&&kr(t,a.outerDeco));if(!d&&a.update(e,t,r,i))return this.destroyBetween(this.index,l),a.dom!=c&&(this.changed=!0),this.index++,!0;if(!d&&(h=this.recreateWrapper(a,e,t,r,i,o)))return this.destroyBetween(this.index,l),this.top.children[this.index]=h,h.contentDOM&&(h.dirty=Ct,h.updateChildren(i,o+1),h.dirty=Ne),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,r,i,s,o){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!kr(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=ht.create(this.top,t,r,i,s,o);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,t,r,i,s){let o=ht.create(this.top,e,t,r,i,s);o.contentDOM&&o.updateChildren(i,s+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,t,r){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(e)&&(e==i.widget||!i.widget.type.toDOM.parentNode))this.index++;else{let s=new Ka(this.top,e,t,r);this.top.children.splice(this.index++,0,s),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof zt;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Rr)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((le||ee)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let i=new Ua(this.top,[],r,null);t!=this.top?t.children.push(i):t.children.splice(this.index++,0,i),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function Ym(n,e){let t=e,r=t.children.length,i=n.childCount,s=new Map,o=[];e:for(;i>0;){let l;for(;;)if(r){let u=t.children[r-1];if(u instanceof zt)t=u,r=u.children.length;else{l=u,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(i-1))break;--i,s.set(l,i),o.push(l)}}return{index:i,matched:s,matches:o.reverse()}}function Qm(n,e){return n.type.side-e.type.side}function Gm(n,e,t,r){let i=e.locals(n),s=0;if(i.length==0){for(let u=0;u<n.childCount;u++){let c=n.child(u);r(c,i,e.forChild(s,c),u),s+=c.nodeSize}return}let o=0,l=[],a=null;for(let u=0;;){let c,h;for(;o<i.length&&i[o].to==s;){let x=i[o++];x.widget&&(c?(h||(h=[c])).push(x):c=x)}if(c)if(h){h.sort(Qm);for(let x=0;x<h.length;x++)t(h[x],u,!!a)}else t(c,u,!!a);let d,f;if(a)f=-1,d=a,a=null;else if(u<n.childCount)f=u,d=n.child(u++);else break;for(let x=0;x<l.length;x++)l[x].to<=s&&l.splice(x--,1);for(;o<i.length&&i[o].from<=s&&i[o].to>s;)l.push(i[o++]);let p=s+d.nodeSize;if(d.isText){let x=p;o<i.length&&i[o].from<x&&(x=i[o].from);for(let k=0;k<l.length;k++)l[k].to<x&&(x=l[k].to);x<p&&(a=d.cut(x-s),d=d.cut(0,x-s),p=x,f=-1)}else for(;o<i.length&&i[o].to<p;)o++;let y=d.isInline&&!d.isLeaf?l.filter(x=>!x.inline):l.slice();r(d,y,e.forChild(s,d),f),s=p}}function Xm(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function Zm(n,e,t,r){for(let i=0,s=0;i<n.childCount&&s<=r;){let o=n.child(i++),l=s;if(s+=o.nodeSize,!o.isText)continue;let a=o.text;for(;i<n.childCount;){let u=n.child(i++);if(s+=u.nodeSize,!u.isText)break;a+=u.text}if(s>=t){if(s>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let u=l<r?a.lastIndexOf(e,r-l-1):-1;if(u>=0&&u+e.length+l>=t)return l+u;if(t==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function Qi(n,e,t,r,i){let s=[];for(let o=0,l=0;o<n.length;o++){let a=n[o],u=l,c=l+=a.size;u>=t||c<=e?s.push(a):(u<e&&s.push(a.slice(0,e-u,r)),i&&(s.push(i),i=void 0),c>t&&s.push(a.slice(t-u,a.size,r)))}return s}function Ds(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let i=n.docView.nearestDesc(t.focusNode),s=i&&i.size==0,o=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(o<0)return null;let l=r.resolve(o),a,u;if(Dr(t)){for(a=o;i&&!i.node;)i=i.parent;let h=i.node;if(i&&h.isAtom&&D.isSelectable(h)&&i.parent&&!(h.isInline&&Nm(t.focusNode,t.focusOffset,i.dom))){let d=i.posBefore;u=new D(o==d?l:r.resolve(d))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let h=o,d=o;for(let f=0;f<t.rangeCount;f++){let p=t.getRangeAt(f);h=Math.min(h,n.docView.posFromDOM(p.startContainer,p.startOffset,1)),d=Math.max(d,n.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(h<0)return null;[a,o]=d==n.state.selection.anchor?[d,h]:[h,d],l=r.resolve(o)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let c=r.resolve(a);if(!u){let h=e=="pointer"||n.state.selection.head<l.pos&&!s?1:-1;u=Rs(n,c,l,h)}return u}function Xa(n){return n.editable?n.hasFocus():eu(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function Ze(n,e=!1){let t=n.state.selection;if(Za(n,t),!!Xa(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&ee){let r=n.domSelectionRange(),i=n.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&Rt(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)tg(n);else{let{anchor:r,head:i}=t,s,o;Ko&&!(t instanceof j)&&(t.$from.parent.inlineContent||(s=Uo(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(o=Uo(n,t.to))),n.docView.setSelection(r,i,n,e),Ko&&(s&&Yo(s),o&&Yo(o)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&eg(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const Ko=le||ee&&Va<63;function Uo(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),i=r<t.childNodes.length?t.childNodes[r]:null,s=r?t.childNodes[r-1]:null;if(le&&i&&i.contentEditable=="false")return ii(i);if((!i||i.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(i)return ii(i);if(s)return ii(s)}}function ii(n){return n.contentEditable="true",le&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function Yo(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function eg(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),r=t.anchorNode,i=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=i)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!Xa(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function tg(n){let e=n.domSelection();if(!e)return;let t=n.cursorWrapper.dom,r=t.nodeName=="IMG";r?e.collapse(t.parentNode,oe(t)+1):e.collapse(t,0),!r&&!n.state.selection.visible&&me&&ct<=11&&(t.disabled=!0,t.disabled=!1)}function Za(n,e){if(e instanceof D){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(Qo(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else Qo(n)}function Qo(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function Rs(n,e,t,r){return n.someProp("createSelectionBetween",i=>i(n,e,t))||j.between(e,t,r)}function Go(n){return n.editable&&!n.hasFocus()?!1:eu(n)}function eu(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function ng(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return Rt(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Gi(n,e){let{$anchor:t,$head:r}=n.selection,i=e>0?t.max(r):t.min(r),s=i.parent.inlineContent?i.depth?n.doc.resolve(e>0?i.after():i.before()):null:i;return s&&W.findFrom(s,e)}function st(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function Xo(n,e,t){let r=n.state.selection;if(r instanceof j)if(t.indexOf("s")>-1){let{$head:i}=r,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let o=n.state.doc.resolve(i.pos+s.nodeSize*(e<0?-1:1));return st(n,new j(r.$anchor,o))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let i=Gi(n.state,e);return i&&i instanceof D?st(n,i):!1}else if(!(we&&t.indexOf("m")>-1)){let i=r.$head,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,o;if(!s||s.isText)return!1;let l=e<0?i.pos-s.nodeSize:i.pos;return s.isAtom||(o=n.docView.descAt(l))&&!o.contentDOM?D.isSelectable(s)?st(n,new D(e<0?n.state.doc.resolve(i.pos-s.nodeSize):i)):Fn?st(n,new j(n.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof D&&r.node.isInline)return st(n,new j(e>0?r.$to:r.$from));{let i=Gi(n.state,e);return i?st(n,i):!1}}}function xr(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Tn(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function Vt(n,e){return e<0?rg(n):ig(n)}function rg(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i,s,o=!1;for(Me&&t.nodeType==1&&r<xr(t)&&Tn(t.childNodes[r],-1)&&(o=!0);;)if(r>0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(Tn(l,-1))i=t,s=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(tu(t))break;{let l=t.previousSibling;for(;l&&Tn(l,-1);)i=t.parentNode,s=oe(l),l=l.previousSibling;if(l)t=l,r=xr(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}o?Xi(n,t,r):i&&Xi(n,i,s)}function ig(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i=xr(t),s,o;for(;;)if(r<i){if(t.nodeType!=1)break;let l=t.childNodes[r];if(Tn(l,1))s=t,o=++r;else break}else{if(tu(t))break;{let l=t.nextSibling;for(;l&&Tn(l,1);)s=l.parentNode,o=oe(l)+1,l=l.nextSibling;if(l)t=l,r=0,i=xr(t);else{if(t=t.parentNode,t==n.dom)break;r=i=0}}}s&&Xi(n,s,o)}function tu(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function sg(n,e){for(;n&&e==n.childNodes.length&&!Pn(n);)e=oe(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function og(n,e){for(;n&&!e&&!Pn(n);)e=oe(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function Xi(n,e,t){if(e.nodeType!=3){let s,o;(o=sg(e,t))?(e=o,t=0):(s=og(e,t))&&(e=s,t=s.nodeValue.length)}let r=n.domSelection();if(!r)return;if(Dr(r)){let s=document.createRange();s.setEnd(e,t),s.setStart(e,t),r.removeAllRanges(),r.addRange(s)}else r.extend&&r.extend(e,t);n.domObserver.setCurSelection();let{state:i}=n;setTimeout(()=>{n.state==i&&Ze(n)},50)}function Zo(n,e){let t=n.state.doc.resolve(e);if(!(ee||_a)&&t.parent.inlineContent){let i=n.coordsAtPos(e);if(e>t.start()){let s=n.coordsAtPos(e-1),o=(s.top+s.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(s.left-i.left)>1)return s.left<i.left?"ltr":"rtl"}if(e<t.end()){let s=n.coordsAtPos(e+1),o=(s.top+s.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(s.left-i.left)>1)return s.left>i.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function el(n,e,t){let r=n.state.selection;if(r instanceof j&&!r.empty||t.indexOf("s")>-1||we&&t.indexOf("m")>-1)return!1;let{$from:i,$to:s}=r;if(!i.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let o=Gi(n.state,e);if(o&&o instanceof D)return st(n,o)}if(!i.parent.inlineContent){let o=e<0?i:s,l=r instanceof be?W.near(o,e):W.findFrom(o,e);return l?st(n,l):!1}return!1}function tl(n,e){if(!(n.state.selection instanceof j))return!0;let{$head:t,$anchor:r,empty:i}=n.state.selection;if(!t.sameParent(r))return!0;if(!i)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(s&&!s.isText){let o=n.state.tr;return e<0?o.delete(t.pos-s.nodeSize,t.pos):o.delete(t.pos,t.pos+s.nodeSize),n.dispatch(o),!0}return!1}function nl(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function lg(n){if(!le||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;nl(n,r,"true"),setTimeout(()=>nl(n,r,"false"),20)}return!1}function ag(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function ug(n,e){let t=e.keyCode,r=ag(e);if(t==8||we&&t==72&&r=="c")return tl(n,-1)||Vt(n,-1);if(t==46&&!e.shiftKey||we&&t==68&&r=="c")return tl(n,1)||Vt(n,1);if(t==13||t==27)return!0;if(t==37||we&&t==66&&r=="c"){let i=t==37?Zo(n,n.state.selection.from)=="ltr"?-1:1:-1;return Xo(n,i,r)||Vt(n,i)}else if(t==39||we&&t==70&&r=="c"){let i=t==39?Zo(n,n.state.selection.from)=="ltr"?1:-1:1;return Xo(n,i,r)||Vt(n,i)}else{if(t==38||we&&t==80&&r=="c")return el(n,-1,r)||Vt(n,-1);if(t==40||we&&t==78&&r=="c")return lg(n)||el(n,1,r)||Vt(n,1);if(r==(we?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function zs(n,e){n.someProp("transformCopied",f=>{e=f(e,n)});let t=[],{content:r,openStart:i,openEnd:s}=e;for(;i>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,s--;let f=r.firstChild;t.push(f.type.name,f.attrs!=f.type.defaultAttrs?f.attrs:null),r=f.content}let o=n.someProp("clipboardSerializer")||en.fromSchema(n.state.schema),l=lu(),a=l.createElement("div");a.appendChild(o.serializeFragment(r,{document:l}));let u=a.firstChild,c,h=0;for(;u&&u.nodeType==1&&(c=ou[u.nodeName.toLowerCase()]);){for(let f=c.length-1;f>=0;f--){let p=l.createElement(c[f]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),h++}u=a.firstChild}u&&u.nodeType==1&&u.setAttribute("data-pm-slice",`${i} ${s}${h?` -${h}`:""} ${JSON.stringify(t)}`);let d=n.someProp("clipboardTextSerializer",f=>f(e,n))||e.content.textBetween(0,e.content.size,`
34
+ `),i;function a(e){return r.stack.push(e),t;function t(){r.stack.pop()}}}function Pi(e){throw Error("Cannot handle value `"+e+"`, expected node")}function Fi(e){throw Error("Cannot handle unknown node `"+e.type+"`")}function Ii(e,t){if(e.type===`definition`&&e.type===t.type)return 0}function Li(e,t){return wi(e,this,t)}function Ri(e,t){return Ti(e,this,t)}function zi(e,t){return ki(this,e,t)}function Bi(e){let t=this;t.compiler=n;function n(n){return Ni(n,{...t.data(`settings`),...e,extensions:t.data(`toMarkdownExtensions`)||[]})}}function Vi(e){if(e)throw e}var Hi=n(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=Object.prototype.toString,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=function(e){return typeof Array.isArray==`function`?Array.isArray(e):r.call(e)===`[object Array]`},s=function(e){if(!e||r.call(e)!==`[object Object]`)return!1;var t=n.call(e,`constructor`),i=e.constructor&&e.constructor.prototype&&n.call(e.constructor.prototype,`isPrototypeOf`);if(e.constructor&&!t&&!i)return!1;for(var a in e);return a===void 0||n.call(e,a)},c=function(e,t){i&&t.name===`__proto__`?i(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},l=function(e,t){if(t===`__proto__`){if(!n.call(e,t))return;if(a)return a(e,t).value}return e[t]};t.exports=function e(){var t,n,r,i,a,u,d=arguments[0],f=1,p=arguments.length,m=!1;for(typeof d==`boolean`&&(m=d,d=arguments[1]||{},f=2),(d==null||typeof d!=`object`&&typeof d!=`function`)&&(d={});f<p;++f)if(t=arguments[f],t!=null)for(n in t)r=l(d,n),i=l(t,n),d!==i&&(m&&i&&(s(i)||(a=o(i)))?(a?(a=!1,u=r&&o(r)?r:[]):u=r&&s(r)?r:{},c(d,{name:n,newValue:e(m,u,i)})):i!==void 0&&c(d,{name:n,newValue:i}));return d}}));function Ui(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function Wi(){let e=[],t={run:n,use:r};return t;function n(...t){let n=-1,r=t.pop();if(typeof r!=`function`)throw TypeError(`Expected function as last argument, not `+r);i(null,...t);function i(a,...o){let s=e[++n],c=-1;if(a){r(a);return}for(;++c<t.length;)(o[c]===null||o[c]===void 0)&&(o[c]=t[c]);t=o,s?Gi(s,i)(...o):r(null,...o)}}function r(n){if(typeof n!=`function`)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}}function Gi(e,t){let n;return r;function r(...t){let r=e.length>t.length,o;r&&t.push(i);try{o=e.apply(this,t)}catch(e){let t=e;if(r&&n)throw t;return i(t)}r||(o&&o.then&&typeof o.then==`function`?o.then(a,i):o instanceof Error?i(o):a(o))}function i(e,...r){n||(n=!0,t(e,...r))}function a(e){i(null,e)}}var N=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=Kn(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};N.prototype.file=``,N.prototype.name=``,N.prototype.reason=``,N.prototype.message=``,N.prototype.stack=``,N.prototype.column=void 0,N.prototype.line=void 0,N.prototype.ancestors=void 0,N.prototype.cause=void 0,N.prototype.fatal=void 0,N.prototype.place=void 0,N.prototype.ruleId=void 0,N.prototype.source=void 0;var Ki={basename:qi,dirname:Ji,extname:Yi,join:Xi,sep:`/`};function qi(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);$i(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?``:e.slice(n,r)}if(t===e)return``;let o=-1,s=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),s>-1&&(e.codePointAt(i)===t.codePointAt(s--)?s<0&&(r=i):(s=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function Ji(e){if($i(e),e.length===0)return`.`;let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||=!0;return t<0?e.codePointAt(0)===47?`/`:`.`:t===1&&e.codePointAt(0)===47?`//`:e.slice(0,t)}function Yi(e){$i(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){let s=e.codePointAt(t);if(s===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),s===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?``:e.slice(i,n)}function Xi(...e){let t=-1,n;for(;++t<e.length;)$i(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:Zi(n)}function Zi(e){$i(e);let t=e.codePointAt(0)===47,n=Qi(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function Qi(e,t){let n=``,r=0,i=-1,a=0,o=-1,s,c;for(;++o<=e.length;){if(o<e.length)s=e.codePointAt(o);else if(s===47)break;else s=47;if(s===47){if(!(i===o-1||a===1))if(i!==o-1&&a===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf(`/`),c!==n.length-1){c<0?(n=``,r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf(`/`)),i=o,a=0;continue}}else if(n.length>0){n=``,r=0,i=o,a=0;continue}}t&&(n=n.length>0?n+`/..`:`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1;i=o,a=0}else s===46&&a>-1?a++:a=-1}return n}function $i(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var ea={cwd:ta};function ta(){return`/`}function na(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function ra(e){if(typeof e==`string`)e=new URL(e);else if(!na(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code=`ERR_INVALID_ARG_TYPE`,t}if(e.protocol!==`file:`){let e=TypeError(`The URL must be of scheme file`);throw e.code=`ERR_INVALID_URL_SCHEME`,e}return ia(e)}function ia(e){if(e.hostname!==``){let e=TypeError(`File URL host must be "localhost" or empty on darwin`);throw e.code=`ERR_INVALID_FILE_URL_HOST`,e}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let e=t.codePointAt(n+2);if(e===70||e===102){let e=TypeError(`File URL path must not include encoded / characters`);throw e.code=`ERR_INVALID_FILE_URL_PATH`,e}}return decodeURIComponent(t)}var aa=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],oa=class{constructor(e){let t;t=e?na(e)?{path:e}:typeof e==`string`||ua(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:ea.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<aa.length;){let e=aa[n];e in t&&t[e]!==void 0&&t[e]!==null&&(this[e]=e===`history`?[...t[e]]:t[e])}let r;for(r in t)aa.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?Ki.basename(this.path):void 0}set basename(e){ca(e,`basename`),sa(e,`basename`),this.path=Ki.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?Ki.dirname(this.path):void 0}set dirname(e){la(this.basename,`dirname`),this.path=Ki.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?Ki.extname(this.path):void 0}set extname(e){if(sa(e,`extname`),la(this.dirname,`extname`),e){if(e.codePointAt(0)!==46)throw Error("`extname` must start with `.`");if(e.includes(`.`,1))throw Error("`extname` cannot contain multiple dots")}this.path=Ki.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){na(e)&&(e=ra(e)),ca(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?Ki.basename(this.path,this.extname):void 0}set stem(e){ca(e,`stem`),sa(e,`stem`),this.path=Ki.join(this.dirname||``,e+(this.extname||``))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new N(e,t,n);return this.path&&(r.name=this.path+`:`+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return this.value===void 0?``:typeof this.value==`string`?this.value:new TextDecoder(e||void 0).decode(this.value)}};function sa(e,t){if(e&&e.includes(Ki.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+Ki.sep+"`")}function ca(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function la(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function ua(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var da=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),fa=t(Hi(),1),pa={}.hasOwnProperty,ma=new class e extends da{constructor(){super(`copy`),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=Wi()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,fa.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(_a(`data`,this.frozen),this.namespace[e]=t,this):pa.call(this.namespace,e)&&this.namespace[e]||void 0:e?(_a(`data`,this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;let e=this;for(;++this.freezeIndex<this.attachers.length;){let[t,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);let r=t.call(e,...n);typeof r==`function`&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=ba(e),n=this.parser||this.Parser;return ha(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),ha(`process`,this.parser||this.Parser),ga(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=ba(e),o=n.parse(a);n.run(o,a,function(e,t,r){if(e||!t||!r)return s(e);let i=t,a=n.stringify(i,r);Sa(a)?r.value=a:r.result=a,s(e,r)});function s(e,n){e||!n?i(e):r?r(n):t(void 0,n)}}}processSync(e){let t=!1,n;return this.freeze(),ha(`processSync`,this.parser||this.Parser),ga(`processSync`,this.compiler||this.Compiler),this.process(e,r),ya(`processSync`,`process`,t),n;function r(e,r){t=!0,Vi(e),n=r}}run(e,t,n){va(e),this.freeze();let r=this.transformers;return!n&&typeof t==`function`&&(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,a){let o=ba(t);r.run(e,o,s);function s(t,r,o){let s=r||e;t?a(t):i?i(s):n(void 0,s,o)}}}runSync(e,t){let n=!1,r;return this.run(e,t,i),ya(`runSync`,`run`,n),r;function i(e,t){Vi(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=ba(t),r=this.compiler||this.Compiler;return ga(`stringify`,r),va(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(_a(`use`,this.frozen),e!=null)if(typeof e==`function`)s(e,t);else if(typeof e==`object`)Array.isArray(e)?o(e):a(e);else throw TypeError("Expected usable value, not `"+e+"`");return this;function i(e){if(typeof e==`function`)s(e,[]);else if(typeof e==`object`)if(Array.isArray(e)){let[t,...n]=e;s(t,n)}else a(e);else throw TypeError("Expected usable value, not `"+e+"`")}function a(e){if(!(`plugins`in e)&&!(`settings`in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(e.plugins),e.settings&&(r.settings=(0,fa.default)(!0,r.settings,e.settings))}function o(e){let t=-1;if(e!=null)if(Array.isArray(e))for(;++t<e.length;){let n=e[t];i(n)}else throw TypeError("Expected a list of plugins, not `"+e+"`")}function s(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(i===-1)n.push([e,...t]);else if(t.length>0){let[r,...a]=t,o=n[i][1];Ui(o)&&Ui(r)&&(r=(0,fa.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function ha(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function ga(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function _a(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function va(e){if(!Ui(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function ya(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function ba(e){return xa(e)?e:new oa(e)}function xa(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function Sa(e){return typeof e==`string`||Ca(e)}function Ca(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}function P(e){this.content=e}P.prototype={constructor:P,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),a=r.content.slice();return i==-1?a.push(n||e,t):(a[i+1]=t,n&&(a[i]=n)),new P(a)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new P(n)},addToStart:function(e,t){return new P([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new P(n)},addBefore:function(e,t,n){var r=this.remove(t),i=r.content.slice(),a=r.find(e);return i.splice(a==-1?i.length:a,0,t,n),new P(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=P.from(e),e.size?new P(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=P.from(e),e.size?new P(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=P.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},P.from=function(e){if(e instanceof P)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new P(t)};function wa(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),a=t.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){for(let e=0;i.text[e]==a.text[e];e++)n++;return n}if(i.content.size||a.content.size){let e=wa(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}function Ta(e,t,n,r){for(let i=e.childCount,a=t.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=e.child(--i),s=t.child(--a),c=o.nodeSize;if(o==s){n-=c,r-=c;continue}if(!o.sameMarkup(s))return{a:n,b:r};if(o.isText&&o.text!=s.text){let e=0,t=Math.min(o.text.length,s.text.length);for(;e<t&&o.text[o.text.length-e-1]==s.text[s.text.length-e-1];)e++,n--,r--;return{a:n,b:r}}if(o.content.size||s.content.size){let e=Ta(o.content,s.content,n-1,r-1);if(e)return e}n-=c,r-=c}}var F=class e{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let a=0,o=0;o<t;a++){let s=this.content[a],c=o+s.nodeSize;if(c>e&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<t.content.length;a++)i.push(t.content[a]);return new e(i,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],i=0;if(n>t)for(let e=0,a=0;a<n;e++){let o=this.content[e],s=a+o.nodeSize;s>t&&((a<t||s>n)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw RangeError(`Index `+e+` out of range for `+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return wa(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return Ta(this,e,t,n)}findIndex(e){if(e==0)return Da(0,e);if(e==this.size)return Da(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?Da(t+1,i):Da(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return new e(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;e<t.length;e++){let i=t[e];r+=i.nodeSize,e&&i.isText&&t[e-1].sameMarkup(i)?(n||=t.slice(0,e),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new e(n||t,r)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw RangeError(`Can not convert `+t+` to a Fragment`+(t.nodesBetween?` (looks like multiple versions of prosemirror-model were loaded)`:``))}};F.empty=new F([],0);var Ea={index:0,offset:0};function Da(e,t){return Ea.index=e,Ea.offset=t,Ea}function Oa(e,t){if(e===t)return!0;if(!(e&&typeof e==`object`)||!(t&&typeof t==`object`))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!Oa(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!Oa(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}var I=class e{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||=e.slice(0,r);else if(i.type.excludes(this.type))return e;else !n&&i.type.rank>this.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Oa(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Mark.fromJSON`);let n=e.marks[t.type];if(!n)throw RangeError(`There is no mark type ${t.type} in this schema`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return e.none;if(t instanceof e)return[t];let n=t.slice();return n.sort((e,t)=>e.type.rank-t.type.rank),n}};I.none=[];var ka=class extends Error{},L=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=ja(this.content,t+this.openStart,n);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(Aa(this.content,t+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(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(F.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};L.empty=new L(F.empty,0,0);function Aa(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy(Aa(a.content,t-i-1,n-i-1)))}function ja(e,t,n,r){let{index:i,offset:a}=e.findIndex(t),o=e.maybeChild(i);if(a==t||o.isText)return r&&!r.canReplace(i,i,n)?null:e.cut(0,t).append(n).append(e.cut(t));let s=ja(o.content,t-a-1,n,o);return s&&e.replaceChild(i,o.copy(s))}function Ma(e,t,n){if(n.openStart>e.depth)throw new ka(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new ka(`Inconsistent open depths`);return Na(e,t,n,0)}function Na(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){let o=Na(e,t,n,r+1);return a.copy(a.content.replaceChild(i,o))}else if(!n.content.size)return Ra(a,Ba(e,t,r));else if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let r=e.parent,i=r.content;return Ra(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}else{let{start:i,end:o}=Va(n,e);return Ra(a,za(e,i,o,t,r))}}function Pa(e,t){if(!t.type.compatibleContent(e.type))throw new ka(`Cannot join `+t.type.name+` onto `+e.type.name)}function Fa(e,t,n){let r=e.node(n);return Pa(r,t.node(n)),r}function Ia(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function La(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(Ia(e.nodeAfter,r),a++));for(let e=a;e<o;e++)Ia(i.child(e),r);t&&t.depth==n&&t.textOffset&&Ia(t.nodeBefore,r)}function Ra(e,t){return e.type.checkContent(t),e.copy(t)}function za(e,t,n,r,i){let a=e.depth>i&&Fa(e,t,i+1),o=r.depth>i&&Fa(n,r,i+1),s=[];return La(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(Pa(a,o),Ia(Ra(a,za(e,t,n,r,i+1)),s)):(a&&Ia(Ra(a,Ba(e,t,i+1)),s),La(t,n,i,s),o&&Ia(Ra(o,Ba(n,r,i+1)),s)),La(r,null,i,s),new F(s)}function Ba(e,t,n){let r=[];return La(null,e,n,r),e.depth>n&&Ia(Ra(Fa(e,t,n+1),Ba(e,t,n+1)),r),La(t,null,n,r),new F(r)}function Va(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(F.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var Ha=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.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 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 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,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return I.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var a=0;a<i.length;a++)i[a].type.spec.inclusive===!1&&(!r||!i[a].isInSet(r.marks))&&(i=i[a--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)n[i].type.spec.inclusive===!1&&(!r||!n[i].isInSet(r.marks))&&(n=n[i--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new Ka(this,e,n);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<this.pos?e:this}toString(){let e=``;for(let t=1;t<=this.depth;t++)e+=(e?`/`:``)+this.node(t).type.name+`_`+this.index(t-1);return e+`:`+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=Ga.get(t);if(r)for(let e=0;e<r.elts.length;e++){let t=r.elts[e];if(t.pos==n)return t}else Ga.set(t,r=new Ua);let i=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%Wa,i}},Ua=class{constructor(){this.elts=[],this.i=0}},Wa=12,Ga=new WeakMap,Ka=class{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},qa=Object.create(null),Ja=class e{constructor(e,t,n,r=I.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||F.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,``)}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&Oa(this.attrs,t||e.defaultAttrs||qa)&&I.sameSet(this.marks,n||I.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return L.empty;let r=this.resolve(e),i=this.resolve(t),a=n?0:r.sharedDepth(t),o=r.start(a);return new L(r.node(a).content.cut(r.pos-o,i.pos-o),r.depth-a,i.depth-a)}replace(e,t,n){return Ma(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return Ha.resolveCached(this,e)}resolveNoCache(e){return Ha.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}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()+`)`),Xa(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=F.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),a=i&&i.matchFragment(this.content,t);return a?a.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=I.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!I.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t 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(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=F.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}};Ja.prototype.text=void 0;var Ya=class e extends Ja{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Xa(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function Xa(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}var Za=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new Qa(t,n);if(r.next==null)return e.empty;let i=$a(r);r.next&&r.err(`Unexpected trailing text`);let a=lo(oo(i));return uo(a,r),a}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];function i(a,o){let s=a.matchFragment(e,n);if(s&&(!t||s.validEnd))return F.from(o.map(e=>e.createAndFill()));for(let e=0;e<a.next.length;e++){let{type:t,next:n}=a.next[e];if(!(t.isText||t.hasRequiredAttrs())&&r.indexOf(n)==-1){r.push(n);let e=i(n,o.concat(t));if(e)return e}}return null}return i(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:a,next:o}=i.next[e];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!r.type||o.validEnd)&&(n.push({match:a.contentMatch,type:a,via:r}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r<n.next.length;r++)e.indexOf(n.next[r].next)==-1&&t(n.next[r].next)}return t(this),e.map((t,n)=>{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n<t.next.length;n++)r+=(n?`, `:``)+t.next[n].type.name+`->`+e.indexOf(t.next[n].next);return r}).join(`
35
+ `)}};Za.empty=new Za(!0);var Qa=class{constructor(e,t){this.string=e,this.nodeTypes=t,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 SyntaxError(e+` (in content expression '`+this.string+`')`)}};function $a(e){let t=[];do t.push(eo(e));while(e.eat(`|`));return t.length==1?t[0]:{type:`choice`,exprs:t}}function eo(e){let t=[];do t.push(to(e));while(e.next&&e.next!=`)`&&e.next!=`|`);return t.length==1?t[0]:{type:`seq`,exprs:t}}function to(e){let t=ao(e);for(;;)if(e.eat(`+`))t={type:`plus`,expr:t};else if(e.eat(`*`))t={type:`star`,expr:t};else if(e.eat(`?`))t={type:`opt`,expr:t};else if(e.eat(`{`))t=ro(e,t);else break;return t}function no(e){/\D/.test(e.next)&&e.err(`Expected number, got '`+e.next+`'`);let t=Number(e.next);return e.pos++,t}function ro(e,t){let n=no(e),r=n;return e.eat(`,`)&&(r=e.next==`}`?-1:no(e)),e.eat(`}`)||e.err(`Unclosed braced range`),{type:`range`,min:n,max:r,expr:t}}function io(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let i=[];for(let e in n){let r=n[e];r.isInGroup(t)&&i.push(r)}return i.length==0&&e.err(`No node type or group '`+t+`' found`),i}function ao(e){if(e.eat(`(`)){let t=$a(e);return e.eat(`)`)||e.err(`Missing closing paren`),t}else if(/\W/.test(e.next))e.err(`Unexpected token '`+e.next+`'`);else{let t=io(e,e.next).map(t=>(e.inline==null?e.inline=t.isInline:e.inline!=t.isInline&&e.err(`Mixing inline and block content`),{type:`name`,value:t}));return e.pos++,t.length==1?t[0]:{type:`choice`,exprs:t}}}function oo(e){let t=[[]];return i(a(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let i={term:r,to:n};return t[e].push(i),i}function i(e,t){e.forEach(e=>e.to=t)}function a(e,t){if(e.type==`choice`)return e.exprs.reduce((e,n)=>e.concat(a(n,t)),[]);if(e.type==`seq`)for(let r=0;;r++){let o=a(e.exprs[r],t);if(r==e.exprs.length-1)return o;i(o,t=n())}else if(e.type==`star`){let o=n();return r(t,o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`plus`){let o=n();return i(a(e.expr,t),o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`opt`)return[r(t)].concat(a(e.expr,t));else if(e.type==`range`){let o=t;for(let t=0;t<e.min;t++){let t=n();i(a(e.expr,o),t),o=t}if(e.max==-1)i(a(e.expr,o),o);else for(let t=e.min;t<e.max;t++){let t=n();r(o,t),i(a(e.expr,o),t),o=t}return[r(o)]}else if(e.type==`name`)return[r(t,void 0,e.value)];else throw Error(`Unknown expr type`)}}function so(e,t){return t-e}function co(e,t){let n=[];return r(t),n.sort(so);function r(t){let i=e[t];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(t);for(let e=0;e<i.length;e++){let{term:t,to:a}=i[e];!t&&n.indexOf(a)==-1&&r(a)}}}function lo(e){let t=Object.create(null);return n(co(e,0));function n(r){let i=[];r.forEach(t=>{e[t].forEach(({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e<i.length;e++)i[e][0]==t&&(r=i[e][1]);co(e,n).forEach(e=>{r||i.push([t,r=[]]),r.indexOf(e)==-1&&r.push(e)})})});let a=t[r.join(`,`)]=new Za(r.indexOf(e.length-1)>-1);for(let e=0;e<i.length;e++){let r=i[e][1].sort(so);a.next.push({type:i[e][0],next:t[r.join(`,`)]||n(r)})}return a}}function uo(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],i=!e.validEnd,a=[];for(let t=0;t<e.next.length;t++){let{type:n,next:o}=e.next[t];a.push(n.name),i&&!(n.isText||n.hasRequiredAttrs())&&(i=!1),r.indexOf(o)==-1&&r.push(o)}i&&t.err(`Only non-generatable nodes (`+a.join(`, `)+`) in a required position (see https://prosemirror.net/docs/guide/#generatable)`)}}function fo(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function po(e,t){let n=Object.create(null);for(let r in e){let i=t&&t[r];if(i===void 0){let t=e[r];if(t.hasDefault)i=t.default;else throw RangeError(`No value supplied for attribute `+r)}n[r]=i}return n}function mo(e,t,n,r){for(let r in t)if(!(r in e))throw RangeError(`Unsupported attribute ${r} for ${n} of type ${r}`);for(let n in e){let r=e[n];r.validate&&r.validate(t[n])}}function ho(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new vo(e,r,t[r]);return n}var go=class e{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(` `):[],this.attrs=ho(e,n.attrs),this.defaultAttrs=fo(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||e==`text`),this.isText=e==`text`}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Za.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?`pre`:`normal`)}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:po(this.attrs,e)}create(e=null,t,n){if(this.isText)throw Error(`NodeType.create can't construct text nodes`);return new Ja(this,this.computeAttrs(e),F.from(t),I.setFrom(n))}createChecked(e=null,t,n){return t=F.from(t),this.checkContent(t),new Ja(this,this.computeAttrs(e),t,I.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),t=F.from(t),t.size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),i=r&&r.fillBefore(F.empty,!0);return i?new Ja(this,e,t.append(i),I.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){mo(this.attrs,e,`node`,this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||=e.slice(0,n);return t?t.length?t:I.none:e}static compile(t,n){let r=Object.create(null);t.forEach((t,i)=>r[t]=new e(t,n,i));let i=n.spec.topNode||`doc`;if(!r[i])throw RangeError(`Schema is missing its top node type ('`+i+`')`);if(!r.text)throw RangeError(`Every schema needs a 'text' type`);for(let e in r.text.attrs)throw RangeError(`The text node type should not have attributes`);return r}};function _o(e,t,n){let r=n.split(`|`);return n=>{let i=n===null?`null`:typeof n;if(r.indexOf(i)<0)throw RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${i}`)}}var vo=class{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,`default`),this.default=n.default,this.validate=typeof n.validate==`string`?_o(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}},yo=class e{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=ho(e,r.attrs),this.excluded=null;let i=fo(this.attrs);this.instance=i?new I(this,i):null}create(e=null){return!e&&this.instance?this.instance:new I(this,po(this.attrs,e))}static compile(t,n){let r=Object.create(null),i=0;return t.forEach((t,a)=>r[t]=new e(t,i++,n,a)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){mo(this.attrs,e,`mark`,this.name)}excludes(e){return this.excluded.indexOf(e)>-1}},bo=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=P.from(e.nodes),t.marks=P.from(e.marks||{}),this.nodes=go.compile(this.spec.nodes,this),this.marks=yo.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw RangeError(e+` can not be both a node and a mark`);let t=this.nodes[e],r=t.spec.content||``,i=t.spec.marks;if(t.contentMatch=n[r]||(n[r]=Za.parse(r,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw RangeError(`Multiple linebreak nodes defined`);if(!t.isInline||!t.isLeaf)throw RangeError(`Linebreak replacement nodes must be inline leaf nodes`);this.linebreakReplacement=t}t.markSet=i==`_`?null:i?xo(this,i.split(` `)):i==``||!t.inlineContent?[]:null}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=n==null?[t]:n==``?[]:xo(this,n.split(` `))}this.nodeFromJSON=e=>Ja.fromJSON(this,e),this.markFromJSON=e=>I.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||`doc`],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if(typeof e==`string`)e=this.nodeType(e);else if(!(e instanceof go))throw RangeError(`Invalid node type: `+e);else if(e.schema!=this)throw RangeError(`Node type from different schema used (`+e.name+`)`);return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new Ya(n,n.defaultAttrs,e,I.setFrom(t))}mark(e,t){return typeof e==`string`&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw RangeError(`Unknown node type: `+e);return t}};function xo(e,t){let n=[];for(let r=0;r<t.length;r++){let i=t[r],a=e.marks[i],o=a;if(a)n.push(a);else for(let t in e.marks){let r=e.marks[t];(i==`_`||r.spec.group&&r.spec.group.split(` `).indexOf(i)>-1)&&n.push(o=r)}if(!o)throw SyntaxError(`Unknown mark type: '`+t[r]+`'`)}return n}function So(e){return e.tag!=null}function Co(e){return e.style!=null}var wo=class e{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(So(e))this.tags.push(e);else if(Co(e)){let t=/[^=]*/.exec(e.style)[0];n.indexOf(t)<0&&n.push(t),this.styles.push(e)}}),this.normalizeLists=!this.tags.some(t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)})}parse(e,t={}){let n=new No(this,t,!1);return n.addAll(e,I.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new No(this,t,!0);return n.addAll(e,I.none,t.from,t.to),L.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let n=this.tags[r];if(Fo(e,n.tag)&&(n.namespace===void 0||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(t===!1)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,r){for(let i=r?this.styles.indexOf(r)+1:0;i<this.styles.length;i++){let r=this.styles[i],a=r.style;if(!(a.indexOf(e)!=0||r.context&&!n.matchesContext(r.context)||a.length>e.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(e===!1)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=e.priority==null?50:e.priority,r=0;for(;r<t.length;r++){let e=t[r];if((e.priority==null?50:e.priority)<n)break}t.splice(r,0,e)}for(let t in e.marks){let r=e.marks[t].spec.parseDOM;r&&r.forEach(e=>{n(e=Io(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach(e=>{n(e=Io(e)),e.node||e.ignore||e.mark||(e.node=t)})}return t}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new e(t,e.schemaRules(t)))}},To={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},Eo={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Do={ol:!0,ul:!0},Oo=1,ko=2,Ao=4;function jo(e,t,n){return t==null?e&&e.whitespace==`pre`?Oo|ko:n&~Ao:(t?Oo:0)|(t===`full`?ko:0)}var Mo=class{constructor(e,t,n,r,i,a){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=a,this.content=[],this.activeMarks=I.none,this.match=i||(a&Ao?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(F.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let t=this.type.contentMatch,n;return(n=t.findWrapping(e.type))?(this.match=t,n):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Oo)){let e=this.content[this.content.length-1],t;if(e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))){let n=e;e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-t[0].length))}}let t=F.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(F.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!To.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},No=class{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r=t.topNode,i,a=jo(null,t.preserveWhitespace,0)|(n?Ao:0);i=r?new Mo(r.type,r.attrs,I.none,!0,t.topMatch||r.type.contentMatch,a):n?new Mo(null,null,I.none,!0,null,a):new Mo(e.schema.topNodeType,null,I.none,!0,null,a),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,r=this.top,i=r.options&ko?`full`:this.localPreserveWS||(r.options&Oo)>0,{schema:a}=this.parser;if(i===`full`||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(!i){if(n=n.replace(/[ \t\r\n\u000c]+/g,` `),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=r.content[r.content.length-1],i=e.previousSibling;(!t||i&&i.nodeName==`BR`||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}}else if(i===`full`)n=n.replace(/\r\n?/g,`
36
+ `);else if(a.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(a.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n<e.length;n++)n&&this.insertNode(a.linebreakReplacement.create(),t,!0),e[n]&&this.insertNode(a.text(e[n]),t,!/\S/.test(e[n]));n=``}else n=n.replace(/\r?\n|\r/g,` `);n&&this.insertNode(a.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let r=this.localPreserveWS,i=this.top;(e.tagName==`PRE`||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let a=e.nodeName.toLowerCase(),o;Do.hasOwnProperty(a)&&this.parser.normalizeLists&&Po(e);let s=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,n));out:if(s?s.ignore:Eo.hasOwnProperty(a))this.findInside(e),this.ignoreFallback(e,t);else if(!s||s.skip||s.closeParent){s&&s.closeParent?this.open=Math.max(0,this.open-1):s&&s.skip.nodeType&&(e=s.skip);let n,r=this.needsBlock;if(To.hasOwnProperty(a))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),n=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break out}let o=s&&s.skip?t:this.readStyles(e,t);o&&this.addAll(e,o),n&&this.sync(i),this.needsBlock=r}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,s,n,s.consuming===!1?o:void 0)}this.localPreserveWS=r}leafFallback(e,t){e.nodeName==`BR`&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
37
+ `),t)}ignoreFallback(e,t){e.nodeName==`BR`&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text(`-`),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let e=0;e<this.parser.matchedStyles.length;e++){let r=this.parser.matchedStyles[e],i=n.getPropertyValue(r);if(i)for(let e;;){let n=this.parser.matchStyle(r,i,this,e);if(!n)break;if(n.ignore)return null;if(t=n.clearMark?t.filter(e=>!n.clearMark(e)):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),n.consuming===!1)e=n;else break}}return t}addElementByRule(e,t,n,r){let i,a;if(t.node)if(a=this.parser.schema.nodes[t.node],a.isLeaf)this.insertNode(a.create(t.attrs),n,e.nodeName==`BR`)||this.leafFallback(e,n);else{let e=this.enter(a,t.attrs||null,n,t.preserveWhitespace);e&&(i=!0,n=e)}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let o=this.top;if(a&&a.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let r=e;typeof t.contentElement==`string`?r=e.querySelector(t.contentElement):typeof t.contentElement==`function`?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}i&&this.sync(o)&&this.open--}addAll(e,t,n,r){let i=n||0;for(let a=n?e.childNodes[n]:e.firstChild,o=r==null?null:e.childNodes[r];a!=o;a=a.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(a,t);this.findAtPoint(e,i)}findPlace(e,t,n){let r,i;for(let t=this.open,a=0;t>=0;t--){let o=this.nodes[t],s=o.findWrapping(e);if(s&&(!r||r.length>s.length+a)&&(r=s,i=o,!s.length))break;if(o.solid){if(n)break;a+=2}}if(!r)return null;this.sync(i);for(let e=0;e<r.length;e++)t=this.enterInner(r[e],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(t=this.enterInner(e,null,t))}let r=this.findPlace(e,t,n);if(r){this.closeExtra();let t=this.top;t.match&&=t.match.matchType(e.type);let n=I.none;for(let i of r.concat(e.marks))(t.type?t.type.allowsMarkType(i.type):Lo(i.type,e.type))&&(n=i.addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n,r){let i=this.findPlace(e.create(t),n,!1);return i&&=this.enterInner(e,t,n,!0,r),i}enterInner(e,t,n,r=!1,i){this.closeExtra();let a=this.top;a.match=a.match&&a.match.matchType(e);let o=jo(e,i,a.options);a.options&Ao&&a.content.length==0&&(o|=Ao);let s=I.none;return n=n.filter(t=>(a.type?a.type.allowsMarkType(t.type):Lo(t.type,e))?(s=t.addToSet(s),!1):!0),this.nodes.push(new Mo(e,t,s,r,null,o)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].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 t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;else this.localPreserveWS&&(this.nodes[t].options|=Oo);return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)this.find[r].pos==null&&e.nodeType==1&&e.contains(this.find[r].node)&&t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf(`|`)>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split(`/`),n=this.options.context,r=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),i=-(n?n.depth+1:0)+(r?0:1),a=(e,o)=>{for(;e>=0;e--){let s=t[e];if(s==``){if(e==t.length-1||e==0)continue;for(;o>=i;o--)if(a(e-1,o))return!0;return!1}else{let e=o>0||o==0&&r?this.nodes[o].type:n&&o>=i?n.node(o-i).type:null;if(!e||e.name!=s&&!e.isInGroup(s))return!1;o--}}return!0};return a(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}};function Po(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=t.nodeType==1?t.nodeName.toLowerCase():null;e&&Do.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):e==`li`?n=t:e&&(n=null)}}function Fo(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function Io(e){let t={};for(let n in e)t[n]=e[n];return t}function Lo(e,t){let n=t.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(e))continue;let a=[],o=e=>{a.push(e);for(let n=0;n<e.edgeCount;n++){let{type:r,next:i}=e.edge(n);if(r==t||a.indexOf(i)<0&&o(i))return!0}};if(o(i.contentMatch))return!0}}var Ro=class e{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||=Bo(t).createDocumentFragment();let r=n,i=[];return e.forEach(e=>{if(i.length||e.marks.length){let n=0,a=0;for(;n<i.length&&a<e.marks.length;){let t=e.marks[a];if(!this.marks[t.type.name]){a++;continue}if(!t.eq(i[n][0])||t.type.spec.spanning===!1)break;n++,a++}for(;n<i.length;)r=i.pop()[1];for(;a<e.marks.length;){let n=e.marks[a++],o=this.serializeMark(n,e.isInline,t);o&&(i.push([n,r]),r.appendChild(o.dom),r=o.contentDOM||o.dom)}}r.appendChild(this.serializeNodeInner(e,t))}),n}serializeNodeInner(e,t){let{dom:n,contentDOM:r}=Wo(Bo(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw RangeError(`Content hole not allowed in a leaf node spec`);this.serializeFragment(e.content,t,r)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let i=this.serializeMark(e.marks[r],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&Wo(Bo(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return Wo(e,t,n,r)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new e(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(e){let t=zo(e.nodes);return t.text||=e=>e.text,t}static marksFromSchema(e){return zo(e.marks)}};function zo(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function Bo(e){return e.document||window.document}var Vo=new WeakMap;function Ho(e){let t=Vo.get(e);return t===void 0&&Vo.set(e,t=Uo(e)),t}function Uo(e){let t=null;function n(e){if(e&&typeof e==`object`)if(Array.isArray(e))if(typeof e[0]==`string`)t||=[],t.push(e);else for(let t=0;t<e.length;t++)n(e[t]);else for(let t in e)n(e[t])}return n(e),t}function Wo(e,t,n,r){if(typeof t==`string`)return{dom:e.createTextNode(t)};if(t.nodeType!=null)return{dom:t};if(t.dom&&t.dom.nodeType!=null)return t;let i=t[0],a;if(typeof i!=`string`)throw RangeError(`Invalid array passed to renderSpec`);if(r&&(a=Ho(r))&&a.indexOf(t)>-1)throw RangeError(`Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.`);let o=i.indexOf(` `);o>0&&(n=i.slice(0,o),i=i.slice(o+1));let s,c=n?e.createElementNS(n,i):e.createElement(i),l=t[1],u=1;if(l&&typeof l==`object`&&l.nodeType==null&&!Array.isArray(l)){u=2;for(let e in l)if(l[e]!=null){let t=e.indexOf(` `);t>0?c.setAttributeNS(e.slice(0,t),e.slice(t+1),l[e]):e==`style`&&c.style?c.style.cssText=l[e]:c.setAttribute(e,l[e])}}for(let i=u;i<t.length;i++){let a=t[i];if(a===0){if(i<t.length-1||i>u)throw RangeError(`Content hole must be the only child of its parent node`);return{dom:c,contentDOM:c}}else{let{dom:t,contentDOM:i}=Wo(e,a,n,r);if(c.appendChild(t),i){if(s)throw RangeError(`Multiple content holes`);s=i}}}return{dom:c,contentDOM:s}}var Go=65535,Ko=2**16;function qo(e,t){return e+t*Ko}function Jo(e){return e&Go}function Yo(e){return(e-(e&Go))/Ko}var Xo=1,Zo=2,Qo=4,$o=8,es=class{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&$o)>0}get deletedBefore(){return(this.delInfo&(Xo|Qo))>0}get deletedAfter(){return(this.delInfo&(Zo|Qo))>0}get deletedAcross(){return(this.delInfo&Qo)>0}},ts=class e{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&e.empty)return e.empty}recover(e){let t=0,n=Jo(e);if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[e*3+2]-this.ranges[e*3+1];return this.ranges[n*3]+t+Yo(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let r=0,i=this.inverted?2:1,a=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let s=this.ranges[o]-(this.inverted?r:0);if(s>e)break;let c=this.ranges[o+i],l=this.ranges[o+a],u=s+c;if(e<=u){let i=c?e==s?-1:e==u?1:t:t,a=s+r+(i<0?0:l);if(n)return a;let d=e==(t<0?s:u)?null:qo(o/3,e-s),f=e==s?Zo:e==u?Xo:Qo;return(t<0?e!=s:e!=u)&&(f|=$o),new es(a,f,d)}r+=l-c}return n?e+r:new es(e+r,0,null)}touches(e,t){let n=0,r=Jo(t),i=this.inverted?2:1,a=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let o=this.ranges[t]-(this.inverted?n:0);if(o>e)break;let s=this.ranges[t+i];if(e<=o+s&&t==r*3)return!0;n+=this.ranges[t+a]-s}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r<this.ranges.length;r+=3){let a=this.ranges[r],o=a-(this.inverted?i:0),s=a+(this.inverted?0:i),c=this.ranges[r+t],l=this.ranges[r+n];e(o,o+c,s,s+l),i+=l-c}}invert(){return new e(this.ranges,!this.inverted)}toString(){return(this.inverted?`-`:``)+JSON.stringify(this.ranges)}static offset(t){return t==0?e.empty:new e(t<0?[0,-t,0]:[0,0,t])}};ts.empty=new ts([]);var ns=class e{constructor(e,t,n=0,r=e?e.length:0){this.mirror=t,this.from=n,this.to=r,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(t=0,n=this.maps.length){return new e(this._maps,this.mirror,t,n)}appendMap(e,t){this.ownData||=(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let r=e.getMirror(t);this.appendMap(e._maps[t],r!=null&&r<t?n+r:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||=[],this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),r!=null&&r>t?n-r-1:void 0)}}invert(){let t=new e;return t.appendMappingInverted(this),t}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let r=0;for(let n=this.from;n<this.to;n++){let i=this._maps[n].mapResult(e,t);if(i.recover!=null){let t=this.getMirror(n);if(t!=null&&t>n&&t<this.to){n=t,e=this._maps[t].recover(i.recover);continue}}r|=i.delInfo,e=i.pos}return n?e:new es(e,r,null)}},rs=Object.create(null),R=class{getMap(){return ts.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw RangeError(`Invalid input for Step.fromJSON`);let n=rs[t.stepType];if(!n)throw RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in rs)throw RangeError(`Duplicate use of step JSON ID `+e);return rs[e]=t,t.prototype.jsonID=e,t}},z=class e{constructor(e,t){this.doc=e,this.failed=t}static ok(t){return new e(t,null)}static fail(t){return new e(null,t)}static fromReplace(t,n,r,i){try{return e.ok(t.replace(n,r,i))}catch(t){if(t instanceof ka)return e.fail(t.message);throw t}}};function is(e,t,n){let r=[];for(let i=0;i<e.childCount;i++){let a=e.child(i);a.content.size&&(a=a.copy(is(a.content,t,a))),a.isInline&&(a=t(a,n,i)),r.push(a)}return F.fromArray(r)}var as=class e extends R{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),r=n.node(n.sharedDepth(this.to)),i=new L(is(t.content,(e,t)=>!e.isAtom||!t.type.allowsMarkType(this.mark.type)?e:e.mark(this.mark.addToSet(e.marks)),r),t.openStart,t.openEnd);return z.fromReplace(e,this.from,this.to,i)}invert(){return new ss(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`addMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for AddMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};R.jsonID(`addMark`,as);var ss=class e extends R{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new L(is(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return z.fromReplace(e,this.from,this.to,n)}invert(){return new as(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`removeMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for RemoveMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};R.jsonID(`removeMark`,ss);var cs=class e extends R{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return z.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return z.fromReplace(e,this.pos,this.pos+1,new L(F.from(n),0,t.isLeaf?0:1))}invert(t){let n=t.nodeAt(this.pos);if(n){let t=this.mark.addToSet(n.marks);if(t.length==n.marks.length){for(let r=0;r<n.marks.length;r++)if(!n.marks[r].isInSet(t))return new e(this.pos,n.marks[r]);return new e(this.pos,this.mark)}}return new ls(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`addNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for AddNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};R.jsonID(`addNodeMark`,cs);var ls=class e extends R{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return z.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return z.fromReplace(e,this.pos,this.pos+1,new L(F.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new cs(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`removeNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for RemoveNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};R.jsonID(`removeNodeMark`,ls);var us=class e extends R{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&fs(e,this.from,this.to)?z.fail(`Structure replace would overwrite content`):z.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new ts([this.from,this.to-this.from,this.slice.size])}invert(t){return new e(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let n=t.mapResult(this.to,-1),r=this.from==this.to&&e.MAP_BIAS<0?n:t.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new e(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(t){if(!(t instanceof e)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let n=this.slice.size+t.slice.size==0?L.empty:new L(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new e(this.from,this.to+(t.to-t.from),n,this.structure)}else if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let n=this.slice.size+t.slice.size==0?L.empty:new L(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new e(t.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:`replace`,from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for ReplaceStep.fromJSON`);return new e(n.from,n.to,L.fromJSON(t,n.slice),!!n.structure)}};us.MAP_BIAS=1,R.jsonID(`replace`,us);var ds=class e extends R{constructor(e,t,n,r,i,a,o=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=i,this.insert=a,this.structure=o}apply(e){if(this.structure&&(fs(e,this.from,this.gapFrom)||fs(e,this.gapTo,this.to)))return z.fail(`Structure gap-replace would overwrite content`);let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return z.fail(`Gap is not a flat range`);let n=this.slice.insertAt(this.insert,t.content);return n?z.fromReplace(e,this.from,this.to,n):z.fail(`Content does not fit in gap`)}getMap(){return new ts([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let n=this.gapTo-this.gapFrom;return new e(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:t.map(this.gapFrom,-1),a=this.to==this.gapTo?r.pos:t.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||a>r.pos?null:new e(n.pos,r.pos,i,a,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(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`||typeof n.gapFrom!=`number`||typeof n.gapTo!=`number`||typeof n.insert!=`number`)throw RangeError(`Invalid input for ReplaceAroundStep.fromJSON`);return new e(n.from,n.to,n.gapFrom,n.gapTo,L.fromJSON(t,n.slice),n.insert,!!n.structure)}};R.jsonID(`replaceAround`,ds);function fs(e,t,n){let r=e.resolve(t),i=n-t,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let e=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,i--}}return!1}function ps(e,t,n,r){let i=[],a=[],o,s;e.doc.nodesBetween(t,n,(e,c,l)=>{if(!e.isInline)return;let u=e.marks;if(!r.isInSet(u)&&l.type.allowsMarkType(r.type)){let l=Math.max(c,t),d=Math.min(c+e.nodeSize,n),f=r.addToSet(u);for(let e=0;e<u.length;e++)u[e].isInSet(f)||(o&&o.to==l&&o.mark.eq(u[e])?o.to=d:i.push(o=new ss(l,d,u[e])));s&&s.to==l?s.to=d:a.push(s=new as(l,d,r))}}),i.forEach(t=>e.step(t)),a.forEach(t=>e.step(t))}function ms(e,t,n,r){let i=[],a=0;e.doc.nodesBetween(t,n,(e,o)=>{if(!e.isInline)return;a++;let s=null;if(r instanceof yo){let t=e.marks,n;for(;n=r.isInSet(t);)(s||=[]).push(n),t=n.removeFromSet(t)}else r?r.isInSet(e.marks)&&(s=[r]):s=e.marks;if(s&&s.length){let r=Math.min(o+e.nodeSize,n);for(let e=0;e<s.length;e++){let n=s[e],c;for(let e=0;e<i.length;e++){let t=i[e];t.step==a-1&&n.eq(i[e].style)&&(c=t)}c?(c.to=r,c.step=a):i.push({style:n,from:Math.max(o,t),to:r,step:a})}}}),i.forEach(t=>e.step(new ss(t.from,t.to,t.style)))}function hs(e,t,n,r=n.contentMatch,i=!0){let a=e.doc.nodeAt(t),o=[],s=t+1;for(let t=0;t<a.childCount;t++){let c=a.child(t),l=s+c.nodeSize,u=r.matchType(c.type);if(!u)o.push(new us(s,l,L.empty));else{r=u;for(let t=0;t<c.marks.length;t++)n.allowsMarkType(c.marks[t].type)||e.step(new ss(s,l,c.marks[t]));if(i&&c.isText&&n.whitespace!=`pre`){let e,t=/\r?\n|\r/g,r;for(;e=t.exec(c.text);)r||=new L(F.from(n.schema.text(` `,n.allowedMarks(c.marks))),0,0),o.push(new us(s+e.index,s+e.index+e[0].length,r))}}s=l}if(!r.validEnd){let t=r.fillBefore(F.empty,!0);e.replace(s,s,new L(t,0,0))}for(let t=o.length-1;t>=0;t--)e.step(o[t])}function gs(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function _s(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,i=0;;--n){let a=e.$from.node(n),o=e.$from.index(n)+r,s=e.$to.indexAfter(n)-i;if(n<e.depth&&a.canReplace(o,s,t))return n;if(n==0||a.type.spec.isolating||!gs(a,o,s))break;o&&(r=1),s<a.childCount&&(i=1)}return null}function vs(e,t,n){let{$from:r,$to:i,depth:a}=t,o=r.before(a+1),s=i.after(a+1),c=o,l=s,u=F.empty,d=0;for(let e=a,t=!1;e>n;e--)t||r.index(e)>0?(t=!0,u=F.from(r.node(e).copy(u)),d++):c--;let f=F.empty,p=0;for(let e=a,t=!1;e>n;e--)t||i.after(e+1)<i.end(e)?(t=!0,f=F.from(i.node(e).copy(f)),p++):l++;e.step(new ds(c,l,o,s,new L(u.append(f),d,p),u.size-d,!0))}function ys(e,t,n=null,r=e){let i=xs(e,t),a=i&&Ss(r,t);return a?i.map(bs).concat({type:t,attrs:n}).concat(a.map(bs)):null}function bs(e){return{type:e,attrs:null}}function xs(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.contentMatchAt(r).findWrapping(t);if(!a)return null;let o=a.length?a[0]:t;return n.canReplaceWith(r,i,o)?a:null}function Ss(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.child(r),o=t.contentMatch.findWrapping(a.type);if(!o)return null;let s=(o.length?o[o.length-1]:t).contentMatch;for(let e=r;s&&e<i;e++)s=s.matchType(n.child(e).type);return!s||!s.validEnd?null:o}function Cs(e,t,n){let r=F.empty;for(let e=n.length-1;e>=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw RangeError(`Wrapper type given to Transform.wrap does not form valid content of its parent wrapper`)}r=F.from(n[e].type.create(n[e].attrs,r))}let i=t.start,a=t.end;e.step(new ds(i,a,i,a,new L(r,0,0),n.length,!0))}function ws(e,t,n,r,i){if(!r.isTextblock)throw RangeError(`Type given to setBlockType should be a textblock`);let a=e.steps.length;e.doc.nodesBetween(t,n,(t,n)=>{let o=typeof i==`function`?i(t):i;if(t.isTextblock&&!t.hasMarkup(r,o)&&Ds(e.doc,e.mapping.slice(a).map(n),r)){let i=null;if(r.schema.linebreakReplacement){let e=r.whitespace==`pre`,t=!!r.contentMatch.matchType(r.schema.linebreakReplacement);e&&!t?i=!1:!e&&t&&(i=!0)}i===!1&&Es(e,t,n,a),hs(e,e.mapping.slice(a).map(n,1),r,void 0,i===null);let s=e.mapping.slice(a),c=s.map(n,1),l=s.map(n+t.nodeSize,1);return e.step(new ds(c,l,c+1,l-1,new L(F.from(r.create(o,null,t.marks)),0,0),1,!0)),i===!0&&Ts(e,t,n,a),!1}})}function Ts(e,t,n,r){t.forEach((i,a)=>{if(i.isText){let o,s=/\r?\n|\r/g;for(;o=s.exec(i.text);){let i=e.mapping.slice(r).map(n+1+a+o.index);e.replaceWith(i,i+1,t.type.schema.linebreakReplacement.create())}}})}function Es(e,t,n,r){t.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let i=e.mapping.slice(r).map(n+1+a);e.replaceWith(i,i+1,t.type.schema.text(`
38
+ `))}})}function Ds(e,t,n){let r=e.resolve(t),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function Os(e,t,n,r,i){let a=e.doc.nodeAt(t);if(!a)throw RangeError(`No node at given position`);n||=a.type;let o=n.create(r,null,i||a.marks);if(a.isLeaf)return e.replaceWith(t,t+a.nodeSize,o);if(!n.validContent(a.content))throw RangeError(`Invalid content for node type `+n.name);e.step(new ds(t,t+a.nodeSize,t+1,t+a.nodeSize-1,new L(F.from(o),0,0),1,!0))}function ks(e,t,n=1,r){let i=e.resolve(t),a=i.depth-n,o=r&&r[r.length-1]||i.parent;if(a<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let e=i.depth-1,t=n-2;e>a;e--,t--){let n=i.node(e),a=i.index(e);if(n.type.spec.isolating)return!1;let o=n.content.cutByIndex(a,n.childCount),s=r&&r[t+1];s&&(o=o.replaceChild(0,s.type.create(s.attrs)));let c=r&&r[t]||n;if(!n.canReplace(a+1,n.childCount)||!c.type.validContent(o))return!1}let s=i.indexAfter(a),c=r&&r[0];return i.node(a).canReplaceWith(s,s,c?c.type:i.node(a+1).type)}function As(e,t,n=1,r){let i=e.doc.resolve(t),a=F.empty,o=F.empty;for(let e=i.depth,t=i.depth-n,s=n-1;e>t;e--,s--){a=F.from(i.node(e).copy(a));let t=r&&r[s];o=F.from(t?t.type.create(t.attrs,o):i.node(e).copy(o))}e.step(new us(t,t,new L(a.append(o),n,n),!0))}function js(e,t){let n=e.resolve(t),r=n.index();return Ns(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function Ms(e,t){t.content.size||e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:r}=e.type.schema;for(let i=0;i<t.childCount;i++){let a=t.child(i),o=a.type==r?e.type.schema.nodes.text:a.type;if(n=n.matchType(o),!n||!e.type.allowsMarks(a.marks))return!1}return n.validEnd}function Ns(e,t){return!!(e&&t&&!e.isLeaf&&Ms(e,t))}function Ps(e,t,n){let r=null,{linebreakReplacement:i}=e.doc.type.schema,a=e.doc.resolve(t-n),o=a.node().type;if(i&&o.inlineContent){let e=o.whitespace==`pre`,t=!!o.contentMatch.matchType(i);e&&!t?r=!1:!e&&t&&(r=!0)}let s=e.steps.length;if(r===!1){let r=e.doc.resolve(t+n);Es(e,r.node(),r.before(),s)}o.inlineContent&&hs(e,t+n-1,o,a.node().contentMatchAt(a.index()),r==null);let c=e.mapping.slice(s),l=c.map(t-n);if(e.step(new us(l,c.map(t+n,-1),L.empty,!0)),r===!0){let t=e.doc.resolve(l);Ts(e,t.node(),t.before(),e.steps.length)}return e}function Fs(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(r.parentOffset==0)for(let e=r.depth-1;e>=0;e--){let t=r.index(e);if(r.node(e).canReplaceWith(t,t,n))return r.before(e+1);if(t>0)return null}if(r.parentOffset==r.parent.content.size)for(let e=r.depth-1;e>=0;e--){let t=r.indexAfter(e);if(r.node(e).canReplaceWith(t,t,n))return r.after(e+1);if(t<r.node(e).childCount)return null}return null}function Is(e,t,n){let r=e.resolve(t);if(!n.content.size)return t;let i=n.content;for(let e=0;e<n.openStart;e++)i=i.firstChild.content;for(let e=1;e<=(n.openStart==0&&n.size?2:1);e++)for(let t=r.depth;t>=0;t--){let n=t==r.depth?0:r.pos<=(r.start(t+1)+r.end(t+1))/2?-1:1,a=r.index(t)+(n>0?1:0),o=r.node(t),s=!1;if(e==1)s=o.canReplace(a,a,i);else{let e=o.contentMatchAt(a).findWrapping(i.firstChild.type);s=e&&o.canReplaceWith(a,a,e[0])}if(s)return n==0?r.pos:n<0?r.before(t+1):r.after(t+1)}return null}function Ls(e,t,n=t,r=L.empty){if(t==n&&!r.size)return null;let i=e.resolve(t),a=e.resolve(n);return Rs(i,a,r)?new us(t,n,r):new zs(i,a,r).fit()}function Rs(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}var zs=class{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=F.empty;for(let t=0;t<=e.depth;t++){let n=e.node(t);this.frontier.push({type:n.type,match:n.contentMatchAt(e.indexAfter(t))})}for(let t=e.depth;t>0;t--)this.placed=F.from(e.node(t).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,r=this.close(e<0?this.$to:n.doc.resolve(e));if(!r)return null;let i=this.placed,a=n.depth,o=r.depth;for(;a&&o&&i.childCount==1;)i=i.firstChild.content,a--,o--;let s=new L(i,a,o);return e>-1?new ds(n.pos,e,this.$to.pos,this.$to.end(),s,t):s.size||n.pos!=this.$to.pos?new us(n.pos,r.pos,s):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,r=this.unplaced.openEnd;n<e;n++){let i=t.firstChild;if(t.childCount>1&&(r=0),i.type.spec.isolating&&r<=n){e=n;break}t=i.content}for(let t=1;t<=2;t++)for(let n=t==1?e:this.unplaced.openStart;n>=0;n--){let e,r=null;n?(r=Hs(this.unplaced.content,n-1).firstChild,e=r.content):e=this.unplaced.content;let i=e.firstChild;for(let e=this.depth;e>=0;e--){let{type:a,match:o}=this.frontier[e],s,c=null;if(t==1&&(i?o.matchType(i.type)||(c=o.fillBefore(F.from(i),!1)):r&&a.compatibleContent(r.type)))return{sliceDepth:n,frontierDepth:e,parent:r,inject:c};if(t==2&&i&&(s=o.findWrapping(i.type)))return{sliceDepth:n,frontierDepth:e,parent:r,wrap:s};if(r&&o.matchType(r.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=Hs(e,t);return!r.childCount||r.firstChild.isLeaf?!1:(this.unplaced=new L(e,t+1,Math.max(n,r.size+t>=e.size-n?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=Hs(e,t);if(r.childCount<=1&&t>0){let i=e.size-t<=t+r.size;this.unplaced=new L(Bs(e,t-1,1),t-1,i?t-1:n)}else this.unplaced=new L(Bs(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:r,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let e=0;e<i.length;e++)this.openFrontierNode(i[e]);let a=this.unplaced,o=n?n.content:a.content,s=a.openStart-e,c=0,l=[],{match:u,type:d}=this.frontier[t];if(r){for(let e=0;e<r.childCount;e++)l.push(r.child(e));u=u.matchFragment(r)}let f=o.size+e-(a.content.size-a.openEnd);for(;c<o.childCount;){let e=o.child(c),t=u.matchType(e.type);if(!t)break;c++,(c>1||s==0||e.content.size)&&(u=t,l.push(Us(e.mark(d.allowedMarks(e.marks)),c==1?s:0,c==o.childCount?f:-1)))}let p=c==o.childCount;p||(f=-1),this.placed=Vs(this.placed,t,F.from(l)),this.frontier[t].match=u,p&&f<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=o;e<f;e++){let e=t.lastChild;this.frontier.push({type:e.type,match:e.contentMatchAt(e.childCount)}),t=e.content}this.unplaced=p?e==0?L.empty:new L(Bs(a.content,e-1,1),e-1,f<0?a.openEnd:e-1):new L(Bs(a.content,e,c),a.openStart,a.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!Ws(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:n}=this.$to,r=this.$to.after(n);for(;n>1&&r==this.$to.end(--n);)++r;return r}findCloseLevel(e){scan:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:r}=this.frontier[t],i=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),a=Ws(e,t,r,n,i);if(a){for(let n=t-1;n>=0;n--){let{match:t,type:r}=this.frontier[n],i=Ws(e,n,r,t,!0);if(!i||i.childCount)continue scan}return{depth:t,fit:a,move:i?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Vs(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),r=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,r)}return e}openFrontierNode(e,t=null,n){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=Vs(this.placed,this.depth,F.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(F.empty,!0);e.childCount&&(this.placed=Vs(this.placed,this.frontier.length,e))}};function Bs(e,t,n){return t==0?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(Bs(e.firstChild.content,t-1,n)))}function Vs(e,t,n){return t==0?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(Vs(e.lastChild.content,t-1,n)))}function Hs(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function Us(e,t,n){if(t<=0)return e;let r=e.content;return t>1&&(r=r.replaceChild(0,Us(r.firstChild,t-1,r.childCount==1?n-1:0))),t>0&&(r=e.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(e.type.contentMatch.matchFragment(r).fillBefore(F.empty,!0)))),e.copy(r)}function Ws(e,t,n,r,i){let a=e.node(t),o=i?e.indexAfter(t):e.index(t);if(o==a.childCount&&!n.compatibleContent(a.type))return null;let s=r.fillBefore(a.content,!0,o);return s&&!Gs(n,a.content,o)?s:null}function Gs(e,t,n){for(let r=n;r<t.childCount;r++)if(!e.allowsMarks(t.child(r).marks))return!0;return!1}function Ks(e){return e.spec.defining||e.spec.definingForContent}function qs(e,t,n,r){if(!r.size)return e.deleteRange(t,n);let i=e.doc.resolve(t),a=e.doc.resolve(n);if(Rs(i,a,r))return e.step(new us(t,n,r));let o=Zs(i,a);o[o.length-1]==0&&o.pop();let s=-(i.depth+1);o.unshift(s);for(let e=i.depth,t=i.pos-1;e>0;e--,t--){let n=i.node(e).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;o.indexOf(e)>-1?s=e:i.before(e)==t&&o.splice(1,0,-e)}let c=o.indexOf(s),l=[],u=r.openStart;for(let e=r.content,t=0;;t++){let n=e.firstChild;if(l.push(n),t==r.openStart)break;e=n.content}for(let e=u-1;e>=0;e--){let t=l[e],n=Ks(t.type);if(n&&!t.sameMarkup(i.node(Math.abs(s)-1)))u=e;else if(n||!t.type.isTextblock)break}for(let t=r.openStart;t>=0;t--){let s=(t+u+1)%(r.openStart+1),d=l[s];if(d)for(let t=0;t<o.length;t++){let l=o[(t+c)%o.length],u=!0;l<0&&(u=!1,l=-l);let f=i.node(l-1),p=i.index(l-1);if(f.canReplaceWith(p,p,d.type,d.marks))return e.replace(i.before(l),u?a.after(l):n,new L(Js(r.content,0,r.openStart,s),s,r.openEnd))}}let d=e.steps.length;for(let s=o.length-1;s>=0&&(e.replace(t,n,r),!(e.steps.length>d));s--){let e=o[s];e<0||(t=i.before(e),n=a.after(e))}}function Js(e,t,n,r,i){if(t<n){let i=e.firstChild;e=e.replaceChild(0,i.copy(Js(i.content,t+1,n,r,i)))}if(t>r){let t=i.contentMatchAt(0),n=t.fillBefore(e).append(e);e=n.append(t.matchFragment(n).fillBefore(F.empty,!0))}return e}function Ys(e,t,n,r){if(!r.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let i=Fs(e.doc,t,r.type);i!=null&&(t=n=i)}e.replaceRange(t,n,new L(F.from(r),0,0))}function Xs(e,t,n){let r=e.doc.resolve(t),i=e.doc.resolve(n);if(r.parent.isTextblock&&i.parent.isTextblock&&r.start()!=i.start()&&r.parentOffset==0&&i.parentOffset==0){let a=r.sharedDepth(n),o=!1;for(let e=r.depth;e>a;e--)r.node(e).type.spec.isolating&&(o=!0);for(let e=i.depth;e>a;e--)i.node(e).type.spec.isolating&&(o=!0);if(!o){for(let e=r.depth;e>0&&t==r.start(e);e--)t=r.before(e);for(let e=i.depth;e>0&&n==i.start(e);e--)n=i.before(e);r=e.doc.resolve(t),i=e.doc.resolve(n)}}let a=Zs(r,i);for(let t=0;t<a.length;t++){let n=a[t],o=t==a.length-1;if(o&&n==0||r.node(n).type.contentMatch.validEnd)return e.delete(r.start(n),i.end(n));if(n>0&&(o||r.node(n-1).canReplace(r.index(n-1),i.indexAfter(n-1))))return e.delete(r.before(n),i.after(n))}for(let a=1;a<=r.depth&&a<=i.depth;a++)if(t-r.start(a)==r.depth-a&&n>r.end(a)&&i.end(a)-n!=i.depth-a&&r.start(a-1)==i.start(a-1)&&r.node(a-1).canReplace(r.index(a-1),i.index(a-1)))return e.delete(r.before(a),n);e.delete(t,n)}function Zs(e,t){let n=[],r=Math.min(e.depth,t.depth);for(let i=r;i>=0;i--){let r=e.start(i);if(r<e.pos-(e.depth-i)||t.end(i)>t.pos+(t.depth-i)||e.node(i).type.spec.isolating||t.node(i).type.spec.isolating)break;(r==t.start(i)||i==e.depth&&i==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&i&&t.start(i-1)==r-1)&&n.push(i)}return n}var Qs=class e extends R{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return z.fail(`No node at attribute step's position`);let n=Object.create(null);for(let e in t.attrs)n[e]=t.attrs[e];n[this.attr]=this.value;let r=t.type.create(n,null,t.marks);return z.fromReplace(e,this.pos,this.pos+1,new L(F.from(r),0,t.isLeaf?0:1))}getMap(){return ts.empty}invert(t){return new e(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.attr,this.value)}toJSON(){return{stepType:`attr`,pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.pos!=`number`||typeof n.attr!=`string`)throw RangeError(`Invalid input for AttrStep.fromJSON`);return new e(n.pos,n.attr,n.value)}};R.jsonID(`attr`,Qs);var $s=class e extends R{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let n in e.attrs)t[n]=e.attrs[n];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return z.ok(n)}getMap(){return ts.empty}invert(t){return new e(this.attr,t.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:`docAttr`,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.attr!=`string`)throw RangeError(`Invalid input for DocAttrStep.fromJSON`);return new e(n.attr,n.value)}};R.jsonID(`docAttr`,$s);var ec=class extends Error{};ec=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},ec.prototype=Object.create(Error.prototype),ec.prototype.constructor=ec,ec.prototype.name=`TransformError`;var tc=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new ns}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new ec(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let n=0;n<this.mapping.maps.length;n++){let r=this.mapping.maps[n];n&&(e=r.map(e,1),t=r.map(t,-1)),r.forEach((n,r,i,a)=>{e=Math.min(e,i),t=Math.max(t,a)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=L.empty){let r=Ls(this.doc,e,t,n);return r&&this.step(r),this}replaceWith(e,t,n){return this.replace(e,t,new L(F.from(n),0,0))}delete(e,t){return this.replace(e,t,L.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return qs(this,e,t,n),this}replaceRangeWith(e,t,n){return Ys(this,e,t,n),this}deleteRange(e,t){return Xs(this,e,t),this}lift(e,t){return vs(this,e,t),this}join(e,t=1){return Ps(this,e,t),this}wrap(e,t){return Cs(this,e,t),this}setBlockType(e,t=e,n,r=null){return ws(this,e,t,n,r),this}setNodeMarkup(e,t,n=null,r){return Os(this,e,t,n,r),this}setNodeAttribute(e,t,n){return this.step(new Qs(e,t,n)),this}setDocAttribute(e,t){return this.step(new $s(e,t)),this}addNodeMark(e,t){return this.step(new cs(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw RangeError(`No node at position `+e);if(t instanceof I)t.isInSet(n.marks)&&this.step(new ls(e,t));else{let r=n.marks,i,a=[];for(;i=t.isInSet(r);)a.push(new ls(e,i)),r=i.removeFromSet(r);for(let e=a.length-1;e>=0;e--)this.step(a[e])}return this}split(e,t=1,n){return As(this,e,t,n),this}addMark(e,t,n){return ps(this,e,t,n),this}removeMark(e,t,n){return ms(this,e,t,n),this}clearIncompatible(e,t,n){return hs(this,e,t,n),this}},nc=Object.create(null),B=class{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new rc(e.min(t),e.max(t))]}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 t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=L.empty){let n=t.content.lastChild,r=null;for(let e=0;e<t.openEnd;e++)r=n,n=n.lastChild;let i=e.steps.length,a=this.ranges;for(let o=0;o<a.length;o++){let{$from:s,$to:c}=a[o],l=e.mapping.slice(i);e.replaceRange(l.map(s.pos),l.map(c.pos),o?L.empty:t),o==0&&dc(e,i,(n?n.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,r=this.ranges;for(let i=0;i<r.length;i++){let{$from:a,$to:o}=r[i],s=e.mapping.slice(n),c=s.map(a.pos),l=s.map(o.pos);i?e.deleteRange(c,l):(e.replaceRangeWith(c,l,t),dc(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let r=e.parent.inlineContent?new V(e):uc(e.node(0),e.parent,e.pos,e.index(),t,n);if(r)return r;for(let r=e.depth-1;r>=0;r--){let i=t<0?uc(e.node(0),e.node(r),e.before(r+1),e.index(r),t,n):uc(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,n);if(i)return i}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new cc(e.node(0))}static atStart(e){return uc(e,e,0,0,1)||new cc(e)}static atEnd(e){return uc(e,e,e.content.size,e.childCount,-1)||new cc(e)}static fromJSON(e,t){if(!t||!t.type)throw RangeError(`Invalid input for Selection.fromJSON`);let n=nc[t.type];if(!n)throw RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in nc)throw RangeError(`Duplicate use of selection JSON ID `+e);return nc[e]=t,t.prototype.jsonID=e,t}getBookmark(){return V.between(this.$anchor,this.$head).getBookmark()}};B.prototype.visible=!0;var rc=class{constructor(e,t){this.$from=e,this.$to=t}},ic=!1;function ac(e){!ic&&!e.parent.inlineContent&&(ic=!0,console.warn(`TextSelection endpoint not pointing into a node with inline content (`+e.parent.type.name+`)`))}var V=class e extends B{constructor(e,t=e){ac(e),ac(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,n){let r=t.resolve(n.map(this.head));if(!r.parent.inlineContent)return B.near(r);let i=t.resolve(n.map(this.anchor));return new e(i.parent.inlineContent?i:r,r)}replace(e,t=L.empty){if(super.replace(e,t),t==L.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(t){return t instanceof e&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new oc(this.anchor,this.head)}toJSON(){return{type:`text`,anchor:this.anchor,head:this.head}}static fromJSON(t,n){if(typeof n.anchor!=`number`||typeof n.head!=`number`)throw RangeError(`Invalid input for TextSelection.fromJSON`);return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(e,t,n=t){let r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))}static between(t,n,r){let i=t.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let e=B.findFrom(n,r,!0)||B.findFrom(n,-r,!0);if(e)n=e.$head;else return B.near(n,r)}return t.parent.inlineContent||(i==0?t=n:(t=(B.findFrom(t,-r,!0)||B.findFrom(t,r,!0)).$anchor,t.pos<n.pos!=i<0&&(t=n))),new e(t,n)}};B.jsonID(`text`,V);var oc=class e{constructor(e,t){this.anchor=e,this.head=t}map(t){return new e(t.map(this.anchor),t.map(this.head))}resolve(e){return V.between(e.resolve(this.anchor),e.resolve(this.head))}},H=class e extends B{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(t,n){let{deleted:r,pos:i}=n.mapResult(this.anchor),a=t.resolve(i);return r?B.near(a):new e(a)}content(){return new L(F.from(this.node),0,0)}eq(t){return t instanceof e&&t.anchor==this.anchor}toJSON(){return{type:`node`,anchor:this.anchor}}getBookmark(){return new sc(this.anchor)}static fromJSON(t,n){if(typeof n.anchor!=`number`)throw RangeError(`Invalid input for NodeSelection.fromJSON`);return new e(t.resolve(n.anchor))}static create(t,n){return new e(t.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}};H.prototype.visible=!1,B.jsonID(`node`,H);var sc=class e{constructor(e){this.anchor=e}map(t){let{deleted:n,pos:r}=t.mapResult(this.anchor);return n?new oc(r,r):new e(r)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&H.isSelectable(n)?new H(t):B.near(t)}},cc=class e extends B{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=L.empty){if(t==L.empty){e.delete(0,e.doc.content.size);let t=B.atStart(e.doc);t.eq(e.selection)||e.setSelection(t)}else super.replace(e,t)}toJSON(){return{type:`all`}}static fromJSON(t){return new e(t)}map(t){return new e(t)}eq(t){return t instanceof e}getBookmark(){return lc}};B.jsonID(`all`,cc);var lc={map(){return this},resolve(e){return new cc(e)}};function uc(e,t,n,r,i,a=!1){if(t.inlineContent)return V.create(e,n);for(let o=r-(i>0?0:1);i>0?o<t.childCount:o>=0;o+=i){let r=t.child(o);if(!r.isAtom){let t=uc(e,r,n+i,i<0?r.childCount:0,i,a);if(t)return t}else if(!a&&H.isSelectable(r))return H.create(e,n-(i<0?r.nodeSize:0));n+=r.nodeSize*i}return null}function dc(e,t,n){let r=e.steps.length-1;if(r<t)return;let i=e.steps[r];if(!(i instanceof us||i instanceof ds))return;let a=e.mapping.maps[r],o;a.forEach((e,t,n,r)=>{o??=r}),e.setSelection(B.near(e.doc.resolve(o),n))}var fc=1,pc=2,mc=4,hc=class extends tc{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.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw RangeError(`Selection passed to setSelection must point at the current document`);return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|fc)&~pc,this.storedMarks=null,this}get selectionSet(){return(this.updated&fc)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=pc,this}ensureMarks(e){return I.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&pc)>0}addStep(e,t){super.addStep(e,t),this.updated&=~pc,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||I.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let r=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(n??=t,!e)return this.deleteRange(t,n);let i=this.storedMarks;if(!i){let e=this.doc.resolve(t);i=n==t?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,i)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(B.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e==`string`?e:e.key]=t,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|=mc,this}get scrolledIntoView(){return(this.updated&mc)>0}};function gc(e,t){return!t||!e?e:e.bind(t)}var _c=class{constructor(e,t,n){this.name=e,this.init=gc(t.init,n),this.apply=gc(t.apply,n)}},vc=[new _c(`doc`,{init(e){return e.doc||e.schema.topNodeType.createAndFill()},apply(e){return e.doc}}),new _c(`selection`,{init(e,t){return e.selection||B.atStart(t.doc)},apply(e){return e.selection}}),new _c(`storedMarks`,{init(e){return e.storedMarks||null},apply(e,t,n,r){return r.selection.$cursor?e.storedMarks:null}}),new _c(`scrollToSelection`,{init(){return 0},apply(e,t){return e.scrolledIntoView?t+1:t}})],yc=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=vc.slice(),t&&t.forEach(e=>{if(this.pluginsByKey[e.key])throw RangeError(`Adding different instances of a keyed plugin (`+e.key+`)`);this.plugins.push(e),this.pluginsByKey[e.key]=e,e.spec.state&&this.fields.push(new _c(e.key,e.spec.state,e))})}},bc=class e{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,t=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=t){let t=this.config.plugins[n];if(t.spec.filterTransaction&&!t.spec.filterTransaction.call(t,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),r=null;for(;;){let i=!1;for(let a=0;a<this.config.plugins.length;a++){let o=this.config.plugins[a];if(o.spec.appendTransaction){let s=r?r[a].n:0,c=r?r[a].state:this,l=s<t.length&&o.spec.appendTransaction.call(o,s?t.slice(s):t,c,n);if(l&&n.filterTransaction(l,a)){if(l.setMeta(`appendedTransaction`,e),!r){r=[];for(let e=0;e<this.config.plugins.length;e++)r.push(e<a?{state:n,n:t.length}:{state:this,n:0})}t.push(l),n=n.applyInner(l),i=!0}r&&(r[a]={state:n,n:t.length})}}if(!i)return{state:n,transactions:t}}}applyInner(t){if(!t.before.eq(this.doc))throw RangeError(`Applying a mismatched transaction`);let n=new e(this.config),r=this.config.fields;for(let e=0;e<r.length;e++){let i=r[e];n[i.name]=i.apply(t,this[i.name],this,n)}return n}get tr(){return new hc(this)}static create(t){let n=new yc(t.doc?t.doc.type.schema:t.schema,t.plugins),r=new e(n);for(let e=0;e<n.fields.length;e++)r[n.fields[e].name]=n.fields[e].init(t,r);return r}reconfigure(t){let n=new yc(this.schema,t.plugins),r=n.fields,i=new e(n);for(let e=0;e<r.length;e++){let n=r[e].name;i[n]=this.hasOwnProperty(n)?this[n]:r[e].init(t,i)}return i}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(e=>e.toJSON())),e&&typeof e==`object`)for(let n in e){if(n==`doc`||n==`selection`)throw RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[n],i=r.spec.state;i&&i.toJSON&&(t[n]=i.toJSON.call(r,this[r.key]))}return t}static fromJSON(t,n,r){if(!n)throw RangeError(`Invalid input for EditorState.fromJSON`);if(!t.schema)throw RangeError(`Required config field 'schema' missing`);let i=new yc(t.schema,t.plugins),a=new e(i);return i.fields.forEach(e=>{if(e.name==`doc`)a.doc=Ja.fromJSON(t.schema,n.doc);else if(e.name==`selection`)a.selection=B.fromJSON(a.doc,n.selection);else if(e.name==`storedMarks`)n.storedMarks&&(a.storedMarks=n.storedMarks.map(t.schema.markFromJSON));else{if(r)for(let i in r){let o=r[i],s=o.spec.state;if(o.key==e.name&&s&&s.fromJSON&&Object.prototype.hasOwnProperty.call(n,i)){a[e.name]=s.fromJSON.call(o,t,n[i],a);return}}a[e.name]=e.init(t,a)}}),a}};function xc(e,t,n){for(let r in e){let i=e[r];i instanceof Function?i=i.bind(t):r==`handleDOMEvents`&&(i=xc(i,t,{})),n[r]=i}return n}var Sc=class{constructor(e){this.spec=e,this.props={},e.props&&xc(e.props,this,this.props),this.key=e.key?e.key.key:wc(`plugin`)}getState(e){return e[this.key]}},Cc=Object.create(null);function wc(e){return e in Cc?e+`$`+ ++Cc[e]:(Cc[e]=0,e+`$`)}var Tc=class{constructor(e=`key`){this.key=wc(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}},Ec=(e,t)=>e.selection.empty?!1:(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function Dc(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`backward`,e):n.parentOffset>0)?null:n}var Oc=(e,t,n)=>{let r=Dc(e,n);if(!r)return!1;let i=Nc(r);if(!i){let n=r.blockRange(),i=n&&_s(n);return i==null?!1:(t&&t(e.tr.lift(n,i).scrollIntoView()),!0)}let a=i.nodeBefore;if(qc(e,i,t,-1))return!0;if(r.parent.content.size==0&&(jc(a,`end`)||H.isSelectable(a)))for(let n=r.depth;;n--){let o=Ls(e.doc,r.before(n),r.after(n),L.empty);if(o&&o.slice.size<o.to-o.from){if(t){let n=e.tr.step(o);n.setSelection(jc(a,`end`)?B.findFrom(n.doc.resolve(n.mapping.map(i.pos,-1)),-1):H.create(n.doc,i.pos-a.nodeSize)),t(n.scrollIntoView())}return!0}if(n==1||r.node(n-1).childCount>1)break}return a.isAtom&&i.depth==r.depth-1?(t&&t(e.tr.delete(i.pos-a.nodeSize,i.pos).scrollIntoView()),!0):!1},kc=(e,t,n)=>{let r=Dc(e,n);if(!r)return!1;let i=Nc(r);return i?Ac(e,i,t):!1};function Ac(e,t,n){let r=t.nodeBefore,i=t.pos-1;for(;!r.isTextblock;i--){if(r.type.spec.isolating)return!1;let e=r.lastChild;if(!e)return!1;r=e}let a=t.nodeAfter,o=t.pos+1;for(;!a.isTextblock;o++){if(a.type.spec.isolating)return!1;let e=a.firstChild;if(!e)return!1;a=e}let s=Ls(e.doc,i,o,L.empty);if(!s||s.from!=i||s instanceof us&&s.slice.size>=o-i)return!1;if(n){let t=e.tr.step(s);t.setSelection(V.create(t.doc,i)),n(t.scrollIntoView())}return!0}function jc(e,t,n=!1){for(let r=e;r;r=t==`start`?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}var Mc=(e,t,n)=>{let{$head:r,empty:i}=e.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock(`backward`,e):r.parentOffset>0)return!1;a=Nc(r)}let o=a&&a.nodeBefore;return!o||!H.isSelectable(o)?!1:(t&&t(e.tr.setSelection(H.create(e.doc,a.pos-o.nodeSize)).scrollIntoView()),!0)};function Nc(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function Pc(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`forward`,e):n.parentOffset<n.parent.content.size)?null:n}var Fc=(e,t,n)=>{let r=Pc(e,n);if(!r)return!1;let i=Lc(r);if(!i)return!1;let a=i.nodeAfter;if(qc(e,i,t,1))return!0;if(r.parent.content.size==0&&(jc(a,`start`)||H.isSelectable(a))){let n=Ls(e.doc,r.before(),r.after(),L.empty);if(n&&n.slice.size<n.to-n.from){if(t){let r=e.tr.step(n);r.setSelection(jc(a,`start`)?B.findFrom(r.doc.resolve(r.mapping.map(i.pos)),1):H.create(r.doc,r.mapping.map(i.pos))),t(r.scrollIntoView())}return!0}}return a.isAtom&&i.depth==r.depth-1?(t&&t(e.tr.delete(i.pos,i.pos+a.nodeSize).scrollIntoView()),!0):!1},Ic=(e,t,n)=>{let{$head:r,empty:i}=e.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock(`forward`,e):r.parentOffset<r.parent.content.size)return!1;a=Lc(r)}let o=a&&a.nodeAfter;return!o||!H.isSelectable(o)?!1:(t&&t(e.tr.setSelection(H.create(e.doc,a.pos)).scrollIntoView()),!0)};function Lc(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){let n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}var Rc=(e,t)=>{let{$head:n,$anchor:r}=e.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(t&&t(e.tr.insertText(`
39
+ `).scrollIntoView()),!0)};function zc(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}var Bc=(e,t)=>{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),a=n.indexAfter(-1),o=zc(i.contentMatchAt(a));if(!o||!i.canReplaceWith(a,a,o))return!1;if(t){let r=n.after(),i=e.tr.replaceWith(r,r,o.createAndFill());i.setSelection(B.near(i.doc.resolve(r),1)),t(i.scrollIntoView())}return!0},Vc=(e,t)=>{let n=e.selection,{$from:r,$to:i}=n;if(n instanceof cc||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=zc(i.parent.contentMatchAt(i.indexAfter()));if(!a||!a.isTextblock)return!1;if(t){let n=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,o=e.tr.insert(n,a.createAndFill());o.setSelection(V.create(o.doc,n+1)),t(o.scrollIntoView())}return!0},Hc=(e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let r=n.before();if(ks(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),i=r&&_s(r);return i==null?!1:(t&&t(e.tr.lift(r,i).scrollIntoView()),!0)};function Uc(e){return(t,n)=>{let{$from:r,$to:i}=t.selection;if(t.selection instanceof H&&t.selection.node.isBlock)return!r.parentOffset||!ks(t.doc,r.pos)?!1:(n&&n(t.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let a=[],o,s,c=!1,l=!1;for(let t=r.depth;;t--)if(r.node(t).isBlock){c=r.end(t)==r.pos+(r.depth-t),l=r.start(t)==r.pos-(r.depth-t),s=zc(r.node(t-1).contentMatchAt(r.indexAfter(t-1)));let n=e&&e(i.parent,c,r);a.unshift(n||(c&&s?{type:s}:null)),o=t;break}else{if(t==1)return!1;a.unshift(null)}let u=t.tr;(t.selection instanceof V||t.selection instanceof cc)&&u.deleteSelection();let d=u.mapping.map(r.pos),f=ks(u.doc,d,a.length,a);if(f||=(a[0]=s?{type:s}:null,ks(u.doc,d,a.length,a)),!f)return!1;if(u.split(d,a.length,a),!c&&l&&r.node(o).type!=s){let e=u.mapping.map(r.before(o)),t=u.doc.resolve(e);s&&r.node(o-1).canReplaceWith(t.index(),t.index()+1,s)&&u.setNodeMarkup(u.mapping.map(r.before(o)),s)}return n&&n(u.scrollIntoView()),!0}}var Wc=Uc(),Gc=(e,t)=>(t&&t(e.tr.setSelection(new cc(e.doc))),!0);function Kc(e,t,n){let r=t.nodeBefore,i=t.nodeAfter,a=t.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&t.parent.canReplace(a-1,a)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),!0):!t.parent.canReplace(a,a+1)||!(i.isTextblock||js(e.doc,t.pos))?!1:(n&&n(e.tr.join(t.pos).scrollIntoView()),!0)}function qc(e,t,n,r){let i=t.nodeBefore,a=t.nodeAfter,o,s,c=i.type.spec.isolating||a.type.spec.isolating;if(!c&&Kc(e,t,n))return!0;let l=!c&&t.parent.canReplace(t.index(),t.index()+1);if(l&&(o=(s=i.contentMatchAt(i.childCount)).findWrapping(a.type))&&s.matchType(o[0]||a.type).validEnd){if(n){let r=t.pos+a.nodeSize,s=F.empty;for(let e=o.length-1;e>=0;e--)s=F.from(o[e].create(null,s));s=F.from(i.copy(s));let c=e.tr.step(new ds(t.pos-1,r,t.pos,r,new L(s,1,0),o.length,!0)),l=c.doc.resolve(r+2*o.length);l.nodeAfter&&l.nodeAfter.type==i.type&&js(c.doc,l.pos)&&c.join(l.pos),n(c.scrollIntoView())}return!0}let u=a.type.spec.isolating||r>0&&c?null:B.findFrom(t,1),d=u&&u.$from.blockRange(u.$to),f=d&&_s(d);if(f!=null&&f>=t.depth)return n&&n(e.tr.lift(d,f).scrollIntoView()),!0;if(l&&jc(a,`start`,!0)&&jc(i,`end`)){let r=i,o=[];for(;o.push(r),!r.isTextblock;)r=r.lastChild;let s=a,c=1;for(;!s.isTextblock;s=s.firstChild)c++;if(r.canReplace(r.childCount,r.childCount,s.content)){if(n){let r=F.empty;for(let e=o.length-1;e>=0;e--)r=F.from(o[e].copy(r));n(e.tr.step(new ds(t.pos-o.length,t.pos+a.nodeSize,t.pos+c,t.pos+a.nodeSize-c,new L(r,o.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function Jc(e){return function(t,n){let r=t.selection,i=e<0?r.$from:r.$to,a=i.depth;for(;i.node(a).isInline;){if(!a)return!1;a--}return i.node(a).isTextblock?(n&&n(t.tr.setSelection(V.create(t.doc,e<0?i.start(a):i.end(a)))),!0):!1}}var Yc=Jc(-1),Xc=Jc(1);function Zc(e,t=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a),s=o&&ys(o,e,t);return s?(r&&r(n.tr.wrap(o,s).scrollIntoView()),!0):!1}}function Qc(e,t=null){return function(n,r){let i=!1;for(let r=0;r<n.selection.ranges.length&&!i;r++){let{$from:{pos:a},$to:{pos:o}}=n.selection.ranges[r];n.doc.nodesBetween(a,o,(r,a)=>{if(i)return!1;if(!(!r.isTextblock||r.hasMarkup(e,t)))if(r.type==e)i=!0;else{let t=n.doc.resolve(a),r=t.index();i=t.parent.canReplaceWith(r,r+1,e)}})}if(!i)return!1;if(r){let i=n.tr;for(let r=0;r<n.selection.ranges.length;r++){let{$from:{pos:a},$to:{pos:o}}=n.selection.ranges[r];i.setBlockType(a,o,e,t)}r(i.scrollIntoView())}return!0}}function $c(e,t,n,r){for(let i=0;i<t.length;i++){let{$from:a,$to:o}=t[i],s=a.depth==0?e.inlineContent&&e.type.allowsMarkType(n):!1;if(e.nodesBetween(a.pos,o.pos,(e,t)=>{if(s||!r&&e.isAtom&&e.isInline&&t>=a.pos&&t+e.nodeSize<=o.pos)return!1;s=e.inlineContent&&e.type.allowsMarkType(n)}),s)return!0}return!1}function el(e){let t=[];for(let n=0;n<e.length;n++){let{$from:r,$to:i}=e[n];r.doc.nodesBetween(r.pos,i.pos,(e,n)=>{if(e.isAtom&&e.content.size&&e.isInline&&n>=r.pos&&n+e.nodeSize<=i.pos)return n+1>r.pos&&t.push(new rc(r,r.doc.resolve(n+1))),r=r.doc.resolve(n+1+e.content.size),!1}),r.pos<i.pos&&t.push(new rc(r,i))}return t}function tl(e,t=null,n){let r=(n&&n.removeWhenPresent)!==!1,i=(n&&n.enterInlineAtoms)!==!1,a=!(n&&n.includeWhitespace);return function(n,o){let{empty:s,$cursor:c,ranges:l}=n.selection;if(s&&!c||!$c(n.doc,l,e,i))return!1;if(o)if(c)e.isInSet(n.storedMarks||c.marks())?o(n.tr.removeStoredMark(e)):o(n.tr.addStoredMark(e.create(t)));else{let s,c=n.tr;i||(l=el(l)),s=r?!l.some(t=>n.doc.rangeHasMark(t.$from.pos,t.$to.pos,e)):!l.every(t=>{let n=!1;return c.doc.nodesBetween(t.$from.pos,t.$to.pos,(r,i,a)=>{if(n)return!1;n=!e.isInSet(r.marks)&&!!a&&a.type.allowsMarkType(e)&&!(r.isText&&/^\s*$/.test(r.textBetween(Math.max(0,t.$from.pos-i),Math.min(r.nodeSize,t.$to.pos-i))))}),!n});for(let n=0;n<l.length;n++){let{$from:r,$to:i}=l[n];if(!s)c.removeMark(r.pos,i.pos,e);else{let n=r.pos,o=i.pos,s=r.nodeAfter,l=i.nodeBefore,u=a&&s&&s.isText?/^\s*/.exec(s.text)[0].length:0,d=a&&l&&l.isText?/\s*$/.exec(l.text)[0].length:0;n+u<o&&(n+=u,o-=d),c.addMark(n,o,e.create(t))}}o(c.scrollIntoView())}return!0}}function nl(...e){return function(t,n,r){for(let i=0;i<e.length;i++)if(e[i](t,n,r))return!0;return!1}}var rl=nl(Ec,Oc,Mc),il=nl(Ec,Fc,Ic),al={Enter:nl(Rc,Vc,Hc,Wc),"Mod-Enter":Bc,Backspace:rl,"Mod-Backspace":rl,"Shift-Backspace":rl,Delete:il,"Mod-Delete":il,"Mod-a":Gc},ol={"Ctrl-h":al.Backspace,"Alt-Backspace":al[`Mod-Backspace`],"Ctrl-d":al.Delete,"Ctrl-Alt-Backspace":al[`Mod-Delete`],"Alt-Delete":al[`Mod-Delete`],"Alt-d":al[`Mod-Delete`],"Ctrl-a":Yc,"Ctrl-e":Xc};for(let e in al)ol[e]=al[e];var sl=(typeof navigator<`u`?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<`u`&&os.platform&&os.platform()==`darwin`)?ol:al,cl=class{constructor(e,t,n={}){this.match=e,this.match=e,this.handler=typeof t==`string`?ll(t):t,this.undoable=n.undoable!==!1,this.inCode=n.inCode||!1,this.inCodeMark=n.inCodeMark!==!1}};function ll(e){return function(t,n,r,i){let a=e;if(n[1]){let e=n[0].lastIndexOf(n[1]);a+=n[0].slice(e+n[1].length),r+=e;let t=r-i;t>0&&(a=n[0].slice(e-t,e)+a,r=i)}return t.tr.insertText(a,r,i)}}var ul=(e,t)=>{let n=e.plugins;for(let r=0;r<n.length;r++){let i=n[r],a;if(i.spec.isInputRules&&(a=i.getState(e))){if(t){let n=e.tr,r=a.transform;for(let e=r.steps.length-1;e>=0;e--)n.step(r.steps[e].invert(r.docs[e]));if(a.text){let t=n.doc.resolve(a.from).marks();n.replaceWith(a.from,a.to,e.schema.text(a.text,t))}else n.delete(a.from,a.to);t(n)}return!0}}return!1};new cl(/--$/,`—`,{inCodeMark:!1}),new cl(/\.\.\.$/,`…`,{inCodeMark:!1}),new cl(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,`“`,{inCodeMark:!1}),new cl(/"$/,`”`,{inCodeMark:!1}),new cl(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,`‘`,{inCodeMark:!1}),new cl(/'$/,`’`,{inCodeMark:!1});function dl(e,t,n=null,r){return new cl(e,(e,i,a,o)=>{let s=n instanceof Function?n(i):n,c=e.tr.delete(a,o),l=c.doc.resolve(a).blockRange(),u=l&&ys(l,t,s);if(!u)return null;c.wrap(l,u);let d=c.doc.resolve(a-1).nodeBefore;return d&&d.type==t&&js(c.doc,a-1)&&(!r||r(i,d))&&c.join(a-1),c})}function fl(e,t,n=null){return new cl(e,(e,r,i,a)=>{let o=e.doc.resolve(i),s=n instanceof Function?n(r):n;return o.node(-1).canReplaceWith(o.index(-1),o.indexAfter(-1),t)?e.tr.delete(i,a).setBlockType(i,i,t,s):null})}var pl=typeof navigator<`u`?navigator:null,ml=typeof document<`u`?document:null,hl=pl&&pl.userAgent||``,gl=/Edge\/(\d+)/.exec(hl),_l=/MSIE \d/.exec(hl),vl=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(hl),yl=!!(_l||vl||gl);_l?document.documentMode:vl?+vl[1]:gl&&+gl[1],!yl&&/gecko\/(\d+)/i.test(hl)&&+(/Firefox\/(\d+)/.exec(hl)||[0,0])[1];var bl=!yl&&/Chrome\/(\d+)/.exec(hl),xl=!!bl;bl&&+bl[1],!yl&&pl&&/Apple Computer/.test(pl.vendor)&&(/Mobile\/\w+/.test(hl)||pl&&pl.maxTouchPoints>2)||pl&&/Mac/.test(pl.platform);var Sl=/Android \d/.test(hl);ml&&`webkitFontSmoothing`in ml.documentElement.style&&+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1];function Cl(e,t,n,r,i,a){if(e.composing)return!1;let o=e.state,s=o.doc.resolve(t);if(s.parent.type.spec.code)return!1;let c=s.parent.textBetween(Math.max(0,s.parentOffset-500),s.parentOffset,void 0,``)+r;for(let s of i){let i=s,l=i.match.exec(c),u=l&&l[0]&&i.handler(o,l,t-(l[0].length-r.length),n);if(u)return i.undoable!==!1&&u.setMeta(a,{transform:u,from:t,to:n,text:r}),e.dispatch(u),!0}return!1}var wl=new Tc(`MILKDOWN_CUSTOM_INPUTRULES`);function Tl({rules:e}){let t=new Sc({key:wl,isInputRules:!0,state:{init(){return null},apply(e,t){return e.getMeta(this)||(e.selectionSet||e.docChanged?null:t)}},props:{handleTextInput(n,r,i,a){return Cl(n,r,i,a,e,t)},handleDOMEvents:{compositionend:n=>(setTimeout(()=>{let{$cursor:r}=n.state.selection;r&&Cl(n,r.pos,r.pos,``,e,t)}),!1),keydown:(e,t)=>!(Sl&&xl&&t.key===`Enter`)||e.composing?!1:e.someProp(`handleKeyDown`,n=>n(e,t))?(t.preventDefault(),!0):!1},handleKeyDown(n,r){if(r.key!==`Enter`)return!1;let{$cursor:i}=n.state.selection;return i?Cl(n,i.pos,i.pos,`
40
+ `,e,t):!1}}});return t}function El(e,t,n={}){return new cl(e,(e,r,i,a)=>{var o;let{tr:s}=e,c=r[r.length-1],l=r[0],u=[],d,f={group:c,fullMatch:l,start:i,end:a},p=n.updateCaptured?.call(n,f);if(Object.assign(f,p),{group:c,fullMatch:l,start:i,end:a}=f,l===null||c?.trim()===``)return null;if(c){let e=l.search(/\S/),f=i+l.indexOf(c),p=f+c.length;u=s.storedMarks??[],p<a&&s.delete(p,a),f>i&&s.delete(i+e,f),d=i+e+c.length;let m=n.getAttr?.call(n,r);s.addMark(i,d,t.create(m)),s.setStoredMarks(u),(o=n.beforeDispatch)==null||o.call(n,{match:r,start:i,end:a,tr:s})}return s})}function Dl(e,t){return Array.isArray(e)&&e.includes(t.type)||t.type===e}function Ol(e,t){if(!(e instanceof H))return;let{node:n,$from:r}=e;if(Dl(t,n))return{node:n,pos:r.pos,start:r.start(r.depth),depth:r.depth}}for(var kl=(e,t)=>{let{selection:n,doc:r}=e;if(n instanceof H)return{hasNode:n.node.type===t,pos:n.from,target:n.node};let{from:i,to:a}=n,o=!1,s=-1,c=null;return r.nodesBetween(i,a,(e,n)=>c?!1:e.type===t?(o=!0,s=n,c=e,!1):!0),{hasNode:o,pos:s,target:c}},Al={8:`Backspace`,9:`Tab`,10:`Enter`,12:`NumLock`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,44:`PrintScreen`,45:`Insert`,46:`Delete`,59:`;`,61:`=`,91:`Meta`,92:`Meta`,106:`*`,107:`+`,108:`,`,109:`-`,110:`.`,111:`/`,144:`NumLock`,145:`ScrollLock`,160:`Shift`,161:`Shift`,162:`Control`,163:`Control`,164:`Alt`,165:`Alt`,173:`-`,186:`;`,187:`=`,188:`,`,189:`-`,190:`.`,191:`/`,192:"`",219:`[`,220:`\\`,221:`]`,222:`'`},jl={48:`)`,49:`!`,50:`@`,51:`#`,52:`$`,53:`%`,54:`^`,55:`&`,56:`*`,57:`(`,59:`:`,61:`+`,173:`_`,186:`:`,187:`+`,188:`<`,189:`_`,190:`>`,191:`?`,192:`~`,219:`{`,220:`|`,221:`}`,222:`"`},Ml=typeof navigator<`u`&&/Mac/.test(navigator.platform),Nl=typeof navigator<`u`&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),U=0;U<10;U++)Al[48+U]=Al[96+U]=String(U);for(var U=1;U<=24;U++)Al[U+111]=`F`+U;for(var U=65;U<=90;U++)Al[U]=String.fromCharCode(U+32),jl[U]=String.fromCharCode(U);for(var Pl in Al)jl.hasOwnProperty(Pl)||(jl[Pl]=Al[Pl]);function Fl(e){var t=!(Ml&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||Nl&&e.shiftKey&&e.key&&e.key.length==1||e.key==`Unidentified`)&&e.key||(e.shiftKey?jl:Al)[e.keyCode]||e.key||`Unidentified`;return t==`Esc`&&(t=`Escape`),t==`Del`&&(t=`Delete`),t==`Left`&&(t=`ArrowLeft`),t==`Up`&&(t=`ArrowUp`),t==`Right`&&(t=`ArrowRight`),t==`Down`&&(t=`ArrowDown`),t}var Il=typeof navigator<`u`&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Ll=typeof navigator<`u`&&/Win/.test(navigator.platform);function Rl(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n==`Space`&&(n=` `);let r,i,a,o;for(let e=0;e<t.length-1;e++){let n=t[e];if(/^(cmd|meta|m)$/i.test(n))o=!0;else if(/^a(lt)?$/i.test(n))r=!0;else if(/^(c|ctrl|control)$/i.test(n))i=!0;else if(/^s(hift)?$/i.test(n))a=!0;else if(/^mod$/i.test(n))Il?o=!0:i=!0;else throw Error(`Unrecognized modifier name: `+n)}return r&&(n=`Alt-`+n),i&&(n=`Ctrl-`+n),o&&(n=`Meta-`+n),a&&(n=`Shift-`+n),n}function zl(e){let t=Object.create(null);for(let n in e)t[Rl(n)]=e[n];return t}function Bl(e,t,n=!0){return t.altKey&&(e=`Alt-`+e),t.ctrlKey&&(e=`Ctrl-`+e),t.metaKey&&(e=`Meta-`+e),n&&t.shiftKey&&(e=`Shift-`+e),e}function Vl(e){return new Sc({props:{handleKeyDown:Hl(e)}})}function Hl(e){let t=zl(e);return function(e,n){let r=Fl(n),i,a=t[Bl(r,n)];if(a&&a(e.state,e.dispatch,e))return!0;if(r.length==1&&r!=` `){if(n.shiftKey){let i=t[Bl(r,n,!1)];if(i&&i(e.state,e.dispatch,e))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(Ll&&n.ctrlKey&&n.altKey)&&(i=Al[n.keyCode])&&i!=r){let r=t[Bl(i,n)];if(r&&r(e.state,e.dispatch,e))return!0}}return!1}}var Ul=class{},Wl=class{constructor(){this.elements=[],this.size=()=>this.elements.length,this.top=()=>this.elements.at(-1),this.push=e=>{this.top()?.push(e)},this.open=e=>{this.elements.push(e)},this.close=()=>{let e=this.elements.pop();if(!e)throw m();return e}}},Gl=class e extends Ul{constructor(e,t,n){super(),this.type=e,this.content=t,this.attrs=n}push(e,...t){this.content.push(e,...t)}pop(){return this.content.pop()}static create(t,n,r){return new e(t,n,r)}},Kl=class extends Wl{#e=I.none;static{this.create=(e,t)=>{let n=new this(e);return e=>(n.run(t,e),n.toDoc())}}constructor(e){super(),this.injectRoot=(e,t,n)=>(this.openNode(t,n),this.next(e.children),this),this.openNode=(e,t)=>(this.open(Gl.create(e,[],t)),this),this.closeNode=()=>{try{this.#a()}catch(e){console.error(e)}return this},this.addNode=(e,t,n)=>{try{this.#o(e,t,n)}catch(e){console.error(e)}return this},this.openMark=(e,t)=>(this.#e=e.create(t).addToSet(this.#e),this),this.closeMark=e=>(this.#e=e.removeFromSet(this.#e),this),this.addText=e=>{try{let t=this.top();if(!t)throw m();let n=t.pop(),r=this.schema.text(e,this.#e);if(!n)return t.push(r),this;let i=this.#n(n,r);return i?(t.push(i),this):(t.push(n,r),this)}catch(e){return console.error(e),this}},this.build=()=>{let e;do e=this.#a();while(this.size());return e},this.next=(e=[])=>([e].flat().forEach(e=>this.#i(e)),this),this.toDoc=()=>this.build(),this.run=(e,t)=>{let n=e.runSync(e.parse(t),t);return this.next(n),this},this.schema=e}#t=e=>e.isText;#n=(e,t)=>{if(this.#t(e)&&this.#t(t)&&I.sameSet(e.marks,t.marks))return this.schema.text(e.text+t.text,e.marks)};#r=e=>{let t=Object.values({...this.schema.nodes,...this.schema.marks}).find(t=>t.spec.parseMarkdown.match(e));if(!t)throw h(e);return t};#i=e=>{let t=this.#r(e);t.spec.parseMarkdown.runner(this,e,t)};#a=()=>{this.#e=I.none;let e=this.close();return this.#o(e.type,e.attrs,e.content)};#o=(e,t,n)=>{let r=e.createAndFill(t,n,this.#e);if(!r)throw p(e,t,n);return this.push(r),r}},ql=class e extends Ul{constructor(e,t,n,r={}){super(),this.type=e,this.children=t,this.value=n,this.props=r,this.push=(e,...t)=>{this.children||=[],this.children.push(e,...t)},this.pop=()=>this.children?.pop()}static{this.create=(t,n,r,i={})=>new e(t,n,r,i)}},Jl=e=>Object.prototype.hasOwnProperty.call(e,`size`),Yl=class extends Wl{#e=I.none;static{this.create=(e,t)=>{let n=new this(e);return e=>(n.run(e),n.toString(t))}}constructor(e){super(),this.openNode=(e,t,n)=>(this.open(ql.create(e,void 0,t,n)),this),this.closeNode=()=>(this.#l(),this),this.addNode=(e,t,n,r)=>(this.#u(e,t,n,r),this),this.withMark=(e,t,n,r)=>(this.#d(e,t,n,r),this),this.closeMark=e=>(this.#f(e),this),this.build=()=>{let e=null;do e=this.#l();while(this.size());return e},this.next=e=>Jl(e)?(e.forEach(e=>{this.#i(e)}),this):(this.#i(e),this),this.toString=e=>e.stringify(this.build()),this.run=e=>(this.next(e),this),this.schema=e}#t=e=>{let t=Object.values({...this.schema.nodes,...this.schema.marks}).find(t=>t.spec.toMarkdown.match(e));if(!t)throw g(e.type);return t};#n=e=>this.#t(e).spec.toMarkdown.runner(this,e);#r=(e,t)=>this.#t(e).spec.toMarkdown.runner(this,e,t);#i=e=>{let{marks:t}=e,n=e=>e.type.spec.priority??50;[...t].sort((e,t)=>n(e)-n(t)).every(t=>!this.#r(t,e))&&this.#n(e),t.forEach(e=>this.#f(e))};#a=(e,t)=>{if(e.type===t||e.children?.length!==1)return e;let n=e=>{if(e.type===t)return e.value==null?e:null;if(e.children?.length!==1)return null;let[r]=e.children;return r?n(r):null},r=n(e);if(!r)return e;let i=r.children?[...r.children]:void 0,a={...e,children:i};return a.children=i,r.children=[a],r};#o=e=>{let{children:t}=e;return t&&(e.children=t.reduce((e,t,n)=>{if(n===0)return[t];let r=e.at(-1);if(r&&r.isMark&&t.isMark){t=this.#a(t,r.type);let{children:n,...i}=t,{children:a,...o}=r;if(t.type===r.type&&n&&a&&JSON.stringify(i)===JSON.stringify(o)){let t={...o,children:[...a,...n]};return e.slice(0,-1).concat(this.#o(t))}}return e.concat(t)},[])),e};#s=e=>{let t={...e.props,type:e.type};return e.children&&(t.children=e.children),e.value&&(t.value=e.value),t};#c=(e,t)=>{let n=``,r=``,i=e.children,a=-1,o=-1,s=e=>{e&&e.forEach((e,t)=>{e.type===`text`&&e.value&&(a<0&&(a=t),o=t)})};if(i){s(i);let e=i?.[o],t=i?.[a];if(e&&e.value.endsWith(` `)){let t=e.value,n=t.trimEnd();r=t.slice(n.length),e.value=n}if(t&&t.value.startsWith(` `)){let e=t.value,r=e.trimStart();n=e.slice(0,e.length-r.length),t.value=r}}n.length&&this.#u(`text`,void 0,n);let c=t();return r.length&&this.#u(`text`,void 0,r),c};#l=(e=!1)=>{let t=this.close(),n=()=>this.#u(t.type,t.children,t.value,t.props);return e?this.#c(t,n):n()};#u=(e,t,n,r)=>{let i=ql.create(e,t,n,r),a=this.#o(this.#s(i));return this.push(a),a};#d=(e,t,n,r)=>e.isInSet(this.#e)?this:(this.#e=e.addToSet(this.#e),this.openNode(t,n,{...r,isMark:!0}));#f=e=>{e.isInSet(this.#e)&&(this.#e=e.type.removeFromSet(this.#e),this.#l(!0))}},W=function(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t},Xl=function(e){let t=e.assignedSlot||e.parentNode;return t&&t.nodeType==11?t.host:t},Zl=null,Ql=function(e,t,n){let r=Zl||=document.createRange();return r.setEnd(e,n??e.nodeValue.length),r.setStart(e,t||0),r},$l=function(){Zl=null},eu=function(e,t,n,r){return n&&(nu(e,t,n,r,-1)||nu(e,t,n,r,1))},tu=/^(img|br|input|textarea|hr)$/i;function nu(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:ru(e))){let n=e.parentNode;if(!n||n.nodeType!=1||su(e)||tu.test(e.nodeName)||e.contentEditable==`false`)return!1;t=W(e)+(i<0?0:1),e=n}else if(e.nodeType==1){let n=e.childNodes[t+(i<0?-1:0)];if(n.nodeType==1&&n.contentEditable==`false`)if(n.pmViewDesc?.ignoreForSelection)t+=i;else return!1;else e=n,t=i<0?ru(e):0}else return!1}}function ru(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function iu(e,t){for(;;){if(e.nodeType==3&&t)return e;if(e.nodeType==1&&t>0){if(e.contentEditable==`false`)return null;e=e.childNodes[t-1],t=ru(e)}else if(e.parentNode&&!su(e))t=W(e),e=e.parentNode;else return null}}function au(e,t){for(;;){if(e.nodeType==3&&t<e.nodeValue.length)return e;if(e.nodeType==1&&t<e.childNodes.length){if(e.contentEditable==`false`)return null;e=e.childNodes[t],t=0}else if(e.parentNode&&!su(e))t=W(e)+1,e=e.parentNode;else return null}}function ou(e,t,n){for(let r=t==0,i=t==ru(e);r||i;){if(e==n)return!0;let t=W(e);if(e=e.parentNode,!e)return!1;r&&=t==0,i&&=t==ru(e)}}function su(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}var cu=function(e){return e.focusNode&&eu(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function lu(e,t){let n=document.createEvent(`Event`);return n.initEvent(`keydown`,!0,!0),n.keyCode=e,n.key=n.code=t,n}function uu(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}function du(e,t,n){if(e.caretPositionFromPoint)try{let r=e.caretPositionFromPoint(t,n);if(r)return{node:r.offsetNode,offset:Math.min(ru(r.offsetNode),r.offset)}}catch{}if(e.caretRangeFromPoint){let r=e.caretRangeFromPoint(t,n);if(r)return{node:r.startContainer,offset:Math.min(ru(r.startContainer),r.startOffset)}}}var fu=typeof navigator<`u`?navigator:null,pu=typeof document<`u`?document:null,mu=fu&&fu.userAgent||``,hu=/Edge\/(\d+)/.exec(mu),gu=/MSIE \d/.exec(mu),_u=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(mu),G=!!(gu||_u||hu),vu=gu?document.documentMode:_u?+_u[1]:hu?+hu[1]:0,yu=!G&&/gecko\/(\d+)/i.test(mu);yu&&+(/Firefox\/(\d+)/.exec(mu)||[0,0])[1];var bu=!G&&/Chrome\/(\d+)/.exec(mu),K=!!bu,xu=bu?+bu[1]:0,q=!G&&!!fu&&/Apple Computer/.test(fu.vendor),Su=q&&(/Mobile\/\w+/.test(mu)||!!fu&&fu.maxTouchPoints>2),Cu=Su||(fu?/Mac/.test(fu.platform):!1),wu=fu?/Win/.test(fu.platform):!1,Tu=/Android \d/.test(mu),Eu=!!pu&&`webkitFontSmoothing`in pu.documentElement.style,Du=Eu?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Ou(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function ku(e,t){return typeof e==`number`?e:e[t]}function Au(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function ju(e,t,n){let r=e.someProp(`scrollThreshold`)||0,i=e.someProp(`scrollMargin`)||5,a=e.dom.ownerDocument;for(let o=n||e.dom;o;){if(o.nodeType!=1){o=Xl(o);continue}let e=o,n=e==a.body,s=n?Ou(a):Au(e),c=0,l=0;if(t.top<s.top+ku(r,`top`)?l=-(s.top-t.top+ku(i,`top`)):t.bottom>s.bottom-ku(r,`bottom`)&&(l=t.bottom-t.top>s.bottom-s.top?t.top+ku(i,`top`)-s.top:t.bottom-s.bottom+ku(i,`bottom`)),t.left<s.left+ku(r,`left`)?c=-(s.left-t.left+ku(i,`left`)):t.right>s.right-ku(r,`right`)&&(c=t.right-s.right+ku(i,`right`)),c||l)if(n)a.defaultView.scrollBy(c,l);else{let n=e.scrollLeft,r=e.scrollTop;l&&(e.scrollTop+=l),c&&(e.scrollLeft+=c);let i=e.scrollLeft-n,a=e.scrollTop-r;t={left:t.left-i,top:t.top-a,right:t.right-i,bottom:t.bottom-a}}let u=n?`fixed`:getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(u))break;o=u==`absolute`?o.offsetParent:Xl(o)}}function Mu(e){let t=e.dom.getBoundingClientRect(),n=Math.max(0,t.top),r,i;for(let a=(t.left+t.right)/2,o=n+1;o<Math.min(innerHeight,t.bottom);o+=5){let t=e.root.elementFromPoint(a,o);if(!t||t==e.dom||!e.dom.contains(t))continue;let s=t.getBoundingClientRect();if(s.top>=n-20){r=t,i=s.top;break}}return{refDOM:r,refTop:i,stack:Nu(e.dom)}}function Nu(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=Xl(r));return t}function Pu({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;Fu(n,r==0?0:r-t)}function Fu(e,t){for(let n=0;n<e.length;n++){let{dom:r,top:i,left:a}=e[n];r.scrollTop!=i+t&&(r.scrollTop=i+t),r.scrollLeft!=a&&(r.scrollLeft=a)}}var Iu=null;function Lu(e){if(e.setActive)return e.setActive();if(Iu)return e.focus(Iu);let t=Nu(e);e.focus(Iu==null?{get preventScroll(){return Iu={preventScroll:!0},!0}}:void 0),Iu||(Iu=!1,Fu(t,0))}function Ru(e,t){let n,r=2e8,i,a=0,o=t.top,s=t.top,c,l;for(let u=e.firstChild,d=0;u;u=u.nextSibling,d++){let e;if(u.nodeType==1)e=u.getClientRects();else if(u.nodeType==3)e=Ql(u).getClientRects();else continue;for(let f=0;f<e.length;f++){let p=e[f];if(p.top<=o&&p.bottom>=s){o=Math.max(p.bottom,o),s=Math.min(p.top,s);let e=p.left>t.left?p.left-t.left:p.right<t.left?t.left-p.right:0;if(e<r){n=u,r=e,i=e&&n.nodeType==3?{left:p.right<t.left?p.right:p.left,top:t.top}:t,u.nodeType==1&&e&&(a=d+(t.left>=(p.left+p.right)/2?1:0));continue}}else p.top>t.top&&!c&&p.left<=t.left&&p.right>=t.left&&(c=u,l={left:Math.max(p.left,Math.min(p.right,t.left)),top:p.top});!n&&(t.left>=p.right&&t.top>=p.top||t.left>=p.left&&t.top>=p.bottom)&&(a=d+1)}}return!n&&c&&(n=c,i=l,r=0),n&&n.nodeType==3?zu(n,i):!n||r&&n.nodeType==1?{node:e,offset:a}:Ru(n,i)}function zu(e,t){let n=e.nodeValue.length,r=document.createRange(),i;for(let a=0;a<n;a++){r.setEnd(e,a+1),r.setStart(e,a);let n=qu(r,1);if(n.top!=n.bottom&&Bu(t,n)){i={node:e,offset:a+(t.left>=(n.left+n.right)/2?1:0)};break}}return r.detach(),i||{node:e,offset:0}}function Bu(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function Vu(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}function Hu(e,t,n){let{node:r,offset:i}=Ru(t,n),a=-1;if(r.nodeType==1&&!r.firstChild){let e=r.getBoundingClientRect();a=e.left!=e.right&&n.left>(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(r,i,a)}function Uu(e,t,n,r){let i=-1;for(let n=t,a=!1;n!=e.dom;){let t=e.docView.nearestDesc(n,!0),o;if(!t)return null;if(t.dom.nodeType==1&&(t.node.isBlock&&t.parent||!t.contentDOM)&&((o=t.dom.getBoundingClientRect()).width||o.height)&&(t.node.isBlock&&t.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(t.dom.nodeName)&&(!a&&o.left>r.left||o.top>r.top?i=t.posBefore:(!a&&o.right<r.left||o.bottom<r.top)&&(i=t.posAfter),a=!0),!t.contentDOM&&i<0&&!t.node.isText))return(t.node.isBlock?r.top<(o.top+o.bottom)/2:r.left<(o.left+o.right)/2)?t.posBefore:t.posAfter;n=t.dom.parentNode}return i>-1?i:e.docView.posFromDOM(t,n,-1)}function Wu(e,t,n){let r=e.childNodes.length;if(r&&n.top<n.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(t.top-n.top)/(n.bottom-n.top))-2)),a=i;;){let n=e.childNodes[a];if(n.nodeType==1){let e=n.getClientRects();for(let r=0;r<e.length;r++){let i=e[r];if(Bu(t,i))return Wu(n,t,i)}}if((a=(a+1)%r)==i)break}return e}function Gu(e,t){let n=e.dom.ownerDocument,r,i=0,a=du(n,t.left,t.top);a&&({node:r,offset:i}=a);let o=(e.root.elementFromPoint?e.root:n).elementFromPoint(t.left,t.top),s;if(!o||!e.dom.contains(o.nodeType==1?o:o.parentNode)){let n=e.dom.getBoundingClientRect();if(!Bu(t,n)||(o=Wu(e.dom,t,n),!o))return null}if(q)for(let e=o;r&&e;e=Xl(e))e.draggable&&(r=void 0);if(o=Vu(o,t),r){if(yu&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let e=r.childNodes[i],n;e.nodeName==`IMG`&&(n=e.getBoundingClientRect()).right<=t.left&&n.bottom>t.top&&i++}let n;Eu&&i&&r.nodeType==1&&(n=r.childNodes[i-1]).nodeType==1&&n.contentEditable==`false`&&n.getBoundingClientRect().top>=t.top&&i--,r==e.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&t.top>r.lastChild.getBoundingClientRect().bottom?s=e.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!=`BR`)&&(s=Uu(e,r,i,t))}s??=Hu(e,o,t);let c=e.docView.nearestDesc(o,!0);return{pos:s,inside:c?c.posAtStart-c.border:-1}}function Ku(e){return e.top<e.bottom||e.left<e.right}function qu(e,t){let n=e.getClientRects();if(n.length){let e=n[t<0?0:n.length-1];if(Ku(e))return e}return Array.prototype.find.call(n,Ku)||e.getBoundingClientRect()}var Ju=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Yu(e,t,n){let{node:r,offset:i,atom:a}=e.docView.domFromPos(t,n<0?-1:1),o=Eu||yu;if(r.nodeType==3)if(o&&(Ju.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let e=qu(Ql(r,i,i),n);if(yu&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let t=qu(Ql(r,i-1,i-1),-1);if(t.top==e.top){let n=qu(Ql(r,i,i+1),-1);if(n.top!=e.top)return Xu(n,n.left<t.left)}}return e}else{let e=i,t=i,a=n<0?1:-1;return n<0&&!i?(t++,a=-1):n>=0&&i==r.nodeValue.length?(e--,a=1):n<0?e--:t++,Xu(qu(Ql(r,e,t),a),a<0)}if(!e.state.doc.resolve(t-(a||0)).parent.inlineContent){if(a==null&&i&&(n<0||i==ru(r))){let e=r.childNodes[i-1];if(e.nodeType==1)return Zu(e.getBoundingClientRect(),!1)}if(a==null&&i<ru(r)){let e=r.childNodes[i];if(e.nodeType==1)return Zu(e.getBoundingClientRect(),!0)}return Zu(r.getBoundingClientRect(),n>=0)}if(a==null&&i&&(n<0||i==ru(r))){let e=r.childNodes[i-1],t=e.nodeType==3?Ql(e,ru(e)-(o?0:1)):e.nodeType==1&&(e.nodeName!=`BR`||!e.nextSibling)?e:null;if(t)return Xu(qu(t,1),!1)}if(a==null&&i<ru(r)){let e=r.childNodes[i];for(;e.pmViewDesc&&e.pmViewDesc.ignoreForCoords;)e=e.nextSibling;let t=e?e.nodeType==3?Ql(e,0,o?0:1):e.nodeType==1?e:null:null;if(t)return Xu(qu(t,-1),!0)}return Xu(qu(r.nodeType==3?Ql(r):r,-n),n>=0)}function Xu(e,t){if(e.width==0)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function Zu(e,t){if(e.height==0)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function Qu(e,t,n){let r=e.state,i=e.root.activeElement;r!=t&&e.updateState(t),i!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),i!=e.dom&&i&&i.focus()}}function $u(e,t,n){let r=t.selection,i=n==`up`?r.$from:r.$to;return Qu(e,t,()=>{let{node:t}=e.docView.domFromPos(i.pos,n==`up`?-1:1);for(;;){let n=e.docView.nearestDesc(t,!0);if(!n)break;if(n.node.isBlock){t=n.contentDOM||n.dom;break}t=n.dom.parentNode}let r=Yu(e,i.pos,1);for(let e=t.firstChild;e;e=e.nextSibling){let t;if(e.nodeType==1)t=e.getClientRects();else if(e.nodeType==3)t=Ql(e,0,e.nodeValue.length).getClientRects();else continue;for(let e=0;e<t.length;e++){let i=t[e];if(i.bottom>i.top+1&&(n==`up`?r.top-i.top>(i.bottom-r.top)*2:i.bottom-r.bottom>(r.bottom-i.top)*2))return!1}}return!0})}var ed=/[\u0590-\u08ac]/;function td(e,t,n){let{$head:r}=t.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,a=!i,o=i==r.parent.content.size,s=e.domSelection();return s?!ed.test(r.parent.textContent)||!s.modify?n==`left`||n==`backward`?a:o:Qu(e,t,()=>{let{focusNode:t,focusOffset:i,anchorNode:a,anchorOffset:o}=e.domSelectionRange(),c=s.caretBidiLevel;s.modify(`move`,n,`character`);let l=r.depth?e.docView.domAfterPos(r.before()):e.dom,{focusNode:u,focusOffset:d}=e.domSelectionRange(),f=u&&!l.contains(u.nodeType==1?u:u.parentNode)||t==u&&i==d;try{s.collapse(a,o),t&&(t!=a||i!=o)&&s.extend&&s.extend(t,i)}catch{}return c!=null&&(s.caretBidiLevel=c),f}):r.pos==r.start()||r.pos==r.end()}var nd=null,rd=null,id=!1;function ad(e,t,n){return nd==t&&rd==n?id:(nd=t,rd=n,id=n==`up`||n==`down`?$u(e,t,n):td(e,t,n))}var od=0,sd=1,cd=2,ld=3,ud=class{constructor(e,t,n,r){this.parent=e,this.children=t,this.dom=n,this.contentDOM=r,this.dirty=od,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,n=this.posAtStart;;t++){let r=this.children[t];if(r==e)return n;n+=r.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,n){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(n<0){let n,r;if(e==this.contentDOM)n=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.previousSibling}for(;n&&!((r=n.pmViewDesc)&&r.parent==this);)n=n.previousSibling;return n?this.posBeforeChild(r)+r.size:this.posAtStart}else{let n,r;if(e==this.contentDOM)n=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.nextSibling}for(;n&&!((r=n.pmViewDesc)&&r.parent==this);)n=n.nextSibling;return n?this.posBeforeChild(r):this.posAtEnd}let r;if(e==this.dom&&this.contentDOM)r=t>W(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!1;break}if(t.previousSibling)break}if(r==null&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!0;break}if(t.nextSibling)break}}return r??n>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,r=e;r;r=r.parentNode){let i=this.getDesc(r),a;if(i&&(!t||i.node))if(n&&(a=i.nodeDOM)&&!(a.nodeType==1?a.contains(e.nodeType==1?e:e.parentNode):a==e))n=!1;else return i}}getDesc(e){let t=e.pmViewDesc;for(let e=t;e;e=e.parent)if(e==this)return t}posFromDOM(e,t,n){for(let r=e;r;r=r.parentNode){let i=this.getDesc(r);if(i)return i.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let r=this.children[t],i=n+r.size;if(n==e&&i!=n){for(;!r.border&&r.children.length;)for(let e=0;e<r.children.length;e++){let t=r.children[e];if(t.size){r=t;break}}return r}if(e<i)return r.descAt(e-n-r.border);n=i}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,r=0;for(let t=0;n<this.children.length;n++){let i=this.children[n],a=t+i.size;if(a>e||i instanceof _d){r=e-t;break}t=a}if(r)return this.children[n].domFromPos(r-this.children[n].border,t);for(let e;n&&!(e=this.children[n-1]).size&&e instanceof dd&&e.side>=0;n--);if(t<=0){let e,r=!0;for(;e=n?this.children[n-1]:null,!(!e||e.dom.parentNode==this.contentDOM);n--,r=!1);return e&&t&&r&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?W(e.dom)+1:0}}else{let e,r=!0;for(;e=n<this.children.length?this.children[n]:null,!(!e||e.dom.parentNode==this.contentDOM);n++,r=!1);return e&&r&&!e.border&&!e.domAtom?e.domFromPos(0,t):{node:this.contentDOM,offset:e?W(e.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,i=-1;for(let a=n,o=0;;o++){let n=this.children[o],s=a+n.size;if(r==-1&&e<=s){let i=a+n.border;if(e>=i&&t<=s-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,i);e=a;for(let t=o;t>0;t--){let n=this.children[t-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){r=W(n.dom)+1;break}e-=n.size}r==-1&&(r=0)}if(r>-1&&(s>t||o==this.children.length-1)){t=s;for(let e=o+1;e<this.children.length;e++){let n=this.children[e];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(-1)){i=W(n.dom);break}t+=n.size}i==-1&&(i=this.contentDOM.childNodes.length);break}a=s}return{node:this.contentDOM,from:e,to:t,fromOffset:r,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:n}=this.domFromPos(e,0);if(t.nodeType!=1||n==t.childNodes.length)throw RangeError(`No node after pos `+e);return t.childNodes[n]}setSelection(e,t,n,r=!1){let i=Math.min(e,t),a=Math.max(e,t);for(let o=0,s=0;o<this.children.length;o++){let c=this.children[o],l=s+c.size;if(i>s&&a<l)return c.setSelection(e-s-c.border,t-s-c.border,n,r);s=l}let o=this.domFromPos(e,e?-1:1),s=t==e?o:this.domFromPos(t,t?-1:1),c=n.root.getSelection(),l=n.domSelectionRange(),u=!1;if((yu||q)&&e==t){let{node:e,offset:t}=o;if(e.nodeType==3){if(u=!!(t&&e.nodeValue[t-1]==`
41
+ `),u&&t==e.nodeValue.length)for(let t=e,n;t;t=t.parentNode){if(n=t.nextSibling){n.nodeName==`BR`&&(o=s={node:n.parentNode,offset:W(n)+1});break}let e=t.pmViewDesc;if(e&&e.node&&e.node.isBlock)break}}else{let n=e.childNodes[t-1];u=n&&(n.nodeName==`BR`||n.contentEditable==`false`)}}if(yu&&l.focusNode&&l.focusNode!=s.node&&l.focusNode.nodeType==1){let e=l.focusNode.childNodes[l.focusOffset];e&&e.contentEditable==`false`&&(r=!0)}if(!(r||u&&q)&&eu(o.node,o.offset,l.anchorNode,l.anchorOffset)&&eu(s.node,s.offset,l.focusNode,l.focusOffset))return;let d=!1;if((c.extend||e==t)&&!(u&&yu)){c.collapse(o.node,o.offset);try{e!=t&&c.extend(s.node,s.offset),d=!0}catch{}}if(!d){if(e>t){let e=o;o=s,s=e}let n=document.createRange();n.setEnd(s.node,s.offset),n.setStart(o.node,o.offset),c.removeAllRanges(),c.addRange(n)}}ignoreMutation(e){return!this.contentDOM&&e.type!=`selection`}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,r=0;r<this.children.length;r++){let i=this.children[r],a=n+i.size;if(n==a?e<=a&&t>=n:e<a&&t>n){let r=n+i.border,o=a-i.border;if(e>=r&&t<=o){this.dirty=e==n||t==a?cd:sd,e==r&&t==o&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=ld:i.markDirty(e-r,t-r);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?cd:ld}n=a}this.dirty=cd}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=e==1?cd:sd;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},dd=class extends ud{constructor(e,t,n,r){let i,a=t.type.toDOM;if(typeof a==`function`&&(a=a(n,()=>{if(!i)return r;if(i.parent)return i.parent.posBeforeChild(i)})),!t.type.spec.raw){if(a.nodeType!=1){let e=document.createElement(`span`);e.appendChild(a),a=e}a.contentEditable=`false`,a.classList.add(`ProseMirror-widget`)}super(e,[],a,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return this.dirty==od&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!=`selection`||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}},fd=class extends ud{constructor(e,t,n,r){super(e,[],t,null),this.textDOM=n,this.text=r}get size(){return this.text.length}localPosFromDOM(e,t){return e==this.textDOM?this.posAtStart+t:this.posAtStart+(t?this.size:0)}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type===`characterData`&&e.target.nodeValue==e.oldValue}},pd=class e extends ud{constructor(e,t,n,r,i){super(e,[],n,r),this.mark=t,this.spec=i}static create(t,n,r,i){let a=i.nodeViews[n.type.name],o=a&&a(n,i,r);return(!o||!o.dom)&&(o=Ro.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new e(t,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&ld||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=ld&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=od){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty<this.dirty&&(e.dirty=this.dirty),this.dirty=od}}slice(t,n,r){let i=e.create(this.parent,this.mark,!0,r),a=this.children,o=this.size;n<o&&(a=Pd(a,n,o,r)),t>0&&(a=Pd(a,0,t,r));for(let e=0;e<a.length;e++)a[e].parent=i;return i.children=a,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},md=class e extends ud{constructor(e,t,n,r,i,a,o,s,c){super(e,[],i,a),this.node=t,this.outerDeco=n,this.innerDeco=r,this.nodeDOM=o}static create(t,n,r,i,a,o){let s=a.nodeViews[n.type.name],c,l=s&&s(n,a,()=>{if(!c)return o;if(c.parent)return c.parent.posBeforeChild(c)},r,i),u=l&&l.dom,d=l&&l.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(u.nodeType!=3)throw RangeError(`Text must be rendered as a DOM text node`)}else if(!u){let e=Ro.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs);({dom:u,contentDOM:d}=e)}!d&&!n.isText&&u.nodeName!=`BR`&&(u.hasAttribute(`contenteditable`)||(u.contentEditable=`false`),n.type.spec.draggable&&(u.draggable=!0));let f=u;return u=Td(u,r,n),l?c=new vd(t,n,r,i,u,d||null,f,l,a,o+1):n.isText?new gd(t,n,r,i,u,f,a):new e(t,n,r,i,u,d||null,f,a,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace==`pre`&&(e.preserveWhitespace=`full`),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let n=this.children[t];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}e.contentElement||(e.getContent=()=>F.empty)}return e}matchesNode(e,t,n){return this.dirty==od&&e.eq(this.node)&&Ed(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let n=this.node.inlineContent,r=t,i=e.composing?this.localCompositionInfo(e,t):null,a=i&&i.pos>-1?i:null,o=i&&i.pos<0,s=new Od(this,a&&a.node,e);jd(this.node,this.innerDeco,(t,i,a)=>{t.spec.marks?s.syncToMarks(t.spec.marks,n,e,i):t.type.side>=0&&!a&&s.syncToMarks(i==this.node.childCount?I.none:this.node.child(i).marks,n,e,i),s.placeWidget(t,e,r)},(t,a,c,l)=>{s.syncToMarks(t.marks,n,e,l);let u;s.findNodeMatch(t,a,c,l)||o&&e.state.selection.from>r&&e.state.selection.to<r+t.nodeSize&&(u=s.findIndexWithChild(i.node))>-1&&s.updateNodeAt(t,a,c,u,e)||s.updateNextNode(t,a,c,e,l,r)||s.addNode(t,a,c,e,r),r+=t.nodeSize}),s.syncToMarks([],n,e,0),this.node.isTextblock&&s.addTextblockHacks(),s.destroyRest(),(s.changed||this.dirty==cd)&&(a&&this.protectLocalComposition(e,a),yd(this.contentDOM,this.children,e),Su&&Md(this.dom))}localCompositionInfo(e,t){let{from:n,to:r}=e.state.selection;if(!(e.state.selection instanceof V)||n<t||r>t+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let e=i.nodeValue,a=Nd(this.node.content,e,n-t,r-t);return a<0?null:{node:i,pos:a,text:e}}else return{node:i,pos:-1,text:``}}protectLocalComposition(e,{node:t,pos:n,text:r}){if(this.getDesc(t))return;let i=t;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&=void 0}let a=new fd(this,i,t,r);e.input.compositionNodes.push(a),this.children=Pd(this.children,n,n+r.length,e,a)}update(e,t,n,r){return this.dirty==ld||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,n,r),!0)}updateInner(e,t,n,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=od}updateOuterDeco(e){if(Ed(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=Cd(this.dom,this.nodeDOM,Sd(this.outerDeco,this.node,t),Sd(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add(`ProseMirror-selectednode`),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove(`ProseMirror-selectednode`),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute(`draggable`))}get domAtom(){return this.node.isAtom}};function hd(e,t,n,r,i){Td(r,t,e);let a=new md(void 0,e,t,n,r,r,r,i,0);return a.contentDOM&&a.updateChildren(i,0),a}var gd=class e extends md{constructor(e,t,n,r,i,a,o){super(e,t,n,r,i,null,a,o,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,r){return this.dirty==ld||this.dirty!=od&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=od||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=od,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return e.type!=`characterData`&&e.type!=`selection`}slice(t,n,r){let i=this.node.cut(t,n),a=document.createTextNode(i.text);return new e(this.parent,i,this.outerDeco,this.innerDeco,a,a,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=ld)}get domAtom(){return!1}isText(e){return this.node.text==e}},_d=class extends ud{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==od&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName==`IMG`}},vd=class extends md{constructor(e,t,n,r,i,a,o,s,c,l){super(e,t,n,r,i,a,o,c,l),this.spec=s}update(e,t,n,r){if(this.dirty==ld)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,t,n);return i&&this.updateInner(e,t,n,r),i}else if(!this.contentDOM&&!e.isLeaf)return!1;else return super.update(e,t,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,r){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,r)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}};function yd(e,t,n){let r=e.firstChild,i=!1;for(let a=0;a<t.length;a++){let o=t[a],s=o.dom;if(s.parentNode==e){for(;s!=r;)r=Dd(r),i=!0;r=r.nextSibling}else i=!0,e.insertBefore(s,r);if(o instanceof pd){let t=r?r.previousSibling:e.lastChild;yd(o.contentDOM,o.children,n),r=t?t.nextSibling:e.firstChild}}for(;r;)r=Dd(r),i=!0;i&&n.trackWrites==e&&(n.trackWrites=null)}var bd=function(e){e&&(this.nodeName=e)};bd.prototype=Object.create(null);var xd=[new bd];function Sd(e,t,n){if(e.length==0)return xd;let r=n?xd[0]:new bd,i=[r];for(let a=0;a<e.length;a++){let o=e[a].type.attrs;if(o){o.nodeName&&i.push(r=new bd(o.nodeName));for(let e in o){let a=o[e];a!=null&&(n&&i.length==1&&i.push(r=new bd(t.isInline?`span`:`div`)),e==`class`?r.class=(r.class?r.class+` `:``)+a:e==`style`?r.style=(r.style?r.style+`;`:``)+a:e!=`nodeName`&&(r[e]=a))}}}return i}function Cd(e,t,n,r){if(n==xd&&r==xd)return t;let i=t;for(let t=0;t<r.length;t++){let a=r[t],o=n[t];if(t){let t;o&&o.nodeName==a.nodeName&&i!=e&&(t=i.parentNode)&&t.nodeName.toLowerCase()==a.nodeName?i=t:(t=document.createElement(a.nodeName),t.pmIsDeco=!0,t.appendChild(i),o=xd[0],i=t)}wd(i,o||xd[0],a)}return i}function wd(e,t,n){for(let r in t)r!=`class`&&r!=`style`&&r!=`nodeName`&&!(r in n)&&e.removeAttribute(r);for(let r in n)r!=`class`&&r!=`style`&&r!=`nodeName`&&n[r]!=t[r]&&e.setAttribute(r,n[r]);if(t.class!=n.class){let r=t.class?t.class.split(` `).filter(Boolean):[],i=n.class?n.class.split(` `).filter(Boolean):[];for(let t=0;t<r.length;t++)i.indexOf(r[t])==-1&&e.classList.remove(r[t]);for(let t=0;t<i.length;t++)r.indexOf(i[t])==-1&&e.classList.add(i[t]);e.classList.length==0&&e.removeAttribute(`class`)}if(t.style!=n.style){if(t.style){let n=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,r;for(;r=n.exec(t.style);)e.style.removeProperty(r[1])}n.style&&(e.style.cssText+=n.style)}}function Td(e,t,n){return Cd(e,e,xd,Sd(t,n,e.nodeType!=1))}function Ed(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function Dd(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}var Od=class{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=kd(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n,r){let i=0,a=this.stack.length>>1,o=Math.min(a,e.length);for(;i<o&&(i==a-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<a;)this.destroyRest(),this.top.dirty=od,this.index=this.stack.pop(),this.top=this.stack.pop(),a--;for(;a<e.length;){this.stack.push(this.top,this.index+1);let i=-1,o=this.top.children.length;r<this.preMatch.index&&(o=Math.min(this.index+3,o));for(let t=this.index;t<o;t++){let n=this.top.children[t];if(n.matchesMark(e[a])&&!this.isLocked(n.dom)){i=t;break}}if(i>-1)i>this.index&&(this.changed=!0,this.destroyBetween(this.index,i)),this.top=this.top.children[this.index];else{let r=pd.create(this.top,e[a],t,n);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,a++}}findNodeMatch(e,t,n,r){let i=-1,a;if(r>=this.preMatch.index&&(a=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&a.matchesNode(e,t,n))i=this.top.children.indexOf(a,this.index);else for(let r=this.index,a=Math.min(this.top.children.length,r+5);r<a;r++){let a=this.top.children[r];if(a.matchesNode(e,t,n)&&!this.preMatch.matched.has(a)){i=r;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,n,r,i){let a=this.top.children[r];return a.dirty==ld&&a.dom==a.contentDOM&&(a.dirty=cd),a.update(e,t,n,i)?(this.destroyBetween(this.index,r),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let t=e.pmViewDesc;if(t){for(let e=this.index;e<this.top.children.length;e++)if(this.top.children[e]==t)return e}return-1}e=t}}updateNextNode(e,t,n,r,i,a){for(let o=this.index;o<this.top.children.length;o++){let s=this.top.children[o];if(s instanceof md){let c=this.preMatch.matched.get(s);if(c!=null&&c!=i)return!1;let l=s.dom,u,d=this.isLocked(l)&&!(e.isText&&s.node&&s.node.isText&&s.nodeDOM.nodeValue==e.text&&s.dirty!=ld&&Ed(t,s.outerDeco));if(!d&&s.update(e,t,n,r))return this.destroyBetween(this.index,o),s.dom!=l&&(this.changed=!0),this.index++,!0;if(!d&&(u=this.recreateWrapper(s,e,t,n,r,a)))return this.destroyBetween(this.index,o),this.top.children[this.index]=u,u.contentDOM&&(u.dirty=cd,u.updateChildren(r,a+1),u.dirty=od),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,r,i,a){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Ed(n,e.outerDeco)||!r.eq(e.innerDeco))return null;let o=md.create(this.top,t,n,r,i,a);if(o.contentDOM){o.children=e.children,e.children=[];for(let e of o.children)e.parent=o}return e.destroy(),o}addNode(e,t,n,r,i){let a=md.create(this.top,e,t,n,r,i);a.contentDOM&&a.updateChildren(r,i+1),this.top.children.splice(this.index++,0,a),this.changed=!0}placeWidget(e,t,n){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(r&&r.matchesWidget(e)&&(e==r.widget||!r.widget.type.toDOM.parentNode))this.index++;else{let r=new dd(this.top,e,t,n);this.top.children.splice(this.index++,0,r),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof pd;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof gd)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((q||K)&&e&&e.dom.contentEditable==`false`&&this.addHackNode(`IMG`,t),this.addHackNode(`BR`,this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let n=document.createElement(e);e==`IMG`&&(n.className=`ProseMirror-separator`,n.alt=``),e==`BR`&&(n.className=`ProseMirror-trailingBreak`);let r=new _d(this.top,[],n,null);t==this.top?t.children.splice(this.index++,0,r):t.children.push(r),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}};function kd(e,t){let n=t,r=n.children.length,i=e.childCount,a=new Map,o=[];outer:for(;i>0;){let s;for(;;)if(r){let e=n.children[r-1];if(e instanceof pd)n=e,r=e.children.length;else{s=e,r--;break}}else if(n==t)break outer;else r=n.parent.children.indexOf(n),n=n.parent;let c=s.node;if(c){if(c!=e.child(i-1))break;--i,a.set(s,i),o.push(s)}}return{index:i,matched:a,matches:o.reverse()}}function Ad(e,t){return e.type.side-t.type.side}function jd(e,t,n,r){let i=t.locals(e),a=0;if(i.length==0){for(let n=0;n<e.childCount;n++){let o=e.child(n);r(o,i,t.forChild(a,o),n),a+=o.nodeSize}return}let o=0,s=[],c=null;for(let l=0;;){let u,d;for(;o<i.length&&i[o].to==a;){let e=i[o++];e.widget&&(u?(d||=[u]).push(e):u=e)}if(u)if(d){d.sort(Ad);for(let e=0;e<d.length;e++)n(d[e],l,!!c)}else n(u,l,!!c);let f,p;if(c)p=-1,f=c,c=null;else if(l<e.childCount)p=l,f=e.child(l++);else break;for(let e=0;e<s.length;e++)s[e].to<=a&&s.splice(e--,1);for(;o<i.length&&i[o].from<=a&&i[o].to>a;)s.push(i[o++]);let m=a+f.nodeSize;if(f.isText){let e=m;o<i.length&&i[o].from<e&&(e=i[o].from);for(let t=0;t<s.length;t++)s[t].to<e&&(e=s[t].to);e<m&&(c=f.cut(e-a),f=f.cut(0,e-a),m=e,p=-1)}else for(;o<i.length&&i[o].to<m;)o++;let h=f.isInline&&!f.isLeaf?s.filter(e=>!e.inline):s.slice();r(f,h,t.forChild(a,f),p),a=m}}function Md(e){if(e.nodeName==`UL`||e.nodeName==`OL`){let t=e.style.cssText;e.style.cssText=t+`; list-style: square !important`,window.getComputedStyle(e).listStyle,e.style.cssText=t}}function Nd(e,t,n,r){for(let i=0,a=0;i<e.childCount&&a<=r;){let o=e.child(i++),s=a;if(a+=o.nodeSize,!o.isText)continue;let c=o.text;for(;i<e.childCount;){let t=e.child(i++);if(a+=t.nodeSize,!t.isText)break;c+=t.text}if(a>=n){if(a>=r&&c.slice(r-t.length-s,r-s)==t)return r-t.length;let e=s<r?c.lastIndexOf(t,r-s-1):-1;if(e>=0&&e+t.length+s>=n)return s+e;if(n==r&&c.length>=r+t.length-s&&c.slice(r-s,r-s+t.length)==t)return r}}return-1}function Pd(e,t,n,r,i){let a=[];for(let o=0,s=0;o<e.length;o++){let c=e[o],l=s,u=s+=c.size;l>=n||u<=t?a.push(c):(l<t&&a.push(c.slice(0,t-l,r)),i&&=(a.push(i),void 0),u>n&&a.push(c.slice(n-l,c.size,r)))}return a}function Fd(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let i=e.docView.nearestDesc(n.focusNode),a=i&&i.size==0,o=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let s=r.resolve(o),c,l;if(cu(n)){for(c=o;i&&!i.node;)i=i.parent;let e=i.node;if(i&&e.isAtom&&H.isSelectable(e)&&i.parent&&!(e.isInline&&ou(n.focusNode,n.focusOffset,i.dom))){let e=i.posBefore;l=new H(o==e?s:r.resolve(e))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let t=o,i=o;for(let r=0;r<n.rangeCount;r++){let a=n.getRangeAt(r);t=Math.min(t,e.docView.posFromDOM(a.startContainer,a.startOffset,1)),i=Math.max(i,e.docView.posFromDOM(a.endContainer,a.endOffset,-1))}if(t<0)return null;[c,o]=i==e.state.selection.anchor?[i,t]:[t,i],s=r.resolve(o)}else c=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(c<0)return null}let u=r.resolve(c);if(!l){let n=t==`pointer`||e.state.selection.head<s.pos&&!a?1:-1;l=Kd(e,u,s,n)}return l}function Id(e){return e.editable?e.hasFocus():Jd(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function Ld(e,t=!1){let n=e.state.selection;if(Wd(e,n),Id(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&K){let t=e.domSelectionRange(),n=e.domObserver.currentSelection;if(t.anchorNode&&n.anchorNode&&eu(t.anchorNode,t.anchorOffset,n.anchorNode,n.anchorOffset)){e.input.mouseDown.delayedSelectionSync=!0,e.domObserver.setCurSelection();return}}if(e.domObserver.disconnectSelection(),e.cursorWrapper)Ud(e);else{let{anchor:r,head:i}=n,a,o;Rd&&!(n instanceof V)&&(n.$from.parent.inlineContent||(a=zd(e,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=zd(e,n.to))),e.docView.setSelection(r,i,e,t),Rd&&(a&&Vd(a),o&&Vd(o)),n.visible?e.dom.classList.remove(`ProseMirror-hideselection`):(e.dom.classList.add(`ProseMirror-hideselection`),`onselectionchange`in document&&Hd(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}var Rd=q||K&&xu<63;function zd(e,t){let{node:n,offset:r}=e.docView.domFromPos(t,0),i=r<n.childNodes.length?n.childNodes[r]:null,a=r?n.childNodes[r-1]:null;if(q&&i&&i.contentEditable==`false`)return Bd(i);if((!i||i.contentEditable==`false`)&&(!a||a.contentEditable==`false`)){if(i)return Bd(i);if(a)return Bd(a)}}function Bd(e){return e.contentEditable=`true`,q&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function Vd(e){e.contentEditable=`false`,e.wasDraggable&&=(e.draggable=!0,null)}function Hd(e){let t=e.dom.ownerDocument;t.removeEventListener(`selectionchange`,e.input.hideSelectionGuard);let n=e.domSelectionRange(),r=n.anchorNode,i=n.anchorOffset;t.addEventListener(`selectionchange`,e.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=i)&&(t.removeEventListener(`selectionchange`,e.input.hideSelectionGuard),setTimeout(()=>{(!Id(e)||e.state.selection.visible)&&e.dom.classList.remove(`ProseMirror-hideselection`)},20))})}function Ud(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,r=n.nodeName==`IMG`;r?t.collapse(n.parentNode,W(n)+1):t.collapse(n,0),!r&&!e.state.selection.visible&&G&&vu<=11&&(n.disabled=!0,n.disabled=!1)}function Wd(e,t){if(t instanceof H){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(Gd(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else Gd(e)}function Gd(e){e.lastSelectedViewDesc&&=(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),void 0)}function Kd(e,t,n,r){return e.someProp(`createSelectionBetween`,r=>r(e,t,n))||V.between(t,n,r)}function qd(e){return e.editable&&!e.hasFocus()?!1:Jd(e)}function Jd(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(t.anchorNode.nodeType==3?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(t.focusNode.nodeType==3?t.focusNode.parentNode:t.focusNode))}catch{return!1}}function Yd(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return eu(t.node,t.offset,n.anchorNode,n.anchorOffset)}function Xd(e,t){let{$anchor:n,$head:r}=e.selection,i=t>0?n.max(r):n.min(r),a=i.parent.inlineContent?i.depth?e.doc.resolve(t>0?i.after():i.before()):null:i;return a&&B.findFrom(a,t)}function Zd(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function Qd(e,t,n){let r=e.state.selection;if(r instanceof V){if(n.indexOf(`s`)>-1){let{$head:n}=r,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let a=e.state.doc.resolve(n.pos+i.nodeSize*(t<0?-1:1));return Zd(e,new V(r.$anchor,a))}else if(!r.empty)return!1;else if(e.endOfTextblock(t>0?`forward`:`backward`)){let n=Xd(e.state,t);return n&&n instanceof H?Zd(e,n):!1}else if(!(Cu&&n.indexOf(`m`)>-1)){let n=r.$head,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter,a;if(!i||i.isText)return!1;let o=t<0?n.pos-i.nodeSize:n.pos;return i.isAtom||(a=e.docView.descAt(o))&&!a.contentDOM?H.isSelectable(i)?Zd(e,new H(t<0?e.state.doc.resolve(n.pos-i.nodeSize):n)):Eu?Zd(e,new V(e.state.doc.resolve(t<0?o:o+i.nodeSize))):!1:!1}}else if(r instanceof H&&r.node.isInline)return Zd(e,new V(t>0?r.$to:r.$from));else{let n=Xd(e.state,t);return n?Zd(e,n):!1}}function $d(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function ef(e,t){let n=e.pmViewDesc;return n&&n.size==0&&(t<0||e.nextSibling||e.nodeName!=`BR`)}function tf(e,t){return t<0?nf(e):rf(e)}function nf(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i,a,o=!1;for(yu&&n.nodeType==1&&r<$d(n)&&ef(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let e=n.childNodes[r-1];if(ef(e,-1))i=n,a=--r;else if(e.nodeType==3)n=e,r=n.nodeValue.length;else break}}else if(af(n))break;else{let t=n.previousSibling;for(;t&&ef(t,-1);)i=n.parentNode,a=W(t),t=t.previousSibling;if(t)n=t,r=$d(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}o?cf(e,n,r):i&&cf(e,i,a)}function rf(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i=$d(n),a,o;for(;;)if(r<i){if(n.nodeType!=1)break;let e=n.childNodes[r];if(ef(e,1))a=n,o=++r;else break}else if(af(n))break;else{let t=n.nextSibling;for(;t&&ef(t,1);)a=t.parentNode,o=W(t)+1,t=t.nextSibling;if(t)n=t,r=0,i=$d(n);else{if(n=n.parentNode,n==e.dom)break;r=i=0}}a&&cf(e,a,o)}function af(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function of(e,t){for(;e&&t==e.childNodes.length&&!su(e);)t=W(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable==`false`)break;e=n,t=0}}function sf(e,t){for(;e&&!t&&!su(e);)t=W(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable==`false`)break;e=n,t=e.childNodes.length}}function cf(e,t,n){if(t.nodeType!=3){let e,r;(r=of(t,n))?(t=r,n=0):(e=sf(t,n))&&(t=e,n=e.nodeValue.length)}let r=e.domSelection();if(!r)return;if(cu(r)){let e=document.createRange();e.setEnd(t,n),e.setStart(t,n),r.removeAllRanges(),r.addRange(e)}else r.extend&&r.extend(t,n);e.domObserver.setCurSelection();let{state:i}=e;setTimeout(()=>{e.state==i&&Ld(e)},50)}function lf(e,t){let n=e.state.doc.resolve(t);if(!(K||wu)&&n.parent.inlineContent){let r=e.coordsAtPos(t);if(t>n.start()){let n=e.coordsAtPos(t-1),i=(n.top+n.bottom)/2;if(i>r.top&&i<r.bottom&&Math.abs(n.left-r.left)>1)return n.left<r.left?`ltr`:`rtl`}if(t<n.end()){let n=e.coordsAtPos(t+1),i=(n.top+n.bottom)/2;if(i>r.top&&i<r.bottom&&Math.abs(n.left-r.left)>1)return n.left>r.left?`ltr`:`rtl`}}return getComputedStyle(e.dom).direction==`rtl`?`rtl`:`ltr`}function uf(e,t,n){let r=e.state.selection;if(r instanceof V&&!r.empty||n.indexOf(`s`)>-1||Cu&&n.indexOf(`m`)>-1)return!1;let{$from:i,$to:a}=r;if(!i.parent.inlineContent||e.endOfTextblock(t<0?`up`:`down`)){let n=Xd(e.state,t);if(n&&n instanceof H)return Zd(e,n)}if(!i.parent.inlineContent){let n=t<0?i:a,o=r instanceof cc?B.near(n,t):B.findFrom(n,t);return o?Zd(e,o):!1}return!1}function df(e,t){if(!(e.state.selection instanceof V))return!0;let{$head:n,$anchor:r,empty:i}=e.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(e.endOfTextblock(t>0?`forward`:`backward`))return!0;let a=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(a&&!a.isText){let r=e.state.tr;return t<0?r.delete(n.pos-a.nodeSize,n.pos):r.delete(n.pos,n.pos+a.nodeSize),e.dispatch(r),!0}return!1}function ff(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function pf(e){if(!q||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&t.nodeType==1&&n==0&&t.firstChild&&t.firstChild.contentEditable==`false`){let n=t.firstChild;ff(e,n,`true`),setTimeout(()=>ff(e,n,`false`),20)}return!1}function mf(e){let t=``;return e.ctrlKey&&(t+=`c`),e.metaKey&&(t+=`m`),e.altKey&&(t+=`a`),e.shiftKey&&(t+=`s`),t}function hf(e,t){let n=t.keyCode,r=mf(t);if(n==8||Cu&&n==72&&r==`c`)return df(e,-1)||tf(e,-1);if(n==46&&!t.shiftKey||Cu&&n==68&&r==`c`)return df(e,1)||tf(e,1);if(n==13||n==27)return!0;if(n==37||Cu&&n==66&&r==`c`){let t=n==37?lf(e,e.state.selection.from)==`ltr`?-1:1:-1;return Qd(e,t,r)||tf(e,t)}else if(n==39||Cu&&n==70&&r==`c`){let t=n==39?lf(e,e.state.selection.from)==`ltr`?1:-1:1;return Qd(e,t,r)||tf(e,t)}else if(n==38||Cu&&n==80&&r==`c`)return uf(e,-1,r)||tf(e,-1);else if(n==40||Cu&&n==78&&r==`c`)return pf(e)||uf(e,1,r)||tf(e,1);else if(r==(Cu?`m`:`c`)&&(n==66||n==73||n==89||n==90))return!0;return!1}function gf(e,t){e.someProp(`transformCopied`,n=>{t=n(t,e)});let n=[],{content:r,openStart:i,openEnd:a}=t;for(;i>1&&a>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,a--;let e=r.firstChild;n.push(e.type.name,e.attrs==e.type.defaultAttrs?null:e.attrs),r=e.content}let o=e.someProp(`clipboardSerializer`)||Ro.fromSchema(e.state.schema),s=Df(),c=s.createElement(`div`);c.appendChild(o.serializeFragment(r,{document:s}));let l=c.firstChild,u,d=0;for(;l&&l.nodeType==1&&(u=Tf[l.nodeName.toLowerCase()]);){for(let e=u.length-1;e>=0;e--){let t=s.createElement(u[e]);for(;c.firstChild;)t.appendChild(c.firstChild);c.appendChild(t),d++}l=c.firstChild}return l&&l.nodeType==1&&l.setAttribute(`data-pm-slice`,`${i} ${a}${d?` -${d}`:``} ${JSON.stringify(n)}`),{dom:c,text:e.someProp(`clipboardTextSerializer`,n=>n(t,e))||t.content.textBetween(0,t.content.size,`
42
42
 
43
- `);return{dom:a,text:d,slice:e}}function nu(n,e,t,r,i){let s=i.parent.type.spec.code,o,l;if(!t&&!e)return null;let a=!!e&&(r||s||!t);if(a){if(n.someProp("transformPastedText",d=>{e=d(e,s||r,n)}),s)return l=new M(T.from(n.state.schema.text(e.replace(/\r\n?/g,`
44
- `))),0,0),n.someProp("transformPasted",d=>{l=d(l,n,!0)}),l;let h=n.someProp("clipboardTextParser",d=>d(e,i,r,n));if(h)l=h;else{let d=i.marks(),{schema:f}=n.state,p=en.fromSchema(f);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(y=>{let x=o.appendChild(document.createElement("p"));y&&x.appendChild(p.serializeNode(f.text(y,d)))})}}else n.someProp("transformPastedHTML",h=>{t=h(t,n)}),o=dg(t),Fn&&pg(o);let u=o&&o.querySelector("[data-pm-slice]"),c=u&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(u.getAttribute("data-pm-slice")||"");if(c&&c[3])for(let h=+c[3];h>0;h--){let d=o.firstChild;for(;d&&d.nodeType!=1;)d=d.nextSibling;if(!d)break;o=d}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Yt.fromSchema(n.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||c),context:i,ruleFromNode(d){return d.nodeName=="BR"&&!d.nextSibling&&d.parentNode&&!cg.test(d.parentNode.nodeName)?{ignore:!0}:null}})),c)l=mg(rl(l,+c[1],+c[2]),c[4]);else if(l=M.maxOpen(hg(l.content,i),!0),l.openStart||l.openEnd){let h=0,d=0;for(let f=l.content.firstChild;h<l.openStart&&!f.type.spec.isolating;h++,f=f.firstChild);for(let f=l.content.lastChild;d<l.openEnd&&!f.type.spec.isolating;d++,f=f.lastChild);l=rl(l,h,d)}return n.someProp("transformPasted",h=>{l=h(l,n,a)}),l}const cg=/^(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 hg(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let i=e.node(t).contentMatchAt(e.index(t)),s,o=[];if(n.forEach(l=>{if(!o)return;let a=i.findWrapping(l.type),u;if(!a)return o=null;if(u=o.length&&s.length&&iu(a,s,l,o[o.length-1],0))o[o.length-1]=u;else{o.length&&(o[o.length-1]=su(o[o.length-1],s.length));let c=ru(l,a);o.push(c),i=i.matchType(c.type),s=a}}),o)return T.from(o)}return n}function ru(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,T.from(n));return n}function iu(n,e,t,r,i){if(i<n.length&&i<e.length&&n[i]==e[i]){let s=iu(n,e,t,r.lastChild,i+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(i==n.length-1?t.type:n[i+1]))return r.copy(r.content.append(T.from(ru(t,n,i+1))))}}function su(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,su(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(T.empty,!0);return n.copy(t.append(r))}function Zi(n,e,t,r,i,s){let o=e<0?n.firstChild:n.lastChild,l=o.content;return n.childCount>1&&(s=0),i<r-1&&(l=Zi(l,e,t,r,i+1,s)),i>=t&&(l=e<0?o.contentMatchAt(0).fillBefore(l,s<=i).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(T.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,o.copy(l))}function rl(n,e,t){return e<n.openStart&&(n=new M(Zi(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new M(Zi(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const ou={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let il=null;function lu(){return il||(il=document.implementation.createHTMLDocument("title"))}let si=null;function fg(n){let e=window.trustedTypes;return e?(si||(si=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),si.createHTML(n)):n}function dg(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=lu().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),i;if((i=r&&ou[r[1].toLowerCase()])&&(n=i.map(s=>"<"+s+">").join("")+n+i.map(s=>"</"+s+">").reverse().join("")),t.innerHTML=fg(n),i)for(let s=0;s<i.length;s++)t=t.querySelector(i[s])||t;return t}function pg(n){let e=n.querySelectorAll(ee?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function mg(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:i,openStart:s,openEnd:o}=n;for(let l=r.length-2;l>=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;i=T.from(a.create(r[l+1],i)),s++,o++}return new M(i,s,o)}const he={},fe={},gg={touchstart:!0,touchmove:!0};class yg{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function kg(n){for(let e in he){let t=he[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{bg(n,r)&&!Ps(n,r)&&(n.editable||!(r.type in fe))&&t(n,r)},gg[e]?{passive:!0}:void 0)}le&&n.dom.addEventListener("input",()=>null),es(n)}function ut(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function xg(n){n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function es(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>Ps(n,r))})}function Ps(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function bg(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function Sg(n,e){!Ps(n,e)&&he[e.type]&&(n.editable||!(e.type in fe))&&he[e.type](n,e)}fe.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!uu(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(Xe&&ee&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),Zt&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",i=>i(n,wt(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||ug(n,t)?t.preventDefault():ut(n,"key")};fe.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};fe.keypress=(n,e)=>{let t=e;if(uu(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||we&&t.metaKey)return;if(n.someProp("handleKeyPress",i=>i(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof j)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(t.charCode),s=()=>n.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!n.someProp("handleTextInput",o=>o(n,r.$from.pos,r.$to.pos,i,s))&&n.dispatch(s()),t.preventDefault()}};function zr(n){return{left:n.clientX,top:n.clientY}}function wg(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function Fs(n,e,t,r,i){if(r==-1)return!1;let s=n.state.doc.resolve(r);for(let o=s.depth+1;o>0;o--)if(n.someProp(e,l=>o>s.depth?l(n,t,s.nodeAfter,s.before(o),i,!0):l(n,t,s.node(o),s.before(o),i,!1)))return!0;return!1}function Ht(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function Cg(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&D.isSelectable(r)?(Ht(n,new D(t)),!0):!1}function Tg(n,e){if(e==-1)return!1;let t=n.state.selection,r,i;t instanceof D&&(r=t.node);let s=n.state.doc.resolve(e);for(let o=s.depth+1;o>0;o--){let l=o>s.depth?s.nodeAfter:s.node(o);if(D.isSelectable(l)){r&&t.$from.depth>0&&o>=t.$from.depth&&s.before(t.$from.depth+1)==t.$from.pos?i=s.before(t.$from.depth):i=s.before(o);break}}return i!=null?(Ht(n,D.create(n.state.doc,i)),!0):!1}function Mg(n,e,t,r,i){return Fs(n,"handleClickOn",e,t,r)||n.someProp("handleClick",s=>s(n,e,r))||(i?Tg(n,t):Cg(n,t))}function Ng(n,e,t,r){return Fs(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",i=>i(n,e,r))}function Og(n,e,t,r){return Fs(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",i=>i(n,e,r))||Eg(n,t,r)}function Eg(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(Ht(n,j.create(r,0,r.content.size)),!0):!1;let i=r.resolve(e);for(let s=i.depth+1;s>0;s--){let o=s>i.depth?i.nodeAfter:i.node(s),l=i.before(s);if(o.inlineContent)Ht(n,j.create(r,l+1,l+1+o.content.size));else if(D.isSelectable(o))Ht(n,D.create(r,l));else continue;return!0}}function Bs(n){return br(n)}const au=we?"metaKey":"ctrlKey";he.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=Bs(n),i=Date.now(),s="singleClick";i-n.input.lastClick.time<500&&wg(t,n.input.lastClick)&&!t[au]&&n.input.lastClick.button==t.button&&(n.input.lastClick.type=="singleClick"?s="doubleClick":n.input.lastClick.type=="doubleClick"&&(s="tripleClick")),n.input.lastClick={time:i,x:t.clientX,y:t.clientY,type:s,button:t.button};let o=n.posAtCoords(zr(t));o&&(s=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new Ig(n,o,t,!!r)):(s=="doubleClick"?Ng:Og)(n,o.pos,o.inside,t)?t.preventDefault():ut(n,"pointer"))};class Ig{constructor(e,t,r,i){this.view=e,this.pos=t,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[au],this.allowDefault=r.shiftKey;let s,o;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),o=t.inside;else{let c=e.state.doc.resolve(t.pos);s=c.parent,o=c.depth?c.before():0}const l=i?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.nodeDOM.nodeType==1?a.nodeDOM:null;let{selection:u}=e.state;(r.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||u instanceof D&&u.from<=o&&u.to>o)&&(this.mightDrag={node:s,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Me&&!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)),ut(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(()=>Ze(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(zr(e))),this.updateAllowDefault(e),this.allowDefault||!t?ut(this.view,"pointer"):Mg(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||le&&this.mightDrag&&!this.mightDrag.node.isAtom||ee&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(Ht(this.view,W.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):ut(this.view,"pointer")}move(e){this.updateAllowDefault(e),ut(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)}}he.touchstart=n=>{n.input.lastTouch=Date.now(),Bs(n),ut(n,"pointer")};he.touchmove=n=>{n.input.lastTouch=Date.now(),ut(n,"pointer")};he.contextmenu=n=>Bs(n);function uu(n,e){return n.composing?!0:le&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const Ag=Xe?5e3:-1;fe.compositionstart=fe.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof j&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||ee&&_a&&Dg(n)))n.markCursor=n.state.storedMarks||t.marks(),br(n,!0),n.markCursor=null;else if(br(n,!e.selection.empty),Me&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let i=r.focusNode,s=r.focusOffset;i&&i.nodeType==1&&s!=0;){let o=s<0?i.lastChild:i.childNodes[s-1];if(!o)break;if(o.nodeType==3){let l=n.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else i=o,s=-1}}n.input.composing=!0}cu(n,Ag)};function Dg(n){let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(!e||e.nodeType!=1||t>=e.childNodes.length)return!1;let r=e.childNodes[t];return r.nodeType==1&&r.contentEditable=="false"}fe.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.badSafariComposition?n.domObserver.forceFlush():n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,cu(n,20))};function cu(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>br(n),e))}function hu(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=zg());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function Rg(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=Tm(e.focusNode,e.focusOffset),r=Mm(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let i=r.pmViewDesc,s=n.domObserver.lastChangedTextNode;if(t==s||r==s)return s;if(!i||!i.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let o=t.pmViewDesc;if(!(!o||!o.isText(t.nodeValue)))return r}}return t||r}function zg(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function br(n,e=!1){if(!(Xe&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),hu(n),e||n.docView&&n.docView.dirty){let t=Ds(n),r=n.state.selection;return t&&!t.eq(r)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function Pg(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const In=me&&ct<15||Zt&&Im<604;he.copy=fe.cut=(n,e)=>{let t=e,r=n.state.selection,i=t.type=="cut";if(r.empty)return;let s=In?null:t.clipboardData,o=r.content(),{dom:l,text:a}=zs(n,o);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):Pg(n,l),i&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Fg(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function Bg(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?An(n,r.value,null,i,e):An(n,r.textContent,r.innerHTML,i,e)},50)}function An(n,e,t,r,i){let s=nu(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,i,s||M.empty)))return!0;if(!s)return!1;let o=Fg(s),l=o?n.state.tr.replaceSelectionWith(o,r):n.state.tr.replaceSelection(s);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function fu(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}fe.paste=(n,e)=>{let t=e;if(n.composing&&!Xe)return;let r=In?null:t.clipboardData,i=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&An(n,fu(r),r.getData("text/html"),i,t)?t.preventDefault():Bg(n,t)};class du{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const vg=we?"altKey":"ctrlKey";function pu(n,e){let t=n.someProp("dragCopies",r=>!r(e));return t??!e[vg]}he.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let i=n.state.selection,s=i.empty?null:n.posAtCoords(zr(t)),o;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof D?i.to-1:i.to))){if(r&&r.mightDrag)o=D.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let h=n.docView.nearestDesc(t.target,!0);h&&h.node.type.spec.draggable&&h!=n.docView&&(o=D.create(n.state.doc,h.posBefore))}}let l=(o||n.state.selection).content(),{dom:a,text:u,slice:c}=zs(n,l);(!t.dataTransfer.files.length||!ee||Va>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(In?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",In||t.dataTransfer.setData("text/plain",u),n.dragging=new du(c,pu(n,t),o)};he.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};fe.dragover=fe.dragenter=(n,e)=>e.preventDefault();fe.drop=(n,e)=>{try{Lg(n,e,n.dragging)}finally{n.dragging=null}};function Lg(n,e,t){if(!e.dataTransfer)return;let r=n.posAtCoords(zr(e));if(!r)return;let i=n.state.doc.resolve(r.pos),s=t&&t.slice;s?n.someProp("transformPasted",f=>{s=f(s,n,!1)}):s=nu(n,fu(e.dataTransfer),In?null:e.dataTransfer.getData("text/html"),!1,i);let o=!!(t&&pu(n,e));if(n.someProp("handleDrop",f=>f(n,e,s||M.empty,o))){e.preventDefault();return}if(!s)return;e.preventDefault();let l=s?Op(n.state.doc,i.pos,s):i.pos;l==null&&(l=i.pos);let a=n.state.tr;if(o){let{node:f}=t;f?f.replace(a):a.deleteSelection()}let u=a.mapping.map(l),c=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,h=a.doc;if(c?a.replaceRangeWith(u,u,s.content.firstChild):a.replaceRange(u,u,s),a.doc.eq(h))return;let d=a.doc.resolve(u);if(c&&D.isSelectable(s.content.firstChild)&&d.nodeAfter&&d.nodeAfter.sameMarkup(s.content.firstChild))a.setSelection(new D(d));else{let f=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((p,y,x,k)=>f=k),a.setSelection(Rs(n,d,a.doc.resolve(f)))}n.focus(),n.dispatch(a.setMeta("uiEvent","drop"))}he.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&Ze(n)},20))};he.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)};he.beforeinput=(n,e)=>{if(ee&&Xe&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",s=>s(n,wt(8,"Backspace")))))return;let{$cursor:i}=n.state.selection;i&&i.pos>0&&n.dispatch(n.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let n in fe)he[n]=fe[n];function Dn(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class Sr{constructor(e,t){this.toDOM=e,this.spec=t||Ot,this.side=this.spec.side||0}map(e,t,r,i){let{pos:s,deleted:o}=e.mapResult(t.from+i,this.side<0?-1:1);return o?null:new ze(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Sr&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Dn(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class ft{constructor(e,t){this.attrs=e,this.spec=t||Ot}map(e,t,r,i){let s=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-r,o=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-r;return s>=o?null:new ze(s,o,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof ft&&Dn(this.attrs,e.attrs)&&Dn(this.spec,e.spec)}static is(e){return e.type instanceof ft}destroy(){}}class vs{constructor(e,t){this.attrs=e,this.spec=t||Ot}map(e,t,r,i){let s=e.mapResult(t.from+i,1);if(s.deleted)return null;let o=e.mapResult(t.to+i,-1);return o.deleted||o.pos<=s.pos?null:new ze(s.pos-r,o.pos-r,this)}valid(e,t){let{index:r,offset:i}=e.content.findIndex(t.from),s;return i==t.from&&!(s=e.child(r)).isText&&i+s.nodeSize==t.to}eq(e){return this==e||e instanceof vs&&Dn(this.attrs,e.attrs)&&Dn(this.spec,e.spec)}destroy(){}}class ze{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new ze(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new ze(e,e,new Sr(t,r))}static inline(e,t,r,i){return new ze(e,t,new ft(r,i))}static node(e,t,r,i){return new ze(e,t,new vs(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof ft}get widget(){return this.type instanceof Sr}}const qt=[],Ot={};class Z{constructor(e,t){this.local=e.length?e:qt,this.children=t.length?t:qt}static create(e,t){return t.length?wr(t,e,0,Ot):ue}find(e,t,r){let i=[];return this.findInner(e??0,t??1e9,i,0,r),i}findInner(e,t,r,i,s){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=t&&l.to>=e&&(!s||s(l.spec))&&r.push(l.copy(l.from+i,l.to+i))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<t&&this.children[o+1]>e){let l=this.children[o]+1;this.children[o+2].findInner(e-l,t-l,r,i+l,s)}}map(e,t,r){return this==ue||e.maps.length==0?this:this.mapInner(e,t,0,0,r||Ot)}mapInner(e,t,r,i,s){let o;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,i);a&&a.type.valid(t,a)?(o||(o=[])).push(a):s.onRemove&&s.onRemove(this.local[l].spec)}return this.children.length?Vg(this.children,o||[],e,t,r,i,s):o?new Z(o.sort(Et),qt):ue}add(e,t){return t.length?this==ue?Z.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let i,s=0;e.forEach((l,a)=>{let u=a+r,c;if(c=gu(t,l,u)){for(i||(i=this.children.slice());s<i.length&&i[s]<a;)s+=3;i[s]==a?i[s+2]=i[s+2].addInner(l,c,u+1):i.splice(s,0,a,a+l.nodeSize,wr(c,l,u+1,Ot)),s+=3}});let o=mu(s?yu(t):t,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new Z(o.length?this.local.concat(o).sort(Et):this.local,i||this.children)}remove(e){return e.length==0||this==ue?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,i=this.local;for(let s=0;s<r.length;s+=3){let o,l=r[s]+t,a=r[s+1]+t;for(let c=0,h;c<e.length;c++)(h=e[c])&&h.from>l&&h.to<a&&(e[c]=null,(o||(o=[])).push(h));if(!o)continue;r==this.children&&(r=this.children.slice());let u=r[s+2].removeInner(o,l+1);u!=ue?r[s+2]=u:(r.splice(s,3),s-=3)}if(i.length){for(let s=0,o;s<e.length;s++)if(o=e[s])for(let l=0;l<i.length;l++)i[l].eq(o,t)&&(i==this.local&&(i=this.local.slice()),i.splice(l--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new Z(i,r):ue}forChild(e,t){if(this==ue)return this;if(t.isLeaf)return Z.empty;let r,i;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let s=e+1,o=s+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<o&&a.to>s&&a.type instanceof ft){let u=Math.max(s,a.from)-s,c=Math.min(o,a.to)-s;u<c&&(i||(i=[])).push(a.copy(u,c))}}if(i){let l=new Z(i.sort(Et),qt);return r?new ot([l,r]):l}return r||ue}eq(e){if(this==e)return!0;if(!(e instanceof Z)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return Ls(this.localsInner(e))}localsInner(e){if(this==ue)return qt;if(e.inlineContent||!this.local.some(ft.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof ft||t.push(this.local[r]);return t}forEachSet(e){e(this)}}Z.empty=new Z([],[]);Z.removeOverlap=Ls;const ue=Z.empty;class ot{constructor(e){this.members=e}map(e,t){const r=this.members.map(i=>i.map(e,t,Ot));return ot.from(r)}forChild(e,t){if(t.isLeaf)return Z.empty;let r=[];for(let i=0;i<this.members.length;i++){let s=this.members[i].forChild(e,t);s!=ue&&(s instanceof ot?r=r.concat(s.members):r.push(s))}return ot.from(r)}eq(e){if(!(e instanceof ot)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,r=!0;for(let i=0;i<this.members.length;i++){let s=this.members[i].localsInner(e);if(s.length)if(!t)t=s;else{r&&(t=t.slice(),r=!1);for(let o=0;o<s.length;o++)t.push(s[o])}}return t?Ls(r?t:t.sort(Et)):qt}static from(e){switch(e.length){case 0:return ue;case 1:return e[0];default:return new ot(e.every(t=>t instanceof Z)?e:e.reduce((t,r)=>t.concat(r instanceof Z?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function Vg(n,e,t,r,i,s,o){let l=n.slice();for(let u=0,c=s;u<t.maps.length;u++){let h=0;t.maps[u].forEach((d,f,p,y)=>{let x=y-p-(f-d);for(let k=0;k<l.length;k+=3){let I=l[k+1];if(I<0||d>I+c-h)continue;let C=l[k]+c-h;f>=C?l[k+1]=d<=C?-2:-1:d>=c&&x&&(l[k]+=x,l[k+1]+=x)}h+=x}),c=t.maps[u].map(c,-1)}let a=!1;for(let u=0;u<l.length;u+=3)if(l[u+1]<0){if(l[u+1]==-2){a=!0,l[u+1]=-1;continue}let c=t.map(n[u]+s),h=c-i;if(h<0||h>=r.content.size){a=!0;continue}let d=t.map(n[u+1]+s,-1),f=d-i,{index:p,offset:y}=r.content.findIndex(h),x=r.maybeChild(p);if(x&&y==h&&y+x.nodeSize==f){let k=l[u+2].mapInner(t,x,c+1,n[u]+s+1,o);k!=ue?(l[u]=h,l[u+1]=f,l[u+2]=k):(l[u+1]=-2,a=!0)}else a=!0}if(a){let u=_g(l,n,e,t,i,s,o),c=wr(u,r,0,o);e=c.local;for(let h=0;h<l.length;h+=3)l[h+1]<0&&(l.splice(h,3),h-=3);for(let h=0,d=0;h<c.children.length;h+=3){let f=c.children[h];for(;d<l.length&&l[d]<f;)d+=3;l.splice(d,0,c.children[h],c.children[h+1],c.children[h+2])}}return new Z(e.sort(Et),l)}function mu(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let i=n[r];t.push(new ze(i.from+e,i.to+e,i.type))}return t}function _g(n,e,t,r,i,s,o){function l(a,u){for(let c=0;c<a.local.length;c++){let h=a.local[c].map(r,i,u);h?t.push(h):o.onRemove&&o.onRemove(a.local[c].spec)}for(let c=0;c<a.children.length;c+=3)l(a.children[c+2],a.children[c]+u+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+s+1);return t}function gu(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,i=null;for(let s=0,o;s<n.length;s++)(o=n[s])&&o.from>t&&o.to<r&&((i||(i=[])).push(o),n[s]=null);return i}function yu(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function wr(n,e,t,r){let i=[],s=!1;e.forEach((l,a)=>{let u=gu(n,l,a+t);if(u){s=!0;let c=wr(u,l,t+a+1,r);c!=ue&&i.push(a,a+l.nodeSize,c)}});let o=mu(s?yu(n):n,-t).sort(Et);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||(r.onRemove&&r.onRemove(o[l].spec),o.splice(l--,1));return o.length||i.length?new Z(o,i):ue}function Et(n,e){return n.from-e.from||n.to-e.to}function Ls(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let i=t+1;i<e.length;i++){let s=e[i];if(s.from==r.from){s.to!=r.to&&(e==n&&(e=n.slice()),e[i]=s.copy(s.from,r.to),sl(e,i+1,s.copy(r.to,s.to)));continue}else{s.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,s.from),sl(e,i,r.copy(s.from,r.to)));break}}}return e}function sl(n,e,t){for(;e<n.length&&Et(t,n[e])>0;)e++;n.splice(e,0,t)}function oi(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=ue&&e.push(r)}),n.cursorWrapper&&e.push(Z.create(n.state.doc,[n.cursorWrapper.deco])),ot.from(e)}const $g={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},qg=me&&ct<=11;class Wg{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 jg{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Wg,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;i<r.length;i++)this.queue.push(r[i]);me&&ct<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():le&&e.composing&&r.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),qg&&(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,$g)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(Go(this.view)){if(this.suppressingSelectionUpdates)return Ze(this.view);if(me&&ct<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Rt(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,r;for(let s=e.focusNode;s;s=Xt(s))t.add(s);for(let s=e.anchorNode;s;s=Xt(s))if(t.has(s)){r=s;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&Go(e)&&!this.ignoreSelectionChange(r),s=-1,o=-1,l=!1,a=[];if(e.editable)for(let c=0;c<t.length;c++){let h=this.registerMutation(t[c],a);h&&(s=s<0?h.from:Math.min(h.from,s),o=o<0?h.to:Math.max(h.to,o),h.typeOver&&(l=!0))}if(Me&&a.length){let c=a.filter(h=>h.nodeName=="BR");if(c.length==2){let[h,d]=c;h.parentNode&&h.parentNode.parentNode==d.parentNode?d.remove():h.remove()}else{let{focusNode:h}=this.currentSelection;for(let d of c){let f=d.parentNode;f&&f.nodeName=="LI"&&(!h||Kg(e,h)!=f)&&d.remove()}}}else if((ee||le)&&a.some(c=>c.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let c of a)if(c.nodeName=="BR"&&c.parentNode){let h=c.nextSibling;h&&h.nodeType==1&&h.contentEditable=="false"&&c.parentNode.removeChild(c)}}let u=null;s<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Dr(r)&&(u=Ds(e))&&u.eq(W.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Ze(e),this.currentSelection.set(r),e.scrollToSelection()):(s>-1||i)&&(s>-1&&(e.docView.markDirty(s,o),Jg(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,Ug(e,a)),this.handleDOMChange(s,o,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Ze(e),this.currentSelection.set(r))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let c=0;c<e.addedNodes.length;c++){let h=e.addedNodes[c];t.push(h),h.nodeType==3&&(this.lastChangedTextNode=h)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,s=e.nextSibling;if(me&&ct<=11&&e.addedNodes.length)for(let c=0;c<e.addedNodes.length;c++){let{previousSibling:h,nextSibling:d}=e.addedNodes[c];(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(i=h),(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(s=d)}let o=i&&i.parentNode==e.target?oe(i)+1:0,l=r.localPosFromDOM(e.target,o,-1),a=s&&s.parentNode==e.target?oe(s):e.target.childNodes.length,u=r.localPosFromDOM(e.target,a,1);return{from:l,to:u}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let ol=new WeakMap,ll=!1;function Jg(n){if(!ol.has(n)&&(ol.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=Me,ll)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),ll=!0}}function al(n,e){let t=e.startContainer,r=e.startOffset,i=e.endContainer,s=e.endOffset,o=n.domAtPos(n.state.selection.anchor);return Rt(o.node,o.offset,i,s)&&([t,r,i,s]=[i,s,t,r]),{anchorNode:t,anchorOffset:r,focusNode:i,focusOffset:s}}function Hg(n,e){if(e.getComposedRanges){let i=e.getComposedRanges(n.root)[0];if(i)return al(n,i)}let t;function r(i){i.preventDefault(),i.stopImmediatePropagation(),t=i.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",r,!0),t?al(n,t):null}function Kg(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let r=n.docView.nearestDesc(t,!0);if(r&&r.node.isBlock)return t}return null}function Ug(n,e){var t;let{focusNode:r,focusOffset:i}=n.domSelectionRange();for(let s of e)if(((t=s.parentNode)===null||t===void 0?void 0:t.nodeName)=="TR"){let o=s.nextSibling;for(;o&&o.nodeName!="TD"&&o.nodeName!="TH";)o=o.nextSibling;if(o){let l=o;for(;;){let a=l.firstChild;if(!a||a.nodeType!=1||a.contentEditable=="false"||/^(BR|IMG)$/.test(a.nodeName))break;l=a}l.insertBefore(s,l.firstChild),r==s&&n.domSelection().collapse(s,i)}else s.parentNode.removeChild(s)}}function Yg(n,e,t){let{node:r,fromOffset:i,toOffset:s,from:o,to:l}=n.docView.parseRange(e,t),a=n.domSelectionRange(),u,c=a.anchorNode;if(c&&n.dom.contains(c.nodeType==1?c:c.parentNode)&&(u=[{node:c,offset:a.anchorOffset}],Dr(a)||u.push({node:a.focusNode,offset:a.focusOffset})),ee&&n.input.lastKeyCode===8)for(let x=s;x>i;x--){let k=r.childNodes[x-1],I=k.pmViewDesc;if(k.nodeName=="BR"&&!I){s=x;break}if(!I||I.size)break}let h=n.state.doc,d=n.someProp("domParser")||Yt.fromSchema(n.state.schema),f=h.resolve(o),p=null,y=d.parse(r,{topNode:f.parent,topMatch:f.parent.contentMatchAt(f.index()),topOpen:!0,from:i,to:s,preserveWhitespace:f.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:Qg,context:f});if(u&&u[0].pos!=null){let x=u[0].pos,k=u[1]&&u[1].pos;k==null&&(k=x),p={anchor:x+o,head:k+o}}return{doc:y,sel:p,from:o,to:l}}function Qg(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(le&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||le&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}const Gg=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Xg(n,e,t,r,i){let s=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let N=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,P=Ds(n,N);if(P&&!n.state.selection.eq(P)){if(ee&&Xe&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",J=>J(n,wt(13,"Enter"))))return;let z=n.state.tr.setSelection(P);N=="pointer"?z.setMeta("pointer",!0):N=="key"&&z.scrollIntoView(),s&&z.setMeta("composition",s),n.dispatch(z)}return}let o=n.state.doc.resolve(e),l=o.sharedDepth(t);e=o.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,u=Yg(n,e,t),c=n.state.doc,h=c.slice(u.from,u.to),d,f;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(d=n.state.selection.to,f="end"):(d=n.state.selection.from,f="start"),n.input.lastKeyCode=null;let p=ty(h.content,u.doc.content,u.from,d,f);if(p&&n.input.domChangeCount++,(Zt&&n.input.lastIOSEnter>Date.now()-225||Xe)&&i.some(N=>N.nodeType==1&&!Gg.test(N.nodeName))&&(!p||p.endA>=p.endB)&&n.someProp("handleKeyDown",N=>N(n,wt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof j&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(u.sel&&u.sel.anchor!=u.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(u.sel){let N=ul(n,n.state.doc,u.sel);if(N&&!N.eq(n.state.selection)){let P=n.state.tr.setSelection(N);s&&P.setMeta("composition",s),n.dispatch(P)}}return}n.state.selection.from<n.state.selection.to&&p.start==p.endB&&n.state.selection instanceof j&&(p.start>n.state.selection.from&&p.start<=n.state.selection.from+2&&n.state.selection.from>=u.from?p.start=n.state.selection.from:p.endA<n.state.selection.to&&p.endA>=n.state.selection.to-2&&n.state.selection.to<=u.to&&(p.endB+=n.state.selection.to-p.endA,p.endA=n.state.selection.to)),me&&ct<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>u.from&&u.doc.textBetween(p.start-u.from-1,p.start-u.from+1)=="  "&&(p.start--,p.endA--,p.endB--);let y=u.doc.resolveNoCache(p.start-u.from),x=u.doc.resolveNoCache(p.endB-u.from),k=c.resolve(p.start),I=y.sameParent(x)&&y.parent.inlineContent&&k.end()>=p.endA;if((Zt&&n.input.lastIOSEnter>Date.now()-225&&(!I||i.some(N=>N.nodeName=="DIV"||N.nodeName=="P"))||!I&&y.pos<u.doc.content.size&&(!y.sameParent(x)||!y.parent.inlineContent)&&y.pos<x.pos&&!/\S/.test(u.doc.textBetween(y.pos,x.pos,"","")))&&n.someProp("handleKeyDown",N=>N(n,wt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>p.start&&ey(c,p.start,p.endA,y,x)&&n.someProp("handleKeyDown",N=>N(n,wt(8,"Backspace")))){Xe&&ee&&n.domObserver.suppressSelectionUpdates();return}ee&&p.endB==p.start&&(n.input.lastChromeDelete=Date.now()),Xe&&!I&&y.start()!=x.start()&&x.parentOffset==0&&y.depth==x.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==p.endA&&(p.endB-=2,x=u.doc.resolveNoCache(p.endB-u.from),setTimeout(()=>{n.someProp("handleKeyDown",function(N){return N(n,wt(13,"Enter"))})},20));let C=p.start,B=p.endA,$=N=>{let P=N||n.state.tr.replace(C,B,u.doc.slice(p.start-u.from,p.endB-u.from));if(u.sel){let z=ul(n,P.doc,u.sel);z&&!(ee&&n.composing&&z.empty&&(p.start!=p.endB||n.input.lastChromeDelete<Date.now()-100)&&(z.head==C||z.head==P.mapping.map(B)-1)||me&&z.empty&&z.head==C)&&P.setSelection(z)}return s&&P.setMeta("composition",s),P.scrollIntoView()},S;if(I)if(y.pos==x.pos){me&&ct<=11&&y.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>Ze(n),20));let N=$(n.state.tr.delete(C,B)),P=c.resolve(p.start).marksAcross(c.resolve(p.endA));P&&N.ensureMarks(P),n.dispatch(N)}else if(p.endA==p.endB&&(S=Zg(y.parent.content.cut(y.parentOffset,x.parentOffset),k.parent.content.cut(k.parentOffset,p.endA-k.start())))){let N=$(n.state.tr);S.type=="add"?N.addMark(C,B,S.mark):N.removeMark(C,B,S.mark),n.dispatch(N)}else if(y.parent.child(y.index()).isText&&y.index()==x.index()-(x.textOffset?0:1)){let N=y.parent.textBetween(y.parentOffset,x.parentOffset),P=()=>$(n.state.tr.insertText(N,C,B));n.someProp("handleTextInput",z=>z(n,C,B,N,P))||n.dispatch(P())}else n.dispatch($());else n.dispatch($())}function ul(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:Rs(n,e.resolve(t.anchor),e.resolve(t.head))}function Zg(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,i=t,s=r,o,l,a;for(let c=0;c<r.length;c++)i=r[c].removeFromSet(i);for(let c=0;c<t.length;c++)s=t[c].removeFromSet(s);if(i.length==1&&s.length==0)l=i[0],o="add",a=c=>c.mark(l.addToSet(c.marks));else if(i.length==0&&s.length==1)l=s[0],o="remove",a=c=>c.mark(l.removeFromSet(c.marks));else return null;let u=[];for(let c=0;c<e.childCount;c++)u.push(a(e.child(c)));if(T.from(u).eq(n))return{mark:l,type:o}}function ey(n,e,t,r,i){if(t-e<=i.pos-r.pos||li(r,!0,!1)<i.pos)return!1;let s=n.resolve(e);if(!r.parent.isTextblock){let l=s.nodeAfter;return l!=null&&t==e+l.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let o=n.resolve(li(s,!0,!0));return!o.parent.isTextblock||o.pos>t||li(o,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function li(n,e,t){let r=n.depth,i=e?n.end():n.pos;for(;r>0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,i++,e=!1;if(t){let s=n.node(r).maybeChild(n.indexAfter(r));for(;s&&!s.isLeaf;)s=s.firstChild,i++}return i}function ty(n,e,t,r,i){let s=n.findDiffStart(e,t);if(s==null)return null;let{a:o,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(i=="end"){let a=Math.max(0,s-Math.min(o,l));r-=o+a-s}if(o<s&&n.size<e.size){let a=r<=s&&r>=o?s-r:0;s-=a,s&&s<e.size&&cl(e.textBetween(s-1,s+1))&&(s+=a?1:-1),l=s+(l-o),o=s}else if(l<s){let a=r<=s&&r>=l?s-r:0;s-=a,s&&s<n.size&&cl(n.textBetween(s-1,s+1))&&(s+=a?1:-1),o=s+(o-l),l=s}return{start:s,endA:o,endB:l}}function cl(n){if(n.length!=2)return!1;let e=n.charCodeAt(0),t=n.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}class ku{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new yg,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(ml),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=dl(this),fl(this),this.nodeViews=pl(this),this.docView=Jo(this.state.doc,hl(this),oi(this),this.dom,this),this.domObserver=new jg(this,(r,i,s,o)=>Xg(this,r,i,s,o)),this.domObserver.start(),kg(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&es(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(ml),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let i=this.state,s=!1,o=!1;e.storedMarks&&this.composing&&(hu(this),o=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let f=pl(this);ry(f,this.nodeViews)&&(this.nodeViews=f,s=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&es(this),this.editable=dl(this),fl(this);let a=oi(this),u=hl(this),c=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",h=s||!this.docView.matchesNode(e.doc,u,a);(h||!e.selection.eq(i.selection))&&(o=!0);let d=c=="preserve"&&o&&this.dom.style.overflowAnchor==null&&Rm(this);if(o){this.domObserver.stop();let f=h&&(me||ee)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&ny(i.selection,e.selection);if(h){let p=ee?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Rg(this)),(s||!this.docView.update(e.doc,u,a,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=Jo(e.doc,u,a,this.dom,this)),p&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(f=!0)}f||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&ng(this))?Ze(this,f):(Za(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),c=="reset"?this.dom.scrollTop=0:c=="to selection"?this.scrollToSelection():d&&zm(d)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof D){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Vo(this,t.getBoundingClientRect(),e)}else Vo(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let r=this.directPlugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let r=this.state.plugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let r=this.pluginViews[t];r.update&&r.update(this,e)}}updateDraggedNode(e,t){let r=e.node,i=-1;if(this.state.doc.nodeAt(r.from)==r.node)i=r.from;else{let s=r.from+(this.state.doc.content.size-t.doc.content.size);(s>0&&this.state.doc.nodeAt(s))==r.node&&(i=s)}this.dragging=new du(e.slice,e.move,i<0?void 0:D.create(this.state.doc,i))}someProp(e,t){let r=this._props&&this._props[e],i;if(r!=null&&(i=t?t(r):r))return i;for(let o=0;o<this.directPlugins.length;o++){let l=this.directPlugins[o].props[e];if(l!=null&&(i=t?t(l):l))return i}let s=this.state.plugins;if(s)for(let o=0;o<s.length;o++){let l=s[o].props[e];if(l!=null&&(i=t?t(l):l))return i}}hasFocus(){if(me){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&Pm(this.dom),Ze(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Vm(this,e)}coordsAtPos(e,t=1){return Ja(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,r=-1){let i=this.docView.posFromDOM(e,t,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,t){return jm(this,t||this.state,e)}pasteHTML(e,t){return An(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return An(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return zs(this,e)}destroy(){this.docView&&(xg(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],oi(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,wm())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Sg(this,e)}domSelectionRange(){let e=this.domSelection();return e?le&&this.root.nodeType===11&&Om(this.dom.ownerDocument)==this.dom&&Hg(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}ku.prototype.dispatch=function(n){let e=this._props.dispatchTransaction;e?e.call(this,n):this.updateState(this.state.apply(n))};function hl(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[ze.node(0,n.state.doc.content.size,e)]}function fl(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:ze.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function dl(n){return!n.someProp("editable",e=>e(n.state)===!1)}function ny(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function pl(n){let e=Object.create(null);function t(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function ry(n,e){let t=0,r=0;for(let i in n){if(n[i]!=e[i])return!0;t++}for(let i in e)r++;return t!=r}function ml(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}function tt(n,e){return n.meta={package:"@milkdown/core",group:"System",...e},n}const xu={text:(n,e,t,r)=>{const i=n.value;return/^[^*_\\]*\s+$/.test(i)?i:t.safe(i,{...r,encode:[]})},strong:(n,e,t,r)=>{const i=n.marker||t.options.strong||"*",s=t.enter("strong"),o=t.createTracker(r);let l=o.move(i+i);return l+=o.move(t.containerPhrasing(n,{before:l,after:i,...o.current()})),l+=o.move(i+i),s(),l},emphasis:(n,e,t,r)=>{const i=n.marker||t.options.emphasis||"*",s=t.enter("emphasis"),o=t.createTracker(r);let l=o.move(i);return l+=o.move(t.containerPhrasing(n,{before:l,after:i,...o.current()})),l+=o.move(i),s(),l}},Kt=V({},"editorView"),kn=V({},"editorState"),ai=V([],"initTimer"),gl=V({},"editor"),ts=V([],"inputRules"),Rn=V([],"prosePlugins"),ns=V([],"remarkPlugins"),rs=V([],"nodeView"),is=V([],"markView"),It=V(vi().use(Di).use(Pi),"remark"),ui=V({handlers:xu,encode:[]},"remarkStringifyOptions"),tr=We("ConfigReady");function iy(n){const e=t=>(t.record(tr),async()=>(await n(t),t.done(tr),()=>{t.clearTimer(tr)}));return tt(e,{displayName:"Config"}),e}const Mn=We("InitReady");function sy(n){const e=t=>(t.inject(gl,n).inject(Rn,[]).inject(ns,[]).inject(ts,[]).inject(rs,[]).inject(is,[]).inject(ui,{handlers:xu,encode:[]}).inject(It,vi().use(Di).use(Pi)).inject(ai,[tr]).record(Mn),async()=>{await t.waitTimers(ai);const r=t.get(ui);return t.set(It,vi().use(Di).use(Pi,r)),t.done(Mn),()=>{t.remove(gl).remove(Rn).remove(ns).remove(ts).remove(rs).remove(is).remove(ui).remove(It).remove(ai).clearTimer(Mn)}});return tt(e,{displayName:"Init"}),e}const Fe=We("SchemaReady"),ci=V([],"schemaTimer"),Ut=V({},"schema"),hi=V([],"nodes"),fi=V([],"marks");function yl(n){return{...n,parseDOM:n.parseDOM?.map(e=>({priority:n.priority,...e}))}}const bu=n=>(n.inject(Ut,{}).inject(hi,[]).inject(fi,[]).inject(ci,[Mn]).record(Fe),async()=>{await n.waitTimers(ci);const e=n.get(It),r=n.get(ns).reduce((l,a)=>l.use(a.plugin,a.options),e);n.set(It,r);const i=Object.fromEntries(n.get(hi).map(([l,a])=>[l,yl(a)])),s=Object.fromEntries(n.get(fi).map(([l,a])=>[l,yl(a)])),o=new xc({nodes:i,marks:s});return n.set(Ut,o),n.done(Fe),()=>{n.remove(Ut).remove(hi).remove(fi).remove(ci).clearTimer(Fe)}});tt(bu,{displayName:"Schema"});class Su{constructor(){this.#t=new Sl,this.#e=null,this.setCtx=e=>{this.#e=e},this.chain=()=>{if(this.#e==null)throw Pr();const e=this.#e,t=[],r=this.get.bind(this),i={run:()=>{const o=tn(...t),l=e.get(Kt);return o(l.state,l.dispatch,l)},inline:o=>(t.push(o),i),pipe:s.bind(this)};function s(o,l){const a=r(o);return t.push(a(l)),i}return i}}#t;#e;get ctx(){return this.#e}create(e,t){const r=e.create(this.#t.sliceMap);return r.set(t),r}get(e){return this.#t.get(e).get()}remove(e){return this.#t.remove(e)}call(e,t){if(this.#e==null)throw Pr();const i=this.get(e)(t),s=this.#e.get(Kt);return i(s.state,s.dispatch,s)}inline(e){if(this.#e==null)throw Pr();const t=this.#e.get(Kt);return e(t.state,t.dispatch,t)}}function Ey(n="cmdKey"){return V((()=>()=>!1),n)}const kl=V(new Su,"commands"),di=V([Fe],"commandsTimer"),nr=We("CommandsReady"),wu=n=>{const e=new Su;return e.setCtx(n),n.inject(kl,e).inject(di,[Fe]).record(nr),async()=>(await n.waitTimers(di),n.done(nr),()=>{n.remove(kl).remove(di).clearTimer(nr)})};tt(wu,{displayName:"Commands"});function oy(n){const e=tn(sm,Ns,_p,Ra);return n.Backspace=e,n}class Cu{constructor(){this.#t=null,this.#e=[],this.setCtx=e=>{this.#t=e},this.add=e=>(this.#e.push(e),()=>{this.#e=this.#e.filter(t=>t!==e)}),this.addObjectKeymap=e=>{const t=[];return Object.entries(e).forEach(([r,i])=>{if(typeof i=="function"){const s={key:r,onRun:()=>i};this.#e.push(s),t.push(()=>{this.#e=this.#e.filter(o=>o!==s)})}else this.#e.push(i),t.push(()=>{this.#e=this.#e.filter(s=>s!==i)})}),()=>{t.forEach(r=>r())}},this.addBaseKeymap=()=>{const e=oy(rm);return this.addObjectKeymap(e)},this.build=()=>{const e={};return this.#e.forEach(r=>{e[r.key]=[...e[r.key]||[],r]}),Object.fromEntries(Object.entries(e).map(([r,i])=>{const s=i.sort((l,a)=>(a.priority??50)-(l.priority??50));return[r,(l,a,u)=>{const c=this.#t;if(c==null)throw Tr();const h=s.map(f=>f.onRun(c));return tn(...h)(l,a,u)}]}))}}#t;#e;get ctx(){return this.#t}}const ss=V(new Cu,"keymap"),pi=V([Fe],"keymapTimer"),rr=We("KeymapReady"),ly=n=>{const e=new Cu;return e.setCtx(n),n.inject(ss,e).inject(pi,[Fe]).record(rr),async()=>(await n.waitTimers(pi),n.done(rr),()=>{n.remove(ss).remove(pi).clearTimer(rr)})},ir=We("ParserReady"),Tu=(()=>{throw Tr()}),sr=V(Tu,"parser"),mi=V([],"parserTimer"),Mu=n=>(n.inject(sr,Tu).inject(mi,[Fe]).record(ir),async()=>{await n.waitTimers(mi);const e=n.get(It),t=n.get(Ut);return n.set(sr,lp.create(t,e)),n.done(ir),()=>{n.remove(sr).remove(mi).clearTimer(ir)}});tt(Mu,{displayName:"Parser"});const or=We("SerializerReady"),gi=V([],"serializerTimer"),Nu=(()=>{throw Tr()}),yi=V(Nu,"serializer"),Ou=n=>(n.inject(yi,Nu).inject(gi,[Fe]).record(or),async()=>{await n.waitTimers(gi);const e=n.get(It),t=n.get(Ut);return n.set(yi,up.create(t,e)),n.done(or),()=>{n.remove(yi).remove(gi).clearTimer(or)}});tt(Ou,{displayName:"Serializer"});const ki=V("","defaultValue"),xi=V(n=>n,"stateOptions"),bi=V([],"editorStateTimer"),lr=We("EditorStateReady");function ay(n,e,t){if(typeof n=="string")return e(n);if(n.type==="html")return Yt.fromSchema(t).parse(n.dom);if(n.type==="json")return Pe.fromJSON(t,n.value);throw ju(n)}const uy=new Ms("MILKDOWN_STATE_TRACKER"),Eu=n=>(n.inject(ki,"").inject(kn,{}).inject(xi,e=>e).inject(bi,[ir,or,nr,rr]).record(lr),async()=>{await n.waitTimers(bi);const e=n.get(Ut),t=n.get(sr),r=n.get(ts),i=n.get(xi),s=n.get(Rn),o=n.get(ki),l=ay(o,t,e),a=n.get(ss),u=a.addBaseKeymap(),c=[...s,new Ar({key:uy,state:{init:()=>{},apply:(f,p,y,x)=>{n.set(kn,x)}}}),hm({rules:r}),bm(a.build())];n.set(Rn,c);const h=i({schema:e,doc:l,plugins:c}),d=Wt.create(h);return n.set(kn,d),n.done(lr),()=>{u(),n.remove(ki).remove(kn).remove(xi).remove(bi).clearTimer(lr)}});tt(Eu,{displayName:"EditorState"});const ls=V([],"pasteRule"),Si=V([Fe],"pasteRuleTimer"),ar=We("PasteRuleReady"),Iu=n=>(n.inject(ls,[]).inject(Si,[Fe]).record(ar),async()=>(await n.waitTimers(Si),n.done(ar),()=>{n.remove(ls).remove(Si).clearTimer(ar)}));tt(Iu,{displayName:"PasteRule"});const wi=We("EditorViewReady"),Ci=V([],"editorViewTimer"),ur=V({},"editorViewOptions"),Ti=V(null,"root"),as=V(null,"rootDOM"),us=V({},"rootAttrs");function cy(n,e){const t=document.createElement("div");t.className="milkdown",n.appendChild(t),e.set(as,t);const r=e.get(us);return Object.entries(r).forEach(([i,s])=>t.setAttribute(i,s)),t}function hy(n){n.classList.add("editor"),n.setAttribute("role","textbox")}const fy=new Ms("MILKDOWN_VIEW_CLEAR"),Au=n=>(n.inject(Ti,document.body).inject(Kt,{}).inject(ur,{}).inject(as,null).inject(us,{}).inject(Ci,[lr,ar]).record(wi),async()=>{await n.wait(Mn);const e=n.get(Ti)||document.body,t=typeof e=="string"?document.querySelector(e):e;n.update(Rn,a=>[new Ar({key:fy,view:u=>{const c=t?cy(t,n):void 0;return(()=>{if(c&&t){const d=u.dom;t.replaceChild(c,d),c.appendChild(d)}})(),{destroy:()=>{c?.parentNode&&c?.parentNode.replaceChild(u.dom,c),c?.remove()}}}}),...a]),await n.waitTimers(Ci);const r=n.get(kn),i=n.get(ur),s=Object.fromEntries(n.get(rs)),o=Object.fromEntries(n.get(is)),l=new ku(t,{state:r,nodeViews:s,markViews:o,transformPasted:(a,u,c)=>(n.get(ls).sort((h,d)=>(d.priority??50)-(h.priority??50)).map(h=>h.run).forEach(h=>{a=h(a,u,c)}),a),...i});return hy(l.dom),n.set(Kt,l),n.done(wi),()=>{l?.destroy(),n.remove(Ti).remove(Kt).remove(ur).remove(as).remove(us).remove(Ci).clearTimer(wi)}});tt(Au,{displayName:"EditorView"});class Du{constructor(){this.#t=!1,this.#e="Idle",this.#r=[],this.#n=()=>{},this.#o=new Sl,this.#s=new Zu,this.#i=new Map,this.#l=new Map,this.#a=new cs(this.#o,this.#s),this.#d=()=>{const e=iy(async r=>{await Promise.all(this.#r.map(i=>Promise.resolve(i(r))))}),t=[bu,Mu,Ou,wu,ly,Iu,Eu,Au,sy(this),e];this.#c(t,this.#l)},this.#c=(e,t)=>{e.forEach(r=>{const i=this.#a.produce(this.#t?r.meta:void 0),s=r(i);t.set(r,{ctx:i,handler:s,cleanup:void 0})})},this.#h=(e,t=!1)=>Promise.all([e].flat().map(async r=>{const s=this.#i.get(r)?.cleanup;return t?this.#i.delete(r):this.#i.set(r,{ctx:void 0,handler:void 0,cleanup:void 0}),typeof s=="function"?s():s})),this.#p=async()=>{await Promise.all([...this.#l.entries()].map(async([e,{cleanup:t}])=>typeof t=="function"?t():t)),this.#l.clear()},this.#u=e=>{this.#e=e,this.#n(e)},this.#f=e=>[...e.entries()].map(async([t,r])=>{const{ctx:i,handler:s}=r;if(!s)return;const o=await s();e.set(t,{ctx:i,handler:s,cleanup:o})}),this.enableInspector=(e=!0)=>(this.#t=e,this),this.onStatusChange=e=>(this.#n=e,this),this.config=e=>(this.#r.push(e),this),this.removeConfig=e=>(this.#r=this.#r.filter(t=>t!==e),this),this.use=e=>{const t=[e].flat();return t.flat().forEach(r=>{this.#i.set(r,{ctx:void 0,handler:void 0,cleanup:void 0})}),this.#e==="Created"&&this.#c(t,this.#i),this},this.remove=async e=>this.#e==="OnCreate"?(console.warn("[Milkdown]: You are trying to remove plugins when the editor is creating, this is not recommended, please check your code."),new Promise(t=>{setTimeout(()=>{t(this.remove(e))},50)})):(await this.#h([e].flat(),!0),this),this.create=async()=>this.#e==="OnCreate"?this:(this.#e==="Created"&&await this.destroy(),this.#u("OnCreate"),this.#d(),this.#c([...this.#i.keys()],this.#i),await Promise.all([this.#f(this.#l),this.#f(this.#i)].flat()),this.#u("Created"),this),this.destroy=async(e=!1)=>this.#e==="Destroyed"||this.#e==="OnDestroy"?this:this.#e==="OnCreate"?new Promise(t=>{setTimeout(()=>{t(this.destroy(e))},50)}):(e&&(this.#r=[]),this.#u("OnDestroy"),await this.#h([...this.#i.keys()],e),await this.#p(),this.#u("Destroyed"),this),this.action=e=>e(this.#a),this.inspect=()=>this.#t?[...this.#l.values(),...this.#i.values()].map(({ctx:e})=>e?.inspector?.read()).filter(e=>!!e):(console.warn("[Milkdown]: You are trying to collect inspection when inspector is disabled, please enable inspector by `editor.enableInspector()` first."),[])}static make(){return new Du}#t;#e;#r;#n;#o;#s;#i;#l;#a;#d;#c;#h;#p;#u;#f;get ctx(){return this.#a}get status(){return this.#e}}function Iy(n){n.update(ur,e=>{const t=e.attributes;return{...e,attributes:r=>{const i=typeof t=="function"?t(r):t;return{...i,class:$u("prose dark:prose-invert",i?.class||"","milkdown-theme-nord")}}}})}export{Ty as $,Yf as A,wy as B,nr as C,en as D,wi as E,T as F,Sy as G,by as H,Mn as I,ui as J,rr as K,dy as L,Vp as M,oc as N,Ny as O,Ar as P,Oy as Q,xe as R,or as S,j as T,wa as U,Pe as V,ie as W,lt as X,ze as Y,Z,My as _,Ms as a,Cy as a0,et as a1,Qf as a2,Du as a3,Ti as a4,ki as a5,Iy as a6,Ut as b,V as c,sr as d,Kt as e,M as f,qu as g,xi as h,Wt as i,kl as j,Ey as k,my as l,py as m,hi as n,Fe as o,Rn as p,fi as q,ns as r,yi as s,ss as t,ts as u,W as v,er as w,ws as x,Cs as y,Xf as z};
43
+ `),slice:t}}function _f(e,t,n,r,i){let a=i.parent.type.spec.code,o,s;if(!n&&!t)return null;let c=!!t&&(r||a||!n);if(c){if(e.someProp(`transformPastedText`,n=>{t=n(t,a||r,e)}),a)return s=new L(F.from(e.state.schema.text(t.replace(/\r\n?/g,`
44
+ `))),0,0),e.someProp(`transformPasted`,t=>{s=t(s,e,!0)}),s;let n=e.someProp(`clipboardTextParser`,n=>n(t,i,r,e));if(n)s=n;else{let n=i.marks(),{schema:r}=e.state,a=Ro.fromSchema(r);o=document.createElement(`div`),t.split(/(?:\r\n?|\n)+/).forEach(e=>{let t=o.appendChild(document.createElement(`p`));e&&t.appendChild(a.serializeNode(r.text(e,n)))})}}else e.someProp(`transformPastedHTML`,t=>{n=t(n,e)}),o=Af(n),Eu&&jf(o);let l=o&&o.querySelector(`[data-pm-slice]`),u=l&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(l.getAttribute(`data-pm-slice`)||``);if(u&&u[3])for(let e=+u[3];e>0;e--){let e=o.firstChild;for(;e&&e.nodeType!=1;)e=e.nextSibling;if(!e)break;o=e}if(s||=(e.someProp(`clipboardParser`)||e.someProp(`domParser`)||wo.fromSchema(e.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||u),context:i,ruleFromNode(e){return e.nodeName==`BR`&&!e.nextSibling&&e.parentNode&&!vf.test(e.parentNode.nodeName)?{ignore:!0}:null}}),u)s=Mf(wf(s,+u[1],+u[2]),u[4]);else if(s=L.maxOpen(yf(s.content,i),!0),s.openStart||s.openEnd){let e=0,t=0;for(let t=s.content.firstChild;e<s.openStart&&!t.type.spec.isolating;e++,t=t.firstChild);for(let e=s.content.lastChild;t<s.openEnd&&!e.type.spec.isolating;t++,e=e.lastChild);s=wf(s,e,t)}return e.someProp(`transformPasted`,t=>{s=t(s,e,c)}),s}var vf=/^(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 yf(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let r=t.node(n).contentMatchAt(t.index(n)),i,a=[];if(e.forEach(e=>{if(!a)return;let t=r.findWrapping(e.type),n;if(!t)return a=null;if(n=a.length&&i.length&&xf(t,i,e,a[a.length-1],0))a[a.length-1]=n;else{a.length&&(a[a.length-1]=Sf(a[a.length-1],i.length));let n=bf(e,t);a.push(n),r=r.matchType(n.type),i=t}}),a)return F.from(a)}return e}function bf(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,F.from(e));return e}function xf(e,t,n,r,i){if(i<e.length&&i<t.length&&e[i]==t[i]){let a=xf(e,t,n,r.lastChild,i+1);if(a)return r.copy(r.content.replaceChild(r.childCount-1,a));if(r.contentMatchAt(r.childCount).matchType(i==e.length-1?n.type:e[i+1]))return r.copy(r.content.append(F.from(bf(n,e,i+1))))}}function Sf(e,t){if(t==0)return e;let n=e.content.replaceChild(e.childCount-1,Sf(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(F.empty,!0);return e.copy(n.append(r))}function Cf(e,t,n,r,i,a){let o=t<0?e.firstChild:e.lastChild,s=o.content;return e.childCount>1&&(a=0),i<r-1&&(s=Cf(s,t,n,r,i+1,a)),i>=n&&(s=t<0?o.contentMatchAt(0).fillBefore(s,a<=i).append(s):s.append(o.contentMatchAt(o.childCount).fillBefore(F.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,o.copy(s))}function wf(e,t,n){return t<e.openStart&&(e=new L(Cf(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new L(Cf(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}var Tf={thead:[`table`],tbody:[`table`],tfoot:[`table`],caption:[`table`],colgroup:[`table`],col:[`table`,`colgroup`],tr:[`table`,`tbody`],td:[`table`,`tbody`,`tr`],th:[`table`,`tbody`,`tr`]},Ef=null;function Df(){return Ef||=document.implementation.createHTMLDocument(`title`)}var Of=null;function kf(e){let t=window.trustedTypes;return t?(Of||=t.defaultPolicy||t.createPolicy(`ProseMirrorClipboard`,{createHTML:e=>e}),Of.createHTML(e)):e}function Af(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=Df().createElement(`div`),r=/<([a-z][^>\s]+)/i.exec(e),i;if((i=r&&Tf[r[1].toLowerCase()])&&(e=i.map(e=>`<`+e+`>`).join(``)+e+i.map(e=>`</`+e+`>`).reverse().join(``)),n.innerHTML=kf(e),i)for(let e=0;e<i.length;e++)n=n.querySelector(i[e])||n;return n}function jf(e){let t=e.querySelectorAll(K?`span:not([class]):not([style])`:`span.Apple-converted-space`);for(let n=0;n<t.length;n++){let r=t[n];r.childNodes.length==1&&r.textContent==`\xA0`&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(` `),r)}}function Mf(e,t){if(!e.size)return e;let n=e.content.firstChild.type.schema,r;try{r=JSON.parse(t)}catch{return e}let{content:i,openStart:a,openEnd:o}=e;for(let e=r.length-2;e>=0;e-=2){let t=n.nodes[r[e]];if(!t||t.hasRequiredAttrs())break;i=F.from(t.create(r[e+1],i)),a++,o++}return new L(i,a,o)}var J={},Y={},Nf={touchstart:!0,touchmove:!0},Pf=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:``,button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function Ff(e){for(let t in J){let n=J[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{Bf(e,t)&&!zf(e,t)&&(e.editable||!(t.type in Y))&&n(e,t)},Nf[t]?{passive:!0}:void 0)}q&&e.dom.addEventListener(`input`,()=>null),Rf(e)}function If(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function Lf(e){e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}function Rf(e){e.someProp(`handleDOMEvents`,t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>zf(e,t))})}function zf(e,t){return e.someProp(`handleDOMEvents`,n=>{let r=n[t.type];return r?r(e,t)||t.defaultPrevented:!1})}function Bf(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function Vf(e,t){!zf(e,t)&&J[t.type]&&(e.editable||!(t.type in Y))&&J[t.type](e,t)}Y.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,!tp(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!(Tu&&K&&n.keyCode==13)))if(n.keyCode!=229&&e.domObserver.forceFlush(),Su&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==t&&(e.someProp(`handleKeyDown`,t=>t(e,lu(13,`Enter`))),e.input.lastIOSEnter=0)},200)}else e.someProp(`handleKeyDown`,t=>t(e,n))||hf(e,n)?n.preventDefault():If(e,`key`)},Y.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)},Y.keypress=(e,t)=>{let n=t;if(tp(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||Cu&&n.metaKey)return;if(e.someProp(`handleKeyPress`,t=>t(e,n))){n.preventDefault();return}let r=e.state.selection;if(!(r instanceof V)||!r.$from.sameParent(r.$to)){let t=String.fromCharCode(n.charCode),i=()=>e.state.tr.insertText(t).scrollIntoView();!/[\r\n]/.test(t)&&!e.someProp(`handleTextInput`,n=>n(e,r.$from.pos,r.$to.pos,t,i))&&e.dispatch(i()),n.preventDefault()}};function Hf(e){return{left:e.clientX,top:e.clientY}}function Uf(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}function Wf(e,t,n,r,i){if(r==-1)return!1;let a=e.state.doc.resolve(r);for(let r=a.depth+1;r>0;r--)if(e.someProp(t,t=>r>a.depth?t(e,n,a.nodeAfter,a.before(r),i,!0):t(e,n,a.node(r),a.before(r),i,!1)))return!0;return!1}function Gf(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);n==`pointer`&&r.setMeta(`pointer`,!0),e.dispatch(r)}function Kf(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return r&&r.isAtom&&H.isSelectable(r)?(Gf(e,new H(n),`pointer`),!0):!1}function qf(e,t){if(t==-1)return!1;let n=e.state.selection,r,i;n instanceof H&&(r=n.node);let a=e.state.doc.resolve(t);for(let e=a.depth+1;e>0;e--){let t=e>a.depth?a.nodeAfter:a.node(e);if(H.isSelectable(t)){i=r&&n.$from.depth>0&&e>=n.$from.depth&&a.before(n.$from.depth+1)==n.$from.pos?a.before(n.$from.depth):a.before(e);break}}return i==null?!1:(Gf(e,H.create(e.state.doc,i),`pointer`),!0)}function Jf(e,t,n,r,i){return Wf(e,`handleClickOn`,t,n,r)||e.someProp(`handleClick`,n=>n(e,t,r))||(i?qf(e,n):Kf(e,n))}function Yf(e,t,n,r){return Wf(e,`handleDoubleClickOn`,t,n,r)||e.someProp(`handleDoubleClick`,n=>n(e,t,r))}function Xf(e,t,n,r){return Wf(e,`handleTripleClickOn`,t,n,r)||e.someProp(`handleTripleClick`,n=>n(e,t,r))||Zf(e,n,r)}function Zf(e,t,n){if(n.button!=0)return!1;let r=e.state.doc;if(t==-1)return r.inlineContent?(Gf(e,V.create(r,0,r.content.size),`pointer`),!0):!1;let i=r.resolve(t);for(let t=i.depth+1;t>0;t--){let n=t>i.depth?i.nodeAfter:i.node(t),a=i.before(t);if(n.inlineContent)Gf(e,V.create(r,a+1,a+1+n.content.size),`pointer`);else if(H.isSelectable(n))Gf(e,H.create(r,a),`pointer`);else continue;return!0}}function Qf(e){return cp(e)}var $f=Cu?`metaKey`:`ctrlKey`;J.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=Qf(e),i=Date.now(),a=`singleClick`;i-e.input.lastClick.time<500&&Uf(n,e.input.lastClick)&&!n[$f]&&e.input.lastClick.button==n.button&&(e.input.lastClick.type==`singleClick`?a=`doubleClick`:e.input.lastClick.type==`doubleClick`&&(a=`tripleClick`)),e.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:a,button:n.button};let o=e.posAtCoords(Hf(n));o&&(a==`singleClick`?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new ep(e,o,n,!!r)):(a==`doubleClick`?Yf:Xf)(e,o.pos,o.inside,n)?n.preventDefault():If(e,`pointer`))};var ep=class{constructor(e,t,n,r){this.view=e,this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[$f],this.allowDefault=n.shiftKey;let i,a;if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),a=t.inside;else{let n=e.state.doc.resolve(t.pos);i=n.parent,a=n.depth?n.before():0}let o=r?null:n.target,s=o?e.docView.nearestDesc(o,!0):null;this.target=s&&s.nodeDOM.nodeType==1?s.nodeDOM:null;let{selection:c}=e.state;(n.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof H&&c.from<=a&&c.to>a)&&(this.mightDrag={node:i,pos:a,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&yu&&!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)),If(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(()=>Ld(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(Hf(e))),this.updateAllowDefault(e),this.allowDefault||!t?If(this.view,`pointer`):Jf(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||q&&this.mightDrag&&!this.mightDrag.node.isAtom||K&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(Gf(this.view,B.near(this.view.state.doc.resolve(t.pos)),`pointer`),e.preventDefault()):If(this.view,`pointer`)}move(e){this.updateAllowDefault(e),If(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)}};J.touchstart=e=>{e.input.lastTouch=Date.now(),Qf(e),If(e,`pointer`)},J.touchmove=e=>{e.input.lastTouch=Date.now(),If(e,`pointer`)},J.contextmenu=e=>Qf(e);function tp(e,t){return e.composing?!0:q&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}var np=Tu?5e3:-1;Y.compositionstart=Y.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof V&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>e.type.spec.inclusive===!1)||K&&wu&&rp(e)))e.markCursor=e.state.storedMarks||n.marks(),cp(e,!0),e.markCursor=null;else if(cp(e,!t.selection.empty),yu&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,r=t.focusOffset;n&&n.nodeType==1&&r!=0;){let t=r<0?n.lastChild:n.childNodes[r-1];if(!t)break;if(t.nodeType==3){let n=e.domSelection();n&&n.collapse(t,t.nodeValue.length);break}else n=t,r=-1}}e.input.composing=!0}ip(e,np)};function rp(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||t.nodeType!=1||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return r.nodeType==1&&r.contentEditable==`false`}Y.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,ip(e,20))};function ip(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>cp(e),t))}function ap(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=sp());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function op(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=iu(t.focusNode,t.focusOffset),r=au(t.focusNode,t.focusOffset);if(n&&r&&n!=r){let t=r.pmViewDesc,i=e.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!t||!t.isText(r.nodeValue))return r;if(e.input.compositionNode==r){let e=n.pmViewDesc;if(!(!e||!e.isText(n.nodeValue)))return r}}return n||r}function sp(){let e=document.createEvent(`Event`);return e.initEvent(`event`,!0,!0),e.timeStamp}function cp(e,t=!1){if(!(Tu&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),ap(e),t||e.docView&&e.docView.dirty){let n=Fd(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):(e.markCursor||t)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.dispatch(e.state.tr.deleteSelection()):e.updateState(e.state),!0}return!1}}function lp(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement(`div`));n.appendChild(t),n.style.cssText=`position: fixed; left: -10000px; top: 10px`;let r=getSelection(),i=document.createRange();i.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}var up=G&&vu<15||Su&&Du<604;J.copy=Y.cut=(e,t)=>{let n=t,r=e.state.selection,i=n.type==`cut`;if(r.empty)return;let a=up?null:n.clipboardData,{dom:o,text:s}=gf(e,r.content());a?(n.preventDefault(),a.clearData(),a.setData(`text/html`,o.innerHTML),a.setData(`text/plain`,s)):lp(e,o),i&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta(`uiEvent`,`cut`))};function dp(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function fp(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?`textarea`:`div`));n||(r.contentEditable=`true`),r.style.cssText=`position: fixed; left: -10000px; top: 10px`,r.focus();let i=e.input.shiftKey&&e.input.lastKeyCode!=45;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?pp(e,r.value,null,i,t):pp(e,r.textContent,r.innerHTML,i,t)},50)}function pp(e,t,n,r,i){let a=_f(e,t,n,r,e.state.selection.$from);if(e.someProp(`handlePaste`,t=>t(e,i,a||L.empty)))return!0;if(!a)return!1;let o=dp(a),s=o?e.state.tr.replaceSelectionWith(o,r):e.state.tr.replaceSelection(a);return e.dispatch(s.scrollIntoView().setMeta(`paste`,!0).setMeta(`uiEvent`,`paste`)),!0}function mp(e){let t=e.getData(`text/plain`)||e.getData(`Text`);if(t)return t;let n=e.getData(`text/uri-list`);return n?n.replace(/\r?\n/g,` `):``}Y.paste=(e,t)=>{let n=t;if(e.composing&&!Tu)return;let r=up?null:n.clipboardData,i=e.input.shiftKey&&e.input.lastKeyCode!=45;r&&pp(e,mp(r),r.getData(`text/html`),i,n)?n.preventDefault():fp(e,n)};var hp=class{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}},gp=Cu?`altKey`:`ctrlKey`;function _p(e,t){return e.someProp(`dragCopies`,e=>!e(t))??!t[gp]}J.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=e.state.selection,a=i.empty?null:e.posAtCoords(Hf(n)),o;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof H?i.to-1:i.to))){if(r&&r.mightDrag)o=H.create(e.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&(o=H.create(e.state.doc,t.posBefore))}}let{dom:s,text:c,slice:l}=gf(e,(o||e.state.selection).content());(!n.dataTransfer.files.length||!K||xu>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(up?`Text`:`text/html`,s.innerHTML),n.dataTransfer.effectAllowed=`copyMove`,up||n.dataTransfer.setData(`text/plain`,c),e.dragging=new hp(l,_p(e,n),o)},J.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},Y.dragover=Y.dragenter=(e,t)=>t.preventDefault(),Y.drop=(e,t)=>{try{vp(e,t,e.dragging)}finally{e.dragging=null}};function vp(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(Hf(t));if(!r)return;let i=e.state.doc.resolve(r.pos),a=n&&n.slice;a?e.someProp(`transformPasted`,t=>{a=t(a,e,!1)}):a=_f(e,mp(t.dataTransfer),up?null:t.dataTransfer.getData(`text/html`),!1,i);let o=!!(n&&_p(e,t));if(e.someProp(`handleDrop`,n=>n(e,t,a||L.empty,o))){t.preventDefault();return}if(!a)return;t.preventDefault();let s=a?Is(e.state.doc,i.pos,a):i.pos;s??=i.pos;let c=e.state.tr;if(o){let{node:e}=n;e?e.replace(c):c.deleteSelection()}let l=c.mapping.map(s),u=a.openStart==0&&a.openEnd==0&&a.content.childCount==1,d=c.doc;if(u?c.replaceRangeWith(l,l,a.content.firstChild):c.replaceRange(l,l,a),c.doc.eq(d))return;let f=c.doc.resolve(l);if(u&&H.isSelectable(a.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(a.content.firstChild))c.setSelection(new H(f));else{let t=c.mapping.map(s);c.mapping.maps[c.mapping.maps.length-1].forEach((e,n,r,i)=>t=i),c.setSelection(Kd(e,f,c.doc.resolve(t)))}e.focus(),e.dispatch(c.setMeta(`uiEvent`,`drop`))}J.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add(`ProseMirror-focused`),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&Ld(e)},20))},J.blur=(e,t)=>{let n=t;e.focused&&=(e.domObserver.stop(),e.dom.classList.remove(`ProseMirror-focused`),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),!1)},J.beforeinput=(e,t)=>{if(K&&Tu&&t.inputType==`deleteContentBackward`){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=t||(e.dom.blur(),e.focus(),e.someProp(`handleKeyDown`,t=>t(e,lu(8,`Backspace`)))))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())},50)}};for(let e in Y)J[e]=Y[e];function yp(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}var bp=class e{constructor(e,t){this.toDOM=e,this.spec=t||Tp,this.side=this.spec.side||0}map(e,t,n,r){let{pos:i,deleted:a}=e.mapResult(t.from+r,this.side<0?-1:1);return a?null:new Cp(i-n,i-n,this)}valid(){return!0}eq(t){return this==t||t instanceof e&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&yp(this.spec,t.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},xp=class e{constructor(e,t){this.attrs=e,this.spec=t||Tp}map(e,t,n,r){let i=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,a=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return i>=a?null:new Cp(i,a,this)}valid(e,t){return t.from<t.to}eq(t){return this==t||t instanceof e&&yp(this.attrs,t.attrs)&&yp(this.spec,t.spec)}static is(t){return t.type instanceof e}destroy(){}},Sp=class e{constructor(e,t){this.attrs=e,this.spec=t||Tp}map(e,t,n,r){let i=e.mapResult(t.from+r,1);if(i.deleted)return null;let a=e.mapResult(t.to+r,-1);return a.deleted||a.pos<=i.pos?null:new Cp(i.pos-n,a.pos-n,this)}valid(e,t){let{index:n,offset:r}=e.content.findIndex(t.from),i;return r==t.from&&!(i=e.child(n)).isText&&r+i.nodeSize==t.to}eq(t){return this==t||t instanceof e&&yp(this.attrs,t.attrs)&&yp(this.spec,t.spec)}destroy(){}},Cp=class e{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(t,n){return new e(t,n,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(t,n,r){return new e(t,t,new bp(n,r))}static inline(t,n,r,i){return new e(t,n,new xp(r,i))}static node(t,n,r,i){return new e(t,n,new Sp(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof xp}get widget(){return this.type instanceof bp}},wp=[],Tp={},Ep=class e{constructor(e,t){this.local=e.length?e:wp,this.children=t.length?t:wp}static create(e,t){return t.length?Np(t,e,0,Tp):X}find(e,t,n){let r=[];return this.findInner(e??0,t??1e9,r,0,n),r}findInner(e,t,n,r,i){for(let a=0;a<this.local.length;a++){let o=this.local[a];o.from<=t&&o.to>=e&&(!i||i(o.spec))&&n.push(o.copy(o.from+r,o.to+r))}for(let a=0;a<this.children.length;a+=3)if(this.children[a]<t&&this.children[a+1]>e){let o=this.children[a]+1;this.children[a+2].findInner(e-o,t-o,n,r+o,i)}}map(e,t,n){return this==X||e.maps.length==0?this:this.mapInner(e,t,0,0,n||Tp)}mapInner(t,n,r,i,a){let o;for(let e=0;e<this.local.length;e++){let s=this.local[e].map(t,r,i);s&&s.type.valid(n,s)?(o||=[]).push(s):a.onRemove&&a.onRemove(this.local[e].spec)}return this.children.length?Op(this.children,o||[],t,n,r,i,a):o?new e(o.sort(Pp),wp):X}add(t,n){return n.length?this==X?e.create(t,n):this.addInner(t,n,0):this}addInner(t,n,r){let i,a=0;t.forEach((e,t)=>{let o=t+r,s;if(s=jp(n,e,o)){for(i||=this.children.slice();a<i.length&&i[a]<t;)a+=3;i[a]==t?i[a+2]=i[a+2].addInner(e,s,o+1):i.splice(a,0,t,t+e.nodeSize,Np(s,e,o+1,Tp)),a+=3}});let o=kp(a?Mp(n):n,-r);for(let e=0;e<o.length;e++)o[e].type.valid(t,o[e])||o.splice(e--,1);return new e(o.length?this.local.concat(o).sort(Pp):this.local,i||this.children)}remove(e){return e.length==0||this==X?this:this.removeInner(e,0)}removeInner(t,n){let r=this.children,i=this.local;for(let e=0;e<r.length;e+=3){let i,a=r[e]+n,o=r[e+1]+n;for(let e=0,n;e<t.length;e++)(n=t[e])&&n.from>a&&n.to<o&&(t[e]=null,(i||=[]).push(n));if(!i)continue;r==this.children&&(r=this.children.slice());let s=r[e+2].removeInner(i,a+1);s==X?(r.splice(e,3),e-=3):r[e+2]=s}if(i.length){for(let e=0,r;e<t.length;e++)if(r=t[e])for(let e=0;e<i.length;e++)i[e].eq(r,n)&&(i==this.local&&(i=this.local.slice()),i.splice(e--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new e(i,r):X}forChild(t,n){if(this==X)return this;if(n.isLeaf)return e.empty;let r,i;for(let e=0;e<this.children.length;e+=3)if(this.children[e]>=t){this.children[e]==t&&(r=this.children[e+2]);break}let a=t+1,o=a+n.content.size;for(let e=0;e<this.local.length;e++){let t=this.local[e];if(t.from<o&&t.to>a&&t.type instanceof xp){let e=Math.max(a,t.from)-a,n=Math.min(o,t.to)-a;e<n&&(i||=[]).push(t.copy(e,n))}}if(i){let t=new e(i.sort(Pp),wp);return r?new Dp([t,r]):t}return r||X}eq(t){if(this==t)return!0;if(!(t instanceof e)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(let e=0;e<this.local.length;e++)if(!this.local[e].eq(t.local[e]))return!1;for(let e=0;e<this.children.length;e+=3)if(this.children[e]!=t.children[e]||this.children[e+1]!=t.children[e+1]||!this.children[e+2].eq(t.children[e+2]))return!1;return!0}locals(e){return Fp(this.localsInner(e))}localsInner(e){if(this==X)return wp;if(e.inlineContent||!this.local.some(xp.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof xp||t.push(this.local[e]);return t}forEachSet(e){e(this)}};Ep.empty=new Ep([],[]),Ep.removeOverlap=Fp;var X=Ep.empty,Dp=class e{constructor(e){this.members=e}map(t,n){let r=this.members.map(e=>e.map(t,n,Tp));return e.from(r)}forChild(t,n){if(n.isLeaf)return Ep.empty;let r=[];for(let i=0;i<this.members.length;i++){let a=this.members[i].forChild(t,n);a!=X&&(a instanceof e?r=r.concat(a.members):r.push(a))}return e.from(r)}eq(t){if(!(t instanceof e)||t.members.length!=this.members.length)return!1;for(let e=0;e<this.members.length;e++)if(!this.members[e].eq(t.members[e]))return!1;return!0}locals(e){let t,n=!0;for(let r=0;r<this.members.length;r++){let i=this.members[r].localsInner(e);if(i.length)if(!t)t=i;else{n&&=(t=t.slice(),!1);for(let e=0;e<i.length;e++)t.push(i[e])}}return t?Fp(n?t:t.sort(Pp)):wp}static from(t){switch(t.length){case 0:return X;case 1:return t[0];default:return new e(t.every(e=>e instanceof Ep)?t:t.reduce((e,t)=>e.concat(t instanceof Ep?t:t.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function Op(e,t,n,r,i,a,o){let s=e.slice();for(let e=0,t=a;e<n.maps.length;e++){let r=0;n.maps[e].forEach((e,n,i,a)=>{let o=a-i-(n-e);for(let i=0;i<s.length;i+=3){let a=s[i+1];if(a<0||e>a+t-r)continue;let c=s[i]+t-r;n>=c?s[i+1]=e<=c?-2:-1:e>=t&&o&&(s[i]+=o,s[i+1]+=o)}r+=o}),t=n.maps[e].map(t,-1)}let c=!1;for(let t=0;t<s.length;t+=3)if(s[t+1]<0){if(s[t+1]==-2){c=!0,s[t+1]=-1;continue}let l=n.map(e[t]+a),u=l-i;if(u<0||u>=r.content.size){c=!0;continue}let d=n.map(e[t+1]+a,-1)-i,{index:f,offset:p}=r.content.findIndex(u),m=r.maybeChild(f);if(m&&p==u&&p+m.nodeSize==d){let r=s[t+2].mapInner(n,m,l+1,e[t]+a+1,o);r==X?(s[t+1]=-2,c=!0):(s[t]=u,s[t+1]=d,s[t+2]=r)}else c=!0}if(c){let c=Np(Ap(s,e,t,n,i,a,o),r,0,o);t=c.local;for(let e=0;e<s.length;e+=3)s[e+1]<0&&(s.splice(e,3),e-=3);for(let e=0,t=0;e<c.children.length;e+=3){let n=c.children[e];for(;t<s.length&&s[t]<n;)t+=3;s.splice(t,0,c.children[e],c.children[e+1],c.children[e+2])}}return new Ep(t.sort(Pp),s)}function kp(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let i=e[r];n.push(new Cp(i.from+t,i.to+t,i.type))}return n}function Ap(e,t,n,r,i,a,o){function s(e,t){for(let a=0;a<e.local.length;a++){let s=e.local[a].map(r,i,t);s?n.push(s):o.onRemove&&o.onRemove(e.local[a].spec)}for(let n=0;n<e.children.length;n+=3)s(e.children[n+2],e.children[n]+t+1)}for(let n=0;n<e.length;n+=3)e[n+1]==-1&&s(e[n+2],t[n]+a+1);return n}function jp(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,i=null;for(let t=0,a;t<e.length;t++)(a=e[t])&&a.from>n&&a.to<r&&((i||=[]).push(a),e[t]=null);return i}function Mp(e){let t=[];for(let n=0;n<e.length;n++)e[n]!=null&&t.push(e[n]);return t}function Np(e,t,n,r){let i=[],a=!1;t.forEach((t,o)=>{let s=jp(e,t,o+n);if(s){a=!0;let e=Np(s,t,n+o+1,r);e!=X&&i.push(o,o+t.nodeSize,e)}});let o=kp(a?Mp(e):e,-n).sort(Pp);for(let e=0;e<o.length;e++)o[e].type.valid(t,o[e])||(r.onRemove&&r.onRemove(o[e].spec),o.splice(e--,1));return o.length||i.length?new Ep(o,i):X}function Pp(e,t){return e.from-t.from||e.to-t.to}function Fp(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let i=n+1;i<t.length;i++){let a=t[i];if(a.from==r.from){a.to!=r.to&&(t==e&&(t=e.slice()),t[i]=a.copy(a.from,r.to),Ip(t,i+1,a.copy(r.to,a.to)));continue}else{a.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,a.from),Ip(t,i,r.copy(a.from,r.to)));break}}}return t}function Ip(e,t,n){for(;t<e.length&&Pp(n,e[t])>0;)t++;e.splice(t,0,n)}function Lp(e){let t=[];return e.someProp(`decorations`,n=>{let r=n(e.state);r&&r!=X&&t.push(r)}),e.cursorWrapper&&t.push(Ep.create(e.state.doc,[e.cursorWrapper.deco])),Dp.from(t)}var Rp={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},zp=G&&vu<=11,Bp=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}},Vp=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Bp,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);G&&vu<=11&&t.some(e=>e.type==`childList`&&e.removedNodes.length||e.type==`characterData`&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():q&&e.composing&&t.some(e=>e.type==`childList`&&e.target.nodeName==`TR`)?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),zp&&(this.onCharData=e=>{this.queue.push({target:e.target,type:`characterData`,oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Rp)),this.onCharData&&this.view.dom.addEventListener(`DOMCharacterDataModified`,this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener(`DOMCharacterDataModified`,this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener(`selectionchange`,this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener(`selectionchange`,this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(qd(this.view)){if(this.suppressingSelectionUpdates)return Ld(this.view);if(G&&vu<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&eu(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,n;for(let n=e.focusNode;n;n=Xl(n))t.add(n);for(let r=e.anchorNode;r;r=Xl(r))if(t.has(r)){n=r;break}let r=n&&this.view.docView.nearestDesc(n);if(r&&r.ignoreMutation({type:`selection`,target:n.nodeType==3?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&qd(e)&&!this.ignoreSelectionChange(n),i=-1,a=-1,o=!1,s=[];if(e.editable)for(let e=0;e<t.length;e++){let n=this.registerMutation(t[e],s);n&&(i=i<0?n.from:Math.min(n.from,i),a=a<0?n.to:Math.max(n.to,a),n.typeOver&&(o=!0))}if(s.some(e=>e.nodeName==`BR`)&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let e of s)if(e.nodeName==`BR`&&e.parentNode){let t=e.nextSibling;for(;t&&t.nodeType==1;){if(t.contentEditable==`false`){e.parentNode.removeChild(e);break}t=t.firstChild}}}else if(yu&&s.length){let t=s.filter(e=>e.nodeName==`BR`);if(t.length==2){let[e,n]=t;e.parentNode&&e.parentNode.parentNode==n.parentNode?n.remove():e.remove()}else{let{focusNode:n}=this.currentSelection;for(let r of t){let t=r.parentNode;t&&t.nodeName==`LI`&&(!n||qp(e,n)!=t)&&r.remove()}}}let c=null;i<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&cu(n)&&(c=Fd(e))&&c.eq(B.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Ld(e),this.currentSelection.set(n),e.scrollToSelection()):(i>-1||r)&&(i>-1&&(e.docView.markDirty(i,a),Wp(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,Jp(e,s)),this.handleDOMChange(i,a,o,s),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||Ld(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if(e.type==`attributes`&&(n==this.view.docView||e.attributeName==`contenteditable`||e.attributeName==`style`&&!e.oldValue&&!e.target.getAttribute(`style`))||!n||n.ignoreMutation(e))return null;if(e.type==`childList`){for(let n=0;n<e.addedNodes.length;n++){let r=e.addedNodes[n];t.push(r),r.nodeType==3&&(this.lastChangedTextNode=r)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let r=e.previousSibling,i=e.nextSibling;if(G&&vu<=11&&e.addedNodes.length)for(let t=0;t<e.addedNodes.length;t++){let{previousSibling:n,nextSibling:a}=e.addedNodes[t];(!n||Array.prototype.indexOf.call(e.addedNodes,n)<0)&&(r=n),(!a||Array.prototype.indexOf.call(e.addedNodes,a)<0)&&(i=a)}let a=r&&r.parentNode==e.target?W(r)+1:0,o=n.localPosFromDOM(e.target,a,-1),s=i&&i.parentNode==e.target?W(i):e.target.childNodes.length;return{from:o,to:n.localPosFromDOM(e.target,s,1)}}else if(e.type==`attributes`)return{from:n.posAtStart-n.border,to:n.posAtEnd+n.border};else return this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}}},Hp=new WeakMap,Up=!1;function Wp(e){if(!Hp.has(e)&&(Hp.set(e,null),[`normal`,`nowrap`,`pre-line`].indexOf(getComputedStyle(e.dom).whiteSpace)!==-1)){if(e.requiresGeckoHackNode=yu,Up)return;console.warn(`ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package.`),Up=!0}}function Gp(e,t){let n=t.startContainer,r=t.startOffset,i=t.endContainer,a=t.endOffset,o=e.domAtPos(e.state.selection.anchor);return eu(o.node,o.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function Kp(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return Gp(e,n)}let n;function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.dom.addEventListener(`beforeinput`,r,!0),document.execCommand(`indent`),e.dom.removeEventListener(`beforeinput`,r,!0),n?Gp(e,n):null}function qp(e,t){for(let n=t.parentNode;n&&n!=e.dom;n=n.parentNode){let t=e.docView.nearestDesc(n,!0);if(t&&t.node.isBlock)return n}return null}function Jp(e,t){let{focusNode:n,focusOffset:r}=e.domSelectionRange();for(let i of t)if(i.parentNode?.nodeName==`TR`){let t=i.nextSibling;for(;t&&t.nodeName!=`TD`&&t.nodeName!=`TH`;)t=t.nextSibling;if(t){let a=t;for(;;){let e=a.firstChild;if(!e||e.nodeType!=1||e.contentEditable==`false`||/^(BR|IMG)$/.test(e.nodeName))break;a=e}a.insertBefore(i,a.firstChild),n==i&&e.domSelection().collapse(i,r)}else i.parentNode.removeChild(i)}}function Yp(e,t,n){let{node:r,fromOffset:i,toOffset:a,from:o,to:s}=e.docView.parseRange(t,n),c=e.domSelectionRange(),l,u=c.anchorNode;if(u&&e.dom.contains(u.nodeType==1?u:u.parentNode)&&(l=[{node:u,offset:c.anchorOffset}],cu(c)||l.push({node:c.focusNode,offset:c.focusOffset})),K&&e.input.lastKeyCode===8)for(let e=a;e>i;e--){let t=r.childNodes[e-1],n=t.pmViewDesc;if(t.nodeName==`BR`&&!n){a=e;break}if(!n||n.size)break}let d=e.state.doc,f=e.someProp(`domParser`)||wo.fromSchema(e.state.schema),p=d.resolve(o),m=null,h=f.parse(r,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:a,preserveWhitespace:p.parent.type.whitespace==`pre`?`full`:!0,findPositions:l,ruleFromNode:Xp,context:p});if(l&&l[0].pos!=null){let e=l[0].pos,t=l[1]&&l[1].pos;t??=e,m={anchor:e+o,head:t+o}}return{doc:h,sel:m,from:o,to:s}}function Xp(e){let t=e.pmViewDesc;if(t)return t.parseRule();if(e.nodeName==`BR`&&e.parentNode){if(q&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let e=document.createElement(`div`);return e.appendChild(document.createElement(`li`)),{skip:e}}else if(e.parentNode.lastChild==e||q&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName==`IMG`&&e.getAttribute(`mark-placeholder`))return{ignore:!0};return null}var Zp=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Qp(e,t,n,r,i){let a=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=Fd(e,t);if(n&&!e.state.selection.eq(n)){if(K&&Tu&&e.input.lastKeyCode===13&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp(`handleKeyDown`,t=>t(e,lu(13,`Enter`))))return;let r=e.state.tr.setSelection(n);t==`pointer`?r.setMeta(`pointer`,!0):t==`key`&&r.scrollIntoView(),a&&r.setMeta(`composition`,a),e.dispatch(r)}return}let o=e.state.doc.resolve(t),s=o.sharedDepth(n);t=o.before(s+1),n=e.state.doc.resolve(n).after(s+1);let c=e.state.selection,l=Yp(e,t,n),u=e.state.doc,d=u.slice(l.from,l.to),f,p;e.input.lastKeyCode===8&&Date.now()-100<e.input.lastKeyCodeTime?(f=e.state.selection.to,p=`end`):(f=e.state.selection.from,p=`start`),e.input.lastKeyCode=null;let m=rm(d.content,l.doc.content,l.from,f,p);if(m&&e.input.domChangeCount++,(Su&&e.input.lastIOSEnter>Date.now()-225||Tu)&&i.some(e=>e.nodeType==1&&!Zp.test(e.nodeName))&&(!m||m.endA>=m.endB)&&e.someProp(`handleKeyDown`,t=>t(e,lu(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(!m)if(r&&c instanceof V&&!c.empty&&c.$head.sameParent(c.$anchor)&&!e.composing&&!(l.sel&&l.sel.anchor!=l.sel.head))m={start:c.from,endA:c.to,endB:c.to};else{if(l.sel){let t=$p(e,e.state.doc,l.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);a&&n.setMeta(`composition`,a),e.dispatch(n)}}return}e.state.selection.from<e.state.selection.to&&m.start==m.endB&&e.state.selection instanceof V&&(m.start>e.state.selection.from&&m.start<=e.state.selection.from+2&&e.state.selection.from>=l.from?m.start=e.state.selection.from:m.endA<e.state.selection.to&&m.endA>=e.state.selection.to-2&&e.state.selection.to<=l.to&&(m.endB+=e.state.selection.to-m.endA,m.endA=e.state.selection.to)),G&&vu<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>l.from&&l.doc.textBetween(m.start-l.from-1,m.start-l.from+1)==` \xA0`&&(m.start--,m.endA--,m.endB--);let h=l.doc.resolveNoCache(m.start-l.from),g=l.doc.resolveNoCache(m.endB-l.from),_=u.resolve(m.start),v=h.sameParent(g)&&h.parent.inlineContent&&_.end()>=m.endA;if((Su&&e.input.lastIOSEnter>Date.now()-225&&(!v||i.some(e=>e.nodeName==`DIV`||e.nodeName==`P`))||!v&&h.pos<l.doc.content.size&&(!h.sameParent(g)||!h.parent.inlineContent)&&h.pos<g.pos&&!/\S/.test(l.doc.textBetween(h.pos,g.pos,``,``)))&&e.someProp(`handleKeyDown`,t=>t(e,lu(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>m.start&&tm(u,m.start,m.endA,h,g)&&e.someProp(`handleKeyDown`,t=>t(e,lu(8,`Backspace`)))){Tu&&K&&e.domObserver.suppressSelectionUpdates();return}K&&m.endB==m.start&&(e.input.lastChromeDelete=Date.now()),Tu&&!v&&h.start()!=g.start()&&g.parentOffset==0&&h.depth==g.depth&&l.sel&&l.sel.anchor==l.sel.head&&l.sel.head==m.endA&&(m.endB-=2,g=l.doc.resolveNoCache(m.endB-l.from),setTimeout(()=>{e.someProp(`handleKeyDown`,function(t){return t(e,lu(13,`Enter`))})},20));let y=m.start,b=m.endA,x=t=>{let n=t||e.state.tr.replace(y,b,l.doc.slice(m.start-l.from,m.endB-l.from));if(l.sel){let t=$p(e,n.doc,l.sel);t&&!(K&&e.composing&&t.empty&&(m.start!=m.endB||e.input.lastChromeDelete<Date.now()-100)&&(t.head==y||t.head==n.mapping.map(b)-1)||G&&t.empty&&t.head==y)&&n.setSelection(t)}return a&&n.setMeta(`composition`,a),n.scrollIntoView()},ee;if(v)if(h.pos==g.pos){G&&vu<=11&&h.parentOffset==0&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>Ld(e),20));let t=x(e.state.tr.delete(y,b)),n=u.resolve(m.start).marksAcross(u.resolve(m.endA));n&&t.ensureMarks(n),e.dispatch(t)}else if(m.endA==m.endB&&(ee=em(h.parent.content.cut(h.parentOffset,g.parentOffset),_.parent.content.cut(_.parentOffset,m.endA-_.start())))){let t=x(e.state.tr);ee.type==`add`?t.addMark(y,b,ee.mark):t.removeMark(y,b,ee.mark),e.dispatch(t)}else if(h.parent.child(h.index()).isText&&h.index()==g.index()-(g.textOffset?0:1)){let t=h.parent.textBetween(h.parentOffset,g.parentOffset),n=()=>x(e.state.tr.insertText(t,y,b));e.someProp(`handleTextInput`,r=>r(e,y,b,t,n))||e.dispatch(n())}else e.dispatch(x());else e.dispatch(x())}function $p(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:Kd(e,t.resolve(n.anchor),t.resolve(n.head))}function em(e,t){let n=e.firstChild.marks,r=t.firstChild.marks,i=n,a=r,o,s,c;for(let e=0;e<r.length;e++)i=r[e].removeFromSet(i);for(let e=0;e<n.length;e++)a=n[e].removeFromSet(a);if(i.length==1&&a.length==0)s=i[0],o=`add`,c=e=>e.mark(s.addToSet(e.marks));else if(i.length==0&&a.length==1)s=a[0],o=`remove`,c=e=>e.mark(s.removeFromSet(e.marks));else return null;let l=[];for(let e=0;e<t.childCount;e++)l.push(c(t.child(e)));if(F.from(l).eq(e))return{mark:s,type:o}}function tm(e,t,n,r,i){if(n-t<=i.pos-r.pos||nm(r,!0,!1)<i.pos)return!1;let a=e.resolve(t);if(!r.parent.isTextblock){let e=a.nodeAfter;return e!=null&&n==t+e.nodeSize}if(a.parentOffset<a.parent.content.size||!a.parent.isTextblock)return!1;let o=e.resolve(nm(a,!0,!0));return!o.parent.isTextblock||o.pos>n||nm(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function nm(e,t,n){let r=e.depth,i=t?e.end():e.pos;for(;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,i++,t=!1;if(n){let t=e.node(r).maybeChild(e.indexAfter(r));for(;t&&!t.isLeaf;)t=t.firstChild,i++}return i}function rm(e,t,n,r,i){let a=e.findDiffStart(t,n);if(a==null)return null;let{a:o,b:s}=e.findDiffEnd(t,n+e.size,n+t.size);if(i==`end`){let e=Math.max(0,a-Math.min(o,s));r-=o+e-a}if(o<a&&e.size<t.size){let e=r<=a&&r>=o?a-r:0;a-=e,a&&a<t.size&&im(t.textBetween(a-1,a+1))&&(a+=e?1:-1),s=a+(s-o),o=a}else if(s<a){let t=r<=a&&r>=s?a-r:0;a-=t,a&&a<e.size&&im(e.textBetween(a-1,a+1))&&(a+=t?1:-1),o=a+(o-s),s=a}return{start:a,endA:o,endB:s}}function im(e){if(e.length!=2)return!1;let t=e.charCodeAt(0),n=e.charCodeAt(1);return t>=56320&&t<=57343&&n>=55296&&n<=56319}var am=class{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new Pf,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(fm),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement(`div`),e&&(e.appendChild?e.appendChild(this.dom):typeof e==`function`?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=cm(this),sm(this),this.nodeViews=um(this),this.docView=hd(this.state.doc,om(this),Lp(this),this.dom,this),this.domObserver=new Vp(this,(e,t,n,r)=>Qp(this,e,t,n,r)),this.domObserver.start(),Ff(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Rf(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(fm),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){let n=this.state,r=!1,i=!1;e.storedMarks&&this.composing&&(ap(this),i=!0),this.state=e;let a=n.plugins!=e.plugins||this._props.plugins!=t.plugins;if(a||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=um(this);dm(e,this.nodeViews)&&(this.nodeViews=e,r=!0)}(a||t.handleDOMEvents!=this._props.handleDOMEvents)&&Rf(this),this.editable=cm(this),sm(this);let o=Lp(this),s=om(this),c=n.plugins!=e.plugins&&!n.doc.eq(e.doc)?`reset`:e.scrollToSelection>n.scrollToSelection?`to selection`:`preserve`,l=r||!this.docView.matchesNode(e.doc,s,o);(l||!e.selection.eq(n.selection))&&(i=!0);let u=c==`preserve`&&i&&this.dom.style.overflowAnchor==null&&Mu(this);if(i){this.domObserver.stop();let t=l&&(G||K)&&!this.composing&&!n.selection.empty&&!e.selection.empty&&lm(n.selection,e.selection);if(l){let n=K?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=op(this)),(r||!this.docView.update(e.doc,s,o,this))&&(this.docView.updateOuterDeco(s),this.docView.destroy(),this.docView=hd(e.doc,s,o,this.dom,this)),n&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(t=!0)}t||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Yd(this))?Ld(this,t):(Wd(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(n),this.dragging?.node&&!n.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,n),c==`reset`?this.dom.scrollTop=0:c==`to selection`?this.scrollToSelection():u&&Pu(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))&&!this.someProp(`handleScrollToSelection`,e=>e(this)))if(this.state.selection instanceof H){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&ju(this,t.getBoundingClientRect(),e)}else ju(this,this.coordsAtPos(this.state.selection.head,1),e)}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e<this.directPlugins.length;e++){let t=this.directPlugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let t=this.state.plugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}}updateDraggedNode(e,t){let n=e.node,r=-1;if(n.from<this.state.doc.content.size&&this.state.doc.nodeAt(n.from)==n.node)r=n.from;else{let e=n.from+(this.state.doc.content.size-t.doc.content.size);(e>0&&e<this.state.doc.content.size&&this.state.doc.nodeAt(e))==n.node&&(r=e)}this.dragging=new hp(e.slice,e.move,r<0?void 0:H.create(this.state.doc,r))}someProp(e,t){let n=this._props&&this._props[e],r;if(n!=null&&(r=t?t(n):n))return r;for(let n=0;n<this.directPlugins.length;n++){let i=this.directPlugins[n].props[e];if(i!=null&&(r=t?t(i):i))return r}let i=this.state.plugins;if(i)for(let n=0;n<i.length;n++){let a=i[n].props[e];if(a!=null&&(r=t?t(a):a))return r}}hasFocus(){if(G){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable==`false`)return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&Lu(this.dom),Ld(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let e=this.dom.parentNode;e;e=e.parentNode)if(e.nodeType==9||e.nodeType==11&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=()=>e.ownerDocument.getSelection()),this._root=e}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Gu(this,e)}coordsAtPos(e,t=1){return Yu(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let r=this.docView.posFromDOM(e,t,n);if(r==null)throw RangeError(`DOM position not inside the editor`);return r}endOfTextblock(e,t){return ad(this,t||this.state,e)}pasteHTML(e,t){return pp(this,``,e,!1,t||new ClipboardEvent(`paste`))}pasteText(e,t){return pp(this,e,null,!0,t||new ClipboardEvent(`paste`))}serializeForClipboard(e){return gf(this,e)}destroy(){this.docView&&(Lf(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Lp(this),this),this.dom.textContent=``):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,$l())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Vf(this,e)}domSelectionRange(){let e=this.domSelection();return e?q&&this.root.nodeType===11&&uu(this.dom.ownerDocument)==this.dom&&Kp(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};am.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};function om(e){let t=Object.create(null);return t.class=`ProseMirror`,t.contenteditable=String(e.editable),e.someProp(`attributes`,n=>{if(typeof n==`function`&&(n=n(e.state)),n)for(let e in n)e==`class`?t.class+=` `+n[e]:e==`style`?t.style=(t.style?t.style+`;`:``)+n[e]:!t[e]&&e!=`contenteditable`&&e!=`nodeName`&&(t[e]=String(n[e]))}),t.translate||=`no`,[Cp.node(0,e.state.doc.content.size,t)]}function sm(e){if(e.markCursor){let t=document.createElement(`img`);t.className=`ProseMirror-separator`,t.setAttribute(`mark-placeholder`,`true`),t.setAttribute(`alt`,``),e.cursorWrapper={dom:t,deco:Cp.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function cm(e){return!e.someProp(`editable`,t=>t(e.state)===!1)}function lm(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}function um(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp(`nodeViews`,n),e.someProp(`markViews`,n),t}function dm(e,t){let n=0,r=0;for(let r in e){if(e[r]!=t[r])return!0;n++}for(let e in t)r++;return n!=r}function fm(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw RangeError(`Plugins passed directly to the view must not have a state component`)}function pm(e,t){return e.meta={package:`@milkdown/core`,group:`System`,...t},e}var mm={text:(e,t,n,r)=>{let i=e.value;return/^[^*_\\]*\s+$/.test(i)?i:n.safe(i,{...r,encode:[]})},strong:(e,t,n,r)=>{let i=e.marker||n.options.strong||`*`,a=n.enter(`strong`),o=n.createTracker(r),s=o.move(i+i);return s+=o.move(n.containerPhrasing(e,{before:s,after:i,...o.current()})),s+=o.move(i+i),a(),s},emphasis:(e,t,n,r)=>{let i=e.marker||n.options.emphasis||`*`,a=n.enter(`emphasis`),o=n.createTracker(r),s=o.move(i);return s+=o.move(n.containerPhrasing(e,{before:s,after:i,...o.current()})),s+=o.move(i),a(),s}},hm=S({},`editorView`),gm=S({},`editorState`),_m=S([],`initTimer`),vm=S({},`editor`),ym=S([],`inputRules`),bm=S([],`prosePlugins`),xm=S([],`remarkPlugins`),Sm=S([],`nodeView`),Cm=S([],`markView`),wm=S(ma().use(rr).use(Bi),`remark`),Tm=S({handlers:mm,encode:[]},`remarkStringifyOptions`),Em=E(`ConfigReady`);function Dm(e){let t=t=>(t.record(Em),async()=>(await e(t),t.done(Em),()=>{t.clearTimer(Em)}));return pm(t,{displayName:`Config`}),t}var Om=E(`InitReady`);function km(e){let t=t=>(t.inject(vm,e).inject(bm,[]).inject(xm,[]).inject(ym,[]).inject(Sm,[]).inject(Cm,[]).inject(Tm,{handlers:mm,encode:[]}).inject(wm,ma().use(rr).use(Bi)).inject(_m,[Em]).record(Om),async()=>{await t.waitTimers(_m);let e=t.get(Tm);return t.set(wm,ma().use(rr).use(Bi,e)),t.done(Om),()=>{t.remove(vm).remove(bm).remove(xm).remove(ym).remove(Sm).remove(Cm).remove(Tm).remove(wm).remove(_m).clearTimer(Om)}});return pm(t,{displayName:`Init`}),t}var Am=E(`SchemaReady`),jm=S([],`schemaTimer`),Mm=S({},`schema`),Nm=S([],`nodes`),Pm=S([],`marks`);function Fm(e){return{...e,parseDOM:e.parseDOM?.map(t=>({priority:e.priority,...t}))}}var Im=e=>(e.inject(Mm,{}).inject(Nm,[]).inject(Pm,[]).inject(jm,[Om]).record(Am),async()=>{await e.waitTimers(jm);let t=e.get(wm),n=e.get(xm).reduce((e,t)=>e.use(t.plugin,t.options),t);e.set(wm,n);let r=new bo({nodes:Object.fromEntries(e.get(Nm).map(([e,t])=>[e,Fm(t)])),marks:Object.fromEntries(e.get(Pm).map(([e,t])=>[e,Fm(t)]))});return e.set(Mm,r),e.done(Am),()=>{e.remove(Mm).remove(Nm).remove(Pm).remove(jm).clearTimer(Am)}});pm(Im,{displayName:`Schema`});var Lm=class{constructor(){this.setCtx=e=>{this.#t=e},this.chain=()=>{if(this.#t==null)throw v();let e=this.#t,t=[],n=this.get.bind(this),r={run:()=>{let n=nl(...t),r=e.get(hm);return n(r.state,r.dispatch,r)},inline:e=>(t.push(e),r),pipe:i.bind(this)};function i(e,i){let a=n(e);return t.push(a(i)),r}return r}}#e=new x;#t=null;get ctx(){return this.#t}create(e,t){let n=e.create(this.#e.sliceMap);return n.set(t),n}get(e){return this.#e.get(e).get()}remove(e){return this.#e.remove(e)}call(e,t){if(this.#t==null)throw v();let n=this.get(e)(t),r=this.#t.get(hm);return n(r.state,r.dispatch,r)}inline(e){if(this.#t==null)throw v();let t=this.#t.get(hm);return e(t.state,t.dispatch,t)}};function Rm(e=`cmdKey`){return S((()=>()=>!1),e)}var Z=S(new Lm,`commands`),zm=S([Am],`commandsTimer`),Bm=E(`CommandsReady`),Vm=e=>{let t=new Lm;return t.setCtx(e),e.inject(Z,t).inject(zm,[Am]).record(Bm),async()=>(await e.waitTimers(zm),e.done(Bm),()=>{e.remove(Z).remove(zm).clearTimer(Bm)})};pm(Vm,{displayName:`Commands`});function Hm(e){return e.Backspace=nl(ul,Ec,kc,Mc),e}var Um=class{constructor(){this.setCtx=e=>{this.#e=e},this.add=e=>(this.#t.push(e),()=>{this.#t=this.#t.filter(t=>t!==e)}),this.addObjectKeymap=e=>{let t=[];return Object.entries(e).forEach(([e,n])=>{if(typeof n==`function`){let r={key:e,onRun:()=>n};this.#t.push(r),t.push(()=>{this.#t=this.#t.filter(e=>e!==r)})}else this.#t.push(n),t.push(()=>{this.#t=this.#t.filter(e=>e!==n)})}),()=>{t.forEach(e=>e())}},this.addBaseKeymap=()=>{let e=Hm(sl);return this.addObjectKeymap(e)},this.build=()=>{let e={};return this.#t.forEach(t=>{e[t.key]=[...e[t.key]||[],t]}),Object.fromEntries(Object.entries(e).map(([e,t])=>{let n=t.sort((e,t)=>(t.priority??50)-(e.priority??50));return[e,(e,t,r)=>{let i=this.#e;if(i==null)throw f();return nl(...n.map(e=>e.onRun(i)))(e,t,r)}]}))}}#e=null;#t=[];get ctx(){return this.#e}},Wm=S(new Um,`keymap`),Gm=S([Am],`keymapTimer`),Km=E(`KeymapReady`),qm=e=>{let t=new Um;return t.setCtx(e),e.inject(Wm,t).inject(Gm,[Am]).record(Km),async()=>(await e.waitTimers(Gm),e.done(Km),()=>{e.remove(Wm).remove(Gm).clearTimer(Km)})},Jm=E(`ParserReady`),Ym=(()=>{throw f()}),Xm=S(Ym,`parser`),Zm=S([],`parserTimer`),Qm=e=>(e.inject(Xm,Ym).inject(Zm,[Am]).record(Jm),async()=>{await e.waitTimers(Zm);let t=e.get(wm),n=e.get(Mm);return e.set(Xm,Kl.create(n,t)),e.done(Jm),()=>{e.remove(Xm).remove(Zm).clearTimer(Jm)}});pm(Qm,{displayName:`Parser`});var $m=E(`SerializerReady`),eh=S([],`serializerTimer`),th=(()=>{throw f()}),nh=S(th,`serializer`),rh=e=>(e.inject(nh,th).inject(eh,[Am]).record($m),async()=>{await e.waitTimers(eh);let t=e.get(wm),n=e.get(Mm);return e.set(nh,Yl.create(n,t)),e.done($m),()=>{e.remove(nh).remove(eh).clearTimer($m)}});pm(rh,{displayName:`Serializer`});var ih=S(``,`defaultValue`),ah=S(e=>e,`stateOptions`),oh=S([],`editorStateTimer`),sh=E(`EditorStateReady`);function ch(e,t,n){if(typeof e==`string`)return t(e);if(e.type===`html`)return wo.fromSchema(n).parse(e.dom);if(e.type===`json`)return Ja.fromJSON(n,e.value);throw l(e)}var lh=new Tc(`MILKDOWN_STATE_TRACKER`),uh=e=>(e.inject(ih,``).inject(gm,{}).inject(ah,e=>e).inject(oh,[Jm,$m,Bm,Km]).record(sh),async()=>{await e.waitTimers(oh);let t=e.get(Mm),n=e.get(Xm),r=e.get(ym),i=e.get(ah),a=e.get(bm),o=ch(e.get(ih),n,t),s=e.get(Wm),c=s.addBaseKeymap(),l=[...a,new Sc({key:lh,state:{init:()=>{},apply:(t,n,r,i)=>{e.set(gm,i)}}}),Tl({rules:r}),Vl(s.build())];e.set(bm,l);let u=i({schema:t,doc:o,plugins:l}),d=bc.create(u);return e.set(gm,d),e.done(sh),()=>{c(),e.remove(ih).remove(gm).remove(ah).remove(oh).clearTimer(sh)}});pm(uh,{displayName:`EditorState`});var dh=S([],`pasteRule`),fh=S([Am],`pasteRuleTimer`),ph=E(`PasteRuleReady`),mh=e=>(e.inject(dh,[]).inject(fh,[Am]).record(ph),async()=>(await e.waitTimers(fh),e.done(ph),()=>{e.remove(dh).remove(fh).clearTimer(ph)}));pm(mh,{displayName:`PasteRule`});var hh=E(`EditorViewReady`),gh=S([],`editorViewTimer`),_h=S({},`editorViewOptions`),vh=S(null,`root`),yh=S(null,`rootDOM`),bh=S({},`rootAttrs`);function xh(e,t){let n=document.createElement(`div`);n.className=`milkdown`,e.appendChild(n),t.set(yh,n);let r=t.get(bh);return Object.entries(r).forEach(([e,t])=>n.setAttribute(e,t)),n}function Sh(e){e.classList.add(`editor`),e.setAttribute(`role`,`textbox`)}var Ch=new Tc(`MILKDOWN_VIEW_CLEAR`),wh=e=>(e.inject(vh,document.body).inject(hm,{}).inject(_h,{}).inject(yh,null).inject(bh,{}).inject(gh,[sh,ph]).record(hh),async()=>{await e.wait(Om);let t=e.get(vh)||document.body,n=typeof t==`string`?document.querySelector(t):t;e.update(bm,t=>[new Sc({key:Ch,view:t=>{let r=n?xh(n,e):void 0;return(()=>{if(r&&n){let e=t.dom;n.replaceChild(r,e),r.appendChild(e)}})(),{destroy:()=>{r?.parentNode&&r?.parentNode.replaceChild(t.dom,r),r?.remove()}}}}),...t]),await e.waitTimers(gh);let r=e.get(gm),i=e.get(_h),a=new am(n,{state:r,nodeViews:Object.fromEntries(e.get(Sm)),markViews:Object.fromEntries(e.get(Cm)),transformPasted:(t,n,r)=>(e.get(dh).sort((e,t)=>(t.priority??50)-(e.priority??50)).map(e=>e.run).forEach(e=>{t=e(t,n,r)}),t),...i});return Sh(a.dom),e.set(hm,a),e.done(hh),()=>{a?.destroy(),e.remove(vh).remove(hm).remove(_h).remove(yh).remove(bh).remove(gh).clearTimer(hh)}});pm(wh,{displayName:`EditorView`});var Th=function(e){return e.Idle=`Idle`,e.OnCreate=`OnCreate`,e.Created=`Created`,e.OnDestroy=`OnDestroy`,e.Destroyed=`Destroyed`,e}({}),Eh=class e{constructor(){this.enableInspector=(e=!0)=>(this.#e=e,this),this.onStatusChange=e=>(this.#r=e,this),this.config=e=>(this.#n.push(e),this),this.removeConfig=e=>(this.#n=this.#n.filter(t=>t!==e),this),this.use=e=>{let t=[e].flat();return t.flat().forEach(e=>{this.#o.set(e,{ctx:void 0,handler:void 0,cleanup:void 0})}),this.#t===Th.Created&&this.#u(t,this.#o),this},this.remove=async e=>this.#t===Th.OnCreate?(console.warn(`[Milkdown]: You are trying to remove plugins when the editor is creating, this is not recommended, please check your code.`),new Promise(t=>{setTimeout(()=>{t(this.remove(e))},50)})):(await this.#d([e].flat(),!0),this),this.create=async()=>this.#t===Th.OnCreate?this:(this.#t===Th.Created&&await this.destroy(),this.#p(Th.OnCreate),this.#l(),this.#u([...this.#o.keys()],this.#o),await Promise.all([this.#m(this.#s),this.#m(this.#o)].flat()),this.#p(Th.Created),this),this.destroy=async(e=!1)=>this.#t===Th.Destroyed||this.#t===Th.OnDestroy?this:this.#t===Th.OnCreate?new Promise(t=>{setTimeout(()=>{t(this.destroy(e))},50)}):(e&&(this.#n=[]),this.#p(Th.OnDestroy),await this.#d([...this.#o.keys()],e),await this.#f(),this.#p(Th.Destroyed),this),this.action=e=>e(this.#c),this.inspect=()=>this.#e?[...this.#s.values(),...this.#o.values()].map(({ctx:e})=>e?.inspector?.read()).filter(e=>!!e):(console.warn("[Milkdown]: You are trying to collect inspection when inspector is disabled, please enable inspector by `editor.enableInspector()` first."),[])}static make(){return new e}#e=!1;#t=Th.Idle;#n=[];#r=()=>void 0;#i=new x;#a=new ne;#o=new Map;#s=new Map;#c=new w(this.#i,this.#a);#l=()=>{let e=Dm(async e=>{await Promise.all(this.#n.map(t=>Promise.resolve(t(e))))}),t=[Im,Qm,rh,Vm,qm,mh,uh,wh,km(this),e];this.#u(t,this.#s)};#u=(e,t)=>{e.forEach(e=>{let n=this.#c.produce(this.#e?e.meta:void 0),r=e(n);t.set(e,{ctx:n,handler:r,cleanup:void 0})})};#d=(e,t=!1)=>Promise.all([e].flat().map(async e=>{let n=this.#o.get(e)?.cleanup;return t?this.#o.delete(e):this.#o.set(e,{ctx:void 0,handler:void 0,cleanup:void 0}),typeof n==`function`?n():n}));#f=async()=>{await Promise.all([...this.#s.entries()].map(async([e,{cleanup:t}])=>typeof t==`function`?t():t)),this.#s.clear()};#p=e=>{this.#t=e,this.#r(e)};#m=e=>[...e.entries()].map(async([t,n])=>{let{ctx:r,handler:i}=n;if(!i)return;let a=await i();e.set(t,{ctx:r,handler:i,cleanup:a})});get ctx(){return this.#c}get status(){return this.#t}},Dh=typeof global==`object`&&global&&global.Object===Object&&global,Oh=typeof self==`object`&&self&&self.Object===Object&&self,kh=Dh||Oh||Function(`return this`)(),Ah=kh.Symbol,jh=Object.prototype,Mh=jh.hasOwnProperty,Nh=jh.toString,Ph=Ah?Ah.toStringTag:void 0;function Fh(e){var t=Mh.call(e,Ph),n=e[Ph];try{e[Ph]=void 0;var r=!0}catch{}var i=Nh.call(e);return r&&(t?e[Ph]=n:delete e[Ph]),i}var Ih=Object.prototype.toString;function Lh(e){return Ih.call(e)}var Rh=`[object Null]`,zh=`[object Undefined]`,Bh=Ah?Ah.toStringTag:void 0;function Vh(e){return e==null?e===void 0?zh:Rh:Bh&&Bh in Object(e)?Fh(e):Lh(e)}function Hh(e){return typeof e==`object`&&!!e}var Uh=`[object Symbol]`;function Wh(e){return typeof e==`symbol`||Hh(e)&&Vh(e)==Uh}var Gh=/\s/;function Kh(e){for(var t=e.length;t--&&Gh.test(e.charAt(t)););return t}var qh=/^\s+/;function Jh(e){return e&&e.slice(0,Kh(e)+1).replace(qh,``)}function Yh(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}var Xh=NaN,Zh=/^[-+]0x[0-9a-f]+$/i,Qh=/^0b[01]+$/i,$h=/^0o[0-7]+$/i,eg=parseInt;function tg(e){if(typeof e==`number`)return e;if(Wh(e))return Xh;if(Yh(e)){var t=typeof e.valueOf==`function`?e.valueOf():e;e=Yh(t)?t+``:t}if(typeof e!=`string`)return e===0?e:+e;e=Jh(e);var n=Qh.test(e);return n||$h.test(e)?eg(e.slice(2),n?2:8):Zh.test(e)?Xh:+e}var ng=function(){return kh.Date.now()},rg=`Expected a function`,ig=Math.max,ag=Math.min;function og(e,t,n){var r,i,a,o,s,c,l=0,u=!1,d=!1,f=!0;if(typeof e!=`function`)throw TypeError(rg);t=tg(t)||0,Yh(n)&&(u=!!n.leading,d=`maxWait`in n,a=d?ig(tg(n.maxWait)||0,t):a,f=`trailing`in n?!!n.trailing:f);function p(t){var n=r,a=i;return r=i=void 0,l=t,o=e.apply(a,n),o}function m(e){return l=e,s=setTimeout(_,t),u?p(e):o}function h(e){var n=e-c,r=e-l,i=t-n;return d?ag(i,a-r):i}function g(e){var n=e-c,r=e-l;return c===void 0||n>=t||n<0||d&&r>=a}function _(){var e=ng();if(g(e))return v(e);s=setTimeout(_,h(e))}function v(e){return s=void 0,f&&r?p(e):(r=i=void 0,o)}function y(){s!==void 0&&clearTimeout(s),l=0,r=c=i=s=void 0}function b(){return s===void 0?o:v(ng())}function x(){var e=ng(),n=g(e);if(r=arguments,i=this,c=e,n){if(s===void 0)return m(c);if(d)return clearTimeout(s),s=setTimeout(_,t),p(c)}return s===void 0&&(s=setTimeout(_,t)),o}return x.cancel=y,x.flush=b,x}var sg=class{constructor(){this.beforeMountedListeners=[],this.mountedListeners=[],this.updatedListeners=[],this.selectionUpdatedListeners=[],this.markdownUpdatedListeners=[],this.blurListeners=[],this.focusListeners=[],this.destroyListeners=[],this.beforeMount=e=>(this.beforeMountedListeners.push(e),this),this.mounted=e=>(this.mountedListeners.push(e),this),this.updated=e=>(this.updatedListeners.push(e),this)}get listeners(){return{beforeMount:this.beforeMountedListeners,mounted:this.mountedListeners,updated:this.updatedListeners,markdownUpdated:this.markdownUpdatedListeners,blur:this.blurListeners,focus:this.focusListeners,destroy:this.destroyListeners,selectionUpdated:this.selectionUpdatedListeners}}markdownUpdated(e){return this.markdownUpdatedListeners.push(e),this}blur(e){return this.blurListeners.push(e),this}focus(e){return this.focusListeners.push(e),this}destroy(e){return this.destroyListeners.push(e),this}selectionUpdated(e){return this.selectionUpdatedListeners.push(e),this}},cg=S(new sg,`listener`),lg=new Tc(`MILKDOWN_LISTENER`),ug=e=>(e.inject(cg,new sg),async()=>{await e.wait(Om);let{listeners:t}=e.get(cg);t.beforeMount.forEach(t=>t(e)),await e.wait($m);let n=e.get(nh),r=null,i=null,a=null,o=null,s=og(()=>{if(!o)return;let{doc:a}=o;if(t.updated.length>0&&r&&!r.eq(a)&&t.updated.forEach(t=>{t(e,a,r)}),t.markdownUpdated.length>0&&r&&!r.eq(a)){let r=n(a);t.markdownUpdated.forEach(t=>{t(e,r,i)}),i=r}r=a,o=null},200),c=new Sc({key:lg,view:()=>({destroy:()=>{t.destroy.forEach(t=>t(e))}}),props:{handleDOMEvents:{focus:()=>(t.focus.forEach(t=>t(e)),!1),blur:()=>(t.blur.forEach(t=>t(e)),!1)}},state:{init:(e,t)=>{r=t.doc,i=n(t.doc)},apply:n=>{let r=n.selection;(!a&&r||a&&!r.eq(a))&&(t.selectionUpdated.forEach(t=>{t(e,r,a)}),a=r),!(!(n.docChanged||n.storedMarksSet)||n.getMeta(`addToHistory`)===!1)&&(o=n,s())}}});e.update(bm,e=>e.concat(c)),await e.wait(hh),t.mounted.forEach(t=>t(e))});ug.meta={package:`@milkdown/plugin-listener`,displayName:`Listener`};var dg=e=>crypto.getRandomValues(new Uint8Array(e)),fg=(e,t,n)=>{let r=(2<<Math.log2(e.length-1))-1,i=-~(1.6*r*t/e.length);return(a=t)=>{let o=``;for(;;){let t=n(i),s=i|0;for(;s--;)if(o+=e[t[s]&r]||``,o.length>=a)return o}}};((e,t=21)=>fg(e,t|0,dg))(`abcedfghicklmn`,10);function Q(e,t){let n=Rm(e),r=i=>async()=>{r.key=n,await i.wait(Bm);let a=t(i);return i.get(Z).create(n,a),r.run=t=>i.get(Z).call(e,t),()=>{i.get(Z).remove(n)}};return r}function pg(e){let t=n=>async()=>{await n.wait(Am);let r=e(n);return n.update(ym,e=>[...e,r]),t.inputRule=r,()=>{n.update(ym,e=>e.filter(e=>e!==r))}};return t}function mg(e,t){let n=r=>async()=>{let i=t(r);return r.update(Pm,t=>[...t.filter(t=>t[0]!==e),[e,i]]),n.id=e,n.schema=i,()=>{r.update(Pm,t=>t.filter(([t])=>t!==e))}};return n.type=t=>{let n=t.get(Mm).marks[e];if(!n)throw b(e);return n},n}function hg(e,t){let n=r=>async()=>{let i=t(r);return r.update(Nm,t=>[...t.filter(t=>t[0]!==e),[e,i]]),n.id=e,n.schema=i,()=>{r.update(Nm,t=>t.filter(([t])=>t!==e))}};return n.type=t=>{let n=t.get(Mm).nodes[e];if(!n)throw y(e);return n},n}function gg(e){let t,n=n=>async()=>(await n.wait(Am),t=e(n),n.update(bm,e=>[...e,t]),()=>{n.update(bm,e=>e.filter(e=>e!==t))});return n.plugin=()=>t,n.key=()=>t.spec.key,n}function _g(e){let t=n=>async()=>{await n.wait(Km);let r=n.get(Wm),i=e(n),a=r.addObjectKeymap(i);return t.keymap=i,()=>{a()}};return t}function vg(e,t){let n=S(e,t),r=e=>(e.inject(n),()=>()=>{e.remove(n)});return r.key=n,r}function yg(e,t){let n=vg(t,e),r=hg(e,e=>e.get(n.key)(e)),i=[n,r];return i.id=r.id,i.node=r,i.type=e=>r.type(e),i.ctx=n,i.key=n.key,i.extendSchema=n=>yg(e,n(t)),i}function bg(e,t){let n=vg(t,e),r=mg(e,e=>e.get(n.key)(e)),i=[n,r];return i.id=r.id,i.mark=r,i.type=e=>r.type(e),i.ctx=n,i.key=n.key,i.extendSchema=n=>bg(e,n(t)),i}function xg(e,t){let n=vg(Object.fromEntries(Object.entries(t).map(([e,{shortcuts:t,priority:n}])=>[e,{shortcuts:t,priority:n}])),`${e}Keymap`),r=_g(e=>{let r=e.get(n.key),i=Object.entries(t).flatMap(([e,{command:t}])=>{let n=r[e],i=[n.shortcuts].flat(),a=n.priority;return i.map(e=>[e,{key:e,onRun:t,priority:a}])});return Object.fromEntries(i)}),i=[n,r];return i.ctx=n,i.shortcuts=r,i.key=n.key,i.keymap=r.keymap,i}var Sg=(e,t=()=>({}))=>vg(t,`${e}Attr`),Cg=(e,t=()=>({}))=>vg(t,`${e}Attr`);function wg(e,t,n){let r=vg(n??{},e),i=e=>async()=>{await e.wait(Om);let n={plugin:t(e),options:e.get(r.key)};return e.update(xm,e=>[...e,n]),()=>{e.update(xm,e=>e.filter(e=>e!==n))}},a=[r,i];return a.id=e,a.plugin=i,a.options=r,a}function Tg(){return e=>{let t=document.createElement(`div`),n=e.get(Mm),r=e.get(hm),i=Ro.fromSchema(n).serializeFragment(r.state.doc.content);return t.appendChild(i),t.innerHTML}}function Eg(e,t=!1){return n=>{let r=n.get(hm),i=n.get(Xm)(e);if(!i)return;if(!t){let{state:e}=r;return r.dispatch(e.tr.replace(0,e.doc.content.size,new L(i.content,0,0)))}let a=n.get(Mm),o=n.get(ah)({schema:a,doc:i,plugins:n.get(bm)}),s=bc.create(o);r.updateState(s)}}function Dg(e,t){return function(n,r){let{$from:i,$to:a,node:o}=n.selection;if(o&&o.isBlock||i.depth<2||!i.sameParent(a))return!1;let s=i.node(-1);if(s.type!=e)return!1;if(i.parent.content.size==0&&i.node(-1).childCount==i.indexAfter(-1)){if(i.depth==3||i.node(-3).type!=e||i.index(-2)!=i.node(-2).childCount-1)return!1;if(r){let t=F.empty,a=i.index(-1)?1:i.index(-2)?2:3;for(let e=i.depth-a;e>=i.depth-3;e--)t=F.from(i.node(e).copy(t));let o=i.indexAfter(-1)<i.node(-2).childCount?1:i.indexAfter(-2)<i.node(-3).childCount?2:3;t=t.append(F.from(e.createAndFill()));let s=i.before(i.depth-(a-1)),c=n.tr.replace(s,i.after(-o),new L(t,4-a,0)),l=-1;c.doc.nodesBetween(s,c.doc.content.size,(e,t)=>{if(l>-1)return!1;e.isTextblock&&e.content.size==0&&(l=t+1)}),l>-1&&c.setSelection(B.near(c.doc.resolve(l))),r(c.scrollIntoView())}return!0}let c=a.pos==i.end()?s.contentMatchAt(0).defaultType:null,l=n.tr.delete(i.pos,a.pos),u=c?[t?{type:e,attrs:t}:null,{type:c}]:void 0;return ks(l.doc,i.pos,2,u)?(r&&r(l.split(i.pos,2,u).scrollIntoView()),!0):!1}}function Og(e){return function(t,n){let{$from:r,$to:i}=t.selection,a=r.blockRange(i,t=>t.childCount>0&&t.firstChild.type==e);return a?n?r.node(a.depth-1).type==e?kg(t,n,e,a):Ag(t,n,a):!0:!1}}function kg(e,t,n,r){let i=e.tr,a=r.end,o=r.$to.end(r.depth);a<o&&(i.step(new ds(a-1,o,a,o,new L(F.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new Ka(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));let s=_s(r);if(s==null)return!1;i.lift(r,s);let c=i.doc.resolve(i.mapping.map(a,-1)-1);return js(i.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&i.join(c.pos),t(i.scrollIntoView()),!0}function Ag(e,t,n){let r=e.tr,i=n.parent;for(let e=n.end,t=n.endIndex-1,a=n.startIndex;t>a;t--)e-=i.child(t).nodeSize,r.delete(e-1,e+1);let a=r.doc.resolve(n.start),o=a.nodeAfter;if(r.mapping.map(n.end)!=n.start+a.nodeAfter.nodeSize)return!1;let s=n.startIndex==0,c=n.endIndex==i.childCount,l=a.node(-1),u=a.index(-1);if(!l.canReplace(u+(s?0:1),u+1,o.content.append(c?F.empty:F.from(i))))return!1;let d=a.pos,f=d+o.nodeSize;return r.step(new ds(d-(s?1:0),f+(c?1:0),d+1,f-1,new L((s?F.empty:F.from(i.copy(F.empty))).append(c?F.empty:F.from(i.copy(F.empty))),s?0:1,c?0:1),s?0:1)),t(r.scrollIntoView()),!0}function jg(e){return function(t,n){let{$from:r,$to:i}=t.selection,a=r.blockRange(i,t=>t.childCount>0&&t.firstChild.type==e);if(!a)return!1;let o=a.startIndex;if(o==0)return!1;let s=a.parent,c=s.child(o-1);if(c.type!=e)return!1;if(n){let r=c.lastChild&&c.lastChild.type==s.type,i=F.from(r?e.create():null),o=new L(F.from(e.create(null,F.from(s.type.create(null,i)))),r?3:1,0),l=a.start,u=a.end;n(t.tr.step(new ds(l-(r?3:1),u,l,u,o,1,!0)).scrollIntoView())}return!0}}function Mg(e){let t=new Map;if(!e||!e.type)throw Error(`mdast-util-definitions expected node`);return zr(e,`definition`,function(e){let n=Ng(e.identifier);n&&!t.get(n)&&t.set(n,e)}),n;function n(e){let n=Ng(e);return t.get(n)}}function Ng(e){return String(e||``).toUpperCase()}function Pg(){return function(e){let t=Mg(e);zr(e,function(e,n,r){if(e.type===`definition`&&r!==void 0&&typeof n==`number`)return r.children.splice(n,1),[Ir,n];if(e.type===`imageReference`||e.type===`linkReference`){let i=t(e.identifier);if(i&&r&&typeof n==`number`)return r.children[n]=e.type===`imageReference`?{type:`image`,url:i.url,title:i.title,alt:e.alt}:{type:`link`,url:i.url,title:i.title,children:e.children},[Ir,n]}})}}function Fg(e,t){if(!(t.childCount>=1&&t.lastChild?.type.name===`hardbreak`)){e.next(t.content);return}let n=[];t.content.forEach((e,r,i)=>{i!==t.childCount-1&&n.push(e)}),e.next(F.fromArray(n))}function $(e,t){return Object.assign(e,{meta:{package:`@milkdown/preset-commonmark`,...t}}),e}var Ig=Cg(`emphasis`);$(Ig,{displayName:`Attr<emphasis>`,group:`Emphasis`});var Lg=bg(`emphasis`,e=>({attrs:{marker:{default:e.get(Tm).emphasis||`*`,validate:`string`}},parseDOM:[{tag:`i`},{tag:`em`},{style:`font-style`,getAttrs:e=>e===`italic`}],toDOM:t=>[`em`,e.get(Ig.key)(t)],parseMarkdown:{match:e=>e.type===`emphasis`,runner:(e,t,n)=>{e.openMark(n,{marker:t.marker}),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>e.type.name===`emphasis`,runner:(e,t)=>{e.withMark(t,`emphasis`,void 0,{marker:t.attrs.marker})}}}));$(Lg.mark,{displayName:`MarkSchema<emphasis>`,group:`Emphasis`}),$(Lg.ctx,{displayName:`MarkSchemaCtx<emphasis>`,group:`Emphasis`});var Rg=Q(`ToggleEmphasis`,e=>()=>tl(Lg.type(e)));$(Rg,{displayName:`Command<toggleEmphasisCommand>`,group:`Emphasis`});var zg=pg(e=>El(/(?:^|[^*])\*([^*]+)\*$/,Lg.type(e),{getAttr:()=>({marker:`*`}),updateCaptured:({fullMatch:e,start:t})=>e.startsWith(`*`)?{}:{fullMatch:e.slice(1),start:t+1}}));$(zg,{displayName:`InputRule<emphasis>|Star`,group:`Emphasis`});var Bg=pg(e=>El(/\b_(?![_\s])(.*?[^_\s])_\b/,Lg.type(e),{getAttr:()=>({marker:`_`}),updateCaptured:({fullMatch:e,start:t})=>e.startsWith(`_`)?{}:{fullMatch:e.slice(1),start:t+1}}));$(Bg,{displayName:`InputRule<emphasis>|Underscore`,group:`Emphasis`});var Vg=xg(`emphasisKeymap`,{ToggleEmphasis:{shortcuts:`Mod-i`,command:e=>{let t=e.get(Z);return()=>t.call(Rg.key)}}});$(Vg.ctx,{displayName:`KeymapCtx<emphasis>`,group:`Emphasis`}),$(Vg.shortcuts,{displayName:`Keymap<emphasis>`,group:`Emphasis`});var Hg=Cg(`strong`);$(Hg,{displayName:`Attr<strong>`,group:`Strong`});var Ug=bg(`strong`,e=>({attrs:{marker:{default:e.get(Tm).strong||`*`,validate:`string`}},parseDOM:[{tag:`b`,getAttrs:e=>e.style.fontWeight!=`normal`&&null},{tag:`strong`},{style:`font-style`,getAttrs:e=>e===`bold`},{style:`font-weight=400`,clearMark:e=>e.type.name==`strong`},{style:`font-weight`,getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}],toDOM:t=>[`strong`,e.get(Hg.key)(t)],parseMarkdown:{match:e=>e.type===`strong`,runner:(e,t,n)=>{e.openMark(n,{marker:t.marker}),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>e.type.name===`strong`,runner:(e,t)=>{e.withMark(t,`strong`,void 0,{marker:t.attrs.marker})}}}));$(Ug.mark,{displayName:`MarkSchema<strong>`,group:`Strong`}),$(Ug.ctx,{displayName:`MarkSchemaCtx<strong>`,group:`Strong`});var Wg=Q(`ToggleStrong`,e=>()=>tl(Ug.type(e)));$(Wg,{displayName:`Command<toggleStrongCommand>`,group:`Strong`});var Gg=pg(e=>El(/(?<![\w:/])(?:\*\*|__)([^*_]+?)(?:\*\*|__)(?![\w/])$/,Ug.type(e),{getAttr:e=>({marker:e[0].startsWith(`*`)?`*`:`_`})}));$(Gg,{displayName:`InputRule<strong>`,group:`Strong`});var Kg=xg(`strongKeymap`,{ToggleBold:{shortcuts:[`Mod-b`],command:e=>{let t=e.get(Z);return()=>t.call(Wg.key)}}});$(Kg.ctx,{displayName:`KeymapCtx<strong>`,group:`Strong`}),$(Kg.shortcuts,{displayName:`Keymap<strong>`,group:`Strong`});var qg=Cg(`inlineCode`);$(qg,{displayName:`Attr<inlineCode>`,group:`InlineCode`});var Jg=bg(`inlineCode`,e=>({priority:100,code:!0,parseDOM:[{tag:`code`}],toDOM:t=>[`code`,e.get(qg.key)(t)],parseMarkdown:{match:e=>e.type===`inlineCode`,runner:(e,t,n)=>{e.openMark(n),e.addText(t.value),e.closeMark(n)}},toMarkdown:{match:e=>e.type.name===`inlineCode`,runner:(e,t,n)=>(e.withMark(t,`inlineCode`,n.text||``),!0)}}));$(Jg.mark,{displayName:`MarkSchema<inlineCode>`,group:`InlineCode`}),$(Jg.ctx,{displayName:`MarkSchemaCtx<inlineCode>`,group:`InlineCode`});var Yg=Q(`ToggleInlineCode`,e=>()=>(t,n)=>{let{selection:r,tr:i}=t;if(r.empty)return!1;let{from:a,to:o}=r;return t.doc.rangeHasMark(a,o,Jg.type(e))?(n?.(i.removeMark(a,o,Jg.type(e))),!0):(Object.keys(t.schema.marks).filter(e=>e!==Jg.type.name).map(e=>t.schema.marks[e]).forEach(e=>{i.removeMark(a,o,e)}),n?.(i.addMark(a,o,Jg.type(e).create())),!0)});$(Yg,{displayName:`Command<toggleInlineCodeCommand>`,group:`InlineCode`});var Xg=pg(e=>El(/(?:`)([^`]+)(?:`)$/,Jg.type(e)));$(Xg,{displayName:`InputRule<inlineCodeInputRule>`,group:`InlineCode`});var Zg=xg(`inlineCodeKeymap`,{ToggleInlineCode:{shortcuts:`Mod-e`,command:e=>{let t=e.get(Z);return()=>t.call(Yg.key)}}});$(Zg.ctx,{displayName:`KeymapCtx<inlineCode>`,group:`InlineCode`}),$(Zg.shortcuts,{displayName:`Keymap<inlineCode>`,group:`InlineCode`});var Qg=Cg(`link`);$(Qg,{displayName:`Attr<link>`,group:`Link`});var $g=bg(`link`,e=>({attrs:{href:{validate:`string`},title:{default:null,validate:`string|null`}},parseDOM:[{tag:`a[href]`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw _(e);return{href:e.getAttribute(`href`),title:e.getAttribute(`title`)}}}],toDOM:t=>[`a`,{...e.get(Qg.key)(t),...t.attrs}],parseMarkdown:{match:e=>e.type===`link`,runner:(e,t,n)=>{let r=t.url,i=t.title;e.openMark(n,{href:r,title:i}),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>e.type.name===`link`,runner:(e,t)=>{e.withMark(t,`link`,void 0,{title:t.attrs.title,url:t.attrs.href})}}}));$($g.mark,{displayName:`MarkSchema<link>`,group:`Link`});var e_=Q(`ToggleLink`,e=>(t={})=>tl($g.type(e),t));$(e_,{displayName:`Command<toggleLinkCommand>`,group:`Link`});var t_=Q(`UpdateLink`,e=>(t={})=>(n,r)=>{if(!r)return!1;let i,a=-1,{selection:o}=n,{from:s,to:c}=o;if(n.doc.nodesBetween(s,s===c?c+1:c,(t,n)=>{if($g.type(e).isInSet(t.marks))return i=t,a=n,!1}),!i)return!1;let l=i.marks.find(({type:t})=>t===$g.type(e));if(!l)return!1;let u=a,d=a+i.nodeSize,{tr:f}=n,p=$g.type(e).create({...l.attrs,...t});return p?(r(f.removeMark(u,d,l).addMark(u,d,p).setSelection(new V(f.selection.$anchor)).scrollIntoView()),!0):!1});$(t_,{displayName:`Command<updateLinkCommand>`,group:`Link`});var n_=hg(`doc`,()=>({content:`block+`,parseMarkdown:{match:({type:e})=>e===`root`,runner:(e,t,n)=>{e.injectRoot(t,n)}},toMarkdown:{match:e=>e.type.name===`doc`,runner:(e,t)=>{e.openNode(`root`),e.next(t.content)}}}));$(n_,{displayName:`NodeSchema<doc>`,group:`Doc`});function r_(e){return Lr(e,e=>e.type===`html`&&[`<br />`,`<br>`,`<br >`,`<br/>`].includes(e.value?.trim()),(e,t)=>{if(!t.length)return;let n=t[t.length-1];if(!n)return;let r=n.children.indexOf(e);r!==-1&&n.children.splice(r,1)},!0)}var i_=wg(`remark-preserve-empty-line`,()=>()=>r_);$(i_.plugin,{displayName:`Remark<remarkPreserveEmptyLine>`,group:`Remark`}),$(i_.options,{displayName:`RemarkConfig<remarkPreserveEmptyLine>`,group:`Remark`});var a_=Sg(`paragraph`);$(a_,{displayName:`Attr<paragraph>`,group:`Paragraph`});var o_=yg(`paragraph`,e=>({content:`inline*`,group:`block`,parseDOM:[{tag:`p`}],toDOM:t=>[`p`,e.get(a_.key)(t),0],parseMarkdown:{match:e=>e.type===`paragraph`,runner:(e,t,n)=>{e.openNode(n),t.children?e.next(t.children):e.addText(t.value||``),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`paragraph`,runner:(t,n)=>{let r=e.get(hm).state?.doc.lastChild;t.openNode(`paragraph`),(!n.content||n.content.size===0)&&n!==r&&s_(e)?t.addNode(`html`,void 0,`<br />`):Fg(t,n),t.closeNode()}}}));function s_(e){let t=!1;try{e.get(i_.id),t=!0}catch{t=!1}return t}$(o_.node,{displayName:`NodeSchema<paragraph>`,group:`Paragraph`}),$(o_.ctx,{displayName:`NodeSchemaCtx<paragraph>`,group:`Paragraph`});var c_=Q(`TurnIntoText`,e=>()=>Qc(o_.type(e)));$(c_,{displayName:`Command<turnIntoTextCommand>`,group:`Paragraph`});var l_=xg(`paragraphKeymap`,{TurnIntoText:{shortcuts:`Mod-Alt-0`,command:e=>{let t=e.get(Z);return()=>t.call(c_.key)}}});$(l_.ctx,{displayName:`KeymapCtx<paragraph>`,group:`Paragraph`}),$(l_.shortcuts,{displayName:`Keymap<paragraph>`,group:`Paragraph`});var u_=[,,,,,,].fill(0).map((e,t)=>t+1);function d_(e){return e.textContent.toLowerCase().trim().replace(/\s+/g,`-`)}var f_=vg(d_,`headingIdGenerator`);$(f_,{displayName:`Ctx<HeadingIdGenerator>`,group:`Heading`});var p_=Sg(`heading`);$(p_,{displayName:`Attr<heading>`,group:`Heading`});var m_=yg(`heading`,e=>{let t=e.get(f_.key);return{content:`inline*`,group:`block`,defining:!0,attrs:{id:{default:``,validate:`string`},level:{default:1,validate:`number`}},parseDOM:u_.map(e=>({tag:`h${e}`,getAttrs:t=>{if(!(t instanceof HTMLElement))throw _(t);return{level:e,id:t.id}}})),toDOM:n=>[`h${n.attrs.level}`,{...e.get(p_.key)(n),id:n.attrs.id||t(n)},0],parseMarkdown:{match:({type:e})=>e===`heading`,runner:(e,t,n)=>{let r=t.depth;e.openNode(n,{level:r}),e.next(t.children),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`heading`,runner:(e,t)=>{e.openNode(`heading`,void 0,{depth:t.attrs.level}),Fg(e,t),e.closeNode()}}}});$(m_.node,{displayName:`NodeSchema<heading>`,group:`Heading`}),$(m_.ctx,{displayName:`NodeSchemaCtx<heading>`,group:`Heading`});var h_=pg(e=>fl(/^(?<hashes>#+)\s$/,m_.type(e),t=>{let n=t.groups?.hashes?.length||0,{$from:r}=e.get(hm).state.selection,i=r.node();if(i.type.name===`heading`){let e=Number(i.attrs.level)+Number(n);return e>6&&(e=6),{level:e}}return{level:n}}));$(h_,{displayName:`InputRule<wrapInHeadingInputRule>`,group:`Heading`});var g_=Q(`WrapInHeading`,e=>t=>(t??=1,t<1?Qc(o_.type(e)):Qc(m_.type(e),{level:t})));$(g_,{displayName:`Command<wrapInHeadingCommand>`,group:`Heading`});var __=Q(`DowngradeHeading`,e=>()=>(t,n,r)=>{let{$from:i}=t.selection,a=i.node();if(a.type!==m_.type(e)||!t.selection.empty||i.parentOffset!==0)return!1;let o=a.attrs.level-1;return o?(n?.(t.tr.setNodeMarkup(t.selection.$from.before(),void 0,{...a.attrs,level:o})),!0):Qc(o_.type(e))(t,n,r)});$(__,{displayName:`Command<downgradeHeadingCommand>`,group:`Heading`});var v_=xg(`headingKeymap`,{TurnIntoH1:{shortcuts:`Mod-Alt-1`,command:e=>{let t=e.get(Z);return()=>t.call(g_.key,1)}},TurnIntoH2:{shortcuts:`Mod-Alt-2`,command:e=>{let t=e.get(Z);return()=>t.call(g_.key,2)}},TurnIntoH3:{shortcuts:`Mod-Alt-3`,command:e=>{let t=e.get(Z);return()=>t.call(g_.key,3)}},TurnIntoH4:{shortcuts:`Mod-Alt-4`,command:e=>{let t=e.get(Z);return()=>t.call(g_.key,4)}},TurnIntoH5:{shortcuts:`Mod-Alt-5`,command:e=>{let t=e.get(Z);return()=>t.call(g_.key,5)}},TurnIntoH6:{shortcuts:`Mod-Alt-6`,command:e=>{let t=e.get(Z);return()=>t.call(g_.key,6)}},DowngradeHeading:{shortcuts:[`Delete`,`Backspace`],command:e=>{let t=e.get(Z);return()=>t.call(__.key)}}});$(v_.ctx,{displayName:`KeymapCtx<heading>`,group:`Heading`}),$(v_.shortcuts,{displayName:`Keymap<heading>`,group:`Heading`});var y_=Sg(`blockquote`);$(y_,{displayName:`Attr<blockquote>`,group:`Blockquote`});var b_=yg(`blockquote`,e=>({content:`block+`,group:`block`,defining:!0,parseDOM:[{tag:`blockquote`}],toDOM:t=>[`blockquote`,e.get(y_.key)(t),0],parseMarkdown:{match:({type:e})=>e===`blockquote`,runner:(e,t,n)=>{e.openNode(n).next(t.children).closeNode()}},toMarkdown:{match:e=>e.type.name===`blockquote`,runner:(e,t)=>{e.openNode(`blockquote`).next(t.content).closeNode()}}}));$(b_.node,{displayName:`NodeSchema<blockquote>`,group:`Blockquote`}),$(b_.ctx,{displayName:`NodeSchemaCtx<blockquote>`,group:`Blockquote`});var x_=pg(e=>dl(/^\s*>\s$/,b_.type(e)));$(x_,{displayName:`InputRule<wrapInBlockquoteInputRule>`,group:`Blockquote`});var S_=Q(`WrapInBlockquote`,e=>()=>Zc(b_.type(e)));$(S_,{displayName:`Command<wrapInBlockquoteCommand>`,group:`Blockquote`});var C_=xg(`blockquoteKeymap`,{WrapInBlockquote:{shortcuts:`Mod-Shift-b`,command:e=>{let t=e.get(Z);return()=>t.call(S_.key)}}});$(C_.ctx,{displayName:`KeymapCtx<blockquote>`,group:`Blockquote`}),$(C_.shortcuts,{displayName:`Keymap<blockquote>`,group:`Blockquote`});var w_=Sg(`codeBlock`,()=>({pre:{},code:{}}));$(w_,{displayName:`Attr<codeBlock>`,group:`CodeBlock`});var T_=yg(`code_block`,e=>({content:`text*`,group:`block`,marks:``,defining:!0,code:!0,attrs:{language:{default:``,validate:`string`}},parseDOM:[{tag:`pre`,preserveWhitespace:`full`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw _(e);return{language:e.dataset.language}}}],toDOM:t=>{let n=e.get(w_.key)(t),r=t.attrs.language,i=r&&r.length>0?{"data-language":r}:void 0;return[`pre`,{...n.pre,...i},[`code`,n.code,0]]},parseMarkdown:{match:({type:e})=>e===`code`,runner:(e,t,n)=>{let r=t.lang??``,i=t.value;e.openNode(n,{language:r}),i&&e.addText(i),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`code_block`,runner:(e,t)=>{e.addNode(`code`,void 0,t.content.firstChild?.text||``,{lang:t.attrs.language})}}}));$(T_.node,{displayName:`NodeSchema<codeBlock>`,group:`CodeBlock`}),$(T_.ctx,{displayName:`NodeSchemaCtx<codeBlock>`,group:`CodeBlock`});var E_=pg(e=>fl(/^```(?<language>[a-z]*)?[\s\n]$/,T_.type(e),e=>({language:e.groups?.language??``})));$(E_,{displayName:`InputRule<createCodeBlockInputRule>`,group:`CodeBlock`});var D_=Q(`CreateCodeBlock`,e=>(t=``)=>Qc(T_.type(e),{language:t}));$(D_,{displayName:`Command<createCodeBlockCommand>`,group:`CodeBlock`}),$(Q(`UpdateCodeBlockLanguage`,()=>({pos:e,language:t}={pos:-1,language:``})=>(n,r)=>e>=0?(r?.(n.tr.setNodeAttribute(e,`language`,t)),!0):!1),{displayName:`Command<updateCodeBlockLanguageCommand>`,group:`CodeBlock`});var O_=xg(`codeBlockKeymap`,{CreateCodeBlock:{shortcuts:`Mod-Alt-c`,command:e=>{let t=e.get(Z);return()=>t.call(D_.key)}}});$(O_.ctx,{displayName:`KeymapCtx<codeBlock>`,group:`CodeBlock`}),$(O_.shortcuts,{displayName:`Keymap<codeBlock>`,group:`CodeBlock`});var k_=Sg(`image`);$(k_,{displayName:`Attr<image>`,group:`Image`});var A_=yg(`image`,e=>({inline:!0,group:`inline`,selectable:!0,draggable:!0,marks:``,atom:!0,defining:!0,isolating:!0,attrs:{src:{default:``,validate:`string`},alt:{default:``,validate:`string`},title:{default:``,validate:`string`}},parseDOM:[{tag:`img[src]`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw _(e);return{src:e.getAttribute(`src`)||``,alt:e.getAttribute(`alt`)||``,title:e.getAttribute(`title`)||e.getAttribute(`alt`)||``}}}],toDOM:t=>[`img`,{...e.get(k_.key)(t),...t.attrs}],parseMarkdown:{match:({type:e})=>e===`image`,runner:(e,t,n)=>{let r=t.url,i=t.alt,a=t.title;e.addNode(n,{src:r,alt:i,title:a})}},toMarkdown:{match:e=>e.type.name===`image`,runner:(e,t)=>{e.addNode(`image`,void 0,void 0,{title:t.attrs.title,url:t.attrs.src,alt:t.attrs.alt})}}}));$(A_.node,{displayName:`NodeSchema<image>`,group:`Image`}),$(A_.ctx,{displayName:`NodeSchemaCtx<image>`,group:`Image`});var j_=Q(`InsertImage`,e=>(t={})=>(n,r)=>{if(!r)return!0;let{src:i=``,alt:a=``,title:o=``}=t,s=A_.type(e).create({src:i,alt:a,title:o});return s&&r(n.tr.replaceSelectionWith(s).scrollIntoView()),!0});$(j_,{displayName:`Command<insertImageCommand>`,group:`Image`});var M_=Q(`UpdateImage`,e=>(t={})=>(n,r)=>{let i=Ol(n.selection,A_.type(e));if(!i)return!1;let{node:a,pos:o}=i,s={...a.attrs},{src:c,alt:l,title:u}=t;return c!==void 0&&(s.src=c),l!==void 0&&(s.alt=l),u!==void 0&&(s.title=u),r?.(n.tr.setNodeMarkup(o,void 0,s).scrollIntoView()),!0});$(M_,{displayName:`Command<updateImageCommand>`,group:`Image`}),$(pg(e=>new cl(/!\[(?<alt>.*?)]\((?<filename>.*?)\s*(?="|\))"?(?<title>[^"]+)?"?\)/,(t,n,r,i)=>{let[a,o,s=``,c]=n;return a?t.tr.replaceWith(r,i,A_.type(e).create({src:s,alt:o,title:c})):null})),{displayName:`InputRule<insertImageInputRule>`,group:`Image`});var N_=Sg(`hardbreak`,e=>({"data-type":`hardbreak`,"data-is-inline":e.attrs.isInline}));$(N_,{displayName:`Attr<hardbreak>`,group:`Hardbreak`});var P_=yg(`hardbreak`,e=>({inline:!0,group:`inline`,attrs:{isInline:{default:!1,validate:`boolean`}},selectable:!1,parseDOM:[{tag:`br`},{tag:`span[data-type="hardbreak"]`,getAttrs:()=>({isInline:!0})}],toDOM:t=>t.attrs.isInline?[`span`,e.get(N_.key)(t),` `]:[`br`,e.get(N_.key)(t)],parseMarkdown:{match:({type:e})=>e===`break`,runner:(e,t,n)=>{e.addNode(n,{isInline:!!t.data?.isInline})}},leafText:()=>`
45
+ `,toMarkdown:{match:e=>e.type.name===`hardbreak`,runner:(e,t)=>{t.attrs.isInline?e.addNode(`text`,void 0,`
46
+ `):e.addNode(`break`)}}}));$(P_.node,{displayName:`NodeSchema<hardbreak>`,group:`Hardbreak`}),$(P_.ctx,{displayName:`NodeSchemaCtx<hardbreak>`,group:`Hardbreak`});var F_=Q(`InsertHardbreak`,e=>()=>(t,n)=>{let{selection:r,tr:i}=t;if(!(r instanceof V))return!1;if(r.empty){let e=r.$from.node();if(e.childCount>0&&e.lastChild?.type.name===`hardbreak`)return n?.(i.replaceRangeWith(r.to-1,r.to,t.schema.node(`paragraph`)).setSelection(B.near(i.doc.resolve(r.to))).scrollIntoView()),!0}return n?.(i.setMeta(`hardbreak`,!0).replaceSelectionWith(P_.type(e).create()).scrollIntoView()),!0});$(F_,{displayName:`Command<insertHardbreakCommand>`,group:`Hardbreak`});var I_=xg(`hardbreakKeymap`,{InsertHardbreak:{shortcuts:`Shift-Enter`,command:e=>{let t=e.get(Z);return()=>t.call(F_.key)}}});$(I_.ctx,{displayName:`KeymapCtx<hardbreak>`,group:`Hardbreak`}),$(I_.shortcuts,{displayName:`Keymap<hardbreak>`,group:`Hardbreak`});var L_=Sg(`hr`);$(L_,{displayName:`Attr<hr>`,group:`Hr`});var R_=yg(`hr`,e=>({group:`block`,parseDOM:[{tag:`hr`}],toDOM:t=>[`hr`,e.get(L_.key)(t)],parseMarkdown:{match:({type:e})=>e===`thematicBreak`,runner:(e,t,n)=>{e.addNode(n)}},toMarkdown:{match:e=>e.type.name===`hr`,runner:e=>{e.addNode(`thematicBreak`)}}}));$(R_.node,{displayName:`NodeSchema<hr>`,group:`Hr`}),$(R_.ctx,{displayName:`NodeSchemaCtx<hr>`,group:`Hr`});var z_=pg(e=>new cl(/^(?:---|___\s|\*\*\*\s)$/,(t,n,r,i)=>{let{tr:a}=t;return n[0]&&a.replaceWith(r-1,i,R_.type(e).create()),a}));$(z_,{displayName:`InputRule<insertHrInputRule>`,group:`Hr`});var B_=Q(`InsertHr`,e=>()=>(t,n)=>{if(!n)return!0;let r=o_.node.type(e).create(),{tr:i,selection:a}=t,{from:o}=a,s=R_.type(e).create();if(!s)return!0;let c=i.replaceSelectionWith(s).insert(o,r),l=B.findFrom(c.doc.resolve(o),1,!0);return l&&n(c.setSelection(l).scrollIntoView()),!0});$(B_,{displayName:`Command<insertHrCommand>`,group:`Hr`});var V_=Sg(`bulletList`);$(V_,{displayName:`Attr<bulletList>`,group:`BulletList`});var H_=yg(`bullet_list`,e=>({content:`listItem+`,group:`block`,attrs:{spread:{default:!1,validate:`boolean`}},parseDOM:[{tag:`ul`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw _(e);return{spread:e.dataset.spread===`true`}}}],toDOM:t=>[`ul`,{...e.get(V_.key)(t),"data-spread":t.attrs.spread},0],parseMarkdown:{match:({type:e,ordered:t})=>e===`list`&&!t,runner:(e,t,n)=>{let r=t.spread==null?`false`:`${t.spread}`;e.openNode(n,{spread:r}).next(t.children).closeNode()}},toMarkdown:{match:e=>e.type.name===`bullet_list`,runner:(e,t)=>{e.openNode(`list`,void 0,{ordered:!1,spread:t.attrs.spread}).next(t.content).closeNode()}}}));$(H_.node,{displayName:`NodeSchema<bulletList>`,group:`BulletList`}),$(H_.ctx,{displayName:`NodeSchemaCtx<bulletList>`,group:`BulletList`});var U_=pg(e=>dl(/^\s*([-+*])\s$/,H_.type(e)));$(U_,{displayName:`InputRule<wrapInBulletListInputRule>`,group:`BulletList`});var W_=Q(`WrapInBulletList`,e=>()=>Zc(H_.type(e)));$(W_,{displayName:`Command<wrapInBulletListCommand>`,group:`BulletList`});var G_=xg(`bulletListKeymap`,{WrapInBulletList:{shortcuts:`Mod-Alt-8`,command:e=>{let t=e.get(Z);return()=>t.call(W_.key)}}});$(G_.ctx,{displayName:`KeymapCtx<bulletListKeymap>`,group:`BulletList`}),$(G_.shortcuts,{displayName:`Keymap<bulletListKeymap>`,group:`BulletList`});var K_=Sg(`orderedList`);$(K_,{displayName:`Attr<orderedList>`,group:`OrderedList`});var q_=yg(`ordered_list`,e=>({content:`listItem+`,group:`block`,attrs:{order:{default:1,validate:`number`},spread:{default:!1,validate:`boolean`}},parseDOM:[{tag:`ol`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw _(e);return{spread:e.dataset.spread,order:e.hasAttribute(`start`)?Number(e.getAttribute(`start`)):1}}}],toDOM:t=>[`ol`,{...e.get(K_.key)(t),...t.attrs.order===1?{}:{start:t.attrs.order},"data-spread":t.attrs.spread},0],parseMarkdown:{match:({type:e,ordered:t})=>e===`list`&&!!t,runner:(e,t,n)=>{let r=t.spread==null?`true`:`${t.spread}`;e.openNode(n,{spread:r,order:t.start??1}).next(t.children).closeNode()}},toMarkdown:{match:e=>e.type.name===`ordered_list`,runner:(e,t)=>{e.openNode(`list`,void 0,{ordered:!0,start:t.attrs.order??1,spread:t.attrs.spread===`true`}),e.next(t.content),e.closeNode()}}}));$(q_.node,{displayName:`NodeSchema<orderedList>`,group:`OrderedList`}),$(q_.ctx,{displayName:`NodeSchemaCtx<orderedList>`,group:`OrderedList`});var J_=pg(e=>dl(/^\s*(\d+)\.\s$/,q_.type(e),e=>({order:Number(e[1])}),(e,t)=>t.childCount+t.attrs.order===Number(e[1])));$(J_,{displayName:`InputRule<wrapInOrderedListInputRule>`,group:`OrderedList`});var Y_=Q(`WrapInOrderedList`,e=>()=>Zc(q_.type(e)));$(Y_,{displayName:`Command<wrapInOrderedListCommand>`,group:`OrderedList`});var X_=xg(`orderedListKeymap`,{WrapInOrderedList:{shortcuts:`Mod-Alt-7`,command:e=>{let t=e.get(Z);return()=>t.call(Y_.key)}}});$(X_.ctx,{displayName:`KeymapCtx<orderedList>`,group:`OrderedList`}),$(X_.shortcuts,{displayName:`Keymap<orderedList>`,group:`OrderedList`});var Z_=Sg(`listItem`);$(Z_,{displayName:`Attr<listItem>`,group:`ListItem`});var Q_=yg(`list_item`,e=>({group:`listItem`,content:`paragraph block*`,attrs:{label:{default:`•`,validate:`string`},listType:{default:`bullet`,validate:`string`},spread:{default:!0,validate:`boolean`}},defining:!0,parseDOM:[{tag:`li`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw _(e);return{label:e.dataset.label,listType:e.dataset.listType,spread:e.dataset.spread===`true`}}}],toDOM:t=>[`li`,{...e.get(Z_.key)(t),"data-label":t.attrs.label,"data-list-type":t.attrs.listType,"data-spread":t.attrs.spread},0],parseMarkdown:{match:({type:e})=>e===`listItem`,runner:(e,t,n)=>{let r=t.label==null?`•`:`${t.label}.`,i=t.label==null?`bullet`:`ordered`,a=t.spread==null?`true`:`${t.spread}`;e.openNode(n,{label:r,listType:i,spread:a}),e.next(t.children),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`list_item`,runner:(e,t)=>{e.openNode(`listItem`,void 0,{spread:t.attrs.spread}),e.next(t.content),e.closeNode()}}}));$(Q_.node,{displayName:`NodeSchema<listItem>`,group:`ListItem`}),$(Q_.ctx,{displayName:`NodeSchemaCtx<listItem>`,group:`ListItem`});var $_=Q(`SinkListItem`,e=>()=>jg(Q_.type(e)));$($_,{displayName:`Command<sinkListItemCommand>`,group:`ListItem`});var ev=Q(`LiftListItem`,e=>()=>Og(Q_.type(e)));$(ev,{displayName:`Command<liftListItemCommand>`,group:`ListItem`});var tv=Q(`SplitListItem`,e=>()=>Dg(Q_.type(e)));$(tv,{displayName:`Command<splitListItemCommand>`,group:`ListItem`});function nv(e){return(t,n,r)=>{let{selection:i}=t;if(!(i instanceof V))return!1;let{empty:a,$from:o}=i;return!a||o.parentOffset!==0||o.node(-1).type!==Q_.type(e)?!1:Oc(t,n,r)}}var rv=Q(`LiftFirstListItem`,e=>()=>nv(e));$(rv,{displayName:`Command<liftFirstListItemCommand>`,group:`ListItem`});var iv=xg(`listItemKeymap`,{NextListItem:{shortcuts:`Enter`,command:e=>{let t=e.get(Z);return()=>t.call(tv.key)}},SinkListItem:{shortcuts:[`Tab`,`Mod-]`],command:e=>{let t=e.get(Z);return()=>t.call($_.key)}},LiftListItem:{shortcuts:[`Shift-Tab`,`Mod-[`],command:e=>{let t=e.get(Z);return()=>t.call(ev.key)}},LiftFirstListItem:{shortcuts:[`Backspace`,`Delete`],command:e=>{let t=e.get(Z);return()=>t.call(rv.key)}}});$(iv.ctx,{displayName:`KeymapCtx<listItem>`,group:`ListItem`}),$(iv.shortcuts,{displayName:`Keymap<listItem>`,group:`ListItem`});var av=hg(`text`,()=>({group:`inline`,parseMarkdown:{match:({type:e})=>e===`text`,runner:(e,t)=>{e.addText(t.value)}},toMarkdown:{match:e=>e.type.name===`text`,runner:(e,t)=>{e.addNode(`text`,void 0,t.text)}}}));$(av,{displayName:`NodeSchema<text>`,group:`Text`});var ov=Sg(`html`);$(ov,{displayName:`Attr<html>`,group:`Html`});var sv=yg(`html`,e=>({atom:!0,group:`inline`,inline:!0,attrs:{value:{default:``,validate:`string`}},toDOM:t=>{let n=document.createElement(`span`),r={...e.get(ov.key)(t),"data-value":t.attrs.value,"data-type":`html`};return n.textContent=t.attrs.value,[`span`,r,t.attrs.value]},parseDOM:[{tag:`span[data-type="html"]`,getAttrs:e=>({value:e.dataset.value??``})}],parseMarkdown:{match:({type:e})=>e===`html`,runner:(e,t,n)=>{e.addNode(n,{value:t.value})}},toMarkdown:{match:e=>e.type.name===`html`,runner:(e,t)=>{e.addNode(`html`,void 0,t.attrs.value)}}}));$(sv.node,{displayName:`NodeSchema<html>`,group:`Html`}),$(sv.ctx,{displayName:`NodeSchemaCtx<html>`,group:`Html`});var cv=[n_,a_,o_,f_,p_,m_,N_,P_,y_,b_,w_,T_,L_,R_,k_,A_,V_,H_,K_,q_,Z_,Q_,Ig,Lg,Hg,Ug,qg,Jg,Qg,$g,ov,sv,av].flat(),lv=[x_,U_,J_,E_,z_,h_].flat(),uv=[zg,Bg,Xg,Gg],dv=[c_,S_,g_,__,D_,F_,B_,j_,M_,Y_,W_,$_,tv,ev,rv,Rg,Yg,Wg,e_,t_,Q(`IsMarkSelected`,()=>e=>t=>{if(!e)return!1;let{doc:n,selection:r}=t;return n.rangeHasMark(r.from,r.to,e)}),Q(`IsNoteSelected`,()=>e=>t=>e?kl(t,e).hasNode:!1),Q(`ClearTextInCurrentBlock`,()=>()=>(e,t)=>{let n=e.tr,{$from:r,$to:i}=n.selection,{pos:a}=r,{pos:o}=i,s=a-r.node().content.size;return s<0?!1:(n=n.deleteRange(s,o),t?.(n),!0)}),Q(`SetBlockType`,()=>e=>(t,n)=>{let{nodeType:r,attrs:i=null}=e??{};if(!r)return!1;let a=t.tr,{from:o,to:s}=a.selection;try{a.setBlockType(o,s,r,i)}catch{return!1}return n?.(a),!0}),Q(`WrapInBlockType`,()=>e=>(t,n)=>{let{nodeType:r,attrs:i=null}=e??{};if(!r)return!1;let a=t.tr;try{let{$from:e,$to:t}=a.selection,n=e.blockRange(t),o=n&&ys(n,r,i);if(!o)return!1;a=a.wrap(n,o)}catch{return!1}return n?.(a),!0}),Q(`AddBlockType`,()=>e=>(t,n)=>{let{nodeType:r,attrs:i=null}=e??{};if(!r)return!1;let a=t.tr;try{let e=r instanceof Ja?r:r.createAndFill(i);if(!e)return!1;a.replaceSelectionWith(e)}catch{return!1}return n?.(a),!0}),Q(`SelectTextNearPos`,()=>e=>(t,n)=>{let{pos:r}=e??{};if(r==null)return!1;let i=(e,t,n)=>Math.min(Math.max(e,t),n),a=t.tr;try{let e=t.doc.resolve(i(r,0,t.doc.content.size));a.setSelection(V.near(e))}catch{return!1}return n?.(a.scrollIntoView()),!0})],fv=[C_,O_,I_,v_,iv,X_,G_,l_,Vg,Zg,Kg].flat(),pv=wg(`remarkAddOrderInList`,()=>()=>e=>{zr(e,`list`,e=>{if(e.ordered){let t=e.start??1;e.children.forEach((e,n)=>{e.label=n+t})}})});$(pv.plugin,{displayName:`Remark<remarkAddOrderInListPlugin>`,group:`Remark`}),$(pv.options,{displayName:`RemarkConfig<remarkAddOrderInListPlugin>`,group:`Remark`});var mv=wg(`remarkLineBreak`,()=>()=>e=>{let t=/[\t ]*(?:\r?\n|\r)/g;zr(e,`text`,(e,n,r)=>{if(!e.value||typeof e.value!=`string`)return;let i=[],a=0;t.lastIndex=0;let o=t.exec(e.value);for(;o;){let n=o.index;a!==n&&i.push({type:`text`,value:e.value.slice(a,n)}),i.push({type:`break`,data:{isInline:!0}}),a=n+o[0].length,o=t.exec(e.value)}if(i.length>0&&r&&typeof n==`number`)return a<e.value.length&&i.push({type:`text`,value:e.value.slice(a)}),r.children.splice(n,1,...i),n+i.length})});$(mv.plugin,{displayName:`Remark<remarkLineBreak>`,group:`Remark`}),$(mv.options,{displayName:`RemarkConfig<remarkLineBreak>`,group:`Remark`});var hv=wg(`remarkInlineLink`,()=>Pg);$(hv.plugin,{displayName:`Remark<remarkInlineLinkPlugin>`,group:`Remark`}),$(hv.options,{displayName:`RemarkConfig<remarkInlineLinkPlugin>`,group:`Remark`});var gv=e=>!!e.children,_v=e=>e.type===`html`;function vv(e,t){return n(e,0,null)[0];function n(e,r,i){if(gv(e)){let t=[];for(let r=0,i=e.children.length;r<i;r++){let i=e.children[r];if(i){let a=n(i,r,e);if(a)for(let e=0,n=a.length;e<n;e++){let n=a[e];n&&t.push(n)}}}e.children=t}return t(e,r,i)}}var yv=[`root`,`blockquote`,`listItem`],bv=wg(`remarkHTMLTransformer`,()=>()=>e=>{vv(e,(e,t,n)=>(_v(e)&&n&&yv.includes(n.type)&&(e.children=[{...e}],delete e.value,e.type=`paragraph`),[e]))});$(bv.plugin,{displayName:`Remark<remarkHtmlTransformer>`,group:`Remark`}),$(bv.options,{displayName:`RemarkConfig<remarkHtmlTransformer>`,group:`Remark`});var xv=wg(`remarkMarker`,()=>()=>(e,t)=>{let n=e=>t.value.charAt(e.position.start.offset);zr(e,e=>[`strong`,`emphasis`].includes(e.type),e=>{e.marker=n(e)})});$(xv.plugin,{displayName:`Remark<remarkMarker>`,group:`Remark`}),$(xv.options,{displayName:`RemarkConfig<remarkMarker>`,group:`Remark`});var Sv=gg(()=>{let e=!1,t=new Sc({key:new Tc(`MILKDOWN_INLINE_NODES_CURSOR`),state:{init(){return!1},apply(e){if(!e.selection.empty)return!1;let t=e.selection.$from,n=t.nodeBefore,r=t.nodeAfter;return!!(n&&r&&n.isInline&&!n.isText&&r.isInline&&!r.isText)}},props:{handleDOMEvents:{compositionend:(n,r)=>e?(e=!1,requestAnimationFrame(()=>{if(t.getState(n.state)){let e=n.state.selection.from;r.preventDefault(),n.dispatch(n.state.tr.insertText(r.data||``,e))}}),!0):!1,compositionstart:n=>(t.getState(n.state)&&(e=!0),!1),beforeinput:(n,r)=>{if(t.getState(n.state)&&r instanceof InputEvent&&r.data&&!e){let e=n.state.selection.from;return r.preventDefault(),n.dispatch(n.state.tr.insertText(r.data||``,e)),!0}return!1}},decorations(e){if(t.getState(e)){let t=e.selection.$from.pos,n=document.createElement(`span`),r=Cp.widget(t,n,{side:-1}),i=document.createElement(`span`),a=Cp.widget(t,i);return setTimeout(()=>{n.contentEditable=`true`,i.contentEditable=`true`}),Ep.create(e.doc,[r,a])}return Ep.empty}}});return t});$(Sv,{displayName:`Prose<inlineNodesCursorPlugin>`,group:`Prose`});var Cv=gg(e=>new Sc({key:new Tc(`MILKDOWN_HARDBREAK_MARKS`),appendTransaction:(t,n,r)=>{if(!t.length)return;let[i]=t;if(!i)return;let[a]=i.steps;if(i.getMeta(`hardbreak`)){if(!(a instanceof us))return;let{from:t}=a;return r.tr.setNodeMarkup(t,P_.type(e),void 0,[])}if(a instanceof as){let t=r.tr,{from:n,to:i}=a;return r.doc.nodesBetween(n,i,(n,r)=>{n.type===P_.type(e)&&(t=t.setNodeMarkup(r,P_.type(e),void 0,[]))}),t}}}));$(Cv,{displayName:`Prose<hardbreakClearMarkPlugin>`,group:`Prose`});var wv=vg([`table`,`code_block`],`hardbreakFilterNodes`);$(wv,{displayName:`Ctx<hardbreakFilterNodes>`,group:`Prose`});var Tv=gg(e=>{let t=e.get(wv.key);return new Sc({key:new Tc(`MILKDOWN_HARDBREAK_FILTER`),filterTransaction:(e,n)=>{let r=e.getMeta(`hardbreak`),[i]=e.steps;if(r&&i){let{from:e}=i,r=n.doc.resolve(e),a=r.depth,o=!0;for(;a>0;)t.includes(r.node(a).type.name)&&(o=!1),a--;return o}return!0}})});$(Tv,{displayName:`Prose<hardbreakFilterPlugin>`,group:`Prose`});var Ev=gg(e=>{let t=new Tc(`MILKDOWN_HEADING_ID`),n=n=>{if(n.composing)return;let r=e.get(f_.key),i=n.state.tr.setMeta(`addToHistory`,!1),a=!1,o={};n.state.doc.descendants((n,s)=>{if(n.type===m_.type(e)){if(n.textContent.trim().length===0)return;let e=n.attrs,c=r(n);o[c]?(o[c]+=1,c+=`-#${o[c]}`):o[c]=1,e.id!==c&&(a=!0,i.setMeta(t,!0).setNodeMarkup(s,void 0,{...e,id:c}))}}),a&&n.dispatch(i)};return new Sc({key:t,view:e=>(n(e),{update:(e,t)=>{e.state.doc.eq(t.doc)||n(e)}})})});$(Ev,{displayName:`Prose<syncHeadingIdPlugin>`,group:`Prose`});var Dv=gg(e=>new Sc({key:new Tc(`MILKDOWN_KEEP_LIST_ORDER`),appendTransaction:(t,n,r)=>{if(!r.selection||t.some(e=>e.getMeta(`addToHistory`)===!1||!e.isGeneric))return null;let i=q_.type(e),a=H_.type(e),o=Q_.type(e),s=(e,t,n=1)=>{let r=!1,i=`${t+n}.`;return e.label!==i&&(e.label=i,r=!0),r},c=r.tr,l=!1;return r.doc.descendants((e,t,n,r)=>{if(e.type===a){let n=e.maybeChild(0);n?.type===o&&n.attrs.listType===`ordered`&&(l=!0,c.setNodeMarkup(t,i,{spread:`true`}),e.descendants((e,t,n,r)=>{if(e.type===o){let n={...e.attrs};s(n,r)&&(c=c.setNodeMarkup(t,void 0,n))}return!1}))}else if(e.type===o&&n?.type===i){let i={...e.attrs},a=!1;i.listType!==`ordered`&&(i.listType=`ordered`,a=!0),n?.maybeChild(0)&&(a=s(i,r,n?.attrs.order??1)),a&&(c=c.setNodeMarkup(t,void 0,i),l=!0)}}),l?c.setMeta(`addToHistory`,!1):null}}));$(Dv,{displayName:`Prose<syncListOrderPlugin>`,group:`Prose`});var Ov=[cv,lv,uv,dv,fv,[Cv,wv,Tv,Sv,pv,hv,mv,bv,xv,i_,Ev,Dv].flat()].flat();function kv(e){e.update(_h,e=>{let t=e.attributes;return{...e,attributes:e=>{let n=typeof t==`function`?t(e):t;return{...n,class:i(`prose dark:prose-invert`,n?.class||``,`milkdown-theme-nord`)}}}})}export{Eh as _,Rg as a,vh as b,c_ as c,g_ as d,Y_ as f,cg as g,ug as h,j_ as i,S_ as l,Eg as m,Ov as n,e_ as o,Tg as p,B_ as r,Wg as s,kv as t,W_ as u,Z as v,ih as y};