Socket
Socket
Sign inDemoInstall

@webqit/subscript

Package Overview
Dependencies
2
Maintainers
1
Versions
92
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.1.40 to 2.1.41

2

dist/dev-elements.js

@@ -189,3 +189,3 @@ (()=>{function J(v,e=!1){let t=v.split(/\n/g);if(t.length>1){for(;!t[0].trim().length;)t.shift();let i=t[e?1:0].split(/[^\s]/)[0].length;if(i)return t.map((n,r)=>{let s=n.substring(0,i);return s.trim().length?s.trim()==="}"&&r===t.length-1?"}":n:n.substring(i)}).join(`

}
`]}};customElements.define("cfunctions-inspector",Q);function ce(...v){let e={runtimeParams:be,compilerParams:me,parserParams:ge},t;for(;t=v.shift();){let{runtimeParams:i={},compilerParams:{globalsNoObserve:n=[],globalsOnlyPathsExcept:r=[],...s}={},parserParams:o={}}=t;e={runtimeParams:{...e.runtimeParams,...i},compilerParams:{...e.compilerParams,globalsNoObserve:[...e.compilerParams.globalsNoObserve,...n],globalsOnlyPathsExcept:[...e.compilerParams.globalsOnlyPathsExcept,...r],...s},parserParams:{...e.parserParams,...o}},v.devMode}return e}var ge={ecmaVersion:"2020",allowReturnOutsideFunction:!0,allowAwaitOutsideFunction:!0,allowSuperOutsideMethod:!0,preserveParens:!1,locations:!1},me={globalsNoObserve:["globalThis","arguments","console","debugger"],globalsOnlyPathsExcept:[],originalSource:!0,locations:!0,compact:2},be={apiVersion:1};var ue=new Map;function q(v,e,t=void 0){let i=ue.get(v);if(arguments.length>2){i||(i=new Map,ue.set(v,i)),i.set(e,t);return}return i&&i.get(e)}var j=class{constructor(e,t,i,n={},r=null,s=null){this.ownerContract=e,this.graph=t,this.callee=i,this.params=e?n:{...n,isSubscriptFunction:!0},this.exits=s||new Map,this.$thread=r||{entries:new Map,sequence:[],ownerContract:this},this.subContracts=new Map,this.observers=[],this.contract=function(o,u,h=null,m=null){if(!this.graph.subContracts[o])throw new Error(`[${this.graph.type}:${this.graph.lineage}]: Graph not found for child contract ${o}.`);let a=this.graph.subContracts[o],b={...this.params,isIterationContract:arguments.length===3,iterationId:arguments.length===3&&u,isFunctionContract:arguments.length===4,functionType:arguments.length===4&&u,isSubscriptFunction:arguments.length===4&&h,functionScope:this.params.isFunctionContract&&this.graph.lineage||this.params.functionScope};if(b.isIterationContract){let f=h,d=new j(this,a,f,b,this.$thread,this.exits),x=this.subContracts.get(o);return x||(x=new Map,this.subContracts.set(o,x)),x.has(b.iterationId)&&x.get(b.iterationId).dispose(),x.set(b.iterationId,d),d.call()}let l,c,p;if(this.subContracts.has(o)&&this.subContracts.get(o).dispose(),b.isFunctionContract){l=m;let f=()=>new j(this,a,l,b);if(b.functionType!=="FunctionDeclaration")p=this.createFunction(f);else{let d=f();b.apiVersion>1?(p=function(...x){let y=d.call(this,...x);return y=$(y,w=>[y,d.thread.bind(d),d]),d=f(),y},p.target=d):p=d}}else l=u,c=new j(this,a,l,b,this.$thread,this.exits),this.subContracts.set(o,c),p=c.call();return p}.bind(this),this.contract.memo=Object.create(null),this.ownerContract&&!["FunctionDeclaration","FunctionExpression"].includes(this.graph.type)&&(this.contract.args=this.ownerContract.contract.args),this.contract.exiting=function(o,u){if(!arguments.length)return this.exits.size;let h=this.exits.get(o)===u;return h&&this.exits.clear(),h}.bind(this),this.contract.exit=function(o,u){this.exits.set(o,u)}.bind(this),this.contract.functions=new Map,this.contract.functions.declaration=(o,u)=>{this.contract.functions.set(o,u),this.applyReflection(o,typeof u=="function"?u.target:u)}}fire(e,t,i){if(!this.ownerContract)return;let n=this.ownerContract.fire(e,t,i);return this.observers.forEach(r=>{r.contractUrl===e&&r.callback(t,i)}),n}observe(e,t){!this.params.isFunctionContract||this.observers.push({contractUrl:e,callback:t})}call(e,...t){if(this.disposed)throw new Error(`[${this.graph.type}:${this.graph.lineage}]: Instance not runable after having been disposed.`);this.ownerContract||(this.contract.args=t,Object.defineProperty(this.contract.args,Symbol.toStringTag,{value:"Arguments"}));let i=this.callee.call(e,this.contract,...t);if(this.graph.$sideEffects)for(let n in this.graph.effects)for(let r of this.graph.effects[n].refs)this.buildThread([],r,[],0,!0);return $(i,()=>{if(!this.ownerContract||this.params.isFunctionContract){let n=this.exits.get("return");if(this.exits.clear(),n!==void 0)return n}return i})}iterate(e=[]){if(this.disposed)return!1;if(!["ForOfStatement","ForInStatement"].includes(this.graph.type)||this.subContracts.size!==1)throw new Error(`Contract ${this.graph.lineage} is not an iterator.`);let[[,t]]=this.subContracts,i;if(!e.length||e.includes("length")&&this.graph.type==="ForOfStatement")for(let[,n]of t)i=$(i,()=>n.call());else for(let n of e){let r=t.get(n)||t.get(parseInt(n));!r||(i=$(i,()=>r.call()))}return i}thread(...e){if(this.disposed)return!1;this.$thread.active=!0;for(let t in this.graph.effects)for(let i of this.graph.effects[t].refs)for(let n of e){let[r,s,o]=this.matchRefs(n,i);!r||this.buildThread(n,i,o,s)}return this.runThread()}runThread(){let e=(r,s)=>{if(["ForOfStatement","ForInStatement"].includes(r.graph.type)&&s.every(o=>o.executionPlan.isIterationContractTarget)){let o=s.map(u=>u.executionPlan.iterationTarget);return this.fire(r.graph.lineage,"iterating",s),r.iterate(o)}return this.fire(r.graph.lineage,"executing",s),r.call()},t,i,n;for(;(i=this.$thread.sequence.shift())&&(n=[...this.$thread.entries.get(i)])&&this.$thread.entries.delete(i);)t=$(t,()=>{if(i.disposed||!i.filterRefs(n).length)return;this.$thread.current=i;let r=e(i,n);return $(r,()=>{for(let s of n)[].concat(s.executionPlan.assigneeRef||s.executionPlan.assigneeRefs||[]).forEach(o=>{i.buildThread([],o,[],0)})}),r});return $(t,()=>{let r=this.exits.get("return");return this.exits.clear(),this.$thread.current=null,this.$thread.active=!1,r})}buildThread(e,t,i,n=0,r=!1){let s=n>0;if(this.ownerContract){if(!this.compute(i)||t.condition!==void 0&&!this.assert(t.condition))return}else s||(s=i.length||t.condition!==void 0);let o=r?t.$subscriptions:t.subscriptions;Object.keys(o).forEach(u=>{let[h,m]=u.split(":"),a=l=>{!l||l.selectRefs(m,o[u],s?e:null)},b=this.locate(h);Array.isArray(b)?b.forEach(a):a(b)})}selectRefs(e,t,i=null){let n=this.$thread,r=this.graph.signals[e],s=(u,h)=>u.graph.lineage.localeCompare(h.graph.lineage,void 0,{numeric:!0}),o=(u,h=[],m={})=>{if(!n.active||n.current&&s(this,n.current)<0)return;let a=n.entries.get(this);if(a||(a=new Set,n.entries.set(this,a),n.sequence.push(this),n.sequence.sort(s)),a.add({...u,computes:h,executionPlan:m}),!m.assigneeRef&&["VariableDeclaration","AssignmentExpression"].includes(this.graph.type)){m.assigneeRefs=[];for(let b in this.graph.effects)m.assigneeRefs.push(...this.graph.effects[b].refs)}};for(let u of t){let h=r.refs[u];if(!i){o(h);continue}let[m,a,b]=this.matchRefs(i,h);if(!m)continue;if(a<=0){o(h,b);continue}let l=i.slice(-a),c="assignee"in r?this.graph.effects[r.assignee]:null;if(c){c.refs.forEach(p=>{if(p.depth.length){let[f,d,x]=this.matchRefs(l,p.depth),y=b.concat(x);if(f&&d>0){let w=p.path.concat(l.slice(-d));this.buildThread(w,p,y,d)}else f&&o(h,y,{assigneeRef:p})}else{let f=p.path.concat(l);this.buildThread(f,p,b,a)}});continue}if(a===1&&this.graph.type==="ForOfStatement"){o(h,b,{isIterationContractTarget:!0,iterationTarget:l[0]});continue}if(a===1&&this.graph.type==="ForInStatement"){o(h,b,{isIterationContractTarget:!0,iterationTarget:l[0]});continue}}}filterRefs(e){return e.filter(t=>{if(!!this.compute(t.computes)&&!(t.condition!==void 0&&!this.assert(t.condition)))return!0})}matchRefs(e,t){let i,n,r,s;Array.isArray(e)?(i=e,n=e.dotSafe?e.join("."):void 0):(i=e.path,n=e.$path),Array.isArray(t)?(r=t,s=t.dotSafe?t.join("."):void 0):(r=t.path,s=t.$path);let o=i.length-r.length;if(o>0&&([i,r,n,s]=[r,i,s,n]),n&&s)return[`${s}.`.startsWith(`${n}.`),o,[]];let u=[],h=a=>typeof a=="object"?a.name:a,m=(a,b)=>{if(!a||!b)return!1;let l=typeof a=="object"&&"memoId"in a,c=typeof b=="object"&&"memoId"in b;return l||c?(u.push(p=>(l?p[a.memoId]:h(a))===(c?p[b.memoId]:h(b))),!0):h(a)===h(b)};return[i.reduce((a,b,l)=>a&&m(b,r[l]),!0),o,u]}locate(e){let t=this.graph.lineage+"/",i=e+"/";if(i===t)return this;if(i.startsWith(t)){let n=e.slice(t.length).split("/"),r=this.subContracts.get(parseInt(n.shift()));if(n.length){if(r instanceof Map)return Array.from(r).reduce((s,[o,u])=>s.concat(u.locate(e)),[]);if(r)return r.locate(e)}return r}if(this.ownerContract)return this.ownerContract.locate(e)}compute(e){return!e.some(t=>t(this.contract.memo)===!1)}assert(e){if(typeof e=="string"&&e.includes(":")){let[n,r]=e.split(":");return this.locate(n).assert(r)}let t=this.graph.conditions[e],i=this.contract.memo;return typeof t.parent<"u"&&!this.assert(t.parent)?!1:typeof t.switch<"u"?t.cases.some(n=>i[n]===i[t.switch]):typeof t.whenNot<"u"?!i[t.whenNot]:typeof t.when<"u"?i[t.when]:!0}dispose(){this.params.isFunctionContract||(this.subContracts.forEach((e,t)=>{e instanceof Map?(e.forEach(i=>i.dispose()),e.clear()):e.dispose()}),this.subContracts.clear(),delete this.ownerContract,delete this.callee,delete this.params,delete this.contract.memo,this.disposed=!0)}createFunction(e,t=void 0){let i=e(),n=function(s,...o){let u=s.call(this===void 0?t:this,...o);return s.params.isSubscriptFunction&&s.params.apiVersion>1&&(u=$(u,h=>[h,s.thread.bind(s),s]),i=e(i)),u},r=i instanceof Promise||i.callee instanceof async function(){}.constructor?async function(){return $(i,s=>n.call(this,s,...arguments))}:function(){return n.call(this,i,...arguments)};return $(i,s=>{this.applyReflection(r,s)}),q(r,"properties",$(i,s=>{let o={type:s.params.functionType||"Program",apiVersion:s.params.apiVersion||1,isSubscriptFunction:s.params.isSubscriptFunction,sideEffects:s.graph.sideEffects||!1};if(s.params.isSubscriptFunction){o.dependencies=[];for(let[u,h]of Object.entries(s.graph.effects))o.dependencies.push(...h.refs.map(m=>m.path.map(a=>"name"in a?a.name:1/0)))}return o})),r}applyReflection(e,t){Object.defineProperty(t.callee,"length",{configurable:!0,value:t.callee.length-1});let i=t.callee.toString();Object.defineProperty(t.callee,"toString",{configurable:!0,value:(r=!1)=>!r&&t.graph.originalSource?t.graph.originalSource:i});let n={name:t.callee.name,length:t.callee.length,toString:t.callee.toString};t.params.isSubscriptFunction&&(t.params.apiVersion>1||(n={...n,thread:t.thread.bind(t),dispose:t.dispose.bind(t),runtime:t})),Object.keys(n).forEach(r=>{Object.defineProperty(e,r,{configurable:!0,value:n[r]})})}};var V=class extends j{static create(e,t=[],i={}){let r=i.async||e.graph.hoistedAwaitKeyword?Object.getPrototypeOf(async function(){}).constructor:Function,s=i.compileFunction?i.compileFunction(e.source,[e.identifier+""].concat(t)):new r(e.identifier+"",...t,e.source);return new this(null,e.graph,s,i)}static createFunction(e,t,i=[],n={},r,s=null){n={...n,functionType:"Constructor"},t instanceof Promise&&(n={...n,async:!0});let o=m=>m?new this(null,m.graph,m.callee,n):$(t,a=>u(this.create(a,i,n))),u=m=>{if(m.graph.originalSource&&!m.graph.originalSourceModified){let a=`${n.async||m.graph.hoistedAwaitKeyword?"async ":""}function ${e||"anonymous"}`,b=m.graph.originalSource.split(/\n/g).map(l=>` ${l}`).join(`
`]}};customElements.define("cfunctions-inspector",Q);function ce(...v){let e={runtimeParams:be,compilerParams:me,parserParams:ge},t;for(;t=v.shift();){let{runtimeParams:i={},compilerParams:{globalsNoObserve:n=[],globalsOnlyPathsExcept:r=[],...s}={},parserParams:o={}}=t;e={runtimeParams:{...e.runtimeParams,...i},compilerParams:{...e.compilerParams,globalsNoObserve:[...e.compilerParams.globalsNoObserve,...n],globalsOnlyPathsExcept:[...e.compilerParams.globalsOnlyPathsExcept,...r],...s},parserParams:{...e.parserParams,...o}},v.devMode}return e}var ge={ecmaVersion:"2020",allowReturnOutsideFunction:!0,allowAwaitOutsideFunction:!0,allowSuperOutsideMethod:!0,preserveParens:!1,locations:!1},me={globalsNoObserve:["arguments","debugger"],globalsOnlyPathsExcept:[],originalSource:!0,locations:!0,compact:2},be={apiVersion:1};var ue=new Map;function q(v,e,t=void 0){let i=ue.get(v);if(arguments.length>2){i||(i=new Map,ue.set(v,i)),i.set(e,t);return}return i&&i.get(e)}var j=class{constructor(e,t,i,n={},r=null,s=null){this.ownerContract=e,this.graph=t,this.callee=i,this.params=e?n:{...n,isSubscriptFunction:!0},this.exits=s||new Map,this.$thread=r||{entries:new Map,sequence:[],ownerContract:this},this.subContracts=new Map,this.observers=[],this.contract=function(o,u,h=null,m=null){if(!this.graph.subContracts[o])throw new Error(`[${this.graph.type}:${this.graph.lineage}]: Graph not found for child contract ${o}.`);let a=this.graph.subContracts[o],b={...this.params,isIterationContract:arguments.length===3,iterationId:arguments.length===3&&u,isFunctionContract:arguments.length===4,functionType:arguments.length===4&&u,isSubscriptFunction:arguments.length===4&&h,functionScope:this.params.isFunctionContract&&this.graph.lineage||this.params.functionScope};if(b.isIterationContract){let f=h,d=new j(this,a,f,b,this.$thread,this.exits),x=this.subContracts.get(o);return x||(x=new Map,this.subContracts.set(o,x)),x.has(b.iterationId)&&x.get(b.iterationId).dispose(),x.set(b.iterationId,d),d.call()}let l,c,p;if(this.subContracts.has(o)&&this.subContracts.get(o).dispose(),b.isFunctionContract){l=m;let f=()=>new j(this,a,l,b);if(b.functionType!=="FunctionDeclaration")p=this.createFunction(f);else{let d=f();b.apiVersion>1?(p=function(...x){let y=d.call(this,...x);return y=$(y,w=>[y,d.thread.bind(d),d]),d=f(),y},p.target=d):p=d}}else l=u,c=new j(this,a,l,b,this.$thread,this.exits),this.subContracts.set(o,c),p=c.call();return p}.bind(this),this.contract.memo=Object.create(null),this.ownerContract&&!["FunctionDeclaration","FunctionExpression"].includes(this.graph.type)&&(this.contract.args=this.ownerContract.contract.args),this.contract.exiting=function(o,u){if(!arguments.length)return this.exits.size;let h=this.exits.get(o)===u;return h&&this.exits.clear(),h}.bind(this),this.contract.exit=function(o,u){this.exits.set(o,u)}.bind(this),this.contract.functions=new Map,this.contract.functions.declaration=(o,u)=>{this.contract.functions.set(o,u),this.applyReflection(o,typeof u=="function"?u.target:u)}}fire(e,t,i){if(!this.ownerContract)return;let n=this.ownerContract.fire(e,t,i);return this.observers.forEach(r=>{r.contractUrl===e&&r.callback(t,i)}),n}observe(e,t){!this.params.isFunctionContract||this.observers.push({contractUrl:e,callback:t})}call(e,...t){if(this.disposed)throw new Error(`[${this.graph.type}:${this.graph.lineage}]: Instance not runable after having been disposed.`);this.ownerContract||(this.contract.args=t,Object.defineProperty(this.contract.args,Symbol.toStringTag,{value:"Arguments"}));let i=this.callee.call(e,this.contract,...t);if(this.graph.$sideEffects)for(let n in this.graph.effects)for(let r of this.graph.effects[n].refs)this.buildThread([],r,[],0,!0);return $(i,()=>{if(!this.ownerContract||this.params.isFunctionContract){let n=this.exits.get("return");if(this.exits.clear(),n!==void 0)return n}return i})}iterate(e=[]){if(this.disposed)return!1;if(!["ForOfStatement","ForInStatement"].includes(this.graph.type)||this.subContracts.size!==1)throw new Error(`Contract ${this.graph.lineage} is not an iterator.`);let[[,t]]=this.subContracts,i;if(!e.length||e.includes("length")&&this.graph.type==="ForOfStatement")for(let[,n]of t)i=$(i,()=>n.call());else for(let n of e){let r=t.get(n)||t.get(parseInt(n));!r||(i=$(i,()=>r.call()))}return i}thread(...e){if(this.disposed)return!1;this.$thread.active=!0;for(let t in this.graph.effects)for(let i of this.graph.effects[t].refs)for(let n of e){let[r,s,o]=this.matchRefs(n,i);!r||this.buildThread(n,i,o,s)}return this.runThread()}runThread(){let e=(r,s)=>{if(["ForOfStatement","ForInStatement"].includes(r.graph.type)&&s.every(o=>o.executionPlan.isIterationContractTarget)){let o=s.map(u=>u.executionPlan.iterationTarget);return this.fire(r.graph.lineage,"iterating",s),r.iterate(o)}return this.fire(r.graph.lineage,"executing",s),r.call()},t,i,n;for(;(i=this.$thread.sequence.shift())&&(n=[...this.$thread.entries.get(i)])&&this.$thread.entries.delete(i);)t=$(t,()=>{if(i.disposed||!i.filterRefs(n).length)return;this.$thread.current=i;let r=e(i,n);return $(r,()=>{for(let s of n)[].concat(s.executionPlan.assigneeRef||s.executionPlan.assigneeRefs||[]).forEach(o=>{i.buildThread([],o,[],0)})}),r});return $(t,()=>{let r=this.exits.get("return");return this.exits.clear(),this.$thread.current=null,this.$thread.active=!1,r})}buildThread(e,t,i,n=0,r=!1){let s=n>0;if(this.ownerContract){if(!this.compute(i)||t.condition!==void 0&&!this.assert(t.condition))return}else s||(s=i.length||t.condition!==void 0);let o=r?t.$subscriptions:t.subscriptions;Object.keys(o).forEach(u=>{let[h,m]=u.split(":"),a=l=>{!l||l.selectRefs(m,o[u],s?e:null)},b=this.locate(h);Array.isArray(b)?b.forEach(a):a(b)})}selectRefs(e,t,i=null){let n=this.$thread,r=this.graph.signals[e],s=(u,h)=>u.graph.lineage.localeCompare(h.graph.lineage,void 0,{numeric:!0}),o=(u,h=[],m={})=>{if(!n.active||n.current&&s(this,n.current)<0)return;let a=n.entries.get(this);if(a||(a=new Set,n.entries.set(this,a),n.sequence.push(this),n.sequence.sort(s)),a.add({...u,computes:h,executionPlan:m}),!m.assigneeRef&&["VariableDeclaration","AssignmentExpression"].includes(this.graph.type)){m.assigneeRefs=[];for(let b in this.graph.effects)m.assigneeRefs.push(...this.graph.effects[b].refs)}};for(let u of t){let h=r.refs[u];if(!i){o(h);continue}let[m,a,b]=this.matchRefs(i,h);if(!m)continue;if(a<=0){o(h,b);continue}let l=i.slice(-a),c="assignee"in r?this.graph.effects[r.assignee]:null;if(c){c.refs.forEach(p=>{if(p.depth.length){let[f,d,x]=this.matchRefs(l,p.depth),y=b.concat(x);if(f&&d>0){let w=p.path.concat(l.slice(-d));this.buildThread(w,p,y,d)}else f&&o(h,y,{assigneeRef:p})}else{let f=p.path.concat(l);this.buildThread(f,p,b,a)}});continue}if(a===1&&this.graph.type==="ForOfStatement"){o(h,b,{isIterationContractTarget:!0,iterationTarget:l[0]});continue}if(a===1&&this.graph.type==="ForInStatement"){o(h,b,{isIterationContractTarget:!0,iterationTarget:l[0]});continue}}}filterRefs(e){return e.filter(t=>{if(!!this.compute(t.computes)&&!(t.condition!==void 0&&!this.assert(t.condition)))return!0})}matchRefs(e,t){let i,n,r,s;Array.isArray(e)?(i=e,n=e.dotSafe?e.join("."):void 0):(i=e.path,n=e.$path),Array.isArray(t)?(r=t,s=t.dotSafe?t.join("."):void 0):(r=t.path,s=t.$path);let o=i.length-r.length;if(o>0&&([i,r,n,s]=[r,i,s,n]),n&&s)return[`${s}.`.startsWith(`${n}.`),o,[]];let u=[],h=a=>typeof a=="object"?a.name:a,m=(a,b)=>{if(!a||!b)return!1;let l=typeof a=="object"&&"memoId"in a,c=typeof b=="object"&&"memoId"in b;return l||c?(u.push(p=>(l?p[a.memoId]:h(a))===(c?p[b.memoId]:h(b))),!0):h(a)===h(b)};return[i.reduce((a,b,l)=>a&&m(b,r[l]),!0),o,u]}locate(e){let t=this.graph.lineage+"/",i=e+"/";if(i===t)return this;if(i.startsWith(t)){let n=e.slice(t.length).split("/"),r=this.subContracts.get(parseInt(n.shift()));if(n.length){if(r instanceof Map)return Array.from(r).reduce((s,[o,u])=>s.concat(u.locate(e)),[]);if(r)return r.locate(e)}return r}if(this.ownerContract)return this.ownerContract.locate(e)}compute(e){return!e.some(t=>t(this.contract.memo)===!1)}assert(e){if(typeof e=="string"&&e.includes(":")){let[n,r]=e.split(":");return this.locate(n).assert(r)}let t=this.graph.conditions[e],i=this.contract.memo;return typeof t.parent<"u"&&!this.assert(t.parent)?!1:typeof t.switch<"u"?t.cases.some(n=>i[n]===i[t.switch]):typeof t.whenNot<"u"?!i[t.whenNot]:typeof t.when<"u"?i[t.when]:!0}dispose(){this.params.isFunctionContract||(this.subContracts.forEach((e,t)=>{e instanceof Map?(e.forEach(i=>i.dispose()),e.clear()):e.dispose()}),this.subContracts.clear(),delete this.ownerContract,delete this.callee,delete this.params,delete this.contract.memo,this.disposed=!0)}createFunction(e,t=void 0){let i=e(),n=function(s,...o){let u=s.call(this===void 0?t:this,...o);return s.params.isSubscriptFunction&&s.params.apiVersion>1&&(u=$(u,h=>[h,s.thread.bind(s),s]),i=e(i)),u},r=i instanceof Promise||i.callee instanceof async function(){}.constructor?async function(){return $(i,s=>n.call(this,s,...arguments))}:function(){return n.call(this,i,...arguments)};return $(i,s=>{this.applyReflection(r,s)}),q(r,"properties",$(i,s=>{let o={type:s.params.functionType||"Program",apiVersion:s.params.apiVersion||1,isSubscriptFunction:s.params.isSubscriptFunction,sideEffects:s.graph.sideEffects||!1};if(s.params.isSubscriptFunction){o.dependencies=[];for(let[u,h]of Object.entries(s.graph.effects))o.dependencies.push(...h.refs.map(m=>m.path.map(a=>"name"in a?a.name:1/0)))}return o})),r}applyReflection(e,t){Object.defineProperty(t.callee,"length",{configurable:!0,value:t.callee.length-1});let i=t.callee.toString();Object.defineProperty(t.callee,"toString",{configurable:!0,value:(r=!1)=>!r&&t.graph.originalSource?t.graph.originalSource:i});let n={name:t.callee.name,length:t.callee.length,toString:t.callee.toString};t.params.isSubscriptFunction&&(t.params.apiVersion>1||(n={...n,thread:t.thread.bind(t),dispose:t.dispose.bind(t),runtime:t})),Object.keys(n).forEach(r=>{Object.defineProperty(e,r,{configurable:!0,value:n[r]})})}};var V=class extends j{static create(e,t=[],i={}){let r=i.async||e.graph.hoistedAwaitKeyword?Object.getPrototypeOf(async function(){}).constructor:Function,s=i.compileFunction?i.compileFunction(e.source,[e.identifier+""].concat(t)):new r(e.identifier+"",...t,e.source);return new this(null,e.graph,s,i)}static createFunction(e,t,i=[],n={},r,s=null){n={...n,functionType:"Constructor"},t instanceof Promise&&(n={...n,async:!0});let o=m=>m?new this(null,m.graph,m.callee,n):$(t,a=>u(this.create(a,i,n))),u=m=>{if(m.graph.originalSource&&!m.graph.originalSourceModified){let a=`${n.async||m.graph.hoistedAwaitKeyword?"async ":""}function ${e||"anonymous"}`,b=m.graph.originalSource.split(/\n/g).map(l=>` ${l}`).join(`
`);m.graph.originalSource=`${a}(${i.join(", ")}) {

@@ -192,0 +192,0 @@ ${b}

@@ -1,5 +0,5 @@

(()=>{function v(...f){let t={runtimeParams:A,compilerParams:I,parserParams:E},e;for(;e=f.shift();){let{runtimeParams:r={},compilerParams:{globalsNoObserve:i=[],globalsOnlyPathsExcept:n=[],...s}={},parserParams:o={}}=e;t={runtimeParams:{...t.runtimeParams,...r},compilerParams:{...t.compilerParams,globalsNoObserve:[...t.compilerParams.globalsNoObserve,...i],globalsOnlyPathsExcept:[...t.compilerParams.globalsOnlyPathsExcept,...n],...s},parserParams:{...t.parserParams,...o}},f.devMode}return t}var E={ecmaVersion:"2020",allowReturnOutsideFunction:!0,allowAwaitOutsideFunction:!0,allowSuperOutsideMethod:!0,preserveParens:!1,locations:!1},I={globalsNoObserve:["globalThis","arguments","console","debugger"],globalsOnlyPathsExcept:[],originalSource:!0,locations:!0,compact:2},A={apiVersion:1};function O(f,t=!1){let e=f.split(/\n/g);if(e.length>1){for(;!e[0].trim().length;)e.shift();let r=e[t?1:0].split(/[^\s]/)[0].length;if(r)return e.map((i,n)=>{let s=i.substring(0,r);return s.trim().length?s.trim()==="}"&&n===e.length-1?"}":i:i.substring(r)}).join(`
`)}return f}var m=(f,t)=>f instanceof Promise?f.then(t):t(f);var j=new Map;function x(f,t,e=void 0){let r=j.get(f);if(arguments.length>2){r||(r=new Map,j.set(f,r)),r.set(t,e);return}return r&&r.get(t)}var S=class{constructor(t,e,r,i={},n=null,s=null){this.ownerContract=t,this.graph=e,this.callee=r,this.params=t?i:{...i,isSubscriptFunction:!0},this.exits=s||new Map,this.$thread=n||{entries:new Map,sequence:[],ownerContract:this},this.subContracts=new Map,this.observers=[],this.contract=function(o,l,u=null,h=null){if(!this.graph.subContracts[o])throw new Error(`[${this.graph.type}:${this.graph.lineage}]: Graph not found for child contract ${o}.`);let a=this.graph.subContracts[o],c={...this.params,isIterationContract:arguments.length===3,iterationId:arguments.length===3&&l,isFunctionContract:arguments.length===4,functionType:arguments.length===4&&l,isSubscriptFunction:arguments.length===4&&u,functionScope:this.params.isFunctionContract&&this.graph.lineage||this.params.functionScope};if(c.isIterationContract){let b=u,g=new S(this,a,b,c,this.$thread,this.exits),w=this.subContracts.get(o);return w||(w=new Map,this.subContracts.set(o,w)),w.has(c.iterationId)&&w.get(c.iterationId).dispose(),w.set(c.iterationId,g),g.call()}let p,y,d;if(this.subContracts.has(o)&&this.subContracts.get(o).dispose(),c.isFunctionContract){p=h;let b=()=>new S(this,a,p,c);if(c.functionType!=="FunctionDeclaration")d=this.createFunction(b);else{let g=b();c.apiVersion>1?(d=function(...w){let C=g.call(this,...w);return C=m(C,$=>[C,g.thread.bind(g),g]),g=b(),C},d.target=g):d=g}}else p=l,y=new S(this,a,p,c,this.$thread,this.exits),this.subContracts.set(o,y),d=y.call();return d}.bind(this),this.contract.memo=Object.create(null),this.ownerContract&&!["FunctionDeclaration","FunctionExpression"].includes(this.graph.type)&&(this.contract.args=this.ownerContract.contract.args),this.contract.exiting=function(o,l){if(!arguments.length)return this.exits.size;let u=this.exits.get(o)===l;return u&&this.exits.clear(),u}.bind(this),this.contract.exit=function(o,l){this.exits.set(o,l)}.bind(this),this.contract.functions=new Map,this.contract.functions.declaration=(o,l)=>{this.contract.functions.set(o,l),this.applyReflection(o,typeof l=="function"?l.target:l)}}fire(t,e,r){if(!this.ownerContract)return;let i=this.ownerContract.fire(t,e,r);return this.observers.forEach(n=>{n.contractUrl===t&&n.callback(e,r)}),i}observe(t,e){!this.params.isFunctionContract||this.observers.push({contractUrl:t,callback:e})}call(t,...e){if(this.disposed)throw new Error(`[${this.graph.type}:${this.graph.lineage}]: Instance not runable after having been disposed.`);this.ownerContract||(this.contract.args=e,Object.defineProperty(this.contract.args,Symbol.toStringTag,{value:"Arguments"}));let r=this.callee.call(t,this.contract,...e);if(this.graph.$sideEffects)for(let i in this.graph.effects)for(let n of this.graph.effects[i].refs)this.buildThread([],n,[],0,!0);return m(r,()=>{if(!this.ownerContract||this.params.isFunctionContract){let i=this.exits.get("return");if(this.exits.clear(),i!==void 0)return i}return r})}iterate(t=[]){if(this.disposed)return!1;if(!["ForOfStatement","ForInStatement"].includes(this.graph.type)||this.subContracts.size!==1)throw new Error(`Contract ${this.graph.lineage} is not an iterator.`);let[[,e]]=this.subContracts,r;if(!t.length||t.includes("length")&&this.graph.type==="ForOfStatement")for(let[,i]of e)r=m(r,()=>i.call());else for(let i of t){let n=e.get(i)||e.get(parseInt(i));!n||(r=m(r,()=>n.call()))}return r}thread(...t){if(this.disposed)return!1;this.$thread.active=!0;for(let e in this.graph.effects)for(let r of this.graph.effects[e].refs)for(let i of t){let[n,s,o]=this.matchRefs(i,r);!n||this.buildThread(i,r,o,s)}return this.runThread()}runThread(){let t=(n,s)=>{if(["ForOfStatement","ForInStatement"].includes(n.graph.type)&&s.every(o=>o.executionPlan.isIterationContractTarget)){let o=s.map(l=>l.executionPlan.iterationTarget);return this.fire(n.graph.lineage,"iterating",s),n.iterate(o)}return this.fire(n.graph.lineage,"executing",s),n.call()},e,r,i;for(;(r=this.$thread.sequence.shift())&&(i=[...this.$thread.entries.get(r)])&&this.$thread.entries.delete(r);)e=m(e,()=>{if(r.disposed||!r.filterRefs(i).length)return;this.$thread.current=r;let n=t(r,i);return m(n,()=>{for(let s of i)[].concat(s.executionPlan.assigneeRef||s.executionPlan.assigneeRefs||[]).forEach(o=>{r.buildThread([],o,[],0)})}),n});return m(e,()=>{let n=this.exits.get("return");return this.exits.clear(),this.$thread.current=null,this.$thread.active=!1,n})}buildThread(t,e,r,i=0,n=!1){let s=i>0;if(this.ownerContract){if(!this.compute(r)||e.condition!==void 0&&!this.assert(e.condition))return}else s||(s=r.length||e.condition!==void 0);let o=n?e.$subscriptions:e.subscriptions;Object.keys(o).forEach(l=>{let[u,h]=l.split(":"),a=p=>{!p||p.selectRefs(h,o[l],s?t:null)},c=this.locate(u);Array.isArray(c)?c.forEach(a):a(c)})}selectRefs(t,e,r=null){let i=this.$thread,n=this.graph.signals[t],s=(l,u)=>l.graph.lineage.localeCompare(u.graph.lineage,void 0,{numeric:!0}),o=(l,u=[],h={})=>{if(!i.active||i.current&&s(this,i.current)<0)return;let a=i.entries.get(this);if(a||(a=new Set,i.entries.set(this,a),i.sequence.push(this),i.sequence.sort(s)),a.add({...l,computes:u,executionPlan:h}),!h.assigneeRef&&["VariableDeclaration","AssignmentExpression"].includes(this.graph.type)){h.assigneeRefs=[];for(let c in this.graph.effects)h.assigneeRefs.push(...this.graph.effects[c].refs)}};for(let l of e){let u=n.refs[l];if(!r){o(u);continue}let[h,a,c]=this.matchRefs(r,u);if(!h)continue;if(a<=0){o(u,c);continue}let p=r.slice(-a),y="assignee"in n?this.graph.effects[n.assignee]:null;if(y){y.refs.forEach(d=>{if(d.depth.length){let[b,g,w]=this.matchRefs(p,d.depth),C=c.concat(w);if(b&&g>0){let $=d.path.concat(p.slice(-g));this.buildThread($,d,C,g)}else b&&o(u,C,{assigneeRef:d})}else{let b=d.path.concat(p);this.buildThread(b,d,c,a)}});continue}if(a===1&&this.graph.type==="ForOfStatement"){o(u,c,{isIterationContractTarget:!0,iterationTarget:p[0]});continue}if(a===1&&this.graph.type==="ForInStatement"){o(u,c,{isIterationContractTarget:!0,iterationTarget:p[0]});continue}}}filterRefs(t){return t.filter(e=>{if(!!this.compute(e.computes)&&!(e.condition!==void 0&&!this.assert(e.condition)))return!0})}matchRefs(t,e){let r,i,n,s;Array.isArray(t)?(r=t,i=t.dotSafe?t.join("."):void 0):(r=t.path,i=t.$path),Array.isArray(e)?(n=e,s=e.dotSafe?e.join("."):void 0):(n=e.path,s=e.$path);let o=r.length-n.length;if(o>0&&([r,n,i,s]=[n,r,s,i]),i&&s)return[`${s}.`.startsWith(`${i}.`),o,[]];let l=[],u=a=>typeof a=="object"?a.name:a,h=(a,c)=>{if(!a||!c)return!1;let p=typeof a=="object"&&"memoId"in a,y=typeof c=="object"&&"memoId"in c;return p||y?(l.push(d=>(p?d[a.memoId]:u(a))===(y?d[c.memoId]:u(c))),!0):u(a)===u(c)};return[r.reduce((a,c,p)=>a&&h(c,n[p]),!0),o,l]}locate(t){let e=this.graph.lineage+"/",r=t+"/";if(r===e)return this;if(r.startsWith(e)){let i=t.slice(e.length).split("/"),n=this.subContracts.get(parseInt(i.shift()));if(i.length){if(n instanceof Map)return Array.from(n).reduce((s,[o,l])=>s.concat(l.locate(t)),[]);if(n)return n.locate(t)}return n}if(this.ownerContract)return this.ownerContract.locate(t)}compute(t){return!t.some(e=>e(this.contract.memo)===!1)}assert(t){if(typeof t=="string"&&t.includes(":")){let[i,n]=t.split(":");return this.locate(i).assert(n)}let e=this.graph.conditions[t],r=this.contract.memo;return typeof e.parent<"u"&&!this.assert(e.parent)?!1:typeof e.switch<"u"?e.cases.some(i=>r[i]===r[e.switch]):typeof e.whenNot<"u"?!r[e.whenNot]:typeof e.when<"u"?r[e.when]:!0}dispose(){this.params.isFunctionContract||(this.subContracts.forEach((t,e)=>{t instanceof Map?(t.forEach(r=>r.dispose()),t.clear()):t.dispose()}),this.subContracts.clear(),delete this.ownerContract,delete this.callee,delete this.params,delete this.contract.memo,this.disposed=!0)}createFunction(t,e=void 0){let r=t(),i=function(s,...o){let l=s.call(this===void 0?e:this,...o);return s.params.isSubscriptFunction&&s.params.apiVersion>1&&(l=m(l,u=>[u,s.thread.bind(s),s]),r=t(r)),l},n=r instanceof Promise||r.callee instanceof async function(){}.constructor?async function(){return m(r,s=>i.call(this,s,...arguments))}:function(){return i.call(this,r,...arguments)};return m(r,s=>{this.applyReflection(n,s)}),x(n,"properties",m(r,s=>{let o={type:s.params.functionType||"Program",apiVersion:s.params.apiVersion||1,isSubscriptFunction:s.params.isSubscriptFunction,sideEffects:s.graph.sideEffects||!1};if(s.params.isSubscriptFunction){o.dependencies=[];for(let[l,u]of Object.entries(s.graph.effects))o.dependencies.push(...u.refs.map(h=>h.path.map(a=>"name"in a?a.name:1/0)))}return o})),n}applyReflection(t,e){Object.defineProperty(e.callee,"length",{configurable:!0,value:e.callee.length-1});let r=e.callee.toString();Object.defineProperty(e.callee,"toString",{configurable:!0,value:(n=!1)=>!n&&e.graph.originalSource?e.graph.originalSource:r});let i={name:e.callee.name,length:e.callee.length,toString:e.callee.toString};e.params.isSubscriptFunction&&(e.params.apiVersion>1||(i={...i,thread:e.thread.bind(e),dispose:e.dispose.bind(e),runtime:e})),Object.keys(i).forEach(n=>{Object.defineProperty(t,n,{configurable:!0,value:i[n]})})}};var F=class extends S{static create(t,e=[],r={}){let n=r.async||t.graph.hoistedAwaitKeyword?Object.getPrototypeOf(async function(){}).constructor:Function,s=r.compileFunction?r.compileFunction(t.source,[t.identifier+""].concat(e)):new n(t.identifier+"",...e,t.source);return new this(null,t.graph,s,r)}static createFunction(t,e,r=[],i={},n,s=null){i={...i,functionType:"Constructor"},e instanceof Promise&&(i={...i,async:!0});let o=h=>h?new this(null,h.graph,h.callee,i):m(e,a=>l(this.create(a,r,i))),l=h=>{if(h.graph.originalSource&&!h.graph.originalSourceModified){let a=`${i.async||h.graph.hoistedAwaitKeyword?"async ":""}function ${t||"anonymous"}`,c=h.graph.originalSource.split(/\n/g).map(p=>` ${p}`).join(`
(()=>{function v(...f){let t={runtimeParams:A,compilerParams:I,parserParams:E},e;for(;e=f.shift();){let{runtimeParams:r={},compilerParams:{globalsNoObserve:i=[],globalsOnlyPathsExcept:n=[],...s}={},parserParams:o={}}=e;t={runtimeParams:{...t.runtimeParams,...r},compilerParams:{...t.compilerParams,globalsNoObserve:[...t.compilerParams.globalsNoObserve,...i],globalsOnlyPathsExcept:[...t.compilerParams.globalsOnlyPathsExcept,...n],...s},parserParams:{...t.parserParams,...o}},f.devMode}return t}var E={ecmaVersion:"2020",allowReturnOutsideFunction:!0,allowAwaitOutsideFunction:!0,allowSuperOutsideMethod:!0,preserveParens:!1,locations:!1},I={globalsNoObserve:["arguments","debugger"],globalsOnlyPathsExcept:[],originalSource:!0,locations:!0,compact:2},A={apiVersion:1};function O(f,t=!1){let e=f.split(/\n/g);if(e.length>1){for(;!e[0].trim().length;)e.shift();let r=e[t?1:0].split(/[^\s]/)[0].length;if(r)return e.map((i,n)=>{let s=i.substring(0,r);return s.trim().length?s.trim()==="}"&&n===e.length-1?"}":i:i.substring(r)}).join(`
`)}return f}var m=(f,t)=>f instanceof Promise?f.then(t):t(f);var j=new Map;function x(f,t,e=void 0){let r=j.get(f);if(arguments.length>2){r||(r=new Map,j.set(f,r)),r.set(t,e);return}return r&&r.get(t)}var S=class{constructor(t,e,r,i={},n=null,s=null){this.ownerContract=t,this.graph=e,this.callee=r,this.params=t?i:{...i,isSubscriptFunction:!0},this.exits=s||new Map,this.$thread=n||{entries:new Map,sequence:[],ownerContract:this},this.subContracts=new Map,this.observers=[],this.contract=function(o,c,u=null,h=null){if(!this.graph.subContracts[o])throw new Error(`[${this.graph.type}:${this.graph.lineage}]: Graph not found for child contract ${o}.`);let a=this.graph.subContracts[o],l={...this.params,isIterationContract:arguments.length===3,iterationId:arguments.length===3&&c,isFunctionContract:arguments.length===4,functionType:arguments.length===4&&c,isSubscriptFunction:arguments.length===4&&u,functionScope:this.params.isFunctionContract&&this.graph.lineage||this.params.functionScope};if(l.isIterationContract){let b=u,g=new S(this,a,b,l,this.$thread,this.exits),w=this.subContracts.get(o);return w||(w=new Map,this.subContracts.set(o,w)),w.has(l.iterationId)&&w.get(l.iterationId).dispose(),w.set(l.iterationId,g),g.call()}let p,y,d;if(this.subContracts.has(o)&&this.subContracts.get(o).dispose(),l.isFunctionContract){p=h;let b=()=>new S(this,a,p,l);if(l.functionType!=="FunctionDeclaration")d=this.createFunction(b);else{let g=b();l.apiVersion>1?(d=function(...w){let C=g.call(this,...w);return C=m(C,$=>[C,g.thread.bind(g),g]),g=b(),C},d.target=g):d=g}}else p=c,y=new S(this,a,p,l,this.$thread,this.exits),this.subContracts.set(o,y),d=y.call();return d}.bind(this),this.contract.memo=Object.create(null),this.ownerContract&&!["FunctionDeclaration","FunctionExpression"].includes(this.graph.type)&&(this.contract.args=this.ownerContract.contract.args),this.contract.exiting=function(o,c){if(!arguments.length)return this.exits.size;let u=this.exits.get(o)===c;return u&&this.exits.clear(),u}.bind(this),this.contract.exit=function(o,c){this.exits.set(o,c)}.bind(this),this.contract.functions=new Map,this.contract.functions.declaration=(o,c)=>{this.contract.functions.set(o,c),this.applyReflection(o,typeof c=="function"?c.target:c)}}fire(t,e,r){if(!this.ownerContract)return;let i=this.ownerContract.fire(t,e,r);return this.observers.forEach(n=>{n.contractUrl===t&&n.callback(e,r)}),i}observe(t,e){!this.params.isFunctionContract||this.observers.push({contractUrl:t,callback:e})}call(t,...e){if(this.disposed)throw new Error(`[${this.graph.type}:${this.graph.lineage}]: Instance not runable after having been disposed.`);this.ownerContract||(this.contract.args=e,Object.defineProperty(this.contract.args,Symbol.toStringTag,{value:"Arguments"}));let r=this.callee.call(t,this.contract,...e);if(this.graph.$sideEffects)for(let i in this.graph.effects)for(let n of this.graph.effects[i].refs)this.buildThread([],n,[],0,!0);return m(r,()=>{if(!this.ownerContract||this.params.isFunctionContract){let i=this.exits.get("return");if(this.exits.clear(),i!==void 0)return i}return r})}iterate(t=[]){if(this.disposed)return!1;if(!["ForOfStatement","ForInStatement"].includes(this.graph.type)||this.subContracts.size!==1)throw new Error(`Contract ${this.graph.lineage} is not an iterator.`);let[[,e]]=this.subContracts,r;if(!t.length||t.includes("length")&&this.graph.type==="ForOfStatement")for(let[,i]of e)r=m(r,()=>i.call());else for(let i of t){let n=e.get(i)||e.get(parseInt(i));!n||(r=m(r,()=>n.call()))}return r}thread(...t){if(this.disposed)return!1;this.$thread.active=!0;for(let e in this.graph.effects)for(let r of this.graph.effects[e].refs)for(let i of t){let[n,s,o]=this.matchRefs(i,r);!n||this.buildThread(i,r,o,s)}return this.runThread()}runThread(){let t=(n,s)=>{if(["ForOfStatement","ForInStatement"].includes(n.graph.type)&&s.every(o=>o.executionPlan.isIterationContractTarget)){let o=s.map(c=>c.executionPlan.iterationTarget);return this.fire(n.graph.lineage,"iterating",s),n.iterate(o)}return this.fire(n.graph.lineage,"executing",s),n.call()},e,r,i;for(;(r=this.$thread.sequence.shift())&&(i=[...this.$thread.entries.get(r)])&&this.$thread.entries.delete(r);)e=m(e,()=>{if(r.disposed||!r.filterRefs(i).length)return;this.$thread.current=r;let n=t(r,i);return m(n,()=>{for(let s of i)[].concat(s.executionPlan.assigneeRef||s.executionPlan.assigneeRefs||[]).forEach(o=>{r.buildThread([],o,[],0)})}),n});return m(e,()=>{let n=this.exits.get("return");return this.exits.clear(),this.$thread.current=null,this.$thread.active=!1,n})}buildThread(t,e,r,i=0,n=!1){let s=i>0;if(this.ownerContract){if(!this.compute(r)||e.condition!==void 0&&!this.assert(e.condition))return}else s||(s=r.length||e.condition!==void 0);let o=n?e.$subscriptions:e.subscriptions;Object.keys(o).forEach(c=>{let[u,h]=c.split(":"),a=p=>{!p||p.selectRefs(h,o[c],s?t:null)},l=this.locate(u);Array.isArray(l)?l.forEach(a):a(l)})}selectRefs(t,e,r=null){let i=this.$thread,n=this.graph.signals[t],s=(c,u)=>c.graph.lineage.localeCompare(u.graph.lineage,void 0,{numeric:!0}),o=(c,u=[],h={})=>{if(!i.active||i.current&&s(this,i.current)<0)return;let a=i.entries.get(this);if(a||(a=new Set,i.entries.set(this,a),i.sequence.push(this),i.sequence.sort(s)),a.add({...c,computes:u,executionPlan:h}),!h.assigneeRef&&["VariableDeclaration","AssignmentExpression"].includes(this.graph.type)){h.assigneeRefs=[];for(let l in this.graph.effects)h.assigneeRefs.push(...this.graph.effects[l].refs)}};for(let c of e){let u=n.refs[c];if(!r){o(u);continue}let[h,a,l]=this.matchRefs(r,u);if(!h)continue;if(a<=0){o(u,l);continue}let p=r.slice(-a),y="assignee"in n?this.graph.effects[n.assignee]:null;if(y){y.refs.forEach(d=>{if(d.depth.length){let[b,g,w]=this.matchRefs(p,d.depth),C=l.concat(w);if(b&&g>0){let $=d.path.concat(p.slice(-g));this.buildThread($,d,C,g)}else b&&o(u,C,{assigneeRef:d})}else{let b=d.path.concat(p);this.buildThread(b,d,l,a)}});continue}if(a===1&&this.graph.type==="ForOfStatement"){o(u,l,{isIterationContractTarget:!0,iterationTarget:p[0]});continue}if(a===1&&this.graph.type==="ForInStatement"){o(u,l,{isIterationContractTarget:!0,iterationTarget:p[0]});continue}}}filterRefs(t){return t.filter(e=>{if(!!this.compute(e.computes)&&!(e.condition!==void 0&&!this.assert(e.condition)))return!0})}matchRefs(t,e){let r,i,n,s;Array.isArray(t)?(r=t,i=t.dotSafe?t.join("."):void 0):(r=t.path,i=t.$path),Array.isArray(e)?(n=e,s=e.dotSafe?e.join("."):void 0):(n=e.path,s=e.$path);let o=r.length-n.length;if(o>0&&([r,n,i,s]=[n,r,s,i]),i&&s)return[`${s}.`.startsWith(`${i}.`),o,[]];let c=[],u=a=>typeof a=="object"?a.name:a,h=(a,l)=>{if(!a||!l)return!1;let p=typeof a=="object"&&"memoId"in a,y=typeof l=="object"&&"memoId"in l;return p||y?(c.push(d=>(p?d[a.memoId]:u(a))===(y?d[l.memoId]:u(l))),!0):u(a)===u(l)};return[r.reduce((a,l,p)=>a&&h(l,n[p]),!0),o,c]}locate(t){let e=this.graph.lineage+"/",r=t+"/";if(r===e)return this;if(r.startsWith(e)){let i=t.slice(e.length).split("/"),n=this.subContracts.get(parseInt(i.shift()));if(i.length){if(n instanceof Map)return Array.from(n).reduce((s,[o,c])=>s.concat(c.locate(t)),[]);if(n)return n.locate(t)}return n}if(this.ownerContract)return this.ownerContract.locate(t)}compute(t){return!t.some(e=>e(this.contract.memo)===!1)}assert(t){if(typeof t=="string"&&t.includes(":")){let[i,n]=t.split(":");return this.locate(i).assert(n)}let e=this.graph.conditions[t],r=this.contract.memo;return typeof e.parent<"u"&&!this.assert(e.parent)?!1:typeof e.switch<"u"?e.cases.some(i=>r[i]===r[e.switch]):typeof e.whenNot<"u"?!r[e.whenNot]:typeof e.when<"u"?r[e.when]:!0}dispose(){this.params.isFunctionContract||(this.subContracts.forEach((t,e)=>{t instanceof Map?(t.forEach(r=>r.dispose()),t.clear()):t.dispose()}),this.subContracts.clear(),delete this.ownerContract,delete this.callee,delete this.params,delete this.contract.memo,this.disposed=!0)}createFunction(t,e=void 0){let r=t(),i=function(s,...o){let c=s.call(this===void 0?e:this,...o);return s.params.isSubscriptFunction&&s.params.apiVersion>1&&(c=m(c,u=>[u,s.thread.bind(s),s]),r=t(r)),c},n=r instanceof Promise||r.callee instanceof async function(){}.constructor?async function(){return m(r,s=>i.call(this,s,...arguments))}:function(){return i.call(this,r,...arguments)};return m(r,s=>{this.applyReflection(n,s)}),x(n,"properties",m(r,s=>{let o={type:s.params.functionType||"Program",apiVersion:s.params.apiVersion||1,isSubscriptFunction:s.params.isSubscriptFunction,sideEffects:s.graph.sideEffects||!1};if(s.params.isSubscriptFunction){o.dependencies=[];for(let[c,u]of Object.entries(s.graph.effects))o.dependencies.push(...u.refs.map(h=>h.path.map(a=>"name"in a?a.name:1/0)))}return o})),n}applyReflection(t,e){Object.defineProperty(e.callee,"length",{configurable:!0,value:e.callee.length-1});let r=e.callee.toString();Object.defineProperty(e.callee,"toString",{configurable:!0,value:(n=!1)=>!n&&e.graph.originalSource?e.graph.originalSource:r});let i={name:e.callee.name,length:e.callee.length,toString:e.callee.toString};e.params.isSubscriptFunction&&(e.params.apiVersion>1||(i={...i,thread:e.thread.bind(e),dispose:e.dispose.bind(e),runtime:e})),Object.keys(i).forEach(n=>{Object.defineProperty(t,n,{configurable:!0,value:i[n]})})}};var F=class extends S{static create(t,e=[],r={}){let n=r.async||t.graph.hoistedAwaitKeyword?Object.getPrototypeOf(async function(){}).constructor:Function,s=r.compileFunction?r.compileFunction(t.source,[t.identifier+""].concat(e)):new n(t.identifier+"",...e,t.source);return new this(null,t.graph,s,r)}static createFunction(t,e,r=[],i={},n,s=null){i={...i,functionType:"Constructor"},e instanceof Promise&&(i={...i,async:!0});let o=h=>h?new this(null,h.graph,h.callee,i):m(e,a=>c(this.create(a,r,i))),c=h=>{if(h.graph.originalSource&&!h.graph.originalSourceModified){let a=`${i.async||h.graph.hoistedAwaitKeyword?"async ":""}function ${t||"anonymous"}`,l=h.graph.originalSource.split(/\n/g).map(p=>` ${p}`).join(`
`);h.graph.originalSource=`${a}(${r.join(", ")}) {
${c}
${l}
}`,h.graph.originalSourceModified=!0}return t&&Object.defineProperty(h.callee,"name",{configurable:!0,value:t}),h},u=this.prototype.createFunction(o,n);return x(u,"locations",m(e,h=>({locations:h.locations}))),u}};function P(...f){if(typeof window!="object")throw new Error("No window in context.");let t=v(typeof f[f.length-1]=="object"?f.pop():{}),e=O(f.pop()||""),r=f,i=n=>F.createFunction(void 0,n,r,t.runtimeParams,this,e);if(window.webqit?.SubscriptCompiler&&!t.runtimeParams.async){let{parse:n,compile:s}=window.webqit.SubscriptCompiler,o=n(e,t.parserParams);return i(s(o,t.compilerParams))}if(window.webqit=window.webqit||{},!window.webqit.SubscriptCompilerWorker){let o=`

@@ -6,0 +6,0 @@ const compilerUrls = [ '${(document.querySelector('meta[name="subscript-compiler-url"]')?.content.split(",")||[]).concat("https://unpkg.com/@webqit/subscript/dist/compiler.js").join("','")}' ];

@@ -1,6 +0,6 @@

(()=>{function $(...p){let e={runtimeParams:k,compilerParams:I,parserParams:A},t;for(;t=p.shift();){let{runtimeParams:i={},compilerParams:{globalsNoObserve:s=[],globalsOnlyPathsExcept:r=[],...n}={},parserParams:o={}}=t;e={runtimeParams:{...e.runtimeParams,...i},compilerParams:{...e.compilerParams,globalsNoObserve:[...e.compilerParams.globalsNoObserve,...s],globalsOnlyPathsExcept:[...e.compilerParams.globalsOnlyPathsExcept,...r],...n},parserParams:{...e.parserParams,...o}},p.devMode}return e}var A={ecmaVersion:"2020",allowReturnOutsideFunction:!0,allowAwaitOutsideFunction:!0,allowSuperOutsideMethod:!0,preserveParens:!1,locations:!1},I={globalsNoObserve:["globalThis","arguments","console","debugger"],globalsOnlyPathsExcept:[],originalSource:!0,locations:!0,compact:2},k={apiVersion:1};function O(p,e=!1){let t=p.split(/\n/g);if(t.length>1){for(;!t[0].trim().length;)t.shift();let i=t[e?1:0].split(/[^\s]/)[0].length;if(i)return t.map((s,r)=>{let n=s.substring(0,i);return n.trim().length?n.trim()==="}"&&r===t.length-1?"}":s:s.substring(i)}).join(`
`)}return p}var m=(p,e)=>p instanceof Promise?p.then(e):e(p);var M=new Map;function C(p,e,t=void 0){let i=M.get(p);if(arguments.length>2){i||(i=new Map,M.set(p,i)),i.set(e,t);return}return i&&i.get(e)}var v=class{constructor(e,t,i,s={},r=null,n=null){this.ownerContract=e,this.graph=t,this.callee=i,this.params=e?s:{...s,isSubscriptFunction:!0},this.exits=n||new Map,this.$thread=r||{entries:new Map,sequence:[],ownerContract:this},this.subContracts=new Map,this.observers=[],this.contract=function(o,l,u=null,h=null){if(!this.graph.subContracts[o])throw new Error(`[${this.graph.type}:${this.graph.lineage}]: Graph not found for child contract ${o}.`);let a=this.graph.subContracts[o],c={...this.params,isIterationContract:arguments.length===3,iterationId:arguments.length===3&&l,isFunctionContract:arguments.length===4,functionType:arguments.length===4&&l,isSubscriptFunction:arguments.length===4&&u,functionScope:this.params.isFunctionContract&&this.graph.lineage||this.params.functionScope};if(c.isIterationContract){let b=u,g=new v(this,a,b,c,this.$thread,this.exits),w=this.subContracts.get(o);return w||(w=new Map,this.subContracts.set(o,w)),w.has(c.iterationId)&&w.get(c.iterationId).dispose(),w.set(c.iterationId,g),g.call()}let f,y,d;if(this.subContracts.has(o)&&this.subContracts.get(o).dispose(),c.isFunctionContract){f=h;let b=()=>new v(this,a,f,c);if(c.functionType!=="FunctionDeclaration")d=this.createFunction(b);else{let g=b();c.apiVersion>1?(d=function(...w){let x=g.call(this,...w);return x=m(x,P=>[x,g.thread.bind(g),g]),g=b(),x},d.target=g):d=g}}else f=l,y=new v(this,a,f,c,this.$thread,this.exits),this.subContracts.set(o,y),d=y.call();return d}.bind(this),this.contract.memo=Object.create(null),this.ownerContract&&!["FunctionDeclaration","FunctionExpression"].includes(this.graph.type)&&(this.contract.args=this.ownerContract.contract.args),this.contract.exiting=function(o,l){if(!arguments.length)return this.exits.size;let u=this.exits.get(o)===l;return u&&this.exits.clear(),u}.bind(this),this.contract.exit=function(o,l){this.exits.set(o,l)}.bind(this),this.contract.functions=new Map,this.contract.functions.declaration=(o,l)=>{this.contract.functions.set(o,l),this.applyReflection(o,typeof l=="function"?l.target:l)}}fire(e,t,i){if(!this.ownerContract)return;let s=this.ownerContract.fire(e,t,i);return this.observers.forEach(r=>{r.contractUrl===e&&r.callback(t,i)}),s}observe(e,t){!this.params.isFunctionContract||this.observers.push({contractUrl:e,callback:t})}call(e,...t){if(this.disposed)throw new Error(`[${this.graph.type}:${this.graph.lineage}]: Instance not runable after having been disposed.`);this.ownerContract||(this.contract.args=t,Object.defineProperty(this.contract.args,Symbol.toStringTag,{value:"Arguments"}));let i=this.callee.call(e,this.contract,...t);if(this.graph.$sideEffects)for(let s in this.graph.effects)for(let r of this.graph.effects[s].refs)this.buildThread([],r,[],0,!0);return m(i,()=>{if(!this.ownerContract||this.params.isFunctionContract){let s=this.exits.get("return");if(this.exits.clear(),s!==void 0)return s}return i})}iterate(e=[]){if(this.disposed)return!1;if(!["ForOfStatement","ForInStatement"].includes(this.graph.type)||this.subContracts.size!==1)throw new Error(`Contract ${this.graph.lineage} is not an iterator.`);let[[,t]]=this.subContracts,i;if(!e.length||e.includes("length")&&this.graph.type==="ForOfStatement")for(let[,s]of t)i=m(i,()=>s.call());else for(let s of e){let r=t.get(s)||t.get(parseInt(s));!r||(i=m(i,()=>r.call()))}return i}thread(...e){if(this.disposed)return!1;this.$thread.active=!0;for(let t in this.graph.effects)for(let i of this.graph.effects[t].refs)for(let s of e){let[r,n,o]=this.matchRefs(s,i);!r||this.buildThread(s,i,o,n)}return this.runThread()}runThread(){let e=(r,n)=>{if(["ForOfStatement","ForInStatement"].includes(r.graph.type)&&n.every(o=>o.executionPlan.isIterationContractTarget)){let o=n.map(l=>l.executionPlan.iterationTarget);return this.fire(r.graph.lineage,"iterating",n),r.iterate(o)}return this.fire(r.graph.lineage,"executing",n),r.call()},t,i,s;for(;(i=this.$thread.sequence.shift())&&(s=[...this.$thread.entries.get(i)])&&this.$thread.entries.delete(i);)t=m(t,()=>{if(i.disposed||!i.filterRefs(s).length)return;this.$thread.current=i;let r=e(i,s);return m(r,()=>{for(let n of s)[].concat(n.executionPlan.assigneeRef||n.executionPlan.assigneeRefs||[]).forEach(o=>{i.buildThread([],o,[],0)})}),r});return m(t,()=>{let r=this.exits.get("return");return this.exits.clear(),this.$thread.current=null,this.$thread.active=!1,r})}buildThread(e,t,i,s=0,r=!1){let n=s>0;if(this.ownerContract){if(!this.compute(i)||t.condition!==void 0&&!this.assert(t.condition))return}else n||(n=i.length||t.condition!==void 0);let o=r?t.$subscriptions:t.subscriptions;Object.keys(o).forEach(l=>{let[u,h]=l.split(":"),a=f=>{!f||f.selectRefs(h,o[l],n?e:null)},c=this.locate(u);Array.isArray(c)?c.forEach(a):a(c)})}selectRefs(e,t,i=null){let s=this.$thread,r=this.graph.signals[e],n=(l,u)=>l.graph.lineage.localeCompare(u.graph.lineage,void 0,{numeric:!0}),o=(l,u=[],h={})=>{if(!s.active||s.current&&n(this,s.current)<0)return;let a=s.entries.get(this);if(a||(a=new Set,s.entries.set(this,a),s.sequence.push(this),s.sequence.sort(n)),a.add({...l,computes:u,executionPlan:h}),!h.assigneeRef&&["VariableDeclaration","AssignmentExpression"].includes(this.graph.type)){h.assigneeRefs=[];for(let c in this.graph.effects)h.assigneeRefs.push(...this.graph.effects[c].refs)}};for(let l of t){let u=r.refs[l];if(!i){o(u);continue}let[h,a,c]=this.matchRefs(i,u);if(!h)continue;if(a<=0){o(u,c);continue}let f=i.slice(-a),y="assignee"in r?this.graph.effects[r.assignee]:null;if(y){y.refs.forEach(d=>{if(d.depth.length){let[b,g,w]=this.matchRefs(f,d.depth),x=c.concat(w);if(b&&g>0){let P=d.path.concat(f.slice(-g));this.buildThread(P,d,x,g)}else b&&o(u,x,{assigneeRef:d})}else{let b=d.path.concat(f);this.buildThread(b,d,c,a)}});continue}if(a===1&&this.graph.type==="ForOfStatement"){o(u,c,{isIterationContractTarget:!0,iterationTarget:f[0]});continue}if(a===1&&this.graph.type==="ForInStatement"){o(u,c,{isIterationContractTarget:!0,iterationTarget:f[0]});continue}}}filterRefs(e){return e.filter(t=>{if(!!this.compute(t.computes)&&!(t.condition!==void 0&&!this.assert(t.condition)))return!0})}matchRefs(e,t){let i,s,r,n;Array.isArray(e)?(i=e,s=e.dotSafe?e.join("."):void 0):(i=e.path,s=e.$path),Array.isArray(t)?(r=t,n=t.dotSafe?t.join("."):void 0):(r=t.path,n=t.$path);let o=i.length-r.length;if(o>0&&([i,r,s,n]=[r,i,n,s]),s&&n)return[`${n}.`.startsWith(`${s}.`),o,[]];let l=[],u=a=>typeof a=="object"?a.name:a,h=(a,c)=>{if(!a||!c)return!1;let f=typeof a=="object"&&"memoId"in a,y=typeof c=="object"&&"memoId"in c;return f||y?(l.push(d=>(f?d[a.memoId]:u(a))===(y?d[c.memoId]:u(c))),!0):u(a)===u(c)};return[i.reduce((a,c,f)=>a&&h(c,r[f]),!0),o,l]}locate(e){let t=this.graph.lineage+"/",i=e+"/";if(i===t)return this;if(i.startsWith(t)){let s=e.slice(t.length).split("/"),r=this.subContracts.get(parseInt(s.shift()));if(s.length){if(r instanceof Map)return Array.from(r).reduce((n,[o,l])=>n.concat(l.locate(e)),[]);if(r)return r.locate(e)}return r}if(this.ownerContract)return this.ownerContract.locate(e)}compute(e){return!e.some(t=>t(this.contract.memo)===!1)}assert(e){if(typeof e=="string"&&e.includes(":")){let[s,r]=e.split(":");return this.locate(s).assert(r)}let t=this.graph.conditions[e],i=this.contract.memo;return typeof t.parent<"u"&&!this.assert(t.parent)?!1:typeof t.switch<"u"?t.cases.some(s=>i[s]===i[t.switch]):typeof t.whenNot<"u"?!i[t.whenNot]:typeof t.when<"u"?i[t.when]:!0}dispose(){this.params.isFunctionContract||(this.subContracts.forEach((e,t)=>{e instanceof Map?(e.forEach(i=>i.dispose()),e.clear()):e.dispose()}),this.subContracts.clear(),delete this.ownerContract,delete this.callee,delete this.params,delete this.contract.memo,this.disposed=!0)}createFunction(e,t=void 0){let i=e(),s=function(n,...o){let l=n.call(this===void 0?t:this,...o);return n.params.isSubscriptFunction&&n.params.apiVersion>1&&(l=m(l,u=>[u,n.thread.bind(n),n]),i=e(i)),l},r=i instanceof Promise||i.callee instanceof async function(){}.constructor?async function(){return m(i,n=>s.call(this,n,...arguments))}:function(){return s.call(this,i,...arguments)};return m(i,n=>{this.applyReflection(r,n)}),C(r,"properties",m(i,n=>{let o={type:n.params.functionType||"Program",apiVersion:n.params.apiVersion||1,isSubscriptFunction:n.params.isSubscriptFunction,sideEffects:n.graph.sideEffects||!1};if(n.params.isSubscriptFunction){o.dependencies=[];for(let[l,u]of Object.entries(n.graph.effects))o.dependencies.push(...u.refs.map(h=>h.path.map(a=>"name"in a?a.name:1/0)))}return o})),r}applyReflection(e,t){Object.defineProperty(t.callee,"length",{configurable:!0,value:t.callee.length-1});let i=t.callee.toString();Object.defineProperty(t.callee,"toString",{configurable:!0,value:(r=!1)=>!r&&t.graph.originalSource?t.graph.originalSource:i});let s={name:t.callee.name,length:t.callee.length,toString:t.callee.toString};t.params.isSubscriptFunction&&(t.params.apiVersion>1||(s={...s,thread:t.thread.bind(t),dispose:t.dispose.bind(t),runtime:t})),Object.keys(s).forEach(r=>{Object.defineProperty(e,r,{configurable:!0,value:s[r]})})}};var E=class extends v{static create(e,t=[],i={}){let r=i.async||e.graph.hoistedAwaitKeyword?Object.getPrototypeOf(async function(){}).constructor:Function,n=i.compileFunction?i.compileFunction(e.source,[e.identifier+""].concat(t)):new r(e.identifier+"",...t,e.source);return new this(null,e.graph,n,i)}static createFunction(e,t,i=[],s={},r,n=null){s={...s,functionType:"Constructor"},t instanceof Promise&&(s={...s,async:!0});let o=h=>h?new this(null,h.graph,h.callee,s):m(t,a=>l(this.create(a,i,s))),l=h=>{if(h.graph.originalSource&&!h.graph.originalSourceModified){let a=`${s.async||h.graph.hoistedAwaitKeyword?"async ":""}function ${e||"anonymous"}`,c=h.graph.originalSource.split(/\n/g).map(f=>` ${f}`).join(`
(()=>{function $(...p){let e={runtimeParams:k,compilerParams:I,parserParams:A},t;for(;t=p.shift();){let{runtimeParams:i={},compilerParams:{globalsNoObserve:r=[],globalsOnlyPathsExcept:s=[],...n}={},parserParams:o={}}=t;e={runtimeParams:{...e.runtimeParams,...i},compilerParams:{...e.compilerParams,globalsNoObserve:[...e.compilerParams.globalsNoObserve,...r],globalsOnlyPathsExcept:[...e.compilerParams.globalsOnlyPathsExcept,...s],...n},parserParams:{...e.parserParams,...o}},p.devMode}return e}var A={ecmaVersion:"2020",allowReturnOutsideFunction:!0,allowAwaitOutsideFunction:!0,allowSuperOutsideMethod:!0,preserveParens:!1,locations:!1},I={globalsNoObserve:["arguments","debugger"],globalsOnlyPathsExcept:[],originalSource:!0,locations:!0,compact:2},k={apiVersion:1};function O(p,e=!1){let t=p.split(/\n/g);if(t.length>1){for(;!t[0].trim().length;)t.shift();let i=t[e?1:0].split(/[^\s]/)[0].length;if(i)return t.map((r,s)=>{let n=r.substring(0,i);return n.trim().length?n.trim()==="}"&&s===t.length-1?"}":r:r.substring(i)}).join(`
`)}return p}var m=(p,e)=>p instanceof Promise?p.then(e):e(p);var M=new Map;function C(p,e,t=void 0){let i=M.get(p);if(arguments.length>2){i||(i=new Map,M.set(p,i)),i.set(e,t);return}return i&&i.get(e)}var v=class{constructor(e,t,i,r={},s=null,n=null){this.ownerContract=e,this.graph=t,this.callee=i,this.params=e?r:{...r,isSubscriptFunction:!0},this.exits=n||new Map,this.$thread=s||{entries:new Map,sequence:[],ownerContract:this},this.subContracts=new Map,this.observers=[],this.contract=function(o,l,u=null,h=null){if(!this.graph.subContracts[o])throw new Error(`[${this.graph.type}:${this.graph.lineage}]: Graph not found for child contract ${o}.`);let a=this.graph.subContracts[o],c={...this.params,isIterationContract:arguments.length===3,iterationId:arguments.length===3&&l,isFunctionContract:arguments.length===4,functionType:arguments.length===4&&l,isSubscriptFunction:arguments.length===4&&u,functionScope:this.params.isFunctionContract&&this.graph.lineage||this.params.functionScope};if(c.isIterationContract){let b=u,g=new v(this,a,b,c,this.$thread,this.exits),w=this.subContracts.get(o);return w||(w=new Map,this.subContracts.set(o,w)),w.has(c.iterationId)&&w.get(c.iterationId).dispose(),w.set(c.iterationId,g),g.call()}let f,y,d;if(this.subContracts.has(o)&&this.subContracts.get(o).dispose(),c.isFunctionContract){f=h;let b=()=>new v(this,a,f,c);if(c.functionType!=="FunctionDeclaration")d=this.createFunction(b);else{let g=b();c.apiVersion>1?(d=function(...w){let x=g.call(this,...w);return x=m(x,P=>[x,g.thread.bind(g),g]),g=b(),x},d.target=g):d=g}}else f=l,y=new v(this,a,f,c,this.$thread,this.exits),this.subContracts.set(o,y),d=y.call();return d}.bind(this),this.contract.memo=Object.create(null),this.ownerContract&&!["FunctionDeclaration","FunctionExpression"].includes(this.graph.type)&&(this.contract.args=this.ownerContract.contract.args),this.contract.exiting=function(o,l){if(!arguments.length)return this.exits.size;let u=this.exits.get(o)===l;return u&&this.exits.clear(),u}.bind(this),this.contract.exit=function(o,l){this.exits.set(o,l)}.bind(this),this.contract.functions=new Map,this.contract.functions.declaration=(o,l)=>{this.contract.functions.set(o,l),this.applyReflection(o,typeof l=="function"?l.target:l)}}fire(e,t,i){if(!this.ownerContract)return;let r=this.ownerContract.fire(e,t,i);return this.observers.forEach(s=>{s.contractUrl===e&&s.callback(t,i)}),r}observe(e,t){!this.params.isFunctionContract||this.observers.push({contractUrl:e,callback:t})}call(e,...t){if(this.disposed)throw new Error(`[${this.graph.type}:${this.graph.lineage}]: Instance not runable after having been disposed.`);this.ownerContract||(this.contract.args=t,Object.defineProperty(this.contract.args,Symbol.toStringTag,{value:"Arguments"}));let i=this.callee.call(e,this.contract,...t);if(this.graph.$sideEffects)for(let r in this.graph.effects)for(let s of this.graph.effects[r].refs)this.buildThread([],s,[],0,!0);return m(i,()=>{if(!this.ownerContract||this.params.isFunctionContract){let r=this.exits.get("return");if(this.exits.clear(),r!==void 0)return r}return i})}iterate(e=[]){if(this.disposed)return!1;if(!["ForOfStatement","ForInStatement"].includes(this.graph.type)||this.subContracts.size!==1)throw new Error(`Contract ${this.graph.lineage} is not an iterator.`);let[[,t]]=this.subContracts,i;if(!e.length||e.includes("length")&&this.graph.type==="ForOfStatement")for(let[,r]of t)i=m(i,()=>r.call());else for(let r of e){let s=t.get(r)||t.get(parseInt(r));!s||(i=m(i,()=>s.call()))}return i}thread(...e){if(this.disposed)return!1;this.$thread.active=!0;for(let t in this.graph.effects)for(let i of this.graph.effects[t].refs)for(let r of e){let[s,n,o]=this.matchRefs(r,i);!s||this.buildThread(r,i,o,n)}return this.runThread()}runThread(){let e=(s,n)=>{if(["ForOfStatement","ForInStatement"].includes(s.graph.type)&&n.every(o=>o.executionPlan.isIterationContractTarget)){let o=n.map(l=>l.executionPlan.iterationTarget);return this.fire(s.graph.lineage,"iterating",n),s.iterate(o)}return this.fire(s.graph.lineage,"executing",n),s.call()},t,i,r;for(;(i=this.$thread.sequence.shift())&&(r=[...this.$thread.entries.get(i)])&&this.$thread.entries.delete(i);)t=m(t,()=>{if(i.disposed||!i.filterRefs(r).length)return;this.$thread.current=i;let s=e(i,r);return m(s,()=>{for(let n of r)[].concat(n.executionPlan.assigneeRef||n.executionPlan.assigneeRefs||[]).forEach(o=>{i.buildThread([],o,[],0)})}),s});return m(t,()=>{let s=this.exits.get("return");return this.exits.clear(),this.$thread.current=null,this.$thread.active=!1,s})}buildThread(e,t,i,r=0,s=!1){let n=r>0;if(this.ownerContract){if(!this.compute(i)||t.condition!==void 0&&!this.assert(t.condition))return}else n||(n=i.length||t.condition!==void 0);let o=s?t.$subscriptions:t.subscriptions;Object.keys(o).forEach(l=>{let[u,h]=l.split(":"),a=f=>{!f||f.selectRefs(h,o[l],n?e:null)},c=this.locate(u);Array.isArray(c)?c.forEach(a):a(c)})}selectRefs(e,t,i=null){let r=this.$thread,s=this.graph.signals[e],n=(l,u)=>l.graph.lineage.localeCompare(u.graph.lineage,void 0,{numeric:!0}),o=(l,u=[],h={})=>{if(!r.active||r.current&&n(this,r.current)<0)return;let a=r.entries.get(this);if(a||(a=new Set,r.entries.set(this,a),r.sequence.push(this),r.sequence.sort(n)),a.add({...l,computes:u,executionPlan:h}),!h.assigneeRef&&["VariableDeclaration","AssignmentExpression"].includes(this.graph.type)){h.assigneeRefs=[];for(let c in this.graph.effects)h.assigneeRefs.push(...this.graph.effects[c].refs)}};for(let l of t){let u=s.refs[l];if(!i){o(u);continue}let[h,a,c]=this.matchRefs(i,u);if(!h)continue;if(a<=0){o(u,c);continue}let f=i.slice(-a),y="assignee"in s?this.graph.effects[s.assignee]:null;if(y){y.refs.forEach(d=>{if(d.depth.length){let[b,g,w]=this.matchRefs(f,d.depth),x=c.concat(w);if(b&&g>0){let P=d.path.concat(f.slice(-g));this.buildThread(P,d,x,g)}else b&&o(u,x,{assigneeRef:d})}else{let b=d.path.concat(f);this.buildThread(b,d,c,a)}});continue}if(a===1&&this.graph.type==="ForOfStatement"){o(u,c,{isIterationContractTarget:!0,iterationTarget:f[0]});continue}if(a===1&&this.graph.type==="ForInStatement"){o(u,c,{isIterationContractTarget:!0,iterationTarget:f[0]});continue}}}filterRefs(e){return e.filter(t=>{if(!!this.compute(t.computes)&&!(t.condition!==void 0&&!this.assert(t.condition)))return!0})}matchRefs(e,t){let i,r,s,n;Array.isArray(e)?(i=e,r=e.dotSafe?e.join("."):void 0):(i=e.path,r=e.$path),Array.isArray(t)?(s=t,n=t.dotSafe?t.join("."):void 0):(s=t.path,n=t.$path);let o=i.length-s.length;if(o>0&&([i,s,r,n]=[s,i,n,r]),r&&n)return[`${n}.`.startsWith(`${r}.`),o,[]];let l=[],u=a=>typeof a=="object"?a.name:a,h=(a,c)=>{if(!a||!c)return!1;let f=typeof a=="object"&&"memoId"in a,y=typeof c=="object"&&"memoId"in c;return f||y?(l.push(d=>(f?d[a.memoId]:u(a))===(y?d[c.memoId]:u(c))),!0):u(a)===u(c)};return[i.reduce((a,c,f)=>a&&h(c,s[f]),!0),o,l]}locate(e){let t=this.graph.lineage+"/",i=e+"/";if(i===t)return this;if(i.startsWith(t)){let r=e.slice(t.length).split("/"),s=this.subContracts.get(parseInt(r.shift()));if(r.length){if(s instanceof Map)return Array.from(s).reduce((n,[o,l])=>n.concat(l.locate(e)),[]);if(s)return s.locate(e)}return s}if(this.ownerContract)return this.ownerContract.locate(e)}compute(e){return!e.some(t=>t(this.contract.memo)===!1)}assert(e){if(typeof e=="string"&&e.includes(":")){let[r,s]=e.split(":");return this.locate(r).assert(s)}let t=this.graph.conditions[e],i=this.contract.memo;return typeof t.parent<"u"&&!this.assert(t.parent)?!1:typeof t.switch<"u"?t.cases.some(r=>i[r]===i[t.switch]):typeof t.whenNot<"u"?!i[t.whenNot]:typeof t.when<"u"?i[t.when]:!0}dispose(){this.params.isFunctionContract||(this.subContracts.forEach((e,t)=>{e instanceof Map?(e.forEach(i=>i.dispose()),e.clear()):e.dispose()}),this.subContracts.clear(),delete this.ownerContract,delete this.callee,delete this.params,delete this.contract.memo,this.disposed=!0)}createFunction(e,t=void 0){let i=e(),r=function(n,...o){let l=n.call(this===void 0?t:this,...o);return n.params.isSubscriptFunction&&n.params.apiVersion>1&&(l=m(l,u=>[u,n.thread.bind(n),n]),i=e(i)),l},s=i instanceof Promise||i.callee instanceof async function(){}.constructor?async function(){return m(i,n=>r.call(this,n,...arguments))}:function(){return r.call(this,i,...arguments)};return m(i,n=>{this.applyReflection(s,n)}),C(s,"properties",m(i,n=>{let o={type:n.params.functionType||"Program",apiVersion:n.params.apiVersion||1,isSubscriptFunction:n.params.isSubscriptFunction,sideEffects:n.graph.sideEffects||!1};if(n.params.isSubscriptFunction){o.dependencies=[];for(let[l,u]of Object.entries(n.graph.effects))o.dependencies.push(...u.refs.map(h=>h.path.map(a=>"name"in a?a.name:1/0)))}return o})),s}applyReflection(e,t){Object.defineProperty(t.callee,"length",{configurable:!0,value:t.callee.length-1});let i=t.callee.toString();Object.defineProperty(t.callee,"toString",{configurable:!0,value:(s=!1)=>!s&&t.graph.originalSource?t.graph.originalSource:i});let r={name:t.callee.name,length:t.callee.length,toString:t.callee.toString};t.params.isSubscriptFunction&&(t.params.apiVersion>1||(r={...r,thread:t.thread.bind(t),dispose:t.dispose.bind(t),runtime:t})),Object.keys(r).forEach(s=>{Object.defineProperty(e,s,{configurable:!0,value:r[s]})})}};var E=class extends v{static create(e,t=[],i={}){let s=i.async||e.graph.hoistedAwaitKeyword?Object.getPrototypeOf(async function(){}).constructor:Function,n=i.compileFunction?i.compileFunction(e.source,[e.identifier+""].concat(t)):new s(e.identifier+"",...t,e.source);return new this(null,e.graph,n,i)}static createFunction(e,t,i=[],r={},s,n=null){r={...r,functionType:"Constructor"},t instanceof Promise&&(r={...r,async:!0});let o=h=>h?new this(null,h.graph,h.callee,r):m(t,a=>l(this.create(a,i,r))),l=h=>{if(h.graph.originalSource&&!h.graph.originalSourceModified){let a=`${r.async||h.graph.hoistedAwaitKeyword?"async ":""}function ${e||"anonymous"}`,c=h.graph.originalSource.split(/\n/g).map(f=>` ${f}`).join(`
`);h.graph.originalSource=`${a}(${i.join(", ")}) {
${c}
}`,h.graph.originalSourceModified=!0}return e&&Object.defineProperty(h.callee,"name",{configurable:!0,value:e}),h},u=this.prototype.createFunction(o,r);return C(u,"locations",m(t,h=>({locations:h.locations}))),u}};function S(...p){if(typeof window!="object")throw new Error("No window in context.");let e=$(typeof p[p.length-1]=="object"?p.pop():{}),t=O(p.pop()||""),i=p,s=r=>E.createFunction(void 0,r,i,e.runtimeParams,this,t);if(window.webqit?.SubscriptCompiler&&!e.runtimeParams.async){let{parse:r,compile:n}=window.webqit.SubscriptCompiler,o=r(t,e.parserParams);return s(n(o,e.compilerParams))}if(window.webqit=window.webqit||{},!window.webqit.SubscriptCompilerWorker){let o=`
}`,h.graph.originalSourceModified=!0}return e&&Object.defineProperty(h.callee,"name",{configurable:!0,value:e}),h},u=this.prototype.createFunction(o,s);return C(u,"locations",m(t,h=>({locations:h.locations}))),u}};function S(...p){if(typeof window!="object")throw new Error("No window in context.");let e=$(typeof p[p.length-1]=="object"?p.pop():{}),t=O(p.pop()||""),i=p,r=s=>E.createFunction(void 0,s,i,e.runtimeParams,this,t);if(window.webqit?.SubscriptCompiler&&!e.runtimeParams.async){let{parse:s,compile:n}=window.webqit.SubscriptCompiler,o=s(t,e.parserParams);return r(n(o,e.compilerParams))}if(window.webqit=window.webqit||{},!window.webqit.SubscriptCompilerWorker){let o=`
const compilerUrls = [ '${(document.querySelector('meta[name="subscript-compiler-url"]')?.content.split(",")||[]).concat("https://unpkg.com/@webqit/subscript/dist/compiler.js").join("','")}' ];

@@ -17,3 +17,3 @@ ( function importScript() {

e.ports[ 0 ]?.postMessage( compilation );
};`;window.webqit.SubscriptCompilerWorker=new Worker(`data:text/javascript;base64,${btoa(o)}`)}return s(new Promise(r=>{let n=new MessageChannel;webqit.SubscriptCompilerWorker.postMessage({source:t,params:e},[n.port2]),n.port1.onmessage=o=>r(o.data)}))}Object.defineProperty(S,"inspect",{value:C});var j=p=>class extends p{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){[].concat(this.css).forEach(t=>{if(t.includes("{")&&t.includes(":")&&t.includes(";")){let i=this.shadowRoot.appendChild(document.createElement("style"));i.textContent=t}else{let i=this.shadowRoot.appendChild(document.createElement("link"));i.setAttribute("rel","stylesheet"),i.setAttribute("href",t)}})}get css(){return[]}};var F=class extends j(HTMLElement){connectedCallback(){this.autoMode=this.getAttribute("auto-mode"),this.visualizerElement=document.createElement("cfunctions-visualizer"),this.controlsElement=document.createElement("div"),this.controlsElement.classList.add("controls-element"),this.buttons={},["edit","play"].forEach(e=>{let t=e.substring(0,1).toUpperCase()+e.substring(1);this.buttons[e]=this.controlsElement.appendChild(document.createElement("button")),this.buttons[e].classList.add(e),this.buttons[e].setAttribute("title",t);let i=this.buttons[e].appendChild(document.createElement("i"));(this.getAttribute(`data-${e}-icon`)||`bi bi-${e==="edit"?"pencil":e}`).split(" ").map(n=>n.trim()).forEach(n=>i.classList.add(n)),this.buttons[e].appendChild(document.createElement("span")).append(" ",t),this.buttons[e].addEventListener("click",n=>{this.active&&this.active.classList.remove("active"),this.active=this.buttons[e],this.active.classList.add("active")})}),this.buttons.edit.addEventListener("click",e=>this.switchEditable(!0)),this.buttons.play.addEventListener("click",e=>this.switchEditable(!1)),this.shadowRoot.append(this.controlsElement,this.visualizerElement),super.connectedCallback(),setTimeout(()=>{this.visualizerElement.innerHTML=this.innerHTML,setTimeout(()=>{this.loadConsole(),this.autoMode&&this.buttons[this.autoMode].dispatchEvent(new MouseEvent("click"))},0)},0)}loadConsole(){this.fn=S(this.visualizerElement.source,{devMode:!0}),this.visualizerElement.visualize(this.fn,!1)}switchEditable(e){this.visualizerElement.editable=e,e?this.fn&&(this.fn.dispose(),this.fn=null):(this.fn||this.loadConsole(),this.fn())}get css(){return["https://cdn.jsdelivr.net/npm/bootstrap-icons@1.5.0/font/bootstrap-icons.css",`
};`;window.webqit.SubscriptCompilerWorker=new Worker(`data:text/javascript;base64,${btoa(o)}`)}return r(new Promise(s=>{let n=new MessageChannel;webqit.SubscriptCompilerWorker.postMessage({source:t,params:e},[n.port2]),n.port1.onmessage=o=>s(o.data)}))}Object.defineProperty(S,"inspect",{value:C});var j=p=>class extends p{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){[].concat(this.css).forEach(t=>{if(t.includes("{")&&t.includes(":")&&t.includes(";")){let i=this.shadowRoot.appendChild(document.createElement("style"));i.textContent=t}else{let i=this.shadowRoot.appendChild(document.createElement("link"));i.setAttribute("rel","stylesheet"),i.setAttribute("href",t)}})}get css(){return[]}};var F=class extends j(HTMLElement){connectedCallback(){this.autoMode=this.getAttribute("auto-mode"),this.visualizerElement=document.createElement("cfunctions-visualizer"),this.controlsElement=document.createElement("div"),this.controlsElement.classList.add("controls-element"),this.buttons={},["edit","play"].forEach(e=>{let t=e.substring(0,1).toUpperCase()+e.substring(1);this.buttons[e]=this.controlsElement.appendChild(document.createElement("button")),this.buttons[e].classList.add(e),this.buttons[e].setAttribute("title",t);let i=this.buttons[e].appendChild(document.createElement("i"));(this.getAttribute(`data-${e}-icon`)||`bi bi-${e==="edit"?"pencil":e}`).split(" ").map(n=>n.trim()).forEach(n=>i.classList.add(n)),this.buttons[e].appendChild(document.createElement("span")).append(" ",t),this.buttons[e].addEventListener("click",n=>{this.active&&this.active.classList.remove("active"),this.active=this.buttons[e],this.active.classList.add("active")})}),this.buttons.edit.addEventListener("click",e=>this.switchEditable(!0)),this.buttons.play.addEventListener("click",e=>this.switchEditable(!1)),this.shadowRoot.append(this.controlsElement,this.visualizerElement),super.connectedCallback(),setTimeout(()=>{this.visualizerElement.innerHTML=this.innerHTML,setTimeout(()=>{this.loadConsole(),this.autoMode&&this.buttons[this.autoMode].dispatchEvent(new MouseEvent("click"))},0)},0)}loadConsole(){this.fn=S(this.visualizerElement.source,{devMode:!0}),this.visualizerElement.visualize(this.fn,!1)}switchEditable(e){this.visualizerElement.editable=e,e?this.fn&&(this.fn.dispose(),this.fn=null):(this.fn||this.loadConsole(),this.fn())}get css(){return["https://cdn.jsdelivr.net/npm/bootstrap-icons@1.5.0/font/bootstrap-icons.css",`
* {

@@ -20,0 +20,0 @@ -webkit-box-sizing: border-box;

@@ -0,0 +0,0 @@ # Subscript

@@ -11,3 +11,3 @@ {

"homepage": "https://webqit.io/tooling/subscript",
"version": "2.1.40",
"version": "2.1.41",
"license": "MIT",

@@ -14,0 +14,0 @@ "repository": {

@@ -6,2 +6,6 @@ # Subscript Functions Proposal

> This is `@webqit/subscript@next` and the docs here is yet to be updated to reflect the few new changes.
>
> > `npm i @webqit/subscript@next`
## Table of Contents

@@ -8,0 +12,0 @@

@@ -0,0 +0,0 @@

@@ -0,0 +0,0 @@

@@ -0,0 +0,0 @@

@@ -0,0 +0,0 @@

@@ -0,0 +0,0 @@

@@ -0,0 +0,0 @@

@@ -0,0 +0,0 @@

@@ -0,0 +0,0 @@

@@ -0,0 +0,0 @@

@@ -0,0 +0,0 @@

@@ -0,0 +0,0 @@

@@ -0,0 +0,0 @@

@@ -0,0 +0,0 @@

@@ -0,0 +0,0 @@

@@ -0,0 +0,0 @@

@@ -0,0 +0,0 @@ /* PrismJS 1.26.0

@@ -0,0 +0,0 @@

@@ -0,0 +0,0 @@

@@ -0,0 +0,0 @@

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -31,3 +31,3 @@

export const compilerParams = {
globalsNoObserve: [ 'globalThis', 'arguments', 'console', 'debugger', ],
globalsNoObserve: [ 'arguments', 'debugger', ],
globalsOnlyPathsExcept: [],

@@ -34,0 +34,0 @@ originalSource: true,

@@ -0,0 +0,0 @@

@@ -0,0 +0,0 @@

@@ -0,0 +0,0 @@

@@ -0,0 +0,0 @@

@@ -0,0 +0,0 @@

@@ -0,0 +0,0 @@

@@ -0,0 +0,0 @@

@@ -0,0 +0,0 @@

@@ -0,0 +0,0 @@

@@ -0,0 +0,0 @@

@@ -0,0 +0,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc