@ds-lang/monaco-editor 0.0.0-stage → 1.1.1
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.
- package/LICENSE +691 -0
- package/README.md +13 -2
- package/dist/THIRD_PARTY_NOTICES.md +77 -0
- package/dist/compiler-worker.js +4 -0
- package/dist/compiler-worker.js.map +7 -0
- package/dist/ds-monaco-editor.js +103 -0
- package/dist/ds-monaco-editor.js.map +7 -0
- package/dist/lsp-worker.js +16 -0
- package/dist/lsp-worker.js.map +7 -0
- package/package.json +56 -4
- package/src/compiler-worker.mjs +5 -0
- package/src/debugger.mjs +472 -0
- package/src/diagnostics.mjs +65 -0
- package/src/ds-language.mjs +102 -0
- package/src/editor.mjs +108 -0
- package/src/index.mjs +10 -0
- package/src/lsp-worker.mjs +6 -0
- package/src/lsp.mjs +248 -0
- package/src/node/ds-lsp.mjs +5 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
var En=Object.defineProperty;var yt=(t,e)=>{for(var n in e)En(t,n,{get:e[n],enumerable:!0})};var Ve={};yt(Ve,{Cache:()=>we,Clock:()=>Re,CompileRefused:()=>q,DsError:()=>$,Engine:()=>Q,EngineEvent:()=>Y,Fact:()=>G,InternalCompilerError:()=>V,JsonText:()=>J,STREAM_EVENT_KINDS:()=>We,compileWasm:()=>qe,open:()=>Wi,runDsc:()=>Ke,status:()=>ye});var ye={};yt(ye,{DS_ERR_ACTION_FAILED:()=>Pn,DS_ERR_BACKEND_ABI_VERSION:()=>mi,DS_ERR_BACKEND_BAD_AGGS:()=>pi,DS_ERR_BACKEND_BAD_MAGIC:()=>ci,DS_ERR_BACKEND_NOT_REGISTERED:()=>ui,DS_ERR_BND_DIALECT_MISMATCH:()=>yi,DS_ERR_BND_DSC_MISMATCH:()=>fi,DS_ERR_BND_INCOMPLETE:()=>_i,DS_ERR_BND_RT_CONFIG_MISMATCH:()=>gi,DS_ERR_BUDGET_EXCEEDED:()=>ri,DS_ERR_CONTRACT_BREACH:()=>hi,DS_ERR_CONTRACT_INVALID:()=>Si,DS_ERR_CONTRACT_MISSING:()=>ki,DS_ERR_CONTRACT_WCET_HALT:()=>bi,DS_ERR_DSC_BAD_MAGIC:()=>qn,DS_ERR_DSC_CAPABILITY_ABSENT:()=>ei,DS_ERR_DSC_DANGLING:()=>Qn,DS_ERR_DSC_DECODE:()=>Jn,DS_ERR_DSC_DECOMPRESS:()=>Zn,DS_ERR_DSC_SEMANTIC:()=>Yn,DS_ERR_DSC_TRUNCATED:()=>Kn,DS_ERR_DSC_VERSION:()=>Vn,DS_ERR_ENCODING:()=>Gn,DS_ERR_ENGINE_HALTED:()=>Nn,DS_ERR_FACT_INVALID:()=>On,DS_ERR_FACT_REF_CONFLICT:()=>Bn,DS_ERR_FN_NOT_FOUND:()=>ii,DS_ERR_FS_DIVERGENCE:()=>wi,DS_ERR_FS_RECORDING_INCOMPLETE:()=>xi,DS_ERR_FS_UNKNOWN_FACT_ID:()=>Ii,DS_ERR_FS_VERSION:()=>Ri,DS_ERR_INTERNAL:()=>Ln,DS_ERR_INVAL:()=>Rn,DS_ERR_IO:()=>Dn,DS_ERR_JSON_LIMIT:()=>jn,DS_ERR_JSON_NONFINITE:()=>$n,DS_ERR_NAN_REJECTED:()=>vn,DS_ERR_NOT_FOUND:()=>$e,DS_ERR_NOT_REPRESENTABLE:()=>Xn,DS_ERR_OOM:()=>wn,DS_ERR_OVERFLOW:()=>xn,DS_ERR_PARSE:()=>Ue,DS_ERR_RETP_INDEX_OOB:()=>ni,DS_ERR_RETP_INVALID:()=>ti,DS_ERR_RTCT_PROFILE_REFUSES_DSRT:()=>Ei,DS_ERR_RT_LIVE:()=>li,DS_ERR_RT_PRECOND:()=>di,DS_ERR_RT_UNSAFE:()=>oi,DS_ERR_SCHEMA_HASH_MISMATCH:()=>Un,DS_ERR_SCHEMA_UNKNOWN:()=>Tn,DS_ERR_SERIES_NO_BACKING:()=>Mn,DS_ERR_SLOT_TYPE_MISMATCH:()=>An,DS_ERR_SLOT_UNKNOWN:()=>Fn,DS_ERR_STATE:()=>Me,DS_ERR_STORAGE_NOT_FOUND:()=>zn,DS_ERR_STORAGE_QUERY_FAILED:()=>Wn,DS_ERR_STORAGE_UNAVAILABLE:()=>Hn,DS_ERR_TIME_RANGE:()=>Cn,DS_ERR_TOKEN_BUDGET:()=>si,DS_ERR_UNSUPPORTED:()=>In,DS_ERR_WM_FULL:()=>ai,DS_OK:()=>bn,STATUS:()=>Li});var bn=0,Rn=-1,wn=-2,$e=-3,Me=-4,xn=-5,In=-7,Ln=-8,Dn=-9,Nn=-10,Ue=-100,Tn=-101,Fn=-103,An=-104,On=-200,Pn=-202,Cn=-205,vn=-216,$n=-217,Mn=-218,Un=-219,Bn=-220,jn=-221,Gn=-222,Xn=-223,Hn=-400,Wn=-401,zn=-402,Kn=-500,qn=-501,Vn=-502,Jn=-503,Yn=-504,Qn=-506,Zn=-507,ei=-514,ti=-601,ni=-602,ii=-604,ri=-605,ai=-606,si=-607,oi=-608,li=-609,di=-610,mi=-620,ci=-621,pi=-622,ui=-623,fi=-700,yi=-701,_i=-703,gi=-704,hi=-710,ki=-711,Si=-712,Ei=-713,bi=-714,Ri=-720,wi=-725,xi=-729,Ii=-730,Li=Object.freeze({DS_OK:0,DS_ERR_INVAL:-1,DS_ERR_OOM:-2,DS_ERR_NOT_FOUND:-3,DS_ERR_STATE:-4,DS_ERR_OVERFLOW:-5,DS_ERR_UNSUPPORTED:-7,DS_ERR_INTERNAL:-8,DS_ERR_IO:-9,DS_ERR_ENGINE_HALTED:-10,DS_ERR_PARSE:-100,DS_ERR_SCHEMA_UNKNOWN:-101,DS_ERR_SLOT_UNKNOWN:-103,DS_ERR_SLOT_TYPE_MISMATCH:-104,DS_ERR_FACT_INVALID:-200,DS_ERR_ACTION_FAILED:-202,DS_ERR_TIME_RANGE:-205,DS_ERR_NAN_REJECTED:-216,DS_ERR_JSON_NONFINITE:-217,DS_ERR_SERIES_NO_BACKING:-218,DS_ERR_SCHEMA_HASH_MISMATCH:-219,DS_ERR_FACT_REF_CONFLICT:-220,DS_ERR_JSON_LIMIT:-221,DS_ERR_ENCODING:-222,DS_ERR_NOT_REPRESENTABLE:-223,DS_ERR_STORAGE_UNAVAILABLE:-400,DS_ERR_STORAGE_QUERY_FAILED:-401,DS_ERR_STORAGE_NOT_FOUND:-402,DS_ERR_DSC_TRUNCATED:-500,DS_ERR_DSC_BAD_MAGIC:-501,DS_ERR_DSC_VERSION:-502,DS_ERR_DSC_DECODE:-503,DS_ERR_DSC_SEMANTIC:-504,DS_ERR_DSC_DANGLING:-506,DS_ERR_DSC_DECOMPRESS:-507,DS_ERR_DSC_CAPABILITY_ABSENT:-514,DS_ERR_RETP_INVALID:-601,DS_ERR_RETP_INDEX_OOB:-602,DS_ERR_FN_NOT_FOUND:-604,DS_ERR_BUDGET_EXCEEDED:-605,DS_ERR_WM_FULL:-606,DS_ERR_TOKEN_BUDGET:-607,DS_ERR_RT_UNSAFE:-608,DS_ERR_RT_LIVE:-609,DS_ERR_RT_PRECOND:-610,DS_ERR_BACKEND_ABI_VERSION:-620,DS_ERR_BACKEND_BAD_MAGIC:-621,DS_ERR_BACKEND_BAD_AGGS:-622,DS_ERR_BACKEND_NOT_REGISTERED:-623,DS_ERR_BND_DSC_MISMATCH:-700,DS_ERR_BND_DIALECT_MISMATCH:-701,DS_ERR_BND_INCOMPLETE:-703,DS_ERR_BND_RT_CONFIG_MISMATCH:-704,DS_ERR_CONTRACT_BREACH:-710,DS_ERR_CONTRACT_MISSING:-711,DS_ERR_CONTRACT_INVALID:-712,DS_ERR_RTCT_PROFILE_REFUSES_DSRT:-713,DS_ERR_CONTRACT_WCET_HALT:-714,DS_ERR_FS_VERSION:-720,DS_ERR_FS_DIVERGENCE:-725,DS_ERR_FS_RECORDING_INCOMPLETE:-729,DS_ERR_FS_UNKNOWN_FACT_ID:-730});var $=class extends Error{constructor(e,n,i){super(n?`ds status ${e}: ${n}`:`ds status ${e}`,i),this.name="DsError",this.status=e,this.detail=n??""}},q=class extends Error{constructor(e,n){super(`${e}: refused by dsc
|
|
2
|
+
${n}`),this.name="CompileRefused",this.file=e,this.diagnostics=n}},V=class extends Error{constructor(e,n){super(`${e}: dsc stopped before it finished (exit 3)${n?`
|
|
3
|
+
${n}`:""}`),this.name="InternalCompilerError",this.file=e,this.reason=n}},J=class{#e;constructor(e){if(typeof e!="string")throw new TypeError("text: want a string of JSON text");this.#e=e}get text(){return this.#e}toString(){return this.#e}},Y=class extends Event{constructor(e,n={}){super(e),Object.assign(this,n)}},ht={fact_assert:!0,fact_retract:!0,fact_modify:!0,rule_fire_begin:!0,rule_fire_end:!0,action_call:!0,action_emit:!0,action_publish:!0,action_cache_set:!0,action_cache_get:!0,action_log:!0,tick:!0,action_cache_delete:!0,rule_lhs_facts:!0,timer_armed:!0,timer_fired:!0,type_error:!0,bounds_error:!0,engine_error:!0,computation_error:!0,pump:!0,unknown:!0},We=Object.freeze(Object.keys(ht)),Ge=null,kt=null,B=null;function ge(){if(Ge===null)throw new Error("@ds-lang/ds: libds is not loaded in this realm; open() it first");return Ge}function St(t,e,n,i){if(B!==null)return B.target!==e||B.entry!==t?Promise.reject(new Error(`@ds-lang/ds: this realm loaded libds as ${B.target} through the ${B.entry} entry, and cannot also load ${e} through the ${t} entry`)):B.api;let r=(async()=>Di(await n(),e,i))(),a={target:e,entry:t,api:r};return B=a,r.catch(()=>{B===a&&(B=null)}),r}function Di(t,e,n){t.init($,(s,l)=>Xe(s,l)),Ge=t,kt=n;let{compile:i,compileFile:r}=n;return Object.freeze({target:e,Engine:Q,Fact:G,JsonText:J,EngineEvent:Y,STREAM_EVENT_KINDS:We,DsError:$,CompileRefused:q,InternalCompilerError:V,status:ye,setUnraisableHook:Ni,compile:i,compileFile:r,fromSource:((s,l)=>Mi(i,s,l)),readAtoms:Pi,messageName:Ci,decodeAnnouncedFactBody:vi,decodeAnnouncedFactBodyHandles:$i})}function Et(t,e){console.error(`@ds-lang/ds: exception ignored in the ${e} callback:`,t)}var Xe=Et;function Ni(t){if(t!==null&&typeof t!="function")throw new TypeError("setUnraisableHook: want a function or null");let e=Xe;return Xe=t??Et,e}var K,ze,G=class t{#e;#t;constructor(e,n){this.#e=e,this.#t=n}static{K=(e,n)=>new t(e,n),ze=e=>e.#t}get id(){return this.#e.factId(this.#t)}get alive(){return this.#e.factAlive(this.#t)}read(){return Fi(this.#e,this.#e.factRead(this.#t))}};function Ti(t,e){return e instanceof Uint8Array?ae(e):e!==null&&typeof e=="object"?K(t,e):e}function he(t,e){let n={};for(let[i,r]of Object.entries(e))n[i]=Ti(t,r);return n}function Fi(t,e){return{schema:e.schema,id:e.id,slots:he(t,e.slots)}}function Ai(t){if(t===null||typeof t!="object"||Array.isArray(t))throw new TypeError("slots: want an object of slot name -> value");let e={};for(let[n,i]of Object.entries(t))e[n]=i instanceof G?ze(i):i;return e}function ae(t){return t.constructor===Uint8Array?t:new Uint8Array(t)}function bt(t){let e={};for(let[n,i]of Object.entries(t))i instanceof Uint8Array?e[n]=ae(i):i===null||typeof i!="object"||i instanceof J?e[n]=i:"json"in i?e[n]=new J(i.json):e[n]={...i,external:ae(i.external)};return e}function Oi(t,e){let n={...e};return"fact"in e&&(n.fact=K(t,e.fact)),"lhsFacts"in e&&(n.lhsFacts=e.lhsFacts.map(i=>K(t,i))),"slots"in e&&(n.slots=he(t,e.slots)),"args"in e&&(n.args=bt(e.args)),"external"in e&&(n.external=ae(e.external)),n}function He(t){if(t instanceof Uint8Array)return ae(t);if(Array.isArray(t)){let e=t;for(let n=0;n<e.length;n++)e[n]=He(e[n]);return t}if(typeof t=="object"){let e=t;for(let[n,i]of Object.entries(e))i!==null&&(e[n]=He(i))}return t}function Be(t,e){if(t!=null&&typeof t!="function")throw new TypeError(`${e}: want a function or null`)}function _t(t){queueMicrotask(()=>{throw t})}var Rt,Re=class t{#e;#t;constructor(e,n){this.#e=e,this.#t=n}static{Rt=(e,n)=>new t(e,n)}get mode(){return this.#e.clockMode(this.#t)}set mode(e){this.#e.clockSetMode(this.#t,e)}get now(){return this.#e.clockNow(this.#t)}get nextDeadline(){return this.#e.clockNextDeadline(this.#t)}set(e){this.#e.clockSet(this.#t,e)}advance(e){this.#e.clockAdvance(this.#t,e)}setWall(e){this.#e.wallClockSet(this.#t,e)}},wt,we=class t{#e;#t;#n;#i=null;constructor(e,n,i){this.#e=e,this.#t=n,this.#n=i}static{wt=(e,n,i)=>new t(e,n,i)}seed(e,n,{ttlNs:i=0n}={}){this.#e.cacheSeed(this.#t,e,n,i)}setCap({keys:e=0n,bytes:n=0n}={}){this.#e.setCacheCap(this.#t,e,n)}get writeThrough(){return this.#i}set writeThrough(e){if(e!==null&&typeof e!="object")throw new TypeError("writeThrough: want { set, delete } or null");this.#n(e),this.#i=e===null?null:Object.freeze({set:e.set??null,delete:e.delete??null})}},xe=class{#e;constructor(e){this.#e=new Map(e)}get size(){return this.#e.size}get(e){return this.#e.get(e)}has(e){return this.#e.has(e)}keys(){return this.#e.keys()}values(){return this.#e.values()}entries(){return this.#e.entries()}forEach(e,n){for(let[i,r]of this.#e)e.call(n,r,i,this)}[Symbol.iterator](){return this.#e[Symbol.iterator]()}};function _e(t){if(t!==null&&typeof t=="object"&&!Object.isFrozen(t)){for(let e of Object.values(t))_e(e);Object.freeze(t)}return t}var je=null,Q=class t extends EventTarget{#e;#t;#n=new Map;#i=null;#m;#c;#r=null;#o=null;#l=null;#d=null;#a=new Map;constructor(e={}){super();let n=ge();this.#e=n,this.#t=je??n.newEngine(e.runId??null,e.tierId??null),je=null,this.#m=Rt(n,this.#t),this.#c=wt(n,this.#t,i=>this.#g(i))}clone(){return je=this.#e.clone(this.#t),new t}recordTo(e){if(this.#i)throw new $(-4,"recordTo: already recording; stopRecording first");let n=null,i;if(typeof e=="function")i=e;else if(typeof e=="string"){let r=kt?.file??null;if(r===null)throw new TypeError("recordTo: a path needs a file system, which this host has none of; give a sink function");this.#e.halted(this.#t);let a=r(e);n=a,i=s=>{a.write(s)}}else throw new TypeError("recordTo: want a path or a sink function");this.#i={sink:i,file:n};try{this.#e.recordTo(this.#t,i)}catch(r){throw this.#i=null,n?.close(),r}}stopRecording(){let e=this.#i;this.#i=null;try{this.#e.stopRecording(this.#t)}finally{e?.file?.close()}}replayStream(e,{maxAtomBytes:n=0}={}){let i=e instanceof Uint8Array?[e]:e;if(i==null||typeof i[Symbol.iterator]!="function")throw new TypeError("replayStream: want a Uint8Array or an iterable of them");this.#s();let r=this.#e.replayBegin(this.#t,n);try{for(let o of i)this.#e.replayFeed(r,o)}catch(o){try{this.#e.replayFinish(r)}catch{}throw this.#s(),o}let a;try{a=this.#e.replayFinish(r)}finally{this.#s()}let{tailBytes:s,...l}=a;if(s>0n)throw new $(-100,`the stream ends inside an atom (${s} bytes of it)`);return l}decodeFactBody(e,n){return he(this.#e,this.#e.decodeFactBody(this.#t,e,n))}get sessionHeader(){let e=this.#e.sessionHeader(this.#t);return{...e,dscHash:e.dscHash===null?null:ae(e.dscHash)}}get runId(){return this.#e.runId(this.#t)}get tierId(){return this.#e.tierId(this.#t)}close(){this.#e.close(this.#t),this.#n.clear(),this.#s(),this.#i?.file?.close(),this.#i=null}[Symbol.dispose](){this.close()}#y(e,n,i){Be(n,e),this.#e.setCallback(this.#t,e,i),this.#n.set(e,i)}addEventListener(e,n,i){n!=null&&this.#_(e),super.addEventListener(e,n,i)}removeEventListener(e,n,i){super.removeEventListener(e,n,i)}#_(e){let n=this.#e;if(Object.hasOwn(ht,e)){if(this.#n.has("stream"))return;let i=r=>{let{kind:a,...s}=Oi(n,r);this.dispatchEvent(new Y(a,s))};n.setCallback(this.#t,"stream",i),this.#n.set("stream",i)}else if((e==="log"||e==="metric")&&!this.#n.has(e)){let i=r=>{this.dispatchEvent(new Y(e,r))};n.setCallback(this.#t,e,i),this.#n.set(e,i)}}#p(e,n){let i=this.#a.get(e);if(i!==void 0&&super.removeEventListener(e,i.listener),this.#a.delete(e),typeof n!="function")return;let r=a=>{n.call(this,a)};this.#a.set(e,{handler:n,listener:r}),this.addEventListener(e,r)}get onlog(){return this.#a.get("log")?.handler??null}set onlog(e){this.#p("log",e)}get onmetric(){return this.#a.get("metric")?.handler??null}set onmetric(e){this.#p("metric",e)}setCallCallback(e){this.#y("call",e,e==null?null:n=>e({...n,args:bt(n.args)}))}#u(e,n=!1){return(...i)=>{try{e(...i)}catch(r){throw n||this.#r===null?_t(r):this.#r.push(r),r}}}get cache(){return this.#c}#g(e){let n=e?.set??null,i=e?.delete??null;Be(n,"writeThrough.set"),Be(i,"writeThrough.delete");let r=n===null?null:this.#u((s,l,o)=>{n.call(e,{key:s,value:l,ttlNs:o})}),a=i===null?null:this.#u((s,l)=>{i.call(e,{key:s,reason:l})});this.#e.setCacheCallbacks(this.#t,r,a),this.#n.set("cacheSet",r),this.#n.set("cacheDelete",a)}#f(e){let n=this.#r,i=[];this.#r=i;try{return e()}catch(r){throw!(r instanceof $)||i.length===0?r:new $(r.status,r.detail,{cause:i.shift()})}finally{this.#r=n;for(let r of i)_t(r)}}loadDsc(e){try{this.#f(()=>this.#e.loadDsc(this.#t,e))}finally{this.#s()}}get schemas(){if(this.#o===null){let e=this.#e,n=this.#t,i=e.schemaCount(n),r=[];for(let a=0;a<i;a++){let s=_e(e.schemaAt(n,a));r.push([s.name,s])}this.#o=new xe(r)}return this.#o}slotToStored(e,n,i){return this.#e.slotConvert(this.#t,e,n,i,!0)}slotFromStored(e,n,i){return this.#e.slotConvert(this.#t,e,n,i,!1)}get rules(){if(this.#l===null){let e=this.#e,n=this.#t,i=e.ruleMetaCount(n),r=[];for(let a=0;a<i;a++){let s=_e(e.ruleMetaAt(n,a));r.push([s.ruleName,s])}this.#l=new xe(r)}return this.#l}get lineSpans(){if(this.#d===null){let e=this.#e,n=this.#t,i=e.lineSpanCount(n),r=[];for(let a=0;a<i;a++)r.push(_e(e.lineSpanAt(n,a)));this.#d=Object.freeze(r)}return this.#d}lineSpan(e){if(!Number.isInteger(e)||e<0||e>4294967295)throw new TypeError(`lineSpan: want a node id, a uint32, not ${e}`);return _e(this.#e.lineSpanFind(this.#t,e))}#s(){this.#o=null,this.#l=null,this.#d=null}assert(e,n){let i=this.#e;return K(i,i.assert(this.#t,e,Ai(n)))}assertExternal(e){let n=e instanceof Uint8Array?e:e?.external;if(!(n instanceof Uint8Array))throw new TypeError("assertExternal: want a Uint8Array or a fact argument");this.#e.assertExternal(this.#t,n)}applyExternalAssert(e){if(!(e instanceof Uint8Array))throw new TypeError("applyExternalAssert: want the atom's body, a Uint8Array");return this.#e.applyExternalAssert(this.#t,e)}retract(e){let n=this.#e;if(e instanceof G){n.retract(this.#t,ze(e));return}let i=n.factById(this.#t,e);if(i===null)throw new $(-3,`retract: no live fact has id ${e}`);n.retract(this.#t,i)}facts({schema:e=null}={}){let n=this.#e;return n.facts(this.#t,e).map(i=>K(n,i))}get factCount(){return this.#e.factCount(this.#t)}get halted(){return this.#e.halted(this.#t)}factById(e){let n=this.#e.factById(this.#t,e);return n===null?null:K(this.#e,n)}memory(){return this.#e.mem(this.#t)}pump(){this.#f(()=>this.#e.pump(this.#t))}get clock(){return this.#m}get platformSignature(){return this.#e.platformSignature(this.#t)}justifiers(e){return this.#e.getJustifiers(this.#t,gt(e))}reteNetwork({ruleFilter:e=null,includeOccupancy:n=!1}={}){return this.#e.reteNetwork(this.#t,e,n)}reteMatchTrace(e){return this.#e.reteMatchTrace(this.#t,gt(e))}refractedActivations(e=null){return this.#e.refractedActivations(this.#t,e)}};typeof Symbol.dispose!="symbol"&&Reflect.deleteProperty(Q.prototype,"undefined");function gt(t){return t instanceof G?t.id:t}function Pi(t,{incremental:e=!1}={}){let n=ge().readAtoms(t,e);for(let i of n.atoms)i.body!==null&&He(i.body);return n}function Ci(t){if(typeof t!="number"||!Number.isInteger(t))throw new TypeError("messageName: want an atom's field number, an integer");if(t<0||t>4294967295)throw new RangeError(`messageName: field number ${t} is outside 0..2^32-1`);return ge().messageName(t)}function vi(t,e){xt("decodeAnnouncedFactBody",t,e);let n=ge();return he(n,n.decodeAnnouncedFactBody(t,e))}function $i(t,e){xt("decodeAnnouncedFactBodyHandles",t,e);let n=ge(),i=n.decodeAnnouncedFactBodyHandles(t,e);return{slots:he(n,i.slots),refs:i.refs}}function xt(t,e,n){if(!Array.isArray(e))throw new TypeError(`${t}: want an array of announced slots`);for(let i of e){if(i===null||typeof i!="object"||typeof i.name!="string")throw new TypeError(`${t}: each slot wants a name, a string`);if(typeof i.kind!="number"||!Number.isInteger(i.kind)||i.kind<0||i.kind>4294967295)throw new TypeError(`${t}: slot ${i.name}'s kind is not a SlotKind number`);if(typeof i.nullable!="boolean")throw new TypeError(`${t}: slot ${i.name}'s nullable is not a boolean`)}if(!(n instanceof Uint8Array))throw new TypeError(`${t}: want a Uint8Array body`)}function Mi(t,e,n){let i=a=>{let s=new Q;try{s.loadDsc(a)}catch(l){throw s.close(),l}return s},r=t(e,n);return r instanceof Uint8Array?i(r):r.then(i)}var ke=t=>t.includes("/")?t.slice(0,t.lastIndexOf("/"))||"/":".",Ui=t=>ke(t).split("/").filter(e=>e!=="."&&e!=="..").join("/")||"/",Bi="/ds_dsc/bin/dsc";async function ji(t){if(t==null)throw new Error("@ds-lang/ds: compiling under wasm needs ds_dsc, passed in as `compiler`");let e=typeof t=="string"||t instanceof URL?await import(String(t)):t,n=typeof e=="function"?e:Reflect.get(e,"default");if(typeof n!="function")throw new TypeError("@ds-lang/ds: `compiler` is not ds_dsc");let i=typeof e=="function"?void 0:Reflect.get(e,"library"),r={};if(i!=null&&typeof i=="object")for(let[a,s]of Object.entries(i)){if(typeof s!="string")throw new TypeError(`@ds-lang/ds: ds_dsc's library entry ${a} is not text`);r[a]=s}return{factory:n,library:r}}function Gi(t){return t!==null&&typeof t=="object"&&Reflect.get(t,"name")==="ExitStatus"&&typeof Reflect.get(t,"status")=="number"}async function Ke(t,e,{stdin:n=new Uint8Array(0),files:i={},wasmBinary:r,wasmModule:a,program:s=Bi}={}){if(!s.startsWith("/"))throw new TypeError(`@ds-lang/ds: \`program\` is ${s}, not an absolute path`);let{factory:l,library:o}=await ji(t),d=`${ke(ke(s))}/share/ds/stdlib`.replace(/^\/\//,"/"),m=[],c=[],f=0;class w extends Error{constructor(E){super(`exit ${E}`),this.status=E}}let M=await l({...r===void 0?{}:{wasmBinary:r},...a===void 0?{}:{instantiateWasm:(b,E)=>(WebAssembly.instantiate(a,b).then(P=>E(P,a)),{})},noInitialRun:!0,thisProgram:s,print:()=>{},printErr:()=>{},quit:(b,E)=>{throw E??new w(b)},preRun:[b=>{b.FS.init(()=>f<n.length?n[f++]:null,E=>{E!==null&&m.push(E&255)},E=>{E!==null&&c.push(E&255)}),b.FS.mkdirTree(ke(s)),b.FS.writeFile(s,new Uint8Array(0));for(let[E,P]of Object.entries(o)){let N=`${d}/${E}`;b.FS.mkdirTree(ke(N)),b.FS.writeFile(N,P)}for(let[E,P]of Object.entries(i))b.FS.mkdirTree(Ui(E)),b.FS.writeFile(E,P)}]}),A=Reflect.get(globalThis,"process"),O=A?.exitCode,D;try{D=M.callMain(e)}catch(b){if(b instanceof w)D=b.status;else if(Gi(b))D=b.status;else throw b}finally{A!==void 0&&(A.exitCode=O)}return{status:D??0,stdout:Uint8Array.from(m),stderr:new TextDecoder().decode(Uint8Array.from(c))}}async function qe(t,e,{file:n="<input>",searchPath:i=[],files:r={},wasmBinary:a,wasmModule:s,program:l}={}){if(typeof e!="string")throw new TypeError("compile: want DS source text");let o=["compile","-","-o","-","--filename",n];for(let c of i)o.push("-L",c);let d=await Ke(t,o,{stdin:new TextEncoder().encode(e),files:r,wasmBinary:a,wasmModule:s,program:l}),m=d.stderr.trim();if(d.status===1)throw new q(n,m);if(d.status===3)throw new V(n,m);if(d.status!==0)throw new Error(`dsc exited ${d.status} on ${n}:
|
|
4
|
+
${m}`);return d.stdout}var Xi="@ds-lang/ds: compiling in a page needs ds_dsc, the wasm compiler: pass it to open() as `compiler`";function Hi(t,e){return{file:null,compile:t===void 0?()=>{throw new Error(Xi)}:(n,i={})=>qe(t,n,{wasmBinary:e,...i}),compileFile:()=>{throw new Error("@ds-lang/ds: compileFile needs a file system; in a page, `compile` the source text")}}}async function It(t,e){if(t==null)throw new TypeError(`@ds-lang/ds: open() needs \`${e}\``);return typeof t=="string"||t instanceof URL?import(String(t)):t}function Ie(t,e){return t!==null&&(typeof t=="object"||typeof t=="function")?Reflect.get(t,e):void 0}async function Wi({glue:t,runtime:e,wasmBinary:n,compiler:i,compilerWasm:r}){return St("browser","wasm",async()=>{let a=await It(t,"glue"),s=typeof a=="function"?a:Ie(a,"default");if(typeof s!="function")throw new TypeError("@ds-lang/ds: `glue` is not ds_wasm.mjs");let l=await It(e,"runtime"),o=Ie(l,"getDefaultContext")??Ie(Ie(l,"default"),"getDefaultContext");if(typeof o!="function")throw new TypeError("@ds-lang/ds: `runtime` is not @emnapi/runtime");return(await s(n===void 0?{}:{wasmBinary:n})).emnapiInit({context:o()})},Hi(i,r))}var Je=new Map([["Module",{type:"mod",fields:[{name:"use",type:"use",kind:"?"},{name:"body",type:"decl",kind:"*"},{name:"comments_end",type:"comment",kind:"*"}],attributes:[]}],["Use",{type:"use",fields:[{name:"dialect",type:"identifier",kind:""},{name:"settings",type:"setting",kind:"*"}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"},{name:"comments_before",type:"comment",kind:"*"},{name:"comment_after",type:"comment",kind:"?"},{name:"blank_lines_before",type:"int",kind:""}]}],["Setting",{type:"setting",fields:[{name:"capability",type:"identifier",kind:""},{name:"value",type:"bool",kind:""}],attributes:[]}],["Import",{type:"decl",fields:[{name:"path",type:"identifier",kind:"*"},{name:"asname",type:"identifier",kind:"?"}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"},{name:"comments_before",type:"comment",kind:"*"},{name:"comment_after",type:"comment",kind:"?"},{name:"blank_lines_before",type:"int",kind:""}]}],["ImportFrom",{type:"decl",fields:[{name:"path",type:"identifier",kind:"*"},{name:"names",type:"alias",kind:"*"}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"},{name:"comments_before",type:"comment",kind:"*"},{name:"comment_after",type:"comment",kind:"?"},{name:"blank_lines_before",type:"int",kind:""}]}],["Schema",{type:"decl",fields:[{name:"name",type:"identifier",kind:""},{name:"scope",type:"scope",kind:"?"},{name:"docstring",type:"string",kind:"?"},{name:"slots",type:"slot",kind:"*"}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"},{name:"comments_before",type:"comment",kind:"*"},{name:"comment_after",type:"comment",kind:"?"},{name:"blank_lines_before",type:"int",kind:""}]}],["Rule",{type:"decl",fields:[{name:"name",type:"identifier",kind:""},{name:"rate",type:"rate",kind:"*"},{name:"docstring",type:"string",kind:"?"},{name:"lhs",type:"lhs",kind:"*"},{name:"lets",type:"let",kind:"*"},{name:"actions",type:"action",kind:"*"},{name:"afters",type:"after",kind:"*"}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"},{name:"comments_before",type:"comment",kind:"*"},{name:"comment_after",type:"comment",kind:"?"},{name:"blank_lines_before",type:"int",kind:""}]}],["Const",{type:"decl",fields:[{name:"name",type:"identifier",kind:""},{name:"annotation",type:"annotation",kind:"?"},{name:"value",type:"expr",kind:""},{name:"colon_form",type:"bool",kind:""}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"},{name:"comments_before",type:"comment",kind:"*"},{name:"comment_after",type:"comment",kind:"?"},{name:"blank_lines_before",type:"int",kind:""}]}],["Series",{type:"decl",fields:[{name:"schema",type:"identifier",kind:"?"},{name:"slot",type:"identifier",kind:""},{name:"options",type:"series_option",kind:"*"},{name:"docstring",type:"string",kind:"?"},{name:"lines",type:"series_line",kind:"*"}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"},{name:"comments_before",type:"comment",kind:"*"},{name:"comment_after",type:"comment",kind:"?"},{name:"blank_lines_before",type:"int",kind:""}]}],["Service",{type:"decl",fields:[{name:"name",type:"identifier",kind:"*"},{name:"docstring",type:"string",kind:"?"},{name:"kwargs",type:"service_kwarg",kind:"*"},{name:"response",type:"service_response",kind:"?"},{name:"hydration",type:"hydration_field",kind:"*"}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"},{name:"comments_before",type:"comment",kind:"*"},{name:"comment_after",type:"comment",kind:"?"},{name:"blank_lines_before",type:"int",kind:""}]}],["UnitDimension",{type:"decl",fields:[{name:"name",type:"identifier",kind:""},{name:"storage",type:"identifier",kind:""},{name:"base",type:"identifier",kind:""}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"},{name:"comments_before",type:"comment",kind:"*"},{name:"comment_after",type:"comment",kind:"?"},{name:"blank_lines_before",type:"int",kind:""}]}],["UnitScalar",{type:"decl",fields:[{name:"name",type:"identifier",kind:""},{name:"storage",type:"identifier",kind:""},{name:"label",type:"string",kind:"?"}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"},{name:"comments_before",type:"comment",kind:"*"},{name:"comment_after",type:"comment",kind:"?"},{name:"blank_lines_before",type:"int",kind:""}]}],["UnitSymbol",{type:"decl",fields:[{name:"symbol",type:"identifier",kind:""},{name:"dimension",type:"identifier",kind:""},{name:"body",type:"unit_body",kind:""},{name:"label",type:"string",kind:"?"},{name:"aliases",type:"identifier",kind:"*"}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"},{name:"comments_before",type:"comment",kind:"*"},{name:"comment_after",type:"comment",kind:"?"},{name:"blank_lines_before",type:"int",kind:""}]}],["UnitFormula",{type:"decl",fields:[{name:"name",type:"identifier",kind:""},{name:"modifiers",type:"formula_modifier",kind:"*"},{name:"lines",type:"formula_line",kind:"*"}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"},{name:"comments_before",type:"comment",kind:"*"},{name:"comment_after",type:"comment",kind:"?"},{name:"blank_lines_before",type:"int",kind:""}]}],["UnitFxPair",{type:"decl",fields:[{name:"name",type:"identifier",kind:""},{name:"from_unit",type:"identifier",kind:""},{name:"to_unit",type:"identifier",kind:""},{name:"via",type:"identifier",kind:""},{name:"where",type:"expr",kind:""},{name:"numerator",type:"identifier",kind:""},{name:"denominator",type:"identifier",kind:""}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"},{name:"comments_before",type:"comment",kind:"*"},{name:"comment_after",type:"comment",kind:"?"},{name:"blank_lines_before",type:"int",kind:""}]}],["Opaque",{type:"decl",fields:[{name:"name",type:"identifier",kind:""},{name:"representation",type:"identifier",kind:""}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"},{name:"comments_before",type:"comment",kind:"*"},{name:"comment_after",type:"comment",kind:"?"},{name:"blank_lines_before",type:"int",kind:""}]}],["Test",{type:"decl",fields:[{name:"name",type:"expr",kind:""},{name:"sections",type:"test_section",kind:"*"}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"},{name:"comments_before",type:"comment",kind:"*"},{name:"comment_after",type:"comment",kind:"?"},{name:"blank_lines_before",type:"int",kind:""}]}],["InitialBlock",{type:"decl",fields:[{name:"items",type:"initial_item",kind:"*"}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"},{name:"comments_before",type:"comment",kind:"*"},{name:"comment_after",type:"comment",kind:"?"},{name:"blank_lines_before",type:"int",kind:""}]}],["Initial",{type:"test_section",fields:[{name:"items",type:"initial_item",kind:"*"}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"},{name:"comments_before",type:"comment",kind:"*"},{name:"comment_after",type:"comment",kind:"?"},{name:"blank_lines_before",type:"int",kind:""}]}],["Inputs",{type:"test_section",fields:[{name:"blocks",type:"at_block",kind:"*"}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"},{name:"comments_before",type:"comment",kind:"*"},{name:"comment_after",type:"comment",kind:"?"},{name:"blank_lines_before",type:"int",kind:""}]}],["Responses",{type:"test_section",fields:[{name:"stubs",type:"stub",kind:"*"}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"},{name:"comments_before",type:"comment",kind:"*"},{name:"comment_after",type:"comment",kind:"?"},{name:"blank_lines_before",type:"int",kind:""}]}],["Produces",{type:"test_section",fields:[{name:"assertions",type:"assertion",kind:"*"}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"},{name:"comments_before",type:"comment",kind:"*"},{name:"comment_after",type:"comment",kind:"?"},{name:"blank_lines_before",type:"int",kind:""}]}],["Until",{type:"test_section",fields:[{name:"when",type:"expr",kind:""}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"},{name:"comments_before",type:"comment",kind:"*"},{name:"comment_after",type:"comment",kind:"?"},{name:"blank_lines_before",type:"int",kind:""}]}],["InitialFact",{type:"initial_item",fields:[{name:"fact",type:"fact",kind:""}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"},{name:"comments_before",type:"comment",kind:"*"},{name:"comment_after",type:"comment",kind:"?"},{name:"blank_lines_before",type:"int",kind:""}]}],["CacheSeed",{type:"initial_item",fields:[{name:"key",type:"expr",kind:""},{name:"value",type:"expr",kind:""}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"},{name:"comments_before",type:"comment",kind:"*"},{name:"comment_after",type:"comment",kind:"?"},{name:"blank_lines_before",type:"int",kind:""}]}],["CacheBlock",{type:"initial_item",fields:[{name:"seeds",type:"seed",kind:"*"}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"},{name:"comments_before",type:"comment",kind:"*"},{name:"comment_after",type:"comment",kind:"?"},{name:"blank_lines_before",type:"int",kind:""}]}],["Seed",{type:"seed",fields:[{name:"key",type:"expr",kind:""},{name:"value",type:"expr",kind:""}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"},{name:"comments_before",type:"comment",kind:"*"},{name:"comment_after",type:"comment",kind:"?"},{name:"blank_lines_before",type:"int",kind:""}]}],["Fact",{type:"fact",fields:[{name:"schema",type:"type_ref",kind:""},{name:"args",type:"keyword",kind:"*"}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"},{name:"comments_before",type:"comment",kind:"*"},{name:"comment_after",type:"comment",kind:"?"},{name:"blank_lines_before",type:"int",kind:""}]}],["At",{type:"at_block",fields:[{name:"when",type:"expr",kind:""},{name:"facts",type:"fact",kind:"*"}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"},{name:"comments_before",type:"comment",kind:"*"},{name:"comment_after",type:"comment",kind:"?"},{name:"blank_lines_before",type:"int",kind:""}]}],["ForCall",{type:"stub",fields:[{name:"library",type:"identifier",kind:"*"},{name:"service",type:"identifier",kind:"*"},{name:"args",type:"keyword",kind:"*"},{name:"correlation",type:"expr",kind:"?"},{name:"after",type:"expr",kind:"?"},{name:"replies",type:"reply",kind:"*"}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"},{name:"comments_before",type:"comment",kind:"*"},{name:"comment_after",type:"comment",kind:"?"},{name:"blank_lines_before",type:"int",kind:""}]}],["Reply",{type:"reply",fields:[{name:"fact",type:"fact",kind:""}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"},{name:"comments_before",type:"comment",kind:"*"},{name:"comment_after",type:"comment",kind:"?"},{name:"blank_lines_before",type:"int",kind:""}]}],["NoResponse",{type:"reply",fields:[],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"},{name:"comments_before",type:"comment",kind:"*"},{name:"comment_after",type:"comment",kind:"?"},{name:"blank_lines_before",type:"int",kind:""}]}],["Assertion",{type:"assertion",fields:[{name:"never",type:"bool",kind:""},{name:"head",type:"test_head",kind:""}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"},{name:"comments_before",type:"comment",kind:"*"},{name:"comment_after",type:"comment",kind:"?"},{name:"blank_lines_before",type:"int",kind:""}]}],["Activated",{type:"test_head",fields:[{name:"rule",type:"identifier",kind:""}],attributes:[]}],["Emitted",{type:"test_head",fields:[{name:"schema",type:"type_ref",kind:""},{name:"args",type:"keyword",kind:"*"},{name:"binding",type:"identifier",kind:"?"},{name:"where",type:"expr",kind:"?"}],attributes:[]}],["Published",{type:"test_head",fields:[{name:"schema",type:"type_ref",kind:""},{name:"args",type:"keyword",kind:"*"},{name:"binding",type:"identifier",kind:"?"},{name:"where",type:"expr",kind:"?"}],attributes:[]}],["Retracted",{type:"test_head",fields:[{name:"schema",type:"type_ref",kind:""},{name:"args",type:"keyword",kind:"*"}],attributes:[]}],["Recorded",{type:"test_head",fields:[{name:"kind",type:"identifier",kind:""}],attributes:[]}],["Called",{type:"test_head",fields:[{name:"library",type:"identifier",kind:"*"},{name:"service",type:"identifier",kind:"*"},{name:"correlation",type:"expr",kind:"?"}],attributes:[]}],["Cached",{type:"test_head",fields:[{name:"key",type:"expr",kind:""},{name:"value",type:"expr",kind:"?"}],attributes:[]}],["CacheDeleted",{type:"test_head",fields:[{name:"key",type:"expr",kind:""}],attributes:[]}],["Logged",{type:"test_head",fields:[{name:"level",type:"log_level",kind:""},{name:"substring",type:"expr",kind:"?"}],attributes:[]}],["WmHas",{type:"test_head",fields:[{name:"schema",type:"type_ref",kind:""},{name:"args",type:"keyword",kind:"*"}],attributes:[]}],["WmCount",{type:"test_head",fields:[{name:"schema",type:"type_ref",kind:""},{name:"count",type:"expr",kind:""}],attributes:[]}],["WmEmpty",{type:"test_head",fields:[],attributes:[]}],["alias",{type:"alias",fields:[{name:"name",type:"identifier",kind:""},{name:"asname",type:"identifier",kind:"?"}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"}]}],["comment",{type:"comment",fields:[{name:"text",type:"string",kind:""}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"blank_lines_before",type:"int",kind:""}]}],["ResponseSchema",{type:"service_response",fields:[{name:"name",type:"identifier",kind:""}],attributes:[]}],["NoServiceResponse",{type:"service_response",fields:[],attributes:[]}],["Explicit",{type:"scope",fields:[],attributes:[]}],["Activation",{type:"scope",fields:[],attributes:[]}],["Logical",{type:"scope",fields:[{name:"ambient",type:"bool",kind:""}],attributes:[]}],["Ttl",{type:"scope",fields:[{name:"duration",type:"expr",kind:""},{name:"ambient",type:"bool",kind:""}],attributes:[]}],["Unprefixed",{type:"scope",fields:[{name:"scope",type:"scope",kind:""}],attributes:[]}],["BareAmbient",{type:"scope",fields:[],attributes:[]}],["Slot",{type:"slot",fields:[{name:"name",type:"identifier",kind:""},{name:"type",type:"identifier",kind:""},{name:"nullable",type:"bool",kind:""},{name:"capacity",type:"expr",kind:"?"},{name:"markers",type:"marker",kind:"*"},{name:"tolerance",type:"expr",kind:"?"},{name:"docstring",type:"string",kind:"?"}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"},{name:"comments_before",type:"comment",kind:"*"},{name:"comment_after",type:"comment",kind:"?"},{name:"blank_lines_before",type:"int",kind:""}]}],["Key",{type:"marker",fields:[],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""}]}],["Mutable",{type:"marker",fields:[],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""}]}],["Sampled",{type:"marker",fields:[],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""}]}],["Retained",{type:"marker",fields:[],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""}]}],["Cooldown",{type:"rate",fields:[{name:"duration",type:"expr",kind:""}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""}]}],["RateKey",{type:"rate",fields:[{name:"paths",type:"expr",kind:"*"}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""}]}],["PatternClause",{type:"lhs",fields:[{name:"pattern",type:"pattern",kind:""}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"},{name:"comments_before",type:"comment",kind:"*"},{name:"comment_after",type:"comment",kind:"?"},{name:"blank_lines_before",type:"int",kind:""}]}],["ThenClause",{type:"lhs",fields:[{name:"step",type:"then_step",kind:""}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"},{name:"comments_before",type:"comment",kind:"*"},{name:"comment_after",type:"comment",kind:"?"},{name:"blank_lines_before",type:"int",kind:""}]}],["Simple",{type:"pattern",fields:[{name:"body",type:"pattern_body",kind:""}],attributes:[]}],["Negated",{type:"pattern",fields:[{name:"body",type:"pattern_body",kind:""},{name:"parenthesised",type:"bool",kind:""}],attributes:[]}],["Sequence",{type:"pattern",fields:[{name:"latest",type:"bool",kind:""},{name:"head",type:"pattern_body",kind:""},{name:"steps",type:"then_step",kind:"*"}],attributes:[]}],["PatternBody",{type:"pattern_body",fields:[{name:"type",type:"type_ref",kind:""},{name:"binding",type:"identifier",kind:"?"},{name:"within",type:"expr",kind:"?"},{name:"where",type:"expr",kind:"?"},{name:"captures",type:"identifier",kind:"*"}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"}]}],["Then",{type:"then_step",fields:[{name:"latest",type:"bool",kind:""},{name:"body",type:"pattern_body",kind:""},{name:"within",type:"expr",kind:""}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"}]}],["TypeName",{type:"type_ref",fields:[{name:"name",type:"identifier",kind:""}],attributes:[]}],["QualifiedType",{type:"type_ref",fields:[{name:"library",type:"identifier",kind:"*"},{name:"name",type:"identifier",kind:""}],attributes:[]}],["Let",{type:"let",fields:[{name:"bindings",type:"let_binding",kind:"*"}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"},{name:"comments_before",type:"comment",kind:"*"},{name:"comment_after",type:"comment",kind:"?"},{name:"blank_lines_before",type:"int",kind:""}]}],["LetName",{type:"let_binding",fields:[{name:"name",type:"identifier",kind:""},{name:"annotation",type:"annotation",kind:"?"},{name:"value",type:"expr",kind:""}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"},{name:"comments_before",type:"comment",kind:"*"},{name:"comment_after",type:"comment",kind:"?"},{name:"blank_lines_before",type:"int",kind:""}]}],["LetCapture",{type:"let_binding",fields:[{name:"names",type:"identifier",kind:"*"},{name:"value",type:"expr",kind:""}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"},{name:"comments_before",type:"comment",kind:"*"},{name:"comment_after",type:"comment",kind:"?"},{name:"blank_lines_before",type:"int",kind:""}]}],["Annotation",{type:"annotation",fields:[{name:"type",type:"identifier",kind:""},{name:"nullable",type:"bool",kind:""}],attributes:[]}],["Log",{type:"action",fields:[{name:"level",type:"log_level",kind:""},{name:"message",type:"expr",kind:""},{name:"args",type:"keyword",kind:"*"}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"},{name:"comments_before",type:"comment",kind:"*"},{name:"comment_after",type:"comment",kind:"?"},{name:"blank_lines_before",type:"int",kind:""}]}],["ServiceCall",{type:"action",fields:[{name:"library",type:"identifier",kind:"*"},{name:"service",type:"identifier",kind:"*"},{name:"args",type:"keyword",kind:"*"},{name:"block",type:"keyword",kind:"*"},{name:"continuations",type:"continuation",kind:"*"},{name:"correlation",type:"expr",kind:"?"}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"},{name:"comments_before",type:"comment",kind:"*"},{name:"comment_after",type:"comment",kind:"?"},{name:"blank_lines_before",type:"int",kind:""}]}],["Emit",{type:"action",fields:[{name:"schema",type:"type_ref",kind:""},{name:"args",type:"keyword",kind:"*"},{name:"block",type:"keyword",kind:"*"}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"},{name:"comments_before",type:"comment",kind:"*"},{name:"comment_after",type:"comment",kind:"?"},{name:"blank_lines_before",type:"int",kind:""}]}],["Publish",{type:"action",fields:[{name:"schema",type:"type_ref",kind:""},{name:"args",type:"keyword",kind:"*"},{name:"block",type:"keyword",kind:"*"}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"},{name:"comments_before",type:"comment",kind:"*"},{name:"comment_after",type:"comment",kind:"?"},{name:"blank_lines_before",type:"int",kind:""}]}],["Cache",{type:"action",fields:[{name:"args",type:"keyword",kind:"*"},{name:"block",type:"keyword",kind:"*"}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"},{name:"comments_before",type:"comment",kind:"*"},{name:"comment_after",type:"comment",kind:"?"},{name:"blank_lines_before",type:"int",kind:""}]}],["CacheDelete",{type:"action",fields:[{name:"args",type:"keyword",kind:"*"},{name:"block",type:"keyword",kind:"*"}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"},{name:"comments_before",type:"comment",kind:"*"},{name:"comment_after",type:"comment",kind:"?"},{name:"blank_lines_before",type:"int",kind:""}]}],["Withdraw",{type:"action",fields:[{name:"binding",type:"identifier",kind:""},{name:"args",type:"keyword",kind:"*"}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"},{name:"comments_before",type:"comment",kind:"*"},{name:"comment_after",type:"comment",kind:"?"},{name:"blank_lines_before",type:"int",kind:""}]}],["LogDebug",{type:"log_level",fields:[],attributes:[]}],["LogInfo",{type:"log_level",fields:[],attributes:[]}],["LogWarning",{type:"log_level",fields:[],attributes:[]}],["LogError",{type:"log_level",fields:[],attributes:[]}],["LogCritical",{type:"log_level",fields:[],attributes:[]}],["LogUnknown",{type:"log_level",fields:[{name:"written",type:"string",kind:""}],attributes:[]}],["keyword",{type:"keyword",fields:[{name:"arg",type:"identifier",kind:""},{name:"value",type:"expr",kind:"?"}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"},{name:"comments_before",type:"comment",kind:"*"},{name:"comment_after",type:"comment",kind:"?"},{name:"blank_lines_before",type:"int",kind:""}]}],["OnResponse",{type:"continuation",fields:[{name:"test",type:"expr",kind:""},{name:"body",type:"action",kind:"*"}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"},{name:"comments_before",type:"comment",kind:"*"},{name:"comment_after",type:"comment",kind:"?"},{name:"blank_lines_before",type:"int",kind:""}]}],["OnTimeout",{type:"continuation",fields:[{name:"duration",type:"expr",kind:""},{name:"body",type:"action",kind:"*"}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"},{name:"comments_before",type:"comment",kind:"*"},{name:"comment_after",type:"comment",kind:"?"},{name:"blank_lines_before",type:"int",kind:""}]}],["OnError",{type:"continuation",fields:[{name:"code",type:"identifier",kind:"*"},{name:"body",type:"action",kind:"*"}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"},{name:"comments_before",type:"comment",kind:"*"},{name:"comment_after",type:"comment",kind:"?"},{name:"blank_lines_before",type:"int",kind:""}]}],["After",{type:"after",fields:[{name:"duration",type:"expr",kind:""},{name:"correlation",type:"expr",kind:"?"},{name:"body",type:"action",kind:"*"},{name:"nested",type:"after",kind:"*"}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"},{name:"comments_before",type:"comment",kind:"*"},{name:"comment_after",type:"comment",kind:"?"},{name:"blank_lines_before",type:"int",kind:""}]}],["Persist",{type:"series_option",fields:[{name:"duration",type:"expr",kind:""}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""}]}],["By",{type:"series_option",fields:[{name:"slot",type:"identifier",kind:"?"}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""}]}],["Capacity",{type:"series_option",fields:[{name:"samples",type:"expr",kind:""}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""}]}],["Nulls",{type:"series_option",fields:[{name:"policy",type:"identifier",kind:""}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""}]}],["SeriesLine",{type:"series_line",fields:[{name:"aggregations",type:"identifier",kind:"*"},{name:"time",type:"time_model",kind:""},{name:"accuracy",type:"accuracy",kind:"?"},{name:"gap",type:"gap_policy",kind:"?"},{name:"asname",type:"identifier",kind:"?"}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"},{name:"comments_before",type:"comment",kind:"*"},{name:"comment_after",type:"comment",kind:"?"},{name:"blank_lines_before",type:"int",kind:""}]}],["AllTime",{type:"time_model",fields:[],attributes:[]}],["Sliding",{type:"time_model",fields:[{name:"window",type:"expr",kind:""}],attributes:[]}],["Tumbling",{type:"time_model",fields:[{name:"window",type:"expr",kind:""}],attributes:[]}],["Sample",{type:"time_model",fields:[{name:"size",type:"expr",kind:""}],attributes:[]}],["Exact",{type:"accuracy",fields:[],attributes:[]}],["Tolerance",{type:"accuracy",fields:[{name:"value",type:"expr",kind:""}],attributes:[]}],["Confidence",{type:"accuracy",fields:[{name:"value",type:"expr",kind:""}],attributes:[]}],["Delta",{type:"accuracy",fields:[{name:"value",type:"expr",kind:""}],attributes:[]}],["BoundDeterministic",{type:"accuracy",fields:[],attributes:[]}],["GapHold",{type:"gap_policy",fields:[],attributes:[]}],["GapZero",{type:"gap_policy",fields:[],attributes:[]}],["GapSkip",{type:"gap_policy",fields:[],attributes:[]}],["ServiceKwarg",{type:"service_kwarg",fields:[{name:"name",type:"identifier",kind:""},{name:"type",type:"identifier",kind:""},{name:"modifiers",type:"kwarg_modifier",kind:"*"}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"},{name:"comments_before",type:"comment",kind:"*"},{name:"comment_after",type:"comment",kind:"?"},{name:"blank_lines_before",type:"int",kind:""}]}],["Default",{type:"kwarg_modifier",fields:[{name:"value",type:"expr",kind:""}],attributes:[]}],["Literal",{type:"kwarg_modifier",fields:[],attributes:[]}],["Required",{type:"kwarg_modifier",fields:[],attributes:[]}],["Hydrates",{type:"hydration_field",fields:[{name:"schemas",type:"identifier",kind:"*"}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"comments_before",type:"comment",kind:"*"},{name:"comment_after",type:"comment",kind:"?"},{name:"blank_lines_before",type:"int",kind:""}]}],["MaxWindow",{type:"hydration_field",fields:[{name:"value",type:"expr",kind:""}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"comments_before",type:"comment",kind:"*"},{name:"comment_after",type:"comment",kind:"?"},{name:"blank_lines_before",type:"int",kind:""}]}],["MaxLimit",{type:"hydration_field",fields:[{name:"value",type:"expr",kind:""}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"comments_before",type:"comment",kind:"*"},{name:"comment_after",type:"comment",kind:"?"},{name:"blank_lines_before",type:"int",kind:""}]}],["FilterFields",{type:"hydration_field",fields:[{name:"fields",type:"filter_field",kind:"*"}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"comments_before",type:"comment",kind:"*"},{name:"comment_after",type:"comment",kind:"?"},{name:"blank_lines_before",type:"int",kind:""}]}],["FilterField",{type:"filter_field",fields:[{name:"name",type:"identifier",kind:""},{name:"ops",type:"cmpop",kind:"*"}],attributes:[]}],["BaseUnit",{type:"unit_body",fields:[],attributes:[]}],["Affine",{type:"unit_body",fields:[{name:"expr",type:"expr",kind:""}],attributes:[]}],["Tier2",{type:"unit_body",fields:[{name:"to_base",type:"expr",kind:""},{name:"from_base",type:"expr",kind:""}],attributes:[]}],["Inverting",{type:"formula_modifier",fields:[],attributes:[]}],["Implicit",{type:"formula_modifier",fields:[],attributes:[]}],["FormulaLine",{type:"formula_line",fields:[{name:"name",type:"identifier",kind:""},{name:"param",type:"identifier",kind:""},{name:"param_type",type:"identifier",kind:""},{name:"returns",type:"identifier",kind:""},{name:"body",type:"expr",kind:""}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"},{name:"comments_before",type:"comment",kind:"*"},{name:"comment_after",type:"comment",kind:"?"},{name:"blank_lines_before",type:"int",kind:""}]}],["BoolOp",{type:"expr",fields:[{name:"op",type:"boolop",kind:""},{name:"values",type:"expr",kind:"*"}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"}]}],["UnaryOp",{type:"expr",fields:[{name:"op",type:"unaryop",kind:""},{name:"operand",type:"expr",kind:""}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"}]}],["BinOp",{type:"expr",fields:[{name:"left",type:"expr",kind:""},{name:"op",type:"operator",kind:""},{name:"right",type:"expr",kind:""}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"}]}],["Compare",{type:"expr",fields:[{name:"left",type:"expr",kind:""},{name:"ops",type:"cmpop",kind:"*"},{name:"comparators",type:"expr",kind:"*"}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"}]}],["Is",{type:"expr",fields:[{name:"operand",type:"expr",kind:""},{name:"negated",type:"bool",kind:""},{name:"subject",type:"is_subject",kind:""}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"}]}],["Match",{type:"expr",fields:[{name:"operand",type:"expr",kind:""},{name:"negated",type:"bool",kind:""},{name:"pattern",type:"string",kind:""},{name:"flags",type:"string",kind:""}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"}]}],["Call",{type:"expr",fields:[{name:"func",type:"expr",kind:""},{name:"args",type:"expr",kind:"*"}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"}]}],["Cast",{type:"expr",fields:[{name:"operand",type:"expr",kind:""},{name:"type",type:"identifier",kind:""},{name:"nullable",type:"bool",kind:""}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"}]}],["Attribute",{type:"expr",fields:[{name:"value",type:"expr",kind:""},{name:"attr",type:"identifier",kind:""}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"}]}],["Subscript",{type:"expr",fields:[{name:"value",type:"expr",kind:""},{name:"index",type:"expr",kind:""}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"}]}],["Name",{type:"expr",fields:[{name:"id",type:"identifier",kind:""}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"}]}],["QualifiedName",{type:"expr",fields:[{name:"library",type:"identifier",kind:"*"},{name:"id",type:"identifier",kind:""}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"}]}],["Constant",{type:"expr",fields:[{name:"value",type:"constant",kind:""},{name:"raw",type:"string",kind:"?"}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"}]}],["Quantity",{type:"expr",fields:[{name:"magnitude",type:"string",kind:""},{name:"unit",type:"string",kind:""},{name:"raw",type:"string",kind:"?"}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"}]}],["JoinedStr",{type:"expr",fields:[{name:"values",type:"expr",kind:"*"},{name:"raw",type:"string",kind:"?"}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"}]}],["FormattedValue",{type:"expr",fields:[{name:"value",type:"expr",kind:""},{name:"format_spec",type:"string",kind:"?"}],attributes:[{name:"lineno",type:"int",kind:""},{name:"col_offset",type:"int",kind:""},{name:"end_lineno",type:"int",kind:"?"},{name:"end_col_offset",type:"int",kind:"?"}]}],["And",{type:"boolop",fields:[],attributes:[]}],["Or",{type:"boolop",fields:[],attributes:[]}],["Add",{type:"operator",fields:[],attributes:[]}],["Sub",{type:"operator",fields:[],attributes:[]}],["Mult",{type:"operator",fields:[],attributes:[]}],["Div",{type:"operator",fields:[],attributes:[]}],["FloorDiv",{type:"operator",fields:[],attributes:[]}],["Mod",{type:"operator",fields:[],attributes:[]}],["Pow",{type:"operator",fields:[],attributes:[]}],["BitOr",{type:"operator",fields:[],attributes:[]}],["BitXor",{type:"operator",fields:[],attributes:[]}],["BitAnd",{type:"operator",fields:[],attributes:[]}],["LShift",{type:"operator",fields:[],attributes:[]}],["RShift",{type:"operator",fields:[],attributes:[]}],["Coalesce",{type:"operator",fields:[],attributes:[]}],["In",{type:"operator",fields:[],attributes:[]}],["Contains",{type:"operator",fields:[],attributes:[]}],["Overlaps",{type:"operator",fields:[],attributes:[]}],["Range",{type:"operator",fields:[],attributes:[]}],["Not",{type:"unaryop",fields:[],attributes:[]}],["UAdd",{type:"unaryop",fields:[],attributes:[]}],["USub",{type:"unaryop",fields:[],attributes:[]}],["Invert",{type:"unaryop",fields:[],attributes:[]}],["Eq",{type:"cmpop",fields:[],attributes:[]}],["NotEq",{type:"cmpop",fields:[],attributes:[]}],["Lt",{type:"cmpop",fields:[],attributes:[]}],["LtE",{type:"cmpop",fields:[],attributes:[]}],["Gt",{type:"cmpop",fields:[],attributes:[]}],["GtE",{type:"cmpop",fields:[],attributes:[]}],["IsNull",{type:"is_subject",fields:[],attributes:[]}],["IsBool",{type:"is_subject",fields:[{name:"value",type:"bool",kind:""}],attributes:[]}],["IsInf",{type:"is_subject",fields:[{name:"negative",type:"bool",kind:""}],attributes:[]}],["IsNaN",{type:"is_subject",fields:[],attributes:[]}],["IsTag",{type:"is_subject",fields:[{name:"tag",type:"identifier",kind:""}],attributes:[]}]]),Lt=new Map([["mod",["Module"]],["use",["Use"]],["setting",["Setting"]],["decl",["Import","ImportFrom","Schema","Rule","Const","Series","Service","UnitDimension","UnitScalar","UnitSymbol","UnitFormula","UnitFxPair","Opaque","Test","InitialBlock"]],["test_section",["Initial","Inputs","Responses","Produces","Until"]],["initial_item",["InitialFact","CacheSeed","CacheBlock"]],["seed",["Seed"]],["fact",["Fact"]],["at_block",["At"]],["stub",["ForCall"]],["reply",["Reply","NoResponse"]],["assertion",["Assertion"]],["test_head",["Activated","Emitted","Published","Retracted","Recorded","Called","Cached","CacheDeleted","Logged","WmHas","WmCount","WmEmpty"]],["alias",["alias"]],["comment",["comment"]],["service_response",["ResponseSchema","NoServiceResponse"]],["scope",["Explicit","Activation","Logical","Ttl","Unprefixed","BareAmbient"]],["slot",["Slot"]],["marker",["Key","Mutable","Sampled","Retained"]],["rate",["Cooldown","RateKey"]],["lhs",["PatternClause","ThenClause"]],["pattern",["Simple","Negated","Sequence"]],["pattern_body",["PatternBody"]],["then_step",["Then"]],["type_ref",["TypeName","QualifiedType"]],["let",["Let"]],["let_binding",["LetName","LetCapture"]],["annotation",["Annotation"]],["action",["Log","ServiceCall","Emit","Publish","Cache","CacheDelete","Withdraw"]],["log_level",["LogDebug","LogInfo","LogWarning","LogError","LogCritical","LogUnknown"]],["keyword",["keyword"]],["continuation",["OnResponse","OnTimeout","OnError"]],["after",["After"]],["series_option",["Persist","By","Capacity","Nulls"]],["series_line",["SeriesLine"]],["time_model",["AllTime","Sliding","Tumbling","Sample"]],["accuracy",["Exact","Tolerance","Confidence","Delta","BoundDeterministic"]],["gap_policy",["GapHold","GapZero","GapSkip"]],["service_kwarg",["ServiceKwarg"]],["kwarg_modifier",["Default","Literal","Required"]],["hydration_field",["Hydrates","MaxWindow","MaxLimit","FilterFields"]],["filter_field",["FilterField"]],["unit_body",["BaseUnit","Affine","Tier2"]],["formula_modifier",["Inverting","Implicit"]],["formula_line",["FormulaLine"]],["expr",["BoolOp","UnaryOp","BinOp","Compare","Is","Match","Call","Cast","Attribute","Subscript","Name","QualifiedName","Constant","Quantity","JoinedStr","FormattedValue"]],["boolop",["And","Or"]],["operator",["Add","Sub","Mult","Div","FloorDiv","Mod","Pow","BitOr","BitXor","BitAnd","LShift","RShift","Coalesce","In","Contains","Overlaps","Range"]],["unaryop",["Not","UAdd","USub","Invert"]],["cmpop",["Eq","NotEq","Lt","LtE","Gt","GtE"]],["is_subject",["IsNull","IsBool","IsInf","IsNaN","IsTag"]]]);var T=class extends Error{constructor(e){super(e),this.name="TreeError"}};function Ye(t){let e=Nt(t,"the root");if(e._type!=="Module")throw new T(`the root is ${e._type}, not Module`);return e}function Nt(t,e){if(t===null||typeof t!="object"||Array.isArray(t))throw new T(`${e} is not a node`);let n=t,i=n._type;if(typeof i!="string")throw new T(`${e} has no _type`);let r=Je.get(i);if(r===void 0)throw new T(`\`${i}\` is not a node in ds.asdl`);let a=[...r.fields,...r.attributes],s=new Set(a.map(d=>d.name)),l=Object.keys(n).filter(d=>d!=="_type"&&!s.has(d)).sort();if(l.length)throw new T(`${i} has no ${l.join(", ")}`);let o=a.filter(d=>!Object.hasOwn(n,d.name)).map(d=>d.name).sort();if(o.length)throw new T(`${i} was written without ${o.join(", ")}`);for(let d of a)zi(n[d.name],d,`${i}.${d.name}`);return t}function zi(t,e,n){if(e.kind==="*"){if(!Array.isArray(t))throw new T(`${n} is not a list`);t.forEach((i,r)=>Dt(i,e.type,`${n}[${r}]`));return}if(t===null){if(e.kind==="?"||e.type==="constant")return;throw new T(`${n} is null, and is required`)}Dt(t,e.type,n)}function Dt(t,e,n){switch(e){case"identifier":case"string":if(typeof t!="string")throw new T(`${n} should be a string`);return;case"int":if(!Number.isInteger(t))throw new T(`${n} should be an int`);return;case"bool":if(typeof t!="boolean")throw new T(`${n} should be a bool`);return;case"constant":if(t!==null&&!["number","string","boolean"].includes(typeof t))throw new T(`${n} should be a constant`);return}let i=Nt(t,n);if(!Lt.get(e)?.includes(i._type))throw new T(`${n} should be ${e}, got ${i._type}`)}function*X(t){yield t;let e=Je.get(t._type),n=t;for(let i of e.fields){if(Ki.has(i.type))continue;let r=n[i.name];if(Array.isArray(r))for(let a of r)yield*X(a);else r!==null&&(yield*X(r))}}var Ki=new Set(["identifier","string","int","bool","constant"]);var Qe=/[\p{L}\p{N}_]/u;function U(t){switch(t._type){case"Schema":case"Rule":case"Const":case"Opaque":case"UnitDimension":case"UnitScalar":case"UnitFormula":case"UnitFxPair":return t.name;case"UnitSymbol":return t.symbol;case"Service":return t.name.join(".");default:return null}}function ee(t){return t.name}function Ze(t,e,n){return e<t.lineno||e===t.lineno&&n<t.col_offset?!1:t.end_lineno===null||t.end_col_offset===null?e===t.lineno:e<t.end_lineno||e===t.end_lineno&&n<=t.end_col_offset}function se(t,e,n){let i=t.body;for(let r=0;r<i.length;r++){let a=i[r];if(e<a.lineno||e===a.lineno&&n<a.col_offset)return null;if(a.end_lineno!==null&&a.end_col_offset!==null){if(Ze(a,e,n))return a;continue}let s=i[r+1];if(s===void 0||e<s.lineno||e===s.lineno&&n<s.col_offset)return a}return null}function te(t){let e=[];for(let n of t){if(n._type==="ThenClause"){e.push(n.step.body);continue}let i=n.pattern;i._type==="Sequence"?e.push(i.head,...i.steps.map(r=>r.body)):e.push(i.body)}return e}function H(t){let e=new Map;for(let n of te(t.lhs))n.binding!==null&&!e.has(n.binding)&&e.set(n.binding,n);return e}function Le(t,e){let n=[...t],i=o=>o>=0&&o<n.length&&Qe.test(n[o]),r=e;if(!i(r)&&i(r-1)&&r--,!i(r))return null;let a=r,s=r;for(;i(a-1);)a--;for(;i(s);)s++;let l=null;if(n[a-1]==="."&&i(a-2)){let o=a-1;for(;i(o-1);)o--;l=n.slice(o,a-1).join("")}return{word:n.slice(a,s).join(""),start:a,end:s,qualifier:l}}function x(t,e,n){let i=[...t[e.lineno-1]??""],r=[...n];for(let a=e.col_offset;a+r.length<=i.length;a++)if(r.every((s,l)=>i[a+l]===s)&&!Qe.test(i[a-1]??"")&&!Qe.test(i[a+r.length]??""))return{line:e.lineno,start:a,end:a+r.length};return{line:e.lineno,start:e.col_offset,end:e.col_offset}}function Ft(t,e){switch(e.kind){case"decl":return x(t,e.decl,e.name);case"binding":return x(t,e.body,e.name);case"slot":return x(t,e.slot,e.slot.name)}}function At(t){if(t===null)return"explicit";switch(t._type){case"Unprefixed":return At(t.scope);case"Explicit":return"explicit";case"Activation":return"activation";case"BareAmbient":return"ambient";case"Logical":return t.ambient?"logical ambient":"logical";case"Ttl":return`ttl ${Se(t.duration)}`+(t.ambient?" ambient":"")}}function Se(t){switch(t._type){case"Quantity":return t.raw??`${t.magnitude}_${t.unit}`;case"Constant":return t.raw??String(t.value);case"Name":return t.id;case"UnaryOp":return t.op._type==="USub"?`-${Se(t.operand)}`:"\u2026";default:return"\u2026"}}function qi(t){switch(t._type){case"Required":return"required";case"Literal":return"literal";case"Default":return`default ${Se(t.value)}`}}function et(t){return[`${t.name}: ${t.type}`,...t.modifiers.map(qi)].join(" ")}function Vi(t,e){let n=[`service ${t}:`,...e.kwargs.map(i=>` kwarg ${et(i)}`)];return e.response!==null&&n.push(e.response._type==="ResponseSchema"?` response ${e.response.name}`:" no response"),n.join(`
|
|
5
|
+
`)}var Ji=t=>t.nullable?`${t.type}?`:t.type,Yi={Key:"key",Mutable:"mutable",Sampled:"sampled",Retained:"retained"};function Ot(t){let e=[Ji(t)];t.capacity!==null&&(e[0]+=` capacity ${Se(t.capacity)}`);for(let n of t.markers)e.push(Yi[n._type]);return t.tolerance!==null&&e.push(`tolerance ${Se(t.tolerance)}`),e.join(" ")}function Pt(t){switch(t.kind){case"slot":return Z(`${t.slot.name}: ${Ot(t.slot)} # in ${t.schema.name}`,t.slot.docstring);case"binding":return Z(`${t.name}: ${t.schema?.name??ee(t.body.type)} # a pattern binding`,null,t.schema===null?"":Tt(t.schema));case"decl":{let e=t.decl;if(e._type==="Schema")return Z(Tt(e),e.docstring);if(e._type==="Rule"){let n=te(e.lhs).map(i=>` ${ee(i.type)}${i.binding===null?"":" "+i.binding}`);return Z([`rule ${e.name}:`,...n].join(`
|
|
6
|
+
`),e.docstring)}if(e._type==="Const"){let n=e.value,i=n._type==="Constant"||n._type==="Quantity"?n.raw:null;return Z(`const ${e.name}${i===null?"":" = "+i}`,null)}return e._type==="Service"?Z(Vi(t.name,e),e.docstring):Z(`${t.name} # ${e._type}`,null)}}}function Tt(t){return[`schema ${t.name} scope ${At(t.scope)}:`,...t.slots.map(e=>` ${e.name}: ${Ot(e)}`)].join(`
|
|
7
|
+
`)}function Z(t,e,n=""){let i=["```ds\n"+t+"\n```"];return n&&i.push("```ds\n"+n+"\n```"),e&&i.push(e),i.join(`
|
|
8
|
+
|
|
9
|
+
`)}function Ct(t,e,n){let i=Zi(t.path===null?e:[Qi(t.path),...e]),r=new Map,a=new Map,s=d=>{for(let m of d.tree.body){if(m._type!=="Import"&&m._type!=="ImportFrom")continue;let c=l(m.path);if(c!==null)if(m._type==="Import")d.modules.set(m.asname??m.path.join("."),c);else for(let f of m.names)d.bare.set(f.asname??f.name,{unit:c,name:f.name})}},l=d=>{let m=d.join("."),c=a.get(m);if(c!==void 0)return c;let f=[];for(let b of i){let E=[b,...d].join("/")+".ds",P=r.has(E)?"":n.read(E);P!==null&&f.push({path:E,text:P})}if(a.set(m,null),f.length!==1)return null;let[{path:w,text:M}]=f,A=r.get(w);if(A!==void 0)return a.set(m,A),A;let O=n.tree(M,w);if(O===null)return null;let D={uri:n.uri(w),path:w,lines:M.split(/\r\n|\n|\r/),tree:O,modules:new Map,bare:new Map};return r.set(w,D),a.set(m,D),s(D),D},o={...t,modules:new Map,bare:new Map};return t.path!==null&&r.set(t.path,o),s(o),o}var Qi=t=>t.slice(0,Math.max(0,t.lastIndexOf("/")))||"/";function Zi(t){let e=new Set,n=[];for(let i of t){let r=i.length>1?i.replace(/\/+$/,""):i;e.has(r)||(e.add(r),n.push(r))}return n}function De(t){let e=[],n=new Set,i=r=>{if(!n.has(r)){n.add(r),e.push(r);for(let a of r.modules.values())i(a);for(let a of r.bare.values())i(a.unit)}};return i(t),e}function tt(t,e){for(let i of t.tree.body)if(U(i)===e)return{unit:t,decl:i};let n=t.bare.get(e);if(n===void 0)return null;for(let i of n.unit.tree.body)if(U(i)===n.name)return{unit:n.unit,decl:i};return null}function oe(t,e){if(e._type==="TypeName")return tt(t,e.name);let n=t.modules.get(e.library.join("."));if(n===void 0)return null;for(let i of n.tree.body)if(U(i)===e.name)return{unit:n,decl:i};return null}function nt(t,e){let n=oe(t,e);return n!==null&&n.decl._type==="Schema"?{unit:n.unit,schema:n.decl}:null}function Ne(t){let e=new Map;for(let n of De(t))for(let i of n.tree.body)i._type==="Service"&&!e.has(i.name.join("."))&&e.set(i.name.join("."),{unit:n,decl:i});return e}function vt(t,e,n){let i=se(t.tree,e,n);if(i?._type!=="Rule")return null;for(let r of X(i)){if(r._type!=="ServiceCall"||r.lineno!==e)continue;let a=r.service.join("."),s=x(t.lines,r,a);if(s.end>s.start&&n>=s.start&&n<=s.end)return a}return null}function $t(t){switch(t.kind){case"decl":return{unit:t.unit,t:{kind:"decl",decl:t.decl,name:t.name}};case"slot":return{unit:t.unit,t:{kind:"slot",schema:t.schema,slot:t.slot}};case"binding":{let e=H(t.rule).get(t.name);if(e===void 0)return null;let n=nt(t.unit,e.type)?.schema??null;return{unit:t.unit,t:{kind:"binding",name:t.name,body:e,schema:n}}}}}function Ee(t,e,n){let i=Le(t.lines[e-1]??"",n);if(i===null)return null;let r=se(t.tree,e,n);if(r?._type==="Rule"){let s=H(r);if(i.qualifier!==null){let l=s.get(i.qualifier);if(l!==void 0){let d=oe(t,l.type),m=d?.decl._type==="Schema"?d.decl.slots.find(c=>c.name===i.word):void 0;return d&&m&&d.decl._type==="Schema"?{kind:"slot",unit:d.unit,schema:d.decl,slot:m}:null}let o=t.modules.get(i.qualifier);if(o===void 0)return null;for(let d of o.tree.body)if(U(d)===i.word)return{kind:"decl",unit:o,decl:d,name:i.word};return null}if(s.has(i.word))return{kind:"binding",unit:t,rule:r,name:i.word};for(let l of X(r))if((l._type==="Emit"||l._type==="Publish")&&Ze(l,e,n)&&[...l.args,...l.block].some(o=>o.arg===i.word&&o.lineno===e)){let o=oe(t,l.schema),d=o?.decl._type==="Schema"?o.decl.slots.find(m=>m.name===i.word):void 0;if(o&&d&&o.decl._type==="Schema")return{kind:"slot",unit:o.unit,schema:o.decl,slot:d}}}if(r?._type==="Schema"){let s=r.slots.find(l=>l.lineno===e&&l.name===i.word);if(s)return{kind:"slot",unit:t,schema:r,slot:s}}let a=tt(t,i.word);return a===null?null:{kind:"decl",unit:a.unit,decl:a.decl,name:U(a.decl)??i.word}}function Mt(t,e){let n=[],i=(r,a,s=!1)=>n.push({unit:r,range:a,declaration:s});if(e.kind==="binding")return er(e,i),n;e.kind==="decl"?i(e.unit,x(e.unit.lines,e.decl,e.name),!0):i(e.unit,x(e.unit.lines,e.slot,e.slot.name),!0);for(let r of De(t))e.kind==="decl"?tr(r,e,i):nr(r,e,i);return n}function er(t,e){let{unit:n,rule:i,name:r}=t;for(let a of te(i.lhs))a.binding===r&&e(n,ir(n.lines,a,ee(a.type),r),!0);for(let a of X(i))a._type==="Name"&&a.id===r&&e(n,Ut(a,r))}function tr(t,e,n){let i=r=>r!==null&&r.decl===e.decl;for(let r of t.tree.body){if(r._type==="ImportFrom")for(let s of r.names)s.name===e.name&&t.bare.get(s.asname??s.name)?.unit===e.unit&&n(t,x(t.lines,s,s.name));if(r._type!=="Rule")continue;let a=H(r);for(let s of te(r.lhs))s.type.name===e.name&&i(oe(t,s.type))&&n(t,x(t.lines,s,e.name));for(let s of X(r))(s._type==="Emit"||s._type==="Publish")&&s.schema.name===e.name&&i(oe(t,s.schema))?n(t,x(t.lines,s,e.name)):s._type==="Name"&&s.id===e.name&&!a.has(s.id)&&i(tt(t,s.id))?n(t,Ut(s,s.id)):s._type==="Attribute"&&s.attr===e.name&&s.value._type==="Name"&&t.modules.get(s.value.id)===e.unit&&!a.has(s.value.id)&&n(t,Bt(t.lines,s))}}function nr(t,e,n){let i=r=>oe(t,r)?.decl===e.schema;for(let r of t.tree.body){if(r._type!=="Rule")continue;let a=new Set;for(let[s,l]of H(r))i(l.type)&&a.add(s);for(let s of X(r))if(s._type==="Attribute"&&s.attr===e.slot.name&&s.value._type==="Name"&&a.has(s.value.id))n(t,Bt(t.lines,s));else if((s._type==="Emit"||s._type==="Publish")&&i(s.schema))for(let l of[...s.args,...s.block])l.arg===e.slot.name&&n(t,x(t.lines,l,l.arg))}}function Ut(t,e){return{line:t.lineno,start:t.col_offset,end:t.col_offset+[...e].length}}function Bt(t,e){let n=e.value,i=n._type==="Name"&&n.lineno===e.lineno?n.col_offset+[...n.id].length:e.col_offset;return x(t,{lineno:e.lineno,col_offset:i},e.attr)}function ir(t,e,n,i){let r=x(t,e,n);return x(t,{lineno:e.lineno,col_offset:r.end},i)}var C=Object.freeze({declaration:Object.freeze(["const","from","import","opaque","rule","schema","series","service","test","unit","use"]),action:Object.freeze(["cache","cache_delete","call","emit","log","publish","withdraw"]),clause:Object.freeze(["activated","activation","after","alias","all_time","ambient","as","at","base","by","cache_deleted","cached","called","capacity","cooldown","count","default","dimension","emitted","empty","error","explicit","field","filter_fields","for","formula","from_base","fx_pair","gap","has","hold","hydrates","hydration","implicit","initial","inputs","inverting","key","kwarg","latest","let","literal","logged","logical","max_limit","max_window","mutable","never","no","none","on","over","persist","produces","published","recorded","required","response","responses","retained","retracted","sample","sampled","scalar","scope","skip","sliding","storage","then","timeout","to","to_base","tolerance","ttl","tumbling","type","until","via","where","within","wm","zero"]),operator:Object.freeze(["and","contains","in","is","not","or","overlaps"]),constant:Object.freeze(["NaN","false","inf","nan","null","true"])}),Te=Object.freeze(["active_fraction","bool_and","bool_or","count_distinct","count_of","direction","dwell","first","integral","last","max","mean","median","min","onset_rate","pstdev","pvariance","rate","stdev","sum","variance"]),le=Object.freeze([{name:"abs",arities:[1],tier:"pure",signatures:["(x: Int) \u2192 Int","(x: Float) \u2192 Float"],summary:"Absolute value, of the argument's type.",defined:[{id:"LEXP.3.2",page:"language/EXPRESSIONS.html#lexp-3-2"}]},{name:"cached",arities:[1],tier:"sync-impure",signatures:["(key: String) \u2192 String?"],summary:"The cache's value for the key, as JSON text; null on a miss.",defined:[{id:"LSTO.4.3.1",page:"language/STORAGE.html#lsto-4-3-1"}]},{name:"calendar.date",arities:[3],tier:"pure",signatures:["(year: Int, month: Int, day: Int) \u2192 Date"],summary:"The Date of that calendar day.",defined:[{id:"LTIM.14.1",page:"language/TIME.html#ltim-14-1"}]},{name:"calendar.time",arities:[3,6,7],tier:"pure",signatures:["(year, month, day: Int) \u2192 Time","(year, month, day, hour, minute, second: Int) \u2192 Time","(year, month, day, hour, minute, second, nanosecond: Int) \u2192 Time"],summary:"The UTC instant of that calendar day and wall-clock time.",defined:[{id:"LTIM.14.1",page:"language/TIME.html#ltim-14-1"}]},{name:"contains",arities:[2],tier:"pure",signatures:["(cursor, value: T) \u2192 Bool"],summary:"Whether the value is among the series' samples in its window.",defined:[{id:"LSER.16.7.1",page:"language/SERIES.html#lser-16-7-1"}]},{name:"count",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Int"],summary:"Number of samples in the series' window.",defined:[{id:"LSER.16.2",page:"language/SERIES.html#lser-16-2"}]},{name:"count_distinct",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Int"],summary:"Number of distinct sample values in the series' window.",defined:[{id:"LSER.16.5.1",page:"language/SERIES.html#lser-16-5-1"}]},{name:"count_of",arities:[2],tier:"pure",signatures:["(cursor, value: T) \u2192 Int"],summary:"Number of samples in the series' window equal to the value.",defined:[{id:"LSER.16.6.1",page:"language/SERIES.html#lser-16-6-1"}]},{name:"direction",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Int?"],summary:"Sign of the difference of the two newest samples: \u22121, 0 or 1.",defined:[{id:"LSER.16.9",page:"language/SERIES.html#lser-16-9"}]},{name:"distance.chebyshev",arities:[4,6],tier:"pure",signatures:["(x1, y1, x2, y2: Float) \u2192 Float","(x1, y1, z1, x2, y2, z2: Float) \u2192 Float"],summary:"L\u221E (chessboard) distance between two points, 2D or 3D.",defined:[{id:"LEXP.5.3.1",page:"language/EXPRESSIONS.html#lexp-5-3-1"}]},{name:"distance.cosine",arities:[4,6],tier:"pure",signatures:["(ax, ay, bx, by: Float) \u2192 Float","(ax, ay, az, bx, by, bz: Float) \u2192 Float"],summary:"Cosine distance, 1 \u2212 cos \u03B8, between two vectors, in [0, 2].",defined:[{id:"LEXP.5.7.1",page:"language/EXPRESSIONS.html#lexp-5-7-1"}]},{name:"distance.euclidean",arities:[4,6],tier:"pure",signatures:["(x1, y1, x2, y2: Float) \u2192 Float","(x1, y1, z1, x2, y2, z2: Float) \u2192 Float"],summary:"L\u2082 distance between two points, 2D or 3D.",defined:[{id:"LEXP.5.3.1",page:"language/EXPRESSIONS.html#lexp-5-3-1"}]},{name:"distance.great_circle",arities:[4],tier:"pure",signatures:["(lat1, lon1, lat2, lon2: Float) \u2192 meter"],summary:"Distance along the Earth's surface between two points given in degrees.",defined:[{id:"LEXP.5.11.1",page:"language/EXPRESSIONS.html#lexp-5-11-1"}]},{name:"distance.hypotenuse",arities:[2,3],tier:"pure",signatures:["(x, y: Float) \u2192 Float","(x, y, z: Float) \u2192 Float"],summary:"Length of a vector from the origin, 2D or 3D.",defined:[{id:"LEXP.5.5",page:"language/EXPRESSIONS.html#lexp-5-5"}]},{name:"distance.manhattan",arities:[4,6],tier:"pure",signatures:["(x1, y1, x2, y2: Float) \u2192 Float","(x1, y1, z1, x2, y2, z2: Float) \u2192 Float"],summary:"L\u2081 (taxicab) distance between two points, 2D or 3D.",defined:[{id:"LEXP.5.3.1",page:"language/EXPRESSIONS.html#lexp-5-3-1"}]},{name:"has",arities:[1],tier:"pure",signatures:["(path: Json path) \u2192 Bool"],summary:"Whether the Json path resolves.",defined:[{id:"LEXP.6.1",page:"language/EXPRESSIONS.html#lexp-6-1"}]},{name:"len",arities:[1],tier:"pure",signatures:["(j: Json) \u2192 Int","(s: String) \u2192 Int","(b: Bytes) \u2192 Int"],summary:"A Json array's length, a String's code points, or a Bytes value's bytes.",defined:[{id:"LEXP.6.1",page:"language/EXPRESSIONS.html#lexp-6-1"},{id:"LSTR.2.1",page:"language/STRINGS.html#lstr-2-1"},{id:"LSTR.4.2",page:"language/STRINGS.html#lstr-4-2"}]},{name:"math.acos",arities:[1],tier:"pure",signatures:["(x: Float) \u2192 Float"],summary:"Inverse cosine, in radians.",defined:[{id:"LEXP.3.9.1",page:"language/EXPRESSIONS.html#lexp-3-9-1"}]},{name:"math.asin",arities:[1],tier:"pure",signatures:["(x: Float) \u2192 Float"],summary:"Inverse sine, in radians.",defined:[{id:"LEXP.3.9.1",page:"language/EXPRESSIONS.html#lexp-3-9-1"}]},{name:"math.atan",arities:[1],tier:"pure",signatures:["(x: Float) \u2192 Float"],summary:"Inverse tangent, in radians.",defined:[{id:"LEXP.3.9.1",page:"language/EXPRESSIONS.html#lexp-3-9-1"}]},{name:"math.atan2",arities:[2],tier:"pure",signatures:["(y: Float, x: Float) \u2192 Float"],summary:"Angle of the point (x, y) from the positive x axis, in radians, in [\u2212\u03C0, \u03C0].",defined:[{id:"LEXP.3.9.1",page:"language/EXPRESSIONS.html#lexp-3-9-1"}]},{name:"math.ceil",arities:[1],tier:"pure",signatures:["(x: Int) \u2192 Int","(x: Float) \u2192 Int","(x: <unit>) \u2192 <unit>"],summary:"Smallest integer not less than x; a Float with no Int answer traps.",defined:[{id:"LEXP.3.2",page:"language/EXPRESSIONS.html#lexp-3-2"}]},{name:"math.cos",arities:[1],tier:"pure",signatures:["(x: Float) \u2192 Float"],summary:"Cosine of x radians.",defined:[{id:"LEXP.3.9.1",page:"language/EXPRESSIONS.html#lexp-3-9-1"}]},{name:"math.cosh",arities:[1],tier:"pure",signatures:["(x: Float) \u2192 Float"],summary:"Hyperbolic cosine.",defined:[{id:"LEXP.3.9.1",page:"language/EXPRESSIONS.html#lexp-3-9-1"}]},{name:"math.degrees",arities:[1],tier:"pure",signatures:["(x: Float) \u2192 Float"],summary:"Radians to degrees.",defined:[{id:"LEXP.3.6.1",page:"language/EXPRESSIONS.html#lexp-3-6-1"}]},{name:"math.exp",arities:[1],tier:"pure",signatures:["(x: Float) \u2192 Float"],summary:"e to the power x.",defined:[{id:"LEXP.3.9.1",page:"language/EXPRESSIONS.html#lexp-3-9-1"}]},{name:"math.floor",arities:[1],tier:"pure",signatures:["(x: Int) \u2192 Int","(x: Float) \u2192 Int","(x: <unit>) \u2192 <unit>"],summary:"Largest integer not greater than x; a Float with no Int answer traps.",defined:[{id:"LEXP.3.2",page:"language/EXPRESSIONS.html#lexp-3-2"}]},{name:"math.fma",arities:[3],tier:"pure",signatures:["(x: Float, y: Float, z: Float) \u2192 Float"],summary:"x \xD7 y + z, rounded once.",defined:[{id:"LEXP.3.2.2",page:"language/EXPRESSIONS.html#lexp-3-2-2"}]},{name:"math.ln",arities:[1],tier:"pure",signatures:["(x: Float) \u2192 Float"],summary:"Natural logarithm.",defined:[{id:"LEXP.3.9.1",page:"language/EXPRESSIONS.html#lexp-3-9-1"}]},{name:"math.log10",arities:[1],tier:"pure",signatures:["(x: Float) \u2192 Float"],summary:"Base-10 logarithm.",defined:[{id:"LEXP.3.9.1",page:"language/EXPRESSIONS.html#lexp-3-9-1"}]},{name:"math.log2",arities:[1],tier:"pure",signatures:["(x: Float) \u2192 Float"],summary:"Base-2 logarithm.",defined:[{id:"LEXP.3.9.1",page:"language/EXPRESSIONS.html#lexp-3-9-1"}]},{name:"math.pow",arities:[2],tier:"pure",signatures:["(x: Int, y: Int) \u2192 Int","(x: Float, y: Float) \u2192 Float"],summary:"x to the power y; an Int only for an Int base and a statically non-negative Int exponent.",defined:[{id:"LEXP.3.2",page:"language/EXPRESSIONS.html#lexp-3-2"}]},{name:"math.radians",arities:[1],tier:"pure",signatures:["(x: Float) \u2192 Float"],summary:"Degrees to radians.",defined:[{id:"LEXP.3.6.1",page:"language/EXPRESSIONS.html#lexp-3-6-1"}]},{name:"math.sign",arities:[1],tier:"pure",signatures:["(x: Int) \u2192 Int","(x: Float) \u2192 Int","(x: <unit>) \u2192 Int"],summary:"1 when x > 0, \u22121 when x < 0, else 0.",defined:[{id:"LEXP.3.2",page:"language/EXPRESSIONS.html#lexp-3-2"}]},{name:"math.sin",arities:[1],tier:"pure",signatures:["(x: Float) \u2192 Float"],summary:"Sine of x radians.",defined:[{id:"LEXP.3.9.1",page:"language/EXPRESSIONS.html#lexp-3-9-1"}]},{name:"math.sinh",arities:[1],tier:"pure",signatures:["(x: Float) \u2192 Float"],summary:"Hyperbolic sine.",defined:[{id:"LEXP.3.9.1",page:"language/EXPRESSIONS.html#lexp-3-9-1"}]},{name:"math.sqrt",arities:[1],tier:"pure",signatures:["(x: Float) \u2192 Float"],summary:"Square root, correctly rounded; NaN for a negative x.",defined:[{id:"LEXP.3.2",page:"language/EXPRESSIONS.html#lexp-3-2"}]},{name:"math.tan",arities:[1],tier:"pure",signatures:["(x: Float) \u2192 Float"],summary:"Tangent of x radians.",defined:[{id:"LEXP.3.9.1",page:"language/EXPRESSIONS.html#lexp-3-9-1"}]},{name:"math.tanh",arities:[1],tier:"pure",signatures:["(x: Float) \u2192 Float"],summary:"Hyperbolic tangent.",defined:[{id:"LEXP.3.9.1",page:"language/EXPRESSIONS.html#lexp-3-9-1"}]},{name:"math.trunc",arities:[1],tier:"pure",signatures:["(x: Int) \u2192 Int","(x: Float) \u2192 Int","(x: <unit>) \u2192 <unit>"],summary:"x truncated toward zero; a Float with no Int answer traps.",defined:[{id:"LEXP.3.2",page:"language/EXPRESSIONS.html#lexp-3-2"}]},{name:"max",arities:[2],tier:"pure",signatures:["(a, b: Int | Float) \u2192 Int | Float","(a, b: <unit>) \u2192 <unit>","(cursor) \u2192 T?"],summary:"The larger of a and b, of the winning operand's type, a tie giving a; with a cursor alone, the series' maximum.",defined:[{id:"LEXP.3.8.1",page:"language/EXPRESSIONS.html#lexp-3-8-1"}]},{name:"mean",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Arithmetic mean of the series' window.",defined:[{id:"LSER.16.2",page:"language/SERIES.html#lser-16-2"}]},{name:"median",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Median of the series' window, as p50.",defined:[{id:"LSER.16.2",page:"language/SERIES.html#lser-16-2"}]},{name:"min",arities:[2],tier:"pure",signatures:["(a, b: Int | Float) \u2192 Int | Float","(a, b: <unit>) \u2192 <unit>","(cursor) \u2192 T?"],summary:"The smaller of a and b, of the winning operand's type, a tie giving a; with a cursor alone, the series' minimum.",defined:[{id:"LEXP.3.8.1",page:"language/EXPRESSIONS.html#lexp-3-8-1"}]},{name:"monotonic_ns",arities:[0],tier:"sync-impure",signatures:["() \u2192 Duration"],summary:"The monotonic clock's reading.",defined:[{id:"LGRA.9.8.10",page:"language/GRAMMAR.html#lgra-9-8-10"}]},{name:"now",arities:[0],tier:"sync-impure",signatures:["() \u2192 Time"],summary:"The wall-clock instant.",defined:[{id:"LGRA.9.8.10",page:"language/GRAMMAR.html#lgra-9-8-10"}]},{name:"p1",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 1 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p10",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 10 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p11",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 11 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p12",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 12 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p13",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 13 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p14",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 14 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p15",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 15 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p16",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 16 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p17",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 17 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p18",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 18 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p19",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 19 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p2",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 2 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p20",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 20 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p21",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 21 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p22",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 22 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p23",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 23 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p24",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 24 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p25",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 25 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p26",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 26 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p27",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 27 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p28",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 28 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p29",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 29 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p3",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 3 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p30",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 30 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p31",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 31 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p32",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 32 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p33",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 33 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p34",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 34 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p35",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 35 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p36",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 36 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p37",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 37 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p38",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 38 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p39",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 39 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p4",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 4 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p40",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 40 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p41",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 41 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p42",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 42 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p43",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 43 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p44",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 44 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p45",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 45 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p46",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 46 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p47",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 47 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p48",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 48 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p49",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 49 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p5",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 5 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p50",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 50 of the series' window, interpolated; the median.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p51",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 51 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p52",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 52 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p53",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 53 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p54",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 54 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p55",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 55 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p56",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 56 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p57",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 57 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p58",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 58 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p59",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 59 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p6",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 6 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p60",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 60 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p61",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 61 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p62",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 62 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p63",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 63 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p64",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 64 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p65",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 65 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p66",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 66 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p67",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 67 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p68",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 68 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p69",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 69 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p7",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 7 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p70",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 70 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p71",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 71 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p72",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 72 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p73",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 73 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p74",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 74 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p75",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 75 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p76",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 76 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p77",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 77 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p78",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 78 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p79",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 79 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p8",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 8 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p80",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 80 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p81",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 81 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p82",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 82 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p83",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 83 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p84",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 84 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p85",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 85 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p86",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 86 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p87",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 87 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p88",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 88 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p89",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 89 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p9",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 9 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p90",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 90 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p91",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 91 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p92",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 92 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p93",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 93 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p94",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 94 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p95",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 95 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p96",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 96 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p97",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 97 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p98",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 98 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"p99",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Percentile 99 of the series' window, interpolated.",defined:[{id:"LSER.16.4.1",page:"language/SERIES.html#lser-16-4-1"}]},{name:"pstdev",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Population standard deviation of the series' window.",defined:[{id:"LSER.16.3.1",page:"language/SERIES.html#lser-16-3-1"}]},{name:"pvariance",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Population variance of the series' window.",defined:[{id:"LSER.16.3.1",page:"language/SERIES.html#lser-16-3-1"}]},{name:"rate",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"(last \u2212 first) / elapsed seconds over the series' window.",defined:[{id:"LSER.16.9",page:"language/SERIES.html#lser-16-9"}]},{name:"round",arities:[1],tier:"pure",signatures:["(x: Int) \u2192 Int","(x: Float) \u2192 Int","(x: <unit>) \u2192 <unit>"],summary:"Nearest integer, ties to even; a Float with no Int answer traps.",defined:[{id:"LEXP.3.2",page:"language/EXPRESSIONS.html#lexp-3-2"}]},{name:"stdev",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Sample standard deviation of the series' window.",defined:[{id:"LSER.16.3.1",page:"language/SERIES.html#lser-16-3-1"}]},{name:"variance",arities:[1],tier:"pure",signatures:["(cursor) \u2192 Float?"],summary:"Sample variance of the series' window.",defined:[{id:"LSER.16.3.1",page:"language/SERIES.html#lser-16-3-1"}]}]),de=Object.freeze([{name:"Bool",clause:"LGRA.5.1"},{name:"Bytes",clause:"LGRA.5.1"},{name:"Date",clause:"LTIM.1"},{name:"Duration",clause:"LTIM.1"},{name:"Float",clause:"LGRA.5.1"},{name:"Int",clause:"LGRA.5.1"},{name:"Interval",clause:"LINT.1"},{name:"Json",clause:"LGRA.5.8"},{name:"String",clause:"LGRA.5.1"},{name:"Time",clause:"LTIM.1"}]);var st=3,Xt=5,rr=6,ar=7,it=9,Fe=14,Ae=21,sr=22,or=24,lr=2,F=(t,e,n)=>n===void 0?{label:t,kind:e}:{label:t,kind:e,detail:n},be=le;function Ht(t,e,n,i,{prog:r=null}={}){let a=[...e[n-1]??""].slice(0,i).join(""),s=/(?:^|\s)call\s+((?:[\p{L}_][\p{L}\p{N}_]*\.)*)[\p{L}\p{N}_]*$/u.exec(a);if(s)return dr(t,r,s[1]);let l=cr(a);if(l!==null)return pr(t,r,l);let o=/([\p{L}_][\p{L}\p{N}_]*)\.[\p{L}\p{N}_]*$/u.exec(a);if(o)return ur(t,r,o[1],n,i);if(/::\s*[\p{L}\p{N}_]*$/u.test(a))return de.map(f=>F(f.name,ar,`type (${f.clause})`));if(/(?:^|\s)(?:emit|publish)\s+[\p{L}\p{N}_]*$/u.test(a))return Gt(t,r);let d=/^\s*[\p{L}\p{N}_]*$/u.test(a);if(d&&!/^\s/u.test(a))return C.declaration.map(f=>F(f,Fe));let m=t===null?null:se(t,n,i);if(m?._type!=="Rule")return jt(t,r,null);let c=[];return d&&(_r(e,m.lineno,n)?c.push(...C.action.map(f=>F(f,Fe)),F("let",Fe)):c.push(...Gt(t,r),...["no","then","latest"].map(f=>F(f,Fe)))),c.push(...jt(t,r,m)),c}function dr(t,e,n){let i=[];for(let[r,a]of Wt(t,e))r.startsWith(n)&&r.length>n.length&&i.push(F(r.slice(n.length),st,mr(a)));return i}function Wt(t,e){let n=new Map;if(e!==null){for(let[i,r]of Ne(e))n.set(i,r.decl);return n}for(let i of t?.body??[]){if(i._type!=="Service")continue;let r=i.name.join(".");n.has(r)||n.set(r,i)}return n}function mr(t){return t.kwargs.length===0?"service":`service (${t.kwargs.map(e=>e.name).join(", ")})`}function cr(t){let e=/(?:^|\s)call\s+([\p{L}_][\p{L}\p{N}_]*(?:\.[\p{L}_][\p{L}\p{N}_]*)+)\s+(.*)$/u.exec(t);if(e===null)return null;let n=e[2].replace(/"(?:[^"\\]|\\.)*"/gu,'""');if((n.match(/"/gu)??[]).length%2===1)return null;let i=n.replace(/[\p{L}\p{N}_]*$/u,"");if(i!==""&&!/\s$/u.test(i)||/:\s*$/u.test(i))return null;let r=new Set([...n.matchAll(/([\p{L}_][\p{L}\p{N}_]*)\s*:/gu)].map(a=>a[1]));return{service:e[1],written:r}}function pr(t,e,n){let i=Wt(t,e).get(n.service);return i===void 0?[]:i.kwargs.filter(r=>!n.written.has(r.name)).map(r=>({label:r.name,kind:Xt,detail:et(r),insertText:`${r.name}: `}))}function me(t){let e=new Map,n=new Map;for(let i of t?.body??[])if(i._type==="Import"){let r=i.path.join(".");e.set(i.asname??r,r)}else if(i._type==="ImportFrom"){let r=i.path.join(".");for(let a of i.names)n.set(a.asname??a.name,`${r}.${a.name}`)}return{modules:e,bare:n}}function ur(t,e,n,i,r){let a=t===null?null:se(t,i,r);if(t!==null&&a?._type==="Rule"){let m=H(a).get(n),c=m===void 0?null:e===null?yr(t,ee(m.type)):nt(e,m.type)?.schema??null;if(c!==null)return c.slots.map(f=>F(f.name,Xt,f.nullable?`${f.type}?`:f.type))}let s=[],l=e?.modules.get(n);l!==void 0&&s.push(...fr(l));let o=me(t).modules.get(n);if(o===void 0)return s;let d=o+".";return s.push(...be.filter(m=>m.name.startsWith(d)).map(m=>at(m,m.name.slice(d.length)))),s}function fr(t){let e=[];for(let n of t.tree.body)n._type==="Schema"?e.push(rt(n.name,n)):n._type==="Const"&&e.push(F(n.name,Ae,"const"));return e}var rt=(t,e)=>F(t,sr,`schema, ${e.slots.length} slots`);function zt(t,e){let n=[];for(let[i,r]of t?.modules??[])r.tree.body.some(e)&&n.push(F(i,it,"library"));return n}function Kt(t,e){let n=[];for(let[i,r]of t?.bare??[]){let a=r.unit.tree.body.find(s=>U(s)===r.name);a!==void 0&&e(a)&&n.push({name:i,decl:a})}return n}function jt(t,e,n){let i=[];if(n!==null&&t!==null)for(let[o,d]of H(n))i.push(F(o,rr,ee(d.type)));for(let o of t?.body??[])o._type==="Const"&&i.push(F(o.name,Ae,"const"));for(let{name:o}of Kt(e,d=>d._type==="Const"))i.push(F(o,Ae,"const"));for(let o of be)o.name.includes(".")||i.push(at(o,o.name));let{modules:r,bare:a}=me(t);for(let[o,d]of r)be.some(m=>m.name.startsWith(d+"."))&&i.push(F(o,it,`builtin module ${d}`));let s=new Set(i.filter(o=>o.kind===it).map(o=>o.label));for(let o of zt(e,d=>d._type==="Schema"||d._type==="Const"))s.has(o.label)||i.push(o);for(let[o,d]of a){let m=be.find(c=>c.name===d);m!==void 0&&i.push(at(m,o))}let l=new Set(be.map(o=>o.name));for(let o of Te)l.has(o)||i.push(F(o,st,"aggregation"));return i.push(...C.constant.map(o=>F(o,Ae)),...C.operator.map(o=>F(o,or))),i}function at(t,e){let n=`${t.arities.length>1?"arities":"arity"} ${t.arities.join(", ")}`,i=t.tier==="sync-impure"?", bound once per firing":"",r=Math.max(...t.arities)>0;return{label:e,kind:st,detail:`${n}${i}`,insertText:r?`${e}($1)`:`${e}()`,insertTextFormat:lr}}function Gt(t,e){let n=[];for(let i of t?.body??[])i._type==="Schema"&&n.push(rt(i.name,i));for(let{name:i,decl:r}of Kt(e,a=>a._type==="Schema"))r._type==="Schema"&&n.push(rt(i,r));return n.push(...zt(e,i=>i._type==="Schema")),n}function yr(t,e){for(let n of t.body)if(n._type==="Schema"&&n.name===e)return n;return null}function _r(t,e,n){for(let i=e;i<n;i++)if((t[i-1]??"").trim().startsWith("->"))return!0;return!1}var qt=new Map(le.map(t=>[t.name,t]));function ot(t,e){let{modules:n,bare:i}=me(t),r=e.indexOf(".");if(r<0)return qt.get(i.get(e)??e)??null;let a=n.get(e.slice(0,r));return a===void 0?null:qt.get(`${a}${e.slice(r)}`)??null}function Vt(t,e,n){let i=Le(e,n);return i===null||!/^\s*\(/u.test([...e].slice(i.end).join(""))?null:ot(t,i.qualifier===null?i.word:`${i.qualifier}.${i.word}`)}function Jt(t,e){if(typeof t!="string"||t==="")return null;let n=/^[a-z][a-z0-9+.-]*:/i.test(t)?t:e(t);return n.endsWith("/")?n:n+"/"}function Yt(t,e){let n=t.defined.map(i=>e===null?`[${i.id}]`:`[[${i.id}]](${e}specs/${i.page})`);return["```ds\n"+t.signatures.map(i=>t.name+i).join(`
|
|
10
|
+
`)+"\n```",t.summary,n.join(", ")].join(`
|
|
11
|
+
|
|
12
|
+
`)}function Qt(t){return Array.isArray(t)&&t.includes("utf-32")?"utf-32":"utf-16"}function ce(t,e,n){if(n==="utf-32")return e;let i=0,r=0;for(let a of t){if(r>=e)return i;i+=a.length,r++}return i+(e-r)}function pe(t,e,n){if(n==="utf-32")return e;let i=0,r=0;for(let a of t){if(i+a.length>e)return r;i+=a.length,r++}return r+Math.max(0,e-i)}function Zt(t){return t.split(/\r\n|\n|\r/)}var Pe=Object.freeze({tokenTypes:Object.freeze(["namespace","type","struct","interface","function","variable","property","keyword","operator","string","number","comment"]),tokenModifiers:Object.freeze(["declaration","readonly","defaultLibrary","action","clause","constant"])}),I=Object.fromEntries(Pe.tokenTypes.map((t,e)=>[t,e])),v=Object.fromEntries(Pe.tokenModifiers.map((t,e)=>[t,1<<e])),gr=/[\p{L}_]/u,hr=/[\p{L}\p{N}_]/u,ue=/[0-9]/,en=/[\p{L}°′″ʹʺ]/u,kr=/[\p{L}\p{N}_°′″ʹʺ]/u;function lt(t,e){let n=[],i=!1,r=e===void 0?t.length:Math.min(e.line,t.length);for(let a=1;a<=r;a++){let s=[...t[a-1]??""],l=e!==void 0&&a===e.line?s.slice(0,e.col):s,o=(m,c,f)=>n.push({line:a,start:m,end:c,kind:f,text:l.slice(m,c).join("")}),d=0;if(i){let m=tn(l,0);if(m<0){l.length&&o(0,l.length,"string");continue}o(0,m,"string"),i=!1,d=m}for(;d<l.length;){let m=l[d];if(m===" "||m===" ")d++;else if(m==="#")o(d,l.length,"comment"),d=l.length;else if(m==='"'&&l[d+1]==='"'&&l[d+2]==='"'){let c=tn(l,d+3);c<0?(o(d,l.length,"string"),i=!0,d=l.length):(o(d,c,"string"),d=c)}else if(m==='"'){let c=d+1;for(;c<l.length&&l[c]!=='"';)c+=l[c]==="\\"?2:1;let f=Math.min(c+1,l.length);o(d,f,"string"),d=f}else if(ue.test(m)){let c=Sr(l,d);o(d,c,"number"),d=c}else if(gr.test(m)){let c=d+1;for(;c<l.length&&hr.test(l[c]);)c++;o(d,c,"name"),d=c}else o(d,d+1,"punct"),d++}}return n}function tn(t,e){for(let n=e;n<t.length;n++)if(t[n]==="\\")n++;else if(t[n]==='"'&&t[n+1]==='"'&&t[n+2]==='"')return n+3;return-1}function Sr(t,e){let n=e,i=a=>{for(;n<t.length&&(a.test(t[n])||t[n]==="_"&&a.test(t[n+1]??""));)n++};if(t[e]==="0"&&/[xob]/.test(t[e+1]??""))return n=e+2,i(/[0-9a-fA-F]/),n;if(i(ue),t[n]==="."&&ue.test(t[n+1]??"")&&(n++,i(ue)),t[n]==="e"||t[n]==="E"){let a=t[n+1]==="+"||t[n+1]==="-"?1:0;ue.test(t[n+1+a]??"")&&(n+=1+a,i(ue))}let r=t[n]==="_"&&en.test(t[n+1]??"")?n+1:n;if(en.test(t[r]??""))for(n=r+1;n<t.length&&kr.test(t[n]);)n++;return n}var Er=new Map([...C.declaration.map(t=>[t,{type:I.keyword,mods:0}]),...C.action.map(t=>[t,{type:I.keyword,mods:v.action}]),...C.clause.map(t=>[t,{type:I.keyword,mods:v.clause}]),...C.constant.map(t=>[t,{type:I.keyword,mods:v.constant}]),...C.operator.map(t=>[t,{type:I.operator,mods:0}])]),br=new Set(de.map(t=>t.name)),Oe=new Set(le.map(t=>t.name)),Rr=new Set(Te);function nn(t,e){let n=lt(t),{modules:i,bare:r}=me(e?.tree??null),a=new Map((e?.tree.body??[]).flatMap(l=>l._type==="Service"?[[l.name.join("."),l.lineno]]:[])),s=[];for(let l=0;l<n.length;l++){let o=n[l],d=(W,ve=0)=>s.push({line:o.line,start:o.start,end:o.end,type:W,mods:ve});if(o.kind==="comment"?d(I.comment):o.kind==="string"?d(I.string):o.kind==="number"&&d(I.number),o.kind!=="name")continue;let m=n[l-1],c=n[l+1],w=m?.kind==="punct"&&m.text==="."&&m.line===o.line&&m.end===o.start&&n[l-2]?.kind==="name"&&n[l-2].end===m.start?n[l-2].text:null,A=c?.kind==="punct"&&c.text==="."&&c.line===o.line&&c.start===o.end&&n[l+2]?.kind==="name"&&n[l+2].start===c.end?n[l+2].text:null,O=c?.kind==="punct"&&c.text==="("&&c.line===o.line,D=dt(n,l),b=D.length>1?a.get(D):void 0;if(b!==void 0){d(I.interface,b===o.line?v.declaration:0);continue}let E=e===null?null:Ee(e,o.line,o.start);if(E!==null&&e!==null){let W=wr(E,e,o);if(W!==null){d(W.type,W.mods);continue}}let P=w!==null?i.get(w):void 0;if(P!==void 0&&Oe.has(`${P}.${o.text}`)){d(I.function,v.defaultLibrary);continue}let N=i.get(o.text);if(A!==null&&N!==void 0&&Oe.has(`${N}.${A}`)){d(I.namespace,v.defaultLibrary);continue}if(w===null&&O&&(Oe.has(o.text)||Oe.has(r.get(o.text)??"")||Rr.has(o.text))){d(I.function,v.defaultLibrary);continue}if(w!==null)continue;if(br.has(o.text)){d(I.type,v.defaultLibrary);continue}let re=Er.get(o.text);if(re!==void 0){d(re.type,re.mods);continue}e!==null&&xr(e,o.line)&&d(I.namespace)}return s}function wr(t,e,n){let i=r=>t.unit===e&&r.line===n.line&&r.start===n.start;switch(t.kind){case"binding":{let r=te(t.rule.lhs).some(a=>a.binding===t.name&&i(x(e.lines,a,t.name)));return{type:I.variable,mods:r?v.declaration:0}}case"slot":return{type:I.property,mods:i(x(t.unit.lines,t.slot,t.slot.name))?v.declaration:0};case"decl":{let r=i(x(t.unit.lines,t.decl,t.name))?v.declaration:0;switch(t.decl._type){case"Schema":return{type:I.struct,mods:r};case"Rule":return{type:I.function,mods:r};case"Const":return{type:I.variable,mods:r|v.readonly};case"Service":return{type:I.interface,mods:r};case"Opaque":case"UnitDimension":case"UnitScalar":case"UnitSymbol":case"UnitFormula":case"UnitFxPair":return{type:I.type,mods:r};default:return null}}}}function dt(t,e){let n=(s,l)=>t[s]!==void 0&&t[l]!==void 0&&t[s].line===t[l].line&&t[s].end===t[l].start,i=s=>t[s]?.kind==="punct"&&t[s].text===".",r=e,a=e;for(;i(r-1)&&t[r-2]?.kind==="name"&&n(r-2,r-1)&&n(r-1,r);)r-=2;for(;i(a+1)&&t[a+2]?.kind==="name"&&n(a,a+1)&&n(a+1,a+2);)a+=2;return t.slice(r,a+1).map(s=>s.text).join("")}function xr(t,e){return t.tree.body.some(n=>(n._type==="Import"||n._type==="ImportFrom")&&e>=n.lineno&&e<=(n.end_lineno??n.lineno))}function rn(t,e,n){let i=[],r=0,a=0;for(let s of t){let l=e[s.line-1]??"",o=ce(l,s.start,n),d=ce(l,s.end,n);if(d<=o)continue;let m=s.line-1;i.push(m-r,m===r?o-a:o,d-o,s.type,s.mods),r=m,a=o}return i}var Ir=new Set(["(","[","{"]),Lr=new Set([")","]","}"]);function an(t,e,n,i){let r=lt(e,{line:n,col:i}),a=[];for(let c=0;c<r.length;c++){let f=r[c];if(f.kind==="punct")if(Ir.has(f.text)){let w=r[c-1],M=f.text==="("&&w?.kind==="name"&&w.line===f.line?dt(r,c-1):null;a.push({open:f.text,callee:M,commas:0})}else Lr.has(f.text)?a.pop():f.text===","&&a.length&&a[a.length-1].commas++}let s=a[a.length-1];if(s===void 0||s.open!=="("||s.callee===null)return null;let l=ot(t,s.callee);if(l===null)return null;let o=s.callee,d=l.signatures.map(c=>Dr(o,c,l.summary)),m=d.findIndex(c=>c.parameters.length>s.commas);return{signatures:d,activeSignature:m<0?d.length-1:m,activeParameter:s.commas}}function Dr(t,e,n){let i=t+e,r=t.length+1,a=r+Nr(e)-1,s=[],l=0,o=r;for(let d=r;d<=a;d++){let m=i[d];if(m==="("||m==="["?l++:(m===")"||m==="]")&&l--,m===","&&l===0||d===a){let c=o,f=d;for(;c<f&&i[c]===" ";)c++;c<f&&s.push({label:[c,f]}),o=d+1}}return{label:i,documentation:n,parameters:s}}function Nr(t){let e=0;for(let n=0;n<t.length;n++)if(t[n]==="(")e++;else if(t[n]===")"&&--e===0)return n;return t.length-1}var j=Object.freeze({Field:8,Interface:11,Function:12,Constant:14,Property:7,Struct:23,Event:24,TypeParameter:26});function mt(t,e){let n=[],i=t.body;for(let r=0;r<i.length;r++){let a=i[r],s=Tr(a);if(s===null)continue;let{nameInText:l,...o}=s;n.push({...o,range:{start:{line:a.lineno,col:a.col_offset},end:Ar(a,i[r+1]??null,e)},selection:x(e,a,l??o.name),children:a._type==="Schema"?a.slots.map(d=>Fr(d,e)):[]})}return n}function sn(t){return t.flatMap(e=>[{...e,container:null},...e.children.map(n=>({...n,container:e.name}))])}function on(t,e){let n=t.toLowerCase(),i=0;for(let r of e.toLowerCase()){if(i=n.indexOf(r,i),i<0)return!1;i+=r.length}return!0}function Tr(t){switch(t._type){case"Schema":return{name:t.name,detail:`schema, ${t.slots.length} slot${t.slots.length===1?"":"s"}`,kind:j.Struct};case"Rule":return{name:t.name,detail:"rule",kind:j.Function};case"Const":return{name:t.name,detail:"const",kind:j.Constant};case"Service":{let e=t.response,n=e===null?"service":e._type==="ResponseSchema"?`service, response ${e.name}`:"service, no response";return{name:t.name.join("."),detail:n,kind:j.Interface}}case"Opaque":return{name:t.name,detail:`opaque ${t.representation}`,kind:j.TypeParameter};case"Series":return{name:t.schema===null?t.slot:`${t.schema}.${t.slot}`,detail:"series",kind:j.Property,nameInText:t.slot};case"Test":{let e=t.name;return{name:e._type==="Constant"&&typeof e.value=="string"?e.value:"test",detail:"test",kind:j.Event,nameInText:"test"}}default:{let e=U(t);return e===null?null:{name:e,detail:"unit",kind:j.Constant}}}}function Fr(t,e){let n=t.end_lineno!==null&&t.end_col_offset!==null?{line:t.end_lineno,col:t.end_col_offset}:{line:t.lineno,col:[...e[t.lineno-1]??""].length};return{name:t.name,detail:t.nullable?`${t.type}?`:t.type,kind:j.Field,range:{start:{line:t.lineno,col:t.col_offset},end:n},selection:x(e,t,t.name),children:[]}}function Ar(t,e,n){if(t.end_lineno!==null&&t.end_col_offset!==null)return{line:t.end_lineno,col:t.end_col_offset};let i=e===null?n.length:e.lineno-1;for(;i>t.lineno&&/^\s*(#.*)?$/.test(n[i-1]??"");)i--;return{line:i,col:[...n[i-1]??""].length}}var Or=/^(related: )?File "(.*)", line (\d+), column (\d+)$/,Pr=/^( *)(\^+)(?: \(continues to line (\d+), column (\d+)\))?$/,Cr=/^([A-Z][A-Z0-9_]*): (.*)$/,ln=" hint: ";function dn(t){let e=t.split(`
|
|
13
|
+
`),n=[],i=0,r=()=>{let a=Or.exec(e[i]);if(a===null)return null;let s=Number(a[3]),l=Number(a[4])-1,o={start:{line:s,col:l},end:{line:s,col:l+1}};if(i++,i+1<e.length&&e[i].startsWith(" ")){let d=Pr.exec(e[i+1].slice(4));d!==null&&(o.end=d[3]!==void 0?{line:Number(d[3]),col:Number(d[4])-1}:{line:s,col:l+d[2].length},i+=2)}return{related:a[1]!==void 0,span:o}};for(;i<e.length;){let a=r();if(a===null||a.related){a===null&&i++;continue}let s=Cr.exec(e[i]??"");if(s===null)continue;i++;let l={code:s[1],message:s[2],hint:null,span:a.span,related:[]};for(e[i]?.startsWith(ln)&&(l.hint=e[i++].slice(ln.length));;){let o=i,d=r();if(d===null||!d.related){i=o;break}l.related.push({span:d.span,message:(e[i++]??"").trim()})}n.push(l)}return n}var vr=new Set([...Object.values(C).flat(),...de.map(t=>t.name)]),$r=256,mn=-32600,Mr=-32601,Ur=-32603,Br=-32002,jr=-32803;function pn({host:t,send:e,log:n,libs:i=[],settleMs:r=200,version:a}){let s=new Map,l="utf-16",o=!1,d=!1,m=[...i],c=t.stdlib?.()??null,f=new Map,w=[],M=null,A=!1,O=_=>{A||e({jsonrpc:"2.0",..._})},D=_=>typeof _=="string"?t.uriPath(_):null,b=Promise.resolve(),E=_=>{let y=b.then(_);return b=y.then(()=>{},()=>{}),y},P=async _=>{let y=s.get(_);if(y===void 0||A)return;let p=D(_),u=p??_,g=await t.dumpAst(y.text,u);if("tree"in g)try{y.tree=Ye(g.tree)}catch(R){if(!(R instanceof T))throw R;n(`ds lsp: ${u}: ${R.message}`)}let k=p===null?m:[t.dirname(p),...m],S=await t.compile(y.text,u,k);if(A)return;let h=S===null?[]:dn(S).map(R=>Xr(R,y.lines,_,l));O({method:"textDocument/publishDiagnostics",params:{uri:_,diagnostics:h}})},N=new Map,re=_=>{clearTimeout(N.get(_)),N.set(_,setTimeout(()=>{E(async()=>{N.has(_)&&(N.delete(_),await P(_))}).catch(y=>n(`ds lsp: ${_}: ${y instanceof Error?y.message:String(y)}`))},r))},W=async()=>{for(let[_,y]of N)clearTimeout(y),N.delete(_),await P(_)},ve=async(_,y)=>{switch(_){case"initialize":{o=!0,l=Qt(y?.capabilities?.general?.positionEncodings);let p=y?.initializationOptions,u=y?.rootUri?D(y.rootUri):null,g=h=>u===null?h:t.resolve(u,h);Array.isArray(p?.libs)&&(m=[...p.libs.filter(h=>typeof h=="string").map(g),...i]);let k=p?.docs;return M=Jt(typeof k=="string"&&!/^[a-z][a-z0-9+.-]*:/i.test(k)?g(k):k,t.pathUri),w=[...(Array.isArray(y?.workspaceFolders)?y.workspaceFolders:[]).map(h=>D(h?.uri)),u].flatMap(h=>h===null?[]:[h]),{capabilities:{positionEncoding:l,textDocumentSync:{openClose:!0,change:1,save:{includeText:!1}},hoverProvider:!0,definitionProvider:!0,completionProvider:{triggerCharacters:[".",":"]},referencesProvider:!0,renameProvider:!0,documentSymbolProvider:!0,workspaceSymbolProvider:!0,semanticTokensProvider:{legend:Pe,full:!0},signatureHelpProvider:{triggerCharacters:["(",","]}},serverInfo:{name:"ds lsp",...a===void 0?{}:{version:a}}}}case"shutdown":return d=!0,null;case"textDocument/hover":{let p=await pt(y);if(p!==null)return{contents:{kind:"markdown",value:Pt(p.t)}};let u=s.get(y?.textDocument?.uri),g=y?.position;if(u===void 0||typeof g?.line!="number")return null;let k=u.lines[g.line]??"",S=Vt(u.tree,k,pe(k,g.character,l));return S===null?null:{contents:{kind:"markdown",value:Yt(S,M)}}}case"textDocument/completion":{let p=y?.textDocument?.uri,u=s.get(p),g=y?.position;if(u===void 0||typeof g?.line!="number")return null;let k=u.lines[g.line]??"",S=u.tree===null?null:await fe(p,u,u.tree);return{isIncomplete:!1,items:Ht(u.tree,u.lines,g.line+1,pe(k,g.character,l),{prog:S})}}case"textDocument/references":{let p=await ut(y);if(p===null)return[];let u=y?.context?.includeDeclaration!==!1;return p.all.filter(g=>u||!g.declaration).map(g=>({uri:g.unit.uri,range:ne(g.unit.lines,g.range.line,g.range.start,g.range.line,g.range.end,l)}))}case"textDocument/rename":{let p=y?.newName;if(typeof p!="string"||!/^[\p{L}_][\p{L}\p{N}_]*$/u.test(p))throw new ie(`${JSON.stringify(p)} is not a DS name`);if(vr.has(p))throw new ie(`\`${p}\` is a reserved word ([LLEX.9.6])`);let u=await ut(y);if(u===null)throw new ie("nothing the program declares is named here");let g=u.all.find(S=>!hn(S.unit.path,S.unit.uri===y.textDocument.uri));if(g!==void 0)throw new ie(`${g.unit.path??g.unit.uri} is outside the workspace, so the rename would leave it behind`);let k={};for(let S of u.all)(k[S.unit.uri]??=[]).push({range:ne(S.unit.lines,S.range.line,S.range.start,S.range.line,S.range.end,l),newText:p});return{changes:k}}case"textDocument/definition":{let p=await pt(y);if(p===null)return null;let u=p.unit.lines,g=Ft(u,p.t);return{uri:p.unit.uri,range:ne(u,g.line,g.start,g.line,g.end,l)}}case"textDocument/documentSymbol":{let p=s.get(y?.textDocument?.uri);if(p===void 0||p.tree===null)return[];let u=p.lines,g=k=>({name:k.name,detail:k.detail,kind:k.kind,range:ne(u,k.range.start.line,k.range.start.col,k.range.end.line,k.range.end.col,l),selectionRange:ne(u,k.selection.line,k.selection.start,k.selection.line,k.selection.end,l),children:k.children.map(g)});return mt(p.tree,u).map(g)}case"textDocument/semanticTokens/full":{let p=y?.textDocument?.uri,u=s.get(p);if(u===void 0)return{data:[]};let g=u.tree===null?null:await fe(p,u,u.tree);return{data:rn(nn(u.lines,g),u.lines,l)}}case"textDocument/signatureHelp":{let p=s.get(y?.textDocument?.uri),u=y?.position;if(p===void 0||typeof u?.line!="number")return null;let g=p.lines[u.line]??"";return an(p.tree,p.lines,u.line+1,pe(g,u.character,l))}case"workspace/symbol":{let p=typeof y?.query=="string"?y.query:"",u=new Set,g=[];for(let[k,S]of s)if(S.tree!==null){for(let h of De(await fe(k,S,S.tree)))if(!u.has(h.uri)){u.add(h.uri);for(let R of sn(mt(h.tree,h.lines))){if(!on(R.name,p))continue;let L=R.range;g.push({name:R.name,kind:R.kind,...R.container===null?{}:{containerName:R.container},location:{uri:h.uri,range:ne(h.lines,L.start.line,L.start.col,L.end.line,L.end.col,l)}})}}}return g}default:throw new Ce(_)}},pt=async _=>{let y=_?.textDocument?.uri,p=s.get(y),u=_?.position;if(p===void 0||p.tree===null||typeof u?.line!="number")return null;let g=await fe(y,p,p.tree),k=p.lines[u.line]??"",S=u.line+1,h=pe(k,u.character,l),R=Ee(g,S,h);if(R!==null)return $t(R);let L=vt(g,S,h),z=L===null?void 0:Ne(g).get(L);return z===void 0||L===null?null:{unit:z.unit,t:{kind:"decl",decl:z.decl,name:L}}},ut=async _=>{let y=_?.textDocument?.uri,p=s.get(y),u=_?.position;if(p===void 0||p.tree===null||typeof u?.line!="number")return null;let g=await fe(y,p,p.tree),k=p.lines[u.line]??"",S=Ee(g,u.line+1,pe(k,u.character,l));if(S===null)return null;let h=new Map;for(let R of Mt(g,S)){let L=`${R.unit.uri}\0${R.range.line}:${R.range.start}`;(!h.has(L)||R.declaration)&&h.set(L,R)}return{all:[...h.values()]}},fe=async(_,y,p)=>{let u=new Map;for(let[k,S]of s){let h=D(k);h!==null&&u.set(h,S.text)}let g=c===null?m:[...m,c];for(;;){let k=new Map,S=Ct({uri:_,path:D(_),lines:y.lines,tree:p},g,{read:h=>u.get(h)??t.read?.(h)??null,tree:(h,R)=>{let L=`${R}\0${h}`,z=f.get(L);return z===void 0?(k.set(L,[h,R]),null):(f.delete(L),f.set(L,z),z)},uri:h=>t.pathUri(h)});if(!k.size){for(let h of f.keys()){if(f.size<=$r)break;f.delete(h)}return S}for(let[h,[R,L]]of k)f.set(h,await gn(R,L))}},gn=async(_,y)=>{let p=await t.dumpAst(_,y);if(!("tree"in p))return null;try{return Ye(p.tree)}catch(u){if(!(u instanceof T))throw u;return n(`ds lsp: ${y}: ${u.message}`),null}},hn=(_,y)=>_===null?y:w.some(p=>_===p||_.startsWith(p.endsWith("/")?p:p+"/")),kn=async(_,y)=>{let p=y?.textDocument?.uri;switch(_){case"textDocument/didOpen":s.set(p,cn(y.textDocument.text,null)),await P(p);return;case"textDocument/didChange":{let u=y.contentChanges,g=u[u.length-1].text;s.set(p,cn(g,s.get(p)?.tree??null)),re(p);return}case"textDocument/didSave":clearTimeout(N.get(p)),N.delete(p),await P(p);return;case"textDocument/didClose":clearTimeout(N.get(p)),N.delete(p),s.delete(p),O({method:"textDocument/publishDiagnostics",params:{uri:p,diagnostics:[]}});return;case"workspace/didChangeWatchedFiles":for(let u of s.keys())re(u);return}},ft=_=>{A=!0;for(let y of N.values())clearTimeout(y);return N.clear(),_},Sn=async(_,y)=>{try{y&&!Gr.has(_.method)&&await W(),y?O({id:_.id,result:await ve(_.method,_.params)}):await kn(_.method,_.params)}catch(p){if(p instanceof Ce){y&&O({id:_.id,error:{code:Mr,message:`no method ${p.message}`}});return}if(p instanceof ie){y&&O({id:_.id,error:{code:jr,message:p.message}});return}let u=p instanceof Error?p.message:String(p);n(`ds lsp: ${_.method}: ${u}`),y&&O({id:_.id,error:{code:Ur,message:u}})}};return{receive:_=>E(async()=>{if(A)return null;if(_===null||typeof _!="object"||typeof _.method!="string")return _?.id===void 0&&O({id:null,error:{code:mn,message:"not a request or notification"}}),null;let y=_.id!==void 0;return _.method==="exit"?ft(d?0:1):!o&&_.method!=="initialize"?(y&&O({id:_.id,error:{code:Br,message:"initialize first"}}),null):d?(y&&O({id:_.id,error:{code:mn,message:"the server is shut down: only `exit` is left"}}),null):(await Sn(_,y),null)}),end:()=>ft(d?0:1)}}var Gr=new Set(["textDocument/completion","textDocument/signatureHelp"]),Ce=class extends Error{},ie=class extends Error{};function cn(t,e){return{text:t,lines:Zt(t),tree:e}}function ne(t,e,n,i,r,a){return{start:{line:e-1,character:ce(t[e-1]??"",n,a)},end:{line:i-1,character:ce(t[i-1]??"",r,a)}}}function Xr(t,e,n,i){let r=(a,s)=>{let l=s.line>a.line||s.col>a.col;return ne(e,a.line,a.col,s.line,l?s.col:a.col+1,i)};return{range:r(t.span.start,t.span.end),severity:1,code:t.code,source:"ds lsp",message:t.hint===null?t.message:`${t.message}
|
|
14
|
+
|
|
15
|
+
hint: ${t.hint}`,...t.related.length?{relatedInformation:t.related.map(a=>({location:{uri:n,range:r(a.span.start,a.span.end)},message:a.message}))}:{}}}var Hr="/ds_dsc/bin/dsc",un="/ds_dsc/share/ds/stdlib";async function fn({binding:t,compiler:e,compilerWasm:n,files:i=new Map}){let r=typeof e=="string"||e instanceof URL?await import(String(e)):e,a=Wr(r),l={wasmModule:n===void 0||n instanceof WebAssembly.Module?n:await WebAssembly.compile(n),program:Hr},o=`${un}/`,d=m=>{let c=m.endsWith("/")?m:`${m}/`;for(let f of i.keys())if(f.startsWith(c))return!0;return!1};return{files:i,async dumpAst(m,c){let f=await t.runDsc(r,["dump-ast","-","--filename",c],{stdin:new TextEncoder().encode(m),...l});if(f.status===0)return{tree:JSON.parse(new TextDecoder().decode(f.stdout))};if(f.status===1)return{refused:f.stderr};throw new Error(`dsc dump-ast exited ${f.status}: ${f.stderr.trim()}`)},async compile(m,c,f){try{return await t.compileWasm(r,m,{file:c,searchPath:f.filter(d),files:Object.fromEntries(i),...l}),null}catch(w){if(w instanceof t.CompileRefused)return w.diagnostics;throw w}},read:m=>i.get(m)??(m.startsWith(o)?a.get(m.slice(o.length)):void 0)??null,stdlib:()=>a.size?un:null,uriPath:m=>m.startsWith("file:")?decodeURIComponent(new URL(m).pathname):null,pathUri:m=>`file://${m.split("/").map(encodeURIComponent).join("/")}`,dirname:zr,resolve:(m,c)=>Kr(c.startsWith("/")?c:`${m}/${c}`)}}function Wr(t){let e=typeof t=="function"||t===null||typeof t!="object"?void 0:Reflect.get(t,"library"),n=new Map;if(e==null)return n;if(typeof e!="object")throw new TypeError("ds lsp: ds_dsc's `library` is not its standard library");for(let[i,r]of Object.entries(e)){if(typeof r!="string")throw new TypeError(`ds lsp: ds_dsc's library entry ${i} is not text`);n.set(i,r)}return n}function zr(t){let e=t.lastIndexOf("/");return e<=0?"/":t.slice(0,e)}function Kr(t){let e=[];for(let n of t.split("/"))n===""||n==="."||(n===".."?e.pop():e.push(n));return`/${e.join("/")}`}function yn({host:t,scope:e=globalThis,libs:n,settleMs:i,version:r}){let a=pn({host:t,send:m=>e.postMessage(JSON.stringify(m)),log:m=>console.error(m),libs:n,settleMs:i,version:r}),s=()=>{},l=new Promise(m=>{s=m}),o=m=>{let c=m.data;if(typeof c=="string")try{c=JSON.parse(c)}catch{e.postMessage(JSON.stringify({jsonrpc:"2.0",id:null,error:{code:-32700,message:"not JSON"}}));return}a.receive(c).then(f=>{f!==null&&(d(),s(f))},f=>console.error(`ds lsp: ${f instanceof Error?f.message:String(f)}`))},d=()=>e.removeEventListener?.("message",o);return e.addEventListener("message",o),{session:a,exited:l,close:d}}var ct="/ds-libraries",qr=/^[A-Za-z0-9_.-]+\.ds$/;function _n(t={}){let e=new Map;for(let[n,i]of Object.entries(t||{})){if(!qr.test(n))throw new Error(`a library is a .ds file name, not ${JSON.stringify(n)}`);e.set(`${ct}/${n}`,String(i))}return e}async function Vr({dsc:t,wasm:e,libraries:n}){let i=_n(n),r=new Uint8Array(await(await fetch(e)).arrayBuffer()),a=await fn({binding:Ve,compiler:t,compilerWasm:r,files:i});yn({host:a,scope:self,libs:i.size?[ct]:[]})}if(typeof self<"u"&&typeof self.addEventListener=="function"&&typeof document>"u"){let t=({data:e})=>{!e||e.op!=="ds-editor-core/init"||(self.removeEventListener("message",t),Vr(e).then(()=>self.postMessage(JSON.stringify({"ds-editor-core/ready":!0})),n=>self.postMessage(JSON.stringify({"ds-editor-core/failed":String(n&&n.message||n)}))))};self.addEventListener("message",t)}
|
|
16
|
+
//# sourceMappingURL=lsp-worker.js.map
|