@north-light/cli 0.3.507 → 0.3.509

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.
Files changed (53) hide show
  1. package/dist/api/client.d.ts +2 -1
  2. package/dist/api/client.js +3 -3
  3. package/dist/api/contract.d.ts +1 -1
  4. package/dist/api/contract.js +1 -1
  5. package/dist/api/dto/docs.d.ts +4 -0
  6. package/dist/api/routes.d.ts +1 -0
  7. package/dist/api/routes.js +1 -1
  8. package/dist/clients/attach/assets/mermaid.min.js +3631 -0
  9. package/dist/clients/attach/render/doc-links.d.ts +2 -5
  10. package/dist/clients/attach/render/doc-links.js +1 -1
  11. package/dist/clients/attach/session/document-links.d.ts +6 -18
  12. package/dist/clients/attach/session/document-links.js +1 -1
  13. package/dist/clients/attach/session/file-links.d.ts +0 -2
  14. package/dist/clients/attach/session/file-links.js +1 -1
  15. package/dist/clients/attach/viewer.js +558 -625
  16. package/dist/core/config.js +1 -1
  17. package/dist/core/graph/events.d.ts +1 -0
  18. package/dist/core/graph/events.js +6 -6
  19. package/dist/core/graph/names.d.ts +6 -3
  20. package/dist/core/graph/names.js +3 -3
  21. package/dist/core/user-settings.d.ts +4 -4
  22. package/dist/core/user-settings.js +1 -1
  23. package/dist/daemon/api/bridge.js +3 -3
  24. package/dist/daemon/api/document-listener.d.ts +7 -0
  25. package/dist/daemon/api/document-listener.js +11 -0
  26. package/dist/daemon/api/document-merge.d.ts +2 -0
  27. package/dist/daemon/api/document-merge.js +1 -0
  28. package/dist/daemon/api/document-secret.d.ts +2 -0
  29. package/dist/daemon/api/document-secret.js +1 -0
  30. package/dist/daemon/api/handlers/docs.d.ts +14 -0
  31. package/dist/daemon/api/handlers/docs.js +1 -1
  32. package/dist/daemon/api/handlers/document-access.d.ts +2 -0
  33. package/dist/daemon/api/handlers/document-access.js +1 -0
  34. package/dist/daemon/api/handlers/objects.js +3 -3
  35. package/dist/daemon/api/map.js +2 -2
  36. package/dist/daemon/api/operations.js +1 -1
  37. package/dist/daemon/api/router.js +1 -1
  38. package/dist/daemon/api/server.js +1 -1
  39. package/dist/daemon/api/vendor-signin.d.ts +1 -0
  40. package/dist/daemon/api/vendor-signin.js +1 -1
  41. package/dist/daemon/crtrd.js +9 -9
  42. package/dist/daemon/peer/ingress.js +1 -1
  43. package/dist/doc-editor/editor.css +1 -0
  44. package/dist/doc-editor/editor.js +53 -0
  45. package/dist/types.d.ts +2 -9
  46. package/dist/types.js +1 -1
  47. package/package.json +13 -2
  48. package/packages/crouter-identity/package.json +1 -1
  49. package/runtime.lock.json +364 -12
  50. package/dist/clients/attach/session/doc-html.d.ts +0 -8
  51. package/dist/clients/attach/session/doc-html.js +0 -66
  52. package/dist/clients/attach/session/doc-materialize.d.ts +0 -57
  53. package/dist/clients/attach/session/doc-materialize.js +0 -3
@@ -0,0 +1,53 @@
1
+ var qm=Object.defineProperty;var a=(e,t)=>qm(e,"name",{value:t,configurable:!0});var Km=Object.create,$o=Object.defineProperty,Jm=Object.getOwnPropertyDescriptor,Um=Object.getOwnPropertyNames,Gm=Object.getPrototypeOf,Qm=Object.prototype.hasOwnProperty,Ym=a((e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),"mk"),Xm=a((e,t)=>{for(var n in t)$o(e,n,{get:t[n],enumerable:!0})},"gk"),Zm=a((e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Um(t))!Qm.call(e,i)&&i!==n&&$o(e,i,{get:a(()=>t[i],"get"),enumerable:!(r=Jm(t,i))||r.enumerable});return e},"yk"),eg=a((e,t,n)=>(n=e!=null?Km(Gm(e)):{},Zm(t||!e||!e.__esModule?$o(n,"default",{value:e,enumerable:!0}):n,e)),"kk"),tg=Ym((e,t)=>{"use strict";var n=Object.prototype.hasOwnProperty,r=Object.prototype.toString,i=Object.defineProperty,o=Object.getOwnPropertyDescriptor,s=a(function(h){return typeof Array.isArray=="function"?Array.isArray(h):r.call(h)==="[object Array]"},"Ch"),l=a(function(h){if(!h||r.call(h)!=="[object Object]")return!1;var d=n.call(h,"constructor"),p=h.constructor&&h.constructor.prototype&&n.call(h.constructor.prototype,"isPrototypeOf");if(h.constructor&&!d&&!p)return!1;var f;for(f in h);return typeof f>"u"||n.call(h,f)},"Sh"),c=a(function(h,d){i&&d.name==="__proto__"?i(h,d.name,{enumerable:!0,configurable:!0,value:d.newValue,writable:!0}):h[d.name]=d.newValue},"Mh"),u=a(function(h,d){if(d==="__proto__")if(n.call(h,d)){if(o)return o(h,d).value}else return;return h[d]},"Nh");t.exports=a(function h(){var d,p,f,m,g,v,y=arguments[0],N=1,x=arguments.length,A=!1;for(typeof y=="boolean"&&(A=y,y=arguments[1]||{},N=2),(y==null||typeof y!="object"&&typeof y!="function")&&(y={});N<x;++N)if(d=arguments[N],d!=null)for(p in d)f=u(y,p),m=u(d,p),y!==m&&(A&&m&&(l(m)||(g=s(m)))?(g?(g=!1,v=f&&s(f)?f:[]):v=f&&l(f)?f:{},c(y,{name:p,newValue:h(A,v,m)})):typeof m<"u"&&c(y,{name:p,newValue:m}));return y},"t")}),_e=(function(e){return e.docTypeError="docTypeError",e.contextNotFound="contextNotFound",e.timerNotFound="timerNotFound",e.ctxCallOutOfScope="ctxCallOutOfScope",e.createNodeInParserFail="createNodeInParserFail",e.stackOverFlow="stackOverFlow",e.parserMatchError="parserMatchError",e.serializerMatchError="serializerMatchError",e.getAtomFromSchemaFail="getAtomFromSchemaFail",e.expectDomTypeError="expectDomTypeError",e.callCommandBeforeEditorView="callCommandBeforeEditorView",e.missingRootElement="missingRootElement",e.missingNodeInSchema="missingNodeInSchema",e.missingMarkInSchema="missingMarkInSchema",e.ctxNotBind="ctxNotBind",e.missingYjsDoc="missingYjsDoc",e.aiProviderError="aiProviderError",e.aiBuildContextError="aiBuildContextError",e})({}),He=class extends Error{static{a(this,"Ze")}constructor(e,t,n){super(t,n),this.name="MilkdownError",this.code=e,n?.cause!==void 0&&(this.cause=n.cause)}},ng=a((e,t)=>typeof t=="function"?"[Function]":t,"bk"),xi=a(e=>JSON.stringify(e,ng),"oo");function rg(e){return new He(_e.docTypeError,`Doc type error, unsupported type: ${xi(e)}`)}a(rg,"rf");function ig(e){return new He(_e.contextNotFound,`Context "${e}" not found, do you forget to inject it?`)}a(ig,"of");function og(e){return new He(_e.timerNotFound,`Timer "${e}" not found, do you forget to record it?`)}a(og,"sf");function Si(){return new He(_e.ctxCallOutOfScope,"Should not call a context out of the plugin.")}a(Si,"fr");function sg(e,t,n){let r=`Cannot create node for ${"name"in e?e.name:e}`,i=a(s=>{if(s==null)return"null";if(Array.isArray(s))return`[${s.map(i).join(", ")}]`;if(typeof s=="object")return"toJSON"in s&&typeof s.toJSON=="function"?JSON.stringify(s.toJSON()):"spec"in s?JSON.stringify(s.spec):JSON.stringify(s);if(typeof s=="string"||typeof s=="number"||typeof s=="boolean")return JSON.stringify(s);if(typeof s=="function")return`[Function: ${s.name||"anonymous"}]`;try{return String(s)}catch{return"[Unserializable]"}},"i"),o=[["[Description]",r],["[Attributes]",t],["[Content]",(n??[]).map(s=>s?typeof s=="object"&&"type"in s?`${s}`:i(s):"null")]].reduce((s,[l,c])=>{let u=`${l}: ${i(c)}.`;return s.concat(u)},[]);return new He(_e.createNodeInParserFail,o.join(`
2
+ `))}a(sg,"lf");function yc(){return new He(_e.stackOverFlow,"Stack over flow, cannot pop on an empty stack.")}a(yc,"Hs");function lg(e){return new He(_e.parserMatchError,`Cannot match target parser for node: ${xi(e)}.`)}a(lg,"af");function ag(e){return new He(_e.serializerMatchError,`Cannot match target serializer for node: ${xi(e)}.`)}a(ag,"cf");function at(e){return new He(_e.expectDomTypeError,`Expect to be a dom, but get: ${xi(e)}.`)}a(at,"et");function Bo(){return new He(_e.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")}a(Bo,"so");function cg(e){return new He(_e.missingNodeInSchema,`Missing node in schema, milkdown cannot find "${e}" in schema.`)}a(cg,"uf");function ug(e){return new He(_e.missingMarkInSchema,`Missing mark in schema, milkdown cannot find "${e}" in schema.`)}a(ug,"ff");var vc=class{static{a(this,"js")}constructor(){this.sliceMap=new Map,this.get=e=>{let t=typeof e=="string"?[...this.sliceMap.values()].find(n=>n.type.name===e):this.sliceMap.get(e.id);if(!t){let n=typeof e=="string"?e:e.name;throw ig(n)}return t},this.remove=e=>{let t=typeof e=="string"?[...this.sliceMap.values()].find(n=>n.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)}},hg=class{static{a(this,"xk")}#t;#e;#r;constructor(e,t,n){this.#t=[],this.#r=()=>{this.#t.forEach(r=>r(this.#e))},this.set=r=>{this.#e=r,this.#r()},this.get=()=>this.#e,this.update=r=>{this.#e=r(this.#e),this.#r()},this.type=n,this.#e=t,e.set(n.id,this)}on(e){return this.#t.push(e),()=>{this.#t=this.#t.filter(t=>t!==e)}}once(e){let t=this.on(n=>{e(n),t()});return t}off(e){this.#t=this.#t.filter(t=>t!==e)}offAll(){this.#t=[]}},dg=class{static{a(this,"wk")}constructor(e,t){this.id=Symbol(`Context-${t}`),this.name=t,this._defaultValue=e,this._typeInfo=()=>{throw Si()}}create(e,t=this._defaultValue){return new hg(e,t,this)}},J=a((e,t)=>new dg(e,t),"U"),pg=class{static{a(this,"Ck")}#t;#e;#r;#n;#o;#s;#i;constructor(e,t,n){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(r=>({name:typeof r=="string"?r:r.name,value:this.#l(r)})),consumedSlices:[...this.#o].map(r=>({name:typeof r=="string"?r:r.name,value:this.#l(r)})),recordedTimers:[...this.#s].map(([r,{duration:i}])=>({name:r.name,duration:i,status:this.#a(r)})),waitTimers:[...this.#i].map(([r,{duration:i}])=>({name:r.name,duration:i,status:this.#a(r)}))}),this.onRecord=r=>{this.#s.set(r,{start:Date.now(),duration:0})},this.onClear=r=>{this.#s.delete(r)},this.onDone=r=>{let i=this.#s.get(r);i&&(i.duration=Date.now()-i.start)},this.onWait=(r,i)=>{let o=Date.now();i.finally(()=>{this.#i.set(r,{duration:Date.now()-o})}).catch(console.error)},this.onInject=r=>{this.#n.add(r)},this.onRemove=r=>{this.#n.delete(r)},this.onUse=r=>{this.#o.add(r)},this.#l=r=>this.#e.get(r).get(),this.#a=r=>this.#r.get(r).status,this.#e=e,this.#r=t,this.#t=n}#l;#a},fg=class wm{static{a(this,"df")}#t;#e;#r;#n;constructor(t,n,r){this.produce=i=>i&&Object.keys(i).length?new wm(this.#t,this.#e,{...i}):this,this.inject=(i,o)=>{let s=i.create(this.#t.sliceMap);return o!=null&&s.set(o),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,o)=>this.use(i).set(o),this.update=(i,o)=>this.use(i).update(o),this.timer=i=>this.#e.get(i),this.done=i=>{this.timer(i).done(),this.#n?.onDone(i)},this.wait=i=>{let o=this.timer(i).start();return this.#n?.onWait(i,o),o},this.waitTimers=async i=>{await Promise.all(this.get(i).map(o=>this.wait(o)))},this.#t=t,this.#e=n,this.#r=r,r&&(this.#n=new pg(t,n,r))}get meta(){return this.#r}get inspector(){return this.#n}},mg=class{static{a(this,"pf")}constructor(){this.store=new Map,this.get=e=>{let t=this.store.get(e.id);if(!t)throw og(e.name);return t},this.remove=e=>{this.store.delete(e.id)},this.has=e=>this.store.has(e.id)}},gg=class{static{a(this,"Sk")}#t;#e;#r;#n;#o;constructor(e,t){this.#t=null,this.#e=null,this.#n="pending",this.#o=null,this.start=()=>(this.#t??=new Promise((n,r)=>{this.#e=i=>{i instanceof CustomEvent&&i.detail.id===this.#r&&(this.#n="resolved",this.#s(),i.stopImmediatePropagation(),n())},this.#i(()=>{this.#n==="pending"&&(this.#n="rejected"),this.#s(),r(new Error(`Timing ${this.type.name} timeout.`))}),this.#n="pending",addEventListener(this.type.name,this.#e)}),this.#t),this.done=()=>{let n=new CustomEvent(this.type.name,{detail:{id:this.#r}});dispatchEvent(n)},this.#s=()=>{this.#o!==null&&(clearTimeout(this.#o),this.#o=null),this.#e&&removeEventListener(this.type.name,this.#e)},this.#i=n=>{this.#o=setTimeout(()=>{this.#o=null,n()},this.type.timeout)},this.#r=Symbol(t.name),this.type=t,e.set(t.id,this)}get status(){return this.#n}#s;#i},yg=class{static{a(this,"Mk")}constructor(e,t=3e3){this.create=n=>new gg(n,this),this.id=Symbol(`Timer-${e}`),this.name=e,this.timeout=t}},ct=a((e,t=3e3)=>new yg(e,t),"tt"),vg={};function Vo(e,t){let n=t||vg,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return kc(e,r,i)}a(Vo,"gn");function kc(e,t,n){if(kg(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return wc(e.children,t,n)}return Array.isArray(e)?wc(e,t,n):""}a(kc,"gf");function wc(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=kc(e[i],t,n);return r.join("")}a(wc,"mf");function kg(e){return!!(e&&typeof e=="object")}a(kg,"vk");var bc=document.createElement("i");function jo(e){let t="&"+e+";";bc.innerHTML=t;let n=bc.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}a(jo,"hr");function Le(e,t,n,r){let i=e.length,o=0,s;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)s=Array.from(r),s.unshift(t,n),e.splice(...s);else for(n&&e.splice(t,n);o<r.length;)s=r.slice(o,o+1e4),s.unshift(t,0),e.splice(...s),o+=1e4,t+=1e4}a(Le,"le");function We(e,t){return e.length>0?(Le(e,e.length,0,t),e):t}a(We,"Be");var xc={}.hasOwnProperty;function Sc(e){let t={},n=-1;for(;++n<e.length;)wg(t,e[n]);return t}a(Sc,"lo");function wg(e,t){let n;for(n in t){let r=(xc.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],o;if(i)for(o in i){xc.call(r,o)||(r[o]=[]);let s=i[o];bg(r[o],Array.isArray(s)?s:s?[s]:[])}}}a(wg,"Tk");function bg(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);Le(e,0,0,r)}a(bg,"Ik");function Cc(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"\uFFFD":String.fromCodePoint(n)}a(Cc,"ao");function nt(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}a(nt,"Ie");var Se=zt(/[A-Za-z]/),Ae=zt(/[\dA-Za-z]/),xg=zt(/[#-'*+\--9=?A-Z^-~]/);function Ci(e){return e!==null&&(e<32||e===127)}a(Ci,"yn");var _o=zt(/\d/),Sg=zt(/[\dA-Fa-f]/),Cg=zt(/[!-/:-@[-`{-~]/);function P(e){return e!==null&&e<-2}a(P,"E");function te(e){return e!==null&&(e<0||e===32)}a(te,"J");function K(e){return e===-2||e===-1||e===32}a(K,"z");var Mi=zt(new RegExp("\\p{P}|\\p{S}","u")),tn=zt(/\s/);function zt(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}a(zt,"Kt");function U(e,t,n,r){let i=r?r-1:Number.POSITIVE_INFINITY,o=0;return s;function s(c){return K(c)?(e.enter(n),l(c)):t(c)}function l(c){return K(c)&&o++<i?(e.consume(c),l):(e.exit(n),t(c))}}a(U,"P");var Mg={tokenize:Ng};function Ng(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(l){if(l===null){e.consume(l);return}return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),U(e,t,"linePrefix")}function i(l){return e.enter("paragraph"),o(l)}function o(l){let c=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=c),n=c,s(l)}function s(l){if(l===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(l);return}return P(l)?(e.consume(l),e.exit("chunkText"),o):(e.consume(l),s)}}a(Ng,"Ak");var Og={tokenize:Tg},Mc={tokenize:Ag};function Tg(e){let t=this,n=[],r=0,i,o,s;return l;function l(x){if(r<n.length){let A=n[r];return t.containerState=A[1],e.attempt(A[0].continuation,c,u)(x)}return u(x)}function c(x){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&N();let A=t.events.length,D=A,M;for(;D--;)if(t.events[D][0]==="exit"&&t.events[D][1].type==="chunkFlow"){M=t.events[D][1].end;break}y(r);let I=A;for(;I<t.events.length;)t.events[I][1].end={...M},I++;return Le(t.events,D+1,0,t.events.slice(A)),t.events.length=I,u(x)}return l(x)}function u(x){if(r===n.length){if(!i)return p(x);if(i.currentConstruct&&i.currentConstruct.concrete)return m(x);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Mc,h,d)(x)}function h(x){return i&&N(),y(r),p(x)}function d(x){return t.parser.lazy[t.now().line]=r!==n.length,s=t.now().offset,m(x)}function p(x){return t.containerState={},e.attempt(Mc,f,m)(x)}function f(x){return r++,n.push([t.currentConstruct,t.containerState]),p(x)}function m(x){if(x===null){i&&N(),y(0),e.consume(x);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:o}),g(x)}function g(x){if(x===null){v(e.exit("chunkFlow"),!0),y(0),e.consume(x);return}return P(x)?(e.consume(x),v(e.exit("chunkFlow")),r=0,t.interrupt=void 0,l):(e.consume(x),g)}function v(x,A){let D=t.sliceStream(x);if(A&&D.push(null),x.previous=o,o&&(o.next=x),o=x,i.defineSkip(x.start),i.write(D),t.parser.lazy[x.start.line]){let M=i.events.length;for(;M--;)if(i.events[M][1].start.offset<s&&(!i.events[M][1].end||i.events[M][1].end.offset>s))return;let I=t.events.length,F=I,$,b;for(;F--;)if(t.events[F][0]==="exit"&&t.events[F][1].type==="chunkFlow"){if($){b=t.events[F][1].end;break}$=!0}for(y(r),M=I;M<t.events.length;)t.events[M][1].end={...b},M++;Le(t.events,F+1,0,t.events.slice(I)),t.events.length=M}}function y(x){let A=n.length;for(;A-- >x;){let D=n[A];t.containerState=D[1],D[0].exit.call(t,e)}n.length=x}function N(){i.write([null]),o=void 0,i=void 0,t.containerState._closeFlow=void 0}}a(Tg,"Ek");function Ag(e,t,n){return U(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}a(Ag,"Ok");function Nn(e){if(e===null||te(e)||tn(e))return 1;if(Mi(e))return 2}a(Nn,"Tt");function Ni(e,t,n){let r=[],i=-1;for(;++i<e.length;){let o=e[i].resolveAll;o&&!r.includes(o)&&(t=o(t,n),r.push(o))}return t}a(Ni,"Wt");var Ho={name:"attention",resolveAll:Ig,tokenize:Eg};function Ig(e,t){let n=-1,r,i,o,s,l,c,u,h;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},p={...e[n][1].start};Nc(d,-c),Nc(p,c),s={type:c>1?"strongSequence":"emphasisSequence",start:d,end:{...e[r][1].end}},l={type:c>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:p},o={type:c>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?"strong":"emphasis",start:{...s.start},end:{...l.end}},e[r][1].end={...s.start},e[n][1].start={...l.end},u=[],e[r][1].end.offset-e[r][1].start.offset&&(u=We(u,[["enter",e[r][1],t],["exit",e[r][1],t]])),u=We(u,[["enter",i,t],["enter",s,t],["exit",s,t],["enter",o,t]]),u=We(u,Ni(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),u=We(u,[["exit",o,t],["enter",l,t],["exit",l,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(h=2,u=We(u,[["enter",e[n][1],t],["exit",e[n][1],t]])):h=0,Le(e,r-1,n-r+3,u),n=r+u.length-h-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}a(Ig,"Rk");function Eg(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Nn(r),o;return s;function s(c){return o=c,e.enter("attentionSequence"),l(c)}function l(c){if(c===o)return e.consume(c),l;let u=e.exit("attentionSequence"),h=Nn(c),d=!h||h===2&&i||n.includes(c),p=!i||i===2&&h||n.includes(r);return u._open=!!(o===42?d:d&&(i||!p)),u._close=!!(o===42?p:p&&(h||!d)),t(c)}}a(Eg,"Dk");function Nc(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}a(Nc,"Nf");var Dg={name:"autolink",tokenize:Rg};function Rg(e,t,n){let r=0;return i;function i(f){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(f),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),o}function o(f){return Se(f)?(e.consume(f),s):f===64?n(f):u(f)}function s(f){return f===43||f===45||f===46||Ae(f)?(r=1,l(f)):u(f)}function l(f){return f===58?(e.consume(f),r=0,c):(f===43||f===45||f===46||Ae(f))&&r++<32?(e.consume(f),l):(r=0,u(f))}function c(f){return f===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(f),e.exit("autolinkMarker"),e.exit("autolink"),t):f===null||f===32||f===60||Ci(f)?n(f):(e.consume(f),c)}function u(f){return f===64?(e.consume(f),h):xg(f)?(e.consume(f),u):n(f)}function h(f){return Ae(f)?d(f):n(f)}function d(f){return f===46?(e.consume(f),r=0,h):f===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(f),e.exit("autolinkMarker"),e.exit("autolink"),t):p(f)}function p(f){if((f===45||Ae(f))&&r++<63){let m=f===45?p:d;return e.consume(f),m}return n(f)}}a(Rg,"Pk");var ar={partial:!0,tokenize:zg};function zg(e,t,n){return r;function r(o){return K(o)?U(e,i,"linePrefix")(o):i(o)}function i(o){return o===null||P(o)?t(o):n(o)}}a(zg,"Lk");var Oc={continuation:{tokenize:Fg},exit:Lg,name:"blockQuote",tokenize:Pg};function Pg(e,t,n){let r=this;return i;function i(s){if(s===62){let l=r.containerState;return l.open||(e.enter("blockQuote",{_container:!0}),l.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(s),e.exit("blockQuoteMarker"),o}return n(s)}function o(s){return K(s)?(e.enter("blockQuotePrefixWhitespace"),e.consume(s),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(s))}}a(Pg,"zk");function Fg(e,t,n){let r=this;return i;function i(s){return K(s)?U(e,o,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(s):o(s)}function o(s){return e.attempt(Oc,t,n)(s)}}a(Fg,"Bk");function Lg(e){e.exit("blockQuote")}a(Lg,"Fk");var Tc={name:"characterEscape",tokenize:$g};function $g(e,t,n){return r;function r(o){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(o),e.exit("escapeMarker"),i}function i(o){return Cg(o)?(e.enter("characterEscapeValue"),e.consume(o),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(o)}}a($g,"_k");var Ac={name:"characterReference",tokenize:Bg};function Bg(e,t,n){let r=this,i=0,o,s;return l;function l(d){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(d),e.exit("characterReferenceMarker"),c}function c(d){return d===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(d),e.exit("characterReferenceMarkerNumeric"),u):(e.enter("characterReferenceValue"),o=31,s=Ae,h(d))}function u(d){return d===88||d===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(d),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),o=6,s=Sg,h):(e.enter("characterReferenceValue"),o=7,s=_o,h(d))}function h(d){if(d===59&&i){let p=e.exit("characterReferenceValue");return s===Ae&&!jo(r.sliceSerialize(p))?n(d):(e.enter("characterReferenceMarker"),e.consume(d),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return s(d)&&i++<o?(e.consume(d),h):n(d)}}a(Bg,"$k");var Ic={partial:!0,tokenize:jg},Ec={concrete:!0,name:"codeFenced",tokenize:Vg};function Vg(e,t,n){let r=this,i={partial:!0,tokenize:D},o=0,s=0,l;return c;function c(M){return u(M)}function u(M){let I=r.events[r.events.length-1];return o=I&&I[1].type==="linePrefix"?I[2].sliceSerialize(I[1],!0).length:0,l=M,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),h(M)}function h(M){return M===l?(s++,e.consume(M),h):s<3?n(M):(e.exit("codeFencedFenceSequence"),K(M)?U(e,d,"whitespace")(M):d(M))}function d(M){return M===null||P(M)?(e.exit("codeFencedFence"),r.interrupt?t(M):e.check(Ic,g,A)(M)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),p(M))}function p(M){return M===null||P(M)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),d(M)):K(M)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),U(e,f,"whitespace")(M)):M===96&&M===l?n(M):(e.consume(M),p)}function f(M){return M===null||P(M)?d(M):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),m(M))}function m(M){return M===null||P(M)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),d(M)):M===96&&M===l?n(M):(e.consume(M),m)}function g(M){return e.attempt(i,A,v)(M)}function v(M){return e.enter("lineEnding"),e.consume(M),e.exit("lineEnding"),y}function y(M){return o>0&&K(M)?U(e,N,"linePrefix",o+1)(M):N(M)}function N(M){return M===null||P(M)?e.check(Ic,g,A)(M):(e.enter("codeFlowValue"),x(M))}function x(M){return M===null||P(M)?(e.exit("codeFlowValue"),N(M)):(e.consume(M),x)}function A(M){return e.exit("codeFenced"),t(M)}function D(M,I,F){let $=0;return b;function b(W){return M.enter("lineEnding"),M.consume(W),M.exit("lineEnding"),ue}function ue(W){return M.enter("codeFencedFence"),K(W)?U(M,Y,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(W):Y(W)}function Y(W){return W===l?(M.enter("codeFencedFenceSequence"),R(W)):F(W)}function R(W){return W===l?($++,M.consume(W),R):$>=s?(M.exit("codeFencedFenceSequence"),K(W)?U(M,H,"whitespace")(W):H(W)):F(W)}function H(W){return W===null||P(W)?(M.exit("codeFencedFence"),I(W)):F(W)}}}a(Vg,"Vk");function jg(e,t,n){let r=this;return i;function i(s){return s===null?n(s):(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),o)}function o(s){return r.parser.lazy[r.now().line]?n(s):t(s)}}a(jg,"Hk");var Wo={name:"codeIndented",tokenize:Hg},_g={partial:!0,tokenize:Wg};function Hg(e,t,n){let r=this;return i;function i(u){return e.enter("codeIndented"),U(e,o,"linePrefix",5)(u)}function o(u){let h=r.events[r.events.length-1];return h&&h[1].type==="linePrefix"&&h[2].sliceSerialize(h[1],!0).length>=4?s(u):n(u)}function s(u){return u===null?c(u):P(u)?e.attempt(_g,s,c)(u):(e.enter("codeFlowValue"),l(u))}function l(u){return u===null||P(u)?(e.exit("codeFlowValue"),s(u)):(e.consume(u),l)}function c(u){return e.exit("codeIndented"),t(u)}}a(Hg,"Kk");function Wg(e,t,n){let r=this;return i;function i(s){return r.parser.lazy[r.now().line]?n(s):P(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),i):U(e,o,"linePrefix",5)(s)}function o(s){let l=r.events[r.events.length-1];return l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?t(s):P(s)?i(s):n(s)}}a(Wg,"Wk");var qg={name:"codeText",previous:Jg,resolve:Kg,tokenize:Ug};function Kg(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(i=r):(r===t||e[r][1].type==="lineEnding")&&(e[i][1].type="codeTextData",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}a(Kg,"qk");function Jg(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}a(Jg,"Jk");function Ug(e,t,n){let r=this,i=0,o,s;return l;function l(p){return e.enter("codeText"),e.enter("codeTextSequence"),c(p)}function c(p){return p===96?(e.consume(p),i++,c):(e.exit("codeTextSequence"),u(p))}function u(p){return p===null?n(p):p===32?(e.enter("space"),e.consume(p),e.exit("space"),u):p===96?(s=e.enter("codeTextSequence"),o=0,d(p)):P(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),u):(e.enter("codeTextData"),h(p))}function h(p){return p===null||p===32||p===96||P(p)?(e.exit("codeTextData"),u(p)):(e.consume(p),h)}function d(p){return p===96?(e.consume(p),o++,d):o===i?(e.exit("codeTextSequence"),e.exit("codeText"),t(p)):(s.type="codeTextData",h(p))}}a(Ug,"Uk");var Gg=class{static{a(this,"po")}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){let n=t??Number.POSITIVE_INFINITY;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,Number.POSITIVE_INFINITY);return n&&cr(this.left,n),i.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),cr(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),cr(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e<this.left.length){let t=this.left.splice(e,Number.POSITIVE_INFINITY);cr(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);cr(this.left,t.reverse())}}};function cr(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}a(cr,"fi");function Dc(e){let t={},n=-1,r,i,o,s,l,c,u,h=new Gg(e);for(;++n<h.length;){for(;n in t;)n=t[n];if(r=h.get(n),n&&r[1].type==="chunkFlow"&&h.get(n-1)[1].type==="listItemPrefix"&&(c=r[1]._tokenizer.events,o=0,o<c.length&&c[o][1].type==="lineEndingBlank"&&(o+=2),o<c.length&&c[o][1].type==="content"))for(;++o<c.length&&c[o][1].type!=="content";)c[o][1].type==="chunkText"&&(c[o][1]._isInFirstContentOfListItem=!0,o++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,Qg(h,n)),n=t[n],u=!0);else if(r[1]._container){for(o=n,i=void 0;o--;)if(s=h.get(o),s[1].type==="lineEnding"||s[1].type==="lineEndingBlank")s[0]==="enter"&&(i&&(h.get(i)[1].type="lineEndingBlank"),s[1].type="lineEnding",i=o);else if(!(s[1].type==="linePrefix"||s[1].type==="listItemIndent"))break;i&&(r[1].end={...h.get(i)[1].start},l=h.slice(i,n),l.unshift(r),h.splice(i,n-i+1,l))}}return Le(e,0,Number.POSITIVE_INFINITY,h.slice(0)),!u}a(Dc,"mo");function Qg(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,o=[],s=n._tokenizer;s||(s=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(s._contentTypeTextTrailing=!0));let l=s.events,c=[],u={},h,d,p=-1,f=n,m=0,g=0,v=[g];for(;f;){for(;e.get(++i)[1]!==f;);o.push(i),f._tokenizer||(h=r.sliceStream(f),f.next||h.push(null),d&&s.defineSkip(f.start),f._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=!0),s.write(h),f._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=void 0)),d=f,f=f.next}for(f=n;++p<l.length;)l[p][0]==="exit"&&l[p-1][0]==="enter"&&l[p][1].type===l[p-1][1].type&&l[p][1].start.line!==l[p][1].end.line&&(g=p+1,v.push(g),f._tokenizer=void 0,f.previous=void 0,f=f.next);for(s.events=[],f?(f._tokenizer=void 0,f.previous=void 0):v.pop(),p=v.length;p--;){let y=l.slice(v[p],v[p+1]),N=o.pop();c.push([N,N+y.length-1]),e.splice(N,2,y)}for(c.reverse(),p=-1;++p<c.length;)u[m+c[p][0]]=m+c[p][1],m+=c[p][1]-c[p][0]-1;return u}a(Qg,"Gk");var Yg={resolve:Zg,tokenize:ey},Xg={partial:!0,tokenize:ty};function Zg(e){return Dc(e),e}a(Zg,"Qk");function ey(e,t){let n;return r;function r(l){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(l)}function i(l){return l===null?o(l):P(l)?e.check(Xg,s,o)(l):(e.consume(l),i)}function o(l){return e.exit("chunkContent"),e.exit("content"),t(l)}function s(l){return e.consume(l),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}a(ey,"Xk");function ty(e,t,n){let r=this;return i;function i(s){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),U(e,o,"linePrefix")}function o(s){if(s===null||P(s))return n(s);let 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?t(s):e.interrupt(r.parser.constructs.flow,n,t)(s)}}a(ty,"Zk");function Rc(e,t,n,r,i,o,s,l,c){let u=c||Number.POSITIVE_INFINITY,h=0;return d;function d(y){return y===60?(e.enter(r),e.enter(i),e.enter(o),e.consume(y),e.exit(o),p):y===null||y===32||y===41||Ci(y)?n(y):(e.enter(r),e.enter(s),e.enter(l),e.enter("chunkString",{contentType:"string"}),g(y))}function p(y){return y===62?(e.enter(o),e.consume(y),e.exit(o),e.exit(i),e.exit(r),t):(e.enter(l),e.enter("chunkString",{contentType:"string"}),f(y))}function f(y){return y===62?(e.exit("chunkString"),e.exit(l),p(y)):y===null||y===60||P(y)?n(y):(e.consume(y),y===92?m:f)}function m(y){return y===60||y===62||y===92?(e.consume(y),f):f(y)}function g(y){return!h&&(y===null||y===41||te(y))?(e.exit("chunkString"),e.exit(l),e.exit(s),e.exit(r),t(y)):h<u&&y===40?(e.consume(y),h++,g):y===41?(e.consume(y),h--,g):y===null||y===32||y===40||Ci(y)?n(y):(e.consume(y),y===92?v:g)}function v(y){return y===40||y===41||y===92?(e.consume(y),g):g(y)}}a(Rc,"go");function zc(e,t,n,r,i,o){let s=this,l=0,c;return u;function u(f){return e.enter(r),e.enter(i),e.consume(f),e.exit(i),e.enter(o),h}function h(f){return l>999||f===null||f===91||f===93&&!c||f===94&&!l&&"_hiddenFootnoteSupport"in s.parser.constructs?n(f):f===93?(e.exit(o),e.enter(i),e.consume(f),e.exit(i),e.exit(r),t):P(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),h):(e.enter("chunkString",{contentType:"string"}),d(f))}function d(f){return f===null||f===91||f===93||P(f)||l++>999?(e.exit("chunkString"),h(f)):(e.consume(f),c||(c=!K(f)),f===92?p:d)}function p(f){return f===91||f===92||f===93?(e.consume(f),l++,d):d(f)}}a(zc,"yo");function Pc(e,t,n,r,i,o){let s;return l;function l(p){return p===34||p===39||p===40?(e.enter(r),e.enter(i),e.consume(p),e.exit(i),s=p===40?41:p,c):n(p)}function c(p){return p===s?(e.enter(i),e.consume(p),e.exit(i),e.exit(r),t):(e.enter(o),u(p))}function u(p){return p===s?(e.exit(o),c(s)):p===null?n(p):P(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),U(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),h(p))}function h(p){return p===s||p===null||P(p)?(e.exit("chunkString"),u(p)):(e.consume(p),p===92?d:h)}function d(p){return p===s||p===92?(e.consume(p),h):h(p)}}a(Pc,"ko");function ur(e,t){let n;return r;function r(i){return P(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):K(i)?U(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}a(ur,"bn");var ny={name:"definition",tokenize:iy},ry={partial:!0,tokenize:oy};function iy(e,t,n){let r=this,i;return o;function o(f){return e.enter("definition"),s(f)}function s(f){return zc.call(r,e,l,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(f)}function l(f){return i=nt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),f===58?(e.enter("definitionMarker"),e.consume(f),e.exit("definitionMarker"),c):n(f)}function c(f){return te(f)?ur(e,u)(f):u(f)}function u(f){return Rc(e,h,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(f)}function h(f){return e.attempt(ry,d,d)(f)}function d(f){return K(f)?U(e,p,"whitespace")(f):p(f)}function p(f){return f===null||P(f)?(e.exit("definition"),r.parser.defined.push(i),t(f)):n(f)}}a(iy,"tb");function oy(e,t,n){return r;function r(l){return te(l)?ur(e,i)(l):n(l)}function i(l){return Pc(e,o,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(l)}function o(l){return K(l)?U(e,s,"whitespace")(l):s(l)}function s(l){return l===null||P(l)?t(l):n(l)}}a(oy,"nb");var sy={name:"hardBreakEscape",tokenize:ly};function ly(e,t,n){return r;function r(o){return e.enter("hardBreakEscape"),e.consume(o),i}function i(o){return P(o)?(e.exit("hardBreakEscape"),t(o)):n(o)}}a(ly,"rb");var ay={name:"headingAtx",resolve:cy,tokenize:uy};function cy(e,t){let n=e.length-2,r=3,i,o;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(i={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},o={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},Le(e,r,n-r+1,[["enter",i,t],["enter",o,t],["exit",o,t],["exit",i,t]])),e}a(cy,"ib");function uy(e,t,n){let r=0;return i;function i(h){return e.enter("atxHeading"),o(h)}function o(h){return e.enter("atxHeadingSequence"),s(h)}function s(h){return h===35&&r++<6?(e.consume(h),s):h===null||te(h)?(e.exit("atxHeadingSequence"),l(h)):n(h)}function l(h){return h===35?(e.enter("atxHeadingSequence"),c(h)):h===null||P(h)?(e.exit("atxHeading"),t(h)):K(h)?U(e,l,"whitespace")(h):(e.enter("atxHeadingText"),u(h))}function c(h){return h===35?(e.consume(h),c):(e.exit("atxHeadingSequence"),l(h))}function u(h){return h===null||h===35||te(h)?(e.exit("atxHeadingText"),l(h)):(e.consume(h),u)}}a(uy,"ob");var hy=["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"],Fc=["pre","script","style","textarea"],dy={concrete:!0,name:"htmlFlow",resolveTo:my,tokenize:gy},py={partial:!0,tokenize:vy},fy={partial:!0,tokenize:yy};function my(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}a(my,"ab");function gy(e,t,n){let r=this,i,o,s,l,c;return u;function u(w){return h(w)}function h(w){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(w),d}function d(w){return w===33?(e.consume(w),p):w===47?(e.consume(w),o=!0,g):w===63?(e.consume(w),i=3,r.interrupt?t:k):Se(w)?(e.consume(w),s=String.fromCharCode(w),v):n(w)}function p(w){return w===45?(e.consume(w),i=2,f):w===91?(e.consume(w),i=5,l=0,m):Se(w)?(e.consume(w),i=4,r.interrupt?t:k):n(w)}function f(w){return w===45?(e.consume(w),r.interrupt?t:k):n(w)}function m(w){let Pe="CDATA[";return w===Pe.charCodeAt(l++)?(e.consume(w),l===Pe.length?r.interrupt?t:Y:m):n(w)}function g(w){return Se(w)?(e.consume(w),s=String.fromCharCode(w),v):n(w)}function v(w){if(w===null||w===47||w===62||te(w)){let Pe=w===47,Zt=s.toLowerCase();return!Pe&&!o&&Fc.includes(Zt)?(i=1,r.interrupt?t(w):Y(w)):hy.includes(s.toLowerCase())?(i=6,Pe?(e.consume(w),y):r.interrupt?t(w):Y(w)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(w):o?N(w):x(w))}return w===45||Ae(w)?(e.consume(w),s+=String.fromCharCode(w),v):n(w)}function y(w){return w===62?(e.consume(w),r.interrupt?t:Y):n(w)}function N(w){return K(w)?(e.consume(w),N):b(w)}function x(w){return w===47?(e.consume(w),b):w===58||w===95||Se(w)?(e.consume(w),A):K(w)?(e.consume(w),x):b(w)}function A(w){return w===45||w===46||w===58||w===95||Ae(w)?(e.consume(w),A):D(w)}function D(w){return w===61?(e.consume(w),M):K(w)?(e.consume(w),D):x(w)}function M(w){return w===null||w===60||w===61||w===62||w===96?n(w):w===34||w===39?(e.consume(w),c=w,I):K(w)?(e.consume(w),M):F(w)}function I(w){return w===c?(e.consume(w),c=null,$):w===null||P(w)?n(w):(e.consume(w),I)}function F(w){return w===null||w===34||w===39||w===47||w===60||w===61||w===62||w===96||te(w)?D(w):(e.consume(w),F)}function $(w){return w===47||w===62||K(w)?x(w):n(w)}function b(w){return w===62?(e.consume(w),ue):n(w)}function ue(w){return w===null||P(w)?Y(w):K(w)?(e.consume(w),ue):n(w)}function Y(w){return w===45&&i===2?(e.consume(w),oe):w===60&&i===1?(e.consume(w),le):w===62&&i===4?(e.consume(w),je):w===63&&i===3?(e.consume(w),k):w===93&&i===5?(e.consume(w),st):P(w)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(py,mt,R)(w)):w===null||P(w)?(e.exit("htmlFlowData"),R(w)):(e.consume(w),Y)}function R(w){return e.check(fy,H,mt)(w)}function H(w){return e.enter("lineEnding"),e.consume(w),e.exit("lineEnding"),W}function W(w){return w===null||P(w)?R(w):(e.enter("htmlFlowData"),Y(w))}function oe(w){return w===45?(e.consume(w),k):Y(w)}function le(w){return w===47?(e.consume(w),s="",tt):Y(w)}function tt(w){if(w===62){let Pe=s.toLowerCase();return Fc.includes(Pe)?(e.consume(w),je):Y(w)}return Se(w)&&s.length<8?(e.consume(w),s+=String.fromCharCode(w),tt):Y(w)}function st(w){return w===93?(e.consume(w),k):Y(w)}function k(w){return w===62?(e.consume(w),je):w===45&&i===2?(e.consume(w),k):Y(w)}function je(w){return w===null||P(w)?(e.exit("htmlFlowData"),mt(w)):(e.consume(w),je)}function mt(w){return e.exit("htmlFlow"),t(w)}}a(gy,"cb");function yy(e,t,n){let r=this;return i;function i(s){return P(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),o):n(s)}function o(s){return r.parser.lazy[r.now().line]?n(s):t(s)}}a(yy,"ub");function vy(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(ar,t,n)}}a(vy,"fb");var ky={name:"htmlText",tokenize:wy};function wy(e,t,n){let r=this,i,o,s;return l;function l(k){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(k),c}function c(k){return k===33?(e.consume(k),u):k===47?(e.consume(k),D):k===63?(e.consume(k),x):Se(k)?(e.consume(k),F):n(k)}function u(k){return k===45?(e.consume(k),h):k===91?(e.consume(k),o=0,m):Se(k)?(e.consume(k),N):n(k)}function h(k){return k===45?(e.consume(k),f):n(k)}function d(k){return k===null?n(k):k===45?(e.consume(k),p):P(k)?(s=d,le(k)):(e.consume(k),d)}function p(k){return k===45?(e.consume(k),f):d(k)}function f(k){return k===62?oe(k):k===45?p(k):d(k)}function m(k){let je="CDATA[";return k===je.charCodeAt(o++)?(e.consume(k),o===je.length?g:m):n(k)}function g(k){return k===null?n(k):k===93?(e.consume(k),v):P(k)?(s=g,le(k)):(e.consume(k),g)}function v(k){return k===93?(e.consume(k),y):g(k)}function y(k){return k===62?oe(k):k===93?(e.consume(k),y):g(k)}function N(k){return k===null||k===62?oe(k):P(k)?(s=N,le(k)):(e.consume(k),N)}function x(k){return k===null?n(k):k===63?(e.consume(k),A):P(k)?(s=x,le(k)):(e.consume(k),x)}function A(k){return k===62?oe(k):x(k)}function D(k){return Se(k)?(e.consume(k),M):n(k)}function M(k){return k===45||Ae(k)?(e.consume(k),M):I(k)}function I(k){return P(k)?(s=I,le(k)):K(k)?(e.consume(k),I):oe(k)}function F(k){return k===45||Ae(k)?(e.consume(k),F):k===47||k===62||te(k)?$(k):n(k)}function $(k){return k===47?(e.consume(k),oe):k===58||k===95||Se(k)?(e.consume(k),b):P(k)?(s=$,le(k)):K(k)?(e.consume(k),$):oe(k)}function b(k){return k===45||k===46||k===58||k===95||Ae(k)?(e.consume(k),b):ue(k)}function ue(k){return k===61?(e.consume(k),Y):P(k)?(s=ue,le(k)):K(k)?(e.consume(k),ue):$(k)}function Y(k){return k===null||k===60||k===61||k===62||k===96?n(k):k===34||k===39?(e.consume(k),i=k,R):P(k)?(s=Y,le(k)):K(k)?(e.consume(k),Y):(e.consume(k),H)}function R(k){return k===i?(e.consume(k),i=void 0,W):k===null?n(k):P(k)?(s=R,le(k)):(e.consume(k),R)}function H(k){return k===null||k===34||k===39||k===60||k===61||k===96?n(k):k===47||k===62||te(k)?$(k):(e.consume(k),H)}function W(k){return k===47||k===62||te(k)?$(k):n(k)}function oe(k){return k===62?(e.consume(k),e.exit("htmlTextData"),e.exit("htmlText"),t):n(k)}function le(k){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(k),e.exit("lineEnding"),tt}function tt(k){return K(k)?U(e,st,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(k):st(k)}function st(k){return e.enter("htmlTextData"),s(k)}}a(wy,"hb");var qo={name:"labelEnd",resolveAll:Cy,resolveTo:My,tokenize:Ny},by={tokenize:Oy},xy={tokenize:Ty},Sy={tokenize:Ay};function Cy(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){let i=r.type==="labelImage"?4:2;r.type="data",t+=i}}return e.length!==n.length&&Le(e,0,e.length,n),e}a(Cy,"gb");function My(e,t){let n=e.length,r=0,i,o,s,l;for(;n--;)if(i=e[n][1],o){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[n][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(s){if(e[n][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(o=n,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(s=n);let c={type:e[o][1].type==="labelLink"?"link":"image",start:{...e[o][1].start},end:{...e[e.length-1][1].end}},u={type:"label",start:{...e[o][1].start},end:{...e[s][1].end}},h={type:"labelText",start:{...e[o+r+2][1].end},end:{...e[s-2][1].start}};return l=[["enter",c,t],["enter",u,t]],l=We(l,e.slice(o+1,o+r+3)),l=We(l,[["enter",h,t]]),l=We(l,Ni(t.parser.constructs.insideSpan.null,e.slice(o+r+4,s-3),t)),l=We(l,[["exit",h,t],e[s-2],e[s-1],["exit",u,t]]),l=We(l,e.slice(s+1)),l=We(l,[["exit",c,t]]),Le(e,o,e.length,l),e}a(My,"yb");function Ny(e,t,n){let r=this,i=r.events.length,o,s;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){o=r.events[i][1];break}return l;function l(p){return o?o._inactive?d(p):(s=r.parser.defined.includes(nt(r.sliceSerialize({start:o.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(p),e.exit("labelMarker"),e.exit("labelEnd"),c):n(p)}function c(p){return p===40?e.attempt(by,h,s?h:d)(p):p===91?e.attempt(xy,h,s?u:d)(p):s?h(p):d(p)}function u(p){return e.attempt(Sy,h,d)(p)}function h(p){return t(p)}function d(p){return o._balanced=!0,n(p)}}a(Ny,"kb");function Oy(e,t,n){return r;function r(d){return e.enter("resource"),e.enter("resourceMarker"),e.consume(d),e.exit("resourceMarker"),i}function i(d){return te(d)?ur(e,o)(d):o(d)}function o(d){return d===41?h(d):Rc(e,s,l,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(d)}function s(d){return te(d)?ur(e,c)(d):h(d)}function l(d){return n(d)}function c(d){return d===34||d===39||d===40?Pc(e,u,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(d):h(d)}function u(d){return te(d)?ur(e,h)(d):h(d)}function h(d){return d===41?(e.enter("resourceMarker"),e.consume(d),e.exit("resourceMarker"),e.exit("resource"),t):n(d)}}a(Oy,"bb");function Ty(e,t,n){let r=this;return i;function i(l){return zc.call(r,e,o,s,"reference","referenceMarker","referenceString")(l)}function o(l){return r.parser.defined.includes(nt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(l):n(l)}function s(l){return n(l)}}a(Ty,"xb");function Ay(e,t,n){return r;function r(o){return e.enter("reference"),e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),i}function i(o){return o===93?(e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),e.exit("reference"),t):n(o)}}a(Ay,"wb");var Iy={name:"labelStartImage",resolveAll:qo.resolveAll,tokenize:Ey};function Ey(e,t,n){let r=this;return i;function i(l){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(l),e.exit("labelImageMarker"),o}function o(l){return l===91?(e.enter("labelMarker"),e.consume(l),e.exit("labelMarker"),e.exit("labelImage"),s):n(l)}function s(l){return l===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(l):t(l)}}a(Ey,"Cb");var Dy={name:"labelStartLink",resolveAll:qo.resolveAll,tokenize:Ry};function Ry(e,t,n){let r=this;return i;function i(s){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(s),e.exit("labelMarker"),e.exit("labelLink"),o}function o(s){return s===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(s):t(s)}}a(Ry,"Sb");var Ko={name:"lineEnding",tokenize:zy};function zy(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),U(e,t,"linePrefix")}}a(zy,"Mb");var Oi={name:"thematicBreak",tokenize:Py};function Py(e,t,n){let r=0,i;return o;function o(u){return e.enter("thematicBreak"),s(u)}function s(u){return i=u,l(u)}function l(u){return u===i?(e.enter("thematicBreakSequence"),c(u)):r>=3&&(u===null||P(u))?(e.exit("thematicBreak"),t(u)):n(u)}function c(u){return u===i?(e.consume(u),r++,c):(e.exit("thematicBreakSequence"),K(u)?U(e,l,"whitespace")(u):l(u))}}a(Py,"Nb");var Ie={continuation:{tokenize:By},exit:jy,name:"list",tokenize:$y},Fy={partial:!0,tokenize:_y},Ly={partial:!0,tokenize:Vy};function $y(e,t,n){let r=this,i=r.events[r.events.length-1],o=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,s=0;return l;function l(f){let m=r.containerState.type||(f===42||f===43||f===45?"listUnordered":"listOrdered");if(m==="listUnordered"?!r.containerState.marker||f===r.containerState.marker:_o(f)){if(r.containerState.type||(r.containerState.type=m,e.enter(m,{_container:!0})),m==="listUnordered")return e.enter("listItemPrefix"),f===42||f===45?e.check(Oi,n,u)(f):u(f);if(!r.interrupt||f===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),c(f)}return n(f)}function c(f){return _o(f)&&++s<10?(e.consume(f),c):(!r.interrupt||s<2)&&(r.containerState.marker?f===r.containerState.marker:f===41||f===46)?(e.exit("listItemValue"),u(f)):n(f)}function u(f){return e.enter("listItemMarker"),e.consume(f),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||f,e.check(ar,r.interrupt?n:h,e.attempt(Fy,p,d))}function h(f){return r.containerState.initialBlankLine=!0,o++,p(f)}function d(f){return K(f)?(e.enter("listItemPrefixWhitespace"),e.consume(f),e.exit("listItemPrefixWhitespace"),p):n(f)}function p(f){return r.containerState.size=o+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(f)}}a($y,"Ib");function By(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(ar,i,o);function i(l){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,U(e,t,"listItemIndent",r.containerState.size+1)(l)}function o(l){return r.containerState.furtherBlankLines||!K(l)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,s(l)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(Ly,t,s)(l))}function s(l){return r.containerState._closeFlow=!0,r.interrupt=void 0,U(e,e.attempt(Ie,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l)}}a(By,"Ab");function Vy(e,t,n){let r=this;return U(e,i,"listItemIndent",r.containerState.size+1);function i(o){let s=r.events[r.events.length-1];return s&&s[1].type==="listItemIndent"&&s[2].sliceSerialize(s[1],!0).length===r.containerState.size?t(o):n(o)}}a(Vy,"Eb");function jy(e){e.exit(this.containerState.type)}a(jy,"Ob");function _y(e,t,n){let r=this;return U(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(o){let s=r.events[r.events.length-1];return!K(o)&&s&&s[1].type==="listItemPrefixWhitespace"?t(o):n(o)}}a(_y,"Rb");var Lc={name:"setextUnderline",resolveTo:Hy,tokenize:Wy};function Hy(e,t){let n=e.length,r,i,o;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(i=n)}else e[n][1].type==="content"&&e.splice(n,1),!o&&e[n][1].type==="definition"&&(o=n);let s={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",o?(e.splice(i,0,["enter",s,t]),e.splice(o+1,0,["exit",e[r][1],t]),e[r][1].end={...e[o][1].end}):e[r][1]=s,e.push(["exit",s,t]),e}a(Hy,"Db");function Wy(e,t,n){let r=this,i;return o;function o(u){let h=r.events.length,d;for(;h--;)if(r.events[h][1].type!=="lineEnding"&&r.events[h][1].type!=="linePrefix"&&r.events[h][1].type!=="content"){d=r.events[h][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||d)?(e.enter("setextHeadingLine"),i=u,s(u)):n(u)}function s(u){return e.enter("setextHeadingLineSequence"),l(u)}function l(u){return u===i?(e.consume(u),l):(e.exit("setextHeadingLineSequence"),K(u)?U(e,c,"lineSuffix")(u):c(u))}function c(u){return u===null||P(u)?(e.exit("setextHeadingLine"),t(u)):n(u)}}a(Wy,"Pb");var qy={tokenize:Ky};function Ky(e){let t=this,n=e.attempt(ar,r,e.attempt(this.parser.constructs.flowInitial,i,U(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Yg,i)),"linePrefix")));return n;function r(o){if(o===null){e.consume(o);return}return e.enter("lineEndingBlank"),e.consume(o),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function i(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),t.currentConstruct=void 0,n}}a(Ky,"Lb");var Jy={resolveAll:Bc()},Uy=$c("string"),Gy=$c("text");function $c(e){return{resolveAll:Bc(e==="text"?Qy:void 0),tokenize:t};function t(n){let r=this,i=this.parser.constructs[e],o=n.attempt(i,s,l);return s;function s(h){return u(h)?o(h):l(h)}function l(h){if(h===null){n.consume(h);return}return n.enter("data"),n.consume(h),c}function c(h){return u(h)?(n.exit("data"),o(h)):(n.consume(h),c)}function u(h){if(h===null)return!0;let d=i[h],p=-1;if(d)for(;++p<d.length;){let f=d[p];if(!f.previous||f.previous.call(r,r.previous))return!0}return!1}}}a($c,"Rf");function Bc(e){return t;function t(n,r){let i=-1,o;for(;++i<=n.length;)o===void 0?n[i]&&n[i][1].type==="data"&&(o=i,i++):(!n[i]||n[i][1].type!=="data")&&(i!==o+2&&(n[o][1].end=n[i-1][1].end,n.splice(o+2,i-o-2),i=o+2),o=void 0);return e?e(n,r):n}}a(Bc,"Df");function Qy(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){let r=e[n-1][1],i=t.sliceStream(r),o=i.length,s=-1,l=0,c;for(;o--;){let u=i[o];if(typeof u=="string"){for(s=u.length;u.charCodeAt(s-1)===32;)l++,s--;if(s)break;s=-1}else if(u===-2)c=!0,l++;else if(u!==-1){o++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(l=0),l){let u={type:n===e.length||c||l<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:o?s:r.start._bufferIndex+s,_index:r.start._index+o,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):(e.splice(n,0,["enter",u,t],["exit",u,t]),n+=2)}n++}return e}a(Qy,"zb");var Vc={};Xm(Vc,{attentionMarkers:a(()=>i0,"attentionMarkers"),contentInitial:a(()=>Xy,"contentInitial"),disable:a(()=>o0,"disable"),document:a(()=>Yy,"document"),flow:a(()=>e0,"flow"),flowInitial:a(()=>Zy,"flowInitial"),insideSpan:a(()=>r0,"insideSpan"),string:a(()=>t0,"string"),text:a(()=>n0,"text")});var Yy={42:Ie,43:Ie,45:Ie,48:Ie,49:Ie,50:Ie,51:Ie,52:Ie,53:Ie,54:Ie,55:Ie,56:Ie,57:Ie,62:Oc},Xy={91:ny},Zy={[-2]:Wo,[-1]:Wo,32:Wo},e0={35:ay,42:Oi,45:[Lc,Oi],60:dy,61:Lc,95:Oi,96:Ec,126:Ec},t0={38:Ac,92:Tc},n0={[-5]:Ko,[-4]:Ko,[-3]:Ko,33:Iy,38:Ac,42:Ho,60:[Dg,ky],91:Dy,92:[sy,Tc],93:qo,95:Ho,96:qg},r0={null:[Ho,Jy]},i0={null:[42,95]},o0={null:[]};function s0(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},o=[],s=[],l=[],c=!0,u={attempt:$(I),check:$(F),consume:A,enter:D,exit:M,interrupt:$(F,{interrupt:!0})},h={code:null,containerState:{},defineSkip:y,events:[],now:v,parser:e,previous:null,sliceSerialize:m,sliceStream:g,write:f},d=t.tokenize.call(h,u),p;return t.resolveAll&&o.push(t),h;function f(R){return s=We(s,R),N(),s[s.length-1]!==null?[]:(b(t,0),h.events=Ni(o,h.events,h),h.events)}function m(R,H){return a0(g(R),H)}function g(R){return l0(s,R)}function v(){let{_bufferIndex:R,_index:H,line:W,column:oe,offset:le}=r;return{_bufferIndex:R,_index:H,line:W,column:oe,offset:le}}function y(R){i[R.line]=R.column,Y()}function N(){let R;for(;r._index<s.length;){let H=s[r._index];if(typeof H=="string")for(R=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===R&&r._bufferIndex<H.length;)x(H.charCodeAt(r._bufferIndex));else x(H)}}function x(R){c=void 0,p=R,d=d(R)}function A(R){P(R)?(r.line++,r.column=1,r.offset+=R===-3?2:1,Y()):R!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===s[r._index].length&&(r._bufferIndex=-1,r._index++)),h.previous=R,c=!0}function D(R,H){let W=H||{};return W.type=R,W.start=v(),h.events.push(["enter",W,h]),l.push(W),W}function M(R){let H=l.pop();return H.end=v(),h.events.push(["exit",H,h]),H}function I(R,H){b(R,H.from)}function F(R,H){H.restore()}function $(R,H){return W;function W(oe,le,tt){let st,k,je,mt;return Array.isArray(oe)?Pe(oe):"tokenize"in oe?Pe([oe]):w(oe);function w(he){return or;function or(gt){let en=gt!==null&&he[gt],Sn=gt!==null&&he.null,Lo=[...Array.isArray(en)?en:en?[en]:[],...Array.isArray(Sn)?Sn:Sn?[Sn]:[]];return Pe(Lo)(gt)}}function Pe(he){return st=he,k=0,he.length===0?tt:Zt(he[k])}function Zt(he){return or;function or(gt){return mt=ue(),je=he,he.partial||(h.currentConstruct=he),he.name&&h.parser.constructs.disable.null.includes(he.name)?bi(gt):he.tokenize.call(H?Object.assign(Object.create(h),H):h,u,Fo,bi)(gt)}}function Fo(he){return c=!0,R(je,mt),le}function bi(he){return c=!0,mt.restore(),++k<st.length?Zt(st[k]):tt}}}function b(R,H){R.resolveAll&&!o.includes(R)&&o.push(R),R.resolve&&Le(h.events,H,h.events.length-H,R.resolve(h.events.slice(H),h)),R.resolveTo&&(h.events=R.resolveTo(h.events,h))}function ue(){let R=v(),H=h.previous,W=h.currentConstruct,oe=h.events.length,le=Array.from(l);return{from:oe,restore:tt};function tt(){r=R,h.previous=H,h.currentConstruct=W,h.events.length=oe,l=le,Y()}}function Y(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}a(s0,"Pf");function l0(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,o=t.end._bufferIndex,s;if(n===i)s=[e[n].slice(r,o)];else{if(s=e.slice(n,i),r>-1){let l=s[0];typeof l=="string"?s[0]=l.slice(r):s.shift()}o>0&&s.push(e[i].slice(0,o))}return s}a(l0,"qb");function a0(e,t){let n=-1,r=[],i;for(;++n<e.length;){let o=e[n],s;if(typeof o=="string")s=o;else switch(o){case-5:{s="\r";break}case-4:{s=`
3
+ `;break}case-3:{s=`\r
4
+ `;break}case-2:{s=t?" ":" ";break}case-1:{if(!t&&i)continue;s=" ";break}default:s=String.fromCharCode(o)}i=o===-2,r.push(s)}return r.join("")}a(a0,"Jb");function c0(e){let t={constructs:Sc([Vc,...(e||{}).extensions||[]]),content:n(Mg),defined:[],document:n(Og),flow:n(qy),lazy:{},string:n(Uy),text:n(Gy)};return t;function n(r){return i;function i(o){return s0(t,r,o)}}}a(c0,"nl");function u0(e){for(;!Dc(e););return e}a(u0,"rl");var jc=/[\0\t\n\r]/g;function h0(){let e=1,t="",n=!0,r;return i;function i(o,s,l){let c=[],u,h,d,p,f;for(o=t+(typeof o=="string"?o.toString():new TextDecoder(s||void 0).decode(o)),d=0,t="",n&&(o.charCodeAt(0)===65279&&d++,n=void 0);d<o.length;){if(jc.lastIndex=d,u=jc.exec(o),p=u&&u.index!==void 0?u.index:o.length,f=o.charCodeAt(p),!u){t=o.slice(d);break}if(f===10&&d===p&&r)c.push(-3),r=void 0;else switch(r&&(c.push(-5),r=void 0),d<p&&(c.push(o.slice(d,p)),e+=p-d),f){case 0:{c.push(65533),e++;break}case 9:{for(h=Math.ceil(e/4)*4,c.push(-2);e++<h;)c.push(-1);break}case 10:{c.push(-4),e=1;break}default:r=!0,e=1}d=p+1}return l&&(r&&c.push(-5),t&&c.push(t),c.push(null)),c}}a(h0,"il");var d0=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function _c(e){return e.replace(d0,p0)}a(_c,"xo");function p0(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let r=n.charCodeAt(1),i=r===120||r===88;return Cc(n.slice(i?2:1),i?16:10)}return jo(n)||e}a(p0,"Gb");function hr(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Hc(e.position):"start"in e||"end"in e?Hc(e):"line"in e||"column"in e?Jo(e):""}a(hr,"qt");function Jo(e){return Wc(e&&e.line)+":"+Wc(e&&e.column)}a(Jo,"ol");function Hc(e){return Jo(e&&e.start)+"-"+Jo(e&&e.end)}a(Hc,"zf");function Wc(e){return e&&typeof e=="number"?e:1}a(Wc,"Bf");var qc={}.hasOwnProperty;function f0(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),m0(n)(u0(c0(n).document().write(h0()(e,t,!0))))}a(f0,"sl");function m0(e){let t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(mc),autolinkProtocol:$,autolinkEmail:$,atxHeading:o(dc),blockQuote:o(gt),characterEscape:$,characterReference:$,codeFenced:o(en),codeFencedFenceInfo:s,codeFencedFenceMeta:s,codeIndented:o(en,s),codeText:o(Sn,s),codeTextData:$,data:$,codeFlowValue:$,definition:o(Lo),definitionDestinationString:s,definitionLabelString:s,definitionTitleString:s,emphasis:o($m),hardBreakEscape:o(pc),hardBreakTrailing:o(pc),htmlFlow:o(fc,s),htmlFlowData:$,htmlText:o(fc,s),htmlTextData:$,image:o(Bm),label:s,link:o(mc),listItem:o(Vm),listItemValue:p,listOrdered:o(gc,d),listUnordered:o(gc),paragraph:o(jm),reference:w,referenceString:s,resourceDestinationString:s,resourceTitleString:s,setextHeading:o(dc),strong:o(_m),thematicBreak:o(Wm)},exit:{atxHeading:c(),atxHeadingSequence:D,autolink:c(),autolinkEmail:or,autolinkProtocol:he,blockQuote:c(),characterEscapeValue:b,characterReferenceMarkerHexadecimal:Zt,characterReferenceMarkerNumeric:Zt,characterReferenceValue:Fo,characterReference:bi,codeFenced:c(v),codeFencedFence:g,codeFencedFenceInfo:f,codeFencedFenceMeta:m,codeFlowValue:b,codeIndented:c(y),codeText:c(W),codeTextData:b,data:b,definition:c(),definitionDestinationString:A,definitionLabelString:N,definitionTitleString:x,emphasis:c(),hardBreakEscape:c(Y),hardBreakTrailing:c(Y),htmlFlow:c(R),htmlFlowData:b,htmlText:c(H),htmlTextData:b,image:c(le),label:st,labelText:tt,lineEnding:ue,link:c(oe),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:Pe,resourceDestinationString:k,resourceTitleString:je,resource:mt,setextHeading:c(F),setextHeadingLineSequence:I,setextHeadingText:M,strong:c(),thematicBreak:c()}};Kc(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(C){let T={type:"root",children:[]},B={stack:[T],tokenStack:[],config:t,enter:l,exit:u,buffer:s,resume:h,data:n},ee=[],ne=-1;for(;++ne<C.length;)if(C[ne][1].type==="listOrdered"||C[ne][1].type==="listUnordered")if(C[ne][0]==="enter")ee.push(ne);else{let lt=ee.pop();ne=i(C,lt,ne)}for(ne=-1;++ne<C.length;){let lt=t[C[ne][0]];qc.call(lt,C[ne][1].type)&&lt[C[ne][1].type].call(Object.assign({sliceSerialize:C[ne][2].sliceSerialize},B),C[ne][1])}if(B.tokenStack.length>0){let lt=B.tokenStack[B.tokenStack.length-1];(lt[1]||Jc).call(B,void 0,lt[0])}for(T.position={start:Pt(C.length>0?C[0][1].start:{line:1,column:1,offset:0}),end:Pt(C.length>0?C[C.length-2][1].end:{line:1,column:1,offset:0})},ne=-1;++ne<t.transforms.length;)T=t.transforms[ne](T)||T;return T}function i(C,T,B){let ee=T-1,ne=-1,lt=!1,Cn,yt,sr,lr;for(;++ee<=B;){let Fe=C[ee];switch(Fe[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Fe[0]==="enter"?ne++:ne--,lr=void 0;break}case"lineEndingBlank":{Fe[0]==="enter"&&(Cn&&!lr&&!ne&&!sr&&(sr=ee),lr=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:lr=void 0}if(!ne&&Fe[0]==="enter"&&Fe[1].type==="listItemPrefix"||ne===-1&&Fe[0]==="exit"&&(Fe[1].type==="listUnordered"||Fe[1].type==="listOrdered")){if(Cn){let Mn=ee;for(yt=void 0;Mn--;){let vt=C[Mn];if(vt[1].type==="lineEnding"||vt[1].type==="lineEndingBlank"){if(vt[0]==="exit")continue;yt&&(C[yt][1].type="lineEndingBlank",lt=!0),vt[1].type="lineEnding",yt=Mn}else if(!(vt[1].type==="linePrefix"||vt[1].type==="blockQuotePrefix"||vt[1].type==="blockQuotePrefixWhitespace"||vt[1].type==="blockQuoteMarker"||vt[1].type==="listItemIndent"))break}sr&&(!yt||sr<yt)&&(Cn._spread=!0),Cn.end=Object.assign({},yt?C[yt][1].start:Fe[1].end),C.splice(yt||ee,0,["exit",Cn,Fe[2]]),ee++,B++}if(Fe[1].type==="listItemPrefix"){let Mn={type:"listItem",_spread:!1,start:Object.assign({},Fe[1].start),end:void 0};Cn=Mn,C.splice(ee,0,["enter",Mn,Fe[2]]),ee++,B++,sr=void 0,lr=!0}}}return C[T][1]._spread=lt,B}function o(C,T){return B;function B(ee){l.call(this,C(ee),ee),T&&T.call(this,ee)}}function s(){this.stack.push({type:"fragment",children:[]})}function l(C,T,B){this.stack[this.stack.length-1].children.push(C),this.stack.push(C),this.tokenStack.push([T,B||void 0]),C.position={start:Pt(T.start),end:void 0}}function c(C){return T;function T(B){C&&C.call(this,B),u.call(this,B)}}function u(C,T){let B=this.stack.pop(),ee=this.tokenStack.pop();if(ee)ee[0].type!==C.type&&(T?T.call(this,C,ee[0]):(ee[1]||Jc).call(this,C,ee[0]));else throw new Error("Cannot close `"+C.type+"` ("+hr({start:C.start,end:C.end})+"): it\u2019s not open");B.position.end=Pt(C.end)}function h(){return Vo(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function p(C){if(this.data.expectingFirstListItemValue){let T=this.stack[this.stack.length-2];T.start=Number.parseInt(this.sliceSerialize(C),10),this.data.expectingFirstListItemValue=void 0}}function f(){let C=this.resume(),T=this.stack[this.stack.length-1];T.lang=C}function m(){let C=this.resume(),T=this.stack[this.stack.length-1];T.meta=C}function g(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function v(){let C=this.resume(),T=this.stack[this.stack.length-1];T.value=C.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function y(){let C=this.resume(),T=this.stack[this.stack.length-1];T.value=C.replace(/(\r?\n|\r)$/g,"")}function N(C){let T=this.resume(),B=this.stack[this.stack.length-1];B.label=T,B.identifier=nt(this.sliceSerialize(C)).toLowerCase()}function x(){let C=this.resume(),T=this.stack[this.stack.length-1];T.title=C}function A(){let C=this.resume(),T=this.stack[this.stack.length-1];T.url=C}function D(C){let T=this.stack[this.stack.length-1];if(!T.depth){let B=this.sliceSerialize(C).length;T.depth=B}}function M(){this.data.setextHeadingSlurpLineEnding=!0}function I(C){let T=this.stack[this.stack.length-1];T.depth=this.sliceSerialize(C).codePointAt(0)===61?1:2}function F(){this.data.setextHeadingSlurpLineEnding=void 0}function $(C){let T=this.stack[this.stack.length-1].children,B=T[T.length-1];(!B||B.type!=="text")&&(B=Hm(),B.position={start:Pt(C.start),end:void 0},T.push(B)),this.stack.push(B)}function b(C){let T=this.stack.pop();T.value+=this.sliceSerialize(C),T.position.end=Pt(C.end)}function ue(C){let T=this.stack[this.stack.length-1];if(this.data.atHardBreak){let B=T.children[T.children.length-1];B.position.end=Pt(C.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(T.type)&&($.call(this,C),b.call(this,C))}function Y(){this.data.atHardBreak=!0}function R(){let C=this.resume(),T=this.stack[this.stack.length-1];T.value=C}function H(){let C=this.resume(),T=this.stack[this.stack.length-1];T.value=C}function W(){let C=this.resume(),T=this.stack[this.stack.length-1];T.value=C}function oe(){let C=this.stack[this.stack.length-1];if(this.data.inReference){let T=this.data.referenceType||"shortcut";C.type+="Reference",C.referenceType=T,delete C.url,delete C.title}else delete C.identifier,delete C.label;this.data.referenceType=void 0}function le(){let C=this.stack[this.stack.length-1];if(this.data.inReference){let T=this.data.referenceType||"shortcut";C.type+="Reference",C.referenceType=T,delete C.url,delete C.title}else delete C.identifier,delete C.label;this.data.referenceType=void 0}function tt(C){let T=this.sliceSerialize(C),B=this.stack[this.stack.length-2];B.label=_c(T),B.identifier=nt(T).toLowerCase()}function st(){let C=this.stack[this.stack.length-1],T=this.resume(),B=this.stack[this.stack.length-1];if(this.data.inReference=!0,B.type==="link"){let ee=C.children;B.children=ee}else B.alt=T}function k(){let C=this.resume(),T=this.stack[this.stack.length-1];T.url=C}function je(){let C=this.resume(),T=this.stack[this.stack.length-1];T.title=C}function mt(){this.data.inReference=void 0}function w(){this.data.referenceType="collapsed"}function Pe(C){let T=this.resume(),B=this.stack[this.stack.length-1];B.label=T,B.identifier=nt(this.sliceSerialize(C)).toLowerCase(),this.data.referenceType="full"}function Zt(C){this.data.characterReferenceType=C.type}function Fo(C){let T=this.sliceSerialize(C),B=this.data.characterReferenceType,ee;B?(ee=Cc(T,B==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):ee=jo(T);let ne=this.stack[this.stack.length-1];ne.value+=ee}function bi(C){let T=this.stack.pop();T.position.end=Pt(C.end)}function he(C){b.call(this,C);let T=this.stack[this.stack.length-1];T.url=this.sliceSerialize(C)}function or(C){b.call(this,C);let T=this.stack[this.stack.length-1];T.url="mailto:"+this.sliceSerialize(C)}function gt(){return{type:"blockquote",children:[]}}function en(){return{type:"code",lang:null,meta:null,value:""}}function Sn(){return{type:"inlineCode",value:""}}function Lo(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function $m(){return{type:"emphasis",children:[]}}function dc(){return{type:"heading",depth:0,children:[]}}function pc(){return{type:"break"}}function fc(){return{type:"html",value:""}}function Bm(){return{type:"image",title:null,url:"",alt:null}}function mc(){return{type:"link",title:null,url:"",children:[]}}function gc(C){return{type:"list",ordered:C.type==="listOrdered",start:null,spread:C._spread,children:[]}}function Vm(C){return{type:"listItem",spread:C._spread,checked:null,children:[]}}function jm(){return{type:"paragraph",children:[]}}function _m(){return{type:"strong",children:[]}}function Hm(){return{type:"text",value:""}}function Wm(){return{type:"thematicBreak"}}}a(m0,"Yb");function Pt(e){return{line:e.line,column:e.column,offset:e.offset}}a(Pt,"Jt");function Kc(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?Kc(e,r):g0(e,r)}}a(Kc,"$f");function g0(e,t){let n;for(n in t)if(qc.call(t,n))switch(n){case"canContainEols":{let r=t[n];r&&e[n].push(...r);break}case"transforms":{let r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{let r=t[n];r&&Object.assign(e[n],r);break}}}a(g0,"Qb");function Jc(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+hr({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+hr({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+hr({start:t.start,end:t.end})+") is still open")}a(Jc,"Ff");function Ti(e){let t=this;t.parser=n;function n(r){return f0(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}a(n,"n")}a(Ti,"Ut");var Uc={}.hasOwnProperty;function y0(e,t){let n=t||{};function r(i,...o){let s=r.invalid,l=r.handlers;if(i&&Uc.call(i,e)){let c=String(i[e]);s=Uc.call(l,c)?l[c]:r.unknown}if(s)return s.call(this,i,...o)}return a(r,"r"),r.handlers=n.handlers||{},r.invalid=n.invalid,r.unknown=n.unknown,r}a(y0,"Hf");var v0={}.hasOwnProperty;function Gc(e,t){let n=-1,r;if(t.extensions)for(;++n<t.extensions.length;)Gc(e,t.extensions[n]);for(r in t)if(v0.call(t,r))switch(r){case"extensions":break;case"unsafe":{Qc(e[r],t[r]);break}case"join":{Qc(e[r],t[r]);break}case"handlers":{k0(e[r],t[r]);break}default:e.options[r]=t[r]}return e}a(Gc,"ll");function Qc(e,t){t&&e.push(...t)}a(Qc,"jf");function k0(e,t){t&&Object.assign(e,t)}a(k0,"Zb");function w0(e,t,n,r){let i=n.enter("blockquote"),o=n.createTracker(r);o.move("> "),o.shift(2);let s=n.indentLines(n.containerFlow(e,o.current()),b0);return i(),s}a(w0,"Kf");function b0(e,t,n){return">"+(n?"":" ")+e}a(b0,"ex");function Yc(e,t){return Xc(e,t.inConstruct,!0)&&!Xc(e,t.notInConstruct,!1)}a(Yc,"wo");function Xc(e,t,n){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}a(Xc,"Wf");function Zc(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
5
+ `&&Yc(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?"":" ";return`\\
6
+ `}a(Zc,"al");function x0(e,t){let n=String(e),r=n.indexOf(t),i=r,o=0,s=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===i?++o>s&&(s=o):o=1,i=r+t.length,r=n.indexOf(t,i);return s}a(x0,"qf");function Uo(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}a(Uo,"di");function S0(e){let t=e.options.fence||"`";if(t!=="`"&&t!=="~")throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}a(S0,"Jf");function C0(e,t,n,r){let i=S0(n),o=e.value||"",s=i==="`"?"GraveAccent":"Tilde";if(Uo(e,n)){let d=n.enter("codeIndented"),p=n.indentLines(o,M0);return d(),p}let l=n.createTracker(r),c=i.repeat(Math.max(x0(o,i)+1,3)),u=n.enter("codeFenced"),h=l.move(c);if(e.lang){let d=n.enter(`codeFencedLang${s}`);h+=l.move(n.safe(e.lang,{before:h,after:" ",encode:["`"],...l.current()})),d()}if(e.lang&&e.meta){let d=n.enter(`codeFencedMeta${s}`);h+=l.move(" "),h+=l.move(n.safe(e.meta,{before:h,after:`
7
+ `,encode:["`"],...l.current()})),d()}return h+=l.move(`
8
+ `),o&&(h+=l.move(o+`
9
+ `)),h+=l.move(c),u(),h}a(C0,"Uf");function M0(e,t,n){return(n?"":" ")+e}a(M0,"tx");function Go(e){let t=e.options.quote||'"';if(t!=='"'&&t!=="'")throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}a(Go,"dr");function N0(e,t,n,r){let i=Go(n),o=i==='"'?"Quote":"Apostrophe",s=n.enter("definition"),l=n.enter("label"),c=n.createTracker(r),u=c.move("[");return u+=c.move(n.safe(n.associationId(e),{before:u,after:"]",...c.current()})),u+=c.move("]: "),l(),!e.url||/[\0- \u007F]/.test(e.url)?(l=n.enter("destinationLiteral"),u+=c.move("<"),u+=c.move(n.safe(e.url,{before:u,after:">",...c.current()})),u+=c.move(">")):(l=n.enter("destinationRaw"),u+=c.move(n.safe(e.url,{before:u,after:e.title?" ":`
10
+ `,...c.current()}))),l(),e.title&&(l=n.enter(`title${o}`),u+=c.move(" "+i),u+=c.move(n.safe(e.title,{before:u,after:i,...c.current()})),u+=c.move(i),l()),s(),u}a(N0,"Gf");function O0(e){let t=e.options.emphasis||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}a(O0,"Yf");function Ft(e){return"&#x"+e.toString(16).toUpperCase()+";"}a(Ft,"We");function Ai(e,t,n){let r=Nn(e),i=Nn(t);return r===void 0?i===void 0?n==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}a(Ai,"pr"),eu.peek=T0;function eu(e,t,n,r){let i=O0(n),o=n.enter("emphasis"),s=n.createTracker(r),l=s.move(i),c=s.move(n.containerPhrasing(e,{after:i,before:l,...s.current()})),u=c.charCodeAt(0),h=Ai(r.before.charCodeAt(r.before.length-1),u,i);h.inside&&(c=Ft(u)+c.slice(1));let d=c.charCodeAt(c.length-1),p=Ai(r.after.charCodeAt(0),d,i);p.inside&&(c=c.slice(0,-1)+Ft(d));let f=s.move(i);return o(),n.attentionEncodeSurroundingInfo={after:p.outside,before:h.outside},l+c+f}a(eu,"cl");function T0(e,t,n){return n.options.emphasis||"*"}a(T0,"nx");var Ii=a((function(e){if(e==null)return D0;if(typeof e=="function")return Ei(e);if(typeof e=="object")return Array.isArray(e)?A0(e):I0(e);if(typeof e=="string")return E0(e);throw new Error("Expected function, string, or object as test")}),"Gt");function A0(e){let t=[],n=-1;for(;++n<e.length;)t[n]=Ii(e[n]);return Ei(r);function r(...i){let o=-1;for(;++o<t.length;)if(t[o].apply(this,i))return!0;return!1}}a(A0,"rx");function I0(e){let t=e;return Ei(n);function n(r){let i=r,o;for(o in e)if(i[o]!==t[o])return!1;return!0}}a(I0,"ix");function E0(e){return Ei(t);function t(n){return n&&n.type===e}}a(E0,"ox");function Ei(e){return t;function t(n,r,i){return!!(R0(n)&&e.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}a(Ei,"Co");function D0(){return!0}a(D0,"sx");function R0(e){return e!==null&&typeof e=="object"&&"type"in e}a(R0,"lx");var tu=[],z0=!0,Qo=!1,Di="skip";function Yo(e,t,n,r){let i;typeof t=="function"&&typeof n!="function"?(r=n,n=t):i=t;let o=Ii(i),s=r?-1:1;l(e,void 0,[])();function l(c,u,h){let d=c&&typeof c=="object"?c:{};if(typeof d.type=="string"){let f=typeof d.tagName=="string"?d.tagName:typeof d.name=="string"?d.name:void 0;Object.defineProperty(p,"name",{value:"node ("+(c.type+(f?"<"+f+">":""))+")"})}return p;function p(){let f=tu,m,g,v;if((!t||o(c,u,h[h.length-1]||void 0))&&(f=P0(n(c,h)),f[0]===Qo))return f;if("children"in c&&c.children){let y=c;if(y.children&&f[0]!==Di)for(g=(r?y.children.length:-1)+s,v=h.concat(y);g>-1&&g<y.children.length;){let N=y.children[g];if(m=l(N,g,v)(),m[0]===Qo)return m;g=typeof m[1]=="number"?m[1]:g+s}}return f}}a(l,"l")}a(Yo,"Sn");function P0(e){return Array.isArray(e)?e:typeof e=="number"?[z0,e]:e==null?tu:[e]}a(P0,"ax");function On(e,t,n,r){let i,o,s;typeof t=="function"&&typeof n!="function"?(o=void 0,s=t,i=n):(o=t,s=n,i=r),Yo(e,o,l,i);function l(c,u){let h=u[u.length-1],d=h?h.children.indexOf(c):void 0;return s(c,d,h)}a(l,"l")}a(On,"ut");function nu(e,t){let n=!1;return On(e,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,Qo}),!!((!e.depth||e.depth<3)&&Vo(e)&&(t.options.setext||n))}a(nu,"Mo");function F0(e,t,n,r){let i=Math.max(Math.min(6,e.depth||1),1),o=n.createTracker(r);if(nu(e,n)){let h=n.enter("headingSetext"),d=n.enter("phrasing"),p=n.containerPhrasing(e,{...o.current(),before:`
11
+ `,after:`
12
+ `});return d(),h(),p+`
13
+ `+(i===1?"=":"-").repeat(p.length-(Math.max(p.lastIndexOf("\r"),p.lastIndexOf(`
14
+ `))+1))}let s="#".repeat(i),l=n.enter("headingAtx"),c=n.enter("phrasing");o.move(s+" ");let u=n.containerPhrasing(e,{before:"# ",after:`
15
+ `,...o.current()});return/^[\t ]/.test(u)&&(u=Ft(u.charCodeAt(0))+u.slice(1)),u=u?s+" "+u:s,n.options.closeAtx&&(u+=" "+s),c(),l(),u}a(F0,"Xf"),ru.peek=L0;function ru(e){return e.value||""}a(ru,"ul");function L0(){return"<"}a(L0,"cx"),iu.peek=$0;function iu(e,t,n,r){let i=Go(n),o=i==='"'?"Quote":"Apostrophe",s=n.enter("image"),l=n.enter("label"),c=n.createTracker(r),u=c.move("![");return u+=c.move(n.safe(e.alt,{before:u,after:"]",...c.current()})),u+=c.move("]("),l(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(l=n.enter("destinationLiteral"),u+=c.move("<"),u+=c.move(n.safe(e.url,{before:u,after:">",...c.current()})),u+=c.move(">")):(l=n.enter("destinationRaw"),u+=c.move(n.safe(e.url,{before:u,after:e.title?" ":")",...c.current()}))),l(),e.title&&(l=n.enter(`title${o}`),u+=c.move(" "+i),u+=c.move(n.safe(e.title,{before:u,after:i,...c.current()})),u+=c.move(i),l()),u+=c.move(")"),s(),u}a(iu,"fl");function $0(){return"!"}a($0,"ux"),ou.peek=B0;function ou(e,t,n,r){let i=e.referenceType,o=n.enter("imageReference"),s=n.enter("label"),l=n.createTracker(r),c=l.move("!["),u=n.safe(e.alt,{before:c,after:"]",...l.current()});c+=l.move(u+"]["),s();let h=n.stack;n.stack=[],s=n.enter("reference");let d=n.safe(n.associationId(e),{before:c,after:"]",...l.current()});return s(),n.stack=h,o(),i==="full"||!u||u!==d?c+=l.move(d+"]"):i==="shortcut"?c=c.slice(0,-1):c+=l.move("]"),c}a(ou,"hl");function B0(){return"!"}a(B0,"fx"),su.peek=V0;function su(e,t,n){let r=e.value||"",i="`",o=-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+" ");++o<n.unsafe.length;){let s=n.unsafe[o],l=n.compilePattern(s),c;if(s.atBreak)for(;c=l.exec(r);){let u=c.index;r.charCodeAt(u)===10&&r.charCodeAt(u-1)===13&&u--,r=r.slice(0,u)+" "+r.slice(c.index+1)}}return i+r+i}a(su,"dl");function V0(){return"`"}a(V0,"hx");function lu(e,t){let n=Vo(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}a(lu,"pl"),au.peek=j0;function au(e,t,n,r){let i=Go(n),o=i==='"'?"Quote":"Apostrophe",s=n.createTracker(r),l,c;if(lu(e,n)){let h=n.stack;n.stack=[],l=n.enter("autolink");let d=s.move("<");return d+=s.move(n.containerPhrasing(e,{before:d,after:">",...s.current()})),d+=s.move(">"),l(),n.stack=h,d}l=n.enter("link"),c=n.enter("label");let u=s.move("[");return u+=s.move(n.containerPhrasing(e,{before:u,after:"](",...s.current()})),u+=s.move("]("),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter("destinationLiteral"),u+=s.move("<"),u+=s.move(n.safe(e.url,{before:u,after:">",...s.current()})),u+=s.move(">")):(c=n.enter("destinationRaw"),u+=s.move(n.safe(e.url,{before:u,after:e.title?" ":")",...s.current()}))),c(),e.title&&(c=n.enter(`title${o}`),u+=s.move(" "+i),u+=s.move(n.safe(e.title,{before:u,after:i,...s.current()})),u+=s.move(i),c()),u+=s.move(")"),l(),u}a(au,"ml");function j0(e,t,n){return lu(e,n)?"<":"["}a(j0,"dx"),cu.peek=_0;function cu(e,t,n,r){let i=e.referenceType,o=n.enter("linkReference"),s=n.enter("label"),l=n.createTracker(r),c=l.move("["),u=n.containerPhrasing(e,{before:c,after:"]",...l.current()});c+=l.move(u+"]["),s();let h=n.stack;n.stack=[],s=n.enter("reference");let d=n.safe(n.associationId(e),{before:c,after:"]",...l.current()});return s(),n.stack=h,o(),i==="full"||!u||u!==d?c+=l.move(d+"]"):i==="shortcut"?c=c.slice(0,-1):c+=l.move("]"),c}a(cu,"gl");function _0(){return"["}a(_0,"px");function Xo(e){let t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}a(Xo,"mr");function H0(e){let t=Xo(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}a(H0,"Zf");function W0(e){let t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}a(W0,"eh");function uu(e){let t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}a(uu,"No");function q0(e,t,n,r){let i=n.enter("list"),o=n.bulletCurrent,s=e.ordered?W0(n):Xo(n),l=e.ordered?s==="."?")":".":H0(n),c=t&&n.bulletLastUsed?s===n.bulletLastUsed:!1;if(!e.ordered){let h=e.children?e.children[0]:void 0;if((s==="*"||s==="-")&&h&&(!h.children||!h.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),uu(n)===s&&h){let d=-1;for(;++d<e.children.length;){let p=e.children[d];if(p&&p.type==="listItem"&&p.children&&p.children[0]&&p.children[0].type==="thematicBreak"){c=!0;break}}}}c&&(s=l),n.bulletCurrent=s;let u=n.containerFlow(e,r);return n.bulletLastUsed=s,n.bulletCurrent=o,i(),u}a(q0,"th");function K0(e){let t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}a(K0,"nh");function J0(e,t,n,r){let i=K0(n),o=n.bulletCurrent||Xo(n);t&&t.type==="list"&&t.ordered&&(o=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+o);let s=o.length+1;(i==="tab"||i==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(s=Math.ceil(s/4)*4);let l=n.createTracker(r);l.move(o+" ".repeat(s-o.length)),l.shift(s);let c=n.enter("listItem"),u=n.indentLines(n.containerFlow(e,l.current()),h);return c(),u;function h(d,p,f){return p?(f?"":" ".repeat(s))+d:(f?o:o+" ".repeat(s-o.length))+d}}a(J0,"rh");function U0(e,t,n,r){let i=n.enter("paragraph"),o=n.enter("phrasing"),s=n.containerPhrasing(e,r);return o(),i(),s}a(U0,"ih");var G0=Ii(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function Q0(e,t,n,r){return(e.children.some(function(i){return G0(i)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}a(Q0,"oh");function Y0(e){let t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}a(Y0,"sh"),hu.peek=X0;function hu(e,t,n,r){let i=Y0(n),o=n.enter("strong"),s=n.createTracker(r),l=s.move(i+i),c=s.move(n.containerPhrasing(e,{after:i,before:l,...s.current()})),u=c.charCodeAt(0),h=Ai(r.before.charCodeAt(r.before.length-1),u,i);h.inside&&(c=Ft(u)+c.slice(1));let d=c.charCodeAt(c.length-1),p=Ai(r.after.charCodeAt(0),d,i);p.inside&&(c=c.slice(0,-1)+Ft(d));let f=s.move(i+i);return o(),n.attentionEncodeSurroundingInfo={after:p.outside,before:h.outside},l+c+f}a(hu,"kl");function X0(e,t,n){return n.options.strong||"*"}a(X0,"mx");function Z0(e,t,n,r){return n.safe(e.value,r)}a(Z0,"lh");function e1(e){let t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}a(e1,"ah");function t1(e,t,n){let r=(uu(n)+(n.options.ruleSpaces?" ":"")).repeat(e1(n));return n.options.ruleSpaces?r.slice(0,-1):r}a(t1,"ch");var Zo={blockquote:w0,break:Zc,code:C0,definition:N0,emphasis:eu,hardBreak:Zc,heading:F0,html:ru,image:iu,imageReference:ou,inlineCode:su,link:au,linkReference:cu,list:q0,listItem:J0,paragraph:U0,root:Q0,strong:hu,text:Z0,thematicBreak:t1},n1=[r1];function r1(e,t,n,r){if(t.type==="code"&&Uo(t,r)&&(e.type==="list"||e.type===t.type&&Uo(e,r)))return!1;if("spread"in n&&typeof n.spread=="boolean")return e.type==="paragraph"&&(e.type===t.type||t.type==="definition"||t.type==="heading"&&nu(t,r))?void 0:n.spread?1:0}a(r1,"gx");var nn=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"],i1=[{character:" ",after:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",before:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde"]},{character:"\r",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde","codeFencedMetaGraveAccent","codeFencedMetaTilde","destinationLiteral","headingAtx"]},{character:`
16
+ `,inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde","codeFencedMetaGraveAccent","codeFencedMetaTilde","destinationLiteral","headingAtx"]},{character:" ",after:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",before:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde"]},{character:"!",after:"\\[",inConstruct:"phrasing",notInConstruct:nn},{character:'"',inConstruct:"titleQuote"},{atBreak:!0,character:"#"},{character:"#",inConstruct:"headingAtx",after:`(?:[\r
17
+ ]|$)`},{character:"&",after:"[#A-Za-z]",inConstruct:"phrasing"},{character:"'",inConstruct:"titleApostrophe"},{character:"(",inConstruct:"destinationRaw"},{before:"\\]",character:"(",inConstruct:"phrasing",notInConstruct:nn},{atBreak:!0,before:"\\d+",character:")"},{character:")",inConstruct:"destinationRaw"},{atBreak:!0,character:"*",after:`(?:[ \r
18
+ *])`},{character:"*",inConstruct:"phrasing",notInConstruct:nn},{atBreak:!0,character:"+",after:`(?:[ \r
19
+ ])`},{atBreak:!0,character:"-",after:`(?:[ \r
20
+ -])`},{atBreak:!0,before:"\\d+",character:".",after:`(?:[ \r
21
+ ]|$)`},{atBreak:!0,character:"<",after:"[!/?A-Za-z]"},{character:"<",after:"[!/?A-Za-z]",inConstruct:"phrasing",notInConstruct:nn},{character:"<",inConstruct:"destinationLiteral"},{atBreak:!0,character:"="},{atBreak:!0,character:">"},{character:">",inConstruct:"destinationLiteral"},{atBreak:!0,character:"["},{character:"[",inConstruct:"phrasing",notInConstruct:nn},{character:"[",inConstruct:["label","reference"]},{character:"\\",after:"[\\r\\n]",inConstruct:"phrasing"},{character:"]",inConstruct:["label","reference"]},{atBreak:!0,character:"_"},{character:"_",inConstruct:"phrasing",notInConstruct:nn},{atBreak:!0,character:"`"},{character:"`",inConstruct:["codeFencedLangGraveAccent","codeFencedMetaGraveAccent"]},{character:"`",inConstruct:"phrasing",notInConstruct:nn},{atBreak:!0,character:"~"}];function o1(e){return e.label||!e.identifier?e.label||"":_c(e.identifier)}a(o1,"hh");function s1(e){if(!e._compiled){let t=(e.atBreak?"[\\r\\n][\\t ]*":"")+(e.before?"(?:"+e.before+")":"");e._compiled=new RegExp((t?"("+t+")":"")+(/[|\\{}()[\]^$+*?.-]/.test(e.character)?"\\":"")+e.character+(e.after?"(?:"+e.after+")":""),"g")}return e._compiled}a(s1,"dh");function l1(e,t,n){let r=t.indexStack,i=e.children||[],o=[],s=-1,l=n.before,c;r.push(-1);let u=t.createTracker(n);for(;++s<i.length;){let h=i[s],d;if(r[r.length-1]=s,s+1<i.length){let m=t.handle.handlers[i[s+1].type];m&&m.peek&&(m=m.peek),d=m?m(i[s+1],e,t,{before:"",after:"",...u.current()}).charAt(0):""}else d=n.after;o.length>0&&(l==="\r"||l===`
22
+ `)&&h.type==="html"&&(o[o.length-1]=o[o.length-1].replace(/(\r?\n|\r)$/," "),l=" ",u=t.createTracker(n),u.move(o.join("")));let p=t.handle(h,e,t,{...u.current(),after:d,before:l});c&&c===p.slice(0,1)&&(p=Ft(c.charCodeAt(0))+p.slice(1));let f=t.attentionEncodeSurroundingInfo;t.attentionEncodeSurroundingInfo=void 0,c=void 0,f&&(o.length>0&&f.before&&l===o[o.length-1].slice(-1)&&(o[o.length-1]=o[o.length-1].slice(0,-1)+Ft(l.charCodeAt(0))),f.after&&(c=d)),u.move(p),o.push(p),l=p.slice(-1)}return r.pop(),o.join("")}a(l1,"ph");function a1(e,t,n){let r=t.indexStack,i=e.children||[],o=t.createTracker(n),s=[],l=-1;for(r.push(-1);++l<i.length;){let c=i[l];r[r.length-1]=l,s.push(o.move(t.handle(c,e,t,{before:`
23
+ `,after:`
24
+ `,...o.current()}))),c.type!=="list"&&(t.bulletLastUsed=void 0),l<i.length-1&&s.push(o.move(c1(c,i[l+1],e,t)))}return r.pop(),s.join("")}a(a1,"mh");function c1(e,t,n,r){let i=r.join.length;for(;i--;){let o=r.join[i](e,t,n,r);if(o===!0||o===1)break;if(typeof o=="number")return`
25
+ `.repeat(1+o);if(o===!1)return`
26
+
27
+ <!---->
28
+
29
+ `}return`
30
+
31
+ `}a(c1,"yx");var u1=/\r?\n|\r/g;function h1(e,t){let n=[],r=0,i=0,o;for(;o=u1.exec(e);)s(e.slice(r,o.index)),n.push(o[0]),r=o.index+o[0].length,i++;return s(e.slice(r)),n.join("");function s(l){n.push(t(l,i,!l))}}a(h1,"gh");function d1(e,t,n){let r=(n.before||"")+(t||"")+(n.after||""),i=[],o=[],s={},l=-1;for(;++l<e.unsafe.length;){let h=e.unsafe[l];if(!Yc(e.stack,h))continue;let d=e.compilePattern(h),p;for(;p=d.exec(r);){let f="before"in h||!!h.atBreak,m="after"in h,g=p.index+(f?p[1].length:0);i.includes(g)?(s[g].before&&!f&&(s[g].before=!1),s[g].after&&!m&&(s[g].after=!1)):(i.push(g),s[g]={before:f,after:m})}}i.sort(p1);let c=n.before?n.before.length:0,u=r.length-(n.after?n.after.length:0);for(l=-1;++l<i.length;){let h=i[l];h<c||h>=u||h+1<u&&i[l+1]===h+1&&s[h].after&&!s[h+1].before&&!s[h+1].after||i[l-1]===h-1&&s[h].before&&!s[h-1].before&&!s[h-1].after||(c!==h&&o.push(du(r.slice(c,h),"\\")),c=h,/[!-/:-@[-`{-~]/.test(r.charAt(h))&&(!n.encode||!n.encode.includes(r.charAt(h)))?o.push("\\"):(o.push(Ft(r.charCodeAt(h))),c++))}return o.push(du(r.slice(c,u),n.after)),o.join("")}a(d1,"kh");function p1(e,t){return e-t}a(p1,"bx");function du(e,t){let n=/\\(?=[!-/:-@[-`{-~])/g,r=[],i=[],o=e+t,s=-1,l=0,c;for(;c=n.exec(o);)r.push(c.index);for(;++s<r.length;)l!==r[s]&&i.push(e.slice(l,r[s])),i.push("\\"),l=r[s];return i.push(e.slice(l)),i.join("")}a(du,"yh");function f1(e){let t=e||{},n=t.now||{},r=t.lineShift||0,i=n.line||1,o=n.column||1;return{move:c,current:s,shift:l};function s(){return{now:{line:i,column:o},lineShift:r}}function l(u){r+=u}function c(u){let h=u||"",d=h.split(/\r?\n|\r/g),p=d[d.length-1];return i+=d.length-1,o=d.length===1?o+p.length:1+p.length+r,h}}a(f1,"bh");function m1(e,t){let n=t||{},r={associationId:o1,containerPhrasing:k1,containerFlow:w1,createTracker:f1,compilePattern:s1,enter:o,handlers:{...Zo},handle:void 0,indentLines:h1,indexStack:[],join:[...n1],options:{},safe:b1,stack:[],unsafe:[...i1]};Gc(r,n),r.options.tightDefinitions&&r.join.push(v1),r.handle=y0("type",{invalid:g1,unknown:y1,handlers:r.handlers});let i=r.handle(e,void 0,r,{before:`
32
+ `,after:`
33
+ `,now:{line:1,column:1},lineShift:0});return i&&i.charCodeAt(i.length-1)!==10&&i.charCodeAt(i.length-1)!==13&&(i+=`
34
+ `),i;function o(s){return r.stack.push(s),l;function l(){r.stack.pop()}}}a(m1,"bl");function g1(e){throw new Error("Cannot handle value `"+e+"`, expected node")}a(g1,"xx");function y1(e){let t=e;throw new Error("Cannot handle unknown node `"+t.type+"`")}a(y1,"wx");function v1(e,t){if(e.type==="definition"&&e.type===t.type)return 0}a(v1,"Cx");function k1(e,t){return l1(e,this,t)}a(k1,"Sx");function w1(e,t){return a1(e,this,t)}a(w1,"Mx");function b1(e,t){return d1(this,e,t)}a(b1,"Nx");function es(e){let t=this;t.compiler=n;function n(r){return m1(r,{...t.data("settings"),...e,extensions:t.data("toMarkdownExtensions")||[]})}a(n,"n")}a(es,"gr");function pu(e){if(e)throw e}a(pu,"xl");var ts=eg(tg(),1);function ns(e){if(typeof e!="object"||e===null)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}a(ns,"pi");function x1(){let e=[],t={run:n,use:r};return t;function n(...i){let o=-1,s=i.pop();if(typeof s!="function")throw new TypeError("Expected function as last argument, not "+s);l(null,...i);function l(c,...u){let h=e[++o],d=-1;if(c){s(c);return}for(;++d<i.length;)(u[d]===null||u[d]===void 0)&&(u[d]=i[d]);i=u,h?S1(h,l)(...u):s(null,...u)}a(l,"l")}function r(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return e.push(i),t}}a(x1,"wl");function S1(e,t){let n;return r;function r(...s){let l=e.length>s.length,c;l&&s.push(i);try{c=e.apply(this,s)}catch(u){let h=u;if(l&&n)throw h;return i(h)}l||(c&&c.then&&typeof c.then=="function"?c.then(o,i):c instanceof Error?i(c):o(c))}function i(s,...l){n||(n=!0,t(s,...l))}function o(s){i(null,s)}}a(S1,"Ah");var Ee=class extends Error{static{a(this,"ge")}constructor(e,t,n){super(),typeof t=="string"&&(n=t,t=void 0);let r="",i={},o=!1;if(t&&("line"in t&&"column"in t?i={place:t}:"start"in t&&"end"in t?i={place:t}:"type"in t?i={ancestors:[t],place:t.position}:i={...t}),typeof e=="string"?r=e:!i.cause&&e&&(o=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n=="string"){let l=n.indexOf(":");l===-1?i.ruleId=n:(i.source=n.slice(0,l),i.ruleId=n.slice(l+1))}if(!i.place&&i.ancestors&&i.ancestors){let l=i.ancestors[i.ancestors.length-1];l&&(i.place=l.position)}let s=i.place&&"start"in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=s?s.column:void 0,this.fatal=void 0,this.file="",this.message=r,this.line=s?s.line:void 0,this.name=hr(i.place)||"1:1",this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=o&&i.cause&&typeof i.cause.stack=="string"?i.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};Ee.prototype.file="",Ee.prototype.name="",Ee.prototype.reason="",Ee.prototype.message="",Ee.prototype.stack="",Ee.prototype.column=void 0,Ee.prototype.line=void 0,Ee.prototype.ancestors=void 0,Ee.prototype.cause=void 0,Ee.prototype.fatal=void 0,Ee.prototype.place=void 0,Ee.prototype.ruleId=void 0,Ee.prototype.source=void 0;var ut={basename:C1,dirname:M1,extname:N1,join:O1,sep:"/"};function C1(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');dr(e);let n=0,r=-1,i=e.length,o;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(o){n=i+1;break}}else r<0&&(o=!0,r=i+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let s=-1,l=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(o){n=i+1;break}}else s<0&&(o=!0,s=i+1),l>-1&&(e.codePointAt(i)===t.codePointAt(l--)?l<0&&(r=i):(l=-1,r=s));return n===r?r=s:r<0&&(r=e.length),e.slice(n,r)}a(C1,"vx");function M1(e){if(dr(e),e.length===0)return".";let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}a(M1,"Tx");function N1(e){dr(e);let t=e.length,n=-1,r=0,i=-1,o=0,s;for(;t--;){let l=e.codePointAt(t);if(l===47){if(s){r=t+1;break}continue}n<0&&(s=!0,n=t+1),l===46?i<0?i=t:o!==1&&(o=1):i>-1&&(o=-1)}return i<0||n<0||o===0||o===1&&i===n-1&&i===r+1?"":e.slice(i,n)}a(N1,"Ix");function O1(...e){let t=-1,n;for(;++t<e.length;)dr(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":T1(n)}a(O1,"Ax");function T1(e){dr(e);let t=e.codePointAt(0)===47,n=A1(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}a(T1,"Ex");function A1(e,t){let n="",r=0,i=-1,o=0,s=-1,l,c;for(;++s<=e.length;){if(s<e.length)l=e.codePointAt(s);else{if(l===47)break;l=47}if(l===47){if(!(i===s-1||o===1))if(i!==s-1&&o===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf("/"),c!==n.length-1){c<0?(n="",r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf("/")),i=s,o=0;continue}}else if(n.length>0){n="",r=0,i=s,o=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(i+1,s):n=e.slice(i+1,s),r=s-i-1;i=s,o=0}else l===46&&o>-1?o++:o=-1}return n}a(A1,"Ox");function dr(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}a(dr,"mi");var I1={cwd:E1};function E1(){return"/"}a(E1,"Rx");function rs(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}a(rs,"yr");function D1(e){if(typeof e=="string")e=new URL(e);else if(!rs(e)){let t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){let t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return R1(e)}a(D1,"Oh");function R1(e){if(e.hostname!==""){let r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let r=t.codePointAt(n+2);if(r===70||r===102){let i=new TypeError("File URL path must not include encoded / characters");throw i.code="ERR_INVALID_FILE_URL_PATH",i}}return decodeURIComponent(t)}a(R1,"Dx");var is=["history","path","basename","stem","extname","dirname"],z1=class{static{a(this,"gi")}constructor(e){let t;e?rs(e)?t={path:e}:typeof e=="string"||P1(e)?t={value:e}:t=e:t={},this.cwd="cwd"in t?"":I1.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<is.length;){let i=is[n];i in t&&t[i]!==void 0&&t[i]!==null&&(this[i]=i==="history"?[...t[i]]:t[i])}let r;for(r in t)is.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path=="string"?ut.basename(this.path):void 0}set basename(e){ls(e,"basename"),ss(e,"basename"),this.path=ut.join(this.dirname||"",e)}get dirname(){return typeof this.path=="string"?ut.dirname(this.path):void 0}set dirname(e){fu(this.basename,"dirname"),this.path=ut.join(e||"",this.basename)}get extname(){return typeof this.path=="string"?ut.extname(this.path):void 0}set extname(e){if(ss(e,"extname"),fu(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=ut.join(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){rs(e)&&(e=D1(e)),ls(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path=="string"?ut.basename(this.path,this.extname):void 0}set stem(e){ls(e,"stem"),ss(e,"stem"),this.path=ut.join(this.dirname||"",e+(this.extname||""))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new Ee(e,t,n);return this.path&&(r.name=this.path+":"+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(e||void 0).decode(this.value)}};function ss(e,t){if(e&&e.includes(ut.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+ut.sep+"`")}a(ss,"Sl");function ls(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}a(ls,"Ml");function fu(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}a(fu,"Rh");function P1(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}a(P1,"Px");var F1=a((function(e){let t=this.constructor.prototype,n=t[e],r=a(function(){return n.apply(r,arguments)},"o");return Object.setPrototypeOf(r,t),r}),"Dh"),L1={}.hasOwnProperty,$1=class bm extends F1{static{a(this,"t")}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=x1()}copy(){let t=new bm,n=-1;for(;++n<this.attachers.length;){let r=this.attachers[n];t.use(...r)}return t.data((0,ts.default)(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(us("data",this.frozen),this.namespace[t]=n,this):L1.call(this.namespace,t)&&this.namespace[t]||void 0:t?(us("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;let t=this;for(;++this.freezeIndex<this.attachers.length;){let[n,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);let i=n.call(t,...r);typeof i=="function"&&this.transformers.use(i)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();let n=zi(t),r=this.parser||this.Parser;return as("parse",r),r(String(n),n)}process(t,n){let r=this;return this.freeze(),as("process",this.parser||this.Parser),cs("process",this.compiler||this.Compiler),n?i(void 0,n):new Promise(i);function i(o,s){let l=zi(t),c=r.parse(l);r.run(c,l,function(h,d,p){if(h||!d||!p)return u(h);let f=d,m=r.stringify(f,p);V1(m)?p.value=m:p.result=m,u(h,p)});function u(h,d){h||!d?s(h):o?o(d):n(void 0,d)}a(u,"c")}}processSync(t){let n=!1,r;return this.freeze(),as("processSync",this.parser||this.Parser),cs("processSync",this.compiler||this.Compiler),this.process(t,i),gu("processSync","process",n),r;function i(o,s){n=!0,pu(o),r=s}}run(t,n,r){mu(t),this.freeze();let i=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?o(void 0,r):new Promise(o);function o(s,l){let c=zi(n);i.run(t,c,u);function u(h,d,p){let f=d||t;h?l(h):s?s(f):r(void 0,f,p)}a(u,"c")}}runSync(t,n){let r=!1,i;return this.run(t,n,o),gu("runSync","run",r),i;function o(s,l){pu(s),i=l,r=!0}}stringify(t,n){this.freeze();let r=zi(n),i=this.compiler||this.Compiler;return cs("stringify",i),mu(t),i(t,r)}use(t,...n){let r=this.attachers,i=this.namespace;if(us("use",this.frozen),t!=null)if(typeof t=="function")c(t,n);else if(typeof t=="object")Array.isArray(t)?l(t):s(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function o(u){if(typeof u=="function")c(u,[]);else if(typeof u=="object")if(Array.isArray(u)){let[h,...d]=u;c(h,d)}else s(u);else throw new TypeError("Expected usable value, not `"+u+"`")}function s(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=(0,ts.default)(!0,i.settings,u.settings))}function l(u){let h=-1;if(u!=null)if(Array.isArray(u))for(;++h<u.length;){let d=u[h];o(d)}else throw new TypeError("Expected a list of plugins, not `"+u+"`")}function c(u,h){let d=-1,p=-1;for(;++d<r.length;)if(r[d][0]===u){p=d;break}if(p===-1)r.push([u,...h]);else if(h.length>0){let[f,...m]=h,g=r[p][1];ns(g)&&ns(f)&&(f=(0,ts.default)(!0,g,f)),r[p]=[u,f,...m]}}}},Ri=new $1().freeze();function as(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}a(as,"Nl");function cs(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}a(cs,"vl");function us(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}a(us,"Tl");function mu(e){if(!ns(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}a(mu,"Ph");function gu(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}a(gu,"Lh");function zi(e){return B1(e)?e:new z1(e)}a(zi,"To");function B1(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}a(B1,"zx");function V1(e){return typeof e=="string"||j1(e)}a(V1,"Bx");function j1(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}a(j1,"Fx");function me(e){this.content=e}a(me,"Ee"),me.prototype={constructor:me,find:a(function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},"find"),get:a(function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},"get"),update:a(function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),o=r.content.slice();return i==-1?o.push(n||e,t):(o[i+1]=t,n&&(o[i]=n)),new me(o)},"update"),remove:a(function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new me(n)},"remove"),addToStart:a(function(e,t){return new me([e,t].concat(this.remove(e).content))},"addToStart"),addToEnd:a(function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new me(n)},"addToEnd"),addBefore:a(function(e,t,n){var r=this.remove(t),i=r.content.slice(),o=r.find(e);return i.splice(o==-1?i.length:o,0,t,n),new me(i)},"addBefore"),forEach:a(function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},"forEach"),prepend:a(function(e){return e=me.from(e),e.size?new me(e.content.concat(this.subtract(e).content)):this},"prepend"),append:a(function(e){return e=me.from(e),e.size?new me(this.subtract(e).content.concat(e.content)):this},"append"),subtract:a(function(e){var t=this;e=me.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},"subtract"),toObject:a(function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},"toObject"),get size(){return this.content.length>>1}},me.from=function(e){if(e instanceof me)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new me(t)};var yu=me;function vu(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),o=t.child(r);if(i==o){n+=i.nodeSize;continue}if(!i.sameMarkup(o))return n;if(i.isText&&i.text!=o.text){let s=i.text,l=o.text,c=0;for(;s[c]==l[c];c++)n++;return c&&c<s.length&&c<l.length&&bu(s.charCodeAt(c-1))&&wu(s.charCodeAt(c))&&n--,n}if(i.content.size||o.content.size){let s=vu(i.content,o.content,n+1);if(s!=null)return s}n+=i.nodeSize}}a(vu,"qh");function ku(e,t,n,r){for(let i=e.childCount,o=t.childCount;;){if(i==0||o==0)return i==o?null:{a:n,b:r};let s=e.child(--i),l=t.child(--o),c=s.nodeSize;if(s==l){n-=c,r-=c;continue}if(!s.sameMarkup(l))return{a:n,b:r};if(s.isText&&s.text!=l.text){let u=s.text,h=l.text,d=u.length,p=h.length;for(;d>0&&p>0&&u[d-1]==h[p-1];)d--,p--,n--,r--;return d&&p&&d<u.length&&bu(u.charCodeAt(d-1))&&wu(u.charCodeAt(d))&&(n++,r++),{a:n,b:r}}if(s.content.size||l.content.size){let u=ku(s.content,l.content,n-1,r-1);if(u)return u}n-=c,r-=c}}a(ku,"Jh");function wu(e){return e>=56320&&e<57344}a(wu,"Uh");function bu(e){return e>=55296&&e<56320}a(bu,"Gh");var O=class Te{static{a(this,"t")}constructor(t,n){if(this.content=t,this.size=n||0,n==null)for(let r=0;r<t.length;r++)this.size+=t[r].nodeSize}nodesBetween(t,n,r,i=0,o){for(let s=0,l=0;l<n;s++){let c=this.content[s],u=l+c.nodeSize;if(u>t&&r(c,i+l,o||null,s)!==!1&&c.content.size){let h=l+1;c.nodesBetween(Math.max(0,t-h),Math.min(c.content.size,n-h),r,i+h)}l=u}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,n,r,i){let o="",s=!0;return this.nodesBetween(t,n,(l,c)=>{let u=l.isText?l.text.slice(Math.max(t,c)-c,n-c):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&&(s?s=!1:o+=r),o+=u},0),o}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),o=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),o=1);o<t.content.length;o++)i.push(t.content[o]);return new Te(i,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],i=0;if(n>t)for(let o=0,s=0;s<n;o++){let l=this.content[o],c=s+l.nodeSize;c>t&&((s<t||c>n)&&(l.isText?l=l.cut(Math.max(0,t-s),Math.min(l.text.length,n-s)):l=l.cut(Math.max(0,t-s-1),Math.min(l.content.size,n-s-1))),r.push(l),i+=l.nodeSize),s=c}return new Te(r,i)}cutByIndex(t,n){return t==n?Te.empty:t==0&&n==this.content.length?this:new Te(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),o=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new Te(i,o)}addToStart(t){return new Te([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new Te(this.content.concat(t),this.size+t.nodeSize)}eq(t){if(this.content.length!=t.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(t.content[n]))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(t){let n=this.content[t];if(!n)throw new RangeError("Index "+t+" out of range for "+this);return n}maybeChild(t){return this.content[t]||null}forEach(t){for(let n=0,r=0;n<this.content.length;n++){let i=this.content[n];t(i,r,n),r+=i.nodeSize}}findDiffStart(t,n=0){return vu(this,t,n)}findDiffEnd(t,n=this.size,r=t.size){return ku(this,t,n,r)}findIndex(t){if(t==0)return Pi(0,t);if(t==this.size)return Pi(this.content.length,t);if(t>this.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let n=0,r=0;;n++){let i=this.child(n),o=r+i.nodeSize;if(o>=t)return o==t?Pi(n+1,o):Pi(n,r);r=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(t=>t.toJSON()):null}static fromJSON(t,n){if(!n)return Te.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return Te.fromArray(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return Te.empty;let n,r=0;for(let i=0;i<t.length;i++){let o=t[i];r+=o.nodeSize,i&&o.isText&&t[i-1].sameMarkup(o)?(n||(n=t.slice(0,i)),n[n.length-1]=o.withText(n[n.length-1].text+o.text)):n&&n.push(o)}return new Te(n||t,r)}static from(t){if(!t)return Te.empty;if(t instanceof Te)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new Te([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}};O.empty=new O([],0);var hs={index:0,offset:0};function Pi(e,t){return hs.index=e,hs.offset=t,hs}a(Pi,"Ao");function Fi(e,t){if(e===t)return!0;if(!(e&&typeof e=="object")||!(t&&typeof t=="object"))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!Fi(e[r],t[r]))return!1}else{for(let r in e)if(!(r in t)||!Fi(e[r],t[r]))return!1;for(let r in t)if(!(r in e))return!1}return!0}a(Fi,"Ro");var X=class nc{static{a(this,"t")}constructor(t,n){this.type=t,this.attrs=n}addToSet(t){let n,r=!1;for(let i=0;i<t.length;i++){let o=t[i];if(this.eq(o))return t;if(this.type.excludes(o.type))n||(n=t.slice(0,i));else{if(o.type.excludes(this.type))return t;!r&&o.type.rank>this.type.rank&&(n||(n=t.slice(0,i)),n.push(this),r=!0),n&&n.push(o)}}return n||(n=t.slice()),r||n.push(this),n}removeFromSet(t){for(let n=0;n<t.length;n++)if(this.eq(t[n]))return t.slice(0,n).concat(t.slice(n+1));return t}isInSet(t){for(let n=0;n<t.length;n++)if(this.eq(t[n]))return!0;return!1}eq(t){return this==t||this.type==t.type&&Fi(this.attrs,t.attrs)}toJSON(){let t={type:this.type.name};for(let n in this.attrs){t.attrs=this.attrs;break}return t}static fromJSON(t,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=t.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);return r.create(n.attrs)}static sameSet(t,n){if(t==n)return!0;if(t.length!=n.length)return!1;for(let r=0;r<t.length;r++)if(!t[r].eq(n[r]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return nc.none;if(t instanceof nc)return[t];let n=t.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};X.none=[];var pr=class extends Error{static{a(this,"Yt")}},E=class tr{static{a(this,"t")}constructor(t,n,r){this.content=t,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=Su(this.content,t+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new tr(r,this.openStart,this.openEnd)}removeBetween(t,n){return new tr(xu(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let t={content:this.content.toJSON()};return this.openStart>0&&(t.openStart=this.openStart),this.openEnd>0&&(t.openEnd=this.openEnd),t}static fromJSON(t,n){if(!n)return tr.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new tr(O.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let o=t.firstChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.firstChild)r++;for(let o=t.lastChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.lastChild)i++;return new tr(t,r,i)}};E.empty=new E(O.empty,0,0);function xu(e,t,n){let{index:r,offset:i}=e.findIndex(t),o=e.maybeChild(r),{index:s,offset:l}=e.findIndex(n);if(i==t||o.isText){if(l!=n&&!e.child(s).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(n))}if(r!=s)throw new RangeError("Removing non-flat range");return e.replaceChild(r,o.copy(xu(o.content,t-i-1,n-i-1)))}a(xu,"Yh");function Su(e,t,n,r,i,o){let{index:s,offset:l}=e.findIndex(t),c=e.maybeChild(s);if(l==t||c.isText)return o&&r<=0&&i<=0&&!o.canReplace(s,s,n)?null:e.cut(0,t).append(n).append(e.cut(t));let u=Su(c.content,t-l-1,n,s==0?r-1:0,s==e.childCount-1?i-1:0,c);return u&&e.replaceChild(s,c.copy(u))}a(Su,"Qh");function _1(e,t,n){if(n.openStart>e.depth)throw new pr("Inserted content deeper than insertion position");if(e.depth-n.openStart!=t.depth-n.openEnd)throw new pr("Inconsistent open depths");return Cu(e,t,n,0)}a(_1,"_x");function Cu(e,t,n,r){let i=e.index(r),o=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){let s=Cu(e,t,n,r+1);return o.copy(o.content.replaceChild(i,s))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let s=e.parent,l=s.content;return on(s,l.cut(0,e.parentOffset).append(n.content).append(l.cut(t.parentOffset)))}else{let{start:s,end:l}=H1(n,e);return on(o,Nu(e,s,l,t,r))}else return on(o,Li(e,t,r))}a(Cu,"Xh");function Mu(e,t){if(!t.type.compatibleContent(e.type))throw new pr("Cannot join "+t.type.name+" onto "+e.type.name)}a(Mu,"Zh");function ds(e,t,n){let r=e.node(n);return Mu(r,t.node(n)),r}a(ds,"Ol");function rn(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}a(rn,"Tn");function fr(e,t,n,r){let i=(t||e).node(n),o=0,s=t?t.index(n):i.childCount;e&&(o=e.index(n),e.depth>n?o++:e.textOffset&&(rn(e.nodeAfter,r),o++));for(let l=o;l<s;l++)rn(i.child(l),r);t&&t.depth==n&&t.textOffset&&rn(t.nodeBefore,r)}a(fr,"yi");function on(e,t){if(!e.type.validContent(t))throw new pr("Invalid content for node "+e.type.name);return e.copy(t)}a(on,"In");function Nu(e,t,n,r,i){let o=e.depth>i&&ds(e,t,i+1),s=r.depth>i&&ds(n,r,i+1),l=[];return fr(null,e,i,l),o&&s&&t.index(i)==n.index(i)?(Mu(o,s),rn(on(o,Nu(e,t,n,r,i+1)),l)):(o&&rn(on(o,Li(e,t,i+1)),l),fr(t,n,i,l),s&&rn(on(s,Li(n,r,i+1)),l)),fr(r,null,i,l),new O(l)}a(Nu,"ed");function Li(e,t,n){let r=[];if(fr(null,e,n,r),e.depth>n){let i=ds(e,t,n+1);rn(on(i,Li(e,t,n+1)),r)}return fr(t,null,n,r),new O(r)}a(Li,"Do");function H1(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let i=n-1;i>=0;i--)r=t.node(i).copy(O.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}a(H1,"$x");var Ou=class rc{static{a(this,"t")}constructor(t,n,r){this.pos=t,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(t){return t==null?this.depth:t<0?this.depth+t:t}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(t){return this.path[this.resolveDepth(t)*3]}index(t){return this.path[this.resolveDepth(t)*3+1]}indexAfter(t){return t=this.resolveDepth(t),this.index(t)+(t==this.depth&&!this.textOffset?0:1)}start(t){return t=this.resolveDepth(t),t==0?0:this.path[t*3-1]+1}end(t){return t=this.resolveDepth(t),this.start(t)+this.node(t).content.size}before(t){if(t=this.resolveDepth(t),!t)throw new RangeError("There is no position before the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]}after(t){if(t=this.resolveDepth(t),!t)throw new RangeError("There is no position after the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]+this.path[t*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let t=this.parent,n=this.index(this.depth);if(n==t.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=t.child(n);return r?t.child(n).cut(r):i}get nodeBefore(){let t=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(t).cut(0,n):t==0?null:this.parent.child(t-1)}posAtIndex(t,n){n=this.resolveDepth(n);let r=this.path[n*3],i=n==0?0:this.path[n*3-1]+1;for(let o=0;o<t;o++)i+=r.child(o).nodeSize;return i}marks(){let t=this.parent,n=this.index();if(t.content.size==0)return X.none;if(this.textOffset)return t.child(n).marks;let r=t.maybeChild(n-1),i=t.maybeChild(n);if(!r){let l=r;r=i,i=l}let o=r.marks;for(var s=0;s<o.length;s++)o[s].type.spec.inclusive===!1&&(!i||!o[s].isInSet(i.marks))&&(o=o[s--].removeFromSet(o));return o}marksAcross(t){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,i=t.parent.maybeChild(t.index());for(var o=0;o<r.length;o++)r[o].type.spec.inclusive===!1&&(!i||!r[o].isInSet(i.marks))&&(r=r[o--].removeFromSet(r));return r}sharedDepth(t){for(let n=this.depth;n>0;n--)if(this.start(n)<=t&&this.end(n)>=t)return n;return 0}blockRange(t=this,n){if(t.pos<this.pos)return t.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==t.pos?1:0);r>=0;r--)if(t.pos<=this.end(r)&&(!n||n(this.node(r))))return new Au(this,t,r);return null}sameParent(t){return this.pos-this.parentOffset==t.pos-t.parentOffset}max(t){return t.pos>this.pos?t:this}min(t){return t.pos<this.pos?t:this}toString(){let t="";for(let n=1;n<=this.depth;n++)t+=(t?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return t+":"+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw new RangeError("Position "+n+" out of range");let r=[],i=0,o=n;for(let s=t;;){let{index:l,offset:c}=s.content.findIndex(o),u=o-c;if(r.push(s,l,i+c),!u||(s=s.child(l),s.isText))break;o=u-1,i+=c+1}return new rc(n,r,o)}static resolveCached(t,n){let r=Tu.get(t);if(r)for(let o=0;o<r.elts.length;o++){let s=r.elts[o];if(s.pos==n)return s}else Tu.set(t,r=new W1);let i=r.elts[r.i]=rc.resolve(t,n);return r.i=(r.i+1)%q1,i}},W1=class{static{a(this,"Rl")}constructor(){this.elts=[],this.i=0}},q1=12,Tu=new WeakMap,Au=class{static{a(this,"bi")}constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},K1=Object.create(null),kt=class ic{static{a(this,"t")}constructor(t,n,r,i=X.none){this.type=t,this.attrs=n,this.marks=i,this.content=r||O.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(t){return this.content.child(t)}maybeChild(t){return this.content.maybeChild(t)}forEach(t){this.content.forEach(t)}nodesBetween(t,n,r,i=0){this.content.nodesBetween(t,n,r,i,this)}descendants(t){this.nodesBetween(0,this.content.size,t)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(t,n,r,i){return this.content.textBetween(t,n,r,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(t){return this==t||this.sameMarkup(t)&&this.content.eq(t.content)}sameMarkup(t){return this.hasMarkup(t.type,t.attrs,t.marks)}hasMarkup(t,n,r){return this.type==t&&Fi(this.attrs,n||t.defaultAttrs||K1)&&X.sameSet(this.marks,r||X.none)}copy(t=null){return t==this.content?this:new ic(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new ic(this.type,this.attrs,this.content,t)}cut(t,n=this.content.size){return t==0&&n==this.content.size?this:this.copy(this.content.cut(t,n))}slice(t,n=this.content.size,r=!1){if(t==n)return E.empty;let i=this.resolve(t),o=this.resolve(n),s=r?0:i.sharedDepth(n),l=i.start(s),c=i.node(s).content.cut(i.pos-l,o.pos-l);return new E(c,i.depth-s,o.depth-s)}replace(t,n,r){return _1(this.resolve(t),this.resolve(n),r)}nodeAt(t){for(let n=this;;){let{index:r,offset:i}=n.content.findIndex(t);if(n=n.maybeChild(r),!n)return null;if(i==t||n.isText)return n;t-=i+1}}childAfter(t){let{index:n,offset:r}=this.content.findIndex(t);return{node:this.content.maybeChild(n),index:n,offset:r}}childBefore(t){if(t==0)return{node:null,index:0,offset:0};let{index:n,offset:r}=this.content.findIndex(t);if(r<t)return{node:this.content.child(n),index:n,offset:r};let i=this.content.child(n-1);return{node:i,index:n-1,offset:r-i.nodeSize}}resolve(t){return Ou.resolveCached(this,t)}resolveNoCache(t){return Ou.resolve(this,t)}rangeHasMark(t,n,r){let i=!1;return n>t&&this.nodesBetween(t,n,o=>(r.isInSet(o.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 t=this.type.name;return this.content.size&&(t+="("+this.content.toStringInner()+")"),Iu(this.marks,t)}contentMatchAt(t){let n=this.type.contentMatch.matchFragment(this.content,0,t);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(t,n,r=O.empty,i=0,o=r.childCount){let s=this.contentMatchAt(t).matchFragment(r,i,o),l=s&&s.matchFragment(this.content,n);if(!l||!l.validEnd)return!1;for(let c=i;c<o;c++)if(!this.type.allowsMarks(r.child(c).marks))return!1;return!0}canReplaceWith(t,n,r,i){if(i&&!this.type.allowsMarks(i))return!1;let o=this.contentMatchAt(t).matchType(r),s=o&&o.matchFragment(this.content,n);return s?s.validEnd:!1}canAppend(t){return t.content.size?this.canReplace(this.childCount,this.childCount,t.content):this.type.compatibleContent(t.type)}check(){this.type.checkContent(this.content),Eu(this.type.attrs,this.attrs,"node",this.type.name);let t=X.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];Eu(r.type.attrs,r.attrs,"mark",r.type.name),t=r.addToSet(t)}if(!X.sameSet(t,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let t={type:this.type.name};for(let n in this.attrs){t.attrs=this.attrs;break}return this.content.size&&(t.content=this.content.toJSON()),this.marks.length&&(t.marks=this.marks.map(n=>n.toJSON())),t}static fromJSON(t,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(t.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return t.text(n.text,r)}let i=O.fromJSON(t,n.content);return t.nodeType(n.type).create(n.attrs,i,r)}};kt.prototype.text=void 0;var J1=class oc extends kt{static{a(this,"t")}constructor(t,n,r,i){if(super(t,n,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):Iu(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(t,n){return this.text.slice(t,n)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new oc(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new oc(this.type,this.attrs,t,this.marks)}cut(t=0,n=this.text.length){return t==0&&n==this.text.length?this:this.withText(this.text.slice(t,n))}eq(t){return this.sameMarkup(t)&&this.text==t.text}toJSON(){let t=super.toJSON();return t.text=this.text,t}};function Iu(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}a(Iu,"td");function Eu(e,t,n,r){for(let i in t)if(!(i in e))throw new RangeError(`Unsupported attribute ${i} for ${n} of type ${r}`);for(let i in e)e[i].validate&&e[i].validate(t[i])}a(Eu,"Bh");var mr=class xm{static{a(this,"t")}constructor(t){this.validEnd=t,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new U1(t,n);if(r.next==null)return xm.empty;let i=Du(r);r.next&&r.err("Unexpected trailing text");let o=tv(ev(i));return nv(o,r),o}matchType(t){for(let n=0;n<this.next.length;n++)if(this.next[n].type==t)return this.next[n].next;return null}matchFragment(t,n=0,r=t.childCount){let i=this;for(let o=n;i&&o<r;o++)i=i.matchType(t.child(o).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let t=0;t<this.next.length;t++){let{type:n}=this.next[t];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(t){for(let n=0;n<this.next.length;n++)for(let r=0;r<t.next.length;r++)if(this.next[n].type==t.next[r].type)return!0;return!1}fillBefore(t,n=!1,r=0){let i=[this];function o(s,l){let c=s.matchFragment(t,r);if(c&&(!n||c.validEnd))return O.from(l.map(u=>u.createAndFill()));for(let u=0;u<s.next.length;u++){let{type:h,next:d}=s.next[u];if(!(h.isText||h.hasRequiredAttrs())&&i.indexOf(d)==-1){i.push(d);let p=o(d,l.concat(h));if(p)return p}}return null}return a(o,"o"),o(this,[])}findWrapping(t){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==t)return this.wrapCache[r+1];let n=this.computeWrapping(t);return this.wrapCache.push(t,n),n}computeWrapping(t){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),o=i.match;if(o.matchType(t)){let s=[];for(let l=i;l.type;l=l.via)s.push(l.type);return s.reverse()}for(let s=0;s<o.next.length;s++){let{type:l,next:c}=o.next[s];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in n)&&(!i.type||c.validEnd)&&(r.push({match:l.contentMatch,type:l,via:i}),n[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(t){if(t>=this.next.length)throw new RangeError(`There's no ${t}th edge in this content match`);return this.next[t]}toString(){let t=[];function n(r){t.push(r);for(let i=0;i<r.next.length;i++)t.indexOf(r.next[i].next)==-1&&n(r.next[i].next)}return a(n,"n"),n(this),t.map((r,i)=>{let o=i+(r.validEnd?"*":" ")+" ";for(let s=0;s<r.next.length;s++)o+=(s?", ":"")+r.next[s].type.name+"->"+t.indexOf(r.next[s].next);return o}).join(`
35
+ `)}};mr.empty=new mr(!0);var U1=class{static{a(this,"Pl")}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 Du(e){let t=[];do t.push(G1(e));while(e.eat("|"));return t.length==1?t[0]:{type:"choice",exprs:t}}a(Du,"nd");function G1(e){let t=[];do t.push(Q1(e));while(e.next&&e.next!=")"&&e.next!="|");return t.length==1?t[0]:{type:"seq",exprs:t}}a(G1,"jx");function Q1(e){let t=Z1(e);for(;;)if(e.eat("+"))t={type:"plus",expr:t};else if(e.eat("*"))t={type:"star",expr:t};else if(e.eat("?"))t={type:"opt",expr:t};else if(e.eat("{"))t=Y1(e,t);else break;return t}a(Q1,"Kx");function Ru(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");let t=Number(e.next);return e.pos++,t}a(Ru,"Fh");function Y1(e,t){let n=Ru(e),r=n;return e.eat(",")&&(e.next!="}"?r=Ru(e):r=-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:t}}a(Y1,"Wx");function X1(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let i=[];for(let o in n){let s=n[o];s.isInGroup(t)&&i.push(s)}return i.length==0&&e.err("No node type or group '"+t+"' found"),i}a(X1,"qx");function Z1(e){if(e.eat("(")){let t=Du(e);return e.eat(")")||e.err("Missing closing paren"),t}else if(/\W/.test(e.next))e.err("Unexpected token '"+e.next+"'");else{let t=X1(e,e.next).map(n=>(e.inline==null?e.inline=n.isInline:e.inline!=n.isInline&&e.err("Mixing inline and block content"),{type:"name",value:n}));return e.pos++,t.length==1?t[0]:{type:"choice",exprs:t}}}a(Z1,"Jx");function ev(e){let t=[[]];return i(o(e,0),n()),t;function n(){return t.push([])-1}function r(s,l,c){let u={term:c,to:l};return t[s].push(u),u}function i(s,l){s.forEach(c=>c.to=l)}function o(s,l){if(s.type=="choice")return s.exprs.reduce((c,u)=>c.concat(o(u,l)),[]);if(s.type=="seq")for(let c=0;;c++){let u=o(s.exprs[c],l);if(c==s.exprs.length-1)return u;i(u,l=n())}else if(s.type=="star"){let c=n();return r(l,c),i(o(s.expr,c),c),[r(c)]}else if(s.type=="plus"){let c=n();return i(o(s.expr,l),c),i(o(s.expr,c),c),[r(c)]}else{if(s.type=="opt")return[r(l)].concat(o(s.expr,l));if(s.type=="range"){let c=l;for(let u=0;u<s.min;u++){let h=n();i(o(s.expr,c),h),c=h}if(s.max==-1)i(o(s.expr,c),c);else for(let u=s.min;u<s.max;u++){let h=n();r(c,h),i(o(s.expr,c),h),c=h}return[r(c)]}else{if(s.type=="name")return[r(l,void 0,s.value)];throw new Error("Unknown expr type")}}}}a(ev,"Ux");function zu(e,t){return t-e}a(zu,"rd");function Pu(e,t){let n=[];return r(t),n.sort(zu);function r(i){let o=e[i];if(o.length==1&&!o[0].term)return r(o[0].to);n.push(i);for(let s=0;s<o.length;s++){let{term:l,to:c}=o[s];!l&&n.indexOf(c)==-1&&r(c)}}}a(Pu,"_h");function tv(e){let t=Object.create(null);return n(Pu(e,0));function n(r){let i=[];r.forEach(s=>{e[s].forEach(({term:l,to:c})=>{if(!l)return;let u;for(let h=0;h<i.length;h++)i[h][0]==l&&(u=i[h][1]);Pu(e,c).forEach(h=>{u||i.push([l,u=[]]),u.indexOf(h)==-1&&u.push(h)})})});let o=t[r.join(",")]=new mr(r.indexOf(e.length-1)>-1);for(let s=0;s<i.length;s++){let l=i[s][1].sort(zu);o.next.push({type:i[s][0],next:t[l.join(",")]||n(l)})}return o}}a(tv,"Gx");function nv(e,t){for(let n=0,r=[e];n<r.length;n++){let i=r[n],o=!i.validEnd,s=[];for(let l=0;l<i.next.length;l++){let{type:c,next:u}=i.next[l];s.push(c.name),o&&!(c.isText||c.hasRequiredAttrs())&&(o=!1),r.indexOf(u)==-1&&r.push(u)}o&&t.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}a(nv,"Yx");function Fu(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}a(Fu,"id");function Lu(e,t){let n=Object.create(null);for(let r in e){let i=e[r],o=t&&t[r];if(o===void 0)if(i.hasDefault)o=i.default;else throw new RangeError("No value supplied for attribute "+r);else i.validate&&i.validate(o);n[r]=o}return n}a(Lu,"od");function $u(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new iv(e,r,t[r]);return n}a($u,"sd");var $i=class Sm{static{a(this,"t")}constructor(t,n,r){this.name=t,this.schema=n,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=$u(t,r.attrs),this.defaultAttrs=Fu(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||t=="text"),this.isText=t=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==mr.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(t){return this.groups.indexOf(t)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let t in this.attrs)if(this.attrs[t].isRequired)return!0;return!1}compatibleContent(t){return this==t||this.contentMatch.compatible(t.contentMatch)}computeAttrs(t){return!t&&this.defaultAttrs?this.defaultAttrs:Lu(this.attrs,t)}create(t=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new kt(this,this.computeAttrs(t),O.from(n),X.setFrom(r))}createChecked(t=null,n,r){return n=O.from(n),this.checkContent(n),new kt(this,this.computeAttrs(t),n,X.setFrom(r))}createAndFill(t=null,n,r){if(t=this.computeAttrs(t),n=O.from(n),n.size){let s=this.contentMatch.fillBefore(n);if(!s)return null;n=s.append(n)}let i=this.contentMatch.matchFragment(n),o=i&&i.fillBefore(O.empty,!0);return o?new kt(this,t,n.append(o),X.setFrom(r)):null}validContent(t){let n=this.contentMatch.matchFragment(t);if(!n||!n.validEnd)return!1;for(let r=0;r<t.childCount;r++)if(!this.allowsMarks(t.child(r).marks))return!1;return!0}checkContent(t){if(!this.validContent(t))throw new RangeError(`Invalid content for node ${this.name}: ${t.toString().slice(0,50)}`)}checkAttrs(t){}allowsMarkType(t){return this.markSet==null||this.markSet.indexOf(t)>-1}allowsMarks(t){if(this.markSet==null)return!0;for(let n=0;n<t.length;n++)if(!this.allowsMarkType(t[n].type))return!1;return!0}allowedMarks(t){if(this.markSet==null)return t;let n;for(let r=0;r<t.length;r++)this.allowsMarkType(t[r].type)?n&&n.push(t[r]):n||(n=t.slice(0,r));return n?n.length?n:X.none:t}static compile(t,n){let r=Object.create(null);t.forEach((o,s)=>r[o]=new Sm(o,n,s));let i=n.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 o in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function rv(e,t,n){let r=n.split("|");return i=>{let o=i===null?"null":typeof i;if(r.indexOf(o)<0)throw new RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${o}`)}}a(rv,"Qx");var iv=class{static{a(this,"Ll")}constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate=typeof n.validate=="string"?rv(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}},Bu=class Cm{static{a(this,"t")}constructor(t,n,r,i){this.name=t,this.rank=n,this.schema=r,this.spec=i,this.attrs=$u(t,i.attrs),this.excluded=null;let o=Fu(this.attrs);this.instance=o?new X(this,o):null}create(t=null){return!t&&this.instance?this.instance:new X(this,Lu(this.attrs,t))}static compile(t,n){let r=Object.create(null),i=0;return t.forEach((o,s)=>r[o]=new Cm(o,i++,n,s)),r}removeFromSet(t){for(var n=0;n<t.length;n++)t[n].type==this&&(t=t.slice(0,n).concat(t.slice(n+1)),n--);return t}isInSet(t){for(let n=0;n<t.length;n++)if(t[n].type==this)return t[n]}excludes(t){return this.excluded.indexOf(t)>-1}},ov=class{static{a(this,"Lo")}constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let r in e)t[r]=e[r];t.nodes=yu.from(e.nodes),t.marks=yu.from(e.marks||{}),this.nodes=$i.compile(this.spec.nodes,this),this.marks=Bu.compile(this.spec.marks,this);let n=Object.create(null);for(let r in this.nodes){if(r in this.marks)throw new RangeError(r+" can not be both a node and a mark");let i=this.nodes[r],o=i.spec.content||"",s=i.spec.marks;if(i.contentMatch=n[o]||(n[o]=mr.parse(o,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=s=="_"?null:s?Vu(this,s.split(" ")):s==""||!i.inlineContent?[]:null}for(let r in this.marks){let i=this.marks[r],o=i.spec.excludes;i.excluded=o==null?[i]:o==""?[]:Vu(this,o.split(" "))}this.nodeFromJSON=r=>kt.fromJSON(this,r),this.markFromJSON=r=>X.fromJSON(this,r),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof $i){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,n,r)}text(e,t){let n=this.nodes.text;return new J1(n,n.defaultAttrs,e,X.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 Vu(e,t){let n=[];for(let r=0;r<t.length;r++){let i=t[r],o=e.marks[i],s=o;if(o)n.push(o);else for(let l in e.marks){let c=e.marks[l];(i=="_"||c.spec.group&&c.spec.group.split(" ").indexOf(i)>-1)&&n.push(s=c)}if(!s)throw new SyntaxError("Unknown mark type: '"+t[r]+"'")}return n}a(Vu,"$h");function sv(e){return e.tag!=null}a(sv,"Xx");function lv(e){return e.style!=null}a(lv,"Zx");var ps=class sc{static{a(this,"t")}constructor(t,n){this.schema=t,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(sv(i))this.tags.push(i);else if(lv(i)){let o=/[^=]*/.exec(i.style)[0];r.indexOf(o)<0&&r.push(o),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let o=t.nodes[i.node];return o.contentMatch.matchType(o)})}parse(t,n={}){let r=new Wu(this,n,!1);return r.addAll(t,X.none,n.from,n.to),r.finish()}parseSlice(t,n={}){let r=new Wu(this,n,!0);return r.addAll(t,X.none,n.from,n.to),E.maxOpen(r.finish())}matchTag(t,n,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let o=this.tags[i];if(uv(t,o.tag)&&(o.namespace===void 0||t.namespaceURI==o.namespace)&&(!o.context||n.matchesContext(o.context))){if(o.getAttrs){let s=o.getAttrs(t);if(s===!1)continue;o.attrs=s||void 0}return o}}}matchStyle(t,n,r,i){for(let o=i?this.styles.indexOf(i)+1:0;o<this.styles.length;o++){let s=this.styles[o],l=s.style;if(!(l.indexOf(t)!=0||s.context&&!r.matchesContext(s.context)||l.length>t.length&&(l.charCodeAt(t.length)!=61||l.slice(t.length+1)!=n))){if(s.getAttrs){let c=s.getAttrs(n);if(c===!1)continue;s.attrs=c||void 0}return s}}}static schemaRules(t){let n=[];function r(i){let o=i.priority==null?50:i.priority,s=0;for(;s<n.length;s++){let l=n[s];if((l.priority==null?50:l.priority)<o)break}n.splice(s,0,i)}a(r,"r");for(let i in t.marks){let o=t.marks[i].spec.parseDOM;o&&o.forEach(s=>{r(s=qu(s)),s.mark||s.ignore||s.clearMark||(s.mark=i)})}for(let i in t.nodes){let o=t.nodes[i].spec.parseDOM;o&&o.forEach(s=>{r(s=qu(s)),s.node||s.ignore||s.mark||(s.node=i)})}return n}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new sc(t,sc.schemaRules(t)))}},ju={address:!0,article:!0,aside:!0,blockquote:!0,body:!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},av={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},_u={ol:!0,ul:!0},gr=1,fs=2,yr=4;function Hu(e,t,n){return t!=null?(t?gr:0)|(t==="full"?fs:0):e&&e.whitespace=="pre"?gr|fs:n&~yr}a(Hu,"Vh");var Bi=class{static{a(this,"kr")}constructor(e,t,n,r,i,o){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=o,this.content=[],this.activeMarks=X.none,this.match=i||(o&yr?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(O.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let n=this.type.contentMatch,r;return(r=n.findWrapping(e.type))?(this.match=n,r):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&gr)){let n=this.content[this.content.length-1],r;if(n&&n.isText&&(r=/[ \t\r\n\u000c]+$/.exec(n.text))){let i=n;n.text.length==r[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-r[0].length))}}let t=O.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(O.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&&!ju.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},Wu=class{static{a(this,"zo")}constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r=t.topNode,i,o=Hu(null,t.preserveWhitespace,0)|(n?yr:0);r?i=new Bi(r.type,r.attrs,X.none,!0,t.topMatch||r.type.contentMatch,o):n?i=new Bi(null,null,X.none,!0,null,o):i=new Bi(e.schema.topNodeType,null,X.none,!0,null,o),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,r=this.top,i=r.options&fs?"full":this.localPreserveWS||(r.options&gr)>0,{schema:o}=this.parser;if(i==="full"||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(i)if(i==="full")n=n.replace(/\r\n?/g,`
36
+ `);else if(o.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(o.linebreakReplacement.create())){let s=n.split(/\r?\n|\r/);for(let l=0;l<s.length;l++)l&&this.insertNode(o.linebreakReplacement.create(),t,!0),s[l]&&this.insertNode(o.text(s[l]),t,!/\S/.test(s[l]));n=""}else n=n.replace(/\r?\n|\r/g," ");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let s=r.content[r.content.length-1],l=e.previousSibling;(!s||l&&l.nodeName=="BR"||s.isText&&/[ \t\r\n\u000c]$/.test(s.text))&&(n=n.slice(1))}n&&this.insertNode(o.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let r=this.localPreserveWS,i=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),s;_u.hasOwnProperty(o)&&this.parser.normalizeLists&&cv(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(s=this.parser.matchTag(e,this,n));e:if(l?l.ignore:av.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,t);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(e=l.skip);let c,u=this.needsBlock;if(ju.hasOwnProperty(o))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),c=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let h=l&&l.skip?t:this.readStyles(e,t);h&&this.addAll(e,h),c&&this.sync(i),this.needsBlock=u}else{let c=this.readStyles(e,t);c&&this.addElementByRule(e,l,c,l.consuming===!1?s:void 0)}this.localPreserveWS=r}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
37
+ `),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let r=0;r<this.parser.matchedStyles.length;r++){let i=this.parser.matchedStyles[r],o=n.getPropertyValue(i);if(o)for(let s=void 0;;){let l=this.parser.matchStyle(i,o,this,s);if(!l)break;if(l.ignore)return null;if(l.clearMark?t=t.filter(c=>!l.clearMark(c)):t=t.concat(this.parser.schema.marks[l.mark].create(l.attrs)),l.consuming===!1)s=l;else break}}return t}addElementByRule(e,t,n,r){let i,o;if(t.node)if(o=this.parser.schema.nodes[t.node],o.isLeaf)this.insertNode(o.create(t.attrs),n,e.nodeName=="BR")||this.leafFallback(e,n);else{let l=this.enter(o,t.attrs||null,n,t.preserveWhitespace);l&&(i=!0,n=l)}else{let l=this.parser.schema.marks[t.mark];n=n.concat(l.create(t.attrs))}let s=this.top;if(o&&o.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(l=>this.insertNode(l,n,!1));else{let l=e;typeof t.contentElement=="string"?l=e.querySelector(t.contentElement):typeof t.contentElement=="function"?l=t.contentElement(e):t.contentElement&&(l=t.contentElement),this.findAround(e,l,!0),this.addAll(l,n),this.findAround(e,l,!1)}i&&this.sync(s)&&this.open--}addAll(e,t,n,r){let i=n||0;for(let o=n?e.childNodes[n]:e.firstChild,s=r==null?null:e.childNodes[r];o!=s;o=o.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(o,t);this.findAtPoint(e,i)}findPlace(e,t,n){let r,i;for(let o=this.open,s=0;o>=0;o--){let l=this.nodes[o],c=l.findWrapping(e);if(c&&(!r||r.length>c.length+s)&&(r=c,i=l,!c.length))break;if(l.solid){if(n)break;s+=2}}if(!r)return null;this.sync(i);for(let o=0;o<r.length;o++)t=this.enterInner(r[o],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(t=this.enterInner(i,null,t))}let r=this.findPlace(e,t,n);if(r){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let o=X.none;for(let s of r.concat(e.marks))(i.type?i.type.allowsMarkType(s.type):Ku(s.type,e.type))&&(o=s.addToSet(o));return i.content.push(e.mark(o)),!0}return!1}enter(e,t,n,r){let i=this.findPlace(e.create(t),n,!1);return i&&(i=this.enterInner(e,t,n,!0,r)),i}enterInner(e,t,n,r=!1,i){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let s=Hu(e,i,o.options);o.options&yr&&o.content.length==0&&(s|=yr);let l=X.none;return n=n.filter(c=>(o.type?o.type.allowsMarkType(c.type):Ku(c.type,e))?(l=c.addToSet(l),!1):!0),this.nodes.push(new Bi(e,t,l,r,null,s)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=gr)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let r=n.length-1;r>=0;r--)e+=n[r].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)this.find[r].pos==null&&e.nodeType==1&&e.contains(this.find[r].node)&&t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),n=this.options.context,r=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),i=-(n?n.depth+1:0)+(r?0:1),o=a((s,l)=>{for(;s>=0;s--){let c=t[s];if(c==""){if(s==t.length-1||s==0)continue;for(;l>=i;l--)if(o(s-1,l))return!0;return!1}else{let u=l>0||l==0&&r?this.nodes[l].type:n&&l>=i?n.node(l-i).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;l--}}return!0},"s");return o(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let t in this.parser.schema.nodes){let n=this.parser.schema.nodes[t];if(n.isTextblock&&n.defaultAttrs)return n}}};function cv(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let r=t.nodeType==1?t.nodeName.toLowerCase():null;r&&_u.hasOwnProperty(r)&&n?(n.appendChild(t),t=n):r=="li"?n=t:r&&(n=null)}}a(cv,"tw");function uv(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}a(uv,"nw");function qu(e){let t={};for(let n in e)t[n]=e[n];return t}a(qu,"Hh");function Ku(e,t){let n=t.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(e))continue;let o=[],s=a(l=>{o.push(l);for(let c=0;c<l.edgeCount;c++){let{type:u,next:h}=l.edge(c);if(u==t||o.indexOf(h)<0&&s(h))return!0}},"s");if(s(i.contentMatch))return!0}}a(Ku,"jh");var Vi=class Mm{static{a(this,"t")}constructor(t,n){this.nodes=t,this.marks=n}serializeFragment(t,n={},r){r||(r=ji(n).createDocumentFragment());let i=r,o=[];return t.forEach(s=>{if(o.length||s.marks.length){let l=0,c=0;for(;l<o.length&&c<s.marks.length;){let u=s.marks[c];if(!this.marks[u.type.name]){c++;continue}if(!u.eq(o[l][0])||u.type.spec.spanning===!1)break;l++,c++}for(;l<o.length;)i=o.pop()[1];for(;c<s.marks.length;){let u=s.marks[c++],h=this.serializeMark(u,s.isInline,n);h&&(o.push([u,i]),i.appendChild(h.dom),i=h.contentDOM||h.dom)}}i.appendChild(this.serializeNodeInner(s,n))}),r}serializeNodeInner(t,n){if(t.isText)return ji(n).createTextNode(t.text);let{dom:r,contentDOM:i}=_i(ji(n),this.nodes[t.type.name](t),null,t.attrs);if(i){if(t.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(t.content,n,i)}return r}serializeNode(t,n={}){let r=this.serializeNodeInner(t,n);for(let i=t.marks.length-1;i>=0;i--){let o=this.serializeMark(t.marks[i],t.isInline,n);o&&((o.contentDOM||o.dom).appendChild(r),r=o.dom)}return r}serializeMark(t,n,r={}){let i=this.marks[t.type.name];return i&&_i(ji(r),i(t,n),null,t.attrs)}static renderSpec(t,n,r=null,i){return typeof n=="string"?{dom:t.createTextNode(n)}:_i(t,n,r,i)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new Mm(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(t){let n=Ju(t.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(t){return Ju(t.marks)}};function Ju(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}a(Ju,"Kh");function ji(e){return e.document||window.document}a(ji,"Eo");var Uu=new WeakMap;function hv(e){let t=Uu.get(e);return t===void 0&&Uu.set(e,t=dv(e)),t}a(hv,"rw");function dv(e){let t=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")t||(t=[]),t.push(r);else for(let i=0;i<r.length;i++)n(r[i]);else for(let i in r)n(r[i])}return a(n,"n"),n(e),t}a(dv,"iw");function _i(e,t,n,r){if(t.nodeType==1)return{dom:t};if(t.dom&&t.dom.nodeType==1)return t;let i=t[0],o;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(o=hv(r))&&o.indexOf(t)>-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 s=i.indexOf(" ");s>0&&(n=i.slice(0,s),i=i.slice(s+1));let l,c=n?e.createElementNS(n,i):e.createElement(i),u=t[1],h=1;if(u&&typeof u=="object"&&u.nodeType==null&&!Array.isArray(u)){h=2;for(let d in u)if(u[d]!=null){let p=d.indexOf(" ");p>0?c.setAttributeNS(d.slice(0,p),d.slice(p+1),u[d]):d=="style"&&c.style?c.style.cssText=u[d]:c.setAttribute(d,u[d])}}for(let d=h;d<t.length;d++){let p=t[d];if(p===0){if(d<t.length-1||d>h)throw new RangeError("Content hole must be the only child of its parent node");return{dom:c,contentDOM:c}}else if(typeof p=="string")c.appendChild(e.createTextNode(p));else{let{dom:f,contentDOM:m}=_i(e,p,n,r);if(c.appendChild(f),m){if(l)throw new RangeError("Multiple content holes");l=m}}}return{dom:c,contentDOM:l}}a(_i,"Oo");var Gu=65535,Qu=Math.pow(2,16);function pv(e,t){return e+t*Qu}a(pv,"ow");function Yu(e){return e&Gu}a(Yu,"cd");function fv(e){return(e-(e&Gu))/Qu}a(fv,"sw");var Xu=1,Zu=2,Hi=4,eh=8,ms=class{static{a(this,"Mi")}constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&eh)>0}get deletedBefore(){return(this.delInfo&(Xu|Hi))>0}get deletedAfter(){return(this.delInfo&(Zu|Hi))>0}get deletedAcross(){return(this.delInfo&Hi)>0}},sn=class nr{static{a(this,"t")}constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&nr.empty)return nr.empty}recover(t){let n=0,r=Yu(t);if(!this.inverted)for(let i=0;i<r;i++)n+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[r*3]+n+fv(t)}mapResult(t,n=1){return this._map(t,n,!1)}map(t,n=1){return this._map(t,n,!0)}_map(t,n,r){let i=0,o=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let c=this.ranges[l]-(this.inverted?i:0);if(c>t)break;let u=this.ranges[l+o],h=this.ranges[l+s],d=c+u;if(t<=d){let p=u?t==c?-1:t==d?1:n:n,f=c+i+(p<0?0:h);if(r)return f;let m=t==(n<0?c:d)?null:pv(l/3,t-c),g=0;return u&&(g|=t==c?Zu:t==d?Xu:Hi,(n<0?t!=c:t!=d)&&(g|=eh)),new ms(f,g,m)}i+=h-u}return r?t+i:new ms(t+i,0,null)}touches(t,n){let r=0,i=Yu(n),o=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let c=this.ranges[l]-(this.inverted?r:0);if(c>t)break;let u=this.ranges[l+o],h=c+u;if(t<=h&&l==i*3)return!0;r+=this.ranges[l+s]-u}return!1}forEach(t){let n=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,o=0;i<this.ranges.length;i+=3){let s=this.ranges[i],l=s-(this.inverted?o:0),c=s+(this.inverted?0:o),u=this.ranges[i+n],h=this.ranges[i+r];t(l,l+u,c,c+h),o+=h-u}}invert(){return new nr(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(t){return t==0?nr.empty:new nr(t<0?[0,-t,0]:[0,0,t])}};sn.empty=new sn([]);var th=class lc{static{a(this,"t")}constructor(t,n,r=0,i=t?t.length:0){this.mirror=n,this.from=r,this.to=i,this._maps=t||[],this.ownData=!(t||n)}get maps(){return this._maps}slice(t=0,n=this.maps.length){return new lc(this._maps,this.mirror,t,n)}appendMap(t,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(t),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(t){for(let n=0,r=this._maps.length;n<t._maps.length;n++){let i=t.getMirror(n);this.appendMap(t._maps[n],i!=null&&i<n?r+i:void 0)}}getMirror(t){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==t)return this.mirror[n+(n%2?-1:1)]}}setMirror(t,n){this.mirror||(this.mirror=[]),this.mirror.push(t,n)}appendMappingInverted(t){for(let n=t.maps.length-1,r=this._maps.length+t._maps.length;n>=0;n--){let i=t.getMirror(n);this.appendMap(t._maps[n].invert(),i!=null&&i>n?r-i-1:void 0)}}invert(){let t=new lc;return t.appendMappingInverted(this),t}map(t,n=1){if(this.mirror)return this._map(t,n,!0);for(let r=this.from;r<this.to;r++)t=this._maps[r].map(t,n);return t}mapResult(t,n=1){return this._map(t,n,!1)}_map(t,n,r){let i=0;for(let o=this.from;o<this.to;o++){let s=this._maps[o],l=s.mapResult(t,n);if(l.recover!=null){let c=this.getMirror(o);if(c!=null&&c>o&&c<this.to){o=c,t=this._maps[c].recover(l.recover);continue}}i|=l.delInfo,t=l.pos}return r?t:new ms(t,i,null)}},gs=Object.create(null),ge=class{static{a(this,"ye")}getMap(){return sn.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=gs[t.stepType];if(!n)throw new RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in gs)throw new RangeError("Duplicate use of step JSON ID "+e);return gs[e]=t,t.prototype.jsonID=e,t}},Ce=class pi{static{a(this,"t")}constructor(t,n){this.doc=t,this.failed=n}static ok(t){return new pi(t,null)}static fail(t){return new pi(null,t)}static fromReplace(t,n,r,i){try{return pi.ok(t.replace(n,r,i))}catch(o){if(o instanceof pr)return pi.fail(o.message);throw o}}};function ys(e,t,n){let r=[];for(let i=0;i<e.childCount;i++){let o=e.child(i);o.content.size&&(o=o.copy(ys(o.content,t,o))),o.isInline&&(o=t(o,n,i)),r.push(o)}return O.fromArray(r)}a(ys,"Vl");var Wi=class fi extends ge{static{a(this,"t")}constructor(t,n,r){super(),this.from=t,this.to=n,this.mark=r}apply(t){let n=t.slice(this.from,this.to),r=t.resolve(this.from),i=r.node(r.sharedDepth(this.to)),o=new E(ys(n.content,(s,l)=>!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),i),n.openStart,n.openEnd);return Ce.fromReplace(t,this.from,this.to,o)}invert(){return new vr(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new fi(n.pos,r.pos,this.mark)}merge(t){return t instanceof fi&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new fi(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new fi(n.from,n.to,t.markFromJSON(n.mark))}};ge.jsonID("addMark",Wi);var vr=class mi extends ge{static{a(this,"t")}constructor(t,n,r){super(),this.from=t,this.to=n,this.mark=r}apply(t){let n=t.slice(this.from,this.to),r=new E(ys(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),t),n.openStart,n.openEnd);return Ce.fromReplace(t,this.from,this.to,r)}invert(){return new Wi(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new mi(n.pos,r.pos,this.mark)}merge(t){return t instanceof mi&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new mi(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new mi(n.from,n.to,t.markFromJSON(n.mark))}};ge.jsonID("removeMark",vr);var vs=class gi extends ge{static{a(this,"t")}constructor(t,n){super(),this.pos=t,this.mark=n}apply(t){let n=t.nodeAt(this.pos);if(!n)return Ce.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return Ce.fromReplace(t,this.pos,this.pos+1,new E(O.from(r),0,n.isLeaf?0:1))}invert(t){let n=t.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let i=0;i<n.marks.length;i++)if(!n.marks[i].isInSet(r))return new gi(this.pos,n.marks[i]);return new gi(this.pos,this.mark)}}return new qi(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new gi(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new gi(n.pos,t.markFromJSON(n.mark))}};ge.jsonID("addNodeMark",vs);var qi=class ac extends ge{static{a(this,"t")}constructor(t,n){super(),this.pos=t,this.mark=n}apply(t){let n=t.nodeAt(this.pos);if(!n)return Ce.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return Ce.fromReplace(t,this.pos,this.pos+1,new E(O.from(r),0,n.isLeaf?0:1))}invert(t){let n=t.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new vs(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new ac(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new ac(n.pos,t.markFromJSON(n.mark))}};ge.jsonID("removeNodeMark",qi);var qe=class Yt extends ge{static{a(this,"t")}constructor(t,n,r,i=!1){super(),this.from=t,this.to=n,this.slice=r,this.structure=i}apply(t){return this.structure&&ks(t,this.from,this.to)?Ce.fail("Structure replace would overwrite content"):Ce.fromReplace(t,this.from,this.to,this.slice)}getMap(){return new sn([this.from,this.to-this.from,this.slice.size])}invert(t){return new Yt(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let n=t.mapResult(this.to,-1),r=this.from==this.to&&Yt.MAP_BIAS<0?n:t.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new Yt(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(t){if(!(t instanceof Yt)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let n=this.slice.size+t.slice.size==0?E.empty:new E(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new Yt(this.from,this.to+(t.to-t.from),n,this.structure)}else if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let n=this.slice.size+t.slice.size==0?E.empty:new E(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new Yt(t.from,this.to,n,this.structure)}else return null}toJSON(){let t={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Yt(n.from,n.to,E.fromJSON(t,n.slice),!!n.structure)}};qe.MAP_BIAS=1,ge.jsonID("replace",qe);var Ke=class Do extends ge{static{a(this,"t")}constructor(t,n,r,i,o,s,l=!1){super(),this.from=t,this.to=n,this.gapFrom=r,this.gapTo=i,this.slice=o,this.insert=s,this.structure=l}apply(t){if(this.structure&&(ks(t,this.from,this.gapFrom)||ks(t,this.gapTo,this.to)))return Ce.fail("Structure gap-replace would overwrite content");let n=t.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return Ce.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?Ce.fromReplace(t,this.from,this.to,r):Ce.fail("Content does not fit in gap")}getMap(){return new sn([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let n=this.gapTo-this.gapFrom;return new Do(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:t.map(this.gapFrom,-1),o=this.to==this.gapTo?r.pos:t.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||o>r.pos?null:new Do(n.pos,r.pos,i,o,this.slice,this.insert,this.structure)}toJSON(){let t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Do(n.from,n.to,n.gapFrom,n.gapTo,E.fromJSON(t,n.slice),n.insert,!!n.structure)}};ge.jsonID("replaceAround",Ke);function ks(e,t,n){let r=e.resolve(t),i=n-t,o=r.depth;for(;i>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,i--;if(i>0){let s=r.node(o).maybeChild(r.indexAfter(o));for(;i>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,i--}}return!1}a(ks,"_l");function mv(e,t,n,r){let i=[],o=[],s,l;e.doc.nodesBetween(t,n,(c,u,h)=>{if(!c.isInline)return;let d=c.marks;if(!r.isInSet(d)&&h.type.allowsMarkType(r.type)){let p=Math.max(u,t),f=Math.min(u+c.nodeSize,n),m=r.addToSet(d);for(let g=0;g<d.length;g++)d[g].isInSet(m)||(s&&s.to==p&&s.mark.eq(d[g])?s.to=f:i.push(s=new vr(p,f,d[g])));l&&l.to==p?l.to=f:o.push(l=new Wi(p,f,r))}}),i.forEach(c=>e.step(c)),o.forEach(c=>e.step(c))}a(mv,"lw");function gv(e,t,n,r){let i=[],o=0;e.doc.nodesBetween(t,n,(s,l)=>{if(!s.isInline)return;o++;let c=null;if(r instanceof Bu){let u=s.marks,h;for(;h=r.isInSet(u);)(c||(c=[])).push(h),u=h.removeFromSet(u)}else r?r.isInSet(s.marks)&&(c=[r]):c=s.marks;if(c&&c.length){let u=Math.min(l+s.nodeSize,n);for(let h=0;h<c.length;h++){let d=c[h],p;for(let f=0;f<i.length;f++){let m=i[f];m.step==o-1&&d.eq(i[f].style)&&(p=m)}p?(p.to=u,p.step=o):i.push({style:d,from:Math.max(l,t),to:u,step:o})}}}),i.forEach(s=>e.step(new vr(s.from,s.to,s.style)))}a(gv,"aw");function ws(e,t,n,r=n.contentMatch,i=!0){let o=e.doc.nodeAt(t),s=[],l=t+1;for(let c=0;c<o.childCount;c++){let u=o.child(c),h=l+u.nodeSize,d=r.matchType(u.type);if(!d)s.push(new qe(l,h,E.empty));else{r=d;for(let p=0;p<u.marks.length;p++)n.allowsMarkType(u.marks[p].type)||e.step(new vr(l,h,u.marks[p]));if(i&&u.isText&&n.whitespace!="pre"){let p,f=/\r?\n|\r/g,m;for(;p=f.exec(u.text);)m||(m=new E(O.from(n.schema.text(" ",n.allowedMarks(u.marks))),0,0)),s.push(new qe(l+p.index,l+p.index+p[0].length,m))}}l=h}if(!r.validEnd){let c=r.fillBefore(O.empty,!0);e.replace(l,l,new E(c,0,0))}for(let c=s.length-1;c>=0;c--)e.step(s[c])}a(ws,"Hl");function yv(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}a(yv,"cw");function Ki(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,i=0;;--n){let o=e.$from.node(n),s=e.$from.index(n)+r,l=e.$to.indexAfter(n)-i;if(n<e.depth&&o.canReplace(s,l,t))return n;if(n==0||o.type.spec.isolating||!yv(o,s,l))break;s&&(r=1),l<o.childCount&&(i=1)}return null}a(Ki,"Cr");function vv(e,t,n){let{$from:r,$to:i,depth:o}=t,s=r.before(o+1),l=i.after(o+1),c=s,u=l,h=O.empty,d=0;for(let m=o,g=!1;m>n;m--)g||r.index(m)>0?(g=!0,h=O.from(r.node(m).copy(h)),d++):c--;let p=O.empty,f=0;for(let m=o,g=!1;m>n;m--)g||i.after(m+1)<i.end(m)?(g=!0,p=O.from(i.node(m).copy(p)),f++):u++;e.step(new Ke(c,u,s,l,new E(h.append(p),d,f),h.size-d,!0))}a(vv,"uw");function bs(e,t,n=null,r=e){let i=kv(e,t),o=i&&wv(r,t);return o?i.map(nh).concat({type:t,attrs:n}).concat(o.map(nh)):null}a(bs,"Dn");function nh(e){return{type:e,attrs:null}}a(nh,"ud");function kv(e,t){let{parent:n,startIndex:r,endIndex:i}=e,o=n.contentMatchAt(r).findWrapping(t);if(!o)return null;let s=o.length?o[0]:t;return n.canReplaceWith(r,i,s)?o:null}a(kv,"fw");function wv(e,t){let{parent:n,startIndex:r,endIndex:i}=e,o=n.child(r),s=t.contentMatch.findWrapping(o.type);if(!s)return null;let l=(s.length?s[s.length-1]:t).contentMatch;for(let c=r;l&&c<i;c++)l=l.matchType(n.child(c).type);return!l||!l.validEnd?null:s}a(wv,"hw");function bv(e,t,n){let r=O.empty;for(let s=n.length-1;s>=0;s--){if(r.size){let l=n[s].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=O.from(n[s].type.create(n[s].attrs,r))}let i=t.start,o=t.end;e.step(new Ke(i,o,i,o,new E(r,0,0),n.length,!0))}a(bv,"dw");function xv(e,t,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=e.steps.length;e.doc.nodesBetween(t,n,(s,l)=>{let c=typeof i=="function"?i(s):i;if(s.isTextblock&&!s.hasMarkup(r,c)&&Sv(e.doc,e.mapping.slice(o).map(l),r)){let u=null;if(r.schema.linebreakReplacement){let f=r.whitespace=="pre",m=!!r.contentMatch.matchType(r.schema.linebreakReplacement);f&&!m?u=!1:!f&&m&&(u=!0)}u===!1&&ih(e,s,l,o),ws(e,e.mapping.slice(o).map(l,1),r,void 0,u===null);let h=e.mapping.slice(o),d=h.map(l,1),p=h.map(l+s.nodeSize,1);return e.step(new Ke(d,p,d+1,p-1,new E(O.from(r.create(c,null,s.marks)),0,0),1,!0)),u===!0&&rh(e,s,l,o),!1}})}a(xv,"pw");function rh(e,t,n,r){t.forEach((i,o)=>{if(i.isText){let s,l=/\r?\n|\r/g;for(;s=l.exec(i.text);){let c=e.mapping.slice(r).map(n+1+o+s.index);e.replaceWith(c,c+1,t.type.schema.linebreakReplacement.create())}}})}a(rh,"kd");function ih(e,t,n,r){t.forEach((i,o)=>{if(i.type==i.type.schema.linebreakReplacement){let s=e.mapping.slice(r).map(n+1+o);e.replaceWith(s,s+1,t.type.schema.text(`
38
+ `))}})}a(ih,"bd");function Sv(e,t,n){let r=e.resolve(t),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}a(Sv,"mw");function Cv(e,t,n,r,i){let o=e.doc.nodeAt(t);if(!o)throw new RangeError("No node at given position");n||(n=o.type);let s=n.create(r,null,i||o.marks);if(o.isLeaf)return e.replaceWith(t,t+o.nodeSize,s);if(!n.validContent(o.content))throw new RangeError("Invalid content for node type "+n.name);e.step(new Ke(t,t+o.nodeSize,t+1,t+o.nodeSize-1,new E(O.from(s),0,0),1,!0))}a(Cv,"gw");function kr(e,t,n=1,r){let i=e.resolve(t),o=i.depth-n,s=r&&r[r.length-1]||i.parent;if(o<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!s.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let u=i.depth-1,h=n-2;u>o;u--,h--){let d=i.node(u),p=i.index(u);if(d.type.spec.isolating)return!1;let f=d.content.cutByIndex(p,d.childCount),m=r&&r[h+1];m&&(f=f.replaceChild(0,m.type.create(m.attrs)));let g=r&&r[h]||d;if(!d.canReplace(p+1,d.childCount)||!g.type.validContent(f))return!1}let l=i.indexAfter(o),c=r&&r[0];return i.node(o).canReplaceWith(l,l,c?c.type:i.node(o+1).type)}a(kr,"Pn");function Mv(e,t,n=1,r){let i=e.doc.resolve(t),o=O.empty,s=O.empty;for(let l=i.depth,c=i.depth-n,u=n-1;l>c;l--,u--){o=O.from(i.node(l).copy(o));let h=r&&r[u];s=O.from(h?h.type.create(h.attrs,s):i.node(l).copy(s))}e.step(new qe(t,t,new E(o.append(s),n,n),!0))}a(Mv,"yw");function Ji(e,t){let n=e.resolve(t),r=n.index();return Ov(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}a(Ji,"Ln");function Nv(e,t){t.content.size||e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:r}=e.type.schema;for(let i=0;i<t.childCount;i++){let o=t.child(i),s=o.type==r?e.type.schema.nodes.text:o.type;if(n=n.matchType(s),!n||!e.type.allowsMarks(o.marks))return!1}return n.validEnd}a(Nv,"kw");function Ov(e,t){return!!(e&&t&&!e.isLeaf&&Nv(e,t))}a(Ov,"bw");function Tv(e,t,n){let r=null,{linebreakReplacement:i}=e.doc.type.schema,o=e.doc.resolve(t-n),s=o.node().type;if(i&&s.inlineContent){let h=s.whitespace=="pre",d=!!s.contentMatch.matchType(i);h&&!d?r=!1:!h&&d&&(r=!0)}let l=e.steps.length;if(r===!1){let h=e.doc.resolve(t+n);ih(e,h.node(),h.before(),l)}s.inlineContent&&ws(e,t+n-1,s,o.node().contentMatchAt(o.index()),r==null);let c=e.mapping.slice(l),u=c.map(t-n);if(e.step(new qe(u,c.map(t+n,-1),E.empty,!0)),r===!0){let h=e.doc.resolve(u);rh(e,h.node(),h.before(),e.steps.length)}return e}a(Tv,"xw");function Av(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let o=r.index(i);if(r.node(i).canReplaceWith(o,o,n))return r.before(i+1);if(o>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let o=r.indexAfter(i);if(r.node(i).canReplaceWith(o,o,n))return r.after(i+1);if(o<r.node(i).childCount)return null}return null}a(Av,"ww");function Iv(e,t,n){let r=e.resolve(t);if(!n.content.size)return t;let i=n.content;for(let o=0;o<n.openStart;o++)i=i.firstChild.content;for(let o=1;o<=(n.openStart==0&&n.size?2:1);o++)for(let s=r.depth;s>=0;s--){let l=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1,c=r.index(s)+(l>0?1:0),u=r.node(s),h=!1;if(o==1)h=u.canReplace(c,c,i);else{let d=u.contentMatchAt(c).findWrapping(i.firstChild.type);h=d&&u.canReplaceWith(c,c,d[0])}if(h)return l==0?r.pos:l<0?r.before(s+1):r.after(s+1)}return null}a(Iv,"xd");function Ui(e,t,n=t,r=E.empty){if(t==n&&!r.size)return null;let i=e.resolve(t),o=e.resolve(n);return oh(i,o,r)?new qe(t,n,r):new Ev(i,o,r).fit()}a(Ui,"Ti");function oh(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}a(oh,"wd");var Ev=class{static{a(this,"$l")}constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=O.empty;for(let r=0;r<=e.depth;r++){let i=e.node(r);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(r))})}for(let r=e.depth;r>0;r--)this.placed=O.from(e.node(r).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,r=this.close(e<0?this.$to:n.doc.resolve(e));if(!r)return null;let i=this.placed,o=n.depth,s=r.depth;for(;o&&s&&i.childCount==1;)i=i.firstChild.content,o--,s--;let l=new E(i,o,s);return e>-1?new Ke(n.pos,e,this.$to.pos,this.$to.end(),l,t):l.size||n.pos!=this.$to.pos?new qe(n.pos,r.pos,l):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,r=this.unplaced.openEnd;n<e;n++){let i=t.firstChild;if(t.childCount>1&&(r=0),i.type.spec.isolating&&r<=n){e=n;break}t=i.content}for(let t=1;t<=2;t++)for(let n=t==1?e:this.unplaced.openStart;n>=0;n--){let r,i=null;n?(i=sh(this.unplaced.content,n-1).firstChild,r=i.content):r=this.unplaced.content;let o=r.firstChild;for(let s=this.depth;s>=0;s--){let{type:l,match:c}=this.frontier[s],u,h=null;if(t==1&&(o?c.matchType(o.type)||(h=c.fillBefore(O.from(o),!1)):i&&l.compatibleContent(i.type)))return{sliceDepth:n,frontierDepth:s,parent:i,inject:h};if(t==2&&o&&(u=c.findWrapping(o.type)))return{sliceDepth:n,frontierDepth:s,parent:i,wrap:u};if(i&&c.matchType(i.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced;return ah(e,-1)<=t?!1:(this.unplaced.size>1&&ah(e,1)>n&&n++,this.unplaced=new E(e,t+1,n),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=sh(e,t);if(r.childCount<=1&&t>0){let i=e.size-t<=t+r.size;this.unplaced=new E(wr(e,t-1,1),t-1,i?t-1:n)}else this.unplaced=new E(wr(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:r,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let m=0;m<i.length;m++)this.openFrontierNode(i[m]);let o=this.unplaced,s=n?n.content:o.content,l=o.openStart-e,c=0,u=[],{match:h,type:d}=this.frontier[t];if(r){for(let m=0;m<r.childCount;m++)u.push(r.child(m));h=h.matchFragment(r)}let p=s.size+e-(o.content.size-o.openEnd);for(;c<s.childCount;){let m=s.child(c),g=h.matchType(m.type);if(!g)break;c++,(c>1||l==0||m.content.size)&&(h=g,u.push(lh(m.mark(d.allowedMarks(m.marks)),c==1?l:0,c==s.childCount?p:-1)))}let f=c==s.childCount;f||(p=-1),this.placed=br(this.placed,t,O.from(u)),this.frontier[t].match=h,f&&p<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=s;m<p;m++){let v=g.lastChild;this.frontier.push({type:v.type,match:v.contentMatchAt(v.childCount)}),g=v.content}this.unplaced=f?e==0?E.empty:new E(wr(o.content,e-1,1),e-1,p<0?o.openEnd:e-1):new E(wr(o.content,e,c),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!xs(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:n}=this.$to,r=this.$to.after(n);for(;n>1&&r==this.$to.end(--n);)++r;return r}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:r}=this.frontier[t],i=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),o=xs(e,t,r,n,i);if(o){for(let s=t-1;s>=0;s--){let{match:l,type:c}=this.frontier[s],u=xs(e,s,c,l,!0);if(!u||u.childCount)continue e}return{depth:t,fit:o,move:i?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=br(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let r=e.node(n),i=r.type.contentMatch.fillBefore(r.content,!0,e.index(n));this.openFrontierNode(r.type,r.attrs,i)}return e}openFrontierNode(e,t=null,n){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=br(this.placed,this.depth,O.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(O.empty,!0);e.childCount&&(this.placed=br(this.placed,this.frontier.length,e))}};function wr(e,t,n){return t==0?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(wr(e.firstChild.content,t-1,n)))}a(wr,"Ci");function br(e,t,n){return t==0?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(br(e.lastChild.content,t-1,n)))}a(br,"Si");function sh(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}a(sh,"fd");function lh(e,t,n){if(t<=0)return e;let r=e.content;return t>1&&(r=r.replaceChild(0,lh(r.firstChild,t-1,r.childCount==1?n-1:0))),t>0&&(r=e.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(e.type.contentMatch.matchFragment(r).fillBefore(O.empty,!0)))),e.copy(r)}a(lh,"Cd");function xs(e,t,n,r,i){let o=e.node(t),s=i?e.indexAfter(t):e.index(t);if(s==o.childCount&&!n.compatibleContent(o.type))return null;let l=r.fillBefore(o.content,!0,s);return l&&!Dv(n,o.content,s)?l:null}a(xs,"Fl");function Dv(e,t,n){for(let r=n;r<t.childCount;r++)if(!e.allowsMarks(t.child(r).marks))return!0;return!1}a(Dv,"Cw");function Rv(e){return e.spec.defining||e.spec.definingForContent}a(Rv,"Sw");function ah(e,t){for(let n=0;;n++){let r=t<0?e.firstChild:e.lastChild;if(!r||r.isAtom)return n;e=r.content}}a(ah,"hd");function zv(e,t,n,r){if(!r.size)return e.deleteRange(t,n);let i=e.doc.resolve(t),o=e.doc.resolve(n);if(oh(i,o,r))return e.step(new qe(t,n,r));let s=uh(i,o);s[s.length-1]==0&&s.pop();let l=-(i.depth+1);s.unshift(l);for(let p=i.depth,f=i.pos-1;p>0;p--,f--){let m=i.node(p).type.spec;if(m.defining||m.definingAsContext||m.isolating)break;s.indexOf(p)>-1?l=p:i.before(p)==f&&s.splice(1,0,-p)}let c=s.indexOf(l),u=[],h=r.openStart;for(let p=r.content,f=0;;f++){let m=p.firstChild;if(u.push(m),f==r.openStart)break;p=m.content}for(let p=h-1;p>=0;p--){let f=u[p],m=Rv(f.type);if(m&&!f.sameMarkup(i.node(Math.abs(l)-1)))h=p;else if(m||!f.type.isTextblock)break}for(let p=r.openStart;p>=0;p--){let f=(p+h+1)%(r.openStart+1),m=u[f];if(m)for(let g=0;g<s.length;g++){let v=s[(g+c)%s.length],y=!0;v<0&&(y=!1,v=-v);let N=i.node(v-1),x=i.index(v-1);if(N.canReplaceWith(x,x,m.type,m.marks))return e.replace(i.before(v),y?o.after(v):n,new E(ch(r.content,0,r.openStart,f),f,r.openEnd))}}let d=e.steps.length;for(let p=s.length-1;p>=0&&(e.replace(t,n,r),!(e.steps.length>d));p--){let f=s[p];f<0||(t=i.before(f),n=o.after(f))}}a(zv,"Mw");function ch(e,t,n,r,i){if(t<n){let o=e.firstChild;e=e.replaceChild(0,o.copy(ch(o.content,t+1,n,r,o)))}if(t>r){let o=i.contentMatchAt(0),s=o.fillBefore(e).append(e);e=s.append(o.matchFragment(s).fillBefore(O.empty,!0))}return e}a(ch,"Sd");function Pv(e,t,n,r){if(!r.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let i=Av(e.doc,t,r.type);i!=null&&(t=n=i)}e.replaceRange(t,n,new E(O.from(r),0,0))}a(Pv,"Nw");function Fv(e,t,n){let r=e.doc.resolve(t),i=e.doc.resolve(n);if(r.parent.isTextblock&&i.parent.isTextblock&&r.start()!=i.start()&&r.parentOffset==0&&i.parentOffset==0){let s=r.sharedDepth(n),l=!1;for(let c=r.depth;c>s;c--)r.node(c).type.spec.isolating&&(l=!0);for(let c=i.depth;c>s;c--)i.node(c).type.spec.isolating&&(l=!0);if(!l){for(let c=r.depth;c>0&&t==r.start(c);c--)t=r.before(c);for(let c=i.depth;c>0&&n==i.start(c);c--)n=i.before(c);r=e.doc.resolve(t),i=e.doc.resolve(n)}}let o=uh(r,i);for(let s=0;s<o.length;s++){let l=o[s],c=s==o.length-1;if(c&&l==0||r.node(l).type.contentMatch.validEnd)return e.delete(r.start(l),i.end(l));if(l>0&&(c||r.node(l-1).canReplace(r.index(l-1),i.indexAfter(l-1))))return e.delete(r.before(l),i.after(l))}for(let s=1;s<=r.depth&&s<=i.depth;s++)if(t-r.start(s)==r.depth-s&&n>r.end(s)&&i.end(s)-n!=i.depth-s&&r.start(s-1)==i.start(s-1)&&r.node(s-1).canReplace(r.index(s-1),i.index(s-1)))return e.delete(r.before(s),n);e.delete(t,n)}a(Fv,"vw");function uh(e,t){let n=[],r=Math.min(e.depth,t.depth);for(let i=r;i>=0;i--){let o=e.start(i);if(o<e.pos-(e.depth-i)||t.end(i)>t.pos+(t.depth-i)||e.node(i).type.spec.isolating||t.node(i).type.spec.isolating)break;(o==t.start(i)||i==e.depth&&i==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&i&&t.start(i-1)==o-1)&&n.push(i)}return n}a(uh,"Md");var hh=class Ro extends ge{static{a(this,"t")}constructor(t,n,r){super(),this.pos=t,this.attr=n,this.value=r}apply(t){let n=t.nodeAt(this.pos);if(!n)return Ce.fail("No node at attribute step's position");let r=Object.create(null);for(let o in n.attrs)r[o]=n.attrs[o];r[this.attr]=this.value;let i=n.type.create(r,null,n.marks);return Ce.fromReplace(t,this.pos,this.pos+1,new E(O.from(i),0,n.isLeaf?0:1))}getMap(){return sn.empty}invert(t){return new Ro(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new Ro(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Ro(n.pos,n.attr,n.value)}};ge.jsonID("attr",hh);var dh=class cc extends ge{static{a(this,"t")}constructor(t,n){super(),this.attr=t,this.value=n}apply(t){let n=Object.create(null);for(let i in t.attrs)n[i]=t.attrs[i];n[this.attr]=this.value;let r=t.type.create(n,t.content,t.marks);return Ce.ok(r)}getMap(){return sn.empty}invert(t){return new cc(this.attr,t.attrs[this.attr])}map(t){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new cc(n.attr,n.value)}};ge.jsonID("docAttr",dh);var Tn=class extends Error{static{a(this,"xr")}};Tn=a(function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},"t"),Tn.prototype=Object.create(Error.prototype),Tn.prototype.constructor=Tn,Tn.prototype.name="TransformError";var ph=class{static{a(this,"wr")}constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new th}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Tn(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let n=0;n<this.mapping.maps.length;n++){let r=this.mapping.maps[n];n&&(e=r.map(e,1),t=r.map(t,-1)),r.forEach((i,o,s,l)=>{e=Math.min(e,s),t=Math.max(t,l)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=E.empty){let r=Ui(this.doc,e,t,n);return r&&this.step(r),this}replaceWith(e,t,n){return this.replace(e,t,new E(O.from(n),0,0))}delete(e,t){return this.replace(e,t,E.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return zv(this,e,t,n),this}replaceRangeWith(e,t,n){return Pv(this,e,t,n),this}deleteRange(e,t){return Fv(this,e,t),this}lift(e,t){return vv(this,e,t),this}join(e,t=1){return Tv(this,e,t),this}wrap(e,t){return bv(this,e,t),this}setBlockType(e,t=e,n,r=null){return xv(this,e,t,n,r),this}setNodeMarkup(e,t,n=null,r){return Cv(this,e,t,n,r),this}setNodeAttribute(e,t,n){return this.step(new hh(e,t,n)),this}setDocAttribute(e,t){return this.step(new dh(e,t)),this}addNodeMark(e,t){return this.step(new vs(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw new RangeError("No node at position "+e);if(t instanceof X)t.isInSet(n.marks)&&this.step(new qi(e,t));else{let r=n.marks,i,o=[];for(;i=t.isInSet(r);)o.push(new qi(e,i)),r=i.removeFromSet(r);for(let s=o.length-1;s>=0;s--)this.step(o[s])}return this}split(e,t=1,n){return Mv(this,e,t,n),this}addMark(e,t,n){return mv(this,e,t,n),this}removeMark(e,t,n){return gv(this,e,t,n),this}clearIncompatible(e,t,n){return ws(this,e,t,n),this}},Ss=Object.create(null),j=class{static{a(this,"B")}constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new Gi(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=E.empty){let n=t.content.lastChild,r=null;for(let s=0;s<t.openEnd;s++)r=n,n=n.lastChild;let i=e.steps.length,o=this.ranges;for(let s=0;s<o.length;s++){let{$from:l,$to:c}=o[s],u=e.mapping.slice(i);e.replaceRange(u.map(l.pos),u.map(c.pos),s?E.empty:t),s==0&&yh(e,i,(n?n.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,r=this.ranges;for(let i=0;i<r.length;i++){let{$from:o,$to:s}=r[i],l=e.mapping.slice(n),c=l.map(o.pos),u=l.map(s.pos);i?e.deleteRange(c,u):(e.replaceRangeWith(c,u,t),yh(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let r=e.parent.inlineContent?new q(e):An(e.node(0),e.parent,e.pos,e.index(),t,n);if(r)return r;for(let i=e.depth-1;i>=0;i--){let o=t<0?An(e.node(0),e.node(i),e.before(i+1),e.index(i),t,n):An(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,t,n);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new wt(e.node(0))}static atStart(e){return An(e,e,0,0,1)||new wt(e)}static atEnd(e){return An(e,e,e.content.size,e.childCount,-1)||new wt(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=Ss[t.type];if(!n)throw new RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in Ss)throw new RangeError("Duplicate use of selection JSON ID "+e);return Ss[e]=t,t.prototype.jsonID=e,t}getBookmark(){return q.between(this.$anchor,this.$head).getBookmark()}};j.prototype.visible=!0;var Gi=class{static{a(this,"Zt")}constructor(e,t){this.$from=e,this.$to=t}},fh=!1;function mh(e){!fh&&!e.parent.inlineContent&&(fh=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}a(mh,"vd");var q=class yi extends j{static{a(this,"t")}constructor(t,n=t){mh(t),mh(n),super(t,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,n){let r=t.resolve(n.map(this.head));if(!r.parent.inlineContent)return j.near(r);let i=t.resolve(n.map(this.anchor));return new yi(i.parent.inlineContent?i:r,r)}replace(t,n=E.empty){if(super.replace(t,n),n==E.empty){let r=this.$from.marksAcross(this.$to);r&&t.ensureMarks(r)}}eq(t){return t instanceof yi&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new gh(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(t,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new yi(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,r=n){let i=t.resolve(n);return new this(i,r==n?i:t.resolve(r))}static between(t,n,r){let i=t.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let o=j.findFrom(n,r,!0)||j.findFrom(n,-r,!0);if(o)n=o.$head;else return j.near(n,r)}return t.parent.inlineContent||(i==0?t=n:(t=(j.findFrom(t,-r,!0)||j.findFrom(t,r,!0)).$anchor,t.pos<n.pos!=i<0&&(t=n))),new yi(t,n)}};j.jsonID("text",q);var gh=class Nm{static{a(this,"t")}constructor(t,n){this.anchor=t,this.head=n}map(t){return new Nm(t.map(this.anchor),t.map(this.head))}resolve(t){return q.between(t.resolve(this.anchor),t.resolve(this.head))}},_=class vi extends j{static{a(this,"t")}constructor(t){let n=t.nodeAfter,r=t.node(0).resolve(t.pos+n.nodeSize);super(t,r),this.node=n}map(t,n){let{deleted:r,pos:i}=n.mapResult(this.anchor),o=t.resolve(i);return r?j.near(o):new vi(o)}content(){return new E(O.from(this.node),0,0)}eq(t){return t instanceof vi&&t.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Lv(this.anchor)}static fromJSON(t,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new vi(t.resolve(n.anchor))}static create(t,n){return new vi(t.resolve(n))}static isSelectable(t){return!t.isText&&t.type.spec.selectable!==!1}};_.prototype.visible=!1,j.jsonID("node",_);var Lv=class Om{static{a(this,"t")}constructor(t){this.anchor=t}map(t){let{deleted:n,pos:r}=t.mapResult(this.anchor);return n?new gh(r,r):new Om(r)}resolve(t){let n=t.resolve(this.anchor),r=n.nodeAfter;return r&&_.isSelectable(r)?new _(n):j.near(n)}},wt=class zo extends j{static{a(this,"t")}constructor(t){super(t.resolve(0),t.resolve(t.content.size))}replace(t,n=E.empty){if(n==E.empty){t.delete(0,t.doc.content.size);let r=j.atStart(t.doc);r.eq(t.selection)||t.setSelection(r)}else super.replace(t,n)}toJSON(){return{type:"all"}}static fromJSON(t){return new zo(t)}map(t){return new zo(t)}eq(t){return t instanceof zo}getBookmark(){return $v}};j.jsonID("all",wt);var $v={map(){return this},resolve(e){return new wt(e)}};function An(e,t,n,r,i,o=!1){if(t.inlineContent)return q.create(e,n);for(let s=r-(i>0?0:1);i>0?s<t.childCount:s>=0;s+=i){let l=t.child(s);if(l.isAtom){if(!o&&_.isSelectable(l))return _.create(e,n-(i<0?l.nodeSize:0))}else{let c=An(e,l,n+i,i<0?l.childCount:0,i,o);if(c)return c}n+=l.nodeSize*i}return null}a(An,"Sr");function yh(e,t,n){let r=e.steps.length-1;if(r<t)return;let i=e.steps[r];if(!(i instanceof qe||i instanceof Ke))return;let o=e.mapping.maps[r],s;o.forEach((l,c,u,h)=>{s==null&&(s=h)}),e.setSelection(j.near(e.doc.resolve(s),n))}a(yh,"Td");var vh=1,Qi=2,kh=4,Bv=class extends ph{static{a(this,"ql")}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|vh)&~Qi,this.storedMarks=null,this}get selectionSet(){return(this.updated&vh)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Qi,this}ensureMarks(e){return X.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&Qi)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~Qi,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||X.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let r=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(n==null&&(n=t),!e)return this.deleteRange(t,n);let i=this.storedMarks;if(!i){let o=this.doc.resolve(t);i=n==t?o.marks():o.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,i)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(j.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|=kh,this}get scrolledIntoView(){return(this.updated&kh)>0}};function wh(e,t){return!t||!e?e:e.bind(t)}a(wh,"Ed");var xr=class{static{a(this,"zn")}constructor(e,t,n){this.name=e,this.init=wh(t.init,n),this.apply=wh(t.apply,n)}},Vv=[new xr("doc",{init(e){return e.doc||e.schema.topNodeType.createAndFill()},apply(e){return e.doc}}),new xr("selection",{init(e,t){return e.selection||j.atStart(t.doc)},apply(e){return e.selection}}),new xr("storedMarks",{init(e){return e.storedMarks||null},apply(e,t,n,r){return r.selection.$cursor?e.storedMarks:null}}),new xr("scrollToSelection",{init(){return 0},apply(e,t){return e.scrolledIntoView?t+1:t}})],Cs=class{static{a(this,"Ii")}constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Vv.slice(),t&&t.forEach(n=>{if(this.pluginsByKey[n.key])throw new RangeError("Adding different instances of a keyed plugin ("+n.key+")");this.plugins.push(n),this.pluginsByKey[n.key]=n,n.spec.state&&this.fields.push(new xr(n.key,n.spec.state,n))})}},jv=class ki{static{a(this,"t")}constructor(t){this.config=t}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(t){return this.applyTransaction(t).state}filterTransaction(t,n=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=n){let i=this.config.plugins[r];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,t,this))return!1}return!0}applyTransaction(t){if(!this.filterTransaction(t))return{state:this,transactions:[]};let n=[t],r=this.applyInner(t),i=null;for(;;){let o=!1;for(let s=0;s<this.config.plugins.length;s++){let l=this.config.plugins[s];if(l.spec.appendTransaction){let c=i?i[s].n:0,u=i?i[s].state:this,h=c<n.length&&l.spec.appendTransaction.call(l,c?n.slice(c):n,u,r);if(h&&r.filterTransaction(h,s)){if(h.setMeta("appendedTransaction",t),!i){i=[];for(let d=0;d<this.config.plugins.length;d++)i.push(d<s?{state:r,n:n.length}:{state:this,n:0})}n.push(h),r=r.applyInner(h),o=!0}i&&(i[s]={state:r,n:n.length})}}if(!o)return{state:r,transactions:n}}}applyInner(t){if(!t.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new ki(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let o=r[i];n[o.name]=o.apply(t,this[o.name],this,n)}return n}get tr(){return new Bv(this)}static create(t){let n=new Cs(t.doc?t.doc.type.schema:t.schema,t.plugins),r=new ki(n);for(let i=0;i<n.fields.length;i++)r[n.fields[i].name]=n.fields[i].init(t,r);return r}reconfigure(t){let n=new Cs(this.schema,t.plugins),r=n.fields,i=new ki(n);for(let o=0;o<r.length;o++){let s=r[o].name;i[s]=this.hasOwnProperty(s)?this[s]:r[o].init(t,i)}return i}toJSON(t){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(r=>r.toJSON())),t&&typeof t=="object")for(let r in t){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=t[r],o=i.spec.state;o&&o.toJSON&&(n[r]=o.toJSON.call(i,this[i.key]))}return n}static fromJSON(t,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!t.schema)throw new RangeError("Required config field 'schema' missing");let i=new Cs(t.schema,t.plugins),o=new ki(i);return i.fields.forEach(s=>{if(s.name=="doc")o.doc=kt.fromJSON(t.schema,n.doc);else if(s.name=="selection")o.selection=j.fromJSON(o.doc,n.selection);else if(s.name=="storedMarks")n.storedMarks&&(o.storedMarks=n.storedMarks.map(t.schema.markFromJSON));else{if(r)for(let l in r){let c=r[l],u=c.spec.state;if(c.key==s.name&&u&&u.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){o[s.name]=u.fromJSON.call(c,t,n[l],o);return}}o[s.name]=s.init(t,o)}}),o}};function bh(e,t,n){for(let r in e){let i=e[r];i instanceof Function?i=i.bind(t):r=="handleDOMEvents"&&(i=bh(i,t,{})),n[r]=i}return n}a(bh,"Od");var ye=class{static{a(this,"ne")}constructor(e){this.spec=e,this.props={},e.props&&bh(e.props,this,this.props),this.key=e.key?e.key.key:xh("plugin")}getState(e){return e[this.key]}},Ms=Object.create(null);function xh(e){return e in Ms?e+"$"+ ++Ms[e]:(Ms[e]=0,e+"$")}a(xh,"Rd");var ve=class{static{a(this,"re")}constructor(e="key"){this.key=xh(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}},Ns=a((e,t)=>e.selection.empty?!1:(t&&t(e.tr.deleteSelection().scrollIntoView()),!0),"jo");function Sh(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("backward",e):n.parentOffset>0)?null:n}a(Sh,"Pd");var Ch=a((e,t,n)=>{let r=Sh(e,n);if(!r)return!1;let i=Os(r);if(!i){let s=r.blockRange(),l=s&&Ki(s);return l==null?!1:(t&&t(e.tr.lift(s,l).scrollIntoView()),!0)}let o=i.nodeBefore;if(Oh(e,i,t,-1))return!0;if(r.parent.content.size==0&&(In(o,"end")||_.isSelectable(o)))for(let s=r.depth;;s--){let l=Ui(e.doc,r.before(s),r.after(s),E.empty);if(l&&l.slice.size<l.to-l.from){if(t){let c=e.tr.step(l);c.setSelection(In(o,"end")?j.findFrom(c.doc.resolve(c.mapping.map(i.pos,-1)),-1):_.create(c.doc,i.pos-o.nodeSize)),t(c.scrollIntoView())}return!0}if(s==1||r.node(s-1).childCount>1)break}return o.isAtom&&i.depth==r.depth-1?(t&&t(e.tr.delete(i.pos-o.nodeSize,i.pos).scrollIntoView()),!0):!1},"Ul"),_v=a((e,t,n)=>{let r=Sh(e,n);if(!r)return!1;let i=Os(r);return i?Hv(e,i,t):!1},"Ld");function Hv(e,t,n){let r=t.nodeBefore,i=r,o=t.pos-1;for(;!i.isTextblock;o--){if(i.type.spec.isolating)return!1;let h=i.lastChild;if(!h)return!1;i=h}let s=t.nodeAfter,l=s,c=t.pos+1;for(;!l.isTextblock;c++){if(l.type.spec.isolating)return!1;let h=l.firstChild;if(!h)return!1;l=h}let u=Ui(e.doc,o,c,E.empty);if(!u||u.from!=o||u instanceof qe&&u.slice.size>=c-o)return!1;if(n){let h=e.tr.step(u);h.setSelection(q.create(h.doc,o)),n(h.scrollIntoView())}return!0}a(Hv,"Aw");function In(e,t,n=!1){for(let r=e;r;r=t=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}a(In,"Mr");var Mh=a((e,t,n)=>{let{$head:r,empty:i}=e.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",e):r.parentOffset>0)return!1;o=Os(r)}let s=o&&o.nodeBefore;return!s||!_.isSelectable(s)?!1:(t&&t(e.tr.setSelection(_.create(e.doc,o.pos-s.nodeSize)).scrollIntoView()),!0)},"Gl");function Os(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}a(Os,"Yl");function Wv(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("forward",e):n.parentOffset<n.parent.content.size)?null:n}a(Wv,"Ew");var qv=a((e,t,n)=>{let r=Wv(e,n);if(!r)return!1;let i=Nh(r);if(!i)return!1;let o=i.nodeAfter;if(Oh(e,i,t,1))return!0;if(r.parent.content.size==0&&(In(o,"start")||_.isSelectable(o))){let s=Ui(e.doc,r.before(),r.after(),E.empty);if(s&&s.slice.size<s.to-s.from){if(t){let l=e.tr.step(s);l.setSelection(In(o,"start")?j.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):_.create(l.doc,l.mapping.map(i.pos))),t(l.scrollIntoView())}return!0}}return o.isAtom&&i.depth==r.depth-1?(t&&t(e.tr.delete(i.pos,i.pos+o.nodeSize).scrollIntoView()),!0):!1},"Ow"),Kv=a((e,t,n)=>{let{$head:r,empty:i}=e.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",e):r.parentOffset<r.parent.content.size)return!1;o=Nh(r)}let s=o&&o.nodeAfter;return!s||!_.isSelectable(s)?!1:(t&&t(e.tr.setSelection(_.create(e.doc,o.pos)).scrollIntoView()),!0)},"Rw");function Nh(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){let n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}a(Nh,"zd");var Jv=a((e,t)=>{let{$head:n,$anchor:r}=e.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(t&&t(e.tr.insertText(`
39
+ `).scrollIntoView()),!0)},"Dw");function Ts(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}a(Ts,"Ql");var Uv=a((e,t)=>{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),o=n.indexAfter(-1),s=Ts(i.contentMatchAt(o));if(!s||!i.canReplaceWith(o,o,s))return!1;if(t){let l=n.after(),c=e.tr.replaceWith(l,l,s.createAndFill());c.setSelection(j.near(c.doc.resolve(l),1)),t(c.scrollIntoView())}return!0},"Pw"),Gv=a((e,t)=>{let n=e.selection,{$from:r,$to:i}=n;if(n instanceof wt||r.parent.inlineContent||i.parent.inlineContent)return!1;let o=Ts(i.parent.contentMatchAt(i.indexAfter()));if(!o||!o.isTextblock)return!1;if(t){let s=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,l=e.tr.insert(s,o.createAndFill());l.setSelection(q.create(l.doc,s+1)),t(l.scrollIntoView())}return!0},"Lw"),Qv=a((e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let o=n.before();if(kr(e.doc,o))return t&&t(e.tr.split(o).scrollIntoView()),!0}let r=n.blockRange(),i=r&&Ki(r);return i==null?!1:(t&&t(e.tr.lift(r,i).scrollIntoView()),!0)},"zw");function Yv(e){return(t,n)=>{if(t.selection instanceof _&&t.selection.node.isBlock){let{$from:f}=t.selection;return!f.parentOffset||!kr(t.doc,f.pos)?!1:(n&&n(t.tr.split(f.pos).scrollIntoView()),!0)}if(!t.selection.$from.depth)return!1;let r=t.tr;!t.selection.empty&&(t.selection instanceof q||t.selection instanceof wt)&&r.deleteSelection();let{$from:i}=r.selection,o=r.steps.length,s=[],l,c,u=!1,h=!1;for(let f=i.depth;;f--)if(i.node(f).isBlock){u=i.end(f)==i.pos+(i.depth-f),h=i.start(f)==i.pos-(i.depth-f),c=Ts(i.node(f-1).contentMatchAt(i.indexAfter(f-1)));let m=e&&e(i.parent,u,i);s.unshift(m||(u&&c?{type:c}:null)),l=f;break}else{if(f==1)return!1;s.unshift(null)}let d=i.pos,p=kr(r.doc,d,s.length,s);if(p||(s[0]=c?{type:c}:null,p=kr(r.doc,d,s.length,s)),!p)return!1;if(r.split(d,s.length,s),!u&&h&&i.node(l).type!=c){let f=r.mapping.slice(o),m=f.map(i.before(l)),g=r.doc.resolve(m);c&&i.node(l-1).canReplaceWith(g.index(),g.index()+1,c)&&r.setNodeMarkup(f.map(i.before(l)),c)}return n&&n(r.scrollIntoView()),!0}}a(Yv,"Bw");var Xv=Yv(),Zv=a((e,t)=>(t&&t(e.tr.setSelection(new wt(e.doc))),!0),"_w");function ek(e,t,n){let r=t.nodeBefore,i=t.nodeAfter,o=t.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&t.parent.canReplace(o-1,o)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),!0):!t.parent.canReplace(o,o+1)||!(i.isTextblock||Ji(e.doc,t.pos))?!1:(n&&n(e.tr.join(t.pos).scrollIntoView()),!0)}a(ek,"$w");function Oh(e,t,n,r){let i=t.nodeBefore,o=t.nodeAfter,s,l,c=i.type.spec.isolating||o.type.spec.isolating;if(!c&&ek(e,t,n))return!0;let u=!c&&t.parent.canReplace(t.index(),t.index()+1);if(u&&(s=(l=i.contentMatchAt(i.childCount)).findWrapping(o.type))&&l.matchType(s[0]||o.type).validEnd){if(n){let f=t.pos+o.nodeSize,m=O.empty;for(let y=s.length-1;y>=0;y--)m=O.from(s[y].create(null,m));m=O.from(i.copy(m));let g=e.tr.step(new Ke(t.pos-1,f,t.pos,f,new E(m,1,0),s.length,!0)),v=g.doc.resolve(f+2*s.length);v.nodeAfter&&v.nodeAfter.type==i.type&&Ji(g.doc,v.pos)&&g.join(v.pos),n(g.scrollIntoView())}return!0}let h=o.type.spec.isolating||r>0&&c?null:j.findFrom(t,1),d=h&&h.$from.blockRange(h.$to),p=d&&Ki(d);if(p!=null&&p>=t.depth)return n&&n(e.tr.lift(d,p).scrollIntoView()),!0;if(u&&In(o,"start",!0)&&In(i,"end")){let f=i,m=[];for(;m.push(f),!f.isTextblock;)f=f.lastChild;let g=o,v=1;for(;!g.isTextblock;g=g.firstChild)v++;if(f.canReplace(f.childCount,f.childCount,g.content)){if(n){let y=O.empty;for(let x=m.length-1;x>=0;x--)y=O.from(m[x].copy(y));let N=e.tr.step(new Ke(t.pos-m.length,t.pos+o.nodeSize,t.pos+v,t.pos+o.nodeSize-v,new E(y,m.length,0),0,!0));n(N.scrollIntoView())}return!0}}return!1}a(Oh,"Bd");function Th(e){return function(t,n){let r=t.selection,i=e<0?r.$from:r.$to,o=i.depth;for(;i.node(o).isInline;){if(!o)return!1;o--}return i.node(o).isTextblock?(n&&n(t.tr.setSelection(q.create(t.doc,e<0?i.start(o):i.end(o)))),!0):!1}}a(Th,"Fd");var tk=Th(-1),nk=Th(1);function As(e,t=null){return function(n,r){let{$from:i,$to:o}=n.selection,s=i.blockRange(o),l=s&&bs(s,e,t);return l?(r&&r(n.tr.wrap(s,l).scrollIntoView()),!0):!1}}a(As,"Ko");function Sr(e,t=null){return function(n,r){let i=!1;for(let o=0;o<n.selection.ranges.length&&!i;o++){let{$from:{pos:s},$to:{pos:l}}=n.selection.ranges[o];n.doc.nodesBetween(s,l,(c,u)=>{if(i)return!1;if(!(!c.isTextblock||c.hasMarkup(e,t)))if(c.type==e)i=!0;else{let h=n.doc.resolve(u),d=h.index();i=h.parent.canReplaceWith(d,d+1,e)}})}if(!i)return!1;if(r){let o=n.tr;for(let s=0;s<n.selection.ranges.length;s++){let{$from:{pos:l},$to:{pos:c}}=n.selection.ranges[s];o.setBlockType(l,c,e,t)}r(o.scrollIntoView())}return!0}}a(Sr,"Nr");function rk(e,t,n,r){for(let i=0;i<t.length;i++){let{$from:o,$to:s}=t[i],l=o.depth==0?e.inlineContent&&e.type.allowsMarkType(n):!1;if(e.nodesBetween(o.pos,s.pos,(c,u)=>{if(l||!r&&c.isAtom&&c.isInline&&u>=o.pos&&u+c.nodeSize<=s.pos)return!1;l=c.inlineContent&&c.type.allowsMarkType(n)}),l)return!0}return!1}a(rk,"jw");function ik(e){let t=[];for(let n=0;n<e.length;n++){let{$from:r,$to:i}=e[n];r.doc.nodesBetween(r.pos,i.pos,(o,s)=>{if(o.isAtom&&o.content.size&&o.isInline&&s>=r.pos&&s+o.nodeSize<=i.pos)return s+1>r.pos&&t.push(new Gi(r,r.doc.resolve(s+1))),r=r.doc.resolve(s+1+o.content.size),!1}),r.pos<i.pos&&t.push(new Gi(r,i))}return t}a(ik,"Kw");function Yi(e,t=null,n){let r=(n&&n.removeWhenPresent)!==!1,i=(n&&n.enterInlineAtoms)!==!1,o=!(n&&n.includeWhitespace);return function(s,l){let{empty:c,$cursor:u,ranges:h}=s.selection;if(c&&!u||!rk(s.doc,h,e,i))return!1;if(l)if(u)e.isInSet(s.storedMarks||u.marks())?l(s.tr.removeStoredMark(e)):l(s.tr.addStoredMark(e.create(t)));else{let d,p=s.tr;i||(h=ik(h)),r?d=!h.some(f=>s.doc.rangeHasMark(f.$from.pos,f.$to.pos,e)):d=!h.every(f=>{let m=!1;return p.doc.nodesBetween(f.$from.pos,f.$to.pos,(g,v,y)=>{if(m)return!1;m=!e.isInSet(g.marks)&&!!y&&y.type.allowsMarkType(e)&&!(g.isText&&/^\s*$/.test(g.textBetween(Math.max(0,f.$from.pos-v),Math.min(g.nodeSize,f.$to.pos-v))))}),!m});for(let f=0;f<h.length;f++){let{$from:m,$to:g}=h[f];if(!d)p.removeMark(m.pos,g.pos,e);else{let v=m.pos,y=g.pos,N=m.nodeAfter,x=g.nodeBefore,A=o&&N&&N.isText?/^\s*/.exec(N.text)[0].length:0,D=o&&x&&x.isText?/\s*$/.exec(x.text)[0].length:0;v+A<y&&(v+=A,y-=D),p.addMark(v,y,e.create(t))}}l(p.scrollIntoView())}return!0}}a(Yi,"vr");function En(...e){return function(t,n,r){for(let i=0;i<e.length;i++)if(e[i](t,n,r))return!0;return!1}}a(En,"Bn");var Is=En(Ns,Ch,Mh),Ah=En(Ns,qv,Kv),bt={Enter:En(Jv,Gv,Qv,Xv),"Mod-Enter":Uv,Backspace:Is,"Mod-Backspace":Is,"Shift-Backspace":Is,Delete:Ah,"Mod-Delete":Ah,"Mod-a":Zv},Ih={"Ctrl-h":bt.Backspace,"Alt-Backspace":bt["Mod-Backspace"],"Ctrl-d":bt.Delete,"Ctrl-Alt-Backspace":bt["Mod-Delete"],"Alt-Delete":bt["Mod-Delete"],"Alt-d":bt["Mod-Delete"],"Ctrl-a":tk,"Ctrl-e":nk};for(let e in bt)Ih[e]=bt[e];var ok=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,sk=ok?Ih:bt,$e=class{static{a(this,"ke")}constructor(e,t,n={}){this.match=e,this.match=e,this.handler=typeof t=="string"?lk(t):t,this.undoable=n.undoable!==!1,this.inCode=n.inCode||!1,this.inCodeMark=n.inCodeMark!==!1}};function lk(e){return function(t,n,r,i){let o=e;if(n[1]){let s=n[0].lastIndexOf(n[1]);o+=n[0].slice(s+n[1].length),r+=s;let l=r-i;l>0&&(o=n[0].slice(s-l,s)+o,r=i)}return t.tr.insertText(o,r,i)}}a(lk,"qw");var ak=a((e,t)=>{let n=e.plugins;for(let r=0;r<n.length;r++){let i=n[r],o;if(i.spec.isInputRules&&(o=i.getState(e))){if(t){let s=e.tr,l=o.transform;for(let c=l.steps.length-1;c>=0;c--)s.step(l.steps[c].invert(l.docs[c]));if(o.text){let c=s.doc.resolve(o.from).marks();s.replaceWith(o.from,o.to,e.schema.text(o.text,c))}else s.delete(o.from,o.to);t(s)}return!0}}return!1},"Vd"),tN=new $e(/--$/,"\u2014",{inCodeMark:!1}),nN=new $e(/\.\.\.$/,"\u2026",{inCodeMark:!1}),rN=new $e(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"\u201C",{inCodeMark:!1}),iN=new $e(/"$/,"\u201D",{inCodeMark:!1}),oN=new $e(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"\u2018",{inCodeMark:!1}),sN=new $e(/'$/,"\u2019",{inCodeMark:!1});function Es(e,t,n=null,r){return new $e(e,(i,o,s,l)=>{let c=n instanceof Function?n(o):n,u=i.tr.delete(s,l),h=u.doc.resolve(s),d=h.blockRange(),p=d&&bs(d,t,c);if(!p)return null;u.wrap(d,p);let f=u.doc.resolve(s-1).nodeBefore;return f&&f.type==t&&Ji(u.doc,s-1)&&(!r||r(o,f))&&u.join(s-1),u})}a(Es,"Wo");function Eh(e,t,n=null){return new $e(e,(r,i,o,s)=>{let l=r.doc.resolve(o),c=n instanceof Function?n(i):n;return l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),t)?r.tr.delete(o,s).setBlockType(o,o,t,c):null})}a(Eh,"Xl");var Lt=typeof navigator<"u"?navigator:null,Dh=typeof document<"u"?document:null,$t=Lt&&Lt.userAgent||"",Ds=/Edge\/(\d+)/.exec($t),Rh=/MSIE \d/.exec($t),Rs=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec($t),zs=!!(Rh||Rs||Ds),lN=Rh?document.documentMode:Rs?+Rs[1]:Ds?+Ds[1]:0,ck=!zs&&/gecko\/(\d+)/i.test($t),aN=ck&&+(/Firefox\/(\d+)/.exec($t)||[0,0])[1],Ps=!zs&&/Chrome\/(\d+)/.exec($t),uk=!!Ps,cN=Ps?+Ps[1]:0,hk=!zs&&!!Lt&&/Apple Computer/.test(Lt.vendor),dk=hk&&(/Mobile\/\w+/.test($t)||!!Lt&&Lt.maxTouchPoints>2),uN=dk||(Lt?/Mac/.test(Lt.platform):!1),pk=/Android \d/.test($t),fk=!!Dh&&"webkitFontSmoothing"in Dh.documentElement.style,hN=fk?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Fs(e,t,n,r,i,o){if(e.composing)return!1;let s=e.state,l=s.doc.resolve(t);if(l.parent.type.spec.code)return!1;let c=l.parent.textBetween(Math.max(0,l.parentOffset-500),l.parentOffset,void 0,"\uFFFC")+r;for(let u of i){let h=u,d=h.match.exec(c),p=d&&d[0]&&h.handler(s,d,t-(d[0].length-r.length),n);if(p)return h.undoable!==!1&&p.setMeta(o,{transform:p,from:t,to:n,text:r}),e.dispatch(p),!0}return!1}a(Fs,"Zl");var mk=new ve("MILKDOWN_CUSTOM_INPUTRULES");function gk({rules:e}){let t=new ye({key:mk,isInputRules:!0,state:{init(){return null},apply(n,r){return n.getMeta(this)||(n.selectionSet||n.docChanged?null:r)}},props:{handleTextInput(n,r,i,o){return Fs(n,r,i,o,e,t)},handleDOMEvents:{compositionend:a(n=>(setTimeout(()=>{let{$cursor:r}=n.state.selection;r&&Fs(n,r.pos,r.pos,"",e,t)}),!1),"compositionend"),keydown:a((n,r)=>!(pk&&uk&&r.key==="Enter")||n.composing?!1:n.someProp("handleKeyDown",i=>i(n,r))?(r.preventDefault(),!0):!1,"keydown")},handleKeyDown(n,r){if(r.key!=="Enter")return!1;let{$cursor:i}=n.state.selection;return i?Fs(n,i.pos,i.pos,`
40
+ `,e,t):!1}}});return t}a(gk,"Wd");function zh(e){return e.some(t=>t.type.spec.code)}a(zh,"qd");function Ph(e,t,n){if(t>=n)return!1;let r=!1;return e.doc.nodesBetween(t,n,i=>(i.isInline&&zh(i.marks)&&(r=!0),!r)),r}a(Ph,"jd");function yk(e,t){var n;return zh((n=e.storedMarks)!=null?n:e.doc.resolve(t).marks())}a(yk,"e1");function Cr(e,t,n={}){return new $e(e,(r,i,o,s)=>{var l,c,u,h;let{tr:d}=r,p=i.length,f=i[p-1],m=i[0],g=[],v,y={group:f,fullMatch:m,start:o,end:s},N=(l=n.updateCaptured)==null?void 0:l.call(n,y);if(Object.assign(y,N),{group:f,fullMatch:m,start:o,end:s}=y,m===null||f?.trim()==="")return null;if(f){let x=m.search(/\S/),A=o+m.indexOf(f),D=A+f.length,M=Ph(r,o+x,A),I=D<s&&Ph(r,D,s);if(M||I||yk(r,s))return null;g=(c=d.storedMarks)!=null?c:[],D<s&&d.delete(D,s),A>o&&d.delete(o+x,A),v=o+x+f.length;let F=(u=n.getAttr)==null?void 0:u.call(n,i);d.addMark(o,v,t.create(F)),d.setStoredMarks(g),(h=n.beforeDispatch)==null||h.call(n,{match:i,start:o,end:s,tr:d})}return d})}a(Cr,"Fn");function Fh(e){return Object.assign(Object.create(e),e).setTime(Date.now())}a(Fh,"ia");function vk(e,t){return Array.isArray(e)&&e.includes(t.type)||t.type===e}a(vk,"t1");function kk(e){return t=>{for(let n=t.depth;n>0;n-=1){let r=t.node(n);if(e(r)){let i=t.before(n),o=t.after(n);return{from:i,to:o,node:r}}}}}a(kk,"n1");function wk(e,t){return kk(n=>n.type===t)(e)}a(wk,"Jd");function bk(e){return t=>{for(let n=t.depth;n>0;n--){let r=t.node(n);if(e(r))return{pos:t.before(n),start:t.start(n),depth:n,node:r}}}}a(bk,"Ud");function xk(e,t){if(!(e instanceof _))return;let{node:n,$from:r}=e;if(vk(t,n))return{node:n,pos:r.pos,start:r.start(r.depth),depth:r.depth}}a(xk,"Gd");var Sk=a((e,t)=>{let{selection:n,doc:r}=e;if(n instanceof _)return{hasNode:n.node.type===t,pos:n.from,target:n.node};let{from:i,to:o}=n,s=!1,l=-1,c=null;return r.nodesBetween(i,o,(u,h)=>c?!1:u.type===t?(s=!0,l=h,c=u,!1):!0),{hasNode:s,pos:l,target:c}},"Yd"),Bt={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:"'"},Xi={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Ck=typeof navigator<"u"&&/Mac/.test(navigator.platform),Mk=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(se=0;se<10;se++)Bt[48+se]=Bt[96+se]=String(se);var se;for(se=1;se<=24;se++)Bt[se+111]="F"+se;var se;for(se=65;se<=90;se++)Bt[se]=String.fromCharCode(se+32),Xi[se]=String.fromCharCode(se);var se;for(Zi in Bt)Xi.hasOwnProperty(Zi)||(Xi[Zi]=Bt[Zi]);var Zi;function Nk(e){var t=Ck&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||Mk&&e.shiftKey&&e.key&&e.key.length==1||e.key=="Unidentified",n=!t&&e.key||(e.shiftKey?Xi:Bt)[e.keyCode]||e.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}a(Nk,"Qd");var Ok=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Tk=typeof navigator<"u"&&/Win/.test(navigator.platform);function Ak(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n=="Space"&&(n=" ");let r,i,o,s;for(let l=0;l<t.length-1;l++){let c=t[l];if(/^(cmd|meta|m)$/i.test(c))s=!0;else if(/^a(lt)?$/i.test(c))r=!0;else if(/^(c|ctrl|control)$/i.test(c))i=!0;else if(/^s(hift)?$/i.test(c))o=!0;else if(/^mod$/i.test(c))Ok?s=!0:i=!0;else throw new Error("Unrecognized modifier name: "+c)}return r&&(n="Alt-"+n),i&&(n="Ctrl-"+n),s&&(n="Meta-"+n),o&&(n="Shift-"+n),n}a(Ak,"l1");function Ik(e){let t=Object.create(null);for(let n in e)t[Ak(n)]=e[n];return t}a(Ik,"a1");function Ls(e,t,n=!0){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),n&&t.shiftKey&&(e="Shift-"+e),e}a(Ls,"oa");function Ek(e){return new ye({props:{handleKeyDown:Lh(e)}})}a(Ek,"Xd");function Lh(e){let t=Ik(e);return function(n,r){let i=Nk(r),o,s=t[Ls(i,r)];if(s&&s(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let l=t[Ls(i,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(Tk&&r.ctrlKey&&r.altKey)&&(o=Bt[r.keyCode])&&o!=i){let l=t[Ls(o,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}a(Lh,"sa");var $h=class{static{a(this,"ep")}},Bh=class{static{a(this,"tp")}constructor(){this.elements=[],this.size=()=>this.elements.length,this.top=()=>this.elements.at(-1),this.push=e=>{this.top()?.push(e)},this.open=e=>{this.elements.push(e)},this.close=()=>{let e=this.elements.pop();if(!e)throw yc();return e}}},Dk=class Tm extends $h{static{a(this,"np")}constructor(t,n,r){super(),this.type=t,this.content=n,this.attrs=r}push(t,...n){this.content.push(t,...n)}pop(){return this.content.pop()}static create(t,n,r){return new Tm(t,n,r)}},Rk=class extends Bh{static{a(this,"rp")}#t;static{this.create=(e,t)=>{let n=new this(e);return r=>(n.run(t,r),n.toDoc())}}constructor(e){super(),this.#t=X.none,this.#e=t=>t.isText,this.#r=(t,n)=>{if(this.#e(t)&&this.#e(n)&&X.sameSet(t.marks,n.marks))return this.schema.text(t.text+n.text,t.marks)},this.#n=t=>{let n=Object.values({...this.schema.nodes,...this.schema.marks}).find(r=>r.spec.parseMarkdown.match(t));if(!n)throw lg(t);return n},this.#o=t=>{let n=this.#n(t);n.spec.parseMarkdown.runner(this,t,n)},this.injectRoot=(t,n,r)=>(this.openNode(n,r),this.next(t.children),this),this.openNode=(t,n)=>(this.open(Dk.create(t,[],n)),this),this.#s=()=>{this.#t=X.none;let t=this.close();return this.#i(t.type,t.attrs,t.content)},this.closeNode=()=>{try{this.#s()}catch(t){console.error(t)}return this},this.#i=(t,n,r)=>{let i=t.createAndFill(n,r,this.#t);if(!i)throw sg(t,n,r);return this.push(i),i},this.addNode=(t,n,r)=>{try{this.#i(t,n,r)}catch(i){console.error(i)}return this},this.openMark=(t,n)=>{let r=t.create(n);return this.#t=r.addToSet(this.#t),this},this.closeMark=t=>(this.#t=t.removeFromSet(this.#t),this),this.addText=t=>{try{let n=this.top();if(!n)throw yc();let r=n.pop(),i=this.schema.text(t,this.#t);if(!r)return n.push(i),this;let o=this.#r(r,i);return o?(n.push(o),this):(n.push(r,i),this)}catch(n){return console.error(n),this}},this.build=()=>{let t;do t=this.#s();while(this.size());return t},this.next=(t=[])=>([t].flat().forEach(n=>this.#o(n)),this),this.toDoc=()=>this.build(),this.run=(t,n)=>{let r=t.runSync(t.parse(n),n);return this.next(r),this},this.schema=e}#e;#r;#n;#o;#s;#i},Vh=class Am extends $h{static{a(this,"ip")}constructor(t,n,r,i={}){super(),this.type=t,this.children=n,this.value=r,this.props=i,this.push=(o,...s)=>{this.children||(this.children=[]),this.children.push(o,...s)},this.pop=()=>this.children?.pop()}static{this.create=(t,n,r,i={})=>new Am(t,n,r,i)}},zk=a(e=>Object.prototype.hasOwnProperty.call(e,"size"),"u1"),Pk=class extends Bh{static{a(this,"op")}#t;static{this.create=(e,t)=>{let n=new this(e);return r=>(n.run(r),n.toString(t))}}constructor(e){super(),this.#t=[],this.#e=t=>{let n=Object.values({...this.schema.nodes,...this.schema.marks}).find(r=>r.spec.toMarkdown.match(t));if(!n)throw ag(t.type);return n},this.#r=t=>this.#e(t).spec.toMarkdown.runner(this,t),this.#n=(t,n)=>this.#e(t).spec.toMarkdown.runner(this,t,n),this.#o=t=>{let n=a(o=>o.type.spec.priority??50,"n"),r=[...t].sort((o,s)=>n(o)-n(s)),i=[];return this.#t.forEach(({mark:o})=>{let s=r.findIndex(l=>l.eq(o));s>=0&&i.push(...r.splice(s,1))}),i.concat(r)},this.#s=t=>{let n=t?.marks,r=0;for(;r<this.#t.length;){let{mark:i,spanning:o}=this.#t[r];if(o&&n?.some(s=>s.eq(i)))r++;else break}for(let i=this.#t.length-1;i>=r;i--)this.#h(this.#t[i].mark)},this.#i=(t,n)=>{this.#o(t.marks).every(r=>!this.#n(r,t))&&this.#r(t),this.#s(n)},this.#l=t=>{let{children:n}=t;return n&&(t.children=n.reduce((r,i,o)=>{if(o===0)return[i];let s=r.at(-1);if(s&&s.isMark&&i.isMark){let{children:l,...c}=i,{children:u,...h}=s;if(i.type===s.type&&l&&u&&JSON.stringify(c)===JSON.stringify(h)){let d={...h,children:[...u,...l]};return r.slice(0,-1).concat(this.#l(d))}}return r.concat(i)},[])),t},this.#a=t=>{let n={...t.props,type:t.type};return t.children&&(n.children=t.children),t.value&&(n.value=t.value),n},this.openNode=(t,n,r)=>(this.open(Vh.create(t,void 0,n,r)),this),this.#d=(t,n)=>{let r="",i="",o=t.children;if(o){let l=o[0],c=o.at(-1);if(c&&c.type==="text"&&c.value.endsWith(" ")){let u=c.value,h=u.trimEnd();i=u.slice(h.length),c.value=h}if(l&&l.type==="text"&&l.value.startsWith(" ")){let u=l.value,h=u.trimStart();r=u.slice(0,u.length-h.length),l.value=h}}r.length&&this.#u("text",void 0,r);let s=n();return i.length&&this.#u("text",void 0,i),s},this.#c=(t=!1)=>{let n=this.close(),r=a(()=>this.#u(n.type,n.children,n.value,n.props),"r");return t?this.#d(n,r):r()},this.closeNode=()=>(this.#c(),this),this.#u=(t,n,r,i)=>{let o=Vh.create(t,n,r,i),s=this.#l(this.#a(o));return this.push(s),s},this.addNode=(t,n,r,i)=>(this.#u(t,n,r,i),this),this.#p=(t,n,r,i)=>this.#t.some(o=>o.mark.eq(t))?this:(this.#t.push({mark:t,spanning:r==null}),this.openNode(n,r,{...i,isMark:!0})),this.#h=t=>{let n=-1;for(let r=this.#t.length-1;r>=0;r--)if(this.#t[r].mark.eq(t)){n=r;break}n<0||(this.#t.splice(n,1),this.#c(!0))},this.withMark=(t,n,r,i)=>(this.#p(t,n,r,i),this),this.closeMark=t=>(this.#h(t),this),this.build=()=>{let t=null;do t=this.#c();while(this.size());return t.children||(t.children=[]),t},this.next=t=>zk(t)?(t.forEach((n,r,i)=>{this.#i(n,t.maybeChild(i+1)??void 0)}),this):(this.#i(t),this),this.toString=t=>t.stringify(this.build()),this.run=t=>(this.#t=[],this.next(t),this),this.schema=e}#e;#r;#n;#o;#s;#i;#l;#a;#d;#c;#u;#p;#h},de=a(function(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t},"Se"),Dn=a(function(e){let t=e.assignedSlot||e.parentNode;return t&&t.nodeType==11?t.host:t},"Er"),$s=null,xt=a(function(e,t,n){let r=$s||($s=document.createRange());return r.setEnd(e,n??e.nodeValue.length),r.setStart(e,t||0),r},"Dt"),Fk=a(function(){$s=null},"f1"),ln=a(function(e,t,n,r){return n&&(jh(e,t,n,r,-1)||jh(e,t,n,r,1))},"qn"),Lk=/^(img|br|input|textarea|hr)$/i;function jh(e,t,n,r,i){for(var o;;){if(e==n&&t==r)return!0;if(t==(i<0?0:ke(e))){let s=e.parentNode;if(!s||!z(s)||Mr(e)||Lk.test(e.nodeName)||e.contentEditable=="false")return!1;t=de(e)+(i<0?0:1),e=s}else if(z(e)){let s=e.childNodes[t+(i<0?-1:0)];if(z(s)&&s.contentEditable=="false")if(!((o=s.pmViewDesc)===null||o===void 0)&&o.ignoreForSelection)t+=i;else return!1;else e=s,t=i<0?ke(e):0}else return!1}}a(jh,"sp");function ke(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}a(ke,"Re");function z(e){return e.nodeType==1}a(z,"L");function ae(e){return e.nodeType==3}a(ae,"pe");function an(e,t){return t?e.contains(z(t)?t:t.parentNode):!1}a(an,"Jn");function $k(e,t){for(;;){if(ae(e)&&t)return e;if(z(e)&&t>0){if(e.contentEditable=="false")return null;e=e.childNodes[t-1],t=ke(e)}else if(e.parentNode&&!Mr(e))t=de(e),e=e.parentNode;else return null}}a($k,"d1");function Bk(e,t){for(;;){if(ae(e)&&t<e.nodeValue.length)return e;if(z(e)&&t<e.childNodes.length){if(e.contentEditable=="false")return null;e=e.childNodes[t],t=0}else if(e.parentNode&&!Mr(e))t=de(e)+1,e=e.parentNode;else return null}}a(Bk,"p1");function Vk(e,t,n){for(let r=t==0,i=t==ke(e);r||i;){if(e==n)return!0;let o=de(e);if(e=e.parentNode,!e)return!1;r=r&&o==0,i=i&&o==ke(e)}}a(Vk,"m1");function Mr(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}a(Mr,"Bi");var eo=a(function(e){return e.focusNode&&ln(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)},"is");function cn(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}a(cn,"_n");function jk(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}a(jk,"g1");function _k(e,t,n){if(e.caretPositionFromPoint)try{let r=e.caretPositionFromPoint(t,n);if(r)return{node:r.offsetNode,offset:Math.min(ke(r.offsetNode),r.offset)}}catch{}if(e.caretRangeFromPoint){let r=e.caretRangeFromPoint(t,n);if(r)return{node:r.startContainer,offset:Math.min(ke(r.startContainer),r.startOffset)}}}a(_k,"y1");var ht=typeof navigator<"u"?navigator:null,_h=typeof document<"u"?document:null,Vt=ht&&ht.userAgent||"",Bs=/Edge\/(\d+)/.exec(Vt),Hh=/MSIE \d/.exec(Vt),Vs=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Vt),De=!!(Hh||Vs||Bs),jt=Hh?document.documentMode:Vs?+Vs[1]:Bs?+Bs[1]:0,Be=!De&&/gecko\/(\d+)/i.test(Vt);Be&&+(/Firefox\/(\d+)/.exec(Vt)||[0,0])[1];var js=!De&&/Chrome\/(\d+)/.exec(Vt),pe=!!js,Wh=js?+js[1]:0,we=!De&&!!ht&&/Apple Computer/.test(ht.vendor),Rn=we&&(/Mobile\/\w+/.test(Vt)||!!ht&&ht.maxTouchPoints>2),Je=Rn||(ht?/Mac/.test(ht.platform):!1),qh=ht?/Win/.test(ht.platform):!1,St=/Android \d/.test(Vt),to=!!_h&&"webkitFontSmoothing"in _h.documentElement.style,Hk=to?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Wk(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}a(Wk,"b1");function Ct(e,t){return typeof e=="number"?e:e[t]}a(Ct,"Rt");function qk(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}a(qk,"x1");function Kh(e,t,n){if(!Hs(t)&&t.left==0)return;let r=e.someProp("scrollThreshold")||0,i=e.someProp("scrollMargin")||5,o=e.dom.ownerDocument;for(let s=n||e.dom;s;){if(!z(s)){s=Dn(s);continue}let l=s==o.body,c=l?Wk(o):qk(s),u=0,h=0;if(t.top<c.top+Ct(r,"top")?h=-(c.top-t.top+Ct(i,"top")):t.bottom>c.bottom-Ct(r,"bottom")&&(h=t.bottom-t.top>c.bottom-c.top?t.top+Ct(i,"top")-c.top:t.bottom-c.bottom+Ct(i,"bottom")),t.left<c.left+Ct(r,"left")?u=-(c.left-t.left+Ct(i,"left")):t.right>c.right-Ct(r,"right")&&(u=t.right-c.right+Ct(i,"right")),u||h)if(l)o.defaultView.scrollBy(u,h);else{let p=s.scrollLeft,f=s.scrollTop;h&&(s.scrollTop+=h),u&&(s.scrollLeft+=u);let m=s.scrollLeft-p,g=s.scrollTop-f;t={left:t.left-m,top:t.top-g,right:t.right-m,bottom:t.bottom-g}}let d=l?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(d))break;s=d=="absolute"?s.offsetParent:Dn(s)}}a(Kh,"ap");function Kk(e){let t=e.dom.getBoundingClientRect(),n=Math.max(0,t.top),r,i;for(let o=(t.left+t.right)/2,s=n+1;s<Math.min(innerHeight,t.bottom);s+=5){let l=e.root.elementFromPoint(o,s);if(!l||l==e.dom||!e.dom.contains(l))continue;let c=l.getBoundingClientRect();if(c.top>=n-20){r=l,i=c.top;break}}return{refDOM:r,refTop:i,stack:Jh(e.dom)}}a(Kk,"w1");function Jh(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=Dn(r));return t}a(Jh,"_p");function Jk({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;Uh(n,r==0?0:r-t)}a(Jk,"C1");function Uh(e,t){for(let n=0;n<e.length;n++){let{dom:r,top:i,left:o}=e[n];r.scrollTop!=i+t&&(r.scrollTop=i+t),r.scrollLeft!=o&&(r.scrollLeft=o)}}a(Uh,"$p");var zn=null;function Uk(e){if(e.setActive)return e.setActive();if(zn)return e.focus(zn);let t=Jh(e);e.focus(zn==null?{get preventScroll(){return zn={preventScroll:!0},!0}}:void 0),zn||(zn=!1,Uh(t,0))}a(Uk,"S1");function Gh(e,t){let n,r=2e8,i,o=0,s=t.top,l=t.top,c,u;for(let h=e.firstChild,d=0;h;h=h.nextSibling,d++){let p;if(z(h))p=h.getClientRects();else if(ae(h))p=xt(h).getClientRects();else continue;for(let f=0;f<p.length;f++){let m=p[f];if(m.top<=s&&m.bottom>=l){s=Math.max(m.bottom,s),l=Math.min(m.top,l);let g=m.left>t.left?m.left-t.left:m.right<t.left?t.left-m.right:0;if(g<r){n=h,r=g,i=g&&ae(n)?{left:m.right<t.left?m.right:m.left,top:t.top}:t,z(h)&&g&&(o=d+(t.left>=(m.left+m.right)/2?1:0));continue}}else m.top>t.top&&!c&&m.left<=t.left&&m.right>=t.left&&(c=h,u={left:Math.max(m.left,Math.min(m.right,t.left)),top:m.top});!n&&(t.left>=m.right&&t.top>=m.top||t.left>=m.left&&t.top>=m.bottom)&&(o=d+1)}}return!n&&c&&(n=c,i=u,r=0),n&&ae(n)?Gk(n,i):!n||r?{node:e,offset:o}:Gh(n,i)}a(Gh,"Vp");function Gk(e,t){let n=e.nodeValue.length,r=document.createRange(),i;for(let o=0;o<n;o++){r.setEnd(e,o+1),r.setStart(e,o);let s=_t(r,1);if(s.top!=s.bottom&&_s(t,s)){i={node:e,offset:o+(t.left>=(s.left+s.right)/2?1:0)};break}}return r.detach(),i||{node:e,offset:0}}a(Gk,"M1");function _s(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}a(_s,"Oa");function Qk(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}a(Qk,"N1");function Yk(e,t,n){let{node:r,offset:i}=Gh(t,n),o=-1;if(z(r)&&!r.firstChild){let s=r.getBoundingClientRect();o=s.left!=s.right&&n.left>(s.left+s.right)/2?1:-1}return e.docView.posFromDOM(r,i,o)}a(Yk,"v1");function Xk(e,t,n,r){let i=-1;for(let o=t,s=!1;o!=e.dom;){let l=e.docView.nearestDesc(o,!0),c;if(!l)return null;if(z(l.dom)&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((c=l.dom.getBoundingClientRect()).width||c.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!s&&c.left>r.left||c.top>r.top?i=l.posBefore:(!s&&c.right<r.left||c.bottom<r.top)&&(i=l.posAfter),s=!0),!l.contentDOM&&i<0&&!l.node.isText))return(l.node.isBlock?r.top<(c.top+c.bottom)/2:r.left<(c.left+c.right)/2)?l.posBefore:l.posAfter;o=l.dom.parentNode}return i>-1?i:e.docView.posFromDOM(t,n,-1)}a(Xk,"T1");function Qh(e,t,n){let r=e.childNodes.length;if(r&&n.top<n.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(t.top-n.top)/(n.bottom-n.top))-2)),o=i;;){let s=e.childNodes[o];if(z(s)){let l=s.getClientRects();for(let c=0;c<l.length;c++){let u=l[c];if(_s(t,u))return Qh(s,t,u)}}if((o=(o+1)%r)==i)break}return e}a(Qh,"Hp");function Zk(e,t){let n=e.dom.ownerDocument,r,i=0,o=_k(n,t.left,t.top);o&&({node:r,offset:i}=o);let s=(e.root.elementFromPoint?e.root:n).elementFromPoint(t.left,t.top),l;if(!s||!e.dom.contains(s)){let u=e.dom.getBoundingClientRect();if(!_s(t,u)||(s=Qh(e.dom,t,u),!s))return null}if(we)for(let u=s;r&&u;u=Dn(u))u.draggable&&(r=void 0);if(s=Qk(s,t),r){if(Be&&z(r)&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let h=r.childNodes[i],d;h.nodeName=="IMG"&&(d=h.getBoundingClientRect()).right<=t.left&&d.bottom>t.top&&i++}let u;to&&i&&z(r)&&z(u=r.childNodes[i-1])&&u.contentEditable=="false"&&u.getBoundingClientRect().top>=t.top&&i--,r==e.dom&&i==r.childNodes.length-1&&z(r.lastChild)&&t.top>r.lastChild.getBoundingClientRect().bottom?l=e.state.doc.content.size:(i==0||!z(r)||r.childNodes[i-1].nodeName!="BR")&&(l=Xk(e,r,i,t))}l==null&&(l=Yk(e,s,t));let c=e.docView.nearestDesc(s,!0);return{pos:l,inside:c?c.posAtStart-c.border:-1}}a(Zk,"I1");function Hs(e){return e.top<e.bottom||e.left<e.right}a(Hs,"ma");function _t(e,t){let n=e.getClientRects();if(n.length){let r=n[t<0?0:n.length-1];if(Hs(r))return r}return Array.prototype.find.call(n,Hs)||e.getBoundingClientRect()}a(_t,"nn");var ew=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Yh(e,t,n){let{node:r,offset:i,atom:o}=e.docView.domFromPos(t,n<0?-1:1),s=to||Be;if(ae(r))if(s&&(ew.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let l=_t(xt(r,i,i),n);if(Be&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let c=_t(xt(r,i-1,i-1),-1);if(c.top==l.top){let u=_t(xt(r,i,i+1),-1);if(u.top!=l.top)return Nr(u,u.left<c.left)}}return l}else{let l=i,c=i,u=n<0?1:-1;return n<0&&!i?(c++,u=-1):n>=0&&i==r.nodeValue.length?(l--,u=1):n<0?l--:c++,Nr(_t(xt(r,l,c),u),u<0)}if(!e.state.doc.resolve(t-(o||0)).parent.inlineContent){if(o==null&&i&&(n<0||i==ke(r))){let l=r.childNodes[i-1];if(z(l))return Ws(l.getBoundingClientRect(),!1)}if(o==null&&i<ke(r)){let l=r.childNodes[i];if(z(l))return Ws(l.getBoundingClientRect(),!0)}return Ws(r.getBoundingClientRect(),n>=0)}if(o==null&&i&&(n<0||i==ke(r))){let l=r.childNodes[i-1],c=ae(l)?xt(l,ke(l)-(s?0:1)):z(l)&&(l.nodeName!="BR"||!l.nextSibling)?l:null;if(c)return Nr(_t(c,1),!1)}if(o==null&&i<ke(r)){let l=r.childNodes[i];for(;l.pmViewDesc&&l.pmViewDesc.ignoreForCoords;)l=l.nextSibling;let c=l?ae(l)?xt(l,0,s?0:1):z(l)?l:null:null;if(c)return Nr(_t(c,-1),!0)}return Nr(_t(ae(r)?xt(r):r,-n),n>=0)}a(Yh,"jp");function Nr(e,t){if(e.width==0)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}a(Nr,"Ai");function Ws(e,t){if(e.height==0)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}a(Ws,"la");function Xh(e,t,n){let r=e.state,i=e.root.activeElement;r!=t&&e.updateState(t),i!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),i!=e.dom&&i&&i.focus()}}a(Xh,"Kp");function tw(e,t,n){let r=t.selection,i=n=="up"?r.$from:r.$to;return Xh(e,t,()=>{let{node:o}=e.docView.domFromPos(i.pos,n=="up"?-1:1);for(;;){let l=e.docView.nearestDesc(o,!0);if(!l)break;if(l.node.isBlock){o=l.contentDOM||l.dom;break}o=l.dom.parentNode}let s=Yh(e,i.pos,1);for(let l=o.firstChild;l;l=l.nextSibling){let c;if(z(l))c=l.getClientRects();else if(ae(l))c=xt(l,0,l.nodeValue.length).getClientRects();else continue;for(let u=0;u<c.length;u++){let h=c[u];if(h.bottom>h.top+1&&(n=="up"?s.top-h.top>(h.bottom-s.top)*2:h.bottom-s.bottom>(s.bottom-h.top)*2))return!1}}return!0})}a(tw,"E1");var nw=/[\u0590-\u08ac]/;function rw(e,t,n){let{$head:r}=t.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,o=!i,s=i==r.parent.content.size,l=e.domSelection();return l?!nw.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?o:s:Xh(e,t,()=>{let{focusNode:c,focusOffset:u,anchorNode:h,anchorOffset:d}=e.domSelectionRange(),p=l.caretBidiLevel;l.modify("move",n,"character");let f=r.depth?e.docView.domAfterPos(r.before()):e.dom,{focusNode:m,focusOffset:g}=e.domSelectionRange(),v=m&&!an(f,m)||c==m&&u==g;try{l.collapse(h,d),c&&(c!=h||u!=d)&&l.extend&&l.extend(c,u)}catch{}return p!=null&&(l.caretBidiLevel=p),v}):r.pos==r.start()||r.pos==r.end()}a(rw,"R1");var Zh=null,ed=null,td=!1;function iw(e,t,n){return Zh==t&&ed==n?td:(Zh=t,ed=n,td=n=="up"||n=="down"?tw(e,t,n):rw(e,t,n))}a(iw,"D1");var Ue=0,nd=1,un=2,rt=3,Or=class{static{a(this,"Un")}constructor(e,t,n,r){this.parent=e,this.children=t,this.dom=n,this.contentDOM=r,this.dirty=Ue,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(e){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,n=this.posAtStart;;t++){let r=this.children[t];if(r==e)return n;n+=r.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,n){if(this.contentDOM&&an(this.contentDOM,e))if(n<0){let i,o;if(e==this.contentDOM)i=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&!((o=i.pmViewDesc)&&o.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(o)+o.size:this.posAtStart}else{let i,o;if(e==this.contentDOM)i=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&!((o=i.pmViewDesc)&&o.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(o):this.posAtEnd}let r;if(e==this.dom&&this.contentDOM)r=t>de(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=!!(e.compareDocumentPosition(this.contentDOM)&4);else if(this.dom.firstChild){if(t==0)for(let i=e;;i=i.parentNode){if(i==this.dom){r=!1;break}if(i.previousSibling)break}if(r==null&&t==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){r=!0;break}if(i.nextSibling)break}}return r??n>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,r=e;r;r=r.parentNode){let i=this.getDesc(r),o;if(i&&(!t||i.node))if(n&&(o=i.nodeDOM)&&!(z(o)?an(o,e):o==e))n=!1;else return i}}getDesc(e){let t=e.pmViewDesc;for(let n=t;n;n=n.parent)if(n==this)return t}posFromDOM(e,t,n){for(let r=e;r;r=r.parentNode){let i=this.getDesc(r);if(i)return i.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let r=this.children[t],i=n+r.size;if(n==e&&i!=n){for(;!r.border&&r.children.length;)for(let o=0;o<r.children.length;o++){let s=r.children[o];if(s.size){r=s;break}}return r}if(e<i)return r.descAt(e-n-r.border);n=i}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,r=0;for(let i=0;n<this.children.length;n++){let o=this.children[n],s=i+o.size;if(s>e){r=e-i;break}i=s}if(r)return this.children[n].domFromPos(r-this.children[n].border,t);for(;n>0;n--){let i=this.children[n-1];if(i.size||!(i instanceof sd||i instanceof rd&&i.side>=0))break}if(t<=0){let i,o=!0;for(;i=n?this.children[n-1]:null,!(!i||i.dom.parentNode==this.contentDOM);n--,o=!1);return i&&t&&o&&!i.border&&!i.domAtom?i.domFromPos(i.size,t):{node:this.contentDOM,offset:i?de(i.dom)+1:0}}else{let i,o=!0;for(;i=n<this.children.length?this.children[n]:null,!(!i||i.dom.parentNode==this.contentDOM);n++,o=!1);return i&&o&&!i.border&&!i.domAtom?i.domFromPos(0,t):{node:this.contentDOM,offset:i?de(i.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,i=-1;for(let o=n,s=0;;s++){let l=this.children[s],c=o+l.size;if(r==-1&&e<=c){let u=o+l.border;if(e>=u&&t<=c-l.border&&l.node&&l.contentDOM&&this.contentDOM.contains(l.contentDOM))return l.parseRange(e,t,u);e=o;for(let h=s;h>0;h--){let d=this.children[h-1];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(1)){r=de(d.dom)+1;break}e-=d.size}r==-1&&(r=0)}if(r>-1&&(c>t||s==this.children.length-1)){t=c;for(let u=s+1;u<this.children.length;u++){let h=this.children[u];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(-1)){i=de(h.dom);break}t+=h.size}i==-1&&(i=this.contentDOM.childNodes.length);break}o=c}return{node:this.contentDOM,from:e,to:t,fromOffset:r,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:n}=this.domFromPos(e,0);if(!z(t)||n==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[n]}setSelection(e,t,n,r=!1){let i=Math.min(e,t),o=Math.max(e,t);for(let p=0,f=0;p<this.children.length;p++){let m=this.children[p],g=f+m.size;if(i>f&&o<g)return m.setSelection(e-f-m.border,t-f-m.border,n,r);f=g}let s=this.domFromPos(e,e?-1:1),l=t==e?s:this.domFromPos(t,t?-1:1),c=n.root.getSelection(),u=n.domSelectionRange(),h=!1;if((Be||we)&&e==t){let{node:p,offset:f}=s;if(ae(p)){if(h=!!(f&&p.nodeValue[f-1]==`
41
+ `),h&&f==p.nodeValue.length)for(let m=p,g;m;m=m.parentNode){if(g=m.nextSibling){g.nodeName=="BR"&&(s=l={node:g.parentNode,offset:de(g)+1});break}let v=m.pmViewDesc;if(v&&v.node&&v.node.isBlock)break}}else{let m=p.childNodes[f-1];h=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(Be&&u.focusNode&&u.focusNode!=l.node&&z(u.focusNode)){let p=u.focusNode.childNodes[u.focusOffset];p&&p.contentEditable=="false"&&(r=!0)}if(!(r||h&&we)&&ln(s.node,s.offset,u.anchorNode,u.anchorOffset)&&ln(l.node,l.offset,u.focusNode,u.focusOffset))return;let d=!1;if((c.extend||e==t)&&!(h&&Be)){c.collapse(s.node,s.offset);try{e!=t&&c.extend(l.node,l.offset),d=!0}catch{}}if(!d){if(e>t){let f=s;s=l,l=f}let p=document.createRange();p.setEnd(l.node,l.offset),p.setStart(s.node,s.offset),c.removeAllRanges(),c.addRange(p)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,r=0;r<this.children.length;r++){let i=this.children[r],o=n+i.size;if(n==o?e<=o&&t>=n:e<o&&t>n){let s=n+i.border,l=o-i.border;if(e>=s&&t<=l){this.dirty=e==n||t==o?un:nd,e==s&&t==l&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=rt:i.markDirty(e-s,t-s);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?un:rt}n=o}this.dirty=un}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=e==1?un:nd;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},rd=class extends Or{static{a(this,"Uo")}constructor(e,t,n,r){let i,o=t.type.toDOM;if(typeof o=="function"&&(o=o(n,()=>{if(!i)return r;if(i.parent)return i.parent.posBeforeChild(i)})),!t.type.spec.raw){let s=z(o)?o:document.createElement("span");s!=o&&s.appendChild(o),s.hasAttribute("contenteditable")||(s.contentEditable="false"),s.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return this.dirty==Ue&&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}},ow=class extends Or{static{a(this,"ga")}constructor(e,t,n,r){super(e,[],t,null),this.textDOM=n,this.text=r}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}},Tr=class uc extends Or{static{a(this,"t")}constructor(t,n,r,i,o){super(t,[],r,i),this.mark=n,this.spec=o}static create(t,n,r,i){let o=i.nodeViews[n.type.name],s=o&&o(n,i,r);return(!s||!s.dom)&&(s=Vi.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new uc(t,n,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&rt||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(t){return this.dirty!=rt&&this.mark.eq(t)}markDirty(t,n){if(super.markDirty(t,n),this.dirty!=Ue){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Ue}}slice(t,n,r){let i=uc.create(this.parent,this.mark,!0,r),o=this.children,s=this.size;n<s&&(o=Ks(o,n,s,r)),t>0&&(o=Ks(o,0,t,r));for(let l=0;l<o.length;l++)o[l].parent=i;return i.children=o,i}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},Pn=class Im extends Or{static{a(this,"t")}constructor(t,n,r,i,o,s,l){super(t,[],o,s),this.node=n,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=l}static create(t,n,r,i,o,s){let l=o.nodeViews[n.type.name],c,u=l&&l(n,o,()=>{if(!c)return s;if(c.parent)return c.parent.posBeforeChild(c)},r,i),h=u&&u.dom,d=u&&u.contentDOM;if(n.isText){if(!h)h=document.createTextNode(n.text);else if(!ae(h))throw new RangeError("Text must be rendered as a DOM text node")}else h||({dom:h,contentDOM:d}=Vi.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!d&&!n.isText&&h.nodeName!="BR"&&(h.hasAttribute("contenteditable")||(h.contentEditable="false"),n.type.spec.draggable&&(h.draggable=!0));let p=h;return h=cd(h,r,n),u?c=new sw(t,n,r,i,h,d||null,p,u):n.isText?new od(t,n,r,i,h,p):new Im(t,n,r,i,h,d||null,p)}parseRule(t){if(this.node.type.spec.reparseInView)return null;let n={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(n.preserveWhitespace="full"),!this.contentDOM)n.getContent=()=>this.node.content;else if(!this.contentLost)n.contentElement=this.contentDOM;else{for(let r=this.children.length-1;r>=0;r--){let i=this.children[r];if(this.dom.contains(i.dom.parentNode)){n.contentElement=i.dom.parentNode;break}}if(!n.contentElement){let r=t&&t.find(i=>z(i)&&t.indexOf(i.parentNode)<0&&this.dom.contains(i));r?n.contentElement=r:n.getContent=()=>O.empty}}return n}matchesNode(t,n,r){return this.dirty==Ue&&t.eq(this.node)&&no(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(t,n){let r=this.node.inlineContent,i=n,o=t.composing?this.localCompositionInfo(t,n):null,s=o&&o.pos>-1?o:null,l=o&&o.pos<0,c=new aw(this,s&&s.node,t),u=this.node.inlineContent,h=u&&this.node.isBlock;hw(this.node,this.innerDeco,(d,p,f)=>{d.spec.marks?c.syncToMarks(d.spec.marks,r,t,p):d.type.side>=0&&!f&&c.syncToMarks(p==this.node.childCount?X.none:this.node.child(p).marks,r,t,p),c.placeWidget(d,t,i)},(d,p,f,m)=>{c.syncToMarks(d.marks,r,t,m),h&&d.isAtom&&!d.isText&&c.addHackNode("IMG",c.top);let g;c.findNodeMatch(d,p,f,m)||l&&t.state.selection.from>i&&t.state.selection.to<i+d.nodeSize&&(g=c.findIndexWithChild(o.node))>-1&&c.updateNodeAt(d,p,f,g,t)||c.updateNextNode(d,p,f,t,m,i)||c.addNode(d,p,f,t,i),i+=d.nodeSize,u&&(h=d.isAtom&&!d.isText)}),c.syncToMarks([],r,t,0),this.node.isTextblock&&c.addTextblockHacks(),c.destroyRest(),(c.changed||this.dirty==un)&&(s&&this.protectLocalComposition(t,s),ld(this.contentDOM,this.children,t),Rn&&dw(this.dom))}localCompositionInfo(t,n){let{from:r,to:i}=t.state.selection;if(!(t.state.selection instanceof q)||r<n||i>n+this.node.content.size)return null;let o=t.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let s=o.nodeValue,l=pw(this.node.content,s,r-n,i-n);return l<0?null:{node:o,pos:l,text:s}}else return{node:o,pos:-1,text:""}}protectLocalComposition(t,{node:n,pos:r,text:i}){if(this.getDesc(n))return;let o=n;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let s=new ow(this,o,n,i);t.input.compositionNodes.push(s),this.children=Ks(this.children,r,r+i.length,t,s)}update(t,n,r,i){return this.dirty==rt||!t.sameMarkup(this.node)?!1:(this.updateInner(t,n,r,i),!0)}updateInner(t,n,r,i){this.updateOuterDeco(n),this.node=t,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=Ue}updateOuterDeco(t){if(no(t,this.outerDeco))return;let n=!z(this.nodeDOM),r=this.dom;this.dom=ad(this.dom,this.nodeDOM,qs(this.outerDeco,this.node,n),qs(t,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=t}selectNode(){z(this.nodeDOM)&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){z(this.nodeDOM)&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}};function id(e,t,n,r,i){cd(r,t,e);let o=new Pn(void 0,e,t,n,r,r,r);return o.contentDOM&&o.updateChildren(i,0),o}a(id,"dp");var od=class Em extends Pn{static{a(this,"t")}constructor(t,n,r,i,o,s){super(t,n,r,i,o,null,s)}parseRule(){let t=this.nodeDOM.parentNode;for(;t&&t!=this.dom&&!t.pmIsDeco;)t=t.parentNode;return{skip:t||!0}}update(t,n,r,i){return this.dirty==rt||this.dirty!=Ue&&!this.inParent()||!t.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=Ue||t.text!=this.node.text)&&t.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=t.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=t,this.dirty=Ue,!0)}inParent(){let t=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==t)return!0;return!1}domFromPos(t){return{node:this.nodeDOM,offset:t}}localPosFromDOM(t,n,r){return t==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(t,n,r)}ignoreMutation(t){return t.type!="characterData"&&t.type!="selection"}slice(t,n,r){let i=this.node.cut(t,n),o=document.createTextNode(i.text);return new Em(this.parent,i,this.outerDeco,this.innerDeco,o,o)}markDirty(t,n){super.markDirty(t,n),this.dom!=this.nodeDOM&&(t==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=rt)}get domAtom(){return!1}isText(t){return this.node.text==t}},sd=class extends Or{static{a(this,"Yo")}parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Ue&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},sw=class extends Pn{static{a(this,"ya")}constructor(e,t,n,r,i,o,s,l){super(e,t,n,r,i,o,s),this.spec=l}update(e,t,n,r){if(this.dirty==rt)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,t,n);return i&&this.updateInner(e,t,n,r),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,r){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,r)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}};function ld(e,t,n){let r=e.firstChild,i=!1;for(let o=0;o<t.length;o++){let s=t[o],l=s.dom;if(l.parentNode==e){for(;l!=r;)r=ud(r),i=!0;r=r.nextSibling}else i=!0,e.insertBefore(l,r);if(s instanceof Tr){let c=r?r.previousSibling:e.lastChild;ld(s.contentDOM,s.children,n),r=c?c.nextSibling:e.firstChild}}for(;r;)r=ud(r),i=!0;i&&n.trackWrites==e&&(n.trackWrites=null)}a(ld,"Wp");var Ar=a(function(e){e&&(this.nodeName=e)},"Oi");Ar.prototype=Object.create(null);var hn=[new Ar];function qs(e,t,n){if(e.length==0)return hn;let r=n?hn[0]:new Ar,i=[r];for(let o=0;o<e.length;o++){let s=e[o].type.attrs;if(s){s.nodeName&&i.push(r=new Ar(s.nodeName));for(let l in s){let c=s[l];c!=null&&(n&&i.length==1&&i.push(r=new Ar(t.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+c:l=="style"?r.style=(r.style?r.style+";":"")+c:l!="nodeName"&&(r[l]=c))}}}return i}a(qs,"ka");function ad(e,t,n,r){if(n==hn&&r==hn)return t;let i=t;for(let o=0;o<r.length;o++){let s=r[o],l=n[o];if(o){let c;l&&l.nodeName==s.nodeName&&i!=e&&(c=i.parentNode)&&c.nodeName.toLowerCase()==s.nodeName||(c=document.createElement(s.nodeName),c.pmIsDeco=!0,c.appendChild(i),l=hn[0]),i=c}lw(i,l||hn[0],s)}return i}a(ad,"qp");function lw(e,t,n){for(let r in t)r!="class"&&r!="style"&&r!="nodeName"&&!(r in n)&&e.removeAttribute(r);for(let r in n)r!="class"&&r!="style"&&r!="nodeName"&&n[r]!=t[r]&&e.setAttribute(r,n[r]);if(t.class!=n.class){let r=t.class?t.class.split(" ").filter(Boolean):[],i=n.class?n.class.split(" ").filter(Boolean):[];for(let o=0;o<r.length;o++)i.indexOf(r[o])==-1&&e.classList.remove(r[o]);for(let o=0;o<i.length;o++)r.indexOf(i[o])==-1&&e.classList.add(i[o]);e.classList.length==0&&e.removeAttribute("class")}if(t.style!=n.style){if(t.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=r.exec(t.style);)e.style.removeProperty(i[1])}n.style&&(e.style.cssText+=n.style)}}a(lw,"P1");function cd(e,t,n){return ad(e,e,hn,qs(t,n,!z(e)))}a(cd,"Jp");function no(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}a(no,"Qo");function ud(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}a(ud,"pp");var aw=class{static{a(this,"ba")}constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=cw(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n,r){let i=0,o=this.stack.length>>1,s=Math.min(o,e.length);for(;i<s&&(i==o-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<o;)this.destroyRest(),this.top.dirty=Ue,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<e.length;){this.stack.push(this.top,this.index+1);let l=-1,c=this.top.children.length;r<this.preMatch.index&&(c=Math.min(this.index+3,c));for(let u=this.index;u<c;u++){let h=this.top.children[u];if(h.matchesMark(e[o])&&!this.isLocked(h.dom)){l=u;break}}if(l<0&&this.index<this.top.children.length){let u=this.top.children[this.index];u instanceof Tr&&u.dirty!=rt&&u.mark.type==e[o].type&&u.spec.update&&!this.isLocked(u.dom)&&u.spec.update(e[o])&&(u.mark=e[o],l=this.index,this.changed=!0)}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let u=Tr.create(this.top,e[o],t,n);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,o++}}findNodeMatch(e,t,n,r){let i=-1,o;if(r>=this.preMatch.index&&(o=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,n))i=this.top.children.indexOf(o,this.index);else for(let s=this.index,l=Math.min(this.top.children.length,s+5);s<l;s++){let c=this.top.children[s];if(c.matchesNode(e,t,n)&&!this.preMatch.matched.has(c)){i=s;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,n,r,i){let o=this.top.children[r];return o.dirty==rt&&o.dom==o.contentDOM&&(o.dirty=un),o.update(e,t,n,i)?(this.destroyBetween(this.index,r),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let n=e.pmViewDesc;if(n){for(let r=this.index;r<this.top.children.length;r++)if(this.top.children[r]==n)return r}return-1}e=t}}updateNextNode(e,t,n,r,i,o){for(let s=this.index;s<this.top.children.length;s++){let l=this.top.children[s];if(l instanceof Pn){let c=this.preMatch.matched.get(l);if(c!=null&&c!=i)return!1;let u=l.dom,h,d=this.isLocked(u)&&!(e.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==e.text&&l.dirty!=rt&&no(t,l.outerDeco));if(!d&&l.update(e,t,n,r))return this.destroyBetween(this.index,s),l.dom!=u&&(this.changed=!0),this.index++,!0;if(!d&&(h=this.recreateWrapper(l,e,t,n,r,o)))return this.destroyBetween(this.index,s),this.top.children[this.index]=h,h.contentDOM&&(h.dirty=un,h.updateChildren(r,o+1),h.dirty=Ue),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,r,i,o){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!no(n,e.outerDeco)||!r.eq(e.innerDeco))return null;let s=Pn.create(this.top,t,n,r,i,o);if(s.contentDOM){s.children=e.children,e.children=[];for(let l of s.children)l.parent=s}return e.destroy(),s}addNode(e,t,n,r,i){let o=Pn.create(this.top,e,t,n,r,i);o.contentDOM&&o.updateChildren(r,i+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,t,n){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(r&&r.matchesWidget(e)&&(e==r.widget||!r.widget.type.toDOM.parentNode))this.index++;else{let i=new rd(this.top,e,t,n);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Tr;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof od)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((we||pe)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let n=document.createElement(e);e=="IMG"&&(n.className="ProseMirror-separator",n.alt=""),e=="BR"&&(n.className="ProseMirror-trailingBreak");let r=new sd(this.top,[],n,null);t!=this.top?t.children.push(r):t.children.splice(this.index++,0,r),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||z(e)&&e.contains(this.lock.parentNode))}};function cw(e,t){let n=t,r=n.children.length,i=e.childCount,o=new Map,s=[];e:for(;i>0;){let l;for(;;)if(r){let u=n.children[r-1];if(u instanceof Tr)n=u,r=u.children.length;else{l=u,r--;break}}else{if(n==t)break e;r=n.parent.children.indexOf(n),n=n.parent}let c=l.node;if(c){if(c!=e.child(i-1))break;--i,o.set(l,i),s.push(l)}}return{index:i,matched:o,matches:s.reverse()}}a(cw,"L1");function uw(e,t){return e.type.side-t.type.side}a(uw,"z1");function hw(e,t,n,r){let i=t.locals(e),o=0;if(i.length==0){for(let u=0;u<e.childCount;u++){let h=e.child(u);r(h,i,t.forChild(o,h),u),o+=h.nodeSize}return}let s=0,l=[],c=null;for(let u=0;;){let h,d;for(;s<i.length&&i[s].to==o;){let v=i[s++];v.widget&&(h?(d||(d=[h])).push(v):h=v)}if(h)if(d){d.sort(uw);for(let v=0;v<d.length;v++)n(d[v],u,!!c)}else n(h,u,!!c);let p,f;if(c)f=-1,p=c,c=null;else if(u<e.childCount)f=u,p=e.child(u++);else break;for(let v=0;v<l.length;v++)l[v].to<=o&&l.splice(v--,1);for(;s<i.length&&i[s].from<=o&&i[s].to>o;)l.push(i[s++]);let m=o+p.nodeSize;if(p.isText){let v=m;s<i.length&&i[s].from<v&&(v=i[s].from);for(let y=0;y<l.length;y++)l[y].to<v&&(v=l[y].to);v<m&&(c=p.cut(v-o),p=p.cut(0,v-o),m=v,f=-1)}else for(;s<i.length&&i[s].to<m;)s++;let g=p.isInline&&!p.isLeaf?l.filter(v=>!v.inline):l.slice();r(p,g,t.forChild(o,p),f),o=m}}a(hw,"B1");function dw(e){if(e.nodeName=="UL"||e.nodeName=="OL"){let t=e.style.cssText;e.style.cssText=t+"; list-style: square !important",window.getComputedStyle(e).listStyle,e.style.cssText=t}}a(dw,"F1");function pw(e,t,n,r){for(let i=0,o=0;i<e.childCount&&o<=r;){let s=e.child(i++),l=o;if(o+=s.nodeSize,!s.isText)continue;let c=s.text;for(;i<e.childCount;){let u=e.child(i++);if(o+=u.nodeSize,!u.isText)break;c+=u.text}if(o>=n){if(o>=r&&c.slice(r-t.length-l,r-l)==t)return r-t.length;let u=l<r?c.lastIndexOf(t,r-l-1):-1;if(u>=0&&u+t.length+l>=n)return l+u;if(n==r&&c.length>=r+t.length-l&&c.slice(r-l,r-l+t.length)==t)return r}}return-1}a(pw,"_1");function Ks(e,t,n,r,i){let o=[];for(let s=0,l=0;s<e.length;s++){let c=e[s],u=l,h=l+=c.size;u>=n||h<=t?o.push(c):(u<t&&o.push(c.slice(0,t-u,r)),i&&(o.push(i),i=void 0),h>n&&o.push(c.slice(n-u,c.size,r)))}return o}a(Ks,"xa");function Js(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let i=e.docView.nearestDesc(n.focusNode),o=i&&i.size==0,s=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let l=r.resolve(s),c,u;if(eo(n)){for(c=s;i&&!i.node;)i=i.parent;if(i&&i.node.isAtom&&_.isSelectable(i.node)&&i.parent&&!(i.node.isInline&&Vk(n.focusNode,n.focusOffset,i.dom))){let d=i.posBefore;u=new _(s==d?l:r.resolve(d))}else if(Be&&t=="key"&&s>e.state.selection.to&&z(n.focusNode)&&n.focusOffset==n.focusNode.childNodes.length&&i&&i.posAtStart>e.state.selection.to)for(let d=n.focusNode;;d=d.parentNode){if(getComputedStyle(d).overflow!="visible"){u=j.findFrom(r.resolve(i.posAtStart),1);break}if(d==i.dom||d.nextSibling||!d.parentNode||!z(d.parentNode))break}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let d=s,p=s;for(let f=0;f<n.rangeCount;f++){let m=n.getRangeAt(f);d=Math.min(d,e.docView.posFromDOM(m.startContainer,m.startOffset,1)),p=Math.max(p,e.docView.posFromDOM(m.endContainer,m.endOffset,-1))}if(d<0)return null;[c,s]=p==e.state.selection.anchor?[p,d]:[d,p],l=r.resolve(s)}else c=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(c<0)return null}let h=r.resolve(c);if(!u){let d=t=="pointer"||e.state.selection.head<l.pos&&!o?1:-1;u=Gs(e,h,l,d)}return u}a(Js,"Ra");function hd(e){return e.editable?e.hasFocus():vd(e)&&document.activeElement&&document.activeElement.contains(e.dom)}a(hd,"Up");function Mt(e,t=!1){let n=e.state.selection;if(md(e,n),!hd(e))return;let r=e.input.mouseDown;if(!t&&pe&&r){let i=e.domSelectionRange(),o=e.domObserver.currentSelection;if(i.anchorNode&&o.anchorNode&&ln(i.anchorNode,i.anchorOffset,o.anchorNode,o.anchorOffset)&&r.delaySelUpdate()){e.domObserver.setCurSelection();return}}if(e.domObserver.disconnectSelection(),e.cursorWrapper)mw(e);else{let{anchor:i,head:o}=n,s,l;dd&&!(n instanceof q)&&(n.$from.parent.inlineContent||(s=pd(e,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(l=pd(e,n.to))),e.docView.setSelection(i,o,e,t),dd&&(s&&fd(s),l&&fd(l)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&fw(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}a(Mt,"zt");var dd=we||pe&&Wh<63;function pd(e,t){let{node:n,offset:r}=e.docView.domFromPos(t,0),i=r<n.childNodes.length?n.childNodes[r]:null,o=r?n.childNodes[r-1]:null;if(we&&i&&i.contentEditable=="false")return Us(i);if((!i||i.contentEditable=="false")&&(!o||o.contentEditable=="false")){if(i)return Us(i);if(o)return Us(o)}}a(pd,"gp");function Us(e){return e.contentEditable="true",we&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}a(Us,"aa");function fd(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}a(fd,"yp");function fw(e){let t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);let n=e.domSelectionRange(),r=n.anchorNode,i=n.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=i)&&(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(()=>{(!hd(e)||e.state.selection.visible)&&e.dom.classList.remove("ProseMirror-hideselection")},20))})}a(fw,"$1");function mw(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,r=n.nodeName=="IMG";r?t.collapse(n.parentNode,de(n)+1):t.collapse(n,0),!r&&!e.state.selection.visible&&De&&jt<=11&&(n.disabled=!0,n.disabled=!1)}a(mw,"V1");function md(e,t){if(t instanceof _){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(gd(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else gd(e)}a(md,"Gp");function gd(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}a(gd,"kp");function Gs(e,t,n,r){return e.someProp("createSelectionBetween",i=>i(e,t,n))||q.between(t,n,r)}a(Gs,"Da");function yd(e){return e.editable&&!e.hasFocus()?!1:vd(e)}a(yd,"bp");function vd(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return an(e.dom,t.anchorNode)&&(e.editable||an(e.dom,t.focusNode))}catch{return!1}}a(vd,"Yp");function gw(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return ln(t.node,t.offset,n.anchorNode,n.anchorOffset)}a(gw,"H1");function Qs(e,t){let{$anchor:n,$head:r}=e.selection,i=t>0?n.max(r):n.min(r),o=i.parent.inlineContent?i.depth?e.doc.resolve(t>0?i.after():i.before()):null:i;return o&&j.findFrom(o,t)}a(Qs,"wa");function Ht(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}a(Ht,"rn");function kd(e,t,n){let r=e.state.selection;if(r instanceof q)if(n.indexOf("s")>-1){let{$head:i}=r,o=i.textOffset?null:t<0?i.nodeBefore:i.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let s=e.state.doc.resolve(i.pos+o.nodeSize*(t<0?-1:1));return Ht(e,new q(r.$anchor,s))}else if(r.empty){if(e.endOfTextblock(t>0?"forward":"backward")){let i=Qs(e.state,t);return i&&i instanceof _?Ht(e,i):!1}else if(!(Je&&n.indexOf("m")>-1)){let i=r.$head,o=i.textOffset?null:t<0?i.nodeBefore:i.nodeAfter,s;if(!o||o.isText)return!1;let l=t<0?i.pos-o.nodeSize:i.pos;return o.isAtom||(s=e.docView.descAt(l))&&!s.contentDOM?_.isSelectable(o)?Ht(e,new _(t<0?e.state.doc.resolve(i.pos-o.nodeSize):i)):Ht(e,new q(e.state.doc.resolve(t<0?l:l+o.nodeSize))):!1}}else return!1;else{if(r instanceof _&&r.node.isInline)return Ht(e,new q(t>0?r.$to:r.$from));{let i=Qs(e.state,t);return i?Ht(e,i):!1}}}a(kd,"xp");function Ir(e,t){let n=e.pmViewDesc;return n?n.size==0&&(t<0||e.nextSibling||e.nodeName!="BR"):z(e)&&e.contentEditable=="false"}a(Ir,"Ri");function Fn(e,t){return t<0?yw(e):vw(e)}a(Fn,"Ir");function yw(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i,o,s=!1;for(Be&&z(n)&&r<ke(n)&&Ir(n.childNodes[r],-1)&&(s=!0);;)if(r>0){if(!z(n))break;let l=n.childNodes[r-1];if(Ir(l,-1))i=n,o=--r;else if(ae(l))n=l,r=n.nodeValue.length;else break}else{if(wd(n))break;{let l=n.previousSibling;for(;l&&Ir(l,-1);)i=n.parentNode,o=de(l),l=l.previousSibling;if(l)n=l,r=ke(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}}s?Ys(e,n,r):i&&Ys(e,i,o)}a(yw,"j1");function vw(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i=ke(n),o,s;for(;;)if(r<i){if(!z(n))break;let l=n.childNodes[r];if(Ir(l,1))o=n,s=++r;else break}else{if(wd(n))break;{let l=n.nextSibling;for(;l&&Ir(l,1);)o=l.parentNode,s=de(l)+1,l=l.nextSibling;if(l)n=l,r=0,i=ke(n);else{if(n=n.parentNode,n==e.dom)break;r=i=0}}}o&&Ys(e,o,s)}a(vw,"K1");function wd(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}a(wd,"Qp");function kw(e,t){for(;e&&t==e.childNodes.length&&!Mr(e);)t=de(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];if(ae(n))return n;if(z(n)&&n.contentEditable=="false")break;e=n,t=0}}a(kw,"W1");function ww(e,t){for(;e&&!t&&!Mr(e);)t=de(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(ae(n))return n;if(z(n)&&n.contentEditable=="false")break;e=n,t=e.childNodes.length}}a(ww,"q1");function Ys(e,t,n){if(!ae(t)){let o,s;(s=kw(t,n))?(t=s,n=0):(o=ww(t,n))&&(t=o,n=o.nodeValue.length)}let r=e.domSelection();if(!r)return;if(eo(r)){let o=document.createRange();o.setEnd(t,n),o.setStart(t,n),r.removeAllRanges(),r.addRange(o)}else r.extend&&r.extend(t,n);e.domObserver.setCurSelection();let{state:i}=e;setTimeout(()=>{e.state==i&&Mt(e)},50)}a(Ys,"Ca");function bd(e,t){let n=e.state.doc.resolve(t);if(!(pe||qh)&&n.parent.inlineContent){let r=e.coordsAtPos(t);if(t>n.start()){let i=e.coordsAtPos(t-1),o=(i.top+i.bottom)/2;if(o>r.top&&o<r.bottom&&Math.abs(i.left-r.left)>1)return i.left<r.left?"ltr":"rtl"}if(t<n.end()){let i=e.coordsAtPos(t+1),o=(i.top+i.bottom)/2;if(o>r.top&&o<r.bottom&&Math.abs(i.left-r.left)>1)return i.left>r.left?"ltr":"rtl"}}return getComputedStyle(e.dom).direction=="rtl"?"rtl":"ltr"}a(bd,"wp");function xd(e,t,n){let r=e.state.selection;if(r instanceof q&&!r.empty||n.indexOf("s")>-1||Je&&n.indexOf("m")>-1)return!1;let{$from:i,$to:o}=r;if(!i.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let s=Qs(e.state,t);if(s&&s instanceof _)return Ht(e,s)}if(!i.parent.inlineContent){let s=t<0?i:o,l=r instanceof wt?j.near(s,t):j.findFrom(s,t);return l?Ht(e,l):!1}return!1}a(xd,"Cp");function Sd(e,t){if(!(e.state.selection instanceof q))return!0;let{$head:n,$anchor:r,empty:i}=e.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let o=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(o&&!o.isText){let s=e.state.tr;return t<0?s.delete(n.pos-o.nodeSize,n.pos):s.delete(n.pos,n.pos+o.nodeSize),e.dispatch(s),!0}return!1}a(Sd,"Sp");function Cd(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}a(Cd,"Mp");function bw(e){if(!we||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&z(t)&&n==0&&t.firstChild&&z(t.firstChild)&&t.firstChild.contentEditable=="false"){let r=t.firstChild;Cd(e,r,"true"),setTimeout(()=>Cd(e,r,"false"),20)}return!1}a(bw,"J1");function xw(e){let t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}a(xw,"U1");function Sw(e,t){let n=t.keyCode,r=xw(t);if(n==8||Je&&n==72&&r=="c")return Sd(e,-1)||Fn(e,-1);if(n==46&&!t.shiftKey||Je&&n==68&&r=="c")return Sd(e,1)||Fn(e,1);if(n==13||n==27)return!0;if(n==37||Je&&n==66&&r=="c"){let i=n==37?bd(e,e.state.selection.from)=="ltr"?-1:1:-1;return kd(e,i,r)||Fn(e,i)}else if(n==39||Je&&n==70&&r=="c"){let i=n==39?bd(e,e.state.selection.from)=="ltr"?1:-1:1;return kd(e,i,r)||Fn(e,i)}else{if(n==38||Je&&n==80&&r=="c")return xd(e,-1,r)||Fn(e,-1);if(n==40||Je&&n==78&&r=="c")return bw(e)||xd(e,1,r)||Fn(e,1);if(r==(Je?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}a(Sw,"G1");function Xs(e,t){e.someProp("transformCopied",f=>{t=f(t,e)});let n=[],{content:r,openStart:i,openEnd:o}=t;for(;i>1&&o>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,o--;let f=r.firstChild;n.push(f.type.name,f.attrs!=f.type.defaultAttrs?f.attrs:null),r=f.content}let s=e.someProp("clipboardSerializer")||Vi.fromSchema(e.state.schema),l=Ed(),c=l.createElement("div");c.appendChild(s.serializeFragment(r,{document:l}));let u=c.firstChild,h,d=0;for(;u&&z(u)&&(h=Id[u.nodeName.toLowerCase()]);){for(let f=h.length-1;f>=0;f--){let m=l.createElement(h[f]);for(;c.firstChild;)m.appendChild(c.firstChild);c.appendChild(m),d++}u=c.firstChild}u&&z(u)&&u.setAttribute("data-pm-slice",`${i} ${o}${d?` -${d}`:""} ${JSON.stringify(n)}`);let p=e.someProp("clipboardTextSerializer",f=>f(t,e))||t.content.textBetween(0,t.content.size,`
42
+
43
+ `);return{dom:c,text:p,slice:t}}a(Xs,"Pa");function Md(e,t,n,r,i){let o=i.parent.type.spec.code,s,l;if(!n&&!t)return null;let c=!!t&&(r||o||!n);if(c){if(e.someProp("transformPastedText",p=>{t=p(t,o||r,e)}),o)return l=new E(O.from(e.state.schema.text(t.replace(/\r\n?/g,`
44
+ `))),0,0),e.someProp("transformPasted",p=>{l=p(l,e,!0)}),l;let d=e.someProp("clipboardTextParser",p=>p(t,i,r,e));if(d)l=d;else{let p=i.marks(),{schema:f}=e.state,m=Vi.fromSchema(f);s=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach(g=>{let v=s.appendChild(document.createElement("p"));g&&v.appendChild(m.serializeNode(f.text(g,p)))})}}else e.someProp("transformPastedHTML",d=>{n=d(n,e)}),s=Ow(n),to&&Tw(s);let u=s&&s.querySelector("[data-pm-slice]"),h=u&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(u.getAttribute("data-pm-slice")||"");if(h&&h[3])for(let d=+h[3];d>0;d--){let p=s.firstChild;for(;p&&!z(p);)p=p.nextSibling;if(!p)break;s=p}if(l||(l=(e.someProp("clipboardParser")||e.someProp("domParser")||ps.fromSchema(e.state.schema)).parseSlice(s,{preserveWhitespace:!!(c||h),context:i,ruleFromNode(d){return d.nodeName=="BR"&&!d.nextSibling&&d.parentNode&&!Cw.test(d.parentNode.nodeName)?{ignore:!0}:null}})),h)l=Aw(Ad(l,+h[1],+h[2]),h[4]);else if(l=E.maxOpen(Mw(l.content,i),!0),l.openStart||l.openEnd){let d=0,p=0;for(let f=l.content.firstChild;d<l.openStart&&!f.type.spec.isolating;d++,f=f.firstChild);for(let f=l.content.lastChild;p<l.openEnd&&!f.type.spec.isolating;p++,f=f.lastChild);l=Ad(l,d,p)}return e.someProp("transformPasted",d=>{l=d(l,e,c)}),l}a(Md,"Xp");var Cw=/^(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 Mw(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let r=t.node(n).contentMatchAt(t.index(n)),i,o=[];if(e.forEach(s=>{if(!o)return;let l=r.findWrapping(s.type),c;if(!l)return o=null;if(c=o.length&&i.length&&Od(l,i,s,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=Td(o[o.length-1],i.length));let u=Nd(s,l);o.push(u),r=r.matchType(u.type),i=l}}),o)return O.from(o)}return e}a(Mw,"Q1");function Nd(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,O.from(e));return e}a(Nd,"Zp");function Od(e,t,n,r,i){if(i<e.length&&i<t.length&&e[i]==t[i]){let o=Od(e,t,n,r.lastChild,i+1);if(o)return r.copy(r.content.replaceChild(r.childCount-1,o));if(r.contentMatchAt(r.childCount).matchType(i==e.length-1?n.type:e[i+1]))return r.copy(r.content.append(O.from(Nd(n,e,i+1))))}}a(Od,"em");function Td(e,t){if(t==0)return e;let n=e.content.replaceChild(e.childCount-1,Td(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(O.empty,!0);return e.copy(n.append(r))}a(Td,"tm");function Zs(e,t,n,r,i,o){let s=t<0?e.firstChild:e.lastChild,l=s.content;return e.childCount>1&&(o=0),i<r-1&&(l=Zs(l,t,n,r,i+1,o)),i>=n&&(l=t<0?s.contentMatchAt(0).fillBefore(l,o<=i).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(O.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,s.copy(l))}a(Zs,"Sa");function Ad(e,t,n){return t<e.openStart&&(e=new E(Zs(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new E(Zs(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}a(Ad,"Np");var Id={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};function Ed(){return document.implementation.createHTMLDocument("title")}a(Ed,"rm");var Er=null;function Nw(e){let t=window.trustedTypes;if(!t)return e;if(!Er){if(Er=t.defaultPolicy)try{return Er.createHTML(e)}catch{}Er=t.createPolicy("ProseMirrorClipboard",{createHTML:a(n=>n,"createHTML")})}return Er.createHTML(e)}a(Nw,"X1");function Ow(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=Ed(),r=n.body,i=/<([a-z][^>\s]+)/i.exec(e),o;if((o=i&&Id[i[1].toLowerCase()])&&(e=o.map(s=>"<"+s+">").join("")+e+o.map(s=>"</"+s+">").reverse().join("")),r.innerHTML=Nw(e),o)for(let s=0;s<o.length;s++)r=r.querySelector(o[s])||r;for(let s=0;s<n.styleSheets.length;s++){let l=n.styleSheets[s];for(let c=0;c<l.rules.length;c++){let u=l.rules[c];if(u instanceof CSSStyleRule){let h=r.querySelectorAll(u.selectorText);for(let d=0;d<h.length;d++)h[d].style.cssText+=u.style.cssText}}}return r}a(Ow,"Z1");function Tw(e){let t=e.querySelectorAll(pe?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<t.length;n++){let r=t[n];r.childNodes.length==1&&r.textContent=="\xA0"&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),r)}}a(Tw,"e0");function Aw(e,t){if(!e.size)return e;let n=e.content.firstChild.type.schema,r;try{r=JSON.parse(t)}catch{return e}let{content:i,openStart:o,openEnd:s}=e;for(let l=r.length-2;l>=0;l-=2){let c=n.nodes[r[l]];if(!c||c.hasRequiredAttrs())break;try{i=O.from(c.create(r[l+1],i))}catch{break}o++,s++}return new E(i,o,s)}a(Aw,"t0");var Me={},Ne={},Iw={touchstart:!0,touchmove:!0},Ew=class{static{a(this,"Ma")}constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function Dw(e){for(let t in Me){let n=Me[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=r=>{zw(e,r)&&!tl(e,r)&&(e.editable||!(r.type in Ne))&&n(e,r)},Iw[t]?{passive:!0}:void 0)}we&&e.dom.addEventListener("input",()=>null),el(e)}a(Dw,"r0");function Nt(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}a(Nt,"Lt");function Rw(e){e.input.mouseDown&&e.input.mouseDown.done(),e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}a(Rw,"i0");function el(e){e.someProp("handleDOMEvents",t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=r=>tl(e,r))})}a(el,"Na");function tl(e,t){return e.someProp("handleDOMEvents",n=>{let r=n[t.type];return r?r(e,t)||t.defaultPrevented:!1})}a(tl,"La");function zw(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}a(zw,"o0");function Pw(e,t){!tl(e,t)&&Me[t.type]&&(e.editable||!(t.type in Ne))&&Me[t.type](e,t)}a(Pw,"s0"),Ne.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,!Pd(e)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!(St&&pe&&n.keyCode==13)))if(n.keyCode!=229&&e.domObserver.forceFlush(),Rn&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();e.input.lastIOSEnter=r,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==r&&(e.someProp("handleKeyDown",i=>i(e,cn(13,"Enter"))),e.input.lastIOSEnter=0)},200)}else e.someProp("handleKeyDown",r=>r(e,n))||Sw(e,n)?n.preventDefault():Nt(e,"key")},Ne.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)},Ne.keypress=(e,t)=>{let n=t;if(Pd(e)||!n.charCode||n.ctrlKey&&!n.altKey||Je&&n.metaKey)return;if(e.someProp("handleKeyPress",i=>i(e,n))){n.preventDefault();return}let r=e.state.selection;if(!(r instanceof q)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(n.charCode),o=a(()=>e.state.tr.insertText(i).scrollIntoView(),"o");!/[\r\n]/.test(i)&&!e.someProp("handleTextInput",s=>s(e,r.$from.pos,r.$to.pos,i,o))&&e.dispatch(o()),n.preventDefault()}};function Dr(e){return{left:e.clientX,top:e.clientY}}a(Dr,"Fi");function Fw(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}a(Fw,"l0");function nl(e,t,n,r,i){if(r==-1)return!1;let o=e.state.doc.resolve(r);for(let s=o.depth+1;s>0;s--)if(e.someProp(t,l=>s>o.depth?l(e,n,o.nodeAfter,o.before(s),i,!0):l(e,n,o.node(s),o.before(s),i,!1)))return!0;return!1}a(nl,"za");function Rr(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);r.setMeta("pointer",!0),e.dispatch(r)}a(Rr,"_i");function Lw(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return r&&r.isAtom&&_.isSelectable(r)?(Rr(e,new _(n)),!0):!1}a(Lw,"a0");function $w(e,t){if(t==-1)return!1;let n=e.state.selection,r,i;n instanceof _&&(r=n.node);let o=e.state.doc.resolve(t);for(let s=o.depth+1;s>0;s--){let l=s>o.depth?o.nodeAfter:o.node(s);if(_.isSelectable(l)){r&&n.$from.depth>0&&s>=n.$from.depth&&o.before(n.$from.depth+1)==n.$from.pos?i=o.before(n.$from.depth):i=o.before(s);break}}return i!=null?(Rr(e,_.create(e.state.doc,i)),!0):!1}a($w,"c0");function Bw(e,t,n,r,i){return nl(e,"handleClickOn",t,n,r)||e.someProp("handleClick",o=>o(e,t,r))||(i?$w(e,n):Lw(e,n))}a(Bw,"u0");function Vw(e,t,n,r){return nl(e,"handleDoubleClickOn",t,n,r)||e.someProp("handleDoubleClick",i=>i(e,t,r))}a(Vw,"f0");function jw(e,t,n,r){return nl(e,"handleTripleClickOn",t,n,r)||e.someProp("handleTripleClick",i=>i(e,t,r))||_w(e,n,r)}a(jw,"h0");function _w(e,t,n){if(n.button!=0)return!1;let r=Dd(e,t,!0),i=e.state.doc;return r?(Rr(e,r),r instanceof q&&i.eq(e.state.doc)&&(e.input.mouseDown=new Ww(e,r)),!0):!1}a(_w,"d0");function Dd(e,t,n){let r=e.state.doc;if(t==-1)return r.inlineContent?q.create(r,0,r.content.size):null;let i=r.resolve(t);for(let o=i.depth+1;o>0;o--){let s=o>i.depth?i.nodeAfter:i.node(o),l=i.before(o);if(s.inlineContent)return q.create(r,l+1,l+1+s.content.size);if(n&&_.isSelectable(s))return _.create(r,l)}return null}a(Dd,"im");function rl(e){return ro(e)}a(rl,"Ba");var Rd=Je?"metaKey":"ctrlKey";Me.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=rl(e),i=Date.now(),o="singleClick";i-e.input.lastClick.time<500&&Fw(n,e.input.lastClick)&&!n[Rd]&&e.input.lastClick.button==n.button&&(e.input.lastClick.type=="singleClick"?o="doubleClick":e.input.lastClick.type=="doubleClick"&&(o="tripleClick")),e.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:o,button:n.button},e.input.mouseDown&&e.input.mouseDown.done();let s=e.posAtCoords(Dr(n));s&&(o=="singleClick"?e.input.mouseDown=new Hw(e,s,n,!!r):(o=="doubleClick"?Vw:jw)(e,s.pos,s.inside,n)?n.preventDefault():Nt(e,"pointer"))};var zd=class{static{a(this,"Xo")}constructor(e){this.view=e,this.mightDrag=null,e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this))}up(e){this.done()}move(e){e.buttons==0&&this.done()}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null)}delaySelUpdate(){return!1}},Hw=class extends zd{static{a(this,"va")}constructor(e,t,n,r){super(e),this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!n[Rd],this.allowDefault=n.shiftKey;let i,o;if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),o=t.inside;else{let u=e.state.doc.resolve(t.pos);i=u.parent,o=u.depth?u.before():0}let s=r?null:n.target,l=s?e.docView.nearestDesc(s,!0):null;this.target=l&&z(l.nodeDOM)?l.nodeDOM:null;let{selection:c}=e.state;n.button==0&&(i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof _&&c.from<=o&&c.to>o)&&(this.mightDrag={node:i,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Be&&!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()),Nt(e,"pointer")}done(){super.done(),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(()=>{this.view.isDestroyed||Mt(this.view)})}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(Dr(e))),this.updateAllowDefault(e),this.allowDefault||!t?Nt(this.view,"pointer"):Bw(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||we&&this.mightDrag&&!this.mightDrag.node.isAtom||pe&&!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)?(Rr(this.view,j.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):Nt(this.view,"pointer")}move(e){this.updateAllowDefault(e),Nt(this.view,"pointer"),super.move(e)}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return this.allowDefault?(this.delayedSelectionSync=!0,!0):!1}},Ww=class extends zd{static{a(this,"Ta")}constructor(e,t){super(e),this.startSelection=t,this.startDoc=e.state.doc}move(e){if(e.buttons==0||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc)){this.done();return}e.preventDefault(),Nt(this.view,"pointer");let t=this.view.posAtCoords(Dr(e)),n=t&&Dd(this.view,t.inside,!1);if(!n)return;let{doc:r}=this.view.state,i=this.startSelection,[o,s]=n.from<i.from?[i.to,n.from]:[i.from,n.to];Rr(this.view,q.create(r,o,s))}};Me.touchstart=e=>{e.input.lastTouch=Date.now(),rl(e),Nt(e,"pointer")},Me.touchmove=e=>{e.input.lastTouch=Date.now(),Nt(e,"pointer")},Me.contextmenu=e=>rl(e);function Pd(e,t){return e.composing?!0:we&&Math.abs(Date.now()-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}a(Pd,"sm");var qw=St?5e3:-1;Ne.compositionstart=Ne.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof q&&t.selection.empty&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||pe&&qh&&Kw(e)))e.markCursor=e.state.storedMarks||n.marks(),ro(e,!0),e.markCursor=null;else if(ro(e,!t.selection.empty),Be&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=e.domSelectionRange();for(let i=r.focusNode,o=r.focusOffset;i&&z(i)&&o!=0;){let s=o<0?i.lastChild:i.childNodes[o-1];if(!s)break;if(ae(s)){let l=e.domSelection();l&&l.collapse(s,s.nodeValue.length);break}else i=s,o=-1}}e.input.composing=!0}Fd(e,qw)};function Kw(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||!z(t)||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return z(r)&&r.contentEditable=="false"}a(Kw,"m0"),Ne.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now(),e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,Fd(e,20))};function Fd(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>ro(e),t))}a(Fd,"lm");function Ld(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}a(Ld,"am");function Jw(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=$k(t.focusNode,t.focusOffset),r=Bk(t.focusNode,t.focusOffset);if(n&&r&&n!=r){let i=r.pmViewDesc,o=e.domObserver.lastChangedTextNode;if(n==o||r==o)return o;if(!i||!i.isText(r.nodeValue))return r;if(e.input.compositionNode==r){let s=n.pmViewDesc;if(!(!s||!s.isText(n.nodeValue)))return r}}return n||r}a(Jw,"g0");function ro(e,t=!1){if(!(St&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),Ld(e),t||e.docView&&e.docView.dirty){let n=Js(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):(e.markCursor||t)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.dispatch(e.state.tr.deleteSelection()):e.updateState(e.state),!0}return!1}}a(ro,"Zo");function Uw(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(t),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}a(Uw,"y0");var zr=De&&jt<15||Rn&&Hk<604;Me.copy=Ne.cut=(e,t)=>{let n=t,r=e.state.selection,i=n.type=="cut";if(r.empty)return;let o=zr?null:n.clipboardData,s=r.content(),{dom:l,text:c}=Xs(e,s);o?(n.preventDefault(),o.clearData(),o.setData("text/html",l.innerHTML),o.setData("text/plain",c)):Uw(e,l),i&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Gw(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}a(Gw,"k0");function Qw(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=e.input.shiftKey&&e.input.lastKeyCode!=45;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Pr(e,r.value,null,i,t):Pr(e,r.textContent,r.innerHTML,i,t)},50)}a(Qw,"b0");function Pr(e,t,n,r,i){let o=Md(e,t,n,r,e.state.selection.$from);if(e.someProp("handlePaste",c=>c(e,i,o||E.empty)))return!0;if(!o)return!1;let s=Gw(o),l=s?e.state.tr.replaceSelectionWith(s,r):e.state.tr.replaceSelection(o);return e.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}a(Pr,"Pi");function $d(e){let t=e.getData("text/plain")||e.getData("Text");if(t)return t;let n=e.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}a($d,"cm"),Ne.paste=(e,t)=>{let n=t;if(e.composing&&!St)return;let r=zr?null:n.clipboardData,i=e.input.shiftKey&&e.input.lastKeyCode!=45;r&&Pr(e,$d(r),r.getData("text/html"),i,n)?n.preventDefault():Qw(e,n)};var Bd=class{static{a(this,"es")}constructor(e,t,n){this.slice=e,this.move=t,this.node=n}},Yw=Je?"altKey":"ctrlKey";function Vd(e,t){let n;return e.someProp("dragCopies",r=>{n=n||r(t)}),n!=null?!n:!t[Yw]}a(Vd,"um"),Me.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=e.state.selection,o=i.empty?null:e.posAtCoords(Dr(n)),s;if(!(o&&o.pos>=i.from&&o.pos<=(i instanceof _?i.to-1:i.to))){if(r&&r.mightDrag)s=_.create(e.state.doc,r.mightDrag.pos);else if(n.target&&z(n.target)){let d=e.docView.nearestDesc(n.target,!0);d&&d.node.type.spec.draggable&&d!=e.docView&&(s=_.create(e.state.doc,d.posBefore))}}let l=(s||e.state.selection).content(),{dom:c,text:u,slice:h}=Xs(e,l);(!n.dataTransfer.files.length||!pe||Wh>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(zr?"Text":"text/html",c.innerHTML),n.dataTransfer.effectAllowed="copyMove",zr||n.dataTransfer.setData("text/plain",u),e.dragging=new Bd(h,Vd(e,n),s)},Me.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},Ne.dragover=Ne.dragenter=(e,t)=>t.preventDefault(),Ne.drop=(e,t)=>{try{Xw(e,t,e.dragging)}finally{e.dragging=null}};function Xw(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(Dr(t));if(!r)return;let i=e.state.doc.resolve(r.pos),o=n&&n.slice;o?e.someProp("transformPasted",f=>{o=f(o,e,!1)}):o=Md(e,$d(t.dataTransfer),zr?null:t.dataTransfer.getData("text/html"),!1,i);let s=!!(n&&Vd(e,t));if(e.someProp("handleDrop",f=>f(e,t,o||E.empty,s))){t.preventDefault();return}if(!o)return;t.preventDefault();let l=o?Iv(e.state.doc,i.pos,o):i.pos;l==null&&(l=i.pos);let c=e.state.tr;if(s){let{node:f}=n;f?f.replace(c):c.deleteSelection()}let u=c.mapping.map(l),h=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,d=c.doc;if(h?c.replaceRangeWith(u,u,o.content.firstChild):c.replaceRange(u,u,o),c.doc.eq(d))return;let p=c.doc.resolve(u);if(h&&_.isSelectable(o.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(o.content.firstChild))c.setSelection(new _(p));else{let f=c.mapping.map(l);c.mapping.maps[c.mapping.maps.length-1].forEach((m,g,v,y)=>f=y),c.setSelection(Gs(e,p,c.doc.resolve(f)))}e.focus(),e.dispatch(c.setMeta("uiEvent","drop"))}a(Xw,"w0"),Me.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&Mt(e)},20))},Me.blur=(e,t)=>{let n=t;e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)},Me.beforeinput=(e,t)=>{if(St&&t.inputType=="deleteContentBackward"){e.domObserver.flushSoon();let{domChangeCount:n}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=n||(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",i=>i(e,cn(8,"Backspace")))))return;let{$cursor:r}=e.state.selection;r&&r.pos>0&&e.dispatch(e.state.tr.delete(r.pos-1,r.pos).scrollIntoView())},50)}};for(let e in Ne)Me[e]=Ne[e];function Fr(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}a(Fr,"Li");var jd=class Dm{static{a(this,"t")}constructor(t,n){this.toDOM=t,this.spec=n||dn,this.side=this.spec.side||0}map(t,n,r,i){let{pos:o,deleted:s}=t.mapResult(n.from+i,this.side<0?-1:1);return s?null:new Ge(o-r,o-r,this)}valid(){return!0}eq(t){return this==t||t instanceof Dm&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&Fr(this.spec,t.spec))}destroy(t){this.spec.destroy&&this.spec.destroy(t)}},Lr=class hc{static{a(this,"t")}constructor(t,n){this.attrs=t,this.spec=n||dn}map(t,n,r,i){let o=t.map(n.from+i,this.spec.inclusiveStart?-1:1)-r,s=t.map(n.to+i,this.spec.inclusiveEnd?1:-1)-r;return o>=s?null:new Ge(o,s,this)}valid(t,n){return n.from<n.to}eq(t){return this==t||t instanceof hc&&Fr(this.attrs,t.attrs)&&Fr(this.spec,t.spec)}static is(t){return t.type instanceof hc}destroy(){}},Zw=class Rm{static{a(this,"t")}constructor(t,n){this.attrs=t,this.spec=n||dn}map(t,n,r,i){let o=t.mapResult(n.from+i,1);if(o.deleted)return null;let s=t.mapResult(n.to+i,-1);return s.deleted||s.pos<=o.pos?null:new Ge(o.pos-r,s.pos-r,this)}valid(t,n){let{index:r,offset:i}=t.content.findIndex(n.from),o;return i==n.from&&!(o=t.child(r)).isText&&i+o.nodeSize==n.to}eq(t){return this==t||t instanceof Rm&&Fr(this.attrs,t.attrs)&&Fr(this.spec,t.spec)}destroy(){}},Ge=class wi{static{a(this,"t")}constructor(t,n,r){this.from=t,this.to=n,this.type=r}copy(t,n){return new wi(t,n,this.type)}eq(t,n=0){return this.type.eq(t.type)&&this.from+n==t.from&&this.to+n==t.to}map(t,n,r){return this.type.map(t,this,n,r)}static widget(t,n,r){return new wi(t,t,new jd(n,r))}static inline(t,n,r,i){return new wi(t,n,new Lr(r,i))}static node(t,n,r,i){return new wi(t,n,new Zw(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Lr}get widget(){return this.type instanceof jd}},Ln=[],dn={},be=class Xt{static{a(this,"t")}constructor(t,n){this.local=t.length?t:Ln,this.children=n.length?n:Ln}static create(t,n){return n.length?io(n,t,0,dn):xe}find(t,n,r){let i=[];return this.findInner(t??0,n??1e9,i,0,r),i}findInner(t,n,r,i,o){for(let s=0;s<this.local.length;s++){let l=this.local[s];l.from<=n&&l.to>=t&&(!o||o(l.spec))&&r.push(l.copy(l.from+i,l.to+i))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<n&&this.children[s+1]>t){let l=this.children[s]+1;this.children[s+2].findInner(t-l,n-l,r,i+l,o)}}map(t,n,r){return this==xe||t.maps.length==0?this:this.mapInner(t,n,0,0,r||dn)}mapInner(t,n,r,i,o){let s;for(let l=0;l<this.local.length;l++){let c=this.local[l].map(t,r,i);c&&c.type.valid(n,c)?(s||(s=[])).push(c):o.onRemove&&o.onRemove(this.local[l].spec)}return this.children.length?eb(this.children,s||[],t,n,r,i,o):s?new Xt(s.sort(pn),Ln):xe}add(t,n){return n.length?this==xe?Xt.create(t,n):this.addInner(t,n,0):this}addInner(t,n,r){let i,o=0;t.forEach((l,c)=>{let u=c+r,h;if(h=Wd(n,l,u)){for(i||(i=this.children.slice());o<i.length&&i[o]<c;)o+=3;i[o]==c?i[o+2]=i[o+2].addInner(l,h,u+1):i.splice(o,0,c,c+l.nodeSize,io(h,l,u+1,dn)),o+=3}});let s=Hd(o?qd(n):n,-r);for(let l=0;l<s.length;l++)s[l].type.valid(t,s[l])||s.splice(l--,1);return new Xt(s.length?this.local.concat(s).sort(pn):this.local,i||this.children)}remove(t){return t.length==0||this==xe?this:this.removeInner(t,0)}removeInner(t,n){let r=this.children,i=this.local;for(let o=0;o<r.length;o+=3){let s,l=r[o]+n,c=r[o+1]+n;for(let h=0,d;h<t.length;h++)(d=t[h])&&d.from>l&&d.to<c&&(t[h]=null,(s||(s=[])).push(d));if(!s)continue;r==this.children&&(r=this.children.slice());let u=r[o+2].removeInner(s,l+1);u!=xe?r[o+2]=u:(r.splice(o,3),o-=3)}if(i.length){for(let o=0,s;o<t.length;o++)if(s=t[o])for(let l=0;l<i.length;l++)i[l].eq(s,n)&&(i==this.local&&(i=this.local.slice()),i.splice(l--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new Xt(i,r):xe}forChild(t,n){if(this==xe)return this;if(n.isLeaf)return Xt.empty;let r,i;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=t){this.children[l]==t&&(r=this.children[l+2]);break}let o=t+1,s=o+n.content.size;for(let l=0;l<this.local.length;l++){let c=this.local[l];if(c.from<s&&c.to>o&&c.type instanceof Lr){let u=Math.max(o,c.from)-o,h=Math.min(s,c.to)-o;u<h&&(i||(i=[])).push(c.copy(u,h))}}if(i){let l=new Xt(i.sort(pn),Ln);return r?new _d([l,r]):l}return r||xe}eq(t){if(this==t)return!0;if(!(t instanceof Xt)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(t.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=t.children[n]||this.children[n+1]!=t.children[n+1]||!this.children[n+2].eq(t.children[n+2]))return!1;return!0}locals(t){return il(this.localsInner(t))}localsInner(t){if(this==xe)return Ln;if(t.inlineContent||!this.local.some(Lr.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Lr||n.push(this.local[r]);return n}forEachSet(t){t(this)}};be.empty=new be([],[]),be.removeOverlap=il;var xe=be.empty,_d=class rr{static{a(this,"t")}constructor(t){this.members=t}map(t,n){let r=this.members.map(i=>i.map(t,n,dn));return rr.from(r)}forChild(t,n){if(n.isLeaf)return be.empty;let r=[];for(let i=0;i<this.members.length;i++){let o=this.members[i].forChild(t,n);o!=xe&&(o instanceof rr?r=r.concat(o.members):r.push(o))}return rr.from(r)}eq(t){if(!(t instanceof rr)||t.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(t.members[n]))return!1;return!0}locals(t){let n,r=!0;for(let i=0;i<this.members.length;i++){let o=this.members[i].localsInner(t);if(o.length)if(!n)n=o;else{r&&(n=n.slice(),r=!1);for(let s=0;s<o.length;s++)n.push(o[s])}}return n?il(r?n:n.sort(pn)):Ln}static from(t){switch(t.length){case 0:return xe;case 1:return t[0];default:return new rr(t.every(n=>n instanceof be)?t:t.reduce((n,r)=>n.concat(r instanceof be?r:r.members),[]))}}forEachSet(t){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(t)}};function eb(e,t,n,r,i,o,s){let l=e.slice();for(let u=0,h=o;u<n.maps.length;u++){let d=0;n.maps[u].forEach((p,f,m,g)=>{let v=g-m-(f-p);for(let y=0;y<l.length;y+=3){let N=l[y+1];if(N<0||p>N+h-d)continue;let x=l[y]+h-d;f>=x?l[y+1]=p<=x?-2:-1:p>=h&&v&&(l[y]+=v,l[y+1]+=v)}d+=v}),h=n.maps[u].map(h,-1)}let c=!1;for(let u=0;u<l.length;u+=3)if(l[u+1]<0){if(l[u+1]==-2){c=!0,l[u+1]=-1;continue}let h=n.map(e[u]+o),d=h-i;if(d<0||d>=r.content.size){c=!0;continue}let p=n.map(e[u+1]+o,-1),f=p-i,{index:m,offset:g}=r.content.findIndex(d),v=r.maybeChild(m);if(v&&g==d&&g+v.nodeSize==f){let y=l[u+2].mapInner(n,v,h+1,e[u]+o+1,s);y!=xe?(l[u]=d,l[u+1]=f,l[u+2]=y):(l[u+1]=-2,c=!0)}else c=!0}if(c){let u=tb(l,e,t,n,i,o,s),h=io(u,r,0,s);t=h.local;for(let d=0;d<l.length;d+=3)l[d+1]<0&&(l.splice(d,3),d-=3);for(let d=0,p=0;d<h.children.length;d+=3){let f=h.children[d];for(;p<l.length&&l[p]<f;)p+=3;l.splice(p,0,h.children[d],h.children[d+1],h.children[d+2])}}return new be(t.sort(pn),l)}a(eb,"C0");function Hd(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let i=e[r];n.push(new Ge(i.from+t,i.to+t,i.type))}return n}a(Hd,"fm");function tb(e,t,n,r,i,o,s){function l(c,u){for(let h=0;h<c.local.length;h++){let d=c.local[h].map(r,i,u);d?n.push(d):s.onRemove&&s.onRemove(c.local[h].spec)}for(let h=0;h<c.children.length;h+=3)l(c.children[h+2],c.children[h]+u+1)}a(l,"l");for(let c=0;c<e.length;c+=3)e[c+1]==-1&&l(e[c+2],t[c]+o+1);return n}a(tb,"S0");function Wd(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,i=null;for(let o=0,s;o<e.length;o++)(s=e[o])&&s.from>n&&s.to<r&&((i||(i=[])).push(s),e[o]=null);return i}a(Wd,"hm");function qd(e){let t=[];for(let n=0;n<e.length;n++)e[n]!=null&&t.push(e[n]);return t}a(qd,"dm");function io(e,t,n,r){let i=[],o=!1;t.forEach((l,c)=>{let u=Wd(e,l,c+n);if(u){o=!0;let h=io(u,l,n+c+1,r);h!=xe&&i.push(c,c+l.nodeSize,h)}});let s=Hd(o?qd(e):e,-n).sort(pn);for(let l=0;l<s.length;l++)s[l].type.valid(t,s[l])||(r.onRemove&&r.onRemove(s[l].spec),s.splice(l--,1));return s.length||i.length?new be(s,i):xe}a(io,"rs");function pn(e,t){return e.from-t.from||e.to-t.to}a(pn,"Wn");function il(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let i=n+1;i<t.length;i++){let o=t[i];if(o.from==r.from){o.to!=r.to&&(t==e&&(t=e.slice()),t[i]=o.copy(o.from,r.to),Kd(t,i+1,o.copy(r.to,o.to)));continue}else{o.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,o.from),Kd(t,i,r.copy(o.from,r.to)));break}}}return t}a(il,"Fa");function Kd(e,t,n){for(;t<e.length&&pn(n,e[t])>0;)t++;e.splice(t,0,n)}a(Kd,"vp");function ol(e){let t=[];return e.someProp("decorations",n=>{let r=n(e.state);r&&r!=xe&&t.push(r)}),e.cursorWrapper&&t.push(be.create(e.state.doc,[e.cursorWrapper.deco])),_d.from(t)}a(ol,"ca");var nb={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},rb=De&&jt<=11,ib=class{static{a(this,"Aa")}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}},ob=class{static{a(this,"Ea")}constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new ib,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(n=>{for(let r=0;r<n.length;r++)this.queue.push(n[r]);De&&jt<=11&&n.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():we&&e.composing&&n.some(r=>r.type=="childList"&&r.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),rb&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.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,nb)),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(yd(this.view)){if(this.suppressingSelectionUpdates)return Mt(this.view);if(De&&jt<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&ln(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,n;for(let i=e.focusNode;i;i=Dn(i))t.add(i);for(let i=e.anchorNode;i;i=Dn(i))if(t.has(i)){n=i;break}let r=n&&this.view.docView.nearestDesc(n);if(r&&r.ignoreMutation({type:"selection",target:ae(n)?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&yd(e)&&!this.ignoreSelectionChange(n),i=-1,o=-1,s=!1,l=[];if(e.editable)for(let u=0;u<t.length;u++){let h=this.registerMutation(t[u],l);h&&(i=i<0?h.from:Math.min(h.from,i),o=o<0?h.to:Math.max(h.to,o),h.typeOver&&(s=!0))}if(l.some(u=>u.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46||pe&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&t.some(u=>u.type=="childList"&&u.removedNodes.length))){for(let u of l)if(u.nodeName=="BR"&&u.parentNode){let h=u.nextSibling;for(;h&&z(h);){if(h.contentEditable=="false"){u.parentNode.removeChild(u);break}h=h.firstChild}}}else if(Be&&l.length){let u=l.filter(h=>h.nodeName=="BR");if(u.length==2){let[h,d]=u;h.parentNode&&h.parentNode.parentNode==d.parentNode?d.remove():h.remove()}else{let{focusNode:h}=this.currentSelection;for(let d of u){let p=d.parentNode;p&&p.nodeName=="LI"&&(!h||ab(e,h)!=p)&&d.remove()}}}let c=null;i<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&eo(n)&&(c=Js(e))&&c.eq(j.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Mt(e),this.currentSelection.set(n),e.scrollToSelection()):(i>-1||r)&&(i>-1&&(e.docView.markDirty(i,o),sb(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,cb(e,l)),this.handleDOMChange(i,o,s,l),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||Mt(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(n==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!n||n.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;u<e.addedNodes.length;u++){let h=e.addedNodes[u];t.push(h),ae(h)&&(this.lastChangedTextNode=h)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let r=e.previousSibling,i=e.nextSibling;if(De&&jt<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:h,nextSibling:d}=e.addedNodes[u];(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(r=h),(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(i=d)}let o=r&&r.parentNode==e.target?de(r)+1:0,s=n.localPosFromDOM(e.target,o,-1),l=i&&i.parentNode==e.target?de(i):e.target.childNodes.length,c=n.localPosFromDOM(e.target,l,1);return{from:s,to:c}}else return e.type=="attributes"?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:(this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}},Jd=new WeakMap,Ud=!1;function sb(e){if(!Jd.has(e)&&(Jd.set(e,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace)!==-1)){if(e.requiresGeckoHackNode=Be,Ud)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."),Ud=!0}}a(sb,"v0");function Gd(e,t){let n=t.startContainer,r=t.startOffset,i=t.endContainer,o=t.endOffset,s=e.domAtPos(e.state.selection.anchor);return ln(s.node,s.offset,i,o)&&([n,r,i,o]=[i,o,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:o}}a(Gd,"Ap");function lb(e,t){if(t.getComposedRanges){let i=t.getComposedRanges(e.root)[0];if(i)return Gd(e,i)}let n;function r(i){i.preventDefault(),i.stopImmediatePropagation(),n=i.getTargetRanges()[0]}return a(r,"r"),e.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),e.dom.removeEventListener("beforeinput",r,!0),n?Gd(e,n):null}a(lb,"T0");function ab(e,t){for(let n=t.parentNode;n&&n!=e.dom;n=n.parentNode){let r=e.docView.nearestDesc(n,!0);if(r&&r.node.isBlock)return n}return null}a(ab,"I0");function cb(e,t){var n;let{focusNode:r,focusOffset:i}=e.domSelectionRange();for(let o of t)if(((n=o.parentNode)===null||n===void 0?void 0:n.nodeName)=="TR"){let s=o.nextSibling;for(;s&&s.nodeName!="TD"&&s.nodeName!="TH";)s=s.nextSibling;if(s){let l=s;for(;;){let c=l.firstChild;if(!c||!z(c)||c.contentEditable=="false"||/^(BR|IMG)$/.test(c.nodeName))break;l=c}l.insertBefore(o,l.firstChild),r==o&&e.domSelection().collapse(o,i)}else o.parentNode.removeChild(o)}}a(cb,"A0");function ub(e,t,n,r){let{node:i,fromOffset:o,toOffset:s,from:l,to:c}=e.docView.parseRange(t,n),u=e.domSelectionRange(),h,d=u.anchorNode;if(d&&an(e.dom,d)&&(h=[{node:d,offset:u.anchorOffset}],eo(u)||h.push({node:u.focusNode,offset:u.focusOffset})),pe&&e.input.lastKeyCode===8)for(let y=s;y>o;y--){let N=i.childNodes[y-1],x=N.pmViewDesc;if(N.nodeName=="BR"&&!x){s=y;break}if(!x||x.size)break}let p=e.state.doc,f=e.someProp("domParser")||ps.fromSchema(e.state.schema),m=p.resolve(l),g=null,v=f.parse(i,{topNode:m.parent,topMatch:m.parent.contentMatchAt(m.index()),topOpen:!0,from:o,to:s,preserveWhitespace:m.parent.type.whitespace=="pre"?"full":!0,findPositions:h,ruleFromNode:hb(r),context:m});if(h&&h[0].pos!=null){let y=h[0].pos,N=h[1]&&h[1].pos;N==null&&(N=y),g={anchor:y+l,head:N+l}}return{doc:v,sel:g,from:l,to:c}}a(ub,"E0");var hb=a(e=>t=>{let n=t.pmViewDesc;if(n)return n.parseRule(e);if(t.nodeName=="BR"&&t.parentNode){if(we&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let r=document.createElement("div");return r.appendChild(document.createElement("li")),{skip:r}}else if(t.parentNode.lastChild==t||we&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null},"O0"),db=/^(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 pb(e,t,n,r,i){let o=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let I=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,F=Js(e,I);if(F&&!e.state.selection.eq(F)){if(pe&&St&&e.input.lastKeyCode===13&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp("handleKeyDown",b=>b(e,cn(13,"Enter"))))return;let $=e.state.tr.setSelection(F);I=="pointer"?$.setMeta("pointer",!0):I=="key"&&$.scrollIntoView(),o&&$.setMeta("composition",o),e.dispatch($)}return}let s=e.state.doc.resolve(t),l=s.sharedDepth(n);t=s.before(l+1),n=e.state.doc.resolve(n).after(l+1);let c=e.state.selection,u=ub(e,t,n,i),h=e.state.doc,d=h.slice(u.from,u.to),p,f;e.input.lastKeyCode===8&&Date.now()-100<e.input.lastKeyCodeTime?(p=e.state.selection.to,f="end"):(p=e.state.selection.from,f="start"),e.input.lastKeyCode=null;let m=yb(d.content,u.doc.content,u.from,p,f);if(m&&e.input.domChangeCount++,(Rn&&e.input.lastIOSEnter>Date.now()-225||St)&&i.some(I=>z(I)&&!db.test(I.nodeName))&&(!m||m.endA>=m.endB)&&e.someProp("handleKeyDown",I=>I(e,cn(13,"Enter")))){e.input.lastIOSEnter=0;return}if(!m)if(r&&c instanceof q&&!c.empty&&c.$head.sameParent(c.$anchor)&&!e.composing&&!(u.sel&&u.sel.anchor!=u.sel.head))m={start:c.from,endA:c.to,endB:c.to};else{if(u.sel){let I=Qd(e,e.state.doc,u.sel);if(I&&!I.eq(e.state.selection)){let F=e.state.tr.setSelection(I);o&&F.setMeta("composition",o),e.dispatch(F)}}return}e.state.selection.from<e.state.selection.to&&m.start==m.endB&&e.state.selection instanceof q&&(m.start>e.state.selection.from&&m.start<=e.state.selection.from+2&&e.state.selection.from>=u.from?m.start=e.state.selection.from:m.endA<e.state.selection.to&&m.endA>=e.state.selection.to-2&&e.state.selection.to<=u.to&&(m.endB+=e.state.selection.to-m.endA,m.endA=e.state.selection.to)),De&&jt<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>u.from&&u.doc.textBetween(m.start-u.from-1,m.start-u.from+1)==" \xA0"&&(m.start--,m.endA--,m.endB--);let g=u.doc.resolveNoCache(m.start-u.from),v=u.doc.resolveNoCache(m.endB-u.from),y=h.resolve(m.start),N=g.sameParent(v)&&g.parent.inlineContent&&y.end()>=m.endA;if((Rn&&e.input.lastIOSEnter>Date.now()-225&&(!N||i.some(I=>I.nodeName=="DIV"||I.nodeName=="P"))||!N&&gb(u.doc,g.pos,v.pos))&&e.someProp("handleKeyDown",I=>I(e,cn(13,"Enter")))){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>m.start&&mb(h,m.start,m.endA,g,v)&&e.someProp("handleKeyDown",I=>I(e,cn(8,"Backspace")))){St&&pe&&e.domObserver.suppressSelectionUpdates();return}pe&&m.endB==m.start&&(e.input.lastChromeDelete=Date.now()),St&&!N&&g.start()!=v.start()&&v.parentOffset==0&&g.depth==v.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==m.endA&&(m.endB-=2,v=u.doc.resolveNoCache(m.endB-u.from),setTimeout(()=>{e.someProp("handleKeyDown",function(I){return I(e,cn(13,"Enter"))})},20));let x=m.start,A=m.endA,D=a(I=>{let F=I||e.state.tr.replace(x,A,u.doc.slice(m.start-u.from,m.endB-u.from));if(u.sel){let $=Qd(e,F.doc,u.sel);$&&!(pe&&e.composing&&$.empty&&(m.start!=m.endB||e.input.lastChromeDelete<Date.now()-100)&&($.head==x||$.head==F.mapping.map(A)-1)||De&&$.empty&&$.head==x)&&F.setSelection($)}return o&&F.setMeta("composition",o),F.scrollIntoView()},"R"),M;if(N)if(g.pos==v.pos){De&&jt<=11&&g.parentOffset==0&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>Mt(e),20));let I=D(e.state.tr.delete(x,A)),F=h.resolve(m.start).marksAcross(h.resolve(m.endA));F&&I.ensureMarks(F),e.dispatch(I)}else if(m.endA==m.endB&&(M=fb(g.parent.content.cut(g.parentOffset,v.parentOffset),y.parent.content.cut(y.parentOffset,m.endA-y.start())))){let I=D(e.state.tr);M.type=="add"?I.addMark(x,A,M.mark):I.removeMark(x,A,M.mark),e.dispatch(I)}else if(g.parent.child(g.index()).isText&&g.index()==v.index()-(v.textOffset?0:1)){let I=g.parent.textBetween(g.parentOffset,v.parentOffset),F=a(()=>D(e.state.tr.insertText(I,x,A)),"F");e.someProp("handleTextInput",$=>$(e,x,A,I,F))||e.dispatch(F())}else e.dispatch(D());else e.dispatch(D())}a(pb,"D0");function Qd(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:Gs(e,t.resolve(n.anchor),t.resolve(n.head))}a(Qd,"Ep");function fb(e,t){let n=e.firstChild.marks,r=t.firstChild.marks,i=n,o=r,s,l,c;for(let h=0;h<r.length;h++)i=r[h].removeFromSet(i);for(let h=0;h<n.length;h++)o=n[h].removeFromSet(o);if(i.length==1&&o.length==0)l=i[0],s="add",c=a(h=>h.mark(l.addToSet(h.marks)),"a");else if(i.length==0&&o.length==1)l=o[0],s="remove",c=a(h=>h.mark(l.removeFromSet(h.marks)),"a");else return null;let u=[];for(let h=0;h<t.childCount;h++)u.push(c(t.child(h)));if(O.from(u).eq(e))return{mark:l,type:s}}a(fb,"P0");function mb(e,t,n,r,i){if(n-t<=i.pos-r.pos||sl(r,!0,!1)<i.pos)return!1;let o=e.resolve(t);if(!r.parent.isTextblock){let l=o.nodeAfter;return l!=null&&n==t+l.nodeSize}if(o.parentOffset<o.parent.content.size||!o.parent.isTextblock)return!1;let s=e.resolve(sl(o,!0,!0));return!s.parent.isTextblock||s.pos>n||sl(s,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(s.parent.content)}a(mb,"L0");function gb(e,t,n){let r=0,i=0;return e.nodesBetween(t,n,(o,s)=>{o.isTextblock&&s>=t&&s<n?r++:(o.isText?/\S/.test(o.text.slice(Math.max(0,t-s),Math.min(o.nodeSize,n-s))):o.isLeaf)&&i++}),i==0&&r==1}a(gb,"z0");function sl(e,t,n){let r=e.depth,i=t?e.end():e.pos;for(;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,i++,t=!1;if(n){let o=e.node(r).maybeChild(e.indexAfter(r));for(;o&&!o.isLeaf;)o=o.firstChild,i++}return i}a(sl,"ua");function yb(e,t,n,r,i){let o=e.findDiffStart(t,n),s=n+e.size,l=n+t.size;if(o==null)return null;let{a:c,b:u}=e.findDiffEnd(t,s,l);if(i=="end"){let h=Math.max(0,o-Math.min(c,u));r-=c+h-o}if(c<o&&s<l){let h=r<=o&&r>=c?o-r:0;o-=h,u=o+(u-c),c=o}else if(u<o){let h=r<=o&&r>=u?o-r:0;o-=h,c=o+(c-u),u=o}return{start:o,endA:c,endB:u}}a(yb,"B0");var Yd=class{static{a(this,"zi")}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 Ew,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(np),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=ep(this),Zd(this),this.nodeViews=tp(this),this.docView=id(this.state.doc,Xd(this),ol(this),this.dom,this),this.domObserver=new ob(this,(n,r,i,o)=>pb(this,n,r,i,o)),this.domObserver.start(),Dw(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&&el(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(np),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let n in this._props)t[n]=this._props[n];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var n;let r=this.state,i=!1,o=!1;e.storedMarks&&this.composing&&(Ld(this),o=!0),this.state=e;let s=r.plugins!=e.plugins||this._props.plugins!=t.plugins;if(s||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let p=tp(this);kb(p,this.nodeViews)&&(this.nodeViews=p,i=!0)}(s||t.handleDOMEvents!=this._props.handleDOMEvents)&&el(this),this.editable=ep(this),Zd(this);let l=ol(this),c=Xd(this),u=r.plugins!=e.plugins&&!r.doc.eq(e.doc)?"reset":e.scrollToSelection>r.scrollToSelection?"to selection":"preserve",h=i||!this.docView.matchesNode(e.doc,c,l);(h||!e.selection.eq(r.selection))&&(o=!0);let d=u=="preserve"&&o&&this.dom.style.overflowAnchor==null&&Kk(this);if(o){this.domObserver.stop();let p=h&&(De||pe)&&!this.composing&&!r.selection.empty&&!e.selection.empty&&vb(r.selection,e.selection);if(h){let m=pe?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Jw(this)),(i||!this.docView.update(e.doc,c,l,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=id(e.doc,c,l,this.dom,this)),m&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(p=!0)}let f=this.input.mouseDown;p||!(f&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&gw(this)&&f.delaySelUpdate())?Mt(this,p):(md(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(r),!((n=this.dragging)===null||n===void 0)&&n.node&&!r.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,r),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():d&&Jk(d)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!an(this.dom,e))&&!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof _){let t=this.docView.domAfterPos(this.state.selection.from);z(t)&&Kh(this,t.getBoundingClientRect(),e)}else Kh(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 n=this.directPlugins[t];n.spec.view&&this.pluginViews.push(n.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let n=this.state.plugins[t];n.spec.view&&this.pluginViews.push(n.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}}updateDraggedNode(e,t){let n=e.node,r=-1;if(n.from<this.state.doc.content.size&&this.state.doc.nodeAt(n.from)==n.node)r=n.from;else{let i=n.from+(this.state.doc.content.size-t.doc.content.size);(i>0&&i<this.state.doc.content.size&&this.state.doc.nodeAt(i))==n.node&&(r=i)}this.dragging=new Bd(e.slice,e.move,r<0?void 0:_.create(this.state.doc,r))}someProp(e,t){let n=this._props&&this._props[e],r;if(n!=null&&(r=t?t(n):n))return r;for(let o=0;o<this.directPlugins.length;o++){let s=this.directPlugins[o].props[e];if(s!=null&&(r=t?t(s):s))return r}let i=this.state.plugins;if(i)for(let o=0;o<i.length;o++){let s=i[o].props[e];if(s!=null&&(r=t?t(s):s))return r}}hasFocus(){if(De){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&&Uk(this.dom),Mt(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 Zk(this,e)}coordsAtPos(e,t=1){return Yh(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let r=this.docView.posFromDOM(e,t,n);if(r==null)throw new RangeError("DOM position not inside the editor");return r}endOfTextblock(e,t){return iw(this,t||this.state,e)}pasteHTML(e,t){return Pr(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Pr(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return Xs(this,e)}destroy(){this.docView&&(Rw(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],ol(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Fk())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Pw(this,e)}domSelectionRange(){let e=this.dom.isConnected!==!1&&this.domSelection();return e?we&&this.root.nodeType===11&&jk(this.dom.ownerDocument)==this.dom&&lb(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};Yd.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};function Xd(e){let t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(e.editable),e.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(e.state)),n)for(let r in n)r=="class"?t.class+=" "+n[r]:r=="style"?t.style=(t.style?t.style+";":"")+n[r]:!t[r]&&r!="contenteditable"&&r!="nodeName"&&(t[r]=String(n[r]))}),t.translate||(t.translate="no"),[Ge.node(0,e.state.doc.content.size,t)]}a(Xd,"Op");function Zd(e){if(e.markCursor){let t=document.createElement("img");t.className="ProseMirror-separator",t.setAttribute("mark-placeholder","true"),t.setAttribute("alt",""),e.cursorWrapper={dom:t,deco:Ge.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}a(Zd,"Rp");function ep(e){return!e.someProp("editable",t=>t(e.state)===!1)}a(ep,"Dp");function vb(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}a(vb,"F0");function tp(e){let t=Object.create(null);function n(r){for(let i in r)Object.prototype.hasOwnProperty.call(t,i)||(t[i]=r[i])}return a(n,"n"),e.someProp("nodeViews",n),e.someProp("markViews",n),t}a(tp,"Pp");function kb(e,t){let n=0,r=0;for(let i in e){if(e[i]!=t[i])return!0;n++}for(let i in t)r++;return n!=r}a(kb,"_0");function np(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}a(np,"Lp");function Ot(e,t){return e.meta={package:"@milkdown/core",group:"System",...t},e}a(Ot,"Bt");var rp={text:a((e,t,n,r)=>{let i=e.value;return/^[^*_\\]*\s+$/.test(i)?i:n.safe(i,{...r,encode:[]})},"text"),strong:a((e,t,n,r)=>{let i=e.marker||n.options.strong||"*",o=n.enter("strong"),s=n.createTracker(r),l=s.move(i+i);return l+=s.move(n.containerPhrasing(e,{before:l,after:i,...s.current()})),l+=s.move(i+i),o(),l},"strong"),emphasis:a((e,t,n,r)=>{let i=e.marker||n.options.emphasis||"*",o=n.enter("emphasis"),s=n.createTracker(r),l=s.move(i);return l+=s.move(n.containerPhrasing(e,{before:l,after:i,...s.current()})),l+=s.move(i),o(),l},"emphasis")},Qe=J({},"editorView"),$r=J({},"editorState"),ll=J([],"initTimer"),ip=J({},"editor"),Br=J([],"inputRules"),fn=J([],"prosePlugins"),Vr=J([],"remarkPlugins"),jr=J([],"nodeView"),_r=J([],"markView"),mn=J(Ri().use(Ti).use(es),"remark"),Hr=J({handlers:rp,encode:[]},"remarkStringifyOptions"),oo=ct("ConfigReady");function wb(e){let t=a(n=>(n.record(oo),async()=>(await e(n),n.done(oo),()=>{n.clearTimer(oo)})),"e");return Ot(t,{displayName:"Config"}),t}a(wb,"$0");var $n=ct("InitReady");function bb(e){let t=a(n=>(n.inject(ip,e).inject(fn,[]).inject(Vr,[]).inject(Br,[]).inject(jr,[]).inject(_r,[]).inject(Hr,{handlers:rp,encode:[]}).inject(mn,Ri().use(Ti).use(es)).inject(ll,[oo]).record($n),async()=>{await n.waitTimers(ll);let r=n.get(Hr);return n.set(mn,Ri().use(Ti).use(es,r)),n.done($n),()=>{n.remove(ip).remove(fn).remove(Vr).remove(Br).remove(jr).remove(_r).remove(Hr).remove(mn).remove(ll).clearTimer($n)}}),"e");return Ot(t,{displayName:"Init"}),t}a(bb,"V0");var Oe=ct("SchemaReady"),al=J([],"schemaTimer"),it=J({},"schema"),Wr=J([],"nodes"),qr=J([],"marks");function op(e){return{...e,parseDOM:e.parseDOM?.map(t=>({priority:e.priority,...t}))}}a(op,"mm");var sp=a(e=>(e.inject(it,{}).inject(Wr,[]).inject(qr,[]).inject(al,[$n]).record(Oe),async()=>{await e.waitTimers(al);let t=e.get(mn),n=e.get(Vr).reduce((s,l)=>s.use(l.plugin,l.options),t);e.set(mn,n);let r=Object.fromEntries(e.get(Wr).map(([s,l])=>[s,op(l)])),i=Object.fromEntries(e.get(qr).map(([s,l])=>[s,op(l)])),o=new ov({nodes:r,marks:i});return e.set(it,o),e.done(Oe),()=>{e.remove(it).remove(Wr).remove(qr).remove(al).clearTimer(Oe)}}),"ym");Ot(sp,{displayName:"Schema"});var lp=class{static{a(this,"km")}constructor(){this.#t=new vc,this.#e=null,this.setCtx=e=>{this.#e=e},this.chain=()=>{if(this.#e==null)throw Bo();let e=this.#e,t=[],n=this.get.bind(this),r={run:a(()=>{let o=En(...t),s=e.get(Qe);return o(s.state,s.dispatch,s)},"run"),inline:a(o=>(t.push(o),r),"inline"),pipe:i.bind(this)};function i(o,s){let l=n(o);return t.push(l(s)),r}return a(i,"i"),r}}#t;#e;get ctx(){return this.#e}create(e,t){let n=e.create(this.#t.sliceMap);return n.set(t),n}get(e){return this.#t.get(e).get()}remove(e){return this.#t.remove(e)}call(e,t){if(this.#e==null)throw Bo();let n=this.get(e)(t),r=this.#e.get(Qe);return n(r.state,r.dispatch,r)}inline(e){if(this.#e==null)throw Bo();let t=this.#e.get(Qe);return e(t.state,t.dispatch,t)}};function xb(e="cmdKey"){return J((()=>()=>!1),e)}a(xb,"bm");var Q=J(new lp,"commands"),cl=J([Oe],"commandsTimer"),Kr=ct("CommandsReady"),ap=a(e=>{let t=new lp;return t.setCtx(e),e.inject(Q,t).inject(cl,[Oe]).record(Kr),async()=>(await e.waitTimers(cl),e.done(Kr),()=>{e.remove(Q).remove(cl).clearTimer(Kr)})},"xm");Ot(ap,{displayName:"Commands"});function Sb(e){return e.Backspace=En(ak,Ns,_v,Mh),e}a(Sb,"H0");var cp=class{static{a(this,"wm")}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=>{let t=[];return Object.entries(e).forEach(([n,r])=>{if(typeof r=="function"){let i={key:n,onRun:a(()=>r,"onRun")};this.#e.push(i),t.push(()=>{this.#e=this.#e.filter(o=>o!==i)})}else this.#e.push(r),t.push(()=>{this.#e=this.#e.filter(i=>i!==r)})}),()=>{t.forEach(n=>n())}},this.addBaseKeymap=()=>{let e=Sb(sk);return this.addObjectKeymap(e)},this.build=()=>{let e={};return this.#e.forEach(t=>{e[t.key]=[...e[t.key]||[],t]}),Object.fromEntries(Object.entries(e).map(([t,n])=>{let r=n.sort((i,o)=>(o.priority??50)-(i.priority??50));return[t,(i,o,s)=>{let l=this.#t;if(l==null)throw Si();let c=r.map(u=>u.onRun(l));return En(...c)(i,o,s)}]}))}}#t;#e;get ctx(){return this.#t}},so=J(new cp,"keymap"),ul=J([Oe],"keymapTimer"),Jr=ct("KeymapReady"),Cb=a(e=>{let t=new cp;return t.setCtx(e),e.inject(so,t).inject(ul,[Oe]).record(Jr),async()=>(await e.waitTimers(ul),e.done(Jr),()=>{e.remove(so).remove(ul).clearTimer(Jr)})},"j0"),lo=ct("ParserReady"),up=a((()=>{throw Si()}),"Cm"),Ur=J(up,"parser"),hl=J([],"parserTimer"),hp=a(e=>(e.inject(Ur,up).inject(hl,[Oe]).record(lo),async()=>{await e.waitTimers(hl);let t=e.get(mn),n=e.get(it);return e.set(Ur,Rk.create(n,t)),e.done(lo),()=>{e.remove(Ur).remove(hl).clearTimer(lo)}}),"Sm");Ot(hp,{displayName:"Parser"});var ao=ct("SerializerReady"),dl=J([],"serializerTimer"),dp=a((()=>{throw Si()}),"Mm"),co=J(dp,"serializer"),pp=a(e=>(e.inject(co,dp).inject(dl,[Oe]).record(ao),async()=>{await e.waitTimers(dl);let t=e.get(mn),n=e.get(it);return e.set(co,Pk.create(n,t)),e.done(ao),()=>{e.remove(co).remove(dl).clearTimer(ao)}}),"Nm");Ot(pp,{displayName:"Serializer"});var uo=J("","defaultValue"),pl=J(e=>e,"stateOptions"),fl=J([],"editorStateTimer"),ho=ct("EditorStateReady");function Mb(e,t,n){if(typeof e=="string")return t(e);if(e.type==="html")return ps.fromSchema(n).parse(e.dom);if(e.type==="json")return kt.fromJSON(n,e.value);throw rg(e)}a(Mb,"K0");var Nb=new ve("MILKDOWN_STATE_TRACKER"),fp=a(e=>(e.inject(uo,"").inject($r,{}).inject(pl,t=>t).inject(fl,[lo,ao,Kr,Jr]).record(ho),async()=>{await e.waitTimers(fl);let t=e.get(it),n=e.get(Ur),r=e.get(Br),i=e.get(pl),o=e.get(fn),s=Mb(e.get(uo),n,t),l=e.get(so),c=l.addBaseKeymap(),u=[...o,new ye({key:Nb,state:{init:a(()=>{},"init"),apply:a((p,f,m,g)=>{e.set($r,g)},"apply")}}),gk({rules:r}),Ek(l.build())];e.set(fn,u);let h=i({schema:t,doc:s,plugins:u}),d=jv.create(h);return e.set($r,d),e.done(ho),()=>{c(),e.remove(uo).remove($r).remove(pl).remove(fl).clearTimer(ho)}}),"vm");Ot(fp,{displayName:"EditorState"});var Gr=J([],"pasteRule"),ml=J([Oe],"pasteRuleTimer"),po=ct("PasteRuleReady"),mp=a(e=>(e.inject(Gr,[]).inject(ml,[Oe]).record(po),async()=>(await e.waitTimers(ml),e.done(po),()=>{e.remove(Gr).remove(ml).clearTimer(po)})),"Tm");Ot(mp,{displayName:"PasteRule"});var gl=ct("EditorViewReady"),yl=J([],"editorViewTimer"),fo=J({},"editorViewOptions"),mo=J(null,"root"),vl=J(null,"rootDOM"),kl=J({},"rootAttrs");function Ob(e,t){let n=document.createElement("div");n.className="milkdown",e.appendChild(n),t.set(vl,n);let r=t.get(kl);return Object.entries(r).forEach(([i,o])=>n.setAttribute(i,o)),n}a(Ob,"q0");function Tb(e){e.classList.add("editor"),e.setAttribute("role","textbox")}a(Tb,"J0");var Ab=new ve("MILKDOWN_VIEW_CLEAR"),gp=a(e=>(e.inject(mo,document.body).inject(Qe,{}).inject(fo,{}).inject(vl,null).inject(kl,{}).inject(yl,[ho,po]).record(gl),async()=>{await e.wait($n);let t=e.get(mo)||document.body,n=typeof t=="string"?document.querySelector(t):t;e.update(fn,c=>[new ye({key:Ab,view:a(u=>{let h=n?Ob(n,e):void 0;return(()=>{if(h&&n){let d=u.dom;n.replaceChild(h,d),h.appendChild(d)}})(),{destroy:a(()=>{h?.parentNode&&h?.parentNode.replaceChild(u.dom,h),h?.remove()},"destroy")}},"view")}),...c]),await e.waitTimers(yl);let r=e.get($r),i=e.get(fo),o=Object.fromEntries(e.get(jr)),s=Object.fromEntries(e.get(_r)),l=new Yd(n,{state:r,nodeViews:o,markViews:s,transformPasted:a((c,u,h)=>(e.get(Gr).sort((d,p)=>(p.priority??50)-(d.priority??50)).map(d=>d.run).forEach(d=>{c=d(c,u,h)}),c),"transformPasted"),...i});return Tb(l.dom),e.set(Qe,l),e.done(gl),()=>{l?.destroy(),e.remove(mo).remove(Qe).remove(fo).remove(vl).remove(kl).remove(yl).clearTimer(gl)}}),"Im");Ot(gp,{displayName:"EditorView"});var Ib=class zm{static{a(this,"Em")}constructor(){this.#t=!1,this.#e="Idle",this.#r=[],this.#n=()=>{},this.#o=new vc,this.#s=new mg,this.#i=new Map,this.#l=new Map,this.#a=new fg(this.#o,this.#s),this.#d=()=>{let t=wb(async r=>{await Promise.all(this.#r.map(i=>Promise.resolve(i(r))))}),n=[sp,hp,pp,ap,Cb,mp,fp,gp,bb(this),t];this.#c(n,this.#l)},this.#c=(t,n)=>{t.forEach(r=>{let i=this.#a.produce(this.#t?r.meta:void 0),o=r(i);n.set(r,{ctx:i,handler:o,cleanup:void 0})})},this.#u=(t,n=!1)=>Promise.all([t].flat().map(async r=>{let i=this.#i.get(r)?.cleanup;return n?this.#i.delete(r):this.#i.set(r,{ctx:void 0,handler:void 0,cleanup:void 0}),typeof i=="function"?i():i})),this.#p=async()=>{await Promise.all([...this.#l.entries()].map(async([t,{cleanup:n}])=>typeof n=="function"?n():n)),this.#l.clear()},this.#h=t=>{this.#e=t,this.#n(t)},this.#f=t=>[...t.entries()].map(async([n,r])=>{let{ctx:i,handler:o}=r;if(!o)return;let s=await o();t.set(n,{ctx:i,handler:o,cleanup:s})}),this.enableInspector=(t=!0)=>(this.#t=t,this),this.onStatusChange=t=>(this.#n=t,this),this.config=t=>(this.#r.push(t),this),this.removeConfig=t=>(this.#r=this.#r.filter(n=>n!==t),this),this.use=t=>{let n=[t].flat();return n.flat().forEach(r=>{this.#i.set(r,{ctx:void 0,handler:void 0,cleanup:void 0})}),this.#e==="Created"&&this.#c(n,this.#i),this},this.remove=async t=>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(n=>{setTimeout(()=>{n(this.remove(t))},50)})):(await this.#u([t].flat(),!0),this),this.create=async()=>this.#e==="OnCreate"?this:(this.#e==="Created"&&await this.destroy(),this.#h("OnCreate"),this.#d(),this.#c([...this.#i.keys()],this.#i),await Promise.all([this.#f(this.#l),this.#f(this.#i)].flat()),this.#h("Created"),this),this.destroy=async(t=!1)=>this.#e==="Destroyed"||this.#e==="OnDestroy"?this:this.#e==="OnCreate"?new Promise(n=>{setTimeout(()=>{n(this.destroy(t))},50)}):(t&&(this.#r=[]),this.#h("OnDestroy"),await this.#u([...this.#i.keys()],t),await this.#p(),this.#h("Destroyed"),this),this.action=t=>t(this.#a),this.inspect=()=>this.#t?[...this.#l.values(),...this.#i.values()].map(({ctx:t})=>t?.inspector?.read()).filter(t=>!!t):(console.warn("[Milkdown]: You are trying to collect inspection when inspector is disabled, please enable inspector by `editor.enableInspector()` first."),[])}static make(){return new zm}#t;#e;#r;#n;#o;#s;#i;#l;#a;#d;#c;#u;#p;#h;#f;get ctx(){return this.#a}get status(){return this.#e}},Eb=a(e=>crypto.getRandomValues(new Uint8Array(e)),"G0"),Db=a((e,t,n)=>{let r=256-256%e.length;if(r===256){let i=e.length-1;return(o=t)=>{if(!o)return"";let s="";for(;;){let l=n(o),c=o|=0;for(;c--;)if(s+=e[l[c]&i],s.length>=o)return s}}}return(i=t)=>{if(!i)return"";let o="",s=Math.ceil(1.6*256*i/r);for(;;){let l=n(s),c=s;for(;c--;)if(l[c]<r&&(o+=e[l[c]%e.length],o.length>=i))return o}}},"Y0"),Rb=a((e,t=21)=>Db(e,t|0,Eb),"Om"),dN=Rb("abcedfghicklmn",10);function yp(e,t,n){let r=e.findIndex(([o])=>o===t);if(r===-1)return[...e,n];let i=e.slice();return i[r]=n,i}a(yp,"Rm");function V(e,t){let n=xb(e),r=a(i=>async()=>{r.key=n,await i.wait(Kr);let o=t(i);return i.get(Q).create(n,o),r.run=s=>i.get(Q).call(e,s),()=>{i.get(Q).remove(n)}},"r");return r}a(V,"_");function Re(e){let t=a(n=>async()=>{await n.wait(Oe);let r=e(n);return n.update(Br,i=>[...i,r]),t.inputRule=r,()=>{n.update(Br,i=>i.filter(o=>o!==r))}},"e");return t}a(Re,"Le");function zb(e){let t=a(n=>async()=>{await n.wait(Oe);let r=e(n);return n.update(Gr,i=>[...i,r]),t.pasteRule=r,()=>{n.update(Gr,i=>i.filter(o=>o!==r))}},"e");return t}a(zb,"Dm");function Pb(e,t){let n=a(r=>async()=>{let i=t(r);return r.update(qr,o=>yp(o,e,[e,i])),n.id=e,n.schema=i,()=>{r.update(qr,o=>o.filter(([s])=>s!==e))}},"n");return n.type=r=>{let i=r.get(it).marks[e];if(!i)throw ug(e);return i},n}a(Pb,"Q0");function Qr(e,t){let n=a(r=>async()=>{let i=t(r);return r.update(Wr,o=>yp(o,e,[e,i])),n.id=e,n.schema=i,()=>{r.update(Wr,o=>o.filter(([s])=>s!==e))}},"n");return n.type=r=>{let i=r.get(it).nodes[e];if(!i)throw cg(e);return i},n}a(Qr,"Xn");function Ye(e){let t,n=a(r=>async()=>(await r.wait(Oe),t=e(r),r.update(fn,i=>[...i,t]),()=>{r.update(fn,i=>i.filter(o=>o!==t))}),"n");return n.plugin=()=>t,n.key=()=>t.spec.key,n}a(Ye,"ze");function Fb(e){let t=a(n=>async()=>{await n.wait(Jr);let r=n.get(so),i=e(n),o=r.addObjectKeymap(i);return t.keymap=i,()=>{o()}},"e");return t}a(Fb,"X0");function Lb(e,t){let n=a(r=>async()=>{await r.wait(Oe);let i=t(r);return e.type(r)instanceof $i?r.update(jr,o=>[...o,[e.id,i]]):r.update(_r,o=>[...o,[e.id,i]]),n.view=i,n.type=e,()=>{e.type(r)instanceof $i?r.update(jr,o=>o.filter(s=>s[0]!==e.id)):r.update(_r,o=>o.filter(s=>s[0]!==e.id))}},"n");return n}a(Lb,"Pm");function dt(e,t){let n=J(e,t),r=a(i=>(i.inject(n),()=>()=>{i.remove(n)}),"r");return r.key=n,r}a(dt,"it");function ce(e,t){let n=dt(t,e),r=Qr(e,o=>o.get(n.key)(o)),i=[n,r];return i.id=r.id,i.node=r,i.type=o=>r.type(o),i.ctx=n,i.key=n.key,i.extendSchema=o=>ce(e,o(t)),i}a(ce,"ce");function Bn(e,t){let n=dt(t,e),r=Pb(e,o=>o.get(n.key)(o)),i=[n,r];return i.id=r.id,i.mark=r,i.type=o=>r.type(o),i.ctx=n,i.key=n.key,i.extendSchema=o=>Bn(e,o(t)),i}a(Bn,"cn");function ze(e,t){let n=dt(Object.fromEntries(Object.entries(t).map(([o,{shortcuts:s,priority:l}])=>[o,{shortcuts:s,priority:l}])),`${e}Keymap`),r=Fb(o=>{let s=o.get(n.key),l=Object.entries(t).flatMap(([c,{command:u}])=>{let h=s[c],d=[h.shortcuts].flat(),p=h.priority;return d.map(f=>[f,{key:f,onRun:u,priority:p}])});return Object.fromEntries(l)}),i=[n,r];return i.ctx=n,i.shortcuts=r,i.key=n.key,i.keymap=r.keymap,i}a(ze,"ve");var ot=a((e,t=()=>({}))=>dt(t,`${e}Attr`),"ot"),Yr=a((e,t=()=>({}))=>dt(t,`${e}Attr`),"Zn");function Wt(e,t,n){let r=dt(n??{},e),i=a(s=>async()=>{await s.wait($n);let l={plugin:t(s),options:s.get(r.key)};return s.update(Vr,c=>[...c,l]),()=>{s.update(Vr,c=>c.filter(u=>u!==l))}},"i"),o=[r,i];return o.id=e,o.plugin=i,o.options=r,o}a(Wt,"dt");function $b(e,t){return function(n,r){let{$from:i,$to:o,node:s}=n.selection;if(s&&s.isBlock||i.depth<2||!i.sameParent(o))return!1;let l=i.node(-1);if(l.type!=e)return!1;if(i.parent.content.size==0&&i.node(-1).childCount==i.indexAfter(-1)){if(i.depth==3||i.node(-3).type!=e||i.index(-2)!=i.node(-2).childCount-1)return!1;if(r){let d=O.empty,p=i.index(-1)?1:i.index(-2)?2:3;for(let y=i.depth-p;y>=i.depth-3;y--)d=O.from(i.node(y).copy(d));let f=i.indexAfter(-1)<i.node(-2).childCount?1:i.indexAfter(-2)<i.node(-3).childCount?2:3;d=d.append(O.from(e.createAndFill()));let m=i.before(i.depth-(p-1)),g=n.tr.replace(m,i.after(-f),new E(d,4-p,0)),v=-1;g.doc.nodesBetween(m,g.doc.content.size,(y,N)=>{if(v>-1)return!1;y.isTextblock&&y.content.size==0&&(v=N+1)}),v>-1&&g.setSelection(j.near(g.doc.resolve(v))),r(g.scrollIntoView())}return!0}let c=o.pos==i.end()?l.contentMatchAt(0).defaultType:null,u=n.tr.delete(i.pos,o.pos),h=c?[t?{type:e,attrs:t}:null,{type:c}]:void 0;return kr(u.doc,i.pos,2,h)?(r&&r(u.split(i.pos,2,h).scrollIntoView()),!0):!1}}a($b,"Lm");function Bb(e){return function(t,n){let{$from:r,$to:i}=t.selection,o=r.blockRange(i,s=>s.childCount>0&&s.firstChild.type==e);return o?n?r.node(o.depth-1).type==e?Vb(t,n,e,o):jb(t,n,o):!0:!1}}a(Bb,"zm");function Vb(e,t,n,r){let i=e.tr,o=r.end,s=r.$to.end(r.depth);o<s&&(i.step(new Ke(o-1,s,o,s,new E(O.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new Au(i.doc.resolve(r.$from.pos),i.doc.resolve(s),r.depth));let l=Ki(r);if(l==null)return!1;i.lift(r,l);let c=i.doc.resolve(i.mapping.map(o,-1)-1);return Ji(i.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&i.join(c.pos),t(i.scrollIntoView()),!0}a(Vb,"Z0");function jb(e,t,n){let r=e.tr,i=n.parent;for(let f=n.end,m=n.endIndex-1,g=n.startIndex;m>g;m--)f-=i.child(m).nodeSize,r.delete(f-1,f+1);let o=r.doc.resolve(n.start),s=o.nodeAfter;if(r.mapping.map(n.end)!=n.start+o.nodeAfter.nodeSize)return!1;let l=n.startIndex==0,c=n.endIndex==i.childCount,u=o.node(-1),h=o.index(-1);if(!u.canReplace(h+(l?0:1),h+1,s.content.append(c?O.empty:O.from(i))))return!1;let d=o.pos,p=d+s.nodeSize;return r.step(new Ke(d-(l?1:0),p+(c?1:0),d+1,p-1,new E((l?O.empty:O.from(i.copy(O.empty))).append(c?O.empty:O.from(i.copy(O.empty))),l?0:1,c?0:1),l?0:1)),t(r.scrollIntoView()),!0}a(jb,"eC");function _b(e){return function(t,n){let{$from:r,$to:i}=t.selection,o=r.blockRange(i,u=>u.childCount>0&&u.firstChild.type==e);if(!o)return!1;let s=o.startIndex;if(s==0)return!1;let l=o.parent,c=l.child(s-1);if(c.type!=e)return!1;if(n){let u=c.lastChild&&c.lastChild.type==l.type,h=O.from(u?e.create():null),d=new E(O.from(e.create(null,O.from(l.type.create(null,h)))),u?3:1,0),p=o.start,f=o.end;n(t.tr.step(new Ke(p-(u?3:1),f,p,f,d,1,!0)).scrollIntoView())}return!0}}a(_b,"Bm");function Hb(e){let t=new Map;if(!e||!e.type)throw new Error("mdast-util-definitions expected node");return On(e,"definition",function(r){let i=vp(r.identifier);i&&!t.get(i)&&t.set(i,r)}),n;function n(r){let i=vp(r);return t.get(i)}}a(Hb,"qa");function vp(e){return String(e||"").toUpperCase()}a(vp,"Fm");function Wb(){return function(e){let t=Hb(e);On(e,function(n,r,i){if(n.type==="definition"&&i!==void 0&&typeof r=="number")return i.children.splice(r,1),[Di,r];if(n.type==="imageReference"||n.type==="linkReference"){let o=t(n.identifier);if(o&&i&&typeof r=="number")return i.children[r]=n.type==="imageReference"?{type:"image",url:o.url,title:o.title,alt:n.alt}:{type:"link",url:o.url,title:o.title,children:n.children},[Di,r]}})}}a(Wb,"ks");function qb(e){let t={...e};return t.position&&(t.position={start:{...t.position.start},end:{...t.position.end}}),delete t.children,t}a(qb,"tC");var Kb="<br />",Jb=/^<br\s*\/?\s*>$/i,Ub=a(e=>typeof e=="string"&&Jb.test(e.trim()),"iC");function kp(e,t){if(!(t.childCount>=1&&t.lastChild?.type.name==="hardbreak")){e.next(t.content);return}let n=[];t.content.forEach((r,i,o)=>{o!==t.childCount-1&&n.push(r)}),e.next(O.fromArray(n))}a(kp,"$m");function S(e,t){return Object.assign(e,{meta:{package:"@milkdown/preset-commonmark",...t}}),e}a(S,"S");var wl=Yr("emphasis");S(wl,{displayName:"Attr<emphasis>",group:"Emphasis"});var Vn=Bn("emphasis",e=>({attrs:{marker:{default:e.get(Hr).emphasis||"*",validate:"string"}},parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style",getAttrs:a(t=>t==="italic","getAttrs")}],toDOM:a(t=>["em",e.get(wl.key)(t)],"toDOM"),parseMarkdown:{match:a(t=>t.type==="emphasis","match"),runner:a((t,n,r)=>{t.openMark(r,{marker:n.marker}),t.next(n.children),t.closeMark(r)},"runner")},toMarkdown:{match:a(t=>t.type.name==="emphasis","match"),runner:a((t,n)=>{t.withMark(n,"emphasis",void 0,{marker:n.attrs.marker})},"runner")}}));S(Vn.mark,{displayName:"MarkSchema<emphasis>",group:"Emphasis"}),S(Vn.ctx,{displayName:"MarkSchemaCtx<emphasis>",group:"Emphasis"});var bl=V("ToggleEmphasis",e=>()=>Yi(Vn.type(e)));S(bl,{displayName:"Command<toggleEmphasisCommand>",group:"Emphasis"});var wp=Re(e=>Cr(/(?:^|[^*])\*([^*]+)\*$/,Vn.type(e),{getAttr:a(()=>({marker:"*"}),"getAttr"),updateCaptured:a(({fullMatch:t,start:n})=>t.startsWith("*")?{}:{fullMatch:t.slice(1),start:n+1},"updateCaptured")}));S(wp,{displayName:"InputRule<emphasis>|Star",group:"Emphasis"});var bp=Re(e=>Cr(/\b_(?![_\s])(.*?[^_\s])_$/,Vn.type(e),{getAttr:a(()=>({marker:"_"}),"getAttr"),updateCaptured:a(({fullMatch:t,start:n})=>t.startsWith("_")?{}:{fullMatch:t.slice(1),start:n+1},"updateCaptured")}));S(bp,{displayName:"InputRule<emphasis>|Underscore",group:"Emphasis"});var xl=ze("emphasisKeymap",{ToggleEmphasis:{shortcuts:"Mod-i",command:a(e=>{let t=e.get(Q);return()=>t.call(bl.key)},"command")}});S(xl.ctx,{displayName:"KeymapCtx<emphasis>",group:"Emphasis"}),S(xl.shortcuts,{displayName:"Keymap<emphasis>",group:"Emphasis"});var Sl=Yr("strong");S(Sl,{displayName:"Attr<strong>",group:"Strong"});var Xr=Bn("strong",e=>({attrs:{marker:{default:e.get(Hr).strong||"*",validate:"string"}},parseDOM:[{tag:"b",getAttrs:a(t=>t.style.fontWeight!="normal"&&null,"getAttrs")},{tag:"strong"},{style:"font-style",getAttrs:a(t=>t==="bold","getAttrs")},{style:"font-weight=400",clearMark:a(t=>t.type.name=="strong","clearMark")},{style:"font-weight",getAttrs:a(t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null,"getAttrs")}],toDOM:a(t=>["strong",e.get(Sl.key)(t)],"toDOM"),parseMarkdown:{match:a(t=>t.type==="strong","match"),runner:a((t,n,r)=>{t.openMark(r,{marker:n.marker}),t.next(n.children),t.closeMark(r)},"runner")},toMarkdown:{match:a(t=>t.type.name==="strong","match"),runner:a((t,n)=>{t.withMark(n,"strong",void 0,{marker:n.attrs.marker})},"runner")}}));S(Xr.mark,{displayName:"MarkSchema<strong>",group:"Strong"}),S(Xr.ctx,{displayName:"MarkSchemaCtx<strong>",group:"Strong"});var Cl=V("ToggleStrong",e=>()=>Yi(Xr.type(e)));S(Cl,{displayName:"Command<toggleStrongCommand>",group:"Strong"});var xp=Re(e=>Cr(/(?<![\w:/])(?:\*\*|__)([^*_]+?)(?:\*\*|__)(?![\w/])$/,Xr.type(e),{getAttr:a(t=>({marker:t[0].startsWith("*")?"*":"_"}),"getAttr")}));S(xp,{displayName:"InputRule<strong>",group:"Strong"});var Ml=ze("strongKeymap",{ToggleBold:{shortcuts:["Mod-b"],command:a(e=>{let t=e.get(Q);return()=>t.call(Cl.key)},"command")}});S(Ml.ctx,{displayName:"KeymapCtx<strong>",group:"Strong"}),S(Ml.shortcuts,{displayName:"Keymap<strong>",group:"Strong"});var Nl=Yr("inlineCode");S(Nl,{displayName:"Attr<inlineCode>",group:"InlineCode"});var qt=Bn("inlineCode",e=>({priority:100,code:!0,inclusive:!1,parseDOM:[{tag:"code"}],toDOM:a(t=>["code",e.get(Nl.key)(t)],"toDOM"),parseMarkdown:{match:a(t=>t.type==="inlineCode","match"),runner:a((t,n,r)=>{t.openMark(r),t.addText(n.value),t.closeMark(r)},"runner")},toMarkdown:{match:a(t=>t.type.name==="inlineCode","match"),runner:a((t,n,r)=>(t.withMark(n,"inlineCode",r.text||""),!0),"runner")}}));S(qt.mark,{displayName:"MarkSchema<inlineCode>",group:"InlineCode"}),S(qt.ctx,{displayName:"MarkSchemaCtx<inlineCode>",group:"InlineCode"});var Ol=V("ToggleInlineCode",e=>()=>(t,n)=>{let{selection:r,tr:i}=t;if(r.empty)return!1;let{from:o,to:s}=r;return t.doc.rangeHasMark(o,s,qt.type(e))?(n?.(i.removeMark(o,s,qt.type(e))),!0):(Object.keys(t.schema.marks).filter(l=>l!==qt.type.name).map(l=>t.schema.marks[l]).forEach(l=>{i.removeMark(o,s,l)}),n?.(i.addMark(o,s,qt.type(e).create())),!0)});S(Ol,{displayName:"Command<toggleInlineCodeCommand>",group:"InlineCode"});var Sp=Re(e=>Cr(/(?:`)([^`]+)(?:`)$/,qt.type(e)));S(Sp,{displayName:"InputRule<inlineCodeInputRule>",group:"InlineCode"});var Tl=ze("inlineCodeKeymap",{ToggleInlineCode:{shortcuts:"Mod-e",command:a(e=>{let t=e.get(Q);return()=>t.call(Ol.key)},"command")}});S(Tl.ctx,{displayName:"KeymapCtx<inlineCode>",group:"InlineCode"}),S(Tl.shortcuts,{displayName:"Keymap<inlineCode>",group:"InlineCode"});var Gb=new Set(["http:","https:","mailto:","tel:","ftp:"]);function Qb(e){return e<=32||e>=127&&e<=160||e>=8203&&e<=8205||e===8232||e===8233||e===65279}a(Qb,"sC");function Yb(e){let t="";for(let n of e)Qb(n.codePointAt(0)??0)||(t+=n);return t}a(Yb,"lC");function Xb(e){if(typeof e!="string")return"";let t=e.trim();if(!t)return"";let n=Yb(t),r=/^([a-z][a-z0-9+.-]*):/i.exec(n)?.[1];return!r||Gb.has(`${r.toLowerCase()}:`)?t:""}a(Xb,"aC");var Al=Yr("link");S(Al,{displayName:"Attr<link>",group:"Link"});var jn=Bn("link",e=>({attrs:{href:{validate:"string"},title:{default:null,validate:"string|null"}},parseDOM:[{tag:"a[href]",getAttrs:a(t=>{if(!(t instanceof HTMLElement))throw at(t);return{href:t.getAttribute("href"),title:t.getAttribute("title")}},"getAttrs")}],toDOM:a(t=>["a",{...e.get(Al.key)(t),...t.attrs,href:Xb(t.attrs.href)}],"toDOM"),parseMarkdown:{match:a(t=>t.type==="link","match"),runner:a((t,n,r)=>{let i=n.url,o=n.title;t.openMark(r,{href:i,title:o}),t.next(n.children),t.closeMark(r)},"runner")},toMarkdown:{match:a(t=>t.type.name==="link","match"),runner:a((t,n)=>{t.withMark(n,"link",void 0,{title:n.attrs.title,url:n.attrs.href})},"runner")}}));S(jn.mark,{displayName:"MarkSchema<link>",group:"Link"});var Cp=V("ToggleLink",e=>(t={})=>Yi(jn.type(e),t));S(Cp,{displayName:"Command<toggleLinkCommand>",group:"Link"});var Mp=V("UpdateLink",e=>(t={})=>(n,r)=>{if(!r)return!1;let i,o=-1,{selection:s}=n,{from:l,to:c}=s;if(n.doc.nodesBetween(l,l===c?c+1:c,(m,g)=>{if(jn.type(e).isInSet(m.marks))return i=m,o=g,!1}),!i)return!1;let u=i.marks.find(({type:m})=>m===jn.type(e));if(!u)return!1;let h=o,d=o+i.nodeSize,{tr:p}=n,f=jn.type(e).create({...u.attrs,...t});return f?(r(p.removeMark(h,d,u).addMark(h,d,f).setSelection(new q(p.selection.$anchor)).scrollIntoView()),!0):!1});S(Mp,{displayName:"Command<updateLinkCommand>",group:"Link"});var Np=Qr("doc",()=>({content:"block+",parseMarkdown:{match:a(({type:e})=>e==="root","match"),runner:a((e,t,n)=>{e.injectRoot(t,n)},"runner")},toMarkdown:{match:a(e=>e.type.name==="doc","match"),runner:a((e,t)=>{e.openNode("root");let n=t.childCount>0?t.child(t.childCount-1):null,r=n?.type.name==="paragraph"&&n.content.size===0?t.content.cut(0,t.content.size-n.nodeSize):t.content;e.next(r)},"runner")}}));S(Np,{displayName:"NodeSchema<doc>",group:"Doc"});var Op=Object.freeze(["root","blockquote","listItem","footnoteDefinition"]),Zb=new Set(["paragraph","heading","tableCell","link","linkReference","emphasis","strong","delete","footnote"]),go=dt(Op,"blockContainerTypes");S(go,{displayName:"Ctx<blockContainerTypes>",group:"Remark"});var Tp=new Set;function Ap(e){let t=e.isInjected(go.key)?e.get(go.key):Op,n=new Set;for(let r of t){if(Zb.has(r)){Tp.has(r)||(Tp.add(r),console.warn(`[milkdown/preset-commonmark] "${r}" holds phrasing content and cannot be a block container; it is ignored in blockContainerTypes.`));continue}n.add(r)}return n}a(Ap,"Gm");var ex=new Set(["paragraph","tableCell"]);function tx(e,t){return Yo(e,n=>n.type==="html"&&Ub(n.value),(n,r)=>{let i=r[r.length-1];if(i){if(ex.has(i.type)){i.children.length===1&&(i.children=[]);return}if(t.has(i.type)){let o=n;return o.children=[],delete o.value,o.type="paragraph",Di}}})}a(tx,"fC");var yo=Wt("remark-preserve-empty-line",e=>()=>t=>tx(t,Ap(e)));S(yo.plugin,{displayName:"Remark<remarkPreserveEmptyLine>",group:"Remark"}),S(yo.options,{displayName:"RemarkConfig<remarkPreserveEmptyLine>",group:"Remark"});var Il=ot("paragraph");S(Il,{displayName:"Attr<paragraph>",group:"Paragraph"});var pt=ce("paragraph",e=>({content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM:a(t=>["p",e.get(Il.key)(t),0],"toDOM"),parseMarkdown:{match:a(t=>t.type==="paragraph","match"),runner:a((t,n,r)=>{t.openNode(r),n.children?t.next(n.children):t.addText(n.value||""),t.closeNode()},"runner")},toMarkdown:{match:a(t=>t.type.name==="paragraph","match"),runner:a((t,n)=>{t.openNode("paragraph"),(!n.content||n.content.size===0)&&nx(e)?t.addNode("html",void 0,Kb):kp(t,n),t.closeNode()},"runner")}}));function nx(e){return e.isInjected(yo.options.key)}a(nx,"hC"),S(pt.node,{displayName:"NodeSchema<paragraph>",group:"Paragraph"}),S(pt.ctx,{displayName:"NodeSchemaCtx<paragraph>",group:"Paragraph"});var El=V("TurnIntoText",e=>()=>Sr(pt.type(e)));S(El,{displayName:"Command<turnIntoTextCommand>",group:"Paragraph"});var Dl=ze("paragraphKeymap",{TurnIntoText:{shortcuts:"Mod-Alt-0",command:a(e=>{let t=e.get(Q);return()=>t.call(El.key)},"command")}});S(Dl.ctx,{displayName:"KeymapCtx<paragraph>",group:"Paragraph"}),S(Dl.shortcuts,{displayName:"Keymap<paragraph>",group:"Paragraph"});var rx=Array(6).fill(0).map((e,t)=>t+1);function ix(e){return e.textContent.toLowerCase().trim().replace(/\s+/g,"-")}a(ix,"pC");var vo=dt(ix,"headingIdGenerator");S(vo,{displayName:"Ctx<HeadingIdGenerator>",group:"Heading"});var Rl=ot("heading");S(Rl,{displayName:"Attr<heading>",group:"Heading"});var gn=ce("heading",e=>{let t=e.get(vo.key);return{content:"inline*",group:"block",defining:!0,attrs:{id:{default:"",validate:"string"},level:{default:1,validate:"number"}},parseDOM:rx.map(n=>({tag:`h${n}`,getAttrs:a(r=>{if(!(r instanceof HTMLElement))throw at(r);return{level:n,id:r.id}},"getAttrs")})),toDOM:a(n=>[`h${n.attrs.level}`,{...e.get(Rl.key)(n),id:n.attrs.id||t(n)},0],"toDOM"),parseMarkdown:{match:a(({type:n})=>n==="heading","match"),runner:a((n,r,i)=>{let o=r.depth;n.openNode(i,{level:o}),n.next(r.children),n.closeNode()},"runner")},toMarkdown:{match:a(n=>n.type.name==="heading","match"),runner:a((n,r)=>{n.openNode("heading",void 0,{depth:r.attrs.level}),kp(n,r),n.closeNode()},"runner")}}});S(gn.node,{displayName:"NodeSchema<heading>",group:"Heading"}),S(gn.ctx,{displayName:"NodeSchemaCtx<heading>",group:"Heading"});var Ip=Re(e=>Eh(/^(?<hashes>#+)\s$/,gn.type(e),t=>{let n=t.groups?.hashes?.length||0,{$from:r}=e.get(Qe).state.selection,i=r.node();if(i.type.name==="heading"){let o=Number(i.attrs.level)+Number(n);return o>6&&(o=6),{level:o}}return{level:n}}));S(Ip,{displayName:"InputRule<wrapInHeadingInputRule>",group:"Heading"});var Kt=V("WrapInHeading",e=>t=>(t??=1,t<1?Sr(pt.type(e)):Sr(gn.type(e),{level:t})));S(Kt,{displayName:"Command<wrapInHeadingCommand>",group:"Heading"});var zl=V("DowngradeHeading",e=>()=>(t,n,r)=>{let{$from:i}=t.selection,o=i.node();if(o.type!==gn.type(e)||!t.selection.empty||i.parentOffset!==0)return!1;let s=o.attrs.level-1;return s?(n?.(t.tr.setNodeMarkup(t.selection.$from.before(),void 0,{...o.attrs,level:s})),!0):Sr(pt.type(e))(t,n,r)});S(zl,{displayName:"Command<downgradeHeadingCommand>",group:"Heading"});var Pl=ze("headingKeymap",{TurnIntoH1:{shortcuts:"Mod-Alt-1",command:a(e=>{let t=e.get(Q);return()=>t.call(Kt.key,1)},"command")},TurnIntoH2:{shortcuts:"Mod-Alt-2",command:a(e=>{let t=e.get(Q);return()=>t.call(Kt.key,2)},"command")},TurnIntoH3:{shortcuts:"Mod-Alt-3",command:a(e=>{let t=e.get(Q);return()=>t.call(Kt.key,3)},"command")},TurnIntoH4:{shortcuts:"Mod-Alt-4",command:a(e=>{let t=e.get(Q);return()=>t.call(Kt.key,4)},"command")},TurnIntoH5:{shortcuts:"Mod-Alt-5",command:a(e=>{let t=e.get(Q);return()=>t.call(Kt.key,5)},"command")},TurnIntoH6:{shortcuts:"Mod-Alt-6",command:a(e=>{let t=e.get(Q);return()=>t.call(Kt.key,6)},"command")},DowngradeHeading:{shortcuts:["Delete","Backspace"],command:a(e=>{let t=e.get(Q);return()=>t.call(zl.key)},"command")}});S(Pl.ctx,{displayName:"KeymapCtx<heading>",group:"Heading"}),S(Pl.shortcuts,{displayName:"Keymap<heading>",group:"Heading"});var Fl=ot("blockquote");S(Fl,{displayName:"Attr<blockquote>",group:"Blockquote"});var Zr=ce("blockquote",e=>({content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM:a(t=>["blockquote",e.get(Fl.key)(t),0],"toDOM"),parseMarkdown:{match:a(({type:t})=>t==="blockquote","match"),runner:a((t,n,r)=>{t.openNode(r).next(n.children).closeNode()},"runner")},toMarkdown:{match:a(t=>t.type.name==="blockquote","match"),runner:a((t,n)=>{t.openNode("blockquote").next(n.content).closeNode()},"runner")}}));S(Zr.node,{displayName:"NodeSchema<blockquote>",group:"Blockquote"}),S(Zr.ctx,{displayName:"NodeSchemaCtx<blockquote>",group:"Blockquote"});var Ep=Re(e=>Es(/^\s*>\s$/,Zr.type(e)));S(Ep,{displayName:"InputRule<wrapInBlockquoteInputRule>",group:"Blockquote"});var Ll=V("WrapInBlockquote",e=>()=>As(Zr.type(e)));S(Ll,{displayName:"Command<wrapInBlockquoteCommand>",group:"Blockquote"});var $l=ze("blockquoteKeymap",{WrapInBlockquote:{shortcuts:"Mod-Shift-b",command:a(e=>{let t=e.get(Q);return()=>t.call(Ll.key)},"command")}});S($l.ctx,{displayName:"KeymapCtx<blockquote>",group:"Blockquote"}),S($l.shortcuts,{displayName:"Keymap<blockquote>",group:"Blockquote"});var Bl=ot("codeBlock",()=>({pre:{},code:{}}));S(Bl,{displayName:"Attr<codeBlock>",group:"CodeBlock"});var _n=ce("code_block",e=>({content:"text*",group:"block",marks:"",defining:!0,code:!0,attrs:{language:{default:"",validate:"string"}},parseDOM:[{tag:"pre",preserveWhitespace:"full",getAttrs:a(t=>{if(!(t instanceof HTMLElement))throw at(t);return{language:t.dataset.language}},"getAttrs")}],toDOM:a(t=>{let n=e.get(Bl.key)(t),r=t.attrs.language,i=r&&r.length>0?{"data-language":r}:void 0;return["pre",{...n.pre,...i},["code",n.code,0]]},"toDOM"),parseMarkdown:{match:a(({type:t})=>t==="code","match"),runner:a((t,n,r)=>{let i=n.lang??"",o=n.value;t.openNode(r,{language:i}),o&&t.addText(o),t.closeNode()},"runner")},toMarkdown:{match:a(t=>t.type.name==="code_block","match"),runner:a((t,n)=>{t.addNode("code",void 0,n.content.firstChild?.text||"",{lang:n.attrs.language})},"runner")}}));S(_n.node,{displayName:"NodeSchema<codeBlock>",group:"CodeBlock"}),S(_n.ctx,{displayName:"NodeSchemaCtx<codeBlock>",group:"CodeBlock"});var Dp=Re(e=>Eh(/^```(?<language>[a-z]*)?[\s\n]$/,_n.type(e),t=>({language:t.groups?.language??""})));S(Dp,{displayName:"InputRule<createCodeBlockInputRule>",group:"CodeBlock"});var Vl=V("CreateCodeBlock",e=>(t="")=>Sr(_n.type(e),{language:t}));S(Vl,{displayName:"Command<createCodeBlockCommand>",group:"CodeBlock"});var ox=V("UpdateCodeBlockLanguage",()=>({pos:e,language:t}={pos:-1,language:""})=>(n,r)=>e>=0?(r?.(n.tr.setNodeAttribute(e,"language",t)),!0):!1);S(ox,{displayName:"Command<updateCodeBlockLanguageCommand>",group:"CodeBlock"});var jl=ze("codeBlockKeymap",{CreateCodeBlock:{shortcuts:"Mod-Alt-c",command:a(e=>{let t=e.get(Q);return()=>t.call(Vl.key)},"command")}});S(jl.ctx,{displayName:"KeymapCtx<codeBlock>",group:"CodeBlock"}),S(jl.shortcuts,{displayName:"Keymap<codeBlock>",group:"CodeBlock"});var _l=ot("image");S(_l,{displayName:"Attr<image>",group:"Image"});var Hn=ce("image",e=>({inline:!0,group:"inline",selectable:!0,draggable:!0,marks:"",atom:!0,defining:!0,isolating:!0,attrs:{src:{default:"",validate:"string"},alt:{default:"",validate:"string"},title:{default:"",validate:"string"}},parseDOM:[{tag:"img[src]",getAttrs:a(t=>{if(!(t instanceof HTMLElement))throw at(t);return{src:t.getAttribute("src")||"",alt:t.getAttribute("alt")||"",title:t.getAttribute("title")||t.getAttribute("alt")||""}},"getAttrs")}],toDOM:a(t=>["img",{...e.get(_l.key)(t),...t.attrs}],"toDOM"),parseMarkdown:{match:a(({type:t})=>t==="image","match"),runner:a((t,n,r)=>{let i=n.url,o=n.alt??"",s=n.title??"";t.addNode(r,{src:i,alt:o,title:s})},"runner")},toMarkdown:{match:a(t=>t.type.name==="image","match"),runner:a((t,n)=>{t.addNode("image",void 0,void 0,{title:n.attrs.title,url:n.attrs.src,alt:n.attrs.alt})},"runner")}}));S(Hn.node,{displayName:"NodeSchema<image>",group:"Image"}),S(Hn.ctx,{displayName:"NodeSchemaCtx<image>",group:"Image"});var Rp=V("InsertImage",e=>(t={})=>(n,r)=>{if(!r)return!0;let{src:i="",alt:o="",title:s=""}=t,l=Hn.type(e).create({src:i,alt:o,title:s});return l&&r(n.tr.replaceSelectionWith(l).scrollIntoView()),!0});S(Rp,{displayName:"Command<insertImageCommand>",group:"Image"});var zp=V("UpdateImage",e=>(t={})=>(n,r)=>{let i=xk(n.selection,Hn.type(e));if(!i)return!1;let{node:o,pos:s}=i,l={...o.attrs},{src:c,alt:u,title:h}=t;return c!==void 0&&(l.src=c),u!==void 0&&(l.alt=u),h!==void 0&&(l.title=h),r?.(n.tr.setNodeMarkup(s,void 0,l).scrollIntoView()),!0});S(zp,{displayName:"Command<updateImageCommand>",group:"Image"});var sx=Re(e=>new $e(/!\[(?<alt>.*?)]\((?<filename>.*?)\s*(?="|\))"?(?<title>[^"]+)?"?\)/,(t,n,r,i)=>{let[o,s,l="",c]=n;return o?t.tr.replaceWith(r,i,Hn.type(e).create({src:l,alt:s,title:c})):null}));S(sx,{displayName:"InputRule<insertImageInputRule>",group:"Image"});var ko=ot("hardbreak",e=>({"data-type":"hardbreak","data-is-inline":e.attrs.isInline}));S(ko,{displayName:"Attr<hardbreak>",group:"Hardbreak"});var yn=ce("hardbreak",e=>({inline:!0,group:"inline",attrs:{isInline:{default:!1,validate:"boolean"}},selectable:!1,parseDOM:[{tag:"br"},{tag:'span[data-type="hardbreak"]',getAttrs:a(()=>({isInline:!0}),"getAttrs")}],toDOM:a(t=>t.attrs.isInline?["span",e.get(ko.key)(t)," "]:["br",e.get(ko.key)(t)],"toDOM"),parseMarkdown:{match:a(({type:t})=>t==="break","match"),runner:a((t,n,r)=>{t.addNode(r,{isInline:!!n.data?.isInline})},"runner")},leafText:a(()=>`
45
+ `,"leafText"),toMarkdown:{match:a(t=>t.type.name==="hardbreak","match"),runner:a((t,n)=>{n.attrs.isInline?t.addNode("text",void 0,`
46
+ `):t.addNode("break")},"runner")}}));S(yn.node,{displayName:"NodeSchema<hardbreak>",group:"Hardbreak"}),S(yn.ctx,{displayName:"NodeSchemaCtx<hardbreak>",group:"Hardbreak"});var Hl=V("InsertHardbreak",e=>()=>(t,n)=>{let{selection:r,tr:i}=t;if(!(r instanceof q))return!1;if(r.empty){let o=r.$from.node();if(o.childCount>0&&o.lastChild?.type.name==="hardbreak")return n?.(i.replaceRangeWith(r.to-1,r.to,t.schema.node("paragraph")).setSelection(j.near(i.doc.resolve(r.to))).scrollIntoView()),!0}return n?.(i.setMeta("hardbreak",!0).replaceSelectionWith(yn.type(e).create()).scrollIntoView()),!0});S(Hl,{displayName:"Command<insertHardbreakCommand>",group:"Hardbreak"});var Wl=ze("hardbreakKeymap",{InsertHardbreak:{shortcuts:"Shift-Enter",command:a(e=>{let t=e.get(Q);return()=>t.call(Hl.key)},"command")}});S(Wl.ctx,{displayName:"KeymapCtx<hardbreak>",group:"Hardbreak"}),S(Wl.shortcuts,{displayName:"Keymap<hardbreak>",group:"Hardbreak"});var ql=ot("hr");S(ql,{displayName:"Attr<hr>",group:"Hr"});var ei=ce("hr",e=>({group:"block",parseDOM:[{tag:"hr"}],toDOM:a(t=>["hr",e.get(ql.key)(t)],"toDOM"),parseMarkdown:{match:a(({type:t})=>t==="thematicBreak","match"),runner:a((t,n,r)=>{t.addNode(r)},"runner")},toMarkdown:{match:a(t=>t.type.name==="hr","match"),runner:a(t=>{t.addNode("thematicBreak")},"runner")}}));S(ei.node,{displayName:"NodeSchema<hr>",group:"Hr"}),S(ei.ctx,{displayName:"NodeSchemaCtx<hr>",group:"Hr"});var Pp=Re(e=>new $e(/^(?:---|___\s|\*\*\*\s)$/,(t,n,r,i)=>{let{tr:o}=t;return n[0]&&o.replaceWith(r-1,i,ei.type(e).create()),o}));S(Pp,{displayName:"InputRule<insertHrInputRule>",group:"Hr"});var Fp=V("InsertHr",e=>()=>(t,n)=>{if(!n)return!0;let r=pt.node.type(e).create(),{tr:i,selection:o}=t,{from:s}=o,l=ei.type(e).create();if(!l)return!0;let c=i.replaceSelectionWith(l).insert(s,r),u=j.findFrom(c.doc.resolve(s),1,!0);return u&&n(c.setSelection(u).scrollIntoView()),!0});S(Fp,{displayName:"Command<insertHrCommand>",group:"Hr"});var Kl=ot("bulletList");S(Kl,{displayName:"Attr<bulletList>",group:"BulletList"});var Wn=ce("bullet_list",e=>({content:"listItem+",group:"block",attrs:{spread:{default:!1,validate:"boolean"}},parseDOM:[{tag:"ul",getAttrs:a(t=>{if(!(t instanceof HTMLElement))throw at(t);return{spread:t.dataset.spread==="true"}},"getAttrs")}],toDOM:a(t=>["ul",{...e.get(Kl.key)(t),"data-spread":t.attrs.spread},0],"toDOM"),parseMarkdown:{match:a(({type:t,ordered:n})=>t==="list"&&!n,"match"),runner:a((t,n,r)=>{let i=n.spread??!1;t.openNode(r,{spread:i}).next(n.children).closeNode()},"runner")},toMarkdown:{match:a(t=>t.type.name==="bullet_list","match"),runner:a((t,n)=>{t.openNode("list",void 0,{ordered:!1,spread:n.attrs.spread}).next(n.content).closeNode()},"runner")}}));S(Wn.node,{displayName:"NodeSchema<bulletList>",group:"BulletList"}),S(Wn.ctx,{displayName:"NodeSchemaCtx<bulletList>",group:"BulletList"});var Lp=Re(e=>Es(/^\s*([-+*])\s$/,Wn.type(e)));S(Lp,{displayName:"InputRule<wrapInBulletListInputRule>",group:"BulletList"});var Jl=V("WrapInBulletList",e=>()=>As(Wn.type(e)));S(Jl,{displayName:"Command<wrapInBulletListCommand>",group:"BulletList"});var Ul=ze("bulletListKeymap",{WrapInBulletList:{shortcuts:"Mod-Alt-8",command:a(e=>{let t=e.get(Q);return()=>t.call(Jl.key)},"command")}});S(Ul.ctx,{displayName:"KeymapCtx<bulletListKeymap>",group:"BulletList"}),S(Ul.shortcuts,{displayName:"Keymap<bulletListKeymap>",group:"BulletList"});var Gl=ot("orderedList");S(Gl,{displayName:"Attr<orderedList>",group:"OrderedList"});var qn=ce("ordered_list",e=>({content:"listItem+",group:"block",attrs:{order:{default:1,validate:"number"},spread:{default:!1,validate:"boolean"}},parseDOM:[{tag:"ol",getAttrs:a(t=>{if(!(t instanceof HTMLElement))throw at(t);return{spread:t.dataset.spread==="true",order:t.hasAttribute("start")?Number(t.getAttribute("start")):1}},"getAttrs")}],toDOM:a(t=>["ol",{...e.get(Gl.key)(t),...t.attrs.order===1?{}:{start:t.attrs.order},"data-spread":t.attrs.spread},0],"toDOM"),parseMarkdown:{match:a(({type:t,ordered:n})=>t==="list"&&!!n,"match"),runner:a((t,n,r)=>{let i=n.spread??!0;t.openNode(r,{spread:i,order:n.start??1}).next(n.children).closeNode()},"runner")},toMarkdown:{match:a(t=>t.type.name==="ordered_list","match"),runner:a((t,n)=>{t.openNode("list",void 0,{ordered:!0,start:n.attrs.order??1,spread:n.attrs.spread}),t.next(n.content),t.closeNode()},"runner")}}));S(qn.node,{displayName:"NodeSchema<orderedList>",group:"OrderedList"}),S(qn.ctx,{displayName:"NodeSchemaCtx<orderedList>",group:"OrderedList"});var $p=Re(e=>Es(/^\s*(\d+)\.\s$/,qn.type(e),t=>({order:Number(t[1])}),(t,n)=>n.childCount+n.attrs.order===Number(t[1])));S($p,{displayName:"InputRule<wrapInOrderedListInputRule>",group:"OrderedList"});var Ql=V("WrapInOrderedList",e=>()=>As(qn.type(e)));S(Ql,{displayName:"Command<wrapInOrderedListCommand>",group:"OrderedList"});var Yl=ze("orderedListKeymap",{WrapInOrderedList:{shortcuts:"Mod-Alt-7",command:a(e=>{let t=e.get(Q);return()=>t.call(Ql.key)},"command")}});S(Yl.ctx,{displayName:"KeymapCtx<orderedList>",group:"OrderedList"}),S(Yl.shortcuts,{displayName:"Keymap<orderedList>",group:"OrderedList"});var Xl=ot("listItem");S(Xl,{displayName:"Attr<listItem>",group:"ListItem"});var Tt=ce("list_item",e=>({group:"listItem",content:"paragraph block*",attrs:{label:{default:"\u2022",validate:"string"},listType:{default:"bullet",validate:"string"},spread:{default:!0,validate:"boolean"}},defining:!0,parseDOM:[{tag:"li",getAttrs:a(t=>{if(!(t instanceof HTMLElement))throw at(t);return{label:t.dataset.label,listType:t.dataset.listType,spread:t.dataset.spread==="true"}},"getAttrs")}],toDOM:a(t=>["li",{...e.get(Xl.key)(t),"data-label":t.attrs.label,"data-list-type":t.attrs.listType,"data-spread":t.attrs.spread},0],"toDOM"),parseMarkdown:{match:a(({type:t})=>t==="listItem","match"),runner:a((t,n,r)=>{let i=n.label!=null?`${n.label}.`:"\u2022",o=n.label!=null?"ordered":"bullet",s=n.spread??!0;t.openNode(r,{label:i,listType:o,spread:s}),t.next(n.children),t.closeNode()},"runner")},toMarkdown:{match:a(t=>t.type.name==="list_item","match"),runner:a((t,n)=>{t.openNode("listItem",void 0,{spread:n.attrs.spread}),t.next(n.content),t.closeNode()},"runner")}}));S(Tt.node,{displayName:"NodeSchema<listItem>",group:"ListItem"}),S(Tt.ctx,{displayName:"NodeSchemaCtx<listItem>",group:"ListItem"});var Zl=V("SinkListItem",e=>()=>_b(Tt.type(e)));S(Zl,{displayName:"Command<sinkListItemCommand>",group:"ListItem"});var ea=V("LiftListItem",e=>()=>Bb(Tt.type(e)));S(ea,{displayName:"Command<liftListItemCommand>",group:"ListItem"});var ta=V("SplitListItem",e=>()=>$b(Tt.type(e)));S(ta,{displayName:"Command<splitListItemCommand>",group:"ListItem"});function lx(e){return(t,n,r)=>{let{selection:i}=t;if(!(i instanceof q))return!1;let{empty:o,$from:s}=i;return!o||s.parentOffset!==0||s.node(-1).type!==Tt.type(e)?!1:Ch(t,n,r)}}a(lx,"yC");var na=V("LiftFirstListItem",e=>()=>lx(e));S(na,{displayName:"Command<liftFirstListItemCommand>",group:"ListItem"});var ra=ze("listItemKeymap",{NextListItem:{shortcuts:"Enter",command:a(e=>{let t=e.get(Q);return()=>t.call(ta.key)},"command")},SinkListItem:{shortcuts:["Tab","Mod-]"],command:a(e=>{let t=e.get(Q);return()=>t.call(Zl.key)},"command")},LiftListItem:{shortcuts:["Shift-Tab","Mod-["],command:a(e=>{let t=e.get(Q);return()=>t.call(ea.key)},"command")},LiftFirstListItem:{shortcuts:["Backspace","Delete"],command:a(e=>{let t=e.get(Q);return()=>t.call(na.key)},"command")}});S(ra.ctx,{displayName:"KeymapCtx<listItem>",group:"ListItem"}),S(ra.shortcuts,{displayName:"Keymap<listItem>",group:"ListItem"});var Bp=Qr("text",()=>({group:"inline",parseMarkdown:{match:a(({type:e})=>e==="text","match"),runner:a((e,t)=>{e.addText(t.value)},"runner")},toMarkdown:{match:a(e=>e.type.name==="text","match"),runner:a((e,t)=>{e.addNode("text",void 0,t.text)},"runner")}}));S(Bp,{displayName:"NodeSchema<text>",group:"Text"});var ia=ot("html");S(ia,{displayName:"Attr<html>",group:"Html"});var oa=ce("html",e=>({atom:!0,group:"inline",inline:!0,attrs:{value:{default:"",validate:"string"}},toDOM:a(t=>{let n=document.createElement("span"),r={...e.get(ia.key)(t),"data-value":t.attrs.value,"data-type":"html"};return n.textContent=t.attrs.value,["span",r,t.attrs.value]},"toDOM"),parseDOM:[{tag:'span[data-type="html"]',getAttrs:a(t=>({value:t.dataset.value??""}),"getAttrs")}],parseMarkdown:{match:a(({type:t})=>t==="html","match"),runner:a((t,n,r)=>{t.addNode(r,{value:n.value})},"runner")},toMarkdown:{match:a(t=>t.type.name==="html","match"),runner:a((t,n)=>{t.addNode("html",void 0,n.attrs.value)},"runner")}}));S(oa.node,{displayName:"NodeSchema<html>",group:"Html"}),S(oa.ctx,{displayName:"NodeSchemaCtx<html>",group:"Html"});var ax=[Np,Il,pt,vo,Rl,gn,ko,yn,Fl,Zr,Bl,_n,ql,ei,_l,Hn,Kl,Wn,Gl,qn,Xl,Tt,wl,Vn,Sl,Xr,Nl,qt,Al,jn,ia,oa,Bp].flat(),cx=[Ep,Lp,$p,Dp,Pp,Ip].flat(),ux=[wp,bp,Sp,xp],hx=V("IsMarkSelected",()=>e=>t=>{if(!e)return!1;let{doc:n,selection:r}=t;return n.rangeHasMark(r.from,r.to,e)}),dx=V("IsNoteSelected",()=>e=>t=>e?Sk(t,e).hasNode:!1),px=V("ClearTextInCurrentBlock",()=>()=>(e,t)=>{let n=e.tr,{$from:r,$to:i}=n.selection,{pos:o}=r,{pos:s}=i,l=o-r.node().content.size;return l<0?!1:(n=n.deleteRange(l,s),t?.(n),!0)}),fx=V("SetBlockType",()=>e=>(t,n)=>{let{nodeType:r,attrs:i=null}=e??{};if(!r)return!1;let o=t.tr,{from:s,to:l}=o.selection;try{o.setBlockType(s,l,r,i)}catch{return!1}return n?.(o),!0}),mx=V("WrapInBlockType",()=>e=>(t,n)=>{let{nodeType:r,attrs:i=null}=e??{};if(!r)return!1;let o=t.tr;try{let{$from:s,$to:l}=o.selection,c=s.blockRange(l),u=c&&bs(c,r,i);if(!u)return!1;o=o.wrap(c,u)}catch{return!1}return n?.(o),!0}),gx=V("AddBlockType",()=>e=>(t,n)=>{let{nodeType:r,attrs:i=null}=e??{};if(!r)return!1;let o=t.tr;try{let s=r instanceof kt?r:r.createAndFill(i);if(!s)return!1;o.replaceSelectionWith(s)}catch{return!1}return n?.(o),!0}),yx=V("SelectTextNearPos",()=>e=>(t,n)=>{let{pos:r}=e??{};if(r==null)return!1;let i=a((s,l,c)=>Math.min(Math.max(s,l),c),"i"),o=t.tr;try{let s=t.doc.resolve(i(r,0,t.doc.content.size));o.setSelection(q.near(s))}catch{return!1}return n?.(o.scrollIntoView()),!0}),vx=[El,Ll,Kt,zl,Vl,Hl,Fp,Rp,zp,Ql,Jl,Zl,ta,ea,na,bl,Ol,Cl,Cp,Mp,hx,dx,px,fx,mx,gx,yx],kx=[$l,jl,Wl,Pl,ra,Yl,Ul,Dl,xl,Tl,Ml].flat(),sa=Wt("remarkAddOrderInList",()=>()=>e=>{On(e,"list",t=>{if(t.ordered){let n=t.start??1;t.children.forEach((r,i)=>{r.label=i+n})}})});S(sa.plugin,{displayName:"Remark<remarkAddOrderInListPlugin>",group:"Remark"}),S(sa.options,{displayName:"RemarkConfig<remarkAddOrderInListPlugin>",group:"Remark"});var la=Wt("remarkLineBreak",()=>()=>e=>{let t=/[\t ]*(?:\r?\n|\r)/g;On(e,"text",(n,r,i)=>{if(!n.value||typeof n.value!="string")return;let o=[],s=0;t.lastIndex=0;let l=t.exec(n.value);for(;l;){let c=l.index;s!==c&&o.push({type:"text",value:n.value.slice(s,c)}),o.push({type:"break",data:{isInline:!0}}),s=c+l[0].length,l=t.exec(n.value)}if(o.length>0&&i&&typeof r=="number")return s<n.value.length&&o.push({type:"text",value:n.value.slice(s)}),i.children.splice(r,1,...o),r+o.length})});S(la.plugin,{displayName:"Remark<remarkLineBreak>",group:"Remark"}),S(la.options,{displayName:"RemarkConfig<remarkLineBreak>",group:"Remark"});var aa=Wt("remarkInlineLink",()=>Wb);S(aa.plugin,{displayName:"Remark<remarkInlineLinkPlugin>",group:"Remark"}),S(aa.options,{displayName:"RemarkConfig<remarkInlineLinkPlugin>",group:"Remark"});var wx=a(e=>!!e.children,"EC"),bx=a(e=>e.type==="html","OC");function xx(e,t){return n(e,0,null)[0];function n(r,i,o){if(wx(r)){let s=[];for(let l=0,c=r.children.length;l<c;l++){let u=r.children[l];if(u){let h=n(u,l,r);if(h)for(let d=0,p=h.length;d<p;d++){let f=h[d];f&&s.push(f)}}}r.children=s}return t(r,i,o)}}a(xx,"RC");var ca=Wt("remarkHTMLTransformer",e=>()=>t=>{let n=Ap(e);xx(t,(r,i,o)=>bx(r)?(o&&n.has(o.type)&&(r.children=[qb(r)],delete r.value,r.type="paragraph"),[r]):[r])});S(ca.plugin,{displayName:"Remark<remarkHtmlTransformer>",group:"Remark"}),S(ca.options,{displayName:"RemarkConfig<remarkHtmlTransformer>",group:"Remark"});var ua=Wt("remarkMarker",()=>()=>(e,t)=>{let n=a(r=>t.value.charAt(r.position.start.offset),"n");On(e,r=>["strong","emphasis"].includes(r.type),r=>{r.marker=n(r)})});S(ua.plugin,{displayName:"Remark<remarkMarker>",group:"Remark"}),S(ua.options,{displayName:"RemarkConfig<remarkMarker>",group:"Remark"});var Vp=Ye(()=>{let e=!1,t=new ve("MILKDOWN_INLINE_NODES_CURSOR"),n=new ye({key:t,state:{init(){return!1},apply(r){if(!r.selection.empty)return!1;let i=r.selection.$from,o=i.nodeBefore,s=i.nodeAfter;return!!(o&&s&&o.isInline&&!o.isText&&s.isInline&&!s.isText)}},props:{handleDOMEvents:{compositionend:a((r,i)=>e?(e=!1,requestAnimationFrame(()=>{if(n.getState(r.state)){let o=r.state.selection.from;i.preventDefault(),r.dispatch(r.state.tr.insertText(i.data||"",o))}}),!0):!1,"compositionend"),compositionstart:a(r=>(n.getState(r.state)&&(e=!0),!1),"compositionstart"),beforeinput:a((r,i)=>{if(n.getState(r.state)&&i instanceof InputEvent&&i.data&&!e){let o=r.state.selection.from;return i.preventDefault(),r.dispatch(r.state.tr.insertText(i.data||"",o)),!0}return!1},"beforeinput")},decorations(r){if(n.getState(r)){let i=r.selection.$from.pos,o=document.createElement("span"),s=Ge.widget(i,o,{side:-1}),l=document.createElement("span"),c=Ge.widget(i,l);return setTimeout(()=>{o.contentEditable="true",l.contentEditable="true"}),be.create(r.doc,[s,c])}return be.empty}}});return n});S(Vp,{displayName:"Prose<inlineNodesCursorPlugin>",group:"Prose"});var jp=Ye(e=>new ye({key:new ve("MILKDOWN_HARDBREAK_MARKS"),appendTransaction:a((t,n,r)=>{if(!t.length)return;let[i]=t;if(!i)return;let[o]=i.steps;if(i.getMeta("hardbreak")){if(!(o instanceof qe))return;let{from:s}=o;return r.tr.setNodeMarkup(s,yn.type(e),void 0,[])}if(o instanceof Wi){let s=r.tr,{from:l,to:c}=o;return r.doc.nodesBetween(l,c,(u,h)=>{u.type===yn.type(e)&&(s=s.setNodeMarkup(h,yn.type(e),void 0,[]))}),s}},"appendTransaction")}));S(jp,{displayName:"Prose<hardbreakClearMarkPlugin>",group:"Prose"});var ha=dt(["table","code_block"],"hardbreakFilterNodes");S(ha,{displayName:"Ctx<hardbreakFilterNodes>",group:"Prose"});var _p=Ye(e=>{let t=e.get(ha.key);return new ye({key:new ve("MILKDOWN_HARDBREAK_FILTER"),filterTransaction:a((n,r)=>{let i=n.getMeta("hardbreak"),[o]=n.steps;if(i&&o){let{from:s}=o,l=r.doc.resolve(s),c=l.depth,u=!0;for(;c>0;)t.includes(l.node(c).type.name)&&(u=!1),c--;return u}return!0},"filterTransaction")})});S(_p,{displayName:"Prose<hardbreakFilterPlugin>",group:"Prose"});var Hp=Ye(e=>{let t=new ve("MILKDOWN_HEADING_ID"),n=a(r=>{if(r.composing)return;let i=e.get(vo.key),o=r.state.tr.setMeta("addToHistory",!1),s=!1,l={};r.state.doc.descendants((c,u)=>{if(c.type===gn.type(e)){if(c.textContent.trim().length===0)return;let h=c.attrs,d=i(c);l[d]?(l[d]+=1,d+=`-#${l[d]}`):l[d]=1,h.id!==d&&(s=!0,o.setMeta(t,!0).setNodeMarkup(u,void 0,{...h,id:d}))}}),s&&r.dispatch(o)},"n");return new ye({key:t,view:a(r=>(n(r),{update:a((i,o)=>{i.state.doc.eq(o.doc)||n(i)},"update")}),"view")})});S(Hp,{displayName:"Prose<syncHeadingIdPlugin>",group:"Prose"});var Wp=Ye(e=>{let t=a((n,r,i)=>{if(!i.selection||n.some(d=>d.getMeta("addToHistory")===!1||!d.isGeneric))return null;let o=qn.type(e),s=Wn.type(e),l=Tt.type(e),c=a((d,p,f=1)=>{let m=!1,g=`${p+f}.`;return d.label!==g&&(d.label=g,m=!0),m},"a"),u=i.tr,h=!1;return i.doc.descendants((d,p,f,m)=>{if(d.type===s){let g=d.maybeChild(0);g?.type===l&&g.attrs.listType==="ordered"&&(h=!0,u.setNodeMarkup(p,o,{spread:!0}),d.descendants((v,y,N,x)=>{if(v.type===l){let A={...v.attrs};c(A,x)&&(u=u.setNodeMarkup(y,void 0,A))}return!1}))}else if(d.type===l&&f?.type===o){let g={...d.attrs},v=!1;g.listType!=="ordered"&&(g.listType="ordered",v=!0),f?.maybeChild(0)&&(v=c(g,m,f?.attrs.order??1)),v&&(u=u.setNodeMarkup(p,void 0,g),h=!0)}}),h?u.setMeta("addToHistory",!1):null},"e");return new ye({key:new ve("MILKDOWN_KEEP_LIST_ORDER"),appendTransaction:t})});S(Wp,{displayName:"Prose<syncListOrderPlugin>",group:"Prose"});var Sx=[jp,ha,_p,Vp,go,sa,aa,la,ca,ua,yo,Hp,Wp].flat(),Cx=[ax,cx,ux,vx,kx,Sx].flat(),da,pa;if(typeof WeakMap<"u"){let e=new WeakMap;da=a(t=>e.get(t),"$c"),pa=a((t,n)=>(e.set(t,n),n),"Vc")}else{let e=[],t=0;da=a(n=>{for(let r=0;r<e.length;r+=2)if(e[r]==n)return e[r+1]},"$c"),pa=a((n,r)=>(t==10&&(t=0),e[t++]=n,e[t++]=r),"Vc")}var Z=class{static{a(this,"Z")}constructor(e,t,n,r){this.width=e,this.height=t,this.map=n,this.problems=r}findCell(e){for(let t=0;t<this.map.length;t++){let n=this.map[t];if(n!=e)continue;let r=t%this.width,i=t/this.width|0,o=r+1,s=i+1;for(let l=1;o<this.width&&this.map[t+l]==n;l++)o++;for(let l=1;s<this.height&&this.map[t+this.width*l]==n;l++)s++;return{left:r,top:i,right:o,bottom:s}}throw new RangeError(`No cell with offset ${e} found`)}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw new RangeError(`No cell with offset ${e} found`)}nextCell(e,t,n){let{left:r,right:i,top:o,bottom:s}=this.findCell(e);return t=="horiz"?(n<0?r==0:i==this.width)?null:this.map[o*this.width+(n<0?r-1:i)]:(n<0?o==0:s==this.height)?null:this.map[r+this.width*(n<0?o-1:s)]}rectBetween(e,t){let{left:n,right:r,top:i,bottom:o}=this.findCell(e),{left:s,right:l,top:c,bottom:u}=this.findCell(t);return{left:Math.min(n,s),top:Math.min(i,c),right:Math.max(r,l),bottom:Math.max(o,u)}}cellsInRect(e){let t=[],n={};for(let r=e.top;r<e.bottom;r++)for(let i=e.left;i<e.right;i++){let o=r*this.width+i,s=this.map[o];n[s]||(n[s]=!0,!(i==e.left&&i&&this.map[o-1]==s||r==e.top&&r&&this.map[o-this.width]==s)&&t.push(s))}return t}positionAt(e,t,n){for(let r=0,i=0;;r++){let o=i+n.child(r).nodeSize;if(r==e){let s=t+e*this.width,l=(e+1)*this.width;for(;s<l&&this.map[s]<i;)s++;return s==l?o-1:this.map[s]}i=o}}static get(e){return da(e)||pa(e,Mx(e))}};function Mx(e){if(e.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+e.type.name);let t=Nx(e),n=e.childCount,r=[],i=0,o=null,s=[];for(let u=0,h=t*n;u<h;u++)r[u]=0;for(let u=0,h=0;u<n;u++){let d=e.child(u);h++;for(let m=0;;m++){for(;i<r.length&&r[i]!=0;)i++;if(m==d.childCount)break;let g=d.child(m),{colspan:v,rowspan:y,colwidth:N}=g.attrs;for(let x=0;x<y;x++){if(x+u>=n){(o||(o=[])).push({type:"overlong_rowspan",pos:h,n:y-x});break}let A=i+x*t;for(let D=0;D<v;D++){r[A+D]==0?r[A+D]=h:(o||(o=[])).push({type:"collision",row:u,pos:h,n:v-D});let M=N&&N[D];if(M){let I=(A+D)%t*2,F=s[I];F==null||F!=M&&s[I+1]==1?(s[I]=M,s[I+1]=1):F==M&&s[I+1]++}}}i+=v,h+=g.nodeSize}let p=(u+1)*t,f=0;for(;i<p;)r[i++]==0&&f++;f&&(o||(o=[])).push({type:"missing",row:u,n:f}),h++}(t===0||n===0)&&(o||(o=[])).push({type:"zero_sized"});let l=new Z(t,n,r,o),c=!1;for(let u=0;!c&&u<s.length;u+=2)s[u]!=null&&s[u+1]<n&&(c=!0);return c&&Ox(l,s,e),l}a(Mx,"PC");function Nx(e){let t=-1,n=!1;for(let r=0;r<e.childCount;r++){let i=e.child(r),o=0;if(n)for(let s=0;s<r;s++){let l=e.child(s);for(let c=0;c<l.childCount;c++){let u=l.child(c);s+u.attrs.rowspan>r&&(o+=u.attrs.colspan)}}for(let s=0;s<i.childCount;s++){let l=i.child(s);o+=l.attrs.colspan,l.attrs.rowspan>1&&(n=!0)}t==-1?t=o:t!=o&&(t=Math.max(t,o))}return t}a(Nx,"LC");function Ox(e,t,n){e.problems||(e.problems=[]);let r={};for(let i=0;i<e.map.length;i++){let o=e.map[i];if(r[o])continue;r[o]=!0;let s=n.nodeAt(o);if(!s)throw new RangeError(`No cell with offset ${o} found`);let l=null,c=s.attrs;for(let u=0;u<c.colspan;u++){let h=t[(i+u)%e.width*2];h!=null&&(!c.colwidth||c.colwidth[u]!=h)&&((l||(l=Tx(c)))[u]=h)}l&&e.problems.unshift({type:"colwidth mismatch",pos:o,colwidth:l})}}a(Ox,"zC");function Tx(e){if(e.colwidth)return e.colwidth.slice();let t=[];for(let n=0;n<e.colspan;n++)t.push(0);return t}a(Tx,"BC");function qp(e,t){if(typeof e=="string")return{};let n=e.getAttribute("data-colwidth"),r=n&&/^\d+(,\d+)*$/.test(n)?n.split(",").map(s=>Number(s)):null,i=Number(e.getAttribute("colspan")||1),o={colspan:i,rowspan:Number(e.getAttribute("rowspan")||1),colwidth:r&&r.length==i?r:null};for(let s in t){let l=t[s].getFromDOM,c=l&&l(e);c!=null&&(o[s]=c)}return o}a(qp,"hg");function Kp(e,t){let n={};e.attrs.colspan!=1&&(n.colspan=e.attrs.colspan),e.attrs.rowspan!=1&&(n.rowspan=e.attrs.rowspan),e.attrs.colwidth&&(n["data-colwidth"]=e.attrs.colwidth.join(","));for(let r in t){let i=t[r].setDOMAttr;i&&i(e.attrs[r],n)}return n}a(Kp,"dg");function Ax(e){if(e!==null){if(!Array.isArray(e))throw new TypeError("colwidth must be null or an array");for(let t of e)if(typeof t!="number")throw new TypeError("colwidth must be null or an array of numbers")}}a(Ax,"FC");function Ix(e){let t=e.cellAttributes||{},n={colspan:{default:1,validate:"number"},rowspan:{default:1,validate:"number"},colwidth:{default:null,validate:Ax}};for(let r in t)n[r]={default:t[r].default,validate:t[r].validate};return{table:{content:"table_row+",tableRole:"table",isolating:!0,group:e.tableGroup,parseDOM:[{tag:"table"}],toDOM(){return["table",["tbody",0]]}},table_row:{content:"(table_cell | table_header)*",tableRole:"row",parseDOM:[{tag:"tr"}],toDOM(){return["tr",0]}},table_cell:{content:e.cellContent,attrs:n,tableRole:"cell",isolating:!0,parseDOM:[{tag:"td",getAttrs:a(r=>qp(r,t),"getAttrs")}],toDOM(r){return["td",Kp(r,t),0]}},table_header:{content:e.cellContent,attrs:n,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:a(r=>qp(r,t),"getAttrs")}],toDOM(r){return["th",Kp(r,t),0]}}}}a(Ix,"Ng");function Xe(e){let t=e.cached.tableNodeTypes;if(!t){t=e.cached.tableNodeTypes={};for(let n in e.nodes){let r=e.nodes[n],i=r.spec.tableRole;i&&(t[i]=r)}}return t}a(Xe,"st");var Jt=new ve("selectingCells");function Kn(e){for(let t=e.depth-1;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return e.node(0).resolve(e.before(t+1));return null}a(Kn,"Yr");function Ze(e){let t=e.selection.$head;for(let n=t.depth;n>0;n--)if(t.node(n).type.spec.tableRole=="row")return!0;return!1}a(Ze,"Ye");function wo(e){let t=e.selection;if("$anchorCell"in t&&t.$anchorCell)return t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell;if("node"in t&&t.node&&t.node.type.spec.tableRole=="cell")return t.$anchor;let n=Kn(t.$head)||Ex(t.$head);if(n)return n;throw new RangeError(`No cell found around position ${t.head}`)}a(wo,"Is");function Ex(e){for(let t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){let r=t.type.spec.tableRole;if(r=="cell"||r=="header_cell")return e.doc.resolve(n)}for(let t=e.nodeBefore,n=e.pos;t;t=t.lastChild,n--){let r=t.type.spec.tableRole;if(r=="cell"||r=="header_cell")return e.doc.resolve(n-t.nodeSize)}}a(Ex,"_C");function fa(e){return e.parent.type.spec.tableRole=="row"&&!!e.nodeAfter}a(fa,"Hc");function Dx(e){return e.node(0).resolve(e.pos+e.nodeAfter.nodeSize)}a(Dx,"$C");function ma(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}a(ma,"Wc");function Jp(e,t,n){let r=e.node(-1),i=Z.get(r),o=e.start(-1),s=i.nextCell(e.pos-o,t,n);return s==null?null:e.node(0).resolve(o+s)}a(Jp,"vg");function vn(e,t,n=1){let r={...e,colspan:e.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(t,n),r.colwidth.some(i=>i>0)||(r.colwidth=null)),r}a(vn,"rr");function Rx(e,t,n=1){let r={...e,colspan:e.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let i=0;i<n;i++)r.colwidth.splice(t,0,0)}return r}a(Rx,"VC");function zx(e,t,n){let r=Xe(t.type.schema).header_cell;for(let i=0;i<e.height;i++)if(t.nodeAt(e.map[n+i*e.width]).type!=r)return!1;return!0}a(zx,"HC");var re=class Rt extends j{static{a(this,"Ft")}constructor(t,n=t){let r=t.node(-1),i=Z.get(r),o=t.start(-1),s=i.rectBetween(t.pos-o,n.pos-o),l=t.node(0),c=i.cellsInRect(s).filter(h=>h!=n.pos-o);c.unshift(n.pos-o);let u=c.map(h=>{let d=r.nodeAt(h);if(!d)throw new RangeError(`No cell with offset ${h} found`);let p=o+h+1;return new Gi(l.resolve(p),l.resolve(p+d.content.size))});super(u[0].$from,u[0].$to,u),this.$anchorCell=t,this.$headCell=n}map(t,n){let r=t.resolve(n.map(this.$anchorCell.pos)),i=t.resolve(n.map(this.$headCell.pos));if(fa(r)&&fa(i)&&ma(r,i)){let o=this.$anchorCell.node(-1)!=r.node(-1);return o&&this.isRowSelection()?Rt.rowSelection(r,i):o&&this.isColSelection()?Rt.colSelection(r,i):new Rt(r,i)}return q.between(r,i)}content(){let t=this.$anchorCell.node(-1),n=Z.get(t),r=this.$anchorCell.start(-1),i=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),o={},s=[];for(let c=i.top;c<i.bottom;c++){let u=[];for(let h=c*n.width+i.left,d=i.left;d<i.right;d++,h++){let p=n.map[h];if(o[p])continue;o[p]=!0;let f=n.findCell(p),m=t.nodeAt(p);if(!m)throw new RangeError(`No cell with offset ${p} found`);let g=i.left-f.left,v=f.right-i.right;if(g>0||v>0){let y=m.attrs;if(g>0&&(y=vn(y,0,g)),v>0&&(y=vn(y,y.colspan-v,v)),f.left<i.left){if(m=m.type.createAndFill(y),!m)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(y)}`)}else m=m.type.create(y,m.content)}if(f.top<i.top||f.bottom>i.bottom){let y={...m.attrs,rowspan:Math.min(f.bottom,i.bottom)-Math.max(f.top,i.top)};f.top<i.top?m=m.type.createAndFill(y):m=m.type.create(y,m.content)}u.push(m)}s.push(t.child(c).copy(O.from(u)))}let l=this.isColSelection()&&this.isRowSelection()?t:s;return new E(O.from(l),1,1)}replace(t,n=E.empty){let r=t.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:l,$to:c}=i[s],u=t.mapping.slice(r);t.replace(u.map(l.pos),u.map(c.pos),s?E.empty:n)}let o=j.findFrom(t.doc.resolve(t.mapping.slice(r).map(this.to)),-1);o&&t.setSelection(o)}replaceWith(t,n){this.replace(t,new E(O.from(n),0,0))}forEachCell(t){let n=this.$anchorCell.node(-1),r=Z.get(n),i=this.$anchorCell.start(-1),o=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-i,this.$headCell.pos-i));for(let s=0;s<o.length;s++)t(n.nodeAt(o[s]),i+o[s])}isColSelection(){let t=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(t,n)>0)return!1;let r=t+this.$anchorCell.nodeAfter.attrs.rowspan,i=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,i)==this.$headCell.node(-1).childCount}static colSelection(t,n=t){let r=t.node(-1),i=Z.get(r),o=t.start(-1),s=i.findCell(t.pos-o),l=i.findCell(n.pos-o),c=t.node(0);return s.top<=l.top?(s.top>0&&(t=c.resolve(o+i.map[s.left])),l.bottom<i.height&&(n=c.resolve(o+i.map[i.width*(i.height-1)+l.right-1]))):(l.top>0&&(n=c.resolve(o+i.map[l.left])),s.bottom<i.height&&(t=c.resolve(o+i.map[i.width*(i.height-1)+s.right-1]))),new Rt(t,n)}isRowSelection(){let t=this.$anchorCell.node(-1),n=Z.get(t),r=this.$anchorCell.start(-1),i=n.colCount(this.$anchorCell.pos-r),o=n.colCount(this.$headCell.pos-r);if(Math.min(i,o)>0)return!1;let s=i+this.$anchorCell.nodeAfter.attrs.colspan,l=o+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,l)==n.width}eq(t){return t instanceof Rt&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,n=t){let r=t.node(-1),i=Z.get(r),o=t.start(-1),s=i.findCell(t.pos-o),l=i.findCell(n.pos-o),c=t.node(0);return s.left<=l.left?(s.left>0&&(t=c.resolve(o+i.map[s.top*i.width])),l.right<i.width&&(n=c.resolve(o+i.map[i.width*(l.top+1)-1]))):(l.left>0&&(n=c.resolve(o+i.map[l.top*i.width])),s.right<i.width&&(t=c.resolve(o+i.map[i.width*(s.top+1)-1]))),new Rt(t,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(t,n){return new Rt(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,r=n){return new Rt(t.resolve(n),t.resolve(r))}getBookmark(){return new Px(this.$anchorCell.pos,this.$headCell.pos)}};re.prototype.visible=!1,j.jsonID("cell",re);var Px=class Pm{static{a(this,"Tg")}constructor(t,n){this.anchor=t,this.head=n}map(t){return new Pm(t.map(this.anchor),t.map(this.head))}resolve(t){let n=t.resolve(this.anchor),r=t.resolve(this.head);return n.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&n.index()<n.parent.childCount&&r.index()<r.parent.childCount&&ma(n,r)?new re(n,r):j.near(r,1)}};function Fx(e){if(!(e.selection instanceof re))return null;let t=[];return e.selection.forEachCell((n,r)=>{t.push(Ge.node(r,r+n.nodeSize,{class:"selectedCell"}))}),be.create(e.doc,t)}a(Fx,"KC");function Lx({$from:e,$to:t}){if(e.pos==t.pos||e.pos<t.pos-6)return!1;let n=e.pos,r=t.pos,i=e.depth;for(;i>=0&&!(e.after(i+1)<e.end(i));i--,n++);for(let o=t.depth;o>=0&&!(t.before(o+1)>t.start(o));o--,r--);return n==r&&/row|table/.test(e.node(i).type.spec.tableRole)}a(Lx,"WC");function $x({$from:e,$to:t}){let n,r;for(let i=e.depth;i>0;i--){let o=e.node(i);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){n=o;break}}for(let i=t.depth;i>0;i--){let o=t.node(i);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){r=o;break}}return n!==r&&t.parentOffset===0}a($x,"qC");function Bx(e,t,n){let r=(t||e).selection,i=(t||e).doc,o,s;if(r instanceof _&&(s=r.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")o=re.create(i,r.from);else if(s=="row"){let l=i.resolve(r.from+1);o=re.rowSelection(l,l)}else if(!n){let l=Z.get(r.node),c=r.from+1,u=c+l.map[l.width*l.height-1];o=re.create(i,c+1,u)}}else r instanceof q&&Lx(r)?o=q.create(i,r.from):r instanceof q&&$x(r)&&(o=q.create(i,r.$from.start(),r.$from.end()));return o&&(t||(t=e.tr)).setSelection(o),t}a(Bx,"JC");var Vx=new ve("fix-tables");function Up(e,t,n,r){let i=e.childCount,o=t.childCount;e:for(let s=0,l=0;s<o;s++){let c=t.child(s);for(let u=l,h=Math.min(i,s+3);u<h;u++)if(e.child(u)==c){l=u+1,n+=c.nodeSize;continue e}r(c,n),l<i&&e.child(l).sameMarkup(c)?Up(e.child(l),c,n+1,r):c.nodesBetween(0,c.content.size,r,n+1),n+=c.nodeSize}}a(Up,"Ig");function jx(e,t){let n,r=a((i,o)=>{i.type.spec.tableRole=="table"&&(n=_x(e,i,o,n))},"r");return t?t.doc!=e.doc&&Up(t.doc,e.doc,0,r):e.doc.descendants(r),n}a(jx,"GC");function _x(e,t,n,r){let i=Z.get(t);if(!i.problems)return r;r||(r=e.tr);let o=[];for(let c=0;c<i.height;c++)o.push(0);for(let c=0;c<i.problems.length;c++){let u=i.problems[c];if(u.type=="collision"){let h=t.nodeAt(u.pos);if(!h)continue;let d=h.attrs;for(let p=0;p<d.rowspan;p++)o[u.row+p]+=u.n;r.setNodeMarkup(r.mapping.map(n+1+u.pos),null,vn(d,d.colspan-u.n,u.n))}else if(u.type=="missing")o[u.row]+=u.n;else if(u.type=="overlong_rowspan"){let h=t.nodeAt(u.pos);if(!h)continue;r.setNodeMarkup(r.mapping.map(n+1+u.pos),null,{...h.attrs,rowspan:h.attrs.rowspan-u.n})}else if(u.type=="colwidth mismatch"){let h=t.nodeAt(u.pos);if(!h)continue;r.setNodeMarkup(r.mapping.map(n+1+u.pos),null,{...h.attrs,colwidth:u.colwidth})}else if(u.type=="zero_sized"){let h=r.mapping.map(n);r.delete(h,h+t.nodeSize)}}let s,l;for(let c=0;c<o.length;c++)o[c]&&(s==null&&(s=c),l=c);for(let c=0,u=n+1;c<i.height;c++){let h=t.child(c),d=u+h.nodeSize,p=o[c];if(p>0){let f="cell";h.firstChild&&(f=h.firstChild.type.spec.tableRole);let m=[];for(let v=0;v<p;v++){let y=Xe(e.schema)[f].createAndFill();y&&m.push(y)}let g=(c==0||s==c-1)&&l==c?u+1:d-1;r.insert(r.mapping.map(g),m)}u=d}return r.setMeta(Vx,{fixTables:!0})}a(_x,"YC");function Gp(e){let t=Z.get(e),n=[],r=t.height,i=t.width;for(let o=0;o<r;o++){let s=[];for(let l=0;l<i;l++){let c=o*i+l,u=t.map[c];if(o>0){let h=c-i;if(u===t.map[h]){s.push(null);continue}}if(l>0){let h=c-1;if(u===t.map[h]){s.push(null);continue}}s.push(e.nodeAt(u))}n.push(s)}return n}a(Gp,"Ag");function Qp(e,t){let n=[],r=Z.get(e),i=r.height,o=r.width;for(let s=0;s<i;s++){let l=e.child(s),c=[];for(let h=0;h<o;h++){let d=t[s][h];if(!d)continue;let p=r.map[s*r.width+h],f=e.nodeAt(p);if(!f)continue;let m=f.type.createChecked(d.attrs,d.content,d.marks);c.push(m)}let u=l.type.createChecked(l.attrs,c,l.marks);n.push(u)}return e.type.createChecked(e.attrs,n,e.marks)}a(Qp,"Eg");function Yp(e,t,n,r){let i=t[0]>n[0]?-1:1,o=e.splice(t[0],t.length),s=o.length%2===0?1:0,l;return r===-1&&i===1?l=n[0]-1:r===1&&i===-1?l=n[n.length-1]-s+1:l=i===-1?n[0]:n[n.length-1]-s,e.splice(l,0,...o),e}a(Yp,"Og");function ti(e){return Hx(t=>t.type.spec.tableRole==="table",e)}a(ti,"Qr");function Hx(e,t){for(let n=t.depth;n>=0;n-=1){let r=t.node(n);if(e(r))return{node:r,pos:n===0?0:t.before(n),start:t.start(n),depth:n}}return null}a(Hx,"QC");function Jn(e,t){let n=ti(t.$from);if(!n)return;let r=Z.get(n.node);if(!(e<0||e>r.width-1))return r.cellsInRect({left:e,right:e+1,top:0,bottom:r.height}).map(i=>{let o=n.node.nodeAt(i),s=i+n.start;return{pos:s,start:s+1,node:o,depth:n.depth+2}})}a(Jn,"Ur");function Un(e,t){let n=ti(t.$from);if(!n)return;let r=Z.get(n.node);if(!(e<0||e>r.height-1))return r.cellsInRect({left:0,right:r.width,top:e,bottom:e+1}).map(i=>{let o=n.node.nodeAt(i),s=i+n.start;return{pos:s,start:s+1,node:o,depth:n.depth+2}})}a(Un,"Gr");function Xp(e,t,n=t){let r=t,i=n;for(let h=t;h>=0;h--){let d=Jn(h,e.selection);d&&d.forEach(p=>{let f=p.node.attrs.colspan+h-1;f>=r&&(r=h),f>i&&(i=f)})}for(let h=t;h<=i;h++){let d=Jn(h,e.selection);d&&d.forEach(p=>{let f=p.node.attrs.colspan+h-1;p.node.attrs.colspan>1&&f>i&&(i=f)})}let o=[];for(let h=r;h<=i;h++){let d=Jn(h,e.selection);d&&d.length>0&&o.push(h)}r=o[0],i=o[o.length-1];let s=Jn(r,e.selection),l=Un(0,e.selection);if(!s||!l)return;let c=e.doc.resolve(s[s.length-1].pos),u;for(let h=i;h>=r;h--){let d=Jn(h,e.selection);if(d&&d.length>0){for(let p=l.length-1;p>=0;p--)if(l[p].pos===d[0].pos){u=d[0];break}if(u)break}}if(u)return{$anchor:c,$head:e.doc.resolve(u.pos),indexes:o}}a(Xp,"pg");function Zp(e,t,n=t){let r=t,i=n;for(let h=t;h>=0;h--){let d=Un(h,e.selection);d&&d.forEach(p=>{let f=p.node.attrs.rowspan+h-1;f>=r&&(r=h),f>i&&(i=f)})}for(let h=t;h<=i;h++){let d=Un(h,e.selection);d&&d.forEach(p=>{let f=p.node.attrs.rowspan+h-1;p.node.attrs.rowspan>1&&f>i&&(i=f)})}let o=[];for(let h=r;h<=i;h++){let d=Un(h,e.selection);d&&d.length>0&&o.push(h)}r=o[0],i=o[o.length-1];let s=Un(r,e.selection),l=Jn(0,e.selection);if(!s||!l)return;let c=e.doc.resolve(s[s.length-1].pos),u;for(let h=i;h>=r;h--){let d=Un(h,e.selection);if(d&&d.length>0){for(let p=l.length-1;p>=0;p--)if(l[p].pos===d[0].pos){u=d[0];break}if(u)break}}if(u)return{$anchor:c,$head:e.doc.resolve(u.pos),indexes:o}}a(Zp,"mg");function ef(e){return e[0].map((t,n)=>e.map(r=>r[n]))}a(ef,"gg");function Wx(e){var t,n;let{tr:r,originIndex:i,targetIndex:o,select:s,pos:l}=e,c=ti(r.doc.resolve(l));if(!c)return!1;let u=(t=Xp(r,i))===null||t===void 0?void 0:t.indexes,h=(n=Xp(r,o))===null||n===void 0?void 0:n.indexes;if(!u||!h||u.includes(o))return!1;let d=qx(c.node,u,h,0);if(r.replaceWith(c.pos,c.pos+c.node.nodeSize,d),!s)return!0;let p=Z.get(d),f=c.start,m=o,g=p.positionAt(p.height-1,m,d),v=r.doc.resolve(f+g),y=p.positionAt(0,m,d),N=r.doc.resolve(f+y);return r.setSelection(re.colSelection(v,N)),!0}a(Wx,"XC");function qx(e,t,n,r){let i=ef(Gp(e));return i=Yp(i,t,n,r),i=ef(i),Qp(e,i)}a(qx,"ZC");function Kx(e){var t,n;let{tr:r,originIndex:i,targetIndex:o,select:s,pos:l}=e,c=ti(r.doc.resolve(l));if(!c)return!1;let u=(t=Zp(r,i))===null||t===void 0?void 0:t.indexes,h=(n=Zp(r,o))===null||n===void 0?void 0:n.indexes;if(!u||!h||u.includes(o))return!1;let d=Jx(c.node,u,h,0);if(r.replaceWith(c.pos,c.pos+c.node.nodeSize,d),!s)return!0;let p=Z.get(d),f=c.start,m=o,g=p.positionAt(m,p.width-1,d),v=r.doc.resolve(f+g),y=p.positionAt(m,0,d),N=r.doc.resolve(f+y);return r.setSelection(re.rowSelection(v,N)),!0}a(Kx,"eS");function Jx(e,t,n,r){let i=Gp(e);return i=Yp(i,t,n,r),Qp(e,i)}a(Jx,"tS");function Ut(e){let t=e.selection,n=wo(e),r=n.node(-1),i=n.start(-1),o=Z.get(r);return{...t instanceof re?o.rectBetween(t.$anchorCell.pos-i,t.$headCell.pos-i):o.findCell(n.pos-i),tableStart:i,map:o,table:r}}a(Ut,"_t");function tf(e,{map:t,tableStart:n,table:r},i){let o=i>0?-1:0;zx(t,r,i+o)&&(o=i==0||i==t.width?null:0);for(let s=0;s<t.height;s++){let l=s*t.width+i;if(i>0&&i<t.width&&t.map[l-1]==t.map[l]){let c=t.map[l],u=r.nodeAt(c);e.setNodeMarkup(e.mapping.map(n+c),null,Rx(u.attrs,i-t.colCount(c))),s+=u.attrs.rowspan-1}else{let c=o==null?Xe(r.type.schema).cell:r.nodeAt(t.map[l+o]).type,u=t.positionAt(s,i,r);e.insert(e.mapping.map(n+u),c.createAndFill())}}return e}a(tf,"Rg");function Ux(e,t){if(!Ze(e))return!1;if(t){let n=Ut(e);t(tf(e.tr,n,n.left))}return!0}a(Ux,"Dg");function Gx(e,t){if(!Ze(e))return!1;if(t){let n=Ut(e);t(tf(e.tr,n,n.right))}return!0}a(Gx,"Pg");function Qx(e,{map:t,table:n,tableStart:r},i){let o=e.mapping.maps.length;for(let s=0;s<t.height;){let l=s*t.width+i,c=t.map[l],u=n.nodeAt(c),h=u.attrs;if(i>0&&t.map[l-1]==c||i<t.width-1&&t.map[l+1]==c)e.setNodeMarkup(e.mapping.slice(o).map(r+c),null,vn(h,i-t.colCount(c)));else{let d=e.mapping.slice(o).map(r+c);e.delete(d,d+u.nodeSize)}s+=h.rowspan}}a(Qx,"nS");function Yx(e,t){if(!Ze(e))return!1;if(t){let n=Ut(e),r=e.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let i=n.right-1;Qx(r,n,i),i!=n.left;i--){let o=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!o)throw new RangeError("No table found");n.table=o,n.map=Z.get(o)}t(r)}return!0}a(Yx,"Lg");function Xx(e,{map:t,table:n,tableStart:r},i){let o=0;for(let u=0;u<i;u++)o+=n.child(u).nodeSize;let s=o+n.child(i).nodeSize,l=e.mapping.maps.length;e.delete(o+r,s+r);let c=new Set;for(let u=0,h=i*t.width;u<t.width;u++,h++){let d=t.map[h];if(!c.has(d)){if(c.add(d),i>0&&d==t.map[h-t.width]){let p=n.nodeAt(d).attrs;e.setNodeMarkup(e.mapping.slice(l).map(d+r),null,{...p,rowspan:p.rowspan-1}),u+=p.colspan-1}else if(i<t.height&&d==t.map[h+t.width]){let p=n.nodeAt(d),f=p.attrs,m=p.type.create({...f,rowspan:p.attrs.rowspan-1},p.content),g=t.positionAt(i+1,u,n);e.insert(e.mapping.slice(l).map(r+g),m),u+=f.colspan-1}}}}a(Xx,"rS");function Zx(e,t){if(!Ze(e))return!1;if(t){let n=Ut(e),r=e.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let i=n.bottom-1;Xx(r,n,i),i!=n.top;i--){let o=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!o)throw new RangeError("No table found");n.table=o,n.map=Z.get(n.table)}t(r)}return!0}a(Zx,"zg");function eS(e,t){return function(n,r){if(!Ze(n))return!1;let i=wo(n);if(i.nodeAfter.attrs[e]===t)return!1;if(r){let o=n.tr;n.selection instanceof re?n.selection.forEachCell((s,l)=>{s.attrs[e]!==t&&o.setNodeMarkup(l,null,{...s.attrs,[e]:t})}):o.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[e]:t}),r(o)}return!0}}a(eS,"Bg");function tS(e){return function(t,n){if(!Ze(t))return!1;if(n){let r=Xe(t.schema),i=Ut(t),o=t.tr,s=i.map.cellsInRect(e=="column"?{left:i.left,top:0,right:i.right,bottom:i.map.height}:e=="row"?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),l=s.map(c=>i.table.nodeAt(c));for(let c=0;c<s.length;c++)l[c].type==r.header_cell&&o.setNodeMarkup(i.tableStart+s[c],r.cell,l[c].attrs);if(o.steps.length===0)for(let c=0;c<s.length;c++)o.setNodeMarkup(i.tableStart+s[c],r.header_cell,l[c].attrs);n(o)}return!0}}a(tS,"iS");function nf(e,t,n){let r=t.map.cellsInRect({left:0,top:0,right:e=="row"?t.map.width:1,bottom:e=="column"?t.map.height:1});for(let i=0;i<r.length;i++){let o=t.table.nodeAt(r[i]);if(o&&o.type!==n.header_cell)return!1}return!0}a(nf,"yg");function ga(e,t){return t=t||{useDeprecatedLogic:!1},t.useDeprecatedLogic?tS(e):function(n,r){if(!Ze(n))return!1;if(r){let i=Xe(n.schema),o=Ut(n),s=n.tr,l=nf("row",o,i),c=nf("column",o,i),u=(e==="column"?l:e==="row"&&c)?1:0,h=e=="column"?{left:0,top:u,right:1,bottom:o.map.height}:e=="row"?{left:u,top:0,right:o.map.width,bottom:1}:o,d=e=="column"?c?i.cell:i.header_cell:e=="row"?l?i.cell:i.header_cell:i.cell;o.map.cellsInRect(h).forEach(p=>{let f=p+o.tableStart,m=s.doc.nodeAt(f);m&&s.setNodeMarkup(f,d,m.attrs)}),r(s)}return!0}}a(ga,"qc");var pN=ga("row",{useDeprecatedLogic:!0}),fN=ga("column",{useDeprecatedLogic:!0}),mN=ga("cell",{useDeprecatedLogic:!0});function nS(e,t){if(t<0){let n=e.nodeBefore;if(n)return e.pos-n.nodeSize;for(let r=e.index(-1)-1,i=e.before();r>=0;r--){let o=e.node(-1).child(r),s=o.lastChild;if(s)return i-1-s.nodeSize;i-=o.nodeSize}}else{if(e.index()<e.parent.childCount-1)return e.pos+e.nodeAfter.nodeSize;let n=e.node(-1);for(let r=e.indexAfter(-1),i=e.after();r<n.childCount;r++){let o=n.child(r);if(o.childCount)return i+1;i+=o.nodeSize}}return null}a(nS,"oS");function rf(e){return function(t,n){if(!Ze(t))return!1;let r=nS(wo(t),e);if(r==null)return!1;if(n){let i=t.doc.resolve(r);n(t.tr.setSelection(q.between(i,Dx(i))).scrollIntoView())}return!0}}a(rf,"Jc");function rS(e,t){let n=e.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole=="table")return t&&t(e.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}a(rS,"Fg");function bo(e,t){let n=e.selection;if(!(n instanceof re))return!1;if(t){let r=e.tr,i=Xe(e.schema).cell.createAndFill().content;n.forEachCell((o,s)=>{o.content.eq(i)||r.replace(r.mapping.map(s+1),r.mapping.map(s+o.nodeSize-1),new E(i,0,0))}),r.docChanged&&t(r)}return!0}a(bo,"Ss");function iS(e){return(t,n)=>{let{from:r,to:i,select:o=!0,pos:s=t.selection.from}=e,l=t.tr;return Kx({tr:l,originIndex:r,targetIndex:i,select:o,pos:s})?(n?.(l),!0):!1}}a(iS,"_g");function oS(e){return(t,n)=>{let{from:r,to:i,select:o=!0,pos:s=t.selection.from}=e,l=t.tr;return Wx({tr:l,originIndex:r,targetIndex:i,select:o,pos:s})?(n?.(l),!0):!1}}a(oS,"$g");function sS(e){if(e.size===0)return null;let{content:t,openStart:n,openEnd:r}=e;for(;t.childCount==1&&(n>0&&r>0||t.child(0).type.spec.tableRole=="table");)n--,r--,t=t.child(0).content;let i=t.child(0),o=i.type.spec.tableRole,s=i.type.schema,l=[];if(o=="row")for(let c=0;c<t.childCount;c++){let u=t.child(c).content,h=c?0:Math.max(0,n-1),d=c<t.childCount-1?0:Math.max(0,r-1);(h||d)&&(u=ya(Xe(s).row,new E(u,h,d)).content),l.push(u)}else if(o=="cell"||o=="header_cell")l.push(n||r?ya(Xe(s).row,new E(t,n,r)).content:t);else return null;return lS(s,l)}a(sS,"sS");function lS(e,t){let n=[];for(let i=0;i<t.length;i++){let o=t[i];for(let s=o.childCount-1;s>=0;s--){let{rowspan:l,colspan:c}=o.child(s).attrs;for(let u=i;u<i+l;u++)n[u]=(n[u]||0)+c}}let r=0;for(let i=0;i<n.length;i++)r=Math.max(r,n[i]);for(let i=0;i<n.length;i++)if(i>=t.length&&t.push(O.empty),n[i]<r){let o=Xe(e).cell.createAndFill(),s=[];for(let l=n[i];l<r;l++)s.push(o);t[i]=t[i].append(O.from(s))}return{height:t.length,width:r,rows:t}}a(lS,"lS");function ya(e,t){let n=e.createAndFill();return new ph(n).replace(0,n.content.size,t).doc}a(ya,"jc");function aS({width:e,height:t,rows:n},r,i){if(e!=r){let o=[],s=[];for(let l=0;l<n.length;l++){let c=n[l],u=[];for(let h=o[l]||0,d=0;h<r;d++){let p=c.child(d%c.childCount);h+p.attrs.colspan>r&&(p=p.type.createChecked(vn(p.attrs,p.attrs.colspan,h+p.attrs.colspan-r),p.content)),u.push(p),h+=p.attrs.colspan;for(let f=1;f<p.attrs.rowspan;f++)o[l+f]=(o[l+f]||0)+p.attrs.colspan}s.push(O.from(u))}n=s,e=r}if(t!=i){let o=[];for(let s=0,l=0;s<i;s++,l++){let c=[],u=n[l%t];for(let h=0;h<u.childCount;h++){let d=u.child(h);s+d.attrs.rowspan>i&&(d=d.type.create({...d.attrs,rowspan:Math.max(1,i-d.attrs.rowspan)},d.content)),c.push(d)}o.push(O.from(c))}n=o,t=i}return{width:e,height:t,rows:n}}a(aS,"aS");function cS(e,t,n,r,i,o,s){let l=e.doc.type.schema,c=Xe(l),u,h;if(i>t.width)for(let d=0,p=0;d<t.height;d++){let f=n.child(d);p+=f.nodeSize;let m=[],g;f.lastChild==null||f.lastChild.type==c.cell?g=u||(u=c.cell.createAndFill()):g=h||(h=c.header_cell.createAndFill());for(let v=t.width;v<i;v++)m.push(g);e.insert(e.mapping.slice(s).map(p-1+r),m)}if(o>t.height){let d=[];for(let m=0,g=(t.height-1)*t.width;m<Math.max(t.width,i);m++){let v=m>=t.width?!1:n.nodeAt(t.map[g+m]).type==c.header_cell;d.push(v?h||(h=c.header_cell.createAndFill()):u||(u=c.cell.createAndFill()))}let p=c.row.create(null,O.from(d)),f=[];for(let m=t.height;m<o;m++)f.push(p);e.insert(e.mapping.slice(s).map(r+n.nodeSize-2),f)}return!!(u||h)}a(cS,"cS");function of(e,t,n,r,i,o,s,l){if(s==0||s==t.height)return!1;let c=!1;for(let u=i;u<o;u++){let h=s*t.width+u,d=t.map[h];if(t.map[h-t.width]==d){c=!0;let p=n.nodeAt(d),{top:f,left:m}=t.findCell(d);e.setNodeMarkup(e.mapping.slice(l).map(d+r),null,{...p.attrs,rowspan:s-f}),e.insert(e.mapping.slice(l).map(t.positionAt(s,m,n)),p.type.createAndFill({...p.attrs,rowspan:f+p.attrs.rowspan-s})),u+=p.attrs.colspan-1}}return c}a(of,"kg");function sf(e,t,n,r,i,o,s,l){if(s==0||s==t.width)return!1;let c=!1;for(let u=i;u<o;u++){let h=u*t.width+s,d=t.map[h];if(t.map[h-1]==d){c=!0;let p=n.nodeAt(d),f=t.colCount(d),m=e.mapping.slice(l).map(d+r);e.setNodeMarkup(m,null,vn(p.attrs,s-f,p.attrs.colspan-(s-f))),e.insert(m+p.nodeSize,p.type.createAndFill(vn(p.attrs,0,s-f))),u+=p.attrs.rowspan-1}}return c}a(sf,"bg");function lf(e,t,n,r,i){let o=n?e.doc.nodeAt(n-1):e.doc;if(!o)throw new Error("No table found");let s=Z.get(o),{top:l,left:c}=r,u=c+i.width,h=l+i.height,d=e.tr,p=0;function f(){if(o=n?d.doc.nodeAt(n-1):d.doc,!o)throw new Error("No table found");s=Z.get(o),p=d.mapping.maps.length}a(f,"d"),cS(d,s,o,n,u,h,p)&&f(),of(d,s,o,n,c,u,l,p)&&f(),of(d,s,o,n,c,u,h,p)&&f(),sf(d,s,o,n,l,h,c,p)&&f(),sf(d,s,o,n,l,h,u,p)&&f();for(let m=l;m<h;m++){let g=s.positionAt(m,c,o),v=s.positionAt(m,u,o);d.replace(d.mapping.slice(p).map(g+n),d.mapping.slice(p).map(v+n),new E(i.rows[m-l],0,0))}f(),d.setSelection(new re(d.doc.resolve(n+s.positionAt(l,c,o)),d.doc.resolve(n+s.positionAt(h-1,u-1,o)))),t(d)}a(lf,"xg");var uS=Lh({ArrowLeft:So("horiz",-1),ArrowRight:So("horiz",1),ArrowUp:So("vert",-1),ArrowDown:So("vert",1),"Shift-ArrowLeft":Co("horiz",-1),"Shift-ArrowRight":Co("horiz",1),"Shift-ArrowUp":Co("vert",-1),"Shift-ArrowDown":Co("vert",1),Backspace:bo,"Mod-Backspace":bo,Delete:bo,"Mod-Delete":bo});function xo(e,t,n){return n.eq(e.selection)?!1:(t&&t(e.tr.setSelection(n).scrollIntoView()),!0)}a(xo,"vs");function So(e,t){return(n,r,i)=>{if(!i)return!1;let o=n.selection;if(o instanceof re)return xo(n,r,j.near(o.$headCell,t));if(e!="horiz"&&!o.empty)return!1;let s=af(i,e,t);if(s==null)return!1;if(e=="horiz")return xo(n,r,j.near(n.doc.resolve(o.head+t),t));{let l=n.doc.resolve(s),c=Jp(l,e,t),u;return c?u=j.near(c,1):t<0?u=j.near(n.doc.resolve(l.before(-1)),-1):u=j.near(n.doc.resolve(l.after(-1)),1),xo(n,r,u)}}}a(So,"Ms");function Co(e,t){return(n,r,i)=>{if(!i)return!1;let o=n.selection,s;if(o instanceof re)s=o;else{let c=af(i,e,t);if(c==null)return!1;s=new re(n.doc.resolve(c))}let l=Jp(s.$headCell,e,t);return l?xo(n,r,new re(s.$anchorCell,l)):!1}}a(Co,"Ns");function hS(e,t){let n=e.state.doc,r=Kn(n.resolve(t));return r?(e.dispatch(e.state.tr.setSelection(new re(r))),!0):!1}a(hS,"fS");function dS(e,t,n){if(!Ze(e.state))return!1;let r=sS(n),i=e.state.selection;if(i instanceof re){r||(r={width:1,height:1,rows:[O.from(ya(Xe(e.state.schema).cell,n))]});let o=i.$anchorCell.node(-1),s=i.$anchorCell.start(-1),l=Z.get(o).rectBetween(i.$anchorCell.pos-s,i.$headCell.pos-s);return r=aS(r,l.right-l.left,l.bottom-l.top),lf(e.state,e.dispatch,s,l,r),!0}else if(r){let o=wo(e.state),s=o.start(-1);return lf(e.state,e.dispatch,s,Z.get(o.node(-1)).findCell(o.pos-s),r),!0}else return!1}a(dS,"hS");function pS(e,t){var n;if(t.button!=0||t.ctrlKey||t.metaKey)return;let r=cf(e,t.target),i;if(t.shiftKey&&e.state.selection instanceof re)o(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&r&&(i=Kn(e.state.selection.$anchor))!=null&&((n=va(e,t))===null||n===void 0?void 0:n.pos)!=i.pos)o(i,t),t.preventDefault();else if(!r)return;function o(c,u){let h=va(e,u),d=Jt.getState(e.state)==null;if(!h||!ma(c,h))if(d)h=c;else return;let p=new re(c,h);if(d||!e.state.selection.eq(p)){let f=e.state.tr.setSelection(p);d&&f.setMeta(Jt,c.pos),e.dispatch(f)}}a(o,"o");function s(){e.root.removeEventListener("mouseup",s),e.root.removeEventListener("dragstart",s),e.root.removeEventListener("mousemove",l),Jt.getState(e.state)!=null&&e.dispatch(e.state.tr.setMeta(Jt,-1))}a(s,"s");function l(c){let u=c,h=Jt.getState(e.state),d;if(h!=null)d=e.state.doc.resolve(h);else if(cf(e,u.target)!=r&&(d=va(e,t),!d))return s();d&&o(d,u)}a(l,"l"),e.root.addEventListener("mouseup",s),e.root.addEventListener("dragstart",s),e.root.addEventListener("mousemove",l)}a(pS,"dS");function af(e,t,n){if(!(e.state.selection instanceof q))return null;let{$head:r}=e.state.selection;for(let i=r.depth-1;i>=0;i--){let o=r.node(i);if((n<0?r.index(i):r.indexAfter(i))!=(n<0?0:o.childCount))return null;if(o.type.spec.tableRole=="cell"||o.type.spec.tableRole=="header_cell"){let s=r.before(i),l=t=="vert"?n>0?"down":"up":n>0?"right":"left";return e.endOfTextblock(l)?s:null}}return null}a(af,"Vg");function cf(e,t){for(;t&&t!=e.dom;t=t.parentNode)if(t.nodeName=="TD"||t.nodeName=="TH")return t;return null}a(cf,"wg");function va(e,t){let n=e.posAtCoords({left:t.clientX,top:t.clientY});if(!n)return null;let{inside:r,pos:i}=n;return r>=0&&Kn(e.state.doc.resolve(r))||Kn(e.state.doc.resolve(i))}a(va,"_c");var fS=class{static{a(this,"pS")}constructor(e,t){this.node=e,this.defaultCellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${t}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),ka(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,ka(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function ka(e,t,n,r,i,o){let s=0,l=!0,c=t.firstChild,u=e.firstChild;if(u){for(let d=0,p=0;d<u.childCount;d++){let{colspan:f,colwidth:m}=u.child(d).attrs;for(let g=0;g<f;g++,p++){let v=i==p?o:m&&m[g],y=v?v+"px":"";if(s+=v||r,v||(l=!1),c)c.style.width!=y&&(c.style.width=y),c=c.nextSibling;else{let N=document.createElement("col");N.style.width=y,t.appendChild(N)}}}for(;c;){var h;let d=c.nextSibling;(h=c.parentNode)===null||h===void 0||h.removeChild(c),c=d}l?(n.style.width=s+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=s+"px")}}a(ka,"Kc");var Ve=new ve("tableColumnResizing");function mS({handleWidth:e=5,cellMinWidth:t=25,defaultCellMinWidth:n=100,View:r=fS,lastColumnResizable:i=!0}={}){let o=new ye({key:Ve,state:{init(s,l){var c;let u=(c=o.spec)===null||c===void 0||(c=c.props)===null||c===void 0?void 0:c.nodeViews,h=Xe(l.schema).table.name;return r&&u&&(u[h]=(d,p)=>new r(d,n,p)),new gS(-1,!1)},apply(s,l){return l.apply(s)}},props:{attributes:a(s=>{let l=Ve.getState(s);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},"attributes"),handleDOMEvents:{mousemove:a((s,l)=>{yS(s,l,e,i)},"mousemove"),mouseleave:a(s=>{vS(s)},"mouseleave"),mousedown:a((s,l)=>{kS(s,l,t,n)},"mousedown")},decorations:a(s=>{let l=Ve.getState(s);if(l&&l.activeHandle>-1)return CS(s,l.activeHandle)},"decorations"),nodeViews:{}}});return o}a(mS,"Hg");var gS=class Po{static{a(this,"Ts")}constructor(t,n){this.activeHandle=t,this.dragging=n}apply(t){let n=this,r=t.getMeta(Ve);if(r&&r.setHandle!=null)return new Po(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new Po(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&t.docChanged){let i=t.mapping.map(n.activeHandle,-1);return fa(t.doc.resolve(i))||(i=-1),new Po(i,n.dragging)}return n}};function yS(e,t,n,r){if(!e.editable)return;let i=Ve.getState(e.state);if(i&&!i.dragging){let o=bS(t.target),s=-1;if(o){let{left:l,right:c}=o.getBoundingClientRect();t.clientX-l<=n?s=uf(e,t,"left",n):c-t.clientX<=n&&(s=uf(e,t,"right",n))}if(s!=i.activeHandle){if(!r&&s!==-1){let l=e.state.doc.resolve(s),c=l.node(-1),u=Z.get(c),h=l.start(-1);if(u.colCount(l.pos-h)+l.nodeAfter.attrs.colspan-1==u.width-1)return}df(e,s)}}}a(yS,"gS");function vS(e){if(!e.editable)return;let t=Ve.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&df(e,-1)}a(vS,"yS");function kS(e,t,n,r){var i;if(!e.editable)return!1;let o=(i=e.dom.ownerDocument.defaultView)!==null&&i!==void 0?i:window,s=Ve.getState(e.state);if(!s||s.activeHandle==-1||s.dragging)return!1;let l=e.state.doc.nodeAt(s.activeHandle),c=wS(e,s.activeHandle,l.attrs);e.dispatch(e.state.tr.setMeta(Ve,{setDragging:{startX:t.clientX,startWidth:c}}));function u(d){o.removeEventListener("mouseup",u),o.removeEventListener("mousemove",h);let p=Ve.getState(e.state);p?.dragging&&(xS(e,p.activeHandle,hf(p.dragging,d,n)),e.dispatch(e.state.tr.setMeta(Ve,{setDragging:null})))}a(u,"c");function h(d){if(!d.which)return u(d);let p=Ve.getState(e.state);if(p&&p.dragging){let f=hf(p.dragging,d,n);pf(e,p.activeHandle,f,r)}}return a(h,"u"),pf(e,s.activeHandle,c,r),o.addEventListener("mouseup",u),o.addEventListener("mousemove",h),t.preventDefault(),!0}a(kS,"kS");function wS(e,t,{colspan:n,colwidth:r}){let i=r&&r[r.length-1];if(i)return i;let o=e.domAtPos(t),s=o.node.childNodes[o.offset].offsetWidth,l=n;if(r)for(let c=0;c<n;c++)r[c]&&(s-=r[c],l--);return s/l}a(wS,"bS");function bS(e){for(;e&&e.nodeName!="TD"&&e.nodeName!="TH";)e=e.classList&&e.classList.contains("ProseMirror")?null:e.parentNode;return e}a(bS,"xS");function uf(e,t,n,r){let i=n=="right"?-r:r,o=e.posAtCoords({left:t.clientX+i,top:t.clientY});if(!o)return-1;let{pos:s}=o,l=Kn(e.state.doc.resolve(s));if(!l)return-1;if(n=="right")return l.pos;let c=Z.get(l.node(-1)),u=l.start(-1),h=c.map.indexOf(l.pos-u);return h%c.width==0?-1:u+c.map[h-1]}a(uf,"Cg");function hf(e,t,n){let r=t.clientX-e.startX;return Math.max(n,e.startWidth+r)}a(hf,"Sg");function df(e,t){e.dispatch(e.state.tr.setMeta(Ve,{setHandle:t}))}a(df,"jg");function xS(e,t,n){let r=e.state.doc.resolve(t),i=r.node(-1),o=Z.get(i),s=r.start(-1),l=o.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1,c=e.state.tr;for(let u=0;u<o.height;u++){let h=u*o.width+l;if(u&&o.map[h]==o.map[h-o.width])continue;let d=o.map[h],p=i.nodeAt(d).attrs,f=p.colspan==1?0:l-o.colCount(d);if(p.colwidth&&p.colwidth[f]==n)continue;let m=p.colwidth?p.colwidth.slice():SS(p.colspan);m[f]=n,c.setNodeMarkup(s+d,null,{...p,colwidth:m})}c.docChanged&&e.dispatch(c)}a(xS,"wS");function pf(e,t,n,r){let i=e.state.doc.resolve(t),o=i.node(-1),s=i.start(-1),l=Z.get(o).colCount(i.pos-s)+i.nodeAfter.attrs.colspan-1,c=e.domAtPos(i.start(-1)).node;for(;c&&c.nodeName!="TABLE";)c=c.parentNode;c&&ka(o,c.firstChild,c,r,l,n)}a(pf,"Mg");function SS(e){return Array(e).fill(0)}a(SS,"CS");function CS(e,t){let n=[],r=e.doc.resolve(t),i=r.node(-1);if(!i)return be.empty;let o=Z.get(i),s=r.start(-1),l=o.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1;for(let u=0;u<o.height;u++){let h=l+u*o.width;if((l==o.width-1||o.map[h]!=o.map[h+1])&&(u==0||o.map[h]!=o.map[h-o.width])){var c;let d=o.map[h],p=s+d+i.nodeAt(d).nodeSize-1,f=document.createElement("div");f.className="column-resize-handle",!((c=Ve.getState(e))===null||c===void 0)&&c.dragging&&n.push(Ge.node(s+d,s+d+i.nodeAt(d).nodeSize,{class:"column-resize-dragging"})),n.push(Ge.widget(p,f))}}return be.create(e.doc,n)}a(CS,"SS");function MS({allowTableNodeSelection:e=!1}={}){return new ye({key:Jt,state:{init(){return null},apply(t,n){let r=t.getMeta(Jt);if(r!=null)return r==-1?null:r;if(n==null||!t.docChanged)return n;let{deleted:i,pos:o}=t.mapping.mapResult(n);return i?null:o}},props:{decorations:Fx,handleDOMEvents:{mousedown:pS},createSelectionBetween(t){return Jt.getState(t.state)!=null?t.state.selection:null},handleTripleClick:hS,handleKeyDown:uS,handlePaste:dS},appendTransaction(t,n,r){return Bx(r,jx(r,n),e)}})}a(MS,"Kg");var Mo=typeof navigator<"u"?navigator:null,wa=Mo&&Mo.userAgent||"",NS=/Edge\/(\d+)/.exec(wa),OS=/MSIE \d/.exec(wa),TS=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(wa),AS=!!(OS||TS||NS),IS=!AS&&!!Mo&&/Apple Computer/.test(Mo.vendor),ff=new ve("safari-ime-span"),ba=!1,ES={key:ff,props:{decorations:DS,handleDOMEvents:{compositionstart:a(()=>{ba=!0},"compositionstart"),compositionend:a(()=>{ba=!1},"compositionend")}}};function DS(e){let{$from:t,$to:n,to:r}=e.selection;if(ba&&t.sameParent(n)){let i=Ge.widget(r,RS,{ignoreSelection:!0,key:"safari-ime-span"});return be.create(e.doc,[i])}}a(DS,"ES");function RS(e){let t=e.dom.ownerDocument.createElement("span");return t.className="ProseMirror-safari-ime-span",t}a(RS,"OS");var zS=new ye(IS?ES:{key:ff});function mf(e,t){let n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}a(mf,"Yc");function PS(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}a(PS,"Qc");function FS(e,t,n){let r=Ii((n||{}).ignore||[]),i=LS(t),o=-1;for(;++o<i.length;)Yo(e,"text",s);function s(c,u){let h=-1,d;for(;++h<u.length;){let p=u[h],f=d?d.children:void 0;if(r(p,f?f.indexOf(p):void 0,d))return;d=p}if(d)return l(c,u)}a(s,"l");function l(c,u){let h=u[u.length-1],d=i[o][0],p=i[o][1],f=0,m=h.children.indexOf(c),g=!1,v=[];d.lastIndex=0;let y=d.exec(c.value);for(;y;){let N=y.index,x={index:y.index,input:y.input,stack:[...u,c]},A=p(...y,x);if(typeof A=="string"&&(A=A.length>0?{type:"text",value:A}:void 0),A===!1?d.lastIndex=N+1:(f!==N&&v.push({type:"text",value:c.value.slice(f,N)}),Array.isArray(A)?v.push(...A):A&&v.push(A),f=N+y[0].length,g=!0),!d.global)break;y=d.exec(c.value)}return g?(f<c.value.length&&v.push({type:"text",value:c.value.slice(f)}),h.children.splice(m,1,...v)):v=[c],m+v.length}a(l,"a")}a(FS,"Xc");function LS(e){let t=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");let n=!e[0]||Array.isArray(e[0])?e:[e],r=-1;for(;++r<n.length;){let i=n[r];t.push([$S(i[0]),BS(i[1])])}return t}a(LS,"RS");function $S(e){return typeof e=="string"?new RegExp(PS(e),"g"):e}a($S,"DS");function BS(e){return typeof e=="function"?e:function(){return e}}a(BS,"PS");var xa="phrasing",Sa=["autolink","link","image","label"];function VS(){return{transforms:[JS],enter:{literalAutolink:_S,literalAutolinkEmail:Ca,literalAutolinkHttp:Ca,literalAutolinkWww:Ca},exit:{literalAutolink:KS,literalAutolinkEmail:qS,literalAutolinkHttp:HS,literalAutolinkWww:WS}}}a(VS,"nu");function jS(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:xa,notInConstruct:Sa},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:xa,notInConstruct:Sa},{character:":",before:"[ps]",after:"\\/",inConstruct:xa,notInConstruct:Sa}]}}a(jS,"ru");function _S(e){this.enter({type:"link",title:null,url:"",children:[]},e)}a(_S,"LS");function Ca(e){this.config.enter.autolinkProtocol.call(this,e)}a(Ca,"tu");function HS(e){this.config.exit.autolinkProtocol.call(this,e)}a(HS,"zS");function WS(e){this.config.exit.data.call(this,e);let t=this.stack[this.stack.length-1];t.type,t.url="http://"+this.sliceSerialize(e)}a(WS,"BS");function qS(e){this.config.exit.autolinkEmail.call(this,e)}a(qS,"FS");function KS(e){this.exit(e)}a(KS,"_S");function JS(e){FS(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,US],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),GS]],{ignore:["link","linkReference"]})}a(JS,"$S");function US(e,t,n,r,i){let o="";if(!gf(i)||(/^w/i.test(t)&&(n=t+n,t="",o="http://"),!QS(n)))return!1;let s=YS(n+r);if(!s[0])return!1;let l={type:"link",title:null,url:o+t+s[0],children:[{type:"text",value:t+s[0]}]};return s[1]?[l,{type:"text",value:s[1]}]:l}a(US,"VS");function GS(e,t,n,r){return!gf(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}a(GS,"HS");function QS(e){let t=e.split(".");return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}a(QS,"jS");function YS(e){let t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(")"),i=mf(e,"("),o=mf(e,")");for(;r!==-1&&i>o;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(")"),o++;return[e,n]}a(YS,"KS");function gf(e,t){let n=e.input.charCodeAt(e.index-1);return(e.index===0||tn(n)||Mi(n))&&(!t||n!==47)}a(gf,"Jg"),yf.peek=sC;function XS(){this.buffer()}a(XS,"WS");function ZS(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}a(ZS,"qS");function eC(){this.buffer()}a(eC,"JS");function tC(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}a(tC,"US");function nC(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=nt(this.sliceSerialize(e)).toLowerCase(),n.label=t}a(nC,"GS");function rC(e){this.exit(e)}a(rC,"YS");function iC(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=nt(this.sliceSerialize(e)).toLowerCase(),n.label=t}a(iC,"QS");function oC(e){this.exit(e)}a(oC,"XS");function sC(){return"["}a(sC,"ZS");function yf(e,t,n,r){let i=n.createTracker(r),o=i.move("[^"),s=n.enter("footnoteReference"),l=n.enter("reference");return o+=i.move(n.safe(n.associationId(e),{after:"]",before:o})),l(),s(),o+=i.move("]"),o}a(yf,"Ug");function lC(){return{enter:{gfmFootnoteCallString:XS,gfmFootnoteCall:ZS,gfmFootnoteDefinitionLabelString:eC,gfmFootnoteDefinition:tC},exit:{gfmFootnoteCallString:nC,gfmFootnoteCall:rC,gfmFootnoteDefinitionLabelString:iC,gfmFootnoteDefinition:oC}}}a(lC,"iu");function aC(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:yf},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(r,i,o,s){let l=o.createTracker(s),c=l.move("[^"),u=o.enter("footnoteDefinition"),h=o.enter("label");return c+=l.move(o.safe(o.associationId(r),{before:c,after:"]"})),h(),c+=l.move("]:"),r.children&&r.children.length>0&&(l.shift(4),c+=l.move((t?`
47
+ `:" ")+o.indentLines(o.containerFlow(r,l.current()),t?vf:cC))),u(),c}}a(aC,"ou");function cC(e,t,n){return t===0?e:vf(e,t,n)}a(cC,"eM");function vf(e,t,n){return(n?"":" ")+e}a(vf,"Gg");var uC=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];kf.peek=mC;function hC(){return{canContainEols:["delete"],enter:{strikethrough:pC},exit:{strikethrough:fC}}}a(hC,"su");function dC(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:uC}],handlers:{delete:kf}}}a(dC,"lu");function pC(e){this.enter({type:"delete",children:[]},e)}a(pC,"nM");function fC(e){this.exit(e)}a(fC,"rM");function kf(e,t,n,r){let i=n.createTracker(r),o=n.enter("strikethrough"),s=i.move("~~");return s+=n.containerPhrasing(e,{...i.current(),before:s,after:"~"}),s+=i.move("~~"),o(),s}a(kf,"Yg");function mC(){return"~"}a(mC,"iM");function gC(e){return e.length}a(gC,"oM");function yC(e,t){let n=t||{},r=(n.align||[]).concat(),i=n.stringLength||gC,o=[],s=[],l=[],c=[],u=0,h=-1;for(;++h<e.length;){let g=[],v=[],y=-1;for(e[h].length>u&&(u=e[h].length);++y<e[h].length;){let N=vC(e[h][y]);if(n.alignDelimiters!==!1){let x=i(N);v[y]=x,(c[y]===void 0||x>c[y])&&(c[y]=x)}g.push(N)}s[h]=g,l[h]=v}let d=-1;if(typeof r=="object"&&"length"in r)for(;++d<u;)o[d]=wf(r[d]);else{let g=wf(r);for(;++d<u;)o[d]=g}d=-1;let p=[],f=[];for(;++d<u;){let g=o[d],v="",y="";g===99?(v=":",y=":"):g===108?v=":":g===114&&(y=":");let N=n.alignDelimiters===!1?1:Math.max(1,c[d]-v.length-y.length),x=v+"-".repeat(N)+y;n.alignDelimiters!==!1&&(N=v.length+N+y.length,N>c[d]&&(c[d]=N),f[d]=N),p[d]=x}s.splice(1,0,p),l.splice(1,0,f),h=-1;let m=[];for(;++h<s.length;){let g=s[h],v=l[h];d=-1;let y=[];for(;++d<u;){let N=g[d]||"",x="",A="";if(n.alignDelimiters!==!1){let D=c[d]-(v[d]||0),M=o[d];M===114?x=" ".repeat(D):M===99?D%2?(x=" ".repeat(D/2+.5),A=" ".repeat(D/2-.5)):(x=" ".repeat(D/2),A=x):A=" ".repeat(D)}n.delimiterStart!==!1&&!d&&y.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&N==="")&&(n.delimiterStart!==!1||d)&&y.push(" "),n.alignDelimiters!==!1&&y.push(x),y.push(N),n.alignDelimiters!==!1&&y.push(A),n.padding!==!1&&y.push(" "),(n.delimiterEnd!==!1||d!==u-1)&&y.push("|")}m.push(n.delimiterEnd===!1?y.join("").replace(/ +$/,""):y.join(""))}return m.join(`
48
+ `)}a(yC,"Xg");function vC(e){return e==null?"":String(e)}a(vC,"sM");function wf(e){let t=typeof e=="string"?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}a(wf,"Qg");function kC(){return{enter:{table:wC,tableData:bf,tableHeader:bf,tableRow:xC},exit:{codeText:SC,table:bC,tableData:Ma,tableHeader:Ma,tableRow:Ma}}}a(kC,"cu");function wC(e){let t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}a(wC,"lM");function bC(e){this.exit(e),this.data.inTable=void 0}a(bC,"aM");function xC(e){this.enter({type:"tableRow",children:[]},e)}a(xC,"cM");function Ma(e){this.exit(e)}a(Ma,"au");function bf(e){this.enter({type:"tableCell",children:[]},e)}a(bf,"Zg");function SC(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,CC));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}a(SC,"uM");function CC(e,t){return t==="|"?t:e}a(CC,"fM");function MC(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,o=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
49
+ `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:p,table:s,tableCell:c,tableRow:l}};function s(f,m,g,v){return u(h(f,g,v),f.align)}function l(f,m,g,v){let y=d(f,g,v),N=u([y]);return N.slice(0,N.indexOf(`
50
+ `))}function c(f,m,g,v){let y=g.enter("tableCell"),N=g.enter("phrasing"),x=g.containerPhrasing(f,{...v,before:o,after:o});return N(),y(),x}function u(f,m){return yC(f,{align:m,alignDelimiters:r,padding:n,stringLength:i})}function h(f,m,g){let v=f.children,y=-1,N=[],x=m.enter("table");for(;++y<v.length;)N[y]=d(v[y],m,g);return x(),N}function d(f,m,g){let v=f.children,y=-1,N=[],x=m.enter("tableRow");for(;++y<v.length;)N[y]=c(v[y],f,m,g);return x(),N}function p(f,m,g){let v=Zo.inlineCode(f,m,g);return g.stack.includes("tableCell")&&(v=v.replace(/\|/g,"\\$&")),v}}a(MC,"uu");function NC(){return{exit:{taskListCheckValueChecked:xf,taskListCheckValueUnchecked:xf,paragraph:TC}}}a(NC,"fu");function OC(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:AC}}}a(OC,"hu");function xf(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}a(xf,"ey");function TC(e){let t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){let n=this.stack[this.stack.length-1];n.type;let r=n.children[0];if(r&&r.type==="text"){let i=t.children,o=-1,s;for(;++o<i.length;){let l=i[o];if(l.type==="paragraph"){s=l;break}}s===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}a(TC,"hM");function AC(e,t,n,r){let i=e.children[0],o=typeof e.checked=="boolean"&&i&&i.type==="paragraph",s="["+(e.checked?"x":" ")+"] ",l=n.createTracker(r);o&&l.move(s);let c=Zo.listItem(e,t,n,{...r,...l.current()});return o&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,u)),c;function u(h){return h+s}}a(AC,"dM");function IC(){return[VS(),lC(),hC(),kC(),NC()]}a(IC,"du");function EC(e){return{extensions:[jS(),aC(e),dC(),MC(e),OC()]}}a(EC,"pu");var DC={tokenize:$C,partial:!0},Sf={tokenize:BC,partial:!0},Cf={tokenize:VC,partial:!0},Mf={tokenize:jC,partial:!0},RC={tokenize:_C,partial:!0},Nf={name:"wwwAutolink",tokenize:FC,previous:Tf},Of={name:"protocolAutolink",tokenize:LC,previous:Af},At={name:"emailAutolink",tokenize:PC,previous:If},ft={};function zC(){return{text:ft}}a(zC,"gu");for(var kn=48;kn<123;)ft[kn]=At,kn++,kn===58?kn=65:kn===91&&(kn=97);ft[43]=At,ft[45]=At,ft[46]=At,ft[95]=At,ft[72]=[At,Of],ft[104]=[At,Of],ft[87]=[At,Nf],ft[119]=[At,Nf];function PC(e,t,n){let r=this,i,o;return s;function s(d){return!Na(d)||!If.call(r,r.previous)||Oa(r.events)?n(d):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),l(d))}function l(d){return Na(d)?(e.consume(d),l):d===64?(e.consume(d),c):n(d)}function c(d){return d===46?e.check(RC,h,u)(d):d===45||d===95||Ae(d)?(o=!0,e.consume(d),c):h(d)}function u(d){return e.consume(d),i=!0,c}function h(d){return o&&i&&Se(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(d)):n(d)}}a(PC,"gM");function FC(e,t,n){let r=this;return i;function i(s){return s!==87&&s!==119||!Tf.call(r,r.previous)||Oa(r.events)?n(s):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(DC,e.attempt(Sf,e.attempt(Cf,o),n),n)(s))}function o(s){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(s)}}a(FC,"yM");function LC(e,t,n){let r=this,i="",o=!1;return s;function s(d){return(d===72||d===104)&&Af.call(r,r.previous)&&!Oa(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(d),e.consume(d),l):n(d)}function l(d){if(Se(d)&&i.length<5)return i+=String.fromCodePoint(d),e.consume(d),l;if(d===58){let p=i.toLowerCase();if(p==="http"||p==="https")return e.consume(d),c}return n(d)}function c(d){return d===47?(e.consume(d),o?u:(o=!0,c)):n(d)}function u(d){return d===null||Ci(d)||te(d)||tn(d)||Mi(d)?n(d):e.attempt(Sf,e.attempt(Cf,h),n)(d)}function h(d){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(d)}}a(LC,"kM");function $C(e,t,n){let r=0;return i;function i(s){return(s===87||s===119)&&r<3?(r++,e.consume(s),i):s===46&&r===3?(e.consume(s),o):n(s)}function o(s){return s===null?n(s):t(s)}}a($C,"bM");function BC(e,t,n){let r,i,o;return s;function s(u){return u===46||u===95?e.check(Mf,c,l)(u):u===null||te(u)||tn(u)||u!==45&&Mi(u)?c(u):(o=!0,e.consume(u),s)}function l(u){return u===95?r=!0:(i=r,r=void 0),e.consume(u),s}function c(u){return i||r||!o?n(u):t(u)}}a(BC,"xM");function VC(e,t){let n=0,r=0;return i;function i(s){return s===40?(n++,e.consume(s),i):s===41&&r<n?o(s):s===33||s===34||s===38||s===39||s===41||s===42||s===44||s===46||s===58||s===59||s===60||s===63||s===93||s===95||s===126?e.check(Mf,t,o)(s):s===null||te(s)||tn(s)?t(s):(e.consume(s),i)}function o(s){return s===41&&r++,e.consume(s),i}}a(VC,"wM");function jC(e,t,n){return r;function r(l){return l===33||l===34||l===39||l===41||l===42||l===44||l===46||l===58||l===59||l===63||l===95||l===126?(e.consume(l),r):l===38?(e.consume(l),o):l===93?(e.consume(l),i):l===60||l===null||te(l)||tn(l)?t(l):n(l)}function i(l){return l===null||l===40||l===91||te(l)||tn(l)?t(l):r(l)}function o(l){return Se(l)?s(l):n(l)}function s(l){return l===59?(e.consume(l),r):Se(l)?(e.consume(l),s):n(l)}}a(jC,"CM");function _C(e,t,n){return r;function r(o){return e.consume(o),i}function i(o){return Ae(o)?n(o):t(o)}}a(_C,"SM");function Tf(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||te(e)}a(Tf,"sy");function Af(e){return!Se(e)}a(Af,"ly");function If(e){return!(e===47||Na(e))}a(If,"ay");function Na(e){return e===43||e===45||e===46||e===95||Ae(e)}a(Na,"mu");function Oa(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}a(Oa,"yu");var HC={tokenize:YC,partial:!0};function WC(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:UC,continuation:{tokenize:GC},exit:QC}},text:{91:{name:"gfmFootnoteCall",tokenize:JC},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:qC,resolveTo:KC}}}}a(WC,"ku");function qC(e,t,n){let r=this,i=r.events.length,o=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),s;for(;i--;){let c=r.events[i][1];if(c.type==="labelImage"){s=c;break}if(c.type==="gfmFootnoteCall"||c.type==="labelLink"||c.type==="label"||c.type==="image"||c.type==="link")break}return l;function l(c){if(!s||!s._balanced)return n(c);let u=nt(r.sliceSerialize({start:s.end,end:r.now()}));return u.codePointAt(0)!==94||!o.includes(u.slice(1))?n(c):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(c),e.exit("gfmFootnoteCallLabelMarker"),t(c))}}a(qC,"NM");function KC(e,t){let n=e.length,r;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){r=e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";let i={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},o={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};o.end.column++,o.end.offset++,o.end._bufferIndex++;let s={type:"gfmFootnoteCallString",start:Object.assign({},o.end),end:Object.assign({},e[e.length-1][1].start)},l={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},c=[e[n+1],e[n+2],["enter",i,t],e[n+3],e[n+4],["enter",o,t],["exit",o,t],["enter",s,t],["enter",l,t],["exit",l,t],["exit",s,t],e[e.length-2],e[e.length-1],["exit",i,t]];return e.splice(n,e.length-n+1,...c),e}a(KC,"vM");function JC(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o=0,s;return l;function l(d){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),c}function c(d){return d!==94?n(d):(e.enter("gfmFootnoteCallMarker"),e.consume(d),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",u)}function u(d){if(o>999||d===93&&!s||d===null||d===91||te(d))return n(d);if(d===93){e.exit("chunkString");let p=e.exit("gfmFootnoteCallString");return i.includes(nt(r.sliceSerialize(p)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(d)}return te(d)||(s=!0),o++,e.consume(d),d===92?h:u}function h(d){return d===91||d===92||d===93?(e.consume(d),o++,u):u(d)}}a(JC,"TM");function UC(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o,s=0,l;return c;function c(m){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),u}function u(m){return m===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",h):n(m)}function h(m){if(s>999||m===93&&!l||m===null||m===91||te(m))return n(m);if(m===93){e.exit("chunkString");let g=e.exit("gfmFootnoteDefinitionLabelString");return o=nt(r.sliceSerialize(g)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),p}return te(m)||(l=!0),s++,e.consume(m),m===92?d:h}function d(m){return m===91||m===92||m===93?(e.consume(m),s++,h):h(m)}function p(m){return m===58?(e.enter("definitionMarker"),e.consume(m),e.exit("definitionMarker"),i.includes(o)||i.push(o),U(e,f,"gfmFootnoteDefinitionWhitespace")):n(m)}function f(m){return t(m)}}a(UC,"IM");function GC(e,t,n){return e.check(ar,t,e.attempt(HC,t,n))}a(GC,"AM");function QC(e){e.exit("gfmFootnoteDefinition")}a(QC,"EM");function YC(e,t,n){let r=this;return U(e,i,"gfmFootnoteDefinitionIndent",5);function i(o){let s=r.events[r.events.length-1];return s&&s[1].type==="gfmFootnoteDefinitionIndent"&&s[2].sliceSerialize(s[1],!0).length===4?t(o):n(o)}}a(YC,"OM");function XC(e){let t=(e||{}).singleTilde,n={name:"strikethrough",tokenize:i,resolveAll:r};return t==null&&(t=!0),{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(o,s){let l=-1;for(;++l<o.length;)if(o[l][0]==="enter"&&o[l][1].type==="strikethroughSequenceTemporary"&&o[l][1]._close){let c=l;for(;c--;)if(o[c][0]==="exit"&&o[c][1].type==="strikethroughSequenceTemporary"&&o[c][1]._open&&o[l][1].end.offset-o[l][1].start.offset===o[c][1].end.offset-o[c][1].start.offset){o[l][1].type="strikethroughSequence",o[c][1].type="strikethroughSequence";let u={type:"strikethrough",start:Object.assign({},o[c][1].start),end:Object.assign({},o[l][1].end)},h={type:"strikethroughText",start:Object.assign({},o[c][1].end),end:Object.assign({},o[l][1].start)},d=[["enter",u,s],["enter",o[c][1],s],["exit",o[c][1],s],["enter",h,s]],p=s.parser.constructs.insideSpan.null;p&&Le(d,d.length,0,Ni(p,o.slice(c+1,l),s)),Le(d,d.length,0,[["exit",h,s],["enter",o[l][1],s],["exit",o[l][1],s],["exit",u,s]]),Le(o,c-1,l-c+3,d),l=c+d.length-2;break}}for(l=-1;++l<o.length;)o[l][1].type==="strikethroughSequenceTemporary"&&(o[l][1].type="data");return o}function i(o,s,l){let c=this.previous,u=this.events,h=0;return d;function d(f){return c===126&&u[u.length-1][1].type!=="characterEscape"?l(f):(o.enter("strikethroughSequenceTemporary"),p(f))}function p(f){let m=Nn(c);if(f===126)return h>1?l(f):(o.consume(f),h++,p);if(h<2&&!t)return l(f);let g=o.exit("strikethroughSequenceTemporary"),v=Nn(f);return g._open=!v||v===2&&!!m,g._close=!m||m===2&&!!v,s(f)}}}a(XC,"bu");var ZC=class{static{a(this,"Es")}constructor(){this.map=[],this.index=new Map}add(e,t,n){eM(this,e,t,n)}consume(e){if(this.map.sort(function(i,o){return i[0]-o[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)t-=1,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let i of r)e.push(i);r=n.pop()}this.map.length=0,this.index.clear()}};function eM(e,t,n,r){if(n===0&&r.length===0)return;let i=e.index.get(t);if(i){i[1]+=n,i[2].push(...r);return}let o=[t,n,r];e.map.push(o),e.index.set(t,o)}a(eM,"RM");function tM(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]==="enter")i[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){let o=r.length-1;r[o]=r[o]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}a(tM,"cy");function nM(){return{flow:{null:{name:"table",tokenize:rM,resolveAll:iM}}}}a(nM,"xu");function rM(e,t,n){let r=this,i=0,o=0,s;return l;function l(b){let ue=r.events.length-1;for(;ue>-1;){let{type:H}=r.events[ue][1];if(H==="lineEnding"||H==="linePrefix")ue--;else break}let Y=ue>-1?r.events[ue][1].type:null,R=Y==="tableHead"||Y==="tableRow"?M:c;return R===M&&r.parser.lazy[r.now().line]?n(b):R(b)}function c(b){return e.enter("tableHead"),e.enter("tableRow"),u(b)}function u(b){return b===124||(s=!0,o+=1),h(b)}function h(b){return b===null?n(b):P(b)?o>1?(o=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),f):n(b):K(b)?U(e,h,"whitespace")(b):(o+=1,s&&(s=!1,i+=1),b===124?(e.enter("tableCellDivider"),e.consume(b),e.exit("tableCellDivider"),s=!0,h):(e.enter("data"),d(b)))}function d(b){return b===null||b===124||te(b)?(e.exit("data"),h(b)):(e.consume(b),b===92?p:d)}function p(b){return b===92||b===124?(e.consume(b),d):d(b)}function f(b){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(b):(e.enter("tableDelimiterRow"),s=!1,K(b)?U(e,m,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(b):m(b))}function m(b){return b===45||b===58?v(b):b===124?(s=!0,e.enter("tableCellDivider"),e.consume(b),e.exit("tableCellDivider"),g):D(b)}function g(b){return K(b)?U(e,v,"whitespace")(b):v(b)}function v(b){return b===58?(o+=1,s=!0,e.enter("tableDelimiterMarker"),e.consume(b),e.exit("tableDelimiterMarker"),y):b===45?(o+=1,y(b)):b===null||P(b)?A(b):D(b)}function y(b){return b===45?(e.enter("tableDelimiterFiller"),N(b)):D(b)}function N(b){return b===45?(e.consume(b),N):b===58?(s=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(b),e.exit("tableDelimiterMarker"),x):(e.exit("tableDelimiterFiller"),x(b))}function x(b){return K(b)?U(e,A,"whitespace")(b):A(b)}function A(b){return b===124?m(b):b===null||P(b)?!s||i!==o?D(b):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(b)):D(b)}function D(b){return n(b)}function M(b){return e.enter("tableRow"),I(b)}function I(b){return b===124?(e.enter("tableCellDivider"),e.consume(b),e.exit("tableCellDivider"),I):b===null||P(b)?(e.exit("tableRow"),t(b)):K(b)?U(e,I,"whitespace")(b):(e.enter("data"),F(b))}function F(b){return b===null||b===124||te(b)?(e.exit("data"),I(b)):(e.consume(b),b===92?$:F)}function $(b){return b===92||b===124?(e.consume(b),F):F(b)}}a(rM,"DM");function iM(e,t){let n=-1,r=!0,i=0,o=[0,0,0,0],s=[0,0,0,0],l=!1,c=0,u,h,d,p=new ZC;for(;++n<e.length;){let f=e[n],m=f[1];f[0]==="enter"?m.type==="tableHead"?(l=!1,c!==0&&(Ef(p,t,c,u,h),h=void 0,c=0),u={type:"table",start:Object.assign({},m.start),end:Object.assign({},m.end)},p.add(n,0,[["enter",u,t]])):m.type==="tableRow"||m.type==="tableDelimiterRow"?(r=!0,d=void 0,o=[0,0,0,0],s=[0,n+1,0,0],l&&(l=!1,h={type:"tableBody",start:Object.assign({},m.start),end:Object.assign({},m.end)},p.add(n,0,[["enter",h,t]])),i=m.type==="tableDelimiterRow"?2:h?3:1):i&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")?(r=!1,s[2]===0&&(o[1]!==0&&(s[0]=s[1],d=No(p,t,o,i,void 0,d),o=[0,0,0,0]),s[2]=n)):m.type==="tableCellDivider"&&(r?r=!1:(o[1]!==0&&(s[0]=s[1],d=No(p,t,o,i,void 0,d)),o=s,s=[o[1],n,0,0])):m.type==="tableHead"?(l=!0,c=n):m.type==="tableRow"||m.type==="tableDelimiterRow"?(c=n,o[1]!==0?(s[0]=s[1],d=No(p,t,o,i,n,d)):s[1]!==0&&(d=No(p,t,s,i,n,d)),i=0):i&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")&&(s[3]=n)}for(c!==0&&Ef(p,t,c,u,h),p.consume(t.events),n=-1;++n<t.events.length;){let f=t.events[n];f[0]==="enter"&&f[1].type==="table"&&(f[1]._align=tM(t.events,n))}return e}a(iM,"PM");function No(e,t,n,r,i,o){let s=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",l="tableContent";n[0]!==0&&(o.end=Object.assign({},Gn(t.events,n[0])),e.add(n[0],0,[["exit",o,t]]));let c=Gn(t.events,n[1]);if(o={type:s,start:Object.assign({},c),end:Object.assign({},c)},e.add(n[1],0,[["enter",o,t]]),n[2]!==0){let u=Gn(t.events,n[2]),h=Gn(t.events,n[3]),d={type:l,start:Object.assign({},u),end:Object.assign({},h)};if(e.add(n[2],0,[["enter",d,t]]),r!==2){let p=t.events[n[2]],f=t.events[n[3]];if(p[1].end=Object.assign({},f[1].end),p[1].type="chunkText",p[1].contentType="text",n[3]>n[2]+1){let m=n[2]+1,g=n[3]-n[2]-1;e.add(m,g,[])}}e.add(n[3]+1,0,[["exit",d,t]])}return i!==void 0&&(o.end=Object.assign({},Gn(t.events,i)),e.add(i,0,[["exit",o,t]]),o=void 0),o}a(No,"Os");function Ef(e,t,n,r,i){let o=[],s=Gn(t.events,n);i&&(i.end=Object.assign({},s),o.push(["exit",i,t])),r.end=Object.assign({},s),o.push(["exit",r,t]),e.add(n+1,0,o)}a(Ef,"uy");function Gn(e,t){let n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}a(Gn,"Xr");var oM={name:"tasklistCheck",tokenize:lM};function sM(){return{text:{91:oM}}}a(sM,"wu");function lM(e,t,n){let r=this;return i;function i(c){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(c):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(c),e.exit("taskListCheckMarker"),o)}function o(c){return te(c)?(e.enter("taskListCheckValueUnchecked"),e.consume(c),e.exit("taskListCheckValueUnchecked"),s):c===88||c===120?(e.enter("taskListCheckValueChecked"),e.consume(c),e.exit("taskListCheckValueChecked"),s):n(c)}function s(c){return c===93?(e.enter("taskListCheckMarker"),e.consume(c),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),l):n(c)}function l(c){return P(c)?t(c):K(c)?e.check({tokenize:aM},t,n)(c):n(c)}}a(lM,"zM");function aM(e,t,n){return U(e,r,"whitespace");function r(i){return i===null?n(i):t(i)}}a(aM,"BM");function cM(e){return Sc([zC(),WC(),XC(e),nM(),sM()])}a(cM,"fy");var uM={};function Df(e){let t=this,n=e||uM,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),o=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),s=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(cM(n)),o.push(IC()),s.push(EC(n))}a(Df,"Zr");function L(e,t){return Object.assign(e,{meta:{package:"@milkdown/preset-gfm",...t}}),e}a(L,"$");var Ta=Yr("strike_through");L(Ta,{displayName:"Attr<strikethrough>",group:"Strikethrough"});var ni=Bn("strike_through",e=>({parseDOM:[{tag:"del"},{style:"text-decoration",getAttrs:a(t=>t==="line-through","getAttrs")}],toDOM:a(t=>["del",e.get(Ta.key)(t)],"toDOM"),parseMarkdown:{match:a(t=>t.type==="delete","match"),runner:a((t,n,r)=>{t.openMark(r),t.next(n.children),t.closeMark(r)},"runner")},toMarkdown:{match:a(t=>t.type.name==="strike_through","match"),runner:a((t,n)=>{t.withMark(n,"delete")},"runner")}}));L(ni.mark,{displayName:"MarkSchema<strikethrough>",group:"Strikethrough"}),L(ni.ctx,{displayName:"MarkSchemaCtx<strikethrough>",group:"Strikethrough"});var Aa=V("ToggleStrikeThrough",e=>()=>Yi(ni.type(e)));L(Aa,{displayName:"Command<ToggleStrikethrough>",group:"Strikethrough"});var Rf=Re(e=>Cr(/(?<![\w:/])(~{1,2})(.+?)\1(?!\w|\/)$/,ni.type(e)));L(Rf,{displayName:"InputRule<strikethrough>",group:"Strikethrough"});var Ia=ze("strikeThroughKeymap",{ToggleStrikethrough:{shortcuts:"Mod-Alt-x",command:a(e=>{let t=e.get(Q);return()=>t.call(Aa.key)},"command")}});L(Ia.ctx,{displayName:"KeymapCtx<strikethrough>",group:"Strikethrough"}),L(Ia.shortcuts,{displayName:"Keymap<strikethrough>",group:"Strikethrough"});function zf(e,t){let n=t.content.firstChild;if(t.childCount!==1||n?.type.name!=="paragraph"){e.next(t.content);return}let r=n.lastChild,i=r?.type.name==="hardbreak"?n.content.cut(0,n.content.size-r.nodeSize):n.content;e.next(i)}a(zf,"py");var ri=Ix({tableGroup:"block",cellContent:"paragraph",cellAttributes:{alignment:{default:"left",getFromDOM:a(e=>e.style.textAlign||"left","getFromDOM"),setDOMAttr:a((e,t)=>{t.style=`text-align: ${e||"left"}`},"setDOMAttr")}}}),It=ce("table",()=>({...ri.table,content:"table_header_row table_row+",disableDropCursor:!0,parseMarkdown:{match:a(e=>e.type==="table","match"),runner:a((e,t,n)=>{let r=t.align,i=t.children.map((o,s)=>({...o,align:r,isHeader:s===0}));e.openNode(n),e.next(i),e.closeNode()},"runner")},toMarkdown:{match:a(e=>e.type.name==="table","match"),runner:a((e,t)=>{let n=t.content.firstChild?.content;if(!n)return;let r=[];n.forEach(i=>{r.push(i.attrs.alignment)}),e.openNode("table",void 0,{align:r}),e.next(t.content),e.closeNode()},"runner")}}));L(It.node,{displayName:"NodeSchema<table>",group:"Table"}),L(It.ctx,{displayName:"NodeSchemaCtx<table>",group:"Table"});var ii=ce("table_header_row",()=>({...ri.table_row,disableDropCursor:!0,content:"(table_header)*",parseDOM:[{tag:"tr[data-is-header]"},{tag:"tr",getAttrs:a(e=>e instanceof HTMLElement&&e.querySelector("th")?{}:!1,"getAttrs")}],toDOM(){return["tr",{"data-is-header":!0},0]},parseMarkdown:{match:a(e=>!!(e.type==="tableRow"&&e.isHeader),"match"),runner:a((e,t,n)=>{let r=t.align,i=t.children.map((o,s)=>({...o,align:r[s],isHeader:t.isHeader}));e.openNode(n),e.next(i),e.closeNode()},"runner")},toMarkdown:{match:a(e=>e.type.name==="table_header_row","match"),runner:a((e,t)=>{t.content.size!==0&&(e.openNode("tableRow",void 0,{isHeader:!0}),e.next(t.content),e.closeNode())},"runner")}}));L(ii.node,{displayName:"NodeSchema<tableHeaderRow>",group:"Table"}),L(ii.ctx,{displayName:"NodeSchemaCtx<tableHeaderRow>",group:"Table"});var Qn=ce("table_row",()=>({...ri.table_row,disableDropCursor:!0,content:"(table_cell)*",parseMarkdown:{match:a(e=>e.type==="tableRow","match"),runner:a((e,t,n)=>{let r=t.align,i=t.children.map((o,s)=>({...o,align:r[s]}));e.openNode(n),e.next(i),e.closeNode()},"runner")},toMarkdown:{match:a(e=>e.type.name==="table_row","match"),runner:a((e,t)=>{t.content.size!==0&&(e.openNode("tableRow"),e.next(t.content),e.closeNode())},"runner")}}));L(Qn.node,{displayName:"NodeSchema<tableRow>",group:"Table"}),L(Qn.ctx,{displayName:"NodeSchemaCtx<tableRow>",group:"Table"});var oi=ce("table_cell",()=>({...ri.table_cell,disableDropCursor:!0,parseMarkdown:{match:a(e=>e.type==="tableCell"&&!e.isHeader,"match"),runner:a((e,t,n)=>{let r=t.align;e.openNode(n,{alignment:r}).openNode(e.schema.nodes.paragraph).next(t.children).closeNode().closeNode()},"runner")},toMarkdown:{match:a(e=>e.type.name==="table_cell","match"),runner:a((e,t)=>{e.openNode("tableCell"),zf(e,t),e.closeNode()},"runner")}}));L(oi.node,{displayName:"NodeSchema<tableCell>",group:"Table"}),L(oi.ctx,{displayName:"NodeSchemaCtx<tableCell>",group:"Table"});var Yn=ce("table_header",()=>({...ri.table_header,disableDropCursor:!0,parseMarkdown:{match:a(e=>e.type==="tableCell"&&!!e.isHeader,"match"),runner:a((e,t,n)=>{let r=t.align;e.openNode(n,{alignment:r}),e.openNode(e.schema.nodes.paragraph),e.next(t.children),e.closeNode(),e.closeNode()},"runner")},toMarkdown:{match:a(e=>e.type.name==="table_header","match"),runner:a((e,t)=>{e.openNode("tableCell"),zf(e,t),e.closeNode()},"runner")}}));L(Yn.node,{displayName:"NodeSchema<tableHeader>",group:"Table"}),L(Yn.ctx,{displayName:"NodeSchemaCtx<tableHeader>",group:"Table"});function Pf(e,t=3,n=3){let r=Array(n).fill(0).map(()=>oi.type(e).createAndFill()),i=Array(n).fill(0).map(()=>Yn.type(e).createAndFill()),o=Array(t).fill(0).map((s,l)=>l===0?ii.type(e).create(null,i):Qn.type(e).create(null,r));return It.type(e).create(null,o)}a(Pf,"my");function Ff(e){return(t,n)=>r=>{n=n??r.selection.from;let i=r.doc.resolve(n),o=bk(c=>c.type.name==="table")(i),s=o?{node:o.node,from:o.start}:void 0,l=e==="row";if(s){let c=Z.get(s.node);if(t>=0&&t<(l?c.height:c.width)){let u=c.positionAt(l?t:c.height-1,l?c.width-1:t,s.node),h=r.doc.resolve(s.from+u),d=l?re.rowSelection:re.colSelection,p=c.positionAt(l?t:0,l?0:t,s.node),f=r.doc.resolve(s.from+p);return Fh(r.setSelection(d(h,f)))}}return r}}a(Ff,"gy");var hM=Ff("row"),dM=Ff("col");function Lf(e,t,{map:n,tableStart:r,table:i},o){let s=Array(o).fill(0).reduce((c,u,h)=>c+i.child(h).nodeSize,r),l=Array(n.width).fill(0).map((c,u)=>{let h=i.nodeAt(n.map[u]);return oi.type(e).createAndFill({alignment:h?.attrs.alignment})});return t.insert(s,Qn.type(e).create(null,l)),t}a(Lf,"yy");function pM(e){let t=ti(e.$from);if(!t)return;let n=Z.get(t.node);return n.cellsInRect({left:0,right:n.width,top:0,bottom:n.height}).map(r=>{let i=t.node.nodeAt(r),o=r+t.start;return{pos:o,start:o+1,node:i}})}a(pM,"VM");function fM(e){let t=pM(e.selection);if(t&&t[0]){let n=e.doc.resolve(t[0].pos),r=t[t.length-1];if(r){let i=e.doc.resolve(r.pos);return Fh(e.setSelection(new re(i,n)))}}return e}a(fM,"HM");var Ea=V("GoToPrevTableCell",()=>()=>rf(-1));L(Ea,{displayName:"Command<goToPrevTableCellCommand>",group:"Table"});var Da=V("GoToNextTableCell",()=>()=>rf(1));L(Da,{displayName:"Command<goToNextTableCellCommand>",group:"Table"});var Ra=V("ExitTable",e=>()=>(t,n)=>{if(!Ze(t))return!1;let{$head:r}=t.selection,i=wk(r,It.type(e));if(!i)return!1;let{to:o}=i,s=t.tr.replaceWith(o,o,pt.type(e).createAndFill());return s.setSelection(j.near(s.doc.resolve(o),1)).scrollIntoView(),n?.(s),!0});L(Ra,{displayName:"Command<breakTableCommand>",group:"Table"});var za=V("InsertTable",e=>({row:t,col:n}={})=>(r,i)=>{let{selection:o,tr:s}=r,{from:l}=o,c=Pf(e,t,n),u=s.replaceSelectionWith(c),h=j.findFrom(u.doc.resolve(l),1,!0);return h&&u.setSelection(h),i?.(u),!0});L(za,{displayName:"Command<insertTableCommand>",group:"Table"});var $f=V("MoveRow",()=>({from:e,to:t,pos:n}={})=>iS({from:e??0,to:t??0,pos:n}));L($f,{displayName:"Command<moveRowCommand>",group:"Table"});var Bf=V("MoveCol",()=>({from:e,to:t,pos:n}={})=>oS({from:e??0,to:t??0,pos:n}));L(Bf,{displayName:"Command<moveColCommand>",group:"Table"});var Vf=V("SelectRow",()=>(e={index:0})=>(t,n)=>{let{tr:r}=t;return!!n?.(hM(e.index,e.pos)(r))});L(Vf,{displayName:"Command<selectRowCommand>",group:"Table"});var jf=V("SelectCol",()=>(e={index:0})=>(t,n)=>{let{tr:r}=t;return!!n?.(dM(e.index,e.pos)(r))});L(jf,{displayName:"Command<selectColCommand>",group:"Table"});var _f=V("SelectTable",()=>()=>(e,t)=>{let{tr:n}=e;return!!t?.(fM(n))});L(_f,{displayName:"Command<selectTableCommand>",group:"Table"});var Hf=V("DeleteSelectedCells",()=>()=>(e,t)=>{let{selection:n}=e;if(!(n instanceof re))return!1;let r=n.isRowSelection(),i=n.isColSelection();return r&&i?rS(e,t):i?Yx(e,t):Zx(e,t)});L(Hf,{displayName:"Command<deleteSelectedCellsCommand>",group:"Table"});var Wf=V("AddColBefore",()=>()=>Ux);L(Wf,{displayName:"Command<addColBeforeCommand>",group:"Table"});var qf=V("AddColAfter",()=>()=>Gx);L(qf,{displayName:"Command<addColAfterCommand>",group:"Table"});var Kf=V("AddRowBefore",e=>()=>(t,n)=>{if(!Ze(t))return!1;if(n){let r=Ut(t);n(Lf(e,t.tr,r,r.top))}return!0});L(Kf,{displayName:"Command<addRowBeforeCommand>",group:"Table"});var Jf=V("AddRowAfter",e=>()=>(t,n)=>{if(!Ze(t))return!1;if(n){let r=Ut(t);n(Lf(e,t.tr,r,r.bottom))}return!0});L(Jf,{displayName:"Command<addRowAfterCommand>",group:"Table"});var Uf=V("SetAlign",()=>(e="left")=>eS("alignment",e));L(Uf,{displayName:"Command<setAlignCommand>",group:"Table"});var Gf=Re(e=>new $e(/^\|(?<col>\d+)[xX](?<row>\d+)\|\s$/,(t,n,r,i)=>{let o=t.doc.resolve(r);if(!o.node(-1).canReplaceWith(o.index(-1),o.indexAfter(-1),It.type(e)))return null;let s=Pf(e,Math.max(Number(n.groups?.row??0),2),Number(n.groups?.col)),l=t.tr.replaceRangeWith(r,i,s);return l.setSelection(q.create(l.doc,r+3)).scrollIntoView()}));L(Gf,{displayName:"InputRule<insertTableInputRule>",group:"Table"});var Qf=zb(e=>({run:a((t,n,r)=>{if(r)return t;function i(u){let h=u.childCount,d=u.lastChild?.childCount??0;if(h===0||d===0)return pt.type(e).create();let p=u.firstChild;if(!(d>0&&p&&p.childCount===0))return u;if(h>=3){let v=u.child(1),y=[];for(let A=0;A<v.childCount;A++){let D=v.child(A);y.push(Yn.type(e).create(D.attrs,D.content,D.marks))}let N=p.type.create(p.attrs,y),x=[];for(let A=2;A<h;A++)x.push(u.child(A));return u.type.create(u.attrs,[N,...x])}let f=Array(d).fill(0).map(()=>Yn.type(e).createAndFill()),m=new E(O.from(f),0,0),g=p.replace(0,0,m);return u.replace(0,p.nodeSize,new E(O.from(g),0,0))}a(i,"i");function o(u){let h=Qn.type(e),d=[],p=[],f=!1;function m(){if(p.length===0)return;let g=ii.type(e).createAndFill(),v=It.type(e).create(null,[g,...p]);d.push(i(v)),p=[]}return a(m,"p"),u.forEach(g=>{g.type===h?(f=!0,p.push(g)):(m(),d.push(g))}),m(),f?O.from(d):u}a(o,"o");function s(u){let h=o(u),d=h!==u,p=[];return h.forEach(f=>{if(f.type===It.type(e)){let m=i(f);m!==f&&(d=!0),p.push(m)}else if(f.childCount>0){let m=s(f.content);m!==f.content?(d=!0,p.push(f.copy(m))):p.push(f)}else p.push(f)}),d?O.from(p):u}a(s,"s");function l(u){let h=[],d=[];u.forEach(p=>d.push(p));for(let p=0;p<d.length;p++){let f=d[p],m=d[p+1];f.type===pt.type(e)&&f.content.size===0&&m&&m.type===It.type(e)||h.push(f)}return h.length<d.length?O.from(h):u}a(l,"l");let c=s(t.content);return c=l(c),new E(O.from(c),t.openStart,t.openEnd)},"run")}));L(Qf,{displayName:"PasteRule<table>",group:"Table"});var Pa=ze("tableKeymap",{NextCell:{priority:100,shortcuts:["Mod-]","Tab"],command:a(e=>{let t=e.get(Q);return()=>t.call(Da.key)},"command")},PrevCell:{shortcuts:["Mod-[","Shift-Tab"],command:a(e=>{let t=e.get(Q);return()=>t.call(Ea.key)},"command")},ExitTable:{shortcuts:["Mod-Enter","Enter"],command:a(e=>{let t=e.get(Q);return()=>t.call(Ra.key)},"command")}});L(Pa.ctx,{displayName:"KeymapCtx<table>",group:"Table"}),L(Pa.shortcuts,{displayName:"Keymap<table>",group:"Table"});var Fa="footnote_definition",Yf="footnoteDefinition",La=ce("footnote_definition",()=>({group:"block",content:"block+",defining:!0,attrs:{label:{default:"",validate:"string"}},parseDOM:[{tag:`dl[data-type="${Fa}"]`,getAttrs:a(e=>{if(!(e instanceof HTMLElement))throw at(e);return{label:e.dataset.label}},"getAttrs"),contentElement:"dd"}],toDOM:a(e=>{let t=e.attrs.label;return["dl",{"data-label":t,"data-type":Fa},["dt",t],["dd",0]]},"toDOM"),parseMarkdown:{match:a(({type:e})=>e===Yf,"match"),runner:a((e,t,n)=>{e.openNode(n,{label:t.label}).next(t.children).closeNode()},"runner")},toMarkdown:{match:a(e=>e.type.name===Fa,"match"),runner:a((e,t)=>{e.openNode(Yf,void 0,{label:t.attrs.label,identifier:t.attrs.label}).next(t.content).closeNode()},"runner")}}));L(La.ctx,{displayName:"NodeSchemaCtx<footnodeDef>",group:"footnote"}),L(La.node,{displayName:"NodeSchema<footnodeDef>",group:"footnote"});var $a="footnote_reference",Ba=ce("footnote_reference",()=>({group:"inline",inline:!0,atom:!0,attrs:{label:{default:"",validate:"string"}},parseDOM:[{tag:`sup[data-type="${$a}"]`,getAttrs:a(e=>{if(!(e instanceof HTMLElement))throw at(e);return{label:e.dataset.label}},"getAttrs")}],toDOM:a(e=>{let t=e.attrs.label;return["sup",{"data-label":t,"data-type":$a},t]},"toDOM"),parseMarkdown:{match:a(({type:e})=>e==="footnoteReference","match"),runner:a((e,t,n)=>{e.addNode(n,{label:t.label})},"runner")},toMarkdown:{match:a(e=>e.type.name===$a,"match"),runner:a((e,t)=>{e.addNode("footnoteReference",void 0,void 0,{label:t.attrs.label,identifier:t.attrs.label})},"runner")}}));L(Ba.ctx,{displayName:"NodeSchemaCtx<footnodeRef>",group:"footnote"}),L(Ba.node,{displayName:"NodeSchema<footnodeRef>",group:"footnote"});var Va=Tt.extendSchema(e=>t=>{let n=e(t);return{...n,attrs:{...n.attrs,checked:{default:null,validate:"boolean|null"}},parseDOM:[{tag:'li[data-item-type="task"]',getAttrs:a(r=>{if(!(r instanceof HTMLElement))throw at(r);return{label:r.dataset.label,listType:r.dataset.listType,spread:r.dataset.spread==="true",checked:r.dataset.checked?r.dataset.checked==="true":null}},"getAttrs")},...n?.parseDOM||[]],toDOM:a(r=>n.toDOM&&r.attrs.checked==null?n.toDOM(r):["li",{"data-item-type":"task","data-label":r.attrs.label,"data-list-type":r.attrs.listType,"data-spread":r.attrs.spread,"data-checked":r.attrs.checked},0],"toDOM"),parseMarkdown:{match:a(({type:r})=>r==="listItem","match"),runner:a((r,i,o)=>{if(i.checked==null){n.parseMarkdown.runner(r,i,o);return}let s=i.label!=null?`${i.label}.`:"\u2022",l=i.checked!=null?!!i.checked:null,c=i.label!=null?"ordered":"bullet",u=i.spread??!0;r.openNode(o,{label:s,listType:c,spread:u,checked:l}),r.next(i.children),r.closeNode()},"runner")},toMarkdown:{match:a(r=>r.type.name==="list_item","match"),runner:a((r,i)=>{if(i.attrs.checked==null){n.toMarkdown.runner(r,i);return}let o=i.attrs.label,s=i.attrs.listType,l=i.attrs.spread,c=i.attrs.checked;r.openNode("listItem",void 0,{label:o,listType:s,spread:l,checked:c}),r.next(i.content),r.closeNode()},"runner")}}});L(Va.node,{displayName:"NodeSchema<taskListItem>",group:"ListItem"}),L(Va.ctx,{displayName:"NodeSchemaCtx<taskListItem>",group:"ListItem"});var Xf=Re(()=>new $e(/^\[(?<checked>\s|x)\]\s$/,(e,t,n,r)=>{let i=e.doc.resolve(n),o=0,s=i.node(o);for(;s&&s.type.name!=="list_item";)o--,s=i.node(o);if(!s||s.attrs.checked!=null)return null;let l=t.groups?.checked==="x",c=i.before(o),u=e.tr;return u.deleteRange(n,r).setNodeMarkup(c,void 0,{...s.attrs,checked:l}),u}));L(Xf,{displayName:"InputRule<wrapInTaskListInputRule>",group:"ListItem"});var mM=[Ia,Pa].flat(),gM=[Gf,Xf],yM=[Rf],vM=[Qf],Zf=Ye(()=>zS);L(Zf,{displayName:"Prose<autoInsertSpanPlugin>",group:"Prose"});var kM=Ye(()=>mS({}));L(kM,{displayName:"Prose<columnResizingPlugin>",group:"Prose"});var em=Ye(()=>MS({allowTableNodeSelection:!0}));L(em,{displayName:"Prose<tableEditingPlugin>",group:"Prose"});var ja=Wt("remarkGFM",()=>Df);L(ja.plugin,{displayName:"Remark<remarkGFMPlugin>",group:"Remark"}),L(ja.options,{displayName:"RemarkConfig<remarkGFMPlugin>",group:"Remark"});var wM=new ve("MILKDOWN_KEEP_TABLE_ALIGN_PLUGIN");function bM(e,t){let n=0;return t.forEach((r,i,o)=>{r===e&&(n=o)}),n}a(bM,"GM");function xM(e,t){let n=e.content.findDiffStart(t.content);if(n==null)return null;let r=e.content.findDiffEnd(t.content);return r?{from:n,to:Math.max(r.b,n)}:null}a(xM,"YM");var tm=Ye(()=>new ye({key:wM,appendTransaction:a((e,t,n)=>{if(t.doc===n.doc)return;let r=xM(t.doc,n.doc);if(!r)return;let i,o=a((s,l)=>{if(s.type.name!=="table_cell")return;let c=n.doc.resolve(l),u=c.node(c.depth),h=c.node(c.depth-1).firstChild;if(!h)return;let d=bM(s,u),p=h.maybeChild(d);if(!p)return;let f=p.attrs.alignment;f!==s.attrs.alignment&&(i||(i=n.tr),i.setNodeMarkup(l,void 0,{...s.attrs,alignment:f}))},"o");return n.doc.nodesBetween(r.from,r.to,(s,l)=>s.type.name!=="table"?!0:(n.doc.nodesBetween(l,l+s.nodeSize,o),!1)),i},"appendTransaction")}));L(tm,{displayName:"Prose<keepTableAlignPlugin>",group:"Prose"});var SM=[tm,Zf,ja,em].flat(),CM=[Va,It,ii,Qn,Yn,oi,La,Ba,Ta,ni].flat(),MM=[Da,Ea,Ra,za,$f,Bf,Vf,jf,_f,Hf,Kf,Jf,Wf,qf,Uf,Aa],NM=[CM,gM,vM,yM,mM,MM,SM].flat(),Oo=200,fe=a(function(){},"Te");fe.prototype.append=function(e){return e.length?(e=fe.from(e),!this.length&&e||e.length<Oo&&this.leafAppend(e)||this.length<Oo&&e.leafPrepend(this)||this.appendInner(e)):this},fe.prototype.prepend=function(e){return e.length?fe.from(e).append(this):this},fe.prototype.appendInner=function(e){return new OM(this,e)},fe.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?fe.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},fe.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},fe.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},fe.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var r=[];return this.forEach(function(i,o){return r.push(e(i,o))},t,n),r},fe.from=function(e){return e instanceof fe?e:e&&e.length?new nm(e):fe.empty};var nm=(function(e){function t(r){e.call(this),this.values=r}a(t,"e"),e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(r,i){return r==0&&i==this.length?this:new t(this.values.slice(r,i))},t.prototype.getInner=function(r){return this.values[r]},t.prototype.forEachInner=function(r,i,o,s){for(var l=i;l<o;l++)if(r(this.values[l],s+l)===!1)return!1},t.prototype.forEachInvertedInner=function(r,i,o,s){for(var l=i-1;l>=o;l--)if(r(this.values[l],s+l)===!1)return!1},t.prototype.leafAppend=function(r){if(this.length+r.length<=Oo)return new t(this.values.concat(r.flatten()))},t.prototype.leafPrepend=function(r){if(this.length+r.length<=Oo)return new t(r.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t})(fe);fe.empty=new nm([]);var OM=(function(e){function t(n,r){e.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return a(t,"e"),e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(n){return n<this.left.length?this.left.get(n):this.right.get(n-this.left.length)},t.prototype.forEachInner=function(n,r,i,o){var s=this.left.length;if(r<s&&this.left.forEachInner(n,r,Math.min(i,s),o)===!1||i>s&&this.right.forEachInner(n,Math.max(r-s,0),Math.min(this.length,i)-s,o+s)===!1)return!1},t.prototype.forEachInvertedInner=function(n,r,i,o){var s=this.left.length;if(r>s&&this.right.forEachInvertedInner(n,r-s,Math.max(i,s)-s,o+s)===!1||i<s&&this.left.forEachInvertedInner(n,Math.min(r,s),i,o)===!1)return!1},t.prototype.sliceInner=function(n,r){if(n==0&&r==this.length)return this;var i=this.left.length;return r<=i?this.left.slice(n,r):n>=i?this.right.slice(n-i,r-i):this.left.slice(n,i).append(this.right.slice(0,r-i))},t.prototype.leafAppend=function(n){var r=this.right.leafAppend(n);if(r)return new t(this.left,r)},t.prototype.leafPrepend=function(n){var r=this.left.leafPrepend(n);if(r)return new t(r,this.right)},t.prototype.appendInner=function(n){return this.left.depth>=Math.max(this.right.depth,n.depth)+1?new t(this.left,new t(this.right,n)):new t(this,n)},t})(fe),rm=fe,TM=500,si=class ir{static{a(this,"t")}constructor(t,n){this.items=t,this.eventCount=n}popEvent(t,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,o;n&&(i=this.remapping(r,this.items.length),o=i.maps.length);let s=t.tr,l,c,u=[],h=[];return this.items.forEach((d,p)=>{if(!d.step){i||(i=this.remapping(r,p+1),o=i.maps.length),o--,h.push(d);return}if(i){h.push(new Gt(d.map));let f=d.step.map(i.slice(o)),m;f&&s.maybeStep(f).doc&&(m=s.mapping.maps[s.mapping.maps.length-1],u.push(new Gt(m,void 0,void 0,u.length+h.length))),o--,m&&i.appendMap(m,o)}else s.maybeStep(d.step);if(d.selection)return l=i?d.selection.map(i.slice(o)):d.selection,c=new ir(this.items.slice(0,r).append(h.reverse().concat(u)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:s,selection:l}}addTransform(t,n,r,i){let o=[],s=this.eventCount,l=this.items,c=!i&&l.length?l.get(l.length-1):null;for(let h=0;h<t.steps.length;h++){let d=t.steps[h].invert(t.docs[h]),p=new Gt(t.mapping.maps[h],d,n),f;(f=c&&c.merge(p))&&(p=f,h?o.pop():l=l.slice(0,l.length-1)),o.push(p),n&&(s++,n=void 0),i||(c=p)}let u=s-r.depth;return u>IM&&(l=AM(l,u),s-=u),new ir(l.append(o),s)}remapping(t,n){let r=new th;return this.items.forEach((i,o)=>{let s=i.mirrorOffset!=null&&o-i.mirrorOffset>=t?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,s)},t,n),r}addMaps(t){return this.eventCount==0?this:new ir(this.items.append(t.map(n=>new Gt(n))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;n=Math.min(this.items.length,n);let r=[],i=this.items.length-n,o=t.mapping,s=t.steps.length,l=this.eventCount;this.items.forEach(p=>{p.selection&&l--},i);let c=n;this.items.forEach(p=>{let f=o.getMirror(--c);if(f==null)return;s=Math.min(s,f);let m=o.maps[f];if(p.step){let g=t.steps[f].invert(t.docs[f]),v=p.selection&&p.selection.map(o.slice(c+1,f));v&&l++,r.push(new Gt(m,g,v))}else r.push(new Gt(m))},i);let u=[];for(let p=n;p<s;p++)u.push(new Gt(o.maps[p]));let h=this.items.slice(0,i).append(u).append(r),d=new ir(h,l);return d.emptyItemCount()>TM&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let t=0;return this.items.forEach(n=>{n.step||t++}),t}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,i=[],o=0;return this.items.forEach((s,l)=>{if(l>=t)i.push(s),s.selection&&o++;else if(s.step){let c=s.step.map(n.slice(r)),u=c&&c.getMap();if(r--,u&&n.appendMap(u,r),c){let h=s.selection&&s.selection.map(n.slice(r));h&&o++;let d=new Gt(u.invert(),c,h),p,f=i.length-1;(p=i.length&&i[f].merge(d))?i[f]=p:i.push(d)}}else s.map&&r--},this.items.length,0),new ir(rm.from(i.reverse()),o)}};si.empty=new si(rm.empty,0);function AM(e,t){let n;return e.forEach((r,i)=>{if(r.selection&&t--==0)return n=i,!1}),e.slice(n)}a(AM,"nN");var Gt=class Fm{static{a(this,"t")}constructor(t,n,r,i){this.map=t,this.step=n,this.selection=r,this.mirrorOffset=i}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new Fm(n.getMap().invert(),n,this.selection)}}},Qt=class{static{a(this,"Ct")}constructor(e,t,n,r,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}},IM=20;function EM(e,t,n,r){let i=n.getMeta(wn),o;if(i)return i.historyState;n.getMeta(zM)&&(e=new Qt(e.done,e.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(n.steps.length==0)return e;if(s&&s.getMeta(wn))return s.getMeta(wn).redo?new Qt(e.done.addTransform(n,void 0,r,To(t)),e.undone,im(n.mapping.maps),e.prevTime,e.prevComposition):new Qt(e.done,e.undone.addTransform(n,void 0,r,To(t)),null,e.prevTime,e.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let l=n.getMeta("composition"),c=e.prevTime==0||!s&&e.prevComposition!=l&&(e.prevTime<(n.time||0)-r.newGroupDelay||!DM(n,e.prevRanges)),u=s?_a(e.prevRanges,n.mapping):im(n.mapping.maps);return new Qt(e.done.addTransform(n,c?t.selection.getBookmark():void 0,r,To(t)),si.empty,u,n.time,l??e.prevComposition)}else return(o=n.getMeta("rebased"))?new Qt(e.done.rebased(n,o),e.undone.rebased(n,o),_a(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new Qt(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),_a(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}a(EM,"iN");function DM(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((r,i)=>{for(let o=0;o<t.length;o+=2)r<=t[o+1]&&i>=t[o]&&(n=!0)}),n}a(DM,"oN");function im(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((r,i,o,s)=>t.push(o,s));return t}a(im,"By");function _a(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let i=t.map(e[r],1),o=t.map(e[r+1],-1);i<=o&&n.push(i,o)}return n}a(_a,"zu");function RM(e,t,n){let r=To(t),i=wn.get(t).spec.config,o=(n?e.undone:e.done).popEvent(t,r);if(!o)return null;let s=o.selection.resolve(o.transform.doc),l=(n?e.done:e.undone).addTransform(o.transform,t.selection.getBookmark(),i,r),c=new Qt(n?l:o.remaining,n?o.remaining:l,null,0,-1);return o.transform.setSelection(s).setMeta(wn,{redo:n,historyState:c})}a(RM,"sN");var Ha=!1,om=null;function To(e){let t=e.plugins;if(om!=t){Ha=!1,om=t;for(let n=0;n<t.length;n++)if(t[n].spec.historyPreserveItems){Ha=!0;break}}return Ha}a(To,"Ps");var wn=new ve("history"),zM=new ve("closeHistory");function PM(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new ye({key:wn,state:{init(){return new Qt(si.empty,si.empty,null,0,-1)},apply(t,n,r){return EM(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(t,n){let r=n.inputType,i=r=="historyUndo"?sm:r=="historyRedo"?lm:null;return!i||!t.editable?!1:(n.preventDefault(),i(t.state,t.dispatch))}}}})}a(PM,"_y");function Ao(e,t){return(n,r)=>{let i=wn.getState(n);if(!i||(e?i.undone:i.done).eventCount==0)return!1;if(r){let o=RM(i,n,e);o&&r(t?o.scrollIntoView():o)}return!0}}a(Ao,"Ls");var sm=Ao(!1,!0),lm=Ao(!0,!0),gN=Ao(!1,!1),yN=Ao(!0,!1);function Xn(e,t){return Object.assign(e,{meta:{package:"@milkdown/plugin-history",...t}}),e}a(Xn,"ni");var Wa=V("Undo",()=>()=>sm);Xn(Wa,{displayName:"Command<undo>"});var qa=V("Redo",()=>()=>lm);Xn(qa,{displayName:"Command<redo>"});var Ka=dt({},"historyProviderConfig");Xn(Ka,{displayName:"Ctx<historyProviderConfig>"});var am=Ye(e=>PM(e.get(Ka.key)));Xn(am,{displayName:"Ctx<historyProviderPlugin>"});var Ja=ze("historyKeymap",{Undo:{shortcuts:"Mod-z",command:a(e=>{let t=e.get(Q);return()=>t.call(Wa.key)},"command")},Redo:{shortcuts:["Mod-y","Shift-Mod-z"],command:a(e=>{let t=e.get(Q);return()=>t.call(qa.key)},"command")}});Xn(Ja.ctx,{displayName:"KeymapCtx<history>"}),Xn(Ja.shortcuts,{displayName:"Keymap<history>"});var FM=[Ka,am,Ja,Wa,qa].flat(),LM=Ri().use(Ti).use(Df),$M=new Set(["heading","paragraph","text","emphasis","strong","delete","inlineCode","break","link","image","blockquote","list","listItem","thematicBreak","code","table","tableRow","tableCell"]);function BM(e,t,n){function r(i){return $M.has(i.type)&&(i.children?.every(r)??!0)}return a(r,"r"),LM.parse(e).children.map(i=>{let o=i.position.start.offset,s=i.position.end.offset,l=e.slice(o,s),c=r(i)?t(l):null;return{start:o,end:s,node:c?.childCount===1?c.firstChild:n(l)}})}a(BM,"Hy");function VM(e){let t=0;return e.map(n=>{let r=t;return t+=n.node.nodeSize,r})}a(VM,"jy");function jM(e,t){return e.map(n=>{if(n===null)return null;let r=t.mapResult(n,1);return r.deleted?null:r.pos})}a(jM,"Ky");function _M(e,t,n,r,i){let o=new Map;n.forEach((m,g)=>{m!==null&&o.set(m,g)});let s=[],l=[];r.forEach((m,g)=>{let v=o.get(g),y=s.length?s[s.length-1][0]:-1;v!==void 0&&v>y&&t[v].node.eq(m)&&s.push([v,l.length]),l.push(m)}),s.push([t.length,l.length]);let c=e.includes(`\r
51
+ `)?`\r
52
+ `:`
53
+ `,u=c+c,h=a((m,g)=>e.slice(m<0?0:t[m].end,g>=t.length?e.length:t[g].start),"u"),d="",p=-1,f=-1;for(let[m,g]of s){let v=m-p-1,y=i(l.slice(f+1,g)).replace(/\n+$/,"").replace(/\r?\n/g,c),N=p<0,x=m>=t.length;v===0&&y===""?d+=h(p,m):y===""?N&&x||(d+=x?h(m-1,m):h(p,p+1)):v>0?d+=h(p,p+1)+y+h(m-1,m):N?d+=h(-1,m)+y+(x?c:u):d+=u+y+h(p,m),x||(d+=e.slice(t[m].start,t[m].end)),p=m,f=g}return d}a(_M,"Wy");var Io=new ve("source-blocks"),HM=Ye(()=>new ye({key:Io,state:{init:a(()=>[],"init"),apply:a((e,t)=>e.getMeta(Io)??(e.docChanged?jM(t,e.mapping):t),"apply")}})),cm=Qr("source_block",()=>({group:"block",atom:!0,isolating:!0,attrs:{source:{default:""}},toDOM:a(e=>["pre",{class:"source-block",contenteditable:"false",title:"Unsupported Markdown \xB7 preserved as source"},["code",{},e.attrs.source]],"toDOM"),parseDOM:[{tag:"pre.source-block",getAttrs:a(e=>({source:e.textContent}),"getAttrs")}],parseMarkdown:{match:a(e=>e.type==="source_block","match"),runner:a((e,t,n)=>{e.addNode(n,{source:t.value})},"runner")},toMarkdown:{match:a(e=>e.type.name==="source_block","match"),runner:a((e,t)=>{e.addNode("html",void 0,t.attrs.source)},"runner")}})),um=Qr("doc_ref",()=>({group:"inline",inline:!0,atom:!0,attrs:{ref:{default:""}},toDOM:a(e=>["a",{class:"doc-ref",href:`/r/${String(e.attrs.ref).trim().split("/").map(encodeURIComponent).join("/")}`,title:e.attrs.ref},`[[${e.attrs.ref}]]`],"toDOM"),parseDOM:[{tag:"a.doc-ref",getAttrs:a(e=>({ref:e.getAttribute("title")??""}),"getAttrs")}],parseMarkdown:{match:a(e=>e.type==="doc_ref","match"),runner:a((e,t,n)=>{e.addNode(n,{ref:t.value})},"runner")},toMarkdown:{match:a(e=>e.type.name==="doc_ref","match"),runner:a((e,t)=>{e.addNode("html",void 0,`[[${t.attrs.ref}]]`)},"runner")}})),WM=Wt("document-references",()=>()=>e=>{function t(n){!n.children||n.type==="link"||(n.children=n.children.flatMap(r=>{if(r.type!=="text"||!r.value)return t(r),[r];let i=[],o=0;for(let s of r.value.matchAll(/\[\[([^\[\]\n]+)\]\]/g))s.index>o&&i.push({type:"text",value:r.value.slice(o,s.index)}),i.push({type:"doc_ref",value:s[1]}),o=s.index+s[0].length;return o===0?[r]:(o<r.value.length&&i.push({type:"text",value:r.value.slice(o)}),i)}))}a(t,"e"),t(e)}),hm,qM=0;function KM(){return hm??=new Promise((e,t)=>{let n=document.createElement("script");n.src=new URL("mermaid.js",import.meta.url).href,n.onload=()=>{let r=window.mermaid;r.initialize({startOnLoad:!1,securityLevel:"strict",theme:matchMedia("(prefers-color-scheme: dark)").matches?"dark":"default"}),e(r)},n.onerror=()=>t(new Error("Diagram library could not be loaded. Source is shown below.")),document.head.append(n)}),hm}a(KM,"dN");var JM=Lb(_n.node,()=>e=>{let t=e,n=0,r=document.createElement("div");r.className="code-block";let i=document.createElement("div");i.className="diagram",i.contentEditable="false";let o=document.createElement("pre"),s=document.createElement("code");o.append(s),r.append(i,o);async function l(){let c=++n,u=String(t.attrs.language).trim().toLowerCase()==="mermaid";if(i.hidden=!u,o.dataset.language=String(t.attrs.language),!u)return;let h=t.textContent;try{let d=await KM();if(c!==n)return;let p=await d.render(`diagram-${++qM}`,h);c===n&&(i.innerHTML=p.svg)}catch(d){c===n&&(i.textContent=`Diagram unavailable: ${d instanceof Error?d.message:String(d)}`)}}return a(l,"l"),l(),{dom:r,contentDOM:s,update(c){if(c.type!==t.type)return!1;let u=!c.eq(t);return t=c,u&&l(),!0},ignoreMutation(c){return c.type!=="selection"&&i.contains(c.target)},destroy(){n++}}}),UM=class Lm{static{a(this,"t")}constructor(t,n){this.editor=t,this.original=n}editor;original;blocks=[];loaded;static async create(t,n,r,i){let o=!1,s=Ye(()=>new ye({view:a(()=>({update(u,h){o&&!u.state.doc.eq(h.doc)&&i()}}),"view"),props:{handleClick(u,h,d){let p=d.target.closest("a");return p?(p.getAttribute("href")&&window.location.assign(p.href),!0):!1}}})),l=await Ib.make().config(u=>{u.set(mo,t),u.set(uo,""),u.update(fo,h=>({...h,editable:a(()=>r,"editable"),attributes:{"aria-label":"Document text",role:"textbox","aria-multiline":"true"}}))}).use(Cx).use(NM).use(FM).use(cm).use(um).use(WM).use(JM).use(HM).use(s).create(),c=new Lm(l,n);return l.action(u=>{let h=u.get(it),d=u.get(Ur);c.blocks=BM(n,d,m=>cm.type(u).create({source:m}));let p=h.topNodeType.createAndFill(null,c.blocks.map(m=>m.node)),f=u.get(Qe);f.dispatch(f.state.tr.replaceWith(0,f.state.doc.content.size,p.content).setMeta("addToHistory",!1).setMeta(Io,VM(c.blocks))),c.loaded=f.state.doc}),o=!0,c}body(){return this.editor.action(t=>{let n=t.get(Qe).state;return n.doc.eq(this.loaded)?this.original:_M(this.original,this.blocks,Io.getState(n),n.doc,r=>r.length?t.get(co)(t.get(it).topNodeType.create(null,r)):"")})}setEditable(t){this.editor.action(n=>n.get(Qe).setProps({editable:a(()=>t,"editable")}))}insertTable(){this.editor.action(t=>{t.get(Q).call(za.key,{row:3,col:2}),t.get(Qe).focus()})}insertLink(){let t=window.prompt("Link URL or document ref (use [[owner/name]])");t?.trim()&&this.editor.action(n=>{let r=n.get(Qe),{from:i,to:o}=r.state.selection,s=t.trim(),l=r.state.tr;if(s.startsWith("[[")&&s.endsWith("]]"))l.replaceSelectionWith(um.type(n).create({ref:s.slice(2,-2)}));else{if(!/^(https?:|mailto:|\/|#)/i.test(s)){window.alert("Use an http, https, mailto, relative URL, or [[document/ref]].");return}let c=n.get(it).marks.link.create({href:s});i===o?l.insertText(s).addMark(i,i+s.length,c):l.addMark(i,o,c)}r.dispatch(l),r.focus()})}async destroy(){await this.editor.destroy()}};function ie(e,t="",n=""){let r=document.createElement(e);return r.className=t,r.textContent=n,r}a(ie,"oe");var dm=document.querySelector("#app"),GM=dm.dataset.ref,pm=ie("header"),fm=ie("div","identity"),Ua=ie("div","name"),mm=ie("div","meta");fm.append(Ua,mm);var gm=ie("div","toolbar"),li=ie("button","","Link"),ai=ie("button","","Table"),ci=ie("button","primary","Save");ci.title="Save (\u2318S / Ctrl+S)";for(let e of[li,ai,ci])e.type="button";gm.append(li,ai,ci),pm.append(fm,gm);var ym=ie("main"),ui=ie("div","status");ui.setAttribute("role","status");var bn=ie("input","rationale");bn.placeholder="What I changed (optional)",bn.setAttribute("aria-label","What I changed");var Eo=ie("article");Eo.setAttribute("aria-label","Document body"),ym.append(ui,bn,Eo),dm.append(pm,ym);var G,et,Zn,xn=!1,hi=!1,er=!1,Ga=0,Qa=!1,Ya="",Xa=Promise.resolve(),Et=a((e,t=!1)=>{ui.textContent=e,ui.classList.toggle("error",t)},"Ht"),Za=a(()=>et!==void 0&&et.body()!==G.body,"Gu");function Dt(){let e=G?.editable&&!er&&!xn&&!hi;for(let t of[li,ai,ci,bn])t.disabled=!e;mm.textContent=`${G.name} \xB7 revision ${G.revision}${Za()?" \xB7 unsaved changes":""}`}a(Dt,"jt");async function QM(e,t){let n=await fetch(e,t),r=await n.json();if(!n.ok)throw new Error(r.error?.message??`Request failed (${n.status})`);return r}a(QM,"gN");async function YM(e=G.body){await et?.destroy(),Eo.replaceChildren(),et=await UM.create(Eo,e,G.editable&&!er,()=>Dt()),Dt()}a(YM,"yN");function ec(e){return Xa=Xa.then(()=>YM(e)),Xa}a(ec,"Yu");function XM(){Zn?.close(),Zn=new EventSource(`/api/events?id=${encodeURIComponent(G.id)}`),Zn.addEventListener("edited",e=>{Ya=JSON.parse(e.data).heads_key,(Ya!==G.heads_key||xn)&&tc().catch(di)}),Zn.addEventListener("deleted",()=>{er=!0,et?.setEditable(!1),Dt(),Et("This document was deleted. Your unsaved text is still on this page.",!0)}),Zn.onerror=()=>Et("Live updates disconnected. Reconnecting\u2026",!0),Zn.onopen=()=>{ui.textContent==="Live updates disconnected. Reconnecting\u2026"&&Et("Live updates connected.")}}a(XM,"kN");async function tc(){if(xn){Qa=!0;return}let e=++Ga,t=await QM(`/api/doc?ref=${encodeURIComponent(GM)}`);if(e!==Ga||G&&t.revision<G.revision||G&&t.heads_key===G.heads_key&&t.editable===G.editable)return;if(G&&(hi||Za())){G={...G,editable:t.editable,readonly_reason:t.readonly_reason},et?.setEditable(G.editable&&!er),Dt(),t.editable?t.heads_key!==G.heads_key&&Et(`Revision ${t.revision} is available. Save to merge your changes, or resolve any overlap.`):Et(`Read only: ${t.readonly_reason??"This document cannot be edited."} Your unsaved text is still on this page.`,!0);return}let n=G?.id;G=t,Ua.textContent=G.name.split("/").pop(),document.title=Ua.textContent,await ec(),Et(G.editable?"":`Read only: ${G.readonly_reason??"This document cannot be edited."}`),n!==G.id&&XM()}a(tc,"Qu");function di(e){Et(e instanceof Error?e.message:String(e),!0)}a(di,"ro");function ZM(e){hi=!0,Dt();let t=ie("dialog","conflict"),n=ie("h2","","Resolve overlapping changes"),r=ie("p","",`Nothing was saved. Compare revision ${e.revision} with your version, then edit the resolved Markdown below.`),i=ie("div","versions"),o=ie("label","",`Current \xB7 revision ${e.revision}`),s=ie("textarea");s.value=e.current_body,s.readOnly=!0,o.append(s);let l=ie("label","","Your version \xB7 edit to resolve"),c=ie("textarea");c.value=e.your_body,l.append(c),i.append(o,l);let u=ie("div","actions"),h=ie("button","","Keep editing"),d=ie("button","primary","Use resolved version"),p=a(()=>{hi=!1,t.close(),t.remove(),Dt()},"h");h.onclick=p,t.addEventListener("cancel",f=>{f.preventDefault(),p()}),d.onclick=()=>{G={...G,revision:e.revision,heads_key:e.heads_key,body:e.current_body};let f=c.value;p(),xn=!0,Dt(),ec(f).then(()=>Et("Resolved version ready. Review it, then Save.")).catch(di).finally(vm)},u.append(h,d),t.append(n,r,i,u),document.body.append(t),t.showModal()}a(ZM,"bN");function vm(){xn=!1,et?.setEditable(G.editable&&!er),Dt(),Qa&&(Qa=!1,Ya!==G.heads_key&&tc().catch(di))}a(vm,"tk");async function km(){if(!(!G?.editable||er||xn||hi||!et)){xn=!0,Dt(),et.setEditable(!1);try{let e=et.body(),t=await fetch("/api/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:G.id,base_heads_key:G.heads_key,base_body:G.body,body:e,...bn.value.trim()?{rationale:bn.value.trim()}:{}})}),n=await t.json();if(Ga++,t.status===409&&n.conflict){ZM(n.conflict);return}if(!t.ok)throw new Error(n.error?.message??`Save failed (${t.status})`);G={...G,revision:n.revision,heads_key:n.heads_key,body:n.body},await ec(),bn.value="",Et(n.merged?"Saved. Your changes were merged with the newer revision.":"Saved.")}catch(e){di(e)}finally{vm()}}}a(km,"nk"),ci.onclick=()=>{km()},li.onmousedown=ai.onmousedown=e=>e.preventDefault(),li.onclick=()=>et?.insertLink(),ai.onclick=()=>et?.insertTable(),window.addEventListener("keydown",e=>{(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()==="s"&&(e.preventDefault(),km())}),window.addEventListener("beforeunload",e=>{Za()&&(e.preventDefault(),e.returnValue="")}),tc().catch(di);