@okcontract/lambdascript 0.1.0 → 0.2.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.
@@ -1 +1,4 @@
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:OOO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j#lQaOT{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"})}));
1
+ var{defineProperty:iO,getOwnPropertyNames:b$,getOwnPropertyDescriptor:y$}=Object,m$=Object.prototype.hasOwnProperty;function i$(O){return this[O]}var d$=(O)=>{var Q=(IQ??=new WeakMap).get(O),$;if(Q)return Q;if(Q=iO({},"__esModule",{value:!0}),O&&typeof O==="object"||typeof O==="function"){for(var P of b$(O))if(!m$.call(Q,P))iO(Q,P,{get:i$.bind(O,P),enumerable:!($=y$(O,P))||$.enumerable})}return IQ.set(O,Q),Q},IQ;var l$=(O)=>O;function v$(O,Q){this[O]=l$.bind(null,Q)}var r$=(O,Q)=>{for(var $ in Q)iO(O,$,{get:Q[$],enumerable:!0,configurable:!0,set:v$.bind(Q,$)})};var qX={};r$(qX,{zero:()=>AQ,typeString:()=>UO,typeNumber:()=>x,typeList:()=>GO,typeFunction:()=>N,typeFromJSValue:()=>TO,typeBytes:()=>K$,typeBoolean:()=>C,typeAny:()=>p,toLowLevelAST:()=>QO,toHighLevelAST:()=>H,reservedKeywords:()=>D$,rationalNumberRegex:()=>dO,rationalNumber:()=>_Q,prettyPrintType:()=>a,prettyPrint:()=>K,plural:()=>YO,parser:()=>$O,parseProgram:()=>fO,parseExpression:()=>AO,newVariable:()=>pO,newTypeVar:()=>L,newTypeTuple:()=>yQ,newTypeScheme:()=>dQ,newTypeObject:()=>LO,newTypeConst:()=>l,newTuple:()=>NQ,newObject:()=>oO,newNumber:()=>rO,newList:()=>tO,newLambdaMulti:()=>aO,newLambda:()=>cO,newFromJS:()=>MO,newConstant:()=>sO,length:()=>QQ,isRationalString:()=>CQ,isRational:()=>fQ,isEqual:()=>i,formatSource:()=>f$,formatProgram:()=>T$,formatExpression:()=>x$,firstDiff:()=>n,evaluateASTSingle:()=>u$,defaultLibrary:()=>NO,defaultFormatSettings:()=>jQ,applyName:()=>TQ,apply:()=>vO,allDiff:()=>j$,Separator:()=>FQ,Rational:()=>F,Program:()=>BQ,Names:()=>xQ,NameVariable:()=>w,NameTuple:()=>J,NameObject:()=>V,NameList:()=>j,NameLambda:()=>R,NameField:()=>g,NameError:()=>T,NameConstant:()=>k,NameApplication:()=>M,EvalOption:()=>KQ,Environment:()=>u});module.exports=d$(qX);var dO=/^-?\d+\/\d+$/,CQ=(O)=>typeof O==="string"&&dO.test(O);class F{_value;constructor(O){this._value=Array.isArray(O)&&O.length===3&&typeof O[0]==="bigint"&&typeof O[1]==="bigint"&&typeof O[2]==="boolean"?O:hQ(O)}output=()=>{let O=this._value[0],Q=this._value[1];return`"${this._value[2]?"-":""}${O.toString()}${Q===1n?"":`/${Q.toString()}`}"`};simplify=()=>new F(WO(this._value));toString=()=>HQ(this._value);get toPrettyString(){return HQ(this._value)}toBigInt=()=>{let[O,Q,$]=this._value;return $?-O/Q:O/Q};toHex=()=>`0x${this.toBigInt().toString(16)}`;toNumber=()=>{let[O,Q,$]=this._value;return $?Number(-O)/Number(Q):Number(O)/Number(Q)};add=(O)=>new F(gQ(this._value,O._value));subtract=(O)=>new F(p$(this._value,O._value));multiply=(O)=>new F(t$(this._value,O._value));divide=(O)=>new F(o$(this._value,O._value));power=(O)=>new F(a$(this._value,O._value));min=(...O)=>new F(n$(this._value,...O.map((Q)=>Q._value)));max=(...O)=>new F(e$(this._value,...O.map((Q)=>Q._value)));compare=(O,Q)=>{let $=this.simplify(),P=Q.simplify(),X=$._value[2]?-($._value[0]*P._value[1]):$._value[0]*P._value[1],Z=P._value[2]?-(P._value[0]*$._value[1]):P._value[0]*$._value[1];switch(O){case"<":return X<Z;case">":return X>Z;case"<=":return X<=Z;case">=":return X>=Z;case"==":return X===Z;case"!=":return X!==Z;default:throw Error("Invalid operator. Use one of these: < > <= >= == !=")}};equals=(O)=>this.compare("==",O);floor=()=>{let[O,Q,$]=this._value,P=O/Q;if($&&O%Q!==0n)P+=1n;return new F([P,1n,$])}}var HQ=(O)=>{let[Q,$,P]=WO(O);return`${P?"-":""}${Q.toString()}${$>1n?`/${$.toString()}`:""}`},hQ=(O)=>{switch(typeof O){case"undefined":return[0n,1n,!1];case"bigint":return[O<0n?-O:O,1n,O<0n];case"number":return MQ(O);case"string":if(O.includes("."))return MQ(Number.parseFloat(O));if(O.includes("/")){let[Q,$]=O.split("/").map((X)=>BigInt(X.trim())),P=Q<0n;return[P?-Q:Q,$,P]}return hQ(BigInt(O))}};function MQ(O,Q=1e6){let $=1/(Q*Q),[P,X]=[1n,0n],[Z,W]=[0n,1n],G=Math.abs(O);do{let Y=BigInt(Math.floor(G)),q=G-Number(Y);if([Z,P]=[P,Y*P+Z],[W,X]=[X,Y*X+W],Math.abs(Number(P)/Number(X)-Math.abs(O))<$)break;G=1/q}while(Number(X)<Q);return[P,X,O<0]}function lO(O,Q){return Q===0n?O:lO(Q,O%Q)}function WO([O,Q,$]){let P=lO(O,Q);return[O/P,Q/P,$]}function gQ([O,Q,$],[P,X,Z]){let W=($?-1n:1n)*O*X+(Z?-1n:1n)*P*Q,G=Q*X,Y=W<0n?-W:W,q=lO(Y,G);return[Y/q,G/q,W<0n]}var s$=([O,Q,$])=>[O,Q,!$],p$=(O,Q)=>gQ(O,s$(Q)),t$=([O,Q,$],[P,X,Z])=>WO([O*P,Q*X,$!==Z]),o$=([O,Q,$],[P,X,Z])=>{if(P===BigInt(0))throw Error("Division by zero");return WO([O*X,Q*P,$!==Z])};function cQ(O,Q=2n,$=-1){let P=0n,X=O,Z=$;while(X**Q!==Q&&X!==P&&--Z)if(P=X,X=((Q-1n)*X+O/X**(Q-1n))/Q,Z<0&&(X-P)**2n===1n)break;if((O-(X-1n)**Q)**2n<(O-X**Q)**2n)X=X-1n;if((O-(X+1n)**Q)**2n<(O-X**Q)**2n)X=X+1n;let W=O-X**Q;return[X,W]}var a$=([O,Q,$],[P,X,Z])=>{if(Z)throw Error("Exponent must be a non-negative integer");if(P===0n)return[1n,1n,!1];if(X!==1n){if($)throw Error("Cannot root a negative base");let[W,G]=cQ(O,X),[Y,q]=cQ(Q,X);if(G!==0n||q!==0n)throw Error("There is a remainder");return WO([W,Y,!1])}return WO([O**P,Q**P,$&&P%2n!==0n])};function LQ([O,Q,$],[P,X,Z]){if($&&!Z)return-1;if(!$&&Z)return 1;let W=O*X,G=P*Q;if($&&Z)return Number(G-W);return Number(W-G)}function n$(O,...Q){let $=O;for(let P of Q)if(LQ(P,$)<0)$=P;return $}function e$(O,...Q){let $=O;for(let P of Q)if(LQ(P,$)>0)$=P;return $}var AQ=new F(0),fQ=(O)=>O!==null&&typeof O==="object"&&("simplify"in O);var M="app",k="const",w="var",j="lst",V="obj",R="λ",g="field",T="error",J="tup",xQ=Object.entries({[M]:"NameApplication",[k]:"NameConstant",[w]:"NameVariable",[j]:"NameList",[V]:"NameObject",[R]:"NameLambda",[g]:"NameField",[T]:"NameError",[J]:"NameTuple"}),vO=(O,Q)=>({type:M,function:O,params:Q}),TQ=(O,Q)=>vO(pO(O),Q),rO=(O)=>{let Q=O instanceof F?O:new F(O);return{type:k,value:Q}},sO=(O)=>typeof O==="number"||typeof O==="bigint"?rO(O):{type:k,value:O},pO=(O)=>({type:w,name:O}),tO=(O)=>({type:j,elements:O}),NQ=(O)=>({type:J,elements:O}),oO=(O)=>({type:V,values:O}),MO=(O)=>Array.isArray(O)?tO(O.map(MO)):typeof O==="object"&&O!==null?oO(Object.fromEntries(Object.entries(O).map(([Q,$])=>[Q,MO($)]))):typeof O==="string"||typeof O==="number"||typeof O==="bigint"||typeof O==="boolean"?sO(O):{type:T,value:`Unsupported JS value: ${String(O)}`},cO=(O,Q)=>({type:R,parameter:O,body:Q}),aO=(O,Q)=>{let[$,...P]=O;if(P.length===0)return cO($,Q);return cO($,aO(P,Q))};var uO=require("@okcontract/cells");var s=(O)=>(Q)=>{switch(Q.type){case k:return O.const(Q.value);case w:{let $=O.read(Q.name);if(!$)throw Error(`Undefined variable: ${Q.name}`);return $}case M:{let $=s(O)(Q.function),P=Q.params.map((X)=>s(O)(X));return $.map((X)=>{if(typeof X!=="function")throw Error(`Not a function: ${Q.function.type}`);return X?.local?X(...P):X(O,...P)},"(app)")}case j:{let $=Q.elements.map(s(O));return O.proxy.new($,"[]")}case J:{let $=Q.elements.map(s(O));return O.proxy.new($,"{}")}case V:{let $=Object.entries(Q.values),P=$.map(([W,G])=>W),X=$.map(([W,G])=>G).map(s(O));return O.proxy.mapNoPrevious(X,(...W)=>Object.fromEntries(W.map((G,Y)=>[P[Y],G])),"{}")}case g:{let $=s(O)(Q.expr);if(g in Q){let X=Q.field;return $.map((Z)=>{return Z[X]})}let P=s(O)(Q.sub);return O.proxy.map([$,P],(X,Z)=>{return X[Z]||null},":")}case R:{let $=(P)=>{let X=O.withValue(Q.parameter,P);return s(X)(Q.body)};return $.local=!0,O.proxy.new($,"eval.λ")}case T:throw Error(`parse error: ${Q.value}`);case"named":throw Error('"named" node type is temporary and should not appears at evaluation');default:return Q}};var uQ=require("@okcontract/cells");var CO=["α","β","γ","δ","ε","ζ","η","θ","ι","κ","λ","μ","ν","ξ","ο","π","ρ","ς","σ","τ","υ","φ","χ","ψ","ω"];function OP(O,Q){if(!O.has(Q.type)){let P=O.size,X=CO[P%CO.length]+(P<CO.length?"":`${Math.floor(P/CO.length)}`);O.set(Q.type,X)}return O.get(Q.type)??Q.type}function a(O){let Q=new Map,$=(P)=>{switch(P.kind){case w:return OP(Q,P);case k:return P.type;case R:{let X=P.argTypes.map((W)=>$(W)).join(", "),Z=$(P.returnType);return`(${X}) -> ${Z}`}case j:return`[${$(P.elementType)}]`;case J:return`{${P.elementTypes.map($).join(", ")}}`;case V:return`{${Object.entries(P.fields).map(([Z,W])=>`${Z}: ${$(W)}`).join(", ")}}`;default:return""}};return $(O)}var QP={"+":1,"-":1,"*":2,"/":2,"%":2,"^":3,"=":0,"<":0,">":0,"!":0},$P=new Set(["-","/","%","=","<",">"]);function PP(O){let Q=Number.parseInt(O,10);return!Number.isNaN(Q)&&Number.isInteger(Q)&&Q.toString()===O}function K(O,Q=0){switch(O.type){case M:{let $;if(O.function.type===w){if($=O.function.name==="IF"?"if":O.function.name,$!=="!"&&/^[+\-*/%=<>!^&|]/.test($)){let X=QP[$],Z=$P.has($)?X+1:X,G=`${O.params.map((Y,q)=>K(Y,q===1?Z:X)).join(` ${$} `)}`;if(Q>X)return`(${G})`;return G}}else $=K(O.function);let P=O.params.map(K);return`${$}(${P.join(", ")})`}case k:{let $=O.value;if($!==null&&typeof $==="object"&&"toString"in $)return $.toString();return uQ.jsonStringify($)}case w:return O.name;case j:return`[${O.elements.map(K).join(", ")}]`;case J:return`{${O.elements.map(K).join(", ")}}`;case V:return`{${Object.entries(O.values).map(([P,X])=>`${P}: ${K(X)}`).join(", ")}}`;case R:return`${O.parameter} => (${K(O.body)})`;case g:{let $="field"in O?O.field:K(O.sub);return PP($)?`${K(O.expr)}[${$}]`:`${K(O.expr)}.${$}`}case"named":throw Error(`node type "named" is temporary and shouldn't appear in final AST`);case T:return O.value;default:throw O}}var hO=(O,Q)=>Object.fromEntries(Object.entries(Q).map(([$,P])=>O($,P))),bQ=(O,Q)=>{let $=!1,P=Object.entries(Q).map(([X,Z])=>{let W=O(Z);if(!W)console.log("ObjectMapValuesPreserve",{k:X,v:Z,newV:W});if(W!==Z)$=!0;return[X,W]});if($)return Object.fromEntries(P);return Q},gO=(O,Q)=>{let $=!1,P=(Z)=>{let W=O(Z);if(!W)console.log("ArrayMapPreserve",{v:Z,newV:W});if(W!==Z)$=!0;return W},X=Q.map(P);if($)return X;return Q};var FO="any",N=(O,Q,$)=>({kind:R,argTypes:O,argVariadic:$,returnType:Q}),GO=(O)=>({kind:j,elementType:O}),yQ=(O)=>({kind:J,elementTypes:O}),LO=(O,Q=!1)=>({kind:V,fields:O,open:Q}),RO="generic",EO="conditional";var mQ=0;function L(O){let Q=mQ++;return{kind:w,type:`${O}${Q}`}}var iQ=(O,Q)=>Object.fromEntries(O.map(($)=>{let P=mQ++;return[$,`${Q}${P}`]}));function nO(O){return O.kind===w}var l=(O)=>{return{kind:k,type:O}};function eO(O){return O.kind===k}var p={kind:FO};function jO(O,Q){let $=(P)=>{switch(P.kind){case w:return O(P.type)??P;case k:return P;case R:{let X=gO($,P.argTypes),Z=$(P.returnType),W=P.argVariadic?$(P.argVariadic):void 0;if(X===P.argTypes&&Z===P.returnType&&W===P.argVariadic)return P;return{kind:R,argTypes:X,returnType:Z,argVariadic:W}}case j:{let X=$(P.elementType);if(X===P.elementType)return P;return{kind:j,elementType:X}}case V:{let X=bQ($,P.fields);if(X===P.fields)return P;return{kind:V,fields:X,open:P.open}}case RO:{let X=$(P.baseType),Z=gO($,P.typeArgs);if(X===P.baseType&&Z===P.typeArgs)return P;return{kind:RO,baseType:X,typeArgs:Z}}case EO:{let X=$(P.check.left),Z=$(P.check.right),W=$(P.trueType),G=$(P.falseType);if(X===P.check.left&&Z===P.check.right&&W===P.trueType&&G===P.falseType)return P;return{kind:EO,check:{kind:P.check.kind,left:X,right:Z},trueType:W,falseType:G}}case FO:return p;case J:{let X=gO($,P.elementTypes);if(X===P.elementTypes)return P;return{kind:J,elementTypes:X}}default:return P}};return $(Q)}var dQ=(O,Q=[])=>({vars:Q,type:O}),OQ=(O,Q)=>{let $=Q??iQ(O.vars,"in");return jO((P)=>{if(O.vars.includes(P))return{kind:w,type:$[P]};return},O.type)};function XP(O){let Q=new Set;return jO(($)=>{Q.add($);return},O),Array.from(Q)}var lQ=(O)=>{return{vars:XP(O),type:O}};var QQ=(O)=>{if(!O)return 0;if(typeof O==="number")return O;if(Array.isArray(O))return O.length;if(typeof O==="object")return Object.keys(O).length;return 1},YO=(O,Q,$=!0)=>{let P=QQ(Q);return`${$?`${P} `:""}${O}${P>1?"s":""}`};var qO=(O,Q)=>{let $=Error(O);if(Q?.range)$.range=Q.range;throw $};class $Q{_current;constructor(){this._current={}}_apply=(O)=>{return jO((Q)=>{let $=this._current[Q];if($)return this._apply($);return},O)};_unify=(O,Q,$,P)=>{if(O===Q)return;let X=this._apply(O),Z=this._apply(Q);if(X===Z)return;if(X.kind===FO||Z.kind===FO)return;if(nO(X))this._current[X.type]=Z;else if(nO(Z))this._unify(Z,X,void 0,P);else if(X.kind===R&&Z.kind===R){if(X.argTypes.length!==Z.argTypes.length)if(X.argVariadic&&X.argTypes.length<Z.argTypes.length)for(let W=X.argTypes.length;W<Z.argTypes.length;W++)this._unify(X.argVariadic,Z.argTypes[W],void 0,P);else if(Z.argVariadic&&Z.argTypes.length<X.argTypes.length)for(let W=Z.argTypes.length;W<X.argTypes.length;W++)this._unify(Z.argVariadic,X.argTypes[W],void 0,P);else qO(`Function expects ${YO("argument",X.argTypes.length,!0)} (${Z.argTypes.length} provided) ${P?`at ${K(P)}`:""}`,P);for(let W=0;W<X.argTypes.length;W++)this._unify(X.argTypes[W],Z.argTypes[W],void 0,P);this._unify(X.returnType,Z.returnType,void 0,P)}else if(X.kind===j&&Z.kind===j)this._unify(X.elementType,Z.elementType,void 0,P);else if(X.kind===J&&Z.kind===J){if(X.elementTypes.length!==Z.elementTypes.length)qO(`Different arity for tuples: ${X.elementTypes.length} vs ${Z.elementTypes.length}`,P);for(let W=0;W<X.elementTypes.length;W++)this._unify(X.elementTypes[W],Z.elementTypes[W],void 0,P)}else if(X.kind===V&&Z.kind===V){let W=new Set([...Object.keys(X.fields),...Object.keys(Z.fields)]);for(let G of W)if(G in X.fields&&G in Z.fields)this._unify(X.fields[G],Z.fields[G],void 0,P);else if(G in X.fields){if(!Z.open)qO(`Object field mismatch: ${G} missing in second type`,P)}else{if(!X.open)qO(`Object field mismatch: ${G} missing in first type`,P);X.fields[G]=Z.fields[G]}if($)this._current[$]=X}else if(X.kind===RO&&Z.kind===RO){if(this._unify(X.baseType,Z.baseType,void 0,P),X.typeArgs.length!==Z.typeArgs.length)qO(`Generic type arguments mismatch: ${X.typeArgs.length} vs ${Z.typeArgs.length}`,P);for(let W=0;W<X.typeArgs.length;W++)this._unify(X.typeArgs[W],Z.typeArgs[W],void 0,P)}else if(X.kind===EO&&Z.kind===EO)this._unify(X.check.left,Z.check.left,void 0,P),this._unify(X.check.right,Z.check.right,void 0,P),this._unify(X.trueType,Z.trueType,void 0,P),this._unify(X.falseType,Z.falseType,void 0,P);else if(eO(X)&&eO(Z)&&(X.type===Z.type||X.type==="string"&&Z.type==="bytes"||X.type==="bytes"&&Z.type==="string"))return;else qO(`Type mismatch: ${a(X)} vs ${a(Z)} ${P?` at ${K(P)}`:""}`,P)}}var o=(O,Q)=>{let $=Error(O);if(Q?.range)$.range=Q.range;throw $},ZP=(O,Q=[])=>{if(O instanceof F)return"number";for(let $ of Q)if($.instance(O))return $.type.type;return typeof O},vQ=(O)=>async(Q)=>{let $=new $Q,P=async(W,G)=>{switch(G.type){case k:{let Y=ZP(G.value,W?.options?.extensions);return l(Y)}case w:{let Y=W.library(G.name);if(Y)return OQ(Y.t);let q=W.type(G.name);if(!q)return o(`Unbound variable: ${G.name}`,G);return OQ(q)}case M:{let Y=await P(W,G.function),q=L("r");return $._unify(Y,{kind:R,argTypes:await Promise.all(G.params.map((U)=>P(W,U))),returnType:q},void 0,G),$._apply(q)}case j:{let Y=L("e");for(let q of G.elements){let U=await P(W,q);$._unify(U,Y,void 0,G)}return $._apply({kind:j,elementType:Y})}case J:{let Y=await Promise.all(G.elements.map((q)=>P(W,q)));return $._apply({kind:J,elementTypes:Y})}case V:{let Y={};for(let q in G.values)Y[q]=await P(W,G.values[q]);return{kind:V,fields:Y,open:!1}}case g:{let Y=await P(W,G.expr),q="field"in G?G.field:await P(W,G.sub),U=typeof q!=="string"&&q.kind==="const"&&q.type==="number";if(!(Y.kind===V&&!U)&&!(Y.kind===j&&U)&&!(Y.kind===J&&U)&&Y.kind!==w)o(`In ${K(G)}: Expected ${U?"a list":"an object"} or variable, got ${Y.kind}`,G);if(typeof q!=="string"&&!U)o(`In ${K(G)}: Expected a field ${U?"index":"name"}, got ${a(q)}`,G);if(Y.kind===w){if(!U&&!("field"in G))o(`No field in ${K(G)}`,G);let S=L("f");return $._unify(Y,U?{kind:j,elementType:S}:{kind:V,fields:{[G.field]:S},open:!0},Y.type,G),$._apply(S)}if(U){if(Y.kind===j)return $._apply(Y.elementType);if(Y.kind===J){let S="sub"in G?G.sub:null;if(!S||!("value"in S)||!(S.value instanceof F))return o("tuple index must be a number",G);return $._apply(Y.elementTypes[S.value.toNumber()])}o("unkown type",G)}if(!(q in Y.fields)){if(!Y.open)o(`In ${K(G)}: Unknown field: ${q}`,G);let S=L("ff");return $._unify(Y,{kind:V,fields:{[q]:S},open:!0},void 0,G),$._apply(S)}return $._apply(Y.fields[q])}case R:{let Y=L("a"),q={vars:[],type:Y},U=await P(W.withType(G.parameter,q),G.body);return{kind:R,argTypes:[$._apply(Y)],returnType:$._apply(U)}}default:return o(`Unknown node type: ${K(G)}`,G)}},X=await P(O,Q);if($._apply(X)!==X)o(`In ${K(Q)}: Non-substituted free variable in ${a(X)}`,Q);return lQ(X)};var OO=(O)=>{let Q={};for(let $ of O)for(let[P,X]of Object.entries($))if(Q[P]===void 0)Q[P]=X;return Q};var B=(O)=>O?{from:O.from,to:O.to}:void 0,f=(O,Q)=>{let $=Error(O);if(Q)$.range=B(Q);throw $};function H(O,Q=[]){if(!O?.name)return f("Invalid parse tree",O);for(let $ of Q)if(O.name===$.elt&&typeof O.value==="string"&&$.pat(O.value))return{type:k,value:$.rewrite(O.value),range:B(O)};switch(O.name){case"SourceFile":if(O.children?.length===1)return H(O.children[0],Q);return f("empty source",O);case"ParenthesizedExpression":if(O.children?.length===1)return H(O.children[0],Q);return f("empty parenthesis",O);case"TupleExpression":{let $=O.children?.map((P)=>H(P,Q))||[];if($.length===0)f("Empty tuples are not allowed",O);return{type:J,elements:$,range:B(O)}}case"Identifier":return{type:w,name:O.value,range:B(O)};case"NumberValue":return{type:k,value:new F(O.value),range:B(O)};case"StringValue":return{type:k,value:JSON.parse(O.value),range:B(O)};case"BooleanValue":return{type:k,value:O.value==="true",range:B(O)};case"ArrayExpression":return{type:j,elements:O.children?.map(($)=>H($,Q))||[],range:B(O)};case"ObjectExpression":return{type:V,values:Object.fromEntries(O.children?.map(($)=>H($,Q))?.map(($)=>[$.key,$.value])||[]),range:B(O)};case"NamedField":if(O.children?.length===2)return{type:"named",key:O.children[0].value,value:H(O.children[1],Q),range:B(O)};return f("wrong NamedField length",O);case"FieldExpression":case"SubscriptExpression":{let $=O.children;if($?.length!==2)return f("wrong FieldExpression length",O);if($[1].name==="Identifier")return{type:g,expr:H($[0],Q),field:$[1].value,range:B(O)};return{type:g,expr:H($[0],Q),sub:H($[1],Q),range:B(O)}}case"FunctionExpression":{let $=O.children;if($?.length!==2)return f("wrong function length",O);let P;if($[0].name==="ArgumentList")P=$[0].children??[];else P=[$[0]];if(!P.length)return f("Function with no arguments",O);let X=H($[1],Q);for(let Z of P.reverse())X={type:R,parameter:Z.value,body:X,range:B(O)};return X}case"CallExpression":{let $=O.children;if($?.length!==2)return f("wrong CallExpression length",O);if($[1].name!=="ArgumentList")return f("wrong CallExpression arguments",$[1]);let P=$[1].children?.map((X)=>H(X,Q))||[];switch($[0].name){case"Identifier":return{type:M,function:{type:w,name:$[0].value,range:B($[0])},params:P,range:B(O)};case"ParenthesizedExpression":case"CallExpression":return{type:M,function:H($[0],Q),params:P,range:B(O)}}return f("unknown CallExpression",O)}case"UnaryExpression":{let $=O.children;if($?.length!==2)return f("wrong UnaryExpression length",O);if(!$[0].name.includes("Operator"))return f("not an unary operator",$[0]);return{type:M,function:{type:w,name:$[0].value,range:B($[0])},params:[H($[1],Q)],range:B(O)}}case"BinaryExpression":{let $=O.children;if($?.length!==3)return f("wrong BinaryExpression length",O);return{type:M,function:{type:w,name:$[1].value,range:B($[1])},params:[H($[0],Q),H($[2],Q)],range:B(O)}}case"TernaryExpression":{let $=O.children;if($?.length!==3)return f("wrong TernaryExpression length",O);return{type:M,function:{type:w,name:"IF",range:B(O)},params:$.map((P)=>H(P,Q)),range:B(O)}}case"⚠":return{type:T,value:O.value,range:B(O)};default:return f(`Unknown parse tree node: ${O.name}`,O)}}function WP(O){return O==="⚠"}function QO(O,Q){let $=(P)=>{let X=P?.type?.name,Z={name:X,from:P.from,to:P.to},W=P.firstChild;if(W){Z.children=[$(W)];while(W=W.nextSibling)Z.children.push($(W))}else Z.value=O.slice(P.from,P.to);if(WP(X))Z.error={from:P.from,to:P.to};return Z};return $(Q.topNode)}var S$=require("@lezer/lr");var JO=require("@lezer/lr");var PQ=100,rQ=1,sQ=101,pQ=102,tQ=103,XQ=104,ZQ=105,WQ=106,GQ=107,YQ=108;var YP=".".codePointAt(0),qP="\\".codePointAt(0),oQ="`".codePointAt(0),zP="$".codePointAt(0),UP="#".codePointAt(0),aQ="(".codePointAt(0),SP="[".codePointAt(0),DP=";".codePointAt(0),VO='"'.codePointAt(0),_P=`
2
+ `.codePointAt(0),nQ="A".codePointAt(0),eQ="Z".codePointAt(0),O$="a".codePointAt(0),Q$="z".codePointAt(0),RP="0".codePointAt(0),EP="9".codePointAt(0),$$="_".codePointAt(0),FP="@".codePointAt(0),jP=/^\p{Lu}/u,wP=/^\p{Ll}/u,VP=/^\p{Lt}/u,JP=/^\p{Lm}/u,kP=/^\p{Lo}/u,KP=/^\p{Me}/u,BP=/^\p{Mn}/u,IP=/^\p{Mc}/u,HP=/^\p{Nd}/u,MP=/^\p{Nl}/u,cP=/^\p{No}/u,CP=/^\p{Pc}/u,hP=/^\p{Sc}/u,gP=/^\p{Sk}/u,LP=/^\p{So}/u,AP=/^\p{Emoji}/u,P$=new JO.ExternalTokenizer((O,Q)=>{let $=O.peek(0);if($===_P||$===DP){if(Q.canShift(PQ)){O.acceptToken(PQ,1);return}}});function X$(O,Q){return jP.test(O)||wP.test(O)||VP.test(O)||JP.test(O)||kP.test(O)||MP.test(O)||hP.test(O)||AP.test(O)||LP.test(O)&&!(Q>=8592&&Q<=8703)&&Q!==65532&&Q!==65533&&Q!==9023&&Q!==166}function Z$(O,Q){let $=O.peek(Q);if($>=nQ&&$<=eQ||$>=O$&&$<=Q$||$===$$||$===zP||$===FP)return 1;if($<161||$>1114111)return 0;let P=W$(O,Q);if(X$(P,$))return P.length;return 0}function W$(O,Q){let $=1,P=O.peek(Q),X=String.fromCodePoint(P);while(!0){let Z=O.peek(Q+$);if(!(55296<=P&&P<=56319&&56320<=Z&&Z<=57343))break;X=X+String.fromCodePoint(Z),P=Z,$=$+1}return X}var G$=new JO.ExternalTokenizer((O,Q)=>{let $=!0,P=0,X=1;while(!0){let Z=O.peek(P);if(Z===-1)break;if($){if($=!1,X=Z$(O,P),X===0)break}else if(Z>=nQ&&Z<=eQ||Z>=O$&&Z<=Q$||Z>=RP&&Z<=EP||Z===$$);else if(Z<161||Z>1114111)break;else{let W=W$(O,P);if(X=W.length,X$(W,Z));else if(BP.test(W)||IP.test(W)||HP.test(W)||CP.test(W)||gP.test(W)||KP.test(W)||cP.test(W)||Z>=8242&&Z<=8247||Z===8279);else break}P=P+X,X=1}if(P!==0)O.acceptToken(rQ,P)}),fP=(O,Q)=>{let $=O.peek(Q),P=O.peek(Q+1);return $===UP&&(Z$(O,Q+1)!==0||P===aQ)},qQ=({till:O,term:Q})=>{return new JO.ExternalTokenizer(($,P)=>{let X=0,Z=!1;while(!0){let W=$.peek(X);if(W===-1)break;if(W===qP)Z=!0;else if(Z)Z=!1;else if(fP($,X)||O($,X)){if(X>0)$.acceptToken(Q,X);return}X=X+1}})},xP=(O,Q)=>{return O.peek(Q)===VO&&O.peek(Q+1)===VO&&O.peek(Q+2)===VO},TP=(O,Q)=>{return O.peek(Q)===VO},NP=(O,Q)=>{return O.peek(Q)===oQ},Y$=qQ({term:sQ,till:xP}),q$=qQ({term:pQ,till:TP}),z$=qQ({term:tQ,till:NP}),wO=(O,Q)=>{let $=O.peek(Q);return $>=9&&$<14||$>=32&&$<33||$>=133&&$<134||$>=160&&$<161||$>=5760&&$<5761||$>=8192&&$<8203||$>=8232&&$<8234||$>=8239&&$<8240||$>=8287&&$<8288||$>=12288&&$<12289},U$=new JO.ExternalTokenizer((O,Q)=>{if(O.peek(0)===aQ&&!wO(O,-1)&&Q.canShift(XQ)){O.acceptToken(XQ,0);return}if(O.peek(0)===SP&&!wO(O,-1)&&Q.canShift(ZQ)){O.acceptToken(ZQ,0);return}if(O.peek(0)===VO&&!wO(O,-1)&&Q.canShift(WQ)){O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z!zVOQR]^fklmnopqrt}!R!U!X!{#T#V#W#`#k#q#{#|$P$T$X$Z$n$q$y%Q%U%Z%]&_&d&k&l'rQ!VUQ%`$^Q&n)gV's&o't(kR%a$^Q$`#_Q%t$aQ%u$bQ&V$gQ&r%cQ&s%eQ&t%fQ&u%gQ&v%hQ&w%iQ&x%jQ&y%kQ&z%l^'O%o'Q'h'z(d(|)^h'Y%z'['^'e(S(W(Y(s(u)U)V)`Q'a&OQ'b&RQ'x&}U(O'U(P(pQ(['_Q(_'dQ(l'vR(m'{S%{$b'eQ'Z%zU(V'[(W(uQ(Z'^Y(q(S(s)U)V)`R(v(Y!v$f#_$a$b$g%c%e%f%g%h%i%j%k%l%o%z&O&R&}'Q'U'['^'_'d'e'h'v'z'{(P(S(W(Y(d(p(s(u(|)U)V)^)`Q&P$eQ(x(]Q)X)iV)a)Y)b)fR(y(]Q%q$`S'W%u'bQ'k&VR({(_R'g&US!_Y!`S!bZ!cT!e[!fT%}$b&RR#b![S#Ox#]R#t!kQdOT!QR!X",nodeNames:"⚠ Identifier SourceFile Program ProgramComponent LetComponent let ComponentBinding 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 and TopLevelDefinition",maxTerm:152,nodeProps:[["group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Q~,pZ#wPqr-cuv%}wx-iz{%}!O!P-n!P!Q%}!Q![(Z!^!_-y!_!`-c!`!a-y#Q#R.R~-fP!_!`%`Q-nO#gQQ-qP!O!P-tQ-yO#tQ~.OPa~!_!`%`Q.WO[Q~.]P#o~![!].`~.eO#s~~.jO#q~~.oQ#c~!_!`%`!`!a.u~.zO#e~~/PQa~![!]/V!_!`%`P/[OYP~/aO#y~~/fO$Q~~/kO$W~~/pO$Y~~/sP#p#q/v~/{O#i~~0QO$Z~~0VO$P~",tokenizers:[P$,G$,Y$,q$,z$,U$,0,1],topRules:{SourceFile:[0,2]},dynamicPrecedences:{"27":2,"42":2,"141":1,"150":1},specialized:[{term:1,get:(O)=>uP[O]||-1}],tokenPrec:3986});var D$=["true","false","if","for","in","let","and"],_$=(O)=>O?{from:O.from,to:O.to}:void 0,m=(O,Q)=>{let $=Error(O);if(Q)$.range=_$(Q);throw $},bP=/^([+-]?)(?:(\d+)(?:\.(\d*))?|\.(\d+))[eE]([+-]?\d+)$/,yP=(O)=>{let $=O.replace(/_/g,"").match(bP);if(!$)return O;let P=$[1]==="-"?"-":"",X=$[2]??"",Z=$[3]&&$[3]!==""?$[3]:$[4]??"",W=Number($[5]),G=X+Z,Y=G===""?"0":G,U=X.length+W;if(/^0+$/.test(Y))return"0";let S;if(W>=0)if(U>=Y.length)S=Y+"0".repeat(U-Y.length);else{let _=Y.slice(0,U)||"0",I=Y.slice(U);S=I?`${_}.${I}`:_}else if(U<=0)S=`0.${"0".repeat(-U)}${Y}`;else{let _=Y.slice(0,U)||"0",I=Y.slice(U);S=`${_}.${I}`}if(S.includes(".")){if(S=S.replace(/^0+(?=\d)/,""),S.startsWith("."))S=`0${S}`}else S=S.replace(/^0+(?=\d)/,"");let h=P+S;return h==="-0"?"0":h},zQ=(O)=>{if(O.name==="NumberValue"&&typeof O.value==="string")O.value=yP(O.value);O.children?.forEach(zQ)},R$=(O,Q)=>{if(O.name!=="ComponentBinding")m(`Unexpected node in binding: ${O.name}`,O);let[$,P]=O.children??[];if($?.name!=="Identifier")m("Program bindings must start with an identifier",O);if(!P)m(`Missing expression for program binding "${$.value??""}"`,$);return{name:$.value,expr:H(P,Q),range:_$($)}},mP=(O,Q)=>{if(O.name!=="LetComponent")m(`Unexpected node in component: ${O.name}`,O);let $=[],P,X=O.children??[];for(let W=0;W<X.length;W++){let G=X[W];if(!G)continue;switch(G.name){case"ComponentBinding":$.push(R$(G,Q));break;case"in":{let Y=X[W+1];if(!Y)m("Missing result expression after `in`",G);P=H(Y,Q),W++;break}case"let":case"and":break;default:m(`Unknown element in let component: ${G.name}`,G)}}if(!$.length)return m("Let components must declare at least one binding",O);let Z=P;if(!Z)return m("Let components must provide a result after `in`",O);return{bindings:$,result:Z}},iP=(O,Q)=>{if(O.name!=="Program")return m(`Unexpected node for program: ${O.name}`,O);let $=[],P=[];for(let X of O.children??[]){if(X.name!=="ProgramComponent")continue;let[Z]=X.children??[];if(!Z)continue;if(Z.name==="LetComponent"){$.push(mP(Z,Q));continue}if(Z.name==="TopLevelDefinition"){let W=Z.children?.find((G)=>G.name==="ComponentBinding");if(!W)return m("Top level definition missing binding content",Z);P.push(R$(W,Q));continue}m(`Unknown program component type: ${Z.name}`,Z)}return{components:$,definitions:P}},AO=async(O,Q={})=>{return new Promise(($,P)=>{try{let X=$O.parse(O),Z=QO(O,X);zQ(Z);let W=H(Z,Q.ext);$(W)}catch(X){P(X)}})},fO=async(O,Q={})=>{return new Promise(($,P)=>{try{let{ext:X=[]}=Q,Z=$O.parse(O),W=QO(O,Z);zQ(W);let G=W.children?.find((Y)=>Y.name==="Program");if(!G){if(O.trim()===""){$({components:[],definitions:[]});return}return m("Expected program definition",W)}$(iP(G,X))}catch(X){P(X)}})};var SO=require("@okcontract/cells");var PO=require("@okcontract/cells");function zO(O){return O.constructor?.name??"Object"}function UQ(O){let Q=Object.getPrototypeOf(O);return Q===Object.prototype||Q===null}function v(O){if(typeof O==="string")return JSON.stringify(O);if(typeof O==="symbol")return O.toString();return String(O)}function E$(O){return(O===null||typeof O!=="object")&&!Number.isNaN(O)}function SQ(O,Q,$){for(let P=0;P<O.length;P++){if($[P])continue;if(i(Q,O[P]))return P}return-1}function DQ(O,Q,$,P){for(let X=0;X<O.length;X++){if(P[X])continue;let[Z,W]=O[X];if(i(Q,Z)&&i($,W))return X}return-1}function F$(O,Q,$){for(let P=0;P<O.length;P++){if($[P])continue;if(i(Q,O[P][0]))return P}return-1}function dP(O,Q){if(O.size!==Q.size)return!1;let $=[],P=[];for(let Z of O)if(E$(Z)){if(!Q.has(Z))return!1}else $.push(Z);if($.length===0)return!0;for(let Z of Q)if(!E$(Z))P.push(Z);if($.length!==P.length)return!1;let X=Array(P.length).fill(!1);for(let Z of $){let W=SQ(P,Z,X);if(W===-1)return!1;X[W]=!0}return!0}function lP(O,Q){if(O.size!==Q.size)return!1;let $=Array.from(Q.entries()),P=Array($.length).fill(!1);for(let[X,Z]of O){let W=DQ($,X,Z,P);if(W===-1)return!1;P[W]=!0}return!0}var j$=(O,Q)=>{let $=[],P=(X,Z,W="")=>{if(X===Z)return;if(X instanceof PO.Cell&&Z instanceof PO.Cell){if(!(X.id===Z.id||X?.pointed===Z.id||X.id===Z?.pointed))$.push(`${W}/Cell: ${X.id} vs ${Z.id}`);return}if(X instanceof u&&Z instanceof u){P(X.values,Z.values,`${W}/Environment`);return}if(X instanceof F&&Z instanceof F){if(!X.compare("==",Z))$.push(`${W}/Rational: ${X} vs ${Z}`);return}if(typeof X==="function"&&typeof Z==="function")return;if(typeof X!=="object"||X===null||typeof Z!=="object"||Z===null){if(typeof X!==typeof Z)$.push(`${W}/Type: ${typeof X} vs ${typeof Z}`);else $.push(`${W}/Value: ${String(X)} vs ${String(Z)}`);return}let G=zO(X),Y=zO(Z);if(G!==Y){$.push(`${W}/Constructor: ${G} vs ${Y}`);return}if(Array.isArray(X)&&Array.isArray(Z)){if(X.length!==Z.length)$.push(`${W}/Array length: ${X.length} vs ${Z.length}`);X.forEach((_,I)=>{P(_,Z[I],`${W}[${I}]`)});return}if(X instanceof Set&&Z instanceof Set){if(X.size!==Z.size)$.push(`${W}/Set size: ${X.size} vs ${Z.size}`);let _=Array.from(Z),I=Array(_.length).fill(!1);for(let c of X){let DO=SQ(_,c,I);if(DO!==-1){I[DO]=!0;continue}let ZO=I.findIndex((_O)=>!_O);if(ZO===-1){$.push(`${W}/Missing value in second set: ${v(c)}`);continue}I[ZO]=!0,$.push(`${W}/Set value difference: ${n(c,_[ZO])??v(c)}`)}for(let c=0;c<_.length;c++)if(!I[c])$.push(`${W}/Unexpected value in second set: ${v(_[c])}`);return}if(X instanceof Map&&Z instanceof Map){if(X.size!==Z.size)$.push(`${W}/Map size: ${X.size} vs ${Z.size}`);let _=Array.from(Z.entries()),I=Array(_.length).fill(!1);for(let[c,DO]of X){let ZO=DQ(_,c,DO,I);if(ZO!==-1){I[ZO]=!0;continue}let _O=F$(_,c,I);if(_O!==-1){I[_O]=!0,P(DO,_[_O][1],`${W}/Map value for key ${v(c)}`);continue}$.push(`${W}/Missing map key in second map: ${v(c)}`)}for(let c=0;c<_.length;c++)if(!I[c])$.push(`${W}/Unexpected map key in second map: ${v(_[c][0])}`);return}if(!UQ(X)&&typeof X.toString==="function"&&typeof Z.toString==="function"){if(X.toString()!==Z.toString())$.push(`${W}/${G}: ${X} vs ${Z}`);return}let q=X,U=Z,S=Object.keys(q),h=Object.keys(U);if(S.length!==h.length)$.push(`${W}/Object keys length: ${S.length} vs ${h.length}`);for(let _ of S)if(!h.includes(_))$.push(`${W}/Missing key in second object: ${_}`);else P(q[_],U[_],`${W}/${_}`)};return P(O,Q),$};function n(O,Q){if(O===Q)return null;if(O instanceof PO.Cell&&Q instanceof PO.Cell){if(!(O.id===Q.id||O?.pointed===Q.id||O.id===Q?.pointed))return`Cell difference: ${O.id} vs ${Q.id}`;return null}if(O instanceof u&&Q instanceof u){let Y=n(O.values,Q.values);if(Y)return`Environment difference: ${Y}`;return null}if(O instanceof F&&Q instanceof F){if(!O.compare("==",Q))return`Rational number difference: ${O} vs ${Q}`;return null}if(typeof O!=="object"||typeof Q!=="object"||O===null||Q===null)return typeof O!==typeof Q?`Type difference: ${typeof O} vs ${typeof Q}`:`Value difference: ${String(O)} vs ${String(Q)}`;let $=zO(O),P=zO(Q);if($!==P)return`Constructor difference: ${$} vs ${P}`;if(Array.isArray(O)&&Array.isArray(Q)){if(O.length!==Q.length)return`Array length difference: ${O.length} vs ${Q.length}`;for(let Y=0;Y<O.length;Y++){let q=n(O[Y],Q[Y]);if(q)return`Array[${Y}] difference: ${q}`}return null}if(O instanceof Set&&Q instanceof Set){if(O.size!==Q.size)return`Set size difference: ${O.size} vs ${Q.size}`;let Y=Array.from(Q),q=Array(Y.length).fill(!1);for(let U of O){let S=SQ(Y,U,q);if(S!==-1){q[S]=!0;continue}let h=q.findIndex((_)=>!_);if(h===-1)return`Missing value in second set: ${v(U)}`;return`Set value difference: ${n(U,Y[h])??v(U)}`}return null}if(O instanceof Map&&Q instanceof Map){if(O.size!==Q.size)return`Map size difference: ${O.size} vs ${Q.size}`;let Y=Array.from(Q.entries()),q=Array(Y.length).fill(!1);for(let[U,S]of O){let h=DQ(Y,U,S,q);if(h!==-1){q[h]=!0;continue}let _=F$(Y,U,q);if(_!==-1){let I=n(S,Y[_][1]);return I?`Map value for key ${v(U)}: ${I}`:`Map entry difference for key ${v(U)}`}return`Missing map key in second map: ${v(U)}`}return null}if(!UQ(O)&&typeof O.toString==="function"&&typeof Q.toString==="function"){if(O.toString()!==Q.toString())return`${$}: ${O} vs ${Q}`;return null}let X=O,Z=Q,W=Object.keys(X),G=Object.keys(Z);if(W.length!==G.length)return`Object keys length difference: ${W.length} vs ${G.length}`;for(let Y of W){if(!G.includes(Y))return`Missing key in second object: ${Y}`;let q=n(X[Y],Z[Y]);if(q)return`Key '${Y}' difference: ${q}`}return null}function i(O,Q){if(O===Q)return!0;if(O instanceof PO.Cell&&Q instanceof PO.Cell)return O.id===Q.id;if(O instanceof u&&Q instanceof u)return i(O.values,Q.values);if(O instanceof F&&Q instanceof F)return O.compare("==",Q);if(typeof O!=="object"||O===null||typeof Q!=="object"||Q===null)return!1;if(Array.isArray(O)&&Array.isArray(Q)){if(O.length!==Q.length)return!1;for(let Z=0;Z<O.length;Z++)if(!i(O[Z],Q[Z]))return!1;return!0}if(O instanceof Set&&Q instanceof Set)return dP(O,Q);if(O instanceof Map&&Q instanceof Map)return lP(O,Q);if(zO(O)!==zO(Q))return!1;if(!UQ(O)&&typeof O.toString==="function"&&typeof Q.toString==="function")return O.toString()===Q.toString();let $=O,P=Q,X=Object.keys($);if(X.length!==Object.keys(P).length)return!1;for(let Z=0;Z<X.length;Z++){let W=X[Z];if(!Object.hasOwn(P,W))return!1;if(!i($[W],P[W]))return!1}return!0}var w$=require("@okcontract/cells"),V$=(O,Q,$,P=Array.prototype.find,X="find",Z)=>{let W=w$.mapArrayCell(O,Q,$,"keep");return O.map([Q,W],(G,Y)=>O.mapNoPrevious(Y,(...q)=>P.call(G,(U,S)=>q[S])),X,Z)};var x=l("number"),UO=l("string"),C=l("boolean"),K$=l("bytes"),vP=(O)=>[...O].map((Q)=>Q.charCodeAt(0).toString(16).padStart(2,"0")).join(""),rP=(O)=>{let Q=L("if");return{f:O.new(($,P,X,Z)=>$.proxy.map([P,X,Z],(W,G,Y)=>W?G:Y,"if"),"$if"),doc:"If statement",t:{vars:[Q.type],type:{kind:R,argTypes:[C,Q,Q],returnType:Q}}}},sP=(O)=>{let Q=L("filter");return{f:O.new(($,P,X)=>SO.filterPredicateCell($.proxy,P,X,"filter"),"$filter"),doc:"Returns a filter for an array",t:{vars:[Q.type],type:{kind:R,argTypes:[{kind:R,argTypes:[Q],returnType:C,label:"filter function"},{kind:j,elementType:Q,label:"value list"}],returnType:{kind:j,elementType:Q,label:"filtered items"}}}}},pP=(O)=>{let Q=L("map"),$=L("map");return{f:O.new((P,X,Z)=>SO.mapArrayCell(P.proxy,Z,X,"map"),"$map"),doc:"Returns a mapped array",t:{vars:[Q.type,$.type],type:{kind:R,argTypes:[{kind:R,argTypes:[Q],returnType:$,label:"map function"},{kind:j,elementType:Q,label:"value list"}],returnType:{kind:j,elementType:$,label:"mapped items"}}}}},J$=(O,Q=Array.prototype.find,$="$find")=>{let P=L("map");return{f:O.new((X,Z,W)=>V$(X.proxy,W,Z,Q,`$${$}`),$),doc:"Returns a mapped array",t:{vars:[P.type],type:{kind:R,argTypes:[{kind:R,argTypes:[P],returnType:C,label:"find function, returns true if an element matches"},{kind:j,elementType:P,label:"value list"}],returnType:P}}}},tP=(O)=>typeof O==="object"&&O!==null&&O.constructor.prototype!==Object.prototype,oP=(O)=>{let Q=L("len");return{f:O.new(($,P)=>$.proxy.map([P],(X)=>new F(Array.isArray(X)?X.length:tP(X)?1:X!==null&&typeof X==="object"?Object.keys(X).length:X!==null&&X!==void 0?1:0),"length"),"$length"),t:{vars:[Q.type],type:N([Q],C)}}},kO=(O,Q,$)=>{return{doc:$,f:O.new((P,X,Z)=>{return P.proxy.map([X,Z],(W,G)=>{switch(Q){case"+":return W.add(G);case"-":return W.subtract(G);case"*":return W.multiply(G);case"/":return W.divide(G);case"^":return W.power(G)}throw Error("unknown operator")},Q)},`(${Q})`),t:{vars:[],type:N([x,x],x)}}},xO=(O,Q,$)=>{let P=L("op");return{doc:$,f:O.new((X,Z,W)=>X.proxy.map([Z,W],(G,Y)=>{if(G instanceof F&&Y instanceof F)return G.compare(Q,Y);let q=G,U=Y;switch(Q){case"<":return q<U;case"<=":return q<=U;case">":return q>U;case">=":return q>=U;case"==":return q===U;case"!=":return q!==U}throw Error("unknown comparator")},Q),`(${Q})`),t:{vars:[P.type],type:N([P,P],C)}}},k$=(O,Q)=>{let $=L("eq");return{doc:`returns ${Q?"false":"true"} if both arguments are equal`,f:O.new((P,X,Z)=>P.proxy.map([X,Z],Q?(W,G)=>!i(W,G):i,Q?"!=":"=="),Q?"(!=)":"(==)"),t:{vars:[$.type],type:N([$,$],C)}}},B$=(O)=>Array.isArray(O)?B$(O[0]):O,NO=(O)=>({$pi:{f:O.new(new F(Math.PI),"π"),t:{vars:[],type:x},doc:"π constant"},"+":kO(O,"+"),"-":kO(O,"-"),"*":kO(O,"*"),"/":kO(O,"/"),"^":kO(O,"^"),"<":xO(O,"<"),"<=":xO(O,"<="),">":xO(O,">"),">=":xO(O,">="),"==":k$(O,!1),"!=":k$(O,!0),if:rP(O),"&&":{f:O.new((Q,$,P)=>Q.proxy.map([$,P],(X,Z)=>X&&Z,"&&"),"(&&)"),t:{vars:[],type:N([C,C],C)}},"||":{f:O.new((Q,$,P)=>Q.proxy.map([$,P],(X,Z)=>X||Z,"||"),"(||)"),t:{vars:[],type:N([C,C],C)}},"!":{f:O.new((Q,$)=>Q.proxy.map([$],(P)=>!P,"!"),"(!)"),t:{vars:[],type:N([C],C)}},$min:{f:O.new((Q,...$)=>Q.proxy.mapNoPrevious($,(...P)=>P[0].min(...P.slice(1)),"min"),"$min"),t:{vars:[],type:N([x],x,x)}},$max:{f:O.new((Q,...$)=>Q.proxy.mapNoPrevious($,(...P)=>P[0].max(...P.slice(1)),"max"),"$max"),t:{vars:[],type:N([x],x,x)}},$last:{f:O.new((Q,$)=>SO.last(Q.proxy,$),"$last"),doc:"return the last element of an array, recursively",t:{vars:["elt"],type:N([GO(p)],p)}},$first:{f:O.new((Q,...$)=>Q.proxy.mapNoPrevious($,(...P)=>B$(P),"first"),"$first"),doc:"Returns the first element in an array, recursively",t:{vars:["elt"],type:N([GO(p)],p)}},$concat:{f:O.new((Q,...$)=>Q.proxy.mapNoPrevious($,(...P)=>P.reduce((X,Z)=>`${X}${String(Z)}`,""))),doc:"Concatenates string representations of any value",t:{vars:[],type:N([],UO,p)}},$filter:sP(O),$map:pP(O),$find:J$(O),$findi:J$(O,Array.prototype.findIndex,"$findi"),$length:oP(O),$floor:{f:O.new((Q,$)=>{return Q.proxy.map([$],(P)=>P.floor(),"floor")},"$floor"),doc:"Returns the floor of a rational number.",t:{vars:[],type:{kind:R,argTypes:[x],returnType:x}}},$json:{f:O.new((Q,$)=>{return Q.proxy.map([$],(P)=>JSON.stringify(P),"json")},"$json"),doc:"Returns the JSON representation of any value",t:{vars:[],type:{kind:R,argTypes:[p],returnType:UO}}},$hex:{f:O.new((Q,$)=>{return Q.proxy.map([$],(P)=>`0x${vP(P)}`,"hex")},"$hex"),doc:"Returns the hex representation of a string (prefixed with 0x)",t:{vars:[],type:{kind:R,argTypes:[UO],returnType:UO}}}}),_Q={name:"Rational",is:(O)=>O instanceof F,type:x},TO=(O,Q=[_Q])=>{for(let P of Q)if(P.is(O))return P.type;let $=typeof O;switch($){case"number":case"bigint":return x;case"string":case"boolean":return l($);case"object":{if(Array.isArray(O))return GO(TO(O[0]));if(O===null)return l("null");return LO(Object.fromEntries(Object.entries(O).map(([X,Z])=>[X,TO(Z)])))}default:throw Error("Unsupported expression type")}};var I$=0,aP=(O)=>hO((Q,$)=>[Q.toLowerCase(),Q],O),nP=(O)=>typeof O.bless==="function";class u{_lib;_values;_types;_originalCases;proxy;initialValues={};initialTypes={true:{vars:[],type:C},false:{vars:[],type:C}};options;get values(){return this._values}constructor(O,Q={}){I$=I$+1,this._lib=Q?.lib||NO(O),this._values=hO(($,P)=>[$.toLowerCase(),P],Q?.values||this.initialValues),this._types=hO(($,P)=>[$.toLowerCase(),P],Q?.types||this.initialTypes),this._originalCases=Q?.cases||aP(Q?.values||this.initialValues),this.proxy=O,this.options=Q}_updateLib(O){this._originalCases={...Object.fromEntries(Object.entries(O).map(([Q,$])=>[Q.toLowerCase(),Q])),...this._originalCases},this._lib=Object.fromEntries(Object.entries(O).map(([Q,$])=>[Q.toLowerCase(),$]))}library=(O)=>this._lib[O.toLowerCase()];value=(O)=>this._values[O.toLowerCase()];type=(O)=>this._types[O.toLowerCase()];case=(O)=>this._originalCases[O.toLowerCase()];infer=vQ(this);eval=s(this);clone=()=>new u(this.proxy,{...this.options,lib:this._lib,values:{...this._values},types:{...this._types},cases:{...this._originalCases},extensions:this.options.extensions});keys=(O=!0)=>[...Object.keys(this._originalCases),...O?Object.keys(this._lib):[]];withValue(O,Q){let $=O.toLowerCase();return new u(this.proxy,{lib:this._lib,values:{...this._values,[$]:Q},types:this._types,cases:{...this._originalCases,[$]:O},extensions:this.options.extensions})}withType(O,Q){let $=O.toLowerCase();return new u(this.proxy,{lib:this._lib,values:this._values,types:{...this._types,[$]:Q},cases:this._originalCases,extensions:this.options.extensions})}addExpression=async(O,Q)=>{if(!O)throw Error("Value must be named");let $=await this.infer(Q),P=this.eval(Q);if(nP(P))P.bless(`eval:${O}`);let X=O.toLowerCase();if(this._types[X]){let Z=this.value(X);if(Z instanceof uO.ValueCell)return P.subscribe((W)=>{Z.set(W)}),!0;return!0}return this.addValueType(O,P,$)};addValueType=(O,Q,$)=>{let P=O.toLowerCase();this._types[P]=$;let X=this._values[P]!==void 0;if(this._values[P]=Q,!this._originalCases[P])this._originalCases[P]=O;return X};removeKey=(O)=>{let Q=O.toLowerCase();delete this._types[Q],delete this._values[Q],delete this._originalCases[Q]};evaluateString=async(O,Q={})=>{let $=await AO(O,this.options.parseOptions);if(Q?.typeCheck)await this.infer($);return this.eval($)};evaluateStringValue=async(O)=>{let Q=await this.evaluateString(O);if(Q instanceof uO.Cell)return Q.get();throw Error(`cannot get value for ${Q}, it's not a cell`)};evaluateStringArray=async(O)=>Promise.all(O.map((Q)=>this.evaluateString(Q)));evaluateStringArrayToValues=async(O)=>{return await Promise.all(O.map((Q)=>this.evaluateStringValue(Q)))};has=(O)=>{let Q=O.toLowerCase();return this.library(Q)!==void 0||this.value(Q)!==void 0};const(O){return this.proxy.new(O,`c:${O}`)}read(O){let Q=O.toLowerCase();return this.library(Q)?.f||this.value(Q)}mergeWith(O,...Q){return new u(this.proxy,{lib:O||this._lib,values:OO([this._values,...Q.map(($)=>$._values)]),types:OO([this._types,...Q.map(($)=>$._types)]),cases:OO([this._originalCases,...Q.map(($)=>$._originalCases)]),extensions:this.options.extensions})}withValueTypes(...O){let Q=Object.fromEntries(O.map(([X,Z,W])=>[X.toLowerCase(),Z])),$=Object.fromEntries(O.map(([X,Z,W])=>[X.toLowerCase(),W])),P=Object.fromEntries(O.map(([X,Z,W])=>[X.toLowerCase(),X]));return new u(this.proxy,{lib:this._lib,values:{...this._values,...Q},types:{...this._types,...$},cases:{...this._originalCases,...P},extensions:this.options.extensions})}valueTypes(){return Object.entries(this._originalCases).map(([O,Q])=>[Q,this._values[O],this._types[O]])}mergeValues(...O){this._values=OO([this._values,...O.map((Q)=>Q._values)]),this._types=OO([this._types,...O.map((Q)=>Q._types)]),this._originalCases=OO([this._originalCases,...O.map((Q)=>Q._originalCases)])}}var FQ={Space:" "},jQ={separator:FQ.Space,spaces:2,trailingCommas:!1,width:80},t=()=>({kind:"concat",parts:[]}),z=(O)=>O.length===0?t():{kind:"text",text:O},D=(O)=>{let Q=[];for(let $ of O){if($.kind==="concat"){Q.push(...$.parts);continue}if($.kind==="text"&&$.text.length===0)continue;Q.push($)}if(Q.length===0)return t();if(Q.length===1)return Q[0];return{kind:"concat",parts:Q}},y=(O)=>({kind:"group",doc:O}),e=(O,Q)=>O===0?Q:{kind:"nest",spaces:O,doc:Q},A={kind:"line",mode:"regular"},bO={kind:"line",mode:"soft"},C$={kind:"line",mode:"hard"},h$=(O,Q=t())=>({kind:"ifBreak",broken:O,flat:Q}),XO=(O,Q)=>{if(Q.length===0)return t();let $=[Q[0]];for(let P=1;P<Q.length;P++)$.push(O,Q[P]);return D($)},wQ=(O={})=>({...jQ,...O}),eP=(O)=>{if(O&&O.length>0)throw Error(`Parse error: ${O}`);throw Error("Parse error.")},g$=(O)=>{if(O.name==="⚠")return O.value;for(let Q of O.children??[]){let $=g$(Q);if($!==void 0)return $}return},VQ=(O)=>{let Q=QO(O,$O.parse(O)),$=g$(Q);if($!==void 0)eP($);return Q},OX=(O,Q)=>Q<O,QX=(O)=>D([z("("),O,z(")")]),r=(O,Q,$)=>OX(Q,$)?QX(O):O,L$=(O)=>{switch(O){case"||":return 10;case"&&":return 20;case"in":case"isa":case"=":case"!=":case"<":case"<=":case">":case">=":return 30;case"+":case"-":return 40;case"*":case"/":case"%":return 50;case"^":return 60;default:return 30}},b=(O)=>{switch(O.name){case"FunctionExpression":case"PairExpression":return 5;case"TernaryExpression":return 8;case"BinaryExpression":{let Q=O.children?.[1]?.value??"";return L$(Q)}case"UnaryExpression":return 70;case"SpreadExpression":return 75;case"InterpolationExpression":return 80;case"FieldExpression":case"SubscriptExpression":case"CallExpression":return 90;default:return 100}},KO=(O,Q,$,P,X)=>{if($.length===0)return D([z(O),z(Q)]);let Z=X.bracketSpacing?A:bO,W=X.trailingCommas&&P.trailingCommas?h$(z(",")):t();return y(D([z(O),e(P.spaces,D([Z,XO(D([z(","),A]),$),W])),Z,z(Q)]))},RQ=(O,Q,$,P,X)=>{let Z=X==="regular"?A:bO;return y(D([z(O),e(P.spaces,D([Z,$])),Z,z(Q)]))},H$=(O,Q,$=0)=>(O.children??[]).map((P)=>E(P,Q,$)),yO=(O,Q)=>{let[$,P]=O.children??[];if(!$||!P)throw Error("Invalid binding");return y(D([z($.value??""),z(" = "),E(P,Q)]))},EQ=(O,Q)=>{let[$,P]=O.children??[];if(!$||!P)throw Error("Invalid named field");return y(D([z($.value??""),z(": "),E(P,Q)]))},$X=(O,Q)=>{let[$]=O.children??[];if(!$)throw Error("Invalid named argument");return EQ($,Q)},PX=(O,Q)=>{let $=O.children??[];if($.length===0)return D([z("("),z(")")]);let P=$.filter((Y)=>Y.name!=="NamedArgument"),X=$.filter((Y)=>Y.name==="NamedArgument"),Z=XO(D([z(","),A]),P.map((Y)=>E(Y,Q))),W=XO(D([z(","),A]),X.map((Y)=>$X(Y,Q))),G=t();if(P.length>0)G=Z;if(X.length>0)G=P.length>0?D([G,z(";"),A,W]):D([z(";"),A,W]);return y(D([z("("),e(Q.spaces,D([bO,G,Q.trailingCommas?h$(z(",")):t()])),bO,z(")")]))},XX=(O,Q)=>{if(O.name==="Identifier")return z(O.value??"");if(O.name!=="ArgumentList")throw Error(`Unsupported function parameter list: ${O.name}`);let $=(O.children??[]).map((P)=>E(P,Q));return KO("(",")",$,Q,{bracketSpacing:!1})},M$=(O,Q)=>XO(A,(O.children??[]).map(($)=>E($,Q))),E=(O,Q,$=0)=>{switch(O.name){case"Identifier":case"BooleanValue":case"Character":case"NumberValue":case"StringValue":case"TripleString":case"CommandString":return z(O.value??"");case"SymbolValue":{let[P]=O.children??[];return D([z(":"),z(P?.value??"")])}case"PrefixedString":{let[P,X]=O.children??[];return D([z(P?.value??""),z(X?.value??"")])}case"InterpolationExpression":{let[P]=O.children??[];if(!P)throw Error("Invalid interpolation expression");if(P.name==="Identifier")return D([z("#"),z(P.value??"")]);return D([z("#("),E(P,Q),z(")")])}case"ParenthesizedExpression":{let[P]=O.children??[];if(!P)return D([z("("),z(")")]);return RQ("(",")",E(P,Q),Q,"soft")}case"TupleExpression":return KO("{","}",H$(O,Q),Q,{bracketSpacing:!0,trailingCommas:!0});case"ArrayExpression":return KO("[","]",H$(O,Q),Q,{bracketSpacing:!1,trailingCommas:!0});case"ObjectExpression":return KO("{","}",(O.children??[]).map((P)=>EQ(P,Q)),Q,{bracketSpacing:!0,trailingCommas:!0});case"NamedField":return EQ(O,Q);case"CallExpression":{let[P,X]=O.children??[];if(!P||!X)throw Error("Invalid call expression");let Z=D([E(P,Q,b(O)),PX(X,Q)]);return r(Z,$,b(O))}case"FieldExpression":{let[P,X]=O.children??[];if(!P||!X)throw Error("Invalid field expression");let Z=D([E(P,Q,b(O)),z("."),X.name==="Identifier"?z(X.value??""):E(X,Q)]);return r(Z,$,b(O))}case"SubscriptExpression":{let[P,...X]=O.children??[];if(!P)throw Error("Invalid subscript expression");let Z=KO("[","]",X.map((G)=>E(G,Q)),Q,{bracketSpacing:!1,trailingCommas:!0}),W=D([E(P,Q,b(O)),Z]);return r(W,$,b(O))}case"UnaryExpression":{let[P,X]=O.children??[];if(!P||!X)throw Error("Invalid unary expression");let Z=b(O);if(P.value!==void 0&&P.name.includes("Operator")){let G=D([z(P.value),E(X,Q,Z)]);return r(G,$,Z)}let W=D([E(P,Q,Z),z(X.value??"")]);return r(W,$,Z)}case"BinaryExpression":{let[P,X,Z]=O.children??[];if(!P||!X||!Z)throw Error("Invalid binary expression");let W=L$(X.value??""),G=y(D([E(P,Q,W),z(` ${X.value??""}`),e(Q.spaces,D([A,E(Z,Q,W+1)]))]));return r(G,$,W)}case"TernaryExpression":{let[P,X,Z]=O.children??[];if(!P||!X||!Z)throw Error("Invalid ternary expression");let W=b(O),G=y(D([E(P,Q,W),z(" ?"),e(Q.spaces,D([A,E(X,Q,W),z(" :"),A,E(Z,Q,W)]))]));return r(G,$,W)}case"FunctionExpression":{let[P,X]=O.children??[];if(!P||!X)throw Error("Invalid function expression");let Z=b(O),W=y(D([XX(P,Q),z(" =>"),e(Q.spaces,D([A,E(X,Q,Z)]))]));return r(W,$,Z)}case"PairExpression":{let[P,X]=O.children??[];if(!P||!X)throw Error("Invalid pair expression");let Z=b(O),W=y(D([E(P,Q,Z),z(" =>"),e(Q.spaces,D([A,E(X,Q,Z)]))]));return r(W,$,Z)}case"SpreadExpression":{let[P]=O.children??[];if(!P)throw Error("Invalid spread expression");let X=b(O),Z=D([E(P,Q,X),z("...")]);return r(Z,$,X)}case"RangeExpression":{let[P,X]=O.children??[];if(!P||!X)throw Error("Invalid range expression");let Z=y(D([E(P,Q,b(O)),z("::"),e(Q.spaces,D([A,E(X,Q,b(O)+1)]))]));return r(Z,$,b(O))}case"ArrayComprehensionExpression":{let[P,...X]=O.children??[];if(!P)throw Error("Invalid array comprehension");return RQ("[","]",D([E(P,Q),z(" "),M$({name:"comprehensionClause",children:X,from:O.from,to:O.to},Q)]),Q,"soft")}case"GeneratorExpression":{let[P,...X]=O.children??[];if(!P)throw Error("Invalid generator expression");return RQ("(",")",D([E(P,Q),z(" "),M$({name:"comprehensionClause",children:X,from:O.from,to:O.to},Q)]),Q,"soft")}case"ForClause":{let P=(O.children??[]).filter((X)=>X.name==="ForBinding");return y(D([z("for "),XO(D([z(","),A]),P.map((X)=>E(X,Q)))]))}case"ForBinding":{let[P,X,Z]=O.children??[];if(!P||!X||!Z)throw Error("Invalid for binding");return y(D([z(P.value??""),z(` ${X.value??""} `),E(Z,Q)]))}case"IfClause":{let[,P]=O.children??[];if(!P)throw Error("Invalid if clause");return y(D([z("if "),E(P,Q)]))}case"SourceFile":return A$(O,Q);case"Program":case"ProgramComponent":case"LetComponent":case"TopLevelDefinition":case"ComponentBinding":return BO(O,Q);default:throw Error(`Unsupported formatter node: ${O.name}`)}},c$=(O,Q)=>{let[$]=O.children??[];if(!$)return t();return BO($,Q)},ZX=(O,Q)=>{let $=O.children??[],P=[],X;for(let G of $){if(G.name==="ComponentBinding")P.push(G);if(G.name==="in"){X=$[$.indexOf(G)+1];break}}if(P.length===0||!X)throw Error("Invalid let component");let[Z,...W]=P;return y(D([z("let "),yO(Z,Q),...W.flatMap((G)=>[A,z("and "),yO(G,Q)]),A,z("in "),E(X,Q)]))},BO=(O,Q)=>{switch(O.name){case"Program":return XO(C$,(O.children??[]).map(($)=>c$($,Q)));case"ProgramComponent":return c$(O,Q);case"LetComponent":return ZX(O,Q);case"TopLevelDefinition":{let[$]=O.children??[];if(!$)throw Error("Invalid top level definition");return yO($,Q)}case"ComponentBinding":return yO(O,Q);default:return E(O,Q)}},A$=(O,Q)=>{let $=O.children??[];if($.length===0)return t();if($.length===1){let[P]=$;if(!P)return t();if(P.name==="Program")return BO(P,Q);return E(P,Q)}return XO(C$,$.map((P)=>P.name==="Program"?BO(P,Q):E(P,Q)))},WX=(O,Q,$)=>{let P=[...Q];while(O>=0&&P.length>0){let X=P.pop();if(!X)break;let{indent:Z,mode:W,doc:G}=X;switch(G.kind){case"text":O-=G.text.length;break;case"concat":for(let Y=G.parts.length-1;Y>=0;Y--)P.push({indent:Z,mode:W,doc:G.parts[Y]});break;case"group":P.push({indent:Z,mode:"flat",doc:G.doc});break;case"nest":P.push({indent:Z+G.spaces,mode:W,doc:G.doc});break;case"line":if(G.mode==="hard")return W==="break";if(W==="break")return!0;if(G.mode==="regular")O-=$.separator.length;break;case"ifBreak":P.push({indent:Z,mode:W,doc:W==="break"?G.broken:G.flat});break}}return O>=0},JQ=(O,Q)=>{let $=[],P=[{indent:0,mode:"break",doc:O}],X=0;while(P.length>0){let Z=P.pop();if(!Z)break;let{indent:W,mode:G,doc:Y}=Z;switch(Y.kind){case"text":$.push(Y.text),X+=Y.text.length;break;case"concat":for(let q=Y.parts.length-1;q>=0;q--)P.push({indent:W,mode:G,doc:Y.parts[q]});break;case"group":{let q={indent:W,mode:"flat",doc:Y.doc};if(WX(Q.width-X,[...P,q],Q))P.push(q);else P.push({indent:W,mode:"break",doc:Y.doc});break}case"nest":P.push({indent:W+Y.spaces,mode:G,doc:Y.doc});break;case"line":if(Y.mode==="hard"||G==="break"){$.push(`
3
+ ${" ".repeat(W)}`),X=W;break}if(Y.mode==="regular")$.push(Q.separator),X+=Q.separator.length;break;case"ifBreak":P.push({indent:W,mode:G,doc:G==="break"?Y.broken:Y.flat});break}}return $.join("")},f$=(O,Q={})=>{let $=wQ(Q),P=VQ(O);return JQ(A$(P,$),$)},x$=(O,Q={})=>{let $=wQ(Q),P=VQ(O),X=P.children?.[0];if(!X||X.name==="Program"||(P.children?.length??0)!==1)throw Error("Expected expression source");return JQ(E(X,$),$)},T$=(O,Q={})=>{let $=wQ(Q),X=VQ(O).children?.find((Z)=>Z.name==="Program");if(!X)throw Error("Expected program definition");return JQ(BO(X,$),$)};var kQ=require("@okcontract/graph");var IO=(O,Q)=>{let $=(P)=>(X)=>{switch(Q(X,P),X.type){case M:{$(P)(X.function);for(let Z of X.params)$(P)(Z);break}case k:break;case w:break;case j:X.elements.forEach($(P));break;case V:Object.values(X.values).forEach($(P));break;case g:if($(P)(X.expr),"sub"in X)$(P)(X.sub);break;case R:{let Z=new Set(P);Z.add(X.parameter),$(Z)(X.body);break}case"named":$(P)(X.value);break;case T:break;case J:X.elements.forEach($(P));break;default:{let Z=X}}};$(new Set)(O)};var mO=(O)=>{let Q=new Set;return IO(O,($,P)=>{switch($.type){case w:if(!P.has($.name))Q.add($.name)}}),Array.from(Q)};var KQ;((W)=>{W.NoFail="noFail";W.LocalEvaluation="local";W.ErrorToFalse="false";W.Sense="sense";W.SkipNotFound="skip";W.FailUndefined="undefined"})(KQ||={});class BQ{_graph;_defs;_components;_options;constructor(O={},Q={}){this._graph=new kQ.Graph,this._defs=O,this._components=[],this._options=Q;for(let $ in O)this._addDef($,O[$])}_resetProgram(O,Q=[]){this._graph=new kQ.Graph,this._defs=O,this._components=Q;for(let $ in O)this._addDef($,O[$]);return this}_addDef(O,Q){let $=O.toLowerCase();this._graph.addNode($);for(let P of mO(Q)){let X=P.toLowerCase();this._graph.addNode(X),this._graph.addEdge($,X)}}set=async(...O)=>{let{defs:Q,components:$}=await this.parseProgramSegments(O);return this._resetProgram(Q,$)};get=(O)=>this._defs[O];get order(){if(!this._defs)return[[],[]];let O=new Set(Object.keys(this._defs)),Q=this._graph.topologicalSort();if(Q===null)throw Error("Program: Cyclic dependencies");return[[...Array.from(O).filter(($)=>!Q.includes($)),...Q.filter(($)=>O.has($))],Q.filter(($)=>!O.has($))]}dependencies=(O,Q)=>{if(!this._defs)return[];let $=new Set,P=new Set,X=(Z)=>{if(P.has(Z))return;if(P.add(Z),this._defs[Z]!==void 0){mO(this._defs[Z]).filter((G)=>Q?!Q.has(G):!0).map((G)=>G.toLowerCase()).forEach(X);return}$.add(Z)};return O.forEach(X),Array.from($)};reduce=async(O)=>{let[Q,$]=this.order,P=[];for(let Z of $)if(!O.has(Z))P.push(Z);if(P.length>0)throw Error(`Unknown ${YO("identifier",P,!1)}: ${P.join(", ")}`);let X=O.clone();for(let Z=0;Z<Q.length;Z++)await X.addExpression(Q[Z],this.get(Q[Z])).catch((W)=>{throw console.log("caught:",{error:W,expr:Q[Z],val:this.get(Q[Z]),defs:this._defs,env:O.keys}),W});return X};partialReduce=async(O)=>{let[Q,$]=this.order,P=[],X=new Set,Z=O.clone();for(let W of Q){let G=mO(this.get(W)).filter((Y)=>!O.has(Y));if(G.length===0)try{await Z.addExpression(W,this.get(W))}catch(Y){console.log("Error during evaluation:",{error:Y,expr:W,val:this.get(W),defs:this._defs,env:O.keys}),P.push(W);for(let q of G)X.add(q)}else{P.push(W);for(let Y of G)X.add(Y)}}return[Z,P,X]};parseProgramSegments=async(O)=>{let $=O.map((Z)=>Z.replace(/^(\s*[$@A-Za-z_][$\w@]*)\s*:(.*)$/s,(W,G,Y)=>`${G} =${Y}`)).join(`
4
+ `),P=await fO($,this._options.parseOptions),X=[...P.definitions,...P.components.flatMap((Z)=>Z.bindings)].map(({name:Z,expr:W})=>[Z,W]);return{defs:Object.fromEntries(X),components:P.components}};get expressions(){return this.order[0].map((O)=>`${O} = ${K(this._defs[O])}`)}get bindings(){return this.order[0].map((O)=>({name:O,expr:this._defs[O]}))}get components(){return this._components}}var N$=require("@okcontract/cells");var GX=(O)=>{let Q=new Set;return IO(O,($,P)=>{if($.type===w){let X=$.name.toLowerCase();if(!P.has(X))Q.add(X)}}),Q},YX=(O)=>{let Q;return IO(O,($)=>{if(Q!==void 0)return;if($.type===T)Q=String($.value??"")}),Q},HO=(O)=>O instanceof N$.Cell,u$=(O)=>(Q)=>{let $=YX(Q);if($!==void 0)throw Error(`parse error: ${$}`);let P=GX(Q),X=[],Z=[],W=[],G=[];for(let S of P){let h=O.value(S);if(h!==void 0){X.push(S),Z.push(h);continue}let _=O.library(S);if(_?.f){W.push(S),G.push(_.f);continue}throw Error(`Undefined variable: ${S}`)}if(Z.length===0&&G.length===0){let S=d(Q,O,{});return O.proxy.new(S,"single-eval:const")}let Y=[...X,...W],q=[...Z,...G];return O.proxy.map.bind(O.proxy)(q,(...S)=>{let h={};for(let _=0;_<Y.length;_++)h[Y[_]]=S[_];return d(Q,O,h)},"single-eval")},d=(O,Q,$)=>{switch(O.type){case k:return O.value;case w:{let P=O.name.toLowerCase();if(Object.hasOwn($,P))return $[P];let X=Q.read(P);if(X===void 0)throw Error(`Undefined variable: ${O.name}`);return X}case M:{let P=d(O.function,Q,$),X=O.params.map((Y)=>d(Y,Q,$));if(typeof P!=="function")throw Error(`Not a function: ${O.function.type}`);if(P?.local===!0)return P(...X);let W=(Y)=>{if(HO(Y))return Y;if(Array.isArray(Y))return Q.proxy.new(Y,"[]");if(Y!==null&&typeof Y==="object")return Q.proxy.new(Y,"{}");return Q.proxy.new(Y)},G=X.map(W);return P(Q,...G)}case j:{let P=O.elements.map((X)=>{let Z=d(X,Q,$);return HO(Z)?Z:Q.proxy.new(Z)});return Q.proxy.new(P,"[]")}case J:{let P=O.elements.map((X)=>{let Z=d(X,Q,$);return HO(Z)?Z:Q.proxy.new(Z)});return Q.proxy.new(P,"{}")}case V:{let P=Object.entries(O.values),Z=P.map(([,W])=>d(W,Q,$)).map((W)=>HO(W)?W:Q.proxy.new(W));return Q.proxy.mapNoPrevious(Z,(...W)=>Object.fromEntries(W.map((G,Y)=>[P[Y][0],G])),"{}")}case g:{let P=d(O.expr,Q,$);if(HO(P)){if("field"in O)return P.map((W)=>W[O.field]);let Z=d(O.sub,Q,$);return P.map((W)=>Array.isArray(W)?W[Z]:W[Z])}if("field"in O)return P[O.field];let X=d(O.sub,Q,$);return Array.isArray(P)?P[X]:P[X]}case R:{let P=O.parameter.toLowerCase(),X=O.body,Z=(W)=>{let G={...$,[P]:W};return d(X,Q,G)};return Z.local=!0,Z}case T:throw Error(`parse error: ${O.value}`);default:{if(O.type==="named")return d(O.value,Q,$);return O}}};
@@ -3,6 +3,8 @@ import type { Tree } from "@lezer/common";
3
3
  export type LowLevelAST = {
4
4
  /** name of Node type */
5
5
  name: string;
6
+ from: number;
7
+ to: number;
6
8
  /** value for terminal Nodes */
7
9
  value?: string;
8
10
  /** children for non-terminal Nodes */
package/dist/parse.d.ts CHANGED
@@ -1,7 +1,21 @@
1
- import type { ASTNode } from "./ast";
2
- import { type ParserExtension } from "./highLevel";
1
+ import type { ASTNode, SourceRange } from "./ast.js";
2
+ import { type ParserExtension } from "./highLevel.js";
3
3
  export declare const reservedKeywords: string[];
4
4
  export type ParseOptions = {
5
5
  ext?: ParserExtension<unknown, string>[];
6
6
  };
7
+ export type ProgramBinding = {
8
+ name: string;
9
+ expr: ASTNode;
10
+ range?: SourceRange;
11
+ };
12
+ export type ProgramComponent = {
13
+ bindings: ProgramBinding[];
14
+ result: ASTNode;
15
+ };
16
+ export type ParsedProgram = {
17
+ components: ProgramComponent[];
18
+ definitions: ProgramBinding[];
19
+ };
7
20
  export declare const parseExpression: (expr: string, options?: ParseOptions) => Promise<ASTNode>;
21
+ export declare const parseProgram: (source: string, options?: ParseOptions) => Promise<ParsedProgram>;
@@ -0,0 +1,7 @@
1
+ export const terminator: ExternalTokenizer;
2
+ export const Identifier: ExternalTokenizer;
3
+ export const tripleStringContent: ExternalTokenizer;
4
+ export const stringContent: ExternalTokenizer;
5
+ export const commandStringContent: ExternalTokenizer;
6
+ export const layoutExtra: ExternalTokenizer;
7
+ import { ExternalTokenizer } from "@lezer/lr";
@@ -0,0 +1,2 @@
1
+ export const parser: LRParser;
2
+ import { LRParser } from "@lezer/lr";
@@ -0,0 +1,37 @@
1
+ export const terminator: 100;
2
+ export const Identifier: 1;
3
+ export const tripleStringContent: 101;
4
+ export const stringContent: 102;
5
+ export const commandStringContent: 103;
6
+ export const immediateParen: 104;
7
+ export const immediateBracket: 105;
8
+ export const immediateDoubleQuote: 106;
9
+ export const immediateBackquote: 107;
10
+ export const immediateDot: 108;
11
+ export const SourceFile: 2;
12
+ export const Program: 3;
13
+ export const ProgramComponent: 4;
14
+ export const LetComponent: 5;
15
+ export const _let: 6;
16
+ export const ComponentBinding: 7;
17
+ export const UnaryOperatorExtra: 10;
18
+ export const PowerOperator: 12;
19
+ export const TimesOperator: 13;
20
+ export const PlusOperator: 14;
21
+ export const _in: 15;
22
+ export const isa: 16;
23
+ export const ComparisonOperator: 17;
24
+ export const OrOperator: 18;
25
+ export const AndOperator: 19;
26
+ export const _for: 48;
27
+ export const _if: 51;
28
+ export const BooleanValue: 53;
29
+ export const Character: 54;
30
+ export const NumberValue: 55;
31
+ export const SymbolValue: 56;
32
+ export const StringValue: 57;
33
+ export const TripleString: 58;
34
+ export const CommandString: 59;
35
+ export const PrefixedString: 60;
36
+ export const and: 76;
37
+ export const TopLevelDefinition: 77;
package/dist/print.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { type ASTNode } from "./ast";
2
- import type { MonoType } from "./types";
1
+ import { type ASTNode } from "./ast.js";
2
+ import type { MonoType } from "./types.js";
3
3
  export declare function prettyPrintType(type: MonoType): string;
4
4
  export declare function prettyPrint(node: ASTNode, parentPrecedence?: number): string;
5
5
  export declare function prettyPrintHTML(node: ASTNode, parentPrecedence?: number): string;