@gdquest/gd-exercise-react
Version:
React project for GDExercise.
1 lines • 89.3 kB
JavaScript
import{L as Et,i as Bt,f as It,d as qt,e as Gt,s as Dt,R as Ft}from"./GdExercise-be6e505c.js";import"./client-c781d100.js";import"./loader-9a6dfd57.js";var yt=1024,Zt=0,Ae=class{constructor(i,e){this.from=i,this.to=e}},v=class{constructor(i={}){this.id=Zt++,this.perNode=!!i.perNode,this.deserialize=i.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(i){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof i!="function"&&(i=K.match(i)),e=>{let t=i(e);return t===void 0?null:[this,t]}}};v.closedBy=new v({deserialize:i=>i.split(" ")});v.openedBy=new v({deserialize:i=>i.split(" ")});v.group=new v({deserialize:i=>i.split(" ")});v.contextHash=new v({perNode:!0});v.lookAhead=new v({perNode:!0});v.mounted=new v({perNode:!0});var Mt=Object.create(null),K=class St{constructor(e,t,r,s=0){this.name=e,this.props=t,this.id=r,this.flags=s}static define(e){let t=e.props&&e.props.length?Object.create(null):Mt,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),s=new St(e.name||"",t,e.id,r);if(e.props){for(let n of e.props)if(Array.isArray(n)||(n=n(s)),n){if(n[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[n[0].id]=n[1]}}return s}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(v.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let r in e)for(let s of r.split(" "))t[s]=e[r];return r=>{for(let s=r.prop(v.group),n=-1;n<(s?s.length:0);n++){let a=t[n<0?r.name:s[n]];if(a)return a}}}};K.none=new K("",Object.create(null),0,8);var Lt=class kt{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 s=null;for(let n of e){let a=n(r);a&&(s||(s=Object.assign({},r.props)),s[a[0].id]=a[1])}t.push(s?new K(r.name,s,r.id,r.flags):r)}return new kt(t)}},ge=new WeakMap,rt=new WeakMap,A;(function(i){i[i.ExcludeBuffers=1]="ExcludeBuffers",i[i.IncludeAnonymous=2]="IncludeAnonymous",i[i.IgnoreMounts=4]="IgnoreMounts",i[i.IgnoreOverlays=8]="IgnoreOverlays"})(A||(A={}));var G=class Be{constructor(e,t,r,s,n){if(this.type=e,this.children=t,this.positions=r,this.length=s,this.props=null,n&&n.length){this.props=Object.create(null);for(let[a,l]of n)this.props[typeof a=="number"?a:a.id]=l}}toString(){let e=this.prop(v.mounted);if(e&&!e.overlay)return e.tree.toString();let t="";for(let r of this.children){let s=r.toString();s&&(t&&(t+=","),t+=s)}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 Ue(this.topNode,e)}cursorAt(e,t=0,r=0){let s=ge.get(this)||this.topNode,n=new Ue(s);return n.moveTo(e,t),ge.set(this,n._tree),n}get topNode(){return new Oe(this,0,0,null)}resolve(e,t=0){let r=ne(ge.get(this)||this.topNode,e,t,!1);return ge.set(this,r),r}resolveInner(e,t=0){let r=ne(rt.get(this)||this.topNode,e,t,!0);return rt.set(this,r),r}iterate(e){let{enter:t,leave:r,from:s=0,to:n=this.length}=e,a=e.mode||0,l=(a&A.IncludeAnonymous)>0;for(let h=this.cursor(a|A.IncludeAnonymous);;){let f=!1;if(h.from<=n&&h.to>=s&&(!l&&h.type.isAnonymous||t(h)!==!1)){if(h.firstChild())continue;f=!0}for(;f&&r&&(l||!h.type.isAnonymous)&&r(h),!h.nextSibling();){if(!h.parent())return;f=!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:Je(K.none,this.children,this.positions,0,this.children.length,0,this.length,(t,r,s)=>new Be(this.type,t,r,s,this.propValues),e.makeTree||((t,r,s)=>new Be(K.none,t,r,s)))}static build(e){return Jt(e)}};G.empty=new G(K.none,[],[],0);var Kt=class Pt{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 Pt(this.buffer,this.index)}},de=class $t{constructor(e,t,r){this.buffer=e,this.length=t,this.set=r}get type(){return K.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],s=this.set.types[t],n=s.name;if(/\W/.test(n)&&!s.isError&&(n=JSON.stringify(n)),e+=4,r==e)return n;let a=[];for(;e<r;)a.push(this.childString(e)),e=this.buffer[e+3];return n+"("+a.join(",")+")"}findChild(e,t,r,s,n){let{buffer:a}=this,l=-1;for(let h=e;h!=t&&!(Xt(n,s,a[h+1],a[h+2])&&(l=h,r>0));h=a[h+3]);return l}slice(e,t,r){let s=this.buffer,n=new Uint16Array(t-e),a=0;for(let l=e,h=0;l<t;){n[h++]=s[l++],n[h++]=s[l++]-r;let f=n[h++]=s[l++]-r;n[h++]=s[l++]-e,a=Math.max(a,f)}return new $t(n,a,this.set)}};function Xt(i,e,t,r){switch(i){case-2:return t<e;case-1:return r>=e&&t<e;case 0:return t<e&&r>e;case 1:return t<=e&&r>e;case 2:return r>e;case 4:return!0}}function vt(i,e){let t=i.childBefore(e);for(;t;){let r=t.lastChild;if(!r||r.to!=t.to)break;r.type.isError&&r.from==r.to?(i=t,t=r.prevSibling):t=r}return i}function ne(i,e,t,r){for(var s;i.from==i.to||(t<1?i.from>=e:i.from>e)||(t>-1?i.to<=e:i.to<e);){let a=!r&&i instanceof Oe&&i.index<0?null:i.parent;if(!a)return i;i=a}let n=r?0:A.IgnoreOverlays;if(r)for(let a=i,l=a.parent;l;a=l,l=a.parent)a instanceof Oe&&a.index<0&&((s=l.enter(e,t,n))===null||s===void 0?void 0:s.from)!=a.from&&(i=l);for(;;){let a=i.enter(e,t,n);if(!a)return i;i=a}}var Oe=class Se{constructor(e,t,r,s){this._tree=e,this.from=t,this.index=r,this._parent=s}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,s,n=0){for(let a=this;;){for(let{children:l,positions:h}=a._tree,f=t>0?l.length:-1;e!=f;e+=t){let o=l[e],m=h[e]+a.from;if(Xt(s,r,m,m+o.length)){if(o instanceof de){if(n&A.ExcludeBuffers)continue;let Q=o.findChild(0,o.buffer.length,t,r-m,s);if(Q>-1)return new Ie(new Ht(a,o,e,m),null,Q)}else if(n&A.IncludeAnonymous||!o.type.isAnonymous||He(o)){let Q;if(!(n&A.IgnoreMounts)&&o.props&&(Q=o.prop(v.mounted))&&!Q.overlay)return new Se(Q.tree,m,e,a);let S=new Se(o,m,e,a);return n&A.IncludeAnonymous||!S.type.isAnonymous?S:S.nextChild(t<0?o.children.length-1:0,t,r,s)}}}if(n&A.IncludeAnonymous||!a.type.isAnonymous||(a.index>=0?e=a.index+t:e=t<0?-1:a._parent._tree.children.length,a=a._parent,!a))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)}enter(e,t,r=0){let s;if(!(r&A.IgnoreOverlays)&&(s=this._tree.prop(v.mounted))&&s.overlay){let n=e-this.from;for(let{from:a,to:l}of s.overlay)if((t>0?a<=n:a<n)&&(t<0?l>=n:l>n))return new Se(s.tree,s.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}cursor(e=0){return new Ue(this,e)}get tree(){return this._tree}toTree(){return this._tree}resolve(e,t=0){return ne(this,e,t,!1)}resolveInner(e,t=0){return ne(this,e,t,!0)}enterUnfinishedNodesBefore(e){return vt(this,e)}getChild(e,t=null,r=null){let s=ve(this,e,t,r);return s.length?s[0]:null}getChildren(e,t=null,r=null){return ve(this,e,t,r)}toString(){return this._tree.toString()}get node(){return this}matchContext(e){return we(this,e)}};function ve(i,e,t,r){let s=i.cursor(),n=[];if(!s.firstChild())return n;if(t!=null){for(;!s.type.is(t);)if(!s.nextSibling())return n}for(;;){if(r!=null&&s.type.is(r))return n;if(s.type.is(e)&&n.push(s.node),!s.nextSibling())return r==null?n:[]}}function we(i,e,t=e.length-1){for(let r=i.parent;t>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[t]&&e[t]!=r.name)return!1;t--}}return!0}var Ht=class{constructor(i,e,t,r){this.parent=i,this.buffer=e,this.index=t,this.start=r}},Ie=class fe{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){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:s}=this.context,n=s.findChild(this.index+4,s.buffer[this.index+3],e,t-this.context.start,r);return n<0?null:new fe(this.context,this,n)}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)}enter(e,t,r=0){if(r&A.ExcludeBuffers)return null;let{buffer:s}=this.context,n=s.findChild(this.index+4,s.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return n<0?null:new fe(this.context,this,n)}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 fe(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 fe(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}cursor(e=0){return new Ue(this,e)}get tree(){return null}toTree(){let e=[],t=[],{buffer:r}=this.context,s=this.index+4,n=r.buffer[this.index+3];if(n>s){let a=r.buffer[this.index+1];e.push(r.slice(s,n,a)),t.push(0)}return new G(this.type,e,t,this.to-this.from)}resolve(e,t=0){return ne(this,e,t,!1)}resolveInner(e,t=0){return ne(this,e,t,!0)}enterUnfinishedNodesBefore(e){return vt(this,e)}toString(){return this.context.buffer.childString(this.index)}getChild(e,t=null,r=null){let s=ve(this,e,t,r);return s.length?s[0]:null}getChildren(e,t=null,r=null){return ve(this,e,t,r)}get node(){return this}matchContext(e){return we(this,e)}},Ue=class{get name(){return this.type.name}constructor(i,e=0){if(this.mode=e,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,i instanceof Oe)this.yieldNode(i);else{this._tree=i.context.parent,this.buffer=i.context;for(let t=i._parent;t;t=t._parent)this.stack.unshift(t.index);this.bufferNode=i,this.yieldBuf(i.index)}}yieldNode(i){return i?(this._tree=i,this.type=i.type,this.from=i.from,this.to=i.to,!0):!1}yieldBuf(i,e){this.index=i;let{start:t,buffer:r}=this.buffer;return this.type=e||r.set.types[r.buffer[i]],this.from=t+r.buffer[i+1],this.to=t+r.buffer[i+2],!0}yield(i){return i?i instanceof Oe?(this.buffer=null,this.yieldNode(i)):(this.buffer=i.context,this.yieldBuf(i.index,i.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(i,e,t){if(!this.buffer)return this.yield(this._tree.nextChild(i<0?this._tree._tree.children.length-1:0,i,e,t,this.mode));let{buffer:r}=this.buffer,s=r.findChild(this.index+4,r.buffer[this.index+3],i,e-this.buffer.start,t);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(i){return this.enterChild(1,i,2)}childBefore(i){return this.enterChild(-1,i,-2)}enter(i,e,t=this.mode){return this.buffer?t&A.ExcludeBuffers?!1:this.enterChild(1,i,e):this.yield(this._tree.enter(i,e,t))}parent(){if(!this.buffer)return this.yieldNode(this.mode&A.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let i=this.mode&A.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(i)}sibling(i){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+i,i,0,4,this.mode)):!1;let{buffer:e}=this.buffer,t=this.stack.length-1;if(i<0){let r=t<0?0:this.stack[t]+4;if(this.index!=r)return this.yieldBuf(e.findChild(r,this.index,-1,0,4))}else{let r=e.buffer[this.index+3];if(r<(t<0?e.buffer.length:e.buffer[this.stack[t]+3]))return this.yieldBuf(r)}return t<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+i,i,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(i){let e,t,{buffer:r}=this;if(r){if(i>0){if(this.index<r.buffer.buffer.length)return!1}else for(let s=0;s<this.index;s++)if(r.buffer.buffer[s+3]<this.index)return!1;({index:e,parent:t}=r)}else({index:e,_parent:t}=this._tree);for(;t;{index:e,_parent:t}=t)if(e>-1)for(let s=e+i,n=i<0?-1:t._tree.children.length;s!=n;s+=i){let a=t._tree.children[s];if(this.mode&A.IncludeAnonymous||a instanceof de||!a.type.isAnonymous||He(a))return!1}return!0}move(i,e){if(e&&this.enterChild(i,0,4))return!0;for(;;){if(this.sibling(i))return!0;if(this.atLastNode(i)||!this.parent())return!1}}next(i=!0){return this.move(1,i)}prev(i=!0){return this.move(-1,i)}moveTo(i,e=0){for(;(this.from==this.to||(e<1?this.from>=i:this.from>i)||(e>-1?this.to<=i:this.to<i))&&this.parent(););for(;this.enterChild(1,i,e););return this}get node(){if(!this.buffer)return this._tree;let i=this.bufferNode,e=null,t=0;if(i&&i.context==this.buffer)e:for(let r=this.index,s=this.stack.length;s>=0;){for(let n=i;n;n=n._parent)if(n.index==r){if(r==this.index)return n;e=n,t=s+1;break e}r=this.stack[--s]}for(let r=t;r<this.stack.length;r++)e=new Ie(this.buffer,e,this.stack[r]);return this.bufferNode=new Ie(this.buffer,e,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(i,e){for(let t=0;;){let r=!1;if(this.type.isAnonymous||i(this)!==!1){if(this.firstChild()){t++;continue}this.type.isAnonymous||(r=!0)}for(;r&&e&&e(this),r=this.type.isAnonymous,!this.nextSibling();){if(!t)return;this.parent(),t--,r=!0}}}matchContext(i){if(!this.buffer)return we(this.node,i);let{buffer:e}=this.buffer,{types:t}=e.set;for(let r=i.length-1,s=this.stack.length-1;r>=0;s--){if(s<0)return we(this.node,i,r);let n=t[e.buffer[this.stack[s]]];if(!n.isAnonymous){if(i[r]&&i[r]!=n.name)return!1;r--}}return!0}};function He(i){return i.children.some(e=>e instanceof de||!e.type.isAnonymous||He(e))}function Jt(i){var e;let{buffer:t,nodeSet:r,maxBufferLength:s=yt,reused:n=[],minRepeatType:a=r.types.length}=i,l=Array.isArray(t)?new Kt(t,t.length):t,h=r.types,f=0,o=0;function m(x,b,u,p,P){let{id:g,start:c,end:y,size:X}=l,w=o;for(;X<0;)if(l.next(),X==-1){let N=n[g];u.push(N),p.push(c-x);return}else if(X==-3){f=g;return}else if(X==-4){o=g;return}else throw new RangeError(`Unrecognized record size: ${X}`);let E=h[g],T,_,le=c-x;if(y-c<=s&&(_=V(l.pos-b,P))){let N=new Uint16Array(_.size-_.skip),U=l.pos-_.size,C=N.length;for(;l.pos>U;)C=I(_.start,N,C);T=new de(N,y-_.start,r),le=_.start-x}else{let N=l.pos-X;l.next();let U=[],C=[],W=g>=a?g:-1,B=0,M=y;for(;l.pos>N;)W>=0&&l.id==W&&l.size>=0?(l.end<=M-s&&(S(U,C,c,B,l.end,M,W,w),B=U.length,M=l.end),l.next()):m(c,N,U,C,W);if(W>=0&&B>0&&B<U.length&&S(U,C,c,B,c,M,W,w),U.reverse(),C.reverse(),W>-1&&B>0){let he=Q(E);T=Je(E,U,C,0,U.length,0,y-c,he,he)}else T=k(E,U,C,y-c,w-y)}u.push(T),p.push(le)}function Q(x){return(b,u,p)=>{let P=0,g=b.length-1,c,y;if(g>=0&&(c=b[g])instanceof G){if(!g&&c.type==x&&c.length==p)return c;(y=c.prop(v.lookAhead))&&(P=u[g]+c.length+y)}return k(x,b,u,p,P)}}function S(x,b,u,p,P,g,c,y){let X=[],w=[];for(;x.length>p;)X.push(x.pop()),w.push(b.pop()+u-P);x.push(k(r.types[c],X,w,g-P,y-g)),b.push(P-u)}function k(x,b,u,p,P=0,g){if(f){let c=[v.contextHash,f];g=g?[c].concat(g):[c]}if(P>25){let c=[v.lookAhead,P];g=g?[c].concat(g):[c]}return new G(x,b,u,p,g)}function V(x,b){let u=l.fork(),p=0,P=0,g=0,c=u.end-s,y={size:0,start:0,skip:0};e:for(let X=u.pos-x;u.pos>X;){let w=u.size;if(u.id==b&&w>=0){y.size=p,y.start=P,y.skip=g,g+=4,p+=4,u.next();continue}let E=u.pos-w;if(w<0||E<X||u.start<c)break;let T=u.id>=a?4:0,_=u.start;for(u.next();u.pos>E;){if(u.size<0)if(u.size==-3)T+=4;else break e;else u.id>=a&&(T+=4);u.next()}P=_,p+=w,g+=T}return(b<0||p==x)&&(y.size=p,y.start=P,y.skip=g),y.size>4?y:void 0}function I(x,b,u){let{id:p,start:P,end:g,size:c}=l;if(l.next(),c>=0&&p<a){let y=u;if(c>4){let X=l.pos-(c-4);for(;l.pos>X;)u=I(x,b,u)}b[--u]=y,b[--u]=g-x,b[--u]=P-x,b[--u]=p}else c==-3?f=p:c==-4&&(o=p);return u}let Y=[],j=[];for(;l.pos>0;)m(i.start||0,i.bufferStart||0,Y,j,-1);let $=(e=i.length)!==null&&e!==void 0?e:Y.length?j[0]+Y[0].length:0;return new G(h[i.topID],Y.reverse(),j.reverse(),$)}var st=new WeakMap;function ke(i,e){if(!i.isAnonymous||e instanceof de||e.type!=i)return 1;let t=st.get(e);if(t==null){t=1;for(let r of e.children){if(r.type!=i||!(r instanceof G)){t=1;break}t+=ke(i,r)}st.set(e,t)}return t}function Je(i,e,t,r,s,n,a,l,h){let f=0;for(let k=r;k<s;k++)f+=ke(i,e[k]);let o=Math.ceil(f*1.5/8),m=[],Q=[];function S(k,V,I,Y,j){for(let $=I;$<Y;){let x=$,b=V[$],u=ke(i,k[$]);for($++;$<Y;$++){let p=ke(i,k[$]);if(u+p>=o)break;u+=p}if($==x+1){if(u>o){let p=k[x];S(p.children,p.positions,0,p.children.length,V[x]+j);continue}m.push(k[x])}else{let p=V[$-1]+k[$-1].length-b;m.push(Je(i,k,V,x,$,b,p,null,h))}Q.push(b+j-n)}}return S(e,t,r,s,0),(l||h)(m,Q,a)}var ei=class{startParse(i,e,t){return typeof i=="string"&&(i=new ti(i)),t=t?t.length?t.map(r=>new Ae(r.from,r.to)):[new Ae(0,0)]:[new Ae(0,i.length)],this.createParse(i,e||[],t)}parse(i,e,t){let r=this.startParse(i,e,t);for(;;){let s=r.advance();if(s)return s}}},ti=class{constructor(i){this.string=i}get length(){return this.string.length}chunk(i){return this.string.slice(i)}get lineChunks(){return!1}read(i,e){return this.string.slice(i,e)}};new v({perNode:!0});var ii=class qe{constructor(e,t,r,s,n,a,l,h,f,o=0,m){this.p=e,this.stack=t,this.state=r,this.reducePos=s,this.pos=n,this.score=a,this.buffer=l,this.bufferBase=h,this.curContext=f,this.lookAhead=o,this.parent=m}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,r=0){let s=e.parser.context;return new qe(e,[],t,r,r,0,[],0,s?new nt(s,s.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var t;let r=e>>19,s=e&65535,{parser:n}=this.p,a=n.dynamicPrecedence(s);if(a&&(this.score+=a),r==0){this.pushState(n.getGoto(this.state,s,!0),this.reducePos),s<n.minRepeatTerm&&this.storeNode(s,this.reducePos,this.reducePos,4,!0),this.reduceContext(s,this.reducePos);return}let l=this.stack.length-(r-1)*3-(e&262144?6:0),h=l?this.stack[l-2]:this.p.ranges[0].from,f=this.reducePos-h;f>=2e3&&!(!((t=this.p.parser.nodeSet.types[s])===null||t===void 0)&&t.isAnonymous)&&(h==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=f):this.p.lastBigReductionSize<f&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=h,this.p.lastBigReductionSize=f));let o=l?this.stack[l-1]:0,m=this.bufferBase+this.buffer.length-o;if(s<n.minRepeatTerm||e&131072){let Q=n.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(s,h,Q,m+4,!0)}if(e&262144)this.state=this.stack[l];else{let Q=this.stack[l-3];this.state=n.getGoto(Q,s,!0)}for(;this.stack.length>l;)this.stack.pop();this.reduceContext(s,h)}storeNode(e,t,r,s=4,n=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let a=this,l=this.buffer.length;if(l==0&&a.parent&&(l=a.bufferBase-a.parent.bufferBase,a=a.parent),l>0&&a.buffer[l-4]==0&&a.buffer[l-1]>-1){if(t==r)return;if(a.buffer[l-2]>=t){a.buffer[l-2]=r;return}}}if(!n||this.pos==r)this.buffer.push(e,t,r,s);else{let a=this.buffer.length;if(a>0&&this.buffer[a-4]!=0)for(;a>0&&this.buffer[a-2]>r;)this.buffer[a]=this.buffer[a-4],this.buffer[a+1]=this.buffer[a-3],this.buffer[a+2]=this.buffer[a-2],this.buffer[a+3]=this.buffer[a-1],a-=4,s>4&&(s-=4);this.buffer[a]=e,this.buffer[a+1]=t,this.buffer[a+2]=r,this.buffer[a+3]=s}}shift(e,t,r){let s=this.pos;if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=r,this.shiftContext(t,s),t<=this.p.parser.maxNode&&this.buffer.push(t,s,r,4);else{let n=e,{parser:a}=this.p;(r>this.pos||t<=a.maxNode)&&(this.pos=r,a.stateFlag(n,1)||(this.reducePos=r)),this.pushState(n,s),this.shiftContext(t,s),t<=a.maxNode&&this.buffer.push(t,s,r,4)}}apply(e,t,r){e&65536?this.reduce(e):this.shift(e,t,r)}useNode(e,t){let r=this.p.reused.length-1;(r<0||this.p.reused[r]!=e)&&(this.p.reused.push(e),r++);let s=this.pos;this.reducePos=this.pos=s+e.length,this.pushState(t,s),this.buffer.push(r,s,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(;t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let r=e.buffer.slice(t),s=e.bufferBase+t;for(;e&&s==e.bufferBase;)e=e.parent;return new qe(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,r,s,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let r=e<=this.p.parser.maxNode;r&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,r?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new ri(this);;){let r=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(r==0)return!1;if(!(r&65536))return!0;t.reduce(r)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let s=[];for(let n=0,a;n<t.length;n+=2)(a=t[n+1])!=this.state&&this.p.parser.hasAction(a,e)&&s.push(t[n],a);if(this.stack.length<120)for(let n=0;s.length<8&&n<t.length;n+=2){let a=t[n+1];s.some((l,h)=>h&1&&l==a)||s.push(t[n],a)}t=s}let r=[];for(let s=0;s<t.length&&r.length<4;s+=2){let n=t[s+1];if(n==this.state)continue;let a=this.split();a.pushState(n,this.pos),a.storeNode(0,a.pos,a.pos,4,!0),a.shiftContext(t[s],this.pos),a.score-=200,r.push(a)}return r}forceReduce(){let{parser:e}=this.p,t=e.stateSlot(this.state,5);if(!(t&65536))return!1;if(!e.validAction(this.state,t)){let r=t>>19,s=t&65535,n=this.stack.length-r*3;if(n<0||e.getGoto(this.stack[n],s,!1)<0){let a=this.findForcedReduction();if(a==null)return!1;t=a}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],r=(s,n)=>{if(!t.includes(s))return t.push(s),e.allActions(s,a=>{if(!(a&393216))if(a&65536){let l=(a>>19)-n;if(l>1){let h=a&65535,f=this.stack.length-l*3;if(f>=0&&e.getGoto(this.stack[f],h,!1)>=0)return l<<19|65536|h}}else{let l=r(a,n+1);if(l!=null)return l}})};return r(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t<this.stack.length;t+=3)if(this.stack[t]!=e.stack[t])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(t)))}reduceContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(t)))}emitContext(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let t=new nt(this.curContext.tracker,e);t.hash!=this.curContext.hash&&this.emitContext(),this.curContext=t}}setLookAhead(e){e>this.lookAhead&&(this.emitLookAhead(),this.lookAhead=e)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}},nt=class{constructor(i,e){this.tracker=i,this.context=e,this.hash=i.strict?i.hash(e):0}},at;(function(i){i[i.Insert=200]="Insert",i[i.Delete=190]="Delete",i[i.Reduce=100]="Reduce",i[i.MaxNext=4]="MaxNext",i[i.MaxInsertStackDepth=300]="MaxInsertStackDepth",i[i.DampenInsertStackDepth=120]="DampenInsertStackDepth",i[i.MinBigReduction=2e3]="MinBigReduction"})(at||(at={}));var ri=class{constructor(i){this.start=i,this.state=i.state,this.stack=i.stack,this.base=this.stack.length}reduce(i){let e=i&65535,t=i>>19;t==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(t-1)*3;let r=this.start.p.parser.getGoto(this.stack[this.base-3],e,!0);this.state=r}},si=class Ge{constructor(e,t,r){this.stack=e,this.pos=t,this.index=r,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new Ge(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}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]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new Ge(this.stack,this.pos,this.index)}};function Qe(i,e=Uint16Array){if(typeof i!="string")return i;let t=null;for(let r=0,s=0;r<i.length;){let n=0;for(;;){let a=i.charCodeAt(r++),l=!1;if(a==126){n=65535;break}a>=92&&a--,a>=34&&a--;let h=a-32;if(h>=46&&(h-=46,l=!0),n+=h,l)break;n*=46}t?t[s++]=n:t=new e(n)}return t}var Pe=class{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}},lt=new Pe,ni=class{constructor(i,e){this.input=i,this.ranges=e,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=lt,this.rangeIndex=0,this.pos=this.chunkPos=e[0].from,this.range=e[0],this.end=e[e.length-1].to,this.readNext()}resolveOffset(i,e){let t=this.range,r=this.rangeIndex,s=this.pos+i;for(;s<t.from;){if(!r)return null;let n=this.ranges[--r];s-=t.from-n.to,t=n}for(;e<0?s>t.to:s>=t.to;){if(r==this.ranges.length-1)return null;let n=this.ranges[++r];s+=n.from-t.to,t=n}return s}clipPos(i){if(i>=this.range.from&&i<this.range.to)return i;for(let e of this.ranges)if(e.to>i)return Math.max(i,e.from);return this.end}peek(i){let e=this.chunkOff+i,t,r;if(e>=0&&e<this.chunk.length)t=this.pos+i,r=this.chunk.charCodeAt(e);else{let s=this.resolveOffset(i,1);if(s==null)return-1;if(t=s,t>=this.chunk2Pos&&t<this.chunk2Pos+this.chunk2.length)r=this.chunk2.charCodeAt(t-this.chunk2Pos);else{let n=this.rangeIndex,a=this.range;for(;a.to<=t;)a=this.ranges[++n];this.chunk2=this.input.chunk(this.chunk2Pos=t),t+this.chunk2.length>a.to&&(this.chunk2=this.chunk2.slice(0,a.to-t)),r=this.chunk2.charCodeAt(0)}}return t>=this.token.lookAhead&&(this.token.lookAhead=t+1),r}acceptToken(i,e=0){let t=e?this.resolveOffset(e,-1):this.pos;if(t==null||t<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=i,this.token.end=t}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:i,chunkPos:e}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=i,this.chunk2Pos=e,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let i=this.input.chunk(this.pos),e=this.pos+i.length;this.chunk=e>this.range.to?i.slice(0,this.range.to-this.pos):i,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(i=1){for(this.chunkOff+=i;this.pos+i>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();i-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=i,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(i,e){if(e?(this.token=e,e.start=i,e.lookAhead=i+1,e.value=e.extended=-1):this.token=lt,this.pos!=i){if(this.pos=i,i==this.end)return this.setDone(),this;for(;i<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;i>=this.range.to;)this.range=this.ranges[++this.rangeIndex];i>=this.chunkPos&&i<this.chunkPos+this.chunk.length?this.chunkOff=i-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(i,e){if(i>=this.chunkPos&&e<=this.chunkPos+this.chunk.length)return this.chunk.slice(i-this.chunkPos,e-this.chunkPos);if(i>=this.chunk2Pos&&e<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(i-this.chunk2Pos,e-this.chunk2Pos);if(i>=this.range.from&&e<=this.range.to)return this.input.read(i,e);let t="";for(let r of this.ranges){if(r.from>=e)break;r.to>i&&(t+=this.input.read(Math.max(r.from,i),Math.min(r.to,e)))}return t}},se=class{constructor(i,e){this.data=i,this.id=e}token(i,e){let{parser:t}=e.p;ai(this.data,i,e,this.id,t.data,t.tokenPrecTable)}};se.prototype.contextual=se.prototype.fallback=se.prototype.extend=!1;se.prototype.fallback=se.prototype.extend=!1;var wt=class{constructor(i,e={}){this.token=i,this.contextual=!!e.contextual,this.fallback=!!e.fallback,this.extend=!!e.extend}};function ai(i,e,t,r,s,n){let a=0,l=1<<r,{dialect:h}=t.p.parser;e:for(;l&i[a];){let f=i[a+1];for(let S=a+3;S<f;S+=2)if((i[S+1]&l)>0){let k=i[S];if(h.allows(k)&&(e.token.value==-1||e.token.value==k||li(k,e.token.value,s,n))){e.acceptToken(k);break}}let o=e.next,m=0,Q=i[a+2];if(e.next<0&&Q>m&&i[f+Q*3-3]==65535&&i[f+Q*3-3]==65535){a=i[f+Q*3-1];continue e}for(;m<Q;){let S=m+Q>>1,k=f+S+(S<<1),V=i[k],I=i[k+1]||65536;if(o<V)Q=S;else if(o>=I)m=S+1;else{a=i[k+2],e.advance();continue e}}break}}function ht(i,e,t){for(let r=e,s;(s=i[r])!=65535;r++)if(s==t)return r-e;return-1}function li(i,e,t,r){let s=ht(t,r,e);return s<0||ht(t,r,i)<s}var q=typeof process<"u"&&process.env&&/\bparse\b/.test({}.LOG),ze=null,ot;(function(i){i[i.Margin=25]="Margin"})(ot||(ot={}));function ft(i,e,t){let r=i.cursor(A.IncludeAnonymous);for(r.moveTo(e);;)if(!(t<0?r.childBefore(e):r.childAfter(e)))for(;;){if((t<0?r.to<e:r.from>e)&&!r.type.isError)return t<0?Math.max(0,Math.min(r.to-1,e-25)):Math.min(i.length,Math.max(r.from+1,e+25));if(t<0?r.prevSibling():r.nextSibling())break;if(!r.parent())return t<0?0:i.length}}var hi=class{constructor(i,e){this.fragments=i,this.nodeSet=e,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let i=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(i){for(this.safeFrom=i.openStart?ft(i.tree,i.from+i.offset,1)-i.offset:i.from,this.safeTo=i.openEnd?ft(i.tree,i.to+i.offset,-1)-i.offset:i.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(i.tree),this.start.push(-i.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(i){if(i<this.nextStart)return null;for(;this.fragment&&this.safeTo<=i;)this.nextFragment();if(!this.fragment)return null;for(;;){let e=this.trees.length-1;if(e<0)return this.nextFragment(),null;let t=this.trees[e],r=this.index[e];if(r==t.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let s=t.children[r],n=this.start[e]+t.positions[r];if(n>i)return this.nextStart=n,null;if(s instanceof G){if(n==i){if(n<this.safeFrom)return null;let a=n+s.length;if(a<=this.safeTo){let l=s.prop(v.lookAhead);if(!l||a+l<this.fragment.to)return s}}this.index[e]++,n+s.length>=Math.max(this.safeFrom,i)&&(this.trees.push(s),this.start.push(n),this.index.push(0))}else this.index[e]++,this.nextStart=n+s.length}}},oi=class{constructor(i,e){this.stream=e,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=i.tokenizers.map(t=>new Pe)}getActions(i){let e=0,t=null,{parser:r}=i.p,{tokenizers:s}=r,n=r.stateSlot(i.state,3),a=i.curContext?i.curContext.hash:0,l=0;for(let h=0;h<s.length;h++){if(!(1<<h&n))continue;let f=s[h],o=this.tokens[h];if(!(t&&!f.fallback)&&((f.contextual||o.start!=i.pos||o.mask!=n||o.context!=a)&&(this.updateCachedToken(o,f,i),o.mask=n,o.context=a),o.lookAhead>o.end+25&&(l=Math.max(o.lookAhead,l)),o.value!=0)){let m=e;if(o.extended>-1&&(e=this.addActions(i,o.extended,o.end,e)),e=this.addActions(i,o.value,o.end,e),!f.extend&&(t=o,e>m))break}}for(;this.actions.length>e;)this.actions.pop();return l&&i.setLookAhead(l),!t&&i.pos==this.stream.end&&(t=new Pe,t.value=i.p.parser.eofTerm,t.start=t.end=i.pos,e=this.addActions(i,t.value,t.end,e)),this.mainToken=t,this.actions}getMainToken(i){if(this.mainToken)return this.mainToken;let e=new Pe,{pos:t,p:r}=i;return e.start=t,e.end=Math.min(t+1,r.stream.end),e.value=t==r.stream.end?r.parser.eofTerm:0,e}updateCachedToken(i,e,t){let r=this.stream.clipPos(t.pos);if(e.token(this.stream.reset(r,i),t),i.value>-1){let{parser:s}=t.p;for(let n=0;n<s.specialized.length;n++)if(s.specialized[n]==i.value){let a=s.specializers[n](this.stream.read(i.start,i.end),t);if(a>=0&&t.p.parser.dialect.allows(a>>1)){a&1?i.extended=a>>1:i.value=a>>1;break}}}else i.value=0,i.end=this.stream.clipPos(r+1)}putAction(i,e,t,r){for(let s=0;s<r;s+=3)if(this.actions[s]==i)return r;return this.actions[r++]=i,this.actions[r++]=e,this.actions[r++]=t,r}addActions(i,e,t,r){let{state:s}=i,{parser:n}=i.p,{data:a}=n;for(let l=0;l<2;l++)for(let h=n.stateSlot(s,l?2:1);;h+=3){if(a[h]==65535)if(a[h+1]==1)h=L(a,h+2);else{r==0&&a[h+1]==2&&(r=this.putAction(L(a,h+2),e,t,r));break}a[h]==e&&(r=this.putAction(L(a,h+1),e,t,r))}return r}},ut;(function(i){i[i.Distance=5]="Distance",i[i.MaxRemainingPerStep=3]="MaxRemainingPerStep",i[i.MinBufferLengthPrune=500]="MinBufferLengthPrune",i[i.ForceReduceLimit=10]="ForceReduceLimit",i[i.CutDepth=15e3]="CutDepth",i[i.CutTo=9e3]="CutTo",i[i.MaxLeftAssociativeReductionCount=300]="MaxLeftAssociativeReductionCount",i[i.MaxStackCount=12]="MaxStackCount"})(ut||(ut={}));var fi=class{constructor(i,e,t,r){this.parser=i,this.input=e,this.ranges=r,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new ni(e,r),this.tokens=new oi(i,this.stream),this.topTerm=i.top[1];let{from:s}=r[0];this.stacks=[ii.start(this,i.top[0],s)],this.fragments=t.length&&this.stream.end-s>i.bufferLength*4?new hi(t,i.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let i=this.stacks,e=this.minStackPos,t=this.stacks=[],r,s;if(this.bigReductionCount>300&&i.length==1){let[n]=i;for(;n.forceReduce()&&n.stack.length&&n.stack[n.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let n=0;n<i.length;n++){let a=i[n];for(;;){if(this.tokens.mainToken=null,a.pos>e)t.push(a);else{if(this.advanceStack(a,t,i))continue;{r||(r=[],s=[]),r.push(a);let l=this.tokens.getMainToken(a);s.push(l.value,l.end)}}break}}if(!t.length){let n=r&&di(r);if(n)return this.stackToTree(n);if(this.parser.strict)throw q&&r&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+e);this.recovering||(this.recovering=5)}if(this.recovering&&r){let n=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,s,t);if(n)return this.stackToTree(n.forceAll())}if(this.recovering){let n=this.recovering==1?1:this.recovering*3;if(t.length>n)for(t.sort((a,l)=>l.score-a.score);t.length>n;)t.pop();t.some(a=>a.reducePos>e)&&this.recovering--}else if(t.length>1){e:for(let n=0;n<t.length-1;n++){let a=t[n];for(let l=n+1;l<t.length;l++){let h=t[l];if(a.sameState(h)||a.buffer.length>500&&h.buffer.length>500)if((a.score-h.score||a.buffer.length-h.buffer.length)>0)t.splice(l--,1);else{t.splice(n--,1);continue e}}}t.length>12&&t.splice(12,t.length-12)}this.minStackPos=t[0].pos;for(let n=1;n<t.length;n++)t[n].pos<this.minStackPos&&(this.minStackPos=t[n].pos);return null}stopAt(i){if(this.stoppedAt!=null&&this.stoppedAt<i)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=i}advanceStack(i,e,t){let r=i.pos,{parser:s}=this,n=q?this.stackID(i)+" -> ":"";if(this.stoppedAt!=null&&r>this.stoppedAt)return i.forceReduce()?i:null;if(this.fragments){let h=i.curContext&&i.curContext.tracker.strict,f=h?i.curContext.hash:0;for(let o=this.fragments.nodeAt(r);o;){let m=this.parser.nodeSet.types[o.type.id]==o.type?s.getGoto(i.state,o.type.id):-1;if(m>-1&&o.length&&(!h||(o.prop(v.contextHash)||0)==f))return i.useNode(o,m),q&&console.log(n+this.stackID(i)+` (via reuse of ${s.getName(o.type.id)})`),!0;if(!(o instanceof G)||o.children.length==0||o.positions[0]>0)break;let Q=o.children[0];if(Q instanceof G&&o.positions[0]==0)o=Q;else break}}let a=s.stateSlot(i.state,4);if(a>0)return i.reduce(a),q&&console.log(n+this.stackID(i)+` (via always-reduce ${s.getName(a&65535)})`),!0;if(i.stack.length>=15e3)for(;i.stack.length>9e3&&i.forceReduce(););let l=this.tokens.getActions(i);for(let h=0;h<l.length;){let f=l[h++],o=l[h++],m=l[h++],Q=h==l.length||!t,S=Q?i:i.split();if(S.apply(f,o,m),q&&console.log(n+this.stackID(S)+` (via ${f&65536?`reduce of ${s.getName(f&65535)}`:"shift"} for ${s.getName(o)} @ ${r}${S==i?"":", split"})`),Q)return!0;S.pos>r?e.push(S):t.push(S)}return!1}advanceFully(i,e){let t=i.pos;for(;;){if(!this.advanceStack(i,null,null))return!1;if(i.pos>t)return Ot(i,e),!0}}runRecovery(i,e,t){let r=null,s=!1;for(let n=0;n<i.length;n++){let a=i[n],l=e[n<<1],h=e[(n<<1)+1],f=q?this.stackID(a)+" -> ":"";if(a.deadEnd&&(s||(s=!0,a.restart(),q&&console.log(f+this.stackID(a)+" (restarted)"),this.advanceFully(a,t))))continue;let o=a.split(),m=f;for(let Q=0;o.forceReduce()&&Q<10&&(q&&console.log(m+this.stackID(o)+" (via force-reduce)"),!this.advanceFully(o,t));Q++)q&&(m=this.stackID(o)+" -> ");for(let Q of a.recoverByInsert(l))q&&console.log(f+this.stackID(Q)+" (via recover-insert)"),this.advanceFully(Q,t);this.stream.end>a.pos?(h==a.pos&&(h++,l=0),a.recoverByDelete(l,h),q&&console.log(f+this.stackID(a)+` (via recover-delete ${this.parser.getName(l)})`),Ot(a,t)):(!r||r.score<a.score)&&(r=a)}return r}stackToTree(i){return i.close(),G.build({buffer:si.create(i),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:i.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(i){let e=(ze||(ze=new WeakMap)).get(i);return e||ze.set(i,e=String.fromCodePoint(this.nextStackID++)),e+i}};function Ot(i,e){for(let t=0;t<e.length;t++){let r=e[t];if(r.pos==i.pos&&r.sameState(i)){e[t].score<i.score&&(e[t]=i);return}}e.push(i)}var ui=class{constructor(i,e,t){this.source=i,this.flags=e,this.disabled=t}allows(i){return!this.disabled||this.disabled[i]==0}},Ve=i=>i,Oi=class{constructor(i){this.start=i.start,this.shift=i.shift||Ve,this.reduce=i.reduce||Ve,this.reuse=i.reuse||Ve,this.hash=i.hash||(()=>0),this.strict=i.strict!==!1}},ci=class De extends ei{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let l=0;l<e.repeatNodeCount;l++)t.push("");let r=Object.keys(e.topRules).map(l=>e.topRules[l][1]),s=[];for(let l=0;l<t.length;l++)s.push([]);function n(l,h,f){s[l].push([h,h.deserialize(String(f))])}if(e.nodeProps)for(let l of e.nodeProps){let h=l[0];typeof h=="string"&&(h=v[h]);for(let f=1;f<l.length;){let o=l[f++];if(o>=0)n(o,h,l[f++]);else{let m=l[f+-o];for(let Q=-o;Q>0;Q--)n(l[f++],h,m);f++}}}this.nodeSet=new Lt(t.map((l,h)=>K.define({name:h>=this.minRepeatTerm?void 0:l,id:h,props:s[h],top:r.indexOf(h)>-1,error:h==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(h)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=yt;let a=Qe(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let l=0;l<this.specializerSpecs.length;l++)this.specialized[l]=this.specializerSpecs[l].term;this.specializers=this.specializerSpecs.map(ct),this.states=Qe(e.states,Uint32Array),this.data=Qe(e.stateData),this.goto=Qe(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(l=>typeof l=="number"?new se(a,l):l),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,r){let s=new fi(this,e,t,r);for(let n of this.wrappers)s=n(s,e,t,r);return s}getGoto(e,t,r=!1){let s=this.goto;if(t>=s[0])return-1;for(let n=s[t+1];;){let a=s[n++],l=a&1,h=s[n++];if(l&&r)return h;for(let f=n+(a>>1);n<f;n++)if(s[n]==e)return h;if(l)return-1}}hasAction(e,t){let r=this.data;for(let s=0;s<2;s++)for(let n=this.stateSlot(e,s?2:1),a;;n+=3){if((a=r[n])==65535)if(r[n+1]==1)a=r[n=L(r,n+2)];else{if(r[n+1]==2)return L(r,n+2);break}if(a==t||a==0)return L(r,n+1)}return 0}stateSlot(e,t){return this.states[e*6+t]}stateFlag(e,t){return(this.stateSlot(e,0)&t)>0}validAction(e,t){return!!this.allActions(e,r=>r==t?!0:null)}allActions(e,t){let r=this.stateSlot(e,4),s=r?t(r):void 0;for(let n=this.stateSlot(e,1);s==null;n+=3){if(this.data[n]==65535)if(this.data[n+1]==1)n=L(this.data,n+2);else break;s=t(L(this.data,n+1))}return s}nextStates(e){let t=[];for(let r=this.stateSlot(e,1);;r+=3){if(this.data[r]==65535)if(this.data[r+1]==1)r=L(this.data,r+2);else break;if(!(this.data[r+2]&1)){let s=this.data[r+1];t.some((n,a)=>a&1&&n==s)||t.push(this.data[r],s)}}return t}configure(e){let t=Object.assign(Object.create(De.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let r=this.topRules[e.top];if(!r)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=r}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(r=>{let s=e.tokenizers.find(n=>n.from==r);return s?s.to:r})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((r,s)=>{let n=e.specializers.find(l=>l.from==r.external);if(!n)return r;let a=Object.assign(Object.assign({},r),{external:n.to});return t.specializers[s]=ct(a),a})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),e.bufferLength!=null&&(t.bufferLength=e.bufferLength),t}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),r=t.map(()=>!1);if(e)for(let n of e.split(" ")){let a=t.indexOf(n);a>=0&&(r[a]=!0)}let s=null;for(let n=0;n<t.length;n++)if(!r[n])for(let a=this.dialects[t[n]],l;(l=this.data[a++])!=65535;)(s||(s=new Uint8Array(this.maxTerm+1)))[l]=1;return new ui(e,r,s)}static deserialize(e){return new De(e)}};function L(i,e){return i[e]|i[e+1]<<16}function di(i){let e=null;for(let t of i){let r=t.p.stoppedAt;(t.pos==t.p.stream.end||r!=null&&t.pos>r)&&t.p.parser.stateFlag(t.state,2)&&(!e||e.score<t.score)&&(e=t)}return e}function ct(i){if(i.external){let e=i.extend?1:0;return(t,r)=>i.external(t,r)<<1|e}return i.get}var pi=0,H=class Ut{constructor(e,t,r){this.set=e,this.base=t,this.modified=r,this.id=pi++}static define(e){if(e!=null&&e.base)throw new Error("Can not derive from a modified tag");let t=new Ut([],null,[]);if(t.set.push(t),e)for(let r of e.set)t.set.push(r);return t}static defineModifier(){let e=new dt;return t=>t.modified.indexOf(e)>-1?t:dt.get(t.base||t,t.modified.concat(e).sort((r,s)=>r.id-s.id))}},gi=0,dt=class Rt{constructor(){this.instances=[],this.id=gi++}static get(e,t){if(!t.length)return e;let r=t[0].instances.find(l=>l.base==e&&Qi(t,l.modified));if(r)return r;let s=[],n=new H(s,e,t);for(let l of t)l.instances.push(n);let a=mi(t);for(let l of e.set)if(!l.modified.length)for(let h of a)s.push(Rt.get(l,h));return n}};function Qi(i,e){return i.length==e.length&&i.every((t,r)=>t==e[r])}function mi(i){let e=[[]];for(let t=0;t<i.length;t++)for(let r=0,s=e.length;r<s;r++)e.push(e[r].concat(i[t]));return e.sort((t,r)=>r.length-t.length)}function xi(i){let e=Object.create(null);for(let t in i){let r=i[t];Array.isArray(r)||(r=[r]);for(let s of t.split(" "))if(s){let n=[],a=2,l=s;for(let m=0;;){if(l=="..."&&m>0&&m+3==s.length){a=1;break}let Q=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!Q)throw new RangeError("Invalid path: "+s);if(n.push(Q[0]=="*"?"":Q[0][0]=='"'?JSON.parse(Q[0]):Q[0]),m+=Q[0].length,m==s.length)break;let S=s[m++];if(m==s.length&&S=="!"){a=0;break}if(S!="/")throw new RangeError("Invalid path: "+s);l=s.slice(m)}let h=n.length-1,f=n[h];if(!f)throw new RangeError("Invalid path: "+s);let o=new Fe(r,a,h>0?n.slice(0,h):null);e[f]=o.sort(e[f])}}return bi.add(e)}var bi=new v,Fe=class{constructor(i,e,t,r){this.tags=i,this.mode=e,this.context=t,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(i){return!i||i.depth<this.depth?(this.next=i,this):(i.next=this.sort(i.next),i)}get depth(){return this.context?this.context.length:0}};Fe.empty=new Fe([],2,null);function yi(i,e){let t=Object.create(null);for(let n of i)if(!Array.isArray(n.tag))t[n.tag.id]=n.class;else for(let a of n.tag)t[a.id]=n.class;let{scope:r,all:s=null}=e||{};return{style:n=>{let a=s;for(let l of n)for(let h of l.set){let f=t[h.id];if(f){a=a?a+" "+f:f;break}}return a},scope:r}}var O=H.define,me=O(),J=O(),pt=O(J),gt=O(J),ee=O(),xe=O(ee),Ye=O(ee),Z=O(),te=O(Z),D=O(),F=O(),Ze=O(),oe=O(Ze),be=O(),d={comment:me,lineComment:O(me),blockComment:O(me),docComment:O(me),name:J,variableName:O(J),typeName:pt,tagName:O(pt),propertyName:gt,attributeName:O(gt),className:O(J),labelName:O(J),namespace:O(J),macroName:O(J),literal:ee,string:xe,docString:O(xe),character:O(xe),attributeValue:O(xe),number:Ye,integer:O(Ye),float:O(Ye),bool:O(ee),regexp:O(ee),escape:O(ee),color:O(ee),url:O(ee),keyword:D,self:O(D),null:O(D),atom:O(D),unit:O(D),modifier:O(D),operatorKeyword:O(D),controlKeyword:O(D),definitionKeyword:O(D),moduleKeyword:O(D),operator:F,derefOperator:O(F),arithmeticOperator:O(F),logicOperator:O(F),bitwiseOperator:O(F),compareOperator:O(F),updateOperator:O(F),definitionOperator:O(F),typeOperator:O(F),controlOperator:O(F),punctuation:Ze,separator:O(Ze),bracket:oe,angleBracket:O(oe),squareBracket:O(oe),paren:O(oe),brace:O(oe),content:Z,heading:te,heading1:O(te),heading2:O(te),heading3:O(te),heading4:O(te),heading5:O(te),heading6:O(te),contentSeparator:O(Z),list:O(Z),quote:O(Z),emphasis:O(Z),strong:O(Z),link:O(Z),monospace:O(Z),strikethrough:O(Z),inserted:O(),deleted:O(),changed:O(),invalid:O(),meta:be,documentMeta:O(be),annotation:O(be),processingInstruction:O(be),definition:H.defineModifier(),constant:H.defineModifier(),function:H.defineModifier(),standard:H.defineModifier(),local:H.defineModifier(),special:H.defineModifier()};yi([{tag:d.link,class:"tok-link"},{tag:d.heading,class:"tok-heading"},{tag:d.emphasis,class:"tok-emphasis"},{tag:d.strong,class:"tok-strong"},{tag:d.keyword,class:"tok-keyword"},{tag:d.atom,class:"tok-atom"},{tag:d.bool,class:"tok-bool"},{tag:d.url,class:"tok-url"},{tag:d.labelName,class:"tok-labelName"},{tag:d.inserted,class:"tok-inserted"},{tag:d.deleted,class:"tok-deleted"},{tag:d.literal,class:"tok-literal"},{tag:d.string,class:"tok-string"},{tag:d.number,class:"tok-number"},{tag:[d.regexp,d.escape,d.special(d.string)],class:"tok-string2"},{tag:d.variableName,class:"tok-variableName"},{tag:d.local(d.variableName),class:"tok-variableName tok-local"},{tag:d.definition(d.variableName),class:"tok-variableName tok-definition"},{tag:d.special(d.variableName),class:"tok-variableName2"},{tag:d.definition(d.propertyName),class:"tok-propertyName tok-definition"},{tag:d.typeName,class:"tok-typeName"},{tag:d.namespace,class:"tok-namespace"},{tag:d.className,class:"tok-className"},{tag:d.macroName,class:"tok-macroName"},{tag:d.propertyName,class:"tok-propertyName"},{tag:d.operator,class:"tok-operator"},{tag:d.comment,class:"tok-comment"},{tag:d.meta,class:"tok-meta"},{tag:d.invalid,class:"tok-invalid"},{tag:d.punctuation,class:"tok-punctuation"}]);function Qt(i){let e=Object.keys(i).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function Si(i){let e=Object.create(null),t=Object.create(null);for(let{label:s}of i){e[s[0]]=!0;for(let n=1;n<s.length;n++)t[s[n]]=!0}let r=Qt(e)+Qt(t)+"*$";return[new RegExp("^"+r),new RegExp(r)]}function ki(i){let e=i.map(s=>typeof s=="string"?{label:s}:s),[t,r]=e.every(s=>/^\w+$/.test(s.label))?[/\w*$/,/\w+$/]:Si(e);return s=>{let n=s.matchBefore(r);return n||s.explicit?{from:n?n.from:s.pos,options:e,validFor:t}:null}}function Pi(i,e){return t=>{for(let r=Dt(t.state).r