@okcontract/lambdascript 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ !function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i((t="undefined"!=typeof globalThis?globalThis:t||self).lambdascript={})}(this,(function(t){"use strict";const i=t=>t?"number"==typeof t?t:Array.isArray(t)?t.length:"object"==typeof t?Object.keys(t).length:1:0,e=(t,e,s=!0)=>{const r=i(e);return`${s?`${r} `:""}${t}${r>1?"s":""}`},s=/^-?\d+\/\d+$/;class r{constructor(t){this.output=()=>{const t=this.h[0],i=this.h[1];return`"${this.h[2]?"-":""}${t.toString()}${1n===i?"":`/${i.toString()}`}"`},this.simplify=()=>new r(l(this.h)),this.toString=()=>n(this.h),this.toBigInt=()=>{const[t,i,e]=this.h;return e?-t/i:t/i},this.toNumber=()=>{const[t,i,e]=this.h;return e?Number(-t)/Number(i):Number(t)/Number(i)},this.add=t=>new r(a(this.h,t.h)),this.subtract=t=>new r(u(this.h,t.h)),this.multiply=t=>new r(f(this.h,t.h)),this.divide=t=>new r(c(this.h,t.h)),this.power=t=>new r(p(this.h,t.h)),this.min=(...t)=>new r(function(t,...i){let e=t;for(const s of i)$(s,e)<0&&(e=s);return e}(this.h,...t.map((t=>t.h)))),this.max=(...t)=>new r(function(t,...i){let e=t;for(const s of i)$(s,e)>0&&(e=s);return e}(this.h,...t.map((t=>t.h)))),this.compare=(t,i)=>{const e=this.simplify(),s=i.simplify(),r=e.h[2]?-e.h[0]*s.h[1]:e.h[0]*s.h[1],n=s.h[2]?-s.h[0]*e.h[1]:s.h[0]*e.h[1];switch(t){case"<":return r<n;case">":return r>n;case"<=":return r<=n;case">=":return r>=n;case"==":return r===n;case"!=":return r!==n;default:throw new Error("Invalid operator. Use one of these: < > <= >= == !=")}},this.equals=t=>this.compare("==",t),this.floor=()=>{const[t,i,e]=this.h;let s=t/i;return e&&t%i!==0n&&(s+=1n),new r([s,1n,e])},this.h=Array.isArray(t)&&3===t.length&&"bigint"==typeof t[0]&&"bigint"==typeof t[1]&&"boolean"==typeof t[2]?t:h(t)}get toPrettyString(){return n(this.h)}}const n=t=>{const[i,e,s]=l(t);return`${s?"-":""}${i.toString()}${e>1n?`/${e.toString()}`:""}`},h=t=>{switch(typeof t){case"bigint":return[t<0n?-t:t,1n,t<0n];case"number":return O(t);case"string":if(t.includes("."))return O(Number.parseFloat(t));if(t.includes("/")){const[i,e]=t.split("/").map((t=>BigInt(t.trim()))),s=i<0n;return[s?-i:i,e,s]}return h(BigInt(t))}};function O(t,i=1e6){const e=1/(i*i);let[s,r]=[1n,0n],[n,h]=[0n,1n],O=Math.abs(t);do{const i=BigInt(Math.floor(O)),o=O-Number(i);if([n,s]=[s,i*s+n],[h,r]=[r,i*r+h],Math.abs(Number(s)/Number(r)-Math.abs(t))<e)break;O=1/o}while(Number(r)<i);return[s,r,t<0]}function o(t,i){return 0n===i?t:o(i,t%i)}function l([t,i,e]){const s=o(t,i);return[t/s,i/s,e]}function a([t,i,e],[s,r,n]){const h=(e?-1n:1n)*t*r+(n?-1n:1n)*s*i,O=i*r,l=h<0n?-h:h,a=o(l,O);return[l/a,O/a,h<0n]}const u=(t,i)=>a(t,(([t,i,e])=>[t,i,!e])(i)),f=([t,i,e],[s,r,n])=>l([t*s,i*r,e!==n]),c=([t,i,e],[s,r,n])=>{if(s===BigInt(0))throw new Error("Division by zero");return l([t*r,i*s,e!==n])};function d(t,i=2n,e=-1){let s=0n,r=t,n=e;for(;r**i!==i&&r!==s&&--n&&(s=r,r=((i-1n)*r+t/r**(i-1n))/i,!(n<0&&(r-s)**2n===1n)););(t-(r-1n)**i)**2n<(t-r**i)**2n&&(r-=1n),(t-(r+1n)**i)**2n<(t-r**i)**2n&&(r+=1n);return[r,t-r**i]}const p=([t,i,e],[s,r,n])=>{if(n)throw new Error("Exponent must be a non-negative integer");if(0n===s)return[1n,1n,!1];if(1n!==r){if(e)throw new Error("Cannot root a negative base");const[s,n]=d(t,r),[h,O]=d(i,r);if(0n!==n||0n!==O)throw new Error("There is a remainder");return l([s,h,!1])}return l([t**s,i**s,e&&s%2n!==0n])};function $([t,i,e],[s,r,n]){if(e&&!n)return-1;if(!e&&n)return 1;const h=t*r,O=s*i;return Number(e&&n?O-h:h-O)}const Q=new r(0),w="app",g="const",b="var",y="lst",m="obj",P="λ",v="field",R="error",x="tup",k=Object.entries({[w]:"NameApplication",[g]:"NameConstant",[b]:"NameVariable",[y]:"NameList",[m]:"NameObject",[P]:"NameLambda",[v]:"NameField",[R]:"NameError",[x]:"NameTuple"}),X=t=>{const i=t instanceof r?t:new r(t);return{type:g,value:i}},S=t=>"number"==typeof t||"bigint"==typeof t?X(t):{type:g,value:t},T=t=>({type:y,elements:t}),E=t=>({type:m,values:t}),j=t=>Array.isArray(t)?T(t.map(j)):"object"==typeof t&&null!==t?E(Object.fromEntries(Object.entries(t).map((([t,i])=>[t,j(i)])))):S("string"==typeof t||"number"==typeof t||"bigint"==typeof t||"boolean"==typeof t?t:null),V=(t,i)=>({type:P,parameter:t,body:i}),U=(t,i)=>{const[e,...s]=t;return 0===s.length?V(e,i):V(e,U(s,i))},z=(t,i)=>Object.fromEntries(Object.entries(i).map((([i,e])=>t(i,e)))),Y=(t,i)=>{let e=!1;const s=i.map((i=>{const s=t(i);return s!==i&&(e=!0),s}));return e?s:i},C="any",G=(t,i,e)=>({kind:P,argTypes:t,argVariadic:e,returnType:i}),Z=t=>({kind:y,elementType:t}),_=(t,i=!1)=>({kind:m,fields:t,open:i}),q="generic",A="conditional";let W=0;function N(t){const i=W++;return{kind:b,type:`${t}${i}`}}function D(t){return t.kind===b}const F=t=>({kind:g,type:t});function M(t){return t.kind===g}const I={kind:C};function B(t,i){const e=i=>{switch(i.kind){case b:return t(i.type)??i;case g:return i;case P:{const t=Y(e,i.argTypes),s=e(i.returnType),r=i.argVariadic?e(i.argVariadic):void 0;return t===i.argTypes&&s===i.returnType&&r===i.argVariadic?i:{kind:P,argTypes:t,returnType:s,argVariadic:r}}case y:{const t=e(i.elementType);return t===i.elementType?i:{kind:y,elementType:t}}case m:{const t=((t,i)=>{let e=!1;const s=Object.entries(i).map((([i,s])=>{const r=t(s);return r!==s&&(e=!0),[i,r]}));return e?Object.fromEntries(s):i})(e,i.fields);return t===i.fields?i:{kind:m,fields:t,open:i.open}}case q:{const t=e(i.baseType),s=Y(e,i.typeArgs);return t===i.baseType&&s===i.typeArgs?i:{kind:q,baseType:t,typeArgs:s}}case A:{const t=e(i.check.left),s=e(i.check.right),r=e(i.trueType),n=e(i.falseType);return t===i.check.left&&s===i.check.right&&r===i.trueType&&n===i.falseType?i:{kind:A,check:{kind:i.check.kind,left:t,right:s},trueType:r,falseType:n}}case C:return I;case x:{const t=Y(e,i.elementTypes);return t===i.elementTypes?i:{kind:x,elementTypes:t}}default:return i}};return e(i)}const L=(t,i)=>{const e=(s=t.vars,r="in",Object.fromEntries(s.map((t=>{const i=W++;return[t,`${r}${i}`]}))));var s,r;return B((i=>{if(t.vars.includes(i))return{kind:b,type:e[i]}}),t.type)};const H=t=>{const i=function(t){const i=new Set;return B((t=>{i.add(t)}),t),Array.from(i)}(t);return{vars:i,type:t}};function J(t,i,e=t=>Promise.reject(t)){return t instanceof Promise?t.catch(e).then(i):i(t)}class K extends Error{constructor(t,i,e=t.toString()){super(`Cell ${e} has an error: ${i}`),this.source=t,this.sourceName=e,this.reason=i}}const tt=t=>{let i;return e=>(i&&t.O.collect(i),i=e,e)},it=t=>"object"==typeof t&&null!==t&&"Object"===t.constructor?.name,et={maxRank:6,resolvePointers:4},st=(t,i=1,e=et)=>e.maxRank&&i>e.maxRank?{"...":!0}:t instanceof lt?e.resolvePointers&&i<=e.resolvePointers?{[`ç[${t.id}]`]:st(t.value,i+1,e)}:{cell:t.id}:Array.isArray(t)?t.map((t=>st(t,i+1,e))):it(t)?Object.fromEntries(Object.entries(t).map((([t,s])=>[t,st(s,i+1,e)]))):t;class rt{constructor(t,i){if(!t)throw new Error("no sheet");this.O=t,this.o=[],this.working=new ut(t.working),this.errors=new ft(t.errors),i&&(this.l=i),this.u=t.addProxy(i)}get id(){return this.u}bless(t,i){this.O.bless(t,i)}name(t){return this.O.name(t)}new(t,i,e){const s=this.O.new(t,this,i,e);return this.working.addComputation(s.id,s.consolidatedValue),this.o.push(s),s}map(t,i,e,s){const r=this.O.map(t,i,e,this,s);return this.o.push(r),this.O.addProxyDependencies(this.u,t,r.id),r}mapNoPrevious(t,i,e,s){const r=this.O.mapNoPrevious(t,i,e,this,s);return this.o.push(r),this.O.addProxyDependencies(this.u,t,r.id),r}get(t){const i=this.O.get(t);return void 0!==i?.pointed?this.get(i.pointed):i}$(t){const i=this.working.startNewComputation(),e=this.O.$(t);return J(e,i),e}equals(t,i){return this.O.equals(t,i)}get size(){return this.o.length+1}wait(){return this.working.wait()}destroy(){this.O.collect(...this.o),this.o=[]}}let nt=0;class ht{}const Ot=new ht;class ot{constructor(){this.m=!1,this.P=[]}get name(){return"Unextended Subscriber"}subscribe(t,i){const e=this.value,s=nt++,r=i=>{this.m,t(i)};J(e,(t=>{t instanceof ht||void 0!==t&&r(t)}));const n=[r,s];return this.P.push(n),()=>{const t=this.P.indexOf(n);-1!==t&&this.P.splice(t,1)}}get subscribersCount(){return this.P.length}R(){if(this.m,void 0!==this.value){const t=Array.from(this.P);for(const i of t)i[0](this.value)}}}class lt extends ot{constructor(t,i,e=void 0,s={noFail:!1}){super(),this.k=0,this.X=0,this.S=null,this.T=t=>{},this.map=(t,i,e)=>this.O instanceof rt?this.O.map([this],t,i,e):this.O.map([this],t,i,void 0,e),this.init=(t,i)=>{const e=async()=>{const i=await this.get();return i instanceof Error?null:t(i)};return this.O instanceof rt?this.O.new(e(),i):this.O.new(e(),void 0,i)},this.get=async()=>void 0!==this.value?this.value:new Promise((t=>{let i;i=this.subscribe((e=>{void 0!==e&&(i(),t(e))}))})),this.O=t,this.id=i,this.dependencies=e||[],this.j=!1,this.V=s.noFail,this.U=!0,this.Y=t.id}get isPointer(){return this.U}get sheet(){return this.O instanceof rt?this.O.O:this.O}setPointed(t){this.sheet.debug([this.id],"setPointed:",{cell:this.name,newPointed:t,currentlyPointed:this.C}),t!==this.C&&(this.sheet.G(this.id,this.C,null===t?void 0:t),this.U=!0,this.C=null===t?void 0:t)}unsetPointed(){this.sheet.debug([this.id],"unsetPointed:",{cell:this.fullName,currentlyPointed:this.C}),this.sheet.G(this.id,this.pointed,void 0),this.U=!1,this.C=void 0}get pointed(){return this.U?this.C:void 0}get pointedCell(){return this.U&&null===!this.v?this.v:void 0}bless(t){this.O.bless(this.id,t)}get name(){return this.O.name(this.id)}get fullName(){return this.O.name(this.id,!0)}get value(){return this.isPointer?null===this.v?null:this.v?.value:this.v}setPendingComputation(t,i){if(this.O.working.addComputation(this.id,i),null===this.S||void 0===this.Z)this.Z=new Promise(((t,i)=>{this.T=t})),this.S=t;else{if(!(t>this.S))return;this.S=t}i.then((i=>{t===this.S&&(this.S=null,this.T(i))}),(()=>{t===this.S&&(this.S=null,this.T(Ot))}))}get pendingValue(){return void 0===this.Z&&(this.Z=void 0===this.v?void 0:Promise.resolve(this.v)),this.Z}get working(){return void 0===this.Z?Promise.resolve():this.Z.then((()=>{}))}get consolidatedValue(){if(this.sheet.debug([this.id],"consolidatedValue Call: ",{cell:this.fullName,valueRank:this.k,currentComputationRank:this.X}),this.k===this.X)return this.isPointer?void 0===this.v?this.get():null===this.v?null:this.v.consolidatedValue:void 0===this.v?this.get():this.v;return this.Z.then((t=>t instanceof ht?this.consolidatedValue:this.isPointer?null===this.v?null:this.v.consolidatedValue:t))}get consolidatedValueWthUndefined(){if(this.sheet.debug([this.id],"consolidatedValueWthUndefined Call:",{cell:this.name,valueRank:this.k,currentComputationRank:this.X}),this.k===this.X)return this.isPointer?(this.sheet.debug([this.id],"consolidatedValueWthUndefined",{isPointer:this.isPointer}),void 0===this.v||null===this.v?this.v:this.v.consolidatedValueWthUndefined):this.v;const t=this.Z;if(void 0!==t)return t.then((t=>this.isPointer?null===this.v||void 0===this.v?this.v:this.v.consolidatedValueWthUndefined:t));this.sheet.debug(void 0,"Pending undefined although compRank differs from value rank",{cell:this.id,valueRank:this.k,compRank:this.X},console.error)}get error(){return this.v instanceof Error?this.v:void 0}get consolidatedError(){return J(this.consolidatedValue,(t=>this.v instanceof Error?this.v:void 0))}refresh(){this.O.$(this.id)}_(t,i,e,s=!1){if(this.sheet.debug([this.id],(()=>`Cell ${this.name} (${this.id}) <== ${t}`),{currentValue:this.value,currentCompRank:this.X,currentValueRank:this.k,newValueRank:i}),void 0===t)return this.sheet.debug([this.id],"newValue undefined",{},console.trace),void(this.X===i&&(this.k=i));if(i<this.k)return void this.sheet.debug([this.id],`Cell ${this.fullName} <== ${t} has been invalidated`,{currentRank:this.X,newValueRank:i},console.warn);const r=!this.O.equals(this.v,t);if(this.sheet.debug([this.id],(()=>`Cell ${this.name} <== ${t}`),{currentValue:st(this.value),currentRank:this.X,newValueRank:i}),this.v=t,this.k=i,r&&this.q)try{const i=this.sheet.A(t);localStorage.setItem(this.q,i),this.sheet.debug([this.id],"ValueCell",{set:i,key:this.q})}catch(n){this.sheet.debug([this.id],"ValueCell: LocalStorage not available",{key:this.q},console.warn)}this.v instanceof Error&&!(this.v instanceof K)?(this.O.errors.W(this.id,this.v),this.j=!0):this.j&&this.O.errors.N(this.id),t instanceof lt?this.setPointed(t.id):this.U&&(null===t?this.setPointed(null):this.unsetPointed()),this.X===i&&r&&(s||this.R(),e&&this.O.$(this.id))}newError(t,i=void 0){if(void 0===i)return t;const e=this.O.name(i);return t instanceof K?t:new K(i,t,e)}}class at extends lt{constructor(t,i,e=void 0,s){super(t,i),this.update=t=>{if(this.isPointer){const i=this.O.get(this.pointed);if(i instanceof at)return i.update(t);throw this.newError("Cell is a pointer to a MapCell")}const i=this.v;if(void 0===i)throw this.newError("Cell not initialized");if(i instanceof Error)throw this.newError("Cell has error");if(this.X!==this.k)throw this.newError("Cell's value is being concurrently computed, cannot update");const e=t(i);void 0!==e&&this.set(e)},this.apply=t=>{if(this.isPointer)throw this.newError("Cell is a pointer");const i=this.v;if(void 0===i)throw this.newError("Cell not initialized");if(i instanceof Error)throw this.newError("Cell has error");if(this.X!==this.k)throw this.newError("Cell's value is being concurrently computed, cannot update");this.set(J(t(i),(()=>i))),this.refresh()};let r=e;if(s?.q)try{const t=localStorage.getItem(s?.q);this.sheet.debug([this.id],"ValueCell",{id:i,options:s,item:t}),null!==t&&(r=JSON.parse(t)),this.q=s?.q}catch(n){this.sheet.debug([this.id],"ValueCell: LocalStorage not available",{id:i,options:s},console.warn)}void 0!==r&&(this.v=r,r instanceof lt?this.setPointed(r.id):this.U=!1,this.setPendingComputation(0,Promise.resolve(r)))}set(t){this.sheet.debug([this.id],"Setting cell value",{cell:this.fullName,value:t}),this.X+=1;const i=this.X;if(t instanceof Promise){const e=t.then((t=>this._(t,i,!0,!0)),(t=>this._(t,i,!0,!0)));return this.setPendingComputation(i,e),e}this._(t,i,!0,!0),this.setPendingComputation(i,Promise.resolve(t))}}class ut extends ot{constructor(t){super(),this.value=!1,this.D=Promise.resolve(),this.F=0,this.resolve=()=>{},this.M=t}startNewComputation(){return this.value=!0,0===this.F&&(this.D=new Promise((t=>{this.resolve=t}))),this.F++,()=>{this.F--,0===this.F&&(this.value=!1,this.resolve())}}addComputation(t,i){if(i instanceof Promise){const e=this.startNewComputation();i.finally(e),this.M?.addComputation(t,i)}}get(){return this.value}wait(){return this.D}}class ft extends ot{constructor(t){super(),this.value=new Map,this.I=t}W(t,i){this.value.set(t,i),this.I?.W(t,i)}N(t){this.value.delete(t),this.I?.N(t)}get(){return this.value}}const ct=new Error("cell"),dt=t=>i=>{switch(i.type){case g:return t.const(i.value);case b:{const e=t.read(i.name);if(!e)throw new Error(`Undefined variable: ${i.name} in ${JSON.stringify(t.keys(!1))}`);return e}case w:{const e=dt(t)(i.function),s=i.params.map((i=>dt(t)(i)));return e.map((e=>{if("function"!=typeof e)throw new Error(`Not a function: ${i.function.type}`);return e?.local?e(...s):e(t,...s)}),"(app)")}case y:{const e=i.elements.map(dt(t));return t.proxy.new(e,"[]")}case x:{const e=i.elements.map(dt(t));return t.proxy.new(e,"{}")}case m:{const e=Object.entries(i.values),s=e.map((([t,i])=>t)),r=e.map((([t,i])=>i)).map(dt(t));return t.proxy.mapNoPrevious(r,((...t)=>Object.fromEntries(t.map(((t,i)=>[s[i],t])))),"{}")}case v:{const e=dt(t)(i.expr);if(v in i){const t=i.field;return e.map((i=>i[t]))}const s=dt(t)(i.sub);return t.proxy.map([e,s],((t,i)=>t[i]||null),":")}case P:{const e=e=>{const s=t.withValue(i.parameter,e);return dt(s)(i.body)};return e.local=!0,t.proxy.new(e,"eval.λ")}case R:throw new Error(`parse error: ${i.value}`);case"named":throw new Error('"named" node type is temporary and should not appears at evaluation');default:return i}},pt=["α","β","γ","δ","ε","ζ","η","θ","ι","κ","λ","μ","ν","ξ","ο","π","ρ","ς","σ","τ","υ","φ","χ","ψ","ω"];function $t(t){const i=new Map,e=t=>{switch(t.kind){case b:return function(t,i){if(!t.has(i.type)){const e=t.size,s=pt[e%pt.length]+(e<pt.length?"":`${Math.floor(e/pt.length)}`);t.set(i.type,s)}return t.get(i.type)}(i,t);case g:return t.type;case P:return`(${t.argTypes.map((t=>e(t))).join(", ")}) -> ${e(t.returnType)}`;case y:return`[${e(t.elementType)}]`;case x:return`{${t.elementTypes.map(e).join(", ")}}`;case m:return`{${Object.entries(t.fields).map((([t,i])=>`${t}: ${e(i)}`)).join(", ")}}`;default:return""}};return e(t)}const Qt={"+":1,"-":1,"*":2,"/":2,"^":3,"=":0,"<":0,">":0,"!":0};function wt(t,i=0){switch(t.type){case w:{let e;if(t.function.type===b){if(e=t.function.name,"!"!==e&&/^[\+\-\*\/=<>!^&|]/.test(e)){const s=`${t.params.map((t=>wt(t,Qt[e]))).join(` ${e} `)}`;return i>Qt[e]?`(${s})`:s}}else e=wt(t.function);const s=t.params.map(wt);return`${e}(${s.join(", ")})`}case g:{const i=t.value;return"object"==typeof i&&"toString"in i?i.toString():((t,i={})=>{let e="";const s=t=>{if(t instanceof lt){if(i?.failOnCell)throw ct;return s(t.value)}if(Array.isArray(t)){e+="[";let i=!0;for(const r of t)i||(e+=","),s(r),i=!1;e+="]"}else switch(typeof t){case"object":{if(null===t){e+="null";break}it(t)||(e+=JSON.stringify(t.toString())),e+="{";let r=!0;for(const[n,h]of Object.entries(t).sort((([t,i],[e,s])=>t<e?-1:t>e?1:0)))void 0===h||i.skipNull&&null===h||(r||(e+=","),e+=JSON.stringify(n),e+=":",s(h),r=!1);e+="}";break}case"function":case"symbol":break;case"bigint":e+=t<1000000000n?Number(t):`"${t.toString()}"`;break;default:e+=JSON.stringify(t)}};return s(t),e})(i)}case b:return t.name;case y:return`[${t.elements.map(wt).join(", ")}]`;case x:return`{${t.elements.map(wt).join(", ")}}`;case m:return`{${Object.entries(t.values).map((([t,i])=>`${t}: ${wt(i)}`)).join(", ")}}`;case P:return`${t.parameter} => (${wt(t.body)})`;case v:{const i="field"in t?t.field:wt(t.sub);return function(t){const i=Number.parseInt(t,10);return!Number.isNaN(i)&&Number.isInteger(i)&&i.toString()===t}(i)?`${wt(t.expr)}[${i}]`:`${wt(t.expr)}.${i}`}case"named":throw new Error('node type "named" is temporary and shouldn\'t appear in final AST');case R:return t.value;default:throw t}}class gt{constructor(){this.B=t=>B((t=>{const i=this.L[t];if(i)return this.B(i)}),t),this.H=(t,i,s,r)=>{if(t===i)return;const n=this.B(t),h=this.B(i);if(n!==h&&n.kind!==C&&h.kind!==C)if(D(n))this.L[n.type]=h;else if(D(h))this.H(h,n,void 0,r);else if(n.kind===P&&h.kind===P){if(n.argTypes.length!==h.argTypes.length)if(n.argVariadic&&n.argTypes.length<h.argTypes.length)for(let t=n.argTypes.length;t<h.argTypes.length;t++)this.H(n.argVariadic,h.argTypes[t],void 0,r);else{if(!(h.argVariadic&&h.argTypes.length<n.argTypes.length))throw new Error(`Function expects ${e("argument",n.argTypes.length,!0)} (${h.argTypes.length} provided) ${r?`at ${wt(r)}`:""}`);for(let t=h.argTypes.length;t<n.argTypes.length;t++)this.H(h.argVariadic,n.argTypes[t],void 0,r)}for(let t=0;t<n.argTypes.length;t++)this.H(n.argTypes[t],h.argTypes[t],void 0,r);this.H(n.returnType,h.returnType,void 0,r)}else if(n.kind===y&&h.kind===y)this.H(n.elementType,h.elementType,void 0,r);else if(n.kind===x&&h.kind===x){if(n.elementTypes.length!==h.elementTypes.length)throw new Error(`Different arity for tuples: ${n.elementTypes.length} vs ${h.elementTypes.length}`);for(let t=0;t<n.elementTypes.length;t++)this.H(n.elementTypes[t],h.elementTypes[t],void 0,r)}else if(n.kind===m&&h.kind===m){const t=new Set([...Object.keys(n.fields),...Object.keys(h.fields)]);for(const i of t)if(i in n.fields&&i in h.fields)this.H(n.fields[i],h.fields[i],void 0,r);else if(i in n.fields){if(!h.open)throw new Error(`Object field mismatch: ${i} missing in second type`)}else{if(!n.open)throw new Error(`Object field mismatch: ${i} missing in first type`);n.fields[i]=h.fields[i]}s&&(this.L[s]=n)}else if(n.kind===q&&h.kind===q){if(this.H(n.baseType,h.baseType,void 0,r),n.typeArgs.length!==h.typeArgs.length)throw new Error(`Generic type arguments mismatch: ${n.typeArgs.length} vs ${h.typeArgs.length}`);for(let t=0;t<n.typeArgs.length;t++)this.H(n.typeArgs[t],h.typeArgs[t],void 0,r)}else{if(n.kind!==A||h.kind!==A){if(M(n)&&M(h)&&n.type===h.type)return;throw new Error(`Type mismatch: ${$t(n)} vs ${$t(h)} ${r?` at ${wt(r)}`:""}`)}this.H(n.check.left,h.check.left,void 0,r),this.H(n.check.right,h.check.right,void 0,r),this.H(n.trueType,h.trueType,void 0,r),this.H(n.falseType,h.falseType,void 0,r)}},this.L={}}}const bt=t=>async i=>{const e=new gt,s=async(t,i)=>{switch(i.type){case g:{const e=((t,i=[])=>{if(t instanceof r)return"number";for(const e of i)if(e.instance(t))return e.type.type;return typeof t})(i.value,t?.options?.extensions);return F(e)}case b:{const e=t.library(i.name);if(e)return L(e.t);const s=t.type(i.name);if(!s)throw new Error(`Unbound variable: ${i.name}`);return L(s)}case w:{const r=await s(t,i.function),n=N("r");return e.H(r,{kind:P,argTypes:await Promise.all(i.params.map((i=>s(t,i)))),returnType:n},void 0,i),e.B(n)}case y:{const r=N("e");for(const n of i.elements){const h=await s(t,n);e.H(h,r,void 0,i)}return e.B({kind:y,elementType:r})}case x:{const r=await Promise.all(i.elements.map((i=>s(t,i))));return e.B({kind:x,elementTypes:r})}case m:{const e={};for(const r in i.values)e[r]=await s(t,i.values[r]);return{kind:m,fields:e,open:!1}}case v:{const r=await s(t,i.expr),n="field"in i?i.field:await s(t,i.sub),h="string"!=typeof n&&"const"===n.kind&&"number"===n.type;if((r.kind!==m||h)&&(r.kind!==y||!h)&&r.kind!==b)throw new Error(`In ${wt(i)}: Expected ${h?"a list":"an object"} or variable, got ${r.kind}`);if("string"!=typeof n&&!h)throw new Error(`In ${wt(i)}: Expected a field ${h?"index":"name"}, got ${$t(n)}`);if(r.kind===b){if(!h&&!("field"in i))throw new Error(`No field in ${wt(i)}`);const t=N("f");return e.H(r,h?{kind:y,elementType:t}:{kind:m,fields:{[i.field]:t},open:!0},r.type,i),e.B(t)}if(h)return e.B(r.elementType);if(!(n in r.fields)){if(!r.open)throw new Error(`In ${wt(i)}: Unknown field: ${n}`);const t=N("ff");return e.H(r,{kind:m,fields:{[n]:t},open:!0},void 0,i),e.B(t)}return e.B(r.fields[n])}case P:{const r=N("a"),n={vars:[],type:r},h=await s(t.withType(i.parameter,n),i.body);return{kind:P,argTypes:[e.B(r)],returnType:e.B(h)}}default:throw new Error(`Unknown node type: ${wt(i)}`)}},n=await s(t,i);if(e.B(n)!==n)throw new Error(`In ${wt(i)}: Non-substituted free variable in ${$t(n)}`);return H(n)},yt=t=>{const i={};for(const e of t)for(const[t,s]of Object.entries(e))void 0===i[t]&&(i[t]=s);return i};function mt(t,i=[]){if(!t||!t.name)throw new Error("Invalid parse tree");for(const e of i)if(t.name===e.elt&&e.pat(t.value))return{type:g,value:e.rewrite(t.value)};switch(t.name){case"SourceFile":if(1===t.children?.length)return mt(t.children[0],i);throw new Error("empty source");case"ParenthesizedExpression":if(1===t.children?.length)return mt(t.children[0],i);throw new Error("empty parenthesis");case"TupleExpression":{const e=t.children?.map((t=>mt(t,i)))||[];if(0===e.length)throw new Error("Empty tuples are not allowed");return{type:x,elements:e}}case"Identifier":return{type:b,name:t.value};case"NumberValue":return{type:g,value:new r(t.value)};case"StringValue":return{type:g,value:JSON.parse(t.value)};case"BooleanValue":return{type:g,value:"true"===t.value};case"ArrayExpression":return{type:y,elements:t.children?.map((t=>mt(t,i)))||[]};case"ObjectExpression":return{type:m,values:Object.fromEntries(t.children?.map((t=>mt(t,i)))?.map((t=>[t.key,t.value]))||[])};case"NamedField":if(2===t.children?.length)return{type:"named",key:t.children[0].value,value:mt(t.children[1],i)};throw new Error("wrong NamedField length");case"FieldExpression":case"SubscriptExpression":if(2!==t.children?.length)throw new Error("wrong FieldExpression length");return"Identifier"===t.children[1].name?{type:v,expr:mt(t.children[0],i),field:t.children[1].value}:{type:v,expr:mt(t.children[0],i),sub:mt(t.children[1],i)};case"FunctionExpression":{if(2!==t.children?.length)throw new Error("wrong function length");let e;if(e="ArgumentList"===t.children[0].name?t.children[0].children??[]:[t.children[0]],!e.length)throw new Error("Function with no arguments");let s=mt(t.children[1],i);for(const t of e.reverse())s={type:P,parameter:t.value,body:s};return s}case"CallExpression":{if(2!==t.children?.length)throw new Error("wrong CallExpression length");if("ArgumentList"!==t.children[1].name)throw new Error("wrong CallExpression arguments");const e=t.children[1].children?.map((t=>mt(t,i)))||[];switch(t.children[0].name){case"Identifier":return{type:w,function:{type:b,name:t.children[0].value},params:e};case"ParenthesizedExpression":case"CallExpression":return{type:w,function:mt(t.children[0],i),params:e}}throw new Error("unknown CallExpression")}case"UnaryExpression":if(2!==t.children?.length)throw new Error("wrong UnaryExpression length");if(!t.children[0].name.includes("Operator"))throw new Error("not an unary operator");return{type:w,function:{type:b,name:t.children[0].value},params:[mt(t.children[1],i)]};case"BinaryExpression":if(3!==t.children?.length)throw new Error("wrong BinaryExpression length");return{type:w,function:{type:b,name:t.children[1].value},params:[mt(t.children[0],i),mt(t.children[2],i)]};case"TernaryExpression":if(3!==t.children?.length)throw new Error("wrong TernaryExpression length");return{type:w,function:{type:b,name:"IF"},params:t.children.map((t=>mt(t,i)))};case"⚠":return{type:R,value:t.value};default:throw new Error(`Unknown parse tree node: ${t.name}`)}}function Pt(t,i){const e=i=>{const s=i?.type?.name,r={name:s};let n=i.firstChild;if(n)for(r.children=[e(n)];n=n.nextSibling;)r.children.push(e(n));else r.value=t.slice(i.from,i.to);return function(t){return"⚠"===t}(s)&&(r.error={from:i.from,to:i.to}),r};return e(i.topNode)}const vt=1024;let Rt=0;class xt{constructor(t,i){this.from=t,this.to=i}}class kt{constructor(t={}){this.id=Rt++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(t){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof t&&(t=Tt.match(t)),i=>{let e=t(i);return void 0===e?null:[this,e]}}}kt.closedBy=new kt({deserialize:t=>t.split(" ")}),kt.openedBy=new kt({deserialize:t=>t.split(" ")}),kt.group=new kt({deserialize:t=>t.split(" ")}),kt.isolate=new kt({deserialize:t=>{if(t&&"rtl"!=t&&"ltr"!=t&&"auto"!=t)throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}}),kt.contextHash=new kt({perNode:!0}),kt.lookAhead=new kt({perNode:!0}),kt.mounted=new kt({perNode:!0});class Xt{constructor(t,i,e){this.tree=t,this.overlay=i,this.parser=e}static get(t){return t&&t.props&&t.props[kt.mounted.id]}}const St=Object.create(null);class Tt{constructor(t,i,e,s=0){this.name=t,this.props=i,this.id=e,this.flags=s}static define(t){let i=t.props&&t.props.length?Object.create(null):St,e=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(null==t.name?8:0),s=new Tt(t.name||"",i,t.id,e);if(t.props)for(let r of t.props)if(Array.isArray(r)||(r=r(s)),r){if(r[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");i[r[0].id]=r[1]}return s}prop(t){return this.props[t.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(t){if("string"==typeof t){if(this.name==t)return!0;let i=this.prop(kt.group);return!!i&&i.indexOf(t)>-1}return this.id==t}static match(t){let i=Object.create(null);for(let e in t)for(let s of e.split(" "))i[s]=t[e];return t=>{for(let e=t.prop(kt.group),s=-1;s<(e?e.length:0);s++){let r=i[s<0?t.name:e[s]];if(r)return r}}}}Tt.none=new Tt("",Object.create(null),0,8);class Et{constructor(t){this.types=t;for(let i=0;i<t.length;i++)if(t[i].id!=i)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...t){let i=[];for(let e of this.types){let s=null;for(let i of t){let t=i(e);t&&(s||(s=Object.assign({},e.props)),s[t[0].id]=t[1])}i.push(s?new Tt(e.name,s,e.id,e.flags):e)}return new Et(i)}}const jt=new WeakMap,Vt=new WeakMap;var Ut,zt;(zt=Ut||(Ut={}))[zt.ExcludeBuffers=1]="ExcludeBuffers",zt[zt.IncludeAnonymous=2]="IncludeAnonymous",zt[zt.IgnoreMounts=4]="IgnoreMounts",zt[zt.IgnoreOverlays=8]="IgnoreOverlays";class Yt{constructor(t,i,e,s,r){if(this.type=t,this.children=i,this.positions=e,this.length=s,this.props=null,r&&r.length){this.props=Object.create(null);for(let[t,i]of r)this.props["number"==typeof t?t:t.id]=i}}toString(){let t=Xt.get(this);if(t&&!t.overlay)return t.tree.toString();let i="";for(let e of this.children){let t=e.toString();t&&(i&&(i+=","),i+=t)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(i.length?"("+i+")":""):i}cursor(t=0){return new Bt(this.topNode,t)}cursorAt(t,i=0,e=0){let s=jt.get(this)||this.topNode,r=new Bt(s);return r.moveTo(t,i),jt.set(this,r.J),r}get topNode(){return new At(this,0,0,null)}resolve(t,i=0){let e=_t(jt.get(this)||this.topNode,t,i,!1);return jt.set(this,e),e}resolveInner(t,i=0){let e=_t(Vt.get(this)||this.topNode,t,i,!0);return Vt.set(this,e),e}resolveStack(t,i=0){return function(t,i,e){let s=t.resolveInner(i,e),r=null;for(let n=s instanceof At?s:s.context.parent;n;n=n.parent)if(n.index<0){let t=n.parent;(r||(r=[s])).push(t.resolve(i,e)),n=t}else{let t=Xt.get(n.tree);if(t&&t.overlay&&t.overlay[0].from<=i&&t.overlay[t.overlay.length-1].to>=i){let h=new At(t.tree,t.overlay[0].from+n.from,-1,n);(r||(r=[s])).push(_t(h,i,e,!1))}}return r?Mt(r):s}(this,t,i)}iterate(t){let{enter:i,leave:e,from:s=0,to:r=this.length}=t,n=t.mode||0,h=(n&Ut.IncludeAnonymous)>0;for(let O=this.cursor(n|Ut.IncludeAnonymous);;){let t=!1;if(O.from<=r&&O.to>=s&&(!h&&O.type.isAnonymous||!1!==i(O))){if(O.firstChild())continue;t=!0}for(;t&&e&&(h||!O.type.isAnonymous)&&e(O),!O.nextSibling();){if(!O.parent())return;t=!0}}}prop(t){return t.perNode?this.props?this.props[t.id]:void 0:this.type.prop(t)}get propValues(){let t=[];if(this.props)for(let i in this.props)t.push([+i,this.props[i]]);return t}balance(t={}){return this.children.length<=8?this:Kt(Tt.none,this.children,this.positions,0,this.children.length,0,this.length,((t,i,e)=>new Yt(this.type,t,i,e,this.propValues)),t.makeTree||((t,i,e)=>new Yt(Tt.none,t,i,e)))}static build(t){return function(t){var i;let{buffer:e,nodeSet:s,maxBufferLength:r=vt,reused:n=[],minRepeatType:h=s.types.length}=t,O=Array.isArray(e)?new Ct(e,e.length):e,o=s.types,l=0,a=0;function u(t,i,e,w,g,b){let{id:y,start:m,end:P,size:v}=O,R=a,x=l;for(;v<0;){if(O.next(),-1==v){let i=n[y];return e.push(i),void w.push(m-t)}if(-3==v)return void(l=y);if(-4==v)return void(a=y);throw new RangeError(`Unrecognized record size: ${v}`)}let k,X,S=o[y],T=m-t;if(P-m<=r&&(X=$(O.pos-i,g))){let i=new Uint16Array(X.size-X.skip),e=O.pos-X.size,r=i.length;for(;O.pos>e;)r=Q(X.start,i,r);k=new Gt(i,P-X.start,s),T=X.start-t}else{let t=O.pos-v;O.next();let i=[],e=[],s=y>=h?y:-1,n=0,o=P;for(;O.pos>t;)s>=0&&O.id==s&&O.size>=0?(O.end<=o-r&&(d(i,e,m,n,O.end,o,s,R,x),n=i.length,o=O.end),O.next()):b>2500?f(m,t,i,e):u(m,t,i,e,s,b+1);if(s>=0&&n>0&&n<i.length&&d(i,e,m,n,m,o,s,R,x),i.reverse(),e.reverse(),s>-1&&n>0){let t=c(S,x);k=Kt(S,i,e,0,i.length,0,P-m,t,t)}else k=p(S,i,e,P-m,R-P,x)}e.push(k),w.push(T)}function f(t,i,e,n){let h=[],o=0,l=-1;for(;O.pos>i;){let{id:t,start:i,end:e,size:s}=O;if(s>4)O.next();else{if(l>-1&&i<l)break;l<0&&(l=e-r),h.push(t,i,e),o++,O.next()}}if(o){let i=new Uint16Array(4*o),r=h[h.length-2];for(let t=h.length-3,e=0;t>=0;t-=3)i[e++]=h[t],i[e++]=h[t+1]-r,i[e++]=h[t+2]-r,i[e++]=e;e.push(new Gt(i,h[2]-r,s)),n.push(r-t)}}function c(t,i){return(e,s,r)=>{let n,h,O=0,o=e.length-1;if(o>=0&&(n=e[o])instanceof Yt){if(!o&&n.type==t&&n.length==r)return n;(h=n.prop(kt.lookAhead))&&(O=s[o]+n.length+h)}return p(t,e,s,r,O,i)}}function d(t,i,e,r,n,h,O,o,l){let a=[],u=[];for(;t.length>r;)a.push(t.pop()),u.push(i.pop()+e-n);t.push(p(s.types[O],a,u,h-n,o-h,l)),i.push(n-e)}function p(t,i,e,s,r,n,h){if(n){let t=[kt.contextHash,n];h=h?[t].concat(h):[t]}if(r>25){let t=[kt.lookAhead,r];h=h?[t].concat(h):[t]}return new Yt(t,i,e,s,h)}function $(t,i){let e=O.fork(),s=0,n=0,o=0,l=e.end-r,a={size:0,start:0,skip:0};t:for(let r=e.pos-t;e.pos>r;){let t=e.size;if(e.id==i&&t>=0){a.size=s,a.start=n,a.skip=o,o+=4,s+=4,e.next();continue}let O=e.pos-t;if(t<0||O<r||e.start<l)break;let u=e.id>=h?4:0,f=e.start;for(e.next();e.pos>O;){if(e.size<0){if(-3!=e.size)break t;u+=4}else e.id>=h&&(u+=4);e.next()}n=f,s+=t,o+=u}return(i<0||s==t)&&(a.size=s,a.start=n,a.skip=o),a.size>4?a:void 0}function Q(t,i,e){let{id:s,start:r,end:n,size:o}=O;if(O.next(),o>=0&&s<h){let h=e;if(o>4){let s=O.pos-(o-4);for(;O.pos>s;)e=Q(t,i,e)}i[--e]=h,i[--e]=n-t,i[--e]=r-t,i[--e]=s}else-3==o?l=s:-4==o&&(a=s);return e}let w=[],g=[];for(;O.pos>0;)u(t.start||0,t.bufferStart||0,w,g,-1,0);let b=null!==(i=t.length)&&void 0!==i?i:w.length?g[0]+w[0].length:0;return new Yt(o[t.topID],w.reverse(),g.reverse(),b)}(t)}}Yt.empty=new Yt(Tt.none,[],[],0);class Ct{constructor(t,i){this.buffer=t,this.index=i}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 Ct(this.buffer,this.index)}}class Gt{constructor(t,i,e){this.buffer=t,this.length=i,this.set=e}get type(){return Tt.none}toString(){let t=[];for(let i=0;i<this.buffer.length;)t.push(this.childString(i)),i=this.buffer[i+3];return t.join(",")}childString(t){let i=this.buffer[t],e=this.buffer[t+3],s=this.set.types[i],r=s.name;if(/\W/.test(r)&&!s.isError&&(r=JSON.stringify(r)),e==(t+=4))return r;let n=[];for(;t<e;)n.push(this.childString(t)),t=this.buffer[t+3];return r+"("+n.join(",")+")"}findChild(t,i,e,s,r){let{buffer:n}=this,h=-1;for(let O=t;O!=i&&!(Zt(r,s,n[O+1],n[O+2])&&(h=O,e>0));O=n[O+3]);return h}slice(t,i,e){let s=this.buffer,r=new Uint16Array(i-t),n=0;for(let h=t,O=0;h<i;){r[O++]=s[h++],r[O++]=s[h++]-e;let i=r[O++]=s[h++]-e;r[O++]=s[h++]-t,n=Math.max(n,i)}return new Gt(r,n,this.set)}}function Zt(t,i,e,s){switch(t){case-2:return e<i;case-1:return s>=i&&e<i;case 0:return e<i&&s>i;case 1:return e<=i&&s>i;case 2:return s>i;case 4:return!0}}function _t(t,i,e,s){for(var r;t.from==t.to||(e<1?t.from>=i:t.from>i)||(e>-1?t.to<=i:t.to<i);){let i=!s&&t instanceof At&&t.index<0?null:t.parent;if(!i)return t;t=i}let n=s?0:Ut.IgnoreOverlays;if(s)for(let h=t,O=h.parent;O;h=O,O=h.parent)h instanceof At&&h.index<0&&(null===(r=O.enter(i,e,n))||void 0===r?void 0:r.from)!=h.from&&(t=O);for(;;){let s=t.enter(i,e,n);if(!s)return t;t=s}}class qt{cursor(t=0){return new Bt(this,t)}getChild(t,i=null,e=null){let s=Wt(this,t,i,e);return s.length?s[0]:null}getChildren(t,i=null,e=null){return Wt(this,t,i,e)}resolve(t,i=0){return _t(this,t,i,!1)}resolveInner(t,i=0){return _t(this,t,i,!0)}matchContext(t){return Nt(this.parent,t)}enterUnfinishedNodesBefore(t){let i=this.childBefore(t),e=this;for(;i;){let t=i.lastChild;if(!t||t.to!=i.to)break;t.type.isError&&t.from==t.to?(e=i,i=t.prevSibling):i=t}return e}get node(){return this}get next(){return this.parent}}class At extends qt{constructor(t,i,e,s){super(),this.J=t,this.from=i,this.index=e,this.K=s}get type(){return this.J.type}get name(){return this.J.type.name}get to(){return this.from+this.J.length}nextChild(t,i,e,s,r=0){for(let n=this;;){for(let{children:h,positions:O}=n.J,o=i>0?h.length:-1;t!=o;t+=i){let o=h[t],l=O[t]+n.from;if(Zt(s,e,l,l+o.length))if(o instanceof Gt){if(r&Ut.ExcludeBuffers)continue;let h=o.findChild(0,o.buffer.length,i,e-l,s);if(h>-1)return new Ft(new Dt(n,o,t,l),null,h)}else if(r&Ut.IncludeAnonymous||!o.type.isAnonymous||Lt(o)){let h;if(!(r&Ut.IgnoreMounts)&&(h=Xt.get(o))&&!h.overlay)return new At(h.tree,l,t,n);let O=new At(o,l,t,n);return r&Ut.IncludeAnonymous||!O.type.isAnonymous?O:O.nextChild(i<0?o.children.length-1:0,i,e,s)}}if(r&Ut.IncludeAnonymous||!n.type.isAnonymous)return null;if(t=n.index>=0?n.index+i:i<0?-1:n.K.J.children.length,n=n.K,!n)return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this.J.children.length-1,-1,0,4)}childAfter(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this.J.children.length-1,-1,t,-2)}enter(t,i,e=0){let s;if(!(e&Ut.IgnoreOverlays)&&(s=Xt.get(this.J))&&s.overlay){let e=t-this.from;for(let{from:t,to:r}of s.overlay)if((i>0?t<=e:t<e)&&(i<0?r>=e:r>e))return new At(s.tree,s.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,i,e)}nextSignificantParent(){let t=this;for(;t.type.isAnonymous&&t.K;)t=t.K;return t}get parent(){return this.K?this.K.nextSignificantParent():null}get nextSibling(){return this.K&&this.index>=0?this.K.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this.K&&this.index>=0?this.K.nextChild(this.index-1,-1,0,4):null}get tree(){return this.J}toTree(){return this.J}toString(){return this.J.toString()}}function Wt(t,i,e,s){let r=t.cursor(),n=[];if(!r.firstChild())return n;if(null!=e)for(let h=!1;!h;)if(h=r.type.is(e),!r.nextSibling())return n;for(;;){if(null!=s&&r.type.is(s))return n;if(r.type.is(i)&&n.push(r.node),!r.nextSibling())return null==s?n:[]}}function Nt(t,i,e=i.length-1){for(let s=t;e>=0;s=s.parent){if(!s)return!1;if(!s.type.isAnonymous){if(i[e]&&i[e]!=s.name)return!1;e--}}return!0}class Dt{constructor(t,i,e,s){this.parent=t,this.buffer=i,this.index=e,this.start=s}}class Ft extends qt{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(t,i,e){super(),this.context=t,this.K=i,this.index=e,this.type=t.buffer.set.types[t.buffer.buffer[e]]}child(t,i,e){let{buffer:s}=this.context,r=s.findChild(this.index+4,s.buffer[this.index+3],t,i-this.context.start,e);return r<0?null:new Ft(this.context,this,r)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(t){return this.child(1,t,2)}childBefore(t){return this.child(-1,t,-2)}enter(t,i,e=0){if(e&Ut.ExcludeBuffers)return null;let{buffer:s}=this.context,r=s.findChild(this.index+4,s.buffer[this.index+3],i>0?1:-1,t-this.context.start,i);return r<0?null:new Ft(this.context,this,r)}get parent(){return this.K||this.context.parent.nextSignificantParent()}externalSibling(t){return this.K?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}get nextSibling(){let{buffer:t}=this.context,i=t.buffer[this.index+3];return i<(this.K?t.buffer[this.K.index+3]:t.buffer.length)?new Ft(this.context,this.K,i):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,i=this.K?this.K.index+4:0;return this.index==i?this.externalSibling(-1):new Ft(this.context,this.K,t.findChild(i,this.index,-1,0,4))}get tree(){return null}toTree(){let t=[],i=[],{buffer:e}=this.context,s=this.index+4,r=e.buffer[this.index+3];if(r>s){let n=e.buffer[this.index+1];t.push(e.slice(s,r,n)),i.push(0)}return new Yt(this.type,t,i,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function Mt(t){if(!t.length)return null;let i=0,e=t[0];for(let n=1;n<t.length;n++){let s=t[n];(s.from>e.from||s.to<e.to)&&(e=s,i=n)}let s=e instanceof At&&e.index<0?null:e.parent,r=t.slice();return s?r[i]=s:r.splice(i,1),new It(r,e)}class It{constructor(t,i){this.heads=t,this.node=i}get next(){return Mt(this.heads)}}class Bt{get name(){return this.type.name}constructor(t,i=0){if(this.mode=i,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,t instanceof At)this.yieldNode(t);else{this.J=t.context.parent,this.buffer=t.context;for(let i=t.K;i;i=i.K)this.stack.unshift(i.index);this.bufferNode=t,this.yieldBuf(t.index)}}yieldNode(t){return!!t&&(this.J=t,this.type=t.type,this.from=t.from,this.to=t.to,!0)}yieldBuf(t,i){this.index=t;let{start:e,buffer:s}=this.buffer;return this.type=i||s.set.types[s.buffer[t]],this.from=e+s.buffer[t+1],this.to=e+s.buffer[t+2],!0}yield(t){return!!t&&(t instanceof At?(this.buffer=null,this.yieldNode(t)):(this.buffer=t.context,this.yieldBuf(t.index,t.type)))}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this.J.toString()}enterChild(t,i,e){if(!this.buffer)return this.yield(this.J.nextChild(t<0?this.J.J.children.length-1:0,t,i,e,this.mode));let{buffer:s}=this.buffer,r=s.findChild(this.index+4,s.buffer[this.index+3],t,i-this.buffer.start,e);return!(r<0)&&(this.stack.push(this.index),this.yieldBuf(r))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(t){return this.enterChild(1,t,2)}childBefore(t){return this.enterChild(-1,t,-2)}enter(t,i,e=this.mode){return this.buffer?!(e&Ut.ExcludeBuffers)&&this.enterChild(1,t,i):this.yield(this.J.enter(t,i,e))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Ut.IncludeAnonymous?this.J.K:this.J.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&Ut.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(t){if(!this.buffer)return!!this.J.K&&this.yield(this.J.index<0?null:this.J.K.nextChild(this.J.index+t,t,0,4,this.mode));let{buffer:i}=this.buffer,e=this.stack.length-1;if(t<0){let t=e<0?0:this.stack[e]+4;if(this.index!=t)return this.yieldBuf(i.findChild(t,this.index,-1,0,4))}else{let t=i.buffer[this.index+3];if(t<(e<0?i.buffer.length:i.buffer[this.stack[e]+3]))return this.yieldBuf(t)}return e<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+t,t,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(t){let i,e,{buffer:s}=this;if(s){if(t>0){if(this.index<s.buffer.buffer.length)return!1}else for(let t=0;t<this.index;t++)if(s.buffer.buffer[t+3]<this.index)return!1;({index:i,parent:e}=s)}else({index:i,K:e}=this.J);for(;e;({index:i,K:e}=e))if(i>-1)for(let s=i+t,r=t<0?-1:e.J.children.length;s!=r;s+=t){let t=e.J.children[s];if(this.mode&Ut.IncludeAnonymous||t instanceof Gt||!t.type.isAnonymous||Lt(t))return!1}return!0}move(t,i){if(i&&this.enterChild(t,0,4))return!0;for(;;){if(this.sibling(t))return!0;if(this.atLastNode(t)||!this.parent())return!1}}next(t=!0){return this.move(1,t)}prev(t=!0){return this.move(-1,t)}moveTo(t,i=0){for(;(this.from==this.to||(i<1?this.from>=t:this.from>t)||(i>-1?this.to<=t:this.to<t))&&this.parent(););for(;this.enterChild(1,t,i););return this}get node(){if(!this.buffer)return this.J;let t=this.bufferNode,i=null,e=0;if(t&&t.context==this.buffer)t:for(let s=this.index,r=this.stack.length;r>=0;){for(let n=t;n;n=n.K)if(n.index==s){if(s==this.index)return n;i=n,e=r+1;break t}s=this.stack[--r]}for(let s=e;s<this.stack.length;s++)i=new Ft(this.buffer,i,this.stack[s]);return this.bufferNode=new Ft(this.buffer,i,this.index)}get tree(){return this.buffer?null:this.J.J}iterate(t,i){for(let e=0;;){let s=!1;if(this.type.isAnonymous||!1!==t(this)){if(this.firstChild()){e++;continue}this.type.isAnonymous||(s=!0)}for(;;){if(s&&i&&i(this),s=this.type.isAnonymous,!e)return;if(this.nextSibling())break;this.parent(),e--,s=!0}}}matchContext(t){if(!this.buffer)return Nt(this.node.parent,t);let{buffer:i}=this.buffer,{types:e}=i.set;for(let s=t.length-1,r=this.stack.length-1;s>=0;r--){if(r<0)return Nt(this.J,t,s);let n=e[i.buffer[this.stack[r]]];if(!n.isAnonymous){if(t[s]&&t[s]!=n.name)return!1;s--}}return!0}}function Lt(t){return t.children.some((t=>t instanceof Gt||!t.type.isAnonymous||Lt(t)))}const Ht=new WeakMap;function Jt(t,i){if(!t.isAnonymous||i instanceof Gt||i.type!=t)return 1;let e=Ht.get(i);if(null==e){e=1;for(let s of i.children){if(s.type!=t||!(s instanceof Yt)){e=1;break}e+=Jt(t,s)}Ht.set(i,e)}return e}function Kt(t,i,e,s,r,n,h,O,o){let l=0;for(let c=s;c<r;c++)l+=Jt(t,i[c]);let a=Math.ceil(1.5*l/8),u=[],f=[];return function i(e,s,r,h,O){for(let l=r;l<h;){let r=l,c=s[l],d=Jt(t,e[l]);for(l++;l<h;l++){let i=Jt(t,e[l]);if(d+i>=a)break;d+=i}if(l==r+1){if(d>a){let t=e[r];i(t.children,t.positions,0,t.children.length,s[r]+O);continue}u.push(e[r])}else{let i=s[l-1]+e[l-1].length-c;u.push(Kt(t,e,s,r,l,c,i,null,o))}f.push(c+O-n)}}(i,e,s,r,0),(O||o)(u,f,h)}class ti{startParse(t,i,e){return"string"==typeof t&&(t=new ii(t)),e=e?e.length?e.map((t=>new xt(t.from,t.to))):[new xt(0,0)]:[new xt(0,t.length)],this.createParse(t,i||[],e)}parse(t,i,e){let s=this.startParse(t,i,e);for(;;){let t=s.advance();if(t)return t}}}class ii{constructor(t){this.string=t}get length(){return this.string.length}chunk(t){return this.string.slice(t)}get lineChunks(){return!1}read(t,i){return this.string.slice(t,i)}}new kt({perNode:!0});class ei{constructor(t,i,e,s,r,n,h,O,o,l=0,a){this.p=t,this.stack=i,this.state=e,this.reducePos=s,this.pos=r,this.score=n,this.buffer=h,this.bufferBase=O,this.curContext=o,this.lookAhead=l,this.parent=a}toString(){return`[${this.stack.filter(((t,i)=>i%3==0)).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(t,i,e=0){let s=t.parser.context;return new ei(t,[],i,e,e,0,[],0,s?new si(s,s.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(t,i){this.stack.push(this.state,i,this.bufferBase+this.buffer.length),this.state=t}reduce(t){var i;let e=t>>19,s=65535&t,{parser:r}=this.p,n=this.reducePos<this.pos-25;n&&this.setLookAhead(this.pos);let h=r.dynamicPrecedence(s);if(h&&(this.score+=h),0==e)return this.pushState(r.getGoto(this.state,s,!0),this.reducePos),s<r.minRepeatTerm&&this.storeNode(s,this.reducePos,this.reducePos,n?8:4,!0),void this.reduceContext(s,this.reducePos);let O=this.stack.length-3*(e-1)-(262144&t?6:0),o=O?this.stack[O-2]:this.p.ranges[0].from,l=this.reducePos-o;l>=2e3&&!(null===(i=this.p.parser.nodeSet.types[s])||void 0===i?void 0:i.isAnonymous)&&(o==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=l):this.p.lastBigReductionSize<l&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=o,this.p.lastBigReductionSize=l));let a=O?this.stack[O-1]:0,u=this.bufferBase+this.buffer.length-a;if(s<r.minRepeatTerm||131072&t){let t=r.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(s,o,t,u+4,!0)}if(262144&t)this.state=this.stack[O];else{let t=this.stack[O-3];this.state=r.getGoto(t,s,!0)}for(;this.stack.length>O;)this.stack.pop();this.reduceContext(s,o)}storeNode(t,i,e,s=4,r=!1){if(0==t&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let t=this,s=this.buffer.length;if(0==s&&t.parent&&(s=t.bufferBase-t.parent.bufferBase,t=t.parent),s>0&&0==t.buffer[s-4]&&t.buffer[s-1]>-1){if(i==e)return;if(t.buffer[s-2]>=i)return void(t.buffer[s-2]=e)}}if(r&&this.pos!=e){let r=this.buffer.length;if(r>0&&0!=this.buffer[r-4]){let t=!1;for(let i=r;i>0&&this.buffer[i-2]>e;i-=4)if(this.buffer[i-1]>=0){t=!0;break}if(t)for(;r>0&&this.buffer[r-2]>e;)this.buffer[r]=this.buffer[r-4],this.buffer[r+1]=this.buffer[r-3],this.buffer[r+2]=this.buffer[r-2],this.buffer[r+3]=this.buffer[r-1],r-=4,s>4&&(s-=4)}this.buffer[r]=t,this.buffer[r+1]=i,this.buffer[r+2]=e,this.buffer[r+3]=s}else this.buffer.push(t,i,e,s)}shift(t,i,e,s){if(131072&t)this.pushState(65535&t,this.pos);else if(262144&t)this.pos=s,this.shiftContext(i,e),i<=this.p.parser.maxNode&&this.buffer.push(i,e,s,4);else{let r=t,{parser:n}=this.p;(s>this.pos||i<=n.maxNode)&&(this.pos=s,n.stateFlag(r,1)||(this.reducePos=s)),this.pushState(r,e),this.shiftContext(i,e),i<=n.maxNode&&this.buffer.push(i,e,s,4)}}apply(t,i,e,s){65536&t?this.reduce(t):this.shift(t,i,e,s)}useNode(t,i){let e=this.p.reused.length-1;(e<0||this.p.reused[e]!=t)&&(this.p.reused.push(t),e++);let s=this.pos;this.reducePos=this.pos=s+t.length,this.pushState(i,s),this.buffer.push(e,s,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,t,this,this.p.stream.reset(this.pos-t.length)))}split(){let t=this,i=t.buffer.length;for(;i>0&&t.buffer[i-2]>t.reducePos;)i-=4;let e=t.buffer.slice(i),s=t.bufferBase+i;for(;t&&s==t.bufferBase;)t=t.parent;return new ei(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,e,s,this.curContext,this.lookAhead,t)}recoverByDelete(t,i){let e=t<=this.p.parser.maxNode;e&&this.storeNode(t,this.pos,i,4),this.storeNode(0,this.pos,i,e?8:4),this.pos=this.reducePos=i,this.score-=190}canShift(t){for(let i=new ri(this);;){let e=this.p.parser.stateSlot(i.state,4)||this.p.parser.hasAction(i.state,t);if(0==e)return!1;if(!(65536&e))return!0;i.reduce(e)}}recoverByInsert(t){if(this.stack.length>=300)return[];let i=this.p.parser.nextStates(this.state);if(i.length>8||this.stack.length>=120){let e=[];for(let s,r=0;r<i.length;r+=2)(s=i[r+1])!=this.state&&this.p.parser.hasAction(s,t)&&e.push(i[r],s);if(this.stack.length<120)for(let t=0;e.length<8&&t<i.length;t+=2){let s=i[t+1];e.some(((t,i)=>1&i&&t==s))||e.push(i[t],s)}i=e}let e=[];for(let s=0;s<i.length&&e.length<4;s+=2){let t=i[s+1];if(t==this.state)continue;let r=this.split();r.pushState(t,this.pos),r.storeNode(0,r.pos,r.pos,4,!0),r.shiftContext(i[s],this.pos),r.reducePos=this.pos,r.score-=200,e.push(r)}return e}forceReduce(){let{parser:t}=this.p,i=t.stateSlot(this.state,5);if(!(65536&i))return!1;if(!t.validAction(this.state,i)){let e=i>>19,s=65535&i,r=this.stack.length-3*e;if(r<0||t.getGoto(this.stack[r],s,!1)<0){let t=this.findForcedReduction();if(null==t)return!1;i=t}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(i),!0}findForcedReduction(){let{parser:t}=this.p,i=[],e=(s,r)=>{if(!i.includes(s))return i.push(s),t.allActions(s,(i=>{if(393216&i);else if(65536&i){let e=(i>>19)-r;if(e>1){let s=65535&i,r=this.stack.length-3*e;if(r>=0&&t.getGoto(this.stack[r],s,!1)>=0)return e<<19|65536|s}}else{let t=e(i,r+1);if(null!=t)return t}}))};return e(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(3!=this.stack.length)return!1;let{parser:t}=this.p;return 65535==t.data[t.stateSlot(this.state,1)]&&!t.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(t){if(this.state!=t.state||this.stack.length!=t.stack.length)return!1;for(let i=0;i<this.stack.length;i+=3)if(this.stack[i]!=t.stack[i])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(t){return this.p.parser.dialect.flags[t]}shiftContext(t,i){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,t,this,this.p.stream.reset(i)))}reduceContext(t,i){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,t,this,this.p.stream.reset(i)))}emitContext(){let t=this.buffer.length-1;(t<0||-3!=this.buffer[t])&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let t=this.buffer.length-1;(t<0||-4!=this.buffer[t])&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(t){if(t!=this.curContext.context){let i=new si(this.curContext.tracker,t);i.hash!=this.curContext.hash&&this.emitContext(),this.curContext=i}}setLookAhead(t){t>this.lookAhead&&(this.emitLookAhead(),this.lookAhead=t)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class si{constructor(t,i){this.tracker=t,this.context=i,this.hash=t.strict?t.hash(i):0}}class ri{constructor(t){this.start=t,this.state=t.state,this.stack=t.stack,this.base=this.stack.length}reduce(t){let i=65535&t,e=t>>19;0==e?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=3*(e-1);let s=this.start.p.parser.getGoto(this.stack[this.base-3],i,!0);this.state=s}}class ni{constructor(t,i,e){this.stack=t,this.pos=i,this.index=e,this.buffer=t.buffer,0==this.index&&this.maybeNext()}static create(t,i=t.bufferBase+t.buffer.length){return new ni(t,i,i-t.bufferBase)}maybeNext(){let t=this.stack.parent;null!=t&&(this.index=this.stack.bufferBase-t.bufferBase,this.stack=t,this.buffer=t.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,0==this.index&&this.maybeNext()}fork(){return new ni(this.stack,this.pos,this.index)}}function hi(t,i=Uint16Array){if("string"!=typeof t)return t;let e=null;for(let s=0,r=0;s<t.length;){let n=0;for(;;){let i=t.charCodeAt(s++),e=!1;if(126==i){n=65535;break}i>=92&&i--,i>=34&&i--;let r=i-32;if(r>=46&&(r-=46,e=!0),n+=r,e)break;n*=46}e?e[r++]=n:e=new i(n)}return e}class Oi{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const oi=new Oi;class li{constructor(t,i){this.input=t,this.ranges=i,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=oi,this.rangeIndex=0,this.pos=this.chunkPos=i[0].from,this.range=i[0],this.end=i[i.length-1].to,this.readNext()}resolveOffset(t,i){let e=this.range,s=this.rangeIndex,r=this.pos+t;for(;r<e.from;){if(!s)return null;let t=this.ranges[--s];r-=e.from-t.to,e=t}for(;i<0?r>e.to:r>=e.to;){if(s==this.ranges.length-1)return null;let t=this.ranges[++s];r+=t.from-e.to,e=t}return r}clipPos(t){if(t>=this.range.from&&t<this.range.to)return t;for(let i of this.ranges)if(i.to>t)return Math.max(t,i.from);return this.end}peek(t){let i,e,s=this.chunkOff+t;if(s>=0&&s<this.chunk.length)i=this.pos+t,e=this.chunk.charCodeAt(s);else{let s=this.resolveOffset(t,1);if(null==s)return-1;if(i=s,i>=this.chunk2Pos&&i<this.chunk2Pos+this.chunk2.length)e=this.chunk2.charCodeAt(i-this.chunk2Pos);else{let t=this.rangeIndex,s=this.range;for(;s.to<=i;)s=this.ranges[++t];this.chunk2=this.input.chunk(this.chunk2Pos=i),i+this.chunk2.length>s.to&&(this.chunk2=this.chunk2.slice(0,s.to-i)),e=this.chunk2.charCodeAt(0)}}return i>=this.token.lookAhead&&(this.token.lookAhead=i+1),e}acceptToken(t,i=0){let e=i?this.resolveOffset(i,-1):this.pos;if(null==e||e<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=t,this.token.end=e}acceptTokenTo(t,i){this.token.value=t,this.token.end=i}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:t,chunkPos:i}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=t,this.chunk2Pos=i,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let t=this.input.chunk(this.pos),i=this.pos+t.length;this.chunk=i>this.range.to?t.slice(0,this.range.to-this.pos):t,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(t=1){for(this.chunkOff+=t;this.pos+t>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();t-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=t,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(t,i){if(i?(this.token=i,i.start=t,i.lookAhead=t+1,i.value=i.extended=-1):this.token=oi,this.pos!=t){if(this.pos=t,t==this.end)return this.setDone(),this;for(;t<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;t>=this.range.to;)this.range=this.ranges[++this.rangeIndex];t>=this.chunkPos&&t<this.chunkPos+this.chunk.length?this.chunkOff=t-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(t,i){if(t>=this.chunkPos&&i<=this.chunkPos+this.chunk.length)return this.chunk.slice(t-this.chunkPos,i-this.chunkPos);if(t>=this.chunk2Pos&&i<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(t-this.chunk2Pos,i-this.chunk2Pos);if(t>=this.range.from&&i<=this.range.to)return this.input.read(t,i);let e="";for(let s of this.ranges){if(s.from>=i)break;s.to>t&&(e+=this.input.read(Math.max(s.from,t),Math.min(s.to,i)))}return e}}class ai{constructor(t,i){this.data=t,this.id=i}token(t,i){let{parser:e}=i.p;!function(t,i,e,s,r,n){let h=0,O=1<<s,{dialect:o}=e.p.parser;t:for(;O&t[h];){let e=t[h+1];for(let u=h+3;u<e;u+=2)if((t[u+1]&O)>0){let e=t[u];if(o.allows(e)&&(-1==i.token.value||i.token.value==e||ci(e,i.token.value,r,n))){i.acceptToken(e);break}}let s=i.next,l=0,a=t[h+2];if(!(i.next<0&&a>l&&65535==t[e+3*a-3])){for(;l<a;){let r=l+a>>1,n=e+r+(r<<1),O=t[n],o=t[n+1]||65536;if(s<O)a=r;else{if(!(s>=o)){h=t[n+2],i.advance();continue t}l=r+1}}break}h=t[e+3*a-1]}}(this.data,t,i,this.id,e.data,e.tokenPrecTable)}}ai.prototype.contextual=ai.prototype.fallback=ai.prototype.extend=!1,ai.prototype.fallback=ai.prototype.extend=!1;class ui{constructor(t,i={}){this.token=t,this.contextual=!!i.contextual,this.fallback=!!i.fallback,this.extend=!!i.extend}}function fi(t,i,e){for(let s,r=i;65535!=(s=t[r]);r++)if(s==e)return r-i;return-1}function ci(t,i,e,s){let r=fi(e,s,i);return r<0||fi(e,s,t)<r}const di="undefined"!=typeof process&&process.env&&/\bparse\b/.test(process.env.LOG);let pi=null;function $i(t,i,e){let s=t.cursor(Ut.IncludeAnonymous);for(s.moveTo(i);;)if(!(e<0?s.childBefore(i):s.childAfter(i)))for(;;){if((e<0?s.to<i:s.from>i)&&!s.type.isError)return e<0?Math.max(0,Math.min(s.to-1,i-25)):Math.min(t.length,Math.max(s.from+1,i+25));if(e<0?s.prevSibling():s.nextSibling())break;if(!s.parent())return e<0?0:t.length}}class Qi{constructor(t,i){this.fragments=t,this.nodeSet=i,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let t=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(t){for(this.safeFrom=t.openStart?$i(t.tree,t.from+t.offset,1)-t.offset:t.from,this.safeTo=t.openEnd?$i(t.tree,t.to+t.offset,-1)-t.offset:t.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(t.tree),this.start.push(-t.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(t){if(t<this.nextStart)return null;for(;this.fragment&&this.safeTo<=t;)this.nextFragment();if(!this.fragment)return null;for(;;){let i=this.trees.length-1;if(i<0)return this.nextFragment(),null;let e=this.trees[i],s=this.index[i];if(s==e.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let r=e.children[s],n=this.start[i]+e.positions[s];if(n>t)return this.nextStart=n,null;if(r instanceof Yt){if(n==t){if(n<this.safeFrom)return null;let t=n+r.length;if(t<=this.safeTo){let i=r.prop(kt.lookAhead);if(!i||t+i<this.fragment.to)return r}}this.index[i]++,n+r.length>=Math.max(this.safeFrom,t)&&(this.trees.push(r),this.start.push(n),this.index.push(0))}else this.index[i]++,this.nextStart=n+r.length}}}class wi{constructor(t,i){this.stream=i,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=t.tokenizers.map((t=>new Oi))}getActions(t){let i=0,e=null,{parser:s}=t.p,{tokenizers:r}=s,n=s.stateSlot(t.state,3),h=t.curContext?t.curContext.hash:0,O=0;for(let o=0;o<r.length;o++){if(!(1<<o&n))continue;let s=r[o],l=this.tokens[o];if((!e||s.fallback)&&((s.contextual||l.start!=t.pos||l.mask!=n||l.context!=h)&&(this.updateCachedToken(l,s,t),l.mask=n,l.context=h),l.lookAhead>l.end+25&&(O=Math.max(l.lookAhead,O)),0!=l.value)){let r=i;if(l.extended>-1&&(i=this.addActions(t,l.extended,l.end,i)),i=this.addActions(t,l.value,l.end,i),!s.extend&&(e=l,i>r))break}}for(;this.actions.length>i;)this.actions.pop();return O&&t.setLookAhead(O),e||t.pos!=this.stream.end||(e=new Oi,e.value=t.p.parser.eofTerm,e.start=e.end=t.pos,i=this.addActions(t,e.value,e.end,i)),this.mainToken=e,this.actions}getMainToken(t){if(this.mainToken)return this.mainToken;let i=new Oi,{pos:e,p:s}=t;return i.start=e,i.end=Math.min(e+1,s.stream.end),i.value=e==s.stream.end?s.parser.eofTerm:0,i}updateCachedToken(t,i,e){let s=this.stream.clipPos(e.pos);if(i.token(this.stream.reset(s,t),e),t.value>-1){let{parser:i}=e.p;for(let s=0;s<i.specialized.length;s++)if(i.specialized[s]==t.value){let r=i.specializers[s](this.stream.read(t.start,t.end),e);if(r>=0&&e.p.parser.dialect.allows(r>>1)){1&r?t.extended=r>>1:t.value=r>>1;break}}}else t.value=0,t.end=this.stream.clipPos(s+1)}putAction(t,i,e,s){for(let r=0;r<s;r+=3)if(this.actions[r]==t)return s;return this.actions[s++]=t,this.actions[s++]=i,this.actions[s++]=e,s}addActions(t,i,e,s){let{state:r}=t,{parser:n}=t.p,{data:h}=n;for(let O=0;O<2;O++)for(let t=n.stateSlot(r,O?2:1);;t+=3){if(65535==h[t]){if(1!=h[t+1]){0==s&&2==h[t+1]&&(s=this.putAction(Pi(h,t+2),i,e,s));break}t=Pi(h,t+2)}h[t]==i&&(s=this.putAction(Pi(h,t+1),i,e,s))}return s}}class gi{constructor(t,i,e,s){this.parser=t,this.input=i,this.ranges=s,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 li(i,s),this.tokens=new wi(t,this.stream),this.topTerm=t.top[1];let{from:r}=s[0];this.stacks=[ei.start(this,t.top[0],r)],this.fragments=e.length&&this.stream.end-r>4*t.bufferLength?new Qi(e,t.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let t,i,e=this.stacks,s=this.minStackPos,r=this.stacks=[];if(this.bigReductionCount>300&&1==e.length){let[t]=e;for(;t.forceReduce()&&t.stack.length&&t.stack[t.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let n=0;n<e.length;n++){let h=e[n];for(;;){if(this.tokens.mainToken=null,h.pos>s)r.push(h);else{if(this.advanceStack(h,r,e))continue;{t||(t=[],i=[]),t.push(h);let e=this.tokens.getMainToken(h);i.push(e.value,e.end)}}break}}if(!r.length){let i=t&&function(t){let i=null;for(let e of t){let t=e.p.stoppedAt;(e.pos==e.p.stream.end||null!=t&&e.pos>t)&&e.p.parser.stateFlag(e.state,2)&&(!i||i.score<e.score)&&(i=e)}return i}(t);if(i)return this.stackToTree(i);if(this.parser.strict)throw new SyntaxError("No parse at "+s);this.recovering||(this.recovering=5)}if(this.recovering&&t){let e=null!=this.stoppedAt&&t[0].pos>this.stoppedAt?t[0]:this.runRecovery(t,i,r);if(e)return this.stackToTree(e.forceAll())}if(this.recovering){let t=1==this.recovering?1:3*this.recovering;if(r.length>t)for(r.sort(((t,i)=>i.score-t.score));r.length>t;)r.pop();r.some((t=>t.reducePos>s))&&this.recovering--}else if(r.length>1){t:for(let t=0;t<r.length-1;t++){let i=r[t];for(let e=t+1;e<r.length;e++){let s=r[e];if(i.sameState(s)||i.buffer.length>500&&s.buffer.length>500){if(!((i.score-s.score||i.buffer.length-s.buffer.length)>0)){r.splice(t--,1);continue t}r.splice(e--,1)}}}r.length>12&&r.splice(12,r.length-12)}this.minStackPos=r[0].pos;for(let n=1;n<r.length;n++)r[n].pos<this.minStackPos&&(this.minStackPos=r[n].pos);return null}stopAt(t){if(null!=this.stoppedAt&&this.stoppedAt<t)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=t}advanceStack(t,i,e){let s=t.pos,{parser:r}=this;di&&this.stackID(t);if(null!=this.stoppedAt&&s>this.stoppedAt)return t.forceReduce()?t:null;if(this.fragments){let i=t.curContext&&t.curContext.tracker.strict,e=i?t.curContext.hash:0;for(let n=this.fragments.nodeAt(s);n;){let s=this.parser.nodeSet.types[n.type.id]==n.type?r.getGoto(t.state,n.type.id):-1;if(s>-1&&n.length&&(!i||(n.prop(kt.contextHash)||0)==e))return t.useNode(n,s),!0;if(!(n instanceof Yt)||0==n.children.length||n.positions[0]>0)break;let h=n.children[0];if(!(h instanceof Yt&&0==n.positions[0]))break;n=h}}let n=r.stateSlot(t.state,4);if(n>0)return t.reduce(n),!0;if(t.stack.length>=8400)for(;t.stack.length>6e3&&t.forceReduce(););let h=this.tokens.getActions(t);for(let O=0;O<h.length;){let r=h[O++],n=h[O++],o=h[O++],l=O==h.length||!e,a=l?t:t.split(),u=this.tokens.mainToken;if(a.apply(r,n,u?u.start:a.pos,o),l)return!0;a.pos>s?i.push(a):e.push(a)}return!1}advanceFully(t,i){let e=t.pos;for(;;){if(!this.advanceStack(t,null,null))return!1;if(t.pos>e)return bi(t,i),!0}}runRecovery(t,i,e){let s=null,r=!1;for(let n=0;n<t.length;n++){let h=t[n],O=i[n<<1],o=i[1+(n<<1)],l=di?this.stackID(h)+" -> ":"";if(h.deadEnd){if(r)continue;if(r=!0,h.restart(),this.advanceFully(h,e))continue}let a=h.split(),u=l;for(let t=0;a.forceReduce()&&t<10;t++){if(this.advanceFully(a,e))break;di&&(u=this.stackID(a)+" -> ")}for(let t of h.recoverByInsert(O))this.advanceFully(t,e);this.stream.end>h.pos?(o==h.pos&&(o++,O=0),h.recoverByDelete(O,o),bi(h,e)):(!s||s.score<h.score)&&(s=h)}return s}stackToTree(t){return t.close(),Yt.build({buffer:ni.create(t),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:t.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(t){let i=(pi||(pi=new WeakMap)).get(t);return i||pi.set(t,i=String.fromCodePoint(this.nextStackID++)),i+t}}function bi(t,i){for(let e=0;e<i.length;e++){let s=i[e];if(s.pos==t.pos&&s.sameState(t))return void(i[e].score<t.score&&(i[e]=t))}i.push(t)}class yi{constructor(t,i,e){this.source=t,this.flags=i,this.disabled=e}allows(t){return!this.disabled||0==this.disabled[t]}}class mi extends ti{constructor(t){if(super(),this.wrappers=[],14!=t.version)throw new RangeError(`Parser version (${t.version}) doesn't match runtime version (14)`);let i=t.nodeNames.split(" ");this.minRepeatTerm=i.length;for(let h=0;h<t.repeatNodeCount;h++)i.push("");let e=Object.keys(t.topRules).map((i=>t.topRules[i][1])),s=[];for(let h=0;h<i.length;h++)s.push([]);function r(t,i,e){s[t].push([i,i.deserialize(String(e))])}if(t.nodeProps)for(let h of t.nodeProps){let t=h[0];"string"==typeof t&&(t=kt[t]);for(let i=1;i<h.length;){let e=h[i++];if(e>=0)r(e,t,h[i++]);else{let s=h[i+-e];for(let n=-e;n>0;n--)r(h[i++],t,s);i++}}}this.nodeSet=new Et(i.map(((i,r)=>Tt.define({name:r>=this.minRepeatTerm?void 0:i,id:r,props:s[r],top:e.indexOf(r)>-1,error:0==r,skipped:t.skippedNodes&&t.skippedNodes.indexOf(r)>-1})))),t.propSources&&(this.nodeSet=this.nodeSet.extend(...t.propSources)),this.strict=!1,this.bufferLength=vt;let n=hi(t.tokenData);this.context=t.context,this.specializerSpecs=t.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let h=0;h<this.specializerSpecs.length;h++)this.specialized[h]=this.specializerSpecs[h].term;this.specializers=this.specializerSpecs.map(vi),this.states=hi(t.states,Uint32Array),this.data=hi(t.stateData),this.goto=hi(t.goto),this.maxTerm=t.maxTerm,this.tokenizers=t.tokenizers.map((t=>"number"==typeof t?new ai(n,t):t)),this.topRules=t.topRules,this.dialects=t.dialects||{},this.dynamicPrecedences=t.dynamicPrecedences||null,this.tokenPrecTable=t.tokenPrec,this.termNames=t.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(t,i,e){let s=new gi(this,t,i,e);for(let r of this.wrappers)s=r(s,t,i,e);return s}getGoto(t,i,e=!1){let s=this.goto;if(i>=s[0])return-1;for(let r=s[i+1];;){let i=s[r++],n=1&i,h=s[r++];if(n&&e)return h;for(let e=r+(i>>1);r<e;r++)if(s[r]==t)return h;if(n)return-1}}hasAction(t,i){let e=this.data;for(let s=0;s<2;s++)for(let r,n=this.stateSlot(t,s?2:1);;n+=3){if(65535==(r=e[n])){if(1!=e[n+1]){if(2==e[n+1])return Pi(e,n+2);break}r=e[n=Pi(e,n+2)]}if(r==i||0==r)return Pi(e,n+1)}return 0}stateSlot(t,i){return this.states[6*t+i]}stateFlag(t,i){return(this.stateSlot(t,0)&i)>0}validAction(t,i){return!!this.allActions(t,(t=>t==i||null))}allActions(t,i){let e=this.stateSlot(t,4),s=e?i(e):void 0;for(let r=this.stateSlot(t,1);null==s;r+=3){if(65535==this.data[r]){if(1!=this.data[r+1])break;r=Pi(this.data,r+2)}s=i(Pi(this.data,r+1))}return s}nextStates(t){let i=[];for(let e=this.stateSlot(t,1);;e+=3){if(65535==this.data[e]){if(1!=this.data[e+1])break;e=Pi(this.data,e+2)}if(!(1&this.data[e+2])){let t=this.data[e+1];i.some(((i,e)=>1&e&&i==t))||i.push(this.data[e],t)}}return i}configure(t){let i=Object.assign(Object.create(mi.prototype),this);if(t.props&&(i.nodeSet=this.nodeSet.extend(...t.props)),t.top){let e=this.topRules[t.top];if(!e)throw new RangeError(`Invalid top rule name ${t.top}`);i.top=e}return t.tokenizers&&(i.tokenizers=this.tokenizers.map((i=>{let e=t.tokenizers.find((t=>t.from==i));return e?e.to:i}))),t.specializers&&(i.specializers=this.specializers.slice(),i.specializerSpecs=this.specializerSpecs.map(((e,s)=>{let r=t.specializers.find((t=>t.from==e.external));if(!r)return e;let n=Object.assign(Object.assign({},e),{external:r.to});return i.specializers[s]=vi(n),n}))),t.contextTracker&&(i.context=t.contextTracker),t.dialect&&(i.dialect=this.parseDialect(t.dialect)),null!=t.strict&&(i.strict=t.strict),t.wrap&&(i.wrappers=i.wrappers.concat(t.wrap)),null!=t.bufferLength&&(i.bufferLength=t.bufferLength),i}hasWrappers(){return this.wrappers.length>0}getName(t){return this.termNames?this.termNames[t]:String(t<=this.maxNode&&this.nodeSet.types[t].name||t)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(t){let i=this.dynamicPrecedences;return null==i?0:i[t]||0}parseDialect(t){let i=Object.keys(this.dialects),e=i.map((()=>!1));if(t)for(let r of t.split(" ")){let t=i.indexOf(r);t>=0&&(e[t]=!0)}let s=null;for(let r=0;r<i.length;r++)if(!e[r])for(let t,e=this.dialects[i[r]];65535!=(t=this.data[e++]);)(s||(s=new Uint8Array(this.maxTerm+1)))[t]=1;return new yi(t,e,s)}static deserialize(t){return new mi(t)}}function Pi(t,i){return t[i]|t[i+1]<<16}function vi(t){if(t.external){let i=t.extend?1:0;return(e,s)=>t.external(e,s)<<1|i}return t.get}const Ri=".".codePointAt(0),xi="\\".codePointAt(0),ki="`".codePointAt(0),Xi="$".codePointAt(0),Si="#".codePointAt(0),Ti="(".codePointAt(0),Ei="[".codePointAt(0),ji=";".codePointAt(0),Vi='"'.codePointAt(0),Ui="\n".codePointAt(0),zi="A".codePointAt(0),Yi="Z".codePointAt(0),Ci="a".codePointAt(0),Gi="z".codePointAt(0),Zi="0".codePointAt(0),_i="9".codePointAt(0),qi="_".codePointAt(0),Ai="@".codePointAt(0),Wi=/^\p{Lu}/u,Ni=/^\p{Ll}/u,Di=/^\p{Lt}/u,Fi=/^\p{Lm}/u,Mi=/^\p{Lo}/u,Ii=/^\p{Me}/u,Bi=/^\p{Mn}/u,Li=/^\p{Mc}/u,Hi=/^\p{Nd}/u,Ji=/^\p{Nl}/u,Ki=/^\p{No}/u,te=/^\p{Pc}/u,ie=/^\p{Sc}/u,ee=/^\p{Sk}/u,se=/^\p{So}/u,re=/^\p{Emoji}/u,ne=new ui(((t,i)=>{const e=t.peek(0);e!==Ui&&e!==ji||!i.canShift(91)||t.acceptToken(91,1)}));function he(t,i){return Wi.test(t)||Ni.test(t)||Di.test(t)||Fi.test(t)||Mi.test(t)||Ji.test(t)||ie.test(t)||re.test(t)||se.test(t)&&!(i>=8592&&i<=8703)&&65532!==i&&65533!==i&&9023!==i&&166!==i}function Oe(t,i){const e=t.peek(i);if(e>=zi&&e<=Yi||e>=Ci&&e<=Gi||e===qi||e===Xi||e===Ai)return 1;if(e<161||e>1114111)return 0;const s=oe(t,i);return he(s,e)?s.length:0}function oe(t,i){let e=1,s=t.peek(i),r=String.fromCodePoint(s);for(;;){const n=t.peek(i+e);if(!(55296<=s&&s<=56319&&56320<=n&&n<=57343))break;r+=String.fromCodePoint(n),s=n,e+=1}return r}const le=new ui(((t,i)=>{let e=!0,s=0,r=1;for(;;){const i=t.peek(s);if(-1===i)break;if(e){if(e=!1,r=Oe(t,s),0===r)break}else if(i>=zi&&i<=Yi||i>=Ci&&i<=Gi||i>=Zi&&i<=_i||i===qi);else{if(i<161||i>1114111)break;{const e=oe(t,s);if(r=e.length,he(e,i));else if(!(Bi.test(e)||Li.test(e)||Hi.test(e)||te.test(e)||ee.test(e)||Ii.test(e)||Ki.test(e)||i>=8242&&i<=8247||8279===i))break}}s+=r,r=1}0!==s&&t.acceptToken(1,s)})),ae=(t,i)=>{const e=t.peek(i),s=t.peek(i+1);return e===Si&&(0!==Oe(t,i+1)||s===Ti)},ue=({till:t,term:i})=>new ui(((e,s)=>{let r=0,n=!1;for(;;){const s=e.peek(r);if(-1===s)break;if(s===xi)n=!0;else if(n)n=!1;else if(ae(e,r)||t(e,r))return void(r>0&&e.acceptToken(i,r));r+=1}})),fe=ue({term:92,till:(t,i)=>t.peek(i)===Vi&&t.peek(i+1)===Vi&&t.peek(i+2)===Vi}),ce=ue({term:93,till:(t,i)=>t.peek(i)===Vi}),de=ue({term:94,till:(t,i)=>t.peek(i)===ki}),pe=(t,i)=>{const e=t.peek(i);return e>=9&&e<14||e>=32&&e<33||e>=133&&e<134||e>=160&&e<161||e>=5760&&e<5761||e>=8192&&e<8203||e>=8232&&e<8234||e>=8239&&e<8240||e>=8287&&e<8288||e>=12288&&e<12289},$e=new ui(((t,i)=>{t.peek(0)!==Ti||pe(t,-1)||!i.canShift(95)?t.peek(0)!==Ei||pe(t,-1)||!i.canShift(96)?t.peek(0)!==Vi||pe(t,-1)||!i.canShift(97)?t.peek(0)!==ki||pe(t,-1)||!i.canShift(98)?t.peek(0)!==Ri||pe(t,-1)||!i.canShift(99)||t.acceptToken(99,0):t.acceptToken(98,0):t.acceptToken(97,0):t.acceptToken(96,0):t.acceptToken(95,0)}),{extend:!0}),Qe={__proto__:null,in:20,isa:22,for:86,if:92,true:268,false:268},we=mi.deserialize({version:14,states:"!!xQVQ!dOOO#RQ#wO'#EfOVQ!dO'#C`O#YQ!dO'#CmO&WQ$iO'#ExO&_Q!bO'#ClO'UQ!dO'#CrO'`Q$iO'#EgOOQs'#D^'#D^O)VQ!dO'#DaO)[O!jO'#DbO)gO!fO'#DcO)rO!rO'#DdO)}Q!dO'#DoO*_Q!dO'#DnOOQs'#Ex'#ExOOQR'#Eg'#EgQOQ!bOOOVQ!dO,58yOOQR,58z,58zOOQQ'#Ce'#CeOOQQ'#Ci'#CiOOQQ'#Cj'#CjOVQ!dO,58|OVQ!dO,58|OVQ!dO,58|OVQ!dO,58|OVQ!dO,58|OVQ!dO,58|OVQ!dO,59VOVQ!dO,59[OOQR,59],59]O*fQ!dO,5;QO*pQ!cO,5;QO*{Q#wO,58zO,iQ#wO,5:`OOQO'#Cn'#CnOOQO'#Eq'#EqOOQs,59X,59XO,|Q!bO,59XO-RQ!dO,59XO-`Q!bO,59XO/UQ$iO'#ExO/`Q!bO,5:XOVQ!dO,59WO/eQ!bO,5:PO/mQ!bO,5:PO/rQ$iO,59^O1iQ$iO'#ExOVQ!dO'#DmO1pQ!bO,59_O1uQ!bO,59aO1zQ!bO,5:VOOQs,59{,59{O2PQ#UO'#FYOOOW'#EO'#EOO2XO!jO,59|OOQs,59|,59|OOOS'#EP'#EPO2dO!fO,59}OOQs,59},59}OOO`'#EQ'#EQO2oO!rO,5:OOOQs,5:O,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{R!RQPOQrQQsRQ!b]Q!e^Q!gbQ!hgQ!ihQ!jiQ!kjQ!lkQ!mlQ!nmQ!onU!pp!q#jh!wx!y!{#T#q#u#w$q$s%|%}'SQ#O|Q#Q!RQ#y!|W$]#`#e$^$gQ$i#iQ$k#mQ%s$[R%x$lSyR#TQ!xxU#t!y#u$sQ#x!{Y$o#q$q%|%}'SR$t#w!rVOQR]^bghijklmnpx|!R!q!y!{!|#T#`#e#i#j#m#q#u#w$[$^$g$l$q$s%|%}'SQ!PUQ$v#zQ&P(wV'T&Q'U'{R$w#zQ#|#SQ%[#}Q%]$OQ%m$TQ&T$yQ&U${Q&V$|Q&W$}Q&X%OQ&Y%PQ&Z%QQ&[%RQ&]%S^&a%V&c&y'['t(^(nh&k%b&m&o&v'd'h'j(T(V(f(g(pQ&r%fQ&s%iQ'Y&`U'`&g'a(QQ'l&pQ'o&uQ'|'WR'}']S%c$O&vQ&l%bU'g&m'h(VQ'k&oY(R'd(T(f(g(pR(W'j!v$S#S#}$O$T$y${$|$}%O%P%Q%R%S%V%b%f%i&`&c&g&m&o&p&u&v&y'W'[']'a'd'h'j't(Q(T(V(^(f(g(n(pQ%g$RQ(Y'mQ(i(yV(q(j(r(vR(Z'mQ%X#|S&i%]&sQ&|%mR(]'oR&x%lS!XY!YS![Z!]T!_[!`T%e$O%iR#V!US!ts#QR#h!e",nodeNames:"⚠ Identifier SourceFile PairExpression UnaryExpression UnaryOperatorExtra BinaryExpression PowerOperator TimesOperator PlusOperator in isa ComparisonOperator OrOperator AndOperator TernaryExpression FunctionExpression ArgumentList NamedArgument NamedField RangeExpression SpreadExpression InterpolationExpression FieldExpression ParenthesizedExpression SubscriptExpression GeneratorExpression PairExpression UnaryExpression BinaryExpression TernaryExpression FunctionExpression ArgumentList NamedArgument NamedField RangeExpression SpreadExpression InterpolationExpression FieldExpression ParenthesizedExpression SubscriptExpression GeneratorExpression ForClause for ForBinding IfClause if CallExpression BooleanValue Character NumberValue SymbolValue StringValue TripleString CommandString PrefixedString ParenthesizedExpression ArrayExpression ObjectExpression ArrayComprehensionExpression GeneratorExpression CallExpression TupleExpression ParenthesizedExpression ArrayExpression ObjectExpression ArrayComprehensionExpression ForClause ForBinding IfClause GeneratorExpression",maxTerm:143,nodeProps:[["group",-4,10,11,43,46,"keyword"],["closedBy",-8,17,24,32,39,56,60,63,70,")",-6,25,40,57,59,64,66,"]",-2,58,65,"}"]],skippedNodes:[0],repeatNodeCount:19,tokenData:"0P~RpXY#VYZ#Vpq#Vqr%Trs%bst%uvw%zwx&Vxy'cyz'hz{'m{|'r|},R}!O,W!O!P,h!P!Q'm!Q!R)T!R![)}![!].Q!]!^._!^!_-s!_!`.d!`!a.t!}#O/U#P#Q/Z#Q#R-{#S#T/`#o#p/e#p#q/j#q#r/u#r#s/P%&b%&c/z~#[T#X~XY#kYZ#kpq#k![!]#}!a!b$i~#nTXY#kYZ#kpq#k![!]#}!a!b$i~$QRXY$ZYZ$Zpq$Z~$`R#c~XY$ZYZ$Zpq$Z~$lRXY$uYZ$upq$u~$zR#b~XY$uYZ$upq$u~%YPTP!_!`%]~%bO[~~%gP#{~rs%j~%mPrs%p~%uO#}~~%zO#m~~%}Pvw&Q~&VO#a~R&[U#]QOw&nx#O&n#O#P&y#P;'S&n;'S;=`']<%lO&nP&qPwx&tP&yO!RPP&|TOw&nwx&tx;'S&n;'S;=`']<%lO&nP'`P;=`<%l&n~'hO#d~~'mO#i~Q'rOWQR'wR#_Q!O!P(Q!Q!R)T!R![)}P(TP!Q![(WP(]S!SP!Q![(W!g!h(i#R#S(W#X#Y(iP(lR{|(u}!O(u!Q![({P(xP!Q![({P)QP!SP!Q![({P)YV!SP!O!P)o!Q![)}!g!h(i!z!{*c#R#S)}#X#Y(i#l#m*cP)tR!SP!Q![(W!g!h(i#X#Y(iP*ST!SP!O!P)o!Q![)}!g!h(i#R#S)}#X#Y(iP*fR!Q![*o!c!i*o#T#Z*oP*tW!SP!Q![*o!c!g*o!g!h+^!h!i*o#R#S*o#T#X*o#X#Y+^#Y#Z*oP+cY!SP{|(u}!O(u!Q![*o!c!g*o!g!h+^!h!i*o#R#S*o#T#X*o#X#Y+^#Y#Z*o~,WO#g~R,_R#_QTP!O!P(Q!Q!R)T!R![)}~,mY#nPqr-]wx-cz{'m!O!P-h!P!Q'm!Q![(W!^!_-s!_!`-]!`!a-s#Q#R-{~-`P!_!`%]Q-hO#^QQ-kP!O!P-nQ-sO#kQ~-xP[~!_!`%]Q.QOVQ~.VP#f~![!].Y~._O#j~~.dO#h~~.iQ#vS!_!`%]!`!a.oR.tO#[R~.yQ[~![!]/P!_!`%]P/UOTP~/ZO#p~~/`O#x~~/eO$O~~/jO$Q~~/mP#p#q/p~/uO#`~~/zO$R~~0PO#w~",tokenizers:[ne,le,fe,ce,de,$e,0,1,2],topRules:{SourceFile:[0,2]},dynamicPrecedences:{22:2,37:2,133:1,142:1},specialized:[{term:1,get:t=>Qe[t]||-1}],tokenPrec:3838}),ge=async(t,i={})=>new Promise(((e,s)=>{try{const s=we.parse(t),r=Pt(t,s);e(mt(r,i.ext))}catch(r){s(r)}})),be=(t,i,e,s=Array.prototype.find,r="find",n)=>{const h=((t,i,e,s="map",r)=>{let n;return t.map([i,e],((i,e,s)=>{const r=new Set((s||[]).map((t=>t.id))),h=i.map(((t,i)=>{const h=e===n&&s?.find((i=>i.dependencies?.[0]===t.id));return h?(r.delete(h.id),h):e(t,i)}));return n=e,t.O.collect(...r),h}),s,r)})(t,i,e,"keep"),O=tt(t);return t.map([i,h],((i,e)=>O(t.mapNoPrevious(e,((...t)=>s.call(i,((i,e)=>t[e])))))),r,n)},ye=F("number"),me=F("string"),Pe=F("boolean"),ve=F("bytes"),Re=t=>{const i=N("if");return{f:t.new(((t,i,e,s)=>t.proxy.map([i,e,s],((t,i,e)=>t?i:e),"if")),"$if"),doc:"If statement",t:{vars:[i.type],type:{kind:P,argTypes:[Pe,i,i],returnType:i}}}},xe=t=>{const i=N("filter");return{f:t.new(((t,i,e)=>((t,i,e,s="filter",r)=>{const n=tt(t);let h;const O=t.map([i,e],((t,i,e)=>{const s=i.map((i=>h===t&&e?.find((t=>t.dependencies?.[0]===i.id))||t(i)));return h=t,s}),"keep",r);return t.map([e,O],((i,e)=>n(t.mapNoPrevious(e,((...t)=>i.filter(((i,e)=>t[e]))),"filter.map"))),s,r)})(t.proxy,i,e,"filter")),"$filter"),doc:"Returns a filter for an array",t:{vars:[i.type],type:{kind:P,argTypes:[{kind:P,argTypes:[i],returnType:Pe,label:"filter function"},{kind:y,elementType:i,label:"value list"}],returnType:{kind:y,elementType:i,label:"filtered items"}}}}},ke=t=>{const i=N("map"),e=N("map");return{f:t.new(((t,i,e)=>((t,i,e,s="map",r)=>{let n;return t.map([i,e],((t,i,e)=>{const s=t.map(((t,s)=>{return r=()=>i(t,s),i===n&&(()=>e?.find((i=>i.dependencies?.[0]===t.id)))()||r();var r}));return n=i,s}),s,r)})(t.proxy,e,i,"map")),"$map"),doc:"Returns a mapped array",t:{vars:[i.type,e.type],type:{kind:P,argTypes:[{kind:P,argTypes:[i],returnType:e,label:"map function"},{kind:y,elementType:i,label:"value list"}],returnType:{kind:y,elementType:e,label:"mapped items"}}}}},Xe=(t,i=Array.prototype.find,e="$find")=>{const s=N("map");return{f:t.new(((t,s,r)=>be(t.proxy,r,s,i,`$${e}`)),e),doc:"Returns a mapped array",t:{vars:[s.type],type:{kind:P,argTypes:[{kind:P,argTypes:[s],returnType:Pe,label:"find function, returns true if an element matches"},{kind:y,elementType:s,label:"value list"}],returnType:s}}}},Se=t=>{const i=N("len");return{f:t.new(((t,i)=>t.proxy.map([i],(t=>{return new r(Array.isArray(t)?t.length:"object"==typeof(i=t)&&null!==i&&i.constructor.prototype!==Object.prototype?1:"object"==typeof t?Object.keys(t).length:null!=t?1:0);var i}),"length")),"$length"),t:{vars:[i.type],type:G([i],Pe)}}},Te=(t,i,e)=>({doc:e,f:t.new(((t,e,s)=>t.proxy.map([e,s],((t,e)=>{switch(i){case"+":return t.add(e);case"-":return t.subtract(e);case"*":return t.multiply(e);case"/":return t.divide(e);case"^":return t.power(e)}throw new Error("unknown operator")}),i)),`(${i})`),t:{vars:[],type:G([ye,ye],ye)}}),Ee=(t,i,e)=>{const s=N("op");return{doc:e,f:t.new(((t,e,s)=>t.proxy.map([e,s],((t,e)=>{if(t instanceof r&&e instanceof r)return t.compare(i,e);switch(i){case"<":return t<e;case"<=":return t<=e;case">":return t>e;case">=":return t>=e;case"==":return t===e;case"!=":return t!==e}throw new Error("unknown comparator")}),i)),`(${i})`),t:{vars:[s.type],type:G([s,s],Pe)}}},je=(t,i)=>{const e=N("eq");return{doc:`returns ${i?"false":"true"} if both arguments are equal`,f:t.new(((t,e,s)=>t.proxy.map([e,s],i?(t,i)=>!Ge(t,i):Ge,i?"!=":"==")),i?"(!=)":"(==)"),t:{vars:[e.type],type:G([e,e],Pe)}}},Ve=t=>Array.isArray(t)?Ve(t[0]):t,Ue=t=>({$pi:{f:t.new(new r(Math.PI),"π"),t:{vars:[],type:ye},doc:"π constant"},"+":Te(t,"+"),"-":Te(t,"-"),"*":Te(t,"*"),"/":Te(t,"/"),"^":Te(t,"^"),"<":Ee(t,"<"),"<=":Ee(t,"<="),">":Ee(t,">"),">=":Ee(t,">="),"==":je(t,!1),"!=":je(t,!0),if:Re(t),"&&":{f:t.new(((t,i,e)=>t.proxy.map([i,e],((t,i)=>t&&i),"&&")),"(&&)"),t:{vars:[],type:G([Pe,Pe],Pe)}},"||":{f:t.new(((t,i,e)=>t.proxy.map([i,e],((t,i)=>t||i),"||")),"(||)"),t:{vars:[],type:G([Pe,Pe],Pe)}},"!":{f:t.new(((t,i)=>t.proxy.map([i],(t=>!t),"!")),"(!)"),t:{vars:[],type:G([Pe],Pe)}},$min:{f:t.new(((t,...i)=>t.proxy.mapNoPrevious(i,((...t)=>t[0].min(...t.slice(1))),"min")),"$min"),t:{vars:[],type:G([ye],ye,ye)}},$max:{f:t.new(((t,...i)=>t.proxy.mapNoPrevious(i,((...t)=>t[0].max(...t.slice(1))),"max")),"$max"),t:{vars:[],type:G([ye],ye,ye)}},$last:{f:t.new(((t,i)=>((t,i,e="last")=>{const s=i=>t.mapNoPrevious([i],(t=>Array.isArray(t)?s(t[t.length-1]):i),e);return s(i)})(t.proxy,i)),"$last"),doc:"return the last element of an array, recursively",t:{vars:["elt"],type:G([Z(I)],I)}},$first:{f:t.new(((t,...i)=>t.proxy.mapNoPrevious(i,((...t)=>Ve(t)),"first")),"$first"),doc:"Returns the first element in an array, recursively",t:{vars:["elt"],type:G([Z(I)],I)}},$concat:{f:t.new(((t,...i)=>t.proxy.mapNoPrevious(i,((...t)=>t.reduce(((t,i)=>`${t}${i.toString()}`),""))))),doc:"Concatenates string representations of any value",t:{vars:[],type:G([],me,I)}},$filter:xe(t),$map:ke(t),$find:Xe(t),$findi:Xe(t,Array.prototype.findIndex,"$findi"),$length:Se(t),$floor:{f:t.new(((t,i)=>t.proxy.map([i],(t=>t.floor()),"floor")),"$floor"),doc:"Returns the floor of a rational number.",t:{vars:[],type:{kind:P,argTypes:[ye],returnType:ye}}},$json:{f:t.new(((t,i)=>t.proxy.map([i],(t=>JSON.stringify(t)),"json")),"$json"),doc:"Returns the JSON representation of any value",t:{vars:[],type:{kind:P,argTypes:[I],returnType:me}}},$hex:{f:t.new(((t,i)=>t.proxy.map([i],(t=>{return`0x${i=t,[...i].map((t=>t.charCodeAt(0).toString(16).padStart(2,"0"))).join("")}`;var i}),"hex")),"$hex"),doc:"Returns the hex representation of a string (prefixed with 0x)",t:{vars:[],type:{kind:P,argTypes:[me],returnType:me}}}}),ze={name:"Rational",is:t=>t instanceof r,type:ye},Ye=(t,i=[ze])=>{for(const s of i)if(s.is(t))return s.type;const e=typeof t;switch(e){case"number":case"bigint":return ye;case"string":case"boolean":return F(e);case"object":return Array.isArray(t)?Z(Ye(t[0])):null===t?F("null"):_(Object.fromEntries(Object.entries(t).map((([t,i])=>[t,Ye(i)]))));default:throw new Error("Unsupported expression type")}};class Ce{constructor(t,i={}){var e;this.initialValues={},this.initialTypes={true:{vars:[],type:Pe},false:{vars:[],type:Pe}},this.library=t=>this.tt[t.toLowerCase()],this.value=t=>this.it[t.toLowerCase()],this.type=t=>this.et[t.toLowerCase()],this.case=t=>this.st[t.toLowerCase()],this.infer=bt(this),this.eval=dt(this),this.clone=()=>new Ce(this.proxy,{...this.options,lib:this.tt,values:{...this.it},types:{...this.et},cases:{...this.st},extensions:this.options.extensions}),this.keys=(t=!0)=>[...Object.keys(this.st),...t?Object.keys(this.tt):[]],this.addExpression=async(t,i)=>{if(!t)throw new Error("Value must be named");const e=await this.infer(i),s=this.eval(i);s.bless(`eval:${t}`);const r=t.toLowerCase();if(this.et[r]){const t=this.value(r);return!(t instanceof at)||(s.subscribe((i=>{t.set(i)})),!0)}return this.addValueType(t,s,e)},this.addValueType=(t,i,e)=>{const s=t.toLowerCase();this.et[s]=e;const r=void 0!==this.it[s];return this.it[s]=i,this.st[s]||(this.st[s]=t),r},this.evaluateString=async(t,i={})=>{const e=await ge(t,this.options.parseOptions);return i?.typeCheck&&await this.infer(e),this.eval(e)},this.evaluateStringValue=async t=>{const i=await this.evaluateString(t);if(i instanceof lt)return i.get();throw new Error(`cannot get value for ${i}, it's not a cell`)},this.evaluateStringArray=async t=>Promise.all(t.map((t=>this.evaluateString(t)))),this.evaluateStringArrayToValues=async t=>await Promise.all(t.map((t=>this.evaluateStringValue(t)))),this.has=t=>{const i=t.toLowerCase();return void 0!==this.library(i)||void 0!==this.value(i)},this.tt=i?.lib||Ue(t),this.it=z(((t,i)=>[t.toLowerCase(),i]),i?.values||this.initialValues),this.et=z(((t,i)=>[t.toLowerCase(),i]),i?.types||this.initialTypes),this.st=i?.cases||(e=i?.values||this.initialValues,z(((t,i)=>[t.toLowerCase(),t]),e)),this.proxy=t,this.options=i}rt(t){this.tt=t}withValue(t,i){const e=t.toLowerCase();return new Ce(this.proxy,{lib:this.tt,values:{...this.it,[e]:i},types:this.et,cases:{...this.st,[e]:t},extensions:this.options.extensions})}withType(t,i){const e=t.toLowerCase();return new Ce(this.proxy,{lib:this.tt,values:this.it,types:{...this.et,[e]:i},cases:this.st,extensions:this.options.extensions})}const(t){return this.proxy.new(t,`c:${t}`)}read(t){const i=t.toLowerCase(),e=this.library(i);return e?.f||this.value(i)}mergeWith(t,...i){return new Ce(this.proxy,{lib:t||this.tt,values:yt([this.it,...i.map((t=>t.it))]),types:yt([this.et,...i.map((t=>t.et))]),cases:yt([this.st,...i.map((t=>t.st))]),extensions:this.options.extensions})}withValueTypes(...t){const i=Object.fromEntries(t.map((([t,i,e])=>[t.toLowerCase(),i]))),e=Object.fromEntries(t.map((([t,i,e])=>[t.toLowerCase(),e]))),s=Object.fromEntries(t.map((([t,i,e])=>[t.toLowerCase(),t])));return new Ce(this.proxy,{lib:this.tt,values:{...this.it,...i},types:{...this.et,...e},cases:{...this.st,...s},extensions:this.options.extensions})}valueTypes(){return Object.entries(this.st).map((([t,i])=>[i,this.it[t],this.et[t]]))}mergeValues(...t){this.it=yt([this.it,...t.map((t=>t.it))]),this.et=yt([this.et,...t.map((t=>t.et))]),this.st=yt([this.st,...t.map((t=>t.st))])}}function Ge(t,i){if(t===i)return!0;if(t instanceof lt&&i instanceof lt)return t.id===i.id||Ge(t.value,i.value);if(t instanceof Ce&&i instanceof Ce){return Ge(t.it,i.it)}if(t instanceof r&&i instanceof r)return t.compare("==",i);if("object"!=typeof t||null===t||"object"!=typeof i||null===i)return!1;if(Array.isArray(t)&&Array.isArray(i)){if(t.length!==i.length)return!1;for(let e=0;e<t.length;e++)if(!Ge(t[e],i[e]))return!1;return!0}if("Object"!==t.constructor.name&&t.constructor.name===i.constructor.name&&t.toString)return t.toString()===i.toString();const e=Object.keys(t),s=Object.keys(i);if(e.length!==s.length)return!1;for(const r of e){if(!s.includes(r))return!1;if(!Ge(t[r],i[r]))return!1}return!0}class Ze{constructor(){this.nt=new Map,this.ht=new Map,this.Ot=new Map,this.ot=new Map}get size(){return this.nt.size}name(t){return this.ot.get(t)}get(t){return this.nt.get(t)}predecessors(t){return this.Ot.get(t)}addNode(t){this.nt.has(t)||(this.nt.set(t,[]),this.Ot.set(t,[]))}bless(t,i){this.ot.set(t,i)}lt(t){if(!this.nt.has(t))throw new Error(`Unknown node: ${t}`)}addEdge(t,i){this.nt.get(t)?.includes(i)||(this.lt(t),this.lt(i),this.nt.get(t)?.push(i),this.Ot.get(i)?.push(t),this.ut(t))}removeEdge(t,i){this.lt(t),this.lt(i);const e=this.nt.get(t),s=e.indexOf(i);-1!==s&&e.splice(s,1);const r=this.Ot.get(i),n=r.indexOf(t);-1!==n&&r.splice(n,1),this.ut(t)}ut(t){this.ht.delete(t);const i=this.Ot.get(t);if(i)for(const e of i)this.ht.delete(e)}topologicalSort(){const t=[],i=new Map,e=new Map;for(const s of this.nt.keys())if(!i.get(s)&&this.ft(s,i,e,t,(t=>this.nt.get(t))))return null;return t}partialTopologicalSort(t,i){if(!this.ht.has(t)){const e=[],s=new Map,r=new Map,n=void 0===i?.next?t=>this.nt.get(t):i.next;s.get(t)||(this.ft(t,s,r,e,n,i?.filter?{filter:i.filter}:void 0)?this.ht.set(t,null):this.ht.set(t,e))}return this.ht.get(t)||null}ft(t,i,e,s,r,n){const h=!!n?.noFailOnLoop&&n.noFailOnLoop;i.set(t,!0),e.set(t,!0);const O=r(t);if(O)for(const o of O){if((!n?.filter||n.filter(t,o))&&!i.get(o)&&this.ft(o,i,e,s,r,n)&&!h)return!0;if(e.get(o)&&!h)return!0}return s.push(t),e.set(t,!1),!1}partialTopologicalSortRootsSet(t,i){const e=void 0===i?.includeRoots||i.includeRoots,s=void 0===i?.next?t=>this.nt.get(t):i.next,r=e?t:t.flatMap((t=>s(t))),n=[],h=new Map,O=new Map;for(const o of r){if(!h.get(o)&&!n.includes(o)&&this.ft(o,h,O,n,s,i?.filter?{filter:i.filter}:void 0))return null;h.set(o,!0)}return n}ct(t,i,e,s,r,n){e.set(t,!0);const h=r(t);if(h)for(const O of h)if(!n?.filter||n.filter(t,O))if(e.get(O)){if(s.get(O))return s.set(t,!0),!0}else{if(i(O))return e.set(O,!0),s.set(O,!0),s.set(t,!0),!0;if(this.ct(O,i,e,s,r,n))return s.set(t,!0),!0}return!1}strictlyReachableProperty(t,i,e){const s=new Set,r=new Map,n=new Map,h=void 0===e?.next?t=>this.nt.get(t):e.next;for(const O of t)this.ct(O,i,r,n,h,e?.filter?{filter:e.filter}:void 0)&&s.add(O);return s}reachableLeaves(t){const i=[],e=new Map,s=new Map,r=Array.from(t).flatMap((t=>this.get(t)||[]));for(const n of r)i.includes(n)||this.ft(n,e,s,i,(t=>this.nt.get(t)),{noFailOnLoop:!0});return new Set(i.filter((t=>this.get(t).length<=0)))}delete(t){this.lt(t);const i=this.nt.get(t)||[];this.nt.delete(t);for(const e of i){const i=this.nt.get(e)||[],s=i.indexOf(t);-1!==s&&i.splice(s,1)}this.nt.forEach(((i,e)=>{const s=i.indexOf(t);-1!==s&&(i.splice(s,1),this.ht.delete(e))})),this.Ot.delete(t),this.Ot.forEach(((i,e)=>{const s=i.indexOf(t);-1!==s&&i.splice(s,1)})),this.ht.delete(t)}toDot(t,i={},e){const s=t=>`${this.ot.get(t)} (${t})`||t;let r="digraph {\n";if(i.title&&(r+=`label="${i.title}";\n`),t)for(const[n,h]of Object.entries(i))t?.[n]?.length&&(r+=`subgraph { node [${h}]; ${t[n].map((t=>`"${s(t)}"`)).join(";\n")}; }\n`);for(const[n,h]of this.nt.entries()){const t=s(n);if(h.length>0)for(const i of h)r+=` "${t}" -> "${s(i)}";\n`;else r+=` "${t}";\n`}if(e)for(const[n,h]of e.nt.entries()){const t=s(n);if(h.length>0)for(const i of h)r+=` "${t}" -> "${s(i)}" [style="dashed"];\n`}return r+="}\n",r}}const _e=t=>{const i=new Set;return((t,i)=>{const e=t=>s=>{switch(i(s,t),s.type){case w:e(t)(s.function);for(const i of s.params)e(t)(i);break;case g:case b:break;case y:s.elements.forEach(e(t));break;case m:Object.values(s.values).forEach(e(t));break;case v:e(t)(s.expr),"sub"in s&&e(t)(s.sub);break;case P:e(t.add(s.parameter))(s.body);break;case"named":e(t)(s.value);break;case R:break;case x:s.elements.forEach(e(t))}};e(new Set)(t)})(t,((t,e)=>{if(t.type===b)e.has(t.name)||i.add(t.name)})),Array.from(i)};var qe=(t=>(t.NoFail="noFail",t.LocalEvaluation="local",t.ErrorToFalse="false",t.Sense="sense",t.SkipNotFound="skip",t.FailUndefined="undefined",t))(qe||{});t.Environment=Ce,t.EvalOption=qe,t.NameApplication=w,t.NameConstant=g,t.NameError=R,t.NameField=v,t.NameLambda=P,t.NameList=y,t.NameObject=m,t.NameTuple=x,t.NameVariable=b,t.Names=k,t.Program=class{constructor(t={},i={}){this.set=async(...t)=>this.dt(await this.parseProgram(t)),this.get=t=>this.$t[t],this.dependencies=(t,i)=>{if(!this.$t)return[];const e=new Set,s=new Set,r=t=>{if(!s.has(t))if(s.add(t),void 0===this.$t[t])e.add(t);else{_e(this.$t[t]).filter((t=>!i||!i.has(t))).map((t=>t.toLowerCase())).forEach(r)}};return t.forEach(r),Array.from(e)},this.reduce=async t=>{const[i,s]=this.order,r=[];for(const e of s)t.has(e)||r.push(e);if(r.length>0)throw new Error(`Unknown ${e("identifier",r,!1)}: ${r.join(", ")}`);const n=t.clone();for(let e=0;e<i.length;e++)await n.addExpression(i[e],this.get(i[e])).catch((t=>{throw t}));return n},this.partialReduce=async t=>{const[i,e]=this.order,s=[],r=new Set,n=t.clone();for(const O of i){const i=_e(this.get(O)).filter((i=>!t.has(i)));if(0===i.length)try{await n.addExpression(O,this.get(O))}catch(h){s.push(O);for(const t of i)r.add(t)}else{s.push(O);for(const t of i)r.add(t)}}return[n,s,r]},this.parseProgram=async t=>Object.fromEntries(await Promise.all(t.map((async t=>{const i=t.indexOf(":"),e=await ge(t.substring(i+1),this.Qt.parseOptions).catch((t=>{throw t}));return[t.substring(0,i),e]})))),this.wt=new Ze,this.$t=t,this.Qt=i;for(const e in t)this.gt(e,t[e])}dt(t){this.wt=new Ze,this.$t=t;for(const i in t)this.gt(i,t[i]);return this}gt(t,i){const e=t.toLowerCase();this.wt.addNode(e);for(const s of _e(i)){const t=s.toLowerCase();this.wt.addNode(t),this.wt.addEdge(e,t)}}get order(){if(!this.$t)return[[],[]];const t=new Set(Object.keys(this.$t)),i=this.wt.topologicalSort();if(null===i)throw new Error("Program: Cyclic dependencies");return[[...Array.from(t).filter((t=>!i.includes(t))),...i.filter((i=>t.has(i)))],i.filter((i=>!t.has(i)))]}get expressions(){return this.order[0].map((t=>wt(this.$t[t])))}},t.Rational=r,t.allDiff=(t,i)=>{const e=[],s=(t,i,n="")=>{if(t===i)return;if(t instanceof lt&&i instanceof lt)return void(t.id!==i.id&&t?.pointed!==i.id&&t.id!==i?.pointed&&e.push(`${n}/Cell: ${t.id} vs ${i.id}`));if(t instanceof Ce&&i instanceof Ce&&s(t.it,i.it,`${n}/Environment`),t instanceof r&&i instanceof r)return void(t.compare("==",i)||e.push(`${n}/Rational: ${t} vs ${i}`));if("function"==typeof t&&"function"==typeof i)return;if("object"!=typeof t||null===t||"object"!=typeof i||null===i)return void e.push(`${n}/Type: ${typeof t} vs ${typeof i}`);if("Object"!==t.constructor.name&&t.constructor.name===i.constructor.name&&t.toString)return void(t.toString()!==i.toString()&&e.push(`${n}/${t.constructor.name}: ${t} vs ${i}`));if(Array.isArray(t)&&Array.isArray(i))return t.length!==i.length&&e.push(`${n}/Array length: ${t.length} vs ${i.length}`),void t.forEach(((t,e)=>{s(t,i[e],`${n}[${e}]`)}));const h=Object.keys(t),O=Object.keys(i);h.length!==O.length&&e.push(`${n}/Object keys length: ${h.length} vs ${O.length}`);for(const r of h)O.includes(r)?s(t[r],i[r],`${n}/${r}`):e.push(`${n}/Missing key in second object: ${r}`)};return s(t,i),e},t.defaultLibrary=Ue,t.firstDiff=function t(i,e){if(i===e)return null;if(i instanceof lt&&e instanceof lt)return i.id!==e.id&&i?.pointed!==e.id&&i.id!==e?.pointed?`Cell difference: ${i.id} vs ${e.id}`:null;if(i instanceof Ce&&e instanceof Ce){const s=t(i.it,e.it);return s?`Environment difference: ${s}`:null}if(i instanceof r&&e instanceof r)return i.compare("==",e)?null:`Rational number difference: ${i} vs ${e}`;if("object"==typeof i&&"object"==typeof e&&"Object"!==i.constructor.name&&i.constructor.name===e.constructor.name&&i.toString)return i.toString()!==e.toString()?`${i.constructor.name}: ${i} vs ${e}`:null;if("object"!=typeof i||null===i||"object"!=typeof e||null===e)return`Type difference: ${typeof i} vs ${typeof e}`;if(Array.isArray(i)&&Array.isArray(e)){if(i.length!==e.length)return`Array length difference: ${i.length} vs ${e.length}`;for(let s=0;s<i.length;s++){const r=t(i[s],e[s]);if(r)return`Array[${s}] difference: ${r}`}return null}const s=Object.keys(i),n=Object.keys(e);if(s.length!==n.length)return`Object keys length difference: ${s.length} vs ${n.length}`;for(const r of s){if(!n.includes(r))return`Missing key in second object: ${r}`;const s=t(i[r],e[r]);if(s)return`Key '${r}' difference: ${s}`}return null},t.isEqual=Ge,t.isRationalString=t=>"string"==typeof t&&s.test(t),t.length=i,t.newConstant=S,t.newFromJS=j,t.newLambda=V,t.newLambdaMulti=U,t.newList=T,t.newNumber=X,t.newObject=E,t.newTypeConst=F,t.newTypeObject=_,t.newTypeScheme=(t,i=[])=>({vars:i,type:t}),t.newTypeTuple=t=>({kind:x,elementTypes:t}),t.newTypeVar=N,t.newVariable=t=>({type:b,name:t}),t.parseExpression=ge,t.parser=we,t.plural=e,t.prettyPrint=wt,t.prettyPrintType=$t,t.rationalNumber=ze,t.rationalNumberRegex=s,t.reservedKeywords=["true","false","if","for","in"],t.toHighLevelAST=mt,t.toLowLevelAST=Pt,t.typeAny=I,t.typeBoolean=Pe,t.typeBytes=ve,t.typeFromJSValue=Ye,t.typeFunction=G,t.typeList=Z,t.typeNumber=ye,t.typeString=me,t.zero=Q,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})}));
@@ -0,0 +1,15 @@
1
+ import type { Tree } from "@lezer/common";
2
+ /** Low-level AST Nodes */
3
+ export type LowLevelAST = {
4
+ /** name of Node type */
5
+ name: string;
6
+ /** value for terminal Nodes */
7
+ value?: string;
8
+ /** children for non-terminal Nodes */
9
+ children?: LowLevelAST[];
10
+ error?: {
11
+ from: number;
12
+ to: number;
13
+ };
14
+ };
15
+ export declare function toLowLevelAST(input: string, tree: Tree): LowLevelAST;
@@ -0,0 +1 @@
1
+ export declare const mergeWithFirstPriority: <Key extends string | number, T extends Record<Key, unknown>>(objects: T[]) => T;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * ObjectMap is map for objects, preserving keys.
3
+ * @param fn
4
+ * @param obj
5
+ * @returns
6
+ */
7
+ export declare const ObjectMap: <A, B>(fn: (key: string, v: A) => B, obj: {
8
+ [key: string]: A;
9
+ }) => {
10
+ [key: string]: B;
11
+ };
12
+ /**
13
+ * ObjectMapKey is map for objects, with the mapping function generating new keys.
14
+ * @param fn
15
+ * @param obj
16
+ * @returns
17
+ */
18
+ export declare const ObjectMapKey: <A, B>(fn: (key: string, v: A) => [string, B], obj: {
19
+ [key: string]: A;
20
+ }) => {
21
+ [key: string]: B;
22
+ };
23
+ /**
24
+ * ObjectMapValuesPreserve is map for objects, preserving keys.
25
+ * It returns the original object if no values have changed.
26
+ */
27
+ export declare const ObjectMapValuesPreserve: <A>(fn: (v: A) => A, obj: {
28
+ [key: string]: A;
29
+ }) => {
30
+ [key: string]: A;
31
+ };
32
+ export declare const ArrayMapPreserve: <A>(fn: (v: A) => A, arr: A[]) => A[];
@@ -0,0 +1,7 @@
1
+ import type { ASTNode } from "./ast";
2
+ import { type ParserExtension } from "./highLevel";
3
+ export declare const reservedKeywords: string[];
4
+ export type ParseOptions = {
5
+ ext?: ParserExtension<unknown, string>[];
6
+ };
7
+ export declare const parseExpression: (expr: string, options?: ParseOptions) => Promise<ASTNode>;
@@ -0,0 +1,5 @@
1
+ import { type ASTNode } from "./ast";
2
+ import type { MonoType } from "./types";
3
+ export declare function prettyPrintType(type: MonoType): string;
4
+ export declare function prettyPrint(node: ASTNode, parentPrecedence?: number): string;
5
+ export declare function prettyPrintHTML(node: ASTNode, parentPrecedence?: number): string;
@@ -0,0 +1,77 @@
1
+ import type { ASTNode } from "./ast";
2
+ import type { Environment } from "./env";
3
+ import { type ParseOptions } from "./parse";
4
+ export declare enum EvalOption {
5
+ NoFail = "noFail",// modified from lowercase
6
+ LocalEvaluation = "local",
7
+ ErrorToFalse = "false",
8
+ Sense = "sense",
9
+ SkipNotFound = "skip",
10
+ FailUndefined = "undefined"
11
+ }
12
+ type ProgramOptions = {
13
+ parseOptions?: ParseOptions;
14
+ };
15
+ /**
16
+ * Program defines a lambdascript program.
17
+ * @usage await new Program().set([defs...])
18
+ */
19
+ export declare class Program {
20
+ private _graph;
21
+ _defs: {
22
+ [key: string]: ASTNode;
23
+ };
24
+ _options: ProgramOptions;
25
+ /**
26
+ *
27
+ * @param defs AST for each expression, where keys **must** be lower case.
28
+ */
29
+ constructor(defs?: {
30
+ [key: string]: ASTNode;
31
+ }, options?: ProgramOptions);
32
+ private _resetProgram;
33
+ /** add a definition to the program, updating the graph */
34
+ private _addDef;
35
+ set: (...l: string[]) => Promise<Program>;
36
+ get: (key: string) => ASTNode | undefined;
37
+ /**
38
+ * order_program returns the order of evaluation for a program.
39
+ * @param p Program (list of definitions "name:expr")
40
+ * @returns [order of evaluation for program definitions, set of required values in env]
41
+ */
42
+ get order(): [string[], string[]];
43
+ /**
44
+ * dependencies computes the required dependencies for a sub-list of keys in a Program.
45
+ * @param keys root keys
46
+ * @returns list of values required for the evaluation of given keys
47
+ * @todo move to Graph
48
+ */
49
+ dependencies: (keys: string[], env?: Environment) => string[];
50
+ /**
51
+ * reduce computes an updated environment after evaluation of a program.
52
+ * @param env environment
53
+ * @param options list of evaluation options
54
+ * @returns updated environment
55
+ */
56
+ reduce: (env: Environment) => Promise<Environment>;
57
+ /**
58
+ * partialReduce attempts to evaluate the program while skipping expressions
59
+ * with unknown dependencies.
60
+ * It returns the updated environment, the list of expressions that couldn't
61
+ * be evaluated, and the set of their unknown dependencies.
62
+ * @param env environment
63
+ * @returns [updated environment, remaining expressions to evaluate,
64
+ * set of unknown dependencies]
65
+ */
66
+ partialReduce: (env: Environment) => Promise<[Environment, string[], Set<string>]>;
67
+ /**
68
+ * parseProgram parses a program (without ordering).
69
+ * @param l list of definitions in the form "name:expr"
70
+ * @returns Program (may throw error)
71
+ */
72
+ parseProgram: (l: string[]) => Promise<{
73
+ [key: string]: ASTNode;
74
+ }>;
75
+ get expressions(): string[];
76
+ }
77
+ export {};
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Rational encodes arbitrary precision numbers as
3
+ * [numerator,denominator,negative]
4
+ */
5
+ export type RationalNumber = [bigint, bigint, boolean];
6
+ export type RationalString = string;
7
+ export declare const rationalNumberRegex: RegExp;
8
+ export declare const isRationalString: (input: unknown) => input is RationalString;
9
+ /**
10
+ * Rational is a class from RationalNumbers.
11
+ */
12
+ export declare class Rational {
13
+ private _value;
14
+ constructor(num: number | bigint | string | RationalNumber);
15
+ /**
16
+ * low-level output
17
+ * @returns
18
+ */
19
+ output: () => string;
20
+ simplify: () => Rational;
21
+ toString: () => string;
22
+ get toPrettyString(): string;
23
+ toBigInt: () => bigint;
24
+ toNumber: () => number;
25
+ add: (b: Rational) => Rational;
26
+ subtract: (b: Rational) => Rational;
27
+ multiply: (b: Rational) => Rational;
28
+ divide: (b: Rational) => Rational;
29
+ power: (b: Rational) => Rational;
30
+ min: (...args: Rational[]) => Rational;
31
+ max: (...args: Rational[]) => Rational;
32
+ compare: (op: string, b: Rational) => boolean;
33
+ equals: (b: Rational) => boolean;
34
+ floor: () => Rational;
35
+ }
36
+ export declare const printRational: (r: RationalNumber) => string;
37
+ /**
38
+ * NewRational creates a new Rational from any number.
39
+ * @param num
40
+ */
41
+ export declare const NewRational: (num: number | bigint | string) => RationalNumber;
42
+ export declare function getNumberParts(x: number): {
43
+ sign: number;
44
+ exponent: number;
45
+ mantissa: number;
46
+ };
47
+ export declare function floatToRational(f: number, maxDenominator?: number): RationalNumber;
48
+ export declare function simplifyRational([numerator, denominator, neg]: RationalNumber): RationalNumber;
49
+ export declare function add([num1, den1, sign1]: RationalNumber, [num2, den2, sign2]: RationalNumber): RationalNumber;
50
+ export declare const negative: ([a, b, s]: RationalNumber) => RationalNumber;
51
+ export declare const subtract: (r1: RationalNumber, r2: RationalNumber) => RationalNumber;
52
+ export declare const multiply: ([num1, den1, isNegative1]: RationalNumber, [num2, den2, isNegative2]: RationalNumber) => RationalNumber;
53
+ export declare const divide: ([num1, den1, isNegative1]: RationalNumber, [num2, den2, isNegative2]: RationalNumber) => RationalNumber;
54
+ /**
55
+ * Calculate n-th root of val
56
+ * Parameters:
57
+ * k: is n-th (default square root)
58
+ * limit: is maximum number of iterations (default: -1 no limit)
59
+ * @from https://stackoverflow.com/questions/53683995/javascript-big-integer-square-root
60
+ */
61
+ export declare function rootNth(val: bigint, k?: bigint, limit?: number): bigint[];
62
+ export declare const power: ([num1, den1, isNegative1]: RationalNumber, [num2, den2, isNegative2]: RationalNumber) => RationalNumber;
63
+ /**
64
+ * Compares two rational numbers.
65
+ * Returns:
66
+ * - a positive number if a > b
67
+ * - 0 if a = b
68
+ * - a negative number if a < b
69
+ */
70
+ export declare function compareRationalNumbers([aNum, aDenom, aNeg]: RationalNumber, [bNum, bDenom, bNeg]: RationalNumber): number;
71
+ export declare function min(v: RationalNumber, ...args: RationalNumber[]): RationalNumber;
72
+ export declare function max(v: RationalNumber, ...args: RationalNumber[]): RationalNumber;
73
+ export declare const zero: Rational;
@@ -0,0 +1,43 @@
1
+ import { type SheetProxy } from "@okcontract/cells";
2
+ import type { Value } from "./eval";
3
+ import type { TypeScheme } from "./typeScheme";
4
+ import { type MonoType, type TypeConst } from "./types";
5
+ export declare const typeNumber: TypeConst;
6
+ export declare const typeString: TypeConst;
7
+ export declare const typeBoolean: TypeConst;
8
+ export declare const typeBytes: TypeConst;
9
+ /**
10
+ * LibraryItem defines an element of the standard library.
11
+ */
12
+ export interface LibraryElement {
13
+ doc?: string;
14
+ f: Value<unknown>;
15
+ t: TypeScheme;
16
+ }
17
+ export declare const isClassInstance: (value: unknown) => boolean;
18
+ /**
19
+ * return the first element of an array, recursively.
20
+ * @param v
21
+ * @returns first element or input value if not an array
22
+ */
23
+ export declare const first_element: <T>(v: T | T[]) => T;
24
+ export type StandardLibrary = {
25
+ [key: string]: LibraryElement;
26
+ };
27
+ /**
28
+ * defaultLibrary is the core standard library.
29
+ * @namespace all names should be lower case
30
+ */
31
+ export declare const defaultLibrary: (libproxy: SheetProxy) => StandardLibrary;
32
+ export type FirstClassValue = {
33
+ name: string;
34
+ is: (v: unknown) => boolean;
35
+ type: TypeConst;
36
+ };
37
+ export declare const rationalNumber: FirstClassValue;
38
+ /**
39
+ * typeFromJSValue creates a λs type from a JS literal.
40
+ * @param expression
41
+ * @returns
42
+ */
43
+ export declare const typeFromJSValue: (expression: unknown, fcv?: FirstClassValue[]) => MonoType;
@@ -0,0 +1,7 @@
1
+ import { type ASTNode } from "./ast";
2
+ /**
3
+ * traverseAST traverses the AST.
4
+ * @param node
5
+ * @param operation function taking the node and the list of bound vars in context.
6
+ */
7
+ export declare const traverseAST: (node: ASTNode, operation: (node: ASTNode, vars: Set<string>) => void) => void;
@@ -0,0 +1,19 @@
1
+ import { type MonoType } from "./types";
2
+ export type TypeScheme = {
3
+ vars: string[];
4
+ type: MonoType;
5
+ };
6
+ export declare const newTypeScheme: (type: MonoType, vars?: string[]) => TypeScheme;
7
+ /**
8
+ * Instantiate a fresh representation of a TypeScheme.
9
+ * @param ts
10
+ * @returns
11
+ */
12
+ export declare const Instantiate: (ts: TypeScheme, newVars?: {
13
+ [orig: string]: string;
14
+ }) => MonoType;
15
+ export declare const InstantiateAlpha: (ts: TypeScheme) => MonoType;
16
+ /**
17
+ * Create a TypeScheme from a MonoType by collecting its free variables.
18
+ */
19
+ export declare const TypeSchemeOfMonoType: (type: MonoType) => TypeScheme;