snow-cms 1.3.3 → 1.4.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,44 @@
1
- var Ro=n=>{throw TypeError(n)};var Po=(n,e,t)=>e.has(n)||Ro("Cannot "+t);var b=(n,e,t)=>(Po(n,e,"read from private field"),t?t.call(n):e.get(n)),B=(n,e,t)=>e.has(n)?Ro("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),N=(n,e,t,r)=>(Po(n,e,"write to private field"),r?r.call(n,t):e.set(n,t),t);function fa(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=fa(n[e]))&&(r&&(r+=" "),r+=t)}else for(t in n)n[t]&&(r&&(r+=" "),r+=t);return r}function Dc(){for(var n,e,t=0,r="",i=arguments.length;t<i;t++)(n=arguments[t])&&(e=fa(n))&&(r&&(r+=" "),r+=e);return r}var nk=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function zc(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Ne=(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))(Ne||{});class Pe extends Error{constructor(e,t){super(t),this.name="MilkdownError",this.code=e}}const Rc=(n,e)=>typeof e=="function"?"[Function]":e,hi=n=>JSON.stringify(n,Rc);function Pc(n){return new Pe(Ne.docTypeError,`Doc type error, unsupported type: ${hi(n)}`)}function Fc(n){return new Pe(Ne.contextNotFound,`Context "${n}" not found, do you forget to inject it?`)}function Bc(n){return new Pe(Ne.timerNotFound,`Timer "${n}" not found, do you forget to record it?`)}function fi(){return new Pe(Ne.ctxCallOutOfScope,"Should not call a context out of the plugin.")}function vc(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 Pe(Ne.createNodeInParserFail,u.join(`
2
- `))}function da(){return new Pe(Ne.stackOverFlow,"Stack over flow, cannot pop on an empty stack.")}function Lc(n){return new Pe(Ne.parserMatchError,`Cannot match target parser for node: ${hi(n)}.`)}function Vc(n){return new Pe(Ne.serializerMatchError,`Cannot match target serializer for node: ${hi(n)}.`)}function rk(n){return new Pe(Ne.expectDomTypeError,`Expect to be a dom, but get: ${hi(n)}.`)}function wi(){return new Pe(Ne.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 ik(n){return new Pe(Ne.missingNodeInSchema,`Missing node in schema, milkdown cannot find "${n}" in schema.`)}function sk(n){return new Pe(Ne.missingMarkInSchema,`Missing mark in schema, milkdown cannot find "${n}" in schema.`)}class pa{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 Fc(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)}}var Ve,st,bn,ha;let _c=(ha=class{constructor(e,t,r){B(this,Ve);B(this,st);B(this,bn);N(this,Ve,[]),N(this,bn,()=>{b(this,Ve).forEach(i=>i(b(this,st)))}),this.set=i=>{N(this,st,i),b(this,bn).call(this)},this.get=()=>b(this,st),this.update=i=>{N(this,st,i(b(this,st))),b(this,bn).call(this)},this.type=r,N(this,st,t),e.set(r.id,this)}on(e){return b(this,Ve).push(e),()=>{N(this,Ve,b(this,Ve).filter(t=>t!==e))}}once(e){const t=this.on(r=>{e(r),t()});return t}off(e){N(this,Ve,b(this,Ve).filter(t=>t!==e))}offAll(){N(this,Ve,[])}},Ve=new WeakMap,st=new WeakMap,bn=new WeakMap,ha);class $c{constructor(e,t){this.id=Symbol(`Context-${t}`),this.name=t,this._defaultValue=e,this._typeInfo=()=>{throw fi()}}create(e,t=this._defaultValue){return new _c(e,t,this)}}const J=(n,e)=>new $c(n,e);var dr,pr,mr,Wt,Sn,St,wn,Cn,Tn;class qc{constructor(e,t,r){B(this,dr);B(this,pr);B(this,mr);B(this,Wt);B(this,Sn);B(this,St);B(this,wn);B(this,Cn);B(this,Tn);N(this,Wt,new Set),N(this,Sn,new Set),N(this,St,new Map),N(this,wn,new Map),this.read=()=>({metadata:b(this,dr),injectedSlices:[...b(this,Wt)].map(i=>({name:typeof i=="string"?i:i.name,value:b(this,Cn).call(this,i)})),consumedSlices:[...b(this,Sn)].map(i=>({name:typeof i=="string"?i:i.name,value:b(this,Cn).call(this,i)})),recordedTimers:[...b(this,St)].map(([i,{duration:s}])=>({name:i.name,duration:s,status:b(this,Tn).call(this,i)})),waitTimers:[...b(this,wn)].map(([i,{duration:s}])=>({name:i.name,duration:s,status:b(this,Tn).call(this,i)}))}),this.onRecord=i=>{b(this,St).set(i,{start:Date.now(),duration:0})},this.onClear=i=>{b(this,St).delete(i)},this.onDone=i=>{const s=b(this,St).get(i);s&&(s.duration=Date.now()-s.start)},this.onWait=(i,s)=>{const o=Date.now();s.finally(()=>{b(this,wn).set(i,{duration:Date.now()-o})}).catch(console.error)},this.onInject=i=>{b(this,Wt).add(i)},this.onRemove=i=>{b(this,Wt).delete(i)},this.onUse=i=>{b(this,Sn).add(i)},N(this,Cn,i=>b(this,pr).get(i).get()),N(this,Tn,i=>b(this,mr).get(i).status),N(this,pr,e),N(this,mr,t),N(this,dr,r)}}dr=new WeakMap,pr=new WeakMap,mr=new WeakMap,Wt=new WeakMap,Sn=new WeakMap,St=new WeakMap,wn=new WeakMap,Cn=new WeakMap,Tn=new WeakMap;var ot,lt,gr,Ee;const Oo=class Oo{constructor(e,t,r){B(this,ot);B(this,lt);B(this,gr);B(this,Ee);this.produce=i=>i&&Object.keys(i).length?new Oo(b(this,ot),b(this,lt),{...i}):this,this.inject=(i,s)=>{var l;const o=i.create(b(this,ot).sliceMap);return s!=null&&o.set(s),(l=b(this,Ee))==null||l.onInject(i),this},this.remove=i=>{var s;return b(this,ot).remove(i),(s=b(this,Ee))==null||s.onRemove(i),this},this.record=i=>{var s;return i.create(b(this,lt).store),(s=b(this,Ee))==null||s.onRecord(i),this},this.clearTimer=i=>{var s;return b(this,lt).remove(i),(s=b(this,Ee))==null||s.onClear(i),this},this.isInjected=i=>b(this,ot).has(i),this.isRecorded=i=>b(this,lt).has(i),this.use=i=>{var s;return(s=b(this,Ee))==null||s.onUse(i),b(this,ot).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=>b(this,lt).get(i),this.done=i=>{var s;this.timer(i).done(),(s=b(this,Ee))==null||s.onDone(i)},this.wait=i=>{var o;const s=this.timer(i).start();return(o=b(this,Ee))==null||o.onWait(i,s),s},this.waitTimers=async i=>{await Promise.all(this.get(i).map(s=>this.wait(s)))},N(this,ot,e),N(this,lt,t),N(this,gr,r),r&&N(this,Ee,new qc(e,t,r))}get meta(){return b(this,gr)}get inspector(){return b(this,Ee)}};ot=new WeakMap,lt=new WeakMap,gr=new WeakMap,Ee=new WeakMap;let ds=Oo;class Wc{constructor(){this.store=new Map,this.get=e=>{const t=this.store.get(e.id);if(!t)throw Bc(e.name);return t},this.remove=e=>{this.store.delete(e.id)},this.has=e=>this.store.has(e.id)}}var Mn,wt,On,at,Nn,yr;class jc{constructor(e,t){B(this,Mn);B(this,wt);B(this,On);B(this,at);B(this,Nn);B(this,yr);N(this,Mn,null),N(this,wt,null),N(this,at,"pending"),this.start=()=>(b(this,Mn)??N(this,Mn,new Promise((r,i)=>{N(this,wt,s=>{s instanceof CustomEvent&&s.detail.id===b(this,On)&&(N(this,at,"resolved"),b(this,Nn).call(this),s.stopImmediatePropagation(),r())}),b(this,yr).call(this,()=>{b(this,at)==="pending"&&N(this,at,"rejected"),b(this,Nn).call(this),i(new Error(`Timing ${this.type.name} timeout.`))}),N(this,at,"pending"),addEventListener(this.type.name,b(this,wt))})),b(this,Mn)),this.done=()=>{const r=new CustomEvent(this.type.name,{detail:{id:b(this,On)}});dispatchEvent(r)},N(this,Nn,()=>{b(this,wt)&&removeEventListener(this.type.name,b(this,wt))}),N(this,yr,r=>{setTimeout(()=>{r()},this.type.timeout)}),N(this,On,Symbol(t.name)),this.type=t,e.set(t.id,this)}get status(){return b(this,at)}}Mn=new WeakMap,wt=new WeakMap,On=new WeakMap,at=new WeakMap,Nn=new WeakMap,yr=new WeakMap;class Jc{constructor(e,t=3e3){this.create=r=>new jc(r,this),this.id=Symbol(`Timer-${e}`),this.name=e,this.timeout=t}}const pt=(n,e=3e3)=>new Jc(n,e);function se(n){this.content=n}se.prototype={constructor:se,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 se(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 se(t)},addToStart:function(n,e){return new se([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new se(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 se(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=se.from(n),n.size?new se(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=se.from(n),n.size?new se(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=se.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}};se.from=function(n){if(n instanceof se)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new se(e)};function ma(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=ma(i.content,s.content,t+1);if(o!=null)return o}t+=i.nodeSize}}function ga(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=ga(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 ma(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return ga(this,e,t,r)}findIndex(e){if(e==0)return Nr(0,e);if(e==this.size)return Nr(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?Nr(t+1,s):Nr(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 Ci={index:0,offset:0};function Nr(n,e){return Ci.index=n,Ci.offset=e,Ci}function Xr(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(!Xr(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!Xr(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}class q{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&&Xr(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 q.none;if(e instanceof q)return[e];let t=e.slice();return t.sort((r,i)=>r.type.rank-i.type.rank),t}}q.none=[];class Zr extends Error{}class O{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=ka(this.content,e+this.openStart,t);return r&&new O(r,this.openStart,this.openEnd)}removeBetween(e,t){return new O(ya(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 O.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 O(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 O(e,r,i)}}O.empty=new O(T.empty,0,0);function ya(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(ya(s.content,e-i-1,t-i-1)))}function ka(n,e,t,r){let{index:i,offset:s}=n.findIndex(e),o=n.maybeChild(i);if(s==e||o.isText)return n.cut(0,e).append(t).append(n.cut(e));let l=ka(o.content,e-s-1,t);return l&&n.replaceChild(i,o.copy(l))}function Hc(n,e,t){if(t.openStart>n.depth)throw new Zr("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Zr("Inconsistent open depths");return xa(n,e,t,0)}function xa(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=xa(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 Qt(o,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=Kc(t,n);return Qt(s,Sa(n,o,l,e,r))}else return Qt(s,ei(n,e,r))}function ba(n,e){if(!e.type.compatibleContent(n.type))throw new Zr("Cannot join "+e.type.name+" onto "+n.type.name)}function ps(n,e,t){let r=n.node(t);return ba(r,e.node(t)),r}function Yt(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 er(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&&(Yt(n.nodeAfter,r),s++));for(let l=s;l<o;l++)Yt(i.child(l),r);e&&e.depth==t&&e.textOffset&&Yt(e.nodeBefore,r)}function Qt(n,e){return n.type.checkContent(e),n.copy(e)}function Sa(n,e,t,r,i){let s=n.depth>i&&ps(n,e,i+1),o=r.depth>i&&ps(t,r,i+1),l=[];return er(null,n,i,l),s&&o&&e.index(i)==t.index(i)?(ba(s,o),Yt(Qt(s,Sa(n,e,t,r,i+1)),l)):(s&&Yt(Qt(s,ei(n,e,i+1)),l),er(e,t,i,l),o&&Yt(Qt(o,ei(t,r,i+1)),l)),er(r,null,i,l),new T(l)}function ei(n,e,t){let r=[];if(er(null,n,t,r),n.depth>t){let i=ps(n,e,t+1);Yt(Qt(i,ei(n,e,t+1)),r)}return er(e,null,t,r),new T(r)}function Kc(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 or{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 q.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 Qc(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 or(t,r,s)}static resolveCached(e,t){let r=Fo.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 Fo.set(e,r=new Uc);let i=r.elts[r.i]=or.resolve(e,t);return r.i=(r.i+1)%Yc,i}}class Uc{constructor(){this.elts=[],this.i=0}}const Yc=12,Fo=new WeakMap;class Qc{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 Gc=Object.create(null);class qe{constructor(e,t,r,i=q.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&&Xr(this.attrs,t||e.defaultAttrs||Gc)&&q.sameSet(this.marks,r||q.none)}copy(e=null){return e==this.content?this:new qe(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new qe(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 O.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 O(u,i.depth-o,s.depth-o)}replace(e,t,r){return Hc(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 or.resolveCached(this,e)}resolveNoCache(e){return or.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()+")"),wa(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=q.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(!q.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}}qe.prototype.text=void 0;class ti extends qe{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):wa(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 ti(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new ti(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 wa(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class en{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new Xc(e,t);if(r.next==null)return en.empty;let i=Ca(r);r.next&&r.err("Unexpected trailing text");let s=sh(ih(i));return oh(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
- `)}}en.empty=new en(!0);class Xc{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 Ca(n){let e=[];do e.push(Zc(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Zc(n){let e=[];do e.push(eh(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function eh(n){let e=rh(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=th(n,e);else break;return e}function Bo(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function th(n,e){let t=Bo(n),r=t;return n.eat(",")&&(n.next!="}"?r=Bo(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function nh(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 rh(n){if(n.eat("(")){let e=Ca(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=nh(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 ih(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 Ta(n,e){return e-n}function vo(n,e){let t=[];return r(e),t.sort(Ta);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 sh(n){let e=Object.create(null);return t(vo(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]);vo(n,a).forEach(c=>{u||i.push([l,u=[]]),u.indexOf(c)==-1&&u.push(c)})})});let s=e[r.join(",")]=new en(r.indexOf(n.length-1)>-1);for(let o=0;o<i.length;o++){let l=i[o][1].sort(Ta);s.next.push({type:i[o][0],next:e[l.join(",")]||t(l)})}return s}}function oh(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 Ma(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 Oa(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 Na(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 Ea(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new ah(n,r,e[r]);return t}let Lo=class Ia{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=Ea(e,r.attrs),this.defaultAttrs=Ma(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==en.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:Oa(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new qe(this,this.computeAttrs(e),T.from(t),q.setFrom(r))}createChecked(e=null,t,r){return t=T.from(t),this.checkContent(t),new qe(this,this.computeAttrs(e),t,q.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 qe(this,e,t.append(s),q.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){Na(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:q.none:e}static compile(e,t){let r=Object.create(null);e.forEach((s,o)=>r[s]=new Ia(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 lh(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 ah{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?lh(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class di{constructor(e,t,r,i){this.name=e,this.rank=t,this.schema=r,this.spec=i,this.attrs=Ea(e,i.attrs),this.excluded=null;let s=Ma(this.attrs);this.instance=s?new q(this,s):null}create(e=null){return!e&&this.instance?this.instance:new q(this,Oa(this.attrs,e))}static compile(e,t){let r=Object.create(null),i=0;return e.forEach((s,o)=>r[s]=new di(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){Na(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class uh{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=se.from(e.nodes),t.marks=se.from(e.marks||{}),this.nodes=Lo.compile(this.spec.nodes,this),this.marks=di.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]=en.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?Vo(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==""?[]:Vo(this,o.split(" "))}this.nodeFromJSON=i=>qe.fromJSON(this,i),this.markFromJSON=i=>q.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 Lo){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 ti(r,r.defaultAttrs,e,q.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 Vo(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 ch(n){return n.tag!=null}function hh(n){return n.style!=null}class Dn{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(i=>{if(ch(i))this.tags.push(i);else if(hh(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 $o(this,t,!1);return r.addAll(e,q.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new $o(this,t,!0);return r.addAll(e,q.none,t.from,t.to),O.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(ph(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=qo(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=qo(o)),o.node||o.ignore||o.mark||(o.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Dn(e,Dn.schemaRules(e)))}}const Aa={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},fh={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Da={ol:!0,ul:!0},lr=1,ms=2,Ar=4;function _o(n,e,t){return e!=null?(e?lr:0)|(e==="full"?ms:0):n&&n.whitespace=="pre"?lr|ms:t&-5}class Er{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=q.none,this.match=s||(o&Ar?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&lr)){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&&!Aa.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class $o{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=_o(null,t.preserveWhitespace,0)|(r?Ar:0);i?s=new Er(i.type,i.attrs,q.none,!0,t.topMatch||i.type.contentMatch,o):r?s=new Er(null,null,q.none,!0,null,o):s=new Er(e.schema.topNodeType,null,q.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&ms?"full":this.localPreserveWS||(i.options&lr)>0;if(s==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(s)s!=="full"?r=r.replace(/\r?\n|\r/g," "):r=r.replace(/\r\n?/g,`
4
- `);else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let o=i.content[i.content.length-1],l=e.previousSibling;(!o||l&&l.nodeName=="BR"||o.isText&&/[ \t\r\n\u000c]$/.test(o.text))&&(r=r.slice(1))}r&&this.insertNode(this.parser.schema.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;Da.hasOwnProperty(o)&&this.parser.normalizeLists&&dh(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:fh.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(Aa.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=q.none;for(let l of i.concat(e.marks))(s.type?s.type.allowsMarkType(l.type):Wo(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=_o(e,s,o.options);o.options&Ar&&o.content.length==0&&(l|=Ar);let a=q.none;return r=r.filter(u=>(o.type?o.type.allowsMarkType(u.type):Wo(u.type,e))?(a=u.addToSet(a),!1):!0),this.nodes.push(new Er(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|=lr)}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 dh(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Da.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function ph(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function qo(n){let e={};for(let t in n)e[t]=n[t];return e}function Wo(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 Bn{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=Ti(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}=Dr(Ti(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&&Dr(Ti(r),i(e,t),null,e.attrs)}static renderSpec(e,t,r=null,i){return Dr(e,t,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Bn(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=jo(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return jo(e.marks)}}function jo(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function Ti(n){return n.document||window.document}const Jo=new WeakMap;function mh(n){let e=Jo.get(n);return e===void 0&&Jo.set(n,e=gh(n)),e}function gh(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 Dr(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=mh(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}=Dr(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 yh={};function Gs(n,e){const t=yh,r=typeof t.includeImageAlt=="boolean"?t.includeImageAlt:!0,i=typeof t.includeHtml=="boolean"?t.includeHtml:!0;return za(n,r,i)}function za(n,e,t){if(kh(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 Ho(n.children,e,t)}return Array.isArray(n)?Ho(n,e,t):""}function Ho(n,e,t){const r=[];let i=-1;for(;++i<n.length;)r[i]=za(n[i],e,t);return r.join("")}function kh(n){return!!(n&&typeof n=="object")}const Ko=document.createElement("i");function Xs(n){const e="&"+n+";";Ko.innerHTML=e;const t=Ko.textContent;return t.charCodeAt(t.length-1)===59&&n!=="semi"||t===e?!1:t}function Ue(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 De(n,e){return n.length>0?(Ue(n,n.length,0,e),n):e}const Uo={}.hasOwnProperty;function xh(n){const e={};let t=-1;for(;++t<n.length;)bh(e,n[t]);return e}function bh(n,e){let t;for(t in e){const i=(Uo.call(n,t)?n[t]:void 0)||(n[t]={}),s=e[t];let o;if(s)for(o in s){Uo.call(i,o)||(i[o]=[]);const l=s[o];Sh(i[o],Array.isArray(l)?l:l?[l]:[])}}}function Sh(n,e){let t=-1;const r=[];for(;++t<e.length;)(e[t].add==="after"?n:r).push(e[t]);Ue(n,0,0,r)}function Ra(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 mn(n){return n.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const He=Rt(/[A-Za-z]/),_e=Rt(/[\dA-Za-z]/),wh=Rt(/[#-'*+\--9=?A-Z^-~]/);function gs(n){return n!==null&&(n<32||n===127)}const ys=Rt(/\d/),Ch=Rt(/[\dA-Fa-f]/),Th=Rt(/[!-/:-@[-`{-~]/);function z(n){return n!==null&&n<-2}function xe(n){return n!==null&&(n<0||n===32)}function H(n){return n===-2||n===-1||n===32}const Mh=Rt(new RegExp("\\p{P}|\\p{S}","u")),Oh=Rt(/\s/);function Rt(n){return e;function e(t){return t!==null&&t>-1&&n.test(String.fromCharCode(t))}}function Q(n,e,t,r){const i=r?r-1:Number.POSITIVE_INFINITY;let s=0;return o;function o(a){return H(a)?(n.enter(t),l(a)):e(a)}function l(a){return H(a)&&s++<i?(n.consume(a),l):(n.exit(t),e(a))}}const Nh={tokenize:Eh};function Eh(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"),Q(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 z(l)?(n.consume(l),n.exit("chunkText"),s):(n.consume(l),o)}}const Ih={tokenize:Ah},Yo={tokenize:Dh};function Ah(n){const e=this,t=[];let r=0,i,s,o;return l;function l(M){if(r<t.length){const V=t[r];return e.containerState=V[1],n.attempt(V[0].continuation,a,u)(M)}return u(M)}function a(M){if(r++,e.containerState._closeFlow){e.containerState._closeFlow=void 0,i&&D();const V=e.events.length;let $=V,w;for(;$--;)if(e.events[$][0]==="exit"&&e.events[$][1].type==="chunkFlow"){w=e.events[$][1].end;break}k(r);let W=V;for(;W<e.events.length;)e.events[W][1].end={...w},W++;return Ue(e.events,$+1,0,e.events.slice(V)),e.events.length=W,u(M)}return l(M)}function u(M){if(r===t.length){if(!i)return d(M);if(i.currentConstruct&&i.currentConstruct.concrete)return p(M);e.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return e.containerState={},n.check(Yo,c,h)(M)}function c(M){return i&&D(),k(r),d(M)}function h(M){return e.parser.lazy[e.now().line]=r!==t.length,o=e.now().offset,p(M)}function d(M){return e.containerState={},n.attempt(Yo,f,p)(M)}function f(M){return r++,t.push([e.currentConstruct,e.containerState]),d(M)}function p(M){if(M===null){i&&D(),k(0),n.consume(M);return}return i=i||e.parser.flow(e.now()),n.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:s}),y(M)}function y(M){if(M===null){x(n.exit("chunkFlow"),!0),k(0),n.consume(M);return}return z(M)?(n.consume(M),x(n.exit("chunkFlow")),r=0,e.interrupt=void 0,l):(n.consume(M),y)}function x(M,V){const $=e.sliceStream(M);if(V&&$.push(null),M.previous=s,s&&(s.next=M),s=M,i.defineSkip(M.start),i.write($),e.parser.lazy[M.start.line]){let w=i.events.length;for(;w--;)if(i.events[w][1].start.offset<o&&(!i.events[w][1].end||i.events[w][1].end.offset>o))return;const W=e.events.length;let E=W,R,v;for(;E--;)if(e.events[E][0]==="exit"&&e.events[E][1].type==="chunkFlow"){if(R){v=e.events[E][1].end;break}R=!0}for(k(r),w=W;w<e.events.length;)e.events[w][1].end={...v},w++;Ue(e.events,E+1,0,e.events.slice(W)),e.events.length=w}}function k(M){let V=t.length;for(;V-- >M;){const $=t[V];e.containerState=$[1],$[0].exit.call(e,n)}t.length=M}function D(){i.write([null]),s=void 0,i=void 0,e.containerState._closeFlow=void 0}}function Dh(n,e,t){return Q(n,n.attempt(this.parser.constructs.document,e,t),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function ni(n){if(n===null||xe(n)||Oh(n))return 1;if(Mh(n))return 2}function Zs(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 ks={name:"attention",resolveAll:zh,tokenize:Rh};function zh(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};Qo(h,-a),Qo(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=De(u,[["enter",n[r][1],e],["exit",n[r][1],e]])),u=De(u,[["enter",i,e],["enter",o,e],["exit",o,e],["enter",s,e]]),u=De(u,Zs(e.parser.constructs.insideSpan.null,n.slice(r+1,t),e)),u=De(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=De(u,[["enter",n[t][1],e],["exit",n[t][1],e]])):c=0,Ue(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 Rh(n,e){const t=this.parser.constructs.attentionMarkers.null,r=this.previous,i=ni(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=ni(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 Qo(n,e){n.column+=e,n.offset+=e,n._bufferIndex+=e}const Ph={name:"autolink",tokenize:Fh};function Fh(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 He(f)?(n.consume(f),o):f===64?t(f):u(f)}function o(f){return f===43||f===45||f===46||_e(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||_e(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||gs(f)?t(f):(n.consume(f),a)}function u(f){return f===64?(n.consume(f),c):wh(f)?(n.consume(f),u):t(f)}function c(f){return _e(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||_e(f))&&r++<63){const p=f===45?d:h;return n.consume(f),p}return t(f)}}const pi={partial:!0,tokenize:Bh};function Bh(n,e,t){return r;function r(s){return H(s)?Q(n,i,"linePrefix")(s):i(s)}function i(s){return s===null||z(s)?e(s):t(s)}}const Pa={continuation:{tokenize:Lh},exit:Vh,name:"blockQuote",tokenize:vh};function vh(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 H(o)?(n.enter("blockQuotePrefixWhitespace"),n.consume(o),n.exit("blockQuotePrefixWhitespace"),n.exit("blockQuotePrefix"),e):(n.exit("blockQuotePrefix"),e(o))}}function Lh(n,e,t){const r=this;return i;function i(o){return H(o)?Q(n,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):s(o)}function s(o){return n.attempt(Pa,e,t)(o)}}function Vh(n){n.exit("blockQuote")}const Fa={name:"characterEscape",tokenize:_h};function _h(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 Th(s)?(n.enter("characterEscapeValue"),n.consume(s),n.exit("characterEscapeValue"),n.exit("characterEscape"),e):t(s)}}const Ba={name:"characterReference",tokenize:$h};function $h(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=_e,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=Ch,c):(n.enter("characterReferenceValue"),s=7,o=ys,c(h))}function c(h){if(h===59&&i){const d=n.exit("characterReferenceValue");return o===_e&&!Xs(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 Go={partial:!0,tokenize:Wh},Xo={concrete:!0,name:"codeFenced",tokenize:qh};function qh(n,e,t){const r=this,i={partial:!0,tokenize:$};let s=0,o=0,l;return a;function a(w){return u(w)}function u(w){const W=r.events[r.events.length-1];return s=W&&W[1].type==="linePrefix"?W[2].sliceSerialize(W[1],!0).length:0,l=w,n.enter("codeFenced"),n.enter("codeFencedFence"),n.enter("codeFencedFenceSequence"),c(w)}function c(w){return w===l?(o++,n.consume(w),c):o<3?t(w):(n.exit("codeFencedFenceSequence"),H(w)?Q(n,h,"whitespace")(w):h(w))}function h(w){return w===null||z(w)?(n.exit("codeFencedFence"),r.interrupt?e(w):n.check(Go,y,V)(w)):(n.enter("codeFencedFenceInfo"),n.enter("chunkString",{contentType:"string"}),d(w))}function d(w){return w===null||z(w)?(n.exit("chunkString"),n.exit("codeFencedFenceInfo"),h(w)):H(w)?(n.exit("chunkString"),n.exit("codeFencedFenceInfo"),Q(n,f,"whitespace")(w)):w===96&&w===l?t(w):(n.consume(w),d)}function f(w){return w===null||z(w)?h(w):(n.enter("codeFencedFenceMeta"),n.enter("chunkString",{contentType:"string"}),p(w))}function p(w){return w===null||z(w)?(n.exit("chunkString"),n.exit("codeFencedFenceMeta"),h(w)):w===96&&w===l?t(w):(n.consume(w),p)}function y(w){return n.attempt(i,V,x)(w)}function x(w){return n.enter("lineEnding"),n.consume(w),n.exit("lineEnding"),k}function k(w){return s>0&&H(w)?Q(n,D,"linePrefix",s+1)(w):D(w)}function D(w){return w===null||z(w)?n.check(Go,y,V)(w):(n.enter("codeFlowValue"),M(w))}function M(w){return w===null||z(w)?(n.exit("codeFlowValue"),D(w)):(n.consume(w),M)}function V(w){return n.exit("codeFenced"),e(w)}function $(w,W,E){let R=0;return v;function v(j){return w.enter("lineEnding"),w.consume(j),w.exit("lineEnding"),I}function I(j){return w.enter("codeFencedFence"),H(j)?Q(w,A,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(j):A(j)}function A(j){return j===l?(w.enter("codeFencedFenceSequence"),X(j)):E(j)}function X(j){return j===l?(R++,w.consume(j),X):R>=o?(w.exit("codeFencedFenceSequence"),H(j)?Q(w,Z,"whitespace")(j):Z(j)):E(j)}function Z(j){return j===null||z(j)?(w.exit("codeFencedFence"),W(j)):E(j)}}}function Wh(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 Mi={name:"codeIndented",tokenize:Jh},jh={partial:!0,tokenize:Hh};function Jh(n,e,t){const r=this;return i;function i(u){return n.enter("codeIndented"),Q(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):z(u)?n.attempt(jh,o,a)(u):(n.enter("codeFlowValue"),l(u))}function l(u){return u===null||z(u)?(n.exit("codeFlowValue"),o(u)):(n.consume(u),l)}function a(u){return n.exit("codeIndented"),e(u)}}function Hh(n,e,t){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?t(o):z(o)?(n.enter("lineEnding"),n.consume(o),n.exit("lineEnding"),i):Q(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):z(o)?i(o):t(o)}}const Kh={name:"codeText",previous:Yh,resolve:Uh,tokenize:Qh};function Uh(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 Yh(n){return n!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Qh(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)):z(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||z(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 Gh{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&&$n(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),$n(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),$n(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);$n(this.right,t.reverse())}else{const t=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);$n(this.left,t.reverse())}}}function $n(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 va(n){const e={};let t=-1,r,i,s,o,l,a,u;const c=new Gh(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,Xh(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 Ue(n,0,Number.POSITIVE_INFINITY,c.slice(0)),!u}function Xh(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]),D=s.pop();a.push([D,D+k.length-1]),n.splice(D,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 Zh={resolve:tf,tokenize:nf},ef={partial:!0,tokenize:rf};function tf(n){return va(n),n}function nf(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):z(l)?n.check(ef,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 rf(n,e,t){const r=this;return i;function i(o){return n.exit("chunkContent"),n.enter("lineEnding"),n.consume(o),n.exit("lineEnding"),Q(n,s,"linePrefix")}function s(o){if(o===null||z(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 La(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||gs(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||z(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||xe(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||gs(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 Va(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):z(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||z(f)||l++>999?(n.exit("chunkString"),c(f)):(n.consume(f),a||(a=!H(f)),f===92?d:h)}function d(f){return f===91||f===92||f===93?(n.consume(f),l++,h):h(f)}}function _a(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):z(d)?(n.enter("lineEnding"),n.consume(d),n.exit("lineEnding"),Q(n,u,"linePrefix")):(n.enter("chunkString",{contentType:"string"}),c(d))}function c(d){return d===o||d===null||z(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 tr(n,e){let t;return r;function r(i){return z(i)?(n.enter("lineEnding"),n.consume(i),n.exit("lineEnding"),t=!0,r):H(i)?Q(n,r,t?"linePrefix":"lineSuffix")(i):e(i)}}const sf={name:"definition",tokenize:lf},of={partial:!0,tokenize:af};function lf(n,e,t){const r=this;let i;return s;function s(f){return n.enter("definition"),o(f)}function o(f){return Va.call(r,n,l,t,"definitionLabel","definitionLabelMarker","definitionLabelString")(f)}function l(f){return i=mn(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 xe(f)?tr(n,u)(f):u(f)}function u(f){return La(n,c,t,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(f)}function c(f){return n.attempt(of,h,h)(f)}function h(f){return H(f)?Q(n,d,"whitespace")(f):d(f)}function d(f){return f===null||z(f)?(n.exit("definition"),r.parser.defined.push(i),e(f)):t(f)}}function af(n,e,t){return r;function r(l){return xe(l)?tr(n,i)(l):t(l)}function i(l){return _a(n,s,t,"definitionTitle","definitionTitleMarker","definitionTitleString")(l)}function s(l){return H(l)?Q(n,o,"whitespace")(l):o(l)}function o(l){return l===null||z(l)?e(l):t(l)}}const uf={name:"hardBreakEscape",tokenize:cf};function cf(n,e,t){return r;function r(s){return n.enter("hardBreakEscape"),n.consume(s),i}function i(s){return z(s)?(n.exit("hardBreakEscape"),e(s)):t(s)}}const hf={name:"headingAtx",resolve:ff,tokenize:df};function ff(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"},Ue(n,r,t-r+1,[["enter",i,e],["enter",s,e],["exit",s,e],["exit",i,e]])),n}function df(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||xe(c)?(n.exit("atxHeadingSequence"),l(c)):t(c)}function l(c){return c===35?(n.enter("atxHeadingSequence"),a(c)):c===null||z(c)?(n.exit("atxHeading"),e(c)):H(c)?Q(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||xe(c)?(n.exit("atxHeadingText"),l(c)):(n.consume(c),u)}}const pf=["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"],Zo=["pre","script","style","textarea"],mf={concrete:!0,name:"htmlFlow",resolveTo:kf,tokenize:xf},gf={partial:!0,tokenize:Sf},yf={partial:!0,tokenize:bf};function kf(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 xf(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):He(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):He(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 ve="CDATA[";return g===ve.charCodeAt(l++)?(n.consume(g),l===ve.length?r.interrupt?e:A:p):t(g)}function y(g){return He(g)?(n.consume(g),o=String.fromCharCode(g),x):t(g)}function x(g){if(g===null||g===47||g===62||xe(g)){const ve=g===47,Bt=o.toLowerCase();return!ve&&!s&&Zo.includes(Bt)?(i=1,r.interrupt?e(g):A(g)):pf.includes(o.toLowerCase())?(i=6,ve?(n.consume(g),k):r.interrupt?e(g):A(g)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?t(g):s?D(g):M(g))}return g===45||_e(g)?(n.consume(g),o+=String.fromCharCode(g),x):t(g)}function k(g){return g===62?(n.consume(g),r.interrupt?e:A):t(g)}function D(g){return H(g)?(n.consume(g),D):v(g)}function M(g){return g===47?(n.consume(g),v):g===58||g===95||He(g)?(n.consume(g),V):H(g)?(n.consume(g),M):v(g)}function V(g){return g===45||g===46||g===58||g===95||_e(g)?(n.consume(g),V):$(g)}function $(g){return g===61?(n.consume(g),w):H(g)?(n.consume(g),$):M(g)}function w(g){return g===null||g===60||g===61||g===62||g===96?t(g):g===34||g===39?(n.consume(g),a=g,W):H(g)?(n.consume(g),w):E(g)}function W(g){return g===a?(n.consume(g),a=null,R):g===null||z(g)?t(g):(n.consume(g),W)}function E(g){return g===null||g===34||g===39||g===47||g===60||g===61||g===62||g===96||xe(g)?$(g):(n.consume(g),E)}function R(g){return g===47||g===62||H(g)?M(g):t(g)}function v(g){return g===62?(n.consume(g),I):t(g)}function I(g){return g===null||z(g)?A(g):H(g)?(n.consume(g),I):t(g)}function A(g){return g===45&&i===2?(n.consume(g),ue):g===60&&i===1?(n.consume(g),re):g===62&&i===4?(n.consume(g),Be):g===63&&i===3?(n.consume(g),m):g===93&&i===5?(n.consume(g),Ge):z(g)&&(i===6||i===7)?(n.exit("htmlFlowData"),n.check(gf,Xe,X)(g)):g===null||z(g)?(n.exit("htmlFlowData"),X(g)):(n.consume(g),A)}function X(g){return n.check(yf,Z,Xe)(g)}function Z(g){return n.enter("lineEnding"),n.consume(g),n.exit("lineEnding"),j}function j(g){return g===null||z(g)?X(g):(n.enter("htmlFlowData"),A(g))}function ue(g){return g===45?(n.consume(g),m):A(g)}function re(g){return g===47?(n.consume(g),o="",Fe):A(g)}function Fe(g){if(g===62){const ve=o.toLowerCase();return Zo.includes(ve)?(n.consume(g),Be):A(g)}return He(g)&&o.length<8?(n.consume(g),o+=String.fromCharCode(g),Fe):A(g)}function Ge(g){return g===93?(n.consume(g),m):A(g)}function m(g){return g===62?(n.consume(g),Be):g===45&&i===2?(n.consume(g),m):A(g)}function Be(g){return g===null||z(g)?(n.exit("htmlFlowData"),Xe(g)):(n.consume(g),Be)}function Xe(g){return n.exit("htmlFlow"),e(g)}}function bf(n,e,t){const r=this;return i;function i(o){return z(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 Sf(n,e,t){return r;function r(i){return n.enter("lineEnding"),n.consume(i),n.exit("lineEnding"),n.attempt(pi,e,t)}}const wf={name:"htmlText",tokenize:Cf};function Cf(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),M):He(m)?(n.consume(m),E):t(m)}function u(m){return m===45?(n.consume(m),c):m===91?(n.consume(m),s=0,p):He(m)?(n.consume(m),D):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):z(m)?(o=h,re(m)):(n.consume(m),h)}function d(m){return m===45?(n.consume(m),f):h(m)}function f(m){return m===62?ue(m):m===45?d(m):h(m)}function p(m){const Be="CDATA[";return m===Be.charCodeAt(s++)?(n.consume(m),s===Be.length?y:p):t(m)}function y(m){return m===null?t(m):m===93?(n.consume(m),x):z(m)?(o=y,re(m)):(n.consume(m),y)}function x(m){return m===93?(n.consume(m),k):y(m)}function k(m){return m===62?ue(m):m===93?(n.consume(m),k):y(m)}function D(m){return m===null||m===62?ue(m):z(m)?(o=D,re(m)):(n.consume(m),D)}function M(m){return m===null?t(m):m===63?(n.consume(m),V):z(m)?(o=M,re(m)):(n.consume(m),M)}function V(m){return m===62?ue(m):M(m)}function $(m){return He(m)?(n.consume(m),w):t(m)}function w(m){return m===45||_e(m)?(n.consume(m),w):W(m)}function W(m){return z(m)?(o=W,re(m)):H(m)?(n.consume(m),W):ue(m)}function E(m){return m===45||_e(m)?(n.consume(m),E):m===47||m===62||xe(m)?R(m):t(m)}function R(m){return m===47?(n.consume(m),ue):m===58||m===95||He(m)?(n.consume(m),v):z(m)?(o=R,re(m)):H(m)?(n.consume(m),R):ue(m)}function v(m){return m===45||m===46||m===58||m===95||_e(m)?(n.consume(m),v):I(m)}function I(m){return m===61?(n.consume(m),A):z(m)?(o=I,re(m)):H(m)?(n.consume(m),I):R(m)}function A(m){return m===null||m===60||m===61||m===62||m===96?t(m):m===34||m===39?(n.consume(m),i=m,X):z(m)?(o=A,re(m)):H(m)?(n.consume(m),A):(n.consume(m),Z)}function X(m){return m===i?(n.consume(m),i=void 0,j):m===null?t(m):z(m)?(o=X,re(m)):(n.consume(m),X)}function Z(m){return m===null||m===34||m===39||m===60||m===61||m===96?t(m):m===47||m===62||xe(m)?R(m):(n.consume(m),Z)}function j(m){return m===47||m===62||xe(m)?R(m):t(m)}function ue(m){return m===62?(n.consume(m),n.exit("htmlTextData"),n.exit("htmlText"),e):t(m)}function re(m){return n.exit("htmlTextData"),n.enter("lineEnding"),n.consume(m),n.exit("lineEnding"),Fe}function Fe(m){return H(m)?Q(n,Ge,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(m):Ge(m)}function Ge(m){return n.enter("htmlTextData"),o(m)}}const eo={name:"labelEnd",resolveAll:Nf,resolveTo:Ef,tokenize:If},Tf={tokenize:Af},Mf={tokenize:Df},Of={tokenize:zf};function Nf(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&&Ue(n,0,n.length,t),n}function Ef(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=De(l,n.slice(s+1,s+r+3)),l=De(l,[["enter",c,e]]),l=De(l,Zs(e.parser.constructs.insideSpan.null,n.slice(s+r+4,o-3),e)),l=De(l,[["exit",c,e],n[o-2],n[o-1],["exit",u,e]]),l=De(l,n.slice(o+1)),l=De(l,[["exit",a,e]]),Ue(n,s,n.length,l),n}function If(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(mn(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(Tf,c,o?c:h)(d):d===91?n.attempt(Mf,c,o?u:h)(d):o?c(d):h(d)}function u(d){return n.attempt(Of,c,h)(d)}function c(d){return e(d)}function h(d){return s._balanced=!0,t(d)}}function Af(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 xe(h)?tr(n,s)(h):s(h)}function s(h){return h===41?c(h):La(n,o,l,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(h)}function o(h){return xe(h)?tr(n,a)(h):c(h)}function l(h){return t(h)}function a(h){return h===34||h===39||h===40?_a(n,u,t,"resourceTitle","resourceTitleMarker","resourceTitleString")(h):c(h)}function u(h){return xe(h)?tr(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 Df(n,e,t){const r=this;return i;function i(l){return Va.call(r,n,s,o,"reference","referenceMarker","referenceString")(l)}function s(l){return r.parser.defined.includes(mn(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?e(l):t(l)}function o(l){return t(l)}}function zf(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 Rf={name:"labelStartImage",resolveAll:eo.resolveAll,tokenize:Pf};function Pf(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 Ff={name:"labelStartLink",resolveAll:eo.resolveAll,tokenize:Bf};function Bf(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 Oi={name:"lineEnding",tokenize:vf};function vf(n,e){return t;function t(r){return n.enter("lineEnding"),n.consume(r),n.exit("lineEnding"),Q(n,e,"linePrefix")}}const zr={name:"thematicBreak",tokenize:Lf};function Lf(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||z(u))?(n.exit("thematicBreak"),e(u)):t(u)}function a(u){return u===i?(n.consume(u),r++,a):(n.exit("thematicBreakSequence"),H(u)?Q(n,l,"whitespace")(u):l(u))}}const ge={continuation:{tokenize:qf},exit:jf,name:"list",tokenize:$f},Vf={partial:!0,tokenize:Jf},_f={partial:!0,tokenize:Wf};function $f(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:ys(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(zr,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 ys(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(pi,r.interrupt?t:c,n.attempt(Vf,d,h))}function c(f){return r.containerState.initialBlankLine=!0,s++,d(f)}function h(f){return H(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 qf(n,e,t){const r=this;return r.containerState._closeFlow=void 0,n.check(pi,i,s);function i(l){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Q(n,e,"listItemIndent",r.containerState.size+1)(l)}function s(l){return r.containerState.furtherBlankLines||!H(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(_f,e,o)(l))}function o(l){return r.containerState._closeFlow=!0,r.interrupt=void 0,Q(n,n.attempt(ge,e,t),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l)}}function Wf(n,e,t){const r=this;return Q(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 jf(n){n.exit(this.containerState.type)}function Jf(n,e,t){const r=this;return Q(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!H(s)&&o&&o[1].type==="listItemPrefixWhitespace"?e(s):t(s)}}const el={name:"setextUnderline",resolveTo:Hf,tokenize:Kf};function Hf(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 Kf(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"),H(u)?Q(n,a,"lineSuffix")(u):a(u))}function a(u){return u===null||z(u)?(n.exit("setextHeadingLine"),e(u)):t(u)}}const Uf={tokenize:Yf};function Yf(n){const e=this,t=n.attempt(pi,r,n.attempt(this.parser.constructs.flowInitial,i,Q(n,n.attempt(this.parser.constructs.flow,i,n.attempt(Zh,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 Qf={resolveAll:qa()},Gf=$a("string"),Xf=$a("text");function $a(n){return{resolveAll:qa(n==="text"?Zf: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 qa(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 Zf(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 ed={42:ge,43:ge,45:ge,48:ge,49:ge,50:ge,51:ge,52:ge,53:ge,54:ge,55:ge,56:ge,57:ge,62:Pa},td={91:sf},nd={[-2]:Mi,[-1]:Mi,32:Mi},rd={35:hf,42:zr,45:[el,zr],60:mf,61:el,95:zr,96:Xo,126:Xo},id={38:Ba,92:Fa},sd={[-5]:Oi,[-4]:Oi,[-3]:Oi,33:Rf,38:Ba,42:ks,60:[Ph,wf],91:Ff,92:[uf,Fa],93:eo,95:ks,96:Kh},od={null:[ks,Qf]},ld={null:[42,95]},ad={null:[]},ud=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:ld,contentInitial:td,disable:ad,document:ed,flow:rd,flowInitial:nd,insideSpan:od,string:id,text:sd},Symbol.toStringTag,{value:"Module"}));function cd(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:W($),check:W(w),consume:D,enter:M,exit:V,interrupt:W(w,{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(I){return o=De(o,I),x(),o[o.length-1]!==null?[]:(E(e,0),u.events=Zs(s,u.events,u),u.events)}function d(I,A){return fd(f(I),A)}function f(I){return hd(o,I)}function p(){const{_bufferIndex:I,_index:A,line:X,column:Z,offset:j}=r;return{_bufferIndex:I,_index:A,line:X,column:Z,offset:j}}function y(I){i[I.line]=I.column,v()}function x(){let I;for(;r._index<o.length;){const A=o[r._index];if(typeof A=="string")for(I=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===I&&r._bufferIndex<A.length;)k(A.charCodeAt(r._bufferIndex));else k(A)}}function k(I){c=c(I)}function D(I){z(I)?(r.line++,r.column=1,r.offset+=I===-3?2:1,v()):I!==-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=I}function M(I,A){const X=A||{};return X.type=I,X.start=p(),u.events.push(["enter",X,u]),l.push(X),X}function V(I){const A=l.pop();return A.end=p(),u.events.push(["exit",A,u]),A}function $(I,A){E(I,A.from)}function w(I,A){A.restore()}function W(I,A){return X;function X(Z,j,ue){let re,Fe,Ge,m;return Array.isArray(Z)?Xe(Z):"tokenize"in Z?Xe([Z]):Be(Z);function Be(ie){return Ln;function Ln(gt){const on=gt!==null&&ie[gt],ln=gt!==null&&ie.null,Or=[...Array.isArray(on)?on:on?[on]:[],...Array.isArray(ln)?ln:ln?[ln]:[]];return Xe(Or)(gt)}}function Xe(ie){return re=ie,Fe=0,ie.length===0?ue:g(ie[Fe])}function g(ie){return Ln;function Ln(gt){return m=R(),Ge=ie,ie.partial||(u.currentConstruct=ie),ie.name&&u.parser.constructs.disable.null.includes(ie.name)?Bt():ie.tokenize.call(A?Object.assign(Object.create(u),A):u,a,ve,Bt)(gt)}}function ve(ie){return I(Ge,m),j}function Bt(ie){return m.restore(),++Fe<re.length?g(re[Fe]):ue}}}function E(I,A){I.resolveAll&&!s.includes(I)&&s.push(I),I.resolve&&Ue(u.events,A,u.events.length-A,I.resolve(u.events.slice(A),u)),I.resolveTo&&(u.events=I.resolveTo(u.events,u))}function R(){const I=p(),A=u.previous,X=u.currentConstruct,Z=u.events.length,j=Array.from(l);return{from:Z,restore:ue};function ue(){r=I,u.previous=A,u.currentConstruct=X,u.events.length=Z,l=j,v()}}function v(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function hd(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 fd(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=`
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 $u(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 Ne extends Error{constructor(e,t){super(t),this.name="MilkdownError",this.code=e}}const qu=(n,e)=>typeof e=="function"?"[Function]":e,Cr=n=>JSON.stringify(n,qu);function Wu(n){return new Ne(Se.docTypeError,`Doc type error, unsupported type: ${Cr(n)}`)}function ju(n){return new Ne(Se.contextNotFound,`Context "${n}" not found, do you forget to inject it?`)}function Ju(n){return new Ne(Se.timerNotFound,`Timer "${n}" not found, do you forget to record it?`)}function Tr(){return new Ne(Se.ctxCallOutOfScope,"Should not call a context out of the plugin.")}function Hu(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 Ne(Se.createNodeInParserFail,u.join(`
2
+ `))}function bl(){return new Ne(Se.stackOverFlow,"Stack over flow, cannot pop on an empty stack.")}function Ku(n){return new Ne(Se.parserMatchError,`Cannot match target parser for node: ${Cr(n)}.`)}function Uu(n){return new Ne(Se.serializerMatchError,`Cannot match target serializer for node: ${Cr(n)}.`)}function cy(n){return new Ne(Se.expectDomTypeError,`Expect to be a dom, but get: ${Cr(n)}.`)}function Pr(){return new Ne(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 hy(n){return new Ne(Se.missingNodeInSchema,`Missing node in schema, milkdown cannot find "${n}" in schema.`)}function fy(n){return new Ne(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 Yu=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 Qu{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 Yu(e,t,this)}}const V=(n,e)=>new Qu(n,e);class Gu{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 Gu(e,t,r))}#t;#e;#r;#n;get meta(){return this.#r}get inspector(){return this.#n}}class Xu{constructor(){this.store=new Map,this.get=e=>{const t=this.store.get(e.id);if(!t)throw Ju(e.name);return t},this.remove=e=>{this.store.delete(e.id)},this.has=e=>this.store.has(e.id)}}class Zu{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 ec{constructor(e,t=3e3){this.create=r=>new Zu(r,this),this.id=Symbol(`Timer-${e}`),this.name=e,this.timeout=t}}const We=(n,e=3e3)=>new ec(n,e);function ne(n){this.content=n}ne.prototype={constructor:ne,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 ne(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 ne(t)},addToStart:function(n,e){return new ne([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new ne(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 ne(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=ne.from(n),n.size?new ne(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=ne.from(n),n.size?new ne(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=ne.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}};ne.from=function(n){if(n instanceof ne)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new ne(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 tc(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 Ol(n,e,t,0)}function Ol(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=Ol(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 Ot(o,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=nc(t,n);return Ot(s,El(n,o,l,e,r))}else return Ot(s,fr(n,e,r))}function Nl(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 Nl(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 Ot(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)?(Nl(s,o),Mt(Ot(s,El(n,e,t,r,i+1)),l)):(s&&Mt(Ot(s,fr(n,e,i+1)),l),xn(e,t,i,l),o&&Mt(Ot(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(Ot(i,fr(n,e,t+1)),r)}return xn(e,null,t,r),new T(r)}function nc(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 On{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 sc(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 On(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 rc);let i=r.elts[r.i]=On.resolve(e,t);return r.i=(r.i+1)%ic,i}}class rc{constructor(){this.elts=[],this.i=0}}const ic=12,js=new WeakMap;class sc{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 oc=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||oc)&&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 tc(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 On.resolveCached(this,e)}resolveNoCache(e){return On.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 lc(e,t);if(r.next==null)return At.empty;let i=Al(r);r.next&&r.err("Unexpected trailing text");let s=pc(dc(i));return mc(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 lc{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(ac(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function ac(n){let e=[];do e.push(uc(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function uc(n){let e=fc(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=cc(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 cc(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 hc(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 fc(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=hc(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 dc(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 pc(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 mc(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 yc(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 gc(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 yc{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?gc(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 kc{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=ne.from(e.nodes),t.marks=ne.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 xc(n){return n.tag!=null}function bc(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(xc(i))this.tags.push(i);else if(bc(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(Cc(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},Sc={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Ll={ol:!0,ul:!0},Nn=1,Oi=2,bn=4;function Ys(n,e,t){return e!=null?(e?Nn:0)|(e==="full"?Oi:0):n&&n.whitespace=="pre"?Nn|Oi: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&Nn)){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&Oi?"full":this.localPreserveWS||(i.options&Nn)>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&&wc(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:Sc.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|=Nn)}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 wc(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 Cc(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 Tc(n){let e=eo.get(n);return e===void 0&&eo.set(n,e=Mc(n)),e}function Mc(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=Tc(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(Nc(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 Nc(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 Ec(n){const e={};let t=-1;for(;++t<n.length;)Ic(e,n[t]);return e}function Ic(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];Ac(i[o],Array.isArray(l)?l:l?[l]:[])}}}function Ac(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]/),Dc=gt(/[#-'*+\--9=?A-Z^-~]/);function Ni(n){return n!==null&&(n<32||n===127)}const Ei=gt(/\d/),Rc=gt(/[\dA-Fa-f]/),zc=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 Pc=gt(new RegExp("\\p{P}|\\p{S}","u")),Fc=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 Bc={tokenize:vc};function vc(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 Lc={tokenize:Vc},io={tokenize:_c};function Vc(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&&E();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 O=B;for(;O<e.events.length;)e.events[O][1].end={...S},O++;return _e(e.events,$+1,0,e.events.slice(B)),e.events.length=O,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&&E(),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&&E(),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 O=e.events.length;let P=O,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=O;S<e.events.length;)e.events[S][1].end={...J},S++;_e(e.events,P+1,0,e.events.slice(O)),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 E(){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)||Fc(n))return 1;if(Pc(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:$c,tokenize:qc};function $c(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 qc(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 Wc={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||Ni(f)?t(f):(n.consume(f),a)}function u(f){return f===64?(n.consume(f),c):Dc(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 Or={partial:!0,tokenize:Jc};function Jc(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:Kc},exit:Uc,name:"blockQuote",tokenize:Hc};function Hc(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 Kc(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 Uc(n){n.exit("blockQuote")}const ql={name:"characterEscape",tokenize:Yc};function Yc(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 zc(s)?(n.enter("characterEscapeValue"),n.consume(s),n.exit("characterEscapeValue"),n.exit("characterEscape"),e):t(s)}}const Wl={name:"characterReference",tokenize:Qc};function Qc(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=Rc,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:Xc},lo={concrete:!0,name:"codeFenced",tokenize:Gc};function Gc(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 O=r.events[r.events.length-1];return s=O&&O[1].type==="linePrefix"?O[2].sliceSerialize(O[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,E,"linePrefix",s+1)(S):E(S)}function E(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"),E(S)):(n.consume(S),C)}function B(S){return n.exit("codeFenced"),e(S)}function $(S,O,P){let z=0;return J;function J(_){return S.enter("lineEnding"),S.consume(_),S.exit("lineEnding"),I}function I(_){return S.enter("codeFencedFence"),q(_)?K(S,N,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(_):N(_)}function N(_){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"),O(_)):P(_)}}}function Xc(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:eh},Zc={partial:!0,tokenize:th};function eh(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(Zc,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 th(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 nh={name:"codeText",previous:ih,resolve:rh,tokenize:sh};function rh(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 ih(n){return n!==96||this.events[this.events.length-1][1].type==="characterEscape"}function sh(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 oh{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 oh(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,lh(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 lh(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]),E=s.pop();a.push([E,E+k.length-1]),n.splice(E,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 ah={resolve:ch,tokenize:hh},uh={partial:!0,tokenize:fh};function ch(n){return jl(n),n}function hh(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(uh,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 fh(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||Ni(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||Ni(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 dh={name:"definition",tokenize:mh},ph={partial:!0,tokenize:gh};function mh(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(ph,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 gh(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 yh={name:"hardBreakEscape",tokenize:kh};function kh(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 xh={name:"headingAtx",resolve:bh,tokenize:Sh};function bh(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 Sh(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 wh=["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"],Ch={concrete:!0,name:"htmlFlow",resolveTo:Oh,tokenize:Nh},Th={partial:!0,tokenize:Ih},Mh={partial:!0,tokenize:Eh};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 Nh(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:N: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):N(g)):wh.includes(o.toLowerCase())?(i=6,Ae?(n.consume(g),k):r.interrupt?e(g):N(g)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?t(g):s?E(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:N):t(g)}function E(g){return q(g)?(n.consume(g),E):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,O):q(g)?(n.consume(g),S):P(g)}function O(g){return g===a?(n.consume(g),a=null,z):g===null||A(g)?t(g):(n.consume(g),O)}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),I):t(g)}function I(g){return g===null||A(g)?N(g):q(g)?(n.consume(g),I):t(g)}function N(g){return g===45&&i===2?(n.consume(g),oe):g===60&&i===1?(n.consume(g),ee):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(Th,Je,Y)(g)):g===null||A(g)?(n.exit("htmlFlowData"),Y(g)):(n.consume(g),N)}function Y(g){return n.check(Mh,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"),N(g))}function oe(g){return g===45?(n.consume(g),m):N(g)}function ee(g){return g===47?(n.consume(g),o="",Ee):N(g)}function Ee(g){if(g===62){const Ae=o.toLowerCase();return ao.includes(Ae)?(n.consume(g),Ie):N(g)}return Le(g)&&o.length<8?(n.consume(g),o+=String.fromCharCode(g),Ee):N(g)}function je(g){return g===93?(n.consume(g),m):N(g)}function m(g){return g===62?(n.consume(g),Ie):g===45&&i===2?(n.consume(g),m):N(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 Eh(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 Ih(n,e,t){return r;function r(i){return n.enter("lineEnding"),n.consume(i),n.exit("lineEnding"),n.attempt(Or,e,t)}}const Ah={name:"htmlText",tokenize:Dh};function Dh(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),E):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,ee(m)):(n.consume(m),h)}function d(m){return m===45?(n.consume(m),f):h(m)}function f(m){return m===62?oe(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,ee(m)):(n.consume(m),y)}function x(m){return m===93?(n.consume(m),k):y(m)}function k(m){return m===62?oe(m):m===93?(n.consume(m),k):y(m)}function E(m){return m===null||m===62?oe(m):A(m)?(o=E,ee(m)):(n.consume(m),E)}function C(m){return m===null?t(m):m===63?(n.consume(m),B):A(m)?(o=C,ee(m)):(n.consume(m),C)}function B(m){return m===62?oe(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):O(m)}function O(m){return A(m)?(o=O,ee(m)):q(m)?(n.consume(m),O):oe(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),oe):m===58||m===95||Le(m)?(n.consume(m),J):A(m)?(o=z,ee(m)):q(m)?(n.consume(m),z):oe(m)}function J(m){return m===45||m===46||m===58||m===95||Re(m)?(n.consume(m),J):I(m)}function I(m){return m===61?(n.consume(m),N):A(m)?(o=I,ee(m)):q(m)?(n.consume(m),I):z(m)}function N(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=N,ee(m)):q(m)?(n.consume(m),N):(n.consume(m),Q)}function Y(m){return m===i?(n.consume(m),i=void 0,_):m===null?t(m):A(m)?(o=Y,ee(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 oe(m){return m===62?(n.consume(m),n.exit("htmlTextData"),n.exit("htmlText"),e):t(m)}function ee(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:Fh,resolveTo:Bh,tokenize:vh},Rh={tokenize:Lh},zh={tokenize:Vh},Ph={tokenize:_h};function Fh(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 Bh(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 vh(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(Rh,c,o?c:h)(d):d===91?n.attempt(zh,c,o?u:h)(d):o?c(d):h(d)}function u(d){return n.attempt(Ph,c,h)(d)}function c(d){return e(d)}function h(d){return s._balanced=!0,t(d)}}function Lh(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 Vh(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 $h={name:"labelStartImage",resolveAll:ps.resolveAll,tokenize:qh};function qh(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 Wh={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:Jh};function Jh(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:Hh};function Hh(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:Qh},exit:Xh,name:"list",tokenize:Yh},Kh={partial:!0,tokenize:Zh},Uh={partial:!0,tokenize:Gh};function Yh(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(Or,r.interrupt?t:c,n.attempt(Kh,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 Qh(n,e,t){const r=this;return r.containerState._closeFlow=void 0,n.check(Or,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(Uh,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 Gh(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 Xh(n){n.exit(this.containerState.type)}function Zh(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:ef,tokenize:tf};function ef(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 tf(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 nf={tokenize:rf};function rf(n){const e=this,t=n.attempt(Or,r,n.attempt(this.parser.constructs.flowInitial,i,K(n,n.attempt(this.parser.constructs.flow,i,n.attempt(ah,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 sf={resolveAll:Yl()},of=Ul("string"),lf=Ul("text");function Ul(n){return{resolveAll:Yl(n==="text"?af: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 af(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 uf={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},cf={91:dh},hf={[-2]:vr,[-1]:vr,32:vr},ff={35:xh,42:Wn,45:[uo,Wn],60:Ch,61:uo,95:Wn,96:lo,126:lo},df={38:Wl,92:ql},pf={[-5]:Lr,[-4]:Lr,[-3]:Lr,33:$h,38:Wl,42:Ii,60:[Wc,Ah],91:Wh,92:[yh,ql],93:ps,95:Ii,96:nh},mf={null:[Ii,sf]},gf={null:[42,95]},yf={null:[]},kf=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:gf,contentInitial:cf,disable:yf,document:uf,flow:ff,flowInitial:hf,insideSpan:mf,string:df,text:pf},Symbol.toStringTag,{value:"Module"}));function xf(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:O($),check:O(S),consume:E,enter:C,exit:B,interrupt:O(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(I){return o=Ce(o,I),x(),o[o.length-1]!==null?[]:(P(e,0),u.events=ds(s,u.events,u),u.events)}function d(I,N){return Sf(f(I),N)}function f(I){return bf(o,I)}function p(){const{_bufferIndex:I,_index:N,line:Y,column:Q,offset:_}=r;return{_bufferIndex:I,_index:N,line:Y,column:Q,offset:_}}function y(I){i[I.line]=I.column,J()}function x(){let I;for(;r._index<o.length;){const N=o[r._index];if(typeof N=="string")for(I=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===I&&r._bufferIndex<N.length;)k(N.charCodeAt(r._bufferIndex));else k(N)}}function k(I){c=c(I)}function E(I){A(I)?(r.line++,r.column=1,r.offset+=I===-3?2:1,J()):I!==-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=I}function C(I,N){const Y=N||{};return Y.type=I,Y.start=p(),u.events.push(["enter",Y,u]),l.push(Y),Y}function B(I){const N=l.pop();return N.end=p(),u.events.push(["exit",N,u]),N}function $(I,N){P(I,N.from)}function S(I,N){N.restore()}function O(I,N){return Y;function Y(Q,_,oe){let ee,Ee,je,m;return Array.isArray(Q)?Je(Q):"tokenize"in Q?Je([Q]):Ie(Q);function Ie(te){return nn;function nn(nt){const Ft=nt!==null&&te[nt],Bt=nt!==null&&te.null,vn=[...Array.isArray(Ft)?Ft:Ft?[Ft]:[],...Array.isArray(Bt)?Bt:Bt?[Bt]:[]];return Je(vn)(nt)}}function Je(te){return ee=te,Ee=0,te.length===0?oe:g(te[Ee])}function g(te){return nn;function nn(nt){return m=z(),je=te,te.partial||(u.currentConstruct=te),te.name&&u.parser.constructs.disable.null.includes(te.name)?kt():te.tokenize.call(N?Object.assign(Object.create(u),N):u,a,Ae,kt)(nt)}}function Ae(te){return I(je,m),_}function kt(te){return m.restore(),++Ee<ee.length?g(ee[Ee]):oe}}}function P(I,N){I.resolveAll&&!s.includes(I)&&s.push(I),I.resolve&&_e(u.events,N,u.events.length-N,I.resolve(u.events.slice(N),u)),I.resolveTo&&(u.events=I.resolveTo(u.events,u))}function z(){const I=p(),N=u.previous,Y=u.currentConstruct,Q=u.events.length,_=Array.from(l);return{from:Q,restore:oe};function oe(){r=I,u.previous=N,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 bf(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 Sf(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
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 dd(n){const r={constructs:xh([ud,...(n||{}).extensions||[]]),content:i(Nh),defined:[],document:i(Ih),flow:i(Uf),lazy:{},string:i(Gf),text:i(Xf)};return r;function i(s){return o;function o(l){return cd(r,s,l)}}}function pd(n){for(;!va(n););return n}const tl=/[\0\t\n\r]/g;function md(){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(tl.lastIndex=h,u=tl.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 gd=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Wa(n){return n.replace(gd,yd)}function yd(n,e,t){if(e)return e;if(t.charCodeAt(0)===35){const i=t.charCodeAt(1),s=i===120||i===88;return Ra(t.slice(s?2:1),s?16:10)}return Xs(t)||n}function nr(n){return!n||typeof n!="object"?"":"position"in n||"type"in n?nl(n.position):"start"in n||"end"in n?nl(n):"line"in n||"column"in n?xs(n):""}function xs(n){return rl(n&&n.line)+":"+rl(n&&n.column)}function nl(n){return xs(n&&n.start)+"-"+xs(n&&n.end)}function rl(n){return n&&typeof n=="number"?n:1}const ja={}.hasOwnProperty;function kd(n,e,t){return typeof e!="string"&&(t=e,e=void 0),xd(t)(pd(dd(t).document().write(md()(n,e,!0))))}function xd(n){const e={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(Do),autolinkProtocol:R,autolinkEmail:R,atxHeading:s(Eo),blockQuote:s(ln),characterEscape:R,characterReference:R,codeFenced:s(Or),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:s(Or,o),codeText:s(wc,o),codeTextData:R,data:R,codeFlowValue:R,definition:s(Cc),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:s(Tc),hardBreakEscape:s(Io),hardBreakTrailing:s(Io),htmlFlow:s(Ao,o),htmlFlowData:R,htmlText:s(Ao,o),htmlTextData:R,image:s(Mc),label:o,link:s(Do),listItem:s(Oc),listItemValue:d,listOrdered:s(zo,h),listUnordered:s(zo),paragraph:s(Nc),reference:g,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:s(Eo),strong:s(Ec),thematicBreak:s(Ac)},exit:{atxHeading:a(),atxHeadingSequence:$,autolink:a(),autolinkEmail:on,autolinkProtocol:gt,blockQuote:a(),characterEscapeValue:v,characterReferenceMarkerHexadecimal:Bt,characterReferenceMarkerNumeric:Bt,characterReferenceValue:ie,characterReference:Ln,codeFenced:a(x),codeFencedFence:y,codeFencedFenceInfo:f,codeFencedFenceMeta:p,codeFlowValue:v,codeIndented:a(k),codeText:a(j),codeTextData:v,data:v,definition:a(),definitionDestinationString:V,definitionLabelString:D,definitionTitleString:M,emphasis:a(),hardBreakEscape:a(A),hardBreakTrailing:a(A),htmlFlow:a(X),htmlFlowData:v,htmlText:a(Z),htmlTextData:v,image:a(re),label:Ge,labelText:Fe,lineEnding:I,link:a(ue),listItem:a(),listOrdered:a(),listUnordered:a(),paragraph:a(),referenceString:ve,resourceDestinationString:m,resourceTitleString:Be,resource:Xe,setextHeading:a(E),setextHeadingLineSequence:W,setextHeadingText:w,strong:a(),thematicBreak:a()}};Ja(e,(n||{}).mdastExtensions||[]);const t={};return r;function r(S){let C={type:"root",children:[]};const F={stack:[C],tokenStack:[],config:e,enter:l,exit:u,buffer:o,resume:c,data:t},_=[];let Y=-1;for(;++Y<S.length;)if(S[Y][1].type==="listOrdered"||S[Y][1].type==="listUnordered")if(S[Y][0]==="enter")_.push(Y);else{const Le=_.pop();Y=i(S,Le,Y)}for(Y=-1;++Y<S.length;){const Le=e[S[Y][0]];ja.call(Le,S[Y][1].type)&&Le[S[Y][1].type].call(Object.assign({sliceSerialize:S[Y][2].sliceSerialize},F),S[Y][1])}if(F.tokenStack.length>0){const Le=F.tokenStack[F.tokenStack.length-1];(Le[1]||il).call(F,void 0,Le[0])}for(C.position={start:yt(S.length>0?S[0][1].start:{line:1,column:1,offset:0}),end:yt(S.length>0?S[S.length-2][1].end:{line:1,column:1,offset:0})},Y=-1;++Y<e.transforms.length;)C=e.transforms[Y](C)||C;return C}function i(S,C,F){let _=C-1,Y=-1,Le=!1,vt,Ze,Vn,_n;for(;++_<=F;){const we=S[_];switch(we[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{we[0]==="enter"?Y++:Y--,_n=void 0;break}case"lineEndingBlank":{we[0]==="enter"&&(vt&&!_n&&!Y&&!Vn&&(Vn=_),_n=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:_n=void 0}if(!Y&&we[0]==="enter"&&we[1].type==="listItemPrefix"||Y===-1&&we[0]==="exit"&&(we[1].type==="listUnordered"||we[1].type==="listOrdered")){if(vt){let an=_;for(Ze=void 0;an--;){const et=S[an];if(et[1].type==="lineEnding"||et[1].type==="lineEndingBlank"){if(et[0]==="exit")continue;Ze&&(S[Ze][1].type="lineEndingBlank",Le=!0),et[1].type="lineEnding",Ze=an}else if(!(et[1].type==="linePrefix"||et[1].type==="blockQuotePrefix"||et[1].type==="blockQuotePrefixWhitespace"||et[1].type==="blockQuoteMarker"||et[1].type==="listItemIndent"))break}Vn&&(!Ze||Vn<Ze)&&(vt._spread=!0),vt.end=Object.assign({},Ze?S[Ze][1].start:we[1].end),S.splice(Ze||_,0,["exit",vt,we[2]]),_++,F++}if(we[1].type==="listItemPrefix"){const an={type:"listItem",_spread:!1,start:Object.assign({},we[1].start),end:void 0};vt=an,S.splice(_,0,["enter",an,we[2]]),_++,F++,Vn=void 0,_n=!0}}}return S[C][1]._spread=Le,F}function s(S,C){return F;function F(_){l.call(this,S(_),_),C&&C.call(this,_)}}function o(){this.stack.push({type:"fragment",children:[]})}function l(S,C,F){this.stack[this.stack.length-1].children.push(S),this.stack.push(S),this.tokenStack.push([C,F||void 0]),S.position={start:yt(C.start),end:void 0}}function a(S){return C;function C(F){S&&S.call(this,F),u.call(this,F)}}function u(S,C){const F=this.stack.pop(),_=this.tokenStack.pop();if(_)_[0].type!==S.type&&(C?C.call(this,S,_[0]):(_[1]||il).call(this,S,_[0]));else throw new Error("Cannot close `"+S.type+"` ("+nr({start:S.start,end:S.end})+"): it’s not open");F.position.end=yt(S.end)}function c(){return Gs(this.stack.pop())}function h(){this.data.expectingFirstListItemValue=!0}function d(S){if(this.data.expectingFirstListItemValue){const C=this.stack[this.stack.length-2];C.start=Number.parseInt(this.sliceSerialize(S),10),this.data.expectingFirstListItemValue=void 0}}function f(){const S=this.resume(),C=this.stack[this.stack.length-1];C.lang=S}function p(){const S=this.resume(),C=this.stack[this.stack.length-1];C.meta=S}function y(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function x(){const S=this.resume(),C=this.stack[this.stack.length-1];C.value=S.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function k(){const S=this.resume(),C=this.stack[this.stack.length-1];C.value=S.replace(/(\r?\n|\r)$/g,"")}function D(S){const C=this.resume(),F=this.stack[this.stack.length-1];F.label=C,F.identifier=mn(this.sliceSerialize(S)).toLowerCase()}function M(){const S=this.resume(),C=this.stack[this.stack.length-1];C.title=S}function V(){const S=this.resume(),C=this.stack[this.stack.length-1];C.url=S}function $(S){const C=this.stack[this.stack.length-1];if(!C.depth){const F=this.sliceSerialize(S).length;C.depth=F}}function w(){this.data.setextHeadingSlurpLineEnding=!0}function W(S){const C=this.stack[this.stack.length-1];C.depth=this.sliceSerialize(S).codePointAt(0)===61?1:2}function E(){this.data.setextHeadingSlurpLineEnding=void 0}function R(S){const F=this.stack[this.stack.length-1].children;let _=F[F.length-1];(!_||_.type!=="text")&&(_=Ic(),_.position={start:yt(S.start),end:void 0},F.push(_)),this.stack.push(_)}function v(S){const C=this.stack.pop();C.value+=this.sliceSerialize(S),C.position.end=yt(S.end)}function I(S){const C=this.stack[this.stack.length-1];if(this.data.atHardBreak){const F=C.children[C.children.length-1];F.position.end=yt(S.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&e.canContainEols.includes(C.type)&&(R.call(this,S),v.call(this,S))}function A(){this.data.atHardBreak=!0}function X(){const S=this.resume(),C=this.stack[this.stack.length-1];C.value=S}function Z(){const S=this.resume(),C=this.stack[this.stack.length-1];C.value=S}function j(){const S=this.resume(),C=this.stack[this.stack.length-1];C.value=S}function ue(){const S=this.stack[this.stack.length-1];if(this.data.inReference){const C=this.data.referenceType||"shortcut";S.type+="Reference",S.referenceType=C,delete S.url,delete S.title}else delete S.identifier,delete S.label;this.data.referenceType=void 0}function re(){const S=this.stack[this.stack.length-1];if(this.data.inReference){const C=this.data.referenceType||"shortcut";S.type+="Reference",S.referenceType=C,delete S.url,delete S.title}else delete S.identifier,delete S.label;this.data.referenceType=void 0}function Fe(S){const C=this.sliceSerialize(S),F=this.stack[this.stack.length-2];F.label=Wa(C),F.identifier=mn(C).toLowerCase()}function Ge(){const S=this.stack[this.stack.length-1],C=this.resume(),F=this.stack[this.stack.length-1];if(this.data.inReference=!0,F.type==="link"){const _=S.children;F.children=_}else F.alt=C}function m(){const S=this.resume(),C=this.stack[this.stack.length-1];C.url=S}function Be(){const S=this.resume(),C=this.stack[this.stack.length-1];C.title=S}function Xe(){this.data.inReference=void 0}function g(){this.data.referenceType="collapsed"}function ve(S){const C=this.resume(),F=this.stack[this.stack.length-1];F.label=C,F.identifier=mn(this.sliceSerialize(S)).toLowerCase(),this.data.referenceType="full"}function Bt(S){this.data.characterReferenceType=S.type}function ie(S){const C=this.sliceSerialize(S),F=this.data.characterReferenceType;let _;F?(_=Ra(C,F==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):_=Xs(C);const Y=this.stack[this.stack.length-1];Y.value+=_}function Ln(S){const C=this.stack.pop();C.position.end=yt(S.end)}function gt(S){v.call(this,S);const C=this.stack[this.stack.length-1];C.url=this.sliceSerialize(S)}function on(S){v.call(this,S);const C=this.stack[this.stack.length-1];C.url="mailto:"+this.sliceSerialize(S)}function ln(){return{type:"blockquote",children:[]}}function Or(){return{type:"code",lang:null,meta:null,value:""}}function wc(){return{type:"inlineCode",value:""}}function Cc(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Tc(){return{type:"emphasis",children:[]}}function Eo(){return{type:"heading",depth:0,children:[]}}function Io(){return{type:"break"}}function Ao(){return{type:"html",value:""}}function Mc(){return{type:"image",title:null,url:"",alt:null}}function Do(){return{type:"link",title:null,url:"",children:[]}}function zo(S){return{type:"list",ordered:S.type==="listOrdered",start:null,spread:S._spread,children:[]}}function Oc(S){return{type:"listItem",spread:S._spread,checked:null,children:[]}}function Nc(){return{type:"paragraph",children:[]}}function Ec(){return{type:"strong",children:[]}}function Ic(){return{type:"text",value:""}}function Ac(){return{type:"thematicBreak"}}}function yt(n){return{line:n.line,column:n.column,offset:n.offset}}function Ja(n,e){let t=-1;for(;++t<e.length;){const r=e[t];Array.isArray(r)?Ja(n,r):bd(n,r)}}function bd(n,e){let t;for(t in e)if(ja.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 il(n,e){throw n?new Error("Cannot close `"+n.type+"` ("+nr({start:n.start,end:n.end})+"): a different token (`"+e.type+"`, "+nr({start:e.start,end:e.end})+") is open"):new Error("Cannot close document, a token (`"+e.type+"`, "+nr({start:e.start,end:e.end})+") is still open")}function bs(n){const e=this;e.parser=t;function t(r){return kd(r,{...e.data("settings"),...n,extensions:e.data("micromarkExtensions")||[],mdastExtensions:e.data("fromMarkdownExtensions")||[]})}}const sl={}.hasOwnProperty;function Sd(n,e){const t=e||{};function r(i,...s){let o=r.invalid;const l=r.handlers;if(i&&sl.call(i,n)){const a=String(i[n]);o=sl.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 wd={}.hasOwnProperty;function Ha(n,e){let t=-1,r;if(e.extensions)for(;++t<e.extensions.length;)Ha(n,e.extensions[t]);for(r in e)if(wd.call(e,r))switch(r){case"extensions":break;case"unsafe":{ol(n[r],e[r]);break}case"join":{ol(n[r],e[r]);break}case"handlers":{Cd(n[r],e[r]);break}default:n.options[r]=e[r]}return n}function ol(n,e){e&&n.push(...e)}function Cd(n,e){e&&Object.assign(n,e)}function Td(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()),Md);return i(),o}function Md(n,e,t){return">"+(t?"":" ")+n}function Ka(n,e){return ll(n,e.inConstruct,!0)&&!ll(n,e.notInConstruct,!1)}function ll(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 al(n,e,t,r){let i=-1;for(;++i<t.unsafe.length;)if(t.unsafe[i].character===`
8
- `&&Ka(t.stack,t.unsafe[i]))return/[ \t]/.test(r.before)?"":" ";return`\\
9
- `}function Od(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 Ss(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 Nd(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 Ed(n,e,t,r){const i=Nd(t),s=n.value||"",o=i==="`"?"GraveAccent":"Tilde";if(Ss(n,t)){const h=t.enter("codeIndented"),d=t.indentLines(s,Id);return h(),d}const l=t.createTracker(r),a=i.repeat(Math.max(Od(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:`
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 wf(n){const r={constructs:Ec([kf,...(n||{}).extensions||[]]),content:i(Bc),defined:[],document:i(Lc),flow:i(nf),lazy:{},string:i(of),text:i(lf)};return r;function i(s){return o;function o(l){return xf(r,s,l)}}}function Cf(n){for(;!jl(n););return n}const co=/[\0\t\n\r]/g;function Tf(){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 Mf=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Ql(n){return n.replace(Mf,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 Nf(n,e,t){return typeof e!="string"&&(t=e,e=void 0),Ef(t)(Cf(wf(t).document().write(Tf()(n,e,!0))))}function Ef(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(Du,o),codeTextData:z,data:z,codeFlowValue:z,definition:s(Ru),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:s(zu),hardBreakEscape:s(_s),hardBreakTrailing:s(_s),htmlFlow:s($s,o),htmlFlowData:z,htmlText:s($s,o),htmlTextData:z,image:s(Pu),label:o,link:s(qs),listItem:s(Fu),listItemValue:d,listOrdered:s(Ws,h),listUnordered:s(Ws),paragraph:s(Bu),reference:g,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:s(Vs),strong:s(vu),thematicBreak:s(Vu)},exit:{atxHeading:a(),atxHeadingSequence:$,autolink:a(),autolinkEmail:Ft,autolinkProtocol:nt,blockQuote:a(),characterEscapeValue:J,characterReferenceMarkerHexadecimal:kt,characterReferenceMarkerNumeric:kt,characterReferenceValue:te,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:E,definitionTitleString:C,emphasis:a(),hardBreakEscape:a(N),hardBreakTrailing:a(N),htmlFlow:a(Y),htmlFlowData:J,htmlText:a(Q),htmlTextData:J,image:a(ee),label:je,labelText:Ee,lineEnding:I,link:a(oe),listItem:a(),listOrdered:a(),listUnordered:a(),paragraph:a(),referenceString:Ae,resourceDestinationString:m,resourceTitleString:Ie,resource:Je,setextHeading:a(P),setextHeadingLineSequence:O,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 E(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 O(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=Lu(),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 I(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 N(){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 oe(){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(){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 te(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 Du(){return{type:"inlineCode",value:""}}function Ru(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function zu(){return{type:"emphasis",children:[]}}function Vs(){return{type:"heading",depth:0,children:[]}}function _s(){return{type:"break"}}function $s(){return{type:"html",value:""}}function Pu(){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 Fu(b){return{type:"listItem",spread:b._spread,checked:null,children:[]}}function Bu(){return{type:"paragraph",children:[]}}function vu(){return{type:"strong",children:[]}}function Lu(){return{type:"text",value:""}}function Vu(){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):If(n,r)}}function If(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 Nf(r,{...e.data("settings"),...n,extensions:e.data("micromarkExtensions")||[],mdastExtensions:e.data("fromMarkdownExtensions")||[]})}}const mo={}.hasOwnProperty;function Af(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 Df={}.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(Df.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":{Rf(n[r],e[r]);break}default:n.options[r]=e[r]}return n}function go(n,e){e&&n.push(...e)}function Rf(n,e){e&&Object.assign(n,e)}function zf(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()),Pf);return i(),o}function Pf(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 Ff(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 Bf(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 vf(n,e,t,r){const i=Bf(t),s=n.value||"",o=i==="`"?"GraveAccent":"Tilde";if(Ri(n,t)){const h=t.enter("codeIndented"),d=t.indentLines(s,Lf);return h(),d}const l=t.createTracker(r),a=i.repeat(Math.max(Ff(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
10
  `,encode:["`"],...l.current()})),h()}return c+=l.move(`
11
11
  `),s&&(c+=l.move(s+`
12
- `)),c+=l.move(a),u(),c}function Id(n,e,t){return(t?"":" ")+n}function to(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 Ad(n,e,t,r){const i=to(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 Dd(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 At(n){return"&#x"+n.toString(16).toUpperCase()+";"}function ri(n,e,t){const r=ni(n),i=ni(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}}Ua.peek=zd;function Ua(n,e,t,r){const i=Dd(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=ri(r.before.charCodeAt(r.before.length-1),u,i);c.inside&&(a=At(u)+a.slice(1));const h=a.charCodeAt(a.length-1),d=ri(r.after.charCodeAt(0),h,i);d.inside&&(a=a.slice(0,-1)+At(h));const f=o.move(i);return s(),t.attentionEncodeSurroundingInfo={after:d.outside,before:c.outside},l+a+f}function zd(n,e,t){return t.options.emphasis||"*"}const no=function(n){if(n==null)return Bd;if(typeof n=="function")return mi(n);if(typeof n=="object")return Array.isArray(n)?Rd(n):Pd(n);if(typeof n=="string")return Fd(n);throw new Error("Expected function, string, or object as test")};function Rd(n){const e=[];let t=-1;for(;++t<n.length;)e[t]=no(n[t]);return mi(r);function r(...i){let s=-1;for(;++s<e.length;)if(e[s].apply(this,i))return!0;return!1}}function Pd(n){const e=n;return mi(t);function t(r){const i=r;let s;for(s in n)if(i[s]!==e[s])return!1;return!0}}function Fd(n){return mi(e);function e(t){return t&&t.type===n}}function mi(n){return e;function e(t,r,i){return!!(vd(t)&&n.call(this,t,typeof r=="number"?r:void 0,i||void 0))}}function Bd(){return!0}function vd(n){return n!==null&&typeof n=="object"&&"type"in n}const Ya=[],Ld=!0,ws=!1,Vd="skip";function _d(n,e,t,r){let i;typeof e=="function"&&typeof t!="function"?(r=t,t=e):i=e;const s=no(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=Ya,p,y,x;if((!e||s(a,u,c[c.length-1]||void 0))&&(f=$d(t(a,c)),f[0]===ws))return f;if("children"in a&&a.children){const k=a;if(k.children&&f[0]!==Vd)for(y=(r?k.children.length:-1)+o,x=c.concat(k);y>-1&&y<k.children.length;){const D=k.children[y];if(p=l(D,y,x)(),p[0]===ws)return p;y=typeof p[1]=="number"?p[1]:y+o}}return f}}}function $d(n){return Array.isArray(n)?n:typeof n=="number"?[Ld,n]:n==null?Ya:[n]}function qd(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),_d(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 Qa(n,e){let t=!1;return qd(n,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return t=!0,ws}),!!((!n.depth||n.depth<3)&&Gs(n)&&(e.options.setext||t))}function Wd(n,e,t,r){const i=Math.max(Math.min(6,n.depth||1),1),s=t.createTracker(r);if(Qa(n,t)){const c=t.enter("headingSetext"),h=t.enter("phrasing"),d=t.containerPhrasing(n,{...s.current(),before:`
12
+ `)),c+=l.move(a),u(),c}function Lf(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 Vf(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=$f;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 $f(n,e,t){return t.options.emphasis||"*"}const gs=(function(n){if(n==null)return Jf;if(typeof n=="function")return Nr(n);if(typeof n=="object")return Array.isArray(n)?qf(n):Wf(n);if(typeof n=="string")return jf(n);throw new Error("Expected function, string, or object as test")});function qf(n){const e=[];let t=-1;for(;++t<n.length;)e[t]=gs(n[t]);return Nr(r);function r(...i){let s=-1;for(;++s<e.length;)if(e[s].apply(this,i))return!0;return!1}}function Wf(n){const e=n;return Nr(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 Nr(e);function e(t){return t&&t.type===n}}function Nr(n){return e;function e(t,r,i){return!!(Hf(t)&&n.call(this,t,typeof r=="number"?r:void 0,i||void 0))}}function Jf(){return!0}function Hf(n){return n!==null&&typeof n=="object"&&"type"in n}const na=[],Kf=!0,zi=!1,Uf="skip";function Yf(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=Qf(t(a,c)),f[0]===zi))return f;if("children"in a&&a.children){const k=a;if(k.children&&f[0]!==Uf)for(y=(r?k.children.length:-1)+o,x=c.concat(k);y>-1&&y<k.children.length;){const E=k.children[y];if(p=l(E,y,x)(),p[0]===zi)return p;y=typeof p[1]=="number"?p[1]:y+o}}return f}}}function Qf(n){return Array.isArray(n)?n:typeof n=="number"?[Kf,n]:n==null?na:[n]}function Gf(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),Yf(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 Gf(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 Xf(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:`
14
14
  `,after:`
15
15
  `});return h(),c(),d+`
16
16
  `+(i===1?"=":"-").repeat(d.length-(Math.max(d.lastIndexOf("\r"),d.lastIndexOf(`
17
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=At(u.charCodeAt(0))+u.slice(1)),u=u?o+" "+u:o,t.options.closeAtx&&(u+=" "+o),a(),l(),u}Ga.peek=jd;function Ga(n){return n.value||""}function jd(){return"<"}Xa.peek=Jd;function Xa(n,e,t,r){const i=to(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 Jd(){return"!"}Za.peek=Hd;function Za(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 Hd(){return"!"}eu.peek=Kd;function eu(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 Kd(){return"`"}function tu(n,e){const t=Gs(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))}nu.peek=Ud;function nu(n,e,t,r){const i=to(t),s=i==='"'?"Quote":"Apostrophe",o=t.createTracker(r);let l,a;if(tu(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 Ud(n,e,t){return tu(n,t)?"<":"["}ru.peek=Yd;function ru(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 Yd(){return"["}function ro(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 Qd(n){const e=ro(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 Gd(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 iu(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 Xd(n,e,t,r){const i=t.enter("list"),s=t.bulletCurrent;let o=n.ordered?Gd(t):ro(t);const l=n.ordered?o==="."?")":".":Qd(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),iu(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 Zd(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 ep(n,e,t,r){const i=Zd(t);let s=t.bulletCurrent||ro(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 tp(n,e,t,r){const i=t.enter("paragraph"),s=t.enter("phrasing"),o=t.containerPhrasing(n,r);return s(),i(),o}const np=no(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function rp(n,e,t,r){return(n.children.some(function(o){return np(o)})?t.containerPhrasing:t.containerFlow).call(t,n,r)}function ip(n){const e=n.options.strong||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize strong with `"+e+"` for `options.strong`, expected `*`, or `_`");return e}su.peek=sp;function su(n,e,t,r){const i=ip(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=ri(r.before.charCodeAt(r.before.length-1),u,i);c.inside&&(a=At(u)+a.slice(1));const h=a.charCodeAt(a.length-1),d=ri(r.after.charCodeAt(0),h,i);d.inside&&(a=a.slice(0,-1)+At(h));const f=o.move(i+i);return s(),t.attentionEncodeSurroundingInfo={after:d.outside,before:c.outside},l+a+f}function sp(n,e,t){return t.options.strong||"*"}function op(n,e,t,r){return t.safe(n.value,r)}function lp(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 ap(n,e,t){const r=(iu(t)+(t.options.ruleSpaces?" ":"")).repeat(lp(t));return t.options.ruleSpaces?r.slice(0,-1):r}const up={blockquote:Td,break:al,code:Ed,definition:Ad,emphasis:Ua,hardBreak:al,heading:Wd,html:Ga,image:Xa,imageReference:Za,inlineCode:eu,link:nu,linkReference:ru,list:Xd,listItem:ep,paragraph:tp,root:rp,strong:su,text:op,thematicBreak:ap},cp=[hp];function hp(n,e,t,r){if(e.type==="code"&&Ss(e,r)&&(n.type==="list"||n.type===e.type&&Ss(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"&&Qa(e,r))?void 0:t.spread?1:0}const Lt=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"],fp=[{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:Lt},{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:Lt},{atBreak:!0,before:"\\d+",character:")"},{character:")",inConstruct:"destinationRaw"},{atBreak:!0,character:"*",after:`(?:[ \r
21
- *])`},{character:"*",inConstruct:"phrasing",notInConstruct:Lt},{atBreak:!0,character:"+",after:`(?:[ \r
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=Zf;function ia(n){return n.value||""}function Zf(){return"<"}sa.peek=ed;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 ed(){return"!"}oa.peek=td;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 td(){return"!"}la.peek=nd;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 nd(){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=rd;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 rd(n,e,t){return aa(n,t)?"<":"["}ca.peek=id;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 id(){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 sd(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 od(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 ld(n,e,t,r){const i=t.enter("list"),s=t.bulletCurrent;let o=n.ordered?od(t):ys(t);const l=n.ordered?o==="."?")":".":sd(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 ad(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 ud(n,e,t,r){const i=ad(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 cd(n,e,t,r){const i=t.enter("paragraph"),s=t.enter("phrasing"),o=t.containerPhrasing(n,r);return s(),i(),o}const hd=gs(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function fd(n,e,t,r){return(n.children.some(function(o){return hd(o)})?t.containerPhrasing:t.containerFlow).call(t,n,r)}function dd(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=pd;function fa(n,e,t,r){const i=dd(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 pd(n,e,t){return t.options.strong||"*"}function md(n,e,t,r){return t.safe(n.value,r)}function gd(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 yd(n,e,t){const r=(ha(t)+(t.options.ruleSpaces?" ":"")).repeat(gd(t));return t.options.ruleSpaces?r.slice(0,-1):r}const kd={blockquote:zf,break:ko,code:vf,definition:Vf,emphasis:ta,hardBreak:ko,heading:Xf,html:ia,image:sa,imageReference:oa,inlineCode:la,link:ua,linkReference:ca,list:ld,listItem:ud,paragraph:cd,root:fd,strong:fa,text:md,thematicBreak:yd},xd=[bd];function bd(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"],Sd=[{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
22
  ])`},{atBreak:!0,character:"-",after:`(?:[ \r
23
23
  -])`},{atBreak:!0,before:"\\d+",character:".",after:`(?:[ \r
24
- ]|$)`},{atBreak:!0,character:"<",after:"[!/?A-Za-z]"},{character:"<",after:"[!/?A-Za-z]",inConstruct:"phrasing",notInConstruct:Lt},{character:"<",inConstruct:"destinationLiteral"},{atBreak:!0,character:"="},{atBreak:!0,character:">"},{character:">",inConstruct:"destinationLiteral"},{atBreak:!0,character:"["},{character:"[",inConstruct:"phrasing",notInConstruct:Lt},{character:"[",inConstruct:["label","reference"]},{character:"\\",after:"[\\r\\n]",inConstruct:"phrasing"},{character:"]",inConstruct:["label","reference"]},{atBreak:!0,character:"_"},{character:"_",inConstruct:"phrasing",notInConstruct:Lt},{atBreak:!0,character:"`"},{character:"`",inConstruct:["codeFencedLangGraveAccent","codeFencedMetaGraveAccent"]},{character:"`",inConstruct:"phrasing",notInConstruct:Lt},{atBreak:!0,character:"~"}];function dp(n){return n.label||!n.identifier?n.label||"":Wa(n.identifier)}function pp(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 mp(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=At(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)+At(l.charCodeAt(0))),f.after&&(a=h)),u.move(d),s.push(d),l=d.slice(-1)}return r.pop(),s.join("")}function gp(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:`
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 wd(n){return n.label||!n.identifier?n.label||"":Ql(n.identifier)}function Cd(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 Td(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 Md(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:`
26
26
  `,after:`
27
- `,...s.current()}))),a.type!=="list"&&(e.bulletLastUsed=void 0),l<i.length-1&&o.push(s.move(yp(a,i[l+1],n,e)))}return r.pop(),o.join("")}function yp(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`
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
28
  `.repeat(1+s);if(s===!1)return`
29
29
 
30
30
  <!---->
31
31
 
32
32
  `}return`
33
33
 
34
- `}const kp=/\r?\n|\r/g;function xp(n,e){const t=[];let r=0,i=0,s;for(;s=kp.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 bp(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(!Ka(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(Sp);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(ul(r.slice(a,c),"\\")),a=c,/[!-/:-@[-`{-~]/.test(r.charAt(c))&&(!t.encode||!t.encode.includes(r.charAt(c)))?s.push("\\"):(s.push(At(r.charCodeAt(c))),a++))}return s.push(ul(r.slice(a,u),t.after)),s.join("")}function Sp(n,e){return n-e}function ul(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 wp(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 Cp(n,e){const t=e||{},r={associationId:dp,containerPhrasing:Np,containerFlow:Ep,createTracker:wp,compilePattern:pp,enter:s,handlers:{...up},handle:void 0,indentLines:xp,indexStack:[],join:[...cp],options:{},safe:Ip,stack:[],unsafe:[...fp]};Ha(r,t),r.options.tightDefinitions&&r.join.push(Op),r.handle=Sd("type",{invalid:Tp,unknown:Mp,handlers:r.handlers});let i=r.handle(n,void 0,r,{before:`
34
+ `}const Nd=/\r?\n|\r/g;function Ed(n,e){const t=[];let r=0,i=0,s;for(;s=Nd.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 Id(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(Ad);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 Ad(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 Dd(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 Rd(n,e){const t=e||{},r={associationId:wd,containerPhrasing:Bd,containerFlow:vd,createTracker:Dd,compilePattern:Cd,enter:s,handlers:{...kd},handle:void 0,indentLines:Ed,indexStack:[],join:[...xd],options:{},safe:Ld,stack:[],unsafe:[...Sd]};Zl(r,t),r.options.tightDefinitions&&r.join.push(Fd),r.handle=Af("type",{invalid:zd,unknown:Pd,handlers:r.handlers});let i=r.handle(n,void 0,r,{before:`
35
35
  `,after:`
36
36
  `,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 Tp(n){throw new Error("Cannot handle value `"+n+"`, expected node")}function Mp(n){const e=n;throw new Error("Cannot handle unknown node `"+e.type+"`")}function Op(n,e){if(n.type==="definition"&&n.type===e.type)return 0}function Np(n,e){return mp(n,this,e)}function Ep(n,e){return gp(n,this,e)}function Ip(n,e){return bp(this,n,e)}function Cs(n){const e=this;e.compiler=t;function t(r){return Cp(r,{...e.data("settings"),...n,extensions:e.data("toMarkdownExtensions")||[]})}}function cl(n){if(n)throw n}var Ni,hl;function Ap(){if(hl)return Ni;hl=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 Ni=function a(){var u,c,h,d,f,p,y=arguments[0],x=1,k=arguments.length,D=!1;for(typeof y=="boolean"&&(D=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&&(D&&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(D,p,d)})):typeof d<"u"&&o(y,{name:c,newValue:d}));return y},Ni}var Dp=Ap();const Ei=zc(Dp);function Ts(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 zp(){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?Rp(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 Rp(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 Se 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=nr(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}}Se.prototype.file="";Se.prototype.name="";Se.prototype.reason="";Se.prototype.message="";Se.prototype.stack="";Se.prototype.column=void 0;Se.prototype.line=void 0;Se.prototype.ancestors=void 0;Se.prototype.cause=void 0;Se.prototype.fatal=void 0;Se.prototype.place=void 0;Se.prototype.ruleId=void 0;Se.prototype.source=void 0;const Je={basename:Pp,dirname:Fp,extname:Bp,join:vp,sep:"/"};function Pp(n,e){if(e!==void 0&&typeof e!="string")throw new TypeError('"ext" argument must be a string');wr(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 Fp(n){if(wr(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 Bp(n){wr(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 vp(...n){let e=-1,t;for(;++e<n.length;)wr(n[e]),n[e]&&(t=t===void 0?n[e]:t+"/"+n[e]);return t===void 0?".":Lp(t)}function Lp(n){wr(n);const e=n.codePointAt(0)===47;let t=Vp(n,!e);return t.length===0&&!e&&(t="."),t.length>0&&n.codePointAt(n.length-1)===47&&(t+="/"),e?"/"+t:t}function Vp(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 wr(n){if(typeof n!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(n))}const _p={cwd:$p};function $p(){return"/"}function Ms(n){return!!(n!==null&&typeof n=="object"&&"href"in n&&n.href&&"protocol"in n&&n.protocol&&n.auth===void 0)}function qp(n){if(typeof n=="string")n=new URL(n);else if(!Ms(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 Wp(n)}function Wp(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 Ii=["history","path","basename","stem","extname","dirname"];class jp{constructor(e){let t;e?Ms(e)?t={path:e}:typeof e=="string"||Jp(e)?t={value:e}:t=e:t={},this.cwd="cwd"in t?"":_p.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<Ii.length;){const s=Ii[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)Ii.includes(i)||(this[i]=t[i])}get basename(){return typeof this.path=="string"?Je.basename(this.path):void 0}set basename(e){Di(e,"basename"),Ai(e,"basename"),this.path=Je.join(this.dirname||"",e)}get dirname(){return typeof this.path=="string"?Je.dirname(this.path):void 0}set dirname(e){fl(this.basename,"dirname"),this.path=Je.join(e||"",this.basename)}get extname(){return typeof this.path=="string"?Je.extname(this.path):void 0}set extname(e){if(Ai(e,"extname"),fl(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=Je.join(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){Ms(e)&&(e=qp(e)),Di(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path=="string"?Je.basename(this.path,this.extname):void 0}set stem(e){Di(e,"stem"),Ai(e,"stem"),this.path=Je.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 Se(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 Ai(n,e){if(n&&n.includes(Je.sep))throw new Error("`"+e+"` cannot be a path: did not expect `"+Je.sep+"`")}function Di(n,e){if(!n)throw new Error("`"+e+"` cannot be empty")}function fl(n,e){if(!n)throw new Error("Setting `"+e+"` requires `path` to be set too")}function Jp(n){return!!(n&&typeof n=="object"&&"byteLength"in n&&"byteOffset"in n)}const Hp=function(n){const r=this.constructor.prototype,i=r[n],s=function(){return i.apply(s,arguments)};return Object.setPrototypeOf(s,r),s},Kp={}.hasOwnProperty;class io extends Hp{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=zp()}copy(){const e=new io;let t=-1;for(;++t<this.attachers.length;){const r=this.attachers[t];e.use(...r)}return e.data(Ei(!0,{},this.namespace)),e}data(e,t){return typeof e=="string"?arguments.length===2?(Pi("data",this.frozen),this.namespace[e]=t,this):Kp.call(this.namespace,e)&&this.namespace[e]||void 0:e?(Pi("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=Ir(e),r=this.parser||this.Parser;return zi("parse",r),r(String(t),t)}process(e,t){const r=this;return this.freeze(),zi("process",this.parser||this.Parser),Ri("process",this.compiler||this.Compiler),t?i(void 0,t):new Promise(i);function i(s,o){const l=Ir(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);Yp(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(),zi("processSync",this.parser||this.Parser),Ri("processSync",this.compiler||this.Compiler),this.process(e,i),pl("processSync","process",t),r;function i(s,o){t=!0,cl(s),r=o}}run(e,t,r){dl(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=Ir(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),pl("runSync","run",r),i;function s(o,l){cl(o),i=l,r=!0}}stringify(e,t){this.freeze();const r=Ir(t),i=this.compiler||this.Compiler;return Ri("stringify",i),dl(e),i(e,r)}use(e,...t){const r=this.attachers,i=this.namespace;if(Pi("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=Ei(!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];Ts(y)&&Ts(f)&&(f=Ei(!0,y,f)),r[d]=[u,f,...p]}}}}const Os=new io().freeze();function zi(n,e){if(typeof e!="function")throw new TypeError("Cannot `"+n+"` without `parser`")}function Ri(n,e){if(typeof e!="function")throw new TypeError("Cannot `"+n+"` without `compiler`")}function Pi(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 dl(n){if(!Ts(n)||typeof n.type!="string")throw new TypeError("Expected node, got `"+n+"`")}function pl(n,e,t){if(!t)throw new Error("`"+n+"` finished async. Use `"+e+"` instead")}function Ir(n){return Up(n)?n:new jp(n)}function Up(n){return!!(n&&typeof n=="object"&&"message"in n&&"messages"in n)}function Yp(n){return typeof n=="string"||Qp(n)}function Qp(n){return!!(n&&typeof n=="object"&&"byteLength"in n&&"byteOffset"in n)}var ou=n=>{throw TypeError(n)},lu=(n,e,t)=>e.has(n)||ou("Cannot "+t),L=(n,e,t)=>(lu(n,e,"read from private field"),t?t.call(n):e.get(n)),ee=(n,e,t)=>e.has(n)?ou("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),G=(n,e,t,r)=>(lu(n,e,"write to private field"),e.set(n,t),t),je,Wn,Rr,Pr,Fr,jn,Jn,nt,Hn,Br,vr,Kn,Lr,Un,Vr,_r,hn,Vt,$r,Yn;class au{}class uu{constructor(){this.elements=[],this.size=()=>this.elements.length,this.top=()=>this.elements.at(-1),this.push=e=>{var t;(t=this.top())==null||t.push(e)},this.open=e=>{this.elements.push(e)},this.close=()=>{const e=this.elements.pop();if(!e)throw da();return e}}}class so extends au{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 so(e,t,r)}}const Ns=class extends uu{constructor(e){super(),ee(this,je),ee(this,Wn),ee(this,Rr),ee(this,Pr),ee(this,Fr),ee(this,jn),ee(this,Jn),G(this,je,q.none),G(this,Wn,t=>t.isText),G(this,Rr,(t,r)=>{if(L(this,Wn).call(this,t)&&L(this,Wn).call(this,r)&&q.sameSet(t.marks,r.marks))return this.schema.text(t.text+r.text,t.marks)}),G(this,Pr,t=>{const r=Object.values({...this.schema.nodes,...this.schema.marks}).find(i=>i.spec.parseMarkdown.match(t));if(!r)throw Lc(t);return r}),G(this,Fr,t=>{const r=L(this,Pr).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(so.create(t,[],r)),this),G(this,jn,()=>{G(this,je,q.none);const t=this.close();return L(this,Jn).call(this,t.type,t.attrs,t.content)}),this.closeNode=()=>{try{L(this,jn).call(this)}catch(t){console.error(t)}return this},G(this,Jn,(t,r,i)=>{const s=t.createAndFill(r,i,L(this,je));if(!s)throw vc(t,r,i);return this.push(s),s}),this.addNode=(t,r,i)=>{try{L(this,Jn).call(this,t,r,i)}catch(s){console.error(s)}return this},this.openMark=(t,r)=>{const i=t.create(r);return G(this,je,i.addToSet(L(this,je))),this},this.closeMark=t=>(G(this,je,t.removeFromSet(L(this,je))),this),this.addText=t=>{try{const r=this.top();if(!r)throw da();const i=r.pop(),s=this.schema.text(t,L(this,je));if(!i)return r.push(s),this;const o=L(this,Rr).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=L(this,jn).call(this);while(this.size());return t},this.next=(t=[])=>([t].flat().forEach(r=>L(this,Fr).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}};je=new WeakMap;Wn=new WeakMap;Rr=new WeakMap;Pr=new WeakMap;Fr=new WeakMap;jn=new WeakMap;Jn=new WeakMap;Ns.create=(n,e)=>{const t=new Ns(n);return r=>(t.run(e,r),t.toDoc())};let Gp=Ns;const Es=class extends au{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=()=>{var s;return(s=this.children)==null?void 0:s.pop()}}};Es.create=(n,e,t,r={})=>new Es(n,e,t,r);let ml=Es;const Xp=n=>Object.prototype.hasOwnProperty.call(n,"size"),Is=class extends uu{constructor(e){super(),ee(this,nt),ee(this,Hn),ee(this,Br),ee(this,vr),ee(this,Kn),ee(this,Lr),ee(this,Un),ee(this,Vr),ee(this,_r),ee(this,hn),ee(this,Vt),ee(this,$r),ee(this,Yn),G(this,nt,q.none),G(this,Hn,t=>{const r=Object.values({...this.schema.nodes,...this.schema.marks}).find(i=>i.spec.toMarkdown.match(t));if(!r)throw Vc(t.type);return r}),G(this,Br,t=>L(this,Hn).call(this,t).spec.toMarkdown.runner(this,t)),G(this,vr,(t,r)=>L(this,Hn).call(this,t).spec.toMarkdown.runner(this,t,r)),G(this,Kn,t=>{const{marks:r}=t,i=l=>l.type.spec.priority??50;[...r].sort((l,a)=>i(l)-i(a)).every(l=>!L(this,vr).call(this,l,t))&&L(this,Br).call(this,t),r.forEach(l=>L(this,Yn).call(this,l))}),G(this,Lr,(t,r)=>{var a;if(t.type===r||((a=t.children)==null?void 0:a.length)!==1)return t;const i=u=>{var h;if(u.type===r)return u;if(((h=u.children)==null?void 0:h.length)!==1)return null;const[c]=u.children;return c?i(c):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}),G(this,Un,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=L(this,Lr).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(L(this,Un).call(this,d))}}return i.concat(s)},[])),t}),G(this,Vr,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(ml.create(t,void 0,r,i)),this),G(this,_r,(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==null?void 0:o[a],d=o==null?void 0: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&&L(this,Vt).call(this,"text",void 0,i);const c=r();return s.length&&L(this,Vt).call(this,"text",void 0,s),c}),G(this,hn,(t=!1)=>{const r=this.close(),i=()=>L(this,Vt).call(this,r.type,r.children,r.value,r.props);return t?L(this,_r).call(this,r,i):i()}),this.closeNode=()=>(L(this,hn).call(this),this),G(this,Vt,(t,r,i,s)=>{const o=ml.create(t,r,i,s),l=L(this,Un).call(this,L(this,Vr).call(this,o));return this.push(l),l}),this.addNode=(t,r,i,s)=>(L(this,Vt).call(this,t,r,i,s),this),G(this,$r,(t,r,i,s)=>t.isInSet(L(this,nt))?this:(G(this,nt,t.addToSet(L(this,nt))),this.openNode(r,i,{...s,isMark:!0}))),G(this,Yn,t=>{t.isInSet(L(this,nt))&&(G(this,nt,t.type.removeFromSet(L(this,nt))),L(this,hn).call(this,!0))}),this.withMark=(t,r,i,s)=>(L(this,$r).call(this,t,r,i,s),this),this.closeMark=t=>(L(this,Yn).call(this,t),this),this.build=()=>{let t=null;do t=L(this,hn).call(this);while(this.size());return t},this.next=t=>Xp(t)?(t.forEach(r=>{L(this,Kn).call(this,r)}),this):(L(this,Kn).call(this,t),this),this.toString=t=>t.stringify(this.build()),this.run=t=>(this.next(t),this),this.schema=e}};nt=new WeakMap;Hn=new WeakMap;Br=new WeakMap;vr=new WeakMap;Kn=new WeakMap;Lr=new WeakMap;Un=new WeakMap;Vr=new WeakMap;_r=new WeakMap;hn=new WeakMap;Vt=new WeakMap;$r=new WeakMap;Yn=new WeakMap;Is.create=(n,e)=>{const t=new Is(n);return r=>(t.run(r),t.toString(e))};let Zp=Is;const cu=65535,hu=Math.pow(2,16);function em(n,e){return n+e*hu}function gl(n){return n&cu}function tm(n){return(n-(n&cu))/hu}const fu=1,du=2,qr=4,pu=8;class As{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&pu)>0}get deletedBefore(){return(this.delInfo&(fu|qr))>0}get deletedAfter(){return(this.delInfo&(du|qr))>0}get deletedAcross(){return(this.delInfo&qr)>0}}class Te{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&Te.empty)return Te.empty}recover(e){let t=0,r=gl(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+tm(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:em(l/3,e-a),y=e==a?du:e==h?fu:qr;return(t<0?e!=a:e!=h)&&(y|=pu),new As(f,y,p)}i+=c-u}return r?e+i:new As(e+i,0,null)}touches(e,t){let r=0,i=gl(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 Te(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Te.empty:new Te(e<0?[0,-e,0]:[0,0,e])}}Te.empty=new Te([]);class ii{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 ii(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 ii;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 As(e,i,null)}}const Fi=Object.create(null);class fe{getMap(){return Te.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Fi[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 Fi)throw new RangeError("Duplicate use of step JSON ID "+e);return Fi[e]=t,t.prototype.jsonID=e,t}}class te{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new te(e,null)}static fail(e){return new te(null,e)}static fromReplace(e,t,r,i){try{return te.ok(e.replace(t,r,i))}catch(s){if(s instanceof Zr)return te.fail(s.message);throw s}}}function oo(n,e,t){let r=[];for(let i=0;i<n.childCount;i++){let s=n.child(i);s.content.size&&(s=s.copy(oo(s.content,e,s))),s.isInline&&(s=e(s,t,i)),r.push(s)}return T.fromArray(r)}class Tt extends fe{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 O(oo(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 te.fromReplace(e,this.from,this.to,s)}invert(){return new Ke(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 Tt(t.pos,r.pos,this.mark)}merge(e){return e instanceof Tt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Tt(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 Tt(t.from,t.to,e.markFromJSON(t.mark))}}fe.jsonID("addMark",Tt);class Ke extends fe{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 O(oo(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return te.fromReplace(e,this.from,this.to,r)}invert(){return new Tt(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 Ke(t.pos,r.pos,this.mark)}merge(e){return e instanceof Ke&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ke(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 Ke(t.from,t.to,e.markFromJSON(t.mark))}}fe.jsonID("removeMark",Ke);class Mt extends fe{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return te.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return te.fromReplace(e,this.pos,this.pos+1,new O(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 Mt(this.pos,t.marks[i]);return new Mt(this.pos,this.mark)}}return new tn(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Mt(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 Mt(t.pos,e.markFromJSON(t.mark))}}fe.jsonID("addNodeMark",Mt);class tn extends fe{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return te.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return te.fromReplace(e,this.pos,this.pos+1,new O(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 Mt(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new tn(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 tn(t.pos,e.markFromJSON(t.mark))}}fe.jsonID("removeNodeMark",tn);class oe extends fe{constructor(e,t,r,i=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=i}apply(e){return this.structure&&Ds(e,this.from,this.to)?te.fail("Structure replace would overwrite content"):te.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Te([this.from,this.to-this.from,this.slice.size])}invert(e){return new oe(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 oe(t.pos,Math.max(t.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof oe)||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?O.empty:new O(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new oe(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?O.empty:new O(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new oe(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 oe(t.from,t.to,O.fromJSON(e,t.slice),!!t.structure)}}fe.jsonID("replace",oe);class Me extends fe{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&&(Ds(e,this.from,this.gapFrom)||Ds(e,this.gapTo,this.to)))return te.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return te.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?te.fromReplace(e,this.from,this.to,r):te.fail("Content does not fit in gap")}getMap(){return new Te([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 Me(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 Me(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 Me(t.from,t.to,t.gapFrom,t.gapTo,O.fromJSON(e,t.slice),t.insert,!!t.structure)}}fe.jsonID("replaceAround",Me);function Ds(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 nm(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 Ke(d,f,h[y])));l&&l.to==d?l.to=f:s.push(l=new Tt(d,f,r))}}),i.forEach(a=>n.step(a)),s.forEach(a=>n.step(a))}function rm(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 di){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 Ke(o.from,o.to,o.style)))}function lo(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 oe(l,c,O.empty));else{r=h;for(let d=0;d<u.marks.length;d++)t.allowsMarkType(u.marks[d].type)||n.step(new Ke(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 O(T.from(t.schema.text(" ",t.allowedMarks(u.marks))),0,0)),o.push(new oe(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 O(a,0,0))}for(let a=o.length-1;a>=0;a--)n.step(o[a])}function im(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function ao(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth;;--r){let i=n.$from.node(r),s=n.$from.index(r),o=n.$to.indexAfter(r);if(r<n.depth&&i.canReplace(s,o,t))return r;if(r==0||i.type.spec.isolating||!im(i,s,o))break}return null}function sm(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 Me(a,u,o,l,new O(c.append(d),h,f),c.size-h,!0))}function mu(n,e,t=null,r=n){let i=om(n,e),s=i&&lm(r,e);return s?i.map(yl).concat({type:e,attrs:t}).concat(s.map(yl)):null}function yl(n){return{type:n,attrs:null}}function om(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 lm(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 am(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 Me(i,s,i,s,new O(r,0,0),t.length,!0))}function um(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)&&cm(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&&yu(n,o,l,s),lo(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 Me(h,d,h+1,d-1,new O(T.from(r.create(a,null,o.marks)),0,0),1,!0)),u===!0&&gu(n,o,l,s),!1}})}function gu(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 yu(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 cm(n,e,t){let r=n.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,t)}function hm(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 Me(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new O(T.from(o),0,0),1,!0))}function Wr(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 fm(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 oe(e,e,new O(s.append(o),t,t),!0))}function uo(n,e){let t=n.resolve(e),r=t.index();return pm(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function dm(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 pm(n,e){return!!(n&&e&&!n.isLeaf&&dm(n,e))}function mm(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);yu(n,c.node(),c.before(),l)}o.inlineContent&&lo(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 oe(u,a.map(e+t,-1),O.empty,!0)),r===!0){let c=n.doc.resolve(u);gu(n,c.node(),c.before(),n.steps.length)}return n}function gm(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 ym(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 gi(n,e,t=e,r=O.empty){if(e==t&&!r.size)return null;let i=n.resolve(e),s=n.resolve(t);return ku(i,s,r)?new oe(e,t,r):new km(i,s,r).fit()}function ku(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class km{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 O(s,o,l);return e>-1?new Me(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new oe(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=Bi(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=Bi(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new O(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=Bi(e,t);if(i.childCount<=1&&t>0){let s=e.size-t<=t+i.size;this.unplaced=new O(Qn(e,t-1,1),t-1,s?t-1:r)}else this.unplaced=new O(Qn(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(xu(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?O.empty:new O(Qn(o.content,e-1,1),e-1,f<0?o.openEnd:e-1):new O(Qn(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||!vi(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=vi(e,t,i,r,s);if(o){for(let l=t-1;l>=0;l--){let{match:a,type:u}=this.frontier[l],c=vi(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 Qn(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Qn(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 Bi(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function xu(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,xu(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 vi(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&&!xm(t,s.content,o)?l:null}function xm(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function bm(n){return n.spec.defining||n.spec.definingForContent}function Sm(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let i=n.doc.resolve(e),s=n.doc.resolve(t);if(ku(i,s,r))return n.step(new oe(e,t,r));let o=Su(i,n.doc.resolve(t));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=bm(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 D=i.node(x-1),M=i.index(x-1);if(D.canReplaceWith(M,M,p.type,p.marks))return n.replace(i.before(x),k?s.after(x):t,new O(bu(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 bu(n,e,t,r,i){if(e<t){let s=n.firstChild;n=n.replaceChild(0,s.copy(bu(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 wm(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=gm(n.doc,e,r.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new O(T.from(r),0,0))}function Cm(n,e,t){let r=n.doc.resolve(e),i=n.doc.resolve(t),s=Su(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 Su(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 gn extends fe{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 te.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 te.fromReplace(e,this.pos,this.pos+1,new O(T.from(i),0,t.isLeaf?0:1))}getMap(){return Te.empty}invert(e){return new gn(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 gn(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 gn(t.pos,t.attr,t.value)}}fe.jsonID("attr",gn);class ar extends fe{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 te.ok(r)}getMap(){return Te.empty}invert(e){return new ar(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 ar(t.attr,t.value)}}fe.jsonID("docAttr",ar);let zn=class extends Error{};zn=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};zn.prototype=Object.create(Error.prototype);zn.prototype.constructor=zn;zn.prototype.name="TransformError";class Tm{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new ii}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new zn(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}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=O.empty){let i=gi(this.doc,e,t,r);return i&&this.step(i),this}replaceWith(e,t,r){return this.replace(e,t,new O(T.from(r),0,0))}delete(e,t){return this.replace(e,t,O.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return Sm(this,e,t,r),this}replaceRangeWith(e,t,r){return wm(this,e,t,r),this}deleteRange(e,t){return Cm(this,e,t),this}lift(e,t){return sm(this,e,t),this}join(e,t=1){return mm(this,e,t),this}wrap(e,t){return am(this,e,t),this}setBlockType(e,t=e,r,i=null){return um(this,e,t,r,i),this}setNodeMarkup(e,t,r=null,i){return hm(this,e,t,r,i),this}setNodeAttribute(e,t,r){return this.step(new gn(e,t,r)),this}setDocAttribute(e,t){return this.step(new ar(e,t)),this}addNodeMark(e,t){return this.step(new Mt(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 q)t.isInSet(r.marks)&&this.step(new tn(e,t));else{let i=r.marks,s,o=[];for(;s=t.isInSet(i);)o.push(new tn(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 fm(this,e,t,r),this}addMark(e,t,r){return nm(this,e,t,r),this}removeMark(e,t,r){return rm(this,e,t,r),this}clearIncompatible(e,t,r){return lo(this,e,t,r),this}}const Li=Object.create(null);class K{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new Mm(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=O.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?O.empty:t),l==0&&bl(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),bl(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let i=e.parent.inlineContent?new U(e):fn(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?fn(e.node(0),e.node(s),e.before(s+1),e.index(s),t,r):fn(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 Oe(e.node(0))}static atStart(e){return fn(e,e,0,0,1)||new Oe(e)}static atEnd(e){return fn(e,e,e.content.size,e.childCount,-1)||new Oe(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Li[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 Li)throw new RangeError("Duplicate use of selection JSON ID "+e);return Li[e]=t,t.prototype.jsonID=e,t}getBookmark(){return U.between(this.$anchor,this.$head).getBookmark()}}K.prototype.visible=!0;class Mm{constructor(e,t){this.$from=e,this.$to=t}}let kl=!1;function xl(n){!kl&&!n.parent.inlineContent&&(kl=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class U extends K{constructor(e,t=e){xl(e),xl(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 K.near(r);let i=e.resolve(t.map(this.anchor));return new U(i.parent.inlineContent?i:r,r)}replace(e,t=O.empty){if(super.replace(e,t),t==O.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof U&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new yi(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 U(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=K.findFrom(t,r,!0)||K.findFrom(t,-r,!0);if(s)t=s.$head;else return K.near(t,r)}return e.parent.inlineContent||(i==0?e=t:(e=(K.findFrom(e,-r,!0)||K.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=i<0&&(e=t))),new U(e,t)}}K.jsonID("text",U);class yi{constructor(e,t){this.anchor=e,this.head=t}map(e){return new yi(e.map(this.anchor),e.map(this.head))}resolve(e){return U.between(e.resolve(this.anchor),e.resolve(this.head))}}class P extends K{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?K.near(s):new P(s)}content(){return new O(T.from(this.node),0,0)}eq(e){return e instanceof P&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new co(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new P(e.resolve(t.anchor))}static create(e,t){return new P(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}P.prototype.visible=!1;K.jsonID("node",P);class co{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new yi(r,r):new co(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&P.isSelectable(r)?new P(t):K.near(t)}}class Oe extends K{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=O.empty){if(t==O.empty){e.delete(0,e.doc.content.size);let r=K.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new Oe(e)}map(e){return new Oe(e)}eq(e){return e instanceof Oe}getBookmark(){return Om}}K.jsonID("all",Oe);const Om={map(){return this},resolve(n){return new Oe(n)}};function fn(n,e,t,r,i,s=!1){if(e.inlineContent)return U.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&&P.isSelectable(l))return P.create(n,t-(i<0?l.nodeSize:0))}else{let a=fn(n,l,t+i,i<0?l.childCount:0,i,s);if(a)return a}t+=l.nodeSize*i}return null}function bl(n,e,t){let r=n.steps.length-1;if(r<e)return;let i=n.steps[r];if(!(i instanceof oe||i instanceof Me))return;let s=n.mapping.maps[r],o;s.forEach((l,a,u,c)=>{o==null&&(o=c)}),n.setSelection(K.near(n.doc.resolve(o),t))}const Sl=1,wl=2,Cl=4;class Nm extends Tm{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|Sl)&-3,this.storedMarks=null,this}get selectionSet(){return(this.updated&Sl)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=wl,this}ensureMarks(e){return q.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&wl)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&-3,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)||q.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),r=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.setSelection(K.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|=Cl,this}get scrolledIntoView(){return(this.updated&Cl)>0}}function Tl(n,e){return!e||!n?n:n.bind(e)}class Xn{constructor(e,t,r){this.name=e,this.init=Tl(t.init,r),this.apply=Tl(t.apply,r)}}const Em=[new Xn("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Xn("selection",{init(n,e){return n.selection||K.atStart(e.doc)},apply(n){return n.selection}}),new Xn("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new Xn("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class Vi{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Em.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 Xn(r.key,r.spec.state,r))})}}class pn{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 pn(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 Nm(this)}static create(e){let t=new Vi(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new pn(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 Vi(this.schema,e.plugins),r=t.fields,i=new pn(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 Vi(e.schema,e.plugins),s=new pn(i);return i.fields.forEach(o=>{if(o.name=="doc")s.doc=qe.fromJSON(e.schema,t.doc);else if(o.name=="selection")s.selection=K.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 wu(n,e,t){for(let r in n){let i=n[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=wu(i,e,{})),t[r]=i}return t}class ki{constructor(e){this.spec=e,this.props={},e.props&&wu(e.props,this,this.props),this.key=e.key?e.key.key:Cu("plugin")}getState(e){return e[this.key]}}const _i=Object.create(null);function Cu(n){return n in _i?n+"$"+ ++_i[n]:(_i[n]=0,n+"$")}class ho{constructor(e="key"){this.key=Cu(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const fo=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function Tu(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const Im=(n,e,t)=>{let r=Tu(n,t);if(!r)return!1;let i=po(r);if(!i){let o=r.blockRange(),l=o&&ao(o);return l==null?!1:(e&&e(n.tr.lift(o,l).scrollIntoView()),!0)}let s=i.nodeBefore;if(Nu(n,i,e,-1))return!0;if(r.parent.content.size==0&&(Rn(s,"end")||P.isSelectable(s)))for(let o=r.depth;;o--){let l=gi(n.doc,r.before(o),r.after(o),O.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(Rn(s,"end")?K.findFrom(a.doc.resolve(a.mapping.map(i.pos,-1)),-1):P.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},Am=(n,e,t)=>{let r=Tu(n,t);if(!r)return!1;let i=po(r);return i?Dm(n,i,e):!1};function Dm(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=gi(n.doc,s,a,O.empty);if(!u||u.from!=s||u instanceof oe&&u.slice.size>=a-s)return!1;if(t){let c=n.tr.step(u);c.setSelection(U.create(c.doc,s)),t(c.scrollIntoView())}return!0}function Rn(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 Mu=(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=po(r)}let o=s&&s.nodeBefore;return!o||!P.isSelectable(o)?!1:(e&&e(n.tr.setSelection(P.create(n.doc,s.pos-o.nodeSize)).scrollIntoView()),!0)};function po(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 zm(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const Rm=(n,e,t)=>{let r=zm(n,t);if(!r)return!1;let i=Ou(r);if(!i)return!1;let s=i.nodeAfter;if(Nu(n,i,e,1))return!0;if(r.parent.content.size==0&&(Rn(s,"start")||P.isSelectable(s))){let o=gi(n.doc,r.before(),r.after(),O.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=n.tr.step(o);l.setSelection(Rn(s,"start")?K.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):P.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},Pm=(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=Ou(r)}let o=s&&s.nodeAfter;return!o||!P.isSelectable(o)?!1:(e&&e(n.tr.setSelection(P.create(n.doc,s.pos)).scrollIntoView()),!0)};function Ou(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 Fm=(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 mo(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 Bm=(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=mo(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(K.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},vm=(n,e)=>{let t=n.selection,{$from:r,$to:i}=t;if(t instanceof Oe||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=mo(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(U.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},Lm=(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(Wr(n.doc,s))return e&&e(n.tr.split(s).scrollIntoView()),!0}let r=t.blockRange(),i=r&&ao(r);return i==null?!1:(e&&e(n.tr.lift(r,i).scrollIntoView()),!0)};function Vm(n){return(e,t)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof P&&e.selection.node.isBlock)return!r.parentOffset||!Wr(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=mo(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 U||e.selection instanceof Oe)&&c.deleteSelection();let h=c.mapping.map(r.pos),d=Wr(c.doc,h,s.length,s);if(d||(s[0]=l?{type:l}:null,d=Wr(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 _m=Vm(),$m=(n,e)=>(e&&e(n.tr.setSelection(new Oe(n.doc))),!0);function qm(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||uo(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function Nu(n,e,t,r){let i=e.nodeBefore,s=e.nodeAfter,o,l,a=i.type.spec.isolating||s.type.spec.isolating;if(!a&&qm(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 Me(e.pos-1,f,e.pos,f,new O(p,1,0),o.length,!0)),x=y.doc.resolve(f+2*o.length);x.nodeAfter&&x.nodeAfter.type==i.type&&uo(y.doc,x.pos)&&y.join(x.pos),t(y.scrollIntoView())}return!0}let c=s.type.spec.isolating||r>0&&a?null:K.findFrom(e,1),h=c&&c.$from.blockRange(c.$to),d=h&&ao(h);if(d!=null&&d>=e.depth)return t&&t(n.tr.lift(h,d).scrollIntoView()),!0;if(u&&Rn(s,"start",!0)&&Rn(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 M=p.length-1;M>=0;M--)k=T.from(p[M].copy(k));let D=n.tr.step(new Me(e.pos-p.length,e.pos+s.nodeSize,e.pos+x,e.pos+s.nodeSize-x,new O(k,p.length,0),0,!0));t(D.scrollIntoView())}return!0}}return!1}function Eu(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(U.create(e.doc,n<0?i.start(s):i.end(s)))),!0):!1}}const Wm=Eu(-1),jm=Eu(1);function ck(n,e=null){return function(t,r){let{$from:i,$to:s}=t.selection,o=i.blockRange(s),l=o&&mu(o,n,e);return l?(r&&r(t.tr.wrap(o,l).scrollIntoView()),!0):!1}}function hk(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 Jm(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 fk(n,e=null,t){return function(r,i){let{empty:s,$cursor:o,ranges:l}=r.selection;if(s&&!o||!Jm(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,D=x&&x.isText?/\s*$/.exec(x.text)[0].length:0;f+k<p&&(f+=k,p-=D),u.addMark(f,p,n.create(e))}}i(u.scrollIntoView())}return!0}}function vn(...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 $i=vn(fo,Im,Mu),Ml=vn(fo,Rm,Pm);const it={Enter:vn(Fm,vm,Lm,_m),"Mod-Enter":Bm,Backspace:$i,"Mod-Backspace":$i,"Shift-Backspace":$i,Delete:Ml,"Mod-Delete":Ml,"Mod-a":$m},Iu={"Ctrl-h":it.Backspace,"Alt-Backspace":it["Mod-Backspace"],"Ctrl-d":it.Delete,"Ctrl-Alt-Backspace":it["Mod-Delete"],"Alt-Delete":it["Mod-Delete"],"Alt-d":it["Mod-Delete"],"Ctrl-a":Wm,"Ctrl-e":jm};for(let n in it)Iu[n]=it[n];const Hm=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,Km=Hm?Iu:it;class mt{constructor(e,t,r={}){this.match=e,this.match=e,this.handler=typeof t=="string"?Um(t):t,this.undoable=r.undoable!==!1,this.inCode=r.inCode||!1,this.inCodeMark=r.inCodeMark!==!1}}function Um(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 Ym=(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 mt(/--$/,"—",{inCodeMark:!1});new mt(/\.\.\.$/,"…",{inCodeMark:!1});new mt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“",{inCodeMark:!1});new mt(/"$/,"”",{inCodeMark:!1});new mt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘",{inCodeMark:!1});new mt(/'$/,"’",{inCodeMark:!1});function dk(n,e,t=null,r){return new mt(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&&mu(h,e,a);if(!d)return null;u.wrap(h,d);let f=u.doc.resolve(o-1).nodeBefore;return f&&f.type==e&&uo(u.doc,o-1)&&(!r||r(s,f))&&u.join(o-1),u})}function pk(n,e,t=null){return new mt(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 Dt=typeof navigator<"u"?navigator:null,Ol=typeof document<"u"?document:null,sn=Dt&&Dt.userAgent||"",zs=/Edge\/(\d+)/.exec(sn),Au=/MSIE \d/.exec(sn),Rs=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(sn),go=!!(Au||Rs||zs);Au?document.documentMode:Rs?+Rs[1]:zs&&+zs[1];const Qm=!go&&/gecko\/(\d+)/i.test(sn);Qm&&+(/Firefox\/(\d+)/.exec(sn)||[0,0])[1];const Nl=!go&&/Chrome\/(\d+)/.exec(sn);Nl&&+Nl[1];const Gm=!go&&!!Dt&&/Apple Computer/.test(Dt.vendor),Xm=Gm&&(/Mobile\/\w+/.test(sn)||!!Dt&&Dt.maxTouchPoints>2);Xm||Dt&&/Mac/.test(Dt.platform);const Zm=!!Ol&&"webkitFontSmoothing"in Ol.documentElement.style;Zm&&+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1];function qi(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 eg=new ho("MILKDOWN_CUSTOM_INPUTRULES");function tg({rules:n}){const e=new ki({key:eg,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 qi(t,r,i,s,n,e)},handleDOMEvents:{compositionend:t=>(setTimeout(()=>{const{$cursor:r}=t.state.selection;r&&qi(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?qi(t,i.pos,i.pos,`
40
- `,n,e):!1}}});return e}function mk(n,e,t={}){return new mt(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},D=(l=t.updateCaptured)==null?void 0:l.call(t,k);if(Object.assign(k,D),{group:f,fullMatch:p,start:s,end:o}=k,p===null||(f==null?void 0:f.trim())==="")return null;if(f){const M=p.search(/\S/),V=s+p.indexOf(f),$=V+f.length;y=(a=h.storedMarks)!=null?a:[],$<o&&h.delete($,o),V>s&&h.delete(s+M,V),x=s+M+f.length;const w=(u=t.getAttr)==null?void 0:u.call(t,i);h.addMark(s,x,e.create(w)),h.setStoredMarks(y),(c=t.beforeDispatch)==null||c.call(t,{match:i,start:s,end:o,tr:h})}return h})}function ng(n,e){return Array.isArray(n)&&n.includes(e.type)||e.type===n}function gk(n,e){if(!(n instanceof P))return;const{node:t,$from:r}=n;if(ng(e,t))return{node:t,pos:r.pos,start:r.start(r.depth),depth:r.depth}}const yk=(n,e)=>{const{selection:t,doc:r}=n;if(t instanceof P)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 zt={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:"'"},si={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},rg=typeof navigator<"u"&&/Mac/.test(navigator.platform),ig=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var le=0;le<10;le++)zt[48+le]=zt[96+le]=String(le);for(var le=1;le<=24;le++)zt[le+111]="F"+le;for(var le=65;le<=90;le++)zt[le]=String.fromCharCode(le+32),si[le]=String.fromCharCode(le);for(var Wi in zt)si.hasOwnProperty(Wi)||(si[Wi]=zt[Wi]);function sg(n){var e=rg&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||ig&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?si:zt)[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 og=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),lg=typeof navigator<"u"&&/Win/.test(navigator.platform);function ag(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))og?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 ug(n){let e=Object.create(null);for(let t in n)e[ag(t)]=n[t];return e}function ji(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 cg(n){return new ki({props:{handleKeyDown:hg(n)}})}function hg(n){let e=ug(n);return function(t,r){let i=sg(r),s,o=e[ji(i,r)];if(o&&o(t.state,t.dispatch,t))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let l=e[ji(i,r,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(lg&&r.ctrlKey&&r.altKey)&&(s=zt[r.keyCode])&&s!=i){let l=e[ji(s,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}const ae=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Pn=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let Ps=null;const rt=function(n,e,t){let r=Ps||(Ps=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},fg=function(){Ps=null},nn=function(n,e,t,r){return t&&(El(n,e,t,r,-1)||El(n,e,t,r,1))},dg=/^(img|br|input|textarea|hr)$/i;function El(n,e,t,r,i){for(var s;;){if(n==t&&e==r)return!0;if(e==(i<0?0:ze(n))){let o=n.parentNode;if(!o||o.nodeType!=1||Cr(n)||dg.test(n.nodeName)||n.contentEditable=="false")return!1;e=ae(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?ze(n):0}else return!1}}function ze(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function pg(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=ze(n)}else if(n.parentNode&&!Cr(n))e=ae(n),n=n.parentNode;else return null}}function mg(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&&!Cr(n))e=ae(n)+1,n=n.parentNode;else return null}}function gg(n,e,t){for(let r=e==0,i=e==ze(n);r||i;){if(n==t)return!0;let s=ae(n);if(n=n.parentNode,!n)return!1;r=r&&s==0,i=i&&s==ze(n)}}function Cr(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 xi=function(n){return n.focusNode&&nn(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function _t(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function yg(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function kg(n,e,t){if(n.caretPositionFromPoint)try{let r=n.caretPositionFromPoint(e,t);if(r)return{node:r.offsetNode,offset:Math.min(ze(r.offsetNode),r.offset)}}catch{}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);if(r)return{node:r.startContainer,offset:Math.min(ze(r.startContainer),r.startOffset)}}}const Ye=typeof navigator<"u"?navigator:null,Il=typeof document<"u"?document:null,Pt=Ye&&Ye.userAgent||"",Fs=/Edge\/(\d+)/.exec(Pt),Du=/MSIE \d/.exec(Pt),Bs=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Pt),be=!!(Du||Bs||Fs),Nt=Du?document.documentMode:Bs?+Bs[1]:Fs?+Fs[1]:0,We=!be&&/gecko\/(\d+)/i.test(Pt);We&&+(/Firefox\/(\d+)/.exec(Pt)||[0,0])[1];const vs=!be&&/Chrome\/(\d+)/.exec(Pt),he=!!vs,zu=vs?+vs[1]:0,de=!be&&!!Ye&&/Apple Computer/.test(Ye.vendor),Fn=de&&(/Mobile\/\w+/.test(Pt)||!!Ye&&Ye.maxTouchPoints>2),Ae=Fn||(Ye?/Mac/.test(Ye.platform):!1),xg=Ye?/Win/.test(Ye.platform):!1,ht=/Android \d/.test(Pt),Tr=!!Il&&"webkitFontSmoothing"in Il.documentElement.style,bg=Tr?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Sg(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 tt(n,e){return typeof n=="number"?n:n[e]}function wg(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 Al(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=Pn(o);continue}let l=o,a=l==s.body,u=a?Sg(s):wg(l),c=0,h=0;if(e.top<u.top+tt(r,"top")?h=-(u.top-e.top+tt(i,"top")):e.bottom>u.bottom-tt(r,"bottom")&&(h=e.bottom-e.top>u.bottom-u.top?e.top+tt(i,"top")-u.top:e.bottom-u.bottom+tt(i,"bottom")),e.left<u.left+tt(r,"left")?c=-(u.left-e.left+tt(i,"left")):e.right>u.right-tt(r,"right")&&(c=e.right-u.right+tt(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:Pn(o)}}function Cg(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:Ru(n.dom)}}function Ru(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=Pn(r));return e}function Tg({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;Pu(t,r==0?0:r-e)}function Pu(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 un=null;function Mg(n){if(n.setActive)return n.setActive();if(un)return n.focus(un);let e=Ru(n);n.focus(un==null?{get preventScroll(){return un={preventScroll:!0},!0}}:void 0),un||(un=!1,Pu(e,0))}function Fu(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=rt(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?Og(t,i):!t||r&&t.nodeType==1?{node:n,offset:s}:Fu(t,i)}function Og(n,e){let t=n.nodeValue.length,r=document.createRange();for(let i=0;i<t;i++){r.setEnd(n,i+1),r.setStart(n,i);let s=kt(r,1);if(s.top!=s.bottom&&yo(e,s))return{node:n,offset:i+(e.left>=(s.left+s.right)/2?1:0)}}return{node:n,offset:0}}function yo(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function Ng(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function Eg(n,e,t){let{node:r,offset:i}=Fu(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 Ig(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 Bu(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(yo(e,u))return Bu(o,e,u)}}if((s=(s+1)%r)==i)break}return n}function Ag(n,e){let t=n.dom.ownerDocument,r,i=0,s=kg(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(!yo(e,u)||(o=Bu(n.dom,e,u),!o))return null}if(de)for(let u=o;r&&u;u=Pn(u))u.draggable&&(r=void 0);if(o=Ng(o,e),r){if(We&&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;Tr&&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=Ig(n,r,i,e))}l==null&&(l=Eg(n,o,e));let a=n.docView.nearestDesc(o,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Dl(n){return n.top<n.bottom||n.left<n.right}function kt(n,e){let t=n.getClientRects();if(t.length){let r=t[e<0?0:t.length-1];if(Dl(r))return r}return Array.prototype.find.call(t,Dl)||n.getBoundingClientRect()}const Dg=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function vu(n,e,t){let{node:r,offset:i,atom:s}=n.docView.domFromPos(e,t<0?-1:1),o=Tr||We;if(r.nodeType==3)if(o&&(Dg.test(r.nodeValue)||(t<0?!i:i==r.nodeValue.length))){let a=kt(rt(r,i,i),t);if(We&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let u=kt(rt(r,i-1,i-1),-1);if(u.top==a.top){let c=kt(rt(r,i,i+1),-1);if(c.top!=a.top)return qn(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++,qn(kt(rt(r,a,u),c),c<0)}if(!n.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&i&&(t<0||i==ze(r))){let a=r.childNodes[i-1];if(a.nodeType==1)return Ji(a.getBoundingClientRect(),!1)}if(s==null&&i<ze(r)){let a=r.childNodes[i];if(a.nodeType==1)return Ji(a.getBoundingClientRect(),!0)}return Ji(r.getBoundingClientRect(),t>=0)}if(s==null&&i&&(t<0||i==ze(r))){let a=r.childNodes[i-1],u=a.nodeType==3?rt(a,ze(a)-(o?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(u)return qn(kt(u,1),!1)}if(s==null&&i<ze(r)){let a=r.childNodes[i];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let u=a?a.nodeType==3?rt(a,0,o?0:1):a.nodeType==1?a:null:null;if(u)return qn(kt(u,-1),!0)}return qn(kt(r.nodeType==3?rt(r):r,-t),t>=0)}function qn(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 Ji(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 Lu(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 zg(n,e,t){let r=e.selection,i=t=="up"?r.$from:r.$to;return Lu(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=vu(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=rt(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 Rg=/[\u0590-\u08ac]/;function Pg(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?!Rg.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?s:o:Lu(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 zl=null,Rl=null,Pl=!1;function Fg(n,e,t){return zl==e&&Rl==t?Pl:(zl=e,Rl=t,Pl=t=="up"||t=="down"?zg(n,e,t):Pg(n,e,t))}const Re=0,Fl=1,$t=2,Qe=3;class Mr{constructor(e,t,r,i){this.parent=e,this.children=t,this.dom=r,this.contentDOM=i,this.dirty=Re,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>ae(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 _u){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 Vu&&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?ae(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?ae(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=ae(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=ae(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((We||de)&&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:ae(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(We&&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&&de)&&nn(l.node,l.offset,c.anchorNode,c.anchorOffset)&&nn(a.node,a.offset,c.focusNode,c.focusOffset))return;let d=!1;if((u.extend||e==t)&&!h){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?$t:Fl,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?$t:Qe}r=o}this.dirty=$t}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?$t:Fl;t.dirty<r&&(t.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class Vu extends Mr{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==Re&&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 Bg extends Mr{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 rn extends Mr{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=Bn.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new rn(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!=Re){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Re}}slice(e,t,r){let i=rn.create(this.parent,this.mark,!0,r),s=this.children,o=this.size;t<o&&(s=Vs(s,t,o,r)),e>0&&(s=Vs(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 Et extends Mr{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}=Bn.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=Wu(c,r,t),u?a=new vg(e,t,r,i,c,h||null,d,u,s,o+1):t.isText?new bi(e,t,r,i,c,d,s):new Et(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==Re&&e.eq(this.node)&&oi(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 Vg(this,o&&o.node,e);qg(this.node,this.innerDeco,(u,c,h)=>{u.spec.marks?a.syncToMarks(u.spec.marks,r,e):u.type.side>=0&&!h&&a.syncToMarks(c==this.node.childCount?q.none:this.node.child(c).marks,r,e),a.placeWidget(u,e,i)},(u,c,h,d)=>{a.syncToMarks(u.marks,r,e);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),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==$t)&&(o&&this.protectLocalComposition(e,o),$u(this.contentDOM,this.children,e),Fn&&Wg(this.dom))}localCompositionInfo(e,t){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof U)||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=jg(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 Bg(this,s,t,i);e.input.compositionNodes.push(o),this.children=Vs(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=Re}updateOuterDeco(e){if(oi(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=qu(this.dom,this.nodeDOM,Ls(this.outerDeco,this.node,t),Ls(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.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function Bl(n,e,t,r,i){Wu(r,e,n);let s=new Et(void 0,n,e,t,r,r,r,i,0);return s.contentDOM&&s.updateChildren(i,0),s}class bi extends Et{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!=Re&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Re||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=Re,!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 bi(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 _u extends Mr{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Re&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class vg extends Et{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 $u(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=vl(r),i=!0;r=r.nextSibling}else i=!0,n.insertBefore(l,r);if(o instanceof rn){let a=r?r.previousSibling:n.lastChild;$u(o.contentDOM,o.children,t),r=a?a.nextSibling:n.firstChild}}for(;r;)r=vl(r),i=!0;i&&t.trackWrites==n&&(t.trackWrites=null)}const rr=function(n){n&&(this.nodeName=n)};rr.prototype=Object.create(null);const qt=[new rr];function Ls(n,e,t){if(n.length==0)return qt;let r=t?qt[0]:new rr,i=[r];for(let s=0;s<n.length;s++){let o=n[s].type.attrs;if(o){o.nodeName&&i.push(r=new rr(o.nodeName));for(let l in o){let a=o[l];a!=null&&(t&&i.length==1&&i.push(r=new rr(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 qu(n,e,t,r){if(t==qt&&r==qt)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=qt[0]),i=a}Lg(i,l||qt[0],o)}return i}function Lg(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 Wu(n,e,t){return qu(n,n,qt,Ls(e,t,n.nodeType!=1))}function oi(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 vl(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class Vg{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=_g(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){let i=0,s=this.stack.length>>1,o=Math.min(s,e.length);for(;i<o&&(i==s-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<s;)this.destroyRest(),this.top.dirty=Re,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let l=-1;for(let a=this.index;a<Math.min(this.index+3,this.top.children.length);a++){let u=this.top.children[a];if(u.matchesMark(e[s])&&!this.isLocked(u.dom)){l=a;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=rn.create(this.top,e[s],t,r);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,s++}}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=$t),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 Et){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&&oi(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=$t,h.updateChildren(i,o+1),h.dirty=Re),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)||!oi(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=Et.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=Et.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 Vu(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 rn;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof bi)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((de||he)&&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 _u(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 _g(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 rn)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 $g(n,e){return n.type.side-e.type.side}function qg(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($g);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 Wg(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 jg(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 Vs(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 ko(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(xi(t)){for(a=o;i&&!i.node;)i=i.parent;let h=i.node;if(i&&h.isAtom&&P.isSelectable(h)&&i.parent&&!(h.isInline&&gg(t.focusNode,t.focusOffset,i.dom))){let d=i.posBefore;u=new P(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=xo(n,c,l,h)}return u}function ju(n){return n.editable?n.hasFocus():Hu(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function ft(n,e=!1){let t=n.state.selection;if(Ju(n,t),!!ju(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&he){let r=n.domSelectionRange(),i=n.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&nn(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)Hg(n);else{let{anchor:r,head:i}=t,s,o;Ll&&!(t instanceof U)&&(t.$from.parent.inlineContent||(s=Vl(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(o=Vl(n,t.to))),n.docView.setSelection(r,i,n,e),Ll&&(s&&_l(s),o&&_l(o)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Jg(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const Ll=de||he&&zu<63;function Vl(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(de&&i&&i.contentEditable=="false")return Hi(i);if((!i||i.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(i)return Hi(i);if(s)return Hi(s)}}function Hi(n){return n.contentEditable="true",de&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function _l(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function Jg(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(()=>{(!ju(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Hg(n){let e=n.domSelection(),t=document.createRange();if(!e)return;let r=n.cursorWrapper.dom,i=r.nodeName=="IMG";i?t.setStart(r.parentNode,ae(r)+1):t.setStart(r,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!i&&!n.state.selection.visible&&be&&Nt<=11&&(r.disabled=!0,r.disabled=!1)}function Ju(n,e){if(e instanceof P){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&($l(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else $l(n)}function $l(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function xo(n,e,t,r){return n.someProp("createSelectionBetween",i=>i(n,e,t))||U.between(e,t,r)}function ql(n){return n.editable&&!n.hasFocus()?!1:Hu(n)}function Hu(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 Kg(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return nn(e.node,e.offset,t.anchorNode,t.anchorOffset)}function _s(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&&K.findFrom(s,e)}function xt(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function Wl(n,e,t){let r=n.state.selection;if(r instanceof U)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 xt(n,new U(r.$anchor,o))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let i=_s(n.state,e);return i&&i instanceof P?xt(n,i):!1}else if(!(Ae&&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?P.isSelectable(s)?xt(n,new P(e<0?n.state.doc.resolve(i.pos-s.nodeSize):i)):Tr?xt(n,new U(n.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof P&&r.node.isInline)return xt(n,new U(e>0?r.$to:r.$from));{let i=_s(n.state,e);return i?xt(n,i):!1}}}function li(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function ir(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function cn(n,e){return e<0?Ug(n):Yg(n)}function Ug(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i,s,o=!1;for(We&&t.nodeType==1&&r<li(t)&&ir(t.childNodes[r],-1)&&(o=!0);;)if(r>0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(ir(l,-1))i=t,s=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(Ku(t))break;{let l=t.previousSibling;for(;l&&ir(l,-1);)i=t.parentNode,s=ae(l),l=l.previousSibling;if(l)t=l,r=li(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}o?$s(n,t,r):i&&$s(n,i,s)}function Yg(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i=li(t),s,o;for(;;)if(r<i){if(t.nodeType!=1)break;let l=t.childNodes[r];if(ir(l,1))s=t,o=++r;else break}else{if(Ku(t))break;{let l=t.nextSibling;for(;l&&ir(l,1);)s=l.parentNode,o=ae(l)+1,l=l.nextSibling;if(l)t=l,r=0,i=li(t);else{if(t=t.parentNode,t==n.dom)break;r=i=0}}}s&&$s(n,s,o)}function Ku(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function Qg(n,e){for(;n&&e==n.childNodes.length&&!Cr(n);)e=ae(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 Gg(n,e){for(;n&&!e&&!Cr(n);)e=ae(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 $s(n,e,t){if(e.nodeType!=3){let s,o;(o=Qg(e,t))?(e=o,t=0):(s=Gg(e,t))&&(e=s,t=s.nodeValue.length)}let r=n.domSelection();if(!r)return;if(xi(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&&ft(n)},50)}function jl(n,e){let t=n.state.doc.resolve(e);if(!(he||xg)&&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 Jl(n,e,t){let r=n.state.selection;if(r instanceof U&&!r.empty||t.indexOf("s")>-1||Ae&&t.indexOf("m")>-1)return!1;let{$from:i,$to:s}=r;if(!i.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let o=_s(n.state,e);if(o&&o instanceof P)return xt(n,o)}if(!i.parent.inlineContent){let o=e<0?i:s,l=r instanceof Oe?K.near(o,e):K.findFrom(o,e);return l?xt(n,l):!1}return!1}function Hl(n,e){if(!(n.state.selection instanceof U))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 Kl(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function Xg(n){if(!de||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;Kl(n,r,"true"),setTimeout(()=>Kl(n,r,"false"),20)}return!1}function Zg(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function ey(n,e){let t=e.keyCode,r=Zg(e);if(t==8||Ae&&t==72&&r=="c")return Hl(n,-1)||cn(n,-1);if(t==46&&!e.shiftKey||Ae&&t==68&&r=="c")return Hl(n,1)||cn(n,1);if(t==13||t==27)return!0;if(t==37||Ae&&t==66&&r=="c"){let i=t==37?jl(n,n.state.selection.from)=="ltr"?-1:1:-1;return Wl(n,i,r)||cn(n,i)}else if(t==39||Ae&&t==70&&r=="c"){let i=t==39?jl(n,n.state.selection.from)=="ltr"?1:-1:1;return Wl(n,i,r)||cn(n,i)}else{if(t==38||Ae&&t==80&&r=="c")return Jl(n,-1,r)||cn(n,-1);if(t==40||Ae&&t==78&&r=="c")return Xg(n)||Jl(n,1,r)||cn(n,1);if(r==(Ae?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function bo(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")||Bn.fromSchema(n.state.schema),l=Zu(),a=l.createElement("div");a.appendChild(o.serializeFragment(r,{document:l}));let u=a.firstChild,c,h=0;for(;u&&u.nodeType==1&&(c=Xu[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,`
37
+ `),i;function s(o){return r.stack.push(o),l;function l(){r.stack.pop()}}}function zd(n){throw new Error("Cannot handle value `"+n+"`, expected node")}function Pd(n){const e=n;throw new Error("Cannot handle unknown node `"+e.type+"`")}function Fd(n,e){if(n.type==="definition"&&n.type===e.type)return 0}function Bd(n,e){return Td(n,this,e)}function vd(n,e){return Md(n,this,e)}function Ld(n,e){return Id(this,n,e)}function Pi(n){const e=this;e.compiler=t;function t(r){return Rd(r,{...e.data("settings"),...n,extensions:e.data("toMarkdownExtensions")||[]})}}function bo(n){if(n)throw n}var Vr,So;function Vd(){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,E=!1;for(typeof y=="boolean"&&(E=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&&(E&&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(E,p,d)})):typeof d<"u"&&o(y,{name:c,newValue:d}));return y},Vr}var _d=Vd();const _r=$u(_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 $d(){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?qd(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 qd(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:Wd,dirname:jd,extname:Jd,join:Hd,sep:"/"};function Wd(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 Jd(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 Hd(...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?".":Kd(t)}function Kd(n){zn(n);const e=n.codePointAt(0)===47;let t=Ud(n,!e);return t.length===0&&!e&&(t="."),t.length>0&&n.codePointAt(n.length-1)===47&&(t+="/"),e?"/"+t:t}function Ud(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 Yd={cwd:Qd};function Qd(){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 Gd(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 Xd(n)}function Xd(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 Zd{constructor(e){let t;e?Bi(e)?t={path:e}:typeof e=="string"||ep(e)?t={value:e}:t=e:t={},this.cwd="cwd"in t?"":Yd.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=Gd(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 ep(n){return!!(n&&typeof n=="object"&&"byteLength"in n&&"byteOffset"in n)}const tp=(function(n){const r=this.constructor.prototype,i=r[n],s=function(){return i.apply(s,arguments)};return Object.setPrototypeOf(s,r),s}),np={}.hasOwnProperty;class ks extends tp{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=$d()}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):np.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);ip(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 rp(n)?n:new Zd(n)}function rp(n){return!!(n&&typeof n=="object"&&"message"in n&&"messages"in n)}function ip(n){return typeof n=="string"||sp(n)}function sp(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 Ku(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 Hu(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 op=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 lp=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 Uu(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=>lp(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 ap=_i;const ya=65535,ka=Math.pow(2,16);function up(n,e){return n+e*ka}function Oo(n){return n&ya}function cp(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=Oo(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+cp(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:up(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=Oo(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 ue{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 ue{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))}}ue.jsonID("addMark",lt);class Ve extends ue{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))}}ue.jsonID("removeMark",Ve);class at extends ue{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))}}ue.jsonID("addNodeMark",at);class Dt extends ue{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))}}ue.jsonID("removeNodeMark",Dt);class re extends ue{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 re(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 re(t.pos,Math.max(t.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof re)||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 re(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 re(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 re(t.from,t.to,M.fromJSON(e,t.slice),!!t.structure)}}ue.jsonID("replace",re);class xe extends ue{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)}}ue.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 hp(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 fp(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 re(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 re(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 dp(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;;--r){let i=n.$from.node(r),s=n.$from.index(r),o=n.$to.indexAfter(r);if(r<n.depth&&i.canReplace(s,o,t))return r;if(r==0||i.type.spec.isolating||!dp(i,s,o))break}return null}function pp(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=mp(n,e),s=i&&gp(r,e);return s?i.map(No).concat({type:e,attrs:t}).concat(s.map(No)):null}function No(n){return{type:n,attrs:null}}function mp(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 gp(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 yp(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 kp(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)&&xp(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 xp(n,e,t){let r=n.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,t)}function bp(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 Sp(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 re(e,e,new M(s.append(o),t,t),!0))}function Cs(n,e){let t=n.resolve(e),r=t.index();return Cp(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function wp(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 Cp(n,e){return!!(n&&e&&!n.isLeaf&&wp(n,e))}function Tp(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 re(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 Mp(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 re(e,t,r):new Np(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 Np{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 re(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(Oa(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 Oa(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,Oa(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&&!Ep(t,s.content,o)?l:null}function Ep(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function Ip(n){return n.spec.defining||n.spec.definingForContent}function Ap(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 re(e,t,r));let o=Ea(i,n.doc.resolve(t));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=Ip(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 E=i.node(x-1),C=i.index(x-1);if(E.canReplaceWith(C,C,p.type,p.marks))return n.replace(i.before(x),k?s.after(x):t,new M(Na(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 Na(n,e,t,r,i){if(e<t){let s=n.firstChild;n=n.replaceChild(0,s.copy(Na(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 Dp(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=Mp(n.doc,e,r.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new M(T.from(r),0,0))}function Rp(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 ue{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)}}ue.jsonID("attr",Jt);class En extends ue{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)}}ue.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 zp{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}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 Ap(this,e,t,r),this}replaceRangeWith(e,t,r){return Dp(this,e,t,r),this}deleteRange(e,t){return Rp(this,e,t),this}lift(e,t){return pp(this,e,t),this}join(e,t=1){return Tp(this,e,t),this}wrap(e,t){return yp(this,e,t),this}setBlockType(e,t=e,r,i=null){return kp(this,e,t,r,i),this}setNodeMarkup(e,t,r=null,i){return bp(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 Sp(this,e,t,r),this}addMark(e,t,r){return hp(this,e,t,r),this}removeMark(e,t,r){return fp(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 Pp(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 Pp{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 Fp}}W.jsonID("all",be);const Fp={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 re||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 Bp extends zp{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 vp=[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=vp.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 Bp(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 Os=(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 Lp=(n,e,t)=>{let r=Da(n,t);if(!r)return!1;let i=Ns(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},Vp=(n,e,t)=>{let r=Da(n,t);if(!r)return!1;let i=Ns(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 re&&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=Ns(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 Ns(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 $p(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const qp=(n,e,t)=>{let r=$p(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},Wp=(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 Jp=(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},Hp=(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},Kp=(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 Up(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 Yp=Up(),Qp=(n,e)=>(e&&e(n.tr.setSelection(new be(n.doc))),!0);function Gp(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&&Gp(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 E=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(E.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 Xp=Fa(-1),Zp=Fa(1);function yy(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 ky(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 em(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 xy(n,e=null,t){return function(r,i){let{empty:s,$cursor:o,ranges:l}=r.selection;if(s&&!o||!em(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,E=x&&x.isText?/\s*$/.exec(x.text)[0].length:0;f+k<p&&(f+=k,p-=E),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(Os,Lp,Ra),Po=tn(Os,qp,Wp);const Ge={Enter:tn(jp,Hp,Kp,Yp),"Mod-Enter":Jp,Backspace:Zr,"Mod-Backspace":Zr,"Shift-Backspace":Zr,Delete:Po,"Mod-Delete":Po,"Mod-a":Qp},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":Xp,"Ctrl-e":Zp};for(let n in Ge)Ba[n]=Ge[n];const tm=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,nm=tm?Ba:Ge;class et{constructor(e,t,r={}){this.match=e,this.match=e,this.handler=typeof t=="string"?rm(t):t,this.undoable=r.undoable!==!1,this.inCode=r.inCode||!1,this.inCodeMark=r.inCodeMark!==!1}}function rm(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 im=(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 by(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 Sy(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 sm=!Is&&/gecko\/(\d+)/i.test(Pt);sm&&+(/Firefox\/(\d+)/.exec(Pt)||[0,0])[1];const Bo=!Is&&/Chrome\/(\d+)/.exec(Pt);Bo&&+Bo[1];const om=!Is&&!!pt&&/Apple Computer/.test(pt.vendor),lm=om&&(/Mobile\/\w+/.test(Pt)||!!pt&&pt.maxTouchPoints>2);lm||pt&&/Mac/.test(pt.platform);const am=!!Fo&&"webkitFontSmoothing"in Fo.documentElement.style;am&&+(/\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 um=new Ms("MILKDOWN_CUSTOM_INPUTRULES");function cm({rules:n}){const e=new Ar({key:um,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 wy(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},E=(l=t.updateCaptured)==null?void 0:l.call(t,k);if(Object.assign(k,E),{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 hm(n,e){return Array.isArray(n)&&n.includes(e.type)||e.type===n}function Cy(n,e){if(!(n instanceof D))return;const{node:t,$from:r}=n;if(hm(e,t))return{node:t,pos:r.pos,start:r.start(r.depth),depth:r.depth}}const Ty=(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:'"'},fm=typeof navigator<"u"&&/Mac/.test(navigator.platform),dm=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var ie=0;ie<10;ie++)mt[48+ie]=mt[96+ie]=String(ie);for(var ie=1;ie<=24;ie++)mt[ie+111]="F"+ie;for(var ie=65;ie<=90;ie++)mt[ie]=String.fromCharCode(ie+32),yr[ie]=String.fromCharCode(ie);for(var ti in mt)yr.hasOwnProperty(ti)||(yr[ti]=mt[ti]);function pm(n){var e=fm&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||dm&&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 mm=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),gm=typeof navigator<"u"&&/Win/.test(navigator.platform);function ym(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))mm?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 km(n){let e=Object.create(null);for(let t in n)e[ym(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 xm(n){return new Ar({props:{handleKeyDown:bm(n)}})}function bm(n){let e=km(n);return function(t,r){let i=pm(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)&&!(gm&&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 se=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},Sm=function(){Ji=null},Rt=function(n,e,t,r){return t&&(vo(n,e,t,r,-1)||vo(n,e,t,r,1))},wm=/^(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)||wm.test(n.nodeName)||n.contentEditable=="false")return!1;e=se(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 Cm(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=se(n),n=n.parentNode;else return null}}function Tm(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=se(n)+1,n=n.parentNode;else return null}}function Mm(n,e,t){for(let r=e==0,i=e==Te(n);r||i;){if(n==t)return!0;let s=se(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 Nm(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),ae=!!Ui,Va=Ui?+Ui[1]:0,ce=!me&&!!$e&&/Apple Computer/.test($e.vendor),Zt=ce&&(/Mobile\/\w+/.test(yt)||!!$e&&$e.maxTouchPoints>2),we=Zt||($e?/Mac/.test($e.platform):!1),Em=$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;$a(t,r==0?0:r-e)}function $a(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,$a(e,0))}function qa(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}:qa(t,i)}function Fm(n,e){let t=n.nodeValue.length,r=document.createRange();for(let i=0;i<t;i++){r.setEnd(n,i+1),r.setStart(n,i);let s=it(r,1);if(s.top!=s.bottom&&As(e,s))return{node:n,offset:i+(e.left>=(s.left+s.right)/2?1:0)}}return{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}=qa(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 Wa(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 Wa(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=Nm(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=Wa(n.dom,e,u),!o))return null}if(ce)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 Ja(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 Ja(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:Ja(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 Oe=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=Oe,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>se(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 Ka){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 Ha&&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?se(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?se(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=se(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=se(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||ce)&&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:se(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&&ce)&&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 Ha 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==Oe&&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!=Oe){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Oe}}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=Qa(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==Oe&&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):u.type.side>=0&&!h&&a.syncToMarks(c==this.node.childCount?L.none:this.node.child(c).marks,r,e),a.placeWidget(u,e,i)},(u,c,h,d)=>{a.syncToMarks(u.marks,r,e);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),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==Ct)&&(o&&this.protectLocalComposition(e,o),Ua(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=Oe}updateOuterDeco(e){if(kr(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Ya(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){Qa(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!=Oe&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Oe||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=Oe,!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 Ka extends Bn{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Oe&&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 Ua(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;Ua(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 Ya(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 Qa(n,e,t){return Ya(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){let i=0,s=this.stack.length>>1,o=Math.min(s,e.length);for(;i<o&&(i==s-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<s;)this.destroyRest(),this.top.dirty=Oe,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let l=-1;for(let a=this.index;a<Math.min(this.index+3,this.top.children.length);a++){let u=this.top.children[a];if(u.matchesMark(e[s])&&!this.isLocked(u.dom)){l=a;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=zt.create(this.top,e[s],t,r);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,s++}}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=Oe),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 Ha(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))&&((ce||ae)&&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 Ka(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&&Mm(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 Ga(n){return n.editable?n.hasFocus():Za(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function Ze(n,e=!1){let t=n.state.selection;if(Xa(n,t),!!Ga(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&ae){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=ce||ae&&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(ce&&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",ce&&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(()=>{(!Ga(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,se(t)+1):e.collapse(t,0),!r&&!n.state.selection.visible&&me&&ct<=11&&(t.disabled=!0,t.disabled=!1)}function Xa(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:Za(n)}function Za(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(eu(t))break;{let l=t.previousSibling;for(;l&&Tn(l,-1);)i=t.parentNode,s=se(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(eu(t))break;{let l=t.nextSibling;for(;l&&Tn(l,1);)s=l.parentNode,o=se(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 eu(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=se(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=se(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(!(ae||Em)&&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(!ce||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=ou(),a=l.createElement("div");a.appendChild(o.serializeFragment(r,{document:l}));let u=a.firstChild,c,h=0;for(;u&&u.nodeType==1&&(c=su[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,`
42
42
 
43
- `);return{dom:a,text:d,slice:e}}function Uu(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 e?new O(T.from(n.state.schema.text(e.replace(/\r\n?/g,`
44
- `))),0,0):O.empty;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=Bn.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=iy(t),Tr&&sy(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")||Dn.fromSchema(n.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||c),context:i,ruleFromNode(d){return d.nodeName=="BR"&&!d.nextSibling&&d.parentNode&&!ty.test(d.parentNode.nodeName)?{ignore:!0}:null}})),c)l=oy(Ul(l,+c[1],+c[2]),c[4]);else if(l=O.maxOpen(ny(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=Ul(l,h,d)}return n.someProp("transformPasted",h=>{l=h(l,n)}),l}const ty=/^(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 ny(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&&Qu(a,s,l,o[o.length-1],0))o[o.length-1]=u;else{o.length&&(o[o.length-1]=Gu(o[o.length-1],s.length));let c=Yu(l,a);o.push(c),i=i.matchType(c.type),s=a}}),o)return T.from(o)}return n}function Yu(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,T.from(n));return n}function Qu(n,e,t,r,i){if(i<n.length&&i<e.length&&n[i]==e[i]){let s=Qu(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(Yu(t,n,i+1))))}}function Gu(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,Gu(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(T.empty,!0);return n.copy(t.append(r))}function qs(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=qs(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 Ul(n,e,t){return e<n.openStart&&(n=new O(qs(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new O(qs(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const Xu={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 Yl=null;function Zu(){return Yl||(Yl=document.implementation.createHTMLDocument("title"))}let Ki=null;function ry(n){let e=window.trustedTypes;return e?(Ki||(Ki=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),Ki.createHTML(n)):n}function iy(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Zu().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),i;if((i=r&&Xu[r[1].toLowerCase()])&&(n=i.map(s=>"<"+s+">").join("")+n+i.map(s=>"</"+s+">").reverse().join("")),t.innerHTML=ry(n),i)for(let s=0;s<i.length;s++)t=t.querySelector(i[s])||t;return t}function sy(n){let e=n.querySelectorAll(he?"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 oy(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 O(i,s,o)}const pe={},me={},ly={touchstart:!0,touchmove:!0};class ay{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.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function uy(n){for(let e in pe){let t=pe[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{hy(n,r)&&!So(n,r)&&(n.editable||!(r.type in me))&&t(n,r)},ly[e]?{passive:!0}:void 0)}de&&n.dom.addEventListener("input",()=>null),Ws(n)}function Ot(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function cy(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 Ws(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>So(n,r))})}function So(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function hy(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 fy(n,e){!So(n,e)&&pe[e.type]&&(n.editable||!(e.type in me))&&pe[e.type](n,e)}me.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!tc(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(ht&&he&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),Fn&&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,_t(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||ey(n,t)?t.preventDefault():Ot(n,"key")};me.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};me.keypress=(n,e)=>{let t=e;if(tc(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||Ae&&t.metaKey)return;if(n.someProp("handleKeyPress",i=>i(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof U)||!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 Si(n){return{left:n.clientX,top:n.clientY}}function dy(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function wo(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 yn(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 py(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&P.isSelectable(r)?(yn(n,new P(t)),!0):!1}function my(n,e){if(e==-1)return!1;let t=n.state.selection,r,i;t instanceof P&&(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(P.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?(yn(n,P.create(n.state.doc,i)),!0):!1}function gy(n,e,t,r,i){return wo(n,"handleClickOn",e,t,r)||n.someProp("handleClick",s=>s(n,e,r))||(i?my(n,t):py(n,t))}function yy(n,e,t,r){return wo(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",i=>i(n,e,r))}function ky(n,e,t,r){return wo(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",i=>i(n,e,r))||xy(n,t,r)}function xy(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(yn(n,U.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)yn(n,U.create(r,l+1,l+1+o.content.size));else if(P.isSelectable(o))yn(n,P.create(r,l));else continue;return!0}}function Co(n){return ai(n)}const ec=Ae?"metaKey":"ctrlKey";pe.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=Co(n),i=Date.now(),s="singleClick";i-n.input.lastClick.time<500&&dy(t,n.input.lastClick)&&!t[ec]&&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(Si(t));o&&(s=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new by(n,o,t,!!r)):(s=="doubleClick"?yy:ky)(n,o.pos,o.inside,t)?t.preventDefault():Ot(n,"pointer"))};class by{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[ec],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.dom.nodeType==1?a.dom:null;let{selection:u}=e.state;(r.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||u instanceof P&&u.from<=o&&u.to>o)&&(this.mightDrag={node:s,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&We&&!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)),Ot(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(()=>ft(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(Si(e))),this.updateAllowDefault(e),this.allowDefault||!t?Ot(this.view,"pointer"):gy(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||de&&this.mightDrag&&!this.mightDrag.node.isAtom||he&&!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)?(yn(this.view,K.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):Ot(this.view,"pointer")}move(e){this.updateAllowDefault(e),Ot(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)}}pe.touchstart=n=>{n.input.lastTouch=Date.now(),Co(n),Ot(n,"pointer")};pe.touchmove=n=>{n.input.lastTouch=Date.now(),Ot(n,"pointer")};pe.contextmenu=n=>Co(n);function tc(n,e){return n.composing?!0:de&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const Sy=ht?5e3:-1;me.compositionstart=me.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof U&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),ai(n,!0),n.markCursor=null;else if(ai(n,!e.selection.empty),We&&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}nc(n,Sy)};me.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.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,nc(n,20))};function nc(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>ai(n),e))}function rc(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Cy());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function wy(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=pg(e.focusNode,e.focusOffset),r=mg(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 Cy(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function ai(n,e=!1){if(!(ht&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),rc(n),e||n.docView&&n.docView.dirty){let t=ko(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 Ty(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 ur=be&&Nt<15||Fn&&bg<604;pe.copy=me.cut=(n,e)=>{let t=e,r=n.state.selection,i=t.type=="cut";if(r.empty)return;let s=ur?null:t.clipboardData,o=r.content(),{dom:l,text:a}=bo(n,o);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):Ty(n,l),i&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function My(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function Oy(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?cr(n,r.value,null,i,e):cr(n,r.textContent,r.innerHTML,i,e)},50)}function cr(n,e,t,r,i){let s=Uu(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,i,s||O.empty)))return!0;if(!s)return!1;let o=My(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 ic(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," "):""}me.paste=(n,e)=>{let t=e;if(n.composing&&!ht)return;let r=ur?null:t.clipboardData,i=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&cr(n,ic(r),r.getData("text/html"),i,t)?t.preventDefault():Oy(n,t)};class sc{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const Ny=Ae?"altKey":"ctrlKey";function oc(n,e){let t=n.someProp("dragCopies",r=>!r(e));return t??!e[Ny]}pe.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(Si(t)),o;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof P?i.to-1:i.to))){if(r&&r.mightDrag)o=P.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=P.create(n.state.doc,h.posBefore))}}let l=(o||n.state.selection).content(),{dom:a,text:u,slice:c}=bo(n,l);(!t.dataTransfer.files.length||!he||zu>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(ur?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",ur||t.dataTransfer.setData("text/plain",u),n.dragging=new sc(c,oc(n,t),o)};pe.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};me.dragover=me.dragenter=(n,e)=>e.preventDefault();me.drop=(n,e)=>{let t=e,r=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let i=n.posAtCoords(Si(t));if(!i)return;let s=n.state.doc.resolve(i.pos),o=r&&r.slice;o?n.someProp("transformPasted",p=>{o=p(o,n)}):o=Uu(n,ic(t.dataTransfer),ur?null:t.dataTransfer.getData("text/html"),!1,s);let l=!!(r&&oc(n,t));if(n.someProp("handleDrop",p=>p(n,t,o||O.empty,l))){t.preventDefault();return}if(!o)return;t.preventDefault();let a=o?ym(n.state.doc,s.pos,o):s.pos;a==null&&(a=s.pos);let u=n.state.tr;if(l){let{node:p}=r;p?p.replace(u):u.deleteSelection()}let c=u.mapping.map(a),h=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,d=u.doc;if(h?u.replaceRangeWith(c,c,o.content.firstChild):u.replaceRange(c,c,o),u.doc.eq(d))return;let f=u.doc.resolve(c);if(h&&P.isSelectable(o.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(o.content.firstChild))u.setSelection(new P(f));else{let p=u.mapping.map(a);u.mapping.maps[u.mapping.maps.length-1].forEach((y,x,k,D)=>p=D),u.setSelection(xo(n,f,u.doc.resolve(p)))}n.focus(),n.dispatch(u.setMeta("uiEvent","drop"))};pe.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())&&ft(n)},20))};pe.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)};pe.beforeinput=(n,e)=>{if(he&&ht&&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,_t(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 me)pe[n]=me[n];function hr(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 ui{constructor(e,t){this.toDOM=e,this.spec=t||Gt,this.side=this.spec.side||0}map(e,t,r,i){let{pos:s,deleted:o}=e.mapResult(t.from+i,this.side<0?-1:1);return o?null:new $e(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof ui&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&hr(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class It{constructor(e,t){this.attrs=e,this.spec=t||Gt}map(e,t,r,i){let s=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-r,o=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-r;return s>=o?null:new $e(s,o,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof It&&hr(this.attrs,e.attrs)&&hr(this.spec,e.spec)}static is(e){return e.type instanceof It}destroy(){}}class To{constructor(e,t){this.attrs=e,this.spec=t||Gt}map(e,t,r,i){let s=e.mapResult(t.from+i,1);if(s.deleted)return null;let o=e.mapResult(t.to+i,-1);return o.deleted||o.pos<=s.pos?null:new $e(s.pos-r,o.pos-r,this)}valid(e,t){let{index:r,offset:i}=e.content.findIndex(t.from),s;return i==t.from&&!(s=e.child(r)).isText&&i+s.nodeSize==t.to}eq(e){return this==e||e instanceof To&&hr(this.attrs,e.attrs)&&hr(this.spec,e.spec)}destroy(){}}class $e{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new $e(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 $e(e,e,new ui(t,r))}static inline(e,t,r,i){return new $e(e,t,new It(r,i))}static node(e,t,r,i){return new $e(e,t,new To(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof It}get widget(){return this.type instanceof ui}}const dn=[],Gt={};class ne{constructor(e,t){this.local=e.length?e:dn,this.children=t.length?t:dn}static create(e,t){return t.length?ci(t,e,0,Gt):ce}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==ce||e.maps.length==0?this:this.mapInner(e,t,0,0,r||Gt)}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?Ey(this.children,o||[],e,t,r,i,s):o?new ne(o.sort(Xt),dn):ce}add(e,t){return t.length?this==ce?ne.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=ac(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,ci(c,l,u+1,Gt)),s+=3}});let o=lc(s?uc(t):t,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new ne(o.length?this.local.concat(o).sort(Xt):this.local,i||this.children)}remove(e){return e.length==0||this==ce?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!=ce?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 ne(i,r):ce}forChild(e,t){if(this==ce)return this;if(t.isLeaf)return ne.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 It){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 ne(i.sort(Xt),dn);return r?new bt([l,r]):l}return r||ce}eq(e){if(this==e)return!0;if(!(e instanceof ne)||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 Mo(this.localsInner(e))}localsInner(e){if(this==ce)return dn;if(e.inlineContent||!this.local.some(It.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof It||t.push(this.local[r]);return t}forEachSet(e){e(this)}}ne.empty=new ne([],[]);ne.removeOverlap=Mo;const ce=ne.empty;class bt{constructor(e){this.members=e}map(e,t){const r=this.members.map(i=>i.map(e,t,Gt));return bt.from(r)}forChild(e,t){if(t.isLeaf)return ne.empty;let r=[];for(let i=0;i<this.members.length;i++){let s=this.members[i].forChild(e,t);s!=ce&&(s instanceof bt?r=r.concat(s.members):r.push(s))}return bt.from(r)}eq(e){if(!(e instanceof bt)||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?Mo(r?t:t.sort(Xt)):dn}static from(e){switch(e.length){case 0:return ce;case 1:return e[0];default:return new bt(e.every(t=>t instanceof ne)?e:e.reduce((t,r)=>t.concat(r instanceof ne?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function Ey(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 D=l[k+1];if(D<0||d>D+c-h)continue;let M=l[k]+c-h;f>=M?l[k+1]=d<=M?-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!=ce?(l[u]=h,l[u+1]=f,l[u+2]=k):(l[u+1]=-2,a=!0)}else a=!0}if(a){let u=Iy(l,n,e,t,i,s,o),c=ci(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 ne(e.sort(Xt),l)}function lc(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let i=n[r];t.push(new $e(i.from+e,i.to+e,i.type))}return t}function Iy(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 ac(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 uc(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function ci(n,e,t,r){let i=[],s=!1;e.forEach((l,a)=>{let u=ac(n,l,a+t);if(u){s=!0;let c=ci(u,l,t+a+1,r);c!=ce&&i.push(a,a+l.nodeSize,c)}});let o=lc(s?uc(n):n,-t).sort(Xt);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 ne(o,i):ce}function Xt(n,e){return n.from-e.from||n.to-e.to}function Mo(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),Ql(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),Ql(e,i,r.copy(s.from,r.to)));break}}}return e}function Ql(n,e,t){for(;e<n.length&&Xt(t,n[e])>0;)e++;n.splice(e,0,t)}function Ui(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=ce&&e.push(r)}),n.cursorWrapper&&e.push(ne.create(n.state.doc,[n.cursorWrapper.deco])),bt.from(e)}const Ay={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Dy=be&&Nt<=11;class zy{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 Ry{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new zy,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]);be&&Nt<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),Dy&&(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,Ay)),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(ql(this.view)){if(this.suppressingSelectionUpdates)return ft(this.view);if(be&&Nt<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&nn(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=Pn(s))t.add(s);for(let s=e.anchorNode;s;s=Pn(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)&&ql(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(We&&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||By(e,h)!=f)&&d.remove()}}}let u=null;s<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&xi(r)&&(u=ko(e))&&u.eq(K.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,ft(e),this.currentSelection.set(r),e.scrollToSelection()):(s>-1||i)&&(s>-1&&(e.docView.markDirty(s,o),Py(e)),this.handleDOMChange(s,o,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||ft(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(be&&Nt<=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?ae(i)+1:0,l=r.localPosFromDOM(e.target,o,-1),a=s&&s.parentNode==e.target?ae(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 Gl=new WeakMap,Xl=!1;function Py(n){if(!Gl.has(n)&&(Gl.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=We,Xl)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."),Xl=!0}}function Zl(n,e){let t=e.startContainer,r=e.startOffset,i=e.endContainer,s=e.endOffset,o=n.domAtPos(n.state.selection.anchor);return nn(o.node,o.offset,i,s)&&([t,r,i,s]=[i,s,t,r]),{anchorNode:t,anchorOffset:r,focusNode:i,focusOffset:s}}function Fy(n,e){if(e.getComposedRanges){let i=e.getComposedRanges(n.root)[0];if(i)return Zl(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?Zl(n,t):null}function By(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 vy(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}],xi(a)||u.push({node:a.focusNode,offset:a.focusOffset})),he&&n.input.lastKeyCode===8)for(let x=s;x>i;x--){let k=r.childNodes[x-1],D=k.pmViewDesc;if(k.nodeName=="BR"&&!D){s=x;break}if(!D||D.size)break}let h=n.state.doc,d=n.someProp("domParser")||Dn.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:Ly,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 Ly(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(de&&/^(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||de&&/^(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 Vy=/^(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 _y(n,e,t,r,i){let s=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let E=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,R=ko(n,E);if(R&&!n.state.selection.eq(R)){if(he&&ht&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",I=>I(n,_t(13,"Enter"))))return;let v=n.state.tr.setSelection(R);E=="pointer"?v.setMeta("pointer",!0):E=="key"&&v.scrollIntoView(),s&&v.setMeta("composition",s),n.dispatch(v)}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=vy(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=Wy(h.content,u.doc.content,u.from,d,f);if(p&&n.input.domChangeCount++,(Fn&&n.input.lastIOSEnter>Date.now()-225||ht)&&i.some(E=>E.nodeType==1&&!Vy.test(E.nodeName))&&(!p||p.endA>=p.endB)&&n.someProp("handleKeyDown",E=>E(n,_t(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof U&&!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 E=ea(n,n.state.doc,u.sel);if(E&&!E.eq(n.state.selection)){let R=n.state.tr.setSelection(E);s&&R.setMeta("composition",s),n.dispatch(R)}}return}n.state.selection.from<n.state.selection.to&&p.start==p.endB&&n.state.selection instanceof U&&(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)),be&&Nt<=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),D=y.sameParent(x)&&y.parent.inlineContent&&k.end()>=p.endA,M;if((Fn&&n.input.lastIOSEnter>Date.now()-225&&(!D||i.some(E=>E.nodeName=="DIV"||E.nodeName=="P"))||!D&&y.pos<u.doc.content.size&&(!y.sameParent(x)||!y.parent.inlineContent)&&!/\S/.test(u.doc.textBetween(y.pos,x.pos,"",""))&&(M=K.findFrom(u.doc.resolve(y.pos+1),1,!0))&&M.head>y.pos)&&n.someProp("handleKeyDown",E=>E(n,_t(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>p.start&&qy(c,p.start,p.endA,y,x)&&n.someProp("handleKeyDown",E=>E(n,_t(8,"Backspace")))){ht&&he&&n.domObserver.suppressSelectionUpdates();return}he&&p.endB==p.start&&(n.input.lastChromeDelete=Date.now()),ht&&!D&&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(E){return E(n,_t(13,"Enter"))})},20));let V=p.start,$=p.endA,w=E=>{let R=E||n.state.tr.replace(V,$,u.doc.slice(p.start-u.from,p.endB-u.from));if(u.sel){let v=ea(n,R.doc,u.sel);v&&!(he&&n.composing&&v.empty&&(p.start!=p.endB||n.input.lastChromeDelete<Date.now()-100)&&(v.head==V||v.head==R.mapping.map($)-1)||be&&v.empty&&v.head==V)&&R.setSelection(v)}return s&&R.setMeta("composition",s),R.scrollIntoView()},W;if(D){if(y.pos==x.pos){be&&Nt<=11&&y.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>ft(n),20));let E=w(n.state.tr.delete(V,$)),R=c.resolve(p.start).marksAcross(c.resolve(p.endA));R&&E.ensureMarks(R),n.dispatch(E)}else if(p.endA==p.endB&&(W=$y(y.parent.content.cut(y.parentOffset,x.parentOffset),k.parent.content.cut(k.parentOffset,p.endA-k.start())))){let E=w(n.state.tr);W.type=="add"?E.addMark(V,$,W.mark):E.removeMark(V,$,W.mark),n.dispatch(E)}else if(y.parent.child(y.index()).isText&&y.index()==x.index()-(x.textOffset?0:1)){let E=y.parent.textBetween(y.parentOffset,x.parentOffset),R=()=>w(n.state.tr.insertText(E,V,$));n.someProp("handleTextInput",v=>v(n,V,$,E,R))||n.dispatch(R())}}else n.dispatch(w())}function ea(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:xo(n,e.resolve(t.anchor),e.resolve(t.head))}function $y(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 qy(n,e,t,r,i){if(t-e<=i.pos-r.pos||Yi(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(Yi(s,!0,!0));return!o.parent.isTextblock||o.pos>t||Yi(o,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function Yi(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 Wy(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&&ta(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&&ta(n.textBetween(s-1,s+1))&&(s+=a?1:-1),o=s+(o-l),l=s}return{start:s,endA:o,endB:l}}function ta(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 cc{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 ay,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(oa),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=ia(this),ra(this),this.nodeViews=sa(this),this.docView=Bl(this.state.doc,na(this),Ui(this),this.dom,this),this.domObserver=new Ry(this,(r,i,s,o)=>_y(this,r,i,s,o)),this.domObserver.start(),uy(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&&Ws(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(oa),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&&(rc(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=sa(this);Jy(f,this.nodeViews)&&(this.nodeViews=f,s=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&Ws(this),this.editable=ia(this),ra(this);let a=Ui(this),u=na(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&&Cg(this);if(o){this.domObserver.stop();let f=h&&(be||he)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&jy(i.selection,e.selection);if(h){let p=he?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=wy(this)),(s||!this.docView.update(e.doc,u,a,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=Bl(e.doc,u,a,this.dom,this)),p&&!this.trackWrites&&(f=!0)}f||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Kg(this))?ft(this,f):(Ju(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&&Tg(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 P){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Al(this,t.getBoundingClientRect(),e)}else Al(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 sc(e.slice,e.move,i<0?void 0:P.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(be){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&&Mg(this.dom),ft(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 Ag(this,e)}coordsAtPos(e,t=1){return vu(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 Fg(this,t||this.state,e)}pasteHTML(e,t){return cr(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return cr(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return bo(this,e)}destroy(){this.docView&&(cy(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Ui(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,fg())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return fy(this,e)}domSelectionRange(){let e=this.domSelection();return e?de&&this.root.nodeType===11&&yg(this.dom.ownerDocument)==this.dom&&Fy(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}cc.prototype.dispatch=function(n){let e=this._props.dispatchTransaction;e?e.call(this,n):this.updateState(this.state.apply(n))};function na(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[$e.node(0,n.state.doc.content.size,e)]}function ra(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:$e.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function ia(n){return!n.someProp("editable",e=>e(n.state)===!1)}function jy(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 sa(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 Jy(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 oa(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 Ft(n,e){return n.meta={package:"@milkdown/core",group:"System",...e},n}const hc={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}},kn=J({},"editorView"),Zn=J({},"editorState"),Qi=J([],"initTimer"),la=J({},"editor"),js=J([],"inputRules"),fr=J([],"prosePlugins"),Js=J([],"remarkPlugins"),Hs=J([],"nodeView"),Ks=J([],"markView"),Zt=J(Os().use(bs).use(Cs),"remark"),Gi=J({handlers:hc},"remarkStringifyOptions"),jr=pt("ConfigReady");function Hy(n){const e=t=>(t.record(jr),async()=>(await n(t),t.done(jr),()=>{t.clearTimer(jr)}));return Ft(e,{displayName:"Config"}),e}const sr=pt("InitReady");function Ky(n){const e=t=>(t.inject(la,n).inject(fr,[]).inject(Js,[]).inject(js,[]).inject(Hs,[]).inject(Ks,[]).inject(Gi,{handlers:hc}).inject(Zt,Os().use(bs).use(Cs)).inject(Qi,[jr]).record(sr),async()=>{await t.waitTimers(Qi);const r=t.get(Gi);return t.set(Zt,Os().use(bs).use(Cs,r)),t.done(sr),()=>{t.remove(la).remove(fr).remove(Js).remove(js).remove(Hs).remove(Ks).remove(Gi).remove(Zt).remove(Qi).clearTimer(sr)}});return Ft(e,{displayName:"Init"}),e}const dt=pt("SchemaReady"),Xi=J([],"schemaTimer"),xn=J({},"schema"),Zi=J([],"nodes"),es=J([],"marks");function aa(n){var e;return{...n,parseDOM:(e=n.parseDOM)==null?void 0:e.map(t=>({priority:n.priority,...t}))}}const fc=n=>(n.inject(xn,{}).inject(Zi,[]).inject(es,[]).inject(Xi,[sr]).record(dt),async()=>{await n.waitTimers(Xi);const e=n.get(Zt),r=n.get(Js).reduce((l,a)=>l.use(a.plugin,a.options),e);n.set(Zt,r);const i=Object.fromEntries(n.get(Zi).map(([l,a])=>[l,aa(a)])),s=Object.fromEntries(n.get(es).map(([l,a])=>[l,aa(a)])),o=new uh({nodes:i,marks:s});return n.set(xn,o),n.done(dt),()=>{n.remove(xn).remove(Zi).remove(es).remove(Xi).clearTimer(dt)}});Ft(fc,{displayName:"Schema"});var jt,Ie;class dc{constructor(){B(this,jt);B(this,Ie);N(this,jt,new pa),N(this,Ie,null),this.setCtx=e=>{N(this,Ie,e)},this.chain=()=>{if(b(this,Ie)==null)throw wi();const e=b(this,Ie),t=[],r=this.get.bind(this),i={run:()=>{const o=vn(...t),l=e.get(kn);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}}get ctx(){return b(this,Ie)}create(e,t){const r=e.create(b(this,jt).sliceMap);return r.set(t),r}get(e){return b(this,jt).get(e).get()}remove(e){return b(this,jt).remove(e)}call(e,t){if(b(this,Ie)==null)throw wi();const i=this.get(e)(t),s=b(this,Ie).get(kn);return i(s.state,s.dispatch,s)}inline(e){if(b(this,Ie)==null)throw wi();const t=b(this,Ie).get(kn);return e(t.state,t.dispatch,t)}}jt=new WeakMap,Ie=new WeakMap;function kk(n="cmdKey"){return J(()=>()=>!1,n)}const ua=J(new dc,"commands"),ts=J([dt],"commandsTimer"),Jr=pt("CommandsReady"),pc=n=>{const e=new dc;return e.setCtx(n),n.inject(ua,e).inject(ts,[dt]).record(Jr),async()=>(await n.waitTimers(ts),n.done(Jr),()=>{n.remove(ua).remove(ts).clearTimer(Jr)})};Ft(pc,{displayName:"Commands"});function Uy(n){const e=vn(Ym,fo,Am,Mu);return n.Backspace=e,n}var Jt,ye;class mc{constructor(){B(this,Jt);B(this,ye);N(this,Jt,null),N(this,ye,[]),this.setCtx=e=>{N(this,Jt,e)},this.add=e=>(b(this,ye).push(e),()=>{N(this,ye,b(this,ye).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};b(this,ye).push(s),t.push(()=>{N(this,ye,b(this,ye).filter(o=>o!==s))})}else b(this,ye).push(i),t.push(()=>{N(this,ye,b(this,ye).filter(s=>s!==i))})}),()=>{t.forEach(r=>r())}},this.addBaseKeymap=()=>{const e=Uy(Km);return this.addObjectKeymap(e)},this.build=()=>{const e={};return b(this,ye).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=b(this,Jt);if(c==null)throw fi();const h=s.map(f=>f.onRun(c));return vn(...h)(l,a,u)}]}))}}get ctx(){return b(this,Jt)}}Jt=new WeakMap,ye=new WeakMap;const Us=J(new mc,"keymap"),ns=J([dt],"keymapTimer"),Hr=pt("KeymapReady"),Yy=n=>{const e=new mc;return e.setCtx(n),n.inject(Us,e).inject(ns,[dt]).record(Hr),async()=>(await n.waitTimers(ns),n.done(Hr),()=>{n.remove(Us).remove(ns).clearTimer(Hr)})},Kr=pt("ParserReady"),gc=()=>{throw fi()},Ur=J(gc,"parser"),rs=J([],"parserTimer"),yc=n=>(n.inject(Ur,gc).inject(rs,[dt]).record(Kr),async()=>{await n.waitTimers(rs);const e=n.get(Zt),t=n.get(xn);return n.set(Ur,Gp.create(t,e)),n.done(Kr),()=>{n.remove(Ur).remove(rs).clearTimer(Kr)}});Ft(yc,{displayName:"Parser"});const Yr=pt("SerializerReady"),is=J([],"serializerTimer"),kc=()=>{throw fi()},ss=J(kc,"serializer"),xc=n=>(n.inject(ss,kc).inject(is,[dt]).record(Yr),async()=>{await n.waitTimers(is);const e=n.get(Zt),t=n.get(xn);return n.set(ss,Zp.create(t,e)),n.done(Yr),()=>{n.remove(ss).remove(is).clearTimer(Yr)}});Ft(xc,{displayName:"Serializer"});const ls=J("","defaultValue"),as=J(n=>n,"stateOptions"),us=J([],"editorStateTimer"),Qr=pt("EditorStateReady");function Qy(n,e,t){if(typeof n=="string")return e(n);if(n.type==="html")return Dn.fromSchema(t).parse(n.dom);if(n.type==="json")return qe.fromJSON(t,n.value);throw Pc(n)}const Gy=new ho("MILKDOWN_STATE_TRACKER"),bc=n=>(n.inject(ls,"").inject(Zn,{}).inject(as,e=>e).inject(us,[Kr,Yr,Jr,Hr]).record(Qr),async()=>{await n.waitTimers(us);const e=n.get(xn),t=n.get(Ur),r=n.get(js),i=n.get(as),s=n.get(fr),o=n.get(ls),l=Qy(o,t,e),a=n.get(Us),u=a.addBaseKeymap(),c=[...s,new ki({key:Gy,state:{init:()=>{},apply:(f,p,y,x)=>{n.set(Zn,x)}}}),tg({rules:r}),cg(a.build())];n.set(fr,c);const h=i({schema:e,doc:l,plugins:c}),d=pn.create(h);return n.set(Zn,d),n.done(Qr),()=>{u(),n.remove(ls).remove(Zn).remove(as).remove(us).clearTimer(Qr)}});Ft(bc,{displayName:"EditorState"});const cs=pt("EditorViewReady"),hs=J([],"editorViewTimer"),Gr=J({},"editorViewOptions"),fs=J(null,"root"),Ys=J(null,"rootDOM"),Qs=J({},"rootAttrs");function Xy(n,e){const t=document.createElement("div");t.className="milkdown",n.appendChild(t),e.set(Ys,t);const r=e.get(Qs);return Object.entries(r).forEach(([i,s])=>t.setAttribute(i,s)),t}function Zy(n){n.classList.add("editor"),n.setAttribute("role","textbox")}const ek=new ho("MILKDOWN_VIEW_CLEAR"),Sc=n=>(n.inject(fs,document.body).inject(kn,{}).inject(Gr,{}).inject(Ys,null).inject(Qs,{}).inject(hs,[Qr]).record(cs),async()=>{await n.wait(sr);const e=n.get(fs)||document.body,t=typeof e=="string"?document.querySelector(e):e;n.update(fr,a=>[new ki({key:ek,view:u=>{const c=t?Xy(t,n):void 0;return(()=>{if(c&&t){const d=u.dom;t.replaceChild(c,d),c.appendChild(d)}})(),{destroy:()=>{c!=null&&c.parentNode&&(c==null||c.parentNode.replaceChild(u.dom,c)),c==null||c.remove()}}}}),...a]),await n.waitTimers(hs);const r=n.get(Zn),i=n.get(Gr),s=Object.fromEntries(n.get(Hs)),o=Object.fromEntries(n.get(Ks)),l=new cc(t,{state:r,nodeViews:s,markViews:o,...i});return Zy(l.dom),n.set(kn,l),n.done(cs),()=>{l==null||l.destroy(),n.remove(fs).remove(kn).remove(Gr).remove(Ys).remove(Qs).remove(hs).clearTimer(cs)}});Ft(Sc,{displayName:"EditorView"});var Ht,Ce,ut,En,kr,xr,ke,ct,Kt,br,Ut,In,Sr,Ct,An;const No=class No{constructor(){B(this,Ht);B(this,Ce);B(this,ut);B(this,En);B(this,kr);B(this,xr);B(this,ke);B(this,ct);B(this,Kt);B(this,br);B(this,Ut);B(this,In);B(this,Sr);B(this,Ct);B(this,An);N(this,Ht,!1),N(this,Ce,"Idle"),N(this,ut,[]),N(this,En,()=>{}),N(this,kr,new pa),N(this,xr,new Wc),N(this,ke,new Map),N(this,ct,new Map),N(this,Kt,new ds(b(this,kr),b(this,xr))),N(this,br,()=>{const e=Hy(async r=>{await Promise.all(b(this,ut).map(i=>i(r)))}),t=[fc,yc,xc,pc,Yy,bc,Sc,Ky(this),e];b(this,Ut).call(this,t,b(this,ct))}),N(this,Ut,(e,t)=>{e.forEach(r=>{const i=b(this,Kt).produce(b(this,Ht)?r.meta:void 0),s=r(i);t.set(r,{ctx:i,handler:s,cleanup:void 0})})}),N(this,In,(e,t=!1)=>Promise.all([e].flat().map(r=>{const i=b(this,ke).get(r),s=i==null?void 0:i.cleanup;return t?b(this,ke).delete(r):b(this,ke).set(r,{ctx:void 0,handler:void 0,cleanup:void 0}),typeof s=="function"?s():s}))),N(this,Sr,async()=>{await Promise.all([...b(this,ct).entries()].map(([e,{cleanup:t}])=>typeof t=="function"?t():t)),b(this,ct).clear()}),N(this,Ct,e=>{N(this,Ce,e),b(this,En).call(this,e)}),N(this,An,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)=>(N(this,Ht,e),this),this.onStatusChange=e=>(N(this,En,e),this),this.config=e=>(b(this,ut).push(e),this),this.removeConfig=e=>(N(this,ut,b(this,ut).filter(t=>t!==e)),this),this.use=e=>{const t=[e].flat();return t.flat().forEach(r=>{b(this,ke).set(r,{ctx:void 0,handler:void 0,cleanup:void 0})}),b(this,Ce)==="Created"&&b(this,Ut).call(this,t,b(this,ke)),this},this.remove=async e=>b(this,Ce)==="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 b(this,In).call(this,[e].flat(),!0),this),this.create=async()=>b(this,Ce)==="OnCreate"?this:(b(this,Ce)==="Created"&&await this.destroy(),b(this,Ct).call(this,"OnCreate"),b(this,br).call(this),b(this,Ut).call(this,[...b(this,ke).keys()],b(this,ke)),await Promise.all([b(this,An).call(this,b(this,ct)),b(this,An).call(this,b(this,ke))].flat()),b(this,Ct).call(this,"Created"),this),this.destroy=async(e=!1)=>b(this,Ce)==="Destroyed"||b(this,Ce)==="OnDestroy"?this:b(this,Ce)==="OnCreate"?new Promise(t=>{setTimeout(()=>{t(this.destroy(e))},50)}):(e&&N(this,ut,[]),b(this,Ct).call(this,"OnDestroy"),await b(this,In).call(this,[...b(this,ke).keys()],e),await b(this,Sr).call(this),b(this,Ct).call(this,"Destroyed"),this),this.action=e=>e(b(this,Kt)),this.inspect=()=>b(this,Ht)?[...b(this,ct).values(),...b(this,ke).values()].map(({ctx:e})=>{var t;return(t=e==null?void 0:e.inspector)==null?void 0:t.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 No}get ctx(){return b(this,Kt)}get status(){return b(this,Ce)}};Ht=new WeakMap,Ce=new WeakMap,ut=new WeakMap,En=new WeakMap,kr=new WeakMap,xr=new WeakMap,ke=new WeakMap,ct=new WeakMap,Kt=new WeakMap,br=new WeakMap,Ut=new WeakMap,In=new WeakMap,Sr=new WeakMap,Ct=new WeakMap,An=new WeakMap;let ca=No;function xk(n){n.update(Gr,e=>{const t=e.attributes;return{...e,attributes:r=>{const i=typeof t=="function"?t(r):t;return{...i,class:Dc("prose dark:prose-invert",(i==null?void 0:i.class)||"","milkdown-theme-nord")}}}})}export{mk as $,qd as A,Vd as B,Jr as C,Bn as D,cs as E,T as F,fk as G,hk as H,sr as I,rk as J,Hr as K,ck as L,Gi as M,Qc as N,Im as O,ki as P,gk as Q,Me as R,Yr as S,U as T,yk as U,mu as V,qe as W,oe as X,Tt as Y,$e as Z,ne as _,J as a,pk as a0,dk as a1,mt as a2,_d as a3,ca as a4,fs as a5,ls as a6,xk as a7,ho as b,nk as c,xn as d,kn as e,Ur as f,zc as g,O as h,as as i,pn as j,kk as k,ua as l,ik as m,Zi as n,sk as o,fr as p,dt as q,Js as r,ss as s,es as t,Us as u,js as v,K as w,Wr as x,ao as y,uo as z};
43
+ `);return{dom:a,text:d,slice:e}}function tu(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&&ru(a,s,l,o[o.length-1],0))o[o.length-1]=u;else{o.length&&(o[o.length-1]=iu(o[o.length-1],s.length));let c=nu(l,a);o.push(c),i=i.matchType(c.type),s=a}}),o)return T.from(o)}return n}function nu(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,T.from(n));return n}function ru(n,e,t,r,i){if(i<n.length&&i<e.length&&n[i]==e[i]){let s=ru(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(nu(t,n,i+1))))}}function iu(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,iu(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 su={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 ou(){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=ou().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),i;if((i=r&&su[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(ae?"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.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)}ce&&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,!au(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(Xe&&ae&&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(au(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 Og(n,e,t,r){return Fs(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",i=>i(n,e,r))}function Ng(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 lu=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[lu]&&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"?Og:Ng)(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[lu],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||ce&&this.mightDrag&&!this.mightDrag.node.isAtom||ae&&!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 au(n,e){return n.composing?!0:ce&&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)))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}uu(n,Ag)};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.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,uu(n,20))};function uu(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>br(n),e))}function cu(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Rg());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function Dg(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=Cm(e.focusNode,e.focusOffset),r=Tm(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 Rg(){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(),cu(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 zg(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)):zg(n,l),i&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Pg(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function Fg(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=tu(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=Pg(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 hu(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,hu(r),r.getData("text/html"),i,t)?t.preventDefault():Fg(n,t)};class fu{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const Bg=we?"altKey":"ctrlKey";function du(n,e){let t=n.someProp("dragCopies",r=>!r(e));return t??!e[Bg]}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||!ae||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 fu(c,du(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)=>{let t=e,r=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let i=n.posAtCoords(zr(t));if(!i)return;let s=n.state.doc.resolve(i.pos),o=r&&r.slice;o?n.someProp("transformPasted",p=>{o=p(o,n,!1)}):o=tu(n,hu(t.dataTransfer),In?null:t.dataTransfer.getData("text/html"),!1,s);let l=!!(r&&du(n,t));if(n.someProp("handleDrop",p=>p(n,t,o||M.empty,l))){t.preventDefault();return}if(!o)return;t.preventDefault();let a=o?Op(n.state.doc,s.pos,o):s.pos;a==null&&(a=s.pos);let u=n.state.tr;if(l){let{node:p}=r;p?p.replace(u):u.deleteSelection()}let c=u.mapping.map(a),h=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,d=u.doc;if(h?u.replaceRangeWith(c,c,o.content.firstChild):u.replaceRange(c,c,o),u.doc.eq(d))return;let f=u.doc.resolve(c);if(h&&D.isSelectable(o.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(o.content.firstChild))u.setSelection(new D(f));else{let p=u.mapping.map(a);u.mapping.maps[u.mapping.maps.length-1].forEach((y,x,k,E)=>p=E),u.setSelection(Rs(n,f,u.doc.resolve(p)))}n.focus(),n.dispatch(u.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(ae&&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||Nt,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||Nt}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||Nt}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=[],Nt={};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,Nt):le}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==le||e.maps.length==0?this:this.mapInner(e,t,0,0,r||Nt)}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):le}add(e,t){return t.length?this==le?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=mu(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,Nt)),s+=3}});let o=pu(s?gu(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==le?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!=le?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):le}forChild(e,t){if(this==le)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||le}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==le)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 le=Z.empty;class ot{constructor(e){this.members=e}map(e,t){const r=this.members.map(i=>i.map(e,t,Nt));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!=le&&(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 le;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 E=l[k+1];if(E<0||d>E+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!=le?(l[u]=h,l[u+1]=f,l[u+2]=k):(l[u+1]=-2,a=!0)}else a=!0}if(a){let u=Lg(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 pu(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 Lg(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 mu(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 gu(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=mu(n,l,a+t);if(u){s=!0;let c=wr(u,l,t+a+1,r);c!=le&&i.push(a,a+l.nodeSize,c)}});let o=pu(s?gu(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):le}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!=le&&e.push(r)}),n.cursorWrapper&&e.push(Z.create(n.state.doc,[n.cursorWrapper.deco])),ot.from(e)}const Vg={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},_g=me&&ct<=11;class $g{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 qg{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new $g,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():this.flush()}),_g&&(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,Vg)),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||Jg(e,h)!=f)&&d.remove()}}}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),Wg(e)),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?se(i)+1:0,l=r.localPosFromDOM(e.target,o,-1),a=s&&s.parentNode==e.target?se(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 Wg(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 jg(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 Jg(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 Hg(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})),ae&&n.input.lastKeyCode===8)for(let x=s;x>i;x--){let k=r.childNodes[x-1],E=k.pmViewDesc;if(k.nodeName=="BR"&&!E){s=x;break}if(!E||E.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:Kg,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 Kg(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(ce&&/^(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||ce&&/^(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 Ug=/^(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 Yg(n,e,t,r,i){let s=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let O=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,P=Ds(n,O);if(P&&!n.state.selection.eq(P)){if(ae&&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);O=="pointer"?z.setMeta("pointer",!0):O=="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=Hg(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=Xg(h.content,u.doc.content,u.from,d,f);if(p&&n.input.domChangeCount++,(Zt&&n.input.lastIOSEnter>Date.now()-225||Xe)&&i.some(O=>O.nodeType==1&&!Ug.test(O.nodeName))&&(!p||p.endA>=p.endB)&&n.someProp("handleKeyDown",O=>O(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 O=ul(n,n.state.doc,u.sel);if(O&&!O.eq(n.state.selection)){let P=n.state.tr.setSelection(O);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),E=y.sameParent(x)&&y.parent.inlineContent&&k.end()>=p.endA;if((Zt&&n.input.lastIOSEnter>Date.now()-225&&(!E||i.some(O=>O.nodeName=="DIV"||O.nodeName=="P"))||!E&&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",O=>O(n,wt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>p.start&&Gg(c,p.start,p.endA,y,x)&&n.someProp("handleKeyDown",O=>O(n,wt(8,"Backspace")))){Xe&&ae&&n.domObserver.suppressSelectionUpdates();return}ae&&p.endB==p.start&&(n.input.lastChromeDelete=Date.now()),Xe&&!E&&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(O){return O(n,wt(13,"Enter"))})},20));let C=p.start,B=p.endA,$=O=>{let P=O||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&&!(ae&&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(E)if(y.pos==x.pos){me&&ct<=11&&y.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>Ze(n),20));let O=$(n.state.tr.delete(C,B)),P=c.resolve(p.start).marksAcross(c.resolve(p.endA));P&&O.ensureMarks(P),n.dispatch(O)}else if(p.endA==p.endB&&(S=Qg(y.parent.content.cut(y.parentOffset,x.parentOffset),k.parent.content.cut(k.parentOffset,p.endA-k.start())))){let O=$(n.state.tr);S.type=="add"?O.addMark(C,B,S.mark):O.removeMark(C,B,S.mark),n.dispatch(O)}else if(y.parent.child(y.index()).isText&&y.index()==x.index()-(x.textOffset?0:1)){let O=y.parent.textBetween(y.parentOffset,x.parentOffset),P=()=>$(n.state.tr.insertText(O,C,B));n.someProp("handleTextInput",z=>z(n,C,B,O,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 Qg(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 Gg(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 Xg(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 yu{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 qg(this,(r,i,s,o)=>Yg(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&&(cu(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);ey(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||ae)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&Zg(i.selection,e.selection);if(h){let p=ae?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Dg(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&&(f=!0)}f||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&ng(this))?Ze(this,f):(Xa(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 fu(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,Sm())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Sg(this,e)}domSelectionRange(){let e=this.domSelection();return e?ce&&this.root.nodeType===11&&Om(this.dom.ownerDocument)==this.dom&&jg(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}yu.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 Zg(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 ey(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 ku={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:ku,encode:[]},"remarkStringifyOptions"),tr=We("ConfigReady");function ty(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 ny(n){const e=t=>(t.inject(gl,n).inject(Rn,[]).inject(ns,[]).inject(ts,[]).inject(rs,[]).inject(is,[]).inject(ui,{handlers:ku,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 xu=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 kc({nodes:i,marks:s});return n.set(Ut,o),n.done(Fe),()=>{n.remove(Ut).remove(hi).remove(fi).remove(ci).clearTimer(Fe)}});tt(xu,{displayName:"Schema"});class bu{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 My(n="cmdKey"){return V((()=>()=>!1),n)}const kl=V(new bu,"commands"),di=V([Fe],"commandsTimer"),nr=We("CommandsReady"),Su=n=>{const e=new bu;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(Su,{displayName:"Commands"});function ry(n){const e=tn(im,Os,Vp,Ra);return n.Backspace=e,n}class wu{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=ry(nm);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 wu,"keymap"),pi=V([Fe],"keymapTimer"),rr=We("KeymapReady"),iy=n=>{const e=new wu;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"),Cu=(()=>{throw Tr()}),sr=V(Cu,"parser"),mi=V([],"parserTimer"),Tu=n=>(n.inject(sr,Cu).inject(mi,[Fe]).record(ir),async()=>{await n.waitTimers(mi);const e=n.get(It),t=n.get(Ut);return n.set(sr,op.create(t,e)),n.done(ir),()=>{n.remove(sr).remove(mi).clearTimer(ir)}});tt(Tu,{displayName:"Parser"});const or=We("SerializerReady"),gi=V([],"serializerTimer"),Mu=(()=>{throw Tr()}),yi=V(Mu,"serializer"),Ou=n=>(n.inject(yi,Mu).inject(gi,[Fe]).record(or),async()=>{await n.waitTimers(gi);const e=n.get(It),t=n.get(Ut);return n.set(yi,ap.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 sy(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 Wu(n)}const oy=new Ms("MILKDOWN_STATE_TRACKER"),Nu=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=sy(o,t,e),a=n.get(ss),u=a.addBaseKeymap(),c=[...s,new Ar({key:oy,state:{init:()=>{},apply:(f,p,y,x)=>{n.set(kn,x)}}}),cm({rules:r}),xm(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(Nu,{displayName:"EditorState"});const ls=V([],"pasteRule"),Si=V([Fe],"pasteRuleTimer"),ar=We("PasteRuleReady"),Eu=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(Eu,{displayName:"PasteRule"});const wi=We("EditorViewReady"),Ci=V([],"editorViewTimer"),ur=V({},"editorViewOptions"),Ti=V(null,"root"),as=V(null,"rootDOM"),us=V({},"rootAttrs");function ly(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 ay(n){n.classList.add("editor"),n.setAttribute("role","textbox")}const uy=new Ms("MILKDOWN_VIEW_CLEAR"),Iu=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:uy,view:u=>{const c=t?ly(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 yu(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 ay(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(Iu,{displayName:"EditorView"});class Au{constructor(){this.#t=!1,this.#e="Idle",this.#r=[],this.#n=()=>{},this.#o=new Sl,this.#s=new Xu,this.#i=new Map,this.#l=new Map,this.#a=new cs(this.#o,this.#s),this.#d=()=>{const e=ty(async r=>{await Promise.all(this.#r.map(i=>Promise.resolve(i(r))))}),t=[xu,Tu,Ou,Su,iy,Eu,Nu,Iu,ny(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 Au}#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 Oy(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{Sy as $,Uf as A,xy as B,nr as C,en as D,wi as E,T as F,ky as G,cy as H,Mn as I,yy as J,rr as K,ui as L,Lp as M,sc as N,Cy as O,Ar as P,Ty as Q,xe as R,or as S,j as T,wa as U,Pe as V,re as W,lt as X,ze as Y,Z,wy as _,Ms as a,by as a0,et as a1,Yf as a2,Au as a3,Ti as a4,ki as a5,Oy as a6,Ut as b,V as c,sr as d,Kt as e,M as f,$u as g,xi as h,Wt as i,My as j,kl as k,fy as l,hy 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,Gf as z};