UNPKG

chrome-devtools-frontend

Version:
1 lines • 69.8 kB
import{T as e,bu as t,bz as r,by as n,E as s,ac as i,l as o,t as l,aZ as a,j as h,aR as f,aK as u,aq as d,az as p,N as c,aL as g,d as m,f as x,ay as k,aP as b,a$ as y,k as w,P as S}from"./codemirror.js";const C=1024;let L=0;class A{constructor(e,t){this.from=e,this.to=t}}class v{constructor(e={}){this.id=L++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof e&&(e=T.match(e)),t=>{let r=e(t);return void 0===r?null:[this,r]}}}v.closedBy=new v({deserialize:e=>e.split(" ")}),v.openedBy=new v({deserialize:e=>e.split(" ")}),v.group=new v({deserialize:e=>e.split(" ")}),v.isolate=new v({deserialize:e=>{if(e&&"rtl"!=e&&"ltr"!=e&&"auto"!=e)throw new RangeError("Invalid value for isolate: "+e);return e||"auto"}}),v.contextHash=new v({perNode:!0}),v.lookAhead=new v({perNode:!0}),v.mounted=new v({perNode:!0});class I{constructor(e,t,r,n=!1){this.tree=e,this.overlay=t,this.parser=r,this.bracketed=n}static get(e){return e&&e.props&&e.props[v.mounted.id]}}const B=Object.create(null);class T{constructor(e,t,r,n=0){this.name=e,this.props=t,this.id=r,this.flags=n}static define(e){let t=e.props&&e.props.length?Object.create(null):B,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(null==e.name?8:0),n=new T(e.name||"",t,e.id,r);if(e.props)for(let r of e.props)if(Array.isArray(r)||(r=r(n)),r){if(r[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[r[0].id]=r[1]}return n}prop(e){return this.props[e.id]}get isTop(){return(1&this.flags)>0}get isSkipped(){return(2&this.flags)>0}get isError(){return(4&this.flags)>0}get isAnonymous(){return(8&this.flags)>0}is(e){if("string"==typeof e){if(this.name==e)return!0;let t=this.prop(v.group);return!!t&&t.indexOf(e)>-1}return this.id==e}static match(e){let t=Object.create(null);for(let r in e)for(let n of r.split(" "))t[n]=e[r];return e=>{for(let r=e.prop(v.group),n=-1;n<(r?r.length:0);n++){let s=t[n<0?e.name:r[n]];if(s)return s}}}}T.none=new T("",Object.create(null),0,8);class E{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let r of this.types){let n=null;for(let t of e){let e=t(r);if(e){n||(n=Object.assign({},r.props));let t=e[1],s=e[0];s.combine&&s.id in n&&(t=s.combine(n[s.id],t)),n[s.id]=t}}t.push(n?new T(r.name,n,r.id,r.flags):r)}return new E(t)}}const M=new WeakMap,P=new WeakMap;var N;!function(e){e[e.ExcludeBuffers=1]="ExcludeBuffers",e[e.IncludeAnonymous=2]="IncludeAnonymous",e[e.IgnoreMounts=4]="IgnoreMounts",e[e.IgnoreOverlays=8]="IgnoreOverlays",e[e.EnterBracketed=16]="EnterBracketed"}(N||(N={}));class H{constructor(e,t,r,n,s){if(this.type=e,this.children=t,this.positions=r,this.length=n,this.props=null,s&&s.length){this.props=Object.create(null);for(let[e,t]of s)this.props["number"==typeof e?e:e.id]=t}}toString(){let e=I.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let e of this.children){let r=e.toString();r&&(t&&(t+=","),t+=r)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new Q(this.topNode,e)}cursorAt(e,t=0,r=0){let n=M.get(this)||this.topNode,s=new Q(n);return s.moveTo(e,t),M.set(this,s._tree),s}get topNode(){return new F(this,0,0,null)}resolve(e,t=0){let r=R(M.get(this)||this.topNode,e,t,!1);return M.set(this,r),r}resolveInner(e,t=0){let r=R(P.get(this)||this.topNode,e,t,!0);return P.set(this,r),r}resolveStack(e,t=0){return function(e,t,r){let n=e.resolveInner(t,r),s=null;for(let e=n instanceof F?n:n.context.parent;e;e=e.parent)if(e.index<0){let i=e.parent;(s||(s=[n])).push(i.resolve(t,r)),e=i}else{let i=I.get(e.tree);if(i&&i.overlay&&i.overlay[0].from<=t&&i.overlay[i.overlay.length-1].to>=t){let o=new F(i.tree,i.overlay[0].from+e.from,-1,e);(s||(s=[n])).push(R(o,t,r,!1))}}return s?U(s):n}(this,e,t)}iterate(e){let{enter:t,leave:r,from:n=0,to:s=this.length}=e,i=e.mode||0,o=(i&N.IncludeAnonymous)>0;for(let e=this.cursor(i|N.IncludeAnonymous);;){let i=!1;if(e.from<=s&&e.to>=n&&(!o&&e.type.isAnonymous||!1!==t(e))){if(e.firstChild())continue;i=!0}for(;i&&r&&(o||!e.type.isAnonymous)&&r(e),!e.nextSibling();){if(!e.parent())return;i=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:G(T.none,this.children,this.positions,0,this.children.length,0,this.length,(e,t,r)=>new H(this.type,e,t,r,this.propValues),e.makeTree||((e,t,r)=>new H(T.none,e,t,r)))}static build(e){return function(e){var t;let{buffer:r,nodeSet:n,maxBufferLength:s=C,reused:i=[],minRepeatType:o=n.types.length}=e,l=Array.isArray(r)?new _(r,r.length):r,a=n.types,h=0,f=0;function u(e,t,r,k,b,y){let{id:w,start:S,end:C,size:L}=l,A=f,v=h;if(L<0){if(l.next(),-1==L){let t=i[w];return r.push(t),void k.push(S-e)}if(-3==L)return void(h=w);if(-4==L)return void(f=w);throw new RangeError(`Unrecognized record size: ${L}`)}let I,B,T=a[w],E=S-e;if(C-S<=s&&(B=m(l.pos-t,b))){let t=new Uint16Array(B.size-B.skip),r=l.pos-B.size,s=t.length;for(;l.pos>r;)s=x(B.start,t,s);I=new O(t,C-B.start,n),E=B.start-e}else{let e=l.pos-L;l.next();let t=[],r=[],n=w>=o?w:-1,i=0,a=C;for(;l.pos>e;)n>=0&&l.id==n&&l.size>=0?(l.end<=a-s&&(c(t,r,S,i,l.end,a,n,A,v),i=t.length,a=l.end),l.next()):y>2500?d(S,e,t,r):u(S,e,t,r,n,y+1);if(n>=0&&i>0&&i<t.length&&c(t,r,S,i,S,a,n,A,v),t.reverse(),r.reverse(),n>-1&&i>0){let e=p(T,v);I=G(T,t,r,0,t.length,0,C-S,e,e)}else I=g(T,t,r,C-S,A-C,v)}r.push(I),k.push(E)}function d(e,t,r,i){let o=[],a=0,h=-1;for(;l.pos>t;){let{id:e,start:t,end:r,size:n}=l;if(n>4)l.next();else{if(h>-1&&t<h)break;h<0&&(h=r-s),o.push(e,t,r),a++,l.next()}}if(a){let t=new Uint16Array(4*a),s=o[o.length-2];for(let e=o.length-3,r=0;e>=0;e-=3)t[r++]=o[e],t[r++]=o[e+1]-s,t[r++]=o[e+2]-s,t[r++]=r;r.push(new O(t,o[2]-s,n)),i.push(s-e)}}function p(e,t){return(r,n,s)=>{let i,o,l=0,a=r.length-1;if(a>=0&&(i=r[a])instanceof H){if(!a&&i.type==e&&i.length==s)return i;(o=i.prop(v.lookAhead))&&(l=n[a]+i.length+o)}return g(e,r,n,s,l,t)}}function c(e,t,r,s,i,o,l,a,h){let f=[],u=[];for(;e.length>s;)f.push(e.pop()),u.push(t.pop()+r-i);e.push(g(n.types[l],f,u,o-i,a-o,h)),t.push(i-r)}function g(e,t,r,n,s,i,o){if(i){let e=[v.contextHash,i];o=o?[e].concat(o):[e]}if(s>25){let e=[v.lookAhead,s];o=o?[e].concat(o):[e]}return new H(e,t,r,n,o)}function m(e,t){let r=l.fork(),n=0,i=0,a=0,h=r.end-s,f={size:0,start:0,skip:0};e:for(let s=r.pos-e;r.pos>s;){let e=r.size;if(r.id==t&&e>=0){f.size=n,f.start=i,f.skip=a,a+=4,n+=4,r.next();continue}let l=r.pos-e;if(e<0||l<s||r.start<h)break;let u=r.id>=o?4:0,d=r.start;for(r.next();r.pos>l;){if(r.size<0){if(-3!=r.size&&-4!=r.size)break e;u+=4}else r.id>=o&&(u+=4);r.next()}i=d,n+=e,a+=u}return(t<0||n==e)&&(f.size=n,f.start=i,f.skip=a),f.size>4?f:void 0}function x(e,t,r){let{id:n,start:s,end:i,size:a}=l;if(l.next(),a>=0&&n<o){let o=r;if(a>4){let n=l.pos-(a-4);for(;l.pos>n;)r=x(e,t,r)}t[--r]=o,t[--r]=i-e,t[--r]=s-e,t[--r]=n}else-3==a?h=n:-4==a&&(f=n);return r}let k=[],b=[];for(;l.pos>0;)u(e.start||0,e.bufferStart||0,k,b,-1,0);let y=null!==(t=e.length)&&void 0!==t?t:k.length?b[0]+k[0].length:0;return new H(a[e.topID],k.reverse(),b.reverse(),y)}(e)}}H.empty=new H(T.none,[],[],0);class _{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new _(this.buffer,this.index)}}class O{constructor(e,t,r){this.buffer=e,this.length=t,this.set=r}get type(){return T.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],r=this.buffer[e+3],n=this.set.types[t],s=n.name;if(/\W/.test(s)&&!n.isError&&(s=JSON.stringify(s)),r==(e+=4))return s;let i=[];for(;e<r;)i.push(this.childString(e)),e=this.buffer[e+3];return s+"("+i.join(",")+")"}findChild(e,t,r,n,s){let{buffer:i}=this,o=-1;for(let l=e;l!=t&&!(z(s,n,i[l+1],i[l+2])&&(o=l,r>0));l=i[l+3]);return o}slice(e,t,r){let n=this.buffer,s=new Uint16Array(t-e),i=0;for(let o=e,l=0;o<t;){s[l++]=n[o++],s[l++]=n[o++]-r;let t=s[l++]=n[o++]-r;s[l++]=n[o++]-e,i=Math.max(i,t)}return new O(s,i,this.set)}}function z(e,t,r,n){switch(e){case-2:return r<t;case-1:return n>=t&&r<t;case 0:return r<t&&n>t;case 1:return r<=t&&n>t;case 2:return n>t;case 4:return!0}}function R(e,t,r,n){for(var s;e.from==e.to||(r<1?e.from>=t:e.from>t)||(r>-1?e.to<=t:e.to<t);){let t=!n&&e instanceof F&&e.index<0?null:e.parent;if(!t)return e;e=t}let i=n?0:N.IgnoreOverlays;if(n)for(let n=e,o=n.parent;o;n=o,o=n.parent)n instanceof F&&n.index<0&&(null===(s=o.enter(t,r,i))||void 0===s?void 0:s.from)!=n.from&&(e=o);for(;;){let n=e.enter(t,r,i);if(!n)return e;e=n}}class D{cursor(e=0){return new Q(this,e)}getChild(e,t=null,r=null){let n=X(this,e,t,r);return n.length?n[0]:null}getChildren(e,t=null,r=null){return X(this,e,t,r)}resolve(e,t=0){return R(this,e,t,!1)}resolveInner(e,t=0){return R(this,e,t,!0)}matchContext(e){return j(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),r=this;for(;t;){let e=t.lastChild;if(!e||e.to!=t.to)break;e.type.isError&&e.from==e.to?(r=t,t=e.prevSibling):t=e}return r}get node(){return this}get next(){return this.parent}}class F extends D{constructor(e,t,r,n){super(),this._tree=e,this.from=t,this.index=r,this._parent=n}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,r,n,s=0){for(let i=this;;){for(let{children:o,positions:l}=i._tree,a=t>0?o.length:-1;e!=a;e+=t){let a,h=o[e],f=l[e]+i.from;if(s&N.EnterBracketed&&h instanceof H&&(a=I.get(h))&&!a.overlay&&a.bracketed&&r>=f&&r<=f+h.length||z(n,r,f,f+h.length))if(h instanceof O){if(s&N.ExcludeBuffers)continue;let o=h.findChild(0,h.buffer.length,t,r-f,n);if(o>-1)return new q(new $(i,h,e,f),null,o)}else if(s&N.IncludeAnonymous||!h.type.isAnonymous||V(h)){let o;if(!(s&N.IgnoreMounts)&&(o=I.get(h))&&!o.overlay)return new F(o.tree,f,e,i);let l=new F(h,f,e,i);return s&N.IncludeAnonymous||!l.type.isAnonymous?l:l.nextChild(t<0?h.children.length-1:0,t,r,n,s)}}if(s&N.IncludeAnonymous||!i.type.isAnonymous)return null;if(e=i.index>=0?i.index+t:t<0?-1:i._parent._tree.children.length,i=i._parent,!i)return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,t,r=0){let n;if(!(r&N.IgnoreOverlays)&&(n=I.get(this._tree))&&n.overlay){let s=e-this.from,i=r&N.EnterBracketed&&n.bracketed;for(let{from:e,to:r}of n.overlay)if((t>0||i?e<=s:e<s)&&(t<0||i?r>=s:r>s))return new F(n.tree,n.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,r)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function X(e,t,r,n){let s=e.cursor(),i=[];if(!s.firstChild())return i;if(null!=r)for(let e=!1;!e;)if(e=s.type.is(r),!s.nextSibling())return i;for(;;){if(null!=n&&s.type.is(n))return i;if(s.type.is(t)&&i.push(s.node),!s.nextSibling())return null==n?i:[]}}function j(e,t,r=t.length-1){for(let n=e;r>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(t[r]&&t[r]!=n.name)return!1;r--}}return!0}class ${constructor(e,t,r,n){this.parent=e,this.buffer=t,this.index=r,this.start=n}}class q extends D{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,r){super(),this.context=e,this._parent=t,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,t,r){let{buffer:n}=this.context,s=n.findChild(this.index+4,n.buffer[this.index+3],e,t-this.context.start,r);return s<0?null:new q(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,t,r=0){if(r&N.ExcludeBuffers)return null;let{buffer:n}=this.context,s=n.findChild(this.index+4,n.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return s<0?null:new q(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new q(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new q(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:r}=this.context,n=this.index+4,s=r.buffer[this.index+3];if(s>n){let i=r.buffer[this.index+1];e.push(r.slice(n,s,i)),t.push(0)}return new H(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function U(e){if(!e.length)return null;let t=0,r=e[0];for(let n=1;n<e.length;n++){let s=e[n];(s.from>r.from||s.to<r.to)&&(r=s,t=n)}let n=r instanceof F&&r.index<0?null:r.parent,s=e.slice();return n?s[t]=n:s.splice(t,1),new Z(s,r)}class Z{constructor(e,t){this.heads=e,this.node=t}get next(){return U(this.heads)}}class Q{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~N.EnterBracketed,e instanceof F)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return!!e&&(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0)}yieldBuf(e,t){this.index=e;let{start:r,buffer:n}=this.buffer;return this.type=t||n.set.types[n.buffer[e]],this.from=r+n.buffer[e+1],this.to=r+n.buffer[e+2],!0}yield(e){return!!e&&(e instanceof F?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)))}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,r,this.mode));let{buffer:n}=this.buffer,s=n.findChild(this.index+4,n.buffer[this.index+3],e,t-this.buffer.start,r);return!(s<0)&&(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,r=this.mode){return this.buffer?!(r&N.ExcludeBuffers)&&this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&N.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&N.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return!!this._tree._parent&&this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode));let{buffer:t}=this.buffer,r=this.stack.length-1;if(e<0){let e=r<0?0:this.stack[r]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(r<0?t.buffer.length:t.buffer[this.stack[r]+3]))return this.yieldBuf(e)}return r<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,r,{buffer:n}=this;if(n){if(e>0){if(this.index<n.buffer.buffer.length)return!1}else for(let e=0;e<this.index;e++)if(n.buffer.buffer[e+3]<this.index)return!1;({index:t,parent:r}=n)}else({index:t,_parent:r}=this._tree);for(;r;({index:t,_parent:r}=r))if(t>-1)for(let n=t+e,s=e<0?-1:r._tree.children.length;n!=s;n+=e){let e=r._tree.children[n];if(this.mode&N.IncludeAnonymous||e instanceof O||!e.type.isAnonymous||V(e))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,r=0;if(e&&e.context==this.buffer)e:for(let n=this.index,s=this.stack.length;s>=0;){for(let i=e;i;i=i._parent)if(i.index==n){if(n==this.index)return i;t=i,r=s+1;break e}n=this.stack[--s]}for(let e=r;e<this.stack.length;e++)t=new q(this.buffer,t,this.stack[e]);return this.bufferNode=new q(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let r=0;;){let n=!1;if(this.type.isAnonymous||!1!==e(this)){if(this.firstChild()){r++;continue}this.type.isAnonymous||(n=!0)}for(;;){if(n&&t&&t(this),n=this.type.isAnonymous,!r)return;if(this.nextSibling())break;this.parent(),r--,n=!0}}}matchContext(e){if(!this.buffer)return j(this.node.parent,e);let{buffer:t}=this.buffer,{types:r}=t.set;for(let n=e.length-1,s=this.stack.length-1;n>=0;s--){if(s<0)return j(this._tree,e,n);let i=r[t.buffer[this.stack[s]]];if(!i.isAnonymous){if(e[n]&&e[n]!=i.name)return!1;n--}}return!0}}function V(e){return e.children.some(e=>e instanceof O||!e.type.isAnonymous||V(e))}const W=new WeakMap;function J(e,t){if(!e.isAnonymous||t instanceof O||t.type!=e)return 1;let r=W.get(t);if(null==r){r=1;for(let n of t.children){if(n.type!=e||!(n instanceof H)){r=1;break}r+=J(e,n)}W.set(t,r)}return r}function G(e,t,r,n,s,i,o,l,a){let h=0;for(let r=n;r<s;r++)h+=J(e,t[r]);let f=Math.ceil(1.5*h/8),u=[],d=[];return function t(r,n,s,o,l){for(let h=s;h<o;){let s=h,p=n[h],c=J(e,r[h]);for(h++;h<o;h++){let t=J(e,r[h]);if(c+t>=f)break;c+=t}if(h==s+1){if(c>f){let e=r[s];t(e.children,e.positions,0,e.children.length,n[s]+l);continue}u.push(r[s])}else{let t=n[h-1]+r[h-1].length-p;u.push(G(e,r,n,s,h,p,t,null,a))}d.push(p+l-i)}}(t,r,n,s,0),(l||a)(u,d,o)}class K{constructor(e,t,r,n,s=!1,i=!1){this.from=e,this.to=t,this.tree=r,this.offset=n,this.open=(s?1:0)|(i?2:0)}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(e,t=[],r=!1){let n=[new K(0,e.length,e,0,!1,r)];for(let r of t)r.to>e.length&&n.push(r);return n}static applyChanges(e,t,r=128){if(!t.length)return e;let n=[],s=1,i=e.length?e[0]:null;for(let o=0,l=0,a=0;;o++){let h=o<t.length?t[o]:null,f=h?h.fromA:1e9;if(f-l>=r)for(;i&&i.from<f;){let t=i;if(l>=t.from||f<=t.to||a){let e=Math.max(t.from,l)-a,r=Math.min(t.to,f)-a;t=e>=r?null:new K(e,r,t.tree,t.offset+a,o>0,!!h)}if(t&&n.push(t),i.to>f)break;i=s<e.length?e[s++]:null}if(!h)break;l=h.toA,a=h.toA-h.toB}return n}}class Y{startParse(e,t,r){return"string"==typeof e&&(e=new ee(e)),r=r?r.length?r.map(e=>new A(e.from,e.to)):[new A(0,0)]:[new A(0,e.length)],this.createParse(e,t||[],r)}parse(e,t,r){let n=this.startParse(e,t,r);for(;;){let e=n.advance();if(e)return e}}}class ee{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}class te{constructor(e,t,r,n,s,i){this.parser=e,this.parse=t,this.overlay=r,this.bracketed=n,this.target=s,this.from=i}}function re(e){if(!e.length||e.some(e=>e.from>=e.to))throw new RangeError("Invalid inner parse ranges given: "+JSON.stringify(e))}class ne{constructor(e,t,r,n,s,i,o,l){this.parser=e,this.predicate=t,this.mounts=r,this.index=n,this.start=s,this.bracketed=i,this.target=o,this.prev=l,this.depth=0,this.ranges=[]}}const se=new v({perNode:!0});class ie{constructor(e,t,r,n,s){this.nest=t,this.input=r,this.fragments=n,this.ranges=s,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=e}advance(){if(this.baseParse){let e=this.baseParse.advance();if(!e)return null;if(this.baseParse=null,this.baseTree=e,this.startInner(),null!=this.stoppedAt)for(let e of this.inner)e.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let e=this.baseTree;return null!=this.stoppedAt&&(e=new H(e.type,e.children,e.positions,e.length,e.propValues.concat([[se,this.stoppedAt]]))),e}let e=this.inner[this.innerDone],t=e.parse.advance();if(t){this.innerDone++;let r=Object.assign(Object.create(null),e.target.props);r[v.mounted.id]=new I(t,e.overlay,e.parser,e.bracketed),e.target.props=r}return null}get parsedPos(){if(this.baseParse)return 0;let e=this.input.length;for(let t=this.innerDone;t<this.inner.length;t++)this.inner[t].from<e&&(e=Math.min(e,this.inner[t].parse.parsedPos));return e}stopAt(e){if(this.stoppedAt=e,this.baseParse)this.baseParse.stopAt(e);else for(let t=this.innerDone;t<this.inner.length;t++)this.inner[t].parse.stopAt(e)}startInner(){let e=new fe(this.fragments),t=null,r=null,n=new Q(new F(this.baseTree,this.ranges[0].from,0,null),N.IncludeAnonymous|N.IgnoreMounts);e:for(let s,i;;){let o,l=!0;if(null!=this.stoppedAt&&n.from>=this.stoppedAt)l=!1;else if(e.hasNode(n)){if(t){let e=t.mounts.find(e=>e.frag.from<=n.from&&e.frag.to>=n.to&&e.mount.overlay);if(e)for(let r of e.mount.overlay){let s=r.from+e.pos,i=r.to+e.pos;s>=n.from&&i<=n.to&&!t.ranges.some(e=>e.from<i&&e.to>s)&&t.ranges.push({from:s,to:i})}}l=!1}else if(r&&(i=oe(r.ranges,n.from,n.to)))l=2!=i;else if(!n.type.isAnonymous&&(s=this.nest(n,this.input))&&(n.from<n.to||!s.overlay)){n.tree||(ae(n),t&&t.depth++,r&&r.depth++);let i=e.findMounts(n.from,s.parser);if("function"==typeof s.overlay)t=new ne(s.parser,s.overlay,i,this.inner.length,n.from,!!s.bracketed,n.tree,t);else{let e=ue(this.ranges,s.overlay||(n.from<n.to?[new A(n.from,n.to)]:[]));e.length&&re(e),!e.length&&s.overlay||this.inner.push(new te(s.parser,e.length?s.parser.startParse(this.input,pe(i,e),e):s.parser.startParse(""),s.overlay?s.overlay.map(e=>new A(e.from-n.from,e.to-n.from)):null,!!s.bracketed,n.tree,e.length?e[0].from:n.from)),s.overlay?e.length&&(r={ranges:e,depth:0,prev:r}):l=!1}}else if(t&&(o=t.predicate(n))&&(!0===o&&(o=new A(n.from,n.to)),o.from<o.to)){let e=t.ranges.length-1;e>=0&&t.ranges[e].to==o.from?t.ranges[e]={from:t.ranges[e].from,to:o.to}:t.ranges.push(o)}if(l&&n.firstChild())t&&t.depth++,r&&r.depth++;else for(;!n.nextSibling();){if(!n.parent())break e;if(t&&! --t.depth){let e=ue(this.ranges,t.ranges);e.length&&(re(e),this.inner.splice(t.index,0,new te(t.parser,t.parser.startParse(this.input,pe(t.mounts,e),e),t.ranges.map(e=>new A(e.from-t.start,e.to-t.start)),t.bracketed,t.target,e[0].from))),t=t.prev}r&&! --r.depth&&(r=r.prev)}}}}function oe(e,t,r){for(let n of e){if(n.from>=r)break;if(n.to>t)return n.from<=t&&n.to>=r?2:1}return 0}function le(e,t,r,n,s,i){if(t<r){let o=e.buffer[t+1];n.push(e.slice(t,r,o)),s.push(o-i)}}function ae(e){let{node:t}=e,r=[],n=t.context.buffer;do{r.push(e.index),e.parent()}while(!e.tree);let s=e.tree,i=s.children.indexOf(n),o=s.children[i],l=o.buffer,a=[i];s.children[i]=function e(n,s,i,h,f,u){let d=r[u],p=[],c=[];le(o,n,d,p,c,h);let g=l[d+1],m=l[d+2];a.push(p.length);let x=u?e(d+4,l[d+3],o.set.types[l[d]],g,m-g,u-1):t.toTree();return p.push(x),c.push(g-h),le(o,l[d+3],s,p,c,h),new H(i,p,c,f)}(0,l.length,T.none,0,o.length,r.length-1);for(let t of a){let r=e.tree.children[t],n=e.tree.positions[t];e.yield(new F(r,n+e.from,t,e._tree))}}class he{constructor(e,t){this.offset=t,this.done=!1,this.cursor=e.cursor(N.IncludeAnonymous|N.IgnoreMounts)}moveTo(e){let{cursor:t}=this,r=e-this.offset;for(;!this.done&&t.from<r;)if(t.to>=e&&t.enter(r,1,N.IgnoreOverlays|N.ExcludeBuffers));else{if(!(t.to<=e))break;t.next(!1)||(this.done=!0)}}hasNode(e){if(this.moveTo(e.from),!this.done&&this.cursor.from+this.offset==e.from&&this.cursor.tree)for(let t=this.cursor.tree;;){if(t==e.tree)return!0;if(!(t.children.length&&0==t.positions[0]&&t.children[0]instanceof H))break;t=t.children[0]}return!1}}let fe=class{constructor(e){var t;if(this.fragments=e,this.curTo=0,this.fragI=0,e.length){let r=this.curFrag=e[0];this.curTo=null!==(t=r.tree.prop(se))&&void 0!==t?t:r.to,this.inner=new he(r.tree,-r.offset)}else this.curFrag=this.inner=null}hasNode(e){for(;this.curFrag&&e.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=e.from&&this.curTo>=e.to&&this.inner.hasNode(e)}nextFrag(){var e;if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let t=this.curFrag=this.fragments[this.fragI];this.curTo=null!==(e=t.tree.prop(se))&&void 0!==e?e:t.to,this.inner=new he(t.tree,-t.offset)}}findMounts(e,t){var r;let n=[];if(this.inner){this.inner.cursor.moveTo(e,1);for(let e=this.inner.cursor.node;e;e=e.parent){let s=null===(r=e.tree)||void 0===r?void 0:r.prop(v.mounted);if(s&&s.parser==t)for(let t=this.fragI;t<this.fragments.length;t++){let r=this.fragments[t];if(r.from>=e.to)break;r.tree==this.curFrag.tree&&n.push({frag:r,pos:e.from-r.offset,mount:s})}}}return n}};function ue(e,t){let r=null,n=t;for(let s=1,i=0;s<e.length;s++){let o=e[s-1].to,l=e[s].from;for(;i<n.length;i++){let e=n[i];if(e.from>=l)break;e.to<=o||(r||(n=r=t.slice()),e.from<o?(r[i]=new A(e.from,o),e.to>l&&r.splice(i+1,0,new A(l,e.to))):e.to>l?r[i--]=new A(l,e.to):r.splice(i--,1))}}return n}function de(e,t,r,n){let s=0,i=0,o=!1,l=!1,a=-1e9,h=[];for(;;){let f=s==e.length?1e9:o?e[s].to:e[s].from,u=i==t.length?1e9:l?t[i].to:t[i].from;if(o!=l){let e=Math.max(a,r),t=Math.min(f,u,n);e<t&&h.push(new A(e,t))}if(a=Math.min(f,u),1e9==a)break;f==a&&(o?(o=!1,s++):o=!0),u==a&&(l?(l=!1,i++):l=!0)}return h}function pe(e,t){let r=[];for(let{pos:n,mount:s,frag:i}of e){let e=n+(s.overlay?s.overlay[0].from:0),o=e+s.tree.length,l=Math.max(i.from,e),a=Math.min(i.to,o);if(s.overlay){let o=de(t,s.overlay.map(e=>new A(e.from+n,e.to+n)),l,a);for(let t=0,n=l;;t++){let l=t==o.length,h=l?a:o[t].from;if(h>n&&r.push(new K(n,h,s.tree,-e,i.from>=n||i.openStart,i.to<=h||i.openEnd)),l)break;n=o[t].to}}else r.push(new K(l,a,s.tree,-e,i.from>=e||i.openStart,i.to<=o||i.openEnd))}return r}class ce{static create(e,t,r,n,s){return new ce(e,t,r,n+(n<<8)+e+(t<<4)|0,s,[],[])}constructor(e,t,r,n,s,i,o){this.type=e,this.value=t,this.from=r,this.hash=n,this.end=s,this.children=i,this.positions=o,this.hashProp=[[v.contextHash,n]]}addChild(e,t){e.prop(v.contextHash)!=this.hash&&(e=new H(e.type,e.children,e.positions,e.length,this.hashProp)),this.children.push(e),this.positions.push(t)}toTree(e,t=this.end){let r=this.children.length-1;return r>=0&&(t=Math.max(t,this.positions[r]+this.children[r].length+this.from)),new H(e.types[this.type],this.children,this.positions,t-this.from).balance({makeTree:(e,t,r)=>new H(T.none,e,t,r,this.hashProp)})}}var ge;!function(e){e[e.Document=1]="Document",e[e.CodeBlock=2]="CodeBlock",e[e.FencedCode=3]="FencedCode",e[e.Blockquote=4]="Blockquote",e[e.HorizontalRule=5]="HorizontalRule",e[e.BulletList=6]="BulletList",e[e.OrderedList=7]="OrderedList",e[e.ListItem=8]="ListItem",e[e.ATXHeading1=9]="ATXHeading1",e[e.ATXHeading2=10]="ATXHeading2",e[e.ATXHeading3=11]="ATXHeading3",e[e.ATXHeading4=12]="ATXHeading4",e[e.ATXHeading5=13]="ATXHeading5",e[e.ATXHeading6=14]="ATXHeading6",e[e.SetextHeading1=15]="SetextHeading1",e[e.SetextHeading2=16]="SetextHeading2",e[e.HTMLBlock=17]="HTMLBlock",e[e.LinkReference=18]="LinkReference",e[e.Paragraph=19]="Paragraph",e[e.CommentBlock=20]="CommentBlock",e[e.ProcessingInstructionBlock=21]="ProcessingInstructionBlock",e[e.Escape=22]="Escape",e[e.Entity=23]="Entity",e[e.HardBreak=24]="HardBreak",e[e.Emphasis=25]="Emphasis",e[e.StrongEmphasis=26]="StrongEmphasis",e[e.Link=27]="Link",e[e.Image=28]="Image",e[e.InlineCode=29]="InlineCode",e[e.HTMLTag=30]="HTMLTag",e[e.Comment=31]="Comment",e[e.ProcessingInstruction=32]="ProcessingInstruction",e[e.Autolink=33]="Autolink",e[e.HeaderMark=34]="HeaderMark",e[e.QuoteMark=35]="QuoteMark",e[e.ListMark=36]="ListMark",e[e.LinkMark=37]="LinkMark",e[e.EmphasisMark=38]="EmphasisMark",e[e.CodeMark=39]="CodeMark",e[e.CodeText=40]="CodeText",e[e.CodeInfo=41]="CodeInfo",e[e.LinkTitle=42]="LinkTitle",e[e.LinkLabel=43]="LinkLabel",e[e.URL=44]="URL"}(ge||(ge={}));class me{constructor(e,t){this.start=e,this.content=t,this.marks=[],this.parsers=[]}}class xe{constructor(){this.text="",this.baseIndent=0,this.basePos=0,this.depth=0,this.markers=[],this.pos=0,this.indent=0,this.next=-1}forward(){this.basePos>this.pos&&this.forwardInner()}forwardInner(){let e=this.skipSpace(this.basePos);this.indent=this.countIndent(e,this.pos,this.indent),this.pos=e,this.next=e==this.text.length?-1:this.text.charCodeAt(e)}skipSpace(e){return we(this.text,e)}reset(e){for(this.text=e,this.baseIndent=this.basePos=this.pos=this.indent=0,this.forwardInner(),this.depth=1;this.markers.length;)this.markers.pop()}moveBase(e){this.basePos=e,this.baseIndent=this.countIndent(e,this.pos,this.indent)}moveBaseColumn(e){this.baseIndent=e,this.basePos=this.findColumn(e)}addMarker(e){this.markers.push(e)}countIndent(e,t=0,r=0){for(let n=t;n<e;n++)r+=9==this.text.charCodeAt(n)?4-r%4:1;return r}findColumn(e){let t=0;for(let r=0;t<this.text.length&&r<e;t++)r+=9==this.text.charCodeAt(t)?4-r%4:1;return t}scrub(){if(!this.baseIndent)return this.text;let e="";for(let t=0;t<this.basePos;t++)e+=" ";return e+this.text.slice(this.basePos)}}function ke(e,t,r){if(r.pos==r.text.length||e!=t.block&&r.indent>=t.stack[r.depth+1].value+r.baseIndent)return!0;if(r.indent>=r.baseIndent+4)return!1;let n=(e.type==ge.OrderedList?Be:Ie)(r,t,!1);return n>0&&(e.type!=ge.BulletList||Ae(r,t,!1)<0)&&r.text.charCodeAt(r.pos+n-1)==e.value}const be={[ge.Blockquote]:(e,t,r)=>62==r.next&&(r.markers.push(rt(ge.QuoteMark,t.lineStart+r.pos,t.lineStart+r.pos+1)),r.moveBase(r.pos+(ye(r.text.charCodeAt(r.pos+1))?2:1)),e.end=t.lineStart+r.text.length,!0),[ge.ListItem]:(e,t,r)=>!(r.indent<r.baseIndent+e.value&&r.next>-1)&&(r.moveBaseColumn(r.baseIndent+e.value),!0),[ge.OrderedList]:ke,[ge.BulletList]:ke,[ge.Document]:()=>!0};function ye(e){return 32==e||9==e||10==e||13==e}function we(e,t=0){for(;t<e.length&&ye(e.charCodeAt(t));)t++;return t}function Se(e,t,r){for(;t>r&&ye(e.charCodeAt(t-1));)t--;return t}function Ce(e){if(96!=e.next&&126!=e.next)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==e.next;)t++;if(t<e.pos+3)return-1;if(96==e.next)for(let r=t;r<e.text.length;r++)if(96==e.text.charCodeAt(r))return-1;return t}function Le(e){return 62!=e.next?-1:32==e.text.charCodeAt(e.pos+1)?2:1}function Ae(e,t,r){if(42!=e.next&&45!=e.next&&95!=e.next)return-1;let n=1;for(let t=e.pos+1;t<e.text.length;t++){let r=e.text.charCodeAt(t);if(r==e.next)n++;else if(!ye(r))return-1}return r&&45==e.next&&Ee(e)>-1&&e.depth==t.stack.length&&t.parser.leafBlockParsers.indexOf(je.SetextHeading)>-1||n<3?-1:1}function ve(e,t){for(let r=e.stack.length-1;r>=0;r--)if(e.stack[r].type==t)return!0;return!1}function Ie(e,t,r){return 45!=e.next&&43!=e.next&&42!=e.next||e.pos!=e.text.length-1&&!ye(e.text.charCodeAt(e.pos+1))||!(!r||ve(t,ge.BulletList)||e.skipSpace(e.pos+2)<e.text.length)?-1:1}function Be(e,t,r){let n=e.pos,s=e.next;for(;s>=48&&s<=57;){if(n++,n==e.text.length)return-1;s=e.text.charCodeAt(n)}return n==e.pos||n>e.pos+9||46!=s&&41!=s||n<e.text.length-1&&!ye(e.text.charCodeAt(n+1))||r&&!ve(t,ge.OrderedList)&&(e.skipSpace(n+1)==e.text.length||n>e.pos+1||49!=e.next)?-1:n+1-e.pos}function Te(e){if(35!=e.next)return-1;let t=e.pos+1;for(;t<e.text.length&&35==e.text.charCodeAt(t);)t++;if(t<e.text.length&&32!=e.text.charCodeAt(t))return-1;let r=t-e.pos;return r>6?-1:r}function Ee(e){if(45!=e.next&&61!=e.next||e.indent>=e.baseIndent+4)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==e.next;)t++;let r=t;for(;t<e.text.length&&ye(e.text.charCodeAt(t));)t++;return t==e.text.length?r:-1}const Me=/^[ \t]*$/,Pe=/-->/,Ne=/\?>/,He=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,Pe],[/^\s*<\?/,Ne],[/^\s*<![A-Z]/,/>/],[/^\s*<!\[CDATA\[/,/\]\]>/],[/^\s*<\/?(?: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|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|\/?>|$)/i,Me],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,Me]];function _e(e,t,r){if(60!=e.next)return-1;let n=e.text.slice(e.pos);for(let e=0,t=He.length-(r?1:0);e<t;e++)if(He[e][0].test(n))return e;return-1}function Oe(e,t){let r=e.countIndent(t,e.pos,e.indent),n=e.skipSpace(t),s=e.countIndent(n,t,r);return s>=r+5||n==e.text.length?r+1:s}function ze(e,t,r){let n=e.length-1;n>=0&&e[n].to==t&&e[n].type==ge.CodeText?e[n].to=r:e.push(rt(ge.CodeText,t,r))}const Re={LinkReference:void 0,IndentedCode(e,t){let r=t.baseIndent+4;if(t.indent<r)return!1;let n=t.findColumn(r),s=e.lineStart+n,i=e.lineStart+t.text.length,o=[],l=[];for(ze(o,s,i);e.nextLine()&&t.depth>=e.stack.length;)if(t.pos==t.text.length){ze(l,e.lineStart-1,e.lineStart);for(let e of t.markers)l.push(e)}else{if(t.indent<r)break;{if(l.length){for(let e of l)e.type==ge.CodeText?ze(o,e.from,e.to):o.push(e);l=[]}ze(o,e.lineStart-1,e.lineStart);for(let e of t.markers)o.push(e);i=e.lineStart+t.text.length;let r=e.lineStart+t.findColumn(t.baseIndent+4);r<i&&ze(o,r,i)}}return l.length&&(l=l.filter(e=>e.type!=ge.CodeText),l.length&&(t.markers=l.concat(t.markers))),e.addNode(e.buffer.writeElements(o,-s).finish(ge.CodeBlock,i-s),s),!0},FencedCode(e,t){let r=Ce(t);if(r<0)return!1;let n=e.lineStart+t.pos,s=t.next,i=r-t.pos,o=t.skipSpace(r),l=Se(t.text,t.text.length,o),a=[rt(ge.CodeMark,n,n+i)];o<l&&a.push(rt(ge.CodeInfo,e.lineStart+o,e.lineStart+l));for(let r=!0,n=!0,o=!1;e.nextLine()&&t.depth>=e.stack.length;r=!1){let l=t.pos;if(t.indent-t.baseIndent<4)for(;l<t.text.length&&t.text.charCodeAt(l)==s;)l++;if(l-t.pos>=i&&t.skipSpace(l)==t.text.length){for(let e of t.markers)a.push(e);n&&o&&ze(a,e.lineStart-1,e.lineStart),a.push(rt(ge.CodeMark,e.lineStart+t.pos,e.lineStart+l)),e.nextLine();break}{o=!0,r||(ze(a,e.lineStart-1,e.lineStart),n=!1);for(let e of t.markers)a.push(e);let s=e.lineStart+t.basePos,i=e.lineStart+t.text.length;s<i&&(ze(a,s,i),n=!1)}}return e.addNode(e.buffer.writeElements(a,-n).finish(ge.FencedCode,e.prevLineEnd()-n),n),!0},Blockquote(e,t){let r=Le(t);return!(r<0)&&(e.startContext(ge.Blockquote,t.pos),e.addNode(ge.QuoteMark,e.lineStart+t.pos,e.lineStart+t.pos+1),t.moveBase(t.pos+r),null)},HorizontalRule(e,t){if(Ae(t,e,!1)<0)return!1;let r=e.lineStart+t.pos;return e.nextLine(),e.addNode(ge.HorizontalRule,r),!0},BulletList(e,t){let r=Ie(t,e,!1);if(r<0)return!1;e.block.type!=ge.BulletList&&e.startContext(ge.BulletList,t.basePos,t.next);let n=Oe(t,t.pos+1);return e.startContext(ge.ListItem,t.basePos,n-t.baseIndent),e.addNode(ge.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+r),t.moveBaseColumn(n),null},OrderedList(e,t){let r=Be(t,e,!1);if(r<0)return!1;e.block.type!=ge.OrderedList&&e.startContext(ge.OrderedList,t.basePos,t.text.charCodeAt(t.pos+r-1));let n=Oe(t,t.pos+r);return e.startContext(ge.ListItem,t.basePos,n-t.baseIndent),e.addNode(ge.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+r),t.moveBaseColumn(n),null},ATXHeading(e,t){let r=Te(t);if(r<0)return!1;let n=t.pos,s=e.lineStart+n,i=Se(t.text,t.text.length,n),o=i;for(;o>n&&t.text.charCodeAt(o-1)==t.next;)o--;o!=i&&o!=n&&ye(t.text.charCodeAt(o-1))||(o=t.text.length);let l=e.buffer.write(ge.HeaderMark,0,r).writeElements(e.parser.parseInline(t.text.slice(n+r+1,o),s+r+1),-s);o<t.text.length&&l.write(ge.HeaderMark,o-n,i-n);let a=l.finish(ge.ATXHeading1-1+r,t.text.length-n);return e.nextLine(),e.addNode(a,s),!0},HTMLBlock(e,t){let r=_e(t,0,!1);if(r<0)return!1;let n=e.lineStart+t.pos,s=He[r][1],i=[],o=s!=Me;for(;!s.test(t.text)&&e.nextLine();){if(t.depth<e.stack.length){o=!1;break}for(let e of t.markers)i.push(e)}o&&e.nextLine();let l=s==Pe?ge.CommentBlock:s==Ne?ge.ProcessingInstructionBlock:ge.HTMLBlock,a=e.prevLineEnd();return e.addNode(e.buffer.writeElements(i,-n).finish(l,a-n),n),!0},SetextHeading:void 0};class De{constructor(e){this.stage=0,this.elts=[],this.pos=0,this.start=e.start,this.advance(e.content)}nextLine(e,t,r){if(-1==this.stage)return!1;let n=r.content+"\n"+t.scrub(),s=this.advance(n);return s>-1&&s<n.length&&this.complete(e,r,s)}finish(e,t){return(2==this.stage||3==this.stage)&&we(t.content,this.pos)==t.content.length&&this.complete(e,t,t.content.length)}complete(e,t,r){return e.addLeafElement(t,rt(ge.LinkReference,this.start,this.start+r,this.elts)),!0}nextStage(e){return e?(this.pos=e.to-this.start,this.elts.push(e),this.stage++,!0):(!1===e&&(this.stage=-1),!1)}advance(e){for(;;){if(-1==this.stage)return-1;if(0==this.stage){if(!this.nextStage(ct(e,this.pos,this.start,!0)))return-1;if(58!=e.charCodeAt(this.pos))return this.stage=-1;this.elts.push(rt(ge.LinkMark,this.pos+this.start,this.pos+this.start+1)),this.pos++}else{if(1!=this.stage){if(2==this.stage){let t=we(e,this.pos),r=0;if(t>this.pos){let n=pt(e,t,this.start);if(n){let t=Fe(e,n.to-this.start);t>0&&(this.nextStage(n),r=t)}}return r||(r=Fe(e,this.pos)),r>0&&r<e.length?r:-1}return Fe(e,this.pos)}if(!this.nextStage(dt(e,we(e,this.pos),this.start)))return-1}}}}function Fe(e,t){for(;t<e.length;t++){let r=e.charCodeAt(t);if(10==r)break;if(!ye(r))return-1}return t}class Xe{nextLine(e,t,r){let n=t.depth<e.stack.length?-1:Ee(t),s=t.next;if(n<0)return!1;let i=rt(ge.HeaderMark,e.lineStart+t.pos,e.lineStart+n);return e.nextLine(),e.addLeafElement(r,rt(61==s?ge.SetextHeading1:ge.SetextHeading2,r.start,e.prevLineEnd(),[...e.parser.parseInline(r.content,r.start),i])),!0}finish(){return!1}}const je={LinkReference:(e,t)=>91==t.content.charCodeAt(0)?new De(t):null,SetextHeading:()=>new Xe},$e=[(e,t)=>Te(t)>=0,(e,t)=>Ce(t)>=0,(e,t)=>Le(t)>=0,(e,t)=>Ie(t,e,!0)>=0,(e,t)=>Be(t,e,!0)>=0,(e,t)=>Ae(t,e,!0)>=0,(e,t)=>_e(t,0,!0)>=0],qe={text:"",end:0};class Ue{constructor(e,t,r,n){this.parser=e,this.input=t,this.ranges=n,this.line=new xe,this.atEnd=!1,this.reusePlaceholders=new Map,this.stoppedAt=null,this.rangeI=0,this.to=n[n.length-1].to,this.lineStart=this.absoluteLineStart=this.absoluteLineEnd=n[0].from,this.block=ce.create(ge.Document,0,this.lineStart,0,0),this.stack=[this.block],this.fragments=r.length?new kt(r,t):null,this.readLine()}get parsedPos(){return this.absoluteLineStart}advance(){if(null!=this.stoppedAt&&this.absoluteLineStart>this.stoppedAt)return this.finish();let{line:e}=this;for(;;){for(let t=0;;){let r=e.depth<this.stack.length?this.stack[this.stack.length-1]:null;for(;t<e.markers.length&&(!r||e.markers[t].from<r.end);){let r=e.markers[t++];this.addNode(r.type,r.from,r.to)}if(!r)break;this.finishContext()}if(e.pos<e.text.length)break;if(!this.nextLine())return this.finish()}if(this.fragments&&this.reuseFragment(e.basePos))return null;e:for(;;){for(let t of this.parser.blockParsers)if(t){let r=t(this,e);if(0!=r){if(1==r)return null;e.forward();continue e}}break}if(e.pos==e.text.length)return this.nextLine()?null:this.finish();let t=new me(this.lineStart+e.pos,e.text.slice(e.pos));for(let e of this.parser.leafBlockParsers)if(e){let r=e(this,t);r&&t.parsers.push(r)}e:for(;this.nextLine()&&e.pos!=e.text.length;){if(e.indent<e.baseIndent+4)for(let r of this.parser.endLeafBlock)if(r(this,e,t))break e;for(let r of t.parsers)if(r.nextLine(this,e,t))return null;t.content+="\n"+e.scrub();for(let r of e.markers)t.marks.push(r)}return this.finishLeaf(t),null}stopAt(e){if(null!=this.stoppedAt&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}reuseFragment(e){if(!this.fragments.moveTo(this.absoluteLineStart+e,this.absoluteLineStart)||!this.fragments.matches(this.block.hash))return!1;let t=this.fragments.takeNodes(this);return!!t&&(this.absoluteLineStart+=t,this.lineStart=bt(this.absoluteLineStart,this.ranges),this.moveRangeI(),this.absoluteLineStart<this.to?(this.lineStart++,this.absoluteLineStart++,this.readLine()):(this.atEnd=!0,this.readLine()),!0)}get depth(){return this.stack.length}parentType(e=this.depth-1){return this.parser.nodeSet.types[this.stack[e].type]}nextLine(){return this.lineStart+=this.line.text.length,this.absoluteLineEnd>=this.to?(this.absoluteLineStart=this.absoluteLineEnd,this.atEnd=!0,this.readLine(),!1):(this.lineStart++,this.absoluteLineStart=this.absoluteLineEnd+1,this.moveRangeI(),this.readLine(),!0)}peekLine(){return this.scanLine(this.absoluteLineEnd+1).text}moveRangeI(){for(;this.rangeI<this.ranges.length-1&&this.absoluteLineStart>=this.ranges[this.rangeI].to;)this.rangeI++,this.absoluteLineStart=Math.max(this.absoluteLineStart,this.ranges[this.rangeI].from)}scanLine(e){let t=qe;if(t.end=e,e>=this.to)t.text="";else if(t.text=this.lineChunkAt(e),t.end+=t.text.length,this.ranges.length>1){let e=this.absoluteLineStart,r=this.rangeI;for(;this.ranges[r].to<t.end;){r++;let n=this.ranges[r].from,s=this.lineChunkAt(n);t.end=n+s.length,t.text=t.text.slice(0,this.ranges[r-1].to-e)+s,e=t.end-t.text.length}}return t}readLine(){let{line:e}=this,{text:t,end:r}=this.scanLine(this.absoluteLineStart);for(this.absoluteLineEnd=r,e.reset(t);e.depth<this.stack.length;e.depth++){let t=this.stack[e.depth],r=this.parser.skipContextMarkup[t.type];if(!r)throw new Error("Unhandled block context "+ge[t.type]);let n=this.line.markers.length;if(!r(t,this,e)){this.line.markers.length>n&&(t.end=this.line.markers[this.line.markers.length-1].to),e.forward();break}e.forward()}}lineChunkAt(e){let t,r=this.input.chunk(e);if(this.input.lineChunks)t="\n"==r?"":r;else{let e=r.indexOf("\n");t=e<0?r:r.slice(0,e)}return e+t.length>this.to?t.slice(0,this.to-e):t}prevLineEnd(){return this.atEnd?this.lineStart:this.lineStart-1}startContext(e,t,r=0){this.block=ce.create(e,r,this.lineStart+t,this.block.hash,this.lineStart+this.line.text.length),this.stack.push(this.block)}startComposite(e,t,r=0){this.startContext(this.parser.getNodeType(e),t,r)}addNode(e,t,r){"number"==typeof e&&(e=new H(this.parser.nodeSet.types[e],Ke,Ke,(null!=r?r:this.prevLineEnd())-t)),this.block.addChild(e,t-this.block.from)}addElement(e){this.block.addChild(e.toTree(this.parser.nodeSet),e.from-this.block.from)}addLeafElement(e,t){this.addNode(this.buffer.writeElements(mt(t.children,e.marks),-t.from).finish(t.type,t.to-t.from),t.from)}finishContext(){let e=this.stack.pop(),t=this.stack[this.stack.length-1];t.addChild(e.toTree(this.parser.nodeSet),e.from-t.from),this.block=t}finish(){for(;this.stack.length>1;)this.finishContext();return this.addGaps(this.block.toTree(this.parser.nodeSet,this.lineStart))}addGaps(e){return this.ranges.length>1?Ze(this.ranges,0,e.topNode,this.ranges[0].from,this.reusePlaceholders):e}finishLeaf(e){for(let t of e.parsers)if(t.finish(this,e))return;let t=mt(this.parser.parseInline(e.content,e.start),e.marks);this.addNode(this.buffer.writeElements(t,-e.start).finish(ge.Paragraph,e.content.length),e.start)}elt(e,t,r,n){return"string"==typeof e?rt(this.parser.getNodeType(e),t,r,n):new tt(e,t)}get buffer(){return new Ye(this.parser.nodeSet)}}function Ze(e,t,r,n,s){let i=e[t].to,o=[],l=[],a=r.from+n;function h(r,s){for(;s?r>=i:r>i;){let s=e[t+1].from-i;n+=s,r+=s,t++,i=e[t].to}}for(let f=r.firstChild;f;f=f.nextSibling){h(f.from+n,!0);let r,u=f.from+n,d=s.get(f.tree);d?r=d:f.to+n>i?(r=Ze(e,t,f,n,s),h(f.to+n,!1)):r=f.toTree(),o.push(r),l.push(u-a)}return h(r.to+n,!1),new H(r.type,o,l,r.to+n-a,r.tree?r.tree.propValues:void 0)}class Qe extends Y{constructor(e,t,r,n,s,i,o,l,a){super(),this.nodeSet=e,this.blockParsers=t,this.leafBlockParsers=r,this.blockNames=n,this.endLeafBlock=s,this.skipContextMarkup=i,this.inlineParsers=o,this.inlineNames=l,this.wrappers=a,this.nodeTypes=Object.create(null);for(let t of e.types)this.nodeTypes[t.name]=t.id}createParse(e,t,r){let n=new Ue(this,e,t,r);for(let s of this.wrappers)n=s(n,e,t,r);return n}configure(r){let n=We(r);if(!n)return this;let{nodeSet:s,skipContextMarkup:i}=this,o=this.blockParsers.slice(),l=this.leafBlockParsers.slice(),a=this.blockNames.slice(),h=this.inlineParsers.slice(),f=this.inlineNames.slice(),u=this.endLeafBlock.slice(),d=this.wrappers;if(Ve(n.defineNodes)){i=Object.assign({},i);let r,o=s.types.slice();for(let t of n.defineNodes){let{name:n,block:s,composite:l,style:a}="string"==typeof t?{name:t}:t;if(o.some(e=>e.name==n))continue;l&&(i[o.length]=(e,t,r)=>l(t,r,e.value));let h=o.length,f=l?["Block","BlockContext"]:s?h>=ge.ATXHeading1&&h<=ge.SetextHeading2?["Block","LeafBlock","Heading"]:["Block","LeafBlock"]:void 0;o.push(T.define({id:h,name:n,props:f&&[[v.group,f]]})),a&&(r||(r={}),Array.isArray(a)||a instanceof e?r[n]=a:Object.assign(r,a))}s=new E(o),r&&(s=s.extend(t(r)))}if(Ve(n.props)&&(s=s.extend(...n.props)),Ve(n.remove))for(let e of n.remove){let t=this.blockNames.indexOf(e),r=this.inlineNames.indexOf(e);t>-1&&(o[t]=l[t]=void 0),r>-1&&(h[r]=void 0)}if(Ve(n.parseBlock))for(let e of n.parseBlock){let t=a.indexOf(e.name);if(t>-1)o[t]=e.parse,l[t]=e.leaf;else{let t=e.before?Je(a,e.before):e.after?Je(a,e.after)+1:a.length-1;o.splice(t,0,e.parse),l.splice(t,0,e.leaf),a.splice(t,0,e.name)}e.endLeaf&&u.push(e.endLeaf)}if(Ve(n.parseInline))for(let e of n.parseInline){let t=f.indexOf(e.name);if(t>-1)h[t]=e.parse;else{let t=e.before?Je(f,e.before):e.after?Je(f,e.after)+1:f.length-1;h.splice(t,0,e.parse),f.splice(t,0,e.name)}}return n.wrap&&(d=d.concat(n.wrap)),new Qe(s,o,l,a,u,i,h,f,d)}getNodeType(e){let t=this.nodeTypes[e];if(null==t)throw new RangeError(`Unknown node type '${e}'`);return t}parseInline(e,t){let r=new gt(this,e,t);e:for(let e=t;e<r.end;){let t=r.char(e);for(let n of this.inlineParsers)if(n){let s=n(r,t,e);if(s>=0){e=s;continue e}}e++}return r.resolveMarkers(0)}}function Ve(e){return null!=e&&e.length>0}function We(e){if(!Array.isArray(e))return e;if(0==e.length)return null;let t=We(e[0]);if(1==e.length)return t;let r=We(e.slice(1));if(!r||!t)return t||r;let n=(e,t)=>(e||Ke).concat(t||Ke),s=t.wrap,i=r.wrap;return{props:n(t.props,r.props),defineNodes:n(t.defineNodes,r.defineNodes),parseBlock:n(t.parseBlock,r.parseBlock),parseInline:n(t.parseInline,r.parseInline),remove:n(t.remove,r.remove),wrap:s?i?(e,t,r,n)=>s(i(e,t,r,n),t,r,n):s:i}}function Je(e,t){let r=e.indexOf(t);if(r<0)throw new RangeError(`Position specified relative to unknown parser ${t}`);return r}let Ge=[T.none];for(let e,t=1;e=ge[t];t++)Ge[t]=T.define({id:t,name:e,props:t>=ge.Escape?[]:[[v.group,t in be?["Block","BlockContext"]:["Block","LeafBlock"]]],top:"Document"==e});const Ke=[];class Ye{constructor(e){this.nodeSet=e,this.content=[],this.nodes=[]}write(e,t,r,n=0){return this.content.push(e,t,r,4+4*n),this}writeElements(e,t=0){for(let r of e)r.writeTo(this,t);return this}finish(e,t){return H.build({buffer:this.content,nodeSet:this.nodeSet,reused:this.nodes,topID:e,length:t})}}class et{constructor(e,t,r,n=Ke){this.type=e,this.from=t,this.to=r,this.children=n}writeTo(e,t){let r=e.content.length;e.writeElements(this.children,t),e.content.push(this.type,this.from+t,this.to+t,e.content.length+4-r)}toTree(e){return new Ye(e).writeElements(this.children,-this.from).finish(this.type,this.to-this.from)}}class tt{constructor(e,t){this.tree=e,this.from=t}get to(){return this.from+this.tree.length}get type(){return this.tree.type.id}get children(){return Ke}writeTo(e,t){e.nodes.push(this.tree),e.content.push(e.nodes.length-1,this.from+t,this.to+t,-1)}toTree(){return this.tree}}function rt(e,t,r,n){return new et(e,t,r,n)}const nt={resolve:"Emphasis",mark:"EmphasisMark"},st={resolve:"Emphasis",mark:"EmphasisMark"},it={},ot={};class lt{constructor(e,t,r,n){this.type=e,this.from=t,this.to=r,this.side=n}}const at="!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~";let ht=/[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\xA1\u2010-\u2027]/;try{ht=new RegExp("[\\p{S}|\\p{P}]","u")}catch(e){}const ft={Escape(e,t,r){if(92!=t||r==e.end-1)return-1;let n=e.char(r+1);for(let t=0;t<32;t++)if(at.charCodeAt(t)==n)return e.append(rt(ge.Escape,r,r+2));return-1},Entity(e,t,r){if(38!=t)return-1;let n=/^(?:#\d+|#x[a-f\d]+|\w+);/i.exec(e.slice(r+1,r+31));return n?e.append(rt(ge.Entity,r,r+1+n[0].length)):-1},InlineCode(e,t,r){if(96!=t||r&&96==e.char(r-1))return-1;let n=r+1;for(;n<e.end&&96==e.char(n);)n++;let s=n-r,i=0;for(;n<e.end;n++)if(96==e.char(n)){if(i++,i==s&&96!=e.char(n+1))return e.append(rt(ge.InlineCode,r,n+1,[rt(ge.CodeMark,r,r+s),rt(ge.CodeMark,n+1-s,n+1)]))}else i=0;return-1},HTMLTag(e,t,r){if(60!=t||r==e.end-1)return-1;let n=e.slice(r+1,e.end),s=/^(?:[a-z][-\w+.]+:[^\s>]+|[a-z\d.!#$%&'*+/=?^_`{|}~-]+@[a-z\d](?:[a-z\d-]{0,61}[a-z\d])?(?:\.[a-z\d](?:[a-z\d-]{0,61}[a-z\d])?)*)>/i.exec(n);if(s)return e.append(rt(ge.Autolink,r,r+1+s[0].length,[rt(ge.LinkMark,r,r+1),rt(ge.URL,r+1,r+s[0].length),rt(ge.LinkMark,r+s[0].length,r+1+s[0].length)]));let i=/^!--[^>](?:-[^-]|[^-])*?-->/i.exec(n);if(i)return e.append(rt(ge.Comment,r,r+1+i[0].length));let o=/^\?[^]*?\?>/.exec(n);if(o)return e.append(rt(ge.ProcessingInstruction,r,r+1